From bfdbb18f43729037d17986e260b4b98500632248 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Wed, 30 Jan 2013 10:47:43 +0000 Subject: [PATCH] tweaks --- Common/Options.cpp | 13 ++++++++++--- Common/Options.h | 1 + Fltk/extraDialogs.cpp | 18 +++++++++--------- Fltk/helpWindow.cpp | 42 ++++++++++++++++++++---------------------- 4 files changed, 40 insertions(+), 34 deletions(-) diff --git a/Common/Options.cpp b/Common/Options.cpp index c6011cf38a..20ae7a5516 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -84,7 +84,9 @@ bool StringOption(int action, const char *category, int num, return false; } - if(action & GMSH_SET_DEFAULT) + if(action & GMSH_GET_DEFAULT) + val = s[i].def; + else if(action & GMSH_SET_DEFAULT) val = s[i].function(num, action | GMSH_SET, s[i].def); else val = s[i].function(num, action, val); @@ -204,7 +206,9 @@ bool NumberOption(int action, const char *category, int num, return false; } - if(action & GMSH_SET_DEFAULT) + if(action & GMSH_GET_DEFAULT) + val = s[i].def; + else if(action & GMSH_SET_DEFAULT) val = s[i].function(num, action | GMSH_SET, s[i].def); else val = s[i].function(num, action, val); @@ -298,7 +302,10 @@ bool ColorOption(int action, const char *category, int num, return false; } - if(action & GMSH_SET_DEFAULT) + if(action & GMSH_GET_DEFAULT) + val = CTX::instance()->packColor + (s[i].def1[0], s[i].def1[1], s[i].def1[2], s[i].def1[3]); + else if(action & GMSH_SET_DEFAULT) val = s[i].function(num, action | GMSH_SET, CTX::instance()->packColor (s[i].def1[0], s[i].def1[1], s[i].def1[2], s[i].def1[3])); else diff --git a/Common/Options.h b/Common/Options.h index ad48ba1deb..ee1006cf68 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -13,6 +13,7 @@ #define GMSH_GET (1<<1) #define GMSH_GUI (1<<2) #define GMSH_SET_DEFAULT (1<<3) +#define GMSH_GET_DEFAULT (1<<4) #define GMSH_SESSIONRC (1<<0) #define GMSH_OPTIONSRC (1<<1) diff --git a/Fltk/extraDialogs.cpp b/Fltk/extraDialogs.cpp index d51920f4a1..fde66bcb49 100644 --- a/Fltk/extraDialogs.cpp +++ b/Fltk/extraDialogs.cpp @@ -62,7 +62,7 @@ int arrowEditor(const char *title, double &a, double &b, double &c) editor->window->end(); editor->window->hotspot(editor->window); } - + editor->window->label(title); editor->sa->value(a); editor->sb->value(b); @@ -95,7 +95,7 @@ class Release_Slider : public Fl_Value_Slider { int handle(int event) { switch (event) { - case FL_RELEASE: + case FL_RELEASE: if(window()) window()->hide(); return 1; @@ -246,7 +246,7 @@ int modelChooser() class historyBrowser : public Fl_Hold_Browser { int handle(int event) - { + { switch (event) { case FL_SHORTCUT: case FL_KEYBOARD: @@ -281,7 +281,7 @@ class historyChooser{ historyChooser(const std::string &prefix, const std::string &label, const std::string &commandLabel, const std::string &defaultCommand, const std::string &okLabel) - : _prefix(prefix), _label(label), _commandLabel(commandLabel), + : _prefix(prefix), _label(label), _commandLabel(commandLabel), _defaultCommand(defaultCommand), _okLabel(okLabel) { int h = 4 * WB + 10 * BH, w = 3 * BB + 2 * WB; @@ -296,9 +296,9 @@ class historyChooser{ browser = new historyBrowser (WB, 2 * WB + 3 * BH, w - 2 * WB, h - 4 * BH - 4 * WB); cancel = new Fl_Button - (w - 2 * WB - 2 * BB, h - WB - BH, BB, BH, "Cancel"); + (w - WB - BB, h - WB - BH, BB, BH, "Cancel"); ok = new Fl_Return_Button - (w - WB - BB, h - WB - BH, BB, BH, _okLabel.c_str()); + (w - 2 * WB - 2 * BB, h - WB - BH, BB, BH, _okLabel.c_str()); Fl_Box *b3 = new Fl_Box(WB, h - WB - BB, WB, WB); b3->hide(); window->resizable(b3); @@ -310,7 +310,7 @@ class historyChooser{ sprintf(name, "%s%02d", _prefix.c_str(), i); if(i < browser->size()) prefs.set(name, browser->text(i + 1)); - else if(prefs.entryExists(name)) + else if(prefs.entryExists(name)) prefs.deleteEntry(name); } prefs.set((_prefix + "PositionX").c_str(), window->x()); @@ -429,7 +429,7 @@ class cgnsImportDialog { window = new Fl_Double_Window(w, h); window->set_modal(); window->label("CGNS import"); - + input_choice = new Fl_Input_Choice(WB + 2 * BB, WB, 1*BB, BH, "Import mesh as order"); ok = new Fl_Return_Button(w - WB - BB, h - WB - BH, BB, BH, "Import"); @@ -500,7 +500,7 @@ static cgnsImportDialog* _cgnsImport = 0; _cgnsImport->input_choice->value("1"); } */ -int cgnsImport() +int cgnsImport() { if (!_cgnsImport) { _cgnsImport = new cgnsImportDialog(); diff --git a/Fltk/helpWindow.cpp b/Fltk/helpWindow.cpp index 0fabbbc992..93a52c6e01 100644 --- a/Fltk/helpWindow.cpp +++ b/Fltk/helpWindow.cpp @@ -36,32 +36,27 @@ static void numberOrStringChooser(const std::string &category, int index, NumberOption(GMSH_GET, category.c_str(), index, name.c_str(), valn); else StringOption(GMSH_GET, category.c_str(), index, name.c_str(), vals); - int width = 4 * BB + 2 * WB, height = 3 * BH + 4 * WB; - int BB1 = (int)(3. * BB / 4.), BB2 = 2 * BB - BB1; - Fl_Window *win = new paletteWindow(width, height, false, "Value Chooser"); + int width = 3 * BB + 4 * WB, height = 2 * BH + 3 * WB; + Fl_Window *win = new paletteWindow(width, height, false, + num ? "Number Chooser" : "String Chooser"); win->set_modal(); win->hotspot(win); - Fl_Box *box = new Fl_Box(WB, WB, width - 2 * WB, BH); - box->align(FL_ALIGN_INSIDE|FL_ALIGN_LEFT|FL_ALIGN_CLIP); Fl_Value_Input *number = 0; Fl_Input *string = 0; - std::string l = "Enter"; if(num){ - box->copy_label((l + " number for " + category + "." + name).c_str()); - number = new Fl_Value_Input(WB, 2 * WB + BH, width - 2 * WB, BH); + number = new Fl_Value_Input(WB, WB, width - 2 * WB, BH); number->value(valn); } else{ - box->copy_label((l + " string for " + category + "." + name).c_str()); - string = new Fl_Input(WB, 2 * WB + BH, width - 2 * WB, BH); + string = new Fl_Input(WB, WB, width - 2 * WB, BH); string->value(vals.c_str()); } - Fl_Button *set = new Fl_Return_Button - (width - BB1 - BB2 - BB - 3 * WB, 3 * WB + 2 * BH, BB1, BH, "Set"); - Fl_Button *reset = new Fl_Button - (width - BB2 - BB - 2 * WB, 3 * WB + 2 * BH, BB2, BH, "Restore default"); + Fl_Button *ok = new Fl_Return_Button + (width - 3 * BB - 3 * WB, 2 * WB + BH, BB, BH, "OK"); + Fl_Button *def = new Fl_Button + (width - 2 * BB - 2 * WB, 2 * WB + BH, BB, BH, "Default"); Fl_Button *cancel = new Fl_Button - (width - BB - WB, 3 * WB + 2 * BH, BB, BH, "Cancel"); + (width - BB - WB, 2 * WB + BH, BB, BH, "Cancel"); win->end(); win->show(); if(number) number->take_focus(); @@ -77,7 +72,7 @@ static void numberOrStringChooser(const std::string &category, int index, done = true; break; } - if(o == set){ + if(o == ok){ if(num){ valn = number->value(); NumberOption(GMSH_SET|GMSH_GUI, category.c_str(), index, @@ -91,14 +86,17 @@ static void numberOrStringChooser(const std::string &category, int index, done = true; break; } - if(o == reset){ - if(num) - NumberOption(GMSH_SET_DEFAULT|GMSH_GUI, category.c_str(), index, + if(o == def){ + if(num){ + NumberOption(GMSH_GET_DEFAULT, category.c_str(), index, name.c_str(), valn); - else - StringOption(GMSH_SET_DEFAULT|GMSH_GUI, category.c_str(), index, + number->value(valn); + } + else{ + StringOption(GMSH_GET_DEFAULT, category.c_str(), index, name.c_str(), vals); - done = true; + string->value(vals.c_str()); + } break; } } -- GitLab