public static void DrawGrid(Gdk.Drawable wnd, int Size)
        {
            int Width, Height;
            var gc = new Gdk.GC (wnd);

            Gdk.Color line_color = new Gdk.Color (0, 255, 255);
            gc.RgbFgColor = line_color;

            wnd.GetSize (out Width, out Height);
            for (int i = 0; i < Width; i += Size)
                wnd.DrawLine (gc, i, 0, i, Height);
            for (int i = 0; i < Height; i += Size)
                wnd.DrawLine (gc, 0, i, Width, i);
        }
		internal protected override void Draw (Gdk.Drawable win, Gdk.Rectangle area, long line, int x, int y)
		{
			if (backgroundGC == null)
				OptionsChanged ();
		
			win.DrawRectangle (backgroundGC, true, x, y, Width, Editor.LineHeight);
			win.DrawLine (separatorGC, x + Width - 1, y, x + Width - 1, y + Editor.LineHeight);
			
			foreach (long bookmark in Data.Bookmarks) {
				if (line * Editor.BytesInRow <= bookmark && bookmark < line * Editor.BytesInRow + Editor.BytesInRow) {
					DrawBookmark (win, x, y);
					return;
				}
			}
		}
Esempio n. 3
0
        public override void Draw(TextEditor editor, Gdk.Drawable win,Pango.Layout layout, bool selected, int startOffset, int endOffset, int y, int startXPos, int endXPos)
        {
            int markerStart = LineSegment.Offset + System.Math.Max (StartCol, 0);
                  int markerEnd   = LineSegment.Offset + (EndCol < 0? LineSegment.Length : EndCol);
                  if (markerEnd < startOffset || markerStart > endOffset)
                        return;

                  int from;
                  int to;

                  if (markerStart < startOffset && endOffset < markerEnd) {
                        from = startXPos;
                        to   = endXPos;
                  } else {
                        int start = startOffset < markerStart ? markerStart : startOffset;
                        int end   = endOffset < markerEnd ? endOffset : markerEnd;
                        from = startXPos + editor.GetWidth (editor.Document.GetTextAt (startOffset, start - startOffset));
                        to   = startXPos + editor.GetWidth (editor.Document.GetTextAt (startOffset, end - startOffset));
                  }
                  from = System.Math.Max (from, editor.TextViewMargin.XOffset);
                  to   = System.Math.Max (to, editor.TextViewMargin.XOffset);
                  if (from >= to) {
                        return;
                  }

                  using (Gdk.GC gc = new Gdk.GC (win)) {
                       // gc.RgbFgColor = ColorName == null ? Color : editor.ColorStyle.GetColorFromDefinition (ColorName);
                        int drawY    = y + editor.LineHeight - 1;

                        win.DrawLine (gc, from, drawY, to, drawY);
            if(@from<to){
                //gc.RgbFgColor = editor.ColorStyle.BracketHighlightRectangle.BackgroundColor;
                //win.DrawRectangle (gc, true, @from + 1, y + 1, to - @from - 1, editor.LineHeight - 2);
                gc.RgbFgColor = editor.ColorStyle.BracketHighlightRectangle.Color;
                win.DrawRectangle (gc, false, @from, y, to - @from, editor.LineHeight - 1);
            }

                  }
        }
        //    The following functions do the real work of the control, drawing the primary content (the area between the slider)
        //    
        /// <summary>
        /// Fills in the content of the control showing all values of Hue (from 0 to 360)
        /// </summary>
        private void Draw_Style_Hue(Gdk.Window g)
        {
            GraphUtil.HSL _hsl = new GraphUtil.HSL();
                _hsl.S = 1.0;	//	S and L will both be at 100% for this DrawStyle
                _hsl.L = 1.0;

                for ( int i = 0; i < this.Allocation.Height - 8; i++ )	//	i represents the current line of pixels we want to draw horizontally
                {
                    _hsl.H = 1.0 - (double)i/(this.Allocation.Height - 8);			//	H (hue) is based on the current vertical position
                    Color c = GraphUtil.HSL_to_RGB(_hsl);

                    Gdk.GC gc     = new Gdk.GC( g );
                    gc.RgbFgColor = GraphUtil.gdkColorFromWinForms( c );

                    g.DrawLine( gc, 11, i + 4, this.Allocation.Width - 11, i +4 );//	Draw the line and loop back for next line
                }
        }
        /// <summary>
        /// Draws the border around the control, in this case the border around the content area between
        /// the slider arrows.
        /// </summary>
        private void DrawBorder(Gdk.Window g)
        {
            //	To make the control look like Adobe Photoshop's the border around the control will be a gray line
            //	on the top and left side, a white line on the bottom and right side, and a black rectangle (line)
            //	inside the gray/white rectangle
            Gdk.GC gc = new Gdk.GC( g );
            gc.RgbFgColor = GraphUtil.gdkColorFromWinForms(Color.FromArgb(172,168,153));
            //The same gray color used by Photoshop

            g.DrawLine(gc, this.Allocation.Width - 10, 2, 9, 2);	//	Draw top line
            g.DrawLine(gc, 9, 2, 9, this.Allocation.Height - 4);	//	Draw left hand line

            gc            = new Gdk.GC( g );
            gc.RgbFgColor = GraphUtil.gdkColorFromWinForms( Color.White );

            g.DrawLine(gc, this.Allocation.Width - 9, 2, this.Allocation.Width - 9,this.Allocation.Height - 3);	//	Draw right hand line
            g.DrawLine(gc, this.Allocation.Width - 9,this.Allocation.Height - 3, 9,this.Allocation.Height - 3);	//	Draw bottome line

            gc            = new Gdk.GC( g );
            gc.RgbFgColor = GraphUtil.gdkColorFromWinForms( Color.Black );
            g.DrawRectangle(gc, false, 10, 3, this.Allocation.Width - 20, this.Allocation.Height - 7);	//	Draw inner black rectangle
        }
