]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/font.cpp
Store pointer to owning wxWindow in wxPizza widget
[wxWidgets.git] / src / msw / font.cpp
index f2ff677d8a5549ceb1bb0df591115c79328be2fd..ed8728be509a700253436f4bbfbfd800f3a05f7d 100644 (file)
@@ -116,9 +116,9 @@ public:
     wxFontRefData(int size,
                   const wxSize& pixelSize,
                   bool sizeUsingPixels,
-                  int family,
-                  int style,
-                  int weight,
+                  wxFontFamily family,
+                  wxFontStyle style,
+                  wxFontWeight weight,
                   bool underlined,
                   const wxString& faceName,
                   wxFontEncoding encoding)
@@ -171,18 +171,18 @@ public:
         return m_nativeFontInfoOk ? true : m_sizeUsingPixels;
     }
 
-    int GetFamily() const
+    wxFontFamily GetFamily() const
     {
         return m_family;
     }
 
-    int GetStyle() const
+    wxFontStyle GetStyle() const
     {
         return m_nativeFontInfoOk ? m_nativeFontInfo.GetStyle()
                                   : m_style;
     }
 
-    int GetWeight() const
+    wxFontWeight GetWeight() const
     {
         return m_nativeFontInfoOk ? m_nativeFontInfo.GetWeight()
                                   : m_weight;
@@ -214,7 +214,7 @@ public:
     WXHFONT GetHFONT(const wxFont *font) const
     {
         if ( !m_hFont )
-            wx_const_cast(wxFontRefData *, this)->Alloc(font);
+            const_cast<wxFontRefData *>(this)->Alloc(font);
 
         return (WXHFONT)m_hFont;
     }
@@ -257,14 +257,14 @@ public:
         }
     }
 
-    void SetFamily(int family)
+    void SetFamily(wxFontFamily family)
     {
         Free();
 
         m_family = family;
     }
 
-    void SetStyle(int style)
+    void SetStyle(wxFontStyle style)
     {
         Free();
 
@@ -274,7 +274,7 @@ public:
             m_style = style;
     }
 
-    void SetWeight(int weight)
+    void SetWeight(wxFontWeight weight)
     {
         Free();
 
@@ -334,9 +334,9 @@ protected:
     void Init(int size,
               const wxSize& pixelSize,
               bool sizeUsingPixels,
-              int family,
-              int style,
-              int weight,
+              wxFontFamily family,
+              wxFontStyle style,
+              wxFontWeight weight,
               bool underlined,
               const wxString& faceName,
               wxFontEncoding encoding);
@@ -347,9 +347,9 @@ protected:
     int           m_pointSize;
     wxSize        m_pixelSize;
     bool          m_sizeUsingPixels;
-    int           m_family;
-    int           m_style;
-    int           m_weight;
+    wxFontFamily  m_family;
+    wxFontStyle   m_style;
+    wxFontWeight  m_weight;
     bool          m_underlined;
     wxString      m_faceName;
     wxFontEncoding m_encoding;
@@ -375,9 +375,9 @@ protected:
 void wxFontRefData::Init(int pointSize,
                          const wxSize& pixelSize,
                          bool sizeUsingPixels,
-                         int family,
-                         int style,
-                         int weight,
+                         wxFontFamily family,
+                         wxFontStyle style,
+                         wxFontWeight weight,
                          bool underlined,
                          const wxString& faceName,
                          wxFontEncoding encoding)
@@ -410,7 +410,7 @@ void wxFontRefData::Init(const wxNativeFontInfo& info, WXHFONT hFont)
     m_nativeFontInfo = info;
     // This is the best we can do since we don't have the
     // correct information at this point.
-    m_family = wxSWISS;
+    m_family = wxFONTFAMILY_SWISS;
 }
 
 wxFontRefData::~wxFontRefData()
@@ -618,9 +618,7 @@ void wxNativeFontInfo::SetUnderlined(bool underlined)
 
 bool wxNativeFontInfo::SetFaceName(const wxString& facename)
 {
-    size_t len = WXSIZEOF(lf.lfFaceName);
-    wxStrncpy(lf.lfFaceName, facename, len);
-    lf.lfFaceName[len - 1] = '\0';    // truncate the face name
+    wxStrlcpy(lf.lfFaceName, facename.c_str(), WXSIZEOF(lf.lfFaceName));
     return true;
 }
 
@@ -864,9 +862,9 @@ wxFont::wxFont(const wxString& fontdesc)
 bool wxFont::DoCreate(int pointSize,
                       const wxSize& pixelSize,
                       bool sizeUsingPixels,
-                      int family,
-                      int style,
-                      int weight,
+                      wxFontFamily family,
+                      wxFontStyle style,
+                      wxFontWeight weight,
                       bool underlined,
                       const wxString& faceName,
                       wxFontEncoding encoding)
@@ -902,7 +900,7 @@ wxGDIRefData *wxFont::CreateGDIRefData() const
 
 wxGDIRefData *wxFont::CloneGDIRefData(const wxGDIRefData *data) const
 {
-    return new wxFontRefData(*wx_static_cast(const wxFontRefData *, data));
+    return new wxFontRefData(*static_cast<const wxFontRefData *>(data));
 }
 
 bool wxFont::RealizeResource()
@@ -958,21 +956,21 @@ void wxFont::SetPixelSize(const wxSize& pixelSize)
     M_FONTDATA->SetPixelSize(pixelSize);
 }
 
-void wxFont::SetFamily(int family)
+void wxFont::SetFamily(wxFontFamily family)
 {
     AllocExclusive();
 
     M_FONTDATA->SetFamily(family);
 }
 
-void wxFont::SetStyle(int style)
+void wxFont::SetStyle(wxFontStyle style)
 {
     AllocExclusive();
 
     M_FONTDATA->SetStyle(style);
 }
 
-void wxFont::SetWeight(int weight)
+void wxFont::SetWeight(wxFontWeight weight)
 {
     AllocExclusive();
 
@@ -1042,23 +1040,23 @@ bool wxFont::IsUsingSizeInPixels() const
     return M_FONTDATA->IsUsingSizeInPixels();
 }
 
-int wxFont::GetFamily() const
+wxFontFamily wxFont::GetFamily() const
 {
-    wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
+    wxCHECK_MSG( Ok(), wxFONTFAMILY_MAX, wxT("invalid font") );
 
     return M_FONTDATA->GetFamily();
 }
 
-int wxFont::GetStyle() const
+wxFontStyle wxFont::GetStyle() const
 {
-    wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
+    wxCHECK_MSG( Ok(), wxFONTSTYLE_MAX, wxT("invalid font") );
 
     return M_FONTDATA->GetStyle();
 }
 
-int wxFont::GetWeight() const
+wxFontWeight wxFont::GetWeight() const
 {
-    wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
+    wxCHECK_MSG( Ok(), wxFONTWEIGHT_MAX, wxT("invalid font") );
 
     return M_FONTDATA->GetWeight();
 }