wxMotif::wxFont supports encodings too (and shares 99% of font code with wxGTK)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3779 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
d391a34510
commit
93ccaed869
@ -334,7 +334,7 @@ utilsres.cpp R
|
||||
wave.cpp R
|
||||
window.cpp R
|
||||
|
||||
gsockmot.cpp X
|
||||
gsockmot.c X S
|
||||
accel.cpp X
|
||||
app.cpp X
|
||||
bitmap.cpp X
|
||||
|
@ -13,120 +13,93 @@
|
||||
#define _WX_FONT_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "font.h"
|
||||
#pragma interface "font.h"
|
||||
#endif
|
||||
|
||||
#include "wx/gdiobj.h"
|
||||
#include "wx/list.h"
|
||||
|
||||
class WXDLLEXPORT wxFont;
|
||||
|
||||
// For every wxFont, there must be a font for each display and scale requested.
|
||||
// So these objects are stored in wxFontRefData::m_fonts
|
||||
class WXDLLEXPORT wxXFont: public wxObject
|
||||
{
|
||||
public:
|
||||
wxXFont();
|
||||
~wxXFont();
|
||||
|
||||
WXFontStructPtr m_fontStruct; // XFontStruct
|
||||
WXFontList m_fontList; // Motif XmFontList
|
||||
WXDisplay* m_display; // XDisplay
|
||||
int m_scale; // Scale * 100
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxFontRefData: public wxGDIRefData
|
||||
{
|
||||
friend class WXDLLEXPORT wxFont;
|
||||
public:
|
||||
wxFontRefData();
|
||||
wxFontRefData(const wxFontRefData& data);
|
||||
~wxFontRefData();
|
||||
protected:
|
||||
int m_pointSize;
|
||||
int m_family;
|
||||
int m_style;
|
||||
int m_weight;
|
||||
bool m_underlined;
|
||||
wxString m_faceName;
|
||||
|
||||
// A list of wxXFonts
|
||||
wxList m_fonts;
|
||||
};
|
||||
|
||||
#define M_FONTDATA ((wxFontRefData *)m_refData)
|
||||
|
||||
WXDLLEXPORT_DATA(extern const char*) wxEmptyString;
|
||||
|
||||
// Font
|
||||
class WXDLLEXPORT wxFont: public wxGDIObject
|
||||
class wxFont : public wxFontBase
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxFont)
|
||||
public:
|
||||
wxFont();
|
||||
wxFont(int pointSize, int family, int style, int weight, bool underlined = FALSE, const wxString& faceName = wxEmptyString);
|
||||
inline wxFont(const wxFont& font) { Ref(font); }
|
||||
// ctors and such
|
||||
wxFont() { Init(); }
|
||||
wxFont(const wxFont& font) { Init(); Ref(font); }
|
||||
|
||||
~wxFont();
|
||||
wxFont(int size,
|
||||
int family,
|
||||
int style,
|
||||
int weight,
|
||||
bool underlined = FALSE,
|
||||
const wxString& face = wxEmptyString,
|
||||
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
|
||||
{
|
||||
Init();
|
||||
|
||||
bool Create(int pointSize, int family, int style, int weight, bool underlined = FALSE, const wxString& faceName = wxEmptyString);
|
||||
(void)Create(size, family, style, weight, underlined, face, encoding);
|
||||
}
|
||||
|
||||
virtual bool Ok() const { return (m_refData != NULL) ; }
|
||||
bool Create(int size,
|
||||
int family,
|
||||
int style,
|
||||
int weight,
|
||||
bool underlined = FALSE,
|
||||
const wxString& face = wxEmptyString,
|
||||
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
||||
|
||||
inline int GetPointSize() const { return M_FONTDATA->m_pointSize; }
|
||||
inline int GetFamily() const { return M_FONTDATA->m_family; }
|
||||
inline int GetStyle() const { return M_FONTDATA->m_style; }
|
||||
inline int GetWeight() const { return M_FONTDATA->m_weight; }
|
||||
wxString GetFamilyString() const ;
|
||||
wxString GetFaceName() const ;
|
||||
wxString GetStyleString() const ;
|
||||
wxString GetWeightString() const ;
|
||||
inline bool GetUnderlined() const { return M_FONTDATA->m_underlined; }
|
||||
virtual ~wxFont();
|
||||
|
||||
void SetPointSize(int pointSize);
|
||||
void SetFamily(int family);
|
||||
void SetStyle(int style);
|
||||
void SetWeight(int weight);
|
||||
void SetFaceName(const wxString& faceName);
|
||||
void SetUnderlined(bool underlined);
|
||||
// assignment
|
||||
wxFont& operator=(const wxFont& font);
|
||||
|
||||
inline wxFont& operator = (const wxFont& font) { if (*this == font) return (*this); Ref(font); return *this; }
|
||||
inline bool operator == (const wxFont& font) const { return m_refData == font.m_refData; }
|
||||
inline bool operator != (const wxFont& font) const { return m_refData != font.m_refData; }
|
||||
// implement base class pure virtuals
|
||||
virtual int GetPointSize() const;
|
||||
virtual int GetFamily() const;
|
||||
virtual int GetStyle() const;
|
||||
virtual int GetWeight() const;
|
||||
virtual bool GetUnderlined() const;
|
||||
virtual wxString GetFaceName() const;
|
||||
virtual wxFontEncoding GetEncoding() const;
|
||||
|
||||
// Implementation
|
||||
virtual void SetPointSize(int pointSize);
|
||||
virtual void SetFamily(int family);
|
||||
virtual void SetStyle(int style);
|
||||
virtual void SetWeight(int weight);
|
||||
virtual void SetFaceName(const wxString& faceName);
|
||||
virtual void SetUnderlined(bool underlined);
|
||||
virtual void SetEncoding(wxFontEncoding encoding);
|
||||
|
||||
// Find an existing, or create a new, XFontStruct
|
||||
// based on this wxFont and the given scale. Append the
|
||||
// font to list in the private data for future reference.
|
||||
// Implementation
|
||||
|
||||
// TODO This is a fairly basic implementation, that doesn't
|
||||
// allow for different facenames, and also doesn't do a mapping
|
||||
// between 'standard' facenames (e.g. Arial, Helvetica, Times Roman etc.)
|
||||
// and the fonts that are available on a particular system.
|
||||
// Maybe we need to scan the user's machine to build up a profile
|
||||
// of the fonts and a mapping file.
|
||||
// Find an existing, or create a new, XFontStruct
|
||||
// based on this wxFont and the given scale. Append the
|
||||
// font to list in the private data for future reference.
|
||||
|
||||
// Return font struct, and optionally the Motif font list
|
||||
wxXFont* GetInternalFont(double scale = 1.0, WXDisplay* display = NULL) const;
|
||||
// TODO This is a fairly basic implementation, that doesn't
|
||||
// allow for different facenames, and also doesn't do a mapping
|
||||
// between 'standard' facenames (e.g. Arial, Helvetica, Times Roman etc.)
|
||||
// and the fonts that are available on a particular system.
|
||||
// Maybe we need to scan the user's machine to build up a profile
|
||||
// of the fonts and a mapping file.
|
||||
|
||||
// These two are helper functions for convenient access of the above.
|
||||
inline WXFontStructPtr GetFontStruct(double scale = 1.0, WXDisplay* display = NULL) const
|
||||
{
|
||||
wxXFont* f = GetInternalFont(scale, display);
|
||||
return (f ? f->m_fontStruct : (WXFontStructPtr) 0);
|
||||
}
|
||||
WXFontList GetFontList(double scale = 1.0, WXDisplay* display = NULL) const
|
||||
{
|
||||
wxXFont* f = GetInternalFont(scale, display);
|
||||
return (f ? f->m_fontList : (WXFontList) 0);
|
||||
}
|
||||
// Return font struct, and optionally the Motif font list
|
||||
class wxXFont* GetInternalFont(double scale = 1.0,
|
||||
WXDisplay* display = NULL) const;
|
||||
|
||||
// These two are helper functions for convenient access of the above.
|
||||
WXFontStructPtr GetFontStruct(double scale = 1.0,
|
||||
WXDisplay* display = NULL) const;
|
||||
WXFontList GetFontList(double scale = 1.0,
|
||||
WXDisplay* display = NULL) const;
|
||||
|
||||
WXFontStructPtr LoadQueryFont(int pointSize, int family, int style,
|
||||
int weight, bool underlined) const;
|
||||
protected:
|
||||
bool RealizeResource();
|
||||
void Unshare();
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
// VZ: IMHO, we don't need it at all...
|
||||
bool RealizeResource() { return TRUE; }
|
||||
void Unshare();
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxFont)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -363,5 +363,30 @@ void wxAllocColor(Display *display,Colormap colormap,XColor *xcolor);
|
||||
|
||||
#endif //__X__
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// font-related functions (X and GTK)
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if defined(__X__) || defined(__WXGTK__)
|
||||
|
||||
#ifdef __X__
|
||||
typedef XFontStruct *wxNativeFont;
|
||||
#else // GDK
|
||||
typedef GdkFont *wxNativeFont;
|
||||
#endif
|
||||
|
||||
#include "wx/font.h" // for wxFontEncoding
|
||||
|
||||
// returns the handle of the nearest available font or 0
|
||||
extern wxNativeFont wxLoadQueryNearestFont(int pointSize,
|
||||
int family,
|
||||
int style,
|
||||
int weight,
|
||||
bool underlined,
|
||||
const wxString &facename,
|
||||
wxFontEncoding encoding);
|
||||
|
||||
#endif // X || GTK
|
||||
|
||||
#endif
|
||||
// _WX_UTILSH__
|
||||
|
218
src/gtk/font.cpp
218
src/gtk/font.cpp
@ -41,9 +41,6 @@
|
||||
// private functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// returns TRUE if there are any fonts matching this font spec
|
||||
static bool wxTestFontSpec(const wxString& fontspec);
|
||||
|
||||
static GdkFont *wxLoadQueryFont( int pointSize,
|
||||
int family,
|
||||
int style,
|
||||
@ -450,221 +447,6 @@ GdkFont *wxFont::GetInternalFont( float scale ) const
|
||||
// local utilities to find a X font
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// returns TRUE if there are any fonts matching this font spec
|
||||
static bool wxTestFontSpec(const wxString& fontSpec)
|
||||
{
|
||||
GdkFont *test = gdk_font_load( wxConvCurrent->cWX2MB(fontSpec) );
|
||||
if ( test )
|
||||
{
|
||||
gdk_font_unref( test );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static GdkFont *wxLoadQueryFont( int pointSize,
|
||||
int family,
|
||||
int style,
|
||||
int weight,
|
||||
bool WXUNUSED(underlined),
|
||||
const wxString &facename,
|
||||
wxFontEncoding encoding )
|
||||
{
|
||||
wxString xfamily;
|
||||
switch (family)
|
||||
{
|
||||
case wxDECORATIVE: xfamily = _T("lucida"); break;
|
||||
case wxROMAN: xfamily = _T("times"); break;
|
||||
case wxMODERN: xfamily = _T("courier"); break;
|
||||
case wxSWISS: xfamily = _T("helvetica"); break;
|
||||
case wxTELETYPE: xfamily = _T("lucidatypewriter"); break;
|
||||
case wxSCRIPT: xfamily = _T("utopia"); break;
|
||||
default: xfamily = _T("*");
|
||||
}
|
||||
|
||||
wxString fontSpec;
|
||||
if (!facename.IsEmpty())
|
||||
{
|
||||
fontSpec.Printf(_T("-*-%s-*-*-normal-*-*-*-*-*-*-*-*-*"),
|
||||
facename.c_str());
|
||||
|
||||
if ( wxTestFontSpec(fontSpec) )
|
||||
{
|
||||
xfamily = facename;
|
||||
}
|
||||
//else: no such family, use default one instead
|
||||
}
|
||||
|
||||
wxString xstyle;
|
||||
switch (style)
|
||||
{
|
||||
case wxITALIC: xstyle = _T("i"); break;
|
||||
case wxSLANT: xstyle = _T("o"); break;
|
||||
case wxNORMAL: xstyle = _T("r"); break;
|
||||
default: xstyle = _T("*"); break;
|
||||
}
|
||||
|
||||
wxString xweight;
|
||||
switch (weight)
|
||||
{
|
||||
case wxBOLD: xweight = _T("bold"); break;
|
||||
case wxLIGHT:
|
||||
case wxNORMAL: xweight = _T("medium"); break;
|
||||
default: xweight = _T("*"); break;
|
||||
}
|
||||
|
||||
wxString xregistry, xencoding;
|
||||
if ( encoding == wxFONTENCODING_DEFAULT )
|
||||
{
|
||||
// use the apps default
|
||||
encoding = wxFont::GetDefaultEncoding();
|
||||
}
|
||||
|
||||
bool test = TRUE; // should we test for availability of encoding?
|
||||
switch ( encoding )
|
||||
{
|
||||
case wxFONTENCODING_ISO8859_1:
|
||||
case wxFONTENCODING_ISO8859_2:
|
||||
case wxFONTENCODING_ISO8859_3:
|
||||
case wxFONTENCODING_ISO8859_4:
|
||||
case wxFONTENCODING_ISO8859_5:
|
||||
case wxFONTENCODING_ISO8859_6:
|
||||
case wxFONTENCODING_ISO8859_7:
|
||||
case wxFONTENCODING_ISO8859_8:
|
||||
case wxFONTENCODING_ISO8859_9:
|
||||
case wxFONTENCODING_ISO8859_10:
|
||||
case wxFONTENCODING_ISO8859_11:
|
||||
case wxFONTENCODING_ISO8859_13:
|
||||
case wxFONTENCODING_ISO8859_14:
|
||||
case wxFONTENCODING_ISO8859_15:
|
||||
{
|
||||
int cp = encoding - wxFONTENCODING_ISO8859_1 + 1;
|
||||
xregistry = _T("iso8859");
|
||||
xencoding.Printf(_T("%d"), cp);
|
||||
}
|
||||
break;
|
||||
|
||||
case wxFONTENCODING_KOI8:
|
||||
xregistry = _T("koi8");
|
||||
if ( wxTestFontSpec(_T("-*-*-*-*-*-*-*-*-*-*-*-*-koi8-1")) )
|
||||
{
|
||||
xencoding = _T("1");
|
||||
|
||||
// test passed, no need to do it once more
|
||||
test = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
xencoding = _T("*");
|
||||
}
|
||||
break;
|
||||
|
||||
case wxFONTENCODING_CP1250:
|
||||
case wxFONTENCODING_CP1251:
|
||||
case wxFONTENCODING_CP1252:
|
||||
{
|
||||
int cp = encoding - wxFONTENCODING_CP1250 + 1250;
|
||||
fontSpec.Printf(_T("-*-*-*-*-*-*-*-*-*-*-*-*-microsoft-cp%d"),
|
||||
cp);
|
||||
if ( wxTestFontSpec(fontSpec) )
|
||||
{
|
||||
xregistry = _T("microsoft");
|
||||
xencoding.Printf(_T("cp%d"), cp);
|
||||
|
||||
// test passed, no need to do it once more
|
||||
test = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// fall back to LatinX
|
||||
xregistry = _T("iso8859");
|
||||
xencoding.Printf(_T("%d"), cp - 1249);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case wxFONTENCODING_SYSTEM:
|
||||
default:
|
||||
test = FALSE;
|
||||
xregistry =
|
||||
xencoding = _T("*");
|
||||
}
|
||||
|
||||
if ( test )
|
||||
{
|
||||
fontSpec.Printf(_T("-*-*-*-*-*-*-*-*-*-*-*-*-%s-%s"),
|
||||
xregistry.c_str(), xencoding.c_str());
|
||||
if ( !wxTestFontSpec(fontSpec) )
|
||||
{
|
||||
// this encoding isn't available - what to do?
|
||||
xregistry =
|
||||
xencoding = _T("*");
|
||||
}
|
||||
}
|
||||
|
||||
// construct the X font spec from our data
|
||||
fontSpec.Printf(_T("-*-%s-%s-%s-normal-*-*-%d-*-*-*-*-%s-%s"),
|
||||
xfamily.c_str(), xweight.c_str(), xstyle.c_str(),
|
||||
pointSize, xregistry.c_str(), xencoding.c_str());
|
||||
|
||||
return gdk_font_load( wxConvCurrent->cWX2MB(fontSpec) );
|
||||
}
|
||||
|
||||
static GdkFont *wxLoadQueryNearestFont( int pointSize,
|
||||
int family,
|
||||
int style,
|
||||
int weight,
|
||||
bool underlined,
|
||||
const wxString &facename,
|
||||
wxFontEncoding encoding )
|
||||
{
|
||||
GdkFont *font = wxLoadQueryFont( pointSize, family, style, weight,
|
||||
underlined, facename, encoding );
|
||||
|
||||
if (!font)
|
||||
{
|
||||
/* search up and down by stepsize 10 */
|
||||
int max_size = pointSize + 20 * (1 + (pointSize/180));
|
||||
int min_size = pointSize - 20 * (1 + (pointSize/180));
|
||||
|
||||
int i;
|
||||
|
||||
/* Search for smaller size (approx.) */
|
||||
for ( i = pointSize - 10; !font && i >= 10 && i >= min_size; i -= 10 )
|
||||
{
|
||||
font = wxLoadQueryFont(i, family, style, weight, underlined,
|
||||
facename, encoding );
|
||||
}
|
||||
|
||||
/* Search for larger size (approx.) */
|
||||
for ( i = pointSize + 10; !font && i <= max_size; i += 10 )
|
||||
{
|
||||
font = wxLoadQueryFont( i, family, style, weight, underlined,
|
||||
facename, encoding );
|
||||
}
|
||||
|
||||
/* Try default family */
|
||||
if ( !font && family != wxDEFAULT )
|
||||
{
|
||||
font = wxLoadQueryFont( pointSize, wxDEFAULT, style, weight,
|
||||
underlined, facename, encoding );
|
||||
}
|
||||
|
||||
/* Bogus font */
|
||||
if ( !font )
|
||||
{
|
||||
font = wxLoadQueryFont(120, wxDEFAULT, wxNORMAL, wxNORMAL,
|
||||
underlined, facename, encoding );
|
||||
}
|
||||
}
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
// wow, what's this stuff? Is it used/useful? (VZ)
|
||||
#if 0
|
||||
|
||||
|
@ -41,9 +41,6 @@
|
||||
// private functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// returns TRUE if there are any fonts matching this font spec
|
||||
static bool wxTestFontSpec(const wxString& fontspec);
|
||||
|
||||
static GdkFont *wxLoadQueryFont( int pointSize,
|
||||
int family,
|
||||
int style,
|
||||
@ -450,221 +447,6 @@ GdkFont *wxFont::GetInternalFont( float scale ) const
|
||||
// local utilities to find a X font
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// returns TRUE if there are any fonts matching this font spec
|
||||
static bool wxTestFontSpec(const wxString& fontSpec)
|
||||
{
|
||||
GdkFont *test = gdk_font_load( wxConvCurrent->cWX2MB(fontSpec) );
|
||||
if ( test )
|
||||
{
|
||||
gdk_font_unref( test );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static GdkFont *wxLoadQueryFont( int pointSize,
|
||||
int family,
|
||||
int style,
|
||||
int weight,
|
||||
bool WXUNUSED(underlined),
|
||||
const wxString &facename,
|
||||
wxFontEncoding encoding )
|
||||
{
|
||||
wxString xfamily;
|
||||
switch (family)
|
||||
{
|
||||
case wxDECORATIVE: xfamily = _T("lucida"); break;
|
||||
case wxROMAN: xfamily = _T("times"); break;
|
||||
case wxMODERN: xfamily = _T("courier"); break;
|
||||
case wxSWISS: xfamily = _T("helvetica"); break;
|
||||
case wxTELETYPE: xfamily = _T("lucidatypewriter"); break;
|
||||
case wxSCRIPT: xfamily = _T("utopia"); break;
|
||||
default: xfamily = _T("*");
|
||||
}
|
||||
|
||||
wxString fontSpec;
|
||||
if (!facename.IsEmpty())
|
||||
{
|
||||
fontSpec.Printf(_T("-*-%s-*-*-normal-*-*-*-*-*-*-*-*-*"),
|
||||
facename.c_str());
|
||||
|
||||
if ( wxTestFontSpec(fontSpec) )
|
||||
{
|
||||
xfamily = facename;
|
||||
}
|
||||
//else: no such family, use default one instead
|
||||
}
|
||||
|
||||
wxString xstyle;
|
||||
switch (style)
|
||||
{
|
||||
case wxITALIC: xstyle = _T("i"); break;
|
||||
case wxSLANT: xstyle = _T("o"); break;
|
||||
case wxNORMAL: xstyle = _T("r"); break;
|
||||
default: xstyle = _T("*"); break;
|
||||
}
|
||||
|
||||
wxString xweight;
|
||||
switch (weight)
|
||||
{
|
||||
case wxBOLD: xweight = _T("bold"); break;
|
||||
case wxLIGHT:
|
||||
case wxNORMAL: xweight = _T("medium"); break;
|
||||
default: xweight = _T("*"); break;
|
||||
}
|
||||
|
||||
wxString xregistry, xencoding;
|
||||
if ( encoding == wxFONTENCODING_DEFAULT )
|
||||
{
|
||||
// use the apps default
|
||||
encoding = wxFont::GetDefaultEncoding();
|
||||
}
|
||||
|
||||
bool test = TRUE; // should we test for availability of encoding?
|
||||
switch ( encoding )
|
||||
{
|
||||
case wxFONTENCODING_ISO8859_1:
|
||||
case wxFONTENCODING_ISO8859_2:
|
||||
case wxFONTENCODING_ISO8859_3:
|
||||
case wxFONTENCODING_ISO8859_4:
|
||||
case wxFONTENCODING_ISO8859_5:
|
||||
case wxFONTENCODING_ISO8859_6:
|
||||
case wxFONTENCODING_ISO8859_7:
|
||||
case wxFONTENCODING_ISO8859_8:
|
||||
case wxFONTENCODING_ISO8859_9:
|
||||
case wxFONTENCODING_ISO8859_10:
|
||||
case wxFONTENCODING_ISO8859_11:
|
||||
case wxFONTENCODING_ISO8859_13:
|
||||
case wxFONTENCODING_ISO8859_14:
|
||||
case wxFONTENCODING_ISO8859_15:
|
||||
{
|
||||
int cp = encoding - wxFONTENCODING_ISO8859_1 + 1;
|
||||
xregistry = _T("iso8859");
|
||||
xencoding.Printf(_T("%d"), cp);
|
||||
}
|
||||
break;
|
||||
|
||||
case wxFONTENCODING_KOI8:
|
||||
xregistry = _T("koi8");
|
||||
if ( wxTestFontSpec(_T("-*-*-*-*-*-*-*-*-*-*-*-*-koi8-1")) )
|
||||
{
|
||||
xencoding = _T("1");
|
||||
|
||||
// test passed, no need to do it once more
|
||||
test = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
xencoding = _T("*");
|
||||
}
|
||||
break;
|
||||
|
||||
case wxFONTENCODING_CP1250:
|
||||
case wxFONTENCODING_CP1251:
|
||||
case wxFONTENCODING_CP1252:
|
||||
{
|
||||
int cp = encoding - wxFONTENCODING_CP1250 + 1250;
|
||||
fontSpec.Printf(_T("-*-*-*-*-*-*-*-*-*-*-*-*-microsoft-cp%d"),
|
||||
cp);
|
||||
if ( wxTestFontSpec(fontSpec) )
|
||||
{
|
||||
xregistry = _T("microsoft");
|
||||
xencoding.Printf(_T("cp%d"), cp);
|
||||
|
||||
// test passed, no need to do it once more
|
||||
test = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// fall back to LatinX
|
||||
xregistry = _T("iso8859");
|
||||
xencoding.Printf(_T("%d"), cp - 1249);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case wxFONTENCODING_SYSTEM:
|
||||
default:
|
||||
test = FALSE;
|
||||
xregistry =
|
||||
xencoding = _T("*");
|
||||
}
|
||||
|
||||
if ( test )
|
||||
{
|
||||
fontSpec.Printf(_T("-*-*-*-*-*-*-*-*-*-*-*-*-%s-%s"),
|
||||
xregistry.c_str(), xencoding.c_str());
|
||||
if ( !wxTestFontSpec(fontSpec) )
|
||||
{
|
||||
// this encoding isn't available - what to do?
|
||||
xregistry =
|
||||
xencoding = _T("*");
|
||||
}
|
||||
}
|
||||
|
||||
// construct the X font spec from our data
|
||||
fontSpec.Printf(_T("-*-%s-%s-%s-normal-*-*-%d-*-*-*-*-%s-%s"),
|
||||
xfamily.c_str(), xweight.c_str(), xstyle.c_str(),
|
||||
pointSize, xregistry.c_str(), xencoding.c_str());
|
||||
|
||||
return gdk_font_load( wxConvCurrent->cWX2MB(fontSpec) );
|
||||
}
|
||||
|
||||
static GdkFont *wxLoadQueryNearestFont( int pointSize,
|
||||
int family,
|
||||
int style,
|
||||
int weight,
|
||||
bool underlined,
|
||||
const wxString &facename,
|
||||
wxFontEncoding encoding )
|
||||
{
|
||||
GdkFont *font = wxLoadQueryFont( pointSize, family, style, weight,
|
||||
underlined, facename, encoding );
|
||||
|
||||
if (!font)
|
||||
{
|
||||
/* search up and down by stepsize 10 */
|
||||
int max_size = pointSize + 20 * (1 + (pointSize/180));
|
||||
int min_size = pointSize - 20 * (1 + (pointSize/180));
|
||||
|
||||
int i;
|
||||
|
||||
/* Search for smaller size (approx.) */
|
||||
for ( i = pointSize - 10; !font && i >= 10 && i >= min_size; i -= 10 )
|
||||
{
|
||||
font = wxLoadQueryFont(i, family, style, weight, underlined,
|
||||
facename, encoding );
|
||||
}
|
||||
|
||||
/* Search for larger size (approx.) */
|
||||
for ( i = pointSize + 10; !font && i <= max_size; i += 10 )
|
||||
{
|
||||
font = wxLoadQueryFont( i, family, style, weight, underlined,
|
||||
facename, encoding );
|
||||
}
|
||||
|
||||
/* Try default family */
|
||||
if ( !font && family != wxDEFAULT )
|
||||
{
|
||||
font = wxLoadQueryFont( pointSize, wxDEFAULT, style, weight,
|
||||
underlined, facename, encoding );
|
||||
}
|
||||
|
||||
/* Bogus font */
|
||||
if ( !font )
|
||||
{
|
||||
font = wxLoadQueryFont(120, wxDEFAULT, wxNORMAL, wxNORMAL,
|
||||
underlined, facename, encoding );
|
||||
}
|
||||
}
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
// wow, what's this stuff? Is it used/useful? (VZ)
|
||||
#if 0
|
||||
|
||||
|
@ -9,8 +9,16 @@
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "font.h"
|
||||
#pragma implementation "font.h"
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
@ -22,9 +30,82 @@
|
||||
#include <Xm/Xm.h>
|
||||
|
||||
#if !USE_SHARED_LIBRARIES
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// private classes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// For every wxFont, there must be a font for each display and scale requested.
|
||||
// So these objects are stored in wxFontRefData::m_fonts
|
||||
class wxXFont: public wxObject
|
||||
{
|
||||
public:
|
||||
wxXFont();
|
||||
~wxXFont();
|
||||
|
||||
WXFontStructPtr m_fontStruct; // XFontStruct
|
||||
WXFontList m_fontList; // Motif XmFontList
|
||||
WXDisplay* m_display; // XDisplay
|
||||
int m_scale; // Scale * 100
|
||||
};
|
||||
|
||||
class wxFontRefData: public wxGDIRefData
|
||||
{
|
||||
friend class wxFont;
|
||||
|
||||
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)
|
||||
{
|
||||
Init(size, family, style, weight, underlined, faceName, encoding);
|
||||
}
|
||||
|
||||
wxFontRefData(const wxFontRefData& data)
|
||||
{
|
||||
Init(data.m_pointSize, data.m_family, data.m_style, data.m_weight,
|
||||
data.m_underlined, data.m_faceName, data.m_encoding);
|
||||
}
|
||||
|
||||
~wxFontRefData();
|
||||
|
||||
protected:
|
||||
// common part of all ctors
|
||||
void Init(int size,
|
||||
int family,
|
||||
int style,
|
||||
int weight,
|
||||
bool underlined,
|
||||
const wxString& faceName,
|
||||
wxFontEncoding encoding);
|
||||
|
||||
// font attributes
|
||||
int m_pointSize;
|
||||
int m_family;
|
||||
int m_style;
|
||||
int m_weight;
|
||||
bool m_underlined;
|
||||
wxString m_faceName;
|
||||
wxFontEncoding m_encoding;
|
||||
|
||||
// A list of wxXFonts
|
||||
wxList m_fonts;
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxXFont
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxXFont::wxXFont()
|
||||
{
|
||||
m_fontStruct = (WXFontStructPtr) 0;
|
||||
@ -45,29 +126,42 @@ wxXFont::~wxXFont()
|
||||
// XFreeFont((Display*) m_display, fontStruct);
|
||||
}
|
||||
|
||||
wxFontRefData::wxFontRefData()
|
||||
{
|
||||
m_style = 0;
|
||||
m_pointSize = 0;
|
||||
m_family = 0;
|
||||
m_style = 0;
|
||||
m_weight = 0;
|
||||
m_underlined = 0;
|
||||
m_faceName = "";
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFontRefData
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxFontRefData::wxFontRefData(const wxFontRefData& data)
|
||||
void wxFontRefData::Init(int pointSize,
|
||||
int family,
|
||||
int style,
|
||||
int weight,
|
||||
bool underlined,
|
||||
const wxString& faceName,
|
||||
wxFontEncoding encoding)
|
||||
{
|
||||
m_style = data.m_style;
|
||||
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;
|
||||
if (family == wxDEFAULT)
|
||||
m_family = wxSWISS;
|
||||
else
|
||||
m_family = family;
|
||||
|
||||
// Don't have to copy actual fonts, because they'll be created
|
||||
// on demand.
|
||||
m_faceName = faceName;
|
||||
|
||||
if (style == wxDEFAULT)
|
||||
m_style = wxNORMAL;
|
||||
else
|
||||
m_style = style;
|
||||
|
||||
if (weight == wxDEFAULT)
|
||||
m_weight = wxNORMAL;
|
||||
else
|
||||
m_weight = weight;
|
||||
|
||||
if (pointSize == wxDEFAULT)
|
||||
m_pointSize = 12;
|
||||
else
|
||||
m_pointSize = pointSize;
|
||||
|
||||
m_underlined = underlined;
|
||||
m_encoding = encoding;
|
||||
}
|
||||
|
||||
wxFontRefData::~wxFontRefData()
|
||||
@ -82,31 +176,27 @@ wxFontRefData::~wxFontRefData()
|
||||
m_fonts.Clear();
|
||||
}
|
||||
|
||||
wxFont::wxFont()
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFont
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxFont::Init()
|
||||
{
|
||||
if ( wxTheFontList )
|
||||
wxTheFontList->Append(this);
|
||||
}
|
||||
|
||||
wxFont::wxFont(int pointSize, int family, int style, int weight, bool underlined, const wxString& faceName)
|
||||
{
|
||||
Create(pointSize, family, style, weight, underlined, faceName);
|
||||
|
||||
if ( wxTheFontList )
|
||||
wxTheFontList->Append(this);
|
||||
}
|
||||
|
||||
bool wxFont::Create(int pointSize, int family, int style, int weight, bool underlined, const wxString& faceName)
|
||||
bool wxFont::Create(int pointSize,
|
||||
int family,
|
||||
int style,
|
||||
int weight,
|
||||
bool underlined,
|
||||
const wxString& faceName,
|
||||
wxFontEncoding encoding)
|
||||
{
|
||||
UnRef();
|
||||
m_refData = new wxFontRefData;
|
||||
|
||||
M_FONTDATA->m_family = family;
|
||||
M_FONTDATA->m_style = style;
|
||||
M_FONTDATA->m_weight = weight;
|
||||
M_FONTDATA->m_pointSize = pointSize;
|
||||
M_FONTDATA->m_underlined = underlined;
|
||||
M_FONTDATA->m_faceName = faceName;
|
||||
m_refData = new wxFontRefData(pointSize, family, style, weight,
|
||||
underlined, faceName, encoding);
|
||||
|
||||
RealizeResource();
|
||||
|
||||
@ -115,15 +205,13 @@ bool wxFont::Create(int pointSize, int family, int style, int weight, bool under
|
||||
|
||||
wxFont::~wxFont()
|
||||
{
|
||||
if (wxTheFontList)
|
||||
if ( wxTheFontList )
|
||||
wxTheFontList->DeleteObject(this);
|
||||
}
|
||||
|
||||
bool wxFont::RealizeResource()
|
||||
{
|
||||
// TODO: create the font (if there is a native font object)
|
||||
return FALSE;
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
// change the font attributes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxFont::Unshare()
|
||||
{
|
||||
@ -194,92 +282,73 @@ void wxFont::SetUnderlined(bool underlined)
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
wxString wxFont::GetFamilyString() const
|
||||
void wxFont::SetEncoding(wxFontEncoding encoding)
|
||||
{
|
||||
wxString fam("");
|
||||
switch (GetFamily())
|
||||
{
|
||||
case wxDECORATIVE:
|
||||
fam = "wxDECORATIVE";
|
||||
break;
|
||||
case wxROMAN:
|
||||
fam = "wxROMAN";
|
||||
break;
|
||||
case wxSCRIPT:
|
||||
fam = "wxSCRIPT";
|
||||
break;
|
||||
case wxSWISS:
|
||||
fam = "wxSWISS";
|
||||
break;
|
||||
case wxMODERN:
|
||||
fam = "wxMODERN";
|
||||
break;
|
||||
case wxTELETYPE:
|
||||
fam = "wxTELETYPE";
|
||||
break;
|
||||
default:
|
||||
fam = "wxDEFAULT";
|
||||
break;
|
||||
}
|
||||
return fam;
|
||||
Unshare();
|
||||
|
||||
M_FONTDATA->m_encoding = encoding;
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// query font attributes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
int wxFont::GetPointSize() const
|
||||
{
|
||||
return M_FONTDATA->m_pointSize;
|
||||
}
|
||||
|
||||
int wxFont::GetFamily() const
|
||||
{
|
||||
return M_FONTDATA->m_family;
|
||||
}
|
||||
|
||||
int wxFont::GetStyle() const
|
||||
{
|
||||
return M_FONTDATA->m_style;
|
||||
}
|
||||
|
||||
int wxFont::GetWeight() const
|
||||
{
|
||||
return M_FONTDATA->m_weight;
|
||||
}
|
||||
|
||||
bool wxFont::GetUnderlined() const
|
||||
{
|
||||
return M_FONTDATA->m_underlined;
|
||||
}
|
||||
|
||||
/* New font system */
|
||||
wxString wxFont::GetFaceName() const
|
||||
{
|
||||
wxString str("");
|
||||
if (M_FONTDATA)
|
||||
wxString str;
|
||||
if ( M_FONTDATA )
|
||||
str = M_FONTDATA->m_faceName ;
|
||||
return str;
|
||||
}
|
||||
|
||||
wxString wxFont::GetStyleString() const
|
||||
wxFontEncoding wxFont::GetEncoding() const
|
||||
{
|
||||
wxString styl("");
|
||||
switch (GetStyle())
|
||||
{
|
||||
case wxITALIC:
|
||||
styl = "wxITALIC";
|
||||
break;
|
||||
case wxSLANT:
|
||||
styl = "wxSLANT";
|
||||
break;
|
||||
default:
|
||||
styl = "wxNORMAL";
|
||||
break;
|
||||
}
|
||||
return styl;
|
||||
return M_FONTDATA->m_encoding;
|
||||
}
|
||||
|
||||
wxString wxFont::GetWeightString() const
|
||||
{
|
||||
wxString w("");
|
||||
switch (GetWeight())
|
||||
{
|
||||
case wxBOLD:
|
||||
w = "wxBOLD";
|
||||
break;
|
||||
case wxLIGHT:
|
||||
w = "wxLIGHT";
|
||||
break;
|
||||
default:
|
||||
w = "wxNORMAL";
|
||||
break;
|
||||
}
|
||||
return w;
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
// real implementation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Find an existing, or create a new, XFontStruct
|
||||
// based on this wxFont and the given scale. Append the
|
||||
// font to list in the private data for future reference.
|
||||
wxXFont* wxFont::GetInternalFont(double scale, WXDisplay* display) const
|
||||
{
|
||||
if (!Ok())
|
||||
return (wxXFont*) NULL;
|
||||
if ( !Ok() )
|
||||
return (wxXFont *)NULL;
|
||||
|
||||
long intScale = long(scale * 100.0 + 0.5); // key for wxXFont
|
||||
int pointSize = (M_FONTDATA->m_pointSize * 10 * intScale) / 100;
|
||||
|
||||
// search existing fonts first
|
||||
wxNode* node = M_FONTDATA->m_fonts.First();
|
||||
while (node)
|
||||
{
|
||||
@ -289,91 +358,42 @@ wxXFont* wxFont::GetInternalFont(double scale, WXDisplay* display) const
|
||||
node = node->Next();
|
||||
}
|
||||
|
||||
WXFontStructPtr font = LoadQueryFont(pointSize, M_FONTDATA->m_family,
|
||||
M_FONTDATA->m_style, M_FONTDATA->m_weight, M_FONTDATA->m_underlined);
|
||||
// not found, create a new one
|
||||
XFontStruct *font = wxLoadQueryNearestFont(pointSize,
|
||||
M_FONTDATA->m_family,
|
||||
M_FONTDATA->m_style,
|
||||
M_FONTDATA->m_weight,
|
||||
M_FONTDATA->m_underlined,
|
||||
_T(""),
|
||||
M_FONTDATA->m_encoding);
|
||||
|
||||
if (!font)
|
||||
if ( !font )
|
||||
{
|
||||
// search up and down by stepsize 10
|
||||
int max_size = pointSize + 20 * (1 + (pointSize/180));
|
||||
int min_size = pointSize - 20 * (1 + (pointSize/180));
|
||||
int i;
|
||||
wxFAIL_MSG( _T("Could not allocate even a default font -- something is wrong.") );
|
||||
|
||||
// Search for smaller size (approx.)
|
||||
for (i=pointSize-10; !font && i >= 10 && i >= min_size; i -= 10)
|
||||
font = LoadQueryFont(i, M_FONTDATA->m_family, M_FONTDATA->m_style, M_FONTDATA->m_weight, M_FONTDATA->m_underlined);
|
||||
// Search for larger size (approx.)
|
||||
for (i=pointSize+10; !font && i <= max_size; i += 10)
|
||||
font = LoadQueryFont(i, M_FONTDATA->m_family, M_FONTDATA->m_style, M_FONTDATA->m_weight, M_FONTDATA->m_underlined);
|
||||
// Try default family
|
||||
if (!font && M_FONTDATA->m_family != wxDEFAULT)
|
||||
font = LoadQueryFont(pointSize, wxDEFAULT, M_FONTDATA->m_style,
|
||||
M_FONTDATA->m_weight, M_FONTDATA->m_underlined);
|
||||
// Bogus font
|
||||
if (!font)
|
||||
font = LoadQueryFont(120, wxDEFAULT, wxNORMAL, wxNORMAL,
|
||||
M_FONTDATA->m_underlined);
|
||||
wxASSERT_MSG( (font != (XFontStruct*) NULL), "Could not allocate even a default font -- something is wrong." );
|
||||
return (wxXFont*) NULL;
|
||||
}
|
||||
if (font)
|
||||
{
|
||||
wxXFont* f = new wxXFont;
|
||||
f->m_fontStruct = 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);
|
||||
return f;
|
||||
}
|
||||
return (wxXFont*) NULL;
|
||||
|
||||
wxXFont* f = new wxXFont;
|
||||
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);
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
WXFontStructPtr wxFont::LoadQueryFont(int pointSize, int family, int style,
|
||||
int weight, bool underlined) const
|
||||
WXFontStructPtr wxFont::GetFontStruct(double scale, WXDisplay* display) const
|
||||
{
|
||||
char *xfamily;
|
||||
char *xstyle;
|
||||
char *xweight;
|
||||
switch (family)
|
||||
{
|
||||
case wxDECORATIVE: xfamily = "lucida";
|
||||
break;
|
||||
case wxROMAN: xfamily = "times";
|
||||
break;
|
||||
case wxMODERN: xfamily = "courier";
|
||||
break;
|
||||
case wxSWISS: xfamily = "lucida";
|
||||
break;
|
||||
case wxDEFAULT:
|
||||
default: xfamily = "*";
|
||||
}
|
||||
switch (style)
|
||||
{
|
||||
case wxITALIC: xstyle = "i";
|
||||
break;
|
||||
case wxSLANT: xstyle = "o";
|
||||
break;
|
||||
case wxNORMAL: xstyle = "r";
|
||||
break;
|
||||
default: xstyle = "*";
|
||||
break;
|
||||
}
|
||||
switch (weight)
|
||||
{
|
||||
case wxBOLD: xweight = "bold";
|
||||
break;
|
||||
case wxLIGHT:
|
||||
case wxNORMAL: xweight = "medium";
|
||||
break;
|
||||
default: xweight = "*";
|
||||
break;
|
||||
}
|
||||
wxXFont* f = GetInternalFont(scale, display);
|
||||
|
||||
sprintf(wxBuffer, "-*-%s-%s-%s-normal-*-*-%d-*-*-*-*-*-*",
|
||||
xfamily, xweight, xstyle, pointSize);
|
||||
|
||||
Display *dpy = (Display*) wxGetDisplay();
|
||||
XFontStruct* font = XLoadQueryFont(dpy, wxBuffer);
|
||||
|
||||
return (WXFontStructPtr) font;
|
||||
return (f ? f->m_fontStruct : (WXFontStructPtr) 0);
|
||||
}
|
||||
|
||||
WXFontList wxFont::GetFontList(double scale, WXDisplay* display) const
|
||||
{
|
||||
wxXFont* f = GetInternalFont(scale, display);
|
||||
|
||||
return (f ? f->m_fontList : (WXFontList) 0);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
# This file was automatically generated by tmake at 20:03, 1999/09/29
|
||||
# This file was automatically generated by tmake at 15:48, 1999/10/01
|
||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE B32.T!
|
||||
|
||||
#
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
# This file was automatically generated by tmake at 20:03, 1999/09/29
|
||||
# This file was automatically generated by tmake at 15:48, 1999/10/01
|
||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE BCC.T!
|
||||
|
||||
#
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
# This file was automatically generated by tmake at 20:03, 1999/09/29
|
||||
# This file was automatically generated by tmake at 15:48, 1999/10/01
|
||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE DOS.T!
|
||||
|
||||
#
|
||||
@ -116,6 +116,7 @@ COMMONOBJS = \
|
||||
$(COMMDIR)\gifdecod.obj \
|
||||
$(COMMDIR)\hash.obj \
|
||||
$(COMMDIR)\helpbase.obj \
|
||||
$(COMMDIR)\imagall.obj \
|
||||
$(COMMDIR)\imagbmp.obj \
|
||||
$(COMMDIR)\image.obj \
|
||||
$(COMMDIR)\imaggif.obj \
|
||||
@ -815,6 +816,11 @@ $(COMMDIR)/helpbase.obj: $*.$(SRCSUFF)
|
||||
$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
$(COMMDIR)/imagall.obj: $*.$(SRCSUFF)
|
||||
cl @<<
|
||||
$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
$(COMMDIR)/imagbmp.obj: $*.$(SRCSUFF)
|
||||
cl @<<
|
||||
$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
# This file was automatically generated by tmake at 20:03, 1999/09/29
|
||||
# This file was automatically generated by tmake at 15:48, 1999/10/01
|
||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE G95.T!
|
||||
|
||||
#
|
||||
@ -91,6 +91,7 @@ COMMONOBJS = \
|
||||
$(COMMDIR)/hash.$(OBJSUFF) \
|
||||
$(COMMDIR)/helpbase.$(OBJSUFF) \
|
||||
$(COMMDIR)/http.$(OBJSUFF) \
|
||||
$(COMMDIR)/imagall.$(OBJSUFF) \
|
||||
$(COMMDIR)/imagbmp.$(OBJSUFF) \
|
||||
$(COMMDIR)/image.$(OBJSUFF) \
|
||||
$(COMMDIR)/imaggif.$(OBJSUFF) \
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
# This file was automatically generated by tmake at 20:03, 1999/09/29
|
||||
# This file was automatically generated by tmake at 15:48, 1999/10/01
|
||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE SC.T!
|
||||
|
||||
# Symantec C++ makefile for the msw objects
|
||||
@ -79,6 +79,7 @@ COMMONOBJS = \
|
||||
$(COMMDIR)\hash.obj \
|
||||
$(COMMDIR)\helpbase.obj \
|
||||
$(COMMDIR)\http.obj \
|
||||
$(COMMDIR)\imagall.obj \
|
||||
$(COMMDIR)\imagbmp.obj \
|
||||
$(COMMDIR)\image.obj \
|
||||
$(COMMDIR)\imaggif.obj \
|
||||
|
@ -1,4 +1,4 @@
|
||||
# This file was automatically generated by tmake at 14:12, 1999/09/30
|
||||
# This file was automatically generated by tmake at 15:48, 1999/10/01
|
||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE VC.T!
|
||||
|
||||
# File: makefile.vc
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
# This file was automatically generated by tmake at 20:03, 1999/09/29
|
||||
# This file was automatically generated by tmake at 15:48, 1999/10/01
|
||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE WAT.T!
|
||||
|
||||
#!/binb/wmake.exe
|
||||
@ -105,6 +105,7 @@ COMMONOBJS = &
|
||||
hash.obj &
|
||||
helpbase.obj &
|
||||
http.obj &
|
||||
imagall.obj &
|
||||
imagbmp.obj &
|
||||
image.obj &
|
||||
imaggif.obj &
|
||||
@ -644,6 +645,9 @@ helpbase.obj: $(COMMDIR)\helpbase.cpp
|
||||
http.obj: $(COMMDIR)\http.cpp
|
||||
*$(CCC) $(CPPFLAGS) $(IFLAGS) $<
|
||||
|
||||
imagall.obj: $(COMMDIR)\imagall.cpp
|
||||
*$(CCC) $(CPPFLAGS) $(IFLAGS) $<
|
||||
|
||||
imagbmp.obj: $(COMMDIR)\imagbmp.cpp
|
||||
*$(CCC) $(CPPFLAGS) $(IFLAGS) $<
|
||||
|
||||
|
@ -569,3 +569,249 @@ void wxFatalError( const wxString &msg, const wxString &title )
|
||||
wxFprintf( stderr, _T(".\n") );
|
||||
exit(3); // the same exit code as for abort()
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// font-related functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// define the functions to create and destroy native fonts for this toolkit
|
||||
#ifdef __X__
|
||||
static inline wxNativeFont wxLoadFont(const wxString& fontSpec)
|
||||
{
|
||||
return XLoadQueryFont((Display *)wxGetDisplay(), fontSpec);
|
||||
}
|
||||
|
||||
static inline void wxFreeFont(wxNativeFont font)
|
||||
{
|
||||
XFreeFont((Display *)wxGetDisplay(), font);
|
||||
}
|
||||
#elif defined(__WXGTK__)
|
||||
static inline wxNativeFont wxLoadFont(const wxString& fontSpec)
|
||||
{
|
||||
return gdk_font_load( wxConvCurrent->cWX2MB(fontSpec) );
|
||||
}
|
||||
|
||||
static inline void wxFreeFont(wxNativeFont font)
|
||||
{
|
||||
gdk_font_unref(font);
|
||||
}
|
||||
#else
|
||||
#error "Unknown GUI toolkit"
|
||||
#endif
|
||||
|
||||
// returns TRUE if there are any fonts matching this font spec
|
||||
static bool wxTestFontSpec(const wxString& fontspec)
|
||||
{
|
||||
wxNativeFont test = wxLoadFont(fontspec);
|
||||
if ( test )
|
||||
{
|
||||
wxFreeFont(test);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO encoding test logic should be moved to wxLoadQueryNearestFont()
|
||||
static wxNativeFont wxLoadQueryFont(int pointSize,
|
||||
int family,
|
||||
int style,
|
||||
int weight,
|
||||
bool WXUNUSED(underlined),
|
||||
const wxString &facename,
|
||||
wxFontEncoding encoding )
|
||||
{
|
||||
wxString xfamily;
|
||||
switch (family)
|
||||
{
|
||||
case wxDECORATIVE: xfamily = _T("lucida"); break;
|
||||
case wxROMAN: xfamily = _T("times"); break;
|
||||
case wxMODERN: xfamily = _T("courier"); break;
|
||||
case wxSWISS: xfamily = _T("helvetica"); break;
|
||||
case wxTELETYPE: xfamily = _T("lucidatypewriter"); break;
|
||||
case wxSCRIPT: xfamily = _T("utopia"); break;
|
||||
default: xfamily = _T("*");
|
||||
}
|
||||
|
||||
wxString fontSpec;
|
||||
if (!facename.IsEmpty())
|
||||
{
|
||||
fontSpec.Printf(_T("-*-%s-*-*-normal-*-*-*-*-*-*-*-*-*"),
|
||||
facename.c_str());
|
||||
|
||||
if ( wxTestFontSpec(fontSpec) )
|
||||
{
|
||||
xfamily = facename;
|
||||
}
|
||||
//else: no such family, use default one instead
|
||||
}
|
||||
|
||||
wxString xstyle;
|
||||
switch (style)
|
||||
{
|
||||
case wxITALIC: xstyle = _T("i"); break;
|
||||
case wxSLANT: xstyle = _T("o"); break;
|
||||
case wxNORMAL: xstyle = _T("r"); break;
|
||||
default: xstyle = _T("*"); break;
|
||||
}
|
||||
|
||||
wxString xweight;
|
||||
switch (weight)
|
||||
{
|
||||
case wxBOLD: xweight = _T("bold"); break;
|
||||
case wxLIGHT:
|
||||
case wxNORMAL: xweight = _T("medium"); break;
|
||||
default: xweight = _T("*"); break;
|
||||
}
|
||||
|
||||
wxString xregistry, xencoding;
|
||||
if ( encoding == wxFONTENCODING_DEFAULT )
|
||||
{
|
||||
// use the apps default
|
||||
encoding = wxFont::GetDefaultEncoding();
|
||||
}
|
||||
|
||||
bool test = TRUE; // should we test for availability of encoding?
|
||||
switch ( encoding )
|
||||
{
|
||||
case wxFONTENCODING_ISO8859_1:
|
||||
case wxFONTENCODING_ISO8859_2:
|
||||
case wxFONTENCODING_ISO8859_3:
|
||||
case wxFONTENCODING_ISO8859_4:
|
||||
case wxFONTENCODING_ISO8859_5:
|
||||
case wxFONTENCODING_ISO8859_6:
|
||||
case wxFONTENCODING_ISO8859_7:
|
||||
case wxFONTENCODING_ISO8859_8:
|
||||
case wxFONTENCODING_ISO8859_9:
|
||||
case wxFONTENCODING_ISO8859_10:
|
||||
case wxFONTENCODING_ISO8859_11:
|
||||
case wxFONTENCODING_ISO8859_13:
|
||||
case wxFONTENCODING_ISO8859_14:
|
||||
case wxFONTENCODING_ISO8859_15:
|
||||
{
|
||||
int cp = encoding - wxFONTENCODING_ISO8859_1 + 1;
|
||||
xregistry = _T("iso8859");
|
||||
xencoding.Printf(_T("%d"), cp);
|
||||
}
|
||||
break;
|
||||
|
||||
case wxFONTENCODING_KOI8:
|
||||
xregistry = _T("koi8");
|
||||
if ( wxTestFontSpec(_T("-*-*-*-*-*-*-*-*-*-*-*-*-koi8-1")) )
|
||||
{
|
||||
xencoding = _T("1");
|
||||
|
||||
// test passed, no need to do it once more
|
||||
test = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
xencoding = _T("*");
|
||||
}
|
||||
break;
|
||||
|
||||
case wxFONTENCODING_CP1250:
|
||||
case wxFONTENCODING_CP1251:
|
||||
case wxFONTENCODING_CP1252:
|
||||
{
|
||||
int cp = encoding - wxFONTENCODING_CP1250 + 1250;
|
||||
fontSpec.Printf(_T("-*-*-*-*-*-*-*-*-*-*-*-*-microsoft-cp%d"),
|
||||
cp);
|
||||
if ( wxTestFontSpec(fontSpec) )
|
||||
{
|
||||
xregistry = _T("microsoft");
|
||||
xencoding.Printf(_T("cp%d"), cp);
|
||||
|
||||
// test passed, no need to do it once more
|
||||
test = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// fall back to LatinX
|
||||
xregistry = _T("iso8859");
|
||||
xencoding.Printf(_T("%d"), cp - 1249);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case wxFONTENCODING_SYSTEM:
|
||||
default:
|
||||
test = FALSE;
|
||||
xregistry =
|
||||
xencoding = _T("*");
|
||||
}
|
||||
|
||||
if ( test )
|
||||
{
|
||||
fontSpec.Printf(_T("-*-*-*-*-*-*-*-*-*-*-*-*-%s-%s"),
|
||||
xregistry.c_str(), xencoding.c_str());
|
||||
if ( !wxTestFontSpec(fontSpec) )
|
||||
{
|
||||
// this encoding isn't available - what to do?
|
||||
xregistry =
|
||||
xencoding = _T("*");
|
||||
}
|
||||
}
|
||||
|
||||
// construct the X font spec from our data
|
||||
fontSpec.Printf(_T("-*-%s-%s-%s-normal-*-*-%d-*-*-*-*-%s-%s"),
|
||||
xfamily.c_str(), xweight.c_str(), xstyle.c_str(),
|
||||
pointSize, xregistry.c_str(), xencoding.c_str());
|
||||
|
||||
return wxLoadFont(fontSpec);
|
||||
}
|
||||
|
||||
wxNativeFont wxLoadQueryNearestFont(int pointSize,
|
||||
int family,
|
||||
int style,
|
||||
int weight,
|
||||
bool underlined,
|
||||
const wxString &facename,
|
||||
wxFontEncoding encoding)
|
||||
{
|
||||
wxNativeFont font = wxLoadQueryFont( pointSize, family, style, weight,
|
||||
underlined, facename, encoding );
|
||||
|
||||
if (!font)
|
||||
{
|
||||
// search up and down by stepsize 10
|
||||
int max_size = pointSize + 20 * (1 + (pointSize/180));
|
||||
int min_size = pointSize - 20 * (1 + (pointSize/180));
|
||||
|
||||
int i;
|
||||
|
||||
// Search for smaller size (approx.)
|
||||
for ( i = pointSize - 10; !font && i >= 10 && i >= min_size; i -= 10 )
|
||||
{
|
||||
font = wxLoadQueryFont(i, family, style, weight, underlined,
|
||||
facename, encoding );
|
||||
}
|
||||
|
||||
// Search for larger size (approx.)
|
||||
for ( i = pointSize + 10; !font && i <= max_size; i += 10 )
|
||||
{
|
||||
font = wxLoadQueryFont( i, family, style, weight, underlined,
|
||||
facename, encoding );
|
||||
}
|
||||
|
||||
// Try default family
|
||||
if ( !font && family != wxDEFAULT )
|
||||
{
|
||||
font = wxLoadQueryFont( pointSize, wxDEFAULT, style, weight,
|
||||
underlined, facename, encoding );
|
||||
}
|
||||
|
||||
// Bogus font
|
||||
if ( !font )
|
||||
{
|
||||
font = wxLoadQueryFont(120, wxDEFAULT, wxNORMAL, wxNORMAL,
|
||||
underlined, facename, encoding );
|
||||
}
|
||||
}
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user