Esempio n. 6
0
        void DrawVerticalRuler(Gdk.Drawable g, System.Drawing.Rectangle lineRectangle)
        {
            if (TextEditorProperties.VerticalRulerRow < textArea.VirtualTop.X) {
                return;
            }
            HighlightColor vRulerColor = textArea.Document.HighlightingStrategy.GetColorFor("VRulerColor");
            int xpos = (int)MeasureString(FontContainer.DefaultFont, "12345678901234567890123456789012345678901234567890123456789012345678901234567890");
            //int xpos = (int)(drawingPosition.Left + GetWidth(g, ' ') * (TextEditorProperties.VerticalRulerRow - textArea.VirtualTop.X));
            using (Gdk.GC gc = new Gdk.GC(g)) {
                gc.RgbFgColor = new Gdk.Color(vRulerColor.Color);

                g.DrawLine(gc,
                        xpos,
                        lineRectangle.Top,
                        xpos,
                        lineRectangle.Bottom);
            }
        }
		void DrawFoldSegment (Gdk.Drawable win, int x, int y, bool isOpen, bool isSelected)
		{
			Gdk.Rectangle drawArea = new Gdk.Rectangle (x + (Width - foldSegmentSize) / 2, y + (editor.LineHeight - foldSegmentSize) / 2, foldSegmentSize, foldSegmentSize);
			win.DrawRectangle (foldBgGC, true, drawArea);
			win.DrawRectangle (isSelected ? foldLineHighlightedGC  : foldLineGC, false, drawArea);
			
			win.DrawLine (foldToggleMarkerGC, 
			              drawArea.Left  + drawArea.Width * 3 / 10,
			              drawArea.Top + drawArea.Height / 2,
			              drawArea.Right - drawArea.Width * 3 / 10,
			              drawArea.Top + drawArea.Height / 2);
			
			if (!isOpen)
				win.DrawLine (foldToggleMarkerGC, 
				              drawArea.Left + drawArea.Width / 2,
				              drawArea.Top + drawArea.Height * 3 / 10,
				              drawArea.Left  + drawArea.Width / 2,
				              drawArea.Bottom - drawArea.Height * 3 / 10);
		}
