]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/dialogs/dialogs.cpp
Test wxDataStream floating point methods in big endian format too.
[wxWidgets.git] / samples / dialogs / dialogs.cpp
index d4c7b8f6f6beb00daccaf48083ef4b2d8a415b3a..679838a4dd63ebdc109c716dcebf3e7b190bee14 100644 (file)
@@ -624,7 +624,7 @@ MyFrame::MyFrame(const wxString& title)
     m_infoBarAdvanced->AddButton(wxID_UNDO);
     m_infoBarAdvanced->AddButton(wxID_REDO);
 
-    m_infoBarAdvanced->Connect(wxID_REDO, wxEVT_COMMAND_BUTTON_CLICKED,
+    m_infoBarAdvanced->Connect(wxID_REDO, wxEVT_BUTTON,
                                 wxCommandEventHandler(MyFrame::OnInfoBarRedo),
                                 NULL,
                                 this);
@@ -671,7 +671,7 @@ MyFrame::MyFrame(const wxString& title)
         static const int DIALOGS_SYSTEM_ABOUT = 0x4010;
 
         menu->Append(DIALOGS_SYSTEM_ABOUT, "&About");
-        Connect(DIALOGS_SYSTEM_ABOUT, wxEVT_COMMAND_MENU_SELECTED,
+        Connect(DIALOGS_SYSTEM_ABOUT, wxEVT_MENU,
                 wxCommandEventHandler(MyFrame::ShowSimpleAboutDialog));
     }
 #endif // __WXMSW__
@@ -1345,7 +1345,7 @@ MyExtraPanel::MyExtraPanel(wxWindow *parent)
     m_btn = new wxButton(this, -1, wxT("Custom Button"));
     m_btn->Enable(false);
     m_cb = new wxCheckBox(this, -1, wxT("Enable Custom Button"));
-    m_cb->Connect(wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED,
+    m_cb->Connect(wxID_ANY, wxEVT_CHECKBOX,
                   wxCommandEventHandler(MyExtraPanel::OnCheckBox), NULL, this);
     wxBoxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
     sizerTop->Add(m_cb, wxSizerFlags().Centre().Border());
@@ -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));
@@ -1876,7 +1886,7 @@ public:
         // And connect the event handlers.
         btnShowText->Connect
                      (
-                        wxEVT_COMMAND_BUTTON_CLICKED,
+                        wxEVT_BUTTON,
                         wxCommandEventHandler(RichTipDialog::OnShowTipForText),
                         NULL,
                         this
@@ -1884,7 +1894,7 @@ public:
 
         btnShowBtn->Connect
                     (
-                        wxEVT_COMMAND_BUTTON_CLICKED,
+                        wxEVT_BUTTON,
                         wxCommandEventHandler(RichTipDialog::OnShowTipForBtn),
                         NULL,
                         this
@@ -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))
@@ -2383,23 +2399,23 @@ void MyFrame::OnFindDialog(wxFindDialogEvent& event)
 {
     wxEventType type = event.GetEventType();
 
-    if ( type == wxEVT_COMMAND_FIND || type == wxEVT_COMMAND_FIND_NEXT )
+    if ( type == wxEVT_FIND || type == wxEVT_FIND_NEXT )
     {
         wxLogMessage(wxT("Find %s'%s' (flags: %s)"),
-                     type == wxEVT_COMMAND_FIND_NEXT ? wxT("next ") : wxT(""),
+                     type == wxEVT_FIND_NEXT ? wxT("next ") : wxT(""),
                      event.GetFindString().c_str(),
                      DecodeFindDialogEventFlags(event.GetFlags()).c_str());
     }
-    else if ( type == wxEVT_COMMAND_FIND_REPLACE ||
-                type == wxEVT_COMMAND_FIND_REPLACE_ALL )
+    else if ( type == wxEVT_FIND_REPLACE ||
+                type == wxEVT_FIND_REPLACE_ALL )
     {
         wxLogMessage(wxT("Replace %s'%s' with '%s' (flags: %s)"),
-                     type == wxEVT_COMMAND_FIND_REPLACE_ALL ? wxT("all ") : wxT(""),
+                     type == wxEVT_FIND_REPLACE_ALL ? wxT("all ") : wxT(""),
                      event.GetFindString().c_str(),
                      event.GetReplaceString().c_str(),
                      DecodeFindDialogEventFlags(event.GetFlags()).c_str());
     }
-    else if ( type == wxEVT_COMMAND_FIND_CLOSE )
+    else if ( type == wxEVT_FIND_CLOSE )
     {
         wxFindReplaceDialog *dlg = event.GetDialog();
 
@@ -2989,7 +3005,8 @@ bool TestMessageBoxDialog::Create()
         "&Information icon",
         "&Question icon",
         "&Warning icon",
-        "&Error icon"
+        "&Error icon",
+        "A&uth needed icon"
     };
 
    wxCOMPILE_TIME_ASSERT( WXSIZEOF(icons) == MsgDlgIcon_Max, IconMismatch );
@@ -3090,6 +3107,10 @@ long TestMessageBoxDialog::GetStyle()
         case MsgDlgIcon_Error:
             style |= wxICON_ERROR;
             break;
+
+        case MsgDlgIcon_AuthNeeded:
+            style |= wxICON_AUTH_NEEDED;
+            break;
     }
 
     if ( m_chkCentre->IsChecked() )