]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/dialogs/dialogs.cpp
expand the collapsible panes contents to fill the entire pane area (see #11004)
[wxWidgets.git] / samples / dialogs / dialogs.cpp
index bcc620839fe86a902c593a6e029e33db924ac93d..248f717fccb52bb4f1101037d89286f71e8b9515 100644 (file)
@@ -809,25 +809,32 @@ void MyFrame::MultiChoice(wxCommandEvent& WXUNUSED(event) )
     };
 
     wxArrayInt selections;
-    size_t count = wxGetMultipleChoices(selections,
+    const int count = wxGetSelectedChoices(selections,
                                         _T("This is a small sample\n")
                                         _T("A multi-choice convenience dialog"),
                                         _T("Please select a value"),
                                         WXSIZEOF(choices), choices,
                                         this);
-    if ( count )
+    if ( count >= 0 )
     {
         wxString msg;
-        msg.Printf(wxT("You selected %u items:\n"), (unsigned)count);
-        for ( size_t n = 0; n < count; n++ )
+        if ( count == 0 )
         {
-            msg += wxString::Format(wxT("\t%u: %u (%s)\n"),
-                                    (unsigned)n, (unsigned)selections[n],
-                                    choices[selections[n]].c_str());
+            msg = wxT("You did not select any items");
+        }
+        else
+        {
+            msg.Printf(wxT("You selected %u items:\n"), (unsigned)count);
+            for ( int n = 0; n < count; n++ )
+            {
+                msg += wxString::Format(wxT("\t%u: %u (%s)\n"),
+                                        (unsigned)n, (unsigned)selections[n],
+                                        choices[selections[n]].c_str());
+            }
         }
         wxLogMessage(msg);
     }
-    //else: cancelled or nothing selected
+    //else: cancelled
 }
 #endif // wxUSE_CHOICEDLG
 
@@ -980,7 +987,7 @@ private:
     wxTextCtrl *m_text;
 
     DECLARE_EVENT_TABLE()
-    DECLARE_NO_COPY_CLASS(MyRearrangeDialog)
+    wxDECLARE_NO_COPY_CLASS(MyRearrangeDialog);
 };
 
 BEGIN_EVENT_TABLE(MyRearrangeDialog, wxRearrangeDialog)
@@ -1514,10 +1521,9 @@ void MyFrame::OnNotifMsgShow(wxCommandEvent& WXUNUSED(event))
 
 void MyFrame::OnNotifMsgHide(wxCommandEvent& WXUNUSED(event))
 {
-    if ( m_notifMsg )
+    if ( m_notifMsg && !m_notifMsg->Close() )
     {
-        if ( !m_notifMsg->Close() )
-            wxLogStatus("Failed to hide manual notification message");
+        wxLogStatus("Failed to hide manual notification message");
     }
 }
 
@@ -1734,7 +1740,7 @@ void MyFrame::ShowSimpleAboutDialog(wxCommandEvent& WXUNUSED(event))
     wxAboutDialogInfo info;
     InitAboutInfoMinimal(info);
 
-    wxAboutBox(info);
+    wxAboutBox(info, this);
 }
 
 void MyFrame::ShowFancyAboutDialog(wxCommandEvent& WXUNUSED(event))
@@ -1742,7 +1748,7 @@ void MyFrame::ShowFancyAboutDialog(wxCommandEvent& WXUNUSED(event))
     wxAboutDialogInfo info;
     InitAboutInfoWebsite(info);
 
-    wxAboutBox(info);
+    wxAboutBox(info, this);
 }
 
 void MyFrame::ShowFullAboutDialog(wxCommandEvent& WXUNUSED(event))
@@ -1750,16 +1756,16 @@ void MyFrame::ShowFullAboutDialog(wxCommandEvent& WXUNUSED(event))
     wxAboutDialogInfo info;
     InitAboutInfoAll(info);
 
-    wxAboutBox(info);
+    wxAboutBox(info, this);
 }
 
 // a trivial example of a custom dialog class
 class MyAboutDialog : public wxGenericAboutDialog
 {
 public:
-    MyAboutDialog(const wxAboutDialogInfo& info)
+    MyAboutDialog(const wxAboutDialogInfo& info, wxWindow* parent)
     {
-        Create(info);
+        Create(info, parent);
     }
 
     // add some custom controls
@@ -1776,7 +1782,7 @@ void MyFrame::ShowCustomAboutDialog(wxCommandEvent& WXUNUSED(event))
     wxAboutDialogInfo info;
     InitAboutInfoAll(info);
 
-    MyAboutDialog dlg(info);
+    MyAboutDialog dlg(info, this);
     dlg.ShowModal();
 }
 
@@ -1792,7 +1798,7 @@ void MyFrame::ShowBusyInfo(wxCommandEvent& WXUNUSED(event))
 
     for ( int i = 0; i < 18; i++ )
     {
-        //wxUsleep(100);
+        wxMilliSleep(100);
         wxTheApp->Yield();
     }
 
@@ -1991,14 +1997,15 @@ MyModalDialog::MyModalDialog(wxWindow *parent)
     m_btnModeless = new wxButton(this, wxID_ANY, _T("Mode&less dialog"));
     m_btnDelete = new wxButton(this, wxID_ANY, _T("&Delete button"));
 
-    wxButton *btnOk = new wxButton(this, wxID_CANCEL, _T("&Close"));
     sizerTop->Add(m_btnModal, 0, wxALIGN_CENTER | wxALL, 5);
     sizerTop->Add(m_btnModeless, 0, wxALIGN_CENTER | wxALL, 5);
     sizerTop->Add(m_btnDelete, 0, wxALIGN_CENTER | wxALL, 5);
-    sizerTop->Add(btnOk, 0, wxALIGN_CENTER | wxALL, 5);
+    sizerTop->Add(new wxButton(this, wxID_CLOSE), 0, wxALIGN_CENTER | wxALL, 5);
 
     SetSizerAndFit(sizerTop);
 
+    SetEscapeId(wxID_CLOSE);
+
     m_btnModal->SetFocus();
     m_btnModal->SetDefault();
 }
@@ -2450,12 +2457,14 @@ TestMessageBoxDialog::TestMessageBoxDialog(wxWindow *parent)
 
     // icon choice
     const wxString icons[] = {
-        "&Information", "&Question", "&Warning", "&Error"
+        "&None", "&Information", "&Question", "&Warning", "&Error"
     };
 
-    m_icons = new wxRadioBox(this, wxID_ANY, "&Icon:",
+    m_icons = new wxRadioBox(this, wxID_ANY, "&Icons",
                              wxDefaultPosition, wxDefaultSize,
                              WXSIZEOF(icons), icons);
+    // Make the 'Information' icon the default one:
+    m_icons->SetSelection(1);
     sizerTop->Add(m_icons, wxSizerFlags().Expand().Border());
 
 
@@ -2516,10 +2525,11 @@ void TestMessageBoxDialog::OnApply(wxCommandEvent& WXUNUSED(event))
 
     switch ( m_icons->GetSelection() )
     {
-        case 0: style |= wxICON_INFORMATION; break;
-        case 1: style |= wxICON_QUESTION; break;
-        case 2: style |= wxICON_WARNING; break;
-        case 3: style |= wxICON_ERROR; break;
+        case 0: style |= wxICON_NONE; break;
+        case 1: style |= wxICON_INFORMATION; break;
+        case 2: style |= wxICON_QUESTION; break;
+        case 3: style |= wxICON_WARNING; break;
+        case 4: style |= wxICON_ERROR; break;
     }
 
     if ( m_chkCentre->IsChecked() )