mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-28 22:28:44 +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:
parent
8426580f8e
commit
f2e2d35ad7
@ -37,6 +37,7 @@
|
|||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#include <wx/textctrl.h>
|
#include <wx/textctrl.h>
|
||||||
|
#include <wx/combobox.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <wx/clipbrd.h>
|
#include <wx/clipbrd.h>
|
||||||
@ -79,6 +80,11 @@ wxTextEntry *NumValidatorBase::GetTextEntry() const
|
|||||||
return text;
|
return text;
|
||||||
#endif // wxUSE_TEXTCTRL
|
#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"));
|
wxFAIL_MSG(wxT("Can only be used with wxTextCtrl or wxComboBox"));
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -101,7 +107,7 @@ bool NumValidatorBase::Validate(wxWindow *parent)
|
|||||||
if ( te )
|
if ( te )
|
||||||
{
|
{
|
||||||
te->SelectAll();
|
te->SelectAll();
|
||||||
te->SetFocus();
|
m_validatorWindow->SetFocus();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,6 @@
|
|||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
#define wxTextEntry wxTextCtrl
|
|
||||||
|
|
||||||
// Bit masks used for numeric validator styles.
|
// Bit masks used for numeric validator styles.
|
||||||
enum class NumValidatorStyle : int
|
enum class NumValidatorStyle : int
|
||||||
{
|
{
|
||||||
@ -213,7 +211,7 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If window is disabled, simply return
|
// If window is disabled, simply return
|
||||||
if ( !control->IsEnabled() )
|
if ( !this->m_validatorWindow->IsEnabled() )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
const wxString s(control->GetValue());
|
const wxString s(control->GetValue());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user