-extern void wxSplitMessage2(const char *message, wxList *messageList, wxWindow *parent, wxRowColSizer *sizer);
-
-wxString wxGetSingleChoice( const wxString& message, const wxString& caption, const int n,
- const wxString *choices, wxWindow *parent,
- const int WXUNUSED(x), const int WXUNUSED(y), const bool WXUNUSED(centre),
- const int WXUNUSED(width), const int WXUNUSED(height) )
-{
- wxSingleChoiceDialog dialog(parent, message, caption, n, choices);
- if ( dialog.ShowModal() == wxID_OK )
- {
- return dialog.GetStringSelection();
- }
- else
- return "";
-}
-
-// Overloaded for backward compatibility
-wxString wxGetSingleChoice( const wxString& message, const wxString& caption, const int n,
- char *choices[], wxWindow *parent,
- const int x, const int y, const bool centre,
- const int width, const int height )
-{
- wxString *strings = new wxString[n];
- int i;
- for ( i = 0; i < n; i++)
- {
- strings[i] = choices[i];
- }
- wxString ans(wxGetSingleChoice(message, caption, n, (const wxString *)strings, parent,
- x, y, centre, width, height));
- delete[] strings;
- return ans;
-}
-
-int wxGetSingleChoiceIndex( const wxString& message, const wxString& caption, const int n,
- const wxString *choices, wxWindow *parent,
- const int WXUNUSED(x), const int WXUNUSED(y), const bool WXUNUSED(centre),
- const int WXUNUSED(width), const int WXUNUSED(height) )
-{
- wxSingleChoiceDialog dialog(parent, message, caption, n, choices);
- if ( dialog.ShowModal() == wxID_OK )
- {
- return dialog.GetSelection();
- }
- else
- return -1;
-}
-
-// Overloaded for backward compatibility
-int wxGetSingleChoiceIndex( const wxString& message, const wxString& caption, const int n,
- char *choices[], wxWindow *parent,
- const int x, const int y, const bool centre,
- const int width, const int height )
-{
- wxString *strings = new wxString[n];
- int i;
- for ( i = 0; i < n; i++)
- {
- strings[i] = choices[i];
- }
- int ans = wxGetSingleChoiceIndex(message, caption, n, (const wxString *)strings, parent,
- x, y, centre, width, height);
- delete[] strings;
- return ans;
-}
-
-char *wxGetSingleChoiceData( const wxString& message, const wxString& caption, const int n,
- const wxString *choices, char **client_data, wxWindow *parent,
- const int WXUNUSED(x), const int WXUNUSED(y), const bool WXUNUSED(centre),
- const int WXUNUSED(width), const int WXUNUSED(height) )
-{
- wxSingleChoiceDialog dialog(parent, message, caption, n, choices, client_data);
- if ( dialog.ShowModal() == wxID_OK )
- {
- return dialog.GetSelectionClientData();
- }
- else
- return NULL;
-}
-
-// Overloaded for backward compatibility
-char *wxGetSingleChoiceData( const wxString& message, const wxString& caption, const int n,
- char *choices[], char **client_data, wxWindow *parent,
- const int x, const int y, const bool centre,
- const int width, const int height )
-{
- wxString *strings = new wxString[n];
- int i;
- for ( i = 0; i < n; i++)
- {
- strings[i] = choices[i];
- }
- char *data = wxGetSingleChoiceData(message, caption, n, (const wxString *)strings, client_data, parent,
- x, y, centre, width, height);
- delete[] strings;
- return data;
-}
-
-
-/* Multiple choice dialog contributed by Robert Cowell
- *
-
-The new data passed are in the "int nsel" and "int * selection"
-
-The idea is to make a multiple selection from list of strings.
-The returned value is the total number selected. initialily there
-are nsel selected, with indices stored in
-selection[0],...,selection[nsel-1] which appear highlighted to
-begin with. On exit with value i
-selection[0..i-1] contains the indices of the selected items.
-(Some prior selectecions might be deselected.)
-Thus selection must be as big as choices, in case all items are
-selected.
-
-*/
-/*
-int wxGetMultipleChoice(const wxString& message, const wxString& caption,
- const int n, const wxString *choices,
- const int nsel, int * selection,
- wxWindow *parent , const int x , const int y, const bool centre,
- const int width, const int height)
-{
- return -1;
-}
-*/
+// ----------------------------------------------------------------------------
+// constants
+// ----------------------------------------------------------------------------
+
+#define wxID_LISTBOX 3000
+
+// ----------------------------------------------------------------------------
+// private functions
+// ----------------------------------------------------------------------------
+
+// convert wxArrayString into a wxString[] which must be delete[]d by caller
+static int ConvertWXArrayToC(const wxArrayString& aChoices, wxString **choices);
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// helpers
+// ----------------------------------------------------------------------------
+
+int ConvertWXArrayToC(const wxArrayString& aChoices, wxString **choices)
+{
+ int n = aChoices.GetCount();
+ *choices = new wxString[n];
+
+ for ( int i = 0; i < n; i++ )
+ {
+ (*choices)[i] = aChoices[i];
+ }
+
+ return n;
+}
+
+// ----------------------------------------------------------------------------
+// wrapper functions
+// ----------------------------------------------------------------------------
+
+wxString wxGetSingleChoice( const wxString& message,
+ const wxString& caption,
+ int n, const wxString *choices,
+ wxWindow *parent,
+ int WXUNUSED(x), int WXUNUSED(y),
+ bool WXUNUSED(centre),
+ int WXUNUSED(width), int WXUNUSED(height),
+ int initialSelection)
+{
+ wxSingleChoiceDialog dialog(parent, message, caption, n, choices);
+
+ dialog.SetSelection(initialSelection);
+
+ wxString choice;
+ if ( dialog.ShowModal() == wxID_OK )
+ choice = dialog.GetStringSelection();
+
+ return choice;
+}
+
+wxString wxGetSingleChoice( const wxString& message,
+ const wxString& caption,
+ const wxArrayString& aChoices,
+ wxWindow *parent,
+ int x, int y,
+ bool centre,
+ int width, int height,
+ int initialSelection)
+{
+ wxString *choices;
+ int n = ConvertWXArrayToC(aChoices, &choices);
+ wxString res = wxGetSingleChoice(message, caption, n, choices, parent,
+ x, y, centre, width, height,
+ initialSelection);
+ delete [] choices;
+
+ return res;
+}
+
+wxString wxGetSingleChoice( const wxString& message,
+ const wxString& caption,
+ const wxArrayString& choices,
+ int initialSelection,
+ wxWindow *parent)
+{
+ return wxGetSingleChoice(message, caption, choices, parent,
+ wxDefaultCoord, wxDefaultCoord,
+ true, wxCHOICE_WIDTH, wxCHOICE_HEIGHT,
+ initialSelection);
+}
+
+wxString wxGetSingleChoice( const wxString& message,
+ const wxString& caption,
+ int n, const wxString *choices,
+ int initialSelection,
+ wxWindow *parent)
+{
+ return wxGetSingleChoice(message, caption, n, choices, parent,
+ wxDefaultCoord, wxDefaultCoord,
+ true, wxCHOICE_WIDTH, wxCHOICE_HEIGHT,
+ initialSelection);
+}
+
+int wxGetSingleChoiceIndex( const wxString& message,
+ const wxString& caption,
+ int n, const wxString *choices,
+ wxWindow *parent,
+ int WXUNUSED(x), int WXUNUSED(y),
+ bool WXUNUSED(centre),
+ int WXUNUSED(width), int WXUNUSED(height),
+ int initialSelection)
+{
+ wxSingleChoiceDialog dialog(parent, message, caption, n, choices);
+
+ dialog.SetSelection(initialSelection);
+
+ int choice;
+ if ( dialog.ShowModal() == wxID_OK )
+ choice = dialog.GetSelection();
+ else
+ choice = -1;
+
+ return choice;
+}
+
+int wxGetSingleChoiceIndex( const wxString& message,
+ const wxString& caption,
+ const wxArrayString& aChoices,
+ wxWindow *parent,
+ int x, int y,
+ bool centre,
+ int width, int height,
+ int initialSelection)
+{
+ wxString *choices;
+ int n = ConvertWXArrayToC(aChoices, &choices);
+ int res = wxGetSingleChoiceIndex(message, caption, n, choices, parent,
+ x, y, centre, width, height,
+ initialSelection);
+ delete [] choices;
+
+ return res;
+}
+
+int wxGetSingleChoiceIndex( const wxString& message,
+ const wxString& caption,
+ const wxArrayString& choices,
+ int initialSelection,
+ wxWindow *parent)
+{
+ return wxGetSingleChoiceIndex(message, caption, choices, parent,
+ wxDefaultCoord, wxDefaultCoord,
+ true, wxCHOICE_WIDTH, wxCHOICE_HEIGHT,
+ initialSelection);
+}
+
+
+int wxGetSingleChoiceIndex( const wxString& message,
+ const wxString& caption,
+ int n, const wxString *choices,
+ int initialSelection,
+ wxWindow *parent)
+{
+ return wxGetSingleChoiceIndex(message, caption, n, choices, parent,
+ wxDefaultCoord, wxDefaultCoord,
+ true, wxCHOICE_WIDTH, wxCHOICE_HEIGHT,
+ initialSelection);
+}
+
+
+void *wxGetSingleChoiceData( const wxString& message,
+ const wxString& caption,
+ int n, const wxString *choices,
+ void **client_data,
+ wxWindow *parent,
+ int WXUNUSED(x), int WXUNUSED(y),
+ bool WXUNUSED(centre),
+ int WXUNUSED(width), int WXUNUSED(height),
+ int initialSelection)
+{
+ wxSingleChoiceDialog dialog(parent, message, caption, n, choices,
+ (char **)client_data);
+
+ dialog.SetSelection(initialSelection);
+
+ void *data;
+ if ( dialog.ShowModal() == wxID_OK )
+ data = dialog.GetSelectionClientData();
+ else
+ data = NULL;
+
+ return data;
+}
+
+void *wxGetSingleChoiceData( const wxString& message,
+ const wxString& caption,
+ const wxArrayString& aChoices,
+ void **client_data,
+ wxWindow *parent,
+ int x, int y,
+ bool centre,
+ int width, int height,
+ int initialSelection)
+{
+ wxString *choices;
+ int n = ConvertWXArrayToC(aChoices, &choices);
+ void *res = wxGetSingleChoiceData(message, caption, n, choices,
+ client_data, parent,
+ x, y, centre, width, height,
+ initialSelection);
+ delete [] choices;
+
+ return res;
+}
+
+void* wxGetSingleChoiceData( const wxString& message,
+ const wxString& caption,
+ const wxArrayString& choices,
+ void **client_data,
+ int initialSelection,
+ wxWindow *parent)
+{
+ return wxGetSingleChoiceData(message, caption, choices,
+ client_data, parent,
+ wxDefaultCoord, wxDefaultCoord,
+ true, wxCHOICE_WIDTH, wxCHOICE_HEIGHT,
+ initialSelection);
+}
+
+void* wxGetSingleChoiceData( const wxString& message,
+ const wxString& caption,
+ int n, const wxString *choices,
+ void **client_data,
+ int initialSelection,
+ wxWindow *parent)
+{
+ return wxGetSingleChoiceData(message, caption, n, choices,
+ client_data, parent,
+ wxDefaultCoord, wxDefaultCoord,
+ true, wxCHOICE_WIDTH, wxCHOICE_HEIGHT,
+ initialSelection);
+}
+
+
+int wxGetSelectedChoices(wxArrayInt& selections,
+ const wxString& message,
+ const wxString& caption,
+ int n, const wxString *choices,
+ wxWindow *parent,
+ int WXUNUSED(x), int WXUNUSED(y),
+ bool WXUNUSED(centre),
+ int WXUNUSED(width), int WXUNUSED(height))
+{
+ wxMultiChoiceDialog dialog(parent, message, caption, n, choices);
+
+ // call this even if selections array is empty and this then (correctly)
+ // deselects the first item which is selected by default
+ dialog.SetSelections(selections);
+
+ if ( dialog.ShowModal() != wxID_OK )
+ {
+ // NB: intentionally do not clear the selections array here, the caller
+ // might want to preserve its original contents if the dialog was
+ // cancelled
+ return -1;
+ }
+
+ selections = dialog.GetSelections();
+ return selections.GetCount();
+}