]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/font.cpp
GTK+1 doesn't have gtk_window_set_type_hint
[wxWidgets.git] / src / palmos / font.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/font.cpp
3 // Purpose: wxFont class
4 // Author: William Osborne
5 // Modified by:
6 // Created: 10/14/04
7 // RCS-ID: $Id:
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "font.h"
22 #endif
23
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
26
27 #ifdef __BORLANDC__
28 #pragma hdrstop
29 #endif
30
31 #ifndef WX_PRECOMP
32 #include "wx/setup.h"
33 #include "wx/list.h"
34 #include "wx/utils.h"
35 #include "wx/app.h"
36 #include "wx/font.h"
37 #include "wx/log.h"
38 #include "wx/encinfo.h"
39 #endif // WX_PRECOMP
40
41 #include "wx/fontutil.h"
42 #include "wx/fontmap.h"
43
44 #include "wx/tokenzr.h"
45
46 #if wxUSE_EXTENDED_RTTI
47
48 wxBEGIN_ENUM( wxFontFamily )
49 wxENUM_MEMBER( wxDEFAULT )
50 wxENUM_MEMBER( wxDECORATIVE )
51 wxENUM_MEMBER( wxROMAN )
52 wxENUM_MEMBER( wxSCRIPT )
53 wxENUM_MEMBER( wxSWISS )
54 wxENUM_MEMBER( wxMODERN )
55 wxENUM_MEMBER( wxTELETYPE )
56 wxEND_ENUM( wxFontFamily )
57
58 wxBEGIN_ENUM( wxFontStyle )
59 wxENUM_MEMBER( wxNORMAL )
60 wxENUM_MEMBER( wxITALIC )
61 wxENUM_MEMBER( wxSLANT )
62 wxEND_ENUM( wxFontStyle )
63
64 wxBEGIN_ENUM( wxFontWeight )
65 wxENUM_MEMBER( wxNORMAL )
66 wxENUM_MEMBER( wxLIGHT )
67 wxENUM_MEMBER( wxBOLD )
68 wxEND_ENUM( wxFontWeight )
69
70 IMPLEMENT_DYNAMIC_CLASS_WITH_COPY_XTI(wxFont, wxGDIObject,"wx/font.h")
71
72 wxBEGIN_PROPERTIES_TABLE(wxFont)
73 wxPROPERTY( Size,int, SetPointSize, GetPointSize, 12 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
74 wxPROPERTY( Family, int , SetFamily, GetFamily, (int)wxDEFAULT , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // wxFontFamily
75 wxPROPERTY( Style, int , SetStyle, GetStyle, (int)wxNORMAL , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // wxFontStyle
76 wxPROPERTY( Weight, int , SetWeight, GetWeight, (int)wxNORMAL , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // wxFontWeight
77 wxPROPERTY( Underlined, bool , SetUnderlined, GetUnderlined, false , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
78 wxPROPERTY( Face, wxString , SetFaceName, GetFaceName, EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
79 wxPROPERTY( Encoding, wxFontEncoding , SetEncoding, GetEncoding, wxFONTENCODING_DEFAULT , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
80 wxEND_PROPERTIES_TABLE()
81
82 wxCONSTRUCTOR_6( wxFont , int , Size , int , Family , int , Style , int , Weight , bool , Underlined , wxString , Face )
83
84 wxBEGIN_HANDLERS_TABLE(wxFont)
85 wxEND_HANDLERS_TABLE()
86
87 #else
88 IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
89 #endif
90
91
92 // ----------------------------------------------------------------------------
93 // constants
94 // ----------------------------------------------------------------------------
95
96 // ----------------------------------------------------------------------------
97 // wxFontRefData - the internal description of the font
98 // ----------------------------------------------------------------------------
99
100 class WXDLLEXPORT wxFontRefData: public wxGDIRefData
101 {
102 public:
103 // constructors
104 wxFontRefData()
105 {
106 Init(-1, wxSize(0, 0), FALSE, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
107 wxFONTWEIGHT_NORMAL, FALSE, wxEmptyString,
108 wxFONTENCODING_DEFAULT);
109 }
110
111 wxFontRefData(int size,
112 const wxSize& pixelSize,
113 bool sizeUsingPixels,
114 int family,
115 int style,
116 int weight,
117 bool underlined,
118 const wxString& faceName,
119 wxFontEncoding encoding)
120 {
121 Init(size, pixelSize, sizeUsingPixels, family, style, weight,
122 underlined, faceName, encoding);
123 }
124
125 wxFontRefData(const wxNativeFontInfo& info, WXHFONT hFont = 0)
126 {
127 Init(info, hFont);
128 }
129
130 wxFontRefData(const wxFontRefData& data)
131 {
132 if ( data.m_nativeFontInfoOk )
133 {
134 Init(data.m_nativeFontInfo);
135 }
136 else
137 {
138 Init(data.m_pointSize, data.m_pixelSize, data.m_sizeUsingPixels,
139 data.m_family, data.m_style, data.m_weight,
140 data.m_underlined, data.m_faceName, data.m_encoding);
141 }
142 }
143
144 virtual ~wxFontRefData();
145
146 // operations
147 bool Alloc(wxFont *font);
148
149 void Free();
150
151 // all wxFont accessors
152 int GetPointSize() const
153 {
154 return m_nativeFontInfoOk ? m_nativeFontInfo.GetPointSize()
155 : m_pointSize;
156 }
157
158 wxSize GetPixelSize() const
159 {
160 return m_nativeFontInfoOk ? m_nativeFontInfo.GetPixelSize()
161 : m_pixelSize;
162 }
163
164 bool IsUsingSizeInPixels() const
165 {
166 return m_nativeFontInfoOk ? true : m_sizeUsingPixels;
167 }
168
169 int GetFamily() const
170 {
171 return m_family;
172 }
173
174 int GetStyle() const
175 {
176 return m_nativeFontInfoOk ? m_nativeFontInfo.GetStyle()
177 : m_style;
178 }
179
180 int GetWeight() const
181 {
182 return m_nativeFontInfoOk ? m_nativeFontInfo.GetWeight()
183 : m_weight;
184 }
185
186 bool GetUnderlined() const
187 {
188 return m_nativeFontInfoOk ? m_nativeFontInfo.GetUnderlined()
189 : m_underlined;
190 }
191
192 wxString GetFaceName() const
193 {
194 wxString s;
195 if ( m_nativeFontInfoOk )
196 s = m_nativeFontInfo.GetFaceName();
197 else
198 s = m_faceName;
199
200 return s;
201 }
202
203 wxFontEncoding GetEncoding() const
204 {
205 return m_nativeFontInfoOk ? m_nativeFontInfo.GetEncoding()
206 : m_encoding;
207 }
208
209 WXHFONT GetHFONT() const { return m_hFont; }
210
211 // ... and setters
212 void SetPointSize(int pointSize)
213 {
214 if ( m_nativeFontInfoOk )
215 {
216 m_nativeFontInfo.SetPointSize(pointSize);
217 }
218 else
219 {
220 m_pointSize = pointSize;
221 m_sizeUsingPixels = FALSE;
222 }
223 }
224
225 void SetPixelSize(const wxSize& pixelSize)
226 {
227 if ( m_nativeFontInfoOk )
228 {
229 m_nativeFontInfo.SetPixelSize(pixelSize);
230 }
231 else
232 {
233 m_pixelSize = pixelSize;
234 m_sizeUsingPixels = TRUE;
235 }
236 }
237
238 void SetFamily(int family)
239 {
240 m_family = family;
241 }
242
243 void SetStyle(int style)
244 {
245 if ( m_nativeFontInfoOk )
246 m_nativeFontInfo.SetStyle((wxFontStyle)style);
247 else
248 m_style = style;
249 }
250
251 void SetWeight(int weight)
252 {
253 if ( m_nativeFontInfoOk )
254 m_nativeFontInfo.SetWeight((wxFontWeight)weight);
255 else
256 m_weight = weight;
257 }
258
259 void SetFaceName(const wxString& faceName)
260 {
261 if ( m_nativeFontInfoOk )
262 m_nativeFontInfo.SetFaceName(faceName);
263 else
264 m_faceName = faceName;
265 }
266
267 void SetUnderlined(bool underlined)
268 {
269 if ( m_nativeFontInfoOk )
270 m_nativeFontInfo.SetUnderlined(underlined);
271 else
272 m_underlined = underlined;
273 }
274
275 void SetEncoding(wxFontEncoding encoding)
276 {
277 if ( m_nativeFontInfoOk )
278 m_nativeFontInfo.SetEncoding(encoding);
279 else
280 m_encoding = encoding;
281 }
282
283 // native font info tests
284 bool HasNativeFontInfo() const { return m_nativeFontInfoOk; }
285
286 const wxNativeFontInfo& GetNativeFontInfo() const
287 { return m_nativeFontInfo; }
288
289 protected:
290 // common part of all ctors
291 void Init(int size,
292 const wxSize& pixelSize,
293 bool sizeUsingPixels,
294 int family,
295 int style,
296 int weight,
297 bool underlined,
298 const wxString& faceName,
299 wxFontEncoding encoding);
300
301 void Init(const wxNativeFontInfo& info, WXHFONT hFont = 0);
302
303 // font characterstics
304 int m_pointSize;
305 wxSize m_pixelSize;
306 bool m_sizeUsingPixels;
307 int m_family;
308 int m_style;
309 int m_weight;
310 bool m_underlined;
311 wxString m_faceName;
312 wxFontEncoding m_encoding;
313
314 // Windows font handle
315 WXHFONT m_hFont;
316
317 // Native font info
318 wxNativeFontInfo m_nativeFontInfo;
319 bool m_nativeFontInfoOk;
320 };
321
322 // ============================================================================
323 // implementation
324 // ============================================================================
325
326 // ----------------------------------------------------------------------------
327 // wxFontRefData
328 // ----------------------------------------------------------------------------
329
330 void wxFontRefData::Init(int pointSize,
331 const wxSize& pixelSize,
332 bool sizeUsingPixels,
333 int family,
334 int style,
335 int weight,
336 bool underlined,
337 const wxString& faceName,
338 wxFontEncoding encoding)
339 {
340 }
341
342 void wxFontRefData::Init(const wxNativeFontInfo& info, WXHFONT hFont)
343 {
344 }
345
346 wxFontRefData::~wxFontRefData()
347 {
348 }
349
350 bool wxFontRefData::Alloc(wxFont *font)
351 {
352 return false;
353 }
354
355 void wxFontRefData::Free()
356 {
357 }
358
359 // ----------------------------------------------------------------------------
360 // wxNativeFontInfo
361 // ----------------------------------------------------------------------------
362
363 void wxNativeFontInfo::SetPixelSize(const wxSize& pixelSize)
364 {
365 }
366
367 // ----------------------------------------------------------------------------
368 // wxFont
369 // ----------------------------------------------------------------------------
370
371 void wxFont::Init()
372 {
373 }
374
375 bool wxFont::Create(const wxNativeFontInfo& info, WXHFONT hFont)
376 {
377 return false;
378 }
379
380 wxFont::wxFont(const wxString& fontdesc)
381 {
382 }
383
384 /* Constructor for a font. Note that the real construction is done
385 * in wxDC::SetFont, when information is available about scaling etc.
386 */
387 bool wxFont::DoCreate(int pointSize,
388 const wxSize& pixelSize,
389 bool sizeUsingPixels,
390 int family,
391 int style,
392 int weight,
393 bool underlined,
394 const wxString& faceName,
395 wxFontEncoding encoding)
396 {
397 return false;
398 }
399
400 wxFont::~wxFont()
401 {
402 }
403
404 // ----------------------------------------------------------------------------
405 // real implementation
406 // ----------------------------------------------------------------------------
407
408 bool wxFont::RealizeResource()
409 {
410 return false;
411 }
412
413 bool wxFont::FreeResource(bool WXUNUSED(force))
414 {
415 return false;
416 }
417
418 WXHANDLE wxFont::GetResourceHandle() const
419 {
420 return (WXHANDLE)0;
421 }
422
423 WXHFONT wxFont::GetHFONT() const
424 {
425 return 0;
426 }
427
428 bool wxFont::IsFree() const
429 {
430 return false;
431 }
432
433 void wxFont::Unshare()
434 {
435 }
436
437 // ----------------------------------------------------------------------------
438 // change font attribute: we recreate font when doing it
439 // ----------------------------------------------------------------------------
440
441 void wxFont::SetPointSize(int pointSize)
442 {
443 }
444
445 void wxFont::SetPixelSize(const wxSize& pixelSize)
446 {
447 }
448
449 void wxFont::SetFamily(int family)
450 {
451 }
452
453 void wxFont::SetStyle(int style)
454 {
455 }
456
457 void wxFont::SetWeight(int weight)
458 {
459 }
460
461 void wxFont::SetFaceName(const wxString& faceName)
462 {
463 }
464
465 void wxFont::SetUnderlined(bool underlined)
466 {
467 }
468
469 void wxFont::SetEncoding(wxFontEncoding encoding)
470 {
471 }
472
473 void wxFont::DoSetNativeFontInfo(const wxNativeFontInfo& info)
474 {
475 }
476
477 // ----------------------------------------------------------------------------
478 // accessors
479 // ----------------------------------------------------------------------------
480
481 int wxFont::GetPointSize() const
482 {
483 return 0;
484 }
485
486 wxSize wxFont::GetPixelSize() const
487 {
488 return wxSize(0,0);
489 }
490
491 bool wxFont::IsUsingSizeInPixels() const
492 {
493 return false;
494 }
495
496 int wxFont::GetFamily() const
497 {
498 return wxFONTFAMILY_ROMAN;
499 }
500
501 int wxFont::GetStyle() const
502 {
503 return wxFONTSTYLE_NORMAL;
504 }
505
506 int wxFont::GetWeight() const
507 {
508 return wxFONTWEIGHT_NORMAL;
509 }
510
511 bool wxFont::GetUnderlined() const
512 {
513 return false;
514 }
515
516 wxString wxFont::GetFaceName() const
517 {
518 return wxEmptyString;
519 }
520
521 wxFontEncoding wxFont::GetEncoding() const
522 {
523 return wxFONTENCODING_SYSTEM;
524 }
525
526 const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
527 {
528 return NULL;
529 }
530
531 bool wxFont::IsFixedWidth() const
532 {
533 return false;
534 }
535