]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/listctrl.h
added wxCheckListBox::HitTest() (modified patch 594524)
[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
6// Id:
7// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
bdc72a22 8// Licence: wxWindows licence
c801d85f
KB
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef __LISTCTRLH_G__
12#define __LISTCTRLH_G__
13
14#ifdef __GNUG__
0d3820b3 15#pragma interface "listctrl.h"
c801d85f
KB
16#endif
17
18#include "wx/defs.h"
19#include "wx/object.h"
9cb07953 20#include "wx/generic/imaglist.h"
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"
c801d85f 28
1e6d9499
JS
29#if wxUSE_DRAG_AND_DROP
30class WXDLLEXPORT wxDropTarget;
31#endif
32
c801d85f
KB
33//-----------------------------------------------------------------------------
34// classes
35//-----------------------------------------------------------------------------
36
1e6d9499
JS
37class WXDLLEXPORT wxListItem;
38class WXDLLEXPORT wxListEvent;
39class WXDLLEXPORT wxListCtrl;
c801d85f
KB
40
41//-----------------------------------------------------------------------------
42// internal classes
43//-----------------------------------------------------------------------------
44
1e6d9499
JS
45class WXDLLEXPORT wxListHeaderData;
46class WXDLLEXPORT wxListItemData;
47class WXDLLEXPORT wxListLineData;
c801d85f 48
1e6d9499
JS
49class WXDLLEXPORT wxListHeaderWindow;
50class WXDLLEXPORT wxListMainWindow;
c801d85f 51
1e6d9499 52class WXDLLEXPORT wxListRenameTimer;
e179bd65 53class WXDLLEXPORT wxListTextCtrl;
c801d85f 54
c801d85f
KB
55//-----------------------------------------------------------------------------
56// wxListCtrl
57//-----------------------------------------------------------------------------
58
3cd94a0d 59class WXDLLEXPORT wxGenericListCtrl: public wxControl
c801d85f 60{
b16088bf 61public:
3cd94a0d
JS
62 wxGenericListCtrl();
63 wxGenericListCtrl( wxWindow *parent,
674ac8b9
VZ
64 wxWindowID id = -1,
65 const wxPoint &pos = wxDefaultPosition,
66 const wxSize &size = wxDefaultSize,
67 long style = wxLC_ICON,
68 const wxValidator& validator = wxDefaultValidator,
69 const wxString &name = "listctrl" )
32e9da8b 70 {
b16088bf 71 Create(parent, id, pos, size, style, validator, name);
32e9da8b 72 }
3cd94a0d 73 ~wxGenericListCtrl();
29149a64 74
674ac8b9
VZ
75 bool Create( wxWindow *parent,
76 wxWindowID id = -1,
77 const wxPoint &pos = wxDefaultPosition,
78 const wxSize &size = wxDefaultSize,
79 long style = wxLC_ICON,
80 const wxValidator& validator = wxDefaultValidator,
81 const wxString &name = "listctrl" );
b16088bf 82
e487524e 83 bool GetColumn( int col, wxListItem& item ) const;
debe6624 84 bool SetColumn( int col, wxListItem& item );
e487524e 85 int GetColumnWidth( int col ) const;
debe6624 86 bool SetColumnWidth( int col, int width);
e179bd65 87 int GetCountPerPage() const; // not the same in wxGLC as in Windows, I think
b16088bf 88
e487524e 89 bool GetItem( wxListItem& info ) const;
c801d85f 90 bool SetItem( wxListItem& info ) ;
debe6624 91 long SetItem( long index, int col, const wxString& label, int imageId = -1 );
e487524e 92 int GetItemState( long item, long stateMask ) const;
debe6624
JS
93 bool SetItemState( long item, long state, long stateMask);
94 bool SetItemImage( long item, int image, int selImage);
e487524e 95 wxString GetItemText( long item ) const;
debe6624 96 void SetItemText( long item, const wxString& str );
e487524e 97 long GetItemData( long item ) const;
debe6624 98 bool SetItemData( long item, long data );
0a240683 99 bool GetItemRect( long item, wxRect& rect, int code = wxLIST_RECT_BOUNDS ) const;
e487524e 100 bool GetItemPosition( long item, wxPoint& pos ) const;
debe6624 101 bool SetItemPosition( long item, const wxPoint& pos ); // not supported in wxGLC
e179bd65
RR
102 int GetItemCount() const;
103 int GetColumnCount() const;
33d0b396 104 void SetItemSpacing( int spacing, bool isSmall = FALSE );
e487524e 105 int GetItemSpacing( bool isSmall ) const;
5b98eb2f
RL
106 void SetItemTextColour( long item, const wxColour& col);
107 wxColour GetItemTextColour( long item ) const;
108 void SetItemBackgroundColour( long item, const wxColour &col);
109 wxColour GetItemBackgroundColour( long item ) const;
e179bd65 110 int GetSelectedItemCount() const;
0530737d
VZ
111 wxColour GetTextColour() const;
112 void SetTextColour(const wxColour& col);
e179bd65 113 long GetTopItem() const;
b16088bf 114
debe6624 115 void SetSingleStyle( long style, bool add = TRUE ) ;
e179bd65
RR
116 void SetWindowStyleFlag( long style );
117 void RecreateWindow() {}
118 long GetNextItem( long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE ) const;
9cb07953
JS
119 wxGenericImageList *GetImageList( int which ) const;
120 void SetImageList( wxGenericImageList *imageList, int which );
121 void AssignImageList( wxGenericImageList *imageList, int which );
debe6624 122 bool Arrange( int flag = wxLIST_ALIGN_DEFAULT ); // always wxLIST_ALIGN_LEFT in wxGLC
57c4d796 123
4f22cf8d 124 void ClearAll();
debe6624 125 bool DeleteItem( long item );
e179bd65
RR
126 bool DeleteAllItems();
127 bool DeleteAllColumns();
debe6624 128 bool DeleteColumn( int col );
57c4d796 129
2c1f73ee
VZ
130 void SetItemCount(long count);
131
e179bd65
RR
132 void EditLabel( long item ) { Edit(item); }
133 void Edit( long item );
57c4d796 134
debe6624 135 bool EnsureVisible( long item );
e179bd65
RR
136 long FindItem( long start, const wxString& str, bool partial = FALSE );
137 long FindItem( long start, long data );
138 long FindItem( long start, const wxPoint& pt, int direction ); // not supported in wxGLC
139 long HitTest( const wxPoint& point, int& flags);
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 );
145 long InsertColumn( long col, const wxString& heading, int format = wxLIST_FORMAT_LEFT,
146 int width = -1 );
147 bool ScrollList( int dx, int dy );
148 bool SortItems( wxListCtrlCompare fn, long data );
149 bool Update( long item );
29149a64 150
2c1f73ee
VZ
151 // returns true if it is a virtual list control
152 bool IsVirtual() const { return (GetWindowStyle() & wxLC_VIRTUAL) != 0; }
153
1a6cb56f
VZ
154 // refresh items selectively (only useful for virtual list controls)
155 void RefreshItem(long item);
156 void RefreshItems(long itemFrom, long itemTo);
157
158 // implementation only from now on
159 // -------------------------------
160
77e7a1dc 161 void OnIdle( wxIdleEvent &event );
b16088bf 162 void OnSize( wxSizeEvent &event );
57c4d796 163
77e7a1dc 164 // We have to hand down a few functions
57c4d796 165
c5c528fc
VZ
166 virtual void Freeze();
167 virtual void Thaw();
168
169 virtual bool SetBackgroundColour( const wxColour &colour );
170 virtual bool SetForegroundColour( const wxColour &colour );
171 virtual wxColour GetBackgroundColour() const;
172 virtual wxColour GetForegroundColour() const;
173 virtual bool SetFont( const wxFont &font );
174 virtual bool SetCursor( const wxCursor &cursor );
57c4d796 175
1e6d9499 176#if wxUSE_DRAG_AND_DROP
c5c528fc
VZ
177 virtual void SetDropTarget( wxDropTarget *dropTarget );
178 virtual wxDropTarget *GetDropTarget() const;
1e6d9499
JS
179#endif
180
c5c528fc
VZ
181 virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
182
183 virtual void SetFocus();
c801d85f 184
b16088bf
RR
185 // implementation
186 // --------------
57c4d796 187
9cb07953
JS
188 wxGenericImageList *m_imageListNormal;
189 wxGenericImageList *m_imageListSmall;
190 wxGenericImageList *m_imageListState; // what's that ?
29149a64 191 bool m_ownsImageListNormal,
2e12c11a
VS
192 m_ownsImageListSmall,
193 m_ownsImageListState;
c801d85f
KB
194 wxListHeaderWindow *m_headerWin;
195 wxListMainWindow *m_mainWin;
a3622daa 196
2c1f73ee
VZ
197protected:
198 // return the text for the given column of the given item
199 virtual wxString OnGetItemText(long item, long column) const;
200
201 // return the icon for the given item
202 virtual int OnGetItemImage(long item) const;
203
6c02c329
VZ
204 // return the attribute for the item (may return NULL if none)
205 virtual wxListItemAttr *OnGetItemAttr(long item) const;
206
2c1f73ee 207 // it calls our OnGetXXX() functions
ad08ef44 208 friend class WXDLLEXPORT wxListMainWindow;
2c1f73ee 209
b16088bf 210private:
210a651b 211 // Virtual function hiding supression
8ac7c509 212 virtual void Update() { wxWindow::Update(); }
210a651b 213
cf1dfa6b
VZ
214 // create the header window
215 void CreateHeaderWindow();
216
c0f8674c
VZ
217 // reposition the header and the main window in the report view depending
218 // on whether it should be shown or not
219 void ResizeReportView(bool showHeader);
220
b16088bf 221 DECLARE_EVENT_TABLE()
3cd94a0d 222 DECLARE_DYNAMIC_CLASS(wxGenericListCtrl);
c801d85f
KB
223};
224
b31989e2
JS
225#if !defined(__WXMSW__) || defined(__WIN16__) || defined(__WXUNIVERSAL__)
226/*
227 * wxListCtrl has to be a real class or we have problems with
228 * the run-time information.
229 */
c801d85f 230
b31989e2
JS
231class WXDLLEXPORT wxListCtrl: public wxGenericListCtrl
232{
233 DECLARE_DYNAMIC_CLASS(wxListCtrl)
234
235public:
236 wxListCtrl() {}
237
238 wxListCtrl(wxWindow *parent, wxWindowID id = -1,
239 const wxPoint& pos = wxDefaultPosition,
240 const wxSize& size = wxDefaultSize,
241 long style = wxLC_ICON,
242 const wxValidator &validator = wxDefaultValidator,
243 const wxString &name = "listctrl" )
244 : wxGenericListCtrl(parent, id, pos, size, style, validator, name)
245 {
246 }
247};
248#endif // !__WXMSW__ || __WIN16__ || __WXUNIVERSAL__
5b98eb2f 249
b31989e2 250#endif // __LISTCTRLH_G__