Example #1
0
        public override void InternalRender(RenderContext context)
        {
            if (_rowInfosDirty)
            {
                UpdateRowInfos();
                _rowInfosDirty = false;
            }

            if (HoverRow != null && HoverRow != SelectedRow && RowHoverBackground != null)
            {
                context.Draw(RowHoverBackground, HoverRow.RowBounds);
            }

            if (SelectedRow != null && SelectedRow.RowVisible && RowSelectionBackground != null)
            {
                if (!IsFocused && RowSelectionBackgroundWithoutFocus != null)
                {
                    context.Draw(RowSelectionBackgroundWithoutFocus, SelectedRow.RowBounds);
                }
                else
                {
                    context.Draw(RowSelectionBackground, SelectedRow.RowBounds);
                }
            }

            base.InternalRender(context);
        }
Example #2
0
        public override void InternalRender(RenderContext context)
        {
            if (Widget == null || !Widget.Visible)
            {
                return;
            }

            // Render child
            base.InternalRender(context);

            if (_horizontalScrollbarVisible)
            {
                if (HorizontalScrollBackground != null)
                {
                    context.Draw(HorizontalScrollBackground, _horizontalScrollbarFrame);
                }

                var r = _horizontalScrollbarThumb;
                r.X += _scrollPosition.X;
                context.Draw(HorizontalScrollKnob, r);
            }

            if (_verticalScrollbarVisible)
            {
                if (VerticalScrollBackground != null)
                {
                    context.Draw(VerticalScrollBackground, _verticalScrollbarFrame);
                }

                var r = _verticalScrollbarThumb;
                r.Y += _scrollPosition.Y;
                context.Draw(VerticalScrollKnob, r);
            }
        }
Example #3
0
        public override void InternalRender(RenderContext context)
        {
            var image = Renderable;

            if (UseHoverRenderable && OverRenderable != null)
            {
                image = OverRenderable;
            }

            if (IsPressed && PressedRenderable != null)
            {
                image = PressedRenderable;
            }

            if (image != null)
            {
                var bounds = ActualBounds;

                if (ResizeMode == ImageResizeMode.KeepAspectRatio)
                {
                    var aspect = (float)image.Size.X / image.Size.Y;
                    bounds.Height = (int)(bounds.Width * aspect);
                }

                context.Draw(image, bounds, Color);
            }
        }
Example #4
0
        public void RenderVisual()
        {
            EnsureRenderContext();

            var oldScissorRectangle = CrossEngineStuff.GetScissor();

            _renderContext.Begin();

            CrossEngineStuff.SetScissor(InternalBounds);
            _renderContext.View    = InternalBounds;
            _renderContext.Opacity = Opacity;

            if (Stylesheet.Current.DesktopStyle != null &&
                Stylesheet.Current.DesktopStyle.Background != null)
            {
                _renderContext.Draw(Stylesheet.Current.DesktopStyle.Background, InternalBounds);
            }

            foreach (var widget in ChildrenCopy)
            {
                if (widget.Visible)
                {
                    widget.Render(_renderContext);
                }
            }

            _renderContext.End();

            CrossEngineStuff.SetScissor(oldScissorRectangle);
        }
Example #5
0
        public void Render()
        {
            var newBounds = BoundsFetcher();

            if (_bounds != newBounds)
            {
                InvalidateLayout();
            }

            _bounds = newBounds;

            if (_bounds.IsEmpty)
            {
                return;
            }

            UpdateInput();
            UpdateLayout();

            if (_scheduleMouseWheelFocus != null)
            {
                if (_scheduleMouseWheelFocus.AcceptsMouseWheelFocus)
                {
                    _previousMouseWheelFocus = FocusedMouseWheelWidget;
                    FocusedMouseWheelWidget  = _scheduleMouseWheelFocus;
                }

                _scheduleMouseWheelFocus = null;
            }

            EnsureRenderContext();

            var oldScissorRectangle = CrossEngineStuff.GetScissor();

            _renderContext.Begin();

            CrossEngineStuff.SetScissor(_bounds);
            _renderContext.View    = _bounds;
            _renderContext.Opacity = Opacity;

            if (Stylesheet.Current.DesktopStyle != null &&
                Stylesheet.Current.DesktopStyle.Background != null)
            {
                _renderContext.Draw(Stylesheet.Current.DesktopStyle.Background, _bounds);
            }

            foreach (var widget in ChildrenCopy)
            {
                if (widget.Visible)
                {
                    widget.Render(_renderContext);
                }
            }

            _renderContext.End();

            CrossEngineStuff.SetScissor(oldScissorRectangle);
        }
