KleineBre's FLTK stuff

I quite like using FLTK for my C++ development as it's a toolkit that's open source, light, free to use in any project (even commercial!) and cross-platform.

Occasionally, however, one runs into a desired functionality that FLTK does not (yet) offer. This is where FLTK really shines: It is usually possible to add such functionality, and the people on the FLTK mailing list are a big help in making such things happen.

Here is the source code of the components they helped me put together.

Image buttons

These classes permit you to create buttons with different up- and down- images, allowing for a bit better-looking buttons than the stock grey FLTK buttons. The images are associated with the button when it is created, and no additional code is required to switch between the up- and down- images.

Fl_Image_Button.cxx
Fl_Image_Button.H

Fl_Image_Repeat_Button.cxx
Fl_Image_Repeat_Button.H

Fl_Image_Toggle_Button.cxx
Fl_Image_Toggle_Button.H


Usage:
- Create a hidden 'down' button image and name it in an identifyable way
- Load the default 'up' image into the button in the usual manner
Add the following 'extra code' to the loading process of the button:

o->up_image(o->image()); // buttons default image is up image
o->down_image(button_play_dn->image()); // the identifyable name as described above
o->image(NULL); 

Animated GIF support

The following two files are a drop-in replacement for Fl_GIF_Image and can be used instead of the FLTK Fl_GIF_Image class. If this replacement detects that an image being loaded is an animated GIF image, it will make sure to load all frames of the image and starts amimating itself. The GIF images will redraw themselves in memory at their prescribed frame rate; all you have to do is to make sure their container periodically redraws itself. Ordinary GIF images behave as ever before.

Fl_GIF_Image.cxx
Fl_GIF_Image.h

Animation demo .fl files (+Fl_GIF_Image files)