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
:
158 CGContextRef context
= cEvent
.GetParameter
<CGContextRef
>(kEventParamCGContextRef
, typeCGContextRef
) ;
159 window
->MacSetDrawingContext(context
);
160 result
= CallNextEventHandler(handler
, event
);
161 window
->MacSetDrawingContext(NULL
);
172 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacListCtrlEventHandler
)
174 class wxMacListCtrlItem
: public wxMacListBoxItem
179 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
180 DataBrowserItemNotification message
,
181 DataBrowserItemDataRef itemData
) const;
183 virtual void SetColumnInfo( unsigned int column
, wxListItem
* item
);
184 virtual wxListItem
* GetColumnInfo( unsigned int column
);
185 virtual bool HasColumnInfo( unsigned int column
);
187 virtual void SetColumnTextValue( unsigned int column
, const wxString
& text
);
188 virtual const wxString
& GetColumnTextValue( unsigned int column
);
190 virtual int GetColumnImageValue( unsigned int column
);
191 virtual void SetColumnImageValue( unsigned int column
, int imageIndex
);
193 virtual ~wxMacListCtrlItem();
195 wxListItemList m_rowItems
;
198 DataBrowserDrawItemUPP gDataBrowserDrawItemUPP
= NULL
;
199 //DataBrowserEditItemUPP gDataBrowserEditItemUPP = NULL;
200 DataBrowserHitTestUPP gDataBrowserHitTestUPP
= NULL
;
202 // TODO: Make a better name!!
203 class wxMacDataBrowserListCtrlControl
: public wxMacDataItemBrowserControl
206 wxMacDataBrowserListCtrlControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
207 virtual ~wxMacDataBrowserListCtrlControl();
209 // create a list item (can be a subclass of wxMacListBoxItem)
211 virtual wxMacDataItem
* CreateItem();
213 virtual void MacInsertItem( unsigned int n
, wxListItem
* item
);
214 virtual void MacSetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
* item
);
215 virtual void MacGetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
& item
);
216 virtual void UpdateState(wxMacDataItem
* dataItem
, wxListItem
* item
);
219 // we need to override to provide specialized handling for virtual wxListCtrls
220 virtual OSStatus
GetSetItemData(DataBrowserItemID itemID
,
221 DataBrowserPropertyID property
,
222 DataBrowserItemDataRef itemData
,
223 Boolean changeValue
);
225 virtual void ItemNotification(
226 DataBrowserItemID itemID
,
227 DataBrowserItemNotification message
,
228 DataBrowserItemDataRef itemData
);
230 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
231 DataBrowserItemID itemTwoID
,
232 DataBrowserPropertyID sortProperty
);
234 static pascal void DataBrowserDrawItemProc(ControlRef browser
,
235 DataBrowserItemID item
,
236 DataBrowserPropertyID property
,
237 DataBrowserItemState itemState
,
240 Boolean colorDevice
);
242 virtual void DrawItem(DataBrowserItemID itemID
,
243 DataBrowserPropertyID property
,
244 DataBrowserItemState itemState
,
245 const Rect
*itemRect
,
247 Boolean colorDevice
);
249 static pascal Boolean
DataBrowserEditTextProc(ControlRef browser
,
250 DataBrowserItemID item
,
251 DataBrowserPropertyID property
,
252 CFStringRef theString
,
253 Rect
*maxEditTextRect
,
254 Boolean
*shrinkToFit
);
256 static pascal Boolean
DataBrowserHitTestProc(ControlRef browser
,
257 DataBrowserItemID itemID
,
258 DataBrowserPropertyID property
,
260 const Rect
*mouseRect
) { return true; }
262 virtual bool ConfirmEditText(DataBrowserItemID item
,
263 DataBrowserPropertyID property
,
264 CFStringRef theString
,
265 Rect
*maxEditTextRect
,
266 Boolean
*shrinkToFit
);
270 wxClientDataType m_clientDataItemsType
;
275 class wxMacListCtrlEventDelegate
: public wxEvtHandler
278 wxMacListCtrlEventDelegate( wxListCtrl
* list
, int id
);
279 virtual bool ProcessEvent( wxEvent
& event
);
286 wxMacListCtrlEventDelegate::wxMacListCtrlEventDelegate( wxListCtrl
* list
, int id
)
292 bool wxMacListCtrlEventDelegate::ProcessEvent( wxEvent
& event
)
294 // even though we use a generic list ctrl underneath, make sure
295 // we present ourselves as wxListCtrl.
296 event
.SetEventObject( m_list
);
299 return wxEvtHandler::ProcessEvent(event
);
302 // ============================================================================
304 // ============================================================================
306 wxMacListControl
* wxListCtrl::GetPeer() const
308 return dynamic_cast<wxMacListControl
*>(m_peer
);
311 // ----------------------------------------------------------------------------
312 // wxListCtrl construction
313 // ----------------------------------------------------------------------------
315 void wxListCtrl::Init()
317 m_imageListNormal
= NULL
;
318 m_imageListSmall
= NULL
;
319 m_imageListState
= NULL
;
321 // keep track of if we created our own image lists, or if they were assigned
323 m_ownsImageListNormal
= m_ownsImageListSmall
= m_ownsImageListState
= false;
327 m_genericImpl
= NULL
;
329 m_compareFunc
= NULL
;
330 m_compareFuncData
= 0;
331 m_colsInfo
= wxColumnList();
332 m_textColor
= wxNullColour
;
333 m_bgColor
= wxNullColour
;
336 class wxGenericListCtrlHook
: public wxGenericListCtrl
339 wxGenericListCtrlHook(wxListCtrl
* parent
,
344 const wxValidator
& validator
,
345 const wxString
& name
)
346 : wxGenericListCtrl(parent
, id
, pos
, size
, style
, validator
, name
),
347 m_nativeListCtrl(parent
)
352 virtual wxListItemAttr
* OnGetItemAttr(long item
) const
354 return m_nativeListCtrl
->OnGetItemAttr(item
);
357 virtual int OnGetItemImage(long item
) const
359 return m_nativeListCtrl
->OnGetItemImage(item
);
362 virtual int OnGetItemColumnImage(long item
, long column
) const
364 return m_nativeListCtrl
->OnGetItemColumnImage(item
, column
);
367 virtual wxString
OnGetItemText(long item
, long column
) const
369 return m_nativeListCtrl
->OnGetItemText(item
, column
);
372 wxListCtrl
* m_nativeListCtrl
;
376 bool wxListCtrl::Create(wxWindow
*parent
,
381 const wxValidator
& validator
,
382 const wxString
& name
)
385 // for now, we'll always use the generic list control for ICON and LIST views,
386 // because they dynamically change the number of columns on resize.
387 // Also, allow the user to set it to use the list ctrl as well.
388 // Also, use generic list control in VIRTUAL mode.
389 if ( (wxSystemOptions::HasOption( wxMAC_ALWAYS_USE_GENERIC_LISTCTRL
)
390 && (wxSystemOptions::GetOptionInt( wxMAC_ALWAYS_USE_GENERIC_LISTCTRL
) == 1)) ||
391 (style
& wxLC_ICON
) || (style
& wxLC_SMALL_ICON
) || (style
& wxLC_LIST
) || (style
& wxLC_EDIT_LABELS
) )
393 m_macIsUserPane
= true;
395 if ( !wxWindow::Create(parent
, id
, pos
, size
, style
, name
) )
397 m_genericImpl
= new wxGenericListCtrlHook(this, id
, pos
, size
, style
, validator
, name
);
398 m_genericImpl
->PushEventHandler( new wxMacListCtrlEventDelegate( this, GetId() ) );
404 m_macIsUserPane
= false;
406 if ( !wxWindow::Create(parent
, id
, pos
, size
, style
, name
) )
408 m_dbImpl
= new wxMacDataBrowserListCtrlControl( this, pos
, size
, style
);
411 MacPostControlCreate( pos
, size
);
413 InstallControlEventHandler( m_peer
->GetControlRef() , GetwxMacListCtrlEventHandlerUPP(),
414 GetEventTypeCount(eventList
), eventList
, this,
415 (EventHandlerRef
*)&m_macListCtrlEventHandler
);
421 wxListCtrl::~wxListCtrl()
425 m_genericImpl
->PopEventHandler(/* deleteHandler = */ true);
428 if (m_ownsImageListNormal
)
429 delete m_imageListNormal
;
430 if (m_ownsImageListSmall
)
431 delete m_imageListSmall
;
432 if (m_ownsImageListState
)
433 delete m_imageListState
;
436 // ----------------------------------------------------------------------------
437 // set/get/change style
438 // ----------------------------------------------------------------------------
440 // Add or remove a single window style
441 void wxListCtrl::SetSingleStyle(long style
, bool add
)
443 long flag
= GetWindowStyleFlag();
445 // Get rid of conflicting styles
448 if ( style
& wxLC_MASK_TYPE
)
449 flag
= flag
& ~wxLC_MASK_TYPE
;
450 if ( style
& wxLC_MASK_ALIGN
)
451 flag
= flag
& ~wxLC_MASK_ALIGN
;
452 if ( style
& wxLC_MASK_SORT
)
453 flag
= flag
& ~wxLC_MASK_SORT
;
461 SetWindowStyleFlag(flag
);
464 // Set the whole window style
465 void wxListCtrl::SetWindowStyleFlag(long flag
)
467 if ( flag
!= m_windowStyle
)
469 m_windowStyle
= flag
;
473 m_genericImpl
->SetWindowStyleFlag(flag
);
480 void wxListCtrl::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
482 wxControl::DoSetSize(x
, y
, width
, height
, sizeFlags
);
485 m_genericImpl
->SetSize(x
, y
, width
, height
, sizeFlags
);
488 bool wxListCtrl::SetFont(const wxFont
& font
)
491 rv
= wxControl::SetFont(font
);
493 rv
= m_genericImpl
->SetFont(font
);
497 bool wxListCtrl::SetForegroundColour(const wxColour
& colour
)
501 rv
= m_genericImpl
->SetForegroundColour(colour
);
503 SetTextColour(colour
);
507 bool wxListCtrl::SetBackgroundColour(const wxColour
& colour
)
511 rv
= m_genericImpl
->SetBackgroundColour(colour
);
517 wxColour
wxListCtrl::GetBackgroundColour()
520 return m_genericImpl
->GetBackgroundColour();
527 // ----------------------------------------------------------------------------
529 // ----------------------------------------------------------------------------
531 // Gets information about this column
532 bool wxListCtrl::GetColumn(int col
, wxListItem
& item
) const
535 return m_genericImpl
->GetColumn(col
, item
);
542 wxColumnList::compatibility_iterator node
= m_colsInfo
.Item( col
);
543 wxASSERT_MSG( node
, _T("invalid column index in wxMacListCtrlItem") );
544 wxListItem
* column
= node
->GetData();
546 long mask
= column
->GetMask();
547 if (mask
& wxLIST_MASK_TEXT
)
548 item
.SetText(column
->GetText());
549 if (mask
& wxLIST_MASK_DATA
)
550 item
.SetData(column
->GetData());
551 if (mask
& wxLIST_MASK_IMAGE
)
552 item
.SetImage(column
->GetImage());
553 if (mask
& wxLIST_MASK_STATE
)
554 item
.SetState(column
->GetState());
555 if (mask
& wxLIST_MASK_FORMAT
)
556 item
.SetAlign(column
->GetAlign());
557 if (mask
& wxLIST_MASK_WIDTH
)
558 item
.SetWidth(column
->GetWidth());
564 // Sets information about this column
565 bool wxListCtrl::SetColumn(int col
, wxListItem
& item
)
568 return m_genericImpl
->SetColumn(col
, item
);
572 if ( col
>= (int)m_colsInfo
.GetCount() )
574 wxListItem
* listItem
= new wxListItem(item
);
575 m_colsInfo
.Append( listItem
);
580 GetColumn( col
, listItem
);
581 long mask
= item
.GetMask();
582 if (mask
& wxLIST_MASK_TEXT
)
583 listItem
.SetText(item
.GetText());
584 if (mask
& wxLIST_MASK_DATA
)
585 listItem
.SetData(item
.GetData());
586 if (mask
& wxLIST_MASK_IMAGE
)
587 listItem
.SetImage(item
.GetImage());
588 if (mask
& wxLIST_MASK_STATE
)
589 listItem
.SetState(item
.GetState());
590 if (mask
& wxLIST_MASK_FORMAT
)
591 listItem
.SetAlign(item
.GetAlign());
592 if (mask
& wxLIST_MASK_WIDTH
)
593 listItem
.SetWidth(item
.GetWidth());
596 // change the appearance in the databrowser.
597 DataBrowserListViewHeaderDesc columnDesc
;
598 columnDesc
.version
=kDataBrowserListViewLatestHeaderDesc
;
599 verify_noerr( m_dbImpl
->GetHeaderDesc( kMinColumnId
+ col
, &columnDesc
) );
602 if (item.GetMask() & wxLIST_MASK_TEXT)
606 enc = m_font.GetEncoding();
608 enc = wxLocale::GetSystemEncoding();
609 wxMacCFStringHolder cfTitle;
610 cfTitle.Assign( item.GetText() , enc );
611 if(columnDesc.titleString)
612 CFRelease(columnDesc.titleString);
613 columnDesc.titleString = cfTitle;
617 if (item
.GetMask() & wxLIST_MASK_IMAGE
&& item
.GetImage() != -1 )
619 columnDesc
.btnContentInfo
.contentType
= kControlContentIconRef
;
620 wxImageList
* imageList
= GetImageList(wxIMAGE_LIST_SMALL
);
621 if (imageList
&& imageList
->GetImageCount() > 0 )
623 wxBitmap bmp
= imageList
->GetBitmap( item
.GetImage() );
624 IconRef icon
= bmp
.GetBitmapData()->GetIconRef();
625 columnDesc
.btnContentInfo
.u
.iconRef
= icon
;
629 verify_noerr( m_dbImpl
->SetHeaderDesc( kMinColumnId
+ col
, &columnDesc
) );
635 int wxListCtrl::GetColumnCount() const
638 return m_genericImpl
->GetColumnCount();
643 m_dbImpl
->GetColumnCount(&count
);
650 // Gets the column width
651 int wxListCtrl::GetColumnWidth(int col
) const
654 return m_genericImpl
->GetColumnWidth(col
);
658 return m_dbImpl
->GetColumnWidth(col
);
664 // Sets the column width
665 bool wxListCtrl::SetColumnWidth(int col
, int width
)
668 return m_genericImpl
->SetColumnWidth(col
, width
);
673 if (width
== wxLIST_AUTOSIZE
|| width
== wxLIST_AUTOSIZE_USEHEADER
)
678 for (int column
= 0; column
< GetColumnCount(); column
++)
680 m_dbImpl
->SetColumnWidth(col
, mywidth
);
684 m_dbImpl
->SetColumnWidth(col
, mywidth
);
692 // Gets the number of items that can fit vertically in the
693 // visible area of the list control (list or report view)
694 // or the total number of items in the list control (icon
695 // or small icon view)
696 int wxListCtrl::GetCountPerPage() const
699 return m_genericImpl
->GetCountPerPage();
708 // Gets the edit control for editing labels.
709 wxTextCtrl
* wxListCtrl::GetEditControl() const
712 return m_genericImpl
->GetEditControl();
717 // Gets information about the item
718 bool wxListCtrl::GetItem(wxListItem
& info
) const
721 return m_genericImpl
->GetItem(info
);
726 m_dbImpl
->MacGetColumnInfo(info
.m_itemId
, info
.m_col
, info
);
729 info
.SetText( OnGetItemText(info
.m_itemId
, info
.m_col
) );
730 info
.SetImage( OnGetItemColumnImage(info
.m_itemId
, info
.m_col
) );
731 wxListItemAttr
* attrs
= OnGetItemAttr( info
.m_itemId
);
734 info
.SetFont( attrs
->GetFont() );
735 info
.SetBackgroundColour( attrs
->GetBackgroundColour() );
736 info
.SetTextColour( attrs
->GetTextColour() );
744 // Sets information about the item
745 bool wxListCtrl::SetItem(wxListItem
& info
)
748 return m_genericImpl
->SetItem(info
);
751 m_dbImpl
->MacSetColumnInfo( info
.m_itemId
, info
.m_col
, &info
);
756 long wxListCtrl::SetItem(long index
, int col
, const wxString
& label
, int imageId
)
759 return m_genericImpl
->SetItem(index
, col
, label
, imageId
);
763 info
.m_mask
= wxLIST_MASK_TEXT
;
764 info
.m_itemId
= index
;
768 info
.m_image
= imageId
;
769 info
.m_mask
|= wxLIST_MASK_IMAGE
;
771 return SetItem(info
);
775 // Gets the item state
776 int wxListCtrl::GetItemState(long item
, long stateMask
) const
779 return m_genericImpl
->GetItemState(item
, stateMask
);
783 info
.m_mask
= wxLIST_MASK_STATE
;
784 info
.m_stateMask
= stateMask
;
785 info
.m_itemId
= item
;
793 // Sets the item state
794 bool wxListCtrl::SetItemState(long item
, long state
, long stateMask
)
797 return m_genericImpl
->SetItemState(item
, state
, stateMask
);
800 info
.m_mask
= wxLIST_MASK_STATE
;
801 info
.m_stateMask
= stateMask
;
802 info
.m_state
= state
;
803 info
.m_itemId
= item
;
804 return SetItem(info
);
807 // Sets the item image
808 bool wxListCtrl::SetItemImage(long item
, int image
, int WXUNUSED(selImage
))
810 return SetItemColumnImage(item
, 0, image
);
813 // Sets the item image
814 bool wxListCtrl::SetItemColumnImage(long item
, long column
, int image
)
817 return m_genericImpl
->SetItemColumnImage(item
, column
, image
);
821 info
.m_mask
= wxLIST_MASK_IMAGE
;
822 info
.m_image
= image
;
823 info
.m_itemId
= item
;
826 return SetItem(info
);
829 // Gets the item text
830 wxString
wxListCtrl::GetItemText(long item
) const
833 return m_genericImpl
->GetItemText(item
);
837 info
.m_mask
= wxLIST_MASK_TEXT
;
838 info
.m_itemId
= item
;
841 return wxEmptyString
;
845 // Sets the item text
846 void wxListCtrl::SetItemText(long item
, const wxString
& str
)
849 return m_genericImpl
->SetItemText(item
, str
);
853 info
.m_mask
= wxLIST_MASK_TEXT
;
854 info
.m_itemId
= item
;
860 // Gets the item data
861 long wxListCtrl::GetItemData(long item
) const
864 return m_genericImpl
->GetItemData(item
);
868 info
.m_mask
= wxLIST_MASK_DATA
;
869 info
.m_itemId
= item
;
876 // Sets the item data
877 bool wxListCtrl::SetItemData(long item
, long data
)
880 return m_genericImpl
->SetItemData(item
, data
);
884 info
.m_mask
= wxLIST_MASK_DATA
;
885 info
.m_itemId
= item
;
888 return SetItem(info
);
891 wxRect
wxListCtrl::GetViewRect() const
893 wxASSERT_MSG( !HasFlag(wxLC_REPORT
| wxLC_LIST
),
894 _T("wxListCtrl::GetViewRect() only works in icon mode") );
897 return m_genericImpl
->GetViewRect();
903 // Gets the item rectangle
904 bool wxListCtrl::GetItemRect(long item
, wxRect
& rect
, int code
) const
907 return m_genericImpl
->GetItemRect(item
, rect
, code
);
912 // Gets the item position
913 bool wxListCtrl::GetItemPosition(long item
, wxPoint
& pos
) const
916 return m_genericImpl
->GetItemPosition(item
, pos
);
918 bool success
= false;
923 // Sets the item position.
924 bool wxListCtrl::SetItemPosition(long item
, const wxPoint
& pos
)
927 return m_genericImpl
->SetItemPosition(item
, pos
);
932 // Gets the number of items in the list control
933 int wxListCtrl::GetItemCount() const
936 return m_genericImpl
->GetItemCount();
939 return m_dbImpl
->MacGetCount();
944 void wxListCtrl::SetItemSpacing( int spacing
, bool isSmall
)
947 m_genericImpl
->SetItemSpacing(spacing
, isSmall
);
950 wxSize
wxListCtrl::GetItemSpacing() const
953 return m_genericImpl
->GetItemSpacing();
958 void wxListCtrl::SetItemTextColour( long item
, const wxColour
&col
)
962 m_genericImpl
->SetItemTextColour(item
, col
);
967 info
.m_itemId
= item
;
968 info
.SetTextColour( col
);
972 wxColour
wxListCtrl::GetItemTextColour( long item
) const
975 return m_genericImpl
->GetItemTextColour(item
);
981 return info
.GetTextColour();
986 void wxListCtrl::SetItemBackgroundColour( long item
, const wxColour
&col
)
990 m_genericImpl
->SetItemBackgroundColour(item
, col
);
995 info
.m_itemId
= item
;
996 info
.SetBackgroundColour( col
);
1000 wxColour
wxListCtrl::GetItemBackgroundColour( long item
) const
1003 return m_genericImpl
->GetItemBackgroundColour(item
);
1009 return info
.GetBackgroundColour();
1011 return wxNullColour
;
1014 void wxListCtrl::SetItemFont( long item
, const wxFont
&f
)
1018 m_genericImpl
->SetItemFont(item
, f
);
1023 info
.m_itemId
= item
;
1028 wxFont
wxListCtrl::GetItemFont( long item
) const
1031 return m_genericImpl
->GetItemFont(item
);
1037 return info
.GetFont();
1043 // Gets the number of selected items in the list control
1044 int wxListCtrl::GetSelectedItemCount() const
1047 return m_genericImpl
->GetSelectedItemCount();
1050 return m_dbImpl
->GetSelectedItemCount(NULL
, true);
1055 // Gets the text colour of the listview
1056 wxColour
wxListCtrl::GetTextColour() const
1059 return m_genericImpl
->GetTextColour();
1061 // TODO: we need owner drawn list items to customize text color.
1065 return wxNullColour
;
1068 // Sets the text colour of the listview
1069 void wxListCtrl::SetTextColour(const wxColour
& col
)
1073 m_genericImpl
->SetTextColour(col
);
1081 // Gets the index of the topmost visible item when in
1082 // list or report view
1083 long wxListCtrl::GetTopItem() const
1086 return m_genericImpl
->GetTopItem();
1091 // Searches for an item, starting from 'item'.
1092 // 'geometry' is one of
1093 // wxLIST_NEXT_ABOVE/ALL/BELOW/LEFT/RIGHT.
1094 // 'state' is a state bit flag, one or more of
1095 // wxLIST_STATE_DROPHILITED/FOCUSED/SELECTED/CUT.
1096 // item can be -1 to find the first item that matches the
1098 // Returns the item or -1 if unsuccessful.
1099 long wxListCtrl::GetNextItem(long item
, int geom
, int state
) const
1102 return m_genericImpl
->GetNextItem(item
, geom
, state
);
1104 if (m_dbImpl
&& geom
== wxLIST_NEXT_ALL
&& state
== wxLIST_STATE_SELECTED
)
1106 long count
= m_dbImpl
->MacGetCount() ;
1107 for ( long line
= item
+ 1 ; line
< count
; line
++ )
1109 wxMacDataItem
* id
= m_dbImpl
->GetItemFromLine(line
);
1110 if ( m_dbImpl
->IsItemSelected(id
) )
1120 wxImageList
*wxListCtrl::GetImageList(int which
) const
1123 return m_genericImpl
->GetImageList(which
);
1125 if ( which
== wxIMAGE_LIST_NORMAL
)
1127 return m_imageListNormal
;
1129 else if ( which
== wxIMAGE_LIST_SMALL
)
1131 return m_imageListSmall
;
1133 else if ( which
== wxIMAGE_LIST_STATE
)
1135 return m_imageListState
;
1140 void wxListCtrl::SetImageList(wxImageList
*imageList
, int which
)
1144 m_genericImpl
->SetImageList(imageList
, which
);
1148 if ( which
== wxIMAGE_LIST_NORMAL
)
1150 if (m_ownsImageListNormal
) delete m_imageListNormal
;
1151 m_imageListNormal
= imageList
;
1152 m_ownsImageListNormal
= false;
1154 else if ( which
== wxIMAGE_LIST_SMALL
)
1156 if (m_ownsImageListSmall
) delete m_imageListSmall
;
1157 m_imageListSmall
= imageList
;
1158 m_ownsImageListSmall
= false;
1160 else if ( which
== wxIMAGE_LIST_STATE
)
1162 if (m_ownsImageListState
) delete m_imageListState
;
1163 m_imageListState
= imageList
;
1164 m_ownsImageListState
= false;
1168 void wxListCtrl::AssignImageList(wxImageList
*imageList
, int which
)
1172 m_genericImpl
->AssignImageList(imageList
, which
);
1176 SetImageList(imageList
, which
);
1177 if ( which
== wxIMAGE_LIST_NORMAL
)
1178 m_ownsImageListNormal
= true;
1179 else if ( which
== wxIMAGE_LIST_SMALL
)
1180 m_ownsImageListSmall
= true;
1181 else if ( which
== wxIMAGE_LIST_STATE
)
1182 m_ownsImageListState
= true;
1185 // ----------------------------------------------------------------------------
1187 // ----------------------------------------------------------------------------
1189 // Arranges the items
1190 bool wxListCtrl::Arrange(int flag
)
1193 return m_genericImpl
->Arrange(flag
);
1198 bool wxListCtrl::DeleteItem(long item
)
1201 return m_genericImpl
->DeleteItem(item
);
1205 m_dbImpl
->MacDelete(item
);
1206 wxListEvent
event( wxEVT_COMMAND_LIST_DELETE_ITEM
, GetId() );
1207 event
.SetEventObject( this );
1208 event
.m_itemIndex
= item
;
1209 GetEventHandler()->ProcessEvent( event
);
1215 // Deletes all items
1216 bool wxListCtrl::DeleteAllItems()
1219 return m_genericImpl
->DeleteAllItems();
1223 m_dbImpl
->MacClear();
1224 wxListEvent
event( wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS
, GetId() );
1225 event
.SetEventObject( this );
1226 GetEventHandler()->ProcessEvent( event
);
1231 // Deletes all items
1232 bool wxListCtrl::DeleteAllColumns()
1235 return m_genericImpl
->DeleteAllColumns();
1240 m_dbImpl
->GetColumnCount(&cols
);
1241 for (UInt32 col
= 0; col
< cols
; col
++)
1251 bool wxListCtrl::DeleteColumn(int col
)
1254 return m_genericImpl
->DeleteColumn(col
);
1258 OSStatus err
= m_dbImpl
->RemoveColumn(col
);
1259 return err
== noErr
;
1265 // Clears items, and columns if there are any.
1266 void wxListCtrl::ClearAll()
1270 m_genericImpl
->ClearAll();
1281 wxTextCtrl
* wxListCtrl::EditLabel(long item
, wxClassInfo
* textControlClass
)
1284 return m_genericImpl
->EditLabel(item
, textControlClass
);
1288 wxMacDataItem
* id
= m_dbImpl
->GetItemFromLine(item
);
1289 verify_noerr( SetDataBrowserEditItem(m_dbImpl
->GetControlRef(), (DataBrowserItemID
)id
, kMinColumnId
) );
1294 // End label editing, optionally cancelling the edit
1295 bool wxListCtrl::EndEditLabel(bool cancel
)
1297 // TODO: generic impl. doesn't have this method - is it needed for us?
1299 return true; // m_genericImpl->EndEditLabel(cancel);
1302 verify_noerr( SetDataBrowserEditItem(m_dbImpl
->GetControlRef(), kDataBrowserNoItem
, kMinColumnId
) );
1306 // Ensures this item is visible
1307 bool wxListCtrl::EnsureVisible(long item
)
1310 return m_genericImpl
->EnsureVisible(item
);
1314 wxMacDataItem
* dataItem
= m_dbImpl
->GetItemFromLine(item
);
1315 m_dbImpl
->RevealItem(dataItem
, kDataBrowserRevealWithoutSelecting
);
1321 // Find an item whose label matches this string, starting from the item after 'start'
1322 // or the beginning if 'start' is -1.
1323 long wxListCtrl::FindItem(long start
, const wxString
& str
, bool partial
)
1326 return m_genericImpl
->FindItem(start
, str
, partial
);
1331 // Find an item whose data matches this data, starting from the item after 'start'
1332 // or the beginning if 'start' is -1.
1333 long wxListCtrl::FindItem(long start
, long data
)
1336 return m_genericImpl
->FindItem(start
, data
);
1338 long idx
= start
+ 1;
1339 long count
= GetItemCount();
1343 if (GetItemData(idx
) == data
)
1351 // Find an item nearest this position in the specified direction, starting from
1352 // the item after 'start' or the beginning if 'start' is -1.
1353 long wxListCtrl::FindItem(long start
, const wxPoint
& pt
, int direction
)
1356 return m_genericImpl
->FindItem(start
, pt
, direction
);
1360 // Determines which item (if any) is at the specified point,
1361 // giving details in 'flags' (see wxLIST_HITTEST_... flags above)
1363 wxListCtrl::HitTest(const wxPoint
& point
, int& flags
, long *ptrSubItem
) const
1366 return m_genericImpl
->HitTest(point
, flags
, ptrSubItem
);
1372 // Inserts an item, returning the index of the new item if successful,
1374 long wxListCtrl::InsertItem(wxListItem
& info
)
1376 wxASSERT_MSG( !IsVirtual(), _T("can't be used with virtual controls") );
1379 return m_genericImpl
->InsertItem(info
);
1383 int count
= GetItemCount();
1385 if (info
.m_itemId
> count
)
1386 info
.m_itemId
= count
;
1388 m_dbImpl
->MacInsertItem(info
.m_itemId
, &info
);
1389 wxListEvent
event( wxEVT_COMMAND_LIST_INSERT_ITEM
, GetId() );
1390 event
.SetEventObject( this );
1391 event
.m_itemIndex
= info
.m_itemId
;
1392 GetEventHandler()->ProcessEvent( event
);
1395 return info
.m_itemId
;
1398 long wxListCtrl::InsertItem(long index
, const wxString
& label
)
1401 return m_genericImpl
->InsertItem(index
, label
);
1404 info
.m_text
= label
;
1405 info
.m_mask
= wxLIST_MASK_TEXT
;
1406 info
.m_itemId
= index
;
1407 return InsertItem(info
);
1410 // Inserts an image item
1411 long wxListCtrl::InsertItem(long index
, int imageIndex
)
1414 return m_genericImpl
->InsertItem(index
, imageIndex
);
1417 info
.m_image
= imageIndex
;
1418 info
.m_mask
= wxLIST_MASK_IMAGE
;
1419 info
.m_itemId
= index
;
1420 return InsertItem(info
);
1423 // Inserts an image/string item
1424 long wxListCtrl::InsertItem(long index
, const wxString
& label
, int imageIndex
)
1427 return m_genericImpl
->InsertItem(index
, label
, imageIndex
);
1430 info
.m_image
= imageIndex
;
1431 info
.m_text
= label
;
1432 info
.m_mask
= wxLIST_MASK_IMAGE
| wxLIST_MASK_TEXT
;
1433 info
.m_itemId
= index
;
1434 return InsertItem(info
);
1437 // For list view mode (only), inserts a column.
1438 long wxListCtrl::InsertColumn(long col
, wxListItem
& item
)
1441 return m_genericImpl
->InsertColumn(col
, item
);
1445 int width
= item
.GetWidth();
1446 if ( !(item
.GetMask() & wxLIST_MASK_WIDTH
) )
1449 DataBrowserPropertyType type
= kDataBrowserCustomType
; //kDataBrowserTextType;
1450 wxImageList
* imageList
= GetImageList(wxIMAGE_LIST_SMALL
);
1451 if (imageList
&& imageList
->GetImageCount() > 0)
1453 wxBitmap bmp
= imageList
->GetBitmap(0);
1455 // type = kDataBrowserIconAndTextType;
1458 SInt16 just
= teFlushDefault
;
1459 if (item
.GetMask() & wxLIST_MASK_FORMAT
)
1461 if (item
.GetAlign() == wxLIST_FORMAT_LEFT
)
1463 else if (item
.GetAlign() == wxLIST_FORMAT_CENTER
)
1465 else if (item
.GetAlign() == wxLIST_FORMAT_RIGHT
)
1466 just
= teFlushRight
;
1468 m_dbImpl
->InsertColumn(col
, type
, item
.GetText(), just
, width
);
1469 SetColumn(col
, item
);
1471 // set/remove options based on the wxListCtrl type.
1472 DataBrowserTableViewColumnID id
;
1473 m_dbImpl
->GetColumnIDFromIndex(col
, &id
);
1474 DataBrowserPropertyFlags flags
;
1475 verify_noerr(m_dbImpl
->GetPropertyFlags(id
, &flags
));
1476 if (GetWindowStyleFlag() & wxLC_EDIT_LABELS
)
1477 flags
|= kDataBrowserPropertyIsEditable
;
1479 if (GetWindowStyleFlag() & wxLC_VIRTUAL
){
1480 flags
&= ~kDataBrowserListViewSortableColumn
;
1482 verify_noerr(m_dbImpl
->SetPropertyFlags(id
, flags
));
1488 long wxListCtrl::InsertColumn(long col
,
1489 const wxString
& heading
,
1494 return m_genericImpl
->InsertColumn(col
, heading
, format
, width
);
1497 item
.m_mask
= wxLIST_MASK_TEXT
| wxLIST_MASK_FORMAT
;
1498 item
.m_text
= heading
;
1501 item
.m_mask
|= wxLIST_MASK_WIDTH
;
1502 item
.m_width
= width
;
1504 item
.m_format
= format
;
1506 return InsertColumn(col
, item
);
1509 // scroll the control by the given number of pixels (exception: in list view,
1510 // dx is interpreted as number of columns)
1511 bool wxListCtrl::ScrollList(int dx
, int dy
)
1514 return m_genericImpl
->ScrollList(dx
, dy
);
1518 m_dbImpl
->SetScrollPosition(dx
, dy
);
1524 bool wxListCtrl::SortItems(wxListCtrlCompare fn
, long data
)
1527 return m_genericImpl
->SortItems(fn
, data
);
1532 m_compareFuncData
= data
;
1538 // ----------------------------------------------------------------------------
1539 // virtual list controls
1540 // ----------------------------------------------------------------------------
1542 wxString
wxListCtrl::OnGetItemText(long WXUNUSED(item
), long WXUNUSED(col
)) const
1544 // this is a pure virtual function, in fact - which is not really pure
1545 // because the controls which are not virtual don't need to implement it
1546 wxFAIL_MSG( _T("wxListCtrl::OnGetItemText not supposed to be called") );
1548 return wxEmptyString
;
1551 int wxListCtrl::OnGetItemImage(long WXUNUSED(item
)) const
1553 wxCHECK_MSG(!GetImageList(wxIMAGE_LIST_SMALL
),
1555 wxT("List control has an image list, OnGetItemImage or OnGetItemColumnImage should be overridden."));
1559 int wxListCtrl::OnGetItemColumnImage(long item
, long column
) const
1562 return OnGetItemImage(item
);
1567 wxListItemAttr
*wxListCtrl::OnGetItemAttr(long WXUNUSED_UNLESS_DEBUG(item
)) const
1569 wxASSERT_MSG( item
>= 0 && item
< GetItemCount(),
1570 _T("invalid item index in OnGetItemAttr()") );
1572 // no attributes by default
1576 void wxListCtrl::SetItemCount(long count
)
1578 wxASSERT_MSG( IsVirtual(), _T("this is for virtual controls only") );
1582 m_genericImpl
->SetItemCount(count
);
1588 // we need to temporarily disable the new item creation notification
1589 // procedure to speed things up
1590 // FIXME: Even this doesn't seem to help much...
1591 DataBrowserCallbacks callbacks
;
1592 DataBrowserItemNotificationUPP itemUPP
;
1593 GetDataBrowserCallbacks(m_dbImpl
->GetControlRef(), &callbacks
);
1594 itemUPP
= callbacks
.u
.v1
.itemNotificationCallback
;
1595 callbacks
.u
.v1
.itemNotificationCallback
= 0;
1596 m_dbImpl
->SetCallbacks(&callbacks
);
1597 ::AddDataBrowserItems(m_dbImpl
->GetControlRef(), kDataBrowserNoItem
,
1598 count
, NULL
, kDataBrowserItemNoProperty
);
1599 callbacks
.u
.v1
.itemNotificationCallback
= itemUPP
;
1600 m_dbImpl
->SetCallbacks(&callbacks
);
1605 void wxListCtrl::RefreshItem(long item
)
1609 m_genericImpl
->RefreshItem(item
);
1614 GetItemRect(item
, rect
);
1618 void wxListCtrl::RefreshItems(long itemFrom
, long itemTo
)
1622 m_genericImpl
->RefreshItems(itemFrom
, itemTo
);
1626 wxRect rect1
, rect2
;
1627 GetItemRect(itemFrom
, rect1
);
1628 GetItemRect(itemTo
, rect2
);
1630 wxRect rect
= rect1
;
1631 rect
.height
= rect2
.GetBottom() - rect1
.GetTop();
1637 // wxMac internal data structures
1639 wxMacListCtrlItem::~wxMacListCtrlItem()
1643 void wxMacListCtrlItem::Notification(wxMacDataItemBrowserControl
*owner
,
1644 DataBrowserItemNotification message
,
1645 DataBrowserItemDataRef itemData
) const
1648 wxMacDataBrowserListCtrlControl
*lb
= dynamic_cast<wxMacDataBrowserListCtrlControl
*>(owner
);
1650 // we want to depend on as little as possible to make sure tear-down of controls is safe
1651 if ( message
== kDataBrowserItemRemoved
)
1653 if ( lb
!= NULL
&& lb
->GetClientDataType() == wxClientData_Object
)
1655 delete (wxClientData
*) (m_data
);
1661 else if ( message
== kDataBrowserItemAdded
)
1663 // we don't issue events on adding, the item is not really stored in the list yet, so we
1664 // avoid asserts by gettting out now
1668 wxListCtrl
*list
= wxDynamicCast( owner
->GetPeer() , wxListCtrl
);
1671 bool trigger
= false;
1673 wxListEvent
event( wxEVT_COMMAND_LIST_ITEM_SELECTED
, list
->GetId() );
1674 bool isSingle
= (list
->GetWindowStyle() & wxLC_SINGLE_SEL
) != 0;
1676 event
.SetEventObject( list
);
1677 event
.m_itemIndex
= owner
->GetLineFromItem( this ) ;
1678 if ( !list
->IsVirtual() )
1680 lb
->MacGetColumnInfo(event
.m_itemIndex
,0,event
.m_item
);
1685 case kDataBrowserItemDeselected
:
1686 event
.SetEventType(wxEVT_COMMAND_LIST_ITEM_DESELECTED
);
1688 trigger
= !lb
->IsSelectionSuppressed();
1691 case kDataBrowserItemSelected
:
1692 trigger
= !lb
->IsSelectionSuppressed();
1695 case kDataBrowserItemDoubleClicked
:
1696 event
.SetEventType( wxEVT_COMMAND_LIST_ITEM_ACTIVATED
);
1700 case kDataBrowserEditStarted
:
1701 // TODO : how to veto ?
1702 event
.SetEventType( wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
) ;
1706 case kDataBrowserEditStopped
:
1707 // TODO probably trigger only upon the value store callback, because
1708 // here IIRC we cannot veto
1709 event
.SetEventType( wxEVT_COMMAND_LIST_END_LABEL_EDIT
) ;
1719 // direct notification is not always having the listbox GetSelection() having in synch with event
1720 wxPostEvent( list
->GetEventHandler(), event
);
1726 wxMacDataBrowserListCtrlControl::wxMacDataBrowserListCtrlControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
)
1727 : wxMacDataItemBrowserControl( peer
, pos
, size
, style
)
1729 OSStatus err
= noErr
;
1730 m_clientDataItemsType
= wxClientData_None
;
1731 m_isVirtual
= false;
1733 if ( style
& wxLC_VIRTUAL
)
1736 DataBrowserSelectionFlags options
= kDataBrowserDragSelect
;
1737 if ( style
& wxLC_SINGLE_SEL
)
1739 options
|= kDataBrowserSelectOnlyOne
;
1743 options
|= kDataBrowserCmdTogglesSelection
;
1746 err
= SetSelectionFlags( options
);
1747 verify_noerr( err
);
1749 DataBrowserCustomCallbacks callbacks
;
1750 InitializeDataBrowserCustomCallbacks( &callbacks
, kDataBrowserLatestCustomCallbacks
);
1752 if ( gDataBrowserDrawItemUPP
== NULL
)
1753 gDataBrowserDrawItemUPP
= NewDataBrowserDrawItemUPP(DataBrowserDrawItemProc
);
1755 // if ( gDataBrowserEditItemUPP == NULL )
1756 // gDataBrowserEditItemUPP = NewDataBrowserEditItemUPP(DataBrowserEditTextProc);
1758 if ( gDataBrowserHitTestUPP
== NULL
)
1759 gDataBrowserHitTestUPP
= NewDataBrowserHitTestUPP(DataBrowserHitTestProc
);
1761 callbacks
.u
.v1
.drawItemCallback
= gDataBrowserDrawItemUPP
;
1762 // callbacks.u.v1.editTextCallback = gDataBrowserEditItemUPP;
1763 callbacks
.u
.v1
.hitTestCallback
= gDataBrowserHitTestUPP
;
1765 SetDataBrowserCustomCallbacks( GetControlRef(), &callbacks
);
1767 if ( style
& wxLC_LIST
)
1769 InsertColumn(0, kDataBrowserIconAndTextType
, wxEmptyString
, -1, -1);
1770 verify_noerr( AutoSizeColumns() );
1773 if ( style
& wxLC_LIST
|| style
& wxLC_NO_HEADER
)
1774 verify_noerr( SetHeaderButtonHeight( 0 ) );
1777 SetSortProperty( kMinColumnId
- 1 );
1779 SetSortProperty( kMinColumnId
);
1780 if ( style
& wxLC_SORT_ASCENDING
)
1782 m_sortOrder
= SortOrder_Text_Ascending
;
1783 SetSortOrder( kDataBrowserOrderIncreasing
);
1785 else if ( style
& wxLC_SORT_DESCENDING
)
1787 m_sortOrder
= SortOrder_Text_Descending
;
1788 SetSortOrder( kDataBrowserOrderDecreasing
);
1792 m_sortOrder
= SortOrder_None
;
1795 if ( style
& wxLC_VRULES
)
1797 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
1798 verify_noerr( DataBrowserChangeAttributes(m_controlRef
, kDataBrowserAttributeListViewDrawColumnDividers
, kDataBrowserAttributeNone
) );
1802 verify_noerr( SetHiliteStyle(kDataBrowserTableViewFillHilite
) );
1803 err
= SetHasScrollBars( (style
& wxHSCROLL
) != 0 , true );
1806 pascal Boolean
wxMacDataBrowserListCtrlControl::DataBrowserEditTextProc(
1808 DataBrowserItemID itemID
,
1809 DataBrowserPropertyID property
,
1810 CFStringRef theString
,
1811 Rect
*maxEditTextRect
,
1812 Boolean
*shrinkToFit
)
1814 Boolean result
= false;
1815 wxMacDataBrowserListCtrlControl
* ctl
= dynamic_cast<wxMacDataBrowserListCtrlControl
*>( wxMacControl::GetReferenceFromNativeControl( browser
) );
1818 result
= ctl
->ConfirmEditText(itemID
, property
, theString
, maxEditTextRect
, shrinkToFit
);
1819 theString
= CFSTR("Hello!");
1824 bool wxMacDataBrowserListCtrlControl::ConfirmEditText(
1825 DataBrowserItemID itemID
,
1826 DataBrowserPropertyID property
,
1827 CFStringRef theString
,
1828 Rect
*maxEditTextRect
,
1829 Boolean
*shrinkToFit
)
1831 //wxListCtrl* list = wxDynamicCast( GetPeer() , wxListCtrl );
1835 pascal void wxMacDataBrowserListCtrlControl::DataBrowserDrawItemProc(
1837 DataBrowserItemID itemID
,
1838 DataBrowserPropertyID property
,
1839 DataBrowserItemState itemState
,
1840 const Rect
*itemRect
,
1842 Boolean colorDevice
)
1844 wxMacDataBrowserListCtrlControl
* ctl
= dynamic_cast<wxMacDataBrowserListCtrlControl
*>( wxMacControl::GetReferenceFromNativeControl( browser
) );
1847 ctl
->DrawItem(itemID
, property
, itemState
, itemRect
, gdDepth
, colorDevice
);
1851 // routines needed for DrawItem
1856 kTextBoxHeight
= 14,
1857 kIconTextSpacingV
= 2,
1859 kContentHeight
= kIconHeight
+ kTextBoxHeight
+ kIconTextSpacingV
1862 static void calculateCGDrawingBounds(CGRect inItemRect
, CGRect
*outIconRect
, CGRect
*outTextRect
, bool hasIcon
= false)
1865 float iconH
, iconW
= 0;
1866 float padding
= kItemPadding
;
1869 iconH
= kIconHeight
;
1871 padding
= padding
*2;
1874 textBottom
= inItemRect
.origin
.y
;
1876 *outIconRect
= CGRectMake(inItemRect
.origin
.x
+ kItemPadding
,
1877 textBottom
+ kIconTextSpacingV
, kIconWidth
,
1880 *outTextRect
= CGRectMake(inItemRect
.origin
.x
+ padding
+ iconW
,
1881 textBottom
+ kIconTextSpacingV
, inItemRect
.size
.width
- padding
- iconW
,
1882 inItemRect
.size
.height
- kIconTextSpacingV
);
1885 void wxMacDataBrowserListCtrlControl::DrawItem(
1886 DataBrowserItemID itemID
,
1887 DataBrowserPropertyID property
,
1888 DataBrowserItemState itemState
,
1889 const Rect
*itemRect
,
1891 Boolean colorDevice
)
1894 wxFont font
= wxNullFont
;
1896 short listColumn
= property
- kMinColumnId
;
1898 wxListCtrl
* list
= wxDynamicCast( GetPeer() , wxListCtrl
);
1899 wxMacListCtrlItem
* lcItem
;
1900 wxColour color
= *wxBLACK
;
1901 wxColour bgColor
= wxNullColour
;
1903 if (listColumn
>= 0)
1907 lcItem
= (wxMacListCtrlItem
*) itemID
;
1908 if (lcItem
->HasColumnInfo(listColumn
)){
1909 wxListItem
* item
= lcItem
->GetColumnInfo(listColumn
);
1911 // we always use the 0 column to get font and text/background colors.
1912 if (lcItem
->HasColumnInfo(0))
1914 wxListItem
* firstItem
= lcItem
->GetColumnInfo(0);
1915 color
= firstItem
->GetTextColour();
1916 bgColor
= firstItem
->GetBackgroundColour();
1917 font
= firstItem
->GetFont();
1920 if (item
->GetMask() & wxLIST_MASK_TEXT
)
1921 text
= item
->GetText();
1922 if (item
->GetMask() & wxLIST_MASK_IMAGE
)
1923 imgIndex
= item
->GetImage();
1929 text
= list
->OnGetItemText( (long)itemID
-1, listColumn
);
1930 imgIndex
= list
->OnGetItemColumnImage( (long)itemID
-1, listColumn
);
1931 wxListItemAttr
* attrs
= list
->OnGetItemAttr( (long)itemID
-1 );
1934 if (attrs
->HasBackgroundColour())
1935 bgColor
= attrs
->GetBackgroundColour();
1936 if (attrs
->HasTextColour())
1937 color
= attrs
->GetTextColour();
1938 if (attrs
->HasFont())
1939 font
= attrs
->GetFont();
1944 wxColour listBgColor
= list
->GetBackgroundColour();
1945 if (bgColor
== wxNullColour
)
1946 bgColor
= listBgColor
;
1948 wxFont listFont
= list
->GetFont();
1949 if (font
== wxNullFont
)
1952 wxMacCFStringHolder cfString
;
1953 cfString
.Assign( text
, wxLocale::GetSystemEncoding() );
1956 CGRect enclosingCGRect
, iconCGRect
, textCGRect
;
1958 ThemeDrawingState savedState
= NULL
;
1959 CGContextRef context
= (CGContextRef
)list
->MacGetDrawingContext();
1960 RGBColor labelColor
;
1962 GetDataBrowserItemPartBounds(GetControlRef(), itemID
, property
, kDataBrowserPropertyEnclosingPart
,
1965 enclosingCGRect
= CGRectMake(enclosingRect
.left
,
1967 enclosingRect
.right
- enclosingRect
.left
,
1968 enclosingRect
.bottom
- enclosingRect
.top
);
1970 active
= IsControlActive(GetControlRef());
1972 if (itemState
== kDataBrowserItemIsSelected
)
1974 RGBColor foregroundColor
;
1976 GetThemeDrawingState(&savedState
);
1978 GetThemeBrushAsColor(kThemeBrushAlternatePrimaryHighlightColor
, 32, true, &foregroundColor
);
1979 GetThemeTextColor(kThemeTextColorWhite
, gdDepth
, colorDevice
, &labelColor
);
1981 CGContextSaveGState(context
);
1983 CGContextSetRGBFillColor(context
, (float)foregroundColor
.red
/ (float)USHRT_MAX
,
1984 (float)foregroundColor
.green
/ (float)USHRT_MAX
,
1985 (float)foregroundColor
.blue
/ (float)USHRT_MAX
, 1.0);
1986 CGContextFillRect(context
, enclosingCGRect
);
1988 CGContextRestoreGState(context
);
1994 labelColor
= MAC_WXCOLORREF( color
.GetPixel() );
1995 else if (list
->GetTextColour().Ok())
1996 labelColor
= MAC_WXCOLORREF( list
->GetTextColour().GetPixel() );
2000 labelColor
.green
= 0;
2001 labelColor
.blue
= 0;
2006 RGBColor foregroundColor
= MAC_WXCOLORREF( bgColor
.GetPixel() );
2007 CGContextSaveGState(context
);
2009 CGContextSetRGBFillColor(context
, (float)foregroundColor
.red
/ (float)USHRT_MAX
,
2010 (float)foregroundColor
.green
/ (float)USHRT_MAX
,
2011 (float)foregroundColor
.blue
/ (float)USHRT_MAX
, 1.0);
2012 CGContextFillRect(context
, enclosingCGRect
);
2014 CGContextRestoreGState(context
);
2018 calculateCGDrawingBounds(enclosingCGRect
, &iconCGRect
, &textCGRect
, (imgIndex
!= -1) );
2022 wxImageList
* imageList
= list
->GetImageList(wxIMAGE_LIST_SMALL
);
2023 if (imageList
&& imageList
->GetImageCount() > 0){
2024 wxBitmap bmp
= imageList
->GetBitmap(imgIndex
);
2025 IconRef icon
= bmp
.GetBitmapData()->GetIconRef();
2029 iconLabel
.green
= 0;
2032 PlotIconRefInContext(context
, &iconCGRect
, kAlignNone
,
2033 active
? kTransformNone
: kTransformDisabled
, &iconLabel
,
2034 kPlotIconRefNormalFlags
, icon
);
2038 HIThemeTextHorizontalFlush hFlush
= kHIThemeTextHorizontalFlushLeft
;
2039 UInt16 fontID
= kThemeViewsFont
;
2043 if (font
.GetFamily() != wxFONTFAMILY_DEFAULT
)
2044 fontID
= font
.MacGetThemeFontID();
2046 // FIXME: replace these with CG or ATSUI calls so we can remove this #ifndef.
2048 ::TextSize( (short)(font
.MacGetFontSize()) ) ;
2049 ::TextFace( font
.MacGetFontStyle() ) ;
2054 list
->GetColumn(listColumn
, item
);
2055 if (item
.GetMask() & wxLIST_MASK_FORMAT
)
2057 if (item
.GetAlign() == wxLIST_FORMAT_LEFT
)
2058 hFlush
= kHIThemeTextHorizontalFlushLeft
;
2059 else if (item
.GetAlign() == wxLIST_FORMAT_CENTER
)
2060 hFlush
= kHIThemeTextHorizontalFlushCenter
;
2061 else if (item
.GetAlign() == wxLIST_FORMAT_RIGHT
)
2063 hFlush
= kHIThemeTextHorizontalFlushRight
;
2064 textCGRect
.origin
.x
-= kItemPadding
; // give a little extra paddding
2068 HIThemeTextInfo info
;
2069 info
.version
= kHIThemeTextInfoVersionZero
;
2070 info
.state
= active
? kThemeStateActive
: kThemeStateInactive
;
2071 info
.fontID
= fontID
;
2072 info
.horizontalFlushness
= hFlush
;
2073 info
.verticalFlushness
= kHIThemeTextVerticalFlushCenter
;
2074 info
.options
= kHIThemeTextBoxOptionNone
;
2075 info
.truncationPosition
= kHIThemeTextTruncationEnd
;
2076 info
.truncationMaxLines
= 1;
2078 CGContextSaveGState(context
);
2079 CGContextSetRGBFillColor (context
, (float)labelColor
.red
/ (float)USHRT_MAX
,
2080 (float)labelColor
.green
/ (float)USHRT_MAX
,
2081 (float)labelColor
.blue
/ (float)USHRT_MAX
, 1.0);
2083 HIThemeDrawTextBox(cfString
, &textCGRect
, &info
, context
, kHIThemeOrientationNormal
);
2085 CGContextRestoreGState(context
);
2087 if (savedState
!= NULL
)
2088 SetThemeDrawingState(savedState
, true);
2091 OSStatus
wxMacDataBrowserListCtrlControl::GetSetItemData(DataBrowserItemID itemID
,
2092 DataBrowserPropertyID property
,
2093 DataBrowserItemDataRef itemData
,
2094 Boolean changeValue
)
2098 short listColumn
= property
- kMinColumnId
;
2100 OSStatus err
= errDataBrowserPropertyNotSupported
;
2101 wxListCtrl
* list
= wxDynamicCast( GetPeer() , wxListCtrl
);
2102 wxMacListCtrlItem
* lcItem
;
2104 if (listColumn
>= 0)
2108 lcItem
= (wxMacListCtrlItem
*) itemID
;
2109 if (lcItem
->HasColumnInfo(listColumn
)){
2110 wxListItem
* item
= lcItem
->GetColumnInfo(listColumn
);
2111 if (item
->GetMask() & wxLIST_MASK_TEXT
)
2112 text
= item
->GetText();
2113 if (item
->GetMask() & wxLIST_MASK_IMAGE
)
2114 imgIndex
= item
->GetImage();
2119 text
= list
->OnGetItemText( (long)itemID
-1, listColumn
);
2120 imgIndex
= list
->OnGetItemColumnImage( (long)itemID
-1, listColumn
);
2128 case kDataBrowserItemIsEditableProperty
:
2129 if ( list
&& list
->HasFlag( wxLC_EDIT_LABELS
) )
2131 verify_noerr(SetDataBrowserItemDataBooleanValue( itemData
, true ));
2136 if ( property
>= kMinColumnId
)
2138 wxMacCFStringHolder cfStr
;
2141 cfStr
.Assign( text
, wxLocale::GetSystemEncoding() );
2142 err
= ::SetDataBrowserItemDataText( itemData
, cfStr
);
2148 if ( imgIndex
!= -1 )
2150 wxImageList
* imageList
= list
->GetImageList(wxIMAGE_LIST_SMALL
);
2151 if (imageList
&& imageList
->GetImageCount() > 0){
2152 wxBitmap bmp
= imageList
->GetBitmap(imgIndex
);
2153 IconRef icon
= bmp
.GetBitmapData()->GetIconRef();
2154 ::SetDataBrowserItemDataIcon(itemData
, icon
);
2168 if ( property
>= kMinColumnId
)
2170 short listColumn
= property
- kMinColumnId
;
2172 // TODO probably send the 'end edit' from here, as we
2173 // can then deal with the veto
2175 verify_noerr( GetDataBrowserItemDataText( itemData
, &sr
) ) ;
2176 wxMacCFStringHolder
cfStr(sr
) ;;
2178 list
->SetItem( (long)itemData
-1 , listColumn
, cfStr
.AsString() ) ;
2182 lcItem
->SetColumnTextValue( listColumn
, cfStr
.AsString() );
2192 void wxMacDataBrowserListCtrlControl::ItemNotification(DataBrowserItemID itemID
,
2193 DataBrowserItemNotification message
,
2194 DataBrowserItemDataRef itemData
)
2196 // we want to depend on as little as possible to make sure tear-down of controls is safe
2197 if ( message
== kDataBrowserItemRemoved
)
2199 // make sure MacDelete does the proper teardown.
2202 else if ( message
== kDataBrowserItemAdded
)
2204 // we don't issue events on adding, the item is not really stored in the list yet, so we
2205 // avoid asserts by getting out now
2209 wxListCtrl
*list
= wxDynamicCast( GetPeer() , wxListCtrl
);
2212 bool trigger
= false;
2214 wxListEvent
event( wxEVT_COMMAND_LIST_ITEM_SELECTED
, list
->GetId() );
2215 bool isSingle
= (list
->GetWindowStyle() & wxLC_SINGLE_SEL
) != 0;
2217 event
.SetEventObject( list
);
2218 if ( !list
->IsVirtual() )
2220 DataBrowserTableViewRowIndex result
= 0;
2221 verify_noerr( GetItemRow( itemID
, &result
) ) ;
2222 event
.m_itemIndex
= result
;
2224 if (event
.m_itemIndex
>= 0)
2225 MacGetColumnInfo(event
.m_itemIndex
,0,event
.m_item
);
2229 event
.m_itemIndex
= (long)itemID
;
2234 case kDataBrowserItemDeselected
:
2235 event
.SetEventType(wxEVT_COMMAND_LIST_ITEM_DESELECTED
);
2237 trigger
= !IsSelectionSuppressed();
2240 case kDataBrowserItemSelected
:
2241 trigger
= !IsSelectionSuppressed();
2245 case kDataBrowserItemDoubleClicked
:
2246 event
.SetEventType( wxEVT_COMMAND_LIST_ITEM_ACTIVATED
);
2250 case kDataBrowserEditStarted
:
2251 // TODO : how to veto ?
2252 event
.SetEventType( wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
) ;
2256 case kDataBrowserEditStopped
:
2257 // TODO probably trigger only upon the value store callback, because
2258 // here IIRC we cannot veto
2259 event
.SetEventType( wxEVT_COMMAND_LIST_END_LABEL_EDIT
) ;
2269 // direct notification is not always having the listbox GetSelection() having in synch with event
2270 wxPostEvent( list
->GetEventHandler(), event
);
2275 Boolean
wxMacDataBrowserListCtrlControl::CompareItems(DataBrowserItemID itemOneID
,
2276 DataBrowserItemID itemTwoID
,
2277 DataBrowserPropertyID sortProperty
)
2280 bool retval
= false;
2282 wxString otherItemText
;
2283 int colId
= sortProperty
- kMinColumnId
;
2285 long otherItemNum
= 0;
2287 wxListCtrl
* list
= wxDynamicCast( GetPeer() , wxListCtrl
);
2294 wxMacListCtrlItem
* item
= (wxMacListCtrlItem
*)itemOneID
;
2295 wxMacListCtrlItem
* otherItem
= (wxMacListCtrlItem
*)itemTwoID
;
2296 wxListCtrlCompare func
= list
->GetCompareFunc();
2297 if (func
!= NULL
&& item
->HasColumnInfo(colId
) && otherItem
->HasColumnInfo(colId
))
2298 return func(item
->GetColumnInfo(colId
)->GetData(), otherItem
->GetColumnInfo(colId
)->GetData(), list
->GetCompareFuncData()) >= 0;
2300 itemNum
= item
->GetOrder();
2301 otherItemNum
= otherItem
->GetOrder();
2302 if (item
->HasColumnInfo(colId
))
2303 itemText
= item
->GetColumnInfo(colId
)->GetText();
2304 if (otherItem
->HasColumnInfo(colId
))
2305 otherItemText
= otherItem
->GetColumnInfo(colId
)->GetText();
2309 itemNum
= (long)itemOneID
;
2310 otherItemNum
= (long)itemTwoID
;
2311 itemText
= list
->OnGetItemText( itemNum
-1, colId
);
2312 otherItemText
= list
->OnGetItemText( otherItemNum
-1, colId
);
2316 DataBrowserSortOrder sort
;
2317 verify_noerr(GetSortOrder(&sort
));
2319 if ( sort
== kDataBrowserOrderIncreasing
)
2321 retval
= itemText
.CmpNoCase( otherItemText
) > 0;
2323 else if ( sort
== kDataBrowserOrderDecreasing
)
2325 retval
= itemText
.CmpNoCase( otherItemText
) < 0;
2329 // fallback for undefined cases
2330 retval
= itemOneID
< itemTwoID
;
2336 wxMacDataBrowserListCtrlControl::~wxMacDataBrowserListCtrlControl()
2340 void wxMacDataBrowserListCtrlControl::MacSetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
* item
)
2342 wxMacDataItem
* dataItem
= GetItemFromLine(row
);
2345 wxMacListCtrlItem
* listItem
= dynamic_cast<wxMacListCtrlItem
*>(dataItem
);
2346 listItem
->SetColumnInfo( column
, item
);
2347 UpdateState(dataItem
, item
);
2351 // apply changes that need to happen immediately, rather than when the
2352 // databrowser control fires a callback.
2353 void wxMacDataBrowserListCtrlControl::UpdateState(wxMacDataItem
* dataItem
, wxListItem
* listItem
)
2355 bool isSelected
= IsItemSelected( dataItem
);
2356 bool isSelectedState
= (listItem
->GetState() == wxLIST_STATE_SELECTED
);
2358 // toggle the selection state if wxListInfo state and actual state don't match.
2359 if ( isSelected
!= isSelectedState
)
2361 DataBrowserSetOption options
= kDataBrowserItemsAdd
;
2362 if (!isSelectedState
)
2363 options
= kDataBrowserItemsRemove
;
2364 SetSelectedItem(dataItem
, options
);
2366 // TODO: Set column width if item width > than current column width
2369 void wxMacDataBrowserListCtrlControl::MacGetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
& item
)
2371 wxMacDataItem
* dataItem
= GetItemFromLine(row
);
2372 // CS should this guard against dataItem = 0 ? , as item is not a pointer if (item) is not appropriate
2375 wxMacListCtrlItem
* listItem
= dynamic_cast<wxMacListCtrlItem
*>(dataItem
);
2376 wxListItem
* oldItem
= listItem
->GetColumnInfo( column
);
2378 long mask
= item
.GetMask();
2380 // by default, get everything for backwards compatibility
2383 if ( mask
& wxLIST_MASK_TEXT
)
2384 item
.SetText(oldItem
->GetText());
2385 if ( mask
& wxLIST_MASK_IMAGE
)
2386 item
.SetImage(oldItem
->GetImage());
2387 if ( mask
& wxLIST_MASK_DATA
)
2388 item
.SetData(oldItem
->GetData());
2389 if ( mask
& wxLIST_MASK_STATE
)
2390 item
.SetState(oldItem
->GetState());
2391 if ( mask
& wxLIST_MASK_WIDTH
)
2392 item
.SetWidth(oldItem
->GetWidth());
2393 if ( mask
& wxLIST_MASK_FORMAT
)
2394 item
.SetAlign(oldItem
->GetAlign());
2396 item
.SetTextColour(oldItem
->GetTextColour());
2397 item
.SetBackgroundColour(oldItem
->GetBackgroundColour());
2398 item
.SetFont(oldItem
->GetFont());
2402 void wxMacDataBrowserListCtrlControl::MacInsertItem( unsigned int n
, wxListItem
* item
)
2404 wxMacDataItemBrowserControl::MacInsert(n
, item
->GetText());
2405 MacSetColumnInfo(n
, 0, item
);
2408 wxMacDataItem
* wxMacDataBrowserListCtrlControl::CreateItem()
2410 return new wxMacListCtrlItem();
2413 wxMacListCtrlItem::wxMacListCtrlItem()
2415 m_rowItems
= wxListItemList();
2418 int wxMacListCtrlItem::GetColumnImageValue( unsigned int column
)
2420 return GetColumnInfo(column
)->GetImage();
2423 void wxMacListCtrlItem::SetColumnImageValue( unsigned int column
, int imageIndex
)
2425 GetColumnInfo(column
)->SetImage(imageIndex
);
2428 const wxString
& wxMacListCtrlItem::GetColumnTextValue( unsigned int column
)
2433 return GetColumnInfo(column
)->GetText();
2436 void wxMacListCtrlItem::SetColumnTextValue( unsigned int column
, const wxString
& text
)
2438 GetColumnInfo(column
)->SetText(text
);
2440 // for compatibility with superclass APIs
2445 wxListItem
* wxMacListCtrlItem::GetColumnInfo( unsigned int column
)
2447 wxListItemList::compatibility_iterator node
= m_rowItems
.Item( column
);
2448 wxASSERT_MSG( node
, _T("invalid column index in wxMacListCtrlItem") );
2450 return node
->GetData();
2453 bool wxMacListCtrlItem::HasColumnInfo( unsigned int column
)
2455 return m_rowItems
.GetCount() > column
;
2458 void wxMacListCtrlItem::SetColumnInfo( unsigned int column
, wxListItem
* item
)
2461 if ( column
>= m_rowItems
.GetCount() )
2463 wxListItem
* listItem
= new wxListItem(*item
);
2464 m_rowItems
.Append( listItem
);
2468 wxListItem
* listItem
= GetColumnInfo( column
);
2469 long mask
= item
->GetMask();
2470 if (mask
& wxLIST_MASK_TEXT
)
2471 listItem
->SetText(item
->GetText());
2472 if (mask
& wxLIST_MASK_DATA
)
2473 listItem
->SetData(item
->GetData());
2474 if (mask
& wxLIST_MASK_IMAGE
)
2475 listItem
->SetImage(item
->GetImage());
2476 if (mask
& wxLIST_MASK_STATE
)
2477 listItem
->SetState(item
->GetState());
2478 if (mask
& wxLIST_MASK_FORMAT
)
2479 listItem
->SetAlign(item
->GetAlign());
2480 if (mask
& wxLIST_MASK_WIDTH
)
2481 listItem
->SetWidth(item
->GetWidth());
2483 listItem
->SetTextColour(item
->GetTextColour());
2484 listItem
->SetBackgroundColour(item
->GetBackgroundColour());
2485 listItem
->SetFont(item
->GetFont());
2489 #endif // wxUSE_LISTCTRL