Example #6
0
        public override void InternalRender(RenderContext context)
        {
            if (_formattedText.Font == null)
            {
                return;
            }

            var bounds = ActualBounds;

            RenderSelection(context);

            var textColor = TextColor;

            if (!Enabled && DisabledTextColor != null)
            {
                textColor = DisabledTextColor.Value;
            }
            else if (IsKeyboardFocused && FocusedTextColor != null)
            {
                textColor = FocusedTextColor.Value;
            }

            var centeredBounds = LayoutUtils.Align(new Point(bounds.Width, bounds.Height), _formattedText.Size, HorizontalAlignment.Left, TextVerticalAlignment);

            centeredBounds.Offset(bounds.Location);

            var p = new Point(centeredBounds.Location.X - _internalScrolling.X,
                              centeredBounds.Location.Y - _internalScrolling.Y);

            _formattedText.Draw(context.Batch,
                                p,
                                context.View, textColor, context.Opacity);

            if (!IsKeyboardFocused)
            {
                // Skip cursor rendering if the widget doesnt have the focus
                return;
            }

            var now = DateTime.Now;

            if ((now - _lastBlinkStamp).TotalMilliseconds >= BlinkIntervalInMs)
            {
                _cursorOn       = !_cursorOn;
                _lastBlinkStamp = now;
            }

            if (Enabled && _cursorOn && Cursor != null)
            {
                p    = GetRenderPositionByIndex(CursorPosition);
                p.X -= _internalScrolling.X;
                p.Y -= _internalScrolling.Y;
                context.Draw(Cursor,
                             new Rectangle(p.X, p.Y,
                                           Cursor.Size.X,
                                           CrossEngineStuff.LineSpacing(_formattedText.Font)));
            }
        }
Example #7
0
        public override void InternalRender(RenderContext context)
        {
            if (_formattedText.Font == null)
            {
                return;
            }

            var bounds = ActualBounds;

            var textColor = TextColor;

            if (!Enabled && DisabledTextColor != null)
            {
                textColor = DisabledTextColor.Value;
            }
            else if (IsFocused && FocusedTextColor != null)
            {
                textColor = FocusedTextColor.Value;
            }

            var centeredBounds = LayoutUtils.Align(bounds.Size, _formattedText.Size, HorizontalAlignment.Left, VerticalAlignment.Center);

            centeredBounds.Offset(bounds.Location);
            _formattedText.Draw(context.Batch, centeredBounds, textColor, context.Opacity);

            if (!IsFocused)
            {
                // Skip cursor rendering if the widget doesnt have the focus
                return;
            }

            var now = DateTime.Now;

            if ((now - _lastBlinkStamp).TotalMilliseconds >= BlinkIntervalInMs)
            {
                _cursorOn       = !_cursorOn;
                _lastBlinkStamp = now;
            }

            if (_cursorOn && Cursor != null)
            {
                var x           = bounds.X;
                var y           = bounds.Y;
                var glyphRender = _formattedText.GetGlyphInfoByIndex(_cursorIndex - 1);
                if (glyphRender != null && glyphRender.TextRun.RenderedPosition != null)
                {
                    x = glyphRender.TextRun.RenderedPosition.Value.X + glyphRender.Bounds.Right;
                    y = glyphRender.TextRun.RenderedPosition.Value.Y;
                }

                context.Draw(Cursor, new Rectangle(x,
                                                   y,
                                                   Cursor.Size.X,
                                                   _formattedText.Font.LineSpacing));
            }
        }
Example #8
0
        public override void InternalRender(RenderContext context)
        {
            base.InternalRender(context);

            if (Drawable != null)
            {
                var bounds = ActualBounds;
                context.Draw(Drawable, bounds);
            }
        }
Example #9
0
File: Tree.cs Project: xvwvx/Myra
        public override void InternalRender(RenderContext context)
        {
            if (_rowInfosDirty)
            {
                UpdateRowInfos();
                _rowInfosDirty = false;
            }

            if (Active && HoverRow != null && HoverRow != SelectedRow && SelectionHoverBackground != null)
            {
                context.Draw(SelectionHoverBackground, HoverRow.RowBounds);
            }

            if (SelectedRow != null && SelectedRow.RowVisible && SelectionBackground != null)
            {
                context.Draw(SelectionBackground, SelectedRow.RowBounds);
            }

            base.InternalRender(context);
        }
