void HandleDrawn(object o, Gtk.DrawnArgs args) { using (var graphics = new Graphics(Widget.Generator, new GraphicsHandler(args.Cr, Control.CreatePangoContext(), false))) { Rectangle rect = new Rectangle(this.Size); //ev.Region.Clipbox.ToEto (); Widget.OnPaint(new PaintEventArgs(graphics, rect)); } }
void HandleDrawn(object o, Gtk.DrawnArgs args) { var gc = Widget.StyleContext.GetBackgroundColor(Widget.StateFlags); args.Cr.Rectangle(0, 0, Widget.Allocation.Width, Widget.Allocation.Height); args.Cr.SetSourceColor(gc.ToCairoColor()); args.Cr.Fill(); }
public void HandleDrawn(object o, Gtk.DrawnArgs args) { var h = Handler; using (var graphics = new Graphics(new GraphicsHandler(args.Cr, h.Control.CreatePangoContext(), false))) { h.Callback.OnPaint(h.Widget, new PaintEventArgs(graphics, new Rectangle(h.Size))); } }
public void HandleDrawn(object o, Gtk.DrawnArgs args) { var h = Handler; var handler = new GraphicsHandler(args.Cr, h.Control.CreatePangoContext(), false); #endif using (var graphics = new Graphics(handler)) { var widgetSize = new Size(h.Control.Allocation.Width, h.Control.Allocation.Height); var imageSize = (SizeF)h.image.Size; var scaleWidth = widgetSize.Width / imageSize.Width; var scaleHeight = widgetSize.Height / imageSize.Height; imageSize *= Math.Min(scaleWidth, scaleHeight); var location = new PointF((widgetSize.Width - imageSize.Width) / 2, (widgetSize.Height - imageSize.Height) / 2); var destRect = new Rectangle(Point.Round(location), Size.Truncate(imageSize)); graphics.DrawImage(h.image, destRect); } }
public void HandleDrawn(object o, Gtk.DrawnArgs args) { var h = Handler; var allocation = h.Control.Allocation.Size; args.Cr.Rectangle(new Cairo.Rectangle(0, 0, allocation.Width, allocation.Height)); args.Cr.Clip(); Gdk.Rectangle rect = new Gdk.Rectangle(); if (!GraphicsHandler.GetClipRectangle(args.Cr, ref rect)) { rect = new Gdk.Rectangle(Gdk.Point.Zero, allocation); } #if old using (var graphics = new Graphics(new GraphicsHandler(args.Cr, h.Control.CreatePangoContext(), false))) { if (h.SelectedBackgroundColor != null) { graphics.Clear(h.SelectedBackgroundColor.Value); } h.Callback.OnPaint(h.Widget, new PaintEventArgs(graphics, rect.ToEto())); } #else //CreatePangoContext - creates a new one each time. local owned //GetPangoContext - gets a context owned by the control // only get the pango context once, using a context owned by the widget if (Pcontext == null) { Pcontext = h.Control.GetPangoContext(); } using (var graphics = new Graphics(new GraphicsHandler(args.Cr, Pcontext, false))) { if (h.SelectedBackgroundColor != null) { graphics.Clear(h.SelectedBackgroundColor.Value); } h.Callback.OnPaint(h.Widget, new PaintEventArgs(graphics, rect.ToEto())); } #endif }
void DrawOverlay(System.Object o, Gtk.DrawnArgs args) { var imageViewWidget = this.drawingArea as ImageViewWidget; if (imageViewWidget == null || imageViewWidget.Image == null || !this.IsActive || !this.UpdateFade(imageViewWidget)) { return; } this.canvasSize = new Cairo.PointD(this.drawingArea.Allocation.Width, this.drawingArea.Allocation.Height); var image = imageViewWidget.Image; bool redrawOverlay = this.canvasSize.X != this.lastCanvasSize.X || this.canvasSize.Y != this.lastCanvasSize.Y || image != this.lastImage || image.NeedsOverlayRedrawn; if (redrawOverlay) { var overlaySurface = new Cairo.ImageSurface(Cairo.Format.ARGB32, (int)this.canvasSize.X, (int)this.canvasSize.Y); var overlayCr = new Cairo.Context(overlaySurface); this.RedrawOverlay(overlayCr, image); overlayCr.Dispose(); if (this.overlaySurface != null) { this.overlaySurface.Dispose(); } this.overlaySurface = overlaySurface; image.NeedsOverlayRedrawn = false; } args.Cr.SetSourceSurface(this.overlaySurface, 0, 0); args.Cr.PaintWithAlpha(this.currentFadeOpacity); this.lastCanvasSize = this.canvasSize; this.lastImage = image; }
public void HandleDrawn(object o, Gtk.DrawnArgs args) { var h = Handler; var allocation = h.Control.Allocation.Size; args.Cr.Rectangle(new Cairo.Rectangle(0, 0, allocation.Width, allocation.Height)); args.Cr.Clip(); Gdk.Rectangle rect = new Gdk.Rectangle(); if (!GraphicsHandler.GetClipRectangle(args.Cr, ref rect)) { rect = new Gdk.Rectangle(Gdk.Point.Zero, allocation); } using (var graphics = new Graphics(new GraphicsHandler(args.Cr, h.Control.PangoContext, false))) { if (h.SelectedBackgroundColor != null) { graphics.Clear(h.SelectedBackgroundColor.Value); } h.Callback.OnPaint(h.Widget, new PaintEventArgs(graphics, rect.ToEto())); } }
static bool DrawnSignalCallback (IntPtr inst, IntPtr arg0, IntPtr gch) { Gtk.DrawnArgs args = new Gtk.DrawnArgs (); Cairo.Context cr = null; try { GLib.Signal sig = ((GCHandle) gch).Target as GLib.Signal; if (sig == null) throw new Exception("Unknown signal GC handle received " + gch); args.Args = new object[1]; cr = new Cairo.Context (arg0, false); args.Args[0] = cr; Gtk.DrawnHandler handler = (Gtk.DrawnHandler) sig.Handler; handler (GLib.Object.GetObject (inst), args); } catch (Exception e) { GLib.ExceptionManager.RaiseUnhandledException (e, false); } finally { var disposable_cr = cr as IDisposable; if (disposable_cr != null) disposable_cr.Dispose (); } try { if (args.RetVal == null) return false; return ((bool) args.RetVal); } catch (Exception) { Exception ex = new Exception ("args.RetVal or 'out' property unset or set to incorrect type in Gtk.DrawnHandler callback"); GLib.ExceptionManager.RaiseUnhandledException (ex, true); // NOTREACHED: above call doesn't return. throw ex; } }