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