Am 21.06.2009 15:24 Uhr schrieb "[email protected]" unter
<[email protected]>:

> [..]
>> 
>> OTOH, if you call window()->redraw(), then this would reliably draw
>> everything,
>> but might flicker, if you don't use double buffering (Fl_Double_Window).
>> 
>> Albrecht
> 
> It occurred to me to try the following, which seems to
> work okay.  Other than being relatively inefficient,
> do you guys see any issues with it?
> 
> Thanks again,
> Stan
> 
> void
> relabel(Fl_Widget* w, char const* newlabel, bool copy = false)
> {
>     static std::string spaces(" ");
>     if(w->label()) {
>         spaces.resize(1);
>         while(fl_width(spaces.c_str()) < fl_width(w->label())) {
>             spaces += ' ';
>         }
>         w->label(spaces.c_str());
>         w->redraw_label();
>     }
>     if(copy) w->copy_label(newlabel); else w->label(newlabel);
>     w->redraw_label();
> }

This will not work because drawing a space mean actually drawing noting. So,
drawing nothing over text will still leave the old text.

Here are some alternatives if redrawing the entire parent is too much:

1: Put your widget into a smaller group that contains the label. Now calling
redraw() on the parent will only redraw a small group.

2: create a second widget (Fl_Box) above your original widget and make an
inside label for that box instead of an outside label for the widget below.
It looks pretty much the same, but refreshes automatically.

3: if your label changes all the time, maybe an Fl_Output wiget is better
suited?

Matthias


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

Reply via email to