diff --git a/docs/changes.txt b/docs/changes.txt index fcdf35fab1..0b397b4bed 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -92,6 +92,7 @@ All (GUI): - Add wxAddRemoveCtrl. - Add wxAppProgressIndicator for MSW (Chaobin Zhang) and OS X (Tobias Taschner). - Add wxTextEntry::ForceUpper(). +- Add wxTextEntryDialog::ForceUpper(). - Add wxEVT_MAGNIFY mouse event (Joost Nieuwenhuijse). - Add wxProcess::Activate(). - Fix setting colours of labels in wxSlider. diff --git a/include/wx/generic/textdlgg.h b/include/wx/generic/textdlgg.h index 218f8c6f1c..8743bd7936 100644 --- a/include/wx/generic/textdlgg.h +++ b/include/wx/generic/textdlgg.h @@ -63,6 +63,8 @@ public: void SetMaxLength(unsigned long len); + void ForceUpper(); + #if wxUSE_VALIDATORS void SetTextValidator( const wxTextValidator& validator ); #if WXWIN_COMPATIBILITY_2_8 diff --git a/interface/wx/textdlg.h b/interface/wx/textdlg.h index 04d4d6411b..911ffbf9c3 100644 --- a/interface/wx/textdlg.h +++ b/interface/wx/textdlg.h @@ -173,6 +173,20 @@ public: */ void SetValue(const wxString& value); + /** + Convert all text entered into the text control used by the dialog to upper case. + + Call this method to ensure that all text entered into the text control + used by the dialog is converted on the fly to upper case. If the text + control is not empty, its existing contents is also converted to upper + case. + + @see wxTextEntry::ForceUpper() + + @since 3.1.0 + */ + void ForceUpper(); + /** Shows the dialog, returning wxID_OK if the user pressed OK, and wxID_CANCEL otherwise. diff --git a/src/generic/textdlgg.cpp b/src/generic/textdlgg.cpp index 97c50bad44..dd24269a71 100644 --- a/src/generic/textdlgg.cpp +++ b/src/generic/textdlgg.cpp @@ -130,14 +130,20 @@ bool wxTextEntryDialog::Create(wxWindow *parent, bool wxTextEntryDialog::TransferDataToWindow() { - m_textctrl->SetValue(m_value); + if ( m_textctrl ) + { + m_textctrl->SetValue(m_value); + } return wxDialog::TransferDataToWindow(); } bool wxTextEntryDialog::TransferDataFromWindow() { - m_value = m_textctrl->GetValue(); + if ( m_textctrl ) + { + m_value = m_textctrl->GetValue(); + } return wxDialog::TransferDataFromWindow(); } @@ -152,9 +158,10 @@ void wxTextEntryDialog::OnOK(wxCommandEvent& WXUNUSED(event) ) void wxTextEntryDialog::SetMaxLength(unsigned long len) { - wxCHECK_RET( m_textctrl, wxS("Must be created first") ); - - m_textctrl->SetMaxLength(len); + if ( m_textctrl ) + { + m_textctrl->SetMaxLength(len); + } } void wxTextEntryDialog::SetValue(const wxString& val) @@ -167,6 +174,14 @@ void wxTextEntryDialog::SetValue(const wxString& val) } } +void wxTextEntryDialog::ForceUpper() +{ + if ( m_textctrl ) + { + m_textctrl->ForceUpper(); + } +} + #if wxUSE_VALIDATORS #if WXWIN_COMPATIBILITY_2_8 @@ -183,9 +198,10 @@ void wxTextEntryDialog::SetTextValidator( wxTextValidatorStyle style ) void wxTextEntryDialog::SetTextValidator( const wxTextValidator& validator ) { - wxCHECK_RET( m_textctrl, wxS("Must be created first") ); - - m_textctrl->SetValidator( validator ); + if ( m_textctrl ) + { + m_textctrl->SetValidator( validator ); + } } #endif // wxUSE_VALIDATORS