Name

ColoredLabel — Simple static text with specified background and foreground color

Synopsis

ColoredLabel ( string  label ,
  color  foreground ,
  color  background ,
  integer  margin );

Parameters

string label

color foreground

color

color background

color

integer margin

around the widget in pixels

Options

boldFont

use a bold font

Properties

string Value

the label text

Usage

 	`ColoredLabel( "Hello, World!", `rgb( 255, 0, 255 ), `rgb( 0, 128, 0 ), 20 )
 

Examples

          {
    if ( ! UI::HasSpecialWidget(`ColoredLabel) )
    {
	UI::OpenDialog(
		   `VBox( 
			 `Label("Error: This UI doesn't support the ColoredLabel widget!"),
			 `PushButton(`opt(`default), "&OK")
			 )
		   );
	UI::UserInput();
	UI::CloseDialog();
	
	return;
    }
    
    UI::OpenDialog(
	       `VBox(
		     `ColoredLabel( "Hello, blue world!",
				    `rgb(255, 255, 255 ),	// foreground
				    `rgb(  0,   0, 200 ),	// background
				    30 ),
		     `PushButton(`opt(`default), "&OK")
		     )
	       );
    UI::UserInput();
    UI::CloseDialog();
}

          
          {
    if ( ! UI::HasSpecialWidget(`ColoredLabel) )
    {
	UI::OpenDialog(
		   `VBox( 
			 `Label("Error: This UI doesn't support the ColoredLabel widget!"),
			 `PushButton(`opt(`default), "&OK")
			 )
		   );
	UI::UserInput();
	UI::CloseDialog();
	
	return;
    }
    
    UI::OpenDialog(
	       `VBox(
		     `ColoredLabel( `opt(`hstretch), "red"  , `rgb( 255,  0,    0 ), `rgb( 80, 80, 80 ), 10 ),
		     `ColoredLabel( `opt(`hstretch), "green", `rgb(   0, 255,   0 ), `rgb( 80, 80, 80 ), 10 ),
		     `ColoredLabel( `opt(`hstretch), "blue" , `rgb(   0,   0, 255 ), `rgb( 80, 80, 80 ), 10 ),
		     `VSpacing(),							
		     `ColoredLabel( `opt(`hstretch), "red"  , `rgb( 80, 80, 80 ), `rgb( 255,   0,   0 ), 10 ),
		     `ColoredLabel( `opt(`hstretch), "green", `rgb( 80, 80, 80 ), `rgb(   0, 255,   0 ), 10 ),
		     `ColoredLabel( `opt(`hstretch), "blue" , `rgb( 80, 80, 80 ), `rgb(   0,   0, 255 ), 10 ),
		     `VSpacing(),
		     `PushButton(`opt(`default), "&OK")
		     )
	       );
    UI::UserInput();
    UI::CloseDialog();
}

          
          /**
 * Advanced ColoredLabel example: A sample ColoredLabel widget and sliders
 * for both foreground and background colors.
 **/
{
    if ( ! UI::HasSpecialWidget(`ColoredLabel) || ! UI::HasSpecialWidget(`Slider) )
    {
	UI::OpenDialog(
		   `VBox( 
			 `Label("Error: This UI doesn't support the required special widgets!"),
			 `PushButton(`opt(`default), "&OK")
			 )
		   );
	UI::UserInput();
	UI::CloseDialog();
	
	return;
    }

    define term sample( integer fg_red, integer fg_green, integer fg_blue,
			integer bg_red, integer bg_green, integer bg_blue ) ``{
	return `ColoredLabel( `opt(`hstretch, `boldFont),
			      "Use the sliders\nto change color",
			      `rgb( fg_red, fg_green, fg_blue ),
			      `rgb( bg_red, bg_green, bg_blue ),
			      30 );
    };
    
    UI::OpenDialog(
	       `VBox(
		     `ReplacePoint(`id(`sample), sample( 200, 0, 0,
							 0, 0, 200) ),
		     `VSpacing(),
		     `HBox(
			   `Frame( "Foreground",
				   `VBox(
					 `Slider(`id(`fg_red  ),`opt(`notify), "&red",   0, 255, 200 ),
					 `Slider(`id(`fg_green),`opt(`notify), "&green", 0, 255,   0 ),
					 `Slider(`id(`fg_blue ),`opt(`notify), "&blue",  0, 255,   0 )
					 )
				   ),
			   `Frame( "Backround",
				   `VBox(
					 `Slider(`id(`bg_red  ), `opt(`notify), "r&ed",   0, 255,   0 ),
					 `Slider(`id(`bg_green), `opt(`notify), "gree&n", 0, 255,   0 ),
					 `Slider(`id(`bg_blue ), `opt(`notify), "b&lue",  0, 255, 200 )
					 )
				   )
			   ),
		     `VSpacing(),
		     `PushButton(`id(`close), "&Close")
		     )
	       );

    any widget = nil;

    do
    {
	widget = UI::UserInput();

	if ( widget != `close )
	{
	    UI::ReplaceWidget(`id(`sample),
			  sample( (integer) UI::QueryWidget(`id(`fg_red  ), `Value ),
				  (integer) UI::QueryWidget(`id(`fg_green), `Value ),
				  (integer) UI::QueryWidget(`id(`fg_blue ), `Value ),
				  
				  (integer) UI::QueryWidget(`id(`bg_red  ), `Value ),
				  (integer) UI::QueryWidget(`id(`bg_green), `Value ),
				  (integer) UI::QueryWidget(`id(`bg_blue ), `Value )
				  )
			  );

	}
	
    } while ( widget != `close );
    
    UI::CloseDialog();
}

          
          /**
 * Advanced ColoredLabel example: A sample ColoredLabel widget and sliders
 * for both foreground and background colors and a colored label beside each slider.
 **/
{
    if ( ! UI::HasSpecialWidget(`ColoredLabel) || ! UI::HasSpecialWidget(`Slider) )
    {
	UI::OpenDialog(
		   `VBox( 
			 `Label("Error: This UI doesn't support the required special widgets!"),
			 `PushButton(`opt(`default), "&OK")
			 )
		   );
	UI::UserInput();
	UI::CloseDialog();
	
	return;
    }

    define term sample( integer fg_red, integer fg_green, integer fg_blue,
			integer bg_red, integer bg_green, integer bg_blue ) ``{
	return `ColoredLabel( `opt(`hstretch),
			      "Use the sliders\nto change color",
			      `rgb( fg_red, fg_green, fg_blue ),
			      `rgb( bg_red, bg_green, bg_blue ),
			      30 );
    };
    
    UI::OpenDialog(
	       `VBox(
		     `ReplacePoint(`id(`sample), sample( 200, 0, 0,
							 0, 0, 200) ),
		     `VSpacing(),
		     `HBox(
			   `Frame( "Foreground",
				   `VBox(
					 `HBox(
					       `Slider(`id(`fg_red  ),`opt(`notify), "&red",   0, 255, 200 ),
					       `ColoredLabel("   ", `rgb(255, 0, 0), `rgb(255, 0, 0), 10 ),
					       `HSpacing()
					       ),
					 `HBox(
					       `Slider(`id(`fg_green),`opt(`notify), "&green", 0, 255,   0 ),
					       `ColoredLabel("   ", `rgb(0, 255, 0), `rgb(0, 255, 0), 10 ),
					       `HSpacing()
					       ),
					 `HBox(
					       `Slider(`id(`fg_blue ),`opt(`notify), "&blue",  0, 255,   0 ),
					       `ColoredLabel("   ", `rgb(0, 0, 255), `rgb(0, 0, 255), 10 ),
					       `HSpacing()
					       )
					 )
				   ),
			   `HSpacing(),
			   `Frame( "Backround",
				   `VBox(
					 `HBox(
					       `Slider(`id(`bg_red  ),`opt(`notify), "&red",   0, 255, 0 ),
					       `ColoredLabel("   ", `rgb(255, 0, 0), `rgb(255, 0, 0), 10 ),
					       `HSpacing()
					       ),
					 `HBox(
					       `Slider(`id(`bg_green),`opt(`notify), "&green", 0, 255,   0 ),
					       `ColoredLabel("   ", `rgb(0, 255, 0), `rgb(0, 255, 0), 10 ),
					       `HSpacing()
					       ),
					 `HBox(
					       `Slider(`id(`bg_blue ),`opt(`notify), "&blue",  0, 255, 200 ),
					       `ColoredLabel("   ", `rgb(0, 0, 255), `rgb(0, 0, 255), 10 ),
					       `HSpacing()
					       )
					 )
				   )
			   ),
		     `VSpacing(),
		     `PushButton(`id(`close), "&Close")
		     )
	       );

    any widget = nil;

    do
    {
	widget = UI::UserInput();

	if ( widget != `close )
	{
	    UI::ReplaceWidget(`id(`sample),
			  sample( (integer) UI::QueryWidget(`id(`fg_red  ), `Value ),
				  (integer) UI::QueryWidget(`id(`fg_green), `Value ),
				  (integer) UI::QueryWidget(`id(`fg_blue ), `Value ),
				  
				  (integer) UI::QueryWidget(`id(`bg_red  ), `Value ),
				  (integer) UI::QueryWidget(`id(`bg_green), `Value ),
				  (integer) UI::QueryWidget(`id(`bg_blue ), `Value )
				  )
			  );

	}
	
    } while ( widget != `close );
    
    UI::CloseDialog();
}