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