Label, Heading — Simple static text
Label
( | string | label); |
Heading
( | string | label); |
outputField
make the label look like an input field in read-only mode
boldFont
use a bold font
A Label is some text displayed in the dialog. A Heading is a text with a font marking it as heading. The text can have more than one line, in which case line feed must be entered.
{
UI::OpenDialog(
`VBox(
`Label("Hello, World!"),
`PushButton("&OK")
)
);
UI::UserInput();
UI::CloseDialog();
}
{
UI::OpenDialog(
`VBox(
`Label("Labels can have\nmultiple lines." ),
`PushButton("&OK")
)
);
UI::UserInput();
UI::CloseDialog();
}
{
// Build dialog with one label, 4 Beatles buttons and an OK button.
UI::OpenDialog(
`VBox(
`Label("Select your favourite Beatle:"),
`Label(`id(`beatle), `opt(`outputField), " "),
`HBox(
`PushButton(`id(`john), "John" ),
`PushButton(`id(`paul), "Paul" ),
`PushButton(`id(`george), "George"),
`PushButton(`id(`ringo), "Ringo" )),
`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(`beatle), `Value, "John Lennon");
else if ( button == `paul ) UI::ChangeWidget(`id(`beatle), `Value, "Paul McCartney");
else if ( button == `george ) UI::ChangeWidget(`id(`beatle), `Value, "George Harrison");
else if ( button == `ringo ) UI::ChangeWidget(`id(`beatle), `Value, "Ringo Starr" );
// Recalculate the layout - this is necessary since the label widget
// doesn't recompute its size upon changing its value.
UI::RecalcLayout();
} until ( button == `ok );
// Retrieve the label's value.
string name = (string) UI::QueryWidget(`id(`beatle), `Value);
// Close the dialog.
// Remember to read values from the dialog's widgets BEFORE closing it!
UI::CloseDialog();
// Pop up a new dialog to echo the input.
UI::OpenDialog(
`VBox(
`VSpacing(),
`HBox(
`Label("You selected:"),
`Label(`opt(`outputField), name),
`HSpacing()
),
`PushButton(`opt(`default), "&OK")
)
);
UI::UserInput();
UI::CloseDialog();
}
// Label example using bold font
{
UI::OpenDialog(`VBox(
`Label( "Label using normal font" ),
`Label(`opt(`boldFont), "Label using bold font" ),
`Label( "Label using normal font" ),
`PushButton(`opt(`default), "&OK" )
)
);
UI::UserInput();
UI::CloseDialog();
}
{
// Build dialog with one label, 4 Beatles buttons and an OK button.
UI::OpenDialog(
`VBox(
`Label("My favourite Beatle:"),
// `Heading(`id(`favourite), "Press one of the buttons below"),
`Heading(`id(`favourite), "(please select one)"),
`HBox(
`PushButton(`id(`john), "John" ),
`PushButton(`id(`paul), "Paul" ),
`PushButton(`id(`george), "George"),
`PushButton(`id(`ringo), "Ringo" )),
`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(`favourite), `Value, "John Lennon");
else if ( button == `paul ) UI::ChangeWidget(`id(`favourite), `Value, "Paul McCartney");
else if ( button == `george ) UI::ChangeWidget(`id(`favourite), `Value, "George Harrison");
else if ( button == `ringo ) UI::ChangeWidget(`id(`favourite), `Value, "Ringo Starr" );
} until ( button == `ok );
}
{
// Build dialog with one label, 4 Beatles buttons and an OK button.
UI::OpenDialog(
`VBox(
`Label("My favourite Beatle:"),
// `Heading(`id(`favourite), "Press one of the buttons below"),
`Heading(`id(`favourite), "(please select one)"),
`HBox(
`PushButton(`id(`john), "John" ),
`PushButton(`id(`paul), "Paul" ),
`PushButton(`id(`george), "George"),
`PushButton(`id(`ringo), "Ringo" )),
`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(`favourite), `Value, "John Lennon");
else if ( button == `paul ) UI::ChangeWidget(`id(`favourite), `Value, "Paul McCartney");
else if ( button == `george ) UI::ChangeWidget(`id(`favourite), `Value, "George Harrison");
else if ( button == `ringo ) UI::ChangeWidget(`id(`favourite), `Value, "Ringo Starr" );
} until ( button == `ok );
}
{
// Build dialog with one label, 4 Beatles buttons and an OK button.
UI::OpenDialog(
`VBox(
`Label("My favourite Beatle:"),
// `Heading(`id(`favourite), "Press one of the buttons below"),
`Heading(`id(`favourite), "(please select one)"),
`HBox(
`PushButton(`id(`john), "John" ),
`PushButton(`id(`paul), "Paul" ),
`PushButton(`id(`george), "George"),
`PushButton(`id(`ringo), "Ringo" )),
`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(`favourite), `Value, "John Lennon");
else if ( button == `paul ) UI::ChangeWidget(`id(`favourite), `Value, "Paul McCartney");
else if ( button == `george ) UI::ChangeWidget(`id(`favourite), `Value, "George Harrison");
else if ( button == `ringo ) UI::ChangeWidget(`id(`favourite), `Value, "Ringo Starr" );
} until ( button == `ok );
}