pointer returned by GetNativeFontInfo() is now const and must not be deleted (replaces patch 810192)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23875 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -152,6 +152,7 @@ public:
|
|||||||
virtual bool GetUnderlined() const;
|
virtual bool GetUnderlined() const;
|
||||||
virtual wxString GetFaceName() const;
|
virtual wxString GetFaceName() const;
|
||||||
virtual wxFontEncoding GetEncoding() const;
|
virtual wxFontEncoding GetEncoding() const;
|
||||||
|
virtual const wxNativeFontInfo *GetNativeFontInfo() const;
|
||||||
|
|
||||||
virtual void SetPointSize(int pointSize);
|
virtual void SetPointSize(int pointSize);
|
||||||
virtual void SetFamily(int family);
|
virtual void SetFamily(int family);
|
||||||
|
@@ -156,7 +156,7 @@ public:
|
|||||||
virtual bool GetUnderlined() const = 0;
|
virtual bool GetUnderlined() const = 0;
|
||||||
virtual wxString GetFaceName() const = 0;
|
virtual wxString GetFaceName() const = 0;
|
||||||
virtual wxFontEncoding GetEncoding() const = 0;
|
virtual wxFontEncoding GetEncoding() const = 0;
|
||||||
virtual wxNativeFontInfo *GetNativeFontInfo() const;
|
virtual const wxNativeFontInfo *GetNativeFontInfo() const = 0;
|
||||||
|
|
||||||
virtual bool IsFixedWidth() const;
|
virtual bool IsFixedWidth() const;
|
||||||
|
|
||||||
|
@@ -139,6 +139,28 @@ public:
|
|||||||
// reset to the default state
|
// reset to the default state
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
|
// init with the parameters of the given font
|
||||||
|
void InitFromFont(const wxFont& font)
|
||||||
|
{
|
||||||
|
// translate all font parameters
|
||||||
|
SetStyle((wxFontStyle)font.GetStyle());
|
||||||
|
SetWeight((wxFontWeight)font.GetWeight());
|
||||||
|
SetUnderlined(font.GetUnderlined());
|
||||||
|
SetPointSize(font.GetPointSize());
|
||||||
|
|
||||||
|
// set the family/facename
|
||||||
|
SetFamily((wxFontFamily)font.GetFamily());
|
||||||
|
const wxString& facename = font.GetFaceName();
|
||||||
|
if ( !facename.empty() )
|
||||||
|
{
|
||||||
|
SetFaceName(facename);
|
||||||
|
}
|
||||||
|
|
||||||
|
// deal with encoding now (it may override the font family and facename
|
||||||
|
// so do it after setting them)
|
||||||
|
SetEncoding(font.GetEncoding());
|
||||||
|
}
|
||||||
|
|
||||||
// accessors and modifiers for the font elements
|
// accessors and modifiers for the font elements
|
||||||
int GetPointSize() const;
|
int GetPointSize() const;
|
||||||
wxFontStyle GetStyle() const;
|
wxFontStyle GetStyle() const;
|
||||||
|
@@ -84,7 +84,7 @@ public:
|
|||||||
virtual wxString GetFaceName() const;
|
virtual wxString GetFaceName() const;
|
||||||
virtual bool GetUnderlined() const;
|
virtual bool GetUnderlined() const;
|
||||||
virtual wxFontEncoding GetEncoding() const;
|
virtual wxFontEncoding GetEncoding() const;
|
||||||
virtual wxNativeFontInfo *GetNativeFontInfo() const;
|
virtual const wxNativeFontInfo *GetNativeFontInfo() const;
|
||||||
virtual bool IsFixedWidth() const;
|
virtual bool IsFixedWidth() const;
|
||||||
|
|
||||||
virtual void SetPointSize( int pointSize );
|
virtual void SetPointSize( int pointSize );
|
||||||
|
@@ -84,7 +84,7 @@ public:
|
|||||||
virtual wxString GetFaceName() const;
|
virtual wxString GetFaceName() const;
|
||||||
virtual bool GetUnderlined() const;
|
virtual bool GetUnderlined() const;
|
||||||
virtual wxFontEncoding GetEncoding() const;
|
virtual wxFontEncoding GetEncoding() const;
|
||||||
virtual wxNativeFontInfo *GetNativeFontInfo() const;
|
virtual const wxNativeFontInfo *GetNativeFontInfo() const;
|
||||||
virtual bool IsFixedWidth() const;
|
virtual bool IsFixedWidth() const;
|
||||||
|
|
||||||
virtual void SetPointSize( int pointSize );
|
virtual void SetPointSize( int pointSize );
|
||||||
|
@@ -16,103 +16,6 @@
|
|||||||
#pragma interface "font.h"
|
#pragma interface "font.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class WXDLLEXPORT wxFontRefData: public wxGDIRefData
|
|
||||||
{
|
|
||||||
friend class WXDLLEXPORT wxFont;
|
|
||||||
public:
|
|
||||||
wxFontRefData()
|
|
||||||
: m_fontId(0)
|
|
||||||
, m_pointSize(10)
|
|
||||||
, m_family(wxDEFAULT)
|
|
||||||
, m_style(wxNORMAL)
|
|
||||||
, m_weight(wxNORMAL)
|
|
||||||
, m_underlined(FALSE)
|
|
||||||
, m_faceName(wxT("Geneva"))
|
|
||||||
, m_encoding(wxFONTENCODING_DEFAULT)
|
|
||||||
, m_macFontNum(0)
|
|
||||||
, m_macFontSize(0)
|
|
||||||
, m_macFontStyle(0)
|
|
||||||
, m_macATSUFontID()
|
|
||||||
{
|
|
||||||
Init(10, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE,
|
|
||||||
wxT("Geneva"), wxFONTENCODING_DEFAULT);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxFontRefData(const wxFontRefData& data)
|
|
||||||
: wxGDIRefData()
|
|
||||||
, m_fontId(data.m_fontId)
|
|
||||||
, m_pointSize(data.m_pointSize)
|
|
||||||
, m_family(data.m_family)
|
|
||||||
, m_style(data.m_style)
|
|
||||||
, m_weight(data.m_weight)
|
|
||||||
, m_underlined(data.m_underlined)
|
|
||||||
, m_faceName(data.m_faceName)
|
|
||||||
, m_encoding(data.m_encoding)
|
|
||||||
, m_macFontNum(data.m_macFontNum)
|
|
||||||
, m_macFontSize(data.m_macFontSize)
|
|
||||||
, m_macFontStyle(data.m_macFontStyle)
|
|
||||||
, m_macATSUFontID(data.m_macATSUFontID)
|
|
||||||
{
|
|
||||||
Init(data.m_pointSize, data.m_family, data.m_style, data.m_weight,
|
|
||||||
data.m_underlined, data.m_faceName, data.m_encoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxFontRefData(int size,
|
|
||||||
int family,
|
|
||||||
int style,
|
|
||||||
int weight,
|
|
||||||
bool underlined,
|
|
||||||
const wxString& faceName,
|
|
||||||
wxFontEncoding encoding)
|
|
||||||
: m_fontId(0)
|
|
||||||
, m_pointSize(size)
|
|
||||||
, m_family(family)
|
|
||||||
, m_style(style)
|
|
||||||
, m_weight(weight)
|
|
||||||
, m_underlined(underlined)
|
|
||||||
, m_faceName(faceName)
|
|
||||||
, m_encoding(encoding)
|
|
||||||
, m_macFontNum(0)
|
|
||||||
, m_macFontSize(0)
|
|
||||||
, m_macFontStyle(0)
|
|
||||||
, m_macATSUFontID(0)
|
|
||||||
{
|
|
||||||
Init(size, family, style, weight, underlined, faceName, encoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~wxFontRefData();
|
|
||||||
void SetNoAntiAliasing( bool no = TRUE ) { m_noAA = no; }
|
|
||||||
bool GetNoAntiAliasing() { return m_noAA; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// common part of all ctors
|
|
||||||
void Init(int size,
|
|
||||||
int family,
|
|
||||||
int style,
|
|
||||||
int weight,
|
|
||||||
bool underlined,
|
|
||||||
const wxString& faceName,
|
|
||||||
wxFontEncoding encoding);
|
|
||||||
|
|
||||||
// font characterstics
|
|
||||||
int m_fontId;
|
|
||||||
int m_pointSize;
|
|
||||||
int m_family;
|
|
||||||
int m_style;
|
|
||||||
int m_weight;
|
|
||||||
bool m_underlined;
|
|
||||||
wxString m_faceName;
|
|
||||||
wxFontEncoding m_encoding;
|
|
||||||
bool m_noAA; // No anti-aliasing
|
|
||||||
|
|
||||||
public:
|
|
||||||
short m_macFontNum;
|
|
||||||
short m_macFontSize;
|
|
||||||
unsigned char m_macFontStyle;
|
|
||||||
wxUint32 m_macATSUFontID;
|
|
||||||
public:
|
|
||||||
void MacFindFont() ;
|
|
||||||
};
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxFont
|
// wxFont
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -174,6 +77,7 @@ public:
|
|||||||
virtual bool GetUnderlined() const;
|
virtual bool GetUnderlined() const;
|
||||||
virtual wxString GetFaceName() const;
|
virtual wxString GetFaceName() const;
|
||||||
virtual wxFontEncoding GetEncoding() const;
|
virtual wxFontEncoding GetEncoding() const;
|
||||||
|
virtual const wxNativeFontInfo *GetNativeFontInfo() const;
|
||||||
|
|
||||||
virtual void SetPointSize(int pointSize);
|
virtual void SetPointSize(int pointSize);
|
||||||
virtual void SetFamily(int family);
|
virtual void SetFamily(int family);
|
||||||
|
@@ -81,6 +81,7 @@ public:
|
|||||||
virtual bool GetUnderlined() const;
|
virtual bool GetUnderlined() const;
|
||||||
virtual wxFontEncoding GetEncoding() const;
|
virtual wxFontEncoding GetEncoding() const;
|
||||||
virtual bool IsFixedWidth() const;
|
virtual bool IsFixedWidth() const;
|
||||||
|
virtual const wxNativeFontInfo *GetNativeFontInfo() const;
|
||||||
|
|
||||||
virtual void SetPointSize(int pointSize);
|
virtual void SetPointSize(int pointSize);
|
||||||
virtual void SetFamily(int family);
|
virtual void SetFamily(int family);
|
||||||
|
@@ -67,7 +67,7 @@ public:
|
|||||||
virtual bool GetUnderlined() const;
|
virtual bool GetUnderlined() const;
|
||||||
virtual wxString GetFaceName() const;
|
virtual wxString GetFaceName() const;
|
||||||
virtual wxFontEncoding GetEncoding() const;
|
virtual wxFontEncoding GetEncoding() const;
|
||||||
virtual wxNativeFontInfo *GetNativeFontInfo() const;
|
virtual const wxNativeFontInfo *GetNativeFontInfo() const;
|
||||||
|
|
||||||
virtual void SetPointSize(int pointSize);
|
virtual void SetPointSize(int pointSize);
|
||||||
virtual void SetFamily(int family);
|
virtual void SetFamily(int family);
|
||||||
|
@@ -72,7 +72,7 @@ public:
|
|||||||
virtual bool GetUnderlined() const;
|
virtual bool GetUnderlined() const;
|
||||||
virtual wxString GetFaceName() const;
|
virtual wxString GetFaceName() const;
|
||||||
virtual wxFontEncoding GetEncoding() const;
|
virtual wxFontEncoding GetEncoding() const;
|
||||||
virtual wxNativeFontInfo* GetNativeFontInfo() const;
|
virtual const wxNativeFontInfo *GetNativeFontInfo() const;
|
||||||
|
|
||||||
virtual void SetPointSize(int pointSize);
|
virtual void SetPointSize(int pointSize);
|
||||||
virtual void SetFamily(int family);
|
virtual void SetFamily(int family);
|
||||||
|
@@ -93,7 +93,7 @@ public:
|
|||||||
virtual bool GetUnderlined(void) const;
|
virtual bool GetUnderlined(void) const;
|
||||||
virtual wxString GetFaceName(void) const;
|
virtual wxString GetFaceName(void) const;
|
||||||
virtual wxFontEncoding GetEncoding(void) const;
|
virtual wxFontEncoding GetEncoding(void) const;
|
||||||
virtual wxNativeFontInfo* GetNativeFontInfo() const;
|
virtual const wxNativeFontInfo* GetNativeFontInfo() const;
|
||||||
|
|
||||||
virtual void SetPointSize(int nPointSize);
|
virtual void SetPointSize(int nPointSize);
|
||||||
virtual void SetFamily(int nFamily);
|
virtual void SetFamily(int nFamily);
|
||||||
|
@@ -71,7 +71,7 @@ public:
|
|||||||
virtual bool GetUnderlined() const;
|
virtual bool GetUnderlined() const;
|
||||||
virtual wxString GetFaceName() const;
|
virtual wxString GetFaceName() const;
|
||||||
virtual wxFontEncoding GetEncoding() const;
|
virtual wxFontEncoding GetEncoding() const;
|
||||||
virtual wxNativeFontInfo *GetNativeFontInfo() const;
|
virtual const wxNativeFontInfo *GetNativeFontInfo() const;
|
||||||
|
|
||||||
virtual bool IsFixedWidth() const;
|
virtual bool IsFixedWidth() const;
|
||||||
|
|
||||||
|
@@ -80,6 +80,11 @@ int wxFont::GetWeight() const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void wxGetNativeFontEncoding(wxFontEncoding, wxNativeEncodingInfo*);
|
void wxGetNativeFontEncoding(wxFontEncoding, wxNativeEncodingInfo*);
|
||||||
|
|
||||||
bool wxFont::Create(int pointSize, int family, int style, int weight, bool underlined, const wxString& faceName, wxFontEncoding encoding)
|
bool wxFont::Create(int pointSize, int family, int style, int weight, bool underlined, const wxString& faceName, wxFontEncoding encoding)
|
||||||
|
@@ -131,25 +131,6 @@ bool wxFontBase::IsFixedWidth() const
|
|||||||
return GetFamily() == wxFONTFAMILY_TELETYPE;
|
return GetFamily() == wxFONTFAMILY_TELETYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxNativeFontInfo *wxFontBase::GetNativeFontInfo() const
|
|
||||||
{
|
|
||||||
#ifdef wxNO_NATIVE_FONTINFO
|
|
||||||
wxNativeFontInfo *fontInfo = new wxNativeFontInfo();
|
|
||||||
|
|
||||||
fontInfo->SetPointSize(GetPointSize());
|
|
||||||
fontInfo->SetFamily((wxFontFamily)GetFamily());
|
|
||||||
fontInfo->SetStyle((wxFontStyle)GetStyle());
|
|
||||||
fontInfo->SetWeight((wxFontWeight)GetWeight());
|
|
||||||
fontInfo->SetUnderlined(GetUnderlined());
|
|
||||||
fontInfo->SetFaceName(GetFaceName());
|
|
||||||
fontInfo->SetEncoding(GetEncoding());
|
|
||||||
|
|
||||||
return fontInfo;
|
|
||||||
#else
|
|
||||||
return (wxNativeFontInfo *)NULL;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxFontBase::DoSetNativeFontInfo(const wxNativeFontInfo& info)
|
void wxFontBase::DoSetNativeFontInfo(const wxNativeFontInfo& info)
|
||||||
{
|
{
|
||||||
#ifdef wxNO_NATIVE_FONTINFO
|
#ifdef wxNO_NATIVE_FONTINFO
|
||||||
@@ -168,11 +149,10 @@ void wxFontBase::DoSetNativeFontInfo(const wxNativeFontInfo& info)
|
|||||||
wxString wxFontBase::GetNativeFontInfoDesc() const
|
wxString wxFontBase::GetNativeFontInfoDesc() const
|
||||||
{
|
{
|
||||||
wxString fontDesc;
|
wxString fontDesc;
|
||||||
wxNativeFontInfo *fontInfo = GetNativeFontInfo();
|
const wxNativeFontInfo *fontInfo = GetNativeFontInfo();
|
||||||
if ( fontInfo )
|
if ( fontInfo )
|
||||||
{
|
{
|
||||||
fontDesc = fontInfo->ToString();
|
fontDesc = fontInfo->ToString();
|
||||||
delete fontInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return fontDesc;
|
return fontDesc;
|
||||||
@@ -181,11 +161,10 @@ wxString wxFontBase::GetNativeFontInfoDesc() const
|
|||||||
wxString wxFontBase::GetNativeFontInfoUserDesc() const
|
wxString wxFontBase::GetNativeFontInfoUserDesc() const
|
||||||
{
|
{
|
||||||
wxString fontDesc;
|
wxString fontDesc;
|
||||||
wxNativeFontInfo *fontInfo = GetNativeFontInfo();
|
const wxNativeFontInfo *fontInfo = GetNativeFontInfo();
|
||||||
if ( fontInfo )
|
if ( fontInfo )
|
||||||
{
|
{
|
||||||
fontDesc = fontInfo->ToUserString();
|
fontDesc = fontInfo->ToUserString();
|
||||||
delete fontInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return fontDesc;
|
return fontDesc;
|
||||||
@@ -362,7 +341,7 @@ wxString wxNativeFontInfo::ToString() const
|
|||||||
|
|
||||||
void wxNativeFontInfo::Init()
|
void wxNativeFontInfo::Init()
|
||||||
{
|
{
|
||||||
pointSize = wxNORMAL_FONT->GetPointSize();
|
pointSize = 0;
|
||||||
family = wxFONTFAMILY_DEFAULT;
|
family = wxFONTFAMILY_DEFAULT;
|
||||||
style = wxFONTSTYLE_NORMAL;
|
style = wxFONTSTYLE_NORMAL;
|
||||||
weight = wxFONTWEIGHT_NORMAL;
|
weight = wxFONTWEIGHT_NORMAL;
|
||||||
|
@@ -790,7 +790,7 @@ bool wxFont::GetNoAntiAliasing()
|
|||||||
return M_FONTDATA->m_noAA;
|
return M_FONTDATA->m_noAA;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxNativeFontInfo *wxFont::GetNativeFontInfo() const
|
const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( Ok(), (wxNativeFontInfo *)NULL, wxT("invalid font") );
|
wxCHECK_MSG( Ok(), (wxNativeFontInfo *)NULL, wxT("invalid font") );
|
||||||
|
|
||||||
@@ -799,7 +799,7 @@ wxNativeFontInfo *wxFont::GetNativeFontInfo() const
|
|||||||
GetInternalFont();
|
GetInternalFont();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return new wxNativeFontInfo(M_FONTDATA->m_nativeFontInfo);
|
return &(M_FONTDATA->m_nativeFontInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxFont::IsFixedWidth() const
|
bool wxFont::IsFixedWidth() const
|
||||||
|
@@ -790,7 +790,7 @@ bool wxFont::GetNoAntiAliasing()
|
|||||||
return M_FONTDATA->m_noAA;
|
return M_FONTDATA->m_noAA;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxNativeFontInfo *wxFont::GetNativeFontInfo() const
|
const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( Ok(), (wxNativeFontInfo *)NULL, wxT("invalid font") );
|
wxCHECK_MSG( Ok(), (wxNativeFontInfo *)NULL, wxT("invalid font") );
|
||||||
|
|
||||||
@@ -799,7 +799,7 @@ wxNativeFontInfo *wxFont::GetNativeFontInfo() const
|
|||||||
GetInternalFont();
|
GetInternalFont();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return new wxNativeFontInfo(M_FONTDATA->m_nativeFontInfo);
|
return &(M_FONTDATA->m_nativeFontInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxFont::IsFixedWidth() const
|
bool wxFont::IsFixedWidth() const
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
// Created: 1998-01-01
|
// Created: 1998-01-01
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Stefan Csomor
|
// Copyright: (c) Stefan Csomor
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
@@ -29,6 +29,106 @@
|
|||||||
IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
|
IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxFontRefData: public wxGDIRefData
|
||||||
|
{
|
||||||
|
friend class WXDLLEXPORT wxFont;
|
||||||
|
public:
|
||||||
|
wxFontRefData()
|
||||||
|
: m_fontId(0)
|
||||||
|
, m_pointSize(10)
|
||||||
|
, m_family(wxDEFAULT)
|
||||||
|
, m_style(wxNORMAL)
|
||||||
|
, m_weight(wxNORMAL)
|
||||||
|
, m_underlined(FALSE)
|
||||||
|
, m_faceName(wxT("Geneva"))
|
||||||
|
, m_encoding(wxFONTENCODING_DEFAULT)
|
||||||
|
, m_macFontNum(0)
|
||||||
|
, m_macFontSize(0)
|
||||||
|
, m_macFontStyle(0)
|
||||||
|
, m_macATSUFontID()
|
||||||
|
{
|
||||||
|
Init(10, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE,
|
||||||
|
wxT("Geneva"), wxFONTENCODING_DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxFontRefData(const wxFontRefData& data)
|
||||||
|
: wxGDIRefData()
|
||||||
|
, m_fontId(data.m_fontId)
|
||||||
|
, m_pointSize(data.m_pointSize)
|
||||||
|
, m_family(data.m_family)
|
||||||
|
, m_style(data.m_style)
|
||||||
|
, m_weight(data.m_weight)
|
||||||
|
, m_underlined(data.m_underlined)
|
||||||
|
, m_faceName(data.m_faceName)
|
||||||
|
, m_encoding(data.m_encoding)
|
||||||
|
, m_macFontNum(data.m_macFontNum)
|
||||||
|
, m_macFontSize(data.m_macFontSize)
|
||||||
|
, m_macFontStyle(data.m_macFontStyle)
|
||||||
|
, m_macATSUFontID(data.m_macATSUFontID)
|
||||||
|
{
|
||||||
|
Init(data.m_pointSize, data.m_family, data.m_style, data.m_weight,
|
||||||
|
data.m_underlined, data.m_faceName, data.m_encoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxFontRefData(int size,
|
||||||
|
int family,
|
||||||
|
int style,
|
||||||
|
int weight,
|
||||||
|
bool underlined,
|
||||||
|
const wxString& faceName,
|
||||||
|
wxFontEncoding encoding)
|
||||||
|
: m_fontId(0)
|
||||||
|
, m_pointSize(size)
|
||||||
|
, m_family(family)
|
||||||
|
, m_style(style)
|
||||||
|
, m_weight(weight)
|
||||||
|
, m_underlined(underlined)
|
||||||
|
, m_faceName(faceName)
|
||||||
|
, m_encoding(encoding)
|
||||||
|
, m_macFontNum(0)
|
||||||
|
, m_macFontSize(0)
|
||||||
|
, m_macFontStyle(0)
|
||||||
|
, m_macATSUFontID(0)
|
||||||
|
{
|
||||||
|
Init(size, family, style, weight, underlined, faceName, encoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~wxFontRefData();
|
||||||
|
void SetNoAntiAliasing( bool no = TRUE ) { m_noAA = no; }
|
||||||
|
bool GetNoAntiAliasing() { return m_noAA; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// common part of all ctors
|
||||||
|
void Init(int size,
|
||||||
|
int family,
|
||||||
|
int style,
|
||||||
|
int weight,
|
||||||
|
bool underlined,
|
||||||
|
const wxString& faceName,
|
||||||
|
wxFontEncoding encoding);
|
||||||
|
|
||||||
|
// font characterstics
|
||||||
|
int m_fontId;
|
||||||
|
int m_pointSize;
|
||||||
|
int m_family;
|
||||||
|
int m_style;
|
||||||
|
int m_weight;
|
||||||
|
bool m_underlined;
|
||||||
|
wxString m_faceName;
|
||||||
|
wxFontEncoding m_encoding;
|
||||||
|
bool m_noAA; // No anti-aliasing
|
||||||
|
|
||||||
|
public:
|
||||||
|
short m_macFontNum;
|
||||||
|
short m_macFontSize;
|
||||||
|
unsigned char m_macFontStyle;
|
||||||
|
wxUint32 m_macATSUFontID;
|
||||||
|
|
||||||
|
wxNativeFontInfo m_info;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void MacFindFont() ;
|
||||||
|
};
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// implementation
|
// implementation
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -313,3 +413,12 @@ bool wxFont::GetNoAntiAliasing()
|
|||||||
return M_FONTDATA->m_noAA;
|
return M_FONTDATA->m_noAA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( Ok(), NULL, wxT("invalid font") );
|
||||||
|
|
||||||
|
M_FONTDATA->m_info.InitFromFont(*this);
|
||||||
|
|
||||||
|
return &(M_FONTDATA->m_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
111
src/mac/font.cpp
111
src/mac/font.cpp
@@ -6,7 +6,7 @@
|
|||||||
// Created: 1998-01-01
|
// Created: 1998-01-01
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Stefan Csomor
|
// Copyright: (c) Stefan Csomor
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
@@ -29,6 +29,106 @@
|
|||||||
IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
|
IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxFontRefData: public wxGDIRefData
|
||||||
|
{
|
||||||
|
friend class WXDLLEXPORT wxFont;
|
||||||
|
public:
|
||||||
|
wxFontRefData()
|
||||||
|
: m_fontId(0)
|
||||||
|
, m_pointSize(10)
|
||||||
|
, m_family(wxDEFAULT)
|
||||||
|
, m_style(wxNORMAL)
|
||||||
|
, m_weight(wxNORMAL)
|
||||||
|
, m_underlined(FALSE)
|
||||||
|
, m_faceName(wxT("Geneva"))
|
||||||
|
, m_encoding(wxFONTENCODING_DEFAULT)
|
||||||
|
, m_macFontNum(0)
|
||||||
|
, m_macFontSize(0)
|
||||||
|
, m_macFontStyle(0)
|
||||||
|
, m_macATSUFontID()
|
||||||
|
{
|
||||||
|
Init(10, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE,
|
||||||
|
wxT("Geneva"), wxFONTENCODING_DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxFontRefData(const wxFontRefData& data)
|
||||||
|
: wxGDIRefData()
|
||||||
|
, m_fontId(data.m_fontId)
|
||||||
|
, m_pointSize(data.m_pointSize)
|
||||||
|
, m_family(data.m_family)
|
||||||
|
, m_style(data.m_style)
|
||||||
|
, m_weight(data.m_weight)
|
||||||
|
, m_underlined(data.m_underlined)
|
||||||
|
, m_faceName(data.m_faceName)
|
||||||
|
, m_encoding(data.m_encoding)
|
||||||
|
, m_macFontNum(data.m_macFontNum)
|
||||||
|
, m_macFontSize(data.m_macFontSize)
|
||||||
|
, m_macFontStyle(data.m_macFontStyle)
|
||||||
|
, m_macATSUFontID(data.m_macATSUFontID)
|
||||||
|
{
|
||||||
|
Init(data.m_pointSize, data.m_family, data.m_style, data.m_weight,
|
||||||
|
data.m_underlined, data.m_faceName, data.m_encoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxFontRefData(int size,
|
||||||
|
int family,
|
||||||
|
int style,
|
||||||
|
int weight,
|
||||||
|
bool underlined,
|
||||||
|
const wxString& faceName,
|
||||||
|
wxFontEncoding encoding)
|
||||||
|
: m_fontId(0)
|
||||||
|
, m_pointSize(size)
|
||||||
|
, m_family(family)
|
||||||
|
, m_style(style)
|
||||||
|
, m_weight(weight)
|
||||||
|
, m_underlined(underlined)
|
||||||
|
, m_faceName(faceName)
|
||||||
|
, m_encoding(encoding)
|
||||||
|
, m_macFontNum(0)
|
||||||
|
, m_macFontSize(0)
|
||||||
|
, m_macFontStyle(0)
|
||||||
|
, m_macATSUFontID(0)
|
||||||
|
{
|
||||||
|
Init(size, family, style, weight, underlined, faceName, encoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~wxFontRefData();
|
||||||
|
void SetNoAntiAliasing( bool no = TRUE ) { m_noAA = no; }
|
||||||
|
bool GetNoAntiAliasing() { return m_noAA; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// common part of all ctors
|
||||||
|
void Init(int size,
|
||||||
|
int family,
|
||||||
|
int style,
|
||||||
|
int weight,
|
||||||
|
bool underlined,
|
||||||
|
const wxString& faceName,
|
||||||
|
wxFontEncoding encoding);
|
||||||
|
|
||||||
|
// font characterstics
|
||||||
|
int m_fontId;
|
||||||
|
int m_pointSize;
|
||||||
|
int m_family;
|
||||||
|
int m_style;
|
||||||
|
int m_weight;
|
||||||
|
bool m_underlined;
|
||||||
|
wxString m_faceName;
|
||||||
|
wxFontEncoding m_encoding;
|
||||||
|
bool m_noAA; // No anti-aliasing
|
||||||
|
|
||||||
|
public:
|
||||||
|
short m_macFontNum;
|
||||||
|
short m_macFontSize;
|
||||||
|
unsigned char m_macFontStyle;
|
||||||
|
wxUint32 m_macATSUFontID;
|
||||||
|
|
||||||
|
wxNativeFontInfo m_info;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void MacFindFont() ;
|
||||||
|
};
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// implementation
|
// implementation
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -313,3 +413,12 @@ bool wxFont::GetNoAntiAliasing()
|
|||||||
return M_FONTDATA->m_noAA;
|
return M_FONTDATA->m_noAA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( Ok(), NULL, wxT("invalid font") );
|
||||||
|
|
||||||
|
M_FONTDATA->m_info.InitFromFont(*this);
|
||||||
|
|
||||||
|
return &(M_FONTDATA->m_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -74,6 +74,8 @@ private:
|
|||||||
wxMGLFontLibrary *m_library;
|
wxMGLFontLibrary *m_library;
|
||||||
bool m_valid;
|
bool m_valid;
|
||||||
|
|
||||||
|
wxNativeFontInfo m_info;
|
||||||
|
|
||||||
friend class wxFont;
|
friend class wxFont;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -264,6 +266,14 @@ bool wxFont::IsFixedWidth() const
|
|||||||
return (bool)(M_FONTDATA->m_library->GetFamily()->GetInfo()->isFixed);
|
return (bool)(M_FONTDATA->m_library->GetFamily()->GetInfo()->isFixed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( Ok(), NULL, wxT("invalid font") );
|
||||||
|
|
||||||
|
M_FONTDATA->m_info.InitFromFont(*this);
|
||||||
|
|
||||||
|
return &(M_FONTDATA->m_info);
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// change font attributes
|
// change font attributes
|
||||||
|
@@ -485,14 +485,14 @@ wxFontEncoding wxFont::GetEncoding() const
|
|||||||
return M_FONTDATA->m_encoding;
|
return M_FONTDATA->m_encoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxNativeFontInfo *wxFont::GetNativeFontInfo() const
|
const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( Ok(), (wxNativeFontInfo *)NULL, wxT("invalid font") );
|
wxCHECK_MSG( Ok(), (wxNativeFontInfo *)NULL, wxT("invalid font") );
|
||||||
|
|
||||||
if(M_FONTDATA->m_nativeFontInfo.GetXFontName().IsEmpty())
|
if(M_FONTDATA->m_nativeFontInfo.GetXFontName().IsEmpty())
|
||||||
GetInternalFont();
|
GetInternalFont();
|
||||||
|
|
||||||
return new wxNativeFontInfo(M_FONTDATA->m_nativeFontInfo);
|
return &(M_FONTDATA->m_nativeFontInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -948,12 +948,10 @@ wxFontEncoding wxFont::GetEncoding() const
|
|||||||
return M_FONTDATA->GetEncoding();
|
return M_FONTDATA->GetEncoding();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxNativeFontInfo *wxFont::GetNativeFontInfo() const
|
const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
|
||||||
{
|
{
|
||||||
if ( M_FONTDATA->HasNativeFontInfo() )
|
return M_FONTDATA->HasNativeFontInfo() ? &(M_FONTDATA->GetNativeFontInfo())
|
||||||
return new wxNativeFontInfo(M_FONTDATA->GetNativeFontInfo());
|
: NULL;
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxFont::IsFixedWidth() const
|
bool wxFont::IsFixedWidth() const
|
||||||
|
@@ -234,36 +234,20 @@ wxFontEncoding wxGetFontEncFromCharSet(int cs)
|
|||||||
|
|
||||||
void wxFillLogFont(LOGFONT *logFont, const wxFont *font)
|
void wxFillLogFont(LOGFONT *logFont, const wxFont *font)
|
||||||
{
|
{
|
||||||
|
wxNativeFontInfo fi;
|
||||||
|
|
||||||
// maybe we already have LOGFONT for this font?
|
// maybe we already have LOGFONT for this font?
|
||||||
wxNativeFontInfo *fontinfo = font->GetNativeFontInfo();
|
const wxNativeFontInfo *pFI = font->GetNativeFontInfo();
|
||||||
if ( !fontinfo )
|
if ( !pFI )
|
||||||
{
|
{
|
||||||
// use wxNativeFontInfo methods to build a LOGFONT for this font
|
// use wxNativeFontInfo methods to build a LOGFONT for this font
|
||||||
fontinfo = new wxNativeFontInfo;
|
fi.InitFromFont(*font);
|
||||||
|
|
||||||
// translate all font parameters
|
pFI = &fi;
|
||||||
fontinfo->SetStyle((wxFontStyle)font->GetStyle());
|
|
||||||
fontinfo->SetWeight((wxFontWeight)font->GetWeight());
|
|
||||||
fontinfo->SetUnderlined(font->GetUnderlined());
|
|
||||||
fontinfo->SetPointSize(font->GetPointSize());
|
|
||||||
|
|
||||||
// set the family/facename
|
|
||||||
fontinfo->SetFamily((wxFontFamily)font->GetFamily());
|
|
||||||
wxString facename = font->GetFaceName();
|
|
||||||
if ( !facename.empty() )
|
|
||||||
{
|
|
||||||
fontinfo->SetFaceName(facename);
|
|
||||||
}
|
|
||||||
|
|
||||||
// deal with encoding now (it may override the font family and facename
|
|
||||||
// so do it after setting them)
|
|
||||||
fontinfo->SetEncoding(font->GetEncoding());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// transfer all the data to LOGFONT
|
// transfer all the data to LOGFONT
|
||||||
*logFont = fontinfo->lf;
|
*logFont = pFI->lf;
|
||||||
|
|
||||||
delete fontinfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFont wxCreateFontFromLogFont(const LOGFONT *logFont)
|
wxFont wxCreateFontFromLogFont(const LOGFONT *logFont)
|
||||||
|
@@ -1140,11 +1140,10 @@ wxFontEncoding wxFont::GetEncoding() const
|
|||||||
return M_FONTDATA->GetEncoding();
|
return M_FONTDATA->GetEncoding();
|
||||||
} // end of wxFont::GetEncoding
|
} // end of wxFont::GetEncoding
|
||||||
|
|
||||||
wxNativeFontInfo* wxFont::GetNativeFontInfo() const
|
const wxNativeFontInfo* wxFont::GetNativeFontInfo() const
|
||||||
{
|
{
|
||||||
if (M_FONTDATA->HasNativeFontInfo())
|
return M_FONTDATA->HasNativeFontInfo() ? &(M_FONTDATA->GetNativeFontInfo())
|
||||||
return new wxNativeFontInfo(M_FONTDATA->GetNativeFontInfo());
|
: NULL;
|
||||||
return 0;
|
|
||||||
} // end of wxFont::GetNativeFontInfo
|
} // end of wxFont::GetNativeFontInfo
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@@ -752,7 +752,7 @@ bool wxFont::GetNoAntiAliasing()
|
|||||||
return M_FONTDATA->m_noAA;
|
return M_FONTDATA->m_noAA;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxNativeFontInfo *wxFont::GetNativeFontInfo() const
|
const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( Ok(), (wxNativeFontInfo *)NULL, wxT("invalid font") );
|
wxCHECK_MSG( Ok(), (wxNativeFontInfo *)NULL, wxT("invalid font") );
|
||||||
|
|
||||||
@@ -762,7 +762,7 @@ wxNativeFontInfo *wxFont::GetNativeFontInfo() const
|
|||||||
GetInternalFont();
|
GetInternalFont();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return new wxNativeFontInfo(M_FONTDATA->m_nativeFontInfo);
|
return &(M_FONTDATA->m_nativeFontInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxFont::IsFixedWidth() const
|
bool wxFont::IsFixedWidth() const
|
||||||
|
Reference in New Issue
Block a user