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
|
|
|
|
1999-10-12 17:52:17 -04:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#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
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// standard font families
|
|
|
|
enum wxFontFamily
|
|
|
|
{
|
|
|
|
wxFONTFAMILY_DEFAULT = wxDEFAULT,
|
|
|
|
wxFONTFAMILY_DECORATIVE = wxDECORATIVE,
|
|
|
|
wxFONTFAMILY_ROMAN = wxROMAN,
|
|
|
|
wxFONTFAMILY_SCRIPT = wxSCRIPT,
|
|
|
|
wxFONTFAMILY_SWISS = wxSWISS,
|
|
|
|
wxFONTFAMILY_MODERN = wxMODERN,
|
|
|
|
wxFONTFAMILY_TELETYPE = wxTELETYPE,
|
|
|
|
wxFONTFAMILY_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
// 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
|
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// 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
|
2001-02-15 16:51:14 -05:00
|
|
|
#ifdef __WXMAC_X__
|
|
|
|
virtual ~wxFontBase() {} // Added min for Mac X
|
|
|
|
#endif
|
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
|
|
|
|
|
|
|
// 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;
|
|
|
|
wxString GetNativeFontInfoDesc() 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);
|
1999-09-29 15:02:07 -04:00
|
|
|
|
2000-12-18 16:15:16 -05:00
|
|
|
// VZ: there is no void SetNativeFontInfo(const wxString& info), needed?
|
|
|
|
|
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
|
|
|
|
static wxFontEncoding GetDefaultEncoding()
|
|
|
|
{ return ms_encodingDefault; }
|
|
|
|
static void SetDefaultEncoding(wxFontEncoding encoding)
|
|
|
|
{ ms_encodingDefault = encoding; }
|
|
|
|
|
|
|
|
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"
|
2001-06-26 16:59:19 -04:00
|
|
|
#elif defined(__WXMGL__)
|
|
|
|
#include "wx/mgl/font.h"
|
1998-08-07 16:23:17 -04:00
|
|
|
#elif defined(__WXQT__)
|
1999-09-29 15:02:07 -04:00
|
|
|
#include "wx/qt/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_
|