Beispiel #1
0
        /// <summary>
        /// Load all xml based fonts required by the scheme.
        /// </summary>
        public void LoadFonts()
        {
            var fntmgr = FontManager.GetSingleton();

            // check fonts
            foreach (var element in d_fonts)
            {
                // skip if a font with this name is already loaded
                if (!String.IsNullOrEmpty(element.name) && fntmgr.IsDefined(element.name))
                {
                    continue;
                }

                // create font using specified xml file.
                var font     = fntmgr.CreateFromFile(element.filename, element.resourceGroup);
                var realname = font.GetName();

                // if name was not in scheme, set it now and proceed to next font
                if (String.IsNullOrEmpty(element.name))
                {
                    element.name = realname;
                    continue;
                }

                // confirm the font loaded has same name specified in scheme
                if (realname != element.name)
                {
                    fntmgr.Destroy(font);
                    throw new InvalidRequestException(
                              "The Font created by file '" + element.filename +
                              "' is named '" + realname + "', not '" + element.name +
                              "' as required by Scheme '" + d_name + "'.");
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Return a pointer to the default Font for the GUIContext
        /// </summary>
        /// <returns>
        /// Pointer to a Font object that is the default for this GUIContext.
        /// </returns>
        public Font GetDefaultFont()
        {
            if (d_defaultFont != null)
            {
                return(d_defaultFont);
            }

            // if no explicit default, we will return the first font we can get from
            // the font manager
            return(FontManager.GetSingleton().Iterator.FirstOrDefault());
        }
Beispiel #3
0
 /// <summary>
 /// Set the default font to be used by the GUIContext.
 /// </summary>
 /// <param name="name">
 /// String object containing the name of the font to be used as the
 /// default for this GUIContext
 /// </param>
 public void SetDefaultFont(string name)
 {
     if (String.IsNullOrEmpty(name))
     {
         SetDefaultFont((Font)null);
     }
     else
     {
         SetDefaultFont(FontManager.GetSingleton().Get(name));
     }
 }
Beispiel #4
0
 /// <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();
 }
Beispiel #5
0
 /// <summary>
 /// helper to get the font object to use
 /// </summary>
 /// <param name="window"></param>
 /// <returns></returns>
 protected Font GetFontObject(Window window)
 {
     try
     {
         return(String.IsNullOrEmpty(_fontPropertyName)
                    ? (String.IsNullOrEmpty(_font)
                           ? window.GetFont()
                           : FontManager.GetSingleton().Get(_font))
                    : FontManager.GetSingleton().Get(window.GetProperty(_fontPropertyName)));
     }
     catch (UnknownObjectException)
     {
         return(null);
     }
 }
Beispiel #6
0
        /// <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));
        }
        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
        }
 /// <summary>
 /// set the font to use when rendering the text.
 /// </summary>
 /// <param name="fontName"></param>
 public void SetFont(string fontName)
 {
     d_font = String.IsNullOrEmpty(fontName)
                      ? null
                      : FontManager.GetSingleton().Get(fontName);
 }
 public RenderedStringTextComponent(string text, string fontName)
     : this(text, String.IsNullOrEmpty(fontName) ? null : FontManager.GetSingleton().Get(fontName))
 {
 }
Beispiel #10
0
 protected Font GetFontObject(Window window)
 {
     return(String.IsNullOrEmpty(_font)
                ? window.GetFont()
                : FontManager.GetSingleton().Get(_font));
 }