// headers
// ----------------------------------------------------------------------------
+#include "wx/font.h"
+
#ifndef WX_PRECOMP
#include <stdio.h>
#include "wx/list.h"
#include "wx/utils.h"
#include "wx/app.h"
- #include "wx/font.h"
#include "wx/log.h"
#endif // WX_PRECOMP
public:
wxFontRefData()
{
- Init(-1, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, FALSE,
+ Init(-1, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false,
wxEmptyString, wxFONTENCODING_DEFAULT);
}
bool m_bInternalPS; // Internally generated PS?
}; // end of CLASS wxFontRefData
+#define M_FONTDATA ((wxFontRefData*)m_refData)
+
// ============================================================================
// implementation
// ============================================================================
fa.usCodePage,
fa.lMatch,
fn.usWeightClass,
- fa.szFacename);
+ (char *)fa.szFacename);
return sStr;
} // end of wxNativeFontInfo::ToString
// here, but we may check that font definition is true
// ----------------------------------------------------------------------------
+wxGDIRefData *wxFont::CreateGDIRefData() const
+{
+ return new wxFontRefData();
+}
+
+wxGDIRefData *wxFont::CloneGDIRefData(const wxGDIRefData *data) const
+{
+ return new wxFontRefData(*wx_static_cast(const wxFontRefData *, data));
+}
+
bool wxFont::RealizeResource()
{
if ( GetResourceHandle() )
return false;
} // end of wxFont::FreeResource
-WXHANDLE wxFont::GetResourceHandle()
+WXHANDLE wxFont::GetResourceHandle() const
{
return GetHFONT();
} // end of wxFont::GetResourceHandle
return M_FONTDATA && (M_FONTDATA->GetHFONT() == 0);
} // end of wxFont::IsFree
-void wxFont::Unshare()
-{
- // Don't change shared data
- if ( !m_refData )
- {
- m_refData = new wxFontRefData();
- }
- else
- {
- wxFontRefData* ref = new wxFontRefData(*M_FONTDATA);
- UnRef();
- m_refData = ref;
- }
-} // end of wxFont::Unshare
-
// ----------------------------------------------------------------------------
// change font attribute: we recreate font when doing it
// ----------------------------------------------------------------------------
int nPointSize
)
{
- Unshare();
+ AllocExclusive();
M_FONTDATA->SetPointSize(nPointSize);
int nFamily
)
{
- Unshare();
+ AllocExclusive();
M_FONTDATA->SetFamily(nFamily);
int nStyle
)
{
- Unshare();
+ AllocExclusive();
M_FONTDATA->SetStyle(nStyle);
int nWeight
)
{
- Unshare();
+ AllocExclusive();
M_FONTDATA->SetWeight(nWeight);
const wxString& rsFaceName
)
{
- Unshare();
+ AllocExclusive();
bool refdataok = M_FONTDATA->SetFaceName(rsFaceName);
bool bUnderlined
)
{
- Unshare();
+ AllocExclusive();
M_FONTDATA->SetUnderlined(bUnderlined);
wxFontEncoding vEncoding
)
{
- Unshare();
+ AllocExclusive();
M_FONTDATA->SetEncoding(vEncoding);
const wxNativeFontInfo& rInfo
)
{
- Unshare();
+ AllocExclusive();
FreeResource();
//
// Internal use only method to set the FONTMETRICS array
//
-void wxFont::SetFM(
- PFONTMETRICS pFM
-, int nNumFonts
-)
+void wxFont::SetFM( PFONTMETRICS pFM, int nNumFonts )
{
M_FONTDATA->SetFM(pFM);
M_FONTDATA->SetNumFonts(nNumFonts);
} // end of wxFont::SetFM
-void wxFont::SetPS(
- HPS hPS
-)
+void wxFont::SetPS( HPS hPS )
{
- Unshare();
+ AllocExclusive();
M_FONTDATA->SetPS(hPS);