示例#1
0
		public override void Render (Gdk.Drawable window, Gdk.Rectangle bounds, Gtk.StateType state)
		{
			Gdk.GC gc = new Gdk.GC (window);
	   		gc.RgbFgColor = (Gdk.Color) Value;
			window.DrawRectangle (gc, true, bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1);
			window.DrawRectangle (Container.Style.BlackGC, false, bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1);
		}
		public override void Render (Gdk.Drawable window, Gdk.Rectangle bounds, Gtk.StateType state)
		{
			Gdk.GC gc = new Gdk.GC (window);
	   		gc.RgbFgColor = GetColor ();
	   		int yd = (bounds.Height - ColorBoxSize) / 2;
			window.DrawRectangle (gc, true, bounds.X, bounds.Y + yd, ColorBoxSize - 1, ColorBoxSize - 1);
			window.DrawRectangle (Container.Style.BlackGC, false, bounds.X, bounds.Y + yd, ColorBoxSize - 1, ColorBoxSize - 1);
			bounds.X += ColorBoxSize + ColorBoxSpacing;
			bounds.Width -= ColorBoxSize + ColorBoxSpacing;
			base.Render (window, bounds, state);
		}
示例#3
0
		public override void Render (Gdk.Drawable window, Cairo.Context ctx, Gdk.Rectangle bounds, Gtk.StateType state)
		{
			using (Gdk.GC gc = new Gdk.GC (window)) {
				gc.RgbFgColor = GetColor ();
				int yd = (bounds.Height - ColorBoxSize) / 2;
				window.DrawRectangle (gc, true, bounds.X, bounds.Y + yd, ColorBoxSize - 1, ColorBoxSize - 1);
				window.DrawRectangle (Container.GetNativeWidget<Gtk.Widget> ().Style.BlackGC, false, bounds.X, bounds.Y + yd, ColorBoxSize - 1, ColorBoxSize - 1);
				bounds.X += ColorBoxSize + ColorBoxSpacing;
				bounds.Width -= ColorBoxSize + ColorBoxSpacing;
				base.Render (window, ctx, bounds, state);
			}
		}
		internal protected override void Draw (Gdk.Drawable drawable, Gdk.Rectangle area, long line, int x, int y)
		{
			drawable.DrawRectangle (GetGC (Style.HexOffsetBg), true, x, y, Width, Editor.LineHeight);
			LayoutWrapper layout = GetLayout (line);
			int w, h;
			layout.Layout.GetPixelSize (out w, out h);
			drawable.DrawLayout (GetGC (line != Caret.Line ? Style.HexOffset : Style.HexOffsetHighlighted), x + Width - w - 4, y, layout.Layout);
			if (layout.IsUncached)
				layout.Dispose ();
		}
		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;
				}
			}
		}
示例#6
0
        public override void Render(Gdk.Drawable window, Gdk.Rectangle bounds, Gtk.StateType state)
        {
            int iy = bounds.Y + (bounds.Height - imgSize) / 2;

            if (image != null) {
                int dy = (imgSize - image.Height) / 2;
                int dx = (imgSize - image.Width) / 2;
                window.DrawPixbuf (Container.Style.BackgroundGC (state), image, 0, 0, bounds.X + dx, iy + dy, -1, -1, Gdk.RgbDither.None, 0, 0);
            }

            window.DrawRectangle (Container.Style.DarkGC (state), false, bounds.X, iy, imgSize - 1, imgSize - 1);

            bounds.X += imgSize + spacing;
            base.Render (window, bounds, state);
        }
