// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "valgen.h"
#endif
#include "wx/slider.h"
#endif
-#if wxUSE_SPINCTRL && !defined(__WIN16__)
+
#include "wx/spinctrl.h"
-#endif
-#if wxUSE_SPINBTN && !defined(__WIN16__)
+
+#if wxUSE_SPINBTN
#include "wx/spinbutt.h"
#endif
-#if wxUSE_CHECKLISTBOX && !defined(__WIN16__)
+#if wxUSE_CHECKLISTBOX
#include "wx/checklst.h"
#endif
#include "wx/valgen.h"
+IMPLEMENT_CLASS(wxGenericValidator, wxValidator)
+
wxGenericValidator::wxGenericValidator(bool *val)
{
Initialize();
}
wxGenericValidator::wxGenericValidator(const wxGenericValidator& val)
+ : wxValidator()
{
Copy(val);
}
}
} else
#endif
-#if wxUSE_SPINCTRL && !defined(__WIN16__) && !defined(__WXMOTIF__)
+#if wxUSE_SPINCTRL && !defined(__WXMOTIF__)
if (m_validatorWindow->IsKindOf(CLASSINFO(wxSpinCtrl)) )
{
wxSpinCtrl* pControl = (wxSpinCtrl*) m_validatorWindow;
}
} else
#endif
-#if wxUSE_SPINBTN && !defined(__WIN16__)
+#if wxUSE_SPINBTN
if (m_validatorWindow->IsKindOf(CLASSINFO(wxSpinButton)) )
{
wxSpinButton* pControl = (wxSpinButton*) m_validatorWindow;
#endif
// string controls
+#if wxUSE_BUTTON
if (m_validatorWindow->IsKindOf(CLASSINFO(wxButton)) )
{
wxButton* pControl = (wxButton*) m_validatorWindow;
return TRUE;
}
} else
+#endif
#if wxUSE_COMBOBOX
if (m_validatorWindow->IsKindOf(CLASSINFO(wxComboBox)) )
{
{
pControl->SetStringSelection(* m_pString);
}
+ else
+ {
+ pControl->SetValue(* m_pString);
+ }
return TRUE;
}
} else
return TRUE;
}
} else
+#if wxUSE_TEXTCTRL
if (m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)) )
{
wxTextCtrl* pControl = (wxTextCtrl*) m_validatorWindow;
return TRUE;
}
} else
-#if wxUSE_CHECKLISTBOX && !defined(__WIN16__)
- // array controls
- // NOTE: wxCheckListBox isa wxListBox, so wxCheckListBox
- // MUST come first:
- if (m_validatorWindow->IsKindOf(CLASSINFO(wxCheckListBox)) )
- {
- wxCheckListBox* pControl = (wxCheckListBox*) m_validatorWindow;
- if (m_pArrayInt)
+#endif
+ // array controls
+#if wxUSE_CHECKLISTBOX
+ // NOTE: wxCheckListBox is a wxListBox, so wxCheckListBox MUST come first:
+ if (m_validatorWindow->IsKindOf(CLASSINFO(wxCheckListBox)) )
{
- // 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;
- }
+ wxCheckListBox* pControl = (wxCheckListBox*) m_validatorWindow;
+ if (m_pArrayInt)
+ {
+ // clear all selections
+ size_t i,
+ count = pControl->GetCount();
+ for ( i = 0 ; i < count; i++ )
+ pControl->Check(i, FALSE);
+
+ // select each item in our array
+ count = m_pArrayInt->GetCount();
+ for ( i = 0 ; i < count; i++ )
+ pControl->Check(m_pArrayInt->Item(i));
+
+ return TRUE;
+ }
else
- return FALSE;
- } else
+ return FALSE;
+ } else
#endif
#if wxUSE_LISTBOX
if (m_validatorWindow->IsKindOf(CLASSINFO(wxListBox)) )
if (m_pArrayInt)
{
// clear all selections
- int i;
- for (i = 0 ; i < pControl->Number(); ++i)
+ size_t i,
+ count = pControl->GetCount();
+ for ( i = 0 ; i < count; 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));
+ count = m_pArrayInt->GetCount();
+ for ( i = 0 ; i < count; i++ )
+ pControl->SetSelection(m_pArrayInt->Item(i));
+
return TRUE;
}
} else
}
} else
#endif
-#if wxUSE_SPINCTRL && !defined(__WIN16__) && !defined(__WXMOTIF__)
+#if wxUSE_SPINCTRL && !defined(__WXMOTIF__)
if (m_validatorWindow->IsKindOf(CLASSINFO(wxSpinCtrl)) )
{
wxSpinCtrl* pControl = (wxSpinCtrl*) m_validatorWindow;
}
} else
#endif
-#if wxUSE_SPINBTN && !defined(__WIN16__)
+#if wxUSE_SPINBTN
if (m_validatorWindow->IsKindOf(CLASSINFO(wxSpinButton)) )
{
wxSpinButton* pControl = (wxSpinButton*) m_validatorWindow;
wxSlider* pControl = (wxSlider*) m_validatorWindow;
if (m_pInt)
{
- pControl->SetValue(*m_pInt) ;
+ *m_pInt = pControl->GetValue() ;
return TRUE;
}
} else
#endif
// string controls
+#if wxUSE_BUTTON
if (m_validatorWindow->IsKindOf(CLASSINFO(wxButton)) )
{
wxButton* pControl = (wxButton*) m_validatorWindow;
*m_pString = pControl->GetLabel() ;
return TRUE;
}
- }
- else
+ } else
+#endif
#if wxUSE_COMBOBOX
if (m_validatorWindow->IsKindOf(CLASSINFO(wxComboBox)) )
{
}
else if (m_pString)
{
- *m_pString = pControl->GetStringSelection();
+ *m_pString = pControl->GetValue();
return TRUE;
}
} else
return TRUE;
}
} else
+#if wxUSE_TEXTCTRL
if (m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)) )
{
wxTextCtrl* pControl = (wxTextCtrl*) m_validatorWindow;
return TRUE;
}
} else
-#if wxUSE_CHECKLISTBOX
-#ifndef __WIN16__
+#endif
// array controls
- // NOTE: wxCheckListBox isa wxListBox, so wxCheckListBox
- // MUST come first:
+#if wxUSE_CHECKLISTBOX
+ // NOTE: wxCheckListBox isa wxListBox, so wxCheckListBox MUST come first:
if (m_validatorWindow->IsKindOf(CLASSINFO(wxCheckListBox)) )
{
wxCheckListBox* pControl = (wxCheckListBox*) m_validatorWindow;
- if (m_pArrayInt)
+ 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)
+ size_t i,
+ count = pControl->GetCount();
+ for ( i = 0; i < count; i++ )
+ {
if (pControl->IsChecked(i))
m_pArrayInt->Add(i);
+ }
+
return TRUE;
}
- else
- return FALSE;
+ else
+ return FALSE;
} else
#endif
-#endif
#if wxUSE_LISTBOX
if (m_validatorWindow->IsKindOf(CLASSINFO(wxListBox)) )
{
{
// clear our array
m_pArrayInt->Clear();
+
// add each selected item to our array
- int i;
- for (i = 0 ; i < pControl->Number(); ++i)
+ size_t i,
+ count = pControl->GetCount();
+ for ( i = 0; i < count; i++ )
+ {
if (pControl->Selected(i))
m_pArrayInt->Add(i);
+ }
+
return TRUE;
}
} else