Curses::Toolkit::Widget - base class for widgets
version 0.211
Base class for widgets
use Curses::Toolkit::Widget qw(Widget) use Curses::Toolkit::Widget qw(:all)
None, this is an abstract class.
Set the name of the widget. It's only a help, the name is used only in error message, so that you know which sicget it is talking about. Default name is 'unknown'.
input : the name output : the widget
Get the name of a widget
input : the widget output : the name
$widget->set_sensitive(1); # set this widget to be sensitive $widget->set_sensitive(0); # set this widget to be non sensitive
Sets the sensitivity on/off on the widget. non-sensitive widgets can be seen as "greyed-out"
input : a boolean output : the widget
Retrieves the sensitivity setting of the widget.
input : none output : true if the widget is sensitive, or false if not
$widget->set_visible(1); # set this widget to be visible $widget->set_visible(0); # set this widget to be non visible
Sets the visibility on/off on the widget. non-visible widgets are not displayed, but they still take space
Retrieves the visibility setting of the widget.
input : none output : true if the widget is visible, or false if not
$widget->set_property('group name', 'property name', 'value'); $widget->set_property('group name', { name1 => 'value1', ... });
Sets a single property or a whole group of property
properties are arbitrary caracteristics of widgets. They are grouped by groups. To set a property, you need to specify the group name, then the property name, then the value name. However you can specify the group name, and a hash representing this group values.
Returns the widget
my $value = $widget->get_property('group name', 'property name'); my $group_hash = $widget->get_property('group name');
Return the property or the group of property of a widget.
$widget->set_theme_property('property name', 'value'); $widget->set_theme_property({ name1 => 'value1', ... });
Sets a single theme property or a whole group of theme property
Theme properties are arbitrary theme caracteristics of widgets. They are specifically theme oriented properties. To set a theme property, you need to specify the property name, then the value name. However you can specify a hash representing the values.
Returns the widget;
my $value = $widget->get_theme_property('property name'); my $hash = $widget->get_theme_property();
Return the theme property or the hash of theme properties of a widget.
$widget->add_event_listener($event_listener);
Adds an event listener to the widget. That allows the widget to respond to some events. You probably don't want to use this method. Please see signal_connect and possible_signals instead.
input : a Curses::Toolkit::EventListener output : the root window
my @listeners = $widget->get_event_listener();
Returns the list of listeners connected to this widget.
input : none output : an ARRAY of Curses::Toolkit::EventListener
$widget->fire_event($event, $widget, 1);
Sends an event to the mainloop so it gets dispatched. You probably don't want to use this method. Please see signal_connect and possible_signals instead.
input : a Curses::Toolkit::Event optional, a widget. if given, the event will apply on it only output : the widget
This is the method that draws the widget itself. Default drawing for the widget. This method doesn't draw anything
Default rendering method for the widget. Any render method should call draw
input : curses_handler output : the widget
Returns the parent of the widget
input : none output : a Curses::Toolkit::Widget object or undef
Set a specific display theme name.
input : a STRING, name of a class inheriting from Curses::Toolkit::Theme a BOOLEAN, if true, recursively sets the themes to the children output : the widget
Get the theme name used for this widget. If there is none, tries to get it from the parent. If there is no parent, the default theme name is used
input : none output : a STRING, name of a class inheriting from Curses::Toolkit::Theme
Get the widget current theme instance. If none is set, creates a new instance from the widget's theme name (see get_theme_name).
input : none output : a Curses::Toolkit::Theme object
my $window = $widget->get_window();
If the widget has been added in a window, get_window() will return this window. If the widget is not part of window, void returned.
input : none output : the window in which the widget is (Curses::Toolkit::Widget::Window), or void
my $window = $widget->get_root_window();
If the widget has been added in a window, get_root_window() will return the root window. If the widget is not part of window, void is returned.
input : none output : the root window (Curses::Toolkit), or void
Get the absolute coordinates (see Curses::Toolkit::Object::Coordinates )
input : none output : a Curses::Toolkit::Object::Coordinates object
Get the relative coordinates (see Curses::Toolkit::Object::Coordinates )
Gets the Coordinates of the part of the widget which is visible
input : none output : the shape (Curses::Toolkit::Object::Coordinates) or void
Gets the Coordinates of the part of the widget which is visible and that its children can draw on. By default it's the same as get_visible_shape, but it may be overloaded to reduce it some time (for instance if the widget has borders)
$widget->rebuild_all_coordinates();
Recompute all the relative coordinates accross the whole window
input : none output : the widget
$widget->needs_redraw()
When called, signify to the root window that a redraw is needed. Has an effect only if a mainloop is active ( see POE::Component::Curses )
my $next_focused_widget = $widget->get_next_focused_widget();
Returns the widget next in the focus chain
input : optional, a true value to start searching from $widget output : the next focused widget
my @signals = keys $widget->possible_signals();
returns the possible signals that can be used. See signal_connect to bind signals to action
input : none output : HASH, keys are signal names, values are signal classes
# quick $widget->signal_connect( clicked => sub { do_something } ); # additional args passed $widget->signal_connect( clicked => \&click_function, $additional, $arguments ); # the corresponding method sub click_function { my ($event, $widget, $additional, $arguments) = @_; print STDERR "the signal came from " . ref($widget) . "\n"; do_stuff(...) }
Connects an action to a signal.
input : STRING, signal_name, CODEREF, code reference to be executed, LIST, additional arguments output : HASH, keys are siagnal names, values are signal classes
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.