X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8316ff5d98f14f8d39fbe15a7fb9248e1f1194f4..0281278534339322516fa6133ed4df925c2156be:/src/generic/choicdgg.cpp diff --git a/src/generic/choicdgg.cpp b/src/generic/choicdgg.cpp index a71dd76d5c..2b5b11b2a2 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")); @@ -290,7 +292,7 @@ bool wxAnyChoiceDialog::Create(wxWindow *parent, #endif // 4) buttons - topsizer->Add( CreateButtonSizer( styleDlg & (wxOK|wxCANCEL) ), 0, wxCENTRE | wxALL, 10 ); + topsizer->Add( CreateButtonSizer( styleDlg & (wxOK|wxCANCEL) ), 0, wxEXPAND | wxALL, 10 ); #endif // !__SMARTPHONE__ @@ -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]); }