protected override void Render (Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
		{
			base.Render (window, widget, background_area, cell_area, expose_area, flags);

			if (PackageSourceViewModel == null)
				return;
				
			using (var layout = new Pango.Layout (widget.PangoContext)) {
				layout.Alignment = Pango.Alignment.Left;
				layout.SetMarkup (GetPackageSourceNameMarkup ());
				int packageSourceNameWidth = GetLayoutWidth (layout);
				StateType state = GetState (widget, flags);

				layout.SetMarkup (GetPackageSourceDescriptionMarkup ());

				window.DrawLayout (widget.Style.TextGC (state), cell_area.X + textSpacing, cell_area.Y + textTopSpacing, layout);

				if (!PackageSourceViewModel.IsValid) {
					using (var ctx = Gdk.CairoHelper.Create (window)) {
						ctx.DrawImage (widget, warningImage, cell_area.X + textSpacing + packageSourceNameWidth + imageSpacing, cell_area.Y + textTopSpacing);
					}

					layout.SetMarkup (GetPackageSourceErrorMarkup ());
					int packageSourceErrorTextX = cell_area.X + textSpacing + packageSourceNameWidth + (int)warningImage.Width + (2 * imageSpacing);
					window.DrawLayout (widget.Style.TextGC (state), packageSourceErrorTextX, cell_area.Y + textTopSpacing, layout);
				}
			}
		}
		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 ();
		}
예제 #3
0
        protected override void Render(Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
        {
            base.Render (window, widget, background_area, cell_area, expose_area, flags);
            int xPos = cell_area.X;
            if(this.Pixbuf != null){
                window.DrawPixbuf(widget.Style.MidGC( StateType.Normal), this.Pixbuf, 0, 0, xPos + 1, cell_area.Y + 1, 16, 16, Gdk.RgbDither.Normal, 0, 0);
                xPos += 20;
            }
            using (var layout = new Pango.Layout(widget.PangoContext)) {
                layout.Alignment = Pango.Alignment.Left;
                layout.SetText(this.Text ?? "");

                StateType state = flags.HasFlag(CellRendererState.Selected) ?
                    widget.IsFocus ? StateType.Selected : StateType.Active : StateType.Normal;

                window.DrawLayout(widget.Style.TextGC(state), xPos, cell_area.Y + 2, layout);
            }
        }
		/// <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);
			}
		}
예제 #5
0
        void DrawText(Gdk.Window window, Cairo.Context cr, string text)
        {
            bool theme;
            Gdk.GC light;
            const int marginx = 10;
            int winWidth, winHeight, w, h;
            window.GetSize (out winWidth, out winHeight);

            if (project != null && project.Details.Theme != null) {
                theme = true;
            }
            else
                theme = false;

            if (theme == true) {
                if (winWidth > project.Details.Width)
                    winWidth = project.Details.Width;

                if (winHeight > project.Details.Height)
                    winHeight = project.Details.Height;
            }

            Pango.Layout layout = new Pango.Layout (this.PangoContext);
            layout.Width = winWidth * (int) Pango.Scale.PangoScale;
            layout.SetMarkup (text);
            layout.GetPixelSize (out w, out h);

            if (theme) {
                // TODO: We should force the ink colour too
                cr.Color = new Cairo.Color (0, 0, 0, 0.7);
                cr.Rectangle (((winWidth - w) /2) - marginx,  (winHeight / 2), w + marginx * 2, h * 2);
                cr.Fill ();
                cr.Stroke ();
                light = Style.LightGC (StateType.Normal);
            }

            light = Style.DarkGC (StateType.Normal);
            window.DrawLayout (light, (winWidth - w) /2, (winHeight / 2) + 4,  layout);
            layout.Dispose ();
        }
예제 #6
0
		void DrawCodeSegmentBorder (Gdk.GC gc, Cairo.Context ctx, double x, int width, BlockInfo firstBlock, BlockInfo lastBlock, string[] lines, Gtk.Widget widget, Gdk.Drawable window)
		{
			int shadowSize = 2;
			int spacing = 4;
			int bottomSpacing = (lineHeight - spacing) / 2;
			
			ctx.Rectangle (x + shadowSize + 0.5, firstBlock.YStart + bottomSpacing + spacing - shadowSize + 0.5, width - shadowSize*2, shadowSize);
			ctx.Color = new Cairo.Color (0.9, 0.9, 0.9);
			ctx.LineWidth = 1;
			ctx.Fill ();
			
			ctx.Rectangle (x + shadowSize + 0.5, lastBlock.YEnd + bottomSpacing + 0.5, width - shadowSize*2, shadowSize);
			ctx.Color = new Cairo.Color (0.9, 0.9, 0.9);
			ctx.Fill ();
			
			ctx.Rectangle (x + 0.5, firstBlock.YStart + bottomSpacing + spacing + 0.5, width, lastBlock.YEnd - firstBlock.YStart - spacing);
			ctx.Color = new Cairo.Color (0.7,0.7,0.7);
			ctx.Stroke ();
			
			string text = lines[firstBlock.FirstLine].Replace ("@","").Replace ("-","");
			text = "<span size='x-small'>" + text.Replace ("+","</span><span size='small'>➜</span><span size='x-small'> ") + "</span>";
			
			layout.SetText ("");
			layout.SetMarkup (text);
			int tw,th;
			layout.GetPixelSize (out tw, out th);
			th--;
			
			int dy = (lineHeight - th) / 2;
			
			ctx.Rectangle (x + 2 + LeftPaddingBlock - 1 + 0.5, firstBlock.YStart + dy - 1 + 0.5, tw + 2, th + 2);
			ctx.LineWidth = 1;
			ctx.Color = widget.Style.Base (Gtk.StateType.Normal).ToCairoColor ();
			ctx.FillPreserve ();
			ctx.Color = new Cairo.Color (0.7, 0.7, 0.7);
			ctx.Stroke ();
				
			window.DrawLayout (gc, (int)(x + 2 + LeftPaddingBlock), firstBlock.YStart + dy, layout);
		}
예제 #7
0
 float DrawString(Gdk.Drawable g, Gdk.GC gc, Pango.FontDescription font, float x, float y, string s)
 {
     Pango.Layout ly = _layout;
     ly.FontDescription = font;
     ly.SetText(s);
     g.DrawLayout(gc, (int) Math.Round(x), (int) Math.Round(y), ly);
     int size = (int)Math.Round(ly.Size.Width/1024.0f);
     return size;
 }
예제 #8
0
		void DrawEolMarker (Gdk.Drawable win, LineSegment line, bool selected, int x, int y)
		{
			switch (line.DelimiterLength) {
			case 1:
				if (Document.GetCharAt (line.Offset + line.EditableLength) == '\n') {
					markerLayout.SetText ("\\n");
				} else {
					markerLayout.SetText ("\\r");
				}
				break;
			case 2:
				markerLayout.SetText ("\\r\\n");
				break;
			case 4:
				markerLayout.SetText ("<EOL>");
				break;
			}
			win.DrawLayout (GetGC (selected ? SelectionColor.Color : ColorStyle.WhitespaceMarker), x, y, markerLayout);
		}