Example #10
0
        public override void InternalRender(RenderContext context)
        {
            if (InternalChild == null || !InternalChild.Visible)
            {
                return;
            }

            // Render child
            base.InternalRender(context);

            var thumbPosition = ThumbPosition;

            if (_horizontalScrollingOn && ShowHorizontalScrollBar)
            {
                if (HorizontalScrollBackground != null)
                {
                    context.Draw(HorizontalScrollBackground, _horizontalScrollbarFrame);
                }

                var r = _horizontalScrollbarThumb;
                r.X += thumbPosition.X;
                context.Draw(HorizontalScrollKnob, r);
            }

            if (_verticalScrollingOn && ShowVerticalScrollBar)
            {
                if (VerticalScrollBackground != null)
                {
                    context.Draw(VerticalScrollBackground, _verticalScrollbarFrame);
                }

                var r = _verticalScrollbarThumb;
                r.Y += thumbPosition.Y;
                context.Draw(VerticalScrollKnob, r);
            }
        }
Example #11
0
        public override void InternalRender(RenderContext context)
        {
            var image = Renderable;

            if (IsMouseOver && OverRenderable != null)
            {
                image = OverRenderable;
            }

            if (IsPressed && PressedRenderable != null)
            {
                image = PressedRenderable;
            }

            if (image != null)
            {
                var bounds = ActualBounds;
                context.Draw(image, bounds, Color);
            }
        }
Example #12
0
        public void Render()
        {
            if (Bounds.IsEmpty)
            {
                return;
            }

            UpdateInput();
            UpdateLayout();

            EnsureRenderContext();

            var oldScissorRectangle = CrossEngineStuff.GetScissor();

            _renderContext.Begin();

            CrossEngineStuff.SetScissor(Bounds);
            _renderContext.View    = Bounds;
            _renderContext.Opacity = Opacity;

            if (Stylesheet.Current.DesktopStyle != null &&
                Stylesheet.Current.DesktopStyle.Background != null)
            {
                _renderContext.Draw(Stylesheet.Current.DesktopStyle.Background, Bounds);
            }

            foreach (var widget in ChildrenCopy)
            {
                if (widget.Visible)
                {
                    widget.Render(_renderContext);
                }
            }

            _renderContext.End();

            CrossEngineStuff.SetScissor(oldScissorRectangle);
        }
Example #13
0
        public virtual void Render(RenderContext context)
        {
            if (!Visible)
            {
                return;
            }

            UpdateLayout();

            var view = Rectangle.Intersect(context.View, Bounds);

            if (view.Width == 0 || view.Height == 0)
            {
                return;
            }

            var batch = context.Batch;
            var oldScissorRectangle = CrossEngineStuff.GetScissor();

            if (ClipToBounds && !MyraEnvironment.DisableClipping)
            {
                var newScissorRectangle = Rectangle.Intersect(oldScissorRectangle, view);

                if (newScissorRectangle.IsEmpty)
                {
                    return;
                }

                context.Flush();

                CrossEngineStuff.SetScissor(newScissorRectangle);
            }

            var oldOpacity = context.Opacity;

            context.Opacity *= Opacity;

            // Background
            var background = GetCurrentBackground();

            if (background != null)
            {
                context.Draw(background, Bounds);
            }

            var oldView = context.View;

            context.View = view;
            InternalRender(context);
            context.View = oldView;

            // Border
            var border = GetCurrentBorder();

            if (border != null)
            {
                context.Draw(border, Bounds);
            }

            if (MyraEnvironment.DrawWidgetsFrames)
            {
                batch.DrawRectangle(Bounds, Color.LightGreen);
            }

            if (MyraEnvironment.DrawFocusedWidgetFrame && IsFocused)
            {
                batch.DrawRectangle(Bounds, Color.Red);
            }

            if (ClipToBounds && !MyraEnvironment.DisableClipping)
            {
                context.Flush();
                CrossEngineStuff.SetScissor(oldScissorRectangle);
            }

            context.Opacity = oldOpacity;
        }
