diff --git a/Common/Options.cpp b/Common/Options.cpp index 7d1ef4159118f9f74a019db313079a074f33037b..76e56ce96e39775c64c352e80d807fdc06460e05 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -107,7 +107,8 @@ static void SetStringOptionsGUI(int num, StringXString s[]) } static void PrintStringOptions(int num, int level, int diff, int help, - StringXString s[], const char *prefix, FILE *file) + StringXString s[], const char *prefix, + FILE *file, std::vector<std::string> *vec=0) { int i = 0; while(s[i].str) { @@ -125,7 +126,10 @@ static void PrintStringOptions(int num, int level, int diff, int help, if(tmp[i] == '\n' || tmp[i] == '\t' || tmp[i] == '\r') tmp[i] = ' '; // Warning: must call Msg::Direct(level, ...) here, because // we cannot use tmp as a format string (it can contain %s!) - Msg::Direct(3, "%s", tmp); + if(vec) + vec->push_back(tmp); + else + Msg::Direct(3, "%s", tmp); } } } @@ -219,7 +223,8 @@ static void SetNumberOptionsGUI(int num, StringXNumber s[]) } static void PrintNumberOptions(int num, int level, int diff, int help, - StringXNumber s[], const char *prefix, FILE * file) + StringXNumber s[], const char *prefix, + FILE * file, std::vector<std::string> *vec=0) { int i = 0; char tmp[1024]; @@ -231,6 +236,8 @@ static void PrintNumberOptions(int num, int level, int diff, int help, help ? " // " : "", help ? s[i].help : ""); if(file) fprintf(file, "%s\n", tmp); + else if(vec) + vec->push_back(tmp); else Msg::Direct(tmp); } @@ -355,7 +362,8 @@ static void SetColorOptionsGUI(int num, StringXColor s[]) } static void PrintColorOptions(int num, int level, int diff, int help, - StringXColor s[], const char *prefix, FILE * file) + StringXColor s[], const char *prefix, FILE * file, + std::vector<std::string> *vec) { int i = 0; char tmp[1024]; @@ -385,6 +393,8 @@ static void PrintColorOptions(int num, int level, int diff, int help, help ? " // " : "", help ? s[i].help : ""); if(file) fprintf(file, "%s\n", tmp); + else if(vec) + vec->push_back(tmp); else Msg::Direct(tmp); } @@ -482,7 +492,7 @@ void InitOptionsGUI(int num) } static void PrintOptionCategory(int level, int diff, int help, const char *cat, - FILE *file) + FILE *file, std::vector<std::string> *vec=0) { if(diff || !help || !(level & GMSH_FULLRC)) return; @@ -491,7 +501,12 @@ static void PrintOptionCategory(int level, int diff, int help, const char *cat, fprintf(file, "// %s\n", cat); fprintf(file, "//\n"); } - else { + else if(vec){ + vec->push_back("//"); + vec->push_back(std::string("// ") + cat); + vec->push_back("//"); + } + else{ Msg::Direct("//"); Msg::Direct("// %s", cat); Msg::Direct("//"); @@ -515,7 +530,8 @@ GmshColorTable *GetColorTable(int num) #endif } -static void PrintColorTable(int num, int diff, const char *prefix, FILE *file) +static void PrintColorTable(int num, int diff, const char *prefix, FILE *file, + std::vector<std::string> *vec) { #if defined(HAVE_POST) PViewOptions *opt; @@ -542,12 +558,16 @@ static void PrintColorTable(int num, int diff, const char *prefix, FILE *file) sprintf(tmp, "%s = {", prefix); if(file) fprintf(file, "%s\n", tmp); + else if(vec) + vec->push_back(tmp); else Msg::Direct(tmp); - ColorTable_Print(&opt->colorTable, file); + ColorTable_Print(&opt->colorTable, file, vec); sprintf(tmp, "};"); if(file) fprintf(file, "%s\n", tmp); + else if(vec) + vec->push_back(tmp); else Msg::Direct(tmp); #endif @@ -565,7 +585,8 @@ void Sanitize_String_Texi(std::string &s) s.insert(i++, "@"); } -void PrintOptions(int num, int level, int diff, int help, const char *filename) +void PrintOptions(int num, int level, int diff, int help, const char *filename, + std::vector<std::string> *vec) { #if defined(HAVE_FLTK) if(FlGui::available()) @@ -607,76 +628,76 @@ void PrintOptions(int num, int level, int diff, int help, const char *filename) fprintf(file, "//\n"); } - PrintOptionCategory(level, diff, help, "General options (strings)", file); - PrintStringOptions(num, level, diff, help, GeneralOptions_String, "General.", file); - PrintOptionCategory(level, diff, help, "General options (numbers)", file); - PrintNumberOptions(num, level, diff, help, GeneralOptions_Number, "General.", file); - PrintOptionCategory(level, diff, help, "General options (colors)", file); - PrintColorOptions(num, level, diff, help, GeneralOptions_Color, "General.", file); - - PrintOptionCategory(level, diff, help, "Geometry options (strings)", file); - PrintStringOptions(num, level, diff, help, GeometryOptions_String, "Geometry.", file); - PrintOptionCategory(level, diff, help, "Geometry options (numbers)", file); - PrintNumberOptions(num, level, diff, help, GeometryOptions_Number, "Geometry.", file); - PrintOptionCategory(level, diff, help, "Geometry options (colors)", file); - PrintColorOptions(num, level, diff, help, GeometryOptions_Color, "Geometry.", file); - - PrintOptionCategory(level, diff, help, "Mesh options (strings)", file); - PrintStringOptions(num, level, diff, help, MeshOptions_String, "Mesh.", file); - PrintOptionCategory(level, diff, help, "Mesh options (numbers)", file); - PrintNumberOptions(num, level, diff, help, MeshOptions_Number, "Mesh.", file); - PrintOptionCategory(level, diff, help, "Mesh options (colors)", file); - PrintColorOptions(num, level, diff, help, MeshOptions_Color, "Mesh.", file); - - PrintOptionCategory(level, diff, help, "Solver options (strings)", file); - PrintStringOptions(num, level, diff, help, SolverOptions_String, "Solver.", file); - PrintOptionCategory(level, diff, help, "Solver options (numbers)", file); - PrintNumberOptions(num, level, diff, help, SolverOptions_Number, "Solver.", file); - PrintOptionCategory(level, diff, help, "Solver options (colors)", file); - PrintColorOptions(num, level, diff, help, SolverOptions_Color, "Solver.", file); - - PrintOptionCategory(level, diff, help, "Post-processing options (strings)", file); + PrintOptionCategory(level, diff, help, "General options (strings)", file, vec); + PrintStringOptions(num, level, diff, help, GeneralOptions_String, "General.", file, vec); + PrintOptionCategory(level, diff, help, "General options (numbers)", file, vec); + PrintNumberOptions(num, level, diff, help, GeneralOptions_Number, "General.", file, vec); + PrintOptionCategory(level, diff, help, "General options (colors)", file, vec); + PrintColorOptions(num, level, diff, help, GeneralOptions_Color, "General.", file, vec); + + PrintOptionCategory(level, diff, help, "Geometry options (strings)", file, vec); + PrintStringOptions(num, level, diff, help, GeometryOptions_String, "Geometry.", file, vec); + PrintOptionCategory(level, diff, help, "Geometry options (numbers)", file, vec); + PrintNumberOptions(num, level, diff, help, GeometryOptions_Number, "Geometry.", file, vec); + PrintOptionCategory(level, diff, help, "Geometry options (colors)", file, vec); + PrintColorOptions(num, level, diff, help, GeometryOptions_Color, "Geometry.", file, vec); + + PrintOptionCategory(level, diff, help, "Mesh options (strings)", file, vec); + PrintStringOptions(num, level, diff, help, MeshOptions_String, "Mesh.", file, vec); + PrintOptionCategory(level, diff, help, "Mesh options (numbers)", file, vec); + PrintNumberOptions(num, level, diff, help, MeshOptions_Number, "Mesh.", file, vec); + PrintOptionCategory(level, diff, help, "Mesh options (colors)", file, vec); + PrintColorOptions(num, level, diff, help, MeshOptions_Color, "Mesh.", file, vec); + + PrintOptionCategory(level, diff, help, "Solver options (strings)", file, vec); + PrintStringOptions(num, level, diff, help, SolverOptions_String, "Solver.", file, vec); + PrintOptionCategory(level, diff, help, "Solver options (numbers)", file, vec); + PrintNumberOptions(num, level, diff, help, SolverOptions_Number, "Solver.", file, vec); + PrintOptionCategory(level, diff, help, "Solver options (colors)", file, vec); + PrintColorOptions(num, level, diff, help, SolverOptions_Color, "Solver.", file, vec); + + PrintOptionCategory(level, diff, help, "Post-processing options (strings)", file, vec); PrintStringOptions(num, level, diff, help, PostProcessingOptions_String, - "PostProcessing.", file); - PrintOptionCategory(level, diff, help, "Post-processing options (numbers)", file); + "PostProcessing.", file, vec); + PrintOptionCategory(level, diff, help, "Post-processing options (numbers)", file, vec); PrintNumberOptions(num, level, diff, help, PostProcessingOptions_Number, - "PostProcessing.", file); - PrintOptionCategory(level, diff, help, "Post-processing options (colors)", file); + "PostProcessing.", file, vec); + PrintOptionCategory(level, diff, help, "Post-processing options (colors)", file, vec); PrintColorOptions(num, level, diff, help, PostProcessingOptions_Color, - "PostProcessing.", file); + "PostProcessing.", file, vec); if(level & GMSH_FULLRC) { #if defined(HAVE_POST) for(unsigned int i = 0; i < PView::list.size(); i++) { char tmp[256]; sprintf(tmp, "View[%d].", i); - PrintOptionCategory(level, diff, help, "View options (strings)", file); - PrintStringOptions(i, level, diff, help, ViewOptions_String, tmp, file); - PrintOptionCategory(level, diff, help, "View options (numbers)", file); - PrintNumberOptions(i, level, diff, help, ViewOptions_Number, tmp, file); - PrintOptionCategory(level, diff, help, "View options (colors)", file); - PrintColorOptions(i, level, diff, help, ViewOptions_Color, tmp, file); + PrintOptionCategory(level, diff, help, "View options (strings)", file, vec); + PrintStringOptions(i, level, diff, help, ViewOptions_String, tmp, file, vec); + PrintOptionCategory(level, diff, help, "View options (numbers)", file, vec); + PrintNumberOptions(i, level, diff, help, ViewOptions_Number, tmp, file, vec); + PrintOptionCategory(level, diff, help, "View options (colors)", file, vec); + PrintColorOptions(i, level, diff, help, ViewOptions_Color, tmp, file, vec); strcat(tmp, "ColorTable"); - PrintColorTable(i, diff, tmp, file); + PrintColorTable(i, diff, tmp, file, vec); } #endif } else if(level & GMSH_OPTIONSRC) { - PrintOptionCategory(level, diff, help, "View options (strings)", file); - PrintStringOptions(num, level, diff, help, ViewOptions_String, "View.", file); - PrintOptionCategory(level, diff, help, "View options (numbers)", file); - PrintNumberOptions(num, level, diff, help, ViewOptions_Number, "View.", file); - PrintOptionCategory(level, diff, help, "View options (colors)", file); - PrintColorOptions(num, level, diff, help, ViewOptions_Color, "View.", file); - PrintColorTable(num, diff, "View.ColorTable", file); - } - - PrintOptionCategory(level, diff, help, "Print options (strings)", file); - PrintStringOptions(num, level, diff, help, PrintOptions_String, "Print.", file); - PrintOptionCategory(level, diff, help, "Print options (numbers)", file); - PrintNumberOptions(num, level, diff, help, PrintOptions_Number, "Print.", file); - PrintOptionCategory(level, diff, help, "Print options (colors)", file); - PrintColorOptions(num, level, diff, help, PrintOptions_Color, "Print.", file); + PrintOptionCategory(level, diff, help, "View options (strings)", file, vec); + PrintStringOptions(num, level, diff, help, ViewOptions_String, "View.", file, vec); + PrintOptionCategory(level, diff, help, "View options (numbers)", file, vec); + PrintNumberOptions(num, level, diff, help, ViewOptions_Number, "View.", file, vec); + PrintOptionCategory(level, diff, help, "View options (colors)", file, vec); + PrintColorOptions(num, level, diff, help, ViewOptions_Color, "View.", file, vec); + PrintColorTable(num, diff, "View.ColorTable", file, vec); + } + + PrintOptionCategory(level, diff, help, "Print options (strings)", file, vec); + PrintStringOptions(num, level, diff, help, PrintOptions_String, "Print.", file, vec); + PrintOptionCategory(level, diff, help, "Print options (numbers)", file, vec); + PrintNumberOptions(num, level, diff, help, PrintOptions_Number, "Print.", file, vec); + PrintOptionCategory(level, diff, help, "Print options (colors)", file, vec); + PrintColorOptions(num, level, diff, help, PrintOptions_Color, "Print.", file, vec); if(filename) fclose(file); } diff --git a/Common/Options.h b/Common/Options.h index 77877f9c6a3684af904eeddae8ff2087b77700c8..fc9db07e2cd7d45554bc74f4599438a146d26da3 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -746,7 +746,8 @@ typedef struct { void InitOptions(int num); void InitOptionsGUI(int num); void ReInitOptions(int num); -void PrintOptions(int num, int level, int diff, int help, const char *filename); +void PrintOptions(int num, int level, int diff, int help, const char *filename, + std::vector<std::string> *vec=0); void PrintOptionsDoc(); bool StringOption(int action, const char *category, int num, diff --git a/Fltk/CMakeLists.txt b/Fltk/CMakeLists.txt index d7732c275bf4cd5b0309dced95f61f2f481452aa..9b223d38bb4c31e088da38deabc2c390618abb89 100644 --- a/Fltk/CMakeLists.txt +++ b/Fltk/CMakeLists.txt @@ -17,7 +17,7 @@ set(SRC clippingWindow.cpp manipWindow.cpp contextWindow.cpp - aboutWindow.cpp + helpWindow.cpp fileDialogs.cpp extraDialogs.cpp projectionEditor.cpp diff --git a/Fltk/FlGui.cpp b/Fltk/FlGui.cpp index 36a9f64c50639614f6ba45dc6ca464fc30a438a7..acc823ab42bfa0fc8c9158fa3c36e790b113911f 100644 --- a/Fltk/FlGui.cpp +++ b/Fltk/FlGui.cpp @@ -28,7 +28,7 @@ typedef unsigned long intptr_t; #include "manipWindow.h" #include "contextWindow.h" #include "onelabGroup.h" -#include "aboutWindow.h" +#include "helpWindow.h" #include "colorbarWindow.h" #include "fileDialogs.h" #include "GmshDefines.h" @@ -186,7 +186,7 @@ FlGui::FlGui(int argc, char **argv) manip = new manipWindow(CTX::instance()->deltaFontSize); geoContext = new geometryContextWindow(CTX::instance()->deltaFontSize); meshContext = new meshContextWindow(CTX::instance()->deltaFontSize); - about = new aboutWindow(); + help = new helpWindow(); // init solver plugin stuff callForSolverPlugin(-1); diff --git a/Fltk/FlGui.h b/Fltk/FlGui.h index 0aa3834585c910ce5add22a8f46880a7ccc2fcf0..20d3bd2aa7f21be7d6f2841bc2e09e4c3be8b22e 100644 --- a/Fltk/FlGui.h +++ b/Fltk/FlGui.h @@ -30,7 +30,7 @@ class clippingWindow; class manipWindow; class geometryContextWindow; class meshContextWindow; -class aboutWindow; +class helpWindow; class onelabGroup; class Fl_Widget; @@ -62,7 +62,7 @@ class FlGui{ manipWindow *manip; geometryContextWindow *geoContext; meshContextWindow *meshContext; - aboutWindow *about; + helpWindow *help; onelabGroup *onelab; public: FlGui(int argc, char **argv); diff --git a/Fltk/aboutWindow.cpp b/Fltk/aboutWindow.cpp deleted file mode 100644 index 0ec4523e37e638293f39ae239ff8d3130c285800..0000000000000000000000000000000000000000 --- a/Fltk/aboutWindow.cpp +++ /dev/null @@ -1,107 +0,0 @@ -// Gmsh - Copyright (C) 1997-2013 C. Geuzaine, J.-F. Remacle -// -// See the LICENSE.txt file for license information. Please report all -// bugs and problems to the public mailing list <gmsh@geuz.org>. - -#include <sstream> -#include <FL/Fl_Help_View.H> -#include "FlGui.h" -#include "aboutWindow.h" -#include "paletteWindow.h" -#include "CommandLine.h" -#include "StringUtils.h" -#include "OS.h" -#include "Context.h" - -static const char *help_link(Fl_Widget *w, const char *uri) -{ - std::string prog = FixWindowsPath(CTX::instance()->webBrowser); - SystemCall(ReplaceSubString("%s", uri, prog)); - return 0; -} - -aboutWindow::aboutWindow() -{ - { - int width = 28 * FL_NORMAL_SIZE; - int height = 18 * BH; - - win = new paletteWindow - (width, height, CTX::instance()->nonModalWindows ? true : false, "About Gmsh"); - win->box(GMSH_WINDOW_BOX); - - Fl_Help_View *o = new Fl_Help_View(0, 0, width, height); - o->textfont(FL_HELVETICA); - o->textsize(FL_NORMAL_SIZE); - o->box(FL_FLAT_BOX); - std::ostringstream sstream; - sstream << "<center><h3>Gmsh</h3><br>version " << GetGmshVersion() - << "<p>Copyright (C) 1997-2013" - << "<br>Christophe Geuzaine and Jean-Francois Remacle" - << "<p><a href=\"http://geuz.org/gmsh/doc/CREDITS.txt\">Credits</a> " - << "and <a href=\"http://geuz.org/gmsh/doc/LICENSE.txt\">licensing " - << "information</a>" - << "<p>Please send all questions and bug reports to " - << "<a href=\"mailto:gmsh@geuz.org\">gmsh@geuz.org</a></center>" - << "<ul>" - << "<li><i>GUI toolkit:</i> FLTK " - << FL_MAJOR_VERSION << "." << FL_MINOR_VERSION << "." << FL_PATCH_VERSION - << "<li><i>Build OS:</i> " << GetGmshBuildOS() - << "<li><i>Build date:</i> " << GetGmshBuildDate() - << "<li><i>Build host:</i> " << GetGmshBuildHost() - << "<li><i>Build options:</i>" << GetGmshBuildOptions() - << "<li><i>Packaged by:</i> " << GetGmshPackager() - << "</ul>" - << "<center>Visit <a href=\"http://geuz.org/gmsh/\">http://geuz.org/gmsh/</a> " - << "for more information</center>"; - o->value(sstream.str().c_str()); - o->link(help_link); - win->position(Fl::x() + Fl::w()/2 - width / 2, - Fl::y() + Fl::h()/2 - height / 2); - win->end(); - } - - { - int width = 40 * FL_NORMAL_SIZE; - int height = 18 * BH; - - winhelp = new paletteWindow - (width, height, CTX::instance()->nonModalWindows ? true : false, - "Keyboard and Mouse Usage"); - winhelp->box(GMSH_WINDOW_BOX); - - Fl_Help_View *o = new Fl_Help_View(0, 0, width, height); - o->textfont(FL_HELVETICA); - o->textsize(FL_NORMAL_SIZE - 1); - o->box(FL_FLAT_BOX); - - std::string s; - s += "<h3>Keyboard Shortcuts</h3>"; - s += "<table border=1>"; - { - std::vector<std::pair<std::string, std::string> > s0 = GetShortcutsUsage(); - for(unsigned int i = 0; i < s0.size(); i++) - s += "<tr><td>" + s0[i].first + "</td><td>" + s0[i].second + "</td></tr>"; - } - s += "</table>"; - - s += "<h3>Mouse Actions</h3>"; - s += "<table border=1>"; - { - std::vector<std::pair<std::string, std::string> > s0 = GetMouseUsage(); - for(unsigned int i = 0; i < s0.size(); i++) - s += "<tr><td>" + s0[i].first + "</td><td>" + s0[i].second + "</td></tr>"; - } - s += "</table>"; - s += "For a 2 button mouse, Middle button = Shift+Left button.<p>"; - s += "For a 1 button mouse, Middle button = Shift+Left button, Right button = Alt+Left button."; - - o->value(s.c_str()); - - winhelp->resizable(o); - winhelp->position(Fl::x() + Fl::w()/2 - width / 2, - Fl::y() + Fl::h()/2 - height / 2); - winhelp->end(); - } - -} diff --git a/Fltk/aboutWindow.h b/Fltk/aboutWindow.h deleted file mode 100644 index 29898e616afa15ff3d2d1a8fa745f8e6850d55c8..0000000000000000000000000000000000000000 --- a/Fltk/aboutWindow.h +++ /dev/null @@ -1,21 +0,0 @@ -// Gmsh - Copyright (C) 1997-2013 C. Geuzaine, J.-F. Remacle -// -// See the LICENSE.txt file for license information. Please report all -// bugs and problems to the public mailing list <gmsh@geuz.org>. - -#ifndef _ABOUT_WINDOW_H_ -#define _ABOUT_WINDOW_H_ - -#include <FL/Fl_Window.H> -#include <FL/Fl_Output.H> -#include <FL/Fl_Button.H> -#include <FL/Fl_Group.H> - -class aboutWindow{ - public: - Fl_Window *win, *winhelp; - public: - aboutWindow(); -}; - -#endif diff --git a/Fltk/graphicWindow.cpp b/Fltk/graphicWindow.cpp index dcb41d9982ba9e68829b4ac9bd306eb3ac41a0bc..c75832d99cd20618122a05df4de3145d7fa7c91f 100644 --- a/Fltk/graphicWindow.cpp +++ b/Fltk/graphicWindow.cpp @@ -32,7 +32,7 @@ typedef unsigned long intptr_t; #include "manipWindow.h" #include "fieldWindow.h" #include "pluginWindow.h" -#include "aboutWindow.h" +#include "helpWindow.h" #include "onelabGroup.h" #include "fileDialogs.h" #include "extraDialogs.h" @@ -532,12 +532,12 @@ static void help_online_cb(Fl_Widget *w, void *data) static void help_basic_cb(Fl_Widget *w, void *data) { - FlGui::instance()->about->winhelp->show(); + FlGui::instance()->help->basic->show(); } void help_about_cb(Fl_Widget *w, void *data) { - FlGui::instance()->about->win->show(); + FlGui::instance()->help->about->show(); } static void geometry_edit_cb(Fl_Widget *w, void *data) @@ -2276,8 +2276,8 @@ void status_options_cb(Fl_Widget *w, void *data) modelChooser(); } else if(!strcmp(str, "?")){ // display options - PrintOptions(0, GMSH_FULLRC, 0, 1, NULL); - FlGui::instance()->showMessages(); + help_options_cb(0, 0); + FlGui::instance()->help->options->show(); } else if(!strcmp(str, "p")){ // toggle projection mode if(!Fl::event_state(FL_SHIFT)){ diff --git a/Fltk/helpWindow.cpp b/Fltk/helpWindow.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f95c89f0ef1fd6094116951fccd5c15bc3ec49d8 --- /dev/null +++ b/Fltk/helpWindow.cpp @@ -0,0 +1,204 @@ +// Gmsh - Copyright (C) 1997-2013 C. Geuzaine, J.-F. Remacle +// +// See the LICENSE.txt file for license information. Please report all +// bugs and problems to the public mailing list <gmsh@geuz.org>. + +#include <sstream> +#include <algorithm> +#include <FL/Fl_Help_View.H> +#include <FL/Fl_Check_Button.H> +#include <FL/Fl_Input.H> +#include "FlGui.h" +#include "helpWindow.h" +#include "paletteWindow.h" +#include "CommandLine.h" +#include "StringUtils.h" +#include "OS.h" +#include "Options.h" +#include "Context.h" + +static const char *help_link(Fl_Widget *w, const char *uri) +{ + std::string prog = FixWindowsPath(CTX::instance()->webBrowser); + SystemCall(ReplaceSubString("%s", uri, prog)); + return 0; +} + +static void copy_cb(Fl_Widget *w, void *data) +{ + std::string buff; + for(int i = 1; i <= FlGui::instance()->help->browser->size(); i++) { + if(FlGui::instance()->help->browser->selected(i)) { + const char *c = FlGui::instance()->help->browser->text(i); + if(strlen(c) > 5 && c[0] == '@') + buff += std::string(&c[5]); + else + buff += std::string(c); + buff += "\n"; + } + } + // bof bof bof + Fl::copy(buff.c_str(), buff.size(), 0); + Fl::copy(buff.c_str(), buff.size(), 1); +} + +void help_options_cb(Fl_Widget *w, void *data) +{ + std::vector<std::string> s0; + int diff = FlGui::instance()->help->modified->value(); + int help = FlGui::instance()->help->showhelp->value(); + std::string search = FlGui::instance()->help->search->value(); + std::transform(search.begin(), search.end(), search.begin(), ::tolower); + + PrintOptions(0, GMSH_FULLRC, diff, help, 0, &s0); + FlGui::instance()->help->browser->clear(); + for(unsigned int i = 0; i < s0.size(); i++){ + if(search.empty()){ + FlGui::instance()->help->browser->add(s0[i].c_str(), 0); + } + else{ + std::string tmp(s0[i]); + std::transform(tmp.begin(), tmp.end(), tmp.begin(), ::tolower); + if(tmp.find(search) != std::string::npos) + FlGui::instance()->help->browser->add(s0[i].c_str(), 0); + } + } +} + +helpWindow::helpWindow() +{ + { + int width = 28 * FL_NORMAL_SIZE; + int height = 18 * BH; + + about = new paletteWindow + (width, height, CTX::instance()->nonModalWindows ? true : false, "About Gmsh"); + about->box(GMSH_WINDOW_BOX); + + Fl_Help_View *o = new Fl_Help_View(0, 0, width, height); + o->textfont(FL_HELVETICA); + o->textsize(FL_NORMAL_SIZE); + o->box(FL_FLAT_BOX); + std::ostringstream sstream; + sstream << "<center><h3>Gmsh</h3><br>version " << GetGmshVersion() + << "<p>Copyright (C) 1997-2013" + << "<br>Christophe Geuzaine and Jean-Francois Remacle" + << "<p><a href=\"http://geuz.org/gmsh/doc/CREDITS.txt\">Credits</a> " + << "and <a href=\"http://geuz.org/gmsh/doc/LICENSE.txt\">licensing " + << "information</a>" + << "<p>Please send all questions and bug reports to " + << "<a href=\"mailto:gmsh@geuz.org\">gmsh@geuz.org</a></center>" + << "<ul>" + << "<li><i>GUI toolkit:</i> FLTK " + << FL_MAJOR_VERSION << "." << FL_MINOR_VERSION << "." << FL_PATCH_VERSION + << "<li><i>Build OS:</i> " << GetGmshBuildOS() + << "<li><i>Build date:</i> " << GetGmshBuildDate() + << "<li><i>Build host:</i> " << GetGmshBuildHost() + << "<li><i>Build options:</i>" << GetGmshBuildOptions() + << "<li><i>Packaged by:</i> " << GetGmshPackager() + << "</ul>" + << "<center>Visit <a href=\"http://geuz.org/gmsh/\">http://geuz.org/gmsh/</a> " + << "for more information</center>"; + o->value(sstream.str().c_str()); + o->link(help_link); + about->position(Fl::x() + Fl::w()/2 - width / 2, + Fl::y() + Fl::h()/2 - height / 2); + about->end(); + } + + { + int width = 40 * FL_NORMAL_SIZE; + int height = 18 * BH; + + basic = new paletteWindow + (width, height, CTX::instance()->nonModalWindows ? true : false, + "Keyboard and Mouse Usage"); + basic->box(GMSH_WINDOW_BOX); + + Fl_Help_View *o = new Fl_Help_View(0, 0, width, height); + o->textfont(FL_HELVETICA); + o->textsize(FL_NORMAL_SIZE - 1); + o->box(FL_FLAT_BOX); + + std::string s; + s += "<h3>Keyboard Shortcuts</h3>"; + s += "<table border=1>"; + { + std::vector<std::pair<std::string, std::string> > s0 = GetShortcutsUsage(); + for(unsigned int i = 0; i < s0.size(); i++) + s += "<tr><td>" + s0[i].first + "</td><td>" + s0[i].second + "</td></tr>"; + } + s += "</table>"; + + s += "<h3>Mouse Actions</h3>"; + s += "<table border=1>"; + { + std::vector<std::pair<std::string, std::string> > s0 = GetMouseUsage(); + for(unsigned int i = 0; i < s0.size(); i++) + s += "<tr><td>" + s0[i].first + "</td><td>" + s0[i].second + "</td></tr>"; + } + s += "</table>"; + s += "For a 2 button mouse, Middle button = Shift+Left button.<p>"; + s += "For a 1 button mouse, Middle button = Shift+Left button, " + "Right button = Alt+Left button."; + + o->value(s.c_str()); + + basic->resizable(o); + basic->position(Fl::x() + Fl::w()/2 - width / 2, + Fl::y() + Fl::h()/2 - height / 2); + basic->end(); + } + + + { + int width = 40 * FL_NORMAL_SIZE; + int height = 18 * BH; + + options = new paletteWindow + (width, height, CTX::instance()->nonModalWindows ? true : false, + "Current Options"); + options->box(GMSH_WINDOW_BOX); + + int BW = (width - 4 * WB) / 3; + + modified = new Fl_Check_Button + (WB, WB, BW, BH, "Show modified"); + modified->type(FL_TOGGLE_BUTTON); + modified->callback(help_options_cb); + modified->tooltip("Show options with values different from defaults"); + + showhelp = new Fl_Check_Button + (2 * WB + BW, WB, BW, BH, "Show help"); + showhelp->type(FL_TOGGLE_BUTTON); + showhelp->callback(help_options_cb); + showhelp->tooltip("Show help string for each option"); + + Fl_Group* o = new Fl_Group(3 * WB + 2 * BW, WB, BW, BH); + o->tooltip("Filter options"); + o->box(FL_DOWN_BOX); + o->color(FL_BACKGROUND2_COLOR); + search = new Fl_Input + (3 * WB + 2 * BW + 25, WB + 2, BW - 27, BH - 4, "@search"); + search->box(FL_FLAT_BOX); + search->callback(help_options_cb); + search->when(FL_WHEN_CHANGED); + search->take_focus(); + o->resizable(search); + o->end(); + + browser = new Fl_Browser(0, BH + 2 * WB, width, height - BH - 2 * WB); + browser->box(GMSH_SIMPLE_TOP_BOX); + browser->textfont(FL_SCREEN); + browser->textsize(FL_NORMAL_SIZE - 2); + browser->type(FL_MULTI_BROWSER); + browser->callback(copy_cb); + + options->resizable(browser); + options->position(Fl::x() + Fl::w()/2 - width / 2, + Fl::y() + Fl::h()/2 - height / 2); + options->size_range(about->w(), about->h()); + options->end(); + } + +} diff --git a/Fltk/helpWindow.h b/Fltk/helpWindow.h new file mode 100644 index 0000000000000000000000000000000000000000..ccc6d112917d2d2eb04a586e6315929a335ae217 --- /dev/null +++ b/Fltk/helpWindow.h @@ -0,0 +1,24 @@ +// Gmsh - Copyright (C) 1997-2013 C. Geuzaine, J.-F. Remacle +// +// See the LICENSE.txt file for license information. Please report all +// bugs and problems to the public mailing list <gmsh@geuz.org>. + +#ifndef _HELP_WINDOW_H_ +#define _HELP_WINDOW_H_ + +#include <FL/Fl_Window.H> +#include <FL/Fl_Browser.H> + +class helpWindow{ + public: + Fl_Window *about, *basic, *options; + Fl_Check_Button *modified, *showhelp; + Fl_Input *search; + Fl_Browser *browser; + public: + helpWindow(); +}; + +void help_options_cb(Fl_Widget *w, void *data); + +#endif diff --git a/Post/ColorTable.cpp b/Post/ColorTable.cpp index 15a5029895d4d230f97fd07a121e359e7cad490c..061ba2a06a875841924a6c9ee0dd520fa568d168 100644 --- a/Post/ColorTable.cpp +++ b/Post/ColorTable.cpp @@ -387,7 +387,7 @@ int ColorTable_Diff(GmshColorTable * ct1, GmshColorTable * ct2) return 0; } -void ColorTable_Print(GmshColorTable * ct, FILE * fp) +void ColorTable_Print(GmshColorTable * ct, FILE * fp, std::vector<std::string> *vec) { int i, r, g, b, a; char tmp1[1024], tmp2[1024]; @@ -401,6 +401,8 @@ void ColorTable_Print(GmshColorTable * ct, FILE * fp) if(i && !(i % 4)) { if(fp) fprintf(fp, "%s\n", tmp1); + else if(vec) + vec->push_back(tmp1); else Msg::Direct(tmp1); strcpy(tmp1, ""); @@ -412,6 +414,8 @@ void ColorTable_Print(GmshColorTable * ct, FILE * fp) } if(fp) fprintf(fp, "%s\n", tmp1); + else if(vec) + vec->push_back(tmp1); else Msg::Direct(tmp1); } diff --git a/Post/ColorTable.h b/Post/ColorTable.h index a6a26ad012355e102a6a3238c374f189e4326450..ea422f7ad11cc24234e8434048b25d1167d9520c 100644 --- a/Post/ColorTable.h +++ b/Post/ColorTable.h @@ -7,6 +7,8 @@ #define _COLORTABLE_H_ #include <stdio.h> +#include <vector> +#include <string> #define COLORTABLE_NBMAX_PARAM 10 #define COLORTABLE_NBMAX_COLOR 1024 @@ -43,7 +45,7 @@ void ColorTable_InitParam(int number, GmshColorTable *ct); void ColorTable_Recompute(GmshColorTable *ct); void ColorTable_Copy(GmshColorTable *ct); void ColorTable_Paste(GmshColorTable *ct); -void ColorTable_Print(GmshColorTable *ct, FILE *fp) ; +void ColorTable_Print(GmshColorTable *ct, FILE *fp, std::vector<std::string> *vec=0) ; int ColorTable_IsAlpha(GmshColorTable *ct) ; int ColorTable_Diff(GmshColorTable *ct1, GmshColorTable *ct2);