//! Destructor. // TODO: ~PixmapFont(); public void DefineMapping(char codepoint, string image_name, float horz_advance) { var image = ImageManager.GetSingleton().Get(d_imageNamePrefix + '/' + image_name); var adv = (horz_advance == -1.0f) ? (float)(int)(image.GetRenderedSize().Width + image.GetRenderedOffset().X) : horz_advance; if (d_autoScaled != AutoScaledMode.Disabled) { adv *= d_origHorzScaling; } if (codepoint > d_maxCodepoint) { d_maxCodepoint = codepoint; } // create a new FontGlyph with given character code var glyph = new FontGlyph(adv, image, true); if (image.GetRenderedOffset().Y < -d_ascender) { d_ascender = -image.GetRenderedOffset().Y; } if (image.GetRenderedSize().Height + image.GetRenderedOffset().Y > -d_descender) { d_descender = -(image.GetRenderedSize().Height + image.GetRenderedOffset().Y); } d_height = d_ascender - d_descender; // add glyph to the map d_cp_map[codepoint] = glyph; }
/// <summary> /// Load all XML based imagesets required by the scheme. /// </summary> public void LoadXMLImagesets() { // check all imagesets foreach (var element in d_imagesets) { ImageManager.GetSingleton().LoadImageset(element.filename, element.resourceGroup); } }
/// <summary> /// Set the Image that will be drawn by this ImageryComponent. /// </summary> /// <param name="name"> /// String holding the name of the Image to be rendered. /// </param> public void SetImage(string name) { try { Image = ImageManager.GetSingleton().Get(name); } catch (UnknownObjectException) { Image = null; } }
/// <summary> /// cleanup the core system singleton objects /// </summary> protected void DestroySingletons() { // TODO: DestroySingletons() //CEGUI_DELETE_AO SchemeManager::getSingletonPtr(); //CEGUI_DELETE_AO WindowManager::getSingletonPtr(); //CEGUI_DELETE_AO WindowFactoryManager::getSingletonPtr(); //CEGUI_DELETE_AO WidgetLookManager::getSingletonPtr(); //CEGUI_DELETE_AO WindowRendererManager::getSingletonPtr(); //CEGUI_DELETE_AO AnimationManager::getSingletonPtr(); //CEGUI_DELETE_AO RenderEffectManager::getSingletonPtr(); FontManager.GetSingleton().Dispose(); ImageManager.GetSingleton().Dispose(); //CEGUI_DELETE_AO GlobalEventSet::getSingletonPtr(); }
/// <summary> /// Set an Image that will be drawn by this FrameComponent. /// </summary> /// <param name="part"> /// One of the FrameImageComponent enumerated values specifying the /// component image to be set. /// </param> /// <param name="name"> /// String holding the name of an Image. The image should already exist, /// if the Image does not exist an Exception will be logged and /// drawing of the component image specified by \a part will be /// disabled. /// </param> public void SetImage(FrameImageComponent part, string name) { Image image; try { image = ImageManager.GetSingleton().Get(name); } catch (UnknownObjectException) { image = null; } SetImage(part, image); }
//! Initialize the imageset. private void Reinit() { if (d_imagesetOwner) { ImageManager.GetSingleton().DestroyImageCollection(d_imageNamePrefix); } if (d_resourceGroup == "*") { d_imageNamePrefix = d_filename; d_imagesetOwner = false; } else { ImageManager.GetSingleton().LoadImageset(d_filename, d_resourceGroup); // here we assume the imageset name will match the font name d_imageNamePrefix = d_name; d_imagesetOwner = true; } }
/// <summary> /// Load all image file based imagesets required by the scheme. /// </summary> public void LoadImageFileImagesets() { var imgr = ImageManager.GetSingleton(); // check images that are created directly from image files foreach (var element in d_imagesetsFromImages) { // if name is empty use the name of the image file. if (String.IsNullOrEmpty(element.name)) { element.name = element.filename; } // see if image is present, and create it if not. if (!imgr.IsDefined(element.name)) { imgr.AddBitmapImageFromFile(element.name, element.filename, element.resourceGroup); } } }
/// <summary> /// Notification function to be called when the main display changes size. /// Client code should call this function when the host window changes size, /// or if the display resolution is changed in full-screen mode. /// /// Calling this function ensures that any other parts of the system that /// need to know about display size changes are notified. This affects /// things such as the Cursor default constraint area, and also the /// auto-scale functioning of Imagesets and Fonts. /// </summary> /// <param name="new_size"> /// Size object describing the new display size in pixels. /// </param> /// <remarks> /// This function will also fire the System::EventDisplaySizeChanged event. /// </remarks> public void NotifyDisplaySizeChanged(Sizef new_size) { // notify other components of the display size change ImageManager.GetSingleton().NotifyDisplaySizeChanged(new_size); FontManager.GetSingleton().NotifyDisplaySizeChanged(new_size); d_renderer.SetDisplaySize(new_size); InvalidateAllWindows(); // Fire event var handler = DisplaySizeChanged; if (handler != null) { handler(this, new DisplayEventArgs(new_size)); } Logger.LogEvent("Display resize:" + " w=" + PropertyHelper.ToString(new_size.Width) + " h=" + PropertyHelper.ToString(new_size.Height)); }
/// <summary> /// Set the current mouse cursor image /// </summary> /// <param name="name"> /// String object holding the name of the desired Image. /// </param> /// <exception cref="UnknownObjectException "> /// thrown if Image \a name is not known. /// </exception> public void SetImage(string name) { SetImage(ImageManager.GetSingleton().Get(name)); }
static PropertyHelper() { RegisterFunction <Boolean>( x => Boolean.Parse(x), x => ((Boolean)x).ToString(CultureInfo.InvariantCulture)); RegisterFunction <Byte>( x => Byte.Parse(x, CultureInfo.InvariantCulture), x => ((Byte)x).ToString(CultureInfo.InvariantCulture)); RegisterFunction <Int16>( x => Int16.Parse(x, CultureInfo.InvariantCulture), x => ((Int16)x).ToString(CultureInfo.InvariantCulture)); RegisterFunction <Int32>( x => Int32.Parse(x, CultureInfo.InvariantCulture), x => ((Int32)x).ToString(CultureInfo.InvariantCulture)); RegisterFunction <Int64>( x => Int64.Parse(x, CultureInfo.InvariantCulture), x => ((Int64)x).ToString(CultureInfo.InvariantCulture)); RegisterFunction <UInt16>( x => UInt16.Parse(x, CultureInfo.InvariantCulture), x => ((UInt16)x).ToString(CultureInfo.InvariantCulture)); RegisterFunction <UInt32>( x => UInt32.Parse(x, CultureInfo.InvariantCulture), x => ((UInt32)x).ToString(CultureInfo.InvariantCulture)); RegisterFunction <UInt64>( x => UInt64.Parse(x, CultureInfo.InvariantCulture), x => ((UInt64)x).ToString(CultureInfo.InvariantCulture)); RegisterFunction <Char>( x => Char.Parse(x), x => ((Char)x).ToString(CultureInfo.InvariantCulture)); RegisterFunction <Single>( x => String.IsNullOrEmpty(x) ? 0f : Single.Parse(x, CultureInfo.InvariantCulture), x => ((Single)x).ToString(CultureInfo.InvariantCulture)); RegisterFunction <Double>( x => Double.Parse(x, CultureInfo.InvariantCulture), x => ((Double)x).ToString(CultureInfo.InvariantCulture)); RegisterFunction <String>( x => x, x => (string)x); RegisterFunction <Colour>( x => Colour.Parse(x), x => ((Colour)x).ToString()); RegisterFunction <ColourRect>( x => ColourRect.Parse(x, CultureInfo.InvariantCulture), x => x.ToString()); RegisterFunction <Sizef>( x => Sizef.Parse(x, CultureInfo.InvariantCulture), x => ((Sizef)x).ToString()); RegisterFunction <Lunatics.Mathematics.Vector3>( x => MathematicsEx.Vector3Parse(x, CultureInfo.InvariantCulture), x => MathematicsEx.ToString((Lunatics.Mathematics.Vector3)x)); RegisterFunction <Rectf>( x => Rectf.Parse(x, CultureInfo.InvariantCulture), x => ((Rectf)x).ToString()); RegisterFunction <Lunatics.Mathematics.Quaternion>( x => MathematicsEx.QuaternionParse(x, CultureInfo.InvariantCulture), x => MathematicsEx.ToString((Lunatics.Mathematics.Quaternion)x)); RegisterFunction <UDim>( x => UDim.Parse(x, CultureInfo.InvariantCulture), x => ((UDim)x).ToString()); RegisterFunction <UVector2>( x => UVector2.Parse(x, CultureInfo.InvariantCulture), x => ((UVector2)x).ToString()); RegisterFunction <USize>( x => USize.Parse(x, CultureInfo.InvariantCulture), x => ((USize)x).ToString()); RegisterFunction <URect>( x => URect.Parse(x, CultureInfo.InvariantCulture), x => ((URect)x).ToString()); RegisterFunction <UBox>( x => UBox.Parse(x, CultureInfo.InvariantCulture), x => ((UBox)x).ToString()); RegisterFunction <Image>( x => String.IsNullOrEmpty(x) ? null : ImageManager.GetSingleton().Get(x), x => x != null ? ((Image)x).GetName() : String.Empty); RegisterFunction <Font>( x => String.IsNullOrEmpty(x) ? null : FontManager.GetSingleton().Get(x), x => x != null ? ((Font)x).GetName() : String.Empty); RegisterFunction <FontMetricType>( x => (FontMetricType)Enum.Parse(typeof(FontMetricType), x, true), x => ((FontMetricType)x).ToString()); RegisterFunction <AspectMode>( x => (AspectMode)Enum.Parse(typeof(AspectMode), x, true), x => ((AspectMode)x).ToString()); RegisterFunction <HorizontalAlignment>( x => { HorizontalAlignment value; if (!Enum.TryParse(x, true, out value)) { switch (x.ToLowerInvariant()) { case "leftaligned": return(HorizontalAlignment.Left); case "centrealigned": return(HorizontalAlignment.Centre); case "rightaligned": return(HorizontalAlignment.Right); } } return(value); }, x => ((HorizontalAlignment)x).ToString()); RegisterFunction <VerticalAlignment>( x => { VerticalAlignment value; if (!Enum.TryParse(x, true, out value)) { switch (x.ToLowerInvariant()) { case "topaligned": return(VerticalAlignment.Top); case "centrealigned": return(VerticalAlignment.Centre); case "bottomaligned": return(VerticalAlignment.Bottom); } } return(value); }, x => ((VerticalAlignment)x).ToString()); RegisterFunction <VerticalTextFormatting>( x => (VerticalTextFormatting)Enum.Parse(typeof(VerticalTextFormatting), x, true), x => ((VerticalTextFormatting)x).ToString()); RegisterFunction <HorizontalTextFormatting>( x => (HorizontalTextFormatting)Enum.Parse(typeof(HorizontalTextFormatting), x, true), x => ((HorizontalTextFormatting)x).ToString()); RegisterFunction <AutoScaledMode>( x => { AutoScaledMode value; if (!Enum.TryParse(x, true, out value)) { if (x.ToLowerInvariant() == "false") { return(AutoScaledMode.Disabled); } } return(value); }, x => ((AutoScaledMode)x).ToString()); RegisterFunction <VerticalFormatting>( x => (VerticalFormatting)Enum.Parse(typeof(VerticalFormatting), x, true), x => ((VerticalFormatting)x).ToString()); RegisterFunction <HorizontalFormatting>( x => (HorizontalFormatting)Enum.Parse(typeof(HorizontalFormatting), x, true), x => ((HorizontalFormatting)x).ToString()); RegisterFunction <FrameImageComponent>( x => (FrameImageComponent)Enum.Parse(typeof(FrameImageComponent), x, true), x => ((FrameImageComponent)x).ToString()); RegisterFunction <DimensionType>( x => (DimensionType)Enum.Parse(typeof(DimensionType), x, true), x => ((DimensionType)x).ToString()); RegisterFunction <DimensionOperator>( x => (DimensionOperator)Enum.Parse(typeof(DimensionOperator), x, true), x => ((DimensionOperator)x).ToString()); RegisterFunction <WindowUpdateMode>( x => (WindowUpdateMode)Enum.Parse(typeof(WindowUpdateMode), x, true), x => ((WindowUpdateMode)x).ToString()); RegisterFunction <ScrollbarDisplayMode>( x => (ScrollbarDisplayMode)Enum.Parse(typeof(ScrollbarDisplayMode), x, true), x => ((ScrollbarDisplayMode)x).ToString()); RegisterFunction <ViewSortMode>( x => (ViewSortMode)Enum.Parse(typeof(ViewSortMode), x, true), x => ((ViewSortMode)x).ToString()); RegisterFunction <Tuple <float, float> >( x => { throw new NotImplementedException(); }, x => String.Format("min:{0} max:{1}", ((Tuple <float, float>)x).Item1, ((Tuple <float, float>)x).Item1)); #region Types from Widgets RegisterFunction <ListHeaderSegment.SortDirection>( x => (ListHeaderSegment.SortDirection)Enum.Parse(typeof(ListHeaderSegment.SortDirection), x, true), x => ((ListHeaderSegment.SortDirection)x).ToString()); RegisterFunction <MultiColumnList.SelectionMode>( x => (MultiColumnList.SelectionMode)Enum.Parse(typeof(MultiColumnList.SelectionMode), x, true), x => ((MultiColumnList.SelectionMode)x).ToString()); RegisterFunction <ItemListBase.SortMode>( x => (ItemListBase.SortMode)Enum.Parse(typeof(ItemListBase.SortMode), x, true), x => ((ItemListBase.SortMode)x).ToString()); RegisterFunction <Spinner.TextInputMode>( x => (Spinner.TextInputMode)Enum.Parse(typeof(Spinner.TextInputMode), x, true), x => ((Spinner.TextInputMode)x).ToString()); RegisterFunction <GridLayoutContainer.AutoPositioning>( x => (GridLayoutContainer.AutoPositioning)Enum.Parse(typeof(GridLayoutContainer.AutoPositioning), x, true), x => ((GridLayoutContainer.AutoPositioning)x).ToString()); #endregion }