示例#1
0
        protected override void RenderContent()
        {
            base.RenderContent();

            TrueTypeFont font = Renderer.GetFont();

            Color4 textColour = Color4.Black;

            int     cY      = (GetContentHeight() / 2) - (font.GetTextHeight(_text) / 2);
            Vector3 textPos = new Vector3();

            textPos.X = _offsetX + 1;
            textPos.Y = cY;
            Renderer.PrintText(_text, ref textPos, ref textColour, ref textColour);

            int cursorX = font.GetTextWidth(_text.Substring(0, _cursorPos));

            cursorX += _offsetX;
            if (_active)
            {
                Vector3 position = new Vector3(cursorX, 1, 0);
                Vector3 scale    = new Vector3(2, GetContentHeight() - 2, 1);
                Renderer.FillShape(ShapeFactory.Rectangle, ref position, ref scale, ref textColour);
            }
        }
示例#2
0
        protected override void RenderContent()
        {
            base.RenderContent();
            //System.Diagnostics.Debug.WriteLine("Cursor Col: {0}, cursor Row: {1}",_cursorColumn, _cursorRow);
            TrueTypeFont font       = Renderer.GetFont();
            int          lineHeight = font.GetLineHeight();

            Vector3 textPos = new Vector3();

            for (int i = 0; i < _lines.Count; i++)
            {
                string text   = _lines[i];
                Color4 colour = Color4.Black;
                textPos.Y = lineHeight - font.GetTextHeight(text) + (i * lineHeight);
                Renderer.PrintText(text, ref textPos, ref colour, ref colour);
            }
            if (_active)
            {
                try
                {
                    int     cursorX  = font.GetTextWidth(_lines[_cursorRow].Substring(0, _cursorColumn)) + 1;
                    Vector3 position = new Vector3(cursorX, (_cursorRow * lineHeight) + 1, 0);
                    Vector3 scale    = new Vector3(2, lineHeight, 1);
                    Color4  colour   = Color4.Black;
                    Renderer.FillShape(ShapeFactory.Rectangle, ref position, ref scale, ref colour);
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine("cursor X error in TextBox.cs render.\n" + e.Message);
                    _cursorColumn--; // emergency fix
                }
            }
        }