]> git.saurik.com Git - wxWidgets.git/commitdiff
Added wxFontEnumerator class for wxMSW, and fixed text validator for French
authorJulian Smart <julian@anthemion.co.uk>
Mon, 6 Sep 1999 09:36:21 +0000 (09:36 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Mon, 6 Sep 1999 09:36:21 +0000 (09:36 +0000)
decimal point (",").

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3571 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/fontenum.h [new file with mode: 0644]
src/common/valtext.cpp
src/msw/fontenum.cpp [new file with mode: 0644]

diff --git a/include/wx/msw/fontenum.h b/include/wx/msw/fontenum.h
new file mode 100644 (file)
index 0000000..c5cc84c
--- /dev/null
@@ -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_
+
index f891889826b97db693fe8897702d9fea694522b2..0bc8568d542e44a5152b50c686470c8e42223aa7 100644 (file)
@@ -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)
               ((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++)
     {
     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;
     }
           if(!((i == 0) && (val[i] == '-')))
             return FALSE;
     }
diff --git a/src/msw/fontenum.cpp b/src/msw/fontenum.cpp
new file mode 100644 (file)
index 0000000..fe6fe19
--- /dev/null
@@ -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;
+}
+