public override object CreateContext (object backend) { Cairo.Surface sf = (Cairo.Surface) backend; CairoContextBackend ctx = new CairoContextBackend (1); ctx.Context = new Cairo.Context (sf); return ctx; }
public override void DrawTextLayout(object backend, TextLayout layout, double x, double y) { var be = (GtkTextLayoutBackendHandler.PangoBackend)Toolkit.GetBackend(layout); var pl = be.Layout; CairoContextBackend ctx = (CairoContextBackend)backend; ctx.Context.MoveTo(x, y); if (layout.Height <= 0) { Pango.CairoHelper.ShowLayout(ctx.Context, pl); } else { var lc = pl.LineCount; var scale = Pango.Scale.PangoScale; double h = 0; var fe = ctx.Context.FontExtents; var baseline = fe.Ascent / (fe.Ascent + fe.Descent); for (int i = 0; i < lc; i++) { var line = pl.Lines [i]; var ext = new Pango.Rectangle(); var extl = new Pango.Rectangle(); line.GetExtents(ref ext, ref extl); h += h == 0 ? (extl.Height / scale * baseline) : (extl.Height / scale); if (h > layout.Height) { break; } ctx.Context.MoveTo(x, y + h); Pango.CairoHelper.ShowLayoutLine(ctx.Context, line); } } }
public void DrawImage(object backend, object img, Rectangle srcRect, Rectangle destRect, double alpha) { CairoContextBackend ctx = (CairoContextBackend)backend; ctx.Context.Save(); ctx.Context.NewPath(); ctx.Context.Rectangle(destRect.X, destRect.Y, destRect.Width, destRect.Height); ctx.Context.Clip(); ctx.Context.Translate(destRect.X - srcRect.X, destRect.Y - srcRect.Y); double sx = destRect.Width / srcRect.Width; double sy = destRect.Height / srcRect.Height; ctx.Context.Scale(sx, sy); SetSourceImage(ctx.Context, img, 0, 0); alpha = alpha * ctx.GlobalAlpha; if (alpha == 1) { ctx.Context.Paint(); } else { ctx.Context.PaintWithAlpha(alpha); } ctx.Context.Restore(); }
public override void ModifyCTM(object backend, Matrix m) { CairoContextBackend gc = (CairoContextBackend)backend; Cairo.Matrix t = new Cairo.Matrix(m.M11, m.M12, m.M21, m.M22, m.OffsetX, m.OffsetY); gc.Context.Transform(t); }
public object Create(Context context) { CairoContextBackend c = (CairoContextBackend)WidgetRegistry.GetBackend(context); LayoutBackend b = new LayoutBackend(); b.Context = c; return(b); }
public object Create(ICanvasBackend canvas) { LayoutBackend b = new LayoutBackend(); CairoContextBackend ba = new CairoContextBackend(); ba.Context = SharedContext; b.Context = ba; return(b); }
public override void DrawImage(object backend, ImageDescription img, double x, double y) { CairoContextBackend ctx = (CairoContextBackend)backend; img.Alpha *= ctx.GlobalAlpha; var pix = (Xwt.GtkBackend.GtkImage)img.Backend; pix.Draw(ApplicationContext, ctx.Context, ctx.ScaleFactor, x, y, img); }
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) { 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 = Gdk.CairoHelper.Create (window); using (ctx) { CellView.Draw (ctx, new Rectangle (cell_area.X, cell_area.Y, cell_area.Width, cell_area.Height)); } }); Parent.EndDrawing (); }
public void DrawImage(object backend, object img, double x, double y, double alpha) { CairoContextBackend ctx = (CairoContextBackend)backend; SetSourceImage(ctx.Context, img, x, y); alpha = alpha * ctx.GlobalAlpha; if (alpha == 1) { ctx.Context.Paint(); } else { ctx.Context.PaintWithAlpha(alpha); } }
public override void DrawImage(object backend, ImageDescription img, Rectangle srcRect, Rectangle destRect) { CairoContextBackend ctx = (CairoContextBackend)backend; ctx.Context.Save(); ctx.Context.NewPath(); ctx.Context.Rectangle(destRect.X, destRect.Y, destRect.Width, destRect.Height); ctx.Context.Clip(); double sx = destRect.Width / srcRect.Width; double sy = destRect.Height / srcRect.Height; ctx.Context.Translate(destRect.X - srcRect.X * sx, destRect.Y - srcRect.Y * sy); ctx.Context.Scale(sx, sy); img.Alpha *= ctx.GlobalAlpha; var pix = (Xwt.GtkBackend.GtkImage)img.Backend; pix.Draw(ApplicationContext, ctx.Context, ctx.ScaleFactor, 0, 0, img); ctx.Context.Restore(); }
public void DrawImage(object backend, object img, double x, double y, double width, double height, double alpha) { CairoContextBackend ctx = (CairoContextBackend)backend; ctx.Context.Save(); var s = GetImageSize(img); double sx = ((double)width) / s.Width; double sy = ((double)height) / s.Height; ctx.Context.Translate(x, y); ctx.Context.Scale(sx, sy); SetSourceImage(ctx.Context, img, 0, 0); alpha = alpha * ctx.GlobalAlpha; if (alpha == 1) { ctx.Context.Paint(); } else { ctx.Context.PaintWithAlpha(alpha); } ctx.Context.Restore(); }
public override void ArcNegative(object backend, double xc, double yc, double radius, double angle1, double angle2) { CairoContextBackend gc = (CairoContextBackend)backend; gc.Context.ArcNegative(xc, yc, radius, angle1 * degrees, angle2 * degrees); }
public override void SetGlobalAlpha(object backend, double alpha) { CairoContextBackend gc = (CairoContextBackend)backend; gc.GlobalAlpha = alpha; }
public override void Translate(object backend, double tx, double ty) { CairoContextBackend gc = (CairoContextBackend)backend; gc.Context.Translate(tx, ty); }
public override void Rotate(object backend, double angle) { CairoContextBackend gc = (CairoContextBackend)backend; gc.Context.Rotate((angle * System.Math.PI) / 180); }
protected void OnDraw (Rectangle dirtyRect, CairoContextBackend context) { Backend.ApplicationContext.InvokeUserCode (delegate { using (context) { var r = new Rectangle (dirtyRect.X - context.Origin.X, dirtyRect.Y - context.Origin.Y, dirtyRect.Width, dirtyRect.Height); EventSink.OnDraw (context, r); } }); }
public override void Rectangle(object backend, double x, double y, double width, double height) { CairoContextBackend gc = (CairoContextBackend)backend; gc.Context.Rectangle(x, y, width, height); }
public void Draw (ApplicationContext actx, Cairo.Context ctx, double scaleFactor, double x, double y, ImageDescription idesc) { if (stockId != null) { ImageFrame frame = null; if (frames != null) frame = frames.FirstOrDefault (f => f.Width == (int) idesc.Size.Width && f.Height == (int) idesc.Size.Height && f.Scale == scaleFactor); if (frame == null) { frame = new ImageFrame (ImageHandler.CreateBitmap (stockId, idesc.Size.Width, idesc.Size.Height, scaleFactor), (int)idesc.Size.Width, (int)idesc.Size.Height, false); frame.Scale = scaleFactor; AddFrame (frame); } DrawPixbuf (ctx, frame.Pixbuf, x, y, idesc); } else if (drawCallback != null) { CairoContextBackend c = new CairoContextBackend (scaleFactor) { Context = ctx }; if (actx != null) { actx.InvokeUserCode (delegate { drawCallback (c, new Rectangle (x, y, idesc.Size.Width, idesc.Size.Height)); }); } else drawCallback (c, new Rectangle (x, y, idesc.Size.Width, idesc.Size.Height)); } else { DrawPixbuf (ctx, GetBestFrame (actx, scaleFactor, idesc.Size.Width, idesc.Size.Height, false), x, y, idesc); } }
public void Restore(object backend) { CairoContextBackend gc = (CairoContextBackend)backend; gc.Context.Restore(); }
public void Save(object backend) { CairoContextBackend gc = (CairoContextBackend)backend; gc.Context.Save(); }
public void ResetTransform(object backend) { CairoContextBackend gc = (CairoContextBackend)backend; gc.Context.IdentityMatrix(); }
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 override void CurveTo(object backend, double x1, double y1, double x2, double y2, double x3, double y3) { CairoContextBackend gc = (CairoContextBackend)backend; gc.Context.CurveTo(x1, y1, x2, y2, x3, y3); }
public override void MoveTo(object backend, double x, double y) { CairoContextBackend gc = (CairoContextBackend)backend; gc.Context.MoveTo(x, y); }
public override void SetStyles(object backend, StyleSet styles) { CairoContextBackend gc = (CairoContextBackend)backend; gc.Styles = styles; }
public void Draw(ApplicationContext actx, Cairo.Context ctx, double scaleFactor, double x, double y, ImageDescription idesc) { if (stockId != null) { Gdk.Pixbuf img = null; if (frames != null) img = frames.FirstOrDefault (p => p.Width == (int) idesc.Size.Width && p.Height == (int) idesc.Size.Height); if (img == null) { img = ImageHandler.CreateBitmap (stockId, idesc.Size.Width, idesc.Size.Height); AddFrame (img); } DrawPixbuf (ctx, img, x, y, idesc); } else if (drawCallback != null) { CairoContextBackend c = new CairoContextBackend (scaleFactor) { Context = ctx }; actx.InvokeUserCode (delegate { drawCallback (c, new Rectangle (x, y, idesc.Size.Width, idesc.Size.Height)); }); } else { DrawPixbuf (ctx, GetBestFrame (actx, scaleFactor, idesc.Size.Width, idesc.Size.Height, false), x, y, idesc); } }
public override object Create(ICanvasBackend canvas) { LayoutBackend b = new LayoutBackend (); CairoContextBackend ba = new CairoContextBackend (); ba.Context = SharedContext; b.Context = ba; return b; }
public override double GetScaleFactor(object backend) { CairoContextBackend gc = (CairoContextBackend)backend; return(gc.ScaleFactor); }
public override void Save(object backend) { CairoContextBackend gc = (CairoContextBackend)backend; gc.Save(); }
public override void Scale(object backend, double scaleX, double scaleY) { CairoContextBackend gc = (CairoContextBackend)backend; gc.Context.Scale(scaleX, scaleY); }
public override void Restore(object backend) { CairoContextBackend gc = (CairoContextBackend)backend; gc.Restore(); }
public CairoContextBackend CreateContext() { CairoContextBackend ctx = new CairoContextBackend (); 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; }
public void LineTo(object backend, double x, double y) { CairoContextBackend gc = (CairoContextBackend)backend; gc.Context.LineTo(x, y); }