internal void StartDrawing(Rectangle ba, Rectangle ca, Gtk.CellRendererState flags) { this.cellArea = ca; this.backgroundArea = ba; isSelected = (flags & Gtk.CellRendererState.Selected) != 0; hasFocus = (flags & Gtk.CellRendererState.Focused) != 0; isDrawing = true; }
internal void StartDrawing(Rectangle ba, Rectangle ca, Gtk.CellRendererState flags) { this.cellArea = ca; this.backgroundArea = ba; isSelected = (flags & CellRendererState.Selected) != 0; hasFocus = (flags & CellRendererState.Focused) != 0; isPrelit = (flags & CellRendererState.Prelit) != 0; // Gtk will rerender the cell on every status change, hence we can expect the values // set here to be valid until the geometry or any other status of the cell and tree changes. // Setting shown=true ensures that those values are always reused instead if queried // from the parent tree after the cell has been rendered. shown = true; }
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) { base.Render(window, widget, background_area, cell_area, expose_area, flags); if (text_layout == null) { UpdateLayout(widget); } int x, y, width, height; /* first render the text */ text_layout.GetPixelSize(out var text_width, out var text_height); x = (int)(cell_area.X + Xpad + Math.Max((int)(Xalign * (cell_area.Width - 2 * Xpad - text_width)), 0)); y = (int)(cell_area.Y + Ypad); Style.PaintLayout(widget.Style, window, StateType.Normal, true, cell_area, widget, "cellrenderertextprogress", x, y, text_layout); y += (int)(text_height + Ypad); x = (int)(cell_area.X + Xpad + Math.Max((int)(Xalign * (cell_area.Width - 2 * Xpad - progress_width)), 0)); /* second render the progress bar */ using (Cairo.Context cairo_context = Gdk.CairoHelper.Create(window)) { width = progress_width; height = progress_height; cairo_context.Rectangle(x, y, width, height); Gdk.CairoHelper.SetSourceColor(cairo_context, widget.Style.Dark(StateType.Normal)); cairo_context.Fill(); x += widget.Style.XThickness; y += widget.Style.XThickness; width -= 2 * widget.Style.XThickness; height -= 2 * widget.Style.Ythickness; cairo_context.Rectangle(x, y, width, height); Gdk.CairoHelper.SetSourceColor(cairo_context, widget.Style.Light(StateType.Normal)); cairo_context.Fill(); /* scale the value and ensure, that at least one pixel is drawn, if the value is greater than zero */ int scaled_width = (int)Math.Max(((progress_value * width) / 100.0), (progress_value == 0)? 0 : 1); cairo_context.Rectangle(x, y, scaled_width, height); Gdk.CairoHelper.SetSourceColor(cairo_context, GetValueColor()); cairo_context.Fill(); } }
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 void Render(Gdk.Drawable drawable, Gtk.Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, Gtk.CellRendererState flags) { if (_ImageRow && _pixbuf == null) { return; } Gdk.Rectangle pix_rect = Gdk.Rectangle.Zero; this.GetSize(widget, ref cell_area, out pix_rect.X, out pix_rect.Y, out pix_rect.Width, out pix_rect.Height); // Take care of padding pix_rect.X += cell_area.X + (int)this.Xpad; pix_rect.Y += cell_area.Y + (int)this.Ypad; // Remove left, right, top and buttom borders which were added to the returned width pix_rect.Width -= (int)this.Xpad * 2; pix_rect.Height -= (int)this.Ypad * 2; Cairo.Context context = Gdk.CairoHelper.Create(drawable); context.Translate(pix_rect.X, pix_rect.Y); if (_ImageRow) { RenderImage(context, pix_rect.Height); } else { RenderDoc(context, widget, pix_rect.Height); } (context as System.IDisposable).Dispose(); }
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(); }