Esempio n. 8
0
		public void DrawCaret (Gdk.Drawable win)
		{
			if (!this.textEditor.IsInDrag) {
				if (!(this.caretX >= 0 && (!this.textEditor.IsSomethingSelected || this.textEditor.SelectionRange.Length == 0))) {
					return;
				}
			}
			if (Settings.Default.CursorBlink && (!Caret.IsVisible || !caretBlink)) {
				return;
			}
			
			switch (Caret.Mode) {
			case CaretMode.Insert:
				win.DrawLine (caretGc, caretX, caretY, caretX, caretY + LineHeight - 1);
				break;
			case CaretMode.Block:
				win.DrawRectangle (caretGc, true, new Gdk.Rectangle (caretX, caretY, this.charWidth, LineHeight));
				/*					textRenderer.BeginDraw (win);
//				textRenderer.SetClip (clipRectangle);
					textRenderer.Color = ColorStyle.Caret.BackgroundColor;
					textRenderer.SetText (caretChar.ToString ());
					textRenderer.DrawText (win, caretX, caretY);
					textRenderer.EndDraw ();*/
				break;
			case CaretMode.Underscore:
				int bottom = caretY + lineHeight;
				win.DrawLine (caretGc, caretX, bottom, caretX + this.charWidth, bottom);
				break;
			}
			
		}
		internal protected override void Draw (Gdk.Drawable win, Gdk.Rectangle area, int line, int x, int y, int lineHeight)
		{
			
			win.DrawLine (UseBGColor ? bgGC : gc, x, y, x, y + lineHeight);
			
//			int top = y;
//			int bottom = top + lineHeight;
//			bool isOdd = (top + (int)editor.VAdjustment.Value) % 2 != 0;
//			win.DrawLine (isOdd? bgGC : bgGC2, x, top, x, bottom);
//			win.DrawLine (isOdd? foldDashedLineGC : foldDashedLineGC2, x, top, x, bottom);
		}
        public override void Paint(Gdk.Drawable wnd, System.Drawing.Rectangle rect)
        {
            int one_width = (int) textArea.TextView.GetWidth ('w');

            using (Gdk.GC gc = new Gdk.GC (wnd)) {
            using (Pango.Layout ly = new Pango.Layout (TextArea.PangoContext)) {
                ly.FontDescription = FontContainer.DefaultFont;
                ly.Width = drawingPosition.Width;
                ly.Alignment = Pango.Alignment.Right;

                HighlightColor lineNumberPainterColor = textArea.Document.HighlightingStrategy.GetColorFor("LineNumbers");

                gc.RgbBgColor = new Gdk.Color (lineNumberPainterColor.BackgroundColor);
                gc.RgbFgColor = TextArea.Style.White;
                wnd.DrawRectangle (gc, true, drawingPosition);

                gc.RgbFgColor = new Gdk.Color (lineNumberPainterColor.Color);
                gc.SetLineAttributes (1, LineStyle.OnOffDash, CapStyle.NotLast, JoinStyle.Miter);
                wnd.DrawLine (gc, drawingPosition.X + drawingPosition.Width, drawingPosition.Y, drawingPosition.X + drawingPosition.Width, drawingPosition.Height);

                //FIXME: This doesnt allow different fonts and what not
                int fontHeight = TextArea.TextView.FontHeight;

                for (int y = 0; y < (DrawingPosition.Height + textArea.TextView.VisibleLineDrawingRemainder) / fontHeight + 1; ++y) {
                    int ypos = drawingPosition.Y + fontHeight * y  - textArea.TextView.VisibleLineDrawingRemainder;

                    int curLine = y + textArea.TextView.FirstVisibleLine;
                    if (curLine < textArea.Document.TotalNumberOfLines) {
                        ly.SetText ((curLine + 1).ToString ());
                        wnd.DrawLayout (gc, drawingPosition.X + drawingPosition.Width - one_width, ypos, ly);
                    }
                }
            }}
        }
Esempio n. 11
0
        // Redraw power samples for the exposed area.
        void DrawPower(Gdk.Window win, Gdk.Rectangle rect)
        {
            SampleQueue data = debugManager.PowerData;

            if (data == null)
            return;

            int[] slice = new int[rect.Width];
            int len;

            len = data.Fetch(rect.X * scale, slice, scale);

            for (int i = 0; i < len; i++)
            {
            int x = rect.X + i;
            int h = slice[i] * allocation.Height / vertMax;

            win.DrawLine(gcBar, x, allocation.Height - 1 - h,
                 x, allocation.Height - 1);
            }
        }
Esempio n. 12
0
        // Redraw horizontal gridlines for the exposed area.
        void DrawHorizontalGrid(Gdk.Window win, Gdk.Rectangle rect)
        {
            int x1 = rect.X;
            int x2 = rect.X + rect.Width - 1;

            // Align the horizontal region so the dotted pattern always
            // appears continuous.
            x1 -= x1 % dotsPeriod;
            x2 += dotsPeriod - (x2 % dotsPeriod);

            for (int i = 1; i < 10; i++) {
            int y = allocation.Height * i / 10;

            win.DrawLine(gcGrid, x1, y, x2, y);
            }
        }
