From 89c684ef8280e2d91096da2d96ba36e24a1fb917 Mon Sep 17 00:00:00 2001
From: Julian Smart <julian@anthemion.co.uk>
Date: Sun, 7 Feb 1999 17:11:44 +0000
Subject: [PATCH] Added wxGenericValidator & doc

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1635 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 docs/latex/wx/category.tex      |   9 +-
 docs/latex/wx/classes.tex       |   1 +
 docs/latex/wx/strmsock.tex      |   4 +-
 docs/latex/wx/valgen.tex        |  81 +++++++
 docs/latex/wx/valtext.tex       |   5 +-
 include/wx/msw/ole/automtn.h    |   4 +
 include/wx/valgen.h             |  58 +++++
 src/common/valgen.cpp           | 386 ++++++++++++++++++++++++++++++++
 src/gtk.inc                     |   1 +
 src/motif.inc                   |   1 +
 src/motif/makefile.unx          |   1 +
 src/msw/makefile.b32            |   3 +
 src/msw/makefile.bcc            |   3 +
 src/msw/makefile.dos            |   6 +
 src/msw/makefile.g95            |   1 +
 src/msw/makefile.sc             |   1 +
 src/msw/makefile.sl             |   4 +
 src/msw/makefile.twn            |   1 +
 src/msw/makefile.vc             |   6 +
 src/msw/makefile.wat            |   4 +
 src/stubs.inc                   |   1 +
 src/stubs/makefile.unx          |   1 +
 src/stubs/makefile.vc           |   6 +
 utils/glcanvas/win/glcanvas.cpp |   2 -
 utils/glcanvas/win/glcanvas.h   |   2 +
 25 files changed, 582 insertions(+), 10 deletions(-)
 create mode 100644 docs/latex/wx/valgen.tex
 create mode 100644 include/wx/valgen.h
 create mode 100644 src/common/valgen.cpp

diff --git a/docs/latex/wx/category.tex b/docs/latex/wx/category.tex
index 6f608b3477..e932b2072e 100644
--- a/docs/latex/wx/category.tex
+++ b/docs/latex/wx/category.tex
@@ -143,7 +143,7 @@ These classes are related to drawing on device contexts and windows.
 \twocolitem{\helpref{wxFont}{wxfont}}{Represents fonts}
 \twocolitem{\helpref{wxFontList}{wxfontlist}}{The list of previously-created fonts}
 \twocolitem{\helpref{wxIcon}{wxicon}}{A small, transparent bitmap for assigning to frames and drawing on device contexts}
-\twocolitem{\helpref{wxImage}{wximage}}{A platform-independent image class.}
+\twocolitem{\helpref{wxImage}{wximage}}{A platform-independent image class}
 \twocolitem{\helpref{wxImageList}{wximagelist}}{A list of images, used with some controls}
 \twocolitem{\helpref{wxMask}{wxmask}}{Represents a mask to be used with a bitmap for transparent drawing}
 \twocolitem{\helpref{wxPen}{wxpen}}{Used for drawing lines on a device context}
@@ -196,8 +196,9 @@ These are the window validators, used for filtering and validating
 user input.
 
 \begin{twocollist}\itemsep=0pt
-\twocolitem{\helpref{wxValidator}{wxvalidator}}{Base validator class.}
-\twocolitem{\helpref{wxTextValidator}{wxtextvalidator}}{Text control validator class.}
+\twocolitem{\helpref{wxValidator}{wxvalidator}}{Base validator class}
+\twocolitem{\helpref{wxTextValidator}{wxtextvalidator}}{Text control validator class}
+\twocolitem{\helpref{wxGenericValidator}{wxgenericvalidator}}{Generic control validator class}
 \end{twocollist}
 
 {\large {\bf Data structures}}
@@ -222,7 +223,7 @@ These are the data structure classes supported by wxWindows.
 \twocolitem{\helpref{wxSize}{wxsize}}{Representation of a size}
 \twocolitem{\helpref{wxTime}{wxtime}}{A class for time manipulation}
 \twocolitem{\helpref{wxVariant}{wxvariant}}{A class for storing arbitrary types
-that may change at run-time.}
+that may change at run-time}
 \end{twocollist}
 
 {\large {\bf Run-time class information system}}
diff --git a/docs/latex/wx/classes.tex b/docs/latex/wx/classes.tex
index 122ab151f6..9a88493103 100644
--- a/docs/latex/wx/classes.tex
+++ b/docs/latex/wx/classes.tex
@@ -100,6 +100,7 @@ $$\image{14cm;0cm}{wxclass.ps}$$
 \input ftp.tex
 \input gauge.tex
 \input gdiobj.tex
+\input valgen.tex
 \input grid.tex
 \input hash.tex
 \input helpinst.tex
