1. wxFontMapper almost finished
2. font helper functions are now in separate files, not utilsunx.cpp git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4376 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -100,7 +100,7 @@ public:
|
||||
// value of this method.
|
||||
//
|
||||
// Override: often.
|
||||
virtual int OnExit() { return 0; }
|
||||
virtual int OnExit();
|
||||
|
||||
// called when a fatal exception occurs, this function should take care
|
||||
// not to do anything which might provoke a nested exception! It may be
|
||||
|
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "wx/window.h"
|
||||
#include "wx/font.h"
|
||||
#include "wx/fontutil.h"
|
||||
#include "wx/colour.h"
|
||||
#include "wx/gdicmn.h"
|
||||
|
||||
@@ -55,7 +56,6 @@ class WXDLLEXPORT wxFontData: public wxObject
|
||||
DECLARE_DYNAMIC_CLASS(wxFontData)
|
||||
public:
|
||||
wxFontData();
|
||||
wxFontData(const wxFontData& fontData);
|
||||
~wxFontData();
|
||||
|
||||
void SetAllowSymbols(bool flag) { allowSymbols = flag; }
|
||||
@@ -78,7 +78,13 @@ public:
|
||||
|
||||
void SetRange(int minRange, int maxRange) { minSize = minRange; maxSize = maxRange; }
|
||||
|
||||
void operator=(const wxFontData& data);
|
||||
// encoding info is split into 2 parts: the logical wxWin encoding
|
||||
// (wxFontEncoding) and a structure containing the native parameters for
|
||||
// it (wxNativeEncodingInfo)
|
||||
wxFontEncoding GetEncoding() const { return m_encoding; }
|
||||
void SetEncoding(wxFontEncoding encoding) { m_encoding = encoding; }
|
||||
|
||||
wxNativeEncodingInfo& EncodingInfo() { return m_encodingInfo; }
|
||||
|
||||
public:
|
||||
wxColour fontColour;
|
||||
@@ -89,6 +95,10 @@ public:
|
||||
wxFont chosenFont;
|
||||
int minSize;
|
||||
int maxSize;
|
||||
|
||||
private:
|
||||
wxFontEncoding m_encoding;
|
||||
wxNativeEncodingInfo m_encodingInfo;
|
||||
};
|
||||
|
||||
#if wxUSE_PRINTING_ARCHITECTURE
|
||||
|
@@ -27,6 +27,7 @@
|
||||
// forward declarations
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxFontData;
|
||||
class WXDLLEXPORT wxFontBase;
|
||||
class WXDLLEXPORT wxFont;
|
||||
|
||||
|
@@ -17,6 +17,8 @@
|
||||
#pragma interface "fontenum.h"
|
||||
#endif
|
||||
|
||||
#include "wx/font.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFontEnumerator enumerates all available fonts on the system or only the
|
||||
// fonts with given attributes
|
||||
|
@@ -20,9 +20,8 @@
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "wx/defs.h" // for wxDEFAULT &c
|
||||
|
||||
#include "wx/font.h" // for wxFontEncoding
|
||||
#include "wx/font.h" // for wxFont and wxFontEncoding
|
||||
#include "wx/fontutil.h" // for wxNativeEncodingInfo
|
||||
|
||||
class WXDLLEXPORT wxConfigBase;
|
||||
|
||||
@@ -49,14 +48,38 @@ public:
|
||||
// virtual dtor for a base class
|
||||
virtual ~wxFontMapper();
|
||||
|
||||
// find an alternative for the given encoding (which is supposed to not be
|
||||
// available on this system). If successful, return TRUE and fill info
|
||||
// structure with the parameters required to create the font, otherwise
|
||||
// return FALSE
|
||||
virtual bool GetAltForEncoding(wxFontEncoding encoding,
|
||||
wxNativeEncodingInfo *info,
|
||||
bool interactive = TRUE);
|
||||
|
||||
// returns the encoding for the given charset (in the form of RFC 2046) or
|
||||
// wxFONTENCODING_SYSTEM if couldn't decode it
|
||||
virtual wxFontEncoding CharsetToEncoding(const wxString& charset,
|
||||
bool interactive = TRUE);
|
||||
|
||||
// encoding names
|
||||
// --------------
|
||||
|
||||
// return internal string identifier for the encoding (see also
|
||||
// GetEncodingDescription())
|
||||
static wxString GetEncodingName(wxFontEncoding encoding);
|
||||
|
||||
// return user-readable string describing the given encoding
|
||||
//
|
||||
// NB: hard-coded now, but might change later (read it from config?)
|
||||
static wxString GetEncodingDescription(wxFontEncoding encoding);
|
||||
|
||||
// configure the appearance of the dialogs we may popup
|
||||
// ----------------------------------------------------
|
||||
|
||||
// the parent window for modal dialogs
|
||||
void SetDialogParent(wxWindow *parent) { m_windowParent = parent; }
|
||||
|
||||
// the title for the dialogs (note that default is quite reasonable)
|
||||
void SetDialogTitle(const wxString& title) { m_titleDialog = title; }
|
||||
|
||||
// functions which allow to configure the config object used: by default,
|
||||
@@ -94,6 +117,17 @@ protected:
|
||||
// restore the config path after use
|
||||
void RestorePath(const wxString& pathOld);
|
||||
|
||||
// GetAltForEncoding() helper: tests for the existence of the given
|
||||
// encoding and saves the result in config if ok - this results in the
|
||||
// following (desired) behaviour: when an unknown/unavailable encoding is
|
||||
// requested for the first time, the user is asked about a replacement,
|
||||
// but if he doesn't choose any and the default logic finds one, it will
|
||||
// be saved in the config so that the user won't be asked about it any
|
||||
// more
|
||||
bool TestAltEncoding(const wxString& configEntry,
|
||||
wxFontEncoding encReplacement,
|
||||
wxNativeEncodingInfo *info);
|
||||
|
||||
// config object and path (in it) to use
|
||||
wxConfigBase *m_config;
|
||||
wxString m_configRootPath;
|
||||
@@ -103,6 +137,15 @@ protected:
|
||||
|
||||
// the parent window for our dialogs
|
||||
wxWindow *m_windowParent;
|
||||
|
||||
friend class wxFontMapperPathChanger;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// global variables
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// the default font mapper for wxWindows programs
|
||||
WXDLLEXPORT_DATA(extern wxFontMapper *) wxTheFontMapper;
|
||||
|
||||
#endif // _WX_FONTMAPPER_H_
|
||||
|
93
include/wx/fontutil.h
Normal file
93
include/wx/fontutil.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/fontutil.h
|
||||
// Purpose: font-related helper functions
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 05.11.99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) wxWindows team
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// General note: this header is private to wxWindows and is not supposed to be
|
||||
// included by user code. The functions declared here are implemented in
|
||||
// msw/fontutil.cpp for Windows, unix/fontutil.cpp for GTK/Motif &c.
|
||||
|
||||
#ifndef _WX_FONTUTIL_H_
|
||||
#define _WX_FONTUTIL_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "fontutil.h"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "wx/font.h" // for wxFont and wxFontEncoding
|
||||
|
||||
// for our purposes here, GDK and X are identical
|
||||
#if defined(__WXGTK__) || defined(__X__)
|
||||
#define _WX_X_FONTLIKE
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// types
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// This private structure specifies all the parameters needed to create a font
|
||||
// with the given encoding on this platform.
|
||||
//
|
||||
// Under X, it contains the last 2 elements of the font specifications
|
||||
// (registry and encoding).
|
||||
//
|
||||
// Under Windows, it contains a number which is one of predefined CHARSET_XXX
|
||||
// values.
|
||||
//
|
||||
// Under all platforms it also contains a facename string which should be
|
||||
// used, if not empty, to create fonts in this encoding (this is the only way
|
||||
// to create a font of non-standard encoding (like KOI8) under Windows - the
|
||||
// facename specifies the encoding then)
|
||||
|
||||
struct wxNativeEncodingInfo
|
||||
{
|
||||
wxString facename; // may be empty meaning "any"
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
int charset;
|
||||
#elif defined(_WX_X_FONTLIKE)
|
||||
wxString xregistry,
|
||||
xencoding;
|
||||
#else
|
||||
#error "Unsupported toolkit"
|
||||
#endif
|
||||
|
||||
// this struct is saved in config by wxFontMapper, so it should know to
|
||||
// serialise itself (implemented in platform-specific code)
|
||||
bool FromString(const wxString& s);
|
||||
wxString ToString() const;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// font-related functions (common)
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// translate a wxFontEncoding into native encoding parameter (defined above),
|
||||
// returning TRUE if an (exact) macth could be found, FALSE otherwise (without
|
||||
// attempting any substitutions)
|
||||
extern bool wxGetNativeFontEncoding(wxFontEncoding encoding,
|
||||
wxNativeEncodingInfo *info);
|
||||
|
||||
// test for the existence of the font described by this facename/encoding,
|
||||
// return TRUE if such font(s) exist, FALSE otherwise
|
||||
extern bool wxTestFontEncoding(const wxNativeEncodingInfo& info);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// font-related functions (X and GTK)
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef _WX_X_FONTLIKE
|
||||
#include "wx/unix/fontutil.h"
|
||||
#endif // X || GDK
|
||||
|
||||
#endif // _WX_FONTUTIL_H_
|
@@ -14,11 +14,7 @@
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/object.h"
|
||||
#include "wx/string.h"
|
||||
#include "wx/hash.h"
|
||||
#include "wx/gdiobj.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// classes
|
||||
@@ -30,12 +26,6 @@ class wxWindow;
|
||||
|
||||
class wxFont;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// global variables
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
extern const wxChar* wxEmptyString;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFont
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -46,6 +36,7 @@ public:
|
||||
// ctors and such
|
||||
wxFont() { Init(); }
|
||||
wxFont(const wxFont& font) { Init(); Ref(font); }
|
||||
wxFont(const wxString& fontname, const wxFontData& fontdata);
|
||||
|
||||
// assignment
|
||||
wxFont& operator=(const wxFont& font);
|
||||
@@ -91,7 +82,6 @@ public:
|
||||
virtual void SetEncoding(wxFontEncoding encoding);
|
||||
|
||||
// implementation from now on
|
||||
wxFont( GdkFont* font, char *xFontName );
|
||||
void Unshare();
|
||||
|
||||
GdkFont* GetInternalFont(float scale = 1.0) const;
|
||||
|
@@ -2,10 +2,10 @@
|
||||
// Name: fontdlgg.h
|
||||
// Purpose: wxFontDialog
|
||||
// Author: Robert Roebling
|
||||
// Created:
|
||||
// Created:
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Robert Roebling
|
||||
// Licence: wxWindows licence
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __GTK_FONTDLGH__
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
wxFontDialog( wxWindow *parent, wxFontData *data = (wxFontData *) NULL );
|
||||
~wxFontDialog();
|
||||
|
||||
inline wxFontData& GetFontData() { return m_fontData; }
|
||||
wxFontData& GetFontData() { return m_fontData; }
|
||||
|
||||
//protected:
|
||||
wxFontData m_fontData;
|
||||
|
@@ -14,11 +14,7 @@
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/object.h"
|
||||
#include "wx/string.h"
|
||||
#include "wx/hash.h"
|
||||
#include "wx/gdiobj.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// classes
|
||||
@@ -30,12 +26,6 @@ class wxWindow;
|
||||
|
||||
class wxFont;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// global variables
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
extern const wxChar* wxEmptyString;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFont
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -46,6 +36,7 @@ public:
|
||||
// ctors and such
|
||||
wxFont() { Init(); }
|
||||
wxFont(const wxFont& font) { Init(); Ref(font); }
|
||||
wxFont(const wxString& fontname, const wxFontData& fontdata);
|
||||
|
||||
// assignment
|
||||
wxFont& operator=(const wxFont& font);
|
||||
@@ -91,7 +82,6 @@ public:
|
||||
virtual void SetEncoding(wxFontEncoding encoding);
|
||||
|
||||
// implementation from now on
|
||||
wxFont( GdkFont* font, char *xFontName );
|
||||
void Unshare();
|
||||
|
||||
GdkFont* GetInternalFont(float scale = 1.0) const;
|
||||
|
@@ -2,10 +2,10 @@
|
||||
// Name: fontdlgg.h
|
||||
// Purpose: wxFontDialog
|
||||
// Author: Robert Roebling
|
||||
// Created:
|
||||
// Created:
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Robert Roebling
|
||||
// Licence: wxWindows licence
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __GTK_FONTDLGH__
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
wxFontDialog( wxWindow *parent, wxFontData *data = (wxFontData *) NULL );
|
||||
~wxFontDialog();
|
||||
|
||||
inline wxFontData& GetFontData() { return m_fontData; }
|
||||
wxFontData& GetFontData() { return m_fontData; }
|
||||
|
||||
//protected:
|
||||
wxFontData m_fontData;
|
||||
|
32
include/wx/unix/fontutil.h
Normal file
32
include/wx/unix/fontutil.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/unix/fontutil.h
|
||||
// Purpose: font-related helper functions for Unix/X11
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 05.11.99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) wxWindows team
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_UNIX_FONTUTIL_H_
|
||||
#define _WX_UNIX_FONTUTIL_H_
|
||||
|
||||
#ifdef __X__
|
||||
typedef XFontStruct *wxNativeFont;
|
||||
#elif defined(__WXGTK__)
|
||||
typedef GdkFont *wxNativeFont;
|
||||
#else
|
||||
#error "Unsupported toolkit"
|
||||
#endif
|
||||
|
||||
// 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 // _WX_UNIX_FONTUTIL_H_
|
@@ -377,38 +377,6 @@ 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);
|
||||
|
||||
// fills xencoding and xregistry with the X font spec parts for the given
|
||||
// encoding ('*' if encoding == wxFONTENCODING_SYSTEM) and returns TRUE if any
|
||||
// fonts with this encoding exist or FALSE if it's unknown (it does *not* mean
|
||||
// that they don't exist!)
|
||||
extern bool wxGetXFontEncoding(wxFontEncoding encoding,
|
||||
wxString *xencoding, wxString *xregistry);
|
||||
|
||||
#endif // X || GTK
|
||||
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user