X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/718970e5906a1fe0f84cc6ea9418cd79377767cd..311b8d3db7f6e723408a7ed9bbc72cac0a682701:/src/generic/choicdgg.cpp diff --git a/src/generic/choicdgg.cpp b/src/generic/choicdgg.cpp index 2d839af295..81ad3ae1f0 100644 --- a/src/generic/choicdgg.cpp +++ b/src/generic/choicdgg.cpp @@ -54,6 +54,20 @@ #define wxID_LISTBOX 3000 +// --------------------------------------------------------------------------- +// macros +// --------------------------------------------------------------------------- + +/* Macro for avoiding #ifdefs when value have to be different depending on size of + device we display on - take it from something like wxDesktopPolicy in the future + */ + +#if defined(__SMARTPHONE__) + #define wxLARGESMALL(large,small) small +#else + #define wxLARGESMALL(large,small) large +#endif + // ---------------------------------------------------------------------------- // private functions // ---------------------------------------------------------------------------- @@ -204,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(); @@ -246,6 +261,12 @@ bool wxAnyChoiceDialog::Create(wxWindow *parent, const wxPoint& pos, long styleLbox) { +#if defined(__SMARTPHONE__) || defined(__POCKETPC__) + styleDlg &= ~wxBORDER_MASK; + styleDlg &= ~wxRESIZE_BORDER; + styleDlg &= ~wxCAPTION; +#endif + if ( !wxDialog::Create(parent, wxID_ANY, caption, pos, wxDefaultSize, styleDlg) ) return false; @@ -262,8 +283,9 @@ bool wxAnyChoiceDialog::Create(wxWindow *parent, if ( n > 0 ) m_listbox->SetSelection(0); - topsizer->Add( m_listbox, 1, wxEXPAND | wxLEFT|wxRIGHT, wxLARGESMALL(15,0) ); + 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")); @@ -276,17 +298,19 @@ 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__ - SetAutoLayout( true ); SetSizer( topsizer ); +#if !defined(__SMARTPHONE__) && !defined(__POCKETPC__) topsizer->SetSizeHints( this ); topsizer->Fit( this ); - Centre( wxBOTH ); + if ( styleDlg & wxCENTRE ) + Centre(wxBOTH); +#endif m_listbox->SetFocus(); @@ -442,8 +466,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]); }