]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: font.h | |
3 | // Purpose: | |
4 | // Author: Robert Roebling | |
58614078 | 5 | // Id: $Id$ |
c801d85f | 6 | // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem |
8bbe427f | 7 | // Licence: wxWindows licence |
c801d85f KB |
8 | ///////////////////////////////////////////////////////////////////////////// |
9 | ||
c801d85f KB |
10 | #ifndef __GTKFONTH__ |
11 | #define __GTKFONTH__ | |
12 | ||
13 | #ifdef __GNUG__ | |
0c5d3e1c | 14 | #pragma interface |
c801d85f KB |
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 | ||
0c5d3e1c VZ |
23 | // ---------------------------------------------------------------------------- |
24 | // conditional compilation | |
25 | // ---------------------------------------------------------------------------- | |
26 | ||
27 | #define wxUSE_FONTNAMEDIRECTORY 0 | |
28 | ||
29 | // ---------------------------------------------------------------------------- | |
c801d85f | 30 | // classes |
0c5d3e1c | 31 | // ---------------------------------------------------------------------------- |
c801d85f KB |
32 | |
33 | class wxDC; | |
34 | class wxPaintDC; | |
35 | class wxWindow; | |
36 | ||
37 | class wxFont; | |
c801d85f | 38 | |
0c5d3e1c VZ |
39 | #if wxUSE_FONTNAMEDIRECTORY |
40 | class wxFontNameDirectory; | |
41 | #endif | |
42 | ||
43 | // ---------------------------------------------------------------------------- | |
c801d85f | 44 | // global variables |
0c5d3e1c | 45 | // ---------------------------------------------------------------------------- |
c801d85f | 46 | |
9d2f3c71 | 47 | extern const wxChar* wxEmptyString; |
c801d85f | 48 | |
0c5d3e1c VZ |
49 | #if wxUSE_FONTNAMEDIRECTORY |
50 | extern wxFontNameDirectory *wxTheFontNameDirectory; | |
51 | #endif | |
52 | ||
53 | // ---------------------------------------------------------------------------- | |
c801d85f | 54 | // wxFont |
0c5d3e1c | 55 | // ---------------------------------------------------------------------------- |
c801d85f | 56 | |
0c5d3e1c | 57 | class wxFont : public wxFontBase |
c801d85f | 58 | { |
358fc25c | 59 | public: |
0c5d3e1c VZ |
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) | |
c801d85f KB |
121 | }; |
122 | ||
0c5d3e1c VZ |
123 | #if wxUSE_FONTNAMEDIRECTORY |
124 | ||
125 | // ---------------------------------------------------------------------------- | |
c801d85f | 126 | // wxFontDirectory |
0c5d3e1c | 127 | // ---------------------------------------------------------------------------- |
c801d85f | 128 | |
8bbe427f | 129 | class wxFontNameDirectory: public wxObject |
c801d85f KB |
130 | { |
131 | DECLARE_DYNAMIC_CLASS(wxFontNameDirectory) | |
8bbe427f | 132 | |
c801d85f | 133 | public: |
8bbe427f | 134 | wxFontNameDirectory(); |
c801d85f KB |
135 | ~wxFontNameDirectory(); |
136 | ||
8bbe427f | 137 | void Initialize(); |
c801d85f KB |
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); | |
8bbe427f | 145 | int GetNewFontId(); |
c801d85f KB |
146 | char* GetPostScriptName(int fontid, int weight, int style); |
147 | char* GetScreenName(int fontid, int weight, int style); | |
8bbe427f | 148 | |
c801d85f KB |
149 | class wxHashTable *table; |
150 | int nextFontId; | |
151 | }; | |
0c5d3e1c VZ |
152 | |
153 | #endif // wxUSE_FONTNAMEDIRECTORY | |
c801d85f | 154 | |
c801d85f | 155 | #endif // __GTKFONTH__ |