Prima::Buttons - button widgets and grouping widgets. |
Prima::Buttons - button widgets and grouping widgets.
Prima::Buttons provides two separate sets of classes: the button widgets and the grouping widgets. The button widgets include push buttons, check-boxes and radio buttons. The grouping widgets are designed for usage as containers for the check-boxes and radio buttons, however, any widget can be inserted in a grouping widget.
The module provides the following classes:
* Prima::AbstractButton ( derived from Prima::Widget and Prima::MouseScroller ) Prima::Button Prima::SpeedButton * Prima::Cluster Prima::CheckBox Prima::Radio Prima::GroupBox ( derived from Prima::Widget ) Prima::RadioGroup ( obsolete ) Prima::CheckBoxGroup ( obsolete )
Note: *
- marked classes are abstract.
use Prima::Buttons;
my $button = $widget-> insert( 'Prima::Button', text => 'Push button'); $button-> flat(1);
my $group = $widget-> insert( 'Prima::GroupBox', onRadioClick => sub { print $_[1]-> text, "\n"; }); $group-> insert( 'Prima::Radio', text => 'Selection 1'); $group-> insert( 'Prima::Radio', text => 'Selection 2', pressed => 1); $group-> index(0);
Prima::AbstractButton realizes common functionality of buttons. It provides reaction on mouse and keyboard events, and calls Click notification when the user activates the button. The mouse activation is performed either by mouse double click or successive mouse down and mouse up events within the button boundaries. The keyboard activation is performed on the following conditions:
{default}
( see default property ) boolean variable is
set and enter key is pressed. This condition holds even if the button is out of focus.
{accel}
character variable is assigned and the corresponding character key
is pressed. {accel}
variable is extracted automatically from the text string
passed to text property.
This condition holds even if the button is out of focus.
Default value: 0
A push button class, that extends Prima::AbstractButton functionality by allowing an image to be drawn together with the text.
Default value: 0
Default value: 2
Default value: 0
Default value: 0
Default value: 0
Default value: 0
image
does not contain such sub-image, the defaultGlyph
sub-image is drawn, and is dimmed over with draw_veil method.
Default value: 1
Default value: 0
glyphs
property assigns how many such sub-images the image object contains.
The sub-image indexes can be assigned for rendition of the different states. These indexes are selected by the following integer properties: defaultGlyph, hiliteGlyph, disabledGlyph, pressedGlyph, holdGlyph.
Default value: 1
image
does not contain such sub-image, the defaultGlyph
sub-image is drawn.
Default value: 0
image
does not contain such sub-image, the defaultGlyph
sub-image is drawn.
Default value: 3
Default value: undef
To allow easy multiframe image access, FILENAME string is checked if it contains
a number after a colon in the string end. Such, imageFile('image.gif:3')
call
would load the fourth frame in image.gif
file.
Default value: 1
mb::XXX
constants.
If a button with non-zero modalResult
is owned by a currently executing
modal window, and is pressed, its modalResult
value is copied to the modalResult
property of the owner window, and the latter is closed.
This scheme is helpful for the dialog design:
$dialog-> insert( 'Prima::Button', modalResult => mb::OK, text => '~Ok', default => 1); $dialog-> insert( 'Prima::Button', modalResult => mb::Cancel, text => 'Cancel); return if $dialog-> execute != mb::OK.
The toolkit defines the following constants for modalResult
use:
mb::OK or mb::Ok mb::Cancel mb::Yes mb::No mb::Abort mb::Retry mb::Ignore mb::Help
However, any other integer value can be safely used.
Default value: 0
image
does not contain such sub-image, the defaultGlyph
sub-image is drawn.
A convenience class, same as the Prima::Button manpage but with default square shape and text property set to an empty string.
An abstract class with common functionality of the Prima::CheckBox manpage and
the Prima::RadioButton manpage. Reassigns default actions on tab and back-tab keys, so
the sibling cluster widgets are not selected. Has ownerBackColor
property
set to 1, to prevent usage of background color from wc::Button
palette.
Although this property is present on the the Prima::CheckBox manpage, it is not used in there.
checked(1)
checked(0)
checked
state of the button and returns the new state.
Represents a standard radio button, that can be either in checked, or in unchecked state. When checked, delivers RadioClick event to the owner ( if the latter provides one ).
The button uses the standard toolkit images with sbmp::RadioXXX
indexes.
If the images can not be loaded, the button is drawn with the graphic primitives.
Represents a standard check box button, that can be either in checked, or in unchecked state.
The button uses the standard toolkit images with sbmp::CheckBoxXXX
indexes.
If the images can not be loaded, the button is drawn with graphic primitives.
The class to be used as a container of radio and check-box buttons. It can, however, contain any other widgets.
The widget draws a 3d-shaded box on its boundaries and a text string in its
upper left corner. Uses transparent
property to determine if it needs to
paint its background.
The class does not provide a method to calculate the extension of the inner rectangle. However, it can be safely assumed that all offsets except the upper are 5 pixels. The upper offset is dependent on a font, and constitutes the half of the font height.
The default action of the class is that all checked buttons,
except BUTTON, are unchecked. Since the flow type of RadioClick
event
is nt::PrivateFirst
, on_radioclick
method must be directly overloaded
to disable this functionality.
index
. The indexing is
based on the index in the widget list, returned by Prima::Widget::widgets
method.
checked
state of a child check-box button. The indexing is
based on the index in the widget list, returned by Prima::Widget::widgets
method.
This class is obsolete and is same as Prima::GroupBox
.
This class is obsolete and is same as Prima::GroupBox
.
The push button is not capable of drawing anything other than single line of text and
single image. If an extended functionality is needed, instead of fully rewriting
the painting procedure, it might be reasonable to overload put_image_indirect
method of Prima::Button
, and perform custom output there.
Tilde escaping in text
is not realized, but is planned to. There currently is no way
to avoid tilde underscoring.
Radio buttons can get unexpectedly checked when used in notebooks. See auto.
Prima::GroupBox::value
parameter is an integer, which size is architecture-dependent.
Shift towards a vector is considered a good idea.
Dmitry Karasik, <dmitry@karasik.eu.org>.
Prima, the Prima::Widget manpage, the Prima::Window manpage, the Prima::IntUtils manpage, the Prima::StdBitmap manpage, examples/buttons.pl, examples/buttons2.pl.
Prima::Buttons - button widgets and grouping widgets. |