Improve wxFont usage
[ctsim.git] / libctgraphics / sgp.cpp
index 775aba21d9a3ed0d183d86f3e2ed07c5c4b5d770..e614a7f9290cd5916d16abd79757f9e56d39fa05 100644 (file)
@@ -99,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);
@@ -117,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
@@ -525,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
@@ -557,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
 }
@@ -585,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
@@ -607,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