Name

Image — Pixmap image

Synopsis

Image ( symbol|byteblock|string  image ,
  string  label );

Parameters

symbol|byteblock|string image

specification which image to display

string label

label or default text of the image

Options

tiled

tile pixmap: repeat it as often as needed to fill all available space

scaleToFit

scale the pixmap so it fits the available space: zoom in or out as needed

zeroWidth

make widget report a nice width of 0

zeroHeight

make widget report a nice height of 0

animated

image data contain an animated image (e.g. MNG)

Description

Displays an image - if the respective UI is capable of that. If not, it is up to the UI to decide whether or not to display the specified default text instead (e.g. with the NCurses UI).

Use `opt( `zeroWidth ) and / or `opt( `zeroHeight ) if the real size of the image widget is determined by outside factors, e.g. by the size of neighboring widgets. With those options you can override the default "nice size" of the image widget and make it show just a part of the image. If more screen space is available, more of the image is shown, if not, the layout engine doesn't complain about the image widget not getting its nice size.

`opt( `tiled ) will make the image repeat endlessly in both dimensions to fill up any available space. You might want to add `opt( `zeroWidth ) or `opt( `zeroHeight ) ( or both ), too to make use of this feature.

`opt( `scaleToFit ) scales the image to fit into the available space, i.e. the image will be zoomed in or out as needed.

This option implicitly sets `opt( `zeroWidth ) and `opt( zeroHeight ), too since there is no useful default size for such an image.

Please note that setting both `opt( `tiled ) and `opt( `scaleToFit ) at once doesn't make any sense.

Examples

          /**
 * Example for simple images:
 * Creates one standard (predefined) image and a user-defined image.  
 **/
{  
    global define void ImageDemo(byteblock pixels) ``{
        UI::OpenDialog(
                   `VBox(
                         `Image(pixels, "Image 1"), 
                         `PushButton("&OK")));
        UI::UserInput();
        UI::CloseDialog();
    };

    byteblock image_data = (byteblock) SCR::Read( .target.byte, "image1.png" );
    ImageDemo( image_data );
}

          
          /**
 * Example for an animated image
 **/
{
    global define void MovieDemo(byteblock movie) ``{
        UI::OpenDialog(
                   `VBox(
                         `Image(`opt(`animated), movie, "Movie"), 
                         `PushButton("&OK")));
        UI::UserInput();
        UI::CloseDialog();
    };
    
    byteblock movie = (byteblock) SCR::Read( .target.byte, "/usr/share/splash/keys.mng" );
    MovieDemo( movie );
}

        
          /**
 * Advanced Image widget features:
 * Load image from local file. This may not always be supported, so check if
 * this feature is available prior to using it! 
 **/
{

    if ( ! lookup( UI::GetDisplayInfo(), "HasLocalImageSupport", false ) )
    {
	UI::OpenDialog(
		   `VBox( 
			 `Label("Loading images from local files not supported!"),
			 `PushButton(`opt(`default), "&OK")
			 )
		   );
	UI::UserInput();
	UI::CloseDialog();
	
	return;
    }

    
    UI::OpenDialog(
	       `VBox( 
		     `Image( "/usr/share/doc/susetour/img/games0.png", "Games" ),
		     `PushButton(`opt(`default), "&OK")
		     )
	       );
    UI::UserInput();
    UI::CloseDialog();
}

          
          /**
 * Advanced Image widget features:
 * Load image from local file and scale it to fit the available space.
 **/
{

    if ( ! lookup( UI::GetDisplayInfo(), "HasLocalImageSupport", false ) )
    {
	UI::OpenDialog(
		   `VBox( 
			 `Label("Loading images from local files not supported!"),
			 `PushButton(`opt(`default), "&OK")
			 )
		   );
	UI::UserInput();
	UI::CloseDialog();
	
	return;
    }

    
    UI::OpenDialog( `opt(`defaultsize), 
	       `VBox(
		     `Image( `opt(`scaleToFit), "/usr/share/doc/susetour/img/games0.png", "Games" ),
		     `Right( `Label( "Resize the window to scale the image" ) ),
		     `PushButton(`opt(`default), "&OK")
		     )
	       );
    UI::UserInput();
    UI::CloseDialog();
}

          
          /**
 * Advanced Image widget features:
 * Load image from local file and scale it to fit the available space.
 **/
{

    if ( ! lookup( UI::GetDisplayInfo(), "HasLocalImageSupport", false ) )
    {
	UI::OpenDialog(
		   `VBox( 
			 `Label("Loading images from local files not supported!"),
			 `PushButton(`opt(`default), "&OK")
			 )
		   );
	UI::UserInput();
	UI::CloseDialog();
	
	return;
    }

    
    UI::OpenDialog(
	       `VBox(
		     `HBox(
			   `VSpacing( 5 ),
			   `Image( `opt(`tiled ), "/opt/kde2/share/apps/amor/static/tux.png", "tux" )
			   ),
		     `Right( `Label( "Resize the window to see the effect of image tiling" ) ),
		     `PushButton(`opt(`default), "&OK")
		     )
	       );
    UI::UserInput();
    UI::CloseDialog();
}