X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/64c794f6820f129444ebcbf9dd6368805470e78e..5b952139e838585734114dd147f7747d6084a0af:/src/generic/choicdgg.cpp diff --git a/src/generic/choicdgg.cpp b/src/generic/choicdgg.cpp index c197380287..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 // ---------------------------------------------------------------------------- @@ -251,10 +265,8 @@ bool wxAnyChoiceDialog::Create(wxWindow *parent, wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL ); -#ifdef __SMARTPHONE__ - // 1) text message - topsizer->Add( CreateTextSizer( message ), 0, wxEXPAND, 0 ); + topsizer->Add( CreateTextSizer( message ), 0, wxALL, wxLARGESMALL(10,0) ); // 2) list box m_listbox = new wxListBox( this, wxID_LISTBOX, @@ -264,25 +276,15 @@ bool wxAnyChoiceDialog::Create(wxWindow *parent, if ( n > 0 ) m_listbox->SetSelection(0); - topsizer->Add( m_listbox, 1, wxEXPAND, 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")); #else // __SMARTPHONE__/!__SMARTPHONE__ - // 1) text message - topsizer->Add( CreateTextSizer( message ), 0, wxALL, 10 ); - - // 2) list box - m_listbox = new wxListBox( this, wxID_LISTBOX, - wxDefaultPosition, wxDefaultSize, - n, choices, - styleLbox ); - if ( n > 0 ) - m_listbox->SetSelection(0); - - topsizer->Add( m_listbox, 1, wxEXPAND | wxLEFT|wxRIGHT, 15 ); - #if wxUSE_STATLINE // 3) static line topsizer->Add( new wxStaticLine( this, wxID_ANY ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 ); @@ -299,7 +301,8 @@ bool wxAnyChoiceDialog::Create(wxWindow *parent, topsizer->SetSizeHints( this ); topsizer->Fit( this ); - Centre( wxBOTH ); + if ( styleDlg & wxCENTRE ) + Centre(wxBOTH); m_listbox->SetFocus(); @@ -324,11 +327,7 @@ bool wxAnyChoiceDialog::Create(wxWindow *parent, // ---------------------------------------------------------------------------- BEGIN_EVENT_TABLE(wxSingleChoiceDialog, wxDialog) -#if defined(__SMARTPHONE__) - EVT_MENU(wxID_OK, wxSingleChoiceDialog::OnOK) -#else EVT_BUTTON(wxID_OK, wxSingleChoiceDialog::OnOK) -#endif EVT_LISTBOX_DCLICK(wxID_LISTBOX, wxSingleChoiceDialog::OnListBoxDClick) END_EVENT_TABLE() @@ -459,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]); }