Todd Plessel:
> How can I create a text string label without an associated 'widget'?
> I.e., something like FL_Output but without the 'box'.
If the area you're drawing over is a widget, it likely already has
a label() method which you can set to the text you want, and use
align() to position the text where you want. For more on align(), see:
http://fltk.org/documentation.php/doc-1.1/Fl_Widget.html#Fl_Widget.align
If the widget you're drawing over is a /window/, then that won't
work because a window's label() only affects the title bar, so to
get a text string inside the window, you should either:
1) Add an Fl_Box as Nordwolf mentioned
2) Subclass the Fl_Window and add fl_draw() to draw the text
in the derived class's draw() method.
#1 is the easiest, and works for drawing over other widgets too.
Fl_Box is about as light weight as it gets, and since the default
box type is FL_NO_BOX, you won't get a box around the text. eg:
Fl_Box *mytext = new Fl_Box(10,10,200,25,"My email is
foo@@somewhere.com");
To disable the @ expansion, see Ian's response.
#2 works well if you've subclassed the widget, and want to
draw the text on your own, eg:
class MyWindow : public Fl_Window {
..
void draw() {
Fl_Window::draw(); // tell the window to
draw itself
fl_font(FL_HELVETICA, 14); // set font/size
fl_color(FL_BLACK); // set font color
fl_draw("My [email protected]", 10, 10, 0); // draw text string at
10,10 with symbols off (so @ works)
}
};
For more on using fl_draw() to draw text, see
http://fltk.org/documentation.php/doc-1.1/drawing.html#text
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk