]> git.saurik.com Git - wxWidgets.git/blob - src/msw/fontenum.cpp
removed some unneeded bit of test code
[wxWidgets.git] / src / msw / fontenum.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: fontenum.cpp
3 // Purpose: wxFontEnumerator class for Windows
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #ifdef __BORLANDC__
16 #pragma hdrstop
17 #endif
18
19 #ifndef WX_PRECOMP
20 #include "wx/font.h"
21 #endif
22
23 #include <wx/msw/private.h>
24
25 int CALLBACK wxFontEnumeratorProc(LPLOGFONT lplf, LPTEXTMETRIC lptm,
26 DWORD dwStyle, LONG lParam)
27 {
28 // Get rid of any fonts that we don't want...
29 if (dwStyle != TRUETYPE_FONTTYPE)
30 return 1;
31
32 wxFontEnumerator *fontEnum = (wxFontEnumerator *)lParam;
33
34 wxFont font = wxCreateFontFromLogFont(lplf);
35
36 if (fontEnum->OnFont(font))
37 return 1 ;
38 else
39 return 0 ;
40 }
41
42 IMPLEMENT_CLASS(wxFontEnumerator, wxObject)
43
44 bool wxFontEnumerator::Enumerate()
45 {
46 m_faceNames.Clear();
47
48 HDC hDC = ::GetDC(NULL);
49 #ifdef __WIN32__
50 ::EnumFontFamilies(hDC, (LPTSTR) NULL, (FONTENUMPROC) wxFontEnumeratorProc, (LPARAM) (void*) this) ;
51 #else
52 ::EnumFonts(hDC, (LPTSTR) NULL, (FONTENUMPROC) wxFontEnumeratorProc, (LPARAM) (void*) this) ;
53 #endif
54 ::ReleaseDC(NULL, hDC);
55 return TRUE;
56 }
57
58 bool wxFontEnumerator::OnFont(const wxFont& font)
59 {
60 m_faceNames.Add(font.GetFaceName());
61 return TRUE;
62 }
63