#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
// ----------------------------------------------------------------------------
{
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();
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;
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"));
#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();
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]);
}