diff --git a/docs/latex/wx/strmsock.tex b/docs/latex/wx/strmsock.tex
index 08a6e8157e..e49fd767f9 100644
--- a/docs/latex/wx/strmsock.tex
+++ b/docs/latex/wx/strmsock.tex
@@ -1,7 +1,7 @@
 % -----------------------------------------------------------------------------
 % wxSocketInputStream
 % -----------------------------------------------------------------------------
-\section{\class{wxSocketInputStream}}
+\section{\class{wxSocketInputStream}}\label{wxsocketinputstream}
 
 \wxheading{Derived from}
 
@@ -23,7 +23,7 @@ socket connection.
 % -----------------------------------------------------------------------------
 % wxSocketOutputStream
 % -----------------------------------------------------------------------------
-\section{\class{wxSocketInputStream}}
+\section{\class{wxSocketOutputStream}}\label{wxsocketoutputstream}
 
 \wxheading{Derived from}
 
diff --git a/docs/latex/wx/valgen.tex b/docs/latex/wx/valgen.tex
new file mode 100644
index 0000000000..cabaeff412
--- /dev/null
+++ b/docs/latex/wx/valgen.tex
@@ -0,0 +1,81 @@
+\section{\class{wxGenericValidator}}\label{wxgenericvalidator}
+
+wxGenericValidator performs data transfer (but not validation or filtering) for the following
+basic controls: wxButton, wxCheckBox, wxListBox, wxStaticText, wxRadioButton, wxRadioBox,
+wxChoice, wxComboBox, wxGauge, wxSlider, wxScrollBar, wxSpinButton, wxTextCtrl, wxCheckListBox.
+
+It checks the type of the window and uses an appropriate type for that window. For example,
+wxButton and wxTextCtrl transfer data to and from a wxString variable; wxListBox uses a
+wxArrayInt; wxCheckBox uses a bool.
+
+For more information, please see \helpref{Validator overview}{validatoroverview}.
+
+\wxheading{Derived from}
+
+\helpref{wxValidator}{wxvalidator}\\
+\helpref{wxEvtHandler}{wxevthandler}\\
+\helpref{wxObject}{wxobject}
+
+\wxheading{See also}
+
+\helpref{Validator overview}{validatoroverview}, \helpref{wxValidator}{wxvalidator}, 
+\helpref{wxTextValidator}{wxTextvalidator}
+
+\latexignore{\rtfignore{\wxheading{Members}}}
+
+\membersection{wxGenericValidator::wxGenericValidator}\label{wxgenericvalidatorconstr}
+
+\func{}{wxGenericValidator}{\param{const wxGenericValidator\&}{ validator}}
+
+Copy constructor.
+
+\func{}{wxGenericValidator}{\param{bool*}{ valPtr}}
+
+Constructor taking a bool pointer. This will be used for wxCheckBox and wxRadioButton.
+
+\func{}{wxGenericValidator}{\param{wxString*}{ valPtr}}
+
+Constructor taking a wxString pointer. This will be used for wxButton, wxComboBox, wxStaticText,
+wxTextCtrl.
+
+\func{}{wxGenericValidator}{\param{int*}{ valPtr}}
+
+Constructor taking an integer pointer. This will be used for wxGauge, wxScrollBar, wxRadioBox, wxSpinButton,
+wxChoice.
+
+\func{}{wxGenericValidator}{\param{wxArrayInt*}{ valPtr}}
+
+Constructor taking a wxArrayInt pointer. This will be used for wxListBox, wxCheckListBox.
+
+\wxheading{Parameters}
+
+\docparam{validator}{Validator to copy.}
+
+\docparam{valPtr}{A pointer to a variable that contains the value. This variable
+should have a lifetime equal to or longer than the validator lifetime (which is usually
+determined by the lifetime of the window).}
+
+\membersection{wxGenericValidator::\destruct{wxGenericValidator}}
+
+\func{}{\destruct{wxGenericValidator}}{\void}
+
+Destructor.
+
+\membersection{wxGenericValidator::Clone}\label{wxgenericvalidatorclone}
+
+\constfunc{virtual wxValidator*}{Clone}{\void}
+
+Clones the generic validator using the copy constructor.
+
+\membersection{wxGenericValidator::TransferFromWindow}\label{wxgenericvalidatortransferfromwindow}
+
+\func{virtual bool}{TransferToWindow}{\param{wxWindow*}{ parent}}
+
+Transfers the value to the window.
+
+\membersection{wxGenericValidator::TransferToWindow}\label{wxgenericvalidatortransfertowindow}
+
+\func{virtual bool}{TransferToWindow}{\param{wxWindow*}{ parent}}
+
+Transfers the window value to the appropriate data type.
+
diff --git a/docs/latex/wx/valtext.tex b/docs/latex/wx/valtext.tex
index 9c7941cb2b..f466e3abd6 100644
--- a/docs/latex/wx/valtext.tex
+++ b/docs/latex/wx/valtext.tex
@@ -12,7 +12,8 @@ For more information, please see \helpref{Validator overview}{validatoroverview}
 
 \wxheading{See also}
 
