public override object GetBackendForContext(object nativeWidget, object nativeContext) { Gtk.Widget w = (Gtk.Widget)nativeWidget; return(new CairoContextBackend(Util.GetScaleFactor(w)) { Context = (Cairo.Context)nativeContext }); }
protected override bool OnDrawn(Cairo.Context cr) { var a = Allocation; // ensure cr does not get disposed before it is passed back to Gtk var context = new TempCairoContextBackend(Util.GetScaleFactor(this)); context.Context = cr; OnDraw(new Rectangle(a.X, a.Y, a.Width, a.Height), context); return(base.OnDrawn(cr)); }
protected override void OnRender(Cairo.Context cr, Gtk.Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, CellRendererState flags) { if (image.IsNull) { return; } var pix = ((GtkImage)image.Backend); pix.Draw(Context, cr, Util.GetScaleFactor(widget), cell_area.X, cell_area.Y, image); }
protected override void Render(Gdk.Drawable window, Gtk.Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, Gtk.CellRendererState flags) { cellView.ApplicationContext.InvokeUserCode(delegate { CairoContextBackend ctx = new CairoContextBackend(Util.GetScaleFactor(widget)); ctx.Context = Gdk.CairoHelper.Create(window); using (ctx) { cellView.Draw(ctx, new Rectangle(cell_area.X, cell_area.Y, cell_area.Width, cell_area.Height)); } }); }
public override void RenderImage(object nativeWidget, object nativeContext, ImageDescription img, double x, double y) { GtkImage gim = (GtkImage)img.Backend; Cairo.Context ctx = nativeContext as Cairo.Context; Gtk.Widget w = (Gtk.Widget)nativeWidget; if (ctx != null) { gim.Draw(ApplicationContext, ctx, Util.GetScaleFactor(w), x, y, img); } }
protected override void OnRender(Cairo.Context cr, Gtk.Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, CellRendererState flags) { Parent.StartDrawing(new Rectangle(background_area.X, background_area.Y, background_area.Width, background_area.Height), new Rectangle(cell_area.X, cell_area.Y, cell_area.Width, cell_area.Height), flags); CellView.ApplicationContext.InvokeUserCode(delegate { CairoContextBackend ctx = new CairoContextBackend(Util.GetScaleFactor(widget)); ctx.Context = cr; using (ctx) { CellView.Draw(ctx, new Rectangle(cell_area.X, cell_area.Y, cell_area.Width, cell_area.Height)); } }); Parent.EndDrawing(); }
protected override void OnRender(Cairo.Context cr, Gtk.Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, CellRendererState flags) { if (image.IsNull) { return; } var pix = ((GtkImage)image.Backend); int x_offset, y_offset, width, height; this.GetSize(widget, ref cell_area, out x_offset, out y_offset, out width, out height); pix.Draw(Context, cr, Util.GetScaleFactor(widget), cell_area.X + x_offset, cell_area.Y + y_offset, image); }
protected override void Render(Gdk.Drawable window, Gtk.Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, Gtk.CellRendererState flags) { if (image.IsNull) { return; } var ctx = Gdk.CairoHelper.Create(window); using (ctx) { var pix = ((GtkImage)image.Backend); pix.Draw(actx, ctx, Util.GetScaleFactor(widget), cell_area.X, cell_area.Y, image); } }
protected override bool OnDrawn(Cairo.Context cr) { // ensure cr does not get disposed before it is passed back to Gtk var context = new TempCairoContextBackend(Util.GetScaleFactor(this)); context.Context = cr; // Set context Origin from initial Cairo CTM (to ensure new Xwt CTM is Identity Matrix) context.Origin.X = cr.Matrix.X0; context.Origin.Y = cr.Matrix.Y0; // Gtk3 Cairo Context cannot access area to be redrawn, so use full Canvas area. // QueueDraw (rect) sets Clip (rect) internally, so drawing is limited correctly OnDraw(new Rectangle(0, 0, Allocation.Width, Allocation.Height), context); return(base.OnDrawn(cr)); }
public CairoContextBackend CreateContext() { CairoContextBackend ctx = new CairoContextBackend(Util.GetScaleFactor(this)); if (!IsRealized) { Cairo.Surface sf = new Cairo.ImageSurface(Cairo.Format.ARGB32, 1, 1); Cairo.Context c = new Cairo.Context(sf); ctx.Context = c; ctx.TempSurface = sf; } else { ctx.Context = Gdk.CairoHelper.Create(GdkWindow); } return(ctx); }
protected override void OnRender(Cairo.Context cr, Gtk.Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, CellRendererState flags) { if (image.IsNull) { return; } var pix = ((GtkImage)image.Backend); /* INTRODUCED BY Antmicro */ // draws icon centered var x = cell_area.X + (cell_area.Width - image.Size.Width) / 2; var y = cell_area.Y + (cell_area.Height - image.Size.Height) / 2; /* INTRODUCED BY Antmicro */ pix.Draw(Context, cr, Util.GetScaleFactor(widget), x, y, image); }
protected override bool OnDrawn(Cairo.Context cr) { if (image.IsNull) { return(true); } int x = (int)(((float)Allocation.Width - (float)image.Size.Width) * xalign); int y = (int)(((float)Allocation.Height - (float)image.Size.Height) * yalign); if (x < 0) { x = 0; } if (y < 0) { y = 0; } ((GtkImage)image.Backend).Draw(actx, cr, Util.GetScaleFactor(this), x, y, image); return(base.OnDrawn(cr)); }
protected override bool OnExposeEvent(Gdk.EventExpose evnt) { if (image.IsNull) { return(true); } int x = Allocation.X + (int)(((float)Allocation.Width - (float)image.Size.Width) * xalign); int y = Allocation.Y + (int)(((float)Allocation.Height - (float)image.Size.Height) * yalign); if (x < 0) { x = 0; } if (y < 0) { y = 0; } using (var ctx = Gdk.CairoHelper.Create(GdkWindow)) { ((GtkImage)image.Backend).Draw(actx, ctx, Util.GetScaleFactor(this), x, y, image); return(true); } }
protected override void OnRender(Cairo.Context cr, Gtk.Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, CellRendererState flags) { if (image.IsNull) { return; } var img = image; if ((flags & CellRendererState.Selected) != 0) { img = new ImageDescription { Backend = img.Backend, Size = img.Size, Alpha = img.Alpha, Styles = img.Styles.Add("sel") }; } var pix = ((GtkImage)img.Backend); int x_offset, y_offset, width, height; this.GetSize(widget, ref cell_area, out x_offset, out y_offset, out width, out height); pix.Draw(Context, cr, Util.GetScaleFactor(widget), cell_area.X + x_offset, cell_area.Y + y_offset, img); }
public CairoContextBackend CreateContext() { CairoContextBackend ctx = new CairoContextBackend(Util.GetScaleFactor(this)); if (!IsRealized) { Cairo.Surface sf = new Cairo.ImageSurface(Cairo.Format.ARGB32, 1, 1); Cairo.Context c = new Cairo.Context(sf); ctx.Context = c; ctx.TempSurface = sf; } else { ctx.Context = Gdk.CairoHelper.Create(GdkWindow); } if (!VisibleWindow) { ctx.Context.Translate(Allocation.X, Allocation.Y); // Set ContextBackend Origin ctx.Origin.X = Allocation.X; ctx.Origin.Y = Allocation.Y; } return(ctx); }
public Gdk.Pixbuf GetBestFrame(ApplicationContext actx, Gtk.Widget w, ImageDescription idesc, bool forceExactSize) { return(GetBestFrame(actx, Util.GetScaleFactor(w), idesc, forceExactSize)); }
public Gdk.Pixbuf GetBestFrame(ApplicationContext actx, Gtk.Widget w, double width, double height, bool forceExactSize) { return(GetBestFrame(actx, Util.GetScaleFactor(w), new ImageDescription { Alpha = 1, Size = new Size(width, height) }, forceExactSize)); }
public Gdk.Pixbuf ToPixbuf(ApplicationContext actx, Gtk.Widget w) { return(GetBestFrame(actx, Util.GetScaleFactor(w), DefaultSize.Width, DefaultSize.Height, true)); }
public Gdk.Pixbuf GetBestFrame(ApplicationContext actx, Gtk.Widget w, double width, double height, bool forceExactSize) { return(GetBestFrame(actx, Util.GetScaleFactor(w), width, height, forceExactSize)); }