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$
|
|
|
|
// Copyright: (c) wxWindows team
|
2003-03-17 10:34:04 +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
|
|
|
|
2003-08-09 12:38:21 +00:00
|
|
|
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
1999-10-12 21:52:17 +00:00
|
|
|
#pragma interface "fontbase.h"
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
1999-11-05 19:03:19 +00:00
|
|
|
class WXDLLEXPORT wxFontData;
|
1999-09-29 19:02:07 +00:00
|
|
|
class WXDLLEXPORT wxFontBase;
|
|
|
|
class WXDLLEXPORT wxFont;
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// 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
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
1999-10-23 19:55:01 +00:00
|
|
|
class WXDLLEXPORT wxFontRefData;
|
2000-12-18 23:49:58 +00:00
|
|
|
struct WXDLLEXPORT 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
|
|
|
|
bool underlined = FALSE, // not underlined by default
|
|
|
|
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);
|
|
|
|
|
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?
|
|
|
|
bool Ok() const { return m_refData != NULL; }
|
|
|
|
|
|
|
|
// comparison
|
|
|
|
bool operator == (const wxFont& font) const;
|
|
|
|
bool operator != (const wxFont& font) const;
|
|
|
|
|
|
|
|
// accessors: get the font characteristics
|
|
|
|
virtual int GetPointSize() const = 0;
|
|
|
|
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;
|
2000-12-18 21:15:16 +00:00
|
|
|
virtual wxNativeFontInfo *GetNativeFontInfo() const;
|
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;
|
|
|
|
virtual void SetFamily( int family ) = 0;
|
|
|
|
virtual void SetStyle( int style ) = 0;
|
|
|
|
virtual void SetWeight( int weight ) = 0;
|
|
|
|
virtual void SetFaceName( const wxString& faceName ) = 0;
|
|
|
|
virtual void SetUnderlined( bool underlined ) = 0;
|
|
|
|
virtual void SetEncoding(wxFontEncoding encoding) = 0;
|
2003-02-12 15:42:27 +00:00
|
|
|
void SetNativeFontInfo(const wxNativeFontInfo& info)
|
|
|
|
{ DoSetNativeFontInfo(info); }
|
2001-12-21 21:39:45 +00:00
|
|
|
|
2001-12-21 17:39:13 +00:00
|
|
|
void SetNativeFontInfo(const wxString& info);
|
2001-12-21 21:39:45 +00:00
|
|
|
void 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
|
2003-01-22 17:10:49 +00:00
|
|
|
virtual void SetNoAntiAliasing( bool WXUNUSED(no) = TRUE ) { }
|
2002-12-04 14:11:26 +00:00
|
|
|
virtual bool GetNoAntiAliasing() { return FALSE; }
|
|
|
|
|
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:
|
|
|
|
// get the internal data
|
1999-10-23 19:55:01 +00:00
|
|
|
wxFontRefData *GetFontData() const
|
1999-09-29 19:02:07 +00:00
|
|
|
{ return (wxFontRefData *)m_refData; }
|
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
|
|
|
|
// specifing encoding parameter using this encoding
|
|
|
|
static wxFontEncoding ms_encodingDefault;
|
|
|
|
};
|
|
|
|
|
|
|
|
// include the real class declaration
|
1998-07-10 14:15:17 +00:00
|
|
|
#if 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"
|
1998-07-10 14:15:17 +00:00
|
|
|
#elif defined(__WXGTK__)
|
1999-09-29 19:02:07 +00:00
|
|
|
#include "wx/gtk/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"
|
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
|
|
|
|
|
1999-09-29 19:02:07 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// macros
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#define M_FONTDATA GetFontData()
|
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
#endif
|
1998-08-15 00:23:28 +00:00
|
|
|
// _WX_FONT_H_BASE_
|