X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/119727ad9e58e42326764a259a5b88267bb43528..5b952139e838585734114dd147f7747d6084a0af:/src/generic/choicdgg.cpp?ds=sidebyside diff --git a/src/generic/choicdgg.cpp b/src/generic/choicdgg.cpp index ad3680b5fd..6e591c78cd 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 // ---------------------------------------------------------------------------- @@ -252,7 +266,7 @@ bool wxAnyChoiceDialog::Create(wxWindow *parent, wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL ); // 1) text message - topsizer->Add( CreateTextSizer( message ), 0, wxEXPAND, wxLARGESMALL(10,0) ); + topsizer->Add( CreateTextSizer( message ), 0, wxALL, wxLARGESMALL(10,0) ); // 2) list box m_listbox = new wxListBox( this, wxID_LISTBOX, @@ -262,8 +276,9 @@ bool wxAnyChoiceDialog::Create(wxWindow *parent, if ( n > 0 ) m_listbox->SetSelection(0); - topsizer->Add( m_listbox, 1, wxEXPAND, 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")); @@ -286,7 +301,8 @@ bool wxAnyChoiceDialog::Create(wxWindow *parent, topsizer->SetSizeHints( this ); topsizer->Fit( this ); - Centre( wxBOTH ); + if ( styleDlg & wxCENTRE ) + Centre(wxBOTH); m_listbox->SetFocus(); @@ -442,8 +458,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]); }