Ryujinx-GtkSharp/gtk/Container.custom
Dan Winship b6d7f14268 * generator/StructBase.cs: update field-generation logic a bit
* generator/CodeGenerator.cs: add a --glue-includes flag

	* generator/GenerationInfo.cs: Accept glue_includes value from
	Main and output it to the glue_filename.

	* generator/FieldBase.cs (Ignored): handle more ignorable cases.
	(CheckGlue): New method to figure out what kind of glue we'll need
	for a field.
	(GenerateImports): generate appropriate imports per CheckGlue.
	(GenerateGlue): Generate C glue for accessing a struct field;
	either a fully-C-based accessor, or a method to just return the
	field's offset in the struct.
	(Generate): Use the generated glue to read the field.

	* generator/PropertyBase.cs (CType): if the field is a single bit,
	set its type to gboolean.

	* generator/ObjectGen.cs (Generate):
	* generator/OpaqueGen.cs (Generate): Call GenFields.

	* generator/StructField.cs: Use FieldBase's glue-generation code
	to handle bitfields. [#54489]

	* generator/ObjectField.cs: Generates accessors for public fields
	of objects and opaque structs. [#69514]

	* generator/ClassBase.cs (ClassBase): Parse <fields> nodes and
	create ObjectField objects.
	(GenFields): Output field properties
	(IgnoreMethod): Ignore Get/Set methods that duplicate fields

	* generator/Makefile.am (sources): update

	* {gdk,gnome,gtk,pango}/*.metadata: Mark some additional fields as
	public. Rename/retype some fields for consistency with earlier
	hand-coded bindings.

	* {gdk,gnome,gtk,pango}/*.custom: Remove custom methods that can
	now be autogenerated.

	* {gdk,gnome,gtk,pango}/glue/*.c: Remove glue methods that can now
	be autogenerated
	
	* {gdk,glade,gnome,gtk,pango,vte}/Makefile.am
	* {gdk,glade,gnome,gtk,pango,vte}/glue/Makefile.am
	* {gdk,gnome,gtk,pango}/glue/makefile.win32: Update

svn path=/trunk/gtk-sharp/; revision=44563
2005-05-16 14:28:55 +00:00

253 lines
7.0 KiB
Plaintext

// Container.custom - customizations to Gtk.Container
//
// Authors: Mike Kestner <mkestner@ximian.com>
//
// Copyright (c) 2004 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
[DllImport("gtksharpglue-2")]
static extern void gtksharp_container_child_get_property (IntPtr container, IntPtr child, IntPtr property, ref GLib.Value value);
public GLib.Value ChildGetProperty (Gtk.Widget child, string property_name) {
GLib.Value value = new GLib.Value ();
IntPtr native = GLib.Marshaller.StringToPtrGStrdup (property_name);
gtksharp_container_child_get_property (Handle, child.Handle, native, ref value);
GLib.Marshaller.Free (native);
return value;
}
[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)
return new Widget [0];
GLib.List list = new GLib.List (list_ptr);
Widget[] result = new Widget [list.Count];
for (int i = 0; i < list.Count; i++)
result [i] = list [i] as Widget;
return result;
}
}
public IEnumerator GetEnumerator ()
{
IntPtr list_ptr = gtk_container_get_children (Handle);
GLib.List list = new GLib.List (list_ptr);
return list.GetEnumerator ();
}
class ChildAccumulator {
public ArrayList Children = new ArrayList ();
public void Add (Gtk.Widget widget)
{
Children.Add (widget);
}
}
public IEnumerable AllChildren {
get {
ChildAccumulator acc = new ChildAccumulator ();
Forall (new Gtk.Callback (acc.Add));
return acc.Children;
}
}
[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)
return new Widget [0];
GLib.List list = new GLib.List (list_ptr);
Widget[] result = new Widget [list.Count];
for (int i = 0; i < list.Count; i++)
result [i] = list [i] as Widget;
return result;
}
set {
GLib.List list = new GLib.List (IntPtr.Zero);
foreach (Widget val in value)
list.Append (val.Handle);
gtk_container_set_focus_chain (Handle, list.Handle);
}
}
[DllImport("gtksharpglue-2")]
static extern void gtksharp_container_base_forall (IntPtr handle, bool include_internals, IntPtr cb, IntPtr data);
[DllImport("gtksharpglue-2")]
static extern void gtksharp_container_override_forall (GLib.GType gtype, ForallDelegate cb);
[DllImport("gtksharpglue-2")]
static extern void gtksharp_container_invoke_gtk_callback (IntPtr cb, IntPtr handle, IntPtr data);
[GLib.CDeclCallback]
delegate void ForallDelegate (IntPtr container, bool include_internals, IntPtr cb, IntPtr data);
static ForallDelegate ForallOldCallback;
static ForallDelegate ForallCallback;
public struct CallbackInvoker {
IntPtr cb;
IntPtr data;
internal CallbackInvoker (IntPtr cb, IntPtr data)
{
this.cb = cb;
this.data = data;
}
internal IntPtr Data {
get {
return data;
}
}
internal IntPtr Callback {
get {
return cb;
}
}
public void Invoke (Widget w)
{
gtksharp_container_invoke_gtk_callback (cb, w.Handle, data);
}
}
static void ForallOld_cb (IntPtr container, bool include_internals, IntPtr cb, IntPtr data)
{
Container obj = GLib.Object.GetObject (container, false) as Container;
CallbackInvoker invoker = new CallbackInvoker (cb, data);
obj.ForAll (include_internals, invoker);
}
static void OverrideForallOld (GLib.GType gtype)
{
if (ForallOldCallback == null)
ForallOldCallback = new ForallDelegate (ForallOld_cb);
gtksharp_container_override_forall (gtype, ForallOldCallback);
}
[Obsolete ("Override the ForAll(bool,Gtk.Callback) method instead")]
[GLib.DefaultSignalHandler (Type=typeof(Gtk.Container), ConnectionMethod="OverrideForallOld")]
protected virtual void ForAll (bool include_internals, CallbackInvoker invoker)
{
gtksharp_container_base_forall (Handle, include_internals, invoker.Callback, invoker.Data);
}
static void Forall_cb (IntPtr container, bool include_internals, IntPtr cb, IntPtr data)
{
Container obj = GLib.Object.GetObject (container, false) as Container;
CallbackInvoker invoker = new CallbackInvoker (cb, data);
obj.ForAll (include_internals, new Gtk.Callback (invoker.Invoke));
}
static void OverrideForall (GLib.GType gtype)
{
if (ForallCallback == null)
ForallCallback = new ForallDelegate (Forall_cb);
gtksharp_container_override_forall (gtype, ForallCallback);
}
[GLib.DefaultSignalHandler (Type=typeof(Gtk.Container), ConnectionMethod="OverrideForall")]
protected virtual void ForAll (bool include_internals, Gtk.Callback callback)
{
CallbackInvoker invoker;
try {
invoker = (CallbackInvoker)callback.Target;
} catch {
throw new ApplicationException ("ForAll can only be called as \"base.ForAll()\". Use Forall() or Foreach().");
}
gtksharp_container_base_forall (Handle, include_internals, invoker.Callback, invoker.Data);
}
[DllImport("libgtk-win32-2.0-0.dll")]
static extern IntPtr gtk_container_child_type(IntPtr raw);
[DllImport("gtksharpglue-2")]
static extern void gtksharp_container_override_child_type (GLib.GType type, ChildTypeDelegate cb);
[GLib.CDeclCallback]
delegate IntPtr ChildTypeDelegate (IntPtr raw);
static ChildTypeDelegate ChildTypeCallback;
static IntPtr ChildType_cb (IntPtr raw)
{
Container obj = GLib.Object.GetObject (raw, false) as Container;
GLib.GType gtype = obj.ChildType ();
return gtype.Val;
}
static void OverrideChildType (GLib.GType gtype)
{
if (ChildTypeCallback == null)
ChildTypeCallback = new ChildTypeDelegate (ChildType_cb);
gtksharp_container_override_child_type (gtype, ChildTypeCallback);
}
[GLib.DefaultSignalHandler (Type=typeof(Gtk.Container), ConnectionMethod="OverrideChildType")]
public virtual GLib.GType ChildType() {
IntPtr raw_ret = gtk_container_child_type(Handle);
GLib.GType ret = new GLib.GType(raw_ret);
return ret;
}
public class ContainerChild {
protected Container parent;
protected Widget child;
public ContainerChild (Container parent, Widget child)
{
this.parent = parent;
this.child = child;
}
public Container Parent {
get {
return parent;
}
}
public Widget Child {
get {
return child;
}
}
}
public virtual ContainerChild this [Widget w] {
get {
return new ContainerChild (this, w);
}
}