Esempio n. 13
0
 public void drawCardFace(Gdk.Window win, Gdk.GC outline, Gdk.GC fill, int x, int y, int w, int h)
 {
     int top = y, bottom = h+y, left = x, right = w+x, corner = 25;
     int hcorner = (int)Math.Ceiling((double)corner/2); // half corner
     /* Outline of Arcs */
     win.DrawArc(outline, true, left-1, top-1, corner, corner, 90 * 64, 90 * 64);
     win.DrawArc(outline, true, left-1, bottom-corner+1, corner, corner, 180 * 64, 90 * 64);
     win.DrawArc(outline, true, right-corner+1, bottom-corner+1, corner, corner, 270 * 64, 90 * 64);
     win.DrawArc(outline, true, right-corner+1, top-1, corner, corner, 360 * 64, 90 * 64);
     /* Fill of Arcs */
     win.DrawArc(fill, true, left, top, corner, corner, 90 * 64, 90 * 64);
     win.DrawArc(fill, true, left, bottom-corner, corner, corner, 180 * 64, 90 * 64);
     win.DrawArc(fill, true, right-corner, bottom-corner, corner, corner, 270 * 64, 90 * 64);
     win.DrawArc(fill, true, right-corner, top, corner, corner, 360 * 64, 90 * 64);
     /* Fill of Card */
     win.DrawRectangle(fill, true, left+hcorner, top, right-left-corner, bottom-top);
     win.DrawRectangle(fill, true, left, top+hcorner, right-left, bottom-top-corner);
     /* Outline of Card */
     win.DrawLine(outline, left+hcorner, top, right-hcorner, top);
     win.DrawLine(outline, left+hcorner, bottom, right-hcorner, bottom);
     win.DrawLine(outline, left, top+hcorner, left, bottom-hcorner);
     win.DrawLine(outline, right, top+hcorner, right, bottom-hcorner);
 }
		internal protected override void Draw (Gdk.Drawable win, Gdk.Rectangle area, int line, int x, int y, int lineHeight)
		{
			Gdk.Rectangle drawArea = new Gdk.Rectangle (x, y, Width, lineHeight);
			
			win.DrawRectangle (backgroundGC, true, drawArea);
			win.DrawLine (separatorGC, x + Width - 1, drawArea.Top, x + Width - 1, drawArea.Bottom);
			
			if (line < editor.Document.LineCount) {
				LineSegment lineSegment = editor.Document.GetLine (line);
				
				foreach (TextMarker marker in lineSegment.Markers) {
					if (marker is IIconBarMarker) 
						((IIconBarMarker)marker).DrawIcon (editor, win, lineSegment, line, x, y, Width, editor.LineHeight);
				}
				if (DrawEvent != null) 
					DrawEvent (this, new BookmarkMarginDrawEventArgs (editor, win, lineSegment, line, x, y));
			}
		}
Esempio n. 15
0
        private static int priv_DrawList(Gdk.GC gc, Gdk.Drawable wnd, Node Root, int Padding, int Level, int Parent)
        {
            if (Root == null)
                return Level;
            int ret = Level;
            wnd.DrawRectangle (gc, false, Padding * cellsize, Level * cellsize, nodesize, nodesize);

            //FIXME: make node size configurable via UI, huh?
            if (Parent != Level) {
                wnd.DrawLine (gc, Padding * cellsize - 1, Level * cellsize + (nodesize >> 1), Padding * cellsize - 2, Level * cellsize + (nodesize >> 1));
                wnd.DrawLine (gc, Padding * cellsize - 2, Level * cellsize + (nodesize >> 1), Padding * cellsize - 2, Parent * cellsize + (nodesize >> 1));
                wnd.DrawLine (gc, Padding * cellsize - 4, Parent * cellsize + (nodesize >> 1), Padding * cellsize - 2, Parent * cellsize + (nodesize >> 1));
            }

            string msg = null;

            switch (Root.sym) {
                case 259:
                    msg = "INT";
                    break;
                case 258:
                    msg = "RT";
                    break;
                case 257:
                    msg = "NYT";
                    break;
                case 256:
                    msg = "EOF";
                    break;
                default:

                    char c = (char)Root.sym;
                    if (char.IsLetterOrDigit (c))
                        msg = c.ToString ();
                    else
                        msg = string.Format("{0:x}h", Root.sym);
                    break;
            }
            Pango.Context pango_ctx = PangoHelper.ContextGet ();
            Pango.Layout pango_lay = new Pango.Layout (pango_ctx);
            pango_lay.SetText (msg);
            pango_lay.FontDescription = Pango.FontDescription.FromString ("monospace 9");
            wnd.DrawLayout (gc, Padding * cellsize + 1, Level * cellsize + 1, pango_lay);

            if (Root.right != null)
                ret = priv_DrawList (gc, wnd, Root.right, Padding + 1, Level + 1, Level);
            if (Root.left != null)
                ret = priv_DrawList (gc, wnd, Root.left, Padding + 1, ret + 1, Level);
            return ret;
        }
        /// <summary>
        /// Fills in the content of the control showing all values of Red (0 to 255) for the given
        /// Green and Blue.
        /// </summary>
        private void Draw_Style_Red(Gdk.Window g)
        {
            for ( int i = 0; i < this.Allocation.Height - 8; i++ ) //	i represents the current line of pixels we want to draw horizontally
            {
                int red = 255 - Round(255 * (double)i/(this.Allocation.Height - 8));	//	red is based on the current vertical position
                //	Get the Color for this line

                Color c = Color.FromArgb(red, m_rgb.G, m_rgb.B);

                Gdk.GC gc     = new Gdk.GC( g );
                gc.RgbFgColor = GraphUtil.gdkColorFromWinForms( c );
                g.DrawLine( gc, 11, i + 4, this.Allocation.Width - 11, i + 4 );			//	Draw the line and loop back for next line
            }
        }
        /// <summary>
        /// Fills in the content of the control showing all values of Saturation (0 to 100%) for the given
        /// Hue and Luminance.
        /// </summary>
        private void Draw_Style_Saturation(Gdk.Window g)
        {
            GraphUtil.HSL _hsl = new GraphUtil.HSL();
            _hsl.H = m_hsl.H;	//	Use the H and L values of the current color (m_hsl)
            _hsl.L = m_hsl.L;

            for ( int i = 0; i < this.Allocation.Height - 8; i++ ) //	i represents the current line of pixels we want to draw horizontally
            {
                _hsl.S = 1.0 - (double)i/(this.Allocation.Height - 8);			//	S (Saturation) is based on the current vertical position

                Color c = GraphUtil.HSL_to_RGB(_hsl);

                Gdk.GC gc     = new Gdk.GC( g );
                gc.RgbFgColor = GraphUtil.gdkColorFromWinForms( c );
                g.DrawLine( gc, 11, i + 4, this.Allocation.Width - 11, i + 4 );	//	Draw the line and loop back for next line
            }
        }
