This slight reworking of Greg's original example does seem to work OK.
It uses a "two box" solution, one underneath for the image, one on top
for the text label.
The "on top" box has no box type set, so is mainly transparent... This
seems to work OK.

fltk-config --use-images --compile img-ovr.cxx 

#include <FL/Fl.H>
#include <FL/Fl_PNG_Image.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Box.H>

Fl_Window     *win = 0;
Fl_Button     *but = 0;
Fl_Box        *box_under = 0;
Fl_Box        *box_over = 0;
Fl_PNG_Image  *picture = 0;

void ButtonCallback(Fl_Widget*,void*) {
  static int ncol = 53;
  box_over->labelcolor((Fl_Color)ncol);
  box_over->label("Your text goes here.");
  box_over->redraw();
  /* get a different colour */
  ncol += 5;
  if(ncol > 80) ncol = 53;
}
int main(int argc, char **argv) {
  picture = new Fl_PNG_Image("../Image_512x512.png");
  win = new Fl_Double_Window(700, 600);
  win->begin();

    box_under = new Fl_Box(10,10,512,512);
    box_under->image(picture);
    box_under->box(FL_FLAT_BOX);

    box_over = new Fl_Box(10,10,512,512);
    box_over->box(FL_NO_BOX);
    box_over->labelcolor(FL_WHITE);
    box_over->labelsize(28);
    box_over->align(FL_ALIGN_CENTER |
                    FL_ALIGN_INSIDE);

    but = new Fl_Button(300,530,120,25,"Push");
    but->callback(ButtonCallback);

  win->end();
  win->show(argc,argv);
  return Fl::run();
}
/* end of file */

SELEX Sensors and Airborne Systems Limited
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 
3EL
A company registered in England & Wales.  Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************

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

Reply via email to