X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a294c6d53ed8be5b92c31e1eb7e3366ba1642fa7..18128cbb47b5775f20fb449dd34f36fa31776d51:/src/generic/textdlgg.cpp diff --git a/src/generic/textdlgg.cpp b/src/generic/textdlgg.cpp index d34210a7c9..4397306f2e 100644 --- a/src/generic/textdlgg.cpp +++ b/src/generic/textdlgg.cpp @@ -28,9 +28,9 @@ #pragma hdrstop #endif -#ifndef WX_PRECOMP - #include +#if wxUSE_TEXTDLG +#ifndef WX_PRECOMP #include "wx/utils.h" #include "wx/dialog.h" #include "wx/button.h" @@ -92,6 +92,12 @@ wxTextEntryDialog::wxTextEntryDialog(wxWindow *parent, style & ~wxTextEntryDialogStyle); topsizer->Add( m_textctrl, 1, wxEXPAND | wxLEFT|wxRIGHT, 15 ); +#if wxUSE_VALIDATORS + wxTextValidator validator( wxFILTER_NONE, &m_value ); + m_textctrl->SetValidator( validator ); +#endif + // wxUSE_VALIDATORS + #if wxUSE_STATLINE // 3) static line topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 ); @@ -115,7 +121,39 @@ wxTextEntryDialog::wxTextEntryDialog(wxWindow *parent, void wxTextEntryDialog::OnOK(wxCommandEvent& WXUNUSED(event) ) { +#if wxUSE_VALIDATORS + if( Validate() && TransferDataFromWindow() ) + { + EndModal( wxID_OK ); + } +#else m_value = m_textctrl->GetValue(); EndModal(wxID_OK); +#endif + // wxUSE_VALIDATORS +} + +void wxTextEntryDialog::SetValue(const wxString& val) +{ + m_value = val; + + m_textctrl->SetValue(val); } + +#if wxUSE_VALIDATORS +void wxTextEntryDialog::SetTextValidator( long style ) +{ + wxTextValidator validator( style, &m_value ); + m_textctrl->SetValidator( validator ); +} + +void wxTextEntryDialog::SetTextValidator( wxTextValidator& validator ) +{ + m_textctrl->SetValidator( validator ); +} + +#endif + // wxUSE_VALIDATORS + +#endif // wxUSE_TEXTDLG