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, Flags f1, const Symbol &img1, Flags f2, const Symbol &img2, Flags f3, const Symbol &img3, Flags f4, const Symbol &img4, Flags f5, const Symbol &img5, Flags f6, const Symbol &img6, Flags f7, const Symbol &img7)
 MultiImage (const Symbol &img0, Flags f1, const Symbol &img1, Flags f2, const Symbol &img2, Flags f3, const Symbol &img3, Flags f4, const Symbol &img4, Flags f5, const Symbol &img5, Flags f6, const Symbol &img6)
 MultiImage (const Symbol &img0, Flags f1, const Symbol &img1, Flags f2, const Symbol &img2, Flags f3, const Symbol &img3, Flags f4, const Symbol &img4, Flags f5, const Symbol &img5)
 MultiImage (const Symbol &img0, Flags f1, const Symbol &img1, Flags f2, const Symbol &img2, Flags f3, const Symbol &img3, Flags f4, const Symbol &img4)
 MultiImage (const Symbol &img0, Flags f1, const Symbol &img1, Flags f2, const Symbol &img2, Flags f3, const Symbol &img3)
 MultiImage (const Symbol &img0, Flags f1, const Symbol &img1, Flags f2, const Symbol &img2)
 MultiImage (const Symbol &img0, Flags f1, const Symbol &img1)
 MultiImage (const Symbol &img0)
 MultiImage (unsigned count, const Symbol *img0, va_list ap)
 constructor for unlimited images state affectation
 MultiImage ()
 for MultiImage arrays construction using set() for post initialization
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:


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::_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.

References fltk::Symbol::measure().

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.

References current_image(), and fltk::Symbol::draw().

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.

References fltk::drawflags().

Referenced by _draw(), and inset().

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

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

Reimplemented from fltk::Symbol.

References current_image(), and fltk::Symbol::inset().

bool MultiImage::fills_rectangle (  )  const [virtual]

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

Reimplemented from fltk::Symbol.

References fltk::Symbol::fills_rectangle().

bool MultiImage::is_frame (  )  const [virtual]

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

Reimplemented from fltk::Symbol.

References fltk::Symbol::is_frame().

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

Innards of the inline constructors.

References fltk::Symbol::get_inset().

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.

References fltk::Symbol::get_inset().


Wed Jun 17 08:58:24 2009. FLTK ©2007 Bill Spitzak and others.
Permission is granted to reproduce this manual or any portion for any purpose, provided this copyright and permission notice are preserved.