2003-12-30 22:09:42 +00:00
|
|
|
// Subclass.cs - Widget subclass Test
|
2002-12-25 00:36:00 +00:00
|
|
|
//
|
2003-12-30 22:09:42 +00:00
|
|
|
// Author: Mike Kestner <mkestner@ximian.com>
|
2002-12-25 00:36:00 +00:00
|
|
|
//
|
2003-12-30 22:09:42 +00:00
|
|
|
// (c) 2001-2003 Mike Kestner, Novell, Inc.
|
2002-12-25 00:36:00 +00:00
|
|
|
|
|
|
|
namespace GtkSamples {
|
|
|
|
|
|
|
|
using Gtk;
|
|
|
|
using GtkSharp;
|
|
|
|
using System;
|
|
|
|
using System.Drawing;
|
|
|
|
|
|
|
|
public class ButtonApp {
|
|
|
|
|
|
|
|
public static int Main (string[] args)
|
|
|
|
{
|
|
|
|
Application.Init ();
|
|
|
|
Window win = new Window ("Button Tester");
|
|
|
|
Button btn = new MyButton ();
|
|
|
|
win.Add (btn);
|
|
|
|
win.ShowAll ();
|
|
|
|
Application.Run ();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class MyButton : Gtk.Button {
|
|
|
|
|
2003-12-15 16:59:25 +00:00
|
|
|
static GLib.GType gtype = GLib.GType.Invalid;
|
2002-12-25 00:36:00 +00:00
|
|
|
|
2003-12-30 22:09:42 +00:00
|
|
|
public MyButton () : base (GType)
|
|
|
|
{
|
|
|
|
Label = "I'm a subclassed button";
|
|
|
|
}
|
2002-12-25 00:36:00 +00:00
|
|
|
|
2003-12-15 16:59:25 +00:00
|
|
|
public static new GLib.GType GType {
|
2002-12-25 00:36:00 +00:00
|
|
|
get {
|
2003-12-15 16:59:25 +00:00
|
|
|
if (gtype == GLib.GType.Invalid)
|
|
|
|
gtype = RegisterGType (typeof (MyButton));
|
2002-12-25 00:36:00 +00:00
|
|
|
return gtype;
|
|
|
|
}
|
|
|
|
}
|
2003-12-30 22:09:42 +00:00
|
|
|
|
|
|
|
protected override void OnClicked ()
|
|
|
|
{
|
|
|
|
Console.WriteLine ("Button::Clicked default handler fired.");
|
|
|
|
}
|
2002-12-25 00:36:00 +00:00
|
|
|
}
|
|
|
|
}
|