]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/textmeasure.cpp
Move code that does not need realized GdkWinow out of realize handler
[wxWidgets.git] / src / gtk / textmeasure.cpp
index 2032a45df0d771696f3db6aae72d5a1f9f1df652..407a62f36be1abefefc143e50bf695c321676878 100644 (file)
@@ -3,7 +3,6 @@
 // Purpose:     wxTextMeasure implementation for wxGTK
 // Author:      Manuel Martin
 // Created:     2012-10-05
-// RCS-ID:      $Id:
 // Copyright:   (c) 1997-2012 wxWidgets team
 // Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
@@ -40,8 +39,6 @@
 
 void wxTextMeasure::Init()
 {
-    wxASSERT_MSG( m_font, wxT("wxTextMeasure needs a valid wxFont") );
-
     m_context = NULL;
     m_layout = NULL;
 
@@ -87,7 +84,7 @@ void wxTextMeasure::BeginMeasuring()
     if ( m_layout )
     {
         pango_layout_set_font_description(m_layout,
-                                          m_font->GetNativeFontInfo()->description);
+                                          GetFont().GetNativeFontInfo()->description);
     }
 }
 
@@ -118,14 +115,17 @@ void wxTextMeasure::DoGetTextExtent(const wxString& string,
 {
     if ( !m_context )
     {
-        *width =
-        *height = 0;
+        if ( width )
+            *width = 0;
+
+        if ( height )
+            *height = 0;
         return;
     }
 
     // Set layout's text
-    const wxCharBuffer dataUTF8 = wxGTK_CONV_FONT(string, *m_font);
-    if ( !dataUTF8 )
+    const wxCharBuffer dataUTF8 = wxGTK_CONV_FONT(string, GetFont());
+    if ( !dataUTF8 && !string.empty() )
     {
         // hardly ideal, but what else can we do if conversion failed?
         wxLogLastError(wxT("GetTextExtent"));
@@ -164,10 +164,13 @@ void wxTextMeasure::DoGetTextExtent(const wxString& string,
 
 bool wxTextMeasure::DoGetPartialTextExtents(const wxString& text,
                                             wxArrayInt& widths,
-                                            double WXUNUSED(scaleX))
+                                            double scaleX)
 {
+    if ( !m_layout )
+        return wxTextMeasureBase::DoGetPartialTextExtents(text, widths, scaleX);
+
     // Set layout's text
-    const wxCharBuffer dataUTF8 = wxGTK_CONV_FONT(text, *m_font);
+    const wxCharBuffer dataUTF8 = wxGTK_CONV_FONT(text, GetFont());
     if ( !dataUTF8 )
     {
         // hardly ideal, but what else can we do if conversion failed?