X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/44b25eac69611e42595f53584b244497f491da74..36d0c79521fa4a804f0c9f75cd7b1b0cbc5ef51f:/samples/dialogs/dialogs.cpp diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index 8649cd7857..f17685e5b2 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -22,6 +22,7 @@ #include "../sample.xpm" +#include "wx/apptrait.h" #include "wx/datetime.h" #include "wx/image.h" #include "wx/bookctrl.h" @@ -83,10 +84,7 @@ #include "wx/fdrepdlg.h" #endif // wxUSE_FINDREPLDLG -#if wxUSE_SPINCTRL #include "wx/spinctrl.h" -#endif - #include "wx/propdlg.h" #include "dialogs.h" @@ -659,7 +657,7 @@ void MyFrame::MessageBox(wxCommandEvent& WXUNUSED(event)) "A long, long string to test out the message box " "layout properly.", "Message box text", - wxVSCROLL | wxCENTER | + wxCENTER | wxNO_DEFAULT | wxYES_NO | wxCANCEL | wxICON_INFORMATION); @@ -2138,7 +2136,8 @@ wxPanel* SettingsDialog::CreateAestheticSettingsPage(wxWindow* parent) // TestMessageBoxDialog // ---------------------------------------------------------------------------- -TestMessageBoxDialog::BtnInfo TestMessageBoxDialog::ms_btnInfo[] = +/* static */ +const TestMessageBoxDialog::BtnInfo TestMessageBoxDialog::ms_btnInfo[] = { { wxYES, "&Yes" }, { wxNO, "&No" }, @@ -2162,7 +2161,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 +2214,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 +2254,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 +2277,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() ) @@ -2295,3 +2325,31 @@ void TestMessageBoxDialog::OnClose(wxCommandEvent& WXUNUSED(event)) } #endif // USE_SETTINGS_DIALOG + +#if wxUSE_LOG + +// ---------------------------------------------------------------------------- +// custom log target +// ---------------------------------------------------------------------------- + +class MyLogGui : public wxLogGui +{ +private: + virtual void DoShowSingleLogMessage(const wxString& message, + const wxString& title, + int style) + { + wxMessageDialog dlg(NULL, message, title, + wxOK | wxCANCEL | wxCANCEL_DEFAULT | style); + dlg.SetOKCancelLabels(wxID_COPY, wxID_OK); + dlg.SetExtendedMessage("Note that this is a custom log dialog."); + dlg.ShowModal(); + } +}; + +wxLog *MyAppTraits::CreateLogTarget() +{ + return new MyLogGui; +} + +#endif // wxUSE_LOG