diff --git a/ChangeLog b/ChangeLog index c31ae6173..e226f4e19 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2002-10-07 Vladimir Vukicevic + + * glue/style.c, gtk/Style.custom: handle + getting GC's and colors correctly -- it's not possible + to marshal arrays from C-land to mono correctly, + so indexed accessors have to be used. + 2002-10-08 Duncan Mak * gdk/Color.custom: diff --git a/glue/style.c b/glue/style.c index c87f5f1a6..69ad9789a 100644 --- a/glue/style.c +++ b/glue/style.c @@ -23,18 +23,18 @@ gtksharp_gtk_style_get_black_gc (GtkStyle *style) return style->black_gc; } -GdkGC** -gtksharp_gtk_style_get_fg_gc (GtkStyle *style) +GdkGC* +gtksharp_gtk_style_get_fg_gc (GtkStyle *style, int i) { - g_object_ref (G_OBJECT (style->fg_gc)); - return style->fg_gc; + g_object_ref (G_OBJECT (style->fg_gc[i])); + return style->fg_gc[i]; } -GdkGC** -gtksharp_gtk_style_get_bg_gc (GtkStyle *style) +GdkGC* +gtksharp_gtk_style_get_bg_gc (GtkStyle *style, int i) { - g_object_ref (G_OBJECT (style->bg_gc)); - return style->bg_gc; + g_object_ref (G_OBJECT (style->bg_gc[i])); + return style->bg_gc[i]; } GdkColor* @@ -50,15 +50,15 @@ gtksharp_gtk_style_get_black (GtkStyle *style) } GdkColor* -gtksharp_gtk_style_get_fg (GtkStyle *style) +gtksharp_gtk_style_get_fg (GtkStyle *style, int i) { - return style->fg; + return &style->fg[i]; } -GdkColor** -gtksharp_gtk_style_get_bg (GtkStyle *style) +GdkColor* +gtksharp_gtk_style_get_bg (GtkStyle *style, int i) { - return style->bg; + return &style->bg[i]; } int diff --git a/gtk/Style.custom b/gtk/Style.custom index e25092974..ed049bbc3 100644 --- a/gtk/Style.custom +++ b/gtk/Style.custom @@ -32,30 +32,40 @@ public Gdk.GC BlackGC { } [DllImport("gtksharpglue")] -static extern IntPtr[] gtksharp_gtk_style_get_fg_gc (IntPtr style); +static extern IntPtr gtksharp_gtk_style_get_fg_gc (IntPtr style, int i); -public Gdk.GC[] ForegroundGC { +public Gdk.GC ForegroundGC (StateType state) +{ + IntPtr raw = gtksharp_gtk_style_get_fg_gc (Handle, (int) state); + return EnsureGC (raw); +} + +public Gdk.GC[] ForegroundGCs { get { - IntPtr[] raws = gtksharp_gtk_style_get_fg_gc (Handle); + IntPtr[] raws = new IntPtr[6]; Gdk.GC[] ret = new Gdk.GC[raws.Length]; - int i = 0; - foreach (IntPtr raw in raws) { - ret[i++] = EnsureGC (raw); + for (int i = 0; i < 6; i++) { + ret[i] = EnsureGC (gtksharp_gtk_style_get_fg_gc (Handle, i)); } return ret; } } [DllImport("gtksharpglue")] -static extern IntPtr[] gtksharp_gtk_style_get_bg_gc (IntPtr style); +static extern IntPtr gtksharp_gtk_style_get_bg_gc (IntPtr style, int i); -public Gdk.GC[] BackgroundGC { +public Gdk.GC BackgroundGC (StateType state) +{ + IntPtr raw = gtksharp_gtk_style_get_bg_gc (Handle, (int) state); + return EnsureGC (raw); +} + +public Gdk.GC[] BackgroundGCs { get { - IntPtr[] raws = gtksharp_gtk_style_get_bg_gc (Handle); + IntPtr[] raws = new IntPtr[6]; Gdk.GC[] ret = new Gdk.GC[raws.Length]; - int i = 0; - foreach (IntPtr raw in raws) { - ret[i++] = EnsureGC (raw); + for (int i = 0; i < 6; i++) { + ret[i] = EnsureGC (gtksharp_gtk_style_get_bg_gc (Handle, i)); } return ret; } @@ -76,17 +86,42 @@ public Gdk.Color Black { } [DllImport("gtksharpglue")] -static extern Gdk.Color[] gtksharp_gtk_style_get_fg (IntPtr style); -public Gdk.Color[] Foreground { +static extern IntPtr gtksharp_gtk_style_get_bg (IntPtr style, int i); + +public Gdk.Color Background (StateType state) +{ + IntPtr raw = gtksharp_gtk_style_get_bg (Handle, (int) state); + return Gdk.Color.New (raw); +} + +public Gdk.Color[] Backgrounds { get { - return gtksharp_gtk_style_get_fg (Handle); + IntPtr[] raws = new IntPtr[6]; + Gdk.Color[] ret = new Gdk.Color[raws.Length]; + for (int i = 0; i < 6; i++) { + ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_bg (Handle, i)); + } + return ret; } } -static extern Gdk.Color[] gtksharp_gtk_style_get_bg (IntPtr style); -public Gdk.Color[] Background { +[DllImport("gtksharpglue")] +static extern IntPtr gtksharp_gtk_style_get_fg (IntPtr style, int i); + +public Gdk.Color Foreground (StateType state) +{ + IntPtr raw = gtksharp_gtk_style_get_fg (Handle, (int) state); + return Gdk.Color.New (raw); +} + +public Gdk.Color[] Foregrounds { get { - return gtksharp_gtk_style_get_bg (Handle); + IntPtr[] raws = new IntPtr[6]; + Gdk.Color[] ret = new Gdk.Color[raws.Length]; + for (int i = 0; i < 6; i++) { + ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_fg (Handle, i)); + } + return ret; } }