]> git.saurik.com Git - wxWidgets.git/blob - src/common/lboxcmn.cpp
wxHtmlFilterHTML adds fake <meta> tag so that the parser knows charset
[wxWidgets.git] / src / common / lboxcmn.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: common/lboxcmn.cpp
3 // Purpose: wxListBox class methods common to all platforms
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 22.10.99
7 // RCS-ID: $Id$
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #ifdef __GNUG__
21 #pragma implementation "listboxbase.h"
22 #endif
23
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
26
27 #ifdef __BORLANDC__
28 #pragma hdrstop
29 #endif
30
31 #ifndef WX_PRECOMP
32 #include "wx/listbox.h"
33 #endif
34
35 // ============================================================================
36 // implementation
37 // ============================================================================
38
39 // ----------------------------------------------------------------------------
40 // adding items
41 // ----------------------------------------------------------------------------
42
43 void wxListBoxBase::InsertItems(int nItems, const wxString *items, int pos)
44 {
45 wxArrayString aItems;
46 for ( int n = 0; n < nItems; n++ )
47 {
48 aItems.Add(items[n]);
49 }
50
51 DoInsertItems(aItems, pos);
52 }
53
54
55 void wxListBoxBase::Set(int nItems, const wxString* items, void **clientData)
56 {
57 wxArrayString aItems;
58 for ( int n = 0; n < nItems; n++ )
59 {
60 aItems.Add(items[n]);
61 }
62
63 DoSetItems(aItems, clientData);
64 }
65
66 // ----------------------------------------------------------------------------
67 // selection
68 // ----------------------------------------------------------------------------
69
70 bool wxListBoxBase::SetStringSelection(const wxString& s, bool select)
71 {
72 int sel = FindString(s);
73 wxCHECK_MSG( sel != -1, FALSE,
74 wxT("invalid string in SetStringSelection") );
75
76 SetSelection(sel, select);
77
78 return TRUE;
79 }
80
81 // ----------------------------------------------------------------------------
82 // misc
83 // ----------------------------------------------------------------------------
84
85 void wxListBoxBase::Command(wxCommandEvent& event)
86 {
87 SetSelection(event.m_commandInt, event.m_extraLong != 0);
88 (void)ProcessEvent(event);
89 }
90
91 void wxListBoxBase::SetFirstItem(const wxString& s)
92 {
93 int n = FindString(s);
94
95 wxCHECK_RET( n != -1, wxT("invalid string in wxListBox::SetFirstItem") );
96
97 DoSetFirstItem(n);
98 }