]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/listctrl.h
avoid a bug in Carbon headers
[wxWidgets.git] / include / wx / generic / listctrl.h
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
bdc72a22 2// Name: wx/generic/listctrl.h
c801d85f
KB
3// Purpose: Generic list control
4// Author: Robert Roebling
5// Created: 01/02/97
6// Id:
371a5b4e 7// Copyright: (c) 1998 Robert Roebling and Julian Smart
bdc72a22 8// Licence: wxWindows licence
c801d85f
KB
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef __LISTCTRLH_G__
12#define __LISTCTRLH_G__
13
12028905 14#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
0d3820b3 15#pragma interface "listctrl.h"
c801d85f
KB
16#endif
17
18#include "wx/defs.h"
19#include "wx/object.h"
9cb07953 20#include "wx/generic/imaglist.h"
9cb07953 21
c801d85f
KB
22#include "wx/control.h"
23#include "wx/timer.h"
24#include "wx/dcclient.h"
25#include "wx/scrolwin.h"
26#include "wx/settings.h"
e81a301c 27#include "wx/listbase.h"
c801d85f 28
1e6d9499
JS
29#if wxUSE_DRAG_AND_DROP
30class WXDLLEXPORT wxDropTarget;
31#endif
32
c801d85f
KB
33//-----------------------------------------------------------------------------
34// classes
35//-----------------------------------------------------------------------------
36
1e6d9499
JS
37class WXDLLEXPORT wxListItem;
38class WXDLLEXPORT wxListEvent;
f9ceab7c
JS
39
40#if !defined(__WXMSW__) || defined(__WIN16__) || defined(__WXUNIVERSAL__)
1e6d9499 41class WXDLLEXPORT wxListCtrl;
f9ceab7c
JS
42#define wxImageListType wxImageList
43#else
44#define wxImageListType wxGenericImageList
45#endif
c801d85f
KB
46
47//-----------------------------------------------------------------------------
48// internal classes
49//-----------------------------------------------------------------------------
50
1e6d9499
JS
51class WXDLLEXPORT wxListHeaderData;
52class WXDLLEXPORT wxListItemData;
53class WXDLLEXPORT wxListLineData;
c801d85f 54
1e6d9499
JS
55class WXDLLEXPORT wxListHeaderWindow;
56class WXDLLEXPORT wxListMainWindow;
c801d85f 57
1e6d9499 58class WXDLLEXPORT wxListRenameTimer;
e179bd65 59class WXDLLEXPORT wxListTextCtrl;
c801d85f 60
c801d85f
KB
61//-----------------------------------------------------------------------------
62// wxListCtrl
63//-----------------------------------------------------------------------------
64
3cd94a0d 65class WXDLLEXPORT wxGenericListCtrl: public wxControl
c801d85f 66{
b16088bf 67public:
3cd94a0d
JS
68 wxGenericListCtrl();
69 wxGenericListCtrl( wxWindow *parent,
674ac8b9
VZ
70 wxWindowID id = -1,
71 const wxPoint &pos = wxDefaultPosition,
72 const wxSize &size = wxDefaultSize,
73 long style = wxLC_ICON,
74 const wxValidator& validator = wxDefaultValidator,
2b5f62a0 75 const wxString &name = wxT("listctrl") )
32e9da8b 76 {
b16088bf 77 Create(parent, id, pos, size, style, validator, name);
32e9da8b 78 }
3cd94a0d 79 ~wxGenericListCtrl();
29149a64 80
674ac8b9
VZ
81 bool Create( wxWindow *parent,
82 wxWindowID id = -1,
83 const wxPoint &pos = wxDefaultPosition,
84 const wxSize &size = wxDefaultSize,
85 long style = wxLC_ICON,
86 const wxValidator& validator = wxDefaultValidator,
2b5f62a0 87 const wxString &name = wxT("listctrl") );
b16088bf 88
e487524e 89 bool GetColumn( int col, wxListItem& item ) const;
debe6624 90 bool SetColumn( int col, wxListItem& item );
e487524e 91 int GetColumnWidth( int col ) const;
debe6624 92 bool SetColumnWidth( int col, int width);
e179bd65 93 int GetCountPerPage() const; // not the same in wxGLC as in Windows, I think
b16088bf 94
e487524e 95 bool GetItem( wxListItem& info ) const;
c801d85f 96 bool SetItem( wxListItem& info ) ;
debe6624 97 long SetItem( long index, int col, const wxString& label, int imageId = -1 );
e487524e 98 int GetItemState( long item, long stateMask ) const;
debe6624
JS
99 bool SetItemState( long item, long state, long stateMask);
100 bool SetItemImage( long item, int image, int selImage);
e487524e 101 wxString GetItemText( long item ) const;
debe6624 102 void SetItemText( long item, const wxString& str );
e487524e 103 long GetItemData( long item ) const;
debe6624 104 bool SetItemData( long item, long data );
0a240683 105 bool GetItemRect( long item, wxRect& rect, int code = wxLIST_RECT_BOUNDS ) const;
e487524e 106 bool GetItemPosition( long item, wxPoint& pos ) const;
debe6624 107 bool SetItemPosition( long item, const wxPoint& pos ); // not supported in wxGLC
e179bd65
RR
108 int GetItemCount() const;
109 int GetColumnCount() const;
33d0b396 110 void SetItemSpacing( int spacing, bool isSmall = FALSE );
e487524e 111 int GetItemSpacing( bool isSmall ) const;
5b98eb2f
RL
112 void SetItemTextColour( long item, const wxColour& col);
113 wxColour GetItemTextColour( long item ) const;
114 void SetItemBackgroundColour( long item, const wxColour &col);
115 wxColour GetItemBackgroundColour( long item ) const;
e179bd65 116 int GetSelectedItemCount() const;
0530737d
VZ
117 wxColour GetTextColour() const;
118 void SetTextColour(const wxColour& col);
e179bd65 119 long GetTopItem() const;
b16088bf 120
debe6624 121 void SetSingleStyle( long style, bool add = TRUE ) ;
e179bd65
RR
122 void SetWindowStyleFlag( long style );
123 void RecreateWindow() {}
124 long GetNextItem( long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE ) const;
f9ceab7c
JS
125 wxImageListType *GetImageList( int which ) const;
126 void SetImageList( wxImageListType *imageList, int which );
127 void AssignImageList( wxImageListType *imageList, int which );
debe6624 128 bool Arrange( int flag = wxLIST_ALIGN_DEFAULT ); // always wxLIST_ALIGN_LEFT in wxGLC
57c4d796 129
4f22cf8d 130 void ClearAll();
debe6624 131 bool DeleteItem( long item );
e179bd65
RR
132 bool DeleteAllItems();
133 bool DeleteAllColumns();
debe6624 134 bool DeleteColumn( int col );
57c4d796 135
2c1f73ee
VZ
136 void SetItemCount(long count);
137
e179bd65
RR
138 void EditLabel( long item ) { Edit(item); }
139 void Edit( long item );
57c4d796 140
debe6624 141 bool EnsureVisible( long item );
e179bd65
RR
142 long FindItem( long start, const wxString& str, bool partial = FALSE );
143 long FindItem( long start, long data );
144 long FindItem( long start, const wxPoint& pt, int direction ); // not supported in wxGLC
145 long HitTest( const wxPoint& point, int& flags);
c801d85f 146 long InsertItem(wxListItem& info);
e179bd65
RR
147 long InsertItem( long index, const wxString& label );
148 long InsertItem( long index, int imageIndex );
149 long InsertItem( long index, const wxString& label, int imageIndex );
150 long InsertColumn( long col, wxListItem& info );
2f1e3c46
VZ
151 long InsertColumn( long col, const wxString& heading,
152 int format = wxLIST_FORMAT_LEFT, int width = -1 );
e179bd65
RR
153 bool ScrollList( int dx, int dy );
154 bool SortItems( wxListCtrlCompare fn, long data );
155 bool Update( long item );
29149a64 156
2c1f73ee
VZ
157 // returns true if it is a virtual list control
158 bool IsVirtual() const { return (GetWindowStyle() & wxLC_VIRTUAL) != 0; }
159
1a6cb56f
VZ
160 // refresh items selectively (only useful for virtual list controls)
161 void RefreshItem(long item);
162 void RefreshItems(long itemFrom, long itemTo);
163
164 // implementation only from now on
165 // -------------------------------
166
5180055b 167 void OnInternalIdle( );
b16088bf 168 void OnSize( wxSizeEvent &event );
57c4d796 169
77e7a1dc 170 // We have to hand down a few functions
2f1e3c46
VZ
171 virtual void Refresh(bool eraseBackground = TRUE,
172 const wxRect *rect = NULL);
57c4d796 173
c5c528fc
VZ
174 virtual void Freeze();
175 virtual void Thaw();
176
177 virtual bool SetBackgroundColour( const wxColour &colour );
178 virtual bool SetForegroundColour( const wxColour &colour );
179 virtual wxColour GetBackgroundColour() const;
180 virtual wxColour GetForegroundColour() const;
181 virtual bool SetFont( const wxFont &font );
182 virtual bool SetCursor( const wxCursor &cursor );
57c4d796 183
1e6d9499 184#if wxUSE_DRAG_AND_DROP
c5c528fc
VZ
185 virtual void SetDropTarget( wxDropTarget *dropTarget );
186 virtual wxDropTarget *GetDropTarget() const;
1e6d9499
JS
187#endif
188
c5c528fc
VZ
189 virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
190
191 virtual void SetFocus();
c801d85f 192
b16088bf
RR
193 // implementation
194 // --------------
57c4d796 195
f9ceab7c
JS
196 wxImageListType *m_imageListNormal;
197 wxImageListType *m_imageListSmall;
198 wxImageListType *m_imageListState; // what's that ?
29149a64 199 bool m_ownsImageListNormal,
2e12c11a
VS
200 m_ownsImageListSmall,
201 m_ownsImageListState;
c801d85f
KB
202 wxListHeaderWindow *m_headerWin;
203 wxListMainWindow *m_mainWin;
a3622daa 204
2c1f73ee
VZ
205protected:
206 // return the text for the given column of the given item
207 virtual wxString OnGetItemText(long item, long column) const;
208
209 // return the icon for the given item
210 virtual int OnGetItemImage(long item) const;
211
6c02c329
VZ
212 // return the attribute for the item (may return NULL if none)
213 virtual wxListItemAttr *OnGetItemAttr(long item) const;
214
2c1f73ee 215 // it calls our OnGetXXX() functions
ad08ef44 216 friend class WXDLLEXPORT wxListMainWindow;
2c1f73ee 217
b16088bf 218private:
210a651b 219 // Virtual function hiding supression
8ac7c509 220 virtual void Update() { wxWindow::Update(); }
210a651b 221
cf1dfa6b
VZ
222 // create the header window
223 void CreateHeaderWindow();
224
c0f8674c
VZ
225 // reposition the header and the main window in the report view depending
226 // on whether it should be shown or not
227 void ResizeReportView(bool showHeader);
228
b16088bf 229 DECLARE_EVENT_TABLE()
3cd94a0d 230 DECLARE_DYNAMIC_CLASS(wxGenericListCtrl);
c801d85f
KB
231};
232
b31989e2
JS
233#if !defined(__WXMSW__) || defined(__WIN16__) || defined(__WXUNIVERSAL__)
234/*
235 * wxListCtrl has to be a real class or we have problems with
236 * the run-time information.
237 */
c801d85f 238
b31989e2
JS
239class WXDLLEXPORT wxListCtrl: public wxGenericListCtrl
240{
241 DECLARE_DYNAMIC_CLASS(wxListCtrl)
242
243public:
244 wxListCtrl() {}
245
246 wxListCtrl(wxWindow *parent, wxWindowID id = -1,
247 const wxPoint& pos = wxDefaultPosition,
248 const wxSize& size = wxDefaultSize,
249 long style = wxLC_ICON,
250 const wxValidator &validator = wxDefaultValidator,
2b5f62a0 251 const wxString &name = wxT("listctrl") )
b31989e2
JS
252 : wxGenericListCtrl(parent, id, pos, size, style, validator, name)
253 {
254 }
255};
256#endif // !__WXMSW__ || __WIN16__ || __WXUNIVERSAL__
5b98eb2f 257
b31989e2 258#endif // __LISTCTRLH_G__