]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/listctrl.cpp
Commited Bryan Petty's blind fix patch.
[wxWidgets.git] / src / palmos / listctrl.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/listctrl.cpp
3 // Purpose: wxListCtrl
4 // Author: William Osborne - minimal working wxPalmOS port
5 // Modified by:
6 // Created: 10/13/04
7 // RCS-ID: $Id$
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 #if wxUSE_LISTCTRL
28
29 #ifndef WX_PRECOMP
30 #include "wx/app.h"
31 #include "wx/intl.h"
32 #include "wx/log.h"
33 #include "wx/settings.h"
34 #include "wx/dcclient.h"
35 #include "wx/textctrl.h"
36 #endif
37
38 #include "wx/imaglist.h"
39 #include "wx/listctrl.h"
40
41 // ----------------------------------------------------------------------------
42 // events
43 // ----------------------------------------------------------------------------
44
45 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_DRAG)
46 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_RDRAG)
47 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT)
48 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_END_LABEL_EDIT)
49 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_DELETE_ITEM)
50 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS)
51 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_GET_INFO)
52 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_SET_INFO)
53 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_SELECTED)
54 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_DESELECTED)
55 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_KEY_DOWN)
56 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_INSERT_ITEM)
57 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_CLICK)
58 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_RIGHT_CLICK)
59 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_BEGIN_DRAG)
60 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_DRAGGING)
61 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_END_DRAG)
62 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK)
63 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK)
64 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_ACTIVATED)
65 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_FOCUSED)
66 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_CACHE_HINT)
67
68 #if wxUSE_EXTENDED_RTTI
69 WX_DEFINE_FLAGS( wxListCtrlStyle )
70
71 wxBEGIN_FLAGS( wxListCtrlStyle )
72 // new style border flags, we put them first to
73 // use them for streaming out
74 wxFLAGS_MEMBER(wxBORDER_SIMPLE)
75 wxFLAGS_MEMBER(wxBORDER_SUNKEN)
76 wxFLAGS_MEMBER(wxBORDER_DOUBLE)
77 wxFLAGS_MEMBER(wxBORDER_RAISED)
78 wxFLAGS_MEMBER(wxBORDER_STATIC)
79 wxFLAGS_MEMBER(wxBORDER_NONE)
80
81 // old style border flags
82 wxFLAGS_MEMBER(wxSIMPLE_BORDER)
83 wxFLAGS_MEMBER(wxSUNKEN_BORDER)
84 wxFLAGS_MEMBER(wxDOUBLE_BORDER)
85 wxFLAGS_MEMBER(wxRAISED_BORDER)
86 wxFLAGS_MEMBER(wxSTATIC_BORDER)
87 wxFLAGS_MEMBER(wxBORDER)
88
89 // standard window styles
90 wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
91 wxFLAGS_MEMBER(wxCLIP_CHILDREN)
92 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
93 wxFLAGS_MEMBER(wxWANTS_CHARS)
94 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
95 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
96 wxFLAGS_MEMBER(wxVSCROLL)
97 wxFLAGS_MEMBER(wxHSCROLL)
98
99 wxFLAGS_MEMBER(wxLC_LIST)
100 wxFLAGS_MEMBER(wxLC_REPORT)
101 wxFLAGS_MEMBER(wxLC_ICON)
102 wxFLAGS_MEMBER(wxLC_SMALL_ICON)
103 wxFLAGS_MEMBER(wxLC_ALIGN_TOP)
104 wxFLAGS_MEMBER(wxLC_ALIGN_LEFT)
105 wxFLAGS_MEMBER(wxLC_AUTOARRANGE)
106 wxFLAGS_MEMBER(wxLC_USER_TEXT)
107 wxFLAGS_MEMBER(wxLC_EDIT_LABELS)
108 wxFLAGS_MEMBER(wxLC_NO_HEADER)
109 wxFLAGS_MEMBER(wxLC_SINGLE_SEL)
110 wxFLAGS_MEMBER(wxLC_SORT_ASCENDING)
111 wxFLAGS_MEMBER(wxLC_SORT_DESCENDING)
112 wxFLAGS_MEMBER(wxLC_VIRTUAL)
113
114 wxEND_FLAGS( wxListCtrlStyle )
115
116 IMPLEMENT_DYNAMIC_CLASS_XTI(wxListCtrl, wxControl,"wx/listctrl.h")
117
118 wxBEGIN_PROPERTIES_TABLE(wxListCtrl)
119 wxEVENT_PROPERTY( TextUpdated , wxEVT_COMMAND_TEXT_UPDATED , wxCommandEvent )
120
121 wxPROPERTY_FLAGS( WindowStyle , wxListCtrlStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
122 wxEND_PROPERTIES_TABLE()
123
124 wxBEGIN_HANDLERS_TABLE(wxListCtrl)
125 wxEND_HANDLERS_TABLE()
126
127 wxCONSTRUCTOR_5( wxListCtrl , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size , long , WindowStyle )
128
129 /*
130 TODO : Expose more information of a list's layout etc. via appropriate objects (à la NotebookPageInfo)
131 */
132 #else
133 IMPLEMENT_DYNAMIC_CLASS(wxListCtrl, wxControl)
134 #endif
135
136 IMPLEMENT_DYNAMIC_CLASS(wxListView, wxListCtrl)
137 IMPLEMENT_DYNAMIC_CLASS(wxListItem, wxObject)
138
139 IMPLEMENT_DYNAMIC_CLASS(wxListEvent, wxNotifyEvent)
140
141 BEGIN_EVENT_TABLE(wxListCtrl, wxControl)
142 EVT_PAINT(wxListCtrl::OnPaint)
143 END_EVENT_TABLE()
144
145 // ============================================================================
146 // implementation
147 // ============================================================================
148
149 // ----------------------------------------------------------------------------
150 // wxListCtrl construction
151 // ----------------------------------------------------------------------------
152
153 void wxListCtrl::Init()
154 {
155 }
156
157 bool wxListCtrl::Create(wxWindow *parent,
158 wxWindowID id,
159 const wxPoint& pos,
160 const wxSize& size,
161 long style,
162 const wxValidator& validator,
163 const wxString& name)
164 {
165 return false;
166 }
167
168 void wxListCtrl::UpdateStyle()
169 {
170 }
171
172 void wxListCtrl::FreeAllInternalData()
173 {
174 }
175
176 wxListCtrl::~wxListCtrl()
177 {
178 }
179
180 // ----------------------------------------------------------------------------
181 // set/get/change style
182 // ----------------------------------------------------------------------------
183
184 // Add or remove a single window style
185 void wxListCtrl::SetSingleStyle(long style, bool add)
186 {
187 }
188
189 // ----------------------------------------------------------------------------
190 // accessors
191 // ----------------------------------------------------------------------------
192
193 /* static */ wxVisualAttributes wxListCtrl::GetClassDefaultAttributes(wxWindowVariant variant)
194 {
195 wxVisualAttributes attrs;
196
197 return attrs;
198 }
199
200 // Sets the foreground, i.e. text, colour
201 bool wxListCtrl::SetForegroundColour(const wxColour& col)
202 {
203 return false;
204 }
205
206 // Sets the background colour
207 bool wxListCtrl::SetBackgroundColour(const wxColour& col)
208 {
209 return false;
210 }
211
212 // Gets information about this column
213 bool wxListCtrl::GetColumn(int col, wxListItem& item) const
214 {
215 return false;
216 }
217
218 // Sets information about this column
219 bool wxListCtrl::SetColumn(int col, wxListItem& item)
220 {
221 return false;
222 }
223
224 // Gets the column width
225 int wxListCtrl::GetColumnWidth(int col) const
226 {
227 return 0;
228 }
229
230 // Sets the column width
231 bool wxListCtrl::SetColumnWidth(int col, int width)
232 {
233 return false;
234 }
235
236 // Gets the number of items that can fit vertically in the
237 // visible area of the list control (list or report view)
238 // or the total number of items in the list control (icon
239 // or small icon view)
240 int wxListCtrl::GetCountPerPage() const
241 {
242 return 0;
243 }
244
245 // Gets the edit control for editing labels.
246 wxTextCtrl* wxListCtrl::GetEditControl() const
247 {
248 return NULL;
249 }
250
251 // Gets information about the item
252 bool wxListCtrl::GetItem(wxListItem& info) const
253 {
254 return false;
255 }
256
257 // Sets information about the item
258 bool wxListCtrl::SetItem(wxListItem& info)
259 {
260 return false;
261 }
262
263 long wxListCtrl::SetItem(long index, int col, const wxString& label, int imageId)
264 {
265 return 0;
266 }
267
268
269 // Gets the item state
270 int wxListCtrl::GetItemState(long item, long stateMask) const
271 {
272 return 0;
273 }
274
275 // Sets the item state
276 bool wxListCtrl::SetItemState(long item, long state, long stateMask)
277 {
278 return false;
279 }
280
281 // Sets the item image
282 bool wxListCtrl::SetItemImage(long item, int image, int WXUNUSED(selImage))
283 {
284 return false;
285 }
286
287 // Sets the item image
288 bool wxListCtrl::SetItemColumnImage(long item, long column, int image)
289 {
290 return false;
291 }
292
293 // Gets the item text
294 wxString wxListCtrl::GetItemText(long item) const
295 {
296 wxListItem info;
297
298 return info.m_text;
299 }
300
301 // Sets the item text
302 void wxListCtrl::SetItemText(long item, const wxString& str)
303 {
304 }
305
306 // Gets the item data
307 long wxListCtrl::GetItemData(long item) const
308 {
309 return 0;
310 }
311
312 // Sets the item data
313 bool wxListCtrl::SetItemData(long item, long data)
314 {
315 return false;
316 }
317
318 wxRect wxListCtrl::GetViewRect() const
319 {
320 wxRect rect;
321
322 return rect;
323 }
324
325 // Gets the item rectangle
326 bool wxListCtrl::GetItemRect(long item, wxRect& rect, int code) const
327 {
328 return false;
329 }
330
331 // Gets the item position
332 bool wxListCtrl::GetItemPosition(long item, wxPoint& pos) const
333 {
334 return false;
335 }
336
337 // Sets the item position.
338 bool wxListCtrl::SetItemPosition(long item, const wxPoint& pos)
339 {
340 return false;
341 }
342
343 // Gets the number of items in the list control
344 int wxListCtrl::GetItemCount() const
345 {
346 return 0;
347 }
348
349 wxSize wxListCtrl::GetItemSpacing() const
350 {
351 return wxSize(0,0);
352 }
353
354 int wxListCtrl::GetItemSpacing(bool isSmall) const
355 {
356 return 0;
357 }
358
359 void wxListCtrl::SetItemTextColour( long item, const wxColour &col )
360 {
361 }
362
363 wxColour wxListCtrl::GetItemTextColour( long item ) const
364 {
365 wxColour col;
366
367 return col;
368 }
369
370 void wxListCtrl::SetItemBackgroundColour( long item, const wxColour &col )
371 {
372 }
373
374 wxColour wxListCtrl::GetItemBackgroundColour( long item ) const
375 {
376 wxColour col;
377
378 return col;
379 }
380
381 // Gets the number of selected items in the list control
382 int wxListCtrl::GetSelectedItemCount() const
383 {
384 return 0;
385 }
386
387 // Gets the text colour of the listview
388 wxColour wxListCtrl::GetTextColour() const
389 {
390 wxColour col;
391 return col;
392 }
393
394 // Sets the text colour of the listview
395 void wxListCtrl::SetTextColour(const wxColour& col)
396 {
397 }
398
399 // Gets the index of the topmost visible item when in
400 // list or report view
401 long wxListCtrl::GetTopItem() const
402 {
403 return 0;
404 }
405
406 // Searches for an item, starting from 'item'.
407 // 'geometry' is one of
408 // wxLIST_NEXT_ABOVE/ALL/BELOW/LEFT/RIGHT.
409 // 'state' is a state bit flag, one or more of
410 // wxLIST_STATE_DROPHILITED/FOCUSED/SELECTED/CUT.
411 // item can be -1 to find the first item that matches the
412 // specified flags.
413 // Returns the item or -1 if unsuccessful.
414 long wxListCtrl::GetNextItem(long item, int geom, int state) const
415 {
416 return 0;
417 }
418
419
420 wxImageList *wxListCtrl::GetImageList(int which) const
421 {
422 return NULL;
423 }
424
425 void wxListCtrl::SetImageList(wxImageList *imageList, int which)
426 {
427 }
428
429 void wxListCtrl::AssignImageList(wxImageList *imageList, int which)
430 {
431 }
432
433 // ----------------------------------------------------------------------------
434 // Operations
435 // ----------------------------------------------------------------------------
436
437 // Arranges the items
438 bool wxListCtrl::Arrange(int flag)
439 {
440 return false;
441 }
442
443 // Deletes an item
444 bool wxListCtrl::DeleteItem(long item)
445 {
446 return false;
447 }
448
449 // Deletes all items
450 bool wxListCtrl::DeleteAllItems()
451 {
452 return false;
453 }
454
455 // Deletes all items
456 bool wxListCtrl::DeleteAllColumns()
457 {
458 return false;
459 }
460
461 // Deletes a column
462 bool wxListCtrl::DeleteColumn(int col)
463 {
464 return false;
465 }
466
467 // Clears items, and columns if there are any.
468 void wxListCtrl::ClearAll()
469 {
470 }
471
472 wxTextCtrl* wxListCtrl::EditLabel(long item, wxClassInfo* textControlClass)
473 {
474 return NULL;
475 }
476
477 // End label editing, optionally cancelling the edit
478 bool wxListCtrl::EndEditLabel(bool WXUNUSED(cancel))
479 {
480 return false;
481 }
482
483 // Ensures this item is visible
484 bool wxListCtrl::EnsureVisible(long item)
485 {
486 return false;
487 }
488
489 // Find an item whose label matches this string, starting from the item after 'start'
490 // or the beginning if 'start' is -1.
491 long wxListCtrl::FindItem(long start, const wxString& str, bool partial)
492 {
493 return 0;
494 }
495
496 // Find an item whose data matches this data, starting from the item after 'start'
497 // or the beginning if 'start' is -1.
498 // NOTE : Lindsay Mathieson - 14-July-2002
499 // No longer use ListView_FindItem as the data attribute is now stored
500 // in a wxListItemInternalData structure refernced by the actual lParam
501 long wxListCtrl::FindItem(long start, long data)
502 {
503 return wxNOT_FOUND;
504 }
505
506 // Find an item nearest this position in the specified direction, starting from
507 // the item after 'start' or the beginning if 'start' is -1.
508 long wxListCtrl::FindItem(long start, const wxPoint& pt, int direction)
509 {
510 return wxNOT_FOUND;
511 }
512
513 // Determines which item (if any) is at the specified point,
514 // giving details in 'flags' (see wxLIST_HITTEST_... flags above)
515 long wxListCtrl::HitTest(const wxPoint& point, int& flags)
516 {
517 return 0;
518 }
519
520 // Inserts an item, returning the index of the new item if successful,
521 // -1 otherwise.
522 long wxListCtrl::InsertItem(wxListItem& info)
523 {
524 return 0;
525 }
526
527 long wxListCtrl::InsertItem(long index, const wxString& label)
528 {
529 return 0;
530 }
531
532 // Inserts an image item
533 long wxListCtrl::InsertItem(long index, int imageIndex)
534 {
535 return 0;
536 }
537
538 // Inserts an image/string item
539 long wxListCtrl::InsertItem(long index, const wxString& label, int imageIndex)
540 {
541 return 0;
542 }
543
544 // For list view mode (only), inserts a column.
545 long wxListCtrl::InsertColumn(long col, wxListItem& item)
546 {
547 return 0;
548 }
549
550 long wxListCtrl::InsertColumn(long col,
551 const wxString& heading,
552 int format,
553 int width)
554 {
555 return 0;
556 }
557
558 // scroll the control by the given number of pixels (exception: in list view,
559 // dx is interpreted as number of columns)
560 bool wxListCtrl::ScrollList(int dx, int dy)
561 {
562 return false;
563 }
564
565 // Sort items.
566
567 // fn is a function which takes 3 long arguments: item1, item2, data.
568 // item1 is the long data associated with a first item (NOT the index).
569 // item2 is the long data associated with a second item (NOT the index).
570 // data is the same value as passed to SortItems.
571 // The return value is a negative number if the first item should precede the second
572 // item, a positive number of the second item should precede the first,
573 // or zero if the two items are equivalent.
574
575 // data is arbitrary data to be passed to the sort function.
576
577 // Internal structures for proxying the user compare function
578 // so that we can pass it the *real* user data
579
580 // translate lParam data and call user func
581 struct wxInternalDataSort
582 {
583 wxListCtrlCompare user_fn;
584 long data;
585 };
586
587 int CALLBACK wxInternalDataCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
588 {
589 struct wxInternalDataSort *internalData = (struct wxInternalDataSort *) lParamSort;
590
591 wxListItemInternalData *data1 = (wxListItemInternalData *) lParam1;
592 wxListItemInternalData *data2 = (wxListItemInternalData *) lParam2;
593
594 long d1 = (data1 == NULL ? 0 : data1->lParam);
595 long d2 = (data2 == NULL ? 0 : data2->lParam);
596
597 return internalData->user_fn(d1, d2, internalData->data);
598
599 };
600
601 bool wxListCtrl::SortItems(wxListCtrlCompare fn, long data)
602 {
603 return false;
604 }
605
606
607
608 // ----------------------------------------------------------------------------
609 // message processing
610 // ----------------------------------------------------------------------------
611
612 // Necessary for drawing hrules and vrules, if specified
613 void wxListCtrl::OnPaint(wxPaintEvent& event)
614 {
615 }
616
617 // ----------------------------------------------------------------------------
618 // virtual list controls
619 // ----------------------------------------------------------------------------
620
621 wxString wxListCtrl::OnGetItemText(long WXUNUSED(item), long WXUNUSED(col)) const
622 {
623 return wxEmptyString;
624 }
625
626 int wxListCtrl::OnGetItemImage(long WXUNUSED(item)) const
627 {
628 return -1;
629 }
630
631 int wxListCtrl::OnGetItemColumnImage(long item, long column) const
632 {
633 if (!column)
634 return OnGetItemImage(item);
635
636 return -1;
637 }
638
639 wxListItemAttr *wxListCtrl::OnGetItemAttr(long WXUNUSED_UNLESS_DEBUG(item)) const
640 {
641 // no attributes by default
642 return NULL;
643 }
644
645 void wxListCtrl::SetItemCount(long count)
646 {
647 }
648
649 void wxListCtrl::RefreshItem(long item)
650 {
651 }
652
653 void wxListCtrl::RefreshItems(long itemFrom, long itemTo)
654 {
655 }
656
657 // ----------------------------------------------------------------------------
658 // internal data stuff
659 // ----------------------------------------------------------------------------
660
661 static wxListItemInternalData *wxGetInternalData(HWND hwnd, long itemId)
662 {
663 return NULL;
664 };
665
666 static wxListItemInternalData *wxGetInternalData(const wxListCtrl *ctl, long itemId)
667 {
668 return wxGetInternalData(GetHwndOf(ctl), itemId);
669 };
670
671 static wxListItemAttr *wxGetInternalDataAttr(wxListCtrl *ctl, long itemId)
672 {
673 return NULL;
674 };
675
676 static void wxDeleteInternalData(wxListCtrl* ctl, long itemId)
677 {
678 }
679
680 #endif // wxUSE_LISTCTRL