Alvin wrote:

> Can the colour of the Fl_Round_Button be configured when using the gtk+
> scheme?
> 
> I have tried setting the Selection Colour in FLUID, but that seems to have
> no effect under gtk+. Using plastic or the default scheme, my chosen
> selection colour is used. I prefer to use gtk+ scheme though.
> 
> Thanks.
> 

I think I have found an unobtrusive way of changing the colour of a
Fl_Round_Button while use the gtk+ scheme.

I had to derive a new widget from Fl_Round_Button and override the draw()
method. The draw method then replaces the FL_SELECTION_COLOR value with the
value from selection_color(). After the widget is drawn, FL_SELECTION_COLOR
is then restored.

Here's the class I am using. So far I haven't noticed any adverse
side-effects.

Enjoy,

Alvin

---- 8<-----

#ifndef FL_RADIO_BUTTON_H
#define FL_RADIO_BUTTON_H

/****************************************************************************/

#include <FL/Fl_Round_Button.H>

/****************************************************************************/

class Fl_Radio_Button : public Fl_Round_Button
{
   public:
      Fl_Radio_Button(int X, int Y, int W, int H, const char* L = 0)
         : Fl_Round_Button(X, Y, W, H, L) {}

      virtual ~Fl_Radio_Button() {}

      virtual void draw();
};

/****************************************************************************/

inline void Fl_Radio_Button::draw()
{
   // save FL_SELECTION_COLOR
   unsigned int sel_col = Fl::get_color(FL_SELECTION_COLOR);

   // use the user defined selection colour
   Fl::set_color(FL_SELECTION_COLOR, Fl::get_color(selection_color()));

   // Let Fl_Round_Button do its work
   Fl_Round_Button::draw();

   // restore FL_SELECTION_COLOR
   Fl::set_color(FL_SELECTION_COLOR, sel_col);
}

/****************************************************************************/

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

Reply via email to