From 05b5ec2d05f1dc2ce31e636ef6f7e58108c6fa92 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Tue, 12 Jun 2007 07:04:08 +0000
Subject: [PATCH] fix side effects from new font size computation

---
 Fltk/Colorbar_Window.cpp |  4 +--
 Fltk/GUI.cpp             | 31 ++++++++++++----------
 Fltk/GUI.h               |  1 +
 Fltk/GUI_Extras.cpp      | 55 ++++++++++++++++++++--------------------
 Fltk/GUI_Projection.cpp  |  9 +++----
 5 files changed, 51 insertions(+), 49 deletions(-)

diff --git a/Fltk/Colorbar_Window.cpp b/Fltk/Colorbar_Window.cpp
index ac75fb89cd..20167e25ce 100644
--- a/Fltk/Colorbar_Window.cpp
+++ b/Fltk/Colorbar_Window.cpp
@@ -1,4 +1,4 @@
-// $Id: Colorbar_Window.cpp,v 1.57 2006-11-27 22:22:09 geuzaine Exp $
+// $Id: Colorbar_Window.cpp,v 1.58 2007-06-12 07:04:08 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -45,7 +45,7 @@ Colorbar_Window::Colorbar_Window(int x, int y, int w, int h, const char *l)
   ct = NULL;
   label = NULL;
   help_flag = 1;
-  font_height = CTX.fontsize;
+  font_height = GetFontSize();
   marker_height = font_height;
   wedge_height = marker_height;
   marker_pos = 0;
diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp
index 02e7ef2ffb..dfc60a826e 100644
--- a/Fltk/GUI.cpp
+++ b/Fltk/GUI.cpp
@@ -1,4 +1,4 @@
-// $Id: GUI.cpp,v 1.622 2007-06-06 07:27:35 geuzaine Exp $
+// $Id: GUI.cpp,v 1.623 2007-06-12 07:04:08 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -452,6 +452,22 @@ int GetFontAlign(char *alignstr)
   return 0;
 }
 
+int GetFontSize()
+{
+  if(CTX.fontsize > 0){
+    return CTX.fontsize;
+  }
+  else{
+    int x, y, w, h;
+    Fl::screen_xywh(x, y, w, h);
+    if(w <= 860)       return 11;
+    else if(w <= 1024) return 12;
+    else if(w <= 1440) return 13;
+    else if(w <= 1600) return 14;
+    else               return 15;
+  }
+}
+
 // Definition of global shortcuts
 
 int GUI::global_shortcuts(int event)
@@ -855,18 +871,7 @@ GUI::GUI(int argc, char **argv)
   // 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.)
-  if(CTX.fontsize > 0){
-    fontsize = CTX.fontsize;
-  }
-  else{
-    int x, y, w, h;
-    Fl::screen_xywh(x, y, w, h);
-    if(w <= 860)       fontsize = 11;
-    else if(w <= 1024) fontsize = 12;
-    else if(w <= 1440) fontsize = 13;
-    else if(w <= 1600) fontsize = 14;
-    else               fontsize = 15;
-  }
+  fontsize = GetFontSize();
 
   // set default font size
   FL_NORMAL_SIZE = fontsize;
diff --git a/Fltk/GUI.h b/Fltk/GUI.h
index e0507a0059..0d2ec1619a 100644
--- a/Fltk/GUI.h
+++ b/Fltk/GUI.h
@@ -332,6 +332,7 @@ int GetFontIndex(char *fontname);
 int GetFontEnum(int index);
 char *GetFontName(int index);
 int GetFontAlign(char *alignstr);
+int GetFontSize();
 
 #endif
 
diff --git a/Fltk/GUI_Extras.cpp b/Fltk/GUI_Extras.cpp
index 34ba903bea..b6c202c0ff 100644
--- a/Fltk/GUI_Extras.cpp
+++ b/Fltk/GUI_Extras.cpp
@@ -1,4 +1,4 @@
-// $Id: GUI_Extras.cpp,v 1.34 2007-05-13 10:37:02 geuzaine Exp $
+// $Id: GUI_Extras.cpp,v 1.35 2007-06-12 07:04:08 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -23,14 +23,13 @@
 #include "GmshUI.h"
 #include "GmshDefines.h"
 #include "File_Picker.h"
-#include "Shortcut_Window.h"
 #include "CreateFile.h"
 #include "Options.h"
 #include "Context.h"
 #include "Draw.h"
+#include "GUI.h"
+#include "Shortcut_Window.h"
 
-#include <FL/Fl_Button.H>
-#include <FL/Fl_Return_Button.H>
 #include <FL/Fl_Value_Slider.H>
 #include <FL/Fl_Menu_Window.H>
 #include <errno.h>
@@ -121,8 +120,8 @@ int arrow_editor(char *title, double &a, double &b, double &c)
   };
   static _editor *editor = NULL;
 
-  const int BH = 2 * CTX.fontsize + 1;
-  const int BB = 7 * CTX.fontsize + 9;
+  const int BH = 2 * GetFontSize() + 1;
+  const int BB = 7 * GetFontSize() + 9;
   const int WB = 7;
 
   if(!editor){
@@ -229,8 +228,8 @@ int generic_bitmap_dialog(char *name, char *title, int format)
   };
   static _generic_bitmap_dialog *dialog = NULL;
 