示例#7
0
    protected override void Render(Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area,
		Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
    {
        int width = 0, height = 0, x_offset = 0, y_offset = 0;
        GetSize (widget, ref cell_area, out x_offset, out y_offset, out width, out height);

        width -= (int) this.Xpad * 2;
        height -= (int) this.Ypad * 2;

        Gdk.Rectangle clipping_area = new Gdk.Rectangle ((int) (cell_area.X + x_offset + this.Xpad),
            (int) (cell_area.Y + y_offset + this.Ypad), width - 1, height - 1);

        using (Gdk.GC gc = new Gdk.GC (window)) {
            gc.RgbFgColor = ColorFromBrush (List.TypeBrushes [Idx]);
            window.DrawRectangle (gc,
                        true,
                        clipping_area);

        }
    }
        public override void Paint(Gdk.Drawable wnd, Rectangle rect)
        {
            HighlightColor lineNumberPainterColor = textArea.Document.HighlightingStrategy.GetColorFor("LineNumbers");

            Gdk.Color rect_fg = TextArea.Style.White;
            Gdk.Color text_fg = new Gdk.Color (lineNumberPainterColor.Color);
            Gdk.Color text_bg = new Gdk.Color (lineNumberPainterColor.BackgroundColor);

            using (Gdk.GC gc = new Gdk.GC (wnd)) {
                gc.RgbFgColor = rect_fg;
                wnd.DrawRectangle (gc, true, new System.Drawing.Rectangle (drawingPosition.X, rect.Top, drawingPosition.Width - 1, rect.Height));

                //g.DrawLine(SystemPens.ControlDark, base.drawingPosition.Right - 1, rect.Top, base.drawingPosition.Right - 1, rect.Bottom);

                // paint icons
                foreach (int mark in textArea.Document.BookmarkManager.Marks) {
                    int lineNumber = textArea.Document.GetLogicalLine(mark);
                    int yPos = (int)(lineNumber * textArea.TextView.FontHeight) - textArea.VirtualTop.Y;
            //					if (yPos >= rect.Y && yPos <= rect.Bottom) {
                        DrawBookmark(gc, wnd, yPos);
            //					}
                }
            }
        }
		/// <summary>
		/// Render an annotation on each line
		/// </summary>
		protected override void Draw (Gdk.Drawable drawable, Gdk.Rectangle area, int line, int x, int y, int lineHeight)
		{
			string ann = (line < annotations.Count)? annotations[line]: string.Empty;
			Gdk.Rectangle drawArea = new Gdk.Rectangle (x, y, Width, lineHeight);
			drawable.DrawRectangle (locallyModified.Equals (ann, StringComparison.Ordinal)? locallyModifiedGC: lineNumberBgGC, true, drawArea);
			
			if (!locallyModified.Equals (ann, StringComparison.Ordinal) &&
			    (line < annotations.Count)) {
				layout.SetText (annotations[line]);
				drawable.DrawLayout ((editor.Caret.Line == line)? lineNumberHighlightGC: lineNumberGC, x + 1, y, layout);
			}
		}
示例#10
0
 /*
  *
  * DRAWINGAREA
  *
  */
 public static void ErasePaint(Gtk.DrawingArea da, Gdk.Pixmap px)
 {
     px.DrawRectangle (da.Style.WhiteGC, true, 0, 0, da.Allocation.Width, da.Allocation.Height);
     da.QueueDraw(); // -- refresh
 }
        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);
                    }
                }
            }}
        }
        /// <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
        }
示例#13
0
        private void DrawMoveHint(Gdk.Window window)
        {
            string letters = "abcdefgh";
            string numbers = "87654321";

            if (moveHint == null)
                return;

            for (int k = 0; k < moveHint.Length; k += 3)
              {
                  int i = -1, j = -1;

                  i = letters.IndexOf (moveHint[k]);
                  j = numbers.IndexOf (moveHint[k + 1]);

                  if (i < 0 && j < 0)
                      continue;

                  if (side)
                    {
                        i = 7 - i;
                        j = 7 - j;
                    }

                  int x = start_x + i * (space + size);
                  int y = start_y + j * (space + size);

                  window.DrawRectangle (Style.
                            BackgroundGC
                            (StateType.Prelight),
                            true, x, y, size,
                            size);
              }
        }
