]>
git.saurik.com Git - wxWidgets.git/blob - src/common/lboxcmn.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/lboxcmn.cpp
3 // Purpose: wxListBox class methods common to all platforms
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
29 #include "wx/listbox.h"
32 #include "wx/dynarray.h"
33 #include "wx/arrstr.h"
36 // ============================================================================
38 // ============================================================================
40 wxListBoxBase::~wxListBoxBase()
42 // this destructor is required for Darwin
45 // ----------------------------------------------------------------------------
47 // ----------------------------------------------------------------------------
49 bool wxListBoxBase::SetStringSelection(const wxString
& s
, bool select
)
51 const int sel
= FindString(s
);
52 if ( sel
== wxNOT_FOUND
)
55 SetSelection(sel
, select
);
60 void wxListBoxBase::DeselectAll(int itemToLeaveSelected
)
62 if ( HasMultipleSelection() )
64 wxArrayInt selections
;
65 GetSelections(selections
);
67 size_t count
= selections
.GetCount();
68 for ( size_t n
= 0; n
< count
; n
++ )
70 int item
= selections
[n
];
71 if ( item
!= itemToLeaveSelected
)
75 else // single selection
77 int sel
= GetSelection();
78 if ( sel
!= wxNOT_FOUND
&& sel
!= itemToLeaveSelected
)
85 // ----------------------------------------------------------------------------
87 // ----------------------------------------------------------------------------
89 void wxListBoxBase::Command(wxCommandEvent
& event
)
91 SetSelection(event
.GetInt(), event
.GetExtraLong() != 0);
92 (void)ProcessEvent(event
);
95 // ----------------------------------------------------------------------------
96 // SetFirstItem() and such
97 // ----------------------------------------------------------------------------
99 void wxListBoxBase::SetFirstItem(const wxString
& s
)
101 int n
= FindString(s
);
103 wxCHECK_RET( n
!= wxNOT_FOUND
, wxT("invalid string in wxListBox::SetFirstItem") );
108 void wxListBoxBase::AppendAndEnsureVisible(const wxString
& s
)
111 EnsureVisible(GetCount() - 1);
114 void wxListBoxBase::EnsureVisible(int WXUNUSED(n
))
116 // the base class version does nothing (the only alternative would be to
117 // call SetFirstItem() but this is probably even more stupid)
120 #endif // wxUSE_LISTBOX