]>
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 |
8ee9d618 | 9 | // Licence: wxWindows licence |
2bda0e17 KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
bbcdf8bc JS |
12 | #ifndef _WX_LISTBOX_H_ |
13 | #define _WX_LISTBOX_H_ | |
2bda0e17 KB |
14 | |
15 | #ifdef __GNUG__ | |
8ee9d618 | 16 | #pragma interface "listbox.h" |
2bda0e17 KB |
17 | #endif |
18 | ||
2ee3ee1b VZ |
19 | // ---------------------------------------------------------------------------- |
20 | // simple types | |
21 | // ---------------------------------------------------------------------------- | |
2bda0e17 | 22 | |
47d67540 | 23 | #if wxUSE_OWNER_DRAWN |
2bda0e17 KB |
24 | class WXDLLEXPORT wxOwnerDrawn; |
25 | ||
26 | // define the array of list box items | |
27 | #include <wx/dynarray.h> | |
184b5d99 | 28 | |
a497618a | 29 | WX_DEFINE_EXPORTED_ARRAY(wxOwnerDrawn *, wxListBoxItemsArray); |
2ee3ee1b | 30 | #endif // wxUSE_OWNER_DRAWN |
2bda0e17 | 31 | |
7f17c6db VZ |
32 | // forward decl for GetSelections() |
33 | class wxArrayInt; | |
34 | ||
2ee3ee1b VZ |
35 | // ---------------------------------------------------------------------------- |
36 | // List box control | |
37 | // ---------------------------------------------------------------------------- | |
2bda0e17 | 38 | |
2ee3ee1b | 39 | class WXDLLEXPORT wxListBox : public wxListBoxBase |
2bda0e17 | 40 | { |
bfc6fde4 | 41 | public: |
2ee3ee1b | 42 | // ctors and such |
bfc6fde4 VZ |
43 | wxListBox(); |
44 | wxListBox(wxWindow *parent, wxWindowID id, | |
45 | const wxPoint& pos = wxDefaultPosition, | |
46 | const wxSize& size = wxDefaultSize, | |
47 | int n = 0, const wxString choices[] = NULL, | |
48 | long style = 0, | |
49 | const wxValidator& validator = wxDefaultValidator, | |
50 | const wxString& name = wxListBoxNameStr) | |
51 | { | |
52 | Create(parent, id, pos, size, n, choices, style, validator, name); | |
53 | } | |
54 | ||
55 | bool Create(wxWindow *parent, wxWindowID id, | |
2ee3ee1b VZ |
56 | const wxPoint& pos = wxDefaultPosition, |
57 | const wxSize& size = wxDefaultSize, | |
58 | int n = 0, const wxString choices[] = NULL, | |
59 | long style = 0, | |
60 | const wxValidator& validator = wxDefaultValidator, | |
61 | const wxString& name = wxListBoxNameStr); | |
bfc6fde4 | 62 | |
2ee3ee1b | 63 | virtual ~wxListBox(); |
bfc6fde4 | 64 | |
2ee3ee1b VZ |
65 | // implement base class pure virtuals |
66 | virtual void Clear(); | |
67 | virtual void Delete(int n); | |
68 | ||
69 | virtual int GetCount() const; | |
70 | virtual wxString GetString(int n) const; | |
71 | virtual void SetString(int n, const wxString& s); | |
72 | virtual int FindString(const wxString& s) const; | |
73 | ||
74 | virtual bool IsSelected(int n) const; | |
75 | virtual void SetSelection(int n, bool select = TRUE); | |
76 | virtual int GetSelection() const; | |
77 | virtual int GetSelections(wxArrayInt& aSelections) const; | |
78 | ||
79 | virtual int DoAppend(const wxString& item); | |
80 | virtual void DoInsertItems(const wxArrayString& items, int pos); | |
81 | virtual void DoSetItems(const wxArrayString& items, void **clientData); | |
2bda0e17 | 82 | |
2ee3ee1b VZ |
83 | virtual void DoSetFirstItem(int n); |
84 | ||
6c8a980f VZ |
85 | virtual void DoSetItemClientData(int n, void* clientData); |
86 | virtual void* DoGetItemClientData(int n) const; | |
87 | virtual void DoSetItemClientObject(int n, wxClientData* clientData); | |
88 | virtual wxClientData* DoGetItemClientObject(int n) const; | |
2ee3ee1b VZ |
89 | |
90 | // wxCheckListBox support | |
47d67540 | 91 | #if wxUSE_OWNER_DRAWN |
bfc6fde4 VZ |
92 | bool MSWOnMeasure(WXMEASUREITEMSTRUCT *item); |
93 | bool MSWOnDraw(WXDRAWITEMSTRUCT *item); | |
2bda0e17 | 94 | |
bfc6fde4 VZ |
95 | // plug-in for derived classes |
96 | virtual wxOwnerDrawn *CreateItem(size_t n); | |
2bda0e17 | 97 | |
bfc6fde4 VZ |
98 | // allows to get the item and use SetXXX functions to set it's appearance |
99 | wxOwnerDrawn *GetItem(size_t n) const { return m_aItems[n]; } | |
dd3c394a VZ |
100 | |
101 | // get the index of the given item | |
102 | int GetItemIndex(wxOwnerDrawn *item) const { return m_aItems.Index(item); } | |
bfc6fde4 | 103 | #endif // wxUSE_OWNER_DRAWN |
2bda0e17 | 104 | |
2ee3ee1b VZ |
105 | // Windows-specific code to set the horizontal extent of the listbox, if |
106 | // necessary. If s is non-NULL, it's used to calculate the horizontal | |
107 | // extent. Otherwise, all strings are used. | |
bfc6fde4 | 108 | virtual void SetHorizontalExtent(const wxString& s = wxEmptyString); |
2bda0e17 | 109 | |
2ee3ee1b | 110 | // Windows callbacks |
bfc6fde4 | 111 | virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, |
2ee3ee1b VZ |
112 | WXUINT message, |
113 | WXWPARAM wParam, WXLPARAM lParam); | |
114 | ||
115 | bool MSWCommand(WXUINT param, WXWORD id); | |
2bda0e17 | 116 | |
bfc6fde4 | 117 | virtual void SetupColours(); |
2bda0e17 | 118 | |
bfc6fde4 | 119 | protected: |
2ee3ee1b VZ |
120 | // do we have multiple selections? |
121 | bool HasMultipleSelection() const; | |
122 | ||
8ee9d618 VZ |
123 | // free memory (common part of Clear() and dtor) |
124 | void Free(); | |
125 | ||
bfc6fde4 VZ |
126 | int m_noItems; |
127 | int m_selected; | |
2bda0e17 | 128 | |
b908d224 VZ |
129 | virtual wxSize DoGetBestSize(); |
130 | ||
47d67540 | 131 | #if wxUSE_OWNER_DRAWN |
bfc6fde4 VZ |
132 | // control items |
133 | wxListBoxItemsArray m_aItems; | |
2bda0e17 | 134 | #endif |
2ee3ee1b VZ |
135 | |
136 | private: | |
137 | DECLARE_DYNAMIC_CLASS(wxListBox) | |
2bda0e17 KB |
138 | }; |
139 | ||
140 | #endif | |
bbcdf8bc | 141 | // _WX_LISTBOX_H_ |