GtkSharp/gtk/Button.cs
Mike Kestner 91c58501fa 2001-09-19 Mike Kestner <mkestner@speakeasy.net>
* HACKING : New rulez.
	* NOTES: Killed.  We have a mailing list now for this kind of stuff.
	* glib/makefile : New, to build the new glib-sharp.dll target.
	* glib/Object.cs : (GetObject): Commented out. Design problems here.
	IntPtr's can't be used in the manner this code attempts to use them.
	(Data prop): Commented out.  Apparently keyed properties are not
	supported.
	(Object prop): Renamed RawObject, and made it protected.
	(Events): Fixed to cause list to be initialized if null and then
	return the list.
	* glib/ObjectManager.cs : commented out entirely.  Not sure what this
	code is trying to accomplish and it doesn't compile.
	* glib/Value.cs : New attempt at implementing GValues. Doesn't work
	yet.
	* gtk/Button.cs : Updated to use RawObject.
	(Clicked event): s/EmitDeleteEvent/EmitClickedEvent.
	(Button(String)): s/gtk_label_new_with_lable/gtk_button_new_with_label.
	* gtk/Label.cs : Fixed some yank and paste errors where 2 value params
	were getting passed to all the set_* property methods.
	* gtk/Window.cs : Fixed hanging GTK namespace ref.
	* sample/HelloWorld.cs : Fixed hanging GTK namespace ref.

svn path=/trunk/gtk-sharp/; revision=884
2001-09-19 11:37:15 +00:00

71 lines
1.3 KiB
C#

// GTK.Button.cs - GTK Button class implementation
//
// Author: Bob Smith <bob@thestuff.net>
//
// (c) 2001 Bob Smith
namespace Gtk {
using System;
using System.Runtime.InteropServices;
public class Button : Widget {
private static readonly object ClickedEvent = new object ();
public event EventHandler Clicked
{
add
{
if (Events[ClickedEvent] == null)
{
ConnectSignal ("clicked", new SimpleCallback (EmitClickedEvent));
}
Events.AddHandler (ClickedEvent, value);
}
remove
{
Events.RemoveHandler (ClickedEvent, value);
}
}
private void EmitClickedEvent (IntPtr obj)
{
EventHandler eh = (EventHandler)(Events[ClickedEvent]);
if (eh != null)
{
EventArgs args = new EventArgs ();
eh(this, args);
}
}
/// <summary>
/// Button Object Constructor
/// </summary>
///
/// <remarks>
/// Constructs a Button Wrapper.
/// </remarks>
public Button (IntPtr o)
{
RawObject = o;
}
/// <summary>
/// Button Constructor
/// </summary>
///
/// <remarks>
/// Constructs a new Button with the specified content.
/// </remarks>
[DllImport("gtk-1.3")]
static extern IntPtr gtk_button_new_with_label (String str);
public Button (String str)
{
RawObject = gtk_button_new_with_label (str);
}
}
}