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 System;
|
|
|
|
|
|
|
|
public class ButtonApp {
|
|
|
|
|
|
|
|
public static int Main (string[] args)
|
|
|
|
{
|
|
|
|
Application.Init ();
|
|
|
|
Window win = new Window ("Button Tester");
|
2004-02-02 21:32:54 +00:00
|
|
|
win.DeleteEvent += new DeleteEventHandler (Quit);
|
2002-12-25 00:36:00 +00:00
|
|
|
Button btn = new MyButton ();
|
|
|
|
win.Add (btn);
|
|
|
|
win.ShowAll ();
|
|
|
|
Application.Run ();
|
|
|
|
return 0;
|
|
|
|
}
|
2004-02-02 21:32:54 +00:00
|
|
|
|
|
|
|
static void Quit (object sender, DeleteEventArgs args)
|
|
|
|
{
|
|
|
|
Application.Quit();
|
|
|
|
}
|
2002-12-25 00:36:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|