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