]>
git.saurik.com Git - wxWidgets.git/blob - src/common/lboxcmn.cpp
8525ef810466f31e9d7805180e744611618529d8
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"
32 #include "wx/listbox.h"
35 // ============================================================================
37 // ============================================================================
39 // ----------------------------------------------------------------------------
41 // ----------------------------------------------------------------------------
43 void wxListBoxBase::InsertItems(int nItems
, const wxString
*items
, int pos
)
46 for ( int n
= 0; n
< nItems
; n
++ )
51 DoInsertItems(aItems
, pos
);
55 void wxListBoxBase::Set(int nItems
, const wxString
* items
, void **clientData
)
58 for ( int n
= 0; n
< nItems
; n
++ )
63 DoSetItems(aItems
, clientData
);
66 // ----------------------------------------------------------------------------
68 // ----------------------------------------------------------------------------
70 wxString
wxListBoxBase::GetStringSelection () const
73 int sel
= GetSelection();
80 bool wxListBoxBase::SetStringSelection(const wxString
& s
, bool select
)
82 int sel
= FindString(s
);
83 wxCHECK_MSG( sel
!= -1, FALSE
,
84 wxT("invalid string in wxListBox::SetStringSelection") );
86 SetSelection(sel
, select
);
91 // ----------------------------------------------------------------------------
93 // ----------------------------------------------------------------------------
95 void wxListBoxBase::SetClientObject(int n
, wxClientData
*data
)
97 wxASSERT_MSG( m_clientDataItemsType
!= ClientData_Void
,
98 wxT("can't have both object and void client data") );
100 wxClientData
*clientDataOld
= DoGetClientObject(n
);
102 delete clientDataOld
;
104 DoSetClientObject(n
, data
);
105 m_clientDataItemsType
= ClientData_Object
;
108 wxClientData
*wxListBoxBase::GetClientObject(int n
) const
110 wxASSERT_MSG( m_clientDataItemsType
== ClientData_Object
,
111 wxT("this window doesn't have object client data") );
113 return DoGetClientObject(n
);
116 void wxListBoxBase::SetClientData(int n
, void *data
)
118 wxASSERT_MSG( m_clientDataItemsType
!= ClientData_Object
,
119 wxT("can't have both object and void client data") );
121 DoSetClientData(n
, data
);
122 m_clientDataItemsType
= ClientData_Void
;
125 void *wxListBoxBase::GetClientData(int n
) const
127 wxASSERT_MSG( m_clientDataItemsType
== ClientData_Void
,
128 wxT("this window doesn't have void client data") );
130 return DoGetClientData(n
);
133 // ----------------------------------------------------------------------------
135 // ----------------------------------------------------------------------------
137 void wxListBoxBase::SetFirstItem(const wxString
& s
)
139 int n
= FindString(s
);
141 wxCHECK_RET( n
!= -1, wxT("invalid string in wxListBox::SetFirstItem") );
146 void wxListBoxBase::Command(wxCommandEvent
& event
)
148 SetSelection(event
.m_commandInt
, event
.m_extraLong
);
149 (void)ProcessEvent(event
);