The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

Window

$window=Paw::Window-new($height, $width, [$abs_x], [$abs_y], [$color], [$name], [\&callback], [\$statusbar], [$orientation], [\&time_function]);>

Parameter

     $height         => number of rows

     $width          => number of columns

     $abs_x          => absolute x-coordinate at the screen
                        [optionally]

     $abs_y          => absolute y-coordinate at the screen
                        [optionally]

     $color          => the colorpair must be generated with
                        Curses::init_pair(pair_nr, COLOR_fg, COLOR_bg)
                        [optionally]

     $name           => name of the widget [optionally]

     \&callback      => reference to the function which will be
                        executed on each key-press.
                        [optionally]

     $quit_key       => Key-Code which terminates the window
                        [optionally]

     \@statusbar     => Reference of an array with 10 elements
                        [optionally]

     \$statusbar     => a reference on a scalar-string wich should
                        appear as text in the statusbar [optional]
                        Since it concerns a reference,
                        the text can be changed at run time.

     $orientation    => "topleft", "topright", "bottomleft",
                        "bottomright", "center"  "grow"
                        are the possible parameters.
                        They indicate how the box will behave on
                        modifications of the terminal size.
                        Either it keeps it's distance to the
                        indicated terminal side, it remains
                        centered or it grows/shrinks with
                        the new terminal size
                        (default is "center") [optionally].

     $title          => Title of the box (will be shown in the top-left
                        corner of the box [optionally]

     \&time_function => This function will be called about
                        every 0,1 seconds as long as
                        the window has the focus.

Example

     $window=Paw::Window->new(height=>20, width=>10,
                                  color=>2, callback=>\&function,
                                  statusbar=>\$status, quit_key=>KEY_F(10));

Callback

The callback method usually is a loop which constantly checks the keyboard for pressed keys and passes those key-codes to the active widget. The internal callback routine, which one is used if none callback Function for the window is defined, for example :

     sub Paw_main_loop {
    
         my $main_win = $_[0];
     
         my $i = "";
         $main_win->_refresh();
         while ( not $main_win->{close_it} and
                     ($i ne $main_win->{quit_key}) )
         {
             $this->{main_win} = $main_win;
             $i = getch();                  # read key
             &{$main_win->{time_function}} if ( defined $main_win->{time_function} );
             if ( $i ne -1 ) {
                 $main_win->key_press($i);  # keycode to widgetset
                 $main_win->_refresh();
             }
             else {
                 $main_win->_refresh() if ( defined $main_win->{time_function} );
             }
         };
         Curses::clear();
         $main_win->{close_it}=0;
         endwin();
     }

if the getch() Function don't receive a key-code for about 0,1 seconds, then it will be left again and "$i" contains the value " -1 ". $widget->key_press($i) passes the key-code to the active widget.

get_window_parameter()

returns the most important parameters of the window.

Example

     ($cols, $rows, $color)=$win->get_window_parameter();

put_dir($direction)

sets the pack-direction of the next widget. "v"ertically or "h"orizontally. This function can be walked around by using boxes.

Example

     $win->put_dir("h");

close_win();

The window loses the focus. If no other window takes over the focus, the program ends.

Example

     $win->close_win();

put($widget)

put the widget into the window.

Example

     $win->put($button0);

set_border(["shade"])

activate the border of the window, optionally with shadow.

Example

     $win->set_border("shade"); oder $win->set_border();

set_focus($widget_name)

Sets the focus not on the next widget but on the "$widget_name" named one. Required however that the widget has a name.

Example

     $win->set_focus($button0);

abs_move_curs($new_x, $new_y);

Sets the packer to the absolute position in the box (negative values lay outside of the box).

Example

     $win->abs_move_curs(new_y=>5, new_x=>2);

rel_move_curs($new_x, $new_y);

Sets the packer relative to the current position in the box (also negative values are possible).

Example

     $win->rel_move_curs(new_x=>-5);