#pragma implementation "font.h"
#endif
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
#include "wx/defs.h"
#ifdef __VMS
IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
+#if wxCHECK_MOTIF_VERSION( 2, 0 ) && !wxCHECK_LESSTIF()
+ #define wxUSE_RENDER_TABLE 1
+#else
+ #define wxUSE_RENDER_TABLE 0
+#endif
+
// ----------------------------------------------------------------------------
// private classes
// ----------------------------------------------------------------------------
~wxXFont();
WXFontStructPtr m_fontStruct; // XFontStruct
+#if !wxUSE_RENDER_TABLE
WXFontList m_fontList; // Motif XmFontList
-#if wxCHECK_MOTIF_VERSION( 2, 0 )
+#else // if wxUSE_RENDER_TABLE
WXRenderTable m_renderTable; // Motif XmRenderTable
#endif
WXDisplay* m_display; // XDisplay
class wxFontRefData: public wxGDIRefData
{
-friend class wxFont;
+ friend class wxFont;
public:
wxFontRefData(int size = wxDEFAULT,
int family = wxDEFAULT,
int style = wxDEFAULT,
int weight = wxDEFAULT,
- bool underlined = FALSE,
+ bool underlined = false,
const wxString& faceName = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
{
wxXFont::wxXFont()
{
m_fontStruct = (WXFontStructPtr) 0;
+#if !wxUSE_RENDER_TABLE
m_fontList = (WXFontList) 0;
-#if wxCHECK_MOTIF_VERSION( 2, 0 )
+#else // if wxUSE_RENDER_TABLE
m_renderTable = (WXRenderTable) 0;
#endif
m_display = (WXDisplay*) 0;
wxXFont::~wxXFont()
{
- XmFontList fontList = (XmFontList) m_fontList;
- XmFontListFree (fontList);
-
-#if wxCHECK_MOTIF_VERSION( 2, 0 ) && !wxCHECK_LESSTIF()
- XmRenderTable renderTable = (XmRenderTable) m_renderTable;
- XmRenderTableFree (renderTable);
+#if !wxUSE_RENDER_TABLE
+ if (m_fontList)
+ XmFontListFree ((XmFontList) m_fontList);
+ m_fontList = NULL;
+#else // if wxUSE_RENDER_TABLE
+ if (m_renderTable)
+ XmRenderTableFree ((XmRenderTable) m_renderTable);
+ m_renderTable = NULL;
#endif
// TODO: why does freeing the font produce a segv???
// Note that XFreeFont wasn't called in wxWin 1.68 either.
+ // MBN: probably some interaction with fonts being still
+ // in use in some widgets...
// XFontStruct* fontStruct = (XFontStruct*) m_fontStruct;
// XFreeFont((Display*) m_display, fontStruct);
}
RealizeResource();
- return TRUE;
+ return true;
}
bool wxFont::Create(const wxString& fontname, wxFontEncoding enc)
if( !fontname )
{
*this = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT);
- return TRUE;
+ return true;
}
m_refData = new wxFontRefData();
}
//else: unknown encoding - may be give a warning here?
else
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
wxFont::~wxFont()
bool wxFont::GetUnderlined() const
{
- wxCHECK_MSG( Ok(), FALSE, wxT("invalid font") );
+ wxCHECK_MSG( Ok(), false, wxT("invalid font") );
return M_FONTDATA->m_underlined;
}
return M_FONTDATA->m_encoding;
}
-wxNativeFontInfo *wxFont::GetNativeFontInfo() const
+const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
{
wxCHECK_MSG( Ok(), (wxNativeFontInfo *)NULL, wxT("invalid font") );
if(M_FONTDATA->m_nativeFontInfo.GetXFontName().IsEmpty())
GetInternalFont();
- return new wxNativeFontInfo(M_FONTDATA->m_nativeFontInfo);
+ return &(M_FONTDATA->m_nativeFontInfo);
}
// ----------------------------------------------------------------------------
f->m_fontStruct = (WXFontStructPtr)font;
f->m_display = ( display ? display : wxGetDisplay() );
f->m_scale = intScale;
- f->m_fontList = XmFontListCreate ((XFontStruct*) font, XmSTRING_DEFAULT_CHARSET);
+
M_FONTDATA->m_fonts.Append(f);
-#if wxCHECK_MOTIF_VERSION( 2, 0 ) && !wxCHECK_LESSTIF()
+#if !wxUSE_RENDER_TABLE
+ f->m_fontList = XmFontListCreate ((XFontStruct*) font, XmSTRING_DEFAULT_CHARSET);
+#else // if wxUSE_RENDER_TABLE
XmRendition rendition;
XmRenderTable renderTable;
Arg args[5];
WXFontList wxFont::GetFontList(double scale, WXDisplay* display) const
{
+#if !wxUSE_RENDER_TABLE
wxXFont* f = GetInternalFont(scale, display);
return (f ? f->m_fontList : (WXFontList) 0);
+#else
+ return NULL;
+#endif
}
+ // declared in the header, can't use wxUSE_RENDER_TABLE
#if wxCHECK_MOTIF_VERSION( 2, 0 )
WXRenderTable wxFont::GetRenderTable(WXDisplay* display) const
{
+#if wxUSE_RENDER_TABLE
wxXFont* f = GetInternalFont(1.0, display);
return (f ? f->m_renderTable : (WXFontList) 0);
+#else
+ return NULL;
+#endif
}
#endif
WXFontType wxFont::GetFontType(WXDisplay* display) const
{
-#if wxCHECK_MOTIF_VERSION( 2, 0 ) && !wxCHECK_LESSTIF()
+#if wxUSE_RENDER_TABLE
return Ok() ? GetRenderTable(display) : NULL;
#else
return Ok() ? GetFontList(1.0, display) : NULL;
#endif
}
+WXFontType wxFont::GetFontTypeC(WXDisplay* display) const
+{
+#if wxUSE_RENDER_TABLE
+ return Ok() ? GetRenderTable(display) : NULL;
+#else
+ return Ok() ? XmFontListCopy( (XmFontList)GetFontList(1.0, display) ) : NULL;
+#endif
+}
+
/*static*/ WXString wxFont::GetFontTag()
{
-#if wxCHECK_MOTIF_VERSION( 2, 0 ) && !wxCHECK_LESSTIF()
+#if wxUSE_RENDER_TABLE
return (WXString)XmNrenderTable;
#else
return (WXString)XmNfontList;