2004-02-11 21:34:32 +00:00
|
|
|
// Container.custom - customizations to Gtk.Container
|
|
|
|
//
|
|
|
|
// Authors: Mike Kestner <mkestner@ximian.com>
|
|
|
|
//
|
|
|
|
// Copyright (c) 2004 Novell, Inc.
|
|
|
|
|
|
|
|
[DllImport("libgtk-win32-2.0-0.dll")]
|
|
|
|
static extern IntPtr gtk_container_get_children (IntPtr raw);
|
|
|
|
|
|
|
|
public Widget[] Children {
|
|
|
|
get {
|
|
|
|
IntPtr list_ptr = gtk_container_get_children (Handle);
|
|
|
|
if (list_ptr == IntPtr.Zero)
|
2004-02-11 21:58:47 +00:00
|
|
|
return new Widget [0];
|
2004-02-11 21:34:32 +00:00
|
|
|
|
2004-02-11 22:23:11 +00:00
|
|
|
GLib.List list = new GLib.List (list_ptr);
|
2004-02-11 21:34:32 +00:00
|
|
|
Widget[] result = new Widget [list.Count];
|
|
|
|
for (int i = 0; i < list.Count; i++)
|
|
|
|
result [i] = list [i] as Widget;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[DllImport("libgtk-win32-2.0-0.dll")]
|
|
|
|
static extern bool gtk_container_get_focus_chain (IntPtr raw, out IntPtr list_ptr);
|
|
|
|
|
|
|
|
[DllImport("libgtk-win32-2.0-0.dll")]
|
|
|
|
static extern void gtk_container_set_focus_chain (IntPtr raw, IntPtr list_ptr);
|
|
|
|
|
|
|
|
public Widget[] FocusChain {
|
|
|
|
get {
|
|
|
|
IntPtr list_ptr;
|
|
|
|
bool success = gtk_container_get_focus_chain (Handle, out list_ptr);
|
|
|
|
if (!success)
|
2004-02-11 21:58:47 +00:00
|
|
|
return new Widget [0];
|
2004-02-11 21:34:32 +00:00
|
|
|
|
2004-02-11 22:23:11 +00:00
|
|
|
GLib.List list = new GLib.List (list_ptr);
|
2004-02-11 21:34:32 +00:00
|
|
|
Widget[] result = new Widget [list.Count];
|
|
|
|
for (int i = 0; i < list.Count; i++)
|
|
|
|
result [i] = list [i] as Widget;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
set {
|
2004-02-11 22:23:11 +00:00
|
|
|
GLib.List list = new GLib.List (IntPtr.Zero);
|
2004-02-11 21:34:32 +00:00
|
|
|
foreach (Widget val in value)
|
|
|
|
list.Append (val.Handle);
|
|
|
|
gtk_container_set_focus_chain (Handle, list.Handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-05-08 02:14:19 +00:00
|
|
|
[DllImport("gtksharpglue")]
|
2004-05-25 13:35:38 +00:00
|
|
|
static extern void gtksharp_container_base_forall (IntPtr handle, bool include_internals, IntPtr cb, IntPtr data);
|
2004-05-08 02:14:19 +00:00
|
|
|
|
|
|
|
[DllImport("gtksharpglue")]
|
|
|
|
static extern void gtksharp_container_override_forall (GLib.GType gtype, ForallDelegate cb);
|
|
|
|
|
2004-05-25 13:35:38 +00:00
|
|
|
[DllImport("gtksharpglue")]
|
|
|
|
static extern void gtksharp_container_invoke_gtk_callback (IntPtr cb, IntPtr handle, IntPtr data);
|
|
|
|
|
|
|
|
delegate void ForallDelegate (IntPtr container, bool include_internals, IntPtr cb, IntPtr data);
|
2004-05-08 02:14:19 +00:00
|
|
|
|
|
|
|
static ForallDelegate ForallCallback;
|
|
|
|
|
2004-05-19 18:57:28 +00:00
|
|
|
public struct CallbackInvoker {
|
2004-05-25 13:35:38 +00:00
|
|
|
IntPtr cb;
|
2004-05-19 18:57:28 +00:00
|
|
|
IntPtr data;
|
|
|
|
|
2004-05-25 13:35:38 +00:00
|
|
|
internal CallbackInvoker (IntPtr cb, IntPtr data)
|
2004-05-19 18:57:28 +00:00
|
|
|
{
|
|
|
|
this.cb = cb;
|
|
|
|
this.data = data;
|
|
|
|
}
|
|
|
|
|
|
|
|
internal IntPtr Data {
|
|
|
|
get {
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-05-25 13:35:38 +00:00
|
|
|
internal IntPtr Callback {
|
2004-05-19 18:57:28 +00:00
|
|
|
get {
|
|
|
|
return cb;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Invoke (Widget w)
|
|
|
|
{
|
2004-05-25 13:35:38 +00:00
|
|
|
gtksharp_container_invoke_gtk_callback (cb, w.Handle, data);
|
2004-05-19 18:57:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-05-25 13:35:38 +00:00
|
|
|
static void Forall_cb (IntPtr container, bool include_internals, IntPtr cb, IntPtr data)
|
2004-05-08 02:14:19 +00:00
|
|
|
{
|
|
|
|
Container obj = GLib.Object.GetObject (container, false) as Container;
|
2004-05-19 18:57:28 +00:00
|
|
|
CallbackInvoker invoker = new CallbackInvoker (cb, data);
|
|
|
|
obj.OnForall (include_internals, invoker);
|
2004-05-08 02:14:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected static void OverrideForall (GLib.GType gtype)
|
|
|
|
{
|
|
|
|
if (ForallCallback == null)
|
|
|
|
ForallCallback = new ForallDelegate (Forall_cb);
|
|
|
|
gtksharp_container_override_forall (gtype, ForallCallback);
|
|
|
|
}
|
|
|
|
|
2004-05-19 18:57:28 +00:00
|
|
|
protected virtual void OnForall (bool include_internals, CallbackInvoker invoker)
|
2004-05-08 02:14:19 +00:00
|
|
|
{
|
2004-05-25 13:35:38 +00:00
|
|
|
gtksharp_container_base_forall (Handle, include_internals, invoker.Callback, invoker.Data);
|
2004-05-08 02:14:19 +00:00
|
|
|
}
|
|
|
|
|