2002-05-01 19:55:07 +04:00
|
|
|
# data file for the Fltk User Interface Designer (fluid)
|
2016-01-30 03:56:42 +03:00
|
|
|
version 1.0400
|
2022-11-25 18:58:50 +03:00
|
|
|
i18n_type 1
|
|
|
|
i18n_include {<stdio.h>}
|
|
|
|
i18n_conditional {}
|
2023-07-15 00:42:09 +03:00
|
|
|
i18n_gnu_function gettext
|
|
|
|
i18n_gnu_static_function gettext_noop
|
2015-07-09 05:09:33 +03:00
|
|
|
header_name {.h}
|
2002-06-27 08:29:39 +04:00
|
|
|
code_name {.cxx}
|
2022-11-25 18:58:50 +03:00
|
|
|
comment {About test/preferences:
|
|
|
|
|
|
|
|
The preferences app shows two features of FLTK and FLUID.
|
|
|
|
|
|
|
|
The Fl_Preferences class is used as a storage for user
|
2023-02-02 19:03:09 +03:00
|
|
|
settings between app launches. Fl_Preferences can store
|
2022-11-25 18:58:50 +03:00
|
|
|
small amounts of arbitrary data in an .ini file format
|
|
|
|
which can be retrieved again at the next app launch.
|
|
|
|
|
|
|
|
The FLUID setup uses GNU gettext for internationalisation
|
|
|
|
(i18n). FLUID finds the texts that need to be translated
|
2023-02-02 19:03:09 +03:00
|
|
|
and writes them into .po files that can be processed by
|
2022-11-25 18:58:50 +03:00
|
|
|
the GNU gettext tools. FLUID produces source code that
|
|
|
|
will translate all text into the current locale when
|
|
|
|
generating the UI.
|
|
|
|
|
|
|
|
|
|
|
|
In this small example, 'getttext' is only emulated.} {in_source not_in_header
|
|
|
|
}
|
|
|
|
|
2010-11-12 14:55:10 +03:00
|
|
|
decl {\#include <FL/Fl_Preferences.H>} {public local
|
2015-07-09 05:09:33 +03:00
|
|
|
}
|
2006-04-04 16:24:36 +04:00
|
|
|
|
2010-11-12 14:55:10 +03:00
|
|
|
decl {\#include <stdio.h>} {public local
|
2015-07-09 05:09:33 +03:00
|
|
|
}
|
2006-04-04 16:24:36 +04:00
|
|
|
|
2010-11-12 14:55:10 +03:00
|
|
|
decl {\#include <stdlib.h>} {private local
|
2015-07-09 05:09:33 +03:00
|
|
|
}
|
2006-04-04 16:24:36 +04:00
|
|
|
|
2010-11-12 14:55:10 +03:00
|
|
|
decl {\#include <FL/filename.H>} {private local
|
2015-07-09 05:09:33 +03:00
|
|
|
}
|
2006-04-04 16:24:36 +04:00
|
|
|
|
2010-11-12 14:55:10 +03:00
|
|
|
decl {\#include <FL/fl_ask.H>} {private local
|
2015-07-09 05:09:33 +03:00
|
|
|
}
|
2006-04-04 16:24:36 +04:00
|
|
|
|
2022-11-25 18:58:50 +03:00
|
|
|
decl {\#define _(text) gettext(text)} {private local
|
2015-07-09 05:09:33 +03:00
|
|
|
}
|
2006-04-04 16:24:36 +04:00
|
|
|
|
2022-11-25 18:58:50 +03:00
|
|
|
decl {int g_language = 0;} {
|
|
|
|
comment {Current languages are:
|
|
|
|
0 = English
|
|
|
|
1 = German} private global
|
2015-07-09 05:09:33 +03:00
|
|
|
}
|
2006-04-04 16:24:36 +04:00
|
|
|
|
2012-01-18 19:15:04 +04:00
|
|
|
decl {const char *project = "fltk.org";} {private local
|
2015-07-09 05:09:33 +03:00
|
|
|
}
|
2012-01-18 19:15:04 +04:00
|
|
|
|
|
|
|
decl {const char *application = "test/preferences";} {private local
|
2015-07-09 05:09:33 +03:00
|
|
|
}
|
2012-01-18 19:15:04 +04:00
|
|
|
|
2022-11-25 18:58:50 +03:00
|
|
|
Function {gettext(const char *text)} {
|
|
|
|
comment {This is a minimal implementation of the GNU gettext API
|
|
|
|
for systems that don't have GNU libintl library.} open return_type {const char*}
|
|
|
|
} {
|
|
|
|
code {static const char* translation_table[][2] = {
|
2023-02-02 19:03:09 +03:00
|
|
|
{ "Alarm at:", "Wecken um:" },
|
|
|
|
{ "Bread:", "Brot:" },
|
|
|
|
{ "Breakfast:", "Frühstück:" },
|
|
|
|
{ "Cancel", "Abbrechen" },
|
2023-12-28 17:43:21 +03:00
|
|
|
{ "Copy", "Kopieren" },
|
|
|
|
{ "Cut", "Ausschneiden" },
|
2023-02-02 19:03:09 +03:00
|
|
|
{ "Drink:", "Getränk:" },
|
|
|
|
{ "English", "Englisch" },
|
|
|
|
{ "German", "Deutsch" },
|
|
|
|
{ "Get Up:", "Aufstehen:" },
|
|
|
|
{ "Language:", "Sprache:" },
|
|
|
|
{ "My Preferences", "Meine Vorlieben" },
|
|
|
|
{ "NY Times", "Der Spiegel" },
|
|
|
|
{ "Newspaper:", "Tageszeitung:" },
|
|
|
|
{ "OK", "OK" },
|
2023-12-28 17:43:21 +03:00
|
|
|
{ "Paste", "Einfügen" },
|
2023-02-02 19:03:09 +03:00
|
|
|
{ "Please restart the app to use your new language setting.",
|
|
|
|
"Bitte starten Sie die App erneut um Ihre Spracheinstellung zu nutzen." },
|
|
|
|
{ "Wear:", "Schuhwerk:" },
|
|
|
|
{ "a.m.", "früh" },
|
|
|
|
{ "bare foot", "barfuß" },
|
|
|
|
{ "brush teeth", "Zähne putzen" },
|
|
|
|
{ "coffee", "Kaffee" },
|
|
|
|
{ "eggs", "Eier" },
|
|
|
|
{ "flip flops", "Schlappen" },
|
|
|
|
{ "juice", "Saft" },
|
|
|
|
{ "left side", "linke Seite" },
|
|
|
|
{ "min.", "Min." },
|
|
|
|
{ "of the bed", "vom Bett" },
|
|
|
|
{ "p.m.", "spät" },
|
|
|
|
{ "right side", "rechte Seite" },
|
|
|
|
{ "rye", "Roggen" },
|
|
|
|
{ "sandals", "Sandalen" },
|
|
|
|
{ "shave", "rasieren" },
|
|
|
|
{ "shoes", "Schuhe" },
|
|
|
|
{ "shower", "duschen" },
|
|
|
|
{ "sourdough", "Sauerteig" },
|
|
|
|
{ "tea", "Tee" },
|
|
|
|
{ "wheat", "Weizen" },
|
|
|
|
{ "white", "Weißbrot" },
|
|
|
|
{ "with butter", "mit Butter" },
|
|
|
|
{ "with milk", "mit Milch" },
|
2022-11-25 18:58:50 +03:00
|
|
|
};
|
|
|
|
int lang = g_language;
|
2023-12-28 17:43:21 +03:00
|
|
|
int i, n = 41;
|
2022-11-25 18:58:50 +03:00
|
|
|
const char *found = 0L;
|
|
|
|
|
|
|
|
// As this is just a minimal demo, I did not implement binary search.
|
|
|
|
for (i=0; i<n; i++) {
|
|
|
|
if (strcmp(text, translation_table[i][0])==0) {
|
|
|
|
found = translation_table[i][lang];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2023-02-02 19:03:09 +03:00
|
|
|
if (found)
|
2022-11-25 18:58:50 +03:00
|
|
|
return found;
|
|
|
|
else
|
|
|
|
return text;} {}
|
|
|
|
}
|
|
|
|
|
2010-12-21 01:19:24 +03:00
|
|
|
Function {closeWindowCB( Fl_Widget*, void* )} {open private return_type void
|
2006-04-04 16:24:36 +04:00
|
|
|
} {
|
2010-12-21 01:19:24 +03:00
|
|
|
code {Fl::delete_widget(myWindow);} {}
|
2015-07-09 05:09:33 +03:00
|
|
|
}
|
2006-04-04 16:24:36 +04:00
|
|
|
|
2010-12-21 01:19:24 +03:00
|
|
|
Function {saveAndCloseWindowCB( Fl_Widget*, void* )} {open private return_type void
|
2002-05-01 19:55:07 +04:00
|
|
|
} {
|
2010-12-21 01:19:24 +03:00
|
|
|
code {writePrefs();
|
|
|
|
Fl::delete_widget(myWindow);} {}
|
2015-07-09 05:09:33 +03:00
|
|
|
}
|
2006-04-04 16:24:36 +04:00
|
|
|
|
2022-11-25 18:58:50 +03:00
|
|
|
Function {} {open return_type int
|
2006-04-04 16:24:36 +04:00
|
|
|
} {
|
2023-12-28 17:43:21 +03:00
|
|
|
code {readLanguagePrefs();
|
|
|
|
Fl_Input::cut_menu_text = gettext("Cut");
|
|
|
|
Fl_Input::copy_menu_text = gettext("Copy");
|
|
|
|
Fl_Input::paste_menu_text = gettext("Paste");} {selected
|
|
|
|
}
|
2006-04-04 16:24:36 +04:00
|
|
|
Fl_Window myWindow {
|
2010-12-21 01:19:24 +03:00
|
|
|
label {My Preferences}
|
|
|
|
callback closeWindowCB open
|
2023-07-15 00:42:09 +03:00
|
|
|
xywh {480 345 322 355} type Double visible
|
2002-05-01 19:55:07 +04:00
|
|
|
} {
|
2010-12-21 01:19:24 +03:00
|
|
|
Fl_Button {} {
|
|
|
|
label Cancel
|
2023-12-28 17:43:21 +03:00
|
|
|
callback closeWindowCB
|
2023-07-15 00:42:09 +03:00
|
|
|
xywh {118 316 90 24}
|
2010-12-21 01:19:24 +03:00
|
|
|
}
|
|
|
|
Fl_Button {} {
|
|
|
|
label OK
|
2023-07-15 00:42:09 +03:00
|
|
|
callback saveAndCloseWindowCB
|
|
|
|
xywh {217 316 90 24}
|
2010-12-21 01:19:24 +03:00
|
|
|
}
|
2006-04-04 16:24:36 +04:00
|
|
|
Fl_Group {} {
|
2010-12-21 01:19:24 +03:00
|
|
|
label {Get Up:} open
|
2023-07-15 00:42:09 +03:00
|
|
|
xywh {15 22 144 248} box ENGRAVED_FRAME align 5
|
2002-05-01 19:55:07 +04:00
|
|
|
} {
|
2010-12-21 01:19:24 +03:00
|
|
|
Fl_Input wAlarm {
|
2021-12-19 03:09:13 +03:00
|
|
|
label {Alarm at:}
|
2023-07-15 00:42:09 +03:00
|
|
|
xywh {25 47 60 20} align 5
|
2010-12-21 01:19:24 +03:00
|
|
|
}
|
|
|
|
Fl_Choice wAmPm {open
|
2023-07-15 00:42:09 +03:00
|
|
|
xywh {85 47 60 20} down_box BORDER_BOX
|
2006-04-04 16:24:36 +04:00
|
|
|
} {
|
|
|
|
MenuItem {} {
|
2010-12-21 01:19:24 +03:00
|
|
|
label {a.m.}
|
|
|
|
xywh {0 0 100 20}
|
2006-04-04 16:24:36 +04:00
|
|
|
}
|
|
|
|
MenuItem {} {
|
2022-01-19 18:08:29 +03:00
|
|
|
label {p.m.}
|
2010-12-21 01:19:24 +03:00
|
|
|
xywh {0 0 100 20}
|
2006-04-04 16:24:36 +04:00
|
|
|
}
|
2010-12-12 22:52:26 +03:00
|
|
|
}
|
2010-12-21 01:19:24 +03:00
|
|
|
Fl_Choice wWear {
|
|
|
|
label {Wear:} open
|
2023-07-15 00:42:09 +03:00
|
|
|
xywh {25 92 120 20} down_box BORDER_BOX align 5
|
2010-12-12 22:52:26 +03:00
|
|
|
} {
|
2006-04-04 16:24:36 +04:00
|
|
|
MenuItem {} {
|
2010-12-21 01:19:24 +03:00
|
|
|
label shoes
|
|
|
|
xywh {0 0 100 20}
|
2006-04-04 16:24:36 +04:00
|
|
|
}
|
|
|
|
MenuItem {} {
|
2010-12-21 01:19:24 +03:00
|
|
|
label sandals
|
|
|
|
xywh {0 0 100 20}
|
2006-04-04 16:24:36 +04:00
|
|
|
}
|
|
|
|
MenuItem {} {
|
2010-12-21 01:19:24 +03:00
|
|
|
label {flip flops}
|
|
|
|
xywh {0 0 100 20}
|
2006-04-04 16:24:36 +04:00
|
|
|
}
|
2010-12-21 01:19:24 +03:00
|
|
|
MenuItem {} {
|
|
|
|
label {bare foot}
|
|
|
|
xywh {0 0 100 20}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Fl_Group {} {open
|
2023-07-15 00:42:09 +03:00
|
|
|
xywh {25 112 120 76}
|
2010-12-21 01:19:24 +03:00
|
|
|
} {
|
|
|
|
Fl_Round_Button wLeft {
|
|
|
|
label {left side}
|
2023-07-15 00:42:09 +03:00
|
|
|
xywh {35 112 100 24} type Radio down_box ROUND_DOWN_BOX
|
2010-12-21 01:19:24 +03:00
|
|
|
}
|
|
|
|
Fl_Round_Button wRight {
|
|
|
|
label {right side}
|
2023-07-15 00:42:09 +03:00
|
|
|
xywh {35 136 100 24} type Radio down_box ROUND_DOWN_BOX
|
2010-12-21 01:19:24 +03:00
|
|
|
}
|
|
|
|
Fl_Box {} {
|
|
|
|
label {of the bed}
|
2023-07-15 00:42:09 +03:00
|
|
|
xywh {35 160 100 24}
|
2010-12-21 01:19:24 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Fl_Check_Button wShower {
|
|
|
|
label shower
|
2023-07-15 00:42:09 +03:00
|
|
|
xywh {25 188 105 24} down_box DOWN_BOX
|
2010-12-21 01:19:24 +03:00
|
|
|
}
|
|
|
|
Fl_Check_Button wShave {
|
|
|
|
label shave
|
2023-07-15 00:42:09 +03:00
|
|
|
xywh {25 212 105 24} down_box DOWN_BOX
|
2010-12-21 01:19:24 +03:00
|
|
|
}
|
|
|
|
Fl_Check_Button wBrush {
|
|
|
|
label {brush teeth}
|
2023-07-15 00:42:09 +03:00
|
|
|
xywh {25 236 105 24} down_box DOWN_BOX
|
2006-04-04 16:24:36 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Fl_Group {} {
|
2022-11-25 18:58:50 +03:00
|
|
|
label {Breakfast:} open
|
2023-07-15 00:42:09 +03:00
|
|
|
xywh {163 22 144 248} box ENGRAVED_FRAME align 5
|
2006-04-04 16:24:36 +04:00
|
|
|
} {
|
2010-12-21 01:19:24 +03:00
|
|
|
Fl_Choice wDrink {
|
|
|
|
label {Drink:} open
|
2023-07-15 00:42:09 +03:00
|
|
|
xywh {173 48 120 20} down_box BORDER_BOX align 5
|
2006-04-04 16:24:36 +04:00
|
|
|
} {
|
|
|
|
MenuItem {} {
|
2010-12-21 01:19:24 +03:00
|
|
|
label coffee
|
|
|
|
xywh {10 10 100 20}
|
2006-04-04 16:24:36 +04:00
|
|
|
}
|
|
|
|
MenuItem {} {
|
2010-12-21 01:19:24 +03:00
|
|
|
label tea
|
|
|
|
xywh {10 10 100 20}
|
2006-04-04 16:24:36 +04:00
|
|
|
}
|
|
|
|
MenuItem {} {
|
2010-12-21 01:19:24 +03:00
|
|
|
label juice
|
|
|
|
xywh {10 10 100 20}
|
2006-04-04 16:24:36 +04:00
|
|
|
}
|
|
|
|
}
|
2010-12-21 01:19:24 +03:00
|
|
|
Fl_Check_Button wMilk {
|
|
|
|
label {with milk}
|
2023-07-15 00:42:09 +03:00
|
|
|
xywh {173 68 100 24} down_box DOWN_BOX
|
2010-12-21 01:19:24 +03:00
|
|
|
}
|
|
|
|
Fl_Choice wBread {
|
|
|
|
label {Bread:} open
|
2023-07-15 00:42:09 +03:00
|
|
|
xywh {173 116 120 20} down_box BORDER_BOX align 5
|
2006-04-04 16:24:36 +04:00
|
|
|
} {
|
2022-11-25 18:58:50 +03:00
|
|
|
MenuItem flWheatItem {
|
2010-12-21 01:19:24 +03:00
|
|
|
label wheat
|
|
|
|
xywh {0 0 100 20}
|
2006-04-04 16:24:36 +04:00
|
|
|
}
|
|
|
|
MenuItem {} {
|
2010-12-21 01:19:24 +03:00
|
|
|
label white
|
|
|
|
xywh {0 0 100 20}
|
2006-04-04 16:24:36 +04:00
|
|
|
}
|
|
|
|
MenuItem {} {
|
2010-12-21 01:19:24 +03:00
|
|
|
label rye
|
|
|
|
xywh {0 0 100 20}
|
|
|
|
}
|
|
|
|
MenuItem {} {
|
2022-11-25 18:58:50 +03:00
|
|
|
label sourdough
|
2010-12-21 01:19:24 +03:00
|
|
|
xywh {0 0 100 20}
|
2006-04-04 16:24:36 +04:00
|
|
|
}
|
|
|
|
}
|
2010-12-21 01:19:24 +03:00
|
|
|
Fl_Check_Button wButter {
|
|
|
|
label {with butter}
|
2023-07-15 00:42:09 +03:00
|
|
|
xywh {173 136 100 24} down_box DOWN_BOX
|
2006-04-04 16:24:36 +04:00
|
|
|
}
|
2010-12-21 01:19:24 +03:00
|
|
|
Fl_Input wEggs {
|
|
|
|
label eggs
|
2023-07-15 00:42:09 +03:00
|
|
|
xywh {173 168 30 20} type Int align 8
|
2010-12-21 01:19:24 +03:00
|
|
|
}
|
|
|
|
Fl_Value_Slider wMinutes {
|
|
|
|
label {min.}
|
2023-07-15 00:42:09 +03:00
|
|
|
xywh {173 196 70 20} type Horizontal align 8 minimum 2 maximum 6 value 3.1
|
2010-12-21 01:19:24 +03:00
|
|
|
}
|
|
|
|
Fl_Input wPaper {
|
|
|
|
label {Newspaper:}
|
2023-07-15 00:42:09 +03:00
|
|
|
xywh {173 239 120 20} align 5
|
2002-05-01 19:55:07 +04:00
|
|
|
}
|
|
|
|
}
|
2022-11-25 18:58:50 +03:00
|
|
|
Fl_Choice wLanguage {
|
|
|
|
label {Language:}
|
2022-12-30 21:20:52 +03:00
|
|
|
callback {fl_message("%s", _("Please restart the app to use your new language setting."));} open
|
2023-07-15 00:42:09 +03:00
|
|
|
xywh {185 283 105 20} down_box BORDER_BOX
|
2022-11-25 18:58:50 +03:00
|
|
|
code0 {\#include <FL/fl_ask.H>}
|
|
|
|
} {
|
|
|
|
MenuItem {} {
|
|
|
|
label English
|
|
|
|
xywh {20 20 100 20}
|
|
|
|
}
|
|
|
|
MenuItem {} {
|
|
|
|
label German
|
|
|
|
xywh {20 20 100 20}
|
|
|
|
}
|
|
|
|
}
|
2002-05-01 19:55:07 +04:00
|
|
|
}
|
2010-12-21 01:19:24 +03:00
|
|
|
code {readPrefs();} {}
|
2015-07-09 05:09:33 +03:00
|
|
|
}
|
2010-12-21 01:19:24 +03:00
|
|
|
|
2022-11-25 18:58:50 +03:00
|
|
|
Function {readLanguagePrefs()} {
|
|
|
|
comment {Read the language setting before we create the UI.} open return_type void
|
|
|
|
} {
|
|
|
|
code {Fl_Preferences app( Fl_Preferences::USER_L, project, application );
|
|
|
|
app.get( "language", g_language, 0 );} {}
|
|
|
|
}
|
|
|
|
|
2010-12-21 01:19:24 +03:00
|
|
|
Function {readPrefs()} {open return_type void
|
|
|
|
} {
|
|
|
|
code {int boolValue;
|
|
|
|
int intValue;
|
|
|
|
char buffer[80];
|
|
|
|
double doubleValue;
|
|
|
|
|
2022-01-19 18:08:29 +03:00
|
|
|
char path[ FL_PATH_MAX ];
|
2022-03-03 19:20:24 +03:00
|
|
|
Fl_Preferences::Root root =
|
2022-01-19 18:08:29 +03:00
|
|
|
Fl_Preferences::filename(path, FL_PATH_MAX, Fl_Preferences::USER_L, project, application);
|
|
|
|
if (root == Fl_Preferences::UNKNOWN_ROOT_TYPE) {
|
|
|
|
printf("Location of future Preferences file not found.\\n");
|
|
|
|
} else {
|
|
|
|
printf("Preferences file will be located at:\\n%s\\n", path);
|
|
|
|
}
|
|
|
|
|
|
|
|
Fl_Preferences app( Fl_Preferences::USER_L, project, application );
|
2010-12-21 01:19:24 +03:00
|
|
|
|
2022-01-19 18:08:29 +03:00
|
|
|
root = app.filename(path, FL_PATH_MAX);
|
|
|
|
if (root == Fl_Preferences::UNKNOWN_ROOT_TYPE) {
|
|
|
|
printf("Location of app Preferences file not found.\\n");
|
|
|
|
} else if (root == Fl_Preferences::MEMORY) {
|
|
|
|
printf("App Preferences are memory mapped.\\n");
|
|
|
|
} else {
|
|
|
|
printf("App Preferences file is actually located at:\\n%s\\n", path);
|
|
|
|
}
|
2022-03-03 19:20:24 +03:00
|
|
|
|
|
|
|
app.getUserdataPath( path, sizeof(path) );
|
2022-01-19 18:08:29 +03:00
|
|
|
if (path[0]) {
|
|
|
|
printf("Preferences user data directory is located at:\\n%s\\n", path);
|
|
|
|
} else {
|
|
|
|
printf("Location of Preferences user data directory not found.\\n");
|
|
|
|
}
|
2023-02-02 19:03:09 +03:00
|
|
|
|
2022-11-25 18:58:50 +03:00
|
|
|
wLanguage->value( g_language );
|
2010-12-21 01:19:24 +03:00
|
|
|
|
|
|
|
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;
|
2022-11-25 18:58:50 +03:00
|
|
|
eat.get( "newspaper", flexBuffer, gettext("NY Times") );
|
2010-12-21 01:19:24 +03:00
|
|
|
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 );
|
2021-12-17 21:37:34 +03:00
|
|
|
**/} {}
|
2015-07-09 05:09:33 +03:00
|
|
|
}
|
2010-12-21 01:19:24 +03:00
|
|
|
|
|
|
|
Function {writePrefs()} {open return_type void
|
|
|
|
} {
|
2022-01-19 18:08:29 +03:00
|
|
|
code {Fl_Preferences app( Fl_Preferences::USER_L, project, application );
|
2010-12-21 01:19:24 +03:00
|
|
|
|
2022-11-25 18:58:50 +03:00
|
|
|
app.set( "language", wLanguage->value() );
|
2023-02-02 19:03:09 +03:00
|
|
|
|
2010-12-21 01:19:24 +03:00
|
|
|
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: */
|
2023-09-22 14:43:00 +03:00
|
|
|
// unsigned int hex = 0xefbeadde;
|
|
|
|
// unsigned int size_of_bed = sizeof( bed ); // size of Fl_Preferences 'bed'
|
|
|
|
// eat.set( "binFoo", (void*)&hex, sizeof( unsigned int ) );
|
|
|
|
// eat.set( "SizeOfBed", (int)size_of_bed );
|
2023-12-28 17:43:21 +03:00
|
|
|
// eat.set( "Prefs_Bed", (void*)&bed, sizeof( bed ) );} {}
|
2015-07-09 05:09:33 +03:00
|
|
|
}
|