1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/listctrl_mac.cpp
4 // Author: Julian Smart
5 // Modified by: Agron Selimaj
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
29 #include "wx/listctrl.h"
35 #include "wx/mac/uma.h"
37 #include "wx/imaglist.h"
38 #include "wx/sysopt.h"
40 #define wxMAC_ALWAYS_USE_GENERIC_LISTCTRL wxT("mac.listctrl.always_use_generic")
42 #if wxUSE_EXTENDED_RTTI
43 WX_DEFINE_FLAGS( wxListCtrlStyle
)
45 wxBEGIN_FLAGS( wxListCtrlStyle
)
46 // new style border flags, we put them first to
47 // use them for streaming out
48 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
49 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
50 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
51 wxFLAGS_MEMBER(wxBORDER_RAISED
)
52 wxFLAGS_MEMBER(wxBORDER_STATIC
)
53 wxFLAGS_MEMBER(wxBORDER_NONE
)
55 // old style border flags
56 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
57 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
58 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
59 wxFLAGS_MEMBER(wxRAISED_BORDER
)
60 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
61 wxFLAGS_MEMBER(wxBORDER
)
63 // standard window styles
64 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
65 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
66 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
67 wxFLAGS_MEMBER(wxWANTS_CHARS
)
68 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
69 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
70 wxFLAGS_MEMBER(wxVSCROLL
)
71 wxFLAGS_MEMBER(wxHSCROLL
)
73 wxFLAGS_MEMBER(wxLC_LIST
)
74 wxFLAGS_MEMBER(wxLC_REPORT
)
75 wxFLAGS_MEMBER(wxLC_ICON
)
76 wxFLAGS_MEMBER(wxLC_SMALL_ICON
)
77 wxFLAGS_MEMBER(wxLC_ALIGN_TOP
)
78 wxFLAGS_MEMBER(wxLC_ALIGN_LEFT
)
79 wxFLAGS_MEMBER(wxLC_AUTOARRANGE
)
80 wxFLAGS_MEMBER(wxLC_USER_TEXT
)
81 wxFLAGS_MEMBER(wxLC_EDIT_LABELS
)
82 wxFLAGS_MEMBER(wxLC_NO_HEADER
)
83 wxFLAGS_MEMBER(wxLC_SINGLE_SEL
)
84 wxFLAGS_MEMBER(wxLC_SORT_ASCENDING
)
85 wxFLAGS_MEMBER(wxLC_SORT_DESCENDING
)
86 wxFLAGS_MEMBER(wxLC_VIRTUAL
)
88 wxEND_FLAGS( wxListCtrlStyle
)
90 IMPLEMENT_DYNAMIC_CLASS_XTI(wxListCtrl
, wxControl
,"wx/listctrl.h")
92 wxBEGIN_PROPERTIES_TABLE(wxListCtrl
)
93 wxEVENT_PROPERTY( TextUpdated
, wxEVT_COMMAND_TEXT_UPDATED
, wxCommandEvent
)
95 wxPROPERTY_FLAGS( WindowStyle
, wxListCtrlStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
96 wxEND_PROPERTIES_TABLE()
98 wxBEGIN_HANDLERS_TABLE(wxListCtrl
)
99 wxEND_HANDLERS_TABLE()
101 wxCONSTRUCTOR_5( wxListCtrl
, wxWindow
* , Parent
, wxWindowID
, Id
, wxPoint
, Position
, wxSize
, Size
, long , WindowStyle
)
104 TODO : Expose more information of a list's layout etc. via appropriate objects (à la NotebookPageInfo)
107 IMPLEMENT_DYNAMIC_CLASS(wxListCtrl
, wxControl
)
110 IMPLEMENT_DYNAMIC_CLASS(wxListView
, wxListCtrl
)
111 IMPLEMENT_DYNAMIC_CLASS(wxListItem
, wxObject
)
113 IMPLEMENT_DYNAMIC_CLASS(wxListEvent
, wxNotifyEvent
)
115 WX_DECLARE_EXPORTED_LIST(wxListItem
, wxListItemList
);
116 #include "wx/listimpl.cpp"
117 WX_DEFINE_LIST(wxListItemList
)
118 WX_DEFINE_LIST(wxColumnList
)
120 // so we can check for column clicks
121 static const EventTypeSpec eventList
[] =
123 { kEventClassControl
, kEventControlHit
},
124 { kEventClassControl
, kEventControlDraw
}
127 static pascal OSStatus
wxMacListCtrlEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
129 OSStatus result
= eventNotHandledErr
;
131 wxMacCarbonEvent
cEvent( event
) ;
133 ControlRef controlRef
;
134 cEvent
.GetParameter( kEventParamDirectObject
, &controlRef
) ;
136 wxListCtrl
*window
= (wxListCtrl
*) data
;
137 wxListEvent
le( wxEVT_COMMAND_LIST_COL_CLICK
, window
->GetId() );
138 le
.SetEventObject( window
);
140 switch ( GetEventKind( event
) )
142 // check if the column was clicked on and fire an event if so
143 case kEventControlHit
:
145 ControlPartCode result
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
) ;
146 if (result
== kControlButtonPart
){
147 DataBrowserPropertyID col
;
148 GetDataBrowserSortProperty(controlRef
, &col
);
149 int column
= col
- kMinColumnId
;
151 window
->GetEventHandler()->ProcessEvent( le
);
153 result
= CallNextEventHandler(handler
, event
);
156 case kEventControlDraw
:
157 CGContextRef context
= cEvent
.GetParameter
<CGContextRef
>(kEventParamCGContextRef
, typeCGContextRef
) ;
158 window
->MacSetDrawingContext(context
);
159 result
= CallNextEventHandler(handler
, event
);
160 window
->MacSetDrawingContext(NULL
);
169 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacListCtrlEventHandler
)
171 class wxMacListCtrlItem
: public wxMacListBoxItem
176 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
177 DataBrowserItemNotification message
,
178 DataBrowserItemDataRef itemData
) const;
180 virtual void SetColumnInfo( unsigned int column
, wxListItem
* item
);
181 virtual wxListItem
* GetColumnInfo( unsigned int column
);
182 virtual bool HasColumnInfo( unsigned int column
);
184 virtual void SetColumnTextValue( unsigned int column
, const wxString
& text
);
185 virtual const wxString
& GetColumnTextValue( unsigned int column
);
187 virtual int GetColumnImageValue( unsigned int column
);
188 virtual void SetColumnImageValue( unsigned int column
, int imageIndex
);
190 virtual ~wxMacListCtrlItem();
192 wxListItemList m_rowItems
;
195 DataBrowserDrawItemUPP gDataBrowserDrawItemUPP
= NULL
;
196 //DataBrowserEditItemUPP gDataBrowserEditItemUPP = NULL;
197 DataBrowserHitTestUPP gDataBrowserHitTestUPP
= NULL
;
199 // TODO: Make a better name!!
200 class wxMacDataBrowserListCtrlControl
: public wxMacDataItemBrowserControl
203 wxMacDataBrowserListCtrlControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
204 virtual ~wxMacDataBrowserListCtrlControl();
206 // create a list item (can be a subclass of wxMacListBoxItem)
208 virtual wxMacDataItem
* CreateItem();
210 virtual void MacInsertItem( unsigned int n
, wxListItem
* item
);
211 virtual void MacSetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
* item
);
212 virtual void MacGetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
& item
);
213 virtual void UpdateState(wxMacDataItem
* dataItem
, wxListItem
* item
);
216 // we need to override to provide specialized handling for virtual wxListCtrls
217 virtual OSStatus
GetSetItemData(DataBrowserItemID itemID
,
218 DataBrowserPropertyID property
,
219 DataBrowserItemDataRef itemData
,
220 Boolean changeValue
);
222 virtual void ItemNotification(
223 DataBrowserItemID itemID
,
224 DataBrowserItemNotification message
,
225 DataBrowserItemDataRef itemData
);
227 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
228 DataBrowserItemID itemTwoID
,
229 DataBrowserPropertyID sortProperty
);
231 static pascal void DataBrowserDrawItemProc(ControlRef browser
,
232 DataBrowserItemID item
,
233 DataBrowserPropertyID property
,
234 DataBrowserItemState itemState
,
237 Boolean colorDevice
);
239 virtual void DrawItem(DataBrowserItemID itemID
,
240 DataBrowserPropertyID property
,
241 DataBrowserItemState itemState
,
242 const Rect
*itemRect
,
244 Boolean colorDevice
);
246 static pascal Boolean
DataBrowserEditTextProc(ControlRef browser
,
247 DataBrowserItemID item
,
248 DataBrowserPropertyID property
,
249 CFStringRef theString
,
250 Rect
*maxEditTextRect
,
251 Boolean
*shrinkToFit
);
253 static pascal Boolean
DataBrowserHitTestProc(ControlRef browser
,
254 DataBrowserItemID itemID
,
255 DataBrowserPropertyID property
,
257 const Rect
*mouseRect
) { return true; }
259 virtual bool ConfirmEditText(DataBrowserItemID item
,
260 DataBrowserPropertyID property
,
261 CFStringRef theString
,
262 Rect
*maxEditTextRect
,
263 Boolean
*shrinkToFit
);
267 wxClientDataType m_clientDataItemsType
;
272 class wxMacListCtrlEventDelegate
: public wxEvtHandler
275 wxMacListCtrlEventDelegate( wxListCtrl
* list
, int id
);
276 virtual bool ProcessEvent( wxEvent
& event
);
283 wxMacListCtrlEventDelegate::wxMacListCtrlEventDelegate( wxListCtrl
* list
, int id
)
289 bool wxMacListCtrlEventDelegate::ProcessEvent( wxEvent
& event
)
291 // even though we use a generic list ctrl underneath, make sure
292 // we present ourselves as wxListCtrl.
293 event
.SetEventObject( m_list
);
296 return wxEvtHandler::ProcessEvent(event
);
299 // ============================================================================
301 // ============================================================================
303 wxMacListControl
* wxListCtrl::GetPeer() const
305 return dynamic_cast<wxMacListControl
*>(m_peer
);
308 // ----------------------------------------------------------------------------
309 // wxListCtrl construction
310 // ----------------------------------------------------------------------------
312 void wxListCtrl::Init()
314 m_imageListNormal
= NULL
;
315 m_imageListSmall
= NULL
;
316 m_imageListState
= NULL
;
318 // keep track of if we created our own image lists, or if they were assigned
320 m_ownsImageListNormal
= m_ownsImageListSmall
= m_ownsImageListState
= false;
324 m_genericImpl
= NULL
;
326 m_compareFunc
= NULL
;
327 m_compareFuncData
= 0;
328 m_colsInfo
= wxColumnList();
329 m_textColor
= wxNullColour
;
330 m_bgColor
= wxNullColour
;
333 class wxGenericListCtrlHook
: public wxGenericListCtrl
336 wxGenericListCtrlHook(wxListCtrl
* parent
,
341 const wxValidator
& validator
,
342 const wxString
& name
)
343 : wxGenericListCtrl(parent
, id
, pos
, size
, style
, validator
, name
),
344 m_nativeListCtrl(parent
)
349 virtual wxListItemAttr
* OnGetItemAttr(long item
) const
351 return m_nativeListCtrl
->OnGetItemAttr(item
);
354 virtual int OnGetItemImage(long item
) const
356 return m_nativeListCtrl
->OnGetItemImage(item
);
359 virtual int OnGetItemColumnImage(long item
, long column
) const
361 return m_nativeListCtrl
->OnGetItemColumnImage(item
, column
);
364 virtual wxString
OnGetItemText(long item
, long column
) const
366 return m_nativeListCtrl
->OnGetItemText(item
, column
);
369 wxListCtrl
* m_nativeListCtrl
;
373 bool wxListCtrl::Create(wxWindow
*parent
,
378 const wxValidator
& validator
,
379 const wxString
& name
)
382 // for now, we'll always use the generic list control for ICON and LIST views,
383 // because they dynamically change the number of columns on resize.
384 // Also, allow the user to set it to use the list ctrl as well.
385 // Also, use generic list control in VIRTUAL mode.
386 if ( (wxSystemOptions::HasOption( wxMAC_ALWAYS_USE_GENERIC_LISTCTRL
)
387 && (wxSystemOptions::GetOptionInt( wxMAC_ALWAYS_USE_GENERIC_LISTCTRL
) == 1)) ||
388 (style
& wxLC_ICON
) || (style
& wxLC_SMALL_ICON
) || (style
& wxLC_LIST
) || (style
& wxLC_EDIT_LABELS
) )
390 m_macIsUserPane
= true;
392 if ( !wxWindow::Create(parent
, id
, pos
, size
, style
, name
) )
394 m_genericImpl
= new wxGenericListCtrlHook(this, id
, pos
, size
, style
, validator
, name
);
395 m_genericImpl
->PushEventHandler( new wxMacListCtrlEventDelegate( this, GetId() ) );
401 m_macIsUserPane
= false;
403 if ( !wxWindow::Create(parent
, id
, pos
, size
, style
, name
) )
405 m_dbImpl
= new wxMacDataBrowserListCtrlControl( this, pos
, size
, style
);
408 MacPostControlCreate( pos
, size
);
410 InstallControlEventHandler( m_peer
->GetControlRef() , GetwxMacListCtrlEventHandlerUPP(),
411 GetEventTypeCount(eventList
), eventList
, this,
412 (EventHandlerRef
*)&m_macListCtrlEventHandler
);
418 wxListCtrl::~wxListCtrl()
422 m_genericImpl
->PopEventHandler(/* deleteHandler = */ true);
425 if (m_ownsImageListNormal
)
426 delete m_imageListNormal
;
427 if (m_ownsImageListSmall
)
428 delete m_imageListSmall
;
429 if (m_ownsImageListState
)
430 delete m_imageListState
;
433 // ----------------------------------------------------------------------------
434 // set/get/change style
435 // ----------------------------------------------------------------------------
437 // Add or remove a single window style
438 void wxListCtrl::SetSingleStyle(long style
, bool add
)
440 long flag
= GetWindowStyleFlag();
442 // Get rid of conflicting styles
445 if ( style
& wxLC_MASK_TYPE
)
446 flag
= flag
& ~wxLC_MASK_TYPE
;
447 if ( style
& wxLC_MASK_ALIGN
)
448 flag
= flag
& ~wxLC_MASK_ALIGN
;
449 if ( style
& wxLC_MASK_SORT
)
450 flag
= flag
& ~wxLC_MASK_SORT
;
458 SetWindowStyleFlag(flag
);
461 // Set the whole window style
462 void wxListCtrl::SetWindowStyleFlag(long flag
)
464 if ( flag
!= m_windowStyle
)
466 m_windowStyle
= flag
;
470 m_genericImpl
->SetWindowStyleFlag(flag
);
477 void wxListCtrl::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
479 wxControl::DoSetSize(x
, y
, width
, height
, sizeFlags
);
482 m_genericImpl
->SetSize(x
, y
, width
, height
, sizeFlags
);
485 bool wxListCtrl::SetFont(const wxFont
& font
)
488 rv
= wxControl::SetFont(font
);
490 rv
= m_genericImpl
->SetFont(font
);
494 bool wxListCtrl::SetForegroundColour(const wxColour
& colour
)
498 rv
= m_genericImpl
->SetForegroundColour(colour
);
500 SetTextColour(colour
);
504 bool wxListCtrl::SetBackgroundColour(const wxColour
& colour
)
508 rv
= m_genericImpl
->SetBackgroundColour(colour
);
514 wxColour
wxListCtrl::GetBackgroundColour()
517 return m_genericImpl
->GetBackgroundColour();
524 // ----------------------------------------------------------------------------
526 // ----------------------------------------------------------------------------
528 // Gets information about this column
529 bool wxListCtrl::GetColumn(int col
, wxListItem
& item
) const
532 return m_genericImpl
->GetColumn(col
, item
);
539 wxColumnList::compatibility_iterator node
= m_colsInfo
.Item( col
);
540 wxASSERT_MSG( node
, _T("invalid column index in wxMacListCtrlItem") );
541 wxListItem
* column
= node
->GetData();
543 long mask
= column
->GetMask();
544 if (mask
& wxLIST_MASK_TEXT
)
545 item
.SetText(column
->GetText());
546 if (mask
& wxLIST_MASK_DATA
)
547 item
.SetData(column
->GetData());
548 if (mask
& wxLIST_MASK_IMAGE
)
549 item
.SetImage(column
->GetImage());
550 if (mask
& wxLIST_MASK_STATE
)
551 item
.SetState(column
->GetState());
552 if (mask
& wxLIST_MASK_FORMAT
)
553 item
.SetAlign(column
->GetAlign());
554 if (mask
& wxLIST_MASK_WIDTH
)
555 item
.SetWidth(column
->GetWidth());
561 // Sets information about this column
562 bool wxListCtrl::SetColumn(int col
, wxListItem
& item
)
565 return m_genericImpl
->SetColumn(col
, item
);
569 if ( col
>= (int)m_colsInfo
.GetCount() )
571 wxListItem
* listItem
= new wxListItem(item
);
572 m_colsInfo
.Append( listItem
);
577 GetColumn( col
, listItem
);
578 long mask
= item
.GetMask();
579 if (mask
& wxLIST_MASK_TEXT
)
580 listItem
.SetText(item
.GetText());
581 if (mask
& wxLIST_MASK_DATA
)
582 listItem
.SetData(item
.GetData());
583 if (mask
& wxLIST_MASK_IMAGE
)
584 listItem
.SetImage(item
.GetImage());
585 if (mask
& wxLIST_MASK_STATE
)
586 listItem
.SetState(item
.GetState());
587 if (mask
& wxLIST_MASK_FORMAT
)
588 listItem
.SetAlign(item
.GetAlign());
589 if (mask
& wxLIST_MASK_WIDTH
)
590 listItem
.SetWidth(item
.GetWidth());
593 // change the appearance in the databrowser.
594 DataBrowserListViewHeaderDesc columnDesc
;
595 columnDesc
.version
=kDataBrowserListViewLatestHeaderDesc
;
596 verify_noerr( m_dbImpl
->GetHeaderDesc( kMinColumnId
+ col
, &columnDesc
) );
599 if (item.GetMask() & wxLIST_MASK_TEXT)
603 enc = m_font.GetEncoding();
605 enc = wxLocale::GetSystemEncoding();
606 wxMacCFStringHolder cfTitle;
607 cfTitle.Assign( item.GetText() , enc );
608 if(columnDesc.titleString)
609 CFRelease(columnDesc.titleString);
610 columnDesc.titleString = cfTitle;
614 if (item
.GetMask() & wxLIST_MASK_IMAGE
&& item
.GetImage() != -1 )
616 columnDesc
.btnContentInfo
.contentType
= kControlContentIconRef
;
617 wxImageList
* imageList
= GetImageList(wxIMAGE_LIST_SMALL
);
618 if (imageList
&& imageList
->GetImageCount() > 0 )
620 wxBitmap bmp
= imageList
->GetBitmap( item
.GetImage() );
621 IconRef icon
= bmp
.GetBitmapData()->GetIconRef();
622 columnDesc
.btnContentInfo
.u
.iconRef
= icon
;
626 verify_noerr( m_dbImpl
->SetHeaderDesc( kMinColumnId
+ col
, &columnDesc
) );
632 int wxListCtrl::GetColumnCount() const
635 return m_genericImpl
->GetColumnCount();
640 m_dbImpl
->GetColumnCount(&count
);
647 // Gets the column width
648 int wxListCtrl::GetColumnWidth(int col
) const
651 return m_genericImpl
->GetColumnWidth(col
);
655 return m_dbImpl
->GetColumnWidth(col
);
661 // Sets the column width
662 bool wxListCtrl::SetColumnWidth(int col
, int width
)
665 return m_genericImpl
->SetColumnWidth(col
, width
);
670 if (width
== wxLIST_AUTOSIZE
|| width
== wxLIST_AUTOSIZE_USEHEADER
)
675 for (int column
= 0; column
< GetColumnCount(); column
++)
677 m_dbImpl
->SetColumnWidth(col
, mywidth
);
681 m_dbImpl
->SetColumnWidth(col
, mywidth
);
689 // Gets the number of items that can fit vertically in the
690 // visible area of the list control (list or report view)
691 // or the total number of items in the list control (icon
692 // or small icon view)
693 int wxListCtrl::GetCountPerPage() const
696 return m_genericImpl
->GetCountPerPage();
705 // Gets the edit control for editing labels.
706 wxTextCtrl
* wxListCtrl::GetEditControl() const
709 return m_genericImpl
->GetEditControl();
714 // Gets information about the item
715 bool wxListCtrl::GetItem(wxListItem
& info
) const
718 return m_genericImpl
->GetItem(info
);
723 m_dbImpl
->MacGetColumnInfo(info
.m_itemId
, info
.m_col
, info
);
726 info
.SetText( OnGetItemText(info
.m_itemId
, info
.m_col
) );
727 info
.SetImage( OnGetItemColumnImage(info
.m_itemId
, info
.m_col
) );
728 wxListItemAttr
* attrs
= OnGetItemAttr( info
.m_itemId
);
731 info
.SetFont( attrs
->GetFont() );
732 info
.SetBackgroundColour( attrs
->GetBackgroundColour() );
733 info
.SetTextColour( attrs
->GetTextColour() );
741 // Sets information about the item
742 bool wxListCtrl::SetItem(wxListItem
& info
)
745 return m_genericImpl
->SetItem(info
);
748 m_dbImpl
->MacSetColumnInfo( info
.m_itemId
, info
.m_col
, &info
);
753 long wxListCtrl::SetItem(long index
, int col
, const wxString
& label
, int imageId
)
756 return m_genericImpl
->SetItem(index
, col
, label
, imageId
);
760 info
.m_mask
= wxLIST_MASK_TEXT
;
761 info
.m_itemId
= index
;
765 info
.m_image
= imageId
;
766 info
.m_mask
|= wxLIST_MASK_IMAGE
;
768 return SetItem(info
);
772 // Gets the item state
773 int wxListCtrl::GetItemState(long item
, long stateMask
) const
776 return m_genericImpl
->GetItemState(item
, stateMask
);
780 info
.m_mask
= wxLIST_MASK_STATE
;
781 info
.m_stateMask
= stateMask
;
782 info
.m_itemId
= item
;
790 // Sets the item state
791 bool wxListCtrl::SetItemState(long item
, long state
, long stateMask
)
794 return m_genericImpl
->SetItemState(item
, state
, stateMask
);
797 info
.m_mask
= wxLIST_MASK_STATE
;
798 info
.m_stateMask
= stateMask
;
799 info
.m_state
= state
;
800 info
.m_itemId
= item
;
801 return SetItem(info
);
804 // Sets the item image
805 bool wxListCtrl::SetItemImage(long item
, int image
, int WXUNUSED(selImage
))
807 return SetItemColumnImage(item
, 0, image
);
810 // Sets the item image
811 bool wxListCtrl::SetItemColumnImage(long item
, long column
, int image
)
814 return m_genericImpl
->SetItemColumnImage(item
, column
, image
);
818 info
.m_mask
= wxLIST_MASK_IMAGE
;
819 info
.m_image
= image
;
820 info
.m_itemId
= item
;
823 return SetItem(info
);
826 // Gets the item text
827 wxString
wxListCtrl::GetItemText(long item
) const
830 return m_genericImpl
->GetItemText(item
);
834 info
.m_mask
= wxLIST_MASK_TEXT
;
835 info
.m_itemId
= item
;
838 return wxEmptyString
;
842 // Sets the item text
843 void wxListCtrl::SetItemText(long item
, const wxString
& str
)
846 return m_genericImpl
->SetItemText(item
, str
);
850 info
.m_mask
= wxLIST_MASK_TEXT
;
851 info
.m_itemId
= item
;
857 // Gets the item data
858 long wxListCtrl::GetItemData(long item
) const
861 return m_genericImpl
->GetItemData(item
);
865 info
.m_mask
= wxLIST_MASK_DATA
;
866 info
.m_itemId
= item
;
873 // Sets the item data
874 bool wxListCtrl::SetItemData(long item
, long data
)
877 return m_genericImpl
->SetItemData(item
, data
);
881 info
.m_mask
= wxLIST_MASK_DATA
;
882 info
.m_itemId
= item
;
885 return SetItem(info
);
888 wxRect
wxListCtrl::GetViewRect() const
890 wxASSERT_MSG( !HasFlag(wxLC_REPORT
| wxLC_LIST
),
891 _T("wxListCtrl::GetViewRect() only works in icon mode") );
894 return m_genericImpl
->GetViewRect();
900 // Gets the item rectangle
901 bool wxListCtrl::GetItemRect(long item
, wxRect
& rect
, int code
) const
904 return m_genericImpl
->GetItemRect(item
, rect
, code
);
909 // Gets the item position
910 bool wxListCtrl::GetItemPosition(long item
, wxPoint
& pos
) const
913 return m_genericImpl
->GetItemPosition(item
, pos
);
915 bool success
= false;
920 // Sets the item position.
921 bool wxListCtrl::SetItemPosition(long item
, const wxPoint
& pos
)
924 return m_genericImpl
->SetItemPosition(item
, pos
);
929 // Gets the number of items in the list control
930 int wxListCtrl::GetItemCount() const
933 return m_genericImpl
->GetItemCount();
936 return m_dbImpl
->MacGetCount();
941 void wxListCtrl::SetItemSpacing( int spacing
, bool isSmall
)
944 m_genericImpl
->SetItemSpacing(spacing
, isSmall
);
947 wxSize
wxListCtrl::GetItemSpacing() const
950 return m_genericImpl
->GetItemSpacing();
955 void wxListCtrl::SetItemTextColour( long item
, const wxColour
&col
)
959 m_genericImpl
->SetItemTextColour(item
, col
);
964 info
.m_itemId
= item
;
965 info
.SetTextColour( col
);
969 wxColour
wxListCtrl::GetItemTextColour( long item
) const
972 return m_genericImpl
->GetItemTextColour(item
);
978 return info
.GetTextColour();
983 void wxListCtrl::SetItemBackgroundColour( long item
, const wxColour
&col
)
987 m_genericImpl
->SetItemBackgroundColour(item
, col
);
992 info
.m_itemId
= item
;
993 info
.SetBackgroundColour( col
);
997 wxColour
wxListCtrl::GetItemBackgroundColour( long item
) const
1000 return m_genericImpl
->GetItemBackgroundColour(item
);
1006 return info
.GetBackgroundColour();
1008 return wxNullColour
;
1011 void wxListCtrl::SetItemFont( long item
, const wxFont
&f
)
1015 m_genericImpl
->SetItemFont(item
, f
);
1020 info
.m_itemId
= item
;
1025 wxFont
wxListCtrl::GetItemFont( long item
) const
1028 return m_genericImpl
->GetItemFont(item
);
1034 return info
.GetFont();
1040 // Gets the number of selected items in the list control
1041 int wxListCtrl::GetSelectedItemCount() const
1044 return m_genericImpl
->GetSelectedItemCount();
1047 return m_dbImpl
->GetSelectedItemCount(NULL
, true);
1052 // Gets the text colour of the listview
1053 wxColour
wxListCtrl::GetTextColour() const
1056 return m_genericImpl
->GetTextColour();
1058 // TODO: we need owner drawn list items to customize text color.
1062 return wxNullColour
;
1065 // Sets the text colour of the listview
1066 void wxListCtrl::SetTextColour(const wxColour
& col
)
1070 m_genericImpl
->SetTextColour(col
);
1078 // Gets the index of the topmost visible item when in
1079 // list or report view
1080 long wxListCtrl::GetTopItem() const
1083 return m_genericImpl
->GetTopItem();
1088 // Searches for an item, starting from 'item'.
1089 // 'geometry' is one of
1090 // wxLIST_NEXT_ABOVE/ALL/BELOW/LEFT/RIGHT.
1091 // 'state' is a state bit flag, one or more of
1092 // wxLIST_STATE_DROPHILITED/FOCUSED/SELECTED/CUT.
1093 // item can be -1 to find the first item that matches the
1095 // Returns the item or -1 if unsuccessful.
1096 long wxListCtrl::GetNextItem(long item
, int geom
, int state
) const
1099 return m_genericImpl
->GetNextItem(item
, geom
, state
);
1101 if (m_dbImpl
&& geom
== wxLIST_NEXT_ALL
&& state
== wxLIST_STATE_SELECTED
)
1103 long count
= m_dbImpl
->MacGetCount() ;
1104 for ( long line
= item
+ 1 ; line
< count
; line
++ )
1106 wxMacDataItem
* id
= m_dbImpl
->GetItemFromLine(line
);
1107 if ( m_dbImpl
->IsItemSelected(id
) )
1117 wxImageList
*wxListCtrl::GetImageList(int which
) const
1120 return m_genericImpl
->GetImageList(which
);
1122 if ( which
== wxIMAGE_LIST_NORMAL
)
1124 return m_imageListNormal
;
1126 else if ( which
== wxIMAGE_LIST_SMALL
)
1128 return m_imageListSmall
;
1130 else if ( which
== wxIMAGE_LIST_STATE
)
1132 return m_imageListState
;
1137 void wxListCtrl::SetImageList(wxImageList
*imageList
, int which
)
1141 m_genericImpl
->SetImageList(imageList
, which
);
1145 if ( which
== wxIMAGE_LIST_NORMAL
)
1147 if (m_ownsImageListNormal
) delete m_imageListNormal
;
1148 m_imageListNormal
= imageList
;
1149 m_ownsImageListNormal
= false;
1151 else if ( which
== wxIMAGE_LIST_SMALL
)
1153 if (m_ownsImageListSmall
) delete m_imageListSmall
;
1154 m_imageListSmall
= imageList
;
1155 m_ownsImageListSmall
= false;
1157 else if ( which
== wxIMAGE_LIST_STATE
)
1159 if (m_ownsImageListState
) delete m_imageListState
;
1160 m_imageListState
= imageList
;
1161 m_ownsImageListState
= false;
1165 void wxListCtrl::AssignImageList(wxImageList
*imageList
, int which
)
1169 m_genericImpl
->AssignImageList(imageList
, which
);
1173 SetImageList(imageList
, which
);
1174 if ( which
== wxIMAGE_LIST_NORMAL
)
1175 m_ownsImageListNormal
= true;
1176 else if ( which
== wxIMAGE_LIST_SMALL
)
1177 m_ownsImageListSmall
= true;
1178 else if ( which
== wxIMAGE_LIST_STATE
)
1179 m_ownsImageListState
= true;
1182 // ----------------------------------------------------------------------------
1184 // ----------------------------------------------------------------------------
1186 // Arranges the items
1187 bool wxListCtrl::Arrange(int flag
)
1190 return m_genericImpl
->Arrange(flag
);
1195 bool wxListCtrl::DeleteItem(long item
)
1198 return m_genericImpl
->DeleteItem(item
);
1202 m_dbImpl
->MacDelete(item
);
1203 wxListEvent
event( wxEVT_COMMAND_LIST_DELETE_ITEM
, GetId() );
1204 event
.SetEventObject( this );
1205 event
.m_itemIndex
= item
;
1206 GetEventHandler()->ProcessEvent( event
);
1212 // Deletes all items
1213 bool wxListCtrl::DeleteAllItems()
1216 return m_genericImpl
->DeleteAllItems();
1220 m_dbImpl
->MacClear();
1221 wxListEvent
event( wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS
, GetId() );
1222 event
.SetEventObject( this );
1223 GetEventHandler()->ProcessEvent( event
);
1228 // Deletes all items
1229 bool wxListCtrl::DeleteAllColumns()
1232 return m_genericImpl
->DeleteAllColumns();
1237 m_dbImpl
->GetColumnCount(&cols
);
1238 for (UInt32 col
= 0; col
< cols
; col
++)
1248 bool wxListCtrl::DeleteColumn(int col
)
1251 return m_genericImpl
->DeleteColumn(col
);
1255 OSStatus err
= m_dbImpl
->RemoveColumn(col
);
1256 return err
== noErr
;
1262 // Clears items, and columns if there are any.
1263 void wxListCtrl::ClearAll()
1267 m_genericImpl
->ClearAll();
1278 wxTextCtrl
* wxListCtrl::EditLabel(long item
, wxClassInfo
* textControlClass
)
1281 return m_genericImpl
->EditLabel(item
, textControlClass
);
1285 wxMacDataItem
* id
= m_dbImpl
->GetItemFromLine(item
);
1286 verify_noerr( SetDataBrowserEditItem(m_dbImpl
->GetControlRef(), (DataBrowserItemID
)id
, kMinColumnId
) );
1291 // End label editing, optionally cancelling the edit
1292 bool wxListCtrl::EndEditLabel(bool cancel
)
1294 // TODO: generic impl. doesn't have this method - is it needed for us?
1296 return true; // m_genericImpl->EndEditLabel(cancel);
1299 verify_noerr( SetDataBrowserEditItem(m_dbImpl
->GetControlRef(), kDataBrowserNoItem
, kMinColumnId
) );
1303 // Ensures this item is visible
1304 bool wxListCtrl::EnsureVisible(long item
)
1307 return m_genericImpl
->EnsureVisible(item
);
1311 wxMacDataItem
* dataItem
= m_dbImpl
->GetItemFromLine(item
);
1312 m_dbImpl
->RevealItem(dataItem
, kDataBrowserRevealWithoutSelecting
);
1318 // Find an item whose label matches this string, starting from the item after 'start'
1319 // or the beginning if 'start' is -1.
1320 long wxListCtrl::FindItem(long start
, const wxString
& str
, bool partial
)
1323 return m_genericImpl
->FindItem(start
, str
, partial
);
1328 // Find an item whose data matches this data, starting from the item after 'start'
1329 // or the beginning if 'start' is -1.
1330 long wxListCtrl::FindItem(long start
, long data
)
1333 return m_genericImpl
->FindItem(start
, data
);
1335 long idx
= start
+ 1;
1336 long count
= GetItemCount();
1340 if (GetItemData(idx
) == data
)
1348 // Find an item nearest this position in the specified direction, starting from
1349 // the item after 'start' or the beginning if 'start' is -1.
1350 long wxListCtrl::FindItem(long start
, const wxPoint
& pt
, int direction
)
1353 return m_genericImpl
->FindItem(start
, pt
, direction
);
1357 // Determines which item (if any) is at the specified point,
1358 // giving details in 'flags' (see wxLIST_HITTEST_... flags above)
1360 wxListCtrl::HitTest(const wxPoint
& point
, int& flags
, long *ptrSubItem
) const
1363 return m_genericImpl
->HitTest(point
, flags
, ptrSubItem
);
1369 // Inserts an item, returning the index of the new item if successful,
1371 long wxListCtrl::InsertItem(wxListItem
& info
)
1373 wxASSERT_MSG( !IsVirtual(), _T("can't be used with virtual controls") );
1376 return m_genericImpl
->InsertItem(info
);
1380 int count
= GetItemCount();
1382 if (info
.m_itemId
> count
)
1383 info
.m_itemId
= count
;
1385 m_dbImpl
->MacInsertItem(info
.m_itemId
, &info
);
1386 wxListEvent
event( wxEVT_COMMAND_LIST_INSERT_ITEM
, GetId() );
1387 event
.SetEventObject( this );
1388 event
.m_itemIndex
= info
.m_itemId
;
1389 GetEventHandler()->ProcessEvent( event
);
1392 return info
.m_itemId
;
1395 long wxListCtrl::InsertItem(long index
, const wxString
& label
)
1398 return m_genericImpl
->InsertItem(index
, label
);
1401 info
.m_text
= label
;
1402 info
.m_mask
= wxLIST_MASK_TEXT
;
1403 info
.m_itemId
= index
;
1404 return InsertItem(info
);
1407 // Inserts an image item
1408 long wxListCtrl::InsertItem(long index
, int imageIndex
)
1411 return m_genericImpl
->InsertItem(index
, imageIndex
);
1414 info
.m_image
= imageIndex
;
1415 info
.m_mask
= wxLIST_MASK_IMAGE
;
1416 info
.m_itemId
= index
;
1417 return InsertItem(info
);
1420 // Inserts an image/string item
1421 long wxListCtrl::InsertItem(long index
, const wxString
& label
, int imageIndex
)
1424 return m_genericImpl
->InsertItem(index
, label
, imageIndex
);
1427 info
.m_image
= imageIndex
;
1428 info
.m_text
= label
;
1429 info
.m_mask
= wxLIST_MASK_IMAGE
| wxLIST_MASK_TEXT
;
1430 info
.m_itemId
= index
;
1431 return InsertItem(info
);
1434 // For list view mode (only), inserts a column.
1435 long wxListCtrl::InsertColumn(long col
, wxListItem
& item
)
1438 return m_genericImpl
->InsertColumn(col
, item
);
1442 int width
= item
.GetWidth();
1443 if ( !(item
.GetMask() & wxLIST_MASK_WIDTH
) )
1446 DataBrowserPropertyType type
= kDataBrowserCustomType
; //kDataBrowserTextType;
1447 wxImageList
* imageList
= GetImageList(wxIMAGE_LIST_SMALL
);
1448 if (imageList
&& imageList
->GetImageCount() > 0)
1450 wxBitmap bmp
= imageList
->GetBitmap(0);
1452 // type = kDataBrowserIconAndTextType;
1455 SInt16 just
= teFlushDefault
;
1456 if (item
.GetMask() & wxLIST_MASK_FORMAT
)
1458 if (item
.GetAlign() == wxLIST_FORMAT_LEFT
)
1460 else if (item
.GetAlign() == wxLIST_FORMAT_CENTER
)
1462 else if (item
.GetAlign() == wxLIST_FORMAT_RIGHT
)
1463 just
= teFlushRight
;
1465 m_dbImpl
->InsertColumn(col
, type
, item
.GetText(), just
, width
);
1466 SetColumn(col
, item
);
1468 // set/remove options based on the wxListCtrl type.
1469 DataBrowserTableViewColumnID id
;
1470 m_dbImpl
->GetColumnIDFromIndex(col
, &id
);
1471 DataBrowserPropertyFlags flags
;
1472 verify_noerr(m_dbImpl
->GetPropertyFlags(id
, &flags
));
1473 if (GetWindowStyleFlag() & wxLC_EDIT_LABELS
)
1474 flags
|= kDataBrowserPropertyIsEditable
;
1476 if (GetWindowStyleFlag() & wxLC_VIRTUAL
){
1477 flags
&= ~kDataBrowserListViewSortableColumn
;
1479 verify_noerr(m_dbImpl
->SetPropertyFlags(id
, flags
));
1485 long wxListCtrl::InsertColumn(long col
,
1486 const wxString
& heading
,
1491 return m_genericImpl
->InsertColumn(col
, heading
, format
, width
);
1494 item
.m_mask
= wxLIST_MASK_TEXT
| wxLIST_MASK_FORMAT
;
1495 item
.m_text
= heading
;
1498 item
.m_mask
|= wxLIST_MASK_WIDTH
;
1499 item
.m_width
= width
;
1501 item
.m_format
= format
;
1503 return InsertColumn(col
, item
);
1506 // scroll the control by the given number of pixels (exception: in list view,
1507 // dx is interpreted as number of columns)
1508 bool wxListCtrl::ScrollList(int dx
, int dy
)
1511 return m_genericImpl
->ScrollList(dx
, dy
);
1515 m_dbImpl
->SetScrollPosition(dx
, dy
);
1521 bool wxListCtrl::SortItems(wxListCtrlCompare fn
, long data
)
1524 return m_genericImpl
->SortItems(fn
, data
);
1529 m_compareFuncData
= data
;
1535 // ----------------------------------------------------------------------------
1536 // virtual list controls
1537 // ----------------------------------------------------------------------------
1539 wxString
wxListCtrl::OnGetItemText(long WXUNUSED(item
), long WXUNUSED(col
)) const
1541 // this is a pure virtual function, in fact - which is not really pure
1542 // because the controls which are not virtual don't need to implement it
1543 wxFAIL_MSG( _T("wxListCtrl::OnGetItemText not supposed to be called") );
1545 return wxEmptyString
;
1548 int wxListCtrl::OnGetItemImage(long WXUNUSED(item
)) const
1550 wxCHECK_MSG(!GetImageList(wxIMAGE_LIST_SMALL
),
1552 wxT("List control has an image list, OnGetItemImage or OnGetItemColumnImage should be overridden."));
1556 int wxListCtrl::OnGetItemColumnImage(long item
, long column
) const
1559 return OnGetItemImage(item
);
1564 wxListItemAttr
*wxListCtrl::OnGetItemAttr(long WXUNUSED_UNLESS_DEBUG(item
)) const
1566 wxASSERT_MSG( item
>= 0 && item
< GetItemCount(),
1567 _T("invalid item index in OnGetItemAttr()") );
1569 // no attributes by default
1573 void wxListCtrl::SetItemCount(long count
)
1575 wxASSERT_MSG( IsVirtual(), _T("this is for virtual controls only") );
1579 m_genericImpl
->SetItemCount(count
);
1585 // we need to temporarily disable the new item creation notification
1586 // procedure to speed things up
1587 // FIXME: Even this doesn't seem to help much...
1588 DataBrowserCallbacks callbacks
;
1589 DataBrowserItemNotificationUPP itemUPP
;
1590 GetDataBrowserCallbacks(m_dbImpl
->GetControlRef(), &callbacks
);
1591 itemUPP
= callbacks
.u
.v1
.itemNotificationCallback
;
1592 callbacks
.u
.v1
.itemNotificationCallback
= 0;
1593 m_dbImpl
->SetCallbacks(&callbacks
);
1594 ::AddDataBrowserItems(m_dbImpl
->GetControlRef(), kDataBrowserNoItem
,
1595 count
, NULL
, kDataBrowserItemNoProperty
);
1596 callbacks
.u
.v1
.itemNotificationCallback
= itemUPP
;
1597 m_dbImpl
->SetCallbacks(&callbacks
);
1602 void wxListCtrl::RefreshItem(long item
)
1606 m_genericImpl
->RefreshItem(item
);
1611 GetItemRect(item
, rect
);
1615 void wxListCtrl::RefreshItems(long itemFrom
, long itemTo
)
1619 m_genericImpl
->RefreshItems(itemFrom
, itemTo
);
1623 wxRect rect1
, rect2
;
1624 GetItemRect(itemFrom
, rect1
);
1625 GetItemRect(itemTo
, rect2
);
1627 wxRect rect
= rect1
;
1628 rect
.height
= rect2
.GetBottom() - rect1
.GetTop();
1634 // wxMac internal data structures
1636 wxMacListCtrlItem::~wxMacListCtrlItem()
1640 void wxMacListCtrlItem::Notification(wxMacDataItemBrowserControl
*owner
,
1641 DataBrowserItemNotification message
,
1642 DataBrowserItemDataRef itemData
) const
1645 wxMacDataBrowserListCtrlControl
*lb
= dynamic_cast<wxMacDataBrowserListCtrlControl
*>(owner
);
1647 // we want to depend on as little as possible to make sure tear-down of controls is safe
1648 if ( message
== kDataBrowserItemRemoved
)
1650 if ( lb
!= NULL
&& lb
->GetClientDataType() == wxClientData_Object
)
1652 delete (wxClientData
*) (m_data
);
1658 else if ( message
== kDataBrowserItemAdded
)
1660 // we don't issue events on adding, the item is not really stored in the list yet, so we
1661 // avoid asserts by gettting out now
1665 wxListCtrl
*list
= wxDynamicCast( owner
->GetPeer() , wxListCtrl
);
1668 bool trigger
= false;
1670 wxListEvent
event( wxEVT_COMMAND_LIST_ITEM_SELECTED
, list
->GetId() );
1671 bool isSingle
= (list
->GetWindowStyle() & wxLC_SINGLE_SEL
) != 0;
1673 event
.SetEventObject( list
);
1674 event
.m_itemIndex
= owner
->GetLineFromItem( this ) ;
1675 if ( !list
->IsVirtual() )
1677 lb
->MacGetColumnInfo(event
.m_itemIndex
,0,event
.m_item
);
1682 case kDataBrowserItemDeselected
:
1683 event
.SetEventType(wxEVT_COMMAND_LIST_ITEM_DESELECTED
);
1685 trigger
= !lb
->IsSelectionSuppressed();
1688 case kDataBrowserItemSelected
:
1689 trigger
= !lb
->IsSelectionSuppressed();
1692 case kDataBrowserItemDoubleClicked
:
1693 event
.SetEventType( wxEVT_COMMAND_LIST_ITEM_ACTIVATED
);
1697 case kDataBrowserEditStarted
:
1698 // TODO : how to veto ?
1699 event
.SetEventType( wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
) ;
1703 case kDataBrowserEditStopped
:
1704 // TODO probably trigger only upon the value store callback, because
1705 // here IIRC we cannot veto
1706 event
.SetEventType( wxEVT_COMMAND_LIST_END_LABEL_EDIT
) ;
1716 // direct notification is not always having the listbox GetSelection() having in synch with event
1717 wxPostEvent( list
->GetEventHandler(), event
);
1723 wxMacDataBrowserListCtrlControl::wxMacDataBrowserListCtrlControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
)
1724 : wxMacDataItemBrowserControl( peer
, pos
, size
, style
)
1726 OSStatus err
= noErr
;
1727 m_clientDataItemsType
= wxClientData_None
;
1728 m_isVirtual
= false;
1730 if ( style
& wxLC_VIRTUAL
)
1733 DataBrowserSelectionFlags options
= kDataBrowserDragSelect
;
1734 if ( style
& wxLC_SINGLE_SEL
)
1736 options
|= kDataBrowserSelectOnlyOne
;
1740 options
|= kDataBrowserCmdTogglesSelection
;
1743 err
= SetSelectionFlags( options
);
1744 verify_noerr( err
);
1746 DataBrowserCustomCallbacks callbacks
;
1747 InitializeDataBrowserCustomCallbacks( &callbacks
, kDataBrowserLatestCustomCallbacks
);
1749 if ( gDataBrowserDrawItemUPP
== NULL
)
1750 gDataBrowserDrawItemUPP
= NewDataBrowserDrawItemUPP(DataBrowserDrawItemProc
);
1752 // if ( gDataBrowserEditItemUPP == NULL )
1753 // gDataBrowserEditItemUPP = NewDataBrowserEditItemUPP(DataBrowserEditTextProc);
1755 if ( gDataBrowserHitTestUPP
== NULL
)
1756 gDataBrowserHitTestUPP
= NewDataBrowserHitTestUPP(DataBrowserHitTestProc
);
1758 callbacks
.u
.v1
.drawItemCallback
= gDataBrowserDrawItemUPP
;
1759 // callbacks.u.v1.editTextCallback = gDataBrowserEditItemUPP;
1760 callbacks
.u
.v1
.hitTestCallback
= gDataBrowserHitTestUPP
;
1762 SetDataBrowserCustomCallbacks( GetControlRef(), &callbacks
);
1764 if ( style
& wxLC_LIST
)
1766 InsertColumn(0, kDataBrowserIconAndTextType
, wxEmptyString
, -1, -1);
1767 verify_noerr( AutoSizeColumns() );
1770 if ( style
& wxLC_LIST
|| style
& wxLC_NO_HEADER
)
1771 verify_noerr( SetHeaderButtonHeight( 0 ) );
1774 SetSortProperty( kMinColumnId
- 1 );
1776 SetSortProperty( kMinColumnId
);
1777 if ( style
& wxLC_SORT_ASCENDING
)
1779 m_sortOrder
= SortOrder_Text_Ascending
;
1780 SetSortOrder( kDataBrowserOrderIncreasing
);
1782 else if ( style
& wxLC_SORT_DESCENDING
)
1784 m_sortOrder
= SortOrder_Text_Descending
;
1785 SetSortOrder( kDataBrowserOrderDecreasing
);
1789 m_sortOrder
= SortOrder_None
;
1792 if ( style
& wxLC_VRULES
)
1794 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
1795 verify_noerr( DataBrowserChangeAttributes(m_controlRef
, kDataBrowserAttributeListViewDrawColumnDividers
, kDataBrowserAttributeNone
) );
1799 verify_noerr( SetHiliteStyle(kDataBrowserTableViewFillHilite
) );
1800 err
= SetHasScrollBars( (style
& wxHSCROLL
) != 0 , true );
1803 pascal Boolean
wxMacDataBrowserListCtrlControl::DataBrowserEditTextProc(
1805 DataBrowserItemID itemID
,
1806 DataBrowserPropertyID property
,
1807 CFStringRef theString
,
1808 Rect
*maxEditTextRect
,
1809 Boolean
*shrinkToFit
)
1811 Boolean result
= false;
1812 wxMacDataBrowserListCtrlControl
* ctl
= dynamic_cast<wxMacDataBrowserListCtrlControl
*>( wxMacControl::GetReferenceFromNativeControl( browser
) );
1815 result
= ctl
->ConfirmEditText(itemID
, property
, theString
, maxEditTextRect
, shrinkToFit
);
1816 theString
= CFSTR("Hello!");
1821 bool wxMacDataBrowserListCtrlControl::ConfirmEditText(
1822 DataBrowserItemID itemID
,
1823 DataBrowserPropertyID property
,
1824 CFStringRef theString
,
1825 Rect
*maxEditTextRect
,
1826 Boolean
*shrinkToFit
)
1828 //wxListCtrl* list = wxDynamicCast( GetPeer() , wxListCtrl );
1832 pascal void wxMacDataBrowserListCtrlControl::DataBrowserDrawItemProc(
1834 DataBrowserItemID itemID
,
1835 DataBrowserPropertyID property
,
1836 DataBrowserItemState itemState
,
1837 const Rect
*itemRect
,
1839 Boolean colorDevice
)
1841 wxMacDataBrowserListCtrlControl
* ctl
= dynamic_cast<wxMacDataBrowserListCtrlControl
*>( wxMacControl::GetReferenceFromNativeControl( browser
) );
1844 ctl
->DrawItem(itemID
, property
, itemState
, itemRect
, gdDepth
, colorDevice
);
1848 // routines needed for DrawItem
1853 kTextBoxHeight
= 14,
1854 kIconTextSpacingV
= 2,
1856 kContentHeight
= kIconHeight
+ kTextBoxHeight
+ kIconTextSpacingV
1859 static void calculateCGDrawingBounds(CGRect inItemRect
, CGRect
*outIconRect
, CGRect
*outTextRect
, bool hasIcon
= false)
1862 float iconH
, iconW
= 0;
1863 float padding
= kItemPadding
;
1866 iconH
= kIconHeight
;
1868 padding
= padding
*2;
1871 textBottom
= inItemRect
.origin
.y
;
1873 *outIconRect
= CGRectMake(inItemRect
.origin
.x
+ kItemPadding
,
1874 textBottom
+ kIconTextSpacingV
, kIconWidth
,
1877 *outTextRect
= CGRectMake(inItemRect
.origin
.x
+ padding
+ iconW
,
1878 textBottom
+ kIconTextSpacingV
, inItemRect
.size
.width
- padding
- iconW
,
1879 inItemRect
.size
.height
- kIconTextSpacingV
);
1882 void wxMacDataBrowserListCtrlControl::DrawItem(
1883 DataBrowserItemID itemID
,
1884 DataBrowserPropertyID property
,
1885 DataBrowserItemState itemState
,
1886 const Rect
*itemRect
,
1888 Boolean colorDevice
)
1891 wxFont font
= wxNullFont
;
1893 short listColumn
= property
- kMinColumnId
;
1895 wxListCtrl
* list
= wxDynamicCast( GetPeer() , wxListCtrl
);
1896 wxMacListCtrlItem
* lcItem
;
1897 wxColour color
= *wxBLACK
;
1898 wxColour bgColor
= wxNullColour
;
1900 if (listColumn
>= 0)
1904 lcItem
= (wxMacListCtrlItem
*) itemID
;
1905 if (lcItem
->HasColumnInfo(listColumn
)){
1906 wxListItem
* item
= lcItem
->GetColumnInfo(listColumn
);
1908 // we always use the 0 column to get font and text/background colors.
1909 if (lcItem
->HasColumnInfo(0))
1911 wxListItem
* firstItem
= lcItem
->GetColumnInfo(0);
1912 color
= firstItem
->GetTextColour();
1913 bgColor
= firstItem
->GetBackgroundColour();
1914 font
= firstItem
->GetFont();
1917 if (item
->GetMask() & wxLIST_MASK_TEXT
)
1918 text
= item
->GetText();
1919 if (item
->GetMask() & wxLIST_MASK_IMAGE
)
1920 imgIndex
= item
->GetImage();
1926 text
= list
->OnGetItemText( (long)itemID
-1, listColumn
);
1927 imgIndex
= list
->OnGetItemColumnImage( (long)itemID
-1, listColumn
);
1928 wxListItemAttr
* attrs
= list
->OnGetItemAttr( (long)itemID
-1 );
1931 if (attrs
->HasBackgroundColour())
1932 bgColor
= attrs
->GetBackgroundColour();
1933 if (attrs
->HasTextColour())
1934 color
= attrs
->GetTextColour();
1935 if (attrs
->HasFont())
1936 font
= attrs
->GetFont();
1941 wxColour listBgColor
= list
->GetBackgroundColour();
1942 if (bgColor
== wxNullColour
)
1943 bgColor
= listBgColor
;
1945 wxFont listFont
= list
->GetFont();
1946 if (font
== wxNullFont
)
1949 wxMacCFStringHolder cfString
;
1950 cfString
.Assign( text
, wxLocale::GetSystemEncoding() );
1953 CGRect enclosingCGRect
, iconCGRect
, textCGRect
;
1955 ThemeDrawingState savedState
= NULL
;
1956 CGContextRef context
= (CGContextRef
)list
->MacGetDrawingContext();
1957 RGBColor labelColor
;
1959 GetDataBrowserItemPartBounds(GetControlRef(), itemID
, property
, kDataBrowserPropertyEnclosingPart
,
1962 enclosingCGRect
= CGRectMake(enclosingRect
.left
,
1964 enclosingRect
.right
- enclosingRect
.left
,
1965 enclosingRect
.bottom
- enclosingRect
.top
);
1967 active
= IsControlActive(GetControlRef());
1969 if (itemState
== kDataBrowserItemIsSelected
)
1971 RGBColor foregroundColor
;
1973 GetThemeDrawingState(&savedState
);
1975 GetThemeBrushAsColor(kThemeBrushAlternatePrimaryHighlightColor
, 32, true, &foregroundColor
);
1976 GetThemeTextColor(kThemeTextColorWhite
, gdDepth
, colorDevice
, &labelColor
);
1978 CGContextSaveGState(context
);
1980 CGContextSetRGBFillColor(context
, (float)foregroundColor
.red
/ (float)USHRT_MAX
,
1981 (float)foregroundColor
.green
/ (float)USHRT_MAX
,
1982 (float)foregroundColor
.blue
/ (float)USHRT_MAX
, 1.0);
1983 CGContextFillRect(context
, enclosingCGRect
);
1985 CGContextRestoreGState(context
);
1991 labelColor
= MAC_WXCOLORREF( color
.GetPixel() );
1992 else if (list
->GetTextColour().Ok())
1993 labelColor
= MAC_WXCOLORREF( list
->GetTextColour().GetPixel() );
1997 labelColor
.green
= 0;
1998 labelColor
.blue
= 0;
2003 RGBColor foregroundColor
= MAC_WXCOLORREF( bgColor
.GetPixel() );
2004 CGContextSaveGState(context
);
2006 CGContextSetRGBFillColor(context
, (float)foregroundColor
.red
/ (float)USHRT_MAX
,
2007 (float)foregroundColor
.green
/ (float)USHRT_MAX
,
2008 (float)foregroundColor
.blue
/ (float)USHRT_MAX
, 1.0);
2009 CGContextFillRect(context
, enclosingCGRect
);
2011 CGContextRestoreGState(context
);
2015 calculateCGDrawingBounds(enclosingCGRect
, &iconCGRect
, &textCGRect
, (imgIndex
!= -1) );
2019 wxImageList
* imageList
= list
->GetImageList(wxIMAGE_LIST_SMALL
);
2020 if (imageList
&& imageList
->GetImageCount() > 0){
2021 wxBitmap bmp
= imageList
->GetBitmap(imgIndex
);
2022 IconRef icon
= bmp
.GetBitmapData()->GetIconRef();
2026 iconLabel
.green
= 0;
2029 PlotIconRefInContext(context
, &iconCGRect
, kAlignNone
,
2030 active
? kTransformNone
: kTransformDisabled
, &iconLabel
,
2031 kPlotIconRefNormalFlags
, icon
);
2035 HIThemeTextHorizontalFlush hFlush
= kHIThemeTextHorizontalFlushLeft
;
2036 UInt16 fontID
= kThemeViewsFont
;
2040 if (font
.GetFamily() != wxFONTFAMILY_DEFAULT
)
2041 fontID
= font
.MacGetThemeFontID();
2043 // FIXME: replace these with CG or ATSUI calls so we can remove this #ifndef.
2045 ::TextSize( (short)(font
.MacGetFontSize()) ) ;
2046 ::TextFace( font
.MacGetFontStyle() ) ;
2051 list
->GetColumn(listColumn
, item
);
2052 if (item
.GetMask() & wxLIST_MASK_FORMAT
)
2054 if (item
.GetAlign() == wxLIST_FORMAT_LEFT
)
2055 hFlush
= kHIThemeTextHorizontalFlushLeft
;
2056 else if (item
.GetAlign() == wxLIST_FORMAT_CENTER
)
2057 hFlush
= kHIThemeTextHorizontalFlushCenter
;
2058 else if (item
.GetAlign() == wxLIST_FORMAT_RIGHT
)
2060 hFlush
= kHIThemeTextHorizontalFlushRight
;
2061 textCGRect
.origin
.x
-= kItemPadding
; // give a little extra paddding
2065 HIThemeTextInfo info
;
2066 info
.version
= kHIThemeTextInfoVersionZero
;
2067 info
.state
= active
? kThemeStateActive
: kThemeStateInactive
;
2068 info
.fontID
= fontID
;
2069 info
.horizontalFlushness
= hFlush
;
2070 info
.verticalFlushness
= kHIThemeTextVerticalFlushCenter
;
2071 info
.options
= kHIThemeTextBoxOptionNone
;
2072 info
.truncationPosition
= kHIThemeTextTruncationEnd
;
2073 info
.truncationMaxLines
= 1;
2075 CGContextSaveGState(context
);
2076 CGContextSetRGBFillColor (context
, (float)labelColor
.red
/ (float)USHRT_MAX
,
2077 (float)labelColor
.green
/ (float)USHRT_MAX
,
2078 (float)labelColor
.blue
/ (float)USHRT_MAX
, 1.0);
2080 HIThemeDrawTextBox(cfString
, &textCGRect
, &info
, context
, kHIThemeOrientationNormal
);
2082 CGContextRestoreGState(context
);
2084 if (savedState
!= NULL
)
2085 SetThemeDrawingState(savedState
, true);
2088 OSStatus
wxMacDataBrowserListCtrlControl::GetSetItemData(DataBrowserItemID itemID
,
2089 DataBrowserPropertyID property
,
2090 DataBrowserItemDataRef itemData
,
2091 Boolean changeValue
)
2095 short listColumn
= property
- kMinColumnId
;
2097 OSStatus err
= errDataBrowserPropertyNotSupported
;
2098 wxListCtrl
* list
= wxDynamicCast( GetPeer() , wxListCtrl
);
2099 wxMacListCtrlItem
* lcItem
;
2101 if (listColumn
>= 0)
2105 lcItem
= (wxMacListCtrlItem
*) itemID
;
2106 if (lcItem
->HasColumnInfo(listColumn
)){
2107 wxListItem
* item
= lcItem
->GetColumnInfo(listColumn
);
2108 if (item
->GetMask() & wxLIST_MASK_TEXT
)
2109 text
= item
->GetText();
2110 if (item
->GetMask() & wxLIST_MASK_IMAGE
)
2111 imgIndex
= item
->GetImage();
2116 text
= list
->OnGetItemText( (long)itemID
-1, listColumn
);
2117 imgIndex
= list
->OnGetItemColumnImage( (long)itemID
-1, listColumn
);
2125 case kDataBrowserItemIsEditableProperty
:
2126 if ( list
&& list
->HasFlag( wxLC_EDIT_LABELS
) )
2128 verify_noerr(SetDataBrowserItemDataBooleanValue( itemData
, true ));
2133 if ( property
>= kMinColumnId
)
2135 wxMacCFStringHolder cfStr
;
2138 cfStr
.Assign( text
, wxLocale::GetSystemEncoding() );
2139 err
= ::SetDataBrowserItemDataText( itemData
, cfStr
);
2145 if ( imgIndex
!= -1 )
2147 wxImageList
* imageList
= list
->GetImageList(wxIMAGE_LIST_SMALL
);
2148 if (imageList
&& imageList
->GetImageCount() > 0){
2149 wxBitmap bmp
= imageList
->GetBitmap(imgIndex
);
2150 IconRef icon
= bmp
.GetBitmapData()->GetIconRef();
2151 ::SetDataBrowserItemDataIcon(itemData
, icon
);
2165 if ( property
>= kMinColumnId
)
2167 short listColumn
= property
- kMinColumnId
;
2169 // TODO probably send the 'end edit' from here, as we
2170 // can then deal with the veto
2172 verify_noerr( GetDataBrowserItemDataText( itemData
, &sr
) ) ;
2173 wxMacCFStringHolder
cfStr(sr
) ;;
2175 list
->SetItem( (long)itemData
-1 , listColumn
, cfStr
.AsString() ) ;
2179 lcItem
->SetColumnTextValue( listColumn
, cfStr
.AsString() );
2189 void wxMacDataBrowserListCtrlControl::ItemNotification(DataBrowserItemID itemID
,
2190 DataBrowserItemNotification message
,
2191 DataBrowserItemDataRef itemData
)
2193 // we want to depend on as little as possible to make sure tear-down of controls is safe
2194 if ( message
== kDataBrowserItemRemoved
)
2196 // make sure MacDelete does the proper teardown.
2199 else if ( message
== kDataBrowserItemAdded
)
2201 // we don't issue events on adding, the item is not really stored in the list yet, so we
2202 // avoid asserts by getting out now
2206 wxListCtrl
*list
= wxDynamicCast( GetPeer() , wxListCtrl
);
2209 bool trigger
= false;
2211 wxListEvent
event( wxEVT_COMMAND_LIST_ITEM_SELECTED
, list
->GetId() );
2212 bool isSingle
= (list
->GetWindowStyle() & wxLC_SINGLE_SEL
) != 0;
2214 event
.SetEventObject( list
);
2215 if ( !list
->IsVirtual() )
2217 DataBrowserTableViewRowIndex result
= 0;
2218 verify_noerr( GetItemRow( itemID
, &result
) ) ;
2219 event
.m_itemIndex
= result
;
2221 if (event
.m_itemIndex
>= 0)
2222 MacGetColumnInfo(event
.m_itemIndex
,0,event
.m_item
);
2226 event
.m_itemIndex
= (long)itemID
;
2231 case kDataBrowserItemDeselected
:
2232 event
.SetEventType(wxEVT_COMMAND_LIST_ITEM_DESELECTED
);
2234 trigger
= !IsSelectionSuppressed();
2237 case kDataBrowserItemSelected
:
2238 trigger
= !IsSelectionSuppressed();
2242 case kDataBrowserItemDoubleClicked
:
2243 event
.SetEventType( wxEVT_COMMAND_LIST_ITEM_ACTIVATED
);
2247 case kDataBrowserEditStarted
:
2248 // TODO : how to veto ?
2249 event
.SetEventType( wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
) ;
2253 case kDataBrowserEditStopped
:
2254 // TODO probably trigger only upon the value store callback, because
2255 // here IIRC we cannot veto
2256 event
.SetEventType( wxEVT_COMMAND_LIST_END_LABEL_EDIT
) ;
2266 // direct notification is not always having the listbox GetSelection() having in synch with event
2267 wxPostEvent( list
->GetEventHandler(), event
);
2272 Boolean
wxMacDataBrowserListCtrlControl::CompareItems(DataBrowserItemID itemOneID
,
2273 DataBrowserItemID itemTwoID
,
2274 DataBrowserPropertyID sortProperty
)
2277 bool retval
= false;
2279 wxString otherItemText
;
2280 int colId
= sortProperty
- kMinColumnId
;
2282 long otherItemNum
= 0;
2284 wxListCtrl
* list
= wxDynamicCast( GetPeer() , wxListCtrl
);
2291 wxMacListCtrlItem
* item
= (wxMacListCtrlItem
*)itemOneID
;
2292 wxMacListCtrlItem
* otherItem
= (wxMacListCtrlItem
*)itemTwoID
;
2293 wxListCtrlCompare func
= list
->GetCompareFunc();
2294 if (func
!= NULL
&& item
->HasColumnInfo(colId
) && otherItem
->HasColumnInfo(colId
))
2295 return func(item
->GetColumnInfo(colId
)->GetData(), otherItem
->GetColumnInfo(colId
)->GetData(), list
->GetCompareFuncData()) >= 0;
2297 itemNum
= item
->GetOrder();
2298 otherItemNum
= otherItem
->GetOrder();
2299 if (item
->HasColumnInfo(colId
))
2300 itemText
= item
->GetColumnInfo(colId
)->GetText();
2301 if (otherItem
->HasColumnInfo(colId
))
2302 otherItemText
= otherItem
->GetColumnInfo(colId
)->GetText();
2306 itemNum
= (long)itemOneID
;
2307 otherItemNum
= (long)itemTwoID
;
2308 itemText
= list
->OnGetItemText( itemNum
-1, colId
);
2309 otherItemText
= list
->OnGetItemText( otherItemNum
-1, colId
);
2313 DataBrowserSortOrder sort
;
2314 verify_noerr(GetSortOrder(&sort
));
2316 if ( sort
== kDataBrowserOrderIncreasing
)
2318 retval
= itemText
.CmpNoCase( otherItemText
) > 0;
2320 else if ( sort
== kDataBrowserOrderDecreasing
)
2322 retval
= itemText
.CmpNoCase( otherItemText
) < 0;
2326 // fallback for undefined cases
2327 retval
= itemOneID
< itemTwoID
;
2333 wxMacDataBrowserListCtrlControl::~wxMacDataBrowserListCtrlControl()
2337 void wxMacDataBrowserListCtrlControl::MacSetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
* item
)
2339 wxMacDataItem
* dataItem
= GetItemFromLine(row
);
2342 wxMacListCtrlItem
* listItem
= dynamic_cast<wxMacListCtrlItem
*>(dataItem
);
2343 listItem
->SetColumnInfo( column
, item
);
2344 UpdateState(dataItem
, item
);
2348 // apply changes that need to happen immediately, rather than when the
2349 // databrowser control fires a callback.
2350 void wxMacDataBrowserListCtrlControl::UpdateState(wxMacDataItem
* dataItem
, wxListItem
* listItem
)
2352 bool isSelected
= IsItemSelected( dataItem
);
2353 bool isSelectedState
= (listItem
->GetState() == wxLIST_STATE_SELECTED
);
2355 // toggle the selection state if wxListInfo state and actual state don't match.
2356 if ( isSelected
!= isSelectedState
)
2358 DataBrowserSetOption options
= kDataBrowserItemsAdd
;
2359 if (!isSelectedState
)
2360 options
= kDataBrowserItemsRemove
;
2361 SetSelectedItem(dataItem
, options
);
2363 // TODO: Set column width if item width > than current column width
2366 void wxMacDataBrowserListCtrlControl::MacGetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
& item
)
2368 wxMacDataItem
* dataItem
= GetItemFromLine(row
);
2369 // CS should this guard against dataItem = 0 ? , as item is not a pointer if (item) is not appropriate
2372 wxMacListCtrlItem
* listItem
= dynamic_cast<wxMacListCtrlItem
*>(dataItem
);
2373 wxListItem
* oldItem
= listItem
->GetColumnInfo( column
);
2375 long mask
= item
.GetMask();
2377 // by default, get everything for backwards compatibility
2380 if ( mask
& wxLIST_MASK_TEXT
)
2381 item
.SetText(oldItem
->GetText());
2382 if ( mask
& wxLIST_MASK_IMAGE
)
2383 item
.SetImage(oldItem
->GetImage());
2384 if ( mask
& wxLIST_MASK_DATA
)
2385 item
.SetData(oldItem
->GetData());
2386 if ( mask
& wxLIST_MASK_STATE
)
2387 item
.SetState(oldItem
->GetState());
2388 if ( mask
& wxLIST_MASK_WIDTH
)
2389 item
.SetWidth(oldItem
->GetWidth());
2390 if ( mask
& wxLIST_MASK_FORMAT
)
2391 item
.SetAlign(oldItem
->GetAlign());
2393 item
.SetTextColour(oldItem
->GetTextColour());
2394 item
.SetBackgroundColour(oldItem
->GetBackgroundColour());
2395 item
.SetFont(oldItem
->GetFont());
2399 void wxMacDataBrowserListCtrlControl::MacInsertItem( unsigned int n
, wxListItem
* item
)
2401 wxMacDataItemBrowserControl::MacInsert(n
, item
->GetText());
2402 MacSetColumnInfo(n
, 0, item
);
2405 wxMacDataItem
* wxMacDataBrowserListCtrlControl::CreateItem()
2407 return new wxMacListCtrlItem();
2410 wxMacListCtrlItem::wxMacListCtrlItem()
2412 m_rowItems
= wxListItemList();
2415 int wxMacListCtrlItem::GetColumnImageValue( unsigned int column
)
2417 return GetColumnInfo(column
)->GetImage();
2420 void wxMacListCtrlItem::SetColumnImageValue( unsigned int column
, int imageIndex
)
2422 GetColumnInfo(column
)->SetImage(imageIndex
);
2425 const wxString
& wxMacListCtrlItem::GetColumnTextValue( unsigned int column
)
2430 return GetColumnInfo(column
)->GetText();
2433 void wxMacListCtrlItem::SetColumnTextValue( unsigned int column
, const wxString
& text
)
2435 GetColumnInfo(column
)->SetText(text
);
2437 // for compatibility with superclass APIs
2442 wxListItem
* wxMacListCtrlItem::GetColumnInfo( unsigned int column
)
2444 wxListItemList::compatibility_iterator node
= m_rowItems
.Item( column
);
2445 wxASSERT_MSG( node
, _T("invalid column index in wxMacListCtrlItem") );
2447 return node
->GetData();
2450 bool wxMacListCtrlItem::HasColumnInfo( unsigned int column
)
2452 return m_rowItems
.GetCount() > column
;
2455 void wxMacListCtrlItem::SetColumnInfo( unsigned int column
, wxListItem
* item
)
2458 if ( column
>= m_rowItems
.GetCount() )
2460 wxListItem
* listItem
= new wxListItem(*item
);
2461 m_rowItems
.Append( listItem
);
2465 wxListItem
* listItem
= GetColumnInfo( column
);
2466 long mask
= item
->GetMask();
2467 if (mask
& wxLIST_MASK_TEXT
)
2468 listItem
->SetText(item
->GetText());
2469 if (mask
& wxLIST_MASK_DATA
)
2470 listItem
->SetData(item
->GetData());
2471 if (mask
& wxLIST_MASK_IMAGE
)
2472 listItem
->SetImage(item
->GetImage());
2473 if (mask
& wxLIST_MASK_STATE
)
2474 listItem
->SetState(item
->GetState());
2475 if (mask
& wxLIST_MASK_FORMAT
)
2476 listItem
->SetAlign(item
->GetAlign());
2477 if (mask
& wxLIST_MASK_WIDTH
)
2478 listItem
->SetWidth(item
->GetWidth());
2480 listItem
->SetTextColour(item
->GetTextColour());
2481 listItem
->SetBackgroundColour(item
->GetBackgroundColour());
2482 listItem
->SetFont(item
->GetFont());
2486 #endif // wxUSE_LISTCTRL