]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/dialogs/dialogs.cpp
Fix crash in wxExecute() introduced by r73406.
[wxWidgets.git] / samples / dialogs / dialogs.cpp
index ce73b79e392b9656039aa0696d4187745719b6e3..0adb60f99f7cf435b2dccc0b5aed6e303cf34ca4 100644 (file)
@@ -670,7 +670,7 @@ MyFrame::MyFrame(const wxString& title)
         // satisfy this condition and need to define and connect a separate id.
         static const int DIALOGS_SYSTEM_ABOUT = 0x4010;
 
-        menu->Append(DIALOGS_SYSTEM_ABOUT, "&About...");
+        menu->Append(DIALOGS_SYSTEM_ABOUT, "&About");
         Connect(DIALOGS_SYSTEM_ABOUT, wxEVT_COMMAND_MENU_SELECTED,
                 wxCommandEventHandler(MyFrame::ShowSimpleAboutDialog));
     }
@@ -1747,6 +1747,9 @@ void MyFrame::OnRequestUserAttention(wxCommandEvent& WXUNUSED(event))
 
 void MyFrame::OnNotifMsgAuto(wxCommandEvent& WXUNUSED(event))
 {
+    // Notice that the notification remains shown even after the
+    // wxNotificationMessage object itself is destroyed so we can show simple
+    // notifications using temporary objects.
     if ( !wxNotificationMessage
           (
             "Automatic Notification",
@@ -1756,6 +1759,11 @@ void MyFrame::OnNotifMsgAuto(wxCommandEvent& WXUNUSED(event))
     {
         wxLogStatus("Failed to show notification message");
     }
+
+    // But it doesn't have to be a temporary, of course.
+    wxNotificationMessage n("Dummy Warning", "Example of a warning notification.");
+    n.SetFlags(wxICON_ERROR);
+    n.Show(5); // Just for testing, use 5 second delay.
 }
 
 void MyFrame::OnNotifMsgShow(wxCommandEvent& WXUNUSED(event))
@@ -1846,13 +1854,14 @@ public:
                                     WXSIZEOF(bgStyles), bgStyles,
                                     1, wxRA_SPECIFY_ROWS);
 
-        const wxString timeouts[] = { "&None", "&Default", "&3 seconds" };
+        const wxString timeouts[] = { "&None", "&Default (no delay)", "&3 seconds" };
         wxCOMPILE_TIME_ASSERT( WXSIZEOF(timeouts) == Timeout_Max, TmMismatch );
         m_timeouts = new wxRadioBox(this, wxID_ANY, "Timeout:",
                                     wxDefaultPosition, wxDefaultSize,
                                     WXSIZEOF(timeouts), timeouts,
                                     1, wxRA_SPECIFY_ROWS);
         m_timeouts->SetSelection(Timeout_Default);
+        m_timeDelay = new wxCheckBox(this, wxID_ANY, "Delay show" );
 
         // Lay them out.
         m_textBody->SetMinSize(wxSize(300, 200));
@@ -1864,6 +1873,7 @@ public:
         sizer->Add(m_tipKinds, wxSizerFlags().Centre().Border());
         sizer->Add(m_bgStyles, wxSizerFlags().Centre().Border());
         sizer->Add(m_timeouts, wxSizerFlags().Centre().Border());
+        sizer->Add(m_timeDelay, wxSizerFlags().Centre().Border());
         wxBoxSizer* const sizerBtns = new wxBoxSizer(wxHORIZONTAL);
         sizerBtns->Add(btnShowText, wxSizerFlags().Border(wxRIGHT));
         sizerBtns->Add(btnShowBtn, wxSizerFlags().Border(wxLEFT));
@@ -1964,17 +1974,22 @@ private:
                 break;
         }
 
+        int delay = m_timeDelay->IsChecked() ? 500 : 0;
+
         switch ( m_timeouts->GetSelection() )
         {
             case Timeout_None:
-                tip.SetTimeout(0);
+                // Don't call SetTimeout unnecessarily
+                // or msw will show generic impl
+                if ( delay )
+                    tip.SetTimeout(0, delay);
                 break;
 
             case Timeout_Default:
                 break;
 
             case Timeout_3sec:
-                tip.SetTimeout(3000);
+                tip.SetTimeout(3000, delay);
                 break;
         }
 
@@ -1989,6 +2004,7 @@ private:
     wxRadioBox* m_tipKinds;
     wxRadioBox* m_bgStyles;
     wxRadioBox* m_timeouts;
+    wxCheckBox* m_timeDelay;
 };
 
 void MyFrame::OnRichTipDialog(wxCommandEvent& WXUNUSED(event))
@@ -2931,6 +2947,10 @@ bool TestMessageBoxDialog::Create()
     // this sizer allows to configure the messages shown in the message box
     wxSizer * const
         sizerMsgs = new wxStaticBoxSizer(wxVERTICAL, this, "&Messages");
+    sizerMsgs->Add(new wxStaticText(this, wxID_ANY, "&Title:"));
+    m_textTitle = new wxTextCtrl(this, wxID_ANY, "Test Message Box");
+    sizerMsgs->Add(m_textTitle, wxSizerFlags().Expand().Border(wxBOTTOM));
+
     sizerMsgs->Add(new wxStaticText(this, wxID_ANY, "&Main message:"));
     m_textMsg = new wxTextCtrl(this, wxID_ANY, "Hello from a box!",
                                wxDefaultPosition, wxDefaultSize,
@@ -3139,7 +3159,7 @@ void TestMessageBoxDialog::PrepareMessageDialog(wxMessageDialogBase &dlg)
 
 void TestMessageBoxDialog::OnApply(wxCommandEvent& WXUNUSED(event))
 {
-    wxMessageDialog dlg(this, GetMessage(), "Test Message Box", GetStyle());
+    wxMessageDialog dlg(this, GetMessage(), GetBoxTitle(), GetStyle());
     PrepareMessageDialog(dlg);
 
     wxString btnName;
@@ -3227,8 +3247,7 @@ void TestRichMessageDialog::AddAdditionalFlags(wxSizer *sizer)
 
 void TestRichMessageDialog::OnApply(wxCommandEvent& WXUNUSED(event))
 {
-    wxRichMessageDialog dlg(this, GetMessage(), "Test Rich Message Dialog",
-                            GetStyle());
+    wxRichMessageDialog dlg(this, GetMessage(), GetBoxTitle(), GetStyle());
     PrepareMessageDialog(dlg);
 
     dlg.ShowCheckBox(m_textCheckBox->GetValue(),