protected override void OnDestroyed() { base.OnDestroyed(); if (caretGc != null) { caretGc.Dispose(); caretGc = null; } }
protected override void OnDestroyed() { if (redgc != null) { redgc.Dispose(); redgc = null; } base.OnDestroyed(); }
public override void Dispose() { base.Dispose(); if (grw != null) { grw.Dispose(); } if (taskGc != null) { taskGc.Dispose(); } }
protected void OnDrawVolumeExposeEvent(object o, Gtk.ExposeEventArgs args) { Gdk.Color back = Style.Background(StateType.Normal); Gdk.Color fore = Style.Foreground(StateType.Normal); Drawable draw = args.Event.Window; int width; int height; draw.GetSize(out width, out height); Gdk.GC gc = new Gdk.GC(draw); gc.Foreground = back; gc.Background = back; draw.DrawRectangle(gc, true, 0, 0, width, height); //Color lightSlateGray = new Color(119,136,153); //gc.Colormap.AllocColor(ref lightSlateGray, false, true); int outside = height * 8 / 10; int middle = height * 6 / 10; int inside = height * 4 / 10; int startOut = 24; int startMiddle = 30; int startInside = 36; int endOut = width - 24; int endMiddle = width - 30; int endInside = width - 36; gc.Foreground = fore; gc.Foreground = fore; gc.SetLineAttributes(outside, LineStyle.Solid, CapStyle.Round, JoinStyle.Round); draw.DrawLine(gc, startOut, height / 2, endOut, height / 2); gc.Foreground = back; gc.Background = back; gc.SetLineAttributes(middle, LineStyle.Solid, CapStyle.Round, JoinStyle.Round); draw.DrawLine(gc, startMiddle, height / 2, endMiddle, height / 2); int endX = (endInside - startInside) * Percentage / 100 + startInside; gc.Foreground = fore; gc.Foreground = fore; gc.SetLineAttributes(inside, LineStyle.Solid, CapStyle.Round, JoinStyle.Round); draw.DrawLine(gc, startInside, height / 2, endX, height / 2); gc.Dispose(); }
public void Draw(Drawable draw, Gdk.Color back) { Gdk.GC gc = new Gdk.GC(draw); try { int width; int height; draw.GetSize(out width, out height); int xPoint = (width * Volume) / 100; int yTop = height * Volume / 100; List<Point> points = new List<Point>(); points.Add(new Point(0,0)); points.Add(new Point(xPoint, yTop)); points.Add(new Point(xPoint, height)); points.Add(new Point(0,height)); points.Add(new Point(0,0)); gc.Foreground = back; gc.Background = back; draw.DrawPolygon(gc, true, points.ToArray()); draw.DrawRectangle(gc, true, xPoint, 0, width, height); points.Clear(); points.Add(new Point(0,0)); points.Add(new Point(xPoint, yTop)); points.Add(new Point(xPoint, 0)); points.Add(new Point(0,0)); gc.Foreground = new Gdk.Color(0,128,0); gc.Background = new Gdk.Color(0,128,0); draw.DrawPolygon(gc, true, points.ToArray()); } catch (Exception ex) { Console.WriteLine(ex.Source); Console.WriteLine(ex.StackTrace); } gc.Dispose(); }
protected override bool OnExposeEvent(Gdk.EventExpose ev) { base.OnExposeEvent(ev); // Insert drawing code here. var window = ev.Window; var gc = new Gdk.GC(window); // window.DrawRectangle(gc, true, new Rectangle(0, 0, 100, 100)); int width = this.DrawingWidth; int height = this.DrawingHeight; CheckerPattern.Draw(window, gc, 10, width, height); DrawImage(window, gc); DrawIslands(window, gc); m_linkIslandsHelper.Step4_Draw(window, gc); gc.Dispose(); return(true); }
protected override void Render(Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags) { if (isDisposed) { return; } if (diffMode) { if (path.Equals(selctedPath)) { selectedLine = -1; selctedPath = null; } int w, maxy; window.GetSize(out w, out maxy); if (DrawLeft) { cell_area.Width += cell_area.X - leftSpace; cell_area.X = leftSpace; } var treeview = widget as FileTreeView; var p = treeview != null? treeview.CursorLocation : null; cell_area.Width -= RightPadding; window.DrawRectangle(widget.Style.BaseGC(Gtk.StateType.Normal), true, cell_area.X, cell_area.Y, cell_area.Width - 1, cell_area.Height); Gdk.GC normalGC = widget.Style.TextGC(StateType.Normal); Gdk.GC removedGC = new Gdk.GC(window); removedGC.Copy(normalGC); removedGC.RgbFgColor = Styles.LogView.DiffRemoveBackgroundColor.AddLight(-0.3).ToGdkColor(); Gdk.GC addedGC = new Gdk.GC(window); addedGC.Copy(normalGC); addedGC.RgbFgColor = Styles.LogView.DiffAddBackgroundColor.AddLight(-0.3).ToGdkColor(); Gdk.GC infoGC = new Gdk.GC(window); infoGC.Copy(normalGC); infoGC.RgbFgColor = widget.Style.Text(StateType.Normal).AddLight(0.2); Cairo.Context ctx = CairoHelper.Create(window); // Rendering is done in two steps: // 1) Get a list of blocks to render // 2) render the blocks var blocks = CalculateBlocks(maxy, cell_area.Y + 2); // Now render the blocks // The y position of the highlighted line int selectedLineRowTop = -1; BlockInfo lastCodeSegmentStart = null; BlockInfo lastCodeSegmentEnd = null; foreach (BlockInfo block in blocks) { if (block.Type == BlockType.Info) { // Finished drawing the content of a code segment. Now draw the segment border and label. if (lastCodeSegmentStart != null) { DrawCodeSegmentBorder(infoGC, ctx, cell_area.X, cell_area.Width, lastCodeSegmentStart, lastCodeSegmentEnd, lines, widget, window); } lastCodeSegmentStart = block; } lastCodeSegmentEnd = block; if (block.YEnd < 0) { continue; } // Draw the block background DrawBlockBg(ctx, cell_area.X + 1, cell_area.Width - 2, block); // Get all text for the current block StringBuilder sb = new StringBuilder(); for (int n = block.FirstLine; n <= block.LastLine; n++) { string s = ProcessLine(lines [n]); if (n > block.FirstLine) { sb.Append('\n'); } if ((block.Type == BlockType.Added || block.Type == BlockType.Removed) && s.Length > 0) { sb.Append(' '); sb.Append(s, 1, s.Length - 1); } else { sb.Append(s); } } // Draw a special background for the selected line if (block.Type != BlockType.Info && p.HasValue && p.Value.X >= cell_area.X && p.Value.X <= cell_area.Right && p.Value.Y >= block.YStart && p.Value.Y <= block.YEnd) { int row = (p.Value.Y - block.YStart) / lineHeight; double yrow = block.YStart + lineHeight * row; double xrow = cell_area.X + LeftPaddingBlock; int wrow = cell_area.Width - 1 - LeftPaddingBlock; if (block.Type == BlockType.Added) { ctx.SetSourceColor(Styles.LogView.DiffAddBackgroundColor.AddLight(0.1).ToCairoColor()); } else if (block.Type == BlockType.Removed) { ctx.SetSourceColor(Styles.LogView.DiffRemoveBackgroundColor.AddLight(0.1).ToCairoColor()); } else { ctx.SetSourceColor(Styles.LogView.DiffHighlightColor.ToCairoColor()); xrow -= LeftPaddingBlock; wrow += LeftPaddingBlock; } ctx.Rectangle(xrow, yrow, wrow, lineHeight); ctx.Fill(); selectedLine = block.SourceLineStart + row; selctedPath = path; selectedLineRowTop = (int)yrow; } // Draw the line text. Ignore header blocks, since they are drawn as labels in DrawCodeSegmentBorder if (block.Type != BlockType.Info) { layout.SetMarkup(""); layout.SetText(sb.ToString()); Gdk.GC gc; switch (block.Type) { case BlockType.Removed: gc = removedGC; break; case BlockType.Added: gc = addedGC; break; case BlockType.Info: gc = infoGC; break; default: gc = normalGC; break; } window.DrawLayout(gc, cell_area.X + 2 + LeftPaddingBlock, block.YStart, layout); } // Finally draw the change symbol at the left margin DrawChangeSymbol(ctx, widget, cell_area.X + 1, cell_area.Width - 2, block); } // Finish the drawing of the code segment if (lastCodeSegmentStart != null) { DrawCodeSegmentBorder(infoGC, ctx, cell_area.X, cell_area.Width, lastCodeSegmentStart, lastCodeSegmentEnd, lines, widget, window); } // Draw the source line number at the current selected line. It must be done at the end because it must // be drawn over the source code text and segment borders. if (selectedLineRowTop != -1) { DrawLineBox(normalGC, ctx, ((Gtk.TreeView)widget).VisibleRect.Right - 4, selectedLineRowTop, selectedLine, widget, window); } ((IDisposable)ctx).Dispose(); removedGC.Dispose(); addedGC.Dispose(); infoGC.Dispose(); } else { // Rendering a normal text row int y = cell_area.Y + (cell_area.Height - height) / 2; window.DrawLayout(widget.Style.TextGC(GetState(widget, flags)), cell_area.X, y, layout); } }
protected override bool OnExposeEvent(Gdk.EventExpose args) { Gdk.Window window = args.Window; var alloc = Allocation; int width = alloc.Width; int height = alloc.Height; int lineWidth = width - margin * 2; int xpos = margin + padding; int yPos = margin; if (PreviewCompletionString) { layout.SetText(string.IsNullOrEmpty(CompletionString) ? MonoDevelop.Core.GettextCatalog.GetString("Select template") : CompletionString); int wi, he; layout.GetPixelSize(out wi, out he); window.DrawRectangle(this.Style.BaseGC(StateType.Insensitive), true, margin, yPos, lineWidth, he + padding); window.DrawLayout(string.IsNullOrEmpty(CompletionString) ? this.Style.TextGC(StateType.Insensitive) : this.Style.TextGC(StateType.Normal), xpos, yPos, layout); yPos += rowHeight; } //when there are no matches, display a message to indicate that the completion list is still handling input if (filteredItems.Count == 0) { Gdk.GC gc = new Gdk.GC(window); gc.RgbFgColor = new Gdk.Color(0xff, 0xbc, 0xc1); window.DrawRectangle(gc, true, 0, yPos, width, height - yPos); gc.Dispose(); layout.SetText(win.DataProvider.ItemCount == 0? NoSuggestionsMsg : NoMatchesMsg); int lWidth, lHeight; layout.GetPixelSize(out lWidth, out lHeight); window.DrawLayout(this.Style.TextGC(StateType.Normal), (width - lWidth) / 2, yPos + (height - lHeight - yPos) / 2, layout); return(true); } var textGCInsensitive = this.Style.TextGC(StateType.Insensitive); var textGCNormal = this.Style.TextGC(StateType.Normal); var fgGCNormal = this.Style.ForegroundGC(StateType.Normal); Iterate(true, ref yPos, delegate(Category category, int ypos) { if (ypos >= height - margin) { return; } // window.DrawRectangle (this.Style.BackgroundGC (StateType.Insensitive), true, 0, yPos, width, rowHeight); Gdk.Pixbuf icon = ImageService.GetPixbuf(category.CompletionCategory.Icon, IconSize.Menu); window.DrawPixbuf(fgGCNormal, icon, 0, 0, margin, ypos, icon.Width, icon.Height, Gdk.RgbDither.None, 0, 0); layout.SetMarkup("<span weight='bold'>" + category.CompletionCategory.DisplayText + "</span>"); window.DrawLayout(textGCInsensitive, icon.Width + 4, ypos, layout); layout.SetMarkup(""); }, delegate(Category curCategory, int item, int ypos) { if (ypos >= height - margin) { return(false); } int itemIndex = filteredItems[item]; if (InCategoryMode && curCategory != null && curCategory.CompletionCategory != null) { xpos = margin + padding + 8; } else { xpos = margin + padding; } string markup = win.DataProvider.HasMarkup(itemIndex) ? (win.DataProvider.GetMarkup(itemIndex) ?? "<null>") : GLib.Markup.EscapeText(win.DataProvider.GetText(itemIndex) ?? "<null>"); string description = win.DataProvider.GetDescription(itemIndex); if (string.IsNullOrEmpty(description)) { layout.SetMarkup(markup); } else { if (item == selection) { layout.SetMarkup(markup + " " + description); } else { layout.SetMarkup(markup + " <span foreground=\"darkgray\">" + description + "</span>"); } } int mw, mh; layout.GetPixelSize(out mw, out mh); if (mw > listWidth) { WidthRequest = listWidth = mw; win.WidthRequest = win.Allocation.Width + mw - width; win.QueueResize(); } string text = win.DataProvider.GetText(itemIndex); if ((!SelectionEnabled || item != selection) && !string.IsNullOrEmpty(text)) { int[] matchIndices = Match(CompletionString, text); if (matchIndices != null) { Pango.AttrList attrList = layout.Attributes ?? new Pango.AttrList(); for (int newSelection = 0; newSelection < matchIndices.Length; newSelection++) { int idx = matchIndices[newSelection]; Pango.AttrForeground fg = new Pango.AttrForeground(0, 0, ushort.MaxValue); fg.StartIndex = (uint)idx; fg.EndIndex = (uint)(idx + 1); attrList.Insert(fg); } layout.Attributes = attrList; } } Gdk.Pixbuf icon = win.DataProvider.GetIcon(itemIndex); int iconHeight, iconWidth; if (icon != null) { iconWidth = icon.Width; iconHeight = icon.Height; } else if (!Gtk.Icon.SizeLookup(Gtk.IconSize.Menu, out iconWidth, out iconHeight)) { iconHeight = iconWidth = 24; } int wi, he, typos, iypos; layout.GetPixelSize(out wi, out he); typos = he < rowHeight ? ypos + (rowHeight - he) / 2 : ypos; iypos = iconHeight < rowHeight ? ypos + (rowHeight - iconHeight) / 2 : ypos; if (item == selection) { if (SelectionEnabled) { window.DrawRectangle(this.Style.BaseGC(StateType.Selected), true, margin, ypos, lineWidth, he + padding); window.DrawLayout(this.Style.TextGC(StateType.Selected), xpos + iconWidth + 2, typos, layout); } else { window.DrawRectangle(this.Style.DarkGC(StateType.Prelight), false, margin, ypos, lineWidth - 1, he + padding - 1); window.DrawLayout(textGCNormal, xpos + iconWidth + 2, typos, layout); } } else { window.DrawLayout(textGCNormal, xpos + iconWidth + 2, typos, layout); } if (icon != null) { window.DrawPixbuf(fgGCNormal, icon, 0, 0, xpos, iypos, iconWidth, iconHeight, Gdk.RgbDither.None, 0, 0); } layout.SetMarkup(""); if (layout.Attributes != null) { layout.Attributes.Dispose(); layout.Attributes = null; } return(true); }); /* * int n = 0; * while (ypos < winHeight - margin && (page + n) < filteredItems.Count) { * * bool hasMarkup = win.DataProvider.HasMarkup (filteredItems[page + n]); * if (hasMarkup) { * layout.SetMarkup (win.DataProvider.GetMarkup (filteredItems[page + n]) ?? "<null>"); * } else { * layout.SetText (win.DataProvider.GetText (filteredItems[page + n]) ?? "<null>"); * } * string text = win.DataProvider.GetText (filteredItems[page + n]); * if ((!SelectionEnabled || page + n != selection) && !string.IsNullOrEmpty (text)) { * int[] matchIndices = Match (CompletionString, text); * if (matchIndices != null) { * Pango.AttrList attrList = layout.Attributes ?? new Pango.AttrList (); * for (int newSelection = 0; newSelection < matchIndices.Length; newSelection++) { * int idx = matchIndices[newSelection]; * Pango.AttrForeground fg = new Pango.AttrForeground (0, 0, ushort.MaxValue); * fg.StartIndex = (uint)idx; * fg.EndIndex = (uint)(idx + 1); * attrList.Insert (fg); * } * layout.Attributes = attrList; * } * } * * Gdk.Pixbuf icon = win.DataProvider.GetIcon (filteredItems[page + n]); * int iconHeight, iconWidth; * if (icon != null) { * iconWidth = icon.Width; * iconHeight = icon.Height; * } else if (!Gtk.Icon.SizeLookup (Gtk.IconSize.Menu, out iconWidth, out iconHeight)) { * iconHeight = iconWidth = 24; * } * * int wi, he, typos, iypos; * layout.GetPixelSize (out wi, out he); * typos = he < rowHeight ? ypos + (rowHeight - he) / 2 : ypos; * iypos = iconHeight < rowHeight ? ypos + (rowHeight - iconHeight) / 2 : ypos; * if (page + n == selection) { * if (SelectionEnabled) { * window.DrawRectangle (this.Style.BaseGC (StateType.Selected), true, margin, ypos, lineWidth, he + padding); * window.DrawLayout (this.Style.TextGC (StateType.Selected), xpos + iconWidth + 2, typos, layout); * } else { * window.DrawRectangle (this.Style.DarkGC (StateType.Prelight), false, margin, ypos, lineWidth - 1, he + padding - 1); * window.DrawLayout (this.Style.TextGC (StateType.Normal), xpos + iconWidth + 2, typos, layout); * } * } else * window.DrawLayout (this.Style.TextGC (StateType.Normal), xpos + iconWidth + 2, typos, layout); * if (icon != null) * window.DrawPixbuf (this.Style.ForegroundGC (StateType.Normal), icon, 0, 0, xpos, iypos, iconWidth, iconHeight, Gdk.RgbDither.None, 0, 0); * ypos += rowHeight; * n++; * if (hasMarkup) * layout.SetMarkup (string.Empty); * if (layout.Attributes != null) { * layout.Attributes.Dispose (); * layout.Attributes = null; * } * } */ return(true); }
protected override void OnDestroyed() { base.OnDestroyed(); backGc.Dispose(); GLib.Source.Remove(TimerHandle); }
protected override bool OnExposeEvent (Gdk.EventExpose args) { using (var context = Gdk.CairoHelper.Create (args.Window)) { context.LineWidth = 1; Gdk.Window window = args.Window; var alloc = Allocation; int width = alloc.Width; int height = alloc.Height; context.Rectangle (args.Area.X, args.Area.Y, args.Area.Width, args.Area.Height); context.Color = this.backgroundColor; context.Fill (); int xpos = iconTextSpacing; int yPos = (int)-vadj.Value; //when there are no matches, display a message to indicate that the completion list is still handling input if (filteredItems.Count == 0) { Gdk.GC gc = new Gdk.GC (window); gc.RgbFgColor = backgroundColor.ToGdkColor (); window.DrawRectangle (gc, true, 0, yPos, width, height - yPos); noMatchLayout.SetText (win.DataProvider.ItemCount == 0 ? NoSuggestionsMsg : NoMatchesMsg); int lWidth, lHeight; noMatchLayout.GetPixelSize (out lWidth, out lHeight); gc.RgbFgColor = (Mono.TextEditor.HslColor)textColor; window.DrawLayout (gc, (width - lWidth) / 2, yPos + (height - lHeight - yPos) / 2 - lHeight, noMatchLayout); gc.Dispose (); return false; } var textGCNormal = new Gdk.GC (window); textGCNormal.RgbFgColor = (Mono.TextEditor.HslColor)textColor; var fgGCNormal = this.Style.ForegroundGC (StateType.Normal); var matcher = CompletionMatcher.CreateCompletionMatcher (CompletionString); Iterate (true, ref yPos, delegate (Category category, int ypos) { if (ypos >= height) return; if (ypos < -rowHeight) return; // window.DrawRectangle (this.Style.BackgroundGC (StateType.Insensitive), true, 0, yPos, width, rowHeight); int x = 2; if (category.CompletionCategory != null && !string.IsNullOrEmpty (category.CompletionCategory.Icon)) { var icon = ImageService.GetPixbuf (category.CompletionCategory.Icon, IconSize.Menu); window.DrawPixbuf (fgGCNormal, icon, 0, 0, 0, ypos, icon.Width, icon.Height, Gdk.RgbDither.None, 0, 0); x = icon.Width + 4; } context.Rectangle (0, ypos, Allocation.Width, rowHeight); context.Color = backgroundColor; context.Fill (); // layout.SetMarkup ("<span weight='bold' foreground='#AAAAAA'>" + (category.CompletionCategory != null ? category.CompletionCategory.DisplayText : "Uncategorized") + "</span>"); // window.DrawLayout (textGCInsensitive, x - 1, ypos + 1 + (rowHeight - py) / 2, layout); // layout.SetMarkup ("<span weight='bold'>" + (category.CompletionCategory != null ? category.CompletionCategory.DisplayText : "Uncategorized") + "</span>"); categoryLayout.SetMarkup ((category.CompletionCategory != null ? category.CompletionCategory.DisplayText : "Uncategorized")); int px, py; categoryLayout.GetPixelSize (out px, out py); window.DrawLayout (textGCNormal, x, ypos + (rowHeight - py) / 2, categoryLayout); }, delegate (Category curCategory, int item, int itemidx, int ypos) { if (ypos >= height) return false; if (ypos < -rowHeight) return true; const int categoryModeItemIndenting = 0; if (InCategoryMode && curCategory != null && curCategory.CompletionCategory != null) { xpos = iconTextSpacing + categoryModeItemIndenting; } else { xpos = iconTextSpacing; } string markup = win.DataProvider.HasMarkup (item) ? (win.DataProvider.GetMarkup (item) ?? "<null>") : GLib.Markup.EscapeText (win.DataProvider.GetText (item) ?? "<null>"); string description = win.DataProvider.GetDescription (item); if (string.IsNullOrEmpty (description)) { layout.SetMarkup (markup); } else { if (item == SelectedItem) { layout.SetMarkup (markup + " " + description); } else { layout.SetMarkup (markup + " <span foreground=\"darkgray\">" + description + "</span>"); } } string text = win.DataProvider.GetText (item); if (!string.IsNullOrEmpty (text)) { int[] matchIndices = matcher.GetMatch (text); if (matchIndices != null) { Pango.AttrList attrList = layout.Attributes ?? new Pango.AttrList (); for (int newSelection = 0; newSelection < matchIndices.Length; newSelection++) { int idx = matchIndices [newSelection]; var fg = new AttrForeground ((ushort)(highlightColor.R * ushort.MaxValue), (ushort)(highlightColor.G * ushort.MaxValue), (ushort)(highlightColor.B * ushort.MaxValue)); fg.StartIndex = (uint)idx; fg.EndIndex = (uint)(idx + 1); attrList.Insert (fg); } layout.Attributes = attrList; } } Gdk.Pixbuf icon = win.DataProvider.GetIcon (item); int iconHeight, iconWidth; if (icon != null) { iconWidth = icon.Width; iconHeight = icon.Height; } else if (!Gtk.Icon.SizeLookup (Gtk.IconSize.Menu, out iconWidth, out iconHeight)) { iconHeight = iconWidth = 24; } int wi, he, typos, iypos; layout.GetPixelSize (out wi, out he); typos = he < rowHeight ? ypos + (rowHeight - he) / 2 : ypos; iypos = iconHeight < rowHeight ? ypos + (rowHeight - iconHeight) / 2 : ypos; if (item == SelectedItem) { context.Rectangle (0, ypos, Allocation.Width, rowHeight / 2); context.Color = SelectionEnabled ? selectedItemColor.Foreground : selectedItemInactiveColor.Foreground; context.Fill (); context.Rectangle (0, ypos + rowHeight / 2, Allocation.Width, rowHeight / 2); context.Color = SelectionEnabled ? selectedItemColor.Background : selectedItemInactiveColor.Background; context.Fill (); context.Rectangle (0.5, ypos + 0.5, Allocation.Width - 1, rowHeight - 1); if (!SelectionEnabled) context.SetDash (new double[] {4, 4}, 0); context.Color = SelectionEnabled ? selectionBorderColor : selectionBorderInactiveColor; context.Stroke (); } if (icon != null) { window.DrawPixbuf (fgGCNormal, icon, 0, 0, xpos, iypos, iconWidth, iconHeight, Gdk.RgbDither.None, 0, 0); xpos += iconTextSpacing; } window.DrawLayout (textGCNormal, xpos + iconWidth + 2, typos, layout); if (wi + xpos + iconWidth + 2 > listWidth) { WidthRequest = listWidth = wi + xpos + iconWidth + 2 + iconTextSpacing; win.ResetSizes (); } else { //workaround for the vscrollbar display - the calculated width needs to be the width ofthe render region. if (Allocation.Width < listWidth) { if (listWidth - Allocation.Width < 30) { WidthRequest = listWidth + listWidth - Allocation.Width; win.ResetSizes (); } } } layout.SetMarkup (""); if (layout.Attributes != null) { layout.Attributes.Dispose (); layout.Attributes = null; } return true; }); /* int n = 0; while (ypos < winHeight - margin && (page + n) < filteredItems.Count) { bool hasMarkup = win.DataProvider.HasMarkup (filteredItems[page + n]); if (hasMarkup) { layout.SetMarkup (win.DataProvider.GetMarkup (filteredItems[page + n]) ?? "<null>"); } else { layout.SetText (win.DataProvider.GetText (filteredItems[page + n]) ?? "<null>"); } string text = win.DataProvider.GetText (filteredItems[page + n]); if ((!SelectionEnabled || page + n != selection) && !string.IsNullOrEmpty (text)) { int[] matchIndices = Match (CompletionString, text); if (matchIndices != null) { Pango.AttrList attrList = layout.Attributes ?? new Pango.AttrList (); for (int newSelection = 0; newSelection < matchIndices.Length; newSelection++) { int idx = matchIndices[newSelection]; Pango.AttrForeground fg = new Pango.AttrForeground (0, 0, ushort.MaxValue); fg.StartIndex = (uint)idx; fg.EndIndex = (uint)(idx + 1); attrList.Insert (fg); } layout.Attributes = attrList; } } Gdk.Pixbuf icon = win.DataProvider.GetIcon (filteredItems[page + n]); int iconHeight, iconWidth; if (icon != null) { iconWidth = icon.Width; iconHeight = icon.Height; } else if (!Gtk.Icon.SizeLookup (Gtk.IconSize.Menu, out iconWidth, out iconHeight)) { iconHeight = iconWidth = 24; } int wi, he, typos, iypos; layout.GetPixelSize (out wi, out he); typos = he < rowHeight ? ypos + (rowHeight - he) / 2 : ypos; iypos = iconHeight < rowHeight ? ypos + (rowHeight - iconHeight) / 2 : ypos; if (page + n == selection) { if (SelectionEnabled) { window.DrawRectangle (this.Style.BaseGC (StateType.Selected), true, margin, ypos, lineWidth, he + padding); window.DrawLayout (this.Style.TextGC (StateType.Selected), xpos + iconWidth + 2, typos, layout); } else { window.DrawRectangle (this.Style.DarkGC (StateType.Prelight), false, margin, ypos, lineWidth - 1, he + padding - 1); window.DrawLayout (this.Style.TextGC (StateType.Normal), xpos + iconWidth + 2, typos, layout); } } else window.DrawLayout (this.Style.TextGC (StateType.Normal), xpos + iconWidth + 2, typos, layout); if (icon != null) window.DrawPixbuf (this.Style.ForegroundGC (StateType.Normal), icon, 0, 0, xpos, iypos, iconWidth, iconHeight, Gdk.RgbDither.None, 0, 0); ypos += rowHeight; n++; if (hasMarkup) layout.SetMarkup (string.Empty); if (layout.Attributes != null) { layout.Attributes.Dispose (); layout.Attributes = null; } } */ return false; } }
protected void OnTableTabsExposeEvent (object o, ExposeEventArgs args) { Color fore = Style.Foreground(StateType.Normal); Drawable draw = args.Event.Window; Gdk.GC gc = new Gdk.GC(draw); try { Rectangle tabRect; switch (notebook.CurrentPage) { case 0: // WiFi tabRect = imageTabWiFi.Allocation; break; case 1: // Clock tabRect = imageTabClock.Allocation; break; case 2: // Radio tabRect = imageTabRadio.Allocation; break; case 3: // weather tabRect = imageTabWeather.Allocation; break; default: tabRect = imageTabIntercom.Allocation; break; } Rectangle rect = notebook.Allocation; rect.Inflate(4, 4); tabRect.Inflate(4, 4); List<Gdk.Point> points = new List<Gdk.Point>(); points.Add(new Point(rect.Left, rect.Top)); points.Add(new Point(rect.Right, rect.Top)); points.Add(new Point(rect.Right, tabRect.Top)); points.Add(new Point(tabRect.Right, tabRect.Top)); points.Add(new Point(tabRect.Right, tabRect.Bottom)); points.Add(new Point(rect.Right, tabRect.Bottom)); points.Add(new Point(rect.Right, rect.Bottom)); points.Add(new Point(rect.Left, rect.Bottom)); points.Add(new Point(rect.Left, rect.Top)); gc.Foreground = fore; gc.Background = fore; gc.SetLineAttributes(4, LineStyle.Solid, CapStyle.Round, JoinStyle.Round); draw.DrawLines(gc, points.ToArray()); } catch (Exception ex) { Console.WriteLine(ex.Source); Console.WriteLine(ex.StackTrace); } gc.Dispose(); }
protected override bool OnExposeEvent(EventExpose evnt) { var baseResult = base.OnExposeEvent(evnt); if (TrackerCore.Instance.TaskManager is EmptyTaskManager) { return(baseResult); } Source = TrackerCore.Instance.TaskManager.AssigmentSource; var v1 = Source.Tables["DataRange"].Rows[0]["MinDate"]; var firstDate = v1 as DateTime? ?? DateTime.Now; var v2 = Source.Tables["DataRange"].Rows[0]["MaxDate"]; var lastDate = v2 as DateTime? ?? DateTime.Now; var deltaSpan = lastDate.Subtract(firstDate); // Insert drawing code here. if (grw == null) { grw = Gdk.CairoHelper.Create(GdkWindow); } int fX, fY, fWidth, fHeight, fDepth; GdkWindow.GetGeometry(out fX, out fY, out fWidth, out fHeight, out fDepth); fWidth -= 3; fHeight -= 3; var delta = (deltaSpan.Days > 0) ? (fWidth - 2 * FBorderMarginH) / deltaSpan.Days : (fWidth - 2 * FBorderMarginH); GdkWindow.ClearArea(fX, fY, fWidth, fHeight); Show(); //DrawBorder grw.SetSourceRGB(0xff, 0, 0); grw.MoveTo(FBorderMarginH, FBorderMarginV); grw.LineTo(fWidth - FBorderMarginH, FBorderMarginV); grw.LineTo(fWidth - FBorderMarginH, fHeight - FBorderMarginV); grw.LineTo(FBorderMarginH, fHeight - FBorderMarginV); grw.LineTo(FBorderMarginH, FBorderMarginV); grw.Stroke(); //DrawTasks var deltaActor = (Source.Tables["Actor"].Rows.Count > 0) ? (fHeight - 2 * FBorderMarginV) / Source.Tables["Actor"].Rows.Count : fHeight - 2 * FBorderMarginV; deltaActor -= FTaskHeight; var maxTaskCout = (from DataRow row in Source.Tables["AssigmentSource"].Rows select(int) row["TaskCount"]).Concat(new[] { 0 }).Max(); var actorIndex = 0; var foregroundColor3 = new Gdk.Color(0xff, 0xff, 0xff); var taskLabelGc = new Gdk.GC(GdkWindow); var colormap = Colormap.System; colormap.AllocColor(ref foregroundColor3, true, true); taskLabelGc.Foreground = foregroundColor3; //draw proportion line. var states1 = new Dictionary <int, int>(); foreach (DataRow row in Source.Tables["StateRange"].Rows) { v1 = row["StateID"]; var id = v1 as int? ?? -1; if (states1.ContainsKey(id)) { states1[id] += 1; } else { states1.Add(id, 0); } } var sum = states1.Keys.Sum(id => states1[id]); var states2 = states1.Keys.ToList(); foreach (var id in states2.OrderBy(s => s)) { states1[id] = (int)(((double)fHeight / sum) * states1[id]); } var proportionOffset = 0; foreach (var id in states1.Keys) { var state = Source.Tables["StateRange"].Select("StateID = " + id)[0]; var taskGc = new Gdk.GC(GdkWindow); try { var colorRed = Convert.ToByte(state["ColorRed"]); var colorGreen = Convert.ToByte(state["ColorGreen"]); var colorBlue = Convert.ToByte(state["ColorBlue"]); var foregroundColor2 = new Gdk.Color(colorRed, colorGreen, colorBlue); colormap.AllocColor(ref foregroundColor2, true, true); taskGc.Foreground = foregroundColor2; } catch (Exception e) { Console.WriteLine(e); throw; } GdkWindow.DrawRectangle(taskGc, true, fWidth - 10, proportionOffset, 10, states1[id]); proportionOffset += states1[id]; } foreach (DataRow row in Source.Tables["Actor"].Rows) { var labelDate = firstDate; var offset = FBorderMarginH; for (var i = 0; i < deltaSpan.Days; i++) { var taskCount = 0; var assignmentId = -1; var assignment = Source.Tables["AssigmentSource"] .Select("ActorID = " + row["ID"] + "and Date = '" + labelDate.ToShortDateString() + "'"); if (assignment.Length > 0) { v1 = assignment[0]["TaskCount"]; taskCount = v1 as int? ?? -1; v2 = assignment[0]["ID"]; assignmentId = v2 as int? ?? -1; } if (taskCount > 0) { var states = Source.Tables["StateRange"].Select("AssigmentID = " + assignmentId, "StateID"); //order by stateid var taskSum = 0; foreach (var state in states) { var taskGc = new Gdk.GC(GdkWindow); try { var colorRed = Convert.ToByte(state["ColorRed"]); var colorGreen = Convert.ToByte(state["ColorGreen"]); var colorBlue = Convert.ToByte(state["ColorBlue"]); var foregroundColor2 = new Gdk.Color(colorRed, colorGreen, colorBlue); colormap.AllocColor(ref foregroundColor2, true, true); taskGc.Foreground = foregroundColor2; } catch (Exception e) { Console.WriteLine(e); } var currentCount = (int)state["TaskCount"]; GdkWindow.DrawRectangle( taskGc, true, offset, FBorderMarginV + (int)(deltaActor * (1 - (double)(taskSum + currentCount) / maxTaskCout)) + deltaActor * actorIndex , delta , (int)(deltaActor * ((double)currentCount / maxTaskCout))); taskSum += currentCount; var layout = new Layout(PangoContext) { Wrap = WrapMode.Word, FontDescription = FontDescription.FromString("Tahoma 10") }; layout.SetMarkup(taskCount.ToString()); GdkWindow.DrawLayout(taskLabelGc, offset, (int)(deltaActor * (1 - (double)taskCount / maxTaskCout)) + deltaActor * actorIndex, layout); } } offset += delta; labelDate = labelDate.AddDays(1); } actorIndex++; } taskLabelGc.Dispose(); //DrawActorAxis var offsetActor = FBorderMarginV; var foregroundColor = new Gdk.Color(0xff, 0, 0); var foregroundColor1 = new Gdk.Color(0, 0, 0xff); var actorLabelGc = new Gdk.GC(GdkWindow); var axisGc = new Gdk.GC(GdkWindow); colormap.AllocColor(ref foregroundColor, true, true); taskLabelGc.Foreground = foregroundColor; axisGc.Foreground = foregroundColor1; foreach (DataRow row in Source.Tables["Actor"].Rows) { var layout = new Layout(PangoContext) { Wrap = WrapMode.Word, FontDescription = FontDescription.FromString("Tahoma 10") }; layout.SetMarkup((string)row["Name"]); GdkWindow.DrawLayout(actorLabelGc, FBorderMarginH, offsetActor - FBorderMarginV, layout); GdkWindow.DrawLine(axisGc, FBorderMarginH, offsetActor, fWidth - FBorderMarginH, offsetActor); offsetActor += deltaActor; } axisGc.Dispose(); //DrawDateAxis var labelDate1 = firstDate; var offset1 = FBorderMarginH; for (var i = 0; i < deltaSpan.Days; i++) { var layout = new Layout(PangoContext) { Wrap = WrapMode.Word, FontDescription = FontDescription.FromString("Tahoma 10") }; layout.SetMarkup(labelDate1.ToString("dd/MM")); GdkWindow.DrawLayout(actorLabelGc, offset1 + FBorderMarginH, fHeight - 2 * FBorderMarginV - FTaskHeight, layout); GdkWindow.DrawLine(axisGc, offset1, FBorderMarginV, offset1, fHeight - FBorderMarginV); offset1 += delta; labelDate1 = labelDate1.AddDays(1); } actorLabelGc.Dispose(); //DrawDateNow var nowSpan = DateTime.Now.Subtract(firstDate); var offsetDate = FBorderMarginH + (int)(delta * (double)nowSpan.Ticks / TimeSpan.TicksPerDay); grw.SetSourceRGB(0, 0, 0); grw.MoveTo(offsetDate, FBorderMarginV); grw.LineTo(offsetDate, fHeight - FBorderMarginV); grw.RelLineTo(new Distance { Dx = -3, Dy = 0 }); grw.RelLineTo(new Distance { Dx = 3, Dy = -3 }); grw.RelLineTo(new Distance { Dx = 3, Dy = 3 }); grw.RelLineTo(new Distance { Dx = -3, Dy = 0 }); grw.Stroke(); return(true); }
protected override void Render (Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags) { if (isDisposed) return; if (diffMode) { if (path.Equals (selctedPath)) { selectedLine = -1; selctedPath = null; } int w, maxy; window.GetSize (out w, out maxy); var treeview = widget as FileTreeView; var p = treeview != null? treeview.CursorLocation : null; int recty = cell_area.Y; int recth = cell_area.Height - 1; if (recty < 0) { recth += recty + 1; recty = -1; } if (recth > maxy + 2) recth = maxy + 2; window.DrawRectangle (widget.Style.BaseGC (Gtk.StateType.Normal), true, cell_area.X, recty, cell_area.Width - 1, recth); Gdk.GC normalGC = widget.Style.TextGC (StateType.Normal); Gdk.GC removedGC = new Gdk.GC (window); removedGC.Copy (normalGC); removedGC.RgbFgColor = new Color (255, 0, 0); Gdk.GC addedGC = new Gdk.GC (window); addedGC.Copy (normalGC); addedGC.RgbFgColor = new Color (0, 0, 255); Gdk.GC infoGC = new Gdk.GC (window); infoGC.Copy (normalGC); infoGC.RgbFgColor = new Color (0xa5, 0x2a, 0x2a); int y = cell_area.Y + 2; int cline = 1; bool inHeader = true; for (int n=0; n<lines.Length; n++, y += lineHeight) { string line = lines [n]; if (line.Length == 0) continue; char tag = line [0]; // Keep track of the real file line int thisLine = cline; if (tag == '@') { int l = ParseCurrentLine (line); if (l != -1) cline = thisLine = l; inHeader = false; } else if (tag != '-' && !inHeader) cline++; if (y + lineHeight < 0) continue; if (y > maxy) break; Gdk.GC gc; switch (tag) { case '-': gc = removedGC; break; case '+': gc = addedGC; break; case '@': gc = infoGC; break; default: gc = normalGC; break; } if (p.HasValue && p.Value.X >= cell_area.X && p.Value.X <= cell_area.Right && p.Value.Y >= y && p.Value.Y < y + lineHeight) { window.DrawRectangle (widget.Style.BaseGC (Gtk.StateType.Prelight), true, cell_area.X, y, cell_area.Width - 1, lineHeight); selectedLine = thisLine; selctedPath = path; } layout.SetText (line); window.DrawLayout (gc, cell_area.X + 2, y, layout); } window.DrawRectangle (widget.Style.DarkGC (Gtk.StateType.Prelight), false, cell_area.X, recty, cell_area.Width - 1, recth); removedGC.Dispose (); addedGC.Dispose (); infoGC.Dispose (); } else { int y = cell_area.Y + (cell_area.Height - height)/2; window.DrawLayout (widget.Style.TextGC (GetState(flags)), cell_area.X, y, layout); } }
protected override void OnDestroyed () { base.OnDestroyed (); backGc.Dispose (); }
protected void OnDrawClockExposeEvent(object o, Gtk.ExposeEventArgs args) { Gdk.Color back = Style.Background(StateType.Normal); Gdk.Color fore = Style.Foreground(StateType.Normal); Drawable draw = args.Event.Window; int width; int height; draw.GetSize(out width, out height); Gdk.GC gc = new Gdk.GC(draw); gc.Foreground = back; gc.Background = back; Point start; Point stop; double xMax; double yMax; double angle = 0; int size = width < height ? width : height; size -= Spacing; Point center = new Point(width / 2, height / 2); Rectangle rect = new Rectangle((width - size) / 2, (height - size) / 2, size, size); if (clockFace != null && (clockFace.Width != width || clockFace.Height != height)) { clockFace.Dispose(); clockFace = null; } if (clockFace == null) { draw.DrawPixbuf(gc, clockFace, 0, 0, 0, 0, width, height, RgbDither.None, 0, 0); draw.DrawRectangle(gc, true, 0, 0, width, height); gc.Foreground = fore; gc.SetLineAttributes(4, LineStyle.Solid, CapStyle.Round, JoinStyle.Round); draw.DrawArc(gc, false, rect.Left, rect.Top, size, size, 0, 360 * 64); gc.SetLineAttributes(1, LineStyle.Solid, CapStyle.Round, JoinStyle.Round); for (int index = 0; index < 60; index++, angle += Math.PI / 30.0) { xMax = Math.Cos(angle) * size / 2; yMax = Math.Sin(angle) * size / 2; start = center; stop = center; if ((index % 5) == 0) { int hour = ((index / 5) + 3) % 12; if (hour == 0) hour = 12; start.Offset((int)(xMax / 1.30), (int)(yMax / 1.30)); Pango.FontDescription font = Pango.FontDescription.FromString("Serif 10"); Pango.Layout layout = CreatePangoLayout(hour.ToString()); layout.FontDescription = font; layout.Width = Pango.Units.FromPixels(100); int textWidth; int textHeight; layout.GetPixelSize(out textWidth, out textHeight); start.Offset(-textWidth / 2, -textHeight / 2); draw.DrawLayoutWithColors(gc, start.X, start.Y, layout, fore, back); layout.Dispose(); start = center; gc.SetLineAttributes(4, LineStyle.Solid, CapStyle.Round, JoinStyle.Round); start.Offset((int)(xMax / 1.05), (int)(yMax / 1.05)); stop.Offset((int)xMax, (int)yMax); draw.DrawLine(gc, start.X, start.Y, stop.X, stop.Y); gc.SetLineAttributes(1, LineStyle.Solid, CapStyle.Round, JoinStyle.Round); } else { start.Offset((int)(xMax / 1.05), (int)(yMax / 1.05)); stop.Offset((int)xMax, (int)yMax); draw.DrawLine(gc, start.X, start.Y, stop.X, stop.Y); } } clockFace = Pixbuf.FromDrawable(draw, draw.Colormap, 0, 0, 0, 0, width, height); } else { draw.DrawPixbuf(gc, clockFace, 0, 0, 0, 0, width, height, RgbDither.None, 0, 0); } gc.Foreground = fore; double startAngle = 1.5 * Math.PI; double secondAngle; double minuteAngle; double hourAngle; if (AnalogMovement) { double value = (CurrentTime.Second * 1000) + CurrentTime.Millisecond; double divisor = 60000.0; secondAngle = 2.0 * Math.PI * value / divisor + startAngle; value += (double) CurrentTime.Minute * divisor; divisor *= 60.0; minuteAngle = 2.0 * Math.PI * value / divisor + startAngle; value += (double) ((CurrentTime.Hour) % 12) * divisor; divisor *= 12.0; hourAngle = 2.0 * Math.PI * value / divisor + startAngle; } else { double value = CurrentTime.Second; double divisor = 60; secondAngle = 2.0 * Math.PI * value / divisor + startAngle; value = CurrentTime.Minute; divisor = 60; minuteAngle = 2.0 * Math.PI * value / divisor + startAngle; value = ((CurrentTime.Hour) % 12); divisor = 12; hourAngle = 2.0 * Math.PI * value / divisor + startAngle; } start = center; stop = center; xMax = Math.Cos(secondAngle) * size / 2; yMax = Math.Sin(secondAngle) * size / 2; stop.Offset((int) (xMax / 1.2), (int) (yMax / 1.2)); draw.DrawLine(gc, start.X, start.Y , stop.X, stop.Y); stop = center; xMax = Math.Cos(minuteAngle) * size / 2; yMax = Math.Sin(minuteAngle) * size / 2; stop.Offset((int) (xMax / 1.4), (int) (yMax / 1.4)); gc.SetLineAttributes(4, LineStyle.Solid, CapStyle.Round, JoinStyle.Round); draw.DrawLine(gc, start.X, start.Y , stop.X, stop.Y); stop = center; xMax = Math.Cos(hourAngle) * size / 2; yMax = Math.Sin(hourAngle) * size / 2; stop.Offset((int) (xMax / 2.2), (int) (yMax / 2.2)); gc.SetLineAttributes(8, LineStyle.Solid, CapStyle.Round, JoinStyle.Round); draw.DrawLine(gc, start.X, start.Y , stop.X, stop.Y); gc.Dispose(); }
protected override bool OnExposeEvent(Gdk.EventExpose args) { using (var context = Gdk.CairoHelper.Create(args.Window)) { context.LineWidth = 1; Gdk.Window window = args.Window; var alloc = Allocation; int width = alloc.Width; int height = alloc.Height; context.Rectangle(args.Area.X, args.Area.Y, args.Area.Width, args.Area.Height); context.Color = this.backgroundColor; context.Fill(); int xpos = iconTextSpacing; int yPos = (int)-vadj.Value; //when there are no matches, display a message to indicate that the completion list is still handling input if (filteredItems.Count == 0) { Gdk.GC gc = new Gdk.GC(window); gc.RgbFgColor = backgroundColor.ToGdkColor(); window.DrawRectangle(gc, true, 0, yPos, width, height - yPos); noMatchLayout.SetText(win.DataProvider.ItemCount == 0 ? NoSuggestionsMsg : NoMatchesMsg); int lWidth, lHeight; noMatchLayout.GetPixelSize(out lWidth, out lHeight); gc.RgbFgColor = (Mono.TextEditor.HslColor)textColor; window.DrawLayout(gc, (width - lWidth) / 2, yPos + (height - lHeight - yPos) / 2 - lHeight, noMatchLayout); gc.Dispose(); return(false); } var textGCNormal = new Gdk.GC(window); textGCNormal.RgbFgColor = (Mono.TextEditor.HslColor)textColor; var fgGCNormal = this.Style.ForegroundGC(StateType.Normal); var matcher = CompletionMatcher.CreateCompletionMatcher(CompletionString); Iterate(true, ref yPos, delegate(Category category, int ypos) { if (ypos >= height) { return; } if (ypos < -rowHeight) { return; } // window.DrawRectangle (this.Style.BackgroundGC (StateType.Insensitive), true, 0, yPos, width, rowHeight); int x = 2; if (category.CompletionCategory != null && !string.IsNullOrEmpty(category.CompletionCategory.Icon)) { var icon = ImageService.GetPixbuf(category.CompletionCategory.Icon, IconSize.Menu); window.DrawPixbuf(fgGCNormal, icon, 0, 0, 0, ypos, icon.Width, icon.Height, Gdk.RgbDither.None, 0, 0); x = icon.Width + 4; } context.Rectangle(0, ypos, Allocation.Width, rowHeight); context.Color = backgroundColor; context.Fill(); // layout.SetMarkup ("<span weight='bold' foreground='#AAAAAA'>" + (category.CompletionCategory != null ? category.CompletionCategory.DisplayText : "Uncategorized") + "</span>"); // window.DrawLayout (textGCInsensitive, x - 1, ypos + 1 + (rowHeight - py) / 2, layout); // layout.SetMarkup ("<span weight='bold'>" + (category.CompletionCategory != null ? category.CompletionCategory.DisplayText : "Uncategorized") + "</span>"); categoryLayout.SetMarkup((category.CompletionCategory != null ? category.CompletionCategory.DisplayText : "Uncategorized")); int px, py; categoryLayout.GetPixelSize(out px, out py); window.DrawLayout(textGCNormal, x, ypos + (rowHeight - py) / 2, categoryLayout); }, delegate(Category curCategory, int item, int itemidx, int ypos) { if (ypos >= height) { return(false); } if (ypos < -rowHeight) { return(true); } const int categoryModeItemIndenting = 0; if (InCategoryMode && curCategory != null && curCategory.CompletionCategory != null) { xpos = iconTextSpacing + categoryModeItemIndenting; } else { xpos = iconTextSpacing; } string markup = win.DataProvider.HasMarkup(item) ? (win.DataProvider.GetMarkup(item) ?? "<null>") : GLib.Markup.EscapeText(win.DataProvider.GetText(item) ?? "<null>"); string description = win.DataProvider.GetDescription(item); if (string.IsNullOrEmpty(description)) { layout.SetMarkup(markup); } else { if (item == SelectedItem) { layout.SetMarkup(markup + " " + description); } else { layout.SetMarkup(markup + " <span foreground=\"darkgray\">" + description + "</span>"); } } string text = win.DataProvider.GetText(item); if (!string.IsNullOrEmpty(text)) { int[] matchIndices = matcher.GetMatch(text); if (matchIndices != null) { Pango.AttrList attrList = layout.Attributes ?? new Pango.AttrList(); for (int newSelection = 0; newSelection < matchIndices.Length; newSelection++) { int idx = matchIndices [newSelection]; var fg = new AttrForeground((ushort)(highlightColor.R * ushort.MaxValue), (ushort)(highlightColor.G * ushort.MaxValue), (ushort)(highlightColor.B * ushort.MaxValue)); fg.StartIndex = (uint)idx; fg.EndIndex = (uint)(idx + 1); attrList.Insert(fg); } layout.Attributes = attrList; } } Gdk.Pixbuf icon = win.DataProvider.GetIcon(item); int iconHeight, iconWidth; if (icon != null) { iconWidth = icon.Width; iconHeight = icon.Height; } else if (!Gtk.Icon.SizeLookup(Gtk.IconSize.Menu, out iconWidth, out iconHeight)) { iconHeight = iconWidth = 24; } int wi, he, typos, iypos; layout.GetPixelSize(out wi, out he); typos = he < rowHeight ? ypos + (rowHeight - he) / 2 : ypos; iypos = iconHeight < rowHeight ? ypos + (rowHeight - iconHeight) / 2 : ypos; if (item == SelectedItem) { context.Rectangle(0, ypos, Allocation.Width, rowHeight / 2); context.Color = SelectionEnabled ? selectedItemColor.Foreground : selectedItemInactiveColor.Background; context.Fill(); context.Rectangle(0, ypos + rowHeight / 2, Allocation.Width, rowHeight / 2); context.Color = SelectionEnabled ? selectedItemColor.Background : selectedItemInactiveColor.Background; context.Fill(); context.Rectangle(0.5, ypos + 0.5, Allocation.Width - 1, rowHeight - 1); if (!SelectionEnabled) { context.SetDash(new double[] { 4, 4 }, 0); } context.Color = SelectionEnabled ? selectionBorderColor : selectionBorderInactiveColor; context.Stroke(); } if (icon != null) { window.DrawPixbuf(fgGCNormal, icon, 0, 0, xpos, iypos, iconWidth, iconHeight, Gdk.RgbDither.None, 0, 0); xpos += iconTextSpacing; } window.DrawLayout(textGCNormal, xpos + iconWidth + 2, typos, layout); if (wi + xpos + iconWidth + 2 > listWidth) { WidthRequest = listWidth = wi + xpos + iconWidth + 2 + iconTextSpacing; win.ResetSizes(); } else { //workaround for the vscrollbar display - the calculated width needs to be the width ofthe render region. if (Allocation.Width < listWidth) { if (listWidth - Allocation.Width < 30) { WidthRequest = listWidth + listWidth - Allocation.Width; win.ResetSizes(); } } } layout.SetMarkup(""); if (layout.Attributes != null) { layout.Attributes.Dispose(); layout.Attributes = null; } return(true); }); /* * int n = 0; * while (ypos < winHeight - margin && (page + n) < filteredItems.Count) { * * bool hasMarkup = win.DataProvider.HasMarkup (filteredItems[page + n]); * if (hasMarkup) { * layout.SetMarkup (win.DataProvider.GetMarkup (filteredItems[page + n]) ?? "<null>"); * } else { * layout.SetText (win.DataProvider.GetText (filteredItems[page + n]) ?? "<null>"); * } * string text = win.DataProvider.GetText (filteredItems[page + n]); * if ((!SelectionEnabled || page + n != selection) && !string.IsNullOrEmpty (text)) { * int[] matchIndices = Match (CompletionString, text); * if (matchIndices != null) { * Pango.AttrList attrList = layout.Attributes ?? new Pango.AttrList (); * for (int newSelection = 0; newSelection < matchIndices.Length; newSelection++) { * int idx = matchIndices[newSelection]; * Pango.AttrForeground fg = new Pango.AttrForeground (0, 0, ushort.MaxValue); * fg.StartIndex = (uint)idx; * fg.EndIndex = (uint)(idx + 1); * attrList.Insert (fg); * } * layout.Attributes = attrList; * } * } * * Gdk.Pixbuf icon = win.DataProvider.GetIcon (filteredItems[page + n]); * int iconHeight, iconWidth; * if (icon != null) { * iconWidth = icon.Width; * iconHeight = icon.Height; * } else if (!Gtk.Icon.SizeLookup (Gtk.IconSize.Menu, out iconWidth, out iconHeight)) { * iconHeight = iconWidth = 24; * } * * int wi, he, typos, iypos; * layout.GetPixelSize (out wi, out he); * typos = he < rowHeight ? ypos + (rowHeight - he) / 2 : ypos; * iypos = iconHeight < rowHeight ? ypos + (rowHeight - iconHeight) / 2 : ypos; * if (page + n == selection) { * if (SelectionEnabled) { * window.DrawRectangle (this.Style.BaseGC (StateType.Selected), true, margin, ypos, lineWidth, he + padding); * window.DrawLayout (this.Style.TextGC (StateType.Selected), xpos + iconWidth + 2, typos, layout); * } else { * window.DrawRectangle (this.Style.DarkGC (StateType.Prelight), false, margin, ypos, lineWidth - 1, he + padding - 1); * window.DrawLayout (this.Style.TextGC (StateType.Normal), xpos + iconWidth + 2, typos, layout); * } * } else * window.DrawLayout (this.Style.TextGC (StateType.Normal), xpos + iconWidth + 2, typos, layout); * if (icon != null) * window.DrawPixbuf (this.Style.ForegroundGC (StateType.Normal), icon, 0, 0, xpos, iypos, iconWidth, iconHeight, Gdk.RgbDither.None, 0, 0); * ypos += rowHeight; * n++; * if (hasMarkup) * layout.SetMarkup (string.Empty); * if (layout.Attributes != null) { * layout.Attributes.Dispose (); * layout.Attributes = null; * } * } */ return(false); } }
protected void OnDrawWeatherExposeEvent(object o, ExposeEventArgs args) { Gdk.Color back = Style.Background(StateType.Normal); Gdk.Color fore = Style.Foreground(StateType.Normal); Drawable draw = drawWeather.GdkWindow; Gdk.GC gc = new Gdk.GC(draw); try { gc.Foreground = back; gc.Background = back; int width; int height; draw.GetSize(out width, out height); draw.DrawRectangle(gc, true, 0, 0, width, height); gc.Foreground = fore; String text = ""; if (Weather.Forecasts.Count > SelectedForecast) { WeatherService.WeatherPeriod info = Weather.Forecasts[SelectedForecast]; text = info.Title + " - " + info.Forecast + "\n"; } Pango.FontDescription font = Pango.FontDescription.FromString("Serif 14"); Pango.Layout layout = drawWeather.CreatePangoLayout(text); layout.FontDescription = font; layout.Width = Pango.Units.FromPixels(width); draw.DrawLayoutWithColors(gc, 0, 0, layout, fore, back); layout.Dispose(); } catch (Exception ex) { Console.WriteLine(ex.Source); Console.WriteLine(ex.StackTrace); } gc.Dispose(); }
protected void OnTableWeatherExposeEvent(object o, ExposeEventArgs args) { Color fore = Style.Foreground(StateType.Normal); Drawable draw = args.Event.Window; Gdk.GC gc = new Gdk.GC(draw); Rectangle rect; switch (SelectedForecast) { case 0: rect = imageMorning1.Allocation; break; case 1: rect = imageDay1.Allocation; break; case 2: rect = imageMorning2.Allocation; break; case 3: rect = imageDay2.Allocation; break; case 4: rect = imageMorning3.Allocation; break; case 5: rect = imageDay3.Allocation; break; case 6: rect = imageMorning4.Allocation; break; default: rect = imageDay4.Allocation; break; } gc.Foreground = fore; gc.Background = fore; gc.SetLineAttributes(4, LineStyle.Solid, CapStyle.Round, JoinStyle.Round); draw.DrawRectangle(gc, false, rect); gc.Dispose(); }
protected override bool OnExposeEvent(Gdk.EventExpose ev) { base.OnExposeEvent(ev); // Insert drawing code here. var window = ev.Window; var gc = new Gdk.GC(window); // window.DrawRectangle(gc, true, new Rectangle(0, 0, 100, 100)); int width = this.DrawingWidth; int height = this.DrawingHeight; CheckerPattern.Draw(window, gc, 10, width, height); DrawImage(window, gc); DrawIslands(window, gc); m_linkIslandsHelper.Step4_Draw(window, gc); gc.Dispose(); return true; }
protected override void Render (Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags) { if (isDisposed) return; try { if (diffMode) { int w, maxy; window.GetSize (out w, out maxy); int recty = cell_area.Y; int recth = cell_area.Height - 1; if (recty < 0) { recth += recty + 1; recty = -1; } if (recth > maxy + 2) recth = maxy + 2; window.DrawRectangle (widget.Style.BaseGC (Gtk.StateType.Normal), true, cell_area.X, recty, cell_area.Width - 1, recth); Gdk.GC normalGC = widget.Style.TextGC (StateType.Normal); Gdk.GC removedGC = new Gdk.GC (window); removedGC.Copy (normalGC); removedGC.RgbFgColor = new Color (255, 0, 0); Gdk.GC addedGC = new Gdk.GC (window); addedGC.Copy (normalGC); addedGC.RgbFgColor = new Color (0, 0, 255); Gdk.GC infoGC = new Gdk.GC (window); infoGC.Copy (normalGC); infoGC.RgbFgColor = new Color (0xa5, 0x2a, 0x2a); int y = cell_area.Y + 2; for (int n = 0; n < lines.Length; n++,y += lineHeight) { if (y + lineHeight < 0) continue; if (y > maxy) break; string line = lines[n]; if (line.Length == 0) continue; Gdk.GC gc; switch (line[0]) { case '-': gc = removedGC; break; case '+': gc = addedGC; break; case '@': gc = infoGC; break; default: gc = normalGC; break; } layout.SetText (line); window.DrawLayout (gc, cell_area.X + 2, y, layout); } window.DrawRectangle (widget.Style.DarkGC (Gtk.StateType.Prelight), false, cell_area.X, recty, cell_area.Width - 1, recth); removedGC.Dispose (); addedGC.Dispose (); infoGC.Dispose (); } else { int y = cell_area.Y + (cell_area.Height - height) / 2; window.DrawLayout (widget.Style.TextGC (GetState (flags)), cell_area.X, y, layout); } } catch (Exception e) { Console.WriteLine (e); } }
protected override void Render(Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags) { if (isDisposed) { return; } try { if (diffMode) { int w, maxy; window.GetSize(out w, out maxy); int recty = cell_area.Y; int recth = cell_area.Height - 1; if (recty < 0) { recth += recty + 1; recty = -1; } if (recth > maxy + 2) { recth = maxy + 2; } window.DrawRectangle(widget.Style.BaseGC(Gtk.StateType.Normal), true, cell_area.X, recty, cell_area.Width - 1, recth); Gdk.GC normalGC = widget.Style.TextGC(StateType.Normal); Gdk.GC removedGC = new Gdk.GC(window); removedGC.Copy(normalGC); removedGC.RgbFgColor = new Color(255, 0, 0); Gdk.GC addedGC = new Gdk.GC(window); addedGC.Copy(normalGC); addedGC.RgbFgColor = new Color(0, 0, 255); Gdk.GC infoGC = new Gdk.GC(window); infoGC.Copy(normalGC); infoGC.RgbFgColor = new Color(0xa5, 0x2a, 0x2a); int y = cell_area.Y + 2; for (int n = 0; n < lines.Length; n++, y += lineHeight) { if (y + lineHeight < 0) { continue; } if (y > maxy) { break; } string line = lines[n]; if (line.Length == 0) { continue; } Gdk.GC gc; switch (line[0]) { case '-': gc = removedGC; break; case '+': gc = addedGC; break; case '@': gc = infoGC; break; default: gc = normalGC; break; } layout.SetText(line); window.DrawLayout(gc, cell_area.X + 2, y, layout); } window.DrawRectangle(widget.Style.DarkGC(Gtk.StateType.Prelight), false, cell_area.X, recty, cell_area.Width - 1, recth); removedGC.Dispose(); addedGC.Dispose(); infoGC.Dispose(); } else { int y = cell_area.Y + (cell_area.Height - height) / 2; window.DrawLayout(widget.Style.TextGC(GetState(flags)), cell_area.X, y, layout); } } catch (Exception e) { Console.WriteLine(e); } }
protected override void Render(Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags) { if (isDisposed) { return; } if (diffMode) { if (path.Equals(selctedPath)) { selectedLine = -1; selctedPath = null; } int w, maxy; window.GetSize(out w, out maxy); if (DrawLeft) { cell_area.Width += cell_area.X - leftSpace; cell_area.X = leftSpace; } var treeview = widget as FileTreeView; var p = treeview != null? treeview.CursorLocation : null; cell_area.Width -= RightPadding; window.DrawRectangle(widget.Style.BaseGC(Gtk.StateType.Normal), true, cell_area.X, cell_area.Y, cell_area.Width - 1, cell_area.Height); Gdk.GC normalGC = widget.Style.TextGC(StateType.Normal); Gdk.GC removedGC = new Gdk.GC(window); removedGC.Copy(normalGC); removedGC.RgbFgColor = Styles.LogView.DiffRemoveBackgroundColor.AddLight(-0.3).ToGdkColor(); Gdk.GC addedGC = new Gdk.GC(window); addedGC.Copy(normalGC); addedGC.RgbFgColor = Styles.LogView.DiffAddBackgroundColor.AddLight(-0.3).ToGdkColor(); Gdk.GC infoGC = new Gdk.GC(window); infoGC.Copy(normalGC); infoGC.RgbFgColor = widget.Style.Text(StateType.Normal).AddLight(0.2); Cairo.Context ctx = CairoHelper.Create(window); // Rendering is done in two steps: // 1) Get a list of blocks to render // 2) render the blocks int y = cell_area.Y + 2; // cline keeps track of the current source code line (the one to jump to when double clicking) int cline = 1; bool inHeader = true; BlockInfo currentBlock = null; List <BlockInfo> blocks = new List <BlockInfo> (); for (int n = 0; n < lines.Length; n++, y += lineHeight) { string line = lines [n]; if (line.Length == 0) { currentBlock = null; y -= lineHeight; continue; } char tag = line [0]; if (line.StartsWith("---", StringComparison.Ordinal) || line.StartsWith("+++", StringComparison.Ordinal)) { // Ignore this part of the header. currentBlock = null; y -= lineHeight; continue; } if (tag == '@') { int l = ParseCurrentLine(line); if (l != -1) { cline = l - 1; } inHeader = false; } else if (tag == '+' && !inHeader) { cline++; } BlockType type; switch (tag) { case '-': type = BlockType.Removed; break; case '+': type = BlockType.Added; break; case '@': type = BlockType.Info; break; default: type = BlockType.Unchanged; break; } if (currentBlock == null || type != currentBlock.Type) { if (y > maxy) { break; } // Starting a new block. Mark section ends between a change block and a normal code block if (currentBlock != null && IsChangeBlock(currentBlock.Type) && !IsChangeBlock(type)) { currentBlock.SectionEnd = true; } currentBlock = new BlockInfo() { YStart = y, FirstLine = n, Type = type, SourceLineStart = cline, SectionStart = (blocks.Count == 0 || !IsChangeBlock(blocks[blocks.Count - 1].Type)) && IsChangeBlock(type) }; blocks.Add(currentBlock); } // Include the line in the current block currentBlock.YEnd = y + lineHeight; currentBlock.LastLine = n; } // Now render the blocks // The y position of the highlighted line int selectedLineRowTop = -1; BlockInfo lastCodeSegmentStart = null; BlockInfo lastCodeSegmentEnd = null; foreach (BlockInfo block in blocks) { if (block.Type == BlockType.Info) { // Finished drawing the content of a code segment. Now draw the segment border and label. if (lastCodeSegmentStart != null) { DrawCodeSegmentBorder(infoGC, ctx, cell_area.X, cell_area.Width, lastCodeSegmentStart, lastCodeSegmentEnd, lines, widget, window); } lastCodeSegmentStart = block; } lastCodeSegmentEnd = block; if (block.YEnd < 0) { continue; } // Draw the block background DrawBlockBg(ctx, cell_area.X + 1, cell_area.Width - 2, block); // Get all text for the current block StringBuilder sb = new StringBuilder(); for (int n = block.FirstLine; n <= block.LastLine; n++) { string s = ProcessLine(lines [n]); if (n > block.FirstLine) { sb.Append('\n'); } if (block.Type != BlockType.Info && s.Length > 0) { sb.Append(s, 1, s.Length - 1); } else { sb.Append(s); } } // Draw a special background for the selected line if (block.Type != BlockType.Info && p.HasValue && p.Value.X >= cell_area.X && p.Value.X <= cell_area.Right && p.Value.Y >= block.YStart && p.Value.Y <= block.YEnd) { int row = (p.Value.Y - block.YStart) / lineHeight; double yrow = block.YStart + lineHeight * row; double xrow = cell_area.X + LeftPaddingBlock; int wrow = cell_area.Width - 1 - LeftPaddingBlock; if (block.Type == BlockType.Added) { ctx.SetSourceColor(Styles.LogView.DiffAddBackgroundColor.AddLight(0.1).ToCairoColor()); } else if (block.Type == BlockType.Removed) { ctx.SetSourceColor(Styles.LogView.DiffRemoveBackgroundColor.AddLight(0.1).ToCairoColor()); } else { ctx.SetSourceColor(Styles.LogView.DiffHighlightColor.ToCairoColor()); xrow -= LeftPaddingBlock; wrow += LeftPaddingBlock; } ctx.Rectangle(xrow, yrow, wrow, lineHeight); ctx.Fill(); selectedLine = block.SourceLineStart + row; selctedPath = path; selectedLineRowTop = (int)yrow; } // Draw the line text. Ignore header blocks, since they are drawn as labels in DrawCodeSegmentBorder if (block.Type != BlockType.Info) { layout.SetMarkup(""); layout.SetText(sb.ToString()); Gdk.GC gc; switch (block.Type) { case BlockType.Removed: gc = removedGC; break; case BlockType.Added: gc = addedGC; break; case BlockType.Info: gc = infoGC; break; default: gc = normalGC; break; } window.DrawLayout(gc, cell_area.X + 2 + LeftPaddingBlock, block.YStart, layout); } // Finally draw the change symbol at the left margin DrawChangeSymbol(ctx, widget, cell_area.X + 1, cell_area.Width - 2, block); } // Finish the drawing of the code segment if (lastCodeSegmentStart != null) { DrawCodeSegmentBorder(infoGC, ctx, cell_area.X, cell_area.Width, lastCodeSegmentStart, lastCodeSegmentEnd, lines, widget, window); } // Draw the source line number at the current selected line. It must be done at the end because it must // be drawn over the source code text and segment borders. if (selectedLineRowTop != -1) { DrawLineBox(normalGC, ctx, ((Gtk.TreeView)widget).VisibleRect.Right - 4, selectedLineRowTop, selectedLine, widget, window); } ((IDisposable)ctx).Dispose(); removedGC.Dispose(); addedGC.Dispose(); infoGC.Dispose(); } else { // Rendering a normal text row int y = cell_area.Y + (cell_area.Height - height) / 2; window.DrawLayout(widget.Style.TextGC(GetState(widget, flags)), cell_area.X, y, layout); } }
protected override bool OnExposeEvent (Gdk.EventExpose args) { Gdk.Window window = args.Window; var alloc = Allocation; int width = alloc.Width; int height = alloc.Height; int lineWidth = width - margin * 2; int xpos = margin + padding; int yPos = margin; if (PreviewCompletionString) { layout.SetText ( string.IsNullOrEmpty (CompletionString) ? MonoDevelop.Core.GettextCatalog.GetString ("Select template") : CompletionString ); int wi, he; layout.GetPixelSize (out wi, out he); window.DrawRectangle (this.Style.BaseGC (StateType.Insensitive), true, margin, yPos, lineWidth, he + padding); window.DrawLayout ( string.IsNullOrEmpty (CompletionString) ? this.Style.TextGC (StateType.Insensitive) : this.Style.TextGC (StateType.Normal), xpos, yPos, layout ); yPos += rowHeight; } //when there are no matches, display a message to indicate that the completion list is still handling input if (filteredItems.Count == 0) { Gdk.GC gc = new Gdk.GC (window); gc.RgbFgColor = new Gdk.Color (0xff, 0xbc, 0xc1); window.DrawRectangle (gc, true, 0, yPos, width, height - yPos); layout.SetText (win.DataProvider.ItemCount == 0 ? NoSuggestionsMsg : NoMatchesMsg); int lWidth, lHeight; layout.GetPixelSize (out lWidth, out lHeight); gc.RgbFgColor = new Gdk.Color (0, 0, 0); window.DrawLayout (gc, (width - lWidth) / 2, yPos + (height - lHeight - yPos) / 2, layout); gc.Dispose (); return true; } var textGCInsensitive = this.Style.TextGC (StateType.Insensitive); var textGCNormal = this.Style.TextGC (StateType.Normal); var fgGCNormal = this.Style.ForegroundGC (StateType.Normal); var matcher = CompletionMatcher.CreateCompletionMatcher (CompletionString); var highlightColor = HighlightColor; Iterate (true, ref yPos, delegate (Category category, int ypos) { if (ypos >= height - margin) return; // window.DrawRectangle (this.Style.BackgroundGC (StateType.Insensitive), true, 0, yPos, width, rowHeight); int x = 2; if (!string.IsNullOrEmpty (category.CompletionCategory.Icon)) { var icon = ImageService.GetPixbuf (category.CompletionCategory.Icon, IconSize.Menu); window.DrawPixbuf (fgGCNormal, icon, 0, 0, margin, ypos, icon.Width, icon.Height, Gdk.RgbDither.None, 0, 0); x = icon.Width + 4; } layout.SetMarkup ("<span weight='bold'>" + category.CompletionCategory.DisplayText + "</span>"); window.DrawLayout (textGCInsensitive, x, ypos, layout); layout.SetMarkup (""); }, delegate (Category curCategory, int item, int itemidx, int ypos) { if (ypos >= height - margin) return false; if (InCategoryMode && curCategory != null && curCategory.CompletionCategory != null) { xpos = margin + padding + 8; } else { xpos = margin + padding; } string markup = win.DataProvider.HasMarkup (item) ? (win.DataProvider.GetMarkup (item) ?? "<null>") : GLib.Markup.EscapeText (win.DataProvider.GetText (item) ?? "<null>"); string description = win.DataProvider.GetDescription (item); if (string.IsNullOrEmpty (description)) { layout.SetMarkup (markup); } else { if (item == SelectedItem) { layout.SetMarkup (markup + " " + description ); } else { layout.SetMarkup (markup + " <span foreground=\"darkgray\">" + description + "</span>"); } } int mw, mh; layout.GetPixelSize (out mw, out mh); if (mw > listWidth) { WidthRequest = listWidth = mw; win.WidthRequest = win.Allocation.Width + mw - width; win.QueueResize (); } string text = win.DataProvider.GetText (item); if ((!SelectionEnabled || item != SelectedItem) && !string.IsNullOrEmpty (text)) { int[] matchIndices = matcher.GetMatch (text); if (matchIndices != null) { Pango.AttrList attrList = layout.Attributes ?? new Pango.AttrList (); for (int newSelection = 0; newSelection < matchIndices.Length; newSelection++) { int idx = matchIndices[newSelection]; Pango.AttrForeground fg = new Pango.AttrForeground (highlightColor.Red, highlightColor.Green, highlightColor.Blue); fg.StartIndex = (uint)idx; fg.EndIndex = (uint)(idx + 1); attrList.Insert (fg); } layout.Attributes = attrList; } } Gdk.Pixbuf icon = win.DataProvider.GetIcon (item); int iconHeight, iconWidth; if (icon != null) { iconWidth = icon.Width; iconHeight = icon.Height; } else if (!Gtk.Icon.SizeLookup (Gtk.IconSize.Menu, out iconWidth, out iconHeight)) { iconHeight = iconWidth = 24; } int wi, he, typos, iypos; layout.GetPixelSize (out wi, out he); typos = he < rowHeight ? ypos + (rowHeight - he) / 2 : ypos; iypos = iconHeight < rowHeight ? ypos + (rowHeight - iconHeight) / 2 : ypos; if (item == SelectedItem) { if (SelectionEnabled) { window.DrawRectangle (this.Style.BaseGC (StateType.Selected), true, margin, ypos, lineWidth, he + padding); window.DrawLayout (this.Style.TextGC (StateType.Selected), xpos + iconWidth + 2, typos, layout); } else { window.DrawRectangle (this.Style.DarkGC (StateType.Prelight), false, margin, ypos, lineWidth - 1, he + padding - 1); window.DrawLayout (textGCNormal, xpos + iconWidth + 2, typos, layout); } } else window.DrawLayout (textGCNormal, xpos + iconWidth + 2, typos, layout); if (icon != null) window.DrawPixbuf (fgGCNormal, icon, 0, 0, xpos, iypos, iconWidth, iconHeight, Gdk.RgbDither.None, 0, 0); layout.SetMarkup (""); if (layout.Attributes != null) { layout.Attributes.Dispose (); layout.Attributes = null; } return true; }); /* int n = 0; while (ypos < winHeight - margin && (page + n) < filteredItems.Count) { bool hasMarkup = win.DataProvider.HasMarkup (filteredItems[page + n]); if (hasMarkup) { layout.SetMarkup (win.DataProvider.GetMarkup (filteredItems[page + n]) ?? "<null>"); } else { layout.SetText (win.DataProvider.GetText (filteredItems[page + n]) ?? "<null>"); } string text = win.DataProvider.GetText (filteredItems[page + n]); if ((!SelectionEnabled || page + n != selection) && !string.IsNullOrEmpty (text)) { int[] matchIndices = Match (CompletionString, text); if (matchIndices != null) { Pango.AttrList attrList = layout.Attributes ?? new Pango.AttrList (); for (int newSelection = 0; newSelection < matchIndices.Length; newSelection++) { int idx = matchIndices[newSelection]; Pango.AttrForeground fg = new Pango.AttrForeground (0, 0, ushort.MaxValue); fg.StartIndex = (uint)idx; fg.EndIndex = (uint)(idx + 1); attrList.Insert (fg); } layout.Attributes = attrList; } } Gdk.Pixbuf icon = win.DataProvider.GetIcon (filteredItems[page + n]); int iconHeight, iconWidth; if (icon != null) { iconWidth = icon.Width; iconHeight = icon.Height; } else if (!Gtk.Icon.SizeLookup (Gtk.IconSize.Menu, out iconWidth, out iconHeight)) { iconHeight = iconWidth = 24; } int wi, he, typos, iypos; layout.GetPixelSize (out wi, out he); typos = he < rowHeight ? ypos + (rowHeight - he) / 2 : ypos; iypos = iconHeight < rowHeight ? ypos + (rowHeight - iconHeight) / 2 : ypos; if (page + n == selection) { if (SelectionEnabled) { window.DrawRectangle (this.Style.BaseGC (StateType.Selected), true, margin, ypos, lineWidth, he + padding); window.DrawLayout (this.Style.TextGC (StateType.Selected), xpos + iconWidth + 2, typos, layout); } else { window.DrawRectangle (this.Style.DarkGC (StateType.Prelight), false, margin, ypos, lineWidth - 1, he + padding - 1); window.DrawLayout (this.Style.TextGC (StateType.Normal), xpos + iconWidth + 2, typos, layout); } } else window.DrawLayout (this.Style.TextGC (StateType.Normal), xpos + iconWidth + 2, typos, layout); if (icon != null) window.DrawPixbuf (this.Style.ForegroundGC (StateType.Normal), icon, 0, 0, xpos, iypos, iconWidth, iconHeight, Gdk.RgbDither.None, 0, 0); ypos += rowHeight; n++; if (hasMarkup) layout.SetMarkup (string.Empty); if (layout.Attributes != null) { layout.Attributes.Dispose (); layout.Attributes = null; } } */ return true; }
protected override bool OnExposeEvent(EventExpose evnt) { var baseResult = base.OnExposeEvent(evnt); if (Source == null && TrackerCore.Instance.TaskManager is EmptyTaskManager) { return(baseResult); } Source = ((IGanttSource)this).StaticSource ?? TrackerCore.Instance.TaskManager.GanttSource; //ReadGepmetry int fX, fY, fWidth, fHeight, fDepth; GdkWindow.GetGeometry(out fX, out fY, out fWidth, out fHeight, out fDepth); fWidth -= 3; fHeight -= 3; // Insert drawing code here. if (grw == null) { grw = Gdk.CairoHelper.Create(GdkWindow); } //DrawBorder grw.SetSourceRGB(0xff, 0, 0); grw.MoveTo(FBorderMarginH, FBorderMarginV); grw.LineTo(fWidth - FBorderMarginH, FBorderMarginV); grw.LineTo(fWidth - FBorderMarginH, fHeight - FBorderMarginV); grw.LineTo(FBorderMarginH, fHeight - FBorderMarginV); grw.LineTo(FBorderMarginH, FBorderMarginV); grw.Stroke(); //DrawTasks var deltaActor = (Source.Tables["Actor"].Rows.Count > 0) ? (fHeight - 2 * FBorderMarginV) / Source.Tables["Actor"].Rows.Count : fHeight - 2 * FBorderMarginV; var v1 = Source.Tables["DataRange"].Rows[0]["MinDate"]; var v2 = Source.Tables["DataRange"].Rows[0]["MaxDate"]; var firstDate = v1 as DateTime? ?? DateTime.Now; var lastDate = v2 as DateTime? ?? DateTime.Now; var deltaSpan = lastDate.Date.Subtract(firstDate.Date); var deltaTask = fWidth; if (deltaSpan.Days > 1) { deltaTask = fWidth / deltaSpan.Days; } var columns = (lastDate - firstDate).Days + 1; var filled = new bool[columns, 100]; var passedState = ConfigurationManager.AppSettings["passed_state"]; var stateColors = new Dictionary <int, Gdk.Color>(); var statePresence = new Dictionary <int, Dictionary <int, int> >(); foreach (DataRow row in Source.Tables["Task"].Rows) { v1 = row["ActorID"]; if ((v1 as int? ?? -1) < 0) { continue; } var actorIndex = Source.Tables["Actor"].Rows.Cast <DataRow>().TakeWhile(actorRow => (int)actorRow["ID"] != (int)row["ActorID"]).Count(); v1 = row["StartTime"]; v2 = row["EndTime"]; var startTime = v1 as DateTime? ?? DateTime.Now; var endTime = v2 as DateTime? ?? DateTime.Now; var startSpan = startTime.Subtract(firstDate); var endSpan = endTime.Subtract(firstDate); // fill availability matrix if (taskGc == null) { taskGc = new Gdk.GC(GdkWindow); } int stateId = (int)row["StateID"]; if (Source.Tables["TaskState"].Select("ID = " + stateId).Length == 0) { throw new KeyNotFoundException <object>(row["StateID"]); } var list = Source.Tables["TaskState"].Select("ID = " + row["StateID"]); if (list.Length > 0) { var stateRow = list[0]; var stateName = (string)stateRow["Name"]; if (passedState.Split(';').Select(s => s.ToLower()).Contains(stateName.ToLower())) { continue; } try { var colorRed = Convert.ToByte(stateRow["ColorRed"]); var colorGreen = Convert.ToByte(stateRow["ColorGreen"]); var colorBlue = Convert.ToByte(stateRow["ColorBlue"]); if (!stateColors.ContainsKey(stateId)) { var foregroundColor = new Gdk.Color(colorRed, colorGreen, colorBlue); stateColors.Add(stateId, foregroundColor); } } catch (Exception e) { Console.WriteLine(e); } } int offset; if (lastDate.Date > endTime.Date) { offset = startSpan.Days * deltaTask + FBorderMarginH; } else if (startTime.Date < lastDate.Date) { offset = startSpan.Days * deltaTask + FBorderMarginH; } else { offset = (startSpan.Days - 1) * deltaTask + FBorderMarginH; } if (!statePresence.ContainsKey(offset)) { statePresence.Add(offset, new Dictionary <int, int>()); } if (!statePresence[offset].ContainsKey(stateId)) { statePresence[offset].Add(stateId, 1); } else { statePresence[offset][stateId]++; } } //TODO: for now the diagram was disabled because it not represent any gantt presentation itself //draw tasks foreach (DataRow row in Source.Tables["Task"].Rows) { v1 = row["ActorID"]; if ((v1 as int? ?? -1) < 0) { continue; } var actorIndex = Source.Tables["Actor"].Rows.Cast <DataRow>().TakeWhile(actorRow => (int)actorRow["ID"] != (int)row["ActorID"]).Count(); v1 = row["StartTime"]; v2 = row["EndTime"]; var startTime = v1 as DateTime? ?? DateTime.Now; var endTime = v2 as DateTime? ?? DateTime.Now; var startSpan = startTime.Subtract(firstDate); var endSpan = endTime.Subtract(firstDate); if (taskGc == null) { taskGc = new Gdk.GC(GdkWindow); } int stateId = (int)row["StateID"]; var foregroundColor = stateColors[stateId]; var colormap = Colormap.System; colormap.AllocColor(ref foregroundColor, true, true); taskGc.Foreground = foregroundColor; colormap.Dispose(); int offset; if (lastDate.Date > endTime.Date) { offset = startSpan.Days * deltaTask + FBorderMarginH; if (statePresence.ContainsKey(offset) && statePresence[offset].ContainsKey(stateId) && statePresence[offset][stateId] > 0) { int sum = 0; int start = 0; bool found = false; foreach (var s in statePresence[offset].Keys) { sum += Math.Abs(statePresence[offset][s]); } foreach (var s in statePresence[offset].Keys) { found = s == stateId; if (!found) { start += deltaActor * (Math.Abs(statePresence[offset][stateId]) - 1) / sum; } else { break; } } GdkWindow.DrawRectangle( taskGc, true, startSpan.Days * deltaTask + FBorderMarginH, actorIndex * deltaActor + start, deltaTask, deltaActor * (statePresence[offset][stateId]) / sum); } } else if (startTime.Date < lastDate.Date) { offset = startSpan.Days * deltaTask + FBorderMarginH; if (statePresence.ContainsKey(offset) && statePresence[offset].ContainsKey(stateId) && statePresence[offset][stateId] > 0) { int sum = 0; int start = 0; bool found = false; foreach (var s in statePresence[offset].Keys) { sum += Math.Abs(statePresence[offset][s]); } foreach (var s in statePresence[offset].Keys) { found = s == stateId; if (!found) { start += deltaActor * (Math.Abs(statePresence[offset][stateId]) - 1) / sum; } else { break; } } GdkWindow.DrawRectangle( taskGc, true, startSpan.Days * deltaTask + FBorderMarginH, actorIndex * deltaActor + FBorderMarginV + start, deltaTask + FBorderMarginH, deltaActor * (statePresence[offset][stateId]) / sum); } } else { offset = (startSpan.Days - 1) * deltaTask + FBorderMarginH; if (statePresence.ContainsKey(offset) && statePresence[offset].ContainsKey(stateId) && statePresence[offset][stateId] > 0) { int sum = 0; int start = 0; bool found = false; foreach (var s in statePresence[offset].Keys) { sum += Math.Abs(statePresence[offset][s]); } foreach (var s in statePresence[offset].Keys) { found = s == stateId; if (!found) { start += deltaActor * (Math.Abs(statePresence[offset][stateId]) - 1) / sum; } else { break; } } GdkWindow.DrawRectangle( taskGc, true, (startSpan.Days - 1) * deltaTask + FBorderMarginH, actorIndex * deltaActor + FBorderMarginV + start, deltaTask + FBorderMarginH, deltaActor * (statePresence[offset][stateId]) / sum); } } statePresence[offset][stateId] = -Math.Abs(statePresence[offset][stateId]); GdkPalette.DestroyColor(); } //DrawActorAxis //TODO: reuse gc var taskLabelGc = new Gdk.GC(GdkWindow); if (!((IGanttSource)this).DateNowVisible) { return(true); } //DrawActorAxis var offsetActor = FBorderMarginV; var foregroundColor2 = new Gdk.Color(0xff, 0, 0); var foregroundColor1 = new Gdk.Color(0, 0, 0xff); //TODO: reuse gc var actorLabelGc = new Gdk.GC(GdkWindow); //TODO: reuse gc var axisGc = new Gdk.GC(GdkWindow); Colormap.System.AllocColor(ref foregroundColor2, true, true); taskLabelGc.Foreground = foregroundColor2; axisGc.Foreground = foregroundColor1; foreach (DataRow row in Source.Tables["Actor"].Rows) { var layout = new Layout(PangoContext) { Wrap = WrapMode.Word, FontDescription = FontDescription.FromString("Tahoma 10") }; v1 = row["Name"]; layout.SetMarkup(v1?.ToString() ?? "<unknown>"); GdkWindow.DrawLayout(actorLabelGc, FBorderMarginH, offsetActor - FBorderMarginV, layout); GdkWindow.DrawLine(axisGc, FBorderMarginH, offsetActor, fWidth - FBorderMarginH, offsetActor); offsetActor += deltaActor; } axisGc.Dispose(); actorLabelGc.Dispose(); //DrawDateNow var nowSpan = DateTime.Now.Subtract(firstDate); var offsetDate = FBorderMarginH + (int)(deltaTask * (double)nowSpan.Ticks / TimeSpan.TicksPerDay); grw.SetSourceRGB(0, 0, 0); grw.MoveTo(offsetDate, FBorderMarginV); grw.LineTo(offsetDate, fHeight - FBorderMarginV); grw.RelLineTo(new Distance { Dx = -3, Dy = 0 }); grw.RelLineTo(new Distance { Dx = 3, Dy = -3 }); grw.RelLineTo(new Distance { Dx = 3, Dy = 3 }); grw.RelLineTo(new Distance { Dx = -3, Dy = 0 }); grw.Stroke(); return(true); }
protected override void Render (Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags) { if (isDisposed) return; if (diffMode) { if (path.Equals (selctedPath)) { selectedLine = -1; selctedPath = null; } int w, maxy; window.GetSize (out w, out maxy); if (DrawLeft) { cell_area.Width += cell_area.X - leftSpace; cell_area.X = leftSpace; } var treeview = widget as FileTreeView; var p = treeview != null? treeview.CursorLocation : null; cell_area.Width -= RightPadding; window.DrawRectangle (widget.Style.BaseGC (Gtk.StateType.Normal), true, cell_area.X, cell_area.Y, cell_area.Width - 1, cell_area.Height); Gdk.GC normalGC = widget.Style.TextGC (StateType.Normal); Gdk.GC removedGC = new Gdk.GC (window); removedGC.Copy (normalGC); removedGC.RgbFgColor = baseRemoveColor.AddLight (-0.3); Gdk.GC addedGC = new Gdk.GC (window); addedGC.Copy (normalGC); addedGC.RgbFgColor = baseAddColor.AddLight (-0.3); Gdk.GC infoGC = new Gdk.GC (window); infoGC.Copy (normalGC); infoGC.RgbFgColor = widget.Style.Text (StateType.Normal).AddLight (0.2); Cairo.Context ctx = CairoHelper.Create (window); Gdk.Color bgColor = new Gdk.Color (0,0,0); // Rendering is done in two steps: // 1) Get a list of blocks to render // 2) render the blocks int y = cell_area.Y + 2; // cline keeps track of the current source code line (the one to jump to when double clicking) int cline = 1; bool inHeader = true; BlockInfo currentBlock = null; List<BlockInfo> blocks = new List<BlockInfo> (); for (int n=0; n<lines.Length; n++, y += lineHeight) { string line = lines [n]; if (line.Length == 0) { currentBlock = null; y -= lineHeight; continue; } char tag = line [0]; if (line.StartsWith ("---") || line.StartsWith ("+++")) { // Ignore this part of the header. currentBlock = null; y -= lineHeight; continue; } if (tag == '@') { int l = ParseCurrentLine (line); if (l != -1) cline = l - 1; inHeader = false; } else if (tag != '-' && !inHeader) cline++; BlockType type; bool hasBg = false; switch (tag) { case '-': type = BlockType.Removed; break; case '+': type = BlockType.Added; break; case '@': type = BlockType.Info; break; default: type = BlockType.Unchanged; break; } if (currentBlock == null || type != currentBlock.Type) { if (y > maxy) break; // Starting a new block. Mark section ends between a change block and a normal code block if (currentBlock != null && IsChangeBlock (currentBlock.Type) && !IsChangeBlock (type)) currentBlock.SectionEnd = true; currentBlock = new BlockInfo () { YStart = y, FirstLine = n, Type = type, SourceLineStart = cline, SectionStart = (blocks.Count == 0 || !IsChangeBlock (blocks[blocks.Count - 1].Type)) && IsChangeBlock (type) }; blocks.Add (currentBlock); } // Include the line in the current block currentBlock.YEnd = y + lineHeight; currentBlock.LastLine = n; } // Now render the blocks // The y position of the highlighted line int selectedLineRowTop = -1; BlockInfo lastCodeSegmentStart = null; BlockInfo lastCodeSegmentEnd = null; foreach (BlockInfo block in blocks) { if (block.Type == BlockType.Info) { // Finished drawing the content of a code segment. Now draw the segment border and label. if (lastCodeSegmentStart != null) DrawCodeSegmentBorder (infoGC, ctx, cell_area.X, cell_area.Width, lastCodeSegmentStart, lastCodeSegmentEnd, lines, widget, window); lastCodeSegmentStart = block; } lastCodeSegmentEnd = block; if (block.YEnd < 0) continue; // Draw the block background DrawBlockBg (ctx, cell_area.X + 1, cell_area.Width - 2, block); // Get all text for the current block StringBuilder sb = new StringBuilder (); for (int n=block.FirstLine; n <= block.LastLine; n++) { string s = ProcessLine (lines [n]); if (sb.Length > 0) sb.Append ('\n'); if (block.Type != BlockType.Info && s.Length > 0) sb.Append (s, 1, s.Length - 1); else sb.Append (s); } // Draw a special background for the selected line if (block.Type != BlockType.Info && p.HasValue && p.Value.X >= cell_area.X && p.Value.X <= cell_area.Right && p.Value.Y >= block.YStart && p.Value.Y <= block.YEnd) { int row = (p.Value.Y - block.YStart) / lineHeight; double yrow = block.YStart + lineHeight * row + 0.5; double xrow = cell_area.X + LeftPaddingBlock + 0.5; int wrow = cell_area.Width - 1 - LeftPaddingBlock; if (block.Type == BlockType.Added) ctx.Color = baseAddColor.AddLight (0.1).ToCairoColor (); else if (block.Type == BlockType.Removed) ctx.Color = baseRemoveColor.AddLight (0.1).ToCairoColor (); else { ctx.Color = widget.Style.Base (Gtk.StateType.Prelight).AddLight (0.1).ToCairoColor (); xrow -= LeftPaddingBlock; wrow += LeftPaddingBlock; } ctx.Rectangle (xrow, yrow, wrow, lineHeight); ctx.Fill (); selectedLine = block.SourceLineStart + row; selctedPath = path; selectedLineRowTop = (int)yrow; } // Draw the line text. Ignore header blocks, since they are drawn as labels in DrawCodeSegmentBorder if (block.Type != BlockType.Info) { layout.SetMarkup (""); layout.SetText (sb.ToString ()); Gdk.GC gc; switch (block.Type) { case BlockType.Removed: gc = removedGC; break; case BlockType.Added: gc = addedGC; break; case BlockType.Info: gc = infoGC; break; default: gc = normalGC; break; } window.DrawLayout (gc, cell_area.X + 2 + LeftPaddingBlock, block.YStart, layout); } // Finally draw the change symbol at the left margin DrawChangeSymbol (ctx, cell_area.X + 1, cell_area.Width - 2, block); } // Finish the drawing of the code segment if (lastCodeSegmentStart != null) DrawCodeSegmentBorder (infoGC, ctx, cell_area.X, cell_area.Width, lastCodeSegmentStart, lastCodeSegmentEnd, lines, widget, window); // Draw the source line number at the current selected line. It must be done at the end because it must // be drawn over the source code text and segment borders. if (selectedLineRowTop != -1) DrawLineBox (normalGC, ctx, ((Gtk.TreeView)widget).VisibleRect.Right - 4, selectedLineRowTop, selectedLine, widget, window); ((IDisposable)ctx).Dispose (); removedGC.Dispose (); addedGC.Dispose (); infoGC.Dispose (); } else { // Rendering a normal text row int y = cell_area.Y + (cell_area.Height - height)/2; window.DrawLayout (widget.Style.TextGC (GetState(flags)), cell_area.X, y, layout); } }
protected void OnDrawWiFiExposeEvent (object o, ExposeEventArgs args) { Gdk.Color back = drawWiFi.Style.Background(StateType.Normal); Gdk.Color fore = drawWiFi.Style.Foreground(StateType.Normal); Drawable draw = drawWiFi.GdkWindow; Gdk.GC gc = new Gdk.GC(draw); try { gc.Foreground = back; gc.Background = back; int width; int height; draw.GetSize(out width, out height); draw.DrawRectangle(gc, true, 0, 0, width, height); gc.Foreground = fore; lastNoise = recognizer.Noise; lastRecognized = recognizer.TimeRecognized.ToShortTimeString() + ": " + recognizer.KeywordRecognized; lastBuffer = recognizer.BufferSize; lastStatus = status; String text = "IP: " + ipAddress + "\n" + "Status: " + lastStatus + "\n" + "Recognized: " + lastRecognized + "\n" + "Buffer: " + lastBuffer + "\n" + "Noise: " + lastNoise + "\n" + "Active Alarm: " + activeAlarm + "\n" + "Next Alarm: " + nextAlarm + "\n"; if (activeConnection == null) { text += "WiFi: Not connected\n"; } else { text += "WiFi: " + activeConnection.ESSID + "\n"; text += "BSSID: " + activeConnection.BSSID + "\n"; text += "Channel: " + activeConnection.Channel + "\n"; text += "Signal: " + activeConnection.Signal + "\n"; text += "Encryption: " + activeConnection.Encryption + "\n"; } Pango.FontDescription font = Pango.FontDescription.FromString("Serif 10"); Pango.Layout layout = drawWiFi.CreatePangoLayout(text); layout.FontDescription = font; layout.Width = Pango.Units.FromPixels(width); draw.DrawLayoutWithColors(gc, 0, 0, layout, fore, back); layout.Dispose(); } catch (Exception ex) { Console.WriteLine(ex.Source); Console.WriteLine(ex.StackTrace); } gc.Dispose(); }
protected void OnCtlDrawingMetaExposeEvent (object o, ExposeEventArgs args) { Gdk.Color back = ctlDrawingMeta.Style.Background(StateType.Normal); Gdk.Color fore = ctlDrawingMeta.Style.Foreground(StateType.Normal); Drawable draw = ctlDrawingMeta.GdkWindow; Gdk.GC gc = new Gdk.GC(draw); try { gc.Foreground = back; gc.Background = back; int width; int height; draw.GetSize(out width, out height); draw.DrawRectangle(gc, true, 0, 0, width, height); gc.Foreground = fore; String stationName = "No station"; if (station != null) { stationName = station.CallLetters + "\n" + station.Location; } String text = stationName + "\n" + artist + "\n" + song; Pango.FontDescription font = Pango.FontDescription.FromString("Serif 14"); Pango.Layout layout = ctlDrawingMeta.CreatePangoLayout(text); layout.FontDescription = font; layout.Width = Pango.Units.FromPixels(width); draw.DrawLayoutWithColors(gc, 0, 0, layout, fore, back); layout.Dispose(); } catch (Exception ex) { Console.WriteLine(ex.Source); Console.WriteLine(ex.StackTrace); } gc.Dispose(); }
protected override void Render(Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags) { if (isDisposed) { return; } if (diffMode) { if (path.Equals(selctedPath)) { selectedLine = -1; selctedPath = null; } int w, maxy; window.GetSize(out w, out maxy); var treeview = widget as FileTreeView; var p = treeview != null? treeview.CursorLocation : null; int recty = cell_area.Y; int recth = cell_area.Height - 1; if (recty < 0) { recth += recty + 1; recty = -1; } if (recth > maxy + 2) { recth = maxy + 2; } window.DrawRectangle(widget.Style.BaseGC(Gtk.StateType.Normal), true, cell_area.X, recty, cell_area.Width - 1, recth); Gdk.GC normalGC = widget.Style.TextGC(StateType.Normal); Gdk.GC removedGC = new Gdk.GC(window); removedGC.Copy(normalGC); removedGC.RgbFgColor = new Color(255, 0, 0); Gdk.GC addedGC = new Gdk.GC(window); addedGC.Copy(normalGC); addedGC.RgbFgColor = new Color(0, 0, 255); Gdk.GC infoGC = new Gdk.GC(window); infoGC.Copy(normalGC); infoGC.RgbFgColor = new Color(0xa5, 0x2a, 0x2a); int y = cell_area.Y + 2; int cline = 1; bool inHeader = true; for (int n = 0; n < lines.Length; n++, y += lineHeight) { string line = lines [n]; if (line.Length == 0) { continue; } char tag = line [0]; // Keep track of the real file line int thisLine = cline; if (tag == '@') { int l = ParseCurrentLine(line); if (l != -1) { cline = thisLine = l; } inHeader = false; } else if (tag != '-' && !inHeader) { cline++; } if (y + lineHeight < 0) { continue; } if (y > maxy) { break; } Gdk.GC gc; switch (tag) { case '-': gc = removedGC; break; case '+': gc = addedGC; break; case '@': gc = infoGC; break; default: gc = normalGC; break; } if (p.HasValue && p.Value.X >= cell_area.X && p.Value.X <= cell_area.Right && p.Value.Y >= y && p.Value.Y < y + lineHeight) { window.DrawRectangle(widget.Style.BaseGC(Gtk.StateType.Prelight), true, cell_area.X, y, cell_area.Width - 1, lineHeight); selectedLine = thisLine; selctedPath = path; } layout.SetText(line); window.DrawLayout(gc, cell_area.X + 2, y, layout); } window.DrawRectangle(widget.Style.DarkGC(Gtk.StateType.Prelight), false, cell_area.X, recty, cell_area.Width - 1, recth); removedGC.Dispose(); addedGC.Dispose(); infoGC.Dispose(); } else { int y = cell_area.Y + (cell_area.Height - height) / 2; window.DrawLayout(widget.Style.TextGC(GetState(flags)), cell_area.X, y, layout); } }