diff --git a/Common/CommandLine.cpp b/Common/CommandLine.cpp
index 778c0128e1d23b30585b2d1d57905ef51840aad5..f3270e342236fdb49ff7a6973feccfd54f9cc930 100644
--- a/Common/CommandLine.cpp
+++ b/Common/CommandLine.cpp
@@ -6,7 +6,14 @@
 #include <string>
 #include <string.h>
 #include <stdlib.h>
-#include "GmshUI.h"
+
+#if defined(HAVE_FLTK)
+#include <FL/Fl.H>
+#if (FL_MAJOR_VERSION != 1) || (FL_MINOR_VERSION != 1) || (FL_PATCH_VERSION < 7)
+#error "Gmsh requires FLTK 1.1.7 or above"
+#endif
+#endif
+
 #include "GmshDefines.h"
 #include "GmshVersion.h"
 #include "GmshMessage.h"
diff --git a/Common/Context.h b/Common/Context.h
index 1a96d459caba8d182f7415102f38d555bdbf7f14..b797d1f828fe466fc5139789c2b2ebede038fadd 100644
--- a/Common/Context.h
+++ b/Common/Context.h
@@ -99,7 +99,6 @@ class Context_T {
   int light[6]; // status of lights
   double light_position[6][4]; // light sources positions 
   double shine, shine_exponent; // material specular reflection parameters
-  int render_mode; // GMSH_RENDER, GMSH_SELECT, GMSH_FEEDBACK 
   double clip_plane[6][4]; // clipping planes 
   int clip_whole_elements, clip_only_draw_intersecting_volume; // clipping options
   int clip_only_volume;
@@ -134,7 +133,7 @@ class Context_T {
     double point_size, line_width, point_sel_size, line_sel_width;
     int point_type, line_type, surface_type;
     int draw, light, light_two_side;
-    int old_circle, circle_points;
+    int old_circle, num_sub_edges;
     int extrude_spline_points, extrude_return_lateral, old_newreg;
     double normals, tangents;
     double scaling_factor;
diff --git a/Common/CreateFile.cpp b/Common/CreateFile.cpp
index 72d212eb4a04900eb84a919e70ffca01538647ac..f94519e4ad92833f2bd3898aba02741442f12927 100644
--- a/Common/CreateFile.cpp
+++ b/Common/CreateFile.cpp
@@ -12,7 +12,7 @@
 #include "Options.h"
 
 #if defined(HAVE_FLTK)
-#include "GmshUI.h"
+#include <FL/gl.h>
 #include "gl2ps.h"
 #include "gl2gif.h"
 #include "gl2jpeg.h"
diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h
index 5b08c7023d47d2d3dd75e1587ddbe4910aad620c..fbc816a10757eec89aeccccca9141dfbc7784c09 100644
--- a/Common/DefaultOptions.h
+++ b/Common/DefaultOptions.h
@@ -647,7 +647,7 @@ StringXNumber GeneralOptions_Number[] = {
     "Horizontal position (in pixels) of the upper left corner of the menu window" }, 
   { F|S, "MenuPositionY" , opt_general_menu_position1 , 50. ,
     "Vertical position (in pixels) of the upper left corner of the menu window" }, 
-  { F|S, "MessageAutoScroll" , opt_general_message_auto_scroll , 1. , 
+  { F|O, "MessageAutoScroll" , opt_general_message_auto_scroll , 1. , 
     "Automatically scroll message window" }, 
   { F|S, "MessagePositionX" , opt_general_message_position0 , 650. , 
     "Horizontal position (in pixels) of the upper left corner of the message window" }, 
@@ -793,8 +793,6 @@ StringXNumber GeometryOptions_Number[] = {
   { F|O, "AutoCoherence" , opt_geometry_auto_coherence , 1. , 
     "Should all duplicate entities be automatically removed?" }, 
 
-  { F|O, "CirclePoints" , opt_geometry_circle_points, 20. ,
-    "Number of points used to draw a circle/ellipse" },
   { F,   "Clip" , opt_geometry_clip , 0.,
     "Enable clipping planes? (Plane[i]=2^i, i=0,...,5)" },
 
@@ -823,6 +821,8 @@ StringXNumber GeometryOptions_Number[] = {
 
   { F|O, "Normals" , opt_geometry_normals , 0. , 
     "Display size of normal vectors (in pixels)" }, 
+  { F|O, "NumSubEdges" , opt_geometry_num_sub_edges , 20. ,
+    "Number of edge subdivisions between control points when displaying curves" }, 
 
   { F|O, "OCCFixSmallEdges" , opt_geometry_occ_fix_small_edges , 1. , 
     "Fix small edges in STEP, IGES and BRep models" },
diff --git a/Common/GmshDefines.h b/Common/GmshDefines.h
index aeb8f1f15045c7078280ec8daae824077346ca86..f8def9cb1662362781d6e2e519b72bda76a9a500 100644
--- a/Common/GmshDefines.h
+++ b/Common/GmshDefines.h
@@ -101,9 +101,4 @@
 #define MESH_TRANSFINITE  1
 #define MESH_UNSTRUCTURED 2
 
-// Render mode
-#define GMSH_RENDER    1
-#define GMSH_SELECT    2
-#define GMSH_FEEDBACK  3
-
 #endif
diff --git a/Common/GmshMessage.cpp b/Common/GmshMessage.cpp
index ee8699e46e55949b9082fc5e15019c80fee60fcf..cd082efc55caa021857bdd1203ef473d5ad8ee16 100644
--- a/Common/GmshMessage.cpp
+++ b/Common/GmshMessage.cpp
@@ -17,9 +17,10 @@
 #endif
 
 #if defined(HAVE_FLTK)
+#include <FL/fl_ask.H>
 #include "GUI.h"
-#include "GUI_Extras.h"
-extern GUI *WID;
+#include "messageWindow.h"
+#include "extraDialogs.h"
 #endif
 
 extern Context_T CTX;
@@ -79,40 +80,9 @@ void Msg::Exit(int level)
 #if defined(HAVE_FLTK)
   // if we exit cleanly (level==0) and we are in full GUI mode, save
   // the persistent info to disk
-  if(WID && !CTX.batch && !_commRank) {
+  if(GUI::available() && !_commRank) {
     if(CTX.session_save) {
-      CTX.position[0] = WID->m_window->x();
-      CTX.position[1] = WID->m_window->y();
-      CTX.gl_position[0] = WID->g_window->x();
-      CTX.gl_position[1] = WID->g_window->y();
-      CTX.msg_position[0] = WID->msg_window->x();
-      CTX.msg_position[1] = WID->msg_window->y();
-      CTX.msg_size[0] = WID->msg_window->w();
-      CTX.msg_size[1] = WID->msg_window->h();
-      CTX.opt_position[0] = WID->opt_window->x();
-      CTX.opt_position[1] = WID->opt_window->y();
-      CTX.plugin_position[0] = WID->plugin_window->x();
-      CTX.plugin_position[1] = WID->plugin_window->y();
-      CTX.plugin_size[0] = WID->plugin_window->w();
-      CTX.plugin_size[1] = WID->plugin_window->h();
-      CTX.field_position[0] = WID->field_window->x();
-      CTX.field_position[1] = WID->field_window->y();
-      CTX.field_size[0] = WID->field_window->w();
-      CTX.field_size[1] = WID->field_window->h();
-      CTX.stat_position[0] = WID->stat_window->x();
-      CTX.stat_position[1] = WID->stat_window->y();
-      CTX.vis_position[0] = WID->vis_window->x();
-      CTX.vis_position[1] = WID->vis_window->y();
-      CTX.clip_position[0] = WID->clip_window->x();
-      CTX.clip_position[1] = WID->clip_window->y();
-      CTX.manip_position[0] = WID->manip_window->x();
-      CTX.manip_position[1] = WID->manip_window->y();
-      CTX.ctx_position[0] = WID->context_geometry_window->x();
-      CTX.ctx_position[1] = WID->context_geometry_window->y();
-      CTX.solver_position[0] = WID->solver[0].window->x();
-      CTX.solver_position[1] = WID->solver[0].window->y();
-      file_chooser_get_position(&CTX.file_chooser_position[0],
-                                &CTX.file_chooser_position[1]);
+      GUI::instance()->storeCurrentWindowsInfo();
       Print_Options(0, GMSH_SESSIONRC, 0, 0, CTX.session_filename_fullpath);
     }
     if(CTX.options_save)
@@ -139,13 +109,15 @@ void Msg::Fatal(const char *fmt, ...)
   if(_callback) (*_callback)("Fatal", str);
 
 #if defined(HAVE_FLTK)
-  if(WID){
-    WID->check();
+  if(GUI::available()){
+    GUI::instance()->check();
     std::string tmp = std::string("@C1@.") + "Fatal   : " + str;
-    WID->add_message(tmp.c_str());
-    WID->create_message_window();
-    WID->save_message(CTX.error_filename_fullpath);
-    WID->fatal_error(CTX.error_filename_fullpath);
+    GUI::instance()->messages->add(tmp.c_str());
+    GUI::instance()->messages->show();
+    GUI::instance()->messages->save(CTX.error_filename_fullpath);
+    fl_alert("A fatal error has occurred which will force Gmsh to abort.\n"
+             "The error messages have been saved in the following file:\n\n%s",
+             CTX.error_filename_fullpath);
   }
 #endif
 
@@ -176,11 +148,11 @@ void Msg::Error(const char *fmt, ...)
   if(_callback) (*_callback)("Error", str);
 
 #if defined(HAVE_FLTK)
-  if(WID){
-    WID->check();
+  if(GUI::available()){
+    GUI::instance()->check();
     std::string tmp = std::string("@C1@.") + "Error   : " + str;
-    WID->add_message(tmp.c_str());
-    WID->create_message_window();
+    GUI::instance()->messages->add(tmp.c_str());
+    GUI::instance()->messages->show();
   }
 #endif
 
@@ -208,10 +180,10 @@ void Msg::Warning(const char *fmt, ...)
   if(_callback) (*_callback)("Warning", str);
 
 #if defined(HAVE_FLTK)
-  if(WID){
-    WID->check();
+  if(GUI::available()){
+    GUI::instance()->check();
     std::string tmp = std::string("@C1@.") + "Warning : " + str;
-    WID->add_message(tmp.c_str());
+    GUI::instance()->messages->add(tmp.c_str());
   }
 #endif
 
@@ -234,10 +206,10 @@ void Msg::Info(const char *fmt, ...)
   if(_callback) (*_callback)("Info", str);
 
 #if defined(HAVE_FLTK)
-  if(WID){
-    WID->check();
+  if(GUI::available()){
+    GUI::instance()->check();
     std::string tmp = std::string("Info    : ") + str;
-    WID->add_message(tmp.c_str());
+    GUI::instance()->messages->add(tmp.c_str());
   }
 #endif
 
@@ -273,16 +245,16 @@ void Msg::Direct(int level, const char *fmt, ...)
   if(_callback) (*_callback)("Direct", str);
 
 #if defined(HAVE_FLTK)
-  if(WID){
-    WID->check();
+  if(GUI::available()){
+    GUI::instance()->check();
     std::string tmp;
     if(level < 3)
       tmp = std::string("@C1@.") + str;
     else
       tmp = std::string("@C4@.") + str;
-    WID->add_message(tmp.c_str());
+    GUI::instance()->messages->add(tmp.c_str());
     if(level == 1)
-      WID->create_message_window();
+      GUI::instance()->messages->show();
   }
 #endif
   
@@ -306,12 +278,12 @@ void Msg::StatusBar(int num, bool log, const char *fmt, ...)
   if(_callback && log) (*_callback)("Info", str);
 
 #if defined(HAVE_FLTK)
-  if(WID){
-    if(log) WID->check();
-    WID->set_status(str, num - 1);
+  if(GUI::available()){
+    if(log) GUI::instance()->check();
+    GUI::instance()->setStatus(str, num - 1);
     if(log){
       std::string tmp = std::string("Info    : ") + str;
-      WID->add_message(tmp.c_str());
+      GUI::instance()->messages->add(tmp.c_str());
     }
   }
 #endif
@@ -335,9 +307,9 @@ void Msg::Debug(const char *fmt, ...)
   if(_callback) (*_callback)("Debug", str);
 
 #if defined(HAVE_FLTK)
-  if(WID){
+  if(GUI::available()){
     std::string tmp = std::string("Debug   : ") + str;
-    WID->add_message(tmp.c_str());
+    GUI::instance()->messages->add(tmp.c_str());
   }
 #endif
 
@@ -370,9 +342,9 @@ void Msg::ProgressMeter(int n, int N, const char *fmt, ...)
     strcat(str, str2);
 
 #if defined(HAVE_FLTK)
-    if(WID){
-      WID->set_status(str, 1);
-      WID->check();
+    if(GUI::available()){
+      GUI::instance()->setStatus(str, 1);
+      GUI::instance()->check();
     }
 #endif
     if(CTX.terminal){
@@ -386,7 +358,7 @@ void Msg::ProgressMeter(int n, int N, const char *fmt, ...)
 
   if(n > N - 1){
 #if defined(HAVE_FLTK)
-    if(WID) WID->set_status("", 1);
+    if(GUI::available()) GUI::instance()->setStatus("", 1);
 #endif
     if(CTX.terminal){
       fprintf(stdout, "Done!                                              \r");
@@ -430,16 +402,16 @@ void Msg::PrintErrorCounter(const char *title)
   sprintf(err, "%5d error%s", _errorCount, _errorCount == 1 ? "" : "s");
 
 #if defined(HAVE_FLTK)
-  if(WID){
+  if(GUI::available()){
     std::string red("@C1@.");
-    WID->add_message((red + prefix + line).c_str());
-    WID->add_message((red + prefix + title).c_str());
-    WID->add_message((red + prefix + warn).c_str());
-    WID->add_message((red + prefix + err).c_str());
-    WID->add_message((red + prefix + help).c_str());
-    WID->add_message((red + prefix + line).c_str());
+    GUI::instance()->messages->add((red + prefix + line).c_str());
+    GUI::instance()->messages->add((red + prefix + title).c_str());
+    GUI::instance()->messages->add((red + prefix + warn).c_str());
+    GUI::instance()->messages->add((red + prefix + err).c_str());
+    GUI::instance()->messages->add((red + prefix + help).c_str());
+    GUI::instance()->messages->add((red + prefix + line).c_str());
     if(_errorCount){
-      WID->create_message_window();
+      GUI::instance()->messages->show();
       fl_beep();
     }
   }
@@ -461,7 +433,7 @@ double Msg::GetValue(const char *text, double defaultval)
   if(CTX.nopopup || _callback) return defaultval;
 
 #if defined(HAVE_FLTK)
-  if(!CTX.batch){
+  if(GUI::available()){
     char defaultstr[256];
     sprintf(defaultstr, "%.16g", defaultval);
     const char *ret = fl_input(text, defaultstr);
@@ -489,7 +461,7 @@ bool Msg::GetBinaryAnswer(const char *question, const char *yes,
   if(CTX.nopopup || _callback) return defaultval;
 
 #if defined(HAVE_FLTK)
-  if(!CTX.batch){
+  if(GUI::available()){
     if(fl_choice(question, no, yes, NULL))
       return true;
     else
diff --git a/Common/GmshUI.h b/Common/GmshUI.h
deleted file mode 100644
index 401b36cfd6fc6a32130e533c137480b61f698aeb..0000000000000000000000000000000000000000
--- a/Common/GmshUI.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
-//
-// See the LICENSE.txt file for license information. Please report all
-// bugs and problems to <gmsh@geuz.org>.
-
-#ifndef _GMSH_UI_H_
-#define _GMSH_UI_H_
-
-#if defined(HAVE_FLTK)
-#  include <FL/Fl.H>
-#  if (FL_MAJOR_VERSION != 1) || (FL_MINOR_VERSION != 1) || (FL_PATCH_VERSION < 7)
-#    error "Gmsh requires FLTK 1.1.7 or above"
-#  endif
-#  include <FL/gl.h>
-#  if defined(__APPLE__)
-#    include <OpenGL/glu.h>
-#  else
-#    include <GL/glu.h>
-#  endif
-# define GMSH_WINDOW_BOX FL_FLAT_BOX
-#endif
-
-// some Windows versions define min/max macros! 
-#if defined(WIN32)
-#undef min
-#undef max
-#endif
-
-#endif
diff --git a/Common/Makefile b/Common/Makefile
index f5bfab8874a5f29b298df1bf4ffa27dca866bfdd..cfe0ca46aa3fb10d1fb066560a13ec979fa40573 100644
--- a/Common/Makefile
+++ b/Common/Makefile
@@ -73,14 +73,11 @@ Gmsh${OBJEXT}: Gmsh.cpp GmshDefines.h ../Geo/GModel.h ../Geo/GVertex.h \
   ../Plugin/PluginManager.h
 GmshMessage${OBJEXT}: GmshMessage.cpp GmshMessage.h Gmsh.h Options.h \
   ../Post/ColorTable.h Context.h ../Geo/CGNSOptions.h \
-  ../Mesh/PartitionOptions.h OS.h ../Fltk/GUI.h ../Fltk/Opengl_Window.h \
-  ../Graphics/drawContext.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Fltk/Colorbar_Window.h ../Common/GmshUI.h ../Fltk/Popup_Button.h \
-  ../Fltk/SpherePosition_Widget.h ../Mesh/Field.h ../Post/PView.h \
-  ../Fltk/GUI_Extras.h
+  ../Mesh/PartitionOptions.h OS.h ../Fltk/GUI.h ../Fltk/messageWindow.h \
+  ../Fltk/extraDialogs.h
 GmshDaemon${OBJEXT}: GmshDaemon.cpp GmshMessage.h OS.h GmshSocket.h
-Options${OBJEXT}: Options.cpp GmshUI.h GmshDefines.h ../Geo/GModel.h \
-  ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
+Options${OBJEXT}: Options.cpp GmshDefines.h ../Geo/GModel.h ../Geo/GVertex.h \
+  ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GPoint.h \
   ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h \
   ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h \
@@ -95,12 +92,15 @@ Options${OBJEXT}: Options.cpp GmshUI.h GmshDefines.h ../Geo/GModel.h \
   ../Post/PViewData.h ../Post/adaptiveData.h ../Common/ListUtils.h \
   ../Numeric/GmshMatrix.h ../Common/GmshMessage.h \
   ../Plugin/PluginManager.h ../Plugin/Plugin.h ../Common/Options.h \
-  ../Post/PViewDataList.h ../Post/PViewData.h ../Fltk/Solvers.h \
-  ../Fltk/GUI.h ../Fltk/Opengl_Window.h ../Graphics/drawContext.h \
-  ../Fltk/Colorbar_Window.h ../Common/GmshUI.h ../Fltk/Popup_Button.h \
-  ../Fltk/SpherePosition_Widget.h
-CommandLine${OBJEXT}: CommandLine.cpp GmshUI.h GmshDefines.h GmshVersion.h \
-  GmshMessage.h OpenFile.h CommandLine.h Context.h ../Geo/CGNSOptions.h \
+  ../Post/PViewDataList.h ../Post/PViewData.h ../Fltk/GUI.h \
+  ../Fltk/Solvers.h ../Fltk/menuWindow.h ../Fltk/popupButton.h \
+  ../Fltk/graphicWindow.h ../Fltk/openglWindow.h \
+  ../Graphics/drawContext.h ../Fltk/optionWindow.h \
+  ../Fltk/spherePositionWidget.h ../Fltk/colorbarWindow.h \
+  ../Fltk/solverWindow.h ../Fltk/manipWindow.h ../Fltk/messageWindow.h \
+  ../Fltk/contextWindow.h ../Fltk/clippingWindow.h
+CommandLine${OBJEXT}: CommandLine.cpp GmshDefines.h GmshVersion.h GmshMessage.h \
+  OpenFile.h CommandLine.h Context.h ../Geo/CGNSOptions.h \
   ../Mesh/PartitionOptions.h Options.h ../Post/ColorTable.h \
   ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h \
   ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
@@ -127,11 +127,8 @@ OpenFile${OBJEXT}: OpenFile.cpp GmshMessage.h ../Geo/Geo.h \
   ../Geo/GEntity.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h Context.h \
   ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h OpenFile.h \
   CommandLine.h ../Graphics/ReadImg.h OS.h StringUtils.h \
-  ../Parser/Parser.h ../Post/PView.h ../Post/PViewData.h GmshUI.h \
-  ../Fltk/Draw.h ../Graphics/SelectBuffer.h ../Graphics/drawContext.h \
-  ../Fltk/GUI.h ../Fltk/Opengl_Window.h ../Fltk/Colorbar_Window.h \
-  ../Common/GmshUI.h ../Post/ColorTable.h ../Fltk/Popup_Button.h \
-  ../Fltk/SpherePosition_Widget.h ../Mesh/Field.h
+  ../Parser/Parser.h ../Post/PView.h ../Post/PViewData.h ../Fltk/GUI.h \
+  ../Fltk/Draw.h ../Graphics/SelectBuffer.h ../Graphics/drawContext.h
 CreateFile${OBJEXT}: CreateFile.cpp GmshMessage.h ../Geo/GModel.h \
   ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GPoint.h \
@@ -142,11 +139,10 @@ CreateFile${OBJEXT}: CreateFile.cpp GmshMessage.h ../Geo/GModel.h \
   ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h GmshDefines.h StringUtils.h Context.h \
   ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h Options.h \
-  ../Post/ColorTable.h GmshUI.h ../Graphics/gl2ps.h ../Graphics/gl2gif.h \
-  ../Graphics/PixelBuffer.h ../Common/GmshUI.h ../Common/GmshMessage.h \
-  ../Fltk/Draw.h ../Common/MallocUtils.h ../Graphics/gl2jpeg.h \
-  ../Graphics/PixelBuffer.h ../Graphics/gl2png.h \
-  ../Graphics/PixelBuffer.h ../Graphics/gl2ppm.h \
+  ../Post/ColorTable.h ../Graphics/gl2ps.h ../Graphics/gl2gif.h \
+  ../Graphics/PixelBuffer.h ../Common/GmshMessage.h ../Fltk/Draw.h \
+  ../Common/MallocUtils.h ../Graphics/gl2jpeg.h ../Graphics/PixelBuffer.h \
+  ../Graphics/gl2png.h ../Graphics/PixelBuffer.h ../Graphics/gl2ppm.h \
   ../Graphics/PixelBuffer.h ../Graphics/gl2yuv.h \
   ../Graphics/PixelBuffer.h
 Visibility${OBJEXT}: Visibility.cpp Visibility.h GmshDefines.h ../Geo/GVertex.h \
diff --git a/Common/OpenFile.cpp b/Common/OpenFile.cpp
index f536183816e58dbfb2d90ef3a323426cee776a70..dc951666a31fbc7b91f9367df2afcc16adb8964e 100644
--- a/Common/OpenFile.cpp
+++ b/Common/OpenFile.cpp
@@ -25,11 +25,10 @@
 #endif
 
 #if defined(HAVE_FLTK)
-#include "GmshUI.h"
+#include <FL/fl_ask.H>
+#include "GUI.h"
 #include "Draw.h"
 #include "SelectBuffer.h"
-#include "GUI.h"
-extern GUI *WID;
 #endif
 
 extern Context_T CTX;
@@ -196,8 +195,8 @@ int ParseFile(const char *f, int close, int warn_if_missing)
   gmsh_yyviewindex = yyviewindex_old;
 
 #if defined(HAVE_FLTK) && !defined(HAVE_NO_POST)
-  if(!CTX.batch && numViewsBefore != (int)PView::list.size())
-    WID->update_views();
+  if(GUI::available() && numViewsBefore != (int)PView::list.size())
+    GUI::instance()->updateViews();
 #endif
 
   return 1;
@@ -230,7 +229,8 @@ void SetProjectName(const char *name)
   GModel::current()->setName(base);
     
 #if defined(HAVE_FLTK)
-  if(!CTX.batch) WID->set_title(CTX.filename);
+  if(GUI::available())
+    GUI::instance()->setGraphicTitle(CTX.filename);
 #endif
 }
 
@@ -261,7 +261,7 @@ int MergeFile(const char *name, int warn_if_missing)
   SplitFileName(name, no_ext, ext, base);
 
 #if defined(HAVE_FLTK)
-  if(!CTX.batch) {
+  if(GUI::available()) {
     if(!strcmp(ext, ".gz")) {
       // the real solution would be to rewrite all our I/O functions in
       // terms of gzFile, but until then, this is better than nothing
@@ -382,8 +382,8 @@ int MergeFile(const char *name, int warn_if_missing)
   CTX.mesh.changed = ENT_ALL;
 
 #if defined(HAVE_FLTK) && !defined(HAVE_NO_POST)
-  if(!CTX.batch && numViewsBefore != (int)PView::list.size())
-    WID->update_views();
+  if(GUI::available() && numViewsBefore != (int)PView::list.size())
+    GUI::instance()->updateViews();
 #endif
 
   if(!status) Msg::Error("Error loading '%s'", name);
@@ -425,19 +425,19 @@ void OpenProject(const char *name)
   CTX.threads_lock = 0;
 
 #if defined(HAVE_FLTK)
-  if(!CTX.batch){
-    WID->reset_visibility();
-    WID->update_views();
-    WID->update_fields();
+  if(GUI::available()){
+    GUI::instance()->resetVisibility();
+    GUI::instance()->updateViews();
+    GUI::instance()->updateFields();
+    ZeroHighlight();
   }
-  ZeroHighlight();
 #endif
 }
 
 void OpenProjectMacFinder(const char *filename)
 {
   static int first = 1;
-  if(first || CTX.batch){
+  if(first || !GUI::available()){
     // just copy the filename: it will be opened when the GUI is ready
     // in main()
     strncpy(CTX.filename, filename, 255);
diff --git a/Common/Options.cpp b/Common/Options.cpp
index 80bdd1f60f97bfe960f01a4c2fc5d4af425f2ca0..f126f5b3f839be85cde5699d073031ab3897bbd3 100644
--- a/Common/Options.cpp
+++ b/Common/Options.cpp
@@ -5,7 +5,6 @@
 
 #include <string.h>
 #include <stdlib.h>
-#include "GmshUI.h"
 #include "GmshDefines.h"
 #include "GModel.h"
 #include "GmshMessage.h"
@@ -27,9 +26,17 @@
 #endif
 
 #if defined(HAVE_FLTK)
-#include "Solvers.h"
+#include <FL/Fl_Tooltip.H>
 #include "GUI.h"
-extern GUI *WID;
+#include "Solvers.h"
+#include "menuWindow.h"
+#include "graphicWindow.h"
+#include "optionWindow.h"
+#include "solverWindow.h"
+#include "manipWindow.h"
+#include "messageWindow.h"
+#include "contextWindow.h"
+#include "clippingWindow.h"
 extern void activate_cb(Fl_Widget* w, void* data);
 #endif
 
@@ -469,7 +476,6 @@ void Init_Options(int num)
   CTX.min[0] = CTX.min[1] = CTX.min[2] = 0.0;
   CTX.max[0] = CTX.max[1] = CTX.max[2] = 1.0;
   CTX.cg[0] = CTX.cg[1] = CTX.cg[2] = 0.0;
-  CTX.render_mode = GMSH_RENDER;
   CTX.polygon_offset = 0;
   CTX.printing = 0;
   CTX.mesh_timer[0] = CTX.mesh_timer[1] = CTX.mesh_timer[2] = 0.;
@@ -923,8 +929,8 @@ const char *opt_general_axes_label0(OPT_ARGS_STR)
   if(action & GMSH_SET)
     strcpy(CTX.axes_label[0], val);
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_input[6]->value(CTX.axes_label[0]);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.input[6]->value(CTX.axes_label[0]);
 #endif
   return CTX.axes_label[0];
 }
@@ -934,8 +940,8 @@ const char *opt_general_axes_label1(OPT_ARGS_STR)
   if(action & GMSH_SET)
     strcpy(CTX.axes_label[1], val);
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_input[7]->value(CTX.axes_label[1]);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.input[7]->value(CTX.axes_label[1]);
 #endif
   return CTX.axes_label[1];
 }
@@ -945,8 +951,8 @@ const char *opt_general_axes_label2(OPT_ARGS_STR)
   if(action & GMSH_SET)
     strcpy(CTX.axes_label[2], val);
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_input[8]->value(CTX.axes_label[2]);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.input[8]->value(CTX.axes_label[2]);
 #endif
   return CTX.axes_label[2];
 }
@@ -956,8 +962,8 @@ const char *opt_general_axes_format0(OPT_ARGS_STR)
   if(action & GMSH_SET)
     strcpy(CTX.axes_format[0], val);
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_input[3]->value(CTX.axes_format[0]);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.input[3]->value(CTX.axes_format[0]);
 #endif
   return CTX.axes_format[0];
 }
@@ -967,8 +973,8 @@ const char *opt_general_axes_format1(OPT_ARGS_STR)
   if(action & GMSH_SET)
     strcpy(CTX.axes_format[1], val);
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_input[4]->value(CTX.axes_format[1]);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.input[4]->value(CTX.axes_format[1]);
 #endif
   return CTX.axes_format[1];
 }
@@ -978,8 +984,8 @@ const char *opt_general_axes_format2(OPT_ARGS_STR)
   if(action & GMSH_SET)
     strcpy(CTX.axes_format[2], val);
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_input[5]->value(CTX.axes_format[2]);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.input[5]->value(CTX.axes_format[2]);
 #endif
   return CTX.axes_format[2];
 }
@@ -1004,8 +1010,8 @@ const char *opt_general_default_filename(OPT_ARGS_STR)
     strcat(CTX.default_filename_fullpath, CTX.default_filename);
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_input[0]->value(CTX.default_filename);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.input[0]->value(CTX.default_filename);
 #endif
   return CTX.default_filename;
 }
@@ -1055,8 +1061,8 @@ const char *opt_general_editor(OPT_ARGS_STR)
   if(action & GMSH_SET)
     CTX.editor = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_input[1]->value(CTX.editor);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.input[1]->value(CTX.editor);
 #endif
   return CTX.editor;
 }
@@ -1066,8 +1072,8 @@ const char *opt_general_web_browser(OPT_ARGS_STR)
   if(action & GMSH_SET)
     CTX.web_browser = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_input[2]->value(CTX.web_browser);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.input[2]->value(CTX.web_browser);
 #endif
   return CTX.web_browser;
 }
@@ -1089,8 +1095,8 @@ const char *opt_general_graphics_font(OPT_ARGS_STR)
     CTX.gl_font = GetFontName(index);
     CTX.gl_font_enum = GetFontEnum(index);
   }
-  if(WID && (action & GMSH_GUI)){
-    WID->gen_choice[1]->value(index);
+  if(GUI::available() && (action & GMSH_GUI)){
+    GUI::instance()->options->general.choice[1]->value(index);
   }
 #endif
   return CTX.gl_font;
@@ -1101,8 +1107,8 @@ const char *opt_solver_socket_name(OPT_ARGS_STR)
   if(action & GMSH_SET)
     CTX.solver.socket_name = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->solver_input[0]->value(CTX.solver.socket_name);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->solver.input[0]->value(CTX.solver.socket_name);
 #endif
   return CTX.solver.socket_name;
 }
@@ -1112,8 +1118,8 @@ const char *opt_solver_name(OPT_ARGS_STR)
 #if defined(HAVE_FLTK)
   if(action & GMSH_SET)
     strcpy(SINFO[num].name, val);
-  if(WID && (action & GMSH_GUI))
-    WID->solver[num].window->label(SINFO[num].name);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->solver[num]->win->label(SINFO[num].name);
   return SINFO[num].name;
 #else
   return "undefined";
@@ -1150,8 +1156,8 @@ const char *opt_solver_executable(OPT_ARGS_STR)
 #if defined(HAVE_FLTK)
   if(action & GMSH_SET)
     strcpy(SINFO[num].executable_name, val);
-  if(WID && (action & GMSH_GUI))
-    WID->solver[num].input[2]->value(SINFO[num].executable_name);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->solver[num]->input[2]->value(SINFO[num].executable_name);
   return SINFO[num].executable_name;
 #else
   return "undefined";
@@ -1296,8 +1302,8 @@ const char *opt_solver_mesh_command(OPT_ARGS_STR)
 #if defined(HAVE_FLTK)
   if(action & GMSH_SET)
     strcpy(SINFO[num].mesh_command, val);
-  if(WID && (action & GMSH_GUI))
-    WID->solver[num].input[1]->value(SINFO[num].mesh_name);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->solver[num]->input[1]->value(SINFO[num].mesh_name);
   return SINFO[num].mesh_command;
 #else
   return "undefined";
@@ -1980,9 +1986,8 @@ const char *opt_solver_fifth_button_command4(OPT_ARGS_STR)
 #if defined(HAVE_FLTK)
 int _gui_action_valid(int action, int num)
 {
-  return ((WID) &&
-          (action & GMSH_GUI) && 
-          (num == WID->view_number));
+  if(!GUI::available()) return 0;
+  return (action & GMSH_GUI) && (num == GUI::instance()->options->view.index);
 }
 #endif
 
@@ -1994,15 +1999,16 @@ const char *opt_view_name(OPT_ARGS_STR)
   if(action & GMSH_SET) {
     data->setName(val);
 #if defined(HAVE_FLTK)
-    if(WID && num >= 0 && num < (int)WID->m_toggle_butt.size()) {
-      WID->m_toggle_butt[num]->copy_label(data->getName().c_str());
-      WID->m_toggle_butt[num]->redraw();
+    if(GUI::available() && num >= 0 && 
+       num < (int)GUI::instance()->menu->toggle.size()) {
+      GUI::instance()->menu->toggle[num]->copy_label(data->getName().c_str());
+      GUI::instance()->menu->toggle[num]->redraw();
     }
 #endif
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_input[0]->value(data->getName().c_str());
+    GUI::instance()->options->view.input[0]->value(data->getName().c_str());
   }
 #endif
   return data->getName().c_str();
@@ -2020,7 +2026,7 @@ const char *opt_view_format(OPT_ARGS_STR)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_input[1]->value(opt->Format);
+    GUI::instance()->options->view.input[1]->value(opt->Format);
 #endif
   return opt->Format;
 #else
@@ -2048,7 +2054,7 @@ const char *opt_view_axes_label0(OPT_ARGS_STR)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_input[10]->value(opt->AxesLabel[0]);
+    GUI::instance()->options->view.input[10]->value(opt->AxesLabel[0]);
 #endif
   return opt->AxesLabel[0];
 #else
@@ -2065,7 +2071,7 @@ const char *opt_view_axes_label1(OPT_ARGS_STR)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_input[11]->value(opt->AxesLabel[1]);
+    GUI::instance()->options->view.input[11]->value(opt->AxesLabel[1]);
 #endif
   return opt->AxesLabel[1];
 #else
@@ -2082,7 +2088,7 @@ const char *opt_view_axes_label2(OPT_ARGS_STR)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_input[12]->value(opt->AxesLabel[2]);
+    GUI::instance()->options->view.input[12]->value(opt->AxesLabel[2]);
 #endif
   return opt->AxesLabel[2];
 #else
@@ -2099,7 +2105,7 @@ const char *opt_view_axes_format0(OPT_ARGS_STR)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_input[7]->value(opt->AxesFormat[0]);
+    GUI::instance()->options->view.input[7]->value(opt->AxesFormat[0]);
 #endif
   return opt->AxesFormat[0];
 #else
@@ -2116,7 +2122,7 @@ const char *opt_view_axes_format1(OPT_ARGS_STR)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_input[8]->value(opt->AxesFormat[1]);
+    GUI::instance()->options->view.input[8]->value(opt->AxesFormat[1]);
 #endif
   return opt->AxesFormat[1];
 #else
@@ -2133,7 +2139,7 @@ const char *opt_view_axes_format2(OPT_ARGS_STR)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_input[9]->value(opt->AxesFormat[2]);
+    GUI::instance()->options->view.input[9]->value(opt->AxesFormat[2]);
 #endif
   return opt->AxesFormat[2];
 #else
@@ -2151,7 +2157,7 @@ const char *opt_view_gen_raise0(OPT_ARGS_STR)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_input[4]->value(opt->GenRaiseX);
+    GUI::instance()->options->view.input[4]->value(opt->GenRaiseX);
 #endif
   return opt->GenRaiseX;
 #else
@@ -2169,7 +2175,7 @@ const char *opt_view_gen_raise1(OPT_ARGS_STR)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_input[5]->value(opt->GenRaiseY);
+    GUI::instance()->options->view.input[5]->value(opt->GenRaiseY);
 #endif
   return opt->GenRaiseY;
 #else
@@ -2187,7 +2193,7 @@ const char *opt_view_gen_raise2(OPT_ARGS_STR)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_input[6]->value(opt->GenRaiseZ);
+    GUI::instance()->options->view.input[6]->value(opt->GenRaiseZ);
 #endif
   return opt->GenRaiseZ;
 #else
@@ -2397,8 +2403,8 @@ double opt_general_graphics_fontsize(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.gl_fontsize = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_value[12]->value(CTX.gl_fontsize);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.value[12]->value(CTX.gl_fontsize);
 #endif
   return CTX.gl_fontsize;
 }
@@ -2408,10 +2414,10 @@ double opt_general_viewport2(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.tmp_viewport[2] = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID){
+  if(GUI::available()){
     if(action & GMSH_SET)
-      WID->g_opengl_window->getDrawContext()->viewport[2] = (int)val;
-    return WID->g_opengl_window->getDrawContext()->viewport[2];
+      GUI::instance()->graph[0]->gl->getDrawContext()->viewport[2] = (int)val;
+    return GUI::instance()->graph[0]->gl->getDrawContext()->viewport[2];
   }
 #endif
   return CTX.tmp_viewport[2];
@@ -2422,10 +2428,10 @@ double opt_general_viewport3(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.tmp_viewport[3] = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID){
+  if(GUI::available()){
     if(action & GMSH_SET)
-      WID->g_opengl_window->getDrawContext()->viewport[3] = (int)val;
-    return WID->g_opengl_window->getDrawContext()->viewport[3];
+      GUI::instance()->graph[0]->gl->getDrawContext()->viewport[3] = (int)val;
+    return GUI::instance()->graph[0]->gl->getDrawContext()->viewport[3];
   }
 #endif
   return CTX.tmp_viewport[3];
@@ -2436,8 +2442,8 @@ double opt_general_polygon_offset_always(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.polygon_offset_always = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_butt[4]->value(CTX.polygon_offset_always);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.butt[4]->value(CTX.polygon_offset_always);
 #endif
   return CTX.polygon_offset_always;
 }
@@ -2447,8 +2453,8 @@ double opt_general_polygon_offset_factor(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.polygon_offset_factor = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_value[15]->value(CTX.polygon_offset_factor);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.value[15]->value(CTX.polygon_offset_factor);
 #endif
   return CTX.polygon_offset_factor;
 }
@@ -2458,8 +2464,8 @@ double opt_general_polygon_offset_units(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.polygon_offset_units = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_value[16]->value(CTX.polygon_offset_units);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.value[16]->value(CTX.polygon_offset_units);
 #endif
   return CTX.polygon_offset_units;
 }
@@ -2574,8 +2580,8 @@ double opt_general_message_auto_scroll(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.msg_auto_scroll = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->msg_butt->value(CTX.msg_auto_scroll);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->messages->butt->value(CTX.msg_auto_scroll);
 #endif
   return CTX.msg_auto_scroll;
 }
@@ -2711,8 +2717,8 @@ double opt_general_session_save(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.session_save = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_butt[8]->value(CTX.session_save);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.butt[8]->value(CTX.session_save);
 #endif
   return CTX.session_save;
 }
@@ -2722,8 +2728,8 @@ double opt_general_options_save(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.options_save = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_butt[9]->value(CTX.options_save);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.butt[9]->value(CTX.options_save);
 #endif
   return CTX.options_save;
 }
@@ -2733,8 +2739,8 @@ double opt_general_confirm_overwrite(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.confirm_overwrite = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_butt[14]->value(CTX.confirm_overwrite);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.butt[14]->value(CTX.confirm_overwrite);
 #endif
   return CTX.confirm_overwrite;
 }
@@ -2744,10 +2750,10 @@ double opt_general_rotation0(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.tmp_r[0] = val;
 #if defined(HAVE_FLTK)
-  if(WID){
+  if(GUI::available()){
     if(action & GMSH_SET)
-      WID->g_opengl_window->getDrawContext()->r[0] = val;
-    return WID->g_opengl_window->getDrawContext()->r[0];
+      GUI::instance()->graph[0]->gl->getDrawContext()->r[0] = val;
+    return GUI::instance()->graph[0]->gl->getDrawContext()->r[0];
   }
 #endif
   return CTX.tmp_r[0];
@@ -2758,10 +2764,10 @@ double opt_general_rotation1(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.tmp_r[1] = val;
 #if defined(HAVE_FLTK)
-  if(WID){
+  if(GUI::available()){
     if(action & GMSH_SET)
-      WID->g_opengl_window->getDrawContext()->r[1] = val;
-    return WID->g_opengl_window->getDrawContext()->r[1];
+      GUI::instance()->graph[0]->gl->getDrawContext()->r[1] = val;
+    return GUI::instance()->graph[0]->gl->getDrawContext()->r[1];
   }
 #endif
   return CTX.tmp_r[1];
@@ -2772,10 +2778,10 @@ double opt_general_rotation2(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.tmp_r[2] = val;
 #if defined(HAVE_FLTK)
-  if(WID){
+  if(GUI::available()){
     if(action & GMSH_SET)
-      WID->g_opengl_window->getDrawContext()->r[2] = val;
-    return WID->g_opengl_window->getDrawContext()->r[2];
+      GUI::instance()->graph[0]->gl->getDrawContext()->r[2] = val;
+    return GUI::instance()->graph[0]->gl->getDrawContext()->r[2];
   }
 #endif
   return CTX.tmp_r[2];
@@ -2786,8 +2792,8 @@ double opt_general_rotation_center0(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.rotation_center[0] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_value[8]->value(CTX.rotation_center[0]);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.value[8]->value(CTX.rotation_center[0]);
 #endif
   return CTX.rotation_center[0];
 }
@@ -2797,8 +2803,8 @@ double opt_general_rotation_center1(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.rotation_center[1] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_value[9]->value(CTX.rotation_center[1]);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.value[9]->value(CTX.rotation_center[1]);
 #endif
   return CTX.rotation_center[1];
 }
@@ -2808,8 +2814,8 @@ double opt_general_rotation_center2(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.rotation_center[2] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_value[10]->value(CTX.rotation_center[2]);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.value[10]->value(CTX.rotation_center[2]);
 #endif
   return CTX.rotation_center[2];
 }
@@ -2819,12 +2825,12 @@ double opt_general_quaternion0(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.tmp_quaternion[0] = val;
 #if defined(HAVE_FLTK)
-  if(WID){
+  if(GUI::available()){
     if(action & GMSH_SET)
-      WID->g_opengl_window->getDrawContext()->quaternion[0] = val;
+      GUI::instance()->graph[0]->gl->getDrawContext()->quaternion[0] = val;
     if(action & GMSH_GUI)
-      WID->update_manip_window();
-    return WID->g_opengl_window->getDrawContext()->quaternion[0];
+      GUI::instance()->manip->update();
+    return GUI::instance()->graph[0]->gl->getDrawContext()->quaternion[0];
   }
 #endif
   return CTX.tmp_quaternion[0];
@@ -2835,12 +2841,12 @@ double opt_general_quaternion1(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.tmp_quaternion[1] = val;
 #if defined(HAVE_FLTK)
-  if(WID){
+  if(GUI::available()){
     if(action & GMSH_SET)
-      WID->g_opengl_window->getDrawContext()->quaternion[1] = val;
+      GUI::instance()->graph[0]->gl->getDrawContext()->quaternion[1] = val;
     if(action & GMSH_GUI)
-      WID->update_manip_window();
-    return WID->g_opengl_window->getDrawContext()->quaternion[1];
+      GUI::instance()->manip->update();
+    return GUI::instance()->graph[0]->gl->getDrawContext()->quaternion[1];
   }
 #endif
   return CTX.tmp_quaternion[1];
@@ -2851,12 +2857,12 @@ double opt_general_quaternion2(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.tmp_quaternion[2] = val;
 #if defined(HAVE_FLTK)
-  if(WID){
+  if(GUI::available()){
     if(action & GMSH_SET)
-      WID->g_opengl_window->getDrawContext()->quaternion[2] = val;
+      GUI::instance()->graph[0]->gl->getDrawContext()->quaternion[2] = val;
     if(action & GMSH_GUI)
-      WID->update_manip_window();
-    return WID->g_opengl_window->getDrawContext()->quaternion[2];
+      GUI::instance()->manip->update();
+    return GUI::instance()->graph[0]->gl->getDrawContext()->quaternion[2];
   }
 #endif
   return CTX.tmp_quaternion[2];
@@ -2867,12 +2873,12 @@ double opt_general_quaternion3(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.tmp_quaternion[3] = val;
 #if defined(HAVE_FLTK)
-  if(WID){
+  if(GUI::available()){
     if(action & GMSH_SET)
-      WID->g_opengl_window->getDrawContext()->quaternion[3] = val;
+      GUI::instance()->graph[0]->gl->getDrawContext()->quaternion[3] = val;
     if(action & GMSH_GUI)
-      WID->update_manip_window();
-    return WID->g_opengl_window->getDrawContext()->quaternion[3];
+      GUI::instance()->manip->update();
+    return GUI::instance()->graph[0]->gl->getDrawContext()->quaternion[3];
   }
 #endif
   return CTX.tmp_quaternion[3];
@@ -2883,12 +2889,12 @@ double opt_general_translation0(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.tmp_t[0] = val;
 #if defined(HAVE_FLTK)
-  if(WID){
+  if(GUI::available()){
     if(action & GMSH_SET)
-      WID->g_opengl_window->getDrawContext()->t[0] = val;
+      GUI::instance()->graph[0]->gl->getDrawContext()->t[0] = val;
     if(action & GMSH_GUI)
-      WID->update_manip_window();
-    return WID->g_opengl_window->getDrawContext()->t[0];
+      GUI::instance()->manip->update();
+    return GUI::instance()->graph[0]->gl->getDrawContext()->t[0];
   }
 #endif
   return CTX.tmp_t[0];
@@ -2899,12 +2905,12 @@ double opt_general_translation1(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.tmp_t[1] = val;
 #if defined(HAVE_FLTK)
-  if(WID){
+  if(GUI::available()){
     if(action & GMSH_SET)
-      WID->g_opengl_window->getDrawContext()->t[1] = val;
+      GUI::instance()->graph[0]->gl->getDrawContext()->t[1] = val;
     if(action & GMSH_GUI)
-      WID->update_manip_window();
-    return WID->g_opengl_window->getDrawContext()->t[1];
+      GUI::instance()->manip->update();
+    return GUI::instance()->graph[0]->gl->getDrawContext()->t[1];
   }
 #endif
   return CTX.tmp_t[1];
@@ -2915,12 +2921,12 @@ double opt_general_translation2(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.tmp_t[2] = val;
 #if defined(HAVE_FLTK)
-  if(WID){
+  if(GUI::available()){
     if(action & GMSH_SET)
-      WID->g_opengl_window->getDrawContext()->t[2] = val;
+      GUI::instance()->graph[0]->gl->getDrawContext()->t[2] = val;
     if(action & GMSH_GUI)
-      WID->update_manip_window();
-    return WID->g_opengl_window->getDrawContext()->t[2];
+      GUI::instance()->manip->update();
+    return GUI::instance()->graph[0]->gl->getDrawContext()->t[2];
   }
 #endif
   return CTX.tmp_t[2];
@@ -2931,12 +2937,12 @@ double opt_general_scale0(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.tmp_s[0] = val ? val : 1.0;
 #if defined(HAVE_FLTK)
-  if(WID){
+  if(GUI::available()){
     if(action & GMSH_SET)
-      WID->g_opengl_window->getDrawContext()->s[0] = val ? val : 1.0;
+      GUI::instance()->graph[0]->gl->getDrawContext()->s[0] = val ? val : 1.0;
     if(action & GMSH_GUI)
-      WID->update_manip_window();
-    return WID->g_opengl_window->getDrawContext()->s[0];
+      GUI::instance()->manip->update();
+    return GUI::instance()->graph[0]->gl->getDrawContext()->s[0];
   }
 #endif
   return CTX.tmp_s[0];
@@ -2947,12 +2953,12 @@ double opt_general_scale1(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.tmp_s[1] = val ? val : 1.0;
 #if defined(HAVE_FLTK)
-  if(WID){
+  if(GUI::available()){
     if(action & GMSH_SET)
-      WID->g_opengl_window->getDrawContext()->s[1] = val ? val : 1.0;
+      GUI::instance()->graph[0]->gl->getDrawContext()->s[1] = val ? val : 1.0;
     if(action & GMSH_GUI)
-      WID->update_manip_window();
-    return WID->g_opengl_window->getDrawContext()->s[1];
+      GUI::instance()->manip->update();
+    return GUI::instance()->graph[0]->gl->getDrawContext()->s[1];
   }
 #endif
   return CTX.tmp_s[1];
@@ -2963,12 +2969,12 @@ double opt_general_scale2(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.tmp_s[2] = val ? val : 1.0;
 #if defined(HAVE_FLTK)
-  if(WID){
+  if(GUI::available()){
     if(action & GMSH_SET)
-      WID->g_opengl_window->getDrawContext()->s[2] = val ? val : 1.0;
+      GUI::instance()->graph[0]->gl->getDrawContext()->s[2] = val ? val : 1.0;
     if(action & GMSH_GUI)
-      WID->update_manip_window();
-    return WID->g_opengl_window->getDrawContext()->s[2];
+      GUI::instance()->manip->update();
+    return GUI::instance()->graph[0]->gl->getDrawContext()->s[2];
   }
 #endif
   return CTX.tmp_s[2];
@@ -2984,8 +2990,8 @@ double opt_general_clip_factor(OPT_ARGS_NUM)
       CTX.clip_factor = val;    
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_value[14]->value(CTX.clip_factor);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.value[14]->value(CTX.clip_factor);
 #endif
   return CTX.clip_factor;
 }
@@ -2995,8 +3001,8 @@ double opt_general_point_size(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.point_size = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_value[6]->value(CTX.point_size);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.value[6]->value(CTX.point_size);
 #endif
   return CTX.point_size;
 }
@@ -3006,8 +3012,8 @@ double opt_general_line_width(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.line_width = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_value[7]->value(CTX.line_width);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.value[7]->value(CTX.line_width);
 #endif
   return CTX.line_width;
 }
@@ -3017,8 +3023,8 @@ double opt_general_shine(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.shine = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_value[1]->value(CTX.shine);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.value[1]->value(CTX.shine);
 #endif
   return CTX.shine;
 }
@@ -3028,8 +3034,8 @@ double opt_general_shine_exponent(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.shine_exponent = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_value[0]->value(CTX.shine_exponent);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.value[0]->value(CTX.shine_exponent);
 #endif
   return CTX.shine_exponent;
 }
@@ -3040,8 +3046,8 @@ double opt_general_verbosity(OPT_ARGS_NUM)
     Msg::SetVerbosity((int)val);
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_value[5]->value(Msg::GetVerbosity());
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.value[5]->value(Msg::GetVerbosity());
 #endif
   return Msg::GetVerbosity();
 }
@@ -3065,8 +3071,8 @@ double opt_general_terminal(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.terminal = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_butt[7]->value(CTX.terminal);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.butt[7]->value(CTX.terminal);
 #endif
   return CTX.terminal;
 }
@@ -3083,8 +3089,8 @@ double opt_general_tooltips(OPT_ARGS_NUM)
 #endif
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_butt[13]->value(CTX.tooltips);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.butt[13]->value(CTX.tooltips);
 #endif
   return CTX.tooltips;
 }
@@ -3094,14 +3100,16 @@ double opt_general_orthographic(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.ortho = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)) {
+  if(GUI::available() && (action & GMSH_GUI)) {
     if(CTX.ortho){
-      WID->gen_choice[2]->value(0);
-      if(!CTX.batch) Msg::StatusBar(2, false, "Orthographic projection");
+      GUI::instance()->options->general.choice[2]->value(0);
+      if(GUI::available())
+        Msg::StatusBar(2, false, "Orthographic projection");
     }
     else{
-      WID->gen_choice[2]->value(1);
-      if(!CTX.batch) Msg::StatusBar(2, false, "Perspective projection");
+      GUI::instance()->options->general.choice[2]->value(1);
+      if(GUI::available())
+        Msg::StatusBar(2, false, "Perspective projection");
     }
   }
 #endif
@@ -3113,16 +3121,18 @@ double opt_general_mouse_selection(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.mouse_selection = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)) {
+  if(GUI::available() && (action & GMSH_GUI)) {
     if(CTX.mouse_selection){
-      if(!CTX.batch) Msg::StatusBar(2, false, "Mouse selection ON");
-      WID->g_status_butt[9]->color(FL_BACKGROUND_COLOR);
+      if(GUI::available())
+        Msg::StatusBar(2, false, "Mouse selection ON");
+      GUI::instance()->graph[0]->butt[9]->color(FL_BACKGROUND_COLOR);
     }
     else{
-      if(!CTX.batch) Msg::StatusBar(2, false, "Mouse selection OFF");
-      WID->g_status_butt[9]->color(FL_RED);
+      if(GUI::available())
+        Msg::StatusBar(2, false, "Mouse selection OFF");
+      GUI::instance()->graph[0]->butt[9]->color(FL_RED);
     }
-    WID->g_status_butt[9]->redraw();
+    GUI::instance()->graph[0]->butt[9]->redraw();
   }
 #endif
   return CTX.mouse_selection;
@@ -3133,8 +3143,8 @@ double opt_general_mouse_hover_meshes(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.mouse_hover_meshes = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_butt[11]->value(CTX.mouse_hover_meshes);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.butt[11]->value(CTX.mouse_hover_meshes);
 #endif
   return CTX.mouse_hover_meshes;
 }
@@ -3144,8 +3154,8 @@ double opt_general_fast_redraw(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.fast_redraw = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)){
-    WID->gen_butt[2]->value(CTX.fast_redraw);
+  if(GUI::available() && (action & GMSH_GUI)){
+    GUI::instance()->options->general.butt[2]->value(CTX.fast_redraw);
     activate_cb(NULL, (void*)"fast_redraw");
   }
 #endif
@@ -3157,8 +3167,8 @@ double opt_general_draw_bounding_box(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.draw_bbox = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_butt[6]->value(CTX.draw_bbox);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.butt[6]->value(CTX.draw_bbox);
 #endif
   return CTX.draw_bbox;
 }
@@ -3208,8 +3218,8 @@ double opt_general_axes(OPT_ARGS_NUM)
       CTX.axes = 0;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)){
-    WID->gen_choice[4]->value(CTX.axes);
+  if(GUI::available() && (action & GMSH_GUI)){
+    GUI::instance()->options->general.choice[4]->value(CTX.axes);
     activate_cb(NULL, (void*)"general_axes");
   }
 #endif
@@ -3222,8 +3232,8 @@ double opt_general_axes_mikado(OPT_ARGS_NUM)
     CTX.axes_mikado = (int)val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_butt[16]->value(CTX.axes_mikado);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.butt[16]->value(CTX.axes_mikado);
 #endif
   return CTX.axes_mikado;
 }
@@ -3233,8 +3243,8 @@ double opt_general_axes_auto_position(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.axes_auto_position = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)){
-    WID->gen_butt[0]->value(CTX.axes_auto_position);
+  if(GUI::available() && (action & GMSH_GUI)){
+    GUI::instance()->options->general.butt[0]->value(CTX.axes_auto_position);
     activate_cb(NULL, (void*)"general_axes_auto");
   }
 #endif
@@ -3246,8 +3256,8 @@ double opt_general_axes_tics0(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.axes_tics[0] = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_value[17]->value(CTX.axes_tics[0]);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.value[17]->value(CTX.axes_tics[0]);
 #endif
   return CTX.axes_tics[0];
 }
@@ -3257,8 +3267,8 @@ double opt_general_axes_tics1(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.axes_tics[1] = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_value[18]->value(CTX.axes_tics[1]);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.value[18]->value(CTX.axes_tics[1]);
 #endif
   return CTX.axes_tics[1];
 }
@@ -3268,8 +3278,8 @@ double opt_general_axes_tics2(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.axes_tics[2] = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_value[19]->value(CTX.axes_tics[2]);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.value[19]->value(CTX.axes_tics[2]);
 #endif
   return CTX.axes_tics[2];
 }
@@ -3279,8 +3289,8 @@ double opt_general_axes_xmin(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.axes_position[0] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_value[20]->value(CTX.axes_position[0]);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.value[20]->value(CTX.axes_position[0]);
 #endif
   return CTX.axes_position[0];
 }
@@ -3290,8 +3300,8 @@ double opt_general_axes_xmax(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.axes_position[1] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_value[23]->value(CTX.axes_position[1]);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.value[23]->value(CTX.axes_position[1]);
 #endif
   return CTX.axes_position[1];
 }
@@ -3301,8 +3311,8 @@ double opt_general_axes_ymin(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.axes_position[2] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_value[21]->value(CTX.axes_position[2]);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.value[21]->value(CTX.axes_position[2]);
 #endif
   return CTX.axes_position[2];
 }
@@ -3312,8 +3322,8 @@ double opt_general_axes_ymax(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.axes_position[3] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_value[24]->value(CTX.axes_position[3]);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.value[24]->value(CTX.axes_position[3]);
 #endif
   return CTX.axes_position[3];
 }
@@ -3323,8 +3333,8 @@ double opt_general_axes_zmin(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.axes_position[4] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_value[22]->value(CTX.axes_position[4]);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.value[22]->value(CTX.axes_position[4]);
 #endif
   return CTX.axes_position[4];
 }
@@ -3334,8 +3344,8 @@ double opt_general_axes_zmax(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.axes_position[5] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_value[25]->value(CTX.axes_position[5]);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.value[25]->value(CTX.axes_position[5]);
 #endif
   return CTX.axes_position[5];
 }
@@ -3345,8 +3355,8 @@ double opt_general_small_axes(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.small_axes = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)){
-    WID->gen_butt[1]->value(CTX.small_axes);
+  if(GUI::available() && (action & GMSH_GUI)){
+    GUI::instance()->options->general.butt[1]->value(CTX.small_axes);
     activate_cb(NULL, (void*)"general_small_axes");
   }
 #endif
@@ -3358,8 +3368,8 @@ double opt_general_small_axes_position0(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.small_axes_pos[0] = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_value[26]->value(CTX.small_axes_pos[0]);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.value[26]->value(CTX.small_axes_pos[0]);
 #endif
   return CTX.small_axes_pos[0];
 }
@@ -3369,8 +3379,8 @@ double opt_general_small_axes_position1(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.small_axes_pos[1] = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_value[27]->value(CTX.small_axes_pos[1]);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.value[27]->value(CTX.small_axes_pos[1]);
 #endif
   return CTX.small_axes_pos[1];
 }
@@ -3387,8 +3397,8 @@ double opt_general_quadric_subdivisions(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.quadric_subdivisions = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_value[11]->value(CTX.quadric_subdivisions);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.value[11]->value(CTX.quadric_subdivisions);
 #endif
   return CTX.quadric_subdivisions;
 }
@@ -3398,16 +3408,16 @@ double opt_general_double_buffer(OPT_ARGS_NUM)
   if(action & GMSH_SET) {
     CTX.db = (int)val;
 #if defined(HAVE_FLTK)
-    if(WID) {
+    if(GUI::available()) {
       int mode = FL_RGB | FL_DEPTH | (CTX.db ? FL_DOUBLE : FL_SINGLE);
       if(CTX.antialiasing) mode |= FL_MULTISAMPLE;
-      WID->g_opengl_window->mode(mode);
+      GUI::instance()->graph[0]->gl->mode(mode);
     }
 #endif
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_butt[3]->value(CTX.db);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.butt[3]->value(CTX.db);
 #endif
   return CTX.db;
 }
@@ -3417,16 +3427,16 @@ double opt_general_antialiasing(OPT_ARGS_NUM)
   if(action & GMSH_SET) {
     CTX.antialiasing = (int)val;
 #if defined(HAVE_FLTK)
-    if(WID) {
+    if(GUI::available()) {
       int mode = FL_RGB | FL_DEPTH | (CTX.db ? FL_DOUBLE : FL_SINGLE);
       if(CTX.antialiasing) mode |= FL_MULTISAMPLE;
-      WID->g_opengl_window->mode(mode);
+      GUI::instance()->graph[0]->gl->mode(mode);
     }
 #endif
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_butt[12]->value(CTX.antialiasing);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.butt[12]->value(CTX.antialiasing);
 #endif
   return CTX.antialiasing;
 }
@@ -3446,8 +3456,8 @@ double opt_general_vector_type(OPT_ARGS_NUM)
       CTX.vector_type = 1;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)){
-    WID->gen_choice[0]->value(CTX.vector_type - 1);
+  if(GUI::available() && (action & GMSH_GUI)){
+    GUI::instance()->options->general.choice[0]->value(CTX.vector_type - 1);
   }
 #endif
   return CTX.vector_type;
@@ -3520,8 +3530,8 @@ double opt_general_color_scheme(OPT_ARGS_NUM)
 #endif
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_choice[3]->value(CTX.color_scheme);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.choice[3]->value(CTX.color_scheme);
 #endif
   return CTX.color_scheme;
 }
@@ -3534,8 +3544,8 @@ double opt_general_background_gradient(OPT_ARGS_NUM)
       CTX.bg_gradient = 0;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_choice[5]->value(CTX.bg_gradient);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.choice[5]->value(CTX.bg_gradient);
 #endif
   return CTX.bg_gradient;
 }
@@ -3545,8 +3555,8 @@ double opt_general_trackball(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.useTrackball = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_butt[5]->value(CTX.useTrackball);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.butt[5]->value(CTX.useTrackball);
 #endif
   return CTX.useTrackball;
 }
@@ -3556,8 +3566,8 @@ double opt_general_rotation_center_cg(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.rotation_center_cg = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)){
-    WID->gen_butt[15]->value(CTX.rotation_center_cg);
+  if(GUI::available() && (action & GMSH_GUI)){
+    GUI::instance()->options->general.butt[15]->value(CTX.rotation_center_cg);
     activate_cb(NULL, (void*)"rotation_center");
   }
 #endif
@@ -3576,8 +3586,8 @@ double opt_general_expert_mode(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.expert_mode = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_butt[10]->value(CTX.expert_mode);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.butt[10]->value(CTX.expert_mode);
 #endif
   return CTX.expert_mode;
 }
@@ -3587,8 +3597,8 @@ double opt_general_clip0a(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.clip_plane[0][0] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->reset_clip_browser();
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->clipping->resetBrowser();
 #endif
   return CTX.clip_plane[0][0];
 }
@@ -3598,8 +3608,8 @@ double opt_general_clip0b(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.clip_plane[0][1] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->reset_clip_browser();
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->clipping->resetBrowser();
 #endif
   return CTX.clip_plane[0][1];
 }
@@ -3609,8 +3619,8 @@ double opt_general_clip0c(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.clip_plane[0][2] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->reset_clip_browser();
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->clipping->resetBrowser();
 #endif
   return CTX.clip_plane[0][2];
 }
@@ -3620,8 +3630,8 @@ double opt_general_clip0d(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.clip_plane[0][3] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->reset_clip_browser();
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->clipping->resetBrowser();
 #endif
   return CTX.clip_plane[0][3];
 }
@@ -3631,8 +3641,8 @@ double opt_general_clip1a(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.clip_plane[1][0] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->reset_clip_browser();
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->clipping->resetBrowser();
 #endif
   return CTX.clip_plane[1][0];
 }
@@ -3642,8 +3652,8 @@ double opt_general_clip1b(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.clip_plane[1][1] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->reset_clip_browser();
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->clipping->resetBrowser();
 #endif
   return CTX.clip_plane[1][1];
 }
@@ -3653,8 +3663,8 @@ double opt_general_clip1c(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.clip_plane[1][2] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->reset_clip_browser();
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->clipping->resetBrowser();
 #endif
   return CTX.clip_plane[1][2];
 }
@@ -3664,8 +3674,8 @@ double opt_general_clip1d(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.clip_plane[1][3] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->reset_clip_browser();
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->clipping->resetBrowser();
 #endif
   return CTX.clip_plane[1][3];
 }
@@ -3675,8 +3685,8 @@ double opt_general_clip2a(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.clip_plane[2][0] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->reset_clip_browser();
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->clipping->resetBrowser();
 #endif
   return CTX.clip_plane[2][0];
 }
@@ -3686,8 +3696,8 @@ double opt_general_clip2b(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.clip_plane[2][1] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->reset_clip_browser();
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->clipping->resetBrowser();
 #endif
   return CTX.clip_plane[2][1];
 }
@@ -3697,8 +3707,8 @@ double opt_general_clip2c(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.clip_plane[2][2] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->reset_clip_browser();
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->clipping->resetBrowser();
 #endif
   return CTX.clip_plane[2][2];
 }
@@ -3708,8 +3718,8 @@ double opt_general_clip2d(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.clip_plane[2][3] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->reset_clip_browser();
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->clipping->resetBrowser();
 #endif
   return CTX.clip_plane[2][3];
 }
@@ -3719,8 +3729,8 @@ double opt_general_clip3a(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.clip_plane[3][0] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->reset_clip_browser();
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->clipping->resetBrowser();
 #endif
   return CTX.clip_plane[3][0];
 }
@@ -3730,8 +3740,8 @@ double opt_general_clip3b(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.clip_plane[3][1] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->reset_clip_browser();
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->clipping->resetBrowser();
 #endif
   return CTX.clip_plane[3][1];
 }
@@ -3741,8 +3751,8 @@ double opt_general_clip3c(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.clip_plane[3][2] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->reset_clip_browser();
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->clipping->resetBrowser();
 #endif
   return CTX.clip_plane[3][2];
 }
@@ -3752,8 +3762,8 @@ double opt_general_clip3d(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.clip_plane[3][3] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->reset_clip_browser();
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->clipping->resetBrowser();
 #endif
   return CTX.clip_plane[3][3];
 }
@@ -3763,8 +3773,8 @@ double opt_general_clip4a(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.clip_plane[4][0] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->reset_clip_browser();
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->clipping->resetBrowser();
 #endif
   return CTX.clip_plane[4][0];
 }
@@ -3774,8 +3784,8 @@ double opt_general_clip4b(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.clip_plane[4][1] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->reset_clip_browser();
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->clipping->resetBrowser();
 #endif
   return CTX.clip_plane[4][1];
 }
@@ -3785,8 +3795,8 @@ double opt_general_clip4c(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.clip_plane[4][2] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->reset_clip_browser();
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->clipping->resetBrowser();
 #endif
   return CTX.clip_plane[4][2];
 }
@@ -3796,8 +3806,8 @@ double opt_general_clip4d(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.clip_plane[4][3] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->reset_clip_browser();
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->clipping->resetBrowser();
 #endif
   return CTX.clip_plane[4][3];
 }
@@ -3807,8 +3817,8 @@ double opt_general_clip5a(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.clip_plane[5][0] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->reset_clip_browser();
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->clipping->resetBrowser();
 #endif
   return CTX.clip_plane[5][0];
 }
@@ -3818,8 +3828,8 @@ double opt_general_clip5b(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.clip_plane[5][1] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->reset_clip_browser();
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->clipping->resetBrowser();
 #endif
   return CTX.clip_plane[5][1];
 }
@@ -3829,8 +3839,8 @@ double opt_general_clip5c(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.clip_plane[5][2] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->reset_clip_browser();
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->clipping->resetBrowser();
 #endif
   return CTX.clip_plane[5][2];
 }
@@ -3840,8 +3850,8 @@ double opt_general_clip5d(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.clip_plane[5][3] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->reset_clip_browser();
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->clipping->resetBrowser();
 #endif
   return CTX.clip_plane[5][3];
 }
@@ -3851,8 +3861,8 @@ double opt_general_clip_whole_elements(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.clip_whole_elements = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)){
-    WID->clip_butt[0]->value(CTX.clip_whole_elements);
+  if(GUI::available() && (action & GMSH_GUI)){
+    GUI::instance()->clipping->butt[0]->value(CTX.clip_whole_elements);
     activate_cb(NULL, (void*)"clip_whole_elements");
   }
 #endif
@@ -3864,8 +3874,8 @@ double opt_general_clip_only_draw_intersecting_volume(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.clip_only_draw_intersecting_volume = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->clip_butt[1]->value(CTX.clip_only_draw_intersecting_volume);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->clipping->butt[1]->value(CTX.clip_only_draw_intersecting_volume);
 #endif
   return CTX.clip_only_draw_intersecting_volume;
 }
@@ -3875,8 +3885,8 @@ double opt_general_clip_only_volume(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.clip_only_volume = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->clip_butt[2]->value(CTX.clip_only_volume);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->clipping->butt[2]->value(CTX.clip_only_volume);
 #endif
   return CTX.clip_only_volume;
 }
@@ -3893,9 +3903,9 @@ double opt_general_light00(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.light_position[0][0] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)){
-    WID->gen_value[2]->value(CTX.light_position[0][0]);
-    WID->gen_sphere->setValue(CTX.light_position[0][0],
+  if(GUI::available() && (action & GMSH_GUI)){
+    GUI::instance()->options->general.value[2]->value(CTX.light_position[0][0]);
+    GUI::instance()->options->general.sphere->setValue(CTX.light_position[0][0],
                               CTX.light_position[0][1],
                               CTX.light_position[0][2]);
   }
@@ -3908,9 +3918,9 @@ double opt_general_light01(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.light_position[0][1] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)){
-    WID->gen_value[3]->value(CTX.light_position[0][1]);
-    WID->gen_sphere->setValue(CTX.light_position[0][0],
+  if(GUI::available() && (action & GMSH_GUI)){
+    GUI::instance()->options->general.value[3]->value(CTX.light_position[0][1]);
+    GUI::instance()->options->general.sphere->setValue(CTX.light_position[0][0],
                               CTX.light_position[0][1],
                               CTX.light_position[0][2]);
   }
@@ -3923,9 +3933,9 @@ double opt_general_light02(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.light_position[0][2] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)){
-    WID->gen_value[4]->value(CTX.light_position[0][2]);
-    WID->gen_sphere->setValue(CTX.light_position[0][0],
+  if(GUI::available() && (action & GMSH_GUI)){
+    GUI::instance()->options->general.value[4]->value(CTX.light_position[0][2]);
+    GUI::instance()->options->general.sphere->setValue(CTX.light_position[0][0],
                               CTX.light_position[0][1],
                               CTX.light_position[0][2]);
   }
@@ -3938,8 +3948,8 @@ double opt_general_light03(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.light_position[0][3] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->gen_value[13]->value(CTX.light_position[0][3]);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->general.value[13]->value(CTX.light_position[0][3]);
 #endif
   return CTX.light_position[0][3];
 }
@@ -4124,8 +4134,8 @@ double opt_geometry_auto_coherence(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.geom.auto_coherence = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->geo_butt[8]->value(CTX.geom.auto_coherence);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->geo.butt[8]->value(CTX.geom.auto_coherence);
 #endif
   return CTX.geom.auto_coherence;
 }
@@ -4135,8 +4145,8 @@ double opt_geometry_highlight_orphans(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.geom.highlight_orphans = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->geo_butt[10]->value(CTX.geom.highlight_orphans);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->geo.butt[10]->value(CTX.geom.highlight_orphans);
 #endif
   return CTX.geom.highlight_orphans;
 }
@@ -4146,8 +4156,8 @@ double opt_geometry_tolerance(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.geom.tolerance = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->geo_value[2]->value(CTX.geom.tolerance);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->geo.value[2]->value(CTX.geom.tolerance);
 #endif
   return CTX.geom.tolerance;
 }
@@ -4157,8 +4167,8 @@ double opt_geometry_normals(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.geom.normals = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->geo_value[0]->value(CTX.geom.normals);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->geo.value[0]->value(CTX.geom.normals);
 #endif
   return CTX.geom.normals;
 }
@@ -4168,8 +4178,8 @@ double opt_geometry_tangents(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.geom.tangents = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->geo_value[1]->value(CTX.geom.tangents);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->geo.value[1]->value(CTX.geom.tangents);
 #endif
   return CTX.geom.tangents;
 }
@@ -4179,8 +4189,8 @@ double opt_geometry_points(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.geom.points = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->geo_butt[0]->value(CTX.geom.points);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->geo.butt[0]->value(CTX.geom.points);
 #endif
   return CTX.geom.points;
 }
@@ -4190,8 +4200,8 @@ double opt_geometry_lines(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.geom.lines = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->geo_butt[1]->value(CTX.geom.lines);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->geo.butt[1]->value(CTX.geom.lines);
 #endif
   return CTX.geom.lines;
 }
@@ -4201,8 +4211,8 @@ double opt_geometry_surfaces(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.geom.surfaces = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->geo_butt[2]->value(CTX.geom.surfaces);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->geo.butt[2]->value(CTX.geom.surfaces);
 #endif
   return CTX.geom.surfaces;
 }
@@ -4212,8 +4222,8 @@ double opt_geometry_volumes(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.geom.volumes = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->geo_butt[3]->value(CTX.geom.volumes);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->geo.butt[3]->value(CTX.geom.volumes);
 #endif
   return CTX.geom.volumes;
 }
@@ -4223,8 +4233,8 @@ double opt_geometry_points_num(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.geom.points_num = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->geo_butt[4]->value(CTX.geom.points_num);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->geo.butt[4]->value(CTX.geom.points_num);
 #endif
   return CTX.geom.points_num;
 }
@@ -4234,8 +4244,8 @@ double opt_geometry_lines_num(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.geom.lines_num = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->geo_butt[5]->value(CTX.geom.lines_num);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->geo.butt[5]->value(CTX.geom.lines_num);
 #endif
   return CTX.geom.lines_num;
 }
@@ -4245,8 +4255,8 @@ double opt_geometry_surfaces_num(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.geom.surfaces_num = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->geo_butt[6]->value(CTX.geom.surfaces_num);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->geo.butt[6]->value(CTX.geom.surfaces_num);
 #endif
   return CTX.geom.surfaces_num;
 }
@@ -4256,8 +4266,8 @@ double opt_geometry_volumes_num(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.geom.volumes_num = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->geo_butt[7]->value(CTX.geom.volumes_num);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->geo.butt[7]->value(CTX.geom.volumes_num);
 #endif
   return CTX.geom.volumes_num;
 }
@@ -4267,8 +4277,8 @@ double opt_geometry_point_size(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.geom.point_size = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->geo_value[3]->value(CTX.geom.point_size);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->geo.value[3]->value(CTX.geom.point_size);
 #endif
   return CTX.geom.point_size;
 }
@@ -4278,8 +4288,8 @@ double opt_geometry_point_sel_size(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.geom.point_sel_size = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->geo_value[5]->value(CTX.geom.point_sel_size);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->geo.value[5]->value(CTX.geom.point_sel_size);
 #endif
   return CTX.geom.point_sel_size;
 }
@@ -4290,8 +4300,8 @@ double opt_geometry_point_type(OPT_ARGS_NUM)
     CTX.geom.point_type = (int)val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)) {
-    WID->geo_choice[0]->value(CTX.geom.point_type);
+  if(GUI::available() && (action & GMSH_GUI)) {
+    GUI::instance()->options->geo.choice[0]->value(CTX.geom.point_type);
   }
 #endif
   return CTX.geom.point_type;
@@ -4302,8 +4312,8 @@ double opt_geometry_line_width(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.geom.line_width = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->geo_value[4]->value(CTX.geom.line_width);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->geo.value[4]->value(CTX.geom.line_width);
 #endif
   return CTX.geom.line_width;
 }
@@ -4313,8 +4323,8 @@ double opt_geometry_line_sel_width(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.geom.line_sel_width = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->geo_value[6]->value(CTX.geom.line_sel_width);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->geo.value[6]->value(CTX.geom.line_sel_width);
 #endif
   return CTX.geom.line_sel_width;
 }
@@ -4325,8 +4335,8 @@ double opt_geometry_line_type(OPT_ARGS_NUM)
     CTX.geom.line_type = (int)val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)) {
-    WID->geo_choice[1]->value(CTX.geom.line_type);
+  if(GUI::available() && (action & GMSH_GUI)) {
+    GUI::instance()->options->geo.choice[1]->value(CTX.geom.line_type);
   }
 #endif
   return CTX.geom.line_type;
@@ -4340,8 +4350,8 @@ double opt_geometry_surface_type(OPT_ARGS_NUM)
       CTX.geom.surface_type = 0;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)) {
-    WID->geo_choice[2]->value(CTX.geom.surface_type);
+  if(GUI::available() && (action & GMSH_GUI)) {
+    GUI::instance()->options->geo.choice[2]->value(CTX.geom.surface_type);
   }
 #endif
   return CTX.geom.surface_type;
@@ -4352,8 +4362,8 @@ double opt_geometry_light(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.geom.light = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)) {
-    WID->geo_butt[9]->value(CTX.geom.light);
+  if(GUI::available() && (action & GMSH_GUI)) {
+    GUI::instance()->options->geo.butt[9]->value(CTX.geom.light);
   }
 #endif
   return CTX.geom.light;
@@ -4364,8 +4374,8 @@ double opt_geometry_light_two_side(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.geom.light_two_side = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->geo_butt[14]->value(CTX.geom.light_two_side);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->geo.butt[14]->value(CTX.geom.light_two_side);
 #endif
   return CTX.geom.light_two_side;
 }
@@ -4375,8 +4385,8 @@ double opt_geometry_occ_fix_small_edges(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.geom.occ_fix_small_edges = val ? 1 : 0;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)) {
-    WID->geo_butt[11]->value(CTX.geom.occ_fix_small_edges);
+  if(GUI::available() && (action & GMSH_GUI)) {
+    GUI::instance()->options->geo.butt[11]->value(CTX.geom.occ_fix_small_edges);
   }
 #endif
   return CTX.geom.occ_fix_small_edges;
@@ -4387,8 +4397,8 @@ double opt_geometry_occ_fix_small_faces(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.geom.occ_fix_small_faces = val ? 1 : 0;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)) {
-    WID->geo_butt[12]->value(CTX.geom.occ_fix_small_faces);
+  if(GUI::available() && (action & GMSH_GUI)) {
+    GUI::instance()->options->geo.butt[12]->value(CTX.geom.occ_fix_small_faces);
   }
 #endif
   return CTX.geom.occ_fix_small_faces;
@@ -4399,8 +4409,8 @@ double opt_geometry_occ_sew_faces(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.geom.occ_sew_faces = val ? 1 : 0;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)) {
-    WID->geo_butt[13]->value(CTX.geom.occ_sew_faces);
+  if(GUI::available() && (action & GMSH_GUI)) {
+    GUI::instance()->options->geo.butt[13]->value(CTX.geom.occ_sew_faces);
   }
 #endif
   return CTX.geom.occ_sew_faces;
@@ -4420,11 +4430,11 @@ double opt_geometry_old_newreg(OPT_ARGS_NUM)
   return CTX.geom.old_newreg;
 }
 
-double opt_geometry_circle_points(OPT_ARGS_NUM)
+double opt_geometry_num_sub_edges(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
-    CTX.geom.circle_points = (int)val;
-  return CTX.geom.circle_points;
+    CTX.geom.num_sub_edges = (int)val;
+  return CTX.geom.num_sub_edges;
 }
 
 double opt_geometry_extrude_spline_points(OPT_ARGS_NUM)
@@ -4453,8 +4463,8 @@ double opt_geometry_snap0(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.geom.snap[0] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->context_geometry_value[0]->value(CTX.geom.snap[0]);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->geoContext->value[0]->value(CTX.geom.snap[0]);
 #endif
   return CTX.geom.snap[0];
 }
@@ -4464,8 +4474,8 @@ double opt_geometry_snap1(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.geom.snap[1] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->context_geometry_value[1]->value(CTX.geom.snap[1]);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->geoContext->value[1]->value(CTX.geom.snap[1]);
 #endif
   return CTX.geom.snap[1];
 }
@@ -4475,8 +4485,8 @@ double opt_geometry_snap2(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.geom.snap[2] = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->context_geometry_value[2]->value(CTX.geom.snap[2]);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->geoContext->value[2]->value(CTX.geom.snap[2]);
 #endif
   return CTX.geom.snap[2];
 }
@@ -4486,8 +4496,8 @@ double opt_geometry_clip(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.geom.clip = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->reset_clip_browser();
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->clipping->resetBrowser();
 #endif
   return CTX.geom.clip;
 }
@@ -4497,8 +4507,8 @@ double opt_mesh_optimize(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.mesh.optimize = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_butt[2]->value(CTX.mesh.optimize);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.butt[2]->value(CTX.mesh.optimize);
 #endif
   return CTX.mesh.optimize;
 }
@@ -4508,8 +4518,8 @@ double opt_mesh_optimize_netgen(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.mesh.optimize_netgen = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_butt[24]->value(CTX.mesh.optimize_netgen);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.butt[24]->value(CTX.mesh.optimize_netgen);
 #endif
   return CTX.mesh.optimize_netgen;
 }
@@ -4527,8 +4537,8 @@ double opt_mesh_normals(OPT_ARGS_NUM)
     CTX.mesh.normals = val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_value[8]->value(CTX.mesh.normals);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.value[8]->value(CTX.mesh.normals);
 #endif
   return CTX.mesh.normals;
 }
@@ -4546,8 +4556,8 @@ double opt_mesh_tangents(OPT_ARGS_NUM)
     CTX.mesh.tangents = val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_value[13]->value(CTX.mesh.tangents);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.value[13]->value(CTX.mesh.tangents);
 #endif
   return CTX.mesh.tangents;
 }
@@ -4560,8 +4570,8 @@ double opt_mesh_explode(OPT_ARGS_NUM)
     CTX.mesh.explode = val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_value[9]->value(CTX.mesh.explode);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.value[9]->value(CTX.mesh.explode);
 #endif
   return CTX.mesh.explode;
 }
@@ -4580,8 +4590,8 @@ double opt_mesh_lc_factor(OPT_ARGS_NUM)
       CTX.mesh.lc_factor = val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_value[2]->value(CTX.mesh.lc_factor);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.value[2]->value(CTX.mesh.lc_factor);
 #endif
   return CTX.mesh.lc_factor;
 }
@@ -4591,8 +4601,8 @@ double opt_mesh_lc_min(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.mesh.lc_min = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_value[25]->value(CTX.mesh.lc_min);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.value[25]->value(CTX.mesh.lc_min);
 #endif
   return CTX.mesh.lc_min;
 }
@@ -4602,8 +4612,8 @@ double opt_mesh_lc_max(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.mesh.lc_max = val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_value[26]->value(CTX.mesh.lc_max);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.value[26]->value(CTX.mesh.lc_max);
 #endif
   return CTX.mesh.lc_max;
 }
@@ -4621,8 +4631,8 @@ double opt_mesh_lc_from_curvature(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.mesh.lc_from_curvature = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_butt[1]->value(CTX.mesh.lc_from_curvature ? 1 : 0);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.butt[1]->value(CTX.mesh.lc_from_curvature ? 1 : 0);
 #endif
   return CTX.mesh.lc_from_curvature;
 }
@@ -4632,8 +4642,8 @@ double opt_mesh_lc_from_points(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.mesh.lc_from_points = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_butt[5]->value(CTX.mesh.lc_from_points ? 1 : 0);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.butt[5]->value(CTX.mesh.lc_from_points ? 1 : 0);
 #endif
   return CTX.mesh.lc_from_points;
 }
@@ -4643,8 +4653,8 @@ double opt_mesh_lc_extend_from_boundary(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.mesh.lc_extend_from_boundary = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_butt[16]->value(CTX.mesh.lc_extend_from_boundary ? 1 : 0);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.butt[16]->value(CTX.mesh.lc_extend_from_boundary ? 1 : 0);
 #endif
   return CTX.mesh.lc_extend_from_boundary;
 }
@@ -4673,8 +4683,8 @@ double opt_mesh_quality_type(OPT_ARGS_NUM)
       CTX.mesh.quality_type = 0;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)){
-    WID->mesh_choice[6]->value(CTX.mesh.quality_type);
+  if(GUI::available() && (action & GMSH_GUI)){
+    GUI::instance()->options->mesh.choice[6]->value(CTX.mesh.quality_type);
   }
 #endif
   return CTX.mesh.quality_type;
@@ -4688,8 +4698,8 @@ double opt_mesh_quality_inf(OPT_ARGS_NUM)
     CTX.mesh.quality_inf = val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_value[4]->value(CTX.mesh.quality_inf);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.value[4]->value(CTX.mesh.quality_inf);
 #endif
   return CTX.mesh.quality_inf;
 }
@@ -4702,8 +4712,8 @@ double opt_mesh_quality_sup(OPT_ARGS_NUM)
     CTX.mesh.quality_sup = val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_value[5]->value(CTX.mesh.quality_sup);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.value[5]->value(CTX.mesh.quality_sup);
 #endif
   return CTX.mesh.quality_sup;
 }
@@ -4716,8 +4726,8 @@ double opt_mesh_radius_inf(OPT_ARGS_NUM)
     CTX.mesh.radius_inf = val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_value[6]->value(CTX.mesh.radius_inf);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.value[6]->value(CTX.mesh.radius_inf);
 #endif
   return CTX.mesh.radius_inf;
 }
@@ -4730,8 +4740,8 @@ double opt_mesh_radius_sup(OPT_ARGS_NUM)
     CTX.mesh.radius_sup = val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_value[7]->value(CTX.mesh.radius_sup);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.value[7]->value(CTX.mesh.radius_sup);
 #endif
   return CTX.mesh.radius_sup;
 }
@@ -4744,8 +4754,8 @@ double opt_mesh_label_type(OPT_ARGS_NUM)
       CTX.mesh.label_type = 0;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)){
-    WID->mesh_choice[7]->value(CTX.mesh.label_type);
+  if(GUI::available() && (action & GMSH_GUI)){
+    GUI::instance()->options->mesh.choice[7]->value(CTX.mesh.label_type);
   }
 #endif
   return CTX.mesh.label_type;
@@ -4757,8 +4767,8 @@ double opt_mesh_points(OPT_ARGS_NUM)
     CTX.mesh.points = (int)val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_butt[6]->value(CTX.mesh.points);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.butt[6]->value(CTX.mesh.points);
 #endif
   return CTX.mesh.points;
 }
@@ -4771,8 +4781,8 @@ double opt_mesh_lines(OPT_ARGS_NUM)
     CTX.mesh.lines = (int)val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_butt[7]->value(CTX.mesh.lines);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.butt[7]->value(CTX.mesh.lines);
 #endif
   return CTX.mesh.lines;
 }
@@ -4785,11 +4795,11 @@ double opt_mesh_triangles(OPT_ARGS_NUM)
     CTX.mesh.triangles = (int)val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)){
+  if(GUI::available() && (action & GMSH_GUI)){
     if(CTX.mesh.triangles)
-      ((Fl_Menu_Item*)WID->mesh_menu_butt->menu())[0].set();
+      ((Fl_Menu_Item*)GUI::instance()->options->mesh.menu->menu())[0].set();
     else
-      ((Fl_Menu_Item*)WID->mesh_menu_butt->menu())[0].clear();
+      ((Fl_Menu_Item*)GUI::instance()->options->mesh.menu->menu())[0].clear();
   }
 #endif
   return CTX.mesh.triangles;
@@ -4803,11 +4813,11 @@ double opt_mesh_quadrangles(OPT_ARGS_NUM)
     CTX.mesh.quadrangles = (int)val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)){
+  if(GUI::available() && (action & GMSH_GUI)){
     if(CTX.mesh.quadrangles)
-      ((Fl_Menu_Item*)WID->mesh_menu_butt->menu())[1].set();
+      ((Fl_Menu_Item*)GUI::instance()->options->mesh.menu->menu())[1].set();
     else
-      ((Fl_Menu_Item*)WID->mesh_menu_butt->menu())[1].clear();
+      ((Fl_Menu_Item*)GUI::instance()->options->mesh.menu->menu())[1].clear();
   }
 #endif
   return CTX.mesh.quadrangles;
@@ -4821,11 +4831,11 @@ double opt_mesh_tetrahedra(OPT_ARGS_NUM)
     CTX.mesh.tetrahedra = (int)val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)){
+  if(GUI::available() && (action & GMSH_GUI)){
     if(CTX.mesh.tetrahedra)
-      ((Fl_Menu_Item*)WID->mesh_menu_butt->menu())[2].set();
+      ((Fl_Menu_Item*)GUI::instance()->options->mesh.menu->menu())[2].set();
     else
-      ((Fl_Menu_Item*)WID->mesh_menu_butt->menu())[2].clear();
+      ((Fl_Menu_Item*)GUI::instance()->options->mesh.menu->menu())[2].clear();
   }
 #endif
   return CTX.mesh.tetrahedra;
@@ -4839,11 +4849,11 @@ double opt_mesh_hexahedra(OPT_ARGS_NUM)
     CTX.mesh.hexahedra = (int)val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)){
+  if(GUI::available() && (action & GMSH_GUI)){
     if(CTX.mesh.hexahedra)
-      ((Fl_Menu_Item*)WID->mesh_menu_butt->menu())[3].set();
+      ((Fl_Menu_Item*)GUI::instance()->options->mesh.menu->menu())[3].set();
     else
-      ((Fl_Menu_Item*)WID->mesh_menu_butt->menu())[3].clear();
+      ((Fl_Menu_Item*)GUI::instance()->options->mesh.menu->menu())[3].clear();
   }
 #endif
   return CTX.mesh.hexahedra;
@@ -4857,11 +4867,11 @@ double opt_mesh_prisms(OPT_ARGS_NUM)
     CTX.mesh.prisms = (int)val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)){
+  if(GUI::available() && (action & GMSH_GUI)){
     if(CTX.mesh.prisms)
-      ((Fl_Menu_Item*)WID->mesh_menu_butt->menu())[4].set();
+      ((Fl_Menu_Item*)GUI::instance()->options->mesh.menu->menu())[4].set();
     else
-      ((Fl_Menu_Item*)WID->mesh_menu_butt->menu())[4].clear();
+      ((Fl_Menu_Item*)GUI::instance()->options->mesh.menu->menu())[4].clear();
   }
 #endif
   return CTX.mesh.prisms;
@@ -4875,11 +4885,11 @@ double opt_mesh_pyramids(OPT_ARGS_NUM)
     CTX.mesh.pyramids = (int)val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)){
+  if(GUI::available() && (action & GMSH_GUI)){
     if(CTX.mesh.pyramids)
-      ((Fl_Menu_Item*)WID->mesh_menu_butt->menu())[5].set();
+      ((Fl_Menu_Item*)GUI::instance()->options->mesh.menu->menu())[5].set();
     else
-      ((Fl_Menu_Item*)WID->mesh_menu_butt->menu())[5].clear();
+      ((Fl_Menu_Item*)GUI::instance()->options->mesh.menu->menu())[5].clear();
   }
 #endif
   return CTX.mesh.pyramids;
@@ -4893,8 +4903,8 @@ double opt_mesh_surfaces_edges(OPT_ARGS_NUM)
     CTX.mesh.surfaces_edges = (int)val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_butt[8]->value(CTX.mesh.surfaces_edges);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.butt[8]->value(CTX.mesh.surfaces_edges);
 #endif
   return CTX.mesh.surfaces_edges;
 }
@@ -4907,8 +4917,8 @@ double opt_mesh_surfaces_faces(OPT_ARGS_NUM)
     CTX.mesh.surfaces_faces = (int)val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_butt[9]->value(CTX.mesh.surfaces_faces);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.butt[9]->value(CTX.mesh.surfaces_faces);
 #endif
   return CTX.mesh.surfaces_faces;
 }
@@ -4921,8 +4931,8 @@ double opt_mesh_volumes_edges(OPT_ARGS_NUM)
     CTX.mesh.volumes_edges = (int)val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_butt[10]->value(CTX.mesh.volumes_edges);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.butt[10]->value(CTX.mesh.volumes_edges);
 #endif
   return CTX.mesh.volumes_edges;
 }
@@ -4935,8 +4945,8 @@ double opt_mesh_volumes_faces(OPT_ARGS_NUM)
     CTX.mesh.volumes_faces = (int)val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_butt[11]->value(CTX.mesh.volumes_faces);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.butt[11]->value(CTX.mesh.volumes_faces);
 #endif
   return CTX.mesh.volumes_faces;
 }
@@ -4947,8 +4957,8 @@ double opt_mesh_points_num(OPT_ARGS_NUM)
     CTX.mesh.points_num = (int)val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_butt[12]->value(CTX.mesh.points_num);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.butt[12]->value(CTX.mesh.points_num);
 #endif
   return CTX.mesh.points_num;
 }
@@ -4959,8 +4969,8 @@ double opt_mesh_lines_num(OPT_ARGS_NUM)
     CTX.mesh.lines_num = (int)val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_butt[13]->value(CTX.mesh.lines_num);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.butt[13]->value(CTX.mesh.lines_num);
 #endif
   return CTX.mesh.lines_num;
 }
@@ -4971,8 +4981,8 @@ double opt_mesh_surfaces_num(OPT_ARGS_NUM)
     CTX.mesh.surfaces_num = (int)val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_butt[14]->value(CTX.mesh.surfaces_num);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.butt[14]->value(CTX.mesh.surfaces_num);
 #endif
   return CTX.mesh.surfaces_num;
 }
@@ -4983,8 +4993,8 @@ double opt_mesh_volumes_num(OPT_ARGS_NUM)
     CTX.mesh.volumes_num = (int)val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_butt[15]->value(CTX.mesh.volumes_num);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.butt[15]->value(CTX.mesh.volumes_num);
 #endif
   return CTX.mesh.volumes_num;
 }
@@ -4995,8 +5005,8 @@ double opt_mesh_point_size(OPT_ARGS_NUM)
     CTX.mesh.point_size = val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_value[10]->value(CTX.mesh.point_size);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.value[10]->value(CTX.mesh.point_size);
 #endif
   return CTX.mesh.point_size;
 }
@@ -5007,8 +5017,8 @@ double opt_mesh_point_type(OPT_ARGS_NUM)
     CTX.mesh.point_type = (int)val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)) {
-    WID->mesh_choice[0]->value(CTX.mesh.point_type ? 1 : 0);
+  if(GUI::available() && (action & GMSH_GUI)) {
+    GUI::instance()->options->mesh.choice[0]->value(CTX.mesh.point_type ? 1 : 0);
   }
 #endif
   return CTX.mesh.point_type;
@@ -5020,8 +5030,8 @@ double opt_mesh_line_width(OPT_ARGS_NUM)
     CTX.mesh.line_width = val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_value[11]->value(CTX.mesh.line_width);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.value[11]->value(CTX.mesh.line_width);
 #endif
   return CTX.mesh.line_width;
 }
@@ -5032,8 +5042,8 @@ double opt_mesh_label_frequency(OPT_ARGS_NUM)
     CTX.mesh.label_frequency = val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_value[12]->value(CTX.mesh.label_frequency);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.value[12]->value(CTX.mesh.label_frequency);
 #endif
   return CTX.mesh.label_frequency;
 }
@@ -5046,8 +5056,8 @@ double opt_mesh_reverse_all_normals(OPT_ARGS_NUM)
     CTX.mesh.reverse_all_normals = (int)val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_butt[0]->value(CTX.mesh.reverse_all_normals);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.butt[0]->value(CTX.mesh.reverse_all_normals);
 #endif
   return CTX.mesh.reverse_all_normals;
 }
@@ -5060,8 +5070,8 @@ double opt_mesh_smooth_normals(OPT_ARGS_NUM)
     CTX.mesh.smooth_normals = (int)val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_butt[19]->value(CTX.mesh.smooth_normals);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.butt[19]->value(CTX.mesh.smooth_normals);
 #endif
   return CTX.mesh.smooth_normals;
 }
@@ -5074,8 +5084,8 @@ double opt_mesh_angle_smooth_normals(OPT_ARGS_NUM)
     CTX.mesh.angle_smooth_normals = val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_value[18]->value(CTX.mesh.angle_smooth_normals);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.value[18]->value(CTX.mesh.angle_smooth_normals);
 #endif
   return CTX.mesh.angle_smooth_normals;
 }
@@ -5085,8 +5095,8 @@ double opt_mesh_light(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.mesh.light = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)){
-    WID->mesh_butt[17]->value(CTX.mesh.light);
+  if(GUI::available() && (action & GMSH_GUI)){
+    GUI::instance()->options->mesh.butt[17]->value(CTX.mesh.light);
     activate_cb(NULL, (void*)"mesh_light");
   }
 #endif
@@ -5098,8 +5108,8 @@ double opt_mesh_light_lines(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.mesh.light_lines = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_butt[20]->value(CTX.mesh.light_lines);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.butt[20]->value(CTX.mesh.light_lines);
 #endif
   return CTX.mesh.light_lines;
 }
@@ -5109,8 +5119,8 @@ double opt_mesh_light_two_side(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.mesh.light_two_side = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_butt[18]->value(CTX.mesh.light_two_side);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.butt[18]->value(CTX.mesh.light_two_side);
 #endif
   return CTX.mesh.light_two_side;
 }
@@ -5152,8 +5162,8 @@ double opt_mesh_nb_smoothing(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.mesh.nb_smoothing = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_value[0]->value(CTX.mesh.nb_smoothing);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.value[0]->value(CTX.mesh.nb_smoothing);
 #endif
   return CTX.mesh.nb_smoothing;
 }
@@ -5165,17 +5175,17 @@ double opt_mesh_algo2d(OPT_ARGS_NUM)
     CTX.mesh.algo2d = algo;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)) {
+  if(GUI::available() && (action & GMSH_GUI)) {
     switch (CTX.mesh.algo2d) {
     case ALGO_2D_FRONTAL:
-      WID->mesh_choice[2]->value(0);
+      GUI::instance()->options->mesh.choice[2]->value(0);
       break;
     case ALGO_2D_DELAUNAY:
-      WID->mesh_choice[2]->value(1);
+      GUI::instance()->options->mesh.choice[2]->value(1);
       break;
     case ALGO_2D_MESHADAPT_DELAUNAY:
     default:
-      WID->mesh_choice[2]->value(2);
+      GUI::instance()->options->mesh.choice[2]->value(2);
       break;
     }
   }
@@ -5191,8 +5201,8 @@ double opt_mesh_recombine_algo(OPT_ARGS_NUM)
       CTX.mesh.algo_recombine = 1;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)) {
-    WID->mesh_choice[5]->value(CTX.mesh.algo_recombine - 1);
+  if(GUI::available() && (action & GMSH_GUI)) {
+    GUI::instance()->options->mesh.choice[5]->value(CTX.mesh.algo_recombine - 1);
   }
 #endif
   return CTX.mesh.algo_recombine;
@@ -5205,14 +5215,14 @@ double opt_mesh_algo3d(OPT_ARGS_NUM)
     CTX.mesh.algo3d = algo;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)) {
+  if(GUI::available() && (action & GMSH_GUI)) {
     switch (CTX.mesh.algo3d) {
     case ALGO_3D_NETGEN:
-      WID->mesh_choice[3]->value(1);
+      GUI::instance()->options->mesh.choice[3]->value(1);
       break;
     case ALGO_3D_TETGEN_DELAUNAY:
     default:
-      WID->mesh_choice[3]->value(0);
+      GUI::instance()->options->mesh.choice[3]->value(0);
       break;
     }
   }
@@ -5253,8 +5263,8 @@ double opt_mesh_order(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.mesh.order = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_value[3]->value(CTX.mesh.order);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.value[3]->value(CTX.mesh.order);
 #endif
   return CTX.mesh.order;
 }
@@ -5264,8 +5274,8 @@ double opt_mesh_c1(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.mesh.c1_continuity = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_butt[21]->value(CTX.mesh.c1_continuity);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.butt[21]->value(CTX.mesh.c1_continuity);
 #endif
   return CTX.mesh.c1_continuity;
 }
@@ -5275,8 +5285,8 @@ double opt_mesh_smooth_internal_edges(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.mesh.smooth_internal_edges = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_butt[3]->value(CTX.mesh.smooth_internal_edges);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.butt[3]->value(CTX.mesh.smooth_internal_edges);
 #endif
   return CTX.mesh.smooth_internal_edges;
 }
@@ -5300,8 +5310,8 @@ double opt_mesh_second_order_incomplete(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.mesh.second_order_incomplete = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->mesh_butt[4]->value(CTX.mesh.second_order_incomplete);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->mesh.butt[4]->value(CTX.mesh.second_order_incomplete);
 #endif
   return CTX.mesh.second_order_incomplete;
 }
@@ -5365,8 +5375,8 @@ double opt_mesh_color_carousel(OPT_ARGS_NUM)
       CTX.mesh.color_carousel = 0;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)){
-    WID->mesh_choice[4]->value(CTX.mesh.color_carousel);
+  if(GUI::available() && (action & GMSH_GUI)){
+    GUI::instance()->options->mesh.choice[4]->value(CTX.mesh.color_carousel);
   }
 #endif
   return CTX.mesh.color_carousel;
@@ -5663,8 +5673,8 @@ double opt_mesh_clip(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.mesh.clip = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->reset_clip_browser();
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->clipping->resetBrowser();
 #endif
   return CTX.mesh.clip;
 }
@@ -5674,8 +5684,8 @@ double opt_solver_max_delay(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.solver.max_delay = (val >= 0) ? (int)val : 0;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->solver_value[0]->value(CTX.solver.max_delay);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->solver.value[0]->value(CTX.solver.max_delay);
 #endif
   return CTX.solver.max_delay;
 }
@@ -5685,8 +5695,8 @@ double opt_solver_listen(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.solver.listen = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->solver_butt[0]->value(CTX.solver.listen);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->solver.butt[0]->value(CTX.solver.listen);
 #endif
   return CTX.solver.listen;
 }
@@ -5703,8 +5713,8 @@ double opt_solver_client_server(OPT_ARGS_NUM)
 #if defined(HAVE_FLTK)
   if(action & GMSH_SET)
     SINFO[num].client_server = (int)val;
-  if(WID && (action & GMSH_GUI))
-    WID->solver[num].butt[2]->value(SINFO[num].client_server);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->solver[num]->butt[2]->value(SINFO[num].client_server);
   return SINFO[num].client_server;
 #else
   return 0.;
@@ -5741,8 +5751,8 @@ double opt_solver_popup_messages(OPT_ARGS_NUM)
 #if defined(HAVE_FLTK)
   if(action & GMSH_SET)
     SINFO[num].popup_messages = (int)val;
-  if(WID && (action & GMSH_GUI))
-    WID->solver[num].butt[0]->value(SINFO[num].popup_messages);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->solver[num]->butt[0]->value(SINFO[num].popup_messages);
   return SINFO[num].popup_messages;
 #else
   return 1.;
@@ -5779,8 +5789,8 @@ double opt_solver_merge_views(OPT_ARGS_NUM)
 #if defined(HAVE_FLTK)
   if(action & GMSH_SET)
     SINFO[num].merge_views = (int)val;
-  if(WID && (action & GMSH_GUI))
-    WID->solver[num].butt[1]->value(SINFO[num].merge_views);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->solver[num]->butt[1]->value(SINFO[num].merge_views);
   return SINFO[num].merge_views;
 #else
   return 1.;
@@ -5817,8 +5827,8 @@ double opt_post_horizontal_scales(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.post.horizontal_scales = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->post_butt[2]->value(CTX.post.horizontal_scales);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->post.butt[2]->value(CTX.post.horizontal_scales);
 #endif
   return CTX.post.horizontal_scales;
 }
@@ -5831,8 +5841,8 @@ double opt_post_link(OPT_ARGS_NUM)
       CTX.post.link = 0;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI)) {
-    WID->post_choice[0]->value(CTX.post.link);
+  if(GUI::available() && (action & GMSH_GUI)) {
+    GUI::instance()->options->post.choice[0]->value(CTX.post.link);
   }
 #endif
   return CTX.post.link;
@@ -5850,8 +5860,8 @@ double opt_post_anim_delay(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.post.anim_delay = (val >= 0.) ? val : 0.;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->post_value[0]->value(CTX.post.anim_delay);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->post.value[0]->value(CTX.post.anim_delay);
 #endif
   return CTX.post.anim_delay;
 }
@@ -5861,10 +5871,10 @@ double opt_post_anim_cycle(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.post.anim_cycle = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->post_butt[0]->value(CTX.post.anim_cycle);
-  if(WID)
-    WID->check_anim_buttons();
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->post.butt[0]->value(CTX.post.anim_cycle);
+  if(GUI::available())
+    GUI::instance()->graph[0]->checkAnimButtons();
 #endif
   return CTX.post.anim_cycle;
 }
@@ -5874,8 +5884,8 @@ double opt_post_combine_remove_orig(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX.post.combine_remove_orig = (int)val;
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI))
-    WID->post_butt[1]->value(CTX.post.combine_remove_orig);
+  if(GUI::available() && (action & GMSH_GUI))
+    GUI::instance()->options->post.butt[1]->value(CTX.post.combine_remove_orig);
 #endif
   return CTX.post.combine_remove_orig;
 }
@@ -5910,9 +5920,9 @@ double opt_view_nb_timestep(OPT_ARGS_NUM)
   if(!data) return 1;
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[50]->maximum(data->getNumTimeSteps() - 1);
-  if(WID)
-    WID->check_anim_buttons();
+    GUI::instance()->options->view.value[50]->maximum(data->getNumTimeSteps() - 1);
+  if(GUI::available())
+    GUI::instance()->graph[0]->checkAnimButtons();
 #endif
   return data->getNumTimeSteps();
 #else
@@ -5940,7 +5950,7 @@ double opt_view_timestep(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[50]->value(opt->TimeStep);
+    GUI::instance()->options->view.value[50]->value(opt->TimeStep);
 #endif
   return opt->TimeStep;
 #else
@@ -5982,7 +5992,7 @@ double opt_view_custom_min(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_value[31]->value(opt->CustomMin);
+    GUI::instance()->options->view.value[31]->value(opt->CustomMin);
   }
 #endif
   return opt->CustomMin;
@@ -6001,7 +6011,7 @@ double opt_view_custom_max(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[32]->value(opt->CustomMax);
+    GUI::instance()->options->view.value[32]->value(opt->CustomMax);
 #endif
   return opt->CustomMax;
 #else
@@ -6085,7 +6095,7 @@ double opt_view_offset0(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[40]->value(opt->Offset[0]);
+    GUI::instance()->options->view.value[40]->value(opt->Offset[0]);
 #endif
   return opt->Offset[0];
 #else
@@ -6103,7 +6113,7 @@ double opt_view_offset1(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[41]->value(opt->Offset[1]);
+    GUI::instance()->options->view.value[41]->value(opt->Offset[1]);
 #endif
   return opt->Offset[1];
 #else
@@ -6121,7 +6131,7 @@ double opt_view_offset2(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[42]->value(opt->Offset[2]);
+    GUI::instance()->options->view.value[42]->value(opt->Offset[2]);
 #endif
   return opt->Offset[2];
 #else
@@ -6139,7 +6149,7 @@ double opt_view_raise0(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[43]->value(opt->Raise[0]);
+    GUI::instance()->options->view.value[43]->value(opt->Raise[0]);
 #endif
   return opt->Raise[0];
 #else
@@ -6157,7 +6167,7 @@ double opt_view_raise1(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[44]->value(opt->Raise[1]);
+    GUI::instance()->options->view.value[44]->value(opt->Raise[1]);
 #endif
   return opt->Raise[1];
 #else
@@ -6175,7 +6185,7 @@ double opt_view_raise2(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[45]->value(opt->Raise[2]);
+    GUI::instance()->options->view.value[45]->value(opt->Raise[2]);
 #endif
   return opt->Raise[2];
 #else
@@ -6193,7 +6203,7 @@ double opt_view_normal_raise(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[46]->value(opt->NormalRaise);
+    GUI::instance()->options->view.value[46]->value(opt->NormalRaise);
 #endif
   return opt->NormalRaise;
 #else
@@ -6211,7 +6221,7 @@ double opt_view_transform00(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[51]->value(opt->Transform[0][0]);
+    GUI::instance()->options->view.value[51]->value(opt->Transform[0][0]);
 #endif
   return opt->Transform[0][0];
 #else
@@ -6229,7 +6239,7 @@ double opt_view_transform01(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[52]->value(opt->Transform[0][1]);
+    GUI::instance()->options->view.value[52]->value(opt->Transform[0][1]);
 #endif
   return opt->Transform[0][1];
 #else
@@ -6247,7 +6257,7 @@ double opt_view_transform02(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[53]->value(opt->Transform[0][2]);
+    GUI::instance()->options->view.value[53]->value(opt->Transform[0][2]);
 #endif
   return opt->Transform[0][2];
 #else
@@ -6265,7 +6275,7 @@ double opt_view_transform10(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[54]->value(opt->Transform[1][0]);
+    GUI::instance()->options->view.value[54]->value(opt->Transform[1][0]);
 #endif
   return opt->Transform[1][0];
 #else
@@ -6283,7 +6293,7 @@ double opt_view_transform11(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[55]->value(opt->Transform[1][1]);
+    GUI::instance()->options->view.value[55]->value(opt->Transform[1][1]);
 #endif
   return opt->Transform[1][1];
 #else
@@ -6301,7 +6311,7 @@ double opt_view_transform12(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[56]->value(opt->Transform[1][2]);
+    GUI::instance()->options->view.value[56]->value(opt->Transform[1][2]);
 #endif
   return opt->Transform[1][2];
 #else
@@ -6319,7 +6329,7 @@ double opt_view_transform20(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[57]->value(opt->Transform[2][0]);
+    GUI::instance()->options->view.value[57]->value(opt->Transform[2][0]);
 #endif
   return opt->Transform[2][0];
 #else
@@ -6337,7 +6347,7 @@ double opt_view_transform21(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[58]->value(opt->Transform[2][1]);
+    GUI::instance()->options->view.value[58]->value(opt->Transform[2][1]);
 #endif
   return opt->Transform[2][1];
 #else
@@ -6355,7 +6365,7 @@ double opt_view_transform22(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[59]->value(opt->Transform[2][2]);
+    GUI::instance()->options->view.value[59]->value(opt->Transform[2][2]);
 #endif
   return opt->Transform[2][2];
 #else
@@ -6372,7 +6382,7 @@ double opt_view_arrow_size(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[60]->value(opt->ArrowSize);
+    GUI::instance()->options->view.value[60]->value(opt->ArrowSize);
 #endif
   return opt->ArrowSize;
 #else
@@ -6389,7 +6399,7 @@ double opt_view_arrow_size_proportional(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_butt[0]->value(opt->ArrowSizeProportional);
+    GUI::instance()->options->view.butt[0]->value(opt->ArrowSizeProportional);
 #endif
   return opt->ArrowSizeProportional;
 #else
@@ -6451,7 +6461,7 @@ double opt_view_normals(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[0]->value(opt->Normals);
+    GUI::instance()->options->view.value[0]->value(opt->Normals);
 #endif
   return opt->Normals;
 #else
@@ -6468,7 +6478,7 @@ double opt_view_tangents(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[1]->value(opt->Tangents);
+    GUI::instance()->options->view.value[1]->value(opt->Tangents);
 #endif
   return opt->Tangents;
 #else
@@ -6486,7 +6496,7 @@ double opt_view_displacement_factor(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[63]->value(opt->DisplacementFactor);
+    GUI::instance()->options->view.value[63]->value(opt->DisplacementFactor);
 #endif
   return opt->DisplacementFactor;
 #else
@@ -6504,7 +6514,7 @@ double opt_view_fake_transparency(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_butt[24]->value(opt->FakeTransparency);
+    GUI::instance()->options->view.butt[24]->value(opt->FakeTransparency);
 #endif
   return opt->FakeTransparency;
 #else
@@ -6522,7 +6532,7 @@ double opt_view_explode(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[12]->value(opt->Explode);
+    GUI::instance()->options->view.value[12]->value(opt->Explode);
 #endif
   return opt->Explode;
 #else
@@ -6538,8 +6548,9 @@ double opt_view_visible(OPT_ARGS_NUM)
     opt->Visible = (int)val;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI) && num >= 0 && num < (int)WID->m_toggle_butt.size())
-    WID->m_toggle_butt[num]->value(opt->Visible);
+  if(GUI::available() && (action & GMSH_GUI) && num >= 0 && 
+     num < (int)GUI::instance()->menu->toggle.size())
+    GUI::instance()->menu->toggle[num]->value(opt->Visible);
 #endif
   return opt->Visible;
 #else
@@ -6559,7 +6570,7 @@ double opt_view_intervals_type(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_choice[0]->value(opt->IntervalsType - 1);
+    GUI::instance()->options->view.choice[0]->value(opt->IntervalsType - 1);
   }
 #endif
   return opt->IntervalsType;
@@ -6578,7 +6589,7 @@ double opt_view_saturate_values(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_butt[38]->value(opt->SaturateValues);
+    GUI::instance()->options->view.butt[38]->value(opt->SaturateValues);
   }
 #endif
   return opt->SaturateValues;
@@ -6601,7 +6612,7 @@ double opt_view_max_recursion_level(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_value[33]->value(opt->MaxRecursionLevel);
+    GUI::instance()->options->view.value[33]->value(opt->MaxRecursionLevel);
   }
 #endif
   return opt->MaxRecursionLevel;
@@ -6624,7 +6635,7 @@ double opt_view_target_error(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_value[34]->value(opt->TargetError);
+    GUI::instance()->options->view.value[34]->value(opt->TargetError);
   }
 #endif
   return opt->TargetError;
@@ -6645,7 +6656,7 @@ double opt_view_type(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_choice[13]->value(opt->Type - 1);
+    GUI::instance()->options->view.choice[13]->value(opt->Type - 1);
   }
 #endif
   return opt->Type;
@@ -6663,7 +6674,7 @@ double opt_view_auto_position(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_butt[7]->value(opt->AutoPosition);
+    GUI::instance()->options->view.butt[7]->value(opt->AutoPosition);
     activate_cb(NULL, (void*)"view_axes_auto_2d");
   }
 #endif
@@ -6682,7 +6693,7 @@ double opt_view_position0(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[20]->value(opt->Position[0]);
+    GUI::instance()->options->view.value[20]->value(opt->Position[0]);
 #endif
   return opt->Position[0];
 #else
@@ -6699,7 +6710,7 @@ double opt_view_position1(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[21]->value(opt->Position[1]);
+    GUI::instance()->options->view.value[21]->value(opt->Position[1]);
 #endif
   return opt->Position[1];
 #else
@@ -6716,7 +6727,7 @@ double opt_view_size0(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[22]->value(opt->Size[0]);
+    GUI::instance()->options->view.value[22]->value(opt->Size[0]);
 #endif
   return opt->Size[0];
 #else
@@ -6733,7 +6744,7 @@ double opt_view_size1(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[23]->value(opt->Size[1]);
+    GUI::instance()->options->view.value[23]->value(opt->Size[1]);
 #endif
   return opt->Size[1];
 #else
@@ -6752,7 +6763,7 @@ double opt_view_axes(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_choice[8]->value(opt->Axes);
+    GUI::instance()->options->view.choice[8]->value(opt->Axes);
     activate_cb(NULL, (void*)"view_axes");
   }
 #endif
@@ -6770,7 +6781,7 @@ double opt_view_axes_mikado(OPT_ARGS_NUM){
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_butt[3]->value(opt->AxesMikado);
+    GUI::instance()->options->view.butt[3]->value(opt->AxesMikado);
   }
 #endif
   return opt->AxesMikado;
@@ -6788,7 +6799,7 @@ double opt_view_axes_auto_position(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_butt[25]->value(opt->AxesAutoPosition);
+    GUI::instance()->options->view.butt[25]->value(opt->AxesAutoPosition);
     activate_cb(NULL, (void*)"view_axes_auto_3d");
   }
 #endif
@@ -6807,7 +6818,7 @@ double opt_view_axes_xmin(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_value[13]->value(opt->AxesPosition[0]);
+    GUI::instance()->options->view.value[13]->value(opt->AxesPosition[0]);
   }
 #endif
   return opt->AxesPosition[0];
@@ -6825,7 +6836,7 @@ double opt_view_axes_xmax(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_value[16]->value(opt->AxesPosition[1]);
+    GUI::instance()->options->view.value[16]->value(opt->AxesPosition[1]);
   }
 #endif
   return opt->AxesPosition[1];
@@ -6843,7 +6854,7 @@ double opt_view_axes_ymin(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_value[14]->value(opt->AxesPosition[2]);
+    GUI::instance()->options->view.value[14]->value(opt->AxesPosition[2]);
   }
 #endif
   return opt->AxesPosition[2];
@@ -6861,7 +6872,7 @@ double opt_view_axes_ymax(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_value[17]->value(opt->AxesPosition[3]);
+    GUI::instance()->options->view.value[17]->value(opt->AxesPosition[3]);
   }
 #endif
   return opt->AxesPosition[3];
@@ -6879,7 +6890,7 @@ double opt_view_axes_zmin(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_value[15]->value(opt->AxesPosition[4]);
+    GUI::instance()->options->view.value[15]->value(opt->AxesPosition[4]);
   }
 #endif
   return opt->AxesPosition[4];
@@ -6897,7 +6908,7 @@ double opt_view_axes_zmax(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_value[18]->value(opt->AxesPosition[5]);
+    GUI::instance()->options->view.value[18]->value(opt->AxesPosition[5]);
   }
 #endif
   return opt->AxesPosition[5];
@@ -6915,7 +6926,7 @@ double opt_view_axes_tics0(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_value[3]->value(opt->AxesTics[0]);
+    GUI::instance()->options->view.value[3]->value(opt->AxesTics[0]);
   }
 #endif
   return opt->AxesTics[0];
@@ -6933,7 +6944,7 @@ double opt_view_axes_tics1(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_value[4]->value(opt->AxesTics[1]);
+    GUI::instance()->options->view.value[4]->value(opt->AxesTics[1]);
   }
 #endif
   return opt->AxesTics[1];
@@ -6951,7 +6962,7 @@ double opt_view_axes_tics2(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_value[5]->value(opt->AxesTics[2]);
+    GUI::instance()->options->view.value[5]->value(opt->AxesTics[2]);
   }
 #endif
   return opt->AxesTics[2];
@@ -6970,7 +6981,7 @@ double opt_view_nb_iso(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[30]->value(opt->NbIso);
+    GUI::instance()->options->view.value[30]->value(opt->NbIso);
 #endif
   return opt->NbIso;
 #else
@@ -6990,7 +7001,7 @@ double opt_view_boundary(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_choice[9]->value(opt->Boundary);
+    GUI::instance()->options->view.choice[9]->value(opt->Boundary);
   }
 #endif
   return opt->Boundary;
@@ -7009,7 +7020,7 @@ double opt_view_light(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)){
-    WID->view_butt[11]->value(opt->Light);
+    GUI::instance()->options->view.butt[11]->value(opt->Light);
     activate_cb(NULL, (void*)"view_light");
   }
 #endif
@@ -7028,7 +7039,7 @@ double opt_view_light_two_side(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_butt[9]->value(opt->LightTwoSide);
+    GUI::instance()->options->view.butt[9]->value(opt->LightTwoSide);
 #endif
   return opt->LightTwoSide;
 #else
@@ -7045,7 +7056,7 @@ double opt_view_light_lines(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_butt[8]->value(opt->LightLines);
+    GUI::instance()->options->view.butt[8]->value(opt->LightLines);
 #endif
   return opt->LightLines;
 #else
@@ -7063,7 +7074,7 @@ double opt_view_smooth_normals(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_butt[12]->value(opt->SmoothNormals);
+    GUI::instance()->options->view.butt[12]->value(opt->SmoothNormals);
 #endif
   return opt->SmoothNormals;
 #else
@@ -7081,7 +7092,7 @@ double opt_view_angle_smooth_normals(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[10]->value(opt->AngleSmoothNormals);
+    GUI::instance()->options->view.value[10]->value(opt->AngleSmoothNormals);
 #endif
   return opt->AngleSmoothNormals;
 #else
@@ -7099,7 +7110,7 @@ double opt_view_show_element(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_butt[10]->value(opt->ShowElement);
+    GUI::instance()->options->view.butt[10]->value(opt->ShowElement);
 #endif
   return opt->ShowElement;
 #else
@@ -7118,7 +7129,7 @@ double opt_view_show_time(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_choice[12]->value(opt->ShowTime);
+    GUI::instance()->options->view.choice[12]->value(opt->ShowTime);
 #endif
   return opt->ShowTime;
 #else
@@ -7135,7 +7146,7 @@ double opt_view_show_scale(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_butt[4]->value(opt->ShowScale);
+    GUI::instance()->options->view.butt[4]->value(opt->ShowScale);
 #endif
   return opt->ShowScale;
 #else
@@ -7152,7 +7163,7 @@ double opt_view_draw_strings(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_butt[5]->value(opt->DrawStrings);
+    GUI::instance()->options->view.butt[5]->value(opt->DrawStrings);
 #endif
   return opt->DrawStrings;
 #else
@@ -7171,9 +7182,9 @@ double opt_view_draw_points(OPT_ARGS_NUM)
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)){
     if(opt->DrawPoints)
-      ((Fl_Menu_Item*)WID->view_menu_butt[1]->menu())[0].set();
+      ((Fl_Menu_Item*)GUI::instance()->options->view.menu[1]->menu())[0].set();
     else
-      ((Fl_Menu_Item*)WID->view_menu_butt[1]->menu())[0].clear();
+      ((Fl_Menu_Item*)GUI::instance()->options->view.menu[1]->menu())[0].clear();
   }
 #endif
   return opt->DrawPoints;
@@ -7193,9 +7204,9 @@ double opt_view_draw_lines(OPT_ARGS_NUM)
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)){
     if(opt->DrawLines)
-      ((Fl_Menu_Item*)WID->view_menu_butt[1]->menu())[1].set();
+      ((Fl_Menu_Item*)GUI::instance()->options->view.menu[1]->menu())[1].set();
     else
-      ((Fl_Menu_Item*)WID->view_menu_butt[1]->menu())[1].clear();
+      ((Fl_Menu_Item*)GUI::instance()->options->view.menu[1]->menu())[1].clear();
   }
 #endif
   return opt->DrawLines;
@@ -7215,9 +7226,9 @@ double opt_view_draw_triangles(OPT_ARGS_NUM)
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)){
     if(opt->DrawTriangles)
-      ((Fl_Menu_Item*)WID->view_menu_butt[1]->menu())[2].set();
+      ((Fl_Menu_Item*)GUI::instance()->options->view.menu[1]->menu())[2].set();
     else
-      ((Fl_Menu_Item*)WID->view_menu_butt[1]->menu())[2].clear();
+      ((Fl_Menu_Item*)GUI::instance()->options->view.menu[1]->menu())[2].clear();
   }
 #endif
   return opt->DrawTriangles;
@@ -7237,9 +7248,9 @@ double opt_view_draw_quadrangles(OPT_ARGS_NUM)
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)){
     if(opt->DrawQuadrangles)
-      ((Fl_Menu_Item*)WID->view_menu_butt[1]->menu())[3].set();
+      ((Fl_Menu_Item*)GUI::instance()->options->view.menu[1]->menu())[3].set();
     else
-      ((Fl_Menu_Item*)WID->view_menu_butt[1]->menu())[3].clear();
+      ((Fl_Menu_Item*)GUI::instance()->options->view.menu[1]->menu())[3].clear();
   }
 #endif
   return opt->DrawQuadrangles;
@@ -7259,9 +7270,9 @@ double opt_view_draw_tetrahedra(OPT_ARGS_NUM)
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)){
     if(opt->DrawTetrahedra)
-      ((Fl_Menu_Item*)WID->view_menu_butt[1]->menu())[4].set();
+      ((Fl_Menu_Item*)GUI::instance()->options->view.menu[1]->menu())[4].set();
     else
-      ((Fl_Menu_Item*)WID->view_menu_butt[1]->menu())[4].clear();
+      ((Fl_Menu_Item*)GUI::instance()->options->view.menu[1]->menu())[4].clear();
   }
 #endif
   return opt->DrawTetrahedra;
@@ -7281,9 +7292,9 @@ double opt_view_draw_hexahedra(OPT_ARGS_NUM)
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)){
     if(opt->DrawHexahedra)
-      ((Fl_Menu_Item*)WID->view_menu_butt[1]->menu())[5].set();
+      ((Fl_Menu_Item*)GUI::instance()->options->view.menu[1]->menu())[5].set();
     else
-      ((Fl_Menu_Item*)WID->view_menu_butt[1]->menu())[5].clear();
+      ((Fl_Menu_Item*)GUI::instance()->options->view.menu[1]->menu())[5].clear();
   }
 #endif
   return opt->DrawHexahedra;
@@ -7303,9 +7314,9 @@ double opt_view_draw_prisms(OPT_ARGS_NUM)
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)){
     if(opt->DrawPrisms)
-      ((Fl_Menu_Item*)WID->view_menu_butt[1]->menu())[6].set();
+      ((Fl_Menu_Item*)GUI::instance()->options->view.menu[1]->menu())[6].set();
     else
-      ((Fl_Menu_Item*)WID->view_menu_butt[1]->menu())[6].clear();
+      ((Fl_Menu_Item*)GUI::instance()->options->view.menu[1]->menu())[6].clear();
   }
 #endif
   return opt->DrawPrisms;
@@ -7325,9 +7336,9 @@ double opt_view_draw_pyramids(OPT_ARGS_NUM)
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)){
     if(opt->DrawPyramids)
-      ((Fl_Menu_Item*)WID->view_menu_butt[1]->menu())[7].set();
+      ((Fl_Menu_Item*)GUI::instance()->options->view.menu[1]->menu())[7].set();
     else
-      ((Fl_Menu_Item*)WID->view_menu_butt[1]->menu())[7].clear();
+      ((Fl_Menu_Item*)GUI::instance()->options->view.menu[1]->menu())[7].clear();
   }
 #endif
   return opt->DrawPyramids;
@@ -7347,9 +7358,9 @@ double opt_view_draw_scalars(OPT_ARGS_NUM)
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)){
     if(opt->DrawScalars)
-      ((Fl_Menu_Item*)WID->view_menu_butt[0]->menu())[0].set();
+      ((Fl_Menu_Item*)GUI::instance()->options->view.menu[0]->menu())[0].set();
     else
-      ((Fl_Menu_Item*)WID->view_menu_butt[0]->menu())[0].clear();
+      ((Fl_Menu_Item*)GUI::instance()->options->view.menu[0]->menu())[0].clear();
   }
 #endif
   return opt->DrawScalars;
@@ -7369,9 +7380,9 @@ double opt_view_draw_vectors(OPT_ARGS_NUM)
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)){
     if(opt->DrawVectors)
-      ((Fl_Menu_Item*)WID->view_menu_butt[0]->menu())[1].set();
+      ((Fl_Menu_Item*)GUI::instance()->options->view.menu[0]->menu())[1].set();
     else
-      ((Fl_Menu_Item*)WID->view_menu_butt[0]->menu())[1].clear();
+      ((Fl_Menu_Item*)GUI::instance()->options->view.menu[0]->menu())[1].clear();
   }
 #endif
   return opt->DrawVectors;
@@ -7391,9 +7402,9 @@ double opt_view_draw_tensors(OPT_ARGS_NUM)
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)){
     if(opt->DrawTensors)
-      ((Fl_Menu_Item*)WID->view_menu_butt[0]->menu())[2].set();
+      ((Fl_Menu_Item*)GUI::instance()->options->view.menu[0]->menu())[2].set();
     else
-      ((Fl_Menu_Item*)WID->view_menu_butt[0]->menu())[2].clear();
+      ((Fl_Menu_Item*)GUI::instance()->options->view.menu[0]->menu())[2].clear();
   }
 #endif
   return opt->DrawTensors;
@@ -7412,7 +7423,7 @@ double opt_view_draw_skin_only(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_butt[2]->value(opt->DrawSkinOnly);
+    GUI::instance()->options->view.butt[2]->value(opt->DrawSkinOnly);
 #endif
   return opt->DrawSkinOnly;
 #else
@@ -7432,7 +7443,7 @@ double opt_view_scale_type(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_choice[1]->value(opt->ScaleType - 1);
+    GUI::instance()->options->view.choice[1]->value(opt->ScaleType - 1);
   }
 #endif
   return opt->ScaleType;
@@ -7453,7 +7464,7 @@ double opt_view_range_type(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)){
-    WID->view_choice[7]->value(opt->RangeType - 1);
+    GUI::instance()->options->view.choice[7]->value(opt->RangeType - 1);
     activate_cb(NULL, (void*)"custom_range");
   }
 #endif
@@ -7475,7 +7486,7 @@ double opt_view_tensor_type(OPT_ARGS_NUM)
   }
  #if defined(HAVE_FLTK)
    if(_gui_action_valid(action, num)) {
-     WID->view_choice[4]->value(opt->TensorType - 1);
+     GUI::instance()->options->view.choice[4]->value(opt->TensorType - 1);
    }
  #endif
   return opt->TensorType;
@@ -7496,7 +7507,7 @@ double opt_view_vector_type(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_choice[2]->value(opt->VectorType - 1);
+    GUI::instance()->options->view.choice[2]->value(opt->VectorType - 1);
   }
 #endif
   return opt->VectorType;
@@ -7517,7 +7528,7 @@ double opt_view_glyph_location(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_choice[3]->value(opt->GlyphLocation - 1);
+    GUI::instance()->options->view.choice[3]->value(opt->GlyphLocation - 1);
   }
 #endif
   return opt->GlyphLocation;
@@ -7536,7 +7547,7 @@ double opt_view_center_glyphs(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_butt[1]->value(opt->CenterGlyphs);
+    GUI::instance()->options->view.butt[1]->value(opt->CenterGlyphs);
   }
 #endif
   return opt->CenterGlyphs;
@@ -7554,7 +7565,7 @@ double opt_view_point_size(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[61]->value(opt->PointSize);
+    GUI::instance()->options->view.value[61]->value(opt->PointSize);
 #endif
   return opt->PointSize;
 #else
@@ -7571,7 +7582,7 @@ double opt_view_line_width(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[62]->value(opt->LineWidth);
+    GUI::instance()->options->view.value[62]->value(opt->LineWidth);
 #endif
   return opt->LineWidth;
 #else
@@ -7591,7 +7602,7 @@ double opt_view_point_type(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_choice[5]->value(opt->PointType);
+    GUI::instance()->options->view.choice[5]->value(opt->PointType);
   }
 #endif
   return opt->PointType;
@@ -7612,7 +7623,7 @@ double opt_view_line_type(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_choice[6]->value(opt->LineType);
+    GUI::instance()->options->view.choice[6]->value(opt->LineType);
   }
 #endif
   return opt->LineType;
@@ -7632,7 +7643,7 @@ double opt_view_colormap_alpha(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_colorbar_window->redraw();
+    GUI::instance()->options->view.colorbar->redraw();
   }
 #endif
   return opt->CT.dpar[COLORTABLE_ALPHA];
@@ -7652,7 +7663,7 @@ double opt_view_colormap_alpha_power(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_colorbar_window->redraw();
+    GUI::instance()->options->view.colorbar->redraw();
   }
 #endif
   return opt->CT.dpar[COLORTABLE_ALPHAPOW];
@@ -7672,7 +7683,7 @@ double opt_view_colormap_beta(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_colorbar_window->redraw();
+    GUI::instance()->options->view.colorbar->redraw();
   }
 #endif
   return opt->CT.dpar[COLORTABLE_BETA];
@@ -7692,7 +7703,7 @@ double opt_view_colormap_bias(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_colorbar_window->redraw();
+    GUI::instance()->options->view.colorbar->redraw();
   }
 #endif
   return opt->CT.dpar[COLORTABLE_BIAS];
@@ -7712,7 +7723,7 @@ double opt_view_colormap_curvature(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_colorbar_window->redraw();
+    GUI::instance()->options->view.colorbar->redraw();
   }
 #endif
   return opt->CT.dpar[COLORTABLE_CURVATURE];
@@ -7732,7 +7743,7 @@ double opt_view_colormap_invert(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_colorbar_window->redraw();
+    GUI::instance()->options->view.colorbar->redraw();
   }
 #endif
   return opt->CT.ipar[COLORTABLE_INVERT];
@@ -7752,7 +7763,7 @@ double opt_view_colormap_number(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_colorbar_window->redraw();
+    GUI::instance()->options->view.colorbar->redraw();
   }
 #endif
   return opt->CT.ipar[COLORTABLE_NUMBER];
@@ -7772,7 +7783,7 @@ double opt_view_colormap_rotation(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_colorbar_window->redraw();
+    GUI::instance()->options->view.colorbar->redraw();
   }
 #endif
   return opt->CT.ipar[COLORTABLE_ROTATION];
@@ -7792,7 +7803,7 @@ double opt_view_colormap_swap(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)) {
-    WID->view_colorbar_window->redraw();
+    GUI::instance()->options->view.colorbar->redraw();
   }
 #endif
   return opt->CT.ipar[COLORTABLE_SWAP];
@@ -7813,10 +7824,10 @@ double opt_view_external_view(OPT_ARGS_NUM)
   if(_gui_action_valid(action, num)){
     // warning: Fl_Choice::size() returns number of items+1
     int item = opt->ExternalViewIndex + 1;
-    if(item > -1 && item < WID->view_choice[10]->size()-1)
-      WID->view_choice[10]->value(item);
+    if(item > -1 && item < GUI::instance()->options->view.choice[10]->size()-1)
+      GUI::instance()->options->view.choice[10]->value(item);
     else
-      WID->view_choice[10]->value(0);
+      GUI::instance()->options->view.choice[10]->value(0);
   }
 #endif
   return opt->ExternalViewIndex;
@@ -7837,10 +7848,10 @@ double opt_view_gen_raise_view(OPT_ARGS_NUM)
   if(_gui_action_valid(action, num)){
     // warning: Fl_Choice::size() returns number of items+1
     int item = opt->ViewIndexForGenRaise + 1;
-    if(item > -1 && item < WID->view_choice[11]->size()-1)
-      WID->view_choice[11]->value(item);
+    if(item > -1 && item < GUI::instance()->options->view.choice[11]->size()-1)
+      GUI::instance()->options->view.choice[11]->value(item);
     else
-      WID->view_choice[11]->value(0);
+      GUI::instance()->options->view.choice[11]->value(0);
   }
 #endif
   return opt->ViewIndexForGenRaise;
@@ -7859,7 +7870,7 @@ double opt_view_gen_raise_factor(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num))
-    WID->view_value[2]->value(opt->GenRaiseFactor);
+    GUI::instance()->options->view.value[2]->value(opt->GenRaiseFactor);
 #endif
   return opt->GenRaiseFactor;
 #else
@@ -7877,7 +7888,7 @@ double opt_view_use_gen_raise(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)){
-    WID->view_butt[6]->value(opt->UseGenRaise);
+    GUI::instance()->options->view.butt[6]->value(opt->UseGenRaise);
     activate_cb(NULL, (void*)"general_transform");
   }
 #endif
@@ -7896,7 +7907,7 @@ double opt_view_use_stipple(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)){
-    WID->view_butt[26]->value(opt->UseStipple);
+    GUI::instance()->options->view.butt[26]->value(opt->UseStipple);
   }
 #endif
   return opt->UseStipple;
@@ -7914,7 +7925,7 @@ double opt_view_clip(OPT_ARGS_NUM)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)){
-    WID->reset_clip_browser();
+    GUI::instance()->clipping->resetBrowser();
   }
 #endif
   return opt->Clip;
@@ -8096,7 +8107,7 @@ double opt_print_tex_as_equation(OPT_ARGS_NUM)
 #if defined(HAVE_FLTK)
 
 #define CCC(col,but)                                                    \
-  if(WID && (action & GMSH_GUI)){                                       \
+  if(GUI::available() && (action & GMSH_GUI)){                          \
     Fl_Color c = fl_color_cube(CTX.UNPACK_RED(col)*FL_NUM_RED/256,      \
                                CTX.UNPACK_GREEN(col)*FL_NUM_GREEN/256,  \
                                CTX.UNPACK_BLUE(col)*FL_NUM_BLUE/256);   \
@@ -8112,12 +8123,12 @@ unsigned int opt_general_color_background(OPT_ARGS_COL)
   if(action & GMSH_SET) {
     CTX.color.bg = val;
 #if defined(HAVE_FLTK)
-    if(WID)
-      WID->view_colorbar_window->redraw();
+    if(GUI::available())
+      GUI::instance()->options->view.colorbar->redraw();
 #endif
   }
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.bg, WID->gen_col[0]);
+  CCC(CTX.color.bg, GUI::instance()->options->general.color[0]);
 #endif
   return CTX.color.bg;
 }
@@ -8127,7 +8138,7 @@ unsigned int opt_general_color_background_gradient(OPT_ARGS_COL)
   if(action & GMSH_SET)
     CTX.color.bg_grad = val;
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.bg_grad, WID->gen_col[1]);
+  CCC(CTX.color.bg_grad, GUI::instance()->options->general.color[1]);
 #endif
   return CTX.color.bg_grad;
 }
@@ -8137,7 +8148,7 @@ unsigned int opt_general_color_foreground(OPT_ARGS_COL)
   if(action & GMSH_SET)
     CTX.color.fg = val;
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.fg, WID->gen_col[2]);
+  CCC(CTX.color.fg, GUI::instance()->options->general.color[2]);
 #endif
   return CTX.color.fg;
 }
@@ -8147,7 +8158,7 @@ unsigned int opt_general_color_text(OPT_ARGS_COL)
   if(action & GMSH_SET)
     CTX.color.text = val;
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.text, WID->gen_col[3]);
+  CCC(CTX.color.text, GUI::instance()->options->general.color[3]);
 #endif
   return CTX.color.text;
 }
@@ -8157,7 +8168,7 @@ unsigned int opt_general_color_axes(OPT_ARGS_COL)
   if(action & GMSH_SET)
     CTX.color.axes = val;
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.axes, WID->gen_col[4]);
+  CCC(CTX.color.axes, GUI::instance()->options->general.color[4]);
 #endif
   return CTX.color.axes;
 }
@@ -8167,7 +8178,7 @@ unsigned int opt_general_color_small_axes(OPT_ARGS_COL)
   if(action & GMSH_SET)
     CTX.color.small_axes = val;
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.small_axes, WID->gen_col[5]);
+  CCC(CTX.color.small_axes, GUI::instance()->options->general.color[5]);
 #endif
   return CTX.color.small_axes;
 }
@@ -8178,7 +8189,7 @@ unsigned int opt_general_color_ambient_light(OPT_ARGS_COL)
     for(int i = 0; i < 6; i++)
       CTX.color.ambient_light[i] = val;
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.ambient_light[0], WID->gen_col[6]);
+  CCC(CTX.color.ambient_light[0], GUI::instance()->options->general.color[6]);
 #endif
   return CTX.color.ambient_light[0];
 }
@@ -8189,7 +8200,7 @@ unsigned int opt_general_color_diffuse_light(OPT_ARGS_COL)
     for(int i = 0; i < 6; i++)
       CTX.color.diffuse_light[i] = val;
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.diffuse_light[0], WID->gen_col[7]);
+  CCC(CTX.color.diffuse_light[0], GUI::instance()->options->general.color[7]);
 #endif
   return CTX.color.diffuse_light[0];
 }
@@ -8200,7 +8211,7 @@ unsigned int opt_general_color_specular_light(OPT_ARGS_COL)
     for(int i = 0; i < 6; i++)
       CTX.color.specular_light[i] = val;
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.specular_light[0], WID->gen_col[8]);
+  CCC(CTX.color.specular_light[0], GUI::instance()->options->general.color[8]);
 #endif
   return CTX.color.specular_light[0];
 }
@@ -8210,7 +8221,7 @@ unsigned int opt_geometry_color_points(OPT_ARGS_COL)
   if(action & GMSH_SET)
     CTX.color.geom.point = val;
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.geom.point, WID->geo_col[0]);
+  CCC(CTX.color.geom.point, GUI::instance()->options->geo.color[0]);
 #endif
   return CTX.color.geom.point;
 }
@@ -8220,7 +8231,7 @@ unsigned int opt_geometry_color_lines(OPT_ARGS_COL)
   if(action & GMSH_SET)
     CTX.color.geom.line = val;
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.geom.line, WID->geo_col[1]);
+  CCC(CTX.color.geom.line, GUI::instance()->options->geo.color[1]);
 #endif
   return CTX.color.geom.line;
 }
@@ -8230,7 +8241,7 @@ unsigned int opt_geometry_color_surfaces(OPT_ARGS_COL)
   if(action & GMSH_SET)
     CTX.color.geom.surface = val;
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.geom.surface, WID->geo_col[2]);
+  CCC(CTX.color.geom.surface, GUI::instance()->options->geo.color[2]);
 #endif
   return CTX.color.geom.surface;
 }
@@ -8240,7 +8251,7 @@ unsigned int opt_geometry_color_volumes(OPT_ARGS_COL)
   if(action & GMSH_SET)
     CTX.color.geom.volume = val;
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.geom.volume, WID->geo_col[3]);
+  CCC(CTX.color.geom.volume, GUI::instance()->options->geo.color[3]);
 #endif
   return CTX.color.geom.volume;
 }
@@ -8250,7 +8261,7 @@ unsigned int opt_geometry_color_selection(OPT_ARGS_COL)
   if(action & GMSH_SET)
     CTX.color.geom.selection = val;
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.geom.selection, WID->geo_col[4]);
+  CCC(CTX.color.geom.selection, GUI::instance()->options->geo.color[4]);
 #endif
   return CTX.color.geom.selection;
 }
@@ -8261,7 +8272,7 @@ unsigned int opt_geometry_color_highlight0(OPT_ARGS_COL)
     CTX.color.geom.highlight[0] = val;
   }
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.geom.highlight[0], WID->geo_col[5]);
+  CCC(CTX.color.geom.highlight[0], GUI::instance()->options->geo.color[5]);
 #endif
   return CTX.color.geom.highlight[0];
 }
@@ -8272,7 +8283,7 @@ unsigned int opt_geometry_color_highlight1(OPT_ARGS_COL)
     CTX.color.geom.highlight[1] = val;
   }
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.geom.highlight[1], WID->geo_col[6]);
+  CCC(CTX.color.geom.highlight[1], GUI::instance()->options->geo.color[6]);
 #endif
   return CTX.color.geom.highlight[1];
 }
@@ -8282,7 +8293,7 @@ unsigned int opt_geometry_color_highlight2(OPT_ARGS_COL)
   if(action & GMSH_SET)
     CTX.color.geom.highlight[2] = val;
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.geom.highlight[2], WID->geo_col[7]);
+  CCC(CTX.color.geom.highlight[2], GUI::instance()->options->geo.color[7]);
 #endif
   return CTX.color.geom.highlight[2];
 }
@@ -8292,7 +8303,7 @@ unsigned int opt_geometry_color_tangents(OPT_ARGS_COL)
   if(action & GMSH_SET)
     CTX.color.geom.tangents = val;
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.geom.tangents, WID->geo_col[8]);
+  CCC(CTX.color.geom.tangents, GUI::instance()->options->geo.color[8]);
 #endif
   return CTX.color.geom.tangents;
 }
@@ -8302,7 +8313,7 @@ unsigned int opt_geometry_color_normals(OPT_ARGS_COL)
   if(action & GMSH_SET)
     CTX.color.geom.normals = val;
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.geom.normals, WID->geo_col[9]);
+  CCC(CTX.color.geom.normals, GUI::instance()->options->geo.color[9]);
 #endif
   return CTX.color.geom.normals;
 }
@@ -8313,7 +8324,7 @@ unsigned int opt_geometry_color_projection(OPT_ARGS_COL)
     CTX.color.geom.projection = val;
   }
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.geom.projection, WID->geo_col[10]);
+  CCC(CTX.color.geom.projection, GUI::instance()->options->geo.color[10]);
 #endif
   return CTX.color.geom.projection;
 }
@@ -8324,7 +8335,7 @@ unsigned int opt_mesh_color_points(OPT_ARGS_COL)
     CTX.color.mesh.vertex = val;
   }
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.mesh.vertex, WID->mesh_col[0]);
+  CCC(CTX.color.mesh.vertex, GUI::instance()->options->mesh.color[0]);
 #endif
   return CTX.color.mesh.vertex;
 }
@@ -8335,7 +8346,7 @@ unsigned int opt_mesh_color_points_sup(OPT_ARGS_COL)
     CTX.color.mesh.vertex_sup = val;
   }
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.mesh.vertex_sup, WID->mesh_col[1]);
+  CCC(CTX.color.mesh.vertex_sup, GUI::instance()->options->mesh.color[1]);
 #endif
   return CTX.color.mesh.vertex_sup;
 }
@@ -8350,7 +8361,7 @@ unsigned int opt_mesh_color_lines(OPT_ARGS_COL)
     CTX.color.mesh.line = val;
   }
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.mesh.line, WID->mesh_col[2]);
+  CCC(CTX.color.mesh.line, GUI::instance()->options->mesh.color[2]);
 #endif
   return CTX.color.mesh.line;
 }
@@ -8365,7 +8376,7 @@ unsigned int opt_mesh_color_triangles(OPT_ARGS_COL)
     CTX.color.mesh.triangle = val;
   }
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.mesh.triangle, WID->mesh_col[3]);
+  CCC(CTX.color.mesh.triangle, GUI::instance()->options->mesh.color[3]);
 #endif
   return CTX.color.mesh.triangle;
 }
@@ -8380,7 +8391,7 @@ unsigned int opt_mesh_color_quadrangles(OPT_ARGS_COL)
     CTX.color.mesh.quadrangle = val;
   }
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.mesh.quadrangle, WID->mesh_col[4]);
+  CCC(CTX.color.mesh.quadrangle, GUI::instance()->options->mesh.color[4]);
 #endif
   return CTX.color.mesh.quadrangle;
 }
@@ -8395,7 +8406,7 @@ unsigned int opt_mesh_color_tetrahedra(OPT_ARGS_COL)
     CTX.color.mesh.tetrahedron = val;
   }
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.mesh.tetrahedron, WID->mesh_col[5]);
+  CCC(CTX.color.mesh.tetrahedron, GUI::instance()->options->mesh.color[5]);
 #endif
   return CTX.color.mesh.tetrahedron;
 }
@@ -8410,7 +8421,7 @@ unsigned int opt_mesh_color_hexahedra(OPT_ARGS_COL)
     CTX.color.mesh.hexahedron = val;
   }
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.mesh.hexahedron, WID->mesh_col[6]);
+  CCC(CTX.color.mesh.hexahedron, GUI::instance()->options->mesh.color[6]);
 #endif
   return CTX.color.mesh.hexahedron;
 }
@@ -8425,7 +8436,7 @@ unsigned int opt_mesh_color_prisms(OPT_ARGS_COL)
     CTX.color.mesh.prism = val;
   }
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.mesh.prism, WID->mesh_col[7]);
+  CCC(CTX.color.mesh.prism, GUI::instance()->options->mesh.color[7]);
 #endif
   return CTX.color.mesh.prism;
 }
@@ -8440,7 +8451,7 @@ unsigned int opt_mesh_color_pyramid(OPT_ARGS_COL)
     CTX.color.mesh.pyramid = val;
   }
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.mesh.pyramid, WID->mesh_col[8]);
+  CCC(CTX.color.mesh.pyramid, GUI::instance()->options->mesh.color[8]);
 #endif
   return CTX.color.mesh.pyramid;
 }
@@ -8451,7 +8462,7 @@ unsigned int opt_mesh_color_tangents(OPT_ARGS_COL)
     CTX.color.mesh.tangents = val;
   }
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.mesh.tangents, WID->mesh_col[9]);
+  CCC(CTX.color.mesh.tangents, GUI::instance()->options->mesh.color[9]);
 #endif
   return CTX.color.mesh.tangents;
 }
@@ -8462,7 +8473,7 @@ unsigned int opt_mesh_color_normals(OPT_ARGS_COL)
     CTX.color.mesh.normals = val;
   }
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.mesh.normals, WID->mesh_col[10]);
+  CCC(CTX.color.mesh.normals, GUI::instance()->options->mesh.color[10]);
 #endif
   return CTX.color.mesh.normals;
 }
@@ -8477,7 +8488,7 @@ unsigned int opt_mesh_color_(int i, OPT_ARGS_COL)
     CTX.color.mesh.carousel[i] = val;
   }
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.mesh.carousel[i], WID->mesh_col[11+i]);
+  CCC(CTX.color.mesh.carousel[i], GUI::instance()->options->mesh.color[11+i]);
 #endif
   return CTX.color.mesh.carousel[i];
 }
@@ -8513,7 +8524,7 @@ unsigned int opt_view_color_points(OPT_ARGS_COL)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)){
-    CCC(opt->color.point, WID->view_col[0]);
+    CCC(opt->color.point, GUI::instance()->options->view.color[0]);
   }
 #endif
   return opt->color.point;
@@ -8532,7 +8543,7 @@ unsigned int opt_view_color_lines(OPT_ARGS_COL)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)){
-    CCC(opt->color.line, WID->view_col[1]);
+    CCC(opt->color.line, GUI::instance()->options->view.color[1]);
   }
 #endif
   return opt->color.line;
@@ -8551,7 +8562,7 @@ unsigned int opt_view_color_triangles(OPT_ARGS_COL)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)){
-    CCC(opt->color.triangle, WID->view_col[2]);
+    CCC(opt->color.triangle, GUI::instance()->options->view.color[2]);
   }
 #endif
   return opt->color.triangle;
@@ -8570,7 +8581,7 @@ unsigned int opt_view_color_quadrangles(OPT_ARGS_COL)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)){
-    CCC(opt->color.quadrangle, WID->view_col[3]);
+    CCC(opt->color.quadrangle, GUI::instance()->options->view.color[3]);
   }
 #endif
   return opt->color.quadrangle;
@@ -8589,7 +8600,7 @@ unsigned int opt_view_color_tetrahedra(OPT_ARGS_COL)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)){
-    CCC(opt->color.tetrahedron, WID->view_col[4]);
+    CCC(opt->color.tetrahedron, GUI::instance()->options->view.color[4]);
   }
 #endif
   return opt->color.tetrahedron;
@@ -8608,7 +8619,7 @@ unsigned int opt_view_color_hexahedra(OPT_ARGS_COL)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)){
-    CCC(opt->color.hexahedron, WID->view_col[5]);
+    CCC(opt->color.hexahedron, GUI::instance()->options->view.color[5]);
   }
 #endif
   return opt->color.hexahedron;
@@ -8627,7 +8638,7 @@ unsigned int opt_view_color_prisms(OPT_ARGS_COL)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)){
-    CCC(opt->color.prism, WID->view_col[6]);
+    CCC(opt->color.prism, GUI::instance()->options->view.color[6]);
   }
 #endif
   return opt->color.prism;
@@ -8646,7 +8657,7 @@ unsigned int opt_view_color_pyramids(OPT_ARGS_COL)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)){
-    CCC(opt->color.pyramid, WID->view_col[7]);
+    CCC(opt->color.pyramid, GUI::instance()->options->view.color[7]);
   }
 #endif
   return opt->color.pyramid;
@@ -8665,7 +8676,7 @@ unsigned int opt_view_color_tangents(OPT_ARGS_COL)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)){
-    CCC(opt->color.tangents, WID->view_col[8]);
+    CCC(opt->color.tangents, GUI::instance()->options->view.color[8]);
   }
 #endif
   return opt->color.tangents;
@@ -8684,7 +8695,7 @@ unsigned int opt_view_color_normals(OPT_ARGS_COL)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)){
-    CCC(opt->color.normals, WID->view_col[9]);
+    CCC(opt->color.normals, GUI::instance()->options->view.color[9]);
   }
 #endif
   return opt->color.normals;
@@ -8702,7 +8713,7 @@ unsigned int opt_view_color_text2d(OPT_ARGS_COL)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)){
-    CCC(opt->color.text2d, WID->view_col[10]);
+    CCC(opt->color.text2d, GUI::instance()->options->view.color[10]);
   }
 #endif
   return opt->color.text2d;
@@ -8720,7 +8731,7 @@ unsigned int opt_view_color_text3d(OPT_ARGS_COL)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)){
-    CCC(opt->color.text3d, WID->view_col[11]);
+    CCC(opt->color.text3d, GUI::instance()->options->view.color[11]);
   }
 #endif
   return opt->color.text3d;
@@ -8738,7 +8749,7 @@ unsigned int opt_view_color_axes(OPT_ARGS_COL)
   }
 #if defined(HAVE_FLTK)
   if(_gui_action_valid(action, num)){
-    CCC(opt->color.axes, WID->view_col[12]);
+    CCC(opt->color.axes, GUI::instance()->options->view.color[12]);
   }
 #endif
   return opt->color.axes;
diff --git a/Common/Options.h b/Common/Options.h
index b8e71c9b2f4119c537e9171083acb54d679584b9..8538c6ace97f03b2c4b59f14f3940cb5676153e0 100644
--- a/Common/Options.h
+++ b/Common/Options.h
@@ -408,7 +408,7 @@ double opt_geometry_occ_fix_small_faces(OPT_ARGS_NUM);
 double opt_geometry_occ_sew_faces(OPT_ARGS_NUM);
 double opt_geometry_old_circle(OPT_ARGS_NUM);
 double opt_geometry_old_newreg(OPT_ARGS_NUM);
-double opt_geometry_circle_points(OPT_ARGS_NUM);
+double opt_geometry_num_sub_edges(OPT_ARGS_NUM);
 double opt_geometry_extrude_spline_points(OPT_ARGS_NUM);
 double opt_geometry_extrude_return_lateral(OPT_ARGS_NUM);
 double opt_geometry_scaling_factor(OPT_ARGS_NUM);
diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp
index 5fce333190e9efbf240742138cfd02f8a8c74f5f..b9a6249f3c9b43b39ec96e6d107141a8f1bc6d0a 100644
--- a/Fltk/Callbacks.cpp
+++ b/Fltk/Callbacks.cpp
@@ -9,8 +9,25 @@
 #include <map>
 #include <string>
 #include <sstream>
-
-#include "GmshUI.h"
+#include <FL/fl_ask.H>
+#include <FL/Fl_Color_Chooser.H>
+#include "GUI.h"
+#include "menuWindow.h"
+#include "graphicWindow.h"
+#include "optionWindow.h"
+#include "visibilityWindow.h"
+#include "clippingWindow.h"
+#include "statisticsWindow.h"
+#include "solverWindow.h"
+#include "manipWindow.h"
+#include "messageWindow.h"
+#include "fieldWindow.h"
+#include "pluginWindow.h"
+#include "contextWindow.h"
+#include "aboutWindow.h"
+#include "partitionDialog.h"
+#include "extraDialogs.h"
+#include "fileDialogs.h"
 #include "GmshMessage.h"
 #include "MallocUtils.h"
 #include "ListUtils.h"
@@ -31,8 +48,6 @@
 #include "CommandLine.h"
 #include "Context.h"
 #include "Options.h"
-#include "GUI.h"
-#include "GUI_Extras.h"
 #include "Callbacks.h"
 #include "Plugin.h"
 #include "PluginManager.h"
@@ -44,15 +59,9 @@
 #include "BackgroundMesh.h"
 
 extern Context_T CTX;
-extern GUI *WID;
 
 // Helper routines
 
-int SetGlobalShortcut(int event)
-{
-  return WID->global_shortcuts(event);
-}
-
 int SelectContour(int type, int num, List_T * List)
 {
   int k = 0, ip;
@@ -103,11 +112,11 @@ void view_color_cb(CALLBACK_ARGS)
 {
   unsigned int (*fct) (int, int, unsigned int);
   fct = (unsigned int (*)(int, int, unsigned int))data;
-  uchar r = CTX.UNPACK_RED(fct(WID->view_number, GMSH_GET, 0));
-  uchar g = CTX.UNPACK_GREEN(fct(WID->view_number, GMSH_GET, 0));
-  uchar b = CTX.UNPACK_BLUE(fct(WID->view_number, GMSH_GET, 0));
+  uchar r = CTX.UNPACK_RED(fct(GUI::instance()->options->view.index, GMSH_GET, 0));
+  uchar g = CTX.UNPACK_GREEN(fct(GUI::instance()->options->view.index, GMSH_GET, 0));
+  uchar b = CTX.UNPACK_BLUE(fct(GUI::instance()->options->view.index, GMSH_GET, 0));
   if(fl_color_chooser("Color Chooser", r, g, b))
-    fct(WID->view_number, GMSH_SET | GMSH_GUI, CTX.PACK_COLOR(r, g, b, 255));
+    fct(GUI::instance()->options->view.index, GMSH_SET | GMSH_GUI, CTX.PACK_COLOR(r, g, b, 255));
   Draw();
 }
 
@@ -122,50 +131,50 @@ void window_cb(CALLBACK_ARGS)
   const char *str = (const char*)data;
 
   if(!strcmp(str, "minimize")){
-    WID->g_window->iconize();
-    if(WID->opt_window->shown()) WID->opt_window->iconize();
-    if(WID->plugin_window->shown()) WID->plugin_window->iconize();
-    if(WID->field_window->shown()) WID->field_window->iconize();
-    if(WID->vis_window->shown()) WID->vis_window->iconize();
-    if(WID->clip_window->shown()) WID->clip_window->iconize();
-    if(WID->manip_window->shown()) WID->manip_window->iconize();
-    if(WID->stat_window->shown()) WID->stat_window->iconize();
-    if(WID->msg_window->shown()) WID->msg_window->iconize();
-    WID->m_window->iconize();
+    GUI::instance()->graph[0]->win->iconize();
+    if(GUI::instance()->options->win->shown()) GUI::instance()->options->win->iconize();
+    if(GUI::instance()->plugins->win->shown()) GUI::instance()->plugins->win->iconize();
+    if(GUI::instance()->fields->win->shown()) GUI::instance()->fields->win->iconize();
+    if(GUI::instance()->visibility->win->shown()) GUI::instance()->visibility->win->iconize();
+    if(GUI::instance()->clipping->win->shown()) GUI::instance()->clipping->win->iconize();
+    if(GUI::instance()->manip->win->shown()) GUI::instance()->manip->win->iconize();
+    if(GUI::instance()->stats->win->shown()) GUI::instance()->stats->win->iconize();
+    if(GUI::instance()->messages->win->shown()) GUI::instance()->messages->win->iconize();
+    GUI::instance()->menu->win->iconize();
   }
   else if(!strcmp(str, "zoom")){
     if(zoom){
-      oldx = WID->g_window->x();
-      oldy = WID->g_window->y();
-      oldw = WID->g_window->w();
-      oldh = WID->g_window->h();
-      WID->g_window->resize(Fl::x(), Fl::y(), Fl::w(), Fl::h());
+      oldx = GUI::instance()->graph[0]->win->x();
+      oldy = GUI::instance()->graph[0]->win->y();
+      oldw = GUI::instance()->graph[0]->win->w();
+      oldh = GUI::instance()->graph[0]->win->h();
+      GUI::instance()->graph[0]->win->resize(Fl::x(), Fl::y(), Fl::w(), Fl::h());
       zoom = 0;
     }
     else{
-      WID->g_window->resize(oldx, oldy, oldw, oldh);
+      GUI::instance()->graph[0]->win->resize(oldx, oldy, oldw, oldh);
       zoom = 1;
     }
-    WID->g_window->show();
-    WID->m_window->show();
+    GUI::instance()->graph[0]->win->show();
+    GUI::instance()->menu->win->show();
   }
   else if(!strcmp(str, "front")){
     // the order is important!
-    WID->g_window->show();
-    if(WID->opt_window->shown()) WID->opt_window->show();
-    if(WID->plugin_window->shown()) WID->plugin_window->show();
-    if(WID->field_window->shown()) WID->field_window->show();
-    if(WID->context_geometry_window->shown()) WID->context_geometry_window->show();
-    if(WID->context_mesh_window->shown()) WID->context_mesh_window->show();
-    for(int i = 0; i < MAXSOLVERS; i++) {
-      if(WID->solver[i].window->shown()) WID->solver[i].window->show();
+    GUI::instance()->graph[0]->win->show();
+    if(GUI::instance()->options->win->shown()) GUI::instance()->options->win->show();
+    if(GUI::instance()->plugins->win->shown()) GUI::instance()->plugins->win->show();
+    if(GUI::instance()->fields->win->shown()) GUI::instance()->fields->win->show();
+    if(GUI::instance()->geoContext->win->shown()) GUI::instance()->geoContext->win->show();
+    if(GUI::instance()->meshContext->win->shown()) GUI::instance()->meshContext->win->show();
+    for(unsigned int i = 0; i < GUI::instance()->solver.size(); i++) {
+      if(GUI::instance()->solver[i]->win->shown()) GUI::instance()->solver[i]->win->show();
     }
-    if(WID->vis_window->shown()) WID->vis_window->show();
-    if(WID->clip_window->shown()) WID->clip_window->show();
-    if(WID->manip_window->shown()) WID->manip_window->show();
-    if(WID->stat_window->shown()) WID->stat_window->show();
-    if(WID->msg_window->shown()) WID->msg_window->show();
-    WID->m_window->show();
+    if(GUI::instance()->visibility->win->shown()) GUI::instance()->visibility->win->show();
+    if(GUI::instance()->clipping->win->shown()) GUI::instance()->clipping->win->show();
+    if(GUI::instance()->manip->win->shown()) GUI::instance()->manip->win->show();
+    if(GUI::instance()->stats->win->shown()) GUI::instance()->stats->win->show();
+    if(GUI::instance()->messages->win->shown()) GUI::instance()->messages->win->show();
+    GUI::instance()->menu->win->show();
   }
 }
 
@@ -176,194 +185,196 @@ void activate_cb(CALLBACK_ARGS)
 
   if(!data) return;
 
+  optionWindow *o = GUI::instance()->options;
+
   const char *str = (const char*)data;
 
   if(!strcmp(str, "fast_redraw")){
-    if(WID->gen_butt[2]->value())
-      WID->opt_redraw->show();
+    if(o->general.butt[2]->value())
+      GUI::instance()->options->redraw->show();
     else
-      WID->opt_redraw->hide();
+      GUI::instance()->options->redraw->hide();
   }
   else if(!strcmp(str, "rotation_center")){
-    if(WID->gen_butt[15]->value()) {
-      WID->gen_push_butt[0]->deactivate();
-      WID->gen_value[8]->deactivate();
-      WID->gen_value[9]->deactivate();
-      WID->gen_value[10]->deactivate();
+    if(o->general.butt[15]->value()) {
+      o->general.push[0]->deactivate();
+      o->general.value[8]->deactivate();
+      o->general.value[9]->deactivate();
+      o->general.value[10]->deactivate();
     }
     else {
-      WID->gen_push_butt[0]->activate();
-      WID->gen_value[8]->activate();
-      WID->gen_value[9]->activate();
-      WID->gen_value[10]->activate();
+      o->general.push[0]->activate();
+      o->general.value[8]->activate();
+      o->general.value[9]->activate();
+      o->general.value[10]->activate();
     }
   }
   else if(!strcmp(str, "general_axes")){
-    if(WID->gen_choice[4]->value()){
-      WID->gen_value[17]->activate();
-      WID->gen_value[18]->activate();
-      WID->gen_value[19]->activate();
-      WID->gen_input[3]->activate();
-      WID->gen_input[4]->activate();
-      WID->gen_input[5]->activate();
-      WID->gen_input[6]->activate();
-      WID->gen_input[7]->activate();
-      WID->gen_input[8]->activate();
+    if(o->general.choice[4]->value()){
+      o->general.value[17]->activate();
+      o->general.value[18]->activate();
+      o->general.value[19]->activate();
+      o->general.input[3]->activate();
+      o->general.input[4]->activate();
+      o->general.input[5]->activate();
+      o->general.input[6]->activate();
+      o->general.input[7]->activate();
+      o->general.input[8]->activate();
     }
     else{
-      WID->gen_value[17]->deactivate();
-      WID->gen_value[18]->deactivate();
-      WID->gen_value[19]->deactivate();
-      WID->gen_input[3]->deactivate();
-      WID->gen_input[4]->deactivate();
-      WID->gen_input[5]->deactivate();
-      WID->gen_input[6]->deactivate();
-      WID->gen_input[7]->deactivate();
-      WID->gen_input[8]->deactivate();
+      o->general.value[17]->deactivate();
+      o->general.value[18]->deactivate();
+      o->general.value[19]->deactivate();
+      o->general.input[3]->deactivate();
+      o->general.input[4]->deactivate();
+      o->general.input[5]->deactivate();
+      o->general.input[6]->deactivate();
+      o->general.input[7]->deactivate();
+      o->general.input[8]->deactivate();
     }
   }
   else if(!strcmp(str, "general_axes_auto")){
-    if(WID->gen_butt[0]->value()){
-      WID->gen_value[20]->deactivate();
-      WID->gen_value[21]->deactivate();
-      WID->gen_value[22]->deactivate();
-      WID->gen_value[23]->deactivate();
-      WID->gen_value[24]->deactivate();
-      WID->gen_value[25]->deactivate();
+    if(o->general.butt[0]->value()){
+      o->general.value[20]->deactivate();
+      o->general.value[21]->deactivate();
+      o->general.value[22]->deactivate();
+      o->general.value[23]->deactivate();
+      o->general.value[24]->deactivate();
+      o->general.value[25]->deactivate();
     }
     else{
-      WID->gen_value[20]->activate();
-      WID->gen_value[21]->activate();
-      WID->gen_value[22]->activate();
-      WID->gen_value[23]->activate();
-      WID->gen_value[24]->activate();
-      WID->gen_value[25]->activate();
+      o->general.value[20]->activate();
+      o->general.value[21]->activate();
+      o->general.value[22]->activate();
+      o->general.value[23]->activate();
+      o->general.value[24]->activate();
+      o->general.value[25]->activate();
     }
   }
   else if(!strcmp(str, "general_small_axes")){
-    if(WID->gen_butt[1]->value()){
-      WID->gen_value[26]->activate();
-      WID->gen_value[27]->activate();
+    if(o->general.butt[1]->value()){
+      o->general.value[26]->activate();
+      o->general.value[27]->activate();
     }
     else{
-      WID->gen_value[26]->deactivate();
-      WID->gen_value[27]->deactivate();
+      o->general.value[26]->deactivate();
+      o->general.value[27]->deactivate();
     }
   }
   else if(!strcmp(str, "custom_range")){
-    if(WID->view_choice[7]->value() == 1){
-      WID->view_value[31]->activate();
-      WID->view_value[32]->activate();
-      WID->view_push_butt[1]->activate();
-      WID->view_push_butt[2]->activate();
+    if(o->view.choice[7]->value() == 1){
+      o->view.value[31]->activate();
+      o->view.value[32]->activate();
+      o->view.push[1]->activate();
+      o->view.push[2]->activate();
     }
     else {
-      WID->view_value[31]->deactivate();
-      WID->view_value[32]->deactivate();
-      WID->view_push_butt[1]->deactivate();
-      WID->view_push_butt[2]->deactivate();
+      o->view.value[31]->deactivate();
+      o->view.value[32]->deactivate();
+      o->view.push[1]->deactivate();
+      o->view.push[2]->deactivate();
     }
   }
   else if(!strcmp(str, "general_transform")){
-    if(WID->view_butt[6]->value()){
-      WID->view_choice[11]->activate();
-      WID->view_value[2]->activate();
-      WID->view_input[4]->activate();
-      WID->view_input[5]->activate();
-      WID->view_input[6]->activate();
+    if(o->view.butt[6]->value()){
+      o->view.choice[11]->activate();
+      o->view.value[2]->activate();
+      o->view.input[4]->activate();
+      o->view.input[5]->activate();
+      o->view.input[6]->activate();
     }
     else{
-      WID->view_choice[11]->deactivate();
-      WID->view_value[2]->deactivate();
-      WID->view_input[4]->deactivate();
-      WID->view_input[5]->deactivate();
-      WID->view_input[6]->deactivate();
+      o->view.choice[11]->deactivate();
+      o->view.value[2]->deactivate();
+      o->view.input[4]->deactivate();
+      o->view.input[5]->deactivate();
+      o->view.input[6]->deactivate();
     }
   }
   else if(!strcmp(str, "mesh_light")){
-    if(WID->mesh_butt[17]->value()){
-      WID->mesh_butt[18]->activate();
-      WID->mesh_butt[19]->activate();
-      WID->mesh_butt[20]->activate();
-      WID->mesh_butt[0]->activate();
-      WID->mesh_value[18]->activate();
+    if(o->mesh.butt[17]->value()){
+      o->mesh.butt[18]->activate();
+      o->mesh.butt[19]->activate();
+      o->mesh.butt[20]->activate();
+      o->mesh.butt[0]->activate();
+      o->mesh.value[18]->activate();
     }
     else{
-      WID->mesh_butt[18]->deactivate();
-      WID->mesh_butt[19]->deactivate();
-      WID->mesh_butt[20]->deactivate();
-      WID->mesh_butt[0]->deactivate();
-      WID->mesh_value[18]->deactivate();
+      o->mesh.butt[18]->deactivate();
+      o->mesh.butt[19]->deactivate();
+      o->mesh.butt[20]->deactivate();
+      o->mesh.butt[0]->deactivate();
+      o->mesh.value[18]->deactivate();
     }
   }
   else if(!strcmp(str, "view_light")){
-    if(WID->view_butt[11]->value()){
-      WID->view_butt[8]->activate();
-      WID->view_butt[9]->activate();
-      WID->view_butt[12]->activate();
-      WID->view_value[10]->activate();
+    if(o->view.butt[11]->value()){
+      o->view.butt[8]->activate();
+      o->view.butt[9]->activate();
+      o->view.butt[12]->activate();
+      o->view.value[10]->activate();
     }
     else{
-      WID->view_butt[8]->deactivate();
-      WID->view_butt[9]->deactivate();
-      WID->view_butt[12]->deactivate();
-      WID->view_value[10]->deactivate();
+      o->view.butt[8]->deactivate();
+      o->view.butt[9]->deactivate();
+      o->view.butt[12]->deactivate();
+      o->view.value[10]->deactivate();
     }
   }
   else if(!strcmp(str, "view_axes")){
-    if(WID->view_choice[8]->value()){
-      WID->view_value[3]->activate();
-      WID->view_value[4]->activate();
-      WID->view_value[5]->activate();
-      WID->view_input[7]->activate();
-      WID->view_input[8]->activate();
-      WID->view_input[9]->activate();
-      WID->view_input[10]->activate();
-      WID->view_input[11]->activate();
-      WID->view_input[12]->activate();
+    if(o->view.choice[8]->value()){
+      o->view.value[3]->activate();
+      o->view.value[4]->activate();
+      o->view.value[5]->activate();
+      o->view.input[7]->activate();
+      o->view.input[8]->activate();
+      o->view.input[9]->activate();
+      o->view.input[10]->activate();
+      o->view.input[11]->activate();
+      o->view.input[12]->activate();
     }
     else{
-      WID->view_value[3]->deactivate();
-      WID->view_value[4]->deactivate();
-      WID->view_value[5]->deactivate();
-      WID->view_input[7]->deactivate();
-      WID->view_input[8]->deactivate();
-      WID->view_input[9]->deactivate();
-      WID->view_input[10]->deactivate();
-      WID->view_input[11]->deactivate();
-      WID->view_input[12]->deactivate();
+      o->view.value[3]->deactivate();
+      o->view.value[4]->deactivate();
+      o->view.value[5]->deactivate();
+      o->view.input[7]->deactivate();
+      o->view.input[8]->deactivate();
+      o->view.input[9]->deactivate();
+      o->view.input[10]->deactivate();
+      o->view.input[11]->deactivate();
+      o->view.input[12]->deactivate();
     }
   }
   else if(!strcmp(str, "view_axes_auto_3d")){
-    if(WID->view_butt[25]->value()){
-      WID->view_value[13]->deactivate();
-      WID->view_value[14]->deactivate();
-      WID->view_value[15]->deactivate();
-      WID->view_value[16]->deactivate();
-      WID->view_value[17]->deactivate();
-      WID->view_value[18]->deactivate();
+    if(o->view.butt[25]->value()){
+      o->view.value[13]->deactivate();
+      o->view.value[14]->deactivate();
+      o->view.value[15]->deactivate();
+      o->view.value[16]->deactivate();
+      o->view.value[17]->deactivate();
+      o->view.value[18]->deactivate();
     }
     else{
-      WID->view_value[13]->activate();
-      WID->view_value[14]->activate();
-      WID->view_value[15]->activate();
-      WID->view_value[16]->activate();
-      WID->view_value[17]->activate();
-      WID->view_value[18]->activate();
+      o->view.value[13]->activate();
+      o->view.value[14]->activate();
+      o->view.value[15]->activate();
+      o->view.value[16]->activate();
+      o->view.value[17]->activate();
+      o->view.value[18]->activate();
     }
   }
   else if(!strcmp(str, "view_axes_auto_2d")){
-    if(WID->view_butt[7]->value()){
-      WID->view_value[20]->deactivate();
-      WID->view_value[21]->deactivate();
-      WID->view_value[22]->deactivate();
-      WID->view_value[23]->deactivate();
+    if(o->view.butt[7]->value()){
+      o->view.value[20]->deactivate();
+      o->view.value[21]->deactivate();
+      o->view.value[22]->deactivate();
+      o->view.value[23]->deactivate();
     }
     else{
-      WID->view_value[20]->activate();
-      WID->view_value[21]->activate();
-      WID->view_value[22]->activate();
-      WID->view_value[23]->activate();
+      o->view.value[20]->activate();
+      o->view.value[21]->activate();
+      o->view.value[22]->activate();
+      o->view.value[23]->activate();
     }
   }
 }
@@ -374,7 +385,7 @@ void status_xyz1p_cb(CALLBACK_ARGS)
 {
   const char *str = (const char*)data;
 
-  drawContext *ctx = WID->g_opengl_window->getDrawContext();
+  drawContext *ctx = GUI::instance()->graph[0]->gl->getDrawContext();
 
   if(!strcmp(str, "r")){ // rotate 90 degress around axis perp to the screen
     double axis[3] = {0., 0., 1.};
@@ -455,17 +466,17 @@ void status_xyz1p_cb(CALLBACK_ARGS)
   }
   else if(!strcmp(str, "?")){ // display options
     Print_Options(0, GMSH_FULLRC, 0, 1, NULL);
-    WID->create_message_window();
+    GUI::instance()->messages->show();
   }
   else if(!strcmp(str, "S")){ // mouse selection
     if(CTX.mouse_selection){
       opt_general_mouse_selection(0, GMSH_SET | GMSH_GUI, 0);
-      WID->g_opengl_window->cursor(FL_CURSOR_DEFAULT, FL_BLACK, FL_WHITE);
+      GUI::instance()->graph[0]->gl->cursor(FL_CURSOR_DEFAULT, FL_BLACK, FL_WHITE);
     }
     else
       opt_general_mouse_selection(0, GMSH_SET | GMSH_GUI, 1);
   }
-  WID->update_manip_window();
+  GUI::instance()->manip->update();
 }
 
 static int stop_anim, view_in_cycle = -1;
@@ -506,7 +517,7 @@ void ManualPlay(int time, int step)
 void status_play_cb(CALLBACK_ARGS)
 {
   static double anim_time;
-  WID->set_anim_buttons(0);
+  GUI::instance()->graph[0]->setAnimButtons(0);
   stop_anim = 0;
   anim_time = GetTimeInSeconds();
   while(1) {
@@ -516,14 +527,14 @@ void status_play_cb(CALLBACK_ARGS)
       anim_time = GetTimeInSeconds();
       ManualPlay(!CTX.post.anim_cycle, 1);
     }
-    WID->check();
+    GUI::instance()->check();
   }
 }
 
 void status_pause_cb(CALLBACK_ARGS)
 {
   stop_anim = 1;
-  WID->set_anim_buttons(1);
+  GUI::instance()->graph[0]->setAnimButtons(1);
 }
 
 void status_rewind_cb(CALLBACK_ARGS)
@@ -631,7 +642,7 @@ void file_open_cb(CALLBACK_ARGS)
     Draw();
   }
   if(n != (int)PView::list.size())
-    WID->set_context(menu_post, 0);
+    GUI::instance()->menu->setContext(menu_post, 0);
 }
 
 void file_merge_cb(CALLBACK_ARGS)
@@ -644,7 +655,7 @@ void file_merge_cb(CALLBACK_ARGS)
     Draw();
   }
   if(n != (int)PView::list.size())
-    WID->set_context(menu_post, 0);
+    GUI::instance()->menu->setContext(menu_post, 0);
 }
 
 int _save_msh(const char *name){ return msh_dialog(name); }
@@ -815,33 +826,12 @@ void file_quit_cb(CALLBACK_ARGS)
 
 void options_cb(CALLBACK_ARGS)
 {
-  WID->create_option_window();
+  GUI::instance()->options->win->show();
 }
 
 void options_browser_cb(CALLBACK_ARGS)
 {
-  switch (WID->opt_browser->value()) {
-  case 0:
-    break;
-  case 1:
-    WID->create_general_options_window();
-    break;
-  case 2:
-    WID->create_geometry_options_window();
-    break;
-  case 3:
-    WID->create_mesh_options_window();
-    break;
-  case 4:
-    WID->create_solver_options_window();
-    break;
-  case 5:
-    WID->create_post_options_window();
-    break;
-  default:
-    WID->create_view_options_window(WID->opt_browser->value() - 6);
-    break;
-  }
+  GUI::instance()->options->showGroup(GUI::instance()->options->browser->value());
 }
 
 void options_save_cb(CALLBACK_ARGS)
@@ -858,8 +848,8 @@ void options_restore_defaults_cb(CALLBACK_ARGS)
   UnlinkFile(CTX.options_filename_fullpath);
   ReInit_Options(0);
   Init_Options_GUI(0);
-  if(WID && WID->get_context() == 3)    // hack to refresh the buttons
-    WID->set_context(menu_post, 0);
+  if(GUI::instance()->menu->module->value() == 3) // hack to refresh the buttons
+    GUI::instance()->menu->setContext(menu_post, 0);
   Draw();
 }
 
@@ -867,12 +857,12 @@ void options_restore_defaults_cb(CALLBACK_ARGS)
 
 void general_options_cb(CALLBACK_ARGS)
 {
-  WID->create_general_options_window();
+  GUI::instance()->options->showGroup(1);
 }
 
 void general_options_color_scheme_cb(CALLBACK_ARGS)
 {
-  opt_general_color_scheme(0, GMSH_SET, WID->gen_choice[3]->value());
+  opt_general_color_scheme(0, GMSH_SET, GUI::instance()->options->general.choice[3]->value());
   Draw();
 }
 
@@ -898,7 +888,7 @@ void general_options_rotation_center_select_cb(CALLBACK_ARGS)
       pc = regions[0]->bounds().center();
     else if(elements.size())
       pc = elements[0]->barycenter();
-    opt_general_rotation_center_cg(0, GMSH_SET, WID->gen_butt[15]->value());
+    opt_general_rotation_center_cg(0, GMSH_SET, GUI::instance()->options->general.butt[15]->value());
     opt_general_rotation_center0(0, GMSH_SET|GMSH_GUI, pc.x());
     opt_general_rotation_center1(0, GMSH_SET|GMSH_GUI, pc.y());
     opt_general_rotation_center2(0, GMSH_SET|GMSH_GUI, pc.z());
@@ -912,12 +902,14 @@ void general_options_ok_cb(CALLBACK_ARGS)
 {
   activate_cb(NULL, data);
 
+  optionWindow *o = GUI::instance()->options;
+
   static double lc = 0.;
   if(lc != CTX.lc){
     lc = CTX.lc;
     for(int i = 2; i < 5; i++){
-      WID->gen_value[i]->minimum(-5*CTX.lc);
-      WID->gen_value[i]->maximum(5*CTX.lc);
+      o->general.value[i]->minimum(-5 * CTX.lc);
+      o->general.value[i]->maximum(5 * CTX.lc);
     }
   }
   if(data){
@@ -927,87 +919,87 @@ void general_options_ok_cb(CALLBACK_ARGS)
     }
     else if(!strcmp(name, "light_value")){
       double x, y, z;
-      x = WID->gen_value[2]->value();
-      y = WID->gen_value[3]->value();
-      z = WID->gen_value[4]->value();
-      WID->gen_sphere->setValue(x, y, z);    
+      x = o->general.value[2]->value();
+      y = o->general.value[3]->value();
+      z = o->general.value[4]->value();
+      o->general.sphere->setValue(x, y, z);    
     }
     else if(!strcmp(name, "light_sphere")){
       double x, y, z;
-      WID->gen_sphere->getValue(x, y, z);
-      WID->gen_value[2]->value(x);
-      WID->gen_value[3]->value(y);
-      WID->gen_value[4]->value(z);
-    }
-  }
-
-  opt_general_axes_auto_position(0, GMSH_SET, WID->gen_butt[0]->value());
-  opt_general_small_axes(0, GMSH_SET, WID->gen_butt[1]->value());
-  opt_general_fast_redraw(0, GMSH_SET, WID->gen_butt[2]->value());
-  opt_general_mouse_hover_meshes(0, GMSH_SET, WID->gen_butt[11]->value());
-  if(opt_general_double_buffer(0, GMSH_GET, 0) != WID->gen_butt[3]->value())
-    opt_general_double_buffer(0, GMSH_SET, WID->gen_butt[3]->value());
-  if(opt_general_antialiasing(0, GMSH_GET, 0) != WID->gen_butt[12]->value())
-    opt_general_antialiasing(0, GMSH_SET, WID->gen_butt[12]->value());
-  opt_general_trackball(0, GMSH_SET, WID->gen_butt[5]->value());
-  opt_general_terminal(0, GMSH_SET, WID->gen_butt[7]->value());
+      o->general.sphere->getValue(x, y, z);
+      o->general.value[2]->value(x);
+      o->general.value[3]->value(y);
+      o->general.value[4]->value(z);
+    }
+  }
+
+  opt_general_axes_auto_position(0, GMSH_SET, o->general.butt[0]->value());
+  opt_general_small_axes(0, GMSH_SET, o->general.butt[1]->value());
+  opt_general_fast_redraw(0, GMSH_SET, o->general.butt[2]->value());
+  opt_general_mouse_hover_meshes(0, GMSH_SET, o->general.butt[11]->value());
+  if(opt_general_double_buffer(0, GMSH_GET, 0) != o->general.butt[3]->value())
+    opt_general_double_buffer(0, GMSH_SET, o->general.butt[3]->value());
+  if(opt_general_antialiasing(0, GMSH_GET, 0) != o->general.butt[12]->value())
+    opt_general_antialiasing(0, GMSH_SET, o->general.butt[12]->value());
+  opt_general_trackball(0, GMSH_SET, o->general.butt[5]->value());
+  opt_general_terminal(0, GMSH_SET, o->general.butt[7]->value());
   double sessionrc = opt_general_session_save(0, GMSH_GET, 0);
-  opt_general_session_save(0, GMSH_SET, WID->gen_butt[8]->value());
+  opt_general_session_save(0, GMSH_SET, o->general.butt[8]->value());
   if(sessionrc && !opt_general_session_save(0, GMSH_GET, 0))
     Print_Options(0, GMSH_SESSIONRC, 1, 1, CTX.session_filename_fullpath);
-  opt_general_options_save(0, GMSH_SET, WID->gen_butt[9]->value());
-  opt_general_expert_mode(0, GMSH_SET, WID->gen_butt[10]->value());
-  opt_general_tooltips(0, GMSH_SET, WID->gen_butt[13]->value());
-  opt_general_confirm_overwrite(0, GMSH_SET, WID->gen_butt[14]->value());
-  opt_general_rotation_center_cg(0, GMSH_SET, WID->gen_butt[15]->value());
-  opt_general_draw_bounding_box(0, GMSH_SET, WID->gen_butt[6]->value());
-  opt_general_polygon_offset_always(0, GMSH_SET, WID->gen_butt[4]->value());
-  opt_general_axes_mikado(0, GMSH_SET, WID->gen_butt[16]->value());
-
-  opt_general_shine_exponent(0, GMSH_SET, WID->gen_value[0]->value());  
-  opt_general_shine(0, GMSH_SET, WID->gen_value[1]->value());
-  opt_general_light00(0, GMSH_SET, WID->gen_value[2]->value());
-  opt_general_light01(0, GMSH_SET, WID->gen_value[3]->value());
-  opt_general_light02(0, GMSH_SET, WID->gen_value[4]->value());
-  opt_general_light03(0, GMSH_SET, WID->gen_value[13]->value());
-  opt_general_verbosity(0, GMSH_SET, WID->gen_value[5]->value());
-  opt_general_point_size(0, GMSH_SET, WID->gen_value[6]->value());
-  opt_general_line_width(0, GMSH_SET, WID->gen_value[7]->value());
-  opt_general_rotation_center0(0, GMSH_SET, WID->gen_value[8]->value());
-  opt_general_rotation_center1(0, GMSH_SET, WID->gen_value[9]->value());
-  opt_general_rotation_center2(0, GMSH_SET, WID->gen_value[10]->value());
-  opt_general_quadric_subdivisions(0, GMSH_SET, WID->gen_value[11]->value());
-  opt_general_graphics_fontsize(0, GMSH_SET, WID->gen_value[12]->value());
-  opt_general_clip_factor(0, GMSH_SET, WID->gen_value[14]->value());
-  opt_general_polygon_offset_factor(0, GMSH_SET, WID->gen_value[15]->value());
-  opt_general_polygon_offset_units(0, GMSH_SET, WID->gen_value[16]->value());
-  opt_general_axes_tics0(0, GMSH_SET, WID->gen_value[17]->value());
-  opt_general_axes_tics1(0, GMSH_SET, WID->gen_value[18]->value());
-  opt_general_axes_tics2(0, GMSH_SET, WID->gen_value[19]->value());
-  opt_general_axes_xmin(0, GMSH_SET, WID->gen_value[20]->value());
-  opt_general_axes_ymin(0, GMSH_SET, WID->gen_value[21]->value());
-  opt_general_axes_zmin(0, GMSH_SET, WID->gen_value[22]->value());
-  opt_general_axes_xmax(0, GMSH_SET, WID->gen_value[23]->value());
-  opt_general_axes_ymax(0, GMSH_SET, WID->gen_value[24]->value());
-  opt_general_axes_zmax(0, GMSH_SET, WID->gen_value[25]->value());
-  opt_general_small_axes_position0(0, GMSH_SET, WID->gen_value[26]->value());
-  opt_general_small_axes_position1(0, GMSH_SET, WID->gen_value[27]->value());
-
-  opt_general_default_filename(0, GMSH_SET, WID->gen_input[0]->value());
-  opt_general_editor(0, GMSH_SET, WID->gen_input[1]->value());
-  opt_general_web_browser(0, GMSH_SET, WID->gen_input[2]->value());
-  opt_general_axes_format0(0, GMSH_SET, WID->gen_input[3]->value());
-  opt_general_axes_format1(0, GMSH_SET, WID->gen_input[4]->value());
-  opt_general_axes_format2(0, GMSH_SET, WID->gen_input[5]->value());
-  opt_general_axes_label0(0, GMSH_SET, WID->gen_input[6]->value());
-  opt_general_axes_label1(0, GMSH_SET, WID->gen_input[7]->value());
-  opt_general_axes_label2(0, GMSH_SET, WID->gen_input[8]->value());
-
-  opt_general_vector_type(0, GMSH_SET, WID->gen_choice[0]->value() + 1);
-  opt_general_graphics_font(0, GMSH_SET, WID->gen_choice[1]->text());
-  opt_general_orthographic(0, GMSH_SET, !WID->gen_choice[2]->value());
-  opt_general_axes(0, GMSH_SET, WID->gen_choice[4]->value());
-  opt_general_background_gradient(0, GMSH_SET, WID->gen_choice[5]->value());
+  opt_general_options_save(0, GMSH_SET, o->general.butt[9]->value());
+  opt_general_expert_mode(0, GMSH_SET, o->general.butt[10]->value());
+  opt_general_tooltips(0, GMSH_SET, o->general.butt[13]->value());
+  opt_general_confirm_overwrite(0, GMSH_SET, o->general.butt[14]->value());
+  opt_general_rotation_center_cg(0, GMSH_SET, o->general.butt[15]->value());
+  opt_general_draw_bounding_box(0, GMSH_SET, o->general.butt[6]->value());
+  opt_general_polygon_offset_always(0, GMSH_SET, o->general.butt[4]->value());
+  opt_general_axes_mikado(0, GMSH_SET, o->general.butt[16]->value());
+
+  opt_general_shine_exponent(0, GMSH_SET, o->general.value[0]->value());  
+  opt_general_shine(0, GMSH_SET, o->general.value[1]->value());
+  opt_general_light00(0, GMSH_SET, o->general.value[2]->value());
+  opt_general_light01(0, GMSH_SET, o->general.value[3]->value());
+  opt_general_light02(0, GMSH_SET, o->general.value[4]->value());
+  opt_general_light03(0, GMSH_SET, o->general.value[13]->value());
+  opt_general_verbosity(0, GMSH_SET, o->general.value[5]->value());
+  opt_general_point_size(0, GMSH_SET, o->general.value[6]->value());
+  opt_general_line_width(0, GMSH_SET, o->general.value[7]->value());
+  opt_general_rotation_center0(0, GMSH_SET, o->general.value[8]->value());
+  opt_general_rotation_center1(0, GMSH_SET, o->general.value[9]->value());
+  opt_general_rotation_center2(0, GMSH_SET, o->general.value[10]->value());
+  opt_general_quadric_subdivisions(0, GMSH_SET, o->general.value[11]->value());
+  opt_general_graphics_fontsize(0, GMSH_SET, o->general.value[12]->value());
+  opt_general_clip_factor(0, GMSH_SET, o->general.value[14]->value());
+  opt_general_polygon_offset_factor(0, GMSH_SET, o->general.value[15]->value());
+  opt_general_polygon_offset_units(0, GMSH_SET, o->general.value[16]->value());
+  opt_general_axes_tics0(0, GMSH_SET, o->general.value[17]->value());
+  opt_general_axes_tics1(0, GMSH_SET, o->general.value[18]->value());
+  opt_general_axes_tics2(0, GMSH_SET, o->general.value[19]->value());
+  opt_general_axes_xmin(0, GMSH_SET, o->general.value[20]->value());
+  opt_general_axes_ymin(0, GMSH_SET, o->general.value[21]->value());
+  opt_general_axes_zmin(0, GMSH_SET, o->general.value[22]->value());
+  opt_general_axes_xmax(0, GMSH_SET, o->general.value[23]->value());
+  opt_general_axes_ymax(0, GMSH_SET, o->general.value[24]->value());
+  opt_general_axes_zmax(0, GMSH_SET, o->general.value[25]->value());
+  opt_general_small_axes_position0(0, GMSH_SET, o->general.value[26]->value());
+  opt_general_small_axes_position1(0, GMSH_SET, o->general.value[27]->value());
+
+  opt_general_default_filename(0, GMSH_SET, o->general.input[0]->value());
+  opt_general_editor(0, GMSH_SET, o->general.input[1]->value());
+  opt_general_web_browser(0, GMSH_SET, o->general.input[2]->value());
+  opt_general_axes_format0(0, GMSH_SET, o->general.input[3]->value());
+  opt_general_axes_format1(0, GMSH_SET, o->general.input[4]->value());
+  opt_general_axes_format2(0, GMSH_SET, o->general.input[5]->value());
+  opt_general_axes_label0(0, GMSH_SET, o->general.input[6]->value());
+  opt_general_axes_label1(0, GMSH_SET, o->general.input[7]->value());
+  opt_general_axes_label2(0, GMSH_SET, o->general.input[8]->value());
+
+  opt_general_vector_type(0, GMSH_SET, o->general.choice[0]->value() + 1);
+  opt_general_graphics_font(0, GMSH_SET, o->general.choice[1]->text());
+  opt_general_orthographic(0, GMSH_SET, !o->general.choice[2]->value());
+  opt_general_axes(0, GMSH_SET, o->general.choice[4]->value());
+  opt_general_background_gradient(0, GMSH_SET, o->general.choice[5]->value());
 
   if(CTX.fast_redraw)
     CTX.post.draw = CTX.mesh.draw = 0;
@@ -1033,40 +1025,42 @@ void general_arrow_param_cb(CALLBACK_ARGS)
 
 void geometry_options_cb(CALLBACK_ARGS)
 {
-  WID->create_geometry_options_window();
+  GUI::instance()->options->showGroup(2);
 }
 
 void geometry_options_ok_cb(CALLBACK_ARGS)
 {
   activate_cb(NULL, data);
 
-  opt_geometry_points(0, GMSH_SET, WID->geo_butt[0]->value());
-  opt_geometry_lines(0, GMSH_SET, WID->geo_butt[1]->value());
-  opt_geometry_surfaces(0, GMSH_SET, WID->geo_butt[2]->value());
-  opt_geometry_volumes(0, GMSH_SET, WID->geo_butt[3]->value());
-  opt_geometry_points_num(0, GMSH_SET, WID->geo_butt[4]->value());
-  opt_geometry_lines_num(0, GMSH_SET, WID->geo_butt[5]->value());
-  opt_geometry_surfaces_num(0, GMSH_SET, WID->geo_butt[6]->value());
-  opt_geometry_volumes_num(0, GMSH_SET, WID->geo_butt[7]->value());
-  opt_geometry_auto_coherence(0, GMSH_SET, WID->geo_butt[8]->value());
-  opt_geometry_light(0, GMSH_SET, WID->geo_butt[9]->value());
-  opt_geometry_highlight_orphans(0, GMSH_SET, WID->geo_butt[10]->value());
-  opt_geometry_occ_fix_small_edges(0, GMSH_SET, WID->geo_butt[11]->value());
-  opt_geometry_occ_fix_small_faces(0, GMSH_SET, WID->geo_butt[12]->value());
-  opt_geometry_occ_sew_faces(0, GMSH_SET, WID->geo_butt[13]->value());
-  opt_geometry_light_two_side(0, GMSH_SET, WID->geo_butt[14]->value());
-
-  opt_geometry_normals(0, GMSH_SET, WID->geo_value[0]->value());
-  opt_geometry_tangents(0, GMSH_SET, WID->geo_value[1]->value());
-  opt_geometry_tolerance(0, GMSH_SET, WID->geo_value[2]->value());
-  opt_geometry_point_size(0, GMSH_SET, WID->geo_value[3]->value());
-  opt_geometry_line_width(0, GMSH_SET, WID->geo_value[4]->value());
-  opt_geometry_point_sel_size(0, GMSH_SET, WID->geo_value[5]->value());
-  opt_geometry_line_sel_width(0, GMSH_SET, WID->geo_value[6]->value());
-
-  opt_geometry_point_type(0, GMSH_SET, WID->geo_choice[0]->value());
-  opt_geometry_line_type(0, GMSH_SET, WID->geo_choice[1]->value());
-  opt_geometry_surface_type(0, GMSH_SET, WID->geo_choice[2]->value());
+  optionWindow *o = GUI::instance()->options;
+
+  opt_geometry_points(0, GMSH_SET, o->geo.butt[0]->value());
+  opt_geometry_lines(0, GMSH_SET, o->geo.butt[1]->value());
+  opt_geometry_surfaces(0, GMSH_SET, o->geo.butt[2]->value());
+  opt_geometry_volumes(0, GMSH_SET, o->geo.butt[3]->value());
+  opt_geometry_points_num(0, GMSH_SET, o->geo.butt[4]->value());
+  opt_geometry_lines_num(0, GMSH_SET, o->geo.butt[5]->value());
+  opt_geometry_surfaces_num(0, GMSH_SET, o->geo.butt[6]->value());
+  opt_geometry_volumes_num(0, GMSH_SET, o->geo.butt[7]->value());
+  opt_geometry_auto_coherence(0, GMSH_SET, o->geo.butt[8]->value());
+  opt_geometry_light(0, GMSH_SET, o->geo.butt[9]->value());
+  opt_geometry_highlight_orphans(0, GMSH_SET, o->geo.butt[10]->value());
+  opt_geometry_occ_fix_small_edges(0, GMSH_SET, o->geo.butt[11]->value());
+  opt_geometry_occ_fix_small_faces(0, GMSH_SET, o->geo.butt[12]->value());
+  opt_geometry_occ_sew_faces(0, GMSH_SET, o->geo.butt[13]->value());
+  opt_geometry_light_two_side(0, GMSH_SET, o->geo.butt[14]->value());
+
+  opt_geometry_normals(0, GMSH_SET, o->geo.value[0]->value());
+  opt_geometry_tangents(0, GMSH_SET, o->geo.value[1]->value());
+  opt_geometry_tolerance(0, GMSH_SET, o->geo.value[2]->value());
+  opt_geometry_point_size(0, GMSH_SET, o->geo.value[3]->value());
+  opt_geometry_line_width(0, GMSH_SET, o->geo.value[4]->value());
+  opt_geometry_point_sel_size(0, GMSH_SET, o->geo.value[5]->value());
+  opt_geometry_line_sel_width(0, GMSH_SET, o->geo.value[6]->value());
+
+  opt_geometry_point_type(0, GMSH_SET, o->geo.choice[0]->value());
+  opt_geometry_line_type(0, GMSH_SET, o->geo.choice[1]->value());
+  opt_geometry_surface_type(0, GMSH_SET, o->geo.choice[2]->value());
 
   if(CTX.fast_redraw)
     CTX.post.draw = CTX.mesh.draw = 0;
@@ -1078,72 +1072,74 @@ void geometry_options_ok_cb(CALLBACK_ARGS)
 
 void mesh_options_cb(CALLBACK_ARGS)
 {
-  WID->create_mesh_options_window();
+  GUI::instance()->options->showGroup(3);
 }
 
 void mesh_options_ok_cb(CALLBACK_ARGS)
 {
   activate_cb(NULL, data);
 
-  opt_mesh_reverse_all_normals(0, GMSH_SET, WID->mesh_butt[0]->value());
-  opt_mesh_lc_from_curvature(0, GMSH_SET, WID->mesh_butt[1]->value());
-  opt_mesh_lc_from_points(0, GMSH_SET, WID->mesh_butt[5]->value());
-  opt_mesh_lc_extend_from_boundary(0, GMSH_SET, WID->mesh_butt[16]->value());
-  opt_mesh_optimize(0, GMSH_SET, WID->mesh_butt[2]->value());
-  opt_mesh_optimize_netgen(0, GMSH_SET, WID->mesh_butt[24]->value());
-  opt_mesh_order(0, GMSH_SET, WID->mesh_value[3]->value());
-  opt_mesh_smooth_internal_edges(0, GMSH_SET, WID->mesh_butt[3]->value());
-  opt_mesh_second_order_incomplete(0, GMSH_SET, WID->mesh_butt[4]->value());
-  opt_mesh_c1(0, GMSH_SET, WID->mesh_butt[21]->value());
-  opt_mesh_points(0, GMSH_SET, WID->mesh_butt[6]->value());
-  opt_mesh_lines(0, GMSH_SET, WID->mesh_butt[7]->value());
-  opt_mesh_triangles(0, GMSH_SET, WID->mesh_menu_butt->menu()[0].value() ? 1 : 0);
-  opt_mesh_quadrangles(0, GMSH_SET, WID->mesh_menu_butt->menu()[1].value() ? 1 : 0);
-  opt_mesh_tetrahedra(0, GMSH_SET, WID->mesh_menu_butt->menu()[2].value() ? 1 : 0);
-  opt_mesh_hexahedra(0, GMSH_SET, WID->mesh_menu_butt->menu()[3].value() ? 1 : 0);
-  opt_mesh_prisms(0, GMSH_SET, WID->mesh_menu_butt->menu()[4].value() ? 1 : 0);
-  opt_mesh_pyramids(0, GMSH_SET, WID->mesh_menu_butt->menu()[5].value() ? 1 : 0);
-  opt_mesh_surfaces_edges(0, GMSH_SET, WID->mesh_butt[8]->value());
-  opt_mesh_surfaces_faces(0, GMSH_SET, WID->mesh_butt[9]->value());
-  opt_mesh_volumes_edges(0, GMSH_SET, WID->mesh_butt[10]->value());
-  opt_mesh_volumes_faces(0, GMSH_SET, WID->mesh_butt[11]->value());
-  opt_mesh_points_num(0, GMSH_SET, WID->mesh_butt[12]->value());
-  opt_mesh_lines_num(0, GMSH_SET, WID->mesh_butt[13]->value());
-  opt_mesh_surfaces_num(0, GMSH_SET, WID->mesh_butt[14]->value());
-  opt_mesh_volumes_num(0, GMSH_SET, WID->mesh_butt[15]->value());
-  opt_mesh_light(0, GMSH_SET, WID->mesh_butt[17]->value());
-  opt_mesh_light_two_side(0, GMSH_SET, WID->mesh_butt[18]->value());
-  opt_mesh_smooth_normals(0, GMSH_SET, WID->mesh_butt[19]->value());
-  opt_mesh_light_lines(0, GMSH_SET, WID->mesh_butt[20]->value());
-  opt_mesh_nb_smoothing(0, GMSH_SET, WID->mesh_value[0]->value());
-  opt_mesh_lc_factor(0, GMSH_SET, WID->mesh_value[2]->value());
-  opt_mesh_lc_min(0, GMSH_SET, WID->mesh_value[25]->value());
-  opt_mesh_lc_max(0, GMSH_SET, WID->mesh_value[26]->value());
-  opt_mesh_quality_inf(0, GMSH_SET, WID->mesh_value[4]->value());
-  opt_mesh_quality_sup(0, GMSH_SET, WID->mesh_value[5]->value());
-  opt_mesh_radius_inf(0, GMSH_SET, WID->mesh_value[6]->value());
-  opt_mesh_radius_sup(0, GMSH_SET, WID->mesh_value[7]->value());
-  opt_mesh_normals(0, GMSH_SET, WID->mesh_value[8]->value());
-  opt_mesh_explode(0, GMSH_SET, WID->mesh_value[9]->value());
-  opt_mesh_tangents(0, GMSH_SET, WID->mesh_value[13]->value());
-  opt_mesh_point_size(0, GMSH_SET, WID->mesh_value[10]->value());
-  opt_mesh_line_width(0, GMSH_SET, WID->mesh_value[11]->value());
-  opt_mesh_label_frequency(0, GMSH_SET, WID->mesh_value[12]->value());
-  opt_mesh_angle_smooth_normals(0, GMSH_SET, WID->mesh_value[18]->value());
-
-  opt_mesh_point_type(0, GMSH_SET, WID->mesh_choice[0]->value());
+  optionWindow *o = GUI::instance()->options;
+
+  opt_mesh_reverse_all_normals(0, GMSH_SET, o->mesh.butt[0]->value());
+  opt_mesh_lc_from_curvature(0, GMSH_SET, o->mesh.butt[1]->value());
+  opt_mesh_lc_from_points(0, GMSH_SET, o->mesh.butt[5]->value());
+  opt_mesh_lc_extend_from_boundary(0, GMSH_SET, o->mesh.butt[16]->value());
+  opt_mesh_optimize(0, GMSH_SET, o->mesh.butt[2]->value());
+  opt_mesh_optimize_netgen(0, GMSH_SET, o->mesh.butt[24]->value());
+  opt_mesh_order(0, GMSH_SET, o->mesh.value[3]->value());
+  opt_mesh_smooth_internal_edges(0, GMSH_SET, o->mesh.butt[3]->value());
+  opt_mesh_second_order_incomplete(0, GMSH_SET, o->mesh.butt[4]->value());
+  opt_mesh_c1(0, GMSH_SET, o->mesh.butt[21]->value());
+  opt_mesh_points(0, GMSH_SET, o->mesh.butt[6]->value());
+  opt_mesh_lines(0, GMSH_SET, o->mesh.butt[7]->value());
+  opt_mesh_triangles(0, GMSH_SET, o->mesh.menu->menu()[0].value() ? 1 : 0);
+  opt_mesh_quadrangles(0, GMSH_SET, o->mesh.menu->menu()[1].value() ? 1 : 0);
+  opt_mesh_tetrahedra(0, GMSH_SET, o->mesh.menu->menu()[2].value() ? 1 : 0);
+  opt_mesh_hexahedra(0, GMSH_SET, o->mesh.menu->menu()[3].value() ? 1 : 0);
+  opt_mesh_prisms(0, GMSH_SET, o->mesh.menu->menu()[4].value() ? 1 : 0);
+  opt_mesh_pyramids(0, GMSH_SET, o->mesh.menu->menu()[5].value() ? 1 : 0);
+  opt_mesh_surfaces_edges(0, GMSH_SET, o->mesh.butt[8]->value());
+  opt_mesh_surfaces_faces(0, GMSH_SET, o->mesh.butt[9]->value());
+  opt_mesh_volumes_edges(0, GMSH_SET, o->mesh.butt[10]->value());
+  opt_mesh_volumes_faces(0, GMSH_SET, o->mesh.butt[11]->value());
+  opt_mesh_points_num(0, GMSH_SET, o->mesh.butt[12]->value());
+  opt_mesh_lines_num(0, GMSH_SET, o->mesh.butt[13]->value());
+  opt_mesh_surfaces_num(0, GMSH_SET, o->mesh.butt[14]->value());
+  opt_mesh_volumes_num(0, GMSH_SET, o->mesh.butt[15]->value());
+  opt_mesh_light(0, GMSH_SET, o->mesh.butt[17]->value());
+  opt_mesh_light_two_side(0, GMSH_SET, o->mesh.butt[18]->value());
+  opt_mesh_smooth_normals(0, GMSH_SET, o->mesh.butt[19]->value());
+  opt_mesh_light_lines(0, GMSH_SET, o->mesh.butt[20]->value());
+  opt_mesh_nb_smoothing(0, GMSH_SET, o->mesh.value[0]->value());
+  opt_mesh_lc_factor(0, GMSH_SET, o->mesh.value[2]->value());
+  opt_mesh_lc_min(0, GMSH_SET, o->mesh.value[25]->value());
+  opt_mesh_lc_max(0, GMSH_SET, o->mesh.value[26]->value());
+  opt_mesh_quality_inf(0, GMSH_SET, o->mesh.value[4]->value());
+  opt_mesh_quality_sup(0, GMSH_SET, o->mesh.value[5]->value());
+  opt_mesh_radius_inf(0, GMSH_SET, o->mesh.value[6]->value());
+  opt_mesh_radius_sup(0, GMSH_SET, o->mesh.value[7]->value());
+  opt_mesh_normals(0, GMSH_SET, o->mesh.value[8]->value());
+  opt_mesh_explode(0, GMSH_SET, o->mesh.value[9]->value());
+  opt_mesh_tangents(0, GMSH_SET, o->mesh.value[13]->value());
+  opt_mesh_point_size(0, GMSH_SET, o->mesh.value[10]->value());
+  opt_mesh_line_width(0, GMSH_SET, o->mesh.value[11]->value());
+  opt_mesh_label_frequency(0, GMSH_SET, o->mesh.value[12]->value());
+  opt_mesh_angle_smooth_normals(0, GMSH_SET, o->mesh.value[18]->value());
+
+  opt_mesh_point_type(0, GMSH_SET, o->mesh.choice[0]->value());
   opt_mesh_algo2d(0, GMSH_SET,
-                  (WID->mesh_choice[2]->value() == 0) ? ALGO_2D_FRONTAL : 
-                  (WID->mesh_choice[2]->value() == 1) ? ALGO_2D_DELAUNAY :
+                  (o->mesh.choice[2]->value() == 0) ? ALGO_2D_FRONTAL : 
+                  (o->mesh.choice[2]->value() == 1) ? ALGO_2D_DELAUNAY :
                   ALGO_2D_MESHADAPT_DELAUNAY);
   opt_mesh_algo3d(0, GMSH_SET,
-                  (WID->mesh_choice[3]->value() == 0) ? ALGO_3D_TETGEN_DELAUNAY : 
+                  (o->mesh.choice[3]->value() == 0) ? ALGO_3D_TETGEN_DELAUNAY : 
                   ALGO_3D_NETGEN);
   opt_mesh_recombine_algo(0, GMSH_SET,
-                  (WID->mesh_choice[5]->value() == 0) ? 1 : 2);
-  opt_mesh_color_carousel(0, GMSH_SET, WID->mesh_choice[4]->value());
-  opt_mesh_quality_type(0, GMSH_SET, WID->mesh_choice[6]->value());
-  opt_mesh_label_type(0, GMSH_SET, WID->mesh_choice[7]->value());
+                  (o->mesh.choice[5]->value() == 0) ? 1 : 2);
+  opt_mesh_color_carousel(0, GMSH_SET, o->mesh.choice[4]->value());
+  opt_mesh_quality_type(0, GMSH_SET, o->mesh.choice[6]->value());
+  opt_mesh_label_type(0, GMSH_SET, o->mesh.choice[7]->value());
 
   if(CTX.fast_redraw)
     CTX.post.draw = CTX.mesh.draw = 0;
@@ -1155,21 +1151,23 @@ void mesh_options_ok_cb(CALLBACK_ARGS)
 
 void solver_options_cb(CALLBACK_ARGS)
 {
-  WID->create_solver_options_window();
+  GUI::instance()->options->showGroup(4);
 }
 
 void solver_options_ok_cb(CALLBACK_ARGS)
 {
   activate_cb(NULL, data);
 
-  int old_listen = (int)opt_solver_listen(0, GMSH_GET, WID->solver_butt[0]->value());
-  opt_solver_listen(0, GMSH_SET, WID->solver_butt[0]->value());
-  if(!old_listen && WID->solver_butt[0]->value())
+  optionWindow *o = GUI::instance()->options;
+
+  int old_listen = (int)opt_solver_listen(0, GMSH_GET, o->solver.butt[0]->value());
+  opt_solver_listen(0, GMSH_SET, o->solver.butt[0]->value());
+  if(!old_listen && o->solver.butt[0]->value())
     Solver(-1, NULL);
 
-  opt_solver_max_delay(0, GMSH_SET, WID->solver_value[0]->value());
+  opt_solver_max_delay(0, GMSH_SET, o->solver.value[0]->value());
 
-  opt_solver_socket_name(0, GMSH_SET, WID->solver_input[0]->value());
+  opt_solver_socket_name(0, GMSH_SET, o->solver.input[0]->value());
 
   if(CTX.fast_redraw)
     CTX.post.draw = CTX.mesh.draw = 0;
@@ -1181,20 +1179,22 @@ void solver_options_ok_cb(CALLBACK_ARGS)
 
 void post_options_cb(CALLBACK_ARGS)
 {
-  WID->create_post_options_window();
+  GUI::instance()->options->showGroup(5);
 }
 
 void post_options_ok_cb(CALLBACK_ARGS)
 {
   activate_cb(NULL, data);
 
-  opt_post_anim_cycle(0, GMSH_SET, WID->post_butt[0]->value());
-  opt_post_combine_remove_orig(0, GMSH_SET, WID->post_butt[1]->value());
-  opt_post_horizontal_scales(0, GMSH_SET, WID->post_butt[2]->value());
+  optionWindow *o = GUI::instance()->options;
+
+  opt_post_anim_cycle(0, GMSH_SET, o->post.butt[0]->value());
+  opt_post_combine_remove_orig(0, GMSH_SET, o->post.butt[1]->value());
+  opt_post_horizontal_scales(0, GMSH_SET, o->post.butt[2]->value());
 
-  opt_post_anim_delay(0, GMSH_SET, WID->post_value[0]->value());
+  opt_post_anim_delay(0, GMSH_SET, o->post.value[0]->value());
 
-  opt_post_link(0, GMSH_SET, WID->post_choice[0]->value());
+  opt_post_link(0, GMSH_SET, o->post.choice[0]->value());
 
   if(CTX.fast_redraw)
     CTX.post.draw = CTX.mesh.draw = 0;
@@ -1206,7 +1206,7 @@ void post_options_ok_cb(CALLBACK_ARGS)
 
 void view_options_cb(CALLBACK_ARGS)
 {
-  WID->create_view_options_window((int)(long)data);
+  GUI::instance()->options->showGroup((int)(long)data + 6);
 }
 
 void view_options_timestep_cb(CALLBACK_ARGS)
@@ -1215,7 +1215,7 @@ void view_options_timestep_cb(CALLBACK_ARGS)
   for(int i = 0; i < (int)PView::list.size(); i++) {
     if((links == 2 || links == 4) ||
        ((links == 1 || links == 3) && opt_view_visible(i, GMSH_GET, 0)) ||
-       (links == 0 && i == WID->view_number)) {
+       (links == 0 && i == GUI::instance()->options->view.index)) {
       opt_view_timestep(i, GMSH_SET, ((Fl_Value_Input *) w)->value());
     }
   }
@@ -1228,7 +1228,7 @@ void view_options_timestep_decr_cb(CALLBACK_ARGS)
   for(int i = 0; i < (int)PView::list.size(); i++) {
     if((links == 2 || links == 4) ||
        ((links == 1 || links == 3) && opt_view_visible(i, GMSH_GET, 0)) ||
-       (links == 0 && i == WID->view_number)) {
+       (links == 0 && i == GUI::instance()->options->view.index)) {
       opt_view_timestep(i, GMSH_SET | GMSH_GUI,
                         opt_view_timestep(i, GMSH_GET, 0) - 1);
     }
@@ -1242,7 +1242,7 @@ void view_options_timestep_incr_cb(CALLBACK_ARGS)
   for(int i = 0; i < (int)PView::list.size(); i++) {
     if((links == 2 || links == 4) ||
        ((links == 1 || links == 3) && opt_view_visible(i, GMSH_GET, 0)) ||
-       (links == 0 && i == WID->view_number)) {
+       (links == 0 && i == GUI::instance()->options->view.index)) {
       opt_view_timestep(i, GMSH_SET | GMSH_GUI,
                         opt_view_timestep(i, GMSH_GET, 0) + 1);
     }
@@ -1252,33 +1252,35 @@ void view_options_timestep_incr_cb(CALLBACK_ARGS)
 
 void view_arrow_param_cb(CALLBACK_ARGS)
 {
-  double a = opt_view_arrow_head_radius(WID->view_number, GMSH_GET, 0);
-  double b = opt_view_arrow_stem_length(WID->view_number, GMSH_GET, 0);
-  double c = opt_view_arrow_stem_radius(WID->view_number, GMSH_GET, 0);
+  double a = opt_view_arrow_head_radius(GUI::instance()->options->view.index, GMSH_GET, 0);
+  double b = opt_view_arrow_stem_length(GUI::instance()->options->view.index, GMSH_GET, 0);
+  double c = opt_view_arrow_stem_radius(GUI::instance()->options->view.index, GMSH_GET, 0);
   while(arrow_editor("Arrow Editor", a, b, c)){
-    opt_view_arrow_head_radius(WID->view_number, GMSH_SET, a);
-    opt_view_arrow_stem_length(WID->view_number, GMSH_SET, b);
-    opt_view_arrow_stem_radius(WID->view_number, GMSH_SET, c);
+    opt_view_arrow_head_radius(GUI::instance()->options->view.index, GMSH_SET, a);
+    opt_view_arrow_stem_length(GUI::instance()->options->view.index, GMSH_SET, b);
+    opt_view_arrow_stem_radius(GUI::instance()->options->view.index, GMSH_SET, c);
     Draw();
   }
 }
 
 void view_options_ok_cb(CALLBACK_ARGS)
 {
-  int current = WID->view_number;
+  int current = GUI::instance()->options->view.index;
 
   if(current < 0)
     return;
 
   activate_cb(NULL, data);
 
+  optionWindow *o = GUI::instance()->options;
+
   if(data){
     const char *str = (const char*)data;
     if(!strcmp(str, "range_min")){
-      WID->view_value[31]->value(opt_view_min(WID->view_number, GMSH_GET, 0));
+      o->view.value[31]->value(opt_view_min(o->view.index, GMSH_GET, 0));
     }
     else if(!strcmp(str, "range_max")){
-      WID->view_value[32]->value(opt_view_max(WID->view_number, GMSH_GET, 0));
+      o->view.value[32]->value(opt_view_max(o->view.index, GMSH_GET, 0));
     }
   }
   
@@ -1400,351 +1402,351 @@ void view_options_ok_cb(CALLBACK_ARGS)
 
       // view_choice
 
-      val = WID->view_choice[1]->value() + 1;
+      val = o->view.choice[1]->value() + 1;
       if(force || (val != scale_type))
         opt_view_scale_type(i, GMSH_SET, val);
 
-      val = WID->view_choice[0]->value() + 1;
+      val = o->view.choice[0]->value() + 1;
       if(force || (val != intervals_type))
         opt_view_intervals_type(i, GMSH_SET, val);
       
-      val = WID->view_choice[5]->value();
+      val = o->view.choice[5]->value();
       if(force || (val != point_type))
         opt_view_point_type(i, GMSH_SET, val);
       
-      val = WID->view_choice[6]->value();
+      val = o->view.choice[6]->value();
       if(force || (val != line_type))
         opt_view_line_type(i, GMSH_SET, val);
 
-      val = WID->view_choice[2]->value() + 1;
+      val = o->view.choice[2]->value() + 1;
       if(force || (val != vector_type))
         opt_view_vector_type(i, GMSH_SET, val);
 
-      val = WID->view_choice[3]->value() + 1;
+      val = o->view.choice[3]->value() + 1;
       if(force || (val != glyph_location))
         opt_view_glyph_location(i, GMSH_SET, val);
 
-      val = WID->view_choice[4]->value() + 1;
+      val = o->view.choice[4]->value() + 1;
       if(force || (val != tensor_type))
         opt_view_tensor_type(i, GMSH_SET, val);
       
-      val = WID->view_choice[7]->value() + 1;
+      val = o->view.choice[7]->value() + 1;
       if(force || (val != range_type))
         opt_view_range_type(i, GMSH_SET, val);
 
-      val = WID->view_choice[8]->value();
+      val = o->view.choice[8]->value();
       if(force || (val != axes))
         opt_view_axes(i, GMSH_SET, val);
 
-      val = WID->view_choice[9]->value();
+      val = o->view.choice[9]->value();
       if(force || (val != boundary))
         opt_view_boundary(i, GMSH_SET, val);
 
-      val = WID->view_choice[10]->value() - 1;
+      val = o->view.choice[10]->value() - 1;
       if(force || (val != external_view))
         opt_view_external_view(i, GMSH_SET, val);
 
-      val = WID->view_choice[11]->value() - 1;
+      val = o->view.choice[11]->value() - 1;
       if(force || (val != gen_raise_view))
         opt_view_gen_raise_view(i, GMSH_SET, val);
 
-      val = WID->view_choice[12]->value();
+      val = o->view.choice[12]->value();
       if(force || (val != show_time))
         opt_view_show_time(i, GMSH_SET, val);
       
-      val = WID->view_choice[13]->value() + 1;
+      val = o->view.choice[13]->value() + 1;
       if(force || (val != type))
         opt_view_type(i, GMSH_SET, val);
 
       // view_butts
 
-      val = WID->view_butt[0]->value();
+      val = o->view.butt[0]->value();
       if(force || (val != arrow_size_proportional))
         opt_view_arrow_size_proportional(i, GMSH_SET, val);
 
-      val = WID->view_butt[38]->value();
+      val = o->view.butt[38]->value();
       if(force || (val != saturate_values))
         opt_view_saturate_values(i, GMSH_SET, val);
 
-      val = WID->view_butt[10]->value();
+      val = o->view.butt[10]->value();
       if(force || (val != show_element))
         opt_view_show_element(i, GMSH_SET, val);
 
-      val = WID->view_butt[2]->value();
+      val = o->view.butt[2]->value();
       if(force || (val != draw_skin_only))
         opt_view_draw_skin_only(i, GMSH_SET, val);
 
-      val = WID->view_butt[4]->value();
+      val = o->view.butt[4]->value();
       if(force || (val != show_scale))
         opt_view_show_scale(i, GMSH_SET, val);
 
-      val = WID->view_butt[3]->value();
+      val = o->view.butt[3]->value();
       if(force || (val != mikado))
         opt_view_axes_mikado(i, GMSH_SET, val);
 
-      val = WID->view_butt[7]->value();
+      val = o->view.butt[7]->value();
       if(force || (val != auto_position))
         opt_view_auto_position(i, GMSH_SET, val);
 
-      val = WID->view_butt[25]->value();
+      val = o->view.butt[25]->value();
       if(force || (val != axes_auto_position))
         opt_view_axes_auto_position(i, GMSH_SET, val);
 
-      val = WID->view_butt[5]->value();
+      val = o->view.butt[5]->value();
       if(force || (val != draw_strings))
         opt_view_draw_strings(i, GMSH_SET, val);
 
-      val = WID->view_butt[11]->value();
+      val = o->view.butt[11]->value();
       if(force || (val != light))
         opt_view_light(i, GMSH_SET, val);
 
-      val = WID->view_butt[8]->value();
+      val = o->view.butt[8]->value();
       if(force || (val != light_lines))
         opt_view_light_lines(i, GMSH_SET, val);
 
-      val = WID->view_butt[9]->value();
+      val = o->view.butt[9]->value();
       if(force || (val != light_two_side))
         opt_view_light_two_side(i, GMSH_SET, val);
 
-      val = WID->view_butt[12]->value();
+      val = o->view.butt[12]->value();
       if(force || (val != smooth_normals))
         opt_view_smooth_normals(i, GMSH_SET, val);
 
-      val = WID->view_menu_butt[0]->menu()[0].value() ? 1 : 0;
+      val = o->view.menu[0]->menu()[0].value() ? 1 : 0;
       if(force || (val != draw_scalars))
         opt_view_draw_scalars(i, GMSH_SET, val);
 
-      val = WID->view_menu_butt[0]->menu()[1].value() ? 1 : 0;
+      val = o->view.menu[0]->menu()[1].value() ? 1 : 0;
       if(force || (val != draw_vectors))
         opt_view_draw_vectors(i, GMSH_SET, val);
 
-      val = WID->view_menu_butt[0]->menu()[2].value() ? 1 : 0;
+      val = o->view.menu[0]->menu()[2].value() ? 1 : 0;
       if(force || (val != draw_tensors))
         opt_view_draw_tensors(i, GMSH_SET, val);
 
-      val = WID->view_menu_butt[1]->menu()[0].value() ? 1 : 0;
+      val = o->view.menu[1]->menu()[0].value() ? 1 : 0;
       if(force || (val != draw_points))
         opt_view_draw_points(i, GMSH_SET, val);
 
-      val = WID->view_menu_butt[1]->menu()[1].value() ? 1 : 0;
+      val = o->view.menu[1]->menu()[1].value() ? 1 : 0;
       if(force || (val != draw_lines))
         opt_view_draw_lines(i, GMSH_SET, val);
 
-      val = WID->view_menu_butt[1]->menu()[2].value() ? 1 : 0;
+      val = o->view.menu[1]->menu()[2].value() ? 1 : 0;
       if(force || (val != draw_triangles))
         opt_view_draw_triangles(i, GMSH_SET, val);
 
-      val = WID->view_menu_butt[1]->menu()[3].value() ? 1 : 0;
+      val = o->view.menu[1]->menu()[3].value() ? 1 : 0;
       if(force || (val != draw_quadrangles))
         opt_view_draw_quadrangles(i, GMSH_SET, val);
 
-      val = WID->view_menu_butt[1]->menu()[4].value() ? 1 : 0;
+      val = o->view.menu[1]->menu()[4].value() ? 1 : 0;
       if(force || (val != draw_tetrahedra))
         opt_view_draw_tetrahedra(i, GMSH_SET, val);
 
-      val = WID->view_menu_butt[1]->menu()[5].value() ? 1 : 0;
+      val = o->view.menu[1]->menu()[5].value() ? 1 : 0;
       if(force || (val != draw_hexahedra))
         opt_view_draw_hexahedra(i, GMSH_SET, val);
 
-      val = WID->view_menu_butt[1]->menu()[6].value() ? 1 : 0;
+      val = o->view.menu[1]->menu()[6].value() ? 1 : 0;
       if(force || (val != draw_prisms))
         opt_view_draw_prisms(i, GMSH_SET, val);
 
-      val = WID->view_menu_butt[1]->menu()[7].value() ? 1 : 0;
+      val = o->view.menu[1]->menu()[7].value() ? 1 : 0;
       if(force || (val != draw_pyramids))
         opt_view_draw_pyramids(i, GMSH_SET, val);
 
-      val = WID->view_butt[6]->value();
+      val = o->view.butt[6]->value();
       if(force || (val != use_gen_raise))
         opt_view_use_gen_raise(i, GMSH_SET, val);
 
-      val = WID->view_butt[24]->value();
+      val = o->view.butt[24]->value();
       if(force || (val != fake_transparency))
         opt_view_fake_transparency(i, GMSH_SET, val);
 
-      val = WID->view_butt[26]->value();
+      val = o->view.butt[26]->value();
       if(force || (val != use_stipple))
         opt_view_use_stipple(i, GMSH_SET, val);
 
-      val = WID->view_butt[1]->value();
+      val = o->view.butt[1]->value();
       if(force || (val != center_glyphs))
         opt_view_center_glyphs(i, GMSH_SET, val);
 
       // view_values
       
-      val = WID->view_value[0]->value();
+      val = o->view.value[0]->value();
       if(force || (val != normals))
         opt_view_normals(i, GMSH_SET, val);
 
-      val = WID->view_value[1]->value();
+      val = o->view.value[1]->value();
       if(force || (val != tangents))
         opt_view_tangents(i, GMSH_SET, val);
 
-      val = WID->view_value[31]->value();
+      val = o->view.value[31]->value();
       if(force || (val != custom_min))
         opt_view_custom_min(i, GMSH_SET, val);
 
-      val = WID->view_value[32]->value();
+      val = o->view.value[32]->value();
       if(force || (val != custom_max))
         opt_view_custom_max(i, GMSH_SET, val);
 
-      val = WID->view_value[33]->value();
+      val = o->view.value[33]->value();
       if(force || (val != max_recursion_level))
         opt_view_max_recursion_level(i, GMSH_SET, val);
 
-      val = WID->view_value[34]->value();
+      val = o->view.value[34]->value();
       if(force || (val != target_error))
         opt_view_target_error(i, GMSH_SET, val);
 
-      val = WID->view_value[30]->value();
+      val = o->view.value[30]->value();
       if(force || (val != nb_iso))
         opt_view_nb_iso(i, GMSH_SET, val);
 
-      val = WID->view_value[40]->value();
+      val = o->view.value[40]->value();
       if(force || (val != offset0))
         opt_view_offset0(i, GMSH_SET, val);
 
-      val = WID->view_value[41]->value();
+      val = o->view.value[41]->value();
       if(force || (val != offset1))
         opt_view_offset1(i, GMSH_SET, val);
 
-      val = WID->view_value[42]->value();
+      val = o->view.value[42]->value();
       if(force || (val != offset2))
         opt_view_offset2(i, GMSH_SET, val);
 
-      val = WID->view_value[51]->value();
+      val = o->view.value[51]->value();
       if(force || (val != transform00))
         opt_view_transform00(i, GMSH_SET, val);
 
-      val = WID->view_value[52]->value();
+      val = o->view.value[52]->value();
       if(force || (val != transform01))
         opt_view_transform01(i, GMSH_SET, val);
 
-      val = WID->view_value[53]->value();
+      val = o->view.value[53]->value();
       if(force || (val != transform02))
         opt_view_transform02(i, GMSH_SET, val);
 
-      val = WID->view_value[54]->value();
+      val = o->view.value[54]->value();
       if(force || (val != transform10))
         opt_view_transform10(i, GMSH_SET, val);
 
-      val = WID->view_value[55]->value();
+      val = o->view.value[55]->value();
       if(force || (val != transform11))
         opt_view_transform11(i, GMSH_SET, val);
 
-      val = WID->view_value[56]->value();
+      val = o->view.value[56]->value();
       if(force || (val != transform12))
         opt_view_transform12(i, GMSH_SET, val);
 
-      val = WID->view_value[57]->value();
+      val = o->view.value[57]->value();
       if(force || (val != transform20))
         opt_view_transform20(i, GMSH_SET, val);
 
-      val = WID->view_value[58]->value();
+      val = o->view.value[58]->value();
       if(force || (val != transform21))
         opt_view_transform21(i, GMSH_SET, val);
 
-      val = WID->view_value[59]->value();
+      val = o->view.value[59]->value();
       if(force || (val != transform22))
         opt_view_transform22(i, GMSH_SET, val);
 
-      val = WID->view_value[43]->value();
+      val = o->view.value[43]->value();
       if(force || (val != raise0))
         opt_view_raise0(i, GMSH_SET, val);
 
-      val = WID->view_value[44]->value();
+      val = o->view.value[44]->value();
       if(force || (val != raise1))
         opt_view_raise1(i, GMSH_SET, val);
 
-      val = WID->view_value[45]->value();
+      val = o->view.value[45]->value();
       if(force || (val != raise2))
         opt_view_raise2(i, GMSH_SET, val);
 
-      val = WID->view_value[46]->value();
+      val = o->view.value[46]->value();
       if(force || (val != normal_raise))
         opt_view_normal_raise(i, GMSH_SET, val);
 
-      val = WID->view_value[50]->value();
+      val = o->view.value[50]->value();
       if(force || (val != timestep))
         opt_view_timestep(i, GMSH_SET, val);
 
-      val = WID->view_value[60]->value();
+      val = o->view.value[60]->value();
       if(force || (val != arrow_size))
         opt_view_arrow_size(i, GMSH_SET, val);
 
-      val = WID->view_value[63]->value();
+      val = o->view.value[63]->value();
       if(force || (val != displacement_factor))
         opt_view_displacement_factor(i, GMSH_SET, val);
 
-      val = WID->view_value[61]->value();
+      val = o->view.value[61]->value();
       if(force || (val != point_size))
         opt_view_point_size(i, GMSH_SET, val);
 
-      val = WID->view_value[62]->value();
+      val = o->view.value[62]->value();
       if(force || (val != line_width))
         opt_view_line_width(i, GMSH_SET, val);
 
-      val = WID->view_value[12]->value();
+      val = o->view.value[12]->value();
       if(force || (val != explode))
         opt_view_explode(i, GMSH_SET, val);
 
-      val = WID->view_value[10]->value();
+      val = o->view.value[10]->value();
       if(force || (val != angle_smooth_normals))
         opt_view_angle_smooth_normals(i, GMSH_SET, val);
 
-      val = WID->view_value[20]->value();
+      val = o->view.value[20]->value();
       if(force || (val != position0))
         opt_view_position0(i, GMSH_SET, val);
 
-      val = WID->view_value[21]->value();
+      val = o->view.value[21]->value();
       if(force || (val != position1))
         opt_view_position1(i, GMSH_SET, val);
 
-      val = WID->view_value[22]->value();
+      val = o->view.value[22]->value();
       if(force || (val != size0))
         opt_view_size0(i, GMSH_SET, val);
       
-      val = WID->view_value[23]->value();
+      val = o->view.value[23]->value();
       if(force || (val != size1))
         opt_view_size1(i, GMSH_SET, val);
 
-      val = WID->view_value[13]->value();
+      val = o->view.value[13]->value();
       if(force || (val != axes_xmin))
         opt_view_axes_xmin(i, GMSH_SET, val);
 
-      val = WID->view_value[14]->value();
+      val = o->view.value[14]->value();
       if(force || (val != axes_ymin))
         opt_view_axes_ymin(i, GMSH_SET, val);
 
-      val = WID->view_value[15]->value();
+      val = o->view.value[15]->value();
       if(force || (val != axes_zmin))
         opt_view_axes_zmin(i, GMSH_SET, val);
 
-      val = WID->view_value[16]->value();
+      val = o->view.value[16]->value();
       if(force || (val != axes_xmax))
         opt_view_axes_xmax(i, GMSH_SET, val);
 
-      val = WID->view_value[17]->value();
+      val = o->view.value[17]->value();
       if(force || (val != axes_ymax))
         opt_view_axes_ymax(i, GMSH_SET, val);
 
-      val = WID->view_value[18]->value();
+      val = o->view.value[18]->value();
       if(force || (val != axes_zmax))
         opt_view_axes_zmax(i, GMSH_SET, val);
 
-      val = WID->view_value[2]->value();
+      val = o->view.value[2]->value();
       if(force || (val != gen_raise_factor))
         opt_view_gen_raise_factor(i, GMSH_SET, val);
 
-      val = WID->view_value[3]->value();
+      val = o->view.value[3]->value();
       if(force || (val != axes_tics0))
         opt_view_axes_tics0(i, GMSH_SET, val);
 
-      val = WID->view_value[4]->value();
+      val = o->view.value[4]->value();
       if(force || (val != axes_tics1))
         opt_view_axes_tics1(i, GMSH_SET, val);
 
-      val = WID->view_value[5]->value();
+      val = o->view.value[5]->value();
       if(force || (val != axes_tics2))
         opt_view_axes_tics2(i, GMSH_SET, val);
 
@@ -1752,47 +1754,47 @@ void view_options_ok_cb(CALLBACK_ARGS)
 
       const char *str;
 
-      str = WID->view_input[0]->value();
+      str = o->view.input[0]->value();
       if(force || strcmp(str, name))
         opt_view_name(i, GMSH_SET, str);
 
-      str = WID->view_input[1]->value();
+      str = o->view.input[1]->value();
       if(force || strcmp(str, format))
         opt_view_format(i, GMSH_SET, str);
 
-      str = WID->view_input[10]->value();
+      str = o->view.input[10]->value();
       if(force || strcmp(str, axes_label0))
         opt_view_axes_label0(i, GMSH_SET, str);
 
-      str = WID->view_input[11]->value();
+      str = o->view.input[11]->value();
       if(force || strcmp(str, axes_label1))
         opt_view_axes_label1(i, GMSH_SET, str);
 
-      str = WID->view_input[12]->value();
+      str = o->view.input[12]->value();
       if(force || strcmp(str, axes_label2))
         opt_view_axes_label2(i, GMSH_SET, str);
 
-      str = WID->view_input[7]->value();
+      str = o->view.input[7]->value();
       if(force || strcmp(str, axes_format0))
         opt_view_axes_format0(i, GMSH_SET, str);
 
-      str = WID->view_input[8]->value();
+      str = o->view.input[8]->value();
       if(force || strcmp(str, axes_format1))
         opt_view_axes_format1(i, GMSH_SET, str);
 
-      str = WID->view_input[9]->value();
+      str = o->view.input[9]->value();
       if(force || strcmp(str, axes_format2))
         opt_view_axes_format2(i, GMSH_SET, str);
 
-      str = WID->view_input[4]->value();
+      str = o->view.input[4]->value();
       if(force || strcmp(str, gen_raise0))
         opt_view_gen_raise0(i, GMSH_SET, str);
 
-      str = WID->view_input[5]->value();
+      str = o->view.input[5]->value();
       if(force || strcmp(str, gen_raise1))
         opt_view_gen_raise1(i, GMSH_SET, str);
 
-      str = WID->view_input[6]->value();
+      str = o->view.input[6]->value();
       if(force || strcmp(str, gen_raise2))
         opt_view_gen_raise2(i, GMSH_SET, str);
 
@@ -1834,12 +1836,12 @@ void view_options_ok_cb(CALLBACK_ARGS)
 
 void statistics_cb(CALLBACK_ARGS)
 {
-  WID->create_statistics_window();
+  GUI::instance()->stats->show();
 }
 
 void statistics_update_cb(CALLBACK_ARGS)
 {
-  WID->set_statistics(true);
+  GUI::instance()->stats->compute(true);
 }
 
 void statistics_histogram_cb(CALLBACK_ARGS)
@@ -1849,19 +1851,19 @@ void statistics_histogram_cb(CALLBACK_ARGS)
   std::vector<double> x, y;
 
   if(name == "Gamma2D"){
-    for(int i = 0; i < 100; i++) y.push_back(WID->quality[0][i]);
+    for(int i = 0; i < 100; i++) y.push_back(GUI::instance()->stats->quality[0][i]);
     new PView("Gamma", "# Elements", x, y);
   }
   else if(name == "Eta2D"){
-    for(int i = 0; i < 100; i++) y.push_back(WID->quality[1][i]);
+    for(int i = 0; i < 100; i++) y.push_back(GUI::instance()->stats->quality[1][i]);
     new PView("Eta", "# Elements", x, y);
   }
   else if(name == "Rho2D"){
-    for(int i = 0; i < 100; i++) y.push_back(WID->quality[2][i]);
+    for(int i = 0; i < 100; i++) y.push_back(GUI::instance()->stats->quality[2][i]);
     new PView("Rho", "# Elements", x, y);
   }
   else if(name == "Disto2D"){
-    for(int i = 0; i < 100; i++) y.push_back(WID->quality[3][i]);
+    for(int i = 0; i < 100; i++) y.push_back(GUI::instance()->stats->quality[3][i]);
     new PView("Disto", "# Elements", x, y);
   }
   else{
@@ -1886,7 +1888,7 @@ void statistics_histogram_cb(CALLBACK_ARGS)
     new PView(name, "ElementData", GModel::current(), d);
   }
 
-  WID->update_views();
+  GUI::instance()->updateViews();
   Draw();
 }
 
@@ -1894,12 +1896,12 @@ void statistics_histogram_cb(CALLBACK_ARGS)
 
 void message_cb(CALLBACK_ARGS)
 {
-  WID->create_message_window();
+  GUI::instance()->messages->show();
 }
 
 void message_auto_scroll_cb(CALLBACK_ARGS)
 {
-  CTX.msg_auto_scroll = WID->msg_butt->value();
+  CTX.msg_auto_scroll = GUI::instance()->messages->butt->value();
 }
 
 void message_copy_cb(CALLBACK_ARGS)
@@ -1907,9 +1909,9 @@ void message_copy_cb(CALLBACK_ARGS)
 #define BUFFL 50000
   static char buff[BUFFL];
   strcpy(buff, "");
-  for(int i = 1; i <= WID->msg_browser->size(); i++) {
-    if(WID->msg_browser->selected(i)) {
-      const char *c = WID->msg_browser->text(i);
+  for(int i = 1; i <= GUI::instance()->messages->browser->size(); i++) {
+    if(GUI::instance()->messages->browser->selected(i)) {
+      const char *c = GUI::instance()->messages->browser->text(i);
       if(strlen(buff) + strlen(c) > BUFFL - 2) {
         Msg::Error("Text selection too large to copy");
         break;
@@ -1928,7 +1930,7 @@ void message_copy_cb(CALLBACK_ARGS)
 
 void message_clear_cb(CALLBACK_ARGS)
 {
-  WID->msg_browser->clear();
+  GUI::instance()->messages->browser->clear();
 }
 
 void message_save_cb(CALLBACK_ARGS)
@@ -1942,7 +1944,7 @@ void message_save_cb(CALLBACK_ARGS)
                       "Cancel", "Replace", NULL, name.c_str()))
           goto test;
     }
-    WID->save_message(name.c_str());
+    GUI::instance()->messages->save(name.c_str());
   }
 }
 
@@ -1954,35 +1956,35 @@ void visibility_cb(CALLBACK_ARGS)
 
   const char *str = (const char*)data;
   if(str && !strcmp(str, "redraw_only"))
-    WID->create_visibility_window(true);
+    GUI::instance()->visibility->show(true);
   else
-    WID->create_visibility_window();
+    GUI::instance()->visibility->show(false);
 
-  WID->vis_browser->clear();
+  GUI::instance()->visibility->browser->clear();
 
-  int type = WID->vis_type->value();
+  int type = GUI::instance()->visibility->type->value();
 
   VisibilityManager::instance()->update(type);
   for(int i = 0; i < VisibilityManager::instance()->getNumEntities(); i++){
-    WID->vis_browser->add(VisibilityManager::instance()->getBrowserLine(i).c_str());
+    GUI::instance()->visibility->browser->add(VisibilityManager::instance()->getBrowserLine(i).c_str());
     if(VisibilityManager::instance()->getVisibility(i))
-      WID->vis_browser->select(i + 1);
+      GUI::instance()->visibility->browser->select(i + 1);
   }
 
   // activate the delete button for physicals only!
   if(type == 1)
-    WID->vis_push_butt[0]->activate();
+    GUI::instance()->visibility->push[0]->activate();
   else
-    WID->vis_push_butt[0]->deactivate();
+    GUI::instance()->visibility->push[0]->deactivate();
 
   // disable numeric and interactive selection for partitions
   if(type == 2){
-    WID->vis_group[1]->deactivate();
-    WID->vis_group[2]->deactivate();
+    GUI::instance()->visibility->group[1]->deactivate();
+    GUI::instance()->visibility->group[2]->deactivate();
   }
   else{
-    WID->vis_group[1]->activate();
-    WID->vis_group[2]->activate();
+    GUI::instance()->visibility->group[1]->activate();
+    GUI::instance()->visibility->group[2]->activate();
   }
 }
 
@@ -1992,16 +1994,16 @@ void visibility_ok_cb(CALLBACK_ARGS)
   // browser and apply them into the model
   if(VisibilityManager::instance()->getNumEntities()){
     CTX.mesh.changed |= (ENT_LINE | ENT_SURFACE | ENT_VOLUME);
-    bool recursive = WID->vis_butt[0]->value() ? true : false;
-    int type = WID->vis_type->value();
+    bool recursive = GUI::instance()->visibility->butt[0]->value() ? true : false;
+    int type = GUI::instance()->visibility->type->value();
     VisibilityManager::instance()->setAllInvisible(type);
     for(int i = 0; i < VisibilityManager::instance()->getNumEntities(); i++)
-      if(WID->vis_browser->selected(i + 1))
+      if(GUI::instance()->visibility->browser->selected(i + 1))
         VisibilityManager::instance()->setVisibility(i, 1, recursive);
     // then refresh the browser to account for recursive selections
     for(int i = 0; i < VisibilityManager::instance()->getNumEntities(); i++)
       if(VisibilityManager::instance()->getVisibility(i))
-        WID->vis_browser->select(i + 1);
+        GUI::instance()->visibility->browser->select(i + 1);
     Draw();
   }
 }
@@ -2014,12 +2016,12 @@ void visibility_save_cb(CALLBACK_ARGS)
 
 void visibility_delete_cb(CALLBACK_ARGS)
 {
-  int type = WID->vis_type->value();
+  int type = GUI::instance()->visibility->type->value();
   if(type != 1) return; // delete only available for physicals
 
   bool all = true;
   for(int i = 0; i < VisibilityManager::instance()->getNumEntities(); i++){
-    if(!WID->vis_browser->selected(i + 1)){
+    if(!GUI::instance()->visibility->browser->selected(i + 1)){
       all = false;
       break;
     }
@@ -2029,7 +2031,7 @@ void visibility_delete_cb(CALLBACK_ARGS)
   }
   else{
     for(int i = 0; i < VisibilityManager::instance()->getNumEntities(); i++){
-      if(WID->vis_browser->selected(i + 1)){
+      if(GUI::instance()->visibility->browser->selected(i + 1)){
         Vis *v = VisibilityManager::instance()->getEntity(i);
         GModel::current()->deletePhysicalGroup(v->getDim(), v->getTag());
       }
@@ -2058,37 +2060,37 @@ void visibility_sort_cb(CALLBACK_ARGS)
 
   if(val == 0) { // select or deselect everything
     int selectall = 0;
-    for(int i = 0; i < WID->vis_browser->size(); i++)
-      if(!WID->vis_browser->selected(i + 1)) {
+    for(int i = 0; i < GUI::instance()->visibility->browser->size(); i++)
+      if(!GUI::instance()->visibility->browser->selected(i + 1)) {
         selectall = 1;
         break;
       }
     if(selectall)
-      for(int i = 0; i < WID->vis_browser->size(); i++)
-        WID->vis_browser->select(i + 1);
+      for(int i = 0; i < GUI::instance()->visibility->browser->size(); i++)
+        GUI::instance()->visibility->browser->select(i + 1);
     else
-      WID->vis_browser->deselect();
+      GUI::instance()->visibility->browser->deselect();
   }
   else if(val == -1){ // invert the selection
-    int *state = new int[WID->vis_browser->size()];
-    for(int i = 0; i < WID->vis_browser->size(); i++)
-      state[i] = WID->vis_browser->selected(i + 1);
-    WID->vis_browser->deselect();
-    for(int i = 0; i < WID->vis_browser->size(); i++)
-      if(!state[i]) WID->vis_browser->select(i + 1);
+    int *state = new int[GUI::instance()->visibility->browser->size()];
+    for(int i = 0; i < GUI::instance()->visibility->browser->size(); i++)
+      state[i] = GUI::instance()->visibility->browser->selected(i + 1);
+    GUI::instance()->visibility->browser->deselect();
+    for(int i = 0; i < GUI::instance()->visibility->browser->size(); i++)
+      if(!state[i]) GUI::instance()->visibility->browser->select(i + 1);
     delete [] state;
   }
   else if(val == -2){ // create new parameter name for selection
-    for(int i = 0; i < WID->vis_browser->size(); i++){
-      if(WID->vis_browser->selected(i + 1)){
+    for(int i = 0; i < GUI::instance()->visibility->browser->size(); i++){
+      if(GUI::instance()->visibility->browser->selected(i + 1)){
         static char tmpstr[256];
         sprintf(tmpstr, "%d", VisibilityManager::instance()->getTag(i));
-        WID->context_geometry_input[1]->value(tmpstr);
+        GUI::instance()->geoContext->input[1]->value(tmpstr);
         break;
       }
     }
-    WID->context_geometry_input[0]->value("NewName");
-    WID->create_geometry_context_window(0);
+    GUI::instance()->geoContext->input[0]->value("NewName");
+    GUI::instance()->geoContext->show(0);
   }
   else { // set new sorting mode
     VisibilityManager::instance()->setSortMode(val);
@@ -2101,7 +2103,7 @@ void visibility_number_cb(CALLBACK_ARGS)
   CTX.mesh.changed |= (ENT_LINE | ENT_SURFACE | ENT_VOLUME);
 
   // type = 0 for elementary, 1 for physical and 2 for partitions
-  int type = WID->vis_type->value();
+  int type = GUI::instance()->visibility->type->value();
   if(type != 0 && type != 1) return;
 
   // what = 0 for nodes, 1 for elements, 2 for points, 3 for lines, 4
@@ -2117,17 +2119,17 @@ void visibility_number_cb(CALLBACK_ARGS)
   else{ // hide
     val = 0;
   }
-  const char *str = WID->vis_input[what]->value();
+  const char *str = GUI::instance()->visibility->input[what]->value();
   if(type == 1 && what >= 2 && what <= 5) what += 4;
 
   int num = (!strcmp(str, "all") || !strcmp(str, "*")) ? -1 : atoi(str);
-  bool recursive = WID->vis_butt[0]->value() ? true : false;
+  bool recursive = GUI::instance()->visibility->butt[0]->value() ? true : false;
   
   VisibilityManager::instance()->setVisibilityByNumber(what, num, val, recursive);
 
-  int pos = WID->vis_browser->position();
+  int pos = GUI::instance()->visibility->browser->position();
   visibility_cb(NULL, (void*)"redraw_only");
-  WID->vis_browser->position(pos);
+  GUI::instance()->visibility->browser->position(pos);
   Draw();
 }
 
@@ -2139,9 +2141,9 @@ static void _apply_visibility(char mode,
                               std::vector<MElement*> &elements)
 {
   // type = 0 for elementary, 1 for physical and 2 for partitions
-  int type = WID->vis_type->value();
+  int type = GUI::instance()->visibility->type->value();
   if(type != 0 && type != 1) return;
-  bool recursive = WID->vis_butt[0]->value() ? true : false;
+  bool recursive = GUI::instance()->visibility->butt[0]->value() ? true : false;
 
   if(mode == 1){ // when showing a single entity, first hide everything
     if(CTX.pick_elements)
@@ -2191,9 +2193,9 @@ static void _apply_visibility(char mode,
             (9, regions[i]->physicals[j], mode, recursive);
     }
   }
-  int pos = WID->vis_browser->position();
+  int pos = GUI::instance()->visibility->browser->position();
   visibility_cb(NULL, (void*)"redraw_only");
-  WID->vis_browser->position(pos);
+  GUI::instance()->visibility->browser->position(pos);
 }
 
 void visibility_interactive_cb(CALLBACK_ARGS)
@@ -2327,24 +2329,24 @@ void visibility_interactive_cb(CALLBACK_ARGS)
 
 void clip_cb(CALLBACK_ARGS)
 {
-  WID->create_clip_window();
+  GUI::instance()->clipping->show();
 }
 
 void clip_num_cb(CALLBACK_ARGS)
 {
-  WID->reset_clip_browser();
+  GUI::instance()->clipping->resetBrowser();
 }
 
 void clip_update_cb(CALLBACK_ARGS)
 {
-  if(WID->clip_group[0]->visible()){ // clipping planes
-    int idx = WID->clip_choice->value();
+  if(GUI::instance()->clipping->group[0]->visible()){ // clipping planes
+    int idx = GUI::instance()->clipping->choice->value();
     CTX.geom.clip &= ~(1 << idx);
     CTX.mesh.clip &= ~(1 << idx);
     for(unsigned int i = 0; i < PView::list.size(); i++)
       PView::list[i]->getOptions()->Clip &= ~(1 << idx);
-    for(int i = 0; i < WID->clip_browser->size(); i++){
-      if(WID->clip_browser->selected(i + 1)){
+    for(int i = 0; i < GUI::instance()->clipping->browser->size(); i++){
+      if(GUI::instance()->clipping->browser->selected(i + 1)){
         if(i == 0)
           CTX.geom.clip |= (1 << idx);
         else if(i == 1)
@@ -2354,15 +2356,15 @@ void clip_update_cb(CALLBACK_ARGS)
       }
     }
     for(int i = 0; i < 4; i++)
-      CTX.clip_plane[idx][i] = WID->clip_value[i]->value();
+      CTX.clip_plane[idx][i] = GUI::instance()->clipping->value[i]->value();
   }
   else{ // clipping box
     CTX.geom.clip = 0;
     CTX.mesh.clip = 0;
     for(unsigned int i = 0; i < PView::list.size(); i++)
       PView::list[i]->getOptions()->Clip = 0;
-    for(int i = 0; i < WID->clip_browser->size(); i++){
-      if(WID->clip_browser->selected(i + 1)){
+    for(int i = 0; i < GUI::instance()->clipping->browser->size(); i++){
+      if(GUI::instance()->clipping->browser->selected(i + 1)){
         for(int idx = 0; idx < 6; idx++){
           if(i == 0)
             CTX.geom.clip |= (1 << idx);
@@ -2373,12 +2375,12 @@ void clip_update_cb(CALLBACK_ARGS)
         }
       }
     }
-    double c[3] = {WID->clip_value[4]->value(),
-                   WID->clip_value[5]->value(),
-                   WID->clip_value[6]->value()};
-    double d[3] = {WID->clip_value[7]->value(),
-                   WID->clip_value[8]->value(),
-                   WID->clip_value[9]->value()};
+    double c[3] = {GUI::instance()->clipping->value[4]->value(),
+                   GUI::instance()->clipping->value[5]->value(),
+                   GUI::instance()->clipping->value[6]->value()};
+    double d[3] = {GUI::instance()->clipping->value[7]->value(),
+                   GUI::instance()->clipping->value[8]->value(),
+                   GUI::instance()->clipping->value[9]->value()};
     // left
     CTX.clip_plane[0][0] = 1.;  CTX.clip_plane[0][1] = 0.;  CTX.clip_plane[0][2] = 0.;
     CTX.clip_plane[0][3] = -(c[0] - d[0] / 2.);
@@ -2399,7 +2401,8 @@ void clip_update_cb(CALLBACK_ARGS)
     CTX.clip_plane[5][3] = (c[2] + d[2] / 2.);
   }
 
-  if(CTX.clip_whole_elements || CTX.clip_whole_elements != WID->clip_butt[0]->value()){
+  if(CTX.clip_whole_elements || 
+     CTX.clip_whole_elements != GUI::instance()->clipping->butt[0]->value()){
     for(int clip = 0; clip < 6; clip++){
       if(CTX.mesh.clip)
 	CTX.mesh.changed |= (ENT_LINE | ENT_SURFACE | ENT_VOLUME);
@@ -2409,9 +2412,9 @@ void clip_update_cb(CALLBACK_ARGS)
     }
   }
   
-  CTX.clip_whole_elements = WID->clip_butt[0]->value();
-  CTX.clip_only_draw_intersecting_volume = WID->clip_butt[1]->value();
-  CTX.clip_only_volume = WID->clip_butt[2]->value();
+  CTX.clip_whole_elements = GUI::instance()->clipping->butt[0]->value();
+  CTX.clip_only_draw_intersecting_volume = GUI::instance()->clipping->butt[1]->value();
+  CTX.clip_only_volume = GUI::instance()->clipping->butt[2]->value();
   
   int old = CTX.draw_bbox;
   CTX.draw_bbox = 1;
@@ -2425,7 +2428,7 @@ void clip_update_cb(CALLBACK_ARGS)
 void clip_invert_cb(CALLBACK_ARGS)
 {
   for(int i = 0; i < 4; i++)
-    WID->clip_value[i]->value(-WID->clip_value[i]->value());
+    GUI::instance()->clipping->value[i]->value(-GUI::instance()->clipping->value[i]->value());
   clip_update_cb(NULL, NULL);
 }
 
@@ -2448,7 +2451,7 @@ void clip_reset_cb(CALLBACK_ARGS)
       PView::list[index]->setChanged(true);
   }
 
-  WID->reset_clip_browser();
+  GUI::instance()->clipping->resetBrowser();
   Draw();
 }
 
@@ -2456,21 +2459,21 @@ void clip_reset_cb(CALLBACK_ARGS)
 
 void manip_cb(CALLBACK_ARGS)
 {
-  WID->create_manip_window();
+  GUI::instance()->manip->show();
 }
 
 void manip_update_cb(CALLBACK_ARGS)
 {
-  drawContext *ctx = WID->g_opengl_window->getDrawContext();
-  ctx->r[0] = WID->manip_value[0]->value();
-  ctx->r[1] = WID->manip_value[1]->value();
-  ctx->r[2] = WID->manip_value[2]->value();
-  ctx->t[0] = WID->manip_value[3]->value();
-  ctx->t[1] = WID->manip_value[4]->value();
-  ctx->t[2] = WID->manip_value[5]->value();
-  ctx->s[0] = WID->manip_value[6]->value();
-  ctx->s[1] = WID->manip_value[7]->value();
-  ctx->s[2] = WID->manip_value[8]->value();
+  drawContext *ctx = GUI::instance()->graph[0]->gl->getDrawContext();
+  ctx->r[0] = GUI::instance()->manip->value[0]->value();
+  ctx->r[1] = GUI::instance()->manip->value[1]->value();
+  ctx->r[2] = GUI::instance()->manip->value[2]->value();
+  ctx->t[0] = GUI::instance()->manip->value[3]->value();
+  ctx->t[1] = GUI::instance()->manip->value[4]->value();
+  ctx->t[2] = GUI::instance()->manip->value[5]->value();
+  ctx->s[0] = GUI::instance()->manip->value[6]->value();
+  ctx->s[1] = GUI::instance()->manip->value[7]->value();
+  ctx->s[2] = GUI::instance()->manip->value[8]->value();
   ctx->setQuaternionFromEulerAngles();
   Draw();
 }
@@ -2570,7 +2573,7 @@ void help_short_cb(CALLBACK_ARGS)
   Msg::Direct("  Alt+Shift+y   Set -Y view"); 
   Msg::Direct("  Alt+Shift+z   Set -Z view"); 
   Msg::Direct(" ");
-  WID->create_message_window();
+  GUI::instance()->messages->show();
 }
 
 void help_mouse_cb(CALLBACK_ARGS)
@@ -2597,14 +2600,14 @@ void help_mouse_cb(CALLBACK_ARGS)
   Msg::Direct("  For a 2 button mouse, Middle button = Shift+Left button");
   Msg::Direct("  For a 1 button mouse, Middle button = Shift+Left button, Right button = Alt+Left button");
   Msg::Direct(" ");
-  WID->create_message_window();
+  GUI::instance()->messages->show();
 }
 
 void help_command_line_cb(CALLBACK_ARGS)
 {
   Msg::Direct(" ");
   Print_Usage("gmsh");
-  WID->create_message_window();
+  GUI::instance()->messages->show();
 }
 
 void _replace_multi_format(const char *in, const char *val, char *out)
@@ -2660,51 +2663,51 @@ void help_credits_cb(CALLBACK_ARGS)
 
 void help_about_cb(CALLBACK_ARGS)
 {
-  WID->create_about_window();
+  GUI::instance()->about->win->show();
 }
 
 // Module Menu
 
 void mod_geometry_cb(CALLBACK_ARGS)
 {
-  WID->set_context(menu_geometry, 0);
+  GUI::instance()->menu->setContext(menu_geometry, 0);
 }
 
 void mod_mesh_cb(CALLBACK_ARGS)
 {
-  WID->set_context(menu_mesh, 0);
+  GUI::instance()->menu->setContext(menu_mesh, 0);
 }
 
 void mod_solver_cb(CALLBACK_ARGS)
 {
-  WID->set_context(menu_solver, 0);
+  GUI::instance()->menu->setContext(menu_solver, 0);
 }
 
 void mod_post_cb(CALLBACK_ARGS)
 {
-  WID->set_context(menu_post, 0);
+  GUI::instance()->menu->setContext(menu_post, 0);
 }
 
 void mod_back_cb(CALLBACK_ARGS)
 {
-  WID->set_context(NULL, -1);
+  GUI::instance()->menu->setContext(NULL, -1);
 }
 
 void mod_forward_cb(CALLBACK_ARGS)
 {
-  WID->set_context(NULL, 1);
+  GUI::instance()->menu->setContext(NULL, 1);
 }
 
 // Dynamic Geomtry Menus
 
 void geometry_elementary_cb(CALLBACK_ARGS)
 {
-  WID->set_context(menu_geometry_elementary, 0);
+  GUI::instance()->menu->setContext(menu_geometry_elementary, 0);
 }
 
 void geometry_physical_cb(CALLBACK_ARGS)
 {
-  WID->set_context(menu_geometry_physical, 0);
+  GUI::instance()->menu->setContext(menu_geometry_physical, 0);
 }
 
 void geometry_edit_cb(CALLBACK_ARGS)
@@ -2724,7 +2727,7 @@ void geometry_reload_cb(CALLBACK_ARGS)
 
 void geometry_elementary_add_cb(CALLBACK_ARGS)
 {
-  WID->set_context(menu_geometry_elementary_add, 0);
+  GUI::instance()->menu->setContext(menu_geometry_elementary_add, 0);
 }
 
 static void _add_new_point()
@@ -2732,10 +2735,10 @@ static void _add_new_point()
   opt_geometry_points(0, GMSH_SET | GMSH_GUI, 1);
   Draw();
 
-  WID->create_geometry_context_window(1);
+  GUI::instance()->geoContext->show(1);
 
   while(1) {
-    WID->g_opengl_window->AddPointMode = true;
+    GUI::instance()->graph[0]->gl->addPointMode = true;
     Msg::StatusBar(3, false, "Move mouse and/or enter coordinates\n"
         "[Press 'Shift' to hold position, 'e' to add point or 'q' to abort]");
     std::vector<GVertex*> vertices;
@@ -2746,15 +2749,15 @@ static void _add_new_point()
     char ib = SelectEntity(ENT_NONE, vertices, edges, faces, regions, elements);
     if(ib == 'e'){
       add_point(CTX.filename,
-                WID->context_geometry_input[2]->value(),
-                WID->context_geometry_input[3]->value(),
-                WID->context_geometry_input[4]->value(),
-                WID->context_geometry_input[5]->value());
-      WID->reset_visibility();
+                GUI::instance()->geoContext->input[2]->value(),
+                GUI::instance()->geoContext->input[3]->value(),
+                GUI::instance()->geoContext->input[4]->value(),
+                GUI::instance()->geoContext->input[5]->value());
+      GUI::instance()->resetVisibility();
       Draw();
     }
     if(ib == 'q'){
-      WID->g_opengl_window->AddPointMode = false;
+      GUI::instance()->graph[0]->gl->addPointMode = false;
       break;
     }
   }
@@ -2796,7 +2799,7 @@ static void _add_new_multiline(std::string type)
     if(ib == 'e') {
       if(p.size() >= 2)
 	add_multline(type, p, CTX.filename);
-      WID->reset_visibility();
+      GUI::instance()->resetVisibility();
       ZeroHighlight();
       Draw();
       p.clear();
@@ -2861,7 +2864,7 @@ static void _add_new_line()
     }
     if(p.size() == 2) {
       add_multline("Line", p, CTX.filename);
-      WID->reset_visibility();
+      GUI::instance()->resetVisibility();
       ZeroHighlight();
       Draw();
       p.clear();
@@ -2917,7 +2920,7 @@ static void _add_new_circle()
     }
     if(p.size() == 3) {
       add_circ(p[0], p[1], p[2], CTX.filename); // begin, center, end
-      WID->reset_visibility();
+      GUI::instance()->resetVisibility();
       ZeroHighlight();
       Draw();
       p.clear();
@@ -2976,7 +2979,7 @@ static void _add_new_ellipse()
     }
     if(p.size() == 4) {
       add_ell(p[0], p[1], p[2], p[3], CTX.filename);
-      WID->reset_visibility();
+      GUI::instance()->resetVisibility();
       ZeroHighlight();
       Draw();
       p.clear();
@@ -3112,7 +3115,7 @@ static void _add_new_surface_volume(int mode)
             case 1: add_surf("Ruled Surface", List2, CTX.filename); break;
             case 2: add_vol(List2, CTX.filename); break;
             }
-            WID->reset_visibility();
+            GUI::instance()->resetVisibility();
             ZeroHighlight();
             Draw();
             break;
@@ -3132,13 +3135,13 @@ stopall:;
 void geometry_elementary_add_new_cb(CALLBACK_ARGS)
 {
   if(!data){
-    WID->set_context(menu_geometry_elementary_add_new, 0);
+    GUI::instance()->menu->setContext(menu_geometry_elementary_add_new, 0);
     return;
   }
 
   std::string str((const char*)data);
   if(str == "Parameter")
-    WID->create_geometry_context_window(0);
+    GUI::instance()->geoContext->show(0);
   else if(str == "Point")
     _add_new_point();
   else if(str == "Line")
@@ -3209,7 +3212,7 @@ static void _split_selection()
     }
   }
   Msg::StatusBar(3, false, "");
-  WID->reset_visibility();
+  GUI::instance()->resetVisibility();
   ZeroHighlight();
   Draw();
 }
@@ -3250,7 +3253,7 @@ static void _action_point_line_surface_volume(int action, int mode, const char *
   }
 
   if(action == 8){
-    WID->create_mesh_context_window(0);
+    GUI::instance()->meshContext->show(0);
   }
 
   Draw();
@@ -3367,49 +3370,49 @@ static void _action_point_line_surface_volume(int action, int mode, const char *
         switch (action) {
         case 0:
           translate(mode, List1, CTX.filename, what,
-                    WID->context_geometry_input[6]->value(),
-                    WID->context_geometry_input[7]->value(),
-                    WID->context_geometry_input[8]->value());
+                    GUI::instance()->geoContext->input[6]->value(),
+                    GUI::instance()->geoContext->input[7]->value(),
+                    GUI::instance()->geoContext->input[8]->value());
           break;
         case 1:
           rotate(mode, List1, CTX.filename, what,
-                 WID->context_geometry_input[12]->value(),
-                 WID->context_geometry_input[13]->value(),
-                 WID->context_geometry_input[14]->value(),
-                 WID->context_geometry_input[9]->value(),
-                 WID->context_geometry_input[10]->value(),
-                 WID->context_geometry_input[11]->value(),
-                 WID->context_geometry_input[15]->value());
+                 GUI::instance()->geoContext->input[12]->value(),
+                 GUI::instance()->geoContext->input[13]->value(),
+                 GUI::instance()->geoContext->input[14]->value(),
+                 GUI::instance()->geoContext->input[9]->value(),
+                 GUI::instance()->geoContext->input[10]->value(),
+                 GUI::instance()->geoContext->input[11]->value(),
+                 GUI::instance()->geoContext->input[15]->value());
           break;
         case 2:
           dilate(mode, List1, CTX.filename, what,
-                 WID->context_geometry_input[16]->value(),
-                 WID->context_geometry_input[17]->value(),
-                 WID->context_geometry_input[18]->value(),
-                 WID->context_geometry_input[19]->value());
+                 GUI::instance()->geoContext->input[16]->value(),
+                 GUI::instance()->geoContext->input[17]->value(),
+                 GUI::instance()->geoContext->input[18]->value(),
+                 GUI::instance()->geoContext->input[19]->value());
           break;
         case 3:
           symmetry(mode, List1, CTX.filename, what,
-                   WID->context_geometry_input[20]->value(),
-                   WID->context_geometry_input[21]->value(),
-                   WID->context_geometry_input[22]->value(),
-                   WID->context_geometry_input[23]->value());
+                   GUI::instance()->geoContext->input[20]->value(),
+                   GUI::instance()->geoContext->input[21]->value(),
+                   GUI::instance()->geoContext->input[22]->value(),
+                   GUI::instance()->geoContext->input[23]->value());
           break;
         case 4:
           extrude(List1, CTX.filename, what,
-                  WID->context_geometry_input[6]->value(),
-                  WID->context_geometry_input[7]->value(),
-                  WID->context_geometry_input[8]->value());
+                  GUI::instance()->geoContext->input[6]->value(),
+                  GUI::instance()->geoContext->input[7]->value(),
+                  GUI::instance()->geoContext->input[8]->value());
           break;
         case 5:
           protude(List1, CTX.filename, what,
-                  WID->context_geometry_input[12]->value(),
-                  WID->context_geometry_input[13]->value(),
-                  WID->context_geometry_input[14]->value(),
-                  WID->context_geometry_input[9]->value(),
-                  WID->context_geometry_input[10]->value(),
-                  WID->context_geometry_input[11]->value(),
-                  WID->context_geometry_input[15]->value());
+                  GUI::instance()->geoContext->input[12]->value(),
+                  GUI::instance()->geoContext->input[13]->value(),
+                  GUI::instance()->geoContext->input[14]->value(),
+                  GUI::instance()->geoContext->input[9]->value(),
+                  GUI::instance()->geoContext->input[10]->value(),
+                  GUI::instance()->geoContext->input[11]->value(),
+                  GUI::instance()->geoContext->input[15]->value());
           break;
         case 6:
           delet(List1, CTX.filename, what);
@@ -3418,7 +3421,7 @@ static void _action_point_line_surface_volume(int action, int mode, const char *
           add_physical(what, List1, CTX.filename);
           break;
         case 8:
-          add_charlength(List1, CTX.filename, WID->context_mesh_input[0]->value());
+          add_charlength(List1, CTX.filename, GUI::instance()->meshContext->input[0]->value());
           break;
         case 9:
           add_recosurf(List1, CTX.filename);
@@ -3429,7 +3432,7 @@ static void _action_point_line_surface_volume(int action, int mode, const char *
           break;
         }
         List_Reset(List1);
-        WID->reset_visibility();
+        GUI::instance()->resetVisibility();
         ZeroHighlight();
         if(action <= 6) SetBoundingBox();
         Draw();
@@ -3449,112 +3452,112 @@ static void _action_point_line_surface_volume(int action, int mode, const char *
 void geometry_elementary_add_translate_cb(CALLBACK_ARGS)
 {
   if(!data){
-    WID->set_context(menu_geometry_elementary_add_translate, 0);
+    GUI::instance()->menu->setContext(menu_geometry_elementary_add_translate, 0);
     return;
   }
-  WID->create_geometry_context_window(2);
+  GUI::instance()->geoContext->show(2);
   _action_point_line_surface_volume(0, 1, (const char*)data);
 }
 
 void geometry_elementary_add_rotate_cb(CALLBACK_ARGS)
 {
   if(!data){
-    WID->set_context(menu_geometry_elementary_add_rotate, 0);
+    GUI::instance()->menu->setContext(menu_geometry_elementary_add_rotate, 0);
     return;
   }
-  WID->create_geometry_context_window(3);
+  GUI::instance()->geoContext->show(3);
   _action_point_line_surface_volume(1, 1, (const char*)data);
 }
 
 void geometry_elementary_add_scale_cb(CALLBACK_ARGS)
 {
   if(!data){
-    WID->set_context(menu_geometry_elementary_add_scale, 0);
+    GUI::instance()->menu->setContext(menu_geometry_elementary_add_scale, 0);
     return;
   }
-  WID->create_geometry_context_window(4);
+  GUI::instance()->geoContext->show(4);
   _action_point_line_surface_volume(2, 1, (const char*)data);
 }
 
 void geometry_elementary_add_symmetry_cb(CALLBACK_ARGS)
 {
   if(!data){
-    WID->set_context(menu_geometry_elementary_add_symmetry, 0);
+    GUI::instance()->menu->setContext(menu_geometry_elementary_add_symmetry, 0);
     return;
   }
-  WID->create_geometry_context_window(5);
+  GUI::instance()->geoContext->show(5);
   _action_point_line_surface_volume(3, 1, (const char*)data);
 }
 
 void geometry_elementary_translate_cb(CALLBACK_ARGS)
 {
   if(!data){
-    WID->set_context(menu_geometry_elementary_translate, 0);
+    GUI::instance()->menu->setContext(menu_geometry_elementary_translate, 0);
     return;
   }
-  WID->create_geometry_context_window(2);
+  GUI::instance()->geoContext->show(2);
   _action_point_line_surface_volume(0, 0, (const char*)data);
 }
 
 void geometry_elementary_rotate_cb(CALLBACK_ARGS)
 {
   if(!data){
-    WID->set_context(menu_geometry_elementary_rotate, 0);
+    GUI::instance()->menu->setContext(menu_geometry_elementary_rotate, 0);
     return;
   }
-  WID->create_geometry_context_window(3);
+  GUI::instance()->geoContext->show(3);
   _action_point_line_surface_volume(1, 0, (const char*)data);
 }
 
 void geometry_elementary_scale_cb(CALLBACK_ARGS)
 {
   if(!data){
-    WID->set_context(menu_geometry_elementary_scale, 0);
+    GUI::instance()->menu->setContext(menu_geometry_elementary_scale, 0);
     return;
   }
-  WID->create_geometry_context_window(4);
+  GUI::instance()->geoContext->show(4);
   _action_point_line_surface_volume(2, 0, (const char*)data);
 }
 
 void geometry_elementary_symmetry_cb(CALLBACK_ARGS)
 {
   if(!data){
-    WID->set_context(menu_geometry_elementary_symmetry, 0);
+    GUI::instance()->menu->setContext(menu_geometry_elementary_symmetry, 0);
     return;
   }
-  WID->create_geometry_context_window(5);
+  GUI::instance()->geoContext->show(5);
   _action_point_line_surface_volume(3, 0, (const char*)data);
 }
 
 void geometry_elementary_extrude_cb(CALLBACK_ARGS)
 {
-  WID->set_context(menu_geometry_elementary_extrude, 0);
+  GUI::instance()->menu->setContext(menu_geometry_elementary_extrude, 0);
 }
 
 void geometry_elementary_extrude_translate_cb(CALLBACK_ARGS)
 {
   if(!data){
-    WID->set_context(menu_geometry_elementary_extrude_translate, 0);
+    GUI::instance()->menu->setContext(menu_geometry_elementary_extrude_translate, 0);
     return;
   }
-  WID->create_geometry_context_window(2);
+  GUI::instance()->geoContext->show(2);
   _action_point_line_surface_volume(4, 0, (const char*)data);
 }
 
 void geometry_elementary_extrude_rotate_cb(CALLBACK_ARGS)
 {
   if(!data){
-    WID->set_context(menu_geometry_elementary_extrude_rotate, 0);
+    GUI::instance()->menu->setContext(menu_geometry_elementary_extrude_rotate, 0);
     return;
   }
-  WID->create_geometry_context_window(3);
+  GUI::instance()->geoContext->show(3);
   _action_point_line_surface_volume(5, 0, (const char*)data);
 }
 
 void geometry_elementary_delete_cb(CALLBACK_ARGS)
 {
   if(!data){
-    WID->set_context(menu_geometry_elementary_delete, 0);
+    GUI::instance()->menu->setContext(menu_geometry_elementary_delete, 0);
     return;
   }
   _action_point_line_surface_volume(6, 0, (const char*)data);
@@ -3563,7 +3566,7 @@ void geometry_elementary_delete_cb(CALLBACK_ARGS)
 void geometry_elementary_split_cb(CALLBACK_ARGS)
 {
   if(!data){
-    WID->set_context(menu_geometry_elementary_split, 0);
+    GUI::instance()->menu->setContext(menu_geometry_elementary_split, 0);
     return;
   }
   _split_selection();
@@ -3577,14 +3580,14 @@ void geometry_elementary_coherence_cb(CALLBACK_ARGS)
 void geometry_physical_add_cb(CALLBACK_ARGS)
 {
   if(!data){
-    WID->set_context(menu_geometry_physical_add, 0);
+    GUI::instance()->menu->setContext(menu_geometry_physical_add, 0);
     return;
   }
   std::string str((const char*)data);
   if(str == "Point")
-    WID->call_for_solver_plugin(0);
+    GUI::instance()->callForSolverPlugin(0);
   else if(str == "Line")
-    WID->call_for_solver_plugin(1);
+    GUI::instance()->callForSolverPlugin(1);
 
   _action_point_line_surface_volume(7, 0, str.c_str());
 }
@@ -3609,7 +3612,7 @@ void mesh_save_cb(CALLBACK_ARGS)
 
 void mesh_define_cb(CALLBACK_ARGS)
 {
-  WID->set_context(menu_mesh_define, 0);
+  GUI::instance()->menu->setContext(menu_mesh_define, 0);
 }
 
 void mesh_1d_cb(CALLBACK_ARGS)
@@ -3635,7 +3638,7 @@ void mesh_3d_cb(CALLBACK_ARGS)
 
 void mesh_delete_cb(CALLBACK_ARGS)
 {
-  WID->set_context(menu_mesh_delete, 0);
+  GUI::instance()->menu->setContext(menu_mesh_delete, 0);
 }
 
 void mesh_delete_parts_cb(CALLBACK_ARGS)
@@ -3814,7 +3817,7 @@ void mesh_inspect_cb(CALLBACK_ARGS)
         Msg::Direct("  Disto: %g", elements[0]->distoShapeMeasure());
         CTX.mesh.changed = ENT_ALL;
         Draw();
-        WID->create_message_window();
+        GUI::instance()->messages->show();
       }
     }
     if(ib == 'q') {
@@ -3879,9 +3882,7 @@ void mesh_optimize_netgen_cb(CALLBACK_ARGS)
 
 void mesh_partition_cb(CALLBACK_ARGS)
 {
-#if defined(HAVE_METIS) || defined(HAVE_CHACO)
   partition_dialog();
-#endif
 }
 
 void mesh_define_length_cb(CALLBACK_ARGS)
@@ -3896,7 +3897,7 @@ void mesh_define_recombine_cb(CALLBACK_ARGS)
 
 void mesh_define_transfinite_cb(CALLBACK_ARGS)
 {
-  WID->set_context(menu_mesh_define_transfinite, 0);
+  GUI::instance()->menu->setContext(menu_mesh_define_transfinite, 0);
 }
 
 static void _add_transfinite(int dim)
@@ -3945,9 +3946,9 @@ static void _add_transfinite(int dim)
       if(dim == 1) {
         if(p.size())
           add_trsfline(p, CTX.filename,
-                       WID->context_mesh_choice[0]->text(),
-                       WID->context_mesh_input[2]->value(),
-                       WID->context_mesh_input[1]->value());
+                       GUI::instance()->meshContext->choice[0]->text(),
+                       GUI::instance()->meshContext->input[2]->value(),
+                       GUI::instance()->meshContext->input[1]->value());
       }
       ZeroHighlight();
       Draw();
@@ -4019,7 +4020,7 @@ static void _add_transfinite(int dim)
             case 2:
               if(p.size() == 0 + 1 || p.size() == 3 + 1 || p.size() == 4 + 1)
                 add_trsfsurf(p, CTX.filename,
-                             WID->context_mesh_choice[1]->text());
+                             GUI::instance()->meshContext->choice[1]->text());
               else
                 Msg::Error("Wrong number of points for transfinite surface");
               break;
@@ -4052,13 +4053,13 @@ stopall:
 
 void mesh_define_transfinite_line_cb(CALLBACK_ARGS)
 {
-  WID->create_mesh_context_window(1);
+  GUI::instance()->meshContext->show(1);
   _add_transfinite(1);
 }
 
 void mesh_define_transfinite_surface_cb(CALLBACK_ARGS)
 {
-  WID->create_mesh_context_window(2);
+  GUI::instance()->meshContext->show(2);
   _add_transfinite(2);
 }
 
@@ -4071,11 +4072,11 @@ void mesh_define_transfinite_volume_cb(CALLBACK_ARGS)
 
 void solver_cb(CALLBACK_ARGS)
 {
-  static int init = 0, first[MAXSOLVERS];
+  static int init = 0, first[MAX_NUM_SOLVERS];
   int num = (int)(long)data;
 
   if(!init) {
-    for(int i = 0; i < MAXSOLVERS; i++)
+    for(int i = 0; i < MAX_NUM_SOLVERS; i++)
       first[i] = 1;
     init = 1;
   }
@@ -4085,17 +4086,17 @@ void solver_cb(CALLBACK_ARGS)
     first[num] = 0;
     strcpy(file, CTX.no_ext_filename);
     strcat(file, SINFO[num].extension);
-    WID->solver[num].input[0]->value(file);
+    GUI::instance()->solver[num]->input[0]->value(file);
   }
   if(SINFO[num].nboptions) {
-    std::string file = FixWindowsPath(WID->solver[num].input[0]->value());
+    std::string file = FixWindowsPath(GUI::instance()->solver[num]->input[0]->value());
     char tmp[256], tmp2[256];
     sprintf(tmp, "\"%s\"", file.c_str());
     sprintf(tmp2, SINFO[num].name_command, tmp);
     sprintf(tmp, "%s %s", SINFO[num].option_command, tmp2);
     Solver(num, tmp);
   }
-  WID->create_solver_window(num);
+  GUI::instance()->solver[num]->win->show();
 }
 
 void solver_file_open_cb(CALLBACK_ARGS)
@@ -4107,7 +4108,7 @@ void solver_file_open_cb(CALLBACK_ARGS)
   // We allow to create the .pro file... Or should we add a "New file"
   // button?
   if(file_chooser(0, 0, "Choose", tmp)) {
-    WID->solver[num].input[0]->value(file_chooser_get_name(1).c_str());
+    GUI::instance()->solver[num]->input[0]->value(file_chooser_get_name(1).c_str());
     if(SINFO[num].nboptions) {
       std::string file = FixWindowsPath(file_chooser_get_name(1).c_str());
       sprintf(tmp, "\"%s\"", file.c_str());
@@ -4122,7 +4123,7 @@ void solver_file_edit_cb(CALLBACK_ARGS)
 {
   int num = (int)(long)data;
   std::string prog = FixWindowsPath(CTX.editor);
-  std::string file = FixWindowsPath(WID->solver[num].input[0]->value());
+  std::string file = FixWindowsPath(GUI::instance()->solver[num]->input[0]->value());
   char cmd[1024];
   _replace_multi_format(prog.c_str(), file.c_str(), cmd);
   SystemCall(cmd);
@@ -4132,7 +4133,7 @@ void solver_choose_mesh_cb(CALLBACK_ARGS)
 {
   int num = (int)(long)data;
   if(file_chooser(0, 0, "Choose", "*"))
-    WID->solver[num].input[1]->value(file_chooser_get_name(1).c_str());
+    GUI::instance()->solver[num]->input[1]->value(file_chooser_get_name(1).c_str());
 }
 
 int nbs(char *str)
@@ -4155,10 +4156,10 @@ void solver_command_cb(CALLBACK_ARGS)
   int i, usedopts = 0;
 
   if(SINFO[num].popup_messages)
-    WID->create_message_window(true);
+    GUI::instance()->messages->show(true);
 
-  if(strlen(WID->solver[num].input[1]->value())) {
-    std::string m = FixWindowsPath(WID->solver[num].input[1]->value());
+  if(strlen(GUI::instance()->solver[num]->input[1]->value())) {
+    std::string m = FixWindowsPath(GUI::instance()->solver[num]->input[1]->value());
     sprintf(tmp, "\"%s\"", m.c_str());
     sprintf(mesh, SINFO[num].mesh_command, tmp);
   }
@@ -4174,13 +4175,13 @@ void solver_command_cb(CALLBACK_ARGS)
       return;
     }
     sprintf(command, SINFO[num].button_command[idx],
-            SINFO[num].option[usedopts][WID->solver[num].choice[usedopts]->value()]);
+            SINFO[num].option[usedopts][GUI::instance()->solver[num]->choice[usedopts]->value()]);
   }
   else {
     strcpy(command, SINFO[num].button_command[idx]);
   }
 
-  std::string c = FixWindowsPath(WID->solver[num].input[0]->value());
+  std::string c = FixWindowsPath(GUI::instance()->solver[num]->input[0]->value());
   sprintf(arg, "\"%s\"", c.c_str());
   sprintf(tmp, SINFO[num].name_command, arg);
   sprintf(arg, "%s %s %s", tmp, mesh, command);
@@ -4207,7 +4208,7 @@ void solver_choose_executable_cb(CALLBACK_ARGS)
                   "*"
 #endif
                   )){
-    WID->solver[num].input[2]->value(file_chooser_get_name(1).c_str());
+    GUI::instance()->solver[num]->input[2]->value(file_chooser_get_name(1).c_str());
     solver_ok_cb(w, data);
   }
 }
@@ -4215,12 +4216,12 @@ void solver_choose_executable_cb(CALLBACK_ARGS)
 void solver_ok_cb(CALLBACK_ARGS)
 {
   int retry = 0, num = (int)(long)data;
-  opt_solver_popup_messages(num, GMSH_SET, WID->solver[num].butt[0]->value());
-  opt_solver_merge_views(num, GMSH_SET, WID->solver[num].butt[1]->value());
-  opt_solver_client_server(num, GMSH_SET, WID->solver[num].butt[2]->value());
-  if(strcmp(opt_solver_executable(num, GMSH_GET, NULL), WID->solver[num].input[2]->value()))
+  opt_solver_popup_messages(num, GMSH_SET, GUI::instance()->solver[num]->butt[0]->value());
+  opt_solver_merge_views(num, GMSH_SET, GUI::instance()->solver[num]->butt[1]->value());
+  opt_solver_client_server(num, GMSH_SET, GUI::instance()->solver[num]->butt[2]->value());
+  if(strcmp(opt_solver_executable(num, GMSH_GET, NULL), GUI::instance()->solver[num]->input[2]->value()))
     retry = 1;
-  opt_solver_executable(num, GMSH_SET, WID->solver[num].input[2]->value());
+  opt_solver_executable(num, GMSH_SET, GUI::instance()->solver[num]->input[2]->value());
   if(retry)
     solver_cb(NULL, data);
 }
@@ -4231,7 +4232,7 @@ void view_toggle_cb(CALLBACK_ARGS)
 {
   int num = (int)(long)data;
   opt_view_visible(num, GMSH_SET,
-                   WID->m_toggle_butt[num]->value());
+                   GUI::instance()->menu->toggle[num]->value());
   Draw();
 }
 
@@ -4261,7 +4262,7 @@ static void _view_reload(int index)
       if(p->getOptions()->TimeStep > p->getData()->getNumTimeSteps() - 1)
         p->getOptions()->TimeStep = 0;
       p->setChanged(true);
-      WID->update_views();
+      GUI::instance()->updateViews();
     }
   }
 }
@@ -4292,7 +4293,7 @@ void view_remove_other_cb(CALLBACK_ARGS)
   if(PView::list.empty()) return;
   for(int i = PView::list.size() - 1; i >= 0; i--)
     if(i != (long)data) delete PView::list[i];
-  WID->update_views();
+  GUI::instance()->updateViews();
   Draw();
 }
 
@@ -4300,7 +4301,7 @@ void view_remove_all_cb(CALLBACK_ARGS)
 {
   if(PView::list.empty()) return;
   while(PView::list.size()) delete PView::list[0];
-  WID->update_views();
+  GUI::instance()->updateViews();
   Draw();
 }
 
@@ -4309,7 +4310,7 @@ void view_remove_visible_cb(CALLBACK_ARGS)
   if(PView::list.empty()) return;
   for(int i = PView::list.size() - 1; i >= 0; i--)
     if(opt_view_visible(i, GMSH_GET, 0)) delete PView::list[i];
-  WID->update_views();
+  GUI::instance()->updateViews();
   Draw();
 }
 
@@ -4318,7 +4319,7 @@ void view_remove_invisible_cb(CALLBACK_ARGS)
   if(PView::list.empty()) return;
   for(int i = PView::list.size() - 1; i >= 0; i--)
     if(!opt_view_visible(i, GMSH_GET, 0)) delete PView::list[i];
-  WID->update_views();
+  GUI::instance()->updateViews();
   Draw();
 }
 
@@ -4327,20 +4328,20 @@ void view_remove_empty_cb(CALLBACK_ARGS)
   if(PView::list.empty()) return;
   for(int i = PView::list.size() - 1; i >= 0; i--)
     if(PView::list[i]->getData()->empty()) delete PView::list[i];
-  WID->update_views();
+  GUI::instance()->updateViews();
   Draw();
 }
 
 void view_remove_cb(CALLBACK_ARGS)
 {
   delete PView::list[(int)(long)data];
-  WID->update_views();
+  GUI::instance()->updateViews();
   Draw();
 }
 
-static void _view_save_as(int view_num, const char *title, int format)
+static void _view_save_as(int index, const char *title, int format)
 {
-  PView *view = PView::list[view_num];
+  PView *view = PView::list[index];
   
  test:
   if(file_chooser(0, 1, title, "*", view->getData()->getFileName().c_str())){
@@ -4393,56 +4394,56 @@ void view_save_med_cb(CALLBACK_ARGS)
 void view_alias_cb(CALLBACK_ARGS)
 {
   new PView(PView::list[(int)(long)data], false);
-  WID->update_views();
+  GUI::instance()->updateViews();
   Draw();
 }
 
 void view_alias_with_options_cb(CALLBACK_ARGS)
 {
   new PView(PView::list[(int)(long)data], true);
-  WID->update_views();
+  GUI::instance()->updateViews();
   Draw();
 }
 
 void view_combine_space_all_cb(CALLBACK_ARGS)
 {
   PView::combine(false, 1, CTX.post.combine_remove_orig);
-  WID->update_views();
+  GUI::instance()->updateViews();
   Draw();
 }
 
 void view_combine_space_visible_cb(CALLBACK_ARGS)
 {
   PView::combine(false, 0, CTX.post.combine_remove_orig);
-  WID->update_views();
+  GUI::instance()->updateViews();
   Draw();
 }
 
 void view_combine_space_by_name_cb(CALLBACK_ARGS)
 {
   PView::combine(false, 2, CTX.post.combine_remove_orig);
-  WID->update_views();
+  GUI::instance()->updateViews();
   Draw();
 }
 
 void view_combine_time_all_cb(CALLBACK_ARGS)
 {
   PView::combine(true, 1, CTX.post.combine_remove_orig);
-  WID->update_views();
+  GUI::instance()->updateViews();
   Draw();
 }
 
 void view_combine_time_visible_cb(CALLBACK_ARGS)
 {
   PView::combine(true, 0, CTX.post.combine_remove_orig);
-  WID->update_views();
+  GUI::instance()->updateViews();
   Draw();
 }
 
 void view_combine_time_by_name_cb(CALLBACK_ARGS)
 {
   PView::combine(true, 2, CTX.post.combine_remove_orig);
-  WID->update_views();
+  GUI::instance()->updateViews();
   Draw();
 }
 
@@ -4465,55 +4466,55 @@ void view_applybgmesh_cb(CALLBACK_ARGS)
 
 void view_plugin_cb(CALLBACK_ARGS)
 {
-  WID->create_plugin_window((int)(long)data);
+  GUI::instance()->plugins->show((int)(long)data);
 }
 
 void view_field_cb(CALLBACK_ARGS)
 {
-  WID->field_window->show();
-  WID->edit_field(NULL);
+  GUI::instance()->fields->win->show();
+  GUI::instance()->fields->editField(NULL);
 }
 
 void view_field_delete_cb(CALLBACK_ARGS)
 {
-  Field *f=(Field*)WID->field_editor_group->user_data();
+  Field *f = (Field*)GUI::instance()->fields->editor_group->user_data();
   delete_field(f->id, CTX.filename);
-  WID->edit_field(NULL);
+  GUI::instance()->fields->editField(NULL);
 }
 
 void view_field_new_cb(CALLBACK_ARGS)
 {
   Fl_Menu_Button* mb = ((Fl_Menu_Button*)w);
-  FieldManager *fields=GModel::current()->getFields();
+  FieldManager *fields = GModel::current()->getFields();
   int id = fields->new_id();
   add_field(id, mb->text(), CTX.filename);
-  WID->edit_field((*fields)[id]);
+  GUI::instance()->fields->editField((*fields)[id]);
 }
 
 void view_field_apply_cb(CALLBACK_ARGS)
 {
-  WID->save_field_options();
+  GUI::instance()->fields->saveFieldOptions();
 }
 
 void view_field_revert_cb(CALLBACK_ARGS)
 {
-  WID->load_field_options();
+  GUI::instance()->fields->loadFieldOptions();
 }
 
 void view_field_browser_cb(CALLBACK_ARGS)
 {
-  int selected = WID->field_browser->value();
+  int selected = GUI::instance()->fields->browser->value();
   if(!selected){
-    WID->edit_field(NULL);
+    GUI::instance()->fields->editField(NULL);
   }
-  Field *f = (Field*)WID->field_browser->data(selected);
-  WID->edit_field(f);
+  Field *f = (Field*)GUI::instance()->fields->browser->data(selected);
+  GUI::instance()->fields->editField(f);
 }
 
 void view_field_put_on_view_cb(CALLBACK_ARGS)
 {
   Fl_Menu_Button* mb = ((Fl_Menu_Button*)w);
-  Field *field = (Field*)WID->field_editor_group->user_data();
+  Field *field = (Field*)GUI::instance()->fields->editor_group->user_data();
   int iView;
   if(sscanf(mb->text(), "View [%i]", &iView)){
     if(iView < (int)PView::list.size()){
@@ -4522,14 +4523,15 @@ void view_field_put_on_view_cb(CALLBACK_ARGS)
   }
   else{
     field->put_on_new_view();
-    WID->update_views();
+    GUI::instance()->updateViews();
   }
   Draw();
 }
 
-void view_field_select_file_cb(CALLBACK_ARGS){
-  Fl_Input *input=(Fl_Input*)data;
-  int ret=file_chooser(0,0,"File selection","",input->value());
+void view_field_select_file_cb(CALLBACK_ARGS)
+{
+  Fl_Input *input = (Fl_Input*)data;
+  int ret = file_chooser(0, 0, "File selection", "", input->value());
   if(ret){
     input->value(file_chooser_get_name(0).c_str());
     input->set_changed();
@@ -4585,9 +4587,9 @@ void view_plugin_browser_cb(CALLBACK_ARGS)
 {
   // get selected plugin
   GMSH_Plugin *p = 0;
-  for(int i = 1; i <= WID->plugin_browser->size(); i++) {
-    if(WID->plugin_browser->selected(i)) {
-      p = (GMSH_Plugin*)WID->plugin_browser->data(i);
+  for(int i = 1; i <= GUI::instance()->plugins->browser->size(); i++) {
+    if(GUI::instance()->plugins->browser->selected(i)) {
+      p = (GMSH_Plugin*)GUI::instance()->plugins->browser->data(i);
       break;
     }
   }
@@ -4595,8 +4597,8 @@ void view_plugin_browser_cb(CALLBACK_ARGS)
 
   // get first first selected view
   int iView = -1;
-  for(int i = 1; i <= WID->plugin_view_browser->size(); i++) {
-    if(WID->plugin_view_browser->selected(i)) {
+  for(int i = 1; i <= GUI::instance()->plugins->view_browser->size(); i++) {
+    if(GUI::instance()->plugins->view_browser->selected(i)) {
       iView = i - 1;
       break;
     }
@@ -4630,8 +4632,8 @@ void view_plugin_browser_cb(CALLBACK_ARGS)
   }
 
   // hide all plugin groups except the selected one
-  for(int i = 1; i <= WID->plugin_browser->size(); i++)
-    ((GMSH_Plugin*)WID->plugin_browser->data(i))->dialogBox->group->hide();
+  for(int i = 1; i <= GUI::instance()->plugins->browser->size(); i++)
+    ((GMSH_Plugin*)GUI::instance()->plugins->browser->data(i))->dialogBox->group->hide();
   p->dialogBox->group->show();
 }
 
@@ -4639,9 +4641,9 @@ void view_plugin_run_cb(CALLBACK_ARGS)
 {
   // get selected plugin
   GMSH_Post_Plugin *p = 0;
-  for(int i = 1; i <= WID->plugin_browser->size(); i++) {
-    if(WID->plugin_browser->selected(i)) {
-      p = (GMSH_Post_Plugin*)WID->plugin_browser->data(i);
+  for(int i = 1; i <= GUI::instance()->plugins->browser->size(); i++) {
+    if(GUI::instance()->plugins->browser->selected(i)) {
+      p = (GMSH_Post_Plugin*)GUI::instance()->plugins->browser->data(i);
       break;
     }
   }
@@ -4664,8 +4666,8 @@ void view_plugin_run_cb(CALLBACK_ARGS)
 
   // run on all selected views
   bool no_view_selected = true;
-  for(int i = 1; i <= WID->plugin_view_browser->size(); i++) {
-    if(WID->plugin_view_browser->selected(i)) {
+  for(int i = 1; i <= GUI::instance()->plugins->view_browser->size(); i++) {
+    if(GUI::instance()->plugins->view_browser->selected(i)) {
       no_view_selected = false;
       try{
         if(i - 1 >= 0 && i - 1 < (int)PView::list.size())
@@ -4684,14 +4686,14 @@ void view_plugin_run_cb(CALLBACK_ARGS)
     p->execute(0);
   }
 
-  WID->update_views();
+  GUI::instance()->updateViews();
   CTX.post.plugin_draw_function = NULL;
   Draw();
 }
 
 void view_plugin_cancel_cb(CALLBACK_ARGS)
 {
-  WID->plugin_window->hide();
+  GUI::instance()->plugins->win->hide();
   CTX.post.plugin_draw_function = NULL;
   Draw();
 }
@@ -4700,19 +4702,19 @@ void view_plugin_cancel_cb(CALLBACK_ARGS)
 
 void con_geometry_define_parameter_cb(CALLBACK_ARGS)
 {
-  add_param(WID->context_geometry_input[0]->value(),
-            WID->context_geometry_input[1]->value(), CTX.filename);
-  WID->reset_visibility();
+  add_param(GUI::instance()->geoContext->input[0]->value(),
+            GUI::instance()->geoContext->input[1]->value(), CTX.filename);
+  GUI::instance()->resetVisibility();
 }
 
 void con_geometry_define_point_cb(CALLBACK_ARGS)
 {
   add_point(CTX.filename,
-            WID->context_geometry_input[2]->value(),
-            WID->context_geometry_input[3]->value(),
-            WID->context_geometry_input[4]->value(),
-            WID->context_geometry_input[5]->value());
-  WID->reset_visibility();
+            GUI::instance()->geoContext->input[2]->value(),
+            GUI::instance()->geoContext->input[3]->value(),
+            GUI::instance()->geoContext->input[4]->value(),
+            GUI::instance()->geoContext->input[5]->value());
+  GUI::instance()->resetVisibility();
   ZeroHighlight();
   SetBoundingBox();
   Draw();
@@ -4720,7 +4722,7 @@ void con_geometry_define_point_cb(CALLBACK_ARGS)
 
 void con_geometry_snap_cb(CALLBACK_ARGS)
 {
-  CTX.geom.snap[0] = WID->context_geometry_value[0]->value();
-  CTX.geom.snap[1] = WID->context_geometry_value[1]->value();
-  CTX.geom.snap[2] = WID->context_geometry_value[2]->value();
+  CTX.geom.snap[0] = GUI::instance()->geoContext->value[0]->value();
+  CTX.geom.snap[1] = GUI::instance()->geoContext->value[1]->value();
+  CTX.geom.snap[2] = GUI::instance()->geoContext->value[2]->value();
 }
diff --git a/Fltk/Callbacks.h b/Fltk/Callbacks.h
index f1b9ffad22b7c47791b64b41e8c85088e80b8ceb..4dcd3126149a8ab9f40c4c8f7238ea97196a9f27 100644
--- a/Fltk/Callbacks.h
+++ b/Fltk/Callbacks.h
@@ -11,7 +11,6 @@
 #define CALLBACK_ARGS   Fl_Widget* w, void* data
 
 void ManualPlay(int time, int step);
-int SetGlobalShortcut(int event);
 
 // Common callbacks
 
diff --git a/Fltk/Colorbar_Window.h b/Fltk/Colorbar_Window.h
deleted file mode 100644
index 3a25d6636d307e97c284e1d254d6618929330f55..0000000000000000000000000000000000000000
--- a/Fltk/Colorbar_Window.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
-//
-// See the LICENSE.txt file for license information. Please report all
-// bugs and problems to <gmsh@geuz.org>.
-
-#ifndef _COLORBAR_WINDOW_H
-#define _COLORBAR_WINDOW_H
-
-#include "GmshUI.h"
-#include "ColorTable.h"
-
-#include <FL/Fl_Window.H>
-
-class Colorbar_Window : public Fl_Window {
-  void draw();
-  int  handle(int);
-
-  // new
-  int  x_to_index(int x);
-  int  index_to_x(int index);
-  int  y_to_intensity(int y);
-  int  intensity_to_y(int intensity);
-  void redraw_range(int a, int b);
-  void redraw_marker();
-
-  int font_height, marker_height, wedge_height;
-  const char *label;
-
-  double minval, maxval;  // min and max data values
-  int wedge_y;     // top coord of color wedge
-  int marker_y;    // top coord of marker arrow
-  int label_y;     // y coord of text labels
-  int help_flag;   // if nonzero, print help message
-  int marker_pos;  // position of marker as index into table
-  
-  GmshColorTable *ct; // pointer to the color table (allocated in the view)
-  bool *viewchanged;   // pointer to changed bit in view
-  Fl_Color color_bg;
-
-public:
-  Colorbar_Window(int x, int y, int w, int h, const char *l=0);
-  void update(const char *name, double min, double max, GmshColorTable *ct,
-              bool *changed);
-};
-
-#endif
diff --git a/Fltk/Draw.cpp b/Fltk/Draw.cpp
index 6de266aef87d49d4c09327e430d003668789f772..5582a29b4a1fb2b744035b430632d7feb2055cc6 100644
--- a/Fltk/Draw.cpp
+++ b/Fltk/Draw.cpp
@@ -3,8 +3,10 @@
 // See the LICENSE.txt file for license information. Please report all
 // bugs and problems to <gmsh@geuz.org>.
 
+#include <FL/gl.h>
+#include <FL/glu.h>
 #include "GUI.h"
-#include "GmshUI.h"
+#include "graphicWindow.h"
 #include "GmshDefines.h"
 #include "Draw.h"
 #include "StringUtils.h"
@@ -12,12 +14,11 @@
 #include "Context.h"
 
 extern Context_T CTX;
-extern GUI *WID;
 
 void SetOpenglContext()
 {
-  if(!WID) return;
-  WID->make_opengl_current();
+  if(!GUI::available()) return;
+  GUI::instance()->graph[0]->gl->make_current();
 }
 
 void ClearOpengl()
@@ -30,15 +31,17 @@ void ClearOpengl()
 
 void Draw()
 {
-  if(!WID) return;
-  WID->redraw_opengl();
+  if(!GUI::available()) return;
+  GUI::instance()->graph[0]->gl->make_current();
+  GUI::instance()->graph[0]->gl->redraw();
+  GUI::instance()->check();
 }
 
 void Draw2d3d()
 {
-  if(!WID) return;
-  WID->g_opengl_window->getDrawContext()->draw3d();
-  WID->g_opengl_window->getDrawContext()->draw2d();
+  if(!GUI::available()) return;
+  GUI::instance()->graph[0]->gl->getDrawContext()->draw3d();
+  GUI::instance()->graph[0]->gl->getDrawContext()->draw2d();
 }
 
 void DrawPlugin(void (*draw)(void *context))
@@ -50,8 +53,7 @@ void DrawPlugin(void (*draw)(void *context))
     CTX.post.draw = 0;
     CTX.mesh.draw = 0;
   }
-  if(!CTX.batch) 
-    Draw();
+  Draw();
   // this is reset in each plugin run/cancel callback:
   // CTX.post.plugin_draw_function = NULL;
   CTX.draw_bbox = old;
@@ -160,33 +162,33 @@ void Draw_String(std::string s, double style)
 
 void Draw_OnScreenMessages()
 {
-  if(!WID) return;
+  if(!GUI::available()) return;
 
   glColor4ubv((GLubyte *) & CTX.color.text);
   gl_font(CTX.gl_font_enum, CTX.gl_fontsize);
   double h = gl_height();
   
-  drawContext *ctx = WID->g_opengl_window->getDrawContext();
+  drawContext *ctx = GUI::instance()->graph[0]->gl->getDrawContext();
   
-  if(strlen(WID->onscreen_buffer[0])){
-    double w = gl_width(WID->onscreen_buffer[0]);
+  if(strlen(GUI::instance()->onscreen_buffer[0])){
+    double w = gl_width(GUI::instance()->onscreen_buffer[0]);
     glRasterPos2d(ctx->viewport[2] / 2. - w / 2., 
                   ctx->viewport[3] - 1.2 * h);
-    gl_draw(WID->onscreen_buffer[0]);
+    gl_draw(GUI::instance()->onscreen_buffer[0]);
   }
-  if(strlen(WID->onscreen_buffer[1])){
-    double w = gl_width(WID->onscreen_buffer[1]);
+  if(strlen(GUI::instance()->onscreen_buffer[1])){
+    double w = gl_width(GUI::instance()->onscreen_buffer[1]);
     glRasterPos2d(ctx->viewport[2] / 2. - w / 2.,
                   ctx->viewport[3] - 2.4 * h);
-    gl_draw(WID->onscreen_buffer[1]);
+    gl_draw(GUI::instance()->onscreen_buffer[1]);
   }
 }
 
 void GetStoredViewport(int viewport[4])
 {
-  if(!WID) return;
+  if(!GUI::available()) return;
   for(int i = 0; i < 4; i++)
-    viewport[i] = WID->g_opengl_window->getDrawContext()->viewport[i];
+    viewport[i] = GUI::instance()->graph[0]->gl->getDrawContext()->viewport[i];
 }
 
 void Viewport2World(double win[3], double xyz[3])
diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp
index 4af972db829167abdad5cbda87c38cd0c1e22fe4..cf329f40930c1d68ceaed4dace703aab28389117 100644
--- a/Fltk/GUI.cpp
+++ b/Fltk/GUI.cpp
@@ -3,670 +3,318 @@
 // See the LICENSE.txt file for license information. Please report all
 // bugs and problems to <gmsh@geuz.org>.
 
-#include <string>
-#include <sstream>
-#include "GmshUI.h"
+#include <FL/Fl.H>
+#include <FL/Fl_Tooltip.H>
+#include <FL/Fl_Shared_Image.H>
+#include <FL/Fl_File_Icon.H>
+#include <FL/x.H>
+#include "GUI.h"
+#include "graphicWindow.h"
+#include "menuWindow.h"
+#include "optionWindow.h"
+#include "fieldWindow.h"
+#include "pluginWindow.h"
+#include "statisticsWindow.h"
+#include "visibilityWindow.h"
+#include "clippingWindow.h"
+#include "messageWindow.h"
+#include "manipWindow.h"
+#include "contextWindow.h"
+#include "solverWindow.h"
+#include "aboutWindow.h"
+#include "colorbarWindow.h"
+#include "popupButton.h"
+#include "fileDialogs.h"
 #include "GmshDefines.h"
 #include "GmshMessage.h"
-#include "Numeric.h"
-#include "Context.h"
-#include "Options.h"
-#include "Draw.h"
-#include "GUI.h"
-#include "Callbacks.h"
-#include "Win32Icon.h"
-#include "OpenFile.h"
-#include "CommandLine.h"
-#include "Generator.h"
-#include "Solvers.h"
-#include "PluginManager.h"
-#include "Plugin.h"
-#include "Shortcut_Window.h"
+#include "GModel.h"
 #include "PView.h"
-#include "PViewOptions.h"
-#include "PViewData.h"
+#include "Solvers.h"
 #include "Field.h"
-#include "GModel.h"
-#include "GeoStringInterface.h"
-#include "StringUtils.h"
-
-#define NB_BUTT_SCROLL 25
-#define NB_HISTORY_MAX 1000
-
-#define IW (10*fontsize)  // input field width
-#define BB (7*fontsize)   // width of a button with internal label
-#define BH (2*fontsize+1) // button height
-#define WB (7)            // window border
+#include "Plugin.h"
+#include "PluginManager.h"
+#include "Callbacks.h"
+#include "OpenFile.h"
+#include "Options.h"
+#include "Context.h"
 
 extern Context_T CTX;
 
-extern StringXColor GeneralOptions_Color[] ;
-extern StringXColor GeometryOptions_Color[] ;
-extern StringXColor MeshOptions_Color[] ;
-extern StringXColor SolverOptions_Color[] ;
-extern StringXColor PostProcessingOptions_Color[] ;
-extern StringXColor ViewOptions_Color[] ;
-extern StringXColor PrintOptions_Color[] ;
-
-// Definition of the static menus (we cannot use the 'g', 'm' 's' and
-// 'p' mnemonics since they are already defined as global shortcuts)
-
-Fl_Menu_Item m_menubar_table[] = {
-  {"&File", 0, 0, 0, FL_SUBMENU},
-    {"&New...",     FL_CTRL+'n', (Fl_Callback *)file_new_cb, 0},
-    {"&Open...",    FL_CTRL+'o', (Fl_Callback *)file_open_cb, 0},
-    {"M&erge...",   FL_CTRL+FL_SHIFT+'o', (Fl_Callback *)file_merge_cb, 0, FL_MENU_DIVIDER},
-    {"&Rename...",  FL_CTRL+'r', (Fl_Callback *)file_rename_cb, 0},
-    {"Save &As...", FL_CTRL+'s', (Fl_Callback *)file_save_as_cb, 0},
-    {"Sa&ve Mesh",  FL_CTRL+FL_SHIFT+'s', (Fl_Callback *)mesh_save_cb, 0, FL_MENU_DIVIDER},
-    {"&Quit",       FL_CTRL+'q', (Fl_Callback *)file_quit_cb, 0},
-    {0},
-  {"&Tools", 0, 0, 0, FL_SUBMENU},
-    {"&Options...",      FL_CTRL+FL_SHIFT+'n', (Fl_Callback *)options_cb, 0},
-    {"Pl&ugins...",      FL_CTRL+FL_SHIFT+'u', (Fl_Callback *)view_plugin_cb, (void*)(-1)},
-    {"&Visibility",      FL_CTRL+FL_SHIFT+'v', (Fl_Callback *)visibility_cb, 0},
-    {"&Clipping",        FL_CTRL+FL_SHIFT+'c', (Fl_Callback *)clip_cb, 0},
-    {"&Manipulator",     FL_CTRL+FL_SHIFT+'m', (Fl_Callback *)manip_cb, 0, FL_MENU_DIVIDER},
-    {"S&tatistics",      FL_CTRL+'i', (Fl_Callback *)statistics_cb, 0},
-    {"M&essage Console", FL_CTRL+'l', (Fl_Callback *)message_cb, 0},
-    {0},
-  {"&Help", 0, 0, 0, FL_SUBMENU},
-    {"On&line Documentation", 0, (Fl_Callback *)help_online_cb, 0, FL_MENU_DIVIDER},
-    {"M&ouse Actions",        0, (Fl_Callback *)help_mouse_cb, 0},
-    {"&Keyboard Shortcuts",   0, (Fl_Callback *)help_short_cb, 0},
-    {"C&ommand Line Options", 0, (Fl_Callback *)help_command_line_cb, 0},
-    {"&Current Options",      0, (Fl_Callback *)status_xyz1p_cb, (void*)"?", FL_MENU_DIVIDER},
-    {"&About Gmsh...",        0, (Fl_Callback *)help_about_cb, 0},
-    {0},
-  {0}
-};
+static int SetGlobalShortcut(int event)
+{
+  return GUI::instance()->testGlobalShortcuts(event);
+}
 
-// Alternative items for the MacOS system menu bar (removed '&'
-// shortcuts: they would cause spurious menu items to appear on the
-// menu window; removed File->Quit)
+GUI::GUI(int argc, char **argv)
+{
+  // initialize on-screen message buffer
+  onscreen_buffer[0][0] = '\0';
+  onscreen_buffer[1][0] = '\0';
 
-#if defined(__APPLE__)
+  // initialize selection bits
+  selection = ENT_NONE;
+  try_selection = quit_selection = end_selection = 0;
+  undo_selection = invert_selection = 0;
+  for(int i = 0; i < 4; i++) try_selection_xywh[i] = 0;
 
-// random changes in fltk are driving me nuts sometimes
-#if (FL_MAJOR_VERSION == 1) && (FL_MINOR_VERSION == 1) && (FL_PATCH_VERSION <= 6)
-#undef FL_META
-#define FL_META FL_CTRL
-#endif
+  // set X display
+  if(strlen(CTX.display))
+    Fl::display(CTX.display);
 
-Fl_Menu_Item m_sys_menubar_table[] = {
-  {"File", 0, 0, 0, FL_SUBMENU},
-    {"New...",     FL_META+'n', (Fl_Callback *)file_new_cb, 0},
-    {"Open...",    FL_META+'o', (Fl_Callback *)file_open_cb, 0},
-    {"Merge...",   FL_META+FL_SHIFT+'o', (Fl_Callback *)file_merge_cb, 0, FL_MENU_DIVIDER},
-    {"Rename...",  FL_META+'r', (Fl_Callback *)file_rename_cb, 0},
-    {"Save As...", FL_META+'s', (Fl_Callback *)file_save_as_cb, 0},
-    {"Save Mesh",  FL_META+FL_SHIFT+'s', (Fl_Callback *)mesh_save_cb, 0},
-    {0},
-  {"Tools", 0, 0, 0, FL_SUBMENU},
-    {"Options...",      FL_META+FL_SHIFT+'n', (Fl_Callback *)options_cb, 0},
-    {"Plugins...",      FL_META+FL_SHIFT+'u', (Fl_Callback *)view_plugin_cb, (void*)(-1)},
-    {"Visibility",      FL_META+FL_SHIFT+'v', (Fl_Callback *)visibility_cb, 0},
-    {"Clipping",        FL_META+FL_SHIFT+'c', (Fl_Callback *)clip_cb, 0},
-    {"Manipulator",     FL_META+FL_SHIFT+'m', (Fl_Callback *)manip_cb, 0, FL_MENU_DIVIDER},
-    {"Statistics",      FL_META+'i', (Fl_Callback *)statistics_cb, 0},
-    {"Message Console", FL_META+'l', (Fl_Callback *)message_cb, 0},
-    {0},
-  {"Window", 0, 0, 0, FL_SUBMENU},
-    {"Minimize",           FL_META+'m', (Fl_Callback *)window_cb, (void*)"minimize"},
-    {"Zoom",               0, (Fl_Callback *)window_cb, (void*)"zoom", FL_MENU_DIVIDER},
-    {"Bring All to Front", 0, (Fl_Callback *)window_cb, (void*)"front"},
-    {0},
-  {"Help", 0, 0, 0, FL_SUBMENU},
-    {"Online Documentation", 0, (Fl_Callback *)help_online_cb, 0, FL_MENU_DIVIDER},
-    {"Mouse Actions",        0, (Fl_Callback *)help_mouse_cb, 0},
-    {"Keyboard Shortcuts",   0, (Fl_Callback *)help_short_cb, 0},
-    {"Command Line Options", 0, (Fl_Callback *)help_command_line_cb, 0},
-    {"Current Options",      0, (Fl_Callback *)status_xyz1p_cb, (void*)"?", FL_MENU_DIVIDER},
-    {"About Gmsh...",        0, (Fl_Callback *)help_about_cb, 0},
-    {0},
-  {0}
-};
+  // add global shortcuts
+  Fl::add_handler(SetGlobalShortcut);
 
-#endif
+  // store fontsize now: we don't want any subsequent change
+  // (e.g. when doing a 'restore options') to be taken into account
+  // in the dynamic GUI features
+  _fontsize = GetFontSize();
 
-Fl_Menu_Item m_module_table[] = {
-  {"Geometry",        'g', (Fl_Callback *)mod_geometry_cb, 0},
-  {"Mesh",            'm', (Fl_Callback *)mod_mesh_cb, 0},
-  {"Solver",          's', (Fl_Callback *)mod_solver_cb, 0},
-  {"Post-processing", 'p', (Fl_Callback *)mod_post_cb, 0},
-  {0}
-};
+  // set default font size
+  FL_NORMAL_SIZE = _fontsize;
 
-// Definition of the dynamic contexts
+  // handle themes and tooltip font size
+  if(strlen(CTX.gui_theme))
+    Fl::scheme(CTX.gui_theme);
+  Fl_Tooltip::size(_fontsize);
 
-Context_Item menu_geometry[] = {
-  {"0Geometry", NULL} ,
-  {"Elementary entities", (Fl_Callback *)geometry_elementary_cb} ,
-  {"Physical groups",     (Fl_Callback *)geometry_physical_cb} ,
-  {"Edit",                (Fl_Callback *)geometry_edit_cb} , 
-  {"Reload",              (Fl_Callback *)geometry_reload_cb} , 
-  {0}
-};  
-    Context_Item menu_geometry_elementary[] = {
-      {"0Geometry>Elementary", NULL} ,
-      {"Add",       (Fl_Callback *)geometry_elementary_add_cb} ,
-      {"Delete",    (Fl_Callback *)geometry_elementary_delete_cb, (void*)0} ,
-      {"Translate", (Fl_Callback *)geometry_elementary_translate_cb, (void*)0} ,
-      {"Rotate",    (Fl_Callback *)geometry_elementary_rotate_cb, (void*)0} ,
-      {"Split",     (Fl_Callback *)geometry_elementary_split_cb, (void*)0} ,
-      {"Scale",     (Fl_Callback *)geometry_elementary_scale_cb, (void*)0} ,
-      {"Symmetry",  (Fl_Callback *)geometry_elementary_symmetry_cb, (void*)0} ,
-      {"Extrude",   (Fl_Callback *)geometry_elementary_extrude_cb, (void*)0} ,
-      {"Coherence", (Fl_Callback *)geometry_elementary_coherence_cb} ,
-      {0} 
-    };  
-        Context_Item menu_geometry_elementary_add[] = {
-          {"0Geometry>Elementary>Add", NULL} ,
-          {"New",       (Fl_Callback *)geometry_elementary_add_new_cb, (void*)0} ,
-          {"Translate", (Fl_Callback *)geometry_elementary_add_translate_cb, (void*)0} ,
-          {"Rotate",    (Fl_Callback *)geometry_elementary_add_rotate_cb, (void*)0} ,
-          {"Scale",     (Fl_Callback *)geometry_elementary_add_scale_cb, (void*)0} ,
-          {"Symmetry",  (Fl_Callback *)geometry_elementary_add_symmetry_cb, (void*)0} ,
-          {0} 
-        };  
-            Context_Item menu_geometry_elementary_add_new[] = {
-              {"0Geometry>Elementary>Add>New", NULL} ,
-              {"Parameter",     (Fl_Callback *)geometry_elementary_add_new_cb, (void*)"Parameter"} ,
-              {"Point",         (Fl_Callback *)geometry_elementary_add_new_cb, (void*)"Point"} ,
-              {"Straight line", (Fl_Callback *)geometry_elementary_add_new_cb, (void*)"Line"} ,
-              {"Spline",        (Fl_Callback *)geometry_elementary_add_new_cb, (void*)"Spline"} ,
-              {"B-Spline",      (Fl_Callback *)geometry_elementary_add_new_cb, (void*)"BSpline"} ,
-              {"Circle arc",    (Fl_Callback *)geometry_elementary_add_new_cb, (void*)"Circle"} ,
-              {"Ellipse arc",   (Fl_Callback *)geometry_elementary_add_new_cb, (void*)"Ellipse"} ,
-              {"Plane surface", (Fl_Callback *)geometry_elementary_add_new_cb, (void*)"Plane Surface"} ,
-              {"Ruled surface", (Fl_Callback *)geometry_elementary_add_new_cb, (void*)"Ruled Surface"} ,
-              {"Volume",        (Fl_Callback *)geometry_elementary_add_new_cb, (void*)"Volume"} ,
-              {0} 
-            };  
-            Context_Item menu_geometry_elementary_add_translate[] = {
-              {"0Geometry>Elementary>Add>Translate", NULL} ,
-              {"Point",   (Fl_Callback *)geometry_elementary_add_translate_cb, (void*)"Point"} ,  
-              {"Line",    (Fl_Callback *)geometry_elementary_add_translate_cb, (void*)"Line"} ,	  
-              {"Surface", (Fl_Callback *)geometry_elementary_add_translate_cb, (void*)"Surface"} ,
-              {"Volume",  (Fl_Callback *)geometry_elementary_add_translate_cb, (void*)"Volume"} , 
-              {0} 
-            };  
-            Context_Item menu_geometry_elementary_add_rotate[] = {
-              {"0Geometry>Elementary>Add>Rotate", NULL} ,
-              {"Point",   (Fl_Callback *)geometry_elementary_add_rotate_cb, (void*)"Point"} ,  
-              {"Line",    (Fl_Callback *)geometry_elementary_add_rotate_cb, (void*)"Line"} ,	  
-              {"Surface", (Fl_Callback *)geometry_elementary_add_rotate_cb, (void*)"Surface"} ,
-              {"Volume",  (Fl_Callback *)geometry_elementary_add_rotate_cb, (void*)"Volume"} , 
-              {0} 
-            };  
-            Context_Item menu_geometry_elementary_add_scale[] = {
-              {"0Geometry>Elementary>Add>Scale", NULL} ,
-              {"Point",   (Fl_Callback *)geometry_elementary_add_scale_cb, (void*)"Point"} ,  
-              {"Line",    (Fl_Callback *)geometry_elementary_add_scale_cb, (void*)"Line"} ,	  
-              {"Surface", (Fl_Callback *)geometry_elementary_add_scale_cb, (void*)"Surface"} ,
-              {"Volume",  (Fl_Callback *)geometry_elementary_add_scale_cb, (void*)"Volume"} , 
-              {0} 
-            };  
-            Context_Item menu_geometry_elementary_add_symmetry[] = {
-              {"0Geometry>Elementary>Add>Symmetry", NULL} ,
-              {"Point",   (Fl_Callback *)geometry_elementary_add_symmetry_cb, (void*)"Point"} ,  
-              {"Line",    (Fl_Callback *)geometry_elementary_add_symmetry_cb, (void*)"Line"} ,	  
-              {"Surface", (Fl_Callback *)geometry_elementary_add_symmetry_cb, (void*)"Surface"} ,
-              {"Volume",  (Fl_Callback *)geometry_elementary_add_symmetry_cb, (void*)"Volume"} , 
-              {0} 
-            };  
-        Context_Item menu_geometry_elementary_delete[] = {
-          {"0Geometry>Elementary>Delete", NULL} ,
-          {"Point",   (Fl_Callback *)geometry_elementary_delete_cb, (void*)"Point"} ,
-          {"Line",    (Fl_Callback *)geometry_elementary_delete_cb, (void*)"Line"} ,
-          {"Surface", (Fl_Callback *)geometry_elementary_delete_cb, (void*)"Surface"} ,
-          {"Volume",  (Fl_Callback *)geometry_elementary_delete_cb, (void*)"Volume"} ,
-          {0} 
-        };  
-        Context_Item menu_geometry_elementary_split[] = {
-          {"0Geometry>Elementary>Split",NULL},
-            {"Line",(Fl_Callback *)geometry_elementary_split_cb,(void*)"Line"},
-            {0}
-        };
-        Context_Item menu_geometry_elementary_translate[] = {
-          {"0Geometry>Elementary>Translate", NULL} ,
-          {"Point",   (Fl_Callback *)geometry_elementary_translate_cb, (void*)"Point"} ,  
-          {"Line",    (Fl_Callback *)geometry_elementary_translate_cb, (void*)"Line"} ,	  
-          {"Surface", (Fl_Callback *)geometry_elementary_translate_cb, (void*)"Surface"} ,
-          {"Volume",  (Fl_Callback *)geometry_elementary_translate_cb, (void*)"Volume"} , 
-          {0} 
-        };  
-        Context_Item menu_geometry_elementary_rotate[] = {
-          {"0Geometry>Elementary>Rotate", NULL} ,
-          {"Point",   (Fl_Callback *)geometry_elementary_rotate_cb, (void*)"Point"} ,  
-          {"Line",    (Fl_Callback *)geometry_elementary_rotate_cb, (void*)"Line"} ,	  
-          {"Surface", (Fl_Callback *)geometry_elementary_rotate_cb, (void*)"Surface"} ,
-          {"Volume",  (Fl_Callback *)geometry_elementary_rotate_cb, (void*)"Volume"} , 
-          {0} 
-        };  
-        Context_Item menu_geometry_elementary_scale[] = {
-          {"0Geometry>Elementary>Scale", NULL} ,
-          {"Point",   (Fl_Callback *)geometry_elementary_scale_cb, (void*)"Point"} ,  
-          {"Line",    (Fl_Callback *)geometry_elementary_scale_cb, (void*)"Line"} ,	  
-          {"Surface", (Fl_Callback *)geometry_elementary_scale_cb, (void*)"Surface"} ,
-          {"Volume",  (Fl_Callback *)geometry_elementary_scale_cb, (void*)"Volume"} , 
-          {0} 
-        };  
-        Context_Item menu_geometry_elementary_symmetry[] = {
-          {"0Geometry>Elementary>Symmetry", NULL} ,
-          {"Point",   (Fl_Callback *)geometry_elementary_symmetry_cb, (void*)"Point"} ,  
-          {"Line",    (Fl_Callback *)geometry_elementary_symmetry_cb, (void*)"Line"} ,	  
-          {"Surface", (Fl_Callback *)geometry_elementary_symmetry_cb, (void*)"Surface"} ,
-          {"Volume",  (Fl_Callback *)geometry_elementary_symmetry_cb, (void*)"Volume"} , 
-          {0} 
-        };  
-        Context_Item menu_geometry_elementary_extrude[] = {
-          {"0Geometry>Elementary>Extrude", NULL} ,
-          {"Translate", (Fl_Callback *)geometry_elementary_extrude_translate_cb, (void*)0} ,
-          {"Rotate",    (Fl_Callback *)geometry_elementary_extrude_rotate_cb, (void*)0} ,
-          {0} 
-        };  
-            Context_Item menu_geometry_elementary_extrude_translate[] = {
-              {"0Geometry>Elementary>Extrude>Translate", NULL} ,
-              {"Point",   (Fl_Callback *)geometry_elementary_extrude_translate_cb, (void*)"Point"} ,
-              {"Line",    (Fl_Callback *)geometry_elementary_extrude_translate_cb, (void*)"Line"} ,
-              {"Surface", (Fl_Callback *)geometry_elementary_extrude_translate_cb, (void*)"Surface"} ,
-              {0} 
-            };  
-            Context_Item menu_geometry_elementary_extrude_rotate[] = {
-              {"0Geometry>Elementary>Extrude>Rotate", NULL} ,
-              {"Point",   (Fl_Callback *)geometry_elementary_extrude_rotate_cb, (void*)"Point"} ,
-              {"Line",    (Fl_Callback *)geometry_elementary_extrude_rotate_cb, (void*)"Line"} ,
-              {"Surface", (Fl_Callback *)geometry_elementary_extrude_rotate_cb, (void*)"Surface"} ,
-              {0} 
-            };  
-    Context_Item menu_geometry_physical[] = {
-      {"0Geometry>Physical", NULL} ,
-      {"Add",    (Fl_Callback *)geometry_physical_add_cb, (void*)0} ,
-      {0} 
-    };  
-        Context_Item menu_geometry_physical_add[] = {
-          {"0Geometry>Physical>Add", NULL} ,
-          {"Point",   (Fl_Callback *)geometry_physical_add_cb, (void*)"Point" } ,
-          {"Line",    (Fl_Callback *)geometry_physical_add_cb, (void*)"Line" } ,
-          {"Surface", (Fl_Callback *)geometry_physical_add_cb, (void*)"Surface" } ,
-          {"Volume",  (Fl_Callback *)geometry_physical_add_cb, (void*)"Volume" } ,
-          {0} 
-        };  
+  // register image formats not in core fltk library (jpeg/png)
+  fl_register_images();
 
-Context_Item menu_mesh[] = {
-  {"1Mesh", NULL} ,
-  {"Define",       (Fl_Callback *)mesh_define_cb} ,
-  {"Inspect",      (Fl_Callback *)mesh_inspect_cb} , 
-  {"Delete",       (Fl_Callback *)mesh_delete_cb} , 
-  {"1D",           (Fl_Callback *)mesh_1d_cb} ,
-  {"2D",           (Fl_Callback *)mesh_2d_cb} , 
-  {"3D",           (Fl_Callback *)mesh_3d_cb} , 
-  {"First order",  (Fl_Callback *)mesh_degree_cb, (void*)1 } , 
-  {"Second order", (Fl_Callback *)mesh_degree_cb, (void*)2 } , 
-  {"Refine",       (Fl_Callback *)mesh_refine_cb} ,
-  {"Optimize",     (Fl_Callback *)mesh_optimize_cb} , 
-#if defined(HAVE_NETGEN)
-  {"Optimize (Netgen)", (Fl_Callback *)mesh_optimize_netgen_cb} , 
-#endif
-#if defined(HAVE_METIS) || defined(HAVE_CHACO)
-  {"Partition", (Fl_Callback *)mesh_partition_cb} ,
-#endif
-#if defined(HAVE_FOURIER_MODEL)
-  {"Reparameterize",   (Fl_Callback *)mesh_parameterize_cb} , 
+  // load default system icons (for file browser)
+  Fl_File_Icon::load_system_icons();
+  
+  // add callback to respond to the Mac Finder (when you click on a
+  // document)
+#if defined(__APPLE__)
+  fl_open_callback(OpenProjectMacFinder);
 #endif
-  //{"Reclassify",   (Fl_Callback *)mesh_classify_cb} , 
-  {"Save",         (Fl_Callback *)mesh_save_cb} ,
-  {0} 
-};  
-    Context_Item menu_mesh_define[] = {
-      {"1Mesh>Define", NULL} ,
-      {"Fields",      (Fl_Callback *)view_field_cb},
-      {"Characteristic length", (Fl_Callback *)mesh_define_length_cb  } ,
-      {"Recombine",   (Fl_Callback *)mesh_define_recombine_cb  } ,
-      {"Transfinite", (Fl_Callback *)mesh_define_transfinite_cb  } , 
-      {0} 
-    };  
-        Context_Item menu_mesh_define_transfinite[] = {
-          {"1Mesh>Define>Transfinite", NULL} ,
-          {"Line",    (Fl_Callback *)mesh_define_transfinite_line_cb} ,
-          {"Surface", (Fl_Callback *)mesh_define_transfinite_surface_cb} ,
-          {"Volume",  (Fl_Callback *)mesh_define_transfinite_volume_cb} , 
-          {0} 
-        };  
-    Context_Item menu_mesh_delete[] = {
-      {"1Mesh>Edit>Delete", NULL} ,
-      {"Elements", (Fl_Callback *)mesh_delete_parts_cb, (void*)"elements"} ,
-      {"Lines",    (Fl_Callback *)mesh_delete_parts_cb, (void*)"lines"} ,
-      {"Surfaces", (Fl_Callback *)mesh_delete_parts_cb, (void*)"surfaces"} ,
-      {"Volumes",  (Fl_Callback *)mesh_delete_parts_cb, (void*)"volumes"} ,
-      {0} 
-    };  
-
-// FIXME: should create MAXSOLVERS items...
-Context_Item menu_solver[] = {
-  {"2Solver", NULL} ,
-  {"Solver 0", (Fl_Callback *)solver_cb , (void*)0} ,
-  {"Solver 1", (Fl_Callback *)solver_cb , (void*)1} ,
-  {"Solver 2", (Fl_Callback *)solver_cb , (void*)2} ,
-  {"Solver 3", (Fl_Callback *)solver_cb , (void*)3} ,
-  {"Solver 4", (Fl_Callback *)solver_cb , (void*)4} ,
-  {0} 
-};
-
-Context_Item menu_post[] = {
-  {"3Post-processing", NULL} ,
-  {0} 
-};
-
-// some other reusable menus
-
-static Fl_Menu_Item menu_point_display[] = {
-  {"Color dot",   0, 0, 0},
-  {"3D sphere",   0, 0, 0},
-  {0}
-};
-
-static Fl_Menu_Item menu_point_display_post[] = {
-  {"Color dot",      0, 0, 0},
-  {"3D sphere",      0, 0, 0},
-  {"Scaled dot",     0, 0, 0},
-  {"Scaled sphere",  0, 0, 0},
-  {0}
-};
 
-static Fl_Menu_Item menu_line_display[] = {
-  {"Color segment", 0, 0, 0},
-  {"3D cylinder",   0, 0, 0},
-  {0}
-};
-
-static Fl_Menu_Item menu_line_display_post[] = {
-  {"Color segment",    0, 0, 0},
-  {"3D cylinder",      0, 0, 0},
-  {"Tapered cylinder", 0, 0, 0},
-  {0}
-};
-
-static Fl_Menu_Item menu_surface_display[] = {
-  {"Cross",     0, 0, 0},
-  {"Wireframe", 0, 0, 0},
-  {"Solid",     0, 0, 0},
-  {0}
-};
-
-static Fl_Menu_Item menu_axes_mode[] = {
-  {"None",        0, 0, 0},
-  {"Simple axes", 0, 0, 0},
-  {"Box",         0, 0, 0},
-  {"Full grid",   0, 0, 0},
-  {"Open grid",   0, 0, 0},
-  {"Ruler",       0, 0, 0},
-  {0}
-};
-
-
-#define NUM_FONTS 14
+  // All static windows are contructed (even if some are not
+  // displayed) since the shortcuts should be valid even for hidden
+  // windows, and we don't want to test for widget existence every time
+  menu = new menuWindow(_fontsize);
+  graph.push_back(new graphicWindow(_fontsize));
 
-Fl_Menu_Item menu_font_names[] = {
-  {"Times-Roman",           0, 0, (void*)FL_TIMES},
-  {"Times-Bold",            0, 0, (void*)FL_TIMES_BOLD},
-  {"Times-Italic",          0, 0, (void*)FL_TIMES_ITALIC},
-  {"Times-BoldItalic",      0, 0, (void*)FL_TIMES_BOLD_ITALIC},
-  {"Helvetica",             0, 0, (void*)FL_HELVETICA},
-  {"Helvetica-Bold",        0, 0, (void*)FL_HELVETICA_BOLD},
-  {"Helvetica-Oblique",     0, 0, (void*)FL_HELVETICA_ITALIC},
-  {"Helvetica-BoldOblique", 0, 0, (void*)FL_HELVETICA_BOLD_ITALIC},
-  {"Courier",               0, 0, (void*)FL_COURIER},
-  {"Courier-Bold",          0, 0, (void*)FL_COURIER_BOLD},
-  {"Courier-Oblique",       0, 0, (void*)FL_COURIER_ITALIC},
-  {"Courier-BoldOblique",   0, 0, (void*)FL_COURIER_BOLD_ITALIC},
-  {"Symbol",                0, 0, (void*)FL_SYMBOL},
-  {"ZapfDingbats",          0, 0, (void*)FL_ZAPF_DINGBATS},
-  {0}
-};
+#if defined(WIN32)
+  graph[0]->win->icon
+    ((const char*)LoadImage(fl_display, MAKEINTRESOURCE(IDI_ICON),
+                            IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR));
+#elif defined(__APPLE__)
+  // Nothing to do here
+#else
+  fl_open_display();
+  static char gmsh32x32[] = {
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x40, 0x03, 0x00,
+    0x00, 0x40, 0x03, 0x00, 0x00, 0x20, 0x07, 0x00, 0x00, 0x20, 0x07, 0x00,
+    0x00, 0x10, 0x0f, 0x00, 0x00, 0x10, 0x0f, 0x00, 0x00, 0x08, 0x1f, 0x00,
+    0x00, 0x08, 0x1f, 0x00, 0x00, 0x04, 0x3f, 0x00, 0x00, 0x04, 0x3f, 0x00,
+    0x00, 0x02, 0x7f, 0x00, 0x00, 0x02, 0x7f, 0x00, 0x00, 0x01, 0xff, 0x00,
+    0x00, 0x01, 0xff, 0x00, 0x80, 0x00, 0xff, 0x01, 0x80, 0x00, 0xff, 0x01,
+    0x40, 0x00, 0xff, 0x03, 0x40, 0x00, 0xff, 0x03, 0x20, 0x00, 0xff, 0x07,
+    0x20, 0x00, 0xff, 0x07, 0x10, 0x00, 0xff, 0x0f, 0x10, 0x00, 0xff, 0x0f,
+    0x08, 0x00, 0xff, 0x1f, 0x08, 0x00, 0xff, 0x1f, 0x04, 0x40, 0xfd, 0x3f,
+    0x04, 0xa8, 0xea, 0x3f, 0x02, 0x55, 0x55, 0x7f, 0xa2, 0xaa, 0xaa, 0x7a,
+    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 };
+  graph[0]->win->icon
+    ((const char*)XCreateBitmapFromData(fl_display, DefaultRootWindow(fl_display),
+                                        gmsh32x32, 32, 32));
+  menu->win->icon
+    ((const char*)XCreateBitmapFromData(fl_display, DefaultRootWindow(fl_display),
+                                        gmsh32x32, 32, 32));
+#endif
 
-int GetFontIndex(const char *fontname)
-{
-  if(fontname){
-    for(int i = 0; i < NUM_FONTS; i++)
-      if(!strcmp(menu_font_names[i].label(), fontname))
-        return i;
-  }
-  Msg::Error("Unknown font \"%s\" (using \"Helvetica\" instead)", fontname);
-  Msg::Info("Available fonts:");
-  for(int i = 0; i < NUM_FONTS; i++)
-    Msg::Info("  \"%s\"", menu_font_names[i].label());
-  return 4;
-}
+  // open graphics window first for correct non-modal behaviour on windows
+  graph[0]->win->show(1, argv);
+  menu->win->show();
 
-int GetFontEnum(int index)
-{
-  if(index >= 0 && index < NUM_FONTS)
-    return (long)menu_font_names[index].user_data();
-  return FL_HELVETICA;
-}
+  // graphic window should have the initial focus (so we can
+  // e.g. directly loop through time steps with the keyboard)
+  graph[0]->gl->take_focus();
+
+  // create all the permanent windows
+  options = new optionWindow(_fontsize);
+  fields = new fieldWindow(_fontsize);
+  plugins = new pluginWindow(_fontsize);
+  stats = new statisticsWindow(_fontsize);
+  visibility = new visibilityWindow(_fontsize);
+  clipping = new clippingWindow(_fontsize);
+  messages = new messageWindow(_fontsize);
+  manip = new manipWindow(_fontsize);
+  geoContext = new geometryContextWindow(_fontsize);
+  meshContext = new meshContextWindow(_fontsize);
+  about = new aboutWindow(_fontsize);
+  for(int i = 0; i < MAX_NUM_SOLVERS; i++)
+    solver.push_back(new solverWindow(i, _fontsize));
+
+  // init solver plugin stuff
+  callForSolverPlugin(-1);
 
-const char *GetFontName(int index)
-{
-  if(index >= 0 && index < NUM_FONTS)
-    return menu_font_names[index].label();
-  return "Helvetica";
+  // Draw the scene
+  graph[0]->gl->redraw();
 }
 
-int GetFontAlign(const char *alignstr)
-{
-  if(alignstr){
-    if(!strcmp(alignstr, "BottomLeft") || !strcmp(alignstr, "Left") ||
-       !strcmp(alignstr, "left"))
-      return 0;
-    else if(!strcmp(alignstr, "BottomCenter") || !strcmp(alignstr, "Center") ||
-            !strcmp(alignstr, "center"))
-      return 1;
-    else if(!strcmp(alignstr, "BottomRight") || !strcmp(alignstr, "Right") ||
-            !strcmp(alignstr, "right"))
-      return 2;
-    else if(!strcmp(alignstr, "TopLeft"))
-      return 3;
-    else if(!strcmp(alignstr, "TopCenter"))
-      return 4;
-    else if(!strcmp(alignstr, "TopRight"))
-      return 5;
-    else if(!strcmp(alignstr, "CenterLeft"))
-      return 6;
-    else if(!strcmp(alignstr, "CenterCenter"))
-      return 7;
-    else if(!strcmp(alignstr, "CenterRight"))
-      return 8;
-  }
-  Msg::Error("Unknown font alignment \"%s\" (using \"Left\" instead)", alignstr);
-  Msg::Info("Available font alignments:");
-  Msg::Info("  \"Left\" (or \"BottomLeft\")");
-  Msg::Info("  \"Center\" (or \"BottomCenter\")");
-  Msg::Info("  \"Right\" (or \"BottomRight\")");
-  Msg::Info("  \"TopLeft\"");
-  Msg::Info("  \"TopCenter\"");
-  Msg::Info("  \"TopRight\"");
-  Msg::Info("  \"CenterLeft\"");
-  Msg::Info("  \"CenterCenter\"");
-  Msg::Info("  \"CenterRight\"");
-  return 0;
-}
+GUI *GUI::_instance = 0;
 
-int GetFontSize()
+GUI *GUI::instance(int argc, char **argv)
 {
-  if(CTX.fontsize > 0){
-    return CTX.fontsize;
-  }
-  else{
-    int w = Fl::w();
-    if(w <= 1024)      return 11;
-    else if(w <= 1280) return 12;
-    else if(w <= 1680) return 13;
-    else if(w <= 1920) return 14;
-    else               return 15;
-  }
+  if(!_instance) _instance = new GUI(argc, argv);
+  return _instance;
 }
 
-// Definition of global shortcuts
-
-int GUI::global_shortcuts(int event)
+int GUI::testGlobalShortcuts(int event)
 {
   // we only handle shortcuts here
-  if(event != FL_SHORTCUT)
-    return 0;
+  if(event != FL_SHORTCUT) return 0;
+
+  int status = 0;
 
   if(Fl::test_shortcut('0')) {
     geometry_reload_cb(0, 0);
     mod_geometry_cb(0, 0);
-    return 1;
+    status = 1;
   }
   else if(Fl::test_shortcut('1') || Fl::test_shortcut(FL_F + 1)) {
     mesh_1d_cb(0, 0);
     mod_mesh_cb(0, 0);
-    return 1;
+    status = 1;
   }
   else if(Fl::test_shortcut('2') || Fl::test_shortcut(FL_F + 2)) {
     mesh_2d_cb(0, 0);
     mod_mesh_cb(0, 0);
-    return 1;
+    status = 1;
   }
   else if(Fl::test_shortcut('3') || Fl::test_shortcut(FL_F + 3)) {
     mesh_3d_cb(0, 0);
     mod_mesh_cb(0, 0);
-    return 1;
+    status = 1;
   }
   else if(Fl::test_shortcut(FL_CTRL + 'q') || Fl::test_shortcut(FL_META + 'q')){
     // only necessary when using the system menu bar, but hey, it
     // cannot hurt...
     file_quit_cb(0, 0);
-    return 1;
+    status = 1;
   }
   else if(Fl::test_shortcut('g')) {
     mod_geometry_cb(0, 0);
-    return 1;
+    status = 1;
   }
   else if(Fl::test_shortcut('m')) {
     mod_mesh_cb(0, 0);
-    return 1;
+    status = 1;
   }
   else if(Fl::test_shortcut('s')) {
     mod_solver_cb(0, 0);
-    return 1;
+    status = 1;
   }
   else if(Fl::test_shortcut('p')) {
     mod_post_cb(0, 0);
-    return 1;
+    status = 1;
   }
   else if(Fl::test_shortcut('<')) {
     mod_back_cb(0, 0);
-    return 1;
+    status = 1;
   }
   else if(Fl::test_shortcut('>')) {
     mod_forward_cb(0, 0);
-    return 1;
+    status = 1;
   }
   else if(Fl::test_shortcut('e')) {
     end_selection = 1;
-    return 0;   // trick: do as if we didn't use it
+    status = 0; // trick: do as if we didn't use it
   }
   else if(Fl::test_shortcut('u')) {
     undo_selection = 1;
-    return 0;   // trick: do as if we didn't use it
+    status = 0; // trick: do as if we didn't use it
   }
   else if(Fl::test_shortcut('i')) {
     invert_selection = 1;
-    return 0;   // trick: do as if we didn't use it
+    status = 0; // trick: do as if we didn't use it
   }
   else if(Fl::test_shortcut('q')) {
     quit_selection = 1;
-    return 0;   // trick: do as if we didn't use it
+    status = 0; // trick: do as if we didn't use it
   }
   else if(Fl::test_shortcut('-')) {
     invert_selection = 1;
-    return 0;   // trick: do as if we didn't use it
+    status = 0; // trick: do as if we didn't use it
   }
   else if(Fl::test_shortcut(FL_Escape) ||
           Fl::test_shortcut(FL_META + FL_Escape) ||
           Fl::test_shortcut(FL_SHIFT + FL_Escape) ||
           Fl::test_shortcut(FL_CTRL + FL_Escape) ||
           Fl::test_shortcut(FL_ALT + FL_Escape)) {
-    if(g_opengl_window->LassoMode){
-      g_opengl_window->LassoMode = false;
-      redraw_opengl();
+    if(graph[0]->gl->lassoMode){
+      graph[0]->gl->lassoMode = false;
+      status = 2;
     }
     else{
       status_xyz1p_cb(0, (void *)"S");
+      status = 1;
     }
-    return 1;
   }
   else if(Fl::test_shortcut(FL_SHIFT + 'a')) { 
     window_cb(0, (void*)"front");
-    return 1;
+    status = 1;
   }
   else if(Fl::test_shortcut(FL_SHIFT + 'o')) {
     general_options_cb(0, 0);
-    return 1;
+    status = 1;
   }
   else if(Fl::test_shortcut(FL_SHIFT + 'g')) {
     geometry_options_cb(0, 0);
-    return 1;
+    status = 1;
   }
   else if(Fl::test_shortcut(FL_SHIFT + 'm')) {
     mesh_options_cb(0, 0);
-    return 1;
+    status = 1;
   }
   else if(Fl::test_shortcut(FL_SHIFT + 's')) {
     solver_options_cb(0, 0);
-    return 1;
+    status = 1;
   }
   else if(Fl::test_shortcut(FL_SHIFT + 'p')) {
     post_options_cb(0, 0);
-    return 1;
+    status = 1;
   }
   else if(Fl::test_shortcut(FL_SHIFT + 'w')) {
     if(PView::list.size()){
-      if(view_number >= 0 && view_number < (int)PView::list.size())
-        create_view_options_window(view_number);
+      if(options->view.index >= 0 && options->view.index < (int)PView::list.size())
+        options->showGroup(options->view.index + 6);
       else
-        create_view_options_window(0);
+        options->showGroup(6);
     }
-    return 1;
+    status = 1;
   }
   else if(Fl::test_shortcut(FL_SHIFT + 'u')) {
     if(PView::list.size()){
-      if(view_number >= 0 && view_number < (int)PView::list.size())
-        create_plugin_window(view_number);
+      if(options->view.index >= 0 && options->view.index < (int)PView::list.size())
+        plugins->show(options->view.index);
       else
-        create_plugin_window(0);
+        plugins->show(0);
     }
-    return 1;
+    status = 1;
   }
   else if(Fl::test_shortcut(FL_ALT + 'f')) {
     opt_general_fast_redraw(0, GMSH_SET | GMSH_GUI,
                             !opt_general_fast_redraw(0, GMSH_GET, 0));
-    redraw_opengl();
-    return 1;
+    status = 2;
   }
   else if(Fl::test_shortcut(FL_ALT + 'b')) {
     opt_general_draw_bounding_box(0, GMSH_SET | GMSH_GUI,
                                   !opt_general_draw_bounding_box(0, GMSH_GET, 0));
-    redraw_opengl();
-    return 1;
+    status = 2;
   }
   else if(Fl::test_shortcut(FL_ALT + 'i')) {
     for(unsigned int i = 0; i < PView::list.size(); i++)
       if(opt_view_visible(i, GMSH_GET, 0))
         opt_view_show_scale(i, GMSH_SET | GMSH_GUI,
                             !opt_view_show_scale(i, GMSH_GET, 0));
-    redraw_opengl();
-    return 1;
+    status = 2;
   }
   else if(Fl::test_shortcut(FL_ALT + 'c')) {
     opt_general_color_scheme(0, GMSH_SET | GMSH_GUI,
                              opt_general_color_scheme(0, GMSH_GET, 0) + 1);
-    redraw_opengl();
-    return 1;
+    status = 2;
   }
   else if(Fl::test_shortcut(FL_ALT + 'w')) {
     opt_geometry_light(0, GMSH_SET | GMSH_GUI,
@@ -677,34 +325,32 @@ int GUI::global_shortcuts(int event)
       if(opt_view_visible(i, GMSH_GET, 0))
         opt_view_light(i, GMSH_SET | GMSH_GUI,
                        !opt_view_light(i, GMSH_GET, 0));
-    redraw_opengl();
-    return 1;
+    status = 2;
   }
   else if(Fl::test_shortcut(FL_ALT + FL_SHIFT + 'w')) {
     opt_mesh_reverse_all_normals(0, GMSH_SET | GMSH_GUI,
                                  !opt_mesh_reverse_all_normals(0, GMSH_GET, 0));
-    redraw_opengl();
-    return 1;
+    status = 2;
   }
   else if(Fl::test_shortcut(FL_ALT + 'x') || 
           Fl::test_shortcut(FL_ALT + FL_SHIFT + 'x')) {
     status_xyz1p_cb(0, (void *)"x");
-    return 1;
+    status = 1;
   }
   else if(Fl::test_shortcut(FL_ALT + 'y') ||
           Fl::test_shortcut(FL_ALT + FL_SHIFT + 'y')) {
     status_xyz1p_cb(0, (void *)"y");
-    return 1;
+    status = 1;
   }
   else if(Fl::test_shortcut(FL_ALT + 'z') ||
           Fl::test_shortcut(FL_ALT + FL_SHIFT + 'z')) {
     status_xyz1p_cb(0, (void *)"z");
-    return 1;
+    status = 1;
   }
   else if(Fl::test_shortcut(FL_ALT + 'o') ||
           Fl::test_shortcut(FL_ALT + FL_SHIFT + 'o')) {
     status_xyz1p_cb(0, (void *)"p");
-    return 1;
+    status = 1;
   }
   else if(Fl::test_shortcut(FL_ALT + 'a')) {
     opt_general_axes(0, GMSH_SET | GMSH_GUI, 
@@ -712,79 +358,66 @@ int GUI::global_shortcuts(int event)
     for(unsigned int i = 0; i < PView::list.size(); i++)
       if(opt_view_visible(i, GMSH_GET, 0))
         opt_view_axes(i, GMSH_SET | GMSH_GUI, opt_view_axes(i, GMSH_GET, 0)+1);
-    redraw_opengl();
-    return 1;
+    status = 2;
   }
   else if(Fl::test_shortcut(FL_ALT + FL_SHIFT + 'a')) {
     opt_general_small_axes(0, GMSH_SET | GMSH_GUI,
                            !opt_general_small_axes(0, GMSH_GET, 0));
-    redraw_opengl();
-    return 1;
+    status = 2;
   }
   else if(Fl::test_shortcut(FL_ALT + 'p')) {
     opt_geometry_points(0, GMSH_SET | GMSH_GUI,
                         !opt_geometry_points(0, GMSH_GET, 0));
-    redraw_opengl();
-    return 1;
+    status = 2;
   }
   else if(Fl::test_shortcut(FL_ALT + 'l')) {
     opt_geometry_lines(0, GMSH_SET | GMSH_GUI,
                        !opt_geometry_lines(0, GMSH_GET, 0));
-    redraw_opengl();
-    return 1;
+    status = 2;
   }
   else if(Fl::test_shortcut(FL_ALT + 's')) {
     opt_geometry_surfaces(0, GMSH_SET | GMSH_GUI,
                           !opt_geometry_surfaces(0, GMSH_GET, 0));
-    redraw_opengl();
-    return 1;
+    status = 2;
   }
   else if(Fl::test_shortcut(FL_ALT + 'v')) {
     opt_geometry_volumes(0, GMSH_SET | GMSH_GUI,
                          !opt_geometry_volumes(0, GMSH_GET, 0));
-    redraw_opengl();
-    return 1;
+    status = 2;
   }
   else if(Fl::test_shortcut(FL_ALT + FL_SHIFT + 'p')) {
     opt_mesh_points(0, GMSH_SET | GMSH_GUI, !opt_mesh_points(0, GMSH_GET, 0));
-    redraw_opengl();
-    return 1;
+    status = 2;
   }
   else if(Fl::test_shortcut(FL_ALT + FL_SHIFT + 'l')) {
     opt_mesh_lines(0, GMSH_SET | GMSH_GUI, 
                    !opt_mesh_lines(0, GMSH_GET, 0));
-    redraw_opengl();
-    return 1;
+    status = 2;
   }
   else if(Fl::test_shortcut(FL_ALT + FL_SHIFT + 's')) {
     opt_mesh_surfaces_edges(0, GMSH_SET | GMSH_GUI,
                             !opt_mesh_surfaces_edges(0, GMSH_GET, 0));
-    redraw_opengl();
-    return 1;
+    status = 2;
   }
   else if(Fl::test_shortcut(FL_ALT + FL_SHIFT + 'v')) {
     opt_mesh_volumes_edges(0, GMSH_SET | GMSH_GUI,
                            !opt_mesh_volumes_edges(0, GMSH_GET, 0));
-    redraw_opengl();
-    return 1;
+    status = 2;
   }
   else if(Fl::test_shortcut(FL_ALT + 'd')){
     opt_geometry_surface_type(0, GMSH_SET | GMSH_GUI,
                               opt_geometry_surface_type(0, GMSH_GET, 0) + 1);
-    redraw_opengl();
-    return 1;
+    status = 2;
   }
   else if(Fl::test_shortcut(FL_ALT + FL_SHIFT + 'd')) {
     opt_mesh_surfaces_faces(0, GMSH_SET | GMSH_GUI,
                             !opt_mesh_surfaces_faces(0, GMSH_GET, 0));
-    redraw_opengl();
-    return 1;
+    status = 2;
   }
   else if(Fl::test_shortcut(FL_ALT + FL_SHIFT + 'b')) {
     opt_mesh_volumes_faces(0, GMSH_SET | GMSH_GUI,
                            !opt_mesh_volumes_faces(0, GMSH_GET, 0));
-    redraw_opengl();
-    return 1;
+    status = 2;
   }
   else if(Fl::test_shortcut(FL_ALT + 'm')) {
     int old = opt_mesh_points(0, GMSH_GET, 0) || 
@@ -797,8 +430,7 @@ int GUI::global_shortcuts(int event)
     opt_mesh_surfaces_faces(0, GMSH_SET | GMSH_GUI, !old);
     opt_mesh_volumes_edges(0, GMSH_SET | GMSH_GUI, !old);
     opt_mesh_volumes_faces(0, GMSH_SET | GMSH_GUI, !old);
-    redraw_opengl();
-    return 1;
+    status = 2;
   }
   else if(Fl::test_shortcut(FL_ALT + 't')) {
     for(unsigned int i = 0; i < PView::list.size(); i++)
@@ -807,53 +439,53 @@ int GUI::global_shortcuts(int event)
 	if(t == 4) t++; // skip numeric
         opt_view_intervals_type(i, GMSH_SET | GMSH_GUI, t);
       }
-    redraw_opengl();
-    return 1;
+    status = 2;
   }
   else if(Fl::test_shortcut(FL_ALT + 'r')) {
     for(unsigned int i = 0; i < PView::list.size(); i++)
       if(opt_view_visible(i, GMSH_GET, 0))
         opt_view_range_type(i, GMSH_SET | GMSH_GUI,
                             opt_view_range_type(i, GMSH_GET, 0) + 1);
-    redraw_opengl();
-    return 1;
+    status = 2;
   }
   else if(Fl::test_shortcut(FL_ALT + 'n')) {
     for(unsigned int i = 0; i < PView::list.size(); i++)
       if(opt_view_visible(i, GMSH_GET, 0))
         opt_view_draw_strings(i, GMSH_SET | GMSH_GUI,
                               !opt_view_draw_strings(i, GMSH_GET, 0));
-    redraw_opengl();
-    return 1;
+    status = 2;
   }
   else if(Fl::test_shortcut(FL_ALT + 'e')) {
     for(unsigned int i = 0; i < PView::list.size(); i++)
       if(opt_view_visible(i, GMSH_GET, 0))
         opt_view_show_element(i, GMSH_SET | GMSH_GUI,
                               !opt_view_show_element(i, GMSH_GET, 0));
-    redraw_opengl();
-    return 1;
+    status = 2;
   }
   else if(Fl::test_shortcut(FL_ALT + 'h')) {
     static int show = 0;
     for(unsigned int i = 0; i < PView::list.size(); i++)
       opt_view_visible(i, GMSH_SET | GMSH_GUI, show);
-    redraw_opengl();
     show = !show;
-    return 1;
+    status = 2;
   }
-  else if(arrow_shortcuts()) {
+  else if(testArrowShortcuts()) {
+    status = 1;
+  }
+  
+  if(status == 2){
+    graph[0]->gl->make_current();
+    graph[0]->gl->redraw();
+    check();
     return 1;
   }
-
-  return 0;
+  else if(status == 1)
+    return 1;
+  else
+    return 0;
 }
 
-// Test the arrow shortcuts (this is not in the global_shortcuts)
-// since it is used elsewhere (where we want to override widget
-// navigation: necessary since FLTK>=1.1)
-
-int GUI::arrow_shortcuts()
+int GUI::testArrowShortcuts()
 {
   if(Fl::test_shortcut(FL_Left)) {
     ManualPlay(1, -1);
@@ -874,4298 +506,218 @@ int GUI::arrow_shortcuts()
   return 0;
 }
 
-// The GUI constructor
-
-GUI::GUI(int argc, char **argv)
+void GUI::setGraphicSize(int w, int h)
 {
-  // initialize static windows
-  g_window = NULL;
-  m_window = NULL;
-  opt_window = NULL;
-  plugin_window = NULL;
-  field_window = NULL;
-  stat_window = NULL;
-  msg_window = NULL;
-  vis_window = NULL;
-  clip_window = NULL;
-  manip_window = NULL;
-  about_window = NULL;
-  context_geometry_window = NULL;
-  context_mesh_window = NULL;
-
-  // initialize on-screen message buffer
-  onscreen_buffer[0][0] = '\0';
-  onscreen_buffer[1][0] = '\0';
+  graph[0]->win->size(w, h + graph[0]->win->h() - graph[0]->gl->h());
+}
 
-  // initialize selection bits
-  selection = ENT_NONE;
-  try_selection = quit_selection = end_selection = 0;
-  undo_selection = invert_selection = 0;
-  for(int i = 0; i < 4; i++) try_selection_xywh[i] = 0;
+void GUI::setGraphicTitle(const char *str)
+{
+  // FIXME should use copy_label, but it is broken for Fl_Windows in
+  // fltk 1.1.7
+  graph[0]->win->label(str);
+}
 
-  // set X display
-  if(strlen(CTX.display))
-    Fl::display(CTX.display);
+void GUI::updateViews()
+{
+  graph[0]->checkAnimButtons();
+  if(menu->module->value() == 3)
+    menu->setContext(menu_post, 0);
+  options->resetBrowser();
+  options->resetExternalViewList();
+  fields->loadFieldViewList();
+  plugins->resetViewBrowser();
+  clipping->resetBrowser();
+}
 
-  // add global shortcuts
-  Fl::add_handler(SetGlobalShortcut);
+void GUI::updateFields()
+{
+  fields->editField(GModel::current()->getFields()->get(fields->selected_id));
+}
 
-  // store fontsize now: we don't want any subsequent change
-  // (e.g. when doing a 'restore options') to be taken into account
-  // in the dynamic GUI features (set_context, plugin, etc.)
-  fontsize = GetFontSize();
+void GUI::resetVisibility()
+{
+  visibility->browser->clear();
+  if(visibility->win->shown())
+    visibility_cb(NULL, NULL);
+}
 
-  // set default font size
-  FL_NORMAL_SIZE = fontsize;
-
-  // handle themes and tooltip font size
-  if(strlen(CTX.gui_theme))
-    Fl::scheme(CTX.gui_theme);
-  Fl_Tooltip::size(fontsize);
-
-  // register image formats not in core fltk library (jpeg/png)
-  fl_register_images();
-
-  // load default system icons (for file browser)
-  Fl_File_Icon::load_system_icons();
-  
-  // add callback to respond to the Mac Finder (when you click on a
-  // document)
-#if defined(__APPLE__)
-  fl_open_callback(OpenProjectMacFinder);
-#endif
-
-  // All static windows are contructed (even if some are not
-  // displayed) since the shortcuts should be valid even for hidden
-  // windows, and we don't want to test for widget existence every time
-
-  create_menu_window();
-  create_graphic_window();
-
-#if defined(WIN32)
-  g_window->icon((const char*)LoadImage(fl_display, MAKEINTRESOURCE(IDI_ICON),
-					IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR));
-#elif defined(__APPLE__)
-  // Nothing to do here
-#else
-  fl_open_display();
-  static char gmsh32x32[] = {
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x40, 0x03, 0x00,
-    0x00, 0x40, 0x03, 0x00, 0x00, 0x20, 0x07, 0x00, 0x00, 0x20, 0x07, 0x00,
-    0x00, 0x10, 0x0f, 0x00, 0x00, 0x10, 0x0f, 0x00, 0x00, 0x08, 0x1f, 0x00,
-    0x00, 0x08, 0x1f, 0x00, 0x00, 0x04, 0x3f, 0x00, 0x00, 0x04, 0x3f, 0x00,
-    0x00, 0x02, 0x7f, 0x00, 0x00, 0x02, 0x7f, 0x00, 0x00, 0x01, 0xff, 0x00,
-    0x00, 0x01, 0xff, 0x00, 0x80, 0x00, 0xff, 0x01, 0x80, 0x00, 0xff, 0x01,
-    0x40, 0x00, 0xff, 0x03, 0x40, 0x00, 0xff, 0x03, 0x20, 0x00, 0xff, 0x07,
-    0x20, 0x00, 0xff, 0x07, 0x10, 0x00, 0xff, 0x0f, 0x10, 0x00, 0xff, 0x0f,
-    0x08, 0x00, 0xff, 0x1f, 0x08, 0x00, 0xff, 0x1f, 0x04, 0x40, 0xfd, 0x3f,
-    0x04, 0xa8, 0xea, 0x3f, 0x02, 0x55, 0x55, 0x7f, 0xa2, 0xaa, 0xaa, 0x7a,
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 };
-  g_window->icon((const char*)XCreateBitmapFromData(fl_display, DefaultRootWindow(fl_display),
-						    gmsh32x32, 32, 32));
-  m_window->icon((const char*)XCreateBitmapFromData(fl_display, DefaultRootWindow(fl_display),
-						    gmsh32x32, 32, 32));
-#endif
-
-  // open graphics window first for correct non-modal behaviour on windows
-  g_window->show(1, argv);
-  m_window->show();
-
-  // graphic window should have the initial focus (so we can
-  // e.g. directly loop through time steps with the keyboard)
-  g_opengl_window->take_focus();
-  
-  create_option_window();
-  create_plugin_window(0);
-  create_field_window();
-  create_message_window();
-  create_statistics_window();
-  create_visibility_window();
-  create_clip_window();
-  create_manip_window();
-  create_about_window();
-  create_geometry_context_window(0);
-  create_mesh_context_window(0);
-  for(int i = 0; i < MAXSOLVERS; i++) {
-    solver[i].window = NULL;
-    create_solver_window(i);
-  }
-  call_for_solver_plugin(-1);
-
-  // Draw the scene
-  g_opengl_window->redraw();
-}
-
-// Run the GUI until no window is left
-
-int GUI::run()
-{
-  return Fl::run();
-}
-
-// Check (now) if any pending events and run them
-
-void GUI::check()
-{
-  Fl::check();
-}
-
-// Wait for any events and run them
-
-void GUI::wait()
-{
-  Fl::wait();
-}
-
-void GUI::wait(double time)
-{
-  Fl::wait(time);
-}
-
-// Create the menu window
-
-void GUI::create_menu_window()
-{
-  int y;
-
-  if(m_window) {
-    m_window->show();
-    return;
-  }
-
-  int width = 14 * fontsize;
-
-  // this is the initial height: no dynamic button is shown!
-#if defined(__APPLE__)
-  if(CTX.system_menu_bar){
-    MH = BH + 6;  // the menu bar is not in the application!
-  }
-  else{
-#endif
-    MH = BH + BH + 6;
-#if defined(__APPLE__)
-  }
-#endif
-
-  m_window = new Main_Window(width, MH + NB_BUTT_SCROLL * BH, CTX.non_modal_windows, "Gmsh");
-  m_window->box(GMSH_WINDOW_BOX);
-  m_window->callback(file_quit_cb);
-
-#if defined(__APPLE__)
-  if(CTX.system_menu_bar){
-    // the system menubar is kind of a hack in fltk < 1.1.7: it still
-    // creates a real (invisible) menubar. To avoid spurious mouse
-    // click events we make it a 1x1 pixel rectangle, 1 pixel off the
-    // edge (so it falls behind the navigation buttons)
-    m_sys_menu_bar = new Fl_Sys_Menu_Bar(1, 1, 1, 1);
-    m_sys_menu_bar->menu(m_sys_menubar_table);
-    m_sys_menu_bar->global();
-    Fl_Box *o = new Fl_Box(0, 0, width, BH + 6);
-    o->box(FL_UP_BOX);
-    y = 3;
-  }
-  else{
-#endif
-    m_menu_bar = new Fl_Menu_Bar(0, 0, width, BH);
-    m_menu_bar->menu(m_menubar_table);
-    m_menu_bar->box(FL_UP_BOX);
-    m_menu_bar->global();
-    Fl_Box *o = new Fl_Box(0, BH, width, BH + 6);
-    o->box(FL_UP_BOX);
-    y = BH + 3;
-#if defined(__APPLE__)
-  }
-#endif
-
-  m_navig_butt[0] = new Fl_Button(1, y, 18, BH / 2, "@#-1<");
-  m_navig_butt[0]->labeltype(FL_SYMBOL_LABEL);
-  m_navig_butt[0]->box(FL_FLAT_BOX);
-  m_navig_butt[0]->selection_color(FL_WHITE);
-  m_navig_butt[0]->callback(mod_back_cb);
-  m_navig_butt[0]->tooltip("Go back one in the menu history (<)");
-
-  m_navig_butt[1] = new Fl_Button(1, y + BH / 2, 18, BH / 2, "@#-1>");
-  m_navig_butt[1]->labeltype(FL_SYMBOL_LABEL);
-  m_navig_butt[1]->box(FL_FLAT_BOX);
-  m_navig_butt[1]->selection_color(FL_WHITE);
-  m_navig_butt[1]->callback(mod_forward_cb);
-  m_navig_butt[1]->tooltip("Go forward one in the menu history (>)");
-
-  m_module_butt = new Fl_Choice(19, y, width - 24, BH);
-  m_module_butt->menu(m_module_table);
-  m_module_butt->box(FL_THIN_DOWN_BOX);
-  // force the executation of the callback even if we didn't change
-  // the selection (we want to go back to the top-level menu every
-  // time we select one of the categories, even if the category is not
-  // changed):
-  m_module_butt->when(FL_WHEN_RELEASE_ALWAYS);
-
-  // create an empty scroll area that will get populated dynamically
-  // in set_context()
-  m_scroll = new Fl_Scroll(0, MH, width, NB_BUTT_SCROLL * BH); 
-  m_scroll->type(Fl_Scroll::VERTICAL);
-  m_scroll->end();
-
-  m_window->size(width, MH);
-  m_window->position(CTX.position[0], CTX.position[1]);
-  
-  m_window->end();
-}
-
-// Dynamically set the context
-
-void GUI::set_context(Context_Item * menu_asked, int flag)
-{
-  static int nb_back = 0, nb_forward = 0, init_context = 0;
-  static Context_Item *menu_history[NB_HISTORY_MAX];
-  Context_Item *menu;
-
-  if(!init_context) {
-    init_context = 1;
-    for(int i = 0; i < NB_HISTORY_MAX; i++) {
-      menu_history[i] = NULL;
-    }
-  }
-
-  if(nb_back > NB_HISTORY_MAX - 2)
-    nb_back = 1; // we should do a circular list
-
-  if(flag == -1) {
-    if(nb_back > 1) {
-      nb_back--;
-      nb_forward++;
-      menu = menu_history[nb_back - 1];
-    }
-    else
-      return;
-  }
-  else if(flag == 1) {
-    if(nb_forward > 0) {
-      nb_back++;
-      nb_forward--;
-      menu = menu_history[nb_back - 1];
-    }
-    else
-      return;
-  }
-  else {
-    menu = menu_asked;
-    if(!nb_back || menu_history[nb_back - 1] != menu) {
-      menu_history[nb_back++] = menu;
-    }
-    nb_forward = 0;
-  }
-
-  if(menu[0].label[0] == '0'){
-    m_module_butt->value(0);
-  }
-  else if(menu[0].label[0] == '1'){
-    m_module_butt->value(1);
-  }
-  else if(menu[0].label[0] == '2'){
-    m_module_butt->value(2);
-    menu[1].label = opt_solver_name0(0, GMSH_GET, 0);
-    menu[2].label = opt_solver_name1(0, GMSH_GET, 0);
-    menu[3].label = opt_solver_name2(0, GMSH_GET, 0);
-    menu[4].label = opt_solver_name3(0, GMSH_GET, 0);
-    menu[5].label = opt_solver_name4(0, GMSH_GET, 0);
-    for(int i = 0; i < MAXSOLVERS; i++) {
-      if(!strlen(menu[i + 1].label))
-        menu[i + 1].label = NULL;
-    }
-  }
-  else if(menu[0].label[0] == '3'){
-    m_module_butt->value(3);
-  }
-  else {
-    Msg::Warning("Something is wrong in your dynamic context definition");
-    return;
-  }
-
-  Msg::StatusBar(1, false, menu[0].label + 1);
-
-  // cannot use m_scroll->clear() in fltk 1.1 (should be fixed in 1.3)
-  for(unsigned int i = 0; i < m_push_butt.size(); i++){
-    m_scroll->remove(m_push_butt[i]);
-    Fl::delete_widget(m_push_butt[i]);
-  }
-  for(unsigned int i = 0; i < m_toggle_butt.size(); i++){
-    m_scroll->remove(m_toggle_butt[i]);
-    Fl::delete_widget(m_toggle_butt[i]);
-  }
-  for(unsigned int i = 0; i < m_toggle2_butt.size(); i++){
-    m_scroll->remove(m_toggle2_butt[i]);
-    Fl::delete_widget(m_toggle2_butt[i]);
-  }
-  for(unsigned int i = 0; i < m_popup_butt.size(); i++){
-    m_scroll->remove(m_popup_butt[i]);
-    Fl::delete_widget(m_popup_butt[i]);
-  }
-  for(unsigned int i = 0; i < m_popup2_butt.size(); i++){
-    m_scroll->remove(m_popup2_butt[i]);
-    Fl::delete_widget(m_popup2_butt[i]);
-  }
-
-  // reset the vectors
-  m_push_butt.clear();
-  m_toggle_butt.clear();
-  m_toggle2_butt.clear();
-  m_popup_butt.clear();
-  m_popup2_butt.clear();
-  for(unsigned int i = 0; i < m_pop_label.size(); i++)
-    delete [] m_pop_label[i];
-  m_pop_label.clear();
-
-  int width = m_window->w();
-  int popw = 4 * fontsize + 3;
-
-  // construct the dynamic menu
-  int nb = 0;
-  if(m_module_butt->value() == 3){ // post-processing context
-    for(nb = 0; nb < (int)PView::list.size(); nb++) {
-      PViewData *data = PView::list[nb]->getData();
-      PViewOptions *opt = PView::list[nb]->getOptions();
-      
-      Fl_Light_Button *b1 = new Fl_Light_Button(0, MH + nb * BH, width - popw, BH);
-      b1->callback(view_toggle_cb, (void *)nb);
-      b1->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE | FL_ALIGN_CLIP);
-      b1->value(opt->Visible);
-      b1->copy_label(data->getName().c_str());
-      b1->tooltip(data->getFileName().c_str());
-      
-      char *tmp = new char[32];
-      sprintf(tmp, "[%d]@#-1>", nb);
-      Fl_Button *b2 = new Fl_Button(width - popw, MH + nb * BH, popw, BH, tmp);
-      m_pop_label.push_back(tmp);
-      b2->align(FL_ALIGN_RIGHT | FL_ALIGN_INSIDE | FL_ALIGN_CLIP);
-      b2->tooltip("Show view option menu (Shift+w)");
-  
-      Popup_Button *p[2];
-      p[0] = new Popup_Button(width - popw, MH + nb * BH, popw, BH);
-      p[0]->type(Fl_Menu_Button::POPUP123);
-      p[1] = new Popup_Button(0, MH + nb * BH, width - popw, BH);
-      p[1]->type(Fl_Menu_Button::POPUP3);
-  
-      for(int j = 0; j < 2; j++) {
-        p[j]->add("Reload/View", 'r', 
-                  (Fl_Callback *) view_reload_cb, (void *)nb, 0);
-        p[j]->add("Reload/Visible Views", 0, 
-                  (Fl_Callback *) view_reload_visible_cb, (void *)nb, 0);
-        p[j]->add("Reload/All Views", 0, 
-                  (Fl_Callback *) view_reload_all_cb, (void *)nb, 0);
-        p[j]->add("Remove/View", FL_Delete, 
-                  (Fl_Callback *) view_remove_cb, (void *)nb, 0);
-        p[j]->add("Remove/Other Views", 0, 
-                  (Fl_Callback *) view_remove_other_cb, (void *)nb, 0);
-        p[j]->add("Remove/Visible Views", 0, 
-                  (Fl_Callback *) view_remove_visible_cb, (void *)nb, 0);
-        p[j]->add("Remove/Invisible Views", 0, 
-                  (Fl_Callback *) view_remove_invisible_cb, (void *)nb, 0);
-        p[j]->add("Remove/Empty Views", 0, 
-                  (Fl_Callback *) view_remove_empty_cb, (void *)nb, 0);
-        p[j]->add("Remove/All Views", 0, 
-                  (Fl_Callback *) view_remove_all_cb, (void *)nb, 0);
-        p[j]->add("Alias/View without Options", 0, 
-                  (Fl_Callback *) view_alias_cb, (void *)nb, 0);
-        p[j]->add("Alias/View with Options", 0, 
-                  (Fl_Callback *) view_alias_with_options_cb, (void *)nb, 0);
-        p[j]->add("Combine Elements/From Visible Views", 0, 
-                  (Fl_Callback *) view_combine_space_visible_cb, (void *)nb, 0);
-        p[j]->add("Combine Elements/From All Views", 0, 
-                  (Fl_Callback *) view_combine_space_all_cb, (void *)nb, 0);
-        p[j]->add("Combine Elements/By View Name", 0, 
-                  (Fl_Callback *) view_combine_space_by_name_cb, (void *)nb, 0);
-        p[j]->add("Combine Time Steps/From Visible Views", 0, 
-                  (Fl_Callback *) view_combine_time_visible_cb, (void *)nb, 0);
-        p[j]->add("Combine Time Steps/From All Views", 0, 
-                  (Fl_Callback *) view_combine_time_all_cb, (void *)nb, 0);
-        p[j]->add("Combine Time Steps/By View Name", 0, 
-                 (Fl_Callback *) view_combine_time_by_name_cb, (void *)nb, 0);
-        p[j]->add("Set Visibility/All On", 0, 
-                  (Fl_Callback *) view_all_visible_cb, (void *)1, 0);
-        p[j]->add("Set Visibility/All Off", 0, 
-                  (Fl_Callback *) view_all_visible_cb, (void *)0, 0);
-        p[j]->add("Set Visibility/Invert", 0, 
-                  (Fl_Callback *) view_all_visible_cb, (void *)-1, 0);
-        p[j]->add("Save As/Parsed View...", 0, 
-                  (Fl_Callback *) view_save_parsed_cb, (void *)nb, 0);
-        p[j]->add("Save As/ASCII View...", 0, 
-                  (Fl_Callback *) view_save_ascii_cb, (void *)nb, 0);
-        p[j]->add("Save As/Binary View...", 0, 
-                  (Fl_Callback *) view_save_binary_cb, (void *)nb, 0);
-        p[j]->add("Save As/STL Triangulation...", 0, 
-                  (Fl_Callback *) view_save_stl_cb, (void *)nb, 0);
-        p[j]->add("Save As/Raw Text...", 0, 
-                  (Fl_Callback *) view_save_txt_cb, (void *)nb, 0);
-        p[j]->add("Save As/Gmsh Mesh...", 0, 
-                  (Fl_Callback *) view_save_msh_cb, (void *)nb, 0);
-#if defined(HAVE_MED)
-        p[j]->add("Save As/MED file...", 0, 
-                  (Fl_Callback *) view_save_med_cb, (void *)nb, 0);
-#endif
-        p[j]->add("Apply As Background Mesh", 0, 
-                  (Fl_Callback *) view_applybgmesh_cb, (void *)nb, FL_MENU_DIVIDER);
-        p[j]->add("Options...", 'o', 
-                  (Fl_Callback *) view_options_cb, (void *)nb, 0);
-        p[j]->add("Plugins...", 'p', 
-                  (Fl_Callback *) view_plugin_cb, (void *)nb, 0);
-      }
-
-      m_toggle_butt.push_back(b1);
-      m_toggle2_butt.push_back(b2);
-      m_popup_butt.push_back(p[0]);
-      m_popup2_butt.push_back(p[1]);
-      m_scroll->add(b1);
-      m_scroll->add(b2);
-      m_scroll->add(p[0]);
-      m_scroll->add(p[1]);
-    }
-  }
-  else{ // geometry, mesh and solver contexts
-    while(menu[nb + 1].label) {
-      Fl_Button *b = new Fl_Button(0, MH + nb * BH, width, BH);
-      b->copy_label(menu[nb + 1].label);
-      b->callback(menu[nb + 1].callback, menu[nb + 1].arg);
-      m_push_butt.push_back(b);
-      m_scroll->add(b);
-      nb++;
-    }
-  }
-
-  m_scroll->redraw();
-
-  if(nb <= NB_BUTT_SCROLL)
-    m_window->size(width, MH + nb * BH);
-  else
-    m_window->size(width, MH + NB_BUTT_SCROLL * BH);
-}
-
-int GUI::get_context()
-{
-  return m_module_butt->value();
-}
-
-// Create the graphic window
-
-#define vv(x,y) fl_vertex(x,y)
-#define bl fl_begin_loop()
-#define el fl_end_loop()
-
-void gmsh_play(Fl_Color c)
-{
-  fl_color(c);
-  bl; vv(-0.3,0.8); vv(0.5,0.0); vv(-0.3,-0.8); el;
-}
-
-void gmsh_pause(Fl_Color c)
-{
-  fl_color(c);
-  bl; vv(-0.8,-0.8); vv(-0.3,-0.8); vv(-0.3,0.8); vv(-0.8,0.8); el;
-  bl; vv(0.0,-0.8); vv(0.5,-0.8); vv(0.5,0.8); vv(0.0,0.8); el;
-}
-
-void gmsh_rewind(Fl_Color c)
-{
-  fl_color(c);
-  bl; vv(-0.8,-0.8); vv(-0.3,-0.8); vv(-0.3,0.8); vv(-0.8,0.8); el;
-  bl; vv(-0.3,0.0); vv(0.5,-0.8); vv(0.5,0.8); el;
-}
-
-void gmsh_forward(Fl_Color c)
-{
-  fl_color(c);
-  bl; vv(0.0,0.8); vv(0.8,0.0); vv(0.0,-0.8); el;
-  bl; vv(-0.8,0.8); vv(-0.3,0.8); vv(-0.3,-0.8); vv(-0.8,-0.8); el;
-}
-
-void gmsh_back(Fl_Color c)
-{
-  fl_rotate(180);  
-  gmsh_forward(c);
-}
-
-void gmsh_ortho(Fl_Color c)
-{
-  fl_color(c);
-  bl; vv(-0.8,0.8); vv(0.3,0.8); vv(0.3,-0.3); vv(-0.8,-0.3); el;
-  bl; vv(-0.3,0.3); vv(0.8,0.3); vv(0.8,-0.8); vv(-0.3,-0.8); el;
-  fl_begin_line(); vv(-0.8,0.8); vv(-0.3,0.3); fl_end_line();
-  fl_begin_line(); vv(0.3,0.8); vv(0.8,0.3); fl_end_line();
-  fl_begin_line(); vv(0.3,-0.3); vv(0.8,-0.8); fl_end_line();
-  fl_begin_line(); vv(-0.8,-0.3); vv(-0.3,-0.8); fl_end_line();
-}
-
-void gmsh_rotate(Fl_Color c)
-{
-  fl_color(c);
-  fl_begin_line(); fl_arc(0.0, -0.1, 0.7, 0.0, 270.0); fl_end_line();
-  fl_begin_polygon(); vv(0.5,0.6); vv(-0.1,0.9); vv(-0.1,0.3); fl_end_polygon();
-}
-
-void gmsh_models(Fl_Color c)
-{
-  fl_color(c);
-  bl; vv(-0.8,-0.8); vv(-0.3,-0.8); vv(-0.3,-0.3); vv(-0.8,-0.3); el;
-  bl; vv(0.3,-0.8); vv(0.8,-0.8); vv(0.8,-0.3); vv(0.3,-0.3); el;
-  bl; vv(-0.8,0.3); vv(-0.3,0.3); vv(-0.3,0.8); vv(-0.8,0.8); el;
-  bl; vv(0.3,0.3); vv(0.8,0.3); vv(0.8,0.8); vv(0.3,0.8); el;
-}
-
-#undef vv
-#undef bl
-#undef el
-
-void GUI::create_graphic_window()
-{
-  if(g_window) {
-    g_window->show();
-    return;
-  }
-
-  fl_add_symbol("gmsh_rewind", gmsh_rewind, 1);
-  fl_add_symbol("gmsh_back", gmsh_back, 1);
-  fl_add_symbol("gmsh_play", gmsh_play, 1);
-  fl_add_symbol("gmsh_pause", gmsh_pause, 1);
-  fl_add_symbol("gmsh_forward", gmsh_forward, 1);
-  fl_add_symbol("gmsh_ortho", gmsh_ortho, 1);
-  fl_add_symbol("gmsh_rotate", gmsh_rotate, 1);
-  fl_add_symbol("gmsh_models", gmsh_models, 1);
-
-  int sh = 2 * fontsize - 4;    // status bar height
-  int sw = fontsize + 3;        // status button width
-  int width = CTX.tmp_viewport[2] - CTX.tmp_viewport[0];
-  int glheight = CTX.tmp_viewport[3] - CTX.tmp_viewport[1];
-  int height = glheight + sh;
-
-  // the graphic window is the main window: it should be a normal
-  // window (neither modal nor non-modal)
-  g_window = new Main_Window(width, height, false);
-  g_window->callback(file_quit_cb);
-
-  // bottom button bar
-
-  Fl_Box *bottom = new Fl_Box(0, glheight, width, sh);
-  bottom->box(FL_FLAT_BOX);
-
-  int x = 2;
-  int sht = sh - 4; // leave a 2 pixel border at the bottom
-
-  g_status_butt[5] = new Fl_Button(x, glheight + 2, sw, sht, "@-1gmsh_models");
-  x += sw;
-  g_status_butt[5]->callback(status_xyz1p_cb, (void *)"model");
-  g_status_butt[5]->tooltip("Change current model");
-
-  g_status_butt[0] = new Fl_Button(x, glheight + 2, sw, sht, "X");
-  x += sw;
-  g_status_butt[0]->callback(status_xyz1p_cb, (void *)"x");
-  g_status_butt[0]->tooltip("Set +X or -X view (Alt+x or Alt+Shift+x)");
-
-  g_status_butt[1] = new Fl_Button(x, glheight + 2, sw, sht, "Y");
-  x += sw;
-  g_status_butt[1]->callback(status_xyz1p_cb, (void *)"y");
-  g_status_butt[1]->tooltip("Set +Y or -Y view (Alt+y or Alt+Shift+y)");
-
-  g_status_butt[2] = new Fl_Button(x, glheight + 2, sw, sht, "Z");
-  x += sw;
-  g_status_butt[2]->callback(status_xyz1p_cb, (void *)"z");
-  g_status_butt[2]->tooltip("Set +Z or -Z view (Alt+z or Alt+Shift+z)");
-
-  g_status_butt[4] = new Fl_Button(x, glheight + 2, sw, sht, "@-1gmsh_rotate");
-  x += sw;
-  g_status_butt[4]->callback(status_xyz1p_cb, (void *)"r");
-  g_status_butt[4]->tooltip("Rotate +90 or -90 degrees");
-
-  g_status_butt[3] = new Fl_Button(x, glheight + 2, 2 * fontsize, sht, "1:1");
-  x += 2 * fontsize;
-  g_status_butt[3]->callback(status_xyz1p_cb, (void *)"1:1");
-  g_status_butt[3]->tooltip("Set unit scale");
-
-  g_status_butt[8] = new Fl_Button(x, glheight + 2, sw, sht, "@-1gmsh_ortho");
-  x += sw;
-  g_status_butt[8]->callback(status_xyz1p_cb, (void *)"p");
-  g_status_butt[8]->tooltip("Toggle projection mode (Alt+o or Alt+Shift+o)");
-
-  g_status_butt[9] = new Fl_Button(x, glheight + 2, sw, sht, "S");
-  x += sw;
-  g_status_butt[9]->callback(status_xyz1p_cb, (void *)"S");
-  g_status_butt[9]->tooltip("Toggle mouse selection ON/OFF (Escape)");
-
-  g_status_butt[6] = new Fl_Button(x, glheight + 2, sw, sht, "@-1gmsh_rewind");
-  x += sw;
-  g_status_butt[6]->callback(status_rewind_cb);
-  g_status_butt[6]->tooltip("Rewind animation");
-  g_status_butt[6]->deactivate();
-
-  g_status_butt[10] = new Fl_Button(x, glheight + 2, sw, sht, "@-1gmsh_back");
-  x += sw;
-  g_status_butt[10]->callback(status_stepbackward_cb);
-  g_status_butt[10]->tooltip("Step backward");
-  g_status_butt[10]->deactivate();
-
-  g_status_butt[7] = new Fl_Button(x, glheight + 2, sw, sht, "@-1gmsh_play");
-  x += sw;
-  g_status_butt[7]->callback(status_play_cb);
-  g_status_butt[7]->tooltip("Play/pause animation");
-  g_status_butt[7]->deactivate();
-
-  g_status_butt[11] = new Fl_Button(x, glheight + 2, sw, sht, "@-1gmsh_forward");
-  x += sw;
-  g_status_butt[11]->callback(status_stepforward_cb);
-  g_status_butt[11]->tooltip("Step forward");
-  g_status_butt[11]->deactivate();
-
-  for(int i = 0; i < 12; i++) {
-    g_status_butt[i]->box(FL_FLAT_BOX);
-    g_status_butt[i]->selection_color(FL_WHITE);
-    g_status_butt[i]->align(FL_ALIGN_CENTER | FL_ALIGN_INSIDE | FL_ALIGN_CLIP);
-  }
-
-  x += 2;
-  int wleft = (width - x) / 3 - 1;
-  int wright = (width - x) - (width - x) / 3 - 1;
-
-  g_status_label[0] = new Fl_Box(x, glheight + 2, wleft, sht);
-  g_status_label[1] = new Fl_Box(x + (width - x) / 3, glheight + 2, wright, sht);
-  for(int i = 0; i < 2; i++) {
-    g_status_label[i]->box(FL_THIN_DOWN_BOX);
-    g_status_label[i]->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE | FL_ALIGN_CLIP);
-  }
-
-  // dummy resizable box
-  Dummy_Box *resize_box = new Dummy_Box(x, 0, width - x, glheight);
-  g_window->resizable(resize_box);
-
-  // opengl window
-  g_opengl_window = new Opengl_Window(0, 0, width, glheight);
-  int mode = FL_RGB | FL_DEPTH | (CTX.db ? FL_DOUBLE : FL_SINGLE);
-  if(CTX.antialiasing) mode |= FL_MULTISAMPLE;
-  g_opengl_window->mode(mode);
-  g_opengl_window->end();
-
-  g_window->position(CTX.gl_position[0], CTX.gl_position[1]);
-  g_window->end();
-}
-
-// Set the size of the graphical window
-
-void GUI::set_size(int new_w, int new_h)
-{
-  g_window->size(new_w, new_h + g_window->h() - g_opengl_window->h());
-}
-
-// Set graphic window title
-
-void GUI::set_title(const char *str)
-{
-  // FIXME shoud use copy_label, but broken for Fl_Windows in fltk 1.1.7
-  g_window->label(str);
-}
-
-// Update GUI when views get added or deleted
-
-void GUI::update_views()
-{
-  check_anim_buttons();
-  if(get_context() == 3)
-    set_context(menu_post, 0);
-  reset_option_browser();
-  reset_plugin_view_browser();
-  reset_clip_browser();
-  reset_external_view_list();
-  load_field_view_list();
-}
-
-// Set animation button
-
-void GUI::set_anim_buttons(int mode)
-{
-  if(mode) {
-    g_status_butt[7]->callback(status_play_cb);
-    g_status_butt[7]->label("@-1gmsh_play");
-  }
-  else {
-    g_status_butt[7]->callback(status_pause_cb);
-    g_status_butt[7]->label("@-1gmsh_pause");
-  }
-}
-
-void GUI::check_anim_buttons()
-{
-  bool play = false;
-  if(CTX.post.anim_cycle){
-    play = true;
-  }
-  else{
-    for(unsigned int i = 0; i < PView::list.size(); i++){
-      if(PView::list[i]->getData()->getNumTimeSteps() > 1){
-        play = true;
-        break;
-      }
-    }
-  }
-  if(play){
-    g_status_butt[6]->activate();
-    g_status_butt[7]->activate();
-    g_status_butt[10]->activate();
-    g_status_butt[11]->activate();
-  }
-  else{
-    g_status_butt[6]->deactivate();
-    g_status_butt[7]->deactivate();
-    g_status_butt[10]->deactivate();
-    g_status_butt[11]->deactivate();
-  }
-}
-
-// Set the status messages
-
-void GUI::set_status(const char *msg, int num)
-{
-  if(num == 0 || num == 1){
-    static char buff[2][1024];
-    strncpy(buff[num], msg, sizeof(buff[num]) - 1);
-    buff[num][sizeof(buff[num]) - 1] = '\0';
-    g_status_label[num]->label(buff[num]);
-    g_status_label[num]->redraw();
-  }
-  else if(num == 2){
-    int n = strlen(msg);
-    int i = 0;
-    while(i < n) if(msg[i++] == '\n') break;
-    strncpy(onscreen_buffer[0], msg, sizeof(onscreen_buffer[0]) - 1);
-    if(i < n) 
-      strncpy(onscreen_buffer[1], &msg[i], sizeof(onscreen_buffer[1]) - 1);
-    else
-      onscreen_buffer[1][0] = '\0';
-    onscreen_buffer[0][i-1] = '\0';
-    redraw_opengl();
-  }
-}
-
-void GUI::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;
-    }
-  }
-}
-
-// set the current drawing context 
-
-void GUI::make_opengl_current()
-{
-  g_opengl_window->make_current();
-}
-
-// Draw the opengl window
-
-void GUI::redraw_opengl()
-{
-  g_opengl_window->make_current();
-  g_opengl_window->redraw();
-  check();
-}
-
-// Create the option window
-
-void GUI::hide_all_option_groups()
-{
-  gen_group->hide();
-  geo_group->hide();
-  mesh_group->hide();
-  solver_group->hide();
-  post_group->hide();
-  view_group->hide();
-}
-
-void GUI::create_general_options_window()
-{
-  create_option_window();
-  hide_all_option_groups();
-  gen_group->show();
-  opt_browser->value(1);
-  opt_window->label("Options - General");
-}
-
-void GUI::create_geometry_options_window()
-{
-  create_option_window();
-  hide_all_option_groups();
-  geo_group->show();
-  opt_browser->value(2);
-  opt_window->label("Options - Geometry");
-}
-
-void GUI::create_mesh_options_window()
-{
-  create_option_window();
-  hide_all_option_groups();
-  mesh_group->show();
-  opt_browser->value(3);
-  opt_window->label("Options - Mesh");
-}
-
-void GUI::create_solver_options_window()
-{
-  create_option_window();
-  hide_all_option_groups();
-  solver_group->show();
-  opt_browser->value(4);
-  opt_window->label("Options - Solver");
-}
-
-void GUI::create_post_options_window()
-{
-  create_option_window();
-  hide_all_option_groups();
-  post_group->show();
-  opt_browser->value(5);
-  opt_window->label("Options - Post-processing");
-}
-
-void GUI::create_view_options_window(int num)
-{
-  create_option_window();
-  hide_all_option_groups();
-  update_view_window(num);
-  view_group->show();
-  opt_browser->value(6 + num);
-  static char str[128];
-  sprintf(str, "Options - View [%d]", num);
-  opt_window->label(str);
-}
-
-void GUI::reset_option_browser()
-{
-  char str[128];
-  int select = opt_browser->value();
-  opt_browser->clear();
-  opt_browser->add("General");
-  opt_browser->add("Geometry");
-  opt_browser->add("Mesh");
-  opt_browser->add("Solver");
-  opt_browser->add("Post-pro");
-  for(unsigned int i = 0; i < PView::list.size(); i++) {
-    sprintf(str, "View [%d]", i);
-    opt_browser->add(str);
-  }
-  int item = (select <= opt_browser->size()) ? select : opt_browser->size();
-
-  opt_browser->value(item);
-  hide_all_option_groups();
-  switch(item){
-  case 0: case 1: gen_group->show(); break;
-  case 2: geo_group->show(); break;
-  case 3: mesh_group->show(); break;
-  case 4: solver_group->show(); break;
-  case 5: post_group->show(); break;
-  default: update_view_window(item - 6); view_group->show(); break;
-  }
-}
-
-void GUI::reset_external_view_list()
-{
-  char str[32];
-  view_choice[10]->clear();
-  view_choice[11]->clear();
-  view_choice[10]->add("Self");
-  view_choice[11]->add("Self");
-  for(unsigned int i = 0; i < PView::list.size(); i++) {
-    sprintf(str, "View [%d]", i);
-    view_choice[10]->add(str, 0, NULL);
-    view_choice[11]->add(str, 0, NULL);
-  }
-  if(view_number >= 0){
-    opt_view_external_view(view_number, GMSH_GUI, 0);
-    opt_view_gen_raise_view(view_number, GMSH_GUI, 0);
-  }
-}
-
-void GUI::create_option_window()
-{
-  int width = 34 * fontsize + WB;
-  int height = 13 * BH + 5 * WB;
-  int L = 7 * fontsize;
-
-  if(opt_window) {
-    opt_window->show();
-    return;
-  }
-
-  opt_window = new Dialog_Window(width, height, CTX.non_modal_windows);
-  opt_window->box(GMSH_WINDOW_BOX);
-
-  // Buttons
-
-  {
-    Fl_Button *o = new Fl_Button(width - BB - WB, height - BH - WB, BB, BH, "Cancel");
-    o->callback(cancel_cb, (void *)opt_window);
-  }
-  {
-    Fl_Button *o = new Fl_Button((int)(width - 2.5 * BB - 2 * WB), height - BH - WB, (int)(1.5 * BB), BH, "Save as defaults");
-    o->callback(options_save_cb);
-  }
-  {
-    opt_redraw = new Fl_Return_Button((int)(width - 3.5 * BB - 3 * WB), height - BH - WB, BB, BH, "Redraw");
-    opt_redraw->callback(redraw_cb);
-  }
-
-  // Selection browser
-
-  opt_browser = new Fl_Hold_Browser(WB, WB, L - WB, height - 3 * WB - BH);
-  opt_browser->has_scrollbar(Fl_Browser_::VERTICAL);
-  opt_browser->add("General");
-  opt_browser->add("Geometry");
-  opt_browser->add("Mesh");
-  opt_browser->add("Solver");
-  opt_browser->add("Post-pro");
-  opt_browser->callback(options_browser_cb);
-  opt_browser->value(1);
-  opt_window->label("Options - General");
-
-  width -= L;
-  int BW = width - 4 * WB;
-  height -= WB + BH;
-
-  // General options
-
-  gen_group = new Fl_Group(L, 0, width, height, "General Options");
-  {
-    Fl_Tabs *o = new Fl_Tabs(L + WB, WB, width - 2 * WB, height - 2 * WB);
-    {
-      Fl_Group *o = new Fl_Group(L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "General");
-
-      gen_butt[10] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 1 * BH, BW, BH, "Enable expert mode");
-      gen_butt[10]->type(FL_TOGGLE_BUTTON);
-      gen_butt[10]->callback(general_options_ok_cb);
-
-      gen_butt[13] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 2 * BH, BW, BH, "Show tooltips");
-      gen_butt[13]->type(FL_TOGGLE_BUTTON);
-      gen_butt[13]->callback(general_options_ok_cb);
-
-      gen_butt[6] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 3 * BH, BW, BH, "Show bounding boxes");
-      gen_butt[6]->tooltip("(Alt+b)");
-      gen_butt[6]->type(FL_TOGGLE_BUTTON);
-      gen_butt[6]->callback(general_options_ok_cb);
-
-      gen_butt[2] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 4 * BH, BW, BH, "Draw simplified model during user interaction");
-      gen_butt[2]->tooltip("(Alt+f)");
-      gen_butt[2]->type(FL_TOGGLE_BUTTON);
-      gen_butt[2]->callback(general_options_ok_cb, (void*)"fast_redraw");
-
-      gen_butt[11] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 5 * BH, BW, BH, "Enable mouse hover over meshes");
-      gen_butt[11]->type(FL_TOGGLE_BUTTON);
-      gen_butt[11]->callback(general_options_ok_cb);
-
-      gen_butt[3] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 6 * BH, BW, BH, "Enable double buffering");
-      gen_butt[3]->type(FL_TOGGLE_BUTTON);
-      gen_butt[3]->callback(general_options_ok_cb);
-
-      gen_butt[12] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 7 * BH, BW, BH, "Enable antialiasing");
-      gen_butt[12]->type(FL_TOGGLE_BUTTON);
-      gen_butt[12]->callback(general_options_ok_cb);
-
-      gen_butt[5] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 8 * BH, BW, BH, "Use trackball rotation instead of Euler angles");
-      gen_butt[5]->type(FL_TOGGLE_BUTTON);
-      gen_butt[5]->callback(general_options_ok_cb);
-
-      gen_butt[15] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 9 * BH, BW, BH, "Rotate around pseudo center of mass");
-      gen_butt[15]->type(FL_TOGGLE_BUTTON);
-      gen_butt[15]->callback(general_options_ok_cb, (void*)"rotation_center");
-
-      gen_push_butt[0] = new Fl_Button(L + 2 * IW - 2 * WB, 2 * WB + 10 * BH, BB, BH, "Select");
-      gen_push_butt[0]->callback(general_options_rotation_center_select_cb);
-
-      gen_value[8] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 10 * BH, IW / 3, BH);
-      gen_value[8]->callback(general_options_ok_cb, (void*)"rotation_center_coord");
-      gen_value[9] = new Fl_Value_Input(L + 2 * WB + IW / 3, 2 * WB + 10 * BH, IW / 3, BH);
-      gen_value[9]->callback(general_options_ok_cb, (void*)"rotation_center_coord");
-      gen_value[10] = new Fl_Value_Input(L + 2 * WB + 2 * IW / 3, 2 * WB + 10 * BH, IW / 3, BH, "Rotation center");
-      gen_value[10]->align(FL_ALIGN_RIGHT);
-      gen_value[10]->callback(general_options_ok_cb, (void*)"rotation_center_coord");
-
-      o->end();
-    }
-    {
-      Fl_Group *o = new Fl_Group(L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Axes");
-
-      gen_choice[4] = new Fl_Choice(L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "Axes mode");
-      gen_choice[4]->menu(menu_axes_mode);
-      gen_choice[4]->align(FL_ALIGN_RIGHT);
-      gen_choice[4]->tooltip("(Alt+a)");
-      gen_choice[4]->callback(general_options_ok_cb, (void*)"general_axes");
-
-      gen_butt[16] = new Fl_Check_Button(L + width - (int)(0.85*IW) - 2 * WB, 2 * WB + 1 * BH, (int)(0.85*IW), BH, "Mikado style");
-      gen_butt[16]->type(FL_TOGGLE_BUTTON);
-      gen_butt[16]->callback(general_options_ok_cb);
-
-      gen_value[17] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 2 * BH, IW / 3, BH);
-      gen_value[17]->minimum(0.);
-      gen_value[17]->step(1);
-      gen_value[17]->maximum(100);
-      gen_value[17]->callback(general_options_ok_cb);
-      gen_value[18] = new Fl_Value_Input(L + 2 * WB + 1*IW/3, 2 * WB + 2 * BH, IW / 3, BH);
-      gen_value[18]->minimum(0.);
-      gen_value[18]->step(1);
-      gen_value[18]->maximum(100);
-      gen_value[18]->callback(general_options_ok_cb);
-      gen_value[19] = new Fl_Value_Input(L + 2 * WB + 2*IW/3, 2 * WB + 2 * BH, IW / 3, BH, "Axes tics");
-      gen_value[19]->minimum(0.);
-      gen_value[19]->step(1);
-      gen_value[19]->maximum(100);
-      gen_value[19]->align(FL_ALIGN_RIGHT);
-      gen_value[19]->callback(general_options_ok_cb);
-
-      gen_input[3] = new Fl_Input(L + 2 * WB, 2 * WB + 3 * BH, IW/3, BH);
-      gen_input[3]->callback(general_options_ok_cb);
-      gen_input[4] = new Fl_Input(L + 2 * WB + 1*IW/3, 2 * WB + 3 * BH, IW/3, BH);
-      gen_input[4]->callback(general_options_ok_cb);
-      gen_input[5] = new Fl_Input(L + 2 * WB + 2*IW/3, 2 * WB + 3 * BH, IW/3, BH, "Axes format");
-      gen_input[5]->align(FL_ALIGN_RIGHT);
-      gen_input[5]->callback(general_options_ok_cb);
-      
-      gen_input[6] = new Fl_Input(L + 2 * WB, 2 * WB + 4 * BH, IW/3, BH);
-      gen_input[6]->callback(general_options_ok_cb);
-      gen_input[7] = new Fl_Input(L + 2 * WB + 1*IW/3, 2 * WB + 4 * BH, IW/3, BH);
-      gen_input[7]->callback(general_options_ok_cb);
-      gen_input[8] = new Fl_Input(L + 2 * WB + 2*IW/3, 2 * WB + 4 * BH, IW/3, BH, "Axes labels");
-      gen_input[8]->align(FL_ALIGN_RIGHT);
-      gen_input[8]->callback(general_options_ok_cb);
-
-      gen_butt[0] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 5 * BH, BW, BH, "Set position and size of axes automatically");
-      gen_butt[0]->type(FL_TOGGLE_BUTTON);
-      gen_butt[0]->callback(general_options_ok_cb, (void*)"general_axes_auto");
-      
-      gen_value[20] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 6 * BH, IW / 3, BH);
-      gen_value[20]->callback(general_options_ok_cb);
-      gen_value[21] = new Fl_Value_Input(L + 2 * WB + IW / 3, 2 * WB + 6 * BH, IW / 3, BH);
-      gen_value[21]->callback(general_options_ok_cb);
-      gen_value[22] = new Fl_Value_Input(L + 2 * WB + 2 * IW / 3, 2 * WB + 6 * BH, IW / 3, BH, "Axes minimum");
-      gen_value[22]->align(FL_ALIGN_RIGHT);
-      gen_value[22]->callback(general_options_ok_cb);
-
-      gen_value[23] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 7 * BH, IW / 3, BH);
-      gen_value[23]->callback(general_options_ok_cb);
-      gen_value[24] = new Fl_Value_Input(L + 2 * WB + IW / 3, 2 * WB + 7 * BH, IW / 3, BH);
-      gen_value[24]->callback(general_options_ok_cb);
-      gen_value[25] = new Fl_Value_Input(L + 2 * WB + 2 * IW / 3, 2 * WB + 7 * BH, IW / 3, BH, "Axes maximum");
-      gen_value[25]->align(FL_ALIGN_RIGHT);
-      gen_value[25]->callback(general_options_ok_cb);
-
-      gen_butt[1] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 8 * BH, BW, BH, "Show small axes");
-      gen_butt[1]->tooltip("(Alt+Shift+a)");
-      gen_butt[1]->type(FL_TOGGLE_BUTTON);
-      gen_butt[1]->callback(general_options_ok_cb, (void*)"general_small_axes");
-
-      gen_value[26] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 9 * BH, IW / 2, BH);
-      gen_value[26]->minimum(-2000);
-      gen_value[26]->maximum(2000);
-      gen_value[26]->step(1);
-      gen_value[26]->callback(general_options_ok_cb);
-      gen_value[27] = new Fl_Value_Input(L + 2 * WB + IW / 2, 2 * WB + 9 * BH, IW / 2, BH, "Small axes position");
-      gen_value[27]->align(FL_ALIGN_RIGHT);
-      gen_value[27]->minimum(-2000);
-      gen_value[27]->maximum(2000);
-      gen_value[27]->step(1);
-      gen_value[27]->callback(general_options_ok_cb);
-
-      o->end();
-    }
-    {
-      Fl_Group *o = new Fl_Group(L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Output");
-      gen_butt[7] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 1 * BH, BW, BH, "Print messages on terminal");
-      gen_butt[7]->type(FL_TOGGLE_BUTTON);
-      gen_butt[7]->callback(general_options_ok_cb);
-
-      gen_butt[8] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 2 * BH, BW, BH, "Save session information on exit");
-      gen_butt[8]->type(FL_TOGGLE_BUTTON);
-      gen_butt[8]->callback(general_options_ok_cb);
-
-      gen_butt[9] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 3 * BH, BW/2-WB, BH, "Save options on exit");
-      gen_butt[9]->type(FL_TOGGLE_BUTTON);
-      gen_butt[9]->callback(general_options_ok_cb);
-
-      Fl_Button *b0 = new Fl_Button(L + width / 2, 2 * WB + 3 * BH, (int)(1.75*BB), BH, "Restore default options");
-      b0->callback(options_restore_defaults_cb);
-
-      gen_butt[14] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 4 * BH, BW, BH, "Ask confirmation before overwriting files");
-      gen_butt[14]->type(FL_TOGGLE_BUTTON);
-      gen_butt[14]->callback(general_options_ok_cb);
-
-      gen_value[5] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Message verbosity");
-      gen_value[5]->minimum(0);
-      gen_value[5]->maximum(10);
-      gen_value[5]->step(1);
-      gen_value[5]->align(FL_ALIGN_RIGHT);
-      gen_value[5]->callback(general_options_ok_cb);
-
-      gen_input[0] = new Fl_Input(L + 2 * WB, 2 * WB + 6 * BH, IW, BH, "Default file name");
-      gen_input[0]->align(FL_ALIGN_RIGHT);
-      gen_input[0]->callback(general_options_ok_cb);
-
-      o->end();
-    }
-    {
-      Fl_Group *o = new Fl_Group(L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Helpers");
-
-      gen_input[1] = new Fl_Input(L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "Text editor command");
-      gen_input[1]->align(FL_ALIGN_RIGHT);
-      gen_input[1]->callback(general_options_ok_cb);
-
-      gen_input[2] = new Fl_Input(L + 2 * WB, 2 * WB + 2 * BH, IW, BH, "Web browser command");
-      gen_input[2]->align(FL_ALIGN_RIGHT);
-      gen_input[2]->callback(general_options_ok_cb);
-
-      o->end();
-    }
-    {
-      Fl_Group *o = new Fl_Group(L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Aspect");
-      o->hide();
-
-      static Fl_Menu_Item menu_projection[] = {
-        {"Orthographic", 0, 0, 0},
-        {"Perspective", 0, 0, 0},
-        {0}
-      };
-      gen_choice[2] = new Fl_Choice(L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "Projection mode");
-      gen_choice[2]->menu(menu_projection);
-      gen_choice[2]->align(FL_ALIGN_RIGHT);
-      gen_choice[2]->tooltip("(Alt+o)");
-      gen_choice[2]->callback(general_options_ok_cb);
-
-      gen_value[14] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 2 * BH, IW, BH, "Z-clipping distance factor");
-      gen_value[14]->minimum(0.1);
-      gen_value[14]->maximum(10.);
-      gen_value[14]->step(0.1);
-      gen_value[14]->align(FL_ALIGN_RIGHT);
-      gen_value[14]->callback(general_options_ok_cb);
-
-      gen_value[15] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 3 * BH, IW/2, BH);
-      gen_value[15]->minimum(0.);
-      gen_value[15]->maximum(10.);
-      gen_value[15]->step(0.01);
-      gen_value[15]->align(FL_ALIGN_RIGHT);
-      gen_value[15]->callback(general_options_ok_cb);
-
-      gen_value[16] = new Fl_Value_Input(L + 2 * WB + IW/2, 2 * WB + 3 * BH, IW/2, BH, "Polygon offset factor/units");
-      gen_value[16]->minimum(0.);
-      gen_value[16]->maximum(10.);
-      gen_value[16]->step(0.01);
-      gen_value[16]->align(FL_ALIGN_RIGHT);
-      gen_value[16]->callback(general_options_ok_cb);
-
-      gen_butt[4] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 4 * BH, BW, BH, "Always apply polygon offset");
-      gen_butt[4]->type(FL_TOGGLE_BUTTON);
-      gen_butt[4]->callback(general_options_ok_cb);
-
-      gen_value[11] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Quadric subdivisions");
-      gen_value[11]->minimum(3);
-      gen_value[11]->maximum(30);
-      gen_value[11]->step(1);
-      gen_value[11]->align(FL_ALIGN_RIGHT);
-      gen_value[11]->callback(general_options_ok_cb);
-
-      gen_value[6] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 6 * BH, IW, BH, "Point size");
-      gen_value[6]->minimum(0.1);
-      gen_value[6]->maximum(50);
-      gen_value[6]->step(0.1);
-      gen_value[6]->align(FL_ALIGN_RIGHT);
-      gen_value[6]->callback(general_options_ok_cb);
-
-      gen_value[7] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 7 * BH, IW, BH, "Line width");
-      gen_value[7]->minimum(0.1);
-      gen_value[7]->maximum(50);
-      gen_value[7]->step(0.1);
-      gen_value[7]->align(FL_ALIGN_RIGHT);
-      gen_value[7]->callback(general_options_ok_cb);
-      
-      static Fl_Menu_Item menu_genvectype[] = {
-        {"Line", 0, 0, 0},
-        {"Arrow", 0, 0, 0},
-        {"Pyramid", 0, 0, 0},
-        {"3D arrow", 0, 0, 0},
-        {0}
-      };
-      gen_choice[0] = new Fl_Choice(L + 2 * WB, 2 * WB + 8 * BH, IW, BH, "Vector display");
-      gen_choice[0]->menu(menu_genvectype);
-      gen_choice[0]->align(FL_ALIGN_RIGHT);
-      gen_choice[0]->callback(general_options_ok_cb);
-
-      Fl_Button *b = new Fl_Button(L + 2 * IW - 2 * WB, 2 * WB + 8 * BH, BB, BH, "Edit arrow");
-      b->callback(general_arrow_param_cb);
-
-      gen_choice[1] = new Fl_Choice(L + 2 * WB, 2 * WB + 9 * BH, IW, BH, "Font");
-      gen_choice[1]->menu(menu_font_names);
-      gen_choice[1]->align(FL_ALIGN_RIGHT);
-      gen_choice[1]->callback(general_options_ok_cb);
-
-      gen_value[12] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 10 * BH, IW, BH, "Font size");
-      gen_value[12]->minimum(5);
-      gen_value[12]->maximum(40);
-      gen_value[12]->step(1);
-      gen_value[12]->align(FL_ALIGN_RIGHT);
-      gen_value[12]->callback(general_options_ok_cb);
-
-      o->end();
-    }
-    {
-      Fl_Group *o = new Fl_Group(L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Color");
-      o->hide();
-
-      gen_value[2] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 1 * BH, IW/3, BH);
-      gen_value[2]->minimum(-1.);
-      gen_value[2]->maximum(1.);
-      gen_value[2]->step(0.01);
-      gen_value[2]->callback(general_options_ok_cb, (void*)"light_value");
-
-      gen_value[3] = new Fl_Value_Input(L + 2 * WB + IW / 3, 2 * WB + 1 * BH, IW/3, BH);
-      gen_value[3]->minimum(-1.);
-      gen_value[3]->maximum(1.);
-      gen_value[3]->step(0.01);
-      gen_value[3]->callback(general_options_ok_cb, (void*)"light_value");
-
-      gen_value[4] = new Fl_Value_Input(L + 2 * WB + 2 * IW / 3, 2 * WB + 1 * BH, IW/3, BH, "Light position");
-      gen_value[4]->minimum(-1.);
-      gen_value[4]->maximum(1.);
-      gen_value[4]->step(0.01);
-      gen_value[4]->align(FL_ALIGN_RIGHT);
-      gen_value[4]->callback(general_options_ok_cb, (void*)"light_value");
-
-      gen_value[13] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 2 * BH, IW, BH, "Light position divisor");
-      gen_value[13]->minimum(0.);
-      gen_value[13]->maximum(1.);
-      gen_value[13]->step(0.01);
-      gen_value[13]->align(FL_ALIGN_RIGHT);
-      gen_value[13]->callback(general_options_ok_cb);
-
-      gen_sphere = new SpherePosition_Widget(L + width - 2 * BH - 2 * WB, 2 * WB + 1 * BH, 2 * BH);
-      gen_sphere->callback(general_options_ok_cb, (void*)"light_sphere");
-
-      gen_value[1] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 3 * BH, IW/2, BH);
-      gen_value[1]->minimum(0);
-      gen_value[1]->maximum(10);
-      gen_value[1]->step(0.1);
-      gen_value[1]->callback(general_options_ok_cb);
-      gen_value[0] = new Fl_Value_Input(L + 2 * WB + IW/2, 2 * WB + 3 * BH, IW/2, BH, "Material shininess/exponent");
-      gen_value[0]->minimum(0);
-      gen_value[0]->maximum(128);
-      gen_value[0]->step(1);
-      gen_value[0]->align(FL_ALIGN_RIGHT);
-      gen_value[0]->callback(general_options_ok_cb);
-
-      static Fl_Menu_Item menu_color_scheme[] = {
-        {"Dark", 0, 0, 0},
-        {"Light", 0, 0, 0},
-        {"Grayscale", 0, 0, 0},
-        {0}
-      };
-
-      gen_choice[3] = new Fl_Choice(L + 2 * WB, 2 * WB + 4 * BH, IW, BH, "Predefined color scheme");
-      gen_choice[3]->menu(menu_color_scheme);
-      gen_choice[3]->align(FL_ALIGN_RIGHT);
-      gen_choice[3]->tooltip("(Alt+c)");
-      gen_choice[3]->callback(general_options_color_scheme_cb);
-
-      static Fl_Menu_Item menu_bg_grad[] = {
-        {"None", 0, 0, 0},
-        {"Vertical", 0, 0, 0},
-        {"Horizontal", 0, 0, 0},
-        {"Radial", 0, 0, 0},
-        {0}
-      };
-
-      gen_choice[5] = new Fl_Choice(L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Background gradient");
-      gen_choice[5]->menu(menu_bg_grad);
-      gen_choice[5]->align(FL_ALIGN_RIGHT);
-      gen_choice[5]->callback(general_options_ok_cb);
-
-      Fl_Scroll *s = new Fl_Scroll(L + 2 * WB, 3 * WB + 6 * BH, IW + 20, height - 5 * WB - 6 * BH);
-      int i = 0;
-      while(GeneralOptions_Color[i].str) {
-        gen_col[i] = new Fl_Button(L + 2 * WB, 3 * WB + (6 + i) * BH, IW, BH, GeneralOptions_Color[i].str);
-        gen_col[i]->callback(color_cb, (void *)GeneralOptions_Color[i].function);
-        i++;
-      }
-      s->end();
-
-      o->end();
-    }
-    o->end();
-  }
-  gen_group->end();
-
-  // Geometry options
-
-  geo_group = new Fl_Group(L, 0, width, height, "Geometry Options");
-  geo_group->hide();
-  {
-    Fl_Tabs *o = new Fl_Tabs(L + WB, WB, width - 2 * WB, height - 2 * WB);
-    {
-      Fl_Group *o = new Fl_Group(L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "General");
-      o->hide();
-
-      geo_value[2] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "Geometry tolerance");
-      geo_value[2]->align(FL_ALIGN_RIGHT);
-      geo_value[2]->callback(geometry_options_ok_cb);
-
-      geo_butt[8] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 2 * BH, BW, BH, "Remove duplicate entities in GEO models");
-      geo_butt[8]->type(FL_TOGGLE_BUTTON);
-      geo_butt[8]->callback(geometry_options_ok_cb);
-
-      geo_butt[11] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 3 * BH, BW, BH, "Remove small edges in OpenCascade models");
-      geo_butt[11]->type(FL_TOGGLE_BUTTON);
-      geo_butt[11]->callback(geometry_options_ok_cb);
-
-      geo_butt[12] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 4 * BH, BW, BH, "Remove small faces in OpenCascade models");
-      geo_butt[12]->type(FL_TOGGLE_BUTTON);
-      geo_butt[12]->callback(geometry_options_ok_cb);
-
-      geo_butt[13] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 5 * BH, BW, BH, "Sew faces in OpenCascade models");
-      geo_butt[13]->type(FL_TOGGLE_BUTTON);
-      geo_butt[13]->callback(geometry_options_ok_cb);
-
-#if !defined(HAVE_OCC)
-      geo_butt[11]->deactivate();
-      geo_butt[12]->deactivate();
-      geo_butt[13]->deactivate();
-#endif
-      o->end();
-    }
-    {
-      Fl_Group *o = new Fl_Group(L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Visibility");
-
-      geo_butt[0] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 1 * BH, BW / 2 - WB, BH, "Points");
-      geo_butt[0]->tooltip("(Alt+p)");
-      geo_butt[0]->type(FL_TOGGLE_BUTTON);
-      geo_butt[0]->callback(geometry_options_ok_cb);
-      
-      geo_butt[1] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 2 * BH, BW / 2 - WB, BH, "Lines");
-      geo_butt[1]->tooltip("(Alt+l)");
-      geo_butt[1]->type(FL_TOGGLE_BUTTON);
-      geo_butt[1]->callback(geometry_options_ok_cb);
-
-      geo_butt[2] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 3 * BH, BW / 2 - WB, BH, "Surfaces");
-      geo_butt[2]->tooltip("(Alt+s)");
-      geo_butt[2]->type(FL_TOGGLE_BUTTON);
-      geo_butt[2]->callback(geometry_options_ok_cb);
-
-      geo_butt[3] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 4 * BH, BW / 2 - WB, BH, "Volumes");
-      geo_butt[3]->tooltip("(Alt+v)");
-      geo_butt[3]->type(FL_TOGGLE_BUTTON);
-      geo_butt[3]->callback(geometry_options_ok_cb);
-
-      geo_butt[4] = new Fl_Check_Button(L + width / 2, 2 * WB + 1 * BH, BW / 2 - WB, BH, "Point numbers");
-      geo_butt[4]->type(FL_TOGGLE_BUTTON);
-      geo_butt[4]->callback(geometry_options_ok_cb);
-
-      geo_butt[5] = new Fl_Check_Button(L + width / 2, 2 * WB + 2 * BH, BW / 2 - WB, BH, "Line numbers");
-      geo_butt[5]->type(FL_TOGGLE_BUTTON);
-      geo_butt[5]->callback(geometry_options_ok_cb);
-
-      geo_butt[6] = new Fl_Check_Button(L + width / 2, 2 * WB + 3 * BH, BW / 2 - WB, BH, "Surface numbers");
-      geo_butt[6]->type(FL_TOGGLE_BUTTON);
-      geo_butt[6]->callback(geometry_options_ok_cb);
-
-      geo_butt[7] = new Fl_Check_Button(L + width / 2, 2 * WB + 4 * BH, BW / 2 - WB, BH, "Volume numbers");
-      geo_butt[7]->type(FL_TOGGLE_BUTTON);
-      geo_butt[7]->callback(geometry_options_ok_cb);
-
-      geo_value[0] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Normals");
-      geo_value[0]->minimum(0);
-      geo_value[0]->maximum(500);
-      geo_value[0]->step(1);
-      geo_value[0]->align(FL_ALIGN_RIGHT);
-      geo_value[0]->when(FL_WHEN_RELEASE);
-      geo_value[0]->callback(geometry_options_ok_cb);
-
-      geo_value[1] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 6 * BH, IW, BH, "Tangents");
-      geo_value[1]->minimum(0);
-      geo_value[1]->maximum(500);
-      geo_value[1]->step(1);
-      geo_value[1]->align(FL_ALIGN_RIGHT);
-      geo_value[1]->when(FL_WHEN_RELEASE);
-      geo_value[1]->callback(geometry_options_ok_cb);
-
-      o->end();
-    }
-    {
-      Fl_Group *o = new Fl_Group(L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Aspect");
-      o->hide();
-
-      geo_choice[0] = new Fl_Choice(L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "Point display");
-      geo_choice[0]->menu(menu_point_display);
-      geo_choice[0]->align(FL_ALIGN_RIGHT);
-      geo_choice[0]->callback(geometry_options_ok_cb);
-
-      geo_value[3] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 2 * BH, IW, BH, "Point size");
-      geo_value[3]->minimum(0.1);
-      geo_value[3]->maximum(50);
-      geo_value[3]->step(0.1);
-      geo_value[3]->align(FL_ALIGN_RIGHT);
-      geo_value[3]->callback(geometry_options_ok_cb);
-
-      geo_value[5] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 3 * BH, IW, BH, "Selected point size");
-      geo_value[5]->minimum(0.1);
-      geo_value[5]->maximum(50);
-      geo_value[5]->step(0.1);
-      geo_value[5]->align(FL_ALIGN_RIGHT);
-      geo_value[5]->callback(geometry_options_ok_cb);
-
-      geo_choice[1] = new Fl_Choice(L + 2 * WB, 2 * WB + 4 * BH, IW, BH, "Line display");
-      geo_choice[1]->menu(menu_line_display);
-      geo_choice[1]->align(FL_ALIGN_RIGHT);     
-      geo_choice[1]->callback(geometry_options_ok_cb);
-
-      geo_value[4] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Line width");
-      geo_value[4]->minimum(0.1);
-      geo_value[4]->maximum(50);
-      geo_value[4]->step(0.1);
-      geo_value[4]->align(FL_ALIGN_RIGHT);
-      geo_value[4]->callback(geometry_options_ok_cb);
-
-      geo_value[6] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 6 * BH, IW, BH, "Selected line width");
-      geo_value[6]->minimum(0.1);
-      geo_value[6]->maximum(50);
-      geo_value[6]->step(0.1);
-      geo_value[6]->align(FL_ALIGN_RIGHT);
-      geo_value[6]->callback(geometry_options_ok_cb);
-
-      geo_choice[2] = new Fl_Choice(L + 2 * WB, 2 * WB + 7 * BH, IW, BH, "Surface display");
-      geo_choice[2]->menu(menu_surface_display);
-      geo_choice[2]->align(FL_ALIGN_RIGHT);     
-      geo_choice[2]->callback(geometry_options_ok_cb);
-      geo_choice[2]->tooltip("(Alt+d)");
-
-      o->end();
-    }
-    {
-      Fl_Group *o = new Fl_Group(L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Color");
-      o->hide();
-
-      geo_butt[9] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 1 * BH, BW, BH, "Enable lighting");
-      geo_butt[9]->type(FL_TOGGLE_BUTTON);
-      geo_butt[9]->tooltip("(Alt+w)");
-      geo_butt[9]->callback(geometry_options_ok_cb);
-
-      geo_butt[14] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 2 * BH, BW, BH, "Use two-side lighting");
-      geo_butt[14]->type(FL_TOGGLE_BUTTON);
-      geo_butt[14]->callback(geometry_options_ok_cb);
-
-      geo_butt[10] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 3 * BH, BW, BH, "Highlight orphan entities");
-      geo_butt[10]->type(FL_TOGGLE_BUTTON);
-      geo_butt[10]->callback(geometry_options_ok_cb);
-
-      Fl_Scroll *s = new Fl_Scroll(L + 2 * WB, 2 * WB + 4 * BH, IW + 20, height - 4 * WB - 4 * BH);
-      int i = 0;
-      while(GeometryOptions_Color[i].str) {
-        geo_col[i] = new Fl_Button(L + 2 * WB, 2 * WB + (4 + i) * BH, IW, BH, GeometryOptions_Color[i].str);
-        geo_col[i]->callback(color_cb, (void *)GeometryOptions_Color[i].function);
-        i++;
-      }
-      s->end();
-
-      o->end();
-    }
-    o->end();
-  }
-  geo_group->end();
-
-  // Mesh options
-
-  mesh_group = new Fl_Group(L, 0, width, height, "Mesh Options");
-  mesh_group->hide();
-  {
-    Fl_Tabs *o = new Fl_Tabs(L + WB, WB, width - 2 * WB, height - 2 * WB);
-    {
-      Fl_Group *o = new Fl_Group(L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "General");
-      o->hide();
-
-      static Fl_Menu_Item menu_2d_algo[] = {
-        {"Frontal", 0, 0, 0},
-        {"Delaunay", 0, 0, 0},
-        {"MeshAdapt+Delaunay", 0, 0, 0},
-        {0}
-      };
-      static Fl_Menu_Item menu_3d_algo[] = {
-        {"Tetgen+Delaunay", 0, 0, 0},
-        {"Netgen", 0, 0, 0},
-        {0}
-      };
-      static Fl_Menu_Item menu_recombine_algo[] = {
-        {"Mixed Tri-Quads", 0, 0, 0},
-        {"All Quads", 0, 0, 0},
-        {0}
-      };
-
-      mesh_choice[2] = new Fl_Choice(L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "2D algorithm");
-      mesh_choice[2]->menu(menu_2d_algo);
-      mesh_choice[2]->align(FL_ALIGN_RIGHT);
-      mesh_choice[2]->callback(mesh_options_ok_cb);
-
-      mesh_choice[3] = new Fl_Choice(L + 2 * WB, 2 * WB + 2 * BH, IW, BH, "3D algorithm");
-      mesh_choice[3]->menu(menu_3d_algo);
-      mesh_choice[3]->align(FL_ALIGN_RIGHT);
-      mesh_choice[3]->callback(mesh_options_ok_cb);
-
-      mesh_choice[5] = new Fl_Choice(L + 2 * WB, 2 * WB + 3 * BH, IW, BH, "Recombine algorithm");
-      mesh_choice[5]->menu(menu_recombine_algo);
-      mesh_choice[5]->align(FL_ALIGN_RIGHT);
-      mesh_choice[5]->callback(mesh_options_ok_cb);
-
-      mesh_value[0] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 4 * BH, IW, BH, "Smoothing steps");
-      mesh_value[0]->minimum(0);
-      mesh_value[0]->maximum(100);
-      mesh_value[0]->step(1);
-      mesh_value[0]->align(FL_ALIGN_RIGHT);
-      mesh_value[0]->callback(mesh_options_ok_cb);
-
-      mesh_value[2] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Element size factor");
-      mesh_value[2]->minimum(0.001);
-      mesh_value[2]->maximum(1000);
-      mesh_value[2]->step(0.01);
-      mesh_value[2]->align(FL_ALIGN_RIGHT);
-      mesh_value[2]->callback(mesh_options_ok_cb);
-
-      mesh_value[25] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 6 * BH, IW, BH, "Minimum element size");
-      mesh_value[25]->align(FL_ALIGN_RIGHT);
-      mesh_value[25]->callback(mesh_options_ok_cb);
-
-      mesh_value[26] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 7 * BH, IW, BH, "Maximum element size");
-      mesh_value[26]->align(FL_ALIGN_RIGHT);
-      mesh_value[26]->callback(mesh_options_ok_cb);
-
-      mesh_value[3] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 8 * BH, IW, BH, "Element order");
-      mesh_value[3]->minimum(1);
-      // FIXME: this makes it possible to set > 2 by hand, but not by
-      // dragging (>2 is too buggy for general use)
-      mesh_value[3]->maximum(2);
-      mesh_value[3]->step(1);
-      mesh_value[3]->align(FL_ALIGN_RIGHT);
-      mesh_value[3]->callback(mesh_options_ok_cb);
-
-      mesh_butt[4] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 9 * BH, BW, BH, "Use incomplete high order elements");
-      mesh_butt[4]->type(FL_TOGGLE_BUTTON);
-      mesh_butt[4]->callback(mesh_options_ok_cb);
-
-      o->end();
-    }
-
-    {
-      Fl_Group *o = new Fl_Group(L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Advanced");
-      o->hide();
-
-      mesh_butt[5] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 1 * BH, BW, BH, "Compute element sizes using point values");
-      mesh_butt[5]->type(FL_TOGGLE_BUTTON);
-      mesh_butt[5]->callback(mesh_options_ok_cb);
-
-      mesh_butt[1] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 2 * BH, BW, BH, "Compute element sizes from curvature" );
-      mesh_butt[1]->type(FL_TOGGLE_BUTTON);
-      mesh_butt[1]->callback(mesh_options_ok_cb);
-
-      mesh_butt[16] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 3 * BH, BW, BH, "Extend element sizes from boundary");
-      mesh_butt[16]->type(FL_TOGGLE_BUTTON);
-      mesh_butt[16]->callback(mesh_options_ok_cb);
-
-      mesh_butt[2] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 4 * BH, BW, BH, "Optimize quality of tetrahedra");
-      mesh_butt[2]->type(FL_TOGGLE_BUTTON);
-      mesh_butt[2]->callback(mesh_options_ok_cb);
-
-      mesh_butt[24] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 5 * BH, BW, BH, "Optimize quality of tetrahedra with Netgen");
-      mesh_butt[24]->type(FL_TOGGLE_BUTTON);
-#if !defined(HAVE_NETGEN)
-      mesh_butt[24]->deactivate();
-#endif
-      mesh_butt[24]->callback(mesh_options_ok_cb);
-
-      mesh_butt[3] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 6 * BH, BW, BH, "Optimize high order mesh (2D-plane only)");
-      mesh_butt[3]->type(FL_TOGGLE_BUTTON);
-      mesh_butt[3]->callback(mesh_options_ok_cb);
-
-      mesh_butt[21] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 7 * BH, BW, BH, "Impose C1 continuity (2D-plane only)");
-      mesh_butt[21]->type(FL_TOGGLE_BUTTON);
-      mesh_butt[21]->callback(mesh_options_ok_cb);
-
-      o->end();
-    }
-
-    {
-      Fl_Group *o = new Fl_Group(L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Visibility");
-
-      mesh_butt[6] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 1 * BH, BW / 2 - WB, BH, "Nodes");
-      mesh_butt[6]->tooltip("(Alt+Shift+p)");
-      mesh_butt[6]->type(FL_TOGGLE_BUTTON);
-      mesh_butt[6]->callback(mesh_options_ok_cb);
-
-      mesh_butt[7] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 2 * BH, BW / 2 - WB, BH, "Lines");
-      mesh_butt[7]->tooltip("(Alt+Shift+l)");
-      mesh_butt[7]->type(FL_TOGGLE_BUTTON);
-      mesh_butt[7]->callback(mesh_options_ok_cb);
-
-      mesh_butt[8] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 3 * BH, BW / 2 - WB, BH, "Surface edges");
-      mesh_butt[8]->tooltip("(Alt+Shift+s)");
-      mesh_butt[8]->type(FL_TOGGLE_BUTTON);
-      mesh_butt[8]->callback(mesh_options_ok_cb);
-
-      mesh_butt[9] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 4 * BH, BW / 2 - WB, BH, "Surface faces");
-      mesh_butt[9]->tooltip("(Alt+Shift+d)");
-      mesh_butt[9]->type(FL_TOGGLE_BUTTON);
-      mesh_butt[9]->callback(mesh_options_ok_cb);
-
-      mesh_butt[10] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 5 * BH, BW / 2 - WB, BH, "Volume edges");
-      mesh_butt[10]->tooltip("(Alt+Shift+v)");
-      mesh_butt[10]->type(FL_TOGGLE_BUTTON);
-      mesh_butt[10]->callback(mesh_options_ok_cb);
-
-      mesh_butt[11] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 6 * BH, BW / 2 - WB, BH, "Volume faces");
-      mesh_butt[11]->tooltip("(Alt+Shift+b)");
-      mesh_butt[11]->type(FL_TOGGLE_BUTTON);
-      mesh_butt[11]->callback(mesh_options_ok_cb);
-
-      mesh_butt[12] = new Fl_Check_Button(L + width / 2, 2 * WB + 1 * BH, BW / 2 - WB, BH, "Node labels");
-      mesh_butt[12]->type(FL_TOGGLE_BUTTON);
-      mesh_butt[12]->callback(mesh_options_ok_cb);
-
-      mesh_butt[13] = new Fl_Check_Button(L + width / 2, 2 * WB + 2 * BH, BW / 2 - WB, BH, "Line labels");
-      mesh_butt[13]->type(FL_TOGGLE_BUTTON);
-      mesh_butt[13]->callback(mesh_options_ok_cb);
-
-      mesh_butt[14] = new Fl_Check_Button(L + width / 2, 2 * WB + 3 * BH, BW / 2 - WB, BH, "Surface labels");
-      mesh_butt[14]->type(FL_TOGGLE_BUTTON);
-      mesh_butt[14]->callback(mesh_options_ok_cb);
-
-      mesh_butt[15] = new Fl_Check_Button(L + width / 2, 2 * WB + 4 * BH, BW / 2 - WB, BH, "Volume labels");
-      mesh_butt[15]->type(FL_TOGGLE_BUTTON);
-      mesh_butt[15]->callback(mesh_options_ok_cb);
-
-      static Fl_Menu_Item menu_label_type[] = {
-        {"Number", 0, 0, 0},
-        {"Elementary entity", 0, 0, 0},
-        {"Physical group", 0, 0, 0},
-        {"Mesh partition", 0, 0, 0},
-        {"Coordinates", 0, 0, 0},
-        {0}
-      };
-      mesh_choice[7] = new Fl_Choice(L + width / 2, 2 * WB + 5 * BH, width / 4 - 2 * WB, BH, "Label type");
-      mesh_choice[7]->menu(menu_label_type);
-      mesh_choice[7]->align(FL_ALIGN_RIGHT);
-      mesh_choice[7]->callback(mesh_options_ok_cb);
-
-      mesh_value[12] = new Fl_Value_Input(L + width / 2, 2 * WB + 6 * BH, width / 4 - 2 * WB, BH, "Frequency");
-      mesh_value[12]->minimum(0);
-      mesh_value[12]->maximum(100);
-      mesh_value[12]->step(1);
-      mesh_value[12]->align(FL_ALIGN_RIGHT);
-      mesh_value[12]->when(FL_WHEN_RELEASE);
-      mesh_value[12]->callback(mesh_options_ok_cb);
-
-      static Fl_Menu_Item menu_mesh_element_types[] = {
-        {"Triangles",   0, 0, 0, FL_MENU_TOGGLE},
-        {"Quadrangles", 0, 0, 0, FL_MENU_TOGGLE},
-        {"Tetrahedra",  0, 0, 0, FL_MENU_TOGGLE},
-        {"Hexahedra",   0, 0, 0, FL_MENU_TOGGLE},
-        {"Prisms",      0, 0, 0, FL_MENU_TOGGLE},
-        {"Pyramids",    0, 0, 0, FL_MENU_TOGGLE},
-        {0}
-      };
-
-      mesh_menu_butt = new Fl_Menu_Button(L + 2 * WB, 2 * WB + 7 * BH, IW, BH, "Elements");
-      mesh_menu_butt->menu(menu_mesh_element_types);
-      mesh_menu_butt->callback(mesh_options_ok_cb);
-
-      mesh_value[4] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 8 * BH, IW / 4, BH);
-      mesh_value[4]->minimum(0);
-      mesh_value[4]->maximum(1);
-      mesh_value[4]->step(0.01);
-      mesh_value[4]->align(FL_ALIGN_RIGHT);
-      mesh_value[4]->when(FL_WHEN_RELEASE);
-      mesh_value[4]->callback(mesh_options_ok_cb);
-
-      mesh_value[5] = new Fl_Value_Input(L + 2 * WB + IW / 4, 2 * WB + 8 * BH, IW / 2 - IW / 4, BH);
-      mesh_value[5]->minimum(0);
-      mesh_value[5]->maximum(1);
-      mesh_value[5]->step(0.01);
-      mesh_value[5]->align(FL_ALIGN_RIGHT);
-      mesh_value[5]->when(FL_WHEN_RELEASE);
-      mesh_value[5]->callback(mesh_options_ok_cb);
-
-      static Fl_Menu_Item menu_quality_type[] = {
-        {"Gamma", 0, 0, 0},
-        {"Eta", 0, 0, 0},
-        {"Rho", 0, 0, 0},
-        {"Disto", 0, 0, 0},
-        {0}
-      };
-      mesh_choice[6] = new Fl_Choice(L + 2 * WB + IW / 2, 2 * WB + 8 * BH, IW/2, BH, "Quality range");
-      mesh_choice[6]->menu(menu_quality_type);
-      mesh_choice[6]->align(FL_ALIGN_RIGHT);
-      mesh_choice[6]->callback(mesh_options_ok_cb);
-
-      mesh_value[6] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 9 * BH, IW / 2, BH);
-      mesh_value[6]->align(FL_ALIGN_RIGHT);
-      mesh_value[6]->when(FL_WHEN_RELEASE);
-      mesh_value[6]->callback(mesh_options_ok_cb);
-
-      mesh_value[7] = new Fl_Value_Input(L + 2 * WB + IW / 2, 2 * WB + 9 * BH, IW / 2, BH, "Size range");
-      mesh_value[7]->align(FL_ALIGN_RIGHT);
-      mesh_value[7]->when(FL_WHEN_RELEASE);
-      mesh_value[7]->callback(mesh_options_ok_cb);
-
-      mesh_value[8] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 10 * BH, IW, BH, "Normals");
-      mesh_value[8]->minimum(0);
-      mesh_value[8]->maximum(500);
-      mesh_value[8]->step(1);
-      mesh_value[8]->align(FL_ALIGN_RIGHT);
-      mesh_value[8]->when(FL_WHEN_RELEASE);
-      mesh_value[8]->callback(mesh_options_ok_cb);
-
-      mesh_value[13] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 11 * BH, IW, BH, "Tangents");
-      mesh_value[13]->minimum(0);
-      mesh_value[13]->maximum(200);
-      mesh_value[13]->step(1.0);
-      mesh_value[13]->align(FL_ALIGN_RIGHT);
-      mesh_value[13]->when(FL_WHEN_RELEASE);
-      mesh_value[13]->callback(mesh_options_ok_cb);
-
-      o->end();
-    }
-    {
-      Fl_Group *o = new Fl_Group(L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Aspect");
-      o->hide();
-
-      mesh_value[9] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "Element shrinking factor");
-      mesh_value[9]->minimum(0);
-      mesh_value[9]->maximum(1);
-      mesh_value[9]->step(0.01);
-      mesh_value[9]->align(FL_ALIGN_RIGHT);
-      mesh_value[9]->when(FL_WHEN_RELEASE);
-      mesh_value[9]->callback(mesh_options_ok_cb);
-
-      mesh_choice[0] = new Fl_Choice(L + 2 * WB, 2 * WB + 2 * BH, IW, BH, "Point display");
-      mesh_choice[0]->menu(menu_point_display);
-      mesh_choice[0]->align(FL_ALIGN_RIGHT);
-      mesh_choice[0]->callback(mesh_options_ok_cb);
-
-      mesh_value[10] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 3 * BH, IW, BH, "Point size");
-      mesh_value[10]->minimum(0.1);
-      mesh_value[10]->maximum(50);
-      mesh_value[10]->step(0.1);
-      mesh_value[10]->align(FL_ALIGN_RIGHT);
-      mesh_value[10]->callback(mesh_options_ok_cb);
-
-      mesh_value[11] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 4 * BH, IW, BH, "Line width");
-      mesh_value[11]->minimum(0.1);
-      mesh_value[11]->maximum(50);
-      mesh_value[11]->step(0.1);
-      mesh_value[11]->align(FL_ALIGN_RIGHT);
-      mesh_value[11]->callback(mesh_options_ok_cb);
-
-      o->end();
-    }
-    {
-      Fl_Group *o = new Fl_Group(L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Color");
-      o->hide();
-
-      mesh_butt[17] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 1 * BH, BW, BH, "Enable lighting");
-      mesh_butt[17]->tooltip("(Alt+w)");
-      mesh_butt[17]->type(FL_TOGGLE_BUTTON);
-      mesh_butt[17]->callback(mesh_options_ok_cb, (void*)"mesh_light");
-
-      mesh_butt[20] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 2 * BH, BW, BH, "Enable lighting of lines");
-      mesh_butt[20]->type(FL_TOGGLE_BUTTON);
-      mesh_butt[20]->callback(mesh_options_ok_cb);
-
-      mesh_butt[18] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 3 * BH, BW, BH, "Use two-side lighting");
-      mesh_butt[18]->type(FL_TOGGLE_BUTTON);
-      mesh_butt[18]->callback(mesh_options_ok_cb);
-
-      mesh_butt[0] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 4 * BH, BW, BH, "Reverse all normals");
-      mesh_butt[0]->tooltip("(Alt+Shift+w)");
-      mesh_butt[0]->type(FL_TOGGLE_BUTTON);
-      mesh_butt[0]->callback(mesh_options_ok_cb);
-
-      mesh_butt[19] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 5 * BH, BW, BH, "Smooth normals");
-      mesh_butt[19]->type(FL_TOGGLE_BUTTON);
-      mesh_butt[19]->callback(mesh_options_ok_cb);
-
-      mesh_value[18] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 6 * BH, IW, BH, "Smoothing threshold angle");
-      mesh_value[18]->minimum(0.);
-      mesh_value[18]->maximum(180.);
-      mesh_value[18]->step(1.);
-      mesh_value[18]->align(FL_ALIGN_RIGHT);
-      mesh_value[18]->when(FL_WHEN_RELEASE);
-      mesh_value[18]->callback(mesh_options_ok_cb);
-
-      static Fl_Menu_Item menu_mesh_color[] = {
-        {"By element type", 0, 0, 0},
-        {"By elementary entity", 0, 0, 0},
-        {"By physical group", 0, 0, 0},
-        {"By mesh partition", 0, 0, 0},
-        {0}
-      };
-      mesh_choice[4] = new Fl_Choice(L + 2 * WB, 2 * WB + 7 * BH, IW, BH, "Coloring mode");
-      mesh_choice[4]->menu(menu_mesh_color);
-      mesh_choice[4]->align(FL_ALIGN_RIGHT);
-      mesh_choice[4]->callback(mesh_options_ok_cb);
-
-      Fl_Scroll *s = new Fl_Scroll(L + 2 * WB, 3 * WB + 8 * BH, IW + 20, height - 5 * WB - 8 * BH);
-      int i = 0;
-      while(MeshOptions_Color[i].str) {
-        mesh_col[i] = new Fl_Button(L + 2 * WB, 3 * WB + (8 + i) * BH, IW, BH, MeshOptions_Color[i].str);
-        mesh_col[i]->callback(color_cb, (void *)MeshOptions_Color[i].function);
-        i++;
-      }
-      s->end();
-
-      o->end();
-    }
-    o->end();
-  }
-  mesh_group->end();
-
-  // Solver options
-
-  solver_group = new Fl_Group(L, 0, width, height, "Solver Options");
-  solver_group->hide();
-  {
-    Fl_Tabs *o = new Fl_Tabs(L + WB, WB, width - 2 * WB, height - 2 * WB);
-    {
-      {
-        Fl_Group *o = new Fl_Group(L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "General");
-
-        solver_value[0] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "Maximum solver delay");
-        solver_value[0]->minimum(0);
-        solver_value[0]->maximum(10);
-        solver_value[0]->step(1);
-        solver_value[0]->align(FL_ALIGN_RIGHT);
-        solver_value[0]->callback(solver_options_ok_cb);
-
-        solver_input[0] = new Fl_Input(L + 2 * WB, 2 * WB + 2 * BH, IW, BH, "Socket name");
-        solver_input[0]->align(FL_ALIGN_RIGHT);
-        solver_input[0]->callback(solver_options_ok_cb);
-
-        solver_butt[0] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 3 * BH, BW, BH, "Always listen to incoming connection requests");
-        solver_butt[0]->type(FL_TOGGLE_BUTTON);
-        solver_butt[0]->callback(solver_options_ok_cb);
-        
-        o->end();
-      }
-    }
-    o->end();
-  }
-  solver_group->end();
-
-  // Post-processing options
-
-  post_group = new Fl_Group(L, 0, width, height, "Post-processing Options");
-  post_group->hide();
-  {
-    Fl_Tabs *o = new Fl_Tabs(L + WB, WB, width - 2 * WB, height - 2 * WB);
-    {
-      Fl_Group *o = new Fl_Group(L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "General");
-
-      static Fl_Menu_Item menu_links[] = {
-        {"None", 0, 0, 0},
-        {"Apply next changes to all visible views", 0, 0, 0},
-        {"Apply next changes to all views", 0, 0, 0},
-        {"Force same options for all visible views", 0, 0, 0},
-        {"Force same options for all views", 0, 0, 0},
-        {0}
-      };
-
-      post_choice[0] = new Fl_Choice(L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "View links");
-      post_choice[0]->menu(menu_links);
-      post_choice[0]->align(FL_ALIGN_RIGHT);
-      post_choice[0]->callback(post_options_ok_cb);
-
-      post_value[0] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 2 * BH, IW, BH, "Animation delay");
-      post_value[0]->minimum(0);
-      post_value[0]->maximum(10);
-      post_value[0]->step(0.01);
-      post_value[0]->align(FL_ALIGN_RIGHT);
-      post_value[0]->callback(post_options_ok_cb);
-
-      post_butt[0] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 3 * BH, BW, BH, "Cycle through views instead of time steps");
-      post_butt[0]->type(FL_TOGGLE_BUTTON);
-      post_butt[0]->callback(post_options_ok_cb);
-
-      post_butt[1] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 4 * BH, BW, BH, "Remove original views after combination");
-      post_butt[1]->type(FL_TOGGLE_BUTTON);
-      post_butt[1]->callback(post_options_ok_cb);
-
-      post_butt[2] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 5 * BH, BW, BH, "Draw value scales horizontally");
-      post_butt[2]->type(FL_TOGGLE_BUTTON);
-      post_butt[2]->callback(post_options_ok_cb);
-
-      o->end();
-    }
-    o->end();
-  }
-  post_group->end();
-
-  // View options
-
-  view_number = -1;
-  view_group = new Fl_Group(L, 0, width, height, "View Options");
-  view_group->hide();
-  {
-    Fl_Tabs *o = new Fl_Tabs(L + WB, WB, width - 2 * WB, height - 2 * WB);
-    {
-      Fl_Group *o = new Fl_Group(L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "General");
-
-      static Fl_Menu_Item menu_plot_type[] = {
-        {"3D", 0, 0, 0},
-        {"2D space", 0, 0, 0},
-        {"2D time", 0, 0, 0},
-        {0}
-      };
-      view_choice[13] = new Fl_Choice(L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "Plot type");
-      view_choice[13]->menu(menu_plot_type);
-      view_choice[13]->align(FL_ALIGN_RIGHT);
-      view_choice[13]->callback(view_options_ok_cb);
-
-      view_input[0] = new Fl_Input(L + 2 * WB, 2 * WB + 2 * BH, IW, BH, "View name");
-      view_input[0]->align(FL_ALIGN_RIGHT);
-      view_input[0]->callback(view_options_ok_cb);
-
-      int sw = (int)(1.5 * fontsize);
-      view_butt_rep[0] = new Fl_Repeat_Button(L + 2 * WB, 2 * WB + 3 * BH, sw, BH, "-");
-      view_butt_rep[0]->callback(view_options_timestep_decr_cb);
-      view_butt_rep[1] = new Fl_Repeat_Button(L + 2 * WB + IW - sw, 2 * WB + 3 * BH, sw, BH, "+");
-      view_butt_rep[1]->callback(view_options_timestep_incr_cb);
-      view_value[50] = new Fl_Value_Input(L + 2 * WB + sw, 2 * WB + 3 * BH, IW - 2 * sw, BH);
-      view_value[50]->callback(view_options_timestep_cb);
-      view_value[50]->align(FL_ALIGN_RIGHT);
-      view_value[50]->minimum(0);
-      view_value[50]->maximum(0);
-      view_value[50]->step(1);
-      Fl_Box *a = new Fl_Box(L + 2 * WB + IW, 2 * WB + 3 * BH, IW / 2, BH, "Time step");
-      a->box(FL_NO_BOX);
-      a->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
-
-      view_range = new Fl_Group(L + 2 * WB, 2 * WB + 4 * BH, width - 4 * WB, 8 * BH);
-
-      view_value[30] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 4 * BH, IW, BH, "Intervals");
-      view_value[30]->align(FL_ALIGN_RIGHT);
-      view_value[30]->minimum(1);
-      view_value[30]->maximum(256);
-      view_value[30]->step(1);
-      view_value[30]->when(FL_WHEN_RELEASE);
-      view_value[30]->callback(view_options_ok_cb);
-      
-      static Fl_Menu_Item menu_iso[] = {
-        {"Iso-values", 0, 0, 0},
-        {"Continuous map", 0, 0, 0},
-        {"Filled iso-values", 0, 0, 0},
-        {"Numeric values", 0, 0, 0},
-        {0}
-      };
-      view_choice[0] = new Fl_Choice(L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Intervals type");
-      view_choice[0]->menu(menu_iso);
-      view_choice[0]->align(FL_ALIGN_RIGHT);
-      view_choice[0]->tooltip("(Alt+t)");
-      view_choice[0]->callback(view_options_ok_cb);
-
-      static Fl_Menu_Item menu_range[] = {
-        {"Default", 0, 0, 0},
-        {"Custom", 0, 0, 0},
-        {"Per time step", 0, 0, 0},
-        {0}
-      };
-      view_choice[7] = new Fl_Choice(L + 2 * WB, 2 * WB + 6 * BH, IW, BH, "Range mode");
-      view_choice[7]->menu(menu_range);
-      view_choice[7]->align(FL_ALIGN_RIGHT);
-      view_choice[7]->tooltip("(Alt+r)");
-      view_choice[7]->callback(view_options_ok_cb, (void*)"custom_range");
-
-      int sw2 = (int)(2.5 * fontsize);
-      view_push_butt[1] = new Fl_Button(L + 2 * WB, 2 * WB + 7 * BH, sw2, BH, "Min");
-      view_push_butt[1]->callback(view_options_ok_cb, (void*)"range_min");
-      view_value[31] = new Fl_Value_Input(L + 2 * WB + sw2, 2 * WB + 7 * BH, IW - sw2, BH, "Custom minimum");
-      view_value[31]->align(FL_ALIGN_RIGHT);
-      view_value[31]->when(FL_WHEN_RELEASE);
-      view_value[31]->callback(view_options_ok_cb);
-
-      view_push_butt[2] = new Fl_Button(L + 2 * WB, 2 * WB + 8 * BH, sw2, BH, "Max");
-      view_push_butt[2]->callback(view_options_ok_cb, (void*)"range_max");
-      view_value[32] = new Fl_Value_Input(L + 2 * WB + sw2, 2 * WB + 8 * BH, IW - sw2, BH, "Custom maximum");
-      view_value[32]->align(FL_ALIGN_RIGHT);
-      view_value[32]->when(FL_WHEN_RELEASE);
-      view_value[32]->callback(view_options_ok_cb);
-
-      view_butt[38] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 9 * BH, BW, BH, "Saturate out-of-range values");
-      view_butt[38]->type(FL_TOGGLE_BUTTON);
-      view_butt[38]->callback(view_options_ok_cb);
-
-      static Fl_Menu_Item menu_scale[] = {
-        {"Linear", 0, 0, 0},
-        {"Logarithmic", 0, 0, 0},
-        {"Double logarithmic", 0, 0, 0},
-        {0}
-      };
-      view_choice[1] = new Fl_Choice(L + 2 * WB, 2 * WB + 10 * BH, IW, BH, "Value scale mode");
-      view_choice[1]->menu(menu_scale);
-      view_choice[1]->align(FL_ALIGN_RIGHT);
-      view_choice[1]->callback(view_options_ok_cb);
-
-      view_input[1] = new Fl_Input(L + 2 * WB, 2 * WB + 11 * BH, IW, BH, "Number display format");
-      view_input[1]->align(FL_ALIGN_RIGHT);
-      view_input[1]->callback(view_options_ok_cb);
-
-      view_range->end();
-
-      o->end();
-    }
-    {
-      Fl_Group *o = new Fl_Group(L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Axes");
-      o->hide();
-
-      view_choice[8] = new Fl_Choice(L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "Axes mode");
-      view_choice[8]->menu(menu_axes_mode);
-      view_choice[8]->align(FL_ALIGN_RIGHT);
-      view_choice[8]->tooltip("(Alt+a)");
-      view_choice[8]->callback(view_options_ok_cb, (void*)"view_axes");
-
-      view_butt[3] = new Fl_Check_Button(L + width - (int)(0.85*IW) - 2 * WB, 2 * WB + 1 * BH, (int)(0.85*IW), BH, "Mikado style");
-      view_butt[3]->type(FL_TOGGLE_BUTTON);
-      view_butt[3]->callback(view_options_ok_cb);
-
-      view_value[3] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 2 * BH, IW/3, BH);
-      view_value[3]->minimum(0.);
-      view_value[3]->step(1);
-      view_value[3]->maximum(100);
-      view_value[3]->callback(view_options_ok_cb);
-      view_value[4] = new Fl_Value_Input(L + 2 * WB + 1*IW/3, 2 * WB + 2 * BH, IW/3, BH);
-      view_value[4]->minimum(0.);
-      view_value[4]->step(1);
-      view_value[4]->maximum(100);
-      view_value[4]->callback(view_options_ok_cb);
-      view_value[5] = new Fl_Value_Input(L + 2 * WB + 2*IW/3, 2 * WB + 2 * BH, IW/3, BH, "Axes tics");
-      view_value[5]->minimum(0.);
-      view_value[5]->step(1);
-      view_value[5]->maximum(100);
-      view_value[5]->align(FL_ALIGN_RIGHT);
-      view_value[5]->callback(view_options_ok_cb);
-
-      view_input[7] = new Fl_Input(L + 2 * WB, 2 * WB + 3 * BH, IW/3, BH);
-      view_input[7]->callback(view_options_ok_cb);
-      view_input[8] = new Fl_Input(L + 2 * WB + 1*IW/3, 2 * WB + 3 * BH, IW/3, BH);
-      view_input[8]->callback(view_options_ok_cb);
-      view_input[9] = new Fl_Input(L + 2 * WB + 2*IW/3, 2 * WB + 3 * BH, IW/3, BH, "Axes format");
-      view_input[9]->align(FL_ALIGN_RIGHT);
-      view_input[9]->callback(view_options_ok_cb);
-      
-      view_input[10] = new Fl_Input(L + 2 * WB, 2 * WB + 4 * BH, IW/3, BH);
-      view_input[10]->callback(view_options_ok_cb);
-      view_input[11] = new Fl_Input(L + 2 * WB + 1*IW/3, 2 * WB + 4 * BH, IW/3, BH);
-      view_input[11]->callback(view_options_ok_cb);
-      view_input[12] = new Fl_Input(L + 2 * WB + 2*IW/3, 2 * WB + 4 * BH, IW/3, BH, "Axes labels");
-      view_input[12]->align(FL_ALIGN_RIGHT);
-      view_input[12]->callback(view_options_ok_cb);
-      
-      view_butt[25] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 5 * BH, BW, BH, "Position 3D axes automatically");
-      view_butt[25]->type(FL_TOGGLE_BUTTON);
-      view_butt[25]->callback(view_options_ok_cb, (void*)"view_axes_auto_3d");
-      
-      view_value[13] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 6 * BH, IW / 3, BH);
-      view_value[13]->callback(view_options_ok_cb);
-      view_value[14] = new Fl_Value_Input(L + 2 * WB + IW / 3, 2 * WB + 6 * BH, IW / 3, BH);
-      view_value[14]->callback(view_options_ok_cb);
-      view_value[15] = new Fl_Value_Input(L + 2 * WB + 2 * IW / 3, 2 * WB + 6 * BH, IW / 3, BH, "3D axes minimum");
-      view_value[15]->align(FL_ALIGN_RIGHT);
-      view_value[15]->callback(view_options_ok_cb);
-
-      view_value[16] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 7 * BH, IW / 3, BH);
-      view_value[16]->callback(view_options_ok_cb);
-      view_value[17] = new Fl_Value_Input(L + 2 * WB + IW / 3, 2 * WB + 7 * BH, IW / 3, BH);
-      view_value[17]->callback(view_options_ok_cb);
-      view_value[18] = new Fl_Value_Input(L + 2 * WB + 2 * IW / 3, 2 * WB + 7 * BH, IW / 3, BH, "3D axes maximum");
-      view_value[18]->align(FL_ALIGN_RIGHT);
-      view_value[18]->callback(view_options_ok_cb);
-
-      view_butt[7] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 8 * BH, BW, BH, "Position 2D axes/value scale automatically");
-      view_butt[7]->type(FL_TOGGLE_BUTTON);
-      view_butt[7]->callback(view_options_ok_cb, (void*)"view_axes_auto_2d");
-      
-      view_value[20] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 9 * BH, IW / 2, BH);
-      view_value[20]->minimum(-2000);
-      view_value[20]->maximum(2000);
-      view_value[20]->step(1);
-      view_value[20]->callback(view_options_ok_cb);
-      view_value[21] = new Fl_Value_Input(L + 2 * WB + IW / 2, 2 * WB + 9 * BH, IW / 2, BH, "2D axes/value scale position");
-      view_value[21]->align(FL_ALIGN_RIGHT);
-      view_value[21]->minimum(-2000);
-      view_value[21]->maximum(2000);
-      view_value[21]->step(1);
-      view_value[21]->callback(view_options_ok_cb);
-
-      view_value[22] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 10 * BH, IW / 2, BH);
-      view_value[22]->minimum(0);
-      view_value[22]->maximum(2000);
-      view_value[22]->step(1);
-      view_value[22]->callback(view_options_ok_cb);
-      view_value[23] = new Fl_Value_Input(L + 2 * WB + IW / 2, 2 * WB + 10 * BH, IW / 2, BH, "2D axes/value scale size");
-      view_value[23]->align(FL_ALIGN_RIGHT);
-      view_value[23]->minimum(0);
-      view_value[23]->maximum(2000);
-      view_value[23]->step(1);
-      view_value[23]->callback(view_options_ok_cb);
-
-      o->end();
-    }
-    {
-      Fl_Group *o = new Fl_Group(L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Visibility");
-      o->hide();
-
-      view_butt[4] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 1 * BH, BW, BH, "Show value scale");
-      view_butt[4]->tooltip("(Alt+i)");
-      view_butt[4]->type(FL_TOGGLE_BUTTON);
-      view_butt[4]->callback(view_options_ok_cb);
-
-      static Fl_Menu_Item time_display[] = {
-        {"None", 0, 0, 0},
-        {"Value if multi-step", 0, 0, 0},
-        {"Value", 0, 0, 0},
-        {"Step if multi-step", 0, 0, 0},
-        {"Step", 0, 0, 0},
-        {0}
-      };
-      view_choice[12] = new Fl_Choice(L + 2 * WB, 2 * WB + 2 * BH, IW, BH, "Time display mode");
-      view_choice[12]->menu(time_display);
-      view_choice[12]->align(FL_ALIGN_RIGHT);
-      view_choice[12]->callback(view_options_ok_cb);
-
-      view_butt[5] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 3 * BH, BW, BH, "Show annotations");
-      view_butt[5]->tooltip("(Alt+n)");
-      view_butt[5]->type(FL_TOGGLE_BUTTON);
-      view_butt[5]->callback(view_options_ok_cb);
-
-      view_butt[10] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 4 * BH, BW / 2, BH, "Draw element outlines");
-      view_butt[10]->tooltip("(Alt+e)");
-      view_butt[10]->type(FL_TOGGLE_BUTTON);
-      view_butt[10]->callback(view_options_ok_cb);
-
-      view_butt[2] = new Fl_Check_Button(L + 2 * WB + BW / 2, 2 * WB + 4 * BH, BW / 2, BH, "Draw 3D skin only");
-      view_butt[2]->type(FL_TOGGLE_BUTTON);
-      view_butt[2]->callback(view_options_ok_cb);
-
-      static Fl_Menu_Item menu_view_element_types[] = {
-        {"Points",      0, 0, 0, FL_MENU_TOGGLE},
-        {"Lines",       0, 0, 0, FL_MENU_TOGGLE},
-        {"Triangles",   0, 0, 0, FL_MENU_TOGGLE},
-        {"Quadrangles", 0, 0, 0, FL_MENU_TOGGLE},
-        {"Tetrahedra",  0, 0, 0, FL_MENU_TOGGLE},
-        {"Hexahedra",   0, 0, 0, FL_MENU_TOGGLE},
-        {"Prisms",      0, 0, 0, FL_MENU_TOGGLE},
-        {"Pyramids",    0, 0, 0, FL_MENU_TOGGLE},
-        {0}
-      };
-
-      view_menu_butt[1] = new Fl_Menu_Button(L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Elements");
-      view_menu_butt[1]->menu(menu_view_element_types);
-      view_menu_butt[1]->callback(view_options_ok_cb);
-      
-      static Fl_Menu_Item menu_boundary[] = {
-        {"None", 0, 0, 0},
-        {"Dimension - 1", 0, 0, 0},
-        {"Dimension - 2", 0, 0, 0},
-        {"Dimension - 3", 0, 0, 0},
-        {0}
-      };
-      view_choice[9] = new Fl_Choice(L + 2 * WB, 2 * WB + 6 * BH, IW, BH, "Element boundary mode");
-      view_choice[9]->menu(menu_boundary);
-      view_choice[9]->align(FL_ALIGN_RIGHT);
-      view_choice[9]->callback(view_options_ok_cb);
-
-      view_value[0] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 7 * BH, IW, BH, "Normals");
-      view_value[0]->minimum(0);
-      view_value[0]->maximum(500);
-      view_value[0]->step(1);
-      view_value[0]->align(FL_ALIGN_RIGHT);
-      view_value[0]->when(FL_WHEN_RELEASE);
-      view_value[0]->callback(view_options_ok_cb);
-
-      view_value[1] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 8 * BH, IW, BH, "Tangents");
-      view_value[1]->minimum(0);
-      view_value[1]->maximum(500);
-      view_value[1]->step(1);
-      view_value[1]->align(FL_ALIGN_RIGHT);
-      view_value[1]->when(FL_WHEN_RELEASE);
-      view_value[1]->callback(view_options_ok_cb);
-
-      static Fl_Menu_Item menu_view_field_types[] = {
-        {"Scalar", 0, 0, 0, FL_MENU_TOGGLE},
-        {"Vector", 0, 0, 0, FL_MENU_TOGGLE},
-        {"Tensor", 0, 0, 0, FL_MENU_TOGGLE},
-        {0}
-      };
-
-      view_menu_butt[0] = new Fl_Menu_Button(L + 2 * WB, 2 * WB + 9 * BH, IW, BH, "Fields");
-      view_menu_butt[0]->menu(menu_view_field_types);
-      view_menu_butt[0]->callback(view_options_ok_cb);
-
-      view_value[33] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 10 * BH, IW, BH, "Maximum recursion level");
-      view_value[33]->align(FL_ALIGN_RIGHT);
-      view_value[33]->minimum(0);
-      view_value[33]->maximum(8);
-      view_value[33]->step(1);
-      view_value[33]->when(FL_WHEN_RELEASE);
-      view_value[33]->callback(view_options_ok_cb);
-
-      view_value[34] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 11 * BH, IW, BH, "Target error");
-      view_value[34]->align(FL_ALIGN_RIGHT);
-      view_value[34]->minimum(0.);
-      view_value[34]->maximum(1.);
-      view_value[34]->step(1.e-3);
-      view_value[34]->when(FL_WHEN_RELEASE);
-      view_value[34]->callback(view_options_ok_cb);
-
-      o->end();
-    }
-    {
-      Fl_Group *o = new Fl_Group(L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Offset");
-      o->hide();
-
-      Fl_Box *b = new Fl_Box(FL_NO_BOX, L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "Coordinate transformation:");
-      b->align(FL_ALIGN_INSIDE|FL_ALIGN_LEFT);
-
-      int ss = 2*IW/3/3+4;
-      view_value[51] = new Fl_Value_Input(L + 2 * WB       , 2 * WB + 2 * BH, ss, BH);
-      view_value[52] = new Fl_Value_Input(L + 2 * WB + ss  , 2 * WB + 2 * BH, ss, BH);
-      view_value[53] = new Fl_Value_Input(L + 2 * WB + 2*ss, 2 * WB + 2 * BH, ss, BH, " X");
-      view_value[40] = new Fl_Value_Input(L + 2 * WB + IW  , 2 * WB + 2 * BH, 7*IW/10, BH);
-
-      view_value[54] = new Fl_Value_Input(L + 2 * WB       , 2 * WB + 3 * BH, ss, BH);
-      view_value[55] = new Fl_Value_Input(L + 2 * WB + ss  , 2 * WB + 3 * BH, ss, BH);
-      view_value[56] = new Fl_Value_Input(L + 2 * WB + 2*ss, 2 * WB + 3 * BH, ss, BH, " Y +");
-      view_value[41] = new Fl_Value_Input(L + 2 * WB + IW  , 2 * WB + 3 * BH, 7*IW/10, BH);
-
-      view_value[57] = new Fl_Value_Input(L + 2 * WB       , 2 * WB + 4 * BH, ss, BH);
-      view_value[58] = new Fl_Value_Input(L + 2 * WB + ss  , 2 * WB + 4 * BH, ss, BH);
-      view_value[59] = new Fl_Value_Input(L + 2 * WB + 2*ss, 2 * WB + 4 * BH, ss, BH, " Z");
-      view_value[42] = new Fl_Value_Input(L + 2 * WB + IW  , 2 * WB + 4 * BH, 7*IW/10, BH);
-
-      Fl_Box *b2 = new Fl_Box(FL_NO_BOX, L + 2 * WB + 2 * IW-3*WB, 2 * WB + 1 * BH, 7*IW/10, BH, "Raise:");
-      b2->align(FL_ALIGN_INSIDE|FL_ALIGN_LEFT);
-
-      view_value[43] = new Fl_Value_Input(L + 2 * WB + 2 * IW-3*WB, 2 * WB + 2 * BH, 7*IW/10, BH);
-      view_value[44] = new Fl_Value_Input(L + 2 * WB + 2 * IW-3*WB, 2 * WB + 3 * BH, 7*IW/10, BH);
-      view_value[45] = new Fl_Value_Input(L + 2 * WB + 2 * IW-3*WB, 2 * WB + 4 * BH, 7*IW/10, BH);
-
-      view_value[46] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 5 * BH, 3*ss, BH, "Normal raise");
-
-      for(int i = 40; i <= 46; i++){
-        view_value[i]->align(FL_ALIGN_RIGHT);
-        view_value[i]->when(FL_WHEN_RELEASE);
-        view_value[i]->callback(view_options_ok_cb);
-      }
-      for(int i = 51; i <= 59; i++){
-        view_value[i]->minimum(-1.);
-        view_value[i]->maximum(1.);
-        view_value[i]->step(0.1);
-        view_value[i]->align(FL_ALIGN_RIGHT);
-        view_value[i]->when(FL_WHEN_RELEASE);
-        view_value[i]->callback(view_options_ok_cb);
-      }
-
-      view_butt[6] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 6 * BH, BW, BH, "Use general transformation expressions");
-      view_butt[6]->type(FL_TOGGLE_BUTTON);
-      view_butt[6]->callback(view_options_ok_cb, (void*)"general_transform");
-
-      view_choice[11] = new Fl_Choice(L + 2 * WB, 2 * WB + 7 * BH, IW, BH, "Data source");
-      view_choice[11]->align(FL_ALIGN_RIGHT);
-      view_choice[11]->add("Self");
-      view_choice[11]->callback(view_options_ok_cb);
-
-      view_value[2] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 8 * BH, IW, BH, "Factor");
-      view_value[2]->align(FL_ALIGN_RIGHT);
-      view_value[2]->when(FL_WHEN_RELEASE);
-      view_value[2]->callback(view_options_ok_cb);
-
-      view_input[4] = new Fl_Input(L + 2 * WB, 2 * WB + 9 * BH, IW, BH, "X expression");
-      view_input[4]->align(FL_ALIGN_RIGHT);
-      view_input[4]->callback(view_options_ok_cb);
-
-      view_input[5] = new Fl_Input(L + 2 * WB, 2 * WB + 10 * BH, IW, BH, "Y expression");
-      view_input[5]->align(FL_ALIGN_RIGHT);
-      view_input[5]->callback(view_options_ok_cb);
-
-      view_input[6] = new Fl_Input(L + 2 * WB, 2 * WB + 11 * BH, IW, BH, "Z expression");
-      view_input[6]->align(FL_ALIGN_RIGHT);
-      view_input[6]->callback(view_options_ok_cb);
-
-      o->end();
-    }
-    {
-      Fl_Group *o = new Fl_Group(L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Aspect");
-      o->hide();
-
-      view_value[12] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "Element shrinking factor");
-      view_value[12]->minimum(0.);
-      view_value[12]->step(0.01);
-      view_value[12]->maximum(1.);
-      view_value[12]->align(FL_ALIGN_RIGHT);
-      view_value[12]->when(FL_WHEN_RELEASE);
-      view_value[12]->callback(view_options_ok_cb);
-
-      view_choice[5] = new Fl_Choice(L + 2 * WB, 2 * WB + 2 * BH, IW, BH, "Point display");
-      view_choice[5]->menu(menu_point_display_post);
-      view_choice[5]->align(FL_ALIGN_RIGHT);
-      view_choice[5]->callback(view_options_ok_cb);
-
-      view_value[61] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 3 * BH, IW, BH, "Point size");
-      view_value[61]->minimum(0.1);
-      view_value[61]->maximum(50);
-      view_value[61]->step(0.1);
-      view_value[61]->align(FL_ALIGN_RIGHT);
-      view_value[61]->callback(view_options_ok_cb);
-
-      view_choice[6] = new Fl_Choice(L + 2 * WB, 2 * WB + 4 * BH, IW, BH, "Line display");
-      view_choice[6]->menu(menu_line_display_post);
-      view_choice[6]->align(FL_ALIGN_RIGHT);
-      view_choice[6]->callback(view_options_ok_cb);
-
-      view_butt[26] = new Fl_Check_Button(L + width - (int)(1.15*BB) - 2 * WB, 2 * WB + 4 * BH, (int)(1.15*BB), BH, "Stipple in 2D");
-      view_butt[26]->type(FL_TOGGLE_BUTTON);
-      view_butt[26]->callback(view_options_ok_cb);
-
-      view_value[62] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Line width");
-      view_value[62]->minimum(0.1);
-      view_value[62]->maximum(50);
-      view_value[62]->step(0.1);
-      view_value[62]->align(FL_ALIGN_RIGHT);
-      view_value[62]->callback(view_options_ok_cb);
-
-      {
-        view_vector = new Fl_Group(L + 2 * WB, 2 * WB + 6 * BH, width - 2 * WB, 4 * BH, 0);
-
-        static Fl_Menu_Item menu_vectype[] = {
-          {"Line", 0, 0, 0},
-          {"Arrow", 0, 0, 0},
-          {"Pyramid", 0, 0, 0},
-          {"3D arrow", 0, 0, 0},
-          {"Displacement", 0, 0, 0},
-          {"Comet", 0, 0, 0},
-          {0}
-        };
-        view_choice[2] = new Fl_Choice(L + 2 * WB, 2 * WB + 6 * BH, IW, BH, "Vector display");
-        view_choice[2]->menu(menu_vectype);
-        view_choice[2]->align(FL_ALIGN_RIGHT);
-        view_choice[2]->callback(view_options_ok_cb);
-
-        view_push_butt[0] = new Fl_Button(L + width - (int)(1.15*BB) - 2 * WB, 2 * WB + 6 * BH, (int)(1.15*BB), BH, "Edit arrow");
-        view_push_butt[0]->callback(view_arrow_param_cb);
-
-        view_value[60] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 7 * BH, IW, BH, "Arrow size");
-        view_value[60]->minimum(0);
-        view_value[60]->maximum(500);
-        view_value[60]->step(1);
-        view_value[60]->align(FL_ALIGN_RIGHT);
-        view_value[60]->callback(view_options_ok_cb);
-
-        view_butt[0] = new Fl_Check_Button(L + width - (int)(1.15*BB) - 2 * WB, 2 * WB + 7 * BH, (int)(1.15*BB), BH, "Proportional");
-        view_butt[0]->type(FL_TOGGLE_BUTTON);
-        view_butt[0]->callback(view_options_ok_cb);
-
-        view_value[63] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 8 * BH, IW, BH, "Displacement factor");
-        view_value[63]->minimum(0.);
-        view_value[63]->maximum(1.);
-        view_value[63]->step(0.01);
-        view_value[63]->align(FL_ALIGN_RIGHT);
-        view_value[63]->when(FL_WHEN_RELEASE);
-        view_value[63]->callback(view_options_ok_cb);
-
-        view_choice[10] = new Fl_Choice(L + 2 * WB, 2 * WB + 9 * BH, IW, BH, "Data source");
-        view_choice[10]->align(FL_ALIGN_RIGHT);
-        view_choice[10]->add("Self");
-        view_choice[10]->callback(view_options_ok_cb);
-
-        view_vector->end();
-      }
-
-      static Fl_Menu_Item menu_vecloc[] = {
-        {"Barycenter", 0, 0, 0},
-        {"Vertex", 0, 0, 0},
-        {0}
-      };
-      view_choice[3] = new Fl_Choice(L + 2 * WB, 2 * WB + 10 * BH, IW, BH, "Glyph location");
-      view_choice[3]->menu(menu_vecloc);
-      view_choice[3]->align(FL_ALIGN_RIGHT);
-      view_choice[3]->callback(view_options_ok_cb);
-
-      view_butt[1] = new Fl_Check_Button(L + width - (int)(1.15*BB) - 2 * WB, 2 * WB + 10 * BH, (int)(1.15*BB), BH, "Center glyph");
-      view_butt[1]->type(FL_TOGGLE_BUTTON);
-      view_butt[1]->callback(view_options_ok_cb);
-      
-      static Fl_Menu_Item menu_tensor[] = {
-        {"Von-Mises", 0, 0, 0},
-        {0}
-      };
-      view_choice[4] = new Fl_Choice(L + 2 * WB, 2 * WB + 11 * BH, IW, BH, "Tensor display");
-      view_choice[4]->menu(menu_tensor);
-      view_choice[4]->align(FL_ALIGN_RIGHT);
-      view_choice[4]->callback(view_options_ok_cb);
-
-      o->end();
-    }
-    {
-      Fl_Group *o = new Fl_Group(L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Color");
-      o->hide();
-
-      view_butt[11] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 1 * BH, BW, BH, "Enable lighting");
-      view_butt[11]->tooltip("(Alt+w)");
-      view_butt[11]->type(FL_TOGGLE_BUTTON);
-      view_butt[11]->callback(view_options_ok_cb, (void*)"view_light");
-
-      view_butt[8] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 2 * BH, BW, BH, "Enable lighting of lines");
-      view_butt[8]->type(FL_TOGGLE_BUTTON);
-      view_butt[8]->callback(view_options_ok_cb);
-
-      view_butt[9] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 3 * BH, BW, BH, "Use two-side lighting");
-      view_butt[9]->type(FL_TOGGLE_BUTTON);
-      view_butt[9]->callback(view_options_ok_cb);
-
-      view_butt[12] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 4 * BH, BW, BH, "Smooth normals");
-      view_butt[12]->type(FL_TOGGLE_BUTTON);
-      view_butt[12]->callback(view_options_ok_cb);
-
-      view_value[10] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Smoothing threshold angle");
-      view_value[10]->minimum(0.);
-      view_value[10]->step(1.);
-      view_value[10]->maximum(180.);
-      view_value[10]->align(FL_ALIGN_RIGHT);
-      view_value[10]->when(FL_WHEN_RELEASE);
-      view_value[10]->callback(view_options_ok_cb);
-
-      view_butt[24] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 6 * BH, BW, BH, "Use fake transparency mode");
-      view_butt[24]->type(FL_TOGGLE_BUTTON);
-      view_butt[24]->callback(view_options_ok_cb);
-
-      Fl_Scroll *s = new Fl_Scroll(L + 2 * WB, 3 * WB + 7 * BH, IW + 20, height - 5 * WB - 7 * BH);
-      int i = 0;
-      while(ViewOptions_Color[i].str) {
-        view_col[i] = new Fl_Button(L + 2 * WB, 3 * WB + (7 + i) * BH, IW, BH, ViewOptions_Color[i].str);
-        view_col[i]->callback(view_color_cb, (void *)ViewOptions_Color[i].function);
-        i++;
-      }
-      s->end();
-
-      o->end();
-    }
-    {
-      Fl_Group *o = new Fl_Group(L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Map");
-      o->hide();
-
-      view_colorbar_window = new Colorbar_Window(L + 2 * WB, 2 * WB + BH, width - 4 * WB, height - 4 * WB - BH);
-      view_colorbar_window->end();
-      view_colorbar_window->callback(view_options_ok_cb);
-
-      o->end();
-    }
-    o->end();
-  }
-  view_group->end();
-
-  opt_window->position(CTX.opt_position[0], CTX.opt_position[1]);
-  opt_window->end();
-}
-
-void GUI::update_view_window(int num)
-{
-  if(num < 0 || num >= (int)PView::list.size()) return;
-
-  view_number = num;
-
-  PView *view = PView::list[num];
-  PViewData *data = view->getData();
-  PViewOptions *opt = view->getOptions();
-
-  double maxval = std::max(fabs(data->getMin()), fabs(data->getMax()));
-  if(!maxval) maxval = 1.;
-  double val1 = 10. * CTX.lc;
-  double val2 = 2. * CTX.lc / maxval;
-
-  opt_view_name(num, GMSH_GUI, NULL);
-  opt_view_format(num, GMSH_GUI, NULL);
-  opt_view_type(num, GMSH_GUI, 0);
-  opt_view_show_scale(num, GMSH_GUI, 0);
-  opt_view_draw_strings(num, GMSH_GUI, 0);
-
-  opt_view_max_recursion_level(num, GMSH_GUI, 0);
-  opt_view_target_error(num, GMSH_GUI, 0);
-  if(data->isAdaptive()){
-    view_value[33]->activate();
-    view_value[34]->activate();
-  }
-  else{
-    view_value[33]->deactivate();
-    view_value[34]->deactivate();
-  }
-
-  if(data->getNumPoints() || data->getNumLines()){
-    ((Fl_Menu_Item*)view_choice[13]->menu())[1].activate();
-    ((Fl_Menu_Item*)view_choice[13]->menu())[2].activate();
-  }
-  else {
-    ((Fl_Menu_Item*)view_choice[13]->menu())[1].deactivate();
-    ((Fl_Menu_Item*)view_choice[13]->menu())[2].deactivate();
-  }
-
-  opt_view_auto_position(num, GMSH_GUI, 0);
-  opt_view_position0(num, GMSH_GUI, 0);
-  opt_view_position1(num, GMSH_GUI, 0);
-  opt_view_size0(num, GMSH_GUI, 0);
-  opt_view_size1(num, GMSH_GUI, 0);
-
-  opt_view_axes(num, GMSH_GUI, 0);
-  opt_view_axes_mikado(num, GMSH_GUI, 0);
-  opt_view_axes_format0(num, GMSH_GUI, NULL);
-  opt_view_axes_format1(num, GMSH_GUI, NULL);
-  opt_view_axes_format2(num, GMSH_GUI, NULL);
-  opt_view_axes_tics0(num, GMSH_GUI, 0);
-  opt_view_axes_tics1(num, GMSH_GUI, 0);
-  opt_view_axes_tics2(num, GMSH_GUI, 0);
-  opt_view_axes_label0(num, GMSH_GUI, NULL);
-  opt_view_axes_label1(num, GMSH_GUI, NULL);
-  opt_view_axes_label2(num, GMSH_GUI, NULL);
-  opt_view_axes_auto_position(num, GMSH_GUI, 0);
-  opt_view_axes_xmin(num, GMSH_GUI, 0);
-  opt_view_axes_xmax(num, GMSH_GUI, 0);
-  opt_view_axes_ymin(num, GMSH_GUI, 0);
-  opt_view_axes_ymax(num, GMSH_GUI, 0);
-  opt_view_axes_zmin(num, GMSH_GUI, 0);
-  opt_view_axes_zmax(num, GMSH_GUI, 0);
-  for(int i = 13; i <= 18; i++){
-    view_value[i]->step(CTX.lc/200.);
-    view_value[i]->minimum(-CTX.lc);
-    view_value[i]->maximum(CTX.lc);
-  }
-
-  if(data->getNumElements()) {
-    view_range->activate();
-    ((Fl_Menu_Item*)view_choice[13]->menu())[0].activate();
-  }
-  else {
-    view_range->deactivate();
-    ((Fl_Menu_Item*)view_choice[13]->menu())[0].deactivate();
-  }
-  opt_view_show_element(num, GMSH_GUI, 0);
-  opt_view_draw_skin_only(num, GMSH_GUI, 0);
-  opt_view_light(num, GMSH_GUI, 0);
-  opt_view_light_two_side(num, GMSH_GUI, 0);
-  opt_view_light_lines(num, GMSH_GUI, 0);
-  opt_view_smooth_normals(num, GMSH_GUI, 0);
-  opt_view_angle_smooth_normals(num, GMSH_GUI, 0);
-  opt_view_boundary(num, GMSH_GUI, 0);
-  opt_view_explode(num, GMSH_GUI, 0);
-  opt_view_draw_points(num, GMSH_GUI, 0);
-  opt_view_draw_lines(num, GMSH_GUI, 0);
-  opt_view_draw_triangles(num, GMSH_GUI, 0);
-  opt_view_draw_quadrangles(num, GMSH_GUI, 0);
-  opt_view_draw_tetrahedra(num, GMSH_GUI, 0);
-  opt_view_draw_hexahedra(num, GMSH_GUI, 0);
-  opt_view_draw_prisms(num, GMSH_GUI, 0);
-  opt_view_draw_pyramids(num, GMSH_GUI, 0);
-  opt_view_draw_scalars(num, GMSH_GUI, 0);
-  opt_view_draw_vectors(num, GMSH_GUI, 0);
-  opt_view_draw_tensors(num, GMSH_GUI, 0);
-  opt_view_normals(num, GMSH_GUI, 0);
-  opt_view_tangents(num, GMSH_GUI, 0);
-
-  opt_view_nb_iso(num, GMSH_GUI, 0);
-  opt_view_intervals_type(num, GMSH_GUI, 0);
-  opt_view_range_type(num, GMSH_GUI, 0);
-  opt_view_custom_min(num, GMSH_GUI, 0);
-  opt_view_custom_max(num, GMSH_GUI, 0);
-  opt_view_scale_type(num, GMSH_GUI, 0);
-  opt_view_saturate_values(num, GMSH_GUI, 0);
-
-  opt_view_offset0(num, GMSH_GUI, 0);
-  opt_view_offset1(num, GMSH_GUI, 0);
-  opt_view_offset2(num, GMSH_GUI, 0);
-  for(int i = 40; i <= 42; i++) {
-    view_value[i]->step(val1/100.);
-    view_value[i]->minimum(-val1);
-    view_value[i]->maximum(val1);
-  }
-  opt_view_transform00(num, GMSH_GUI, 0);
-  opt_view_transform01(num, GMSH_GUI, 0);
-  opt_view_transform02(num, GMSH_GUI, 0);
-  opt_view_transform10(num, GMSH_GUI, 0);
-  opt_view_transform11(num, GMSH_GUI, 0);
-  opt_view_transform12(num, GMSH_GUI, 0);
-  opt_view_transform20(num, GMSH_GUI, 0);
-  opt_view_transform21(num, GMSH_GUI, 0);
-  opt_view_transform22(num, GMSH_GUI, 0);
-  opt_view_raise0(num, GMSH_GUI, 0);
-  opt_view_raise1(num, GMSH_GUI, 0);
-  opt_view_raise2(num, GMSH_GUI, 0);
-  opt_view_normal_raise(num, GMSH_GUI, 0);
-  for(int i = 43; i <= 46; i++) {
-    view_value[i]->step(val2/100.);
-    view_value[i]->minimum(-val2);
-    view_value[i]->maximum(val2);
-  }
-  opt_view_use_gen_raise(num, GMSH_GUI, 0);
-  opt_view_gen_raise_view(num, GMSH_GUI, 0);
-  opt_view_gen_raise_factor(num, GMSH_GUI, 0);
-  opt_view_gen_raise0(num, GMSH_GUI, 0);
-  opt_view_gen_raise1(num, GMSH_GUI, 0);
-  opt_view_gen_raise2(num, GMSH_GUI, 0);
-  view_value[2]->step(val2/100.);
-  view_value[2]->minimum(-val2);
-  view_value[2]->maximum(val2);
-
-  if(data->getNumTimeSteps() == 1) {
-    view_value[50]->deactivate();
-    view_butt_rep[0]->deactivate();
-    view_butt_rep[1]->deactivate();
-  }
-  else {
-    view_value[50]->activate();
-    view_butt_rep[0]->activate();
-    view_butt_rep[1]->activate();
-  }
-  view_value[50]->maximum(data->getNumTimeSteps() - 1);
-  opt_view_timestep(num, GMSH_GUI, 0);
-  opt_view_show_time(num, GMSH_GUI, 0);
-
-  if(data->getNumVectors() || data->getNumTensors())
-    view_vector->activate();
-  else
-    view_vector->deactivate();
-
-  opt_view_point_size(num, GMSH_GUI, 0);
-  opt_view_point_type(num, GMSH_GUI, 0);
-  opt_view_line_width(num, GMSH_GUI, 0);
-  opt_view_line_type(num, GMSH_GUI, 0);
-  opt_view_vector_type(num, GMSH_GUI, 0);
-  opt_view_arrow_size(num, GMSH_GUI, 0);
-  opt_view_arrow_size_proportional(num, GMSH_GUI, 0);
-
-  opt_view_displacement_factor(num, GMSH_GUI, 0);
-  double val3 = 2. * CTX.lc / maxval;
-  view_value[63]->step(val3/100.);
-  view_value[63]->maximum(val3);
-
-  opt_view_external_view(num, GMSH_GUI, 0);
-  opt_view_glyph_location(num, GMSH_GUI, 0);
-  opt_view_center_glyphs(num, GMSH_GUI, 0);
-  opt_view_tensor_type(num, GMSH_GUI, 0);
-
-  opt_view_fake_transparency(num, GMSH_GUI, 0);
-  opt_view_use_stipple(num, GMSH_GUI, 0);
-  opt_view_color_points(num, GMSH_GUI, 0);
-  opt_view_color_lines(num, GMSH_GUI, 0);
-  opt_view_color_triangles(num, GMSH_GUI, 0);
-  opt_view_color_quadrangles(num, GMSH_GUI, 0);
-  opt_view_color_tetrahedra(num, GMSH_GUI, 0);
-  opt_view_color_hexahedra(num, GMSH_GUI, 0);
-  opt_view_color_prisms(num, GMSH_GUI, 0);
-  opt_view_color_pyramids(num, GMSH_GUI, 0);
-  opt_view_color_tangents(num, GMSH_GUI, 0);
-  opt_view_color_normals(num, GMSH_GUI, 0);
-  opt_view_color_text2d(num, GMSH_GUI, 0);
-  opt_view_color_text3d(num, GMSH_GUI, 0);
-  opt_view_color_axes(num, GMSH_GUI, 0);
-
-  view_colorbar_window->update(data->getName().c_str(), data->getMin(), 
-                               data->getMax(), &opt->CT, &view->getChanged());
-}
-
-// Create the plugin manager window
-
-void GUI::create_plugin_dialog_box(GMSH_Plugin *p, int x, int y, int width, int height)
-{
-  p->dialogBox = new PluginDialogBox;
-  p->dialogBox->group = new Fl_Group(x, y, width, height);
-
-  {
-    Fl_Tabs *o = new Fl_Tabs(x, y, width, height);
-    {
-      Fl_Group *g = new Fl_Group(x, y + BH, width, height - BH, "Options");
-      Fl_Scroll *s = new Fl_Scroll(x + WB, y + WB + BH, width - 2 * WB, height - BH - 2 * WB);
-
-      int m = p->getNbOptionsStr();
-      if(m > MAX_PLUGIN_OPTIONS) m = MAX_PLUGIN_OPTIONS;
-
-      int n = p->getNbOptions();
-      if(n > MAX_PLUGIN_OPTIONS) n = MAX_PLUGIN_OPTIONS;
-
-      int k = 0;
-      for(int i = 0; i < m; i++) {
-        StringXString *sxs = p->getOptionStr(i);
-        p->dialogBox->input[i] = new Fl_Input(x + WB, y + WB + (k + 1) * BH, IW, BH, sxs->str);
-        p->dialogBox->input[i]->align(FL_ALIGN_RIGHT);
-        p->dialogBox->input[i]->value(sxs->def);
-        k++;
-      }
-      for(int i = 0; i < n; i++) {
-        StringXNumber *sxn = p->getOption(i);
-        p->dialogBox->value[i] = new Fl_Value_Input(x + WB, y + WB + (k + 1) * BH, IW, BH, sxn->str);
-        p->dialogBox->value[i]->align(FL_ALIGN_RIGHT);
-        p->dialogBox->value[i]->value(sxn->def);
-        k++;
-      }
-
-      s->end();
-      g->end();
-      o->resizable(g); // to avoid ugly resizing of tab labels
-    }
-    {
-      Fl_Group *g = new Fl_Group(x, y + BH, width, height - BH, "About");
-
-      Fl_Browser *o = new Fl_Browser(x + WB, y + WB + BH, width - 2 * WB, height - 2 * WB - BH);
-
-      char name[1024], copyright[256], author[256], help[4096];
-      p->getName(name);
-      p->getInfos(author, copyright, help);
-
-      o->add(" ");
-      add_multiline_in_browser(o, "@c@b@.", name);
-      o->add(" ");
-      add_multiline_in_browser(o, "", help);
-      o->add(" ");
-      add_multiline_in_browser(o, "Author: ", author);
-      add_multiline_in_browser(o, "Copyright (C) ", copyright);
-      o->add(" ");
-
-      g->end();
-    }
-    o->end();
-  }
-
-  p->dialogBox->group->end();
-  p->dialogBox->group->hide();
-}
-
-void GUI::reset_plugin_view_browser()
-{
-  // save selected state
-  std::vector<int> state;
-  for(int i = 0; i < plugin_view_browser->size(); i++){
-    if(plugin_view_browser->selected(i + 1))
-      state.push_back(1);
-    else
-      state.push_back(0);
-  }
-
-  char str[128];
-  plugin_view_browser->clear();
-
-  if(PView::list.size()){
-    plugin_view_browser->activate();
-    for(unsigned int i = 0; i < PView::list.size(); i++) {
-      sprintf(str, "View [%d]", i);
-      plugin_view_browser->add(str);
-    }
-    for(int i = 0; i < plugin_view_browser->size(); i++){
-      if(i < (int)state.size() && state[i])
-        plugin_view_browser->select(i + 1);
-    }
-  }
-  else{
-    plugin_view_browser->add("No Views");
-    plugin_view_browser->deactivate();
-  }
-
-  view_plugin_browser_cb(NULL, NULL);
-}
-
-void GUI::create_plugin_window(int numview)
-{
-  int width0 = 34 * fontsize + WB;
-  int height0 = 13 * BH + 5 * WB;
-
-  int width = (CTX.plugin_size[0] < width0) ? width0 : CTX.plugin_size[0];
-  int height = (CTX.plugin_size[1] < height0) ? height0 : CTX.plugin_size[1];
-
-  if(plugin_window) {
-    reset_plugin_view_browser();
-    if(numview >= 0 && numview < (int)PView::list.size()){
-      plugin_view_browser->deselect();
-      plugin_view_browser->select(numview + 1);
-      view_plugin_browser_cb(NULL, NULL);
-    }
-    plugin_window->show();
-    return;
-  }
-
-  plugin_window = new Dialog_Window(width, height, CTX.non_modal_windows, "Plugins");
-  plugin_window->box(GMSH_WINDOW_BOX);
-
-  {
-    Fl_Button *o = new Fl_Button(width - BB - WB, height - BH - WB, BB, BH, "Cancel");
-    o->callback(view_plugin_cancel_cb);
-  }
-  {
-    plugin_run = new Fl_Return_Button(width - 2 * BB - 2 * WB, height - BH - WB, BB, BH, "Run");
-    plugin_run->callback(view_plugin_run_cb);
-  }
-
-  int L1 = (int)(0.3 * width), L2 = (int)(0.6 * L1);
-  plugin_browser = new Fl_Hold_Browser(WB, WB, L1, height - 3 * WB - BH);
-  plugin_browser->callback(view_plugin_browser_cb);
-
-  plugin_view_browser = new Fl_Multi_Browser(WB + L1, WB, L2, height - 3 * WB - BH);
-  plugin_view_browser->has_scrollbar(Fl_Browser_::VERTICAL);
-  plugin_view_browser->callback(view_plugin_browser_cb);
-
-  for(GMSH_PluginManager::iter it = GMSH_PluginManager::instance()->begin();
-      it != GMSH_PluginManager::instance()->end(); ++it) {
-    GMSH_Plugin *p = (*it).second;
-    if(p->getType() == GMSH_Plugin::GMSH_POST_PLUGIN) {
-      char name[256];
-      p->getName(name);
-      plugin_browser->add(name, p);
-      create_plugin_dialog_box(p, 2 * WB + L1 + L2, WB, width - L1 - L2 - 3 * WB, height - 3 * WB - BH);
-      // select first plugin by default
-      if(it == GMSH_PluginManager::instance()->begin()){
-        plugin_browser->select(1);
-        p->dialogBox->group->show();
-      }
-    }
-  }
-
-  Dummy_Box *resize_box = new Dummy_Box(3*WB + L1+L2, WB, WB, height - 3 * WB - BH);
-  plugin_window->resizable(resize_box);
-  plugin_window->size_range(width0, height0);
-
-  plugin_window->position(CTX.plugin_position[0], CTX.plugin_position[1]);
-  plugin_window->end();
-}
-
-// field window
-
-void GUI::update_fields()
-{
-  edit_field(GModel::current()->getFields()->get(field_selected_id));
-}
-
-void GUI::load_field_list()
-{
-  FieldManager &fields = *GModel::current()->getFields();
-  Field *selected_field = (Field*)field_editor_group->user_data();
-  field_browser->clear();
-  int i_entry = 0;
-  for(FieldManager::iterator it = fields.begin(); it != fields.end(); it++){
-    i_entry++;
-    Field *field = it->second;
-    std::ostringstream sstream;
-    if(it->first == fields.background_field)
-      sstream << "@b";
-    sstream << it->first << " " << field->get_name();
-    field_browser->add(sstream.str().c_str(), field);
-    if(it->second == selected_field)
-      field_browser->select(i_entry);
-  }
-}
-
-void GUI::save_field_options()
-{
-  std::list<Fl_Widget*>::iterator input = field_options_widget.begin();
-  Field *f = (Field*)field_editor_group->user_data();
-  std::ostringstream sstream;
-  int i;
-  char a;
-  sstream.precision(16);
-  for(std::map<std::string, FieldOption*>::iterator it = f->options.begin();
-      it != f->options.end(); it++){
-    FieldOption *option = it->second;
-    sstream.str("");
-    switch(option->get_type()){
-    case FIELD_OPTION_STRING:
-    case FIELD_OPTION_PATH:
-      sstream << "\"" << ((Fl_Input*)*input)->value() << "\"";
-      break;
-    case FIELD_OPTION_INT:
-      sstream << (int)((Fl_Value_Input*)*input)->value();
-      break;
-    case FIELD_OPTION_DOUBLE:
-      sstream << ((Fl_Value_Input*)*input)->value();
-      break;
-    case FIELD_OPTION_BOOL:
-      sstream << (bool)((Fl_Check_Button*)*input)->value();
-      break;
-    case FIELD_OPTION_LIST:
-      {
-        sstream << "{";
-        std::istringstream istream(((Fl_Input*)*input)->value());
-        while(istream >> i){
-          sstream << i;
-          if(istream >> a){
-            if(a != ',')
-              Msg::Error("Unexpected character \'%c\' while parsing option '%s' of field \'%s\'",
-                         a, it->first.c_str(), f->id);
-            sstream<<", ";
-          }
-        }
-        sstream<<"}";
-      }
-      break;
-    }
-    if((*input)->changed()){
-      add_field_option(f->id, it->first.c_str(), sstream.str().c_str(), CTX.filename);
-      (*input)->clear_changed();
-    }
-    input++;
-  }
-  int is_bg_field = field_background_btn->value();
-  FieldManager &fields = *GModel::current()->getFields();
-  if(is_bg_field && fields.background_field != f->id){
-    set_background_field(f->id, CTX.filename);
-    load_field_list();
-  }
-  if(!is_bg_field && fields.background_field == f->id){
-    set_background_field(-1, CTX.filename);
-    load_field_list();
-  }
-}
-
-void GUI::load_field_options()
-{
-  Field *f = (Field*)field_editor_group->user_data();
-  std::list<Fl_Widget*>::iterator input = field_options_widget.begin();
-  for(std::map<std::string,FieldOption*>::iterator it = f->options.begin();
-      it != f->options.end(); it++){
-    FieldOption *option = it->second;
-    std::ostringstream vstr;
-    std::list<int>::iterator list_it;
-    switch(option->get_type()){
-    case FIELD_OPTION_STRING:
-    case FIELD_OPTION_PATH:
-      ((Fl_Input*)(*input))->value(option->string().c_str());
-      break;
-    case FIELD_OPTION_INT:
-    case FIELD_OPTION_DOUBLE:
-      ((Fl_Value_Input*)(*input))->value(option->numerical_value());
-      break;
-    case FIELD_OPTION_BOOL:
-      ((Fl_Check_Button*)(*input))->value((int)option->numerical_value());
-      break;
-    case FIELD_OPTION_LIST:
-      vstr.str("");
-      for(list_it = option->list().begin(); list_it != option->list().end(); list_it++){
-	if(list_it!=option->list().begin())
-	  vstr << ", ";
-	vstr << *list_it;
-      }
-      ((Fl_Input*)(*input))->value(vstr.str().c_str());
-      break;
-    }
-    (*input)->clear_changed();
-    input++;
-  }
-  field_background_btn->value(GModel::current()->getFields()->background_field == f->id);
-}
-
-void GUI::load_field_view_list()
-{
-  field_put_on_view_btn->clear();
-  field_put_on_view_btn->add("New view");
-  field_put_on_view_btn->activate();
-  for(unsigned int i = 0; i < PView::list.size(); i++) {
-    std::ostringstream s;
-    s << "View [" << i << "]";
-    field_put_on_view_btn->add(s.str().c_str());
-  }
-}
-
-void GUI::edit_field(Field *f)
-{
-  field_editor_group->user_data(f);
-  field_put_on_view_btn->deactivate();
-  field_delete_btn->deactivate();
-  if(f == NULL){
-    field_selected_id = -1;
-    field_editor_group->hide();
-    load_field_list();
-    return;
-  }
-  field_selected_id = f->id;
-  field_editor_group->show();
-  field_editor_group->user_data(f);
-  field_title->label(f->get_name());
-  field_options_scroll->clear();
-  field_options_widget.clear();
-  field_options_scroll->begin();
-  int x = field_options_scroll->x();
-  int yy = field_options_scroll->y() + WB;
-  field_help_display->clear();
-  add_multiline_in_browser(field_help_display, "", f->get_description().c_str(), 100);
-  field_help_display->add("\n");
-  field_help_display->add("@b@cOptions");
-  for(std::map<std::string, FieldOption*>::iterator it = f->options.begin(); 
-      it != f->options.end(); it++){
-    Fl_Widget *input;
-    field_help_display->add(("@b" + it->first).c_str());
-    field_help_display->add(("@i" + it->second->get_type_name()).c_str());
-    add_multiline_in_browser(field_help_display, "", it->second->get_description().c_str(), 100);
-    switch(it->second->get_type()){
-    case FIELD_OPTION_INT:
-    case FIELD_OPTION_DOUBLE:
-      input = new Fl_Value_Input(x, yy, IW, BH, it->first.c_str());
-      break;
-    case FIELD_OPTION_BOOL:
-      input = new Fl_Check_Button(x, yy, BH, BH, it->first.c_str());
-      break;
-    case FIELD_OPTION_PATH:
-      {
-        Fl_Button *b = new Fl_Button(x, yy, BH, BH, "S");
-        input = new Fl_Input(x + WB + BH, yy, IW - WB - BH, BH, it->first.c_str());
-        b->callback(view_field_select_file_cb, input);
-      }
-      break;
-    case FIELD_OPTION_STRING:
-      input = new Fl_Input(x, yy, IW, BH, it->first.c_str());
-      break;
-    case FIELD_OPTION_LIST:
-    default:
-      input = new Fl_Input(x, yy, IW, BH, it->first.c_str());
-      break;
-    }
-    input->align(FL_ALIGN_RIGHT);
-    field_options_widget.push_back(input);
-    yy += WB + BH;
-  }
-  field_options_scroll->end();
-  load_field_options();
-  field_options_scroll->damage(1);
-  field_put_on_view_btn->activate();
-  field_delete_btn->activate();
-  load_field_list();
-}
-
-void GUI::create_field_window()
-{
-  int width0 = 34 * fontsize + WB;
-  int height0 = 13 * BH + 5 * WB;
-  int width = (CTX.field_size[0] < width0) ? width0 : CTX.field_size[0];
-  int height = (CTX.field_size[1] < height0) ? height0 : CTX.field_size[1];
-  field_window = new Dialog_Window(width, height, CTX.non_modal_windows, "Fields");
-  field_window->box(GMSH_WINDOW_BOX);
-  int x = WB;
-  int y = WB;
-  int w = (int)(1.5 * BB);
-  Fl_Menu_Button *new_field_btn = new Fl_Menu_Button(x, y, w, BH, "New");
-  FieldManager &fields = *GModel::current()->getFields();
-  std::map<std::string, FieldFactory*>::iterator it;
-  for(it = fields.map_type_name.begin(); it != fields.map_type_name.end(); it++)
-    new_field_btn->add(it->first.c_str());
-  new_field_btn->callback(view_field_new_cb);
-  y += BH;
-  int h = height - 2 * WB - 3 * BH;
-  field_browser = new Fl_Hold_Browser(x, y + WB, w, h - 2 * WB);
-  y += h; 
-  field_delete_btn = new Fl_Button(x, y, w, BH, "Delete");
-  field_delete_btn->callback(view_field_delete_cb, this);
-  y += BH;
-  field_browser->callback(view_field_browser_cb);
-  field_put_on_view_btn = new Fl_Menu_Button(x, y, w, BH, "Put on view");
-  field_put_on_view_btn->callback(view_field_put_on_view_cb, this);
-  x += w + WB;
-  y = WB;
-  w = width - x - WB;
-  h = height - y - WB;
-  field_editor_group = new Fl_Group(x, y, w, h);
-  field_title = new Fl_Box(x, y, w, BH, "field_name");
-  y += BH + WB;
-  h -= BH + WB;
-  field_title->labelfont(FL_BOLD);
-  field_title->labelsize(18);
-  Fl_Tabs *tabs = new Fl_Tabs(x, y , w, h);
-  y += BH;
-  h -= BH;
-  x += WB;
-  w -= 2 * WB;
-  Fl_Group *options_tab = new Fl_Group(x, y, w, h, "Options");
-  Fl_Scroll *options_scroll = new Fl_Scroll(x, y, w, h - BH - 2 * WB);
-  field_options_scroll = options_scroll;
-  options_scroll->end();
-  Fl_Button *apply_btn = new Fl_Return_Button(x + w - BB, y + h - BH - WB, BB, BH, "Apply");
-  Fl_Button *revert_btn = new Fl_Button(x + w - 2 * BB - WB, y + h - BH - WB, BB, BH, "Revert");
-  field_background_btn = new Fl_Check_Button(x, y + h - BH - WB, (int)(1.5 * BB), BH, "Background mesh size");
-  apply_btn->callback(view_field_apply_cb, this);
-  revert_btn->callback(view_field_revert_cb, this);
-  options_tab->end();
-  Fl_Group *help_tab= new Fl_Group(x, y, w, h, "Help");
-  field_help_display = new Fl_Browser(x, y + WB, w, h - 2 * WB);
-  help_tab->end();
-  tabs->end();
-  field_editor_group->end();
-  field_window->resizable(new Dummy_Box((int)(1.5 * BB) + 2 * WB, BH + 2 * WB, 
-                                        width - 3 * WB - (int)(1.5 * BB), height - 3 * BH - 5 * WB));
-  field_editor_group->resizable(tabs);
-  tabs->resizable(options_tab);
-  options_tab->resizable(new Dummy_Box(3 * BB + 4 * WB, BH + 2 * WB,
-                                       width - 9 * WB - 5 * BB, height - 3 * BH - 5 * WB));
-  //options_tab->resizable(options_scroll);
-  //field_window->resizable(field_editor_group);
-  field_window->size_range(width0, height0);
-  field_window->position(CTX.field_position[0], CTX.field_position[1]);
-  field_window->end();
-  load_field_view_list();
-  edit_field(NULL);
-}
-
-// Create the window for the statistics
-
-void GUI::create_statistics_window()
-{
-  int i, num = 0;
-  static Fl_Group *g[10];
-
-  if(stat_window) {
-    if(!stat_window->shown())
-      set_statistics(false);
-    for(i = 0; i < 3; i++)
-      g[i]->hide();
-    switch(get_context()){
-    case 0: g[0]->show(); break; // geometry
-    case 1: g[1]->show(); break; // mesh
-    case 3: g[2]->show(); break; // post-pro
-    default: g[1]->show(); break; // mesh
-    }
-    stat_window->show();
-    return;
-  }
-
-  int width = 26 * fontsize;
-  int height = 5 * WB + 18 * BH;
-
-  stat_window = new Dialog_Window(width, height, CTX.non_modal_windows, "Statistics");
-  stat_window->box(GMSH_WINDOW_BOX);
-  {
-    Fl_Tabs *o = new Fl_Tabs(WB, WB, width - 2 * WB, height - 3 * WB - BH);
-    {
-      g[0] = new Fl_Group(WB, WB + BH, width - 2 * WB, height - 3 * WB - 2 * BH, "Geometry");
-      stat_value[num++] = new Fl_Output(2 * WB, 2 * WB + 1 * BH, IW, BH, "Points");
-      stat_value[num++] = new Fl_Output(2 * WB, 2 * WB + 2 * BH, IW, BH, "Lines");
-      stat_value[num++] = new Fl_Output(2 * WB, 2 * WB + 3 * BH, IW, BH, "Surfaces");
-      stat_value[num++] = new Fl_Output(2 * WB, 2 * WB + 4 * BH, IW, BH, "Volumes");
-      stat_value[num++] = new Fl_Output(2 * WB, 2 * WB + 5 * BH, IW, BH, "Physical groups");
-      g[0]->end();
-    }
-    {
-      g[1] = new Fl_Group(WB, WB + BH, width - 2 * WB, height - 3 * WB - 2 * BH, "Mesh");
-      stat_value[num++] = new Fl_Output(2 * WB, 2 * WB + 1 * BH, IW, BH, "Nodes on Lines");
-      stat_value[num++] = new Fl_Output(2 * WB, 2 * WB + 2 * BH, IW, BH, "Nodes on surfaces");
-      stat_value[num++] = new Fl_Output(2 * WB, 2 * WB + 3 * BH, IW, BH, "Nodes in volumes");
-      stat_value[num++] = new Fl_Output(2 * WB, 2 * WB + 4 * BH, IW, BH, "Triangles");
-      stat_value[num++] = new Fl_Output(2 * WB, 2 * WB + 5 * BH, IW, BH, "Quadrangles");
-      stat_value[num++] = new Fl_Output(2 * WB, 2 * WB + 6 * BH, IW, BH, "Tetrahedra");
-      stat_value[num++] = new Fl_Output(2 * WB, 2 * WB + 7 * BH, IW, BH, "Hexahedra");
-      stat_value[num++] = new Fl_Output(2 * WB, 2 * WB + 8 * BH, IW, BH, "Prisms");
-      stat_value[num++] = new Fl_Output(2 * WB, 2 * WB + 9 * BH, IW, BH, "Pyramids");
-
-      stat_value[num++] = new Fl_Output(2 * WB, 2 * WB + 10 * BH, IW, BH, "Time for 1D mesh");
-      stat_value[num++] = new Fl_Output(2 * WB, 2 * WB + 11 * BH, IW, BH, "Time for 2D mesh");
-      stat_value[num++] = new Fl_Output(2 * WB, 2 * WB + 12 * BH, IW, BH, "Time for 3D mesh");
-
-      stat_value[num] = new Fl_Output(2 * WB, 2 * WB + 13 * BH, IW, BH, "Gamma"); 
-      stat_value[num]->tooltip("~ inscribed_radius / circumscribed_radius"); num++;
-      stat_value[num] = new Fl_Output(2 * WB, 2 * WB + 14 * BH, IW, BH, "Eta");
-      stat_value[num]->tooltip("~ volume^(2/3) / sum_edge_length^2"); num++;
-      stat_value[num] = new Fl_Output(2 * WB, 2 * WB + 15 * BH, IW, BH, "Rho");
-      stat_value[num]->tooltip("~ min_edge_length / max_edge_length"); num++;
-      stat_value[num] = new Fl_Output(2 * WB, 2 * WB + 16 * BH, IW, BH, "Disto");
-      stat_value[num]->tooltip("~ min (J0/J, J/J0)"); num++;
-
-      for(int i = 0; i < 4; i++){
-        int ww = 3 * fontsize;
-        new Fl_Box(FL_NO_BOX, width - 3 * ww - 2 * WB, 2 * WB + (13 + i) * BH, ww, BH, "Plot:");
-        stat_butt[2 * i] = new Fl_Button(width - 2 * ww - 2 * WB, 2 * WB + (13 + i) * BH, ww, BH, "2D");
-        stat_butt[2 * i + 1] = new Fl_Button(width - ww - 2 * WB, 2 * WB + (13 + i) * BH, ww, BH, "3D");
-      }
-      stat_butt[0]->callback(statistics_histogram_cb, (void *)"Gamma2D");
-      stat_butt[1]->callback(statistics_histogram_cb, (void *)"Gamma3D");
-      stat_butt[2]->callback(statistics_histogram_cb, (void *)"Eta2D");
-      stat_butt[3]->callback(statistics_histogram_cb, (void *)"Eta3D");
-      stat_butt[4]->callback(statistics_histogram_cb, (void *)"Rho2D");
-      stat_butt[5]->callback(statistics_histogram_cb, (void *)"Rho3D");
-      stat_butt[6]->callback(statistics_histogram_cb, (void *)"Disto2D");
-      stat_butt[7]->callback(statistics_histogram_cb, (void *)"Disto3D");
-
-      g[1]->end();
-    }
-    {
-      g[2] = new Fl_Group(WB, WB + BH, width - 2 * WB, height - 3 * WB - 2 * BH, "Post-processing");
-      stat_value[num++] = new Fl_Output(2 * WB, 2 * WB + 1 * BH, IW, BH, "Views");
-      stat_value[num++] = new Fl_Output(2 * WB, 2 * WB + 2 * BH, IW, BH, "Points");
-      stat_value[num++] = new Fl_Output(2 * WB, 2 * WB + 3 * BH, IW, BH, "Lines");
-      stat_value[num++] = new Fl_Output(2 * WB, 2 * WB + 4 * BH, IW, BH, "Triangles");
-      stat_value[num++] = new Fl_Output(2 * WB, 2 * WB + 5 * BH, IW, BH, "Quadrangles");
-      stat_value[num++] = new Fl_Output(2 * WB, 2 * WB + 6 * BH, IW, BH, "Tetrahedra");
-      stat_value[num++] = new Fl_Output(2 * WB, 2 * WB + 7 * BH, IW, BH, "Hexahedra");
-      stat_value[num++] = new Fl_Output(2 * WB, 2 * WB + 8 * BH, IW, BH, "Prisms");
-      stat_value[num++] = new Fl_Output(2 * WB, 2 * WB + 9 * BH, IW, BH, "Pyramids");
-      stat_value[num++] = new Fl_Output(2 * WB, 2 * WB + 10 * BH, IW, BH, "Strings");
-      g[2]->end();
-    }
-    o->end();
-  }
-
-  for(i = 0; i < num; i++) {
-    stat_value[i]->align(FL_ALIGN_RIGHT);
-    stat_value[i]->value(0);
-  }
-
-  {
-    Fl_Return_Button *o = new Fl_Return_Button(width - 2 * BB - 2 * WB, height - BH - WB, BB, BH, "Update");
-    o->callback(statistics_update_cb);
-  }
-  {
-    Fl_Button *o = new Fl_Button(width - BB - WB, height - BH - WB, BB, BH, "Cancel");
-    o->callback(cancel_cb, (void *)stat_window);
-  }
-
-  stat_window->position(CTX.stat_position[0], CTX.stat_position[1]);
-  stat_window->end();
-}
-
-void GUI::set_statistics(bool compute_quality)
-{
-  int num = 0;
-  static double s[50];
-  static char label[50][256];
-
-  if(compute_quality)
-    GetStatistics(s, quality);
-  else
-    GetStatistics(s);
-
-  // geom
-  sprintf(label[num], "%g", s[0]); stat_value[num]->value(label[num]); num++;
-  sprintf(label[num], "%g", s[1]); stat_value[num]->value(label[num]); num++;
-  sprintf(label[num], "%g", s[2]); stat_value[num]->value(label[num]); num++;
-  sprintf(label[num], "%g", s[3]); stat_value[num]->value(label[num]); num++;
-  sprintf(label[num], "%g", s[45]); stat_value[num]->value(label[num]); num++;
-
-  // mesh
-  sprintf(label[num], "%g", s[4]); stat_value[num]->value(label[num]); num++;
-  sprintf(label[num], "%g", s[5]); stat_value[num]->value(label[num]); num++;
-  sprintf(label[num], "%g", s[6]); stat_value[num]->value(label[num]); num++;
-  sprintf(label[num], "%g", s[7]); stat_value[num]->value(label[num]); num++;
-  sprintf(label[num], "%g", s[8]); stat_value[num]->value(label[num]); num++;
-  sprintf(label[num], "%g", s[9]); stat_value[num]->value(label[num]); num++;
-  sprintf(label[num], "%g", s[10]); stat_value[num]->value(label[num]); num++;
-  sprintf(label[num], "%g", s[11]); stat_value[num]->value(label[num]); num++;
-  sprintf(label[num], "%g", s[12]); stat_value[num]->value(label[num]); num++;
-
-  sprintf(label[num], "%g", s[13]); stat_value[num]->value(label[num]); num++;
-  sprintf(label[num], "%g", s[14]); stat_value[num]->value(label[num]); num++;
-  sprintf(label[num], "%g", s[15]); stat_value[num]->value(label[num]); num++;
-
-  if(!compute_quality){
-    for(int i = 0; i < 8; i += 2) stat_butt[i]->deactivate();
-    sprintf(label[num], "Press Update");
-    stat_value[num]->deactivate();
-    stat_value[num]->value(label[num]); num++;
-    sprintf(label[num], "Press Update");
-    stat_value[num]->deactivate();
-    stat_value[num]->value(label[num]); num++;
-    sprintf(label[num], "Press Update");
-    stat_value[num]->deactivate();
-    stat_value[num]->value(label[num]); num++;
-    sprintf(label[num], "Press Update");
-    stat_value[num]->deactivate();
-    stat_value[num]->value(label[num]); num++;
-  }
-  else{
-    for(int i = 0; i < 8; i += 2) stat_butt[i]->activate();
-    sprintf(label[num], "%.4g (%.4g->%.4g)", s[17], s[18], s[19]);
-    stat_value[num]->activate();
-    stat_value[num]->value(label[num]); num++;
-    sprintf(label[num], "%.4g (%.4g->%.4g)", s[20], s[21], s[22]);
-    stat_value[num]->activate();
-    stat_value[num]->value(label[num]); num++;
-    sprintf(label[num], "%.4g (%.4g->%.4g)", s[23], s[24], s[25]);
-    stat_value[num]->activate();
-    stat_value[num]->value(label[num]); num++;
-    sprintf(label[num], "%.4g (%.4g->%.4g)", s[46], s[47], s[48]);
-    stat_value[num]->activate();
-    stat_value[num]->value(label[num]); num++;
-  }
-
-  // post
-  sprintf(label[num], "%g", s[26]); stat_value[num]->value(label[num]); num++;
-  sprintf(label[num], "%g", s[27]); stat_value[num]->value(label[num]); num++;
-  sprintf(label[num], "%g", s[28]); stat_value[num]->value(label[num]); num++;
-  sprintf(label[num], "%g", s[29]); stat_value[num]->value(label[num]); num++;
-  sprintf(label[num], "%g", s[30]); stat_value[num]->value(label[num]); num++;
-  sprintf(label[num], "%g", s[31]); stat_value[num]->value(label[num]); num++;
-  sprintf(label[num], "%g", s[32]); stat_value[num]->value(label[num]); num++;
-  sprintf(label[num], "%g", s[33]); stat_value[num]->value(label[num]); num++;
-  sprintf(label[num], "%g", s[34]); stat_value[num]->value(label[num]); num++;
-  sprintf(label[num], "%g", s[35]); stat_value[num]->value(label[num]); num++;
-}
-
-
-// Create the window for the messages
-
-void GUI::create_message_window(bool redraw_only)
-{
-
-  if(msg_window) {
-    if(msg_window->shown() && redraw_only)
-      msg_window->redraw();
-    else
-      msg_window->show();
-    return;
-  }
-
-  int width = CTX.msg_size[0];
-  int height = CTX.msg_size[1];
-
-  msg_window = new Dialog_Window(width, height, CTX.non_modal_windows, "Message Console");
-  msg_window->box(GMSH_WINDOW_BOX);
-
-  msg_browser = new Fl_Browser(0, 0, width, height - 2 * WB - BH);
-  msg_browser->box(FL_FLAT_BOX);
-  msg_browser->textfont(FL_COURIER);
-  msg_browser->textsize(fontsize - 1);
-  msg_browser->type(FL_MULTI_BROWSER);
-  msg_browser->callback(message_copy_cb);
-
-  {
-    msg_butt = new Fl_Check_Button(width - 4 * BB - 4 * WB, height - BH - WB, BB, BH, "Auto scroll");
-    msg_butt->type(FL_TOGGLE_BUTTON);
-    msg_butt->callback(message_auto_scroll_cb);
-  }
-  {
-    Fl_Return_Button *o = new Fl_Return_Button(width - 3 * BB - 3 * WB, height - BH - WB, BB, BH, "Clear");
-    o->callback(message_clear_cb);
-  }
-  {
-    Fl_Button *o = new Fl_Button(width - 2 * BB - 2 * WB, height - BH - WB, BB, BH, "Save");
-    o->callback(message_save_cb);
-  }
-  {
-    Fl_Button *o = new Fl_Button(width - BB - WB, height - BH - WB, BB, BH, "Cancel");
-    o->callback(cancel_cb, (void *)msg_window);
-  }
-
-  msg_window->resizable(new Fl_Box(1, 1, 4, 4));
-  msg_window->size_range(WB + 100 + 3 * BB + 4 * WB, 100);
-
-  msg_window->position(CTX.msg_position[0], CTX.msg_position[1]);
-  msg_window->end();
-}
-
-void GUI::add_message(const char *msg)
-{
-  msg_browser->add(msg, 0);
-  if(CTX.msg_auto_scroll)
-    msg_browser->bottomline(msg_browser->size());
-}
-
-void GUI::save_message(const char *filename)
-{
-  FILE *fp;
-
-  if(!(fp = fopen(filename, "w"))) {
-    Msg::Error("Unable to open file '%s'", filename);
-    return;
-  }
-
-  Msg::StatusBar(2, true, "Writing '%s'", filename);
-  for(int i = 1; i <= msg_browser->size(); i++) {
-    const char *c = msg_browser->text(i);
-    if(c[0] == '@')
-      fprintf(fp, "%s\n", &c[5]);
-    else
-      fprintf(fp, "%s\n", c);
-  }
-  Msg::StatusBar(2, true, "Wrote '%s'", filename);
-  fclose(fp);
-}
-
-void GUI::fatal_error(const char *filename)
-{
-  fl_alert("A fatal error has occurred which will force Gmsh to abort.\n"
-           "The error messages have been saved in the following file:\n\n%s",
-           filename);
-}
-
-// Create the visibility window
-
-void GUI::reset_visibility()
-{
-  if(vis_window) {
-    vis_browser->clear();
-    if(vis_window->shown())
-      visibility_cb(NULL, NULL);
-  }
-}
-
-class Vis_Browser : public Fl_Browser{
-  // special browser that reacts differently to Enter key
-  int handle(int event)
-  {
-    if(event == FL_KEYBOARD){
-      switch(Fl::event_key()) {
-      case FL_Enter:
-      case FL_KP_Enter:
-        visibility_ok_cb(NULL, NULL);
-        return 1;
-      }
-    }
-    return Fl_Browser::handle(event);
-  }
-public:
-  Vis_Browser(int x, int y, int w , int h, const char* c = 0)
-    : Fl_Browser(x, y, w, h, c){}
-};
-
-void GUI::create_visibility_window(bool redraw_only)
-{
-  if(vis_window) {
-    if(vis_window->shown() && redraw_only)
-      vis_window->redraw();
-    else
-      vis_window->show();
-    return;
-  }
-
-  static int cols[5] = { 15, 95, 95, 180, 0 };
-  static Fl_Menu_Item type_table[] = {
-    {"Elementary entities", 0, (Fl_Callback *) visibility_cb},
-    {"Physical groups", 0, (Fl_Callback *) visibility_cb},
-    {"Mesh partitions", 0, (Fl_Callback *) visibility_cb},
-    {0}
-  };
-
-  int width = cols[0] + cols[1] + cols[2] + cols[3] + 6 * WB;
-  int height = 18 * BH;
-  int brw = width - 4 * WB;
-
-  vis_window = new Dialog_Window(width, height, CTX.non_modal_windows, "Visibility");
-  vis_window->box(GMSH_WINDOW_BOX);
-
-  vis_type = new Fl_Choice(WB, WB, (width - 3 * WB) / 2, BH);
-  vis_type->menu(type_table);
-  
-  vis_butt[0] = new Fl_Check_Button(WB + (width - 3 * WB) / 2 + WB, WB, (width - 3 * WB) / 2, BH, 
-                                    "Set visibility recursively");
-  vis_butt[0]->type(FL_TOGGLE_BUTTON);
-  vis_butt[0]->value(1);
-
-  Fl_Tabs *o = new Fl_Tabs(WB, 2 * WB + BH, width - 2 * WB, height - 4 * WB - 2 * BH);
-  {
-    vis_group[0] = new Fl_Group(WB, 2 * WB + 2 * BH, width - 2 * WB, height - 4 * WB - 3 * BH, "Browser");
-
-    Fl_Button *o0 = new Fl_Button(2 * WB, 3 * WB + 2 * BH, cols[0], BH/2, "*");
-    o0->align(FL_ALIGN_TOP | FL_ALIGN_INSIDE);
-    o0->tooltip("Select/unselect all");
-    o0->callback(visibility_sort_cb, (void *)"*");
-
-    Fl_Button *o1 = new Fl_Button(2 * WB, 3 * WB + 2 * BH + BH/2, cols[0], BH - BH/2, "-");
-    o1->tooltip("Invert selection");
-    o1->callback(visibility_sort_cb, (void *)"-");
-
-    Fl_Button *o2 = new Fl_Button(2 * WB + cols[0], 3 * WB + 2 * BH, cols[1], BH, "Type");
-    o2->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
-    o2->tooltip("Sort by type");
-    o2->callback(visibility_sort_cb, (void *)"type");
-
-    Fl_Button *o3 = new Fl_Button(2 * WB + cols[0] + cols[1], 3 * WB + 2 * BH, cols[2], BH, "Number");
-    o3->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
-    o3->tooltip("Sort by number");
-    o3->callback(visibility_sort_cb, (void *)"number");
-
-    Fl_Button *o4 = new Fl_Button(2 * WB + cols[0] + cols[1] + cols[2], 3 * WB + 2 * BH, cols[3], BH, "Name");
-    o4->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
-    o4->tooltip("Sort by name");
-    o4->callback(visibility_sort_cb, (void *)"name");
-
-    Fl_Button *o5 = new Fl_Button(width - 4 * WB, 3 * WB + 2 * BH, 2 * WB, BH, "+");
-    o5->tooltip("Add parameter name for first selected item");
-    o5->callback(visibility_sort_cb, (void *)"+");
-
-    {
-      Fl_Group *o = new Fl_Group(2 * WB, 3 * WB + 3 * BH, brw, height - 7 * WB - 5 * BH);
-      
-      vis_browser = new Vis_Browser(2 * WB, 3 * WB + 3 * BH, brw, height - 7 * WB - 5 * BH);
-      vis_browser->type(FL_MULTI_BROWSER);
-      vis_browser->column_widths(cols);
-      
-      o->end();
-      Fl_Group::current()->resizable(o);
-    }
-
-    vis_push_butt[0] = new Fl_Button(width - 2 * BB - 3 * WB, height - 2 * BH - 3 * WB, BB, BH, "Delete");
-    vis_push_butt[0]->callback(visibility_delete_cb);
-
-    Fl_Return_Button *b1 = new Fl_Return_Button(width - 1 * BB - 2 * WB, height - 2 * BH - 3 * WB, BB, BH, "Apply");
-    b1->callback(visibility_ok_cb);
-
-    vis_group[0]->end();
-    Fl_Group::current()->resizable(vis_group[0]);
-  }
-  {
-    vis_group[1] = new Fl_Group(WB, 2 * WB + 2 * BH, width - 2 * WB, height - 4 * WB - 2 * BH, "Numeric input");
-    vis_group[1]->resizable(NULL);
-
-    for(int i = 0; i < 6; i++){
-      vis_input[i] = new Fl_Input(width/2-WB/2-IW, 3 * WB + (i+2) * BH, IW, BH);
-      vis_input[i]->align(FL_ALIGN_LEFT);
-      vis_input[i]->value("*");
-
-      Fl_Button *o1 = new Fl_Button(width/2+WB/2, 3 * WB + (i+2) * BH, BB, BH, "Show");
-      o1->callback(visibility_number_cb, (void *)(100+i));
-
-      Fl_Button *o2 = new Fl_Button(width/2+WB/2+BB+WB, 3 * WB + (i+2) * BH, BB, BH, "Hide");
-      o2->callback(visibility_number_cb, (void *)i);
-    }
-
-    vis_input[0]->label("Node");
-    vis_input[0]->tooltip("Enter node number, or *");
-
-    vis_input[1]->label("Element");
-    vis_input[1]->tooltip("Enter element number, or *");
-
-    vis_input[2]->label("Point");
-    vis_input[2]->tooltip("Enter point number, or *");
-
-    vis_input[3]->label("Line");
-    vis_input[3]->tooltip("Enter line number, or *");
-
-    vis_input[4]->label("Surface");
-    vis_input[4]->tooltip("Enter surface number, or *");
-
-    vis_input[5]->label("Volume");
-    vis_input[5]->tooltip("Enter volume number, or *");
-
-    vis_group[1]->end();
-  }
-  {
-    vis_group[2] = new Fl_Group(WB, 2 * WB + 2 * BH, width - 2 * WB, height - 4 * WB - 2 * BH, "Interactive");
-    vis_group[2]->resizable(NULL);
-
-    int ll = width/2 - BH - WB - IW;
-
-    Fl_Box *b2 = new Fl_Box(FL_NO_BOX, ll, 3 * WB + 2 * BH, IW, BH, 
-                            "Hide with the mouse:");
-    b2->align(FL_ALIGN_INSIDE|FL_ALIGN_CENTER);
-
-    Fl_Button *butt1 = new Fl_Button(ll, 3 * WB + 3 * BH, IW, BH, "Elements");
-    butt1->callback(visibility_interactive_cb, (void *)"hide_elements");
-    Fl_Button *butt2 = new Fl_Button(ll, 3 * WB + 4 * BH, IW, BH, "Points");
-    butt2->callback(visibility_interactive_cb, (void *)"hide_points");
-    Fl_Button *butt3 = new Fl_Button(ll, 3 * WB + 5 * BH, IW, BH, "Lines");
-    butt3->callback(visibility_interactive_cb, (void *)"hide_lines");
-    Fl_Button *butt4 = new Fl_Button(ll, 3 * WB + 6 * BH, IW, BH, "Surfaces");
-    butt4->callback(visibility_interactive_cb, (void *)"hide_surfaces");
-    Fl_Button *butt5 = new Fl_Button(ll, 3 * WB + 7 * BH, IW, BH, "Volumes");
-    butt5->callback(visibility_interactive_cb, (void *)"hide_volumes");
-
-    Fl_Button *butt6 = new Fl_Button(ll + IW + WB, 3 * WB + 3 * BH, 2 * BH, 5*BH, "Show\nAll");
-    butt6->callback(visibility_interactive_cb, (void *)"show_all");
-
-    int ll2 = ll + IW + WB + 2*BH + WB;
-
-    Fl_Box *b12 = new Fl_Box(FL_NO_BOX, ll2, 3 * WB + 2 * BH, IW, BH, 
-                             "Show with the mouse:");
-    b12->align(FL_ALIGN_INSIDE|FL_ALIGN_CENTER);
-
-    Fl_Button *butt11 = new Fl_Button(ll2, 3 * WB + 3 * BH, IW, BH, "Elements");
-    butt11->callback(visibility_interactive_cb, (void *)"show_elements");
-    Fl_Button *butt12 = new Fl_Button(ll2, 3 * WB + 4 * BH, IW, BH, "Points");
-    butt12->callback(visibility_interactive_cb, (void *)"show_points");
-    Fl_Button *butt13 = new Fl_Button(ll2, 3 * WB + 5 * BH, IW, BH, "Lines");
-    butt13->callback(visibility_interactive_cb, (void *)"show_lines");
-    Fl_Button *butt14 = new Fl_Button(ll2, 3 * WB + 6 * BH, IW, BH, "Surfaces");
-    butt14->callback(visibility_interactive_cb, (void *)"show_surfaces");
-    Fl_Button *butt15 = new Fl_Button(ll2, 3 * WB + 7 * BH, IW, BH, "Volumes");
-    butt15->callback(visibility_interactive_cb, (void *)"show_volumes");
-    
-    vis_group[2]->end();
-  }
-  o->end();
-
-  vis_window->resizable(o);
-  vis_window->size_range(width, 9 * BH + 6 * WB, width);
-
-  {
-    Fl_Button *o1 = new Fl_Button(width - 2 * BB - 2 * WB, height - BH - WB, BB, BH, "Save");
-    o1->callback(visibility_save_cb);
-
-    Fl_Button *o2 = new Fl_Button(width - BB - WB, height - BH - WB, BB, BH, "Cancel");
-    o2->callback(cancel_cb, (void *)vis_window);
-  }
-
-  vis_window->position(CTX.vis_position[0], CTX.vis_position[1]);
-  vis_window->end();
-}
-
-// Create the clipping planes window
-
-void GUI::reset_clip_browser()
-{
-  char str[128];
-  clip_browser->clear();
-  clip_browser->add("Geometry");
-  clip_browser->add("Mesh");
-  for(unsigned int i = 0; i < PView::list.size(); i++) {
-    sprintf(str, "View [%d]", i);
-    clip_browser->add(str);
-  }
-  int idx = clip_choice->value();
-  clip_browser->deselect();
-  for(int i = 0; i < clip_browser->size(); i++){
-    if((i == 0 && CTX.geom.clip & (1 << idx)) ||
-       (i == 1 && CTX.mesh.clip & (1 << idx)) ||
-       (i - 2 < PView::list.size() && 
-        PView::list[i - 2]->getOptions()->Clip & (1 << idx)))
-      clip_browser->select(i + 1);
-  }
-  for(int i = 0; i < 4; i++)
-    clip_value[i]->value(CTX.clip_plane[idx][i]);
-  for(int i = 4; i < 7; i++)
-    clip_value[i]->value(0.);
-  for(int i = 7; i < 10; i++)
-    clip_value[i]->value(1.);
-
-  for(int i = 0; i < 3; i++) {
-    clip_value[i]->step(0.01);
-    clip_value[i]->minimum(-1.0);
-    clip_value[i]->maximum(1.0);
-  }
-  double val1 = 0;
-  for(int i = 0; i < 3; i++)
-    val1 = std::max(val1, std::max(fabs(CTX.min[i]), fabs(CTX.max[i])));
-  val1 *= 1.5;
-  for(int i = 3; i < 10; i++){
-    clip_value[i]->step(val1/200.);
-    clip_value[i]->minimum(-val1);
-    clip_value[i]->maximum(val1);
-  }
-}
-
-void GUI::create_clip_window()
+void GUI::setStatus(const char *msg, int num)
 {
-  if(clip_window) {
-    reset_clip_browser();
-    clip_window->show();
-    return;
-  }
-
-  static Fl_Menu_Item plane_number[] = {
-    {"Plane 0", 0, 0},
-    {"Plane 1", 0, 0},
-    {"Plane 2", 0, 0},
-    {"Plane 3", 0, 0},
-    {"Plane 4", 0, 0},
-    {"Plane 5", 0, 0},
-    {0}
-  };
-
-  int width = 26 * fontsize;
-  int height = 10 * BH + 5 * WB;
-  int L = 7 * fontsize;
-
-  clip_window = new Dialog_Window(width, height, CTX.non_modal_windows, "Clipping");
-  clip_window->box(GMSH_WINDOW_BOX);
-
-  clip_browser = new Fl_Multi_Browser(WB, WB, L - WB, height - BH - 3 * WB);
-  clip_browser->callback(clip_update_cb);
-
-  Fl_Tabs *o = new Fl_Tabs(L + WB, WB, width - L - 2 * WB, height - 3 * WB - 4 * BH);
-  {
-    clip_group[0] = new Fl_Group(L + WB, WB + BH, width - L - 2 * WB, height - 3 * WB - 5 * BH, "Planes");
-
-    int BW = width - L - 4 * WB - 4 * fontsize;
-
-    clip_choice = new Fl_Choice(L + 2 * WB, 2 * WB + 1 * BH, BW, BH);
-    clip_choice->menu(plane_number);
-    clip_choice->callback(clip_num_cb);
-
-    Fl_Button *invert = new Fl_Button(L + 2 * WB, 2 * WB + 2 * BH, fontsize, 4 * BH, "-");
-    invert->callback(clip_invert_cb);
-    invert->tooltip("Invert orientation");
-    
-    clip_value[0] = new Fl_Value_Input(L + 2 * WB + fontsize, 2 * WB + 2 * BH, BW - fontsize, BH, "A");
-    clip_value[1] = new Fl_Value_Input(L + 2 * WB + fontsize, 2 * WB + 3 * BH, BW - fontsize, BH, "B");
-    clip_value[2] = new Fl_Value_Input(L + 2 * WB + fontsize, 2 * WB + 4 * BH, BW - fontsize, BH, "C");
-    clip_value[3] = new Fl_Value_Input(L + 2 * WB + fontsize, 2 * WB + 5 * BH, BW - fontsize, BH, "D");
-    for(int i = 0; i < 4; i++){
-      clip_value[i]->align(FL_ALIGN_RIGHT);
-      clip_value[i]->callback(clip_update_cb);
-    }
-
-    clip_group[0]->end();
-  }
-  {
-    clip_group[1] = new Fl_Group(L + WB, WB + BH, width - L - 2 * WB, height - 3 * WB - 5 * BH, "Box");
-    clip_group[1]->hide();
-
-    int w2 = (width - L - 4 * WB) / 2;
-    int BW = w2 - 2 * fontsize;
-    clip_value[4] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 1 * BH, BW, BH, "Cx");
-    clip_value[5] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 2 * BH, BW, BH, "Cy");
-    clip_value[6] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 3 * BH, BW, BH, "Cz");
-    clip_value[7] = new Fl_Value_Input(L + 2 * WB + w2, 2 * WB + 1 * BH, BW, BH, "Wx");
-    clip_value[8] = new Fl_Value_Input(L + 2 * WB + w2, 2 * WB + 2 * BH, BW, BH, "Wy");
-    clip_value[9] = new Fl_Value_Input(L + 2 * WB + w2, 2 * WB + 3 * BH, BW, BH, "Wz");
-    for(int i = 4; i < 10; i++){
-      clip_value[i]->align(FL_ALIGN_RIGHT);
-      clip_value[i]->callback(clip_update_cb);
-    }
-
-    clip_group[1]->end();
-  }
-  o->callback(clip_reset_cb);
-  o->end();
-
-  clip_butt[0] = new Fl_Check_Button(L + WB, 3 * WB + 6 * BH, width - L - 2 * WB, BH, "Keep whole elements");
-  clip_butt[1] = new Fl_Check_Button(L + WB, 3 * WB + 7 * BH, width - L - 2 * WB, BH, "Only draw intersecting volume layer");
-  clip_butt[2] = new Fl_Check_Button(L + WB, 3 * WB + 8 * BH, width - L - 2 * WB, BH, "Cut only volume elements");
-  for(int i = 0; i < 3; i++){
-    clip_butt[i]->type(FL_TOGGLE_BUTTON);
-    clip_butt[i]->callback(clip_update_cb);
-  }
-
-  reset_clip_browser();
-
-  {
-    Fl_Return_Button *o = new Fl_Return_Button(width - 3 * BB - 3 * WB, height - BH - WB, BB, BH, "Redraw");
-    o->callback(redraw_cb);
-  }
-  {
-    Fl_Button *o = new Fl_Button(width - 2 * BB - 2 * WB, height - BH - WB, BB, BH, "Reset");
-    o->callback(clip_reset_cb);
-  }
-  {
-    Fl_Button *o = new Fl_Button(width - BB - WB, height - BH - WB, BB, BH, "Cancel");
-    o->callback(cancel_cb, (void *)clip_window);
+  if(num == 0 || num == 1){
+    static char buff[2][1024];
+    strncpy(buff[num], msg, sizeof(buff[num]) - 1);
+    buff[num][sizeof(buff[num]) - 1] = '\0';
+    graph[0]->label[num]->label(buff[num]);
+    graph[0]->label[num]->redraw();
   }
-
-  clip_window->position(CTX.clip_position[0], CTX.clip_position[1]);
-  clip_window->end();
+  else if(num == 2){
+    int n = strlen(msg);
+    int i = 0;
+    while(i < n) if(msg[i++] == '\n') break;
+    strncpy(onscreen_buffer[0], msg, sizeof(onscreen_buffer[0]) - 1);
+    if(i < n) 
+      strncpy(onscreen_buffer[1], &msg[i], sizeof(onscreen_buffer[1]) - 1);
+    else
+      onscreen_buffer[1][0] = '\0';
+    onscreen_buffer[0][i-1] = '\0';
+    graph[0]->gl->make_current();
+    graph[0]->gl->redraw();
+    check();
+  }
+}
+
+void GUI::storeCurrentWindowsInfo()
+{
+  CTX.position[0] = menu->win->x();
+  CTX.position[1] = menu->win->y();
+  CTX.gl_position[0] = graph[0]->win->x();
+  CTX.gl_position[1] = graph[0]->win->y();
+  CTX.msg_position[0] = messages->win->x();
+  CTX.msg_position[1] = messages->win->y();
+  CTX.msg_size[0] = messages->win->w();
+  CTX.msg_size[1] = messages->win->h();
+  CTX.opt_position[0] = options->win->x();
+  CTX.opt_position[1] = options->win->y();
+  CTX.plugin_position[0] = plugins->win->x();
+  CTX.plugin_position[1] = plugins->win->y();
+  CTX.plugin_size[0] = plugins->win->w();
+  CTX.plugin_size[1] = plugins->win->h();
+  CTX.field_position[0] = fields->win->x();
+  CTX.field_position[1] = fields->win->y();
+  CTX.field_size[0] = fields->win->w();
+  CTX.field_size[1] = fields->win->h();
+  CTX.stat_position[0] = stats->win->x();
+  CTX.stat_position[1] = stats->win->y();
+  CTX.vis_position[0] = visibility->win->x();
+  CTX.vis_position[1] = visibility->win->y();
+  CTX.clip_position[0] = clipping->win->x();
+  CTX.clip_position[1] = clipping->win->y();
+  CTX.manip_position[0] = manip->win->x();
+  CTX.manip_position[1] = manip->win->y();
+  CTX.ctx_position[0] = geoContext->win->x();
+  CTX.ctx_position[1] = meshContext->win->y();
+  CTX.solver_position[0] = solver[0]->win->x();
+  CTX.solver_position[1] = solver[0]->win->y();
+  file_chooser_get_position(&CTX.file_chooser_position[0],
+                            &CTX.file_chooser_position[1]);
+}
+
+void GUI::callForSolverPlugin(int dim)
+{ 
+  GMSH_Solve_Plugin *sp = GMSH_PluginManager::instance()->findSolverPlugin();   
+  if(sp) sp->popupPropertiesForPhysicalEntity(dim);
 }
 
-// create the manipulator
+// Utility routines
 
-void GUI::update_manip_window(int force)
+int GetFontIndex(const char *fontname)
 {
-  if(force || manip_window->shown()){
-    double val1 = CTX.lc;
-    for(int i = 0; i < 3; i++){
-      manip_value[i]->value(g_opengl_window->getDrawContext()->r[i]);
-      manip_value[i]->minimum(-360.);
-      manip_value[i]->maximum(360.);
-      manip_value[i]->step(1.);
-
-      manip_value[i+3]->value(g_opengl_window->getDrawContext()->t[i]);
-      manip_value[i+3]->minimum(-val1);
-      manip_value[i+3]->maximum(val1);
-      manip_value[i+3]->step(val1/200.);
-
-      manip_value[i+6]->value(g_opengl_window->getDrawContext()->s[i]);
-      manip_value[i+6]->minimum(0.01);
-      manip_value[i+6]->maximum(100.);
-      manip_value[i+6]->step(0.01);
-    }
+  if(fontname){
+    for(int i = 0; i < NUM_FONTS; i++)
+      if(!strcmp(menu_font_names[i].label(), fontname))
+        return i;
   }
+  Msg::Error("Unknown font \"%s\" (using \"Helvetica\" instead)", fontname);
+  Msg::Info("Available fonts:");
+  for(int i = 0; i < NUM_FONTS; i++)
+    Msg::Info("  \"%s\"", menu_font_names[i].label());
+  return 4;
 }
 
-void GUI::create_manip_window()
+int GetFontEnum(int index)
 {
-  if(manip_window) {
-    update_manip_window(1);
-    manip_window->show();
-    return;
-  }
-
-  int width = 4 * BB + 2 * WB;
-  int height = 5 * BH + 3 * WB;
-
-  manip_window = new Dialog_Window(width, height, CTX.non_modal_windows, "Manipulator");
-  manip_window->box(GMSH_WINDOW_BOX);
-
-  Fl_Box *top[3], *left[3];
-  top[0] = new Fl_Box(WB + 1 * BB, 1 * WB + 0 * BH, BB, BH, "X");
-  top[1] = new Fl_Box(WB + 2 * BB, 1 * WB + 0 * BH, BB, BH, "Y");
-  top[2] = new Fl_Box(WB + 3 * BB, 1 * WB + 0 * BH, BB, BH, "Z");
-  left[0] = new Fl_Box(WB + 0 * BB, 1 * WB + 1 * BH, BB, BH, "Rotation");
-  left[1] = new Fl_Box(WB + 0 * BB, 1 * WB + 2 * BH, BB, BH, "Translation");
-  left[2] = new Fl_Box(WB + 0 * BB, 1 * WB + 3 * BH, BB, BH, "Scale");
-  for(int i = 0; i < 3; i++){  
-    top[i]->align(FL_ALIGN_INSIDE|FL_ALIGN_CENTER);
-    left[i]->align(FL_ALIGN_INSIDE|FL_ALIGN_CENTER);
-  }
-
-  manip_value[0] = new Fl_Value_Input(WB + 1 * BB, 1 * WB + 1 * BH, BB, BH);
-  manip_value[1] = new Fl_Value_Input(WB + 2 * BB, 1 * WB + 1 * BH, BB, BH);
-  manip_value[2] = new Fl_Value_Input(WB + 3 * BB, 1 * WB + 1 * BH, BB, BH);
-  manip_value[3] = new Fl_Value_Input(WB + 1 * BB, 1 * WB + 2 * BH, BB, BH);
-  manip_value[4] = new Fl_Value_Input(WB + 2 * BB, 1 * WB + 2 * BH, BB, BH);
-  manip_value[5] = new Fl_Value_Input(WB + 3 * BB, 1 * WB + 2 * BH, BB, BH);
-  manip_value[6] = new Fl_Value_Input(WB + 1 * BB, 1 * WB + 3 * BH, BB, BH);
-  manip_value[7] = new Fl_Value_Input(WB + 2 * BB, 1 * WB + 3 * BH, BB, BH);
-  manip_value[8] = new Fl_Value_Input(WB + 3 * BB, 1 * WB + 3 * BH, BB, BH);
-
-  for(int i = 0; i < 9; i++){
-    if(i < 3){
-      manip_value[i]->minimum(0.);
-      manip_value[i]->maximum(360.);
-      manip_value[i]->step(1.);
-    }
-    else if(i > 5){
-      manip_value[i]->minimum(0.1);
-      manip_value[i]->maximum(100.);
-      manip_value[i]->step(0.1);
-    }
-    manip_value[i]->align(FL_ALIGN_RIGHT);
-    manip_value[i]->callback(manip_update_cb);
-  }
-
-  {
-    Fl_Return_Button *o = new Fl_Return_Button(width - 2 * BB - 2 * WB, height - BH - WB, BB, BH, "Reset");
-    o->callback(status_xyz1p_cb, (void *)"reset");
-  }
-  {
-    Fl_Button *o = new Fl_Button(width - BB - WB, height - BH - WB, BB, BH, "Cancel");
-    o->callback(cancel_cb, (void *)manip_window);
-  }
-
-  manip_window->position(CTX.manip_position[0], CTX.manip_position[1]);
-  manip_window->end();
+  if(index >= 0 && index < NUM_FONTS)
+    return (long)menu_font_names[index].user_data();
+  return FL_HELVETICA;
 }
 
-// Create the about window
-
-void GUI::create_about_window()
+const char *GetFontName(int index)
 {
-  char buffer[1024];
-
-  if(about_window) {
-    about_window->show();
-    return;
-  }
-
-  int width = 28 * fontsize;
-  int height = 15 * BH + BH/2;
-
-  about_window = new Dialog_Window(width, height, CTX.non_modal_windows, "About Gmsh");
-  about_window->box(GMSH_WINDOW_BOX);
-
-  {
-    Fl_Browser *o = new Fl_Browser(0, 0, width, height - 2 * WB - BH);
-    o->box(FL_FLAT_BOX);
-    o->has_scrollbar(0); // no scrollbars
-    o->add(" ");
-    o->add("@c@b@.Gmsh");
-    o->add("@c@.A three-dimensional finite element mesh generator");
-    o->add("@c@.with built-in pre- and post-processing facilities");
-    o->add(" ");
-    o->add("@c@.Copyright (C) 1997-2008");
-#if defined(__APPLE__)
-    o->add("@c@.Christophe Geuzaine and Jean-Francois Remacle");
-#else
-    o->add("@c@.Christophe Geuzaine and Jean-Fran�ois Remacle");
-#endif
-    o->add(" ");
-    o->add("@c@.Please send all questions and bug reports to");
-    o->add("@c@b@.gmsh@geuz.org");
-    o->add(" ");
-    sprintf(buffer, "@c@.Version: %s", Get_GmshVersion());
-    o->add(buffer);
-    sprintf(buffer, "@c@.License: %s", Get_GmshShortLicense());
-    o->add(buffer);
-    sprintf(buffer, "@c@.Graphical user interface toolkit: FLTK %d.%d.%d", 
-            FL_MAJOR_VERSION, FL_MINOR_VERSION, FL_PATCH_VERSION);
-    o->add(buffer);
-    sprintf(buffer, "@c@.Build OS: %s", Get_GmshBuildOS());
-    o->add(buffer);
-    sprintf(buffer, "@c@.Build date: %s", Get_GmshBuildDate());
-    o->add(buffer);
-    sprintf(buffer, "@c@.Build host: %s", Get_GmshBuildHost());
-    o->add(buffer);
-    std::vector<std::string> lines = SplitWhiteSpace(Get_GmshBuildOptions(), 30);
-    for(unsigned int i = 0; i < lines.size(); i++){
-      if(!i)
-        sprintf(buffer, "@c@.Build options: %s", lines[i].c_str());
-      else
-        sprintf(buffer, "@c@.%s", lines[i].c_str());
-        o->add(buffer);
-      }
-    sprintf(buffer, "@c@.Packaged by: %s", Get_GmshPackager());
-    o->add(buffer);
-    o->add(" ");
-    o->add("@c@.Visit http://www.geuz.org/gmsh/ for more information");
-    o->add(" ");
-    o->callback(cancel_cb, (void *)about_window);
-  }
-
-  {
-    Fl_Button *o = new Fl_Button(width/2 - BB - WB/2, height - BH - WB, BB, BH, "License");
-    o->callback(help_license_cb);
-  }
-
-  {
-    Fl_Button *o = new Fl_Button(width/2 + WB/2, height - BH - WB, BB, BH, "Credits");
-    o->callback(help_credits_cb);
-  }
-
-  about_window->position(Fl::x() + Fl::w()/2 - width / 2,
-                         Fl::y() + Fl::h()/2 - height / 2);
-  about_window->end();
+  if(index >= 0 && index < NUM_FONTS)
+    return menu_font_names[index].label();
+  return "Helvetica";
 }
 
-
-// Create the window for geometry context dependant definitions
-
-void GUI::create_geometry_context_window(int num)
+int GetFontAlign(const char *alignstr)
 {
-  static Fl_Group *g[10];
-  int i;
-
-  if(context_geometry_window) {
-    for(i = 0; i < 6; i++)
-      g[i]->hide();
-    g[num]->show();
-    context_geometry_window->show();
-    return;
-  }
-
-  int width = 31 * fontsize;
-  int height = 5 * WB + 9 * BH;
-
-  context_geometry_window = new Dialog_Window(width, height, CTX.non_modal_windows, "Contextual Geometry Definitions");
-  context_geometry_window->box(GMSH_WINDOW_BOX);
-  {
-    Fl_Tabs *o = new Fl_Tabs(WB, WB, width - 2 * WB, height - 3 * WB - BH);
-    // 0: Parameter
-    {
-      g[0] = new Fl_Group(WB, WB + BH, width - 2 * WB, height - 3 * WB - 2 * BH, "Parameter");
-      context_geometry_input[0] = new Fl_Input(2 * WB, 2 * WB + 1 * BH, IW, BH, "Name");
-      context_geometry_input[0]->value("lc");
-      context_geometry_input[1] = new Fl_Input(2 * WB, 2 * WB + 2 * BH, IW, BH, "Value");
-      context_geometry_input[1]->value("0.1");
-      for(i = 0; i < 2; i++) {
-        context_geometry_input[i]->align(FL_ALIGN_RIGHT);
-      }
-      {
-        Fl_Return_Button *o = new Fl_Return_Button(width - BB - 2 * WB, 2 * WB + 7 * BH, BB, BH, "Add");
-        o->callback(con_geometry_define_parameter_cb);
-      }
-      g[0]->end();
-    }
-    // 1: Point
-    {
-      g[1] = new Fl_Group(WB, WB + BH, width - 2 * WB, height - 3 * WB - 2 * BH, "Point");
-      context_geometry_input[2] = new Fl_Input(2 * WB, 2 * WB + 1 * BH, IW, BH, "X coordinate");
-      context_geometry_input[2]->value("0");
-      context_geometry_input[3] = new Fl_Input(2 * WB, 2 * WB + 2 * BH, IW, BH, "Y coordinate");
-      context_geometry_input[3]->value("0");
-      context_geometry_input[4] = new Fl_Input(2 * WB, 2 * WB + 3 * BH, IW, BH, "Z coordinate");
-      context_geometry_input[4]->value("0");
-      context_geometry_input[5] = new Fl_Input(2 * WB, 2 * WB + 4 * BH, IW, BH, "Characteristic length");
-      context_geometry_input[5]->value("");
-      for(i = 2; i < 6; i++) {
-        context_geometry_input[i]->align(FL_ALIGN_RIGHT);
-      }
-      context_geometry_value[0] = new Fl_Value_Input(2 * WB, 2 * WB + 5 * BH, IW/3, BH);
-      context_geometry_value[1] = new Fl_Value_Input(2 * WB + IW/3, 2 * WB + 5 * BH, IW/3, BH);
-      context_geometry_value[2] = new Fl_Value_Input(2 * WB + 2*IW/3, 2 * WB + 5 * BH, IW/3, BH, "Snapping grid spacing");
-      for(i = 0; i < 3; i++) {
-        context_geometry_value[i]->align(FL_ALIGN_RIGHT);
-        context_geometry_value[i]->callback(con_geometry_snap_cb);
-      }
-      {
-        Fl_Return_Button *o = new Fl_Return_Button(width - BB - 2 * WB, 2 * WB + 7 * BH, BB, BH, "Add");
-        o->callback(con_geometry_define_point_cb);
-      }
-      g[1]->end();
-    }
-    // 2: Translation
-    {
-      g[2] = new Fl_Group(WB, WB + BH, width - 2 * WB, height - 3 * WB - 2 * BH, "Translation");
-      context_geometry_input[6] = new Fl_Input(2 * WB, 2 * WB + 1 * BH, IW, BH, "X component");
-      context_geometry_input[6]->value("0");
-      context_geometry_input[7] = new Fl_Input(2 * WB, 2 * WB + 2 * BH, IW, BH, "Y component");
-      context_geometry_input[7]->value("0");
-      context_geometry_input[8] = new Fl_Input(2 * WB, 2 * WB + 3 * BH, IW, BH, "Z component");
-      context_geometry_input[8]->value("1");
-      for(i = 6; i < 9; i++) {
-        context_geometry_input[i]->align(FL_ALIGN_RIGHT);
-      }
-      g[2]->end();
-    }
-    // 3: Rotation
-    {
-      g[3] = new Fl_Group(WB, WB + BH, width - 2 * WB, height - 3 * WB - 2 * BH, "Rotation");
-      context_geometry_input[9] = new Fl_Input(2 * WB, 2 * WB + 1 * BH, IW, BH, "X coordinate of an axis point");
-      context_geometry_input[9]->value("0");
-      context_geometry_input[10] = new Fl_Input(2 * WB, 2 * WB + 2 * BH, IW, BH, "Y coordinate of an axis point");
-      context_geometry_input[10]->value("0");
-      context_geometry_input[11] = new Fl_Input(2 * WB, 2 * WB + 3 * BH, IW, BH, "Z coordinate of an axis point");
-      context_geometry_input[11]->value("0");
-      context_geometry_input[12] = new Fl_Input(2 * WB, 2 * WB + 4 * BH, IW, BH, "X component of axis direction");
-      context_geometry_input[12]->value("0");
-      context_geometry_input[13] = new Fl_Input(2 * WB, 2 * WB + 5 * BH, IW, BH, "Y component of axis direction");
-      context_geometry_input[13]->value("1");
-      context_geometry_input[14] = new Fl_Input(2 * WB, 2 * WB + 6 * BH, IW, BH, "Z component of axis direction");
-      context_geometry_input[14]->value("0");
-      context_geometry_input[15] = new Fl_Input(2 * WB, 2 * WB + 7 * BH, IW, BH, "Angle in radians");
-      context_geometry_input[15]->value("Pi/4");
-      for(i = 9; i < 16; i++) {
-        context_geometry_input[i]->align(FL_ALIGN_RIGHT);
-      }
-      g[3]->end();
-    }
-    // 4: Scale
-    {
-      g[4] = new Fl_Group(WB, WB + BH, width - 2 * WB, height - 3 * WB - 2 * BH, "Scale");
-      context_geometry_input[16] = new Fl_Input(2 * WB, 2 * WB + 1 * BH, IW, BH, "X component of direction");
-      context_geometry_input[16]->value("0");
-      context_geometry_input[17] = new Fl_Input(2 * WB, 2 * WB + 2 * BH, IW, BH, "Y component of direction");
-      context_geometry_input[17]->value("0");
-      context_geometry_input[18] = new Fl_Input(2 * WB, 2 * WB + 3 * BH, IW, BH, "Z component of direction");
-      context_geometry_input[18]->value("0");
-      context_geometry_input[19] = new Fl_Input(2 * WB, 2 * WB + 4 * BH, IW, BH, "Factor");
-      context_geometry_input[19]->value("0.5");
-      for(i = 16; i < 20; i++) {
-        context_geometry_input[i]->align(FL_ALIGN_RIGHT);
-      }
-      g[4]->end();
-    }
-    // 5: Symmetry
-    {
-      g[5] = new Fl_Group(WB, WB + BH, width - 2 * WB, height - 3 * WB - 2 * BH, "Symmetry");
-      context_geometry_input[20] = new Fl_Input(2 * WB, 2 * WB + 1 * BH, IW, BH, "A");
-      context_geometry_input[20]->value("1");
-      context_geometry_input[21] = new Fl_Input(2 * WB, 2 * WB + 2 * BH, IW, BH, "B");
-      context_geometry_input[21]->value("0");
-      context_geometry_input[22] = new Fl_Input(2 * WB, 2 * WB + 3 * BH, IW, BH, "C");
-      context_geometry_input[22]->value("0");
-      context_geometry_input[23] = new Fl_Input(2 * WB, 2 * WB + 4 * BH, IW, BH, "D");
-      context_geometry_input[23]->value("1");
-      for(i = 20; i < 24; i++) {
-        context_geometry_input[i]->align(FL_ALIGN_RIGHT);
-      }
-      g[5]->end();
-    }
-    o->end();
-  }
-
-  {
-    Fl_Button *o = new Fl_Button(width - BB - WB, height - BH - WB, BB, BH, "Cancel");
-    o->callback(cancel_cb, (void *)context_geometry_window);
-  }
-
-  context_geometry_window->position(CTX.ctx_position[0], CTX.ctx_position[1]);
-  context_geometry_window->end();
-}
-
-// Create the window for physical context dependant definitions
-
-void GUI::call_for_solver_plugin (int dim)
-{ 
-  GMSH_Solve_Plugin *sp = GMSH_PluginManager::instance()->findSolverPlugin();   
-  if (sp) {
-    sp->popupPropertiesForPhysicalEntity(dim);
+  if(alignstr){
+    if(!strcmp(alignstr, "BottomLeft") || !strcmp(alignstr, "Left") ||
+       !strcmp(alignstr, "left"))
+      return 0;
+    else if(!strcmp(alignstr, "BottomCenter") || !strcmp(alignstr, "Center") ||
+            !strcmp(alignstr, "center"))
+      return 1;
+    else if(!strcmp(alignstr, "BottomRight") || !strcmp(alignstr, "Right") ||
+            !strcmp(alignstr, "right"))
+      return 2;
+    else if(!strcmp(alignstr, "TopLeft"))
+      return 3;
+    else if(!strcmp(alignstr, "TopCenter"))
+      return 4;
+    else if(!strcmp(alignstr, "TopRight"))
+      return 5;
+    else if(!strcmp(alignstr, "CenterLeft"))
+      return 6;
+    else if(!strcmp(alignstr, "CenterCenter"))
+      return 7;
+    else if(!strcmp(alignstr, "CenterRight"))
+      return 8;
   }
+  Msg::Error("Unknown font alignment \"%s\" (using \"Left\" instead)", alignstr);
+  Msg::Info("Available font alignments:");
+  Msg::Info("  \"Left\" (or \"BottomLeft\")");
+  Msg::Info("  \"Center\" (or \"BottomCenter\")");
+  Msg::Info("  \"Right\" (or \"BottomRight\")");
+  Msg::Info("  \"TopLeft\"");
+  Msg::Info("  \"TopCenter\"");
+  Msg::Info("  \"TopRight\"");
+  Msg::Info("  \"CenterLeft\"");
+  Msg::Info("  \"CenterCenter\"");
+  Msg::Info("  \"CenterRight\"");
+  return 0;
 }
 
-// Create the window for mesh context dependant definitions
-
-void GUI::create_mesh_context_window(int num)
+int GetFontSize()
 {
-  static Fl_Group *g[10];
-  static Fl_Menu menu_transfinite_dir[] = {
-    {"Left", 0, 0, 0},
-    {"Right", 0, 0, 0},
-    {"Alternated", 0, 0, 0},
-    {0}
-  };
-
-  if(context_mesh_window) {
-    for(int i = 0; i < 3; i++)
-      g[i]->hide();
-    g[num]->show();
-    context_mesh_window->show();
-    return;
-  }
-
-  int width = 29 * fontsize;
-  int height = 5 * WB + 5 * BH;
-
-  context_mesh_window = new Dialog_Window(width, height, CTX.non_modal_windows, "Contextual Mesh Definitions");
-  context_mesh_window->box(GMSH_WINDOW_BOX);
-  {
-    Fl_Tabs *o = new Fl_Tabs(WB, WB, width - 2 * WB, height - 3 * WB - BH);
-    // 0: Characteristic length
-    {
-      g[0] = new Fl_Group(WB, WB + BH, width - 2 * WB, height - 3 * WB - 2 * BH, "Characteristic Length");
-      context_mesh_input[0] = new Fl_Input(2 * WB, 2 * WB + 1 * BH, IW, BH, "Value");
-      context_mesh_input[0]->value("0.1");
-      context_mesh_input[0]->align(FL_ALIGN_RIGHT);
-      g[0]->end();
-    }
-    // 1: Transfinite line
-    {
-      g[1] = new Fl_Group(WB, WB + BH, width - 2 * WB, height - 3 * WB - 2 * BH, "Transfinite Line");
-      context_mesh_input[1] = new Fl_Input(2 * WB, 2 * WB + 1 * BH, IW, BH, "Number of points");
-      context_mesh_input[1]->value("10");
-      context_mesh_input[2] = new Fl_Input(2 * WB, 2 * WB + 3 * BH, IW, BH, "Parameter");
-      context_mesh_input[2]->value("1");
-      for(int i = 1; i < 3; i++) {
-        context_mesh_input[i]->align(FL_ALIGN_RIGHT);
-      }
-      static Fl_Menu_Item menu_trsf_mesh[] = {
-        {"Progression", 0, 0, 0},
-        {"Bump", 0, 0, 0},
-        {0}
-      };
-      context_mesh_choice[0] = new Fl_Choice(2 * WB, 2 * WB + 2 * BH, IW, BH, "Type");
-      context_mesh_choice[0]->menu(menu_trsf_mesh);
-      context_mesh_choice[0]->align(FL_ALIGN_RIGHT);
-      g[1]->end();
-    }
-    
-    // 2: Transfinite surface
-    {
-      g[2] = new Fl_Group(WB, WB + BH, width - 2 * WB, height - 3 * WB - 2 * BH, "Transfinite Surface");
-
-      context_mesh_choice[1] = new Fl_Choice(2 * WB, 2 * WB + 1 * BH, IW, BH, "Transfinite Arrangement");
-      context_mesh_choice[1]->menu(menu_transfinite_dir);
-      context_mesh_choice[1]->align(FL_ALIGN_RIGHT);
-
-      g[2]->end();
-    }
-    o->end();
+  if(CTX.fontsize > 0){
+    return CTX.fontsize;
   }
-
-  {
-    Fl_Button *o = new Fl_Button(width - BB - WB, height - BH - WB, BB, BH, "Cancel");
-    o->callback(cancel_cb, (void *)context_mesh_window);
+  else{
+    int w = Fl::w();
+    if(w <= 1024)      return 11;
+    else if(w <= 1280) return 12;
+    else if(w <= 1680) return 13;
+    else if(w <= 1920) return 14;
+    else               return 15;
   }
-
-  context_mesh_window->position(CTX.ctx_position[0], CTX.ctx_position[1]);
-  context_mesh_window->end();
 }
 
-
-// Create the windows for the solvers
-
-void GUI::create_solver_window(int num)
+void add_multiline_in_browser(Fl_Browser *o, const char *prefix, 
+                              const char *str, int wrap)
 {
-  if(solver[num].window) {
-    solver[num].window->show();
+  int start = 0, len;
+  if(!str || !strlen(str) || !strcmp(str, "\n")) {
+    o->add(" ");
     return;
   }
-
-  for(int i = 0; i < MAXSOLVERS; i++)
-    if(strlen(SINFO[num].option_name[i]))
-      SINFO[num].nboptions = i + 1;
-
-  int LL = 2 * IW;
-  int width = LL + BB + BB / 3 + 4 * WB;
-  int height = (8 + SINFO[num].nboptions) * BH + 6 * WB;
-  int BBS = (width - 8 * WB) / 5;
-  
-  solver[num].window = new Dialog_Window(width, height, CTX.non_modal_windows);
-  solver[num].window->box(GMSH_WINDOW_BOX);
-  {
-    Fl_Tabs *o = new Fl_Tabs(WB, WB, width - 2 * WB, height - 3 * WB - 1 * BH);
-    {
-      Fl_Group *g = new Fl_Group(WB, WB + BH, width - 2 * WB, height - 3 * WB - 2 * BH, "Controls");
-
-      solver[num].input[2] = new Fl_Input(2 * WB, 2 * WB + 1 * BH, LL, BH, "Solver");
-      solver[num].input[2]->callback(solver_ok_cb, (void *)num);
-
-      Fl_Button *b1 = new Fl_Button(width - 2 * WB - BBS, 2 * WB + 1 * BH, BBS, BH, "Choose");
-      b1->callback(solver_choose_executable_cb, (void *)num);
-      Fl_Button *b2 = new Fl_Button(width - 2 * WB - BBS, 2 * WB + 2 * BH, BBS, BH, "Save");
-      b2->callback(options_save_cb);
-
-      int ww = (LL - WB) / 2;
-      solver[num].butt[2] = new Fl_Check_Button(2 * WB, 2 * WB + 2 * BH, ww, BH, "Client/server");
-      solver[num].butt[0] = new Fl_Check_Button(2 * WB, 2 * WB + 3 * BH, ww, BH, "Pop-up messages");
-      solver[num].butt[1] = new Fl_Check_Button(3 * WB + ww, 2 * WB + 2 * BH, ww, BH, "Auto-load results");
-      
-      for(int i = 0; i < 3; i++){
-        solver[num].butt[i]->type(FL_TOGGLE_BUTTON);
-        solver[num].butt[i]->callback(solver_ok_cb, (void *)num);
-      }
-
-      solver[num].input[0] = new Fl_Input(2 * WB + BB / 2, 2 * WB + 4 * BH, LL - BB / 2, BH, "Input");
-      Fl_Button *b3 = new Fl_Button(width - 2 * WB - BBS, 2 * WB + 4 * BH, BBS, BH, "Choose");
-      b3->callback(solver_file_open_cb, (void *)num);
-
-      Fl_Button *b4 = new Fl_Button(2 * WB, 2 * WB + 4 * BH, BB / 2, BH, "Edit");
-      b4->callback(solver_file_edit_cb, (void *)num);
-
-      solver[num].input[1] = new Fl_Input(2 * WB, 2 * WB + 5 * BH, LL, BH, "Mesh");
-      Fl_Button *b5 = new Fl_Button(width - 2 * WB - BBS, 2 * WB + 5 * BH, BBS, BH, "Choose");
-      b5->callback(solver_choose_mesh_cb, (void *)num);
-
-      for(int i = 0; i < 3; i++) {
-        solver[num].input[i]->align(FL_ALIGN_RIGHT);
-      }
-
-      for(int i = 0; i < SINFO[num].nboptions; i++) {
-        solver[num].choice[i] = new Fl_Choice(2 * WB, 2 * WB + (6 + i) * BH, LL, BH,
-                                              SINFO[num].option_name[i]);
-        solver[num].choice[i]->align(FL_ALIGN_RIGHT);
-      }
-
-      static int arg[MAXSOLVERS][5][2];
-      for(int i = 0; i < 5; i++) {
-        if(strlen(SINFO[num].button_name[i])) {
-          arg[num][i][0] = num;
-          arg[num][i][1] = i;
-          solver[num].command[i] = new Fl_Button((2 + i) * WB + i * BBS, 
-                                                 3 * WB + (6 + SINFO[num].nboptions) * BH,
-                                                 BBS, BH, SINFO[num].button_name[i]);
-          solver[num].command[i]->callback(solver_command_cb, (void *)arg[num][i]);
-        }
+  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;
       }
-
-      g->end();
-    }
-    {
-      Fl_Group *g = new Fl_Group(WB, WB + BH, width - 2 * WB, height - 3 * WB - 2 * BH, "About");
-
-      Fl_Browser *o = new Fl_Browser(2 * WB, 2 * WB + 1 * BH, width - 4 * WB,
-                                     height - 5 * WB - 2 * BH);
-      o->add(" ");
-      add_multiline_in_browser(o, "@c@b@.", SINFO[num].name);
-      o->add(" ");
-      add_multiline_in_browser(o, "@c@. ", SINFO[num].help);
-
-      g->end();
+      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;
     }
-    o->end();
-  }
-
-  {
-    Fl_Button *b1 = new Fl_Button(width - 2 * BB - 2 * WB, height - BH - WB, BB, BH, "Kill solver");
-    b1->callback(solver_kill_cb, (void *)num);
-    Fl_Button *b2 = new Fl_Button(width - BB - WB, height - BH - WB, BB, BH, "Cancel");
-    b2->callback(cancel_cb, (void *)solver[num].window);
   }
-
-  solver[num].window->position(CTX.solver_position[0], CTX.solver_position[1]);
-  solver[num].window->end();
 }
diff --git a/Fltk/GUI.h b/Fltk/GUI.h
index 67fb543162c241bbc66e29edf7c764d8b1e8b79d..7cb7958dd7f7976d5c0c52902190a9d36664ee6a 100644
--- a/Fltk/GUI.h
+++ b/Fltk/GUI.h
@@ -6,345 +6,104 @@
 #ifndef _GUI_H_
 #define _GUI_H_
 
-#include <FL/Fl_Window.H>
-#include <FL/Fl_Double_Window.H>
-#include <FL/Fl_Box.H>
-#include <FL/Fl_Menu_Bar.H>
-#include <FL/Fl_Menu_Button.H>
-#include <FL/fl_draw.H>
-#include <FL/gl.h>
-#include <FL/Fl_Choice.H>
-#include <FL/Fl_Scroll.H>
-#include <FL/Fl_Tabs.H>
-#include <FL/Fl_Button.H>
-#include <FL/Fl_Return_Button.H>
-#include <FL/Fl_Repeat_Button.H>
-#include <FL/Fl_Light_Button.H>
-#include <FL/Fl_Check_Button.H>
-#include <FL/Fl_Input.H>
-#include <FL/Fl_Value_Input.H>
-#include <FL/Fl_Output.H>
-#include <FL/Fl_Multiline_Output.H>
-#include <FL/Fl_Bitmap.H>
-#include <FL/Fl_Browser.H>
-#include <FL/Fl_Multi_Browser.H>
-#include <FL/Fl_Hold_Browser.H>
-#include <FL/x.H>
-#include <FL/Fl_Color_Chooser.H>
-#include <FL/fl_ask.H>
-#include <FL/Fl_Tooltip.H>
-#include <FL/Fl_Shared_Image.H>
-#include <FL/Fl_File_Icon.H>
-#if defined(__APPLE__)
-#include <FL/Fl_Sys_Menu_Bar.H>
-#endif
-
 #include <vector>
-#include <string>
-#include <list>
-
-#include "Opengl_Window.h"
-#include "Colorbar_Window.h"
-#include "Popup_Button.h"
-#include "SpherePosition_Widget.h"
-
-#include "Field.h"
-
-// The dynamic contexts
-
-typedef struct{
-  const char *label;
-  Fl_Callback* callback;
-  void *arg;
-} Context_Item;
-
-extern Context_Item menu_geometry[]; 
-extern    Context_Item menu_geometry_elementary[]; 
-extern        Context_Item menu_geometry_elementary_add[]; 
-extern            Context_Item menu_geometry_elementary_add_new[]; 
-extern            Context_Item menu_geometry_elementary_add_translate[]; 
-extern            Context_Item menu_geometry_elementary_add_rotate[]; 
-extern            Context_Item menu_geometry_elementary_add_scale[]; 
-extern            Context_Item menu_geometry_elementary_add_symmetry[]; 
-extern        Context_Item menu_geometry_elementary_translate[]; 
-extern        Context_Item menu_geometry_elementary_rotate[]; 
-extern        Context_Item menu_geometry_elementary_scale[]; 
-extern        Context_Item menu_geometry_elementary_symmetry[]; 
-extern        Context_Item menu_geometry_elementary_extrude[]; 
-extern            Context_Item menu_geometry_elementary_extrude_translate[]; 
-extern            Context_Item menu_geometry_elementary_extrude_rotate[]; 
-extern        Context_Item menu_geometry_elementary_delete[]; 
-extern        Context_Item menu_geometry_elementary_split[]; 
-extern    Context_Item menu_geometry_physical[]; 
-extern        Context_Item menu_geometry_physical_add[]; 
-extern Context_Item menu_mesh[]; 
-extern    Context_Item menu_mesh_edit[]; 
-extern        Context_Item menu_mesh_delete[]; 
-extern    Context_Item menu_mesh_define[]; 
-extern        Context_Item menu_mesh_define_transfinite[]; 
-extern Context_Item menu_solver[]; 
-extern Context_Item menu_post[]; 
-
-// A generalized dialogbox for plugins
-
-#define MAX_PLUGIN_OPTIONS 50
-
-class GMSH_Plugin;
-
-struct PluginDialogBox
-{
-  Fl_Group *group;
-  Fl_Value_Input *value[MAX_PLUGIN_OPTIONS];
-  Fl_Input *input[MAX_PLUGIN_OPTIONS];
-};
-
-// The dialog for solvers
-
-struct SolverDialogBox
-{
-  Fl_Window *window;
-  Fl_Input *input[50];
-  Fl_Choice *choice[10];
-  Fl_Check_Button *butt[10];
-  Fl_Button *command[10];
-};
-
-// The GUI class contains only the important widgets (which can be set/queried).
+#include <FL/Fl.H>
+
+#define GMSH_WINDOW_BOX FL_FLAT_BOX
+#define NB_BUTT_SCROLL 25
+#define NB_HISTORY_MAX 1000
+#define IW (10 * _fontsize)    // input field width
+#define BB (7 * _fontsize)     // width of a button with internal label
+#define BH (2 * _fontsize + 1) // button height
+#define WB (7)                 // window border
+
+class graphicWindow;
+class menuWindow;
+class optionWindow;
+class fieldWindow;
+class pluginWindow;
+class statisticsWindow;
+class visibilityWindow;
+class clippingWindow;
+class messageWindow;
+class manipWindow;
+class geometryContextWindow;
+class meshContextWindow;
+class aboutWindow;
+class solverWindow;
 
 class GUI{
-
-  int MH, fontsize;
-  Fl_Scroll *m_scroll;
-
-  void add_multiline_in_browser(Fl_Browser *o, const char *prefix, const char *str, int wrap=0);
-
-public:
-
-  // graphic window
-  Fl_Window        *g_window;
-  Opengl_Window    *g_opengl_window;
-  Fl_Button        *g_status_butt[12];
-  Fl_Box           *g_status_label[2];
-
-  // menu window
-  Fl_Window        *m_window;
-#if defined(__APPLE__)
-  Fl_Sys_Menu_Bar  *m_sys_menu_bar;
-#endif
-  Fl_Menu_Bar      *m_menu_bar;
-  Fl_Choice        *m_module_butt;
-  Fl_Button        *m_navig_butt[2];
-  std::vector<Fl_Button*>       m_push_butt;
-  std::vector<Fl_Light_Button*> m_toggle_butt;
-  std::vector<Fl_Button*>       m_toggle2_butt;
-  std::vector<Popup_Button*>    m_popup_butt;
-  std::vector<Popup_Button*>    m_popup2_butt;
-  std::vector<char*>            m_pop_label;
-
-  // Option window
-  Fl_Window        *opt_window;
-  Fl_Hold_Browser  *opt_browser;
-  Fl_Return_Button *opt_redraw;
-
-  // general options
-  Fl_Group         *gen_group;
-  Fl_Check_Button  *gen_butt[20];
-  Fl_Button        *gen_push_butt[20];
-  Fl_Value_Input   *gen_value[50];
-  Fl_Button        *gen_col[50];
-  Fl_Input         *gen_input[20];
-  Fl_Choice        *gen_choice[20];
-  SpherePosition_Widget *gen_sphere;
-
-  // geometry options
-  Fl_Group         *geo_group;
-  Fl_Check_Button  *geo_butt[20];
-  Fl_Value_Input   *geo_value[20];
-  Fl_Button        *geo_col[50];
-  Fl_Choice        *geo_choice[20];
-  
-  // mesh options
-  Fl_Group         *mesh_group;
-  Fl_Group         *mesh_cut_plane;
-  Fl_Check_Button  *mesh_butt[50];
-  Fl_Return_Button *mesh_retbutt[50];
-  Fl_Input         *mesh_input[20];
-  Fl_Value_Input   *mesh_value[50];
-  Fl_Button        *mesh_col[50];
-  Fl_Choice        *mesh_choice[20];
-  Fl_Menu_Button   *mesh_menu_butt;
-
-  // solver options
-  Fl_Group         *solver_group;
-  Fl_Check_Button  *solver_butt[20];
-  Fl_Value_Input   *solver_value[20];
-  Fl_Input         *solver_input[20];
-
-  // post-processing options
-  Fl_Group         *post_group;
-  Fl_Check_Button  *post_butt[20];
-  Fl_Value_Input   *post_value[20];
-  Fl_Choice        *post_choice[20];
-
-  // view options
-  int view_number;
-  Fl_Group         *view_group;
-  Fl_Group         *view_range, *view_vector;
-  Fl_Check_Button  *view_butt[100];
-  Fl_Value_Input   *view_value[100];
-  Fl_Input         *view_input[100];
-  Fl_Repeat_Button *view_butt_rep[100];
-  Fl_Button        *view_push_butt[100];
-  Fl_Choice        *view_choice[100];
-  Fl_Button        *view_col[50];
-  Colorbar_Window  *view_colorbar_window;
-  Fl_Return_Button *view_ok;
-  Fl_Menu_Button   *view_menu_butt[2];
-
-  // Field window
-  Fl_Window        *field_window;
-  Fl_Hold_Browser  *field_browser;
-  std::list<Fl_Widget*> field_options_widget;
-  Fl_Scroll        *field_options_scroll;
-  Fl_Group         *field_editor_group;
-  Fl_Box           *field_title;
-  Fl_Check_Button  *field_background_btn;
-  Fl_Menu_Button   *field_put_on_view_btn;
-  Fl_Browser       *field_help_display;
-  Fl_Button        *field_delete_btn;
-  int              field_selected_id;
-
-  // Plugin window
-  Fl_Window        *plugin_window;
-  Fl_Hold_Browser  *plugin_browser;
-  Fl_Multi_Browser *plugin_view_browser;
-  Fl_Return_Button *plugin_run;
-
-  // statistics window
-  Fl_Window        *stat_window;
-  Fl_Output        *stat_value[50];
-  Fl_Button        *stat_butt[8];
-  double            quality[4][100];
-
-  // message window
-  Fl_Window        *msg_window;
-  Fl_Browser       *msg_browser;
-  Fl_Check_Button  *msg_butt;
-
-  // visibility window
-  Fl_Window        *vis_window;
-  Fl_Group         *vis_group[5];
-  Fl_Choice        *vis_type;
-  Fl_Browser       *vis_browser;
-  Fl_Check_Button  *vis_butt[2];
-  Fl_Button        *vis_push_butt[2];
-  Fl_Input         *vis_input[10];
-
-  // clipping planes window
-  Fl_Window        *clip_window;
-  Fl_Choice        *clip_choice;
-  Fl_Multi_Browser *clip_browser;
-  Fl_Value_Input   *clip_value[10];
-  Fl_Check_Button  *clip_butt[3];
-  Fl_Group         *clip_group[2];
-
-  // manipulator window
-  Fl_Window        *manip_window;
-  Fl_Value_Input   *manip_value[9];
-
-  // about window
-  Fl_Window        *about_window;
-
-  // geometry context window
-  Fl_Window        *context_geometry_window;
-  Fl_Input         *context_geometry_input[30];
-  Fl_Value_Input   *context_geometry_value[10];
-
-  // mesh context window
-  Fl_Window        *context_mesh_window;
-  Fl_Input         *context_mesh_input[20];
-  Fl_Choice        *context_mesh_choice[20];
-
-  // solver windows
-  SolverDialogBox  solver[5];
-
-  // on-screen persistent messages
+ private:
+  int _fontsize;
+  static GUI *_instance;
+ public:
   char onscreen_buffer[2][256];
-
-  // the constructor
+  int selection, try_selection, quit_selection, end_selection;
+  int undo_selection, invert_selection;
+  int try_selection_xywh[4];
+ public:
+  std::vector<graphicWindow*> graph;
+  menuWindow *menu;
+  optionWindow *options;
+  fieldWindow *fields;
+  pluginWindow *plugins;
+  statisticsWindow *stats;
+  visibilityWindow *visibility;
+  clippingWindow *clipping;
+  messageWindow *messages;
+  manipWindow *manip;
+  geometryContextWindow *geoContext;
+  meshContextWindow *meshContext;
+  aboutWindow *about;
+  std::vector<solverWindow*> solver;
+ public:
   GUI(int argc, char **argv);
-
-  // create the windows
-  void create_menu_window();
-  void create_graphic_window();
-  void create_option_window();
-  void hide_all_option_groups();
-  void create_general_options_window();
-  void create_geometry_options_window();
-  void create_mesh_options_window();
-  void create_solver_options_window();
-  void create_post_options_window();
-  void create_view_options_window(int numview);
-  void create_plugin_dialog_box(GMSH_Plugin *p, int x, int y, int width, int height);
-  void create_plugin_window(int numview);
-  void create_field_window();
-  void create_visibility_window(bool redraw_only=false);
-  void create_clip_window();
-  void create_manip_window();
-  void create_statistics_window();
-  void create_message_window(bool redraw_only=false);
-  void create_about_window();
-  void create_geometry_context_window(int num);
-  void call_for_solver_plugin (int dim);
-  void create_mesh_context_window(int num);
-  void create_solver_window(int num);
-
-  // general purpose interaction
-  int run();
-  void check();
-  void wait();
-  void wait(double time);
-  void make_opengl_current();
-  void redraw_opengl();
-  void set_size(int w, int h);
-  void set_context(Context_Item menu[], int flag);
-  int  get_context();
-  void update_views();
-  void update_fields();
-  void edit_field(Field *f);
-  void save_field_options();
-  void load_field_options();
-  void load_field_list();
-  void load_field_view_list();
-  void set_anim_buttons(int mode);
-  void check_anim_buttons();
-  void set_status(const char *msg, int num);
-  void add_message(const char *msg);
-  void save_message(const char *filename);
-  void fatal_error(const char *filename);
-  void set_statistics(bool compute_quality);
-  void update_view_window(int numview);
-  void set_title(const char *str);
-  void add_handler();
-  int  global_shortcuts(int event);
-  int  arrow_shortcuts();
-  void reset_visibility();
-  void reset_option_browser();
-  void reset_plugin_view_browser();
-  void reset_clip_browser();
-  void update_manip_window(int force=0);
-  void reset_external_view_list();
-  int  selection, try_selection, quit_selection, end_selection;
-  int  undo_selection, invert_selection;
-  int  try_selection_xywh[4];
+  ~GUI(){}
+  // return the single static instance of the GUI
+  static GUI *instance(int argc=0, char **argv=0);
+  // check if the GUI is available
+  static bool GUI::available(){ return (_instance != 0); }
+  // run the GUI until there's no window left
+  int run(){ return Fl::run(); }
+  // check (now!) if there are any pending events, and process them
+  void check(){ Fl::check(); }
+  // wait (possibly indefinitely) for any events, then process them
+  void wait(){ Fl::wait(); }
+  // wait (at most time seconds) for any events, then process them
+  void wait(double time){ Fl::wait(time); }
+  // test application-level keyboard shortcuts
+  int testGlobalShortcuts(int event);
+  // test the arrow shortcuts (not in the application-level shortcuts)
+  // since it is used elsewhere (where we want to override widget
+  // navigation). This is necessary since FLTK 1.1.
+  int testArrowShortcuts();
+  // set the size of the graphic window
+  void setGraphicSize(int w, int h);
+  // set the title of the graphic window
+  void setGraphicTitle(const char *str);
+  // update the GUI when views get added or deleted
+  void updateViews();
+  // update the GUI when fields change
+  void updateFields();
+  // reset the visibility window
+  void resetVisibility();
+  // store current window positions and sizes in CTX
+  void storeCurrentWindowsInfo();
+  // display status message
+  void setStatus(const char *msg, int num);
+  // create the window for physical context dependant definitions
+  void callForSolverPlugin(int dim);
 };
 
-// some utility font functions
+// utility functions
 int GetFontIndex(const char *fontname);
 int GetFontEnum(int index);
 const char *GetFontName(int index);
 int GetFontAlign(const char *alignstr);
 int GetFontSize();
 
-#endif
+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/Main.cpp b/Fltk/Main.cpp
index 4bfbd7647877515295dfde5190ba9efdb854836b..6b1b8106542d4cd84539003afc47b8dbd3c8f778 100644
--- a/Fltk/Main.cpp
+++ b/Fltk/Main.cpp
@@ -6,8 +6,8 @@
 #include <string>
 #include <time.h>
 #include "GUI.h"
+#include "menuWindow.h"
 #include "Gmsh.h"
-#include "GmshUI.h"
 #include "GmshMessage.h"
 #include "Draw.h"
 #include "Context.h"
@@ -24,8 +24,6 @@
 
 extern Context_T CTX;
 
-GUI *WID = 0;
-
 int main(int argc, char *argv[])
 {
   // Log some info
@@ -67,18 +65,12 @@ int main(int argc, char *argv[])
     Msg::Exit(0);
   }
 
-  // Interactive Gmsh
-  CTX.batch = -1; // The GUI is not ready yet for interactivity
-
   // Create the GUI
-  WID = new GUI(argc, argv);
+  GUI::instance(argc, argv);
 
   // Set all previously defined options in the GUI
   Init_Options_GUI(0);
 
-  // The GUI is ready
-  CTX.batch = 0;
-
   // Say welcome!
   Msg::StatusBar(1, false, "Geometry");
   Msg::StatusBar(2, false, "Gmsh %s", Get_GmshVersion());
@@ -97,7 +89,7 @@ int main(int argc, char *argv[])
   Msg::Info("-------------------------------------------------------");
 
   // Display the GUI immediately to have a quick "a la Windows" launch time
-  WID->check();
+  GUI::instance()->check();
 
   // Open project file and merge all other input files
   OpenProject(CTX.filename);
@@ -110,20 +102,20 @@ int main(int argc, char *argv[])
   
   if(CTX.post.combine_time){
     PView::combine(true, 2, CTX.post.combine_remove_orig);
-    WID->update_views();
+    GUI::instance()->updateViews();
   }
 
   // Init first context
   switch (CTX.initial_context) {
-  case 1: WID->set_context(menu_geometry, 0); break;
-  case 2: WID->set_context(menu_mesh, 0); break;
-  case 3: WID->set_context(menu_solver, 0); break;
-  case 4: WID->set_context(menu_post, 0); break;
+  case 1: GUI::instance()->menu->setContext(menu_geometry, 0); break;
+  case 2: GUI::instance()->menu->setContext(menu_mesh, 0); break;
+  case 3: GUI::instance()->menu->setContext(menu_solver, 0); break;
+  case 4: GUI::instance()->menu->setContext(menu_post, 0); break;
   default: // automatic
     if(PView::list.size())
-      WID->set_context(menu_post, 0);
+      GUI::instance()->menu->setContext(menu_post, 0);
     else
-      WID->set_context(menu_geometry, 0);
+      GUI::instance()->menu->setContext(menu_geometry, 0);
     break;
   }
 
@@ -143,5 +135,5 @@ int main(int argc, char *argv[])
   if(CTX.solver.listen) Solver(-1, NULL);
 
   // loop
-  return WID->run();
+  return GUI::instance()->run();
 }
diff --git a/Fltk/Makefile b/Fltk/Makefile
index ee51ec063e2b1b179ae18cca9124d44bdc92220d..1d8dc146d2f2874329f42fa77b38984712e3f4ad 100644
--- a/Fltk/Makefile
+++ b/Fltk/Makefile
@@ -16,13 +16,28 @@ CFLAGS = ${OPTIM} ${FLAGS} ${INC} ${SYSINCLUDE}
 
 SRC = Main.cpp \
       GUI.cpp\
-        GUI_Extras.cpp\
-        GUI_Projection.cpp\
-        GUI_Classifier.cpp\
+        graphicWindow.cpp\
+          openglWindow.cpp\
+        menuWindow.cpp\
+        optionWindow.cpp\
+          colorbarWindow.cpp\
+        fieldWindow.cpp\
+        pluginWindow.cpp\
+        statisticsWindow.cpp\
+        visibilityWindow.cpp\
+        clippingWindow.cpp\
+        messageWindow.cpp\
+        manipWindow.cpp\
+        contextWindow.cpp\
+        solverWindow.cpp\
+        aboutWindow.cpp\
+        fileDialogs.cpp\
+        extraDialogs.cpp\
+        projectionEditor.cpp\
+        classificationEditor.cpp\
+        partitionDialog.cpp\
       Callbacks.cpp\
       Draw.cpp\
-      Opengl_Window.cpp\
-      Colorbar_Window.cpp\
       Solvers.cpp
 
 OBJ = ${SRC:.cpp=${OBJEXT}}
@@ -54,162 +69,245 @@ depend:
 	rm -f Makefile.new
 
 # DO NOT DELETE THIS LINE
-Main${OBJEXT}: Main.cpp GUI.h Opengl_Window.h ../Graphics/drawContext.h \
-  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h Colorbar_Window.h \
-  ../Common/GmshUI.h ../Post/ColorTable.h Popup_Button.h \
-  SpherePosition_Widget.h ../Mesh/Field.h ../Post/PView.h \
-  ../Common/Gmsh.h ../Common/GmshMessage.h Draw.h ../Common/Context.h \
-  ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h ../Common/Options.h \
+Main${OBJEXT}: Main.cpp GUI.h menuWindow.h popupButton.h ../Common/Gmsh.h \
+  ../Common/GmshMessage.h Draw.h ../Common/Context.h ../Geo/CGNSOptions.h \
+  ../Mesh/PartitionOptions.h ../Common/Options.h ../Post/ColorTable.h \
   ../Parser/Parser.h ../Common/OpenFile.h ../Common/CommandLine.h \
   Solvers.h ../Plugin/PluginManager.h ../Geo/GModel.h ../Geo/GVertex.h \
   ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GPoint.h \
+  ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h \
+  ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h \
+  ../Geo/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/GEdgeLoop.h \
+  ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h \
+  ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SPoint3.h \
+  ../Geo/SBoundingBox3d.h ../Mesh/Field.h ../Post/PView.h \
+  ../Mesh/BackgroundMesh.h
+GUI${OBJEXT}: GUI.cpp GUI.h graphicWindow.h openglWindow.h \
+  ../Graphics/drawContext.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
+  menuWindow.h popupButton.h optionWindow.h spherePositionWidget.h \
+  colorbarWindow.h ../Post/ColorTable.h fieldWindow.h pluginWindow.h \
+  statisticsWindow.h visibilityWindow.h clippingWindow.h messageWindow.h \
+  manipWindow.h contextWindow.h solverWindow.h aboutWindow.h \
+  fileDialogs.h ../Common/GmshDefines.h ../Common/GmshMessage.h \
+  ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h \
+  ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/GPoint.h \
+  ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h \
+  ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h \
+  ../Geo/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/GEdgeLoop.h \
+  ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h \
+  ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SPoint3.h \
+  ../Geo/SBoundingBox3d.h ../Post/PView.h Solvers.h ../Mesh/Field.h \
+  ../Plugin/Plugin.h ../Common/Options.h ../Post/PViewDataList.h \
+  ../Post/PViewData.h ../Common/ListUtils.h ../Numeric/GmshMatrix.h \
+  ../Plugin/PluginManager.h Callbacks.h ../Common/OpenFile.h \
+  ../Common/Context.h ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h
+graphicWindow${OBJEXT}: graphicWindow.cpp graphicWindow.h openglWindow.h \
+  ../Graphics/drawContext.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
+  shortcutWindow.h ../Post/PView.h ../Post/PViewData.h Callbacks.h \
+  ../Common/Context.h ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h
+openglWindow${OBJEXT}: openglWindow.cpp openglWindow.h ../Graphics/drawContext.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h graphicWindow.h manipWindow.h \
+  contextWindow.h ../Common/GmshDefines.h ../Common/GmshMessage.h Draw.h \
+  ../Numeric/Numeric.h ../Numeric/NumericEmbedded.h ../Common/Context.h \
+  ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h \
+  ../Graphics/SelectBuffer.h ../Graphics/drawContext.h ../Geo/GVertex.h \
+  ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h \
   ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
   ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/GFace.h ../Geo/GEntity.h \
   ../Geo/GPoint.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h \
-  ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h \
-  ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Mesh/BackgroundMesh.h
-GUI${OBJEXT}: GUI.cpp ../Common/GmshUI.h ../Common/GmshDefines.h \
-  ../Common/GmshMessage.h ../Numeric/Numeric.h \
-  ../Numeric/NumericEmbedded.h ../Common/Context.h ../Geo/CGNSOptions.h \
-  ../Mesh/PartitionOptions.h ../Common/Options.h ../Post/ColorTable.h \
-  Draw.h GUI.h Opengl_Window.h ../Graphics/drawContext.h \
-  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h Colorbar_Window.h \
-  Popup_Button.h SpherePosition_Widget.h ../Mesh/Field.h ../Post/PView.h \
-  Callbacks.h Win32Icon.h ../Common/OpenFile.h ../Common/CommandLine.h \
-  ../Mesh/Generator.h Solvers.h ../Plugin/PluginManager.h \
-  ../Plugin/Plugin.h ../Post/PViewDataList.h ../Post/PViewData.h \
-  ../Common/ListUtils.h ../Numeric/GmshMatrix.h Shortcut_Window.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h ../Geo/GModel.h \
-  ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
-  ../Geo/SBoundingBox3d.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h \
+  ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h GUI.h \
+  ../Geo/MElement.h ../Geo/MVertex.h ../Geo/SPoint2.h ../Geo/SPoint3.h \
+  ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h ../Geo/MFace.h \
+  ../Geo/MVertex.h ../Geo/SVector3.h ../Numeric/FunctionSpace.h \
+  ../Numeric/GmshMatrix.h
+menuWindow${OBJEXT}: menuWindow.cpp GUI.h menuWindow.h popupButton.h \
+  shortcutWindow.h Callbacks.h ../Common/Options.h ../Post/ColorTable.h \
+  Solvers.h ../Common/GmshMessage.h ../Post/PView.h ../Geo/SPoint3.h \
+  ../Post/PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
+  ../Post/PViewOptions.h ../Post/ColorTable.h ../Common/Context.h \
+  ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h
+optionWindow${OBJEXT}: optionWindow.cpp GUI.h optionWindow.h \
+  spherePositionWidget.h colorbarWindow.h ../Post/ColorTable.h \
+  shortcutWindow.h ../Common/GmshMessage.h ../Common/Options.h \
+  Callbacks.h ../Post/PView.h ../Geo/SPoint3.h ../Post/PViewData.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Post/PViewOptions.h \
+  ../Post/ColorTable.h ../Common/Context.h ../Geo/CGNSOptions.h \
+  ../Mesh/PartitionOptions.h
+colorbarWindow${OBJEXT}: colorbarWindow.cpp colorbarWindow.h \
+  ../Post/ColorTable.h GUI.h ../Common/Context.h ../Geo/CGNSOptions.h \
+  ../Mesh/PartitionOptions.h
+fieldWindow${OBJEXT}: fieldWindow.cpp GUI.h fieldWindow.h shortcutWindow.h \
+  ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h \
+  ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
+  ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h \
+  ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h \
+  ../Geo/SPoint2.h ../Geo/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h \
+  ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h \
+  ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SPoint3.h \
+  ../Geo/SBoundingBox3d.h ../Post/PView.h Callbacks.h \
+  ../Common/GmshMessage.h ../Mesh/Field.h ../Geo/GeoStringInterface.h \
+  ../Common/ListUtils.h ../Common/Context.h ../Geo/CGNSOptions.h \
+  ../Mesh/PartitionOptions.h
+pluginWindow${OBJEXT}: pluginWindow.cpp GUI.h pluginWindow.h shortcutWindow.h \
+  ../Post/PView.h ../Geo/SPoint3.h ../Plugin/PluginManager.h \
+  ../Plugin/Plugin.h ../Common/Options.h ../Post/ColorTable.h \
+  ../Common/GmshMessage.h ../Post/PViewDataList.h ../Post/PViewData.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Common/ListUtils.h \
+  ../Numeric/GmshMatrix.h Callbacks.h ../Common/Context.h \
+  ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h
+statisticsWindow${OBJEXT}: statisticsWindow.cpp GUI.h statisticsWindow.h \
+  shortcutWindow.h ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h \
+  ../Geo/Range.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h \
   ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
   ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/GFace.h ../Geo/GEntity.h \
   ../Geo/GPoint.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h \
   ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h \
-  ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/GeoStringInterface.h \
-  ../Common/StringUtils.h
-GUI_Extras${OBJEXT}: GUI_Extras.cpp ../Common/GmshUI.h ../Common/GmshDefines.h \
-  ../Common/CreateFile.h ../Common/Options.h ../Post/ColorTable.h \
-  ../Common/Context.h ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h \
-  Draw.h GUI.h Opengl_Window.h ../Graphics/drawContext.h \
-  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h Colorbar_Window.h \
-  Popup_Button.h SpherePosition_Widget.h ../Mesh/Field.h ../Post/PView.h \
-  Shortcut_Window.h ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h \
-  ../Geo/Range.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/GPoint.h \
+  ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Post/PView.h Callbacks.h \
+  ../Mesh/Generator.h ../Common/Context.h ../Geo/CGNSOptions.h \
+  ../Mesh/PartitionOptions.h
+visibilityWindow${OBJEXT}: visibilityWindow.cpp GUI.h visibilityWindow.h \
+  shortcutWindow.h Callbacks.h ../Common/Context.h ../Geo/CGNSOptions.h \
+  ../Mesh/PartitionOptions.h
+clippingWindow${OBJEXT}: clippingWindow.cpp GUI.h clippingWindow.h \
+  shortcutWindow.h ../Post/PView.h ../Geo/SPoint3.h \
+  ../Post/PViewOptions.h ../Post/ColorTable.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint3.h Callbacks.h ../Common/Context.h ../Geo/CGNSOptions.h \
+  ../Mesh/PartitionOptions.h
+messageWindow${OBJEXT}: messageWindow.cpp GUI.h messageWindow.h shortcutWindow.h \
+  Callbacks.h ../Common/GmshMessage.h ../Common/Context.h \
+  ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h
+manipWindow${OBJEXT}: manipWindow.cpp GUI.h manipWindow.h shortcutWindow.h \
+  Callbacks.h ../Common/Options.h ../Post/ColorTable.h \
+  ../Common/Context.h ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h
+contextWindow${OBJEXT}: contextWindow.cpp GUI.h contextWindow.h shortcutWindow.h \
+  Callbacks.h ../Common/Context.h ../Geo/CGNSOptions.h \
+  ../Mesh/PartitionOptions.h
+solverWindow${OBJEXT}: solverWindow.cpp GUI.h solverWindow.h shortcutWindow.h \
+  Solvers.h Callbacks.h ../Common/Context.h ../Geo/CGNSOptions.h \
+  ../Mesh/PartitionOptions.h
+aboutWindow${OBJEXT}: aboutWindow.cpp GUI.h aboutWindow.h shortcutWindow.h \
+  ../Common/CommandLine.h ../Common/StringUtils.h Callbacks.h \
+  ../Common/Context.h ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h
+fileDialogs${OBJEXT}: fileDialogs.cpp GUI.h shortcutWindow.h \
+  ../Common/GmshDefines.h ../Common/CreateFile.h ../Common/Options.h \
+  ../Post/ColorTable.h Draw.h ../Geo/GModel.h ../Geo/GVertex.h \
+  ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GPoint.h \
   ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h \
   ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h \
   ../Geo/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/GEdgeLoop.h \
   ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h \
   ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SPoint3.h \
-  ../Geo/SBoundingBox3d.h ../Mesh/Partition.h File_Picker.h
-GUI_Projection${OBJEXT}: GUI_Projection.cpp ../Geo/GModelIO_Fourier.h \
-  ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h \
-  ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h \
-  ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h \
-  ../Geo/SPoint2.h ../Geo/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h \
-  ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h \
-  ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SPoint3.h \
-  ../Geo/SBoundingBox3d.h ../Geo/MElement.h ../Common/GmshDefines.h \
-  ../Geo/MVertex.h ../Geo/SPoint2.h ../Geo/SPoint3.h ../Geo/MEdge.h \
-  ../Geo/MVertex.h ../Geo/SVector3.h ../Geo/MFace.h ../Geo/MVertex.h \
-  ../Geo/SVector3.h ../Common/GmshMessage.h ../Numeric/FunctionSpace.h \
-  ../Numeric/GmshMatrix.h Draw.h ../Common/Options.h ../Post/ColorTable.h \
-  ../Common/Context.h ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h \
+  ../Geo/SBoundingBox3d.h ../Common/Context.h ../Geo/CGNSOptions.h \
+  ../Mesh/PartitionOptions.h fileChooser.h
+extraDialogs${OBJEXT}: extraDialogs.cpp GUI.h shortcutWindow.h \
+  ../Common/GmshDefines.h ../Common/CreateFile.h ../Common/Options.h \
+  ../Post/ColorTable.h Draw.h ../Geo/GModel.h ../Geo/GVertex.h \
+  ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GPoint.h \
+  ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h \
+  ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h \
+  ../Geo/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/GEdgeLoop.h \
+  ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h \
+  ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SPoint3.h \
+  ../Geo/SBoundingBox3d.h ../Common/Context.h ../Geo/CGNSOptions.h \
+  ../Mesh/PartitionOptions.h
+projectionEditor${OBJEXT}: projectionEditor.cpp GUI.h projectionEditor.h \
+  shortcutWindow.h ../Geo/fourierProjectionFace.h ../Geo/GModel.h \
+  ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GPoint.h \
+  ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h \
+  ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h \
+  ../Geo/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/GEdgeLoop.h \
+  ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h \
+  ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SPoint3.h \
+  ../Geo/SBoundingBox3d.h ../Geo/Range.h ../Post/ColorTable.h \
+  fileDialogs.h ../Geo/GModelIO_Fourier.h ../Geo/GModel.h \
+  ../Geo/MElement.h ../Common/GmshDefines.h ../Geo/MVertex.h \
+  ../Geo/SPoint2.h ../Geo/SPoint3.h ../Geo/MEdge.h ../Geo/MVertex.h \
+  ../Geo/SVector3.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Common/GmshMessage.h ../Numeric/FunctionSpace.h \
+  ../Numeric/GmshMatrix.h Draw.h ../Common/Options.h \
   ../Common/StringUtils.h ../Graphics/SelectBuffer.h \
-  ../Graphics/drawContext.h GUI_Projection.h ../Common/GmshUI.h \
-  ../Geo/fourierProjectionFace.h ../Geo/GModel.h ../Geo/Range.h GUI.h \
-  Opengl_Window.h Colorbar_Window.h Popup_Button.h \
-  SpherePosition_Widget.h ../Mesh/Field.h ../Post/PView.h \
-  Shortcut_Window.h GUI_Extras.h ../Geo/fourierFace.h ../Geo/GFace.h \
+  ../Graphics/drawContext.h ../Geo/fourierFace.h ../Geo/GFace.h \
   ../Geo/GModel.h ../Geo/Range.h ../Geo/fourierEdge.h ../Geo/GEdge.h \
   ../Geo/GModel.h ../Geo/fourierVertex.h ../Geo/GModel.h ../Geo/GVertex.h \
-  ../Geo/MVertex.h
-GUI_Classifier${OBJEXT}: GUI_Classifier.cpp GUI_Classifier.h ../Common/GmshUI.h \
-  ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h \
-  ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h \
-  ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h \
-  ../Geo/SPoint2.h ../Geo/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h \
-  ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h \
-  ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SPoint3.h \
+  ../Geo/MVertex.h ../Common/Context.h ../Geo/CGNSOptions.h \
+  ../Mesh/PartitionOptions.h
+classificationEditor${OBJEXT}: classificationEditor.cpp GUI.h \
+  classificationEditor.h shortcutWindow.h ../Geo/GModel.h \
+  ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GPoint.h \
+  ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h \
+  ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h \
+  ../Geo/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/GEdgeLoop.h \
+  ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h \
+  ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/MElement.h ../Common/GmshDefines.h \
   ../Geo/MVertex.h ../Geo/SPoint2.h ../Geo/SPoint3.h ../Geo/MEdge.h \
   ../Geo/MVertex.h ../Geo/SVector3.h ../Geo/MFace.h ../Geo/MVertex.h \
   ../Geo/SVector3.h ../Common/GmshMessage.h ../Numeric/FunctionSpace.h \
-  ../Numeric/GmshMatrix.h GUI.h Opengl_Window.h ../Graphics/drawContext.h \
-  Colorbar_Window.h ../Post/ColorTable.h Popup_Button.h \
-  SpherePosition_Widget.h ../Mesh/Field.h ../Post/PView.h \
-  Shortcut_Window.h ../Numeric/Numeric.h ../Numeric/NumericEmbedded.h \
-  Draw.h ../Common/Options.h ../Common/Context.h ../Geo/CGNSOptions.h \
-  ../Mesh/PartitionOptions.h ../Graphics/SelectBuffer.h \
-  ../Graphics/drawContext.h GUI_Projection.h \
-  ../Geo/fourierProjectionFace.h ../Geo/GModel.h ../Geo/Range.h \
-  GUI_Extras.h ../Mesh/meshGFaceDelaunayInsertion.h \
-  ../Mesh/meshGFaceOptimize.h ../Mesh/meshGFaceDelaunayInsertion.h \
-  ../Geo/discreteEdge.h ../Geo/GModel.h ../Geo/GEdge.h \
-  ../Geo/discreteFace.h ../Geo/GModel.h ../Geo/GFace.h
-Callbacks${OBJEXT}: Callbacks.cpp ../Common/GmshUI.h ../Common/GmshMessage.h \
-  ../Common/MallocUtils.h ../Common/ListUtils.h ../Common/StringUtils.h \
-  ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h \
-  ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h \
-  ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h \
-  ../Geo/SPoint2.h ../Geo/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h \
-  ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h \
-  ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SPoint3.h \
-  ../Geo/SBoundingBox3d.h ../Geo/MElement.h ../Common/GmshDefines.h \
-  ../Geo/MVertex.h ../Geo/SPoint2.h ../Geo/SPoint3.h ../Geo/MEdge.h \
-  ../Geo/MVertex.h ../Geo/SVector3.h ../Geo/MFace.h ../Geo/MVertex.h \
-  ../Geo/SVector3.h ../Numeric/FunctionSpace.h ../Numeric/GmshMatrix.h \
+  ../Numeric/GmshMatrix.h ../Post/ColorTable.h ../Numeric/Numeric.h \
+  ../Numeric/NumericEmbedded.h Draw.h ../Common/Options.h \
+  ../Common/Context.h ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h \
+  ../Graphics/SelectBuffer.h ../Graphics/drawContext.h \
+  ../Mesh/meshGFaceDelaunayInsertion.h ../Mesh/meshGFaceOptimize.h \
+  ../Mesh/meshGFaceDelaunayInsertion.h ../Geo/discreteEdge.h \
+  ../Geo/GModel.h ../Geo/GEdge.h ../Geo/discreteFace.h ../Geo/GModel.h \
+  ../Geo/GFace.h
+partitionDialog${OBJEXT}: partitionDialog.cpp GUI.h shortcutWindow.h \
+  ../Common/GmshDefines.h ../Common/GmshMessage.h ../Geo/GModel.h \
+  ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GPoint.h \
+  ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h \
+  ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h \
+  ../Geo/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/GEdgeLoop.h \
+  ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h \
+  ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SPoint3.h \
+  ../Geo/SBoundingBox3d.h Draw.h ../Common/Options.h ../Post/ColorTable.h \
+  ../Mesh/Partition.h ../Common/Context.h ../Geo/CGNSOptions.h \
+  ../Mesh/PartitionOptions.h
+Callbacks${OBJEXT}: Callbacks.cpp GUI.h menuWindow.h popupButton.h \
+  graphicWindow.h openglWindow.h ../Graphics/drawContext.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h optionWindow.h \
+  spherePositionWidget.h colorbarWindow.h ../Post/ColorTable.h \
+  visibilityWindow.h clippingWindow.h statisticsWindow.h solverWindow.h \
+  manipWindow.h messageWindow.h fieldWindow.h pluginWindow.h \
+  contextWindow.h aboutWindow.h partitionDialog.h extraDialogs.h \
+  fileDialogs.h ../Common/GmshMessage.h ../Common/MallocUtils.h \
+  ../Common/ListUtils.h ../Common/StringUtils.h ../Geo/GModel.h \
+  ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
+  ../Geo/SBoundingBox3d.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h \
+  ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
+  ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/GFace.h ../Geo/GEntity.h \
+  ../Geo/GPoint.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h \
+  ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h \
+  ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/MElement.h \
+  ../Common/GmshDefines.h ../Geo/MVertex.h ../Geo/SPoint2.h \
+  ../Geo/SPoint3.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Numeric/FunctionSpace.h ../Numeric/GmshMatrix.h \
   ../Geo/GeoStringInterface.h ../Geo/findLinks.h ../Mesh/Generator.h \
   ../Mesh/HighOrder.h Draw.h ../Graphics/SelectBuffer.h \
   ../Graphics/drawContext.h ../Post/PView.h ../Post/PViewOptions.h \
   ../Post/ColorTable.h ../Post/PViewData.h ../Common/CreateFile.h \
   ../Common/OpenFile.h ../Common/CommandLine.h ../Common/Context.h \
   ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h ../Common/Options.h \
-  GUI.h Opengl_Window.h Colorbar_Window.h Popup_Button.h \
-  SpherePosition_Widget.h ../Mesh/Field.h GUI_Extras.h Callbacks.h \
-  ../Plugin/Plugin.h ../Post/PViewDataList.h ../Post/PViewData.h \
-  ../Plugin/PluginManager.h ../Common/Visibility.h \
+  Callbacks.h ../Plugin/Plugin.h ../Post/PViewDataList.h \
+  ../Post/PViewData.h ../Plugin/PluginManager.h ../Common/Visibility.h \
   ../Common/GmshDefines.h ../Numeric/Numeric.h \
-  ../Numeric/NumericEmbedded.h Solvers.h ../Common/OS.h \
+  ../Numeric/NumericEmbedded.h Solvers.h ../Common/OS.h ../Mesh/Field.h \
   ../Mesh/BackgroundMesh.h
-Draw${OBJEXT}: Draw.cpp GUI.h Opengl_Window.h ../Graphics/drawContext.h \
-  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h Colorbar_Window.h \
-  ../Common/GmshUI.h ../Post/ColorTable.h Popup_Button.h \
-  SpherePosition_Widget.h ../Mesh/Field.h ../Post/PView.h \
+Draw${OBJEXT}: Draw.cpp GUI.h graphicWindow.h openglWindow.h \
+  ../Graphics/drawContext.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
   ../Common/GmshDefines.h Draw.h ../Common/StringUtils.h \
   ../Graphics/gl2ps.h ../Common/Context.h ../Geo/CGNSOptions.h \
   ../Mesh/PartitionOptions.h
-Opengl_Window${OBJEXT}: Opengl_Window.cpp ../Common/GmshUI.h \
-  ../Common/GmshDefines.h ../Common/GmshMessage.h Draw.h \
-  ../Numeric/Numeric.h ../Numeric/NumericEmbedded.h ../Common/Context.h \
-  ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h \
-  ../Graphics/SelectBuffer.h ../Graphics/drawContext.h \
-  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GVertex.h \
-  ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
-  ../Geo/SBoundingBox3d.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h \
-  ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
-  ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/GFace.h ../Geo/GEntity.h \
-  ../Geo/GPoint.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h \
-  ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h GUI.h \
-  Opengl_Window.h Colorbar_Window.h ../Post/ColorTable.h Popup_Button.h \
-  SpherePosition_Widget.h ../Mesh/Field.h ../Post/PView.h \
-  ../Geo/MElement.h ../Geo/MVertex.h ../Geo/SPoint2.h ../Geo/SPoint3.h \
-  ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h ../Geo/MFace.h \
-  ../Geo/MVertex.h ../Geo/SVector3.h ../Numeric/FunctionSpace.h \
-  ../Numeric/GmshMatrix.h
-Colorbar_Window${OBJEXT}: Colorbar_Window.cpp ../Common/GmshUI.h GUI.h \
-  Opengl_Window.h ../Graphics/drawContext.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h Colorbar_Window.h ../Post/ColorTable.h Popup_Button.h \
-  SpherePosition_Widget.h ../Mesh/Field.h ../Post/PView.h \
-  ../Common/Context.h ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h
-Solvers${OBJEXT}: Solvers.cpp ../Common/GmshMessage.h ../Common/StringUtils.h \
-  Solvers.h ../Common/GmshSocket.h ../Common/OpenFile.h \
-  ../Common/GmshUI.h GUI.h Opengl_Window.h ../Graphics/drawContext.h \
-  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h Colorbar_Window.h \
-  ../Post/ColorTable.h Popup_Button.h SpherePosition_Widget.h \
-  ../Mesh/Field.h ../Post/PView.h Draw.h ../Common/Context.h \
-  ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h ../Common/OS.h
+Solvers${OBJEXT}: Solvers.cpp GUI.h solverWindow.h menuWindow.h popupButton.h \
+  ../Common/GmshMessage.h ../Common/StringUtils.h Solvers.h \
+  ../Common/GmshSocket.h ../Common/OpenFile.h ../Post/PView.h \
+  ../Geo/SPoint3.h Draw.h ../Common/Context.h ../Geo/CGNSOptions.h \
+  ../Mesh/PartitionOptions.h ../Common/OS.h
diff --git a/Fltk/Solvers.cpp b/Fltk/Solvers.cpp
index 58c51273d7501bb20e73ed6a35ff130bb4a01187..a9e36174b6ac68218be2a6c4f6d141b5cc56633b 100644
--- a/Fltk/Solvers.cpp
+++ b/Fltk/Solvers.cpp
@@ -5,22 +5,22 @@
 
 #include <string.h>
 #include <string>
+#include "GUI.h"
+#include "solverWindow.h"
+#include "menuWindow.h"
 #include "GmshMessage.h"
 #include "StringUtils.h"
 #include "Solvers.h"
 #include "GmshSocket.h"
 #include "OpenFile.h"
-#include "GmshUI.h"
-#include "GUI.h"
 #include "PView.h"
 #include "Draw.h"
 #include "Context.h"
 #include "OS.h"
 
 extern Context_T CTX;
-extern GUI *WID;
 
-SolverInfo SINFO[MAXSOLVERS];
+SolverInfo SINFO[MAX_NUM_SOLVERS];
 
 class myGmshServer : public GmshServer{
  public:
@@ -48,7 +48,7 @@ class myGmshServer : public GmshServer{
       if(ret == 0){ 
         // nothing available: wait at most waitint seconds, and in the
         // meantime respond to FLTK events
-        WID->wait(waitint);
+        GUI::instance()->wait(waitint);
       }
       else if(ret > 0){ 
         // data is there
@@ -124,7 +124,8 @@ int Solver(int num, const char *args)
 #endif
   }
 
-  int sock = server->StartClient(command.c_str(), sockname.c_str(), CTX.solver.max_delay);
+  int sock = server->StartClient(command.c_str(), sockname.c_str(),
+                                 CTX.solver.max_delay);
 
   if(sock < 0) {
     switch (sock) {
@@ -158,7 +159,7 @@ int Solver(int num, const char *args)
     }
     if(num >= 0){
       for(int i = 0; i < SINFO[num].nboptions; i++)
-        WID->solver[num].choice[i]->clear();
+        GUI::instance()->solver[num]->choice[i]->clear();
     }
     return 0;
   }
@@ -235,7 +236,7 @@ int Solver(int num, const char *args)
             MergeFile(message);
             Draw();
             if(n != (int)PView::list.size()) 
-              WID->set_context(menu_post, 0);
+              GUI::instance()->menu->setContext(menu_post, 0);
           }
           break;
         case GmshServer::CLIENT_PARSE_STRING:
@@ -243,25 +244,29 @@ int Solver(int num, const char *args)
           Draw();
           break;
         case GmshServer::CLIENT_INFO:
-          Msg::Direct("%-8.8s: %s", num >= 0 ? SINFO[num].name : "Client", message);
+          Msg::Direct("%-8.8s: %s", num >= 0 ? SINFO[num].name : "Client",
+                      message);
           break;
         case GmshServer::CLIENT_WARNING:
-          Msg::Direct(2, "%-8.8s: %s", num >= 0 ? SINFO[num].name : "Client", message);
+          Msg::Direct(2, "%-8.8s: %s", num >= 0 ? SINFO[num].name : "Client",
+                      message);
           break;
         case GmshServer::CLIENT_ERROR:
-          Msg::Direct(1, "%-8.8s: %s", num >= 0 ? SINFO[num].name : "Client", message);
+          Msg::Direct(1, "%-8.8s: %s", num >= 0 ? SINFO[num].name : "Client",
+                      message);
           break;
         case GmshServer::CLIENT_SPEED_TEST:
-          Msg::Info("got %d Mb message in %g seconds", strlen(message) / 1024 / 1024,
-                    GetTimeInSeconds() - timer);
+          Msg::Info("got %d Mb message in %g seconds", 
+                    strlen(message) / 1024 / 1024, GetTimeInSeconds() - timer);
           break;
         default:
           Msg::Warning("Unknown type of message received from %s",
               num >= 0 ? SINFO[num].name : "client");
-	  Msg::Direct("%-8.8s: %s", num >= 0 ? SINFO[num].name : "Client", message);
+	  Msg::Direct("%-8.8s: %s", num >= 0 ? SINFO[num].name : "Client", 
+                      message);
           break;
         }
-        WID->check();
+        GUI::instance()->check();
       }
       else{
         Msg::Warning("Failed to receive message body on socket: aborting");
@@ -278,10 +283,10 @@ int Solver(int num, const char *args)
   if(num >= 0){
     for(int i = 0; i < SINFO[num].nboptions; i++) {
       if(SINFO[num].nbval[i]) {
-        WID->solver[num].choice[i]->clear();
+        GUI::instance()->solver[num]->choice[i]->clear();
         for(int j = 0; j < SINFO[num].nbval[i]; j++)
-          WID->solver[num].choice[i]->add(SINFO[num].option[i][j]);
-        WID->solver[num].choice[i]->value(0);
+          GUI::instance()->solver[num]->choice[i]->add(SINFO[num].option[i][j]);
+        GUI::instance()->solver[num]->choice[i]->value(0);
       }
     }
   }
diff --git a/Fltk/Solvers.h b/Fltk/Solvers.h
index e5fcc2cb723f2809fb0dc4afa0992144c612e6f8..60ec601ed56ea5ef4b8dfa16516dbd7269f7c048 100644
--- a/Fltk/Solvers.h
+++ b/Fltk/Solvers.h
@@ -6,7 +6,8 @@
 #ifndef _SOLVERS_H_
 #define _SOLVERS_H_
 
-#define MAXSOLVERS 5
+#define MAX_NUM_SOLVERS 5
+#define MAX_NUM_SOLVER_OPTIONS 5
 
 class GmshServer;
 
@@ -15,17 +16,18 @@ typedef struct{
   char mesh_name[256], mesh_command[256];
   char socket_command[256];
   char name_command[256];
-  char button_name[MAXSOLVERS][32], button_command[MAXSOLVERS][256];
-  char option_name[MAXSOLVERS][256], option_command[256];
-  char option[MAXSOLVERS][100][256];
-  int  nboptions, nbval[MAXSOLVERS];
+  char button_name[MAX_NUM_SOLVER_OPTIONS][32];
+  char button_command[MAX_NUM_SOLVER_OPTIONS][256];
+  char option_name[MAX_NUM_SOLVER_OPTIONS][256], option_command[256];
+  char option[MAX_NUM_SOLVER_OPTIONS][100][256];
+  int  nboptions, nbval[MAX_NUM_SOLVER_OPTIONS];
   const char *help;
   int client_server, popup_messages, merge_views;
   int pid;
   GmshServer *server;
 } SolverInfo ;
 
-extern SolverInfo SINFO[MAXSOLVERS] ;
+extern SolverInfo SINFO[MAX_NUM_SOLVERS];
 
 int Solver(int num, const char *args);
 
diff --git a/Fltk/aboutWindow.cpp b/Fltk/aboutWindow.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..db95e0a99175e9e7ac9cb36acd20af9aad48ae6b
--- /dev/null
+++ b/Fltk/aboutWindow.cpp
@@ -0,0 +1,90 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+
+#include <FL/Fl_Browser.H>
+#include <FL/Fl_Box.H>
+#include <FL/Fl_Button.H>
+#include "GUI.h"
+#include "aboutWindow.h"
+#include "shortcutWindow.h"
+#include "CommandLine.h"
+#include "StringUtils.h"
+#include "Callbacks.h"
+#include "Context.h"
+
+extern Context_T CTX;
+
+aboutWindow::aboutWindow(int fontsize)
+  : _fontsize(fontsize)
+{
+  char buffer[1024];
+  int width = 28 * _fontsize;
+  int height = 15 * BH + BH/2;
+
+  win = new dialogWindow(width, height, CTX.non_modal_windows, "About Gmsh");
+  win->box(GMSH_WINDOW_BOX);
+
+  {
+    Fl_Browser *o = new Fl_Browser(0, 0, width, height - 2 * WB - BH);
+    o->box(FL_FLAT_BOX);
+    o->has_scrollbar(0); // no scrollbars
+    o->add(" ");
+    o->add("@c@b@.Gmsh");
+    o->add("@c@.A three-dimensional finite element mesh generator");
+    o->add("@c@.with built-in pre- and post-processing facilities");
+    o->add(" ");
+    o->add("@c@.Copyright (C) 1997-2008");
+#if defined(__APPLE__)
+    o->add("@c@.Christophe Geuzaine and Jean-Francois Remacle");
+#else
+    o->add("@c@.Christophe Geuzaine and Jean-Fran�ois Remacle");
+#endif
+    o->add(" ");
+    o->add("@c@.Please send all questions and bug reports to");
+    o->add("@c@b@.gmsh@geuz.org");
+    o->add(" ");
+    sprintf(buffer, "@c@.Version: %s", Get_GmshVersion());
+    o->add(buffer);
+    sprintf(buffer, "@c@.License: %s", Get_GmshShortLicense());
+    o->add(buffer);
+    sprintf(buffer, "@c@.Graphical user interface toolkit: FLTK %d.%d.%d", 
+            FL_MAJOR_VERSION, FL_MINOR_VERSION, FL_PATCH_VERSION);
+    o->add(buffer);
+    sprintf(buffer, "@c@.Build OS: %s", Get_GmshBuildOS());
+    o->add(buffer);
+    sprintf(buffer, "@c@.Build date: %s", Get_GmshBuildDate());
+    o->add(buffer);
+    sprintf(buffer, "@c@.Build host: %s", Get_GmshBuildHost());
+    o->add(buffer);
+    std::vector<std::string> lines = SplitWhiteSpace(Get_GmshBuildOptions(), 30);
+    for(unsigned int i = 0; i < lines.size(); i++){
+      if(!i)
+        sprintf(buffer, "@c@.Build options: %s", lines[i].c_str());
+      else
+        sprintf(buffer, "@c@.%s", lines[i].c_str());
+        o->add(buffer);
+      }
+    sprintf(buffer, "@c@.Packaged by: %s", Get_GmshPackager());
+    o->add(buffer);
+    o->add(" ");
+    o->add("@c@.Visit http://www.geuz.org/gmsh/ for more information");
+    o->add(" ");
+    o->callback(cancel_cb, (void *)win);
+  }
+
+  {
+    Fl_Button *o = new Fl_Button(width/2 - BB - WB/2, height - BH - WB, BB, BH, "License");
+    o->callback(help_license_cb);
+  }
+
+  {
+    Fl_Button *o = new Fl_Button(width/2 + WB/2, height - BH - WB, BB, BH, "Credits");
+    o->callback(help_credits_cb);
+  }
+
+  win->position(Fl::x() + Fl::w()/2 - width / 2,
+                         Fl::y() + Fl::h()/2 - height / 2);
+  win->end();
+}
diff --git a/Fltk/aboutWindow.h b/Fltk/aboutWindow.h
new file mode 100644
index 0000000000000000000000000000000000000000..9766e83ad8d4d752deba32571e06d05a9e0e4a9a
--- /dev/null
+++ b/Fltk/aboutWindow.h
@@ -0,0 +1,23 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <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{
+ private:
+  int _fontsize;
+ public:
+  Fl_Window *win;
+ public:
+  aboutWindow(int fontsize);
+};
+
+#endif
diff --git a/Fltk/GUI_Classifier.cpp b/Fltk/classificationEditor.cpp
similarity index 57%
rename from Fltk/GUI_Classifier.cpp
rename to Fltk/classificationEditor.cpp
index 61c21b863ecafcafd69b835c85a715372413090e..92bfa09f486f01e710bb1133abe04c18a2882025 100644
--- a/Fltk/GUI_Classifier.cpp
+++ b/Fltk/classificationEditor.cpp
@@ -3,14 +3,15 @@
 // See the LICENSE.txt file for license information. Please report all
 // bugs and problems to <gmsh@geuz.org>.
 
-#include "GUI_Classifier.h"
+#include <Fl/Fl_Tabs.H>
+#include <Fl/Fl_Value_Input.H>
+#include "GUI.h"
+#include "classificationEditor.h"
 #include "Numeric.h"
 #include "Draw.h"
 #include "Options.h"
 #include "Context.h"
 #include "SelectBuffer.h"
-#include "GUI_Projection.h"
-#include "GUI_Extras.h"
 #include "GmshMessage.h"
 #include "meshGFaceDelaunayInsertion.h"
 #include "meshGFaceOptimize.h"
@@ -19,7 +20,8 @@
 
 extern Context_T CTX;
 
-void buildListOfEdgeAngle ( e2t_cont adj,std::vector<edge_angle> &edges_detected,std::vector<edge_angle> &edges_lonly);
+void buildListOfEdgeAngle(e2t_cont adj,std::vector<edge_angle> &edges_detected,
+                          std::vector<edge_angle> &edges_lonly);
 
 void NoElementsSelectedMode (classificationEditor *e)
 {
@@ -32,12 +34,10 @@ void NoElementsSelectedMode (classificationEditor *e)
 
   e->_buttons[CLASSBUTTON_SELECT]->activate(); 
   e->_togbuttons[CLASSTOGBUTTON_HIDE]->activate(); 
-
 }
 
-void ElementsSelectedMode (classificationEditor *e)
+void ElementsSelectedMode(classificationEditor *e)
 {
-
   e->_buttons[CLASSBUTTON_DEL]->activate();
   e->_buttons[CLASSBUTTON_ADD]->activate();
   e->_buttons[CLASSBUTTON_CLEAR]->activate();
@@ -49,9 +49,7 @@ void ElementsSelectedMode (classificationEditor *e)
   e->_togbuttons[CLASSTOGBUTTON_HIDE]->deactivate(); 
 }
 
-
-
-int maxEdgeNum ()
+int maxEdgeNum()
 {
   GModel::eiter it =  GModel::current()->firstEdge();
   GModel::eiter ite = GModel::current()->lastEdge();
@@ -64,7 +62,7 @@ int maxEdgeNum ()
   return MAXX;
 }
 
-int maxFaceNum ()
+int maxFaceNum()
 {
   GModel::fiter it =  GModel::current()->firstFace();
   GModel::fiter ite = GModel::current()->lastFace();
@@ -77,7 +75,6 @@ int maxFaceNum ()
   return MAXX;
 }
 
-
 struct compareMLinePtr 
 {
   bool operator () ( MLine *l1 , MLine *l2) const
@@ -87,36 +84,29 @@ struct compareMLinePtr
   }
 };
 
- 
-void recurClassify ( MTri3 *t , 
-                     GFace *gf,
-                     std::map<MLine*, GEdge*, compareMLinePtr> &lines,
-                     std::map<MTriangle*, GFace*> &reverse)
+void recurClassify(MTri3 *t, GFace *gf,
+                   std::map<MLine*, GEdge*, compareMLinePtr> &lines,
+                   std::map<MTriangle*, GFace*> &reverse)
 {
-  if (!t->isDeleted())
-    {
-      gf->triangles.push_back(t->tri());
-      reverse[t->tri()] = gf;
-
-      t->setDeleted ( true );
-      
-      for (int i=0;i<3;i++)
-        {
-          MTri3 *tn = t->getNeigh(i);
-          if (tn)
-            {
-              edgeXface exf ( t, i);
-              MLine ml (exf.v[0],exf.v[1]);       
-              std::map<MLine*, GEdge*, compareMLinePtr>::iterator it = lines.find(&ml);
-              if (it==lines.end())
-                recurClassify (tn, gf,lines, reverse);
-            }
-        }  
-    }
+  if (!t->isDeleted()){
+    gf->triangles.push_back(t->tri());
+    reverse[t->tri()] = gf;
+    t->setDeleted(true);
+    for(int i = 0; i < 3; i++){
+      MTri3 *tn = t->getNeigh(i);
+      if(tn){
+        edgeXface exf(t, i);
+        MLine ml(exf.v[0], exf.v[1]);       
+        std::map<MLine*, GEdge*, compareMLinePtr>::iterator it = lines.find(&ml);
+        if (it == lines.end())
+          recurClassify(tn, gf, lines, reverse);
+      }
+    }  
+  }
 }
 
-
-GEdge * getNewModelEdge (GFace *gf1, GFace *gf2, std::map< std::pair <int, int> , GEdge* > &newEdges)
+GEdge *getNewModelEdge(GFace *gf1, GFace *gf2, 
+                       std::map<std::pair<int, int>, GEdge* > &newEdges)
 {
   int t1 = gf1 ? gf1->tag() : -1;
   int t2 = gf2 ? gf2->tag() : -1;
@@ -125,58 +115,48 @@ GEdge * getNewModelEdge (GFace *gf1, GFace *gf2, std::map< std::pair <int, int>
 
   if (i1 == i2) return 0;
 
-  std::map< std::pair <int, int> , GEdge* >::iterator it = newEdges.find(std::make_pair<int,int>(i1,i2));
-  if (it == newEdges.end())
-    {
-      discreteEdge *temporary = new discreteEdge(GModel::current(), maxEdgeNum() + 1);
-      GModel::current()->add (temporary);
-      newEdges[std::make_pair<int,int>(i1,i2)] = temporary;
-      
-      return temporary;
-    }
+  std::map<std::pair<int, int>, GEdge*>::iterator it = 
+    newEdges.find(std::make_pair<int, int>(i1, i2));
+  if(it == newEdges.end()){
+    discreteEdge *temporary = new discreteEdge(GModel::current(), maxEdgeNum() + 1);
+    GModel::current()->add (temporary);
+    newEdges[std::make_pair<int, int>(i1, i2)] = temporary;
+    return temporary;
+  }
   else
     return it->second;  
 }
 
-
-void recurClassifyEdges ( MTri3 *t , 
-                          std::map<MTriangle*, GFace*> &reverse,
-                          std::map<MLine*, GEdge*, compareMLinePtr> &lines,
-                          std::set<MLine*> &touched,
-                          std::map< std::pair <int, int> , GEdge* > &newEdges)
+void recurClassifyEdges(MTri3 *t , 
+                        std::map<MTriangle*, GFace*> &reverse,
+                        std::map<MLine*, GEdge*, compareMLinePtr> &lines,
+                        std::set<MLine*> &touched,
+                        std::map<std::pair<int, int>, GEdge*> &newEdges)
 {
-  if (!t->isDeleted())
-    {
-      t->setDeleted ( true );
-      
-      GFace *gf1 = reverse[t->tri()];
-      for (int i=0;i<3;i++)
-        {
-          GFace *gf2 = 0;
-          MTri3 *tn = t->getNeigh(i);
-          if (tn)
-            gf2 = reverse[tn->tri()];
-
-          edgeXface exf ( t, i);
-          MLine ml (exf.v[0],exf.v[1]);   
-          std::map<MLine*, GEdge*, compareMLinePtr>::iterator it = lines.find(&ml);
-          if (it != lines.end())
-            {
-              if (touched.find(it->first) == touched.end())
-                {
-                  GEdge *ge =  getNewModelEdge (gf1, gf2, newEdges);
-                  if (ge) ge->lines.push_back(it->first);
-                  touched.insert(it->first);
-                }
-            }
-          if (tn)
-            recurClassifyEdges (tn, reverse,lines, touched,newEdges);
-        }  
+  if (!t->isDeleted()){
+    t->setDeleted(true);
+    GFace *gf1 = reverse[t->tri()];
+    for (int i = 0; i < 3; i++){
+      GFace *gf2 = 0;
+      MTri3 *tn = t->getNeigh(i);
+      if (tn)
+        gf2 = reverse[tn->tri()];
+      edgeXface exf(t, i);
+      MLine ml(exf.v[0], exf.v[1]);
+      std::map<MLine*, GEdge*, compareMLinePtr>::iterator it = lines.find(&ml);
+      if (it != lines.end()){
+        if (touched.find(it->first) == touched.end()){
+          GEdge *ge =  getNewModelEdge (gf1, gf2, newEdges);
+          if (ge) ge->lines.push_back(it->first);
+          touched.insert(it->first);
+        }
+      }
+      if (tn)
+        recurClassifyEdges(tn, reverse, lines, touched, newEdges);
     }
+  }
 }
 
-
-
 void class_color_cb(Fl_Widget* w, void* data)
 {
   classificationEditor *e = (classificationEditor*)data;
@@ -184,207 +164,192 @@ void class_color_cb(Fl_Widget* w, void* data)
   {
     GModel::eiter it =  GModel::current()->firstEdge();
     GModel::eiter ite = GModel::current()->lastEdge();
-    for( ;it!=ite;++it)
-      {
-        for (unsigned int i=0;i<(*it)->lines.size();i++)lines[(*it)->lines[i] ] = *it;
-      }
+    for( ;it!=ite;++it){
+      for (unsigned int i = 0; i < (*it)->lines.size();i++) 
+        lines[(*it)->lines[i]] = *it;
+    }
   }
 
-
   std::list<MTri3*> tris;
   {
     std::set<GFace*>::iterator it = e->_faces.begin();
-    while (it != e->_faces.end())
-      {
-        GFace *gf = *it;
-        for (unsigned int i=0;i<gf->triangles.size();i++)
-          {
-            tris.push_back (new MTri3 ( gf->triangles [i] , 0 ) );
-          }
-        gf->triangles.clear();
-        ++it;
+    while (it != e->_faces.end()){
+      GFace *gf = *it;
+      for (unsigned int i = 0; i < gf->triangles.size(); i++){
+            tris.push_back(new MTri3(gf->triangles [i], 0));
       }
+      gf->triangles.clear();
+      ++it;
+    }
   }
 
-
-  connectTriangles (tris);
+  connectTriangles(tris);
 
   {
     std::map<MTriangle*,GFace*> reverse;
 
     // color all triangles
     std::list<MTri3*> ::iterator it = tris.begin();
-    while (it != tris.end())
-      {
-        if (!(*it)->isDeleted())
-          {
-            discreteFace *temporary = new discreteFace(GModel::current(), maxFaceNum() + 1);
-            recurClassify(*it, temporary, lines, reverse);
-            GModel::current()->add(temporary);
-          }
-        ++it;
+    while (it != tris.end()){
+      if (!(*it)->isDeleted()){
+        discreteFace *temporary = new discreteFace(GModel::current(), maxFaceNum() + 1);
+        recurClassify(*it, temporary, lines, reverse);
+        GModel::current()->add(temporary);
       }
-
+      ++it;
+    }
+    
     // color some lines
     it = tris.begin();
-    while (it != tris.end())
-      {
-        (*it)->setDeleted(false);
-        ++it;
-      }
-
+    while (it != tris.end()){
+      (*it)->setDeleted(false);
+      ++it;
+    }
+    
     it = tris.begin();
-
-    std::map< std::pair <int, int> , GEdge* > newEdges;
-    std::set< MLine* > touched;
-    recurClassifyEdges ( *it , reverse , lines, touched,newEdges);
+    
+    std::map<std::pair<int, int>, GEdge*> newEdges;
+    std::set<MLine*> touched;
+    recurClassifyEdges(*it, reverse, lines, touched, newEdges);
     GModel::current()->remove(e->saved);
 
-    while (it != tris.end())
-      {
-        delete *it;
-        ++it;
-      }
+    while (it != tris.end()){
+      delete *it;
+      ++it;
+    }
   }
-
+  
   CTX.mesh.changed = ENT_ALL;
   Draw();  
   Msg::StatusBar(3, false, "");
-
 }
 
 void updateedges_cb(Fl_Widget* w, void* data)
 {
   classificationEditor *e = (classificationEditor*)data;
  
-  //  printf("%d edges detected\n",e->edges_detected.size());
+  // printf("%d edges detected\n", e->edges_detected.size());
 
-  for (unsigned int i=0;i<e->temporary->lines.size();i++)
-    {
-      delete e->temporary->lines[i];
-    }
+  for(unsigned int i = 0; i < e->temporary->lines.size(); i++){
+    delete e->temporary->lines[i];
+  }
   e->temporary->lines.clear();
 
-  for (unsigned int i=0 ; i<e->edges_detected.size();i++)
-    {
-      edge_angle ea =  e->edges_detected[i];
-      //      printf("angle = %g\n",ea.angle);
-      if ( ea.angle  <= e -> _inputs[CLASSVALUE_ANGLE] ->value() / 180 * M_PI) 
-        break;
-      e->temporary->lines.push_back(new MLine(ea.v1, ea.v2));            
-    } 
+  for (unsigned int i = 0; i < e->edges_detected.size(); i++){
+    edge_angle ea =  e->edges_detected[i];
+    // printf("angle = %g\n",ea.angle);
+    if(ea.angle <= e->_inputs[CLASSVALUE_ANGLE]->value() / 180 * M_PI)
+      break;
+    e->temporary->lines.push_back(new MLine(ea.v1, ea.v2));
+  } 
 
-  if (e->_togbuttons[CLASSTOGBUTTON_CLOS]->value())
-    {
-      for (unsigned int i=0 ; i<e->edges_lonly.size();i++)
-        {
-          edge_angle ea =  e->edges_lonly[i];
-          e->temporary->lines.push_back(new MLine(ea.v1, ea.v2));            
-        } 
-    }
+  if (e->_togbuttons[CLASSTOGBUTTON_CLOS]->value()){
+    for (unsigned int i = 0 ; i < e->edges_lonly.size(); i++){
+      edge_angle ea = e->edges_lonly[i];
+      e->temporary->lines.push_back(new MLine(ea.v1, ea.v2));
+    } 
+  }
   
-
   CTX.mesh.changed = ENT_ALL;
   Draw();   
 }
 
-edge_angle::  edge_angle ( MVertex *_v1, MVertex *_v2, MElement *t1, MElement *t2)
+edge_angle::edge_angle(MVertex *_v1, MVertex *_v2, MElement *t1, MElement *t2)
   : v1(_v1), v2(_v2)
 {
   if (!t2) angle = 0;
-  else
+  else{
+    double c1[3];
+    double c2[3];
+    double c3[3];
     {
-      double c1[3];
-      double c2[3];
-      double c3[3];
-      {
-        MVertex *p1 = t1->getVertex(0);
-        MVertex *p2 = t1->getVertex(1);
-        MVertex *p3 = t1->getVertex(2);
-        double a[3] = { p1->x() - p2->x(), p1->y() - p2->y(), p1->z() - p2->z() };
-        double b[3] = { p1->x() - p3->x(), p1->y() - p3->y(), p1->z() - p3->z() };
-        c1[2] = a[0] * b[1] - a[1] * b[0];
-        c1[1] = -a[0] * b[2] + a[2] * b[0];
-        c1[0] = a[1] * b[2] - a[2] * b[1];
-      }
-      {
-        MVertex *p1 = t2->getVertex(0);
-        MVertex *p2 = t2->getVertex(1);
-        MVertex *p3 = t2->getVertex(2);
-        double a[3] = { p1->x() - p2->x(), p1->y() - p2->y(), p1->z() - p2->z() };
-        double b[3] = { p1->x() - p3->x(), p1->y() - p3->y(), p1->z() - p3->z() };
-        c2[2] = a[0] * b[1] - a[1] * b[0];
-        c2[1] = -a[0] * b[2] + a[2] * b[0];
-        c2[0] = a[1] * b[2] - a[2] * b[1];
-      }
-      norme(c1);
-      norme(c2);
-      prodve(c1,c2,c3);
-      double cosa ; prosca(c1,c2,&cosa);
-      double sina = norme (c3);
-      angle = atan2(sina,cosa);
+      MVertex *p1 = t1->getVertex(0);
+      MVertex *p2 = t1->getVertex(1);
+      MVertex *p3 = t1->getVertex(2);
+      double a[3] = {p1->x() - p2->x(), p1->y() - p2->y(), p1->z() - p2->z()};
+      double b[3] = {p1->x() - p3->x(), p1->y() - p3->y(), p1->z() - p3->z()};
+      c1[2] = a[0] * b[1] - a[1] * b[0];
+      c1[1] = -a[0] * b[2] + a[2] * b[0];
+      c1[0] = a[1] * b[2] - a[2] * b[1];
     }
-  
-}
-void buildListOfEdgeAngle ( e2t_cont adj,std::vector<edge_angle> &edges_detected,std::vector<edge_angle> &edges_lonly)
-{
-  e2t_cont::iterator it = adj.begin();
-  for ( ; it!=adj.end();++it )
     {
-      if ( it->second.second ) edges_detected.push_back ( edge_angle ( it->first.getVertex (0) ,it->first.getVertex (1) , 
-                                                                       it->second.first,it->second.second) );
-      else edges_lonly.push_back ( edge_angle ( it->first.getVertex (0) ,it->first.getVertex (1) , 
-                                                it->second.first,it->second.second) );  
+      MVertex *p1 = t2->getVertex(0);
+      MVertex *p2 = t2->getVertex(1);
+      MVertex *p3 = t2->getVertex(2);
+      double a[3] = {p1->x() - p2->x(), p1->y() - p2->y(), p1->z() - p2->z()};
+      double b[3] = {p1->x() - p3->x(), p1->y() - p3->y(), p1->z() - p3->z()};
+      c2[2] = a[0] * b[1] - a[1] * b[0];
+      c2[1] = -a[0] * b[2] + a[2] * b[0];
+      c2[0] = a[1] * b[2] - a[2] * b[1];
     }
-  std::sort ( edges_detected .begin() ,  edges_detected .end() );
+    norme(c1);
+    norme(c2);
+    prodve(c1,c2,c3);
+    double cosa ; prosca(c1,c2,&cosa);
+    double sina = norme (c3);
+    angle = atan2(sina,cosa);
+  }
 }
 
-
-classificationEditor::classificationEditor() 
+void buildListOfEdgeAngle(e2t_cont adj, std::vector<edge_angle> &edges_detected,
+                          std::vector<edge_angle> &edges_lonly)
 {
+  e2t_cont::iterator it = adj.begin();
+  for( ; it != adj.end(); ++it){
+    if(it->second.second)
+      edges_detected.push_back(edge_angle(it->first.getVertex(0), 
+                                          it->first.getVertex(1), 
+                                          it->second.first, it->second.second));
+    else 
+      edges_lonly.push_back(edge_angle(it->first.getVertex(0),
+                                       it->first.getVertex(1), 
+                                       it->second.first, it->second.second));
+  }
+  std::sort(edges_detected.begin(), edges_detected.end());
+}
 
-  op[0]=opt_mesh_lines(0, GMSH_GET, 0.);
-  op[1]=opt_mesh_surfaces_edges(0, GMSH_GET, 0.);
-  op[2]=opt_mesh_surfaces_faces(0, GMSH_GET, 0.);
-  op[3]=opt_mesh_line_width(0, GMSH_SET | GMSH_GET,0.);
+classificationEditor::classificationEditor()
+{
+  op[0] = opt_mesh_lines(0, GMSH_GET, 0.);
+  op[1] = opt_mesh_surfaces_edges(0, GMSH_GET, 0.);
+  op[2] = opt_mesh_surfaces_faces(0, GMSH_GET, 0.);
+  op[3] = opt_mesh_line_width(0, GMSH_SET | GMSH_GET,0.);
 
   opt_mesh_lines(0, GMSH_SET | GMSH_GUI, 1);
   opt_mesh_surfaces_edges(0, GMSH_SET | GMSH_GUI, 0);
   opt_mesh_surfaces_faces(0, GMSH_SET | GMSH_GUI, 1);
   opt_mesh_line_width(0, GMSH_SET | GMSH_GUI, 1.5);
 
-
   // construct GUI in terms of standard sizes
-  const int BH = 2 * GetFontSize() + 1, BB = 12 * GetFontSize(), WB = 7;
+  int _fontsize = GetFontSize();
   const int width = (int)(3.5 * BB), height = 10 * BH;
 
-  _window = new Dialog_Window(width, height, CTX.non_modal_windows, "Classify");
+  _window = new dialogWindow(width, height, CTX.non_modal_windows, "Classify");
   
   new Fl_Tabs(WB, WB, width - 2 * WB, height - 2 * WB);
   {
-    Fl_Group *o = new Fl_Group(WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Edge Detection");
+    Fl_Group *o = new Fl_Group
+      (WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Edge Detection");
     edge_detec = o;
-    //    o->hide();
-    // create all widgets (we construct this once, we never deallocate!)
     
-    _buttons[CLASSBUTTON_OK] = 
-      new Fl_Button       (4*WB+2*BB, 7*WB+6*BH, BB, BH, "OK");
+    _buttons[CLASSBUTTON_OK] = new Fl_Button 
+      (4*WB+2*BB, 7*WB+6*BH, BB, BH, "OK");
     _buttons[CLASSBUTTON_OK]->callback(class_ok_cb, this);
     
-    _buttons[CLASSBUTTON_SELECT] = 
-      new Fl_Button       (2*WB, 2*WB+1*BH, BB, BH, "Select Elements");
+    _buttons[CLASSBUTTON_SELECT] = new Fl_Button 
+      (2*WB, 2*WB+1*BH, BB, BH, "Select Elements");
     _buttons[CLASSBUTTON_SELECT]->callback(class_select_cb, this);
     
-    _togbuttons[CLASSTOGBUTTON_HIDE] = 
-      new Fl_Toggle_Button(3*WB+BB, 2*WB+1*BH, BB, BH, "Hide Unselected");
+    _togbuttons[CLASSTOGBUTTON_HIDE] = new Fl_Toggle_Button
+      (3*WB+BB, 2*WB+1*BH, BB, BH, "Hide Unselected");
     _togbuttons[CLASSTOGBUTTON_HIDE]->callback(class_hide_cb,this);
 
-    _togbuttons[CLASSTOGBUTTON_CLOS] = 
-      new Fl_Toggle_Button(2*WB, 4*WB+3*BH, BB, BH, "Include Closure");
+    _togbuttons[CLASSTOGBUTTON_CLOS] = new Fl_Toggle_Button
+      (2*WB, 4*WB+3*BH, BB, BH, "Include Closure");
     _togbuttons[CLASSTOGBUTTON_CLOS]->callback(updateedges_cb,this);
     
-    _inputs[CLASSVALUE_ANGLE] = 
-      new Fl_Value_Input(3*WB+BB, 4*WB+3*BH, BB, BH, "Treshold Angle");
+    _inputs[CLASSVALUE_ANGLE] = new Fl_Value_Input
+      (3*WB+BB, 4*WB+3*BH, BB, BH, "Treshold Angle");
     _inputs[CLASSVALUE_ANGLE]->value(40);
     _inputs [CLASSVALUE_ANGLE]->maximum(90);
     _inputs[CLASSVALUE_ANGLE]->minimum(0);
@@ -393,37 +358,39 @@ classificationEditor::classificationEditor()
     _inputs[CLASSVALUE_ANGLE]->when(FL_WHEN_RELEASE);  
     _inputs[CLASSVALUE_ANGLE]->callback(updateedges_cb,this);
 
-    _buttons[CLASSBUTTON_DEL] = 
-      new Fl_Button       (2*WB, 5*WB+4*BH, BB, BH, "Delete Edge");
+    _buttons[CLASSBUTTON_DEL] = new Fl_Button 
+      (2*WB, 5*WB+4*BH, BB, BH, "Delete Edge");
     _buttons[CLASSBUTTON_DEL]->callback(class_deleteedge_cb, this);    
     _buttons[CLASSBUTTON_DEL]->deactivate();
 
-    _buttons[CLASSBUTTON_ADD] = 
-      new Fl_Button       (2*WB, 6*WB+5*BH, BB, BH, "Save Selection");
+    _buttons[CLASSBUTTON_ADD] = new Fl_Button
+      (2*WB, 6*WB+5*BH, BB, BH, "Save Selection");
     _buttons[CLASSBUTTON_ADD]->callback(class_save_cb, this);    
     _buttons[CLASSBUTTON_ADD]->deactivate();
 
-    _buttons[CLASSBUTTON_CLEAR] = 
-      new Fl_Button       (2*WB, 7*WB+6*BH, BB, BH, "Clear Selection");
+    _buttons[CLASSBUTTON_CLEAR] = new Fl_Button 
+      (2*WB, 7*WB+6*BH, BB, BH, "Clear Selection");
     _buttons[CLASSBUTTON_CLEAR]->callback(class_clear_cb, this);    
     _buttons[CLASSBUTTON_CLEAR]->deactivate();
     o->end();
   }
   {
-    Fl_Group *o = new Fl_Group(WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Face Colouring");
+    Fl_Group *o = new Fl_Group
+      (WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Face Colouring");
     face_color = o;
     o->deactivate();
     o->hide();
-    _buttons[CLASSBUTTON_SELFAC] = 
-      new Fl_Button       (2*WB, 2*WB+1*BH, BB, BH, "Select Model Face");
+    _buttons[CLASSBUTTON_SELFAC] = new Fl_Button
+      (2*WB, 2*WB+1*BH, BB, BH, "Select Model Face");
     _buttons[CLASSBUTTON_SELFAC]->callback(class_selectgface_cb, this);
-    _buttons[CLASSBUTTON_COLOR] = 
-      new Fl_Button       (2*WB, 3*WB+2*BH, BB, BH, "Classify Mesh Faces");
+    _buttons[CLASSBUTTON_COLOR] = new Fl_Button 
+      (2*WB, 3*WB+2*BH, BB, BH, "Classify Mesh Faces");
     _buttons[CLASSBUTTON_COLOR]->callback(class_color_cb, this);
     o->end();
   }
   {
-    Fl_Group *o = new Fl_Group(WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Reparametrize Surfaces");
+    Fl_Group *o = new Fl_Group
+      (WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Reparametrize Surfaces");
     reverse_eng = o;
     o->hide();
     o->deactivate();
@@ -446,7 +413,6 @@ classificationEditor::classificationEditor()
   _window->size_range(width, (int)(0.85 * height));    
 }
 
-
 void class_hide_cb(Fl_Widget *w, void *data)
 {
   CTX.hide_unselected = !CTX.hide_unselected;
@@ -512,7 +478,6 @@ void class_select_cb(Fl_Widget *w, void *data)
   Msg::StatusBar(3, false, "");
 }
 
-
 void class_selectgface_cb(Fl_Widget *w, void *data)
 {
   classificationEditor *e = (classificationEditor*)data;
@@ -558,7 +523,6 @@ void class_selectgface_cb(Fl_Widget *w, void *data)
   Msg::StatusBar(3, false, "");
 }
 
-
 void class_deleteedge_cb(Fl_Widget *w, void *data)
 {
   classificationEditor *e = (classificationEditor*)data;
@@ -605,7 +569,6 @@ void class_deleteedge_cb(Fl_Widget *w, void *data)
     }
   }
 
-
   std::sort (ele.begin(),ele.end());
   //  look in all temporary edges if a deleted one is present and delete it !
   std::vector<MLine*> temp = e->temporary->lines;
@@ -627,12 +590,12 @@ void class_deleteedge_cb(Fl_Widget *w, void *data)
   Msg::StatusBar(3, false, "");
 }
 
-
 void class_save_cb(Fl_Widget *w, void *data)
 {
   classificationEditor *e = (classificationEditor*)data;
 
-  e->saved->lines.insert (e->saved->lines.end(), e->temporary->lines.begin(), e->temporary->lines.end());
+  e->saved->lines.insert(e->saved->lines.end(), e->temporary->lines.begin(),
+                         e->temporary->lines.end());
   e->temporary->lines.clear();
   e->_elements.clear();
   e->edges_detected.clear();
@@ -648,10 +611,9 @@ void class_clear_cb(Fl_Widget *w, void *data)
 {
   classificationEditor *e = (classificationEditor*)data;
 
-  for (unsigned int i=0;i<e->temporary->lines.size();i++)
-    {      
-      delete e->temporary->lines[i];
-    }
+  for(unsigned int i = 0; i < e->temporary->lines.size(); i++){      
+    delete e->temporary->lines[i];
+  }
   e->temporary->lines.clear();
 
   CTX.mesh.changed = ENT_ALL;
@@ -688,8 +650,6 @@ void class_okcolor_cb(Fl_Widget *w, void *data)
   Msg::StatusBar(3, false, "");
 }
 
-
-
 void mesh_classify_cb(Fl_Widget* w, void* data)
 {
   // create the (static) editor
@@ -699,5 +659,3 @@ void mesh_classify_cb(Fl_Widget* w, void* data)
   }
   editor->show();
 }
-
-
diff --git a/Fltk/GUI_Classifier.h b/Fltk/classificationEditor.h
similarity index 91%
rename from Fltk/GUI_Classifier.h
rename to Fltk/classificationEditor.h
index e6ac0694703bd851b778c80adf82b1b0913b6821..86b3daeb33bf82886cd92885149872733b924079 100644
--- a/Fltk/GUI_Classifier.h
+++ b/Fltk/classificationEditor.h
@@ -3,28 +3,16 @@
 // See the LICENSE.txt file for license information. Please report all
 // bugs and problems to <gmsh@geuz.org>.
 
-#ifndef _GUI_CLASSIFIER_H_
-#define _GUI_CLASSIFIER_H_
+#ifndef _CLASSIFICATION_EDITOR_H_
+#define _CLASSIFICATION_EDITOR_H_
 
-#include "GmshUI.h"
+#include <vector>
+#include <FL/Fl_Toggle_Button.H>
+#include <FL/Fl_Round_Button.H>
+#include "shortcutWindow.h"
 #include "GModel.h"
 #include "MElement.h"
-#include "GUI.h"
-#include "Shortcut_Window.h"
 #include "ColorTable.h"
-#include <FL/Fl_Toggle_Button.H>
-#include <FL/Fl_Round_Button.H>
-#include <vector>
-
-void class_select_cb(Fl_Widget *w, void *data);
-void class_hide_cb(Fl_Widget *w, void *data);
-void class_selectgface_cb(Fl_Widget *w, void *data);
-void class_save_cb(Fl_Widget *w, void *data);
-void class_clear_cb(Fl_Widget *w, void *data);
-void class_deleteedge_cb(Fl_Widget *w, void *data);
-void class_color_cb(Fl_Widget *w, void *data);
-void class_ok_cb(Fl_Widget *w, void *data);
-void class_okcolor_cb(Fl_Widget *w, void *data);
 
 #define CLASSBUTTON_SELECT   0
 #define CLASSBUTTON_DEL      1
@@ -66,6 +54,17 @@ class classificationEditor {
   classificationEditor();
   void show(){ _window->show();}
   std::vector<MTriangle*> &getElements() { return _elements; }
-  Fl_Group *edge_detec,*face_color,*reverse_eng;
+  Fl_Group *edge_detec, *face_color, *reverse_eng;
 };
+
+void class_select_cb(Fl_Widget *w, void *data);
+void class_hide_cb(Fl_Widget *w, void *data);
+void class_selectgface_cb(Fl_Widget *w, void *data);
+void class_save_cb(Fl_Widget *w, void *data);
+void class_clear_cb(Fl_Widget *w, void *data);
+void class_deleteedge_cb(Fl_Widget *w, void *data);
+void class_color_cb(Fl_Widget *w, void *data);
+void class_ok_cb(Fl_Widget *w, void *data);
+void class_okcolor_cb(Fl_Widget *w, void *data);
+
 #endif
diff --git a/Fltk/clippingWindow.cpp b/Fltk/clippingWindow.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..85f795f8538b224c8ba111d5f2eb97d2a5c275ab
--- /dev/null
+++ b/Fltk/clippingWindow.cpp
@@ -0,0 +1,175 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+
+#include <FL/Fl_Tabs.H>
+#include <FL/Fl_Return_Button.H>
+#include "GUI.h"
+#include "clippingWindow.h"
+#include "shortcutWindow.h"
+#include "PView.h"
+#include "PViewOptions.h"
+#include "Callbacks.h"
+#include "Context.h"
+
+extern Context_T CTX;
+
+clippingWindow::clippingWindow(int fontsize) 
+  : _fontsize(fontsize)
+{
+  static Fl_Menu_Item plane_number[] = {
+    {"Plane 0", 0, 0},
+    {"Plane 1", 0, 0},
+    {"Plane 2", 0, 0},
+    {"Plane 3", 0, 0},
+    {"Plane 4", 0, 0},
+    {"Plane 5", 0, 0},
+    {0}
+  };
+
+  int width = 26 * _fontsize;
+  int height = 10 * BH + 5 * WB;
+  int L = 7 * _fontsize;
+
+  win = new dialogWindow(width, height, CTX.non_modal_windows, "Clipping");
+  win->box(GMSH_WINDOW_BOX);
+
+  browser = new Fl_Multi_Browser(WB, WB, L - WB, height - BH - 3 * WB);
+  browser->callback(clip_update_cb);
+
+  Fl_Tabs *o = new Fl_Tabs
+    (L + WB, WB, width - L - 2 * WB, height - 3 * WB - 4 * BH);
+  {
+    group[0] = new Fl_Group
+      (L + WB, WB + BH, width - L - 2 * WB, height - 3 * WB - 5 * BH, "Planes");
+
+    int BW = width - L - 4 * WB - 4 * _fontsize;
+
+    choice = new Fl_Choice(L + 2 * WB, 2 * WB + 1 * BH, BW, BH);
+    choice->menu(plane_number);
+    choice->callback(clip_num_cb);
+
+    Fl_Button *invert = new Fl_Button
+      (L + 2 * WB, 2 * WB + 2 * BH, _fontsize, 4 * BH, "-");
+    invert->callback(clip_invert_cb);
+    invert->tooltip("Invert orientation");
+    
+    value[0] = new Fl_Value_Input
+      (L + 2 * WB + _fontsize, 2 * WB + 2 * BH, BW - _fontsize, BH, "A");
+    value[1] = new Fl_Value_Input
+      (L + 2 * WB + _fontsize, 2 * WB + 3 * BH, BW - _fontsize, BH, "B");
+    value[2] = new Fl_Value_Input
+      (L + 2 * WB + _fontsize, 2 * WB + 4 * BH, BW - _fontsize, BH, "C");
+    value[3] = new Fl_Value_Input
+      (L + 2 * WB + _fontsize, 2 * WB + 5 * BH, BW - _fontsize, BH, "D");
+    for(int i = 0; i < 4; i++){
+      value[i]->align(FL_ALIGN_RIGHT);
+      value[i]->callback(clip_update_cb);
+    }
+
+    group[0]->end();
+  }
+  {
+    group[1] = new Fl_Group
+      (L + WB, WB + BH, width - L - 2 * WB, height - 3 * WB - 5 * BH, "Box");
+    group[1]->hide();
+
+    int w2 = (width - L - 4 * WB) / 2;
+    int BW = w2 - 2 * _fontsize;
+    value[4] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 1 * BH, BW, BH, "Cx");
+    value[5] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 2 * BH, BW, BH, "Cy");
+    value[6] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 3 * BH, BW, BH, "Cz");
+    value[7] = new Fl_Value_Input(L + 2 * WB + w2, 2 * WB + 1 * BH, BW, BH, "Wx");
+    value[8] = new Fl_Value_Input(L + 2 * WB + w2, 2 * WB + 2 * BH, BW, BH, "Wy");
+    value[9] = new Fl_Value_Input(L + 2 * WB + w2, 2 * WB + 3 * BH, BW, BH, "Wz");
+    for(int i = 4; i < 10; i++){
+      value[i]->align(FL_ALIGN_RIGHT);
+      value[i]->callback(clip_update_cb);
+    }
+
+    group[1]->end();
+  }
+  o->callback(clip_reset_cb);
+  o->end();
+
+  butt[0] = new Fl_Check_Button
+    (L + WB, 3 * WB + 6 * BH, width - L - 2 * WB, BH, "Keep whole elements");
+  butt[1] = new Fl_Check_Button
+    (L + WB, 3 * WB + 7 * BH, width - L - 2 * WB, BH, "Only draw intersecting volume layer");
+  butt[2] = new Fl_Check_Button
+    (L + WB, 3 * WB + 8 * BH, width - L - 2 * WB, BH, "Cut only volume elements");
+  for(int i = 0; i < 3; i++){
+    butt[i]->type(FL_TOGGLE_BUTTON);
+    butt[i]->callback(clip_update_cb);
+  }
+
+  resetBrowser();
+
+  {
+    Fl_Return_Button *o = new Fl_Return_Button
+      (width - 3 * BB - 3 * WB, height - BH - WB, BB, BH, "Redraw");
+    o->callback(redraw_cb);
+  }
+  {
+    Fl_Button *o = new Fl_Button
+      (width - 2 * BB - 2 * WB, height - BH - WB, BB, BH, "Reset");
+    o->callback(clip_reset_cb);
+  }
+  {
+    Fl_Button *o = new Fl_Button
+      (width - BB - WB, height - BH - WB, BB, BH, "Cancel");
+    o->callback(cancel_cb, (void *)win);
+  }
+
+  win->position(CTX.clip_position[0], CTX.clip_position[1]);
+  win->end();
+}
+
+void clippingWindow::resetBrowser()
+{
+  char str[128];
+  browser->clear();
+  browser->add("Geometry");
+  browser->add("Mesh");
+  for(unsigned int i = 0; i < PView::list.size(); i++) {
+    sprintf(str, "View [%d]", i);
+    browser->add(str);
+  }
+  int idx = choice->value();
+  browser->deselect();
+  for(int i = 0; i < browser->size(); i++){
+    if((i == 0 && CTX.geom.clip & (1 << idx)) ||
+       (i == 1 && CTX.mesh.clip & (1 << idx)) ||
+       (i - 2 < PView::list.size() && 
+        PView::list[i - 2]->getOptions()->Clip & (1 << idx)))
+      browser->select(i + 1);
+  }
+  for(int i = 0; i < 4; i++)
+    value[i]->value(CTX.clip_plane[idx][i]);
+  for(int i = 4; i < 7; i++)
+    value[i]->value(0.);
+  for(int i = 7; i < 10; i++)
+    value[i]->value(1.);
+
+  for(int i = 0; i < 3; i++) {
+    value[i]->step(0.01);
+    value[i]->minimum(-1.0);
+    value[i]->maximum(1.0);
+  }
+  double val1 = 0;
+  for(int i = 0; i < 3; i++)
+    val1 = std::max(val1, std::max(fabs(CTX.min[i]), fabs(CTX.max[i])));
+  val1 *= 1.5;
+  for(int i = 3; i < 10; i++){
+    value[i]->step(val1/200.);
+    value[i]->minimum(-val1);
+    value[i]->maximum(val1);
+  }
+}
+
+void clippingWindow::show()
+{
+  resetBrowser();
+  win->show();
+}
diff --git a/Fltk/clippingWindow.h b/Fltk/clippingWindow.h
new file mode 100644
index 0000000000000000000000000000000000000000..de6678b19dcc55bf7568197d098161989ce46ca4
--- /dev/null
+++ b/Fltk/clippingWindow.h
@@ -0,0 +1,32 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+
+#ifndef _CLIPPING_WINDOW_H_
+#define _CLIPPING_WINDOW_H_
+
+#include <FL/Fl_Window.H>
+#include <FL/Fl_Choice.H>
+#include <FL/Fl_Multi_Browser.H>
+#include <FL/Fl_Value_Input.H>
+#include <FL/Fl_Check_Button.H>
+#include <FL/Fl_Group.H>
+
+class clippingWindow{
+ private:
+  int _fontsize;
+ public:
+  Fl_Window *win;
+  Fl_Choice *choice;
+  Fl_Multi_Browser *browser;
+  Fl_Value_Input *value[10];
+  Fl_Check_Button *butt[3];
+  Fl_Group *group[2];
+ public:
+  clippingWindow(int fontsize);
+  void resetBrowser();
+  void show();
+};
+
+#endif
diff --git a/Fltk/Colorbar_Window.cpp b/Fltk/colorbarWindow.cpp
similarity index 96%
rename from Fltk/Colorbar_Window.cpp
rename to Fltk/colorbarWindow.cpp
index db9facc7f0a4cbcbb580db26ecd0b81a728ca89d..bd96c81289d8cc7c7203215e8e97a5c56f04c36c 100644
--- a/Fltk/Colorbar_Window.cpp
+++ b/Fltk/colorbarWindow.cpp
@@ -7,22 +7,22 @@
 // program for visualizing five dimensional gridded data sets
 // Copyright (C) 1990 - 1995 Bill Hibbard, Brian Paul, Dave Santek,
 // and Andre Battaiola.
-   
-#include "GmshUI.h"
-#include "GUI.h"
+
+#include <FL/fl_draw.H>
+#include "colorbarWindow.h"   
 #include "ColorTable.h"
-#include "Colorbar_Window.h"
+#include "GUI.h" // FIXME for GetFontSize
 #include "Context.h"
 
 extern Context_T CTX;
 
 #define EPS 1.e-10
 
-// This file defines the Colorbar_Window class (subclass of Fl_Window)
+// This file defines the colorbarWindow class (subclass of Fl_Window)
 
 // The constructor
 
-Colorbar_Window::Colorbar_Window(int x, int y, int w, int h, const char *l)
+colorbarWindow::colorbarWindow(int x, int y, int w, int h, const char *l)
   : Fl_Window(x, y, w, h, l)
 {
   ct = NULL;
@@ -37,7 +37,7 @@ Colorbar_Window::Colorbar_Window(int x, int y, int w, int h, const char *l)
 
 // Convert window X coordinate to color table index
 
-int Colorbar_Window::x_to_index(int x)
+int colorbarWindow::x_to_index(int x)
 {
   int index;
   index = (int)(x * (double)ct->size / (double)w());
@@ -50,7 +50,7 @@ int Colorbar_Window::x_to_index(int x)
 
 // Convert color table index to window X coordinate
 
-int Colorbar_Window::index_to_x(int index)
+int colorbarWindow::index_to_x(int index)
 {
   int x;
   x = (int)(index * (double)w() / (double)(ct->size - 1));
@@ -61,7 +61,7 @@ int Colorbar_Window::index_to_x(int index)
 
 // Convert a color intensity to a window Y coordinate
 
-int Colorbar_Window::intensity_to_y(int intensity)
+int colorbarWindow::intensity_to_y(int intensity)
 {
   int y;
   y = (int)(wedge_y - intensity * (double)wedge_y / 255.);
@@ -74,7 +74,7 @@ int Colorbar_Window::intensity_to_y(int intensity)
 
 // Convert a window Y coordinate to a color intensity
 
-int Colorbar_Window::y_to_intensity(int y)
+int colorbarWindow::y_to_intensity(int y)
 {
   int intensity;
   intensity = (int)((wedge_y - y) * 255. / (double)wedge_y);
@@ -85,9 +85,9 @@ int Colorbar_Window::y_to_intensity(int y)
   return intensity;
 }
 
-// Redraw part of the Colorbar_Window (between a and b)
+// Redraw part of the colorbarWindow (between a and b)
 
-void Colorbar_Window::redraw_range(int a, int b)
+void colorbarWindow::redraw_range(int a, int b)
 {
   int i;
   int x, y, px = 0, py = 0;
@@ -264,7 +264,7 @@ void Colorbar_Window::redraw_range(int a, int b)
 
 // Redraw the marker and the text
 
-void Colorbar_Window::redraw_marker()
+void colorbarWindow::redraw_marker()
 {
   int x, y0, y1;
   char str[50];
@@ -295,7 +295,7 @@ void Colorbar_Window::redraw_marker()
 
 // Draw everything
 
-void Colorbar_Window::draw()
+void colorbarWindow::draw()
 {
   if(!ct) return;
 
@@ -311,7 +311,7 @@ void Colorbar_Window::draw()
 
 // Update
 
-void Colorbar_Window::update(const char *name, double min, double max,
+void colorbarWindow::update(const char *name, double min, double max,
                              GmshColorTable *table, bool *changed)
 {
   label = name;
@@ -324,7 +324,7 @@ void Colorbar_Window::update(const char *name, double min, double max,
 
 // Handle
 
-int Colorbar_Window::handle(int event)
+int colorbarWindow::handle(int event)
 {
   if(!ct) return Fl_Window::handle(event);
 
diff --git a/Fltk/colorbarWindow.h b/Fltk/colorbarWindow.h
new file mode 100644
index 0000000000000000000000000000000000000000..c2b047a9e888c4b49e1fb440c2880719d26b3eb1
--- /dev/null
+++ b/Fltk/colorbarWindow.h
@@ -0,0 +1,40 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+
+#ifndef _COLORBAR_WINDOW_H
+#define _COLORBAR_WINDOW_H
+
+#include <FL/Fl.H>
+#include <FL/Fl_Window.H>
+#include "ColorTable.h"
+
+class colorbarWindow : public Fl_Window {
+ private:
+  int font_height, marker_height, wedge_height;
+  const char *label;
+  double minval, maxval; // min and max data values
+  int wedge_y; // top coord of color wedge
+  int marker_y; // top coord of marker arrow
+  int label_y; // y coord of text labels
+  int help_flag; // if nonzero, print help message
+  int marker_pos; // position of marker as index into table
+  GmshColorTable *ct; // pointer to the color table (allocated in the view)
+  bool *viewchanged; // pointer to changed bit in view
+  Fl_Color color_bg;
+  int x_to_index(int x);
+  int index_to_x(int index);
+  int y_to_intensity(int y);
+  int intensity_to_y(int intensity);
+  void redraw_range(int a, int b);
+  void redraw_marker();
+  void draw();
+  int handle(int);
+ public:
+  colorbarWindow(int x, int y, int w, int h, const char *l=0);
+  void update(const char *name, double min, double max, GmshColorTable *ct,
+              bool *changed);
+};
+
+#endif
diff --git a/Fltk/contextWindow.cpp b/Fltk/contextWindow.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a84ff337fa29b84427e53528b6f8ca037cab6c65
--- /dev/null
+++ b/Fltk/contextWindow.cpp
@@ -0,0 +1,259 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+
+#include <FL/Fl_Tabs.H>
+#include <FL/Fl_Return_Button.H>
+#include "GUI.h"
+#include "contextWindow.h"
+#include "shortcutWindow.h"
+#include "Callbacks.h"
+#include "Context.h"
+
+extern Context_T CTX;
+
+geometryContextWindow::geometryContextWindow(int fontsize)
+  : _fontsize(fontsize)
+{
+  int width = 31 * _fontsize;
+  int height = 5 * WB + 9 * BH;
+
+  win = new dialogWindow
+    (width, height, CTX.non_modal_windows, "Contextual Geometry Definitions");
+  win->box(GMSH_WINDOW_BOX);
+  {
+    Fl_Tabs *o = new Fl_Tabs(WB, WB, width - 2 * WB, height - 3 * WB - BH);
+    // 0: Parameter
+    {
+      group[0] = new Fl_Group
+        (WB, WB + BH, width - 2 * WB, height - 3 * WB - 2 * BH, "Parameter");
+      input[0] = new Fl_Input(2 * WB, 2 * WB + 1 * BH, IW, BH, "Name");
+      input[0]->value("lc");
+      input[1] = new Fl_Input(2 * WB, 2 * WB + 2 * BH, IW, BH, "Value");
+      input[1]->value("0.1");
+      for(int i = 0; i < 2; i++) {
+        input[i]->align(FL_ALIGN_RIGHT);
+      }
+      {
+        Fl_Return_Button *o = new Fl_Return_Button
+          (width - BB - 2 * WB, 2 * WB + 7 * BH, BB, BH, "Add");
+        o->callback(con_geometry_define_parameter_cb);
+      }
+      group[0]->end();
+    }
+    // 1: Point
+    {
+      group[1] = new Fl_Group
+        (WB, WB + BH, width - 2 * WB, height - 3 * WB - 2 * BH, "Point");
+      input[2] = new Fl_Input(2 * WB, 2 * WB + 1 * BH, IW, BH, "X coordinate");
+      input[2]->value("0");
+      input[3] = new Fl_Input(2 * WB, 2 * WB + 2 * BH, IW, BH, "Y coordinate");
+      input[3]->value("0");
+      input[4] = new Fl_Input(2 * WB, 2 * WB + 3 * BH, IW, BH, "Z coordinate");
+      input[4]->value("0");
+      input[5] = new Fl_Input(2 * WB, 2 * WB + 4 * BH, IW, BH, "Characteristic length");
+      input[5]->value("");
+      for(int i = 2; i < 6; i++) {
+        input[i]->align(FL_ALIGN_RIGHT);
+      }
+      value[0] = new Fl_Value_Input(2 * WB, 2 * WB + 5 * BH, IW/3, BH);
+      value[1] = new Fl_Value_Input(2 * WB + IW/3, 2 * WB + 5 * BH, IW/3, BH);
+      value[2] = new Fl_Value_Input(2 * WB + 2*IW/3, 2 * WB + 5 * BH, IW/3, BH,
+                                    "Snapping grid spacing");
+      for(int i = 0; i < 3; i++) {
+        value[i]->align(FL_ALIGN_RIGHT);
+        value[i]->callback(con_geometry_snap_cb);
+      }
+      {
+        Fl_Return_Button *o = new Fl_Return_Button
+          (width - BB - 2 * WB, 2 * WB + 7 * BH, BB, BH, "Add");
+        o->callback(con_geometry_define_point_cb);
+      }
+      group[1]->end();
+    }
+    // 2: Translation
+    {
+      group[2] = new Fl_Group
+        (WB, WB + BH, width - 2 * WB, height - 3 * WB - 2 * BH, "Translation");
+      input[6] = new Fl_Input(2 * WB, 2 * WB + 1 * BH, IW, BH, "X component");
+      input[6]->value("0");
+      input[7] = new Fl_Input(2 * WB, 2 * WB + 2 * BH, IW, BH, "Y component");
+      input[7]->value("0");
+      input[8] = new Fl_Input(2 * WB, 2 * WB + 3 * BH, IW, BH, "Z component");
+      input[8]->value("1");
+      for(int i = 6; i < 9; i++) {
+        input[i]->align(FL_ALIGN_RIGHT);
+      }
+      group[2]->end();
+    }
+    // 3: Rotation
+    {
+      group[3] = new Fl_Group
+        (WB, WB + BH, width - 2 * WB, height - 3 * WB - 2 * BH, "Rotation");
+      input[9] = new Fl_Input
+        (2 * WB, 2 * WB + 1 * BH, IW, BH, "X coordinate of an axis point");
+      input[9]->value("0");
+      input[10] = new Fl_Input
+        (2 * WB, 2 * WB + 2 * BH, IW, BH, "Y coordinate of an axis point");
+      input[10]->value("0");
+      input[11] = new Fl_Input
+        (2 * WB, 2 * WB + 3 * BH, IW, BH, "Z coordinate of an axis point");
+      input[11]->value("0");
+      input[12] = new Fl_Input
+        (2 * WB, 2 * WB + 4 * BH, IW, BH, "X component of axis direction");
+      input[12]->value("0");
+      input[13] = new Fl_Input
+        (2 * WB, 2 * WB + 5 * BH, IW, BH, "Y component of axis direction");
+      input[13]->value("1");
+      input[14] = new Fl_Input
+        (2 * WB, 2 * WB + 6 * BH, IW, BH, "Z component of axis direction");
+      input[14]->value("0");
+      input[15] = new Fl_Input
+        (2 * WB, 2 * WB + 7 * BH, IW, BH, "Angle in radians");
+      input[15]->value("Pi/4");
+      for(int i = 9; i < 16; i++) {
+        input[i]->align(FL_ALIGN_RIGHT);
+      }
+      group[3]->end();
+    }
+    // 4: Scale
+    {
+      group[4] = new Fl_Group
+        (WB, WB + BH, width - 2 * WB, height - 3 * WB - 2 * BH, "Scale");
+      input[16] = new Fl_Input
+        (2 * WB, 2 * WB + 1 * BH, IW, BH, "X component of direction");
+      input[16]->value("0");
+      input[17] = new Fl_Input
+        (2 * WB, 2 * WB + 2 * BH, IW, BH, "Y component of direction");
+      input[17]->value("0");
+      input[18] = new Fl_Input
+        (2 * WB, 2 * WB + 3 * BH, IW, BH, "Z component of direction");
+      input[18]->value("0");
+      input[19] = new Fl_Input
+        (2 * WB, 2 * WB + 4 * BH, IW, BH, "Factor");
+      input[19]->value("0.5");
+      for(int i = 16; i < 20; i++) {
+        input[i]->align(FL_ALIGN_RIGHT);
+      }
+      group[4]->end();
+    }
+    // 5: Symmetry
+    {
+      group[5] = new Fl_Group
+        (WB, WB + BH, width - 2 * WB, height - 3 * WB - 2 * BH, "Symmetry");
+      input[20] = new Fl_Input(2 * WB, 2 * WB + 1 * BH, IW, BH, "A");
+      input[20]->value("1");
+      input[21] = new Fl_Input(2 * WB, 2 * WB + 2 * BH, IW, BH, "B");
+      input[21]->value("0");
+      input[22] = new Fl_Input(2 * WB, 2 * WB + 3 * BH, IW, BH, "C");
+      input[22]->value("0");
+      input[23] = new Fl_Input(2 * WB, 2 * WB + 4 * BH, IW, BH, "D");
+      input[23]->value("1");
+      for(int i = 20; i < 24; i++) {
+        input[i]->align(FL_ALIGN_RIGHT);
+      }
+      group[5]->end();
+    }
+    o->end();
+  }
+
+  {
+    Fl_Button *o = new Fl_Button
+      (width - BB - WB, height - BH - WB, BB, BH, "Cancel");
+    o->callback(cancel_cb, (void *)win);
+  }
+
+  win->position(CTX.ctx_position[0], CTX.ctx_position[1]);
+  win->end();
+}
+
+void geometryContextWindow::show(int pane)
+{
+  for(int i = 0; i < 6; i++)
+    group[i]->hide();
+  group[pane]->show();
+  win->show();
+}
+
+meshContextWindow::meshContextWindow(int fontsize)
+  : _fontsize(fontsize)
+{
+  static Fl_Menu menu_transfinite_dir[] = {
+    {"Left", 0, 0, 0},
+    {"Right", 0, 0, 0},
+    {"Alternated", 0, 0, 0},
+    {0}
+  };
+
+  int width = 29 * _fontsize;
+  int height = 5 * WB + 5 * BH;
+
+  win = new dialogWindow
+    (width, height, CTX.non_modal_windows, "Contextual Mesh Definitions");
+  win->box(GMSH_WINDOW_BOX);
+  {
+    Fl_Tabs *o = new Fl_Tabs(WB, WB, width - 2 * WB, height - 3 * WB - BH);
+    // 0: Characteristic length
+    {
+      group[0] = new Fl_Group
+        (WB, WB + BH, width - 2 * WB, height - 3 * WB - 2 * BH, "Characteristic Length");
+      input[0] = new Fl_Input(2 * WB, 2 * WB + 1 * BH, IW, BH, "Value");
+      input[0]->value("0.1");
+      input[0]->align(FL_ALIGN_RIGHT);
+      group[0]->end();
+    }
+    // 1: Transfinite line
+    {
+      group[1] = new Fl_Group
+        (WB, WB + BH, width - 2 * WB, height - 3 * WB - 2 * BH, "Transfinite Line");
+      input[1] = new Fl_Input(2 * WB, 2 * WB + 1 * BH, IW, BH, "Number of points");
+      input[1]->value("10");
+      input[2] = new Fl_Input(2 * WB, 2 * WB + 3 * BH, IW, BH, "Parameter");
+      input[2]->value("1");
+      for(int i = 1; i < 3; i++) {
+        input[i]->align(FL_ALIGN_RIGHT);
+      }
+      static Fl_Menu_Item menu_trsf_mesh[] = {
+        {"Progression", 0, 0, 0},
+        {"Bump", 0, 0, 0},
+        {0}
+      };
+      choice[0] = new Fl_Choice(2 * WB, 2 * WB + 2 * BH, IW, BH, "Type");
+      choice[0]->menu(menu_trsf_mesh);
+      choice[0]->align(FL_ALIGN_RIGHT);
+      group[1]->end();
+    }
+    
+    // 2: Transfinite surface
+    {
+      group[2] = new Fl_Group
+        (WB, WB + BH, width - 2 * WB, height - 3 * WB - 2 * BH, "Transfinite Surface");
+
+      choice[1] = new Fl_Choice
+        (2 * WB, 2 * WB + 1 * BH, IW, BH, "Transfinite Arrangement");
+      choice[1]->menu(menu_transfinite_dir);
+      choice[1]->align(FL_ALIGN_RIGHT);
+
+      group[2]->end();
+    }
+    o->end();
+  }
+
+  {
+    Fl_Button *o = new Fl_Button
+      (width - BB - WB, height - BH - WB, BB, BH, "Cancel");
+    o->callback(cancel_cb, (void *)win);
+  }
+
+  win->position(CTX.ctx_position[0], CTX.ctx_position[1]);
+  win->end();
+}
+
+void meshContextWindow::show(int pane)
+{
+  for(int i = 0; i < 3; i++)
+    group[i]->hide();
+  group[pane]->show();
+  win->show();
+}
diff --git a/Fltk/contextWindow.h b/Fltk/contextWindow.h
new file mode 100644
index 0000000000000000000000000000000000000000..e03e4014532a62c52192b23b4c1f3ce1edc02ce8
--- /dev/null
+++ b/Fltk/contextWindow.h
@@ -0,0 +1,41 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+
+#ifndef _CONTEXT_WINDOW_H_
+#define _CONTEXT_WINDOW_H_
+
+#include <FL/Fl_Window.H>
+#include <FL/Fl_Input.H>
+#include <FL/Fl_Value_Input.H>
+#include <FL/Fl_Choice.H>
+#include <FL/Fl_Group.H>
+
+class geometryContextWindow{
+ private:
+  int _fontsize;
+ public:
+  Fl_Window *win;
+  Fl_Input *input[30];
+  Fl_Value_Input *value[10];
+  Fl_Group *group[10];
+ public:
+  geometryContextWindow(int fontsize);
+  void show(int pane);
+};
+
+class meshContextWindow{
+ private:
+  int _fontsize;
+ public:
+  Fl_Window *win;
+  Fl_Input *input[20];
+  Fl_Choice *choice[20];
+  Fl_Group *group[10];
+ public:
+  meshContextWindow(int fontsize);
+  void show(int pane);
+};
+
+#endif
diff --git a/Fltk/extraDialogs.cpp b/Fltk/extraDialogs.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ac9186aa28c6a7ca16477b8a416f44ee015aa06a
--- /dev/null
+++ b/Fltk/extraDialogs.cpp
@@ -0,0 +1,202 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+//
+// Contributor(s):
+//   Stephen Guzik
+//
+
+#include <FL/Fl_Value_Slider.H>
+#include <FL/Fl_Menu_Window.H>
+#include <FL/Fl_Select_Browser.H>
+#include <FL/Fl_Toggle_Button.H>
+#include <FL/Fl_Round_Button.H>
+#include <FL/Fl_Return_Button.H>
+#include <FL/Fl_Check_Button.H>
+#include <FL/Fl_Hold_Browser.H>
+#include <FL/Fl_Box.H>
+#include "GUI.h"
+#include "shortcutWindow.h"
+#include "GmshDefines.h"
+#include "CreateFile.h"
+#include "Options.h"
+#include "Draw.h"
+#include "GModel.h"
+#include "Context.h"
+
+extern Context_T CTX;
+
+// Arrow editor
+
+int arrow_editor(const char *title, double &a, double &b, double &c)
+{
+  struct _editor{
+    Fl_Window *window;
+    Fl_Value_Slider *sa, *sb, *sc;
+    Fl_Button *apply, *cancel;
+  };
+  static _editor *editor = NULL;
+
+  int _fontsize = GetFontSize();
+
+  if(!editor){
+    editor = new _editor;
+    editor->window = new dialogWindow
+      (2 * BB + 3 * WB, 4 * BH + 3 * WB, CTX.non_modal_windows);
+    editor->sa = new Fl_Value_Slider(WB, WB, BB, BH, "Head radius");
+    editor->sa->type(FL_HOR_SLIDER);
+    editor->sa->align(FL_ALIGN_RIGHT);
+    editor->sb = new Fl_Value_Slider(WB, WB + BH, BB, BH, "Stem length");
+    editor->sb->type(FL_HOR_SLIDER);
+    editor->sb->align(FL_ALIGN_RIGHT);
+    editor->sc = new Fl_Value_Slider(WB, WB + 2 * BH, BB, BH, "Stem radius");
+    editor->sc->type(FL_HOR_SLIDER);
+    editor->sc->align(FL_ALIGN_RIGHT);
+    editor->apply = new Fl_Return_Button(WB, 2 * WB + 3 * BH, BB, BH, "Apply");
+    editor->cancel = new Fl_Button(2 * WB + BB, 2 * WB + 3 * BH, BB, BH, "Cancel");
+    editor->window->end();
+    editor->window->hotspot(editor->window);
+  }
+  
+  editor->window->label(title);
+  editor->sa->value(a);
+  editor->sb->value(b);
+  editor->sc->value(c);
+  editor->window->show();
+
+  while(editor->window->shown()){
+    Fl::wait();
+    for (;;) {
+      Fl_Widget* o = Fl::readqueue();
+      if (!o) break;
+      if (o == editor->apply) {
+        a = editor->sa->value();
+        b = editor->sb->value();
+        c = editor->sc->value();
+        return 1;
+      }
+      if (o == editor->window || o == editor->cancel){
+        editor->window->hide();
+        return 0;
+      }
+    }
+  }
+  return 0;
+}
+
+// Perspective editor (aka z-clipping planes factor slider)
+
+static void persp_change_factor(Fl_Widget* w, void* data)
+{
+  opt_general_clip_factor(0, GMSH_SET|GMSH_GUI, ((Fl_Slider*)w)->value());
+  Draw();
+}
+
+class Release_Slider : public Fl_Slider {
+  int handle(int event){ 
+    switch (event) {
+    case FL_RELEASE: 
+      if(window())
+        window()->hide();
+      return 1;
+    default:
+      return Fl_Slider::handle(event);
+    }
+  };
+public:
+  Release_Slider(int x, int y, int w, int h, const char *l=0)
+    : Fl_Slider(x, y, w, h, l) {}
+};
+
+int perspective_editor()
+{
+  struct _editor{
+    Fl_Menu_Window *window;
+    Release_Slider *sa;
+  };
+  static _editor *editor = NULL;
+
+  if(!editor){
+    editor = new _editor;
+    editor->window = new Fl_Menu_Window(20, 100);
+    if(CTX.non_modal_windows) editor->window->set_non_modal();
+    editor->sa = new Release_Slider(0, 0, 20, 100);
+    editor->sa->type(FL_VERT_NICE_SLIDER);
+    editor->sa->minimum(12);
+    editor->sa->maximum(0.75);
+    editor->sa->callback(persp_change_factor);
+    editor->window->border(0);
+    editor->window->end();
+  }
+
+  editor->window->hotspot(editor->window);
+  editor->sa->value(CTX.clip_factor);
+
+  if(editor->window->non_modal() && !editor->window->shown())
+    editor->window->show(); // fix ordering
+  editor->window->show();
+  return 0;
+}
+
+// Model chooser
+
+static void model_switch(Fl_Widget* w, void *data)
+{
+  Fl_Select_Browser *b = (Fl_Select_Browser *)w;
+  if(b->value()) GModel::current(b->value() - 1);
+  if(w->window()) w->window()->hide();
+  CTX.mesh.changed = ENT_ALL;
+  GUI::instance()->resetVisibility();
+  Draw();
+}
+
+static void model_draw_all(Fl_Widget* w, void *data)
+{
+  Fl_Check_Button *b = (Fl_Check_Button*)w;
+  opt_general_draw_all_models(0, GMSH_SET | GMSH_GUI, (int)b->value());
+  Draw();
+}
+
+int model_chooser()
+{
+  struct _menu{
+    Fl_Menu_Window *window;
+    Fl_Hold_Browser *browser;
+    Fl_Check_Button *butt;
+  };
+  static _menu *menu = NULL;
+
+  int _fontsize = GetFontSize();
+  const int WW = 200;
+
+  if(!menu){
+    menu = new _menu;
+    menu->window = new Fl_Menu_Window(WW, 6 * BH);
+    if(CTX.non_modal_windows) menu->window->set_non_modal();
+    menu->window->border(0);
+    Fl_Box *l = new Fl_Box(0, 0, WW, BH, "Choose current model:");
+    l->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE | FL_ALIGN_CLIP);
+    menu->browser = new Fl_Hold_Browser(0, BH, WW, 4 * BH);
+    menu->browser->callback(model_switch);
+    menu->browser->when(FL_WHEN_RELEASE_ALWAYS);
+    menu->butt = new Fl_Check_Button(0, 5 * BH, WW, BH, "Draw all models");
+    menu->butt->callback(model_draw_all);
+    menu->window->end();
+  }
+
+  menu->window->hotspot(menu->window);
+  menu->browser->clear();
+  for(unsigned int i = 0; i < GModel::list.size(); i++){
+    char tmp[256];
+    sprintf(tmp, "Model %d <<%s>>", i, GModel::list[i]->getName().c_str());
+    menu->browser->add(tmp);
+    if(GModel::list[i] == GModel::current()) menu->browser->value(i + 1);
+  }
+  menu->butt->value(CTX.draw_all_models);
+
+  if(menu->window->non_modal() && !menu->window->shown())
+    menu->window->show(); // fix ordering
+  menu->window->show();
+  return 0;
+}
diff --git a/Fltk/extraDialogs.h b/Fltk/extraDialogs.h
new file mode 100644
index 0000000000000000000000000000000000000000..d22116094d1e3555e6aa4fca3c616f62ba8a47d9
--- /dev/null
+++ b/Fltk/extraDialogs.h
@@ -0,0 +1,13 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+
+#ifndef _EXTRA_DIALOGS_H_
+#define _EXTRA_DIALOGS_H_
+
+int arrow_editor(const char *title, double &a, double &b, double &c);
+int perspective_editor();
+int model_chooser();
+
+#endif
diff --git a/Fltk/fieldWindow.cpp b/Fltk/fieldWindow.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e4095aad98301e0fbf41375c198c478458f456e9
--- /dev/null
+++ b/Fltk/fieldWindow.cpp
@@ -0,0 +1,310 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+
+#include <sstream>
+#include <FL/Fl_Input.H>
+#include <FL/Fl_Tabs.H>
+#include <FL/Fl_Return_Button.H>
+#include <FL/Fl_Value_Input.H>
+#include "GUI.h"
+#include "fieldWindow.h"
+#include "shortcutWindow.h"
+#include "GModel.h"
+#include "PView.h"
+#include "Callbacks.h"
+#include "GmshMessage.h"
+#include "Field.h"
+#include "GeoStringInterface.h"
+#include "Context.h"
+
+extern Context_T CTX;
+
+fieldWindow::fieldWindow(int fontsize) : _fontsize(fontsize)
+{
+  int width0 = 34 * _fontsize + WB;
+  int height0 = 13 * BH + 5 * WB;
+  int width = (CTX.field_size[0] < width0) ? width0 : CTX.field_size[0];
+  int height = (CTX.field_size[1] < height0) ? height0 : CTX.field_size[1];
+
+  win = new dialogWindow(width, height, CTX.non_modal_windows, "Fields");
+  win->box(GMSH_WINDOW_BOX);
+
+  int x = WB, y = WB, w = (int)(1.5 * BB), h = height - 2 * WB - 3 * BH;
+
+  Fl_Menu_Button *new_btn = new Fl_Menu_Button(x, y, w, BH, "New");
+  FieldManager &fields = *GModel::current()->getFields();
+
+  std::map<std::string, FieldFactory*>::iterator it;
+  for(it = fields.map_type_name.begin(); it != fields.map_type_name.end(); it++)
+    new_btn->add(it->first.c_str());
+  new_btn->callback(view_field_new_cb);
+
+  y += BH;
+  browser = new Fl_Hold_Browser(x, y + WB, w, h - 2 * WB);
+  browser->callback(view_field_browser_cb);
+
+  y += h; 
+  delete_btn = new Fl_Button(x, y, w, BH, "Delete");
+  delete_btn->callback(view_field_delete_cb, this);
+
+  y += BH;
+  put_on_view_btn = new Fl_Menu_Button(x, y, w, BH, "Put on view");
+  put_on_view_btn->callback(view_field_put_on_view_cb, this);
+
+  x += w + WB;
+  y = WB;
+  w = width - x - WB;
+  h = height - y - WB;
+  editor_group = new Fl_Group(x, y, w, h);
+    
+  title = new Fl_Box(x, y, w, BH, "field_name");
+  title->labelfont(FL_BOLD);
+  title->labelsize(18);
+  
+  y += BH + WB;
+  h -= BH + WB;
+  Fl_Tabs *tabs = new Fl_Tabs(x, y , w, h);
+  y += BH;
+  h -= BH;
+  x += WB;
+  w -= 2 * WB;
+
+  Fl_Group *options_tab = new Fl_Group(x, y, w, h, "Options");
+  
+  options_scroll = new Fl_Scroll(x, y, w, h - BH - 2 * WB);
+  options_scroll->end();
+  
+  Fl_Button *apply_btn = new Fl_Return_Button
+    (x + w - BB, y + h - BH - WB, BB, BH, "Apply");
+  apply_btn->callback(view_field_apply_cb, this);
+  
+  Fl_Button *revert_btn = new Fl_Button
+    (x + w - 2 * BB - WB, y + h - BH - WB, BB, BH, "Revert");
+  revert_btn->callback(view_field_revert_cb, this);
+  
+  background_btn = new Fl_Check_Button
+    (x, y + h - BH - WB, (int)(1.5 * BB), BH, "Background mesh size");
+  options_tab->end();
+
+  Fl_Group *help_tab = new Fl_Group(x, y, w, h, "Help");
+  help_display = new Fl_Browser(x, y + WB, w, h - 2 * WB);
+  help_tab->end();
+
+  tabs->end();
+
+  editor_group->end();
+
+  win->resizable(new Fl_Box((int)(1.5 * BB) + 2 * WB, BH + 2 * WB, 
+                            width - 3 * WB - (int)(1.5 * BB),
+                            height - 3 * BH - 5 * WB));
+  editor_group->resizable(tabs);
+  tabs->resizable(options_tab);
+  options_tab->resizable(new Fl_Box(3 * BB + 4 * WB, BH + 2 * WB,
+                                    width - 9 * WB - 5 * BB, 
+                                    height - 3 * BH - 5 * WB));
+  win->size_range(width0, height0);
+  win->position(CTX.field_position[0], CTX.field_position[1]);
+  win->end();
+
+  loadFieldViewList();
+  editField(NULL);
+}
+
+void fieldWindow::loadFieldViewList()
+{
+  put_on_view_btn->clear();
+  put_on_view_btn->add("New view");
+  put_on_view_btn->activate();
+  for(unsigned int i = 0; i < PView::list.size(); i++) {
+    std::ostringstream s;
+    s << "View [" << i << "]";
+    put_on_view_btn->add(s.str().c_str());
+  }
+}
+
+void fieldWindow::loadFieldList()
+{
+  FieldManager &fields = *GModel::current()->getFields();
+  Field *selected_field = (Field*)editor_group->user_data();
+  browser->clear();
+  int i_entry = 0;
+  for(FieldManager::iterator it = fields.begin(); it != fields.end(); it++){
+    i_entry++;
+    Field *field = it->second;
+    std::ostringstream sstream;
+    if(it->first == fields.background_field)
+      sstream << "@b";
+    sstream << it->first << " " << field->get_name();
+    browser->add(sstream.str().c_str(), field);
+    if(it->second == selected_field)
+      browser->select(i_entry);
+  }
+}
+
+void fieldWindow::saveFieldOptions()
+{
+  std::list<Fl_Widget*>::iterator input = options_widget.begin();
+  Field *f = (Field*)editor_group->user_data();
+  std::ostringstream sstream;
+  int i;
+  char a;
+  sstream.precision(16);
+  for(std::map<std::string, FieldOption*>::iterator it = f->options.begin();
+      it != f->options.end(); it++){
+    FieldOption *option = it->second;
+    sstream.str("");
+    switch(option->get_type()){
+    case FIELD_OPTION_STRING:
+    case FIELD_OPTION_PATH:
+      sstream << "\"" << ((Fl_Input*)*input)->value() << "\"";
+      break;
+    case FIELD_OPTION_INT:
+      sstream << (int)((Fl_Value_Input*)*input)->value();
+      break;
+    case FIELD_OPTION_DOUBLE:
+      sstream << ((Fl_Value_Input*)*input)->value();
+      break;
+    case FIELD_OPTION_BOOL:
+      sstream << (bool)((Fl_Check_Button*)*input)->value();
+      break;
+    case FIELD_OPTION_LIST:
+      {
+        sstream << "{";
+        std::istringstream istream(((Fl_Input*)*input)->value());
+        while(istream >> i){
+          sstream << i;
+          if(istream >> a){
+            if(a != ',')
+              Msg::Error("Unexpected character \'%c\' while parsing option "
+                         "'%s' of field \'%s\'", a, it->first.c_str(), f->id);
+            sstream << ", ";
+          }
+        }
+        sstream << "}";
+      }
+      break;
+    }
+    if((*input)->changed()){
+      add_field_option(f->id, it->first.c_str(), sstream.str().c_str(), 
+                       CTX.filename);
+      (*input)->clear_changed();
+    }
+    input++;
+  }
+  int is_bg_field = background_btn->value();
+  FieldManager &fields = *GModel::current()->getFields();
+  if(is_bg_field && fields.background_field != f->id){
+    set_background_field(f->id, CTX.filename);
+    loadFieldList();
+  }
+  if(!is_bg_field && fields.background_field == f->id){
+    set_background_field(-1, CTX.filename);
+    loadFieldList();
+  }
+}
+
+void fieldWindow::loadFieldOptions()
+{
+  Field *f = (Field*)editor_group->user_data();
+  std::list<Fl_Widget*>::iterator input = options_widget.begin();
+  for(std::map<std::string, FieldOption*>::iterator it = f->options.begin();
+      it != f->options.end(); it++){
+    FieldOption *option = it->second;
+    std::ostringstream vstr;
+    std::list<int>::iterator list_it;
+    switch(option->get_type()){
+    case FIELD_OPTION_STRING:
+    case FIELD_OPTION_PATH:
+      ((Fl_Input*)(*input))->value(option->string().c_str());
+      break;
+    case FIELD_OPTION_INT:
+    case FIELD_OPTION_DOUBLE:
+      ((Fl_Value_Input*)(*input))->value(option->numerical_value());
+      break;
+    case FIELD_OPTION_BOOL:
+      ((Fl_Check_Button*)(*input))->value((int)option->numerical_value());
+      break;
+    case FIELD_OPTION_LIST:
+      vstr.str("");
+      for(list_it = option->list().begin(); list_it != option->list().end();
+          list_it++){
+	if(list_it!=option->list().begin())
+	  vstr << ", ";
+	vstr << *list_it;
+      }
+      ((Fl_Input*)(*input))->value(vstr.str().c_str());
+      break;
+    }
+    (*input)->clear_changed();
+    input++;
+  }
+  background_btn->value(GModel::current()->getFields()->background_field == f->id);
+}
+
+void fieldWindow::editField(Field *f)
+{
+  editor_group->user_data(f);
+  put_on_view_btn->deactivate();
+  delete_btn->deactivate();
+  if(f == NULL){
+    selected_id = -1;
+    editor_group->hide();
+    loadFieldList();
+    return;
+  }
+  selected_id = f->id;
+  editor_group->show();
+  editor_group->user_data(f);
+  title->label(f->get_name());
+  options_scroll->clear();
+  options_widget.clear();
+  options_scroll->begin();
+  int x = options_scroll->x();
+  int yy = options_scroll->y() + WB;
+  help_display->clear();
+  add_multiline_in_browser(help_display, "", f->get_description().c_str(), 100);
+  help_display->add("\n");
+  help_display->add("@b@cOptions");
+  for(std::map<std::string, FieldOption*>::iterator it = f->options.begin(); 
+      it != f->options.end(); it++){
+    Fl_Widget *input;
+    help_display->add(("@b" + it->first).c_str());
+    help_display->add(("@i" + it->second->get_type_name()).c_str());
+    add_multiline_in_browser
+      (help_display, "", it->second->get_description().c_str(), 100);
+    switch(it->second->get_type()){
+    case FIELD_OPTION_INT:
+    case FIELD_OPTION_DOUBLE:
+      input = new Fl_Value_Input(x, yy, IW, BH, it->first.c_str());
+      break;
+    case FIELD_OPTION_BOOL:
+      input = new Fl_Check_Button(x, yy, BH, BH, it->first.c_str());
+      break;
+    case FIELD_OPTION_PATH:
+      {
+        Fl_Button *b = new Fl_Button(x, yy, BH, BH, "S");
+        input = new Fl_Input(x + WB + BH, yy, IW - WB - BH, BH, it->first.c_str());
+        b->callback(view_field_select_file_cb, input);
+      }
+      break;
+    case FIELD_OPTION_STRING:
+      input = new Fl_Input(x, yy, IW, BH, it->first.c_str());
+      break;
+    case FIELD_OPTION_LIST:
+    default:
+      input = new Fl_Input(x, yy, IW, BH, it->first.c_str());
+      break;
+    }
+    input->align(FL_ALIGN_RIGHT);
+    options_widget.push_back(input);
+    yy += WB + BH;
+  }
+  options_scroll->end();
+  loadFieldOptions();
+  options_scroll->damage(1);
+  put_on_view_btn->activate();
+  delete_btn->activate();
+  loadFieldList();
+}
diff --git a/Fltk/fieldWindow.h b/Fltk/fieldWindow.h
new file mode 100644
index 0000000000000000000000000000000000000000..349007d8eb8ba713a38ef4db8f18462886b439da
--- /dev/null
+++ b/Fltk/fieldWindow.h
@@ -0,0 +1,47 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+
+#ifndef _FIELD_WINDOW_H_
+#define _FIELD_WINDOW_H_
+
+#include <list>
+#include <FL/Fl_Window.H>
+#include <FL/Fl_Browser.H>
+#include <FL/Fl_Hold_Browser.H>
+#include <FL/Fl_Widget.H>
+#include <FL/Fl_Button.H>
+#include <FL/Fl_Check_Button.H>
+#include <FL/Fl_Group.H>
+#include <FL/Fl_Scroll.H>
+#include <FL/Fl_Box.H>
+#include <FL/Fl_Menu_Button.H>
+
+class Field;
+
+class fieldWindow{
+ private:
+  int _fontsize;
+ public:
+  Fl_Window *win;
+  Fl_Hold_Browser *browser;
+  std::list<Fl_Widget*> options_widget;
+  Fl_Scroll *options_scroll;
+  Fl_Group *editor_group;
+  Fl_Box *title;
+  Fl_Check_Button *background_btn;
+  Fl_Menu_Button *put_on_view_btn;
+  Fl_Browser *help_display;
+  Fl_Button *delete_btn;
+  int selected_id;
+ public:
+  fieldWindow(int fontsize);
+  void loadFieldViewList();
+  void loadFieldList();
+  void saveFieldOptions();
+  void loadFieldOptions();
+  void editField(Field *f);
+};
+
+#endif
diff --git a/Fltk/File_Picker.h b/Fltk/fileChooser.h
similarity index 86%
rename from Fltk/File_Picker.h
rename to Fltk/fileChooser.h
index 347d6544d2f8c9d0cf17d1d8a4a9e65e9fef4510..f372c4bd68c51d01c9a6d0bea5eb9567e264f235 100644
--- a/Fltk/File_Picker.h
+++ b/Fltk/fileChooser.h
@@ -16,17 +16,19 @@
 // we need to use a cheap hack to get to it. Even worse is the hack
 // used to get the focus on the file input widget. Sigh...
 
-class File_Picker : public Fl_File_Chooser {
-private:
+class fileChooser : public Fl_File_Chooser {
+ private:
   Fl_Window *_win;
   Fl_File_Input *_in;
-public:
-  File_Picker(const char *d, const char *p, int t, const char *title)
-    : Fl_File_Chooser(d, p, t, title) { 
+ public:
+  fileChooser(const char *d, const char *p, int t, const char *title)
+    : Fl_File_Chooser(d, p, t, title) 
+  { 
     _win = dynamic_cast<Fl_Window*>(newButton->parent()->parent()); 
     _in = dynamic_cast<Fl_File_Input *>(previewButton->parent()->parent()->resizable());
   }
-  void show(){
+  void show()
+  {
     if(_win){
       _win->show();
       rescan(); // necessary since fltk 1.1.7
diff --git a/Fltk/GUI_Extras.cpp b/Fltk/fileDialogs.cpp
similarity index 52%
rename from Fltk/GUI_Extras.cpp
rename to Fltk/fileDialogs.cpp
index 2a8a71e86bf7c618447e3932a85ae263ef4cb633..e23fdc805c8ba11fc94eb66238f88b68fc949fb9 100644
--- a/Fltk/GUI_Extras.cpp
+++ b/Fltk/fileDialogs.cpp
@@ -8,39 +8,36 @@
 //
 
 #include <limits>
-#include "GmshUI.h"
+#include <errno.h>
+#include <FL/Fl_Check_Button.H>
+#include <FL/Fl_Return_Button.H>
+#include <FL/Fl_Value_Slider.H>
+#include <FL/Fl_Menu_Window.H>
+#include <FL/Fl_Select_Browser.H>
+#include <FL/Fl_Toggle_Button.H>
+#include <FL/Fl_Round_Button.H>
+#include <FL/Fl_Choice.H>
+#include "GUI.h"
+#include "shortcutWindow.h"
 #include "GmshDefines.h"
 #include "CreateFile.h"
 #include "Options.h"
-#include "Context.h"
 #include "Draw.h"
-#include "GUI.h"
-#include "Shortcut_Window.h"
 #include "GModel.h"
-#include "Partition.h"
+#include "Context.h"
 
-#include <FL/Fl_Value_Slider.H>
-#include <FL/Fl_Menu_Window.H>
-#include <FL/Fl_Select_Browser.H>
-#include <FL/Fl_Toggle_Button.H>
-#include <FL/Fl_Round_Button.H>
-#include <errno.h>
+extern Context_T CTX;
 
-// FIXME we shoud use copy_label everywhere, but it's broken for
-// Fl_Windows in fltk 1.1.7
+// File chooser
 
 #if defined(HAVE_NATIVE_FILE_CHOOSER)
 #include <FL/Fl_Native_File_Chooser.H>
 static Fl_Native_File_Chooser *fc = 0;
 #else
-#include "File_Picker.h"
-static File_Picker *fc = 0;
+#include "fileChooser.h"
+static fileChooser *fc = 0;
 #endif
 
-extern Context_T CTX;
-
-// File chooser
-
 int file_chooser(int multi, int create, const char *message,
                  const char *filter, const char *fname)
 {
@@ -80,7 +77,7 @@ int file_chooser(int multi, int create, const char *message,
   Fl_File_Chooser::show_label = "Format:";
   Fl_File_Chooser::all_files_label = "All files (*)";
   if(!fc) {
-    fc = new File_Picker(getenv("PWD") ? "." : CTX.home_dir, thefilter, 
+    fc = new fileChooser(getenv("PWD") ? "." : CTX.home_dir, thefilter, 
                          Fl_File_Chooser::SINGLE, message);
     fc->position(CTX.file_chooser_position[0], CTX.file_chooser_position[1]);
   }
@@ -129,181 +126,6 @@ void file_chooser_get_position(int *x, int *y)
 #endif
 }
 
-// Arrow editor
-
-int arrow_editor(const char *title, double &a, double &b, double &c)
-{
-  struct _editor{
-    Fl_Window *window;
-    Fl_Value_Slider *sa, *sb, *sc;
-    Fl_Button *apply, *cancel;
-  };
-  static _editor *editor = NULL;
-
-  const int BH = 2 * GetFontSize() + 1;
-  const int BB = 7 * GetFontSize() + 9;
-  const int WB = 7;
-
-  if(!editor){
-    editor = new _editor;
-    editor->window = new Dialog_Window(2 * BB + 3 * WB, 4 * BH + 3 * WB, CTX.non_modal_windows);
-    editor->sa = new Fl_Value_Slider(WB, WB, BB, BH, "Head radius");
-    editor->sa->type(FL_HOR_SLIDER);
-    editor->sa->align(FL_ALIGN_RIGHT);
-    editor->sb = new Fl_Value_Slider(WB, WB + BH, BB, BH, "Stem length");
-    editor->sb->type(FL_HOR_SLIDER);
-    editor->sb->align(FL_ALIGN_RIGHT);
-    editor->sc = new Fl_Value_Slider(WB, WB + 2 * BH, BB, BH, "Stem radius");
-    editor->sc->type(FL_HOR_SLIDER);
-    editor->sc->align(FL_ALIGN_RIGHT);
-    editor->apply = new Fl_Return_Button(WB, 2 * WB + 3 * BH, BB, BH, "Apply");
-    editor->cancel = new Fl_Button(2 * WB + BB, 2 * WB + 3 * BH, BB, BH, "Cancel");
-    editor->window->end();
-    editor->window->hotspot(editor->window);
-  }
-  
-  editor->window->label(title);
-  editor->sa->value(a);
-  editor->sb->value(b);
-  editor->sc->value(c);
-  editor->window->show();
-
-  while(editor->window->shown()){
-    Fl::wait();
-    for (;;) {
-      Fl_Widget* o = Fl::readqueue();
-      if (!o) break;
-      if (o == editor->apply) {
-        a = editor->sa->value();
-        b = editor->sb->value();
-        c = editor->sc->value();
-        return 1;
-      }
-      if (o == editor->window || o == editor->cancel){
-        editor->window->hide();
-        return 0;
-      }
-    }
-  }
-  return 0;
-}
-
-// Perspective editor (aka z-clipping planes factor slider)
-
-static void persp_change_factor(Fl_Widget* w, void* data)
-{
-  opt_general_clip_factor(0, GMSH_SET|GMSH_GUI, ((Fl_Slider*)w)->value());
-  Draw();
-}
-
-class Release_Slider : public Fl_Slider {
-  int handle(int event){ 
-    switch (event) {
-    case FL_RELEASE: 
-      if(window())
-        window()->hide();
-      return 1;
-    default:
-      return Fl_Slider::handle(event);
-    }
-  };
-public:
-  Release_Slider(int x,int y,int w,int h,const char *l=0)
-    : Fl_Slider(x, y, w, h, l) {}
-};
-
-int perspective_editor()
-{
-  struct _editor{
-    Fl_Menu_Window *window;
-    Release_Slider *sa;
-  };
-  static _editor *editor = NULL;
-
-  if(!editor){
-    editor = new _editor;
-    editor->window = new Fl_Menu_Window(20, 100);
-    if(CTX.non_modal_windows) editor->window->set_non_modal();
-    editor->sa = new Release_Slider(0, 0, 20, 100);
-    editor->sa->type(FL_VERT_NICE_SLIDER);
-    editor->sa->minimum(12);
-    editor->sa->maximum(0.75);
-    editor->sa->callback(persp_change_factor);
-    editor->window->border(0);
-    editor->window->end();
-  }
-
-  editor->window->hotspot(editor->window);
-  editor->sa->value(CTX.clip_factor);
-
-  if(editor->window->non_modal() && !editor->window->shown())
-    editor->window->show(); // fix ordering
-  editor->window->show();
-  return 0;
-}
-
-// Model chooser
-
-static void model_switch(Fl_Widget* w, void *data)
-{
-  Fl_Select_Browser *b = (Fl_Select_Browser *)w;
-  if(b->value()) GModel::current(b->value() - 1);
-  if(w->window()) w->window()->hide();
-  CTX.mesh.changed = ENT_ALL;
-  // FIXME: need to call WID->reset_visibility();
-  Draw();
-}
-
-static void model_draw_all(Fl_Widget* w, void *data)
-{
-  Fl_Check_Button *b = (Fl_Check_Button*)w;
-  opt_general_draw_all_models(0, GMSH_SET | GMSH_GUI, (int)b->value());
-  Draw();
-}
-
-int model_chooser()
-{
-  struct _menu{
-    Fl_Menu_Window *window;
-    Fl_Hold_Browser *browser;
-    Fl_Check_Button *butt;
-  };
-  static _menu *menu = NULL;
-
-  const int BH = 2 * GetFontSize() + 1;
-  const int WW = 200;
-
-  if(!menu){
-    menu = new _menu;
-    menu->window = new Fl_Menu_Window(WW, 6 * BH);
-    if(CTX.non_modal_windows) menu->window->set_non_modal();
-    menu->window->border(0);
-    Fl_Box *l = new Fl_Box(0, 0, WW, BH, "Choose current model:");
-    l->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE | FL_ALIGN_CLIP);
-    menu->browser = new Fl_Hold_Browser(0, BH, WW, 4 * BH);
-    menu->browser->callback(model_switch);
-    menu->browser->when(FL_WHEN_RELEASE_ALWAYS);
-    menu->butt = new Fl_Check_Button(0, 5 * BH, WW, BH, "Draw all models");
-    menu->butt->callback(model_draw_all);
-    menu->window->end();
-  }
-
-  menu->window->hotspot(menu->window);
-  menu->browser->clear();
-  for(unsigned int i = 0; i < GModel::list.size(); i++){
-    char tmp[256];
-    sprintf(tmp, "Model %d <<%s>>", i, GModel::list[i]->getName().c_str());
-    menu->browser->add(tmp);
-    if(GModel::list[i] == GModel::current()) menu->browser->value(i + 1);
-  }
-  menu->butt->value(CTX.draw_all_models);
-
-  if(menu->window->non_modal() && !menu->window->shown())
-    menu->window->show(); // fix ordering
-  menu->window->show();
-  return 0;
-}
-
 // Generic save bitmap dialog
 
 int generic_bitmap_dialog(const char *name, const char *title, int format)
@@ -314,18 +136,16 @@ int generic_bitmap_dialog(const char *name, const char *title, int format)
     Fl_Button *ok, *cancel;
   };
   static _generic_bitmap_dialog *dialog = NULL;
-
-  const int BH = 2 * GetFontSize() + 1;
-  const int BB = 7 * GetFontSize() + 9;
-  const int WB = 7;
+  int _fontsize = GetFontSize();
 
   if(!dialog){
     dialog = new _generic_bitmap_dialog;
     int h = 3 * WB + 2 * BH, w = 2 * BB + 3 * WB, y = WB;
-    // not a "Dialog_Window" since it is modal 
+    // not a "dialogWindow" since it is modal 
     dialog->window = new Fl_Double_Window(w, h);
     dialog->window->box(GMSH_WINDOW_BOX);
-    dialog->b = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Print text strings"); y += BH;
+    dialog->b = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Print text strings"); y += BH;
     dialog->b->type(FL_TOGGLE_BUTTON);
     dialog->ok = new Fl_Return_Button(WB, y + WB, BB, BH, "OK");
     dialog->cancel = new Fl_Button(2 * WB + BB, y + WB, BB, BH, "Cancel");
@@ -368,18 +188,17 @@ int latex_dialog(const char *name)
     Fl_Button *ok, *cancel;
   };
   static _latex_dialog *dialog = NULL;
-
-  const int BH = 2 * GetFontSize() + 1;
-  const int BB = 7 * GetFontSize() + 9;
-  const int WB = 7;
+  
+  int _fontsize = GetFontSize();
 
   if(!dialog){
     dialog = new _latex_dialog;
     int h = 3 * WB + 2 * BH, w = 2 * BB + 3 * WB, y = WB;
-    // not a "Dialog_Window" since it is modal 
+    // not a "dialogWindow" since it is modal 
     dialog->window = new Fl_Double_Window(w, h, "LaTeX Options");
     dialog->window->box(GMSH_WINDOW_BOX);
-    dialog->b = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Print strings as equations"); y += BH;
+    dialog->b = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Print strings as equations"); y += BH;
     dialog->b->type(FL_TOGGLE_BUTTON);
     dialog->ok = new Fl_Return_Button(WB, y + WB, BB, BH, "OK");
     dialog->cancel = new Fl_Button(2 * WB + BB, y + WB, BB, BH, "Cancel");
@@ -423,14 +242,12 @@ int jpeg_dialog(const char *name)
   };
   static _jpeg_dialog *dialog = NULL;
 
-  const int BH = 2 * GetFontSize() + 1;
-  const int BB = 7 * GetFontSize() + 9;
-  const int WB = 7;
+  int _fontsize = GetFontSize();
 
   if(!dialog){
     dialog = new _jpeg_dialog;
     int h = 3 * WB + 4 * BH, w = 2 * BB + 3 * WB, y = WB;
-    // not a "Dialog_Window" since it is modal 
+    // not a "dialogWindow" since it is modal 
     dialog->window = new Fl_Double_Window(w, h, "JPEG Options");
     dialog->window->box(GMSH_WINDOW_BOX);
     dialog->s[0] = new Fl_Value_Slider(WB, y, BB, BH, "Quality"); y += BH;
@@ -445,7 +262,8 @@ int jpeg_dialog(const char *name)
     dialog->s[1]->minimum(0);
     dialog->s[1]->maximum(100);
     dialog->s[1]->step(1);
-    dialog->b = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Print text strings"); y += BH;
+    dialog->b = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Print text strings"); y += BH;
     dialog->b->type(FL_TOGGLE_BUTTON);
     dialog->ok = new Fl_Return_Button(WB, y + WB, BB, BH, "OK");
     dialog->cancel = new Fl_Button(2 * WB + BB, y + WB, BB, BH, "Cancel");
@@ -492,21 +310,24 @@ int gif_dialog(const char *name)
   };
   static _gif_dialog *dialog = NULL;
 
-  const int BH = 2 * GetFontSize() + 1;
-  const int BB = 7 * GetFontSize() + 9;
-  const int WB = 7;
+  int _fontsize = GetFontSize();
 
   if(!dialog){
     dialog = new _gif_dialog;
     int h = 3 * WB + 6 * BH, w = 2 * BB + 3 * WB, y = WB;
-    // not a "Dialog_Window" since it is modal 
+    // not a "dialogWindow" since it is modal 
     dialog->window = new Fl_Double_Window(w, h, "GIF Options");
     dialog->window->box(GMSH_WINDOW_BOX);
-    dialog->b[0] = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Dither"); y += BH;
-    dialog->b[1] = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Interlace"); y += BH;
-    dialog->b[2] = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Sort colormap"); y += BH;
-    dialog->b[3] = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Transparent background"); y += BH;
-    dialog->b[4] = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Print text strings"); y += BH;
+    dialog->b[0] = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Dither"); y += BH;
+    dialog->b[1] = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Interlace"); y += BH;
+    dialog->b[2] = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Sort colormap"); y += BH;
+    dialog->b[3] = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Transparent background"); y += BH;
+    dialog->b[4] = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Print text strings"); y += BH;
     for(int i = 0; i < 5; i++){
       dialog->b[i]->type(FL_TOGGLE_BUTTON);
     }
@@ -604,25 +425,29 @@ int gl2ps_dialog(const char *name, const char *title, int format)
     {0}
   };
 
-  const int BH = 2 * GetFontSize() + 1;
-  const int BB = 7 * GetFontSize() + 9;
-  const int WB = 7;
+  int _fontsize = GetFontSize();
 
   if(!dialog){
     dialog = new _gl2ps_dialog;
     int h = 3 * WB + 8 * BH, w = 2 * BB + 3 * WB, y = WB;
-    // not a "Dialog_Window" since it is modal 
+    // not a "dialogWindow" since it is modal 
     dialog->window = new Fl_Double_Window(w, h);
     dialog->window->box(GMSH_WINDOW_BOX);
     dialog->c = new Fl_Choice(WB, y, BB + WB + BB / 2, BH, "Type"); y += BH;
     dialog->c->menu(sortmenu);
     dialog->c->align(FL_ALIGN_RIGHT);
-    dialog->b[0] = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Compress"); y += BH;
-    dialog->b[1] = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Print background"); y += BH;
-    dialog->b[2] = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Remove hidden primitives"); y += BH;
-    dialog->b[3] = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Optimize BSP tree"); y += BH;
-    dialog->b[4] = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Use level 3 shading"); y += BH;
-    dialog->b[5] = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Print text strings"); y += BH;
+    dialog->b[0] = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Compress"); y += BH;
+    dialog->b[1] = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Print background"); y += BH;
+    dialog->b[2] = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Remove hidden primitives"); y += BH;
+    dialog->b[3] = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Optimize BSP tree"); y += BH;
+    dialog->b[4] = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Use level 3 shading"); y += BH;
+    dialog->b[5] = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Print text strings"); y += BH;
     for(int i = 0; i < 6; i++){
       dialog->b[i]->type(FL_TOGGLE_BUTTON);
     }
@@ -687,20 +512,20 @@ int options_dialog(const char *name)
   };
   static _options_dialog *dialog = NULL;
 
-  const int BH = 2 * GetFontSize() + 1;
-  const int BB = 7 * GetFontSize() + 9;
-  const int WB = 7;
+  int _fontsize = GetFontSize();
 
   if(!dialog){
     dialog = new _options_dialog;
     int h = 3 * WB + 3 * BH, w = 2 * BB + 3 * WB, y = WB;
-    // not a "Dialog_Window" since it is modal 
+    // not a "dialogWindow" since it is modal 
     dialog->window = new Fl_Double_Window(w, h, "Options");
     dialog->window->box(GMSH_WINDOW_BOX);
-    dialog->b[0] = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Save only modified options"); y += BH;
+    dialog->b[0] = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Save only modified options"); y += BH;
     dialog->b[0]->value(1);
     dialog->b[0]->type(FL_TOGGLE_BUTTON);
-    dialog->b[1] = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Print help strings"); y += BH;
+    dialog->b[1] = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Print help strings"); y += BH;
     dialog->b[1]->value(0);
     dialog->b[1]->type(FL_TOGGLE_BUTTON);
     dialog->ok = new Fl_Return_Button(WB, y + WB, BB, BH, "OK");
@@ -742,17 +567,16 @@ int geo_dialog(const char *name)
   };
   static _geo_dialog *dialog = NULL;
 
-  const int BH = 2 * GetFontSize() + 1;
-  const int BB = 7 * GetFontSize() + 9;
-  const int WB = 7;
+  int _fontsize = GetFontSize();
 
   if(!dialog){
     dialog = new _geo_dialog;
     int h = 3 * WB + 2 * BH, w = 2 * BB + 3 * WB, y = WB;
-    // not a "Dialog_Window" since it is modal 
+    // not a "dialogWindow" since it is modal 
     dialog->window = new Fl_Double_Window(w, h, "GEO Options");
     dialog->window->box(GMSH_WINDOW_BOX);
-    dialog->b = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Save physical group labels"); y += BH;
+    dialog->b = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Save physical group labels"); y += BH;
     dialog->b->type(FL_TOGGLE_BUTTON);
     dialog->ok = new Fl_Return_Button(WB, y + WB, BB, BH, "OK");
     dialog->cancel = new Fl_Button(2 * WB + BB, y + WB, BB, BH, "Cancel");
@@ -793,23 +617,28 @@ int pos_dialog(const char *name)
   };
   static _pos_dialog *dialog = NULL;
 
-  const int BH = 2 * GetFontSize() + 1;
-  const int BB = 7 * GetFontSize() + 9;
-  const int WB = 7;
+  int _fontsize = GetFontSize();
 
   if(!dialog){
     dialog = new _pos_dialog;
     int h = 3 * WB + 8 * BH, w = 2 * BB + 3 * WB, y = WB;
-    // not a "Dialog_Window" since it is modal 
+    // not a "dialogWindow" since it is modal 
     dialog->window = new Fl_Double_Window(w, h, "POS Options");
     dialog->window->box(GMSH_WINDOW_BOX);
-    dialog->b[0] = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Save all (ignore physical groups)"); y += BH;
-    dialog->b[1] = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Print elementary tags"); y += BH;
-    dialog->b[2] = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Print element numbers"); y += BH;
-    dialog->b[3] = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Print Gamma quality measure"); y += BH;
-    dialog->b[4] = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Print Eta quality measure"); y += BH;
-    dialog->b[5] = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Print Rho quality measure"); y += BH;
-    dialog->b[6] = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Print Disto quality measure"); y += BH;
+    dialog->b[0] = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Save all (ignore physical groups)"); y += BH;
+    dialog->b[1] = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Print elementary tags"); y += BH;
+    dialog->b[2] = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Print element numbers"); y += BH;
+    dialog->b[3] = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Print Gamma quality measure"); y += BH;
+    dialog->b[4] = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Print Eta quality measure"); y += BH;
+    dialog->b[5] = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Print Rho quality measure"); y += BH;
+    dialog->b[6] = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Print Disto quality measure"); y += BH;
     for(int i = 0; i < 6; i++)
       dialog->b[i]->type(FL_TOGGLE_BUTTON);
     dialog->ok = new Fl_Return_Button(WB, y + WB, BB, BH, "OK");
@@ -873,22 +702,22 @@ int msh_dialog(const char *name)
     {0}
   };
 
-  const int BH = 2 * GetFontSize() + 1;
-  const int BB = 7 * GetFontSize() + 9;
-  const int WB = 7;
+  int _fontsize = GetFontSize();
 
   if(!dialog){
     dialog = new _msh_dialog;
     int h = 3 * WB + 4 * BH, w = 2 * BB + 3 * WB, y = WB;
-    // not a "Dialog_Window" since it is modal 
+    // not a "dialogWindow" since it is modal 
     dialog->window = new Fl_Double_Window(w, h, "MSH Options");
     dialog->window->box(GMSH_WINDOW_BOX);
     dialog->c = new Fl_Choice(WB, y, BB + BB / 2, BH, "Format"); y += BH;
     dialog->c->menu(formatmenu);
     dialog->c->align(FL_ALIGN_RIGHT);
-    dialog->b = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Save all (ignore physical groups)"); y += BH;
+    dialog->b = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Save all (ignore physical groups)"); y += BH;
     dialog->b->type(FL_TOGGLE_BUTTON);
-    dialog->p = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Save Parametric Coordinates"); y += BH;
+    dialog->p = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Save Parametric Coordinates"); y += BH;
     dialog->p->type(FL_TOGGLE_BUTTON);
     dialog->ok = new Fl_Return_Button(WB, y + WB, BB, BH, "OK");
     dialog->cancel = new Fl_Button(2 * WB + BB, y + WB, BB, BH, "Cancel");
@@ -909,7 +738,8 @@ int msh_dialog(const char *name)
       Fl_Widget* o = Fl::readqueue();
       if (!o) break;
       if (o == dialog->ok) {
-        opt_mesh_msh_file_version(0, GMSH_SET | GMSH_GUI, (dialog->c->value() == 0) ? 1.0 : 2.0);
+        opt_mesh_msh_file_version(0, GMSH_SET | GMSH_GUI, 
+                                  (dialog->c->value() == 0) ? 1.0 : 2.0);
         opt_mesh_binary(0, GMSH_SET | GMSH_GUI, (dialog->c->value() == 2) ? 1 : 0);
         opt_mesh_save_all(0, GMSH_SET | GMSH_GUI, dialog->b->value() ? 1 : 0);
         opt_mesh_save_parametric(0, GMSH_SET | GMSH_GUI, dialog->p->value() ? 1 : 0);
@@ -937,19 +767,19 @@ int unv_dialog(const char *name)
   };
   static _unv_dialog *dialog = NULL;
 
-  const int BH = 2 * GetFontSize() + 1;
-  const int BB = 7 * GetFontSize() + 9;
-  const int WB = 7;
+  int _fontsize = GetFontSize();
 
   if(!dialog){
     dialog = new _unv_dialog;
     int h = 3 * WB + 3 * BH, w = 2 * BB + 3 * WB, y = WB;
-    // not a "Dialog_Window" since it is modal 
+    // not a "dialogWindow" since it is modal 
     dialog->window = new Fl_Double_Window(w, h, "UNV Options");
     dialog->window->box(GMSH_WINDOW_BOX);
-    dialog->b[0] = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Save all (ignore physical groups)"); y += BH;
+    dialog->b[0] = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Save all (ignore physical groups)"); y += BH;
     dialog->b[0]->type(FL_TOGGLE_BUTTON);
-    dialog->b[1] = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Save groups of nodes"); y += BH;
+    dialog->b[1] = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Save groups of nodes"); y += BH;
     dialog->b[1]->type(FL_TOGGLE_BUTTON);
     dialog->ok = new Fl_Return_Button(WB, y + WB, BB, BH, "OK");
     dialog->cancel = new Fl_Button(2 * WB + BB, y + WB, BB, BH, "Cancel");
@@ -969,7 +799,8 @@ int unv_dialog(const char *name)
       if (!o) break;
       if (o == dialog->ok) {
         opt_mesh_save_all(0, GMSH_SET | GMSH_GUI, dialog->b[0]->value() ? 1 : 0);
-        opt_mesh_save_groups_of_nodes(0, GMSH_SET | GMSH_GUI, dialog->b[1]->value() ? 1 : 0);
+        opt_mesh_save_groups_of_nodes(0, GMSH_SET | GMSH_GUI, 
+                                      dialog->b[1]->value() ? 1 : 0);
         CreateOutputFile(name, FORMAT_UNV);
         dialog->window->hide();
         return 1;
@@ -1002,20 +833,19 @@ int bdf_dialog(const char *name)
     {0}
   };
 
-  const int BH = 2 * GetFontSize() + 1;
-  const int BB = 7 * GetFontSize() + 9;
-  const int WB = 7;
+  int _fontsize = GetFontSize();
 
   if(!dialog){
     dialog = new _bdf_dialog;
     int h = 3 * WB + 3 * BH, w = 2 * BB + 3 * WB, y = WB;
-    // not a "Dialog_Window" since it is modal 
+    // not a "dialogWindow" since it is modal 
     dialog->window = new Fl_Double_Window(w, h, "BDF Options");
     dialog->window->box(GMSH_WINDOW_BOX);
     dialog->c = new Fl_Choice(WB, y, BB + BB / 2, BH, "Format"); y += BH;
     dialog->c->menu(formatmenu);
     dialog->c->align(FL_ALIGN_RIGHT);
-    dialog->b = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Save all (ignore physical groups)"); y += BH;
+    dialog->b = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Save all (ignore physical groups)"); y += BH;
     dialog->b->type(FL_TOGGLE_BUTTON);
     dialog->ok = new Fl_Return_Button(WB, y + WB, BB, BH, "OK");
     dialog->cancel = new Fl_Button(2 * WB + BB, y + WB, BB, BH, "Cancel");
@@ -1068,20 +898,19 @@ int generic_mesh_dialog(const char *name, const char *title, int format,
     {0}
   };
 
-  const int BH = 2 * GetFontSize() + 1;
-  const int BB = 7 * GetFontSize() + 9;
-  const int WB = 7;
+  int _fontsize = GetFontSize();
 
   if(!dialog){
     dialog = new _generic_mesh_dialog;
     int h = 3 * WB + 3 * BH, w = 2 * BB + 3 * WB, y = WB;
-    // not a "Dialog_Window" since it is modal 
+    // not a "dialogWindow" since it is modal 
     dialog->window = new Fl_Double_Window(w, h);
     dialog->window->box(GMSH_WINDOW_BOX);
     dialog->c = new Fl_Choice(WB, y, BB + BB / 2, BH, "Format"); y += BH;
     dialog->c->menu(formatmenu);
     dialog->c->align(FL_ALIGN_RIGHT);
-    dialog->b = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Save all (ignore physical groups)"); y += BH;
+    dialog->b = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Save all (ignore physical groups)"); y += BH;
     dialog->b->type(FL_TOGGLE_BUTTON);
     dialog->ok = new Fl_Return_Button(WB, y + WB, BB, BH, "OK");
     dialog->cancel = new Fl_Button(2 * WB + BB, y + WB, BB, BH, "Cancel");
@@ -1121,7 +950,6 @@ int generic_mesh_dialog(const char *name, const char *title, int format,
 }
 
 
-// CGNS write dialog - widget pointers, callbacks, and dialog routine
 #if defined(HAVE_LIBCGNS)
 
 // Forward declarations of some callbacks
@@ -1321,13 +1149,9 @@ int cgns_write_dialog(const char *filename)
     {0}
   };
 
-  const int BH = 2*GetFontSize() + 1;   // button height
-  const int RBH = 3*GetFontSize()/2;    // radio button height
-  const int IW = 10*GetFontSize();      // Input field width
-  const int BB = 7*GetFontSize() + 9;   // Width of a button with an internal
-                                        // label
-  const int WB = 7;                     // Window border
+  int _fontsize = GetFontSize();
 
+  const int RBH = 3*GetFontSize()/2;    // radio button height
   const int col1 = WB;                  // Start of left column
   const int col2 = 2*WB + 2*BB;         // Start of right column
   const int hcol1 = 5*WB + 2*RBH + 3*BH;
@@ -1340,7 +1164,7 @@ int cgns_write_dialog(const char *filename)
   const int w = 3*WB + 4*BB;            // Window width
   int y = WB;
 
-  dlg.window = new Dialog_Window(w, h, true, "CGNS Options");
+  dlg.window = new dialogWindow(w, h, true, "CGNS Options");
   dlg.window->box(GMSH_WINDOW_BOX);
   dlg.window->callback((Fl_Callback *)cgnsw_cancel_cb, &dlg);
 
@@ -1550,763 +1374,3 @@ int cgns_write_dialog(const char *filename)
 }
 
 #endif  // compiling CGNS write dialog
-
-
-// Partition dialog - widget pointers, callbacks and dialog routine
-#if defined(HAVE_CHACO) || defined(HAVE_METIS)
-
-// Forward declarations of some callbacks
-void partition_opt_chaco_globalalg_cb(Fl_Widget *widget, void *data);
-void partition_opt_architecture_cb(Fl_Widget *widget, void *data);
-void partition_opt_num_partitions_cb(Fl_Widget *widget, void *data);
-void partition_opt_spectralcheck_cb(Fl_Widget *widget, void *data);
-void partition_select_groups_cb(Fl_Widget *widget, void *data);
-
-// Pointers to required widgets
-struct PartitionDialog
-{
-  Fl_Window *window;
-  // Group 0
-  Fl_Choice *choicePartitioner;
-  Fl_Value_Input *inputNumPartition;
-  // Group 1
-  Fl_Choice *choiceChacoAlg;
-  Fl_Toggle_Button *toggleButtonAdvChaco;
-  // Group 2
-  Fl_Choice *choiceArchitecture;
-  Fl_Value_Input *inputNumPartition1;
-  Fl_Value_Input *inputNumPartition2;
-  Fl_Value_Input *inputNumPartition3;
-  Fl_Choice *choiceDivisions;
-  Fl_Value_Input *inputVMax;
-  Fl_Choice *choiceEigensolver;
-  Fl_Value_Input *inputEigtol;
-  Fl_Choice *choiceLocalAlgorithm;
-  Fl_Value_Input *inputSeed;
-  Fl_Check_Button *checkButtonRefPart;
-  Fl_Check_Button *checkButtonIntVert;
-  Fl_Check_Button *checkButtonRefMap;
-  Fl_Check_Button *checkButtonTermProp;
-  // Group 3
-  Fl_Choice *choiceMetisAlg;
-  Fl_Toggle_Button *toggleButtonAdvMetis;
-  // Group 4
-  Fl_Choice *choiceEdgeMatch;
-  Fl_Choice *choiceRefineAlg;
-  void write_all_options()
-  {
-    // Group 0
-    CTX.mesh.partition_options.partitioner = choicePartitioner->value() + 1;
-    CTX.mesh.partition_options.num_partitions =
-      static_cast<int>(inputNumPartition->value());
-
-    // Group 1
-    CTX.mesh.partition_options.global_method = choiceChacoAlg->value() + 1;
-
-    // Group 2
-    CTX.mesh.partition_options.architecture = choiceArchitecture->value();
-    switch(CTX.mesh.partition_options.architecture) {
-    case 0:
-      CTX.mesh.partition_options.ndims_tot =
-        static_cast<int>(inputNumPartition1->value());
-      break;
-    case 3:
-      CTX.mesh.partition_options.mesh_dims[2] =
-        static_cast<int>(inputNumPartition3->value());
-    case 2:
-      CTX.mesh.partition_options.mesh_dims[1] =
-        static_cast<int>(inputNumPartition2->value());
-    case 1:
-      CTX.mesh.partition_options.mesh_dims[0] =
-        static_cast<int>(inputNumPartition1->value());
-      break;
-    }
-    CTX.mesh.partition_options.ndims = choiceDivisions->value() + 1;
-    CTX.mesh.partition_options.vmax = static_cast<int>(inputVMax->value());
-    CTX.mesh.partition_options.rqi_flag = choiceEigensolver->value();
-    CTX.mesh.partition_options.eigtol = inputEigtol->value();
-    CTX.mesh.partition_options.local_method = choiceLocalAlgorithm->value() + 1;
-    CTX.mesh.partition_options.seed = static_cast<long>(inputSeed->value());
-    CTX.mesh.partition_options.refine_partition = checkButtonRefPart->value();
-    CTX.mesh.partition_options.internal_vertices = checkButtonIntVert->value();
-    CTX.mesh.partition_options.refine_map = checkButtonRefMap->value();
-    CTX.mesh.partition_options.terminal_propogation =
-      checkButtonTermProp->value();
-  
-    // Group 3
-    CTX.mesh.partition_options.algorithm = choiceMetisAlg->value() + 1;
-
-    // Group 4
-    CTX.mesh.partition_options.edge_matching = choiceEdgeMatch->value() + 1;
-    CTX.mesh.partition_options.refine_algorithm = choiceRefineAlg->value() + 1;
-  }
-  void read_all_options()
-  {
-    // Group 0
-    choicePartitioner->value(CTX.mesh.partition_options.partitioner - 1);
-    inputNumPartition->value(CTX.mesh.partition_options.num_partitions);
-
-    // Group 1
-    choiceChacoAlg->value(CTX.mesh.partition_options.global_method - 1);
-
-    // Group 2
-    choiceArchitecture->value(CTX.mesh.partition_options.architecture);
-    switch(CTX.mesh.partition_options.architecture) {
-    case 0:
-      inputNumPartition1->value(CTX.mesh.partition_options.ndims_tot);
-      break;
-    case 1:
-      inputNumPartition1->value(CTX.mesh.partition_options.mesh_dims[0]);
-      break;
-    }
-    inputNumPartition2->value(CTX.mesh.partition_options.mesh_dims[1]);
-    inputNumPartition3->value(CTX.mesh.partition_options.mesh_dims[2]);
-    choiceDivisions->value(CTX.mesh.partition_options.ndims - 1);
-    inputVMax->value(CTX.mesh.partition_options.vmax);
-    choiceEigensolver->value(CTX.mesh.partition_options.rqi_flag);
-    inputEigtol->value(CTX.mesh.partition_options.eigtol);
-    choiceLocalAlgorithm->value(CTX.mesh.partition_options.local_method - 1);
-    inputSeed->value(CTX.mesh.partition_options.seed);
-    checkButtonRefPart->value(CTX.mesh.partition_options.refine_partition);
-    checkButtonIntVert->value(CTX.mesh.partition_options.internal_vertices);
-    checkButtonRefMap->value(CTX.mesh.partition_options.refine_map);
-    checkButtonTermProp->value(CTX.mesh.partition_options.terminal_propogation);
-  
-    // Group 3
-    choiceMetisAlg->value(CTX.mesh.partition_options.algorithm - 1);
-
-    // Group 4
-    choiceEdgeMatch->value(CTX.mesh.partition_options.edge_matching - 1);
-    choiceRefineAlg->value(CTX.mesh.partition_options.refine_algorithm - 1);
-
-    // Call all callbacks to ensure consistent options
-    partition_opt_chaco_globalalg_cb(choiceChacoAlg, this);
-    partition_opt_architecture_cb(choiceArchitecture, this);
-    partition_opt_num_partitions_cb(inputNumPartition, this);
-    partition_opt_spectralcheck_cb(choiceDivisions, this);
-  }
-};
-
-// Chaco option considerations based on the global algorithm
-void partition_opt_chaco_globalalg_cb(Fl_Widget *widget, void *data)
-{
-  PartitionDialog *dlg = static_cast<PartitionDialog*>(data);
-  unsigned opt = dlg->choiceChacoAlg->value();
-  if(opt == 0) {
-    dlg->choiceLocalAlgorithm->value(0);
-    dlg->choiceLocalAlgorithm->deactivate();
-  }
-  else {
-    dlg->choiceLocalAlgorithm->activate();
-  }
-  if(opt == 1) {
-    dlg->choiceEigensolver->value(1);
-    dlg->choiceEigensolver->activate();
-    if(dlg->choiceDivisions->value() != 0 &&
-       dlg->checkButtonTermProp->value())
-      dlg->choiceDivisions->value(0);
-  }
-  else {
-    dlg->choiceEigensolver->deactivate();
-  }
-}
-
-// Chaco option considerations based on the architecture
-void partition_opt_architecture_cb(Fl_Widget *widget, void *data)
-{
-  PartitionDialog *dlg = static_cast<PartitionDialog*>(data);
-  switch(static_cast<int>(dlg->choiceArchitecture->value())) {
-  case 0:
-    dlg->inputNumPartition1->maximum(31);
-    dlg->inputNumPartition2->deactivate();
-    dlg->inputNumPartition3->deactivate();
-    break;
-  case 1:
-    dlg->inputNumPartition1->maximum(std::numeric_limits<int>::max());
-    dlg->inputNumPartition2->deactivate();
-    dlg->inputNumPartition3->deactivate();
-    break;
-  case 2:
-    dlg->inputNumPartition1->maximum(std::numeric_limits<int>::max());
-    dlg->inputNumPartition2->activate();
-    dlg->inputNumPartition3->deactivate();
-    break;
-  case 3:
-    dlg->inputNumPartition1->maximum(std::numeric_limits<int>::max());
-    dlg->inputNumPartition2->activate();
-    dlg->inputNumPartition3->activate();
-    break;
-  }
-  // Set topology dimensions from main number of partitions
-  partition_opt_num_partitions_cb(dlg->inputNumPartition, data);
-}
-
-// Match several locations that provide a partition number
-void partition_opt_num_partitions_cb(Fl_Widget *widget, void *data)
-{
-  PartitionDialog *dlg = static_cast<PartitionDialog*>(data);
-  unsigned val = 0;
-  if(widget == dlg->inputNumPartition) {
-    val = static_cast<unsigned>(dlg->inputNumPartition->value());
-    switch(static_cast<int>(dlg->choiceArchitecture->value())) {
-    case 0:
-      {
-        unsigned y = 0;
-        unsigned x = val;
-        while(x >>= 1) ++y;
-        dlg->inputNumPartition1->value(y);
-      }
-      break;
-    case 1:
-    case 2:
-    case 3:
-      dlg->inputNumPartition1->value(val);
-      dlg->inputNumPartition2->value(1);
-      dlg->inputNumPartition3->value(1);
-      break;
-    }
-  }
-  else {
-    switch(static_cast<int>(dlg->choiceArchitecture->value())) {
-    case 0:
-      {
-        unsigned x = static_cast<unsigned>(dlg->inputNumPartition1->value());
-        val = 1 << x;
-      }
-      break;
-    case 1:
-      val = static_cast<unsigned>(dlg->inputNumPartition1->value());
-      break;
-    case 2:
-      val = static_cast<unsigned>
-        (dlg->inputNumPartition1->value()*dlg->inputNumPartition2->value());
-      break;
-    case 3:
-      val = static_cast<unsigned>
-        (dlg->inputNumPartition1->value()*dlg->inputNumPartition2->value()*
-         dlg->inputNumPartition3->value());
-      break;
-    }
-    dlg->inputNumPartition->value(val);
-  }
-  switch(dlg->choicePartitioner->value()) {
-  case 0:
-    if(val <= 3) {
-      dlg->choiceDivisions->value(0);
-      dlg->choiceDivisions->mode(1, FL_MENU_INACTIVE);
-      dlg->choiceDivisions->mode(2, FL_MENU_INACTIVE);
-    }
-    else if(val <= 7) {
-      if(dlg->choiceDivisions->value() > 1) dlg->choiceDivisions->value(1);
-      dlg->choiceDivisions->mode(1, 0);
-      dlg->choiceDivisions->mode(2, FL_MENU_INACTIVE);
-    }
-    else {
-      dlg->choiceDivisions->mode(1, 0);
-      dlg->choiceDivisions->mode(2, 0);
-    }
-    break;
-  case 1:
-    dlg->choiceMetisAlg->value((val <= 8) ? 0: 1);
-    break;
-  }
-}
-
-// Option considerations for the Chaco spectral algorithm
-void partition_opt_spectralcheck_cb(Fl_Widget *widget, void *data)
-{
-  PartitionDialog *dlg = static_cast<PartitionDialog*>(data);
-  if(dlg->choiceChacoAlg->value() == 1) {
-    if(widget == dlg->choiceDivisions && dlg->choiceDivisions->value() != 0)
-      dlg->checkButtonTermProp->value(0);
-    else if(widget == dlg->checkButtonTermProp)
-      dlg->choiceDivisions->value(0);
-  }
-}
-
-void partition_defaults_cb(Fl_Widget *widget, void *data)
-{
-  PartitionDialog *dlg = static_cast<PartitionDialog*>(data);
-  CTX.mesh.partition_options.setDefaults();
-  dlg->read_all_options();
-  partition_select_groups_cb(dlg->choicePartitioner, data);
-}
-
-void partition_partition_cb(Fl_Widget *widget, void *data)
-{
-  PartitionDialog *dlg = static_cast<PartitionDialog*>(data);
-
-  // Write all options
-  dlg->write_all_options();
-
-  // Partition the mesh
-  int ier = PartitionMesh(GModel::current(), CTX.mesh.partition_options);
-
-  // Update the screen
-  if(!ier) {
-    opt_mesh_zone_definition(0, GMSH_SET, 1.);  // Define zone by partition
-    opt_mesh_color_carousel(0, GMSH_SET | GMSH_GUI, 3.);
-    CTX.mesh.changed = ENT_ALL;
-    Draw();
-  }
-}
-
-void partition_cancel_cb(Fl_Widget *widget, void *data)
-{
-  PartitionDialog *dlg = static_cast<PartitionDialog*>(data);
-  dlg->window->hide();
-  Fl::delete_widget(dlg->window);
-}
-
-// Select groups to display
-void partition_select_groups_cb(Fl_Widget *widget, void *data)
-{
-  PartitionDialog *dlg = static_cast<PartitionDialog*>(data);
-  // If this callback was made by the "Advanced" toggle buttons, set the label
-  if(dlg->toggleButtonAdvChaco == widget) {
-    dlg->toggleButtonAdvChaco->label((dlg->toggleButtonAdvChaco->value()) ?
-                                     "Advanced @-28->" : "Advanced @-22->");
-  }
-  else if(dlg->toggleButtonAdvMetis == widget) {
-    dlg->toggleButtonAdvMetis->label((dlg->toggleButtonAdvMetis->value()) ?
-                                     "Advanced @-28->" : "Advanced @-22->");
-  }
-  const int WB = 7;                     // Window border
-  // Get the groups
-  Fl_Widget *const *g = dlg->window->array();
-  int y = g[0]->h();
-  switch(dlg->choicePartitioner->value()) {
-  case 0:
-    g[1]->show();
-    y += g[1]->h();
-    if(dlg->toggleButtonAdvChaco->value()) {
-      g[2]->show();
-      y += g[2]->h();
-    }
-    else g[2]->hide();
-    g[3]->hide();
-    g[4]->hide();
-    break;
-  case 1:
-    g[3]->show();
-    y += g[3]->h();
-    if(dlg->toggleButtonAdvMetis->value()) {
-      g[4]->show();
-      y += g[4]->h();
-    }
-    else g[4]->hide();
-    g[1]->hide();
-    g[2]->hide();
-    break;
-  }
-  // Reset the vertical position of all widgets in group 6
-  {
-    int yG = y;
-    g[5]->position(g[5]->x(), yG);
-    Fl_Widget *o = static_cast<Fl_Group*>(g[5])->child(0);
-    o->position(o->x(), yG);
-    yG += WB + o->h();
-    o = static_cast<Fl_Group*>(g[5])->child(1);
-    o->position(o->x(), yG);
-    o = static_cast<Fl_Group*>(g[5])->child(2);
-    o->position(o->x(), yG);
-    o = static_cast<Fl_Group*>(g[5])->child(3);
-    o->position(o->x(), yG);
-    yG += WB + o->h();
-  }
-  y += g[5]->h();
-  // Resize and redraw the window
-  dlg->window->size(dlg->window->w(), y);
-  dlg->window->redraw();
-}
-
-void partition_dialog()
-{
-  static PartitionDialog dlg;
-
-  static Fl_Menu_Item partitionTypeMenu[] = {
-    {"Chaco", 0, 0, 0},
-    {"Metis", 0, 0, 0},
-    {0}
-  };
-
-  static Fl_Menu_Item chacoAlgMenu[] = {
-    {"Multilevel-KL", 0, 0, 0},
-    {"Spectral", 0, 0, 0},
-    {"Inertial", 0, 0, 0, FL_MENU_INACTIVE},
-    {"Linear", 0, 0, 0},
-    {"Random", 0, 0, 0},
-    {"Scattered", 0, 0, 0},
-    {0}
-  };
-
-  static Fl_Menu_Item metisAlgMenu[] = {
-    {"Recursive", 0, 0, 0},
-    {"K-way", 0, 0, 0},
-    {0}
-  };
-
-  static Fl_Menu_Item chachoArchitectureMenu[] = {
-    {"Hypercube", 0, 0, 0},
-    {"1-D Mesh", 0, 0, 0},
-    {"2-D Mesh", 0, 0, 0},
-    {"3-D Mesh", 0, 0, 0},
-    {0}
-  };
-
-  static Fl_Menu_Item chachoLocalMethodMenu[] = {
-    {"Kernighan-Lin", 0, 0, 0},
-    {"None", 0, 0, 0},
-    {0}
-  };
-
-  static Fl_Menu_Item chachoEigSolMenu[] = {
-    {"Lanczos", 0, 0, 0},
-    {"Multilevel RQI/Symmlq", 0, 0, 0},
-    {0}
-  };
-
-  static Fl_Menu_Item chachoDivisionsMenu[] = {
-    {"Bisection", 0, 0, 0},
-    {"Quadrisection", 0, 0, 0},
-    {"Octasection", 0, 0, 0},
-    {0}
-  };
-
-  static Fl_Menu_Item metisEdgeMatchingMenu[] = {
-    {"Random", 0, 0, 0},
-    {"Heavy-edge", 0, 0, 0},
-    {"Sorted heavy-edge", 0, 0, 0},
-    {0}
-  };
-
-  static Fl_Menu_Item metisRefineAlgMenu[] = {
-    {"Random", 0, 0, 0},
-    {"Greedy", 0, 0, 0},
-    {"Random (Min. Conn.)", 0, 0, 0},
-    {0}
-  };
-
-  const int IW = 10*GetFontSize();      // Input field width
-  const int BH = 2*GetFontSize() + 1;   // button height
-  const int BB = 7*GetFontSize() + 9;   // Width of a button with an internal
-                                        // label
-  const int WB = 7;                     // Window border
-
-  const int h = 6 * WB + 3 * BH + 4;    // This will be resized based on groups
-                                        // that are displayed
-  const int w = 3 * BB + IW + 3 * WB;   // Window width
-  int y = 0;
-
-  dlg.window = new Dialog_Window(w, h, CTX.non_modal_windows,
-                                 "Partitioner Options");
-  dlg.window->box(GMSH_WINDOW_BOX);
-  dlg.window->callback((Fl_Callback *)partition_cancel_cb, &dlg);
-
-  // Main options group [0]
-  {
-    const int GH = BH + 2 + 3*WB;
-    y += WB;
-    Fl_Group *g = new Fl_Group(0, y, w, GH);
-    // Partitioner
-    {
-      Fl_Choice *const o = new Fl_Choice(WB, y, BB, BH, "Partitioner");
-      dlg.choicePartitioner = o;
-      o->menu(partitionTypeMenu);
-      o->callback((Fl_Callback *)partition_select_groups_cb, &dlg);
-#if !defined(HAVE_CHACO)
-      o->mode(0, FL_MENU_INACTIVE);
-#endif
-#if !defined(HAVE_METIS)
-      o->mode(1, FL_MENU_INACTIVE);
-#endif
-      o->align(FL_ALIGN_RIGHT);
-    }
-    // Number of partitions
-    {
-      Fl_Value_Input *const o = new Fl_Value_Input
-        (2*WB + 2*BB, y, IW, BH, "Number of\nPartitions");
-      dlg.inputNumPartition = o;
-      o->minimum(1);
-      o->maximum(std::numeric_limits<int>::max());
-      o->callback((Fl_Callback *)partition_opt_num_partitions_cb, &dlg);
-      o->step(1);
-      o->align(FL_ALIGN_RIGHT);
-    }
-    y += BH + WB;
-    // Box (line)
-    { Fl_Box* o = new Fl_Box(WB, y, w - 2*WB, 2);
-      o->box(FL_ENGRAVED_FRAME);
-      o->labeltype(FL_NO_LABEL);
-    }
-    y += 2 + WB;
-    g->end();
-    g->show();
-  }
-  const int yMain = y;
-
-  // Chaco options group [1]
-  {
-    const int GH = BH + WB;
-    Fl_Group *g = new Fl_Group(0, y, w, GH);
-    // Algorithm
-    {
-      Fl_Choice *const o = new Fl_Choice(WB, y, IW, BH, "Global Algorithm");
-      dlg.choiceChacoAlg = o;
-      o->menu(chacoAlgMenu);
-      o->callback((Fl_Callback *)partition_opt_chaco_globalalg_cb, &dlg);
-      o->align(FL_ALIGN_RIGHT);
-    }
-    // Advanced Button
-    {
-      Fl_Toggle_Button *const o = new Fl_Toggle_Button
-        (w - (WB + BB), y, BB, BH, "Advanced @-22->");
-      dlg.toggleButtonAdvChaco = o;
-      o->callback((Fl_Callback *)partition_select_groups_cb, &dlg);
-    }
-    y += BH + WB;
-    g->end();
-    g->hide();
-  }
-
-  // Chaco advanced options group [2]
-  {
-    const int GH = 2 + WB + 5*(BH + WB) + BH + 6;
-    Fl_Group *g = new Fl_Group(0, y, w, GH);
-    // Box (line)
-    {
-      Fl_Box *const o = new Fl_Box(WB, y, w - 2*WB, 2);
-      o->box(FL_ENGRAVED_FRAME);
-      o->labeltype(FL_NO_LABEL);
-    }
-    y += 2 + WB + 1;  // +1 for multiline label
-    // Architecture
-    {
-      Fl_Choice *const o = new Fl_Choice(WB, y, BB, BH, "Architecture");
-      dlg.choiceArchitecture = o;
-      o->menu(chachoArchitectureMenu);
-      o->callback((Fl_Callback *)partition_opt_architecture_cb, &dlg);
-      o->align(FL_ALIGN_RIGHT);
-    }
-    // Mesh_dim1
-    {
-      Fl_Value_Input *const o = new Fl_Value_Input
-        (2*WB + 2*BB, y, IW/3, BH);
-      dlg.inputNumPartition1 = o;
-      o->minimum(1);
-      o->maximum(std::numeric_limits<int>::max());
-      o->callback((Fl_Callback *)partition_opt_num_partitions_cb, &dlg);
-      o->step(1);
-    }
-    // Mesh_dim2
-    {
-      Fl_Value_Input *const o = new Fl_Value_Input
-        (2*WB + 2*BB + IW/3, y, IW/3, BH);
-      dlg.inputNumPartition2 = o;
-      o->minimum(1);
-      o->maximum(std::numeric_limits<int>::max());
-      o->callback((Fl_Callback *)partition_opt_num_partitions_cb, &dlg);
-      o->step(1);
-    }
-    // Mesh_dim3
-    {
-      Fl_Value_Input *const o = new Fl_Value_Input
-        (2*WB + 2*BB + 2*IW/3, y, IW/3, BH);
-      dlg.inputNumPartition3 = o;
-      o->minimum(1);
-      o->maximum(std::numeric_limits<int>::max());
-      o->callback((Fl_Callback *)partition_opt_num_partitions_cb, &dlg);
-      o->step(1);
-    }
-    // Label
-    {
-      Fl_Box *const o = new Fl_Box(2*WB + 2*BB + IW, y, 0, BH,
-                                   "Topology\ndimensions");
-      o->align(FL_ALIGN_RIGHT);
-    }
-    y += BH + WB + 2;  // +2 for multiline labels
-    // Divisions
-    {
-      Fl_Choice *const o = new Fl_Choice(WB, y, BB, BH, "Divisions");
-      dlg.choiceDivisions = o;
-      o->copy(chachoDivisionsMenu);
-      o->callback((Fl_Callback *)partition_opt_spectralcheck_cb, &dlg);
-      o->align(FL_ALIGN_RIGHT);
-    }
-    // Vmax
-    {
-      Fl_Value_Input *const o = new Fl_Value_Input
-        (2*WB + 2*BB, y, IW, BH, "Max. vertices in\ncoarse graph");
-      dlg.inputVMax = o;
-      o->minimum(2);
-      o->maximum(std::numeric_limits<double>::max());
-      o->step(1);
-      o->align(FL_ALIGN_RIGHT);
-    }
-    y += BH + WB + 2;  // +2 for multiline labels
-    // Eigensolver
-    {
-      Fl_Choice *const o = new Fl_Choice(WB, y, BB, BH, "Eigensolver");
-      dlg.choiceEigensolver = o;
-      o->menu(chachoEigSolMenu);
-      o->align(FL_ALIGN_RIGHT);
-    }
-    // Eigtol
-    {
-      Fl_Value_Input *const o = new Fl_Value_Input
-        (2*WB + 2*BB, y, IW, BH, "Eigensolver\ntolerance");
-      dlg.inputEigtol = o;
-      o->minimum(std::numeric_limits<double>::min());
-      o->maximum(std::numeric_limits<double>::max());
-      o->step(5.E-3);
-      o->align(FL_ALIGN_RIGHT);
-    }
-    y += BH + WB + 1;  // +1 for multiline label
-    // Local method
-    {
-      Fl_Choice *const o = new Fl_Choice(WB, y, BB, BH, "Local algorithm");
-      dlg.choiceLocalAlgorithm = o;
-      o->menu(chachoLocalMethodMenu);
-      o->align(FL_ALIGN_RIGHT);
-    }
-    // Seed
-    {
-      Fl_Value_Input *const o = new Fl_Value_Input
-        (2*WB + 2*BB, y, IW, BH, "Seed");
-      dlg.inputSeed = o;
-      o->minimum(1);
-      o->maximum(std::numeric_limits<int>::max());
-      o->step(1);
-      o->align(FL_ALIGN_RIGHT);
-    }
-    y += BH + WB;
-    // Parameters
-    {
-      Fl_Check_Button *const o = new Fl_Check_Button(WB, y, 2*WB, BH,
-                                                     "Refine partition");
-      dlg.checkButtonRefPart = o;
-      o->align(FL_ALIGN_RIGHT);
-    }
-    {
-      Fl_Check_Button *const o = new Fl_Check_Button(2*WB + 2*BB, y, 2*WB, BH,
-                                                     "Internal vertices");
-      dlg.checkButtonIntVert = o;
-      o->align(FL_ALIGN_RIGHT);
-    }
-    y += BH;
-    {
-      Fl_Check_Button *const o = new Fl_Check_Button(WB, y, 2*WB, BH,
-                                                     "Refine map");
-      dlg.checkButtonRefMap = o;
-      o->align(FL_ALIGN_RIGHT);
-    }
-    {
-      Fl_Check_Button *const o = new Fl_Check_Button(2*WB + 2*BB, y, 2*WB, BH,
-                                                     "Terminal propogation");
-      dlg.checkButtonTermProp = o;
-      o->callback((Fl_Callback *)partition_opt_spectralcheck_cb, &dlg);
-      o->align(FL_ALIGN_RIGHT);
-    }
-    y += BH + WB;
-    g->end();
-    g->hide();
-  }
-
-  // Metis options group [3]
-  y = yMain;
-  {
-    const int GH = BH + WB;
-    Fl_Group *g = new Fl_Group(0, y, w, GH);
-    // Algorithm
-    {
-      Fl_Choice *const o = new Fl_Choice(WB, y, BB, BH, "Algorithm");
-      dlg.choiceMetisAlg = o;
-      o->menu(metisAlgMenu);
-      o->align(FL_ALIGN_RIGHT);
-    }
-    // Advanced Button
-    {
-      Fl_Toggle_Button *const o = new Fl_Toggle_Button
-        (w - (WB + BB), y, BB, BH, "Advanced @-22->");
-      dlg.toggleButtonAdvMetis = o;
-      o->callback((Fl_Callback *)partition_select_groups_cb, &dlg);
-    }
-    y += BH + WB;
-    g->end();
-    g->hide();
-  }
-
-  // Metis advanced option group [4]
-  {
-    const int GH = 2 + WB + (BH + WB) + 2;
-    Fl_Group *g = new Fl_Group(0, y, w, GH);
-    // Box (line)
-    {
-      Fl_Box *const o = new Fl_Box(WB, y, w - 2*WB, 2);
-      o->box(FL_ENGRAVED_FRAME);
-      o->labeltype(FL_NO_LABEL);
-    }
-    y += 2 + WB + 1;  // +1 for multiline label
-    // Edge matching algorithm
-    {
-      Fl_Choice *const o = new Fl_Choice(WB, y, BB, BH, "Edge matching");
-      dlg.choiceEdgeMatch = o;
-      o->menu(metisEdgeMatchingMenu);
-      o->align(FL_ALIGN_RIGHT);
-    }
-    // Refinement algorithm
-    {
-      Fl_Choice *const o = new Fl_Choice(2*WB + 2*BB, y, BB, BH,
-                                         "Refinement\nalgorithm");
-      dlg.choiceRefineAlg = o;
-      o->menu(metisRefineAlgMenu);
-      o->align(FL_ALIGN_RIGHT);
-    }
-    y += BH + WB + 1;  // +1 for multiline label
-    g->end();
-    g->hide();
-  }
-  
-  // Dialog termination group [5]
-  {
-    const int GH = 2 + BH + 2*WB;
-    Fl_Group *g = new Fl_Group(0, y, w, GH);
-    // Box (line) [0]
-    {
-      Fl_Box *const o = new Fl_Box(WB, y, w - 2*WB, 2);
-      o->box(FL_ENGRAVED_FRAME);
-      o->labeltype(FL_NO_LABEL);
-    }
-    y += 2 + WB;
-    // Defaults Button [1]
-    {
-      Fl_Button *const o = new Fl_Button
-         (WB, y, BB, BH, "Defaults");
-      o->callback((Fl_Callback *)partition_defaults_cb, &dlg);
-    }
-    // Partition Button [2]
-    {
-      Fl_Return_Button *const o = new Fl_Return_Button
-        (w - 2*(WB + BB), y, BB, BH, "Partition");
-      o->callback((Fl_Callback *)partition_partition_cb, &dlg);
-    }
-    // Cancel Button [3]
-    {
-      Fl_Button *const o = new Fl_Button(w - (WB + BB), y, BB, BH, "Cancel");
-      o->callback((Fl_Callback *)partition_cancel_cb, &dlg);
-    }
-    y += BH + WB;
-    g->end();
-    g->show();
-  }
-
-  dlg.window->end();
-  dlg.window->hotspot(dlg.window);
-
-  dlg.read_all_options();
-  // Set the groups to be initally displayed
-  partition_select_groups_cb(dlg.window, &dlg);
-  dlg.window->show();
-}
-
-#endif  // compiling partition dialog
diff --git a/Fltk/GUI_Extras.h b/Fltk/fileDialogs.h
similarity index 85%
rename from Fltk/GUI_Extras.h
rename to Fltk/fileDialogs.h
index 1cec1ab425a425fd54f97a9646ba96f0f819ff4c..a463c6ef44b7bd7633ad1433c6386905862faa02 100644
--- a/Fltk/GUI_Extras.h
+++ b/Fltk/fileDialogs.h
@@ -3,8 +3,8 @@
 // See the LICENSE.txt file for license information. Please report all
 // bugs and problems to <gmsh@geuz.org>.
 
-#ifndef _GUI_EXTRAS_H_
-#define _GUI_EXTRAS_H_
+#ifndef _FILE_DIALOGS_H_
+#define _FILE_DIALOGS_H_
 
 #include <string>
 
@@ -14,10 +14,6 @@ std::string file_chooser_get_name(int num);
 int file_chooser_get_filter();
 void file_chooser_get_position(int *x, int *y);
 
-int arrow_editor(const char *title, double &a, double &b, double &c);
-int perspective_editor();
-int model_chooser();
-
 int jpeg_dialog(const char *filename);
 int gif_dialog(const char *filename);
 int geo_dialog(const char *filename);
@@ -32,7 +28,5 @@ int unv_dialog(const char *filename);
 int bdf_dialog(const char *filename);
 int latex_dialog(const char *filename);
 int cgns_write_dialog(const char *filename);
-void partition_dialog();
 
 #endif
-
diff --git a/Fltk/graphicWindow.cpp b/Fltk/graphicWindow.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ee56a7cfefb50f42f377de5c5f853943131c4b18
--- /dev/null
+++ b/Fltk/graphicWindow.cpp
@@ -0,0 +1,263 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+
+#include <FL/fl_draw.H>
+#include "graphicWindow.h"
+#include "shortcutWindow.h"
+#include "PView.h"
+#include "PViewData.h"
+#include "Callbacks.h"
+#include "Context.h"
+
+extern Context_T CTX;
+
+// This dummy box class permits to define a box widget that will not
+// eat the FL_ENTER/FL_LEAVE events (the new Box widget in fltk > 1.1
+// does that, so that gl->handle() was not called when the mouse
+// moved)
+class dummyBox : public Fl_Box {
+ private:
+  int handle(int){ return 0; } // always!
+ public:
+  dummyBox(int x, int y, int w, int h, const char *l=0) : Fl_Box(x, y, w, h, l) {}
+};
+
+// Icons for the satus bar
+#define vv(x,y) fl_vertex(x,y)
+#define bl fl_begin_loop()
+#define el fl_end_loop()
+
+static void gmsh_play(Fl_Color c)
+{
+  fl_color(c);
+  bl; vv(-0.3,0.8); vv(0.5,0.0); vv(-0.3,-0.8); el;
+}
+
+static void gmsh_pause(Fl_Color c)
+{
+  fl_color(c);
+  bl; vv(-0.8,-0.8); vv(-0.3,-0.8); vv(-0.3,0.8); vv(-0.8,0.8); el;
+  bl; vv(0.0,-0.8); vv(0.5,-0.8); vv(0.5,0.8); vv(0.0,0.8); el;
+}
+
+static void gmsh_rewind(Fl_Color c)
+{
+  fl_color(c);
+  bl; vv(-0.8,-0.8); vv(-0.3,-0.8); vv(-0.3,0.8); vv(-0.8,0.8); el;
+  bl; vv(-0.3,0.0); vv(0.5,-0.8); vv(0.5,0.8); el;
+}
+
+static void gmsh_forward(Fl_Color c)
+{
+  fl_color(c);
+  bl; vv(0.0,0.8); vv(0.8,0.0); vv(0.0,-0.8); el;
+  bl; vv(-0.8,0.8); vv(-0.3,0.8); vv(-0.3,-0.8); vv(-0.8,-0.8); el;
+}
+
+static void gmsh_back(Fl_Color c)
+{
+  fl_rotate(180);  
+  gmsh_forward(c);
+}
+
+static void gmsh_ortho(Fl_Color c)
+{
+  fl_color(c);
+  bl; vv(-0.8,0.8); vv(0.3,0.8); vv(0.3,-0.3); vv(-0.8,-0.3); el;
+  bl; vv(-0.3,0.3); vv(0.8,0.3); vv(0.8,-0.8); vv(-0.3,-0.8); el;
+  fl_begin_line(); vv(-0.8,0.8); vv(-0.3,0.3); fl_end_line();
+  fl_begin_line(); vv(0.3,0.8); vv(0.8,0.3); fl_end_line();
+  fl_begin_line(); vv(0.3,-0.3); vv(0.8,-0.8); fl_end_line();
+  fl_begin_line(); vv(-0.8,-0.3); vv(-0.3,-0.8); fl_end_line();
+}
+
+static void gmsh_rotate(Fl_Color c)
+{
+  fl_color(c);
+  fl_begin_line(); fl_arc(0.0, -0.1, 0.7, 0.0, 270.0); fl_end_line();
+  fl_begin_polygon(); vv(0.5,0.6); vv(-0.1,0.9); vv(-0.1,0.3); fl_end_polygon();
+}
+
+static void gmsh_models(Fl_Color c)
+{
+  fl_color(c);
+  bl; vv(-0.8,-0.8); vv(-0.3,-0.8); vv(-0.3,-0.3); vv(-0.8,-0.3); el;
+  bl; vv(0.3,-0.8); vv(0.8,-0.8); vv(0.8,-0.3); vv(0.3,-0.3); el;
+  bl; vv(-0.8,0.3); vv(-0.3,0.3); vv(-0.3,0.8); vv(-0.8,0.8); el;
+  bl; vv(0.3,0.3); vv(0.8,0.3); vv(0.8,0.8); vv(0.3,0.8); el;
+}
+
+#undef vv
+#undef bl
+#undef el
+
+graphicWindow::graphicWindow(int fontsize)
+{
+  static bool first = true;
+  if(first){
+    fl_add_symbol("gmsh_rewind", gmsh_rewind, 1);
+    fl_add_symbol("gmsh_back", gmsh_back, 1);
+    fl_add_symbol("gmsh_play", gmsh_play, 1);
+    fl_add_symbol("gmsh_pause", gmsh_pause, 1);
+    fl_add_symbol("gmsh_forward", gmsh_forward, 1);
+    fl_add_symbol("gmsh_ortho", gmsh_ortho, 1);
+    fl_add_symbol("gmsh_rotate", gmsh_rotate, 1);
+    fl_add_symbol("gmsh_models", gmsh_models, 1);
+    first = false;
+  }
+  
+  int sh = 2 * fontsize - 4; // status bar height
+  int sw = fontsize + 3; // status button width
+  int width = CTX.tmp_viewport[2] - CTX.tmp_viewport[0];
+  int glheight = CTX.tmp_viewport[3] - CTX.tmp_viewport[1];
+  int height = glheight + sh;
+  
+  // the graphic window is a "main" window: it should be a normal
+  // window (neither modal nor non-modal)
+  win = new mainWindow(width, height, false);
+  win->callback(file_quit_cb);
+  
+  // bottom button bar
+  Fl_Box *bottom = new Fl_Box(0, glheight, width, sh);
+  bottom->box(FL_FLAT_BOX);
+  
+  int x = 2;
+  int sht = sh - 4; // leave a 2 pixel border at the bottom
+  
+  butt[5] = new Fl_Button(x, glheight + 2, sw, sht, "@-1gmsh_models");
+  x += sw;
+  butt[5]->callback(status_xyz1p_cb, (void *)"model");
+  butt[5]->tooltip("Change current model");
+  
+  butt[0] = new Fl_Button(x, glheight + 2, sw, sht, "X");
+  x += sw;
+  butt[0]->callback(status_xyz1p_cb, (void *)"x");
+  butt[0]->tooltip("Set +X or -X view (Alt+x or Alt+Shift+x)");
+  
+  butt[1] = new Fl_Button(x, glheight + 2, sw, sht, "Y");
+  x += sw;
+  butt[1]->callback(status_xyz1p_cb, (void *)"y");
+  butt[1]->tooltip("Set +Y or -Y view (Alt+y or Alt+Shift+y)");
+  
+  butt[2] = new Fl_Button(x, glheight + 2, sw, sht, "Z");
+  x += sw;
+  butt[2]->callback(status_xyz1p_cb, (void *)"z");
+  butt[2]->tooltip("Set +Z or -Z view (Alt+z or Alt+Shift+z)");
+  
+  butt[4] = new Fl_Button(x, glheight + 2, sw, sht, "@-1gmsh_rotate");
+  x += sw;
+  butt[4]->callback(status_xyz1p_cb, (void *)"r");
+  butt[4]->tooltip("Rotate +90 or -90 degrees");
+  
+  butt[3] = new Fl_Button(x, glheight + 2, 2 * fontsize, sht, "1:1");
+  x += 2 * fontsize;
+  butt[3]->callback(status_xyz1p_cb, (void *)"1:1");
+  butt[3]->tooltip("Set unit scale");
+  
+  butt[8] = new Fl_Button(x, glheight + 2, sw, sht, "@-1gmsh_ortho");
+  x += sw;
+  butt[8]->callback(status_xyz1p_cb, (void *)"p");
+  butt[8]->tooltip("Toggle projection mode (Alt+o or Alt+Shift+o)");
+  
+  butt[9] = new Fl_Button(x, glheight + 2, sw, sht, "S");
+  x += sw;
+  butt[9]->callback(status_xyz1p_cb, (void *)"S");
+  butt[9]->tooltip("Toggle mouse selection ON/OFF (Escape)");
+  
+  butt[6] = new Fl_Button(x, glheight + 2, sw, sht, "@-1gmsh_rewind");
+  x += sw;
+  butt[6]->callback(status_rewind_cb);
+  butt[6]->tooltip("Rewind animation");
+  butt[6]->deactivate();
+  
+  butt[10] = new Fl_Button(x, glheight + 2, sw, sht, "@-1gmsh_back");
+  x += sw;
+  butt[10]->callback(status_stepbackward_cb);
+  butt[10]->tooltip("Step backward");
+  butt[10]->deactivate();
+  
+  butt[7] = new Fl_Button(x, glheight + 2, sw, sht, "@-1gmsh_play");
+  x += sw;
+  butt[7]->callback(status_play_cb);
+  butt[7]->tooltip("Play/pause animation");
+  butt[7]->deactivate();
+  
+  butt[11] = new Fl_Button(x, glheight + 2, sw, sht, "@-1gmsh_forward");
+  x += sw;
+  butt[11]->callback(status_stepforward_cb);
+  butt[11]->tooltip("Step forward");
+  butt[11]->deactivate();
+  
+  for(int i = 0; i < 12; i++) {
+    butt[i]->box(FL_FLAT_BOX);
+    butt[i]->selection_color(FL_WHITE);
+    butt[i]->align(FL_ALIGN_CENTER | FL_ALIGN_INSIDE | FL_ALIGN_CLIP);
+  }
+  
+  x += 2;
+  int wleft = (width - x) / 3 - 1;
+  int wright = (width - x) - (width - x) / 3 - 1;
+  
+  label[0] = new Fl_Box(x, glheight + 2, wleft, sht);
+  label[1] = new Fl_Box(x + (width - x) / 3, glheight + 2, wright, sht);
+  for(int i = 0; i < 2; i++) {
+    label[i]->box(FL_THIN_DOWN_BOX);
+    label[i]->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE | FL_ALIGN_CLIP);
+  }
+  
+  // dummy resizable box
+  dummyBox *resbox = new dummyBox(x, 0, width - x, glheight);
+  win->resizable(resbox);
+  
+  // opengl window
+  gl = new openglWindow(0, 0, width, glheight);
+  int mode = FL_RGB | FL_DEPTH | (CTX.db ? FL_DOUBLE : FL_SINGLE);
+  if(CTX.antialiasing) mode |= FL_MULTISAMPLE;
+  gl->mode(mode);
+  gl->end();
+  
+  win->position(CTX.gl_position[0], CTX.gl_position[1]);
+  win->end();
+}
+
+void graphicWindow::setAnimButtons(int mode)
+{
+  if(mode) {
+    butt[7]->callback(status_play_cb);
+    butt[7]->label("@-1gmsh_play");
+  }
+  else {
+    butt[7]->callback(status_pause_cb);
+    butt[7]->label("@-1gmsh_pause");
+  }
+}
+
+void graphicWindow::checkAnimButtons()
+{
+  bool play = false;
+  if(CTX.post.anim_cycle){
+    play = true;
+  }
+  else{
+    for(unsigned int i = 0; i < PView::list.size(); i++){
+      if(PView::list[i]->getData()->getNumTimeSteps() > 1){
+        play = true;
+        break;
+      }
+    }
+  }
+  if(play){
+    butt[6]->activate();
+    butt[7]->activate();
+    butt[10]->activate();
+    butt[11]->activate();
+  }
+  else{
+    butt[6]->deactivate();
+    butt[7]->deactivate();
+    butt[10]->deactivate();
+    butt[11]->deactivate();
+  }
+}
diff --git a/Fltk/graphicWindow.h b/Fltk/graphicWindow.h
new file mode 100644
index 0000000000000000000000000000000000000000..0610cfa0f7524b95a94250c4bda53b849426502f
--- /dev/null
+++ b/Fltk/graphicWindow.h
@@ -0,0 +1,26 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+
+#ifndef _GRAPHIC_WINDOW_H_
+#define _GRAPHIC_WINDOW_H_
+
+#include <FL/Fl_Window.H>
+#include <FL/Fl_Button.H>
+#include <FL/Fl_Box.H>
+#include "openglWindow.h"
+
+class graphicWindow{
+ public:
+  Fl_Window *win;
+  openglWindow *gl;
+  Fl_Button *butt[12];
+  Fl_Box *label[2];
+ public:
+  graphicWindow(int fontsize);
+  void setAnimButtons(int mode);
+  void checkAnimButtons();
+};
+
+#endif
diff --git a/Fltk/manipWindow.cpp b/Fltk/manipWindow.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c83feddb27b011404b04bf3404aaf034b9571b88
--- /dev/null
+++ b/Fltk/manipWindow.cpp
@@ -0,0 +1,121 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+
+#include <FL/Fl_Box.H>
+#include <FL/Fl_Return_Button.H>
+#include "GUI.h"
+#include "manipWindow.h"
+#include "shortcutWindow.h"
+#include "Callbacks.h"
+#include "Options.h"
+#include "Context.h"
+
+extern Context_T CTX;
+
+manipWindow::manipWindow(int fontsize)
+  : _fontsize(fontsize)
+{
+
+  int width = 4 * BB + 2 * WB;
+  int height = 5 * BH + 3 * WB;
+
+  win = new dialogWindow(width, height, CTX.non_modal_windows, "Manipulator");
+  win->box(GMSH_WINDOW_BOX);
+
+  Fl_Box *top[3], *left[3];
+  top[0] = new Fl_Box(WB + 1 * BB, 1 * WB + 0 * BH, BB, BH, "X");
+  top[1] = new Fl_Box(WB + 2 * BB, 1 * WB + 0 * BH, BB, BH, "Y");
+  top[2] = new Fl_Box(WB + 3 * BB, 1 * WB + 0 * BH, BB, BH, "Z");
+  left[0] = new Fl_Box(WB + 0 * BB, 1 * WB + 1 * BH, BB, BH, "Rotation");
+  left[1] = new Fl_Box(WB + 0 * BB, 1 * WB + 2 * BH, BB, BH, "Translation");
+  left[2] = new Fl_Box(WB + 0 * BB, 1 * WB + 3 * BH, BB, BH, "Scale");
+  for(int i = 0; i < 3; i++){  
+    top[i]->align(FL_ALIGN_INSIDE|FL_ALIGN_CENTER);
+    left[i]->align(FL_ALIGN_INSIDE|FL_ALIGN_CENTER);
+  }
+
+  value[0] = new Fl_Value_Input(WB + 1 * BB, 1 * WB + 1 * BH, BB, BH);
+  value[1] = new Fl_Value_Input(WB + 2 * BB, 1 * WB + 1 * BH, BB, BH);
+  value[2] = new Fl_Value_Input(WB + 3 * BB, 1 * WB + 1 * BH, BB, BH);
+  value[3] = new Fl_Value_Input(WB + 1 * BB, 1 * WB + 2 * BH, BB, BH);
+  value[4] = new Fl_Value_Input(WB + 2 * BB, 1 * WB + 2 * BH, BB, BH);
+  value[5] = new Fl_Value_Input(WB + 3 * BB, 1 * WB + 2 * BH, BB, BH);
+  value[6] = new Fl_Value_Input(WB + 1 * BB, 1 * WB + 3 * BH, BB, BH);
+  value[7] = new Fl_Value_Input(WB + 2 * BB, 1 * WB + 3 * BH, BB, BH);
+  value[8] = new Fl_Value_Input(WB + 3 * BB, 1 * WB + 3 * BH, BB, BH);
+
+  for(int i = 0; i < 9; i++){
+    if(i < 3){
+      value[i]->minimum(0.);
+      value[i]->maximum(360.);
+      value[i]->step(1.);
+    }
+    else if(i > 5){
+      value[i]->minimum(0.1);
+      value[i]->maximum(100.);
+      value[i]->step(0.1);
+    }
+    value[i]->align(FL_ALIGN_RIGHT);
+    value[i]->callback(manip_update_cb);
+  }
+
+  {
+    Fl_Return_Button *o = new Fl_Return_Button
+      (width - 2 * BB - 2 * WB, height - BH - WB, BB, BH, "Reset");
+    o->callback(status_xyz1p_cb, (void *)"reset");
+  }
+  {
+    Fl_Button *o = new Fl_Button
+      (width - BB - WB, height - BH - WB, BB, BH, "Cancel");
+    o->callback(cancel_cb, (void *)win);
+  }
+
+  win->position(CTX.manip_position[0], CTX.manip_position[1]);
+  win->end();
+}
+
+void manipWindow::update(bool force)
+{
+  if(force || win->shown()){
+    double val1 = CTX.lc;
+    
+    double r0 = opt_general_rotation0(0, GMSH_GET, 0);
+    double r1 = opt_general_rotation1(0, GMSH_GET, 0);
+    double r2 = opt_general_rotation2(0, GMSH_GET, 0);
+    double t0 = opt_general_translation0(0, GMSH_GET, 0);
+    double t1 = opt_general_translation1(0, GMSH_GET, 0);
+    double t2 = opt_general_translation2(0, GMSH_GET, 0);
+    double s0 = opt_general_scale0(0, GMSH_GET, 0);
+    double s1 = opt_general_scale1(0, GMSH_GET, 0);
+    double s2 = opt_general_scale2(0, GMSH_GET, 0);
+
+    value[0]->value(r0);
+    value[1]->value(r1);
+    value[2]->value(r2);
+    value[3]->value(t0);
+    value[4]->value(t1);
+    value[5]->value(t2);
+    value[6]->value(s0);
+    value[7]->value(s1);
+    value[8]->value(s2);
+    for(int i = 0; i < 3; i++){
+      value[i]->minimum(-360.);
+      value[i]->maximum(360.);
+      value[i]->step(1.);
+      value[i+3]->minimum(-val1);
+      value[i+3]->maximum(val1);
+      value[i+3]->step(val1/200.);
+      value[i+6]->minimum(0.01);
+      value[i+6]->maximum(100.);
+      value[i+6]->step(0.01);
+    }
+  }
+}
+
+void manipWindow::show()
+{
+  update(true);
+  win->show();
+}
diff --git a/Fltk/manipWindow.h b/Fltk/manipWindow.h
new file mode 100644
index 0000000000000000000000000000000000000000..043923bae73df90302d1e850e0d453529a779de6
--- /dev/null
+++ b/Fltk/manipWindow.h
@@ -0,0 +1,24 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+
+#ifndef _MANIP_WINDOW_H_
+#define _MANIP_WINDOW_H_
+
+#include <FL/Fl_Window.H>
+#include <FL/Fl_Value_Input.H>
+
+class manipWindow{
+ private:
+  int _fontsize;
+ public:
+  Fl_Window *win;
+  Fl_Value_Input *value[9];
+ public:
+  manipWindow(int fontsize);
+  void update(bool force=false);
+  void show();
+};
+
+#endif
diff --git a/Fltk/menuWindow.cpp b/Fltk/menuWindow.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2e9bf4f05a69857cdac9a5740f7500f88fb6057b
--- /dev/null
+++ b/Fltk/menuWindow.cpp
@@ -0,0 +1,634 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+
+#include <string.h>
+#include <FL/Fl_Box.H>
+#include "GUI.h"
+#include "menuWindow.h"
+#include "shortcutWindow.h"
+#include "Callbacks.h"
+#include "Options.h"
+#include "Solvers.h"
+#include "GmshMessage.h"
+#include "PView.h"
+#include "PViewData.h"
+#include "PViewOptions.h"
+#include "Context.h"
+
+extern Context_T CTX;
+
+// The static menus (we cannot use the 'g', 'm' 's' and 'p' mnemonics
+// since they are already defined as global shortcuts)
+static Fl_Menu_Item bar_table[] = {
+  {"&File", 0, 0, 0, FL_SUBMENU},
+    {"&New...",     FL_CTRL+'n', (Fl_Callback *)file_new_cb, 0},
+    {"&Open...",    FL_CTRL+'o', (Fl_Callback *)file_open_cb, 0},
+    {"M&erge...",   FL_CTRL+FL_SHIFT+'o', (Fl_Callback *)file_merge_cb, 0, FL_MENU_DIVIDER},
+    {"&Rename...",  FL_CTRL+'r', (Fl_Callback *)file_rename_cb, 0},
+    {"Save &As...", FL_CTRL+'s', (Fl_Callback *)file_save_as_cb, 0},
+    {"Sa&ve Mesh",  FL_CTRL+FL_SHIFT+'s', (Fl_Callback *)mesh_save_cb, 0, FL_MENU_DIVIDER},
+    {"&Quit",       FL_CTRL+'q', (Fl_Callback *)file_quit_cb, 0},
+    {0},
+  {"&Tools", 0, 0, 0, FL_SUBMENU},
+    {"&Options...",      FL_CTRL+FL_SHIFT+'n', (Fl_Callback *)options_cb, 0},
+    {"Pl&ugins...",      FL_CTRL+FL_SHIFT+'u', (Fl_Callback *)view_plugin_cb, (void*)(-1)},
+    {"&Visibility",      FL_CTRL+FL_SHIFT+'v', (Fl_Callback *)visibility_cb, 0},
+    {"&Clipping",        FL_CTRL+FL_SHIFT+'c', (Fl_Callback *)clip_cb, 0},
+    {"&Manipulator",     FL_CTRL+FL_SHIFT+'m', (Fl_Callback *)manip_cb, 0, FL_MENU_DIVIDER},
+    {"S&tatistics",      FL_CTRL+'i', (Fl_Callback *)statistics_cb, 0},
+    {"M&essage Console", FL_CTRL+'l', (Fl_Callback *)message_cb, 0},
+    {0},
+  {"&Help", 0, 0, 0, FL_SUBMENU},
+    {"On&line Documentation", 0, (Fl_Callback *)help_online_cb, 0, FL_MENU_DIVIDER},
+    {"M&ouse Actions",        0, (Fl_Callback *)help_mouse_cb, 0},
+    {"&Keyboard Shortcuts",   0, (Fl_Callback *)help_short_cb, 0},
+    {"C&ommand Line Options", 0, (Fl_Callback *)help_command_line_cb, 0},
+    {"&Current Options",      0, (Fl_Callback *)status_xyz1p_cb, (void*)"?", FL_MENU_DIVIDER},
+    {"&About Gmsh...",        0, (Fl_Callback *)help_about_cb, 0},
+    {0},
+  {0}
+};
+
+#if defined(__APPLE__)
+
+#if (FL_MAJOR_VERSION == 1) && (FL_MINOR_VERSION == 1) && (FL_PATCH_VERSION <= 6)
+#undef FL_META
+#define FL_META FL_CTRL
+#endif
+
+// Alternative items for the MacOS system menu bar (removed '&'
+// shortcuts: they would cause spurious menu items to appear on the
+// menu window; removed File->Quit)
+static Fl_Menu_Item sysbar_table[] = {
+  {"File", 0, 0, 0, FL_SUBMENU},
+    {"New...",     FL_META+'n', (Fl_Callback *)file_new_cb, 0},
+    {"Open...",    FL_META+'o', (Fl_Callback *)file_open_cb, 0},
+    {"Merge...",   FL_META+FL_SHIFT+'o', (Fl_Callback *)file_merge_cb, 0, FL_MENU_DIVIDER},
+    {"Rename...",  FL_META+'r', (Fl_Callback *)file_rename_cb, 0},
+    {"Save As...", FL_META+'s', (Fl_Callback *)file_save_as_cb, 0},
+    {"Save Mesh",  FL_META+FL_SHIFT+'s', (Fl_Callback *)mesh_save_cb, 0},
+    {0},
+  {"Tools", 0, 0, 0, FL_SUBMENU},
+    {"Options...",      FL_META+FL_SHIFT+'n', (Fl_Callback *)options_cb, 0},
+    {"Plugins...",      FL_META+FL_SHIFT+'u', (Fl_Callback *)view_plugin_cb, (void*)(-1)},
+    {"Visibility",      FL_META+FL_SHIFT+'v', (Fl_Callback *)visibility_cb, 0},
+    {"Clipping",        FL_META+FL_SHIFT+'c', (Fl_Callback *)clip_cb, 0},
+    {"Manipulator",     FL_META+FL_SHIFT+'m', (Fl_Callback *)manip_cb, 0, FL_MENU_DIVIDER},
+    {"Statistics",      FL_META+'i', (Fl_Callback *)statistics_cb, 0},
+    {"Message Console", FL_META+'l', (Fl_Callback *)message_cb, 0},
+    {0},
+  {"Window", 0, 0, 0, FL_SUBMENU},
+    {"Minimize",           FL_META+'m', (Fl_Callback *)window_cb, (void*)"minimize"},
+    {"Zoom",               0, (Fl_Callback *)window_cb, (void*)"zoom", FL_MENU_DIVIDER},
+    {"Bring All to Front", 0, (Fl_Callback *)window_cb, (void*)"front"},
+    {0},
+  {"Help", 0, 0, 0, FL_SUBMENU},
+    {"Online Documentation", 0, (Fl_Callback *)help_online_cb, 0, FL_MENU_DIVIDER},
+    {"Mouse Actions",        0, (Fl_Callback *)help_mouse_cb, 0},
+    {"Keyboard Shortcuts",   0, (Fl_Callback *)help_short_cb, 0},
+    {"Command Line Options", 0, (Fl_Callback *)help_command_line_cb, 0},
+    {"Current Options",      0, (Fl_Callback *)status_xyz1p_cb, (void*)"?", FL_MENU_DIVIDER},
+    {"About Gmsh...",        0, (Fl_Callback *)help_about_cb, 0},
+    {0},
+  {0}
+};
+
+#endif
+
+static Fl_Menu_Item module_table[] = {
+  {"Geometry",        'g', (Fl_Callback *)mod_geometry_cb, 0},
+  {"Mesh",            'm', (Fl_Callback *)mod_mesh_cb, 0},
+  {"Solver",          's', (Fl_Callback *)mod_solver_cb, 0},
+  {"Post-processing", 'p', (Fl_Callback *)mod_post_cb, 0},
+  {0}
+};
+
+// Dynamic menus contexts
+contextItem menu_geometry[] = {
+  {"0Geometry", NULL} ,
+  {"Elementary entities", (Fl_Callback *)geometry_elementary_cb} ,
+  {"Physical groups",     (Fl_Callback *)geometry_physical_cb} ,
+  {"Edit",                (Fl_Callback *)geometry_edit_cb} , 
+  {"Reload",              (Fl_Callback *)geometry_reload_cb} , 
+  {0}
+};  
+  contextItem menu_geometry_elementary[] = {
+    {"0Geometry>Elementary", NULL} ,
+    {"Add",       (Fl_Callback *)geometry_elementary_add_cb} ,
+    {"Delete",    (Fl_Callback *)geometry_elementary_delete_cb, (void*)0} ,
+    {"Translate", (Fl_Callback *)geometry_elementary_translate_cb, (void*)0} ,
+    {"Rotate",    (Fl_Callback *)geometry_elementary_rotate_cb, (void*)0} ,
+    {"Split",     (Fl_Callback *)geometry_elementary_split_cb, (void*)0} ,
+    {"Scale",     (Fl_Callback *)geometry_elementary_scale_cb, (void*)0} ,
+    {"Symmetry",  (Fl_Callback *)geometry_elementary_symmetry_cb, (void*)0} ,
+    {"Extrude",   (Fl_Callback *)geometry_elementary_extrude_cb, (void*)0} ,
+    {"Coherence", (Fl_Callback *)geometry_elementary_coherence_cb} ,
+    {0} 
+  };  
+    contextItem menu_geometry_elementary_add[] = {
+      {"0Geometry>Elementary>Add", NULL} ,
+      {"New",       (Fl_Callback *)geometry_elementary_add_new_cb, (void*)0} ,
+      {"Translate", (Fl_Callback *)geometry_elementary_add_translate_cb, (void*)0} ,
+      {"Rotate",    (Fl_Callback *)geometry_elementary_add_rotate_cb, (void*)0} ,
+      {"Scale",     (Fl_Callback *)geometry_elementary_add_scale_cb, (void*)0} ,
+      {"Symmetry",  (Fl_Callback *)geometry_elementary_add_symmetry_cb, (void*)0} ,
+      {0} 
+    };  
+      contextItem menu_geometry_elementary_add_new[] = {
+        {"0Geometry>Elementary>Add>New", NULL} ,
+        {"Parameter",     (Fl_Callback *)geometry_elementary_add_new_cb, (void*)"Parameter"} ,
+        {"Point",         (Fl_Callback *)geometry_elementary_add_new_cb, (void*)"Point"} ,
+        {"Straight line", (Fl_Callback *)geometry_elementary_add_new_cb, (void*)"Line"} ,
+        {"Spline",        (Fl_Callback *)geometry_elementary_add_new_cb, (void*)"Spline"} ,
+        {"B-Spline",      (Fl_Callback *)geometry_elementary_add_new_cb, (void*)"BSpline"} ,
+        {"Circle arc",    (Fl_Callback *)geometry_elementary_add_new_cb, (void*)"Circle"} ,
+        {"Ellipse arc",   (Fl_Callback *)geometry_elementary_add_new_cb, (void*)"Ellipse"} ,
+        {"Plane surface", (Fl_Callback *)geometry_elementary_add_new_cb, (void*)"Plane Surface"} ,
+        {"Ruled surface", (Fl_Callback *)geometry_elementary_add_new_cb, (void*)"Ruled Surface"} ,
+        {"Volume",        (Fl_Callback *)geometry_elementary_add_new_cb, (void*)"Volume"} ,
+        {0} 
+      };  
+      contextItem menu_geometry_elementary_add_translate[] = {
+        {"0Geometry>Elementary>Add>Translate", NULL} ,
+        {"Point",   (Fl_Callback *)geometry_elementary_add_translate_cb, (void*)"Point"} ,  
+        {"Line",    (Fl_Callback *)geometry_elementary_add_translate_cb, (void*)"Line"} ,	  
+        {"Surface", (Fl_Callback *)geometry_elementary_add_translate_cb, (void*)"Surface"} ,
+        {"Volume",  (Fl_Callback *)geometry_elementary_add_translate_cb, (void*)"Volume"} , 
+        {0} 
+      };  
+      contextItem menu_geometry_elementary_add_rotate[] = {
+        {"0Geometry>Elementary>Add>Rotate", NULL} ,
+        {"Point",   (Fl_Callback *)geometry_elementary_add_rotate_cb, (void*)"Point"} ,  
+        {"Line",    (Fl_Callback *)geometry_elementary_add_rotate_cb, (void*)"Line"} ,	  
+        {"Surface", (Fl_Callback *)geometry_elementary_add_rotate_cb, (void*)"Surface"} ,
+        {"Volume",  (Fl_Callback *)geometry_elementary_add_rotate_cb, (void*)"Volume"} , 
+        {0} 
+      };  
+      contextItem menu_geometry_elementary_add_scale[] = {
+        {"0Geometry>Elementary>Add>Scale", NULL} ,
+        {"Point",   (Fl_Callback *)geometry_elementary_add_scale_cb, (void*)"Point"} ,  
+        {"Line",    (Fl_Callback *)geometry_elementary_add_scale_cb, (void*)"Line"} ,	  
+        {"Surface", (Fl_Callback *)geometry_elementary_add_scale_cb, (void*)"Surface"} ,
+        {"Volume",  (Fl_Callback *)geometry_elementary_add_scale_cb, (void*)"Volume"} , 
+        {0} 
+      };  
+      contextItem menu_geometry_elementary_add_symmetry[] = {
+        {"0Geometry>Elementary>Add>Symmetry", NULL} ,
+        {"Point",   (Fl_Callback *)geometry_elementary_add_symmetry_cb, (void*)"Point"} ,  
+        {"Line",    (Fl_Callback *)geometry_elementary_add_symmetry_cb, (void*)"Line"} ,	  
+        {"Surface", (Fl_Callback *)geometry_elementary_add_symmetry_cb, (void*)"Surface"} ,
+        {"Volume",  (Fl_Callback *)geometry_elementary_add_symmetry_cb, (void*)"Volume"} , 
+        {0} 
+      };  
+    contextItem menu_geometry_elementary_delete[] = {
+      {"0Geometry>Elementary>Delete", NULL} ,
+      {"Point",   (Fl_Callback *)geometry_elementary_delete_cb, (void*)"Point"} ,
+      {"Line",    (Fl_Callback *)geometry_elementary_delete_cb, (void*)"Line"} ,
+      {"Surface", (Fl_Callback *)geometry_elementary_delete_cb, (void*)"Surface"} ,
+      {"Volume",  (Fl_Callback *)geometry_elementary_delete_cb, (void*)"Volume"} ,
+      {0} 
+    };  
+    contextItem menu_geometry_elementary_split[] = {
+      {"0Geometry>Elementary>Split",NULL},
+        {"Line",(Fl_Callback *)geometry_elementary_split_cb,(void*)"Line"},
+        {0}
+    };
+    contextItem menu_geometry_elementary_translate[] = {
+      {"0Geometry>Elementary>Translate", NULL} ,
+      {"Point",   (Fl_Callback *)geometry_elementary_translate_cb, (void*)"Point"} ,  
+      {"Line",    (Fl_Callback *)geometry_elementary_translate_cb, (void*)"Line"} ,	  
+      {"Surface", (Fl_Callback *)geometry_elementary_translate_cb, (void*)"Surface"} ,
+      {"Volume",  (Fl_Callback *)geometry_elementary_translate_cb, (void*)"Volume"} , 
+      {0} 
+    };  
+    contextItem menu_geometry_elementary_rotate[] = {
+      {"0Geometry>Elementary>Rotate", NULL} ,
+      {"Point",   (Fl_Callback *)geometry_elementary_rotate_cb, (void*)"Point"} ,  
+      {"Line",    (Fl_Callback *)geometry_elementary_rotate_cb, (void*)"Line"} ,	  
+      {"Surface", (Fl_Callback *)geometry_elementary_rotate_cb, (void*)"Surface"} ,
+      {"Volume",  (Fl_Callback *)geometry_elementary_rotate_cb, (void*)"Volume"} , 
+      {0} 
+    };  
+    contextItem menu_geometry_elementary_scale[] = {
+      {"0Geometry>Elementary>Scale", NULL} ,
+      {"Point",   (Fl_Callback *)geometry_elementary_scale_cb, (void*)"Point"} ,  
+      {"Line",    (Fl_Callback *)geometry_elementary_scale_cb, (void*)"Line"} ,	  
+      {"Surface", (Fl_Callback *)geometry_elementary_scale_cb, (void*)"Surface"} ,
+      {"Volume",  (Fl_Callback *)geometry_elementary_scale_cb, (void*)"Volume"} , 
+      {0} 
+    };  
+    contextItem menu_geometry_elementary_symmetry[] = {
+      {"0Geometry>Elementary>Symmetry", NULL} ,
+      {"Point",   (Fl_Callback *)geometry_elementary_symmetry_cb, (void*)"Point"} ,  
+      {"Line",    (Fl_Callback *)geometry_elementary_symmetry_cb, (void*)"Line"} ,	  
+      {"Surface", (Fl_Callback *)geometry_elementary_symmetry_cb, (void*)"Surface"} ,
+      {"Volume",  (Fl_Callback *)geometry_elementary_symmetry_cb, (void*)"Volume"} , 
+      {0} 
+    };  
+    contextItem menu_geometry_elementary_extrude[] = {
+      {"0Geometry>Elementary>Extrude", NULL} ,
+      {"Translate", (Fl_Callback *)geometry_elementary_extrude_translate_cb, (void*)0} ,
+      {"Rotate",    (Fl_Callback *)geometry_elementary_extrude_rotate_cb, (void*)0} ,
+      {0} 
+    };  
+      contextItem menu_geometry_elementary_extrude_translate[] = {
+        {"0Geometry>Elementary>Extrude>Translate", NULL} ,
+        {"Point",   (Fl_Callback *)geometry_elementary_extrude_translate_cb, (void*)"Point"} ,
+        {"Line",    (Fl_Callback *)geometry_elementary_extrude_translate_cb, (void*)"Line"} ,
+        {"Surface", (Fl_Callback *)geometry_elementary_extrude_translate_cb, (void*)"Surface"} ,
+        {0} 
+      };  
+      contextItem menu_geometry_elementary_extrude_rotate[] = {
+        {"0Geometry>Elementary>Extrude>Rotate", NULL} ,
+        {"Point",   (Fl_Callback *)geometry_elementary_extrude_rotate_cb, (void*)"Point"} ,
+        {"Line",    (Fl_Callback *)geometry_elementary_extrude_rotate_cb, (void*)"Line"} ,
+        {"Surface", (Fl_Callback *)geometry_elementary_extrude_rotate_cb, (void*)"Surface"} ,
+        {0} 
+      };  
+  contextItem menu_geometry_physical[] = {
+    {"0Geometry>Physical", NULL} ,
+    {"Add",    (Fl_Callback *)geometry_physical_add_cb, (void*)0} ,
+    {0} 
+  };  
+    contextItem menu_geometry_physical_add[] = {
+      {"0Geometry>Physical>Add", NULL} ,
+      {"Point",   (Fl_Callback *)geometry_physical_add_cb, (void*)"Point" } ,
+      {"Line",    (Fl_Callback *)geometry_physical_add_cb, (void*)"Line" } ,
+      {"Surface", (Fl_Callback *)geometry_physical_add_cb, (void*)"Surface" } ,
+      {"Volume",  (Fl_Callback *)geometry_physical_add_cb, (void*)"Volume" } ,
+      {0} 
+    };  
+
+contextItem menu_mesh[] = {
+  {"1Mesh", NULL} ,
+  {"Define",       (Fl_Callback *)mesh_define_cb} ,
+  {"Inspect",      (Fl_Callback *)mesh_inspect_cb} , 
+  {"Delete",       (Fl_Callback *)mesh_delete_cb} , 
+  {"1D",           (Fl_Callback *)mesh_1d_cb} ,
+  {"2D",           (Fl_Callback *)mesh_2d_cb} , 
+  {"3D",           (Fl_Callback *)mesh_3d_cb} , 
+  {"First order",  (Fl_Callback *)mesh_degree_cb, (void*)1 } , 
+  {"Second order", (Fl_Callback *)mesh_degree_cb, (void*)2 } , 
+  {"Refine",       (Fl_Callback *)mesh_refine_cb} ,
+  {"Optimize",     (Fl_Callback *)mesh_optimize_cb} , 
+#if defined(HAVE_NETGEN)
+  {"Optimize (Netgen)", (Fl_Callback *)mesh_optimize_netgen_cb} , 
+#endif
+#if defined(HAVE_METIS) || defined(HAVE_CHACO)
+  {"Partition", (Fl_Callback *)mesh_partition_cb} ,
+#endif
+#if defined(HAVE_FOURIER_MODEL)
+  {"Reparameterize",   (Fl_Callback *)mesh_parameterize_cb} , 
+#endif
+  //{"Reclassify",   (Fl_Callback *)mesh_classify_cb} , 
+  {"Save",         (Fl_Callback *)mesh_save_cb} ,
+  {0} 
+};  
+  contextItem menu_mesh_define[] = {
+    {"1Mesh>Define", NULL} ,
+    {"Fields",      (Fl_Callback *)view_field_cb},
+    {"Characteristic length", (Fl_Callback *)mesh_define_length_cb  } ,
+    {"Recombine",   (Fl_Callback *)mesh_define_recombine_cb  } ,
+    {"Transfinite", (Fl_Callback *)mesh_define_transfinite_cb  } , 
+    {0} 
+  };  
+    contextItem menu_mesh_define_transfinite[] = {
+      {"1Mesh>Define>Transfinite", NULL} ,
+      {"Line",    (Fl_Callback *)mesh_define_transfinite_line_cb} ,
+      {"Surface", (Fl_Callback *)mesh_define_transfinite_surface_cb} ,
+      {"Volume",  (Fl_Callback *)mesh_define_transfinite_volume_cb} , 
+      {0} 
+    };  
+  contextItem menu_mesh_delete[] = {
+    {"1Mesh>Edit>Delete", NULL} ,
+    {"Elements", (Fl_Callback *)mesh_delete_parts_cb, (void*)"elements"} ,
+    {"Lines",    (Fl_Callback *)mesh_delete_parts_cb, (void*)"lines"} ,
+    {"Surfaces", (Fl_Callback *)mesh_delete_parts_cb, (void*)"surfaces"} ,
+    {"Volumes",  (Fl_Callback *)mesh_delete_parts_cb, (void*)"volumes"} ,
+    {0} 
+  };  
+
+contextItem menu_solver[] = {
+  {"2Solver", NULL} ,
+  {"Solver 0", (Fl_Callback *)solver_cb , (void*)0} ,
+  {"Solver 1", (Fl_Callback *)solver_cb , (void*)1} ,
+  {"Solver 2", (Fl_Callback *)solver_cb , (void*)2} ,
+  {"Solver 3", (Fl_Callback *)solver_cb , (void*)3} ,
+  {"Solver 4", (Fl_Callback *)solver_cb , (void*)4} ,
+  {0} 
+};
+
+contextItem menu_post[] = {
+  {"3Post-processing", NULL} ,
+  {0} 
+};
+
+menuWindow::menuWindow(int fontsize) : _fontsize(fontsize)
+{
+  int width = 14 * fontsize;
+
+  // this is the initial height: no dynamic button is shown
+#if defined(__APPLE__)
+  if(CTX.system_menu_bar){
+    _MH = BH + 6; // the menu bar is not in the application
+  }
+  else{
+#endif
+    _MH = BH + BH + 6;
+#if defined(__APPLE__)
+  }
+#endif
+
+  win = new mainWindow(width, _MH + NB_BUTT_SCROLL * BH, CTX.non_modal_windows, "Gmsh");
+  win->box(GMSH_WINDOW_BOX);
+  win->callback(file_quit_cb);
+
+  int y;
+#if defined(__APPLE__)
+  if(CTX.system_menu_bar){
+    // the system menubar is kind of a hack in fltk < 1.1.7: it still
+    // creates a real (invisible) menubar. To avoid spurious mouse
+    // click events we make it a 1x1 pixel rectangle, 1 pixel off the
+    // edge (so it falls behind the navigation buttons)
+    sysbar = new Fl_Sys_Menu_Bar(1, 1, 1, 1);
+    sysbar->menu(sysbar_table);
+    sysbar->global();
+    Fl_Box *o = new Fl_Box(0, 0, width, BH + 6);
+    o->box(FL_UP_BOX);
+    y = 3;
+  }
+  else{
+#endif
+    bar = new Fl_Menu_Bar(0, 0, width, BH);
+    bar->menu(bar_table);
+    bar->box(FL_UP_BOX);
+    bar->global();
+    Fl_Box *o = new Fl_Box(0, BH, width, BH + 6);
+    o->box(FL_UP_BOX);
+    y = BH + 3;
+#if defined(__APPLE__)
+  }
+#endif
+
+  navig[0] = new Fl_Button(1, y, 18, BH / 2, "@#-1<");
+  navig[0]->labeltype(FL_SYMBOL_LABEL);
+  navig[0]->box(FL_FLAT_BOX);
+  navig[0]->selection_color(FL_WHITE);
+  navig[0]->callback(mod_back_cb);
+  navig[0]->tooltip("Go back one in the menu history (<)");
+
+  navig[1] = new Fl_Button(1, y + BH / 2, 18, BH / 2, "@#-1>");
+  navig[1]->labeltype(FL_SYMBOL_LABEL);
+  navig[1]->box(FL_FLAT_BOX);
+  navig[1]->selection_color(FL_WHITE);
+  navig[1]->callback(mod_forward_cb);
+  navig[1]->tooltip("Go forward one in the menu history (>)");
+
+  module = new Fl_Choice(19, y, width - 24, BH);
+  module->menu(module_table);
+  module->box(FL_THIN_DOWN_BOX);
+  // force the executation of the callback even if we didn't change
+  // the selection (we want to go back to the top-level menu every
+  // time we select one of the categories, even if the category is not
+  // changed):
+  module->when(FL_WHEN_RELEASE_ALWAYS);
+
+  // create an empty scroll area that will get populated dynamically
+  // in set_context()
+  scroll = new Fl_Scroll(0, _MH, width, NB_BUTT_SCROLL * BH); 
+  scroll->type(Fl_Scroll::VERTICAL);
+  scroll->end();
+
+  win->size(width, _MH);
+  win->position(CTX.position[0], CTX.position[1]);
+  
+  win->end();
+}
+
+void menuWindow::setContext(contextItem *menu_asked, int flag)
+{
+  static int nb_back = 0, nb_forward = 0, init_context = 0;
+  static contextItem *menu_history[NB_HISTORY_MAX];
+  contextItem *menu;
+
+  if(!init_context) {
+    init_context = 1;
+    for(int i = 0; i < NB_HISTORY_MAX; i++) {
+      menu_history[i] = NULL;
+    }
+  }
+
+  if(nb_back > NB_HISTORY_MAX - 2)
+    nb_back = 1; // we should do a circular list
+
+  if(flag == -1) {
+    if(nb_back > 1) {
+      nb_back--;
+      nb_forward++;
+      menu = menu_history[nb_back - 1];
+    }
+    else
+      return;
+  }
+  else if(flag == 1) {
+    if(nb_forward > 0) {
+      nb_back++;
+      nb_forward--;
+      menu = menu_history[nb_back - 1];
+    }
+    else
+      return;
+  }
+  else {
+    menu = menu_asked;
+    if(!nb_back || menu_history[nb_back - 1] != menu) {
+      menu_history[nb_back++] = menu;
+    }
+    nb_forward = 0;
+  }
+
+  if(menu[0].label[0] == '0'){
+    module->value(0);
+  }
+  else if(menu[0].label[0] == '1'){
+    module->value(1);
+  }
+  else if(menu[0].label[0] == '2'){
+    module->value(2);
+    menu[1].label = opt_solver_name0(0, GMSH_GET, 0);
+    menu[2].label = opt_solver_name1(0, GMSH_GET, 0);
+    menu[3].label = opt_solver_name2(0, GMSH_GET, 0);
+    menu[4].label = opt_solver_name3(0, GMSH_GET, 0);
+    menu[5].label = opt_solver_name4(0, GMSH_GET, 0);
+    for(int i = 0; i < MAX_NUM_SOLVERS; i++) {
+      if(!strlen(menu[i + 1].label))
+        menu[i + 1].label = NULL;
+    }
+  }
+  else if(menu[0].label[0] == '3'){
+    module->value(3);
+  }
+  else {
+    Msg::Warning("Something is wrong in your dynamic context definition");
+    return;
+  }
+
+  Msg::StatusBar(1, false, menu[0].label + 1);
+
+  // cannot use scroll->clear() in fltk 1.1 (should be fixed in 1.3)
+  for(unsigned int i = 0; i < push.size(); i++){
+    scroll->remove(push[i]);
+    Fl::delete_widget(push[i]);
+  }
+  for(unsigned int i = 0; i < toggle.size(); i++){
+    scroll->remove(toggle[i]);
+    Fl::delete_widget(toggle[i]);
+  }
+  for(unsigned int i = 0; i < toggle2.size(); i++){
+    scroll->remove(toggle2[i]);
+    Fl::delete_widget(toggle2[i]);
+  }
+  for(unsigned int i = 0; i < popup.size(); i++){
+    scroll->remove(popup[i]);
+    Fl::delete_widget(popup[i]);
+  }
+  for(unsigned int i = 0; i < popup2.size(); i++){
+    scroll->remove(popup2[i]);
+    Fl::delete_widget(popup2[i]);
+  }
+
+  // reset the vectors
+  push.clear();
+  toggle.clear();
+  toggle2.clear();
+  popup.clear();
+  popup2.clear();
+  for(unsigned int i = 0; i < label.size(); i++)
+    delete [] label[i];
+  label.clear();
+
+  int width = win->w();
+  int popw = 4 * _fontsize + 3;
+
+  // construct the dynamic menu
+  int nb = 0;
+  if(module->value() == 3){ // post-processing context
+    for(nb = 0; nb < (int)PView::list.size(); nb++) {
+      PViewData *data = PView::list[nb]->getData();
+      PViewOptions *opt = PView::list[nb]->getOptions();
+      
+      Fl_Light_Button *b1 = new Fl_Light_Button(0, _MH + nb * BH, width - popw, BH);
+      b1->callback(view_toggle_cb, (void *)nb);
+      b1->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE | FL_ALIGN_CLIP);
+      b1->value(opt->Visible);
+      b1->copy_label(data->getName().c_str());
+      b1->tooltip(data->getFileName().c_str());
+      
+      char *tmp = new char[32];
+      sprintf(tmp, "[%d]@#-1>", nb);
+      Fl_Button *b2 = new Fl_Button(width - popw, _MH + nb * BH, popw, BH, tmp);
+      label.push_back(tmp);
+      b2->align(FL_ALIGN_RIGHT | FL_ALIGN_INSIDE | FL_ALIGN_CLIP);
+      b2->tooltip("Show view option menu (Shift+w)");
+  
+      popupButton *p[2];
+      p[0] = new popupButton(width - popw, _MH + nb * BH, popw, BH);
+      p[0]->type(Fl_Menu_Button::POPUP123);
+      p[1] = new popupButton(0, _MH + nb * BH, width - popw, BH);
+      p[1]->type(Fl_Menu_Button::POPUP3);
+  
+      for(int j = 0; j < 2; j++) {
+        p[j]->add("Reload/View", 'r', 
+                  (Fl_Callback *) view_reload_cb, (void *)nb, 0);
+        p[j]->add("Reload/Visible Views", 0, 
+                  (Fl_Callback *) view_reload_visible_cb, (void *)nb, 0);
+        p[j]->add("Reload/All Views", 0, 
+                  (Fl_Callback *) view_reload_all_cb, (void *)nb, 0);
+        p[j]->add("Remove/View", FL_Delete, 
+                  (Fl_Callback *) view_remove_cb, (void *)nb, 0);
+        p[j]->add("Remove/Other Views", 0, 
+                  (Fl_Callback *) view_remove_other_cb, (void *)nb, 0);
+        p[j]->add("Remove/Visible Views", 0, 
+                  (Fl_Callback *) view_remove_visible_cb, (void *)nb, 0);
+        p[j]->add("Remove/Invisible Views", 0, 
+                  (Fl_Callback *) view_remove_invisible_cb, (void *)nb, 0);
+        p[j]->add("Remove/Empty Views", 0, 
+                  (Fl_Callback *) view_remove_empty_cb, (void *)nb, 0);
+        p[j]->add("Remove/All Views", 0, 
+                  (Fl_Callback *) view_remove_all_cb, (void *)nb, 0);
+        p[j]->add("Alias/View without Options", 0, 
+                  (Fl_Callback *) view_alias_cb, (void *)nb, 0);
+        p[j]->add("Alias/View with Options", 0, 
+                  (Fl_Callback *) view_alias_with_options_cb, (void *)nb, 0);
+        p[j]->add("Combine Elements/From Visible Views", 0, 
+                  (Fl_Callback *) view_combine_space_visible_cb, (void *)nb, 0);
+        p[j]->add("Combine Elements/From All Views", 0, 
+                  (Fl_Callback *) view_combine_space_all_cb, (void *)nb, 0);
+        p[j]->add("Combine Elements/By View Name", 0, 
+                  (Fl_Callback *) view_combine_space_by_name_cb, (void *)nb, 0);
+        p[j]->add("Combine Time Steps/From Visible Views", 0, 
+                  (Fl_Callback *) view_combine_time_visible_cb, (void *)nb, 0);
+        p[j]->add("Combine Time Steps/From All Views", 0, 
+                  (Fl_Callback *) view_combine_time_all_cb, (void *)nb, 0);
+        p[j]->add("Combine Time Steps/By View Name", 0, 
+                 (Fl_Callback *) view_combine_time_by_name_cb, (void *)nb, 0);
+        p[j]->add("Set Visibility/All On", 0, 
+                  (Fl_Callback *) view_all_visible_cb, (void *)1, 0);
+        p[j]->add("Set Visibility/All Off", 0, 
+                  (Fl_Callback *) view_all_visible_cb, (void *)0, 0);
+        p[j]->add("Set Visibility/Invert", 0, 
+                  (Fl_Callback *) view_all_visible_cb, (void *)-1, 0);
+        p[j]->add("Save As/Parsed View...", 0, 
+                  (Fl_Callback *) view_save_parsed_cb, (void *)nb, 0);
+        p[j]->add("Save As/ASCII View...", 0, 
+                  (Fl_Callback *) view_save_ascii_cb, (void *)nb, 0);
+        p[j]->add("Save As/Binary View...", 0, 
+                  (Fl_Callback *) view_save_binary_cb, (void *)nb, 0);
+        p[j]->add("Save As/STL Triangulation...", 0, 
+                  (Fl_Callback *) view_save_stl_cb, (void *)nb, 0);
+        p[j]->add("Save As/Raw Text...", 0, 
+                  (Fl_Callback *) view_save_txt_cb, (void *)nb, 0);
+        p[j]->add("Save As/Gmsh Mesh...", 0, 
+                  (Fl_Callback *) view_save_msh_cb, (void *)nb, 0);
+#if defined(HAVE_MED)
+        p[j]->add("Save As/MED file...", 0, 
+                  (Fl_Callback *) view_save_med_cb, (void *)nb, 0);
+#endif
+        p[j]->add("Apply As Background Mesh", 0, 
+                  (Fl_Callback *) view_applybgmesh_cb, (void *)nb, FL_MENU_DIVIDER);
+        p[j]->add("Options...", 'o', 
+                  (Fl_Callback *) view_options_cb, (void *)nb, 0);
+        p[j]->add("Plugins...", 'p', 
+                  (Fl_Callback *) view_plugin_cb, (void *)nb, 0);
+      }
+
+      toggle.push_back(b1);
+      toggle2.push_back(b2);
+      popup.push_back(p[0]);
+      popup2.push_back(p[1]);
+      scroll->add(b1);
+      scroll->add(b2);
+      scroll->add(p[0]);
+      scroll->add(p[1]);
+    }
+  }
+  else{ // geometry, mesh and solver contexts
+    while(menu[nb + 1].label) {
+      Fl_Button *b = new Fl_Button(0, _MH + nb * BH, width, BH);
+      b->copy_label(menu[nb + 1].label);
+      b->callback(menu[nb + 1].callback, menu[nb + 1].arg);
+      push.push_back(b);
+      scroll->add(b);
+      nb++;
+    }
+  }
+
+  scroll->redraw();
+
+  if(nb <= NB_BUTT_SCROLL)
+    win->size(width, _MH + nb * BH);
+  else
+    win->size(width, _MH + NB_BUTT_SCROLL * BH);
+}
diff --git a/Fltk/menuWindow.h b/Fltk/menuWindow.h
new file mode 100644
index 0000000000000000000000000000000000000000..1953ea97a11bffde875edc26d7d7aab9f6565e73
--- /dev/null
+++ b/Fltk/menuWindow.h
@@ -0,0 +1,79 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+
+#ifndef _MENU_WINDOW_H_
+#define _MENU_WINDOW_H_
+
+#include <vector>
+#include <FL/Fl_Window.H>
+#if defined(__APPLE__)
+#include <FL/Fl_Sys_Menu_Bar.H>
+#endif
+#include <FL/Fl_Menu_Bar.H>
+#include <FL/Fl_Scroll.H>
+#include <FL/Fl_Choice.H>
+#include <FL/Fl_Button.H>
+#include <FL/Fl_Light_Button.H>
+#include "popupButton.h"
+
+// The dynamic menu contexts
+typedef struct{
+  const char *label;
+  Fl_Callback *callback;
+  void *arg;
+} contextItem;
+
+extern contextItem menu_geometry[]; 
+extern    contextItem menu_geometry_elementary[]; 
+extern        contextItem menu_geometry_elementary_add[]; 
+extern            contextItem menu_geometry_elementary_add_new[]; 
+extern            contextItem menu_geometry_elementary_add_translate[]; 
+extern            contextItem menu_geometry_elementary_add_rotate[]; 
+extern            contextItem menu_geometry_elementary_add_scale[]; 
+extern            contextItem menu_geometry_elementary_add_symmetry[]; 
+extern        contextItem menu_geometry_elementary_translate[]; 
+extern        contextItem menu_geometry_elementary_rotate[]; 
+extern        contextItem menu_geometry_elementary_scale[]; 
+extern        contextItem menu_geometry_elementary_symmetry[]; 
+extern        contextItem menu_geometry_elementary_extrude[]; 
+extern            contextItem menu_geometry_elementary_extrude_translate[]; 
+extern            contextItem menu_geometry_elementary_extrude_rotate[]; 
+extern        contextItem menu_geometry_elementary_delete[]; 
+extern        contextItem menu_geometry_elementary_split[]; 
+extern    contextItem menu_geometry_physical[]; 
+extern        contextItem menu_geometry_physical_add[]; 
+extern contextItem menu_mesh[]; 
+extern    contextItem menu_mesh_edit[]; 
+extern        contextItem menu_mesh_delete[]; 
+extern    contextItem menu_mesh_define[]; 
+extern        contextItem menu_mesh_define_transfinite[]; 
+extern contextItem menu_solver[]; 
+extern contextItem menu_post[]; 
+
+class menuWindow{
+ private:
+  int _MH;
+  int _fontsize;
+ public:
+  Fl_Window *win;
+#if defined(__APPLE__)
+  Fl_Sys_Menu_Bar *sysbar;
+#endif
+  Fl_Menu_Bar *bar;
+  Fl_Choice *module;
+  Fl_Button *navig[2];
+  Fl_Scroll *scroll;
+  std::vector<Fl_Button*> push;
+  std::vector<Fl_Light_Button*> toggle;
+  std::vector<Fl_Button*> toggle2;
+  std::vector<popupButton*> popup;
+  std::vector<popupButton*> popup2;
+  std::vector<char*> label;
+ public:
+  menuWindow(int fontsize);
+  void setContext(contextItem *menu_asked, int flag);
+};
+
+#endif
diff --git a/Fltk/messageWindow.cpp b/Fltk/messageWindow.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5c01de08a12bf6696a629f1728e846a48ffe3cf4
--- /dev/null
+++ b/Fltk/messageWindow.cpp
@@ -0,0 +1,97 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+
+#include <FL/Fl_Box.H>
+#include <FL/Fl_Return_Button.H>
+#include "GUI.h"
+#include "messageWindow.h"
+#include "shortcutWindow.h"
+#include "Callbacks.h"
+#include "GmshMessage.h"
+#include "Context.h"
+
+extern Context_T CTX;
+
+messageWindow::messageWindow(int fontsize)
+  : _fontsize(fontsize)
+{
+  int width = CTX.msg_size[0];
+  int height = CTX.msg_size[1];
+
+  win = new dialogWindow
+    (width, height, CTX.non_modal_windows, "Message Console");
+  win->box(GMSH_WINDOW_BOX);
+
+  browser = new Fl_Browser(0, 0, width, height - 2 * WB - BH);
+  browser->box(FL_FLAT_BOX);
+  browser->textfont(FL_COURIER);
+  browser->textsize(_fontsize - 1);
+  browser->type(FL_MULTI_BROWSER);
+  browser->callback(message_copy_cb);
+
+  {
+    butt = new Fl_Check_Button
+      (width - 4 * BB - 4 * WB, height - BH - WB, BB, BH, "Auto scroll");
+    butt->type(FL_TOGGLE_BUTTON);
+    butt->callback(message_auto_scroll_cb);
+  }
+  {
+    Fl_Return_Button *o = new Fl_Return_Button
+      (width - 3 * BB - 3 * WB, height - BH - WB, BB, BH, "Clear");
+    o->callback(message_clear_cb);
+  }
+  {
+    Fl_Button *o = new Fl_Button
+      (width - 2 * BB - 2 * WB, height - BH - WB, BB, BH, "Save");
+    o->callback(message_save_cb);
+  }
+  {
+    Fl_Button *o = new Fl_Button
+      (width - BB - WB, height - BH - WB, BB, BH, "Cancel");
+    o->callback(cancel_cb, (void *)win);
+  }
+
+  win->resizable(new Fl_Box(1, 1, 4, 4));
+  win->size_range(WB + 100 + 3 * BB + 4 * WB, 100);
+
+  win->position(CTX.msg_position[0], CTX.msg_position[1]);
+  win->end();
+}
+
+void messageWindow::add(const char *msg)
+{
+  browser->add(msg, 0);
+  if(CTX.msg_auto_scroll)
+    browser->bottomline(browser->size());
+}
+
+void messageWindow::save(const char *filename)
+{
+  FILE *fp = fopen(filename, "w");
+
+  if(!fp) {
+    Msg::Error("Unable to open file '%s'", filename);
+    return;
+  }
+
+  Msg::StatusBar(2, true, "Writing '%s'", filename);
+  for(int i = 1; i <= browser->size(); i++) {
+    const char *c = browser->text(i);
+    if(c[0] == '@')
+      fprintf(fp, "%s\n", &c[5]);
+    else
+      fprintf(fp, "%s\n", c);
+  }
+  Msg::StatusBar(2, true, "Wrote '%s'", filename);
+  fclose(fp);
+}
+
+void messageWindow::show(bool redrawOnly)
+{
+  if(win->shown() && redrawOnly)
+    win->redraw();
+  else
+    win->show();
+}
diff --git a/Fltk/messageWindow.h b/Fltk/messageWindow.h
new file mode 100644
index 0000000000000000000000000000000000000000..2d1b2140e4cf23a41c168e0f51272f0ef4263f6c
--- /dev/null
+++ b/Fltk/messageWindow.h
@@ -0,0 +1,27 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+
+#ifndef _MESSAGE_WINDOW_H_
+#define _MESSAGE_WINDOW_H_
+
+#include <FL/Fl_Window.H>
+#include <FL/Fl_Browser.H>
+#include <FL/Fl_Check_Button.H>
+
+class messageWindow{
+ private:
+  int _fontsize;
+ public:
+  Fl_Window *win;
+  Fl_Browser *browser;
+  Fl_Check_Button *butt;
+ public:
+  messageWindow(int fontsize);
+  void show(bool redrawOnly=false);
+  void add(const char *msg);
+  void save(const char *filename);
+};
+
+#endif
diff --git a/Fltk/Opengl_Window.cpp b/Fltk/openglWindow.cpp
similarity index 59%
rename from Fltk/Opengl_Window.cpp
rename to Fltk/openglWindow.cpp
index 9f67f501358b271d89e5968cd5438217af1f196e..072293ea6cc9780bec866e8cbc5ff1cb2bfdf7c5 100644
--- a/Fltk/Opengl_Window.cpp
+++ b/Fltk/openglWindow.cpp
@@ -3,7 +3,11 @@
 // See the LICENSE.txt file for license information. Please report all
 // bugs and problems to <gmsh@geuz.org>.
 
-#include "GmshUI.h"
+#include <FL/gl.h>
+#include "openglWindow.h"
+#include "graphicWindow.h"
+#include "manipWindow.h"
+#include "contextWindow.h"
 #include "GmshDefines.h"
 #include "GmshMessage.h"
 #include "Draw.h"
@@ -11,13 +15,11 @@
 #include "Context.h"
 #include "SelectBuffer.h"
 #include "GUI.h"
-#include "Opengl_Window.h"
 #include "MElement.h"
 
-extern GUI *WID;
 extern Context_T CTX;
 
-void MousePosition::set(drawContext *ctx)
+void mousePosition::set(drawContext *ctx)
 {
   for(int i = 0; i < 3; i++){
     s[i] = ctx->s[i];
@@ -37,7 +39,7 @@ void MousePosition::set(drawContext *ctx)
   wnr[2] = 0.;
 }
 
-void MousePosition::recenter(drawContext *ctx)
+void mousePosition::recenter(drawContext *ctx)
 {
   // compute the equivalent translation to apply *after* the scaling
   // so that the scaling is done around the point which was clicked:
@@ -45,7 +47,7 @@ void MousePosition::recenter(drawContext *ctx)
   ctx->t[1] = t[1] * (s[1] / ctx->s[1]) - wnr[1] * (1. - (s[1] / ctx->s[1]));
 }
   
-static void lassoZoom(drawContext *ctx, MousePosition &click1, MousePosition &click2)
+static void lassoZoom(drawContext *ctx, mousePosition &click1, mousePosition &click2)
 {
   if(click1.win[0] == click2.win[0] || click1.win[1] == click2.win[1])
     return;
@@ -55,30 +57,32 @@ static void lassoZoom(drawContext *ctx, MousePosition &click1, MousePosition &cl
   ctx->s[2] = std::min(ctx->s[0], ctx->s[1]); // bof...
   
   // recenter around the center of the lasso rectangle
-  MousePosition tmp(click1);
+  mousePosition tmp(click1);
   tmp.wnr[0] = 0.5 * (click1.wnr[0] + click2.wnr[0]);
   tmp.wnr[1] = 0.5 * (click1.wnr[1] + click2.wnr[1]);
   tmp.recenter(ctx);
 
   ctx->initPosition();
   Draw();
-  WID->update_manip_window();
+  GUI::instance()->manip->update();
 }
 
-Opengl_Window::Opengl_Window(int x, int y, int w, int h, const char *l)
+openglWindow::openglWindow(int x, int y, int w, int h, const char *l)
   : Fl_Gl_Window(x, y, w, h, l)
 {
-  AddPointMode = LassoMode = SelectionMode = false;
+  addPointMode = lassoMode = selectionMode = false;
   _point[0] = _point[1] = _point[2] = 0.;
+  //double mat[3][3]={{1,0,0}, {0,1,0}, {0,0,10}};
+  //_ctx = new drawContext(new drawTransformScaled(mat));
   _ctx = new drawContext();
 }
 
-Opengl_Window::~Opengl_Window()
+openglWindow::~openglWindow()
 { 
   delete _ctx; 
 }
 
-void Opengl_Window::draw()
+void openglWindow::draw()
 {
   static int locked = 0;
   if(locked)
@@ -86,7 +90,7 @@ void Opengl_Window::draw()
   else
     locked = 1;
 
-  Msg::Debug("Opengl_Window->draw()");
+  Msg::Debug("openglWindow->draw()");
 
   if(!valid()) {
     valid(1);
@@ -100,14 +104,14 @@ void Opengl_Window::draw()
   else {
     if((w() != _ctx->viewport[2] - _ctx->viewport[0]) ||
        (h() != _ctx->viewport[3] - _ctx->viewport[1])) {
-      WID->set_size(_ctx->viewport[2] - _ctx->viewport[0],
-                    _ctx->viewport[3] - _ctx->viewport[1]);
+      GUI::instance()->setGraphicSize(_ctx->viewport[2] - _ctx->viewport[0],
+                          _ctx->viewport[3] - _ctx->viewport[1]);
       glViewport(_ctx->viewport[0], _ctx->viewport[1],
                  _ctx->viewport[2], _ctx->viewport[3]);
     }
   }
 
-  if(LassoMode) { 
+  if(lassoMode) { 
     // draw the zoom or selection lasso on top of the current scene
     // (without using overlays!)
     glMatrixMode(GL_PROJECTION);
@@ -118,7 +122,7 @@ void Opengl_Window::draw()
     glLoadIdentity();
     glColor3d(1., 1., 1.);
     glDisable(GL_DEPTH_TEST);
-    if(SelectionMode && CTX.mouse_selection){
+    if(selectionMode && CTX.mouse_selection){
       glEnable(GL_LINE_STIPPLE);
       glLineStipple(1, 0x0F0F);
     }
@@ -137,11 +141,11 @@ void Opengl_Window::draw()
       if(!i) _lasso.set(_ctx);
     }
     glDisable(GL_BLEND);
-    if(SelectionMode && CTX.mouse_selection)
+    if(selectionMode && CTX.mouse_selection)
       glDisable(GL_LINE_STIPPLE);
     glEnable(GL_DEPTH_TEST);
   }
-  else if(AddPointMode) { 
+  else if(addPointMode) { 
     // draw the whole scene and the point to add
     if(CTX.fast_redraw) {
       CTX.mesh.draw = 0;
@@ -174,7 +178,7 @@ void Opengl_Window::draw()
 // as treated, and is suppressed. If the handle returns 0, the event
 // is passed to the parent.
 
-int Opengl_Window::handle(int event)
+int openglWindow::handle(int event)
 {
   switch (event) {
 
@@ -185,7 +189,7 @@ int Opengl_Window::handle(int event)
   case FL_SHORTCUT:
   case FL_KEYBOARD:
     // override the default widget arrow-key-navigation
-    if(WID->arrow_shortcuts())
+    if(GUI::instance()->testArrowShortcuts())
       return 1;
     return Fl_Gl_Window::handle(event);
     
@@ -194,62 +198,74 @@ int Opengl_Window::handle(int event)
     _curr.set(_ctx);
     if(Fl::event_button() == 1 && 
        !Fl::event_state(FL_SHIFT) && !Fl::event_state(FL_ALT)) {
-      if(!LassoMode && Fl::event_state(FL_CTRL)) {
-        LassoMode = true;
+      if(!lassoMode && Fl::event_state(FL_CTRL)) {
+        lassoMode = true;
         _lasso.set(_ctx);
       }
-      else if(LassoMode) {
-        LassoMode = false;
-        if(SelectionMode && CTX.mouse_selection){
-          WID->try_selection = 2; // will try to select multiple entities
-          WID->try_selection_xywh[0] = (int)(_click.win[0] + _curr.win[0])/2;
-          WID->try_selection_xywh[1] = (int)(_click.win[1] + _curr.win[1])/2;
-          WID->try_selection_xywh[2] = (int)fabs(_click.win[0] - _curr.win[0]);
-          WID->try_selection_xywh[3] = (int)fabs(_click.win[1] - _curr.win[1]);
+      else if(lassoMode) {
+        lassoMode = false;
+        if(selectionMode && CTX.mouse_selection){
+          // will try to select multiple entities
+          GUI::instance()->try_selection = 2;
+          GUI::instance()->try_selection_xywh[0] = 
+            (int)(_click.win[0] + _curr.win[0]) / 2;
+          GUI::instance()->try_selection_xywh[1] = 
+            (int)(_click.win[1] + _curr.win[1]) / 2;
+          GUI::instance()->try_selection_xywh[2] = 
+            (int)fabs(_click.win[0] - _curr.win[0]);
+          GUI::instance()->try_selection_xywh[3] = 
+            (int)fabs(_click.win[1] - _curr.win[1]);
         }
         else{
           lassoZoom(_ctx, _click, _curr);
         }
       }
       else if(CTX.mouse_selection){
-        WID->try_selection = 1; // will try to select clicked entity
-        WID->try_selection_xywh[0] = (int)_curr.win[0];
-        WID->try_selection_xywh[1] = (int)_curr.win[1];
-        WID->try_selection_xywh[2] = 5;
-        WID->try_selection_xywh[3] = 5;
+        // will try to select clicked entity
+        GUI::instance()->try_selection = 1;
+        GUI::instance()->try_selection_xywh[0] = (int)_curr.win[0];
+        GUI::instance()->try_selection_xywh[1] = (int)_curr.win[1];
+        GUI::instance()->try_selection_xywh[2] = 5;
+        GUI::instance()->try_selection_xywh[3] = 5;
       }
     }
     else if(Fl::event_button() == 2 || 
             (Fl::event_button() == 1 && Fl::event_state(FL_SHIFT))) {
-      if(!LassoMode && Fl::event_state(FL_CTRL)) {
+      if(!lassoMode && Fl::event_state(FL_CTRL)) {
         // make zoom isotropic
         _ctx->s[1] = _ctx->s[0];
         _ctx->s[2] = _ctx->s[0];
         redraw();
       }
-      else if(LassoMode) {
-        LassoMode = false;
-        if(SelectionMode && CTX.mouse_selection){
-          WID->try_selection = -2; // will try to unselect multiple entities
-          WID->try_selection_xywh[0] = (int)(_click.win[0] + _curr.win[0])/2;
-          WID->try_selection_xywh[1] = (int)(_click.win[1] + _curr.win[1])/2;
-          WID->try_selection_xywh[2] = (int)fabs(_click.win[0] - _curr.win[0]);
-          WID->try_selection_xywh[3] = (int)fabs(_click.win[1] - _curr.win[1]);
+      else if(lassoMode) {
+        lassoMode = false;
+        if(selectionMode && CTX.mouse_selection){
+          // will try to unselect multiple entities
+          GUI::instance()->try_selection = -2;
+          GUI::instance()->try_selection_xywh[0] = 
+            (int)(_click.win[0] + _curr.win[0]) / 2;
+          GUI::instance()->try_selection_xywh[1] =
+            (int)(_click.win[1] + _curr.win[1]) / 2;
+          GUI::instance()->try_selection_xywh[2] =
+            (int)fabs(_click.win[0] - _curr.win[0]);
+          GUI::instance()->try_selection_xywh[3] =
+            (int)fabs(_click.win[1] - _curr.win[1]);
         }
         else{
           lassoZoom(_ctx, _click, _curr);
         }
       }
       else if(CTX.mouse_selection){
-        WID->try_selection = -1; // will try to unselect clicked entity
-        WID->try_selection_xywh[0] = (int)_curr.win[0];
-        WID->try_selection_xywh[1] = (int)_curr.win[1];
-        WID->try_selection_xywh[2] = 5;
-        WID->try_selection_xywh[3] = 5;
+        // will try to unselect clicked entity
+        GUI::instance()->try_selection = -1;
+        GUI::instance()->try_selection_xywh[0] = (int)_curr.win[0];
+        GUI::instance()->try_selection_xywh[1] = (int)_curr.win[1];
+        GUI::instance()->try_selection_xywh[2] = 5;
+        GUI::instance()->try_selection_xywh[3] = 5;
       }
     }
     else {
-      if(Fl::event_state(FL_CTRL) && !LassoMode) {
+      if(Fl::event_state(FL_CTRL) && !lassoMode) {
         if(CTX.useTrackball)
           _ctx->setQuaternion(0., 0., 0., 1.);
         else
@@ -259,18 +275,18 @@ int Opengl_Window::handle(int event)
         redraw();
       }
       else {
-        LassoMode = false;
+        lassoMode = false;
       }
     }
     _click.set(_ctx);
     _prev.set(_ctx);
-    WID->update_manip_window();
+    GUI::instance()->manip->update();
     return 1;
 
   case FL_RELEASE:
     _curr.set(_ctx);
     CTX.draw_rotation_center = 0;
-    if(!LassoMode) {
+    if(!lassoMode) {
       CTX.mesh.draw = 1;
       CTX.post.draw = 1;
       redraw();
@@ -288,7 +304,7 @@ int Opengl_Window::handle(int event)
       _prev.recenter(_ctx);
       redraw();
     }
-    WID->update_manip_window();
+    GUI::instance()->manip->update();
     return 1;
 
   case FL_DRAG:
@@ -296,17 +312,17 @@ int Opengl_Window::handle(int event)
     {
       double dx = _curr.win[0] - _prev.win[0];
       double dy = _curr.win[1] - _prev.win[1];
-      if(LassoMode) {
+      if(lassoMode) {
         redraw();
       }
       else {
         if(Fl::event_state(FL_META)) {
           // will try to select or unselect entities on the fly
-          WID->try_selection = Fl::event_state(FL_SHIFT) ? -1 : 1; 
-          WID->try_selection_xywh[0] = (int)_curr.win[0];
-          WID->try_selection_xywh[1] = (int)_curr.win[1];
-          WID->try_selection_xywh[2] = 5;
-          WID->try_selection_xywh[3] = 5;
+          GUI::instance()->try_selection = Fl::event_state(FL_SHIFT) ? -1 : 1; 
+          GUI::instance()->try_selection_xywh[0] = (int)_curr.win[0];
+          GUI::instance()->try_selection_xywh[1] = (int)_curr.win[1];
+          GUI::instance()->try_selection_xywh[2] = 5;
+          GUI::instance()->try_selection_xywh[3] = 5;
         }
         else if(Fl::event_button() == 1 && 
                 !Fl::event_state(FL_SHIFT) && !Fl::event_state(FL_ALT)) {
@@ -346,16 +362,16 @@ int Opengl_Window::handle(int event)
       }
     }
     _prev.set(_ctx);
-    WID->update_manip_window();
+    GUI::instance()->manip->update();
     return 1;
 
   case FL_MOVE:
     _curr.set(_ctx);
-    if(LassoMode) {
+    if(lassoMode) {
       redraw();
     }
-    else if(AddPointMode && !Fl::event_state(FL_SHIFT)){
-      WID->g_opengl_window->cursor(FL_CURSOR_CROSS, FL_BLACK, FL_WHITE);
+    else if(addPointMode && !Fl::event_state(FL_SHIFT)){
+      cursor(FL_CURSOR_CROSS, FL_BLACK, FL_WHITE);
       // find line in real space corresponding to current cursor position
       double p[3],d[3];
       _ctx->unproject(_curr.win[0], _curr.win[1], p, d);
@@ -373,32 +389,34 @@ int Opengl_Window::handle(int event)
         }
       }
       char str[32];
-      sprintf(str, "%g", _point[0]); WID->context_geometry_input[2]->value(str);
-      sprintf(str, "%g", _point[1]); WID->context_geometry_input[3]->value(str);
-      sprintf(str, "%g", _point[2]); WID->context_geometry_input[4]->value(str);
+      sprintf(str, "%g", _point[0]); 
+      GUI::instance()->geoContext->input[2]->value(str);
+      sprintf(str, "%g", _point[1]); 
+      GUI::instance()->geoContext->input[3]->value(str);
+      sprintf(str, "%g", _point[2]); 
+      GUI::instance()->geoContext->input[4]->value(str);
       redraw();
     }
     else{ // hover mode
       if(_curr.win[0] != _prev.win[0] || _curr.win[1] != _prev.win[1]){
-        WID->make_opengl_current();
+        GUI::instance()->graph[0]->gl->make_current();
         std::vector<GVertex*> vertices;
         std::vector<GEdge*> edges;
         std::vector<GFace*> faces;
         std::vector<GRegion*> regions;
         std::vector<MElement*> elements;
-        bool res = ProcessSelectionBuffer(_ctx, WID->selection, false, 
-                                          CTX.mouse_hover_meshes, 
-                                          (int)_curr.win[0], (int)_curr.win[1], 5, 5, 
-                                          vertices, edges, faces, regions,
-                                          elements);
-        if((WID->selection == ENT_ALL && res) ||
-           (WID->selection == ENT_POINT && vertices.size()) ||
-           (WID->selection == ENT_LINE && edges.size()) || 
-           (WID->selection == ENT_SURFACE && faces.size()) ||
-           (WID->selection == ENT_VOLUME && regions.size()))
-          WID->g_window->cursor(FL_CURSOR_CROSS, FL_BLACK, FL_WHITE);
+        bool res = ProcessSelectionBuffer
+          (_ctx, GUI::instance()->selection, false, CTX.mouse_hover_meshes, 
+           (int)_curr.win[0], (int)_curr.win[1], 5, 5, vertices, edges, 
+           faces, regions, elements);
+        if((GUI::instance()->selection == ENT_ALL && res) ||
+           (GUI::instance()->selection == ENT_POINT && vertices.size()) ||
+           (GUI::instance()->selection == ENT_LINE && edges.size()) || 
+           (GUI::instance()->selection == ENT_SURFACE && faces.size()) ||
+           (GUI::instance()->selection == ENT_VOLUME && regions.size()))
+          cursor(FL_CURSOR_CROSS, FL_BLACK, FL_WHITE);
         else
-          WID->g_window->cursor(FL_CURSOR_DEFAULT, FL_BLACK, FL_WHITE);
+          cursor(FL_CURSOR_DEFAULT, FL_BLACK, FL_WHITE);
         GEntity *ge = 0;
         if(vertices.size()) ge = vertices[0];
         else if(edges.size()) ge = edges[0];
@@ -418,9 +436,6 @@ int Opengl_Window::handle(int event)
   }
 }
 
-
-// Select entity routine
-
 char SelectEntity(int type, 
                   std::vector<GVertex*> &vertices,
                   std::vector<GEdge*> &edges,
@@ -428,17 +443,19 @@ char SelectEntity(int type,
                   std::vector<GRegion*> &regions,
                   std::vector<MElement*> &elements)
 {
-  if(!WID) return 'q';
+  if(!GUI::instance()) return 'q';
 
-  WID->g_opengl_window->take_focus(); // force keyboard focus in GL window 
-  WID->g_opengl_window->SelectionMode = true; // enable lasso selection
+  // force keyboard focus in GL window 
+  GUI::instance()->graph[0]->gl->take_focus();
+  // enable lasso selection
+  GUI::instance()->graph[0]->gl->selectionMode = true;
 
-  WID->selection = type;
-  WID->try_selection = 0;
-  WID->quit_selection = 0;
-  WID->end_selection = 0;
-  WID->undo_selection = 0;
-  WID->invert_selection = 0;
+  GUI::instance()->selection = type;
+  GUI::instance()->try_selection = 0;
+  GUI::instance()->quit_selection = 0;
+  GUI::instance()->end_selection = 0;
+  GUI::instance()->undo_selection = 0;
+  GUI::instance()->invert_selection = 0;
 
   while(1) {
     vertices.clear();
@@ -446,46 +463,46 @@ char SelectEntity(int type,
     faces.clear();
     regions.clear();
     elements.clear();
-    WID->wait();
-    if(WID->quit_selection) {
-      WID->selection = ENT_NONE;
-      WID->g_opengl_window->SelectionMode = false;
-      WID->g_opengl_window->LassoMode = false;
-      WID->g_opengl_window->AddPointMode = false;
-      WID->g_opengl_window->cursor(FL_CURSOR_DEFAULT, FL_BLACK, FL_WHITE);
+    GUI::instance()->wait();
+    if(GUI::instance()->quit_selection) {
+      GUI::instance()->selection = ENT_NONE;
+      GUI::instance()->graph[0]->gl->selectionMode = false;
+      GUI::instance()->graph[0]->gl->lassoMode = false;
+      GUI::instance()->graph[0]->gl->addPointMode = false;
+      GUI::instance()->graph[0]->gl->cursor(FL_CURSOR_DEFAULT, FL_BLACK, FL_WHITE);
       return 'q';
     }
-    if(WID->end_selection) {
-      WID->end_selection = 0;
-      WID->selection = ENT_NONE;
+    if(GUI::instance()->end_selection) {
+      GUI::instance()->end_selection = 0;
+      GUI::instance()->selection = ENT_NONE;
       return 'e';
     }
-    if(WID->undo_selection) {
-      WID->undo_selection = 0;
+    if(GUI::instance()->undo_selection) {
+      GUI::instance()->undo_selection = 0;
       return 'u';
     }
-    if(WID->invert_selection) {
-      WID->invert_selection = 0;
+    if(GUI::instance()->invert_selection) {
+      GUI::instance()->invert_selection = 0;
       return 'i';
     }
-    if(WID->try_selection) {
-      bool add = (WID->try_selection > 0) ? true : false;
-      bool multi = (abs(WID->try_selection) > 1) ? true : false;
-      WID->try_selection = 0;
-      if(WID->selection == ENT_NONE){ // just report the mouse click
-        WID->g_opengl_window->SelectionMode = false;
+    if(GUI::instance()->try_selection) {
+      bool add = (GUI::instance()->try_selection > 0) ? true : false;
+      bool multi = (abs(GUI::instance()->try_selection) > 1) ? true : false;
+      GUI::instance()->try_selection = 0;
+      if(GUI::instance()->selection == ENT_NONE){ // just report the mouse click
+        GUI::instance()->graph[0]->gl->selectionMode = false;
         return 'c';
       }
-      else if(ProcessSelectionBuffer(WID->g_opengl_window->getDrawContext(),
-                                     WID->selection, multi, true,
-                                     WID->try_selection_xywh[0],
-                                     WID->try_selection_xywh[1], 
-                                     WID->try_selection_xywh[2],
-                                     WID->try_selection_xywh[3], 
-                                     vertices, edges, faces, regions,
-                                     elements)){
-        WID->selection = ENT_NONE;
-        WID->g_opengl_window->SelectionMode = false;
+      else if(ProcessSelectionBuffer
+              (GUI::instance()->graph[0]->gl->getDrawContext(),
+               GUI::instance()->selection, multi, true,
+               GUI::instance()->try_selection_xywh[0],
+               GUI::instance()->try_selection_xywh[1], 
+               GUI::instance()->try_selection_xywh[2],
+               GUI::instance()->try_selection_xywh[3], 
+               vertices, edges, faces, regions, elements)){
+        GUI::instance()->selection = ENT_NONE;
+        GUI::instance()->graph[0]->gl->selectionMode = false;
         if(add)
           return 'l';
         else
diff --git a/Fltk/Opengl_Window.h b/Fltk/openglWindow.h
similarity index 58%
rename from Fltk/Opengl_Window.h
rename to Fltk/openglWindow.h
index 1dca77460bb4632b45b52a8e528e4e05f12e2118..5ab361fc2e2fbac48497277bc44f370da760f827 100644
--- a/Fltk/Opengl_Window.h
+++ b/Fltk/openglWindow.h
@@ -10,18 +10,18 @@
 #include <FL/Fl_Box.H>
 #include "drawContext.h"
 
-class MousePosition {
+class mousePosition {
  public:
   double win[3]; // window coordinates
   double wnr[3]; // world coordinates BEFORE rotation
   double s[3]; // scaling state when the event was recorded
   double t[3]; // translation state when the event was recorded
-  MousePosition()
+  mousePosition()
   {
     for(int i = 0; i < 3; i++)
       win[i] = wnr[i] = s[i] = t[i] = 0.;
   }
-  MousePosition(const MousePosition &instance)
+  mousePosition(const mousePosition &instance)
   {
     for(int i = 0; i < 3; i++){
       win[i] = instance.win[i];
@@ -34,29 +34,18 @@ class MousePosition {
   void recenter(drawContext *ctx);
 };
 
-class Opengl_Window : public Fl_Gl_Window {
+class openglWindow : public Fl_Gl_Window {
  private:
-  MousePosition _click, _curr, _prev, _lasso;
-  double _point[3];
+  mousePosition _click, _curr, _prev, _lasso;
   drawContext *_ctx;
+  double _point[3];
   void draw();
   int handle(int);
  public:
-  bool AddPointMode, LassoMode, SelectionMode;
-  Opengl_Window(int x, int y, int w, int h, const char *l=0);
-  ~Opengl_Window();
+  bool addPointMode, lassoMode, selectionMode;
+  openglWindow(int x, int y, int w, int h, const char *l=0);
+  ~openglWindow();
   drawContext *getDrawContext(){ return _ctx; }
 };
 
-// This dummy box class permits to define a box widget that will not
-// eat the FL_ENTER/FL_LEAVE events (the new Box widget in fltk >1.1
-// does that, so that our Opengl_Window->handle() was not called each
-// time the mouse moved)
-class Dummy_Box : public Fl_Box {
- private:
-  int handle(int){ return 0; } // always!
- public:
-  Dummy_Box(int x,int y,int w,int h,const char *l=0) : Fl_Box(x, y, w, h, l) {}
-};
-
 #endif
diff --git a/Fltk/optionWindow.cpp b/Fltk/optionWindow.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..114adb667147a1db971b434758937ce805e399d2
--- /dev/null
+++ b/Fltk/optionWindow.cpp
@@ -0,0 +1,2223 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+
+#include <string.h>
+#include <FL/Fl_Tabs.H>
+#include <FL/Fl_Box.H>
+#include <FL/Fl_Scroll.H>
+#include "GUI.h"
+#include "optionWindow.h"
+#include "shortcutWindow.h"
+#include "GmshMessage.h"
+#include "Options.h"
+#include "Callbacks.h"
+#include "PView.h"
+#include "PViewData.h"
+#include "PViewOptions.h"
+#include "Context.h"
+
+extern Context_T CTX;
+
+extern StringXColor GeneralOptions_Color[] ;
+extern StringXColor GeometryOptions_Color[] ;
+extern StringXColor MeshOptions_Color[] ;
+extern StringXColor SolverOptions_Color[] ;
+extern StringXColor PostProcessingOptions_Color[] ;
+extern StringXColor ViewOptions_Color[] ;
+extern StringXColor PrintOptions_Color[] ;
+
+static Fl_Menu_Item menu_point_display[] = {
+  {"Color dot",   0, 0, 0},
+  {"3D sphere",   0, 0, 0},
+  {0}
+};
+
+static Fl_Menu_Item menu_point_display_post[] = {
+  {"Color dot",      0, 0, 0},
+  {"3D sphere",      0, 0, 0},
+  {"Scaled dot",     0, 0, 0},
+  {"Scaled sphere",  0, 0, 0},
+  {0}
+};
+
+static Fl_Menu_Item menu_line_display[] = {
+  {"Color segment", 0, 0, 0},
+  {"3D cylinder",   0, 0, 0},
+  {0}
+};
+
+static Fl_Menu_Item menu_line_display_post[] = {
+  {"Color segment",    0, 0, 0},
+  {"3D cylinder",      0, 0, 0},
+  {"Tapered cylinder", 0, 0, 0},
+  {0}
+};
+
+static Fl_Menu_Item menu_surface_display[] = {
+  {"Cross",     0, 0, 0},
+  {"Wireframe", 0, 0, 0},
+  {"Solid",     0, 0, 0},
+  {0}
+};
+
+static Fl_Menu_Item menu_axes_mode[] = {
+  {"None",        0, 0, 0},
+  {"Simple axes", 0, 0, 0},
+  {"Box",         0, 0, 0},
+  {"Full grid",   0, 0, 0},
+  {"Open grid",   0, 0, 0},
+  {"Ruler",       0, 0, 0},
+  {0}
+};
+
+Fl_Menu_Item menu_font_names[] = {
+  {"Times-Roman",           0, 0, (void*)FL_TIMES},
+  {"Times-Bold",            0, 0, (void*)FL_TIMES_BOLD},
+  {"Times-Italic",          0, 0, (void*)FL_TIMES_ITALIC},
+  {"Times-BoldItalic",      0, 0, (void*)FL_TIMES_BOLD_ITALIC},
+  {"Helvetica",             0, 0, (void*)FL_HELVETICA},
+  {"Helvetica-Bold",        0, 0, (void*)FL_HELVETICA_BOLD},
+  {"Helvetica-Oblique",     0, 0, (void*)FL_HELVETICA_ITALIC},
+  {"Helvetica-BoldOblique", 0, 0, (void*)FL_HELVETICA_BOLD_ITALIC},
+  {"Courier",               0, 0, (void*)FL_COURIER},
+  {"Courier-Bold",          0, 0, (void*)FL_COURIER_BOLD},
+  {"Courier-Oblique",       0, 0, (void*)FL_COURIER_ITALIC},
+  {"Courier-BoldOblique",   0, 0, (void*)FL_COURIER_BOLD_ITALIC},
+  {"Symbol",                0, 0, (void*)FL_SYMBOL},
+  {"ZapfDingbats",          0, 0, (void*)FL_ZAPF_DINGBATS},
+  {0}
+};
+
+optionWindow::optionWindow(int fontsize) : _fontsize(fontsize)
+{
+  int width = 34 * _fontsize + WB;
+  int height = 13 * BH + 5 * WB;
+  int L = 7 * _fontsize;
+
+  win = new dialogWindow(width, height, CTX.non_modal_windows);
+  win->box(GMSH_WINDOW_BOX);
+  win->label("Options - General");
+
+  // Buttons
+  {
+    Fl_Button *o = new Fl_Button
+      (width - BB - WB, height - BH - WB, BB, BH, "Cancel");
+    o->callback(cancel_cb, (void *)win);
+  }
+  {
+    Fl_Button *o = new Fl_Button
+      ((int)(width - 2.5 * BB - 2 * WB), height - BH - WB, (int)(1.5 * BB), BH, 
+       "Save as defaults");
+    o->callback(options_save_cb);
+  }
+  {
+    redraw = new Fl_Return_Button
+      ((int)(width - 3.5 * BB - 3 * WB), height - BH - WB, BB, BH, "Redraw");
+    redraw->callback(redraw_cb);
+  }
+
+  // Selection browser
+  browser = new Fl_Hold_Browser(WB, WB, L - WB, height - 3 * WB - BH);
+  browser->has_scrollbar(Fl_Browser_::VERTICAL);
+  browser->add("General");
+  browser->add("Geometry");
+  browser->add("Mesh");
+  browser->add("Solver");
+  browser->add("Post-pro");
+  browser->callback(options_browser_cb);
+  browser->value(1);
+
+  width -= L;
+  int BW = width - 4 * WB;
+  height -= WB + BH;
+
+  // General options
+  general.group = new Fl_Group(L, 0, width, height, "General Options");
+  {
+    Fl_Tabs *o = new Fl_Tabs(L + WB, WB, width - 2 * WB, height - 2 * WB);
+    {
+      Fl_Group *o = new Fl_Group
+        (L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "General");
+      general.butt[10] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 1 * BH, BW, BH, "Enable expert mode");
+      general.butt[10]->type(FL_TOGGLE_BUTTON);
+      general.butt[10]->callback(general_options_ok_cb);
+
+      general.butt[13] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 2 * BH, BW, BH, "Show tooltips");
+      general.butt[13]->type(FL_TOGGLE_BUTTON);
+      general.butt[13]->callback(general_options_ok_cb);
+
+      general.butt[6] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 3 * BH, BW, BH, "Show bounding boxes");
+      general.butt[6]->tooltip("(Alt+b)");
+      general.butt[6]->type(FL_TOGGLE_BUTTON);
+      general.butt[6]->callback(general_options_ok_cb);
+
+      general.butt[2] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 4 * BH, BW, BH, 
+         "Draw simplified model during user interaction");
+      general.butt[2]->tooltip("(Alt+f)");
+      general.butt[2]->type(FL_TOGGLE_BUTTON);
+      general.butt[2]->callback(general_options_ok_cb, (void*)"fast_redraw");
+
+      general.butt[11] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 5 * BH, BW, BH, "Enable mouse hover over meshes");
+      general.butt[11]->type(FL_TOGGLE_BUTTON);
+      general.butt[11]->callback(general_options_ok_cb);
+
+      general.butt[3] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 6 * BH, BW, BH, "Enable double buffering");
+      general.butt[3]->type(FL_TOGGLE_BUTTON);
+      general.butt[3]->callback(general_options_ok_cb);
+
+      general.butt[12] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 7 * BH, BW, BH, "Enable antialiasing");
+      general.butt[12]->type(FL_TOGGLE_BUTTON);
+      general.butt[12]->callback(general_options_ok_cb);
+
+      general.butt[5] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 8 * BH, BW, BH, 
+         "Use trackball rotation instead of Euler angles");
+      general.butt[5]->type(FL_TOGGLE_BUTTON);
+      general.butt[5]->callback(general_options_ok_cb);
+
+      general.butt[15] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 9 * BH, BW, BH, "Rotate around pseudo center of mass");
+      general.butt[15]->type(FL_TOGGLE_BUTTON);
+      general.butt[15]->callback(general_options_ok_cb, (void*)"rotation_center");
+
+      general.push[0] = new Fl_Button
+        (L + 2 * IW - 2 * WB, 2 * WB + 10 * BH, BB, BH, "Select");
+      general.push[0]->callback(general_options_rotation_center_select_cb);
+
+      general.value[8] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 10 * BH, IW / 3, BH);
+      general.value[8]->callback(general_options_ok_cb, (void*)"rotation_center_coord");
+      general.value[9] = new Fl_Value_Input
+        (L + 2 * WB + IW / 3, 2 * WB + 10 * BH, IW / 3, BH);
+      general.value[9]->callback(general_options_ok_cb, (void*)"rotation_center_coord");
+      general.value[10] = new Fl_Value_Input
+        (L + 2 * WB + 2 * IW / 3, 2 * WB + 10 * BH, IW / 3, BH, "Rotation center");
+      general.value[10]->align(FL_ALIGN_RIGHT);
+      general.value[10]->callback(general_options_ok_cb, (void*)"rotation_center_coord");
+
+      o->end();
+    }
+    {
+      Fl_Group *o = new Fl_Group
+        (L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Axes");
+
+      general.choice[4] = new Fl_Choice
+        (L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "Axes mode");
+      general.choice[4]->menu(menu_axes_mode);
+      general.choice[4]->align(FL_ALIGN_RIGHT);
+      general.choice[4]->tooltip("(Alt+a)");
+      general.choice[4]->callback(general_options_ok_cb, (void*)"general_axes");
+
+      general.butt[16] = new Fl_Check_Button
+        (L + width - (int)(0.85*IW) - 2 * WB, 2 * WB + 1 * BH, (int)(0.85*IW), BH,
+         "Mikado style");
+      general.butt[16]->type(FL_TOGGLE_BUTTON);
+      general.butt[16]->callback(general_options_ok_cb);
+
+      general.value[17] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 2 * BH, IW / 3, BH);
+      general.value[17]->minimum(0.);
+      general.value[17]->step(1);
+      general.value[17]->maximum(100);
+      general.value[17]->callback(general_options_ok_cb);
+      general.value[18] = new Fl_Value_Input
+        (L + 2 * WB + 1*IW/3, 2 * WB + 2 * BH, IW / 3, BH);
+      general.value[18]->minimum(0.);
+      general.value[18]->step(1);
+      general.value[18]->maximum(100);
+      general.value[18]->callback(general_options_ok_cb);
+      general.value[19] = new Fl_Value_Input
+        (L + 2 * WB + 2*IW/3, 2 * WB + 2 * BH, IW / 3, BH, "Axes tics");
+      general.value[19]->minimum(0.);
+      general.value[19]->step(1);
+      general.value[19]->maximum(100);
+      general.value[19]->align(FL_ALIGN_RIGHT);
+      general.value[19]->callback(general_options_ok_cb);
+
+      general.input[3] = new Fl_Input
+        (L + 2 * WB, 2 * WB + 3 * BH, IW/3, BH);
+      general.input[3]->callback(general_options_ok_cb);
+      general.input[4] = new Fl_Input
+        (L + 2 * WB + 1*IW/3, 2 * WB + 3 * BH, IW/3, BH);
+      general.input[4]->callback(general_options_ok_cb);
+      general.input[5] = new Fl_Input
+        (L + 2 * WB + 2*IW/3, 2 * WB + 3 * BH, IW/3, BH, "Axes format");
+      general.input[5]->align(FL_ALIGN_RIGHT);
+      general.input[5]->callback(general_options_ok_cb);
+      
+      general.input[6] = new Fl_Input
+        (L + 2 * WB, 2 * WB + 4 * BH, IW/3, BH);
+      general.input[6]->callback(general_options_ok_cb);
+      general.input[7] = new Fl_Input
+        (L + 2 * WB + 1*IW/3, 2 * WB + 4 * BH, IW/3, BH);
+      general.input[7]->callback(general_options_ok_cb);
+      general.input[8] = new Fl_Input
+        (L + 2 * WB + 2*IW/3, 2 * WB + 4 * BH, IW/3, BH, "Axes labels");
+      general.input[8]->align(FL_ALIGN_RIGHT);
+      general.input[8]->callback(general_options_ok_cb);
+
+      general.butt[0] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 5 * BH, BW, BH,
+         "Set position and size of axes automatically");
+      general.butt[0]->type(FL_TOGGLE_BUTTON);
+      general.butt[0]->callback(general_options_ok_cb, (void*)"general_axes_auto");
+      
+      general.value[20] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 6 * BH, IW / 3, BH);
+      general.value[20]->callback(general_options_ok_cb);
+      general.value[21] = new Fl_Value_Input
+        (L + 2 * WB + IW / 3, 2 * WB + 6 * BH, IW / 3, BH);
+      general.value[21]->callback(general_options_ok_cb);
+      general.value[22] = new Fl_Value_Input
+        (L + 2 * WB + 2 * IW / 3, 2 * WB + 6 * BH, IW / 3, BH, "Axes minimum");
+      general.value[22]->align(FL_ALIGN_RIGHT);
+      general.value[22]->callback(general_options_ok_cb);
+
+      general.value[23] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 7 * BH, IW / 3, BH);
+      general.value[23]->callback(general_options_ok_cb);
+      general.value[24] = new Fl_Value_Input
+        (L + 2 * WB + IW / 3, 2 * WB + 7 * BH, IW / 3, BH);
+      general.value[24]->callback(general_options_ok_cb);
+      general.value[25] = new Fl_Value_Input
+        (L + 2 * WB + 2 * IW / 3, 2 * WB + 7 * BH, IW / 3, BH, "Axes maximum");
+      general.value[25]->align(FL_ALIGN_RIGHT);
+      general.value[25]->callback(general_options_ok_cb);
+
+      general.butt[1] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 8 * BH, BW, BH, "Show small axes");
+      general.butt[1]->tooltip("(Alt+Shift+a)");
+      general.butt[1]->type(FL_TOGGLE_BUTTON);
+      general.butt[1]->callback(general_options_ok_cb, (void*)"general_small_axes");
+
+      general.value[26] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 9 * BH, IW / 2, BH);
+      general.value[26]->minimum(-2000);
+      general.value[26]->maximum(2000);
+      general.value[26]->step(1);
+      general.value[26]->callback(general_options_ok_cb);
+      general.value[27] = new Fl_Value_Input
+        (L + 2 * WB + IW / 2, 2 * WB + 9 * BH, IW / 2, BH, "Small axes position");
+      general.value[27]->align(FL_ALIGN_RIGHT);
+      general.value[27]->minimum(-2000);
+      general.value[27]->maximum(2000);
+      general.value[27]->step(1);
+      general.value[27]->callback(general_options_ok_cb);
+
+      o->end();
+    }
+    {
+      Fl_Group *o = new Fl_Group
+        (L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Output");
+      general.butt[7] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 1 * BH, BW, BH, "Print messages on terminal");
+      general.butt[7]->type(FL_TOGGLE_BUTTON);
+      general.butt[7]->callback(general_options_ok_cb);
+
+      general.butt[8] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 2 * BH, BW, BH, "Save session information on exit");
+      general.butt[8]->type(FL_TOGGLE_BUTTON);
+      general.butt[8]->callback(general_options_ok_cb);
+
+      general.butt[9] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 3 * BH, BW/2-WB, BH, "Save options on exit");
+      general.butt[9]->type(FL_TOGGLE_BUTTON);
+      general.butt[9]->callback(general_options_ok_cb);
+
+      Fl_Button *b0 = new Fl_Button
+        (L + width / 2, 2 * WB + 3 * BH, (int)(1.75*BB), BH, "Restore default options");
+      b0->callback(options_restore_defaults_cb);
+
+      general.butt[14] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 4 * BH, BW, BH,
+         "Ask confirmation before overwriting files");
+      general.butt[14]->type(FL_TOGGLE_BUTTON);
+      general.butt[14]->callback(general_options_ok_cb);
+
+      general.value[5] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Message verbosity");
+      general.value[5]->minimum(0);
+      general.value[5]->maximum(10);
+      general.value[5]->step(1);
+      general.value[5]->align(FL_ALIGN_RIGHT);
+      general.value[5]->callback(general_options_ok_cb);
+
+      general.input[0] = new Fl_Input
+        (L + 2 * WB, 2 * WB + 6 * BH, IW, BH, "Default file name");
+      general.input[0]->align(FL_ALIGN_RIGHT);
+      general.input[0]->callback(general_options_ok_cb);
+
+      o->end();
+    }
+    {
+      Fl_Group *o = new Fl_Group
+        (L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Helpers");
+
+      general.input[1] = new Fl_Input
+        (L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "Text editor command");
+      general.input[1]->align(FL_ALIGN_RIGHT);
+      general.input[1]->callback(general_options_ok_cb);
+
+      general.input[2] = new Fl_Input
+        (L + 2 * WB, 2 * WB + 2 * BH, IW, BH, "Web browser command");
+      general.input[2]->align(FL_ALIGN_RIGHT);
+      general.input[2]->callback(general_options_ok_cb);
+
+      o->end();
+    }
+    {
+      Fl_Group *o = new Fl_Group
+        (L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Aspect");
+      o->hide();
+
+      static Fl_Menu_Item menu_projection[] = {
+        {"Orthographic", 0, 0, 0},
+        {"Perspective", 0, 0, 0},
+        {0}
+      };
+      general.choice[2] = new Fl_Choice
+        (L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "Projection mode");
+      general.choice[2]->menu(menu_projection);
+      general.choice[2]->align(FL_ALIGN_RIGHT);
+      general.choice[2]->tooltip("(Alt+o)");
+      general.choice[2]->callback(general_options_ok_cb);
+
+      general.value[14] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 2 * BH, IW, BH, "Z-clipping distance factor");
+      general.value[14]->minimum(0.1);
+      general.value[14]->maximum(10.);
+      general.value[14]->step(0.1);
+      general.value[14]->align(FL_ALIGN_RIGHT);
+      general.value[14]->callback(general_options_ok_cb);
+
+      general.value[15] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 3 * BH, IW/2, BH);
+      general.value[15]->minimum(0.);
+      general.value[15]->maximum(10.);
+      general.value[15]->step(0.01);
+      general.value[15]->align(FL_ALIGN_RIGHT);
+      general.value[15]->callback(general_options_ok_cb);
+
+      general.value[16] = new Fl_Value_Input
+        (L + 2 * WB + IW/2, 2 * WB + 3 * BH, IW/2, BH, "Polygon offset factor/units");
+      general.value[16]->minimum(0.);
+      general.value[16]->maximum(10.);
+      general.value[16]->step(0.01);
+      general.value[16]->align(FL_ALIGN_RIGHT);
+      general.value[16]->callback(general_options_ok_cb);
+
+      general.butt[4] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 4 * BH, BW, BH, "Always apply polygon offset");
+      general.butt[4]->type(FL_TOGGLE_BUTTON);
+      general.butt[4]->callback(general_options_ok_cb);
+
+      general.value[11] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Quadric subdivisions");
+      general.value[11]->minimum(3);
+      general.value[11]->maximum(30);
+      general.value[11]->step(1);
+      general.value[11]->align(FL_ALIGN_RIGHT);
+      general.value[11]->callback(general_options_ok_cb);
+
+      general.value[6] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 6 * BH, IW, BH, "Point size");
+      general.value[6]->minimum(0.1);
+      general.value[6]->maximum(50);
+      general.value[6]->step(0.1);
+      general.value[6]->align(FL_ALIGN_RIGHT);
+      general.value[6]->callback(general_options_ok_cb);
+
+      general.value[7] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 7 * BH, IW, BH, "Line width");
+      general.value[7]->minimum(0.1);
+      general.value[7]->maximum(50);
+      general.value[7]->step(0.1);
+      general.value[7]->align(FL_ALIGN_RIGHT);
+      general.value[7]->callback(general_options_ok_cb);
+      
+      static Fl_Menu_Item menu_genvectype[] = {
+        {"Line", 0, 0, 0},
+        {"Arrow", 0, 0, 0},
+        {"Pyramid", 0, 0, 0},
+        {"3D arrow", 0, 0, 0},
+        {0}
+      };
+      general.choice[0] = new Fl_Choice
+        (L + 2 * WB, 2 * WB + 8 * BH, IW, BH, "Vector display");
+      general.choice[0]->menu(menu_genvectype);
+      general.choice[0]->align(FL_ALIGN_RIGHT);
+      general.choice[0]->callback(general_options_ok_cb);
+
+      Fl_Button *b = new Fl_Button
+        (L + 2 * IW - 2 * WB, 2 * WB + 8 * BH, BB, BH, "Edit arrow");
+      b->callback(general_arrow_param_cb);
+
+      general.choice[1] = new Fl_Choice
+        (L + 2 * WB, 2 * WB + 9 * BH, IW, BH, "Font");
+      general.choice[1]->menu(menu_font_names);
+      general.choice[1]->align(FL_ALIGN_RIGHT);
+      general.choice[1]->callback(general_options_ok_cb);
+
+      general.value[12] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 10 * BH, IW, BH, "Font size");
+      general.value[12]->minimum(5);
+      general.value[12]->maximum(40);
+      general.value[12]->step(1);
+      general.value[12]->align(FL_ALIGN_RIGHT);
+      general.value[12]->callback(general_options_ok_cb);
+
+      o->end();
+    }
+    {
+      Fl_Group *o = new Fl_Group
+        (L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Color");
+      o->hide();
+
+      general.value[2] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 1 * BH, IW/3, BH);
+      general.value[2]->minimum(-1.);
+      general.value[2]->maximum(1.);
+      general.value[2]->step(0.01);
+      general.value[2]->callback(general_options_ok_cb, (void*)"light_value");
+
+      general.value[3] = new Fl_Value_Input
+        (L + 2 * WB + IW / 3, 2 * WB + 1 * BH, IW/3, BH);
+      general.value[3]->minimum(-1.);
+      general.value[3]->maximum(1.);
+      general.value[3]->step(0.01);
+      general.value[3]->callback(general_options_ok_cb, (void*)"light_value");
+
+      general.value[4] = new Fl_Value_Input
+        (L + 2 * WB + 2 * IW / 3, 2 * WB + 1 * BH, IW/3, BH, "Light position");
+      general.value[4]->minimum(-1.);
+      general.value[4]->maximum(1.);
+      general.value[4]->step(0.01);
+      general.value[4]->align(FL_ALIGN_RIGHT);
+      general.value[4]->callback(general_options_ok_cb, (void*)"light_value");
+
+      general.value[13] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 2 * BH, IW, BH, "Light position divisor");
+      general.value[13]->minimum(0.);
+      general.value[13]->maximum(1.);
+      general.value[13]->step(0.01);
+      general.value[13]->align(FL_ALIGN_RIGHT);
+      general.value[13]->callback(general_options_ok_cb);
+
+      general.sphere = new spherePositionWidget
+        (L + width - 2 * BH - 2 * WB, 2 * WB + 1 * BH, 2 * BH);
+      general.sphere->callback(general_options_ok_cb, (void*)"light_sphere");
+
+      general.value[1] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 3 * BH, IW/2, BH);
+      general.value[1]->minimum(0);
+      general.value[1]->maximum(10);
+      general.value[1]->step(0.1);
+      general.value[1]->callback(general_options_ok_cb);
+      general.value[0] = new Fl_Value_Input
+        (L + 2 * WB + IW/2, 2 * WB + 3 * BH, IW/2, BH, "Material shininess/exponent");
+      general.value[0]->minimum(0);
+      general.value[0]->maximum(128);
+      general.value[0]->step(1);
+      general.value[0]->align(FL_ALIGN_RIGHT);
+      general.value[0]->callback(general_options_ok_cb);
+
+      static Fl_Menu_Item menu_color_scheme[] = {
+        {"Dark", 0, 0, 0},
+        {"Light", 0, 0, 0},
+        {"Grayscale", 0, 0, 0},
+        {0}
+      };
+
+      general.choice[3] = new Fl_Choice
+        (L + 2 * WB, 2 * WB + 4 * BH, IW, BH, "Predefined color scheme");
+      general.choice[3]->menu(menu_color_scheme);
+      general.choice[3]->align(FL_ALIGN_RIGHT);
+      general.choice[3]->tooltip("(Alt+c)");
+      general.choice[3]->callback(general_options_color_scheme_cb);
+
+      static Fl_Menu_Item menu_bg_grad[] = {
+        {"None", 0, 0, 0},
+        {"Vertical", 0, 0, 0},
+        {"Horizontal", 0, 0, 0},
+        {"Radial", 0, 0, 0},
+        {0}
+      };
+
+      general.choice[5] = new Fl_Choice
+        (L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Background gradient");
+      general.choice[5]->menu(menu_bg_grad);
+      general.choice[5]->align(FL_ALIGN_RIGHT);
+      general.choice[5]->callback(general_options_ok_cb);
+
+      Fl_Scroll *s = new Fl_Scroll
+        (L + 2 * WB, 3 * WB + 6 * BH, IW + 20, height - 5 * WB - 6 * BH);
+      int i = 0;
+      while(GeneralOptions_Color[i].str) {
+        general.color[i] = new Fl_Button
+          (L + 2 * WB, 3 * WB + (6 + i) * BH, IW, BH, GeneralOptions_Color[i].str);
+        general.color[i]->callback(color_cb, (void *)GeneralOptions_Color[i].function);
+        i++;
+      }
+      s->end();
+
+      o->end();
+    }
+    o->end();
+  }
+  general.group->end();
+
+  // Geometry options
+  geo.group = new Fl_Group(L, 0, width, height, "Geometry Options");
+  geo.group->hide();
+  {
+    Fl_Tabs *o = new Fl_Tabs(L + WB, WB, width - 2 * WB, height - 2 * WB);
+    {
+      Fl_Group *o = new Fl_Group
+        (L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "General");
+      o->hide();
+
+      geo.value[2] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "Geometry tolerance");
+      geo.value[2]->align(FL_ALIGN_RIGHT);
+      geo.value[2]->callback(geometry_options_ok_cb);
+
+      geo.butt[8] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 2 * BH, BW, BH, "Remove duplicate entities in GEO models");
+      geo.butt[8]->type(FL_TOGGLE_BUTTON);
+      geo.butt[8]->callback(geometry_options_ok_cb);
+
+      geo.butt[11] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 3 * BH, BW, BH, "Remove small edges in OpenCascade models");
+      geo.butt[11]->type(FL_TOGGLE_BUTTON);
+      geo.butt[11]->callback(geometry_options_ok_cb);
+
+      geo.butt[12] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 4 * BH, BW, BH, "Remove small faces in OpenCascade models");
+      geo.butt[12]->type(FL_TOGGLE_BUTTON);
+      geo.butt[12]->callback(geometry_options_ok_cb);
+
+      geo.butt[13] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 5 * BH, BW, BH, "Sew faces in OpenCascade models");
+      geo.butt[13]->type(FL_TOGGLE_BUTTON);
+      geo.butt[13]->callback(geometry_options_ok_cb);
+
+#if !defined(HAVE_OCC)
+      geo.butt[11]->deactivate();
+      geo.butt[12]->deactivate();
+      geo.butt[13]->deactivate();
+#endif
+      o->end();
+    }
+    {
+      Fl_Group *o = new Fl_Group
+        (L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Visibility");
+
+      geo.butt[0] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 1 * BH, BW / 2 - WB, BH, "Points");
+      geo.butt[0]->tooltip("(Alt+p)");
+      geo.butt[0]->type(FL_TOGGLE_BUTTON);
+      geo.butt[0]->callback(geometry_options_ok_cb);
+      
+      geo.butt[1] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 2 * BH, BW / 2 - WB, BH, "Lines");
+      geo.butt[1]->tooltip("(Alt+l)");
+      geo.butt[1]->type(FL_TOGGLE_BUTTON);
+      geo.butt[1]->callback(geometry_options_ok_cb);
+
+      geo.butt[2] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 3 * BH, BW / 2 - WB, BH, "Surfaces");
+      geo.butt[2]->tooltip("(Alt+s)");
+      geo.butt[2]->type(FL_TOGGLE_BUTTON);
+      geo.butt[2]->callback(geometry_options_ok_cb);
+
+      geo.butt[3] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 4 * BH, BW / 2 - WB, BH, "Volumes");
+      geo.butt[3]->tooltip("(Alt+v)");
+      geo.butt[3]->type(FL_TOGGLE_BUTTON);
+      geo.butt[3]->callback(geometry_options_ok_cb);
+
+      geo.butt[4] = new Fl_Check_Button
+        (L + width / 2, 2 * WB + 1 * BH, BW / 2 - WB, BH, "Point numbers");
+      geo.butt[4]->type(FL_TOGGLE_BUTTON);
+      geo.butt[4]->callback(geometry_options_ok_cb);
+
+      geo.butt[5] = new Fl_Check_Button
+        (L + width / 2, 2 * WB + 2 * BH, BW / 2 - WB, BH, "Line numbers");
+      geo.butt[5]->type(FL_TOGGLE_BUTTON);
+      geo.butt[5]->callback(geometry_options_ok_cb);
+
+      geo.butt[6] = new Fl_Check_Button
+        (L + width / 2, 2 * WB + 3 * BH, BW / 2 - WB, BH, "Surface numbers");
+      geo.butt[6]->type(FL_TOGGLE_BUTTON);
+      geo.butt[6]->callback(geometry_options_ok_cb);
+
+      geo.butt[7] = new Fl_Check_Button
+        (L + width / 2, 2 * WB + 4 * BH, BW / 2 - WB, BH, "Volume numbers");
+      geo.butt[7]->type(FL_TOGGLE_BUTTON);
+      geo.butt[7]->callback(geometry_options_ok_cb);
+
+      geo.value[0] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Normals");
+      geo.value[0]->minimum(0);
+      geo.value[0]->maximum(500);
+      geo.value[0]->step(1);
+      geo.value[0]->align(FL_ALIGN_RIGHT);
+      geo.value[0]->when(FL_WHEN_RELEASE);
+      geo.value[0]->callback(geometry_options_ok_cb);
+
+      geo.value[1] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 6 * BH, IW, BH, "Tangents");
+      geo.value[1]->minimum(0);
+      geo.value[1]->maximum(500);
+      geo.value[1]->step(1);
+      geo.value[1]->align(FL_ALIGN_RIGHT);
+      geo.value[1]->when(FL_WHEN_RELEASE);
+      geo.value[1]->callback(geometry_options_ok_cb);
+
+      o->end();
+    }
+    {
+      Fl_Group *o = new Fl_Group
+        (L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Aspect");
+      o->hide();
+
+      geo.choice[0] = new Fl_Choice
+        (L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "Point display");
+      geo.choice[0]->menu(menu_point_display);
+      geo.choice[0]->align(FL_ALIGN_RIGHT);
+      geo.choice[0]->callback(geometry_options_ok_cb);
+
+      geo.value[3] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 2 * BH, IW, BH, "Point size");
+      geo.value[3]->minimum(0.1);
+      geo.value[3]->maximum(50);
+      geo.value[3]->step(0.1);
+      geo.value[3]->align(FL_ALIGN_RIGHT);
+      geo.value[3]->callback(geometry_options_ok_cb);
+
+      geo.value[5] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 3 * BH, IW, BH, "Selected point size");
+      geo.value[5]->minimum(0.1);
+      geo.value[5]->maximum(50);
+      geo.value[5]->step(0.1);
+      geo.value[5]->align(FL_ALIGN_RIGHT);
+      geo.value[5]->callback(geometry_options_ok_cb);
+
+      geo.choice[1] = new Fl_Choice
+        (L + 2 * WB, 2 * WB + 4 * BH, IW, BH, "Line display");
+      geo.choice[1]->menu(menu_line_display);
+      geo.choice[1]->align(FL_ALIGN_RIGHT);     
+      geo.choice[1]->callback(geometry_options_ok_cb);
+
+      geo.value[4] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Line width");
+      geo.value[4]->minimum(0.1);
+      geo.value[4]->maximum(50);
+      geo.value[4]->step(0.1);
+      geo.value[4]->align(FL_ALIGN_RIGHT);
+      geo.value[4]->callback(geometry_options_ok_cb);
+
+      geo.value[6] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 6 * BH, IW, BH, "Selected line width");
+      geo.value[6]->minimum(0.1);
+      geo.value[6]->maximum(50);
+      geo.value[6]->step(0.1);
+      geo.value[6]->align(FL_ALIGN_RIGHT);
+      geo.value[6]->callback(geometry_options_ok_cb);
+
+      geo.choice[2] = new Fl_Choice
+        (L + 2 * WB, 2 * WB + 7 * BH, IW, BH, "Surface display");
+      geo.choice[2]->menu(menu_surface_display);
+      geo.choice[2]->align(FL_ALIGN_RIGHT);     
+      geo.choice[2]->callback(geometry_options_ok_cb);
+      geo.choice[2]->tooltip("(Alt+d)");
+
+      o->end();
+    }
+    {
+      Fl_Group *o = new Fl_Group
+        (L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Color");
+      o->hide();
+
+      geo.butt[9] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 1 * BH, BW, BH, "Enable lighting");
+      geo.butt[9]->type(FL_TOGGLE_BUTTON);
+      geo.butt[9]->tooltip("(Alt+w)");
+      geo.butt[9]->callback(geometry_options_ok_cb);
+
+      geo.butt[14] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 2 * BH, BW, BH, "Use two-side lighting");
+      geo.butt[14]->type(FL_TOGGLE_BUTTON);
+      geo.butt[14]->callback(geometry_options_ok_cb);
+
+      geo.butt[10] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 3 * BH, BW, BH, "Highlight orphan entities");
+      geo.butt[10]->type(FL_TOGGLE_BUTTON);
+      geo.butt[10]->callback(geometry_options_ok_cb);
+
+      Fl_Scroll *s = new Fl_Scroll
+        (L + 2 * WB, 2 * WB + 4 * BH, IW + 20, height - 4 * WB - 4 * BH);
+      int i = 0;
+      while(GeometryOptions_Color[i].str) {
+        geo.color[i] = new Fl_Button
+          (L + 2 * WB, 2 * WB + (4 + i) * BH, IW, BH, GeometryOptions_Color[i].str);
+        geo.color[i]->callback(color_cb, (void *)GeometryOptions_Color[i].function);
+        i++;
+      }
+      s->end();
+
+      o->end();
+    }
+    o->end();
+  }
+  geo.group->end();
+
+  // Mesh options
+  mesh.group = new Fl_Group(L, 0, width, height, "Mesh Options");
+  mesh.group->hide();
+  {
+    Fl_Tabs *o = new Fl_Tabs(L + WB, WB, width - 2 * WB, height - 2 * WB);
+    {
+      Fl_Group *o = new Fl_Group
+        (L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "General");
+      o->hide();
+
+      static Fl_Menu_Item menu_2d_algo[] = {
+        {"Frontal", 0, 0, 0},
+        {"Delaunay", 0, 0, 0},
+        {"MeshAdapt+Delaunay", 0, 0, 0},
+        {0}
+      };
+      static Fl_Menu_Item menu_3d_algo[] = {
+        {"Tetgen+Delaunay", 0, 0, 0},
+        {"Netgen", 0, 0, 0},
+        {0}
+      };
+      static Fl_Menu_Item menu_recombine_algo[] = {
+        {"Mixed Tri-Quads", 0, 0, 0},
+        {"All Quads", 0, 0, 0},
+        {0}
+      };
+
+      mesh.choice[2] = new Fl_Choice
+        (L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "2D algorithm");
+      mesh.choice[2]->menu(menu_2d_algo);
+      mesh.choice[2]->align(FL_ALIGN_RIGHT);
+      mesh.choice[2]->callback(mesh_options_ok_cb);
+
+      mesh.choice[3] = new Fl_Choice
+        (L + 2 * WB, 2 * WB + 2 * BH, IW, BH, "3D algorithm");
+      mesh.choice[3]->menu(menu_3d_algo);
+      mesh.choice[3]->align(FL_ALIGN_RIGHT);
+      mesh.choice[3]->callback(mesh_options_ok_cb);
+
+      mesh.choice[5] = new Fl_Choice
+        (L + 2 * WB, 2 * WB + 3 * BH, IW, BH, "Recombine algorithm");
+      mesh.choice[5]->menu(menu_recombine_algo);
+      mesh.choice[5]->align(FL_ALIGN_RIGHT);
+      mesh.choice[5]->callback(mesh_options_ok_cb);
+
+      mesh.value[0] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 4 * BH, IW, BH, "Smoothing steps");
+      mesh.value[0]->minimum(0);
+      mesh.value[0]->maximum(100);
+      mesh.value[0]->step(1);
+      mesh.value[0]->align(FL_ALIGN_RIGHT);
+      mesh.value[0]->callback(mesh_options_ok_cb);
+
+      mesh.value[2] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Element size factor");
+      mesh.value[2]->minimum(0.001);
+      mesh.value[2]->maximum(1000);
+      mesh.value[2]->step(0.01);
+      mesh.value[2]->align(FL_ALIGN_RIGHT);
+      mesh.value[2]->callback(mesh_options_ok_cb);
+
+      mesh.value[25] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 6 * BH, IW, BH, "Minimum element size");
+      mesh.value[25]->align(FL_ALIGN_RIGHT);
+      mesh.value[25]->callback(mesh_options_ok_cb);
+
+      mesh.value[26] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 7 * BH, IW, BH, "Maximum element size");
+      mesh.value[26]->align(FL_ALIGN_RIGHT);
+      mesh.value[26]->callback(mesh_options_ok_cb);
+
+      mesh.value[3] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 8 * BH, IW, BH, "Element order");
+      mesh.value[3]->minimum(1);
+      // FIXME: this makes it possible to set > 2 by hand, but not by
+      // dragging (>2 is too buggy for general use)
+      mesh.value[3]->maximum(2);
+      mesh.value[3]->step(1);
+      mesh.value[3]->align(FL_ALIGN_RIGHT);
+      mesh.value[3]->callback(mesh_options_ok_cb);
+
+      mesh.butt[4] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 9 * BH, BW, BH, "Use incomplete high order elements");
+      mesh.butt[4]->type(FL_TOGGLE_BUTTON);
+      mesh.butt[4]->callback(mesh_options_ok_cb);
+
+      o->end();
+    }
+
+    {
+      Fl_Group *o = new Fl_Group
+        (L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Advanced");
+      o->hide();
+
+      mesh.butt[5] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 1 * BH, BW, BH, "Compute element sizes using point values");
+      mesh.butt[5]->type(FL_TOGGLE_BUTTON);
+      mesh.butt[5]->callback(mesh_options_ok_cb);
+
+      mesh.butt[1] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 2 * BH, BW, BH, "Compute element sizes from curvature" );
+      mesh.butt[1]->type(FL_TOGGLE_BUTTON);
+      mesh.butt[1]->callback(mesh_options_ok_cb);
+
+      mesh.butt[16] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 3 * BH, BW, BH, "Extend element sizes from boundary");
+      mesh.butt[16]->type(FL_TOGGLE_BUTTON);
+      mesh.butt[16]->callback(mesh_options_ok_cb);
+
+      mesh.butt[2] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 4 * BH, BW, BH, "Optimize quality of tetrahedra");
+      mesh.butt[2]->type(FL_TOGGLE_BUTTON);
+      mesh.butt[2]->callback(mesh_options_ok_cb);
+
+      mesh.butt[24] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 5 * BH, BW, BH, "Optimize quality of tetrahedra with Netgen");
+      mesh.butt[24]->type(FL_TOGGLE_BUTTON);
+#if !defined(HAVE_NETGEN)
+      mesh.butt[24]->deactivate();
+#endif
+      mesh.butt[24]->callback(mesh_options_ok_cb);
+
+      mesh.butt[3] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 6 * BH, BW, BH, "Optimize high order mesh (2D-plane only)");
+      mesh.butt[3]->type(FL_TOGGLE_BUTTON);
+      mesh.butt[3]->callback(mesh_options_ok_cb);
+
+      mesh.butt[21] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 7 * BH, BW, BH, "Impose C1 continuity (2D-plane only)");
+      mesh.butt[21]->type(FL_TOGGLE_BUTTON);
+      mesh.butt[21]->callback(mesh_options_ok_cb);
+
+      o->end();
+    }
+
+    {
+      Fl_Group *o = new Fl_Group
+        (L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Visibility");
+
+      mesh.butt[6] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 1 * BH, BW / 2 - WB, BH, "Nodes");
+      mesh.butt[6]->tooltip("(Alt+Shift+p)");
+      mesh.butt[6]->type(FL_TOGGLE_BUTTON);
+      mesh.butt[6]->callback(mesh_options_ok_cb);
+
+      mesh.butt[7] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 2 * BH, BW / 2 - WB, BH, "Lines");
+      mesh.butt[7]->tooltip("(Alt+Shift+l)");
+      mesh.butt[7]->type(FL_TOGGLE_BUTTON);
+      mesh.butt[7]->callback(mesh_options_ok_cb);
+
+      mesh.butt[8] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 3 * BH, BW / 2 - WB, BH, "Surface edges");
+      mesh.butt[8]->tooltip("(Alt+Shift+s)");
+      mesh.butt[8]->type(FL_TOGGLE_BUTTON);
+      mesh.butt[8]->callback(mesh_options_ok_cb);
+
+      mesh.butt[9] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 4 * BH, BW / 2 - WB, BH, "Surface faces");
+      mesh.butt[9]->tooltip("(Alt+Shift+d)");
+      mesh.butt[9]->type(FL_TOGGLE_BUTTON);
+      mesh.butt[9]->callback(mesh_options_ok_cb);
+
+      mesh.butt[10] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 5 * BH, BW / 2 - WB, BH, "Volume edges");
+      mesh.butt[10]->tooltip("(Alt+Shift+v)");
+      mesh.butt[10]->type(FL_TOGGLE_BUTTON);
+      mesh.butt[10]->callback(mesh_options_ok_cb);
+
+      mesh.butt[11] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 6 * BH, BW / 2 - WB, BH, "Volume faces");
+      mesh.butt[11]->tooltip("(Alt+Shift+b)");
+      mesh.butt[11]->type(FL_TOGGLE_BUTTON);
+      mesh.butt[11]->callback(mesh_options_ok_cb);
+
+      mesh.butt[12] = new Fl_Check_Button
+        (L + width / 2, 2 * WB + 1 * BH, BW / 2 - WB, BH, "Node labels");
+      mesh.butt[12]->type(FL_TOGGLE_BUTTON);
+      mesh.butt[12]->callback(mesh_options_ok_cb);
+
+      mesh.butt[13] = new Fl_Check_Button
+        (L + width / 2, 2 * WB + 2 * BH, BW / 2 - WB, BH, "Line labels");
+      mesh.butt[13]->type(FL_TOGGLE_BUTTON);
+      mesh.butt[13]->callback(mesh_options_ok_cb);
+
+      mesh.butt[14] = new Fl_Check_Button
+        (L + width / 2, 2 * WB + 3 * BH, BW / 2 - WB, BH, "Surface labels");
+      mesh.butt[14]->type(FL_TOGGLE_BUTTON);
+      mesh.butt[14]->callback(mesh_options_ok_cb);
+
+      mesh.butt[15] = new Fl_Check_Button
+        (L + width / 2, 2 * WB + 4 * BH, BW / 2 - WB, BH, "Volume labels");
+      mesh.butt[15]->type(FL_TOGGLE_BUTTON);
+      mesh.butt[15]->callback(mesh_options_ok_cb);
+
+      static Fl_Menu_Item menu_label_type[] = {
+        {"Number", 0, 0, 0},
+        {"Elementary entity", 0, 0, 0},
+        {"Physical group", 0, 0, 0},
+        {"Mesh partition", 0, 0, 0},
+        {"Coordinates", 0, 0, 0},
+        {0}
+      };
+      mesh.choice[7] = new Fl_Choice
+        (L + width / 2, 2 * WB + 5 * BH, width / 4 - 2 * WB, BH, "Label type");
+      mesh.choice[7]->menu(menu_label_type);
+      mesh.choice[7]->align(FL_ALIGN_RIGHT);
+      mesh.choice[7]->callback(mesh_options_ok_cb);
+
+      mesh.value[12] = new Fl_Value_Input
+        (L + width / 2, 2 * WB + 6 * BH, width / 4 - 2 * WB, BH, "Frequency");
+      mesh.value[12]->minimum(0);
+      mesh.value[12]->maximum(100);
+      mesh.value[12]->step(1);
+      mesh.value[12]->align(FL_ALIGN_RIGHT);
+      mesh.value[12]->when(FL_WHEN_RELEASE);
+      mesh.value[12]->callback(mesh_options_ok_cb);
+
+      static Fl_Menu_Item menu_mesh_element_types[] = {
+        {"Triangles",   0, 0, 0, FL_MENU_TOGGLE},
+        {"Quadrangles", 0, 0, 0, FL_MENU_TOGGLE},
+        {"Tetrahedra",  0, 0, 0, FL_MENU_TOGGLE},
+        {"Hexahedra",   0, 0, 0, FL_MENU_TOGGLE},
+        {"Prisms",      0, 0, 0, FL_MENU_TOGGLE},
+        {"Pyramids",    0, 0, 0, FL_MENU_TOGGLE},
+        {0}
+      };
+
+      mesh.menu = new Fl_Menu_Button
+        (L + 2 * WB, 2 * WB + 7 * BH, IW, BH, "Elements");
+      mesh.menu->menu(menu_mesh_element_types);
+      mesh.menu->callback(mesh_options_ok_cb);
+
+      mesh.value[4] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 8 * BH, IW / 4, BH);
+      mesh.value[4]->minimum(0);
+      mesh.value[4]->maximum(1);
+      mesh.value[4]->step(0.01);
+      mesh.value[4]->align(FL_ALIGN_RIGHT);
+      mesh.value[4]->when(FL_WHEN_RELEASE);
+      mesh.value[4]->callback(mesh_options_ok_cb);
+
+      mesh.value[5] = new Fl_Value_Input
+        (L + 2 * WB + IW / 4, 2 * WB + 8 * BH, IW / 2 - IW / 4, BH);
+      mesh.value[5]->minimum(0);
+      mesh.value[5]->maximum(1);
+      mesh.value[5]->step(0.01);
+      mesh.value[5]->align(FL_ALIGN_RIGHT);
+      mesh.value[5]->when(FL_WHEN_RELEASE);
+      mesh.value[5]->callback(mesh_options_ok_cb);
+
+      static Fl_Menu_Item menu_quality_type[] = {
+        {"Gamma", 0, 0, 0},
+        {"Eta", 0, 0, 0},
+        {"Rho", 0, 0, 0},
+        {"Disto", 0, 0, 0},
+        {0}
+      };
+      mesh.choice[6] = new Fl_Choice
+        (L + 2 * WB + IW / 2, 2 * WB + 8 * BH, IW/2, BH, "Quality range");
+      mesh.choice[6]->menu(menu_quality_type);
+      mesh.choice[6]->align(FL_ALIGN_RIGHT);
+      mesh.choice[6]->callback(mesh_options_ok_cb);
+
+      mesh.value[6] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 9 * BH, IW / 2, BH);
+      mesh.value[6]->align(FL_ALIGN_RIGHT);
+      mesh.value[6]->when(FL_WHEN_RELEASE);
+      mesh.value[6]->callback(mesh_options_ok_cb);
+
+      mesh.value[7] = new Fl_Value_Input
+        (L + 2 * WB + IW / 2, 2 * WB + 9 * BH, IW / 2, BH, "Size range");
+      mesh.value[7]->align(FL_ALIGN_RIGHT);
+      mesh.value[7]->when(FL_WHEN_RELEASE);
+      mesh.value[7]->callback(mesh_options_ok_cb);
+
+      mesh.value[8] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 10 * BH, IW, BH, "Normals");
+      mesh.value[8]->minimum(0);
+      mesh.value[8]->maximum(500);
+      mesh.value[8]->step(1);
+      mesh.value[8]->align(FL_ALIGN_RIGHT);
+      mesh.value[8]->when(FL_WHEN_RELEASE);
+      mesh.value[8]->callback(mesh_options_ok_cb);
+
+      mesh.value[13] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 11 * BH, IW, BH, "Tangents");
+      mesh.value[13]->minimum(0);
+      mesh.value[13]->maximum(200);
+      mesh.value[13]->step(1.0);
+      mesh.value[13]->align(FL_ALIGN_RIGHT);
+      mesh.value[13]->when(FL_WHEN_RELEASE);
+      mesh.value[13]->callback(mesh_options_ok_cb);
+
+      o->end();
+    }
+    {
+      Fl_Group *o = new Fl_Group
+        (L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Aspect");
+      o->hide();
+
+      mesh.value[9] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "Element shrinking factor");
+      mesh.value[9]->minimum(0);
+      mesh.value[9]->maximum(1);
+      mesh.value[9]->step(0.01);
+      mesh.value[9]->align(FL_ALIGN_RIGHT);
+      mesh.value[9]->when(FL_WHEN_RELEASE);
+      mesh.value[9]->callback(mesh_options_ok_cb);
+
+      mesh.choice[0] = new Fl_Choice
+        (L + 2 * WB, 2 * WB + 2 * BH, IW, BH, "Point display");
+      mesh.choice[0]->menu(menu_point_display);
+      mesh.choice[0]->align(FL_ALIGN_RIGHT);
+      mesh.choice[0]->callback(mesh_options_ok_cb);
+
+      mesh.value[10] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 3 * BH, IW, BH, "Point size");
+      mesh.value[10]->minimum(0.1);
+      mesh.value[10]->maximum(50);
+      mesh.value[10]->step(0.1);
+      mesh.value[10]->align(FL_ALIGN_RIGHT);
+      mesh.value[10]->callback(mesh_options_ok_cb);
+
+      mesh.value[11] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 4 * BH, IW, BH, "Line width");
+      mesh.value[11]->minimum(0.1);
+      mesh.value[11]->maximum(50);
+      mesh.value[11]->step(0.1);
+      mesh.value[11]->align(FL_ALIGN_RIGHT);
+      mesh.value[11]->callback(mesh_options_ok_cb);
+
+      o->end();
+    }
+    {
+      Fl_Group *o = new Fl_Group
+        (L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Color");
+      o->hide();
+
+      mesh.butt[17] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 1 * BH, BW, BH, "Enable lighting");
+      mesh.butt[17]->tooltip("(Alt+w)");
+      mesh.butt[17]->type(FL_TOGGLE_BUTTON);
+      mesh.butt[17]->callback(mesh_options_ok_cb, (void*)"mesh_light");
+
+      mesh.butt[20] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 2 * BH, BW, BH, "Enable lighting of lines");
+      mesh.butt[20]->type(FL_TOGGLE_BUTTON);
+      mesh.butt[20]->callback(mesh_options_ok_cb);
+
+      mesh.butt[18] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 3 * BH, BW, BH, "Use two-side lighting");
+      mesh.butt[18]->type(FL_TOGGLE_BUTTON);
+      mesh.butt[18]->callback(mesh_options_ok_cb);
+
+      mesh.butt[0] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 4 * BH, BW, BH, "Reverse all normals");
+      mesh.butt[0]->tooltip("(Alt+Shift+w)");
+      mesh.butt[0]->type(FL_TOGGLE_BUTTON);
+      mesh.butt[0]->callback(mesh_options_ok_cb);
+
+      mesh.butt[19] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 5 * BH, BW, BH, "Smooth normals");
+      mesh.butt[19]->type(FL_TOGGLE_BUTTON);
+      mesh.butt[19]->callback(mesh_options_ok_cb);
+
+      mesh.value[18] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 6 * BH, IW, BH, "Smoothing threshold angle");
+      mesh.value[18]->minimum(0.);
+      mesh.value[18]->maximum(180.);
+      mesh.value[18]->step(1.);
+      mesh.value[18]->align(FL_ALIGN_RIGHT);
+      mesh.value[18]->when(FL_WHEN_RELEASE);
+      mesh.value[18]->callback(mesh_options_ok_cb);
+
+      static Fl_Menu_Item menu_mesh_color[] = {
+        {"By element type", 0, 0, 0},
+        {"By elementary entity", 0, 0, 0},
+        {"By physical group", 0, 0, 0},
+        {"By mesh partition", 0, 0, 0},
+        {0}
+      };
+      mesh.choice[4] = new Fl_Choice
+        (L + 2 * WB, 2 * WB + 7 * BH, IW, BH, "Coloring mode");
+      mesh.choice[4]->menu(menu_mesh_color);
+      mesh.choice[4]->align(FL_ALIGN_RIGHT);
+      mesh.choice[4]->callback(mesh_options_ok_cb);
+
+      Fl_Scroll *s = new Fl_Scroll
+        (L + 2 * WB, 3 * WB + 8 * BH, IW + 20, height - 5 * WB - 8 * BH);
+      int i = 0;
+      while(MeshOptions_Color[i].str) {
+        mesh.color[i] = new Fl_Button
+          (L + 2 * WB, 3 * WB + (8 + i) * BH, IW, BH, MeshOptions_Color[i].str);
+        mesh.color[i]->callback(color_cb, (void *)MeshOptions_Color[i].function);
+        i++;
+      }
+      s->end();
+
+      o->end();
+    }
+    o->end();
+  }
+  mesh.group->end();
+
+  // Solver options
+  solver.group = new Fl_Group(L, 0, width, height, "Solver Options");
+  solver.group->hide();
+  {
+    Fl_Tabs *o = new Fl_Tabs(L + WB, WB, width - 2 * WB, height - 2 * WB);
+    {
+      {
+        Fl_Group *o = new Fl_Group
+          (L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "General");
+
+        solver.value[0] = new Fl_Value_Input
+          (L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "Maximum solver delay");
+        solver.value[0]->minimum(0);
+        solver.value[0]->maximum(10);
+        solver.value[0]->step(1);
+        solver.value[0]->align(FL_ALIGN_RIGHT);
+        solver.value[0]->callback(solver_options_ok_cb);
+
+        solver.input[0] = new Fl_Input
+          (L + 2 * WB, 2 * WB + 2 * BH, IW, BH, "Socket name");
+        solver.input[0]->align(FL_ALIGN_RIGHT);
+        solver.input[0]->callback(solver_options_ok_cb);
+
+        solver.butt[0] = new Fl_Check_Button
+          (L + 2 * WB, 2 * WB + 3 * BH, BW, BH, 
+           "Always listen to incoming connection requests");
+        solver.butt[0]->type(FL_TOGGLE_BUTTON);
+        solver.butt[0]->callback(solver_options_ok_cb);
+        
+        o->end();
+      }
+    }
+    o->end();
+  }
+  solver.group->end();
+
+  // Post-processing options
+  post.group = new Fl_Group(L, 0, width, height, "Post-processing Options");
+  post.group->hide();
+  {
+    Fl_Tabs *o = new Fl_Tabs(L + WB, WB, width - 2 * WB, height - 2 * WB);
+    {
+      Fl_Group *o = new Fl_Group
+        (L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "General");
+
+      static Fl_Menu_Item menu_links[] = {
+        {"None", 0, 0, 0},
+        {"Apply next changes to all visible views", 0, 0, 0},
+        {"Apply next changes to all views", 0, 0, 0},
+        {"Force same options for all visible views", 0, 0, 0},
+        {"Force same options for all views", 0, 0, 0},
+        {0}
+      };
+
+      post.choice[0] = new Fl_Choice
+        (L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "View links");
+      post.choice[0]->menu(menu_links);
+      post.choice[0]->align(FL_ALIGN_RIGHT);
+      post.choice[0]->callback(post_options_ok_cb);
+
+      post.value[0] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 2 * BH, IW, BH, "Animation delay");
+      post.value[0]->minimum(0);
+      post.value[0]->maximum(10);
+      post.value[0]->step(0.01);
+      post.value[0]->align(FL_ALIGN_RIGHT);
+      post.value[0]->callback(post_options_ok_cb);
+
+      post.butt[0] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 3 * BH, BW, BH, "Cycle through views instead of time steps");
+      post.butt[0]->type(FL_TOGGLE_BUTTON);
+      post.butt[0]->callback(post_options_ok_cb);
+
+      post.butt[1] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 4 * BH, BW, BH, "Remove original views after combination");
+      post.butt[1]->type(FL_TOGGLE_BUTTON);
+      post.butt[1]->callback(post_options_ok_cb);
+
+      post.butt[2] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 5 * BH, BW, BH, "Draw value scales horizontally");
+      post.butt[2]->type(FL_TOGGLE_BUTTON);
+      post.butt[2]->callback(post_options_ok_cb);
+
+      o->end();
+    }
+    o->end();
+  }
+  post.group->end();
+
+  // View options
+  view.index = -1;
+  view.group = new Fl_Group(L, 0, width, height, "View Options");
+  view.group->hide();
+  {
+    Fl_Tabs *o = new Fl_Tabs(L + WB, WB, width - 2 * WB, height - 2 * WB);
+    {
+      Fl_Group *o = new Fl_Group
+        (L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "General");
+
+      static Fl_Menu_Item menu_plot_type[] = {
+        {"3D", 0, 0, 0},
+        {"2D space", 0, 0, 0},
+        {"2D time", 0, 0, 0},
+        {0}
+      };
+      view.choice[13] = new Fl_Choice
+        (L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "Plot type");
+      view.choice[13]->menu(menu_plot_type);
+      view.choice[13]->align(FL_ALIGN_RIGHT);
+      view.choice[13]->callback(view_options_ok_cb);
+
+      view.input[0] = new Fl_Input
+        (L + 2 * WB, 2 * WB + 2 * BH, IW, BH, "View name");
+      view.input[0]->align(FL_ALIGN_RIGHT);
+      view.input[0]->callback(view_options_ok_cb);
+
+      int sw = (int)(1.5 * _fontsize);
+      view.butt_rep[0] = new Fl_Repeat_Button
+        (L + 2 * WB, 2 * WB + 3 * BH, sw, BH, "-");
+      view.butt_rep[0]->callback(view_options_timestep_decr_cb);
+      view.butt_rep[1] = new Fl_Repeat_Button
+        (L + 2 * WB + IW - sw, 2 * WB + 3 * BH, sw, BH, "+");
+      view.butt_rep[1]->callback(view_options_timestep_incr_cb);
+      view.value[50] = new Fl_Value_Input
+        (L + 2 * WB + sw, 2 * WB + 3 * BH, IW - 2 * sw, BH);
+      view.value[50]->callback(view_options_timestep_cb);
+      view.value[50]->align(FL_ALIGN_RIGHT);
+      view.value[50]->minimum(0);
+      view.value[50]->maximum(0);
+      view.value[50]->step(1);
+      Fl_Box *a = new Fl_Box
+        (L + 2 * WB + IW, 2 * WB + 3 * BH, IW / 2, BH, "Time step");
+      a->box(FL_NO_BOX);
+      a->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
+
+      view.range = new Fl_Group
+        (L + 2 * WB, 2 * WB + 4 * BH, width - 4 * WB, 8 * BH);
+
+      view.value[30] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 4 * BH, IW, BH, "Intervals");
+      view.value[30]->align(FL_ALIGN_RIGHT);
+      view.value[30]->minimum(1);
+      view.value[30]->maximum(256);
+      view.value[30]->step(1);
+      view.value[30]->when(FL_WHEN_RELEASE);
+      view.value[30]->callback(view_options_ok_cb);
+      
+      static Fl_Menu_Item menu_iso[] = {
+        {"Iso-values", 0, 0, 0},
+        {"Continuous map", 0, 0, 0},
+        {"Filled iso-values", 0, 0, 0},
+        {"Numeric values", 0, 0, 0},
+        {0}
+      };
+      view.choice[0] = new Fl_Choice
+        (L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Intervals type");
+      view.choice[0]->menu(menu_iso);
+      view.choice[0]->align(FL_ALIGN_RIGHT);
+      view.choice[0]->tooltip("(Alt+t)");
+      view.choice[0]->callback(view_options_ok_cb);
+
+      static Fl_Menu_Item menu_range[] = {
+        {"Default", 0, 0, 0},
+        {"Custom", 0, 0, 0},
+        {"Per time step", 0, 0, 0},
+        {0}
+      };
+      view.choice[7] = new Fl_Choice
+        (L + 2 * WB, 2 * WB + 6 * BH, IW, BH, "Range mode");
+      view.choice[7]->menu(menu_range);
+      view.choice[7]->align(FL_ALIGN_RIGHT);
+      view.choice[7]->tooltip("(Alt+r)");
+      view.choice[7]->callback(view_options_ok_cb, (void*)"custom_range");
+
+      int sw2 = (int)(2.5 * _fontsize);
+      view.push[1] = new Fl_Button
+        (L + 2 * WB, 2 * WB + 7 * BH, sw2, BH, "Min");
+      view.push[1]->callback(view_options_ok_cb, (void*)"range_min");
+      view.value[31] = new Fl_Value_Input
+        (L + 2 * WB + sw2, 2 * WB + 7 * BH, IW - sw2, BH, "Custom minimum");
+      view.value[31]->align(FL_ALIGN_RIGHT);
+      view.value[31]->when(FL_WHEN_RELEASE);
+      view.value[31]->callback(view_options_ok_cb);
+
+      view.push[2] = new Fl_Button
+        (L + 2 * WB, 2 * WB + 8 * BH, sw2, BH, "Max");
+      view.push[2]->callback(view_options_ok_cb, (void*)"range_max");
+      view.value[32] = new Fl_Value_Input
+        (L + 2 * WB + sw2, 2 * WB + 8 * BH, IW - sw2, BH, "Custom maximum");
+      view.value[32]->align(FL_ALIGN_RIGHT);
+      view.value[32]->when(FL_WHEN_RELEASE);
+      view.value[32]->callback(view_options_ok_cb);
+
+      view.butt[38] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 9 * BH, BW, BH, "Saturate out-of-range values");
+      view.butt[38]->type(FL_TOGGLE_BUTTON);
+      view.butt[38]->callback(view_options_ok_cb);
+
+      static Fl_Menu_Item menu_scale[] = {
+        {"Linear", 0, 0, 0},
+        {"Logarithmic", 0, 0, 0},
+        {"Double logarithmic", 0, 0, 0},
+        {0}
+      };
+      view.choice[1] = new Fl_Choice
+        (L + 2 * WB, 2 * WB + 10 * BH, IW, BH, "Value scale mode");
+      view.choice[1]->menu(menu_scale);
+      view.choice[1]->align(FL_ALIGN_RIGHT);
+      view.choice[1]->callback(view_options_ok_cb);
+
+      view.input[1] = new Fl_Input
+        (L + 2 * WB, 2 * WB + 11 * BH, IW, BH, "Number display format");
+      view.input[1]->align(FL_ALIGN_RIGHT);
+      view.input[1]->callback(view_options_ok_cb);
+
+      view.range->end();
+
+      o->end();
+    }
+    {
+      Fl_Group *o = new Fl_Group
+        (L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Axes");
+      o->hide();
+
+      view.choice[8] = new Fl_Choice
+        (L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "Axes mode");
+      view.choice[8]->menu(menu_axes_mode);
+      view.choice[8]->align(FL_ALIGN_RIGHT);
+      view.choice[8]->tooltip("(Alt+a)");
+      view.choice[8]->callback(view_options_ok_cb, (void*)"view_axes");
+
+      view.butt[3] = new Fl_Check_Button
+        (L + width - (int)(0.85*IW) - 2 * WB, 2 * WB + 1 * BH, (int)(0.85*IW), BH,
+         "Mikado style");
+      view.butt[3]->type(FL_TOGGLE_BUTTON);
+      view.butt[3]->callback(view_options_ok_cb);
+
+      view.value[3] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 2 * BH, IW/3, BH);
+      view.value[3]->minimum(0.);
+      view.value[3]->step(1);
+      view.value[3]->maximum(100);
+      view.value[3]->callback(view_options_ok_cb);
+      view.value[4] = new Fl_Value_Input
+        (L + 2 * WB + 1*IW/3, 2 * WB + 2 * BH, IW/3, BH);
+      view.value[4]->minimum(0.);
+      view.value[4]->step(1);
+      view.value[4]->maximum(100);
+      view.value[4]->callback(view_options_ok_cb);
+      view.value[5] = new Fl_Value_Input
+        (L + 2 * WB + 2*IW/3, 2 * WB + 2 * BH, IW/3, BH, "Axes tics");
+      view.value[5]->minimum(0.);
+      view.value[5]->step(1);
+      view.value[5]->maximum(100);
+      view.value[5]->align(FL_ALIGN_RIGHT);
+      view.value[5]->callback(view_options_ok_cb);
+
+      view.input[7] = new Fl_Input
+        (L + 2 * WB, 2 * WB + 3 * BH, IW/3, BH);
+      view.input[7]->callback(view_options_ok_cb);
+      view.input[8] = new Fl_Input
+        (L + 2 * WB + 1*IW/3, 2 * WB + 3 * BH, IW/3, BH);
+      view.input[8]->callback(view_options_ok_cb);
+      view.input[9] = new Fl_Input
+        (L + 2 * WB + 2*IW/3, 2 * WB + 3 * BH, IW/3, BH, "Axes format");
+      view.input[9]->align(FL_ALIGN_RIGHT);
+      view.input[9]->callback(view_options_ok_cb);
+      
+      view.input[10] = new Fl_Input
+        (L + 2 * WB, 2 * WB + 4 * BH, IW/3, BH);
+      view.input[10]->callback(view_options_ok_cb);
+      view.input[11] = new Fl_Input
+        (L + 2 * WB + 1*IW/3, 2 * WB + 4 * BH, IW/3, BH);
+      view.input[11]->callback(view_options_ok_cb);
+      view.input[12] = new Fl_Input
+        (L + 2 * WB + 2*IW/3, 2 * WB + 4 * BH, IW/3, BH, "Axes labels");
+      view.input[12]->align(FL_ALIGN_RIGHT);
+      view.input[12]->callback(view_options_ok_cb);
+      
+      view.butt[25] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 5 * BH, BW, BH, "Position 3D axes automatically");
+      view.butt[25]->type(FL_TOGGLE_BUTTON);
+      view.butt[25]->callback(view_options_ok_cb, (void*)"view_axes_auto_3d");
+      
+      view.value[13] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 6 * BH, IW / 3, BH);
+      view.value[13]->callback(view_options_ok_cb);
+      view.value[14] = new Fl_Value_Input
+        (L + 2 * WB + IW / 3, 2 * WB + 6 * BH, IW / 3, BH);
+      view.value[14]->callback(view_options_ok_cb);
+      view.value[15] = new Fl_Value_Input
+        (L + 2 * WB + 2 * IW / 3, 2 * WB + 6 * BH, IW / 3, BH, "3D axes minimum");
+      view.value[15]->align(FL_ALIGN_RIGHT);
+      view.value[15]->callback(view_options_ok_cb);
+
+      view.value[16] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 7 * BH, IW / 3, BH);
+      view.value[16]->callback(view_options_ok_cb);
+      view.value[17] = new Fl_Value_Input
+        (L + 2 * WB + IW / 3, 2 * WB + 7 * BH, IW / 3, BH);
+      view.value[17]->callback(view_options_ok_cb);
+      view.value[18] = new Fl_Value_Input
+        (L + 2 * WB + 2 * IW / 3, 2 * WB + 7 * BH, IW / 3, BH, "3D axes maximum");
+      view.value[18]->align(FL_ALIGN_RIGHT);
+      view.value[18]->callback(view_options_ok_cb);
+
+      view.butt[7] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 8 * BH, BW, BH, "Position 2D axes/value scale automatically");
+      view.butt[7]->type(FL_TOGGLE_BUTTON);
+      view.butt[7]->callback(view_options_ok_cb, (void*)"view_axes_auto_2d");
+      
+      view.value[20] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 9 * BH, IW / 2, BH);
+      view.value[20]->minimum(-2000);
+      view.value[20]->maximum(2000);
+      view.value[20]->step(1);
+      view.value[20]->callback(view_options_ok_cb);
+      view.value[21] = new Fl_Value_Input
+        (L + 2 * WB + IW / 2, 2 * WB + 9 * BH, IW / 2, BH, "2D axes/value scale position");
+      view.value[21]->align(FL_ALIGN_RIGHT);
+      view.value[21]->minimum(-2000);
+      view.value[21]->maximum(2000);
+      view.value[21]->step(1);
+      view.value[21]->callback(view_options_ok_cb);
+
+      view.value[22] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 10 * BH, IW / 2, BH);
+      view.value[22]->minimum(0);
+      view.value[22]->maximum(2000);
+      view.value[22]->step(1);
+      view.value[22]->callback(view_options_ok_cb);
+      view.value[23] = new Fl_Value_Input
+        (L + 2 * WB + IW / 2, 2 * WB + 10 * BH, IW / 2, BH, "2D axes/value scale size");
+      view.value[23]->align(FL_ALIGN_RIGHT);
+      view.value[23]->minimum(0);
+      view.value[23]->maximum(2000);
+      view.value[23]->step(1);
+      view.value[23]->callback(view_options_ok_cb);
+
+      o->end();
+    }
+    {
+      Fl_Group *o = new Fl_Group
+        (L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Visibility");
+      o->hide();
+
+      view.butt[4] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 1 * BH, BW, BH, "Show value scale");
+      view.butt[4]->tooltip("(Alt+i)");
+      view.butt[4]->type(FL_TOGGLE_BUTTON);
+      view.butt[4]->callback(view_options_ok_cb);
+
+      static Fl_Menu_Item time_display[] = {
+        {"None", 0, 0, 0},
+        {"Value if multi-step", 0, 0, 0},
+        {"Value", 0, 0, 0},
+        {"Step if multi-step", 0, 0, 0},
+        {"Step", 0, 0, 0},
+        {0}
+      };
+      view.choice[12] = new Fl_Choice
+        (L + 2 * WB, 2 * WB + 2 * BH, IW, BH, "Time display mode");
+      view.choice[12]->menu(time_display);
+      view.choice[12]->align(FL_ALIGN_RIGHT);
+      view.choice[12]->callback(view_options_ok_cb);
+
+      view.butt[5] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 3 * BH, BW, BH, "Show annotations");
+      view.butt[5]->tooltip("(Alt+n)");
+      view.butt[5]->type(FL_TOGGLE_BUTTON);
+      view.butt[5]->callback(view_options_ok_cb);
+
+      view.butt[10] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 4 * BH, BW / 2, BH, "Draw element outlines");
+      view.butt[10]->tooltip("(Alt+e)");
+      view.butt[10]->type(FL_TOGGLE_BUTTON);
+      view.butt[10]->callback(view_options_ok_cb);
+
+      view.butt[2] = new Fl_Check_Button
+        (L + 2 * WB + BW / 2, 2 * WB + 4 * BH, BW / 2, BH, "Draw 3D skin only");
+      view.butt[2]->type(FL_TOGGLE_BUTTON);
+      view.butt[2]->callback(view_options_ok_cb);
+
+      static Fl_Menu_Item menu_view_element_types[] = {
+        {"Points",      0, 0, 0, FL_MENU_TOGGLE},
+        {"Lines",       0, 0, 0, FL_MENU_TOGGLE},
+        {"Triangles",   0, 0, 0, FL_MENU_TOGGLE},
+        {"Quadrangles", 0, 0, 0, FL_MENU_TOGGLE},
+        {"Tetrahedra",  0, 0, 0, FL_MENU_TOGGLE},
+        {"Hexahedra",   0, 0, 0, FL_MENU_TOGGLE},
+        {"Prisms",      0, 0, 0, FL_MENU_TOGGLE},
+        {"Pyramids",    0, 0, 0, FL_MENU_TOGGLE},
+        {0}
+      };
+
+      view.menu[1] = new Fl_Menu_Button
+        (L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Elements");
+      view.menu[1]->menu(menu_view_element_types);
+      view.menu[1]->callback(view_options_ok_cb);
+      
+      static Fl_Menu_Item menu_boundary[] = {
+        {"None", 0, 0, 0},
+        {"Dimension - 1", 0, 0, 0},
+        {"Dimension - 2", 0, 0, 0},
+        {"Dimension - 3", 0, 0, 0},
+        {0}
+      };
+      view.choice[9] = new Fl_Choice
+        (L + 2 * WB, 2 * WB + 6 * BH, IW, BH, "Element boundary mode");
+      view.choice[9]->menu(menu_boundary);
+      view.choice[9]->align(FL_ALIGN_RIGHT);
+      view.choice[9]->callback(view_options_ok_cb);
+
+      view.value[0] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 7 * BH, IW, BH, "Normals");
+      view.value[0]->minimum(0);
+      view.value[0]->maximum(500);
+      view.value[0]->step(1);
+      view.value[0]->align(FL_ALIGN_RIGHT);
+      view.value[0]->when(FL_WHEN_RELEASE);
+      view.value[0]->callback(view_options_ok_cb);
+
+      view.value[1] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 8 * BH, IW, BH, "Tangents");
+      view.value[1]->minimum(0);
+      view.value[1]->maximum(500);
+      view.value[1]->step(1);
+      view.value[1]->align(FL_ALIGN_RIGHT);
+      view.value[1]->when(FL_WHEN_RELEASE);
+      view.value[1]->callback(view_options_ok_cb);
+
+      static Fl_Menu_Item menu_view_field_types[] = {
+        {"Scalar", 0, 0, 0, FL_MENU_TOGGLE},
+        {"Vector", 0, 0, 0, FL_MENU_TOGGLE},
+        {"Tensor", 0, 0, 0, FL_MENU_TOGGLE},
+        {0}
+      };
+
+      view.menu[0] = new Fl_Menu_Button
+        (L + 2 * WB, 2 * WB + 9 * BH, IW, BH, "Fields");
+      view.menu[0]->menu(menu_view_field_types);
+      view.menu[0]->callback(view_options_ok_cb);
+
+      view.value[33] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 10 * BH, IW, BH, "Maximum recursion level");
+      view.value[33]->align(FL_ALIGN_RIGHT);
+      view.value[33]->minimum(0);
+      view.value[33]->maximum(8);
+      view.value[33]->step(1);
+      view.value[33]->when(FL_WHEN_RELEASE);
+      view.value[33]->callback(view_options_ok_cb);
+
+      view.value[34] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 11 * BH, IW, BH, "Target error");
+      view.value[34]->align(FL_ALIGN_RIGHT);
+      view.value[34]->minimum(0.);
+      view.value[34]->maximum(1.);
+      view.value[34]->step(1.e-3);
+      view.value[34]->when(FL_WHEN_RELEASE);
+      view.value[34]->callback(view_options_ok_cb);
+
+      o->end();
+    }
+    {
+      Fl_Group *o = new Fl_Group
+        (L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Offset");
+      o->hide();
+
+      Fl_Box *b = new Fl_Box
+        (FL_NO_BOX, L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "Coordinate transformation:");
+      b->align(FL_ALIGN_INSIDE|FL_ALIGN_LEFT);
+
+      int ss = 2*IW/3/3+4;
+      view.value[51] = new Fl_Value_Input
+        (L + 2 * WB       , 2 * WB + 2 * BH, ss, BH);
+      view.value[52] = new Fl_Value_Input
+        (L + 2 * WB + ss  , 2 * WB + 2 * BH, ss, BH);
+      view.value[53] = new Fl_Value_Input
+        (L + 2 * WB + 2*ss, 2 * WB + 2 * BH, ss, BH, " X");
+      view.value[40] = new Fl_Value_Input
+        (L + 2 * WB + IW  , 2 * WB + 2 * BH, 7*IW/10, BH);
+
+      view.value[54] = new Fl_Value_Input
+        (L + 2 * WB       , 2 * WB + 3 * BH, ss, BH);
+      view.value[55] = new Fl_Value_Input
+        (L + 2 * WB + ss  , 2 * WB + 3 * BH, ss, BH);
+      view.value[56] = new Fl_Value_Input
+        (L + 2 * WB + 2*ss, 2 * WB + 3 * BH, ss, BH, " Y +");
+      view.value[41] = new Fl_Value_Input
+        (L + 2 * WB + IW  , 2 * WB + 3 * BH, 7*IW/10, BH);
+
+      view.value[57] = new Fl_Value_Input
+        (L + 2 * WB       , 2 * WB + 4 * BH, ss, BH);
+      view.value[58] = new Fl_Value_Input
+        (L + 2 * WB + ss  , 2 * WB + 4 * BH, ss, BH);
+      view.value[59] = new Fl_Value_Input
+        (L + 2 * WB + 2*ss, 2 * WB + 4 * BH, ss, BH, " Z");
+      view.value[42] = new Fl_Value_Input
+        (L + 2 * WB + IW  , 2 * WB + 4 * BH, 7*IW/10, BH);
+
+      Fl_Box *b2 = new Fl_Box
+        (FL_NO_BOX, L + 2 * WB + 2 * IW-3*WB, 2 * WB + 1 * BH, 7*IW/10, BH, "Raise:");
+      b2->align(FL_ALIGN_INSIDE|FL_ALIGN_LEFT);
+
+      view.value[43] = new Fl_Value_Input
+        (L + 2 * WB + 2 * IW-3*WB, 2 * WB + 2 * BH, 7*IW/10, BH);
+      view.value[44] = new Fl_Value_Input
+        (L + 2 * WB + 2 * IW-3*WB, 2 * WB + 3 * BH, 7*IW/10, BH);
+      view.value[45] = new Fl_Value_Input
+        (L + 2 * WB + 2 * IW-3*WB, 2 * WB + 4 * BH, 7*IW/10, BH);
+
+      view.value[46] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 5 * BH, 3*ss, BH, "Normal raise");
+
+      for(int i = 40; i <= 46; i++){
+        view.value[i]->align(FL_ALIGN_RIGHT);
+        view.value[i]->when(FL_WHEN_RELEASE);
+        view.value[i]->callback(view_options_ok_cb);
+      }
+      for(int i = 51; i <= 59; i++){
+        view.value[i]->minimum(-1.);
+        view.value[i]->maximum(1.);
+        view.value[i]->step(0.1);
+        view.value[i]->align(FL_ALIGN_RIGHT);
+        view.value[i]->when(FL_WHEN_RELEASE);
+        view.value[i]->callback(view_options_ok_cb);
+      }
+
+      view.butt[6] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 6 * BH, BW, BH, "Use general transformation expressions");
+      view.butt[6]->type(FL_TOGGLE_BUTTON);
+      view.butt[6]->callback(view_options_ok_cb, (void*)"general_transform");
+
+      view.choice[11] = new Fl_Choice
+        (L + 2 * WB, 2 * WB + 7 * BH, IW, BH, "Data source");
+      view.choice[11]->align(FL_ALIGN_RIGHT);
+      view.choice[11]->add("Self");
+      view.choice[11]->callback(view_options_ok_cb);
+
+      view.value[2] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 8 * BH, IW, BH, "Factor");
+      view.value[2]->align(FL_ALIGN_RIGHT);
+      view.value[2]->when(FL_WHEN_RELEASE);
+      view.value[2]->callback(view_options_ok_cb);
+
+      view.input[4] = new Fl_Input
+        (L + 2 * WB, 2 * WB + 9 * BH, IW, BH, "X expression");
+      view.input[4]->align(FL_ALIGN_RIGHT);
+      view.input[4]->callback(view_options_ok_cb);
+
+      view.input[5] = new Fl_Input
+        (L + 2 * WB, 2 * WB + 10 * BH, IW, BH, "Y expression");
+      view.input[5]->align(FL_ALIGN_RIGHT);
+      view.input[5]->callback(view_options_ok_cb);
+
+      view.input[6] = new Fl_Input
+        (L + 2 * WB, 2 * WB + 11 * BH, IW, BH, "Z expression");
+      view.input[6]->align(FL_ALIGN_RIGHT);
+      view.input[6]->callback(view_options_ok_cb);
+
+      o->end();
+    }
+    {
+      Fl_Group *o = new Fl_Group
+        (L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Aspect");
+      o->hide();
+
+      view.value[12] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "Element shrinking factor");
+      view.value[12]->minimum(0.);
+      view.value[12]->step(0.01);
+      view.value[12]->maximum(1.);
+      view.value[12]->align(FL_ALIGN_RIGHT);
+      view.value[12]->when(FL_WHEN_RELEASE);
+      view.value[12]->callback(view_options_ok_cb);
+
+      view.choice[5] = new Fl_Choice
+        (L + 2 * WB, 2 * WB + 2 * BH, IW, BH, "Point display");
+      view.choice[5]->menu(menu_point_display_post);
+      view.choice[5]->align(FL_ALIGN_RIGHT);
+      view.choice[5]->callback(view_options_ok_cb);
+
+      view.value[61] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 3 * BH, IW, BH, "Point size");
+      view.value[61]->minimum(0.1);
+      view.value[61]->maximum(50);
+      view.value[61]->step(0.1);
+      view.value[61]->align(FL_ALIGN_RIGHT);
+      view.value[61]->callback(view_options_ok_cb);
+
+      view.choice[6] = new Fl_Choice
+        (L + 2 * WB, 2 * WB + 4 * BH, IW, BH, "Line display");
+      view.choice[6]->menu(menu_line_display_post);
+      view.choice[6]->align(FL_ALIGN_RIGHT);
+      view.choice[6]->callback(view_options_ok_cb);
+
+      view.butt[26] = new Fl_Check_Button
+        (L + width - (int)(1.15*BB) - 2 * WB, 2 * WB + 4 * BH, (int)(1.15*BB), BH,
+         "Stipple in 2D");
+      view.butt[26]->type(FL_TOGGLE_BUTTON);
+      view.butt[26]->callback(view_options_ok_cb);
+
+      view.value[62] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Line width");
+      view.value[62]->minimum(0.1);
+      view.value[62]->maximum(50);
+      view.value[62]->step(0.1);
+      view.value[62]->align(FL_ALIGN_RIGHT);
+      view.value[62]->callback(view_options_ok_cb);
+
+      {
+        view.vector = new Fl_Group
+          (L + 2 * WB, 2 * WB + 6 * BH, width - 2 * WB, 4 * BH, 0);
+
+        static Fl_Menu_Item menu_vectype[] = {
+          {"Line", 0, 0, 0},
+          {"Arrow", 0, 0, 0},
+          {"Pyramid", 0, 0, 0},
+          {"3D arrow", 0, 0, 0},
+          {"Displacement", 0, 0, 0},
+          {"Comet", 0, 0, 0},
+          {0}
+        };
+        view.choice[2] = new Fl_Choice
+          (L + 2 * WB, 2 * WB + 6 * BH, IW, BH, "Vector display");
+        view.choice[2]->menu(menu_vectype);
+        view.choice[2]->align(FL_ALIGN_RIGHT);
+        view.choice[2]->callback(view_options_ok_cb);
+
+        view.push[0] = new Fl_Button
+          (L + width - (int)(1.15*BB) - 2 * WB, 2 * WB + 6 * BH, (int)(1.15*BB), BH,
+           "Edit arrow");
+        view.push[0]->callback(view_arrow_param_cb);
+
+        view.value[60] = new Fl_Value_Input
+          (L + 2 * WB, 2 * WB + 7 * BH, IW, BH, "Arrow size");
+        view.value[60]->minimum(0);
+        view.value[60]->maximum(500);
+        view.value[60]->step(1);
+        view.value[60]->align(FL_ALIGN_RIGHT);
+        view.value[60]->callback(view_options_ok_cb);
+
+        view.butt[0] = new Fl_Check_Button
+          (L + width - (int)(1.15*BB) - 2 * WB, 2 * WB + 7 * BH, (int)(1.15*BB), BH,
+           "Proportional");
+        view.butt[0]->type(FL_TOGGLE_BUTTON);
+        view.butt[0]->callback(view_options_ok_cb);
+
+        view.value[63] = new Fl_Value_Input
+          (L + 2 * WB, 2 * WB + 8 * BH, IW, BH, "Displacement factor");
+        view.value[63]->minimum(0.);
+        view.value[63]->maximum(1.);
+        view.value[63]->step(0.01);
+        view.value[63]->align(FL_ALIGN_RIGHT);
+        view.value[63]->when(FL_WHEN_RELEASE);
+        view.value[63]->callback(view_options_ok_cb);
+
+        view.choice[10] = new Fl_Choice
+          (L + 2 * WB, 2 * WB + 9 * BH, IW, BH, "Data source");
+        view.choice[10]->align(FL_ALIGN_RIGHT);
+        view.choice[10]->add("Self");
+        view.choice[10]->callback(view_options_ok_cb);
+
+        view.vector->end();
+      }
+
+      static Fl_Menu_Item menu_vecloc[] = {
+        {"Barycenter", 0, 0, 0},
+        {"Vertex", 0, 0, 0},
+        {0}
+      };
+      view.choice[3] = new Fl_Choice
+        (L + 2 * WB, 2 * WB + 10 * BH, IW, BH, "Glyph location");
+      view.choice[3]->menu(menu_vecloc);
+      view.choice[3]->align(FL_ALIGN_RIGHT);
+      view.choice[3]->callback(view_options_ok_cb);
+
+      view.butt[1] = new Fl_Check_Button
+        (L + width - (int)(1.15*BB) - 2 * WB, 2 * WB + 10 * BH, (int)(1.15*BB), BH,
+         "Center glyph");
+      view.butt[1]->type(FL_TOGGLE_BUTTON);
+      view.butt[1]->callback(view_options_ok_cb);
+      
+      static Fl_Menu_Item menu_tensor[] = {
+        {"Von-Mises", 0, 0, 0},
+        {0}
+      };
+      view.choice[4] = new Fl_Choice
+        (L + 2 * WB, 2 * WB + 11 * BH, IW, BH, "Tensor display");
+      view.choice[4]->menu(menu_tensor);
+      view.choice[4]->align(FL_ALIGN_RIGHT);
+      view.choice[4]->callback(view_options_ok_cb);
+
+      o->end();
+    }
+    {
+      Fl_Group *o = new Fl_Group
+        (L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Color");
+      o->hide();
+
+      view.butt[11] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 1 * BH, BW, BH, "Enable lighting");
+      view.butt[11]->tooltip("(Alt+w)");
+      view.butt[11]->type(FL_TOGGLE_BUTTON);
+      view.butt[11]->callback(view_options_ok_cb, (void*)"view_light");
+
+      view.butt[8] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 2 * BH, BW, BH, "Enable lighting of lines");
+      view.butt[8]->type(FL_TOGGLE_BUTTON);
+      view.butt[8]->callback(view_options_ok_cb);
+
+      view.butt[9] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 3 * BH, BW, BH, "Use two-side lighting");
+      view.butt[9]->type(FL_TOGGLE_BUTTON);
+      view.butt[9]->callback(view_options_ok_cb);
+
+      view.butt[12] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 4 * BH, BW, BH, "Smooth normals");
+      view.butt[12]->type(FL_TOGGLE_BUTTON);
+      view.butt[12]->callback(view_options_ok_cb);
+
+      view.value[10] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Smoothing threshold angle");
+      view.value[10]->minimum(0.);
+      view.value[10]->step(1.);
+      view.value[10]->maximum(180.);
+      view.value[10]->align(FL_ALIGN_RIGHT);
+      view.value[10]->when(FL_WHEN_RELEASE);
+      view.value[10]->callback(view_options_ok_cb);
+
+      view.butt[24] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 6 * BH, BW, BH, "Use fake transparency mode");
+      view.butt[24]->type(FL_TOGGLE_BUTTON);
+      view.butt[24]->callback(view_options_ok_cb);
+
+      Fl_Scroll *s = new Fl_Scroll
+        (L + 2 * WB, 3 * WB + 7 * BH, IW + 20, height - 5 * WB - 7 * BH);
+      int i = 0;
+      while(ViewOptions_Color[i].str) {
+        view.color[i] = new Fl_Button
+          (L + 2 * WB, 3 * WB + (7 + i) * BH, IW, BH, ViewOptions_Color[i].str);
+        view.color[i]->callback(view_color_cb, (void *)ViewOptions_Color[i].function);
+        i++;
+      }
+      s->end();
+
+      o->end();
+    }
+    {
+      Fl_Group *o = new Fl_Group
+        (L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Map");
+      o->hide();
+
+      view.colorbar = new colorbarWindow
+        (L + 2 * WB, 2 * WB + BH, width - 4 * WB, height - 4 * WB - BH);
+      view.colorbar->end();
+      view.colorbar->callback(view_options_ok_cb);
+
+      o->end();
+    }
+    o->end();
+  }
+  view.group->end();
+
+  win->position(CTX.opt_position[0], CTX.opt_position[1]);
+  win->end();
+}
+
+void optionWindow::showGroup(int num, bool showWindow)
+{
+  general.group->hide();
+  geo.group->hide();
+  mesh.group->hide();
+  solver.group->hide();
+  post.group->hide();
+  view.group->hide();
+  browser->value(num);
+  switch(num){
+  case 0: case 1: win->label("Options - General"); general.group->show(); break;
+  case 2: win->label("Options - Geometry"); geo.group->show(); break;
+  case 3: win->label("Options - Mesh"); mesh.group->show(); break;
+  case 4: win->label("Options - Solver"); solver.group->show(); break;
+  case 5: win->label("Options - Post-pro"); post.group->show(); break;
+  default: 
+    {
+      updateViewGroup(num - 6);
+      static char str[128];
+      sprintf(str, "Options - View [%d]", num - 6);
+      win->label(str);
+      view.group->show();
+    }
+    break;
+  }
+  if(showWindow) win->show();
+}
+
+void optionWindow::resetBrowser()
+{
+  int select = browser->value();
+  browser->clear();
+  browser->add("General");
+  browser->add("Geometry");
+  browser->add("Mesh");
+  browser->add("Solver");
+  browser->add("Post-pro");
+  for(unsigned int i = 0; i < PView::list.size(); i++){
+    char str[128];
+    sprintf(str, "View [%d]", i);
+    browser->add(str);
+  }
+  int num = (select <= browser->size()) ? select : browser->size();
+  browser->value(num);
+  showGroup(num, false);
+}
+
+void optionWindow::resetExternalViewList()
+{
+  char str[32];
+  view.choice[10]->clear();
+  view.choice[11]->clear();
+  view.choice[10]->add("Self");
+  view.choice[11]->add("Self");
+  for(unsigned int i = 0; i < PView::list.size(); i++) {
+    sprintf(str, "View [%d]", i);
+    view.choice[10]->add(str, 0, NULL);
+    view.choice[11]->add(str, 0, NULL);
+  }
+  if(view.index >= 0){
+    opt_view_external_view(view.index, GMSH_GUI, 0);
+    opt_view_gen_raise_view(view.index, GMSH_GUI, 0);
+  }
+}
+
+void optionWindow::updateViewGroup(int index)
+{
+  if(index < 0 || index >= (int)PView::list.size()) return;
+
+  view.index = index;
+
+  PView *v = PView::list[index];
+  PViewData *data = v->getData();
+  PViewOptions *opt = v->getOptions();
+
+  double maxval = std::max(fabs(data->getMin()), fabs(data->getMax()));
+  if(!maxval) maxval = 1.;
+  double val1 = 10. * CTX.lc;
+  double val2 = 2. * CTX.lc / maxval;
+
+  opt_view_name(index, GMSH_GUI, NULL);
+  opt_view_format(index, GMSH_GUI, NULL);
+  opt_view_type(index, GMSH_GUI, 0);
+  opt_view_show_scale(index, GMSH_GUI, 0);
+  opt_view_draw_strings(index, GMSH_GUI, 0);
+
+  opt_view_max_recursion_level(index, GMSH_GUI, 0);
+  opt_view_target_error(index, GMSH_GUI, 0);
+  if(data->isAdaptive()){
+    view.value[33]->activate();
+    view.value[34]->activate();
+  }
+  else{
+    view.value[33]->deactivate();
+    view.value[34]->deactivate();
+  }
+
+  if(data->getNumPoints() || data->getNumLines()){
+    ((Fl_Menu_Item*)view.choice[13]->menu())[1].activate();
+    ((Fl_Menu_Item*)view.choice[13]->menu())[2].activate();
+  }
+  else {
+    ((Fl_Menu_Item*)view.choice[13]->menu())[1].deactivate();
+    ((Fl_Menu_Item*)view.choice[13]->menu())[2].deactivate();
+  }
+
+  opt_view_auto_position(index, GMSH_GUI, 0);
+  opt_view_position0(index, GMSH_GUI, 0);
+  opt_view_position1(index, GMSH_GUI, 0);
+  opt_view_size0(index, GMSH_GUI, 0);
+  opt_view_size1(index, GMSH_GUI, 0);
+
+  opt_view_axes(index, GMSH_GUI, 0);
+  opt_view_axes_mikado(index, GMSH_GUI, 0);
+  opt_view_axes_format0(index, GMSH_GUI, NULL);
+  opt_view_axes_format1(index, GMSH_GUI, NULL);
+  opt_view_axes_format2(index, GMSH_GUI, NULL);
+  opt_view_axes_tics0(index, GMSH_GUI, 0);
+  opt_view_axes_tics1(index, GMSH_GUI, 0);
+  opt_view_axes_tics2(index, GMSH_GUI, 0);
+  opt_view_axes_label0(index, GMSH_GUI, NULL);
+  opt_view_axes_label1(index, GMSH_GUI, NULL);
+  opt_view_axes_label2(index, GMSH_GUI, NULL);
+  opt_view_axes_auto_position(index, GMSH_GUI, 0);
+  opt_view_axes_xmin(index, GMSH_GUI, 0);
+  opt_view_axes_xmax(index, GMSH_GUI, 0);
+  opt_view_axes_ymin(index, GMSH_GUI, 0);
+  opt_view_axes_ymax(index, GMSH_GUI, 0);
+  opt_view_axes_zmin(index, GMSH_GUI, 0);
+  opt_view_axes_zmax(index, GMSH_GUI, 0);
+  for(int i = 13; i <= 18; i++){
+    view.value[i]->step(CTX.lc/200.);
+    view.value[i]->minimum(-CTX.lc);
+    view.value[i]->maximum(CTX.lc);
+  }
+
+  if(data->getNumElements()) {
+    view.range->activate();
+    ((Fl_Menu_Item*)view.choice[13]->menu())[0].activate();
+  }
+  else {
+    view.range->deactivate();
+    ((Fl_Menu_Item*)view.choice[13]->menu())[0].deactivate();
+  }
+  opt_view_show_element(index, GMSH_GUI, 0);
+  opt_view_draw_skin_only(index, GMSH_GUI, 0);
+  opt_view_light(index, GMSH_GUI, 0);
+  opt_view_light_two_side(index, GMSH_GUI, 0);
+  opt_view_light_lines(index, GMSH_GUI, 0);
+  opt_view_smooth_normals(index, GMSH_GUI, 0);
+  opt_view_angle_smooth_normals(index, GMSH_GUI, 0);
+  opt_view_boundary(index, GMSH_GUI, 0);
+  opt_view_explode(index, GMSH_GUI, 0);
+  opt_view_draw_points(index, GMSH_GUI, 0);
+  opt_view_draw_lines(index, GMSH_GUI, 0);
+  opt_view_draw_triangles(index, GMSH_GUI, 0);
+  opt_view_draw_quadrangles(index, GMSH_GUI, 0);
+  opt_view_draw_tetrahedra(index, GMSH_GUI, 0);
+  opt_view_draw_hexahedra(index, GMSH_GUI, 0);
+  opt_view_draw_prisms(index, GMSH_GUI, 0);
+  opt_view_draw_pyramids(index, GMSH_GUI, 0);
+  opt_view_draw_scalars(index, GMSH_GUI, 0);
+  opt_view_draw_vectors(index, GMSH_GUI, 0);
+  opt_view_draw_tensors(index, GMSH_GUI, 0);
+  opt_view_normals(index, GMSH_GUI, 0);
+  opt_view_tangents(index, GMSH_GUI, 0);
+
+  opt_view_nb_iso(index, GMSH_GUI, 0);
+  opt_view_intervals_type(index, GMSH_GUI, 0);
+  opt_view_range_type(index, GMSH_GUI, 0);
+  opt_view_custom_min(index, GMSH_GUI, 0);
+  opt_view_custom_max(index, GMSH_GUI, 0);
+  opt_view_scale_type(index, GMSH_GUI, 0);
+  opt_view_saturate_values(index, GMSH_GUI, 0);
+
+  opt_view_offset0(index, GMSH_GUI, 0);
+  opt_view_offset1(index, GMSH_GUI, 0);
+  opt_view_offset2(index, GMSH_GUI, 0);
+  for(int i = 40; i <= 42; i++) {
+    view.value[i]->step(val1/100.);
+    view.value[i]->minimum(-val1);
+    view.value[i]->maximum(val1);
+  }
+  opt_view_transform00(index, GMSH_GUI, 0);
+  opt_view_transform01(index, GMSH_GUI, 0);
+  opt_view_transform02(index, GMSH_GUI, 0);
+  opt_view_transform10(index, GMSH_GUI, 0);
+  opt_view_transform11(index, GMSH_GUI, 0);
+  opt_view_transform12(index, GMSH_GUI, 0);
+  opt_view_transform20(index, GMSH_GUI, 0);
+  opt_view_transform21(index, GMSH_GUI, 0);
+  opt_view_transform22(index, GMSH_GUI, 0);
+  opt_view_raise0(index, GMSH_GUI, 0);
+  opt_view_raise1(index, GMSH_GUI, 0);
+  opt_view_raise2(index, GMSH_GUI, 0);
+  opt_view_normal_raise(index, GMSH_GUI, 0);
+  for(int i = 43; i <= 46; i++) {
+    view.value[i]->step(val2/100.);
+    view.value[i]->minimum(-val2);
+    view.value[i]->maximum(val2);
+  }
+  opt_view_use_gen_raise(index, GMSH_GUI, 0);
+  opt_view_gen_raise_view(index, GMSH_GUI, 0);
+  opt_view_gen_raise_factor(index, GMSH_GUI, 0);
+  opt_view_gen_raise0(index, GMSH_GUI, 0);
+  opt_view_gen_raise1(index, GMSH_GUI, 0);
+  opt_view_gen_raise2(index, GMSH_GUI, 0);
+  view.value[2]->step(val2/100.);
+  view.value[2]->minimum(-val2);
+  view.value[2]->maximum(val2);
+
+  if(data->getNumTimeSteps() == 1) {
+    view.value[50]->deactivate();
+    view.butt_rep[0]->deactivate();
+    view.butt_rep[1]->deactivate();
+  }
+  else {
+    view.value[50]->activate();
+    view.butt_rep[0]->activate();
+    view.butt_rep[1]->activate();
+  }
+  view.value[50]->maximum(data->getNumTimeSteps() - 1);
+  opt_view_timestep(index, GMSH_GUI, 0);
+  opt_view_show_time(index, GMSH_GUI, 0);
+
+  if(data->getNumVectors() || data->getNumTensors())
+    view.vector->activate();
+  else
+    view.vector->deactivate();
+
+  opt_view_point_size(index, GMSH_GUI, 0);
+  opt_view_point_type(index, GMSH_GUI, 0);
+  opt_view_line_width(index, GMSH_GUI, 0);
+  opt_view_line_type(index, GMSH_GUI, 0);
+  opt_view_vector_type(index, GMSH_GUI, 0);
+  opt_view_arrow_size(index, GMSH_GUI, 0);
+  opt_view_arrow_size_proportional(index, GMSH_GUI, 0);
+
+  opt_view_displacement_factor(index, GMSH_GUI, 0);
+  double val3 = 2. * CTX.lc / maxval;
+  view.value[63]->step(val3/100.);
+  view.value[63]->maximum(val3);
+
+  opt_view_external_view(index, GMSH_GUI, 0);
+  opt_view_glyph_location(index, GMSH_GUI, 0);
+  opt_view_center_glyphs(index, GMSH_GUI, 0);
+  opt_view_tensor_type(index, GMSH_GUI, 0);
+
+  opt_view_fake_transparency(index, GMSH_GUI, 0);
+  opt_view_use_stipple(index, GMSH_GUI, 0);
+  opt_view_color_points(index, GMSH_GUI, 0);
+  opt_view_color_lines(index, GMSH_GUI, 0);
+  opt_view_color_triangles(index, GMSH_GUI, 0);
+  opt_view_color_quadrangles(index, GMSH_GUI, 0);
+  opt_view_color_tetrahedra(index, GMSH_GUI, 0);
+  opt_view_color_hexahedra(index, GMSH_GUI, 0);
+  opt_view_color_prisms(index, GMSH_GUI, 0);
+  opt_view_color_pyramids(index, GMSH_GUI, 0);
+  opt_view_color_tangents(index, GMSH_GUI, 0);
+  opt_view_color_normals(index, GMSH_GUI, 0);
+  opt_view_color_text2d(index, GMSH_GUI, 0);
+  opt_view_color_text3d(index, GMSH_GUI, 0);
+  opt_view_color_axes(index, GMSH_GUI, 0);
+
+  view.colorbar->update(data->getName().c_str(), data->getMin(), 
+                        data->getMax(), &opt->CT, &v->getChanged());
+}
diff --git a/Fltk/optionWindow.h b/Fltk/optionWindow.h
new file mode 100644
index 0000000000000000000000000000000000000000..b103a78b906d8c09be2e4c5f5d82287b78210484
--- /dev/null
+++ b/Fltk/optionWindow.h
@@ -0,0 +1,95 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+
+#ifndef _OPTION_WINDOW_H_
+#define _OPTION_WINDOW_H_
+
+#include <FL/Fl_Window.H>
+#include <FL/Fl_Hold_Browser.H>
+#include <FL/Fl_Button.H>
+#include <FL/Fl_Return_Button.H>
+#include <FL/Fl_Check_Button.H>
+#include <FL/Fl_Menu_Button.H>
+#include <FL/Fl_Repeat_Button.H>
+#include <FL/Fl_Group.H>
+#include <FL/Fl_Choice.H>
+#include <FL/Fl_Input.H>
+#include <FL/Fl_Value_Input.H>
+#include "spherePositionWidget.h"
+#include "colorbarWindow.h"
+
+#define NUM_FONTS 14
+extern Fl_Menu_Item menu_font_names[];
+
+class optionWindow{
+ private:
+  int _fontsize;
+ public:
+  Fl_Window *win;
+  Fl_Hold_Browser *browser;
+  Fl_Return_Button *redraw;
+  struct{
+    Fl_Group *group;
+    Fl_Check_Button *butt[20];
+    Fl_Button *push[20];
+    Fl_Value_Input *value[50];
+    Fl_Button *color[50];
+    Fl_Input *input[20];
+    Fl_Choice *choice[20];
+    spherePositionWidget *sphere;
+  } general;
+  struct{
+    Fl_Group *group;
+    Fl_Check_Button *butt[20];
+    Fl_Value_Input *value[20];
+    Fl_Button *color[50];
+    Fl_Choice *choice[20];
+  } geo;
+  struct{
+    Fl_Group *group;
+    Fl_Check_Button *butt[50];
+    Fl_Return_Button *retbutt[50];
+    Fl_Input *input[20];
+    Fl_Value_Input *value[50];
+    Fl_Button *color[50];
+    Fl_Choice *choice[20];
+    Fl_Menu_Button *menu;
+  } mesh;
+  struct{
+    Fl_Group *group;
+    Fl_Check_Button *butt[20];
+    Fl_Value_Input *value[20];
+    Fl_Input *input[20];
+  } solver;
+  struct{
+    Fl_Group *group;
+    Fl_Check_Button *butt[20];
+    Fl_Value_Input *value[20];
+    Fl_Choice *choice[20];
+  } post;
+  struct{
+    int index;
+    Fl_Group *group, *range, *vector;
+    Fl_Check_Button *butt[100];
+    Fl_Value_Input *value[100];
+    Fl_Input *input[100];
+    Fl_Repeat_Button *butt_rep[100];
+    Fl_Button *push[100];
+    Fl_Choice *choice[100];
+    Fl_Button *color[50];
+    colorbarWindow *colorbar;
+    Fl_Return_Button *ok;
+    Fl_Menu_Button *menu[2];
+  } view;
+
+ public:
+  optionWindow(int fontsize);
+  void showGroup(int num, bool showWindow=true);
+  void resetBrowser();
+  void resetExternalViewList();
+  void updateViewGroup(int index);
+};
+
+#endif
diff --git a/Fltk/partitionDialog.cpp b/Fltk/partitionDialog.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ef1ab914aab4dd51e39e8139d9c8b73c63f9fc06
--- /dev/null
+++ b/Fltk/partitionDialog.cpp
@@ -0,0 +1,796 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+//
+// Contributor(s):
+//   Stephen Guzik
+//
+
+#include <limits>
+#include <FL/Fl.H>
+#include <FL/Fl_Window.H>
+#include <FL/Fl_Choice.H>
+#include <FL/Fl_Value_Input.H>
+#include <FL/Fl_Toggle_Button.H>
+#include <FL/Fl_Check_Button.H>
+#include <FL/Fl_Toggle_Button.H>
+#include <FL/Fl_Return_Button.H>
+#include <FL/Fl_Group.H>
+#include <FL/Fl_Box.H>
+#include "GUI.h"
+#include "shortcutWindow.h"
+#include "GmshDefines.h"
+#include "GmshMessage.h"
+#include "GModel.h"
+#include "Draw.h"
+#include "Options.h"
+#include "Partition.h"
+#include "Context.h"
+
+extern Context_T CTX;
+
+#define GMSH_WINDOW_BOX FL_FLAT_BOX
+
+#if defined(HAVE_CHACO) || defined(HAVE_METIS)
+
+// Forward declarations of some callbacks
+void partition_opt_chaco_globalalg_cb(Fl_Widget *widget, void *data);
+void partition_opt_architecture_cb(Fl_Widget *widget, void *data);
+void partition_opt_num_partitions_cb(Fl_Widget *widget, void *data);
+void partition_opt_spectralcheck_cb(Fl_Widget *widget, void *data);
+void partition_select_groups_cb(Fl_Widget *widget, void *data);
+
+// Pointers to required widgets
+struct PartitionDialog
+{
+  Fl_Window *window;
+  // Group 0
+  Fl_Choice *choicePartitioner;
+  Fl_Value_Input *inputNumPartition;
+  // Group 1
+  Fl_Choice *choiceChacoAlg;
+  Fl_Toggle_Button *toggleButtonAdvChaco;
+  // Group 2
+  Fl_Choice *choiceArchitecture;
+  Fl_Value_Input *inputNumPartition1;
+  Fl_Value_Input *inputNumPartition2;
+  Fl_Value_Input *inputNumPartition3;
+  Fl_Choice *choiceDivisions;
+  Fl_Value_Input *inputVMax;
+  Fl_Choice *choiceEigensolver;
+  Fl_Value_Input *inputEigtol;
+  Fl_Choice *choiceLocalAlgorithm;
+  Fl_Value_Input *inputSeed;
+  Fl_Check_Button *checkButtonRefPart;
+  Fl_Check_Button *checkButtonIntVert;
+  Fl_Check_Button *checkButtonRefMap;
+  Fl_Check_Button *checkButtonTermProp;
+  // Group 3
+  Fl_Choice *choiceMetisAlg;
+  Fl_Toggle_Button *toggleButtonAdvMetis;
+  // Group 4
+  Fl_Choice *choiceEdgeMatch;
+  Fl_Choice *choiceRefineAlg;
+  void write_all_options()
+  {
+    // Group 0
+    CTX.mesh.partition_options.partitioner = choicePartitioner->value() + 1;
+    CTX.mesh.partition_options.num_partitions =
+      static_cast<int>(inputNumPartition->value());
+
+    // Group 1
+    CTX.mesh.partition_options.global_method = choiceChacoAlg->value() + 1;
+
+    // Group 2
+    CTX.mesh.partition_options.architecture = choiceArchitecture->value();
+    switch(CTX.mesh.partition_options.architecture) {
+    case 0:
+      CTX.mesh.partition_options.ndims_tot =
+        static_cast<int>(inputNumPartition1->value());
+      break;
+    case 3:
+      CTX.mesh.partition_options.mesh_dims[2] =
+        static_cast<int>(inputNumPartition3->value());
+    case 2:
+      CTX.mesh.partition_options.mesh_dims[1] =
+        static_cast<int>(inputNumPartition2->value());
+    case 1:
+      CTX.mesh.partition_options.mesh_dims[0] =
+        static_cast<int>(inputNumPartition1->value());
+      break;
+    }
+    CTX.mesh.partition_options.ndims = choiceDivisions->value() + 1;
+    CTX.mesh.partition_options.vmax = static_cast<int>(inputVMax->value());
+    CTX.mesh.partition_options.rqi_flag = choiceEigensolver->value();
+    CTX.mesh.partition_options.eigtol = inputEigtol->value();
+    CTX.mesh.partition_options.local_method = choiceLocalAlgorithm->value() + 1;
+    CTX.mesh.partition_options.seed = static_cast<long>(inputSeed->value());
+    CTX.mesh.partition_options.refine_partition = checkButtonRefPart->value();
+    CTX.mesh.partition_options.internal_vertices = checkButtonIntVert->value();
+    CTX.mesh.partition_options.refine_map = checkButtonRefMap->value();
+    CTX.mesh.partition_options.terminal_propogation =
+      checkButtonTermProp->value();
+  
+    // Group 3
+    CTX.mesh.partition_options.algorithm = choiceMetisAlg->value() + 1;
+
+    // Group 4
+    CTX.mesh.partition_options.edge_matching = choiceEdgeMatch->value() + 1;
+    CTX.mesh.partition_options.refine_algorithm = choiceRefineAlg->value() + 1;
+  }
+  void read_all_options()
+  {
+    // Group 0
+    choicePartitioner->value(CTX.mesh.partition_options.partitioner - 1);
+    inputNumPartition->value(CTX.mesh.partition_options.num_partitions);
+
+    // Group 1
+    choiceChacoAlg->value(CTX.mesh.partition_options.global_method - 1);
+
+    // Group 2
+    choiceArchitecture->value(CTX.mesh.partition_options.architecture);
+    switch(CTX.mesh.partition_options.architecture) {
+    case 0:
+      inputNumPartition1->value(CTX.mesh.partition_options.ndims_tot);
+      break;
+    case 1:
+      inputNumPartition1->value(CTX.mesh.partition_options.mesh_dims[0]);
+      break;
+    }
+    inputNumPartition2->value(CTX.mesh.partition_options.mesh_dims[1]);
+    inputNumPartition3->value(CTX.mesh.partition_options.mesh_dims[2]);
+    choiceDivisions->value(CTX.mesh.partition_options.ndims - 1);
+    inputVMax->value(CTX.mesh.partition_options.vmax);
+    choiceEigensolver->value(CTX.mesh.partition_options.rqi_flag);
+    inputEigtol->value(CTX.mesh.partition_options.eigtol);
+    choiceLocalAlgorithm->value(CTX.mesh.partition_options.local_method - 1);
+    inputSeed->value(CTX.mesh.partition_options.seed);
+    checkButtonRefPart->value(CTX.mesh.partition_options.refine_partition);
+    checkButtonIntVert->value(CTX.mesh.partition_options.internal_vertices);
+    checkButtonRefMap->value(CTX.mesh.partition_options.refine_map);
+    checkButtonTermProp->value(CTX.mesh.partition_options.terminal_propogation);
+  
+    // Group 3
+    choiceMetisAlg->value(CTX.mesh.partition_options.algorithm - 1);
+
+    // Group 4
+    choiceEdgeMatch->value(CTX.mesh.partition_options.edge_matching - 1);
+    choiceRefineAlg->value(CTX.mesh.partition_options.refine_algorithm - 1);
+
+    // Call all callbacks to ensure consistent options
+    partition_opt_chaco_globalalg_cb(choiceChacoAlg, this);
+    partition_opt_architecture_cb(choiceArchitecture, this);
+    partition_opt_num_partitions_cb(inputNumPartition, this);
+    partition_opt_spectralcheck_cb(choiceDivisions, this);
+  }
+};
+
+// Chaco option considerations based on the global algorithm
+void partition_opt_chaco_globalalg_cb(Fl_Widget *widget, void *data)
+{
+  PartitionDialog *dlg = static_cast<PartitionDialog*>(data);
+  unsigned opt = dlg->choiceChacoAlg->value();
+  if(opt == 0) {
+    dlg->choiceLocalAlgorithm->value(0);
+    dlg->choiceLocalAlgorithm->deactivate();
+  }
+  else {
+    dlg->choiceLocalAlgorithm->activate();
+  }
+  if(opt == 1) {
+    dlg->choiceEigensolver->value(1);
+    dlg->choiceEigensolver->activate();
+    if(dlg->choiceDivisions->value() != 0 &&
+       dlg->checkButtonTermProp->value())
+      dlg->choiceDivisions->value(0);
+  }
+  else {
+    dlg->choiceEigensolver->deactivate();
+  }
+}
+
+// Chaco option considerations based on the architecture
+void partition_opt_architecture_cb(Fl_Widget *widget, void *data)
+{
+  PartitionDialog *dlg = static_cast<PartitionDialog*>(data);
+  switch(static_cast<int>(dlg->choiceArchitecture->value())) {
+  case 0:
+    dlg->inputNumPartition1->maximum(31);
+    dlg->inputNumPartition2->deactivate();
+    dlg->inputNumPartition3->deactivate();
+    break;
+  case 1:
+    dlg->inputNumPartition1->maximum(std::numeric_limits<int>::max());
+    dlg->inputNumPartition2->deactivate();
+    dlg->inputNumPartition3->deactivate();
+    break;
+  case 2:
+    dlg->inputNumPartition1->maximum(std::numeric_limits<int>::max());
+    dlg->inputNumPartition2->activate();
+    dlg->inputNumPartition3->deactivate();
+    break;
+  case 3:
+    dlg->inputNumPartition1->maximum(std::numeric_limits<int>::max());
+    dlg->inputNumPartition2->activate();
+    dlg->inputNumPartition3->activate();
+    break;
+  }
+  // Set topology dimensions from main number of partitions
+  partition_opt_num_partitions_cb(dlg->inputNumPartition, data);
+}
+
+// Match several locations that provide a partition number
+void partition_opt_num_partitions_cb(Fl_Widget *widget, void *data)
+{
+  PartitionDialog *dlg = static_cast<PartitionDialog*>(data);
+  unsigned val = 0;
+  if(widget == dlg->inputNumPartition) {
+    val = static_cast<unsigned>(dlg->inputNumPartition->value());
+    switch(static_cast<int>(dlg->choiceArchitecture->value())) {
+    case 0:
+      {
+        unsigned y = 0;
+        unsigned x = val;
+        while(x >>= 1) ++y;
+        dlg->inputNumPartition1->value(y);
+      }
+      break;
+    case 1:
+    case 2:
+    case 3:
+      dlg->inputNumPartition1->value(val);
+      dlg->inputNumPartition2->value(1);
+      dlg->inputNumPartition3->value(1);
+      break;
+    }
+  }
+  else {
+    switch(static_cast<int>(dlg->choiceArchitecture->value())) {
+    case 0:
+      {
+        unsigned x = static_cast<unsigned>(dlg->inputNumPartition1->value());
+        val = 1 << x;
+      }
+      break;
+    case 1:
+      val = static_cast<unsigned>(dlg->inputNumPartition1->value());
+      break;
+    case 2:
+      val = static_cast<unsigned>
+        (dlg->inputNumPartition1->value()*dlg->inputNumPartition2->value());
+      break;
+    case 3:
+      val = static_cast<unsigned>
+        (dlg->inputNumPartition1->value()*dlg->inputNumPartition2->value()*
+         dlg->inputNumPartition3->value());
+      break;
+    }
+    dlg->inputNumPartition->value(val);
+  }
+  switch(dlg->choicePartitioner->value()) {
+  case 0:
+    if(val <= 3) {
+      dlg->choiceDivisions->value(0);
+      dlg->choiceDivisions->mode(1, FL_MENU_INACTIVE);
+      dlg->choiceDivisions->mode(2, FL_MENU_INACTIVE);
+    }
+    else if(val <= 7) {
+      if(dlg->choiceDivisions->value() > 1) dlg->choiceDivisions->value(1);
+      dlg->choiceDivisions->mode(1, 0);
+      dlg->choiceDivisions->mode(2, FL_MENU_INACTIVE);
+    }
+    else {
+      dlg->choiceDivisions->mode(1, 0);
+      dlg->choiceDivisions->mode(2, 0);
+    }
+    break;
+  case 1:
+    dlg->choiceMetisAlg->value((val <= 8) ? 0: 1);
+    break;
+  }
+}
+
+// Option considerations for the Chaco spectral algorithm
+void partition_opt_spectralcheck_cb(Fl_Widget *widget, void *data)
+{
+  PartitionDialog *dlg = static_cast<PartitionDialog*>(data);
+  if(dlg->choiceChacoAlg->value() == 1) {
+    if(widget == dlg->choiceDivisions && dlg->choiceDivisions->value() != 0)
+      dlg->checkButtonTermProp->value(0);
+    else if(widget == dlg->checkButtonTermProp)
+      dlg->choiceDivisions->value(0);
+  }
+}
+
+void partition_defaults_cb(Fl_Widget *widget, void *data)
+{
+  PartitionDialog *dlg = static_cast<PartitionDialog*>(data);
+  CTX.mesh.partition_options.setDefaults();
+  dlg->read_all_options();
+  partition_select_groups_cb(dlg->choicePartitioner, data);
+}
+
+void partition_partition_cb(Fl_Widget *widget, void *data)
+{
+  PartitionDialog *dlg = static_cast<PartitionDialog*>(data);
+
+  // Write all options
+  dlg->write_all_options();
+
+  // Partition the mesh
+  int ier = PartitionMesh(GModel::current(), CTX.mesh.partition_options);
+
+  // Update the screen
+  if(!ier) {
+    opt_mesh_zone_definition(0, GMSH_SET, 1.);  // Define zone by partition
+    opt_mesh_color_carousel(0, GMSH_SET | GMSH_GUI, 3.);
+    CTX.mesh.changed = ENT_ALL;
+    Draw();
+  }
+}
+
+void partition_cancel_cb(Fl_Widget *widget, void *data)
+{
+  PartitionDialog *dlg = static_cast<PartitionDialog*>(data);
+  dlg->window->hide();
+  Fl::delete_widget(dlg->window);
+}
+
+// Select groups to display
+void partition_select_groups_cb(Fl_Widget *widget, void *data)
+{
+  PartitionDialog *dlg = static_cast<PartitionDialog*>(data);
+  // If this callback was made by the "Advanced" toggle buttons, set the label
+  if(dlg->toggleButtonAdvChaco == widget) {
+    dlg->toggleButtonAdvChaco->label((dlg->toggleButtonAdvChaco->value()) ?
+                                     "Advanced @-28->" : "Advanced @-22->");
+  }
+  else if(dlg->toggleButtonAdvMetis == widget) {
+    dlg->toggleButtonAdvMetis->label((dlg->toggleButtonAdvMetis->value()) ?
+                                     "Advanced @-28->" : "Advanced @-22->");
+  }
+
+  int _fontsize = GetFontSize();
+
+  // Get the groups
+  Fl_Widget *const *g = dlg->window->array();
+  int y = g[0]->h();
+  switch(dlg->choicePartitioner->value()) {
+  case 0:
+    g[1]->show();
+    y += g[1]->h();
+    if(dlg->toggleButtonAdvChaco->value()) {
+      g[2]->show();
+      y += g[2]->h();
+    }
+    else g[2]->hide();
+    g[3]->hide();
+    g[4]->hide();
+    break;
+  case 1:
+    g[3]->show();
+    y += g[3]->h();
+    if(dlg->toggleButtonAdvMetis->value()) {
+      g[4]->show();
+      y += g[4]->h();
+    }
+    else g[4]->hide();
+    g[1]->hide();
+    g[2]->hide();
+    break;
+  }
+  // Reset the vertical position of all widgets in group 6
+  {
+    int yG = y;
+    g[5]->position(g[5]->x(), yG);
+    Fl_Widget *o = static_cast<Fl_Group*>(g[5])->child(0);
+    o->position(o->x(), yG);
+    yG += WB + o->h();
+    o = static_cast<Fl_Group*>(g[5])->child(1);
+    o->position(o->x(), yG);
+    o = static_cast<Fl_Group*>(g[5])->child(2);
+    o->position(o->x(), yG);
+    o = static_cast<Fl_Group*>(g[5])->child(3);
+    o->position(o->x(), yG);
+    yG += WB + o->h();
+  }
+  y += g[5]->h();
+  // Resize and redraw the window
+  dlg->window->size(dlg->window->w(), y);
+  dlg->window->redraw();
+}
+
+void partition_dialog()
+{
+  static PartitionDialog dlg;
+
+  static Fl_Menu_Item partitionTypeMenu[] = {
+    {"Chaco", 0, 0, 0},
+    {"Metis", 0, 0, 0},
+    {0}
+  };
+
+  static Fl_Menu_Item chacoAlgMenu[] = {
+    {"Multilevel-KL", 0, 0, 0},
+    {"Spectral", 0, 0, 0},
+    {"Inertial", 0, 0, 0, FL_MENU_INACTIVE},
+    {"Linear", 0, 0, 0},
+    {"Random", 0, 0, 0},
+    {"Scattered", 0, 0, 0},
+    {0}
+  };
+
+  static Fl_Menu_Item metisAlgMenu[] = {
+    {"Recursive", 0, 0, 0},
+    {"K-way", 0, 0, 0},
+    {0}
+  };
+
+  static Fl_Menu_Item chachoArchitectureMenu[] = {
+    {"Hypercube", 0, 0, 0},
+    {"1-D Mesh", 0, 0, 0},
+    {"2-D Mesh", 0, 0, 0},
+    {"3-D Mesh", 0, 0, 0},
+    {0}
+  };
+
+  static Fl_Menu_Item chachoLocalMethodMenu[] = {
+    {"Kernighan-Lin", 0, 0, 0},
+    {"None", 0, 0, 0},
+    {0}
+  };
+
+  static Fl_Menu_Item chachoEigSolMenu[] = {
+    {"Lanczos", 0, 0, 0},
+    {"Multilevel RQI/Symmlq", 0, 0, 0},
+    {0}
+  };
+
+  static Fl_Menu_Item chachoDivisionsMenu[] = {
+    {"Bisection", 0, 0, 0},
+    {"Quadrisection", 0, 0, 0},
+    {"Octasection", 0, 0, 0},
+    {0}
+  };
+
+  static Fl_Menu_Item metisEdgeMatchingMenu[] = {
+    {"Random", 0, 0, 0},
+    {"Heavy-edge", 0, 0, 0},
+    {"Sorted heavy-edge", 0, 0, 0},
+    {0}
+  };
+
+  static Fl_Menu_Item metisRefineAlgMenu[] = {
+    {"Random", 0, 0, 0},
+    {"Greedy", 0, 0, 0},
+    {"Random (Min. Conn.)", 0, 0, 0},
+    {0}
+  };
+
+  int _fontsize = GetFontSize();
+
+  const int h = 6 * WB + 3 * BH + 4;    // This will be resized based on groups
+                                        // that are displayed
+  const int w = 3 * BB + IW + 3 * WB;   // Window width
+  int y = 0;
+
+  dlg.window = new dialogWindow(w, h, CTX.non_modal_windows,
+                                 "Partitioner Options");
+  dlg.window->box(GMSH_WINDOW_BOX);
+  dlg.window->callback((Fl_Callback *)partition_cancel_cb, &dlg);
+
+  // Main options group [0]
+  {
+    const int GH = BH + 2 + 3*WB;
+    y += WB;
+    Fl_Group *g = new Fl_Group(0, y, w, GH);
+    // Partitioner
+    {
+      Fl_Choice *const o = new Fl_Choice(WB, y, BB, BH, "Partitioner");
+      dlg.choicePartitioner = o;
+      o->menu(partitionTypeMenu);
+      o->callback((Fl_Callback *)partition_select_groups_cb, &dlg);
+#if !defined(HAVE_CHACO)
+      o->mode(0, FL_MENU_INACTIVE);
+#endif
+#if !defined(HAVE_METIS)
+      o->mode(1, FL_MENU_INACTIVE);
+#endif
+      o->align(FL_ALIGN_RIGHT);
+    }
+    // Number of partitions
+    {
+      Fl_Value_Input *const o = new Fl_Value_Input
+        (2*WB + 2*BB, y, IW, BH, "Number of\nPartitions");
+      dlg.inputNumPartition = o;
+      o->minimum(1);
+      o->maximum(std::numeric_limits<int>::max());
+      o->callback((Fl_Callback *)partition_opt_num_partitions_cb, &dlg);
+      o->step(1);
+      o->align(FL_ALIGN_RIGHT);
+    }
+    y += BH + WB;
+    // Box (line)
+    { Fl_Box* o = new Fl_Box(WB, y, w - 2*WB, 2);
+      o->box(FL_ENGRAVED_FRAME);
+      o->labeltype(FL_NO_LABEL);
+    }
+    y += 2 + WB;
+    g->end();
+    g->show();
+  }
+  const int yMain = y;
+
+  // Chaco options group [1]
+  {
+    const int GH = BH + WB;
+    Fl_Group *g = new Fl_Group(0, y, w, GH);
+    // Algorithm
+    {
+      Fl_Choice *const o = new Fl_Choice(WB, y, IW, BH, "Global Algorithm");
+      dlg.choiceChacoAlg = o;
+      o->menu(chacoAlgMenu);
+      o->callback((Fl_Callback *)partition_opt_chaco_globalalg_cb, &dlg);
+      o->align(FL_ALIGN_RIGHT);
+    }
+    // Advanced Button
+    {
+      Fl_Toggle_Button *const o = new Fl_Toggle_Button
+        (w - (WB + BB), y, BB, BH, "Advanced @-22->");
+      dlg.toggleButtonAdvChaco = o;
+      o->callback((Fl_Callback *)partition_select_groups_cb, &dlg);
+    }
+    y += BH + WB;
+    g->end();
+    g->hide();
+  }
+
+  // Chaco advanced options group [2]
+  {
+    const int GH = 2 + WB + 5*(BH + WB) + BH + 6;
+    Fl_Group *g = new Fl_Group(0, y, w, GH);
+    // Box (line)
+    {
+      Fl_Box *const o = new Fl_Box(WB, y, w - 2*WB, 2);
+      o->box(FL_ENGRAVED_FRAME);
+      o->labeltype(FL_NO_LABEL);
+    }
+    y += 2 + WB + 1;  // +1 for multiline label
+    // Architecture
+    {
+      Fl_Choice *const o = new Fl_Choice(WB, y, BB, BH, "Architecture");
+      dlg.choiceArchitecture = o;
+      o->menu(chachoArchitectureMenu);
+      o->callback((Fl_Callback *)partition_opt_architecture_cb, &dlg);
+      o->align(FL_ALIGN_RIGHT);
+    }
+    // Mesh_dim1
+    {
+      Fl_Value_Input *const o = new Fl_Value_Input
+        (2*WB + 2*BB, y, IW/3, BH);
+      dlg.inputNumPartition1 = o;
+      o->minimum(1);
+      o->maximum(std::numeric_limits<int>::max());
+      o->callback((Fl_Callback *)partition_opt_num_partitions_cb, &dlg);
+      o->step(1);
+    }
+    // Mesh_dim2
+    {
+      Fl_Value_Input *const o = new Fl_Value_Input
+        (2*WB + 2*BB + IW/3, y, IW/3, BH);
+      dlg.inputNumPartition2 = o;
+      o->minimum(1);
+      o->maximum(std::numeric_limits<int>::max());
+      o->callback((Fl_Callback *)partition_opt_num_partitions_cb, &dlg);
+      o->step(1);
+    }
+    // Mesh_dim3
+    {
+      Fl_Value_Input *const o = new Fl_Value_Input
+        (2*WB + 2*BB + 2*IW/3, y, IW/3, BH);
+      dlg.inputNumPartition3 = o;
+      o->minimum(1);
+      o->maximum(std::numeric_limits<int>::max());
+      o->callback((Fl_Callback *)partition_opt_num_partitions_cb, &dlg);
+      o->step(1);
+    }
+    // Label
+    {
+      Fl_Box *const o = new Fl_Box(2*WB + 2*BB + IW, y, 0, BH,
+                                   "Topology\ndimensions");
+      o->align(FL_ALIGN_RIGHT);
+    }
+    y += BH + WB + 2;  // +2 for multiline labels
+    // Divisions
+    {
+      Fl_Choice *const o = new Fl_Choice(WB, y, BB, BH, "Divisions");
+      dlg.choiceDivisions = o;
+      o->copy(chachoDivisionsMenu);
+      o->callback((Fl_Callback *)partition_opt_spectralcheck_cb, &dlg);
+      o->align(FL_ALIGN_RIGHT);
+    }
+    // Vmax
+    {
+      Fl_Value_Input *const o = new Fl_Value_Input
+        (2*WB + 2*BB, y, IW, BH, "Max. vertices in\ncoarse graph");
+      dlg.inputVMax = o;
+      o->minimum(2);
+      o->maximum(std::numeric_limits<double>::max());
+      o->step(1);
+      o->align(FL_ALIGN_RIGHT);
+    }
+    y += BH + WB + 2;  // +2 for multiline labels
+    // Eigensolver
+    {
+      Fl_Choice *const o = new Fl_Choice(WB, y, BB, BH, "Eigensolver");
+      dlg.choiceEigensolver = o;
+      o->menu(chachoEigSolMenu);
+      o->align(FL_ALIGN_RIGHT);
+    }
+    // Eigtol
+    {
+      Fl_Value_Input *const o = new Fl_Value_Input
+        (2*WB + 2*BB, y, IW, BH, "Eigensolver\ntolerance");
+      dlg.inputEigtol = o;
+      o->minimum(std::numeric_limits<double>::min());
+      o->maximum(std::numeric_limits<double>::max());
+      o->step(5.E-3);
+      o->align(FL_ALIGN_RIGHT);
+    }
+    y += BH + WB + 1;  // +1 for multiline label
+    // Local method
+    {
+      Fl_Choice *const o = new Fl_Choice(WB, y, BB, BH, "Local algorithm");
+      dlg.choiceLocalAlgorithm = o;
+      o->menu(chachoLocalMethodMenu);
+      o->align(FL_ALIGN_RIGHT);
+    }
+    // Seed
+    {
+      Fl_Value_Input *const o = new Fl_Value_Input
+        (2*WB + 2*BB, y, IW, BH, "Seed");
+      dlg.inputSeed = o;
+      o->minimum(1);
+      o->maximum(std::numeric_limits<int>::max());
+      o->step(1);
+      o->align(FL_ALIGN_RIGHT);
+    }
+    y += BH + WB;
+    // Parameters
+    {
+      Fl_Check_Button *const o = new Fl_Check_Button(WB, y, 2*WB, BH,
+                                                     "Refine partition");
+      dlg.checkButtonRefPart = o;
+      o->align(FL_ALIGN_RIGHT);
+    }
+    {
+      Fl_Check_Button *const o = new Fl_Check_Button(2*WB + 2*BB, y, 2*WB, BH,
+                                                     "Internal vertices");
+      dlg.checkButtonIntVert = o;
+      o->align(FL_ALIGN_RIGHT);
+    }
+    y += BH;
+    {
+      Fl_Check_Button *const o = new Fl_Check_Button(WB, y, 2*WB, BH,
+                                                     "Refine map");
+      dlg.checkButtonRefMap = o;
+      o->align(FL_ALIGN_RIGHT);
+    }
+    {
+      Fl_Check_Button *const o = new Fl_Check_Button(2*WB + 2*BB, y, 2*WB, BH,
+                                                     "Terminal propogation");
+      dlg.checkButtonTermProp = o;
+      o->callback((Fl_Callback *)partition_opt_spectralcheck_cb, &dlg);
+      o->align(FL_ALIGN_RIGHT);
+    }
+    y += BH + WB;
+    g->end();
+    g->hide();
+  }
+
+  // Metis options group [3]
+  y = yMain;
+  {
+    const int GH = BH + WB;
+    Fl_Group *g = new Fl_Group(0, y, w, GH);
+    // Algorithm
+    {
+      Fl_Choice *const o = new Fl_Choice(WB, y, BB, BH, "Algorithm");
+      dlg.choiceMetisAlg = o;
+      o->menu(metisAlgMenu);
+      o->align(FL_ALIGN_RIGHT);
+    }
+    // Advanced Button
+    {
+      Fl_Toggle_Button *const o = new Fl_Toggle_Button
+        (w - (WB + BB), y, BB, BH, "Advanced @-22->");
+      dlg.toggleButtonAdvMetis = o;
+      o->callback((Fl_Callback *)partition_select_groups_cb, &dlg);
+    }
+    y += BH + WB;
+    g->end();
+    g->hide();
+  }
+
+  // Metis advanced option group [4]
+  {
+    const int GH = 2 + WB + (BH + WB) + 2;
+    Fl_Group *g = new Fl_Group(0, y, w, GH);
+    // Box (line)
+    {
+      Fl_Box *const o = new Fl_Box(WB, y, w - 2*WB, 2);
+      o->box(FL_ENGRAVED_FRAME);
+      o->labeltype(FL_NO_LABEL);
+    }
+    y += 2 + WB + 1;  // +1 for multiline label
+    // Edge matching algorithm
+    {
+      Fl_Choice *const o = new Fl_Choice(WB, y, BB, BH, "Edge matching");
+      dlg.choiceEdgeMatch = o;
+      o->menu(metisEdgeMatchingMenu);
+      o->align(FL_ALIGN_RIGHT);
+    }
+    // Refinement algorithm
+    {
+      Fl_Choice *const o = new Fl_Choice(2*WB + 2*BB, y, BB, BH,
+                                         "Refinement\nalgorithm");
+      dlg.choiceRefineAlg = o;
+      o->menu(metisRefineAlgMenu);
+      o->align(FL_ALIGN_RIGHT);
+    }
+    y += BH + WB + 1;  // +1 for multiline label
+    g->end();
+    g->hide();
+  }
+  
+  // Dialog termination group [5]
+  {
+    const int GH = 2 + BH + 2*WB;
+    Fl_Group *g = new Fl_Group(0, y, w, GH);
+    // Box (line) [0]
+    {
+      Fl_Box *const o = new Fl_Box(WB, y, w - 2*WB, 2);
+      o->box(FL_ENGRAVED_FRAME);
+      o->labeltype(FL_NO_LABEL);
+    }
+    y += 2 + WB;
+    // Defaults Button [1]
+    {
+      Fl_Button *const o = new Fl_Button
+         (WB, y, BB, BH, "Defaults");
+      o->callback((Fl_Callback *)partition_defaults_cb, &dlg);
+    }
+    // Partition Button [2]
+    {
+      Fl_Return_Button *const o = new Fl_Return_Button
+        (w - 2*(WB + BB), y, BB, BH, "Partition");
+      o->callback((Fl_Callback *)partition_partition_cb, &dlg);
+    }
+    // Cancel Button [3]
+    {
+      Fl_Button *const o = new Fl_Button(w - (WB + BB), y, BB, BH, "Cancel");
+      o->callback((Fl_Callback *)partition_cancel_cb, &dlg);
+    }
+    y += BH + WB;
+    g->end();
+    g->show();
+  }
+
+  dlg.window->end();
+  dlg.window->hotspot(dlg.window);
+
+  dlg.read_all_options();
+  // Set the groups to be initally displayed
+  partition_select_groups_cb(dlg.window, &dlg);
+  dlg.window->show();
+}
+
+#else
+
+void partition_dialog()
+{
+  Msg::Error("Gmsh has to be compiled with METIS or CHACO support to partition meshes");
+}
+
+#endif
diff --git a/Fltk/partitionDialog.h b/Fltk/partitionDialog.h
new file mode 100644
index 0000000000000000000000000000000000000000..f0484381f73c191912f0cd7632921bb1f26e7317
--- /dev/null
+++ b/Fltk/partitionDialog.h
@@ -0,0 +1,11 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+
+#ifndef _PARTITION_DIALOG_H_
+#define _PARTITION_DIALOG_H_
+
+void partition_dialog();
+
+#endif
diff --git a/Fltk/pluginWindow.cpp b/Fltk/pluginWindow.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6aac712470289970c86df745eee230692c36029e
--- /dev/null
+++ b/Fltk/pluginWindow.cpp
@@ -0,0 +1,187 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+
+#include <vector>
+#include <FL/Fl_Box.H>
+#include <FL/Fl_Tabs.H>
+#include <FL/Fl_Scroll.H>
+#include "GUI.h"
+#include "pluginWindow.h"
+#include "shortcutWindow.h"
+#include "PView.h"
+#include "PluginManager.h"
+#include "Plugin.h"
+#include "Callbacks.h"
+#include "Context.h"
+
+extern Context_T CTX;
+
+pluginWindow::pluginWindow(int fontsize) : _fontsize(fontsize)
+{
+  int width0 = 34 * _fontsize + WB;
+  int height0 = 13 * BH + 5 * WB;
+
+  int width = (CTX.plugin_size[0] < width0) ? width0 : CTX.plugin_size[0];
+  int height = (CTX.plugin_size[1] < height0) ? height0 : CTX.plugin_size[1];
+
+  win = new dialogWindow(width, height, CTX.non_modal_windows, "Plugins");
+  win->box(GMSH_WINDOW_BOX);
+
+  {
+    Fl_Button *o = new Fl_Button
+      (width - BB - WB, height - BH - WB, BB, BH, "Cancel");
+    o->callback(view_plugin_cancel_cb);
+  }
+  {
+    run = new Fl_Return_Button
+      (width - 2 * BB - 2 * WB, height - BH - WB, BB, BH, "Run");
+    run->callback(view_plugin_run_cb);
+  }
+  
+  int L1 = (int)(0.3 * width), L2 = (int)(0.6 * L1);
+  browser = new Fl_Hold_Browser(WB, WB, L1, height - 3 * WB - BH);
+  browser->callback(view_plugin_browser_cb);
+
+  view_browser = new Fl_Multi_Browser(WB + L1, WB, L2, height - 3 * WB - BH);
+  view_browser->has_scrollbar(Fl_Browser_::VERTICAL);
+  view_browser->callback(view_plugin_browser_cb);
+
+  for(GMSH_PluginManager::iter it = GMSH_PluginManager::instance()->begin();
+      it != GMSH_PluginManager::instance()->end(); ++it) {
+    GMSH_Plugin *p = (*it).second;
+    if(p->getType() == GMSH_Plugin::GMSH_POST_PLUGIN) {
+      char name[256];
+      p->getName(name);
+      browser->add(name, p);
+      createDialogBox(p, 2 * WB + L1 + L2, WB, width - L1 - L2 - 3 * WB, 
+                      height - 3 * WB - BH);
+      // select first plugin by default
+      if(it == GMSH_PluginManager::instance()->begin()){
+        browser->select(1);
+        p->dialogBox->group->show();
+      }
+    }
+  }
+  
+  Fl_Box *resize_box = new Fl_Box(3*WB + L1+L2, WB, WB, height - 3 * WB - BH);
+  win->resizable(resize_box);
+  win->size_range(width0, height0);
+
+  win->position(CTX.plugin_position[0], CTX.plugin_position[1]);
+  win->end();
+}
+
+void pluginWindow::show(int viewIndex)
+{
+  resetViewBrowser();
+  if(viewIndex >= 0 && viewIndex < (int)PView::list.size()){
+    view_browser->deselect();
+    view_browser->select(viewIndex + 1);
+    view_plugin_browser_cb(NULL, NULL);
+  }
+  win->show();
+}
+
+void pluginWindow::createDialogBox(GMSH_Plugin *p, int x, int y, int width, int height)
+{
+  p->dialogBox = new PluginDialogBox;
+  p->dialogBox->group = new Fl_Group(x, y, width, height);
+
+  {
+    Fl_Tabs *o = new Fl_Tabs(x, y, width, height);
+    {
+      Fl_Group *g = new Fl_Group
+        (x, y + BH, width, height - BH, "Options");
+      Fl_Scroll *s = new Fl_Scroll
+        (x + WB, y + WB + BH, width - 2 * WB, height - BH - 2 * WB);
+
+      int m = p->getNbOptionsStr();
+      if(m > MAX_PLUGIN_OPTIONS) m = MAX_PLUGIN_OPTIONS;
+
+      int n = p->getNbOptions();
+      if(n > MAX_PLUGIN_OPTIONS) n = MAX_PLUGIN_OPTIONS;
+
+      int k = 0;
+      for(int i = 0; i < m; i++) {
+        StringXString *sxs = p->getOptionStr(i);
+        p->dialogBox->input[i] = new Fl_Input
+          (x + WB, y + WB + (k + 1) * BH, IW, BH, sxs->str);
+        p->dialogBox->input[i]->align(FL_ALIGN_RIGHT);
+        p->dialogBox->input[i]->value(sxs->def);
+        k++;
+      }
+      for(int i = 0; i < n; i++) {
+        StringXNumber *sxn = p->getOption(i);
+        p->dialogBox->value[i] = new Fl_Value_Input
+          (x + WB, y + WB + (k + 1) * BH, IW, BH, sxn->str);
+        p->dialogBox->value[i]->align(FL_ALIGN_RIGHT);
+        p->dialogBox->value[i]->value(sxn->def);
+        k++;
+      }
+
+      s->end();
+      g->end();
+      o->resizable(g); // to avoid ugly resizing of tab labels
+    }
+    {
+      Fl_Group *g = new Fl_Group(x, y + BH, width, height - BH, "About");
+
+      Fl_Browser *o = new Fl_Browser
+        (x + WB, y + WB + BH, width - 2 * WB, height - 2 * WB - BH);
+
+      char name[1024], copyright[256], author[256], help[4096];
+      p->getName(name);
+      p->getInfos(author, copyright, help);
+
+      o->add(" ");
+      add_multiline_in_browser(o, "@c@b@.", name, false);
+      o->add(" ");
+      add_multiline_in_browser(o, "", help, false);
+      o->add(" ");
+      add_multiline_in_browser(o, "Author: ", author, false);
+      add_multiline_in_browser(o, "Copyright (C) ", copyright, false);
+      o->add(" ");
+
+      g->end();
+    }
+    o->end();
+  }
+
+  p->dialogBox->group->end();
+  p->dialogBox->group->hide();
+}
+
+void pluginWindow::resetViewBrowser()
+{
+  // save selected state
+  std::vector<int> state;
+  for(int i = 0; i < view_browser->size(); i++){
+    if(view_browser->selected(i + 1))
+      state.push_back(1);
+    else
+      state.push_back(0);
+  }
+
+  char str[128];
+  view_browser->clear();
+
+  if(PView::list.size()){
+    view_browser->activate();
+    for(unsigned int i = 0; i < PView::list.size(); i++) {
+      sprintf(str, "View [%d]", i);
+      view_browser->add(str);
+    }
+    for(int i = 0; i < view_browser->size(); i++){
+      if(i < (int)state.size() && state[i])
+        view_browser->select(i + 1);
+    }
+  }
+  else{
+    view_browser->add("No Views");
+    view_browser->deactivate();
+  }
+
+  view_plugin_browser_cb(NULL, NULL);
+}
diff --git a/Fltk/pluginWindow.h b/Fltk/pluginWindow.h
new file mode 100644
index 0000000000000000000000000000000000000000..697a4eae1059ae1fe36036ab689a3f9f53acda32
--- /dev/null
+++ b/Fltk/pluginWindow.h
@@ -0,0 +1,41 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+
+#ifndef _PLUGIN_WINDOW_H_
+#define _PLUGIN_WINDOW_H_
+
+#include <FL/Fl_Window.H>
+#include <FL/Fl_Hold_Browser.H>
+#include <FL/Fl_Multi_Browser.H>
+#include <FL/Fl_Return_Button.H>
+#include <FL/Fl_Group.H>
+#include <FL/Fl_Value_Input.H>
+#include <FL/Fl_Input.H>
+
+class GMSH_Plugin;
+
+#define MAX_PLUGIN_OPTIONS 50
+struct PluginDialogBox{
+  Fl_Group *group;
+  Fl_Value_Input *value[MAX_PLUGIN_OPTIONS];
+  Fl_Input *input[MAX_PLUGIN_OPTIONS];
+};
+
+class pluginWindow{
+ private:
+  int _fontsize;
+ public:
+  Fl_Window *win;
+  Fl_Hold_Browser *browser;
+  Fl_Multi_Browser *view_browser;
+  Fl_Return_Button *run;
+ public:
+  pluginWindow(int fontsize);
+  void show(int viewIndex);
+  void createDialogBox(GMSH_Plugin *p, int x, int y, int width, int height);
+  void resetViewBrowser();
+};
+
+#endif
diff --git a/Fltk/Popup_Button.h b/Fltk/popupButton.h
similarity index 79%
rename from Fltk/Popup_Button.h
rename to Fltk/popupButton.h
index 912d57379b6b2f21d43021b3d398e16176c2fee2..b54185968c7b4548ac58f998e2baf352be22fa29 100644
--- a/Fltk/Popup_Button.h
+++ b/Fltk/popupButton.h
@@ -6,18 +6,15 @@
 #ifndef _POPUP_BUTTON_H
 #define _POPUP_BUTTON_H
 
-#include "GmshUI.h"
+#include <FL/Fl.H>
 #include <FL/Fl_Menu_Button.H>
 
-// We need to define our own popup button to fix a bug in FLTK 1.1.7
-// (popup() in 1.1.7 calls redraw() after picked(), which can cause a
-// crash if the button was deleted by the callback)
-
-// Update Sat Apr 29 21:39:00 2006: this bug is now fixed in FLTK.
-
-class Popup_Button : public Fl_Menu_Button {
+// This is needed for FLTK < 1.1.8 (popup() in 1.1.7 calls redraw()
+// after picked(), which can cause a crash if the button was deleted
+// by the callback)
+class popupButton : public Fl_Menu_Button {
  public:
-  Popup_Button(int x, int y, int w, int h, char *label=0) 
+  popupButton(int x, int y, int w, int h, char *label=0) 
     : Fl_Menu_Button(x, y, w, h, label) {}
   void draw(){ Fl_Menu_Button::draw(); }
   int handle(int e)
diff --git a/Fltk/GUI_Projection.cpp b/Fltk/projectionEditor.cpp
similarity index 96%
rename from Fltk/GUI_Projection.cpp
rename to Fltk/projectionEditor.cpp
index aa609b8b51be17c4f3ed3022d01816d6ecd70cf8..55f1ea5c108842fd4dfd206be7e1ce8fbfda69cb 100644
--- a/Fltk/GUI_Projection.cpp
+++ b/Fltk/projectionEditor.cpp
@@ -2,17 +2,23 @@
 //
 // See the LICENSE.txt file for license information. Please report all
 // bugs and problems to <gmsh@geuz.org>.
+
+#include <FL/fl_draw.H>
+#include <FL/Fl_Box.H>
+#include <FL/Fl_Scroll.H>
+#include <FL/Fl_Repeat_Button.H>
+#include "GUI.h"
+#include "projectionEditor.h"
+#include "fileDialogs.h"
 #include "GModelIO_Fourier.h"
 #include "MElement.h"
 #include "Draw.h"
 #include "Options.h"
-#include "Context.h"
 #include "StringUtils.h"
 #include "SelectBuffer.h"
-#include "GUI_Projection.h"
-#include "GUI_Extras.h"
 #include "fourierFace.h"
 #include "GmshMessage.h"
+#include "Context.h"
 
 extern Context_T CTX;
 
@@ -138,20 +144,20 @@ void uvPlot::draw()
 }
 
 projection::projection(fourierProjectionFace *f, int x, int y, int w, int h, 
-                       int BB, int BH, projectionEditor *e) 
+                       int bb, int bh, projectionEditor *e) 
   : face(f)
 {
   group = new Fl_Scroll(x, y, w, h);
   SBoundingBox3d bounds = GModel::current()->bounds();
   FM::ProjectionSurface *ps = (FM::ProjectionSurface*)f->getNativePtr();
   
-  Fl_Toggle_Button *b = new Fl_Toggle_Button(x, y, BB, BH, "Set position");
+  Fl_Toggle_Button *b = new Fl_Toggle_Button(x, y, bb, bh, "Set position");
   b->callback(set_position_cb, e);
   
   { // origin is stored in parameters[0,1,2]
     SPoint3 pc = bounds.center();
     for(int i = 0; i < 3; i++){
-      Fl_Value_Input *v = new Fl_Value_Input(x, y + (1 + i) * BH, BB, BH);
+      Fl_Value_Input *v = new Fl_Value_Input(x, y + (1 + i) * bh, bb, bh);
       parameters.push_back(v);
       v->maximum(bounds.max()[i] + 10. * CTX.lc);
       v->minimum(bounds.min()[i] - 10. * CTX.lc);
@@ -162,12 +168,12 @@ projection::projection(fourierProjectionFace *f, int x, int y, int w, int h,
     ps->SetOrigin(pc[0], pc[1], pc[2]);
     Fl_Repeat_Button *bm[3], *bp[3];
     for(int i = 0; i < 3; i++){
-      new Fl_Box(x + w - BB / 3 - BB / 6, y + (1 + i) * BH, BB / 8, BH, 
+      new Fl_Box(x + w - bb / 3 - bb / 6, y + (1 + i) * bh, bb / 8, bh, 
                  (i == 0) ? "E0" : (i == 1) ? "E1" : "E2");
-      bp[i] = new Fl_Repeat_Button(x + w - BB / 3, y + (1 + i) * BH, 
-                                   BB / 8, BH / 2, "+");
-      bm[i] = new Fl_Repeat_Button(x + w - BB / 3, y + (1 + i) * BH + BH / 2,
-                                   BB / 8, BH / 2, "-");
+      bp[i] = new Fl_Repeat_Button(x + w - bb / 3, y + (1 + i) * bh, 
+                                   bb / 8, bh / 2, "+");
+      bm[i] = new Fl_Repeat_Button(x + w - bb / 3, y + (1 + i) * bh + bh / 2,
+                                   bb / 8, bh / 2, "-");
     }
     bp[0]->callback(translate_p0_cb, e);
     bp[1]->callback(translate_p1_cb, e);
@@ -177,22 +183,22 @@ projection::projection(fourierProjectionFace *f, int x, int y, int w, int h,
     bm[2]->callback(translate_m2_cb, e);
   }
   { // normal is stored in parameters[3,4,5]
-    Fl_Value_Input *v1 = new Fl_Value_Input(x, y + 4 * BH, BB / 3, BH);
+    Fl_Value_Input *v1 = new Fl_Value_Input(x, y + 4 * bh, bb / 3, bh);
     parameters.push_back(v1);
     v1->maximum(1.); v1->minimum(-1.); v1->step(0.01); v1->value(0.);
-    Fl_Value_Input *v2 = new Fl_Value_Input(x + BB / 3, y + 4 * BH, BB / 3, BH);
+    Fl_Value_Input *v2 = new Fl_Value_Input(x + bb / 3, y + 4 * bh, bb / 3, bh);
     parameters.push_back(v2);
     v2->maximum(1.); v2->minimum(-1.); v2->step(0.01); v2->value(0.);
-    Fl_Value_Input *v3 = new Fl_Value_Input(x + 2 * BB / 3, y + 4 * BH, BB - 2 * BB / 3, BH);
+    Fl_Value_Input *v3 = new Fl_Value_Input(x + 2 * bb / 3, y + 4 * bh, bb - 2 * bb / 3, bh);
     parameters.push_back(v3);
     v3->maximum(1.); v3->minimum(-1.); v3->step(0.01); v3->value(1.);
     v3->label("Normal");
-    Fl_Button *b = new Fl_Button(x + w - BB / 3, y + 4 * BH + BH / 4, BB / 8, BH / 2, "-");
+    Fl_Button *b = new Fl_Button(x + w - bb / 3, y + 4 * bh + bh / 4, bb / 8, bh / 2, "-");
     b->callback(invert_normal_cb, e);
     b->tooltip("Invert normal");
   }
   { // rotation is stored in parameters[6]
-    Fl_Value_Input *v = new Fl_Value_Input(x, y + 5 * BH, BB, BH, "Rotation");
+    Fl_Value_Input *v = new Fl_Value_Input(x, y + 5 * bh, bb, bh, "Rotation");
     v->maximum(-180.);
     v->minimum(180.);
     v->step(0.1);
@@ -201,7 +207,7 @@ projection::projection(fourierProjectionFace *f, int x, int y, int w, int h,
   }
   { // scale is stored in parameters[7,8,9]
     for(int i = 0; i < 3; i++){
-      Fl_Value_Input *v = new Fl_Value_Input(x, y + (6 + i) * BH, BB, BH);
+      Fl_Value_Input *v = new Fl_Value_Input(x, y + (6 + i) * bh, bb, bh);
       parameters.push_back(v);
       v->maximum(CTX.lc * 10.);
       v->minimum(CTX.lc / 100.);
@@ -213,7 +219,7 @@ projection::projection(fourierProjectionFace *f, int x, int y, int w, int h,
 
   // other parameters are stored in parameters[10,...]
   for(int i = 0; i < ps->GetNumParameters(); i++){
-    Fl_Value_Input *v = new Fl_Value_Input(x, y + (9 + i) * BH, BB, BH);
+    Fl_Value_Input *v = new Fl_Value_Input(x, y + (9 + i) * bh, bb, bh);
     v->maximum(10. * CTX.lc);
     v->minimum(-10. * CTX.lc);
     v->step(CTX.lc / 100.);
@@ -241,11 +247,11 @@ projectionEditor::projectionEditor()
   printf("currentSize = %d\n",m->getFMInternals()->current()->GetNumGroups());
 
   // construct GUI in terms of standard sizes
-  const int BH = 2 * GetFontSize() + 1, BB = 7 * GetFontSize(), WB = 7;
+  int _fontsize = GetFontSize();
   const int width = (int)(3.75 * BB), height = 25 * BH;
   
   // create all widgets (we construct this once, we never deallocate!)
-  _window = new Dialog_Window(width, height, CTX.non_modal_windows, "Reparameterize");
+  _window = new dialogWindow(width, height, CTX.non_modal_windows, "Reparameterize");
   
   new Fl_Box(WB, WB + BH / 2, BB / 2, BH, "Select:");
   
@@ -417,6 +423,12 @@ void projectionEditor::load(fourierProjectionFace *face, std::string tag)
   _window->add(p->group);
 }
 
+void projectionEditor::show()
+{ 
+  _window->show(); 
+  select_cb(0, this); 
+}
+
 int projectionEditor::getSelectionMode() 
 { 
   if(_select[0]->value())
diff --git a/Fltk/GUI_Projection.h b/Fltk/projectionEditor.h
similarity index 93%
rename from Fltk/GUI_Projection.h
rename to Fltk/projectionEditor.h
index bd7e2ce12d9c8f3f91d8d0dc97abdb48f0094f14..95392bd2c352a0f8ac42b96e57dfc276f985bdfa 100644
--- a/Fltk/GUI_Projection.h
+++ b/Fltk/projectionEditor.h
@@ -3,46 +3,25 @@
 // See the LICENSE.txt file for license information. Please report all
 // bugs and problems to <gmsh@geuz.org>.
 
-#ifndef _GUI_PROJECTION_H_
-#define _GUI_PROJECTION_H_
+#ifndef _PROJECTION_EDITOR_H_
+#define _PROJECTION_EDITOR_H_
 
-#include "GmshUI.h"
-#include "GModel.h"
-#include "fourierProjectionFace.h"
-#include "GUI.h"
-#include "Shortcut_Window.h"
-#include "ColorTable.h"
-#include <FL/Fl_Toggle_Button.H>
-#include <FL/Fl_Round_Button.H>
 #include <vector>
 #include <complex>
+#include <FL/Fl_Toggle_Button.H>
+#include <FL/Fl_Round_Button.H>
+#include <FL/Fl_Value_Input.H>
+#include <FL/Fl_Hold_Browser.H>
+#include "shortcutWindow.h"
+#include "fourierProjectionFace.h"
+#include "GModel.h"
+#include "ColorTable.h"
 
 #if defined(HAVE_FOURIER_MODEL)
 
 #include "FM_FPatch.h"
 #include "FM_WFPatch.h"
 
-void select_cb(Fl_Widget *w, void *data);
-void filter_cb(Fl_Widget *w, void *data);
-void browse_cb(Fl_Widget *w, void *data);
-void set_position_cb(Fl_Widget *w, void *data);
-void invert_normal_cb(Fl_Widget *w, void *data);
-void translate_p0_cb(Fl_Widget *w, void *data);
-void translate_p1_cb(Fl_Widget *w, void *data);
-void translate_p2_cb(Fl_Widget *w, void *data);
-void translate_m0_cb(Fl_Widget *w, void *data);
-void translate_m1_cb(Fl_Widget *w, void *data);
-void translate_m2_cb(Fl_Widget *w, void *data);
-void update_cb(Fl_Widget *w, void *data);
-void close_cb(Fl_Widget *w, void *data);
-void hide_cb(Fl_Widget *w, void *data);
-void save_selection_cb(Fl_Widget *w, void *data);
-void load_projection_cb(Fl_Widget *w, void *data);
-void save_projection_cb(Fl_Widget *w, void *data);
-void blend_cb(Fl_Widget *w, void *data);
-void compute_cb(Fl_Widget *w, void *data);
-void action_cb(Fl_Widget *w, void *data);
-
 class uvPlot : public Fl_Window {
  private:
   std::vector<double> _u, _v, _dist;
@@ -67,8 +46,8 @@ class projection {
   fourierProjectionFace *face;
   Fl_Group *group;
   std::vector<Fl_Value_Input*> parameters;
-  projection(fourierProjectionFace *f, int x, int y, int w, int h, int BB, int BH,
-             projectionEditor *e);
+  projection(fourierProjectionFace *f, int x, int y, int w, int h, 
+             int bb, int bh, projectionEditor *e);
 };
 
 class projectionEditor {
@@ -87,7 +66,7 @@ class projectionEditor {
  public:
   projectionEditor();
   void load(fourierProjectionFace *face, std::string tag="");
-  void show(){ _window->show(); select_cb(0, this); }
+  void show();
   uvPlot *uv() { return _uvPlot; }
   std::vector<MElement*> &getElements() { return _elements; }
   std::vector<GEntity*> &getEntities() { return _entities; }
@@ -102,6 +81,27 @@ class projectionEditor {
   double getThreshold(){ return _slider->value(); }
 };
 
+void select_cb(Fl_Widget *w, void *data);
+void filter_cb(Fl_Widget *w, void *data);
+void browse_cb(Fl_Widget *w, void *data);
+void set_position_cb(Fl_Widget *w, void *data);
+void invert_normal_cb(Fl_Widget *w, void *data);
+void translate_p0_cb(Fl_Widget *w, void *data);
+void translate_p1_cb(Fl_Widget *w, void *data);
+void translate_p2_cb(Fl_Widget *w, void *data);
+void translate_m0_cb(Fl_Widget *w, void *data);
+void translate_m1_cb(Fl_Widget *w, void *data);
+void translate_m2_cb(Fl_Widget *w, void *data);
+void update_cb(Fl_Widget *w, void *data);
+void close_cb(Fl_Widget *w, void *data);
+void hide_cb(Fl_Widget *w, void *data);
+void save_selection_cb(Fl_Widget *w, void *data);
+void load_projection_cb(Fl_Widget *w, void *data);
+void save_projection_cb(Fl_Widget *w, void *data);
+void blend_cb(Fl_Widget *w, void *data);
+void compute_cb(Fl_Widget *w, void *data);
+void action_cb(Fl_Widget *w, void *data);
+
 #endif
 
 #endif
diff --git a/Fltk/Shortcut_Window.h b/Fltk/shortcutWindow.h
similarity index 86%
rename from Fltk/Shortcut_Window.h
rename to Fltk/shortcutWindow.h
index ad2d6851da515a7b7df2c205fb154f3e0baeea93..8f1a5f409545e40c3192d449a45c61d12f1b0368 100644
--- a/Fltk/Shortcut_Window.h
+++ b/Fltk/shortcutWindow.h
@@ -6,7 +6,7 @@
 #ifndef _SHORTCUT_WINDOW_H
 #define _SHORTCUT_WINDOW_H
 
-#include "GmshUI.h"
+#include <FL/Fl.H>
 #include <FL/Fl_Window.H>
 #include <FL/Fl_Double_Window.H>
 #include <FL/fl_ask.H>
@@ -14,8 +14,10 @@
 // Derive special windows from Fl_Double_Window to correctly process
 // the OS-specific shorcuts (Cmd-w on Mac, Alt+F4 on Windows)
 
-class Dialog_Window : public Fl_Double_Window {
-  int  handle(int event){
+class dialogWindow : public Fl_Double_Window {
+ private:
+  int handle(int event)
+  {
     switch (event) {
     case FL_SHORTCUT:
     case FL_KEYBOARD:
@@ -34,7 +36,7 @@ class Dialog_Window : public Fl_Double_Window {
     return Fl_Double_Window::handle(event);
   }
  public:
-  Dialog_Window(int w,int h,int nonmodal=false,const char *l=0)
+  dialogWindow(int w, int h, int nonmodal=false, const char *l=0)
     : Fl_Double_Window(w, h, l) 
   {
     if(nonmodal) set_non_modal();
@@ -52,8 +54,10 @@ class Dialog_Window : public Fl_Double_Window {
 // are recreated each time, or the big (already double-buffered)
 // OpenGL area anyway.
 
-class Main_Window : public Fl_Window {
-  int  handle(int event){
+class mainWindow : public Fl_Window {
+ private:
+  int handle(int event)
+  {
     switch (event) {
     case FL_SHORTCUT:
     case FL_KEYBOARD:
@@ -64,7 +68,7 @@ class Main_Window : public Fl_Window {
 #else
       if(Fl::test_shortcut(FL_CTRL+'w')){
 #endif
-        if(fl_choice("Do you really want to quit?", "Cancel", "Quit", NULL))
+        if(fl_choice("Do you really want to quit?", "Cancel", "Quit", 0))
           do_callback();
         return 1;
       }
@@ -73,7 +77,7 @@ class Main_Window : public Fl_Window {
     return Fl_Window::handle(event);
   }
  public:
-  Main_Window(int w,int h,bool nonmodal=false, const char *l=0) 
+  mainWindow(int w, int h, bool nonmodal=false, const char *l=0) 
     : Fl_Window(w, h, l) 
   {
     if(nonmodal) set_non_modal();
diff --git a/Fltk/solverWindow.cpp b/Fltk/solverWindow.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..644de28021cba55bbcf933a217a4751c0c80bee4
--- /dev/null
+++ b/Fltk/solverWindow.cpp
@@ -0,0 +1,133 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+
+#include <FL/Fl_Tabs.H>
+#include <FL/Fl_Box.H>
+#include <FL/Fl_Return_Button.H>
+#include <FL/Fl_Browser.H>
+#include "GUI.h"
+#include "solverWindow.h"
+#include "shortcutWindow.h"
+#include "Solvers.h"
+#include "Callbacks.h"
+#include "Context.h"
+
+extern Context_T CTX;
+
+solverWindow::solverWindow(int solverIndex, int fontsize)
+  : _fontsize(fontsize)
+{
+  for(int i = 0; i < MAX_NUM_SOLVER_OPTIONS; i++)
+    if(strlen(SINFO[solverIndex].option_name[i]))
+      SINFO[solverIndex].nboptions = i + 1;
+
+  int LL = 2 * IW;
+  int width = LL + BB + BB / 3 + 4 * WB;
+  int height = (8 + SINFO[solverIndex].nboptions) * BH + 6 * WB;
+  int BBS = (width - 8 * WB) / 5;
+  
+  win = new dialogWindow
+    (width, height, CTX.non_modal_windows);
+  win->box(GMSH_WINDOW_BOX);
+  {
+    Fl_Tabs *o = new Fl_Tabs
+      (WB, WB, width - 2 * WB, height - 3 * WB - 1 * BH);
+    {
+      Fl_Group *g = new Fl_Group
+        (WB, WB + BH, width - 2 * WB, height - 3 * WB - 2 * BH, "Controls");
+
+      input[2] = new Fl_Input
+        (2 * WB, 2 * WB + 1 * BH, LL, BH, "Solver");
+      input[2]->callback(solver_ok_cb, (void *)solverIndex);
+
+      Fl_Button *b1 = new Fl_Button
+        (width - 2 * WB - BBS, 2 * WB + 1 * BH, BBS, BH, "Choose");
+      b1->callback(solver_choose_executable_cb, (void *)solverIndex);
+      Fl_Button *b2 = new Fl_Button
+        (width - 2 * WB - BBS, 2 * WB + 2 * BH, BBS, BH, "Save");
+      b2->callback(options_save_cb);
+
+      int ww = (LL - WB) / 2;
+      butt[2] = new Fl_Check_Button
+        (2 * WB, 2 * WB + 2 * BH, ww, BH, "Client/server");
+      butt[0] = new Fl_Check_Button
+        (2 * WB, 2 * WB + 3 * BH, ww, BH, "Pop-up messages");
+      butt[1] = new Fl_Check_Button
+        (3 * WB + ww, 2 * WB + 2 * BH, ww, BH, "Auto-load results");
+      
+      for(int i = 0; i < 3; i++){
+        butt[i]->type(FL_TOGGLE_BUTTON);
+        butt[i]->callback(solver_ok_cb, (void *)solverIndex);
+      }
+
+      input[0] = new Fl_Input
+        (2 * WB + BB / 2, 2 * WB + 4 * BH, LL - BB / 2, BH, "Input");
+      Fl_Button *b3 = new Fl_Button
+        (width - 2 * WB - BBS, 2 * WB + 4 * BH, BBS, BH, "Choose");
+      b3->callback(solver_file_open_cb, (void *)solverIndex);
+
+      Fl_Button *b4 = new Fl_Button
+        (2 * WB, 2 * WB + 4 * BH, BB / 2, BH, "Edit");
+      b4->callback(solver_file_edit_cb, (void *)solverIndex);
+
+      input[1] = new Fl_Input
+        (2 * WB, 2 * WB + 5 * BH, LL, BH, "Mesh");
+      Fl_Button *b5 = new Fl_Button
+        (width - 2 * WB - BBS, 2 * WB + 5 * BH, BBS, BH, "Choose");
+      b5->callback(solver_choose_mesh_cb, (void *)solverIndex);
+
+      for(int i = 0; i < 3; i++) {
+        input[i]->align(FL_ALIGN_RIGHT);
+      }
+
+      for(int i = 0; i < SINFO[solverIndex].nboptions; i++) {
+        choice[i] = new Fl_Choice
+          (2 * WB, 2 * WB + (6 + i) * BH, LL, BH, SINFO[solverIndex].option_name[i]);
+        choice[i]->align(FL_ALIGN_RIGHT);
+      }
+
+      static int arg[MAX_NUM_SOLVERS][5][2];
+      for(int i = 0; i < 5; i++) {
+        if(strlen(SINFO[solverIndex].button_name[i])) {
+          arg[solverIndex][i][0] = solverIndex;
+          arg[solverIndex][i][1] = i;
+          command[i] = new Fl_Button
+            ((2 + i) * WB + i * BBS, 3 * WB + (6 + SINFO[solverIndex].nboptions) * BH,
+             BBS, BH, SINFO[solverIndex].button_name[i]);
+          command[i]->callback
+            (solver_command_cb, (void *)arg[solverIndex][i]);
+        }
+      }
+      
+      g->end();
+    }
+    {
+      Fl_Group *g = new Fl_Group
+        (WB, WB + BH, width - 2 * WB, height - 3 * WB - 2 * BH, "About");
+
+      Fl_Browser *o = new Fl_Browser
+        (2 * WB, 2 * WB + 1 * BH, width - 4 * WB, height - 5 * WB - 2 * BH);
+      o->add(" ");
+      add_multiline_in_browser(o, "@c@b@.", SINFO[solverIndex].name, false);
+      o->add(" ");
+      add_multiline_in_browser(o, "@c@. ", SINFO[solverIndex].help, false);
+
+      g->end();
+    }
+    o->end();
+  }
+
+  {
+    Fl_Button *b1 = new Fl_Button
+      (width - 2 * BB - 2 * WB, height - BH - WB, BB, BH, "Kill solver");
+    b1->callback(solver_kill_cb, (void *)solverIndex);
+    Fl_Button *b2 = new Fl_Button
+      (width - BB - WB, height - BH - WB, BB, BH, "Cancel");
+    b2->callback(cancel_cb, (void*)win);
+  }
+
+  win->position(CTX.solver_position[0], CTX.solver_position[1]);
+  win->end();
+}
diff --git a/Fltk/solverWindow.h b/Fltk/solverWindow.h
new file mode 100644
index 0000000000000000000000000000000000000000..ebc5fbfd9da50d317b7ebd745520caa5ccd9e76b
--- /dev/null
+++ b/Fltk/solverWindow.h
@@ -0,0 +1,28 @@
+ // Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+
+#ifndef _SOLVER_WINDOW_H_
+#define _SOLVER_WINDOW_H_
+
+#include <FL/Fl_Window.H>
+#include <FL/Fl_Input.H>
+#include <FL/Fl_Choice.H>
+#include <FL/Fl_Check_Button.H>
+#include <FL/Fl_Button.H>
+
+class solverWindow{
+ private:
+  int _fontsize;
+ public:
+  Fl_Window *win;
+  Fl_Input *input[50];
+  Fl_Choice *choice[10];
+  Fl_Check_Button *butt[10];
+  Fl_Button *command[10];
+ public:
+  solverWindow(int solverIndex, int fontsize);
+};
+
+#endif
diff --git a/Fltk/SpherePosition_Widget.h b/Fltk/spherePositionWidget.h
similarity index 93%
rename from Fltk/SpherePosition_Widget.h
rename to Fltk/spherePositionWidget.h
index 5f6caa03c81187dc4b0e06eca39077041dca65ab..6f0f1004e0213af317581f502820ccc8719ded9a 100644
--- a/Fltk/SpherePosition_Widget.h
+++ b/Fltk/spherePositionWidget.h
@@ -8,10 +8,11 @@
 
 #include <math.h>
 #include <FL/Fl_Widget.H>
+#include <FL/fl_draw.H>
 
 // A small 2D widget to set the coordinates of a point on the unit
 // sphere.
-class SpherePosition_Widget : public Fl_Widget {
+class spherePositionWidget : public Fl_Widget {
  private:
   double _x, _y, _z;
   void draw()
@@ -58,9 +59,8 @@ class SpherePosition_Widget : public Fl_Widget {
       return 0;
     }
   }
-
-public:
-  SpherePosition_Widget(int x,int y,int w, const char *l=0)
+ public:
+  spherePositionWidget(int x, int y, int w, const char *l=0)
     : Fl_Widget(x, y, w, w, l), _x(0.), _y(0.), _z(0.)
   {
     box(FL_FLAT_BOX);
diff --git a/Fltk/statisticsWindow.cpp b/Fltk/statisticsWindow.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..074af9e76d896ce983c3002d428292c4ab8e0b45
--- /dev/null
+++ b/Fltk/statisticsWindow.cpp
@@ -0,0 +1,217 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+
+#include <FL/Fl_Tabs.H>
+#include <FL/Fl_Box.H>
+#include <FL/Fl_Return_Button.H>
+#include "GUI.h"
+#include "statisticsWindow.h"
+#include "shortcutWindow.h"
+#include "GModel.h"
+#include "PView.h"
+#include "Callbacks.h"
+#include "Generator.h"
+#include "Context.h"
+
+extern Context_T CTX;
+
+statisticsWindow::statisticsWindow(int fontsize)
+  : _fontsize(fontsize)
+{
+  int i, num = 0;
+  int width = 26 * _fontsize;
+  int height = 5 * WB + 18 * BH;
+
+  win = new dialogWindow(width, height, CTX.non_modal_windows, "Statistics");
+  win->box(GMSH_WINDOW_BOX);
+  {
+    Fl_Tabs *o = new Fl_Tabs(WB, WB, width - 2 * WB, height - 3 * WB - BH);
+    {
+      group[0] = new Fl_Group
+        (WB, WB + BH, width - 2 * WB, height - 3 * WB - 2 * BH, "Geometry");
+      value[num++] = new Fl_Output(2 * WB, 2 * WB + 1 * BH, IW, BH, "Points");
+      value[num++] = new Fl_Output(2 * WB, 2 * WB + 2 * BH, IW, BH, "Lines");
+      value[num++] = new Fl_Output(2 * WB, 2 * WB + 3 * BH, IW, BH, "Surfaces");
+      value[num++] = new Fl_Output(2 * WB, 2 * WB + 4 * BH, IW, BH, "Volumes");
+      value[num++] = new Fl_Output(2 * WB, 2 * WB + 5 * BH, IW, BH, "Physical groups");
+      group[0]->end();
+    }
+    {
+      group[1] = new Fl_Group
+        (WB, WB + BH, width - 2 * WB, height - 3 * WB - 2 * BH, "Mesh");
+      value[num++] = new Fl_Output(2 * WB, 2 * WB + 1 * BH, IW, BH, "Nodes on Lines");
+      value[num++] = new Fl_Output(2 * WB, 2 * WB + 2 * BH, IW, BH, "Nodes on surfaces");
+      value[num++] = new Fl_Output(2 * WB, 2 * WB + 3 * BH, IW, BH, "Nodes in volumes");
+      value[num++] = new Fl_Output(2 * WB, 2 * WB + 4 * BH, IW, BH, "Triangles");
+      value[num++] = new Fl_Output(2 * WB, 2 * WB + 5 * BH, IW, BH, "Quadrangles");
+      value[num++] = new Fl_Output(2 * WB, 2 * WB + 6 * BH, IW, BH, "Tetrahedra");
+      value[num++] = new Fl_Output(2 * WB, 2 * WB + 7 * BH, IW, BH, "Hexahedra");
+      value[num++] = new Fl_Output(2 * WB, 2 * WB + 8 * BH, IW, BH, "Prisms");
+      value[num++] = new Fl_Output(2 * WB, 2 * WB + 9 * BH, IW, BH, "Pyramids");
+
+      value[num++] = new Fl_Output(2 * WB, 2 * WB + 10 * BH, IW, BH, "Time for 1D mesh");
+      value[num++] = new Fl_Output(2 * WB, 2 * WB + 11 * BH, IW, BH, "Time for 2D mesh");
+      value[num++] = new Fl_Output(2 * WB, 2 * WB + 12 * BH, IW, BH, "Time for 3D mesh");
+
+      value[num] = new Fl_Output(2 * WB, 2 * WB + 13 * BH, IW, BH, "Gamma"); 
+      value[num]->tooltip("~ inscribed_radius / circumscribed_radius"); num++;
+      value[num] = new Fl_Output(2 * WB, 2 * WB + 14 * BH, IW, BH, "Eta");
+      value[num]->tooltip("~ volume^(2/3) / sum_edge_length^2"); num++;
+      value[num] = new Fl_Output(2 * WB, 2 * WB + 15 * BH, IW, BH, "Rho");
+      value[num]->tooltip("~ min_edge_length / max_edge_length"); num++;
+      value[num] = new Fl_Output(2 * WB, 2 * WB + 16 * BH, IW, BH, "Disto");
+      value[num]->tooltip("~ min (J0/J, J/J0)"); num++;
+
+      for(int i = 0; i < 4; i++){
+        int ww = 3 * _fontsize;
+        new Fl_Box
+          (FL_NO_BOX, width - 3 * ww - 2 * WB, 2 * WB + (13 + i) * BH, ww, BH, "Plot:");
+        butt[2 * i] = new Fl_Button
+          (width - 2 * ww - 2 * WB, 2 * WB + (13 + i) * BH, ww, BH, "2D");
+        butt[2 * i + 1] = new Fl_Button
+          (width - ww - 2 * WB, 2 * WB + (13 + i) * BH, ww, BH, "3D");
+      }
+      butt[0]->callback(statistics_histogram_cb, (void *)"Gamma2D");
+      butt[1]->callback(statistics_histogram_cb, (void *)"Gamma3D");
+      butt[2]->callback(statistics_histogram_cb, (void *)"Eta2D");
+      butt[3]->callback(statistics_histogram_cb, (void *)"Eta3D");
+      butt[4]->callback(statistics_histogram_cb, (void *)"Rho2D");
+      butt[5]->callback(statistics_histogram_cb, (void *)"Rho3D");
+      butt[6]->callback(statistics_histogram_cb, (void *)"Disto2D");
+      butt[7]->callback(statistics_histogram_cb, (void *)"Disto3D");
+
+      group[1]->end();
+    }
+    {
+      group[2] = new Fl_Group
+        (WB, WB + BH, width - 2 * WB, height - 3 * WB - 2 * BH, "Post-processing");
+      value[num++] = new Fl_Output(2 * WB, 2 * WB + 1 * BH, IW, BH, "Views");
+      value[num++] = new Fl_Output(2 * WB, 2 * WB + 2 * BH, IW, BH, "Points");
+      value[num++] = new Fl_Output(2 * WB, 2 * WB + 3 * BH, IW, BH, "Lines");
+      value[num++] = new Fl_Output(2 * WB, 2 * WB + 4 * BH, IW, BH, "Triangles");
+      value[num++] = new Fl_Output(2 * WB, 2 * WB + 5 * BH, IW, BH, "Quadrangles");
+      value[num++] = new Fl_Output(2 * WB, 2 * WB + 6 * BH, IW, BH, "Tetrahedra");
+      value[num++] = new Fl_Output(2 * WB, 2 * WB + 7 * BH, IW, BH, "Hexahedra");
+      value[num++] = new Fl_Output(2 * WB, 2 * WB + 8 * BH, IW, BH, "Prisms");
+      value[num++] = new Fl_Output(2 * WB, 2 * WB + 9 * BH, IW, BH, "Pyramids");
+      value[num++] = new Fl_Output(2 * WB, 2 * WB + 10 * BH, IW, BH, "Strings");
+      group[2]->end();
+    }
+    o->end();
+  }
+
+  for(i = 0; i < num; i++) {
+    value[i]->align(FL_ALIGN_RIGHT);
+    value[i]->value(0);
+  }
+
+  {
+    Fl_Return_Button *o = new Fl_Return_Button
+      (width - 2 * BB - 2 * WB, height - BH - WB, BB, BH, "Update");
+    o->callback(statistics_update_cb);
+  }
+  {
+    Fl_Button *o = new Fl_Button(width - BB - WB, height - BH - WB, BB, BH, "Cancel");
+    o->callback(cancel_cb, (void *)win);
+  }
+  
+  win->position(CTX.stat_position[0], CTX.stat_position[1]);
+  win->end();
+}
+
+void statisticsWindow::compute(bool elementQuality)
+{
+  int num = 0;
+  static double s[50];
+  static char label[50][256];
+
+  if(elementQuality)
+    GetStatistics(s, quality);
+  else
+    GetStatistics(s);
+
+  // geom
+  sprintf(label[num], "%g", s[0]); value[num]->value(label[num]); num++;
+  sprintf(label[num], "%g", s[1]); value[num]->value(label[num]); num++;
+  sprintf(label[num], "%g", s[2]); value[num]->value(label[num]); num++;
+  sprintf(label[num], "%g", s[3]); value[num]->value(label[num]); num++;
+  sprintf(label[num], "%g", s[45]); value[num]->value(label[num]); num++;
+
+  // mesh
+  sprintf(label[num], "%g", s[4]); value[num]->value(label[num]); num++;
+  sprintf(label[num], "%g", s[5]); value[num]->value(label[num]); num++;
+  sprintf(label[num], "%g", s[6]); value[num]->value(label[num]); num++;
+  sprintf(label[num], "%g", s[7]); value[num]->value(label[num]); num++;
+  sprintf(label[num], "%g", s[8]); value[num]->value(label[num]); num++;
+  sprintf(label[num], "%g", s[9]); value[num]->value(label[num]); num++;
+  sprintf(label[num], "%g", s[10]); value[num]->value(label[num]); num++;
+  sprintf(label[num], "%g", s[11]); value[num]->value(label[num]); num++;
+  sprintf(label[num], "%g", s[12]); value[num]->value(label[num]); num++;
+
+  sprintf(label[num], "%g", s[13]); value[num]->value(label[num]); num++;
+  sprintf(label[num], "%g", s[14]); value[num]->value(label[num]); num++;
+  sprintf(label[num], "%g", s[15]); value[num]->value(label[num]); num++;
+
+  if(!elementQuality){
+    for(int i = 0; i < 8; i += 2) butt[i]->deactivate();
+    sprintf(label[num], "Press Update");
+    value[num]->deactivate();
+    value[num]->value(label[num]); num++;
+    sprintf(label[num], "Press Update");
+    value[num]->deactivate();
+    value[num]->value(label[num]); num++;
+    sprintf(label[num], "Press Update");
+    value[num]->deactivate();
+    value[num]->value(label[num]); num++;
+    sprintf(label[num], "Press Update");
+    value[num]->deactivate();
+    value[num]->value(label[num]); num++;
+  }
+  else{
+    for(int i = 0; i < 8; i += 2) butt[i]->activate();
+    sprintf(label[num], "%.4g (%.4g->%.4g)", s[17], s[18], s[19]);
+    value[num]->activate();
+    value[num]->value(label[num]); num++;
+    sprintf(label[num], "%.4g (%.4g->%.4g)", s[20], s[21], s[22]);
+    value[num]->activate();
+    value[num]->value(label[num]); num++;
+    sprintf(label[num], "%.4g (%.4g->%.4g)", s[23], s[24], s[25]);
+    value[num]->activate();
+    value[num]->value(label[num]); num++;
+    sprintf(label[num], "%.4g (%.4g->%.4g)", s[46], s[47], s[48]);
+    value[num]->activate();
+    value[num]->value(label[num]); num++;
+  }
+
+  // post
+  sprintf(label[num], "%g", s[26]); value[num]->value(label[num]); num++;
+  sprintf(label[num], "%g", s[27]); value[num]->value(label[num]); num++;
+  sprintf(label[num], "%g", s[28]); value[num]->value(label[num]); num++;
+  sprintf(label[num], "%g", s[29]); value[num]->value(label[num]); num++;
+  sprintf(label[num], "%g", s[30]); value[num]->value(label[num]); num++;
+  sprintf(label[num], "%g", s[31]); value[num]->value(label[num]); num++;
+  sprintf(label[num], "%g", s[32]); value[num]->value(label[num]); num++;
+  sprintf(label[num], "%g", s[33]); value[num]->value(label[num]); num++;
+  sprintf(label[num], "%g", s[34]); value[num]->value(label[num]); num++;
+  sprintf(label[num], "%g", s[35]); value[num]->value(label[num]); num++;
+}
+
+void statisticsWindow::show()
+{
+  if(!win->shown()) 
+    compute(false);
+
+  for(int i = 0; i < 3; i++)
+    group[i]->hide();
+  
+  if(GModel::current()->getMeshStatus(true) > 0)
+    group[1]->show();
+  else if(PView::list.size())
+    group[2]->show();
+  else
+    group[0]->show();
+
+  win->show();
+}
diff --git a/Fltk/statisticsWindow.h b/Fltk/statisticsWindow.h
new file mode 100644
index 0000000000000000000000000000000000000000..304a38783c839681f251d73511b963fec0597b9f
--- /dev/null
+++ b/Fltk/statisticsWindow.h
@@ -0,0 +1,29 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+
+#ifndef _STATISTICS_WINDOW_H_
+#define _STATISTICS_WINDOW_H_
+
+#include <FL/Fl_Window.H>
+#include <FL/Fl_Output.H>
+#include <FL/Fl_Button.H>
+#include <FL/Fl_Group.H>
+
+class statisticsWindow{
+ private:
+  int _fontsize;
+ public:
+  Fl_Window *win;
+  Fl_Output *value[50];
+  Fl_Button *butt[8];
+  Fl_Group *group[3];
+  double quality[4][100];
+ public:
+  statisticsWindow(int fontsize);
+  void compute(bool elementQuality);
+  void show();
+};
+
+#endif
diff --git a/Fltk/visibilityWindow.cpp b/Fltk/visibilityWindow.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9733b5e7f5cb86118ca2d24f0294356987644318
--- /dev/null
+++ b/Fltk/visibilityWindow.cpp
@@ -0,0 +1,239 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+
+#include <FL/Fl_Tabs.H>
+#include <FL/Fl_Box.H>
+#include <FL/Fl_Return_Button.H>
+#include "GUI.h"
+#include "visibilityWindow.h"
+#include "shortcutWindow.h"
+#include "Callbacks.h"
+#include "Context.h"
+
+extern Context_T CTX;
+
+// derive our own browser, that reacts differently to the Enter key
+class visBrowser : public Fl_Browser{
+  int handle(int event)
+  {
+    if(event == FL_KEYBOARD){
+      switch(Fl::event_key()) {
+      case FL_Enter:
+      case FL_KP_Enter:
+        visibility_ok_cb(NULL, NULL);
+        return 1;
+      }
+    }
+    return Fl_Browser::handle(event);
+  }
+ public:
+  visBrowser(int x, int y, int w , int h, const char* c = 0)
+    : Fl_Browser(x, y, w, h, c){}
+};
+
+visibilityWindow::visibilityWindow(int fontsize) 
+  : _fontsize(fontsize)
+{
+  static int cols[5] = {15, 95, 95, 180, 0};
+  static Fl_Menu_Item type_table[] = {
+    {"Elementary entities", 0, (Fl_Callback *) visibility_cb},
+    {"Physical groups", 0, (Fl_Callback *) visibility_cb},
+    {"Mesh partitions", 0, (Fl_Callback *) visibility_cb},
+    {0}
+  };
+
+  int width = cols[0] + cols[1] + cols[2] + cols[3] + 6 * WB;
+  int height = 18 * BH;
+  int brw = width - 4 * WB;
+
+  win = new dialogWindow
+    (width, height, CTX.non_modal_windows, "Visibility");
+  win->box(GMSH_WINDOW_BOX);
+
+  type = new Fl_Choice(WB, WB, (width - 3 * WB) / 2, BH);
+  type->menu(type_table);
+  
+  butt[0] = new Fl_Check_Button
+    (WB + (width - 3 * WB) / 2 + WB, WB, (width - 3 * WB) / 2, BH, 
+     "Set visibility recursively");
+  butt[0]->type(FL_TOGGLE_BUTTON);
+  butt[0]->value(1);
+
+  Fl_Tabs *o = new Fl_Tabs
+    (WB, 2 * WB + BH, width - 2 * WB, height - 4 * WB - 2 * BH);
+  {
+    group[0] = new Fl_Group
+      (WB, 2 * WB + 2 * BH, width - 2 * WB, height - 4 * WB - 3 * BH, "Browser");
+
+    Fl_Button *o0 = new Fl_Button
+      (2 * WB, 3 * WB + 2 * BH, cols[0], BH/2, "*");
+    o0->align(FL_ALIGN_TOP | FL_ALIGN_INSIDE);
+    o0->tooltip("Select/unselect all");
+    o0->callback(visibility_sort_cb, (void *)"*");
+
+    Fl_Button *o1 = new Fl_Button
+      (2 * WB, 3 * WB + 2 * BH + BH/2, cols[0], BH - BH/2, "-");
+    o1->tooltip("Invert selection");
+    o1->callback(visibility_sort_cb, (void *)"-");
+
+    Fl_Button *o2 = new Fl_Button
+      (2 * WB + cols[0], 3 * WB + 2 * BH, cols[1], BH, "Type");
+    o2->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
+    o2->tooltip("Sort by type");
+    o2->callback(visibility_sort_cb, (void *)"type");
+
+    Fl_Button *o3 = new Fl_Button
+      (2 * WB + cols[0] + cols[1], 3 * WB + 2 * BH, cols[2], BH, "Number");
+    o3->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
+    o3->tooltip("Sort by number");
+    o3->callback(visibility_sort_cb, (void *)"number");
+
+    Fl_Button *o4 = new Fl_Button
+      (2 * WB + cols[0] + cols[1] + cols[2], 3 * WB + 2 * BH, cols[3], BH, "Name");
+    o4->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
+    o4->tooltip("Sort by name");
+    o4->callback(visibility_sort_cb, (void *)"name");
+
+    Fl_Button *o5 = new Fl_Button
+      (width - 4 * WB, 3 * WB + 2 * BH, 2 * WB, BH, "+");
+    o5->tooltip("Add parameter name for first selected item");
+    o5->callback(visibility_sort_cb, (void *)"+");
+
+    {
+      Fl_Group *o = new Fl_Group
+        (2 * WB, 3 * WB + 3 * BH, brw, height - 7 * WB - 5 * BH);
+      
+      browser = new visBrowser
+        (2 * WB, 3 * WB + 3 * BH, brw, height - 7 * WB - 5 * BH);
+      browser->type(FL_MULTI_BROWSER);
+      browser->column_widths(cols);
+      
+      o->end();
+      Fl_Group::current()->resizable(o);
+    }
+
+    push[0] = new Fl_Button
+      (width - 2 * BB - 3 * WB, height - 2 * BH - 3 * WB, BB, BH, "Delete");
+    push[0]->callback(visibility_delete_cb);
+
+    Fl_Return_Button *b1 = new Fl_Return_Button
+      (width - 1 * BB - 2 * WB, height - 2 * BH - 3 * WB, BB, BH, "Apply");
+    b1->callback(visibility_ok_cb);
+
+    group[0]->end();
+    Fl_Group::current()->resizable(group[0]);
+  }
+  {
+    group[1] = new Fl_Group
+      (WB, 2 * WB + 2 * BH, width - 2 * WB, height - 4 * WB - 2 * BH, "Numeric input");
+    group[1]->resizable(NULL);
+
+    for(int i = 0; i < 6; i++){
+      input[i] = new Fl_Input
+        (width / 2 - WB / 2 - IW, 3 * WB + (i + 2) * BH, IW, BH);
+      input[i]->align(FL_ALIGN_LEFT);
+      input[i]->value("*");
+
+      Fl_Button *o1 = new Fl_Button
+        (width / 2 + WB / 2, 3 * WB + (i + 2) * BH, BB, BH, "Show");
+      o1->callback(visibility_number_cb, (void *)(100+i));
+
+      Fl_Button *o2 = new Fl_Button
+        (width / 2 + WB / 2 + BB + WB, 3 * WB + (i + 2) * BH, BB, BH, "Hide");
+      o2->callback(visibility_number_cb, (void *)i);
+    }
+
+    input[0]->label("Node");
+    input[0]->tooltip("Enter node number, or *");
+
+    input[1]->label("Element");
+    input[1]->tooltip("Enter element number, or *");
+
+    input[2]->label("Point");
+    input[2]->tooltip("Enter point number, or *");
+
+    input[3]->label("Line");
+    input[3]->tooltip("Enter line number, or *");
+
+    input[4]->label("Surface");
+    input[4]->tooltip("Enter surface number, or *");
+
+    input[5]->label("Volume");
+    input[5]->tooltip("Enter volume number, or *");
+
+    group[1]->end();
+  }
+  {
+    group[2] = new Fl_Group
+      (WB, 2 * WB + 2 * BH, width - 2 * WB, height - 4 * WB - 2 * BH, "Interactive");
+    group[2]->resizable(NULL);
+
+    int ll = width/2 - BH - WB - IW;
+
+    Fl_Box *b2 = new Fl_Box
+      (FL_NO_BOX, ll, 3 * WB + 2 * BH, IW, BH, "Hide with the mouse:");
+    b2->align(FL_ALIGN_INSIDE|FL_ALIGN_CENTER);
+
+    Fl_Button *butt1 = new Fl_Button(ll, 3 * WB + 3 * BH, IW, BH, "Elements");
+    butt1->callback(visibility_interactive_cb, (void *)"hide_elements");
+    Fl_Button *butt2 = new Fl_Button(ll, 3 * WB + 4 * BH, IW, BH, "Points");
+    butt2->callback(visibility_interactive_cb, (void *)"hide_points");
+    Fl_Button *butt3 = new Fl_Button(ll, 3 * WB + 5 * BH, IW, BH, "Lines");
+    butt3->callback(visibility_interactive_cb, (void *)"hide_lines");
+    Fl_Button *butt4 = new Fl_Button(ll, 3 * WB + 6 * BH, IW, BH, "Surfaces");
+    butt4->callback(visibility_interactive_cb, (void *)"hide_surfaces");
+    Fl_Button *butt5 = new Fl_Button(ll, 3 * WB + 7 * BH, IW, BH, "Volumes");
+    butt5->callback(visibility_interactive_cb, (void *)"hide_volumes");
+
+    Fl_Button *butt6 = new Fl_Button
+      (ll + IW + WB, 3 * WB + 3 * BH, 2 * BH, 5*BH, "Show\nAll");
+    butt6->callback(visibility_interactive_cb, (void *)"show_all");
+
+    int ll2 = ll + IW + WB + 2*BH + WB;
+
+    Fl_Box *b12 = new Fl_Box
+      (FL_NO_BOX, ll2, 3 * WB + 2 * BH, IW, BH, "Show with the mouse:");
+    b12->align(FL_ALIGN_INSIDE|FL_ALIGN_CENTER);
+
+    Fl_Button *butt11 = new Fl_Button(ll2, 3 * WB + 3 * BH, IW, BH, "Elements");
+    butt11->callback(visibility_interactive_cb, (void *)"show_elements");
+    Fl_Button *butt12 = new Fl_Button(ll2, 3 * WB + 4 * BH, IW, BH, "Points");
+    butt12->callback(visibility_interactive_cb, (void *)"show_points");
+    Fl_Button *butt13 = new Fl_Button(ll2, 3 * WB + 5 * BH, IW, BH, "Lines");
+    butt13->callback(visibility_interactive_cb, (void *)"show_lines");
+    Fl_Button *butt14 = new Fl_Button(ll2, 3 * WB + 6 * BH, IW, BH, "Surfaces");
+    butt14->callback(visibility_interactive_cb, (void *)"show_surfaces");
+    Fl_Button *butt15 = new Fl_Button(ll2, 3 * WB + 7 * BH, IW, BH, "Volumes");
+    butt15->callback(visibility_interactive_cb, (void *)"show_volumes");
+    
+    group[2]->end();
+  }
+  o->end();
+
+  win->resizable(o);
+  win->size_range(width, 9 * BH + 6 * WB, width);
+
+  {
+    Fl_Button *o1 = new Fl_Button
+      (width - 2 * BB - 2 * WB, height - BH - WB, BB, BH, "Save");
+    o1->callback(visibility_save_cb);
+
+    Fl_Button *o2 = new Fl_Button
+      (width - BB - WB, height - BH - WB, BB, BH, "Cancel");
+    o2->callback(cancel_cb, (void *)win);
+  }
+
+  win->position(CTX.vis_position[0], CTX.vis_position[1]);
+  win->end();
+}
+
+void visibilityWindow::show(bool redrawOnly)
+{
+  if(win->shown() && redrawOnly)
+    win->redraw();
+  else
+    win->show();
+}
+
diff --git a/Fltk/visibilityWindow.h b/Fltk/visibilityWindow.h
new file mode 100644
index 0000000000000000000000000000000000000000..cc78e570a02451911318ebca7cdd846a3436f789
--- /dev/null
+++ b/Fltk/visibilityWindow.h
@@ -0,0 +1,33 @@
+// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to <gmsh@geuz.org>.
+
+#ifndef _VISIBILITY_WINDOW_H_
+#define _VISIBILITY_WINDOW_H_
+
+#include <FL/Fl_Window.H>
+#include <FL/Fl_Group.H>
+#include <FL/Fl_Choice.H>
+#include <FL/Fl_Browser.H>
+#include <FL/Fl_Button.H>
+#include <FL/Fl_Check_Button.H>
+#include <FL/Fl_Input.H>
+
+class visibilityWindow{
+ private:
+  int _fontsize;
+ public:
+  Fl_Window *win;
+  Fl_Group *group[5];
+  Fl_Choice *type;
+  Fl_Browser *browser;
+  Fl_Check_Button *butt[2];
+  Fl_Button *push[2];
+  Fl_Input *input[10];
+ public:
+  visibilityWindow(int fontsize);
+  void show(bool redrawOnly);
+};
+
+#endif
diff --git a/Geo/OCCEdge.cpp b/Geo/OCCEdge.cpp
index 335b1932009f0819efc82e78367770b668f71d81..70d23684bc350783cacc90e64374fec6cfbf1580 100644
--- a/Geo/OCCEdge.cpp
+++ b/Geo/OCCEdge.cpp
@@ -222,10 +222,8 @@ int OCCEdge::minimumDrawSegments() const
 {
   if(geomType() == Line)
     return GEdge::minimumDrawSegments();
-  else if(geomType() == Circle || geomType() == Ellipse)
-    return CTX.geom.circle_points;
   else
-    return 20 * GEdge::minimumDrawSegments();
+    return CTX.geom.num_sub_edges * GEdge::minimumDrawSegments();
 }
 
 double OCCEdge::curvature(double par) const 
diff --git a/Geo/fourierEdge.cpp b/Geo/fourierEdge.cpp
index d97e075967e1bdc4fcc503e5f3128950a3d2564c..95daf90540152d606d387ae6cf5afd8783621a5f 100644
--- a/Geo/fourierEdge.cpp
+++ b/Geo/fourierEdge.cpp
@@ -55,10 +55,8 @@ int fourierEdge::minimumDrawSegments() const
 
   if(geomType() == Line)
     return n;
-  else if(geomType() == Circle || geomType() == Ellipse)
-    return CTX.geom.circle_points;
   else
-    return 20 * n;
+    return CTX.geom.num_sub_edges * n;
 }
 
 #endif
diff --git a/Geo/gmshEdge.cpp b/Geo/gmshEdge.cpp
index 760520d1fc60199b8f4cb9e393c9b7f4d1e356d4..73a8f0952dadc8d1c78e668c079782fb519091f6 100644
--- a/Geo/gmshEdge.cpp
+++ b/Geo/gmshEdge.cpp
@@ -109,10 +109,8 @@ int gmshEdge::minimumDrawSegments () const
 
   if(geomType() == Line && !c->geometry)
     return n;
-  else if(geomType() == Circle || geomType() == Ellipse)
-    return CTX.geom.circle_points;
   else
-    return 10 * n;
+    return CTX.geom.num_sub_edges * n;
 }
 
 SPoint2 gmshEdge::reparamOnFace(GFace *face, double epar,int dir) const
diff --git a/Graphics/Makefile b/Graphics/Makefile
index 024dba366af36d54be22022ad4e289eb39babe18..ff0d12a9b51012b3bd4a1a7fb0fba85b2b1cbdbd 100644
--- a/Graphics/Makefile
+++ b/Graphics/Makefile
@@ -60,9 +60,9 @@ depend:
 
 # DO NOT DELETE THIS LINE
 Trackball${OBJEXT}: Trackball.cpp Trackball.h
-SelectBuffer${OBJEXT}: SelectBuffer.cpp ../Common/GmshUI.h \
-  ../Common/GmshDefines.h ../Common/GmshMessage.h ../Geo/GModel.h \
-  ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
+SelectBuffer${OBJEXT}: SelectBuffer.cpp ../Common/GmshDefines.h \
+  ../Common/GmshMessage.h ../Geo/GModel.h ../Geo/GVertex.h \
+  ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GPoint.h \
   ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h \
   ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h \
@@ -76,13 +76,11 @@ SelectBuffer${OBJEXT}: SelectBuffer.cpp ../Common/GmshUI.h \
   ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h SelectBuffer.h \
   drawContext.h ../Common/VertexArray.h
 Iso${OBJEXT}: Iso.cpp ../Numeric/Numeric.h ../Numeric/NumericEmbedded.h
-ReadImg${OBJEXT}: ReadImg.cpp ReadImg.h ../Common/GmshMessage.h \
-  ../Common/GmshUI.h ../Post/PView.h ../Geo/SPoint3.h \
-  ../Post/PViewDataList.h ../Post/PViewData.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h ../Common/ListUtils.h
-drawContext${OBJEXT}: drawContext.cpp ../Common/GmshUI.h ../Common/GmshDefines.h \
-  ../Common/GmshMessage.h ../Fltk/Draw.h drawContext.h \
-  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h Trackball.h \
+ReadImg${OBJEXT}: ReadImg.cpp ReadImg.h ../Common/GmshMessage.h ../Post/PView.h \
+  ../Geo/SPoint3.h ../Post/PViewDataList.h ../Post/PViewData.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Common/ListUtils.h
+drawContext${OBJEXT}: drawContext.cpp ../Common/GmshMessage.h ../Fltk/Draw.h \
+  drawContext.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h Trackball.h \
   ../Common/Context.h ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h \
   ../Numeric/Numeric.h ../Numeric/NumericEmbedded.h ../Geo/GModel.h \
   ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
@@ -94,44 +92,42 @@ drawContext${OBJEXT}: drawContext.cpp ../Common/GmshUI.h ../Common/GmshDefines.h
   ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Post/PView.h \
   ../Post/PViewOptions.h ../Post/ColorTable.h
 drawMesh${OBJEXT}: drawMesh.cpp drawContext.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h ../Common/GmshMessage.h ../Common/GmshUI.h \
-  ../Common/GmshDefines.h ../Geo/GModel.h ../Geo/GVertex.h \
-  ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
-  ../Geo/SBoundingBox3d.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h \
-  ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
-  ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/GFace.h ../Geo/GEntity.h \
-  ../Geo/GPoint.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h \
-  ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h \
-  ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/MElement.h \
-  ../Geo/MVertex.h ../Geo/SPoint2.h ../Geo/SPoint3.h ../Geo/MEdge.h \
-  ../Geo/MVertex.h ../Geo/SVector3.h ../Geo/MFace.h ../Geo/MVertex.h \
-  ../Geo/SVector3.h ../Numeric/FunctionSpace.h ../Numeric/GmshMatrix.h \
-  ../Fltk/Draw.h ../Common/Context.h ../Geo/CGNSOptions.h \
-  ../Mesh/PartitionOptions.h ../Common/OS.h gl2ps.h \
-  ../Common/VertexArray.h ../Common/SmoothData.h ../Post/PView.h \
-  ../Post/PViewData.h
+  ../Geo/SPoint3.h ../Common/GmshMessage.h ../Common/GmshDefines.h \
+  ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h \
+  ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/GPoint.h \
+  ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h \
+  ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h \
+  ../Geo/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/GEdgeLoop.h \
+  ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h \
+  ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SPoint3.h \
+  ../Geo/SBoundingBox3d.h ../Geo/MElement.h ../Geo/MVertex.h \
+  ../Geo/SPoint2.h ../Geo/SPoint3.h ../Geo/MEdge.h ../Geo/MVertex.h \
+  ../Geo/SVector3.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Numeric/FunctionSpace.h ../Numeric/GmshMatrix.h ../Fltk/Draw.h \
+  ../Common/Context.h ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h \
+  ../Common/OS.h gl2ps.h ../Common/VertexArray.h ../Common/SmoothData.h \
+  ../Post/PView.h ../Post/PViewData.h
 drawGeom${OBJEXT}: drawGeom.cpp drawContext.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h ../Common/GmshUI.h ../Common/GmshDefines.h \
-  ../Fltk/Draw.h ../Common/Context.h ../Geo/CGNSOptions.h \
-  ../Mesh/PartitionOptions.h gl2ps.h ../Common/VertexArray.h \
-  ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/GModel.h ../Geo/GVertex.h \
-  ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
-  ../Geo/SBoundingBox3d.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h \
-  ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
-  ../Geo/SPoint2.h ../Geo/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h \
-  ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h \
-  ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SPoint3.h \
-  ../Geo/SBoundingBox3d.h
+  ../Geo/SPoint3.h ../Fltk/Draw.h ../Common/Context.h \
+  ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h gl2ps.h \
+  ../Common/VertexArray.h ../Geo/SVector3.h ../Geo/SPoint3.h \
+  ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h \
+  ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/GPoint.h \
+  ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h \
+  ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/GFace.h \
+  ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h \
+  ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h \
+  ../Geo/GEntity.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h
 drawPost${OBJEXT}: drawPost.cpp drawContext.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h ../Common/GmshMessage.h ../Common/GmshUI.h \
-  ../Numeric/Numeric.h ../Numeric/NumericEmbedded.h ../Fltk/Draw.h Iso.h \
-  ../Post/PView.h ../Post/PViewOptions.h ../Post/ColorTable.h \
-  ../Post/PViewData.h ../Common/VertexArray.h ../Geo/SVector3.h \
-  ../Geo/SPoint3.h ../Common/SmoothData.h ../Common/Context.h \
-  ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h gl2ps.h
+  ../Geo/SPoint3.h ../Common/GmshMessage.h ../Numeric/Numeric.h \
+  ../Numeric/NumericEmbedded.h ../Fltk/Draw.h Iso.h ../Post/PView.h \
+  ../Post/PViewOptions.h ../Post/ColorTable.h ../Post/PViewData.h \
+  ../Common/VertexArray.h ../Geo/SVector3.h ../Geo/SPoint3.h \
+  ../Common/SmoothData.h ../Common/Context.h ../Geo/CGNSOptions.h \
+  ../Mesh/PartitionOptions.h gl2ps.h
 drawAxes${OBJEXT}: drawAxes.cpp drawContext.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h ../Common/GmshUI.h ../Fltk/Draw.h ../Geo/GModel.h \
-  ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
+  ../Geo/SPoint3.h ../Fltk/Draw.h ../Geo/GModel.h ../Geo/GVertex.h \
+  ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h \
   ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
   ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/GFace.h ../Geo/GEntity.h \
@@ -141,27 +137,26 @@ drawAxes${OBJEXT}: drawAxes.cpp drawContext.h ../Geo/SBoundingBox3d.h \
   ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h ../Numeric/Numeric.h \
   ../Numeric/NumericEmbedded.h gl2ps.h
 drawScales${OBJEXT}: drawScales.cpp drawContext.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h ../Common/GmshUI.h ../Fltk/Draw.h ../Post/PView.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h ../Post/PViewData.h \
-  ../Common/Context.h ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h \
-  gl2ps.h
+  ../Geo/SPoint3.h ../Fltk/Draw.h ../Post/PView.h ../Post/PViewOptions.h \
+  ../Post/ColorTable.h ../Post/PViewData.h ../Common/Context.h \
+  ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h gl2ps.h
 drawGraph2d${OBJEXT}: drawGraph2d.cpp drawContext.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h ../Common/GmshUI.h ../Fltk/Draw.h ../Post/PView.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h ../Post/PViewData.h gl2ps.h \
-  ../Common/Context.h ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h \
-  ../Numeric/Numeric.h ../Numeric/NumericEmbedded.h
+  ../Geo/SPoint3.h ../Fltk/Draw.h ../Post/PView.h ../Post/PViewOptions.h \
+  ../Post/ColorTable.h ../Post/PViewData.h gl2ps.h ../Common/Context.h \
+  ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h ../Numeric/Numeric.h \
+  ../Numeric/NumericEmbedded.h
 drawGlyph${OBJEXT}: drawGlyph.cpp drawContext.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h ../Common/GmshUI.h ../Numeric/Numeric.h \
-  ../Numeric/NumericEmbedded.h ../Fltk/Draw.h ../Common/Context.h \
-  ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h gl2ps.h
+  ../Geo/SPoint3.h ../Numeric/Numeric.h ../Numeric/NumericEmbedded.h \
+  ../Fltk/Draw.h ../Common/Context.h ../Geo/CGNSOptions.h \
+  ../Mesh/PartitionOptions.h gl2ps.h
 gl2ps${OBJEXT}: gl2ps.cpp gl2ps.h
 gl2gif${OBJEXT}: gl2gif.cpp ../Common/MallocUtils.h gl2gif.h PixelBuffer.h \
-  ../Common/GmshUI.h ../Common/GmshMessage.h ../Fltk/Draw.h
-gl2jpeg${OBJEXT}: gl2jpeg.cpp gl2jpeg.h PixelBuffer.h ../Common/GmshUI.h \
-  ../Common/GmshMessage.h ../Fltk/Draw.h ../Common/MallocUtils.h
-gl2png${OBJEXT}: gl2png.cpp gl2png.h PixelBuffer.h ../Common/GmshUI.h \
-  ../Common/GmshMessage.h ../Fltk/Draw.h ../Common/MallocUtils.h
-gl2ppm${OBJEXT}: gl2ppm.cpp gl2ppm.h PixelBuffer.h ../Common/GmshUI.h \
-  ../Common/GmshMessage.h ../Fltk/Draw.h ../Common/MallocUtils.h
+  ../Common/GmshMessage.h ../Fltk/Draw.h
+gl2jpeg${OBJEXT}: gl2jpeg.cpp gl2jpeg.h PixelBuffer.h ../Common/GmshMessage.h \
+  ../Fltk/Draw.h ../Common/MallocUtils.h
+gl2png${OBJEXT}: gl2png.cpp gl2png.h PixelBuffer.h ../Common/GmshMessage.h \
+  ../Fltk/Draw.h ../Common/MallocUtils.h
+gl2ppm${OBJEXT}: gl2ppm.cpp gl2ppm.h PixelBuffer.h ../Common/GmshMessage.h \
+  ../Fltk/Draw.h ../Common/MallocUtils.h
 gl2yuv${OBJEXT}: gl2yuv.cpp ../Common/MallocUtils.h gl2yuv.h PixelBuffer.h \
-  ../Common/GmshUI.h ../Common/GmshMessage.h ../Fltk/Draw.h
+  ../Common/GmshMessage.h ../Fltk/Draw.h
diff --git a/Graphics/PixelBuffer.h b/Graphics/PixelBuffer.h
index cfdd63f559c1ed52a33a1a4a7142bc7e8f75ae19..de9892a5a5a032d5237e323f8e9b523a0163282a 100644
--- a/Graphics/PixelBuffer.h
+++ b/Graphics/PixelBuffer.h
@@ -6,7 +6,7 @@
 #ifndef _PIXEL_BUFFER_H_
 #define _PIXEL_BUFFER_H_
 
-#include "GmshUI.h"
+#include <FL/gl.h>
 #include "GmshMessage.h"
 #include "Draw.h"
 #include "MallocUtils.h"
diff --git a/Graphics/ReadImg.cpp b/Graphics/ReadImg.cpp
index fe7438fae8e73adf1ac6480cdd0dcf5b148b8301..558bad61ed6a2cf1ed224d159e33fccefd5a96e2 100644
--- a/Graphics/ReadImg.cpp
+++ b/Graphics/ReadImg.cpp
@@ -4,16 +4,14 @@
 // bugs and problems to <gmsh@geuz.org>.
 
 #include <string.h>
-#include "ReadImg.h"
-#include "GmshMessage.h"
-#include "GmshUI.h"
-#include "PView.h"
-#include "PViewDataList.h"
-  
 #include <FL/Fl_JPEG_Image.H>
 #include <FL/Fl_PNM_Image.H>
 #include <FL/Fl_PNG_Image.H>
 #include <FL/Fl_BMP_Image.H>
+#include "ReadImg.h"
+#include "GmshMessage.h"
+#include "PView.h"
+#include "PViewDataList.h"
 
 // from an image, we create a post-procession view
 
diff --git a/Graphics/SelectBuffer.cpp b/Graphics/SelectBuffer.cpp
index d5213551ece3daa658c65550230e6405f824e316..2d9b06e02139b3c5fbd19c8b7b650609ec214433 100644
--- a/Graphics/SelectBuffer.cpp
+++ b/Graphics/SelectBuffer.cpp
@@ -3,7 +3,7 @@
 // See the LICENSE.txt file for license information. Please report all
 // bugs and problems to <gmsh@geuz.org>.
 
-#include "GmshUI.h"
+#include <FL/gl.h>
 #include "GmshDefines.h"
 #include "GmshMessage.h"
 #include "GModel.h"
@@ -15,7 +15,7 @@
 extern Context_T CTX;
 
 class hit{
-public:
+ public:
   GLuint type, ient, depth, type2, ient2;
   hit(GLuint t, GLuint i, GLuint d, GLuint t2=0, GLuint i2=0) 
     : type(t), ient(i), depth(d), type2(t2), ient2(i2) {}
@@ -72,7 +72,7 @@ bool ProcessSelectionBuffer(drawContext *ctx, int entityType,
   glSelectBuffer(size, selectionBuffer);
 
   glRenderMode(GL_SELECT);
-  CTX.render_mode = GMSH_SELECT;
+  ctx->render_mode = drawContext::GMSH_SELECT;
 
   glInitNames();
   glPushMatrix();
@@ -83,7 +83,7 @@ bool ProcessSelectionBuffer(drawContext *ctx, int entityType,
   glPopMatrix();
 
   GLint numhits = glRenderMode(GL_RENDER);
-  CTX.render_mode = GMSH_RENDER;
+  ctx->render_mode = drawContext::GMSH_RENDER;
 
   if(!numhits){ // no hits
     delete [] selectionBuffer;
diff --git a/Graphics/drawAxes.cpp b/Graphics/drawAxes.cpp
index 635ef316f3ce9fc293fe35031712279f8b025ecc..09073317bdc0d261e667ea9db5c0e68dd3f74be1 100644
--- a/Graphics/drawAxes.cpp
+++ b/Graphics/drawAxes.cpp
@@ -3,8 +3,8 @@
 // See the LICENSE.txt file for license information. Please report all
 // bugs and problems to <gmsh@geuz.org>.
 
+#include <FL/gl.h>
 #include "drawContext.h"
-#include "GmshUI.h"
 #include "Draw.h"
 #include "GModel.h"
 #include "Context.h"
diff --git a/Graphics/drawContext.cpp b/Graphics/drawContext.cpp
index c9f3891092892654d3e846902cd2cf601f6c84b7..ee8cc50d0906b4d79e5a9e24dea72f6b39f140a0 100644
--- a/Graphics/drawContext.cpp
+++ b/Graphics/drawContext.cpp
@@ -3,8 +3,8 @@
 // See the LICENSE.txt file for license information. Please report all
 // bugs and problems to <gmsh@geuz.org>.
 
-#include "GmshUI.h"
-#include "GmshDefines.h"
+#include <FL/gl.h>
+#include <FL/glu.h>
 #include "GmshMessage.h"
 #include "Draw.h"
 #include "drawContext.h"
@@ -33,6 +33,7 @@ drawContext::drawContext(drawTransform *transform)
   viewport[2] = CTX.tmp_viewport[2];
   viewport[3] = CTX.tmp_viewport[3];
 
+  render_mode = GMSH_RENDER;
   vxmin = vymin = vxmax = vymax = 0.;
   pixel_equiv_x = pixel_equiv_y = 0.;
 }
@@ -234,7 +235,7 @@ void drawContext::initProjection(int xpick, int ypick, int wpick, int hpick)
   glLoadIdentity();
 
   // restrict picking to a rectangular region around xpick,ypick in SELECT mode
-  if(CTX.render_mode == GMSH_SELECT)
+  if(render_mode == GMSH_SELECT)
     gluPickMatrix((GLdouble)xpick, (GLdouble)(viewport[3] - ypick),
                   (GLdouble)wpick, (GLdouble)hpick, (GLint *)viewport);
 
@@ -277,7 +278,7 @@ void drawContext::initProjection(int xpick, int ypick, int wpick, int hpick)
   }
 
   // draw background gradient
-  if(CTX.render_mode != GMSH_SELECT && CTX.bg_gradient){
+  if(render_mode != GMSH_SELECT && CTX.bg_gradient){
     glPushMatrix();
     glLoadIdentity();
     glTranslated(0., 0., -grad_z);
diff --git a/Graphics/drawContext.h b/Graphics/drawContext.h
index 294a981f15cfd0395b63f5bed8fcea56a091c771..adf3fbbd35eeb6512dd5dd73627623ad2e935f9f 100644
--- a/Graphics/drawContext.h
+++ b/Graphics/drawContext.h
@@ -48,20 +48,22 @@ class drawTransformScaled : public drawTransform {
 class drawContext {
  private:
   drawTransform *_transform;
- public:
 
+ public:
   double r[3]; // current Euler angles (in degrees!) 
   double t[3], s[3]; // current translation and scale 
   double quaternion[4]; // current quaternion used for "trackball" rotation
   int viewport[4]; // current viewport 
-
   double rot[16]; // current rotation matrix 
   double t_init[3]; // initial translation before applying modelview transform
   double vxmin, vxmax, vymin, vymax; // current viewport in real coordinates 
   double pixel_equiv_x, pixel_equiv_y; // approx equiv model length of a pixel 
   double model[16], proj[16]; // the modelview and projection matrix as they were
                               // at the time of the last InitPosition() call
+  enum RenderMode {GMSH_RENDER=1, GMSH_SELECT=2, GMSH_FEEDBACK=3};
+  int render_mode; // current rendering mode
 
+ public:
   drawContext(drawTransform *transform=0);
   virtual ~drawContext(){}
   void setTransform(drawTransform *transform){ _transform = transform; }
@@ -70,31 +72,24 @@ class drawContext {
   {
     if(_transform) _transform->transform(x, y, z); 
   }
-
-  // trackball functions 
   void buildRotationMatrix();
   void setQuaternion(double p1x, double p1y, double p2x, double p2y);
   void addQuaternion(double p1x, double p1y, double p2x, double p2y);
   void addQuaternionFromAxisAndAngle(double axis[3], double angle);
   void setQuaternionFromEulerAngles();
   void setEulerAnglesFromRotationMatrix();
-
   void initProjection(int xpick=0, int ypick=0, int wpick=0, int hpick=0);
   void initRenderModel();
   void initPosition();
   void unproject(double x, double y, double p[3], double d[3]);
   int fix2dCoordinates(double *x, double *y);
-
   void draw3d();
   void draw2d();
-
   void drawGeom();
   void drawMesh();
   void drawPost();
-
   void drawText2d();
   void drawGraph2d();
-
   void drawAxis(double xmin, double ymin, double zmin,
                 double xmax, double ymax, double zmax, 
                 int nticks, int mikado);
@@ -104,9 +99,7 @@ class drawContext {
                 char label[3][256], SBoundingBox3d &bb, int mikado);
   void drawAxes();
   void drawSmallAxes();
-
   void drawScales();
-
   void drawSphere(double size, double x, double y, double z, int light);
   void drawCylinder(double width, double *x, double *y, double *z, int light);
   void drawTaperedCylinder(double width, double val1, double val2, 
diff --git a/Graphics/drawGeom.cpp b/Graphics/drawGeom.cpp
index 689e31da6af79f191605bad60e496eac02743f01..2791a7baf997e889df51c602ed568f5e4a058913 100644
--- a/Graphics/drawGeom.cpp
+++ b/Graphics/drawGeom.cpp
@@ -3,9 +3,8 @@
 // See the LICENSE.txt file for license information. Please report all
 // bugs and problems to <gmsh@geuz.org>.
 
+#include <FL/gl.h>
 #include "drawContext.h"
-#include "GmshUI.h"
-#include "GmshDefines.h"
 #include "Draw.h"
 #include "Context.h"
 #include "gl2ps.h"
@@ -25,7 +24,8 @@ class drawGVertex {
     if(!v->getVisibility()) return;
     if(v->geomType() == GEntity::BoundaryLayerPoint) return;
 
-    bool select = (CTX.render_mode == GMSH_SELECT && v->model() == GModel::current());
+    bool select = (_ctx->render_mode == drawContext::GMSH_SELECT && 
+                   v->model() == GModel::current());
     if(select) {
       glPushName(0);
       glPushName(v->tag());
@@ -96,7 +96,8 @@ class drawGEdge {
     if(e->geomType() == GEntity::DiscreteCurve) return;
     if(e->geomType() == GEntity::BoundaryLayerCurve) return;
     
-    bool select = (CTX.render_mode == GMSH_SELECT && e->model() == GModel::current());
+    bool select = (_ctx->render_mode == drawContext::GMSH_SELECT && 
+                   e->model() == GModel::current());
     if(select) {
       glPushName(1);
       glPushName(e->tag());
@@ -379,7 +380,8 @@ class drawGFace {
     if(f->geomType() == GEntity::DiscreteSurface) return;
     if(f->geomType() == GEntity::BoundaryLayerSurface) return;
 
-    bool select = (CTX.render_mode == GMSH_SELECT && f->model() == GModel::current());
+    bool select = (_ctx->render_mode == drawContext::GMSH_SELECT && 
+                   f->model() == GModel::current());
     if(select) {
       glPushName(2);
       glPushName(f->tag());
@@ -419,7 +421,8 @@ class drawGRegion {
     if(!r->getVisibility()) return;
     if(r->geomType() == GEntity::DiscreteVolume) return;
     
-    bool select = (CTX.render_mode == GMSH_SELECT && r->model() == GModel::current());
+    bool select = (_ctx->render_mode == drawContext::GMSH_SELECT && 
+                   r->model() == GModel::current());
     if(select) {
       glPushName(3);
       glPushName(r->tag());
diff --git a/Graphics/drawGlyph.cpp b/Graphics/drawGlyph.cpp
index fb8a19f7ed96d1bdc9b92a779d9434c5448bd381..6d2da6e5673ffac3e41563648ff539570f98d8cd 100644
--- a/Graphics/drawGlyph.cpp
+++ b/Graphics/drawGlyph.cpp
@@ -4,8 +4,9 @@
 // bugs and problems to <gmsh@geuz.org>.
 
 #include <string.h>
+#include <FL/gl.h>
+#include <FL/glu.h>
 #include "drawContext.h"
-#include "GmshUI.h"
 #include "Numeric.h"
 #include "Draw.h"
 #include "Context.h"
diff --git a/Graphics/drawGraph2d.cpp b/Graphics/drawGraph2d.cpp
index d4f3e6eb089253eb1b10e11bb3a6a4766ef197f4..f436642c40a73f710955d4aa8d3688bd15cae8a2 100644
--- a/Graphics/drawGraph2d.cpp
+++ b/Graphics/drawGraph2d.cpp
@@ -3,8 +3,8 @@
 // See the LICENSE.txt file for license information. Please report all
 // bugs and problems to <gmsh@geuz.org>.
 
+#include <FL/gl.h>
 #include "drawContext.h"
-#include "GmshUI.h"
 #include "Draw.h"
 #include "PView.h"
 #include "PViewOptions.h"
diff --git a/Graphics/drawMesh.cpp b/Graphics/drawMesh.cpp
index 166b9a57a2bf591333fe473261e394e01fc31868..d7a44958c6bd39abf62ab8f4af25e6ff31d0a65c 100644
--- a/Graphics/drawMesh.cpp
+++ b/Graphics/drawMesh.cpp
@@ -4,9 +4,9 @@
 // bugs and problems to <gmsh@geuz.org>.
 
 #include <math.h>
+#include <FL/gl.h>
 #include "drawContext.h"
 #include "GmshMessage.h"
-#include "GmshUI.h"
 #include "GmshDefines.h"
 #include "GModel.h"
 #include "MElement.h"
@@ -503,15 +503,15 @@ static void addElementsInArrays(GEntity *e, std::vector<T*> &elements,
   }
 }
 
-static void drawArrays(GEntity *e, VertexArray *va, GLint type, bool useNormalArray, 
-                       int forceColor=0, unsigned int color=0)
+static void drawArrays(drawContext *ctx, GEntity *e, VertexArray *va, GLint type, 
+                       bool useNormalArray, int forceColor=0, unsigned int color=0)
 {
   if(!va || !va->getNumVertices()) return;
 
   // If we want to be enable picking of individual elements we need to
   // draw each one separately
-  bool select = (CTX.render_mode == GMSH_SELECT && CTX.pick_elements && 
-                 e->model() == GModel::current());
+  bool select = (ctx->render_mode == drawContext::GMSH_SELECT && 
+                 CTX.pick_elements && e->model() == GModel::current());
   if(select) {
     if(va->getNumElementPointers() == va->getNumVertices()){
       for(int i = 0; i < va->getNumVertices(); i += va->getNumVerticesPerElement()){
@@ -579,7 +579,8 @@ class drawMeshGVertex {
   {  
     if(!v->getVisibility()) return;
     
-    bool select = (CTX.render_mode == GMSH_SELECT && v->model() == GModel::current());
+    bool select = (_ctx->render_mode == drawContext::GMSH_SELECT && 
+                   v->model() == GModel::current());
     if(select) {
       glPushName(0);
       glPushName(v->tag());
@@ -633,14 +634,15 @@ class drawMeshGEdge {
   {  
     if(!e->getVisibility()) return;
 
-    bool select = (CTX.render_mode == GMSH_SELECT && e->model() == GModel::current());    
+    bool select = (_ctx->render_mode == drawContext::GMSH_SELECT && 
+                   e->model() == GModel::current());    
     if(select) {
       glPushName(1);
       glPushName(e->tag());
     }
 
     if(CTX.mesh.lines)
-      drawArrays(e, e->va_lines, GL_LINES, false);
+      drawArrays(_ctx, e, e->va_lines, GL_LINES, false);
 
     if(CTX.mesh.lines_num)
       drawElementLabels(e, e->lines);
@@ -729,15 +731,16 @@ class drawMeshGFace {
   {  
     if(!f->getVisibility()) return;
 
-    bool select = (CTX.render_mode == GMSH_SELECT && f->model() == GModel::current());
+    bool select = (_ctx->render_mode == drawContext::GMSH_SELECT &&
+                   f->model() == GModel::current());
     if(select) {
       glPushName(2);
       glPushName(f->tag());
     }
 
-    drawArrays(f, f->va_lines, GL_LINES, CTX.mesh.light && CTX.mesh.light_lines, 
+    drawArrays(_ctx, f, f->va_lines, GL_LINES, CTX.mesh.light && CTX.mesh.light_lines, 
                CTX.mesh.surfaces_faces, CTX.color.mesh.line);
-    drawArrays(f, f->va_triangles, GL_TRIANGLES, CTX.mesh.light);
+    drawArrays(_ctx, f, f->va_triangles, GL_TRIANGLES, CTX.mesh.light);
 
     if(CTX.mesh.surfaces_num) {
       if(CTX.mesh.triangles)
@@ -855,15 +858,16 @@ class drawMeshGRegion {
   {  
     if(!r->getVisibility()) return;
 
-    bool select = (CTX.render_mode == GMSH_SELECT && r->model() == GModel::current());
+    bool select = (_ctx->render_mode == drawContext::GMSH_SELECT && 
+                   r->model() == GModel::current());
     if(select) {
       glPushName(3);
       glPushName(r->tag());
     }
 
-    drawArrays(r, r->va_lines, GL_LINES, CTX.mesh.light && CTX.mesh.light_lines, 
+    drawArrays(_ctx, r, r->va_lines, GL_LINES, CTX.mesh.light && CTX.mesh.light_lines, 
                CTX.mesh.volumes_faces, CTX.color.mesh.line);
-    drawArrays(r, r->va_triangles, GL_TRIANGLES, CTX.mesh.light);
+    drawArrays(_ctx, r, r->va_triangles, GL_TRIANGLES, CTX.mesh.light);
     
     if(CTX.mesh.volumes_num) {
       if(CTX.mesh.tetrahedra) 
diff --git a/Graphics/drawPost.cpp b/Graphics/drawPost.cpp
index 4afd7edad55c542515793e6de4db0bc726b84a98..cc7550251a115c3045bc6f9b7eb7dc5de456eb28 100644
--- a/Graphics/drawPost.cpp
+++ b/Graphics/drawPost.cpp
@@ -5,9 +5,9 @@
 
 #include <math.h>
 #include <algorithm>
+#include <FL/gl.h>
 #include "drawContext.h"
 #include "GmshMessage.h"
-#include "GmshUI.h"
 #include "Numeric.h"
 #include "Draw.h"
 #include "Iso.h"
diff --git a/Graphics/drawScales.cpp b/Graphics/drawScales.cpp
index 1b852df8ff8f4766b1acd0a46cf675ae86f2f7b9..32ec1a68d485735fdf9251135fa85d223fa6e243 100644
--- a/Graphics/drawScales.cpp
+++ b/Graphics/drawScales.cpp
@@ -3,8 +3,8 @@
 // See the LICENSE.txt file for license information. Please report all
 // bugs and problems to <gmsh@geuz.org>.
 
+#include <FL/gl.h>
 #include "drawContext.h"
-#include "GmshUI.h"
 #include "Draw.h"
 #include "PView.h"
 #include "PViewOptions.h"
diff --git a/Mesh/Generator.cpp b/Mesh/Generator.cpp
index 559779a73229ca0572d8dcfff304744c94c2a7b6..32c81bb2737142c59d557c35005019b990ac474e 100644
--- a/Mesh/Generator.cpp
+++ b/Mesh/Generator.cpp
@@ -213,26 +213,26 @@ void GetStatistics(double stat[50], double quality[4][100])
       for(GModel::fiter it = m->firstFace(); it != m->lastFace(); ++it){
 	GetQualityMeasure((*it)->quadrangles, gamma, gammaMin, gammaMax,
 			  eta, etaMin, etaMax, rho, rhoMin, rhoMax, 
-			  disto, distoMin,distoMax,quality);
+			  disto, distoMin, distoMax, quality);
 	GetQualityMeasure((*it)->triangles, gamma, gammaMin, gammaMax,
 			  eta, etaMin, etaMax, rho, rhoMin, rhoMax,
-			  disto, distoMin,distoMax,quality);
+			  disto, distoMin, distoMax, quality);
       }
     }
     else{
       for(GModel::riter it = m->firstRegion(); it != m->lastRegion(); ++it){
 	GetQualityMeasure((*it)->tetrahedra, gamma, gammaMin, gammaMax,
 			  eta, etaMin, etaMax, rho, rhoMin, rhoMax, 
-			  disto, distoMin,distoMax,quality);
+			  disto, distoMin, distoMax, quality);
 	GetQualityMeasure((*it)->hexahedra, gamma, gammaMin, gammaMax,
 			  eta, etaMin, etaMax, rho, rhoMin, rhoMax,
-			  disto, distoMin,distoMax,quality);
+			  disto, distoMin, distoMax, quality);
 	GetQualityMeasure((*it)->prisms, gamma, gammaMin, gammaMax,
 			  eta, etaMin, etaMax, rho, rhoMin, rhoMax,
-			  disto, distoMin,distoMax,quality);
+			  disto, distoMin, distoMax,quality);
 	GetQualityMeasure((*it)->pyramids, gamma, gammaMin, gammaMax,
 			  eta, etaMin, etaMax, rho, rhoMin, rhoMax,
-			  disto, distoMin,distoMax,quality);
+			  disto, distoMin, distoMax, quality);
       }
     }
     double N = stat[9] + stat[10] + stat[11] + stat[12];
diff --git a/Mesh/Partition.h b/Mesh/Partition.h
index 4b8bf9358b56e9d8056bdb79c90eeff252dce182..9581ce85b8d47252b831580c81cbec13304c5b1f 100644
--- a/Mesh/Partition.h
+++ b/Mesh/Partition.h
@@ -2,9 +2,12 @@
 //
 // See the LICENSE.txt file for license information. Please report all
 // bugs and problems to <gmsh@geuz.org>.
+
 #ifndef _PARTITION_H_
 #define _PARTITION_H_
 
+#include <vector>
+
 struct PartitionOptions;
 struct BoElemGr;
 class GModel;
@@ -12,7 +15,6 @@ class Graph;
 
 typedef std::vector<BoElemGr> BoElemGrVec;
 
-
 /*******************************************************************************
  *
  * Partitioning routines
diff --git a/Plugin/Annotate.cpp b/Plugin/Annotate.cpp
index 6f2803ebdbd59fd14fff620291cc6091c5940ef6..1fb5585b98afcc318055a243d08ab7ae8de516f3 100644
--- a/Plugin/Annotate.cpp
+++ b/Plugin/Annotate.cpp
@@ -8,9 +8,10 @@
 #include "Context.h"
 
 #if defined(HAVE_FLTK)
-#include "GmshUI.h"
-#include "GUI.h"
+#include <FL/gl.h>
+#include "drawContext.h"
 #include "Draw.h"
+#include "GUI.h" // FIXME for GetFontSize
 #endif
 
 extern Context_T CTX;
diff --git a/Plugin/CutGrid.cpp b/Plugin/CutGrid.cpp
index a63fadaa397a9b64254a512d92c8f86ee82fa485..320a2298870c627bbe09b5671c00ea6a1e2b0f11 100644
--- a/Plugin/CutGrid.cpp
+++ b/Plugin/CutGrid.cpp
@@ -8,7 +8,7 @@
 #include "Context.h"
 
 #if defined(HAVE_FLTK)
-#include "GmshUI.h"
+#include <FL/gl.h>
 #include "drawContext.h"
 #include "Draw.h"
 #endif
diff --git a/Plugin/CutParametric.cpp b/Plugin/CutParametric.cpp
index 1211cbdfd0df13821eff9790ddbe36d9e29befcd..255b7e5c831871a8eb9928085b5c96582bee816a 100644
--- a/Plugin/CutParametric.cpp
+++ b/Plugin/CutParametric.cpp
@@ -9,7 +9,7 @@
 #include "Context.h"
 
 #if defined(HAVE_FLTK)
-#include "GmshUI.h"
+#include <FL/gl.h>
 #include "drawContext.h"
 #include "Draw.h"
 #endif
diff --git a/Plugin/CutPlane.cpp b/Plugin/CutPlane.cpp
index 3dfb4d4491055b5a081b05470f87ce91241aa79e..406b8364fef28511027b89c66fd4d369ce43691d 100644
--- a/Plugin/CutPlane.cpp
+++ b/Plugin/CutPlane.cpp
@@ -7,7 +7,7 @@
 #include "Context.h"
 
 #if defined(HAVE_FLTK)
-#include "GmshUI.h"
+#include <FL/gl.h>
 #include "drawContext.h"
 #include "Draw.h"
 #endif
diff --git a/Plugin/CutSphere.cpp b/Plugin/CutSphere.cpp
index 4d439c35bee351683284dfccb305a8c06b3805ce..96e0f989bb4d7b33b1f344caebd94a3616b028de 100644
--- a/Plugin/CutSphere.cpp
+++ b/Plugin/CutSphere.cpp
@@ -8,7 +8,8 @@
 #include "Context.h"
 
 #if defined(HAVE_FLTK)
-#include "GmshUI.h"
+#include <FL/gl.h>
+#include <FL/glu.h>
 #include "Draw.h"
 #endif
 
diff --git a/Plugin/Makefile b/Plugin/Makefile
index 418105be520af9b99cc5a60663980360e558f807..e665aaeab46626abde2d43775ee3a2751ceb1cdc 100644
--- a/Plugin/Makefile
+++ b/Plugin/Makefile
@@ -89,15 +89,14 @@ CutPlane${OBJEXT}: CutPlane.cpp CutPlane.h Levelset.h Plugin.h \
   ../Post/PView.h ../Geo/SPoint3.h ../Post/PViewDataList.h \
   ../Post/PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
   ../Common/ListUtils.h ../Numeric/GmshMatrix.h ../Common/Context.h \
-  ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h ../Common/GmshUI.h \
+  ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h \
   ../Graphics/drawContext.h ../Fltk/Draw.h
 CutSphere${OBJEXT}: CutSphere.cpp CutSphere.h Levelset.h Plugin.h \
   ../Common/Options.h ../Post/ColorTable.h ../Common/GmshMessage.h \
   ../Post/PView.h ../Geo/SPoint3.h ../Post/PViewDataList.h \
   ../Post/PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
   ../Common/ListUtils.h ../Numeric/GmshMatrix.h ../Common/Context.h \
-  ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h ../Common/GmshUI.h \
-  ../Fltk/Draw.h
+  ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h ../Fltk/Draw.h
 CutMap${OBJEXT}: CutMap.cpp CutMap.h Levelset.h Plugin.h ../Common/Options.h \
   ../Post/ColorTable.h ../Common/GmshMessage.h ../Post/PView.h \
   ../Geo/SPoint3.h ../Post/PViewDataList.h ../Post/PViewData.h \
@@ -115,7 +114,7 @@ CutParametric${OBJEXT}: CutParametric.cpp ../Post/OctreePost.h \
   ../Post/PView.h ../Geo/SPoint3.h ../Post/PViewDataList.h \
   ../Post/PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
   ../Common/ListUtils.h ../Numeric/GmshMatrix.h ../Common/Context.h \
-  ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h ../Common/GmshUI.h \
+  ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h \
   ../Graphics/drawContext.h ../Fltk/Draw.h
 Lambda2${OBJEXT}: Lambda2.cpp Lambda2.h Plugin.h ../Common/Options.h \
   ../Post/ColorTable.h ../Common/GmshMessage.h ../Post/PView.h \
@@ -142,15 +141,14 @@ StreamLines${OBJEXT}: StreamLines.cpp StreamLines.h Plugin.h ../Common/Options.h
   ../Numeric/GmshMatrix.h ../Post/OctreePost.h ../Common/Octree.h \
   ../Common/OctreeInternals.h ../Common/Context.h ../Geo/CGNSOptions.h \
   ../Mesh/PartitionOptions.h ../Post/PViewOptions.h ../Post/ColorTable.h \
-  ../Common/GmshUI.h ../Graphics/drawContext.h ../Fltk/Draw.h
+  ../Graphics/drawContext.h ../Fltk/Draw.h
 CutGrid${OBJEXT}: CutGrid.cpp ../Post/OctreePost.h ../Common/Octree.h \
   ../Common/OctreeInternals.h CutGrid.h Plugin.h ../Common/Options.h \
   ../Post/ColorTable.h ../Common/GmshMessage.h ../Post/PView.h \
   ../Geo/SPoint3.h ../Post/PViewDataList.h ../Post/PViewData.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Common/ListUtils.h \
   ../Numeric/GmshMatrix.h ../Common/Context.h ../Geo/CGNSOptions.h \
-  ../Mesh/PartitionOptions.h ../Common/GmshUI.h ../Graphics/drawContext.h \
-  ../Fltk/Draw.h
+  ../Mesh/PartitionOptions.h ../Graphics/drawContext.h ../Fltk/Draw.h
 Transform${OBJEXT}: Transform.cpp Transform.h Plugin.h ../Common/Options.h \
   ../Post/ColorTable.h ../Common/GmshMessage.h ../Post/PView.h \
   ../Geo/SPoint3.h ../Post/PViewDataList.h ../Post/PViewData.h \
@@ -282,10 +280,8 @@ Annotate${OBJEXT}: Annotate.cpp Annotate.h Plugin.h ../Common/Options.h \
   ../Geo/SPoint3.h ../Post/PViewDataList.h ../Post/PViewData.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Common/ListUtils.h \
   ../Numeric/GmshMatrix.h ../Common/Context.h ../Geo/CGNSOptions.h \
-  ../Mesh/PartitionOptions.h ../Common/GmshUI.h ../Fltk/GUI.h \
-  ../Fltk/Opengl_Window.h ../Graphics/drawContext.h \
-  ../Fltk/Colorbar_Window.h ../Fltk/Popup_Button.h \
-  ../Fltk/SpherePosition_Widget.h ../Mesh/Field.h ../Fltk/Draw.h
+  ../Mesh/PartitionOptions.h ../Graphics/drawContext.h ../Fltk/Draw.h \
+  ../Fltk/GUI.h
 Remove${OBJEXT}: Remove.cpp Remove.h Plugin.h ../Common/Options.h \
   ../Post/ColorTable.h ../Common/GmshMessage.h ../Post/PView.h \
   ../Geo/SPoint3.h ../Post/PViewDataList.h ../Post/PViewData.h \
@@ -297,8 +293,7 @@ Probe${OBJEXT}: Probe.cpp Probe.h Plugin.h ../Common/Options.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Common/ListUtils.h \
   ../Numeric/GmshMatrix.h ../Common/Context.h ../Geo/CGNSOptions.h \
   ../Mesh/PartitionOptions.h ../Post/OctreePost.h ../Common/Octree.h \
-  ../Common/OctreeInternals.h ../Common/GmshUI.h \
-  ../Graphics/drawContext.h ../Fltk/Draw.h
+  ../Common/OctreeInternals.h ../Graphics/drawContext.h ../Fltk/Draw.h
 HarmonicToTime${OBJEXT}: HarmonicToTime.cpp HarmonicToTime.h Plugin.h \
   ../Common/Options.h ../Post/ColorTable.h ../Common/GmshMessage.h \
   ../Post/PView.h ../Geo/SPoint3.h ../Post/PViewDataList.h \
diff --git a/Plugin/Probe.cpp b/Plugin/Probe.cpp
index c0aa4191136aec77714d9985569bcd2790a79056..c5c3c4c04e4cc927dbb7b7aceb291756b8d1cb33 100644
--- a/Plugin/Probe.cpp
+++ b/Plugin/Probe.cpp
@@ -8,7 +8,7 @@
 #include "OctreePost.h"
 
 #if defined(HAVE_FLTK)
-#include "GmshUI.h"
+#include <FL/gl.h>
 #include "drawContext.h"
 #include "Draw.h"
 #endif
diff --git a/Plugin/StreamLines.cpp b/Plugin/StreamLines.cpp
index 74877316f2bdd4493e4f28a732f9efb9f8e7e454..7c3e8140b68792e81d7a1be60b4750cca8ba46bf 100644
--- a/Plugin/StreamLines.cpp
+++ b/Plugin/StreamLines.cpp
@@ -10,7 +10,7 @@
 #include "PViewOptions.h"
 
 #if defined(HAVE_FLTK)
-#include "GmshUI.h"
+#include <FL/gl.h>
 #include "drawContext.h"
 #include "Draw.h"
 #endif
diff --git a/doc/VERSIONS.txt b/doc/VERSIONS.txt
index f77b3343265f092b600c4a7587f09e5d095a5e6f..ed8d86f35d03cd7800c5a8b82f7f06f3756e6b0b 100644
--- a/doc/VERSIONS.txt
+++ b/doc/VERSIONS.txt
@@ -1,8 +1,8 @@
-$Id: VERSIONS.txt,v 1.20 2008-11-28 18:49:10 geuzaine Exp $
+$Id: VERSIONS.txt,v 1.21 2008-12-01 20:08:27 geuzaine Exp $
 
 2.2.7 (?): restored full-quad recombine algorithm; fixed clipping
 planes when more than 32 views are present (replaced General.Clip with
-{Geometry,Mesh,View}.Clip).
+{Geometry,Mesh,View}.Clip); major graphics and gui code refactoring.
 
 2.2.6 (Nov 21, 2008): better transfinite smoothing and automatic
 corner selection; fixed high order meshing crashes on Windows and