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