public override void draw(DrawCanvas drawCanvas, Rect rect)
        {
            drawCanvas.enableClipping((int)rect.Left, (int)rect.Top, (int)rect.Width, (int)rect.Height);

            ICanvasTextItem textCanvasItem = new CanvasItemFactory().createCanvasTextItem();

            textCanvasItem.setText(text);
            textCanvasItem.setTextColor(textColor);
            textCanvasItem.setTextSize(textSize);
            drawCanvas.drawToCanvas(textCanvasItem, rect.Left, rect.Top);

            drawCanvas.disableClipping();
        }
        public override void draw(DrawCanvas drawCanvas, Rect rect)
        {
            ICanvasRectItem edge = new CanvasItemFactory().createCanvasRectItem();

            edge.setColor(edgeColor);
            edge.setSize(rect.Width, rect.Height);
            drawCanvas.drawToCanvas(edge, rect.Left, rect.Top);

            if (rect.Width - 2 * BORDER_SIZE < 0 || rect.Height - 2 * BORDER_SIZE < 0)
            {
                return;
            }

            Rect textRegion = new Rect(new Point(rect.Left + BORDER_SIZE, rect.Top + BORDER_SIZE), new Size(rect.Width - 2 * BORDER_SIZE, rect.Height - 2 * BORDER_SIZE));

            drawCanvas.enableClipping((int)textRegion.Left, (int)textRegion.Top, (int)textRegion.Width, (int)textRegion.Height);

            ICanvasRectItem background = new CanvasItemFactory().createCanvasRectItem();

            background.setColor(backgroundColor);
            background.setSize(textRegion.Width, textRegion.Height);
            drawCanvas.drawToCanvas(background, textRegion.X, textRegion.Y);

            calcualteAllTextPositions();

            previousBounds = new Rect(new Point(textRegion.X, textRegion.Y), new Size(textRegion.Width, textRegion.Height));

            int selectionStartIndex = Math.Min(selectionBeganIndex, cursorIndex);
            int selectionEndIndex   = Math.Max(selectionBeganIndex, cursorIndex);

            for (int i = 0; i < displayText.Length; i++)
            {
                if (displayText[i] == '\r' || displayText[i] == '\n')
                {
                    continue;
                }

                Point letterPos = getTextPosForIndex(i);
                letterPos.X += textRegion.Left;  // Add textBox offset
                letterPos.Y += textRegion.Top;
                letterPos.X += scroller.scrollX; // Add textBox offset
                letterPos.Y += scroller.scrollY;

                if (letterPos.X + charecterDimensions.Width < 0)
                {
                    continue;
                }
                if (letterPos.Y + charecterDimensions.Height < 0)
                {
                    continue;
                }
                if (letterPos.X > textRegion.Width)
                {
                    continue;
                }
                if (letterPos.Y > textRegion.Height + rect.Top)
                {
                    continue;
                }

                if ((i >= selectionStartIndex && i < selectionEndIndex)) // Draw cursor selection
                {
                    drawCharecterHighlight(drawCanvas, displayText[i], letterPos.X, letterPos.Y, edgeColor);
                }
                else
                {
                    drawCharecterHighlight(drawCanvas, displayText[i], letterPos.X, letterPos.Y, contents.getColorForCharAtIndex(i));
                }

                if (displayText[i] != '\t')
                {
                    ICanvasTextItem letterCanvasItem = new CanvasItemFactory().createCanvasTextItem();
                    letterCanvasItem.setText(displayText[i] + "");
                    drawCanvas.drawToCanvas(letterCanvasItem, letterPos.X, letterPos.Y);
                }
            }

            if (singleLine)
            {
                scroller.hideBars = true;
            }

            scroller.drawScroller(drawCanvas, textRegion, new Rect(new Size(maxXPos + charecterDimensions.Width, maxYPos + charecterDimensions.Height)));

            drawCanvas.disableClipping();
        }