Esempio n. 18
0
        // Redraw vertical gridlines for the exposed area.
        void DrawVerticalGrid(Gdk.Window win, Gdk.Rectangle rect)
        {
            SampleQueue data = debugManager.PowerData;

            if (data == null)
            return;

            int usPerPx = scale * data.Period;
            int t = rect.X * usPerPx;

            // Find the first time divison before the exposed area
            t -= t % hSpacingUs;

            for (;;)
            {
            int x = t / usPerPx;

            if (x >= rect.X + rect.Width)
            break;

            win.DrawLine(gcGrid, x, 0, x, allocation.Height - 1);
            t += hSpacingUs;
            }
        }
		public void DrawCaret (Gdk.Drawable win)
		{
			if (!this.textEditor.IsInDrag && !(this.caretX >= 0 && (!this.textEditor.IsSomethingSelected || this.textEditor.SelectionRange.Length == 0))) 
				return;
			if (win == null || Settings.Default.CursorBlink && !Caret.IsVisible)
				return;

			switch (Caret.Mode) {
			case CaretMode.Insert:
				win.DrawLine (caretGc, (int)caretX, (int)caretY, (int)caretX, (int)(caretY + LineHeight - 1));
				break;
			case CaretMode.Block:
				win.DrawRectangle (caretGc, true, new Gdk.Rectangle ((int)caretX, (int)caretY, (int)this.charWidth, (int)LineHeight));
				break;
			case CaretMode.Underscore:
				double bottom = caretY + LineHeight;
				win.DrawLine (caretGc, (int)caretX, (int)bottom, (int)(caretX + this.charWidth), (int)bottom);
				break;
			}
		}
Esempio n. 20
0
        void DrawFoldMarker(Gdk.Drawable g, RectangleF rectangle, bool isOpened)
        {
            HighlightColor foldMarkerColor = textArea.Document.HighlightingStrategy.GetColorFor("FoldMarker");
            HighlightColor foldLineColor   = textArea.Document.HighlightingStrategy.GetColorFor("FoldLine");

            System.Drawing.Rectangle intRect = new System.Drawing.Rectangle((int)rectangle.X, (int)rectangle.Y, (int)rectangle.Width, (int)rectangle.Height);
            using (Gdk.GC gc = new Gdk.GC(g)) {
                gc.RgbFgColor = new Gdk.Color (foldMarkerColor.BackgroundColor);
                g.DrawRectangle(gc, true, intRect);
                gc.RgbFgColor = new Gdk.Color (foldMarkerColor.Color);
                g.DrawRectangle(gc, false, intRect);

                int space  = (int)Math.Round(((double)rectangle.Height) / 8d) + 1;
                int mid    = intRect.Height / 2 + intRect.Height % 2;

                gc.RgbFgColor = new Gdk.Color (foldMarkerColor.Color);
                g.DrawLine(gc,
                       (int)rectangle.X + space,
                       (int)rectangle.Y + mid,
                       (int)rectangle.X + (int)rectangle.Width - space,
                       (int)rectangle.Y + mid);

                if (!isOpened) {
                    g.DrawLine(gc,
                           (int)rectangle.X + mid,
                           (int)rectangle.Y + space,
                           (int)rectangle.X + mid,
                           (int)rectangle.Y + (int)rectangle.Height - space);

                }
            }
        }
Esempio n. 21
0
		public void DrawRectangleWithRuler (Gdk.Drawable win, int x, Gdk.Rectangle area, Gdk.Color color, bool drawDefaultBackground)
		{
			if (BackgroundRenderer != null)
				return;
			bool isDefaultColor = (color.Red == defaultBgColor.Red && color.Green == defaultBgColor.Green && color.Blue == defaultBgColor.Blue);
			if (isDefaultColor && !drawDefaultBackground)
				return;
			Gdk.GC gc = GetGC (color);
			if (textEditor.Options.ShowRuler) {
				int divider = System.Math.Max (area.Left, System.Math.Min (x + rulerX, area.Right));
				if (divider < area.Right) {
					win.DrawRectangle (gc, true, new Rectangle (area.X, area.Y, divider - area.X, area.Height));
					gc = GetGC (DimColor (color));
					win.DrawRectangle (gc, true, new Rectangle (divider, area.Y, area.Right - divider, area.Height));
					win.DrawLine (GetGC (ColorStyle.Ruler), divider, area.Top, divider, area.Bottom);
					return;
				}
			}
			win.DrawRectangle (gc, true, area);
		}
