Name

HSpacing, VSpacing — Fixed size empty space for layout

Synopsis

HSpacing (void); 
VSpacing (void); 

Optional Arguments

integer|float size

Description

These widgets can be used to create empty space within a dialog to avoid widgets being cramped together - purely for aesthetical reasons. There is no functionality attached.

Do not try to use spacings with excessive sizes to create layouts! This is very likely to work for just one UI. Use spacings only to separate widgets from each other or from dialog borders. For other purposes, use `HWeight and `VWeight and describe the dialog logically rather than physically.

The size given is measured in units roughly equivalent to the size of a character in the respective UI. Fractional numbers can be used here, but text based UIs may choose to round the number as appropriate - even if this means simply ignoring a spacing when its size becomes zero.

If size is omitted, it defaults to 1. HSpacing will create a horizontal spacing with default width and zero height. VSpacing will create a vertical spacing with default height and zero width.

With options hstretch or vstretch, the spacing will at least take the amount of space specified with size, but it will be stretchable in the respective dimension. Thus, `HSpacing( `opt( `hstretch ) is equivalent to `HBox( `HSpacing( 0.5 ), `HSpacing( 0.5 ) )

Usage

 	`HSpacing( 0.3 )

Examples

          {
    // Build dialog with one text entry field, 4 Beatles buttons and an OK button.
    UI::OpenDialog(
	       `VBox( 
		     `VSpacing(),
		     `HBox(
			   `Label("Name:"),
			   `TextEntry(`id(`name), "")
			   ),
		     `VSpacing(0.2),
		     `HBox(
			   `PushButton(`id(`john),	"&John"	),	`HSpacing(0.5),
			   `PushButton(`id(`paul),	"&Paul"	),	`HSpacing(3),
			   `PushButton(`id(`george),	"&George"),	`HSpacing(0.5),
			   `PushButton(`id(`ringo),	"&Ringo"	)
			   ),
		     `VSpacing(0.5),
		     `PushButton(`id(`ok), "&OK")
		     )
	       );

    // Wait for user input.
    any button = nil;

    // Input loop that only the OK button will leave.
    // The 4 Beatles buttons will just propose a name.
    repeat
    {
        button = UI::UserInput();

	if      ( button == `john )	UI::ChangeWidget(`id(`name), `Value, "John Lennon");
	else if ( button == `paul )	UI::ChangeWidget(`id(`name), `Value, "Paul McCartney");
	else if ( button == `george )	UI::ChangeWidget(`id(`name), `Value, "George Harrison");
	else if ( button == `ringo )	UI::ChangeWidget(`id(`name), `Value, "Ringo Starr" );
	
    } until ( button == `ok );

    UI::CloseDialog();
}

        
          {
    // Layout example:
    //
    // Build a dialog with three equal sized buttons,
    // this time with some spacing in between.
    //
    // The equal `HWeight()s will make the buttons even sized.
    // When resized larger, all buttons will retain their size.
    // Excess space will go to the HSpacing() widgets between the
    // buttons, i.e. there will be empty space between the buttons.
    //
    // Notice the importance of `opt(`hstretch) for the `HSpacing()s
    // here: This is what makes the HSpacing()s grow. Otherwise, they
    // would retain a constant size, and the buttons would grow.
    
    UI::OpenDialog(
	       `HBox(
		     `HWeight(1, `PushButton( `opt(`default), "&OK" ) ),
		     `HSpacing(`opt(`hstretch), 3),
		     `HWeight(1, `PushButton( "&Cancel everything" ) ),
		     `HSpacing(`opt(`hstretch), 3),
		     `HWeight(1, `PushButton( "&Help"   ) )
		     )
	       );

    UI::UserInput();
    UI::CloseDialog();
}


          
          {
    list itemlist1 =
	[
	 `item(`id(3), "Spaghetti",	  8),
	 `item(`id(4), "Steak Sandwich",  12),
	 `item(`id(1), "Chili",           6),
	 `item(`id(2), "Salami Baguette", nil)
	];

    list itemlist2 =
	[
	 `item(`id(0), "Mercedes",	60000),
	 `item(`id(1), "AUDI",		50000),
	 `item(`id(2), "VW",		40000),
	 `item(`id(3), "BMW",		60000),
	 `item(`id(3), "Porsche",	80000)
	];

    list itemslists = [ itemlist1, itemlist2 ];

    integer listnum = 0;

    UI::OpenDialog(
		   `VBox(
			 `Heading("Prices"),
			 `MinSize( 30, 10, `Table(`id(`table), `header("Name", "price"), itemlist1) ),
			 `Right(
				`HBox(
				      `PushButton(`id(`next), "Change &Table Contents"),
				      `PushButton(`id(`cancel), "&Close")
				      )
				)
			 )
		   );

    while (UI::UserInput() != `cancel)
    {
	listnum = 1 - listnum;
	UI::ChangeWidget(`id(`table), `Items, select(itemslists, listnum, nil));
    }
    
    UI::CloseDialog();
}


          
          {
    list itemlist1 =
	[
	 `item(`id(3), "Spaghetti",	  8),
	 `item(`id(4), "Steak Sandwich",  12),
	 `item(`id(1), "Chili",           6),
	 `item(`id(2), "Salami Baguette", nil)
	];

    list itemlist2 =
	[
	 `item(`id(0), "Mercedes",	60000),
	 `item(`id(1), "AUDI",		50000),
	 `item(`id(2), "VW",		40000),
	 `item(`id(3), "BMW",		60000),
	 `item(`id(3), "Porsche",	80000)
	];

    list itemslists = [ itemlist1, itemlist2 ];

    integer listnum = 0;

    UI::OpenDialog(
		   `VBox(
			 `Heading("Prices"),
			 `MinSize( 30, 10, `Table(`id(`table), `header("Name", "price"), itemlist1) ),
			 `Right(
				`HBox(
				      `PushButton(`id(`next), "Change &Table Contents"),
				      `PushButton(`id(`cancel), "&Close")
				      )
				)
			 )
		   );

    while (UI::UserInput() != `cancel)
    {
	listnum = 1 - listnum;
	UI::ChangeWidget(`id(`table), `Items, select(itemslists, listnum, nil));
    }
    
    UI::CloseDialog();
}