1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxListBox class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_LISTBOX_H_
13 #define _WX_LISTBOX_H_
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "listbox.h"
19 #include "wx/ctrlsub.h"
20 #include "wx/clntdata.h"
22 // forward decl for GetSelections()
23 class WXDLLEXPORT wxArrayInt
;
26 class WXDLLEXPORT wxListBox
: public wxListBoxBase
28 DECLARE_DYNAMIC_CLASS(wxListBox
)
32 wxListBox(wxWindow
*parent
, wxWindowID id
,
33 const wxPoint
& pos
= wxDefaultPosition
,
34 const wxSize
& size
= wxDefaultSize
,
35 int n
= 0, const wxString choices
[] = NULL
,
37 const wxValidator
& validator
= wxDefaultValidator
,
38 const wxString
& name
= wxListBoxNameStr
)
40 Create(parent
, id
, pos
, size
, n
, choices
, style
, validator
, name
);
43 wxListBox(wxWindow
*parent
, wxWindowID id
,
46 const wxArrayString
& choices
,
48 const wxValidator
& validator
= wxDefaultValidator
,
49 const wxString
& name
= wxListBoxNameStr
)
51 Create(parent
, id
, pos
, size
, choices
, style
, validator
, name
);
54 bool Create(wxWindow
*parent
, wxWindowID id
,
55 const wxPoint
& pos
= wxDefaultPosition
,
56 const wxSize
& size
= wxDefaultSize
,
57 int n
= 0, const wxString choices
[] = NULL
,
59 const wxValidator
& validator
= wxDefaultValidator
,
60 const wxString
& name
= wxListBoxNameStr
);
62 bool Create(wxWindow
*parent
, wxWindowID id
,
65 const wxArrayString
& choices
,
67 const wxValidator
& validator
= wxDefaultValidator
,
68 const wxString
& name
= wxListBoxNameStr
);
72 // implementation of wxControlWithItems
73 virtual int GetCount() const;
74 virtual int DoAppend(const wxString
& item
);
75 virtual void DoSetItemClientData(int n
, void* clientData
);
76 virtual void* DoGetItemClientData(int n
) const;
77 virtual void DoSetItemClientObject(int n
, wxClientData
* clientData
);
78 virtual wxClientData
* DoGetItemClientObject(int n
) const;
79 virtual int GetSelection() const;
80 virtual void Delete(int n
);
81 virtual int FindString(const wxString
& s
) const;
83 virtual void SetString(int n
, const wxString
& s
);
84 virtual wxString
GetString(int n
) const;
86 // implementation of wxListBoxbase
87 virtual void SetSelection(int n
, bool select
= true);
88 virtual void DoInsertItems(const wxArrayString
& items
, int pos
);
89 virtual void DoSetItems(const wxArrayString
& items
, void **clientData
);
90 virtual void DoSetFirstItem(int n
);
91 virtual int GetSelections(wxArrayInt
& aSelections
) const;
92 virtual bool IsSelected(int n
) const;
94 // For single or multiple choice list item
95 void Command(wxCommandEvent
& event
);
98 virtual void ChangeBackgroundColour();
99 virtual void ChangeForegroundColour();
100 WXWidget
GetTopWidget() const;
102 #if wxUSE_CHECKLISTBOX
103 virtual void DoToggleItem(int item
, int x
) {};
106 virtual wxSize
DoGetBestSize() const;
110 // List mapping positions->client data
111 wxClientDataDictionary m_clientDataDict
;
113 void SetSelectionPolicy();