]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/fontmgrcmn.cpp
blind build fix for STL builds
[wxWidgets.git] / src / common / fontmgrcmn.cpp
index 6a5d0683ec5fe4c1c2d2cb186754d45e7741aa54..86c88d8be2fbf22d85436202692ded2a8f47e0e9 100644 (file)
 WX_DECLARE_LIST(wxFontInstance, wxFontInstanceList);
 WX_DEFINE_LIST(wxFontInstanceList)
 WX_DEFINE_LIST(wxFontBundleList)
+
 WX_DECLARE_HASH_MAP(wxString, wxFontBundle*,
                     wxStringHash, wxStringEqual,
-                    wxFontBundleHash);
+                    wxFontBundleHashBase);
+// in STL build, hash class is typedef to a template, so it can't be forward
+// declared, as we do; solve it by having a dummy class:
+class wxFontBundleHash : public wxFontBundleHashBase
+{
+};
 
 // ============================================================================
 // implementation
@@ -65,17 +71,14 @@ wxFontInstance *wxFontFaceBase::GetFontInstance(float ptSize, bool aa)
 {
     wxASSERT_MSG( m_refCnt > 0, _T("font library not loaded!") );
 
-    wxFontInstance *i;
-    wxFontInstanceList::Node *node;
-
-    for ( node = m_instances->GetFirst(); node; node = node->GetNext() )
+    for ( wxFontInstanceList::const_iterator i = m_instances->begin();
+          i != m_instances->end(); ++i )
     {
-        i = node->GetData();
-        if ( i->GetPointSize() == ptSize && i->IsAntiAliased() == aa )
-            return i;
+        if ( (*i)->GetPointSize() == ptSize && (*i)->IsAntiAliased() == aa )
+            return *i;
     }
 
-    i = CreateFontInstance(ptSize, aa);
+    wxFontInstance *i = CreateFontInstance(ptSize, aa);
     m_instances->Append(i);
     return i;
 }
@@ -110,7 +113,8 @@ wxFontFace *wxFontBundleBase::GetFace(FaceType type) const
 wxFontFace *
 wxFontBundleBase::GetFaceForFont(const wxFontMgrFontRefData& font) const
 {
-    wxASSERT_MSG( font.GetFaceName().empty() || font.GetFaceName() == GetName(),
+    wxASSERT_MSG( font.GetFaceName().empty() ||
+                  GetName().CmpNoCase(font.GetFaceName()) == 0,
                   _T("calling GetFaceForFont for incompatible font") );
 
     int type = FaceType_Regular;
@@ -129,6 +133,8 @@ wxFontBundleBase::GetFaceForFont(const wxFontMgrFontRefData& font) const
 
     if ( !HasFace((FaceType)type) )
     {
+        // if we can't get the exact font requested, substitute it with
+        // some other variant:
         for (int i = 0; i < FaceType_Max; i++)
         {
             if ( HasFace((FaceType)i) )
@@ -219,19 +225,15 @@ void wxFontsManagerBase::AddBundle(wxFontBundle *bundle)
 // ----------------------------------------------------------------------------
 
 wxFontMgrFontRefData::wxFontMgrFontRefData(int size,
-                                           int family,
-                                           int style,
-                                           int weight,
+                                           wxFontFamily family,
+                                           wxFontStyle style,
+                                           wxFontWeight weight,
                                            bool underlined,
                                            const wxString& faceName,
                                            wxFontEncoding encoding)
 {
-    if ( family == wxDEFAULT )
-        family = wxSWISS;
-    if ( style == wxDEFAULT )
-        style = wxNORMAL;
-    if ( weight == wxDEFAULT )
-        weight = wxNORMAL;
+    if ( family == wxFONTFAMILY_DEFAULT )
+        family = wxFONTFAMILY_SWISS;
     if ( size == wxDEFAULT )
         size = 12;
 
@@ -288,21 +290,21 @@ void wxFontMgrFontRefData::SetPointSize(int pointSize)
     m_fontValid = false;
 }
 
-void wxFontMgrFontRefData::SetFamily(int family)
+void wxFontMgrFontRefData::SetFamily(wxFontFamily family)
 {
-    m_info.family = (wxFontFamily)family;
+    m_info.family = family;
     m_fontValid = false;
 }
 
-void wxFontMgrFontRefData::SetStyle(int style)
+void wxFontMgrFontRefData::SetStyle(wxFontStyle style)
 {
-    m_info.style = (wxFontStyle)style;
+    m_info.style = style;
     m_fontValid = false;
 }
 
-void wxFontMgrFontRefData::SetWeight(int weight)
+void wxFontMgrFontRefData::SetWeight(wxFontWeight weight)
 {
-    m_info.weight = (wxFontWeight)weight;
+    m_info.weight = weight;
     m_fontValid = false;
 }