Re: Setting the background color of a GtkFixed
- From: Olexiy Avramchenko <olexiy ctech cn ua>
- To: Tapan Satpathy Ansuman-A19108 <ansuman motorola com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Setting the background color of a GtkFixed
- Date: Wed, 10 Nov 2004 10:35:12 +0200
Tapan Satpathy Ansuman-A19108 wrote:
Hi,
I want to create a Frame in which I can put many child widgets.
For that I create a Frame and put a GtkFixed inside this. I want to add some colours dynamically to the 
Parent Frame. But gtk_widget_modify_bg(...) doesn't seem to be working on GtkFixed.
Is there any method to do so? Or should I use some other widget instead of GtkFixed ?
 
Hello, the one possible solution is to use expose-event callback for the 
fixed container, like this:
static gboolean
fixed_expose_event (GtkWidget *widget, GdkEventExpose *event)
{
       gint i,n;
       GdkRectangle *rects;
       gdk_region_get_rectangles(event->region, &rects, &n);
       for (i=0; i<n; i++)
               gdk_draw_rectangle(
                                       widget->window,
                                       
widget->style->bg_gc[GTK_STATE_NORMAL],
                                       TRUE,
                                       rects[i].x,     rects[i].y,
                                       rects[i].width, rects[i].height
               );
       return FALSE;
}
It uses background pixel value for the GTK_STATE_NORMAL, so you can use 
call gtk_widget_modify_bg() function for changing background colour 
(remember that this function wants allocated colour, with real pixel value).
*NOTE* callback _must_ return FALSE or you'll see no container's children.
   Olexiy
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]