Re: color/colormap oddities



Karl H. Beckers wrote:

Hello,

any pointers to a solution welcome, TIA ...

I have this app which has one GtkWindow and a number of small GtkDialogs
I'm abusing to mark an area on screen with an always-on-top rectangle.

These GtkDialogs are painted red in an expose-event event handler.

//paint parts of frame on expose
static gint on_expose_paint(GtkWidget *w, GdkEventExpose *e) {
        GdkGC *gc;
        GdkColormap *colormap;
        GdkColor g_col;
        int n;
gc = w->style->fg_gc[GTK_WIDGET_STATE (w)];
        colormap = gtk_widget_get_colormap (w);
        if (gdk_color_parse("red", &g_col)){
if (gdk_colormap_alloc_color(colormap, &g_col, FALSE, TRUE)) {
                        gdk_gc_set_function ( gc, GDK_COPY );
                        gdk_gc_set_fill ( gc, GDK_SOLID );
gdk_gc_set_line_attributes ( gc, 3, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER );
                        gdk_gc_set_foreground ( gc, &g_col );
gdk_draw_rectangle (w->window, gc, TRUE, 0, 0, w->allocation.width, w->allocation.height);
                 }
}
}



If I do this, some widgets get painted red as well (even in other dialogs
opened from the main window), e.g. the downward arrow in a spinbutton
where you're already at the lowest value of the range.

Looks to me like I'm messing up my colormap ... but how and why (on
a TrueColor display).

Any pointers and RTFMs welcom,

You've messed style's gc, not colormap. You have to create your own gc and use it for painting.

   Olexiy





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]