]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: listctrl.h | |
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 | |
8 | // Licence: wxWindows licence | |
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" | |
20 | #include "wx/imaglist.h" | |
21 | #include "wx/control.h" | |
22 | #include "wx/timer.h" | |
23 | #include "wx/dcclient.h" | |
24 | #include "wx/scrolwin.h" | |
25 | #include "wx/settings.h" | |
26 | ||
27 | //----------------------------------------------------------------------------- | |
28 | // classes | |
29 | //----------------------------------------------------------------------------- | |
30 | ||
31 | class wxListItem; | |
32 | class wxListEvent; | |
33 | class wxListCtrl; | |
34 | ||
35 | //----------------------------------------------------------------------------- | |
36 | // internal classes | |
37 | //----------------------------------------------------------------------------- | |
38 | ||
39 | class wxListHeaderData; | |
40 | class wxListItemData; | |
41 | class wxListLineData; | |
42 | ||
43 | class wxListHeaderWindow; | |
44 | class wxListMainWindow; | |
45 | ||
46 | class wxListRenameTimer; | |
47 | //class wxListTextCtrl; | |
48 | ||
49 | //----------------------------------------------------------------------------- | |
50 | // types | |
51 | //----------------------------------------------------------------------------- | |
52 | ||
53 | // type of compare function for wxListCtrl sort operation | |
debe6624 | 54 | typedef int (*wxListCtrlCompare)(long item1, long item2, long sortData); |
c801d85f KB |
55 | |
56 | //----------------------------------------------------------------------------- | |
57 | // wxListCtrl flags | |
58 | //----------------------------------------------------------------------------- | |
59 | ||
60 | #define wxLC_ICON 0x0004 | |
61 | #define wxLC_SMALL_ICON 0x0008 | |
62 | #define wxLC_LIST 0x0010 | |
63 | #define wxLC_REPORT 0x0020 | |
64 | #define wxLC_ALIGN_TOP 0x0040 | |
65 | #define wxLC_ALIGN_LEFT 0x0080 | |
66 | #define wxLC_AUTOARRANGE 0x0100 // not supported in wxGLC | |
67 | #define wxLC_USER_TEXT 0x0200 // not supported in wxGLC (how does it work?) | |
68 | #define wxLC_EDIT_LABELS 0x0400 | |
69 | #define wxLC_NO_HEADER 0x0800 // not supported in wxGLC | |
70 | #define wxLC_NO_SORT_HEADER 0x1000 // not supported in wxGLC | |
71 | #define wxLC_SINGLE_SEL 0x2000 | |
a3622daa | 72 | #define wxLC_SORT_ASCENDING 0x4000 |
c801d85f KB |
73 | #define wxLC_SORT_DESCENDING 0x8000 // not supported in wxGLC |
74 | ||
75 | #define wxLC_MASK_TYPE (wxLC_ICON | wxLC_SMALL_ICON | wxLC_LIST | wxLC_REPORT) | |
76 | #define wxLC_MASK_ALIGN (wxLC_ALIGN_TOP | wxLC_ALIGN_LEFT) | |
77 | #define wxLC_MASK_SORT (wxLC_SORT_ASCENDING | wxLC_SORT_DESCENDING) | |
78 | ||
79 | // Omitted because (a) too much detail (b) not enough style flags | |
80 | // #define wxLC_NO_SCROLL | |
81 | // #define wxLC_NO_LABEL_WRAP | |
82 | // #define wxLC_OWNERDRAW_FIXED | |
83 | // #define wxLC_SHOW_SEL_ALWAYS | |
84 | ||
85 | // Mask flags to tell app/GUI what fields of wxListItem are valid | |
86 | #define wxLIST_MASK_STATE 0x0001 | |
87 | #define wxLIST_MASK_TEXT 0x0002 | |
88 | #define wxLIST_MASK_IMAGE 0x0004 | |
89 | #define wxLIST_MASK_DATA 0x0008 | |
90 | #define wxLIST_SET_ITEM 0x0010 | |
91 | #define wxLIST_MASK_WIDTH 0x0020 | |
92 | #define wxLIST_MASK_FORMAT 0x0040 | |
93 | ||
94 | // State flags for indicating the state of an item | |
95 | #define wxLIST_STATE_DONTCARE 0x0000 | |
96 | #define wxLIST_STATE_DROPHILITED 0x0001 // not supported in wxGLC | |
97 | #define wxLIST_STATE_FOCUSED 0x0002 | |
a3622daa | 98 | #define wxLIST_STATE_SELECTED 0x0004 |
c801d85f KB |
99 | #define wxLIST_STATE_CUT 0x0008 // not supported in wxGLC |
100 | ||
101 | // Hit test flags, used in HitTest // wxGLC suppots 20 and 80 | |
102 | #define wxLIST_HITTEST_ABOVE 0x0001 // Above the client area. | |
103 | #define wxLIST_HITTEST_BELOW 0x0002 // Below the client area. | |
104 | #define wxLIST_HITTEST_NOWHERE 0x0004 // In the client area but below the last item. | |
105 | #define wxLIST_HITTEST_ONITEMICON 0x0020 // On the bitmap associated with an item. | |
106 | #define wxLIST_HITTEST_ONITEMLABEL 0x0080 // On the label (string) associated with an item. | |
107 | #define wxLIST_HITTEST_ONITEMRIGHT 0x0100 // In the area to the right of an item. | |
108 | #define wxLIST_HITTEST_ONITEMSTATEICON 0x0200 // On the state icon for a tree view item that is in a user-defined state. | |
109 | #define wxLIST_HITTEST_TOLEFT 0x0400 // To the right of the client area. | |
110 | #define wxLIST_HITTEST_TORIGHT 0x0800 // To the left of the client area. | |
111 | ||
112 | #define wxLIST_HITTEST_ONITEM (wxLIST_HITTEST_ONITEMICON | wxLIST_HITTEST_ONITEMLABEL | wxLIST_HITTEST_ONITEMSTATEICON) | |
113 | ||
114 | ||
115 | ||
116 | // Flags for GetNextItem // always wxLIST_NEXT_ALL in wxGLC | |
117 | enum { | |
118 | wxLIST_NEXT_ABOVE, // Searches for an item above the specified item | |
119 | wxLIST_NEXT_ALL, // Searches for subsequent item by index | |
120 | wxLIST_NEXT_BELOW, // Searches for an item below the specified item | |
121 | wxLIST_NEXT_LEFT, // Searches for an item to the left of the specified item | |
a3622daa | 122 | wxLIST_NEXT_RIGHT // Searches for an item to the right of the specified item |
c801d85f KB |
123 | }; |
124 | ||
125 | // Alignment flags for Arrange // always wxLIST_ALIGN_LEFT in wxGLC | |
126 | enum { | |
127 | wxLIST_ALIGN_DEFAULT, | |
128 | wxLIST_ALIGN_LEFT, | |
129 | wxLIST_ALIGN_TOP, | |
130 | wxLIST_ALIGN_SNAP_TO_GRID | |
131 | }; | |
132 | ||
133 | // Column format // always wxLIST_FORMAT_LEFT in wxGLC | |
134 | enum { | |
135 | wxLIST_FORMAT_LEFT, | |
136 | wxLIST_FORMAT_RIGHT, | |
137 | wxLIST_FORMAT_CENTRE, | |
138 | wxLIST_FORMAT_CENTER = wxLIST_FORMAT_CENTRE | |
139 | }; | |
140 | ||
141 | // Autosize values for SetColumnWidth | |
142 | enum { | |
143 | wxLIST_AUTOSIZE = -1, // always 80 in wxGLC (what else?) | |
144 | wxLIST_AUTOSIZE_USEHEADER = -2 | |
145 | }; | |
146 | ||
147 | // Flag values for GetItemRect | |
148 | enum { | |
149 | wxLIST_RECT_BOUNDS, | |
150 | wxLIST_RECT_ICON, | |
151 | wxLIST_RECT_LABEL | |
152 | }; | |
153 | ||
154 | // Flag values for FindItem // not supported by wxGLC | |
155 | enum { | |
156 | wxLIST_FIND_UP, | |
157 | wxLIST_FIND_DOWN, | |
158 | wxLIST_FIND_LEFT, | |
159 | wxLIST_FIND_RIGHT | |
160 | }; | |
161 | ||
c801d85f KB |
162 | //----------------------------------------------------------------------------- |
163 | // wxListItem | |
164 | //----------------------------------------------------------------------------- | |
165 | ||
166 | class wxListItem: public wxObject | |
167 | { | |
168 | DECLARE_DYNAMIC_CLASS(wxListItem) | |
169 | ||
170 | public: | |
171 | long m_mask; // Indicates what fields are valid | |
172 | long m_itemId; // The zero-based item position | |
173 | int m_col; // Zero-based column, if in report mode | |
174 | long m_state; // The state of the item | |
175 | long m_stateMask; // Which flags of m_state are valid (uses same flags) | |
176 | wxString m_text; // The label/header text | |
177 | int m_image; // The zero-based index into an image list | |
178 | long m_data; // App-defined data | |
179 | wxColour *m_colour; // only wxGLC, not supported by Windows ;-> | |
180 | ||
181 | // For columns only | |
182 | int m_format; // left, right, centre | |
183 | int m_width; // width of column | |
184 | ||
185 | wxListItem(void); | |
186 | }; | |
187 | ||
188 | //----------------------------------------------------------------------------- | |
189 | // wxListEvent | |
190 | //----------------------------------------------------------------------------- | |
191 | ||
192 | class WXDLLEXPORT wxListEvent: public wxCommandEvent | |
193 | { | |
194 | DECLARE_DYNAMIC_CLASS(wxListEvent) | |
195 | ||
196 | public: | |
64693098 | 197 | wxListEvent(wxEventType commandType = wxEVT_NULL, int id = 0); |
c801d85f KB |
198 | |
199 | int m_code; | |
200 | long m_itemIndex; | |
201 | long m_oldItemIndex; | |
202 | int m_col; | |
203 | bool m_cancelled; | |
204 | wxPoint m_pointDrag; | |
205 | ||
206 | wxListItem m_item; | |
207 | }; | |
208 | ||
209 | typedef void (wxEvtHandler::*wxListEventFunction)(wxListEvent&); | |
210 | ||
fe71f65c RR |
211 | #define EVT_LIST_BEGIN_DRAG(id, fn) { wxEVT_COMMAND_LIST_BEGIN_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL }, |
212 | #define EVT_LIST_BEGIN_RDRAG(id, fn) { wxEVT_COMMAND_LIST_BEGIN_RDRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL }, | |
213 | #define EVT_LIST_BEGIN_LABEL_EDIT(id, fn) { wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL }, | |
214 | #define EVT_LIST_END_LABEL_EDIT(id, fn) { wxEVT_COMMAND_LIST_END_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL }, | |
215 | #define EVT_LIST_DELETE_ITEM(id, fn) { wxEVT_COMMAND_LIST_DELETE_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL }, | |
216 | #define EVT_LIST_DELETE_ALL_ITEMS(id, fn) { wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL }, | |
217 | #define EVT_LIST_GET_INFO(id, fn) { wxEVT_COMMAND_LIST_GET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL }, | |
218 | #define EVT_LIST_SET_INFO(id, fn) { wxEVT_COMMAND_LIST_SET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL }, | |
219 | #define EVT_LIST_ITEM_SELECTED(id, fn) { wxEVT_COMMAND_LIST_ITEM_SELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL }, | |
220 | #define EVT_LIST_ITEM_DESELECTED(id, fn) { wxEVT_COMMAND_LIST_ITEM_DESELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL }, | |
221 | #define EVT_LIST_KEY_DOWN(id, fn) { wxEVT_COMMAND_LIST_KEY_DOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL }, | |
222 | #define EVT_LIST_INSERT_ITEM(id, fn) { wxEVT_COMMAND_LIST_INSERT_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL }, | |
223 | #define EVT_LIST_COL_CLICK(id, fn) { wxEVT_COMMAND_LIST_COL_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL }, | |
c801d85f KB |
224 | |
225 | ||
226 | //----------------------------------------------------------------------------- | |
227 | // wxListItemData (internal) | |
228 | //----------------------------------------------------------------------------- | |
229 | ||
230 | class wxListItemData : public wxObject | |
231 | { | |
232 | DECLARE_DYNAMIC_CLASS(wxListItemData); | |
233 | ||
234 | protected: | |
235 | wxString m_text; | |
236 | int m_image; | |
237 | long m_data; | |
238 | int m_xpos,m_ypos; | |
239 | int m_width,m_height; | |
240 | wxColour *m_colour; | |
a3622daa | 241 | |
c801d85f KB |
242 | public: |
243 | wxListItemData(void); | |
244 | wxListItemData( const wxListItem &info ); | |
245 | void SetItem( const wxListItem &info ); | |
246 | void SetText( const wxString &s ); | |
debe6624 JS |
247 | void SetImage( int image ); |
248 | void SetData( long data ); | |
249 | void SetPosition( int x, int y ); | |
250 | void SetSize( int width, int height ); | |
c801d85f KB |
251 | void SetColour( wxColour *col ); |
252 | bool HasImage(void) const; | |
253 | bool HasText(void) const; | |
debe6624 | 254 | bool IsHit( int x, int y ) const; |
c801d85f KB |
255 | void GetText( wxString &s ); |
256 | int GetX( void ) const; | |
257 | int GetY( void ) const; | |
258 | int GetWidth(void) const; | |
259 | int GetHeight(void) const; | |
260 | int GetImage(void) const; | |
261 | void GetItem( wxListItem &info ); | |
262 | wxColour *GetColour(void); | |
263 | }; | |
264 | ||
265 | //----------------------------------------------------------------------------- | |
266 | // wxListHeaderData (internal) | |
267 | //----------------------------------------------------------------------------- | |
268 | ||
269 | class wxListHeaderData : public wxObject | |
270 | { | |
271 | DECLARE_DYNAMIC_CLASS(wxListHeaderData); | |
272 | ||
273 | protected: | |
274 | long m_mask; | |
275 | int m_image; | |
276 | wxString m_text; | |
277 | int m_format; | |
278 | int m_width; | |
279 | int m_xpos,m_ypos; | |
280 | int m_height; | |
a3622daa | 281 | |
c801d85f KB |
282 | public: |
283 | wxListHeaderData(void); | |
284 | wxListHeaderData( const wxListItem &info ); | |
285 | void SetItem( const wxListItem &item ); | |
debe6624 JS |
286 | void SetPosition( int x, int y ); |
287 | void SetWidth( int w ); | |
288 | void SetFormat( int format ); | |
289 | void SetHeight( int h ); | |
c801d85f KB |
290 | bool HasImage(void) const; |
291 | bool HasText(void) const; | |
debe6624 | 292 | bool IsHit( int x, int y ) const; |
c801d85f KB |
293 | void GetItem( wxListItem &item ); |
294 | void GetText( wxString &s ); | |
295 | int GetImage(void) const; | |
296 | int GetWidth(void) const; | |
297 | int GetFormat(void) const; | |
298 | }; | |
299 | ||
300 | //----------------------------------------------------------------------------- | |
301 | // wxListLineData (internal) | |
302 | //----------------------------------------------------------------------------- | |
303 | ||
304 | class wxListLineData : public wxObject | |
305 | { | |
306 | DECLARE_DYNAMIC_CLASS(wxListLineData); | |
307 | ||
308 | protected: | |
309 | wxList m_items; | |
310 | wxRectangle m_bound_all; | |
311 | wxRectangle m_bound_label; | |
312 | wxRectangle m_bound_icon; | |
313 | wxRectangle m_bound_hilight; | |
314 | int m_mode; | |
315 | bool m_hilighted; | |
316 | wxBrush *m_hilightBrush; | |
317 | int m_spacing; | |
318 | wxListMainWindow *m_owner; | |
319 | ||
debe6624 | 320 | void DoDraw( wxPaintDC *dc, bool hilight, bool paintBG ); |
c801d85f KB |
321 | |
322 | public: | |
323 | wxListLineData( void ) {}; | |
debe6624 JS |
324 | wxListLineData( wxListMainWindow *owner, int mode, wxBrush *hilightBrush ); |
325 | void CalculateSize( wxPaintDC *dc, int spacing ); | |
326 | void SetPosition( wxPaintDC *dc, int x, int y, int window_width ); | |
327 | void SetColumnPosition( int index, int x ); | |
c801d85f KB |
328 | void GetSize( int &width, int &height ); |
329 | void GetExtent( int &x, int &y, int &width, int &height ); | |
330 | void GetLabelExtent( int &x, int &y, int &width, int &height ); | |
debe6624 JS |
331 | long IsHit( int x, int y ); |
332 | void InitItems( int num ); | |
333 | void SetItem( int index, const wxListItem &info ); | |
334 | void GetItem( int index, wxListItem &info ); | |
335 | void GetText( int index, wxString &s ); | |
336 | void SetText( int index, const wxString s ); | |
337 | int GetImage( int index ); | |
c801d85f | 338 | void GetRect( wxRectangle &rect ); |
debe6624 | 339 | void Hilight( bool on ); |
c801d85f | 340 | void ReverseHilight( void ); |
debe6624 | 341 | void DrawRubberBand( wxPaintDC *dc, bool on ); |
c801d85f | 342 | void Draw( wxPaintDC *dc ); |
debe6624 | 343 | bool IsInRect( int x, int y, const wxRectangle &rect ); |
c801d85f | 344 | bool IsHilighted( void ); |
debe6624 | 345 | void AssignRect( wxRectangle &dest, int x, int y, int width, int height ); |
c801d85f KB |
346 | void AssignRect( wxRectangle &dest, const wxRectangle &source ); |
347 | }; | |
348 | ||
349 | //----------------------------------------------------------------------------- | |
350 | // wxListHeaderWindow (internal) | |
351 | //----------------------------------------------------------------------------- | |
352 | ||
353 | class wxListHeaderWindow : public wxWindow | |
354 | { | |
355 | DECLARE_DYNAMIC_CLASS(wxListHeaderWindow) | |
356 | ||
357 | protected: | |
358 | wxListMainWindow *m_owner; | |
359 | wxCursor *m_currentCursor; | |
360 | wxCursor *m_resizeCursor; | |
361 | ||
362 | public: | |
363 | wxListHeaderWindow( void ); | |
a3622daa | 364 | wxListHeaderWindow( wxWindow *win, wxWindowID id, wxListMainWindow *owner, |
debe6624 JS |
365 | const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, |
366 | long style = 0, const wxString &name = "columntitles" ); | |
c801d85f KB |
367 | void DoDrawRect( wxPaintDC *dc, int x, int y, int w, int h ); |
368 | void OnPaint( wxPaintEvent &event ); | |
369 | void OnMouse( wxMouseEvent &event ); | |
370 | void OnSetFocus( wxFocusEvent &event ); | |
a3622daa | 371 | |
c801d85f KB |
372 | DECLARE_EVENT_TABLE() |
373 | }; | |
374 | ||
375 | //----------------------------------------------------------------------------- | |
376 | // wxListRenameTimer (internal) | |
377 | //----------------------------------------------------------------------------- | |
378 | ||
379 | class wxListRenameTimer: public wxTimer | |
380 | { | |
381 | private: | |
382 | wxListMainWindow *m_owner; | |
a3622daa | 383 | |
c801d85f KB |
384 | public: |
385 | wxListRenameTimer( wxListMainWindow *owner ); | |
386 | void Notify(); | |
387 | }; | |
388 | ||
389 | /* | |
390 | ||
391 | //----------------------------------------------------------------------------- | |
392 | // wxListTextCtrl (internal) | |
393 | //----------------------------------------------------------------------------- | |
394 | ||
395 | class wxListTextCtrl: public wxTextCtrl | |
396 | { | |
397 | DECLARE_DYNAMIC_CLASS(wxListTextCtrl); | |
a3622daa | 398 | |
c801d85f KB |
399 | private: |
400 | bool *m_accept; | |
401 | wxString *m_res; | |
402 | wxListMainWindow *m_owner; | |
403 | ||
404 | public: | |
405 | wxListTextCtrl(void) : wxTextCtrl() {}; | |
a3622daa | 406 | wxListTextCtrl( wxWindow *parent, const char *value = "", |
c801d85f KB |
407 | bool *accept, wxString *res, wxListMainWindow *owner, |
408 | int x = -1, int y = -1, int w = -1, int h = -1, int style = 0, char *name = "rawtext" ) : | |
a3622daa | 409 | wxTextCtrl( parent, value, x, y, w, h, style, name ) |
c801d85f KB |
410 | { |
411 | m_res = res; | |
412 | m_accept = accept; | |
413 | m_owner = owner; | |
414 | }; | |
415 | void OnChar( wxKeyEvent &event ) | |
416 | { | |
417 | if (event.keyCode == WXK_RETURN) | |
418 | { | |
419 | (*m_accept) = TRUE; | |
420 | (*m_res) = GetValue(); | |
421 | m_owner->OnRenameAccept(); | |
422 | // Show( FALSE ); | |
423 | delete this; | |
424 | return; | |
425 | }; | |
426 | if (event.keyCode == WXK_ESCAPE) | |
427 | { | |
428 | (*m_accept) = FALSE; | |
429 | (*m_res) = ""; | |
430 | // Show( FALSE ); | |
431 | delete this; | |
432 | return; | |
433 | }; | |
434 | }; | |
435 | void OnKillFocus(void) | |
436 | { | |
437 | (*m_accept) = FALSE; | |
438 | (*m_res) = ""; | |
439 | // Show( FALSE ); | |
440 | delete this; | |
441 | return; | |
442 | }; | |
443 | }; | |
444 | ||
445 | */ | |
446 | ||
447 | //----------------------------------------------------------------------------- | |
448 | // wxListMainWindow (internal) | |
449 | //----------------------------------------------------------------------------- | |
450 | ||
451 | class wxListMainWindow: public wxScrolledWindow | |
452 | { | |
453 | DECLARE_DYNAMIC_CLASS(wxListMainWindow); | |
454 | ||
455 | public: | |
456 | long m_mode; | |
457 | wxList m_lines; | |
a3622daa | 458 | wxList m_columns; |
c801d85f KB |
459 | wxListLineData *m_current; |
460 | int m_visibleLines; | |
461 | wxBrush *m_hilightBrush; | |
462 | wxColour *m_hilightColour; | |
463 | wxFont *m_myFont; | |
464 | int m_xScroll,m_yScroll; | |
465 | bool m_dirty; | |
466 | wxImageList *m_small_image_list; | |
467 | wxImageList *m_normal_image_list; | |
468 | int m_small_spacing; | |
469 | int m_normal_spacing; | |
470 | bool m_hasFocus; | |
471 | bool m_usedKeys; | |
472 | bool m_lastOnSame; | |
473 | wxTimer *m_renameTimer; | |
474 | // wxListTextCtrl *m_text; | |
475 | bool m_renameAccept; | |
476 | wxString m_renameRes; | |
477 | bool m_isCreated; | |
e3e65dac | 478 | int m_dragCount; |
c801d85f KB |
479 | |
480 | public: | |
a3622daa VZ |
481 | wxListMainWindow(void); |
482 | wxListMainWindow( wxWindow *parent, wxWindowID id, | |
debe6624 JS |
483 | const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, |
484 | long style = 0, const wxString &name = "listctrl" ); | |
c801d85f KB |
485 | ~wxListMainWindow(void); |
486 | void RefreshLine( wxListLineData *line ); | |
487 | void OnPaint( wxPaintEvent &event ); | |
debe6624 | 488 | void HilightAll( bool on ); |
c801d85f | 489 | void ActivateLine( wxListLineData *line ); |
64693098 | 490 | void SendNotify( wxListLineData *line, wxEventType command ); |
c801d85f KB |
491 | void FocusLine( wxListLineData *line ); |
492 | void UnfocusLine( wxListLineData *line ); | |
493 | void SelectLine( wxListLineData *line ); | |
494 | void DeselectLine( wxListLineData *line ); | |
495 | void DeleteLine( wxListLineData *line ); | |
496 | void RenameLine( wxListLineData *line, const wxString &newName ); | |
497 | void OnRenameTimer(void); | |
498 | void OnRenameAccept(void); | |
499 | void OnMouse( wxMouseEvent &event ); | |
500 | void MoveToFocus( void ); | |
501 | void OnArrowChar( wxListLineData *newCurrent, bool shiftDown ); | |
502 | void OnChar( wxKeyEvent &event ); | |
503 | void OnSetFocus( wxFocusEvent &event ); | |
504 | void OnKillFocus( wxFocusEvent &event ); | |
505 | void OnSize( wxSizeEvent &event ); | |
506 | wxFont *GetMyFont( void ); | |
507 | void DrawImage( int index, wxPaintDC *dc, int x, int y ); | |
508 | void GetImageSize( int index, int &width, int &height ); | |
509 | int GetIndexOfLine( const wxListLineData *line ); | |
510 | int GetTextLength( wxString &s ); // should be const | |
511 | ||
debe6624 JS |
512 | void SetImageList( wxImageList *imageList, int which ); |
513 | void SetItemSpacing( int spacing, bool isSmall = FALSE ); | |
514 | int GetItemSpacing( bool isSmall = FALSE ); | |
515 | void SetColumn( int col, wxListItem &item ); | |
516 | void SetColumnWidth( int col, int width ); | |
517 | void GetColumn( int col, wxListItem &item ); | |
518 | int GetColumnWidth( int vol ); | |
c801d85f | 519 | int GetColumnCount( void ); |
a3622daa | 520 | int GetCountPerPage( void ); |
c801d85f KB |
521 | void SetItem( wxListItem &item ); |
522 | void GetItem( wxListItem &item ); | |
a3622daa | 523 | void SetItemState( long item, long state, long stateMask ); |
debe6624 | 524 | int GetItemState( long item, long stateMask ); |
c801d85f | 525 | int GetItemCount( void ); |
debe6624 | 526 | void GetItemRect( long index, wxRectangle &rect ); |
e3e65dac | 527 | bool GetItemPosition(long item, wxPoint& pos); |
c801d85f | 528 | int GetSelectedItemCount( void ); |
debe6624 | 529 | void SetMode( long mode ); |
c801d85f KB |
530 | long GetMode( void ) const; |
531 | void CalculatePositions( void ); | |
532 | void RealizeChanges(void); | |
debe6624 JS |
533 | long GetNextItem( long item, int geometry, int state ); |
534 | void DeleteItem( long index ); | |
c801d85f | 535 | void DeleteAllItems( void ); |
debe6624 | 536 | void DeleteColumn( int col ); |
c801d85f | 537 | void DeleteEverything( void ); |
debe6624 JS |
538 | void EnsureVisible( long index ); |
539 | long FindItem(long start, const wxString& str, bool partial = FALSE ); | |
540 | long FindItem(long start, long data); | |
541 | long HitTest( int x, int y, int &flags ); | |
c801d85f | 542 | void InsertItem( wxListItem &item ); |
30dea054 | 543 | // void AddItem( wxListItem &item ); |
debe6624 | 544 | void InsertColumn( long col, wxListItem &item ); |
30dea054 | 545 | // void AddColumn( wxListItem &item ); |
c801d85f KB |
546 | void SortItems( wxListCtrlCompare fn, long data ); |
547 | virtual bool OnListNotify( wxListEvent &event ); | |
a3622daa | 548 | |
c801d85f KB |
549 | DECLARE_EVENT_TABLE() |
550 | }; | |
551 | ||
552 | //----------------------------------------------------------------------------- | |
553 | // wxListCtrl | |
554 | //----------------------------------------------------------------------------- | |
555 | ||
556 | class wxListCtrl: public wxControl | |
557 | { | |
558 | DECLARE_DYNAMIC_CLASS(wxListCtrl); | |
a3622daa | 559 | |
c801d85f | 560 | public: |
a3622daa | 561 | |
c801d85f | 562 | wxListCtrl(void); |
a3622daa | 563 | wxListCtrl( wxWindow *parent, wxWindowID id, |
debe6624 JS |
564 | const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, |
565 | long style = 0, const wxString &name = "listctrl" ); | |
c801d85f | 566 | ~wxListCtrl(void); |
a3622daa | 567 | bool Create( wxWindow *parent, wxWindowID id, |
debe6624 JS |
568 | const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, |
569 | long style = 0, const wxString &name = "listctrl" ); | |
c801d85f KB |
570 | void OnSize( wxSizeEvent &event ); |
571 | void SetBackgroundColour( const wxColour& col ); | |
debe6624 JS |
572 | bool GetColumn( int col, wxListItem& item ); |
573 | bool SetColumn( int col, wxListItem& item ); | |
574 | int GetColumnWidth( int col ); | |
575 | bool SetColumnWidth( int col, int width); | |
c801d85f KB |
576 | int GetCountPerPage(void); // not the same in wxGLC as in Windows, I think |
577 | // wxText& GetEditControl(void) const; // not supported in wxGLC | |
578 | bool GetItem( wxListItem& info ); | |
579 | bool SetItem( wxListItem& info ) ; | |
debe6624 JS |
580 | long SetItem( long index, int col, const wxString& label, int imageId = -1 ); |
581 | int GetItemState( long item, long stateMask ); | |
582 | bool SetItemState( long item, long state, long stateMask); | |
583 | bool SetItemImage( long item, int image, int selImage); | |
584 | wxString GetItemText( long item ); | |
585 | void SetItemText( long item, const wxString& str ); | |
586 | long GetItemData( long item ); | |
587 | bool SetItemData( long item, long data ); | |
a3622daa | 588 | bool GetItemRect( long item, wxRectangle& rect, int code = wxLIST_RECT_BOUNDS ); |
e3e65dac | 589 | bool GetItemPosition( long item, wxPoint& pos ); |
debe6624 | 590 | bool SetItemPosition( long item, const wxPoint& pos ); // not supported in wxGLC |
c801d85f | 591 | int GetItemCount(void); |
33d0b396 | 592 | void SetItemSpacing( int spacing, bool isSmall = FALSE ); |
c801d85f KB |
593 | int GetItemSpacing( bool isSmall ); |
594 | int GetSelectedItemCount(void); | |
595 | // wxColour GetTextColour(void) const; // wxGLC has colours for every Item (see wxListItem) | |
596 | // void SetTextColour(const wxColour& col); | |
597 | long GetTopItem(void); | |
debe6624 JS |
598 | void SetSingleStyle( long style, bool add = TRUE ) ; |
599 | void SetWindowStyleFlag(long style); | |
c801d85f | 600 | void RecreateWindow(void) {}; |
debe6624 JS |
601 | long GetNextItem(long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE); |
602 | wxImageList *GetImageList(int which); | |
603 | void SetImageList(wxImageList *imageList, int which) ; | |
604 | bool Arrange( int flag = wxLIST_ALIGN_DEFAULT ); // always wxLIST_ALIGN_LEFT in wxGLC | |
605 | bool DeleteItem( long item ); | |
c801d85f | 606 | bool DeleteAllItems(void) ; |
debe6624 JS |
607 | bool DeleteColumn( int col ); |
608 | // wxText& Edit(long item) ; // not supported in wxGLC | |
609 | bool EnsureVisible( long item ); | |
610 | long FindItem(long start, const wxString& str, bool partial = FALSE ); | |
611 | long FindItem(long start, long data); | |
612 | long FindItem(long start, const wxPoint& pt, int direction); // not supported in wxGLC | |
c801d85f KB |
613 | long HitTest(const wxPoint& point, int& flags); |
614 | long InsertItem(wxListItem& info); | |
debe6624 JS |
615 | long InsertItem(long index, const wxString& label); |
616 | long InsertItem(long index, int imageIndex); | |
617 | long InsertItem(long index, const wxString& label, int imageIndex); | |
618 | long InsertColumn(long col, wxListItem& info); | |
619 | long InsertColumn(long col, const wxString& heading, int format = wxLIST_FORMAT_LEFT, | |
620 | int width = -1); | |
621 | bool ScrollList(int dx, int dy); | |
c801d85f | 622 | bool SortItems(wxListCtrlCompare fn, long data); |
debe6624 | 623 | bool Update(long item); |
c801d85f KB |
624 | virtual bool OnListNotify(wxListEvent& WXUNUSED(event)) { return FALSE; } |
625 | void SetDropTarget( wxDropTarget *dropTarget ) | |
626 | { m_mainWin->SetDropTarget( dropTarget ); }; | |
627 | wxDropTarget *GetDropTarget() const | |
628 | { return m_mainWin->GetDropTarget(); }; | |
a3622daa | 629 | |
53010e52 | 630 | void OnIdle( wxIdleEvent &event ); |
c801d85f KB |
631 | |
632 | protected: | |
a3622daa | 633 | |
c801d85f | 634 | // wxListTextCtrl m_textCtrl; |
a3622daa VZ |
635 | wxImageList *m_imageListNormal; |
636 | wxImageList *m_imageListSmall; | |
c801d85f KB |
637 | wxImageList *m_imageListState; // what's that ? |
638 | wxListHeaderWindow *m_headerWin; | |
639 | wxListMainWindow *m_mainWin; | |
a3622daa | 640 | |
c801d85f KB |
641 | DECLARE_EVENT_TABLE() |
642 | ||
643 | }; | |
644 | ||
645 | ||
646 | #endif // __LISTCTRLH_G__ |