Example #14
0
        private void RenderSelection(RenderContext context)
        {
            var bounds = ActualBounds;

            if (string.IsNullOrEmpty(Text) || Selection == null)
            {
                return;
            }

            var selectStart = Math.Min(SelectStart, SelectEnd);
            var selectEnd   = Math.Max(SelectStart, SelectEnd);

            if (selectStart >= selectEnd)
            {
                return;
            }

            var startGlyph = _formattedText.GetGlyphInfoByIndex(selectStart);

            if (startGlyph == null)
            {
                return;
            }

            var lineIndex = startGlyph.TextChunk.LineIndex;
            var i         = selectStart;

            var lineHeight = CrossEngineStuff.LineSpacing(_formattedText.Font);

            while (true)
            {
                startGlyph = _formattedText.GetGlyphInfoByIndex(i);
                var startPosition = GetRenderPositionByIndex(i);

                var line = _formattedText.Lines[startGlyph.TextChunk.LineIndex];

                if (selectEnd < line.TextStartIndex + line.Count)
                {
                    var endPosition = GetRenderPositionByIndex(selectEnd);

                    context.Draw(Selection,
                                 new Rectangle(startPosition.X - _internalScrolling.X,
                                               startPosition.Y - _internalScrolling.Y,
                                               endPosition.X - startPosition.X,
                                               lineHeight));

                    break;
                }

                context.Draw(Selection,
                             new Rectangle(startPosition.X - _internalScrolling.X,
                                           startPosition.Y - _internalScrolling.Y,
                                           bounds.Left + startGlyph.TextChunk.Size.X - startPosition.X,
                                           lineHeight));

                ++lineIndex;
                if (lineIndex >= _formattedText.Lines.Count)
                {
                    break;
                }

                i = _formattedText.Lines[lineIndex].TextStartIndex;
            }
        }
Example #15
0
        private void RenderSelection(RenderContext context)
        {
            var bounds = ActualBounds;

            switch (GridSelectionMode)
            {
            case GridSelectionMode.None:
                break;

            case GridSelectionMode.Row:
            {
                if (HoverRowIndex != null && HoverRowIndex != SelectedRowIndex && SelectionHoverBackground != null)
                {
                    var rect = Rectangle.Intersect(new Rectangle(bounds.Left,
                                                                 _cellLocationsY[HoverRowIndex.Value] + bounds.Top - RowSpacing / 2,
                                                                 bounds.Width,
                                                                 _rowHeights[HoverRowIndex.Value] + RowSpacing), context.View);

                    context.Draw(SelectionHoverBackground, rect);
                }

                if (SelectedRowIndex != null && SelectionBackground != null)
                {
                    var rect = Rectangle.Intersect(new Rectangle(bounds.Left,
                                                                 _cellLocationsY[SelectedRowIndex.Value] + bounds.Top - RowSpacing / 2,
                                                                 bounds.Width,
                                                                 _rowHeights[SelectedRowIndex.Value] + RowSpacing), context.View);

                    context.Draw(SelectionBackground, rect);
                }
            }
            break;

            case GridSelectionMode.Column:
            {
                if (HoverColumnIndex != null && HoverColumnIndex != SelectedColumnIndex && SelectionHoverBackground != null)
                {
                    var rect = Rectangle.Intersect(new Rectangle(_cellLocationsX[HoverColumnIndex.Value] + bounds.Left - ColumnSpacing / 2,
                                                                 bounds.Top,
                                                                 _colWidths[HoverColumnIndex.Value] + ColumnSpacing,
                                                                 bounds.Height), context.View);

                    context.Draw(SelectionHoverBackground, rect);
                }

                if (SelectedColumnIndex != null && SelectionBackground != null)
                {
                    var rect = Rectangle.Intersect(new Rectangle(_cellLocationsX[SelectedColumnIndex.Value] + bounds.Left - ColumnSpacing / 2,
                                                                 bounds.Top,
                                                                 _colWidths[SelectedColumnIndex.Value] + ColumnSpacing,
                                                                 bounds.Height), context.View);

                    context.Draw(SelectionBackground, rect);
                }
            }
            break;

            case GridSelectionMode.Cell:
            {
                if (HoverRowIndex != null && HoverColumnIndex != null &&
                    (HoverRowIndex != SelectedRowIndex || HoverColumnIndex != SelectedColumnIndex) &&
                    SelectionHoverBackground != null)
                {
                    var rect = Rectangle.Intersect(new Rectangle(_cellLocationsX[HoverColumnIndex.Value] + bounds.Left - ColumnSpacing / 2,
                                                                 _cellLocationsY[HoverRowIndex.Value] + bounds.Top - RowSpacing / 2,
                                                                 _colWidths[HoverColumnIndex.Value] + ColumnSpacing,
                                                                 _rowHeights[HoverRowIndex.Value] + RowSpacing), context.View);

                    context.Draw(SelectionHoverBackground, rect);
                }

                if (SelectedRowIndex != null && SelectedColumnIndex != null && SelectionBackground != null)
                {
                    var rect = Rectangle.Intersect(new Rectangle(_cellLocationsX[SelectedColumnIndex.Value] + bounds.Left - ColumnSpacing / 2,
                                                                 _cellLocationsY[SelectedRowIndex.Value] + bounds.Top - RowSpacing / 2,
                                                                 _colWidths[SelectedColumnIndex.Value] + ColumnSpacing,
                                                                 _rowHeights[SelectedRowIndex.Value] + RowSpacing), context.View);

                    context.Draw(SelectionBackground, rect);
                }
            }
            break;
            }
        }
