Sanko Robinson > FLTK-0.532009 > FLTK::Symbol

Download:
FLTK-0.532009.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.532006   Source  

NAME ^

FLTK::Symbol - Base class for all small, reusable graphics

Description ^

All small reusable graphics drawn by fltk are based on this class. This includes bitmapped images, the boxes drawn around widgets, symbols drawn into buttons, small symbols drawn between the letters in labels, and a number of formatting symbols to change the color or fontsize or alignment of labels.

Symbols are typically statically allocated and exist for the life of the program. They may either be identified directly by a pointer to them, or by a string name. The strings are stored in a simple hash table that should be quite efficient up to a few thousand named symbols.

Functions ^

dh

my $h = $symbol->dh( );

Returns -$symbol->getInset->h( ). This is usally the height of the top and bottom insets added together, though if the inset( ) method was overridden it may return a different number.

dw

my $w = $symbol->dw( );

Returns -$symbol->getInset->w( ). This is usally the width of the left and right insets added together, though if the inset( ) method was overridden it may return a different number.

dx

my $x = $symbol->dx( );

Returns $symbol->getInset( )->x( ). This is usally the width of the left inset for the image, though if the inset( ) method was overridden it may return a different number.

dy

my $y = $symbol->dy( );

Returns $symbol->getInset->y( ). This is usally the height of the top inset for the image, though if the inset( ) method was overridden it may return a different number.

find

my $this = $symbol->find( $name );

Locate a symbol by the name used to construct it. Returns either a pointer to the symbol, or null if it is undefined.

my $this = $symbol->find( $name, $end );

Locate a symbol by the substring after an @ sign as used by drawtext( ). $name points at the start of the name, $end points to the character after the end (this allows the name to be extracted from a longer string without having to copy it).

drawtext( ) can pass "arguments" to symbols as extra text before and after the actual name. If the text does not seem to correspond to a symbol name, this function tries to strip off these argments and try again. The current rules are to remove a leading # and + or - sign, remove a leading and trailing integer, so @+400foo21 will locate the symbol "foo". If that still does not work, it tries the first letter as a 1-letter symbol, so @Ccolorname will work.

When the symbol's draw( ) function is called, text( ) is set to $name and text_length( ) is set to $end minus $name, so the draw( ) method can examine these arguments.

get_inset

my $rect = $symbol->get_inset( );

measure

$symbol->measure( $w, $h );

Returns the size a Symbol will draw.

The variables $w and $h should be preset to a size you want to draw the symbol, many Symbols can scale and will return without changing these values. Or they may alter the values to preserve aspect ratio. Or they may just return constant sizes.

The most recent values sent to setcolor( ), setbgcolor( ), setdrawflags( ), setfont( ), etc, may influence the values that this returns.

name

my $name = $symbol->name( );

Returns the name of the symbol.

$symbol->name( $name );

Sets the name of the symbol. If it is in the hash table under the old name it is removed. If the new name is defined, then it is added under the new name to the hash table.

set_inset

$symbol->set_inset( $x, $y, $w, $h );
$symbol->set_inset( $x, $y );
$symbol->set_inset( $x );
$symbol->set_inset( $rect );

Set the inset rectangle. This is normally done by the constructor for a subclass. If the l<inset( )|FLTK::Symbol/"inset"> method is not overridden, the values in this rectangle define the edges.

text

$symbol->text( $string, $n );

Set the values returned by text( ) and text_length( ).

my $text = $symbol->text( );

Returns a pointer to right after the @ sign to the text used to invoke this symbol. This is a zero-length string if not being called from drawtext( ). This is useful for extracting the arguments that are skipped by the find( ) method.

text_length

my $length = $symbol->text_length( );

Returns the number of bytes between the @ sign and the ; or null or space that terminates the symbol when called from drawtext( ). This is useful for parsing the arguments. This returns zero if it is not being called from drawtext( ).

Author ^

Sanko Robinson <sanko@cpan.org> - http://sankorobinson.com/

License and Legal ^

Copyright (C) 2008-2010 by Sanko Robinson <sanko@cpan.org>

This program is free software; you can redistribute it and/or modify it under the terms of The Artistic License 2.0. See the LICENSE file included with this distribution or notes on the Artistic License 2.0 for clarification.

When separated from the distribution, all original POD documentation is covered by the Creative Commons Attribution-Share Alike 3.0 License. See the clarification of the CCA-SA3.0.

syntax highlighting: