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
)
119 class wxMacListCtrlItem
: public wxMacListBoxItem
124 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
125 DataBrowserItemNotification message
,
126 DataBrowserItemDataRef itemData
) const;
128 virtual void SetColumnInfo( unsigned int column
, wxListItem
* item
);
129 virtual wxListItem
* GetColumnInfo( unsigned int column
);
130 virtual bool HasColumnInfo( unsigned int column
);
132 virtual void SetColumnTextValue( unsigned int column
, const wxString
& text
);
133 virtual const wxString
& GetColumnTextValue( unsigned int column
);
135 virtual int GetColumnImageValue( unsigned int column
);
136 virtual void SetColumnImageValue( unsigned int column
, int imageIndex
);
138 virtual ~wxMacListCtrlItem();
140 wxListItemList m_rowItems
;
143 // TODO: Make a better name!!
144 class wxMacDataBrowserListCtrlControl
: public wxMacDataItemBrowserControl
147 wxMacDataBrowserListCtrlControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
148 virtual ~wxMacDataBrowserListCtrlControl();
150 // create a list item (can be a subclass of wxMacListBoxItem)
152 virtual wxMacDataItem
* CreateItem();
154 virtual void MacInsertItem( unsigned int n
, wxListItem
* item
);
155 virtual void MacSetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
* item
);
156 virtual void MacGetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
& item
);
157 virtual void UpdateState(wxMacDataItem
* dataItem
, wxListItem
* item
);
160 // we need to override to provide specialized handling for virtual wxListCtrls
161 virtual OSStatus
GetSetItemData(DataBrowserItemID itemID
,
162 DataBrowserPropertyID property
,
163 DataBrowserItemDataRef itemData
,
164 Boolean changeValue
);
166 virtual void ItemNotification(
167 DataBrowserItemID itemID
,
168 DataBrowserItemNotification message
,
169 DataBrowserItemDataRef itemData
);
171 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
172 DataBrowserItemID itemTwoID
,
173 DataBrowserPropertyID sortProperty
);
175 wxClientDataType m_clientDataItemsType
;
180 // TODO: This gives errors, find out why.
181 //BEGIN_EVENT_TABLE(wxListCtrl, wxControl)
182 // EVT_PAINT(wxListCtrl::OnPaint)
185 // ============================================================================
187 // ============================================================================
189 wxMacListControl
* wxListCtrl::GetPeer() const
191 return dynamic_cast<wxMacListControl
*>(m_peer
);
194 // ----------------------------------------------------------------------------
195 // wxListCtrl construction
196 // ----------------------------------------------------------------------------
198 void wxListCtrl::Init()
200 m_imageListNormal
= NULL
;
201 m_imageListSmall
= NULL
;
202 m_imageListState
= NULL
;
204 // keep track of if we created our own image lists, or if they were assigned
206 m_ownsImageListNormal
= m_ownsImageListSmall
= m_ownsImageListState
= false;
210 m_genericImpl
= NULL
;
214 class wxGenericListCtrlHook
: public wxGenericListCtrl
217 wxGenericListCtrlHook(wxListCtrl
* parent
,
222 const wxValidator
& validator
,
223 const wxString
& name
)
224 : wxGenericListCtrl(parent
, id
, pos
, size
, style
, validator
, name
),
225 m_nativeListCtrl(parent
)
230 virtual wxListItemAttr
* OnGetItemAttr(long item
) const
232 return m_nativeListCtrl
->OnGetItemAttr(item
);
235 virtual int OnGetItemImage(long item
) const
237 return m_nativeListCtrl
->OnGetItemImage(item
);
240 virtual int OnGetItemColumnImage(long item
, long column
) const
242 return m_nativeListCtrl
->OnGetItemColumnImage(item
, column
);
245 virtual wxString
OnGetItemText(long item
, long column
) const
247 return m_nativeListCtrl
->OnGetItemText(item
, column
);
250 wxListCtrl
* m_nativeListCtrl
;
254 bool wxListCtrl::Create(wxWindow
*parent
,
259 const wxValidator
& validator
,
260 const wxString
& name
)
263 // for now, we'll always use the generic list control for ICON and LIST views,
264 // because they dynamically change the number of columns on resize.
265 // Also, allow the user to set it to use the list ctrl as well.
266 // Also, use generic list control in VIRTUAL mode.
267 if ( (wxSystemOptions::HasOption( wxMAC_ALWAYS_USE_GENERIC_LISTCTRL
)
268 && (wxSystemOptions::GetOptionInt( wxMAC_ALWAYS_USE_GENERIC_LISTCTRL
) == 1)) ||
269 (style
& wxLC_ICON
) || (style
& wxLC_SMALL_ICON
) || (style
& wxLC_LIST
) /* || (style & wxLC_VIRTUAL) */ )
271 m_macIsUserPane
= true;
273 if ( !wxWindow::Create(parent
, id
, pos
, size
, style
, name
) )
275 m_genericImpl
= new wxGenericListCtrlHook(this, id
, pos
, size
, style
, validator
, name
);
281 m_macIsUserPane
= false;
283 if ( !wxWindow::Create(parent
, id
, pos
, size
, style
, name
) )
285 m_dbImpl
= new wxMacDataBrowserListCtrlControl( this, pos
, size
, style
);
288 MacPostControlCreate( pos
, size
);
294 wxListCtrl::~wxListCtrl()
296 if (m_ownsImageListNormal
)
297 delete m_imageListNormal
;
298 if (m_ownsImageListSmall
)
299 delete m_imageListSmall
;
300 if (m_ownsImageListState
)
301 delete m_imageListState
;
304 // ----------------------------------------------------------------------------
305 // set/get/change style
306 // ----------------------------------------------------------------------------
308 // Add or remove a single window style
309 void wxListCtrl::SetSingleStyle(long style
, bool add
)
311 long flag
= GetWindowStyleFlag();
313 // Get rid of conflicting styles
316 if ( style
& wxLC_MASK_TYPE
)
317 flag
= flag
& ~wxLC_MASK_TYPE
;
318 if ( style
& wxLC_MASK_ALIGN
)
319 flag
= flag
& ~wxLC_MASK_ALIGN
;
320 if ( style
& wxLC_MASK_SORT
)
321 flag
= flag
& ~wxLC_MASK_SORT
;
329 SetWindowStyleFlag(flag
);
332 // Set the whole window style
333 void wxListCtrl::SetWindowStyleFlag(long flag
)
335 if ( flag
!= m_windowStyle
)
337 m_windowStyle
= flag
;
341 m_genericImpl
->SetWindowStyleFlag(flag
);
348 void wxListCtrl::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
350 wxControl::DoSetSize(x
, y
, width
, height
, sizeFlags
);
353 m_genericImpl
->SetSize(x
, y
, width
, height
, sizeFlags
);
356 // ----------------------------------------------------------------------------
358 // ----------------------------------------------------------------------------
360 // Gets information about this column
361 bool wxListCtrl::GetColumn(int col
, wxListItem
& item
) const
364 return m_genericImpl
->GetColumn(col
, item
);
368 if ( item
.m_mask
& wxLIST_MASK_TEXT
)
372 if ( item
.m_mask
& wxLIST_MASK_FORMAT
)
376 if ( item
.m_mask
& wxLIST_MASK_IMAGE
)
380 if ( (item
.m_mask
& wxLIST_MASK_TEXT
) )
388 // Sets information about this column
389 bool wxListCtrl::SetColumn(int col
, wxListItem
& item
)
392 return m_genericImpl
->SetColumn(col
, item
);
397 int wxListCtrl::GetColumnCount() const
400 return m_genericImpl
->GetColumnCount();
405 m_dbImpl
->GetColumnCount(&count
);
412 // Gets the column width
413 int wxListCtrl::GetColumnWidth(int col
) const
416 return m_genericImpl
->GetColumnWidth(col
);
420 return m_dbImpl
->GetColumnWidth(col
);
426 // Sets the column width
427 bool wxListCtrl::SetColumnWidth(int col
, int width
)
430 return m_genericImpl
->SetColumnWidth(col
, width
);
432 // TODO: This is setting the width of the first column
433 // to the entire window width; investigate why
439 if (width
== wxLIST_AUTOSIZE
|| width
== wxLIST_AUTOSIZE_USEHEADER
)
444 for (int column
= 0; column
< GetColumnCount(); column
++)
446 m_dbImpl
->SetColumnWidth(col
, mywidth
);
450 m_dbImpl
->SetColumnWidth(col
, mywidth
);
458 // Gets the number of items that can fit vertically in the
459 // visible area of the list control (list or report view)
460 // or the total number of items in the list control (icon
461 // or small icon view)
462 int wxListCtrl::GetCountPerPage() const
465 return m_genericImpl
->GetCountPerPage();
474 // Gets the edit control for editing labels.
475 wxTextCtrl
* wxListCtrl::GetEditControl() const
478 return m_genericImpl
->GetEditControl();
483 // Gets information about the item
484 bool wxListCtrl::GetItem(wxListItem
& info
) const
487 return m_genericImpl
->GetItem(info
);
490 m_dbImpl
->MacGetColumnInfo(info
.m_itemId
, info
.m_col
, info
);
495 // Sets information about the item
496 bool wxListCtrl::SetItem(wxListItem
& info
)
499 return m_genericImpl
->SetItem(info
);
502 m_dbImpl
->MacSetColumnInfo( info
.m_itemId
, info
.m_col
, &info
);
507 long wxListCtrl::SetItem(long index
, int col
, const wxString
& label
, int imageId
)
510 return m_genericImpl
->SetItem(index
, col
, label
, imageId
);
514 info
.m_mask
= wxLIST_MASK_TEXT
;
515 info
.m_itemId
= index
;
519 info
.m_image
= imageId
;
520 info
.m_mask
|= wxLIST_MASK_IMAGE
;
522 return SetItem(info
);
526 // Gets the item state
527 int wxListCtrl::GetItemState(long item
, long stateMask
) const
530 return m_genericImpl
->GetItemState(item
, stateMask
);
534 info
.m_mask
= wxLIST_MASK_STATE
;
535 info
.m_stateMask
= stateMask
;
536 info
.m_itemId
= item
;
544 // Sets the item state
545 bool wxListCtrl::SetItemState(long item
, long state
, long stateMask
)
548 return m_genericImpl
->SetItemState(item
, state
, stateMask
);
551 info
.m_mask
= wxLIST_MASK_STATE
;
552 info
.m_stateMask
= stateMask
;
553 info
.m_state
= state
;
554 info
.m_itemId
= item
;
555 return SetItem(info
);
558 // Sets the item image
559 bool wxListCtrl::SetItemImage(long item
, int image
, int WXUNUSED(selImage
))
561 return SetItemColumnImage(item
, 0, image
);
564 // Sets the item image
565 bool wxListCtrl::SetItemColumnImage(long item
, long column
, int image
)
568 return m_genericImpl
->SetItemColumnImage(item
, column
, image
);
572 info
.m_mask
= wxLIST_MASK_IMAGE
;
573 info
.m_image
= image
;
574 info
.m_itemId
= item
;
577 return SetItem(info
);
580 // Gets the item text
581 wxString
wxListCtrl::GetItemText(long item
) const
584 return m_genericImpl
->GetItemText(item
);
588 info
.m_mask
= wxLIST_MASK_TEXT
;
589 info
.m_itemId
= item
;
592 return wxEmptyString
;
596 // Sets the item text
597 void wxListCtrl::SetItemText(long item
, const wxString
& str
)
600 return m_genericImpl
->SetItemText(item
, str
);
604 info
.m_mask
= wxLIST_MASK_TEXT
;
605 info
.m_itemId
= item
;
611 // Gets the item data
612 long wxListCtrl::GetItemData(long item
) const
615 return m_genericImpl
->GetItemData(item
);
619 info
.m_mask
= wxLIST_MASK_DATA
;
620 info
.m_itemId
= item
;
627 // Sets the item data
628 bool wxListCtrl::SetItemData(long item
, long data
)
631 return m_genericImpl
->SetItemData(item
, data
);
635 info
.m_mask
= wxLIST_MASK_DATA
;
636 info
.m_itemId
= item
;
639 return SetItem(info
);
642 wxRect
wxListCtrl::GetViewRect() const
644 wxASSERT_MSG( !HasFlag(wxLC_REPORT
| wxLC_LIST
),
645 _T("wxListCtrl::GetViewRect() only works in icon mode") );
648 return m_genericImpl
->GetViewRect();
654 // Gets the item rectangle
655 bool wxListCtrl::GetItemRect(long item
, wxRect
& rect
, int code
) const
658 return m_genericImpl
->GetItemRect(item
, rect
, code
);
663 // Gets the item position
664 bool wxListCtrl::GetItemPosition(long item
, wxPoint
& pos
) const
667 return m_genericImpl
->GetItemPosition(item
, pos
);
669 bool success
= false;
674 // Sets the item position.
675 bool wxListCtrl::SetItemPosition(long item
, const wxPoint
& pos
)
678 return m_genericImpl
->SetItemPosition(item
, pos
);
683 // Gets the number of items in the list control
684 int wxListCtrl::GetItemCount() const
687 return m_genericImpl
->GetItemCount();
690 return m_dbImpl
->MacGetCount();
695 void wxListCtrl::SetItemSpacing( int spacing
, bool isSmall
)
698 m_genericImpl
->SetItemSpacing(spacing
, isSmall
);
701 wxSize
wxListCtrl::GetItemSpacing() const
704 return m_genericImpl
->GetItemSpacing();
709 void wxListCtrl::SetItemTextColour( long item
, const wxColour
&col
)
713 m_genericImpl
->SetItemTextColour(item
, col
);
718 info
.m_itemId
= item
;
719 info
.SetTextColour( col
);
723 wxColour
wxListCtrl::GetItemTextColour( long item
) const
726 return m_genericImpl
->GetItemTextColour(item
);
732 return info
.GetTextColour();
737 void wxListCtrl::SetItemBackgroundColour( long item
, const wxColour
&col
)
741 m_genericImpl
->SetItemBackgroundColour(item
, col
);
746 info
.m_itemId
= item
;
747 info
.SetBackgroundColour( col
);
751 wxColour
wxListCtrl::GetItemBackgroundColour( long item
) const
754 return m_genericImpl
->GetItemBackgroundColour(item
);
760 return info
.GetBackgroundColour();
765 void wxListCtrl::SetItemFont( long item
, const wxFont
&f
)
769 m_genericImpl
->SetItemFont(item
, f
);
774 info
.m_itemId
= item
;
779 wxFont
wxListCtrl::GetItemFont( long item
) const
782 return m_genericImpl
->GetItemFont(item
);
788 return info
.GetFont();
794 // Gets the number of selected items in the list control
795 int wxListCtrl::GetSelectedItemCount() const
798 return m_genericImpl
->GetSelectedItemCount();
801 return m_dbImpl
->GetSelectedItemCount(NULL
, true);
806 // Gets the text colour of the listview
807 wxColour
wxListCtrl::GetTextColour() const
810 return m_genericImpl
->GetTextColour();
812 // TODO: we need owner drawn list items to customize text color.
819 // Sets the text colour of the listview
820 void wxListCtrl::SetTextColour(const wxColour
& col
)
824 m_genericImpl
->SetTextColour(col
);
828 // TODO: if we add owner-drawn item support for DataBrowser,
829 // consider supporting this property
832 // Gets the index of the topmost visible item when in
833 // list or report view
834 long wxListCtrl::GetTopItem() const
837 return m_genericImpl
->GetTopItem();
842 // Searches for an item, starting from 'item'.
843 // 'geometry' is one of
844 // wxLIST_NEXT_ABOVE/ALL/BELOW/LEFT/RIGHT.
845 // 'state' is a state bit flag, one or more of
846 // wxLIST_STATE_DROPHILITED/FOCUSED/SELECTED/CUT.
847 // item can be -1 to find the first item that matches the
849 // Returns the item or -1 if unsuccessful.
850 long wxListCtrl::GetNextItem(long item
, int geom
, int state
) const
853 return m_genericImpl
->GetNextItem(item
, geom
, state
);
855 if (m_dbImpl
&& geom
== wxLIST_NEXT_ALL
&& state
== wxLIST_STATE_SELECTED
)
857 long count
= m_dbImpl
->MacGetCount() ;
858 for ( long line
= item
+ 1 ; line
< count
; line
++ )
860 wxMacDataItem
* id
= m_dbImpl
->GetItemFromLine(line
);
861 if ( m_dbImpl
->IsItemSelected(id
) )
871 wxImageList
*wxListCtrl::GetImageList(int which
) const
874 return m_genericImpl
->GetImageList(which
);
876 if ( which
== wxIMAGE_LIST_NORMAL
)
878 return m_imageListNormal
;
880 else if ( which
== wxIMAGE_LIST_SMALL
)
882 return m_imageListSmall
;
884 else if ( which
== wxIMAGE_LIST_STATE
)
886 return m_imageListState
;
891 void wxListCtrl::SetImageList(wxImageList
*imageList
, int which
)
895 m_genericImpl
->SetImageList(imageList
, which
);
899 if ( which
== wxIMAGE_LIST_NORMAL
)
901 if (m_ownsImageListNormal
) delete m_imageListNormal
;
902 m_imageListNormal
= imageList
;
903 m_ownsImageListNormal
= false;
905 else if ( which
== wxIMAGE_LIST_SMALL
)
907 if (m_ownsImageListSmall
) delete m_imageListSmall
;
908 m_imageListSmall
= imageList
;
909 m_ownsImageListSmall
= false;
911 else if ( which
== wxIMAGE_LIST_STATE
)
913 if (m_ownsImageListState
) delete m_imageListState
;
914 m_imageListState
= imageList
;
915 m_ownsImageListState
= false;
919 void wxListCtrl::AssignImageList(wxImageList
*imageList
, int which
)
923 m_genericImpl
->AssignImageList(imageList
, which
);
927 SetImageList(imageList
, which
);
928 if ( which
== wxIMAGE_LIST_NORMAL
)
929 m_ownsImageListNormal
= true;
930 else if ( which
== wxIMAGE_LIST_SMALL
)
931 m_ownsImageListSmall
= true;
932 else if ( which
== wxIMAGE_LIST_STATE
)
933 m_ownsImageListState
= true;
936 // ----------------------------------------------------------------------------
938 // ----------------------------------------------------------------------------
940 // Arranges the items
941 bool wxListCtrl::Arrange(int flag
)
944 return m_genericImpl
->Arrange(flag
);
949 bool wxListCtrl::DeleteItem(long item
)
952 return m_genericImpl
->DeleteItem(item
);
956 m_dbImpl
->MacDelete(item
);
957 wxListEvent
event( wxEVT_COMMAND_LIST_DELETE_ITEM
, GetId() );
958 event
.SetEventObject( this );
959 event
.m_itemIndex
= item
;
960 GetEventHandler()->ProcessEvent( event
);
967 bool wxListCtrl::DeleteAllItems()
970 return m_genericImpl
->DeleteAllItems();
974 m_dbImpl
->MacClear();
975 wxListEvent
event( wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS
, GetId() );
976 event
.SetEventObject( this );
977 GetEventHandler()->ProcessEvent( event
);
983 bool wxListCtrl::DeleteAllColumns()
986 return m_genericImpl
->DeleteAllColumns();
991 m_dbImpl
->GetColumnCount(&cols
);
992 for (UInt32 col
= 0; col
< cols
; col
++)
1002 bool wxListCtrl::DeleteColumn(int col
)
1005 return m_genericImpl
->DeleteColumn(col
);
1009 OSStatus err
= m_dbImpl
->RemoveColumn(col
);
1010 return err
== noErr
;
1016 // Clears items, and columns if there are any.
1017 void wxListCtrl::ClearAll()
1021 m_genericImpl
->ClearAll();
1032 wxTextCtrl
* wxListCtrl::EditLabel(long item
, wxClassInfo
* textControlClass
)
1035 return m_genericImpl
->EditLabel(item
, textControlClass
);
1039 wxMacDataItem
* id
= m_dbImpl
->GetItemFromLine(item
);
1040 verify_noerr( SetDataBrowserEditItem(m_dbImpl
->GetControlRef(), (DataBrowserItemID
)id
, kMinColumnId
) );
1045 // End label editing, optionally cancelling the edit
1046 bool wxListCtrl::EndEditLabel(bool cancel
)
1048 // TODO: generic impl. doesn't have this method - is it needed for us?
1050 return true; // m_genericImpl->EndEditLabel(cancel);
1053 verify_noerr( SetDataBrowserEditItem(m_dbImpl
->GetControlRef(), kDataBrowserNoItem
, kMinColumnId
) );
1057 // Ensures this item is visible
1058 bool wxListCtrl::EnsureVisible(long item
)
1061 return m_genericImpl
->EnsureVisible(item
);
1065 wxMacDataItem
* dataItem
= m_dbImpl
->GetItemFromLine(item
);
1066 m_dbImpl
->RevealItem(dataItem
, kDataBrowserRevealWithoutSelecting
);
1072 // Find an item whose label matches this string, starting from the item after 'start'
1073 // or the beginning if 'start' is -1.
1074 long wxListCtrl::FindItem(long start
, const wxString
& str
, bool partial
)
1077 return m_genericImpl
->FindItem(start
, str
, partial
);
1082 // Find an item whose data matches this data, starting from the item after 'start'
1083 // or the beginning if 'start' is -1.
1084 long wxListCtrl::FindItem(long start
, long data
)
1087 return m_genericImpl
->FindItem(start
, data
);
1089 long idx
= start
+ 1;
1090 long count
= GetItemCount();
1094 if (GetItemData(idx
) == data
)
1102 // Find an item nearest this position in the specified direction, starting from
1103 // the item after 'start' or the beginning if 'start' is -1.
1104 long wxListCtrl::FindItem(long start
, const wxPoint
& pt
, int direction
)
1107 return m_genericImpl
->FindItem(start
, pt
, direction
);
1111 // Determines which item (if any) is at the specified point,
1112 // giving details in 'flags' (see wxLIST_HITTEST_... flags above)
1114 wxListCtrl::HitTest(const wxPoint
& point
, int& flags
, long *ptrSubItem
) const
1117 return m_genericImpl
->HitTest(point
, flags
, ptrSubItem
);
1123 // Inserts an item, returning the index of the new item if successful,
1125 long wxListCtrl::InsertItem(wxListItem
& info
)
1127 wxASSERT_MSG( !IsVirtual(), _T("can't be used with virtual controls") );
1130 return m_genericImpl
->InsertItem(info
);
1134 int count
= GetItemCount();
1136 if (info
.m_itemId
> count
)
1137 info
.m_itemId
= count
;
1139 m_dbImpl
->MacInsertItem(info
.m_itemId
, &info
);
1140 wxListEvent
event( wxEVT_COMMAND_LIST_INSERT_ITEM
, GetId() );
1141 event
.SetEventObject( this );
1142 event
.m_itemIndex
= info
.m_itemId
;
1143 GetEventHandler()->ProcessEvent( event
);
1146 return info
.m_itemId
;
1149 long wxListCtrl::InsertItem(long index
, const wxString
& label
)
1152 return m_genericImpl
->InsertItem(index
, label
);
1155 info
.m_text
= label
;
1156 info
.m_mask
= wxLIST_MASK_TEXT
;
1157 info
.m_itemId
= index
;
1158 return InsertItem(info
);
1161 // Inserts an image item
1162 long wxListCtrl::InsertItem(long index
, int imageIndex
)
1165 return m_genericImpl
->InsertItem(index
, imageIndex
);
1168 info
.m_image
= imageIndex
;
1169 info
.m_mask
= wxLIST_MASK_IMAGE
;
1170 info
.m_itemId
= index
;
1171 return InsertItem(info
);
1174 // Inserts an image/string item
1175 long wxListCtrl::InsertItem(long index
, const wxString
& label
, int imageIndex
)
1178 return m_genericImpl
->InsertItem(index
, label
, imageIndex
);
1181 info
.m_image
= imageIndex
;
1182 info
.m_text
= label
;
1183 info
.m_mask
= wxLIST_MASK_IMAGE
| wxLIST_MASK_TEXT
;
1184 info
.m_itemId
= index
;
1185 return InsertItem(info
);
1188 // For list view mode (only), inserts a column.
1189 long wxListCtrl::InsertColumn(long col
, wxListItem
& item
)
1192 return m_genericImpl
->InsertColumn(col
, item
);
1196 if ( !(item
.GetMask() & wxLIST_MASK_WIDTH
) )
1199 DataBrowserPropertyType type
= kDataBrowserTextType
;
1200 wxImageList
* imageList
= GetImageList(wxIMAGE_LIST_SMALL
);
1201 if (imageList
&& imageList
->GetImageCount() > 0)
1203 wxBitmap bmp
= imageList
->GetBitmap(0);
1205 type
= kDataBrowserIconAndTextType
;
1208 SInt16 just
= teFlushDefault
;
1209 if (item
.GetMask() & wxLIST_MASK_FORMAT
)
1211 if (item
.GetAlign() == wxLIST_FORMAT_LEFT
)
1213 else if (item
.GetAlign() == wxLIST_FORMAT_CENTER
)
1215 else if (item
.GetAlign() == wxLIST_FORMAT_RIGHT
)
1216 just
= teFlushRight
;
1218 m_dbImpl
->InsertColumn(col
, type
, item
.GetText(), just
, item
.GetWidth());
1220 // set/remove options based on the wxListCtrl type.
1221 DataBrowserTableViewColumnID id
;
1222 m_dbImpl
->GetColumnIDFromIndex(col
, &id
);
1223 DataBrowserPropertyFlags flags
;
1224 verify_noerr(m_dbImpl
->GetPropertyFlags(id
, &flags
));
1225 if (GetWindowStyleFlag() & wxLC_EDIT_LABELS
)
1226 flags
|= kDataBrowserPropertyIsEditable
;
1228 if (GetWindowStyleFlag() & wxLC_VIRTUAL
){
1229 flags
&= ~kDataBrowserListViewSortableColumn
;
1231 verify_noerr(m_dbImpl
->SetPropertyFlags(id
, flags
));
1237 long wxListCtrl::InsertColumn(long col
,
1238 const wxString
& heading
,
1243 return m_genericImpl
->InsertColumn(col
, heading
, format
, width
);
1246 item
.m_mask
= wxLIST_MASK_TEXT
| wxLIST_MASK_FORMAT
;
1247 item
.m_text
= heading
;
1250 item
.m_mask
|= wxLIST_MASK_WIDTH
;
1251 item
.m_width
= width
;
1253 item
.m_format
= format
;
1255 return InsertColumn(col
, item
);
1258 // scroll the control by the given number of pixels (exception: in list view,
1259 // dx is interpreted as number of columns)
1260 bool wxListCtrl::ScrollList(int dx
, int dy
)
1263 return m_genericImpl
->ScrollList(dx
, dy
);
1267 m_dbImpl
->SetScrollPosition(dx
, dy
);
1273 bool wxListCtrl::SortItems(wxListCtrlCompare fn
, long data
)
1276 return m_genericImpl
->SortItems(fn
, data
);
1281 // ----------------------------------------------------------------------------
1282 // virtual list controls
1283 // ----------------------------------------------------------------------------
1285 wxString
wxListCtrl::OnGetItemText(long WXUNUSED(item
), long WXUNUSED(col
)) const
1287 // this is a pure virtual function, in fact - which is not really pure
1288 // because the controls which are not virtual don't need to implement it
1289 wxFAIL_MSG( _T("wxListCtrl::OnGetItemText not supposed to be called") );
1291 return wxEmptyString
;
1294 int wxListCtrl::OnGetItemImage(long WXUNUSED(item
)) const
1296 wxCHECK_MSG(!GetImageList(wxIMAGE_LIST_SMALL
),
1298 wxT("List control has an image list, OnGetItemImage or OnGetItemColumnImage should be overridden."));
1302 int wxListCtrl::OnGetItemColumnImage(long item
, long column
) const
1305 return OnGetItemImage(item
);
1310 wxListItemAttr
*wxListCtrl::OnGetItemAttr(long WXUNUSED_UNLESS_DEBUG(item
)) const
1312 wxASSERT_MSG( item
>= 0 && item
< GetItemCount(),
1313 _T("invalid item index in OnGetItemAttr()") );
1315 // no attributes by default
1319 void wxListCtrl::SetItemCount(long count
)
1321 wxASSERT_MSG( IsVirtual(), _T("this is for virtual controls only") );
1325 m_genericImpl
->SetItemCount(count
);
1331 // we need to temporarily disable the new item creation notification
1332 // procedure to speed things up
1333 // FIXME: Even this doesn't seem to help much...
1334 DataBrowserCallbacks callbacks
;
1335 DataBrowserItemNotificationUPP itemUPP
;
1336 GetDataBrowserCallbacks(m_dbImpl
->GetControlRef(), &callbacks
);
1337 itemUPP
= callbacks
.u
.v1
.itemNotificationCallback
;
1338 callbacks
.u
.v1
.itemNotificationCallback
= 0;
1339 m_dbImpl
->SetCallbacks(&callbacks
);
1340 ::AddDataBrowserItems(m_dbImpl
->GetControlRef(), kDataBrowserNoItem
,
1341 count
, NULL
, kDataBrowserItemNoProperty
);
1342 callbacks
.u
.v1
.itemNotificationCallback
= itemUPP
;
1343 m_dbImpl
->SetCallbacks(&callbacks
);
1348 void wxListCtrl::RefreshItem(long item
)
1352 m_genericImpl
->RefreshItem(item
);
1357 GetItemRect(item
, rect
);
1361 void wxListCtrl::RefreshItems(long itemFrom
, long itemTo
)
1365 m_genericImpl
->RefreshItems(itemFrom
, itemTo
);
1369 wxRect rect1
, rect2
;
1370 GetItemRect(itemFrom
, rect1
);
1371 GetItemRect(itemTo
, rect2
);
1373 wxRect rect
= rect1
;
1374 rect
.height
= rect2
.GetBottom() - rect1
.GetTop();
1380 // wxMac internal data structures
1382 wxMacListCtrlItem::~wxMacListCtrlItem()
1386 void wxMacListCtrlItem::Notification(wxMacDataItemBrowserControl
*owner
,
1387 DataBrowserItemNotification message
,
1388 DataBrowserItemDataRef itemData
) const
1391 wxMacDataBrowserListCtrlControl
*lb
= dynamic_cast<wxMacDataBrowserListCtrlControl
*>(owner
);
1393 // we want to depend on as little as possible to make sure tear-down of controls is safe
1394 if ( message
== kDataBrowserItemRemoved
)
1396 if ( lb
!= NULL
&& lb
->GetClientDataType() == wxClientData_Object
)
1398 delete (wxClientData
*) (m_data
);
1404 else if ( message
== kDataBrowserItemAdded
)
1406 // we don't issue events on adding, the item is not really stored in the list yet, so we
1407 // avoid asserts by gettting out now
1411 wxListCtrl
*list
= wxDynamicCast( owner
->GetPeer() , wxListCtrl
);
1414 bool trigger
= false;
1416 wxListEvent
event( wxEVT_COMMAND_LIST_ITEM_SELECTED
, list
->GetId() );
1417 bool isSingle
= (list
->GetWindowStyle() & wxLC_SINGLE_SEL
) != 0;
1419 event
.SetEventObject( list
);
1420 event
.m_itemIndex
= owner
->GetLineFromItem( this ) ;
1421 if ( !list
->IsVirtual() )
1423 lb
->MacGetColumnInfo(event
.m_itemIndex
,0,event
.m_item
);
1428 case kDataBrowserItemDeselected
:
1429 event
.SetEventType(wxEVT_COMMAND_LIST_ITEM_DESELECTED
);
1431 trigger
= !lb
->IsSelectionSuppressed();
1434 case kDataBrowserItemSelected
:
1435 trigger
= !lb
->IsSelectionSuppressed();
1438 case kDataBrowserItemDoubleClicked
:
1439 event
.SetEventType( wxEVT_LEFT_DCLICK
);
1443 case kDataBrowserEditStarted
:
1444 // TODO : how to veto ?
1445 event
.SetEventType( wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
) ;
1449 case kDataBrowserEditStopped
:
1450 // TODO probably trigger only upon the value store callback, because
1451 // here IIRC we cannot veto
1452 event
.SetEventType( wxEVT_COMMAND_LIST_END_LABEL_EDIT
) ;
1462 // direct notification is not always having the listbox GetSelection() having in synch with event
1463 wxPostEvent( list
->GetEventHandler(), event
);
1469 wxMacDataBrowserListCtrlControl::wxMacDataBrowserListCtrlControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
)
1470 : wxMacDataItemBrowserControl( peer
, pos
, size
, style
)
1472 OSStatus err
= noErr
;
1473 m_clientDataItemsType
= wxClientData_None
;
1474 m_isVirtual
= false;
1476 if ( style
& wxLC_VIRTUAL
)
1479 DataBrowserSelectionFlags options
= kDataBrowserDragSelect
;
1480 if ( style
& wxLC_SINGLE_SEL
)
1482 options
|= kDataBrowserSelectOnlyOne
;
1486 options
|= kDataBrowserCmdTogglesSelection
;
1489 err
= SetSelectionFlags( options
);
1490 verify_noerr( err
);
1492 if ( style
& wxLC_LIST
)
1494 InsertColumn(0, kDataBrowserIconAndTextType
, wxEmptyString
, -1, -1);
1495 verify_noerr( AutoSizeColumns() );
1498 if ( style
& wxLC_LIST
|| style
& wxLC_NO_HEADER
)
1499 verify_noerr( SetHeaderButtonHeight( 0 ) );
1502 SetSortProperty( kMinColumnId
- 1 );
1504 SetSortProperty( kMinColumnId
);
1505 if ( style
& wxLC_SORT_ASCENDING
)
1507 m_sortOrder
= SortOrder_Text_Ascending
;
1508 SetSortOrder( kDataBrowserOrderIncreasing
);
1510 else if ( style
& wxLC_SORT_DESCENDING
)
1512 m_sortOrder
= SortOrder_Text_Descending
;
1513 SetSortOrder( kDataBrowserOrderDecreasing
);
1517 m_sortOrder
= SortOrder_None
;
1520 if ( style
& wxLC_VRULES
)
1522 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
1523 verify_noerr( DataBrowserChangeAttributes(m_controlRef
, kDataBrowserAttributeListViewDrawColumnDividers
, kDataBrowserAttributeNone
) );
1527 verify_noerr( SetHiliteStyle(kDataBrowserTableViewFillHilite
) );
1528 err
= SetHasScrollBars( (style
& wxHSCROLL
) != 0 , true );
1531 OSStatus
wxMacDataBrowserListCtrlControl::GetSetItemData(DataBrowserItemID itemID
,
1532 DataBrowserPropertyID property
,
1533 DataBrowserItemDataRef itemData
,
1534 Boolean changeValue
)
1538 short listColumn
= property
- kMinColumnId
;
1540 OSStatus err
= errDataBrowserPropertyNotSupported
;
1541 wxListCtrl
* list
= wxDynamicCast( GetPeer() , wxListCtrl
);
1542 wxMacListCtrlItem
* lcItem
;
1544 if (listColumn
>= 0)
1548 lcItem
= (wxMacListCtrlItem
*) itemID
;
1549 if (lcItem
->HasColumnInfo(listColumn
)){
1550 wxListItem
* item
= lcItem
->GetColumnInfo(listColumn
);
1551 if (item
->GetMask() & wxLIST_MASK_TEXT
)
1552 text
= item
->GetText();
1553 if (item
->GetMask() & wxLIST_MASK_IMAGE
)
1554 imgIndex
= item
->GetImage();
1559 text
= list
->OnGetItemText( (long)itemID
-1, listColumn
);
1560 imgIndex
= list
->OnGetItemColumnImage( (long)itemID
-1, listColumn
);
1568 case kDataBrowserItemIsEditableProperty
:
1569 if ( list
&& list
->HasFlag( wxLC_EDIT_LABELS
) )
1571 verify_noerr(SetDataBrowserItemDataBooleanValue( itemData
, true ));
1576 if ( property
>= kMinColumnId
)
1578 wxMacCFStringHolder cfStr
;
1581 cfStr
.Assign( text
, wxLocale::GetSystemEncoding() );
1582 err
= ::SetDataBrowserItemDataText( itemData
, cfStr
);
1588 if ( imgIndex
!= -1 )
1590 wxImageList
* imageList
= list
->GetImageList(wxIMAGE_LIST_SMALL
);
1591 if (imageList
&& imageList
->GetImageCount() > 0){
1592 wxBitmap bmp
= imageList
->GetBitmap(imgIndex
);
1593 IconRef icon
= bmp
.GetBitmapData()->GetIconRef();
1594 ::SetDataBrowserItemDataIcon(itemData
, icon
);
1608 if ( property
>= kMinColumnId
)
1610 short listColumn
= property
- kMinColumnId
;
1612 // TODO probably send the 'end edit' from here, as we
1613 // can then deal with the veto
1615 verify_noerr( GetDataBrowserItemDataText( itemData
, &sr
) ) ;
1616 wxMacCFStringHolder
cfStr(sr
) ;;
1618 list
->SetItem( (long)itemData
-1 , listColumn
, cfStr
.AsString() ) ;
1622 lcItem
->SetColumnTextValue( listColumn
, cfStr
.AsString() );
1632 void wxMacDataBrowserListCtrlControl::ItemNotification(DataBrowserItemID itemID
,
1633 DataBrowserItemNotification message
,
1634 DataBrowserItemDataRef itemData
)
1636 // we want to depend on as little as possible to make sure tear-down of controls is safe
1637 if ( message
== kDataBrowserItemRemoved
)
1639 // make sure MacDelete does the proper teardown.
1642 else if ( message
== kDataBrowserItemAdded
)
1644 // we don't issue events on adding, the item is not really stored in the list yet, so we
1645 // avoid asserts by getting out now
1649 wxListCtrl
*list
= wxDynamicCast( GetPeer() , wxListCtrl
);
1652 bool trigger
= false;
1654 wxListEvent
event( wxEVT_COMMAND_LIST_ITEM_SELECTED
, list
->GetId() );
1655 bool isSingle
= (list
->GetWindowStyle() & wxLC_SINGLE_SEL
) != 0;
1657 event
.SetEventObject( list
);
1658 if ( !list
->IsVirtual() )
1660 DataBrowserTableViewRowIndex result
= 0;
1661 verify_noerr( GetItemRow( itemID
, &result
) ) ;
1662 event
.m_itemIndex
= result
;
1664 if (event
.m_itemIndex
>= 0)
1665 MacGetColumnInfo(event
.m_itemIndex
,0,event
.m_item
);
1669 event
.m_itemIndex
= (long)itemID
;
1674 case kDataBrowserItemDeselected
:
1675 event
.SetEventType(wxEVT_COMMAND_LIST_ITEM_DESELECTED
);
1677 trigger
= IsSelectionSuppressed();
1680 case kDataBrowserItemSelected
:
1681 trigger
= IsSelectionSuppressed();
1684 case kDataBrowserItemDoubleClicked
:
1685 event
.SetEventType( wxEVT_LEFT_DCLICK
);
1689 case kDataBrowserEditStarted
:
1690 // TODO : how to veto ?
1691 event
.SetEventType( wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
) ;
1695 case kDataBrowserEditStopped
:
1696 // TODO probably trigger only upon the value store callback, because
1697 // here IIRC we cannot veto
1698 event
.SetEventType( wxEVT_COMMAND_LIST_END_LABEL_EDIT
) ;
1708 // direct notification is not always having the listbox GetSelection() having in synch with event
1709 wxPostEvent( list
->GetEventHandler(), event
);
1714 Boolean
wxMacDataBrowserListCtrlControl::CompareItems(DataBrowserItemID itemOneID
,
1715 DataBrowserItemID itemTwoID
,
1716 DataBrowserPropertyID sortProperty
)
1719 bool retval
= false;
1721 wxString otherItemText
;
1722 int colId
= sortProperty
- kMinColumnId
;
1724 long otherItemNum
= 0;
1726 wxListCtrl
* list
= wxDynamicCast( GetPeer() , wxListCtrl
);
1733 wxMacListCtrlItem
* item
= (wxMacListCtrlItem
*)itemOneID
;
1734 wxMacListCtrlItem
* otherItem
= (wxMacListCtrlItem
*)itemTwoID
;
1735 itemNum
= item
->GetOrder();
1736 otherItemNum
= otherItem
->GetOrder();
1737 if (item
->HasColumnInfo(colId
))
1738 itemText
= item
->GetColumnInfo(colId
)->GetText();
1739 if (otherItem
->HasColumnInfo(colId
))
1740 otherItemText
= otherItem
->GetColumnInfo(colId
)->GetText();
1744 itemNum
= (long)itemOneID
;
1745 otherItemNum
= (long)itemTwoID
;
1746 itemText
= list
->OnGetItemText( itemNum
-1, colId
);
1747 otherItemText
= list
->OnGetItemText( otherItemNum
-1, colId
);
1751 DataBrowserSortOrder sort
;
1752 verify_noerr(GetSortOrder(&sort
));
1754 if ( sort
== kDataBrowserOrderIncreasing
)
1756 retval
= itemText
.CmpNoCase( otherItemText
) > 0;
1758 else if ( sort
== kDataBrowserOrderDecreasing
)
1760 retval
= itemText
.CmpNoCase( otherItemText
) < 0;
1764 // fallback for undefined cases
1765 retval
= itemOneID
< itemTwoID
;
1771 wxMacDataBrowserListCtrlControl::~wxMacDataBrowserListCtrlControl()
1775 void wxMacDataBrowserListCtrlControl::MacSetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
* item
)
1777 wxMacDataItem
* dataItem
= GetItemFromLine(row
);
1780 wxMacListCtrlItem
* listItem
= dynamic_cast<wxMacListCtrlItem
*>(dataItem
);
1781 listItem
->SetColumnInfo( column
, item
);
1782 UpdateState(dataItem
, item
);
1786 // apply changes that need to happen immediately, rather than when the
1787 // databrowser control fires a callback.
1788 void wxMacDataBrowserListCtrlControl::UpdateState(wxMacDataItem
* dataItem
, wxListItem
* listItem
)
1790 bool isSelected
= IsItemSelected( dataItem
);
1791 bool isSelectedState
= (listItem
->GetState() == wxLIST_STATE_SELECTED
);
1793 // toggle the selection state if wxListInfo state and actual state don't match.
1794 if ( isSelected
!= isSelectedState
)
1796 DataBrowserSetOption options
= kDataBrowserItemsAdd
;
1797 if (!isSelectedState
)
1798 options
= kDataBrowserItemsRemove
;
1799 SetSelectedItem(dataItem
, options
);
1801 // TODO: Set column width if item width > than current column width
1804 void wxMacDataBrowserListCtrlControl::MacGetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
& item
)
1806 wxMacDataItem
* dataItem
= GetItemFromLine(row
);
1807 // CS should this guard against dataItem = 0 ? , as item is not a pointer if (item) is not appropriate
1810 wxMacListCtrlItem
* listItem
= dynamic_cast<wxMacListCtrlItem
*>(dataItem
);
1811 wxListItem
* oldItem
= listItem
->GetColumnInfo( column
);
1813 long mask
= item
.GetMask();
1815 // by default, get everything for backwards compatibility
1818 if ( mask
& wxLIST_MASK_TEXT
)
1819 item
.SetText(oldItem
->GetText());
1820 if ( mask
& wxLIST_MASK_IMAGE
)
1821 item
.SetImage(oldItem
->GetImage());
1822 if ( mask
& wxLIST_MASK_DATA
)
1823 item
.SetData(oldItem
->GetData());
1824 if ( mask
& wxLIST_MASK_STATE
)
1825 item
.SetState(oldItem
->GetState());
1826 if ( mask
& wxLIST_MASK_WIDTH
)
1827 item
.SetWidth(oldItem
->GetWidth());
1828 if ( mask
& wxLIST_MASK_FORMAT
)
1829 item
.SetAlign(oldItem
->GetAlign());
1831 item
.SetTextColour(oldItem
->GetTextColour());
1832 item
.SetBackgroundColour(oldItem
->GetBackgroundColour());
1833 item
.SetFont(oldItem
->GetFont());
1837 void wxMacDataBrowserListCtrlControl::MacInsertItem( unsigned int n
, wxListItem
* item
)
1839 wxMacDataItemBrowserControl::MacInsert(n
, item
->GetText());
1840 MacSetColumnInfo(n
, 0, item
);
1843 wxMacDataItem
* wxMacDataBrowserListCtrlControl::CreateItem()
1845 return new wxMacListCtrlItem();
1848 wxMacListCtrlItem::wxMacListCtrlItem()
1850 m_rowItems
= wxListItemList();
1853 int wxMacListCtrlItem::GetColumnImageValue( unsigned int column
)
1855 return GetColumnInfo(column
)->GetImage();
1858 void wxMacListCtrlItem::SetColumnImageValue( unsigned int column
, int imageIndex
)
1860 GetColumnInfo(column
)->SetImage(imageIndex
);
1863 const wxString
& wxMacListCtrlItem::GetColumnTextValue( unsigned int column
)
1868 return GetColumnInfo(column
)->GetText();
1871 void wxMacListCtrlItem::SetColumnTextValue( unsigned int column
, const wxString
& text
)
1873 GetColumnInfo(column
)->SetText(text
);
1875 // for compatibility with superclass APIs
1880 wxListItem
* wxMacListCtrlItem::GetColumnInfo( unsigned int column
)
1882 wxListItemList::compatibility_iterator node
= m_rowItems
.Item( column
);
1883 wxASSERT_MSG( node
, _T("invalid column index in wxMacListCtrlItem") );
1885 return node
->GetData();
1888 bool wxMacListCtrlItem::HasColumnInfo( unsigned int column
)
1890 return m_rowItems
.GetCount() > column
;
1893 void wxMacListCtrlItem::SetColumnInfo( unsigned int column
, wxListItem
* item
)
1896 if ( column
>= m_rowItems
.GetCount() )
1898 wxListItem
* listItem
= new wxListItem(*item
);
1899 m_rowItems
.Append( listItem
);
1903 wxListItem
* listItem
= GetColumnInfo( column
);
1904 long mask
= item
->GetMask();
1905 if (mask
& wxLIST_MASK_TEXT
)
1906 listItem
->SetText(item
->GetText());
1907 if (mask
& wxLIST_MASK_DATA
)
1908 listItem
->SetData(item
->GetData());
1909 if (mask
& wxLIST_MASK_IMAGE
)
1910 listItem
->SetImage(item
->GetImage());
1911 if (mask
& wxLIST_MASK_STATE
)
1912 listItem
->SetState(item
->GetState());
1913 if (mask
& wxLIST_MASK_FORMAT
)
1914 listItem
->SetAlign(item
->GetAlign());
1915 if (mask
& wxLIST_MASK_WIDTH
)
1916 listItem
->SetWidth(item
->GetWidth());
1920 #endif // wxUSE_LISTCTRL