Example #16
0
        public void Render(RenderContext context)
        {
            if (!Visible)
            {
                return;
            }

            UpdateLayout();

            var view = Rectangle.Intersect(context.View, Bounds);

            if (view.Width == 0 || view.Height == 0)
            {
                return;
            }

            var batch = context.Batch;
            var oldScissorRectangle = CrossEngineStuff.GetScissor();

            if (ClipToBounds && !MyraEnvironment.DisableClipping)
            {
                var newScissorRectangle = Rectangle.Intersect(oldScissorRectangle, view);

                if (newScissorRectangle.IsEmpty)
                {
                    return;
                }

                context.Flush();

                CrossEngineStuff.SetScissor(newScissorRectangle);
            }

            var oldOpacity = context.Opacity;
            var oldView    = context.View;

            context.Opacity *= Opacity;
            context.View     = view;

            BeforeRender?.Invoke(context);

            // Background
            var background = GetCurrentBackground();

            if (background != null)
            {
                context.Draw(background, BackgroundBounds);
            }

            // Borders
            var border = GetCurrentBorder();

            if (border != null)
            {
                var borderBounds = BorderBounds;
                if (BorderThickness.Left > 0)
                {
                    context.Draw(border, new Rectangle(borderBounds.X, borderBounds.Y, BorderThickness.Left, borderBounds.Height));
                }

                if (BorderThickness.Top > 0)
                {
                    context.Draw(border, new Rectangle(borderBounds.X, borderBounds.Y, borderBounds.Width, BorderThickness.Top));
                }

                if (BorderThickness.Right > 0)
                {
                    context.Draw(border, new Rectangle(borderBounds.Right - BorderThickness.Right, borderBounds.Y, BorderThickness.Right, borderBounds.Height));
                }

                if (BorderThickness.Bottom > 0)
                {
                    context.Draw(border, new Rectangle(borderBounds.X, borderBounds.Bottom - BorderThickness.Bottom, borderBounds.Width, BorderThickness.Bottom));
                }
            }

            InternalRender(context);

            AfterRender?.Invoke(context);

            // Restore context settings
            context.View    = oldView;
            context.Opacity = oldOpacity;

            // Optional debug rendering
            if (MyraEnvironment.DrawWidgetsFrames)
            {
                batch.DrawRectangle(Bounds, Color.LightGreen);
            }

            if (MyraEnvironment.DrawKeyboardFocusedWidgetFrame && IsKeyboardFocused)
            {
                batch.DrawRectangle(Bounds, Color.Red);
            }

            if (MyraEnvironment.DrawMouseWheelFocusedWidgetFrame && IsMouseWheelFocused)
            {
                batch.DrawRectangle(Bounds, Color.Yellow);
            }

            if (ClipToBounds && !MyraEnvironment.DisableClipping)
            {
                // Restore scissor
                context.Flush();
                CrossEngineStuff.SetScissor(oldScissorRectangle);
            }
        }