示例#14
0
        private void RenderSelection (Gdk.Drawable drawable, Gdk.Rectangle background_area,
            bool selected, StateType state)
        {
            if (view == null) {
                return;
            }

            if (selected && view.Cr != null) {
                Gdk.Rectangle rect = background_area;
                rect.X -= 2;
                rect.Width += 4;

                // clear the standard GTK selection and focus
                drawable.DrawRectangle (view.Style.BaseGC (StateType.Normal), true, rect);

                // draw the hot cairo selection
                if (!view.EditingRow) {
                    view.Theme.DrawRowSelection (view.Cr, background_area.X + 1, background_area.Y + 1,
                        background_area.Width - 2, background_area.Height - 2);
                }
            } else if (!TreeIter.Zero.Equals (iter) && iter.Equals (view.HighlightedIter) && view.Cr != null) {
                view.Theme.DrawRowSelection (view.Cr, background_area.X + 1, background_area.Y + 1,
                    background_area.Width - 2, background_area.Height - 2, false);
            } else if (view.NotifyStage.ActorCount > 0 && view.Cr != null) {
                if (!TreeIter.Zero.Equals (iter) && view.NotifyStage.Contains (iter)) {
                    Actor<TreeIter> actor = view.NotifyStage[iter];
                    Cairo.Color color = view.Theme.Colors.GetWidgetColor (GtkColorClass.Background, StateType.Active);
                    color.A = Math.Sin (actor.Percent * Math.PI);

                    view.Theme.DrawRowSelection (view.Cr, background_area.X + 1, background_area.Y + 1,
                        background_area.Width - 2, background_area.Height - 2, true, true, color);
                }
            }
        }
        public override void Paint(Gdk.Drawable wnd, System.Drawing.Rectangle rect)
        {
            HighlightColor lineNumberPainterColor = textArea.Document.HighlightingStrategy.GetColorFor("LineNumbers");

            Gdk.Color rect_fg = TextArea.Style.White;
            Gdk.Color text_fg = new Gdk.Color (lineNumberPainterColor.Color);
            Gdk.Color text_bg = new Gdk.Color (lineNumberPainterColor.BackgroundColor);

            using (Gdk.GC gc = new Gdk.GC(wnd)) {
            for (int y = 0; y < (DrawingPosition.Height + textArea.TextView.VisibleLineDrawingRemainder) / textArea.TextView.FontHeight + 1; ++y) {

                gc.RgbFgColor = rect_fg;
                System.Drawing.Rectangle markerRectangle = new System.Drawing.Rectangle(DrawingPosition.X, DrawingPosition.Top + y * textArea.TextView.FontHeight - textArea.TextView.VisibleLineDrawingRemainder, DrawingPosition.Width, textArea.TextView.FontHeight);

                if (rect.IntersectsWith(markerRectangle)) {
                    wnd.DrawRectangle (gc, true, new System.Drawing.Rectangle (markerRectangle.X + 1, markerRectangle.Y, markerRectangle.Width - 1, markerRectangle.Height));

                    int currentLine = textArea.TextView.FirstVisibleLine + y;
                    PaintFoldMarker(wnd, currentLine, markerRectangle);
                } //Using
            }
            }
        }
