Chapter 8. Windows

Table of Contents
8.1. Window Title
8.2. Focus and the Default Widget
8.3. Window Policy
8.4. Modal Windows
8.5. Window Size and Position

Inheritance Hierarchy

Object
   +--- Widget
         +--- Container
               +--- Bin
                     +--- Window
         

8.1. Window Title

If you want to set the Window's title, you would use this function:

$window->set_title( $title );

Where $title is a string containing the title of the window.

8.2. Focus and the Default Widget

Each window can have a Widget that has the current focus. To set the focus, use:

$window->set_focus( $widget );

Widgets that have the focus can be activated by pressing on the space key.

The default Widget for a window can be set using:

$window->set_default( $widget );

Note that the widget must first call its can_default() function. Default Widgets can be activated by pressing the enter key.

8.3. Window Policy

The window policy determines how a window deals with resize requests. You set the window policy by calling:

$window->set_policy( $allow_shrink, $allow_grow, $auto_shrink );

The $allow_shrink argument is a true or false value determining whether the user can shrink the window below its size request. The $allow_grow argument is a true or false value determining whether the user can make the window grow larger than its size request. The $auto_shrink argument is a true or false value specifying whether the window automatically snaps back to its size request if it's larger.

Realistically, there are only two useful ways of calling this function, and they are:

# window is user resizable
$window->set_policy( $false, $true, $false );

# window's size is program controlled
$window->set_policy( $false, $false, $true );

The default policy for a window is the first one above.

8.4. Modal Windows

A modal window puts the focus of the application on itself and keeps it there so the user cannot use any other window until that window disappears. The only events that the application allows to be processed are for the modal window. Modeless windows do not freeze the rest of the application. Modal windows are normally used for dialog boxes. To set a windows modal value use the following function:

$window->set_modal( $modal );

Where $modal is a true or false value that specifies whether the window is modal (true) or modeless (false).

8.5. Window Size and Position

You can set the default size of a window using the following function:

$window->set_default_size( $width, $height );

You may set the windows position with this function:

$window->set_position( $position );

Where the $position argument may be: