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