From d3755b23f3ad36fff46b80d76c074a3980916975 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Mon, 8 Jan 2001 08:20:11 +0000
Subject: [PATCH] *** empty log message ***

---
 Fltk/Callbacks.cpp             | 112 ++++++++
 Fltk/Callbacks.h               |  34 +++
 Fltk/GUI.cpp                   | 316 ++++++++++++++++++++++
 Fltk/GUI.h                     | 103 ++++++++
 Fltk/Main.cpp                  | 152 +++++++++++
 Fltk/Makefile                  |  85 ++++++
 Fltk/Message.cpp               | 236 +++++++++++++++++
 Fltk/Opengl.cpp                | 470 +++++++++++++++++++++++++++++++++
 {Unix => Motif}/Bitmaps.h      |   0
 {Unix => Motif}/CbColorbar.cpp |   2 +-
 {Unix => Motif}/CbColorbar.h   |   0
 {Unix => Motif}/CbContext.cpp  |   2 +-
 {Unix => Motif}/CbContext.h    |   0
 {Unix => Motif}/CbFile.cpp     |   2 +-
 {Unix => Motif}/CbFile.h       |   0
 {Unix => Motif}/CbGeneral.cpp  |   2 +-
 {Unix => Motif}/CbGeneral.h    |   0
 {Unix => Motif}/CbGeom.cpp     |   2 +-
 {Unix => Motif}/CbGeom.h       |   0
 {Unix => Motif}/CbInput.cpp    |   2 +-
 {Unix => Motif}/CbMesh.cpp     |   2 +-
 {Unix => Motif}/CbMesh.h       |   0
 {Unix => Motif}/CbOptions.cpp  |   2 +-
 {Unix => Motif}/CbOptions.h    |   0
 {Unix => Motif}/CbPost.cpp     |   2 +-
 {Unix => Motif}/CbPost.h       |   0
 {Unix => Motif}/Geometry.cpp   |   2 +-
 {Unix => Motif}/Geometry.h     |   0
 {Unix => Motif}/Help.h         |   0
 {Unix => Motif}/Info.h         |   0
 {Unix => Motif}/Main.cpp       |   2 +-
 {Unix => Motif}/Makefile       |   2 +-
 {Unix => Motif}/Message.cpp    |   2 +-
 Motif/Opengl.cpp               | 159 +++++++++++
 {Unix => Motif}/Pixmaps.cpp    |   2 +-
 {Unix => Motif}/Pixmaps.h      |   0
 {Unix => Motif}/Register.cpp   |   2 +-
 {Unix => Motif}/Register.h     |   0
 {Unix => Motif}/Widgets.cpp    |   2 +-
 {Unix => Motif}/Widgets.h      |   0
 {Unix => Motif}/XColors.cpp    |   2 +-
 {Unix => Motif}/XColors.h      |   0
 {Unix => Motif}/XContext.h     |   0
 {Unix => Motif}/XCursor.cpp    |   2 +-
 {Unix => Motif}/XRessources.h  |   0
 {Unix => Motif}/XStatic.h      |   0
 Unix/Main.h                    |  12 -
 47 files changed, 1685 insertions(+), 30 deletions(-)
 create mode 100644 Fltk/Callbacks.cpp
 create mode 100644 Fltk/Callbacks.h
 create mode 100644 Fltk/GUI.cpp
 create mode 100644 Fltk/GUI.h
 create mode 100644 Fltk/Main.cpp
 create mode 100644 Fltk/Makefile
 create mode 100644 Fltk/Message.cpp
 create mode 100644 Fltk/Opengl.cpp
 rename {Unix => Motif}/Bitmaps.h (100%)
 rename {Unix => Motif}/CbColorbar.cpp (99%)
 rename {Unix => Motif}/CbColorbar.h (100%)
 rename {Unix => Motif}/CbContext.cpp (99%)
 rename {Unix => Motif}/CbContext.h (100%)
 rename {Unix => Motif}/CbFile.cpp (96%)
 rename {Unix => Motif}/CbFile.h (100%)
 rename {Unix => Motif}/CbGeneral.cpp (99%)
 rename {Unix => Motif}/CbGeneral.h (100%)
 rename {Unix => Motif}/CbGeom.cpp (99%)
 rename {Unix => Motif}/CbGeom.h (100%)
 rename {Unix => Motif}/CbInput.cpp (99%)
 rename {Unix => Motif}/CbMesh.cpp (99%)
 rename {Unix => Motif}/CbMesh.h (100%)
 rename {Unix => Motif}/CbOptions.cpp (99%)
 rename {Unix => Motif}/CbOptions.h (100%)
 rename {Unix => Motif}/CbPost.cpp (99%)
 rename {Unix => Motif}/CbPost.h (100%)
 rename {Unix => Motif}/Geometry.cpp (99%)
 rename {Unix => Motif}/Geometry.h (100%)
 rename {Unix => Motif}/Help.h (100%)
 rename {Unix => Motif}/Info.h (100%)
 rename {Unix => Motif}/Main.cpp (99%)
 rename {Unix => Motif}/Makefile (99%)
 rename {Unix => Motif}/Message.cpp (99%)
 create mode 100644 Motif/Opengl.cpp
 rename {Unix => Motif}/Pixmaps.cpp (98%)
 rename {Unix => Motif}/Pixmaps.h (100%)
 rename {Unix => Motif}/Register.cpp (99%)
 rename {Unix => Motif}/Register.h (100%)
 rename {Unix => Motif}/Widgets.cpp (99%)
 rename {Unix => Motif}/Widgets.h (100%)
 rename {Unix => Motif}/XColors.cpp (99%)
 rename {Unix => Motif}/XColors.h (100%)
 rename {Unix => Motif}/XContext.h (100%)
 rename {Unix => Motif}/XCursor.cpp (96%)
 rename {Unix => Motif}/XRessources.h (100%)
 rename {Unix => Motif}/XStatic.h (100%)
 delete mode 100644 Unix/Main.h

diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp
new file mode 100644
index 0000000000..20628b02cc
--- /dev/null
+++ b/Fltk/Callbacks.cpp
@@ -0,0 +1,112 @@
+
+#include "Gmsh.h"
+#include "GmshUI.h"
+#include "Geo.h"
+#include "Mesh.h"
+#include "Draw.h"
+#include "Views.h"
+#include "OpenFile.h"
+#include "Context.h"
+#include "GUI.h"
+
+#include <FL/fl_file_chooser.H>
+
+extern GUI *WID;
+extern Mesh M;
+extern Context_T CTX;
+
+// File Menu
+
+void file_open_cb(void) {
+  char *newfile;
+  newfile = fl_file_chooser("Open File", "*.geo", NULL);
+  if (newfile != NULL) {
+    OpenProblem(newfile); 
+    Init();
+    Draw(); 
+  }
+}
+
+void file_merge_cb(void) {
+  char *newfile;
+  newfile = fl_file_chooser("Merge File", "*.{geo,pos,msh}", NULL);
+  if (newfile != NULL) {
+    MergeProblem(newfile); 
+    Init();
+    Draw(); 
+  }
+}
+
+void file_save_cb(void) {
+}
+
+void file_save_as_cb(void) {
+}
+
+void file_reload_all_views_cb(void) {
+}
+
+void file_remove_all_views_cb(void) {
+}
+
+void file_quit_cb(void) {
+  exit(0);
+}
+
+// Option Menu
+
+void opt_general_cb(void) {
+  WID->opt_general();
+}
+
+void opt_geometry_cb(void) {
+}
+void opt_mesh_cb(void) {
+}
+void opt_post_cb(void) {
+}
+void opt_stat_cb(void) {
+}
+
+// Help Menu
+
+void help_short_cb(void){
+}
+void help_about_cb(void){
+}
+
+// Module Menu
+
+void mod_geometry_cb(void){
+}
+void mod_mesh_cb(void){
+}
+void mod_post_cb(void){
+}
+
+// View Menus
+
+void view_reload_cb(Fl_Widget* w, void* data){
+  printf("Reload view %d \n", (int)data);
+}
+void view_remove_cb(Fl_Widget* w, void* data){
+  printf("Remove view %d \n", (int)data);
+}
+void view_duplicate_cb(Fl_Widget* w, void* data){
+  printf("Duplicate view %d \n", (int)data);
+}
+void view_lighting_cb(Fl_Widget* w, void* data){
+  printf("Light view %d \n", (int)data);
+}
+void view_elements_cb(Fl_Widget* w, void* data){
+  printf("Show Elements view %d \n", (int)data);
+}
+void view_applybgmesh_cb(Fl_Widget* w, void* data){
+  printf("Apply bgmesh view %d \n", (int)data);
+}
+void view_timestep_cb(Fl_Widget* w, void* data){
+  printf("Timestep view %d \n", (int)data);
+}
+void view_options_cb(Fl_Widget* w, void* data){
+  printf("Options view %d \n", (int)data);
+}
diff --git a/Fltk/Callbacks.h b/Fltk/Callbacks.h
new file mode 100644
index 0000000000..f04535f8cd
--- /dev/null
+++ b/Fltk/Callbacks.h
@@ -0,0 +1,34 @@
+#ifndef _CALLBACKS_H_
+#define _CALLBACKS_H_
+
+void file_open_cb(void) ;
+void file_merge_cb(void) ;
+void file_save_cb(void) ;
+void file_save_as_cb(void) ;
+void file_reload_all_views_cb(void) ;
+void file_remove_all_views_cb(void) ;
+void file_quit_cb(void) ;
+
+void opt_general_cb(void) ;
+void opt_geometry_cb(void) ;
+void opt_mesh_cb(void) ;
+void opt_post_cb(void) ;
+void opt_stat_cb(void) ;
+
+void help_short_cb(void) ;
+void help_about_cb(void) ;
+
+void mod_geometry_cb(void) ;
+void mod_mesh_cb(void) ;
+void mod_post_cb(void) ;
+
+void view_reload_cb(Fl_Widget* w, void*) ;
+void view_remove_cb(Fl_Widget* w, void*) ;
+void view_duplicate_cb(Fl_Widget* w, void*) ;
+void view_lighting_cb(Fl_Widget* w, void*) ;
+void view_elements_cb(Fl_Widget* w, void*) ;
+void view_timestep_cb(Fl_Widget* w, void*) ;
+void view_options_cb(Fl_Widget* w, void*) ;
+void view_applybgmesh_cb(Fl_Widget* w, void*) ;
+
+#endif
diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp
new file mode 100644
index 0000000000..09ea8127e3
--- /dev/null
+++ b/Fltk/GUI.cpp
@@ -0,0 +1,316 @@
+
+// To make the interface as visually consistent as possible, please:
+// - use the BH and WB values for button heights and window borders
+// - use CTX.fontsize for font sizes
+// - examine what's already done before adding something new...
+
+#include "Gmsh.h"
+#include "GmshUI.h"
+#include "Context.h"
+#include "Const.h"
+#include "Geo.h"
+#include "Mesh.h"
+#include "Draw.h"
+#include "Version.h"
+#include "GUI.h"
+#include "Callbacks.h"
+
+extern Context_T CTX;
+
+// Definition of the static menus
+
+Fl_Menu_Item m_menubar_table[] = {
+  {"File", 0, 0, 0, FL_SUBMENU},
+    {"Open...",          FL_CTRL+'o', (Fl_Callback *)file_open_cb, 0},
+    {"Merge...",         FL_CTRL+'m', (Fl_Callback *)file_merge_cb, 0, FL_MENU_DIVIDER},
+    {"Save",             FL_CTRL+'s', (Fl_Callback *)file_save_cb, 0},
+    {"Save As...",       FL_CTRL+'p', (Fl_Callback *)file_save_as_cb, 0, FL_MENU_DIVIDER},
+    {"Reload All Views", FL_CTRL+'l', (Fl_Callback *)file_reload_all_views_cb, 0},
+    {"Remove All Views", FL_CTRL+'r', (Fl_Callback *)file_remove_all_views_cb, 0, FL_MENU_DIVIDER},
+    {"Quit",             FL_CTRL+'q', (Fl_Callback *)file_quit_cb, 0},
+    {0},
+  {"Options",0,0,0,FL_SUBMENU},
+    {"Geometry...",        FL_SHIFT+'g', (Fl_Callback *)opt_geometry_cb, 0},
+    {"Mesh...",            FL_SHIFT+'m', (Fl_Callback *)opt_mesh_cb, 0},
+    {"Post-Processing...", FL_SHIFT+'p', (Fl_Callback *)opt_post_cb, 0, FL_MENU_DIVIDER},
+    {"General...",         FL_SHIFT+'o', (Fl_Callback *)opt_general_cb, 0},
+    {"Statistics...",      FL_SHIFT+'i', (Fl_Callback *)opt_stat_cb, 0},
+    {0},
+  {"Help",0,0,0,FL_SUBMENU},
+    {"Short Help...",   0, (Fl_Callback *)help_short_cb, 0, FL_MENU_DIVIDER},
+    {"About...",        0, (Fl_Callback *)help_about_cb, 0},
+    {0},
+  {0}
+};
+
+Fl_Menu_Item m_module_table[] = {
+  {" Geometry",        'g', (Fl_Callback *)mod_geometry_cb, 0},
+  {" Mesh",            'm', (Fl_Callback *)mod_mesh_cb, 0},
+  {" Post-Processing", 'p', (Fl_Callback *)mod_post_cb, 0},
+  {0}
+};
+
+
+// The GUI constructor creates ONLY the widgets that always exist (we
+// want the lowest memory footprint for the interface and the fastest
+// startup time). All optional dialogs are also created only once, but
+// on demand.
+
+GUI::GUI() {
+  int i, x, y;
+
+  BH = 2*CTX.fontsize+2;
+  WB = CTX.fontsize-6;
+
+  if(strlen(CTX.display)) Fl::display(CTX.display);
+
+  // Menu Window
+
+  {
+    int width = 152 ;
+    int height = 450 ;
+
+    m_window = new Fl_Window(width,height);
+    m_window->box(FL_THIN_UP_BOX);
+
+    {
+      Fl_Menu_Bar *o = new Fl_Menu_Bar(0,0,width,BH); 
+      o->menu(m_menubar_table);
+      o->textsize(CTX.fontsize);
+      o->box(FL_UP_BOX);
+    }
+
+    Fl_Box *o = new Fl_Box(0,BH,width,BH+6);
+    o->box(FL_UP_BOX);
+
+    y = BH+3;
+    
+    m_navig_butt[0] = new Fl_Button(2,y,20,BH/2,"@<");
+    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[1] = new Fl_Button(2,y+BH/2,20,BH/2,"@>");
+    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_module_butt = new Fl_Choice(22,y,width-26,BH);
+    m_module_butt->menu(m_module_table);
+    m_module_butt->textsize(CTX.fontsize);
+    m_module_butt->box(FL_THIN_DOWN_BOX);
+    
+    y = BH+ BH +6;
+    
+    for(i=0; i<NB_BUTT_MAX; i++){
+      m_push_butt[i] = new Fl_Button(0,y+i*BH,width,BH); 
+      m_push_butt[i]->labelsize(CTX.fontsize);
+      m_push_butt[i]->hide();
+      m_toggle_butt[i] = new Fl_Light_Button(0,y+i*BH,width,BH,"test"); 
+      m_toggle_butt[i]->labelsize(CTX.fontsize); 
+      if(i>5)m_toggle_butt[i]->hide();
+      m_popup_butt[i] = new Fl_Menu_Button(0,y+i*BH,width,BH);
+      m_popup_butt[i]->type(Fl_Menu_Button::POPUP3);
+      m_popup_butt[i]->add("Reload", 0, 
+			   (Fl_Callback *)view_reload_cb, (void*)i, 0);
+      m_popup_butt[i]->add("Remove", 0, 
+			   (Fl_Callback *)view_remove_cb, (void*)i, 0);
+      m_popup_butt[i]->add("Duplicate", 0,
+			   (Fl_Callback *)view_duplicate_cb, (void*)i, 0);
+      m_popup_butt[i]->add("Lightning", 0,
+			   (Fl_Callback *)view_lighting_cb, (void*)i, 0);
+      m_popup_butt[i]->add("Show Elements", 0,
+			   (Fl_Callback *)view_elements_cb, (void*)i, 0);
+      m_popup_butt[i]->add("Apply as Background Mesh", 0,
+			   (Fl_Callback *)view_applybgmesh_cb, (void*)i, FL_MENU_DIVIDER);
+      m_popup_butt[i]->add("Time Step...", 0,
+			   (Fl_Callback *)view_timestep_cb, (void*)i, 0);
+      m_popup_butt[i]->add("Options...", 0,
+			   (Fl_Callback *)view_options_cb, (void*)i, 0);
+      m_popup_butt[i]->textsize(CTX.fontsize);
+      if(i>5)m_popup_butt[i]->hide();
+    }
+    
+    m_window->resizable(m_window);
+    
+    m_window->position(800,50);
+    m_window->end();
+    m_window->show();
+
+  }
+    
+  // Graphic Window
+
+  {
+    g_window = new Fl_Window(700,520);
+
+    g_opengl_window = new Opengl_Window(0,0,700,500);
+    
+    {
+      Fl_Group *o = new Fl_Group(0,500,700,20);
+      o->box(FL_THIN_UP_BOX);
+
+      x = 2;
+      g_status_butt[0] = new Fl_Button(x,502,15,16,"X"); x+=15;
+      //g_status_butt[0]->tooltip("Set X view");
+      g_status_butt[1] = new Fl_Button(x,502,15,16,"Y"); x+=15;
+      g_status_butt[2] = new Fl_Button(x,502,15,16,"Z"); x+=15;
+      g_status_butt[3] = new Fl_Button(x,502,16,16,"1:1"); x+=16;
+      g_status_butt[4] = new Fl_Button(x,502,15,16,"?"); x+=15;
+      g_status_butt[5] = new Fl_Button(x,502,15,16,">>"); x+=15;
+      g_status_butt[6] = new Fl_Button(x,502,15,16,"0"); x+=15;
+      for(i = 0 ; i<7 ; i++){
+	g_status_butt[i]->box(FL_FLAT_BOX);
+	g_status_butt[i]->selection_color(FL_WHITE);
+	g_status_butt[i]->labelsize(CTX.fontsize);
+	g_status_butt[i]->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE|FL_ALIGN_CLIP);
+      }
+
+      g_status_box[0] = new Fl_Box(x,502,(700-x)/3,16);
+      g_status_box[1] = new Fl_Box(x+(700-x)/3,5022,(700-x)/3,16);
+      g_status_box[2] = new Fl_Box(x+2*(700-x)/3,5022,(700-x)/3-2,16);
+      for(i = 0 ; i<3 ; i++){
+	g_status_box[i]->box(FL_FLAT_BOX);
+	g_status_box[i]->labelsize(CTX.fontsize);
+	g_status_box[i]->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE|FL_ALIGN_CLIP);
+      }
+      
+      o->end();
+    }
+
+    g_window->resizable(g_opengl_window);
+    g_window->position(20,30);
+    g_window->end();
+    g_window->show();
+    
+  }
+
+  // Draw the actual scene
+
+  g_opengl_window->redraw();
+
+}
+
+// Definition of general purpose public GUI functions. This is mainly
+// for compatibility with the old Motif programming structure.
+
+void GUI::draw_gl(){
+  g_opengl_window->redraw();
+}
+
+void GUI::draw_gl_overlay(){
+  g_opengl_window->redraw_overlay();
+}
+
+void GUI::run(){
+  Fl::run();
+}
+
+void GUI::check(){
+  Fl::check();
+}
+
+static int initw, inith, init=1;
+void GUI::set_size(int w, int h){
+  if(init){
+    init = 0;
+    initw = w;
+    inith = h;
+  }
+  if(w == initw && h == inith) return;
+  initw = w;
+  inith = h;
+  int hh = g_window->h()-g_opengl_window->h();
+  g_window->size(w,h+hh);
+}
+
+// The window for general options
+
+static int init_opt_general = 0;
+
+void GUI::opt_general(){
+  if(!init_opt_general){
+    init_opt_general = 1 ;
+
+    int width = 280;
+    int height = 5*WB+8*BH ;
+    
+    gen_window = new Fl_Window(width,height);
+    gen_window->box(FL_THIN_UP_BOX);
+    { 
+      Fl_Tabs* o = new Fl_Tabs(WB, WB, width-2*WB, height-3*WB-BH);
+      { 
+	Fl_Group* o = new Fl_Group(WB, WB+BH, width-2*WB, height-3*WB-2*BH, "Miscellaneous");
+	o->labelsize(CTX.fontsize);
+        gen_butt[0] = new Fl_Check_Button(2*WB, 2*WB+BH, 150, BH, "Show moving axes");
+        gen_butt[1] = new Fl_Check_Button(2*WB, 2*WB+2*BH, 150, BH, "Show small axes");
+        gen_butt[2] = new Fl_Check_Button(2*WB, 2*WB+3*BH, 150, BH, "Enable fast redraw");
+        gen_butt[3] = new Fl_Check_Button(2*WB, 2*WB+4*BH, 150, BH, "Use Display lists");
+        gen_butt[4] = new Fl_Check_Button(2*WB, 2*WB+5*BH, 150, BH, "Enable alpha blending");
+        gen_butt[5] = new Fl_Check_Button(2*WB, 2*WB+6*BH, 150, BH, "Trackball rotation mode");
+	for(int i=0 ; i<6 ; i++){
+	  gen_butt[i]->type(FL_TOGGLE_BUTTON);
+	  gen_butt[i]->down_box(FL_DOWN_BOX);
+	  gen_butt[i]->labelsize(CTX.fontsize);
+	  gen_butt[i]->selection_color(FL_YELLOW);
+	}
+        o->end();
+      }
+      { 
+	Fl_Group* o = new Fl_Group(WB, WB+BH, width-2*WB, height-3*WB-2*BH, "Projection");
+	o->labelsize(CTX.fontsize);
+        o->hide();
+        gen_butt[6] = new Fl_Check_Button(2*WB, 2*WB+BH, 150, BH, "Orthographic");
+        gen_butt[7] = new Fl_Check_Button(2*WB, 2*WB+2*BH, 150, BH, "Perspective");
+	for(int i=6 ; i<8 ; i++){
+	  gen_butt[i]->type(FL_RADIO_BUTTON);
+	  gen_butt[i]->labelsize(CTX.fontsize);
+	  gen_butt[i]->selection_color(FL_YELLOW);
+	}
+        o->end();
+      }
+      { 
+	Fl_Group* o = new Fl_Group(WB, WB+BH, width-2*WB, height-3*WB-2*BH, "Light and color");
+	o->labelsize(CTX.fontsize);
+        o->hide();
+        gen_value[0] = new Fl_Value_Input(2*WB, 2*WB+BH, 100, BH, "Color Scheme");
+	gen_value[0]->minimum(1); gen_value[0]->maximum(3); gen_value[0]->step(1);
+	gen_value[1] = new Fl_Value_Input(2*WB, 2*WB+2*BH, 100, BH, "Shininess");
+	gen_value[1]->minimum(0); gen_value[1]->maximum(100); gen_value[1]->step(1);
+        gen_value[2] = new Fl_Value_Input(2*WB, 2*WB+3*BH, 100, BH, "Light Position X");
+	gen_value[2]->minimum(0); gen_value[2]->maximum(100); gen_value[2]->step(1);
+        gen_value[3] = new Fl_Value_Input(2*WB, 2*WB+4*BH, 100, BH, "Light Position Y");
+	gen_value[3]->minimum(0); gen_value[3]->maximum(100); gen_value[3]->step(1);
+        gen_value[4] = new Fl_Value_Input(2*WB, 2*WB+5*BH, 100, BH, "Light Position Z");
+	gen_value[4]->minimum(0); gen_value[4]->maximum(100); gen_value[4]->step(1);
+	for(int i=0 ; i<5 ; i++){
+	  gen_value[i]->labelsize(CTX.fontsize);
+	  gen_value[i]->type(FL_HORIZONTAL);
+	  gen_value[i]->align(FL_ALIGN_RIGHT);
+	}
+        o->end();
+      }
+      o->end();
+
+    }
+
+    { 
+      Fl_Button* o = new Fl_Button(width-2*60-2*WB, height-BH-WB, 60, BH, "cancel");
+      o->labelsize(CTX.fontsize);
+    }
+    { 
+      Fl_Return_Button* o = new Fl_Return_Button(width-60-WB, height-BH-WB, 60, BH, "OK");
+      o->labelsize(CTX.fontsize);
+    }
+
+    gen_window->end();
+    gen_window->show();
+  }
+  else{
+    if(gen_window->shown())
+      gen_window->hide();
+    else
+      gen_window->show();
+    
+  }
+
+}
diff --git a/Fltk/GUI.h b/Fltk/GUI.h
new file mode 100644
index 0000000000..5595d2bd74
--- /dev/null
+++ b/Fltk/GUI.h
@@ -0,0 +1,103 @@
+#ifndef _GUI_H_
+#define _GUI_H_
+
+#include <FL/Fl_Window.H>
+#include <FL/Fl_Box.H>
+#include <FL/Fl_Menu_Bar.H>
+#include <FL/fl_draw.H>
+#include <FL/gl.h>
+#include <FL/Fl_Gl_Window.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_Toggle_Button.H>
+#include <FL/Fl_Round_Button.H>
+#include <FL/Fl_Light_Button.H>
+#include <FL/Fl_Menu_Button.H>
+#include <FL/Fl_Check_Button.H>
+
+#include <FL/Fl_Value_Input.H>
+
+#define NB_BUTT_MAX  100
+
+// New composite widgets
+
+class Opengl_Window : public Fl_Gl_Window {
+  void draw();
+  void draw_overlay();
+  int handle(int);
+
+  // new
+  void draw_highlight();
+  void clear_overlay();
+  void draw_overlay_zoom();
+  void draw_overlay_highlight();
+
+public:
+  Opengl_Window(int x,int y,int w,int h,const char *l=0)
+    : Fl_Gl_Window(x, y, w, h, l) {}
+};
+
+// The GUI class contains only the important widgets
+
+class GUI{
+
+  int BH; // button height
+  int WB; // window border
+  
+  // Windows
+  Fl_Window  *m_window, *g_window, *gen_window, *geo_window ;
+  Fl_Window  *mesh_window, *post_window, *stat_window ;
+  Fl_Window  *view_window ;
+  Opengl_Window    *g_opengl_window ;
+  
+  // We keep the following widgets for easy further reference
+
+  // menu window
+  Fl_Choice        *m_module_butt ;
+  Fl_Button        *m_navig_butt  [2] ;
+  Fl_Button        *m_push_butt   [NB_BUTT_MAX] ;
+  Fl_Light_Button  *m_toggle_butt [NB_BUTT_MAX] ;
+  Fl_Menu_Button   *m_popup_butt  [NB_BUTT_MAX] ;
+
+  // graphic window
+  Fl_Button        *g_status_butt[7] ;
+  Fl_Box           *g_status_box[3] ;
+
+  // general options window
+  Fl_Check_Button  *gen_butt[10] ;
+  Fl_Value_Input   *gen_value[10] ;
+
+  // geometry options window
+  
+  // mesh options window
+
+  // post-processing options window
+
+  // statistics window
+
+  // view options window
+
+public:
+
+  GUI();
+  void run();
+  void check();
+  void draw_gl();
+  void draw_gl_overlay();
+  void set_size(int w, int h);
+
+  void opt_general();
+  void opt_geometry();
+  void opt_mesh();
+  void opt_post();
+  void opt_stat();
+
+};
+
+
+#endif
+
diff --git a/Fltk/Main.cpp b/Fltk/Main.cpp
new file mode 100644
index 0000000000..b19988a8d3
--- /dev/null
+++ b/Fltk/Main.cpp
@@ -0,0 +1,152 @@
+// $Id: Main.cpp,v 1.1 2001-01-08 08:16:27 geuzaine Exp $
+
+#include <signal.h>
+
+#include "Gmsh.h"
+#include "GmshUI.h"
+
+#include "Geo.h"
+#include "Verif.h"
+#include "Mesh.h"
+#include "Draw.h"
+#include "Context.h"
+#include "ColorTable.h"
+#include "Parser.h"
+#include "Static.h"
+#include "Version.h"
+#include "GUI.h"
+#include "OpenFile.h"
+#include "GetOptions.h"
+
+extern List_T *Post_ViewList;
+int            SHOW_ALL_ENTITIES ;
+
+void AddViewInUI(int, char *, int){}
+
+GUI *WID ;
+
+int main(int argc, char *argv[]){
+  int     i, nbf;
+  extern char  TextAbout[1024];
+ 
+  // Gmsh default context options
+  
+  Init_Context();
+
+  // Command line options
+
+  Get_Options(argc, argv, &nbf);
+
+  if(CTX.verbosity)
+    fprintf(stderr, "%s, Version %.2f\n", gmsh_progname, GMSH_VERSION);
+
+  // Initialize the static Mesh
+
+  M.Vertices = NULL ;
+  M.VertexEdges = NULL ;
+  M.Simplexes = NULL ;
+  M.Points = NULL ;
+  M.Curves = NULL ;
+  M.SurfaceLoops = NULL ;
+  M.EdgeLoops = NULL ;
+  M.Surfaces = NULL ;
+  M.Volumes = NULL ;
+  M.PhysicalGroups = NULL ;
+  M.Metric = NULL ;
+
+  // Signal handling
+
+  signal(SIGINT,  Signal); 
+  signal(SIGSEGV, Signal);
+  signal(SIGFPE,  Signal); 
+
+  // Non-interactive Gmsh
+
+  if(CTX.interactive){
+    OpenProblem(CTX.filename);
+    if(yyerrorstate)
+      exit(1);
+    else {
+      if(nbf > 1){
+        for(i=1;i<nbf;i++) MergeProblem(TheFileNameTab[i]);
+      }
+      if(TheBgmFileName){
+        MergeProblem(TheBgmFileName);
+        if(List_Nbr(Post_ViewList))
+          BGMWithView((Post_View*)List_Pointer(Post_ViewList, List_Nbr(Post_ViewList)-1));
+        else
+          Msg(ERROR, "Invalid Background Mesh (no View)");
+      }
+      if(CTX.interactive > 0){
+        mai3d(THEM, CTX.interactive);
+        Print_Mesh(THEM,NULL,CTX.mesh.format);
+      }
+      else
+        Print_Geo(THEM, NULL);
+      exit(1);
+    }    
+  }
+  
+
+  // Interactive Gmsh
+
+  CTX.interactive = -1 ; // The GUI is not ready yet for interactivity
+
+  // Text for about window
+
+  sprintf(TextAbout, "%s\n \n%s%.2f\n%s\n%s\n%s\n%s\n%s\n%s\n \n%s\n \n"
+          "Type 'gmsh -help' for command line options",
+          gmsh_progname, gmsh_version, GMSH_VERSION, 
+          gmsh_os, gmsh_date, gmsh_host, gmsh_packager, 
+          gmsh_url, gmsh_email, gmsh_copyright);
+
+  // Create the GUI
+  
+  WID = new GUI();
+
+  // The GUI is ready
+  CTX.interactive = 0 ; 
+  CTX.expose = 1 ;
+
+  // Say welcome!
+
+  Msg(STATUS, "Ready");
+  Msg(SELECT, "Gmsh %.2f", GMSH_VERSION);
+
+  // Display the GUI to have a quick "a la Windows" launch time
+
+  WID->check();
+
+  // Open input file
+
+  OpenProblem(CTX.filename);
+
+  // Merge all Input Files, then init first context (geometry or post)
+
+  if(nbf > 1){
+    for(i=1;i<nbf;i++) MergeProblem(TheFileNameTab[i]);
+    //ActualizeContextCb (NULL,(XtPointer)CONTEXT_POST,NULL); 
+  }
+  else {
+    //ActualizeContextCb(NULL,(XtPointer)CONTEXT_GEOM,NULL);
+  }
+
+  // Read background mesh on disk
+
+  if(TheBgmFileName){
+    MergeProblem(TheBgmFileName);
+    if(List_Nbr(Post_ViewList))
+      BGMWithView((Post_View*)List_Pointer(Post_ViewList, List_Nbr(Post_ViewList)-1));
+    else
+      Msg(ERROR, "Invalid Background Mesh (no View)");
+  }
+
+  // Draw the actual scene
+  Init();
+  Draw();
+
+  // loop
+  WID->run();
+
+}
+  
diff --git a/Fltk/Makefile b/Fltk/Makefile
new file mode 100644
index 0000000000..c3fc8f2a2a
--- /dev/null
+++ b/Fltk/Makefile
@@ -0,0 +1,85 @@
+# $Id: Makefile,v 1.1 2001-01-08 08:16:27 geuzaine Exp $
+#
+# Makefile for "libFltk.a"
+#
+
+.IGNORE:
+
+CC       = c++
+RM       = rm
+RANLIB   = ranlib
+
+LIB      = ../lib/libFltk.a
+INCLUDE  = -I../Common -I../DataStr -I../Graphics -I../Geo\
+           -I../Mesh -I../Parser -I../Fltk
+
+C_FLAGS       = -g -Wall
+OS_FLAGS      = -D_LITTLE_ENDIAN
+VERSION_FLAGS = -D_NOTHREADS -D_FLTK
+
+GL_INCLUDE    = -I$(HOME)/SOURCES/Mesa-3.1/include\
+                -I$(HOME)/SOURCES/Mesa-3.1/include/GL
+GUI_INCLUDE   = -I$(HOME)/SOURCES/fltk
+
+RMFLAGS  = -f
+CFLAGS   = $(C_FLAGS) $(OS_FLAGS) $(VERSION_FLAGS) $(INCLUDE)\
+           $(GUI_INCLUDE) $(GL_INCLUDE)
+
+SRC = Main.cpp \
+      Message.cpp \
+      GUI.cpp\
+      Opengl.cpp\
+      Callbacks.cpp
+
+
+OBJ = $(SRC:.cpp=.o)
+
+.SUFFIXES: .o .cpp
+
+$(LIB): $(OBJ) 
+	ar ruvs $(LIB) $(OBJ) 
+	$(RANLIB) $(LIB)
+
+.cpp.o:
+	$(CC) $(CFLAGS) -c $<
+
+clean:
+	$(RM) $(RMFLAGS) *.o
+
+lint:
+	$(LINT) $(CFLAGS) $(SRC)
+
+depend:
+	(sed '/^# DO NOT DELETE THIS LINE/q' Makefile && \
+	$(CC) -MM $(CFLAGS) ${SRC} \
+	) >Makefile.new
+	cp Makefile Makefile.bak
+	cp Makefile.new Makefile
+	$(RM) $(RMFLAGS) Makefile.new
+
+# DO NOT DELETE THIS LINE
+Main.o: Main.cpp ../Common/Gmsh.h ../Common/Message.h ../DataStr/Malloc.h \
+  ../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h \
+  ../Common/GmshUI.h ../Geo/Geo.h ../Geo/Verif.h ../Mesh/Mesh.h \
+  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Edge.h \
+  ../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Graphics/Draw.h \
+  ../Common/Views.h ../Common/Const.h ../Common/ColorTable.h \
+  ../Common/Context.h ../Parser/Parser.h ../Common/Static.h \
+  ../Common/Version.h GUI.h ../Parser/OpenFile.h ../Common/GetOptions.h
+Message.o: Message.cpp ../Common/Gmsh.h ../Common/Message.h \
+  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
+  ../DataStr/avl.h ../DataStr/Tools.h ../Common/GmshUI.h \
+  ../Common/Version.h ../Common/Context.h ../Common/Const.h
+GUI.o: GUI.cpp ../Common/Gmsh.h ../Common/Message.h ../DataStr/Malloc.h \
+  ../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h \
+  ../Common/GmshUI.h ../Common/Context.h ../Common/Const.h ../Geo/Geo.h \
+  ../Mesh/Mesh.h ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Edge.h \
+  ../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Graphics/Draw.h \
+  ../Common/Views.h ../Common/ColorTable.h ../Common/Version.h GUI.h
+Opengl.o: Opengl.cpp ../Common/Gmsh.h ../Common/Message.h \
+  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
+  ../DataStr/avl.h ../DataStr/Tools.h ../Common/GmshUI.h \
+  ../Common/Context.h ../Common/Const.h ../Geo/Geo.h ../Mesh/Mesh.h \
+  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Edge.h \
+  ../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Graphics/Draw.h \
+  ../Common/Views.h ../Common/ColorTable.h GUI.h
diff --git a/Fltk/Message.cpp b/Fltk/Message.cpp
new file mode 100644
index 0000000000..1d004cee87
--- /dev/null
+++ b/Fltk/Message.cpp
@@ -0,0 +1,236 @@
+// $Id: Message.cpp,v 1.1 2001-01-08 08:16:27 geuzaine Exp $
+
+#include <signal.h>
+#include <sys/resource.h>
+
+#include "Gmsh.h"
+#include "GmshUI.h"
+#include "Version.h"
+#include "Context.h"
+
+extern Context_T   CTX;
+
+/* ------------------------------------------------------------------------ */
+/*  S i g n a l                                                             */
+/* ------------------------------------------------------------------------ */
+
+void Signal (int sig_num){
+
+  switch (sig_num){
+  case SIGSEGV : 
+    Msg(FATAL, "Segmentation Violation (Invalid Memory Reference)\n"
+        "------------------------------------------------------\n"
+        "You have discovered a bug in Gmsh. You may e-mail the\n"
+        "context in which it occurred to one of the authors:\n"
+        "type 'gmsh -info' to get feedback information"); 
+    break;
+  case SIGFPE : 
+    Msg(FATAL, "Floating Point Exception (Division by Zero?)"); 
+    break;
+  case SIGINT :
+    Msg(FATAL, "Interrupt (Generated from Terminal Special Character)"); 
+    break;
+  default :
+    Msg(FATAL, "Unknown Signal");
+    break;
+  }
+}
+
+
+/* ------------------------------------------------------------------------ */
+/*  M s g                                                                   */
+/* ------------------------------------------------------------------------ */
+
+char *TextBuffer, TextAbout[1024];
+
+#define PUT_IN_COMMAND_WIN			\
+    vfprintf(stderr, fmt, args); 		\
+    fprintf(stderr, "\n");
+
+
+void Msg(int level, char *fmt, ...){
+  va_list  args;
+  int      abort=0;
+
+  if(level != FATAL && level != ERROR && level != PARSER_ERROR &&
+     CTX.interactive && !CTX.verbosity) 
+    return ;
+
+  va_start (args, fmt);
+
+  switch(level){
+  case FATAL :
+    fprintf(stderr, FATAL_STR);
+    vfprintf(stderr, fmt, args); 
+    fprintf(stderr, "\n");
+    abort = 1; 
+    break;
+  case ERROR :
+    if(CTX.interactive || !CTX.command_win){
+      fprintf(stderr, ERROR_STR);
+      vfprintf(stderr, fmt, args); 
+      fprintf(stderr, "\n");
+    }
+    else{
+      PUT_IN_COMMAND_WIN ;
+    }
+    break;
+  case WARNING :
+    if(CTX.interactive || !CTX.command_win){
+      if(CTX.verbosity > 0){
+        fprintf(stderr, WARNING_STR);
+        vfprintf(stderr, fmt, args); 
+        fprintf(stderr, "\n");
+      }
+    }
+    else{
+      PUT_IN_COMMAND_WIN ;
+    }
+    break;
+  case INFOS :
+    if(CTX.interactive || !CTX.command_win){
+      if(CTX.verbosity > 1){
+        fprintf(stderr, INFOS_STR);
+        vfprintf(stderr, fmt, args); 
+        fprintf(stderr, "\n");
+      }
+    }
+    else{
+      PUT_IN_COMMAND_WIN ;
+    }
+    break;
+  case INFO :
+    if(CTX.interactive){
+      if(CTX.verbosity > 1){
+        fprintf(stderr, INFO_STR);
+        vfprintf(stderr, fmt, args);
+        fprintf(stderr, "\n");
+      }
+    }
+    else{
+      PUT_IN_COMMAND_WIN ;
+      /*
+      vsprintf(TextBuffer, fmt, args);
+      XtVaSetValues(WID.G.infoLabel, XmNlabelString,
+                    XmStringCreateSimple(TextBuffer), NULL);
+      XmUpdateDisplay(WID.G.infoLabel);
+      */
+    }
+    break;
+  case SELECT :
+    if(CTX.interactive){
+      if(CTX.verbosity > 1){
+        fprintf(stderr, SELECT_STR);
+        vfprintf(stderr, fmt, args); 
+        fprintf(stderr, "\n");
+      }
+    }
+    else{
+      PUT_IN_COMMAND_WIN ;
+      /*
+      vsprintf(TextBuffer, fmt, args);
+      XtVaSetValues(WID.G.selectLabel, XmNlabelString, 
+                    XmStringCreateSimple(TextBuffer), NULL);
+      XmUpdateDisplay(WID.G.selectLabel);
+      */
+    }
+    break;
+  case STATUS :
+    if(CTX.interactive){
+      if(CTX.verbosity > 1){
+        fprintf(stderr, STATUS_STR);
+        vfprintf(stderr, fmt, args);
+        fprintf(stderr, "\n");
+      }
+    }
+    else{
+      PUT_IN_COMMAND_WIN ;
+      /*
+      vsprintf(TextBuffer, fmt, args);
+      XtVaSetValues(WID.G.statusLabel, XmNlabelString,
+                    XmStringCreateSimple(TextBuffer), NULL);
+      XmUpdateDisplay(WID.G.statusLabel);
+      */
+    }
+    break;
+  case PARSER_ERROR :
+    if(CTX.interactive || !CTX.command_win){
+      if(CTX.verbosity > 0){
+        fprintf(stderr, PARSER_ERROR_STR);
+        vfprintf(stderr, fmt, args); 
+        fprintf(stderr, "\n");
+      }
+    }
+    else{
+      PUT_IN_COMMAND_WIN ;
+    }
+    break;
+  case PARSER_INFO :
+    if(CTX.interactive || !CTX.command_win){
+      if(CTX.verbosity > 1){
+        fprintf(stderr, PARSER_INFO_STR);
+        vfprintf(stderr, fmt, args); 
+        fprintf(stderr, "\n");
+      }
+    }
+    else{
+      PUT_IN_COMMAND_WIN ;
+    }
+    break;
+  case DEBUG :
+    if(CTX.interactive || !CTX.command_win){
+      if(CTX.verbosity > 2){
+        fprintf(stderr, DEBUG_STR);
+        vfprintf(stderr, fmt, args); 
+        fprintf(stderr, "\n");
+      }
+    }
+    else{
+      PUT_IN_COMMAND_WIN ;
+    }
+    break;
+  }
+
+  va_end (args);
+
+  if(abort) exit(1);
+
+}
+
+
+/* ------------------------------------------------------------------------ */
+/*  C p u                                                                   */
+/* ------------------------------------------------------------------------ */
+
+void GetResources(long *s, long *us, long *mem){
+  static struct rusage r;
+
+  getrusage(RUSAGE_SELF,&r);
+  *s   = (long)r.ru_utime.tv_sec ;
+  *us  = (long)r.ru_utime.tv_usec ;
+  *mem = (long)r.ru_maxrss ;
+}
+
+void PrintResources(FILE *stream, char *fmt, long s, long us, long mem){
+  fprintf(stream, "Resources = %scpu %ld.%ld s / mem %ld kb\n", fmt, s, us, mem);
+}
+
+double Cpu(void){
+  long s, us, mem;
+  GetResources(&s, &us, &mem);
+  return (double)s + (double)us/1.e6 ;
+}
+
+/* ------------------------------------------------------------------------ */
+/*  P r o g r e s s                                                         */
+/* ------------------------------------------------------------------------ */
+
+void Progress(int i){
+}
+
+/* ------------------------------------------------------------------------ */
+/*  E d i t G e o m e t r y                                                 */
+/* ------------------------------------------------------------------------ */
+
+void AddALineInTheEditGeometryForm (char* line){
+}
diff --git a/Fltk/Opengl.cpp b/Fltk/Opengl.cpp
new file mode 100644
index 0000000000..01c0ae2db8
--- /dev/null
+++ b/Fltk/Opengl.cpp
@@ -0,0 +1,470 @@
+// $Id: Opengl.cpp,v 1.1 2001-01-08 08:16:27 geuzaine Exp $
+
+#include "Gmsh.h"
+#include "GmshUI.h"
+#include "Context.h"
+#include "Const.h"
+#include "Geo.h"
+#include "Mesh.h"
+#include "Draw.h"
+#include "GUI.h"
+
+extern GUI *WID;
+extern Mesh M;
+extern Context_T CTX;
+
+void Process_SelectionBuffer(int x, int y, int *n, GLuint *ii, GLuint *jj);
+void Filter_SelectionBuffer(int n, GLuint *typ, GLuint *ient, Vertex **thev,
+                            Curve **thec, Surface **thes, Mesh *m);
+void myZoom(GLdouble X1, GLdouble X2, GLdouble Y1, GLdouble Y2,
+            GLdouble Xc1, GLdouble Xc2, GLdouble Yc1, GLdouble Yc2);
+
+/* ------------------------------------------------------------------------ */
+/*  Init/Draw                                                               */
+/* ------------------------------------------------------------------------ */
+
+void Init(void){
+}
+
+void InitOverlay(void){
+}
+
+void Draw(void){
+  WID->set_size(CTX.viewport[2]-CTX.viewport[0],
+	       CTX.viewport[3]-CTX.viewport[1]);
+  WID->draw_gl();
+}
+
+void DrawOverlay(void){
+  WID->draw_gl_overlay();
+}
+
+void DrawUI(void){
+  WID->check();
+}
+
+
+/* ------------------------------------------------------------------------ 
+    set_XXX
+   ------------------------------------------------------------------------ */
+
+void set_r(int i, double val){
+  if(!CTX.useTrackball){
+    if(!CTX.rlock[i]){
+      CTX.r[i] = val;
+    }
+  }
+}
+
+void set_t(int i, double val){
+  if(!CTX.tlock[i]){
+    CTX.t[i] = val;
+  }
+}
+
+void set_s(int i, double val){
+  if(!CTX.slock[i]){
+    CTX.s[i] = val;
+  }
+}
+
+
+/* ------------------------------------------------------------------------ */
+/*  SelectEntity                                                            */
+/* ------------------------------------------------------------------------ */
+
+int check_type(int type, Vertex *v, Curve *c, Surface *s){
+  return ( (type==ENT_POINT   && v) ||
+           (type==ENT_LINE    && c) ||
+           (type==ENT_SURFACE && s) ) ;
+}
+
+int SelectEntity(int type, Vertex **v, Curve **c, Surface **s){
+  int             hits;
+  GLuint          ii[SELECTION_BUFFER_SIZE],jj[SELECTION_BUFFER_SIZE];
+  int event;
+
+  *v = NULL; *c = NULL; *s = NULL;
+
+  printf("select entity...\n");
+
+  while(1){
+    Fl::check();
+    if((event = Fl::event_key())){
+      if(event == 'q') return(0);
+      if(event == 'e') return(-1);
+    }
+    if(Fl::event_is_click()){
+      Process_SelectionBuffer(Fl::event_x(), Fl::event_y(), &hits, ii, jj);
+      Filter_SelectionBuffer(hits,ii,jj,v,c,s,&M);
+      if(check_type(type,*v,*c,*s)){
+        BeginHighlight();
+        HighlightEntity(*v,*c,*s,1);
+        EndHighlight(1);
+        return(Fl::event_button());
+      }
+    }
+  }
+
+}
+
+
+/* ------------------------------------------------------------------------ */
+/*  The OpenGL Widget                                                       */
+/* ------------------------------------------------------------------------ */
+
+void Opengl_Window::draw() {
+  if (!valid()) {
+    valid(1);
+    CTX.viewport[0] = 0 ;
+    CTX.viewport[1] = 0 ;
+    CTX.viewport[2] = w() ;
+    CTX.viewport[3] = h() ;
+    glViewport(CTX.viewport[0],
+	       CTX.viewport[1],
+	       CTX.viewport[2],
+	       CTX.viewport[3]);
+  }
+  Orthogonalize(0,0);
+  glClearColor(UNPACK_RED(CTX.color.bg)/255.,
+               UNPACK_GREEN(CTX.color.bg)/255.,
+               UNPACK_BLUE(CTX.color.bg)/255.,
+               0.);
+  glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
+  Draw3d();
+  Draw2d();
+}
+
+void Opengl_Window::clear_overlay() {
+  if(CTX.overlay) {}
+}
+
+void Opengl_Window::draw_overlay_zoom() {
+  /*
+  if (!valid()) {
+    valid(1);
+    CTX.viewport[0] = 0 ;
+    CTX.viewport[1] = 0 ;
+    CTX.viewport[2] = w() ;
+    CTX.viewport[3] = h() ;
+    glViewport(CTX.viewport[0],
+	       CTX.viewport[1],
+	       CTX.viewport[2],
+	       CTX.viewport[3]);
+  }
+  Orthogonalize(0,0);
+  glClearIndex(0);
+  glClear(GL_COLOR_BUFFER_BIT);  
+
+  glLineWidth(1.);
+  glClearIndex(0);
+  glClear(GL_COLOR_BUFFER_BIT);  
+  glIndexi((CTX.color.bg<CTX.color.fg)?FL_WHITE:FL_BLACK);
+  glBegin(GL_LINE_STRIP);
+  glVertex2d(xb,yb);
+  glVertex2d(xb+movzx,yb);
+  glVertex2d(xb+movzx,yb+movzy);
+  glVertex2d(xb,yb+movzy);
+  glVertex2d(xb,yb);
+  glEnd();
+  */
+}
+
+void Opengl_Window::draw_overlay_highlight(){
+  /*
+  if(CTX.overlay){
+    glXMakeCurrent(XtDisplay(WID.G.glo), XtWindow(WID.G.glo), XCTX.glo.context);
+    if(ov != v || oc != c || os != s) { 
+      glClearIndex(0);
+      glClear(GL_COLOR_BUFFER_BIT);  
+      glIndexi((CTX.color.bg<CTX.color.fg)?XCTX.xcolor.ovwhite:XCTX.xcolor.ovblack);
+      BeginHighlight();
+      HighlightEntity(v,c,s,0);
+      EndHighlight(0);
+    }
+    glXMakeCurrent(XtDisplay(WID.G.glw), XtWindow(WID.G.glw), XCTX.glw.context);
+  }
+  else{
+    if(ov != v || oc != c || os != s) { 
+      if(CTX.geom.highlight){
+	Init();
+	Draw();
+      }
+      BeginHighlight();
+      HighlightEntity(v,c,s,0);
+      EndHighlight(0);
+    }
+  }
+  */
+}
+
+void Opengl_Window::draw_overlay() {
+}
+
+
+static int Modifier=0;
+
+int Opengl_Window::handle(int event) {
+  GLuint          ii[SELECTION_BUFFER_SIZE], jj[SELECTION_BUFFER_SIZE];
+  int             previous_mesh_draw, previous_post_draw ;
+  int             width, height ;
+
+  static int      ibut, hits;
+  static int      ButtonPressed=0, ZoomClick=0, FirstClick=0;
+  static int      x, y, movx, movy;
+  static GLdouble xc1, yc1, xc2, yc2, xt1, yt1, xscale1, yscale1;
+  static GLdouble xb, yb, xc, yc, xe, ye, xz, yz;
+  static GLdouble movzx, movzy;
+  static Vertex   *v=NULL, *ov;
+  static Curve    *c=NULL, *oc;
+  static Surface  *s=NULL, *os;
+  
+  width  = w() ;
+  height = h() ;
+
+  switch (event) {
+
+  /* -------------------------------------------------------------
+     K e y s 
+     ------------------------------------------------------------- */
+
+  case FL_SHORTCUT:
+    /*
+    m = menu->test_shortcut();
+    if (m) {m->do_callback(this, (void*)m); return 1;}
+    */
+    return 0;
+
+  case FL_ENTER :
+  case FL_LEAVE :
+    ButtonPressed = 0;
+    Modifier = 0;
+    return Fl_Gl_Window::handle(event);
+    
+  case FL_FOCUS:
+    return 1;
+
+  case FL_UNFOCUS:
+    return 1;
+
+  case FL_KEYBOARD:
+    
+    switch(Fl::event_key()){
+    case FL_Control_L : case FL_Control_R : 
+      printf("got a ctrl\n");
+      Modifier = 1; 
+      return 1;
+    case FL_Alt_L : case FL_Alt_R : 
+    case FL_Meta_L : case FL_Meta_R : 
+      Modifier = 2; 
+      return 1;
+    default:
+      return Fl_Gl_Window::handle(event);
+    }
+    break;
+    
+  /* -------------------------------------------------------------
+     B u t t o n P r e s s
+     ------------------------------------------------------------- */
+
+  case FL_PUSH:
+
+    ButtonPressed++;
+    FirstClick=1;
+    ibut = Fl::event_button();
+    x    = Fl::event_x();
+    y    = Fl::event_y();
+
+    switch(ibut){
+    case 1:
+      if(!ZoomClick && Modifier){
+        xb = CTX.vxmin + ((GLdouble) x / width) * (CTX.vxmax - CTX.vxmin);
+        yb = CTX.vymax - ((GLdouble) y / height) * (CTX.vymax - CTX.vymin);
+        xc1 = xb/CTX.s[0] - CTX.t[0];
+        yc1 = yb/CTX.s[1] - CTX.t[1];
+        ZoomClick=1;
+        Modifier = 0;
+      }
+      else if(ZoomClick){
+        xe = CTX.vxmin + ((GLdouble) x / width) * (CTX.vxmax - CTX.vxmin);
+        ye = CTX.vymax - ((GLdouble) y / height) * (CTX.vymax - CTX.vymin);
+        xc2 = xe/CTX.s[0] - CTX.t[0];
+        yc2 = ye/CTX.s[1] - CTX.t[1];     
+        ZoomClick=0;
+        clear_overlay();
+        if(xb!=xe && yb!=ye) myZoom(xb,xe,yb,ye,xc1,xc2,yc1,yc2);
+      } 
+      break;
+    case 2:
+      if(Modifier && !ZoomClick){
+        Modifier = 0;
+        set_s(1, CTX.s[0]);
+        set_s(2, CTX.s[0]);
+        Init();
+        Draw();
+      }
+      else{
+        ZoomClick=0;
+        clear_overlay();
+      }
+      break;      
+    case 3:
+      if(Modifier && !ZoomClick){
+        Modifier = 0;
+	if(CTX.useTrackball){
+	  CTX.setQuaternion(0.,0.,0.,1.);
+	}
+	else{
+	  set_r(0,0.); set_r(1,0.); set_r(2,0.); 
+	}
+        set_t(0,0.); set_t(1,0.); set_t(2,0.);
+        set_s(0,1.); set_s(1,1.); set_s(2,1.);
+        Init();
+        Draw();
+      }
+      else{
+        ZoomClick=0;
+        clear_overlay();
+      }
+      break;
+    }
+
+    return 1;
+
+  /* -------------------------------------------------------------
+      B u t t o n R e l e a s e
+     ------------------------------------------------------------- */
+
+  case FL_RELEASE:
+
+    if(ButtonPressed>0){
+      ButtonPressed--;
+      ibut = Fl::event_button();
+      x    = Fl::event_x();
+      y    = Fl::event_y();
+    }
+    if(!ZoomClick){
+      Init();
+      previous_mesh_draw = CTX.mesh.draw ;
+      previous_post_draw = CTX.post.draw ;
+      if(ButtonPressed>0){
+        if(CTX.fast) CTX.mesh.draw = CTX.post.draw = 0;
+      }
+      Draw();
+      CTX.mesh.draw = previous_mesh_draw ;
+      CTX.post.draw = previous_post_draw ;
+    }
+
+    return 1;
+
+      
+  /* -------------------------------------------------------------
+      M o t i o n N o t i f y 
+     ------------------------------------------------------------- */
+
+  case FL_DRAG:
+
+    movx = Fl::event_x()-x;
+    movy = Fl::event_y()-y;
+
+    if(ZoomClick) {
+      printf("should draw the zoom... %d %d %d %d\n", x, y, movx, movy);
+
+      xz = CTX.vxmin + ((GLdouble) Fl::event_x() / width) *
+	(CTX.vxmax - CTX.vxmin);
+      yz = CTX.vymax - ((GLdouble) Fl::event_y() / height) * 
+	(CTX.vymax - CTX.vymin) ;
+
+      movzx = xz - xb; movzy = yz - yb;
+      draw_overlay();
+    }
+    else {
+      if(ButtonPressed){
+
+	clear_overlay();
+
+        if(FirstClick){
+          xc1 = ( ((GLdouble) x / width) * (CTX.vxmax - CTX.vxmin) 
+		  + CTX.vxmin )/CTX.s[0] - CTX.t[0];
+          yc1 = ( CTX.vymax - ((GLdouble) y / height) * 
+		  (CTX.vymax - CTX.vymin))/CTX.s[1] - CTX.t[1];
+          xt1 = CTX.t[0];
+          yt1 = CTX.t[1];
+          xscale1 = CTX.s[0];
+          yscale1 = CTX.s[1];
+          FirstClick=0;
+        }
+
+        switch(ibut){
+        case 1:
+	  
+	  if(CTX.useTrackball){
+	    CTX.addQuaternion ((2.0*x - width) / width,
+			       (height - 2.0*y) / height,
+			       (2.0*Fl::event_x() - width) / width,
+			       (height - 2.0*Fl::event_y()) / height);
+	  }
+	  else{
+	    set_r(1, CTX.r[1] + ((abs(movx) > abs(movy))?180*(float)movx/(float)width:0));
+	    set_r(0, CTX.r[0] + ((abs(movx) > abs(movy))?0:180*(float)movy/(float)height));
+	  }
+          break;
+        case 2:
+	  if(!CTX.useTrackball)
+	    set_r(2, CTX.r[2] + ((abs(movy) > abs(movx))?0:-180*(float)movx/(float)width));         
+
+          set_s(0, CTX.s[0] * ( (abs(movy) > abs(movx)) ?
+                                ( (movy>0) ? (float)(1.04*(abs(movy)+height))/(float)height
+                                  : (float)(height)/(float)(1.04*(abs(movy)+height)) )
+                                : 1.) );                    
+          set_s(1, CTX.s[0]);
+          set_s(2, CTX.s[0]);
+
+          if(abs(movy) > abs(movx)){
+            set_t(0, xt1*(xscale1/CTX.s[0])-xc1*(1.-(xscale1/CTX.s[0])));
+            set_t(1, yt1*(yscale1/CTX.s[1])-yc1*(1.-(yscale1/CTX.s[1])));
+          }
+          break;
+        case 3:
+          xc = ( ((GLdouble) x / width) * (CTX.vxmax - CTX.vxmin) + 
+		 CTX.vxmin ) / CTX.s[0];
+          yc = ( CTX.vymax - ((GLdouble) y / height) *
+		 (CTX.vymax - CTX.vymin)) / CTX.s[1];
+          set_t(0, xc-xc1);
+          set_t(1, yc-yc1);
+          set_t(2, 0.);
+          break;
+        }
+        Init();
+        previous_mesh_draw = CTX.mesh.draw ;
+        previous_post_draw = CTX.post.draw ;
+        if(CTX.fast) CTX.mesh.draw = CTX.post.draw = 0;
+        Draw();
+        CTX.mesh.draw = previous_mesh_draw ;
+        CTX.post.draw = previous_post_draw ;
+      }
+      else{
+        Process_SelectionBuffer(Fl::event_x(), Fl::event_y(), &hits, ii, jj);
+        ov = v; oc = c; os = s; 
+        v = NULL; c = NULL; s = NULL;
+        Filter_SelectionBuffer(hits,ii,jj,&v,&c,&s,&M);
+	draw_overlay_highlight();
+      }
+      x += movx; 
+      y += movy; 
+    }
+
+    return 1;
+
+  /* -------------------------------------------------------------
+      O t h er
+     ------------------------------------------------------------- */
+
+  default:
+    // pass other events to the base class...
+    return Fl_Gl_Window::handle(event);
+
+  }
+
+}
+
diff --git a/Unix/Bitmaps.h b/Motif/Bitmaps.h
similarity index 100%
rename from Unix/Bitmaps.h
rename to Motif/Bitmaps.h
diff --git a/Unix/CbColorbar.cpp b/Motif/CbColorbar.cpp
similarity index 99%
rename from Unix/CbColorbar.cpp
rename to Motif/CbColorbar.cpp
index 295f28ddba..419959e81e 100644
--- a/Unix/CbColorbar.cpp
+++ b/Motif/CbColorbar.cpp
@@ -1,4 +1,4 @@
-// $Id: CbColorbar.cpp,v 1.5 2001-01-08 08:03:39 geuzaine Exp $
+// $Id: CbColorbar.cpp,v 1.1 2001-01-08 08:20:10 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
diff --git a/Unix/CbColorbar.h b/Motif/CbColorbar.h
similarity index 100%
rename from Unix/CbColorbar.h
rename to Motif/CbColorbar.h
diff --git a/Unix/CbContext.cpp b/Motif/CbContext.cpp
similarity index 99%
rename from Unix/CbContext.cpp
rename to Motif/CbContext.cpp
index 6282a17f02..1a45bb01a5 100644
--- a/Unix/CbContext.cpp
+++ b/Motif/CbContext.cpp
@@ -1,4 +1,4 @@
-// $Id: CbContext.cpp,v 1.10 2001-01-08 08:03:39 geuzaine Exp $
+// $Id: CbContext.cpp,v 1.1 2001-01-08 08:20:10 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
diff --git a/Unix/CbContext.h b/Motif/CbContext.h
similarity index 100%
rename from Unix/CbContext.h
rename to Motif/CbContext.h
diff --git a/Unix/CbFile.cpp b/Motif/CbFile.cpp
similarity index 96%
rename from Unix/CbFile.cpp
rename to Motif/CbFile.cpp
index af63c3a614..09fcb7ca77 100644
--- a/Unix/CbFile.cpp
+++ b/Motif/CbFile.cpp
@@ -1,4 +1,4 @@
-// $Id: CbFile.cpp,v 1.21 2001-01-08 08:03:40 geuzaine Exp $
+// $Id: CbFile.cpp,v 1.1 2001-01-08 08:20:10 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
diff --git a/Unix/CbFile.h b/Motif/CbFile.h
similarity index 100%
rename from Unix/CbFile.h
rename to Motif/CbFile.h
diff --git a/Unix/CbGeneral.cpp b/Motif/CbGeneral.cpp
similarity index 99%
rename from Unix/CbGeneral.cpp
rename to Motif/CbGeneral.cpp
index 94b3ea785a..4279056292 100644
--- a/Unix/CbGeneral.cpp
+++ b/Motif/CbGeneral.cpp
@@ -1,4 +1,4 @@
-// $Id: CbGeneral.cpp,v 1.7 2001-01-08 08:03:40 geuzaine Exp $
+// $Id: CbGeneral.cpp,v 1.1 2001-01-08 08:20:10 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
diff --git a/Unix/CbGeneral.h b/Motif/CbGeneral.h
similarity index 100%
rename from Unix/CbGeneral.h
rename to Motif/CbGeneral.h
diff --git a/Unix/CbGeom.cpp b/Motif/CbGeom.cpp
similarity index 99%
rename from Unix/CbGeom.cpp
rename to Motif/CbGeom.cpp
index 98332e2bb0..1419fc277a 100644
--- a/Unix/CbGeom.cpp
+++ b/Motif/CbGeom.cpp
@@ -1,4 +1,4 @@
-// $Id: CbGeom.cpp,v 1.11 2001-01-08 08:03:40 geuzaine Exp $
+// $Id: CbGeom.cpp,v 1.1 2001-01-08 08:20:10 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
diff --git a/Unix/CbGeom.h b/Motif/CbGeom.h
similarity index 100%
rename from Unix/CbGeom.h
rename to Motif/CbGeom.h
diff --git a/Unix/CbInput.cpp b/Motif/CbInput.cpp
similarity index 99%
rename from Unix/CbInput.cpp
rename to Motif/CbInput.cpp
index b21d052cc9..f165a76cc6 100644
--- a/Unix/CbInput.cpp
+++ b/Motif/CbInput.cpp
@@ -1,4 +1,4 @@
-// $Id: CbInput.cpp,v 1.16 2001-01-08 08:03:40 geuzaine Exp $
+// $Id: CbInput.cpp,v 1.1 2001-01-08 08:20:10 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
diff --git a/Unix/CbMesh.cpp b/Motif/CbMesh.cpp
similarity index 99%
rename from Unix/CbMesh.cpp
rename to Motif/CbMesh.cpp
index 337b0c53fa..c0ca0fa6d0 100644
--- a/Unix/CbMesh.cpp
+++ b/Motif/CbMesh.cpp
@@ -1,4 +1,4 @@
-// $Id: CbMesh.cpp,v 1.6 2001-01-08 08:03:40 geuzaine Exp $
+// $Id: CbMesh.cpp,v 1.1 2001-01-08 08:20:10 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
diff --git a/Unix/CbMesh.h b/Motif/CbMesh.h
similarity index 100%
rename from Unix/CbMesh.h
rename to Motif/CbMesh.h
diff --git a/Unix/CbOptions.cpp b/Motif/CbOptions.cpp
similarity index 99%
rename from Unix/CbOptions.cpp
rename to Motif/CbOptions.cpp
index 1e65db005b..a9f3acaefb 100644
--- a/Unix/CbOptions.cpp
+++ b/Motif/CbOptions.cpp
@@ -1,4 +1,4 @@
-// $Id: CbOptions.cpp,v 1.20 2001-01-08 08:03:40 geuzaine Exp $
+// $Id: CbOptions.cpp,v 1.1 2001-01-08 08:20:10 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
diff --git a/Unix/CbOptions.h b/Motif/CbOptions.h
similarity index 100%
rename from Unix/CbOptions.h
rename to Motif/CbOptions.h
diff --git a/Unix/CbPost.cpp b/Motif/CbPost.cpp
similarity index 99%
rename from Unix/CbPost.cpp
rename to Motif/CbPost.cpp
index 3c5436b302..52f166b151 100644
--- a/Unix/CbPost.cpp
+++ b/Motif/CbPost.cpp
@@ -1,4 +1,4 @@
-// $Id: CbPost.cpp,v 1.11 2001-01-08 08:03:40 geuzaine Exp $
+// $Id: CbPost.cpp,v 1.1 2001-01-08 08:20:10 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
diff --git a/Unix/CbPost.h b/Motif/CbPost.h
similarity index 100%
rename from Unix/CbPost.h
rename to Motif/CbPost.h
diff --git a/Unix/Geometry.cpp b/Motif/Geometry.cpp
similarity index 99%
rename from Unix/Geometry.cpp
rename to Motif/Geometry.cpp
index 228a9c19eb..45a436971b 100644
--- a/Unix/Geometry.cpp
+++ b/Motif/Geometry.cpp
@@ -1,4 +1,4 @@
-// $Id: Geometry.cpp,v 1.9 2001-01-08 08:03:40 geuzaine Exp $
+// $Id: Geometry.cpp,v 1.1 2001-01-08 08:20:10 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
diff --git a/Unix/Geometry.h b/Motif/Geometry.h
similarity index 100%
rename from Unix/Geometry.h
rename to Motif/Geometry.h
diff --git a/Unix/Help.h b/Motif/Help.h
similarity index 100%
rename from Unix/Help.h
rename to Motif/Help.h
diff --git a/Unix/Info.h b/Motif/Info.h
similarity index 100%
rename from Unix/Info.h
rename to Motif/Info.h
diff --git a/Unix/Main.cpp b/Motif/Main.cpp
similarity index 99%
rename from Unix/Main.cpp
rename to Motif/Main.cpp
index 109c66055b..a6a6278080 100644
--- a/Unix/Main.cpp
+++ b/Motif/Main.cpp
@@ -1,4 +1,4 @@
-// $Id: Main.cpp,v 1.35 2001-01-08 08:03:40 geuzaine Exp $
+// $Id: Main.cpp,v 1.1 2001-01-08 08:20:11 geuzaine Exp $
 
 #include <signal.h>
 
