I tried to display custom text on top of an image. My first attempt was to use 
InvisibleBox as below:

int main(int argc, char ** argv) {
        fltk::register_images();
        fltk::Window * window = new fltk::Window(0, 0, 480, 640, "Test");
        window->begin();

        window->image(new fltk::TiledImage(fltk::SharedImage::get("test.png")));
        fltk::InvisibleBox * b = new fltk::InvisibleBox(60, 120, 340, 80, 
"Sample text.");
        b->labelfont(fltk::COURIER_BOLD);
        b->labelsize(28);

        window->end();
        window->show(argc, argv);

        return fltk::run();
}

but in this example even "Sample text." is not visible. I can't find any 
predefined box type, that allows to display text on top of other widget (image 
on my example) with no background and no border.
I created custom class by some mindless copy-paste from src/UpBox.cxx:

struct BoxNoBackground : public fltk::Box {
        void _draw(const fltk::Rectangle & r) const {}
        BoxNoBackground() : fltk::Box("xyz") { set_inset(1); }
};
static BoxNoBackground bnb;
static fltk::Box * const BOX_NO_BACKGROUND = &bnb;

and further use:
b->box(BOX_NO_BACKGROUND);

but it would be strange if there isn't solution without creating custom class.
What is the preferred way to display text on top of other widget?

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

Reply via email to