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 IMPLEMENT_DYNAMIC_CLASS(wxListBox
, wxControl
)
23 // ============================================================================
24 // list box control implementation
25 // ============================================================================
28 wxListBox::wxListBox()
34 bool wxListBox::Create(wxWindow
*parent
, wxWindowID id
,
37 int n
, const wxString choices
[],
39 const wxValidator
& validator
,
46 SetValidator(validator
);
48 if (parent
) parent
->AddChild(this);
50 wxSystemSettings settings
;
51 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW
));
53 m_windowId
= ( id
== -1 ) ? (int)NewControlId() : id
;
55 // TODO create listbox
60 wxListBox::~wxListBox()
64 void wxListBox::SetFirstItem(int N
)
69 void wxListBox::SetFirstItem(const wxString
& s
)
74 void wxListBox::Delete(int N
)
80 void wxListBox::Append(const wxString
& item
)
87 void wxListBox::Append(const wxString
& item
, char *Client_data
)
94 void wxListBox::Set(int n
, const wxString
*choices
, char** clientData
)
101 int wxListBox::FindString(const wxString
& s
) const
107 void wxListBox::Clear()
113 void wxListBox::SetSelection(int N
, bool select
)
118 bool wxListBox::Selected(int N
) const
124 void wxListBox::Deselect(int N
)
129 char *wxListBox::GetClientData(int N
) const
135 void wxListBox::SetClientData(int N
, char *Client_data
)
140 // Return number of selections and an array of selected integers
141 int wxListBox::GetSelections(wxArrayInt
& aSelections
) const
146 if ((m_windowStyle & wxLB_MULTIPLE) || (m_windowStyle & wxLB_EXTENDED))
149 for ( int n = 0; n < no_sel; n++ )
154 else // single-selection listbox
164 // Get single selection, for single choice list items
165 int wxListBox::GetSelection() const
171 // Find string for position
172 wxString
wxListBox::GetString(int N
) const
178 void wxListBox::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
183 void wxListBox::InsertItems(int nItems
, const wxString items
[], int pos
)
190 void wxListBox::SetString(int N
, const wxString
& s
)
195 int wxListBox::Number () const
200 // For single selection items only
201 wxString
wxListBox::GetStringSelection () const
203 int sel
= GetSelection ();
205 return this->GetString (sel
);
210 bool wxListBox::SetStringSelection (const wxString
& s
, bool flag
)
212 int sel
= FindString (s
);
215 SetSelection (sel
, flag
);
222 void wxListBox::Command (wxCommandEvent
& event
)
224 if (event
.m_extraLong
)
225 SetSelection (event
.m_commandInt
);
228 Deselect (event
.m_commandInt
);
231 ProcessCommand (event
);