Example #17
0
        private void RenderSelection(RenderContext context)
        {
            var bounds = ActualBounds;

            if (string.IsNullOrEmpty(Text) || Selection == null)
            {
                return;
            }

            var selectStart = Math.Min(SelectStart, SelectEnd);
            var selectEnd   = Math.Max(SelectStart, SelectEnd);

            if (selectStart >= selectEnd)
            {
                return;
            }

            var startGlyph = _formattedText.GetGlyphInfoByIndex(selectStart);

            if (startGlyph == null)
            {
                return;
            }

            var lineIndex = startGlyph.TextLine.LineIndex;
            var i         = selectStart;

            while (true)
            {
                startGlyph = _formattedText.GetGlyphInfoByIndex(i);
                var startPosition = GetRenderPositionByIndex(i);

                if (selectEnd < i + startGlyph.TextLine.Count)
                {
                    var endPosition = GetRenderPositionByIndex(selectEnd);

                    context.Draw(Selection,
                                 new Rectangle(startPosition.X - _internalScrolling.X,
                                               startPosition.Y - _internalScrolling.Y,
                                               endPosition.X - startPosition.X,
                                               CrossEngineStuff.LineSpacing(_formattedText.Font)));

                    break;
                }

                context.Draw(Selection,
                             new Rectangle(startPosition.X - _internalScrolling.X,
                                           startPosition.Y - _internalScrolling.Y,
                                           bounds.Left + startGlyph.TextLine.Size.X - startPosition.X,
                                           CrossEngineStuff.LineSpacing(_formattedText.Font)));

                ++lineIndex;
                if (lineIndex >= _formattedText.Strings.Length)
                {
                    break;
                }

                i = 0;
                for (var k = 0; k < lineIndex; ++k)
                {
                    i += _formattedText.Strings[k].Count;
                }
            }
        }
Example #18
0
        public override void InternalRender(RenderContext context)
        {
            if (_formattedText.Font == null)
            {
                return;
            }

            var bounds = ActualBounds;

            if (Selection != null && !string.IsNullOrEmpty(Text))
            {
                var selectStart = Math.Min(SelectStart, SelectEnd);
                var selectEnd   = Math.Max(SelectStart, SelectEnd);

                if (selectStart < selectEnd)
                {
                    //					Debug.WriteLine("{0} - {1}", selectStart, selectEnd);

                    var startGlyph = _formattedText.GetGlyphInfoByIndex(selectStart);
                    var lineIndex  = startGlyph.TextLine.LineIndex;
                    var i          = selectStart;

                    while (true)
                    {
                        startGlyph = _formattedText.GetGlyphInfoByIndex(i);
                        var startPosition = GetRenderPositionByIndex(i);

                        if (selectEnd < i + startGlyph.TextLine.Count)
                        {
                            var endPosition = GetRenderPositionByIndex(selectEnd);

                            context.Draw(Selection,
                                         new Rectangle(startPosition.X - _internalScrolling.X,
                                                       startPosition.Y - _internalScrolling.Y,
                                                       endPosition.X - startPosition.X,
                                                       CrossEngineStuff.LineSpacing(_formattedText.Font)));

                            break;
                        }

                        context.Draw(Selection,
                                     new Rectangle(startPosition.X - _internalScrolling.X,
                                                   startPosition.Y - _internalScrolling.Y,
                                                   bounds.Left + startGlyph.TextLine.Size.X - startPosition.X,
                                                   CrossEngineStuff.LineSpacing(_formattedText.Font)));

                        ++lineIndex;
                        if (lineIndex >= _formattedText.Strings.Length)
                        {
                            break;
                        }

                        i = 0;
                        for (var k = 0; k < lineIndex; ++k)
                        {
                            i += _formattedText.Strings[k].Count;
                        }
                    }
                }
            }

            var textColor = TextColor;

            if (!Enabled && DisabledTextColor != null)
            {
                textColor = DisabledTextColor.Value;
            }
            else if (IsKeyboardFocused && FocusedTextColor != null)
            {
                textColor = FocusedTextColor.Value;
            }

            var centeredBounds = LayoutUtils.Align(new Point(bounds.Width, bounds.Height), _formattedText.Size, HorizontalAlignment.Left, TextVerticalAlignment);

            centeredBounds.Offset(bounds.Location);

            var p = new Point(centeredBounds.Location.X - _internalScrolling.X,
                              centeredBounds.Location.Y - _internalScrolling.Y);

            _formattedText.Draw(context.Batch,
                                p,
                                context.View, textColor, context.Opacity);

            if (!IsKeyboardFocused)
            {
                // Skip cursor rendering if the widget doesnt have the focus
                return;
            }

            var now = DateTime.Now;

            if ((now - _lastBlinkStamp).TotalMilliseconds >= BlinkIntervalInMs)
            {
                _cursorOn       = !_cursorOn;
                _lastBlinkStamp = now;
            }

            if (Enabled && _cursorOn && Cursor != null)
            {
                p    = GetRenderPositionByIndex(CursorPosition);
                p.X -= _internalScrolling.X;
                p.Y -= _internalScrolling.Y;
                context.Draw(Cursor,
                             new Rectangle(p.X, p.Y,
                                           Cursor.Size.X,
                                           CrossEngineStuff.LineSpacing(_formattedText.Font)));
            }
        }