The Arrow widget draws an arrowhead, facing in a number of possible directions and having a number of possible styles. It can be very useful when placed on a button in many applications. Like the Label widget, it emits no signals.
There are only two functions for manipulating an Arrow widget:
$arrow = Gtk2::Arrow->new($arrow_type, $shadow_type); Gtk2::Arrow->set($arrow, $arrow_type, $shadow_type); |
The first creates a new arrow widget with the indicated type and appearance. The second allows these values to be altered retrospectively. The arrow_type argument may take one of the following values:
'up'/'GTK_ARROW_UP' 'down'/'GTK_ARROW_DOWN' 'left'/'GTK_ARROW_LEFT' 'right'/'GTK_ARROW_RIGHT' |
These values obviously indicate the direction in which the arrow will point. The shadow_type argument may take one of these values:
'in'/'GTK_SHADOW_IN' 'out'/'GTK_SHADOW_OUT' (the default) 'etched-in'/'GTK_SHADOW_ETCHED_IN' 'etched-out'/'GTK_SHADOW_ETCHED_OUT' |
Here's a brief example to illustrate their use.
use Glib qw/TRUE FALSE/; use Gtk2; # Create an Arrow widget with the specified parameters # and pack in into a button sub create_arrow_button { my ($arrow_type, $shadow_type) = @_; $button = Gtk2::Button->new; $arrow = Gtk2::Arrow->new($arrow_type, $shadow_type); $button->add($arrow); $button->show; $arrow->show; return $button; } Gtk2->init; $window = Gtk2::Window->new('toplevel'); $window->set_title("Arrow Buttons"); # It's a good idea to do this for all windows. $window->signal_connect(destroy => sub { Gtk2->main_quit; }); # Sets the border width of the window. $window->set_border_width(10); # Create a box to hold the arrows/buttons $box = Gtk2::HBox->new(FALSE, 0); $box->set_border_width(2); $window->add($box); # Pack and show all our widgets $box->show; $button = create_arrow_button('up', 'in'); $box->pack_start($button, FALSE, FALSE, 3); $button = create_arrow_button('down', 'out'); $box->pack_start($button, FALSE, FALSE, 3); $button = create_arrow_button('left', 'etched-in'); $box->pack_start($button, FALSE, FALSE, 3); $button = create_arrow_button('right', 'etched-out'); $box->pack_start($button, FALSE, FALSE, 3); $window->show; # Rest in gtk_main and wait for the fun to begin! Gtk2->main; 0; |