ste wrote:
> haii.. i m new with fltk... how to show text on an image .jpeg?? for example,
> i have an image .jpeg and a button, after klik this buttom some text appear
> on the image.. i had try like fltk's guide.. with callback, gl,etc.. enyone
> can help??.. or any articles?? tengkiu verymuch...
I would have thought the following would work, but it doesn't:
the text strangely when an image is assigned. Is this a bug?
There are a lot of other ways to do this; it's a bit more code
and involves deriving your own class and overriding draw().
I'll follow up with that separately. I'm just surprised this doesn't
work:
#include <FL/Fl.H>
#include <FL/Fl_JPEG_Image.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Box.H>
Fl_Window *win = 0;
Fl_Button *but = 0;
Fl_Box *box = 0;
Fl_JPEG_Image *jpg = 0;
void ButtonCallback(Fl_Widget*,void*) { // callback for when
button is pushed
box->label("Your text goes here."); // set label text for
box
box->labelcolor(FL_WHITE); // label's text color
box->labelsize(28); // label's text size
box->align(FL_ALIGN_CENTER | // label will be
centered
FL_ALIGN_INSIDE | // label will be
/inside/ box
FL_ALIGN_TEXT_OVER_IMAGE); // label will be /over/
image
}
int main(int argc, char **argv) {
jpg = new Fl_JPEG_Image("/tmp/foo.jpg"); // load image
win = new Fl_Window(700, 600); // create window
box = new Fl_Box(10,10,640,480); // create box for image
box->image(jpg); // assign image to box
box->box(FL_BORDER_FRAME);
but = new Fl_Button(300,500,120,25,"Push"); // create button
but->callback(ButtonCallback); // assign callback to
button
win->end();
win->show(argc,argv);
return(Fl::run());
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk