]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/listctrl.cpp
Headers cleaning.
[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 // Set the whole window style
195 void wxListCtrl::SetWindowStyleFlag(long flag)
196 {
197 }
198
199 // ----------------------------------------------------------------------------
200 // accessors
201 // ----------------------------------------------------------------------------
202
203 /* static */ wxVisualAttributes wxListCtrl::GetClassDefaultAttributes(wxWindowVariant variant)
204 {
205 wxVisualAttributes attrs;
206
207 return attrs;
208 }
209
210 // Sets the foreground, i.e. text, colour
211 bool wxListCtrl::SetForegroundColour(const wxColour& col)
212 {
213 return false;
214 }
215
216 // Sets the background colour
217 bool wxListCtrl::SetBackgroundColour(const wxColour& col)
218 {
219 return false;
220 }
221
222 // Gets information about this column
223 bool wxListCtrl::GetColumn(int col, wxListItem& item) const
224 {
225 return false;
226 }
227
228 // Sets information about this column
229 bool wxListCtrl::SetColumn(int col, wxListItem& item)
230 {
231 return false;
232 }
233
234 // Gets the column width
235 int wxListCtrl::GetColumnWidth(int col) const
236 {
237 return 0;
238 }
239
240 // Sets the column width
241 bool wxListCtrl::SetColumnWidth(int col, int width)
242 {
243 return false;
244 }
245
246 // Gets the number of items that can fit vertically in the
247 // visible area of the list control (list or report view)
248 // or the total number of items in the list control (icon
249 // or small icon view)
250 int wxListCtrl::GetCountPerPage() const
251 {
252 return 0;
253 }
254
255 // Gets the edit control for editing labels.
256 wxTextCtrl* wxListCtrl::GetEditControl() const
257 {
258 return NULL;
259 }
260
261 // Gets information about the item
262 bool wxListCtrl::GetItem(wxListItem& info) const
263 {
264 return false;
265 }
266
267 // Sets information about the item
268 bool wxListCtrl::SetItem(wxListItem& info)
269 {
270 return false;
271 }
272
273 long wxListCtrl::SetItem(long index, int col, const wxString& label, int imageId)
274 {
275 return 0;
276 }
277
278
279 // Gets the item state
280 int wxListCtrl::GetItemState(long item, long stateMask) const
281 {
282 return 0;
283 }
284
285 // Sets the item state
286 bool wxListCtrl::SetItemState(long item, long state, long stateMask)
287 {
288 return false;
289 }
290
291 // Sets the item image
292 bool wxListCtrl::SetItemImage(long item, int image, int WXUNUSED(selImage))
293 {
294 return false;
295 }
296
297 // Gets the item text
298 wxString wxListCtrl::GetItemText(long item) const
299 {
300 wxListItem info;
301
302 return info.m_text;
303 }
304
305 // Sets the item text
306 void wxListCtrl::SetItemText(long item, const wxString& str)
307 {
308 }
309
310 // Gets the item data
311 long wxListCtrl::GetItemData(long item) const
312 {
313 return 0;
314 }
315
316 // Sets the item data
317 bool wxListCtrl::SetItemData(long item, long data)
318 {
319 return false;
320 }
321
322 wxRect wxListCtrl::GetViewRect() const
323 {
324 wxRect rect;
325
326 return rect;
327 }
328
329 // Gets the item rectangle
330 bool wxListCtrl::GetItemRect(long item, wxRect& rect, int code) const
331 {
332 return false;
333 }
334
335 // Gets the item position
336 bool wxListCtrl::GetItemPosition(long item, wxPoint& pos) const
337 {
338 return false;
339 }
340
341 // Sets the item position.
342 bool wxListCtrl::SetItemPosition(long item, const wxPoint& pos)
343 {
344 return false;
345 }
346
347 // Gets the number of items in the list control
348 int wxListCtrl::GetItemCount() const
349 {
350 return 0;
351 }
352
353 wxSize wxListCtrl::GetItemSpacing() const
354 {
355 return wxSize(0,0);
356 }
357
358 int wxListCtrl::GetItemSpacing(bool isSmall) const
359 {
360 return 0;
361 }
362
363 void wxListCtrl::SetItemTextColour( long item, const wxColour &col )
364 {
365 }
366
367 wxColour wxListCtrl::GetItemTextColour( long item ) const
368 {
369 wxColour col;
370
371 return col;
372 }
373
374 void wxListCtrl::SetItemBackgroundColour( long item, const wxColour &col )
375 {
376 }
377
378 wxColour wxListCtrl::GetItemBackgroundColour( long item ) const
379 {
380 wxColour col;
381
382 return col;
383 }
384
385 // Gets the number of selected items in the list control
386 int wxListCtrl::GetSelectedItemCount() const
387 {
388 return 0;
389 }
390
391 // Gets the text colour of the listview
392 wxColour wxListCtrl::GetTextColour() const
393 {
394 wxColour col;
395 return col;
396 }
397
398 // Sets the text colour of the listview
399 void wxListCtrl::SetTextColour(const wxColour& col)
400 {
401 }
402
403 // Gets the index of the topmost visible item when in
404 // list or report view
405 long wxListCtrl::GetTopItem() const
406 {
407 return 0;
408 }
409
410 // Searches for an item, starting from 'item'.
411 // 'geometry' is one of
412 // wxLIST_NEXT_ABOVE/ALL/BELOW/LEFT/RIGHT.
413 // 'state' is a state bit flag, one or more of
414 // wxLIST_STATE_DROPHILITED/FOCUSED/SELECTED/CUT.
415 // item can be -1 to find the first item that matches the
416 // specified flags.
417 // Returns the item or -1 if unsuccessful.
418 long wxListCtrl::GetNextItem(long item, int geom, int state) const
419 {
420 return 0;
421 }
422
423
424 wxImageList *wxListCtrl::GetImageList(int which) const
425 {
426 return NULL;
427 }
428
429 void wxListCtrl::SetImageList(wxImageList *imageList, int which)
430 {
431 }
432
433 void wxListCtrl::AssignImageList(wxImageList *imageList, int which)
434 {
435 }
436
437 // ----------------------------------------------------------------------------
438 // Operations
439 // ----------------------------------------------------------------------------
440
441 // Arranges the items
442 bool wxListCtrl::Arrange(int flag)
443 {
444 return false;
445 }
446
447 // Deletes an item
448 bool wxListCtrl::DeleteItem(long item)
449 {
450 return false;
451 }
452
453 // Deletes all items
454 bool wxListCtrl::DeleteAllItems()
455 {
456 return false;
457 }
458
459 // Deletes all items
460 bool wxListCtrl::DeleteAllColumns()
461 {
462 return false;
463 }
464
465 // Deletes a column
466 bool wxListCtrl::DeleteColumn(int col)
467 {
468 return false;
469 }
470
471 // Clears items, and columns if there are any.
472 void wxListCtrl::ClearAll()
473 {
474 }
475
476 wxTextCtrl* wxListCtrl::EditLabel(long item, wxClassInfo* textControlClass)
477 {
478 return NULL;
479 }
480
481 // End label editing, optionally cancelling the edit
482 bool wxListCtrl::EndEditLabel(bool WXUNUSED(cancel))
483 {
484 return false;
485 }
486
487 // Ensures this item is visible
488 bool wxListCtrl::EnsureVisible(long item)
489 {
490 return false;
491 }
492
493 // Find an item whose label matches this string, starting from the item after 'start'
494 // or the beginning if 'start' is -1.
495 long wxListCtrl::FindItem(long start, const wxString& str, bool partial)
496 {
497 return 0;
498 }
499
500 // Find an item whose data matches this data, starting from the item after 'start'
501 // or the beginning if 'start' is -1.
502 // NOTE : Lindsay Mathieson - 14-July-2002
503 // No longer use ListView_FindItem as the data attribute is now stored
504 // in a wxListItemInternalData structure refernced by the actual lParam
505 long wxListCtrl::FindItem(long start, long data)
506 {
507 return wxNOT_FOUND;
508 }
509
510 // Find an item nearest this position in the specified direction, starting from
511 // the item after 'start' or the beginning if 'start' is -1.
512 long wxListCtrl::FindItem(long start, const wxPoint& pt, int direction)
513 {
514 return wxNOT_FOUND;
515 }
516
517 // Determines which item (if any) is at the specified point,
518 // giving details in 'flags' (see wxLIST_HITTEST_... flags above)
519 long wxListCtrl::HitTest(const wxPoint& point, int& flags)
520 {
521 return 0;
522 }
523
524 // Inserts an item, returning the index of the new item if successful,
525 // -1 otherwise.
526 long wxListCtrl::InsertItem(wxListItem& info)
527 {
528 return 0;
529 }
530
531 long wxListCtrl::InsertItem(long index, const wxString& label)
532 {
533 return 0;
534 }
535
536 // Inserts an image item
537 long wxListCtrl::InsertItem(long index, int imageIndex)
538 {
539 return 0;
540 }
541
542 // Inserts an image/string item
543 long wxListCtrl::InsertItem(long index, const wxString& label, int imageIndex)
544 {
545 return 0;
546 }
547
548 // For list view mode (only), inserts a column.
549 long wxListCtrl::InsertColumn(long col, wxListItem& item)
550 {
551 return 0;
552 }
553
554 long wxListCtrl::InsertColumn(long col,
555 const wxString& heading,
556 int format,
557 int width)
558 {
559 return 0;
560 }
561
562 // scroll the control by the given number of pixels (exception: in list view,
563 // dx is interpreted as number of columns)
564 bool wxListCtrl::ScrollList(int dx, int dy)
565 {
566 return false;
567 }
568
569 // Sort items.
570
571 // fn is a function which takes 3 long arguments: item1, item2, data.
572 // item1 is the long data associated with a first item (NOT the index).
573 // item2 is the long data associated with a second item (NOT the index).
574 // data is the same value as passed to SortItems.
575 // The return value is a negative number if the first item should precede the second
576 // item, a positive number of the second item should precede the first,
577 // or zero if the two items are equivalent.
578
579 // data is arbitrary data to be passed to the sort function.
580
581 // Internal structures for proxying the user compare function
582 // so that we can pass it the *real* user data
583
584 // translate lParam data and call user func
585 struct wxInternalDataSort
586 {
587 wxListCtrlCompare user_fn;
588 long data;
589 };
590
591 int CALLBACK wxInternalDataCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
592 {
593 struct wxInternalDataSort *internalData = (struct wxInternalDataSort *) lParamSort;
594
595 wxListItemInternalData *data1 = (wxListItemInternalData *) lParam1;
596 wxListItemInternalData *data2 = (wxListItemInternalData *) lParam2;
597
598 long d1 = (data1 == NULL ? 0 : data1->lParam);
599 long d2 = (data2 == NULL ? 0 : data2->lParam);
600
601 return internalData->user_fn(d1, d2, internalData->data);
602
603 };
604
605 bool wxListCtrl::SortItems(wxListCtrlCompare fn, long data)
606 {
607 return false;
608 }
609
610
611
612 // ----------------------------------------------------------------------------
613 // message processing
614 // ----------------------------------------------------------------------------
615
616 // Necessary for drawing hrules and vrules, if specified
617 void wxListCtrl::OnPaint(wxPaintEvent& event)
618 {
619 }
620
621 // ----------------------------------------------------------------------------
622 // virtual list controls
623 // ----------------------------------------------------------------------------
624
625 wxString wxListCtrl::OnGetItemText(long WXUNUSED(item), long WXUNUSED(col)) const
626 {
627 return wxEmptyString;
628 }
629
630 int wxListCtrl::OnGetItemImage(long WXUNUSED(item)) const
631 {
632 return -1;
633 }
634
635 wxListItemAttr *wxListCtrl::OnGetItemAttr(long WXUNUSED_UNLESS_DEBUG(item)) const
636 {
637 // no attributes by default
638 return NULL;
639 }
640
641 void wxListCtrl::SetItemCount(long count)
642 {
643 }
644
645 void wxListCtrl::RefreshItem(long item)
646 {
647 }
648
649 void wxListCtrl::RefreshItems(long itemFrom, long itemTo)
650 {
651 }
652
653 // ----------------------------------------------------------------------------
654 // internal data stuff
655 // ----------------------------------------------------------------------------
656
657 static wxListItemInternalData *wxGetInternalData(HWND hwnd, long itemId)
658 {
659 return NULL;
660 };
661
662 static wxListItemInternalData *wxGetInternalData(const wxListCtrl *ctl, long itemId)
663 {
664 return wxGetInternalData(GetHwndOf(ctl), itemId);
665 };
666
667 static wxListItemAttr *wxGetInternalDataAttr(wxListCtrl *ctl, long itemId)
668 {
669 return NULL;
670 };
671
672 static void wxDeleteInternalData(wxListCtrl* ctl, long itemId)
673 {
674 }
675
676 #endif // wxUSE_LISTCTRL
677