Re: GtkAlignment makes things smaller, but surrouning don't get bigger



On Mon, 2005-03-07 at 18:32 -0800, Ben Johnson wrote:

> this is more or less what I'm doing...
> 
>   mydialog = gtk_dialog_new ();
>   gtk_window_set_title        (GTK_WINDOW (mydialog), "Payment Amount");
>   gtk_window_set_position     (GTK_WINDOW (mydialog), GTK_WIN_POS_CENTER);
>   gtk_window_set_modal        (GTK_WINDOW (mydialog), TRUE);
>   gtk_window_set_default_size (GTK_WINDOW (mydialog), 320, 350);
>   gtk_window_set_type_hint    (GTK_WINDOW (mydialog), GDK_WINDOW_TYPE_HINT_DIALOG);
> 
>   vbox8 = GTK_DIALOG (mydialog)->vbox;
>   gtk_widget_show (vbox8);
> 
>   mycalculator = createcustwidgetfunc_enterpaymentdlg_handleamount ("mycalculator", "", "", 0, 0);
>   gtk_widget_show (mycalculator);
>   gtk_box_pack_start (GTK_BOX (vbox8), mycalculator, TRUE, TRUE, 0);
>   GTK_WIDGET_UNSET_FLAGS (mycalculator, GTK_CAN_FOCUS);
>   GTK_WIDGET_UNSET_FLAGS (mycalculator, GTK_CAN_DEFAULT);
> 
>   alignment14 = gtk_alignment_new (0.5, 0.5, 1, 0.5);
>   gtk_widget_show (alignment14);
>   gtk_box_pack_start (GTK_BOX (vbox8), alignment14, TRUE, TRUE, 0);

Try making this FALSE, FALSE ... you've said "if you have excess space,
give it to vbox8 and alignment14 equally.

>   hbox11 = gtk_hbox_new (TRUE, 0);
>   gtk_widget_show (hbox11);
>   gtk_container_add (GTK_CONTAINER (alignment14), hbox11);
> 
> After that I add some buttons to hbox11 setting the fill and expand
> properties to TRUE (which doesn't affect the layout).  So... all expand
> and fill props (that I know of) are set to TRUE and the alignment has
> default values except the yscale is set to .5.
> 
> The result of this is hbox11 takes up less space and mycalculator
> doesn't take up any additional space, leaving some empty space around
> hbox11.
> 
> if I change the alignment so that it doesn't get any smaller,
> 
>   alignment14 = gtk_alignment_new (0.5, 0.5, 1, 1);
> 
> ...then the hbox11 is too big.
> 
> If I instead change either the expand or fill props on alignment14 to
> false then I wind up with hbox11 being too small, regardless of what the
> yscale is set to.  setting expand to false results in the calculator
> widget taking up the available space.  leaving expand set to true and
> setting fill to false results in too small box11 buttons with a lot of
> wasted goofy looking space.

You aren't making sense here. Where do you want the excess space - 
the "calculator" or the hbox at the bottom? Both? Make a decision.

If you want some fixed amount of space around the buttons in  
hbox11, use gtk_container_set_border_width(). 

In the end, size allocation in GTK+ is utterly simple:

 Phase 1: "Please ask your children how much space they need, 
           add in any space you need yourself and tell me how
           much that is"

 Phase 2: "OK, you have this much space, please divide between
           yourself and your children"

All expand and fill do is determine how a hbox/vbox makes that
division in phase 2. 

Regards,
						Owen

Attachment: signature.asc
Description: This is a digitally signed message part



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