From 933a1742cce7b2fc86f3c847f9b9f0852f321697 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Mon, 8 Feb 2010 16:19:04 +0000 Subject: [PATCH] better display of solver help --- Common/DefaultOptions.h | 4 ++-- Fltk/FlGui.cpp | 28 ---------------------------- Fltk/FlGui.h | 4 ---- Fltk/solverWindow.cpp | 17 +++++++++-------- 4 files changed, 11 insertions(+), 42 deletions(-) diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index 943799a9f1..8036820d81 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -120,8 +120,8 @@ StringXString SolverOptions_String[] = { { F|O, "Name0" , opt_solver_name0 , "GetDP" , "Name of solver 0" }, { F|O, "Help0" , opt_solver_help0 , - "A General environment for the treatment of\nDiscrete Problems\n\n" - "Copyright (C) 1997-2009\nPatrick Dular and Christophe Geuzaine\n\n" + "A General environment for the treatment of Discrete Problems\n\n" + "Copyright (C) 1997-2009 Patrick Dular and Christophe Geuzaine\n\n" "Visit http://www.geuz.org/getdp/ for more info", "Help string for solver 0" }, { F|O, "Executable0" , opt_solver_executable0 , diff --git a/Fltk/FlGui.cpp b/Fltk/FlGui.cpp index de9c4529e4..288717e2f0 100644 --- a/Fltk/FlGui.cpp +++ b/Fltk/FlGui.cpp @@ -860,31 +860,3 @@ void window_cb(Fl_Widget *w, void *data) } } -void add_multiline_in_browser(Fl_Browser *o, const char *prefix, - const char *str, int wrap) -{ - int start = 0, len; - if(!str || !strlen(str) || !strcmp(str, "\n")) { - o->add(" "); - return; - } - for(int i = 0; i < (int)strlen(str); i++) { - if(i == (int)strlen(str) - 1 || str[i] == '\n' || - (wrap > 0 && i - start == wrap)) { - if(wrap > 0 && i - start == wrap){ //line is longer than wrap - while(str[i] != ' ' && i > start) //go back to the previous space - i--; - if(i == start) //no space in this line, cut the word - i += wrap; - } - len = i - start + (str[i] == '\n' ? 0 : 1); - char *buff = new char[len + strlen(prefix) + 2]; - strcpy(buff, prefix); - strncat(buff, &str[start], len); - buff[len + strlen(prefix)] = '\0'; - o->add(buff); - start = i + 1; - delete [] buff; - } - } -} diff --git a/Fltk/FlGui.h b/Fltk/FlGui.h index 5cd7469a4f..df54a9b5fc 100644 --- a/Fltk/FlGui.h +++ b/Fltk/FlGui.h @@ -111,8 +111,4 @@ class FlGui{ void redraw_cb(Fl_Widget *w, void *data); void window_cb(Fl_Widget *w, void *data); -class Fl_Browser; -void add_multiline_in_browser(Fl_Browser *o, const char *prefix, - const char *str, int wrap=0); - #endif diff --git a/Fltk/solverWindow.cpp b/Fltk/solverWindow.cpp index 22a79d7cbf..dbaa815d5a 100644 --- a/Fltk/solverWindow.cpp +++ b/Fltk/solverWindow.cpp @@ -7,7 +7,7 @@ #include <FL/Fl_Tabs.H> #include <FL/Fl_Box.H> #include <FL/Fl_Return_Button.H> -#include <FL/Fl_Browser.H> +#include <FL/Fl_Help_View.H> #include "GmshMessage.h" #include "GmshSocket.h" #include "ConnectionManager.h" @@ -510,14 +510,15 @@ solverWindow::solverWindow(int num, int deltaFontSize) Fl_Group *g = new Fl_Group (WB, WB + BH, width - 2 * WB, height - 2 * WB, "About"); - Fl_Browser *o = new Fl_Browser + Fl_Help_View *o = new Fl_Help_View (2 * WB, 2 * WB + 1 * BH, width - 4 * WB, height - 4 * WB - BH); - o->add(" "); - add_multiline_in_browser - (o, "@c@b@.", ConnectionManager::get(num)->name.c_str(), false); - o->add(" "); - add_multiline_in_browser - (o, "@c@. ", ConnectionManager::get(num)->help.c_str(), false); + o->textfont(FL_HELVETICA); + o->textsize(FL_NORMAL_SIZE); + std::string help = ConnectionManager::get(num)->help; + ConvertToHTML(help); + help = std::string("<h3>") + ConnectionManager::get(num)->name + + "</h3><p>" + help; + o->value(help.c_str()); g->end(); } -- GitLab