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