]>
Commit | Line | Data |
---|---|---|
0dbd6262 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: listbox.h | |
3 | // Purpose: wxListBox class | |
a31a5f85 | 4 | // Author: Stefan Csomor |
0dbd6262 | 5 | // Modified by: |
a31a5f85 | 6 | // Created: 1998-01-01 |
0dbd6262 | 7 | // RCS-ID: $Id$ |
a31a5f85 | 8 | // Copyright: (c) Stefan Csomor |
e40298d5 | 9 | // Licence: wxWindows licence |
0dbd6262 SC |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
e7549107 | 12 | |
0dbd6262 SC |
13 | #ifndef _WX_LISTBOX_H_ |
14 | #define _WX_LISTBOX_H_ | |
15 | ||
12028905 | 16 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
e7549107 | 17 | #pragma interface "listbox.h" |
0dbd6262 SC |
18 | #endif |
19 | ||
e7549107 SC |
20 | // ---------------------------------------------------------------------------- |
21 | // simple types | |
22 | // ---------------------------------------------------------------------------- | |
ed39ff57 | 23 | #include "wx/dynarray.h" |
584ad2a3 | 24 | #include "wx/arrstr.h" |
0dbd6262 | 25 | |
e7549107 SC |
26 | #if wxUSE_OWNER_DRAWN |
27 | class WXDLLEXPORT wxOwnerDrawn; | |
0dbd6262 | 28 | |
e7549107 | 29 | // define the array of list box items |
cba5db5f | 30 | #include "wx/dynarray.h" |
0dbd6262 | 31 | |
e7549107 SC |
32 | WX_DEFINE_EXPORTED_ARRAY(wxOwnerDrawn *, wxListBoxItemsArray); |
33 | #endif // wxUSE_OWNER_DRAWN | |
34 | ||
35 | // forward decl for GetSelections() | |
36 | class wxArrayInt; | |
0dbd6262 SC |
37 | |
38 | // List box item | |
519cb848 SC |
39 | |
40 | WX_DEFINE_ARRAY( char * , wxListDataArray ) ; | |
41 | ||
e7549107 SC |
42 | // ---------------------------------------------------------------------------- |
43 | // List box control | |
44 | // ---------------------------------------------------------------------------- | |
45 | ||
46 | class WXDLLEXPORT wxListBox : public wxListBoxBase | |
0dbd6262 | 47 | { |
e7549107 SC |
48 | public: |
49 | // ctors and such | |
50 | wxListBox(); | |
51 | wxListBox(wxWindow *parent, wxWindowID id, | |
52 | const wxPoint& pos = wxDefaultPosition, | |
53 | const wxSize& size = wxDefaultSize, | |
54 | int n = 0, const wxString choices[] = NULL, | |
55 | long style = 0, | |
56 | const wxValidator& validator = wxDefaultValidator, | |
57 | const wxString& name = wxListBoxNameStr) | |
58 | { | |
59 | Create(parent, id, pos, size, n, choices, style, validator, name); | |
60 | } | |
584ad2a3 MB |
61 | wxListBox(wxWindow *parent, wxWindowID id, |
62 | const wxPoint& pos, | |
63 | const wxSize& size, | |
64 | const wxArrayString& choices, | |
65 | long style = 0, | |
66 | const wxValidator& validator = wxDefaultValidator, | |
67 | const wxString& name = wxListBoxNameStr) | |
68 | { | |
69 | Create(parent, id, pos, size, choices, style, validator, name); | |
70 | } | |
e7549107 SC |
71 | |
72 | bool Create(wxWindow *parent, wxWindowID id, | |
73 | const wxPoint& pos = wxDefaultPosition, | |
74 | const wxSize& size = wxDefaultSize, | |
75 | int n = 0, const wxString choices[] = NULL, | |
76 | long style = 0, | |
77 | const wxValidator& validator = wxDefaultValidator, | |
78 | const wxString& name = wxListBoxNameStr); | |
584ad2a3 MB |
79 | bool Create(wxWindow *parent, wxWindowID id, |
80 | const wxPoint& pos, | |
81 | const wxSize& size, | |
82 | const wxArrayString& choices, | |
83 | long style = 0, | |
84 | const wxValidator& validator = wxDefaultValidator, | |
85 | const wxString& name = wxListBoxNameStr); | |
e7549107 SC |
86 | |
87 | virtual ~wxListBox(); | |
60149370 GD |
88 | virtual void Refresh(bool eraseBack = TRUE, const wxRect *rect = NULL); |
89 | ||
e7549107 SC |
90 | // implement base class pure virtuals |
91 | virtual void Clear(); | |
92 | virtual void Delete(int n); | |
93 | ||
94 | virtual int GetCount() const; | |
95 | virtual wxString GetString(int n) const; | |
96 | virtual void SetString(int n, const wxString& s); | |
97 | virtual int FindString(const wxString& s) const; | |
98 | ||
99 | virtual bool IsSelected(int n) const; | |
100 | virtual void SetSelection(int n, bool select = TRUE); | |
101 | virtual int GetSelection() const; | |
102 | virtual int GetSelections(wxArrayInt& aSelections) const; | |
103 | ||
104 | virtual int DoAppend(const wxString& item); | |
105 | virtual void DoInsertItems(const wxArrayString& items, int pos); | |
106 | virtual void DoSetItems(const wxArrayString& items, void **clientData); | |
107 | ||
108 | virtual void DoSetFirstItem(int n); | |
109 | ||
110 | virtual void DoSetItemClientData(int n, void* clientData); | |
111 | virtual void* DoGetItemClientData(int n) const; | |
112 | virtual void DoSetItemClientObject(int n, wxClientData* clientData); | |
113 | virtual wxClientData* DoGetItemClientObject(int n) const; | |
e40298d5 | 114 | virtual void DoSetSize(int x, int y,int width, int height,int sizeFlags = wxSIZE_AUTO ) ; |
e7549107 SC |
115 | |
116 | // wxCheckListBox support | |
117 | #if wxUSE_OWNER_DRAWN | |
118 | // plug-in for derived classes | |
119 | virtual wxOwnerDrawn *CreateItem(size_t n); | |
120 | ||
121 | // allows to get the item and use SetXXX functions to set it's appearance | |
122 | wxOwnerDrawn *GetItem(size_t n) const { return m_aItems[n]; } | |
123 | ||
124 | // get the index of the given item | |
125 | int GetItemIndex(wxOwnerDrawn *item) const { return m_aItems.Index(item); } | |
126 | #endif // wxUSE_OWNER_DRAWN | |
127 | ||
e7549107 SC |
128 | // Windows callbacks |
129 | ||
d84afea9 | 130 | virtual void SetupColours(); |
69b85ca4 | 131 | virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) ; |
e40298d5 | 132 | virtual bool MacCanFocus() const { return true ; } |
5fcf715b | 133 | void OnChar(wxKeyEvent& event); |
e7549107 | 134 | |
d84afea9 GD |
135 | void* m_macList ; |
136 | wxArrayString m_stringArray ; | |
137 | wxListDataArray m_dataArray ; | |
138 | wxArrayInt m_selectionPreImage ; | |
139 | void MacSetRedraw( bool doDraw ) ; | |
e7549107 | 140 | protected: |
d84afea9 GD |
141 | void MacDestroy() ; |
142 | void MacDelete( int n ) ; | |
c4e41ce3 SC |
143 | void MacInsert( int n , const wxString& item) ; |
144 | void MacAppend( const wxString& item) ; | |
145 | void MacSet( int n , const wxString& item ) ; | |
d84afea9 GD |
146 | void MacClear() ; |
147 | void MacSetSelection( int n , bool select ) ; | |
148 | int MacGetSelection() const ; | |
149 | int MacGetSelections(wxArrayInt& aSelections) const ; | |
150 | bool MacIsSelected( int n ) const ; | |
151 | void MacScrollTo( int n ) ; | |
864db5de | 152 | void OnSize( wxSizeEvent &size ) ; |
d84afea9 GD |
153 | void MacDoClick() ; |
154 | void MacDoDoubleClick() ; | |
519cb848 | 155 | |
e7549107 SC |
156 | // do we have multiple selections? |
157 | bool HasMultipleSelection() const; | |
158 | ||
159 | // free memory (common part of Clear() and dtor) | |
4b651a46 GD |
160 | // prevent collision with some BSD definitions of macro Free() |
161 | void FreeData(); | |
e7549107 SC |
162 | |
163 | int m_noItems; | |
164 | int m_selected; | |
e40298d5 JS |
165 | wxString m_typeIn ; |
166 | long m_lastTypeIn ; | |
e7549107 | 167 | |
05adb9d2 | 168 | virtual wxSize DoGetBestSize() const; |
e7549107 SC |
169 | |
170 | #if wxUSE_OWNER_DRAWN | |
171 | // control items | |
172 | wxListBoxItemsArray m_aItems; | |
173 | #endif | |
174 | ||
175 | private: | |
176 | DECLARE_DYNAMIC_CLASS(wxListBox) | |
d84afea9 | 177 | DECLARE_EVENT_TABLE() |
0dbd6262 SC |
178 | }; |
179 | ||
180 | #endif | |
181 | // _WX_LISTBOX_H_ |