vanishing checkbox labels

21 views
Skip to first unread message

joe63074

unread,
Apr 26, 2015, 3:30:33 PM4/26/15
to fltkg...@googlegroups.com
I have a few dialogs which use a widget extended from Fl_Check_Button (trivially, only to place within a group). If the dialog requires refreshing, the checkbox itself is redrawn -- but not the label. Only this particular widget has the problem. Ideas?

Thanks,
-Joe

Richard Sanders

unread,
Apr 26, 2015, 4:16:05 PM4/26/15
to fltkg...@googlegroups.com



I have a few dialogs which use a widget extended from Fl_Check_Button (trivially, only to place within a group). If the dialog requires refreshing, the checkbox itself is redrawn -- but not the label. Only this particular widget has the problem. Ideas?


If you are setting your labels with checkbox->label() switch to checkbox->copy_label()

If you are setting labels with Fl_Check_Button(x, y, w, h, string-variable); then change to checkbox->copy_label() for setting your labels.

If the string-variable goes out of scope then labels are undefined, copy_label() makes a local copy that stays in scope.





 

Ian MacArthur

unread,
Apr 26, 2015, 4:45:41 PM4/26/15
to fltkg...@googlegroups.com
On Sun Apr 26 2015 20:30:32, joe63074 wrote:
> I have a few dialogs which use a widget extended from Fl_Check_Button (trivially, only to place within a group). If the dialog requires refreshing, the checkbox itself is redrawn -- but not the label. Only this particular widget has the problem. Ideas?
>


Usually this is a bounding box issue.

It is not uncommon for checkboxes to be created with a bounding box that is basically the size of the check box itself, say 20x20 or whatever. The label then lies outside the bounding box...
But when a widget is signalled to redraw, the clip region is set to the bounding box. In that case, the label will not be redrawn, since it lies outside the active clip.

So, you have two options; either make sure your bounding box is large enough to enclose the label too, or explicitly trigger a redraw of the parent widget if you know the label of the checkbox has changed (assuming of course that the label does lie somewhere inside the bounding box of the parent, of course.

This is in the docs somewhere (though I’m not sure where...)

It’s a slightly odd behaviour and it catches folk out.

It ties back to the fast-light thing - with a checkbox, it is usually only the check that changes, and hence only the check that needs to be redrawn.
The label is probably static so might be drawn once and never altered.

The assumption is that the programmer will know when the label might be altered (e.g. if the label has changed, or the parent widget has a changing background, or whatever) so in that case the programmer is best placed to determine when to redraw the label...



joe63074

unread,
Apr 26, 2015, 5:39:46 PM4/26/15
to fltkg...@googlegroups.com
It was the bounding box. By mistake I had only taken the label measurement into account for x/y positioning, and didn't adjust the width/height. Thanks.

Reply all
Reply to author
Forward
0 new messages