> > I need to change the background of the checkmark for a
> > Fl_Check_Button.
>
> > From documentation, I find :
> > The selection_color() sets the color of the checkmark.
> > Black is default.
> > I however need to set the background - which is white as default.
>
> > How do I change this color ?
>
> Well, you could try overwriting FL_BACKGROUND_COLOR, but that would
> affect all widgets - not the desired effect, I imagine!
>
> I haven't tried it, but for a checkbox, is the background not set by
> the color(); method?
>
> I might have to try that, actually... Not at all sure!
OK, tried that.
It is not set by color(); instead, it is hard-coded to FL_BACKGROUND2_COLOR, which is usually white (though is set during a win->show(argc, argv); call to match the system settings where possible.)
Now, doing something like:
Fl::set_color(FL_BACKGROUND2_COLOR, 0, 250, 0);
will work, though will have side-effects, since other widgets may also be using FL_BACKGROUND2_COLOR...
The "easy" fix might be to derive your own check button that only re-implements draw() to just set/restore FL_BACKGROUND2_COLOR on the fly?
viz:
class alt_check : public Fl_Check_Button
{
public:
alt_check(int X, int Y, int W, int H, const char *L) :
Fl_Check_Button(X,Y,W,H,L) {};
private:
void draw ()
{
Fl_Color old = Fl::get_color(FL_BACKGROUND2_COLOR); // save the default colour
Fl::set_color(FL_BACKGROUND2_COLOR, 0, 200, 0); // force green background
Fl_Check_Button::draw(); // do the drawing
Fl::set_color(FL_BACKGROUND2_COLOR, old); // put the default colour back
}
};
Which works in a quick hack test...