Re: Mod to hbox/vbox



On Thu, Jan 21, 1999 at 08:04:33PM -0500, Jeff Evarts wrote:
> I'd like to be able to weight the amount of space given to
> children of an hbox or vbox.
> 
> I can't seem to find an easy way to say "I have three
> expandable children in this hbox, please make sure the
> middle one gets 3/5 of the space, and the left and right
> children get 1/5 each". If there is a way to do this
> already, please email me and skip the rest of this document.
> 
...
> Well, any thoughts?

You do not want to use a box for this, you want to use a 
table.  Below is an example for you.  The important part
is that the middle button takes up 3 columns in the table
and the other two only take one column each.

#include <gtk/gtk.h>

int
main (int argc, char **argv)
{
  GtkWidget *window;
  GtkWidget *table;
  GtkWidget *button1;
  GtkWidget *button2;
  GtkWidget *button3;

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

  table = gtk_table_new (1, 5, TRUE);
  gtk_container_add (GTK_CONTAINER (window), table);
  
  button1 = gtk_button_new_with_label ("1");
  button2 = gtk_button_new_with_label ("2");
  button3 = gtk_button_new_with_label ("3");

  gtk_table_attach_defaults (GTK_TABLE (table), button1, 0, 1, 0, 1);
  gtk_table_attach_defaults (GTK_TABLE (table), button2, 1, 4, 0, 1);
  gtk_table_attach_defaults (GTK_TABLE (table), button3, 4, 5, 0, 1);

  gtk_widget_show_all (window);

  gtk_main ();
}

-Shawn

--
Shawn T. Amundson               
amundson@gimp.org               http://www.gimp.org/~amundson

"The assumption that the universe looks the same in every
 direction is clearly not true in reality." - Stephen Hawking



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