1999-09-29 15:02:07 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/font.h
|
|
|
|
// Purpose: wxFontBase class: the interface of wxFont
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Modified by:
|
|
|
|
// Created: 20.09.99
|
|
|
|
// RCS-ID: $Id$
|
2004-05-23 10:56:36 -04:00
|
|
|
// Copyright: (c) wxWidgets team
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1999-09-29 15:02:07 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-14 20:23:28 -04:00
|
|
|
#ifndef _WX_FONT_H_BASE_
|
|
|
|
#define _WX_FONT_H_BASE_
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-09-29 15:02:07 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "wx/defs.h" // for wxDEFAULT &c
|
2000-07-15 15:51:35 -04:00
|
|
|
#include "wx/fontenc.h" // the font encoding constants
|
1999-09-29 15:02:07 -04:00
|
|
|
#include "wx/gdiobj.h" // the base class
|
2008-03-16 18:42:38 -04:00
|
|
|
#include "wx/gdicmn.h" // for wxGDIObjListBase
|
1999-09-29 15:02:07 -04:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// forward declarations
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2007-07-09 06:09:52 -04:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxFontData;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxFontBase;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxFont;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxSize;
|
1999-09-29 15:02:07 -04:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// font constants
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2002-01-18 15:01:49 -05:00
|
|
|
// standard font families: these may be used only for the font creation, it
|
|
|
|
// doesn't make sense to query an existing font for its font family as,
|
|
|
|
// especially if the font had been created from a native font description, it
|
|
|
|
// may be unknown
|
1999-09-29 15:02:07 -04:00
|
|
|
enum wxFontFamily
|
|
|
|
{
|
|
|
|
wxFONTFAMILY_DEFAULT = wxDEFAULT,
|
|
|
|
wxFONTFAMILY_DECORATIVE = wxDECORATIVE,
|
|
|
|
wxFONTFAMILY_ROMAN = wxROMAN,
|
|
|
|
wxFONTFAMILY_SCRIPT = wxSCRIPT,
|
|
|
|
wxFONTFAMILY_SWISS = wxSWISS,
|
|
|
|
wxFONTFAMILY_MODERN = wxMODERN,
|
|
|
|
wxFONTFAMILY_TELETYPE = wxTELETYPE,
|
2002-01-18 15:01:49 -05:00
|
|
|
wxFONTFAMILY_MAX,
|
|
|
|
wxFONTFAMILY_UNKNOWN = wxFONTFAMILY_MAX
|
1999-09-29 15:02:07 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// font styles
|
|
|
|
enum wxFontStyle
|
|
|
|
{
|
|
|
|
wxFONTSTYLE_NORMAL = wxNORMAL,
|
|
|
|
wxFONTSTYLE_ITALIC = wxITALIC,
|
|
|
|
wxFONTSTYLE_SLANT = wxSLANT,
|
|
|
|
wxFONTSTYLE_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
// font weights
|
|
|
|
enum wxFontWeight
|
|
|
|
{
|
|
|
|
wxFONTWEIGHT_NORMAL = wxNORMAL,
|
|
|
|
wxFONTWEIGHT_LIGHT = wxLIGHT,
|
|
|
|
wxFONTWEIGHT_BOLD = wxBOLD,
|
|
|
|
wxFONTWEIGHT_MAX
|
|
|
|
};
|
|
|
|
|
2002-11-02 18:58:52 -05:00
|
|
|
// the font flag bits for the new font ctor accepting one combined flags word
|
2008-09-25 15:15:28 -04:00
|
|
|
enum wxFontFlag
|
2002-11-02 18:58:52 -05:00
|
|
|
{
|
|
|
|
// no special flags: font with default weight/slant/anti-aliasing
|
|
|
|
wxFONTFLAG_DEFAULT = 0,
|
|
|
|
|
|
|
|
// slant flags (default: no slant)
|
|
|
|
wxFONTFLAG_ITALIC = 1 << 0,
|
|
|
|
wxFONTFLAG_SLANT = 1 << 1,
|
|
|
|
|
|
|
|
// weight flags (default: medium)
|
|
|
|
wxFONTFLAG_LIGHT = 1 << 2,
|
|
|
|
wxFONTFLAG_BOLD = 1 << 3,
|
|
|
|
|
|
|
|
// anti-aliasing flag: force on or off (default: the current system default)
|
|
|
|
wxFONTFLAG_ANTIALIASED = 1 << 4,
|
|
|
|
wxFONTFLAG_NOT_ANTIALIASED = 1 << 5,
|
|
|
|
|
|
|
|
// underlined/strikethrough flags (default: no lines)
|
|
|
|
wxFONTFLAG_UNDERLINED = 1 << 6,
|
|
|
|
wxFONTFLAG_STRIKETHROUGH = 1 << 7,
|
|
|
|
|
|
|
|
// the mask of all currently used flags
|
|
|
|
wxFONTFLAG_MASK = wxFONTFLAG_ITALIC |
|
|
|
|
wxFONTFLAG_SLANT |
|
|
|
|
wxFONTFLAG_LIGHT |
|
|
|
|
wxFONTFLAG_BOLD |
|
|
|
|
wxFONTFLAG_ANTIALIASED |
|
|
|
|
wxFONTFLAG_NOT_ANTIALIASED |
|
|
|
|
wxFONTFLAG_UNDERLINED |
|
|
|
|
wxFONTFLAG_STRIKETHROUGH
|
|
|
|
};
|
|
|
|
|
1999-09-29 15:02:07 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxFontBase represents a font object
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2007-07-09 06:09:52 -04:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxNativeFontInfo;
|
1999-10-23 15:55:01 -04:00
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxFontBase : public wxGDIObject
|
1999-09-29 15:02:07 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
// creator function
|
2002-01-07 16:52:28 -05:00
|
|
|
virtual ~wxFontBase();
|
2000-12-18 16:15:16 -05:00
|
|
|
|
|
|
|
// from the font components
|
1999-09-29 15:02:07 -04:00
|
|
|
static wxFont *New(
|
|
|
|
int pointSize, // size of the font in points
|
|
|
|
int family, // see wxFontFamily enum
|
|
|
|
int style, // see wxFontStyle enum
|
|
|
|
int weight, // see wxFontWeight enum
|
2004-09-14 08:08:28 -04:00
|
|
|
bool underlined = false, // not underlined by default
|
1999-09-29 15:02:07 -04:00
|
|
|
const wxString& face = wxEmptyString, // facename
|
|
|
|
wxFontEncoding encoding = wxFONTENCODING_DEFAULT); // ISO8859-X, ...
|
2000-12-18 16:15:16 -05:00
|
|
|
|
2002-11-02 18:58:52 -05:00
|
|
|
// from the font components but using the font flags instead of separate
|
|
|
|
// parameters for each flag
|
|
|
|
static wxFont *New(int pointSize,
|
|
|
|
wxFontFamily family,
|
|
|
|
int flags = wxFONTFLAG_DEFAULT,
|
|
|
|
const wxString& face = wxEmptyString,
|
|
|
|
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
|
|
|
|
2004-09-25 19:03:44 -04:00
|
|
|
// from the font components
|
|
|
|
static wxFont *New(
|
|
|
|
const wxSize& pixelSize, // size of the font in pixels
|
|
|
|
int family, // see wxFontFamily enum
|
|
|
|
int style, // see wxFontStyle enum
|
|
|
|
int weight, // see wxFontWeight enum
|
2004-12-20 07:44:22 -05:00
|
|
|
bool underlined = false, // not underlined by default
|
2004-09-25 19:03:44 -04:00
|
|
|
const wxString& face = wxEmptyString, // facename
|
|
|
|
wxFontEncoding encoding = wxFONTENCODING_DEFAULT); // ISO8859-X, ...
|
|
|
|
|
|
|
|
// from the font components but using the font flags instead of separate
|
|
|
|
// parameters for each flag
|
|
|
|
static wxFont *New(const wxSize& pixelSize,
|
|
|
|
wxFontFamily family,
|
|
|
|
int flags = wxFONTFLAG_DEFAULT,
|
|
|
|
const wxString& face = wxEmptyString,
|
|
|
|
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
|
|
|
|
2000-12-18 16:15:16 -05:00
|
|
|
// from the (opaque) native font description object
|
|
|
|
static wxFont *New(const wxNativeFontInfo& nativeFontDesc);
|
|
|
|
|
|
|
|
// from the string representation of wxNativeFontInfo
|
|
|
|
static wxFont *New(const wxString& strNativeFontDesc);
|
1999-09-29 15:02:07 -04:00
|
|
|
|
|
|
|
// comparison
|
2007-12-15 12:54:20 -05:00
|
|
|
bool operator==(const wxFont& font) const;
|
|
|
|
bool operator!=(const wxFont& font) const { return !(*this == font); }
|
1999-09-29 15:02:07 -04:00
|
|
|
|
|
|
|
// accessors: get the font characteristics
|
|
|
|
virtual int GetPointSize() const = 0;
|
2004-09-25 19:03:44 -04:00
|
|
|
virtual wxSize GetPixelSize() const;
|
|
|
|
virtual bool IsUsingSizeInPixels() const;
|
1999-09-29 15:02:07 -04:00
|
|
|
virtual int GetFamily() const = 0;
|
|
|
|
virtual int GetStyle() const = 0;
|
|
|
|
virtual int GetWeight() const = 0;
|
|
|
|
virtual bool GetUnderlined() const = 0;
|
|
|
|
virtual wxString GetFaceName() const = 0;
|
|
|
|
virtual wxFontEncoding GetEncoding() const = 0;
|
2003-09-23 21:23:37 -04:00
|
|
|
virtual const wxNativeFontInfo *GetNativeFontInfo() const = 0;
|
2001-12-21 16:39:45 -05:00
|
|
|
|
2002-01-14 14:04:35 -05:00
|
|
|
virtual bool IsFixedWidth() const;
|
|
|
|
|
2000-12-18 16:15:16 -05:00
|
|
|
wxString GetNativeFontInfoDesc() const;
|
2001-12-21 16:39:45 -05:00
|
|
|
wxString GetNativeFontInfoUserDesc() const;
|
1999-09-29 15:02:07 -04:00
|
|
|
|
|
|
|
// change the font characteristics
|
|
|
|
virtual void SetPointSize( int pointSize ) = 0;
|
2004-09-25 19:03:44 -04:00
|
|
|
virtual void SetPixelSize( const wxSize& pixelSize );
|
1999-09-29 15:02:07 -04:00
|
|
|
virtual void SetFamily( int family ) = 0;
|
|
|
|
virtual void SetStyle( int style ) = 0;
|
|
|
|
virtual void SetWeight( int weight ) = 0;
|
|
|
|
virtual void SetUnderlined( bool underlined ) = 0;
|
|
|
|
virtual void SetEncoding(wxFontEncoding encoding) = 0;
|
2006-05-28 20:03:36 -04:00
|
|
|
virtual bool SetFaceName( const wxString& faceName );
|
2003-02-12 10:42:27 -05:00
|
|
|
void SetNativeFontInfo(const wxNativeFontInfo& info)
|
|
|
|
{ DoSetNativeFontInfo(info); }
|
2001-12-21 16:39:45 -05:00
|
|
|
|
2006-05-28 20:03:36 -04:00
|
|
|
bool SetNativeFontInfo(const wxString& info);
|
|
|
|
bool SetNativeFontInfoUserDesc(const wxString& info);
|
2000-12-18 16:15:16 -05:00
|
|
|
|
1999-09-29 15:02:07 -04:00
|
|
|
// translate the fonts into human-readable string (i.e. GetStyleString()
|
|
|
|
// will return "wxITALIC" for an italic font, ...)
|
|
|
|
wxString GetFamilyString() const;
|
|
|
|
wxString GetStyleString() const;
|
|
|
|
wxString GetWeightString() const;
|
|
|
|
|
2002-12-04 09:11:26 -05:00
|
|
|
// Unofficial API, don't use
|
2004-09-14 08:08:28 -04:00
|
|
|
virtual void SetNoAntiAliasing( bool WXUNUSED(no) = true ) { }
|
|
|
|
virtual bool GetNoAntiAliasing() const { return false; }
|
2002-12-04 09:11:26 -05:00
|
|
|
|
1999-09-29 15:02:07 -04:00
|
|
|
// the default encoding is used for creating all fonts with default
|
|
|
|
// encoding parameter
|
2002-01-25 09:29:33 -05:00
|
|
|
static wxFontEncoding GetDefaultEncoding() { return ms_encodingDefault; }
|
|
|
|
static void SetDefaultEncoding(wxFontEncoding encoding);
|
1999-09-29 15:02:07 -04:00
|
|
|
|
|
|
|
protected:
|
2003-02-12 10:42:27 -05:00
|
|
|
// the function called by both overloads of SetNativeFontInfo()
|
|
|
|
virtual void DoSetNativeFontInfo(const wxNativeFontInfo& info);
|
|
|
|
|
1999-09-29 15:02:07 -04:00
|
|
|
private:
|
|
|
|
// the currently default encoding: by default, it's the default system
|
|
|
|
// encoding, but may be changed by the application using
|
|
|
|
// SetDefaultEncoding() to make all subsequent fonts created without
|
2005-05-31 05:20:43 -04:00
|
|
|
// specifying encoding parameter using this encoding
|
1999-09-29 15:02:07 -04:00
|
|
|
static wxFontEncoding ms_encodingDefault;
|
|
|
|
};
|
|
|
|
|
2007-07-27 19:49:08 -04:00
|
|
|
// wxFontBase <-> wxString utilities, used by wxConfig
|
|
|
|
WXDLLIMPEXP_CORE wxString wxToString(const wxFontBase& font);
|
|
|
|
WXDLLIMPEXP_CORE bool wxFromString(const wxString& str, wxFontBase* font);
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-09-29 15:02:07 -04:00
|
|
|
// include the real class declaration
|
2004-12-20 07:44:22 -05:00
|
|
|
#if defined(__WXPALMOS__)
|
2004-10-19 09:40:30 -04:00
|
|
|
#include "wx/palmos/font.h"
|
|
|
|
#elif defined(__WXMSW__)
|
1999-09-29 15:02:07 -04:00
|
|
|
#include "wx/msw/font.h"
|
1998-07-10 10:15:17 -04:00
|
|
|
#elif defined(__WXMOTIF__)
|
1999-09-29 15:02:07 -04:00
|
|
|
#include "wx/motif/font.h"
|
2006-01-22 22:27:34 -05:00
|
|
|
#elif defined(__WXGTK20__)
|
1999-09-29 15:02:07 -04:00
|
|
|
#include "wx/gtk/font.h"
|
2006-01-22 22:27:34 -05:00
|
|
|
#elif defined(__WXGTK__)
|
|
|
|
#include "wx/gtk1/font.h"
|
2002-02-05 11:34:33 -05:00
|
|
|
#elif defined(__WXX11__)
|
|
|
|
#include "wx/x11/font.h"
|
2001-06-26 16:59:19 -04:00
|
|
|
#elif defined(__WXMGL__)
|
|
|
|
#include "wx/mgl/font.h"
|
2006-08-27 05:42:42 -04:00
|
|
|
#elif defined(__WXDFB__)
|
|
|
|
#include "wx/dfb/font.h"
|
1998-08-14 20:23:28 -04:00
|
|
|
#elif defined(__WXMAC__)
|
2008-06-11 15:17:41 -04:00
|
|
|
#include "wx/osx/font.h"
|
2003-03-22 01:18:36 -05:00
|
|
|
#elif defined(__WXCOCOA__)
|
|
|
|
#include "wx/cocoa/font.h"
|
1999-07-27 23:38:12 -04:00
|
|
|
#elif defined(__WXPM__)
|
1999-09-29 15:02:07 -04:00
|
|
|
#include "wx/os2/font.h"
|
1998-05-20 10:01:55 -04:00
|
|
|
#endif
|
|
|
|
|
2008-03-16 17:11:12 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxFontList: public wxGDIObjListBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxFont *FindOrCreateFont(int pointSize,
|
|
|
|
wxFontFamily family,
|
|
|
|
wxFontStyle style,
|
|
|
|
wxFontWeight weight,
|
|
|
|
bool underline = false,
|
|
|
|
const wxString& face = wxEmptyString,
|
|
|
|
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
2008-03-24 08:04:34 -04:00
|
|
|
|
|
|
|
#if FUTURE_WXWIN_COMPATIBILITY_3_0
|
|
|
|
wxFont *FindOrCreateFont(int pointSize, int family, int style, int weight,
|
|
|
|
bool underline = false,
|
|
|
|
const wxString& face = wxEmptyString,
|
|
|
|
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
|
|
|
|
{ return FindOrCreateFont(pointSize, (wxFontFamily)family, (wxFontStyle)style,
|
|
|
|
(wxFontWeight)weight, underline, face, encoding); }
|
|
|
|
#endif
|
|
|
|
|
2008-03-16 17:11:12 -04:00
|
|
|
#if WXWIN_COMPATIBILITY_2_6
|
|
|
|
wxDEPRECATED( void AddFont(wxFont*) );
|
|
|
|
wxDEPRECATED( void RemoveFont(wxFont*) );
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
extern WXDLLIMPEXP_DATA_CORE(wxFontList*) wxTheFontList;
|
2008-03-16 17:11:12 -04:00
|
|
|
|
1998-05-20 10:01:55 -04:00
|
|
|
#endif
|
1998-08-14 20:23:28 -04:00
|
|
|
// _WX_FONT_H_BASE_
|