protected override bool OnExposeEvent (EventExpose evnt) { using (var cr = CairoHelper.Create (evnt.Window)) { cr.Color = (Mono.TextEditor.HslColor)Style.Dark (StateType.Normal); cr.Rectangle (0, 0, Allocation.Width, Allocation.Height); cr.Fill (); } return true; }
protected override bool OnExposeEvent (EventExpose evnt) { base.OnExposeEvent (evnt); using (var e = CairoHelper.Create (evnt.Window)) { Render (e); } return true; }
protected override bool OnExposeEvent(EventExpose args) { using (Context context = CairoHelper.Create (base.GdkWindow)) { CairoHelper.Rectangle (context, args.Area); context.Clip (); CreatePath (context); StrokeAndFill (context); } return true; }
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 (EventExpose evnt) { base.OnExposeEvent (evnt); using (var e = CairoHelper.Create (evnt.Window)) { var hourRadians = (time.Hour % 12 + time.Minute / 60F) * 30 * Math.PI / 180; DrawHand (3, hourLength, hourColor, hourRadians, e); var minuteRadians = (time.Minute) * 6 * Math.PI / 180; DrawHand (2, minuteLength, minuteColor, minuteRadians, e); var secondRadians = (time.Second) * 6 * Math.PI / 180; DrawHand (1, secondLength, secondColor, secondRadians, e); for (int i = 0; i < 60; i++) { if (i % 5 == 0) { var p1 = new Cairo.PointD (center.X + (radius / 1.50 * Math.Sin (i * 6 * Math.PI / 180)), center.Y - (radius / 1.50 * Math.Cos (i * 6 * Math.PI / 180))); var p2 = new Cairo.PointD (center.X + (radius / 1.65 * Math.Sin (i * 6 * Math.PI / 180)), center.Y - (radius / 1.65 * Math.Cos (i * 6 * Math.PI / 180))); e.LineWidth = 1; e.Color = ticksColor; e.MoveTo (p1); e.LineTo (p2); e.ClosePath (); e.Stroke (); } else { var p1 = new Cairo.PointD (center.X + (radius / 1.50 * Math.Sin (i * 6 * Math.PI / 180)), center.Y - (radius / 1.50 * Math.Cos (i * 6 * Math.PI / 180))); var p2 = new Cairo.PointD ( center.X + (radius / 1.55 * Math.Sin (i * 6 * Math.PI / 180)), center.Y - (radius / 1.55 * Math.Cos (i * 6 * Math.PI / 180))); e.LineWidth = 1; e.Color = ticksColor; e.MoveTo (p1); e.LineTo (p2); e.ClosePath (); e.Stroke (); } } DrawFace (center, (radius / 2) + 17, e); DrawFace (center, 8, e); } return true; }
protected override bool OnExposeEvent(Gdk.EventExpose args) { Gdk.Window win = args.Window; using (Cairo.Context gr = Gdk.CairoHelper.Create(win)) { int x, y, w, h, d; win.GetGeometry(out x, out y, out w, out h, out d); scale_y = h / max_y; gr.Rectangle(0, 0, w, h); gr.SetSourceRGB(0.2, 0.2, 0.2); gr.Fill(); draw_grid(gr, w, h); if (w < values.Count) { first_value = values.Count - w; } draw(gr); } return(true); }
protected override bool OnExposeEvent(Gdk.EventExpose args) { Gdk.Window win = args.Window; //Gdk.Rectangle area = args.Area; Cairo.Context g = Gdk.CairoHelper.Create(win); int x, y, w, h, d; win.GetGeometry(out x, out y, out w, out h, out d); if (!p) { width2 = w; height2 = h; InitializeSeeds(); p = true; } draw(g, w, h); return(true); }
protected override bool OnExposeEvent(EventExpose evnt) { Paint(evnt.Area.ToPerspex()); return true; }
//FIXME: we could use the expose event's clipbox to make the drawing more efficient void DrawList(Gdk.EventExpose args) { var window = args.Window; int winWidth, winHeight; window.GetSize(out winWidth, out winHeight); int ypos = margin; int lineWidth = winWidth - margin * 2; int xpos = margin + padding - (int)hAdjustement.Value; //avoid recreating the GC objects that we use multiple times var textGCNormal = this.Style.TextGC(StateType.Normal); var fgGCNormal = this.Style.ForegroundGC(StateType.Normal); int n = 0; while (ypos < winHeight - margin && (page + n) < RowCount) { bool isSelected = selectedRows.Contains(page + n); bool hasMarkup = SetLayoutText(page + n, isSelected); Gdk.Pixbuf icon = dataProvider.GetIcon(page + n); int iconHeight = icon != null? icon.Height : IconWidth; int iconWidth = icon != null? icon.Width : IconWidth; 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 (isSelected) { if (!disableSelection) { window.DrawRectangle(this.Style.BaseGC(StateType.Selected), true, margin, ypos, lineWidth, he + padding); window.DrawLayout(this.Style.TextGC(StateType.Selected), xpos + iconWidth + ColumnGap, typos, layout); } else { window.DrawRectangle(this.Style.BaseGC(StateType.Selected), false, margin, ypos, lineWidth, he + padding); window.DrawLayout(textGCNormal, xpos + iconWidth + ColumnGap, typos, layout); } // Draw a 'most recent selection' rectangle. if (this.SelectedRow == page + n) { window.DrawRectangle(this.Style.BaseGC(StateType.Active), false, margin, ypos, lineWidth, he + padding - 1); window.DrawLayout(this.Style.TextGC(StateType.Active), xpos + iconWidth + ColumnGap, typos, layout); } } else { window.DrawLayout(textGCNormal, xpos + iconWidth + ColumnGap, typos, layout); } if (icon != null) { window.DrawPixbuf(fgGCNormal, icon, 0, 0, xpos, iypos, iconWidth, iconHeight, RgbDither.None, 0, 0); } ypos += rowHeight; n++; //reset the markup or it carries over to the next SetText if (hasMarkup) { layout.SetMarkup(string.Empty); } } }
protected override bool OnExposeEvent(EventExpose evnt) { int height; int width; Gdk.Window win = evnt.Window; win.GetSize(out width, out height); win.Resize((int)(frames/pixelRatio), height); win.GetSize(out width, out height); if(Environment.OSVersion.Platform == PlatformID.Unix) this.CairoDraw(evnt,height,width); else this.GdkDraw(evnt,height,width); return base.OnExposeEvent(evnt); }
protected override bool OnExposeEvent(EventExpose evnt) { if (evnt.Window != GdkWindow) return true; if (selection.Collection.Count == 0) return true; if (Orientation == Orientation.Horizontal && (extendable && Allocation.Width >= BackgroundPixbuf.Width + (2 * x_offset) + BackgroundTile.Width) || Orientation == Orientation.Vertical && (extendable && Allocation.Height >= BackgroundPixbuf.Height + (2 * y_offset) + BackgroundTile.Height) ) BackgroundPixbuf = null; if ( Orientation == Orientation.Horizontal && (extendable && Allocation.Width < BackgroundPixbuf.Width + (2 * x_offset) ) || Orientation == Orientation.Vertical && ( extendable && Allocation.Height < BackgroundPixbuf.Height + (2 * y_offset) )) BackgroundPixbuf = null; int xpad = 0, ypad = 0; if (Allocation.Width > BackgroundPixbuf.Width + (2 * x_offset)) xpad = (int) (x_align * (Allocation.Width - (BackgroundPixbuf.Width + (2 * x_offset)))); if (Allocation.Height > BackgroundPixbuf.Height + (2 * y_offset)) ypad = (int) (y_align * (Allocation.Height - (BackgroundPixbuf.Height + (2 * y_offset)))); GdkWindow.DrawPixbuf (Style.BackgroundGC (StateType.Normal), BackgroundPixbuf, 0, 0, x_offset + xpad, y_offset + ypad, BackgroundPixbuf.Width, BackgroundPixbuf.Height, RgbDither.None, 0, 0); //drawing the icons... start_indexes = new Dictionary<int, int> (); Pixbuf icon_pixbuf = null; if (Orientation == Orientation.Horizontal) icon_pixbuf = new Pixbuf (Colorspace.Rgb, true, 8, BackgroundPixbuf.Width, thumb_size); else if (Orientation == Orientation.Vertical) icon_pixbuf = new Pixbuf (Colorspace.Rgb, true, 8, thumb_size, BackgroundPixbuf.Height); icon_pixbuf.Fill (0x00000000); Pixbuf current = GetPixbuf ((int) Math.Round (Position)); int ref_x = (int)(icon_pixbuf.Width / 2.0 - current.Width * (Position + 0.5f - Math.Round (Position))); //xpos of the reference icon int ref_y = (int)(icon_pixbuf.Height / 2.0 - current.Height * (Position + 0.5f - Math.Round (Position))); int start_x = Orientation == Orientation.Horizontal ? ref_x : 0; int start_y = Orientation == Orientation.Vertical ? ref_y : 0; for (int i = (int) Math.Round (Position); i < selection.Collection.Count; i++) { current = GetPixbuf (i, ActiveItem == i); if (Orientation == Orientation.Horizontal) { current.CopyArea (0, 0, Math.Min (current.Width, icon_pixbuf.Width - start_x) , current.Height, icon_pixbuf, start_x, start_y); start_indexes [start_x] = i; start_x += current.Width + spacing; if (start_x > icon_pixbuf.Width) break; } else if (Orientation == Orientation.Vertical) { current.CopyArea (0, 0, current.Width, Math.Min (current.Height, icon_pixbuf.Height - start_y), icon_pixbuf, start_x, start_y); start_indexes [start_y] = i; start_y += current.Height + spacing; if (start_y > icon_pixbuf.Height) break; } } filmstrip_end_pos = (Orientation == Orientation.Horizontal ? start_x : start_y); start_x = Orientation == Orientation.Horizontal ? ref_x : 0; start_y = Orientation == Orientation.Vertical ? ref_y : 0; for (int i = (int) Math.Round (Position) - 1; i >= 0; i--) { current = GetPixbuf (i, ActiveItem == i); if (Orientation == Orientation.Horizontal) { start_x -= (current.Width + spacing); current.CopyArea (Math.Max (0, -start_x), 0, Math.Min (current.Width, current.Width + start_x), current.Height, icon_pixbuf, Math.Max (start_x, 0), 0); start_indexes [Math.Max (0, start_x)] = i; if (start_x < 0) break; } else if (Orientation == Orientation.Vertical) { start_y -= (current.Height + spacing); current.CopyArea (0, Math.Max (0, -start_y), current.Width, Math.Min (current.Height, current.Height + start_y), icon_pixbuf, 0, Math.Max (start_y, 0)); start_indexes [Math.Max (0, start_y)] = i; if (start_y < 0) break; } } filmstrip_start_pos = Orientation == Orientation.Horizontal ? start_x : start_y; GdkWindow.DrawPixbuf (Style.BackgroundGC (StateType.Normal), icon_pixbuf, 0, 0, x_offset + xpad, y_offset + ypad + thumb_offset, icon_pixbuf.Width, icon_pixbuf.Height, RgbDither.None, 0, 0); icon_pixbuf.Dispose (); return true; }
protected override bool OnExposeEvent (EventExpose evnt) { bool hideButton = widget.MainEditor.Document.ReadOnly; using (Cairo.Context cr = Gdk.CairoHelper.Create (evnt.Window)) { cr.Rectangle (evnt.Region.Clipbox.X, evnt.Region.Clipbox.Y, evnt.Region.Clipbox.Width, evnt.Region.Clipbox.Height); cr.Clip (); int delta = widget.MainEditor.Allocation.Y - Allocation.Y; if (Diff != null) { foreach (Mono.TextEditor.Utils.Hunk hunk in Diff) { double z1 = delta + fromEditor.LineToY (hunk.RemoveStart) - fromEditor.VAdjustment.Value; double z2 = delta + fromEditor.LineToY (hunk.RemoveStart + hunk.Removed) - fromEditor.VAdjustment.Value; if (z1 == z2) z2 = z1 + 1; double y1 = delta + toEditor.LineToY (hunk.InsertStart) - toEditor.VAdjustment.Value; double y2 = delta + toEditor.LineToY (hunk.InsertStart + hunk.Inserted) - toEditor.VAdjustment.Value; if (y1 == y2) y2 = y1 + 1; if (!useLeft) { var tmp = z1; z1 = y1; y1 = tmp; tmp = z2; z2 = y2; y2 = tmp; } int x1 = 0; int x2 = Allocation.Width; if (!hideButton) { if (useLeft && hunk.Removed > 0 || !useLeft && hunk.Removed == 0) { x1 += 16; } else { x2 -= 16; } } if (z1 == z2) z2 = z1 + 1; cr.MoveTo (x1, z1); cr.CurveTo (x1 + (x2 - x1) / 4, z1, x1 + (x2 - x1) * 3 / 4, y1, x2, y1); cr.LineTo (x2, y2); cr.CurveTo (x1 + (x2 - x1) * 3 / 4, y2, x1 + (x2 - x1) / 4, z2, x1, z2); cr.ClosePath (); cr.Color = GetColor (hunk, this.useLeft, false, 1.0); cr.Fill (); cr.Color = GetColor (hunk, this.useLeft, true, 1.0); cr.MoveTo (x1, z1); cr.CurveTo (x1 + (x2 - x1) / 4, z1, x1 + (x2 - x1) * 3 / 4, y1, x2, y1); cr.Stroke (); cr.MoveTo (x2, y2); cr.CurveTo (x1 + (x2 - x1) * 3 / 4, y2, x1 + (x2 - x1) / 4, z2, x1, z2); cr.Stroke (); if (!hideButton) { bool isButtonSelected = hunk == selectedHunk; double x, y, w, h; bool drawArrow = useLeft ? GetButtonPosition (hunk, y1, y2, z1, z2, out x, out y, out w, out h) : GetButtonPosition (hunk, z1, z2, y1, y2, out x, out y, out w, out h); cr.Rectangle (x, y, w, h); if (isButtonSelected) { int mx, my; GetPointer (out mx, out my); // mx -= (int)x; // my -= (int)y; Cairo.RadialGradient gradient = new Cairo.RadialGradient (mx, my, h, mx, my, 2); var color = (Mono.TextEditor.HslColor)Style.Mid (StateType.Normal); color.L *= 1.05; gradient.AddColorStop (0, color); color.L *= 1.07; gradient.AddColorStop (1, color); cr.Pattern = gradient; } else { cr.Color = (Mono.TextEditor.HslColor)Style.Mid (StateType.Normal); } cr.FillPreserve (); cr.Color = (Mono.TextEditor.HslColor)Style.Dark (StateType.Normal); cr.Stroke (); cr.LineWidth = 1; cr.Color = new Cairo.Color (0, 0, 0); if (drawArrow) { DrawArrow (cr, x + w / 1.5, y + h / 2); DrawArrow (cr, x + w / 2.5, y + h / 2); } else { DrawCross (cr, x + w / 2 , y + (h) / 2); } cr.Stroke (); } } } } // var result = base.OnExposeEvent (evnt); // // Gdk.GC gc = Style.DarkGC (State); // evnt.Window.DrawLine (gc, Allocation.X, Allocation.Top, Allocation.X, Allocation.Bottom); // evnt.Window.DrawLine (gc, Allocation.Right, Allocation.Top, Allocation.Right, Allocation.Bottom); // // evnt.Window.DrawLine (gc, Allocation.Left, Allocation.Y, Allocation.Right, Allocation.Y); // evnt.Window.DrawLine (gc, Allocation.Left, Allocation.Bottom, Allocation.Right, Allocation.Bottom); return true; }
protected override bool OnExposeEvent (EventExpose evnt) { int w, h; GetSize (out w, out h); using (var ctx = CairoHelper.Create (evnt.Window)) { ctx.SetSourceColor (new Cairo.Color (0.17, 0.55, 0.79)); ctx.Rectangle (Allocation.ToCairoRect ()); ctx.Fill (); } return true; }
protected override bool OnExposeEvent(EventExpose evnt) { ExposeIt(); return base.OnExposeEvent (evnt); }
protected virtual void OnDrawContent(Gdk.EventExpose evnt, Cairo.Context context) { Theme.RenderBackground(context, new Gdk.Rectangle(Allocation.X, Allocation.Y, paintSize.Width, paintSize.Height)); }
protected override bool OnExposeEvent(Gdk.EventExpose evnt) { InitializeDelayedHide(); return(base.OnExposeEvent(evnt)); }
//FIXME: we could use the expose event's clipbox to make the drawing more efficient void DrawList(Gdk.EventExpose args) { var window = args.Window; int winWidth, winHeight; window.GetSize(out winWidth, out winHeight); int ypos = margin; int lineWidth = winWidth - margin * 2; int xpos = margin + padding; //avoid recreating the GC objects that we use multiple times var textGCNormal = this.Style.TextGC(StateType.Normal); var fgGCNormal = this.Style.ForegroundGC(StateType.Normal); int n = 0; while (ypos < winHeight - margin && (page + n) < win.DataProvider.Count) { bool hasMarkup = false; IMarkupListDataProvider <T> markupListDataProvider = win.DataProvider as IMarkupListDataProvider <T>; if (markupListDataProvider != null) { if (markupListDataProvider.HasMarkup(page + n)) { layout.SetMarkup(markupListDataProvider.GetMarkup(page + n) ?? "<null>"); hasMarkup = true; } } if (!hasMarkup) { layout.SetText(win.DataProvider.GetText(page + n) ?? "<null>"); } Gdk.Pixbuf icon = win.DataProvider.GetIcon(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 (!disableSelection) { args.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.BaseGC(StateType.Selected), false, margin, ypos, lineWidth, he + padding); 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); } ypos += rowHeight; n++; //reset the markup or it carries over to the next SetText if (hasMarkup) { layout.SetMarkup(string.Empty); } } }
protected override bool OnExposeEvent(Gdk.EventExpose args) { base.OnExposeEvent(args); DrawList(args); return(true); }
protected override bool OnExposeEvent(Gdk.EventExpose e) { Cairo.Context cr = Gdk.CairoHelper.Create(e.Window); Gdk.Rectangle area = e.Area; if (this.categories.Count == 0 || !string.IsNullOrEmpty(CustomMessage)) { Pango.Layout messageLayout = new Pango.Layout(this.PangoContext); messageLayout.Alignment = Pango.Alignment.Center; messageLayout.Width = (int)(Allocation.Width * 2 / 3 * Pango.Scale.PangoScale); if (!string.IsNullOrEmpty(CustomMessage)) { messageLayout.SetText(CustomMessage); } else { messageLayout.SetText(MonoDevelop.Core.GettextCatalog.GetString("There are no tools available for the current document.")); } cr.MoveTo(Allocation.Width * 1 / 6, 12); cr.SetSourceColor(Style.Text(StateType.Normal).ToCairoColor()); Pango.CairoHelper.ShowLayout(cr, messageLayout); messageLayout.Dispose(); ((IDisposable)cr).Dispose(); return(true); } var backColor = Style.Base(StateType.Normal).ToCairoColor(); cr.SetSourceColor(backColor); cr.Rectangle(area.X, area.Y, area.Width, area.Height); cr.Fill(); int xpos = (this.hAdjustement != null ? (int)this.hAdjustement.Value : 0); int vadjustment = (this.vAdjustement != null ? (int)this.vAdjustement.Value : 0); int ypos = -vadjustment; Category lastCategory = null; int lastCategoryYpos = 0; Iterate(ref xpos, ref ypos, delegate(Category category, Gdk.Size itemDimension) { const int foldSegmentHeight = 8; ProcessExpandAnimation(cr, lastCategory, lastCategoryYpos, backColor, area, ref ypos); cr.Rectangle(xpos, ypos, itemDimension.Width, itemDimension.Height); using (var pat = new Cairo.LinearGradient(xpos, ypos, xpos, ypos + itemDimension.Height)) { pat.AddColorStop(0, CategoryBackgroundGradientStartColor); pat.AddColorStop(1, CategoryBackgroundGradientEndColor); cr.SetSource(pat); cr.Fill(); } if (lastCategory == null || lastCategory.IsExpanded || lastCategory.AnimatingExpand) { cr.MoveTo(xpos, ypos + 0.5); cr.LineTo(itemDimension.Width, ypos + 0.5); } cr.MoveTo(0, ypos + itemDimension.Height - 0.5); cr.LineTo(xpos + Allocation.Width, ypos + itemDimension.Height - 0.5); cr.SetSourceColor(CategoryBorderColor); cr.LineWidth = 1; cr.Stroke(); headerLayout.SetText(category.Text); int width, height; cr.SetSourceColor(CategoryLabelColor); layout.GetPixelSize(out width, out height); cr.MoveTo(xpos + CategoryLeftPadding, ypos + (itemDimension.Height - height) / 2); Pango.CairoHelper.ShowLayout(cr, headerLayout); var img = category.IsExpanded ? discloseUp : discloseDown; Gdk.CairoHelper.SetSourcePixbuf(cr, img, Allocation.Width - img.Width - CategoryRightPadding, ypos + (itemDimension.Height - img.Height) / 2); cr.Paint(); lastCategory = category; lastCategoryYpos = ypos + itemDimension.Height; }, delegate(Category curCategory, Item item, Gdk.Size itemDimension) { if (item == SelectedItem) { cr.SetSourceColor(Style.Base(StateType.Selected).ToCairoColor()); cr.Rectangle(xpos, ypos, itemDimension.Width, itemDimension.Height); cr.Fill(); } if (listMode || !curCategory.CanIconizeItems) { Gdk.CairoHelper.SetSourcePixbuf(cr, item.Icon, xpos + ItemLeftPadding, ypos + (itemDimension.Height - item.Icon.Height) / 2); cr.Paint(); layout.SetText(item.Text); int width, height; layout.GetPixelSize(out width, out height); cr.SetSourceColor(Style.Text(item != this.SelectedItem ? StateType.Normal : StateType.Selected).ToCairoColor()); cr.MoveTo(xpos + ItemLeftPadding + IconSize.Width + ItemIconTextItemSpacing, ypos + (itemDimension.Height - height) / 2); Pango.CairoHelper.ShowLayout(cr, layout); } else { Gdk.CairoHelper.SetSourcePixbuf(cr, item.Icon, xpos + (itemDimension.Width - item.Icon.Width) / 2, ypos + (itemDimension.Height - item.Icon.Height) / 2); cr.Paint(); } if (item == mouseOverItem) { cr.SetSourceColor(Style.Dark(StateType.Prelight).ToCairoColor()); cr.Rectangle(xpos + 0.5, ypos + 0.5, itemDimension.Width - 1, itemDimension.Height - 1); cr.Stroke(); } }); ProcessExpandAnimation(cr, lastCategory, lastCategoryYpos, backColor, area, ref ypos); if (lastCategory != null && lastCategory.AnimatingExpand) { // Closing line when animating the last group of the toolbox cr.MoveTo(area.X, ypos + 0.5); cr.RelLineTo(area.Width, 0); cr.SetSourceColor(CategoryBorderColor); cr.Stroke(); } ((IDisposable)cr).Dispose(); return(true); }
protected override bool OnExposeEvent(Gdk.EventExpose e) { using (Cairo.Context cr = Gdk.CairoHelper.Create(e.Window)) { double xPos = padding, yPos = padding; var layout = PangoUtil.CreateLayout(this); int w, h; layout.SetText(new string ('X', maxLength)); layout.GetPixelSize(out w, out h); foreach (Category cat in categories) { yPos = padding; cr.MoveTo(xPos, yPos); layout.SetMarkup("<b>" + cat.Title + "</b>"); cr.Color = (HslColor)Style.Text(StateType.Normal); cr.ShowLayout(layout); if (cat.Items.Count == 0) { continue; } layout.SetMarkup(""); int w2, h2; layout.GetPixelSize(out w2, out h2); yPos += h2; yPos += headerDistance; var startY = yPos; int curItem = 0; int row = 0; var iconHeight = Math.Max(h, cat.Items [0].Icon.Height + 2) + itemPadding * 2; if (cat.FirstVisibleItem > 0) { Gtk.Style.PaintArrow(Style, e.Window, State, ShadowType.None, new Rectangle((int)xPos, (int)yPos, w, h), this, "", ArrowType.Up, true, (int)xPos, (int)yPos, w, h); yPos += iconHeight; curItem++; } for (int i = cat.FirstVisibleItem; i < cat.Items.Count; i++) { var item = cat.Items [i]; if (curItem + 1 >= maxItems && row + 1 >= maxRows && i + 1 < cat.Items.Count) { Gtk.Style.PaintArrow(Style, e.Window, State, ShadowType.None, new Rectangle((int)xPos, (int)yPos, w, h), this, "", ArrowType.Down, true, (int)xPos, (int)yPos, w, h); break; } if (item == ActiveItem) { int itemWidth = w + item.Icon.Width + 2 + itemPadding * 2; cr.Rectangle(xPos, yPos, itemWidth, iconHeight); cr.LineWidth = 1; cr.Color = (HslColor)Style.Base(StateType.Selected); cr.Fill(); } else if (item == hoverItem) { int itemWidth = w + item.Icon.Width + 2 + itemPadding * 2; cr.Rectangle(xPos + 0.5, yPos + 0.5, itemWidth - 1, iconHeight); cr.LineWidth = 1; cr.Color = (HslColor)Style.Base(StateType.Selected); cr.Stroke(); } cr.Color = (HslColor)Style.Text(item == ActiveItem? StateType.Selected : StateType.Normal); cr.MoveTo(xPos + item.Icon.Width + 2 + itemPadding, yPos + (iconHeight - h) / 2); layout.SetText(Ellipsize(item.ListTitle ?? item.Title, maxLength)); cr.ShowLayout(layout); e.Window.DrawPixbuf(Style.BaseGC(StateType.Normal), item.Icon, 0, 0, (int)xPos + itemPadding, (int)(yPos + (iconHeight - item.Icon.Height) / 2), item.Icon.Width, item.Icon.Height, RgbDither.None, 0, 0); yPos += iconHeight; if (++curItem >= maxItems) { curItem = 0; yPos = startY; xPos += w + cat.Items [0].Icon.Width + 2 + padding + itemPadding * 2; row++; } } xPos += w + cat.Items [0].Icon.Width + 2 + padding + itemPadding * 2; } layout.Dispose(); } return(true); }
//FIXME: we could use the expose event's clipbox to make the drawing more efficient void DrawList(Gdk.EventExpose args) { var window = args.Window; int winWidth, winHeight; window.GetSize(out winWidth, out winHeight); int ypos = margin; int lineWidth = winWidth - margin * 2; int xpos = margin + padding; using (var cr = this.CreateXwtContext()) { //avoid recreating the GC objects that we use multiple times var textColor = this.Style.Text(StateType.Normal).ToXwtColor(); int n = 0; n = (int)(vadj.Value / rowHeight); while (ypos < winHeight - margin && n < win.DataProvider.Count) { bool hasMarkup = false; IMarkupListDataProvider <T> markupListDataProvider = win.DataProvider as IMarkupListDataProvider <T>; if (markupListDataProvider != null) { if (markupListDataProvider.HasMarkup(n)) { layout.Markup = (markupListDataProvider.GetMarkup(n) ?? "<null>"); hasMarkup = true; } } if (!hasMarkup) { layout.Text = (win.DataProvider.GetText(n) ?? "<null>"); } Xwt.Drawing.Image icon = win.DataProvider.GetIcon(n); int iconHeight, iconWidth; if (icon != null) { iconWidth = (int)icon.Width; iconHeight = (int)icon.Height; } else if (!Gtk.Icon.SizeLookup(Gtk.IconSize.Menu, out iconWidth, out iconHeight)) { iconHeight = iconWidth = 24; } var s = layout.GetSize(); int typos, iypos; int he = (int)s.Height; typos = he < rowHeight ? ypos + (rowHeight - he) / 2 : ypos; iypos = iconHeight < rowHeight ? ypos + (rowHeight - iconHeight) / 2 : ypos; if (n == selection) { if (!disableSelection) { cr.Rectangle(margin, ypos, lineWidth, he + padding); cr.SetColor(this.Style.Base(StateType.Selected).ToXwtColor()); cr.Fill(); cr.SetColor(this.Style.Text(StateType.Selected).ToXwtColor()); cr.DrawTextLayout(layout, xpos + iconWidth + 2, typos); } else { cr.Rectangle(margin, ypos, lineWidth, he + padding); cr.SetColor(this.Style.Base(StateType.Selected).ToXwtColor()); cr.Stroke(); cr.SetColor(textColor); cr.DrawTextLayout(layout, xpos + iconWidth + 2, typos); } } else { cr.SetColor(textColor); cr.DrawTextLayout(layout, xpos + iconWidth + 2, typos); } if (icon != null) { cr.DrawImage(icon, xpos, iypos); } ypos += rowHeight; n++; //reset the markup or it carries over to the next SetText if (hasMarkup) { layout.Markup = string.Empty; } } } }
protected override bool OnExposeEvent(EventExpose e) { base.OnExposeEvent (e); if (!PintaCore.Workspace.HasOpenDocuments) return true; double scale = PintaCore.Workspace.Scale; int x = (int)PintaCore.Workspace.Offset.X; int y = (int)PintaCore.Workspace.Offset.Y; // Translate our expose area for the whole drawingarea to just our canvas Rectangle canvas_bounds = new Rectangle (x, y, PintaCore.Workspace.CanvasSize.Width, PintaCore.Workspace.CanvasSize.Height); canvas_bounds.Intersect (e.Area); if (canvas_bounds.IsEmpty) return true; canvas_bounds.X -= x; canvas_bounds.Y -= y; // Resize our offscreen surface to a surface the size of our drawing area if (canvas == null || canvas.Width != canvas_bounds.Width || canvas.Height != canvas_bounds.Height) { if (canvas != null) (canvas as IDisposable).Dispose (); canvas = new Cairo.ImageSurface (Cairo.Format.Argb32, canvas_bounds.Width, canvas_bounds.Height); } cr.Initialize (PintaCore.Workspace.ImageSize, PintaCore.Workspace.CanvasSize); using (Cairo.Context g = CairoHelper.Create (GdkWindow)) { // Draw our canvas drop shadow g.DrawRectangle (new Cairo.Rectangle (x, y, PintaCore.Workspace.CanvasSize.Width + 1, PintaCore.Workspace.CanvasSize.Height + 1), new Cairo.Color (.5, .5, .5), 1); g.DrawRectangle (new Cairo.Rectangle (x - 1, y - 1, PintaCore.Workspace.CanvasSize.Width + 3, PintaCore.Workspace.CanvasSize.Height + 3), new Cairo.Color (.8, .8, .8), 1); g.DrawRectangle (new Cairo.Rectangle (x - 2, y - 2, PintaCore.Workspace.CanvasSize.Width + 5, PintaCore.Workspace.CanvasSize.Height + 5), new Cairo.Color (.9, .9, .9), 1); // Set up our clip rectangle g.Rectangle (new Cairo.Rectangle (x, y, PintaCore.Workspace.CanvasSize.Width, PintaCore.Workspace.CanvasSize.Height)); g.Clip (); g.Translate (x, y); // Render all the layers to a surface var layers = PintaCore.Layers.GetLayersToPaint (); if (layers.Count == 0) { canvas.Clear (); } cr.Render (layers, canvas, canvas_bounds.Location); // Paint the surface to our canvas g.SetSourceSurface (canvas, canvas_bounds.X + (int)(0 * scale), canvas_bounds.Y + (int)(0 * scale)); g.Paint (); // Selection outline if (PintaCore.Layers.ShowSelection) { g.Save (); g.Translate (0.5, 0.5); g.Scale (scale, scale); g.AppendPath (PintaCore.Layers.SelectionPath); if (PintaCore.Tools.CurrentTool.Name.Contains ("Select") && !PintaCore.Tools.CurrentTool.Name.Contains ("Selected")) { g.Color = new Cairo.Color (0.7, 0.8, 0.9, 0.2); g.FillRule = Cairo.FillRule.EvenOdd; g.FillPreserve (); } g.LineWidth = 1 / scale; // Draw a white line first so it shows up on dark backgrounds g.Color = new Cairo.Color (1, 1, 1); g.StrokePreserve (); // Draw a black dashed line over the white line g.SetDash (new double[] { 2 / scale, 4 / scale }, 0); g.Color = new Cairo.Color (0, 0, 0); g.Stroke (); g.Restore (); } } return true; }
protected override bool OnExposeEvent (EventExpose evnt) { using (var context = Gdk.CairoHelper.Create (evnt.Window)) { DrawBackground (context, Allocation, 15, State); var icon = GetIcon(); icon.Show ( context, Allocation.X + (icon.Width - Allocation.Width) / 2, Allocation.Y + (icon.Height - Allocation.Height) / 2 ); } return base.OnExposeEvent (evnt); }
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); // FIXME: VV: Remove gradient features 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; } using (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 (EventExpose evnt) { if (canvas != null) { GdkWindow.DrawDrawable (Style.BackgroundGC (State), canvas, 0, 0, widget_alloc.X, widget_alloc.Y, widget_alloc.Width, widget_alloc.Height); return true; } else { return base.OnExposeEvent (evnt); } }
protected override bool OnExposeEvent(Gdk.EventExpose e) { using (Cairo.Context cr = Gdk.CairoHelper.Create(e.Window)) { cr.LineWidth = Math.Max(1.0, widget.Editor.Options.Zoom); cr.Rectangle(leftSpacer, 0, Allocation.Width, Allocation.Height); cr.SetSourceRGB(0.95, 0.95, 0.95); cr.Fill(); int startLine = widget.Editor.YToLine((int)widget.Editor.VAdjustment.Value); double startY = widget.Editor.LineToY(startLine); while (startLine > 1 && startLine < annotations.Count && annotations[startLine - 1] != null && annotations[startLine] != null && annotations[startLine - 1].Revision == annotations[startLine].Revision) { startLine--; startY -= widget.Editor.GetLineHeight(widget.Editor.Document.GetLine(startLine)); } double curY = startY - widget.Editor.VAdjustment.Value; int line = startLine; while (curY < Allocation.Bottom && line <= widget.Editor.LineCount) { double curStart = curY; // widget.JumpOverFoldings (ref line); int lineStart = line; int authorWidth = 0, revisionWidth = 0, dateWidth = 0, h = 16; Annotation ann = line <= annotations.Count ? annotations[line - 1] : null; if (ann != null) { do { widget.JumpOverFoldings(ref line); line++; } while (line <= annotations.Count && annotations[line - 1] != null && annotations[line - 1].Revision == ann.Revision); double nextY = widget.editor.LineToY(line) - widget.editor.VAdjustment.Value; if (highlightAnnotation != null && highlightAnnotation.Revision == ann.Revision && curStart <= highlightPositon && highlightPositon < nextY) { cr.Rectangle(leftSpacer, curStart + cr.LineWidth, Allocation.Width - leftSpacer, nextY - curStart - cr.LineWidth); cr.SetSourceRGB(1, 1, 1); cr.Fill(); } // use a fixed size revision to get a approx. revision width layout.SetText("88888888"); layout.GetPixelSize(out revisionWidth, out h); layout.SetText(TruncRevision(ann.Revision)); e.Window.DrawLayout(Style.BlackGC, Allocation.Width - revisionWidth - margin, (int)(curY + (widget.Editor.LineHeight - h) / 2), layout); const int dateRevisionSpacing = 16; if (ann.HasDate) { string dateTime = ann.Date.ToShortDateString(); // use a fixed size date to get a approx. date width layout.SetText(new DateTime(1999, 10, 10).ToShortDateString()); layout.GetPixelSize(out dateWidth, out h); layout.SetText(dateTime); e.Window.DrawLayout(Style.BlackGC, Allocation.Width - revisionWidth - margin - revisionWidth - dateRevisionSpacing, (int)(curY + (widget.Editor.LineHeight - h) / 2), layout); } using (var authorLayout = PangoUtil.CreateLayout(this)) { var description = Pango.FontDescription.FromString("Tahoma " + (int)(10 * widget.Editor.Options.Zoom)); authorLayout.FontDescription = description; authorLayout.SetText(ann.Author); authorLayout.GetPixelSize(out authorWidth, out h); var maxWidth = Allocation.Width - revisionWidth - margin - revisionWidth - dateRevisionSpacing; /* if (authorWidth > maxWidth) { * int idx = ann.Author.IndexOf ('<'); * if (idx > 0) * authorLayout.SetText (ann.Author.Substring (0, idx) + Environment.NewLine + ann.Author.Substring (idx)); * authorLayout.GetPixelSize (out authorWidth, out h); * }*/ cr.Save(); cr.Rectangle(0, 0, maxWidth, Allocation.Height); cr.Clip(); cr.Translate(leftSpacer + margin, (int)(curY + (widget.Editor.LineHeight - h) / 2)); cr.SetSourceRGB(0, 0, 0); cr.ShowLayout(authorLayout); cr.ResetClip(); cr.Restore(); } curY = nextY; } else { curY += widget.Editor.GetLineHeight(line); line++; widget.JumpOverFoldings(ref line); } if (ann != null && line - lineStart > 1) { string msg = GetCommitMessage(lineStart, false); if (!string.IsNullOrEmpty(msg)) { msg = FormatMessage(msg); layout.SetText(msg); layout.Width = (int)(Allocation.Width * Pango.Scale.PangoScale); using (var gc = new Gdk.GC(e.Window)) { gc.RgbFgColor = Style.Dark(State); gc.ClipRectangle = new Rectangle(0, (int)curStart, Allocation.Width, (int)(curY - curStart)); e.Window.DrawLayout(gc, (int)(leftSpacer + margin), (int)(curStart + h), layout); } } } cr.Rectangle(0, curStart, leftSpacer, curY - curStart); if (ann != null && ann != locallyModified && !string.IsNullOrEmpty(ann.Author)) { double a; if (ann != null && (maxDate - minDate).TotalHours > 0) { a = 1 - (ann.Date - minDate).TotalHours / (maxDate - minDate).TotalHours; } else { a = 1; } HslColor color = new Cairo.Color(0.90, 0.90, 1); color.L = 0.4 + a / 2; color.S = 1 - a / 2; cr.SetSourceColor(color); } else { cr.SetSourceColor(ann != null ? new Cairo.Color(1, 1, 0) : new Cairo.Color(0.95, 0.95, 0.95)); } cr.Fill(); if (ann != null) { cr.MoveTo(0, curY + 0.5); cr.LineTo(Allocation.Width, curY + 0.5); cr.SetSourceRGB(0.6, 0.6, 0.6); cr.Stroke(); } } } return(true); }
protected override bool OnExposeEvent(Gdk.EventExpose args) { bool needsRefresh = false; using (var context = Gdk.CairoHelper.Create(args.Window)) { var scalef = GtkWorkarounds.GetScaleFactor(this); context.LineWidth = 1; 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); var backgroundColor = Styles.CodeCompletion.BackgroundColor.ToCairoColor(); var textColor = Styles.CodeCompletion.TextColor.ToCairoColor(); var categoryColor = Styles.CodeCompletion.CategoryColor.ToCairoColor(); context.SetSourceColor(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) { context.Rectangle(0, yPos, width, height - yPos); context.SetSourceColor(backgroundColor); context.Stroke(); //TODO: David, line below is simplified noMatchLayout.SetText (DataProvider.ItemCount == 0 ? NoSuggestionsMsg : NoMatchesMsg); noMatchLayout.SetText(NoSuggestionsMsg); int lWidth, lHeight; noMatchLayout.GetPixelSize(out lWidth, out lHeight); context.SetSourceColor(textColor); context.MoveTo((width - lWidth) / 2, yPos + (height - lHeight - yPos) / 2 - lHeight / 2); Pango.CairoHelper.ShowLayout(context, noMatchLayout); return(false); } Iterate(true, ref yPos, delegate(int index, int itemidx, int ypos) { if (ypos >= height) { return(false); } if (ypos < -rowHeight) { return(true); } xpos = iconTextSpacing; var selected = index == SelectedItemIndex; bool drawIconAsSelected = SelectionEnabled && selected; var item = filteredItems [index]; string markup = GLib.Markup.EscapeText(item.DisplayText); string description = ""; //TODO: David DataProvider.GetDescription (item, drawIconAsSelected); if (string.IsNullOrEmpty(description)) { layout.SetMarkup(markup); } else { layout.SetMarkup(markup + " " + description); } string text = item.DisplayText; //TODO: David, where do we get HighlightedSpans? //if (!string.IsNullOrEmpty (text) && item.HighlightedSpans.Any ()) { // Pango.AttrList attrList = layout.Attributes ?? new Pango.AttrList (); // foreach (var span in item.HighlightedSpans) { // var bold = new AttrWeight (Weight.Bold); // bold.StartIndex = (uint)span.Start; // bold.EndIndex = (uint)span.End; // attrList.Insert (bold); // if (!selected) { // var highlightColor = (selected) ? Styles.CodeCompletion.SelectionHighlightColor : Styles.CodeCompletion.HighlightColor; // var fg = new AttrForeground ((ushort)(highlightColor.Red * ushort.MaxValue), (ushort)(highlightColor.Green * ushort.MaxValue), (ushort)(highlightColor.Blue * ushort.MaxValue)); // fg.StartIndex = (uint)span.Start; // fg.EndIndex = (uint)span.End; // attrList.Insert (fg); // } // } // layout.Attributes = attrList; //} //TODO: Todd, can you sprinkle some magic on this to do //textView.GetTextBufferFromSpan(triggerSpan).GetMimeType() instead fixed text/csharp? Xwt.Drawing.Image icon = ImageService.GetIcon(RoslynCompletionData.GetIcon(item, "text/csharp")); int iconHeight, iconWidth; if (icon != null) { if (drawIconAsSelected) { icon = icon.WithStyles("sel"); } iconWidth = (int)icon.Width; iconHeight = (int)icon.Height; } else if (!Gtk.Icon.SizeLookup(IconSize.Menu, out iconWidth, out iconHeight)) { iconHeight = iconWidth = 24; } int wi, he, typos, iypos; layout.GetPixelSize(out wi, out he); typos = he < rowHeight ? ypos + (int)Math.Ceiling((rowHeight - he) / 2.0) : ypos; if (scalef <= 1.0) { typos -= 1; // 1px up on non HiDPI } iypos = iconHeight < rowHeight ? ypos + (rowHeight - iconHeight) / 2 : ypos; if (selected) { var barStyle = SelectionEnabled ? Styles.CodeCompletion.SelectionBackgroundColor : Styles.CodeCompletion.SelectionBackgroundInactiveColor; context.SetSourceColor(barStyle.ToCairoColor()); if (SelectionEnabled) { context.Rectangle(0, ypos, Allocation.Width, rowHeight); context.Fill(); } else { context.LineWidth++; context.Rectangle(0.5, ypos + 0.5, Allocation.Width - 1, rowHeight - 1); context.Stroke(); context.LineWidth--; } } if (icon != null) { context.DrawImage(this, icon, xpos, iypos); xpos += iconTextSpacing; } context.SetSourceColor((drawIconAsSelected ? Styles.CodeCompletion.SelectionTextColor : Styles.CodeCompletion.TextColor).ToCairoColor()); var textXPos = xpos + iconWidth + 2; context.MoveTo(textXPos, typos); layout.Width = (int)((Allocation.Width - textXPos) * Pango.Scale.PangoScale); layout.Ellipsize = EllipsizeMode.End; Pango.CairoHelper.ShowLayout(context, layout); int textW, textH; layout.GetPixelSize(out textW, out textH); layout.Width = -1; layout.Ellipsize = EllipsizeMode.None; layout.SetMarkup(""); if (layout.Attributes != null) { layout.Attributes.Dispose(); layout.Attributes = null; } string rightText = ""; //TODO: David DataProvider.GetRightSideDescription (index, drawIconAsSelected); if (!string.IsNullOrEmpty(rightText)) { layout.SetMarkup(rightText); int w, h; layout.GetPixelSize(out w, out h); const int leftpadding = 8; const int rightpadding = 3; w += rightpadding; w = Math.Min(w, Allocation.Width - textXPos - textW - leftpadding); wi += w; typos = h < rowHeight ? ypos + (rowHeight - h) / 2 : ypos; if (scalef <= 1.0) { typos -= 1; // 1px up on non HiDPI } context.MoveTo(Allocation.Width - w, typos); layout.Width = (int)(w * Pango.Scale.PangoScale); layout.Ellipsize = EllipsizeMode.End; Pango.CairoHelper.ShowLayout(context, layout); layout.Width = -1; layout.Ellipsize = EllipsizeMode.None; } if (Math.Min(maxListWidth, wi + xpos + iconWidth + 2) > listWidth) { box.WidthRequest = listWidth = Math.Min(maxListWidth, wi + xpos + iconWidth + 2 + iconTextSpacing); needsRefresh = true; } 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) { box.WidthRequest = listWidth + listWidth - Allocation.Width; needsRefresh = true; } } } return(true); }); if (needsRefresh) { QueueSpaceReservationStackRefresh(); } return(false); } }
protected override bool OnExposeEvent(Gdk.EventExpose args) { Rectangle area; //Console.WriteLine ("expose {0}", args.Area); foreach (Rectangle sub in args.Region.GetRectangles()) { if (sub.Intersect(background, out area)) { Rectangle active = background; int min_x = BoxX(min_limit.Position); int max_x = BoxX(max_limit.Position + 1); active.X = min_x; active.Width = max_x - min_x; if (active.Intersect(area, out active)) { GdkWindow.DrawRectangle(Style.BaseGC(State), true, active); } int i; BoxXHit(area.X, out i); int end; BoxXHit(area.X + area.Width, out end); while (i <= end) { DrawBox(area, i++); } } Style.PaintShadow(this.Style, GdkWindow, State, ShadowType.In, area, this, null, background.X, background.Y, background.Width, background.Height); if (sub.Intersect(legend, out area)) { int i = 0; while (i < box_counts.Length) { DrawTick(area, i++); } } if (has_limits) { if (min_limit != null) { min_limit.Draw(sub); } if (max_limit != null) { max_limit.Draw(sub); } } if (glass != null) { glass.Draw(sub); } } return(base.OnExposeEvent(args)); }
protected override bool OnExposeEvent (EventExpose evnt) { bool hideButton = widget.OriginalEditor.Document.ReadOnly || !widget.DiffEditor.Document.ReadOnly; using (Cairo.Context cr = Gdk.CairoHelper.Create (evnt.Window)) { int delta = widget.OriginalEditor.Allocation.Y - Allocation.Y; if (widget.Diff != null) { foreach (Diff.Hunk hunk in widget.Diff) { if (!hunk.Same) { int y1 = delta + widget.DiffEditor.LineToVisualY (hunk.Right.Start) - (int)widget.OriginalEditor.VAdjustment.Value; int y2 = delta + widget.DiffEditor.LineToVisualY (hunk.Right.Start + hunk.Right.Count) - (int)widget.OriginalEditor.VAdjustment.Value; if (y1 == y2) y2 = y1 + 1; int z1 = delta + widget.OriginalEditor.LineToVisualY (hunk.Left.Start) - (int)widget.DiffEditor.VAdjustment.Value; int z2 = delta + widget.OriginalEditor.LineToVisualY (hunk.Left.Start + hunk.Left.Count) - (int)widget.DiffEditor.VAdjustment.Value; if (z1 == z2) z2 = z1 + 1; cr.MoveTo (Allocation.Width, y1); cr.CurveTo (Allocation.Width / 2, y1, Allocation.Width / 2, z1, 0, z1); cr.LineTo (0, z2); cr.CurveTo (Allocation.Width / 2, z2, Allocation.Width / 2, y2, Allocation.Width, y2); cr.ClosePath (); cr.Color = GetColor (hunk, fillAlpha); cr.Fill (); cr.Color = GetColor (hunk, lineAlpha); cr.MoveTo (Allocation.Width, y1); cr.CurveTo (Allocation.Width / 2, y1, Allocation.Width / 2, z1, 0, z1); cr.Stroke (); cr.MoveTo (0, z2); cr.CurveTo (Allocation.Width / 2, z2, Allocation.Width / 2, y2, Allocation.Width, y2); cr.Stroke (); if (!hideButton) { bool isButtonSelected = selectedHunk != null && hunk.Left.Start == selectedHunk.Left.Start && hunk.Right.Start == selectedHunk.Right.Start; cr.Save (); int x, y, r; GetButtonPosition (hunk, z1, z2, y1, y2, out x, out y, out r); FoldingScreenbackgroundRenderer.DrawRoundRectangle (cr, true, true, x, y, r / 2, r, r); cr.Color = new Cairo.Color (1, 0, 0); cr.Fill (); FoldingScreenbackgroundRenderer.DrawRoundRectangle (cr, true, true, x + 1, y + 1, (r - 2) / 2, r - 2, r - 2); var shadowGradient = new Cairo.LinearGradient (x, y, x + r, y + r); if (isButtonSelected) { shadowGradient.AddColorStop (0, new Cairo.Color (1, 1, 1, 0)); shadowGradient.AddColorStop (1, new Cairo.Color (1, 1, 1, 0.8)); } else { shadowGradient.AddColorStop (0, new Cairo.Color (1, 1, 1, 0.8)); shadowGradient.AddColorStop (1, new Cairo.Color (1, 1, 1, 0)); } cr.Source = shadowGradient; cr.Fill (); cr.LineWidth = 2; cr.LineCap = Cairo.LineCap.Round; cr.Color = isButtonSelected ? new Cairo.Color (0.9, 0.9, 0.9) : new Cairo.Color (1, 1, 1); int a = 4; cr.MoveTo (x + a, y + a); cr.LineTo (x + r - a, y + r - a); cr.MoveTo (x + r - a, y + a); cr.LineTo (x + a, y + r - a); cr.Stroke (); cr.Restore (); } } } } } var result = base.OnExposeEvent (evnt); Gdk.GC gc = Style.DarkGC (State); evnt.Window.DrawLine (gc, Allocation.X, Allocation.Top, Allocation.X, Allocation.Bottom); evnt.Window.DrawLine (gc, Allocation.Right, Allocation.Top, Allocation.Right, Allocation.Bottom); evnt.Window.DrawLine (gc, Allocation.Left, Allocation.Y, Allocation.Right, Allocation.Y); evnt.Window.DrawLine (gc, Allocation.Left, Allocation.Bottom, Allocation.Right, Allocation.Bottom); return result; }
private void GdkDraw(EventExpose evnt,int height,int width) { Time time = new Time(); layout.SetMarkup("0"); this.GdkWindow.DrawLayout(this.Style.TextGC(StateType.Normal),0,height-23,layout); Gdk.Point topL= new Gdk.Point((int)(CurrentFrame/pixelRatio-Scroll-5),height-15); Gdk.Point topR= new Gdk.Point((int)(CurrentFrame/pixelRatio-Scroll+5),height-15); Gdk.Point bottom= new Gdk.Point((int)(CurrentFrame/pixelRatio-Scroll),height); this.GdkWindow.DrawPolygon(this.Style.TextGC(StateType.Normal),true,new Gdk.Point[] {topL,topR,bottom}); for(int i=10*FrameRate; i<=frames/pixelRatio;) { // Drawing separator line evnt.Window.DrawLine(Style.DarkGC(StateType.Normal),i-(int)Scroll,height,i-(int)Scroll,height-10); time.Seconds = (int)(i/FrameRate*pixelRatio); layout.SetMarkup(time.ToSecondsString()); this.GdkWindow.DrawLayout(this.Style.TextGC(StateType.Normal),i-(int)Scroll-13,height-23,layout); //g.ShowText(time.ToSecondsString()); i=i+10*FrameRate; } for(int i=0; i<=frames/pixelRatio;) { evnt.Window.DrawLine(Style.DarkGC(StateType.Normal),i-(int)Scroll,height,i-(int)Scroll,height-5); i=i+FrameRate; } // Drawing main line evnt.Window.DrawLine(Style.DarkGC(StateType.Normal),0,height,width,height); }
protected override bool OnExposeEvent (EventExpose evnt) { if (!IsRealized) return false; using (Cairo.Context cr = Gdk.CairoHelper.Create (evnt.Window)) { if (background_buffer == null) { if (Orientation == DockPosition.Bottom || Orientation == DockPosition.Top) { background_buffer = new DockySurface (allocation.Width, allocation.Height, cr.Target); } else { // switch width and height so we can rotate it later background_buffer = new DockySurface (allocation.Height, allocation.Width, cr.Target); } DrawBackground (background_buffer); } switch (Orientation) { case DockPosition.Top: cr.Scale (1, -1); cr.Translate (0, -background_buffer.Height); break; case DockPosition.Left: cr.Rotate (Math.PI * .5); cr.Translate (0, -background_buffer.Height); break; case DockPosition.Right: cr.Rotate (Math.PI * -0.5); cr.Translate (-background_buffer.Width, 0); break; } cr.Operator = Operator.Source; background_buffer.Internal.Show (cr, 0, 0); (cr.Target as IDisposable).Dispose (); } return base.OnExposeEvent (evnt); }
protected override bool OnExposeEvent (EventExpose evnt) { using (Cairo.Context cr = Gdk.CairoHelper.Create (evnt.Window)) { cr.LineWidth = 1; var alloc = Allocation; int right = alloc.RightInside (); int bottom = alloc.BottomInside (); cr.SharpLineX (alloc.X, alloc.Y, alloc.X, bottom); cr.SharpLineX (right, alloc.Y, right, bottom); cr.SharpLineY (alloc.X, alloc.Y, right, alloc.Y); cr.SharpLineY (alloc.X, bottom, right, bottom); cr.Color = Mono.TextEditor.Highlighting.ColorSheme.ToCairoColor (Style.Dark (State)); cr.Stroke (); } return base.OnExposeEvent (evnt); }
private void CairoDraw(EventExpose evnt,int height,int width) { Time time = new Time(); using(Cairo.Context g = Gdk.CairoHelper.Create(evnt.Window)) { Cairo.Color color = new Cairo.Color(0, 0, 0); /* Drawing position triangle */ CairoUtils.DrawTriangle(g,CurrentFrame/pixelRatio-Scroll, height, 10, 15, color); /* Draw '0' */ CairoUtils.DrawLine(g, 0-Scroll, height, width, height, 2, color); g.MoveTo(new PointD(0-Scroll,height-20)); g.ShowText("0"); for(int i=10*FrameRate; i<=frames/pixelRatio;) { CairoUtils.DrawLine(g, i-Scroll, height,i-Scroll, height-10, 2, color); g.MoveTo(new PointD(i-Scroll-13,height-20)); time.Seconds = (int)(i/FrameRate*pixelRatio); g.ShowText(time.ToSecondsString()); i=i+10*FrameRate; } for(int i=0; i<=frames/pixelRatio;) { CairoUtils.DrawLine(g, i-Scroll, height,i-Scroll, height-5, 1, color); i=i+FrameRate; } } }
protected override bool OnExposeEvent(Gdk.EventExpose e) { if (TextEditor == null) { return(true); } using (Cairo.Context cr = Gdk.CairoHelper.Create(e.Window)) { cr.LineWidth = 1; cr.Rectangle(0, 0, Allocation.Width, Allocation.Height); if (TextEditor.ColorStyle != null) { if (Platform.IsWindows) { using (var pattern = new Cairo.SolidPattern(win81Background)) { cr.SetSource(pattern); } } else { var col = TextEditor.ColorStyle.PlainText.Background.ToXwtColor(); col.Light *= 0.948; using (var grad = new Cairo.LinearGradient(0, 0, Allocation.Width, 0)) { grad.AddColorStop(0, col.ToCairoColor()); grad.AddColorStop(0.7, TextEditor.ColorStyle.PlainText.Background); grad.AddColorStop(1, col.ToCairoColor()); cr.SetSource(grad); } /* * var col = new Cairo.Color (229 / 255.0, 229 / 255.0, 229 / 255.0); * using (var grad = new Cairo.LinearGradient (0, 0, Allocation.Width, 0)) { * grad.AddColorStop (0, col); * grad.AddColorStop (0.5, new Cairo.Color (1, 1, 1)); * grad.AddColorStop (1, col); * cr.SetSource (grad); * }*/ } } cr.Fill(); if (TextEditor == null) { return(true); } if (TextEditor.HighlightSearchPattern) { DrawSearchResults(cr); DrawSearchIndicator(cr); } else { if (!Debugger.DebuggingService.IsDebugging) { var severity = DrawQuickTasks(cr); DrawIndicator(cr, severity); } } DrawCaret(cr); if (QuickTaskStrip.MergeScrollBarAndQuickTasks) { DrawBar(cr); } DrawLeftBorder(cr); } return(true); }
//draw the background protected override bool OnExposeEvent (EventExpose evnt) { if (logoPixbuf != null) { var gc = Style.BackgroundGC (State); var lRect = new Rectangle (Allocation.X, Allocation.Y, logoPixbuf.Width, logoPixbuf.Height); if (evnt.Region.RectIn (lRect) != OverlapType.Out) GdkWindow.DrawPixbuf (gc, logoPixbuf, 0, 0, lRect.X, lRect.Y, lRect.Width, lRect.Height, RgbDither.None, 0, 0); var bgRect = new Rectangle (Allocation.X + logoPixbuf.Width, Allocation.Y, Allocation.Width - logoPixbuf.Width, bgPixbuf.Height); if (evnt.Region.RectIn (bgRect) != OverlapType.Out) for (int x = bgRect.X; x < bgRect.Right; x += bgPixbuf.Width) GdkWindow.DrawPixbuf (gc, bgPixbuf, 0, 0, x, bgRect.Y, bgPixbuf.Width, bgRect.Height, RgbDither.None, 0, 0); } foreach (Widget widget in Children) PropagateExpose (widget, evnt); 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) ? MainClass.Languages.Translate("select") : 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; } 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(MainClass.Languages.Translate("no_suggestions")); 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; // Gdk.Pixbuf icon = MainClass.Tools.GetIconFromStock (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(int item, int ypos) { //Category curCategory, 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(EventExpose evnt) { if (!base.OnExposeEvent (evnt)) return false; if (!CanSelect || !CropHelpers || Selection == Rectangle.Zero) return false; using (Cairo.Context ctx = CairoHelper.Create (GdkWindow)) { ctx.SetSourceRGBA (.7, .7, .7, .8); ctx.SetDash (new double [] {10, 15}, 0); ctx.LineWidth = .8; for (int i=1; i<3; i++) { Point s = ImageCoordsToWindow (new Point (Selection.X + Selection.Width / 3 * i, Selection.Y)); Point e = ImageCoordsToWindow (new Point (Selection.X + Selection.Width / 3 * i, Selection.Y + Selection.Height)); ctx.MoveTo (s.X, s.Y); ctx.LineTo (e.X, e.Y); ctx.Stroke (); } for (int i=1; i<3; i++) { Point s = ImageCoordsToWindow (new Point (Selection.X, Selection.Y + Selection.Height / 3 * i)); Point e = ImageCoordsToWindow (new Point (Selection.X + Selection.Width, Selection.Y + Selection.Height / 3 * i)); ctx.MoveTo (s.X, s.Y); ctx.LineTo (e.X, e.Y); ctx.Stroke (); } } return true; }
protected override bool OnExposeEvent(Gdk.EventExpose args) { using (var context = Gdk.CairoHelper.Create(args.Window)) { context.LineWidth = 1; 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.SetSourceColor(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) { context.Rectangle(0, yPos, width, height - yPos); context.SetSourceColor(backgroundColor); context.Stroke(); noMatchLayout.SetText(win.DataProvider.ItemCount == 0 ? NoSuggestionsMsg : NoMatchesMsg); int lWidth, lHeight; noMatchLayout.GetPixelSize(out lWidth, out lHeight); context.SetSourceColor(textColor); context.MoveTo((width - lWidth) / 2, yPos + (height - lHeight - yPos) / 2 - lHeight); Pango.CairoHelper.ShowLayout(context, noMatchLayout); return(false); } 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.GetIcon(category.CompletionCategory.Icon, IconSize.Menu); context.DrawImage(this, icon, 0, ypos); x = (int)icon.Width + 4; } context.Rectangle(0, ypos, Allocation.Width, rowHeight); context.SetSourceColor(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); context.MoveTo(x, ypos + (rowHeight - py) / 2); context.SetSourceColor(textColor); Pango.CairoHelper.ShowLayout(context, 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, item == SelectedItem); if (string.IsNullOrEmpty(description)) { layout.SetMarkup(markup); } else { layout.SetMarkup(markup + " " + description); } 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; } } Xwt.Drawing.Image icon = win.DataProvider.GetIcon(item); int iconHeight, iconWidth; if (icon != null) { iconWidth = (int)icon.Width; iconHeight = (int)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.SetSourceColor(SelectionEnabled ? selectedItemColor.Foreground : selectedItemInactiveColor.Background); context.Fill(); context.Rectangle(0, ypos + rowHeight / 2, Allocation.Width, rowHeight / 2); context.SetSourceColor(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.SetSourceColor(SelectionEnabled ? selectionBorderColor : selectionBorderInactiveColor); context.Stroke(); } if (icon != null) { context.DrawImage(this, icon, xpos, iypos); xpos += iconTextSpacing; } context.SetSourceColor(textColor); var textXPos = xpos + iconWidth + 2; context.MoveTo(textXPos, typos); layout.Width = (int)((Allocation.Width - textXPos) * Pango.Scale.PangoScale); layout.Ellipsize = EllipsizeMode.End; Pango.CairoHelper.ShowLayout(context, layout); layout.Width = -1; layout.Ellipsize = EllipsizeMode.None; layout.SetMarkup(""); if (layout.Attributes != null) { layout.Attributes.Dispose(); layout.Attributes = null; } string rightText = win.DataProvider.GetRightSideDescription(item, item == SelectedItem); if (!string.IsNullOrEmpty(rightText)) { layout.SetMarkup(rightText); int w, h; layout.GetPixelSize(out w, out h); wi += w; typos = h < rowHeight ? ypos + (rowHeight - h) / 2 : ypos; context.MoveTo(Allocation.Width - w, typos); Pango.CairoHelper.ShowLayout(context, layout); } if (Math.Min(maxListWidth, wi + xpos + iconWidth + 2) > listWidth) { WidthRequest = listWidth = Math.Min(maxListWidth, 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(); } } } return(true); }); return(false); } }
protected override bool OnExposeEvent (EventExpose evnt) { using (var context = CairoHelper.Create (evnt.Window)) { Draw (context); } return base.OnExposeEvent (evnt); }
protected override bool OnExposeEvent(Gdk.EventExpose e) { Cairo.Context cr = Gdk.CairoHelper.Create(e.Window); Gdk.Rectangle area = e.Area; if (this.categories.Count == 0 || !string.IsNullOrEmpty(CustomMessage)) { Pango.Layout messageLayout = new Pango.Layout(this.PangoContext); messageLayout.Alignment = Pango.Alignment.Center; messageLayout.Width = (int)(Allocation.Width * 2 / 3 * Pango.Scale.PangoScale); if (!string.IsNullOrEmpty(CustomMessage)) { messageLayout.SetText(CustomMessage); } else { messageLayout.SetText(MonoDevelop.Core.GettextCatalog.GetString("There are no tools available for the current document.")); } cr.MoveTo(Allocation.Width * 1 / 6, 12); cr.SetSourceColor(Style.Text(StateType.Normal).ToCairoColor()); Pango.CairoHelper.ShowLayout(cr, messageLayout); messageLayout.Dispose(); ((IDisposable)cr).Dispose(); return(true); } var backColor = Style.Base(StateType.Normal).ToCairoColor(); cr.SetSourceColor(backColor); cr.Rectangle(area.X, area.Y, area.Width, area.Height); cr.Fill(); int xpos = (this.hAdjustement != null ? (int)this.hAdjustement.Value : 0); int vadjustment = (this.vAdjustement != null ? (int)this.vAdjustement.Value : 0); int ypos = -vadjustment; ToolboxWidgetCategory lastCategory = null; int lastCategoryYpos = 0; cr.LineWidth = 1; Iterate(ref xpos, ref ypos, (category, itemDimension) => { ProcessExpandAnimation(cr, lastCategory, lastCategoryYpos, backColor, area, ref ypos); if (!area.IntersectsWith(new Gdk.Rectangle(new Gdk.Point(xpos, ypos), itemDimension))) { return(true); } cr.Rectangle(xpos, ypos, itemDimension.Width, itemDimension.Height); cr.SetSourceColor(Ide.Gui.Styles.PadCategoryBackgroundColor.ToCairoColor()); cr.Fill(); if (lastCategory == null || lastCategory.IsExpanded || lastCategory.AnimatingExpand) { cr.MoveTo(xpos, ypos + 0.5); cr.LineTo(itemDimension.Width, ypos + 0.5); } cr.MoveTo(0, ypos + itemDimension.Height - 0.5); cr.LineTo(xpos + Allocation.Width, ypos + itemDimension.Height - 0.5); cr.SetSourceColor(MonoDevelop.Ide.Gui.Styles.PadCategoryBorderColor.ToCairoColor()); cr.Stroke(); headerLayout.SetMarkup(category.Text); int width, height; cr.SetSourceColor(MonoDevelop.Ide.Gui.Styles.PadCategoryLabelColor.ToCairoColor()); headerLayout.GetPixelSize(out width, out height); cr.MoveTo(xpos + CategoryLeftPadding, ypos + (double)(Math.Round((double)(itemDimension.Height - height) / 2))); Pango.CairoHelper.ShowLayout(cr, headerLayout); var img = category.IsExpanded ? discloseUp : discloseDown; cr.DrawImage(this, img, Allocation.Width - img.Width - CategoryRightPadding, ypos + Math.Round((itemDimension.Height - img.Height) / 2)); lastCategory = category; lastCategoryYpos = ypos + itemDimension.Height; return(true); }, (curCategory, item, itemDimension) => { if (!area.IntersectsWith(new Gdk.Rectangle(new Gdk.Point(xpos, ypos), itemDimension))) { return(true); } var icon = item.Icon; if (!icon.HasFixedSize) { var maxIconSize = Math.Min(itemDimension.Width, itemDimension.Height); var fittingIconSize = maxIconSize > 32 ? Xwt.IconSize.Large : maxIconSize > 16 ? Xwt.IconSize.Medium : Xwt.IconSize.Small; icon = item.Icon.WithSize(fittingIconSize); } if (item == SelectedItem) { icon = icon.WithStyles("sel"); cr.SetSourceColor(Style.Base(StateType.Selected).ToCairoColor()); cr.Rectangle(xpos, ypos, itemDimension.Width, itemDimension.Height); cr.Fill(); } if (listMode || !curCategory.CanIconizeItems) { cr.DrawImage(this, icon, xpos + ItemLeftPadding, ypos + Math.Round((itemDimension.Height - icon.Height) / 2)); layout.SetMarkup(item.Text); layout.Width = (int)((itemDimension.Width - ItemIconTextItemSpacing - iconSize.Width - ItemLeftPadding * 2) * Pango.Scale.PangoScale); layout.GetPixelSize(out var width, out var height); cr.SetSourceColor(Style.Text(item != SelectedItem ? StateType.Normal : StateType.Selected).ToCairoColor()); cr.MoveTo(xpos + ItemLeftPadding + iconSize.Width + ItemIconTextItemSpacing, ypos + Math.Round((double)(itemDimension.Height - height) / 2)); Pango.CairoHelper.ShowLayout(cr, layout); } else { cr.DrawImage(this, icon, xpos + Math.Round((itemDimension.Width - icon.Width) / 2), ypos + Math.Round((itemDimension.Height - icon.Height) / 2)); } if (item == mouseOverItem) { cr.SetSourceColor(Style.Dark(StateType.Prelight).ToCairoColor()); cr.Rectangle(xpos + 0.5, ypos + 0.5, itemDimension.Width - 1, itemDimension.Height - 1); cr.Stroke(); } return(true); }); ProcessExpandAnimation(cr, lastCategory, lastCategoryYpos, backColor, area, ref ypos); if (lastCategory != null && lastCategory.AnimatingExpand) { // Closing line when animating the last group of the toolbox cr.MoveTo(area.X, ypos + 0.5); cr.RelLineTo(area.Width, 0); cr.SetSourceColor(MonoDevelop.Ide.Gui.Styles.PadCategoryBorderColor.ToCairoColor()); cr.Stroke(); } ((IDisposable)cr).Dispose(); return(true); }
bool OnSelectionExposeEvent(EventExpose evnt) { if (selection == Rectangle.Zero) return false; Rectangle win_selection = ImageCoordsToWindow (selection); using (var evnt_region = evnt.Region.Copy ()) { using (Region r = new Region ()) { r.UnionWithRect (win_selection); evnt_region.Subtract (r); } using (Cairo.Context ctx = CairoHelper.Create (GdkWindow)) { ctx.SetSourceRGBA (.5, .5, .5, .7); CairoHelper.Region (ctx, evnt_region); ctx.Fill (); } } return true; }
protected override bool OnExposeEvent(Gdk.EventExpose e) { if (TextEditor == null) { return(true); } using (Cairo.Context cr = Gdk.CairoHelper.Create(e.Window)) { cr.LineWidth = 1; cr.Rectangle(0, 0, Allocation.Width, Allocation.Height); if (TextEditor.ColorStyle != null) { var col = (HslColor)TextEditor.ColorStyle.PlainText.Background; col.L *= 0.95; if (flatStyle) { using (var pattern = new Cairo.SolidPattern(col)) { cr.Pattern = pattern; } } else { using (var grad = new Cairo.LinearGradient(0, 0, Allocation.Width, 0)) { grad.AddColorStop(0, col); grad.AddColorStop(0.7, TextEditor.ColorStyle.PlainText.Background); grad.AddColorStop(1, col); cr.Pattern = grad; } } } cr.Fill(); /* * cr.Color = (HslColor)Style.Dark (State); * cr.MoveTo (-0.5, 0.5); * cr.LineTo (Allocation.Width, 0.5); * * cr.MoveTo (-0.5, Allocation.Height - 0.5); * cr.LineTo (Allocation.Width, Allocation.Height - 0.5); * cr.Stroke ();*/ if (TextEditor == null) { return(true); } if (TextEditor.HighlightSearchPattern) { DrawSearchResults(cr); DrawSearchIndicator(cr); } else { if (!Debugger.DebuggingService.IsDebugging) { var severity = DrawQuickTasks(cr); DrawIndicator(cr, severity); } } DrawCaret(cr); DrawBar(cr); DrawLeftBorder(cr); } return(true); }
protected override bool OnExposeEvent (EventExpose evnt) { using (var ctx = Gdk.CairoHelper.Create (GdkWindow)) { ctx.Rectangle (0, 0, Allocation.Width, Allocation.Height); using (var g = new Cairo.LinearGradient (0, 0, 0, Allocation.Height)) { g.AddColorStop (0, Styles.BreadcrumbBackgroundColor); g.AddColorStop (1, Styles.BreadcrumbGradientEndColor); ctx.SetSource (g); } ctx.Fill (); if (widths == null) return true; // Calculate the total required with, and the reduction to be applied in case it doesn't fit the available space bool widthReduced; var currentWidths = GetCurrentWidths (out widthReduced); // Render the paths int textTopPadding = topPadding + (height - textHeight) / 2; int xpos = leftPadding, ypos = topPadding; for (int i = 0; i < leftPath.Length; i++) { bool last = i == leftPath.Length - 1; // Reduce the item size when required int itemWidth = currentWidths [i]; int x = xpos; xpos += itemWidth; if (hoverIndex >= 0 && hoverIndex < Path.Length && leftPath [i] == Path [hoverIndex] && (menuVisible || pressed || hovering)) DrawButtonBorder (ctx, x - padding, itemWidth + padding + padding); int textOffset = 0; if (leftPath [i].DarkIcon != null) { int iy = (height - (int)leftPath [i].DarkIcon.Height) / 2 + topPadding; ctx.DrawImage (this, leftPath [i].DarkIcon, x, iy); textOffset += (int) leftPath [i].DarkIcon.Width + iconSpacing; } layout.Attributes = (i == activeIndex) ? boldAtts : null; layout.SetMarkup (GetFirstLineFromMarkup (leftPath [i].Markup)); ctx.Save (); // If size is being reduced, ellipsize it bool showText = true; if (widthReduced) { int w = itemWidth - textOffset; if (w > 0) { ctx.Rectangle (x + textOffset, textTopPadding, w, height); ctx.Clip (); } else showText = false; } else layout.Width = -1; if (showText) { // Text ctx.SetSourceColor (Styles.BreadcrumbTextColor.ToCairoColor ()); ctx.MoveTo (x + textOffset, textTopPadding); Pango.CairoHelper.ShowLayout (ctx, layout); } ctx.Restore (); if (!last) { xpos += arrowLeftPadding; if (leftPath [i].IsPathEnd) { Style.PaintVline (Style, GdkWindow, State, evnt.Area, this, "", ypos, ypos + height, xpos - arrowSize / 2); } else { int arrowH = Math.Min (height, arrowSize); int arrowY = ypos + (height - arrowH) / 2; DrawPathSeparator (ctx, xpos, arrowY, arrowH); } xpos += arrowSize + arrowRightPadding; } } int xposRight = Allocation.Width - rightPadding; for (int i = 0; i < rightPath.Length; i++) { // bool last = i == rightPath.Length - 1; // Reduce the item size when required int itemWidth = currentWidths [i + leftPath.Length]; xposRight -= itemWidth; xposRight -= arrowSize; int x = xposRight; if (hoverIndex >= 0 && hoverIndex < Path.Length && rightPath [i] == Path [hoverIndex] && (menuVisible || pressed || hovering)) DrawButtonBorder (ctx, x - padding, itemWidth + padding + padding); int textOffset = 0; if (rightPath [i].DarkIcon != null) { ctx.DrawImage (this, rightPath [i].DarkIcon, x, ypos); textOffset += (int) rightPath [i].DarkIcon.Width + padding; } layout.Attributes = (i == activeIndex) ? boldAtts : null; layout.SetMarkup (GetFirstLineFromMarkup (rightPath [i].Markup)); ctx.Save (); // If size is being reduced, ellipsize it bool showText = true; if (widthReduced) { int w = itemWidth - textOffset; if (w > 0) { ctx.Rectangle (x + textOffset, textTopPadding, w, height); ctx.Clip (); } else showText = false; } else layout.Width = -1; if (showText) { // Text ctx.SetSourceColor (Styles.BreadcrumbTextColor.ToCairoColor ()); ctx.MoveTo (x + textOffset, textTopPadding); Pango.CairoHelper.ShowLayout (ctx, layout); } ctx.Restore (); } ctx.MoveTo (0, Allocation.Height - 0.5); ctx.RelLineTo (Allocation.Width, 0); ctx.SetSourceColor (Styles.BreadcrumbBottomBorderColor); ctx.LineWidth = 1; ctx.Stroke (); } return true; }
protected override bool OnExposeEvent(Gdk.EventExpose e) { using (Cairo.Context cr = Gdk.CairoHelper.Create(e.Window)) { cr.LineWidth = Math.Max(1.0, widget.Editor.Options.Zoom); cr.Rectangle(leftSpacer, 0, Allocation.Width, Allocation.Height); cr.Color = new Cairo.Color(0.95, 0.95, 0.95); cr.Fill(); int startLine = widget.Editor.YToLine((int)widget.Editor.VAdjustment.Value); double startY = widget.Editor.LineToY(startLine); while (startLine > 1 && startLine < annotations.Count && annotations[startLine - 1] != null && annotations[startLine] != null && annotations[startLine - 1].Revision == annotations[startLine].Revision) { startLine--; startY -= widget.Editor.GetLineHeight(widget.Editor.Document.GetLine(startLine)); } double curY = startY - widget.Editor.VAdjustment.Value; int line = startLine; while (curY < Allocation.Bottom && line <= widget.Editor.LineCount) { double curStart = curY; // widget.JumpOverFoldings (ref line); int lineStart = line; int w = 0, w2 = 0, h = 16; Annotation ann = line <= annotations.Count ? annotations[line - 1] : null; if (ann != null) { do { widget.JumpOverFoldings(ref line); line++; } while (line <= annotations.Count && annotations[line - 1] != null && annotations[line - 1].Revision == ann.Revision); double nextY = widget.editor.LineToY(line) - widget.editor.VAdjustment.Value; if (highlightAnnotation != null && highlightAnnotation.Revision == ann.Revision && curStart <= highlightPositon && highlightPositon < nextY) { cr.Rectangle(leftSpacer, curStart + cr.LineWidth, Allocation.Width - leftSpacer, nextY - curStart - cr.LineWidth); cr.Color = new Cairo.Color(1, 1, 1); cr.Fill(); } layout.SetText(ann.Author); layout.GetPixelSize(out w, out h); e.Window.DrawLayout(Style.BlackGC, leftSpacer + margin, (int)(curY + (widget.Editor.LineHeight - h) / 2), layout); layout.SetText(TruncRevision(ann.Revision)); layout.GetPixelSize(out w2, out h); e.Window.DrawLayout(Style.BlackGC, Allocation.Width - w2 - margin, (int)(curY + (widget.Editor.LineHeight - h) / 2), layout); if (ann.HasDate) { string dateTime = ann.Date.ToShortDateString(); int middle = w + (Allocation.Width - margin * 2 - leftSpacer - w - w2) / 2; layout.SetText(dateTime); layout.GetPixelSize(out w, out h); e.Window.DrawLayout(Style.BlackGC, leftSpacer + margin + middle - w / 2, (int)(curY + (widget.Editor.LineHeight - h) / 2), layout); } curY = nextY; } else { curY += widget.Editor.GetLineHeight(line); line++; widget.JumpOverFoldings(ref line); } if (ann != null && line - lineStart > 1) { string msg = GetCommitMessage(lineStart); if (!string.IsNullOrEmpty(msg)) { msg = FormatMessage(msg); layout.SetText(msg); layout.Width = (int)(Allocation.Width * Pango.Scale.PangoScale); using (var gc = new Gdk.GC(e.Window)) { gc.RgbFgColor = Style.Dark(State); gc.ClipRectangle = new Rectangle(0, (int)curStart, Allocation.Width, (int)(curY - curStart)); e.Window.DrawLayout(gc, (int)(leftSpacer + margin), (int)(curStart + h), layout); } } } cr.Rectangle(0, curStart, leftSpacer, curY - curStart); if (ann != null && ann != locallyModified && !string.IsNullOrEmpty(ann.Author)) { double a; if (ann != null && (maxDate - minDate).TotalHours > 0) { a = 1 - (ann.Date - minDate).TotalHours / (maxDate - minDate).TotalHours; } else { a = 1; } HslColor color = new Cairo.Color(0.90, 0.90, 1); color.L = 0.4 + a / 2; color.S = 1 - a / 2; cr.Color = color; } else { cr.Color = ann != null ? new Cairo.Color(1, 1, 0) : new Cairo.Color(0.95, 0.95, 0.95); } cr.Fill(); if (ann != null) { cr.MoveTo(0, curY + 0.5); cr.LineTo(Allocation.Width, curY + 0.5); cr.Color = new Cairo.Color(0.6, 0.6, 0.6); cr.Stroke(); } } } return(true); }
protected override bool OnExposeEvent (EventExpose evnt) { Gdk.GC gc = Style.DarkGC (State); evnt.Window.DrawLine (gc, Allocation.X, Allocation.Top, Allocation.X, Allocation.Bottom); if (vScrollBar.Visible && hScrollBar.Visible) { evnt.Window.DrawLine (gc, Allocation.Right, Allocation.Top, Allocation.Right, Allocation.Y + Allocation.Height / 2); } else { evnt.Window.DrawLine (gc, Allocation.Right, Allocation.Top, Allocation.Right, Allocation.Bottom); } evnt.Window.DrawLine (gc, Allocation.Left, Allocation.Y, Allocation.Right, Allocation.Y); if (vScrollBar.Visible && hScrollBar.Visible) { evnt.Window.DrawLine (gc, Allocation.Left, Allocation.Bottom, Allocation.Left + Allocation.Width / 2 , Allocation.Bottom); } else { evnt.Window.DrawLine (gc, Allocation.Left, Allocation.Bottom, Allocation.Right, Allocation.Bottom); } /* if (vScrollBar.Visible && hScrollBar.Visible) { int vwidth = vScrollBar.Requisition.Width; int hheight = hScrollBar.Requisition.Height; evnt.Window.DrawRectangle (Style.BackgroundGC (State), true, Allocation.Right - vwidth, Allocation.Bottom - hheight, vwidth, hheight); }*/ return base.OnExposeEvent (evnt); }
protected override bool OnExposeEvent(Gdk.EventExpose args) { if (photo != null) { tags = photo.Tags; } if (tags == null) { return(base.OnExposeEvent(args)); } SetSizeRequest((thumbnail_size + TAG_ICON_VSPACING) * tags.Length, thumbnail_size); int tag_x = Allocation.X; int tag_y = Allocation.Y + (Allocation.Height - thumbnail_size) / 2; string [] names = new string [tags.Length]; int i = 0; foreach (Tag t in tags) { names [i++] = t.Name; Pixbuf icon = t.Icon; Category category = t.Category; while (icon == null && category != null) { icon = category.Icon; category = category.Category; } if (icon == null) { continue; } Pixbuf scaled_icon; if (icon.Width == thumbnail_size) { scaled_icon = icon; } else { scaled_icon = icon.ScaleSimple(thumbnail_size, thumbnail_size, InterpType.Bilinear); } FSpot.ColorManagement.ApplyScreenProfile(scaled_icon); scaled_icon.RenderToDrawable(GdkWindow, Style.WhiteGC, 0, 0, tag_x, tag_y, thumbnail_size, thumbnail_size, RgbDither.None, tag_x, tag_y); tag_x += thumbnail_size + TAG_ICON_VSPACING; } if (parent_tips != null) { parent_tips.SetTip(this, String.Join(", ", names), null); } return(base.OnExposeEvent(args)); }
protected override bool OnExposeEvent (EventExpose evnt) { base.OnExposeEvent (evnt); int winWidth, winHeight; this.GetSize (out winWidth, out winHeight); this.GdkWindow.DrawRectangle (this.Style.ForegroundGC (StateType.Insensitive), false, 0, 0, winWidth - 1, winHeight - 1); return false; }
protected override bool OnExposeEvent (EventExpose evnt) { Gdk.GC gc = Style.DarkGC (State); evnt.Window.DrawLine (gc, Allocation.X, Allocation.Top, Allocation.X, Allocation.Bottom); evnt.Window.DrawLine (gc, Allocation.Right, Allocation.Top, Allocation.Right, Allocation.Bottom); evnt.Window.DrawLine (gc, Allocation.Left, Allocation.Y, Allocation.Right, Allocation.Y); evnt.Window.DrawLine (gc, Allocation.Left, Allocation.Bottom, Allocation.Right, Allocation.Bottom); return base.OnExposeEvent (evnt); }
protected override bool OnExposeEvent (EventExpose evnt) { var ret = base.OnExposeEvent (evnt); if (image.Pixbuf != null) return ret; using (var cr = CairoHelper.Create (evnt.Window)) { cr.Rectangle (evnt.Region.Clipbox.X, evnt.Region.Clipbox.Y, evnt.Region.Clipbox.Width, evnt.Region.Clipbox.Height); cr.Clip (); var imgAlloc = image.Allocation; cr.Translate (imgAlloc.X, imgAlloc.Y); using (var layout = new Pango.Layout (PangoContext)) { layout.SetText (GettextCatalog.GetString ("No image")); layout.Width = (int)((imgAlloc.Width - 20) * Pango.Scale.PangoScale); layout.Wrap = Pango.WrapMode.WordChar; layout.Alignment = Pango.Alignment.Center; int pw, ph; layout.GetPixelSize (out pw, out ph); cr.MoveTo ((imgAlloc.Width - layout.Width / Pango.Scale.PangoScale) / 2, (imgAlloc.Height - ph) / 2); cr.Color = new Cairo.Color (0.5, 0.5, 0.5); cr.ShowLayout (layout); } CairoExtensions.RoundedRectangle (cr, 5, 5, imgAlloc.Width - 10, imgAlloc.Height - 10, 5); cr.LineWidth = 3; cr.Color = new Cairo.Color (0.8, 0.8, 0.8); cr.SetDash (new double[] { 12, 2 }, 0); cr.Stroke (); } return ret; }
protected override bool OnExposeEvent(Gdk.EventExpose args) { GdkWindow.DrawPolygon(redgc, false, arrow); GdkWindow.DrawPolygon(redgc, true, arrow); return(true); }
protected override bool OnExposeEvent (EventExpose evnt) { if (data == null) BuildData (); hostSpots.Clear (); int ytop = padding; int markerX = 3; int lx = markerX + MarkerWidth + 1; int tx = 250; int ty = ytop; int maxx = lx; int maxy = 0; DateTime initialTime = mainValue.TimeStamp; Cairo.Context ctx = CairoHelper.Create (GdkWindow); Gdk.GC gc = new Gdk.GC (GdkWindow); gc.RgbFgColor = Style.White; GdkWindow.DrawRectangle (gc, true, 0, 0, Allocation.Width, Allocation.Height); // Draw full time marker ctx.NewPath (); ctx.Rectangle (markerX, ytop + baseTime + 0.5, MarkerWidth/2, ((mainValue.Duration.TotalMilliseconds * scale) / 1000)); Mono.TextEditor.HslColor hsl = Style.Foreground (Gtk.StateType.Normal); hsl.L = 0.8; ctx.SetSourceColor (hsl); ctx.Fill (); // Draw values foreach (CounterValueInfo val in data) { DrawValue (ctx, gc, initialTime, ytop, lx, tx, ref ty, ref maxx, ref maxy, 0, val); } if (ty > maxy) maxy = ty; int totalms = (int) mainValue.Duration.TotalMilliseconds; int marks = (totalms / 1000) + 1; ctx.LineWidth = 1; gc.RgbFgColor = Style.Foreground (Gtk.StateType.Normal); for (int n=0; n<=marks; n++) { ctx.NewPath (); int y = ytop + (int) (n * scale) + baseTime; ctx.MoveTo (markerX, y + 0.5); ctx.LineTo (markerX + MarkerWidth, y + 0.5); ctx.SetSourceColor (Style.Foreground (Gtk.StateType.Normal).ToCairoColor ()); ctx.Stroke (); y += 2; layout.SetText (n + "s"); GdkWindow.DrawLayout (gc, markerX + 1, y + 2, layout); int tw, th; layout.GetPixelSize (out tw, out th); y += th; if (y > maxy) maxy = y; } ((IDisposable)ctx).Dispose (); maxy += padding; maxx += padding; if (lastHeight != maxy || lastWidth != maxx) { lastWidth = maxx; lastHeight = maxy; SetSizeRequest (maxx, maxy); } return true; }
//FIXME: respect damage regions not just the whole areas, and skip more work when possible protected override bool OnExposeEvent(Gdk.EventExpose evnt) { if (sections.Count == 0) { return(false); } var alloc = Allocation; int bw = (int)BorderWidth; double halfLineWidth = borderLineWidth / 2.0; int bw2 = bw * 2; int w = alloc.Width - bw2; int h = alloc.Height - bw2; using (var cr = CairoHelper.Create(evnt.Window)) { CairoHelper.Region(cr, evnt.Region); cr.Clip(); cr.Translate(alloc.X + bw, alloc.Y + bw); var borderCol = Convert(Style.Dark(StateType.Normal)); cr.SetSourceColor(borderCol); cr.Rectangle(halfLineWidth, halfLineWidth, w - borderLineWidth, h - borderLineWidth); cr.LineWidth = borderLineWidth; cr.Stroke(); cr.Translate(borderLineWidth, borderLineWidth); w = w - (2 * borderLineWidth); using (LinearGradient unselectedGrad = new LinearGradient(0, 0, 0, headerHeight), hoverGrad = new LinearGradient(0, 0, 0, headerHeight), selectedGrad = new LinearGradient(0, 0, 0, headerHeight) ) { var unselectedCol = Convert(Style.Mid(StateType.Normal)); var unselectedTextCol = Convert(Style.Text(StateType.Normal)); unselectedCol.A = 0.6; unselectedGrad.AddColorStop(0, unselectedCol); unselectedCol.A = 1; unselectedGrad.AddColorStop(1, unselectedCol); var hoverCol = Convert(Style.Mid(StateType.Prelight)); var hoverTextCol = Convert(Style.Text(StateType.Prelight)); hoverCol.A = 0.6; hoverGrad.AddColorStop(0, unselectedCol); hoverCol.A = 1; hoverGrad.AddColorStop(1, unselectedCol); var selectedCol = Convert(Style.Mid(StateType.Normal)); var selectedTextCol = Convert(Style.Text(StateType.Normal)); selectedCol.A = 0.6; selectedGrad.AddColorStop(0, selectedCol); selectedCol.A = 1; selectedGrad.AddColorStop(1, selectedCol); for (int i = 0; i < sections.Count; i++) { var section = sections[i]; bool isActive = activeIndex == i; bool isHover = hoverIndex == i; cr.Rectangle(0, 0, w, headerHeight); cr.SetSource(isActive? selectedGrad : (isHover? hoverGrad : unselectedGrad)); cr.Fill(); cr.SetSourceColor(isActive? selectedTextCol : (isHover? hoverTextCol : unselectedTextCol)); layout.SetText(section.Title); layout.Ellipsize = Pango.EllipsizeMode.End; layout.Width = (int)((w - headerPadding - headerPadding) * Pango.Scale.PangoScale); cr.MoveTo(headerPadding, headerPadding); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(-halfLineWidth, i > activeIndex? -halfLineWidth : headerHeight + halfLineWidth); cr.RelLineTo(w + borderLineWidth, 0.0); cr.SetSourceColor(borderCol); cr.Stroke(); cr.Translate(0, headerHeight + borderLineWidth); if (isActive) { cr.Translate(0, section.Child.Allocation.Height + borderLineWidth); } } } } PropagateExpose(sections[activeIndex].Child, evnt); return(true); // base.OnExposeEvent (evnt); }
protected override bool OnExposeEvent(EventExpose evnt) { using (var context = Gdk.CairoHelper.Create (evnt.Window)) { DrawBackground (context, Allocation, 15, State); var icon = GetIcon(); context.DrawImage (this, icon, Allocation.X + Math.Max (0, (Allocation.Width - icon.Width) / 2), Allocation.Y + Math.Max (0, (Allocation.Height - icon.Height) / 2)); } return base.OnExposeEvent (evnt); }
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); }