示例#16
0
		void DecorateMatchingBracket (Gdk.Drawable win, LayoutWrapper layout, int offset, int length, int xPos, int y, int selectionStart, int selectionEnd)
		{
			uint curIndex = 0, byteIndex = 0;
			if (offset <= highlightBracketOffset && highlightBracketOffset <= offset + length) {
				int index = highlightBracketOffset - offset;
				Pango.Rectangle rect = layout.Layout.IndexToPos ((int)TranslateToUTF8Index (layout.LineChars, (uint)index, ref curIndex, ref byteIndex));
				
				Gdk.Rectangle bracketMatch = new Gdk.Rectangle (xPos + (int)(rect.X / Pango.Scale.PangoScale), y, (int)(rect.Width / Pango.Scale.PangoScale) - 1, (int)(rect.Height / Pango.Scale.PangoScale) - 1);
				if (BackgroundRenderer == null)
					win.DrawRectangle (GetGC (this.ColorStyle.BracketHighlightRectangle.BackgroundColor), true, bracketMatch);
				
				win.DrawRectangle (GetGC (this.ColorStyle.BracketHighlightRectangle.Color), false, bracketMatch);
			}
		}
			public bool DrawBackground (TextEditor editor, Gdk.Drawable win, TextViewMargin.LayoutWrapper layout, int selectionStart, int selectionEnd, int startOffset, int endOffset, int y, int startXPos, int endXPos, ref bool drawBg)
			{
				drawBg = false;
				if (selectionStart >= 0 || editor.CurrentMode is TextLinkEditMode)
					return true;
				foreach (ISegment usage in Usages) {
					int markerStart = usage.Offset;
					int markerEnd = usage.EndOffset;
					
					if (markerEnd < startOffset || markerStart > endOffset) 
						return true; 
					
					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;
						
						uint curIndex = 0, byteIndex = 0;
						TextViewMargin.TranslateToUTF8Index (layout.LineChars, (uint)(start - startOffset), ref curIndex, ref byteIndex);
						
						int x_pos = layout.Layout.IndexToPos ((int)byteIndex).X;
						
						@from = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
						
						TextViewMargin.TranslateToUTF8Index (layout.LineChars, (uint)(end - startOffset), ref curIndex, ref byteIndex);
						x_pos = layout.Layout.IndexToPos ((int)byteIndex).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 = 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);
						}
					}
				}
				return true;
			}
        void DrawBookmark(Gdk.GC gc, Gdk.Drawable wnd, int y)
        {
            gc.RgbFgColor = new Gdk.Color (Color.DarkBlue);
            int delta = textArea.TextView.FontHeight / 6;
            Rectangle rect = new Rectangle( 2, y + delta, base.drawingPosition.Width - 6, textArea.TextView.FontHeight - 2 * delta);

            wnd.DrawRectangle (gc, true, rect);

            gc.RgbFgColor = new Gdk.Color (Color.Black);

            wnd.DrawRectangle (gc, false, rect);
            //FillRoundRect(g, Brushes.Cyan, rect);
            //DrawRoundRect(g, Pens.Black, rect);
        }
		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;
			}
		}
