From: Vadim Zeitlin Date: Tue, 9 Sep 2008 17:25:34 +0000 (+0000) Subject: add tests for the remaining message box flags (wxNO_DEFAULT and wxCENTRE) X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/4e2dc7895b298774d54a6f9e73855c116dfd8851 add tests for the remaining message box flags (wxNO_DEFAULT and wxCENTRE) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55528 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index 8649cd7857..25ac914716 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -2162,7 +2162,7 @@ TestMessageBoxDialog::TestMessageBoxDialog(wxWindow *parent) wxSizer * const sizerMsgs = new wxStaticBoxSizer(wxVERTICAL, this, "&Messages"); sizerMsgs->Add(new wxStaticText(this, wxID_ANY, "&Main message:")); - m_textMsg = new wxTextCtrl(this, wxID_ANY, "", + m_textMsg = new wxTextCtrl(this, wxID_ANY, "Hello from a box!", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE); sizerMsgs->Add(m_textMsg, wxSizerFlags(1).Expand().Border(wxBOTTOM)); @@ -2215,11 +2215,30 @@ TestMessageBoxDialog::TestMessageBoxDialog(wxWindow *parent) sizerTop->Add(m_icons, wxSizerFlags().Expand().Border()); + // miscellaneous other stuff + wxSizer * const + sizerFlags = new wxStaticBoxSizer(wxHORIZONTAL, this, "&Other flags"); + + m_chkNoDefault = new wxCheckBox(this, wxID_ANY, "Make \"No\" &default"); + m_chkNoDefault->Connect(wxEVT_UPDATE_UI, + wxUpdateUIEventHandler( + TestMessageBoxDialog::OnUpdateNoDefaultUI), + NULL, + this); + sizerFlags->Add(m_chkNoDefault, wxSizerFlags(1).Border()); + + m_chkCentre = new wxCheckBox(this, wxID_ANY, "Centre on &parent"); + sizerFlags->Add(m_chkCentre, wxSizerFlags(1).Border()); + + sizerTop->Add(sizerFlags, wxSizerFlags().Expand().Border()); + // finally buttons to show the resulting message box and close this dialog sizerTop->Add(CreateStdDialogButtonSizer(wxAPPLY | wxCLOSE), wxSizerFlags().Right().Border()); SetSizerAndFit(sizerTop); + + m_buttons[Btn_Ok]->SetValue(true); } void TestMessageBoxDialog::OnUpdateLabelUI(wxUpdateUIEvent& event) @@ -2236,6 +2255,11 @@ void TestMessageBoxDialog::OnUpdateLabelUI(wxUpdateUIEvent& event) wxFAIL_MSG( "called for unknown label" ); } +void TestMessageBoxDialog::OnUpdateNoDefaultUI(wxUpdateUIEvent& event) +{ + event.Enable( m_buttons[Btn_No]->IsChecked() ); +} + void TestMessageBoxDialog::OnApply(wxCommandEvent& WXUNUSED(event)) { long style = 0; @@ -2254,6 +2278,13 @@ void TestMessageBoxDialog::OnApply(wxCommandEvent& WXUNUSED(event)) case 3: style |= wxICON_ERROR; break; } + if ( m_chkCentre->IsChecked() ) + style |= wxCENTRE; + + if ( m_chkNoDefault->IsEnabled() && m_chkNoDefault->IsChecked() ) + style |= wxNO_DEFAULT; + + wxMessageDialog dlg(this, m_textMsg->GetValue(), "Test Message Box", style); if ( !m_textExtMsg->IsEmpty() ) diff --git a/samples/dialogs/dialogs.h b/samples/dialogs/dialogs.h index 481794688f..0dd71405a5 100644 --- a/samples/dialogs/dialogs.h +++ b/samples/dialogs/dialogs.h @@ -181,6 +181,7 @@ private: void OnApply(wxCommandEvent& event); void OnClose(wxCommandEvent& event); void OnUpdateLabelUI(wxUpdateUIEvent& event); + void OnUpdateNoDefaultUI(wxUpdateUIEvent& event); enum { @@ -207,6 +208,9 @@ private: wxRadioBox *m_icons; + wxCheckBox *m_chkNoDefault, + *m_chkCentre; + DECLARE_EVENT_TABLE() DECLARE_NO_COPY_CLASS(TestMessageBoxDialog) };