]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/listctrl.h
More asserts and stuff
[wxWidgets.git] / include / wx / generic / listctrl.h
CommitLineData
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"
f60d0f94 20#include "wx/generic/imaglist.h"
c801d85f
KB
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
1e6d9499
JS
28#if wxUSE_DRAG_AND_DROP
29class WXDLLEXPORT wxDropTarget;
30#endif
31
c801d85f
KB
32//-----------------------------------------------------------------------------
33// classes
34//-----------------------------------------------------------------------------
35
1e6d9499
JS
36class WXDLLEXPORT wxListItem;
37class WXDLLEXPORT wxListEvent;
38class WXDLLEXPORT wxListCtrl;
c801d85f
KB
39
40//-----------------------------------------------------------------------------
41// internal classes
42//-----------------------------------------------------------------------------
43
1e6d9499
JS
44class WXDLLEXPORT wxListHeaderData;
45class WXDLLEXPORT wxListItemData;
46class WXDLLEXPORT wxListLineData;
c801d85f 47
1e6d9499
JS
48class WXDLLEXPORT wxListHeaderWindow;
49class WXDLLEXPORT wxListMainWindow;
c801d85f 50
1e6d9499 51class WXDLLEXPORT wxListRenameTimer;
e179bd65 52class WXDLLEXPORT wxListTextCtrl;
c801d85f
KB
53
54//-----------------------------------------------------------------------------
55// types
56//-----------------------------------------------------------------------------
57
58// type of compare function for wxListCtrl sort operation
debe6624 59typedef int (*wxListCtrlCompare)(long item1, long item2, long sortData);
c801d85f
KB
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 // not supported in wxGLC
75#define wxLC_NO_SORT_HEADER 0x1000 // not supported in wxGLC
76#define wxLC_SINGLE_SEL 0x2000
a3622daa 77#define wxLC_SORT_ASCENDING 0x4000
c801d85f
KB
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
a3622daa 103#define wxLIST_STATE_SELECTED 0x0004
c801d85f
KB
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
122enum {
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
a3622daa 127 wxLIST_NEXT_RIGHT // Searches for an item to the right of the specified item
c801d85f
KB
128};
129
130// Alignment flags for Arrange // always wxLIST_ALIGN_LEFT in wxGLC
131enum {
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
139enum {
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
147enum {
0180dad6
RR
148 wxLIST_AUTOSIZE = -1, // width of longest item
149 wxLIST_AUTOSIZE_USEHEADER = -2 // always 80 in wxGLC
c801d85f
KB
150};
151
152// Flag values for GetItemRect
153enum {
154 wxLIST_RECT_BOUNDS,
155 wxLIST_RECT_ICON,
156 wxLIST_RECT_LABEL
157};
158
159// Flag values for FindItem // not supported by wxGLC
160enum {
161 wxLIST_FIND_UP,
162 wxLIST_FIND_DOWN,
163 wxLIST_FIND_LEFT,
164 wxLIST_FIND_RIGHT
165};
166
c801d85f
KB
167//-----------------------------------------------------------------------------
168// wxListItem
169//-----------------------------------------------------------------------------
170
1e6d9499 171class WXDLLEXPORT wxListItem: public wxObject
c801d85f
KB
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(void);
191};
192
193//-----------------------------------------------------------------------------
194// wxListEvent
195//-----------------------------------------------------------------------------
196
92976ab6 197class WXDLLEXPORT wxListEvent: public wxNotifyEvent
c801d85f
KB
198{
199 DECLARE_DYNAMIC_CLASS(wxListEvent)
200
201 public:
64693098 202 wxListEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
c801d85f
KB
203
204 int m_code;
205 long m_itemIndex;
206 long m_oldItemIndex;
207 int m_col;
208 bool m_cancelled;
209 wxPoint m_pointDrag;
210
211 wxListItem m_item;
212};
213
214typedef void (wxEvtHandler::*wxListEventFunction)(wxListEvent&);
215
c67daf87
UR
216#define EVT_LIST_BEGIN_DRAG(id, fn) { wxEVT_COMMAND_LIST_BEGIN_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
217#define EVT_LIST_BEGIN_RDRAG(id, fn) { wxEVT_COMMAND_LIST_BEGIN_RDRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
218#define EVT_LIST_BEGIN_LABEL_EDIT(id, fn) { wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
219#define EVT_LIST_END_LABEL_EDIT(id, fn) { wxEVT_COMMAND_LIST_END_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
220#define EVT_LIST_DELETE_ITEM(id, fn) { wxEVT_COMMAND_LIST_DELETE_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
221#define EVT_LIST_DELETE_ALL_ITEMS(id, fn) { wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
222#define EVT_LIST_GET_INFO(id, fn) { wxEVT_COMMAND_LIST_GET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
223#define EVT_LIST_SET_INFO(id, fn) { wxEVT_COMMAND_LIST_SET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
224#define EVT_LIST_ITEM_SELECTED(id, fn) { wxEVT_COMMAND_LIST_ITEM_SELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
225#define EVT_LIST_ITEM_DESELECTED(id, fn) { wxEVT_COMMAND_LIST_ITEM_DESELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
226#define EVT_LIST_KEY_DOWN(id, fn) { wxEVT_COMMAND_LIST_KEY_DOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
227#define EVT_LIST_INSERT_ITEM(id, fn) { wxEVT_COMMAND_LIST_INSERT_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
228#define EVT_LIST_COL_CLICK(id, fn) { wxEVT_COMMAND_LIST_COL_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
92976ab6
RR
229#define EVT_LIST_ITEM_RIGHT_CLICK(id, fn) { wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
230#define EVT_LIST_ITEM_MIDDLE_CLICK(id, fn) { wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
435fe83e 231#define EVT_LIST_ITEM_ACTIVATED(id, fn) { wxEVT_COMMAND_LIST_ITEM_ACTIVATED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
c801d85f
KB
232
233//-----------------------------------------------------------------------------
234// wxListItemData (internal)
235//-----------------------------------------------------------------------------
236
1e6d9499 237class WXDLLEXPORT wxListItemData : public wxObject
c801d85f
KB
238{
239 DECLARE_DYNAMIC_CLASS(wxListItemData);
240
0208334d 241 public:
c801d85f
KB
242 wxString m_text;
243 int m_image;
244 long m_data;
245 int m_xpos,m_ypos;
246 int m_width,m_height;
247 wxColour *m_colour;
a3622daa 248
c801d85f
KB
249 public:
250 wxListItemData(void);
251 wxListItemData( const wxListItem &info );
252 void SetItem( const wxListItem &info );
253 void SetText( const wxString &s );
debe6624
JS
254 void SetImage( int image );
255 void SetData( long data );
256 void SetPosition( int x, int y );
257 void SetSize( int width, int height );
c801d85f
KB
258 void SetColour( wxColour *col );
259 bool HasImage(void) const;
260 bool HasText(void) const;
debe6624 261 bool IsHit( int x, int y ) const;
c801d85f
KB
262 void GetText( wxString &s );
263 int GetX( void ) const;
264 int GetY( void ) const;
265 int GetWidth(void) const;
266 int GetHeight(void) const;
267 int GetImage(void) const;
268 void GetItem( wxListItem &info );
269 wxColour *GetColour(void);
270};
271
272//-----------------------------------------------------------------------------
273// wxListHeaderData (internal)
274//-----------------------------------------------------------------------------
275
1e6d9499 276class WXDLLEXPORT wxListHeaderData : public wxObject
c801d85f
KB
277{
278 DECLARE_DYNAMIC_CLASS(wxListHeaderData);
279
280 protected:
281 long m_mask;
282 int m_image;
283 wxString m_text;
284 int m_format;
285 int m_width;
286 int m_xpos,m_ypos;
287 int m_height;
a3622daa 288
c801d85f
KB
289 public:
290 wxListHeaderData(void);
291 wxListHeaderData( const wxListItem &info );
292 void SetItem( const wxListItem &item );
debe6624
JS
293 void SetPosition( int x, int y );
294 void SetWidth( int w );
295 void SetFormat( int format );
296 void SetHeight( int h );
c801d85f
KB
297 bool HasImage(void) const;
298 bool HasText(void) const;
debe6624 299 bool IsHit( int x, int y ) const;
c801d85f
KB
300 void GetItem( wxListItem &item );
301 void GetText( wxString &s );
302 int GetImage(void) const;
303 int GetWidth(void) const;
304 int GetFormat(void) const;
305};
306
307//-----------------------------------------------------------------------------
308// wxListLineData (internal)
309//-----------------------------------------------------------------------------
310
1e6d9499 311class WXDLLEXPORT wxListLineData : public wxObject
c801d85f
KB
312{
313 DECLARE_DYNAMIC_CLASS(wxListLineData);
314
0208334d 315 public:
c801d85f 316 wxList m_items;
0a240683
JS
317 wxRect m_bound_all;
318 wxRect m_bound_label;
319 wxRect m_bound_icon;
320 wxRect m_bound_hilight;
c801d85f
KB
321 int m_mode;
322 bool m_hilighted;
323 wxBrush *m_hilightBrush;
324 int m_spacing;
325 wxListMainWindow *m_owner;
326
1e6d9499 327 void DoDraw( wxDC *dc, bool hilight, bool paintBG );
c801d85f
KB
328
329 public:
330 wxListLineData( void ) {};
debe6624 331 wxListLineData( wxListMainWindow *owner, int mode, wxBrush *hilightBrush );
1e6d9499
JS
332 void CalculateSize( wxDC *dc, int spacing );
333 void SetPosition( wxDC *dc, int x, int y, int window_width );
debe6624 334 void SetColumnPosition( int index, int x );
c801d85f
KB
335 void GetSize( int &width, int &height );
336 void GetExtent( int &x, int &y, int &width, int &height );
337 void GetLabelExtent( int &x, int &y, int &width, int &height );
debe6624
JS
338 long IsHit( int x, int y );
339 void InitItems( int num );
340 void SetItem( int index, const wxListItem &info );
341 void GetItem( int index, wxListItem &info );
342 void GetText( int index, wxString &s );
343 void SetText( int index, const wxString s );
344 int GetImage( int index );
0a240683 345 void GetRect( wxRect &rect );
debe6624 346 void Hilight( bool on );
c801d85f 347 void ReverseHilight( void );
1e6d9499
JS
348 void DrawRubberBand( wxDC *dc, bool on );
349 void Draw( wxDC *dc );
0a240683 350 bool IsInRect( int x, int y, const wxRect &rect );
c801d85f 351 bool IsHilighted( void );
0a240683
JS
352 void AssignRect( wxRect &dest, int x, int y, int width, int height );
353 void AssignRect( wxRect &dest, const wxRect &source );
c801d85f
KB
354};
355
356//-----------------------------------------------------------------------------
357// wxListHeaderWindow (internal)
358//-----------------------------------------------------------------------------
359
1e6d9499 360class WXDLLEXPORT wxListHeaderWindow : public wxWindow
c801d85f
KB
361{
362 DECLARE_DYNAMIC_CLASS(wxListHeaderWindow)
363
364 protected:
365 wxListMainWindow *m_owner;
366 wxCursor *m_currentCursor;
367 wxCursor *m_resizeCursor;
cfb50f14 368 bool m_isDragging;
0208334d
RR
369 int m_column;
370 int m_minX;
371 int m_currentX;
c801d85f
KB
372
373 public:
374 wxListHeaderWindow( void );
a367b9b3 375 ~wxListHeaderWindow( void );
a3622daa 376 wxListHeaderWindow( wxWindow *win, wxWindowID id, wxListMainWindow *owner,
debe6624
JS
377 const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
378 long style = 0, const wxString &name = "columntitles" );
1e6d9499 379 void DoDrawRect( wxDC *dc, int x, int y, int w, int h );
c801d85f 380 void OnPaint( wxPaintEvent &event );
0208334d 381 void DrawCurrent();
c801d85f
KB
382 void OnMouse( wxMouseEvent &event );
383 void OnSetFocus( wxFocusEvent &event );
a3622daa 384
c801d85f
KB
385 DECLARE_EVENT_TABLE()
386};
387
388//-----------------------------------------------------------------------------
389// wxListRenameTimer (internal)
390//-----------------------------------------------------------------------------
391
1e6d9499 392class WXDLLEXPORT wxListRenameTimer: public wxTimer
c801d85f
KB
393{
394 private:
395 wxListMainWindow *m_owner;
a3622daa 396
c801d85f
KB
397 public:
398 wxListRenameTimer( wxListMainWindow *owner );
399 void Notify();
400};
401
c801d85f
KB
402//-----------------------------------------------------------------------------
403// wxListTextCtrl (internal)
404//-----------------------------------------------------------------------------
405
1e6d9499 406class WXDLLEXPORT wxListTextCtrl: public wxTextCtrl
c801d85f
KB
407{
408 DECLARE_DYNAMIC_CLASS(wxListTextCtrl);
a3622daa 409
c801d85f
KB
410 private:
411 bool *m_accept;
412 wxString *m_res;
413 wxListMainWindow *m_owner;
414
415 public:
ee7ee469
RR
416 wxListTextCtrl(void) {};
417 wxListTextCtrl( wxWindow *parent, const wxWindowID id,
418 bool *accept, wxString *res, wxListMainWindow *owner,
419 const wxString &value = "",
420 const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
421 int style = 0, const wxValidator& validator = wxDefaultValidator,
422 const wxString &name = "wxListTextCtrlText" );
423 void OnChar( wxKeyEvent &event );
424 void OnKillFocus( wxFocusEvent &event );
425
426 DECLARE_EVENT_TABLE()
c801d85f
KB
427};
428
c801d85f
KB
429//-----------------------------------------------------------------------------
430// wxListMainWindow (internal)
431//-----------------------------------------------------------------------------
432
1e6d9499 433class WXDLLEXPORT wxListMainWindow: public wxScrolledWindow
c801d85f
KB
434{
435 DECLARE_DYNAMIC_CLASS(wxListMainWindow);
436
437 public:
438 long m_mode;
439 wxList m_lines;
a3622daa 440 wxList m_columns;
c801d85f 441 wxListLineData *m_current;
e179bd65 442 wxListLineData *m_currentEdit;
c801d85f
KB
443 int m_visibleLines;
444 wxBrush *m_hilightBrush;
445 wxColour *m_hilightColour;
c801d85f
KB
446 int m_xScroll,m_yScroll;
447 bool m_dirty;
448 wxImageList *m_small_image_list;
449 wxImageList *m_normal_image_list;
450 int m_small_spacing;
451 int m_normal_spacing;
452 bool m_hasFocus;
453 bool m_usedKeys;
454 bool m_lastOnSame;
455 wxTimer *m_renameTimer;
c801d85f
KB
456 bool m_renameAccept;
457 wxString m_renameRes;
458 bool m_isCreated;
e3e65dac 459 int m_dragCount;
c801d85f
KB
460
461 public:
e179bd65 462 wxListMainWindow();
a3622daa 463 wxListMainWindow( wxWindow *parent, wxWindowID id,
debe6624
JS
464 const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
465 long style = 0, const wxString &name = "listctrl" );
e179bd65 466 ~wxListMainWindow();
c801d85f
KB
467 void RefreshLine( wxListLineData *line );
468 void OnPaint( wxPaintEvent &event );
debe6624 469 void HilightAll( bool on );
64693098 470 void SendNotify( wxListLineData *line, wxEventType command );
c801d85f
KB
471 void FocusLine( wxListLineData *line );
472 void UnfocusLine( wxListLineData *line );
473 void SelectLine( wxListLineData *line );
474 void DeselectLine( wxListLineData *line );
475 void DeleteLine( wxListLineData *line );
e179bd65
RR
476
477 void Edit( long item );
478 void OnRenameTimer();
479 void OnRenameAccept();
480
c801d85f 481 void OnMouse( wxMouseEvent &event );
e179bd65 482 void MoveToFocus();
c801d85f
KB
483 void OnArrowChar( wxListLineData *newCurrent, bool shiftDown );
484 void OnChar( wxKeyEvent &event );
3dfb93fd 485 void OnKeyDown( wxKeyEvent &event );
c801d85f
KB
486 void OnSetFocus( wxFocusEvent &event );
487 void OnKillFocus( wxFocusEvent &event );
488 void OnSize( wxSizeEvent &event );
e179bd65 489
1e6d9499 490 void DrawImage( int index, wxDC *dc, int x, int y );
c801d85f
KB
491 void GetImageSize( int index, int &width, int &height );
492 int GetIndexOfLine( const wxListLineData *line );
493 int GetTextLength( wxString &s ); // should be const
494
debe6624
JS
495 void SetImageList( wxImageList *imageList, int which );
496 void SetItemSpacing( int spacing, bool isSmall = FALSE );
497 int GetItemSpacing( bool isSmall = FALSE );
498 void SetColumn( int col, wxListItem &item );
499 void SetColumnWidth( int col, int width );
500 void GetColumn( int col, wxListItem &item );
501 int GetColumnWidth( int vol );
e179bd65
RR
502 int GetColumnCount();
503 int GetCountPerPage();
c801d85f
KB
504 void SetItem( wxListItem &item );
505 void GetItem( wxListItem &item );
a3622daa 506 void SetItemState( long item, long state, long stateMask );
debe6624 507 int GetItemState( long item, long stateMask );
e179bd65 508 int GetItemCount();
0a240683 509 void GetItemRect( long index, wxRect &rect );
e179bd65
RR
510 bool GetItemPosition( long item, wxPoint& pos );
511 int GetSelectedItemCount();
debe6624 512 void SetMode( long mode );
e179bd65
RR
513 long GetMode() const;
514 void CalculatePositions();
515 void RealizeChanges();
debe6624
JS
516 long GetNextItem( long item, int geometry, int state );
517 void DeleteItem( long index );
e179bd65 518 void DeleteAllItems();
debe6624 519 void DeleteColumn( int col );
e179bd65 520 void DeleteEverything();
debe6624 521 void EnsureVisible( long index );
e179bd65
RR
522 long FindItem( long start, const wxString& str, bool partial = FALSE );
523 long FindItem( long start, long data);
debe6624 524 long HitTest( int x, int y, int &flags );
c801d85f 525 void InsertItem( wxListItem &item );
30dea054 526// void AddItem( wxListItem &item );
debe6624 527 void InsertColumn( long col, wxListItem &item );
30dea054 528// void AddColumn( wxListItem &item );
c801d85f 529 void SortItems( wxListCtrlCompare fn, long data );
a3622daa 530
c801d85f
KB
531 DECLARE_EVENT_TABLE()
532};
533
534//-----------------------------------------------------------------------------
535// wxListCtrl
536//-----------------------------------------------------------------------------
537
1e6d9499 538class WXDLLEXPORT wxListCtrl: public wxControl
c801d85f
KB
539{
540 DECLARE_DYNAMIC_CLASS(wxListCtrl);
a3622daa 541
c801d85f 542 public:
e179bd65 543 wxListCtrl();
32e9da8b 544 wxListCtrl( wxWindow *parent, wxWindowID id = -1,
debe6624 545 const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
32e9da8b
RR
546 long style = wxLC_ICON, const wxValidator& validator = wxDefaultValidator,
547 const wxString &name = "listctrl" )
548 {
549 Create(parent, id, pos, size, style, validator, name);
550 }
e179bd65 551 ~wxListCtrl();
32e9da8b 552 bool Create( wxWindow *parent, wxWindowID id = -1,
debe6624 553 const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
32e9da8b
RR
554 long style = wxLC_ICON, const wxValidator& validator = wxDefaultValidator,
555 const wxString &name = "listctrl" );
c801d85f 556 void OnSize( wxSizeEvent &event );
e487524e 557 bool GetColumn( int col, wxListItem& item ) const;
debe6624 558 bool SetColumn( int col, wxListItem& item );
e487524e 559 int GetColumnWidth( int col ) const;
debe6624 560 bool SetColumnWidth( int col, int width);
e179bd65 561 int GetCountPerPage() const; // not the same in wxGLC as in Windows, I think
e487524e 562 bool GetItem( wxListItem& info ) const;
c801d85f 563 bool SetItem( wxListItem& info ) ;
debe6624 564 long SetItem( long index, int col, const wxString& label, int imageId = -1 );
e487524e 565 int GetItemState( long item, long stateMask ) const;
debe6624
JS
566 bool SetItemState( long item, long state, long stateMask);
567 bool SetItemImage( long item, int image, int selImage);
e487524e 568 wxString GetItemText( long item ) const;
debe6624 569 void SetItemText( long item, const wxString& str );
e487524e 570 long GetItemData( long item ) const;
debe6624 571 bool SetItemData( long item, long data );
0a240683 572 bool GetItemRect( long item, wxRect& rect, int code = wxLIST_RECT_BOUNDS ) const;
e487524e 573 bool GetItemPosition( long item, wxPoint& pos ) const;
debe6624 574 bool SetItemPosition( long item, const wxPoint& pos ); // not supported in wxGLC
e179bd65
RR
575 int GetItemCount() const;
576 int GetColumnCount() const;
33d0b396 577 void SetItemSpacing( int spacing, bool isSmall = FALSE );
e487524e 578 int GetItemSpacing( bool isSmall ) const;
e179bd65
RR
579 int GetSelectedItemCount() const;
580// wxColour GetTextColour() const; // wxGLC has colours for every Item (see wxListItem)
c801d85f 581// void SetTextColour(const wxColour& col);
e179bd65 582 long GetTopItem() const;
debe6624 583 void SetSingleStyle( long style, bool add = TRUE ) ;
e179bd65
RR
584 void SetWindowStyleFlag( long style );
585 void RecreateWindow() {}
586 long GetNextItem( long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE ) const;
587 wxImageList *GetImageList( int which ) const;
588 void SetImageList( wxImageList *imageList, int which );
debe6624 589 bool Arrange( int flag = wxLIST_ALIGN_DEFAULT ); // always wxLIST_ALIGN_LEFT in wxGLC
e179bd65 590
4f22cf8d 591 void ClearAll();
debe6624 592 bool DeleteItem( long item );
e179bd65
RR
593 bool DeleteAllItems();
594 bool DeleteAllColumns();
debe6624 595 bool DeleteColumn( int col );
e179bd65
RR
596
597 void EditLabel( long item ) { Edit(item); }
598 void Edit( long item );
599
debe6624 600 bool EnsureVisible( long item );
e179bd65
RR
601 long FindItem( long start, const wxString& str, bool partial = FALSE );
602 long FindItem( long start, long data );
603 long FindItem( long start, const wxPoint& pt, int direction ); // not supported in wxGLC
604 long HitTest( const wxPoint& point, int& flags);
c801d85f 605 long InsertItem(wxListItem& info);
e179bd65
RR
606 long InsertItem( long index, const wxString& label );
607 long InsertItem( long index, int imageIndex );
608 long InsertItem( long index, const wxString& label, int imageIndex );
609 long InsertColumn( long col, wxListItem& info );
610 long InsertColumn( long col, const wxString& heading, int format = wxLIST_FORMAT_LEFT,
611 int width = -1 );
612 bool ScrollList( int dx, int dy );
613 bool SortItems( wxListCtrlCompare fn, long data );
614 bool Update( long item );
77e7a1dc
RR
615 void OnIdle( wxIdleEvent &event );
616
617 // We have to hand down a few functions
618
f03fc89f
VZ
619 bool SetBackgroundColour( const wxColour &colour );
620 bool SetForegroundColour( const wxColour &colour );
621 bool SetFont( const wxFont &font );
e4d06860 622
1e6d9499 623#if wxUSE_DRAG_AND_DROP
c801d85f 624 void SetDropTarget( wxDropTarget *dropTarget )
77e7a1dc 625 { m_mainWin->SetDropTarget( dropTarget ); }
c801d85f 626 wxDropTarget *GetDropTarget() const
77e7a1dc 627 { return m_mainWin->GetDropTarget(); }
1e6d9499
JS
628#endif
629
f03fc89f
VZ
630 bool SetCursor( const wxCursor &cursor )
631 { return m_mainWin ? m_mainWin->wxWindow::SetCursor(cursor) : FALSE; }
77e7a1dc 632 wxColour GetBackgroundColour() const
f03fc89f 633 { return m_mainWin ? m_mainWin->GetBackgroundColour() : wxColour(); }
77e7a1dc 634 wxColour GetForegroundColour() const
f03fc89f 635 { return m_mainWin ? m_mainWin->GetForegroundColour() : wxColour(); }
a1665b22 636 bool DoPopupMenu( wxMenu *menu, int x, int y )
39570cd4 637 { return m_mainWin->PopupMenu( menu, x, y ); }
b292e2f5
RR
638 void SetFocus()
639 { m_mainWin->SetFocus(); }
c801d85f 640
0208334d 641 // implementation
e179bd65 642
a3622daa
VZ
643 wxImageList *m_imageListNormal;
644 wxImageList *m_imageListSmall;
c801d85f
KB
645 wxImageList *m_imageListState; // what's that ?
646 wxListHeaderWindow *m_headerWin;
647 wxListMainWindow *m_mainWin;
a3622daa 648
c801d85f
KB
649 DECLARE_EVENT_TABLE()
650
651};
652
653
654#endif // __LISTCTRLH_G__