Chapter 34. Arrow Widgets

Inheritance Hierarchy

Object
   +--- Widget
         +--- Misc
               +--- Arrow
         

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 = new Gtk::Arrow( $arrow_type, $shadow_type );

$arrow->set( $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'
'down'
'left'
'right'

These values obviously indicate the direction in which the arrow will point. The $shadow_type argument may take one of these values:

'in'
'out' (the default)
'etched_in'
'etched_out'

34.1. Arrow Example

Here's a brief example to illustrate their use.

Arrow Program Source

      
#!/usr/bin/perl -w

use Gtk;
use strict;

set_locale Gtk;
init Gtk;

my $false = 0;
my $true = 1;

my $window;
my $button;
my $box;

# Create the window
$window = new Gtk::Window( "toplevel" );
$window->set_title( "Arrow Buttons" );
$window->signal_connect( "destroy", sub { Gtk->exit( 0 ); } );
$window->border_width( 10 );

# Create a box to hold the arrows/buttons
$box = new Gtk::HBox( $false, 0 );
$box->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', 'in' );
$box->pack_start( $button, $false, $false, 3 );

$button = create_arrow_button( 'right', 'out' );
$box->pack_start( $button, $false, $false, 3 );

$window->show();
main Gtk;
exit( 0 );



### Subroutines


# Create an Arrow widget with the specified parameters and pack it
# into a button.  The first parameter is the type of arrow, and the
# second parameter is the type of shadow.

sub create_arrow_button
{
   my ( $arrow_type, $shadow_type ) = @_;

   my $button;
   my $arrow;

   $button = new Gtk::Button();
   $arrow = new Gtk::Arrow( $arrow_type, $shadow_type );

   $button->add( $arrow );
   $button->show();
   $arrow->show();

   return ( $button );
 }


# END EXAMPLE PROGRAM
      
   

Arrow Example Screenshot