summaryrefslogtreecommitdiff
path: root/fluid/alignment_panel.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2010-12-20 22:19:24 +0000
committerMatthias Melcher <fltk@matthiasm.com>2010-12-20 22:19:24 +0000
commita8e883155958ae8a7ea9087682da42411d46d3d9 (patch)
tree0d1d3b7e19056a6b1e75e12ff5d8d57674b506cf /fluid/alignment_panel.cxx
parent3b65b1b3bfc5c49bf5d843f30bfd60df03c71ddb (diff)
Moved global FLTK options into Fluid until we find a better setup. Restored the original Preferences demo.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8089 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'fluid/alignment_panel.cxx')
-rw-r--r--fluid/alignment_panel.cxx243
1 files changed, 243 insertions, 0 deletions
diff --git a/fluid/alignment_panel.cxx b/fluid/alignment_panel.cxx
index 913e0ffdb..17fc005b7 100644
--- a/fluid/alignment_panel.cxx
+++ b/fluid/alignment_panel.cxx
@@ -28,6 +28,8 @@
// generated by Fast Light User Interface Designer (fluid) version 1.0300
#include "alignment_panel.h"
+#include <FL/Fl_Preferences.H>
+#include <FL/fl_ask.H>
Fl_Text_Buffer *shell_run_buffer;
Fl_Double_Window *project_window=(Fl_Double_Window *)0;
@@ -497,6 +499,247 @@ Fl_Double_Window* make_layout_window() {
} // Fl_Double_Window* grid_window
return grid_window;
}
+/**
+ Copy of all options in user and system mode
+*/
+static int opt[10][2];
+
+/**
+ Update the UI using the values in the opt array
+*/
+static void refreshUI() {
+ 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]);
+}
+
+/**
+ read all preferences and refresh the GUI
+*/
+static void readPrefs() {
+ // 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();
+}
+
+/**
+ write all preferences using the array
+*/
+static void writePrefs() {
+ // 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]);
+ }
+}
+
+void show_global_settings_window() {
+ if (!global_settings_window)
+ make_global_settings_window();
+ readPrefs();
+ refreshUI();
+ fl_message(
+ "WARNING!\n\n"
+ "The following dialog changes the user interface behavior\n"
+ "of ALL FLTK applications, for the current user, or for \n"
+ "ALL users on this machine.\n\n"
+ "Please choose these settings carefully, or reset\n"
+ "user and system settings to \"default\".");
+ global_settings_window->show();
+}
+
+Fl_Double_Window *global_settings_window=(Fl_Double_Window *)0;
+
+Fl_Choice *wVisibleFocus=(Fl_Choice *)0;
+
+static void cb_wVisibleFocus(Fl_Choice*, void*) {
+ int mode = wUserOrSystem->value();
+opt[Fl::OPTION_VISIBLE_FOCUS][mode] = wVisibleFocus->value();
+}
+
+Fl_Menu_Item menu_wVisibleFocus[] = {
+ {"off", 0, 0, (void*)(0), 0, FL_NORMAL_LABEL, 0, 14, 0},
+ {"on", 0, 0, (void*)(1), 128, FL_NORMAL_LABEL, 0, 14, 0},
+ {"default", 0, 0, (void*)(2), 0, FL_NORMAL_LABEL, 0, 14, 0},
+ {0,0,0,0,0,0,0,0,0}
+};
+
+Fl_Choice *wArrowFocus=(Fl_Choice *)0;
+
+static void cb_wArrowFocus(Fl_Choice*, void*) {
+ int mode = wUserOrSystem->value();
+opt[Fl::OPTION_ARROW_FOCUS][mode] = wArrowFocus->value();
+}
+
+Fl_Menu_Item menu_wArrowFocus[] = {
+ {"off", 0, 0, (void*)(0), 0, FL_NORMAL_LABEL, 0, 14, 0},
+ {"on", 0, 0, (void*)(1), 128, FL_NORMAL_LABEL, 0, 14, 0},
+ {"default", 0, 0, (void*)(2), 0, FL_NORMAL_LABEL, 0, 14, 0},
+ {0,0,0,0,0,0,0,0,0}
+};
+
+Fl_Choice *wShowTooltips=(Fl_Choice *)0;
+
+static void cb_wShowTooltips(Fl_Choice*, void*) {
+ int mode = wUserOrSystem->value();
+opt[Fl::OPTION_SHOW_TOOLTIPS][mode] = wShowTooltips->value();
+}
+
+Fl_Menu_Item menu_wShowTooltips[] = {
+ {"off", 0, 0, (void*)(0), 0, FL_NORMAL_LABEL, 0, 14, 0},
+ {"on", 0, 0, (void*)(1), 128, FL_NORMAL_LABEL, 0, 14, 0},
+ {"default", 0, 0, (void*)(2), 0, FL_NORMAL_LABEL, 0, 14, 0},
+ {0,0,0,0,0,0,0,0,0}
+};
+
+Fl_Choice *wDNDText=(Fl_Choice *)0;
+
+static void cb_wDNDText(Fl_Choice*, void*) {
+ int mode = wUserOrSystem->value();
+opt[Fl::OPTION_DND_TEXT][mode] = wDNDText->value();
+}
+
+Fl_Menu_Item menu_wDNDText[] = {
+ {"off", 0, 0, (void*)(0), 0, FL_NORMAL_LABEL, 0, 14, 0},
+ {"on", 0, 0, (void*)(1), 128, FL_NORMAL_LABEL, 0, 14, 0},
+ {"default", 0, 0, (void*)(2), 0, FL_NORMAL_LABEL, 0, 14, 0},
+ {0,0,0,0,0,0,0,0,0}
+};
+
+Fl_Choice *wUserOrSystem=(Fl_Choice *)0;
+
+static void cb_wUserOrSystem(Fl_Choice*, void*) {
+ refreshUI();
+}
+
+Fl_Menu_Item menu_wUserOrSystem[] = {
+ {"User Settings", 0, 0, (void*)(0), 0, FL_NORMAL_LABEL, 0, 14, 0},
+ {"System Settings", 0, 0, (void*)(1), 0, FL_NORMAL_LABEL, 0, 14, 0},
+ {0,0,0,0,0,0,0,0,0}
+};
+
+static void cb_Cancel1(Fl_Button*, void*) {
+ global_settings_window->hide();
+}
+
+static void cb_OK(Fl_Button*, void*) {
+ writePrefs();
+global_settings_window->hide();
+}
+
+Fl_Double_Window* make_global_settings_window() {
+ { global_settings_window = new Fl_Double_Window(403, 317, "FLTK Preferences");
+ global_settings_window->color(FL_LIGHT1);
+ { Fl_Group* o = new Fl_Group(10, 10, 380, 100, "Keyboard Focus Options");
+ o->box(FL_GTK_DOWN_BOX);
+ o->labelfont(2);
+ o->align(Fl_Align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE));
+ { wVisibleFocus = new Fl_Choice(245, 40, 100, 25, "Visible Keyboard Focus:");
+ wVisibleFocus->tooltip("OPTION_VISIBLE_FOCUS\n\nIf visible focus is switched on, FLTK will draw a dot\
+ted rectangle inside the widget that will receive the next keystroke. If switc\
+hed off, no such indicator will be drawn and keyboard navigation is disabled.\
+\n\nDefault is on.");
+ wVisibleFocus->down_box(FL_BORDER_BOX);
+ wVisibleFocus->callback((Fl_Callback*)cb_wVisibleFocus);
+ wVisibleFocus->menu(menu_wVisibleFocus);
+ } // Fl_Choice* wVisibleFocus
+ { wArrowFocus = new Fl_Choice(245, 75, 100, 25, "Arrow Keys move Focus:");
+ wArrowFocus->tooltip("OPTION_ARROW_FOCUS\n\nWhen switched on, moving the text cursor beyond the sta\
+rt or end of the text in a text widget will change focus to the next widget. W\
+hen switched off, the cursor will stop at the end of the text. Pressing Tab or\
+ Ctrl-Tab will advance the keyboard focus. Switch this on, if you want the old\
+ behavior of FLTK 1.1.\n\nDefault is off.");
+ wArrowFocus->down_box(FL_BORDER_BOX);
+ wArrowFocus->callback((Fl_Callback*)cb_wArrowFocus);
+ wArrowFocus->menu(menu_wArrowFocus);
+ } // Fl_Choice* wArrowFocus
+ o->end();
+ } // Fl_Group* o
+ { Fl_Group* o = new Fl_Group(10, 120, 380, 65, "Tooltip Options");
+ o->box(FL_GTK_DOWN_BOX);
+ o->labelfont(2);
+ o->align(Fl_Align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE));
+ { wShowTooltips = new Fl_Choice(245, 150, 100, 25, "Show Tooltips:");
+ wShowTooltips->tooltip("OPTION_SHOW_TOOLTIPS\n\nIf tooltips are enabled, hovering the mouse over a wi\
+dget with a tooltip text will open a little tooltip window until the mouse lea\
+ves the widget. If disabled, no tooltip is shown.\n\nDefault is on.");
+ wShowTooltips->down_box(FL_BORDER_BOX);
+ wShowTooltips->callback((Fl_Callback*)cb_wShowTooltips);
+ wShowTooltips->menu(menu_wShowTooltips);
+ } // Fl_Choice* wShowTooltips
+ o->end();
+ } // Fl_Group* o
+ { Fl_Group* o = new Fl_Group(10, 194, 380, 66, "Drag And Drop Options");
+ o->box(FL_GTK_DOWN_BOX);
+ o->labelfont(2);
+ o->align(Fl_Align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE));
+ { wDNDText = new Fl_Choice(245, 225, 100, 25, "Allow dragging Text:");
+ wDNDText->tooltip("OPTION_DND_TEXT\n\nIf 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.\n\nDefault is on.");
+ wDNDText->down_box(FL_BORDER_BOX);
+ wDNDText->callback((Fl_Callback*)cb_wDNDText);
+ wDNDText->menu(menu_wDNDText);
+ } // Fl_Choice* wDNDText
+ o->end();
+ } // Fl_Group* o
+ { wUserOrSystem = new Fl_Choice(14, 275, 141, 25);
+ wUserOrSystem->tooltip("Change settings for the current user, or default values for all users of this\
+ computer. Individual users can override system options, if they set their opt\
+ions to specific values (not \'default\').");
+ wUserOrSystem->down_box(FL_BORDER_BOX);
+ wUserOrSystem->callback((Fl_Callback*)cb_wUserOrSystem);
+ wUserOrSystem->menu(menu_wUserOrSystem);
+ } // Fl_Choice* wUserOrSystem
+ { Fl_Button* o = new Fl_Button(230, 275, 75, 25, "Cancel");
+ o->callback((Fl_Callback*)cb_Cancel1);
+ } // Fl_Button* o
+ { Fl_Button* o = new Fl_Button(315, 275, 75, 25, "OK");
+ o->callback((Fl_Callback*)cb_OK);
+ } // Fl_Button* o
+ global_settings_window->end();
+ } // Fl_Double_Window* global_settings_window
+ readPrefs();
+ Fl::option(Fl::OPTION_SHOW_TOOLTIPS,1); // make sure tooltips are on !
+ return global_settings_window;
+}
//
// End of "$Id$".