Esempio n. 22
0
        void PaintFoldMarker(Gdk.Drawable g, int lineNumber, System.Drawing.Rectangle drawingRectangle)
        {
            HighlightColor foldLineColor = textArea.Document.HighlightingStrategy.GetColorFor("FoldLine");

            bool isFoldStart = textArea.Document.FoldingManager.IsFoldStart(lineNumber);
            bool isBetween   = textArea.Document.FoldingManager.IsBetweenFolding(lineNumber);
            bool isFoldEnd   = textArea.Document.FoldingManager.IsFoldEnd(lineNumber);

            int foldMarkerSize = (int)Math.Round(textArea.TextView.FontHeight * 0.57f);
            foldMarkerSize -= (foldMarkerSize) % 2;
            int foldMarkerYPos = drawingRectangle.Y + (int)((drawingRectangle.Height - foldMarkerSize) / 2);
            int xPos = drawingRectangle.X + (drawingRectangle.Width - foldMarkerSize) / 2 + foldMarkerSize / 2;

            if (isFoldStart) {
                ArrayList startFoldings = textArea.Document.FoldingManager.GetFoldingsWithStart(lineNumber);
                bool isVisible = true;
                bool moreLinedOpenFold = false;
                foreach (FoldMarker foldMarker in startFoldings) {
                    if (foldMarker.IsFolded) {
                        isVisible = false;
                    } else {
                        moreLinedOpenFold = foldMarker.EndLine > foldMarker.StartLine;
                    }
                }

                ArrayList endFoldings = textArea.Document.FoldingManager.GetFoldingsWithEnd(lineNumber);
                bool isFoldEndFromUpperFold = false;
                foreach (FoldMarker foldMarker in endFoldings) {
                    if (foldMarker.EndLine > foldMarker.StartLine && !foldMarker.IsFolded) {
                        isFoldEndFromUpperFold = true;
                    }
                }

                DrawFoldMarker(g, new RectangleF(drawingRectangle.X + (drawingRectangle.Width - foldMarkerSize) / 2,
                                                 foldMarkerYPos,
                                                 foldMarkerSize,
                                                 foldMarkerSize),
                                  isVisible);
                if (isBetween || isFoldEndFromUpperFold) {
                    using (Gdk.GC gc = new Gdk.GC(g)) {
                        gc.RgbFgColor = new Gdk.Color (foldLineColor.Color);

                        g.DrawLine(gc,
                               xPos,
                               drawingRectangle.Top,
                               xPos,
                               foldMarkerYPos);
                    }
                }

                if (isBetween || moreLinedOpenFold) {
                    using (Gdk.GC gc = new Gdk.GC(g)) {
                        gc.RgbFgColor = new Gdk.Color (foldLineColor.Color);
                        g.DrawLine(gc,
                               xPos,
                               foldMarkerYPos + foldMarkerSize,
                               xPos,
                               drawingRectangle.Bottom);
                    }
                }
            } else {
                if (isFoldEnd) {
                    int midy = drawingRectangle.Top + drawingRectangle.Height / 2;
                    using (Gdk.GC gc = new Gdk.GC(g)) {
                        gc.RgbFgColor = new Gdk.Color (foldLineColor.Color);
                        g.DrawLine(gc,
                                    xPos,
                                    drawingRectangle.Top,
                                    xPos,
                                    isBetween ? drawingRectangle.Bottom : midy);
                        g.DrawLine(gc,
                                    xPos,
                                    midy,
                                    xPos + foldMarkerSize / 2,
                                    midy);
                    }
                } else if (isBetween) {
                    using (Gdk.GC gc = new Gdk.GC(g)) {
                        gc.RgbFgColor = new Gdk.Color (foldLineColor.Color);
                        g.DrawLine(gc,
                                    xPos,
                                    drawingRectangle.Top,
                                    xPos,
                                    drawingRectangle.Bottom);
                    }
                }
            }
        }
