public void drawScroller(DrawCanvas canvas, Rect drawRegion, Rect contentsSize)
        {
            this.drawRegion   = drawRegion;
            this.contentsSize = contentsSize;

            if (hideBars)
            {
                return;
            }

            if (yScrollEnabled())
            {
                ICanvasRectItem rectangle = new CanvasItemFactory().createCanvasRectItem();
                rectangle.setColor(new Layout.Color(scrollerBrightness, scrollerBrightness, scrollerBrightness));
                rectangle.setSize(scrollerWidth, scrollerHeight);
                canvas.drawToCanvas(rectangle, drawRegion.Right - scrollerWidth - scrollerPadding, drawRegion.Top + scrollerPadding + getYScrollerYPos());
            }

            if (drawRegion.Width < contentsSize.Width)
            {
                ICanvasRectItem rectangle = new CanvasItemFactory().createCanvasRectItem();
                rectangle.setColor(new Layout.Color(scrollerBrightness, scrollerBrightness, scrollerBrightness));
                rectangle.setSize(scrollerHeight, scrollerWidth);
                canvas.drawToCanvas(rectangle, drawRegion.Left + scrollerPadding + getXScrollerXPos(), drawRegion.Bottom - scrollerWidth - scrollerPadding);
            }
        }
        public override void draw(LayoutRenderer.DrawCanvas drawCanvas, Rect rect)
        {
            ICanvasRectItem edgeRectangle = new CanvasItemFactory().createCanvasRectItem();
            Color           edgeColor     = new Color(color.r + 30, color.g + 30, color.b + 30);

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

            ICanvasRectItem rectangle = new CanvasItemFactory().createCanvasRectItem();
            Color           buttonColor;

            if (mouseOverButton)
            {
                buttonColor = new Color((int)(color.r + 15), (int)(color.g + 15), (int)(color.b + 15));
            }
            else
            {
                buttonColor = color;
            }
            rectangle.setColor(buttonColor);
            rectangle.setSize(rect.Width - 2 * EDGE_WIDTH, rect.Height - 2 * EDGE_WIDTH);
            drawCanvas.drawToCanvas(rectangle, rect.Left + EDGE_WIDTH, rect.Top + EDGE_WIDTH);

            if (contentsMeasuredLayout != null)
            {
                contentsMeasuredLayout.drawable.draw(drawCanvas, contentsMeasuredLayout.getBounds().rect);
            }
        }
Ejemplo n.º 3
0
        public override void draw(LayoutRenderer.DrawCanvas drawCanvas, Rect rect)
        {
            if (color.a != 0)
            {
                ICanvasRectItem rectangle = new CanvasItemFactory().createCanvasRectItem();
                rectangle.setColor(color);
                rectangle.setSize(rect.Width, rect.Height);

                drawCanvas.drawToCanvas(rectangle, rect.Left, rect.Top);
            }
        }
        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();
        }
Ejemplo n.º 5
0
        private void drawCursor(DrawCanvas drawCanvas, Rect bounds, double charWidth, double charHeight)
        {
            Point cursorPos = getTextPosForIndex(getCursorIndex());

            cursorPos.X += bounds.Left;      // Add textBox offset
            cursorPos.Y += bounds.Top;
            cursorPos.X += scroller.scrollX; // Add textBox offset
            cursorPos.Y += scroller.scrollY;

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

            cursorRect.setColor(edgeColor);
            cursorRect.setSize(CURSOR_WIDTH, charHeight - 2);
            drawCanvas.drawToCanvas(cursorRect, cursorPos.X + 1, cursorPos.Y + 1);
        }
Ejemplo n.º 6
0
        public EditTextLayout()
        {
            ICanvasTextItem textMeasurer = new CanvasItemFactory().createCanvasTextItem();

            charecterDimensions = textMeasurer.measureText("a");

            this.handleMouseEvent += mouseEventHandler;
            this.handleKeyPress   += keyboardEventHandler;
            this.onFocus          += () =>
            {
                isViewFocused = true;
            };
            this.onLostFocus += () =>
            {
                makingSelection = false;
                scroller.stopScrolling();
                isViewFocused = false;
            };
        }
        public JsonLayout()
        {
            ICanvasTextItem textMeasurer = new CanvasItemFactory().createCanvasTextItem();

            charecterDimensions = textMeasurer.measureText("a");

            this.handleMouseEvent += mouseEventHandler;
            this.onFocus          += () =>
            {
                isViewFocused = true;
                edgeColor     = new Color(0, 90, 180);
            };
            this.onLostFocus += () =>
            {
                makingSelection = false;
                scroller.stopScrolling();
                isViewFocused = false;
                edgeColor     = new Color(170, 170, 170);
            };
        }
        private void drawCharecterHighlight(DrawCanvas canvas, char charecter, double x, double y, Color color)
        {
            if (color.a == 0)
            {
                return;
            }

            double selectionWidth = charecterDimensions.Width;

            if (charecter == '\t')
            {
                selectionWidth *= tabSpaces;
            }

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

            selection.setColor(color);
            selection.setSize(selectionWidth, charecterDimensions.Height);
            canvas.drawToCanvas(selection, x, y);
        }
        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();
        }
Ejemplo n.º 10
0
 public void SetUp()
 {
     _factory = new CanvasItemFactory();
 }