On 10/17/11 16:52, David wrote:
> Looking for where labels xywh are set was murky. Instead I just created a
> class for now:
Yes, this is a decent solution, though I think a more solid one
would be to override draw() so that if the parent's bgcolor is
something other than FL_INACTIVE_COLOR, it will still look right.
> public:
> Fl_Groupbox(int x,int y,int w,int h, const char *label = 0) :
> Fl_Group(x,y,w,h), Text(x, y, w, 0, label)
> {
..to allow the user of the widget to change the label(),
you might want to override 'const char *label()' and
'void label(const char*)' so that changes to the label
are applied to the Text and not the Fl_Group, and have it
resize the Text box to adapt to the new text.
> Text.size(w+8, h);
> Text.position(x+5, y-(h/2));
..I think those two lines can be a one liner:
resize(x+5, y-(h/2), w+8, h);
> Text.labelcolor(FL_INACTIVE_COLOR);
> Text.box(FL_FLAT_BOX);
..this will work as long as you know the actual background color
under the label is FL_INACTIVE_COLOR.
For a widget that doesn't care what the bg color is, there might
be a way to mask the border from drawing where the label is.
I'm not sure how to pull that off though.. I don't think fl_clip()
would do it.. one would need something the opposite of a clip,
eg. a 'mask'; defining a rectangular region that drawing functions
won't draw into.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk