diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2010-12-12 19:52:26 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2010-12-12 19:52:26 +0000 |
| commit | 318b3dea5750dfce5103a8fbce6eea38f7fcd613 (patch) | |
| tree | 69532eb4658057f41e1c07f80314aaa68c046e28 /src | |
| parent | 495b3b5af5051dd69f595aa05989f679ed992fef (diff) | |
Added an 'Options' dialog (replacing test/preferences) that can be used to set system wide or user real options like Visible Focus.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8018 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl.cxx | 64 | ||||
| -rw-r--r-- | src/Fl_Text_Display.cxx | 2 | ||||
| -rw-r--r-- | src/Fl_Tooltip.cxx | 3 |
3 files changed, 55 insertions, 14 deletions
diff --git a/src/Fl.cxx b/src/Fl.cxx index f38205910..300b17b5b 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -90,8 +90,6 @@ int Fl::damage_, char *Fl::e_text = (char *)""; int Fl::e_length; -int Fl::visible_focus_ = 1, - Fl::dnd_text_ops_ = 1; unsigned char Fl::options_[] = { 0, 0 }; unsigned char Fl::options_read_ = 0; @@ -1760,7 +1758,7 @@ void Fl::clear_widget_pointer(Fl_Widget const *w) /** - \brief User interface options management. + \brief FLTK library options management. This function needs to be documented in more detail. It can be used for more optional settings, such as using a native file chooser instead of the FLTK one @@ -1771,6 +1769,10 @@ void Fl::clear_widget_pointer(Fl_Widget const *w) There should be an application that manages options system wide, per user, and per application. + + \param opt which option + \return true or false + \see Fl_Option */ bool Fl::option(Fl_Option opt) { @@ -1779,15 +1781,35 @@ bool Fl::option(Fl_Option opt) { // first, read the system wide preferences Fl_Preferences prefs(Fl_Preferences::SYSTEM, "fltk.org", "fltk"); Fl_Preferences opt_prefs(prefs, "options"); - opt_prefs.get("ArrowFocus", tmp, 0); options_[OPTION_ARROW_FOCUS] = tmp; - opt_prefs.get("NativeFilechooser", tmp, 0); options_[OPTION_NATIVE_FILECHOOSER] = tmp; + opt_prefs.get("ArrowFocus", tmp, 0); // default: off + options_[OPTION_ARROW_FOCUS] = tmp; + //opt_prefs.get("NativeFilechooser", tmp, 1); // default: on + //options_[OPTION_NATIVE_FILECHOOSER] = tmp; + //opt_prefs.get("FilechooserPreview", tmp, 1); // default: on + //options_[OPTION_FILECHOOSER_PREVIEW] = tmp; + opt_prefs.get("VisibleFocus", tmp, 1); // default: on + options_[OPTION_VISIBLE_FOCUS] = tmp; + opt_prefs.get("DNDText", tmp, 1); // default: on + options_[OPTION_DND_TEXT] = tmp; + opt_prefs.get("ShowTooltips", tmp, 1); // default: on + options_[OPTION_SHOW_TOOLTIPS] = tmp; } { // next, check the user preferences // override system options only, if the option is set ( >= 0 ) Fl_Preferences prefs(Fl_Preferences::USER, "fltk.org", "fltk"); Fl_Preferences opt_prefs(prefs, "options"); - opt_prefs.get("ArrowFocus", tmp, -1); if (tmp >= 0) options_[OPTION_ARROW_FOCUS] = tmp; - opt_prefs.get("NativeFilechooser", tmp, -1); if (tmp >= 0) options_[OPTION_NATIVE_FILECHOOSER] = tmp; + opt_prefs.get("ArrowFocus", tmp, -1); + if (tmp >= 0) options_[OPTION_ARROW_FOCUS] = tmp; + //opt_prefs.get("NativeFilechooser", tmp, -1); + //if (tmp >= 0) options_[OPTION_NATIVE_FILECHOOSER] = tmp; + //opt_prefs.get("FilechooserPreview", tmp, -1); + //if (tmp >= 0) options_[OPTION_FILECHOOSER_PREVIEW] = tmp; + opt_prefs.get("VisibleFocus", tmp, -1); + if (tmp >= 0) options_[OPTION_VISIBLE_FOCUS] = tmp; + opt_prefs.get("DNDText", tmp, -1); + if (tmp >= 0) options_[OPTION_DND_TEXT] = tmp; + opt_prefs.get("ShowTooltips", tmp, -1); + if (tmp >= 0) options_[OPTION_SHOW_TOOLTIPS] = tmp; } { // now, if the developer has registered this app, we could as for per-application preferences } @@ -1798,14 +1820,34 @@ bool Fl::option(Fl_Option opt) return (bool)options_[opt]; } +/** + \brief Override an option while the application is running. + + This function does not change any system or user settings. + + \param opt which option + \param val set to true or false + \see Fl_Option + */ +void Fl::option(Fl_Option opt, bool val) +{ + if (opt<0 || opt>=OPTION_LAST) + return; + if (!options_read_) { + // first read this option, so we don't override our setting later + option(opt); + } + options_[opt] = val; +} + // Helper class Fl_Widget_Tracker /** The constructor adds a widget to the watch list. */ -Fl_Widget_Tracker::Fl_Widget_Tracker(Fl_Widget *wi) { - +Fl_Widget_Tracker::Fl_Widget_Tracker(Fl_Widget *wi) +{ wp_ = wi; Fl::watch_widget_pointer(wp_); // add pointer to watch list } @@ -1813,8 +1855,8 @@ Fl_Widget_Tracker::Fl_Widget_Tracker(Fl_Widget *wi) { /** The destructor removes a widget from the watch list. */ -Fl_Widget_Tracker::~Fl_Widget_Tracker() { - +Fl_Widget_Tracker::~Fl_Widget_Tracker() +{ Fl::release_widget_pointer(wp_); // remove pointer from watch list } diff --git a/src/Fl_Text_Display.cxx b/src/Fl_Text_Display.cxx index 6347fcd02..a512e477e 100644 --- a/src/Fl_Text_Display.cxx +++ b/src/Fl_Text_Display.cxx @@ -3609,7 +3609,7 @@ int Fl_Text_Display::handle(int event) { if (dragType==DRAG_NONE) return 1; if (dragType==DRAG_START_DND) { - if (!Fl::event_is_click()) { + if (!Fl::event_is_click() && Fl::dnd_text_ops()) { const char* copy = buffer()->selection_text(); Fl::dnd(); free((void*)copy); diff --git a/src/Fl_Tooltip.cxx b/src/Fl_Tooltip.cxx index 7239d8f46..67d620f94 100644 --- a/src/Fl_Tooltip.cxx +++ b/src/Fl_Tooltip.cxx @@ -34,13 +34,12 @@ float Fl_Tooltip::delay_ = 1.0f; float Fl_Tooltip::hoverdelay_ = 0.2f; -int Fl_Tooltip::enabled_ = 1; Fl_Color Fl_Tooltip::color_ = fl_color_cube(FL_NUM_RED - 1, FL_NUM_GREEN - 1, FL_NUM_BLUE - 2); Fl_Color Fl_Tooltip::textcolor_ = FL_BLACK; Fl_Font Fl_Tooltip::font_ = FL_HELVETICA; -Fl_Fontsize Fl_Tooltip::size_ = FL_NORMAL_SIZE; +Fl_Fontsize Fl_Tooltip::size_ = FL_NORMAL_SIZE; #define MAX_WIDTH 400 |
