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$
|
|
|
|
// Copyright: (c) wxWindows team
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
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
|
|
|
|
2002-08-31 07:29:13 -04:00
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
1999-10-12 17:52:17 -04:00
|
|
|
#pragma interface "fontbase.h"
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// forward declarations
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
1999-11-05 14:03:19 -05:00
|
|
|
class WXDLLEXPORT wxFontData;
|
1999-09-29 15:02:07 -04:00
|
|
|
class WXDLLEXPORT wxFontBase;
|
|
|
|
class WXDLLEXPORT wxFont;
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// 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
|
|
|
|
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 15:02:07 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxFontBase represents a font object
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
1999-10-23 15:55:01 -04:00
|
|
|
class WXDLLEXPORT wxFontRefData;
|
2000-12-18 18:49:58 -05:00
|
|
|
struct WXDLLEXPORT wxNativeFontInfo;
|
1999-10-23 15:55:01 -04:00
|
|
|
|
2000-01-09 19:55:05 -05:00
|
|
|
class WXDLLEXPORT 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
|
|
|
|
bool underlined = FALSE, // not underlined by default
|
|
|
|
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);
|
|
|
|
|
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
|
|
|
|
|
|
|
// 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 16:15:16 -05:00
|
|
|
virtual wxNativeFontInfo *GetNativeFontInfo() const;
|
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;
|
|
|
|
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;
|
2000-12-17 20:00:25 -05:00
|
|
|
virtual void SetNativeFontInfo(const wxNativeFontInfo& info);
|
2001-12-21 16:39:45 -05:00
|
|
|
|
2001-12-21 12:39:13 -05:00
|
|
|
void SetNativeFontInfo(const wxString& info);
|
2001-12-21 16:39:45 -05:00
|
|
|
void 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;
|
|
|
|
|
|
|
|
// 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:
|
|
|
|
// get the internal data
|
1999-10-23 15:55:01 -04:00
|
|
|
wxFontRefData *GetFontData() const
|
1999-09-29 15:02:07 -04:00
|
|
|
{ return (wxFontRefData *)m_refData; }
|
|
|
|
|
|
|
|
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 10:15:17 -04:00
|
|
|
#if 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"
|
1998-07-10 10:15:17 -04:00
|
|
|
#elif defined(__WXGTK__)
|
1999-09-29 15:02:07 -04:00
|
|
|
#include "wx/gtk/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"
|
1998-08-14 20:23:28 -04:00
|
|
|
#elif defined(__WXMAC__)
|
1999-09-29 15:02:07 -04:00
|
|
|
#include "wx/mac/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-08-14 20:23:28 -04:00
|
|
|
#elif defined(__WXSTUBS__)
|
1999-09-29 15:02:07 -04:00
|
|
|
#include "wx/stubs/font.h"
|
1998-05-20 10:01:55 -04:00
|
|
|
#endif
|
|
|
|
|
1999-09-29 15:02:07 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// macros
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#define M_FONTDATA GetFontData()
|
|
|
|
|
1998-05-20 10:01:55 -04:00
|
|
|
#endif
|
1998-08-14 20:23:28 -04:00
|
|
|
// _WX_FONT_H_BASE_
|