RE: Setting the background color of a GtkFixed



Hi,

Thanks. This worked well for me.

I have two more questions.

Is it possible to make the widget transparent ? I want to put my Frame as a child of the fixed of another 
Frame, and I want to make the child transparent. Is there any way?

Seocond,

In frame heirarchy [Considering my approach to frame, ie, Frame = frame + fixed], if I make a hirearchy of 
frames, the child frames are drifted right. I am putting the child frame in (0, 0) of the parent frame's 
Fixed. I think this is happening because of the border of the frame, can I avoid this?

|--------|
||-------|
|||------|
|||______|

This for reference.

Regards.
Ansuman



-----Original Message-----
From: Olexiy Avramchenko [mailto:olexiy ctech cn ua] 
Sent: Wednesday, November 10, 2004 2:05 PM
To: Tapan Satpathy Ansuman-A19108
Cc: gtk-app-devel-list gnome org
Subject: Re: Setting the background color of a GtkFixed


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]