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