$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.
returns the most important parameters of the window.
($cols, $rows, $color)=$win->get_window_parameter();
sets the pack-direction of the next widget. "v"ertically or "h"orizontally. This function can be walked around by using boxes.
$win->put_dir("h");
The window loses the focus. If no other window takes over the focus, the program ends.
$win->close_win();
put the widget into the window.
$win->put($button0);
activate the border of the window, optionally with shadow.
$win->set_border("shade"); oder $win->set_border();
Sets the focus not on the next widget but on the "$widget_name" named one. Required however that the widget has a name.
$win->set_focus($button0);
Sets the packer to the absolute position in the box (negative values lay outside of the box).
$win->abs_move_curs(new_y=>5, new_x=>2);
Sets the packer relative to the current position in the box (also negative values are possible).
$win->rel_move_curs(new_x=>-5);
To install Paw, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Paw
CPAN shell
perl -MCPAN -e shell install Paw
For more information on module installation, please visit the detailed CPAN module installation guide.