1999-09-29 19:02:07 +00: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 14:56:36 +00:00
|
|
|
// Copyright: (c) wxWidgets team
|
2004-05-23 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
1999-09-29 19:02:07 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-15 00:23:28 +00:00
|
|
|
#ifndef _WX_FONT_H_BASE_
|
|
|
|
#define _WX_FONT_H_BASE_
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1999-09-29 19:02:07 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "wx/defs.h" // for wxDEFAULT &c
|
2000-07-15 19:51:35 +00:00
|
|
|
#include "wx/fontenc.h" // the font encoding constants
|
1999-09-29 19:02:07 +00:00
|
|
|
#include "wx/gdiobj.h" // the base class
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// forward declarations
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2007-07-09 10:09:52 +00:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxFontData;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxFontBase;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxFont;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxSize;
|
1999-09-29 19:02:07 +00:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// font constants
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2002-01-18 20:01:49 +00: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 19:02:07 +00: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 20:01:49 +00:00
|
|
|
wxFONTFAMILY_MAX,
|
|
|
|
wxFONTFAMILY_UNKNOWN = wxFONTFAMILY_MAX
|
1999-09-29 19:02:07 +00: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 23:58:52 +00:00
|
|
|
// the font flag bits for the new font ctor accepting one combined flags word
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
// 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 19:02:07 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxFontBase represents a font object
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2007-07-09 10:09:52 +00:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxNativeFontInfo;
|
1999-10-23 19:55:01 +00:00
|
|
|
|
2000-01-10 00:55:05 +00:00
|
|
|
class WXDLLEXPORT wxFontBase : public wxGDIObject
|
1999-09-29 19:02:07 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
// creator function
|
2002-01-07 21:52:28 +00:00
|
|
|
virtual ~wxFontBase();
|
2000-12-18 21:15:16 +00:00
|
|
|
|
|
|
|
// from the font components
|
1999-09-29 19:02:07 +00: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 12:08:28 +00:00
|
|
|
bool underlined = false, // not underlined by default
|
1999-09-29 19:02:07 +00:00
|
|
|
const wxString& face = wxEmptyString, // facename
|
|
|
|
wxFontEncoding encoding = wxFONTENCODING_DEFAULT); // ISO8859-X, ...
|
2000-12-18 21:15:16 +00:00
|
|
|
|
2002-11-02 23:58:52 +00: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 23:03:44 +00: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 12:44:22 +00:00
|
|
|
bool underlined = false, // not underlined by default
|
2004-09-25 23:03:44 +00: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 21:15:16 +00: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 19:02:07 +00:00
|
|
|
|
|
|
|
// was the font successfully created?
|
2006-10-08 21:56:55 +00:00
|
|
|
bool Ok() const { return IsOk(); }
|
|
|
|
bool IsOk() const { return m_refData != NULL; }
|
1999-09-29 19:02:07 +00:00
|
|
|
|
|
|
|
// comparison
|
|
|
|
bool operator == (const wxFont& font) const;
|
|
|
|
bool operator != (const wxFont& font) const;
|
|
|
|
|
|
|
|
// accessors: get the font characteristics
|
|
|
|
virtual int GetPointSize() const = 0;
|
2004-09-25 23:03:44 +00:00
|
|
|
virtual wxSize GetPixelSize() const;
|
|
|
|
virtual bool IsUsingSizeInPixels() const;
|
1999-09-29 19:02:07 +00: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-24 01:23:37 +00:00
|
|
|
virtual const wxNativeFontInfo *GetNativeFontInfo() const = 0;
|
2001-12-21 21:39:45 +00:00
|
|
|
|
2002-01-14 19:04:35 +00:00
|
|
|
virtual bool IsFixedWidth() const;
|
|
|
|
|
2000-12-18 21:15:16 +00:00
|
|
|
wxString GetNativeFontInfoDesc() const;
|
2001-12-21 21:39:45 +00:00
|
|
|
wxString GetNativeFontInfoUserDesc() const;
|
1999-09-29 19:02:07 +00:00
|
|
|
|
|
|
|
// change the font characteristics
|
|
|
|
virtual void SetPointSize( int pointSize ) = 0;
|
2004-09-25 23:03:44 +00:00
|
|
|
virtual void SetPixelSize( const wxSize& pixelSize );
|
1999-09-29 19:02:07 +00: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-29 00:03:36 +00:00
|
|
|
virtual bool SetFaceName( const wxString& faceName );
|
2003-02-12 15:42:27 +00:00
|
|
|
void SetNativeFontInfo(const wxNativeFontInfo& info)
|
|
|
|
{ DoSetNativeFontInfo(info); }
|
2001-12-21 21:39:45 +00:00
|
|
|
|
2006-05-29 00:03:36 +00:00
|
|
|
bool SetNativeFontInfo(const wxString& info);
|
|
|
|
bool SetNativeFontInfoUserDesc(const wxString& info);
|
2000-12-18 21:15:16 +00:00
|
|
|
|
1999-09-29 19:02:07 +00: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 14:11:26 +00:00
|
|
|
// Unofficial API, don't use
|
2004-09-14 12:08:28 +00:00
|
|
|
virtual void SetNoAntiAliasing( bool WXUNUSED(no) = true ) { }
|
|
|
|
virtual bool GetNoAntiAliasing() const { return false; }
|
2002-12-04 14:11:26 +00:00
|
|
|
|
1999-09-29 19:02:07 +00:00
|
|
|
// the default encoding is used for creating all fonts with default
|
|
|
|
// encoding parameter
|
2002-01-25 14:29:33 +00:00
|
|
|
static wxFontEncoding GetDefaultEncoding() { return ms_encodingDefault; }
|
|
|
|
static void SetDefaultEncoding(wxFontEncoding encoding);
|
1999-09-29 19:02:07 +00:00
|
|
|
|
|
|
|
protected:
|
2003-02-12 15:42:27 +00:00
|
|
|
// the function called by both overloads of SetNativeFontInfo()
|
|
|
|
virtual void DoSetNativeFontInfo(const wxNativeFontInfo& info);
|
|
|
|
|
1999-09-29 19:02:07 +00: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 09:20:43 +00:00
|
|
|
// specifying encoding parameter using this encoding
|
1999-09-29 19:02:07 +00:00
|
|
|
static wxFontEncoding ms_encodingDefault;
|
|
|
|
};
|
|
|
|
|
2007-07-27 23:49:08 +00: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 19:02:07 +00:00
|
|
|
// include the real class declaration
|
2004-12-20 12:44:22 +00:00
|
|
|
#if defined(__WXPALMOS__)
|
2004-10-19 13:40:30 +00:00
|
|
|
#include "wx/palmos/font.h"
|
|
|
|
#elif defined(__WXMSW__)
|
1999-09-29 19:02:07 +00:00
|
|
|
#include "wx/msw/font.h"
|
1998-07-10 14:15:17 +00:00
|
|
|
#elif defined(__WXMOTIF__)
|
1999-09-29 19:02:07 +00:00
|
|
|
#include "wx/motif/font.h"
|
2006-01-23 03:27:34 +00:00
|
|
|
#elif defined(__WXGTK20__)
|
1999-09-29 19:02:07 +00:00
|
|
|
#include "wx/gtk/font.h"
|
2006-01-23 03:27:34 +00:00
|
|
|
#elif defined(__WXGTK__)
|
|
|
|
#include "wx/gtk1/font.h"
|
2002-02-05 16:34:33 +00:00
|
|
|
#elif defined(__WXX11__)
|
|
|
|
#include "wx/x11/font.h"
|
2001-06-26 20:59:19 +00:00
|
|
|
#elif defined(__WXMGL__)
|
|
|
|
#include "wx/mgl/font.h"
|
2006-08-27 09:42:42 +00:00
|
|
|
#elif defined(__WXDFB__)
|
|
|
|
#include "wx/dfb/font.h"
|
1998-08-15 00:23:28 +00:00
|
|
|
#elif defined(__WXMAC__)
|
1999-09-29 19:02:07 +00:00
|
|
|
#include "wx/mac/font.h"
|
2003-03-22 06:18:36 +00:00
|
|
|
#elif defined(__WXCOCOA__)
|
|
|
|
#include "wx/cocoa/font.h"
|
1999-07-28 03:38:12 +00:00
|
|
|
#elif defined(__WXPM__)
|
1999-09-29 19:02:07 +00:00
|
|
|
#include "wx/os2/font.h"
|
1998-05-20 14:01:55 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
1998-08-15 00:23:28 +00:00
|
|
|
// _WX_FONT_H_BASE_
|