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