]>
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"
37 // ============================================================================
39 // ============================================================================
41 wxListBoxBase::~wxListBoxBase()
43 // this destructor is required for Darwin
46 // ----------------------------------------------------------------------------
48 // ----------------------------------------------------------------------------
50 void wxListBoxBase::InsertItems(int nItems
, const wxString
*items
, int pos
)
53 for ( int n
= 0; n
< nItems
; n
++ )
58 DoInsertItems(aItems
, pos
);
62 void wxListBoxBase::Set(int nItems
, const wxString
* items
, void **clientData
)
65 for ( int n
= 0; n
< nItems
; n
++ )
70 DoSetItems(aItems
, clientData
);
73 // ----------------------------------------------------------------------------
75 // ----------------------------------------------------------------------------
77 bool wxListBoxBase::SetStringSelection(const wxString
& s
, bool select
)
79 int sel
= FindString(s
);
80 wxCHECK_MSG( sel
!= -1, FALSE
,
81 wxT("invalid string in SetStringSelection") );
83 SetSelection(sel
, select
);
88 void wxListBoxBase::DeselectAll(int itemToLeaveSelected
)
90 if ( HasMultipleSelection() )
92 wxArrayInt selections
;
93 GetSelections(selections
);
95 size_t count
= selections
.GetCount();
96 for ( size_t n
= 0; n
< count
; n
++ )
98 int item
= selections
[n
];
99 if ( item
!= itemToLeaveSelected
)
103 else // single selection
105 int sel
= GetSelection();
106 if ( sel
!= -1 && sel
!= itemToLeaveSelected
)
113 // ----------------------------------------------------------------------------
115 // ----------------------------------------------------------------------------
117 void wxListBoxBase::Command(wxCommandEvent
& event
)
119 SetSelection(event
.m_commandInt
, event
.m_extraLong
!= 0);
120 (void)ProcessEvent(event
);
123 // ----------------------------------------------------------------------------
124 // SetFirstItem() and such
125 // ----------------------------------------------------------------------------
127 void wxListBoxBase::SetFirstItem(const wxString
& s
)
129 int n
= FindString(s
);
131 wxCHECK_RET( n
!= -1, wxT("invalid string in wxListBox::SetFirstItem") );
136 void wxListBoxBase::AppendAndEnsureVisible(const wxString
& s
)
139 EnsureVisible(GetCount() - 1);
142 void wxListBoxBase::EnsureVisible(int WXUNUSED(n
))
144 // the base class version does nothing (the only alternative would be to
145 // call SetFirstItem() but this is probably even more stupid)
148 #endif // wxUSE_LISTBOX