void ExposeHandler(object obj, ExposeEventArgs args) { int max_steps = 25; int displ; Gdk.Window win = args.Event.Window; Gdk.Rectangle area = args.Event.Area; win.DrawRectangle(Style.BaseGC(StateType.Normal), true, area); for (int y = 0, row = top_displayed; y < area.Y + area.Height; y += line_height, row++) { Gdk.GC gc; Gdk.Rectangle region_area = new Gdk.Rectangle(0, y, Allocation.Width, line_height); StateType state = StateType.Normal; if (sel_rows.Contains(row)) { if (HasFocus) { state = StateType.Selected; } else { state = StateType.Active; } win.DrawRectangle(Style.BaseGC(state), true, region_area); } //FIXME: we have a ghost row at the end of the list! if (row >= provider.Rows) { return; } string text = ""; if (ellipses[row] == null) { text = provider.GetValue(row); } else { text = (string)ellipses[row]; } displ = (int)((max_steps / HAdjustment.Upper) * HAdjustment.Value); text = ELabel.Ellipsize(layout, text, Allocation.Width - 2 * 2, ellipsis_width, en_width, displ); layout.SetText(text); gc = Style.TextGC(state); win.DrawLayout(gc, 2, y, layout); } args.RetVal = true; }
public override void Clear(Color c) { Gdk.GC g = new Gdk.GC(window); g.RgbFgColor = GdkColor(c); g.RgbBgColor = GdkColor(c); int Width; int Height; window.GetSize(out Width, out Height); window.DrawRectangle(g, true, 0, 0, Width, Height); }
protected override bool OnExposeEvent(Gdk.EventExpose args) { Gdk.Window win = GdkWindow; Gdk.GC g = new Gdk.GC(win); g.RgbFgColor = color; win.DrawRectangle(g, true, Allocation.X + margin, Allocation.Y + margin, Allocation.Width - margin * 2, Allocation.Height - margin * 2); if (Active || State == StateType.Active) { g.RgbFgColor = boxColor; win.DrawRectangle(g, false, Allocation.X + 1, Allocation.Y + 1, Allocation.Width - 3, Allocation.Height - 3); } PropagateExpose(Child, args); return(false); }
// Expose callback for the drawing area private void ExposeEventCallback(object o, ExposeEventArgs args) { EventExpose eventExpose = args.Event; Gdk.Window window = eventExpose.Window; Rectangle area = eventExpose.Area; window.DrawRectangle(drawingArea.Style.BackgroundGC(StateType.Normal), true, area.X, area.Y, area.Width, area.Height); args.RetVal = true; }
private void DrawSelectionRect(Gtk.Widget widget, Gdk.Window window) { Gdk.GC gc = (widget.Style.WhiteGC); gc.SetLineAttributes(1, LineStyle.OnOffDash, CapStyle.Butt, JoinStyle.Miter); gc.Function = Function.Xor; _selectionRect.Normalize(); RectangleD r = _selectionRect; PointD p = View.DrawingToView(r.X, r.Y); window.DrawRectangle(gc, false, (int)p.X, (int)p.Y, (int)(r.Width * View.Scale), (int)(r.Height * View.Scale)); }
public static void Draw(Window window, Gdk.GC gc, int units, int width, int height) { var darkColor = new Gdk.Color(50, 50, 50); var brightColor = new Gdk.Color(100, 100, 100); int nw = width / units; int nh = height / units; for (int i = 0; i <= nw; i++) { for (int j = 0; j <= nh; j++) { bool dark = ((i + j) % 2) == 0; if (dark) gc.RgbFgColor = darkColor; else gc.RgbFgColor = brightColor; window.DrawRectangle(gc, true, units * i, units * j, units, units); } } }
protected override bool OnExposeEvent(EventExpose evnt) { Gdk.Window win = evnt.Window; win.DrawRectangle(Style.BaseGC(string.IsNullOrEmpty(Markup) ? StateType.Insensitive : StateType.Normal), true, evnt.Area); int x = 0; int y = 0; if (string.IsNullOrEmpty(Markup)) { layout.SetMarkup(GettextCatalog.GetString("No documentation available.")); int width, height; layout.GetPixelSize(out width, out height); x = (Allocation.Width - width) / 2; y = (Allocation.Height - height) / 2; } else { layout.SetMarkup(Markup); } layout.Width = Allocation.Width * (int)Pango.Scale.PangoScale; win.DrawLayout(Style.TextGC(StateType.Normal), x, y, layout); return(true); }
protected override bool OnExposeEvent(Gdk.EventExpose args) { Gdk.Window win = GdkWindow; int rwidth, rheight; Cairo.Context ctx = CairoHelper.Create(win); win.GetSize(out rwidth, out rheight); if (autoStartY || autoEndY) { double nstartY = double.MaxValue; double nendY = double.MinValue; GetValueRange(AxisDimension.Y, out nstartY, out nendY); if (!autoStartY) { nstartY = startY; } if (!autoEndY) { nendY = endY; } if (nendY < nstartY) { nendY = nstartY; } if (nstartY != startY || nendY != endY) { yrangeChanged = true; startY = nstartY; endY = nendY; } } if (autoStartX || autoEndX) { double nstartX = double.MaxValue; double nendX = double.MinValue; GetValueRange(AxisDimension.X, out nstartX, out nendX); if (!autoStartX) { nstartX = startX; } if (!autoEndX) { nendX = endX; } if (nendX < nstartX) { nendX = nstartX; } if (nstartX != startX || nendX != endX) { xrangeChanged = true; startX = nstartX; endX = nendX; } } if (yrangeChanged) { FixOrigins(); int right = rwidth - 2 - AreaBorderWidth; left = AreaBorderWidth; left += MeasureAxisSize(AxisPosition.Left) + 1; right -= MeasureAxisSize(AxisPosition.Right) + 1; yrangeChanged = false; width = right - left + 1; if (width <= 0) { width = 1; } } if (xrangeChanged) { FixOrigins(); int bottom = rheight - 2 - AreaBorderWidth; top = AreaBorderWidth; bottom -= MeasureAxisSize(AxisPosition.Bottom); top += MeasureAxisSize(AxisPosition.Top); // Make room for cursor handles foreach (ChartCursor cursor in cursors) { if (cursor.Dimension == AxisDimension.X && top - AreaBorderWidth < cursor.HandleSize) { top = cursor.HandleSize + AreaBorderWidth; } } xrangeChanged = false; height = bottom - top + 1; if (height <= 0) { height = 1; } } if (AutoScaleMargin != 0 && height > 0) { double margin = (double)AutoScaleMargin * (endY - startY) / (double)height; if (autoStartY) { startY -= margin; } if (autoEndY) { endY += margin; } } // Console.WriteLine ("L:" + left + " T:" + top + " W:" + width + " H:" + height); // Draw the background if (backgroundDisplay == BackgroundDisplay.Gradient) { ctx.Rectangle(left - 1, top - 1, width + 2, height + 2); using (var pat = new Cairo.LinearGradient(left - 1, top - 1, left - 1, height + 2)) { pat.AddColorStop(0, backroundColor); Cairo.Color endc = new Cairo.Color(1, 1, 1); pat.AddColorStop(1, endc); ctx.SetSource(pat); ctx.Fill(); } } else { ctx.Rectangle(left - 1, top - 1, width + 2, height + 2); ctx.SetSourceColor(backroundColor); ctx.Fill(); } // win.DrawRectangle (Style.WhiteGC, true, left - 1, top - 1, width + 2, height + 2); win.DrawRectangle(Style.BlackGC, false, left - AreaBorderWidth, top - AreaBorderWidth, width + AreaBorderWidth * 2, height + AreaBorderWidth * 2); // Draw selected area if (enableSelection) { int sx, sy, ex, ey; GetPoint(selectionStart.Value, selectionStart.Value, out sx, out sy); GetPoint(selectionEnd.Value, selectionEnd.Value, out ex, out ey); if (sx > ex) { int tmp = sx; sx = ex; ex = tmp; } Gdk.GC sgc = new Gdk.GC(GdkWindow); sgc.RgbFgColor = new Color(225, 225, 225); win.DrawRectangle(sgc, true, sx, top, ex - sx, height + 1); } // Draw axes Gdk.GC gc = Style.BlackGC; foreach (Axis ax in axis) { DrawAxis(win, gc, ax); } // Draw values foreach (Serie serie in series) { if (serie.Visible) { DrawSerie(ctx, serie); } } // Draw cursors foreach (ChartCursor cursor in cursors) { DrawCursor(cursor); } // Draw cursor labels foreach (ChartCursor cursor in cursors) { if (cursor.ShowValueLabel) { DrawCursorLabel(cursor); } } ((IDisposable)ctx).Dispose(); return(true); }
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 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); } }
private void DrawIslands(Window window, Gdk.GC gc) { if (m_app == null) return; if (m_app.Islands == null) return; gc.RgbFgColor = new Color(255, 0, 255); foreach (var island in m_app.Islands) { window.DrawRectangle(gc, false, island.X, island.Y, island.Width, island.Height); } }
void DrawCell(int c, int r, int item) { if (adapter == null) { return; } Pixbuf image = adapter[item]; if (image == null) { return; } #if DORKY_HIGHLIGHT Console.WriteLine("{0} {1} // {2} {3} // {4}", c, r, mouse_col, mouse_row, highlight_mouse); if (c == mouse_col && r == mouse_row && highlight_mouse) { Pixbuf original = image; image = new Pixbuf(original.Colorspace, original.HasAlpha, original.BitsPerSample, original.Width, original.Height); original.CopyArea(0, 0, original.Width, original.Height, image, 0, 0); image.SaturateAndPixelate(image, 4.0f, false); } #endif int x = c * cell_width + margin_left; int y = r * cell_height + margin_top; int iw = (int)Math.Min(image.Width * zoom, icon_width); int ih = (int)Math.Min(image.Height * zoom, icon_height); x += (icon_width - iw) / 2; y += (icon_height - ih) / 2; // paint over any possible old selection if (!Selection.Get(item)) { for (int i = 0; i < 5; i++) { window.DrawRectangle (bkgr_gc, false, x - i - 1, y - i - 1, iw + i * 2 + 1, ih + i * 2 + 1); } } if (iw != image.Width || ih != image.Height) { using (Gdk.Pixbuf scaled_image = image.ScaleSimple(iw, ih, InterpType.Tiles)) { Console.WriteLine("scalesimple pixbuf is at 0x" + scaled_image.Handle.ToInt32().ToString("x")); scaled_image.RenderToDrawable(window, white_gc, 0, 0, x, y, iw, ih, Gdk.RgbDither.None, 0, 0); } } else { image.RenderToDrawable( window, white_gc, 0, 0, x, y, iw, ih, Gdk.RgbDither.None, 0, 0); } // then draw any selection if (Selection.Get(item)) { window.DrawRectangle(selection_gc, false, x - 4, y - 4, iw + 7, ih + 7); } }
protected override bool OnExposeEvent(Gdk.EventExpose ev) { Gdk.Window win = ev.Window; Gdk.Rectangle rect = ev.Area; Gdk.GC gc = this.Style.BaseGC(StateType.Normal); lock (this.drawLock){ if (this.toDraw != null) { //Raise events for the symbols... bool gotSymbol = false; //See if there's a new symbol if (this.symbols != null) { foreach (Symbol s in this.symbols) { if (s.Count > 0 && this.data != s.ToString()) { this.data = s.ToString(); //Don't raise it inside the expose event :) GLib.IdleHandler raiser = delegate(){ if (this.BarScanned != null) { this.BarScanned(this, new BarScannedArgs(s)); } return(false); }; GLib.Idle.Add(raiser); gotSymbol = true; } } } //Avoid beeping more than once.. if (gotSymbol) { if (!this.Mute) { System.Media.SystemSounds.Beep.Play(); } if (this.overlayingFrames == 0) { GLib.TimeoutHandler hdl = delegate(){ this.QueueDraw(); this.overlayingFrames -= 1; return(this.overlayingFrames > 0); }; GLib.Timeout.Add(35, hdl); } //Start drawing an overlay this.overlayingFrames = overlayFrameCount; } this.symbols = null; //Symbols have been handled //See if we want to request a resize if (this.reqHeight != this.toDrawHeight || this.reqWidth != this.toDrawWidth) { this.reqHeight = this.toDrawHeight; this.reqWidth = this.toDrawWidth; this.QueueResize(); } //Draw the gray image int w = Math.Min(rect.Size.Width, this.toDrawWidth); int h = Math.Min(rect.Size.Height, this.toDrawHeight); //Draw the image win.DrawGrayImage(gc, 0, 0, w, h, Gdk.RgbDither.Normal, this.toDraw, this.toDrawWidth); if (this.overlayingFrames > 0) { Pixbuf overlay_tmp = overlay; if (this.overlay.Width > w * 0.8 || this.overlay.Height > h * 0.8) { int overlayMaxSize = Math.Min(h * 80 / 100, w * 80 / 100); overlay_tmp = overlay.ScaleSimple(overlayMaxSize, overlayMaxSize, InterpType.Bilinear); } w = Math.Min(this.toDrawWidth, (int)overlay_tmp.Width); h = Math.Min(this.toDrawHeight, (int)overlay_tmp.Height); using (Gdk.Pixbuf pix = new Pixbuf(Colorspace.Rgb, true, 8, w, h)){ pix.Fill(0x00000000); //Fill with invisibility :) overlay_tmp.Composite(pix, 0, 0, w, h, 0, 0, 1, 1, InterpType.Bilinear, 255 / 35 * this.overlayingFrames); win.DrawPixbuf(gc, pix, 0, 0, (this.toDrawWidth - w) / 2, (this.toDrawHeight - h) / 2, w, h, RgbDither.Normal, 0, 0); } } } else { win.DrawRectangle(gc, true, rect); int w = Math.Min(this.toDrawWidth, (int)this.sourceMissing.Width); int h = Math.Min(this.toDrawHeight, (int)this.sourceMissing.Height); Rectangle img = new Rectangle((this.toDrawWidth - w) / 2, (this.toDrawHeight - h) / 2, w, h); Rectangle target = Rectangle.Intersect(img, rect); if (target != Rectangle.Zero) { win.DrawPixbuf(gc, this.sourceMissing, Math.Max(target.X - img.X, 0), Math.Max(target.Y - img.Y, 0), target.X, target.Y, target.Width, target.Height, RgbDither.Normal, 0, 0); } } } return(true); }