]>
git.saurik.com Git - wxWidgets.git/blob - src/common/lboxcmn.cpp
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"
35 #include "wx/dynarray.h"
38 // ============================================================================
40 // ============================================================================
42 wxListBoxBase::~wxListBoxBase()
44 // this destructor is required for Darwin
47 // ----------------------------------------------------------------------------
49 // ----------------------------------------------------------------------------
51 void wxListBoxBase::InsertItems(int nItems
, const wxString
*items
, int pos
)
54 for ( int n
= 0; n
< nItems
; n
++ )
59 DoInsertItems(aItems
, pos
);
63 void wxListBoxBase::Set(int nItems
, const wxString
* items
, void **clientData
)
66 for ( int n
= 0; n
< nItems
; n
++ )
71 DoSetItems(aItems
, clientData
);
74 // ----------------------------------------------------------------------------
76 // ----------------------------------------------------------------------------
78 bool wxListBoxBase::SetStringSelection(const wxString
& s
, bool select
)
80 int sel
= FindString(s
);
81 wxCHECK_MSG( sel
!= -1, FALSE
,
82 wxT("invalid string in SetStringSelection") );
84 SetSelection(sel
, select
);
89 void wxListBoxBase::DeselectAll(int itemToLeaveSelected
)
91 if ( HasMultipleSelection() )
93 wxArrayInt selections
;
94 GetSelections(selections
);
96 size_t count
= selections
.GetCount();
97 for ( size_t n
= 0; n
< count
; n
++ )
99 int item
= selections
[n
];
100 if ( item
!= itemToLeaveSelected
)
104 else // single selection
106 int sel
= GetSelection();
107 if ( sel
!= -1 && sel
!= itemToLeaveSelected
)
114 // ----------------------------------------------------------------------------
116 // ----------------------------------------------------------------------------
118 void wxListBoxBase::Command(wxCommandEvent
& event
)
120 SetSelection(event
.m_commandInt
, event
.m_extraLong
!= 0);
121 (void)ProcessEvent(event
);
124 // ----------------------------------------------------------------------------
125 // SetFirstItem() and such
126 // ----------------------------------------------------------------------------
128 void wxListBoxBase::SetFirstItem(const wxString
& s
)
130 int n
= FindString(s
);
132 wxCHECK_RET( n
!= -1, wxT("invalid string in wxListBox::SetFirstItem") );
137 void wxListBoxBase::AppendAndEnsureVisible(const wxString
& s
)
140 EnsureVisible(GetCount() - 1);
143 void wxListBoxBase::EnsureVisible(int WXUNUSED(n
))
145 // the base class version does nothing (the only alternative would be to
146 // call SetFirstItem() but this is probably even more stupid)
149 #endif // wxUSE_LISTBOX