From: Jim Evins Date: Sun, 3 Nov 2002 18:16:31 +0000 (+0000) Subject: Adds code to set the view canvas's background color. X-Git-Tag: glabels-2_3_0~714 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a922bbec35a3b9a3fff8fdf38537a460c8b48c71;p=glabels Adds code to set the view canvas's background color. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@173 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- diff --git a/glabels2/src/color.c b/glabels2/src/color.c index ad84ea48..c3cc745e 100644 --- a/glabels2/src/color.c +++ b/glabels2/src/color.c @@ -37,3 +37,20 @@ gl_color_set_opacity (guint color, return new_color; } +/*****************************************************************************/ +/* Convert canvas color into a GdkColor */ +/*****************************************************************************/ +GdkColor * +gl_color_to_gdk_color (guint color) +{ + GdkColor *gdk_color; + + gdk_color = g_new0 (GdkColor, 1); + + gdk_color->red = GL_COLOR_F_RED (color) * 65535; + gdk_color->green = GL_COLOR_F_GREEN (color) * 65535; + gdk_color->blue = GL_COLOR_F_BLUE (color) * 65535; + + return gdk_color; +} + diff --git a/glabels2/src/color.h b/glabels2/src/color.h index 22fe359d..4ca88e2d 100644 --- a/glabels2/src/color.h +++ b/glabels2/src/color.h @@ -40,7 +40,9 @@ G_BEGIN_DECLS #define GL_COLOR_F_BLUE(x) ( (((x)>>8) & 0xff) / 255.0 ) #define GL_COLOR_F_ALPHA(x) ( ( (x) & 0xff) / 255.0 ) -guint gl_color_set_opacity (guint color, gdouble opacity); +guint gl_color_set_opacity (guint color, gdouble opacity); + +GdkColor *gl_color_to_gdk_color (guint color); G_END_DECLS diff --git a/glabels2/src/view.c b/glabels2/src/view.c index 1ba3e58f..fc24a7d8 100644 --- a/glabels2/src/view.c +++ b/glabels2/src/view.c @@ -46,9 +46,10 @@ /* Private macros and constants. */ /*==========================================================================*/ +#define BG_COLOR GL_COLOR (192, 192, 192) #define OUTLINE_COLOR GL_COLOR (173, 216, 230) #define PAPER_COLOR GL_COLOR (255, 255, 255) -#define GRID_COLOR GL_COLOR (192, 192, 192) +#define GRID_COLOR BG_COLOR #define MARKUP_COLOR GL_COLOR (240, 100, 100) #define SEL_LINE_COLOR GL_COLOR_A (0, 0, 255, 128) @@ -359,9 +360,10 @@ gl_view_construct (glView *view) static GtkWidget * gl_view_construct_canvas (glView *view) { - gdouble scale; - glLabel *label = view->label; - gdouble label_width, label_height; + gdouble scale; + glLabel *label = view->label; + gdouble label_width, label_height; + GdkColor *bg_color; gl_debug (DEBUG_VIEW, "START"); @@ -372,6 +374,10 @@ gl_view_construct_canvas (glView *view) view->canvas = gnome_canvas_new_aa (); gtk_widget_pop_colormap (); + bg_color = gl_color_to_gdk_color (BG_COLOR); + gtk_widget_modify_bg (GTK_WIDGET(view->canvas), GTK_STATE_NORMAL, bg_color); + g_free (bg_color); + gl_label_get_size (label, &label_width, &label_height); gl_debug (DEBUG_VIEW, "Label size: w=%lf, h=%lf", label_width, label_height);