1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-04-30 23:59:41 +02: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:
Paul Licameli 2019-02-03 17:34:47 -05:00
parent 8426580f8e
commit f2e2d35ad7
2 changed files with 8 additions and 4 deletions

View File

@ -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;
}

View File

@ -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());