diff options
-rw-r--r-- | dw/fltkui.cc | 49 | ||||
-rw-r--r-- | dw/fltkui.hh | 5 |
2 files changed, 52 insertions, 2 deletions
diff --git a/dw/fltkui.cc b/dw/fltkui.cc index fe65cbd7..01b71247 100644 --- a/dw/fltkui.cc +++ b/dw/fltkui.cc @@ -151,7 +151,6 @@ void FltkResource::setWidgetStyle (Fl_Widget *widget, Fl_Color fg = fl_contrast(style_fg, normal_bg); widget->labelcolor(fg); - widget->selection_color(fg); } widget->color(normal_bg); @@ -475,6 +474,23 @@ Fl_Widget *FltkEntryResource::createNewWidget (core::Allocation return input; } +void FltkEntryResource::setWidgetStyle (Fl_Widget *widget, + core::style::Style *style) +{ + Fl_Input *in = (Fl_Input *)widget; + + FltkResource::setWidgetStyle(widget, style); + + /* labelcolor has our foreground color. Borrow it for textcolor and + * find something that contrasts with the background for selection_color. + */ + in->textcolor(widget->labelcolor()); + widget->selection_color( + fl_contrast(in->textcolor(), widget->color())); + + in->cursor_color(in->textcolor()); +} + void FltkEntryResource::setDisplayed(bool displayed) { FltkResource::setDisplayed(displayed); @@ -579,6 +595,23 @@ Fl_Widget *FltkMultiLineTextResource::createNewWidget (core::Allocation return text; } +void FltkMultiLineTextResource::setWidgetStyle (Fl_Widget *widget, + core::style::Style *style) +{ + Fl_Text_Editor *ed = (Fl_Text_Editor *)widget; + + FltkResource::setWidgetStyle(widget, style); + + /* labelcolor has our foreground color. Borrow it for textcolor and + * find something that contrasts with the background for selection_color. + */ + ed->textcolor(widget->labelcolor()); + widget->selection_color( + fl_contrast(ed->textcolor(), widget->color())); + + ed->cursor_color(ed->textcolor()); +} + void FltkMultiLineTextResource::sizeRequest (core::Requisition *requisition) { if (style) { @@ -856,6 +889,20 @@ FltkOptionMenuResource::~FltkOptionMenuResource () delete menu; } +void FltkOptionMenuResource::setWidgetStyle (Fl_Widget *widget, + core::style::Style *style) +{ + Fl_Choice *ch = (Fl_Choice *)widget; + + FltkResource::setWidgetStyle(widget, style); + + /* labelcolor has our foreground color. Borrow it for textcolor and + * find something suitably contrasting for selection_color. + */ + ch->textcolor(widget->labelcolor()); + widget->selection_color( + fl_contrast(ch->color(), ch->textcolor())); +} Fl_Widget *FltkOptionMenuResource::createNewWidget (core::Allocation *allocation) diff --git a/dw/fltkui.hh b/dw/fltkui.hh index f62e7a3e..ccfe3710 100644 --- a/dw/fltkui.hh +++ b/dw/fltkui.hh @@ -187,7 +187,7 @@ protected: void init (FltkPlatform *platform); virtual Fl_Widget *createNewWidget (core::Allocation *allocation) = 0; - void setWidgetStyle (Fl_Widget *widget, core::style::Style *style); + virtual void setWidgetStyle (Fl_Widget *widget, core::style::Style *style); void setDisplayed (bool displayed); bool displayed(); public: @@ -293,6 +293,7 @@ private: protected: Fl_Widget *createNewWidget (core::Allocation *allocation); + void setWidgetStyle (Fl_Widget *widget, core::style::Style *style); public: FltkEntryResource (FltkPlatform *platform, int maxLength, bool password, @@ -318,6 +319,7 @@ private: protected: Fl_Widget *createNewWidget (core::Allocation *allocation); + void setWidgetStyle (Fl_Widget *widget, core::style::Style *style); public: FltkMultiLineTextResource (FltkPlatform *platform, int cols, int rows); @@ -453,6 +455,7 @@ class FltkOptionMenuResource: protected: Fl_Widget *createNewWidget (core::Allocation *allocation); virtual bool setSelectedItems() { return true; } + void setWidgetStyle (Fl_Widget *widget, core::style::Style *style); int getNumberOfItems(); int getMaxItemWidth (); private: |