-\helpref{Validator overview}{validatoroverview}, \helpref{wxValidator}{wxvalidator}
+\helpref{Validator overview}{validatoroverview}, \helpref{wxValidator}{wxvalidator}, 
+\helpref{wxGenericValidator}{wxgenericvalidator}
 
 \latexignore{\rtfignore{\wxheading{Members}}}
 
@@ -57,7 +58,7 @@ Destructor.
 
 \membersection{wxTextValidator::Clone}\label{wxtextvalidatorclone}
 
-\constfunc{virtual wxTextValidator*}{Clone}{\void}
+\constfunc{virtual wxValidator*}{Clone}{\void}
 
 Clones the text validator using the copy constructor.
 
diff --git a/include/wx/msw/ole/automtn.h b/include/wx/msw/ole/automtn.h
index b3598a5985..9e35455a54 100644
--- a/include/wx/msw/ole/automtn.h
+++ b/include/wx/msw/ole/automtn.h
@@ -22,6 +22,10 @@
 typedef void            WXIDISPATCH;
 typedef unsigned short* WXBSTR;
 
+#ifdef GetObject
+#undef GetObject
+#endif
+
 /*
  * wxAutomationObject
  * Wraps up an IDispatch pointer and invocation; does variant conversion.
diff --git a/include/wx/valgen.h b/include/wx/valgen.h
new file mode 100644
index 0000000000..88e9b88bb0
--- /dev/null
+++ b/include/wx/valgen.h
@@ -0,0 +1,58 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        valgen.h
+// Purpose:     wxGenericValidator class
+// Author:      Kevin Smith
+// Modified by:
+// Created:     Jan 22 1999
+// RCS-ID:      
+// Copyright:   (c) 1999 Kevin Smith
+// Licence:   	wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_VALGENH__
+#define _WX_VALGENH__
+
+#ifdef __GNUG__
+#pragma interface "valgen.h"
+#endif
+
+#include "wx/validate.h"
+
+class WXDLLEXPORT wxGenericValidator: public wxValidator
+{
+public:
+  wxGenericValidator(bool* val);
+  wxGenericValidator(int* val);
+  wxGenericValidator(wxString* val);
+  wxGenericValidator(wxArrayInt* val);
+  wxGenericValidator(const wxGenericValidator& copyFrom);
+
+  ~wxGenericValidator();
+
+  // Make a clone of this validator (or return NULL) - currently necessary
+  // if you're passing a reference to a validator.
+  // Another possibility is to always pass a pointer to a new validator
+  // (so the calling code can use a copy constructor of the relevant class).
+  virtual wxValidator *Clone(void) const { return new wxGenericValidator(*this); }
+  bool Copy(const wxGenericValidator& val);
+
+  // Called when the value in the window must be validated.
+  // This function can pop up an error message.
+  virtual bool Validate(wxWindow *parent)	{return true;}
+
+  // Called to transfer data to the window
+  virtual bool TransferToWindow(void);
+
+  // Called to transfer data to the window
+  virtual bool TransferFromWindow(void);
+
+protected:
+  void Initialize();
+
+  bool*       m_pBool;
+  int*        m_pInt;
+  wxString*   m_pString;
+  wxArrayInt* m_pArrayInt;
+};
+
+#endif	// _WX_VALGENH__
diff --git a/src/common/valgen.cpp b/src/common/valgen.cpp
new file mode 100644
index 0000000000..d90f90f6f0
--- /dev/null
+++ b/src/common/valgen.cpp
@@ -0,0 +1,386 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        valgen.cpp
+// Purpose:     wxGenericValidator class
+// Author:      Kevin Smith
+// Modified by:
+// Created:     Jan 22 1999
+// RCS-ID:      
+// Copyright:   (c) 1999 Kevin Smith
+// Licence:   	wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "valgen.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/utils.h"
+#include "wx/intl.h"
+#endif
+
+#include "wx/spinbutt.h"
+#include "wx/checklst.h"
+
+#include "wx/valgen.h"
+
+wxGenericValidator::wxGenericValidator(bool *val)
+{
+  Initialize();
+  m_pBool = val;
+}
+
+wxGenericValidator::wxGenericValidator(int *val)
+{
+  Initialize();
+  m_pInt = val;
+}
+
+wxGenericValidator::wxGenericValidator(wxString *val)
+{
+  Initialize();
+  m_pString = val;
+}
+
+wxGenericValidator::wxGenericValidator(wxArrayInt *val)
+{
+  Initialize();
+  m_pArrayInt = val;
+}
+
+wxGenericValidator::wxGenericValidator(const wxGenericValidator& val)
+{
+  Copy(val);
+}
+
+bool wxGenericValidator::Copy(const wxGenericValidator& val)
+{
+  wxValidator::Copy(val);
+
+  m_pBool = val.m_pBool;
+  m_pInt = val.m_pInt;
+  m_pString = val.m_pString;
+  m_pArrayInt = val.m_pArrayInt;
+
+  return TRUE;
+}
+
+wxGenericValidator::~wxGenericValidator()
+{
+}
+
+// Called to transfer data to the window
+bool wxGenericValidator::TransferToWindow(void)
+{
+  if ( !m_validatorWindow )
+    return FALSE;
+
+  // bool controls
+  if (m_validatorWindow->IsKindOf(CLASSINFO(wxCheckBox)) )
+  {
+    wxCheckBox* pControl = (wxCheckBox*) m_validatorWindow;
+	if (m_pBool)
+    {
+      pControl->SetValue(*m_pBool) ;
+      return TRUE;
+    }
+  }
+  else if (m_validatorWindow->IsKindOf(CLASSINFO(wxRadioButton)) )
+  {
+    wxRadioButton* pControl = (wxRadioButton*) m_validatorWindow;
+	if (m_pBool)
+    {
+      pControl->SetValue(*m_pBool) ;
+      return TRUE;
+    }
+  }
+  // int controls
+  else if (m_validatorWindow->IsKindOf(CLASSINFO(wxGauge)) )
+  {
+    wxGauge* pControl = (wxGauge*) m_validatorWindow;
+	if (m_pInt)
+    {
+      pControl->SetValue(*m_pInt) ;
+      return TRUE;
+    }
+  }
+  else if (m_validatorWindow->IsKindOf(CLASSINFO(wxRadioBox)) )
+  {
+    wxRadioBox* pControl = (wxRadioBox*) m_validatorWindow;
+	if (m_pInt)
+    {
+      pControl->SetSelection(*m_pInt) ;
+      return TRUE;
+    }
+  }
+  else if (m_validatorWindow->IsKindOf(CLASSINFO(wxScrollBar)) )
+  {
+    wxScrollBar* pControl = (wxScrollBar*) m_validatorWindow;
+	if (m_pInt)
+    {
+      pControl->SetThumbPosition(*m_pInt) ;
+      return TRUE;
+    }
+  }
+  else if (m_validatorWindow->IsKindOf(CLASSINFO(wxSpinButton)) )
+  {
+    wxSpinButton* pControl = (wxSpinButton*) m_validatorWindow;
+	if (m_pInt)
+    {
+      pControl->SetValue(*m_pInt) ;
+      return TRUE;
+    }
+  }
+  // string controls
+  else if (m_validatorWindow->IsKindOf(CLASSINFO(wxButton)) )
+  {
+    wxButton* pControl = (wxButton*) m_validatorWindow;
+	if (m_pString)
+    {
+      pControl->SetLabel(*m_pString) ;
+      return TRUE;
+    }
+  }
+  else if (m_validatorWindow->IsKindOf(CLASSINFO(wxComboBox)) )
+  {
+    wxComboBox* pControl = (wxComboBox*) m_validatorWindow;
+	if (m_pString)
+    {
+      pControl->SetValue(*m_pString) ;
+      return TRUE;
+    }
+  }
+  else if (m_validatorWindow->IsKindOf(CLASSINFO(wxChoice)) )
+  {
+    wxChoice* pControl = (wxChoice*) m_validatorWindow;
+	if (m_pInt)
+    {
+      pControl->SetSelection(*m_pInt) ;
+      return TRUE;
+    }
+  }
+  else if (m_validatorWindow->IsKindOf(CLASSINFO(wxStaticText)) )
+  {
+    wxStaticText* pControl = (wxStaticText*) m_validatorWindow;
+	if (m_pString)
+    {
+      pControl->SetLabel(*m_pString) ;
+      return TRUE;
+    }
+  }
+  else if (m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)) )
+  {
+    wxTextCtrl* pControl = (wxTextCtrl*) m_validatorWindow;
+	if (m_pString)
+    {
+      pControl->SetValue(*m_pString) ;
+      return TRUE;
+    }
+  }
+  // array controls
+  // NOTE: wxCheckListBox isa wxListBox, so wxCheckListBox
+  // MUST come first:
+  else if (m_validatorWindow->IsKindOf(CLASSINFO(wxCheckListBox)) )
+  {
+    wxCheckListBox* pControl = (wxCheckListBox*) m_validatorWindow;
+	if (m_pArrayInt)
+    {
+      // clear all selections
+      int i;
+      for (i = 0 ; i < pControl->Number(); ++i)
+        pControl->Check(i, FALSE);
+      // select each item in our array
+      unsigned u;
+      for (u = 0; u < m_pArrayInt->Count(); ++u)
+        pControl->Check(m_pArrayInt->Item(u));
+      return TRUE;
+    }
+	else
+		return FALSE;
+  }
+  else if (m_validatorWindow->IsKindOf(CLASSINFO(wxListBox)) )
+  {
+    wxListBox* pControl = (wxListBox*) m_validatorWindow;
+	if (m_pArrayInt)
+    {
+      // clear all selections
+      int i;
+      for (i = 0 ; i < pControl->Number(); ++i)
+        pControl->Deselect(i);
+      // select each item in our array
+      unsigned u;
+      for (u = 0; u < m_pArrayInt->Count(); ++u)
+        pControl->SetSelection(m_pArrayInt->Item(u));
+      return TRUE;
+    }
+  }
+
+  // unrecognized control, or bad pointer
+  return FALSE;
+}
+
+// Called to transfer data to the window
+bool wxGenericValidator::TransferFromWindow(void)
+{
+  if ( !m_validatorWindow )
+    return FALSE;
+
+  // bool controls
+  if (m_validatorWindow->IsKindOf(CLASSINFO(wxCheckBox)) )
+  {
+    wxCheckBox* pControl = (wxCheckBox*) m_validatorWindow;
+	if (m_pBool)
+    {
+      *m_pBool = pControl->GetValue() ;
+      return TRUE;
+    }
+  }
+  else if (m_validatorWindow->IsKindOf(CLASSINFO(wxRadioButton)) )
+  {
+    wxRadioButton* pControl = (wxRadioButton*) m_validatorWindow;
+	if (m_pBool)
+    {
+      *m_pBool = pControl->GetValue() ;
+      return TRUE;
+    }
+  }
+  // int controls
+  else if (m_validatorWindow->IsKindOf(CLASSINFO(wxGauge)) )
+  {
+    wxGauge* pControl = (wxGauge*) m_validatorWindow;
+	if (m_pInt)
+    {
+      *m_pInt = pControl->GetValue() ;
+      return TRUE;
+    }
+  }
+  else if (m_validatorWindow->IsKindOf(CLASSINFO(wxRadioBox)) )
+  {
+    wxRadioBox* pControl = (wxRadioBox*) m_validatorWindow;
+	if (m_pInt)
+    {
+      *m_pInt = pControl->GetSelection() ;
+      return TRUE;
+    }
+  }
+  else if (m_validatorWindow->IsKindOf(CLASSINFO(wxScrollBar)) )
+  {
+    wxScrollBar* pControl = (wxScrollBar*) m_validatorWindow;
+	if (m_pInt)
+    {
+      *m_pInt = pControl->GetThumbPosition() ;
+      return TRUE;
+    }
+  }
+  else if (m_validatorWindow->IsKindOf(CLASSINFO(wxSpinButton)) )
+  {
+    wxSpinButton* pControl = (wxSpinButton*) m_validatorWindow;
+	if (m_pInt)
+    {
+      *m_pInt = pControl->GetValue() ;
+      return TRUE;
+    }
+  }
+  // string controls
+  else if (m_validatorWindow->IsKindOf(CLASSINFO(wxButton)) )
+  {
+    wxButton* pControl = (wxButton*) m_validatorWindow;
+	if (m_pString)
+    {
+      *m_pString = pControl->GetLabel() ;
+      return TRUE;
+    }
+  }
+  else if (m_validatorWindow->IsKindOf(CLASSINFO(wxComboBox)) )
+  {
+    wxComboBox* pControl = (wxComboBox*) m_validatorWindow;
+	if (m_pString)
+    {
+      *m_pString = pControl->GetValue() ;
+      return TRUE;
+    }
+  }
+  else if (m_validatorWindow->IsKindOf(CLASSINFO(wxChoice)) )
+  {
+    wxChoice* pControl = (wxChoice*) m_validatorWindow;
+	if (m_pInt)
+    {
+      *m_pInt = pControl->GetSelection() ;
+      return TRUE;
+    }
+  }
+  else if (m_validatorWindow->IsKindOf(CLASSINFO(wxStaticText)) )
+  {
+    wxStaticText* pControl = (wxStaticText*) m_validatorWindow;
+	if (m_pString)
+    {
+      *m_pString = pControl->GetLabel() ;
+      return TRUE;
+    }
+  }
+  else if (m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)) )
+  {
+    wxTextCtrl* pControl = (wxTextCtrl*) m_validatorWindow;
+	if (m_pString)
+    {
+      *m_pString = pControl->GetValue() ;
+      return TRUE;
+    }
+  }
+  // array controls
+  // NOTE: wxCheckListBox isa wxListBox, so wxCheckListBox
+  // MUST come first:
+  else if (m_validatorWindow->IsKindOf(CLASSINFO(wxCheckListBox)) )
+  {
+    wxCheckListBox* pControl = (wxCheckListBox*) m_validatorWindow;
+	if (m_pArrayInt)
+    {
+      // clear our array
+      m_pArrayInt->Clear();
+      // add each selected item to our array
+      int i;
+      for (i = 0 ; i < pControl->Number(); ++i)
+        if (pControl->IsChecked(i))
+          m_pArrayInt->Add(i);
+      return TRUE;
+    }
+	else
+	  return FALSE;
+  }
+  else if (m_validatorWindow->IsKindOf(CLASSINFO(wxListBox)) )
+  {
+    wxListBox* pControl = (wxListBox*) m_validatorWindow;
+	if (m_pArrayInt)
+    {
+      // clear our array
+      m_pArrayInt->Clear();
+      // add each selected item to our array
+      int i;
+      for (i = 0 ; i < pControl->Number(); ++i)
+        if (pControl->Selected(i))
+          m_pArrayInt->Add(i);
+      return TRUE;
+    }
+  }
+
+  // unrecognized control, or bad pointer
+  return FALSE;
+}
+
+/*
+  Called by constructors to initialize ALL data members
+*/
+void wxGenericValidator::Initialize()
+{
+  m_pBool = 0;
+  m_pInt = 0;
+  m_pString = 0;
+  m_pArrayInt = 0;
+}
+
diff --git a/src/gtk.inc b/src/gtk.inc
index c2fa2e4460..821187bd46 100644
--- a/src/gtk.inc
+++ b/src/gtk.inc
@@ -54,6 +54,7 @@ LIB_CPP_SRC=\
  common/objstrm.cpp \
  common/sckstrm.cpp \
  common/validate.cpp \