Esempio n. 23
0
        void DrawTicks(Gdk.Window win, Gdk.GC gc, TickEnumerator e, AxisPosition pos, AxisDimension ad, int tickSize, bool showLabels)
        {
            int rwidth, rheight;
            win.GetSize (out rwidth, out rheight);

            Pango.Layout layout = null;

            if (showLabels) {
                layout = new Pango.Layout (this.PangoContext);
                layout.FontDescription = Pango.FontDescription.FromString ("Tahoma 8");
            }

            bool isX = pos == AxisPosition.Top || pos == AxisPosition.Bottom;
            bool isTop = pos == AxisPosition.Top || pos == AxisPosition.Right;

            double start = GetStart (ad);
            double end = GetEnd (ad);

            e.Init (GetOrigin (ad));

            while (e.CurrentValue > start)
                e.MovePrevious ();

            int lastPosLabel;
            int lastPos;
            int lastTw = 0;

            if (isX) {
                lastPosLabel = reverseXAxis ? left + width + MinLabelGapX : left - MinLabelGapX;
                lastPos = left - minTickStep*2;
            }
            else {
                lastPosLabel = reverseYAxis ? top - MinLabelGapY : rheight + MinLabelGapY;
                lastPos = top + height + minTickStep*2;
            }

            for ( ; e.CurrentValue <= end; e.MoveNext ())
            {
                int px, py;
                int tw = 0, th = 0;
                int tick = tickSize;

                GetPoint (e.CurrentValue, e.CurrentValue, out px, out py);

                if (showLabels) {
                    layout.SetMarkup (e.CurrentLabel);
                    layout.GetPixelSize (out tw, out th);
                }

                if (isX) {
                    if (Math.Abs ((long)px - (long)lastPos) < minTickStep || px < left || px > left + width)
                        continue;
                    lastPos = px;

                    bool labelFits = false;
                    if ((Math.Abs (px - lastPosLabel) - (tw/2) - (lastTw/2)) >= MinLabelGapX) {
                        lastPosLabel = px;
                        lastTw = tw;
                        labelFits = true;
                    }

                    if (isTop) {
                        if (showLabels) {
                            if (labelFits)
                                win.DrawLayout (gc, px - (tw/2), top - AreaBorderWidth - th, layout);
                            else
                                tick = tick / 2;
                        }
                        win.DrawLine (gc, px, top, px, top + tick);
                    }
                    else {
                        if (showLabels) {
                            if (labelFits)
                                win.DrawLayout (gc, px - (tw/2), top + height + AreaBorderWidth, layout);
                            else
                                tick = tick / 2;
                        }
                        win.DrawLine (gc, px, top + height, px, top + height - tick);
                    }
                }
                else {
                    if (Math.Abs ((long)lastPos - (long)py) < minTickStep || py < top || py > top + height)
                        continue;
                    lastPos = py;

                    bool labelFits = false;
                    if ((Math.Abs (py - lastPosLabel) - (th/2) - (lastTw/2)) >= MinLabelGapY) {
                        lastPosLabel = py;
                        lastTw = th;
                        labelFits = true;
                    }

                    if (isTop) {
                        if (showLabels) {
                            if (labelFits)
                                win.DrawLayout (gc, left + width + AreaBorderWidth + 1, py - (th/2), layout);
                            else
                                tick = tick / 2;
                        }
                        win.DrawLine (gc, left + width, py, left + width - tick, py);
                    }
                    else {
                        if (showLabels) {
                            if (labelFits)
                                win.DrawLayout (gc, left - AreaBorderWidth - tw - 1, py - (th/2), layout);
                            else
                                tick = tick / 2;
                        }
                        win.DrawLine (gc, left, py, left + tick, py);
                    }
                }
            }
        }
		public override void Draw (TextEditor editor, Gdk.Drawable win, Pango.Layout layout, bool selected, int startOffset, int endOffset, int y, int startXPos, int endXPos)
		{
			int markerStart = line.Offset + startColumn;
			int markerEnd = line.Offset + endColumn;
	
			if (markerEnd < startOffset || markerStart > endOffset) 
				return; 
	
			int @from;
			int to;
	
			if (markerStart < startOffset && endOffset < markerEnd) {
				@from = startXPos;
				to = endXPos;
			} else {
				int start = startOffset < markerStart ? markerStart : startOffset;
				int end = endOffset < markerEnd ? endOffset : markerEnd;
				int x_pos = layout.IndexToPos (start - startOffset).X;
	
				@from = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
	
				x_pos = layout.IndexToPos (end - startOffset).X;
	
				to = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
			}
	
			@from = System.Math.Max (@from, editor.TextViewMargin.XOffset);
			to = System.Math.Max (to, editor.TextViewMargin.XOffset);
			if (@from < to) {
				using (Gdk.GC gc = new Gdk.GC(win)) {
					gc.RgbFgColor = selected ? editor.ColorStyle.Selection.Color : editor.ColorStyle.GetChunkStyle (style).Color;
					win.DrawLine (gc, @from, y + editor.LineHeight - 1, to, y + editor.LineHeight - 1);
				}
			}
		}
		internal protected override void Draw (Gdk.Drawable win, Gdk.Rectangle area, int line, int x, int y, int lineHeight)
		{
			foldSegmentSize = Width * 4 / 6;
			foldSegmentSize -= (foldSegmentSize) % 2;
			
			Gdk.Rectangle drawArea = new Gdk.Rectangle (x, y, Width, lineHeight);
			Document.LineState state = editor.Document.GetLineState (line);
			
			bool isFoldStart = false;
			bool isContaining = false;
			bool isFoldEnd = false;
			
			bool isStartSelected = false;
			bool isContainingSelected = false;
			bool isEndSelected = false;
			
			if (line < editor.Document.LineCount) {
				LineSegment lineSegment = editor.Document.GetLine (line);
				startFoldings.Clear ();
				containingFoldings.Clear ();
				endFoldings.Clear ();
				foreach (FoldSegment segment in editor.Document.GetFoldingContaining (lineSegment)) {
					if (segment.StartLine.Offset == lineSegment.Offset) {
						startFoldings.Add (segment);
					} else if (segment.EndLine.Offset == lineSegment.Offset) {
						endFoldings.Add (segment);
					} else {
						containingFoldings.Add (segment);
					}
				}
				
				isFoldStart  = startFoldings.Count > 0;
				isContaining = containingFoldings.Count > 0;
				isFoldEnd    = endFoldings.Count > 0;
				
				isStartSelected      = this.lineHover != null && IsMouseHover (startFoldings);
				isContainingSelected = this.lineHover != null && IsMouseHover (containingFoldings);
				isEndSelected        = this.lineHover != null && IsMouseHover (endFoldings);
			}
			
			Gdk.GC bgGC = foldBgGC;
			if (editor.TextViewMargin.BackgroundRenderer != null) {
				if (isContainingSelected || isStartSelected || isEndSelected) {
					bgGC = foldBgGC;
				} else {
					bgGC = foldLineHighlightedGCBg;
				}
			}
			
			win.DrawRectangle (bgGC, true, drawArea);
			if (state == Document.LineState.Changed) {
				win.DrawRectangle (lineStateChangedGC, true, x + 1, y, Width / 3, lineHeight);
		//		win.DrawRectangle (bgGC, true, x + 3 , y, Width  - 3, lineHeight);
			} else if (state == Document.LineState.Dirty) {
				win.DrawRectangle (lineStateDirtyGC, true, x + 1, y, Width / 3, lineHeight);
		//		win.DrawRectangle (bgGC, true, x + 3 , y, Width - 3, lineHeight);
			}/* else {
				win.DrawRectangle (bgGC, true, drawArea);
			}*/
			
			if (line < editor.Document.LineCount) {
			
				int foldSegmentYPos = y + (editor.LineHeight - foldSegmentSize) / 2;
				int xPos = x + Width / 2;
				
				if (isFoldStart) {
					bool isVisible         = true;
					bool moreLinedOpenFold = false;
					foreach (FoldSegment foldSegment in startFoldings) {
						if (foldSegment.IsFolded) {
							isVisible = false;
						} else {
							moreLinedOpenFold = foldSegment.EndLine.Offset > foldSegment.StartLine.Offset;
						}
					}
					bool isFoldEndFromUpperFold = false;
					foreach (FoldSegment foldSegment in endFoldings) {
						if (foldSegment.EndLine.Offset > foldSegment.StartLine.Offset && !foldSegment.IsFolded) 
							isFoldEndFromUpperFold = true;
					}
					DrawFoldSegment (win, x, y, isVisible, isStartSelected);
					if (isContaining || isFoldEndFromUpperFold) 
						win.DrawLine (isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, drawArea.Top, xPos, foldSegmentYPos - 2);
					if (isContaining || moreLinedOpenFold) 
						win.DrawLine (isEndSelected || (isStartSelected && isVisible) || isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, foldSegmentYPos + foldSegmentSize + 2, xPos, drawArea.Bottom);
				} else {
					if (isFoldEnd) {
						int yMid = drawArea.Top + drawArea.Height / 2;
						win.DrawLine (isEndSelected ? foldLineHighlightedGC : foldLineGC, xPos, yMid, x + Width - 2, yMid);
						win.DrawLine (isContainingSelected || isEndSelected ? foldLineHighlightedGC : foldLineGC, xPos, drawArea.Top, xPos, yMid);
						if (isContaining) 
							win.DrawLine (isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, yMid + 1, xPos, drawArea.Bottom);
					} else if (isContaining) {
						win.DrawLine (isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, drawArea.Top, xPos, drawArea.Bottom);
					}
				}
			}
		}
		internal protected override void Draw (Gdk.Drawable win, Gdk.Rectangle area, long line, int x, int y)
		{
			int top = y;
			int bottom = top + this.Editor.LineHeight;
			bool isOdd = (top + (int)this.Data.VAdjustment.Value) % 2 != 0;
			win.DrawLine (isOdd? bgGC : bgGC2, x, top, x, bottom);
			win.DrawLine (isOdd? foldDashedLineGC : foldDashedLineGC2, x, top, x, bottom);
		}