示例#20
0
		protected internal override void Draw (Gdk.Drawable win, Gdk.Rectangle area, int lineNr, int x, int y, int _lineHeight)
		{
			//			int visibleLine = y / this.LineHeight;
			//			this.caretX = -1;
			LineSegment line = lineNr < Document.LineCount ? Document.GetLine (lineNr) : null;
			int xStart = System.Math.Max (area.X, XOffset);
			xStart = System.Math.Max (0, xStart);
			
			Gdk.Rectangle lineArea = new Gdk.Rectangle (XOffset, y, textEditor.Allocation.Width - XOffset, textEditor.LineHeight);
			int width, height;
			int pangoPosition = (int)((x - textEditor.HAdjustment.Value + TextStartPosition) * Pango.Scale.PangoScale);
			
			// Draw the default back color for the whole line. Colors other than the default
			// background will be drawn when rendering the text chunks.
			
			bool isSelectionDrawn = false;

			if (BackgroundRenderer != null)
				BackgroundRenderer.Draw (win, area, line, x, y, _lineHeight);
			
			if ((HighlightCaretLine || textEditor.Options.HighlightCaretLine) && Caret.Line == lineNr)
				defaultBgColor = ColorStyle.LineMarker;
			else
				defaultBgColor = ColorStyle.Default.BackgroundColor;
			DrawRectangleWithRuler (win, x, lineArea, defaultBgColor, true);
			
			// Check if line is beyond the document length
			
			if (line == null) {
				if (textEditor.Options.ShowInvalidLines) {
					DrawInvalidLineMarker (win, (int)(pangoPosition / Pango.Scale.PangoScale), y);
				}
				var marker = Document.GetExtendingTextMarker (lineNr);
				if (marker != null) 
					marker.Draw (textEditor, win, lineNr, lineArea);
				return;
			}
			//selectedRegions.Clear ();
			
			IEnumerable<FoldSegment> foldings = Document.GetStartFoldings (line);
			int offset = line.Offset;
			int caretOffset = Caret.Offset;
			restart:
			foreach (FoldSegment folding in foldings) {
				int foldOffset = folding.StartLine.Offset + folding.Column;
				if (foldOffset < offset)
					continue;
				
				if (folding.IsFolded) {
					//					layout.SetText (Document.GetTextAt (offset, foldOffset - offset));
					//					gc.RgbFgColor = ColorStyle.FoldLine;
					//					win.DrawLayout (gc, xPos, y, layout);
					//					layout.GetPixelSize (out width, out height);
					
					DrawLinePart (win, line, offset, foldOffset - offset, ref pangoPosition, ref isSelectionDrawn, y, area.Right);
					//					xPos += width;
					offset = folding.EndLine.Offset + folding.EndColumn;
					markerLayout.SetText (folding.Description);
					
					markerLayout.GetSize (out width, out height);
					bool isFoldingSelected = !this.HideSelection && textEditor.IsSomethingSelected && textEditor.SelectionRange.Contains (folding);
					int pixelX = (int)(pangoPosition / Pango.Scale.PangoScale);
					int pixelWidth = (int)((pangoPosition + width) / Pango.Scale.PangoScale) - pixelX;
					Rectangle foldingRectangle = new Rectangle (pixelX, y, pixelWidth - 1, this.LineHeight - 1);
					if (BackgroundRenderer == null)
						win.DrawRectangle (GetGC (isFoldingSelected ? SelectionColor.BackgroundColor : defaultBgColor), true, foldingRectangle);
					/*
					using (Cairo.Context cr = Gdk.CairoHelper.Create (win)) {
						cr.Color = Mono.TextEditor.Highlighting.Style.ToCairoColor (isFoldingSelected ? SelectionColor.Color : ColorStyle.FoldLine.Color);
						cr.LineWidth = textEditor.Options.Zoom;
						FoldingScreenbackgroundRenderer.DrawRoundRectangle (cr, true, true, 
						                                                    foldingRectangle.X, 
						                                                    foldingRectangle.Y, 
						                                                    textEditor.LineHeight / 2, 
						                                                    foldingRectangle.Width, 
						                                                    foldingRectangle.Height);
						cr.Stroke ();
					}*/
					win.DrawRectangle (GetGC (isFoldingSelected ? SelectionColor.Color : ColorStyle.FoldLine.Color), false, foldingRectangle);
					win.DrawLayout (GetGC (isFoldingSelected ? SelectionColor.Color : ColorStyle.FoldLine.Color), (int)(pangoPosition / Pango.Scale.PangoScale), y, markerLayout);
					
					if (caretOffset == foldOffset && !string.IsNullOrEmpty (folding.Description))
						SetVisibleCaretPosition (win, folding.Description[0], (int)(pangoPosition / Pango.Scale.PangoScale), y);
					
					pangoPosition += width;
					
					if (folding.EndLine != line) {
						line = folding.EndLine;
						foldings = Document.GetStartFoldings (line);
						goto restart;
					}
				}
			}
			
			// Draw remaining line - must be called for empty line parts as well because the caret may be at this positon 
			// and the caret position is calculated in DrawLinePart.
			if (line.EndOffset - offset >= 0)
				DrawLinePart (win, line, offset, line.Offset + line.EditableLength - offset, ref pangoPosition, ref isSelectionDrawn, y, area.Right);
			
			bool isEolSelected = !this.HideSelection && textEditor.IsSomethingSelected && textEditor.SelectionMode == SelectionMode.Normal && textEditor.SelectionRange.Contains (line.Offset + line.EditableLength);
			
			lineArea.X = (int)(pangoPosition / Pango.Scale.PangoScale);
			lineArea.Width = textEditor.Allocation.Width - (int)(pangoPosition / Pango.Scale.PangoScale);
			
			if (textEditor.SelectionMode == SelectionMode.Block && textEditor.IsSomethingSelected && textEditor.SelectionRange.Contains (line.Offset + line.EditableLength)) {
				DocumentLocation start = textEditor.MainSelection.Anchor;
				DocumentLocation end = textEditor.MainSelection.Lead;
				DocumentLocation visStart = Document.LogicalToVisualLocation (this.textEditor.GetTextEditorData (), start);
				DocumentLocation visEnd = Document.LogicalToVisualLocation (this.textEditor.GetTextEditorData (), end);
				
				int x1 = this.ColumnToVisualX (line, visStart.Column);
				int x2 = this.ColumnToVisualX (line, visEnd.Column);
				if (x1 > x2) {
					int tmp = x1;
					x1 = x2;
					x2 = tmp;
				}
				x1 += (int)(XOffset - textEditor.HAdjustment.Value);
				x2 += (int)(XOffset - textEditor.HAdjustment.Value);
				
				if (x2 > lineArea.X) {
					if (x1 - lineArea.X > 0) {
						DrawRectangleWithRuler (win, x, new Gdk.Rectangle (lineArea.X, lineArea.Y, x1 - lineArea.X, lineArea.Height), defaultBgColor, false);
						lineArea.X = x1;
					}
					DrawRectangleWithRuler (win, x, new Gdk.Rectangle (lineArea.X, lineArea.Y, x2 - lineArea.X, lineArea.Height), this.SelectionColor.BackgroundColor, false);
					lineArea.X = x2;
					lineArea.Width = textEditor.Allocation.Width - lineArea.X;
				}
			}
			if (!isSelectionDrawn)
				DrawRectangleWithRuler (win, x, lineArea, isEolSelected ? this.SelectionColor.BackgroundColor : defaultBgColor, false);
			if (textEditor.Options.ShowEolMarkers)
				DrawEolMarker (win, isEolSelected, (int)(pangoPosition / Pango.Scale.PangoScale), y);
			var extendingMarker = Document.GetExtendingTextMarker (lineNr);
			if (extendingMarker != null) 
				extendingMarker.Draw (textEditor, win, lineNr, lineArea);
//			int lineEndX = (int)(pangoPosition / Pango.Scale.PangoScale);
//			win.DrawLine (GetGC (new Color (255, 0, 0)), lineEndX, y, lineEndX, y + LineHeight);
			lastLineRenderWidth = (int)(pangoPosition / Pango.Scale.PangoScale);
		}
		internal protected override void Draw (Gdk.Drawable win, Gdk.Rectangle area, int line, int x, int y, int lineHeight)
		{
			Gdk.Rectangle drawArea = new Rectangle (x, y, Width, lineHeight);
			win.DrawRectangle (lineNumberBgGC, true, drawArea);
			layout.Alignment = Pango.Alignment.Right;
			layout.Width = Width;
			
			if (line < editor.Document.LineCount) {
				layout.SetText ((line + 1).ToString ());
				win.DrawLayout (editor.Caret.Line == line ? lineNumberHighlightGC : lineNumberGC, x + Width, y, layout);
			}
		}
        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);

                }
            }
        }