+ common/valgen.cpp \
  common/valtext.cpp \
  common/variant.cpp \
  common/socket.cpp \
diff --git a/src/motif.inc b/src/motif.inc
index 3b0679bd8b..4736d0f71f 100644
--- a/src/motif.inc
+++ b/src/motif.inc
@@ -55,6 +55,7 @@ LIB_CPP_SRC=\
  common/objstrm.cpp \
  common/sckstrm.cpp \
  common/validate.cpp \
+ common/valgen.cpp \
  common/valtext.cpp \
  common/variant.cpp \
  common/wxexpr.cpp \
diff --git a/src/motif/makefile.unx b/src/motif/makefile.unx
index eda10a023f..6a0d47c13d 100644
--- a/src/motif/makefile.unx
+++ b/src/motif/makefile.unx
@@ -59,6 +59,7 @@ LIB_CPP_SRC=\
  ../common/objstrm.cpp \
  ../common/sckstrm.cpp \
  ../common/validate.cpp \
+ ../common/valgen.cpp \
  ../common/valtext.cpp \
  ../common/variant.cpp \
  ../common/wxexpr.cpp \
diff --git a/src/msw/makefile.b32 b/src/msw/makefile.b32
index 15d88838ed..0183737a6a 100644
--- a/src/msw/makefile.b32
+++ b/src/msw/makefile.b32
@@ -127,6 +127,7 @@ COMMONOBJS = \
   $(MSWDIR)\timercmn.obj \
   $(MSWDIR)\utilscmn.obj \
   $(MSWDIR)\validate.obj \
