]>
Commit | Line | Data |
---|---|---|
0e320a79 DW |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: listbox.h | |
3 | // Purpose: wxListBox class | |
fb9010ed | 4 | // Author: David Webster |
0e320a79 | 5 | // Modified by: |
fb9010ed | 6 | // Created: 10/09/99 |
0e320a79 | 7 | // RCS-ID: $Id$ |
fb9010ed DW |
8 | // Copyright: (c) David Webster |
9 | // Licence: wxWindows licence | |
0e320a79 DW |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_LISTBOX_H_ | |
13 | #define _WX_LISTBOX_H_ | |
14 | ||
dcd307ee DW |
15 | // ---------------------------------------------------------------------------- |
16 | // simple types | |
17 | // ---------------------------------------------------------------------------- | |
0e320a79 | 18 | |
fb9010ed DW |
19 | #if wxUSE_OWNER_DRAWN |
20 | class WXDLLEXPORT wxOwnerDrawn; | |
21 | ||
22 | // define the array of list box items | |
23 | #include <wx/dynarray.h> | |
24 | ||
dcd307ee DW |
25 | WX_DEFINE_EXPORTED_ARRAY(wxOwnerDrawn *, wxListBoxItemsArray); |
26 | #endif // wxUSE_OWNER_DRAWN | |
fb9010ed | 27 | |
0e320a79 | 28 | // forward decl for GetSelections() |
dcd307ee | 29 | class wxArrayInt; |
0e320a79 | 30 | |
dcd307ee DW |
31 | // ---------------------------------------------------------------------------- |
32 | // List box control | |
33 | // ---------------------------------------------------------------------------- | |
0e320a79 | 34 | |
dcd307ee | 35 | class WXDLLEXPORT wxListBox : public wxListBoxBase |
0e320a79 | 36 | { |
dcd307ee DW |
37 | public: |
38 | // ctors and such | |
39 | wxListBox(); | |
40 | wxListBox(wxWindow *parent, wxWindowID id, | |
41 | const wxPoint& pos = wxDefaultPosition, | |
42 | const wxSize& size = wxDefaultSize, | |
43 | int n = 0, const wxString choices[] = NULL, | |
44 | long style = 0, | |
57c4d796 | 45 | #if wxUSE_VALIDATORS |
dcd307ee | 46 | const wxValidator& validator = wxDefaultValidator, |
57c4d796 | 47 | #endif |
dcd307ee DW |
48 | const wxString& name = wxListBoxNameStr) |
49 | { | |
50 | Create(parent, id, pos, size, n, choices, style, validator, name); | |
51 | } | |
52 | ||
53 | bool Create(wxWindow *parent, wxWindowID id, | |
54 | const wxPoint& pos = wxDefaultPosition, | |
55 | const wxSize& size = wxDefaultSize, | |
56 | int n = 0, const wxString choices[] = NULL, | |
57 | long style = 0, | |
57c4d796 | 58 | #if wxUSE_VALIDATORS |
dcd307ee | 59 | const wxValidator& validator = wxDefaultValidator, |
57c4d796 | 60 | #endif |
dcd307ee DW |
61 | const wxString& name = wxListBoxNameStr); |
62 | ||
63 | virtual ~wxListBox(); | |
64 | ||
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); | |
82 | ||
83 | virtual void DoSetFirstItem(int n); | |
84 | ||
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; | |
89 | ||
90 | // wxCheckListBox support | |
fb9010ed DW |
91 | #if wxUSE_OWNER_DRAWN |
92 | bool OS2OnMeasure(WXMEASUREITEMSTRUCT *item); | |
93 | bool OS2OnDraw(WXDRAWITEMSTRUCT *item); | |
94 | ||
95 | // plug-in for derived classes | |
96 | virtual wxOwnerDrawn *CreateItem(size_t n); | |
97 | ||
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]; } | |
100 | ||
101 | // get the index of the given item | |
102 | int GetItemIndex(wxOwnerDrawn *item) const { return m_aItems.Index(item); } | |
103 | #endif // wxUSE_OWNER_DRAWN | |
104 | ||
dcd307ee DW |
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. | |
fb9010ed DW |
108 | virtual void SetHorizontalExtent(const wxString& s = wxEmptyString); |
109 | ||
dcd307ee | 110 | // Windows callbacks |
fb9010ed | 111 | virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, |
dcd307ee DW |
112 | WXUINT message, |
113 | WXWPARAM wParam, WXLPARAM lParam); | |
114 | ||
115 | bool OS2Command(WXUINT param, WXWORD id); | |
fb9010ed | 116 | |
fb9010ed DW |
117 | virtual void SetupColours(); |
118 | ||
119 | protected: | |
dcd307ee DW |
120 | // do we have multiple selections? |
121 | bool HasMultipleSelection() const; | |
122 | ||
123 | int m_noItems; | |
124 | int m_selected; | |
fb9010ed | 125 | |
e78c4d50 | 126 | virtual wxSize DoGetBestSize() const; |
fb9010ed DW |
127 | |
128 | #if wxUSE_OWNER_DRAWN | |
129 | // control items | |
130 | wxListBoxItemsArray m_aItems; | |
131 | #endif | |
dcd307ee | 132 | |
fb9010ed | 133 | private: |
dcd307ee DW |
134 | #if wxUSE_WX_RESOURCES |
135 | # if wxUSE_OWNER_DRAWN | |
136 | virtual wxControl *CreateItem(const wxItemResource* childResource, | |
137 | const wxItemResource* parentResource, | |
138 | const wxResourceTable *table = (const wxResourceTable *) NULL) | |
139 | { return(wxWindowBase::CreateItem(childResource, parentResource, table)); } | |
140 | # endif | |
141 | #endif | |
142 | DECLARE_DYNAMIC_CLASS(wxListBox) | |
0e320a79 DW |
143 | }; |
144 | ||
145 | #endif | |
146 | // _WX_LISTBOX_H_ |