]> git.saurik.com Git - wxWidgets.git/blame - src/mac/fontenum.cpp
Implement GetValue() and SetValue() and send an event when clicked
[wxWidgets.git] / src / mac / fontenum.cpp
CommitLineData
ee6b1d97
SC
1///////////////////////////////////////////////////////////////////////////////
2// Name: mac/fontenum.cpp
3// Purpose: wxFontEnumerator class for MacOS
4// Author: Stefan Csomor
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
8// Copyright: (c) Stefan Csomor
9// Licence: wxWindows licence
10///////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
20#ifdef __GNUG__
21 #pragma implementation "fontenum.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/font.h"
33#endif
34
35#include "wx/fontenum.h"
5b781a67 36#include "wx/fontutil.h"
ee6b1d97 37#include "wx/fontmap.h"
3b7e6277 38#include "wx/fontutil.h"
ee6b1d97 39
76a5e5d2
SC
40#include "wx/mac/private.h"
41
ee6b1d97
SC
42// ----------------------------------------------------------------------------
43// private classes
44// ----------------------------------------------------------------------------
45
46class wxFontEnumeratorHelper
47{
48public:
49 wxFontEnumeratorHelper(wxFontEnumerator *fontEnum);
50
51 // control what exactly are we enumerating
52 bool SetEncoding(wxFontEncoding encoding);
53 void SetFixedOnly(bool fixedOnly)
54 { m_fixedOnly = fixedOnly; }
55
56 // call to start enumeration
57 void DoEnumerate();
58
59private:
60 // the object we forward calls to OnFont() to
61 wxFontEnumerator *m_fontEnum;
62
63 // if != -1, enum only fonts which have this encoding
64 int m_charset;
65
66 // if not empty, enum only the fonts with this facename
67 wxString m_facename;
68
69 // if TRUE, enum only fixed fonts
70 bool m_fixedOnly;
71};
72// ============================================================================
73// implementation
74// ============================================================================
75
76// ----------------------------------------------------------------------------
77// wxFontEnumeratorHelper
78// ----------------------------------------------------------------------------
79
80wxFontEnumeratorHelper::wxFontEnumeratorHelper(wxFontEnumerator *fontEnum)
81{
82 m_fontEnum = fontEnum;
83 m_charset = -1;
84 m_fixedOnly = FALSE;
85}
86
87bool wxFontEnumeratorHelper::SetEncoding(wxFontEncoding encoding)
88{
89 wxNativeEncodingInfo info;
90 if ( !wxGetNativeFontEncoding(encoding, &info) )
91 {
142b3bc2 92 if ( !wxFontMapper::Get()->GetAltForEncoding(encoding, &info) )
ee6b1d97
SC
93 {
94 // no such encodings at all
95 return FALSE;
96 }
97 }
98 m_charset = info.charset;
99 m_facename = info.facename;
100
101 return TRUE;
102}
103
104void wxFontEnumeratorHelper::DoEnumerate()
105{
e40298d5
JS
106 MenuHandle menu ;
107 Str255 p_name ;
108
109 short lines ;
110
111 menu = NewMenu( 32000 , "\pFont" ) ;
112 AppendResMenu( menu , 'FONT' ) ;
113 lines = CountMenuItems( menu ) ;
114
115 for ( int i = 1 ; i < lines+1 ; i ++ )
116 {
117 GetMenuItemText( menu , i , p_name ) ;
118 wxString c_name = wxMacMakeStringFromPascal(p_name) ;
119
120 /*
121
122 if ( m_fixedOnly )
123 {
124 // check that it's a fixed pitch font (there is *no* error here, the
125 // flag name is misleading!)
126 if ( tm->tmPitchAndFamily & TMPF_FIXED_PITCH )
127 {
128 // not a fixed pitch font
129 return TRUE;
130 }
131 }
132
133 if ( m_charset != -1 )
134 {
135 // check that we have the right encoding
136 if ( lf->lfCharSet != m_charset )
137 {
138 return TRUE;
139 }
140 }
141
142 */
143 m_fontEnum->OnFacename( c_name ) ;
144 }
145 DisposeMenu( menu ) ;
ee6b1d97
SC
146}
147
148// ----------------------------------------------------------------------------
149// wxFontEnumerator
150// ----------------------------------------------------------------------------
151
152bool wxFontEnumerator::EnumerateFacenames(wxFontEncoding encoding,
153 bool fixedWidthOnly)
154{
155 wxFontEnumeratorHelper fe(this);
156 if ( fe.SetEncoding(encoding) )
157 {
158 fe.SetFixedOnly(fixedWidthOnly);
159
160 fe.DoEnumerate();
161 }
162 // else: no such fonts, unknown encoding
163
164 return TRUE;
165}
166
167bool wxFontEnumerator::EnumerateEncodings(const wxString& family)
168{
8d480857 169 wxFAIL_MSG(wxT("wxFontEnumerator::EnumerateEncodings() not yet implemented"));
ee6b1d97
SC
170
171 return TRUE;
172}