were deprecated in favour of wxFileName methods. See docs for more info.
- wxEvtHandler::TryValidator/Parent() are deprecated, override the new and
documented TryBefore/After() methods if you used to override these ones.
-
+- wxGetMultipleChoices() is deprecated, use wxGetSelectedChoices() which has
+ the same signature but returns -1 and not 0 if the dialog was cancelled.
Major new features in this release
----------------------------------
- Render <th> element contents in bold in wxHTML.
- Added wxGrid::{Set,Get}{Row,Col}Sizes() methods (Andrey Putrin).
- Add support for wxSP_WRAP in the generic version of wxSpinCtrlDouble.
+- Added wxGetSelectedChoices() replacing wxGetMultipleChoices() (Kolya Kosenko).
wxGTK:
// fill the array with the indices of the chosen items, it will be empty
// if no items were selected or Cancel was pressed - return the number of
-// selections
-WXDLLIMPEXP_CORE size_t wxGetMultipleChoices(wxArrayInt& selections,
+// selections or -1 if cancelled
+WXDLLIMPEXP_CORE int wxGetSelectedChoices(wxArrayInt& selections,
const wxString& message,
const wxString& caption,
int n, const wxString *choices,
int width = wxCHOICE_WIDTH,
int height = wxCHOICE_HEIGHT);
-WXDLLIMPEXP_CORE size_t wxGetMultipleChoices(wxArrayInt& selections,
+WXDLLIMPEXP_CORE int wxGetSelectedChoices(wxArrayInt& selections,
const wxString& message,
const wxString& caption,
const wxArrayString& choices,
int width = wxCHOICE_WIDTH,
int height = wxCHOICE_HEIGHT);
+#if WXWIN_COMPATIBILITY_2_8
+// fill the array with the indices of the chosen items, it will be empty
+// if no items were selected or Cancel was pressed - return the number of
+// selections
+wxDEPRECATED( WXDLLIMPEXP_CORE size_t wxGetMultipleChoices(wxArrayInt& selections,
+ const wxString& message,
+ const wxString& caption,
+ int n, const wxString *choices,
+ wxWindow *parent = NULL,
+ int x = wxDefaultCoord,
+ int y = wxDefaultCoord,
+ bool centre = true,
+ int width = wxCHOICE_WIDTH,
+ int height = wxCHOICE_HEIGHT) );
+
+wxDEPRECATED( WXDLLIMPEXP_CORE size_t wxGetMultipleChoices(wxArrayInt& selections,
+ const wxString& message,
+ const wxString& caption,
+ const wxArrayString& choices,
+ wxWindow *parent = NULL,
+ int x = wxDefaultCoord,
+ int y = wxDefaultCoord,
+ bool centre = true,
+ int width = wxCHOICE_WIDTH,
+ int height = wxCHOICE_HEIGHT));
+#endif // WXWIN_COMPATIBILITY_2_8
+
#endif // _WX_GENERIC_CHOICDGG_H_
multiple-selection listbox. The user may choose an arbitrary (including 0)
number of items in the listbox whose indices will be returned in
@c selections array. The initial contents of this array will be used to
- select the items when the dialog is shown.
+ select the items when the dialog is shown. If the user cancels the dialog,
+ the function returns -1 and @c selections array is left unchanged.
You may pass the list of strings to choose from either using @c choices
which is an array of @a n strings for the listbox or by using a single
@header{wx/choicdlg.h}
*/
-size_t wxGetMultipleChoices(wxArrayInt& selections,
+int wxGetSelectedChoices(wxArrayInt& selections,
const wxString& message,
const wxString& caption,
const wxArrayString& aChoices,
bool centre = true,
int width = 150,
int height = 200);
-size_t wxGetMultipleChoices(wxArrayInt& selections,
+int wxGetSelectedChoices(wxArrayInt& selections,
const wxString& message,
const wxString& caption,
int n,
};
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 = wxT("You did not select any items");
+ }
+ else
{
- msg += wxString::Format(wxT("\t%u: %u (%s)\n"),
- (unsigned)n, (unsigned)selections[n],
- choices[selections[n]].c_str());
+ 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
return res;
}
-size_t wxGetMultipleChoices(wxArrayInt& selections,
+int wxGetSelectedChoices(wxArrayInt& selections,
const wxString& message,
const wxString& caption,
int n, const wxString *choices,
// deselects the first item which is selected by default
dialog.SetSelections(selections);
- if ( dialog.ShowModal() == wxID_OK )
- selections = dialog.GetSelections();
- else
- selections.Empty();
+ 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();
}
-size_t wxGetMultipleChoices(wxArrayInt& selections,
+int wxGetSelectedChoices(wxArrayInt& selections,
const wxString& message,
const wxString& caption,
const wxArrayString& aChoices,
{
wxString *choices;
int n = ConvertWXArrayToC(aChoices, &choices);
- size_t res = wxGetMultipleChoices(selections, message, caption,
+ 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
// ----------------------------------------------------------------------------