mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-24 18:05:32 +00:00
699238daad
svn path=/trunk/gtk-sharp/; revision=962
133 lines
3.3 KiB
C#
Executable file
133 lines
3.3 KiB
C#
Executable file
// GTK.Widget.cs - GTK Widget class implementation
|
|
//
|
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
|
//
|
|
// (c) 2001 Mike Kestner
|
|
|
|
namespace Gtk {
|
|
|
|
using System;
|
|
using System.Runtime.InteropServices;
|
|
using Glib;
|
|
using Gdk;
|
|
|
|
public class Widget : Object {
|
|
public Widget() {}
|
|
public ~Widget()
|
|
{
|
|
foreach (EventHandler e in Events[DeleteEvent])
|
|
{
|
|
DeleteEvent -= e;
|
|
}
|
|
}
|
|
private static readonly string DeleteEvent = "delete-event";
|
|
public event EventHandler DeleteEvent
|
|
{
|
|
add
|
|
{
|
|
AddGdkSimpleEvent(DeleteEvent, value);
|
|
}
|
|
remove
|
|
{
|
|
RemoveGdkSimpleEvent (DeleteEvent, value);
|
|
}
|
|
}
|
|
|
|
public void AddSimpleEvent(Object type, string name, EventHandler value)
|
|
{
|
|
if (Events[type] == null)
|
|
{
|
|
ConnectSimpleSignal(name, type);
|
|
}
|
|
Events.AddHandler(type, value);
|
|
}
|
|
|
|
public void AddSimpleEvent(String type, EventHandle value)
|
|
: this (type, type, value) {}
|
|
|
|
public void RemoveSimpleEvent(Object type, string name, EventHander value)
|
|
{
|
|
Events.RemoveHandler(type, value);
|
|
if (Events[type] == null)
|
|
{
|
|
DisconnectSimpleSignal(name, type);
|
|
}
|
|
}
|
|
|
|
public void RemoveSimpleEvent(String type, EventHandle value)
|
|
: this (type, type, value) {}
|
|
|
|
public void AddGdkSimpleEvent(Object type, string name, EventHandler value)
|
|
{
|
|
if (Events[type] == null)
|
|
{
|
|
ConnectGdkSimpleEventSignal(name, type);
|
|
}
|
|
Events.AddHandler(type, value);
|
|
}
|
|
|
|
public void AddGdkSimpleEvent(String type, EventHandle value)
|
|
: this (type, type, value) {}
|
|
|
|
public void RemoveGdkSimpleEvent(Object type, string name, EventHander value)
|
|
{
|
|
Events.RemoveHandler(type, value);
|
|
if (Events[type] == null)
|
|
{
|
|
DisconnectGdkSimpleEventSignal(name, type);
|
|
}
|
|
}
|
|
|
|
public void RemoveGdkSimpleEvent(String type, EventHandle value)
|
|
: this (type, type, value) {}
|
|
|
|
|
|
[DllImport("gtk-1.3")]
|
|
static extern void gtk_signal_connect_full (
|
|
IntPtr obj, string evname,
|
|
SimpleDelegate cb, IntPtr unsupported,
|
|
IntPtr data, IntPtr destroycb,
|
|
int objsig, int after );
|
|
|
|
public void ConnectSimpleSignal(string name, Object signal)
|
|
{
|
|
gtk_signal_connect_full(RawObject, name, Glib.Signals.Simple.Delegate,
|
|
new IntPtr (0), new IntPtr (signal.GetHashCode()),
|
|
new IntPtr (0), 0, 0);
|
|
}
|
|
|
|
public void DisconnectSimpleSignal(string name, Object signal)
|
|
{
|
|
Glib.Signals.Simple.Unref();
|
|
}
|
|
|
|
public void ConnectGdkSimpleSignal(string name, Object signal)
|
|
{
|
|
gtk_signal_connect_full(RawObject, name, Gdk.Signals.SimpleEvent.Delegate,
|
|
new IntPtr (0), new IntPtr (signal.GetHashCode()),
|
|
new IntPtr (0), 0, 0);
|
|
}
|
|
|
|
public void DisconnectGdkSimpleSignal(string name, Object signal)
|
|
{
|
|
Gdk.Signals.SimpleEvent.Unref();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Show Method
|
|
/// </summary>
|
|
///
|
|
/// <remarks>
|
|
/// Makes the Widget visible on the display.
|
|
/// </remarks>
|
|
|
|
[DllImport("gtk-1.3")]
|
|
static extern void gtk_widget_show (IntPtr obj);
|
|
|
|
public void Show ()
|
|
{
|
|
gtk_widget_show (RawObject);
|
|
}
|
|
}
|
|
}
|