NAME
Curses::Toolkit::Widget - base class for widgets
VERSION
version 0.100680
DESCRIPTION
Base class for widgets
CONSTRUCTOR
None, this is an abstract class
METHODS
set_name
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_name
Get the name of a widget
input : the widget
output : the name
set_sensitive
$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
is_sensitive
Retrieves the sensitivity setting of the widget.
input : none
output : true if the widget is sensitive, or false if not
set_visible
$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
input : a boolean
output : the widget
is_visible
Retrieves the visibility setting of the widget.
input : none
output : true if the widget is visible, or false if not
set_property
$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
get_property
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.
set_theme_property
$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;
get_theme_property
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.
add_event_listener
$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
get_event_listeners
my @listeners = $widget->get_event_listener();
Returns the list of listeners connected to this widget.
input : none
output : an ARRAY of Curses::Toolkit::EventListener
fire_event
$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
draw
This is the method that draws the widget itself. Default drawing for the widget. This method doesn't draw anything
render
Default rendering method for the widget. Any render method should call draw
input : curses_handler
output : the widget
get_parent
Returns the parent of the widget
input : none
output : a Curses::Toolkit::Widget object or undef
set_theme_name
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_theme_name
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_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
get_window
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
get_root_window
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_coordinates
Get the absolute coordinates (see Curses::Toolkit::Object::Coordinates )
input : none
output : a Curses::Toolkit::Object::Coordinates object
get_relatives_coordinates
Get the relative coordinates (see Curses::Toolkit::Object::Coordinates )
input : none
output : a Curses::Toolkit::Object::Coordinates object
get_visible_shape
Gets the Coordinates of the part of the widget which is visible
input : none
output : the shape (Curses::Toolkit::Object::Coordinates) or void
rebuild_all_coordinates
$widget->rebuild_all_coordinates();
Recompute all the relative coordinates accross the whole window
input : none
output : the widget
needs_redraw
$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 )
input : none
output : the widget
set_modal
unset_modal
get_next_focused_widget
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
possible_signals
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
possible_signals
# 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
AUTHOR
Damien "dams" Krotkine
COPYRIGHT AND LICENSE
This software is copyright (c) 2008 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.