]> git.saurik.com Git - wxWidgets.git/commitdiff
no real changes, just refactor to remove some code duplication in wxToolBarTool
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 3 Aug 2008 11:27:03 +0000 (11:27 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 3 Aug 2008 11:27:03 +0000 (11:27 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54954 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/osx/carbon/toolbar.cpp

index 64a2201ccec6d80400e0c98255680c4a9b73cc2d..a3aedf7db67057819155a646d67c8d7709c49cb4 100644 (file)
@@ -178,14 +178,7 @@ public:
         m_toolbarItemRef = ref;
         if ( m_toolbarItemRef )
         {
         m_toolbarItemRef = ref;
         if ( m_toolbarItemRef )
         {
-            wxFont f;
-            wxFontEncoding enc;
-            if ( GetToolBar() )
-                f = GetToolBar()->GetFont();
-            if ( f.IsOk() )
-                enc = f.GetEncoding();
-            else
-                enc = wxFont::GetDefaultEncoding();
+            wxFontEncoding enc = GetToolBarFontEncoding();
 
             HIToolbarItemSetHelpText(
                 m_toolbarItemRef,
 
             HIToolbarItemSetHelpText(
                 m_toolbarItemRef,
@@ -215,25 +208,29 @@ public:
 
         if ( m_toolbarItemRef )
         {
 
         if ( m_toolbarItemRef )
         {
-            wxFont f;
-            wxFontEncoding enc;
-            if ( GetToolBar() )
-                f = GetToolBar()->GetFont();
-            if ( f.IsOk() )
-                enc = f.GetEncoding();
-            else
-                enc = wxFont::GetDefaultEncoding();
-
             // strip mnemonics from the label for compatibility with the usual
             // labels in wxStaticText sense
             wxString labelStr = wxStripMenuCodes(label);
 
             // strip mnemonics from the label for compatibility with the usual
             // labels in wxStaticText sense
             wxString labelStr = wxStripMenuCodes(label);
 
-            HIToolbarItemSetLabel( m_toolbarItemRef, wxCFStringRef(labelStr, enc) );
+            HIToolbarItemSetLabel(
+                m_toolbarItemRef,
+                wxCFStringRef(labelStr, GetToolBarFontEncoding()) );
         }
     }
 #endif // wxOSX_USE_NATIVE_TOOLBAR
 
 private:
         }
     }
 #endif // wxOSX_USE_NATIVE_TOOLBAR
 
 private:
+#if wxOSX_USE_NATIVE_TOOLBAR
+    wxFontEncoding GetToolBarFontEncoding() const
+    {
+        wxFont f;
+        wxFontEncoding enc;
+        if ( GetToolBar() )
+            f = GetToolBar()->GetFont();
+        return f.IsOk() ? f.GetEncoding() : wxFont::GetDefaultEncoding();
+    }
+#endif // wxOSX_USE_NATIVE_TOOLBAR
+
     void Init()
     {
         m_controlHandle = NULL;
     void Init()
     {
         m_controlHandle = NULL;