]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/listctrl.h
wxClipboard now serves the primary selection as well
[wxWidgets.git] / include / wx / generic / listctrl.h
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/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 //-----------------------------------------------------------------------------
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
55 typedef int (*wxListCtrlCompare)(long item1, long item2, long sortData);
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
73 #define wxLC_SORT_ASCENDING 0x4000
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
99 #define wxLIST_STATE_SELECTED 0x0004
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
123 wxLIST_NEXT_RIGHT // Searches for an item to the right of the specified item
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
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
193 class WXDLLEXPORT wxListEvent: public wxNotifyEvent
194 {
195 DECLARE_DYNAMIC_CLASS(wxListEvent)
196
197 public:
198 wxListEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
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
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 },
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 },
227 #define EVT_LIST_ITEM_ACTIVATED(id, fn) { wxEVT_COMMAND_LIST_ITEM_ACTIVATED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
228
229 //-----------------------------------------------------------------------------
230 // wxListItemData (internal)
231 //-----------------------------------------------------------------------------
232
233 class wxListItemData : public wxObject
234 {
235 DECLARE_DYNAMIC_CLASS(wxListItemData);
236
237 public:
238 wxString m_text;
239 int m_image;
240 long m_data;
241 int m_xpos,m_ypos;
242 int m_width,m_height;
243 wxColour *m_colour;
244
245 public:
246 wxListItemData(void);
247 wxListItemData( const wxListItem &info );
248 void SetItem( const wxListItem &info );
249 void SetText( const wxString &s );
250 void SetImage( int image );
251 void SetData( long data );
252 void SetPosition( int x, int y );
253 void SetSize( int width, int height );
254 void SetColour( wxColour *col );
255 bool HasImage(void) const;
256 bool HasText(void) const;
257 bool IsHit( int x, int y ) const;
258 void GetText( wxString &s );
259 int GetX( void ) const;
260 int GetY( void ) const;
261 int GetWidth(void) const;
262 int GetHeight(void) const;
263 int GetImage(void) const;
264 void GetItem( wxListItem &info );
265 wxColour *GetColour(void);
266 };
267
268 //-----------------------------------------------------------------------------
269 // wxListHeaderData (internal)
270 //-----------------------------------------------------------------------------
271
272 class wxListHeaderData : public wxObject
273 {
274 DECLARE_DYNAMIC_CLASS(wxListHeaderData);
275
276 protected:
277 long m_mask;
278 int m_image;
279 wxString m_text;
280 int m_format;
281 int m_width;
282 int m_xpos,m_ypos;
283 int m_height;
284
285 public:
286 wxListHeaderData(void);
287 wxListHeaderData( const wxListItem &info );
288 void SetItem( const wxListItem &item );
289 void SetPosition( int x, int y );
290 void SetWidth( int w );
291 void SetFormat( int format );
292 void SetHeight( int h );
293 bool HasImage(void) const;
294 bool HasText(void) const;
295 bool IsHit( int x, int y ) const;
296 void GetItem( wxListItem &item );
297 void GetText( wxString &s );
298 int GetImage(void) const;
299 int GetWidth(void) const;
300 int GetFormat(void) const;
301 };
302
303 //-----------------------------------------------------------------------------
304 // wxListLineData (internal)
305 //-----------------------------------------------------------------------------
306
307 class wxListLineData : public wxObject
308 {
309 DECLARE_DYNAMIC_CLASS(wxListLineData);
310
311 public:
312 wxList m_items;
313 wxRectangle m_bound_all;
314 wxRectangle m_bound_label;
315 wxRectangle m_bound_icon;
316 wxRectangle m_bound_hilight;
317 int m_mode;
318 bool m_hilighted;
319 wxBrush *m_hilightBrush;
320 int m_spacing;
321 wxListMainWindow *m_owner;
322
323 void DoDraw( wxPaintDC *dc, bool hilight, bool paintBG );
324
325 public:
326 wxListLineData( void ) {};
327 wxListLineData( wxListMainWindow *owner, int mode, wxBrush *hilightBrush );
328 void CalculateSize( wxPaintDC *dc, int spacing );
329 void SetPosition( wxPaintDC *dc, int x, int y, int window_width );
330 void SetColumnPosition( int index, int x );
331 void GetSize( int &width, int &height );
332 void GetExtent( int &x, int &y, int &width, int &height );
333 void GetLabelExtent( int &x, int &y, int &width, int &height );
334 long IsHit( int x, int y );
335 void InitItems( int num );
336 void SetItem( int index, const wxListItem &info );
337 void GetItem( int index, wxListItem &info );
338 void GetText( int index, wxString &s );
339 void SetText( int index, const wxString s );
340 int GetImage( int index );
341 void GetRect( wxRectangle &rect );
342 void Hilight( bool on );
343 void ReverseHilight( void );
344 void DrawRubberBand( wxPaintDC *dc, bool on );
345 void Draw( wxPaintDC *dc );
346 bool IsInRect( int x, int y, const wxRectangle &rect );
347 bool IsHilighted( void );
348 void AssignRect( wxRectangle &dest, int x, int y, int width, int height );
349 void AssignRect( wxRectangle &dest, const wxRectangle &source );
350 };
351
352 //-----------------------------------------------------------------------------
353 // wxListHeaderWindow (internal)
354 //-----------------------------------------------------------------------------
355
356 class wxListHeaderWindow : public wxWindow
357 {
358 DECLARE_DYNAMIC_CLASS(wxListHeaderWindow)
359
360 protected:
361 wxListMainWindow *m_owner;
362 wxCursor *m_currentCursor;
363 wxCursor *m_resizeCursor;
364 bool m_isDraging;
365 int m_column;
366 int m_minX;
367 int m_currentX;
368
369 public:
370 wxListHeaderWindow( void );
371 ~wxListHeaderWindow( void );
372 wxListHeaderWindow( wxWindow *win, wxWindowID id, wxListMainWindow *owner,
373 const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
374 long style = 0, const wxString &name = "columntitles" );
375 void DoDrawRect( wxPaintDC *dc, int x, int y, int w, int h );
376 void OnPaint( wxPaintEvent &event );
377 void DrawCurrent();
378 void OnMouse( wxMouseEvent &event );
379 void OnSetFocus( wxFocusEvent &event );
380
381 DECLARE_EVENT_TABLE()
382 };
383
384 //-----------------------------------------------------------------------------
385 // wxListRenameTimer (internal)
386 //-----------------------------------------------------------------------------
387
388 class wxListRenameTimer: public wxTimer
389 {
390 private:
391 wxListMainWindow *m_owner;
392
393 public:
394 wxListRenameTimer( wxListMainWindow *owner );
395 void Notify();
396 };
397
398 //-----------------------------------------------------------------------------
399 // wxListTextCtrl (internal)
400 //-----------------------------------------------------------------------------
401
402 class wxListTextCtrl: public wxTextCtrl
403 {
404 DECLARE_DYNAMIC_CLASS(wxListTextCtrl);
405
406 private:
407 bool *m_accept;
408 wxString *m_res;
409 wxListMainWindow *m_owner;
410
411 public:
412 wxListTextCtrl(void) {};
413 wxListTextCtrl( wxWindow *parent, const wxWindowID id,
414 bool *accept, wxString *res, wxListMainWindow *owner,
415 const wxString &value = "",
416 const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
417 int style = 0, const wxValidator& validator = wxDefaultValidator,
418 const wxString &name = "wxListTextCtrlText" );
419 void OnChar( wxKeyEvent &event );
420 void OnKillFocus( wxFocusEvent &event );
421
422 DECLARE_EVENT_TABLE()
423 };
424
425 //-----------------------------------------------------------------------------
426 // wxListMainWindow (internal)
427 //-----------------------------------------------------------------------------
428
429 class wxListMainWindow: public wxScrolledWindow
430 {
431 DECLARE_DYNAMIC_CLASS(wxListMainWindow);
432
433 public:
434 long m_mode;
435 wxList m_lines;
436 wxList m_columns;
437 wxListLineData *m_current;
438 int m_visibleLines;
439 wxBrush *m_hilightBrush;
440 wxColour *m_hilightColour;
441 int m_xScroll,m_yScroll;
442 bool m_dirty;
443 wxImageList *m_small_image_list;
444 wxImageList *m_normal_image_list;
445 int m_small_spacing;
446 int m_normal_spacing;
447 bool m_hasFocus;
448 bool m_usedKeys;
449 bool m_lastOnSame;
450 wxTimer *m_renameTimer;
451 // wxListTextCtrl *m_text;
452 bool m_renameAccept;
453 wxString m_renameRes;
454 bool m_isCreated;
455 int m_dragCount;
456
457 public:
458 wxListMainWindow(void);
459 wxListMainWindow( wxWindow *parent, wxWindowID id,
460 const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
461 long style = 0, const wxString &name = "listctrl" );
462 ~wxListMainWindow(void);
463 void RefreshLine( wxListLineData *line );
464 void OnPaint( wxPaintEvent &event );
465 void HilightAll( bool on );
466 void SendNotify( wxListLineData *line, wxEventType command );
467 void FocusLine( wxListLineData *line );
468 void UnfocusLine( wxListLineData *line );
469 void SelectLine( wxListLineData *line );
470 void DeselectLine( wxListLineData *line );
471 void DeleteLine( wxListLineData *line );
472 void RenameLine( wxListLineData *line, const wxString &newName );
473 void StartLabelEdit( wxListLineData *line );
474 void OnRenameTimer(void);
475 void OnRenameAccept(void);
476 void OnMouse( wxMouseEvent &event );
477 void MoveToFocus( void );
478 void OnArrowChar( wxListLineData *newCurrent, bool shiftDown );
479 void OnChar( wxKeyEvent &event );
480 void OnSetFocus( wxFocusEvent &event );
481 void OnKillFocus( wxFocusEvent &event );
482 void OnSize( wxSizeEvent &event );
483 void DrawImage( int index, wxPaintDC *dc, int x, int y );
484 void GetImageSize( int index, int &width, int &height );
485 int GetIndexOfLine( const wxListLineData *line );
486 int GetTextLength( wxString &s ); // should be const
487
488 void SetImageList( wxImageList *imageList, int which );
489 void SetItemSpacing( int spacing, bool isSmall = FALSE );
490 int GetItemSpacing( bool isSmall = FALSE );
491 void SetColumn( int col, wxListItem &item );
492 void SetColumnWidth( int col, int width );
493 void GetColumn( int col, wxListItem &item );
494 int GetColumnWidth( int vol );
495 int GetColumnCount( void );
496 int GetCountPerPage( void );
497 void SetItem( wxListItem &item );
498 void GetItem( wxListItem &item );
499 void SetItemState( long item, long state, long stateMask );
500 int GetItemState( long item, long stateMask );
501 int GetItemCount( void );
502 void GetItemRect( long index, wxRectangle &rect );
503 bool GetItemPosition(long item, wxPoint& pos);
504 int GetSelectedItemCount( void );
505 void SetMode( long mode );
506 long GetMode( void ) const;
507 void CalculatePositions( void );
508 void RealizeChanges(void);
509 long GetNextItem( long item, int geometry, int state );
510 void DeleteItem( long index );
511 void DeleteAllItems( void );
512 void DeleteColumn( int col );
513 void DeleteEverything( void );
514 void EnsureVisible( long index );
515 long FindItem(long start, const wxString& str, bool partial = FALSE );
516 long FindItem(long start, long data);
517 long HitTest( int x, int y, int &flags );
518 void InsertItem( wxListItem &item );
519 // void AddItem( wxListItem &item );
520 void InsertColumn( long col, wxListItem &item );
521 // void AddColumn( wxListItem &item );
522 void SortItems( wxListCtrlCompare fn, long data );
523
524 DECLARE_EVENT_TABLE()
525 };
526
527 //-----------------------------------------------------------------------------
528 // wxListCtrl
529 //-----------------------------------------------------------------------------
530
531 class wxListCtrl: public wxControl
532 {
533 DECLARE_DYNAMIC_CLASS(wxListCtrl);
534
535 public:
536
537 wxListCtrl(void);
538 wxListCtrl( wxWindow *parent, wxWindowID id = -1,
539 const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
540 long style = wxLC_ICON, const wxValidator& validator = wxDefaultValidator,
541 const wxString &name = "listctrl" )
542 {
543 Create(parent, id, pos, size, style, validator, name);
544 }
545 ~wxListCtrl(void);
546 bool Create( wxWindow *parent, wxWindowID id = -1,
547 const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
548 long style = wxLC_ICON, const wxValidator& validator = wxDefaultValidator,
549 const wxString &name = "listctrl" );
550 void OnSize( wxSizeEvent &event );
551 bool GetColumn( int col, wxListItem& item ) const;
552 bool SetColumn( int col, wxListItem& item );
553 int GetColumnWidth( int col ) const;
554 bool SetColumnWidth( int col, int width);
555 int GetCountPerPage(void) const; // not the same in wxGLC as in Windows, I think
556 // wxText& GetEditControl(void) const; // not supported in wxGLC
557 bool GetItem( wxListItem& info ) const;
558 bool SetItem( wxListItem& info ) ;
559 long SetItem( long index, int col, const wxString& label, int imageId = -1 );
560 int GetItemState( long item, long stateMask ) const;
561 bool SetItemState( long item, long state, long stateMask);
562 bool SetItemImage( long item, int image, int selImage);
563 wxString GetItemText( long item ) const;
564 void SetItemText( long item, const wxString& str );
565 long GetItemData( long item ) const;
566 bool SetItemData( long item, long data );
567 bool GetItemRect( long item, wxRectangle& rect, int code = wxLIST_RECT_BOUNDS ) const;
568 bool GetItemPosition( long item, wxPoint& pos ) const;
569 bool SetItemPosition( long item, const wxPoint& pos ); // not supported in wxGLC
570 int GetItemCount(void) const;
571 int GetColumnCount(void) const;
572 void SetItemSpacing( int spacing, bool isSmall = FALSE );
573 int GetItemSpacing( bool isSmall ) const;
574 int GetSelectedItemCount(void) const;
575 // wxColour GetTextColour(void) const; // wxGLC has colours for every Item (see wxListItem)
576 // void SetTextColour(const wxColour& col);
577 long GetTopItem(void) const;
578 void SetSingleStyle( long style, bool add = TRUE ) ;
579 void SetWindowStyleFlag(long style);
580 void RecreateWindow(void) {};
581 long GetNextItem(long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE) const;
582 wxImageList *GetImageList(int which) const;
583 void SetImageList(wxImageList *imageList, int which) ;
584 bool Arrange( int flag = wxLIST_ALIGN_DEFAULT ); // always wxLIST_ALIGN_LEFT in wxGLC
585 void ClearAll();
586 bool DeleteItem( long item );
587 bool DeleteAllItems(void);
588 bool DeleteAllColumns(void);
589 bool DeleteColumn( int col );
590 // wxText& Edit(long item) ; // not supported in wxGLC
591 bool EnsureVisible( long item );
592 long FindItem(long start, const wxString& str, bool partial = FALSE );
593 long FindItem(long start, long data);
594 long FindItem(long start, const wxPoint& pt, int direction); // not supported in wxGLC
595 long HitTest(const wxPoint& point, int& flags);
596 long InsertItem(wxListItem& info);
597 long InsertItem(long index, const wxString& label);
598 long InsertItem(long index, int imageIndex);
599 long InsertItem(long index, const wxString& label, int imageIndex);
600 long InsertColumn(long col, wxListItem& info);
601 long InsertColumn(long col, const wxString& heading, int format = wxLIST_FORMAT_LEFT,
602 int width = -1);
603 bool ScrollList(int dx, int dy);
604 bool SortItems(wxListCtrlCompare fn, long data);
605 bool Update(long item);
606 void OnIdle( wxIdleEvent &event );
607
608 // We have to hand down a few functions
609
610 void SetBackgroundColour( const wxColour &colour );
611 void SetForegroundColour( const wxColour &colour );
612 void SetFont( const wxFont &font );
613
614 void SetDropTarget( wxDropTarget *dropTarget )
615 { m_mainWin->SetDropTarget( dropTarget ); }
616 wxDropTarget *GetDropTarget() const
617 { return m_mainWin->GetDropTarget(); }
618 void SetCursor( const wxCursor &cursor )
619 { if (m_mainWin) m_mainWin->wxWindow::SetCursor( cursor); }
620 wxColour GetBackgroundColour() const
621 { if (m_mainWin) return m_mainWin->GetBackgroundColour();
622 else return wxColour(); }
623 wxColour GetForegroundColour() const
624 { if (m_mainWin) return m_mainWin->GetForegroundColour();
625 else return wxColour(); }
626 bool PopupMenu( wxMenu *menu, int x, int y )
627 { return m_mainWin->PopupMenu( menu, x, y ); }
628 void SetFocus()
629 { m_mainWin->SetFocus(); }
630
631 // implementation
632
633 // wxListTextCtrl m_textCtrl;
634 wxImageList *m_imageListNormal;
635 wxImageList *m_imageListSmall;
636 wxImageList *m_imageListState; // what's that ?
637 wxListHeaderWindow *m_headerWin;
638 wxListMainWindow *m_mainWin;
639
640 DECLARE_EVENT_TABLE()
641
642 };
643
644
645 #endif // __LISTCTRLH_G__