mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-06 17:13:49 +01:00
Make numeric validators work with ComboBoxes too...
... as was the intention in the wxWidgets code from which these files were
adapted
More importantly this removes the mischievous #define (added at 08c94d5) from
valnum.h, which made it impossible to #include that header before
<wx/combobox.h>.
Note that (the real type) wxTextEntry is not a kind of wxWindow, but a class
from which wxTextCtrl and wxComboBox both inherit, while they inherit wxWindow
too along other paths.
So in some places, use the protected variable m_ValidatorWindow instead to
access the validator's window.
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/combobox.h>
|
||||
#endif
|
||||
|
||||
#include <wx/clipbrd.h>
|
||||
@@ -79,6 +80,11 @@ wxTextEntry *NumValidatorBase::GetTextEntry() const
|
||||
return text;
|
||||
#endif // wxUSE_TEXTCTRL
|
||||
|
||||
#if wxUSE_COMBOBOX
|
||||
if ( wxComboBox *combo = wxDynamicCast(m_validatorWindow, wxComboBox) )
|
||||
return combo;
|
||||
#endif // wxUSE_COMBOBOX
|
||||
|
||||
wxFAIL_MSG(wxT("Can only be used with wxTextCtrl or wxComboBox"));
|
||||
|
||||
return NULL;
|
||||
@@ -101,7 +107,7 @@ bool NumValidatorBase::Validate(wxWindow *parent)
|
||||
if ( te )
|
||||
{
|
||||
te->SelectAll();
|
||||
te->SetFocus();
|
||||
m_validatorWindow->SetFocus();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
|
||||
#include <limits>
|
||||
|
||||
#define wxTextEntry wxTextCtrl
|
||||
|
||||
// Bit masks used for numeric validator styles.
|
||||
enum class NumValidatorStyle : int
|
||||
{
|
||||
@@ -213,7 +211,7 @@ public:
|
||||
return false;
|
||||
|
||||
// If window is disabled, simply return
|
||||
if ( !control->IsEnabled() )
|
||||
if ( !this->m_validatorWindow->IsEnabled() )
|
||||
return true;
|
||||
|
||||
const wxString s(control->GetValue());
|
||||
|
||||
Reference in New Issue
Block a user