private void DrawOpenedAreaScrollbar(float scrollbarInnerTexturePositionX, MyRectangle2D openedArea, float transitionAlpha)
        {
            var margin = m_styleDef.ScrollbarMargin;

            var pos = GetPositionAbsoluteBottomRight() + new Vector2(-(margin.Right + m_scrollbarTexture.MinSizeGui.X),
                                                                     margin.Top + m_scrollBarCurrentPosition);
            m_scrollbarTexture.Draw(pos, m_scrollBarHeight - m_scrollbarTexture.MinSizeGui.Y, ApplyColorMaskModifiers(ColorMask, Enabled, transitionAlpha));
        }
        public override void Draw(float transitionAlpha)
        {
            base.Draw(transitionAlpha);
            var textArea = new MyRectangle2D(Vector2.Zero, Size);
            textArea.LeftTop += GetPositionAbsoluteTopLeft();
            Vector2 carriageOffset = GetCarriageOffset(CarriagePositionIndex);

            var scissor = new RectangleF(textArea.LeftTop, textArea.Size);
            using (MyGuiManager.UsingScissorRectangle(ref scissor))
            {
                DrawSelectionBackgrounds(textArea, transitionAlpha);
                DrawText(m_scrollbar.Value);


                //  Draw carriage line
                //  Carriage blinker time is solved here in Draw because I want to be sure it will be drawn even in low FPS
                if (HasFocus && Selectable)
                {
                    //  This condition controls "blinking", so most often is carrier visible and blinks very fast
                    //  It also depends on FPS, but as we have max FPS set to 60, it won't go faster, nor will it omit a "blink".
                    int carriageInterval = m_carriageBlinkerTimer % 20;
                    if ((carriageInterval >= 0) && (carriageInterval <= 15))
                    {
                        MyGuiManager.DrawSpriteBatch(MyGuiConstants.BLANK_TEXTURE,
                            textArea.LeftTop + carriageOffset,
                            1,
                            GetCarriageHeight(),
                            ApplyColorMaskModifiers(Vector4.One, Enabled, transitionAlpha),
                            MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
                    }
                }
                m_carriageBlinkerTimer++;

                if (m_drawScrollbar)
                    m_scrollbar.Draw(ApplyColorMaskModifiers(ColorMask, Enabled, transitionAlpha));
            }
            //m_scrollbar.DebugDraw();
        }
 private void RefreshTextArea()
 {
     m_textAreaRelative = new MyRectangle2D(MyGuiConstants.TEXTBOX_TEXT_OFFSET, Size - 2 * MyGuiConstants.TEXTBOX_TEXT_OFFSET);
 }
        private void DrawSelectionBackgrounds(MyRectangle2D textArea, float transitionAlpha)
        {
            var lines = Text.ToString().Substring(m_selection.Start, m_selection.Length).Split('\n');
            int currentPos = m_selection.Start;
            foreach (var line in lines)
            {
                Vector2 selectionPos = textArea.LeftTop + GetCarriageOffset(currentPos);
                Vector2 normalizedSize = GetCarriageOffset(currentPos + line.Length) - GetCarriageOffset(currentPos);
                Vector2 selectionSize = new Vector2(normalizedSize.X, GetCarriageHeight());
                MyGuiManager.DrawSpriteBatch(MyGuiConstants.BLANK_TEXTURE,
                        selectionPos,
                        selectionSize,
                        ApplyColorMaskModifiers(new Vector4(1, 1, 1, 0.5f), Enabled, transitionAlpha),
                        MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP
                   );

                currentPos += line.Length +1 ; //+1 because of \n that split cuts out
            }
        }