]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/grideditors.cpp
Disable wxUSE_ENH_METAFILE for wxGTK builds.
[wxWidgets.git] / src / generic / grideditors.cpp
index 93095852e8052cb30e32e3cbdffbaa744034912f..2963e77821dbd270d13eadcb062a15c687da72f4 100644 (file)
@@ -382,9 +382,9 @@ void wxGridCellEditor::StartingClick()
 // wxGridCellTextEditor
 // ----------------------------------------------------------------------------
 
-wxGridCellTextEditor::wxGridCellTextEditor()
+wxGridCellTextEditor::wxGridCellTextEditor(size_t maxChars)
 {
-    m_maxChars = 0;
+    m_maxChars = maxChars;
 }
 
 void wxGridCellTextEditor::Create(wxWindow* parent,
@@ -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
 {