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