fltk::MultiImage Class Reference

Inherits fltk::Symbol.

List of all members.

Public Member Functions

void _draw (const Rectangle &) const
void _measure (int &, int &) const
void add (Flags flags, const Symbol &image)
const Symbolcurrent_image () const
bool fills_rectangle () const
void inset (Rectangle &) const
bool is_frame () const
 MultiImage (const Symbol &img0)
 MultiImage ()
 for MultiImage arrays construction using set() for post initialization
 MultiImage (unsigned count, const Symbol *img0, va_list ap)
 constructor for unlimited images state affectation
 MultiImage (const Symbol &img0, Flags f1, const Symbol &img1)
 MultiImage (const Symbol &img0, Flags f1, const Symbol &img1, Flags f2, const Symbol &img2)
void release ()
 Destroys everything except image0.
void set (unsigned count, const Symbol *img0,...)

Detailed Description

A Symbol containing pointers to a set of different Symbols. The drawflags() are used to select which one to draw. This is most useful for making an image for a button that is different depending on whether it is pushed in, the current value is on, or when the mouse is over it.

The basic constructor takes the "image0" which is the image that is drawn if no other image is used. You can then use add() or replace() to add pairs of images and flags. These are searched and the last one where all it's flags are turned on is used. There are also inline constructors so that a fully-populated MultiImage with up to 8 images can be declared inline.

Typical example:

  MultiImage buttonImage(OffImage,
                STATE, OnImage,
                INACTIVE_R, DimOffImage,
                INACTIVE_R|STATE, DimOnImage,
                FOCUSED, FocusedOffImage,
                FOCUSED|STATE, FocusedOnImage,
                HIGHLIGHT, BrightOffImage,
                HIGHLIGHT|STATE, BrightOnImage,
                PUSHED, BrightPushedOffImage,
                PUSHED|STATE, BrightPushedOnImage);

In the above example, because the PUSHED is later than the FOCUSED, when the user pushes the button and it has the focus they will see the pushed image. If they were the other way around they would see the focused image and not see any feedback from pushing the button. In addition, although the hightlight or focus should not turn on for an inactive widget, this will show if it happens.

Also note that the number of images is less than 2^n where n is the number of flags you care about. This seems to be true of most hand-painted image sets. The user probably does not care or is confused by showing the focus or highlight state of a button they are pushing.

A fully-populated example like the above is not necessary, as the flags are passed to the sub-images. If they respond to them (for instance drawing differently depending on STATE) then fewer images are necessary.

Useful flags are:

  • INACTIVE_R
  • STATE True for button that is turned on
  • HIGHLIGHT True when the mouse is over widget or pushing it (you must also set highlight_color() to non-zero or most widgets will not redraw because they don't think they changed appearance).
  • PUSHED True if user is pushing button
  • FOCUSED True if button has the keyboard focus

Constructor & Destructor Documentation

MultiImage::MultiImage ( const Symbol image0) [inline]

Constructor where only the "image0" is provided. Unless you call add(), this will always just draw image0.

MultiImage::MultiImage ( const Symbol image0,
Flags  flags1,
const Symbol image1 
) [inline]

If all of flags1 are on in drawimage(), then image1 will be drawn, otherwise image0 will be drawn.

MultiImage::MultiImage ( const Symbol image0,
Flags  flags1,
const Symbol image1,
Flags  flags2,
const Symbol image2 
) [inline]

If all of flags2 are on in drawimage(), then image2 will be drawn, else if all of flags1 are on then image1 will be drawn, otherwise image0 will be drawn.

This pattern continues for the other inline constructors. The last image and flags are checked first, and then backwards.


Member Function Documentation

void MultiImage::_draw ( const Rectangle r) const [virtual]

Select one of the images and draw it. The last image with all the flags specified for it turned on will be drawn. If none of them match then Image0 is drawn.

Implements fltk::Symbol.

void MultiImage::_measure ( int &  w,
int &  h 
) const [virtual]

It probably is useless for the images to be different sizes. However if they are, Image0 (the first one passed to the constructor) is used to figure out the size.

Reimplemented from fltk::Symbol.

void MultiImage::add ( Flags  flags,
const Symbol image 
)

Makes it draw image if all of the flags are turned on in drawflags().

If flags is zero, this replaces the image0 that was provided to the constructor. Otherwise, if any image with flags has already been specified, it is replaced with this image. Otherwise a new pair of flags and image is added to the end of the list.

const Symbol * MultiImage::current_image ( ) const

Return the image that will be drawn according to the current value of drawflags(). The last image with all the flags specified for it turned on will be drawn. If none of them match then image0 (the first one passed to the constructor) is returned.

bool MultiImage::fills_rectangle ( ) const [virtual]

Returns the info from the first image given to the constructor.

Reimplemented from fltk::Symbol.

void MultiImage::inset ( Rectangle r) const [virtual]

Calls the same image that _draw() will call to get the inset.

Reimplemented from fltk::Symbol.

bool MultiImage::is_frame ( ) const [virtual]

Returns the info from the first image given to the constructor.

Reimplemented from fltk::Symbol.

void MultiImage::set ( unsigned  count,
const Symbol img0,
  ... 
)

Innards of the inline constructors.


The documentation for this class was generated from the following files: