1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/listctrl.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"
33 #include "wx/settings.h"
34 #include "wx/dcclient.h"
35 #include "wx/textctrl.h"
38 #include "wx/mac/uma.h"
40 #include "wx/imaglist.h"
41 #include "wx/listctrl.h"
42 #include "wx/sysopt.h"
44 #define wxMAC_ALWAYS_USE_GENERIC_LISTCTRL wxT("mac.listctrl.always_use_generic")
46 #if wxUSE_EXTENDED_RTTI
47 WX_DEFINE_FLAGS( wxListCtrlStyle
)
49 wxBEGIN_FLAGS( wxListCtrlStyle
)
50 // new style border flags, we put them first to
51 // use them for streaming out
52 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
53 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
54 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
55 wxFLAGS_MEMBER(wxBORDER_RAISED
)
56 wxFLAGS_MEMBER(wxBORDER_STATIC
)
57 wxFLAGS_MEMBER(wxBORDER_NONE
)
59 // old style border flags
60 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
61 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
62 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
63 wxFLAGS_MEMBER(wxRAISED_BORDER
)
64 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
65 wxFLAGS_MEMBER(wxBORDER
)
67 // standard window styles
68 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
69 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
70 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
71 wxFLAGS_MEMBER(wxWANTS_CHARS
)
72 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
73 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
74 wxFLAGS_MEMBER(wxVSCROLL
)
75 wxFLAGS_MEMBER(wxHSCROLL
)
77 wxFLAGS_MEMBER(wxLC_LIST
)
78 wxFLAGS_MEMBER(wxLC_REPORT
)
79 wxFLAGS_MEMBER(wxLC_ICON
)
80 wxFLAGS_MEMBER(wxLC_SMALL_ICON
)
81 wxFLAGS_MEMBER(wxLC_ALIGN_TOP
)
82 wxFLAGS_MEMBER(wxLC_ALIGN_LEFT
)
83 wxFLAGS_MEMBER(wxLC_AUTOARRANGE
)
84 wxFLAGS_MEMBER(wxLC_USER_TEXT
)
85 wxFLAGS_MEMBER(wxLC_EDIT_LABELS
)
86 wxFLAGS_MEMBER(wxLC_NO_HEADER
)
87 wxFLAGS_MEMBER(wxLC_SINGLE_SEL
)
88 wxFLAGS_MEMBER(wxLC_SORT_ASCENDING
)
89 wxFLAGS_MEMBER(wxLC_SORT_DESCENDING
)
90 wxFLAGS_MEMBER(wxLC_VIRTUAL
)
92 wxEND_FLAGS( wxListCtrlStyle
)
94 IMPLEMENT_DYNAMIC_CLASS_XTI(wxListCtrl
, wxControl
,"wx/listctrl.h")
96 wxBEGIN_PROPERTIES_TABLE(wxListCtrl
)
97 wxEVENT_PROPERTY( TextUpdated
, wxEVT_COMMAND_TEXT_UPDATED
, wxCommandEvent
)
99 wxPROPERTY_FLAGS( WindowStyle
, wxListCtrlStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
100 wxEND_PROPERTIES_TABLE()
102 wxBEGIN_HANDLERS_TABLE(wxListCtrl
)
103 wxEND_HANDLERS_TABLE()
105 wxCONSTRUCTOR_5( wxListCtrl
, wxWindow
* , Parent
, wxWindowID
, Id
, wxPoint
, Position
, wxSize
, Size
, long , WindowStyle
)
108 TODO : Expose more information of a list's layout etc. via appropriate objects (à la NotebookPageInfo)
111 IMPLEMENT_DYNAMIC_CLASS(wxListCtrl
, wxControl
)
114 IMPLEMENT_DYNAMIC_CLASS(wxListView
, wxListCtrl
)
115 IMPLEMENT_DYNAMIC_CLASS(wxListItem
, wxObject
)
117 IMPLEMENT_DYNAMIC_CLASS(wxListEvent
, wxNotifyEvent
)
119 WX_DECLARE_EXPORTED_LIST(wxListItem
, wxListItemList
);
120 #include "wx/listimpl.cpp"
121 WX_DEFINE_LIST(wxListItemList
)
123 class wxMacListCtrlItem
: public wxMacListBoxItem
128 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
129 DataBrowserItemNotification message
,
130 DataBrowserItemDataRef itemData
) const;
132 virtual void SetColumnInfo( unsigned int column
, wxListItem
* item
);
133 virtual wxListItem
* GetColumnInfo( unsigned int column
);
134 virtual bool HasColumnInfo( unsigned int column
);
136 virtual void SetColumnTextValue( unsigned int column
, const wxString
& text
);
137 virtual const wxString
& GetColumnTextValue( unsigned int column
);
139 virtual int GetColumnImageValue( unsigned int column
);
140 virtual void SetColumnImageValue( unsigned int column
, int imageIndex
);
142 virtual ~wxMacListCtrlItem();
144 wxListItemList m_rowItems
;
147 // TODO: Make a better name!!
148 class wxMacDataBrowserListCtrlControl
: public wxMacDataItemBrowserControl
151 wxMacDataBrowserListCtrlControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
152 virtual ~wxMacDataBrowserListCtrlControl();
154 // create a list item (can be a subclass of wxMacListBoxItem)
156 virtual wxMacListCtrlItem
* CreateItem();
158 virtual void MacInsertItem( unsigned int n
, wxListItem
* item
);
159 virtual void MacSetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
* item
);
160 virtual void MacGetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
& item
);
161 virtual void UpdateState(wxMacDataItem
* dataItem
, wxListItem
* item
);
164 // we need to override to provide specialized handling for virtual wxListCtrls
165 virtual OSStatus
GetSetItemData(DataBrowserItemID itemID
,
166 DataBrowserPropertyID property
,
167 DataBrowserItemDataRef itemData
,
168 Boolean changeValue
);
170 virtual void ItemNotification(
171 DataBrowserItemID itemID
,
172 DataBrowserItemNotification message
,
173 DataBrowserItemDataRef itemData
);
175 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
176 DataBrowserItemID itemTwoID
,
177 DataBrowserPropertyID sortProperty
);
179 wxClientDataType m_clientDataItemsType
;
184 // TODO: This gives errors, find out why.
185 //BEGIN_EVENT_TABLE(wxListCtrl, wxControl)
186 // EVT_PAINT(wxListCtrl::OnPaint)
189 // ============================================================================
191 // ============================================================================
193 wxMacListControl
* wxListCtrl::GetPeer() const
195 return dynamic_cast<wxMacListControl
*>(m_peer
);
198 // ----------------------------------------------------------------------------
199 // wxListCtrl construction
200 // ----------------------------------------------------------------------------
202 void wxListCtrl::Init()
204 m_imageListNormal
= NULL
;
205 m_imageListSmall
= NULL
;
206 m_imageListState
= NULL
;
208 // keep track of if we created our own image lists, or if they were assigned
210 m_ownsImageListNormal
= m_ownsImageListSmall
= m_ownsImageListState
= false;
214 m_genericImpl
= NULL
;
218 class wxGenericListCtrlHook
: public wxGenericListCtrl
221 wxGenericListCtrlHook(wxListCtrl
* parent
,
226 const wxValidator
& validator
,
227 const wxString
& name
)
228 : wxGenericListCtrl(parent
, id
, pos
, size
, style
, validator
, name
),
229 m_nativeListCtrl(parent
)
233 virtual wxListItemAttr
* OnGetItemAttr(long item
) const
235 return m_nativeListCtrl
->OnGetItemAttr(item
);
238 virtual int OnGetItemImage(long item
) const
240 return m_nativeListCtrl
->OnGetItemImage(item
);
243 virtual int OnGetItemColumnImage(long item
, long column
) const
245 return m_nativeListCtrl
->OnGetItemColumnImage(item
, column
);
248 virtual wxString
OnGetItemText(long item
, long column
) const
250 return m_nativeListCtrl
->OnGetItemText(item
, column
);
254 wxListCtrl
* m_nativeListCtrl
;
258 bool wxListCtrl::Create(wxWindow
*parent
,
263 const wxValidator
& validator
,
264 const wxString
& name
)
267 // for now, we'll always use the generic list control for ICON and LIST views,
268 // because they dynamically change the number of columns on resize.
269 // Also, allow the user to set it to use the list ctrl as well.
270 // Also, use generic list control in VIRTUAL mode.
271 if ( (wxSystemOptions::HasOption( wxMAC_ALWAYS_USE_GENERIC_LISTCTRL
)
272 && (wxSystemOptions::GetOptionInt( wxMAC_ALWAYS_USE_GENERIC_LISTCTRL
) == 1)) ||
273 (style
& wxLC_ICON
) || (style
& wxLC_SMALL_ICON
) || (style
& wxLC_LIST
) || (style
& wxLC_VIRTUAL
) )
275 m_macIsUserPane
= true;
277 if ( !wxWindow::Create(parent
, id
, pos
, size
, style
, name
) )
279 m_genericImpl
= new wxGenericListCtrlHook(this, id
, pos
, size
, style
, validator
, name
);
285 m_macIsUserPane
= false;
287 if ( !wxWindow::Create(parent
, id
, pos
, size
, style
, name
) )
289 m_dbImpl
= new wxMacDataBrowserListCtrlControl( this, pos
, size
, style
);
292 MacPostControlCreate( pos
, size
);
298 wxListCtrl::~wxListCtrl()
300 if (m_ownsImageListNormal
)
301 delete m_imageListNormal
;
302 if (m_ownsImageListSmall
)
303 delete m_imageListSmall
;
304 if (m_ownsImageListState
)
305 delete m_imageListState
;
308 // ----------------------------------------------------------------------------
309 // set/get/change style
310 // ----------------------------------------------------------------------------
312 // Add or remove a single window style
313 void wxListCtrl::SetSingleStyle(long style
, bool add
)
315 long flag
= GetWindowStyleFlag();
317 // Get rid of conflicting styles
320 if ( style
& wxLC_MASK_TYPE
)
321 flag
= flag
& ~wxLC_MASK_TYPE
;
322 if ( style
& wxLC_MASK_ALIGN
)
323 flag
= flag
& ~wxLC_MASK_ALIGN
;
324 if ( style
& wxLC_MASK_SORT
)
325 flag
= flag
& ~wxLC_MASK_SORT
;
333 SetWindowStyleFlag(flag
);
336 // Set the whole window style
337 void wxListCtrl::SetWindowStyleFlag(long flag
)
339 if ( flag
!= m_windowStyle
)
341 m_windowStyle
= flag
;
345 m_genericImpl
->SetWindowStyleFlag(flag
);
352 void wxListCtrl::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
354 wxControl::DoSetSize(x
, y
, width
, height
, sizeFlags
);
357 m_genericImpl
->SetSize(x
, y
, width
, height
, sizeFlags
);
360 // ----------------------------------------------------------------------------
362 // ----------------------------------------------------------------------------
364 // Gets information about this column
365 bool wxListCtrl::GetColumn(int col
, wxListItem
& item
) const
368 return m_genericImpl
->GetColumn(col
, item
);
372 if ( item
.m_mask
& wxLIST_MASK_TEXT
)
376 if ( item
.m_mask
& wxLIST_MASK_FORMAT
)
380 if ( item
.m_mask
& wxLIST_MASK_IMAGE
)
384 if ( (item
.m_mask
& wxLIST_MASK_TEXT
) )
392 // Sets information about this column
393 bool wxListCtrl::SetColumn(int col
, wxListItem
& item
)
396 return m_genericImpl
->SetColumn(col
, item
);
401 int wxListCtrl::GetColumnCount() const
404 return m_genericImpl
->GetColumnCount();
409 m_dbImpl
->GetColumnCount(&count
);
416 // Gets the column width
417 int wxListCtrl::GetColumnWidth(int col
) const
420 return m_genericImpl
->GetColumnWidth(col
);
424 return m_dbImpl
->GetColumnWidth(col
);
430 // Sets the column width
431 bool wxListCtrl::SetColumnWidth(int col
, int width
)
434 return m_genericImpl
->SetColumnWidth(col
, width
);
436 // TODO: This is setting the width of the first column
437 // to the entire window width; investigate why
443 if (width
== wxLIST_AUTOSIZE
|| width
== wxLIST_AUTOSIZE_USEHEADER
)
448 for (int column
= 0; column
< GetColumnCount(); column
++)
450 m_dbImpl
->SetColumnWidth(col
, mywidth
);
454 m_dbImpl
->SetColumnWidth(col
, mywidth
);
462 // Gets the number of items that can fit vertically in the
463 // visible area of the list control (list or report view)
464 // or the total number of items in the list control (icon
465 // or small icon view)
466 int wxListCtrl::GetCountPerPage() const
469 return m_genericImpl
->GetCountPerPage();
478 // Gets the edit control for editing labels.
479 wxTextCtrl
* wxListCtrl::GetEditControl() const
482 return m_genericImpl
->GetEditControl();
487 // Gets information about the item
488 bool wxListCtrl::GetItem(wxListItem
& info
) const
491 return m_genericImpl
->GetItem(info
);
494 m_dbImpl
->MacGetColumnInfo(info
.m_itemId
, info
.m_col
, info
);
499 // Sets information about the item
500 bool wxListCtrl::SetItem(wxListItem
& info
)
503 return m_genericImpl
->SetItem(info
);
506 m_dbImpl
->MacSetColumnInfo( info
.m_itemId
, info
.m_col
, &info
);
511 long wxListCtrl::SetItem(long index
, int col
, const wxString
& label
, int imageId
)
514 return m_genericImpl
->SetItem(index
, col
, label
, imageId
);
518 info
.m_mask
= wxLIST_MASK_TEXT
;
519 info
.m_itemId
= index
;
523 info
.m_image
= imageId
;
524 info
.m_mask
|= wxLIST_MASK_IMAGE
;
526 return SetItem(info
);
530 // Gets the item state
531 int wxListCtrl::GetItemState(long item
, long stateMask
) const
534 return m_genericImpl
->GetItemState(item
, stateMask
);
538 info
.m_mask
= wxLIST_MASK_STATE
;
539 info
.m_stateMask
= stateMask
;
540 info
.m_itemId
= item
;
548 // Sets the item state
549 bool wxListCtrl::SetItemState(long item
, long state
, long stateMask
)
552 return m_genericImpl
->SetItemState(item
, state
, stateMask
);
555 info
.m_mask
= wxLIST_MASK_STATE
;
556 info
.m_stateMask
= stateMask
;
557 info
.m_state
= state
;
558 info
.m_itemId
= item
;
559 return SetItem(info
);
562 // Sets the item image
563 bool wxListCtrl::SetItemImage(long item
, int image
, int WXUNUSED(selImage
))
565 return SetItemColumnImage(item
, 0, image
);
568 // Sets the item image
569 bool wxListCtrl::SetItemColumnImage(long item
, long column
, int image
)
572 return m_genericImpl
->SetItemColumnImage(item
, column
, image
);
576 info
.m_mask
= wxLIST_MASK_IMAGE
;
577 info
.m_image
= image
;
578 info
.m_itemId
= item
;
581 return SetItem(info
);
584 // Gets the item text
585 wxString
wxListCtrl::GetItemText(long item
) const
588 return m_genericImpl
->GetItemText(item
);
592 info
.m_mask
= wxLIST_MASK_TEXT
;
593 info
.m_itemId
= item
;
596 return wxEmptyString
;
600 // Sets the item text
601 void wxListCtrl::SetItemText(long item
, const wxString
& str
)
604 return m_genericImpl
->SetItemText(item
, str
);
608 info
.m_mask
= wxLIST_MASK_TEXT
;
609 info
.m_itemId
= item
;
615 // Gets the item data
616 long wxListCtrl::GetItemData(long item
) const
619 return m_genericImpl
->GetItemData(item
);
623 info
.m_mask
= wxLIST_MASK_DATA
;
624 info
.m_itemId
= item
;
631 // Sets the item data
632 bool wxListCtrl::SetItemData(long item
, long data
)
635 return m_genericImpl
->SetItemData(item
, data
);
639 info
.m_mask
= wxLIST_MASK_DATA
;
640 info
.m_itemId
= item
;
643 return SetItem(info
);
646 wxRect
wxListCtrl::GetViewRect() const
648 wxASSERT_MSG( !HasFlag(wxLC_REPORT
| wxLC_LIST
),
649 _T("wxListCtrl::GetViewRect() only works in icon mode") );
652 return m_genericImpl
->GetViewRect();
658 // Gets the item rectangle
659 bool wxListCtrl::GetItemRect(long item
, wxRect
& rect
, int code
) const
662 return m_genericImpl
->GetItemRect(item
, rect
, code
);
667 // Gets the item position
668 bool wxListCtrl::GetItemPosition(long item
, wxPoint
& pos
) const
671 return m_genericImpl
->GetItemPosition(item
, pos
);
673 bool success
= false;
678 // Sets the item position.
679 bool wxListCtrl::SetItemPosition(long item
, const wxPoint
& pos
)
682 return m_genericImpl
->SetItemPosition(item
, pos
);
687 // Gets the number of items in the list control
688 int wxListCtrl::GetItemCount() const
691 return m_genericImpl
->GetItemCount();
694 return m_dbImpl
->MacGetCount();
699 void wxListCtrl::SetItemSpacing( int spacing
, bool isSmall
)
702 m_genericImpl
->SetItemSpacing(spacing
, isSmall
);
705 wxSize
wxListCtrl::GetItemSpacing() const
708 return m_genericImpl
->GetItemSpacing();
713 void wxListCtrl::SetItemTextColour( long item
, const wxColour
&col
)
717 m_genericImpl
->SetItemTextColour(item
, col
);
722 info
.m_itemId
= item
;
723 info
.SetTextColour( col
);
727 wxColour
wxListCtrl::GetItemTextColour( long item
) const
730 return m_genericImpl
->GetItemTextColour(item
);
736 return info
.GetTextColour();
741 void wxListCtrl::SetItemBackgroundColour( long item
, const wxColour
&col
)
745 m_genericImpl
->SetItemBackgroundColour(item
, col
);
750 info
.m_itemId
= item
;
751 info
.SetBackgroundColour( col
);
755 wxColour
wxListCtrl::GetItemBackgroundColour( long item
) const
758 return m_genericImpl
->GetItemBackgroundColour(item
);
764 return info
.GetBackgroundColour();
769 void wxListCtrl::SetItemFont( long item
, const wxFont
&f
)
773 m_genericImpl
->SetItemFont(item
, f
);
778 info
.m_itemId
= item
;
783 wxFont
wxListCtrl::GetItemFont( long item
) const
786 return m_genericImpl
->GetItemFont(item
);
792 return info
.GetFont();
798 // Gets the number of selected items in the list control
799 int wxListCtrl::GetSelectedItemCount() const
802 return m_genericImpl
->GetSelectedItemCount();
805 return m_dbImpl
->GetSelectedItemCount(NULL
, true);
810 // Gets the text colour of the listview
811 wxColour
wxListCtrl::GetTextColour() const
814 return m_genericImpl
->GetTextColour();
816 // TODO: we need owner drawn list items to customize text color.
823 // Sets the text colour of the listview
824 void wxListCtrl::SetTextColour(const wxColour
& col
)
828 m_genericImpl
->SetTextColour(col
);
832 // TODO: if we add owner-drawn item support for DataBrowser,
833 // consider supporting this property
836 // Gets the index of the topmost visible item when in
837 // list or report view
838 long wxListCtrl::GetTopItem() const
841 return m_genericImpl
->GetTopItem();
846 // Searches for an item, starting from 'item'.
847 // 'geometry' is one of
848 // wxLIST_NEXT_ABOVE/ALL/BELOW/LEFT/RIGHT.
849 // 'state' is a state bit flag, one or more of
850 // wxLIST_STATE_DROPHILITED/FOCUSED/SELECTED/CUT.
851 // item can be -1 to find the first item that matches the
853 // Returns the item or -1 if unsuccessful.
854 long wxListCtrl::GetNextItem(long item
, int geom
, int state
) const
857 return m_genericImpl
->GetNextItem(item
, geom
, state
);
863 wxImageList
*wxListCtrl::GetImageList(int which
) const
866 return m_genericImpl
->GetImageList(which
);
868 if ( which
== wxIMAGE_LIST_NORMAL
)
870 return m_imageListNormal
;
872 else if ( which
== wxIMAGE_LIST_SMALL
)
874 return m_imageListSmall
;
876 else if ( which
== wxIMAGE_LIST_STATE
)
878 return m_imageListState
;
883 void wxListCtrl::SetImageList(wxImageList
*imageList
, int which
)
887 m_genericImpl
->SetImageList(imageList
, which
);
891 if ( which
== wxIMAGE_LIST_NORMAL
)
893 if (m_ownsImageListNormal
) delete m_imageListNormal
;
894 m_imageListNormal
= imageList
;
895 m_ownsImageListNormal
= false;
897 else if ( which
== wxIMAGE_LIST_SMALL
)
899 if (m_ownsImageListSmall
) delete m_imageListSmall
;
900 m_imageListSmall
= imageList
;
901 m_ownsImageListSmall
= false;
903 else if ( which
== wxIMAGE_LIST_STATE
)
905 if (m_ownsImageListState
) delete m_imageListState
;
906 m_imageListState
= imageList
;
907 m_ownsImageListState
= false;
911 void wxListCtrl::AssignImageList(wxImageList
*imageList
, int which
)
915 m_genericImpl
->AssignImageList(imageList
, which
);
919 SetImageList(imageList
, which
);
920 if ( which
== wxIMAGE_LIST_NORMAL
)
921 m_ownsImageListNormal
= true;
922 else if ( which
== wxIMAGE_LIST_SMALL
)
923 m_ownsImageListSmall
= true;
924 else if ( which
== wxIMAGE_LIST_STATE
)
925 m_ownsImageListState
= true;
928 // ----------------------------------------------------------------------------
930 // ----------------------------------------------------------------------------
932 // Arranges the items
933 bool wxListCtrl::Arrange(int flag
)
936 return m_genericImpl
->Arrange(flag
);
941 bool wxListCtrl::DeleteItem(long item
)
944 return m_genericImpl
->DeleteItem(item
);
948 m_dbImpl
->MacDelete(item
);
949 wxListEvent
event( wxEVT_COMMAND_LIST_DELETE_ITEM
, GetId() );
950 event
.SetEventObject( this );
951 event
.m_itemIndex
= item
;
952 GetEventHandler()->ProcessEvent( event
);
959 bool wxListCtrl::DeleteAllItems()
962 return m_genericImpl
->DeleteAllItems();
966 m_dbImpl
->MacClear();
967 wxListEvent
event( wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS
, GetId() );
968 event
.SetEventObject( this );
969 GetEventHandler()->ProcessEvent( event
);
975 bool wxListCtrl::DeleteAllColumns()
978 return m_genericImpl
->DeleteAllColumns();
983 m_dbImpl
->GetColumnCount(&cols
);
984 for (UInt32 col
= 0; col
< cols
; col
++)
994 bool wxListCtrl::DeleteColumn(int col
)
997 return m_genericImpl
->DeleteColumn(col
);
1001 OSStatus err
= m_dbImpl
->RemoveColumn(col
);
1002 return err
== noErr
;
1008 // Clears items, and columns if there are any.
1009 void wxListCtrl::ClearAll()
1013 m_genericImpl
->ClearAll();
1024 wxTextCtrl
* wxListCtrl::EditLabel(long item
, wxClassInfo
* textControlClass
)
1027 return m_genericImpl
->EditLabel(item
, textControlClass
);
1031 wxMacDataItem
* id
= m_dbImpl
->GetItemFromLine(item
);
1032 verify_noerr( SetDataBrowserEditItem(m_dbImpl
->GetControlRef(), (DataBrowserItemID
)id
, kMinColumnId
) );
1037 // End label editing, optionally cancelling the edit
1038 bool wxListCtrl::EndEditLabel(bool cancel
)
1040 // TODO: generic impl. doesn't have this method - is it needed for us?
1042 return true; // m_genericImpl->EndEditLabel(cancel);
1045 verify_noerr( SetDataBrowserEditItem(m_dbImpl
->GetControlRef(), kDataBrowserNoItem
, kMinColumnId
) );
1049 // Ensures this item is visible
1050 bool wxListCtrl::EnsureVisible(long item
)
1053 return m_genericImpl
->EnsureVisible(item
);
1057 wxMacDataItem
* dataItem
= m_dbImpl
->GetItemFromLine(item
);
1058 m_dbImpl
->RevealItem(dataItem
, kDataBrowserRevealWithoutSelecting
);
1064 // Find an item whose label matches this string, starting from the item after 'start'
1065 // or the beginning if 'start' is -1.
1066 long wxListCtrl::FindItem(long start
, const wxString
& str
, bool partial
)
1069 return m_genericImpl
->FindItem(start
, str
, partial
);
1074 // Find an item whose data matches this data, starting from the item after 'start'
1075 // or the beginning if 'start' is -1.
1076 long wxListCtrl::FindItem(long start
, long data
)
1079 return m_genericImpl
->FindItem(start
, data
);
1081 long idx
= start
+ 1;
1082 long count
= GetItemCount();
1086 if (GetItemData(idx
) == data
)
1094 // Find an item nearest this position in the specified direction, starting from
1095 // the item after 'start' or the beginning if 'start' is -1.
1096 long wxListCtrl::FindItem(long start
, const wxPoint
& pt
, int direction
)
1099 return m_genericImpl
->FindItem(start
, pt
, direction
);
1103 // Determines which item (if any) is at the specified point,
1104 // giving details in 'flags' (see wxLIST_HITTEST_... flags above)
1106 wxListCtrl::HitTest(const wxPoint
& point
, int& flags
, long *ptrSubItem
) const
1109 return m_genericImpl
->HitTest(point
, flags
, ptrSubItem
);
1115 // Inserts an item, returning the index of the new item if successful,
1117 long wxListCtrl::InsertItem(wxListItem
& info
)
1119 wxASSERT_MSG( !IsVirtual(), _T("can't be used with virtual controls") );
1122 return m_genericImpl
->InsertItem(info
);
1126 int count
= GetItemCount();
1128 if (info
.m_itemId
> count
)
1129 info
.m_itemId
= count
;
1131 m_dbImpl
->MacInsertItem(info
.m_itemId
, &info
);
1132 wxListEvent
event( wxEVT_COMMAND_LIST_INSERT_ITEM
, GetId() );
1133 event
.SetEventObject( this );
1134 event
.m_itemIndex
= info
.m_itemId
;
1135 GetEventHandler()->ProcessEvent( event
);
1138 return info
.m_itemId
;
1141 long wxListCtrl::InsertItem(long index
, const wxString
& label
)
1144 return m_genericImpl
->InsertItem(index
, label
);
1147 info
.m_text
= label
;
1148 info
.m_mask
= wxLIST_MASK_TEXT
;
1149 info
.m_itemId
= index
;
1150 return InsertItem(info
);
1153 // Inserts an image item
1154 long wxListCtrl::InsertItem(long index
, int imageIndex
)
1157 return m_genericImpl
->InsertItem(index
, imageIndex
);
1160 info
.m_image
= imageIndex
;
1161 info
.m_mask
= wxLIST_MASK_IMAGE
;
1162 info
.m_itemId
= index
;
1163 return InsertItem(info
);
1166 // Inserts an image/string item
1167 long wxListCtrl::InsertItem(long index
, const wxString
& label
, int imageIndex
)
1170 return m_genericImpl
->InsertItem(index
, label
, imageIndex
);
1173 info
.m_image
= imageIndex
;
1174 info
.m_text
= label
;
1175 info
.m_mask
= wxLIST_MASK_IMAGE
| wxLIST_MASK_TEXT
;
1176 info
.m_itemId
= index
;
1177 return InsertItem(info
);
1180 // For list view mode (only), inserts a column.
1181 long wxListCtrl::InsertColumn(long col
, wxListItem
& item
)
1184 return m_genericImpl
->InsertColumn(col
, item
);
1188 if ( !(item
.GetMask() & wxLIST_MASK_WIDTH
) )
1191 DataBrowserPropertyType type
= kDataBrowserTextType
;
1192 wxImageList
* imageList
= GetImageList(wxIMAGE_LIST_SMALL
);
1193 if (imageList
&& imageList
->GetImageCount() > 0)
1195 wxBitmap bmp
= imageList
->GetBitmap(0);
1197 type
= kDataBrowserIconAndTextType
;
1200 SInt16 just
= teFlushDefault
;
1201 if (item
.GetMask() & wxLIST_MASK_FORMAT
)
1203 if (item
.GetAlign() == wxLIST_FORMAT_LEFT
)
1205 else if (item
.GetAlign() == wxLIST_FORMAT_CENTER
)
1207 else if (item
.GetAlign() == wxLIST_FORMAT_RIGHT
)
1208 just
= teFlushRight
;
1210 m_dbImpl
->InsertColumn(col
, type
, item
.GetText(), just
, item
.GetWidth());
1212 if (GetWindowStyleFlag() & wxLC_EDIT_LABELS
)
1214 DataBrowserTableViewColumnID id
;
1215 m_dbImpl
->GetColumnIDFromIndex(col
, &id
);
1216 DataBrowserPropertyFlags flags
;
1217 verify_noerr(m_dbImpl
->GetPropertyFlags(id
, &flags
));
1218 flags
|= kDataBrowserPropertyIsEditable
;
1219 verify_noerr(m_dbImpl
->SetPropertyFlags(id
, flags
));
1226 long wxListCtrl::InsertColumn(long col
,
1227 const wxString
& heading
,
1232 return m_genericImpl
->InsertColumn(col
, heading
, format
, width
);
1235 item
.m_mask
= wxLIST_MASK_TEXT
| wxLIST_MASK_FORMAT
;
1236 item
.m_text
= heading
;
1239 item
.m_mask
|= wxLIST_MASK_WIDTH
;
1240 item
.m_width
= width
;
1242 item
.m_format
= format
;
1244 return InsertColumn(col
, item
);
1247 // scroll the control by the given number of pixels (exception: in list view,
1248 // dx is interpreted as number of columns)
1249 bool wxListCtrl::ScrollList(int dx
, int dy
)
1252 return m_genericImpl
->ScrollList(dx
, dy
);
1256 m_dbImpl
->SetScrollPosition(dx
, dy
);
1262 bool wxListCtrl::SortItems(wxListCtrlCompare fn
, long data
)
1265 return m_genericImpl
->SortItems(fn
, data
);
1270 // ----------------------------------------------------------------------------
1271 // virtual list controls
1272 // ----------------------------------------------------------------------------
1274 wxString
wxListCtrl::OnGetItemText(long WXUNUSED(item
), long WXUNUSED(col
)) const
1276 // this is a pure virtual function, in fact - which is not really pure
1277 // because the controls which are not virtual don't need to implement it
1278 wxFAIL_MSG( _T("wxListCtrl::OnGetItemText not supposed to be called") );
1280 return wxEmptyString
;
1283 int wxListCtrl::OnGetItemImage(long WXUNUSED(item
)) const
1285 wxCHECK_MSG(!GetImageList(wxIMAGE_LIST_SMALL
),
1287 wxT("List control has an image list, OnGetItemImage or OnGetItemColumnImage should be overridden."));
1291 int wxListCtrl::OnGetItemColumnImage(long item
, long column
) const
1294 return OnGetItemImage(item
);
1299 wxListItemAttr
*wxListCtrl::OnGetItemAttr(long WXUNUSED_UNLESS_DEBUG(item
)) const
1301 wxASSERT_MSG( item
>= 0 && item
< GetItemCount(),
1302 _T("invalid item index in OnGetItemAttr()") );
1304 // no attributes by default
1308 void wxListCtrl::SetItemCount(long count
)
1310 wxASSERT_MSG( IsVirtual(), _T("this is for virtual controls only") );
1314 m_genericImpl
->SetItemCount(count
);
1320 // we need to temporarily disable the new item creation notification
1321 // procedure to speed things up
1322 // FIXME: Even this doesn't seem to help much...
1323 DataBrowserCallbacks callbacks
;
1324 DataBrowserItemNotificationUPP itemUPP
;
1325 GetDataBrowserCallbacks(m_dbImpl
->GetControlRef(), &callbacks
);
1326 itemUPP
= callbacks
.u
.v1
.itemNotificationCallback
;
1327 callbacks
.u
.v1
.itemNotificationCallback
= 0;
1328 m_dbImpl
->SetCallbacks(&callbacks
);
1329 ::AddDataBrowserItems(m_dbImpl
->GetControlRef(), kDataBrowserNoItem
,
1330 count
, NULL
, kDataBrowserItemNoProperty
);
1331 callbacks
.u
.v1
.itemNotificationCallback
= itemUPP
;
1332 m_dbImpl
->SetCallbacks(&callbacks
);
1337 void wxListCtrl::RefreshItem(long item
)
1341 m_genericImpl
->RefreshItem(item
);
1346 GetItemRect(item
, rect
);
1350 void wxListCtrl::RefreshItems(long itemFrom
, long itemTo
)
1354 m_genericImpl
->RefreshItems(itemFrom
, itemTo
);
1358 wxRect rect1
, rect2
;
1359 GetItemRect(itemFrom
, rect1
);
1360 GetItemRect(itemTo
, rect2
);
1362 wxRect rect
= rect1
;
1363 rect
.height
= rect2
.GetBottom() - rect1
.GetTop();
1369 // wxMac internal data structures
1371 wxMacListCtrlItem::~wxMacListCtrlItem()
1375 void wxMacListCtrlItem::Notification(wxMacDataItemBrowserControl
*owner
,
1376 DataBrowserItemNotification message
,
1377 DataBrowserItemDataRef itemData
) const
1380 wxMacDataBrowserListCtrlControl
*lb
= dynamic_cast<wxMacDataBrowserListCtrlControl
*>(owner
);
1382 // we want to depend on as little as possible to make sure tear-down of controls is safe
1383 if ( message
== kDataBrowserItemRemoved
)
1385 if ( lb
!= NULL
&& lb
->GetClientDataType() == wxClientData_Object
)
1387 delete (wxClientData
*) (m_data
);
1393 else if ( message
== kDataBrowserItemAdded
)
1395 // we don't issue events on adding, the item is not really stored in the list yet, so we
1396 // avoid asserts by gettting out now
1400 wxListCtrl
*list
= wxDynamicCast( owner
->GetPeer() , wxListCtrl
);
1403 bool trigger
= false;
1405 wxListEvent
event( wxEVT_COMMAND_LIST_ITEM_SELECTED
, list
->GetId() );
1406 bool isSingle
= list
->GetWindowStyle() | wxLC_SINGLE_SEL
;
1408 event
.SetEventObject( list
);
1409 event
.m_itemIndex
= owner
->GetLineFromItem( this ) ;
1410 if ( !list
->IsVirtual() )
1412 lb
->MacGetColumnInfo(event
.m_itemIndex
,0,event
.m_item
);
1417 case kDataBrowserItemDeselected
:
1418 event
.SetEventType(wxEVT_COMMAND_LIST_ITEM_DESELECTED
);
1420 trigger
= !lb
->IsSelectionSuppressed();
1423 case kDataBrowserItemSelected
:
1424 trigger
= !lb
->IsSelectionSuppressed();
1427 case kDataBrowserItemDoubleClicked
:
1428 event
.SetEventType( wxEVT_LEFT_DCLICK
);
1432 case kDataBrowserEditStarted
:
1433 // TODO : how to veto ?
1434 event
.SetEventType( wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
) ;
1438 case kDataBrowserEditStopped
:
1439 // TODO probably trigger only upon the value store callback, because
1440 // here IIRC we cannot veto
1441 event
.SetEventType( wxEVT_COMMAND_LIST_END_LABEL_EDIT
) ;
1451 // direct notification is not always having the listbox GetSelection() having in synch with event
1452 wxPostEvent( list
->GetEventHandler(), event
);
1458 wxMacDataBrowserListCtrlControl::wxMacDataBrowserListCtrlControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
)
1459 : wxMacDataItemBrowserControl( peer
, pos
, size
, style
)
1461 OSStatus err
= noErr
;
1462 m_clientDataItemsType
= wxClientData_None
;
1463 m_isVirtual
= false;
1465 if ( style
& wxLC_VIRTUAL
)
1468 DataBrowserSelectionFlags options
= kDataBrowserDragSelect
;
1469 if ( style
& wxLC_SINGLE_SEL
)
1471 options
|= kDataBrowserSelectOnlyOne
;
1475 options
|= kDataBrowserCmdTogglesSelection
;
1478 err
= SetSelectionFlags( options
);
1479 verify_noerr( err
);
1481 if ( style
& wxLC_LIST
)
1483 InsertColumn(0, kDataBrowserIconAndTextType
, wxEmptyString
, -1, -1);
1484 verify_noerr( AutoSizeColumns() );
1487 if ( style
& wxLC_LIST
|| style
& wxLC_NO_HEADER
)
1488 verify_noerr( SetHeaderButtonHeight( 0 ) );
1490 SetSortProperty( kMinColumnId
);
1491 if ( style
& wxLC_SORT_ASCENDING
)
1493 m_sortOrder
= SortOrder_Text_Ascending
;
1494 SetSortOrder( kDataBrowserOrderIncreasing
);
1496 else if ( style
& wxLC_SORT_DESCENDING
)
1498 m_sortOrder
= SortOrder_Text_Descending
;
1499 SetSortOrder( kDataBrowserOrderDecreasing
);
1503 m_sortOrder
= SortOrder_None
;
1506 if ( style
& wxLC_VRULES
)
1508 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
1509 verify_noerr( DataBrowserChangeAttributes(m_controlRef
, kDataBrowserAttributeListViewDrawColumnDividers
, kDataBrowserAttributeNone
) );
1513 verify_noerr( SetHiliteStyle(kDataBrowserTableViewFillHilite
) );
1514 err
= SetHasScrollBars( (style
& wxHSCROLL
) != 0 , true );
1517 OSStatus
wxMacDataBrowserListCtrlControl::GetSetItemData(DataBrowserItemID itemID
,
1518 DataBrowserPropertyID property
,
1519 DataBrowserItemDataRef itemData
,
1520 Boolean changeValue
)
1524 short listColumn
= property
- kMinColumnId
;
1526 OSStatus err
= errDataBrowserPropertyNotSupported
;
1527 wxListCtrl
* list
= wxDynamicCast( GetPeer() , wxListCtrl
);
1529 if (listColumn
>= 0)
1533 wxMacListCtrlItem
* lcItem
= (wxMacListCtrlItem
*) itemID
;
1534 if (lcItem
->HasColumnInfo(listColumn
)){
1535 wxListItem
* item
= lcItem
->GetColumnInfo(listColumn
);
1536 if (item
->GetMask() & wxLIST_MASK_TEXT
)
1537 text
= item
->GetText();
1538 if (item
->GetMask() & wxLIST_MASK_IMAGE
)
1539 imgIndex
= item
->GetImage();
1544 text
= list
->OnGetItemText( (long)itemID
-1, listColumn
);
1545 imgIndex
= list
->OnGetItemColumnImage( (long)itemID
-1, listColumn
);
1553 case kDataBrowserItemIsEditableProperty
:
1554 if ( list
&& list
->HasFlag( wxLC_EDIT_LABELS
) )
1556 verify_noerr(SetDataBrowserItemDataBooleanValue( itemData
, true ));
1561 if ( property
>= kMinColumnId
)
1563 wxMacCFStringHolder cfStr
;
1566 cfStr
.Assign( text
, wxLocale::GetSystemEncoding() );
1567 err
= ::SetDataBrowserItemDataText( itemData
, cfStr
);
1573 if ( imgIndex
!= -1 )
1575 wxImageList
* imageList
= list
->GetImageList(wxIMAGE_LIST_SMALL
);
1576 if (imageList
&& imageList
->GetImageCount() > 0){
1577 wxBitmap bmp
= imageList
->GetBitmap(imgIndex
);
1578 IconRef icon
= bmp
.GetBitmapData()->GetIconRef();
1579 ::SetDataBrowserItemDataIcon(itemData
, icon
);
1593 if ( property
>= kMinColumnId
)
1595 short listColumn
= property
- kMinColumnId
;
1597 // TODO probably send the 'end edit' from here, as we
1598 // can then deal with the veto
1600 verify_noerr( GetDataBrowserItemDataText( itemData
, &sr
) ) ;
1601 wxMacCFStringHolder
cfStr(sr
) ;;
1602 list
->SetItem( (long)itemData
, listColumn
, cfStr
.AsString() ) ;
1611 void wxMacDataBrowserListCtrlControl::ItemNotification(DataBrowserItemID itemID
,
1612 DataBrowserItemNotification message
,
1613 DataBrowserItemDataRef itemData
)
1615 // we want to depend on as little as possible to make sure tear-down of controls is safe
1616 if ( message
== kDataBrowserItemRemoved
)
1618 // make sure MacDelete does the proper teardown.
1621 else if ( message
== kDataBrowserItemAdded
)
1623 // we don't issue events on adding, the item is not really stored in the list yet, so we
1624 // avoid asserts by gettting out now
1628 wxListCtrl
*list
= wxDynamicCast( GetPeer() , wxListCtrl
);
1631 bool trigger
= false;
1633 wxListEvent
event( wxEVT_COMMAND_LIST_ITEM_SELECTED
, list
->GetId() );
1634 bool isSingle
= list
->GetWindowStyle() | wxLC_SINGLE_SEL
;
1636 event
.SetEventObject( list
);
1637 if ( !list
->IsVirtual() )
1639 wxMacDataItem
* item
= (wxMacDataItem
*)itemID
;
1640 DataBrowserTableViewRowIndex result
= 0;
1641 verify_noerr( GetItemRow( itemID
, &result
) ) ;
1642 event
.m_itemIndex
= result
;
1644 if (event
.m_itemIndex
>= 0)
1645 MacGetColumnInfo(event
.m_itemIndex
,0,event
.m_item
);
1649 event
.m_itemIndex
= (long)itemID
;
1654 case kDataBrowserItemDeselected
:
1655 event
.SetEventType(wxEVT_COMMAND_LIST_ITEM_DESELECTED
);
1657 trigger
= IsSelectionSuppressed();
1660 case kDataBrowserItemSelected
:
1661 trigger
= IsSelectionSuppressed();
1664 case kDataBrowserItemDoubleClicked
:
1665 event
.SetEventType( wxEVT_LEFT_DCLICK
);
1669 case kDataBrowserEditStarted
:
1670 // TODO : how to veto ?
1671 event
.SetEventType( wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
) ;
1675 case kDataBrowserEditStopped
:
1676 // TODO probably trigger only upon the value store callback, because
1677 // here IIRC we cannot veto
1678 event
.SetEventType( wxEVT_COMMAND_LIST_END_LABEL_EDIT
) ;
1688 // direct notification is not always having the listbox GetSelection() having in synch with event
1689 wxPostEvent( list
->GetEventHandler(), event
);
1694 Boolean
wxMacDataBrowserListCtrlControl::CompareItems(DataBrowserItemID itemOneID
,
1695 DataBrowserItemID itemTwoID
,
1696 DataBrowserPropertyID sortProperty
)
1699 bool retval
= false;
1701 wxString otherItemText
;
1702 int colId
= sortProperty
- kMinColumnId
;
1704 long otherItemNum
= 0;
1706 wxListCtrl
* list
= wxDynamicCast( GetPeer() , wxListCtrl
);
1713 wxMacListCtrlItem
* item
= (wxMacListCtrlItem
*)itemOneID
;
1714 wxMacListCtrlItem
* otherItem
= (wxMacListCtrlItem
*)itemTwoID
;
1715 itemNum
= item
->GetOrder();
1716 otherItemNum
= otherItem
->GetOrder();
1717 if (item
->HasColumnInfo(colId
))
1718 itemText
= item
->GetColumnInfo(colId
)->GetText();
1719 if (otherItem
->HasColumnInfo(colId
))
1720 otherItemText
= otherItem
->GetColumnInfo(colId
)->GetText();
1724 itemNum
= (long)itemOneID
;
1725 otherItemNum
= (long)itemTwoID
;
1726 itemText
= list
->OnGetItemText( itemNum
-1, colId
);
1727 otherItemText
= list
->OnGetItemText( otherItemNum
-1, colId
);
1731 DataBrowserSortOrder sort
;
1732 verify_noerr(GetSortOrder(&sort
));
1734 if ( sort
== kDataBrowserOrderIncreasing
)
1736 retval
= itemText
.CmpNoCase( otherItemText
) > 0;
1738 else if ( sort
== kDataBrowserOrderDecreasing
)
1740 retval
= itemText
.CmpNoCase( otherItemText
) < 0;
1744 // fallback for undefined cases
1745 retval
= itemOneID
< itemTwoID
;
1751 wxMacDataBrowserListCtrlControl::~wxMacDataBrowserListCtrlControl()
1755 void wxMacDataBrowserListCtrlControl::MacSetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
* item
)
1757 wxMacDataItem
* dataItem
= GetItemFromLine(row
);
1760 wxMacListCtrlItem
* listItem
= dynamic_cast<wxMacListCtrlItem
*>(dataItem
);
1761 listItem
->SetColumnInfo( column
, item
);
1762 UpdateState(dataItem
, item
);
1766 // apply changes that need to happen immediately, rather than when the
1767 // databrowser control fires a callback.
1768 void wxMacDataBrowserListCtrlControl::UpdateState(wxMacDataItem
* dataItem
, wxListItem
* listItem
)
1770 bool isSelected
= IsItemSelected( dataItem
);
1771 bool isSelectedState
= (listItem
->GetState() == wxLIST_STATE_SELECTED
);
1773 // toggle the selection state if wxListInfo state and actual state don't match.
1774 if ( isSelected
!= isSelectedState
)
1776 DataBrowserSetOption options
= kDataBrowserItemsAdd
;
1777 if (!isSelectedState
)
1778 options
= kDataBrowserItemsRemove
;
1779 SetSelectedItem(dataItem
, options
);
1781 // TODO: Set column width if item width > than current column width
1784 void wxMacDataBrowserListCtrlControl::MacGetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
& item
)
1786 wxMacDataItem
* dataItem
= GetItemFromLine(row
);
1787 // CS should this guard against dataItem = 0 ? , as item is not a pointer if (item) is not appropriate
1790 wxMacListCtrlItem
* listItem
= dynamic_cast<wxMacListCtrlItem
*>(dataItem
);
1791 wxListItem
* oldItem
= listItem
->GetColumnInfo( column
);
1793 long mask
= item
.GetMask();
1795 // by default, get everything for backwards compatibility
1798 if ( mask
& wxLIST_MASK_TEXT
)
1799 item
.SetText(oldItem
->GetText());
1800 if ( mask
& wxLIST_MASK_IMAGE
)
1801 item
.SetImage(oldItem
->GetImage());
1802 if ( mask
& wxLIST_MASK_DATA
)
1803 item
.SetData(oldItem
->GetData());
1804 if ( mask
& wxLIST_MASK_STATE
)
1805 item
.SetState(oldItem
->GetState());
1806 if ( mask
& wxLIST_MASK_WIDTH
)
1807 item
.SetWidth(oldItem
->GetWidth());
1808 if ( mask
& wxLIST_MASK_FORMAT
)
1809 item
.SetAlign(oldItem
->GetAlign());
1811 item
.SetTextColour(oldItem
->GetTextColour());
1812 item
.SetBackgroundColour(oldItem
->GetBackgroundColour());
1813 item
.SetFont(oldItem
->GetFont());
1817 void wxMacDataBrowserListCtrlControl::MacInsertItem( unsigned int n
, wxListItem
* item
)
1819 wxMacDataItemBrowserControl::MacInsert(n
, item
->GetText());
1820 MacSetColumnInfo(n
, 0, item
);
1823 wxMacListCtrlItem
* wxMacDataBrowserListCtrlControl::CreateItem()
1825 return new wxMacListCtrlItem();
1828 wxMacListCtrlItem::wxMacListCtrlItem()
1830 m_rowItems
= wxListItemList();
1833 int wxMacListCtrlItem::GetColumnImageValue( unsigned int column
)
1835 return GetColumnInfo(column
)->GetImage();
1838 void wxMacListCtrlItem::SetColumnImageValue( unsigned int column
, int imageIndex
)
1840 GetColumnInfo(column
)->SetImage(imageIndex
);
1843 const wxString
& wxMacListCtrlItem::GetColumnTextValue( unsigned int column
)
1848 return GetColumnInfo(column
)->GetText();
1851 void wxMacListCtrlItem::SetColumnTextValue( unsigned int column
, const wxString
& text
)
1853 GetColumnInfo(column
)->SetText(text
);
1855 // for compatibility with superclass APIs
1860 wxListItem
* wxMacListCtrlItem::GetColumnInfo( unsigned int column
)
1862 wxListItemList::compatibility_iterator node
= m_rowItems
.Item( column
);
1863 wxASSERT_MSG( node
, _T("invalid column index in wxMacListCtrlItem") );
1865 return node
->GetData();
1868 bool wxMacListCtrlItem::HasColumnInfo( unsigned int column
)
1870 return m_rowItems
.GetCount() > column
;
1873 void wxMacListCtrlItem::SetColumnInfo( unsigned int column
, wxListItem
* item
)
1876 if ( column
>= m_rowItems
.GetCount() )
1878 wxListItem
* listItem
= new wxListItem(*item
);
1879 m_rowItems
.Append( listItem
);
1883 wxListItem
* listItem
= GetColumnInfo( column
);
1884 long mask
= item
->GetMask();
1885 if (mask
& wxLIST_MASK_TEXT
)
1886 listItem
->SetText(item
->GetText());
1887 if (mask
& wxLIST_MASK_DATA
)
1888 listItem
->SetData(item
->GetData());
1889 if (mask
& wxLIST_MASK_IMAGE
)
1890 listItem
->SetImage(item
->GetImage());
1891 if (mask
& wxLIST_MASK_STATE
)
1892 listItem
->SetState(item
->GetState());
1893 if (mask
& wxLIST_MASK_FORMAT
)
1894 listItem
->SetAlign(item
->GetAlign());
1895 if (mask
& wxLIST_MASK_WIDTH
)
1896 listItem
->SetWidth(item
->GetWidth());
1900 #endif // wxUSE_LISTCTRL