]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/font.cpp
reSWIGged
[wxWidgets.git] / src / palmos / font.cpp
CommitLineData
ffecfa5a
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/palmos/font.cpp
3// Purpose: wxFont class
e2731512 4// Author: William Osborne - minimal working wxPalmOS port
ffecfa5a
JS
5// Modified by:
6// Created: 10/14/04
e2731512 7// RCS-ID: $Id$
ffecfa5a
JS
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
48wxBEGIN_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 )
56wxEND_ENUM( wxFontFamily )
57
58wxBEGIN_ENUM( wxFontStyle )
59 wxENUM_MEMBER( wxNORMAL )
60 wxENUM_MEMBER( wxITALIC )
61 wxENUM_MEMBER( wxSLANT )
62wxEND_ENUM( wxFontStyle )
63
64wxBEGIN_ENUM( wxFontWeight )
65 wxENUM_MEMBER( wxNORMAL )
66 wxENUM_MEMBER( wxLIGHT )
67 wxENUM_MEMBER( wxBOLD )
68wxEND_ENUM( wxFontWeight )
69
70IMPLEMENT_DYNAMIC_CLASS_WITH_COPY_XTI(wxFont, wxGDIObject,"wx/font.h")
71
72wxBEGIN_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"))
80wxEND_PROPERTIES_TABLE()
81
82wxCONSTRUCTOR_6( wxFont , int , Size , int , Family , int , Style , int , Weight , bool , Underlined , wxString , Face )
83
84wxBEGIN_HANDLERS_TABLE(wxFont)
85wxEND_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
100class WXDLLEXPORT wxFontRefData: public wxGDIRefData
101{
102public:
103 // constructors
104 wxFontRefData()
105 {
4055ed82
WS
106 Init(-1, wxSize(0, 0), false, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
107 wxFONTWEIGHT_NORMAL, false, wxEmptyString,
ffecfa5a
JS
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;
4055ed82 221 m_sizeUsingPixels = false;
ffecfa5a
JS
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;
4055ed82 234 m_sizeUsingPixels = true;
ffecfa5a
JS
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
289protected:
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
330void 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
342void wxFontRefData::Init(const wxNativeFontInfo& info, WXHFONT hFont)
343{
344}
345
346wxFontRefData::~wxFontRefData()
347{
348}
349
350bool wxFontRefData::Alloc(wxFont *font)
351{
352 return false;
353}
354
355void wxFontRefData::Free()
356{
357}
358
359// ----------------------------------------------------------------------------
360// wxNativeFontInfo
361// ----------------------------------------------------------------------------
362
363void wxNativeFontInfo::SetPixelSize(const wxSize& pixelSize)
364{
365}
366
367// ----------------------------------------------------------------------------
368// wxFont
369// ----------------------------------------------------------------------------
370
371void wxFont::Init()
372{
373}
374
375bool wxFont::Create(const wxNativeFontInfo& info, WXHFONT hFont)
376{
377 return false;
378}
379
380wxFont::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 */
387bool 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{
4055ed82 397 return false;
ffecfa5a
JS
398}
399
400wxFont::~wxFont()
401{
402}
403
404// ----------------------------------------------------------------------------
405// real implementation
406// ----------------------------------------------------------------------------
407
408bool wxFont::RealizeResource()
409{
4055ed82 410 return false;
ffecfa5a
JS
411}
412
413bool wxFont::FreeResource(bool WXUNUSED(force))
414{
415 return false;
416}
417
418WXHANDLE wxFont::GetResourceHandle() const
419{
420 return (WXHANDLE)0;
421}
422
ffecfa5a
JS
423bool wxFont::IsFree() const
424{
425 return false;
426}
427
428void wxFont::Unshare()
429{
430}
431
432// ----------------------------------------------------------------------------
433// change font attribute: we recreate font when doing it
434// ----------------------------------------------------------------------------
435
436void wxFont::SetPointSize(int pointSize)
437{
438}
439
440void wxFont::SetPixelSize(const wxSize& pixelSize)
441{
442}
443
444void wxFont::SetFamily(int family)
445{
446}
447
448void wxFont::SetStyle(int style)
449{
450}
451
452void wxFont::SetWeight(int weight)
453{
454}
455
456void wxFont::SetFaceName(const wxString& faceName)
457{
458}
459
460void wxFont::SetUnderlined(bool underlined)
461{
462}
463
464void wxFont::SetEncoding(wxFontEncoding encoding)
465{
466}
467
468void wxFont::DoSetNativeFontInfo(const wxNativeFontInfo& info)
469{
470}
471
472// ----------------------------------------------------------------------------
473// accessors
474// ----------------------------------------------------------------------------
475
476int wxFont::GetPointSize() const
477{
478 return 0;
479}
480
481wxSize wxFont::GetPixelSize() const
482{
483 return wxSize(0,0);
484}
485
486bool wxFont::IsUsingSizeInPixels() const
487{
488 return false;
489}
490
491int wxFont::GetFamily() const
492{
493 return wxFONTFAMILY_ROMAN;
494}
495
496int wxFont::GetStyle() const
497{
498 return wxFONTSTYLE_NORMAL;
499}
500
501int wxFont::GetWeight() const
502{
503 return wxFONTWEIGHT_NORMAL;
504}
505
506bool wxFont::GetUnderlined() const
507{
508 return false;
509}
510
511wxString wxFont::GetFaceName() const
512{
513 return wxEmptyString;
514}
515
516wxFontEncoding wxFont::GetEncoding() const
517{
518 return wxFONTENCODING_SYSTEM;
519}
520
521const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
522{
523 return NULL;
524}
525
526bool wxFont::IsFixedWidth() const
527{
528 return false;
529}
530