Exemplo n.º 1
0
        private Font InternalGetFont(Renderer.RendererBase renderer, string faceName, int size, FontStyle style)
        {
            string id = String.Format("{0};{1};{2}", faceName, size, (int)style);
            Font   font;

            if (!m_FontCache.TryGetValue(id, out font))
            {
                font = new Font(renderer, faceName, size);

                if ((style & FontStyle.Bold) != 0)
                {
                    font.Bold = true;
                }
                if ((style & FontStyle.Italic) != 0)
                {
                    font.Italic = true;
                }
                if ((style & FontStyle.Underline) != 0)
                {
                    font.Underline = true;
                }
                if ((style & FontStyle.Strikeout) != 0)
                {
                    font.Strikeout = true;
                }

                m_FontCache[id] = font;
            }

            return(font);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Renders the currently visible tooltip.
        /// </summary>
        /// <param name="skin"></param>
        public static void RenderToolTip(Skin.SkinBase skin)
        {
            if (null == g_ToolTip)
            {
                return;
            }

            Renderer.RendererBase render = skin.Renderer;

            Point     oldRenderOffset = render.RenderOffset;
            Point     mousePos        = Input.InputHandler.MousePosition;
            Rectangle bounds          = g_ToolTip.ToolTip.Bounds;

            Rectangle offset = Util.FloatRect(mousePos.X - bounds.Width / 2, mousePos.Y - bounds.Height - 10, bounds.Width, bounds.Height);

            offset = Util.ClampRectToRect(offset, g_ToolTip.GetCanvas().Bounds);

            //Calculate offset on screen bounds
            render.AddRenderOffset(offset);
            render.EndClip();

            skin.DrawToolTip(g_ToolTip.ToolTip);
            g_ToolTip.ToolTip.DoRender(skin);

            render.RenderOffset = oldRenderOffset;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Texture"/> class.
 /// </summary>
 /// <param name="renderer">Renderer to use.</param>
 public Texture(Renderer.RendererBase renderer)
 {
     m_Renderer = renderer;
     Width      = 4;
     Height     = 4;
     Failed     = false;
 }
Exemplo n.º 4
0
        public static Font GetFont(Renderer.RendererBase renderer, string faceName, int size = 10, FontStyle style = 0)
        {
            if (m_Instance == null)
            {
                m_Instance = new FontCache();
            }

            return(m_Instance.InternalGetFont(renderer, faceName, size, style));
        }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Font"/> class.
 /// </summary>
 /// <param name="renderer">Renderer to use.</param>
 /// <param name="faceName">Face name.</param>
 /// <param name="size">Font size.</param>
 public Font(Renderer.RendererBase renderer, string faceName, int size = 10)
 {
     m_Renderer    = renderer;
     m_FontMetrics = null;
     FaceName      = faceName;
     Size          = size;
     Smooth        = false;
     Bold          = false;
     Italic        = false;
     Underline     = false;
     Strikeout     = false;
     //DropShadow = false;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Font"/> class.
 /// </summary>
 public Font(Renderer.RendererBase renderer)
     : this(renderer, "Arial", 10)
 {
 }
Exemplo n.º 7
0
 /// <summary>
 /// Create a new font instance. This function uses a font cache to load the font.
 /// This is preferable method to create a font. User don't need to worry about
 /// disposing the font.
 /// </summary>
 /// <param name="renderer">Renderer to use.</param>
 /// <param name="faceName">Face name.</param>
 /// <param name="size">Font size.</param>
 /// <param name="style">Font style.</param>
 /// <returns>Font.</returns>
 public static Font Create(Renderer.RendererBase renderer, string faceName, int size = 10, FontStyle style = 0)
 {
     return(FontCache.GetFont(renderer, faceName, size, style));
 }