Curses::Toolkit::Widget::Window - a window
version 0.207
# 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);
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.
+-[ title ]------------+ | | | | | | | | | | | | | | | | +----------------------#
input : none output : a Curses::Toolkit::Widget::Window
Set the title of the window
input : the title output : the window widget
Get the title of the window
input : none output : the window title
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
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 the root window
input : none output : the root toolkit object (Curses::Toolkit)
$window->bring_to_front()
Bring the window to front
input : none output : the window widget
$window->bring_to_back()
Bring the window to the back
input : none output : none
$window->set_focused_widget($widget);
Set the widget that has focus.
input : a Curses::Toolkit::Widget that is into this window output : the window
my $widget = $window->get_focused_widget();
Gets the focused widget.
input : none output : the focused Curses::Toolkit::Widget
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
Gets the Coordinates of the part of the window which is visible
input : none output : the shape (Curses::Toolkit::Object::Coordinates)
Set the type of the window. Default is 'normal'. Can be :
input : SCALAR : the type, one of 'normal', 'menu' output : the window widget
Get the type of the window
input : none output : the type
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 !
The width of the border of the window.
Example : # set window to have no border $button->set_theme_property(border_width => 0 );
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 );
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');
Specifies if the title should be on the left/top, center or right/bottom on the title bar. Can be 'left', 'center' or 'right'
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 => [ '<', '>' ]);
If title_position is 'left', this offset will be used to move the title on the right
If title_position is 'right', this offset will be used to move the title on the left
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.
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
This sets the duration the loop animation should pause before going to the other direction. It's in seconds, but fractions are accepted
Damien "dams" Krotkine
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.
To install Curses::Toolkit, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Curses::Toolkit
CPAN shell
perl -MCPAN -e shell install Curses::Toolkit
For more information on module installation, please visit the detailed CPAN module installation guide.