1. added a brief overview of Unicode support
[wxWidgets.git] / include / wx / gtk / font.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: font.h
3 // Purpose:
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifndef __GTKFONTH__
11 #define __GTKFONTH__
12
13 #ifdef __GNUG__
14 #pragma interface
15 #endif
16
17 #include "wx/defs.h"
18 #include "wx/object.h"
19 #include "wx/string.h"
20 #include "wx/hash.h"
21 #include "wx/gdiobj.h"
22
23 // ----------------------------------------------------------------------------
24 // conditional compilation
25 // ----------------------------------------------------------------------------
26
27 #define wxUSE_FONTNAMEDIRECTORY 0
28
29 // ----------------------------------------------------------------------------
30 // classes
31 // ----------------------------------------------------------------------------
32
33 class wxDC;
34 class wxPaintDC;
35 class wxWindow;
36
37 class wxFont;
38
39 #if wxUSE_FONTNAMEDIRECTORY
40 class wxFontNameDirectory;
41 #endif
42
43 // ----------------------------------------------------------------------------
44 // global variables
45 // ----------------------------------------------------------------------------
46
47 extern const wxChar* wxEmptyString;
48
49 #if wxUSE_FONTNAMEDIRECTORY
50 extern wxFontNameDirectory *wxTheFontNameDirectory;
51 #endif
52
53 // ----------------------------------------------------------------------------
54 // wxFont
55 // ----------------------------------------------------------------------------
56
57 class wxFont : public wxFontBase
58 {
59 public:
60 // ctors and such
61 wxFont() { Init(); }
62 wxFont(const wxFont& font) { Init(); Ref(font); }
63
64 // assignment
65 wxFont& operator=(const wxFont& font);
66
67 wxFont(int size,
68 int family,
69 int style,
70 int weight,
71 bool underlined = FALSE,
72 const wxString& face = wxEmptyString,
73 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
74 {
75 Init();
76
77 (void)Create(size, family, style, weight, underlined, face, encoding);
78 }
79
80 bool Create(int size,
81 int family,
82 int style,
83 int weight,
84 bool underlined = FALSE,
85 const wxString& face = wxEmptyString,
86 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
87
88 ~wxFont();
89
90 // implement base class pure virtuals
91 virtual int GetPointSize() const;
92 virtual int GetFamily() const;
93 virtual int GetStyle() const;
94 virtual int GetWeight() const;
95 virtual wxString GetFaceName() const;
96 virtual bool GetUnderlined() const;
97 virtual wxFontEncoding GetEncoding() const;
98
99 virtual void SetPointSize( int pointSize );
100 virtual void SetFamily( int family );
101 virtual void SetStyle( int style );
102 virtual void SetWeight( int weight );
103 virtual void SetFaceName( const wxString& faceName );
104 virtual void SetUnderlined( bool underlined );
105 virtual void SetEncoding(wxFontEncoding encoding);
106
107 // implementation from now on
108 wxFont( GdkFont* font, char *xFontName );
109 void Unshare();
110
111 GdkFont* GetInternalFont(float scale = 1.0) const;
112
113 // no data :-)
114
115 protected:
116 // common part of all ctors
117 void Init();
118
119 private:
120 DECLARE_DYNAMIC_CLASS(wxFont)
121 };
122
123 #if wxUSE_FONTNAMEDIRECTORY
124
125 // ----------------------------------------------------------------------------
126 // wxFontDirectory
127 // ----------------------------------------------------------------------------
128
129 class wxFontNameDirectory: public wxObject
130 {
131 DECLARE_DYNAMIC_CLASS(wxFontNameDirectory)
132
133 public:
134 wxFontNameDirectory();
135 ~wxFontNameDirectory();
136
137 void Initialize();
138 void Initialize(int fontid, int family, const char *name);
139
140 int FindOrCreateFontId(const char *name, int family);
141 char* GetAFMName(int fontid, int weight, int style);
142 int GetFamily(int fontid);
143 int GetFontId(const char *name);
144 char* GetFontName(int fontid);
145 int GetNewFontId();
146 char* GetPostScriptName(int fontid, int weight, int style);
147 char* GetScreenName(int fontid, int weight, int style);
148
149 class wxHashTable *table;
150 int nextFontId;
151 };
152
153 #endif // wxUSE_FONTNAMEDIRECTORY
154
155 #endif // __GTKFONTH__