| @@ -56,6 +56,7 @@ class Fl_Color_Scheme | |||
| Fl_Color_Scheme *next; | |||
| static int total; | |||
| static Fl_Color_Scheme *first; | |||
| static Fl_Color_Scheme *_current; | |||
| Fl_Color _bg; | |||
| Fl_Color _bg2; | |||
| @@ -63,6 +64,7 @@ class Fl_Color_Scheme | |||
| Fl_Color _sel; | |||
| const char *_name; | |||
| static void refresh ( void ); | |||
| public: | |||
| @@ -98,6 +100,8 @@ class Fl_Theme | |||
| void (*_init_func)(void); | |||
| static void refresh ( void ); | |||
| public: | |||
| const char *name ( void ) const { return _name; } | |||
| @@ -112,9 +116,10 @@ public: | |||
| _init_func = init_func; | |||
| } | |||
| static void save ( void ); | |||
| static void add ( Fl_Theme *td ); | |||
| static Fl_Theme **get ( void ); | |||
| static int set ( void ); | |||
| static int load_default ( void ); | |||
| static int set ( const char *name ); | |||
| static const Fl_Theme *current ( void ) { return _current; } | |||
| }; | |||
| @@ -25,6 +25,7 @@ | |||
| Fl_Theme *Fl_Theme::first; | |||
| Fl_Theme *Fl_Theme::_current; | |||
| Fl_Color_Scheme *Fl_Color_Scheme::first; | |||
| Fl_Color_Scheme *Fl_Color_Scheme::_current; | |||
| int Fl_Theme::total; | |||
| int Fl_Color_Scheme::total; | |||
| @@ -112,21 +113,15 @@ conf_get_color ( const char *key, Fl_Color def ) | |||
| return (Fl_Color)c; | |||
| } | |||
| static bool dont_save = false; | |||
| /* sets the configured default */ | |||
| int | |||
| Fl_Theme::set ( void ) | |||
| Fl_Theme::load_default ( void ) | |||
| { | |||
| const char *name = conf_get( "theme", "clean" ); | |||
| const char *name = conf_get( "theme", "cairo" ); | |||
| int rv = set( name ); | |||
| dont_save = true; | |||
| Fl_Color_Scheme::set( "System" ); | |||
| dont_save = false; | |||
| Fl_Color_Scheme::set( "Dark" ); | |||
| uchar r, g, b; | |||
| @@ -140,6 +135,12 @@ Fl_Theme::set ( void ) | |||
| return rv; | |||
| } | |||
| void | |||
| Fl_Theme::save ( void ) | |||
| { | |||
| conf_set( "theme", Fl_Theme::_current->name() ); | |||
| } | |||
| int | |||
| Fl_Theme::set ( const char *name ) | |||
| { | |||
| @@ -149,14 +150,10 @@ Fl_Theme::set ( const char *name ) | |||
| /* reset boxtypes */ | |||
| Fl::reload_scheme(); | |||
| printf( "Theme set to %s\n", t->name() ); | |||
| t->_init_func(); | |||
| Fl_Theme::_current = t; | |||
| conf_set( "theme", t->name() ); | |||
| for ( Fl_Window *w = Fl::first_window(); w; w = Fl::next_window( w ) ) | |||
| w->redraw(); | |||
| refresh(); | |||
| return 1; | |||
| } | |||
| @@ -164,6 +161,13 @@ Fl_Theme::set ( const char *name ) | |||
| return 0; | |||
| } | |||
| void | |||
| Fl_Theme::refresh ( void ) | |||
| { | |||
| for ( Fl_Window *w = Fl::first_window(); w; w = Fl::next_window( w ) ) | |||
| w->redraw(); | |||
| } | |||
| void | |||
| Fl_Color_Scheme::add ( Fl_Color_Scheme *t ) | |||
| { | |||
| @@ -189,13 +193,15 @@ Fl_Color_Scheme::get ( void ) | |||
| void | |||
| Fl_Color_Scheme::save ( void ) | |||
| { | |||
| if ( ! dont_save ) | |||
| { | |||
| conf_set( "background", Fl::get_color( FL_BACKGROUND_COLOR ) ); | |||
| conf_set( "foreground", Fl::get_color( FL_FOREGROUND_COLOR ) ); | |||
| conf_set( "background2", Fl::get_color( FL_BACKGROUND2_COLOR ) ); | |||
| } | |||
| conf_set( "color_scheme", Fl_Color_Scheme::_current->name() ); | |||
| conf_set( "background", Fl::get_color( FL_BACKGROUND_COLOR ) ); | |||
| conf_set( "foreground", Fl::get_color( FL_FOREGROUND_COLOR ) ); | |||
| conf_set( "background2", Fl::get_color( FL_BACKGROUND2_COLOR ) ); | |||
| } | |||
| void | |||
| Fl_Color_Scheme::refresh ( void ) | |||
| { | |||
| for ( Fl_Window *w = Fl::first_window(); w; w = Fl::next_window( w ) ) | |||
| w->redraw(); | |||
| } | |||
| @@ -217,9 +223,9 @@ Fl_Color_Scheme::set ( const char *name ) | |||
| /* Fl::get_color( t->_sel, r, g, b ); */ | |||
| /* Fl::selection( r, g, b ); */ | |||
| conf_set( "color_scheme", t->name() ); | |||
| Fl_Color_Scheme::_current = t; | |||
| save(); | |||
| refresh(); | |||
| return 1; | |||
| } | |||
| @@ -48,7 +48,7 @@ void Fl_Theme_Chooser::cb_color_scheme_choice(Fl_Choice* o, void* v) { | |||
| } | |||
| void Fl_Theme_Chooser::cb_OK_i(Fl_Return_Button*, void*) { | |||
| hide(); | |||
| Fl_Theme::save(); Fl_Color_Scheme::save(); hide(); | |||
| } | |||
| void Fl_Theme_Chooser::cb_OK(Fl_Return_Button* o, void* v) { | |||
| ((Fl_Theme_Chooser*)(o->parent()))->cb_OK_i(o,v); | |||
| @@ -62,8 +62,6 @@ Fl::get_color( o->color(), r,g,b ); | |||
| Fl::background( r,g,b ); | |||
| o->window()->redraw(); | |||
| Fl_Color_Scheme::save(); | |||
| } | |||
| void Fl_Theme_Chooser::cb_background_color_button(Fl_Color_Button* o, void* v) { | |||
| ((Fl_Theme_Chooser*)(o->parent()))->cb_background_color_button_i(o,v); | |||
| @@ -77,8 +75,6 @@ Fl::get_color( o->color(), r,g,b ); | |||
| Fl::background2( r,g,b ); | |||
| o->window()->redraw(); | |||
| Fl_Color_Scheme::save(); | |||
| } | |||
| void Fl_Theme_Chooser::cb_background2_color_button(Fl_Color_Button* o, void* v) { | |||
| ((Fl_Theme_Chooser*)(o->parent()))->cb_background2_color_button_i(o,v); | |||
| @@ -92,8 +88,6 @@ Fl::get_color( o->color(), r,g,b ); | |||
| Fl::foreground( r,g,b ); | |||
| o->window()->redraw(); | |||
| Fl_Color_Scheme::save(); | |||
| } | |||
| void Fl_Theme_Chooser::cb_foreground_color_button(Fl_Color_Button* o, void* v) { | |||
| ((Fl_Theme_Chooser*)(o->parent()))->cb_foreground_color_button_i(o,v); | |||
| @@ -65,7 +65,7 @@ redraw();} open | |||
| } {} | |||
| Fl_Return_Button {} { | |||
| label OK | |||
| callback {hide();} selected | |||
| callback {Fl_Theme::save(); Fl_Color_Scheme::save(); hide();} selected | |||
| xywh {355 345 75 25} | |||
| } | |||
| Fl_Group {} { | |||
| @@ -104,7 +104,7 @@ Fl::background( r,g,b ); | |||
| o->window()->redraw(); | |||
| Fl_Color_Scheme::save();} | |||
| } | |||
| xywh {120 76 300 25} box BORDER_BOX align 4 when 6 | |||
| code0 {\#include <FL/fl_ask.H>} | |||
| code1 {o->color( FL_BACKGROUND_COLOR );} | |||
| @@ -119,8 +119,7 @@ Fl::get_color( o->color(), r,g,b ); | |||
| Fl::background2( r,g,b ); | |||
| o->window()->redraw(); | |||
| Fl_Color_Scheme::save();} | |||
| } | |||
| xywh {120 104 300 25} box BORDER_BOX align 4 | |||
| code1 {o->color( FL_BACKGROUND2_COLOR );} | |||
| class Fl_Color_Button | |||
| @@ -135,7 +134,7 @@ Fl::foreground( r,g,b ); | |||
| o->window()->redraw(); | |||
| Fl_Color_Scheme::save();} | |||
| } | |||
| xywh {120 132 300 25} box BORDER_BOX align 4 | |||
| code1 {o->color( FL_FOREGROUND_COLOR );} | |||
| class Fl_Color_Button | |||
| @@ -665,7 +665,8 @@ void fl_open_display(Display* d) { | |||
| Fl::get_system_colors(); | |||
| fl_register_themes(); | |||
| Fl_Theme::set(); | |||
| Fl_Theme::load_default(); | |||
| } | |||
| void fl_close_display() { | |||