]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: listctrl.h | |
3 | // Purpose: Generic list control | |
4 | // Author: Robert Roebling | |
5 | // Created: 01/02/97 | |
6 | // Id: | |
7 | // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem | |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #ifndef __LISTCTRLH_G__ | |
12 | #define __LISTCTRLH_G__ | |
13 | ||
14 | #ifdef __GNUG__ | |
0d3820b3 | 15 | #pragma interface "listctrl.h" |
c801d85f KB |
16 | #endif |
17 | ||
18 | #include "wx/defs.h" | |
19 | #include "wx/object.h" | |
20 | #include "wx/imaglist.h" | |
21 | #include "wx/control.h" | |
22 | #include "wx/timer.h" | |
ee7ee469 | 23 | #include "wx/textctrl.h" |
c801d85f KB |
24 | #include "wx/dcclient.h" |
25 | #include "wx/scrolwin.h" | |
26 | #include "wx/settings.h" | |
27 | ||
28 | //----------------------------------------------------------------------------- | |
29 | // classes | |
30 | //----------------------------------------------------------------------------- | |
31 | ||
32 | class wxListItem; | |
33 | class wxListEvent; | |
34 | class wxListCtrl; | |
35 | ||
36 | //----------------------------------------------------------------------------- | |
37 | // internal classes | |
38 | //----------------------------------------------------------------------------- | |
39 | ||
40 | class wxListHeaderData; | |
41 | class wxListItemData; | |
42 | class wxListLineData; | |
43 | ||
44 | class wxListHeaderWindow; | |
45 | class wxListMainWindow; | |
46 | ||
47 | class wxListRenameTimer; | |
48 | //class wxListTextCtrl; | |
49 | ||
50 | //----------------------------------------------------------------------------- | |
51 | // types | |
52 | //----------------------------------------------------------------------------- | |
53 | ||
54 | // type of compare function for wxListCtrl sort operation | |
debe6624 | 55 | typedef int (*wxListCtrlCompare)(long item1, long item2, long sortData); |
c801d85f KB |
56 | |
57 | //----------------------------------------------------------------------------- | |
58 | // wxListCtrl flags | |
59 | //----------------------------------------------------------------------------- | |
60 | ||
61 | #define wxLC_ICON 0x0004 | |
62 | #define wxLC_SMALL_ICON 0x0008 | |
63 | #define wxLC_LIST 0x0010 | |
64 | #define wxLC_REPORT 0x0020 | |
65 | #define wxLC_ALIGN_TOP 0x0040 | |
66 | #define wxLC_ALIGN_LEFT 0x0080 | |
67 | #define wxLC_AUTOARRANGE 0x0100 // not supported in wxGLC | |
68 | #define wxLC_USER_TEXT 0x0200 // not supported in wxGLC (how does it work?) | |
69 | #define wxLC_EDIT_LABELS 0x0400 | |
70 | #define wxLC_NO_HEADER 0x0800 // not supported in wxGLC | |
71 | #define wxLC_NO_SORT_HEADER 0x1000 // not supported in wxGLC | |
72 | #define wxLC_SINGLE_SEL 0x2000 | |
a3622daa | 73 | #define wxLC_SORT_ASCENDING 0x4000 |
c801d85f KB |
74 | #define wxLC_SORT_DESCENDING 0x8000 // not supported in wxGLC |
75 | ||
76 | #define wxLC_MASK_TYPE (wxLC_ICON | wxLC_SMALL_ICON | wxLC_LIST | wxLC_REPORT) | |
77 | #define wxLC_MASK_ALIGN (wxLC_ALIGN_TOP | wxLC_ALIGN_LEFT) | |
78 | #define wxLC_MASK_SORT (wxLC_SORT_ASCENDING | wxLC_SORT_DESCENDING) | |
79 | ||
80 | // Omitted because (a) too much detail (b) not enough style flags | |
81 | // #define wxLC_NO_SCROLL | |
82 | // #define wxLC_NO_LABEL_WRAP | |
83 | // #define wxLC_OWNERDRAW_FIXED | |
84 | // #define wxLC_SHOW_SEL_ALWAYS | |
85 | ||
86 | // Mask flags to tell app/GUI what fields of wxListItem are valid | |
87 | #define wxLIST_MASK_STATE 0x0001 | |
88 | #define wxLIST_MASK_TEXT 0x0002 | |
89 | #define wxLIST_MASK_IMAGE 0x0004 | |
90 | #define wxLIST_MASK_DATA 0x0008 | |
91 | #define wxLIST_SET_ITEM 0x0010 | |
92 | #define wxLIST_MASK_WIDTH 0x0020 | |
93 | #define wxLIST_MASK_FORMAT 0x0040 | |
94 | ||
95 | // State flags for indicating the state of an item | |
96 | #define wxLIST_STATE_DONTCARE 0x0000 | |
97 | #define wxLIST_STATE_DROPHILITED 0x0001 // not supported in wxGLC | |
98 | #define wxLIST_STATE_FOCUSED 0x0002 | |
a3622daa | 99 | #define wxLIST_STATE_SELECTED 0x0004 |
c801d85f KB |
100 | #define wxLIST_STATE_CUT 0x0008 // not supported in wxGLC |
101 | ||
102 | // Hit test flags, used in HitTest // wxGLC suppots 20 and 80 | |
103 | #define wxLIST_HITTEST_ABOVE 0x0001 // Above the client area. | |
104 | #define wxLIST_HITTEST_BELOW 0x0002 // Below the client area. | |
105 | #define wxLIST_HITTEST_NOWHERE 0x0004 // In the client area but below the last item. | |
106 | #define wxLIST_HITTEST_ONITEMICON 0x0020 // On the bitmap associated with an item. | |
107 | #define wxLIST_HITTEST_ONITEMLABEL 0x0080 // On the label (string) associated with an item. | |
108 | #define wxLIST_HITTEST_ONITEMRIGHT 0x0100 // In the area to the right of an item. | |
109 | #define wxLIST_HITTEST_ONITEMSTATEICON 0x0200 // On the state icon for a tree view item that is in a user-defined state. | |
110 | #define wxLIST_HITTEST_TOLEFT 0x0400 // To the right of the client area. | |
111 | #define wxLIST_HITTEST_TORIGHT 0x0800 // To the left of the client area. | |
112 | ||
113 | #define wxLIST_HITTEST_ONITEM (wxLIST_HITTEST_ONITEMICON | wxLIST_HITTEST_ONITEMLABEL | wxLIST_HITTEST_ONITEMSTATEICON) | |
114 | ||
115 | ||
116 | ||
117 | // Flags for GetNextItem // always wxLIST_NEXT_ALL in wxGLC | |
118 | enum { | |
119 | wxLIST_NEXT_ABOVE, // Searches for an item above the specified item | |
120 | wxLIST_NEXT_ALL, // Searches for subsequent item by index | |
121 | wxLIST_NEXT_BELOW, // Searches for an item below the specified item | |
122 | wxLIST_NEXT_LEFT, // Searches for an item to the left of the specified item | |
a3622daa | 123 | wxLIST_NEXT_RIGHT // Searches for an item to the right of the specified item |
c801d85f KB |
124 | }; |
125 | ||
126 | // Alignment flags for Arrange // always wxLIST_ALIGN_LEFT in wxGLC | |
127 | enum { | |
128 | wxLIST_ALIGN_DEFAULT, | |
129 | wxLIST_ALIGN_LEFT, | |
130 | wxLIST_ALIGN_TOP, | |
131 | wxLIST_ALIGN_SNAP_TO_GRID | |
132 | }; | |
133 | ||
134 | // Column format // always wxLIST_FORMAT_LEFT in wxGLC | |
135 | enum { | |
136 | wxLIST_FORMAT_LEFT, | |
137 | wxLIST_FORMAT_RIGHT, | |
138 | wxLIST_FORMAT_CENTRE, | |
139 | wxLIST_FORMAT_CENTER = wxLIST_FORMAT_CENTRE | |
140 | }; | |
141 | ||
142 | // Autosize values for SetColumnWidth | |
143 | enum { | |
144 | wxLIST_AUTOSIZE = -1, // always 80 in wxGLC (what else?) | |
145 | wxLIST_AUTOSIZE_USEHEADER = -2 | |
146 | }; | |
147 | ||
148 | // Flag values for GetItemRect | |
149 | enum { | |
150 | wxLIST_RECT_BOUNDS, | |
151 | wxLIST_RECT_ICON, | |
152 | wxLIST_RECT_LABEL | |
153 | }; | |
154 | ||
155 | // Flag values for FindItem // not supported by wxGLC | |
156 | enum { | |
157 | wxLIST_FIND_UP, | |
158 | wxLIST_FIND_DOWN, | |
159 | wxLIST_FIND_LEFT, | |
160 | wxLIST_FIND_RIGHT | |
161 | }; | |
162 | ||
c801d85f KB |
163 | //----------------------------------------------------------------------------- |
164 | // wxListItem | |
165 | //----------------------------------------------------------------------------- | |
166 | ||
167 | class wxListItem: public wxObject | |
168 | { | |
169 | DECLARE_DYNAMIC_CLASS(wxListItem) | |
170 | ||
171 | public: | |
172 | long m_mask; // Indicates what fields are valid | |
173 | long m_itemId; // The zero-based item position | |
174 | int m_col; // Zero-based column, if in report mode | |
175 | long m_state; // The state of the item | |
176 | long m_stateMask; // Which flags of m_state are valid (uses same flags) | |
177 | wxString m_text; // The label/header text | |
178 | int m_image; // The zero-based index into an image list | |
179 | long m_data; // App-defined data | |
180 | wxColour *m_colour; // only wxGLC, not supported by Windows ;-> | |
181 | ||
182 | // For columns only | |
183 | int m_format; // left, right, centre | |
184 | int m_width; // width of column | |
185 | ||
186 | wxListItem(void); | |
187 | }; | |
188 | ||
189 | //----------------------------------------------------------------------------- | |
190 | // wxListEvent | |
191 | //----------------------------------------------------------------------------- | |
192 | ||
92976ab6 | 193 | class WXDLLEXPORT wxListEvent: public wxNotifyEvent |
c801d85f KB |
194 | { |
195 | DECLARE_DYNAMIC_CLASS(wxListEvent) | |
196 | ||
197 | public: | |
64693098 | 198 | wxListEvent(wxEventType commandType = wxEVT_NULL, int id = 0); |
c801d85f KB |
199 | |
200 | int m_code; | |
201 | long m_itemIndex; | |
202 | long m_oldItemIndex; | |
203 | int m_col; | |
204 | bool m_cancelled; | |
205 | wxPoint m_pointDrag; | |
206 | ||
207 | wxListItem m_item; | |
208 | }; | |
209 | ||
210 | typedef void (wxEvtHandler::*wxListEventFunction)(wxListEvent&); | |
211 | ||
c67daf87 UR |
212 | #define EVT_LIST_BEGIN_DRAG(id, fn) { wxEVT_COMMAND_LIST_BEGIN_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL }, |
213 | #define EVT_LIST_BEGIN_RDRAG(id, fn) { wxEVT_COMMAND_LIST_BEGIN_RDRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL }, | |
214 | #define EVT_LIST_BEGIN_LABEL_EDIT(id, fn) { wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL }, | |
215 | #define EVT_LIST_END_LABEL_EDIT(id, fn) { wxEVT_COMMAND_LIST_END_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL }, | |
216 | #define EVT_LIST_DELETE_ITEM(id, fn) { wxEVT_COMMAND_LIST_DELETE_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL }, | |
217 | #define EVT_LIST_DELETE_ALL_ITEMS(id, fn) { wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL }, | |
218 | #define EVT_LIST_GET_INFO(id, fn) { wxEVT_COMMAND_LIST_GET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL }, | |
219 | #define EVT_LIST_SET_INFO(id, fn) { wxEVT_COMMAND_LIST_SET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL }, | |
220 | #define EVT_LIST_ITEM_SELECTED(id, fn) { wxEVT_COMMAND_LIST_ITEM_SELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL }, | |
221 | #define EVT_LIST_ITEM_DESELECTED(id, fn) { wxEVT_COMMAND_LIST_ITEM_DESELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL }, | |
222 | #define EVT_LIST_KEY_DOWN(id, fn) { wxEVT_COMMAND_LIST_KEY_DOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL }, | |
223 | #define EVT_LIST_INSERT_ITEM(id, fn) { wxEVT_COMMAND_LIST_INSERT_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL }, | |
224 | #define EVT_LIST_COL_CLICK(id, fn) { wxEVT_COMMAND_LIST_COL_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL }, | |
92976ab6 RR |
225 | #define EVT_LIST_ITEM_RIGHT_CLICK(id, fn) { wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL }, |
226 | #define EVT_LIST_ITEM_MIDDLE_CLICK(id, fn) { wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL }, | |
c801d85f KB |
227 | |
228 | //----------------------------------------------------------------------------- | |
229 | // wxListItemData (internal) | |
230 | //----------------------------------------------------------------------------- | |
231 | ||
232 | class wxListItemData : public wxObject | |
233 | { | |
234 | DECLARE_DYNAMIC_CLASS(wxListItemData); | |
235 | ||
0208334d | 236 | public: |
c801d85f KB |
237 | wxString m_text; |
238 | int m_image; | |
239 | long m_data; | |
240 | int m_xpos,m_ypos; | |
241 | int m_width,m_height; | |
242 | wxColour *m_colour; | |
a3622daa | 243 | |
c801d85f KB |
244 | public: |
245 | wxListItemData(void); | |
246 | wxListItemData( const wxListItem &info ); | |
247 | void SetItem( const wxListItem &info ); | |
248 | void SetText( const wxString &s ); | |
debe6624 JS |
249 | void SetImage( int image ); |
250 | void SetData( long data ); | |
251 | void SetPosition( int x, int y ); | |
252 | void SetSize( int width, int height ); | |
c801d85f KB |
253 | void SetColour( wxColour *col ); |
254 | bool HasImage(void) const; | |
255 | bool HasText(void) const; | |
debe6624 | 256 | bool IsHit( int x, int y ) const; |
c801d85f KB |
257 | void GetText( wxString &s ); |
258 | int GetX( void ) const; | |
259 | int GetY( void ) const; | |
260 | int GetWidth(void) const; | |
261 | int GetHeight(void) const; | |
262 | int GetImage(void) const; | |
263 | void GetItem( wxListItem &info ); | |
264 | wxColour *GetColour(void); | |
265 | }; | |
266 | ||
267 | //----------------------------------------------------------------------------- | |
268 | // wxListHeaderData (internal) | |
269 | //----------------------------------------------------------------------------- | |
270 | ||
271 | class wxListHeaderData : public wxObject | |
272 | { | |
273 | DECLARE_DYNAMIC_CLASS(wxListHeaderData); | |
274 | ||
275 | protected: | |
276 | long m_mask; | |
277 | int m_image; | |
278 | wxString m_text; | |
279 | int m_format; | |
280 | int m_width; | |
281 | int m_xpos,m_ypos; | |
282 | int m_height; | |
a3622daa | 283 | |
c801d85f KB |
284 | public: |
285 | wxListHeaderData(void); | |
286 | wxListHeaderData( const wxListItem &info ); | |
287 | void SetItem( const wxListItem &item ); | |
debe6624 JS |
288 | void SetPosition( int x, int y ); |
289 | void SetWidth( int w ); | |
290 | void SetFormat( int format ); | |
291 | void SetHeight( int h ); | |
c801d85f KB |
292 | bool HasImage(void) const; |
293 | bool HasText(void) const; | |
debe6624 | 294 | bool IsHit( int x, int y ) const; |
c801d85f KB |
295 | void GetItem( wxListItem &item ); |
296 | void GetText( wxString &s ); | |
297 | int GetImage(void) const; | |
298 | int GetWidth(void) const; | |
299 | int GetFormat(void) const; | |
300 | }; | |
301 | ||
302 | //----------------------------------------------------------------------------- | |
303 | // wxListLineData (internal) | |
304 | //----------------------------------------------------------------------------- | |
305 | ||
306 | class wxListLineData : public wxObject | |
307 | { | |
308 | DECLARE_DYNAMIC_CLASS(wxListLineData); | |
309 | ||
0208334d | 310 | public: |
c801d85f KB |
311 | wxList m_items; |
312 | wxRectangle m_bound_all; | |
313 | wxRectangle m_bound_label; | |
314 | wxRectangle m_bound_icon; | |
315 | wxRectangle m_bound_hilight; | |
316 | int m_mode; | |
317 | bool m_hilighted; | |
318 | wxBrush *m_hilightBrush; | |
319 | int m_spacing; | |
320 | wxListMainWindow *m_owner; | |
321 | ||
debe6624 | 322 | void DoDraw( wxPaintDC *dc, bool hilight, bool paintBG ); |
c801d85f KB |
323 | |
324 | public: | |
325 | wxListLineData( void ) {}; | |
debe6624 JS |
326 | wxListLineData( wxListMainWindow *owner, int mode, wxBrush *hilightBrush ); |
327 | void CalculateSize( wxPaintDC *dc, int spacing ); | |
328 | void SetPosition( wxPaintDC *dc, int x, int y, int window_width ); | |
329 | void SetColumnPosition( int index, int x ); | |
c801d85f KB |
330 | void GetSize( int &width, int &height ); |
331 | void GetExtent( int &x, int &y, int &width, int &height ); | |
332 | void GetLabelExtent( int &x, int &y, int &width, int &height ); | |
debe6624 JS |
333 | long IsHit( int x, int y ); |
334 | void InitItems( int num ); | |
335 | void SetItem( int index, const wxListItem &info ); | |
336 | void GetItem( int index, wxListItem &info ); | |
337 | void GetText( int index, wxString &s ); | |
338 | void SetText( int index, const wxString s ); | |
339 | int GetImage( int index ); | |
c801d85f | 340 | void GetRect( wxRectangle &rect ); |
debe6624 | 341 | void Hilight( bool on ); |
c801d85f | 342 | void ReverseHilight( void ); |
debe6624 | 343 | void DrawRubberBand( wxPaintDC *dc, bool on ); |
c801d85f | 344 | void Draw( wxPaintDC *dc ); |
debe6624 | 345 | bool IsInRect( int x, int y, const wxRectangle &rect ); |
c801d85f | 346 | bool IsHilighted( void ); |
debe6624 | 347 | void AssignRect( wxRectangle &dest, int x, int y, int width, int height ); |
c801d85f KB |
348 | void AssignRect( wxRectangle &dest, const wxRectangle &source ); |
349 | }; | |
350 | ||
351 | //----------------------------------------------------------------------------- | |
352 | // wxListHeaderWindow (internal) | |
353 | //----------------------------------------------------------------------------- | |
354 | ||
355 | class wxListHeaderWindow : public wxWindow | |
356 | { | |
357 | DECLARE_DYNAMIC_CLASS(wxListHeaderWindow) | |
358 | ||
359 | protected: | |
360 | wxListMainWindow *m_owner; | |
361 | wxCursor *m_currentCursor; | |
362 | wxCursor *m_resizeCursor; | |
0208334d RR |
363 | bool m_isDraging; |
364 | int m_column; | |
365 | int m_minX; | |
366 | int m_currentX; | |
c801d85f KB |
367 | |
368 | public: | |
369 | wxListHeaderWindow( void ); | |
a367b9b3 | 370 | ~wxListHeaderWindow( void ); |
a3622daa | 371 | wxListHeaderWindow( wxWindow *win, wxWindowID id, wxListMainWindow *owner, |
debe6624 JS |
372 | const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, |
373 | long style = 0, const wxString &name = "columntitles" ); | |
c801d85f KB |
374 | void DoDrawRect( wxPaintDC *dc, int x, int y, int w, int h ); |
375 | void OnPaint( wxPaintEvent &event ); | |
0208334d | 376 | void DrawCurrent(); |
c801d85f KB |
377 | void OnMouse( wxMouseEvent &event ); |
378 | void OnSetFocus( wxFocusEvent &event ); | |
a3622daa | 379 | |
c801d85f KB |
380 | DECLARE_EVENT_TABLE() |
381 | }; | |
382 | ||
383 | //----------------------------------------------------------------------------- | |
384 | // wxListRenameTimer (internal) | |
385 | //----------------------------------------------------------------------------- | |
386 | ||
387 | class wxListRenameTimer: public wxTimer | |
388 | { | |
389 | private: | |
390 | wxListMainWindow *m_owner; | |
a3622daa | 391 | |
c801d85f KB |
392 | public: |
393 | wxListRenameTimer( wxListMainWindow *owner ); | |
394 | void Notify(); | |
395 | }; | |
396 | ||
c801d85f KB |
397 | //----------------------------------------------------------------------------- |
398 | // wxListTextCtrl (internal) | |
399 | //----------------------------------------------------------------------------- | |
400 | ||
401 | class wxListTextCtrl: public wxTextCtrl | |
402 | { | |
403 | DECLARE_DYNAMIC_CLASS(wxListTextCtrl); | |
a3622daa | 404 | |
c801d85f KB |
405 | private: |
406 | bool *m_accept; | |
407 | wxString *m_res; | |
408 | wxListMainWindow *m_owner; | |
409 | ||
410 | public: | |
ee7ee469 RR |
411 | wxListTextCtrl(void) {}; |
412 | wxListTextCtrl( wxWindow *parent, const wxWindowID id, | |
413 | bool *accept, wxString *res, wxListMainWindow *owner, | |
414 | const wxString &value = "", | |
415 | const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, | |
416 | int style = 0, const wxValidator& validator = wxDefaultValidator, | |
417 | const wxString &name = "wxListTextCtrlText" ); | |
418 | void OnChar( wxKeyEvent &event ); | |
419 | void OnKillFocus( wxFocusEvent &event ); | |
420 | ||
421 | DECLARE_EVENT_TABLE() | |
c801d85f KB |
422 | }; |
423 | ||
c801d85f KB |
424 | //----------------------------------------------------------------------------- |
425 | // wxListMainWindow (internal) | |
426 | //----------------------------------------------------------------------------- | |
427 | ||
428 | class wxListMainWindow: public wxScrolledWindow | |
429 | { | |
430 | DECLARE_DYNAMIC_CLASS(wxListMainWindow); | |
431 | ||
432 | public: | |
433 | long m_mode; | |
434 | wxList m_lines; | |
a3622daa | 435 | wxList m_columns; |
c801d85f KB |
436 | wxListLineData *m_current; |
437 | int m_visibleLines; | |
438 | wxBrush *m_hilightBrush; | |
439 | wxColour *m_hilightColour; | |
c801d85f KB |
440 | int m_xScroll,m_yScroll; |
441 | bool m_dirty; | |
442 | wxImageList *m_small_image_list; | |
443 | wxImageList *m_normal_image_list; | |
444 | int m_small_spacing; | |
445 | int m_normal_spacing; | |
446 | bool m_hasFocus; | |
447 | bool m_usedKeys; | |
448 | bool m_lastOnSame; | |
449 | wxTimer *m_renameTimer; | |
450 | // wxListTextCtrl *m_text; | |
451 | bool m_renameAccept; | |
452 | wxString m_renameRes; | |
453 | bool m_isCreated; | |
e3e65dac | 454 | int m_dragCount; |
c801d85f KB |
455 | |
456 | public: | |
a3622daa VZ |
457 | wxListMainWindow(void); |
458 | wxListMainWindow( wxWindow *parent, wxWindowID id, | |
debe6624 JS |
459 | const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, |
460 | long style = 0, const wxString &name = "listctrl" ); | |
c801d85f KB |
461 | ~wxListMainWindow(void); |
462 | void RefreshLine( wxListLineData *line ); | |
463 | void OnPaint( wxPaintEvent &event ); | |
debe6624 | 464 | void HilightAll( bool on ); |
64693098 | 465 | void SendNotify( wxListLineData *line, wxEventType command ); |
c801d85f KB |
466 | void FocusLine( wxListLineData *line ); |
467 | void UnfocusLine( wxListLineData *line ); | |
468 | void SelectLine( wxListLineData *line ); | |
469 | void DeselectLine( wxListLineData *line ); | |
470 | void DeleteLine( wxListLineData *line ); | |
471 | void RenameLine( wxListLineData *line, const wxString &newName ); | |
ee7ee469 | 472 | void StartLabelEdit( wxListLineData *line ); |
c801d85f KB |
473 | void OnRenameTimer(void); |
474 | void OnRenameAccept(void); | |
475 | void OnMouse( wxMouseEvent &event ); | |
476 | void MoveToFocus( void ); | |
477 | void OnArrowChar( wxListLineData *newCurrent, bool shiftDown ); | |
478 | void OnChar( wxKeyEvent &event ); | |
479 | void OnSetFocus( wxFocusEvent &event ); | |
480 | void OnKillFocus( wxFocusEvent &event ); | |
481 | void OnSize( wxSizeEvent &event ); | |
c801d85f KB |
482 | void DrawImage( int index, wxPaintDC *dc, int x, int y ); |
483 | void GetImageSize( int index, int &width, int &height ); | |
484 | int GetIndexOfLine( const wxListLineData *line ); | |
485 | int GetTextLength( wxString &s ); // should be const | |
486 | ||
debe6624 JS |
487 | void SetImageList( wxImageList *imageList, int which ); |
488 | void SetItemSpacing( int spacing, bool isSmall = FALSE ); | |
489 | int GetItemSpacing( bool isSmall = FALSE ); | |
490 | void SetColumn( int col, wxListItem &item ); | |
491 | void SetColumnWidth( int col, int width ); | |
492 | void GetColumn( int col, wxListItem &item ); | |
493 | int GetColumnWidth( int vol ); | |
c801d85f | 494 | int GetColumnCount( void ); |
a3622daa | 495 | int GetCountPerPage( void ); |
c801d85f KB |
496 | void SetItem( wxListItem &item ); |
497 | void GetItem( wxListItem &item ); | |
a3622daa | 498 | void SetItemState( long item, long state, long stateMask ); |
debe6624 | 499 | int GetItemState( long item, long stateMask ); |
c801d85f | 500 | int GetItemCount( void ); |
debe6624 | 501 | void GetItemRect( long index, wxRectangle &rect ); |
e3e65dac | 502 | bool GetItemPosition(long item, wxPoint& pos); |
c801d85f | 503 | int GetSelectedItemCount( void ); |
debe6624 | 504 | void SetMode( long mode ); |
c801d85f KB |
505 | long GetMode( void ) const; |
506 | void CalculatePositions( void ); | |
507 | void RealizeChanges(void); | |
debe6624 JS |
508 | long GetNextItem( long item, int geometry, int state ); |
509 | void DeleteItem( long index ); | |
c801d85f | 510 | void DeleteAllItems( void ); |
debe6624 | 511 | void DeleteColumn( int col ); |
c801d85f | 512 | void DeleteEverything( void ); |
debe6624 JS |
513 | void EnsureVisible( long index ); |
514 | long FindItem(long start, const wxString& str, bool partial = FALSE ); | |
515 | long FindItem(long start, long data); | |
516 | long HitTest( int x, int y, int &flags ); | |
c801d85f | 517 | void InsertItem( wxListItem &item ); |
30dea054 | 518 | // void AddItem( wxListItem &item ); |
debe6624 | 519 | void InsertColumn( long col, wxListItem &item ); |
30dea054 | 520 | // void AddColumn( wxListItem &item ); |
c801d85f | 521 | void SortItems( wxListCtrlCompare fn, long data ); |
a3622daa | 522 | |
c801d85f KB |
523 | DECLARE_EVENT_TABLE() |
524 | }; | |
525 | ||
526 | //----------------------------------------------------------------------------- | |
527 | // wxListCtrl | |
528 | //----------------------------------------------------------------------------- | |
529 | ||
530 | class wxListCtrl: public wxControl | |
531 | { | |
532 | DECLARE_DYNAMIC_CLASS(wxListCtrl); | |
a3622daa | 533 | |
c801d85f | 534 | public: |
a3622daa | 535 | |
c801d85f | 536 | wxListCtrl(void); |
32e9da8b | 537 | wxListCtrl( wxWindow *parent, wxWindowID id = -1, |
debe6624 | 538 | const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, |
32e9da8b RR |
539 | long style = wxLC_ICON, const wxValidator& validator = wxDefaultValidator, |
540 | const wxString &name = "listctrl" ) | |
541 | { | |
542 | Create(parent, id, pos, size, style, validator, name); | |
543 | } | |
c801d85f | 544 | ~wxListCtrl(void); |
32e9da8b | 545 | bool Create( wxWindow *parent, wxWindowID id = -1, |
debe6624 | 546 | const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, |
32e9da8b RR |
547 | long style = wxLC_ICON, const wxValidator& validator = wxDefaultValidator, |
548 | const wxString &name = "listctrl" ); | |
c801d85f | 549 | void OnSize( wxSizeEvent &event ); |
e487524e | 550 | bool GetColumn( int col, wxListItem& item ) const; |
debe6624 | 551 | bool SetColumn( int col, wxListItem& item ); |
e487524e | 552 | int GetColumnWidth( int col ) const; |
debe6624 | 553 | bool SetColumnWidth( int col, int width); |
e487524e | 554 | int GetCountPerPage(void) const; // not the same in wxGLC as in Windows, I think |
c801d85f | 555 | // wxText& GetEditControl(void) const; // not supported in wxGLC |
e487524e | 556 | bool GetItem( wxListItem& info ) const; |
c801d85f | 557 | bool SetItem( wxListItem& info ) ; |
debe6624 | 558 | long SetItem( long index, int col, const wxString& label, int imageId = -1 ); |
e487524e | 559 | int GetItemState( long item, long stateMask ) const; |
debe6624 JS |
560 | bool SetItemState( long item, long state, long stateMask); |
561 | bool SetItemImage( long item, int image, int selImage); | |
e487524e | 562 | wxString GetItemText( long item ) const; |
debe6624 | 563 | void SetItemText( long item, const wxString& str ); |
e487524e | 564 | long GetItemData( long item ) const; |
debe6624 | 565 | bool SetItemData( long item, long data ); |
e487524e RR |
566 | bool GetItemRect( long item, wxRectangle& rect, int code = wxLIST_RECT_BOUNDS ) const; |
567 | bool GetItemPosition( long item, wxPoint& pos ) const; | |
debe6624 | 568 | bool SetItemPosition( long item, const wxPoint& pos ); // not supported in wxGLC |
e487524e | 569 | int GetItemCount(void) const; |
92976ab6 | 570 | int GetColumnCount(void) const; |
33d0b396 | 571 | void SetItemSpacing( int spacing, bool isSmall = FALSE ); |
e487524e RR |
572 | int GetItemSpacing( bool isSmall ) const; |
573 | int GetSelectedItemCount(void) const; | |
c801d85f KB |
574 | // wxColour GetTextColour(void) const; // wxGLC has colours for every Item (see wxListItem) |
575 | // void SetTextColour(const wxColour& col); | |
e487524e | 576 | long GetTopItem(void) const; |
debe6624 JS |
577 | void SetSingleStyle( long style, bool add = TRUE ) ; |
578 | void SetWindowStyleFlag(long style); | |
c801d85f | 579 | void RecreateWindow(void) {}; |
6de97a3b | 580 | long GetNextItem(long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE) const; |
e487524e | 581 | wxImageList *GetImageList(int which) const; |
debe6624 JS |
582 | void SetImageList(wxImageList *imageList, int which) ; |
583 | bool Arrange( int flag = wxLIST_ALIGN_DEFAULT ); // always wxLIST_ALIGN_LEFT in wxGLC | |
584 | bool DeleteItem( long item ); | |
c801d85f | 585 | bool DeleteAllItems(void) ; |
bd8289c1 | 586 | void DeleteAllColumns(void) ; |
debe6624 JS |
587 | bool DeleteColumn( int col ); |
588 | // wxText& Edit(long item) ; // not supported in wxGLC | |
589 | bool EnsureVisible( long item ); | |
590 | long FindItem(long start, const wxString& str, bool partial = FALSE ); | |
591 | long FindItem(long start, long data); | |
592 | long FindItem(long start, const wxPoint& pt, int direction); // not supported in wxGLC | |
c801d85f KB |
593 | long HitTest(const wxPoint& point, int& flags); |
594 | long InsertItem(wxListItem& info); | |
debe6624 JS |
595 | long InsertItem(long index, const wxString& label); |
596 | long InsertItem(long index, int imageIndex); | |
597 | long InsertItem(long index, const wxString& label, int imageIndex); | |
598 | long InsertColumn(long col, wxListItem& info); | |
599 | long InsertColumn(long col, const wxString& heading, int format = wxLIST_FORMAT_LEFT, | |
600 | int width = -1); | |
601 | bool ScrollList(int dx, int dy); | |
c801d85f | 602 | bool SortItems(wxListCtrlCompare fn, long data); |
debe6624 | 603 | bool Update(long item); |
77e7a1dc RR |
604 | void OnIdle( wxIdleEvent &event ); |
605 | ||
606 | // We have to hand down a few functions | |
607 | ||
e4d06860 RR |
608 | void SetBackgroundColour( const wxColour &colour ); |
609 | void SetForegroundColour( const wxColour &colour ); | |
610 | void SetFont( const wxFont &font ); | |
611 | ||
c801d85f | 612 | void SetDropTarget( wxDropTarget *dropTarget ) |
77e7a1dc | 613 | { m_mainWin->SetDropTarget( dropTarget ); } |
c801d85f | 614 | wxDropTarget *GetDropTarget() const |
77e7a1dc RR |
615 | { return m_mainWin->GetDropTarget(); } |
616 | void SetCursor( const wxCursor &cursor ) | |
a367b9b3 | 617 | { if (m_mainWin) m_mainWin->wxWindow::SetCursor( cursor); } |
77e7a1dc | 618 | wxColour GetBackgroundColour() const |
a367b9b3 JS |
619 | { if (m_mainWin) return m_mainWin->GetBackgroundColour(); |
620 | else return wxColour(); } | |
77e7a1dc | 621 | wxColour GetForegroundColour() const |
a367b9b3 JS |
622 | { if (m_mainWin) return m_mainWin->GetForegroundColour(); |
623 | else return wxColour(); } | |
77e7a1dc | 624 | bool PopupMenu( wxMenu *menu, int x, int y ) |
39570cd4 | 625 | { return m_mainWin->PopupMenu( menu, x, y ); } |
c801d85f | 626 | |
0208334d | 627 | // implementation |
a3622daa | 628 | |
c801d85f | 629 | // wxListTextCtrl m_textCtrl; |
a3622daa VZ |
630 | wxImageList *m_imageListNormal; |
631 | wxImageList *m_imageListSmall; | |
c801d85f KB |
632 | wxImageList *m_imageListState; // what's that ? |
633 | wxListHeaderWindow *m_headerWin; | |
634 | wxListMainWindow *m_mainWin; | |
a3622daa | 635 | |
c801d85f KB |
636 | DECLARE_EVENT_TABLE() |
637 | ||
638 | }; | |
639 | ||
640 | ||
641 | #endif // __LISTCTRLH_G__ |