X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8316ff5d98f14f8d39fbe15a7fb9248e1f1194f4..c0b0635cf69537ca32377bad5650b39402cb21b6:/src/generic/choicdgg.cpp?ds=inline diff --git a/src/generic/choicdgg.cpp b/src/generic/choicdgg.cpp index a71dd76d5c..bb2a38dc56 100644 --- a/src/generic/choicdgg.cpp +++ b/src/generic/choicdgg.cpp @@ -59,7 +59,7 @@ // --------------------------------------------------------------------------- /* Macro for avoiding #ifdefs when value have to be different depending on size of - device we display on + device we display on - take it from something like wxDesktopPolicy in the future */ #if defined(__SMARTPHONE__) @@ -218,8 +218,9 @@ size_t wxGetMultipleChoices(wxArrayInt& selections, { wxMultiChoiceDialog dialog(parent, message, caption, n, choices); - if ( !selections.IsEmpty() ) - dialog.SetSelections(selections); + // 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 ) selections = dialog.GetSelections(); @@ -278,6 +279,7 @@ bool wxAnyChoiceDialog::Create(wxWindow *parent, topsizer->Add( m_listbox, 1, wxEXPAND | wxLEFT|wxRIGHT, wxLARGESMALL(15,0) ); + // smart phones does not support or do not waste space for wxButtons #ifdef __SMARTPHONE__ SetRightMenu(wxID_CANCEL, _("Cancel")); @@ -457,8 +459,17 @@ bool wxMultiChoiceDialog::Create( wxWindow *parent, void wxMultiChoiceDialog::SetSelections(const wxArrayInt& selections) { - size_t count = selections.GetCount(); - for ( size_t n = 0; n < count; n++ ) + // first clear all currently selected items + size_t n, + count = m_listbox->GetCount(); + for ( n = 0; n < count; ++n ) + { + m_listbox->Deselect(n); + } + + // now select the ones which should be selected + count = selections.GetCount(); + for ( n = 0; n < count; n++ ) { m_listbox->Select(selections[n]); }