NAME
Curses::Toolkit::Widget::Window - a window
VERSION
version 0.211
SYNOPSIS
# create a window in the center of the screen
my $window = Curses::Toolkit::Widget::Window
->new()
->set_name('main_window')
->set_title('This is a title');
->set_coordinates(x1 => '25%', y1 => '25%'
x2 => '75%', y2 => '75%');
# create a fullscreen window
my $window = Curses::Toolkit::Widget::Window
->new()
->set_name('main_window')
->set_theme_property(border_width => 0); # set no border
->set_coordinates(x1 => 0, y1 => 0
x2 => '100%', y2 => '100%');
# add one widget to the window. You can add only one widget to the window.
# See L<Curses::Toolkit::Widget::VBox> and <Curses::Toolkit::Widget::HBox> to
# pack widgets
$window->add_widget($vbox)
# add the window to the root window. See L<Curses::Toolkit> to see how to
# spawn a root window
$root->add_window($window);
DESCRIPTION
This is a window widget. This widget is important, as it's the only one that you can add on the root window. So all your graphical interface should be contained in one or more window.
Appearence
+-[ title ]------------+
| |
| |
| |
| |
| |
| |
| |
| |
+----------------------#
CONSTRUCTOR
new
input : none
output : a Curses::Toolkit::Widget::Window
set_title
Set the title of the window
input : the title
output : the window widget
get_title
Get the title of the window
input : none
output : the window title
set_coordinates
Set the coordinates (see Curses::Toolkit::Object::Coordinates )
You can also set coordinates in percent of the root window width / height :
input : x1 : top left x (can be in percent ( ex : '42%' ) )
y1 : top left y (can be in percent ( ex : '42%' ) )
x2 : right bottom x (can be in percent ( ex : '42%' ) )
y2 : right bottom y (can be in percent ( ex : '42%' ) )
OR
input : x1 : top left x (can be in percent ( ex : '42%' ) )
y1 : top left y (can be in percent ( ex : '42%' ) )
width : width (can be in percent ( ex : '42%' ) )
height : heigth (can be in percent ( ex : '42%' ) )
OR
input : x1 : sub { ... } # returns top left x
y1 : sub { ... } # returns top left y
x2 : sub { ... } # returns right bottom x
y2 : sub { ... } # returns right bottom y
OR
input : a Curses::Toolkit::Object::Coordinates object
set_root_window
Sets the root window ( the root toolkit object) to which this window is added
input : the root toolkit object (Curses::Toolkit)
output : the window
get_root_window
Get the root window
input : none
output : the root toolkit object (Curses::Toolkit)
bring_to_front()
$window->bring_to_front()
Bring the window to front
input : none
output : the window widget
bring_to_back()
$window->bring_to_back()
Bring the window to the back
input : none
output : none
set_focused_widget
$window->set_focused_widget($widget);
Set the widget that has focus.
input : a Curses::Toolkit::Widget that is into this window
output : the window
get_focused_widget
my $widget = $window->get_focused_widget();
Gets the focused widget.
input : none
output : the focused Curses::Toolkit::Widget
draw
Draw the widget. You shouldn't use that, the mainloop will take care of it. If you are not using any mainloop, you should call draw() on the root window. See Curses::Toolkit
get_visible_shape
Gets the Coordinates of the part of the window which is visible
input : none
output : the shape (Curses::Toolkit::Object::Coordinates)
set_type
Set the type of the window. Default is 'normal'. Can be :
input : SCALAR : the type, one of 'normal', 'menu'
output : the window widget
get_type
Get the type of the window
input : none
output : the type
Theme related properties
To set/get a theme properties, you should do :
$window->set_theme_property(property_name => $property_value);
$value = $window->get_theme_property('property_name');
Here is the list of properties related to the window, that can be changed in the associated theme. See the Curses::Toolkit::Theme class used for the default (default class to look at is Curses::Toolkit::Theme::Default)
Don't forget to look at properties from the parent class, as these are also inherited from !
border_width (inherited)
The width of the border of the window.
Example : # set window to have no border $button->set_theme_property(border_width => 0 );
title_width
The width (or the height if the title is displayed vertically) of the window that will be use to display the title, in percent.
Example : # the title can take up to 80% of the windows border $window->set_theme_property(title_width => 80 );
title_bar_position
Can be 'top', 'bottom', 'left', 'right', sets the position of the title bar on the window border Example : # The title will appear on the left $window->set_theme_property(title_position => 'left');
title_position
Specifies if the title should be on the left/top, center or right/bottom on the title bar. Can be 'left', 'center' or 'right'
title_brackets_characters
An ARRAYREF of 2 strings (usually 1 character long), the first one is displayed before the title, the second one is used after the title.
Example : # The title will appear <like that> $window->set_theme_property(title_brackets_characters => [ '<', '>' ]);
title_left_offset
If title_position is 'left', this offset will be used to move the title on the right
title_right_offset
If title_position is 'right', this offset will be used to move the title on the left
title_animation
If set to 1, when the title is too big to be displayed in the window title bar, an animation will make the title loop back and forth.
title_loop_duration
If the title is too big to be displayed in the window title bar, an animation will make the title loop back and forth. This properties let's you specify what should be the complete animation duration. It's in seconds, but fractions are accepted
title_loop_pause
This sets the duration the loop animation should pause before going to the other direction. It's in seconds, but fractions are accepted
AUTHOR
Damien "dams" Krotkine
COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Damien "dams" Krotkine.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.