예제 #9
0
        protected override void Render (Gdk.Drawable drawable, Widget widget, Gdk.Rectangle background_area,
            Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
        {
            if (source == null || source is SourceManager.GroupSource) {
                return;
            }

            view = widget as SourceView;
            bool selected = view != null && view.Selection.IterIsSelected (iter);
            StateType state = RendererStateToWidgetState (widget, flags);

            RenderSelection (drawable, background_area, selected, state);

            int title_layout_width = 0, title_layout_height = 0;
            int count_layout_width = 0, count_layout_height = 0;
            int max_title_layout_width;

            int img_padding = 6;
            int expander_icon_spacing = 3;
            int x = cell_area.X;
            bool np_etc = (source.Order + Depth * 100) < 40;
            if (!np_etc) {
                x += Depth * img_padding + (int)Xpad;
            } else {
                // Don't indent NowPlaying and Play Queue as much
                x += Math.Max (0, (int)Xpad - 2);
            }

            Gdk.GC main_gc = widget.Style.TextGC (state);

            // Draw the expander if the source has children
            double exp_h = (cell_area.Height - 2.0*Ypad) / 3.2;
            double exp_w = exp_h * 1.6;
            if (view != null && view.Cr != null && source.Children != null && source.Children.Count > 0) {
                var r = new Gdk.Rectangle (x, cell_area.Y + (int)((cell_area.Height - exp_h) / 2.0), (int)exp_w, (int)exp_h);
                view.Theme.DrawArrow (view.Cr, r, source.Expanded ? Math.PI/2.0 : 0.0);
            }

            if (!np_etc) {
                x += (int) exp_w;
                x += 2; // a little spacing after the expander
                expander_right_x = x;
            }

            // Draw icon
            Pixbuf icon = SourceIconResolver.ResolveIcon (source, RowHeight);

            bool dispose_icon = false;
            if (state == StateType.Insensitive) {
                // Code ported from gtk_cell_renderer_pixbuf_render()
                var icon_source = new IconSource () {
                    Pixbuf = icon,
                    Size = IconSize.SmallToolbar,
                    SizeWildcarded = false
                };

                icon = widget.Style.RenderIcon (icon_source, widget.Direction, state,
                    (IconSize)(-1), widget, "SourceRowRenderer");

                dispose_icon = true;
                icon_source.Dispose ();
            }

            if (icon != null) {
                x += expander_icon_spacing;
                drawable.DrawPixbuf (main_gc, icon, 0, 0,
                    x, Middle (cell_area, icon.Height),
                    icon.Width, icon.Height, RgbDither.None, 0, 0);

                x += icon.Width;

                if (dispose_icon) {
                    icon.Dispose ();
                }
            }

            // Setup font info for the title/count, and see if we should show the count
            bool hide_count = source.EnabledCount <= 0 || source.Properties.Get<bool> ("SourceView.HideCount");
            FontDescription fd = widget.PangoContext.FontDescription.Copy ();
            fd.Weight = (ISource)ServiceManager.PlaybackController.NextSource == (ISource)source
                ? Pango.Weight.Bold
                : Pango.Weight.Normal;

            if (view != null && source == view.NewPlaylistSource) {
                fd.Style = Pango.Style.Italic;
                hide_count = true;
            }

            Pango.Layout title_layout = new Pango.Layout (widget.PangoContext);
            Pango.Layout count_layout = null;

            // If we have a count to draw, setup its fonts and see how wide it is to see if we have room
            if (!hide_count) {
                count_layout = new Pango.Layout (widget.PangoContext);
                count_layout.FontDescription = fd;
                count_layout.SetMarkup (String.Format ("<span size=\"small\">{0}</span>", source.EnabledCount));
                count_layout.GetPixelSize (out count_layout_width, out count_layout_height);
            }

            // Hide the count if the title has no space
            max_title_layout_width = cell_area.Width - x - count_layout_width;//(icon == null ? 0 : icon.Width) - count_layout_width - 10;
            if (!hide_count && max_title_layout_width <= 0) {
                hide_count = true;
            }

            // Draw the source Name
            title_layout.FontDescription = fd;
            title_layout.Width = (int)(max_title_layout_width * Pango.Scale.PangoScale);
            title_layout.Ellipsize = EllipsizeMode.End;
            title_layout.SetText (source.Name);
            title_layout.GetPixelSize (out title_layout_width, out title_layout_height);

            x += img_padding;
            drawable.DrawLayout (main_gc, x, Middle (cell_area, title_layout_height), title_layout);

            title_layout.Dispose ();

            // Draw the count
            if (!hide_count) {
                if (view != null && view.Cr != null) {
                    view.Cr.Color = state == StateType.Normal || (view != null && state == StateType.Prelight)
                        ? view.Theme.TextMidColor
                        : view.Theme.Colors.GetWidgetColor (GtkColorClass.Text, state);

                    view.Cr.MoveTo (
                        cell_area.X + cell_area.Width - count_layout_width - 2,
                        cell_area.Y + 0.5 + (double)(cell_area.Height - count_layout_height) / 2.0);
                    PangoCairoHelper.ShowLayout (view.Cr, count_layout);
                }

                count_layout.Dispose ();
            }

            fd.Dispose ();
        }
예제 #10
0
        public void draw(Gdk.Window win, Gdk.Color terr, Gdk.Color textcolor, Pango.Context pango_context)
        {
            Gdk.GC textcoloring = new Gdk.GC(win);
               		textcoloring.RgbFgColor = textcolor;
               	int carriedUnits = 0;
               	string extraLabel = "";
            GraphicsStorage store = GraphicsStorage.GetInstance();
            int cenTerrX = MapTerritory.centerX;
            int cenTerrY = MapTerritory.centerY;

               	/* Show flag */
               	Gdk.Pixbuf flag = store.AppropriateFlag(owner.CountryID);
               	if (flag != null && owner.Active)
               		win.DrawPixbuf(textcoloring, flag, 0, 0, cenTerrX, cenTerrY, flag.Width, flag.Height, RgbDither.Normal, 1, 1);

            /* Draw the map */
               	MapTerritory.draw(win, terr, textcolor);

               	/* Show radiation if destroyed */
               	if (destroyed)
            win.DrawPixbuf(textcoloring, store.Radiation, 0, 0, cenTerrX, cenTerrY, store.Radiation.Width, store.Radiation.Height, RgbDither.Normal, 1, 1);

               	/* Determine personnel carrier status */
               	foreach(TacticalUnit joe in units)
               		carriedUnits += joe.UnitsAboardCount;
               	if (carriedUnits > 0)
               		extraLabel = "(" + carriedUnits + ")";

            /* Draw the first N units staggered, then use a label to show further #'s */
               	for (int offset=0; offset < units.Count && offset < 3; offset++)
               	{
               		((TacticalUnit)units[offset]).draw(win, offset*5);
               	}

               	/* Label */
               	if (units.Count > 1 || carriedUnits > 0)
               	{
               	        Pango.Layout label = new Pango.Layout (pango_context);
            label.Wrap = Pango.WrapMode.Word;
            label.FontDescription = FontDescription.FromString ("Tahoma 8");
            label.SetMarkup ( units.Count.ToString() + extraLabel );

            int szX, szY;
            label.GetPixelSize(out szX, out szY);

            /*Redraw*/
            //			win.InvalidateRect(new Gdk.Rectangle(MapTerritory.centerX, MapTerritory.centerY, szX, szY), true);

            win.DrawLayout (textcoloring, MapTerritory.centerX, MapTerritory.centerY, label);
               	}
        }
		public void Draw (TextEditor editor, Gdk.Drawable win, int lineNr, Gdk.Rectangle lineArea)
		{
			EnsureLayoutCreated (editor);
			int lineNumber = editor.Document.OffsetToLineNumber (lineSegment.Offset);
			int errorNumber = lineNr - lineNumber;
			int x = editor.TextViewMargin.XOffset;
			int y = lineArea.Y;
			int right = editor.Allocation.Width;
			int errorCounterWidth = 0;
			
			int ew = 0, eh = 0;
			if (errors.Count > 1 && errorCountLayout != null) {
				errorCountLayout.GetPixelSize (out ew, out eh);
				errorCounterWidth = ew + 10;
			}
			
			int x2 = System.Math.Max (right - LayoutWidth - border - (ShowIconsInBubble ? errorPixbuf.Width : 0) - errorCounterWidth, fitsInSameLine ? editor.TextViewMargin.XOffset + editor.LineHeight / 2 : editor.TextViewMargin.XOffset);
//			bool isEolSelected = editor.IsSomethingSelected && editor.SelectionMode != SelectionMode.Block ? editor.SelectionRange.Contains (lineSegment.Offset  + lineSegment.EditableLength) : false;
			int active = editor.Document.GetTextAt (lineSegment) == initialText ? 0 : 1;
			bool isCaretInLine = lineSegment.Offset <= editor.Caret.Offset && editor.Caret.Offset <= lineSegment.EndOffset;
			int highlighted = active == 0 && isCaretInLine ? 1 : 0;
			int selected = 0;
			LayoutDescriptor layout = layouts[errorNumber];
			x2 = right - LayoutWidth - border - (ShowIconsInBubble ? errorPixbuf.Width : 0);
			
			x2 -= errorCounterWidth;
			x2 = System.Math.Max (x2, fitsInSameLine ? editor.TextViewMargin.XOffset + editor.LineHeight / 2 : editor.TextViewMargin.XOffset);
			
			using (var g = Gdk.CairoHelper.Create (win)) {
				g.LineWidth = Math.Max (1.0, editor.Options.Zoom);
				g.MoveTo (new Cairo.PointD (x2 + 0.5, y));
				g.LineTo (new Cairo.PointD (x2 + 0.5, y + editor.LineHeight));
				g.LineTo (new Cairo.PointD (right, y + editor.LineHeight));
				g.LineTo (new Cairo.PointD (right, y));
				g.ClosePath ();
				g.Color = colorMatrix[active, BOTTOM, LIGHT, highlighted, selected];
				g.Fill ();
				
				g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, selected];
				g.MoveTo (new Cairo.PointD (x2 + 0.5, y));
				g.LineTo (new Cairo.PointD (x2 + 0.5, y + editor.LineHeight));
				if (errorNumber == errors.Count - 1)
					g.LineTo (new Cairo.PointD (lineArea.Right, y + editor.LineHeight));
				g.Stroke ();
				
				if (editor.Options.ShowRuler) {
					int divider = Math.Max (editor.TextViewMargin.XOffset, x + editor.TextViewMargin.RulerX);
					if (divider >= x2) {
						g.MoveTo (new Cairo.PointD (divider + 0.5, y));
						g.LineTo (new Cairo.PointD (divider + 0.5, y + editor.LineHeight));
						g.Color = colorMatrix[active, BOTTOM, DARK, highlighted, selected];
						g.Stroke ();
					}
				}
			}
			win.DrawLayout (selected == 0 ? gc : gcSelected, x2 + (ShowIconsInBubble ? errorPixbuf.Width : 0) + border, y + (editor.LineHeight - layout.Height) / 2 + layout.Height % 2, layout.Layout);
			if (ShowIconsInBubble)
				win.DrawPixbuf (editor.Style.BaseGC (Gtk.StateType.Normal), errors[errorNumber].IsError ? errorPixbuf : warningPixbuf, 0, 0, x2, y + (editor.LineHeight - errorPixbuf.Height) / 2, errorPixbuf.Width, errorPixbuf.Height, Gdk.RgbDither.None, 0, 0);
		}
		internal protected override void Draw (Gdk.Drawable drawable, Gdk.Rectangle area, long line, int x, int y)
		{
			drawable.DrawRectangle (bgGC, true, x, y, Width, Editor.LineHeight);
			LayoutWrapper layout = GetLayout (line);
			
			if (!Data.IsSomethingSelected && Caret.InTextEditor && line == Data.Caret.Line) {
				drawable.DrawRectangle (GetGC (Style.HighlightOffset), true, CalculateCaretXPos (false), y, byteWidth, Editor.LineHeight);
			}
			
			drawable.DrawLayout (fgGC, x, y, layout.Layout);
			if (layout.IsUncached)
				layout.Dispose ();
		}
