rendered paste body public class BetterCheckButton : Gtk.MenuItem
{
bool active;
static int indicator_size = 13;
static int indicator_spacing = 2;
#region Constructors
public BetterCheckButton () : base ()
{
active = false;
SetSizeRequest (indicator_size + indicator_spacing,
indicator_size + indicator_spacing);
}
#endregion // Constructors
#region Properties
public bool Active
{
get { return active; }
set {
this.Toggle ();
}
}
#endregion // Properties
#region Private Methods
void Paint (Gdk.Rectangle area)
{
int x;
int y;
Widget child;
Gtk.ShadowType shadow_type;
Gtk.StateType state_type;
x = Allocation.X + indicator_spacing + (int) BorderWidth;
y = Allocation.Y + (Allocation.Height - indicator_size) / 2;
child = this.Child;
if (active) {
shadow_type = Gtk.ShadowType.EtchedIn;
state_type = Gtk.StateType.Insensitive;
} else {
shadow_type = Gtk.ShadowType.EtchedOut;
state_type = Gtk.StateType.Normal;
}
Gtk.Style.PaintCheck (Style, GdkWindow,
state_type, shadow_type,
area, this, "checkbutton",
x, y, indicator_size, indicator_size);
}
protected override bool OnExposeEvent (Gdk.EventExpose evnt)
{
Paint (evnt.Area);
return false;
}
protected override void OnToggled ()
{
active = !active;
}
#endregion // Private Methods
}