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
This commit is contained in:
Matthias Melcher 2010-12-20 22:19:24 +00:00
parent 3b65b1b3bf
commit a8e8831559
6 changed files with 803 additions and 212 deletions

View File

@ -245,6 +245,11 @@ void show_settings_cb(Fl_Widget *, void *) {
settings_window->show();
}
void show_global_settings_cb(Fl_Widget *, void *) {
global_settings_window->hotspot(global_settings_window);
show_global_settings_window();
}
void header_input_cb(Fl_Input* i, void*) {
if (header_file_name && strcmp(header_file_name, i->value()))
set_modflag(1);

View File

@ -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$".

View File

@ -40,6 +40,12 @@ decl {\#include <FL/Fl_Text_Display.H>} {public local
decl {\#include <FL/filename.H>} {public local
}
decl {\#include <FL/Fl_Preferences.H>} {private global
}
decl {\#include <FL/fl_ask.H>} {private global
}
decl {extern void load_history();} {public local
}
@ -61,8 +67,7 @@ decl {extern Fl_Preferences fluid_prefs;} {public local
decl {Fl_Text_Buffer *shell_run_buffer;} {public local
}
Function {make_project_window()} {open
} {
Function {make_project_window()} {} {
Fl_Window project_window {
label {Project Settings} open
xywh {393 460 399 252} type Double
@ -142,7 +147,7 @@ Function {make_project_window()} {open
}
Fl_Input i18n_set_input {
label {Set:}
callback i18n_int_cb selected
callback i18n_int_cb
tooltip {The message set number.} xywh {100 128 272 20} type Int box THIN_DOWN_BOX labelfont 1 textfont 4
}
Fl_Input i18n_function_input {
@ -326,8 +331,7 @@ Function {make_shell_window()} {} {
}
}
Function {make_layout_window()} {open
} {
Function {make_layout_window()} {} {
Fl_Window grid_window {
label {Layout Settings} open
xywh {760 427 285 245} type Double non_modal visible
@ -433,6 +437,245 @@ Function {make_layout_window()} {open
}
}
decl {int opt[10][2];} {
comment {Copy of all options in user and system mode} private local
}
Function {refreshUI()} {
comment {Update the UI using the values in the opt array} private 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 {readPrefs()} {
comment {read all preferences and refresh the GUI} private return_type void
} {
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 {writePrefs()} {
comment {write all preferences using the array} private return_type void
} {
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 {show_global_settings_window()} {open return_type void
} {
code {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();} {selected
}
}
Function {make_global_settings_window()} {} {
Fl_Window global_settings_window {
label {FLTK Preferences} open
xywh {444 220 403 317} type Double color 50 visible
} {
Fl_Group {} {
label {Keyboard Focus Options} open
xywh {10 10 380 100} box GTK_DOWN_BOX labelfont 2 align 21
} {
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.
Default is on.} xywh {245 40 100 25} down_box BORDER_BOX
} {
MenuItem {} {
label off
user_data 0 user_data_type long
xywh {10 10 31 20}
}
MenuItem {} {
label on
user_data 1 user_data_type long
xywh {10 10 31 20} divider
}
MenuItem {} {
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 the text in a text widget will change focus to the next widget. When 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.
Default is off.} xywh {245 75 100 25} down_box BORDER_BOX
} {
MenuItem {} {
label off
user_data 0 user_data_type long
xywh {0 0 31 20}
}
MenuItem {} {
label on
user_data 1 user_data_type long
xywh {0 0 31 20} divider
}
MenuItem {} {
label default
user_data 2 user_data_type long
xywh {0 0 31 20}
}
}
}
Fl_Group {} {
label {Tooltip Options} open
xywh {10 120 380 65} box GTK_DOWN_BOX labelfont 2 align 21
} {
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 tooltip 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 off
user_data 0 user_data_type long
xywh {10 10 31 20}
}
MenuItem {} {
label on
user_data 1 user_data_type long
xywh {10 10 31 20} divider
}
MenuItem {} {
label default
user_data 2 user_data_type long
xywh {10 10 31 20}
}
}
}
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 off
user_data 0 user_data_type long
xywh {30 30 31 20}
}
MenuItem {} {
label on
user_data 1 user_data_type long
xywh {30 30 31 20} divider
}
MenuItem {} {
label default
user_data 2 user_data_type long
xywh {30 30 31 20}
}
}
}
Fl_Choice wUserOrSystem {
callback {refreshUI();} open
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 options to specific values (not 'default').} 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}
}
MenuItem {} {
label {System Settings}
user_data 1 user_data_type long
xywh {0 0 31 20}
}
}
Fl_Button {} {
label Cancel
callback {global_settings_window->hide();}
xywh {230 275 75 25}
}
Fl_Button {} {
label OK
callback {writePrefs();
global_settings_window->hide();}
xywh {315 275 75 25}
}
}
code {readPrefs();
Fl::option(Fl::OPTION_SHOW_TOOLTIPS,1); // make sure tooltips are on !} {}
}
comment {
//
// End of "$Id$".

View File

@ -107,6 +107,19 @@ extern Fl_Check_Button *guides_toggle;
extern void default_widget_size_cb(Fl_Round_Button*, long);
extern Fl_Round_Button *def_widget_size[6];
Fl_Double_Window* make_layout_window();
void show_global_settings_window();
extern Fl_Double_Window *global_settings_window;
extern Fl_Choice *wVisibleFocus;
extern Fl_Choice *wArrowFocus;
extern Fl_Choice *wShowTooltips;
extern Fl_Choice *wDNDText;
extern Fl_Choice *wUserOrSystem;
Fl_Double_Window* make_global_settings_window();
extern Fl_Menu_Item menu_wVisibleFocus[];
extern Fl_Menu_Item menu_wArrowFocus[];
extern Fl_Menu_Item menu_wShowTooltips[];
extern Fl_Menu_Item menu_wDNDText[];
extern Fl_Menu_Item menu_wUserOrSystem[];
#endif
//

View File

@ -835,6 +835,7 @@ static void sort_cb(Fl_Widget *,void *) {
void show_project_cb(Fl_Widget *, void *);
void show_grid_cb(Fl_Widget *, void *);
void show_settings_cb(Fl_Widget *, void *);
void show_global_settings_cb(Fl_Widget *, void *);
void align_widget_cb(Fl_Widget *, long);
void widget_size_cb(Fl_Widget *, long);
@ -1630,7 +1631,8 @@ Fl_Menu_Item Main_Menu[] = {
{"Show Widget &Bin...",FL_ALT+'b',toggle_widgetbin_cb},
{"Show Source Code...",FL_ALT+FL_SHIFT+'s', (Fl_Callback*)toggle_sourceview_cb, 0, FL_MENU_DIVIDER},
{"Pro&ject Settings...",FL_ALT+'p',show_project_cb},
{"GU&I Settings...",FL_ALT+FL_SHIFT+'p',show_settings_cb},
{"GU&I Settings...",FL_ALT+FL_SHIFT+'p',show_settings_cb,0,FL_MENU_DIVIDER},
{"Global &FLTK Settings...",FL_ALT+FL_SHIFT+'g',show_global_settings_cb},
{0},
{"&New", 0, 0, (void *)New_Menu, FL_SUBMENU_POINTER},
{"&Layout",0,0,0,FL_SUBMENU},
@ -1788,6 +1790,7 @@ void make_main_window() {
if (!compile_only) {
load_history();
make_settings_window();
make_global_settings_window();
}
}

View File

@ -17,228 +17,312 @@ decl {\#include <FL/filename.H>} {private local
decl {\#include <FL/fl_ask.H>} {private local
}
decl {int opt[10][2];} {
comment {Copy of all options in user and system mode} private local
decl {void readPrefs();} {public local
}
Function {refreshUI()} {
comment {Update the UI using the values in the opt array} return_type void
decl {void writePrefs();} {public local
}
Function {closeWindowCB( Fl_Widget*, void* )} {open private 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]);} {}
code {Fl::delete_widget(myWindow);} {}
}
Function {readPrefs()} {
comment {read all preferences and refresh the GUI} return_type void
Function {saveAndCloseWindowCB( Fl_Widget*, void* )} {open private return_type void
} {
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();} {}
code {writePrefs();
Fl::delete_widget(myWindow);} {}
}
Function {writePrefs()} {
comment {write all preferences using the array} return_type void
} {
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 {} {
comment {create the user interface and launch} selected return_type int
Function {} {open return_type int
} {
Fl_Window myWindow {
label {FLTK Preferences}
callback {Fl::delete_widget(myWindow);} open
xywh {424 200 403 317} type Double color 50 visible
label {My Preferences}
callback closeWindowCB open
xywh {394 64 298 311} type Double visible
} {
Fl_Group {} {
label {Keyboard Focus Options} open
xywh {10 10 380 100} box GTK_DOWN_BOX labelfont 2 align 21
} {
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.
Default is on.} xywh {245 40 100 25} down_box BORDER_BOX
} {
MenuItem {} {
label off
user_data 0 user_data_type long
xywh {10 10 31 20}
}
MenuItem {} {
label on
user_data 1 user_data_type long
xywh {10 10 31 20} divider
}
MenuItem {} {
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 the text in a text widget will change focus to the next widget. When 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.
Default is off.} xywh {245 75 100 25} down_box BORDER_BOX
} {
MenuItem {} {
label off
user_data 0 user_data_type long
xywh {0 0 31 20}
}
MenuItem {} {
label on
user_data 1 user_data_type long
xywh {0 0 31 20} divider
}
MenuItem {} {
label default
user_data 2 user_data_type long
xywh {0 0 31 20}
}
}
}
Fl_Group {} {
label {Tooltip Options} open
xywh {10 120 380 65} box GTK_DOWN_BOX labelfont 2 align 21
} {
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 tooltip 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 off
user_data 0 user_data_type long
xywh {10 10 31 20}
}
MenuItem {} {
label on
user_data 1 user_data_type long
xywh {10 10 31 20} divider
}
MenuItem {} {
label default
user_data 2 user_data_type long
xywh {10 10 31 20}
}
}
}
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 off
user_data 0 user_data_type long
xywh {30 30 31 20}
}
MenuItem {} {
label on
user_data 1 user_data_type long
xywh {30 30 31 20} divider
}
MenuItem {} {
label default
user_data 2 user_data_type long
xywh {30 30 31 20}
}
}
}
Fl_Choice wUserOrSystem {
callback {refreshUI();} open
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 options to specific values (not 'default'). } 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}
}
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}
callback closeWindowCB
xywh {210 275 75 25}
}
Fl_Button {} {
label OK
callback {writePrefs();
Fl::delete_widget(myWindow);}
xywh {315 275 75 25}
callback saveAndCloseWindowCB
xywh {125 275 75 25}
}
Fl_Group {} {
label {Get Up:} open
xywh {20 30 115 225} box ENGRAVED_FRAME align 5
} {
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
} {
MenuItem {} {
label {a.m.}
xywh {0 0 100 20}
}
MenuItem {} {
label {p.m.}
xywh {0 0 100 20}
}
}
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}
}
MenuItem {} {
label sandals
xywh {0 0 100 20}
}
MenuItem {} {
label {flip flops}
xywh {0 0 100 20}
}
MenuItem {} {
label {bare foot}
xywh {0 0 100 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
} {
Fl_Choice wDrink {
label {Drink:} open
xywh {165 50 105 20} down_box BORDER_BOX align 5
} {
MenuItem {} {
label coffee
xywh {10 10 100 20}
}
MenuItem {} {
label tea
xywh {10 10 100 20}
}
MenuItem {} {
label juice
xywh {10 10 100 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
} {
MenuItem {} {
label wheat
xywh {0 0 100 20}
}
MenuItem {} {
label white
xywh {0 0 100 20}
}
MenuItem {} {
label rye
xywh {0 0 100 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_Input wPaper {
label {Newspaper:}
xywh {165 225 105 20} align 5
}
}
}
code {readPrefs();
Fl::option(Fl::OPTION_SHOW_TOOLTIPS,1); // make sure tooltips are on !
} {}
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
}
}