예제 #13
0
        private void DrawCoords(Gdk.Window window)
        {
            Gdk.GC gc;

            gc = Style.ForegroundGC (StateType.Normal);
            window.DrawRectangle (gc, false,
                          start_x - space - size / 5,
                          start_y - space - size / 5,
                          (size + space) * 8 +
                          2 * size / 5,
                          (size + space) * 8 +
                          2 * size / 5);

            string letters = "abcdefgh";

            for (int i = 0; i < 8; i++)
              {
                  layout.SetText ((letters[i]).ToString ());
                  window.DrawLayout (Style.
                             TextGC (StateType.
                                 Normal),
                             start_x + size / 2 +
                             (size + space) * i,
                             start_y - size / 5 -
                             2 * space, layout);
                  window.DrawLayout (Style.
                             TextGC (StateType.
                                 Normal),
                             start_x + size / 2 +
                             (size + space) * i,
                             start_y + (size +
                                space) * 8 -
                             2 * space, layout);
              }

            string numbers = "12345678";

            if (!side)
                numbers = "87654321";

            for (int i = 0; i < 8; i++)
              {
                  layout.SetText ((numbers[i]).ToString ());
                  window.DrawLayout (Style.
                             TextGC (StateType.
                                 Normal),
                             start_x - size / 5,
                             start_y + size / 2 +
                             (size + space) * i,
                             layout);
                  window.DrawLayout (Style.
                             TextGC (StateType.
                                 Normal),
                             start_x + (size +
                                space) * 8,
                             start_y + size / 2 +
                             (size + space) * i,
                             layout);
              }
        }
        protected override void Render (Gdk.Drawable drawable, Widget widget, Gdk.Rectangle background_area,
            Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
        {
            if (source == null) {
                return;
            }

            view = widget as SourceView;
            bool selected = view != null && view.Selection.IterIsSelected (iter);
            StateType state = RendererStateToWidgetState (widget, flags);

            RenderSelection (drawable, background_area, selected, state);

            int title_layout_width = 0, title_layout_height = 0;
            int count_layout_width = 0, count_layout_height = 0;
            int max_title_layout_width;

            bool hide_counts = source.EnabledCount <= 0;

            Pixbuf icon = SourceIconResolver.ResolveIcon (source, RowHeight);

            bool dispose_icon = false;
            if (state == StateType.Insensitive) {
                // Code ported from gtk_cell_renderer_pixbuf_render()
                var icon_source = new IconSource () {
                    Pixbuf = icon,
                    Size = IconSize.SmallToolbar,
                    SizeWildcarded = false
                };

                icon = widget.Style.RenderIcon (icon_source, widget.Direction, state,
                    (IconSize)(-1), widget, "SourceRowRenderer");

                dispose_icon = true;
                icon_source.Dispose ();
            }

            FontDescription fd = widget.PangoContext.FontDescription.Copy ();
            fd.Weight = (ISource)ServiceManager.PlaybackController.NextSource == (ISource)source
                ? Pango.Weight.Bold
                : Pango.Weight.Normal;

            if (view != null && source == view.NewPlaylistSource) {
                fd.Style = Pango.Style.Italic;
                hide_counts = true;
            }

            Pango.Layout title_layout = new Pango.Layout (widget.PangoContext);
            Pango.Layout count_layout = null;

            if (!hide_counts) {
                count_layout = new Pango.Layout (widget.PangoContext);
                count_layout.FontDescription = fd;
                count_layout.SetMarkup (String.Format ("<span size=\"small\">{0}</span>", source.EnabledCount));
                count_layout.GetPixelSize (out count_layout_width, out count_layout_height);
            }

            max_title_layout_width = cell_area.Width - (icon == null ? 0 : icon.Width) - count_layout_width - 10;

            if (!hide_counts && max_title_layout_width < 0) {
                hide_counts = true;
            }

            title_layout.FontDescription = fd;
            title_layout.Width = (int)(max_title_layout_width * Pango.Scale.PangoScale);
            title_layout.Ellipsize = EllipsizeMode.End;
            title_layout.SetText (source.Name);
            title_layout.GetPixelSize (out title_layout_width, out title_layout_height);

            Gdk.GC main_gc = widget.Style.TextGC (state);

            drawable.DrawLayout (main_gc,
                cell_area.X + (icon == null ? 0 : icon.Width) + 6,
                Middle (cell_area, title_layout_height),
                title_layout);

            title_layout.Dispose ();

            if (icon != null) {
                drawable.DrawPixbuf (main_gc, icon, 0, 0,
                    cell_area.X, Middle (cell_area, icon.Height),
                    icon.Width, icon.Height, RgbDither.None, 0, 0);

                if (dispose_icon) {
                    icon.Dispose ();
                }
            }

            if (hide_counts) {
                fd.Dispose ();
                return;
            }

            if (view != null && view.Cr != null) {
                view.Cr.Color = state == StateType.Normal || (view != null && state == StateType.Prelight)
                    ? view.Theme.TextMidColor
                    : view.Theme.Colors.GetWidgetColor (GtkColorClass.Text, state);

                view.Cr.MoveTo (
                    cell_area.X + cell_area.Width - count_layout_width - 2,
                    cell_area.Y + 0.5 + (double)(cell_area.Height - count_layout_height) / 2.0);
                PangoCairoHelper.ShowLayout (view.Cr, count_layout);
            }

            count_layout.Dispose ();
            fd.Dispose ();
        }
예제 #15
0
        public void draw(Gdk.Window win, Gdk.Color terr, Gdk.Color textcolor)
        {
            if (label == null)
            {
               	/* Make label */
            label = new Pango.Layout (Game.GetInstance().GUI.Map.PangoContext);
            label.Wrap = Pango.WrapMode.Word;
            label.Alignment = Pango.Alignment.Center;
            label.FontDescription = FontDescription.FromString ("Tahoma 9");
            label.SetMarkup (Name);
            }

               	Gdk.GC field = new Gdk.GC(win);
               	Gdk.GC text = new Gdk.GC(win);
               	field.RgbFgColor = terr;
               	// Add transparency, somehow...
               	text.RgbFgColor = textcolor;

            //win.DrawPolygon(field, false, borders);
            win.DrawLayout (text, mathCenterX, mathCenterY, label);
        }
		internal protected override void Draw (Gdk.Drawable drawable, Gdk.Rectangle area, long line, int x, int y)
		{
			
			drawable.DrawRectangle (bgGC, true, x, y, Width, Editor.LineHeight);
			LayoutWrapper layout = GetLayout (line);
			if (!Data.IsSomethingSelected && !Caret.InTextEditor && line == Data.Caret.Line) {
				int column = (int)(Caret.Offset % BytesInRow);
				int xOffset = charWidth * column;
				drawable.DrawRectangle (GetGC (Style.HighlightOffset), true, x + xOffset, y, charWidth, Editor.LineHeight);
			}
			drawable.DrawLayout (fgGC, x, y, layout.Layout);
			if (layout.IsUncached)
				layout.Dispose ();
		}
예제 #17
0
        protected override void Render(Gdk.Drawable drawable, Widget widget,
		                                Gdk.Rectangle background_area, Gdk.Rectangle cell_area,
		                                Gdk.Rectangle expose_area, CellRendererState flags)
        {
            Pango.Layout layout = GetLayout (widget);

            // FIXME: If this code is ever built into its own library,
            // the call to Tomboy will definitely have to change
            layout.SetText (Utilities.GetPrettyPrintDate (date, show_time));

            int x, y, w, h;
            CalculateSize (layout, out x, out y, out w, out h);

            StateType state = RendererStateToWidgetState(flags);

            Gdk.GC gc;
            if (state.Equals(StateType.Selected)) {
                // Use the proper Gtk.StateType so text appears properly when selected
                gc = new Gdk.GC(drawable);
                gc.Copy(widget.Style.TextGC(state));
                gc.RgbFgColor = widget.Style.Foreground(state);
            } else
                gc = widget.Style.TextGC(Gtk.StateType.Normal);

            drawable.DrawLayout (
                    gc,
                    cell_area.X + (int)Xalign + (int)Xpad,
                    cell_area.Y + ((cell_area.Height - h) / 2),
                    layout);
        }
예제 #18
0
		void DrawLinePart (Gdk.Drawable win, LineSegment line, int offset, int length, ref int pangoPosition, ref bool isSelectionDrawn, int y, int maxX)
		{
			SyntaxMode mode = Document.SyntaxMode != null && textEditor.Options.EnableSyntaxHighlighting ? Document.SyntaxMode : SyntaxMode.Default;
			int selectionStart;
			int selectionEnd;
			if (BackgroundRenderer != null || this.HideSelection) {
				selectionStart = selectionEnd = -1;
			} else {
				GetSelectionOffsets (line, out selectionStart, out selectionEnd);
			}
			
			// ---- new renderer
			LayoutWrapper layout = CreateLinePartLayout (mode, line, offset, length, selectionStart, selectionEnd);
			int width = (int)(layout.PangoWidth / Pango.Scale.PangoScale);
			
			int xPos = (int)(pangoPosition / Pango.Scale.PangoScale);
			bool drawBg = true;
			bool drawText = true;
			foreach (TextMarker marker in line.Markers) {
				IBackgroundMarker bgMarker = marker as IBackgroundMarker;
				if (bgMarker == null || !marker.IsVisible)
					continue;
				isSelectionDrawn |= (marker.Flags & TextMarkerFlags.DrawsSelection) == TextMarkerFlags.DrawsSelection;
				drawText &= bgMarker.DrawBackground (textEditor, win, layout, selectionStart, selectionEnd, offset, offset + length, y, xPos, xPos + width, ref drawBg);
			}
			
			if (DecorateLineBg != null)
				DecorateLineBg (win, layout, offset, length, xPos, y, selectionStart, selectionEnd);
		
			if (!isSelectionDrawn && (layout.StartSet || selectionStart == offset + length)) {
				int startX;
				int endX;
				
				if (selectionStart != offset + length) {
					var start = layout.Layout.IndexToPos ((int)layout.SelectionStartIndex);
					startX = (int)(start.X / Pango.Scale.PangoScale);
					var end = layout.Layout.IndexToPos ((int)layout.SelectionEndIndex);
					endX = (int)(end.X / Pango.Scale.PangoScale);
				} else {
					startX = width;
					endX = startX;
				}
				
				if (textEditor.MainSelection.SelectionMode == SelectionMode.Block && startX == endX) {
					endX = startX + 2;
				}
				DrawRectangleWithRuler (win, xPos + (int)textEditor.HAdjustment.Value - TextStartPosition, new Rectangle (xPos + startX, y, endX - startX, textEditor.LineHeight), this.SelectionColor.BackgroundColor, true);
			}
			
				
			// highlight search results
			ISegment firstSearch;
			int o = offset;
			uint curIndex = 0, byteIndex = 0;
			
			while ((firstSearch = GetFirstSearchResult (o, offset + length)) != null) {
				int x = pangoPosition;
				HandleSelection (line, selectionStart, selectionEnd, firstSearch.Offset, firstSearch.EndOffset, delegate(int start, int end) {
					uint startIndex = (uint)(start - offset);
					uint endIndex = (uint)(end - offset);
					if (startIndex < endIndex && endIndex <= layout.LineChars.Length) {
						uint startTranslated = TranslateToUTF8Index (layout.LineChars, startIndex, ref curIndex, ref byteIndex);
						uint endTranslated = TranslateToUTF8Index (layout.LineChars, endIndex, ref curIndex, ref byteIndex);
						using (Cairo.Context cr = Gdk.CairoHelper.Create (win)) {
							cr.Rectangle (XOffset, 0, textEditor.Allocation.Width - XOffset, textEditor.Allocation.Height);
							cr.Clip ();
							
							int l, x1, x2;
							layout.Layout.IndexToLineX ((int)startTranslated, false, out l, out x1);
							layout.Layout.IndexToLineX ((int)endTranslated, false, out l, out x2);
							x1 += x; 
							x2 += x;
							x1 /= (int)Pango.Scale.PangoScale;
							x2 /= (int)Pango.Scale.PangoScale;
							
							cr.Color = Mono.TextEditor.Highlighting.Style.ToCairoColor (MainSearchResult == null || MainSearchResult.Offset != firstSearch.Offset ? ColorStyle.SearchTextBg : ColorStyle.SearchTextMainBg, AlphaBlendSearchResults ? 0.6 : 1.0);
							FoldingScreenbackgroundRenderer.DrawRoundRectangle (cr, true, true, x1, y, (int)(System.Math.Min (10, width) * textEditor.Options.Zoom), x2 - x1, textEditor.LineHeight);
							cr.Fill ();
						}
						
					}
				}, null);
			
				o = System.Math.Max (firstSearch.EndOffset, o + 1);
			}
			
			
			win.DrawLayout (GetGC (ColorStyle.Default.Color), xPos, y, layout.Layout);
			
			if (DecorateLineFg != null)
				DecorateLineFg (win, layout, offset, length, xPos, y, selectionStart, selectionEnd);

			if (Document.GetLine (Caret.Line) == line) {
				int caretOffset = Caret.Offset;
				if (offset <= caretOffset && caretOffset <= offset + length) {
					Pango.Rectangle strong_pos, weak_pos;
					int index = caretOffset- offset;
					if (offset <= textEditor.preeditOffset && textEditor.preeditOffset < offset + length) {
						index += textEditor.preeditString.Length;
					}
					
					if (Caret.Column > line.EditableLength) {
						string virtualSpace = this.textEditor.GetTextEditorData ().GetVirtualSpaces (Caret.Line, Caret.Column);
						LayoutWrapper wrapper = new LayoutWrapper (PangoUtil.CreateLayout (textEditor));
						wrapper.LineChars = virtualSpace.ToCharArray ();
						wrapper.Layout.SetText (virtualSpace);
						wrapper.Layout.Tabs = tabArray;
						int vy, vx;
						wrapper.Layout.GetSize (out vx, out vy);
						SetVisibleCaretPosition (win, ' ', (int)((pangoPosition + vx + layout.PangoWidth) / Pango.Scale.PangoScale), y);
						xPos = (int)((pangoPosition + layout.PangoWidth) / Pango.Scale.PangoScale);
						
						if (!isSelectionDrawn && (selectionEnd == line.Offset + line.EditableLength)) {
							int startX;
							int endX;
							startX = xPos;
							endX = (int)((pangoPosition + vx + layout.PangoWidth) / Pango.Scale.PangoScale);
							DrawRectangleWithRuler (win, xPos + (int)textEditor.HAdjustment.Value - TextStartPosition, new Rectangle (startX, y, endX - startX, textEditor.LineHeight), this.SelectionColor.BackgroundColor, true);
						}
						
						if (DecorateLineBg != null)
							DecorateLineBg (win, wrapper, offset, length, xPos, y, selectionStart, selectionEnd + virtualSpace.Length);
						if (DecorateLineFg != null)
							DecorateLineFg (win, wrapper, offset, length, xPos, y, selectionStart, selectionEnd + virtualSpace.Length);
						wrapper.Dispose ();
						pangoPosition += vx;
					} else if (index >= 0 && index < length) {
						curIndex = byteIndex = 0;
						layout.Layout.GetCursorPos ((int)TranslateToUTF8Index (layout.LineChars, (uint)index, ref curIndex, ref byteIndex), out strong_pos, out weak_pos);
						char caretChar = Document.GetCharAt (caretOffset);
						if (textEditor.Options.ShowSpaces && caretChar == ' ')
							caretChar = spaceMarkerChar;
						if (textEditor.Options.ShowTabs && caretChar == '\t')
							caretChar = tabMarkerChar;
						SetVisibleCaretPosition (win, caretChar, xPos + (int)(strong_pos.X / Pango.Scale.PangoScale), y);
					} else if (index == length) {
						SetVisibleCaretPosition (win, textEditor.Options.ShowEolMarkers ? eolMarkerChar : ' ', (int)((pangoPosition + layout.PangoWidth) / Pango.Scale.PangoScale), y);
					}
				}
			}

			foreach (TextMarker marker in line.Markers) {
				marker.Draw (textEditor, win, layout.Layout, false, /*selected*/offset, offset + length, y, xPos, xPos + width);
			}
			
			pangoPosition += layout.PangoWidth;
			if (layout.IsUncached)
				layout.Dispose ();
		}
		public bool DrawBackground (TextEditor editor, Gdk.Drawable win, TextViewMargin.LayoutWrapper layout2, int selectionStart, int selectionEnd, int startOffset, int endOffset, int y, int startXPos, int endXPos, ref bool drawBg)
		{
			if (!IsExpanded || DebuggingService.IsDebugging)
				return true;
			EnsureLayoutCreated (editor);
			int x = editor.TextViewMargin.XOffset;
			int right = editor.Allocation.Width;
			int errorCounterWidth = 0;
			bool isCaretInLine = startOffset <= editor.Caret.Offset && editor.Caret.Offset <= endOffset;
			int ew = 0, eh = 0;
			if (errors.Count > 1 && errorCountLayout != null) {
				errorCountLayout.GetPixelSize (out ew, out eh);
				errorCounterWidth = ew + 10;
			}
			
			int x2 = System.Math.Max (right - LayoutWidth - border - (ShowIconsInBubble ? errorPixbuf.Width : 0) - errorCounterWidth, fitsInSameLine ? editor.TextViewMargin.XOffset + editor.LineHeight / 2 : editor.TextViewMargin.XOffset);
			bool isEolSelected = editor.IsSomethingSelected && editor.SelectionMode != SelectionMode.Block ? editor.SelectionRange.Contains (lineSegment.Offset + lineSegment.EditableLength) : false;
			
			int active = editor.Document.GetTextAt (lineSegment) == initialText ? 0 : 1;
			int highlighted = active == 0 && isCaretInLine ? 1 : 0;
			int selected = 0;
			
			int topSize = editor.LineHeight / 2;
			int bottomSize = editor.LineHeight / 2 + editor.LineHeight % 2;
			
			using (var g = Gdk.CairoHelper.Create (win)) {
				g.LineWidth = Math.Max (1.0, editor.Options.Zoom);
				if (!fitsInSameLine) {
					if (isEolSelected) {
						x -= (int)editor.HAdjustment.Value;
						editor.TextViewMargin.DrawRectangleWithRuler (win, x, new Gdk.Rectangle (x, y + editor.LineHeight, editor.TextViewMargin.TextStartPosition, editor.LineHeight), editor.ColorStyle.Default.BackgroundColor, true);
						editor.TextViewMargin.DrawRectangleWithRuler (win, x + editor.TextViewMargin.TextStartPosition, new Gdk.Rectangle (x + editor.TextViewMargin.TextStartPosition, y + editor.LineHeight, editor.Allocation.Width + (int)editor.HAdjustment.Value, editor.LineHeight), editor.ColorStyle.Selection.BackgroundColor, true);
						x += (int)editor.HAdjustment.Value;
					} else {
						editor.TextViewMargin.DrawRectangleWithRuler (win, x, new Gdk.Rectangle (x, y + editor.LineHeight, x2, editor.LineHeight), editor.ColorStyle.Default.BackgroundColor, true);
					}
				}
				DrawRectangle (g, x, y, right, topSize);
				g.Color = colorMatrix[active, TOP, LIGHT, highlighted, selected];
				g.Fill ();
				DrawRectangle (g, x, y + topSize, right, bottomSize);
				g.Color = colorMatrix[active, BOTTOM, LIGHT, highlighted, selected];
				g.Fill ();
				
				g.MoveTo (new Cairo.PointD (x, y + 0.5));
				g.LineTo (new Cairo.PointD (x + right, y + 0.5));
				g.Color = colorMatrix[active, TOP, LINE, highlighted, selected];
				g.Stroke ();
				
				g.MoveTo (new Cairo.PointD (x, y + editor.LineHeight - 0.5));
				g.LineTo (new Cairo.PointD ((fitsInSameLine ? x + right : x2 + 1), y + editor.LineHeight - 0.5));
				g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, selected];
				g.Stroke ();
				if (editor.Options.ShowRuler) {
					int divider = Math.Max (editor.TextViewMargin.XOffset, x + editor.TextViewMargin.RulerX);
					g.MoveTo (new Cairo.PointD (divider + 0.5, y));
					g.LineTo (new Cairo.PointD (divider + 0.5, y + editor.LineHeight));
					g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, selected];
					g.Stroke ();
				}
				
				// draw background
				if (layout2.StartSet || selectionStart == endOffset) {
					int startX;
					int endX;
					
					if (selectionStart != endOffset) {
						var start = layout2.Layout.IndexToPos ((int)layout2.SelectionStartIndex);
						startX = (int)(start.X / Pango.Scale.PangoScale);
						var end = layout2.Layout.IndexToPos ((int)layout2.SelectionEndIndex);
						endX = (int)(end.X / Pango.Scale.PangoScale);
					} else {
						startX = x2;
						endX = startX;
					}
					
					if (editor.MainSelection.SelectionMode == SelectionMode.Block && startX == endX)
						endX = startX + 2;
					startX += startXPos;
					endX += startXPos;
					startX = Math.Max (editor.TextViewMargin.XOffset, startX);
					// clip region to textviewmargin start
					if (isEolSelected)
						endX = editor.Allocation.Width + (int)editor.HAdjustment.Value;
					if (startX < endX) {
						DrawRectangle (g, startX, y, endX - startX, topSize);
						g.Color = colorMatrix[active, TOP, LIGHT, highlighted, 1];
						g.Fill ();
						DrawRectangle (g, startX, y + topSize, endX - startX, bottomSize);
						g.Color = colorMatrix[active, BOTTOM, LIGHT, highlighted, 1];
						g.Fill ();
						
						g.MoveTo (new Cairo.PointD (startX, y + 0.5));
						g.LineTo (new Cairo.PointD (endX, y + 0.5));
						g.Color = colorMatrix[active, TOP, LINE, highlighted, 1];
						g.Stroke ();
						
						if (startX < x2) {
							g.MoveTo (new Cairo.PointD (startX, y + editor.LineHeight - 0.5));
							g.LineTo (new Cairo.PointD (System.Math.Min (endX, x2 + 1), y + editor.LineHeight - 0.5));
							g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, 1];
							g.Stroke ();
							if (x2 + 1 < endX) {
								g.MoveTo (new Cairo.PointD (x2 + 1, y + editor.LineHeight - 0.5));
								g.LineTo (new Cairo.PointD (endX, y + editor.LineHeight - 0.5));
								g.Color = colorMatrix[active, BOTTOM, LIGHT, highlighted, 1];
								g.Stroke ();
							}
						}
						
						if (editor.Options.ShowRuler) {
							int divider = Math.Max (editor.TextViewMargin.XOffset, x + editor.TextViewMargin.RulerX);
							g.MoveTo (new Cairo.PointD (divider + 0.5, y));
							g.LineTo (new Cairo.PointD (divider + 0.5, y + editor.LineHeight));
							g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, 1];
							g.Stroke ();
						}
					}
				}
				
				if (!fitsInSameLine)
					y += editor.LineHeight;
				double y2 = y + 0.5;
				double y2Bottom = y2 + editor.LineHeight - 1;
				selected = isEolSelected && (CollapseExtendedErrors || errors.Count == 1) ? 1 : 0;
				
				// draw message text background
				if (CollapseExtendedErrors || errors.Count == 1) {
					if (!fitsInSameLine) {
						// draw box below line 
						g.MoveTo (new Cairo.PointD (x2 + 0.5, y2 - 1));
						g.LineTo (new Cairo.PointD (x2 + 0.5, y2Bottom));
						g.LineTo (new Cairo.PointD (right, y2Bottom));
						g.LineTo (new Cairo.PointD (right, y2 - 1));
						g.ClosePath ();
						g.Color = colorMatrix[active, BOTTOM, LIGHT, highlighted, selected];
						g.Fill ();
						
						g.MoveTo (new Cairo.PointD (x2 + 0.5, y2 - 1));
						g.LineTo (new Cairo.PointD (x2 + 0.5, y2Bottom));
						g.LineTo (new Cairo.PointD (right, y2Bottom));
						g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, selected];
						g.Stroke ();
					} else {
						// draw 'arrow marker' in the same line
						g.MoveTo (new Cairo.PointD (x2 + 0.5, y2));
						double mid = y2 + topSize;
						g.LineTo (new Cairo.PointD (x2 - editor.LineHeight / 2 + 0.5, mid));
						
						g.LineTo (new Cairo.PointD (right, mid));
						g.LineTo (new Cairo.PointD (right, y2));
						g.ClosePath ();
						g.Color = colorMatrix[active, TOP, DARK, highlighted, selected];
						g.Fill ();
						g.MoveTo (new Cairo.PointD (x2 + 0.5, y2Bottom));
						g.LineTo (new Cairo.PointD (x2 - editor.LineHeight / 2 + 0.5, mid));
						
						g.LineTo (new Cairo.PointD (right, mid));
						g.LineTo (new Cairo.PointD (right, y2Bottom));
						g.ClosePath ();
						
						g.Color = colorMatrix[active, BOTTOM, DARK, highlighted, selected];
						g.Fill ();
						
						// draw border
						g.MoveTo (new Cairo.PointD (x2 + 0.5, y2));
						g.LineTo (new Cairo.PointD (x2 - editor.LineHeight / 2 + 0.5, y2 + editor.LineHeight / 2));
						
						g.LineTo (new Cairo.PointD (x2 + 0.5, y2Bottom));
						g.LineTo (new Cairo.PointD (right, y2Bottom));
						g.LineTo (new Cairo.PointD (right, y2));
						g.ClosePath ();
						
						g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, selected];
						g.Stroke ();
					}
				} else {
					if (!fitsInSameLine) {
						// draw box below line
						g.MoveTo (new Cairo.PointD (x2 + 0.5, y2 - 1));
						g.LineTo (new Cairo.PointD (x2 + 0.5, y2Bottom));
						g.LineTo (new Cairo.PointD (right, y2Bottom));
						g.LineTo (new Cairo.PointD (right, y2 - 1));
						g.ClosePath ();
					} else {
						// draw filled arrow box
						g.MoveTo (new Cairo.PointD (x2 + 0.5, y2));
						g.LineTo (new Cairo.PointD (x2 - editor.LineHeight / 2 + 0.5, y2 + editor.LineHeight / 2));
						g.LineTo (new Cairo.PointD (x2 + 0.5, y2Bottom));
						g.LineTo (new Cairo.PointD (right, y2Bottom));
						g.LineTo (new Cairo.PointD (right, y2));
						g.ClosePath ();
					}
					g.Color = colorMatrix[active, BOTTOM, LIGHT, highlighted, selected];
					g.Fill ();
					
					// draw light bottom line
					g.MoveTo (new Cairo.PointD (right, y2Bottom));
					g.LineTo (new Cairo.PointD (x2 + 0.5, y2Bottom));
					g.Stroke ();
					
					// stroke left line
					if (fitsInSameLine) {
						g.MoveTo (new Cairo.PointD (x2 + 0.5, y2));
						g.LineTo (new Cairo.PointD (x2 - editor.LineHeight / 2 + 0.5, y2 + editor.LineHeight / 2));
						g.LineTo (new Cairo.PointD (x2 + 0.5, y2Bottom));
					} else {
						g.MoveTo (new Cairo.PointD (x2 + 0.5, y2 - 1));
						g.LineTo (new Cairo.PointD (x2 + 0.5, y2Bottom + 1));
					}
					
					g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, selected];
					g.Stroke ();
					
					// stroke top line
					if (fitsInSameLine) {
						g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, selected];
						g.MoveTo (new Cairo.PointD (right, y2));
						g.LineTo (new Cairo.PointD (x2 + 0.5, y2));
						g.Stroke ();
					}
				}
				
				if (editor.Options.ShowRuler) {
					int divider = Math.Max (editor.TextViewMargin.XOffset, x + editor.TextViewMargin.RulerX);
					if (divider >= x2) {
						g.MoveTo (new Cairo.PointD (divider + 0.5, y2));
						g.LineTo (new Cairo.PointD (divider + 0.5, y2Bottom));
						g.Color = colorMatrix[active, BOTTOM, DARK, highlighted, selected];
						g.Stroke ();
					}
				}
				
				if (errors.Count > 1 && errorCountLayout != null) {
					int rX = x2 + (ShowIconsInBubble ? errorPixbuf.Width : 0) + border + LayoutWidth;
					int rY = y + editor.LineHeight / 6;
					int rW = errorCounterWidth - 2;
					int rH = editor.LineHeight * 3 / 4;
					BookmarkMarker.DrawRoundRectangle (g, rX, rY, 8, rW, rH);
					
					g.Color = oldIsOver ? new Cairo.Color (0.3, 0.3, 0.3) : new Cairo.Color (0.5, 0.5, 0.5);
					g.Fill ();
					if (CollapseExtendedErrors) {
						win.DrawLayout (gcLight, x2 + (ShowIconsInBubble ? errorPixbuf.Width : 0) + border + LayoutWidth + 4, y + (editor.LineHeight - eh) / 2 + eh % 2, errorCountLayout);
					} else {
						g.MoveTo (rX + rW / 2 - rW / 4, rY + rH - rH / 4);
						g.LineTo (rX + rW / 2 + rW / 4, rY + rH - rH / 4);
						g.LineTo (rX + rW / 2, rY + rH / 4);
						g.ClosePath ();
						
						g.Color = new Cairo.Color (1, 1, 1);
						g.Fill ();
					}
				}
				
				for (int i = 0; i < layouts.Count; i++) {
					LayoutDescriptor layout = layouts[i];
					x2 = right - layout.Width - border - errorPixbuf.Width;
					if (i == 0)
						x2 -= errorCounterWidth;
					x2 = System.Math.Max (x2, fitsInSameLine ? editor.TextViewMargin.XOffset + editor.LineHeight / 2 : editor.TextViewMargin.XOffset);
					if (i > 0) {
						editor.TextViewMargin.DrawRectangleWithRuler (win, x, new Gdk.Rectangle (x, y, right, editor.LineHeight), isEolSelected ? editor.ColorStyle.Selection.BackgroundColor : editor.ColorStyle.Default.BackgroundColor, true);
						g.MoveTo (new Cairo.PointD (x2 + 0.5, y));
						g.LineTo (new Cairo.PointD (x2 + 0.5, y + editor.LineHeight));
						g.LineTo (new Cairo.PointD (right, y + editor.LineHeight));
						g.LineTo (new Cairo.PointD (right, y));
						g.ClosePath ();
						
						if (CollapseExtendedErrors) {
							Cairo.Gradient pat = new Cairo.LinearGradient (x2, y, x2, y + editor.LineHeight);
							pat.AddColorStop (0, colorMatrix[active, TOP, LIGHT, highlighted, selected]);
							pat.AddColorStop (1, colorMatrix[active, BOTTOM, LIGHT, highlighted, selected]);
							g.Pattern = pat;
						} else {
							g.Color = colorMatrix[active, TOP, LIGHT, highlighted, selected];
						}
						g.Fill ();
						if (editor.Options.ShowRuler) {
							int divider = Math.Max (editor.TextViewMargin.XOffset, x + editor.TextViewMargin.RulerX);
							if (divider >= x2) {
								g.MoveTo (new Cairo.PointD (divider + 0.5, y));
								g.LineTo (new Cairo.PointD (divider + 0.5, y + editor.LineHeight));
								g.Color = colorMatrix[active, BOTTOM, DARK, highlighted, selected];
								g.Stroke ();
							}
						}
					}
					int lw, lh;
					layout.Layout.GetPixelSize (out lw, out lh);
					win.DrawLayout (selected == 0 ? gc : gcSelected, x2 + errorPixbuf.Width + border, y + (editor.LineHeight - layout.Height) / 2 + layout.Height % 2, layout.Layout);
					if (ShowIconsInBubble)
						win.DrawPixbuf (editor.Style.BaseGC (Gtk.StateType.Normal), errors[i].IsError ? errorPixbuf : warningPixbuf, 0, 0, x2, y + (editor.LineHeight - errorPixbuf.Height) / 2, errorPixbuf.Width, errorPixbuf.Height, Gdk.RgbDither.None, 0, 0);
					y += editor.LineHeight;
					if (!UseVirtualLines)
						break;
				}
			}
			return true;
		}
