]>
Commit | Line | Data |
---|---|---|
2bda0e17 | 1 | ///////////////////////////////////////////////////////////////////////////// |
2ee3ee1b | 2 | // Name: wx/msw/listbox.h |
2bda0e17 KB |
3 | // Purpose: wxListBox class |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
bbcdf8bc | 8 | // Copyright: (c) Julian Smart |
65571936 | 9 | // Licence: wxWindows licence |
2bda0e17 KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
bbcdf8bc JS |
12 | #ifndef _WX_LISTBOX_H_ |
13 | #define _WX_LISTBOX_H_ | |
2bda0e17 | 14 | |
12028905 | 15 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
8ee9d618 | 16 | #pragma interface "listbox.h" |
2bda0e17 KB |
17 | #endif |
18 | ||
1e6feb95 VZ |
19 | #if wxUSE_LISTBOX |
20 | ||
2ee3ee1b VZ |
21 | // ---------------------------------------------------------------------------- |
22 | // simple types | |
23 | // ---------------------------------------------------------------------------- | |
2bda0e17 | 24 | |
47d67540 | 25 | #if wxUSE_OWNER_DRAWN |
2bda0e17 KB |
26 | class WXDLLEXPORT wxOwnerDrawn; |
27 | ||
28 | // define the array of list box items | |
ace954f1 | 29 | #include "wx/dynarray.h" |
184b5d99 | 30 | |
d5d29b8a | 31 | WX_DEFINE_EXPORTED_ARRAY_PTR(wxOwnerDrawn *, wxListBoxItemsArray); |
2ee3ee1b | 32 | #endif // wxUSE_OWNER_DRAWN |
2bda0e17 | 33 | |
7f17c6db | 34 | // forward decl for GetSelections() |
446e5259 | 35 | class WXDLLIMPEXP_BASE wxArrayInt; |
7f17c6db | 36 | |
2ee3ee1b VZ |
37 | // ---------------------------------------------------------------------------- |
38 | // List box control | |
39 | // ---------------------------------------------------------------------------- | |
2bda0e17 | 40 | |
2ee3ee1b | 41 | class WXDLLEXPORT wxListBox : public wxListBoxBase |
2bda0e17 | 42 | { |
bfc6fde4 | 43 | public: |
2ee3ee1b | 44 | // ctors and such |
bfc6fde4 VZ |
45 | wxListBox(); |
46 | wxListBox(wxWindow *parent, wxWindowID id, | |
47 | const wxPoint& pos = wxDefaultPosition, | |
48 | const wxSize& size = wxDefaultSize, | |
49 | int n = 0, const wxString choices[] = NULL, | |
50 | long style = 0, | |
51 | const wxValidator& validator = wxDefaultValidator, | |
6463b9f5 JS |
52 | const wxString& name = wxListBoxNameStr) |
53 | { | |
54 | Create(parent, id, pos, size, n, choices, style, validator, name); | |
55 | } | |
584ad2a3 MB |
56 | wxListBox(wxWindow *parent, wxWindowID id, |
57 | const wxPoint& pos, | |
58 | const wxSize& size, | |
59 | const wxArrayString& choices, | |
60 | long style = 0, | |
61 | const wxValidator& validator = wxDefaultValidator, | |
62 | const wxString& name = wxListBoxNameStr) | |
63 | { | |
64 | Create(parent, id, pos, size, choices, style, validator, name); | |
65 | } | |
bfc6fde4 VZ |
66 | |
67 | bool Create(wxWindow *parent, wxWindowID id, | |
2ee3ee1b VZ |
68 | const wxPoint& pos = wxDefaultPosition, |
69 | const wxSize& size = wxDefaultSize, | |
70 | int n = 0, const wxString choices[] = NULL, | |
71 | long style = 0, | |
72 | const wxValidator& validator = wxDefaultValidator, | |
73 | const wxString& name = wxListBoxNameStr); | |
584ad2a3 MB |
74 | bool Create(wxWindow *parent, wxWindowID id, |
75 | const wxPoint& pos, | |
76 | const wxSize& size, | |
77 | const wxArrayString& choices, | |
78 | long style = 0, | |
79 | const wxValidator& validator = wxDefaultValidator, | |
80 | const wxString& name = wxListBoxNameStr); | |
bfc6fde4 | 81 | |
2ee3ee1b | 82 | virtual ~wxListBox(); |
bfc6fde4 | 83 | |
2ee3ee1b VZ |
84 | // implement base class pure virtuals |
85 | virtual void Clear(); | |
86 | virtual void Delete(int n); | |
87 | ||
88 | virtual int GetCount() const; | |
89 | virtual wxString GetString(int n) const; | |
90 | virtual void SetString(int n, const wxString& s); | |
91 | virtual int FindString(const wxString& s) const; | |
92 | ||
93 | virtual bool IsSelected(int n) const; | |
c6179a84 | 94 | virtual void DoSetSelection(int n, bool select); |
2ee3ee1b VZ |
95 | virtual int GetSelection() const; |
96 | virtual int GetSelections(wxArrayInt& aSelections) const; | |
97 | ||
98 | virtual int DoAppend(const wxString& item); | |
99 | virtual void DoInsertItems(const wxArrayString& items, int pos); | |
100 | virtual void DoSetItems(const wxArrayString& items, void **clientData); | |
2bda0e17 | 101 | |
2ee3ee1b VZ |
102 | virtual void DoSetFirstItem(int n); |
103 | ||
6c8a980f VZ |
104 | virtual void DoSetItemClientData(int n, void* clientData); |
105 | virtual void* DoGetItemClientData(int n) const; | |
106 | virtual void DoSetItemClientObject(int n, wxClientData* clientData); | |
107 | virtual wxClientData* DoGetItemClientObject(int n) const; | |
2ee3ee1b VZ |
108 | |
109 | // wxCheckListBox support | |
47d67540 | 110 | #if wxUSE_OWNER_DRAWN |
bfc6fde4 VZ |
111 | bool MSWOnMeasure(WXMEASUREITEMSTRUCT *item); |
112 | bool MSWOnDraw(WXDRAWITEMSTRUCT *item); | |
2bda0e17 | 113 | |
bfc6fde4 | 114 | // plug-in for derived classes |
2b5f62a0 | 115 | virtual wxOwnerDrawn *CreateLboxItem(size_t n); |
2bda0e17 | 116 | |
bfc6fde4 VZ |
117 | // allows to get the item and use SetXXX functions to set it's appearance |
118 | wxOwnerDrawn *GetItem(size_t n) const { return m_aItems[n]; } | |
dd3c394a VZ |
119 | |
120 | // get the index of the given item | |
121 | int GetItemIndex(wxOwnerDrawn *item) const { return m_aItems.Index(item); } | |
bfc6fde4 | 122 | #endif // wxUSE_OWNER_DRAWN |
2bda0e17 | 123 | |
2ee3ee1b VZ |
124 | // Windows-specific code to set the horizontal extent of the listbox, if |
125 | // necessary. If s is non-NULL, it's used to calculate the horizontal | |
126 | // extent. Otherwise, all strings are used. | |
bfc6fde4 | 127 | virtual void SetHorizontalExtent(const wxString& s = wxEmptyString); |
2bda0e17 | 128 | |
2ee3ee1b | 129 | // Windows callbacks |
2ee3ee1b | 130 | bool MSWCommand(WXUINT param, WXWORD id); |
2bda0e17 | 131 | |
7a69cd96 VZ |
132 | virtual wxVisualAttributes GetDefaultAttributes() const |
133 | { | |
134 | return GetClassDefaultAttributes(GetWindowVariant()); | |
135 | } | |
136 | ||
137 | static wxVisualAttributes | |
138 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL) | |
139 | { | |
140 | return GetCompositeControlsDefaultAttributes(variant); | |
141 | } | |
2bda0e17 | 142 | |
bfc6fde4 | 143 | protected: |
7a69cd96 VZ |
144 | WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; |
145 | ||
012e1eeb VZ |
146 | virtual WXHBRUSH MSWControlColor(WXHDC pDC) |
147 | { | |
148 | return MSWControlColorSolid(pDC); | |
149 | } | |
150 | ||
8ee9d618 VZ |
151 | // free memory (common part of Clear() and dtor) |
152 | void Free(); | |
153 | ||
bfc6fde4 VZ |
154 | int m_noItems; |
155 | int m_selected; | |
2bda0e17 | 156 | |
f68586e5 | 157 | virtual wxSize DoGetBestSize() const; |
b908d224 | 158 | |
47d67540 | 159 | #if wxUSE_OWNER_DRAWN |
bfc6fde4 VZ |
160 | // control items |
161 | wxListBoxItemsArray m_aItems; | |
2bda0e17 | 162 | #endif |
2ee3ee1b VZ |
163 | |
164 | private: | |
fc7a2a60 | 165 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxListBox) |
2bda0e17 KB |
166 | }; |
167 | ||
1e6feb95 VZ |
168 | #endif // wxUSE_LISTBOX |
169 | ||
2bda0e17 | 170 | #endif |
bbcdf8bc | 171 | // _WX_LISTBOX_H_ |