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