Show the result of closing rich message box in the sample.

Improve showing the button which closed the message box by doing it inside the
dialog used for testing it instead of popping up a separate message box just
for this.

And do the same thing for rich message boxes as for the normal ones.

See #16153.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76256 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2014-04-02 22:39:08 +00:00
parent cb2de3b400
commit 400e16fd89
2 changed files with 23 additions and 5 deletions

View File

@ -3097,6 +3097,13 @@ bool TestMessageBoxDialog::Create()
sizerTop->Add(sizerFlags, wxSizerFlags().Expand().Border());
// add the currently unused zone for displaying the dialog result
m_labelResult = new wxStaticText(this, wxID_ANY, "",
wxDefaultPosition, wxDefaultSize,
wxST_NO_AUTORESIZE | wxALIGN_CENTRE);
m_labelResult->SetForegroundColour(*wxBLUE);
sizerTop->Add(m_labelResult, wxSizerFlags().Expand().DoubleBorder());
// finally buttons to show the resulting message box and close this dialog
sizerTop->Add(CreateStdDialogButtonSizer(wxAPPLY | wxCLOSE),
wxSizerFlags().Right().Border());
@ -3226,16 +3233,21 @@ void TestMessageBoxDialog::OnApply(wxCommandEvent& WXUNUSED(event))
wxMessageDialog dlg(this, GetMessage(), GetBoxTitle(), GetStyle());
PrepareMessageDialog(dlg);
ShowResult(dlg.ShowModal());
}
void TestMessageBoxDialog::ShowResult(int res)
{
wxString btnName;
switch ( dlg.ShowModal() )
switch ( res )
{
case wxID_OK:
btnName = "OK";
break;
case wxID_CANCEL:
// Avoid the extra message box if the dialog was cancelled.
return;
btnName = "Cancel";
break;
case wxID_YES:
btnName = "Yes";
@ -3253,7 +3265,9 @@ void TestMessageBoxDialog::OnApply(wxCommandEvent& WXUNUSED(event))
btnName = "Unknown";
}
wxLogMessage("Dialog was closed with the \"%s\" button.", btnName);
m_labelResult->SetLabel(
wxString::Format("Dialog was closed with the \"%s\" button.", btnName)
);
}
void TestMessageBoxDialog::OnClose(wxCommandEvent& WXUNUSED(event))
@ -3318,7 +3332,7 @@ void TestRichMessageDialog::OnApply(wxCommandEvent& WXUNUSED(event))
m_initialValueCheckBox->GetValue());
dlg.ShowDetailedText(m_textDetailed->GetValue());
dlg.ShowModal();
ShowResult(dlg.ShowModal());
}
#endif // wxUSE_RICHMSGDLG

View File

@ -216,6 +216,8 @@ protected:
virtual void AddAdditionalTextOptions(wxSizer *WXUNUSED(sizer)) { }
virtual void AddAdditionalFlags(wxSizer *WXUNUSED(sizer)) { }
void ShowResult(int res);
void OnApply(wxCommandEvent& event);
void OnClose(wxCommandEvent& event);
void OnUpdateLabelUI(wxUpdateUIEvent& event);
@ -264,6 +266,8 @@ private:
wxCheckBox *m_chkNoDefault,
*m_chkCentre;
wxStaticText *m_labelResult;
wxDECLARE_EVENT_TABLE();
wxDECLARE_NO_COPY_CLASS(TestMessageBoxDialog);
};