示例#23
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);
		}
        private void DrawSelectionRect(Gtk.Widget widget, Gdk.Window window)
        {
            Gdk.GC gc = widget.Style.WhiteGC;
            gc.SetLineAttributes (1, LineStyle.OnOffDash, CapStyle.Butt, JoinStyle.Miter);
            gc.Function = Function.Xor;
            selectionRectangle.Normalize ();

            RectangleD r = selectionRectangle;
            PointD p = View.DrawingToView(r.X, r.Y);

            window.DrawRectangle (gc, false, (int) p.X,
                                   (int) p.Y,
                                   (int) (r.Width * View.Scale),
                                   (int) (r.Height * View.Scale));
        }
示例#25
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;
			}
			
		}
		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);
		}
示例#27
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);
            }

                  }
        }
        private void DrawRedGradientRectangle(ref Gdk.Drawable window, 
												 int x, int y, 
												 int width, int height)
        {
            int step = (0xFF / height) - 3;

            for (int i=0; i < height; i++) {
                Gdk.GC gc = new Gdk.GC(window);
                byte r = (byte) (0xFF - (i*step));
                byte g = 0;
                byte b = 0;
                gc.RgbFgColor = new Gdk.Color(r, g, b);
                window.DrawRectangle(gc, true, x, y + i, width, 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);
					}
				}
			}
		}
 /// <summary>
 /// Redraws the background over the slider area on both sides of the control
 /// </summary>
 private void ClearSlider(Gdk.Window g)
 {
     //Brush brush = System.Drawing.SystemBrushes.Control;
     Gdk.Color color = this.Style.Background( this.State );
     Gdk.GC gc       = new Gdk.GC( g );
     gc.RgbBgColor   = color;
     gc.RgbFgColor   = color;
     g.DrawRectangle( gc, true, 0, 0, 8, this.Allocation.Height);				//	clear left hand slider
     g.DrawRectangle( gc, true, this.Allocation.Width - 8, 0, 8, this.Allocation.Height);	//	clear right hand slider
 }