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_
16 #pragma interface "listbox.h"
19 #include "wx/ctrlsub.h"
20 #include "wx/clntdata.h"
22 WXDLLEXPORT_DATA(extern const char*) wxListBoxNameStr
;
24 // forward decl for GetSelections()
25 class WXDLLEXPORT wxArrayInt
;
27 WXDLLEXPORT_DATA(extern const char*) wxEmptyString
;
30 class WXDLLEXPORT wxListBox
: public wxListBoxBase
32 DECLARE_DYNAMIC_CLASS(wxListBox
)
36 wxListBox(wxWindow
*parent
, wxWindowID id
,
37 const wxPoint
& pos
= wxDefaultPosition
,
38 const wxSize
& size
= wxDefaultSize
,
39 int n
= 0, const wxString choices
[] = NULL
,
41 const wxValidator
& validator
= wxDefaultValidator
,
42 const wxString
& name
= wxListBoxNameStr
)
44 Create(parent
, id
, pos
, size
, n
, choices
, style
, validator
, name
);
47 bool Create(wxWindow
*parent
, wxWindowID id
,
48 const wxPoint
& pos
= wxDefaultPosition
,
49 const wxSize
& size
= wxDefaultSize
,
50 int n
= 0, const wxString choices
[] = NULL
,
52 const wxValidator
& validator
= wxDefaultValidator
,
53 const wxString
& name
= wxListBoxNameStr
);
57 // implementation of wxControlWithItems
58 virtual int GetCount() const;
59 virtual int DoAppend(const wxString
& item
);
60 virtual void DoSetItemClientData(int n
, void* clientData
);
61 virtual void* DoGetItemClientData(int n
) const;
62 virtual void DoSetItemClientObject(int n
, wxClientData
* clientData
);
63 virtual wxClientData
* DoGetItemClientObject(int n
) const;
64 virtual int GetSelection() const;
65 virtual void Delete(int n
);
66 virtual int FindString(const wxString
& s
) const;
68 virtual void SetString(int n
, const wxString
& s
);
69 virtual wxString
GetString(int n
) const;
71 // implementation of wxListBoxbase
72 virtual void SetSelection(int n
, bool select
= TRUE
);
73 virtual void DoInsertItems(const wxArrayString
& items
, int pos
);
74 virtual void DoSetItems(const wxArrayString
& items
, void **clientData
);
75 virtual void DoSetFirstItem(int n
);
76 virtual int GetSelections(wxArrayInt
& aSelections
) const;
77 virtual bool IsSelected(int n
) const;
79 // For single or multiple choice list item
80 void Command(wxCommandEvent
& event
);
83 virtual void ChangeBackgroundColour();
84 virtual void ChangeForegroundColour();
85 WXWidget
GetTopWidget() const;
87 #if wxUSE_CHECKLISTBOX
88 virtual void DoToggleItem(int item
, int x
) {};
91 virtual wxSize
DoGetBestSize() const;
95 // List mapping positions->client data
96 wxClientDataDictionary m_clientDataDict
;
98 void SetSelectionPolicy();