2001-09-16 23:15:56 +00:00
|
|
|
// GTK.Widget.cs - GTK Widget class implementation
|
|
|
|
//
|
|
|
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
|
|
|
//
|
|
|
|
// (c) 2001 Mike Kestner
|
|
|
|
|
2001-09-19 02:04:57 +00:00
|
|
|
namespace Gtk {
|
2001-09-16 23:15:56 +00:00
|
|
|
|
2001-09-21 14:03:17 +00:00
|
|
|
using System;
|
|
|
|
using System.Runtime.InteropServices;
|
2001-09-27 17:17:33 +00:00
|
|
|
using GLib;
|
2001-09-21 14:03:17 +00:00
|
|
|
using Gdk;
|
2001-09-16 23:15:56 +00:00
|
|
|
|
2001-09-27 17:17:33 +00:00
|
|
|
|
2001-09-25 15:56:50 +00:00
|
|
|
public class Widget : Object {
|
|
|
|
public Widget() {}
|
2001-09-27 17:17:33 +00:00
|
|
|
~Widget()
|
2001-09-25 15:56:50 +00:00
|
|
|
{
|
2001-09-27 17:17:33 +00:00
|
|
|
/* FIXME: Find a valid way to Delete the handlers
|
|
|
|
foreach (EventHandler e in Events[DelEvName])
|
2001-09-25 15:56:50 +00:00
|
|
|
{
|
|
|
|
DeleteEvent -= e;
|
|
|
|
}
|
2001-09-27 17:17:33 +00:00
|
|
|
*/
|
2001-09-25 15:56:50 +00:00
|
|
|
}
|
2001-09-27 17:17:33 +00:00
|
|
|
|
|
|
|
private static readonly string DelEvName = "delete-event";
|
|
|
|
|
|
|
|
public event EventHandler DeleteEvent {
|
|
|
|
add {
|
|
|
|
if (Events [DelEvName] == null)
|
|
|
|
ConnectSignal(DelEvName);
|
|
|
|
|
|
|
|
Events.AddHandler(DelEvName, value);
|
2001-09-18 03:57:16 +00:00
|
|
|
}
|
2001-09-27 17:17:33 +00:00
|
|
|
remove {
|
|
|
|
Events.RemoveHandler(DelEvName, value);
|
|
|
|
if (Events [DelEvName] == null)
|
|
|
|
DisconnectSignal (DelEvName);
|
2001-09-18 03:57:16 +00:00
|
|
|
}
|
2001-09-16 23:15:56 +00:00
|
|
|
}
|
2001-09-27 17:17:33 +00:00
|
|
|
/*
|
2001-09-21 14:03:17 +00:00
|
|
|
public void AddSimpleEvent(Object type, string name, EventHandler value)
|
|
|
|
{
|
|
|
|
if (Events[type] == null)
|
|
|
|
{
|
|
|
|
ConnectSimpleSignal(name, type);
|
|
|
|
}
|
|
|
|
Events.AddHandler(type, value);
|
|
|
|
}
|
|
|
|
|
2001-09-27 17:17:33 +00:00
|
|
|
public void RemoveSimpleEvent(Object type, string name, EventHandler value)
|
2001-09-21 14:03:17 +00:00
|
|
|
{
|
|
|
|
Events.RemoveHandler(type, value);
|
2001-09-25 15:56:50 +00:00
|
|
|
if (Events[type] == null)
|
|
|
|
{
|
|
|
|
DisconnectSimpleSignal(name, type);
|
|
|
|
}
|
2001-09-21 14:03:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void AddGdkSimpleEvent(Object type, string name, EventHandler value)
|
2001-09-16 23:15:56 +00:00
|
|
|
{
|
2001-09-21 14:03:17 +00:00
|
|
|
if (Events[type] == null)
|
2001-09-18 03:57:16 +00:00
|
|
|
{
|
2001-09-21 14:03:17 +00:00
|
|
|
ConnectGdkSimpleEventSignal(name, type);
|
2001-09-16 23:15:56 +00:00
|
|
|
}
|
2001-09-21 14:03:17 +00:00
|
|
|
Events.AddHandler(type, value);
|
|
|
|
}
|
|
|
|
|
2001-09-27 17:17:33 +00:00
|
|
|
public void RemoveGdkSimpleEvent(Object type, string name, EventHandler value)
|
2001-09-21 14:03:17 +00:00
|
|
|
{
|
|
|
|
Events.RemoveHandler(type, value);
|
2001-09-25 15:56:50 +00:00
|
|
|
if (Events[type] == null)
|
|
|
|
{
|
|
|
|
DisconnectGdkSimpleEventSignal(name, type);
|
|
|
|
}
|
2001-09-16 23:15:56 +00:00
|
|
|
}
|
2001-09-27 17:17:33 +00:00
|
|
|
*/
|
|
|
|
[DllImport("gtk-1.3.dll")]
|
2001-09-21 14:03:17 +00:00
|
|
|
static extern void gtk_signal_connect_full (
|
|
|
|
IntPtr obj, string evname,
|
|
|
|
SimpleDelegate cb, IntPtr unsupported,
|
2001-09-27 17:17:33 +00:00
|
|
|
String data, IntPtr destroycb,
|
2001-09-21 14:03:17 +00:00
|
|
|
int objsig, int after );
|
2001-09-16 23:15:56 +00:00
|
|
|
|
2001-09-27 17:17:33 +00:00
|
|
|
public void ConnectSignal(string name)
|
2001-09-16 23:15:56 +00:00
|
|
|
{
|
2001-09-27 17:17:33 +00:00
|
|
|
gtk_signal_connect_full(RawObject, name, SimpleSignal.Delegate,
|
|
|
|
new IntPtr (0), name,
|
2001-09-21 14:03:17 +00:00
|
|
|
new IntPtr (0), 0, 0);
|
|
|
|
}
|
2001-09-16 23:15:56 +00:00
|
|
|
|
2001-09-27 17:17:33 +00:00
|
|
|
public void DisconnectSignal(string name)
|
2001-09-25 15:56:50 +00:00
|
|
|
{
|
2001-09-27 17:17:33 +00:00
|
|
|
SimpleSignal.Unref();
|
2001-09-25 15:56:50 +00:00
|
|
|
}
|
|
|
|
|
2001-09-27 17:17:33 +00:00
|
|
|
/*
|
2001-09-21 14:03:17 +00:00
|
|
|
public void ConnectGdkSimpleSignal(string name, Object signal)
|
|
|
|
{
|
2001-09-27 17:17:33 +00:00
|
|
|
gtk_signal_connect_full(RawObject, name, SimpleEvent.Delegate,
|
|
|
|
new IntPtr (0), name,
|
2001-09-21 14:03:17 +00:00
|
|
|
new IntPtr (0), 0, 0);
|
2001-09-16 23:15:56 +00:00
|
|
|
}
|
2001-09-21 14:03:17 +00:00
|
|
|
|
2001-09-25 15:56:50 +00:00
|
|
|
public void DisconnectGdkSimpleSignal(string name, Object signal)
|
|
|
|
{
|
2001-09-27 17:17:33 +00:00
|
|
|
SimpleEvent.Unref();
|
2001-09-25 15:56:50 +00:00
|
|
|
}
|
2001-09-27 17:17:33 +00:00
|
|
|
*/
|
2001-09-21 14:03:17 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Show Method
|
|
|
|
/// </summary>
|
|
|
|
///
|
|
|
|
/// <remarks>
|
|
|
|
/// Makes the Widget visible on the display.
|
|
|
|
/// </remarks>
|
|
|
|
|
2001-09-27 17:17:33 +00:00
|
|
|
[DllImport("gtk-1.3.dll")]
|
2001-09-21 14:03:17 +00:00
|
|
|
static extern void gtk_widget_show (IntPtr obj);
|
|
|
|
|
|
|
|
public void Show ()
|
|
|
|
{
|
|
|
|
gtk_widget_show (RawObject);
|
|
|
|
}
|
|
|
|
}
|
2001-09-16 23:15:56 +00:00
|
|
|
}
|