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