+  $(MSWDIR)\valgen.obj \
   $(MSWDIR)\valtext.obj \
   $(MSWDIR)\variant.obj \
   $(MSWDIR)\date.obj \
@@ -539,6 +540,8 @@ $(MSWDIR)\utilscmn.obj:     $(COMMDIR)\utilscmn.$(SRCSUFF)
 
 $(MSWDIR)\validate.obj:     $(COMMDIR)\validate.$(SRCSUFF)
 
+$(MSWDIR)\valgen.obj:     $(COMMDIR)\valtext.$(SRCSUFF)
+
 $(MSWDIR)\valtext.obj:     $(COMMDIR)\valtext.$(SRCSUFF)
 
 $(MSWDIR)\date.obj:     $(COMMDIR)\date.$(SRCSUFF)
diff --git a/src/msw/makefile.bcc b/src/msw/makefile.bcc
index 240d9ac3c1..fdbd53bab7 100644
--- a/src/msw/makefile.bcc
+++ b/src/msw/makefile.bcc
@@ -124,6 +124,7 @@ COMMONOBJS = \
   $(MSWDIR)\timercmn.obj \
   $(MSWDIR)\utilscmn.obj \
   $(MSWDIR)\validate.obj \
+  $(MSWDIR)\valgen.obj \
   $(MSWDIR)\valtext.obj \
   $(MSWDIR)\variant.obj \
   $(MSWDIR)\date.obj \
