1 ///////////////////////////////////////////////////////////////////////////////
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "listbox.h"
16 #include "wx/listbox.h"
17 #include "wx/settings.h"
18 #include "wx/dynarray.h"
21 #if !USE_SHARED_LIBRARY
22 IMPLEMENT_DYNAMIC_CLASS(wxListBox
, wxControl
)
25 // ============================================================================
26 // list box control implementation
27 // ============================================================================
30 wxListBox
::wxListBox()
36 bool wxListBox
::Create(wxWindow
*parent
, wxWindowID id
,
39 int n
, const wxString choices
[],
41 const wxValidator
& validator
,
48 SetValidator(validator
);
50 if (parent
) parent
->AddChild(this);
52 wxSystemSettings settings
;
53 SetBackgroundColour(wxSystemSettings
::GetSystemColour(wxSYS_COLOUR_WINDOW
));
55 m_windowId
= ( id
== -1 ) ?
(int)NewControlId() : id
;
57 // TODO create listbox
62 wxListBox
::~wxListBox()
66 void wxListBox
::SetFirstItem(int N
)
71 void wxListBox
::SetFirstItem(const wxString
& s
)
76 void wxListBox
::Delete(int N
)
82 void wxListBox
::Append(const wxString
& item
)
89 void wxListBox
::Append(const wxString
& item
, char *Client_data
)
96 void wxListBox
::Set(int n
, const wxString
*choices
, char** clientData
)
103 int wxListBox
::FindString(const wxString
& s
) const
109 void wxListBox
::Clear()
115 void wxListBox
::SetSelection(int N
, bool select
)
120 bool wxListBox
::Selected(int N
) const
126 void wxListBox
::Deselect(int N
)
131 char *wxListBox
::GetClientData(int N
) const
137 void wxListBox
::SetClientData(int N
, char *Client_data
)
142 // Return number of selections and an array of selected integers
143 int wxListBox
::GetSelections(wxArrayInt
& aSelections
) const
148 if ((m_windowStyle & wxLB_MULTIPLE) || (m_windowStyle & wxLB_EXTENDED))
151 for ( int n = 0; n < no_sel; n++ )
156 else // single-selection listbox
166 // Get single selection, for single choice list items
167 int wxListBox
::GetSelection() const
173 // Find string for position
174 wxString wxListBox
::GetString(int N
) const
180 void wxListBox
::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
185 void wxListBox
::InsertItems(int nItems
, const wxString items
[], int pos
)
192 void wxListBox
::SetString(int N
, const wxString
& s
)
197 int wxListBox
::Number () const
202 // For single selection items only
203 wxString wxListBox
::GetStringSelection () const
205 int sel
= GetSelection ();
207 return this->GetString (sel
);
212 bool wxListBox
::SetStringSelection (const wxString
& s
, bool flag
)
214 int sel
= FindString (s
);
217 SetSelection (sel
, flag
);
224 void wxListBox
::Command (wxCommandEvent
& event
)
226 if (event
.m_extraLong
)
227 SetSelection (event
.m_commandInt
);
230 Deselect (event
.m_commandInt
);
233 ProcessCommand (event
);