From 54838fec295e11b50099a0fed3ef94def6a6d082 Mon Sep 17 00:00:00 2001 From: Rachel Hestilow Date: Sat, 3 Aug 2002 22:24:37 +0000 Subject: [PATCH] 2002-08-03 Rachel Hestilow * generator/Method.cs: Support libname overrides. Call parms.Finish. * generator/Parameters.cs: New method parms.Finish. Generate a temporary holder variable for enum out parameters. * generator/Property.cs: Pass a boolean to EnumWrapper indicating. if these are flags. * generator/StructBase.cs: Disable array marshalling (it is broken in mono.) * generator/SymbolTable.cs: Add methods IsEnumFlags. * glib/EnumWrapper.cs: New bool "flags". * glib/Value.cs: Call flags variant on GValue for enum props, if needed. * glue/Makefile.am, glue/style.c, glue/widget.c: Add widget and style field accessor methods. * gtk/Style.custom, Widget.custom: Added. * parser/README: Update requirements (needed for pixbuf drawable hack) * parser/Gdk.metadata: Fix library for pixbuf methods in gdk. Add Window.GetPointer "out" parameters. * parser/gapi2xml.pl: Remap gdk_draw_* methods to Drawable. * sample/Makefile.in: Add size and scribble samples. * sample/Scribble.cs: Added. svn path=/trunk/gtk-sharp/; revision=6387 --- ChangeLog | 27 ++++ generator/Method.cs | 10 +- generator/Parameters.cs | 23 +-- generator/Property.cs | 2 +- generator/StructBase.cs | 3 +- generator/SymbolTable.cs | 13 +- generator/gtkapi.xml | 329 ++++++++++++++++++++++++++++++++++++++- glib/EnumWrapper.cs | 4 +- glib/Value.cs | 12 +- glue/Makefile.am | 4 +- glue/style.c | 59 +++++++ glue/widget.c | 16 ++ gtk/Style.custom | 92 +++++++++++ gtk/Widget.custom | 17 ++ parser/Gdk.metadata | 45 +++++- parser/README | 1 + parser/gapi2xml.pl | 17 +- sample/Makefile.in | 8 +- sample/Scribble.cs | 131 ++++++++++++++++ sources/Gdk.metadata | 45 +++++- sources/README | 1 + 21 files changed, 832 insertions(+), 27 deletions(-) create mode 100644 glue/style.c create mode 100644 glue/widget.c create mode 100644 gtk/Style.custom create mode 100644 gtk/Widget.custom create mode 100644 sample/Scribble.cs diff --git a/ChangeLog b/ChangeLog index 2973786df..bc7422feb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +2002-08-03 Rachel Hestilow + + * generator/Method.cs: Support libname overrides. Call parms.Finish. + * generator/Parameters.cs: New method parms.Finish. Generate a temporary + holder variable for enum out parameters. + * generator/Property.cs: Pass a boolean to EnumWrapper indicating. + if these are flags. + * generator/StructBase.cs: Disable array marshalling (it is + broken in mono.) + * generator/SymbolTable.cs: Add methods IsEnumFlags. + + * glib/EnumWrapper.cs: New bool "flags". + * glib/Value.cs: Call flags variant on GValue for enum props, if needed. + + * glue/Makefile.am, glue/style.c, glue/widget.c: Add widget + and style field accessor methods. + + * gtk/Style.custom, Widget.custom: Added. + + * parser/README: Update requirements (needed for pixbuf drawable hack) + * parser/Gdk.metadata: Fix library for pixbuf methods in gdk. + Add Window.GetPointer "out" parameters. + * parser/gapi2xml.pl: Remap gdk_draw_* methods to Drawable. + + * sample/Makefile.in: Add size and scribble samples. + * sample/Scribble.cs: Added. + 2002-08-02 Rachel Hestilow [ Mike, this is everything I wanted in for the release. ] diff --git a/generator/Method.cs b/generator/Method.cs index 75ec83a8b..9a703ef31 100644 --- a/generator/Method.cs +++ b/generator/Method.cs @@ -27,12 +27,16 @@ namespace GtkSharp.Generation { public Method (string libname, XmlElement elem, ClassBase container_type) { - this.libname = libname; this.elem = elem; if (elem["parameters"] != null) parms = new Parameters (elem["parameters"]); this.container_type = container_type; this.name = elem.GetAttribute("name"); + // override library - used in pixbuf API fixage + if (elem.HasAttribute ("library")) + this.libname = elem.GetAttribute ("library"); + else + this.libname = libname; } public string Name { @@ -356,8 +360,10 @@ namespace GtkSharp.Generation { } } - if (parms != null) + if (parms != null) { + parms.Finish (sw, indent); parms.HandleException (sw, indent); + } if (is_get && parms != null) sw.WriteLine (indent + "\t\t\treturn " + parms.AccessorName + ";"); diff --git a/generator/Parameters.cs b/generator/Parameters.cs index 8f77fe8a4..ae6439768 100644 --- a/generator/Parameters.cs +++ b/generator/Parameters.cs @@ -199,12 +199,15 @@ namespace GtkSharp.Generation { if (p_elem.HasAttribute("pass_as")) { string pass_as = p_elem.GetAttribute("pass_as"); signature += pass_as + " "; - // We only need to do this for value types + // We only need to do this for value types if (type != "GError**" && m_type != "IntPtr" && m_type != "System.IntPtr") { import_sig += pass_as + " "; call_string += "out "; } + + if (SymbolTable.IsEnum (type)) + call_parm = name + "_as_int"; } else if (type == "GError**") { @@ -253,13 +256,17 @@ namespace GtkSharp.Generation { if ((is_get || (p_elem.HasAttribute("pass_as") && p_elem.GetAttribute ("pass_as") == "out")) && (SymbolTable.IsObject (c_type) || SymbolTable.IsOpaque (c_type))) { sw.WriteLine(indent + "\t\t\t" + name + " = new " + type + "();"); } + + if (p_elem.HasAttribute("pass_as") && p_elem.GetAttribute ("pass_as") == "out" && SymbolTable.IsEnum (c_type)) { + sw.WriteLine(indent + "\t\t\tint " + name + "_as_int;"); + } } if (ThrowsException) sw.WriteLine (indent + "\t\t\tIntPtr error = IntPtr.Zero;"); } -/* - public void Finish (StreamWriter sw) + + public void Finish (StreamWriter sw, string indent) { foreach (XmlNode parm in elem.ChildNodes) { if (parm.Name != "parameter") { @@ -269,16 +276,14 @@ namespace GtkSharp.Generation { XmlElement p_elem = (XmlElement) parm; string c_type = p_elem.GetAttribute ("type"); string name = MangleName(p_elem.GetAttribute("name")); + string type = SymbolTable.GetCSType(c_type); - if ((p_elem.HasAttribute("pass_as") && p_elem.GetAttribute ("pass_as") == "out")) { - string call_parm = SymbolTable.CallByName(c_type, name); - string local_parm = GetPossibleLocal (call_parm); - if (call_parm != local_parm) - sw.WriteLine ("\t\t\t{0} = {1};", call_parm, local_parm); + if (p_elem.HasAttribute("pass_as") && p_elem.GetAttribute ("pass_as") == "out" && SymbolTable.IsEnum (c_type)) { + sw.WriteLine(indent + "\t\t\t" + name + " = (" + type + ") " + name + "_as_int;"); } } } -*/ + public void HandleException (StreamWriter sw, string indent) { diff --git a/generator/Property.cs b/generator/Property.cs index df5b7aaee..cc38211ec 100644 --- a/generator/Property.cs +++ b/generator/Property.cs @@ -117,7 +117,7 @@ namespace GtkSharp.Generation { sw.WriteLine("\t\t\tset {"); sw.Write("\t\t\t\tSetProperty(" + cname + ", new GLib.Value("); if (SymbolTable.IsEnum(c_type)) { - sw.WriteLine("Handle, " + cname + ", new GLib.EnumWrapper ((int) value)));"); + sw.WriteLine("Handle, " + cname + ", new GLib.EnumWrapper ((int) value, {0})));", SymbolTable.IsEnumFlags (c_type) ? "true" : "false"); } else if (SymbolTable.IsBoxed (c_type)) { sw.WriteLine("Handle, " + cname + ", new GLib.Boxed (value)));"); } else { diff --git a/generator/StructBase.cs b/generator/StructBase.cs index 92002e356..7f41a3f35 100644 --- a/generator/StructBase.cs +++ b/generator/StructBase.cs @@ -128,8 +128,9 @@ namespace GtkSharp.Generation { } } + // FIXME: marshalling not implemented here in mono if (field.HasAttribute("array_len")) - type += "[]"; + type = "IntPtr"; if (IsBit (field)) name = String.Format ("_bitfield{0}", bitfields++); diff --git a/generator/SymbolTable.cs b/generator/SymbolTable.cs index eaa9185ce..46dba5269 100644 --- a/generator/SymbolTable.cs +++ b/generator/SymbolTable.cs @@ -296,7 +296,18 @@ namespace GtkSharp.Generation { } return false; } - + + public static bool IsEnumFlags(string c_type) + { + c_type = Trim(c_type); + c_type = DeAlias(c_type); + if (complex_types.ContainsKey(c_type)) { + EnumGen gen = complex_types[c_type] as EnumGen; + return (gen != null && gen.Elem.GetAttribute ("type") == "flags"); + } + return false; + } + public static bool IsInterface(string c_type) { c_type = Trim(c_type); diff --git a/generator/gtkapi.xml b/generator/gtkapi.xml index 1bfed827a..686eb3536 100644 --- a/generator/gtkapi.xml +++ b/generator/gtkapi.xml @@ -1119,6 +1119,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1196,6 +1222,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2313,6 +2402,240 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2912,9 +3235,9 @@ - - - + + + diff --git a/glib/EnumWrapper.cs b/glib/EnumWrapper.cs index d67c0a1b5..a647bdc00 100644 --- a/glib/EnumWrapper.cs +++ b/glib/EnumWrapper.cs @@ -13,9 +13,11 @@ namespace GLib { // public class EnumWrapper { int val; + public bool flags; - public EnumWrapper (int val) { + public EnumWrapper (int val, bool flags) { this.val = val; + this.flags = flags; } public static explicit operator int (EnumWrapper wrap) { diff --git a/glib/Value.cs b/glib/Value.cs index e6df66de0..c62c8e711 100755 --- a/glib/Value.cs +++ b/glib/Value.cs @@ -233,6 +233,8 @@ namespace GLib { [DllImport("gobject-2.0")] static extern void g_value_set_enum (IntPtr val, int data); + [DllImport("gobject-2.0")] + static extern void g_value_set_flags (IntPtr val, uint data); /// /// Value Constructor @@ -245,7 +247,10 @@ namespace GLib { public Value (IntPtr obj, string prop_name, EnumWrapper wrap) { _val = gtksharp_value_create_from_property (obj, prop_name); - g_value_set_enum (_val, (int) wrap); + if (wrap.flags) + g_value_set_flags (_val, (uint) (int) wrap); + else + g_value_set_enum (_val, (int) wrap); } [DllImport("gobject-2.0")] @@ -451,6 +456,8 @@ namespace GLib { [DllImport("gobject-2.0")] static extern int g_value_get_enum (IntPtr val); + [DllImport("gobject-2.0")] + static extern uint g_value_get_flags (IntPtr val); /// /// Value to Enum Conversion @@ -466,7 +473,8 @@ namespace GLib { { // FIXME: Insert an appropriate exception here if // _val.type indicates an error. - return new EnumWrapper (g_value_get_enum (val._val)); + // FIXME: handle flags + return new EnumWrapper (g_value_get_enum (val._val), false); } /// diff --git a/glue/Makefile.am b/glue/Makefile.am index c49651b18..a0a6c65e2 100644 --- a/glue/Makefile.am +++ b/glue/Makefile.am @@ -8,7 +8,9 @@ BASESOURCES = \ error.c \ event.c \ slist.c \ - paned.c + paned.c \ + style.c \ + widget.c if ENABLE_GNOME libgtksharpglue_la_SOURCES = \ diff --git a/glue/style.c b/glue/style.c new file mode 100644 index 000000000..02d800862 --- /dev/null +++ b/glue/style.c @@ -0,0 +1,59 @@ +/* style.c : Glue to access fields in GtkStyle. + * + * Author: Rachel Hestilow + * + * 2002 Rachel Hestilow, Mike Kestner + */ + +#include + +/* FIXME: include all fields */ + +GdkGC* +gtksharp_gtk_style_get_white_gc (GtkStyle *style) +{ + return style->white_gc; +} + +GdkGC* +gtksharp_gtk_style_get_black_gc (GtkStyle *style) +{ + return style->black_gc; +} + +GdkGC** +gtksharp_gtk_style_get_fg_gc (GtkStyle *style) +{ + return style->fg_gc; +} + +GdkGC** +gtksharp_gtk_style_get_bg_gc (GtkStyle *style) +{ + return style->bg_gc; +} + +GdkColor* +gtksharp_gtk_style_get_white (GtkStyle *style) +{ + return &style->white; +} + +GdkColor* +gtksharp_gtk_style_get_black (GtkStyle *style) +{ + return &style->black; +} + +GdkColor* +gtksharp_gtk_style_get_fg (GtkStyle *style) +{ + return style->fg; +} + +GdkColor** +gtksharp_gtk_style_get_bg (GtkStyle *style) +{ + return style->bg; +} + diff --git a/glue/widget.c b/glue/widget.c new file mode 100644 index 000000000..b70472bb1 --- /dev/null +++ b/glue/widget.c @@ -0,0 +1,16 @@ +/* widget.c : Glue to access fields in GtkWidget. + * + * Author: Rachel Hestilow + * + * 2002 Rachel Hestilow, Mike Kestner + */ + +#include + +GdkRectangle* +gtksharp_gtk_widget_get_allocation (GtkWidget *widget) +{ + return &widget->allocation; +} + + diff --git a/gtk/Style.custom b/gtk/Style.custom new file mode 100644 index 000000000..14ef546ac --- /dev/null +++ b/gtk/Style.custom @@ -0,0 +1,92 @@ +// +// Gtk.Style.custom - Gtk Style class customizations +// +// Author: Rachel Hestilow +// +// Copyright (C) 2002 Rachel Hestilow +// +// This code is inserted after the automatically generated code. +// + +static Gdk.GC EnsureGC (IntPtr raw) { + if (raw == IntPtr.Zero) + return null; + Gdk.GC ret = (Gdk.GC) GLib.Object.GetObject (raw); + if (ret == null) + ret = new Gdk.GC (raw); + return ret; +} + +[DllImport("gtksharpglue")] +static extern IntPtr gtksharp_gtk_style_get_white_gc (IntPtr style); + +public Gdk.GC WhiteGC { + get { return EnsureGC (gtksharp_gtk_style_get_white_gc (Handle)); } +} + +[DllImport("gtksharpglue")] +static extern IntPtr gtksharp_gtk_style_get_black_gc (IntPtr style); + +public Gdk.GC BlackGC { + get { return EnsureGC (gtksharp_gtk_style_get_black_gc (Handle)); } +} + +[DllImport("gtksharpglue")] +static extern IntPtr[] gtksharp_gtk_style_get_fg_gc (IntPtr style); + +public Gdk.GC[] ForegroundGC { + get { + IntPtr[] raws = gtksharp_gtk_style_get_fg_gc (Handle); + Gdk.GC[] ret = new Gdk.GC[raws.Length]; + int i = 0; + foreach (IntPtr raw in raws) { + ret[i++] = EnsureGC (raw); + } + return ret; + } +} + +[DllImport("gtksharpglue")] +static extern IntPtr[] gtksharp_gtk_style_get_bg_gc (IntPtr style); + +public Gdk.GC[] BackgroundGC { + get { + IntPtr[] raws = gtksharp_gtk_style_get_bg_gc (Handle); + Gdk.GC[] ret = new Gdk.GC[raws.Length]; + int i = 0; + foreach (IntPtr raw in raws) { + ret[i++] = EnsureGC (raw); + } + return ret; + } +} + +[DllImport("gtksharpglue")] +static extern IntPtr gtksharp_gtk_style_get_white (IntPtr style); + +public Gdk.Color White { + get { return Gdk.Color.New (gtksharp_gtk_style_get_white (Handle)); } +} + +[DllImport("gtksharpglue")] +static extern IntPtr gtksharp_gtk_style_get_black (IntPtr style); + +public Gdk.Color Black { + get { return Gdk.Color.New (gtksharp_gtk_style_get_black (Handle)); } +} + +[DllImport("gtksharpglue")] +static extern Gdk.Color[] gtksharp_gtk_style_get_fg (IntPtr style); +public Gdk.Color[] Foreground { + get { + return gtksharp_gtk_style_get_fg (Handle); + } +} + +static extern Gdk.Color[] gtksharp_gtk_style_get_bg (IntPtr style); +public Gdk.Color[] Background { + get { + return gtksharp_gtk_style_get_bg (Handle); + } +} + diff --git a/gtk/Widget.custom b/gtk/Widget.custom new file mode 100644 index 000000000..e36baebfa --- /dev/null +++ b/gtk/Widget.custom @@ -0,0 +1,17 @@ +// +// Gtk.Widget.custom - Gtk Widget class customizations +// +// Author: Rachel Hestilow +// +// Copyright (C) 2002 Rachel Hestilow +// +// This code is inserted after the automatically generated code. +// + +[DllImport("gtksharpglue")] +static extern IntPtr gtksharp_gtk_widget_get_allocation (IntPtr style); + +public Gdk.Rectangle Allocation { + get { return Gdk.Rectangle.New (gtksharp_gtk_widget_get_allocation (Handle)); } +} + diff --git a/parser/Gdk.metadata b/parser/Gdk.metadata index a6f6aba27..d78bd433e 100644 --- a/parser/Gdk.metadata +++ b/parser/Gdk.metadata @@ -42,7 +42,7 @@ - + @@ -63,5 +63,48 @@ + + + RenderThresholdAlpha + RenderToDrawable + RenderToDrawableAlpha + RenderPixmapAndMaskForColormap + RenderPixmapAndMask + GetFromDrawable + GetFromImage + + + + library + gdk-x11-2.0 + + + + + + + + GetPointer + + + + gint* + pass_as + out + + + + + + GetPointer + + + + GdkModifierType* + pass_as + out + + + diff --git a/parser/README b/parser/README index c0f285a88..e517381b5 100644 --- a/parser/README +++ b/parser/README @@ -6,6 +6,7 @@ glib-2.0.3 pango-1.0.3 atk-1.0.2 gtk+-2.0.5 + * you need gdkpixbuf*.[ch] from gdk/ symlinked into gdk-pixbuf/ libgnome-2.0.1 libgnomecanvas-2.0.1 libgnomeui-2.0.1 diff --git a/parser/gapi2xml.pl b/parser/gapi2xml.pl index cb4f71ef8..31648f142 100755 --- a/parser/gapi2xml.pl +++ b/parser/gapi2xml.pl @@ -438,9 +438,15 @@ sub addFuncElems next if ($mname =~ /^_/); $obj_el = ""; $prefix = $mname; + $prepend = undef; while ($prefix =~ /(\w+)_/) { $prefix = $key = $1; $key =~ s/_//g; + # FIXME: lame Gdk API hack + if ($key eq "gdkdraw") { + $key = "gdkdrawable"; + $prepend = "draw_"; + } if (exists ($elem_table{$key})) { $prefix .= "_"; $obj_el = $elem_table{$key}; @@ -456,7 +462,7 @@ sub addFuncElems $el = addNameElem($obj_el, 'constructor', $mname); $drop_1st = 0; } else { - $el = addNameElem($obj_el, 'method', $mname, $prefix); + $el = addNameElem($obj_el, 'method', $mname, $prefix, $prepend); $mdef =~ /(.*?)\w+\s*\(/; addReturnElem($el, $1); $mdef =~ /\(\s*(const)?\s*(\w+)/; @@ -500,13 +506,18 @@ sub addFuncElems sub addNameElem { - my ($node, $type, $cname, $prefix) = @_; + my ($node, $type, $cname, $prefix, $prepend) = @_; my $elem = $doc->createElement($type); $node->appendChild($elem); if ($prefix) { $cname =~ /$prefix(\w+)/; - $elem->setAttribute('name', StudlyCaps($1)); + if ($prepend) { + $name = $prepend . $1; + } else { + $name = $1; + } + $elem->setAttribute('name', StudlyCaps($name)); } if ($cname) { $elem->setAttribute('cname', $cname); diff --git a/sample/Makefile.in b/sample/Makefile.in index de56bd648..4062b2657 100755 --- a/sample/Makefile.in +++ b/sample/Makefile.in @@ -14,7 +14,7 @@ windows: $(CSC) /unsafe /out:gtk-hello-world.exe /r:../glib/glib-sharp.dll /r:../gtk/gtk-sharp.dll /r:../gdk/gdk-sharp.dll HelloWorld.cs $(CSC) /unsafe /out:button.exe /r:../glib/glib-sharp.dll /r:../gtk/gtk-sharp.dll ButtonApp.cs -linux: gtk-hello-world.exe button.exe menu.exe $(GNOME_TARGETS) +linux: gtk-hello-world.exe button.exe menu.exe size.exe scribble.exe $(GNOME_TARGETS) gtk-hello-world.exe: HelloWorld.cs $(MCS) --unsafe -o gtk-hello-world.exe $(local_paths) $(all_assemblies) HelloWorld.cs @@ -28,6 +28,12 @@ button.exe: ButtonApp.cs menu.exe: Menu.cs $(MCS) --unsafe -o menu.exe $(local_paths) $(all_assemblies) Menu.cs +size.exe: Size.cs + $(MCS) --unsafe -o size.exe $(local_paths) $(all_assemblies) Size.cs + +scribble.exe: Scribble.cs + $(MCS) --unsafe -o scribble.exe $(local_paths) $(all_assemblies) Scribble.cs + clean: rm -f *.exe diff --git a/sample/Scribble.cs b/sample/Scribble.cs new file mode 100644 index 000000000..b2bf9a08e --- /dev/null +++ b/sample/Scribble.cs @@ -0,0 +1,131 @@ +// Scribble.cs - port of Gtk+ scribble demo +// +// Author: Rachel Hestilow +// +// (c) 2002 Rachel Hestilow + +namespace GtkSamples { + + using Gtk; + using Gdk; + using GtkSharp; + using System; + + public class Scribble { + private static Gtk.DrawingArea darea; + private static Gdk.Pixmap pixmap = null; + + public static int Main (string[] args) + { + Application.Init (); + Gtk.Window win = new Gtk.Window ("Scribble demo"); + win.DeleteEvent += new DeleteEventHandler (Window_Delete); + + darea = new Gtk.DrawingArea (); + darea.SetSizeRequest (200, 200); + win.Add (darea); + + darea.ExposeEvent += new ExposeEventHandler (ExposeEvent); + darea.ConfigureEvent += new ConfigureEventHandler (ConfigureEvent); + darea.MotionNotifyEvent += new MotionNotifyEventHandler (MotionNotifyEvent); + darea.ButtonPressEvent += new ButtonPressEventHandler (ButtonPressEvent); + darea.Events = EventMask.ExposureMask | + EventMask.LeaveNotifyMask | + EventMask.ButtonPressMask | + EventMask.PointerMotionMask | + EventMask.PointerMotionHintMask; + + win.ShowAll (); + Application.Run (); + return 0; + } + + static void Window_Delete (object obj, DeleteEventArgs args) + { + SignalArgs sa = (SignalArgs) args; + Application.Quit (); + sa.RetVal = true; + } + + static void ExposeEvent (object obj, ExposeEventArgs args) + { + Gdk.EventExpose ev = args.Event; + Gdk.Window window = ev.window; + // FIXME: mcs bug + Gdk.Rectangle area = ev.area; + // FIXME: array marshalling not done yet so no FG */ + window.DrawDrawable (darea.Style.BlackGC, + pixmap, + area.x, area.y, + area.x, area.y, + area.width, area.height); + + SignalArgs sa = (SignalArgs) args; + sa.RetVal = false; + } + + static void ConfigureEvent (object obj, ConfigureEventArgs args) + { + Gdk.EventConfigure ev = args.Event; + Gdk.Window window = ev.window; + Gdk.Rectangle allocation = darea.Allocation; + pixmap = new Gdk.Pixmap (window, + allocation.width, + allocation.height, + -1); + pixmap.DrawRectangle (darea.Style.WhiteGC, 1, 0, 0, + allocation.width, allocation.height); + + SignalArgs sa = (SignalArgs) args; + sa.RetVal = true; + } + + static void DrawBrush (double x, double y) + { + Gdk.Rectangle update_rect = new Gdk.Rectangle (); + update_rect.x = (int) x - 5; + update_rect.y = (int) y - 5; + update_rect.width = 10; + update_rect.height = 10; + + pixmap.DrawRectangle (darea.Style.BlackGC, 1, + update_rect.x, update_rect.y, + update_rect.width, update_rect.height); + darea.QueueDrawArea (update_rect.x, update_rect.y, + update_rect.width, update_rect.height); + } + + static void ButtonPressEvent (object obj, ButtonPressEventArgs args) + { + Gdk.EventButton ev = args.Event; + if (ev.button == 1 && pixmap != null) + DrawBrush (ev.x, ev.y); + + SignalArgs sa = (SignalArgs) args; + sa.RetVal = true; + } + + static void MotionNotifyEvent (object obj, MotionNotifyEventArgs args) + { + int x, y; + Gdk.ModifierType state; + Gdk.EventMotion ev = args.Event; + Gdk.Window window = ev.window; + + if (ev.is_hint != 0) + window.GetPointer (out x, out y, out state); + else { + x = (int) ev.x; + y = (int) ev.y; + state = (Gdk.ModifierType) ev.state; + } + + if ((state & Gdk.ModifierType.Button1Mask) != 0 && pixmap != null) + DrawBrush (x, y); + + SignalArgs sa = (SignalArgs) args; + sa.RetVal = true; + } + } +} + diff --git a/sources/Gdk.metadata b/sources/Gdk.metadata index a6f6aba27..d78bd433e 100644 --- a/sources/Gdk.metadata +++ b/sources/Gdk.metadata @@ -42,7 +42,7 @@ - + @@ -63,5 +63,48 @@ + + + RenderThresholdAlpha + RenderToDrawable + RenderToDrawableAlpha + RenderPixmapAndMaskForColormap + RenderPixmapAndMask + GetFromDrawable + GetFromImage + + + + library + gdk-x11-2.0 + + + + + + + + GetPointer + + + + gint* + pass_as + out + + + + + + GetPointer + + + + GdkModifierType* + pass_as + out + + + diff --git a/sources/README b/sources/README index c0f285a88..e517381b5 100644 --- a/sources/README +++ b/sources/README @@ -6,6 +6,7 @@ glib-2.0.3 pango-1.0.3 atk-1.0.2 gtk+-2.0.5 + * you need gdkpixbuf*.[ch] from gdk/ symlinked into gdk-pixbuf/ libgnome-2.0.1 libgnomecanvas-2.0.1 libgnomeui-2.0.1