The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Image::Button::Set - Builds a set of related PNG buttons

SYNOPSIS

  use Image::Button::Rect;
  use Image::Button::Plain;
  use Image::Button::Set;

  my $b1 = new Image::Button::Rect(text     => 'text b1',
                                   font     => 'newsgotn.ttf',
                                   fontsize => 20,
                                   fgcolor  => [0, 0, 0],
                                   file     => 'b1.png');

  my $b2 = $b1->copy(text => 'text b2', file => 'b2.png');

  my $set = new Image::Button::Set(buttons => [ $b1, $b2 ]);
  
  my $b3 = $b1->copy(text => 'text b3', file => 'b3.png');

  $set->push(button => $b3);

  my $b4 = $b1->copy(text => 'text b4', file => 'b4.png');
  my $b5 = $b1->copy(text => 'text b5', file => 'b5.png');

  my $b6 = new Image::Button::Plain(text     => 'text b6',
                                    font     => 'newsgotn.ttf',
                                    bdcolor  => [10, 10, 10]);

  $set->push(buttons => [$b4, $b5, $b6]);

  $set->print(sameWidth  => 0, 
              sameHeight => 1,
              prefix     => 'w-');
  $set->flush(sameWidth  => 1,
              sameHeight => 0,
              postfix    => '-h',
              override   => { bdcolor => [0, 0, 20],
                              btcolor => [20, 0, 0] });

DESCRIPTION

Builds a set of related buttons. They might be forced to have the same width and/or height. Make sure you specify an output file in the constructor of the buttons, because otherwise they will all go to stdout and the result won't be what you expect.

FUNCTIONS

Constructor

  my $set = new Image::Button::Set(buttons => [ $b1, $b2 ]);

Takes the same arguments as flush, coming next.

Add buttons

Either

  $set->push(button   => $b1,
             textlist => ['text b2', 'text b3', 'text b4']);

or

  $set->push(buttons  => [$b1, $b2],
             textlist => ['text b3', 'text b4']);

or $set->push(button => $b1); $set->push(textlist => ['text b2', 'text b3', 'text b4']);

Possible arguments are:

button => $button

A button to add to the list.

buttons => [$button1, $button2]

A reference to an array of buttons to add to the list.

textlist => ['text b1', 'text b2']

A list of button texts with which buttons will be built and appended. They will clone the last button on the list, so there has to be at least one. If called with a button or buttons argument it will go lat, so it will clone the last button you just added.

  $set->print(sameWidth  => 1,
              sameHeight => 0,
              prefix     => 'pre-',
              postfix    => '-pos',
              override   => { fontsize => 23,
                              fgcolor  => [0, 0, 0] });

or

  $set->flush(sameWidth  => 1,
              sameHeight => 0,
              prefix     => 'pre-',
              postfix    => '-pos');

They both take the same arguments:

sameWidth => 0

If 1 makes all the buttons of the same width, which will equal the width of the widest one. Defaults to 0.

sameHeight => 0

If 1 makes all the buttons of the same height, which will equal the height of the tallest one. Defaults to 0.

prefix => ''

Adds a prefix to the file name of each button. Useful when you want to print a list of buttons several times in different configurations to different files.

postfix => ''

Adds a postfix before the extension to the file name of each button.

override => { font => 'newfont.ttf', fontsize => 10 }

A dictionary reference with parameters to override on the buttons to print. Any parameter that the button's constructor understands can be overriden here. The buttons will actually be changed.

After flush the button list is cleared. Flush understands an additional parameter, print, which defaults to 1. If set to zero the list will be cleared, but nothing will be printed.

SEE ALSO

Image::Button for a description of how to make buttons, and a list of available button types.

AUTHOR

Juan M. García-Reyero <joanmg@twostones.org>

COPYRIGHT

Copyright (C) 2003 Juan M. García-Reyero. All Rights Reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 251:

Non-ASCII character seen before =encoding in 'García-Reyero'. Assuming CP1252