예제 #20
0
		void DrawInvalidLineMarker (Gdk.Drawable win, int x, int y)
		{
			markerLayout.SetText (invalidLineMarkerChar.ToString ());
			win.DrawLayout (GetGC (ColorStyle.InvalidLineMarker), x, y, markerLayout);
		}
		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);
			}
		}
예제 #22
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;
        }
예제 #23
0
		void DrawTabMarker (Gdk.Drawable win, bool selected, int x, int y)
		{
			markerLayout.SetText (tabMarkerChar.ToString ());
			win.DrawLayout (GetGC (selected ? SelectionColor.Color : ColorStyle.WhitespaceMarker), x, y, markerLayout);
		}
예제 #24
0
        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);
                    }
                }
            }}
        }
예제 #25
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);
		}
예제 #26
0
 protected override void OnPaint(Gdk.Drawable win, Gdk.Point offset, Gdk.Rectangle clip)
 {
     Pango.Layout layout = view.Layout;
     layout.Alignment = Pango.Alignment.Left;
     layout.Width = -1;
     layout.SetText (caption);
     layout.Attributes = Attrs;
     win.DrawLayout (view.Style.TextGC (0), Location.X + offset.X - ink_offset.X, Location.Y + offset.Y - ink_offset.Y, layout);
     layout.Attributes = null;
 }
