summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES2
-rw-r--r--FL/Fl_Preferences.H8
-rw-r--r--fluid/Fl_Window_Type.cxx42
-rw-r--r--fluid/alignment_panel.cxx148
-rw-r--r--fluid/alignment_panel.fl117
-rw-r--r--fluid/alignment_panel.h18
-rw-r--r--fluid/file.cxx23
-rw-r--r--fluid/fluid.cxx154
-rw-r--r--src/Fl_Preferences.cxx14
-rw-r--r--test/preferences.cxx2
10 files changed, 383 insertions, 145 deletions
diff --git a/CHANGES b/CHANGES
index a7d046216..b67cf329d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,7 @@
CHANGES IN FLTK 1.1.0rc1
+ - FLUID now keeps track of grid, tooltip, and other
+ GUI options, along with the last 10 files opened.
- Tooltip windows would show up in the task bar under
WIN32.
- Now append trailing slash to directory names in names
diff --git a/FL/Fl_Preferences.H b/FL/Fl_Preferences.H
index c2ae5045b..8f2dfdfaf 100644
--- a/FL/Fl_Preferences.H
+++ b/FL/Fl_Preferences.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Preferences.H,v 1.1.2.3 2002/04/29 20:57:29 easysw Exp $"
+// "$Id: Fl_Preferences.H,v 1.1.2.4 2002/04/30 18:11:49 easysw Exp $"
//
// Preferences definitions for the Fast Light Tool Kit (FLTK).
//
@@ -81,7 +81,7 @@ public:
// FL_EXPORT char get( const char *entry, void *value, const char *defaultValue, int maxSize );
FL_EXPORT int size( const char *entry );
- FL_EXPORT char getUserdataPath( char *path );
+ FL_EXPORT char getUserdataPath( char *path, int pathlen );
FL_EXPORT void flush();
@@ -141,7 +141,7 @@ private:
~RootNode();
int read();
int write();
- char getPath( char *path );
+ char getPath( char *path, int pathlen );
};
friend class RootNode;
@@ -154,5 +154,5 @@ private:
#endif // !Fl_Preferences_H
//
-// End of "$Id: Fl_Preferences.H,v 1.1.2.3 2002/04/29 20:57:29 easysw Exp $".
+// End of "$Id: Fl_Preferences.H,v 1.1.2.4 2002/04/30 18:11:49 easysw Exp $".
//
diff --git a/fluid/Fl_Window_Type.cxx b/fluid/Fl_Window_Type.cxx
index e024e588e..dd7d55d78 100644
--- a/fluid/Fl_Window_Type.cxx
+++ b/fluid/Fl_Window_Type.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Window_Type.cxx,v 1.13.2.10.2.1 2002/01/01 15:11:29 easysw Exp $"
+// "$Id: Fl_Window_Type.cxx,v 1.13.2.10.2.2 2002/04/30 18:11:49 easysw Exp $"
//
// Window type code for the Fast Light Tool Kit (FLTK).
//
@@ -38,9 +38,9 @@
#include "alignment_panel.h"
#include <stdio.h>
-int gridx = 5;
-int gridy = 5;
-int snap = 3;
+extern int gridx;
+extern int gridy;
+extern int snap;
int include_H_from_C = 1;
extern int i18n_type;
@@ -50,15 +50,25 @@ extern const char* i18n_file;
extern const char* i18n_set;
extern int modflag;
-void alignment_cb(Fl_Input *i, long v) {
+extern Fl_Preferences fluid_prefs;
+
+void grid_cb(Fl_Input *i, long v) {
int n = atoi(i->value());
if (n < 0) n = 0;
switch (v) {
- case 1: gridx = n; break;
- case 2: gridy = n; break;
- case 3: snap = n; break;
+ case 1:
+ gridx = n;
+ fluid_prefs.set("gridx", n);
+ break;
+ case 2:
+ gridy = n;
+ fluid_prefs.set("gridy", n);
+ break;
+ case 3:
+ snap = n;
+ fluid_prefs.set("snap", n);
+ break;
}
- modflag = 1;
}
void i18n_type_cb(Fl_Choice *c, void *) {
@@ -117,10 +127,6 @@ void show_alignment_cb(Fl_Widget *, void *) {
include_H_from_C_button->value(include_H_from_C);
header_file_input->value(header_file_name);
code_file_input->value(code_file_name);
- char buf[128];
- sprintf(buf,"%d",gridx); horizontal_input->value(buf);
- sprintf(buf,"%d",gridy); vertical_input->value(buf);
- sprintf(buf,"%d",snap); snap_input->value(buf);
i18n_type_chooser->value(i18n_type);
i18n_function_input->value(i18n_function);
i18n_file_input->value(i18n_file);
@@ -149,6 +155,14 @@ void show_alignment_cb(Fl_Widget *, void *) {
alignment_window->show();
}
+void show_settings_cb(Fl_Widget *, void *) {
+ char buf[128];
+ sprintf(buf,"%d",gridx); horizontal_input->value(buf);
+ sprintf(buf,"%d",gridy); vertical_input->value(buf);
+ sprintf(buf,"%d",snap); snap_input->value(buf);
+ settings_window->show();
+}
+
void header_input_cb(Fl_Input* i, void*) {
header_file_name = i->value();
}
@@ -752,5 +766,5 @@ int Fl_Window_Type::read_fdesign(const char* name, const char* value) {
}
//
-// End of "$Id: Fl_Window_Type.cxx,v 1.13.2.10.2.1 2002/01/01 15:11:29 easysw Exp $".
+// End of "$Id: Fl_Window_Type.cxx,v 1.13.2.10.2.2 2002/04/30 18:11:49 easysw Exp $".
//
diff --git a/fluid/alignment_panel.cxx b/fluid/alignment_panel.cxx
index 559002794..b0d29c33b 100644
--- a/fluid/alignment_panel.cxx
+++ b/fluid/alignment_panel.cxx
@@ -4,12 +4,6 @@
Fl_Window *alignment_window=(Fl_Window *)0;
-Fl_Input *horizontal_input=(Fl_Input *)0;
-
-Fl_Input *vertical_input=(Fl_Input *)0;
-
-Fl_Input *snap_input=(Fl_Input *)0;
-
static void cb_Close(Fl_Button*, void*) {
alignment_window->hide();
}
@@ -23,9 +17,9 @@ Fl_Light_Button *include_H_from_C_button=(Fl_Light_Button *)0;
Fl_Choice *i18n_type_chooser=(Fl_Choice *)0;
Fl_Menu_Item menu_i18n_type_chooser[] = {
- {"None", 0, 0, 0, 0, 0, 0, 14, 0},
- {"GNU gettext", 0, 0, 0, 0, 0, 0, 14, 0},
- {"POSIX catgets", 0, 0, 0, 0, 0, 0, 14, 0},
+ {"None", 0, 0, 0, 0, 0, 0, 14, 56},
+ {"GNU gettext", 0, 0, 0, 0, 0, 0, 14, 56},
+ {"POSIX catgets", 0, 0, 0, 0, 0, 0, 14, 56},
{0}
};
@@ -41,32 +35,6 @@ Fl_Window* make_alignment_window() {
Fl_Window* w;
{ Fl_Window* o = alignment_window = new Fl_Window(365, 340, "Preferences");
w = o;
- { Fl_Box* o = new Fl_Box(10, 25, 130, 130, "Grid:");
- o->box(FL_ENGRAVED_FRAME);
- o->labelsize(12);
- o->align(FL_ALIGN_TOP_LEFT);
- }
- { Fl_Input* o = horizontal_input = new Fl_Input(90, 35, 40, 20, "Horizontal:");
- o->tooltip("Horizontal grid spacing.");
- o->type(2);
- o->box(FL_THIN_DOWN_BOX);
- o->callback((Fl_Callback*)alignment_cb, (void*)(1));
- o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);
- }
- { Fl_Input* o = vertical_input = new Fl_Input(90, 65, 40, 20, "Vertical:");
- o->tooltip("Vertical grid spacing.");
- o->type(2);
- o->box(FL_THIN_DOWN_BOX);
- o->callback((Fl_Callback*)alignment_cb, (void*)(2));
- o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);
- }
- { Fl_Input* o = snap_input = new Fl_Input(90, 95, 40, 20, "Snap:");
- o->tooltip("Snap to grid within this many pixels.");
- o->type(2);
- o->box(FL_THIN_DOWN_BOX);
- o->callback((Fl_Callback*)alignment_cb, (void*)(3));
- o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);
- }
{ Fl_Button* o = new Fl_Button(295, 305, 60, 25, "Close");
o->tooltip("Close this dialog.");
o->callback((Fl_Callback*)cb_Close);
@@ -100,33 +68,33 @@ Fl_Window* make_alignment_window() {
o->labelsize(12);
o->callback((Fl_Callback*)include_H_from_C_button_cb);
}
- { Fl_Box* o = new Fl_Box(150, 25, 205, 130, "Internationalization:");
+ { Fl_Box* o = new Fl_Box(10, 25, 345, 130, "Internationalization:");
o->box(FL_ENGRAVED_FRAME);
o->labelsize(12);
o->align(FL_ALIGN_TOP_LEFT);
}
- { Fl_Choice* o = i18n_type_chooser = new Fl_Choice(220, 35, 125, 20, "Use:");
+ { Fl_Choice* o = i18n_type_chooser = new Fl_Choice(100, 35, 125, 20, "Use:");
o->tooltip("Type of internationalization to use.");
o->box(FL_THIN_UP_BOX);
o->down_box(FL_BORDER_BOX);
o->callback((Fl_Callback*)i18n_type_cb);
o->menu(menu_i18n_type_chooser);
}
- { Fl_Input* o = i18n_include_input = new Fl_Input(220, 65, 125, 20, "#include:");
+ { Fl_Input* o = i18n_include_input = new Fl_Input(100, 65, 245, 20, "#include:");
o->tooltip("The include file for internationalization.");
o->box(FL_THIN_DOWN_BOX);
o->textfont(4);
o->callback((Fl_Callback*)i18n_text_cb);
o->hide();
}
- { Fl_Input* o = i18n_file_input = new Fl_Input(220, 95, 125, 20, "File:");
+ { Fl_Input* o = i18n_file_input = new Fl_Input(100, 95, 245, 20, "File:");
o->tooltip("The name of the message catalog.");
o->box(FL_THIN_DOWN_BOX);
o->textfont(4);
o->callback((Fl_Callback*)i18n_text_cb);
o->hide();
}
- { Fl_Input* o = i18n_set_input = new Fl_Input(220, 125, 125, 20, "Set:");
+ { Fl_Input* o = i18n_set_input = new Fl_Input(100, 125, 245, 20, "Set:");
o->tooltip("The message set number.");
o->type(2);
o->box(FL_THIN_DOWN_BOX);
@@ -134,7 +102,7 @@ Fl_Window* make_alignment_window() {
o->callback((Fl_Callback*)i18n_text_cb);
o->hide();
}
- { Fl_Input* o = i18n_function_input = new Fl_Input(220, 95, 125, 20, "Function:");
+ { Fl_Input* o = i18n_function_input = new Fl_Input(100, 95, 245, 20, "Function:");
o->tooltip("The function to call to internationalize the labels and tooltips.");
o->box(FL_THIN_DOWN_BOX);
o->textfont(4);
@@ -147,3 +115,101 @@ Fl_Window* make_alignment_window() {
return w;
}
extern void i18n_cb(Fl_Choice *,void *);
+extern Fl_Preferences fluid_prefs;
+
+Fl_Window *settings_window=(Fl_Window *)0;
+
+static void cb_Close1(Fl_Button*, void*) {
+ settings_window->hide();
+}
+
+Fl_Input *horizontal_input=(Fl_Input *)0;
+
+Fl_Input *vertical_input=(Fl_Input *)0;
+
+Fl_Input *snap_input=(Fl_Input *)0;
+
+Fl_Check_Button *tooltips_button=(Fl_Check_Button *)0;
+
+static void cb_tooltips_button(Fl_Check_Button*, void*) {
+ Fl_Tooltip::enable(tooltips_button->value());
+fluid_prefs.set("show_tooltips", tooltips_button->value());
+}
+
+Fl_Check_Button *completion_button=(Fl_Check_Button *)0;
+
+static void cb_completion_button(Fl_Check_Button*, void*) {
+ fluid_prefs.set("show_completion_dialogs", completion_button->value());
+}
+
+Fl_Check_Button *openlast_button=(Fl_Check_Button *)0;
+
+static void cb_openlast_button(Fl_Check_Button*, void*) {
+ fluid_prefs.set("open_previous_file", openlast_button->value());
+}
+
+Fl_Window* make_settings_window() {
+ Fl_Window* w;
+ { Fl_Window* o = settings_window = new Fl_Window(400, 175, "Settings");
+ w = o;
+ { Fl_Button* o = new Fl_Button(330, 140, 60, 25, "Close");
+ o->tooltip("Close this dialog.");
+ o->callback((Fl_Callback*)cb_Close1);
+ }
+ { Fl_Box* o = new Fl_Box(15, 30, 130, 100, "Grid:");
+ o->box(FL_ENGRAVED_FRAME);
+ o->labelsize(12);
+ o->align(FL_ALIGN_TOP_LEFT);
+ }
+ { Fl_Input* o = horizontal_input = new Fl_Input(95, 40, 40, 20, "Horizontal:");
+ o->tooltip("Horizontal grid spacing.");
+ o->type(2);
+ o->box(FL_THIN_DOWN_BOX);
+ o->callback((Fl_Callback*)grid_cb, (void*)(1));
+ o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);
+ }
+ { Fl_Input* o = vertical_input = new Fl_Input(95, 70, 40, 20, "Vertical:");
+ o->tooltip("Vertical grid spacing.");
+ o->type(2);
+ o->box(FL_THIN_DOWN_BOX);
+ o->callback((Fl_Callback*)grid_cb, (void*)(2));
+ o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);
+ }
+ { Fl_Input* o = snap_input = new Fl_Input(95, 100, 40, 20, "Snap:");
+ o->tooltip("Snap to grid within this many pixels.");
+ o->type(2);
+ o->box(FL_THIN_DOWN_BOX);
+ o->callback((Fl_Callback*)grid_cb, (void*)(3));
+ o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);
+ }
+ { Fl_Box* o = new Fl_Box(155, 30, 235, 100, "GUI:");
+ o->box(FL_ENGRAVED_FRAME);
+ o->labelsize(12);
+ o->align(FL_ALIGN_TOP_LEFT);
+ }
+ { Fl_Check_Button* o = tooltips_button = new Fl_Check_Button(165, 40, 215, 20, "Show Tooltips");
+ o->down_box(FL_DOWN_BOX);
+ o->callback((Fl_Callback*)cb_tooltips_button);
+ char b;
+ fluid_prefs.get("show_tooltips", b, 1);
+ tooltips_button->value(b);
+ Fl_Tooltip::enable(b);
+ }
+ { Fl_Check_Button* o = completion_button = new Fl_Check_Button(165, 70, 215, 20, "Show Completion Dialogs");
+ o->down_box(FL_DOWN_BOX);
+ o->callback((Fl_Callback*)cb_completion_button);
+ char b;
+ fluid_prefs.get("show_completion_dialogs", b, 1);
+ completion_button->value(b);
+ }
+ { Fl_Check_Button* o = openlast_button = new Fl_Check_Button(165, 100, 215, 20, "Open Previous File on Startup");
+ o->down_box(FL_DOWN_BOX);
+ o->callback((Fl_Callback*)cb_openlast_button);
+ char b;
+ fluid_prefs.get("open_previous_file", b, 0);
+ openlast_button->value(b);
+ }
+ o->end();
+ }
+ return w;
+}
diff --git a/fluid/alignment_panel.fl b/fluid/alignment_panel.fl
index 5e8e1a251..3f8624400 100644
--- a/fluid/alignment_panel.fl
+++ b/fluid/alignment_panel.fl
@@ -1,44 +1,16 @@
# data file for the Fltk User Interface Designer (fluid)
version 1.0100
header_name {.h}
-code_name {.cxx}
-gridx 5
-gridy 5
-snap 3
+code_name {.cxx}
Function {make_alignment_window()} {open
} {
Fl_Window alignment_window {
label Preferences open
xywh {469 112 365 340} modal visible
} {
- Fl_Box {} {
- label {Grid:}
- xywh {10 25 130 130} box ENGRAVED_FRAME labelsize 12 align 5
- }
- Fl_Input horizontal_input {
- label {Horizontal:}
- user_data 1 user_data_type long
- callback alignment_cb
- tooltip {Horizontal grid spacing.} xywh {90 35 40 20} type Int box THIN_DOWN_BOX
- code0 {o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);}
- }
- Fl_Input vertical_input {
- label {Vertical:}
- user_data 2 user_data_type long
- callback alignment_cb
- tooltip {Vertical grid spacing.} xywh {90 65 40 20} type Int box THIN_DOWN_BOX
- code0 {o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);}
- }
- Fl_Input snap_input {
- label {Snap:}
- user_data 3 user_data_type long
- callback alignment_cb
- tooltip {Snap to grid within this many pixels.} xywh {90 95 40 20} type Int box THIN_DOWN_BOX
- code0 {o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);}
- }
Fl_Button {} {
label Close
- callback {alignment_window->hide();} selected
+ callback {alignment_window->hide();}
tooltip {Close this dialog.} xywh {295 305 60 25}
}
Fl_Box {} {
@@ -68,12 +40,12 @@ Function {make_alignment_window()} {open
}
Fl_Box {} {
label {Internationalization:}
- xywh {150 25 205 130} box ENGRAVED_FRAME labelsize 12 align 5
+ xywh {10 25 345 130} box ENGRAVED_FRAME labelsize 12 align 5
}
Fl_Choice i18n_type_chooser {
label {Use:}
callback i18n_type_cb open
- tooltip {Type of internationalization to use.} xywh {220 35 125 20} box THIN_UP_BOX down_box BORDER_BOX
+ tooltip {Type of internationalization to use.} xywh {100 35 125 20} box THIN_UP_BOX down_box BORDER_BOX
} {
menuitem {} {
label None
@@ -91,24 +63,97 @@ Function {make_alignment_window()} {open
Fl_Input i18n_include_input {
label {\#include:}
callback i18n_text_cb
- tooltip {The include file for internationalization.} xywh {220 65 125 20} box THIN_DOWN_BOX textfont 4 hide
+ tooltip {The include file for internationalization.} xywh {100 65 245 20} box THIN_DOWN_BOX textfont 4 hide
}
Fl_Input i18n_file_input {
label {File:}
callback i18n_text_cb
- tooltip {The name of the message catalog.} xywh {220 95 125 20} box THIN_DOWN_BOX textfont 4 hide
+ tooltip {The name of the message catalog.} xywh {100 95 245 20} box THIN_DOWN_BOX textfont 4 hide
}
Fl_Input i18n_set_input {
label {Set:}
callback i18n_text_cb
- tooltip {The message set number.} xywh {220 125 125 20} type Int box THIN_DOWN_BOX textfont 4 hide
+ tooltip {The message set number.} xywh {100 125 245 20} type Int box THIN_DOWN_BOX textfont 4 hide
}
Fl_Input i18n_function_input {
label {Function:}
callback i18n_text_cb
- tooltip {The function to call to internationalize the labels and tooltips.} xywh {220 95 125 20} box THIN_DOWN_BOX textfont 4 hide
+ tooltip {The function to call to internationalize the labels and tooltips.} xywh {100 95 245 20} box THIN_DOWN_BOX textfont 4 hide
}
}
}
decl {extern void i18n_cb(Fl_Choice *,void *);} {}
+
+decl {extern Fl_Preferences fluid_prefs;} {}
+
+Function {make_settings_window()} {open
+} {
+ Fl_Window settings_window {
+ label Settings open
+ xywh {376 480 400 175}
+ code0 {\#include <FL/Fl_Preferences.H>}
+ code1 {\#include <FL/Fl_Tooltip.H>} visible
+ } {
+ Fl_Button {} {
+ label Close
+ callback {settings_window->hide();}
+ tooltip {Close this dialog.} xywh {330 140 60 25}
+ }
+ Fl_Box {} {
+ label {Grid:}
+ xywh {15 30 130 100} box ENGRAVED_FRAME labelsize 12 align 5
+ }
+ Fl_Input horizontal_input {
+ label {Horizontal:}
+ user_data 1 user_data_type long
+ callback grid_cb
+ tooltip {Horizontal grid spacing.} xywh {95 40 40 20} type Int box THIN_DOWN_BOX
+ code0 {o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);}
+ }
+ Fl_Input vertical_input {
+ label {Vertical:}
+ user_data 2 user_data_type long
+ callback grid_cb
+ tooltip {Vertical grid spacing.} xywh {95 70 40 20} type Int box THIN_DOWN_BOX
+ code0 {o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);}
+ }
+ Fl_Input snap_input {
+ label {Snap:}
+ user_data 3 user_data_type long
+ callback grid_cb
+ tooltip {Snap to grid within this many pixels.} xywh {95 100 40 20} type Int box THIN_DOWN_BOX
+ code0 {o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);}
+ }
+ Fl_Box {} {
+ label {GUI:}
+ xywh {155 30 235 100} box ENGRAVED_FRAME labelsize 12 align 5
+ }
+ Fl_Check_Button tooltips_button {
+ label {Show Tooltips}
+ callback {Fl_Tooltip::enable(tooltips_button->value());
+fluid_prefs.set("show_tooltips", tooltips_button->value());} selected
+ xywh {165 40 215 20} down_box DOWN_BOX
+ code0 {char b;}
+ code1 {fluid_prefs.get("show_tooltips", b, 1);}
+ code2 {tooltips_button->value(b);}
+ code3 {Fl_Tooltip::enable(b);}
+ }
+ Fl_Check_Button completion_button {
+ label {Show Completion Dialogs}
+ callback {fluid_prefs.set("show_completion_dialogs", completion_button->value());}
+ xywh {165 70 215 20} down_box DOWN_BOX
+ code0 {char b;}
+ code1 {fluid_prefs.get("show_completion_dialogs", b, 1);}
+ code2 {completion_button->value(b);}
+ }
+ Fl_Check_Button openlast_button {
+ label {Open Previous File on Startup}
+ callback {fluid_prefs.set("open_previous_file", openlast_button->value());}
+ xywh {165 100 215 20} down_box DOWN_BOX
+ code0 {char b;}
+ code1 {fluid_prefs.get("open_previous_file", b, 0);}
+ code2 {openlast_button->value(b);}
+ }
+ }
+}
diff --git a/fluid/alignment_panel.h b/fluid/alignment_panel.h
index 8fbe5da1d..e25a873b3 100644
--- a/fluid/alignment_panel.h
+++ b/fluid/alignment_panel.h
@@ -5,13 +5,9 @@
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
extern Fl_Window *alignment_window;
+#include <FL/Fl_Button.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Input.H>
-extern void alignment_cb(Fl_Input*, long);
-extern Fl_Input *horizontal_input;
-extern Fl_Input *vertical_input;
-extern Fl_Input *snap_input;
-#include <FL/Fl_Button.H>
extern void header_input_cb(Fl_Input*, void*);
extern Fl_Input *header_file_input;
extern void code_input_cb(Fl_Input*, void*);
@@ -29,4 +25,16 @@ extern Fl_Input *i18n_set_input;
extern Fl_Input *i18n_function_input;
Fl_Window* make_alignment_window();
extern Fl_Menu_Item menu_i18n_type_chooser[];
+#include <FL/Fl_Preferences.H>
+#include <FL/Fl_Tooltip.H>
+extern Fl_Window *settings_window;
+extern void grid_cb(Fl_Input*, long);
+extern Fl_Input *horizontal_input;
+extern Fl_Input *vertical_input;
+extern Fl_Input *snap_input;
+#include <FL/Fl_Check_Button.H>
+extern Fl_Check_Button *tooltips_button;
+extern Fl_Check_Button *completion_button;
+extern Fl_Check_Button *openlast_button;
+Fl_Window* make_settings_window();
#endif
diff --git a/fluid/file.cxx b/fluid/file.cxx
index cd8bc0d7c..3b47e2b5c 100644
--- a/fluid/file.cxx
+++ b/fluid/file.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: file.cxx,v 1.7.2.6.2.1 2002/01/01 15:11:29 easysw Exp $"
+// "$Id: file.cxx,v 1.7.2.6.2.2 2002/04/30 18:11:49 easysw Exp $"
//
// Fluid file routines for the Fast Light Tool Kit (FLTK).
//
@@ -304,17 +304,11 @@ const char *read_word(int wantbrace) {
#include "Fl_Widget_Type.h"
// global int variables:
-extern int gridx, gridy, snap;
extern int i18n_type;
extern const char* i18n_include;
extern const char* i18n_function;
extern const char* i18n_file;
extern const char* i18n_set;
-static struct {const char* name; int* value;} inttable[] = {
- {"gridx", &gridx},
- {"gridy", &gridy},
- {"snap", &snap}
-};
extern int header_file_set;
@@ -344,8 +338,6 @@ int write_file(const char *filename, int selected_only) {
if (!selected_only) {
write_string("\nheader_name"); write_word(header_file_name);
write_string("\ncode_name"); write_word(code_file_name);
- for (unsigned int i=0; i<sizeof(inttable)/sizeof(*inttable); i++)
- write_string("\n%s %d",inttable[i].name, *inttable[i].value);
}
for (Fl_Type *p = Fl_Type::first; p;) {
if (!selected_only || p->selected) {
@@ -372,7 +364,6 @@ extern Fl_Type *Fl_Type_make(const char *tn);
static void read_children(Fl_Type *p, int paste) {
Fl_Type::current = p;
for (;;) {
- unsigned int i;
const char *c = read_word();
REUSE_C:
if (!c) {
@@ -454,12 +445,10 @@ static void read_children(Fl_Type *p, int paste) {
goto CONTINUE;
}
- for (i=0; i<sizeof(inttable)/sizeof(*inttable); i++) {
- if (!strcmp(c,inttable[i].name)) {
- c = read_word();
- *inttable[i].value = atoi(c);
- goto CONTINUE;
- }
+ if (!strcmp(c, "snap") || !strcmp(c, "gridx") || !strcmp(c, "gridy")) {
+ // grid settings are now global
+ read_word();
+ goto CONTINUE;
}
{Fl_Type *t = Fl_Type_make(c);
@@ -639,5 +628,5 @@ void read_fdesign() {
}
//
-// End of "$Id: file.cxx,v 1.7.2.6.2.1 2002/01/01 15:11:29 easysw Exp $".
+// End of "$Id: file.cxx,v 1.7.2.6.2.2 2002/04/30 18:11:49 easysw Exp $".
//
diff --git a/fluid/fluid.cxx b/fluid/fluid.cxx
index c61f3d9c8..1184a5d24 100644
--- a/fluid/fluid.cxx
+++ b/fluid/fluid.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fluid.cxx,v 1.15.2.13.2.14 2002/04/28 10:12:41 easysw Exp $"
+// "$Id: fluid.cxx,v 1.15.2.13.2.15 2002/04/30 18:11:49 easysw Exp $"
//
// FLUID main entry for the Fast Light Tool Kit (FLTK).
//
@@ -44,6 +44,7 @@
#include <errno.h>
#include "../src/flstring.h"
+#include "alignment_panel.h"
#if defined(WIN32) && !defined(__CYGWIN__)
# include <direct.h>
@@ -61,6 +62,18 @@
static Fl_Help_Dialog *help_dialog = 0;
+Fl_Preferences fluid_prefs(Fl_Preferences::USER, "fltk.org", "fluid");
+int gridx;
+int gridy;
+int snap;
+
+// File history info...
+char absolute_history[10][1024];
+char relative_history[10][1024];
+
+void load_history();
+void update_history(const char *);
+
////////////////////////////////////////////////////////////////
@@ -144,6 +157,16 @@ void open_cb(Fl_Widget *, void *v) {
else modflag = 1;
}
+void open_history_cb(Fl_Widget *, void *v) {
+ if (modflag && !fl_ask("Discard changes?")) return;
+ if (!read_file((char *)v, 0)) {
+ fl_message("Can't read %s: %s", v, strerror(errno));
+ return;
+ }
+ set_filename((char *)v);
+ modflag = 0;
+}
+
void new_cb(Fl_Widget *, void *v) {
if (!v && modflag && !fl_ask("Discard changes?")) return;
const char *c;
@@ -196,7 +219,7 @@ void write_cb(Fl_Widget *, void *) {
} else {
if (!x) {
fl_message("Can't write %s: %s", cname, strerror(errno));
- } else {
+ } else if (completion_button->value()) {
fl_message("Wrote %s", cname, 0);
}
}
@@ -219,7 +242,7 @@ void write_strings_cb(Fl_Widget *, void *) {
} else {
if (x) {
fl_message("Can't write %s: %s", sname, strerror(errno));
- } else {
+ } else if (completion_button->value()) {
fl_message("Wrote %s", sname);
}
}
@@ -245,26 +268,17 @@ extern int pasteoffset;
static int ipasteoffset;
static char* cutfname() {
-#if defined WIN32 && ! defined(__CYGWIN__)
-# ifndef MAX_PATH
-# define MAX_PATH 256
-# endif // !MAX_PATH
-
- static char name[MAX_PATH+16] = "";
-
- if (!name[0]) {
- if (!GetTempPath(sizeof(name), name)) strcpy(name,"\\"); // failure
-
- strcat(name, ".fluidcutbuffer");
+ static char name[1024];
+ static char beenhere = 0;
+
+ if (!beenhere) {
+ beenhere = 1;
+ fluid_prefs.getUserdataPath(name, sizeof(name));
+ strncat(name, "cut_buffer", sizeof(name) - 1);
+ // getUserdataPath zeros the "name" buffer...
}
return name;
-#else
- static char name[256] = "~/.fluid_cut_buffer";
- static char beenhere;
- if (!beenhere) {beenhere = 1; fl_filename_expand(name,name);}
- return name;
-#endif
}
void copy_cb(Fl_Widget*, void*) {
@@ -316,6 +330,7 @@ static void sort_cb(Fl_Widget *,void *) {
}
void show_alignment_cb(Fl_Widget *, void *);
+void show_settings_cb(Fl_Widget *, void *);
void about_cb(Fl_Widget *, void *) {
if (!about_panel) make_about_panel();
@@ -363,6 +378,18 @@ Fl_Menu_Item Main_Menu[] = {
{"&File",0,0,0,FL_SUBMENU},
{"New", 0, new_cb, 0},
{"Open...", FL_CTRL+'o', open_cb, 0},
+ {"Open Previous",0,0,0,FL_SUBMENU},
+ {relative_history[0], FL_CTRL+'0', open_history_cb, absolute_history[0]},
+ {relative_history[1], FL_CTRL+'1', open_history_cb, absolute_history[1]},
+ {relative_history[2], FL_CTRL+'2', open_history_cb, absolute_history[2]},
+ {relative_history[3], FL_CTRL+'3', open_history_cb, absolute_history[3]},
+ {relative_history[4], FL_CTRL+'4', open_history_cb, absolute_history[4]},
+ {relative_history[5], FL_CTRL+'5', open_history_cb, absolute_history[5]},
+ {relative_history[6], FL_CTRL+'6', open_history_cb, absolute_history[6]},
+ {relative_history[7], FL_CTRL+'7', open_history_cb, absolute_history[7]},
+ {relative_history[8], FL_CTRL+'8', open_history_cb, absolute_history[8]},
+ {relative_history[9], FL_CTRL+'9', open_history_cb, absolute_history[9]},
+ {0},
{"Save", FL_CTRL+'s', save_cb, 0},
{"Save As...", FL_CTRL+FL_SHIFT+'s', save_cb, (void*)1},
{"Merge...", FL_CTRL+'i', open_cb, (void*)1, FL_MENU_DIVIDER},
@@ -388,6 +415,7 @@ Fl_Menu_Item Main_Menu[] = {
//{"Activate", 0, nyi, 0, FL_MENU_DIVIDER},
{"Overlays on/off",FL_CTRL+FL_SHIFT+'o',toggle_overlays},
{"Preferences",FL_CTRL+'p',show_alignment_cb},
+ {"Settings",FL_CTRL+FL_SHIFT+'p',show_settings_cb},
{0},
{"&New", 0, 0, (void *)New_Menu, FL_SUBMENU_POINTER},
{"&Help",0,0,0,FL_SUBMENU},
@@ -406,6 +434,21 @@ Fl_Menu_Item Main_Menu[] = {
extern void fill_in_New_Menu();
void make_main_window() {
+ int i;
+
+ fluid_prefs.get("snap", i, 1);
+ snap = i;
+
+ fluid_prefs.get("gridx", i, 5);
+ gridx = i;
+
+ fluid_prefs.get("gridy", i, 5);
+ gridy = i;
+
+ load_history();
+
+ make_settings_window();
+
if (!main_window) {
Fl_Widget *o;
main_window = new Fl_Double_Window(WINWIDTH,WINHEIGHT,"fluid");
@@ -422,10 +465,75 @@ void make_main_window() {
}
}
+// Load file history from preferences...
+void load_history() {
+ int i; // Looping var
+ char name[32]; // Variable name
+
+ for (i = 0; i < 10; i ++) {
+ sprintf(name, "file%d", i);
+ fluid_prefs.get(name, absolute_history[i], "", sizeof(absolute_history[i]));
+ if (absolute_history[i][0]) {
+ // Make a relative version of the filename for the menu...
+ fl_filename_relative(relative_history[i], sizeof(relative_history[i]),
+ absolute_history[i]);
+
+ Main_Menu[i + 4].flags = 0;
+ } else Main_Menu[i + 4].flags = FL_MENU_INVISIBLE;
+ }
+
+ if (!absolute_history[0][0]) Main_Menu[3].flags |= FL_MENU_INACTIVE;
+}
+
+// Update file history from preferences...
+void update_history(const char *filename) {
+ int i; // Looping var
+ char name[32]; // Variable name
+ char absolute[1024];
+
+ fl_filename_absolute(absolute, sizeof(absolute), filename);
+
+ for (i = 0; i < 10; i ++)
+#if defined(WIN32) || defined(__APPLE__)
+ if (!strcasecmp(absolute, absolute_history[i])) break;
+#else
+ if (!strcasecmp(absolute, absolute_history[i])) break;
+#endif // WIN32 || __APPLE__
+
+ if (i == 0) return;
+
+ if (i >= 10) i = 9;
+
+ // Move the other filenames down in the list...
+ memmove(absolute_history + 1, absolute_history,
+ i * sizeof(absolute_history[0]));
+ memmove(relative_history + 1, relative_history,
+ i * sizeof(relative_history[0]));
+
+ // Put the new file at the top...
+ strncpy(absolute_history[0], absolute, sizeof(absolute_history[0]) - 1);
+ absolute_history[0][sizeof(absolute_history[0]) - 1] = '\0';
+
+ fl_filename_relative(relative_history[0], sizeof(relative_history[0]),
+ absolute_history[0]);
+
+ // Update the menu items as needed...
+ for (i = 0; i < 10; i ++) {
+ sprintf(name, "file%d", i);
+ fluid_prefs.set(name, absolute_history[i]);
+ if (absolute_history[i][0]) Main_Menu[i + 4].flags = 0;
+ else Main_Menu[i + 4].flags = FL_MENU_INVISIBLE;
+ }
+
+ Main_Menu[3].flags &= ~FL_MENU_INACTIVE;
+}
+
void set_filename(const char *c) {
if (filename) free((void *)filename);
filename = strdup(c);
if (main_window) main_window->label(filename);
+
+ update_history(filename);
}
////////////////////////////////////////////////////////////////
@@ -488,6 +596,10 @@ int main(int argc,char **argv) {
Fl_File_Icon::load_system_icons();
main_window->callback(exit_cb);
main_window->show(argc,argv);
+ if (!c && openlast_button->value() && absolute_history[0][0]) {
+ // Open previous file when no file specified...
+ open_history_cb(0, absolute_history[0]);
+ }
}
if (c && !read_file(c,0)) {
if (compile_only) {
@@ -506,5 +618,5 @@ int main(int argc,char **argv) {
}
//
-// End of "$Id: fluid.cxx,v 1.15.2.13.2.14 2002/04/28 10:12:41 easysw Exp $".
+// End of "$Id: fluid.cxx,v 1.15.2.13.2.15 2002/04/30 18:11:49 easysw Exp $".
//
diff --git a/src/Fl_Preferences.cxx b/src/Fl_Preferences.cxx
index d5ddb7224..8d1ded130 100644
--- a/src/Fl_Preferences.cxx
+++ b/src/Fl_Preferences.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Preferences.cxx,v 1.1.2.6 2002/04/30 15:34:58 easysw Exp $"
+// "$Id: Fl_Preferences.cxx,v 1.1.2.7 2002/04/30 18:11:49 easysw Exp $"
//
// Preferences methods for the Fast Light Tool Kit (FLTK).
//
@@ -408,10 +408,10 @@ int Fl_Preferences::size( const char *key )
* Win32: c:/Documents and Settings/matt/Application Data/matthiasm.com/test/
* prefs: c:/Documents and Settings/matt/Application Data/matthiasm.com/test.prefs
*/
-char Fl_Preferences::getUserdataPath( char *path )
+char Fl_Preferences::getUserdataPath( char *path, int pathlen )
{
if ( rootNode )
- return rootNode->getPath( path );
+ return rootNode->getPath( path, pathlen );
return 0;
}
@@ -630,9 +630,11 @@ int Fl_Preferences::RootNode::write()
}
// get the path to the preferences directory
-char Fl_Preferences::RootNode::getPath( char *path )
+char Fl_Preferences::RootNode::getPath( char *path, int pathlen )
{
- strcpy( path, filename_ );
+ strncpy( path, filename_, pathlen - 1 );
+ path[pathlen - 1] = '\0';
+
char *s;
for ( s = path; *s; s++ ) if ( *s == '\\' ) *s = '/';
s = strrchr( path, '.' );
@@ -935,5 +937,5 @@ char Fl_Preferences::Node::remove()
//
-// End of "$Id: Fl_Preferences.cxx,v 1.1.2.6 2002/04/30 15:34:58 easysw Exp $".
+// End of "$Id: Fl_Preferences.cxx,v 1.1.2.7 2002/04/30 18:11:49 easysw Exp $".
//
diff --git a/test/preferences.cxx b/test/preferences.cxx
index 6c8de6308..6943ffd5f 100644
--- a/test/preferences.cxx
+++ b/test/preferences.cxx
@@ -172,7 +172,7 @@ double doubleValue;
Fl_Preferences app( Fl_Preferences::USER, "fltk.org", "test/preferences" );
char path[ FL_PATH_MAX ];
- app.getUserdataPath( path );
+ app.getUserdataPath( path, sizeof(path) );
Fl_Preferences bed( app, "Bed" );
bed.get( "alarm", buffer, "8:00", 80 );