-  const int BH = 2 * CTX.fontsize + 1;
-  const int BB = 7 * CTX.fontsize + 9;
+  const int BH = 2 * GetFontSize() + 1;
+  const int BB = 7 * GetFontSize() + 9;
   const int WB = 7;
 
   if(!dialog){
@@ -284,8 +283,8 @@ int jpeg_dialog(char *name)
   };
   static _jpeg_dialog *dialog = NULL;
 
-  const int BH = 2 * CTX.fontsize + 1;
-  const int BB = 7 * CTX.fontsize + 9;
+  const int BH = 2 * GetFontSize() + 1;
+  const int BB = 7 * GetFontSize() + 9;
   const int WB = 7;
 
   if(!dialog){
@@ -353,8 +352,8 @@ int gif_dialog(char *name)
   };
   static _gif_dialog *dialog = NULL;
 
-  const int BH = 2 * CTX.fontsize + 1;
-  const int BB = 7 * CTX.fontsize + 9;
+  const int BH = 2 * GetFontSize() + 1;
+  const int BB = 7 * GetFontSize() + 9;
   const int WB = 7;
 
   if(!dialog){
@@ -465,8 +464,8 @@ int gl2ps_dialog(char *name, char *title, int format)
     {0}
   };
 
-  const int BH = 2 * CTX.fontsize + 1;
-  const int BB = 7 * CTX.fontsize + 9;
+  const int BH = 2 * GetFontSize() + 1;
+  const int BB = 7 * GetFontSize() + 9;
   const int WB = 7;
 
   if(!dialog){
@@ -548,8 +547,8 @@ int options_dialog(char *name)
   };
   static _options_dialog *dialog = NULL;
 
-  const int BH = 2 * CTX.fontsize + 1;
-  const int BB = 7 * CTX.fontsize + 9;
+  const int BH = 2 * GetFontSize() + 1;
+  const int BB = 7 * GetFontSize() + 9;
   const int WB = 7;
 
   if(!dialog){
@@ -603,8 +602,8 @@ int geo_dialog(char *name)
   };
   static _geo_dialog *dialog = NULL;
 
-  const int BH = 2 * CTX.fontsize + 1;
-  const int BB = 7 * CTX.fontsize + 9;
+  const int BH = 2 * GetFontSize() + 1;
+  const int BB = 7 * GetFontSize() + 9;
   const int WB = 7;
 
   if(!dialog){
@@ -656,8 +655,8 @@ int generic_mesh_dialog(char *name, char *title, int format)
   };
   static _generic_mesh_dialog *dialog = NULL;
 
-  const int BH = 2 * CTX.fontsize + 1;
-  const int BB = 7 * CTX.fontsize + 9;
+  const int BH = 2 * GetFontSize() + 1;
+  const int BB = 7 * GetFontSize() + 9;
   const int WB = 7;
 
   if(!dialog){
@@ -718,8 +717,8 @@ int msh_dialog(char *name)
     {0}
   };
 
-  const int BH = 2 * CTX.fontsize + 1;
-  const int BB = 7 * CTX.fontsize + 9;
+  const int BH = 2 * GetFontSize() + 1;
+  const int BB = 7 * GetFontSize() + 9;
   const int WB = 7;
 
   if(!dialog){
@@ -780,8 +779,8 @@ int unv_dialog(char *name)
   };
   static _unv_dialog *dialog = NULL;
 
-  const int BH = 2 * CTX.fontsize + 1;
-  const int BB = 7 * CTX.fontsize + 9;
+  const int BH = 2 * GetFontSize() + 1;
+  const int BB = 7 * GetFontSize() + 9;
   const int WB = 7;
 
   if(!dialog){
@@ -845,8 +844,8 @@ int bdf_dialog(char *name)
     {0}
   };
 
-  const int BH = 2 * CTX.fontsize + 1;
-  const int BB = 7 * CTX.fontsize + 9;
+  const int BH = 2 * GetFontSize() + 1;
+  const int BB = 7 * GetFontSize() + 9;
   const int WB = 7;
 
   if(!dialog){
@@ -910,8 +909,8 @@ int stl_dialog(char *name)
     {0}
   };
 
-  const int BH = 2 * CTX.fontsize + 1;
-  const int BB = 7 * CTX.fontsize + 9;
+  const int BH = 2 * GetFontSize() + 1;
+  const int BB = 7 * GetFontSize() + 9;
   const int WB = 7;
 
   if(!dialog){
diff --git a/Fltk/GUI_Projection.cpp b/Fltk/GUI_Projection.cpp
index 53354f939e..9706436b5d 100644
--- a/Fltk/GUI_Projection.cpp
+++ b/Fltk/GUI_Projection.cpp
@@ -5,11 +5,8 @@
 #include "Draw.h"
 #include "Options.h"
 #include "Context.h"
-
+#include "GUI.h"
 #include "Shortcut_Window.h"
-#include <FL/Fl_Button.H>
-#include <FL/Fl_Return_Button.H>
-#include <FL/Fl_Value_Input.H>
 
 extern GModel *GMODEL;
 extern Context_T CTX;
@@ -23,8 +20,8 @@ int projection_editor(char *title, projectionFace *p)
   };
   static _editor *editor = 0;
 
-  const int BH = 2 * CTX.fontsize + 1;
-  const int BB = 7 * CTX.fontsize;
+  const int BH = 2 * GetFontSize() + 1;
+  const int BB = 7 * GetFontSize();
   const int WB = 7;
   
   SBoundingBox3d bounds = GMODEL->bounds();
-- 
GitLab