예제 #27
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);
                    }
                }
            }
        }
예제 #28
0
 protected override void OnPaint(Gdk.Drawable win, Gdk.Point offset, Gdk.Rectangle clip)
 {
     Pango.Layout layout = view.Layout;
     layout.FontDescription = FontDescription;
     layout.Alignment = Pango.Alignment.Left;
     layout.Width = -1;
     layout.SetText (heading);
     win.DrawLayout (view.Style.TextGC (0), Location.X + offset.X - ink_offset.X, Location.Y + offset.Y - ink_offset.Y, layout);
     layout.FontDescription = null;
 }
예제 #29
0
		void DrawLineBox (Gdk.GC gc, Cairo.Context ctx, int right, int top, int line, Gtk.Widget widget, Gdk.Drawable window)
		{
			layout.SetText ("");
			layout.SetMarkup ("<small>" + line.ToString () + "</small>");
			int tw,th;
			layout.GetPixelSize (out tw, out th);
			th--;
			
			int dy = (lineHeight - th) / 2;
			
			ctx.Rectangle (right - tw - 2 + 0.5, top + dy - 1 + 0.5, tw + 2, th + 2);
			ctx.LineWidth = 1;
			ctx.Color = widget.Style.Base (Gtk.StateType.Normal).ToCairoColor ();
			ctx.FillPreserve ();
			ctx.Color = new Cairo.Color (0.7, 0.7, 0.7);
			ctx.Stroke ();

			window.DrawLayout (gc, right - tw - 1, top + dy, layout);
		}
        protected override void Render(Gdk.Drawable drawable, 
            Widget widget, Gdk.Rectangle background_area, 
            Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, 
            CellRendererState flags)
        {
            StateType state = RendererStateToWidgetState(flags);
            int text_indent = 6;
            int text_layout_width, text_layout_height;
            Gdk.Pixbuf render_icon = radio_icon;
            Track track = null;
            RadioTrackInfo radio_track = null;
            string text = Text;

            if(widget is TreeView) {
                TreePath path;
                if((widget as TreeView).GetPathAtPos(cell_area.X, cell_area.Y, out path)) {
                    track = model.GetTrack(path);
                    radio_track = model.GetRadioTrackInfo(path);
                }
            }

            FontDescription font_description = widget.PangoContext.FontDescription.Copy();

            if(playing_icon != null && track != null && PlayerEngineCore.CurrentTrack is RadioTrackInfo
                && (PlayerEngineCore.CurrentTrack as RadioTrackInfo).XspfTrack.Title == track.Title
                && (PlayerEngineCore.CurrentTrack as RadioTrackInfo).XspfTrack.Annotation == track.Annotation) {
                render_icon = playing_icon;
                font_description.Style = Pango.Style.Normal;
                font_description.Weight = Pango.Weight.Bold;
            } else if(radio_track != null && radio_track.ParsingPlaylist) {
                render_icon = loading_icon;
                font_description.Style = Pango.Style.Italic;
                font_description.Weight = Pango.Weight.Normal;
                text = String.Format("{0}: {1}", Catalog.GetString("Loading"), Text);
            } else if(radio_track != null && radio_track.PlaybackError != TrackPlaybackError.None) {
                render_icon = error_icon;
                font_description.Style = Pango.Style.Italic;
                font_description.Weight = Pango.Weight.Normal;
                string prefix = null;

                switch(radio_track.PlaybackError) {
                    case TrackPlaybackError.ResourceNotFound:
                        prefix = Catalog.GetString("Missing");
                        break;
                    case TrackPlaybackError.CodecNotFound:
                        prefix = Catalog.GetString("No Codec");
                        break;
                    case TrackPlaybackError.Unknown:
                        prefix = Catalog.GetString("Unknown Error");
                        break;
                    default:
                        break;
                }

                if(prefix != null) {
                    text = String.Format("({0}) {1}", prefix, Text);
                }

                if(!(CellRendererState.Selected & flags).Equals(CellRendererState.Selected)) {
                    state = StateType.Insensitive;
                }

                if(track != null) {
                    track.Title = String.Empty;
                }
            } else {
                font_description.Style = Pango.Style.Normal;
                font_description.Weight = Pango.Weight.Normal;
            }

            Gdk.GC main_gc = widget.Style.TextGC(state);

            if(track != null) {
                drawable.DrawPixbuf(main_gc, render_icon, 0, 0,
                cell_area.X - render_icon.Width,
                cell_area.Y + ((cell_area.Height - render_icon.Height) / 2),
                render_icon.Width, render_icon.Height,
                RgbDither.None, 0, 0);
            } else {
                text_indent = 0;
            }

            Pango.Layout text_layout = new Pango.Layout(widget.PangoContext);
            text_layout.FontDescription = font_description;
            text_layout.SetMarkup(GLib.Markup.EscapeText(text));
            text_layout.GetPixelSize(out text_layout_width, out text_layout_height);

            drawable.DrawLayout(main_gc,
                cell_area.X + text_indent,
                cell_area.Y + ((cell_area.Height - text_layout_height) / 2),
                text_layout);
        }