From 543f08a67631f2849872d5d3ee7cb99047718560 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Mon, 6 Sep 1999 09:36:21 +0000 Subject: [PATCH] Added wxFontEnumerator class for wxMSW, and fixed text validator for French decimal point (","). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3571 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/fontenum.h | 45 ++++++++++++++++++++++++++++ src/common/valtext.cpp | 6 ++-- src/msw/fontenum.cpp | 63 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 include/wx/msw/fontenum.h create mode 100644 src/msw/fontenum.cpp diff --git a/include/wx/msw/fontenum.h b/include/wx/msw/fontenum.h new file mode 100644 index 0000000000..c5cc84c9ba --- /dev/null +++ b/include/wx/msw/fontenum.h @@ -0,0 +1,45 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: fontenum.h +// Purpose: wxFontEnumerator class for Windows +// Author: Julian Smart +// Modified by: +// Created: 04/01/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_FONTENUM_H_ +#define _WX_FONTENUM_H_ + +#ifdef __GNUG__ +#pragma interface "fontenum.h" +#endif + +/* + * wxFontEnumerator: for gathering font information + */ + +class wxFontEnumerator: public wxObject +{ +DECLARE_CLASS(wxFontEnumerator) +public: + wxFontEnumerator() {}; + + // Enumerate the fonts. + bool Enumerate(); + + // Stop enumeration if FALSE is returned. + // By default, the enumerator stores the facenames in a list for + // retrieval via GetFacenames(). + virtual bool OnFont(const wxFont& font); + + // Return the list of facenames. + wxStringList& GetFacenames() { return (wxStringList&) m_faceNames; } +protected: + wxStringList m_faceNames; +}; + +#endif + // _WX_FONTENUM_H_ + diff --git a/src/common/valtext.cpp b/src/common/valtext.cpp index f891889826..0bc8568d54 100644 --- a/src/common/valtext.cpp +++ b/src/common/valtext.cpp @@ -281,7 +281,7 @@ void wxTextValidator::OnChar(wxKeyEvent& event) ((m_validatorStyle & wxFILTER_ALPHA) && !isalpha(keyCode)) || ((m_validatorStyle & wxFILTER_ALPHANUMERIC) && !isalnum(keyCode)) || ((m_validatorStyle & wxFILTER_NUMERIC) && !isdigit(keyCode) - && keyCode != '.' && keyCode != '-') + && keyCode != '.' && keyCode != ',' && keyCode != '-') ) ) { @@ -301,7 +301,9 @@ static bool wxIsNumeric(const wxString& val) int i; for ( i = 0; i < (int)val.Length(); i++) { - if ((!isdigit(val[i])) && (val[i] != '.')) + // Allow for "," (French) as well as "." -- in future we should + // use wxSystemSettings or other to do better localisation + if ((!isdigit(val[i])) && (val[i] != '.') && (val[i] != ',')) if(!((i == 0) && (val[i] == '-'))) return FALSE; } diff --git a/src/msw/fontenum.cpp b/src/msw/fontenum.cpp new file mode 100644 index 0000000000..fe6fe19421 --- /dev/null +++ b/src/msw/fontenum.cpp @@ -0,0 +1,63 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: fontenum.cpp +// Purpose: wxFontEnumerator class for Windows +// Author: Julian Smart +// Modified by: +// Created: 04/01/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/font.h" +#endif + +#include + +int CALLBACK wxFontEnumeratorProc(LPLOGFONT lplf, LPTEXTMETRIC lptm, + DWORD dwStyle, LONG lParam) +{ + // Get rid of any fonts that we don't want... + if (dwStyle != TRUETYPE_FONTTYPE) + return 1; + + wxFontEnumerator *fontEnum = (wxFontEnumerator *)lParam; + + wxFont font = wxCreateFontFromLogFont(lplf); + + if (fontEnum->OnFont(font)) + return 1 ; + else + return 0 ; +} + +IMPLEMENT_CLASS(wxFontEnumerator, wxObject) + +bool wxFontEnumerator::Enumerate() +{ + m_faceNames.Clear(); + + HDC hDC = ::GetDC(NULL); +#ifdef __WIN32__ + ::EnumFontFamilies(hDC, (LPTSTR) NULL, (FONTENUMPROC) wxFontEnumeratorProc, (LPARAM) (void*) this) ; +#else + ::EnumFonts(hDC, (LPTSTR) NULL, (FONTENUMPROC) wxFontEnumeratorProc, (LPARAM) (void*) this) ; +#endif + ::ReleaseDC(NULL, hDC); + return TRUE; +} + +bool wxFontEnumerator::OnFont(const wxFont& font) +{ + m_faceNames.Add(font.GetFaceName()); + return TRUE; +} + -- 2.47.2