#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
// ----------------------------------------------------------------------------
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,
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 );
topsizer->SetSizeHints( this );
topsizer->Fit( this );
- Centre( wxBOTH );
+ if ( styleDlg & wxCENTRE )
+ Centre(wxBOTH);
m_listbox->SetFocus();
// ----------------------------------------------------------------------------
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()
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]);
}