Allow associating a validator with wxGridCellTextEditor.
Add wxGridCellTextEditor::SetValidator() for finer control over text input in wxGrid. Closes #15176. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74001 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
79be3fb48d
commit
c6dae1699e
@ -655,6 +655,7 @@ All (GUI):
|
||||
- Add chainable wxWizardPageSimple::Chain() overload.
|
||||
- Add wxTextEntryDialog::SetMaxLength() (derEine).
|
||||
- Fix maximum width support in wxGridCellTextEditor (derEine).
|
||||
- Allow associating a validator with wxGridCellTextEditor (derEine).
|
||||
- Add more convenient wxFont(wxFontInfo) ctor.
|
||||
- Pass menu events to the handler in the associated wxMenuBar.
|
||||
|
||||
|
@ -75,9 +75,9 @@ public:
|
||||
|
||||
// parameters string format is "max_width"
|
||||
virtual void SetParameters(const wxString& params);
|
||||
virtual void SetValidator(const wxValidator& validator);
|
||||
|
||||
virtual wxGridCellEditor *Clone() const
|
||||
{ return new wxGridCellTextEditor(m_maxChars); }
|
||||
virtual wxGridCellEditor *Clone() const;
|
||||
|
||||
// added GetValue so we can get the value which is in the control
|
||||
virtual wxString GetValue() const;
|
||||
@ -92,8 +92,9 @@ protected:
|
||||
void DoReset(const wxString& startValue);
|
||||
|
||||
private:
|
||||
size_t m_maxChars; // max number of chars allowed
|
||||
wxString m_value;
|
||||
size_t m_maxChars; // max number of chars allowed
|
||||
wxScopedPtr<wxValidator> m_validator;
|
||||
wxString m_value;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxGridCellTextEditor);
|
||||
};
|
||||
|
@ -638,6 +638,13 @@ public:
|
||||
the maximum width.
|
||||
*/
|
||||
virtual void SetParameters(const wxString& params);
|
||||
|
||||
/**
|
||||
Set validator to validate user input.
|
||||
|
||||
@since 2.9.5
|
||||
*/
|
||||
virtual void SetValidator(const wxValidator& validator);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -416,6 +416,11 @@ void wxGridCellTextEditor::DoCreate(wxWindow* parent,
|
||||
{
|
||||
Text()->SetMaxLength(m_maxChars);
|
||||
}
|
||||
// validate text in textctrl, if validator is set
|
||||
if ( m_validator )
|
||||
{
|
||||
Text()->SetValidator(*m_validator);
|
||||
}
|
||||
|
||||
wxGridCellEditor::Create(parent, id, evtHandler);
|
||||
}
|
||||
@ -634,6 +639,21 @@ void wxGridCellTextEditor::SetParameters(const wxString& params)
|
||||
}
|
||||
}
|
||||
|
||||
void wxGridCellTextEditor::SetValidator(const wxValidator& validator)
|
||||
{
|
||||
m_validator.reset(static_cast<wxValidator*>(validator.Clone()));
|
||||
}
|
||||
|
||||
wxGridCellEditor *wxGridCellTextEditor::Clone() const
|
||||
{
|
||||
wxGridCellTextEditor* editor = new wxGridCellTextEditor(m_maxChars);
|
||||
if ( m_validator )
|
||||
{
|
||||
editor->SetValidator(*m_validator);
|
||||
}
|
||||
return editor;
|
||||
}
|
||||
|
||||
// return the value in the text control
|
||||
wxString wxGridCellTextEditor::GetValue() const
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user