projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
use facename in wxFontRefData::Init() in Unicode build (part of patch 1671684)
[wxWidgets.git]
/
src
/
msw
/
font.cpp
diff --git
a/src/msw/font.cpp
b/src/msw/font.cpp
index 308a36e837ddbf8b571b007115afcc1418b26ca4..d7fcfe9b9f6b995f4843bfa17c39883ed5442f07 100644
(file)
--- a/
src/msw/font.cpp
+++ b/
src/msw/font.cpp
@@
-24,11
+24,12
@@
#pragma hdrstop
#endif
#pragma hdrstop
#endif
+#include "wx/font.h"
+
#ifndef WX_PRECOMP
#include "wx/list.h"
#include "wx/utils.h"
#include "wx/app.h"
#ifndef WX_PRECOMP
#include "wx/list.h"
#include "wx/utils.h"
#include "wx/app.h"
- #include "wx/font.h"
#include "wx/log.h"
#include "wx/encinfo.h"
#endif // WX_PRECOMP
#include "wx/log.h"
#include "wx/encinfo.h"
#endif // WX_PRECOMP
@@
-261,7
+262,7
@@
public:
if ( m_nativeFontInfoOk )
return m_nativeFontInfo.SetFaceName(faceName);
if ( m_nativeFontInfoOk )
return m_nativeFontInfo.SetFaceName(faceName);
-
m_faceName = faceName;
+ m_faceName = faceName;
return true;
}
return true;
}
@@
-320,6
+321,8
@@
protected:
bool m_nativeFontInfoOk;
};
bool m_nativeFontInfoOk;
};
+#define M_FONTDATA ((wxFontRefData*)m_refData)
+
// ============================================================================
// implementation
// ============================================================================
// ============================================================================
// implementation
// ============================================================================
@@
-413,6
+416,14
@@
void wxFontRefData::Free()
void wxNativeFontInfo::Init()
{
wxZeroMemory(lf);
void wxNativeFontInfo::Init()
{
wxZeroMemory(lf);
+
+ // we get better font quality if we use this instead of DEFAULT_QUALITY
+ // apparently without any drawbacks
+#ifdef __WXWINCE__
+ lf.lfQuality = CLEARTYPE_QUALITY;
+#else
+ lf.lfQuality = PROOF_QUALITY;
+#endif
}
int wxNativeFontInfo::GetPointSize() const
}
int wxNativeFontInfo::GetPointSize() const
@@
-573,7
+584,7
@@
void wxNativeFontInfo::SetFamily(wxFontFamily family)
BYTE ff_family;
wxArrayString facename;
BYTE ff_family;
wxArrayString facename;
- // the list of fonts associated with a family was partially
+ // the list of fonts associated with a family was partially
// taken from http://www.codestyle.org/css/font-family
switch ( family )
// taken from http://www.codestyle.org/css/font-family
switch ( family )
@@
-629,15
+640,15
@@
void wxNativeFontInfo::SetFamily(wxFontFamily family)
// is returned as default GUI font for compatibility
int verMaj;
ff_family = FF_SWISS;
// is returned as default GUI font for compatibility
int verMaj;
ff_family = FF_SWISS;
- if(wxGetOsVersion(&verMaj) == wxWINDOWS_NT && verMaj >= 5)
+ if(wxGetOsVersion(&verMaj) == wx
OS_
WINDOWS_NT && verMaj >= 5)
facename.Add(_T("MS Shell Dlg 2"));
else
facename.Add(_T("MS Shell Dlg"));
// Quoting the MSDN:
facename.Add(_T("MS Shell Dlg 2"));
else
facename.Add(_T("MS Shell Dlg"));
// Quoting the MSDN:
- // "MS Shell Dlg is a mapping mechanism that enables
- // U.S. English Microsoft Windows NT, and Microsoft Windows 2000 to
- // support locales that have characters that are not contained in code
+ // "MS Shell Dlg is a mapping mechanism that enables
+ // U.S. English Microsoft Windows NT, and Microsoft Windows 2000 to
+ // support locales that have characters that are not contained in code
// page 1252. It is not a font but a face name for a nonexistent font."
}
}
// page 1252. It is not a font but a face name for a nonexistent font."
}
}
@@
-846,6
+857,16
@@
wxFont::~wxFont()
// real implementation
// ----------------------------------------------------------------------------
// real implementation
// ----------------------------------------------------------------------------
+wxObjectRefData *wxFont::CreateRefData() const
+{
+ return new wxFontRefData();
+}
+
+wxObjectRefData *wxFont::CloneRefData(const wxObjectRefData *data) const
+{
+ return new wxFontRefData(*wx_static_cast(const wxFontRefData *, data));
+}
+
bool wxFont::RealizeResource()
{
if ( GetResourceHandle() )
bool wxFont::RealizeResource()
{
if ( GetResourceHandle() )
@@
-885,28
+906,13
@@
bool wxFont::IsFree() const
return M_FONTDATA && (M_FONTDATA->GetHFONT() == 0);
}
return M_FONTDATA && (M_FONTDATA->GetHFONT() == 0);
}
-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;
- }
-}
-
// ----------------------------------------------------------------------------
// change font attribute: we recreate font when doing it
// ----------------------------------------------------------------------------
void wxFont::SetPointSize(int pointSize)
{
// ----------------------------------------------------------------------------
// change font attribute: we recreate font when doing it
// ----------------------------------------------------------------------------
void wxFont::SetPointSize(int pointSize)
{
-
Unshar
e();
+
AllocExclusiv
e();
M_FONTDATA->SetPointSize(pointSize);
M_FONTDATA->SetPointSize(pointSize);
@@
-915,7
+921,7
@@
void wxFont::SetPointSize(int pointSize)
void wxFont::SetPixelSize(const wxSize& pixelSize)
{
void wxFont::SetPixelSize(const wxSize& pixelSize)
{
-
Unshar
e();
+
AllocExclusiv
e();
M_FONTDATA->SetPixelSize(pixelSize);
M_FONTDATA->SetPixelSize(pixelSize);
@@
-924,7
+930,7
@@
void wxFont::SetPixelSize(const wxSize& pixelSize)
void wxFont::SetFamily(int family)
{
void wxFont::SetFamily(int family)
{
-
Unshar
e();
+
AllocExclusiv
e();
M_FONTDATA->SetFamily(family);
M_FONTDATA->SetFamily(family);
@@
-933,7
+939,7
@@
void wxFont::SetFamily(int family)
void wxFont::SetStyle(int style)
{
void wxFont::SetStyle(int style)
{
-
Unshar
e();
+
AllocExclusiv
e();
M_FONTDATA->SetStyle(style);
M_FONTDATA->SetStyle(style);
@@
-942,7
+948,7
@@
void wxFont::SetStyle(int style)
void wxFont::SetWeight(int weight)
{
void wxFont::SetWeight(int weight)
{
-
Unshar
e();
+
AllocExclusiv
e();
M_FONTDATA->SetWeight(weight);
M_FONTDATA->SetWeight(weight);
@@
-951,7
+957,7
@@
void wxFont::SetWeight(int weight)
bool wxFont::SetFaceName(const wxString& faceName)
{
bool wxFont::SetFaceName(const wxString& faceName)
{
-
Unshar
e();
+
AllocExclusiv
e();
bool refdataok = M_FONTDATA->SetFaceName(faceName);
bool refdataok = M_FONTDATA->SetFaceName(faceName);
@@
-969,7
+975,7
@@
bool wxFont::SetFaceName(const wxString& faceName)
void wxFont::SetUnderlined(bool underlined)
{
void wxFont::SetUnderlined(bool underlined)
{
-
Unshar
e();
+
AllocExclusiv
e();
M_FONTDATA->SetUnderlined(underlined);
M_FONTDATA->SetUnderlined(underlined);
@@
-978,7
+984,7
@@
void wxFont::SetUnderlined(bool underlined)
void wxFont::SetEncoding(wxFontEncoding encoding)
{
void wxFont::SetEncoding(wxFontEncoding encoding)
{
-
Unshar
e();
+
AllocExclusiv
e();
M_FONTDATA->SetEncoding(encoding);
M_FONTDATA->SetEncoding(encoding);
@@
-987,9
+993,7
@@
void wxFont::SetEncoding(wxFontEncoding encoding)
void wxFont::DoSetNativeFontInfo(const wxNativeFontInfo& info)
{
void wxFont::DoSetNativeFontInfo(const wxNativeFontInfo& info)
{
- Unshare();
-
- FreeResource();
+ AllocExclusive();
*M_FONTDATA = wxFontRefData(info);
*M_FONTDATA = wxFontRefData(info);
@@
-1009,6
+1013,8
@@
int wxFont::GetPointSize() const
wxSize wxFont::GetPixelSize() const
{
wxSize wxFont::GetPixelSize() const
{
+ wxCHECK_MSG( Ok(), wxDefaultSize, wxT("invalid font") );
+
return M_FONTDATA->GetPixelSize();
}
return M_FONTDATA->GetPixelSize();
}
@@
-1063,12
+1069,14
@@
wxFontEncoding wxFont::GetEncoding() const
const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
{
const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
{
- return M_FONTDATA->HasNativeFontInfo() ? &(M_FONTDATA->GetNativeFontInfo())
+ return
Ok() &&
M_FONTDATA->HasNativeFontInfo() ? &(M_FONTDATA->GetNativeFontInfo())
: NULL;
}
wxString wxFont::GetNativeFontInfoDesc() const
{
: NULL;
}
wxString wxFont::GetNativeFontInfoDesc() const
{
+ wxCHECK_MSG( Ok(), wxEmptyString, wxT("invalid font") );
+
// be sure we have an HFONT associated...
wxConstCast(this, wxFont)->RealizeResource();
return wxFontBase::GetNativeFontInfoDesc();
// be sure we have an HFONT associated...
wxConstCast(this, wxFont)->RealizeResource();
return wxFontBase::GetNativeFontInfoDesc();
@@
-1076,6
+1084,8
@@
wxString wxFont::GetNativeFontInfoDesc() const
wxString wxFont::GetNativeFontInfoUserDesc() const
{
wxString wxFont::GetNativeFontInfoUserDesc() const
{
+ wxCHECK_MSG( Ok(), wxEmptyString, wxT("invalid font") );
+
// be sure we have an HFONT associated...
wxConstCast(this, wxFont)->RealizeResource();
return wxFontBase::GetNativeFontInfoUserDesc();
// be sure we have an HFONT associated...
wxConstCast(this, wxFont)->RealizeResource();
return wxFontBase::GetNativeFontInfoUserDesc();
@@
-1095,4
+1105,3
@@
bool wxFont::IsFixedWidth() const
return wxFontBase::IsFixedWidth();
}
return wxFontBase::IsFixedWidth();
}
-