problem setting the background color of a widget
- From: Ronald Bultje <rbultje tux bitfreak net>
- To: GTK Mailing List <gtk-list gnome org>
- Subject: problem setting the background color of a widget
- Date: 14 May 2001 20:30:01 +0200
Hey people,
here's a Really Stupid Question (tm).
If I make something like a event-box, how do I set the backgroundcolor
to, for example, black?
I tried the following code:
GdkColor *color;
GdkGC *gc;
GtkWidget *widget;
widget = gtk_event_box_new();
gtk_widget_set_usize(GTK_WIDGET(widget), width, height);
/* the vbox2 is already there */
gtk_box_pack_start (GTK_BOX (vbox2), widget, FALSE, FALSE, 0);
gtk_widget_show(widget);
gc = gdk_gc_new(window->window);
color = (GdkColor *)malloc(sizeof(GdkColor));
color->red = 0;
color->green = 0;
color->blue = 0;
color->pixel = (gulong)(0);
gdk_color_alloc(gtk_widget_get_colormap(window), color);
gdk_gc_set_foreground(gc, color); (I also tried gdk_gc_set_background)
/*gdk_draw_rectangle(lavedit_tv->window, gc, 1, 0, 0, tv_width_edit,
tv_height_edit);*/
gdk_gc_destroy(gc);
If I uncomment the gdk_draw_rectangle, it will segfault (probably
because one of the parents has not been realized yet).
But gtk_widget_realize() was a really bad idea, If I remember correctly.
So..... what am I doing wrong, not understanding correctly or is there a
much better way to do this?
Thanks in advance,
Ronald
--
---------------------------------------------------.
-- .-. | Ronald Bultje |
-- /V\ | Running: Linux 2.4.4 and OpenBSD 2.8 |
-- // \\ | E-mail : rbultje ronald bitfreak net |
-- /( )\ | WWW : http://ronald.bitfreak.net/ |
-- ^^-^^ | *** Warning: Unix Addicted *** |
---------------------------------------------------'
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]