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