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
This commit is contained in:
45
include/wx/msw/fontenum.h
Normal file
45
include/wx/msw/fontenum.h
Normal file
@@ -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_
|
||||
|
@@ -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;
|
||||
}
|
||||
|
63
src/msw/fontenum.cpp
Normal file
63
src/msw/fontenum.cpp
Normal file
@@ -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 <wx/msw/private.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user