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