corrected wxComboBox validator behaviour

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7763 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-07-19 07:20:03 +00:00
parent 3d68c787aa
commit 54355138d0

View File

@@ -6,7 +6,7 @@
// Created: Jan 22 1999 // Created: Jan 22 1999
// RCS-ID: // RCS-ID:
// Copyright: (c) 1999 Kevin Smith // Copyright: (c) 1999 Kevin Smith
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
@@ -110,21 +110,21 @@ bool wxGenericValidator::TransferToWindow(void)
{ {
wxCheckBox* pControl = (wxCheckBox*) m_validatorWindow; wxCheckBox* pControl = (wxCheckBox*) m_validatorWindow;
if (m_pBool) if (m_pBool)
{ {
pControl->SetValue(*m_pBool); pControl->SetValue(*m_pBool);
return TRUE; return TRUE;
} }
} else } else
#endif #endif
#if wxUSE_RADIOBTN #if wxUSE_RADIOBTN
if (m_validatorWindow->IsKindOf(CLASSINFO(wxRadioButton)) ) if (m_validatorWindow->IsKindOf(CLASSINFO(wxRadioButton)) )
{ {
wxRadioButton* pControl = (wxRadioButton*) m_validatorWindow; wxRadioButton* pControl = (wxRadioButton*) m_validatorWindow;
if (m_pBool) if (m_pBool)
{ {
pControl->SetValue(*m_pBool) ; pControl->SetValue(*m_pBool) ;
return TRUE; return TRUE;
} }
} else } else
#endif #endif
@@ -133,83 +133,68 @@ bool wxGenericValidator::TransferToWindow(void)
if (m_validatorWindow->IsKindOf(CLASSINFO(wxGauge)) ) if (m_validatorWindow->IsKindOf(CLASSINFO(wxGauge)) )
{ {
wxGauge* pControl = (wxGauge*) m_validatorWindow; wxGauge* pControl = (wxGauge*) m_validatorWindow;
if (m_pInt) if (m_pInt)
{ {
pControl->SetValue(*m_pInt); pControl->SetValue(*m_pInt);
return TRUE; return TRUE;
} }
} else } else
#endif #endif
#if wxUSE_RADIOBOX #if wxUSE_RADIOBOX
if (m_validatorWindow->IsKindOf(CLASSINFO(wxRadioBox)) ) if (m_validatorWindow->IsKindOf(CLASSINFO(wxRadioBox)) )
{ {
wxRadioBox* pControl = (wxRadioBox*) m_validatorWindow; wxRadioBox* pControl = (wxRadioBox*) m_validatorWindow;
if (m_pInt) if (m_pInt)
{ {
pControl->SetSelection(*m_pInt) ; pControl->SetSelection(*m_pInt) ;
return TRUE; return TRUE;
} }
} else } else
#endif #endif
#if wxUSE_SCROLLBAR #if wxUSE_SCROLLBAR
if (m_validatorWindow->IsKindOf(CLASSINFO(wxScrollBar)) ) if (m_validatorWindow->IsKindOf(CLASSINFO(wxScrollBar)) )
{ {
wxScrollBar* pControl = (wxScrollBar*) m_validatorWindow; wxScrollBar* pControl = (wxScrollBar*) m_validatorWindow;
if (m_pInt) if (m_pInt)
{ {
pControl->SetThumbPosition(*m_pInt) ; pControl->SetThumbPosition(*m_pInt) ;
return TRUE; return TRUE;
} }
} else } else
#endif #endif
#if wxUSE_SPINBTN #if wxUSE_SPINBTN && !defined(__WIN16__)
#ifndef __WIN16__
if (m_validatorWindow->IsKindOf(CLASSINFO(wxSpinButton)) ) if (m_validatorWindow->IsKindOf(CLASSINFO(wxSpinButton)) )
{ {
wxSpinButton* pControl = (wxSpinButton*) m_validatorWindow; wxSpinButton* pControl = (wxSpinButton*) m_validatorWindow;
if (m_pInt) if (m_pInt)
{ {
pControl->SetValue(*m_pInt) ; pControl->SetValue(*m_pInt) ;
return TRUE; return TRUE;
} }
} else } else
#endif #endif
#endif
#if wxUSE_SLIDER #if wxUSE_SLIDER
if (m_validatorWindow->IsKindOf(CLASSINFO(wxSlider)) ) if (m_validatorWindow->IsKindOf(CLASSINFO(wxSlider)) )
{ {
wxSlider* pControl = (wxSlider*) m_validatorWindow; wxSlider* pControl = (wxSlider*) m_validatorWindow;
if (m_pInt) if (m_pInt)
{ {
pControl->SetValue(*m_pInt) ; pControl->SetValue(*m_pInt) ;
return TRUE; return TRUE;
} }
} else } else
#endif #endif
// string controls // string controls
#if 1
if (m_validatorWindow->IsKindOf(CLASSINFO(wxButton)) ) if (m_validatorWindow->IsKindOf(CLASSINFO(wxButton)) )
{ {
wxButton* pControl = (wxButton*) m_validatorWindow; wxButton* pControl = (wxButton*) m_validatorWindow;
if (m_pString) if (m_pString)
{ {
pControl->SetLabel(*m_pString) ; pControl->SetLabel(*m_pString) ;
return TRUE; return TRUE;
} }
} else } else
#endif
#if wxUSE_COMBOBOX
if (m_validatorWindow->IsKindOf(CLASSINFO(wxComboBox)) )
{
wxComboBox* pControl = (wxComboBox*) m_validatorWindow;
if (m_pString)
{
pControl->SetValue(*m_pString) ;
return TRUE;
}
} else
#endif
#if wxUSE_CHOICE #if wxUSE_CHOICE
if (m_validatorWindow->IsKindOf(CLASSINFO(wxChoice)) ) if (m_validatorWindow->IsKindOf(CLASSINFO(wxChoice)) )
{ {
@@ -229,6 +214,7 @@ bool wxGenericValidator::TransferToWindow(void)
} }
} else } else
#endif #endif
#if wxUSE_COMBOBOX
if (m_validatorWindow->IsKindOf(CLASSINFO(wxComboBox)) ) if (m_validatorWindow->IsKindOf(CLASSINFO(wxComboBox)) )
{ {
wxComboBox* pControl = (wxComboBox*) m_validatorWindow; wxComboBox* pControl = (wxComboBox*) m_validatorWindow;
@@ -246,6 +232,7 @@ bool wxGenericValidator::TransferToWindow(void)
return TRUE; return TRUE;
} }
} else } else
#endif
if (m_validatorWindow->IsKindOf(CLASSINFO(wxStaticText)) ) if (m_validatorWindow->IsKindOf(CLASSINFO(wxStaticText)) )
{ {
wxStaticText* pControl = (wxStaticText*) m_validatorWindow; wxStaticText* pControl = (wxStaticText*) m_validatorWindow;
@@ -271,15 +258,14 @@ bool wxGenericValidator::TransferToWindow(void)
return TRUE; return TRUE;
} }
} else } else
#if wxUSE_CHECKLISTBOX #if wxUSE_CHECKLISTBOX && !defined(__WIN16__)
#ifndef __WIN16__
// array controls // array controls
// NOTE: wxCheckListBox isa wxListBox, so wxCheckListBox // NOTE: wxCheckListBox isa wxListBox, so wxCheckListBox
// MUST come first: // MUST come first:
if (m_validatorWindow->IsKindOf(CLASSINFO(wxCheckListBox)) ) if (m_validatorWindow->IsKindOf(CLASSINFO(wxCheckListBox)) )
{ {
wxCheckListBox* pControl = (wxCheckListBox*) m_validatorWindow; wxCheckListBox* pControl = (wxCheckListBox*) m_validatorWindow;
if (m_pArrayInt) if (m_pArrayInt)
{ {
// clear all selections // clear all selections
int i; int i;
@@ -291,32 +277,31 @@ bool wxGenericValidator::TransferToWindow(void)
pControl->Check(m_pArrayInt->Item(u)); pControl->Check(m_pArrayInt->Item(u));
return TRUE; return TRUE;
} }
else else
return FALSE; return FALSE;
} else } else
#endif #endif
#endif
#if wxUSE_LISTBOX #if wxUSE_LISTBOX
if (m_validatorWindow->IsKindOf(CLASSINFO(wxListBox)) ) if (m_validatorWindow->IsKindOf(CLASSINFO(wxListBox)) )
{ {
wxListBox* pControl = (wxListBox*) m_validatorWindow; wxListBox* pControl = (wxListBox*) m_validatorWindow;
if (m_pArrayInt) if (m_pArrayInt)
{ {
// clear all selections // clear all selections
int i; int i;
for (i = 0 ; i < pControl->Number(); ++i) for (i = 0 ; i < pControl->Number(); ++i)
pControl->Deselect(i); pControl->Deselect(i);
// select each item in our array // select each item in our array
unsigned u; unsigned u;
for (u = 0; u < m_pArrayInt->Count(); ++u) for (u = 0; u < m_pArrayInt->Count(); ++u)
pControl->SetSelection(m_pArrayInt->Item(u)); pControl->SetSelection(m_pArrayInt->Item(u));
return TRUE; return TRUE;
} }
} else } else
#endif #endif
; // to match the last 'else' above
// unrecognized control, or bad pointer // unrecognized control, or bad pointer
return FALSE;
return FALSE; return FALSE;
} }
@@ -331,7 +316,7 @@ bool wxGenericValidator::TransferFromWindow(void)
if (m_validatorWindow->IsKindOf(CLASSINFO(wxCheckBox)) ) if (m_validatorWindow->IsKindOf(CLASSINFO(wxCheckBox)) )
{ {
wxCheckBox* pControl = (wxCheckBox*) m_validatorWindow; wxCheckBox* pControl = (wxCheckBox*) m_validatorWindow;
if (m_pBool) if (m_pBool)
{ {
*m_pBool = pControl->GetValue() ; *m_pBool = pControl->GetValue() ;
return TRUE; return TRUE;
@@ -342,7 +327,7 @@ bool wxGenericValidator::TransferFromWindow(void)
if (m_validatorWindow->IsKindOf(CLASSINFO(wxRadioButton)) ) if (m_validatorWindow->IsKindOf(CLASSINFO(wxRadioButton)) )
{ {
wxRadioButton* pControl = (wxRadioButton*) m_validatorWindow; wxRadioButton* pControl = (wxRadioButton*) m_validatorWindow;
if (m_pBool) if (m_pBool)
{ {
*m_pBool = pControl->GetValue() ; *m_pBool = pControl->GetValue() ;
return TRUE; return TRUE;
@@ -354,7 +339,7 @@ bool wxGenericValidator::TransferFromWindow(void)
if (m_validatorWindow->IsKindOf(CLASSINFO(wxGauge)) ) if (m_validatorWindow->IsKindOf(CLASSINFO(wxGauge)) )
{ {
wxGauge* pControl = (wxGauge*) m_validatorWindow; wxGauge* pControl = (wxGauge*) m_validatorWindow;
if (m_pInt) if (m_pInt)
{ {
*m_pInt = pControl->GetValue() ; *m_pInt = pControl->GetValue() ;
return TRUE; return TRUE;
@@ -365,7 +350,7 @@ bool wxGenericValidator::TransferFromWindow(void)
if (m_validatorWindow->IsKindOf(CLASSINFO(wxRadioBox)) ) if (m_validatorWindow->IsKindOf(CLASSINFO(wxRadioBox)) )
{ {
wxRadioBox* pControl = (wxRadioBox*) m_validatorWindow; wxRadioBox* pControl = (wxRadioBox*) m_validatorWindow;
if (m_pInt) if (m_pInt)
{ {
*m_pInt = pControl->GetSelection() ; *m_pInt = pControl->GetSelection() ;
return TRUE; return TRUE;
@@ -376,7 +361,7 @@ bool wxGenericValidator::TransferFromWindow(void)
if (m_validatorWindow->IsKindOf(CLASSINFO(wxScrollBar)) ) if (m_validatorWindow->IsKindOf(CLASSINFO(wxScrollBar)) )
{ {
wxScrollBar* pControl = (wxScrollBar*) m_validatorWindow; wxScrollBar* pControl = (wxScrollBar*) m_validatorWindow;
if (m_pInt) if (m_pInt)
{ {
*m_pInt = pControl->GetThumbPosition() ; *m_pInt = pControl->GetThumbPosition() ;
return TRUE; return TRUE;
@@ -388,7 +373,7 @@ bool wxGenericValidator::TransferFromWindow(void)
if (m_validatorWindow->IsKindOf(CLASSINFO(wxSpinButton)) ) if (m_validatorWindow->IsKindOf(CLASSINFO(wxSpinButton)) )
{ {
wxSpinButton* pControl = (wxSpinButton*) m_validatorWindow; wxSpinButton* pControl = (wxSpinButton*) m_validatorWindow;
if (m_pInt) if (m_pInt)
{ {
*m_pInt = pControl->GetValue() ; *m_pInt = pControl->GetValue() ;
return TRUE; return TRUE;
@@ -411,7 +396,7 @@ bool wxGenericValidator::TransferFromWindow(void)
if (m_validatorWindow->IsKindOf(CLASSINFO(wxButton)) ) if (m_validatorWindow->IsKindOf(CLASSINFO(wxButton)) )
{ {
wxButton* pControl = (wxButton*) m_validatorWindow; wxButton* pControl = (wxButton*) m_validatorWindow;
if (m_pString) if (m_pString)
{ {
*m_pString = pControl->GetLabel() ; *m_pString = pControl->GetLabel() ;
return TRUE; return TRUE;
@@ -422,7 +407,7 @@ bool wxGenericValidator::TransferFromWindow(void)
if (m_validatorWindow->IsKindOf(CLASSINFO(wxComboBox)) ) if (m_validatorWindow->IsKindOf(CLASSINFO(wxComboBox)) )
{ {
wxComboBox* pControl = (wxComboBox*) m_validatorWindow; wxComboBox* pControl = (wxComboBox*) m_validatorWindow;
if (m_pString) if (m_pString)
{ {
*m_pString = pControl->GetValue() ; *m_pString = pControl->GetValue() ;
return TRUE; return TRUE;
@@ -438,7 +423,7 @@ bool wxGenericValidator::TransferFromWindow(void)
if (m_validatorWindow->IsKindOf(CLASSINFO(wxChoice)) ) if (m_validatorWindow->IsKindOf(CLASSINFO(wxChoice)) )
{ {
wxChoice* pControl = (wxChoice*) m_validatorWindow; wxChoice* pControl = (wxChoice*) m_validatorWindow;
if (m_pInt) if (m_pInt)
{ {
*m_pInt = pControl->GetSelection() ; *m_pInt = pControl->GetSelection() ;
return TRUE; return TRUE;
@@ -453,7 +438,7 @@ bool wxGenericValidator::TransferFromWindow(void)
if (m_validatorWindow->IsKindOf(CLASSINFO(wxComboBox)) ) if (m_validatorWindow->IsKindOf(CLASSINFO(wxComboBox)) )
{ {
wxComboBox* pControl = (wxComboBox*) m_validatorWindow; wxComboBox* pControl = (wxComboBox*) m_validatorWindow;
if (m_pInt) if (m_pInt)
{ {
*m_pInt = pControl->GetSelection() ; *m_pInt = pControl->GetSelection() ;
return TRUE; return TRUE;
@@ -467,7 +452,7 @@ bool wxGenericValidator::TransferFromWindow(void)
if (m_validatorWindow->IsKindOf(CLASSINFO(wxStaticText)) ) if (m_validatorWindow->IsKindOf(CLASSINFO(wxStaticText)) )
{ {
wxStaticText* pControl = (wxStaticText*) m_validatorWindow; wxStaticText* pControl = (wxStaticText*) m_validatorWindow;
if (m_pString) if (m_pString)
{ {
*m_pString = pControl->GetLabel() ; *m_pString = pControl->GetLabel() ;
return TRUE; return TRUE;
@@ -476,7 +461,7 @@ bool wxGenericValidator::TransferFromWindow(void)
if (m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)) ) if (m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)) )
{ {
wxTextCtrl* pControl = (wxTextCtrl*) m_validatorWindow; wxTextCtrl* pControl = (wxTextCtrl*) m_validatorWindow;
if (m_pString) if (m_pString)
{ {
*m_pString = pControl->GetValue() ; *m_pString = pControl->GetValue() ;
return TRUE; return TRUE;
@@ -495,7 +480,7 @@ bool wxGenericValidator::TransferFromWindow(void)
if (m_validatorWindow->IsKindOf(CLASSINFO(wxCheckListBox)) ) if (m_validatorWindow->IsKindOf(CLASSINFO(wxCheckListBox)) )
{ {
wxCheckListBox* pControl = (wxCheckListBox*) m_validatorWindow; wxCheckListBox* pControl = (wxCheckListBox*) m_validatorWindow;
if (m_pArrayInt) if (m_pArrayInt)
{ {
// clear our array // clear our array
m_pArrayInt->Clear(); m_pArrayInt->Clear();
@@ -506,8 +491,8 @@ bool wxGenericValidator::TransferFromWindow(void)
m_pArrayInt->Add(i); m_pArrayInt->Add(i);
return TRUE; return TRUE;
} }
else else
return FALSE; return FALSE;
} else } else
#endif #endif
#endif #endif
@@ -515,7 +500,7 @@ bool wxGenericValidator::TransferFromWindow(void)
if (m_validatorWindow->IsKindOf(CLASSINFO(wxListBox)) ) if (m_validatorWindow->IsKindOf(CLASSINFO(wxListBox)) )
{ {
wxListBox* pControl = (wxListBox*) m_validatorWindow; wxListBox* pControl = (wxListBox*) m_validatorWindow;
if (m_pArrayInt) if (m_pArrayInt)
{ {
// clear our array // clear our array
m_pArrayInt->Clear(); m_pArrayInt->Clear();