+
+ selections = dialog.GetSelections();
+ return selections.GetCount();
+}
+
+int wxGetSelectedChoices(wxArrayInt& selections,
+ const wxString& message,
+ const wxString& caption,
+ const wxArrayString& aChoices,
+ wxWindow *parent,
+ int x, int y,
+ bool centre,
+ int width, int height)
+{
+ wxString *choices;
+ int n = ConvertWXArrayToC(aChoices, &choices);
+ int res = wxGetSelectedChoices(selections, message, caption,
+ n, choices, parent,
+ x, y, centre, width, height);
+ delete [] choices;
+
+ return res;
+}
+
+#if WXWIN_COMPATIBILITY_2_8
+size_t wxGetMultipleChoices(wxArrayInt& selections,
+ const wxString& message,
+ const wxString& caption,
+ int n, const wxString *choices,
+ wxWindow *parent,
+ int x, int y,
+ bool centre,
+ int width, int height)
+{
+ int rc = wxGetSelectedChoices(selections, message, caption,
+ n, choices,
+ parent, x, y, centre, width, height);
+ if ( rc == -1 )
+ {
+ selections.clear();
+ return 0;
+ }
+
+ return rc;
+}
+
+size_t wxGetMultipleChoices(wxArrayInt& selections,
+ const wxString& message,
+ const wxString& caption,
+ const wxArrayString& aChoices,
+ wxWindow *parent,
+ int x, int y,
+ bool centre,
+ int width, int height)
+{
+ int rc = wxGetSelectedChoices(selections, message, caption,
+ aChoices,
+ parent, x, y, centre, width, height);
+ if ( rc == -1 )
+ {
+ selections.clear();
+ return 0;
+ }
+
+ return rc;
+}
+#endif // WXWIN_COMPATIBILITY_2_8
+
+// ----------------------------------------------------------------------------
+// wxAnyChoiceDialog
+// ----------------------------------------------------------------------------
+
+bool wxAnyChoiceDialog::Create(wxWindow *parent,
+ const wxString& message,
+ const wxString& caption,
+ int n, const wxString *choices,
+ long styleDlg,
+ const wxPoint& pos,
+ long styleLbox)
+{
+ // extract the buttons styles from the dialog one and remove them from it
+ const long styleBtns = styleDlg & (wxOK | wxCANCEL);
+ styleDlg &= ~styleBtns;
+
+ if ( !wxDialog::Create(parent, wxID_ANY, caption, pos, wxDefaultSize, styleDlg) )
+ return false;
+
+ wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
+
+ // 1) text message
+ topsizer->
+ Add(CreateTextSizer(message), wxSizerFlags().Expand().TripleBorder());
+
+ // 2) list box
+ m_listbox = CreateList(n, choices, styleLbox);
+
+ if ( n > 0 )
+ m_listbox->SetSelection(0);
+
+ topsizer->
+ Add(m_listbox, wxSizerFlags().Expand().Proportion(1).TripleBorder(wxLEFT | wxRIGHT));
+
+ // 3) buttons if any
+ wxSizer *
+ buttonSizer = CreateSeparatedButtonSizer(styleBtns);
+ if ( buttonSizer )
+ {
+ topsizer->Add(buttonSizer, wxSizerFlags().Expand().DoubleBorder());
+ }
+
+ SetSizer( topsizer );
+
+ topsizer->SetSizeHints( this );
+ topsizer->Fit( this );
+
+ if ( styleDlg & wxCENTRE )
+ Centre(wxBOTH);
+
+ m_listbox->SetFocus();
+
+ return true;
+}
+
+bool wxAnyChoiceDialog::Create(wxWindow *parent,
+ const wxString& message,
+ const wxString& caption,
+ const wxArrayString& choices,
+ long styleDlg,
+ const wxPoint& pos,
+ long styleLbox)
+{
+ wxCArrayString chs(choices);
+ return Create(parent, message, caption, chs.GetCount(), chs.GetStrings(),
+ styleDlg, pos, styleLbox);
+}
+
+wxListBoxBase *wxAnyChoiceDialog::CreateList(int n, const wxString *choices, long styleLbox)
+{
+ return new wxListBox( this, wxID_LISTBOX,
+ wxDefaultPosition, wxDefaultSize,
+ n, choices,
+ styleLbox );
+}
+
+// ----------------------------------------------------------------------------
+// wxSingleChoiceDialog
+// ----------------------------------------------------------------------------
+
+BEGIN_EVENT_TABLE(wxSingleChoiceDialog, wxDialog)
+ EVT_BUTTON(wxID_OK, wxSingleChoiceDialog::OnOK)
+#ifndef __SMARTPHONE__
+ EVT_LISTBOX_DCLICK(wxID_LISTBOX, wxSingleChoiceDialog::OnListBoxDClick)
+#endif
+#ifdef __WXWINCE__
+ EVT_JOY_BUTTON_DOWN(wxSingleChoiceDialog::OnJoystickButtonDown)
+#endif
+END_EVENT_TABLE()
+
+IMPLEMENT_DYNAMIC_CLASS(wxSingleChoiceDialog, wxDialog)
+
+wxSingleChoiceDialog::wxSingleChoiceDialog(wxWindow *parent,
+ const wxString& message,
+ const wxString& caption,
+ int n,
+ const wxString *choices,
+ char **clientData,
+ long style,
+ const wxPoint& WXUNUSED(pos))
+{
+ Create(parent, message, caption, n, choices, clientData, style);
+}
+
+wxSingleChoiceDialog::wxSingleChoiceDialog(wxWindow *parent,
+ const wxString& message,
+ const wxString& caption,
+ const wxArrayString& choices,
+ char **clientData,
+ long style,
+ const wxPoint& WXUNUSED(pos))
+{
+ Create(parent, message, caption, choices, clientData, style);
+}
+
+bool wxSingleChoiceDialog::Create( wxWindow *parent,
+ const wxString& message,
+ const wxString& caption,
+ int n,
+ const wxString *choices,
+ char **clientData,
+ long style,
+ const wxPoint& pos )
+{
+ if ( !wxAnyChoiceDialog::Create(parent, message, caption,
+ n, choices,
+ style, pos) )
+ return false;
+
+ m_selection = n > 0 ? 0 : -1;
+
+ if (clientData)
+ {
+ for (int i = 0; i < n; i++)
+ m_listbox->SetClientData(i, clientData[i]);
+ }
+
+ return true;
+}
+
+bool wxSingleChoiceDialog::Create( wxWindow *parent,
+ const wxString& message,
+ const wxString& caption,
+ const wxArrayString& choices,
+ char **clientData,
+ long style,
+ const wxPoint& pos )
+{
+ wxCArrayString chs(choices);
+ return Create( parent, message, caption, chs.GetCount(), chs.GetStrings(),
+ clientData, style, pos );
+}
+
+// Set the selection
+void wxSingleChoiceDialog::SetSelection(int sel)
+{
+ wxCHECK_RET( sel >= 0 && (unsigned)sel < m_listbox->GetCount(),
+ "Invalid initial selection" );
+
+ m_listbox->SetSelection(sel);