Improve wxFont usage
[ctsim.git] / libctgraphics / sgp.cpp
index 6d0e1f4838daa28d34894ecd2c76a0ddafc15cd8..e614a7f9290cd5916d16abd79757f9e56d39fa05 100644 (file)
@@ -5,9 +5,7 @@
 **      Programmer: Kevin Rosenberg
 **
 **  This is part of the CTSim program
-**  Copyright (c) 1983-2001 Kevin Rosenberg
-**
-**  $Id$
+**  Copyright (c) 1983-2009 Kevin Rosenberg
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License (version 2) as
@@ -101,7 +99,7 @@ SGP::SGP (const SGPDriver& driver)
   stylusNDC (0., 0., false);
 
   setTextAngle (0.);
-  setTextPointSize (12);
+  setTextPointSize (8);
   setColor (C_BLACK);
   setLineStyle (LS_SOLID);
   setMarker (MARKER_POINT);
@@ -119,11 +117,8 @@ SGP::initFromDC (wxDC* pDC)
     static const double dPointsPerInch = 72.;
     m_dPointsPerPixel = dPointsPerInch / dScreenDPI;
     const int iTestPointSize = 12;
-    m_pFont = new wxFont (wxROMAN, wxNORMAL, wxNORMAL, wxNORMAL);
-    m_pFont->SetPointSize (iTestPointSize);
-    m_pFont->SetWeight (wxNORMAL);
-    m_pFont->SetStyle (wxNORMAL);
-    m_pFont->SetFamily (wxROMAN);
+    m_pFont = new wxFont (iTestPointSize, wxFONTFAMILY_ROMAN, 
+                          wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
 #ifdef MSVC
     m_pFont->SetFaceName(wxString("times new roman"));
 #endif
@@ -527,6 +522,9 @@ SGP::setTextSize (double height)
       double dHeightPixels = height * m_iPhysicalYSize;
       double dHeightPoints = dHeightPixels * m_dPointsPerPixel;
       m_pFont->SetPointSize (nearest<int>(dHeightPoints));
+      sys_error (ERR_TRACE, "Setting text size to %d points", 
+                 nearest<int>(dHeightPoints));
+
       m_driver.idWX()->SetFont (*m_pFont);
   }
 #endif
@@ -559,8 +557,9 @@ SGP::setTextPointSize (double height)
 #if HAVE_WXWINDOWS
   if (m_driver.isWX()) {
     m_iTextPointSize = static_cast<int>(height+0.5);
-      m_pFont->SetPointSize (m_iTextPointSize);
-      m_driver.idWX()->SetFont (*m_pFont);
+    m_pFont->SetPointSize (m_iTextPointSize);
+    sys_error (ERR_TRACE, "Setting point size to %d", m_iTextPointSize);
+    m_driver.idWX()->SetFont (*m_pFont);
   }
 #endif
 }
@@ -587,13 +586,13 @@ SGP::getTextExtent (const char* szText, double* worldW, double* worldH)
 double
 SGP::getCharHeight ()
 {
-  double dHeight = (1. / 25.);
+  double dHeight = (1. / 50.);
 
 #if HAVE_WXWINDOWS
   if (m_driver.isWX()) {
     dHeight = m_driver.idWX()->GetCharHeight();
     dHeight /= static_cast<double>(m_iPhysicalYSize);
-          dHeight /= (yv_max - yv_min); // scale to viewport;
+    dHeight /= (yv_max - yv_min); // scale to viewport;
   }
 #endif
   dHeight *= (yw_max - yw_min);  // scale to world coordinates
@@ -609,7 +608,7 @@ SGP::getCharWidth ()
   if (m_driver.isWX()) {
     dWidth = m_driver.idWX()->GetCharWidth();
     dWidth /= static_cast<double>(m_iPhysicalXSize);
-          dWidth /= (xv_max - xv_min); // scale to viewport
+    dWidth /= (xv_max - xv_min); // scale to viewport
   }
 #endif
   dWidth *= (xw_max - xw_min); //scale to world coordinates