diff options
| -rw-r--r-- | CHANGES | 1 | ||||
| -rw-r--r-- | FL/Fl.H | 59 | ||||
| -rw-r--r-- | FL/Fl_Tooltip.H | 7 | ||||
| -rw-r--r-- | ide/Xcode3/FLTK.xcodeproj/project.pbxproj | 2 | ||||
| -rw-r--r-- | src/Fl.cxx | 64 | ||||
| -rw-r--r-- | src/Fl_Text_Display.cxx | 2 | ||||
| -rw-r--r-- | src/Fl_Tooltip.cxx | 3 | ||||
| -rw-r--r-- | test/preferences.fl | 424 |
8 files changed, 269 insertions, 293 deletions
@@ -1,5 +1,6 @@ CHANGES IN FLTK 1.3.0 + - Added general Options dialog (STR #2471) - Fixed Compiling with mingw-w64 (STR #2308). - Fixed crashes when detecting illegal utf 8 sequences in Fl_Text_* widgets (STR #2348) @@ -137,8 +137,6 @@ public: // should be private! static Fl_Window* modal_; static Fl_Window* grab_; static int compose_state; - static int visible_focus_; - static int dnd_text_ops_; #endif /** If true then flush() will do something. @@ -147,14 +145,35 @@ public: // should be private! public: typedef enum { - /// If set, the arrow keys can change focus from a text widget to another - /// widget. If clear, only Tab and BackTab can. + /// When switched on, moving the text cursor beyond the start or end of + /// a text in a text widget will change focus to the next text widgt. + /// When switched off, the cursor will stop at the end of the text. + /// Pressing Tab or Ctrl-Tab will advance the keyboard focus. OPTION_ARROW_FOCUS = 0, - /// If set, calls to fl_file_chooser will open the native file chooser. - /// If clear, the FLTK file chooser will open instead. - /// \todo Fl::OPTION_NATIVE_FILECHOOSER not yet supported - OPTION_NATIVE_FILECHOOSER, - // don't change this, leave it always as the last element + // When switched on, FLTK will use the file chooser dialog that comes + // with your operating system whenever possible. When switched off, FLTK + // will present its own file chooser. + // \todo implement me + // OPTION_NATIVE_FILECHOOSER, + // When Filechooser Preview is enabled, the FLTK or native file chooser + // will show a preview of a selected file (if possible) before the user + // decides to choose the file. + // \todo implement me + //OPTION_FILECHOOSER_PREVIEW, + /// If visible focus is switched on, FLTK will draw a dotted rectangle + /// inside the widget that will receive the next keystroke. If switched + /// off, no such indicator will be drawn and keyboard navigation + /// is disabled. + OPTION_VISIBLE_FOCUS, + /// If text drag-and-drop is enabled, the user can select and drag text + /// from any text widget. If disabled, no dragging is possible, however + /// dropping text from other applications still works. + OPTION_DND_TEXT, + /// If tooltips are enabled, hovering the mouse over a widget with a + /// tooltip text will open a little tootip window until the mouse leaves + /// the widget. If disabled, no tooltip is shown. + OPTION_SHOW_TOOLTIPS, + // don't change this, leave it always as the last element OPTION_LAST } Fl_Option; @@ -163,15 +182,17 @@ private: static unsigned char options_read_; public: - /** - Return a global setting for all FLTK applications, possibly overridden - by a setting specifically for this application. - - \param opt - \returns true or false + /* + Return a global setting for all FLTK applications, possibly overridden + by a setting specifically for this application. */ static bool option(Fl_Option opt); + /* + Override an option while the application is running. + */ + static void option(Fl_Option opt, bool val); + /** The currently executing idle callback function: DO NOT USE THIS DIRECTLY! @@ -913,13 +934,13 @@ public: non-text widgets. The default mode is to enable keyboard focus for all widgets. */ - static void visible_focus(int v) { visible_focus_ = v; } + static void visible_focus(int v) { option(OPTION_VISIBLE_FOCUS, v); } /** Gets or sets the visible keyboard focus on buttons and other non-text widgets. The default mode is to enable keyboard focus for all widgets. */ - static int visible_focus() { return visible_focus_; } + static int visible_focus() { return option(OPTION_VISIBLE_FOCUS); } // Drag-n-drop text operation methods... /** @@ -928,14 +949,14 @@ public: be dragged from text fields or dragged within a text field as a cut/paste shortcut. */ - static void dnd_text_ops(int v) { dnd_text_ops_ = v; } + static void dnd_text_ops(int v) { option(OPTION_DND_TEXT, v); } /** Gets or sets whether drag and drop text operations are supported. This specifically affects whether selected text can be dragged from text fields or dragged within a text field as a cut/paste shortcut. */ - static int dnd_text_ops() { return dnd_text_ops_; } + static int dnd_text_ops() { return option(OPTION_DND_TEXT); } /** \defgroup fl_multithread Multithreading support functions fl multithreading support functions declared in <FL/Fl.H> @{ */ diff --git a/FL/Fl_Tooltip.H b/FL/Fl_Tooltip.H index 49419c985..33b69cb6a 100644 --- a/FL/Fl_Tooltip.H +++ b/FL/Fl_Tooltip.H @@ -55,11 +55,11 @@ public: */ static void hoverdelay(float f) { hoverdelay_ = f; } /** Returns non-zero if tooltips are enabled. */ - static int enabled() { return enabled_; } + static int enabled() { return Fl::option(Fl::OPTION_SHOW_TOOLTIPS); } /** Enables tooltips on all widgets (or disables if <i>b</i> is false). */ - static void enable(int b = 1) { enabled_ = b;} + static void enable(int b = 1) { Fl::option(Fl::OPTION_SHOW_TOOLTIPS, b);} /** Same as enable(0), disables tooltips on all widgets. */ - static void disable() { enabled_ = 0; } + static void disable() { enable(0); } static void (*enter)(Fl_Widget* w); static void enter_area(Fl_Widget* w, int X, int Y, int W, int H, const char* tip); static void (*exit)(Fl_Widget *w); @@ -100,7 +100,6 @@ private: private: static float delay_; //!< delay before a tooltip is shown static float hoverdelay_; //!< delay between tooltips - static int enabled_; static Fl_Color color_; static Fl_Color textcolor_; static Fl_Font font_; diff --git a/ide/Xcode3/FLTK.xcodeproj/project.pbxproj b/ide/Xcode3/FLTK.xcodeproj/project.pbxproj index 2517e5274..3ffda7957 100644 --- a/ide/Xcode3/FLTK.xcodeproj/project.pbxproj +++ b/ide/Xcode3/FLTK.xcodeproj/project.pbxproj @@ -5449,6 +5449,7 @@ 2DE25DB4CE986C1857B5ECF7 /* Fl_Native_File_Chooser.cxx */, D1C792936D427CC48581BFAE /* Fl_Overlay_Window.cxx */, 813C830680D031C1B2FCF9B6 /* Fl_Pack.cxx */, + 6C1C9A4F054C48CDD6A2DE44 /* Fl_Paged_Device.cxx */, D79D3910F834D4B78FED92F3 /* Fl_Pixmap.cxx */, 05BBBFE4BED0452E5D6A81F7 /* Fl_Positioner.cxx */, B4CAFA162560925C4591997A /* Fl_Printer.cxx */, @@ -5558,7 +5559,6 @@ FB7A9EFB3C7CDAE324E9544F /* case.c */, 6B30F6EA5CA69E305D2B82EE /* is_right2left.c */, 5AE1F936F1C186E18C1B9C28 /* is_spacing.c */, - 6C1C9A4F054C48CDD6A2DE44 /* Fl_Paged_Device.cxx */, ); name = fltk; sourceTree = "<group>"; 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 diff --git a/test/preferences.fl b/test/preferences.fl index 0190f6651..a6d8692a8 100644 --- a/test/preferences.fl +++ b/test/preferences.fl @@ -17,312 +17,226 @@ decl {\#include <FL/filename.H>} {private local decl {\#include <FL/fl_ask.H>} {private local } -decl {void readPrefs();} {public local +decl {int opt[10][2];} { + comment {Copy of all options in user and system mode} private local } -decl {void writePrefs();} {public local +Function {refreshUI()} { + comment {Update the UI using the values in the opt array} return_type void +} { + code {int mode = wUserOrSystem->value(); +wVisibleFocus->value(opt[Fl::OPTION_VISIBLE_FOCUS][mode]); +wArrowFocus->value(opt[Fl::OPTION_ARROW_FOCUS][mode]); +wShowTooltips->value(opt[Fl::OPTION_SHOW_TOOLTIPS][mode]); +wDNDText->value(opt[Fl::OPTION_DND_TEXT][mode]);} {} } -Function {closeWindowCB( Fl_Widget*, void* )} {open private return_type void +Function {readPrefs()} { + comment {read all preferences and refresh the GUI} return_type void } { - code {Fl::delete_widget(myWindow);} {} + code {// read all preferences and refresh the GUI +{ + Fl_Preferences prefs(Fl_Preferences::SYSTEM, "fltk.org", "fltk"); + Fl_Preferences opt_prefs(prefs, "options"); + opt_prefs.get("ArrowFocus", opt[Fl::OPTION_ARROW_FOCUS][1], 2); + opt_prefs.get("VisibleFocus", opt[Fl::OPTION_VISIBLE_FOCUS][1], 2); + opt_prefs.get("DNDText", opt[Fl::OPTION_DND_TEXT][1], 2); + opt_prefs.get("ShowTooltips", opt[Fl::OPTION_SHOW_TOOLTIPS][1], 2); +} +{ + Fl_Preferences prefs(Fl_Preferences::USER, "fltk.org", "fltk"); + Fl_Preferences opt_prefs(prefs, "options"); + opt_prefs.get("ArrowFocus", opt[Fl::OPTION_ARROW_FOCUS][0], 2); + opt_prefs.get("VisibleFocus", opt[Fl::OPTION_VISIBLE_FOCUS][0], 2); + opt_prefs.get("DNDText", opt[Fl::OPTION_DND_TEXT][0], 2); + opt_prefs.get("ShowTooltips", opt[Fl::OPTION_SHOW_TOOLTIPS][0], 2); +} +refreshUI();} {} } -Function {saveAndCloseWindowCB( Fl_Widget*, void* )} {open private return_type void +Function {writePrefs()} { + comment {write all preferences using the array} return_type void } { - code {writePrefs(); -Fl::delete_widget(myWindow);} {} + code {// write all preferences using the array +{ + Fl_Preferences prefs(Fl_Preferences::SYSTEM, "fltk.org", "fltk"); + Fl_Preferences opt_prefs(prefs, "options"); + if (opt[Fl::OPTION_ARROW_FOCUS][1]==2) opt_prefs.deleteEntry("ArrowFocus"); + else opt_prefs.set("ArrowFocus", opt[Fl::OPTION_ARROW_FOCUS][1]); + if (opt[Fl::OPTION_VISIBLE_FOCUS][1]==2) opt_prefs.deleteEntry("VisibleFocus"); + else opt_prefs.set("VisibleFocus", opt[Fl::OPTION_VISIBLE_FOCUS][1]); + if (opt[Fl::OPTION_DND_TEXT][1]==2) opt_prefs.deleteEntry("DNDText"); + else opt_prefs.set("DNDText", opt[Fl::OPTION_DND_TEXT][1]); + if (opt[Fl::OPTION_SHOW_TOOLTIPS][1]==2) opt_prefs.deleteEntry("ShowTooltips"); + else opt_prefs.set("ShowTooltips", opt[Fl::OPTION_SHOW_TOOLTIPS][1]); +} +{ + Fl_Preferences prefs(Fl_Preferences::USER, "fltk.org", "fltk"); + Fl_Preferences opt_prefs(prefs, "options"); + if (opt[Fl::OPTION_ARROW_FOCUS][0]==2) opt_prefs.deleteEntry("ArrowFocus"); + else opt_prefs.set("ArrowFocus", opt[Fl::OPTION_ARROW_FOCUS][0]); + if (opt[Fl::OPTION_VISIBLE_FOCUS][0]==2) opt_prefs.deleteEntry("VisibleFocus"); + else opt_prefs.set("VisibleFocus", opt[Fl::OPTION_VISIBLE_FOCUS][0]); + if (opt[Fl::OPTION_DND_TEXT][0]==2) opt_prefs.deleteEntry("DNDText"); + else opt_prefs.set("DNDText", opt[Fl::OPTION_DND_TEXT][0]); + if (opt[Fl::OPTION_SHOW_TOOLTIPS][0]==2) opt_prefs.deleteEntry("ShowTooltips"); + else opt_prefs.set("ShowTooltips", opt[Fl::OPTION_SHOW_TOOLTIPS][0]); +}} {} } -Function {} {open return_type int +Function {} { + comment {create the user interface and launch} selected return_type int } { Fl_Window myWindow { - label {My Preferences} - callback closeWindowCB open - xywh {394 64 298 311} type Double visible + label {FLTK Preferences} + callback {Fl::delete_widget(myWindow);} open + xywh {424 200 403 317} type Double color 50 visible } { - Fl_Button {} { - label Cancel - callback closeWindowCB - xywh {210 275 75 25} - } - Fl_Button {} { - label OK - callback saveAndCloseWindowCB - xywh {125 275 75 25} - } Fl_Group {} { - label {Get Up:} open - xywh {20 30 115 225} box ENGRAVED_FRAME align 5 + label {Keyboard Focus Options} open + xywh {10 10 380 100} box GTK_DOWN_BOX labelfont 2 align 21 } { - Fl_Input wAlarm { - label {Alarm at:} - xywh {25 55 45 20} align 5 - } - Fl_Choice wAmPm {open - xywh {75 55 55 20} down_box BORDER_BOX + Fl_Choice wVisibleFocus { + label {Visible Keyboard Focus:} + callback {int mode = wUserOrSystem->value(); +opt[Fl::OPTION_VISIBLE_FOCUS][mode] = wVisibleFocus->value();} open + tooltip {OPTION_VISIBLE_FOCUS + +If visible focus is switched on, FLTK will draw a dotted rectangle inside the widget that will receive the next keystroke. If switched off, no such indicator will be drawn and keyboard navigation is disabled. + +On by default.} xywh {245 40 100 25} down_box BORDER_BOX } { MenuItem {} { - label {a.m.} - xywh {0 0 100 20} + label off + user_data 0 user_data_type long + xywh {10 10 31 20} } MenuItem {} { - label {p.m.} - xywh {0 0 100 20} + label on + user_data 1 user_data_type long + xywh {10 10 31 20} divider } - } - Fl_Choice wWear { - label {Wear:} open - xywh {25 100 105 20} down_box BORDER_BOX align 5 - } { MenuItem {} { - label shoes - xywh {0 0 100 20} + label default + user_data 2 user_data_type long + xywh {10 10 31 20} } + } + Fl_Choice wArrowFocus { + label {Arrow Keys move Focus:} + callback {int mode = wUserOrSystem->value(); +opt[Fl::OPTION_ARROW_FOCUS][mode] = wArrowFocus->value();} open + tooltip {OPTION_ARROW_FOCUS + +When switched on, moving the text cursor beyond the start or end of a text in a text widget will change focus to the next text widgt. When switched off, the cursor will stop at the end of the text. Pressing Tab or Ctrl-Tab will advance the keyboard focus. + +Default is off.} xywh {245 75 100 25} down_box BORDER_BOX + } { MenuItem {} { - label sandals - xywh {0 0 100 20} + label off + user_data 0 user_data_type long + xywh {0 0 31 20} } MenuItem {} { - label {flip flops} - xywh {0 0 100 20} + label on + user_data 1 user_data_type long + xywh {0 0 31 20} divider } MenuItem {} { - label {bare foot} - xywh {0 0 100 20} + label default + user_data 2 user_data_type long + xywh {0 0 31 20} } } - Fl_Group {} {open - xywh {35 120 98 60} - } { - Fl_Round_Button wLeft { - label {left side} - xywh {35 120 95 25} type Radio down_box ROUND_DOWN_BOX - } - Fl_Round_Button wRight { - label {right side} - xywh {35 140 95 25} type Radio down_box ROUND_DOWN_BOX - } - Fl_Box {} { - label {of the bed} - xywh {38 160 95 20} - } - } - Fl_Check_Button wShower { - label shower - xywh {25 180 105 25} down_box DOWN_BOX - } - Fl_Check_Button wShave { - label shave - xywh {25 200 105 25} down_box DOWN_BOX - } - Fl_Check_Button wBrush { - label {brush teeth} - xywh {25 220 105 25} down_box DOWN_BOX - } } Fl_Group {} { - label {Breakfast::} open - xywh {160 30 115 225} box ENGRAVED_FRAME align 5 + label {Tooltip Options} open + xywh {10 120 380 65} box GTK_DOWN_BOX labelfont 2 align 21 } { - Fl_Choice wDrink { - label {Drink:} open - xywh {165 50 105 20} down_box BORDER_BOX align 5 + Fl_Choice wShowTooltips { + label {Show Tooltips:} + callback {int mode = wUserOrSystem->value(); +opt[Fl::OPTION_SHOW_TOOLTIPS][mode] = wShowTooltips->value();} open + tooltip {OPTION_SHOW_TOOLTIPS + +If tooltips are enabled, hovering the mouse over a widget with a tooltip text will open a little tootip window until the mouse leaves the widget. If disabled, no tooltip is shown. + +Default is on.} xywh {245 150 100 25} down_box BORDER_BOX } { MenuItem {} { - label coffee - xywh {10 10 100 20} + label off + user_data 0 user_data_type long + xywh {10 10 31 20} } MenuItem {} { - label tea - xywh {10 10 100 20} + label on + user_data 1 user_data_type long + xywh {10 10 31 20} divider } MenuItem {} { - label juice - xywh {10 10 100 20} + label default + user_data 2 user_data_type long + xywh {10 10 31 20} } } - Fl_Check_Button wMilk { - label {with milk} - xywh {170 70 100 25} down_box DOWN_BOX - } - Fl_Choice wBread { - label {Bread:} open - xywh {165 110 105 20} down_box BORDER_BOX align 5 + } + Fl_Group {} { + label {Drag And Drop Options} open + xywh {10 194 380 66} box GTK_DOWN_BOX labelfont 2 align 21 + } { + Fl_Choice wDNDText { + label {Allow dragging Text:} + callback {int mode = wUserOrSystem->value(); +opt[Fl::OPTION_DND_TEXT][mode] = wDNDText->value();} open + tooltip {OPTION_DND_TEXT + +If text drag-and-drop is enabled, the user can select and drag text from any text widget. If disabled, no dragging is possible, however dropping text from other applications still works. + +Default is on.} xywh {245 225 100 25} down_box BORDER_BOX } { MenuItem {} { - label wheat - xywh {0 0 100 20} + label off + user_data 0 user_data_type long + xywh {30 30 31 20} } MenuItem {} { - label white - xywh {0 0 100 20} + label on + user_data 1 user_data_type long + xywh {30 30 31 20} divider } MenuItem {} { - label rye - xywh {0 0 100 20} + label default + user_data 2 user_data_type long + xywh {30 30 31 20} } - MenuItem {} { - label {sour doh} - xywh {0 0 100 20} - } - } - Fl_Check_Button wButter { - label {with butter} - xywh {170 130 100 25} down_box DOWN_BOX - } - Fl_Input wEggs { - label eggs - xywh {165 163 30 20} type Int align 8 } - Fl_Value_Slider wMinutes { - label {min.} - xywh {175 185 70 20} type Horizontal align 8 minimum 2 maximum 6 value 3.1 + } + Fl_Choice wUserOrSystem { + callback {refreshUI();} open + tooltip {Change settings for the current user, or for all users of this computer.} xywh {14 275 141 25} down_box BORDER_BOX + } { + MenuItem {} { + label {User Settings} + user_data 0 user_data_type long + xywh {0 0 31 20} } - Fl_Input wPaper { - label {Newspaper:} - xywh {165 225 105 20} align 5 + MenuItem {} { + label {System Settings} + user_data 1 user_data_type long + xywh {0 0 31 20} } } + Fl_Button {} { + label Cancel + callback {Fl::delete_widget(myWindow);} + xywh {230 275 75 25} + } + Fl_Button {} { + label OK + callback {writePrefs(); +Fl::delete_widget(myWindow);} + xywh {315 275 75 25} + } } code {readPrefs();} {} } - -Function {readPrefs()} {open return_type void -} { - code {int boolValue; -int intValue; -char buffer[80]; -double doubleValue; - -Fl_Preferences app( Fl_Preferences::USER, "fltk.org", "test/preferences" ); - - char path[ FL_PATH_MAX ]; - app.getUserdataPath( path, sizeof(path) ); - - Fl_Preferences bed( app, "Bed" ); - bed.get( "alarm", buffer, "8:00", 79 ); - wAlarm->value( buffer ); - - bed.get( "ampm", intValue, 0 ); - wAmPm->value( intValue ); - - bed.get( "wear", intValue, 1 ); - wWear->value( intValue ); - - int side; - bed.get( "side", side, 2 ); - if ( side == 1 ) wLeft->value( 1 ); - if ( side == 2 ) wRight->value( 1 ); - - int tasks; - bed.get( "taskFlags", tasks, 0x05 ); - if ( tasks & 0x01 ) wShower->value( 1 ); - if ( tasks & 0x02 ) wShave->value( 1 ); - if ( tasks & 0x04 ) wBrush->value( 1 ); - - Fl_Preferences eat( app, "Breakfast" ); - - eat.get( "drink", intValue, 1 ); - wDrink->value( intValue ); - - eat.get( "wMilk", boolValue, 0 ); - wMilk->value( boolValue ); - - eat.get( "bread", intValue, 0 ); - wBread->value( intValue ); - - eat.get( "wButter", boolValue, 1 ); - wButter->value( boolValue ); - - eat.get( "nEggs", intValue, 2 ); - sprintf( buffer, "%d", intValue ); - wEggs->value( buffer ); - - eat.get( "minutes", doubleValue, 3.2 ); - wMinutes->value( doubleValue ); - - char *flexBuffer; - eat.get( "newspaper", flexBuffer, "NY Tymes" ); - wPaper->value( flexBuffer ); - if ( flexBuffer ) free( flexBuffer ); - - eat.get( "foo", buffer, "bar", 80 ); - - /** sample code only: - Fl_Preferences prev( app, "PreviousStarts" ); - { - int i, n; - prev.get( "n", n, 0 ); - for ( i=0; i<n; i++ ) - prev.get( Fl_Preferences::Name( i ), flexBuffer, "" ); - } - - unsigned int hex; - eat.get( "binFoo", (void*)&hex, 0, 0, sizeof( unsigned int ) ); - void *data; - eat.get( "binFoo2", data, 0, 0 ); - **/} {} -} - -Function {writePrefs()} {open return_type void -} { - code {Fl_Preferences app( Fl_Preferences::USER, "fltk.org", "test/preferences" ); - - Fl_Preferences bed( app, "Bed" ); - - bed.set( "alarm", wAlarm->value() ); - bed.set( "ampm", wAmPm->value() ); - - bed.set( "wear", wWear->value() ); - - int side = 0; - if ( wLeft->value() ) side = 1; - if ( wRight->value() ) side = 2; - bed.set( "side", side ); - - int tasks = 0; - if ( wShower->value() ) tasks |= 0x01; - if ( wShave->value() ) tasks |= 0x02; - if ( wBrush->value() ) tasks |= 0x04; - bed.set( "taskFlags", tasks ); - - Fl_Preferences eat( app, "Breakfast" ); - - eat.set( "drink", wDrink->value() ); - eat.set( "wMilk", wMilk->value() ); - eat.set( "bread", wBread->value() ); - eat.set( "wButter", wButter->value() ); - - eat.set( "nEggs", wEggs->value() ); - eat.set( "minutes", wMinutes->value() ); - - eat.set( "newspaper", wPaper->value() ); - - eat.set( "foo", "bar\\nfly\\rBackslash: \\\\ and bell: \\007 and delete: \\177\\n" ); - - eat.set( Fl_Preferences::Name( 3 ), "Test3" ); - - /* sample: create a sub-sub-group */ - Fl_Preferences eatMore( eat, "More" ); - - eatMore.set( "more", "stuff" ); - - /* all the following searches should return 1 */ - int sum = 0; - sum += app.groupExists( "Breakfast" ); /* find 'eat' relative to 'app' */ - sum += app.groupExists( "Breakfast/More" ); /* find 'eat.eatMore' relative to 'app' */ - sum += app.groupExists( "./Breakfast/More" ); /* find 'eat.eatMore' relative to Preferences */ - sum += eat.groupExists( "More" ); /* find 'eatMore' relative to 'eat' */ - sum += eat.groupExists( "./Breakfast/More" ); /* find 'eat.eatMore' relative to Preferences */ - sum += eat.groupExists( "." ); /* find myself ('eat') */ - sum += eat.groupExists( "./" ); /* find the topmost group ('app') */ - if ( sum != 7 ) - fl_message( "Assertion failed:\\nNot all group entries were found!" ); - - /* sample code only: */ - unsigned int hex = 0x2387efcd; - eat.set( "binFoo", (void*)&hex, sizeof( unsigned int ) ); - eat.set( "binFoo2", (void*)&writePrefs, 256 );} {selected - } -} |
