From b00846dea221344f43c4335af6ee7f6305ead498 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Fri, 28 Feb 2003 20:29:20 +0000 Subject: [PATCH] Add examples to Foreground/Background, because they are far from obvious svn path=/trunk/gtk-sharp/; revision=12070 --- doc/en/Gdk/GC.xml | 76 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 70 insertions(+), 6 deletions(-) diff --git a/doc/en/Gdk/GC.xml b/doc/en/Gdk/GC.xml index 89aa8280b..7fffa04b7 100644 --- a/doc/en/Gdk/GC.xml +++ b/doc/en/Gdk/GC.xml @@ -435,9 +435,11 @@ a Gdk.Colormap a Gdk.Colormap - Sets the colormap for the GC to the given - colormap. The depth of the colormap's visual must match the - depth of the drawable for which the GC was created. + + Fetches or changes the colormap of the GC. The depth of + the colormap's visual must match the depth of the drawable + for which the GC was created. + @@ -480,7 +482,34 @@ the new foreground color. the new foreground color. - Sets the foreground color for a graphics context. + + Sets the foreground color for a graphics context to the + given color. The color must have been allocated for this + to work. + + + + Gdk.GC my_gc = new Gdk.GC (gdk_window); + + // + // Create the color + // + Gdk.Color red_color = new Gdk.Color (0xff, 0, 0); + + // + // Allocate it + // + Gdk.Colormap colormap = Gdk.Colormap.System; + colormap.AllocColor (ref red_color, true, true); + + my_gc.Foreground = red_color; + + // + // Draw diagonal, using the GC with the red color + // + gdk_window.DrawLine (my_gc, 0, 0, 100, 100); + + @@ -579,8 +608,43 @@ the new background color. the new background color. - Sets the background color for a graphics - context. + + Sets the background color for a graphics + context. The color must have been allocated. + + + + Gdk.GC my_gc = new Gdk.GC (gdk_window); + + // + // Create the color + // + Gdk.Color back_color = new Gdk.Color (0xff, 0, 0); + Gdk.Color fore_color = new Gdk.Color (0, 0, 0xff); + + // + // Allocate them + // + Gdk.Colormap colormap = Gdk.Colormap.System; + colormap.AllocColor (ref back_color, true, true); + Gdk.Colormap colormap = Gdk.Colormap.System; + colormap.AllocColor (ref fore_color, true, true); + + my_gc.Background = back_color; + my_gc.Background = fore_color; + + // + // Draw a thick line, alternating between foreground and + // background colors + // + my_gc.SetLineAttributes (3, LineStyle.DoubleDash, CapStyle.NotLast, JoinStyle.Round); + + // + // Draw diagonal, using the GC with the red color + // + gdk_window.DrawLine (my_gc, 0, 0, 100, 100); + +