NAME

Image::ButtonMaker::Button - A Button object for the ButtonMaker module

SYNOPSIS

  use Image::ButtonMaker::Button;

  my $but = Image::ButtonMaker::Button->new
           ( print_warnings => 1,
             name  => 'submitButton',

             properties => {
                            WidthMin         => 100,
                            HeightMin        => 55,
                            HeightMax        => 55,

                            CanvasType        => 'pixmap',
                            CanvasTemplateImg => 'pinky.png',
                            CanvasCutRight    => 1,
                            CanvasCutLeft     => 1,
                            CanvasCutTop      => 2,
                            CanvasCutBottom   => 2,

                            ArtWorkType   => 'text',
                            ArtWorkHAlign => 'center',
                            ArtWorkVAlign => 'baseline',

                            Text          => 'Submit Form',
                            TextColor     => '#000000',
                            TextSize      => 18,
                            TextFont      => '/home/users/piotr/head/uws-hosts/globals/autobuttons/fonts/arial.ttf',
                            TextAntiAlias => 'no',

                            MarginLeft   => 25,
                            MarginRight  => 30,
                            MarginTop    => 8,
                            MarginBottom => 24,

                            AfterResizeY => 30,
                            }

           ) or die "$Image::ButtonMaker::Button::errorstr";

  my $img = $but->render || die "$Image::ButtonMaker::Button::errorstr";

DESCRIPTION

This module is used to create single button objects and is capable of rendering image objects. The module uses Image::Magick as a backend and some methods return and deal with Image::Magick objects.

METHODS

new

This is a class method and a constuctor for Image::ButtonMaker::Button. When a Image::ButtonMaker::Button object is created, it also creates some lower-level objects for internal use.

Most of the parameters for the new method are actually parameters for these lower level objects.

  • name

    Name of the button. I is used by the write method to compute the filename.

  • classname

    Name of button class. It is only used, when Image::ButtonMaker::Button is used from inside the Image::ButtonMaker module.

  • classcontainer

    Reference to a Image::ButtonMaker::ClassContainer object. It is only used, when Image::ButtonMaker::Button is used from inside the Image::ButtonMaker module.

  • print_warnings

    Boolean attribute. Send warnings to STDERR.

  • die_on_errors

    Boolean attrbute.

  • die_on_warnings

    Boolean attribute. A warning could be: "Text does not fit into button" or a similar 'minor' error.

  • properties

    Hash reference. It is a hash of legal button-properties. Following properties are allowed:

    • FileType

      File type of the file generated by the write method. Could be 'png' or 'gif' or something more exotic, as long as Image::Magick supports it.

    • WidthMin

      Minimum width of the generated button.

    • WidthMax

      Maximum width of the generated button.

    • HeightMin

      Minimum height of the generated button.

    • HeightMax

      Maximum height of the generated button.

    • ArtWorkType

      The type of graphics, that will be rendered into the button. Options are 'text', 'text+icon' or 'icon+text'

    • ArtWorkHAlign

      Horizontal alignment of the graphics inside the button. The legal options are 'left', 'right', 'center'

    • ArtWorkVAlign

      Horizontal alignment of the graphics inside the button. The legal options are 'top', 'bottom' and 'baseline'. Where 'top' and 'bottom' place the graphics at top or bottom of the available space, the 'baseline' option is a bit different. What it does is to place the baseline of the rendered text, which is the line between the ascendant and descendant parts of the text, and place it at the line defined by MarginBottom.

    • MarginLeft

      Left margin of the artwork area.

    • MarginRight

      Right margin of the artwork area.

    • MarginTop

      Top margin of the artwork area/

    • MarginBottom

      Bottom margin of the artwork area. When using ArtworkVAlign, the bottom margin will be crossed by some letters like 'y' or 'j'.

    • CanvasType

      Canvas is the template of the button. At this point two types of canvas are supported and they are 'pixmap' and 'color'. 'pixmap' type uses a template which is sliced up and stretched for each button, while 'color' is just for plain rectangular buttons with plain background and a maybe a border.

    • CanvasTemplateImg

      When CanvasType is set to 'pixmap' this is the path tho the template image. The image must be readable by Image::Magick to be usefull.

    • CanvasCutRight

      When CanvasType is set to 'pixmap' this is the number of pixels, that will be cut off and placed in the right stretch area.

    • CanvasCutLeft

      When CanvasType is set to 'pixmap' this is the number of pixels, that will be cut off and placed in the left stretch area.

    • CanvasCutTop

      When CanvasType is set to 'pixmap' this is the number of pixels, that will be cut off and placed in the top stretch area.

    • CanvasCutBottom

      When CanvasType is set to 'pixmap' this is the number of pixels, that will be cut off and placed in the bottom stretch area.

    • CanvasBackgroundColor

      When CanvasType is set to 'color' this is the background color.

    • CanvasBorderColor

      When CanvasType is set to 'color' this is the border color.

    • CanvasBorderWidth

      When CanvasType is set to 'color' this is the border width. Border is only drawn when CanvasBorderWidth is different from 0.

    • Text

      This is the text to be rendered inside a button.

    • TextFont

      A path to a .ttf (True Type Font) file containing your favorite font to be used inside the button.

    • TextColor

      A color of the text. Can be an RGB value like '#ff00aa' or some symbolic name understood by Image::Magick.

    • TextSize

      Text size. F.ex '9' or maybe even '11'

    • TextAntiAlias

      Make the text nice and soft in the edges. Options are 'yes' or 'no'.

    • TextScale

      Scale factor for the text. This one defaults to 1.0.

    • NoLexicon

    • IconName

      If the ArtworkType is 'text+icon' or 'icon+text' this must contain the path to the icon image.

    • IconSpace

      Amount of horizontal space between the text and the icon.

    • IconVerticalAdjust

      Sometimes it is nice to be able to lift or lower the icon compared to the text. This is the amount of pixels for that. Positive values lift and negative lower the icon.

    • AfterResizeY

      Resize button to height AfterResizeY after it has been rendered. It can be used for solving problems with antialiasing of text and icons by rendering a really big image, and resizing it to smaller size afterwards.

    • AfterResizeX

      Resize button to with AfterResizeX after it has been rendered.

  • render

    Render the button.

  • write

    Write the button to file with prefix from the 'name' attribute of the object and suffix defined by the FileType property.

  • lookup_name

    Return $self->{name}

  • lookup_filename

    Return $self->{name} suffixed with the FileType button property

  • lookup_property($property_name)

    Lookup and return a button property. If running from ButtonMaker with a ClassContainer object defined, the property can be obtained from the class definition or a parent class.

  • set_property

    Set a button property inside the object.

AUTHORS

Piotr Czarny <picz@sifira.dk> wrote this module and this crappy documentation.

6 POD Errors

The following errors were encountered while parsing the POD:

Around line 916:

Expected '=item *'

Around line 920:

Expected '=item *'

Around line 925:

Expected '=item *'

Around line 929:

Expected '=item *'

Around line 933:

Expected '=item *'

Around line 939:

Expected '=item *'