]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/dialogs/dialogs.cpp
fix wrong placement of the @apperance tag previously committed
[wxWidgets.git] / samples / dialogs / dialogs.cpp
index 8649cd78574aa04167592ee629fae04527f34c5c..f17685e5b2bb0a46514b057b75d50192a2bde590 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "../sample.xpm"
 
+#include "wx/apptrait.h"
 #include "wx/datetime.h"
 #include "wx/image.h"
 #include "wx/bookctrl.h"
     #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