diff --git a/Unix/Makefile b/Motif/Makefile
similarity index 99%
rename from Unix/Makefile
rename to Motif/Makefile
index 8b5e4717cf..8bc2405b8f 100644
--- a/Unix/Makefile
+++ b/Motif/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.7 2001-01-08 08:03:40 geuzaine Exp $
+# $Id: Makefile,v 1.1 2001-01-08 08:20:11 geuzaine Exp $
 #
 # Makefile for "libMotif.a"
 #
diff --git a/Unix/Message.cpp b/Motif/Message.cpp
similarity index 99%
rename from Unix/Message.cpp
rename to Motif/Message.cpp
index 85fb171efe..66263d52b2 100644
--- a/Unix/Message.cpp
+++ b/Motif/Message.cpp
@@ -1,4 +1,4 @@
-// $Id: Message.cpp,v 1.7 2001-01-08 08:03:40 geuzaine Exp $
+// $Id: Message.cpp,v 1.1 2001-01-08 08:20:11 geuzaine Exp $
 
 #include <signal.h>
 #include <sys/resource.h>
diff --git a/Motif/Opengl.cpp b/Motif/Opengl.cpp
new file mode 100644
index 0000000000..0adf331944
--- /dev/null
+++ b/Motif/Opengl.cpp
@@ -0,0 +1,159 @@
+// $Id: Opengl.cpp,v 1.1 2001-01-08 08:20:11 geuzaine Exp $
+
+#include <X11/IntrinsicP.h>
+
+#include "Gmsh.h"
+#include "GmshUI.h"
+#include "Geo.h"
+#include "Mesh.h"
+#include "Draw.h"
+#include "Context.h"
+#include "MinMax.h"
+#include "Widgets.h"
+#include "XContext.h"
+
+extern XContext_T   XCTX ;
+extern Widgets_T    WID ;
+extern Context_T    CTX ;
+extern Mesh         M;
+
+void Process_SelectionBuffer(int x, int y, int *n, GLuint *ii, GLuint *jj);
+void Filter_SelectionBuffer(int n, GLuint *typ, GLuint *ient, Vertex **thev,
+                            Curve **thec, Surface **thes, Mesh *m);
+void myZoom(GLdouble X1, GLdouble X2, GLdouble Y1, GLdouble Y2,
+            GLdouble Xc1, GLdouble Xc2, GLdouble Yc1, GLdouble Yc2);
+
+/* ------------------------------------------------------------------------ */
+/*  Init/Draw                                                               */
+/* ------------------------------------------------------------------------ */
+
+void Init(void){
+
+  /* Resize Graphical Window if told to do it */
+  XWindowAttributes  xattrib;
+  XGetWindowAttributes(XtDisplay(WID.G.bottomForm),XtWindow(WID.G.bottomForm),&xattrib);
+  XtResizeWidget(WID.G.shell,
+		 CTX.viewport[2]-CTX.viewport[0],
+		 xattrib.height+CTX.viewport[3]-CTX.viewport[1],
+		 0);
+
+  /* X11 forbids to change the context (GLX) in GL_FEEDBACK or GL_SELECT mode,
+     which would happen for postscript output */
+  if(CTX.stream == TO_SCREEN)
+    glXMakeCurrent(XtDisplay(WID.G.glw), XtWindow(WID.G.glw), XCTX.glw.context);
+
+  Orthogonalize(0,0);
+}
+
+void InitOverlay(void){
+  glXMakeCurrent(XtDisplay(WID.G.glo), XtWindow(WID.G.glo), XCTX.glo.context);
+  Orthogonalize(0,0);
+}
+
+void Draw(void){
+  glClearColor(UNPACK_RED(CTX.color.bg)/255.,
+               UNPACK_GREEN(CTX.color.bg)/255.,
+               UNPACK_BLUE(CTX.color.bg)/255.,
+               0.);
+  glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
+  if(CTX.db) glDrawBuffer(GL_BACK);    
+  Draw3d();
+  Draw2d();
+  glFlush();
+  if(CTX.db) glXSwapBuffers(XCTX.display,XtWindow(WID.G.glw));
+}
+
+void DrawOverlay(void){
+}
+
+void DrawUI(void){
+}
+
+/* ------------------------------------------------------------------------ */
+/*  SelectEntity                                                            */
+/* ------------------------------------------------------------------------ */
+
+
+int check_type(int type, Vertex *v, Curve *c, Surface *s){
+  return ( (type==ENT_POINT   && v) ||
+           (type==ENT_LINE    && c) ||
+           (type==ENT_SURFACE && s) ) ;
+}
+
+int SelectEntity(int type, Vertex **v, Curve **c, Surface **s){
+  XEvent          event;
+  XComposeStatus  stat;
+  KeySym          keysym;
+  int             hits;
+  GLuint          ii[SELECTION_BUFFER_SIZE],jj[SELECTION_BUFFER_SIZE];
+  char            buf[100];
+
+  *v = NULL;
+  *c = NULL; 
+  *s = NULL;
+
+  while(1){
+    XtAppNextEvent(XCTX.AppContext,&event);
+    XtDispatchEvent(&event);
+    switch(event.type){
+    case KeyPress :
+      XLookupString(&event.xkey, buf, sizeof(buf), &keysym, &stat);
+      if(keysym == XK_q) return(0);
+      if(keysym == XK_e) return(-1);
+      break;
+    case ButtonPress :
+      Process_SelectionBuffer(event.xbutton.x, event.xbutton.y, &hits, ii, jj);
+      Filter_SelectionBuffer(hits,ii,jj,v,c,s,&M);
+      if(check_type(type,*v,*c,*s)){
+        BeginHighlight();
+        HighlightEntity(*v,*c,*s,1);
+        EndHighlight(1);
+        return(event.xbutton.button);
+      }
+    }
+  }
+}
+
+/* ------------------------------------------------------------------------ */
+/*  Callbacks                                                               */
+/* ------------------------------------------------------------------------ */
+
+void InitCb(Widget w, XtPointer client_data, GLwDrawingAreaCallbackStruct *cb){
+  glXMakeCurrent(XtDisplay(WID.G.glw), XtWindow(WID.G.glw), XCTX.glw.context);
+  CTX.viewport[0] = 0 ;
+  CTX.viewport[1] = 0 ;
+  CTX.viewport[2] = cb->width ;
+  CTX.viewport[3] = cb->height ;
+  glViewport(CTX.viewport[0],
+             CTX.viewport[1],
+             CTX.viewport[2],
+             CTX.viewport[3]);
+}
+
+void ResizeCb(Widget w,XtPointer client_data, GLwDrawingAreaCallbackStruct *cb){
+  CTX.viewport[0] = 0 ;
+  CTX.viewport[1] = 0 ;
+  CTX.viewport[2] = cb->width ;
+  CTX.viewport[3] = cb->height ;
+  glViewport(CTX.viewport[0],
+             CTX.viewport[1],
+             CTX.viewport[2],
+             CTX.viewport[3]);
+  Init();
+  Draw();
+  if(CTX.overlay) InitOverlay();
+}
+
+void ExposeCb(Widget w,XtPointer client_data, GLwDrawingAreaCallbackStruct *cb){
+
+  /* compress incoming events as much as possible */
+  if(cb->event->xexpose.count != 0){
+    return;
+  }
+
+  if(!CTX.expose) return;
+  Init();
+  Draw(); 
+
+}
+
diff --git a/Unix/Pixmaps.cpp b/Motif/Pixmaps.cpp
similarity index 98%
rename from Unix/Pixmaps.cpp
rename to Motif/Pixmaps.cpp
index 538497a478..882e0714b1 100644
--- a/Unix/Pixmaps.cpp
+++ b/Motif/Pixmaps.cpp
@@ -1,4 +1,4 @@
-// $Id: Pixmaps.cpp,v 1.4 2001-01-08 08:03:40 geuzaine Exp $
+// $Id: Pixmaps.cpp,v 1.1 2001-01-08 08:20:11 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
diff --git a/Unix/Pixmaps.h b/Motif/Pixmaps.h
similarity index 100%
rename from Unix/Pixmaps.h
rename to Motif/Pixmaps.h
diff --git a/Unix/Register.cpp b/Motif/Register.cpp
similarity index 99%
rename from Unix/Register.cpp
rename to Motif/Register.cpp
index bf4a49455d..0c816d344b 100644
--- a/Unix/Register.cpp
+++ b/Motif/Register.cpp
@@ -1,4 +1,4 @@
-// $Id: Register.cpp,v 1.20 2001-01-08 08:03:40 geuzaine Exp $
+// $Id: Register.cpp,v 1.1 2001-01-08 08:20:11 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
diff --git a/Unix/Register.h b/Motif/Register.h
similarity index 100%
rename from Unix/Register.h
rename to Motif/Register.h
diff --git a/Unix/Widgets.cpp b/Motif/Widgets.cpp
similarity index 99%
rename from Unix/Widgets.cpp
rename to Motif/Widgets.cpp
index d475328422..be888863b2 100644
--- a/Unix/Widgets.cpp
+++ b/Motif/Widgets.cpp
@@ -1,4 +1,4 @@
-// $Id: Widgets.cpp,v 1.29 2001-01-08 08:03:41 geuzaine Exp $
+// $Id: Widgets.cpp,v 1.1 2001-01-08 08:20:11 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
diff --git a/Unix/Widgets.h b/Motif/Widgets.h
similarity index 100%
rename from Unix/Widgets.h
rename to Motif/Widgets.h
diff --git a/Unix/XColors.cpp b/Motif/XColors.cpp
similarity index 99%
rename from Unix/XColors.cpp
rename to Motif/XColors.cpp
index 5268e9cc28..ccc82d9508 100644
--- a/Unix/XColors.cpp
+++ b/Motif/XColors.cpp
@@ -1,4 +1,4 @@
-// $Id: XColors.cpp,v 1.5 2001-01-08 08:03:41 geuzaine Exp $
+// $Id: XColors.cpp,v 1.1 2001-01-08 08:20:11 geuzaine Exp $
 
 /*
   Attention. Toutes les couleurs sont crees a partir de la colormap de
diff --git a/Unix/XColors.h b/Motif/XColors.h
similarity index 100%
rename from Unix/XColors.h
rename to Motif/XColors.h
diff --git a/Unix/XContext.h b/Motif/XContext.h
similarity index 100%
rename from Unix/XContext.h
rename to Motif/XContext.h
diff --git a/Unix/XCursor.cpp b/Motif/XCursor.cpp
similarity index 96%
rename from Unix/XCursor.cpp
rename to Motif/XCursor.cpp
index e7033dc20c..e138d6f84b 100644
--- a/Unix/XCursor.cpp
+++ b/Motif/XCursor.cpp
@@ -1,4 +1,4 @@
-// $Id: XCursor.cpp,v 1.3 2001-01-08 08:03:41 geuzaine Exp $
+// $Id: XCursor.cpp,v 1.1 2001-01-08 08:20:11 geuzaine Exp $
 
 #include <X11/cursorfont.h>
 
diff --git a/Unix/XRessources.h b/Motif/XRessources.h
similarity index 100%
rename from Unix/XRessources.h
rename to Motif/XRessources.h
diff --git a/Unix/XStatic.h b/Motif/XStatic.h
similarity index 100%
rename from Unix/XStatic.h
rename to Motif/XStatic.h
diff --git a/Unix/Main.h b/Unix/Main.h
deleted file mode 100644
index 3c81eae6f8..0000000000
--- a/Unix/Main.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/* $Id: Main.h,v 1.2 2000-11-23 14:11:41 geuzaine Exp $ */
-#ifndef _MAIN_H_
-#define _MAIN_H_
-
-#include "Const.h"
-
-void OpenProblem(char *name);
-void MergeProblem(char *name);
-
-extern char TheFileName[NAME_STR_L], TheBaseFileName[NAME_STR_L];
-
-#endif
-- 
GitLab