Re: Setting the background colour of a container



On Thu, 07 Sep 2000 01:44:25 -0400, Wolfgang Sourdeau <wolfgang ultim net> wrote:
Hi,


What is the way of setting the background colour of a container such
as a GtkTable? I have tried different ways during 2 hours without
success...

One problem you could be having is that the widgets you put into
the table take up all the space and you don't see the change in the
table's background color.  Try changing the background color of the
widgets you place into the table.


Another question is, in the same table, how do I insert buttons with a
maximum size ? What I was using before is a GtkFixed instead of the
table, which used to work fine but is less pretty.

You can put the widget into a GtkFixed and then put the GtkFixed into
the table and then set the widget's size to the max value.

#include <gtk/gtk.h>

gchar *rcstring = "
style 'blue_background' {
        bg[NORMAL] = { 0.0, 0.0, 1.0 }
}

widget '*some_blue_fixed_widget' style 'blue_background'
";

int main (int argc, char *argv[])
{
        GtkWidget *win, *table;
        guint row, col;

        gtk_init (&argc, &argv);
        /* if you put the above rcstring into a file you can use
         * gtk_rc_parse (filename) instead of gtk_rc_parse_string ()
         * and change the values at runtime.
         */
        gtk_rc_parse_string (rcstring);

        win = gtk_window_new (GTK_WINDOW_TOPLEVEL);

        table = gtk_table_new (5, 5, FALSE);
        gtk_container_add (GTK_CONTAINER (win), table);

        for (row = 0;  row < 5;  row++) {
                for (col = 0;  col < 5;  col++) {
                        GtkWidget *fixed, *button;

                        fixed = gtk_fixed_new ();
                        gtk_widget_set_name (fixed, "some_blue_fixed_widget");

                        button = gtk_button_new ();
                        gtk_widget_set_usize (button,
                                        10 + row * 10,
                                        10 + col * 10);
                        gtk_fixed_put (GTK_FIXED (fixed), button, 0, 0);
                        gtk_table_attach_defaults (GTK_TABLE (table), fixed,
                                                row, row + 1,
                                                col, col + 1);
                }
        }

        gtk_widget_show_all (win);

        /* just resizing win so that you can see the blue background of the
         * fixed widgets
         */
        gtk_widget_set_usize (win, 400, 400);
        gtk_main ();
        return 0;
}



Thanks in advance,


Wolfgang

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list






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