Randy Seedle wrote:

> Is there a means to create multiple image buttons on a single screen ? The
> images need to be loaded from .png files. And when clicked, the image
> would need to return a unique identifier.
> 
> Randy Seedle
> ShockWatch Inc.

I'm going to assume you are using fltk 1.1.x (cause that's what I use ;) )

To load the images, use Fl_Shared_Image. That way you can load not only png
files, but bmp, xpm, and jpg with no extra effort.

Then you want to create a Fl_Box with the label set as "" (empty string) and
a box type of FL_FLAT_BOX. Finally, use Fl_Box::image(Fl_Image *) to set
the image you want for the widget.

Here's an example,

Fl_Shared_Image *img = Fl_Shared_Image::get("/path/to/image.png");

Fl_Box *w = new Fl_Box(X, Y, img->w(), img->h(), "");
w->box(FL_FLAT_BOX);
w->align(FL_ALIGN_INSIDE | FL_ALIGN_LEFT);

If you use FLUID to design you app, then its even easier. Just set the image
field to the path of your image file. Then use in the _inside_ alignment
for the label.

Just one more note. In fltk 1.1.x, done this way, an image on the widget is
considered part of the widget's label.

HTH,

-- 
Alvin
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to