1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: common/lboxcmn.cpp
3 // Purpose: wxListBox class methods common to all platforms
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "listboxbase.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
34 #include "wx/listbox.h"
37 // ============================================================================
39 // ============================================================================
41 // ----------------------------------------------------------------------------
43 // ----------------------------------------------------------------------------
45 void wxListBoxBase::InsertItems(int nItems
, const wxString
*items
, int pos
)
48 for ( int n
= 0; n
< nItems
; n
++ )
53 DoInsertItems(aItems
, pos
);
57 void wxListBoxBase::Set(int nItems
, const wxString
* items
, void **clientData
)
60 for ( int n
= 0; n
< nItems
; n
++ )
65 DoSetItems(aItems
, clientData
);
68 // ----------------------------------------------------------------------------
70 // ----------------------------------------------------------------------------
72 bool wxListBoxBase::SetStringSelection(const wxString
& s
, bool select
)
74 int sel
= FindString(s
);
75 wxCHECK_MSG( sel
!= -1, FALSE
,
76 wxT("invalid string in SetStringSelection") );
78 SetSelection(sel
, select
);
83 void wxListBoxBase::DeselectAll(int itemToLeaveSelected
)
85 if ( HasMultipleSelection() )
87 wxArrayInt selections
;
88 GetSelections(selections
);
90 size_t count
= selections
.GetCount();
91 for ( size_t n
= 0; n
< count
; n
++ )
93 int item
= selections
[n
];
94 if ( item
!= itemToLeaveSelected
)
98 else // single selection
100 int sel
= GetSelection();
101 if ( sel
!= -1 && sel
!= itemToLeaveSelected
)
108 // ----------------------------------------------------------------------------
110 // ----------------------------------------------------------------------------
112 void wxListBoxBase::Command(wxCommandEvent
& event
)
114 SetSelection(event
.m_commandInt
, event
.m_extraLong
!= 0);
115 (void)ProcessEvent(event
);
118 // ----------------------------------------------------------------------------
119 // SetFirstItem() and such
120 // ----------------------------------------------------------------------------
122 void wxListBoxBase::SetFirstItem(const wxString
& s
)
124 int n
= FindString(s
);
126 wxCHECK_RET( n
!= -1, wxT("invalid string in wxListBox::SetFirstItem") );
131 void wxListBoxBase::AppendAndEnsureVisible(const wxString
& s
)
134 EnsureVisible(GetCount() - 1);
137 void wxListBoxBase::EnsureVisible(int WXUNUSED(n
))
139 // the base class version does nothing (the only alternative would be to
140 // call SetFirstItem() but this is probably even more stupid)
143 #endif // wxUSE_LISTBOX