don't expose M_FONTDATA in public header

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43547 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2006-11-20 16:43:55 +00:00
parent cd4e5a4998
commit d04f9b8e31
3 changed files with 76 additions and 275 deletions

View File

@@ -29,85 +29,12 @@
#include "wx/app.h"
#endif
#include "wx/fontutil.h"
#include "wx/dfb/private.h"
#include "wx/private/fontmgr.h"
// ----------------------------------------------------------------------------
// wxFontRefData
// ----------------------------------------------------------------------------
// FIXME: for now, always use single font
static wxIDirectFBFontPtr gs_font = NULL;
static unsigned gs_fontRefCnt = 0;
class wxFontRefData : public wxObjectRefData
{
public:
wxFontRefData(int size = wxDEFAULT,
int family = wxDEFAULT,
int style = wxDEFAULT,
int weight = wxDEFAULT,
bool underlined = false,
const wxString& faceName = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
{
if ( family == wxDEFAULT )
family = wxSWISS;
if ( style == wxDEFAULT )
style = wxNORMAL;
if ( weight == wxDEFAULT )
weight = wxNORMAL;
if ( size == wxDEFAULT )
size = 12;
m_info.family = (wxFontFamily)family;
m_info.faceName = faceName;
m_info.style = (wxFontStyle)style;
m_info.weight = (wxFontWeight)weight;
m_info.pointSize = size;
m_info.underlined = underlined;
m_info.encoding = encoding;
// FIXME: always use default font for now
if ( !gs_font )
{
DFBFontDescription desc;
desc.flags = (DFBFontDescriptionFlags)0;
wxIDirectFBFontPtr f(wxIDirectFB::Get()->CreateFont(NULL, &desc));
if ( f )
gs_font = f;
}
if ( gs_font ) // the above may fail
{
gs_fontRefCnt++;
m_font = gs_font;
}
}
wxFontRefData(const wxFontRefData& data)
{
m_info = data.m_info;
m_font = data.m_font;
}
~wxFontRefData()
{
if ( m_font )
{
m_font.Reset();
// FIXME
if ( --gs_fontRefCnt == 0 )
gs_font = NULL;
}
}
wxNativeFontInfo m_info;
wxIDirectFBFontPtr m_font;
};
typedef wxFontMgrFontRefData wxFontRefData;
#define M_FONTDATA ((wxFontRefData*)m_refData)
// ----------------------------------------------------------------------------
// wxFont
// ----------------------------------------------------------------------------
@@ -148,53 +75,55 @@ wxObjectRefData *wxFont::CloneRefData(const wxObjectRefData *data) const
// accessors
// ----------------------------------------------------------------------------
wxIDirectFBFontPtr wxFont::GetDirectFBFont() const
wxIDirectFBFontPtr wxFont::GetDirectFBFont(bool antialiased) const
{
wxCHECK_MSG( Ok(), NULL, wxT("invalid font") );
return M_FONTDATA->m_font;
// we don't support DC scaling yet, so use scale=1
wxFontInstance *i = M_FONTDATA->GetFontInstance(1.0, antialiased);
return i ? i->GetDirectFBFont() : wxIDirectFBFontPtr();
}
int wxFont::GetPointSize() const
{
wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
return M_FONTDATA->m_info.pointSize;
return M_FONTDATA->GetPointSize();
}
wxString wxFont::GetFaceName() const
{
wxCHECK_MSG( Ok(), wxEmptyString, wxT("invalid font") );
return M_FONTDATA->m_info.faceName;
return M_FONTDATA->GetFaceName();
}
int wxFont::GetFamily() const
{
wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
return M_FONTDATA->m_info.family;
return M_FONTDATA->GetFamily();
}
int wxFont::GetStyle() const
{
wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
return M_FONTDATA->m_info.style;
return M_FONTDATA->GetStyle();
}
int wxFont::GetWeight() const
{
wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
return M_FONTDATA->m_info.weight;
return M_FONTDATA->GetWeight();
}
bool wxFont::GetUnderlined() const
{
wxCHECK_MSG( Ok(), false, wxT("invalid font") );
return M_FONTDATA->m_info.underlined;
return M_FONTDATA->GetUnderlined();
}
@@ -202,21 +131,28 @@ wxFontEncoding wxFont::GetEncoding() const
{
wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT, wxT("invalid font") );
return M_FONTDATA->m_info.encoding;
return M_FONTDATA->GetEncoding();
}
bool wxFont::IsFixedWidth() const
{
wxCHECK_MSG( Ok(), false, wxT("invalid font") );
return true; // FIXME_DFB
return M_FONTDATA->IsFixedWidth();
}
const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
{
wxCHECK_MSG( Ok(), NULL, wxT("invalid font") );
return &(M_FONTDATA->m_info);
return M_FONTDATA->GetNativeFontInfo();
}
bool wxFont::GetNoAntiAliasing() const
{
wxCHECK_MSG( Ok(), false, wxT("invalid font") );
return M_FONTDATA->GetNoAntiAliasing();
}
// ----------------------------------------------------------------------------
@@ -226,50 +162,48 @@ const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
void wxFont::SetPointSize(int pointSize)
{
AllocExclusive();
M_FONTDATA->m_info.pointSize = pointSize;
M_FONTDATA->SetPointSize(pointSize);
}
void wxFont::SetFamily(int family)
{
AllocExclusive();
M_FONTDATA->m_info.family = (wxFontFamily)family;
M_FONTDATA->SetFamily(family);
}
void wxFont::SetStyle(int style)
{
AllocExclusive();
M_FONTDATA->m_info.style = (wxFontStyle)style;
M_FONTDATA->SetStyle(style);
}
void wxFont::SetWeight(int weight)
{
AllocExclusive();
M_FONTDATA->m_info.weight = (wxFontWeight)weight;
M_FONTDATA->SetWeight(weight);
}
bool wxFont::SetFaceName(const wxString& faceName)
{
AllocExclusive();
M_FONTDATA->m_info.faceName = faceName;
M_FONTDATA->SetFaceName(faceName);
return wxFontBase::SetFaceName(faceName);
}
void wxFont::SetUnderlined(bool underlined)
{
AllocExclusive();
M_FONTDATA->m_info.underlined = underlined;
M_FONTDATA->SetUnderlined(underlined);
}
void wxFont::SetEncoding(wxFontEncoding encoding)
{
AllocExclusive();
M_FONTDATA->m_info.encoding = encoding;
M_FONTDATA->SetEncoding(encoding);
}
void wxFont::SetNoAntiAliasing(bool no)
{
AllocExclusive();
M_FONTDATA->SetNoAntiAliasing(no);
}