@@ -526,6 +527,8 @@ $(MSWDIR)\utilscmn.obj:     $(COMMDIR)\utilscmn.$(SRCSUFF)
 
 $(MSWDIR)\validate.obj:     $(COMMDIR)\validate.$(SRCSUFF)
 
+$(MSWDIR)\valgen.obj:     $(COMMDIR)\valgen.$(SRCSUFF)
+
 $(MSWDIR)\valtext.obj:     $(COMMDIR)\valtext.$(SRCSUFF)
 
 $(MSWDIR)\date.obj:     $(COMMDIR)\date.$(SRCSUFF)
diff --git a/src/msw/makefile.dos b/src/msw/makefile.dos
index 1727d1747f..97fec5e99f 100644
--- a/src/msw/makefile.dos
+++ b/src/msw/makefile.dos
@@ -105,6 +105,7 @@ COMMONOBJS = \
   $(COMMDIR)\timercmn.obj \
   $(COMMDIR)\utilscmn.obj \
   $(COMMDIR)\validate.obj \
+  $(COMMDIR)\valgen.obj \
   $(COMMDIR)\valtext.obj \
   $(COMMDIR)\date.obj \
   $(COMMDIR)\wxexpr.obj \
@@ -833,6 +834,11 @@ $(COMMDIR)/validate.obj:     $*.$(SRCSUFF)
 $(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
 <<
 
+$(COMMDIR)/valgen.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
 $(COMMDIR)/valtext.obj:     $*.$(SRCSUFF)
         cl @<<
 $(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
diff --git a/src/msw/makefile.g95 b/src/msw/makefile.g95
index aee32cbfd7..455592f62c 100644
--- a/src/msw/makefile.g95
+++ b/src/msw/makefile.g95
@@ -111,6 +111,7 @@ COMMONOBJS = \
   $(COMMDIR)/timercmn.$(OBJSUFF) \
   $(COMMDIR)/utilscmn.$(OBJSUFF) \
   $(COMMDIR)/validate.$(OBJSUFF) \
+  $(COMMDIR)/valgen.$(OBJSUFF) \
   $(COMMDIR)/valtext.$(OBJSUFF) \
   $(COMMDIR)/date.$(OBJSUFF) \
   $(COMMDIR)/wxexpr.$(OBJSUFF) \
diff --git a/src/msw/makefile.sc b/src/msw/makefile.sc
index 4828b35b59..2bea2b583c 100644
--- a/src/msw/makefile.sc
+++ b/src/msw/makefile.sc
@@ -83,6 +83,7 @@ COMMONOBJS = \
   $(COMMDIR)\timercmn.obj \
   $(COMMDIR)\utilscmn.obj \
   $(COMMDIR)\validate.obj \
+  $(COMMDIR)\valgen.obj \
   $(COMMDIR)\valtext.obj \
   $(COMMDIR)\date.obj \
   $(COMMDIR)\hash.obj \
diff --git a/src/msw/makefile.sl b/src/msw/makefile.sl
index 105badbf23..ffe534970a 100644
--- a/src/msw/makefile.sl
+++ b/src/msw/makefile.sl
@@ -69,6 +69,7 @@ COMMONOBJS = cmndata.obj \
   timercmn.obj \
   utilscmn.obj \
   validate.obj \
+  valgen.obj \
   valtext.obj \
   date.obj \
   hash.obj \
@@ -598,6 +599,9 @@ utilscmn.obj:     $(COMMDIR)\utilscmn.cpp
 validate.obj:     $(COMMDIR)\validate.cpp
   $(CCC) $(CPPFLAGS) $(IFLAGS) $(COMMDIR)\validate.cpp /BINARY validate.obj
 
+valgen.obj:     $(COMMDIR)\valgen.cpp
+  $(CCC) $(CPPFLAGS) $(IFLAGS) $(COMMDIR)\valgen.cpp /BINARY valgen.obj
+
 valtext.obj:     $(COMMDIR)\valtext.cpp
   $(CCC) $(CPPFLAGS) $(IFLAGS) $(COMMDIR)\valtext.cpp /BINARY valtext.obj
 
diff --git a/src/msw/makefile.twn b/src/msw/makefile.twn
index 832d3a8fc8..503c878f4f 100644
--- a/src/msw/makefile.twn
+++ b/src/msw/makefile.twn
@@ -108,6 +108,7 @@ COMMONOBJS = \
   $(COMMDIR)/timercmn.$(OBJSUFF) \
   $(COMMDIR)/utilscmn.$(OBJSUFF) \
   $(COMMDIR)/validate.$(OBJSUFF) \
+  $(COMMDIR)/valgen.$(OBJSUFF) \
   $(COMMDIR)/valtext.$(OBJSUFF) \
   $(COMMDIR)/date.$(OBJSUFF) \
   $(COMMDIR)/wxexpr.$(OBJSUFF) \
diff --git a/src/msw/makefile.vc b/src/msw/makefile.vc
index 8be1b36ec8..73b6293aa8 100644
--- a/src/msw/makefile.vc
+++ b/src/msw/makefile.vc
@@ -112,6 +112,7 @@ COMMONOBJS = \
   $(COMMDIR)\timercmn.obj \
   $(COMMDIR)\utilscmn.obj \
   $(COMMDIR)\validate.obj \
+  $(COMMDIR)\valgen.obj \
   $(COMMDIR)\valtext.obj \
   $(COMMDIR)\date.obj \
   $(COMMDIR)\hash.obj \
@@ -927,6 +928,11 @@ $(COMMDIR)/validate.obj:     $*.$(SRCSUFF)
 $(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
 <<
 
+$(COMMDIR)/valgen.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
 $(COMMDIR)/valtext.obj:     $*.$(SRCSUFF)
         cl @<<
 $(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
diff --git a/src/msw/makefile.wat b/src/msw/makefile.wat
index 37416522c1..4bbe861184 100644
--- a/src/msw/makefile.wat
+++ b/src/msw/makefile.wat
@@ -79,6 +79,7 @@ COMMONOBJS = cmndata.obj &
   timercmn.obj &
   utilscmn.obj &
   validate.obj &
+  valgen.obj &
   valtext.obj &
   date.obj &
   hash.obj &
@@ -610,6 +611,9 @@ utilscmn.obj:     $(COMMDIR)\utilscmn.cpp
 validate.obj:     $(COMMDIR)\validate.cpp
   *$(CCC) $(CPPFLAGS) $(IFLAGS) $<
 
+valgen.obj:     $(COMMDIR)\valgen.cpp
+  *$(CCC) $(CPPFLAGS) $(IFLAGS) $<
+
 valtext.obj:     $(COMMDIR)\valtext.cpp
   *$(CCC) $(CPPFLAGS) $(IFLAGS) $<
 
diff --git a/src/stubs.inc b/src/stubs.inc
index 2f63d56891..20543be921 100644
--- a/src/stubs.inc
+++ b/src/stubs.inc
@@ -52,6 +52,7 @@ LIB_CPP_SRC=\
  common/objstrm.cpp \
  common/sckstrm.cpp \
  common/validate.cpp \
+ common/valgen.cpp \
  common/valtext.cpp \
  common/variant.cpp \
  common/wxexpr.cpp \
diff --git a/src/stubs/makefile.unx b/src/stubs/makefile.unx
index abd4765ea4..365042e45f 100644
--- a/src/stubs/makefile.unx
+++ b/src/stubs/makefile.unx
@@ -57,6 +57,7 @@ LIB_CPP_SRC=\
  ../common/objstrm.cpp \
  ../common/sckstrm.cpp \
  ../common/validate.cpp \
+ ../common/valgen.cpp \
  ../common/valtext.cpp \
  ../common/variant.cpp \
  ../common/wxexpr.cpp \
diff --git a/src/stubs/makefile.vc b/src/stubs/makefile.vc
index 18136ec664..b0a6240fef 100644
--- a/src/stubs/makefile.vc
+++ b/src/stubs/makefile.vc
@@ -145,6 +145,7 @@ COMMONOBJS = \
   $(COMMDIR)\timercmn.obj \
   $(COMMDIR)\utilscmn.obj \
   $(COMMDIR)\validate.obj \
+  $(COMMDIR)\valgen.obj \
   $(COMMDIR)\valtext.obj \
   $(COMMDIR)\date.obj \
   $(COMMDIR)\hash.obj \
@@ -750,6 +751,11 @@ $(COMMDIR)/validate.obj:     $*.$(SRCSUFF)
 $(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
 <<
 
+$(COMMDIR)/valgen.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
 $(COMMDIR)/valtext.obj:     $*.$(SRCSUFF)
         cl @<<
 $(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
diff --git a/utils/glcanvas/win/glcanvas.cpp b/utils/glcanvas/win/glcanvas.cpp
index 252bcb8c0c..44449532ea 100644
--- a/utils/glcanvas/win/glcanvas.cpp
+++ b/utils/glcanvas/win/glcanvas.cpp
@@ -23,8 +23,6 @@
 #include <wx/frame.h>
 #endif
 
-#include "GL/gl.h"
-
 #include "glcanvas.h"
 
 /*
diff --git a/utils/glcanvas/win/glcanvas.h b/utils/glcanvas/win/glcanvas.h
index 5c84eb5db0..a21382a987 100644
--- a/utils/glcanvas/win/glcanvas.h
+++ b/utils/glcanvas/win/glcanvas.h
@@ -18,6 +18,8 @@
 
 #include <wx/scrolwin.h>
 
+#include <windows.h>
+
 #include "gl/gl.h"
 
 class wxGLContext: public wxObject
-- 
2.50.0

