]> git.saurik.com Git - wxWidgets.git/blame - src/os2/fontenum.cpp
correct painting of the items with custom colours in TVIS_DROPHILITED state (patch...
[wxWidgets.git] / src / os2 / fontenum.cpp
CommitLineData
d8cde57b
DW
1///////////////////////////////////////////////////////////////////////////////
2// Name: msw/fontenum.cpp
3// Purpose: wxFontEnumerator class for Windows
4// Author: Julian Smart
5// Modified by: David Webster to add support for font encodings
6// Created: 01/03/00
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
65571936 9// Licence: wxWindows licence
d8cde57b
DW
10///////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
20// For compilers that support precompilation, includes "wx.h".
21#include "wx/wxprec.h"
22
19193a2c
KB
23#if wxUSE_FONTMAP
24
d8cde57b
DW
25#ifndef WX_PRECOMP
26 #include "wx/font.h"
27#endif
28
29#include "wx/fontenum.h"
30#include "wx/fontmap.h"
bd6685b3 31#include "wx/encinfo.h"
d8cde57b
DW
32
33#include "wx/os2/private.h"
34
35// ----------------------------------------------------------------------------
36// private classes
37// ----------------------------------------------------------------------------
38
39class wxFontEnumeratorHelper
40{
41public:
42 wxFontEnumeratorHelper(wxFontEnumerator *fontEnum);
43
44 // control what exactly are we enumerating
45 bool SetEncoding(wxFontEncoding encoding);
46 void SetFixedOnly(bool fixedOnly)
47 { m_fixedOnly = fixedOnly; }
48
49 // call to start enumeration
50 void DoEnumerate();
51
52 // called by our font enumeration proc
53 bool OnFont(/*const LPLOGFONT lf, const LPTEXTMETRIC tm*/) const;
54
55private:
56 // the object we forward calls to OnFont() to
57 wxFontEnumerator *m_fontEnum;
58
59 // if != -1, enum only fonts which have this encoding
60 int m_charset;
61
62 // if not empty, enum only the fonts with this facename
63 wxString m_facename;
64
6670f564 65 // if true, enum only fixed fonts
d8cde57b
DW
66 bool m_fixedOnly;
67};
68
69// ----------------------------------------------------------------------------
70// private functions
71// ----------------------------------------------------------------------------
72
73// TODO:
74/*
75int CALLBACK wxFontEnumeratorProc(LPLOGFONT lplf, LPTEXTMETRIC lptm,
76 DWORD dwStyle, LONG lParam);
77*/
78
79// ============================================================================
80// implementation
81// ============================================================================
82
83// ----------------------------------------------------------------------------
84// wxFontEnumeratorHelper
85// ----------------------------------------------------------------------------
86
87wxFontEnumeratorHelper::wxFontEnumeratorHelper(wxFontEnumerator *fontEnum)
88{
89 m_fontEnum = fontEnum;
90 m_charset = -1;
91 m_fixedOnly = FALSE;
92}
93
94bool wxFontEnumeratorHelper::SetEncoding(wxFontEncoding encoding)
95{
96 wxNativeEncodingInfo info;
97 if ( !wxGetNativeFontEncoding(encoding, &info) )
98 {
142b3bc2 99 if ( !wxFontMapper::Get()->GetAltForEncoding(encoding, &info) )
d8cde57b
DW
100 {
101 // no such encodings at all
102 return FALSE;
103 }
104 }
105 m_charset = info.charset;
106 m_facename = info.facename;
107
6670f564 108 return true;
d8cde57b
DW
109}
110
111#define wxFONTENUMPROC FONTENUMPROC
112
113void wxFontEnumeratorHelper::DoEnumerate()
114{
115 // TODO:
116 /*
117 HDC hDC = ::GetDC(NULL);
118
119#ifdef __WIN32__
120 LOGFONT lf;
121 lf.lfCharSet = m_charset;
122 wxStrncpy(lf.lfFaceName, m_facename, WXSIZEOF(lf.lfFaceName));
123 lf.lfPitchAndFamily = 0;
124 ::EnumFontFamiliesEx(hDC, &lf, (wxFONTENUMPROC)wxFontEnumeratorProc,
125 (LPARAM)this, 0) ;
126#else // Win16
127 ::EnumFonts(hDC, (LPTSTR)NULL, (FONTENUMPROC)wxFontEnumeratorProc,
128 #ifdef STRICT
129 (LPARAM)
130 #else
131 (LPSTR)
132 #endif
133 this);
134#endif // Win32/16
135
136 ::ReleaseDC(NULL, hDC);
137 */
138}
139
140bool wxFontEnumeratorHelper::OnFont(/*const LPLOGFONT lf,
141 const LPTEXTMETRIC tm */) const
142{
143 // TODO:
144 /*
145 if ( m_fixedOnly )
146 {
147 // check that it's a fixed pitch font (there is *no* error here, the
148 // flag name is misleading!)
149 if ( tm->tmPitchAndFamily & TMPF_FIXED_PITCH )
150 {
151 // not a fixed pitch font
6670f564 152 return true;
d8cde57b
DW
153 }
154 }
155
156 if ( m_charset != -1 )
157 {
158 // check that we have the right encoding
159 if ( lf->lfCharSet != m_charset )
160 {
6670f564 161 return true;
d8cde57b
DW
162 }
163 }
164
165 return m_fontEnum->OnFacename(lf->lfFaceName);
166 */
6670f564 167 return true;
d8cde57b
DW
168}
169
170// ----------------------------------------------------------------------------
171// wxFontEnumerator
172// ----------------------------------------------------------------------------
173
174bool wxFontEnumerator::EnumerateFacenames(wxFontEncoding encoding,
175 bool fixedWidthOnly)
176{
177 wxFontEnumeratorHelper fe(this);
178 if ( fe.SetEncoding(encoding) )
179 {
180 fe.SetFixedOnly(fixedWidthOnly);
181
182 fe.DoEnumerate();
183 }
184 // else: no such fonts, unknown encoding
185
6670f564 186 return true;
d8cde57b
DW
187}
188
6670f564 189bool wxFontEnumerator::EnumerateEncodings(const wxString& WXUNUSED(family))
d8cde57b
DW
190{
191 wxFAIL_MSG(wxT("TODO"));
192
6670f564 193 return true;
d8cde57b
DW
194}
195
196// ----------------------------------------------------------------------------
197// Windows callbacks
198// ----------------------------------------------------------------------------
199
200// TODO:
201/*
202int CALLBACK wxFontEnumeratorProc(LPLOGFONT lplf, LPTEXTMETRIC lptm,
203 DWORD dwStyle, LONG lParam)
204{
205 // Get rid of any fonts that we don't want...
206 if ( dwStyle != TRUETYPE_FONTTYPE )
207 {
208 // continue enumeration
209 return TRUE;
210 }
211
212 wxFontEnumeratorHelper *fontEnum = (wxFontEnumeratorHelper *)lParam;
213
214 return fontEnum->OnFont(lplf, lptm);
215}
216*/
217
19193a2c 218#endif // wxUSE_FONTMAP