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 chainable wxWizardPageSimple::Chain() overload.
|
||||||
- Add wxTextEntryDialog::SetMaxLength() (derEine).
|
- Add wxTextEntryDialog::SetMaxLength() (derEine).
|
||||||
- Fix maximum width support in wxGridCellTextEditor (derEine).
|
- Fix maximum width support in wxGridCellTextEditor (derEine).
|
||||||
|
- Allow associating a validator with wxGridCellTextEditor (derEine).
|
||||||
- Add more convenient wxFont(wxFontInfo) ctor.
|
- Add more convenient wxFont(wxFontInfo) ctor.
|
||||||
- Pass menu events to the handler in the associated wxMenuBar.
|
- Pass menu events to the handler in the associated wxMenuBar.
|
||||||
|
|
||||||
|
@ -75,9 +75,9 @@ public:
|
|||||||
|
|
||||||
// parameters string format is "max_width"
|
// parameters string format is "max_width"
|
||||||
virtual void SetParameters(const wxString& params);
|
virtual void SetParameters(const wxString& params);
|
||||||
|
virtual void SetValidator(const wxValidator& validator);
|
||||||
|
|
||||||
virtual wxGridCellEditor *Clone() const
|
virtual wxGridCellEditor *Clone() const;
|
||||||
{ return new wxGridCellTextEditor(m_maxChars); }
|
|
||||||
|
|
||||||
// added GetValue so we can get the value which is in the control
|
// added GetValue so we can get the value which is in the control
|
||||||
virtual wxString GetValue() const;
|
virtual wxString GetValue() const;
|
||||||
@ -93,6 +93,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
size_t m_maxChars; // max number of chars allowed
|
size_t m_maxChars; // max number of chars allowed
|
||||||
|
wxScopedPtr<wxValidator> m_validator;
|
||||||
wxString m_value;
|
wxString m_value;
|
||||||
|
|
||||||
wxDECLARE_NO_COPY_CLASS(wxGridCellTextEditor);
|
wxDECLARE_NO_COPY_CLASS(wxGridCellTextEditor);
|
||||||
|
@ -638,6 +638,13 @@ public:
|
|||||||
the maximum width.
|
the maximum width.
|
||||||
*/
|
*/
|
||||||
virtual void SetParameters(const wxString& params);
|
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);
|
Text()->SetMaxLength(m_maxChars);
|
||||||
}
|
}
|
||||||
|
// validate text in textctrl, if validator is set
|
||||||
|
if ( m_validator )
|
||||||
|
{
|
||||||
|
Text()->SetValidator(*m_validator);
|
||||||
|
}
|
||||||
|
|
||||||
wxGridCellEditor::Create(parent, id, evtHandler);
|
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
|
// return the value in the text control
|
||||||
wxString wxGridCellTextEditor::GetValue() const
|
wxString wxGridCellTextEditor::GetValue() const
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user