mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-09-09 00:13:20 +02:00
![Vladimir Vukicevic](/assets/img/avatar_default.png)
coming from Gtk (so can't use ref Gdk.Rectangle, have to use IntPtr) svn path=/trunk/gtk-sharp/; revision=28424
89 lines
3.8 KiB
Plaintext
89 lines
3.8 KiB
Plaintext
//
|
|
// CellRenderer.custom - Gtk CellRenderer class customizations
|
|
//
|
|
// Author: Todd Berman <tberman@sevenl.net>
|
|
//
|
|
// Copyright (C) 2004 Todd Berman
|
|
//
|
|
// This code is inserted after the automatically generated code.
|
|
//
|
|
|
|
public CellRenderer () : base (IntPtr.Zero)
|
|
{
|
|
if (GetType () != typeof (CellRenderer)) {
|
|
CreateNativeObject (new string[0], new GLib.Value[0]);
|
|
return;
|
|
}
|
|
throw new InvalidOperationException ("You MUST subclass this class");
|
|
}
|
|
|
|
[DllImport("gtksharpglue")]
|
|
static extern void gtksharp_cellrenderer_base_get_size (IntPtr handle, IntPtr widget, Gdk.Rectangle cell_area, out int x_offset, out int y_offset, out int width, out int height);
|
|
|
|
[DllImport("gtksharpglue")]
|
|
static extern void gtksharp_cellrenderer_override_get_size (GLib.GType gtype, GetSizeDelegate cb);
|
|
|
|
delegate void GetSizeDelegate (IntPtr item, IntPtr widget, IntPtr cell_area_ptr, IntPtr x_offset, IntPtr y_offset, IntPtr width, IntPtr height);
|
|
|
|
static GetSizeDelegate GetSizeCallback;
|
|
|
|
static void GetSize_cb (IntPtr item, IntPtr widget, IntPtr cell_area_ptr, IntPtr x_offset, IntPtr y_offset, IntPtr width, IntPtr height)
|
|
{
|
|
CellRenderer obj = GLib.Object.GetObject (item, false) as CellRenderer;
|
|
Gtk.Widget widg = GLib.Object.GetObject (widget, false) as Gtk.Widget;
|
|
Gdk.Rectangle cell_area = Gdk.Rectangle.New (cell_area_ptr);
|
|
int a, b, c, d;
|
|
|
|
obj.OnGetSize (widg, cell_area, out a, out b, out c, out d);
|
|
if (x_offset != IntPtr.Zero)
|
|
Marshal.WriteInt32 (x_offset, a);
|
|
if (y_offset != IntPtr.Zero)
|
|
Marshal.WriteInt32 (y_offset, b);
|
|
if (width != IntPtr.Zero)
|
|
Marshal.WriteInt32 (width, c);
|
|
if (height != IntPtr.Zero)
|
|
Marshal.WriteInt32 (height, d);
|
|
}
|
|
|
|
protected static void OverrideGetSize (GLib.GType gtype)
|
|
{
|
|
if (GetSizeCallback == null)
|
|
GetSizeCallback = new GetSizeDelegate (GetSize_cb);
|
|
gtksharp_cellrenderer_override_get_size (gtype, GetSizeCallback);
|
|
}
|
|
|
|
protected virtual void OnGetSize (Gtk.Widget widget, Gdk.Rectangle cell_area, out int x_offset, out int y_offset, out int width, out int height)
|
|
{
|
|
gtksharp_cellrenderer_base_get_size (Handle, widget.Handle, cell_area, out x_offset, out y_offset, out width, out height);
|
|
}
|
|
|
|
[DllImport("gtksharpglue")]
|
|
static extern void gtksharp_cellrenderer_base_render (IntPtr handle, IntPtr window, IntPtr widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, Gtk.CellRendererState flags);
|
|
|
|
[DllImport("gtksharpglue")]
|
|
static extern void gtksharp_cellrenderer_override_render (GLib.GType gtype, RenderDelegate cb);
|
|
|
|
delegate void RenderDelegate (IntPtr item, IntPtr window, IntPtr widget, ref Gdk.Rectangle background_area, ref Gdk.Rectangle cell_area, ref Gdk.Rectangle expose_area, Gtk.CellRendererState flags);
|
|
|
|
static RenderDelegate RenderCallback;
|
|
|
|
static void Render_cb (IntPtr item, IntPtr window, IntPtr widget, ref Gdk.Rectangle background_area, ref Gdk.Rectangle cell_area, ref Gdk.Rectangle expose_area, Gtk.CellRendererState flags)
|
|
{
|
|
CellRenderer obj = GLib.Object.GetObject (item, false) as CellRenderer;
|
|
Gdk.Drawable wind = GLib.Object.GetObject (window, false) as Gdk.Drawable;
|
|
Gtk.Widget widg = GLib.Object.GetObject (widget, false) as Gtk.Widget;
|
|
obj.OnRender (wind, widg, background_area, cell_area, expose_area, flags);
|
|
}
|
|
|
|
protected static void OverrideRender (GLib.GType gtype)
|
|
{
|
|
if (RenderCallback == null)
|
|
RenderCallback = new RenderDelegate (Render_cb);
|
|
gtksharp_cellrenderer_override_render (gtype, RenderCallback);
|
|
}
|
|
|
|
protected virtual void OnRender (Gdk.Drawable window, Gtk.Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, Gtk.CellRendererState flags)
|
|
{
|
|
gtksharp_cellrenderer_base_render (Handle, window.Handle, widget.Handle, background_area, cell_area, expose_area, flags);
|
|
}
|