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 wxMacListCtrlItem
* 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
)
229 virtual wxListItemAttr
* OnGetItemAttr(long item
) const
231 return m_nativeListCtrl
->OnGetItemAttr(item
);
234 virtual int OnGetItemImage(long item
) const
236 return m_nativeListCtrl
->OnGetItemImage(item
);
239 virtual int OnGetItemColumnImage(long item
, long column
) const
241 return m_nativeListCtrl
->OnGetItemColumnImage(item
, column
);
244 virtual wxString
OnGetItemText(long item
, long column
) const
246 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 if (GetWindowStyleFlag() & wxLC_EDIT_LABELS
)
1222 DataBrowserTableViewColumnID id
;
1223 m_dbImpl
->GetColumnIDFromIndex(col
, &id
);
1224 DataBrowserPropertyFlags flags
;
1225 verify_noerr(m_dbImpl
->GetPropertyFlags(id
, &flags
));
1226 flags
|= kDataBrowserPropertyIsEditable
;
1227 verify_noerr(m_dbImpl
->SetPropertyFlags(id
, flags
));
1234 long wxListCtrl::InsertColumn(long col
,
1235 const wxString
& heading
,
1240 return m_genericImpl
->InsertColumn(col
, heading
, format
, width
);
1243 item
.m_mask
= wxLIST_MASK_TEXT
| wxLIST_MASK_FORMAT
;
1244 item
.m_text
= heading
;
1247 item
.m_mask
|= wxLIST_MASK_WIDTH
;
1248 item
.m_width
= width
;
1250 item
.m_format
= format
;
1252 return InsertColumn(col
, item
);
1255 // scroll the control by the given number of pixels (exception: in list view,
1256 // dx is interpreted as number of columns)
1257 bool wxListCtrl::ScrollList(int dx
, int dy
)
1260 return m_genericImpl
->ScrollList(dx
, dy
);
1264 m_dbImpl
->SetScrollPosition(dx
, dy
);
1270 bool wxListCtrl::SortItems(wxListCtrlCompare fn
, long data
)
1273 return m_genericImpl
->SortItems(fn
, data
);
1278 // ----------------------------------------------------------------------------
1279 // virtual list controls
1280 // ----------------------------------------------------------------------------
1282 wxString
wxListCtrl::OnGetItemText(long WXUNUSED(item
), long WXUNUSED(col
)) const
1284 // this is a pure virtual function, in fact - which is not really pure
1285 // because the controls which are not virtual don't need to implement it
1286 wxFAIL_MSG( _T("wxListCtrl::OnGetItemText not supposed to be called") );
1288 return wxEmptyString
;
1291 int wxListCtrl::OnGetItemImage(long WXUNUSED(item
)) const
1293 wxCHECK_MSG(!GetImageList(wxIMAGE_LIST_SMALL
),
1295 wxT("List control has an image list, OnGetItemImage or OnGetItemColumnImage should be overridden."));
1299 int wxListCtrl::OnGetItemColumnImage(long item
, long column
) const
1302 return OnGetItemImage(item
);
1307 wxListItemAttr
*wxListCtrl::OnGetItemAttr(long WXUNUSED_UNLESS_DEBUG(item
)) const
1309 wxASSERT_MSG( item
>= 0 && item
< GetItemCount(),
1310 _T("invalid item index in OnGetItemAttr()") );
1312 // no attributes by default
1316 void wxListCtrl::SetItemCount(long count
)
1318 wxASSERT_MSG( IsVirtual(), _T("this is for virtual controls only") );
1322 m_genericImpl
->SetItemCount(count
);
1328 // we need to temporarily disable the new item creation notification
1329 // procedure to speed things up
1330 // FIXME: Even this doesn't seem to help much...
1331 DataBrowserCallbacks callbacks
;
1332 DataBrowserItemNotificationUPP itemUPP
;
1333 GetDataBrowserCallbacks(m_dbImpl
->GetControlRef(), &callbacks
);
1334 itemUPP
= callbacks
.u
.v1
.itemNotificationCallback
;
1335 callbacks
.u
.v1
.itemNotificationCallback
= 0;
1336 m_dbImpl
->SetCallbacks(&callbacks
);
1337 ::AddDataBrowserItems(m_dbImpl
->GetControlRef(), kDataBrowserNoItem
,
1338 count
, NULL
, kDataBrowserItemNoProperty
);
1339 callbacks
.u
.v1
.itemNotificationCallback
= itemUPP
;
1340 m_dbImpl
->SetCallbacks(&callbacks
);
1345 void wxListCtrl::RefreshItem(long item
)
1349 m_genericImpl
->RefreshItem(item
);
1354 GetItemRect(item
, rect
);
1358 void wxListCtrl::RefreshItems(long itemFrom
, long itemTo
)
1362 m_genericImpl
->RefreshItems(itemFrom
, itemTo
);
1366 wxRect rect1
, rect2
;
1367 GetItemRect(itemFrom
, rect1
);
1368 GetItemRect(itemTo
, rect2
);
1370 wxRect rect
= rect1
;
1371 rect
.height
= rect2
.GetBottom() - rect1
.GetTop();
1377 // wxMac internal data structures
1379 wxMacListCtrlItem::~wxMacListCtrlItem()
1383 void wxMacListCtrlItem::Notification(wxMacDataItemBrowserControl
*owner
,
1384 DataBrowserItemNotification message
,
1385 DataBrowserItemDataRef itemData
) const
1388 wxMacDataBrowserListCtrlControl
*lb
= dynamic_cast<wxMacDataBrowserListCtrlControl
*>(owner
);
1390 // we want to depend on as little as possible to make sure tear-down of controls is safe
1391 if ( message
== kDataBrowserItemRemoved
)
1393 if ( lb
!= NULL
&& lb
->GetClientDataType() == wxClientData_Object
)
1395 delete (wxClientData
*) (m_data
);
1401 else if ( message
== kDataBrowserItemAdded
)
1403 // we don't issue events on adding, the item is not really stored in the list yet, so we
1404 // avoid asserts by gettting out now
1408 wxListCtrl
*list
= wxDynamicCast( owner
->GetPeer() , wxListCtrl
);
1411 bool trigger
= false;
1413 wxListEvent
event( wxEVT_COMMAND_LIST_ITEM_SELECTED
, list
->GetId() );
1414 bool isSingle
= list
->GetWindowStyle() | wxLC_SINGLE_SEL
;
1416 event
.SetEventObject( list
);
1417 event
.m_itemIndex
= owner
->GetLineFromItem( this ) ;
1418 if ( !list
->IsVirtual() )
1420 lb
->MacGetColumnInfo(event
.m_itemIndex
,0,event
.m_item
);
1425 case kDataBrowserItemDeselected
:
1426 event
.SetEventType(wxEVT_COMMAND_LIST_ITEM_DESELECTED
);
1428 trigger
= !lb
->IsSelectionSuppressed();
1431 case kDataBrowserItemSelected
:
1432 trigger
= !lb
->IsSelectionSuppressed();
1435 case kDataBrowserItemDoubleClicked
:
1436 event
.SetEventType( wxEVT_LEFT_DCLICK
);
1440 case kDataBrowserEditStarted
:
1441 // TODO : how to veto ?
1442 event
.SetEventType( wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
) ;
1446 case kDataBrowserEditStopped
:
1447 // TODO probably trigger only upon the value store callback, because
1448 // here IIRC we cannot veto
1449 event
.SetEventType( wxEVT_COMMAND_LIST_END_LABEL_EDIT
) ;
1459 // direct notification is not always having the listbox GetSelection() having in synch with event
1460 wxPostEvent( list
->GetEventHandler(), event
);
1466 wxMacDataBrowserListCtrlControl::wxMacDataBrowserListCtrlControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
)
1467 : wxMacDataItemBrowserControl( peer
, pos
, size
, style
)
1469 OSStatus err
= noErr
;
1470 m_clientDataItemsType
= wxClientData_None
;
1471 m_isVirtual
= false;
1473 if ( style
& wxLC_VIRTUAL
)
1476 DataBrowserSelectionFlags options
= kDataBrowserDragSelect
;
1477 if ( style
& wxLC_SINGLE_SEL
)
1479 options
|= kDataBrowserSelectOnlyOne
;
1483 options
|= kDataBrowserCmdTogglesSelection
;
1486 err
= SetSelectionFlags( options
);
1487 verify_noerr( err
);
1489 if ( style
& wxLC_LIST
)
1491 InsertColumn(0, kDataBrowserIconAndTextType
, wxEmptyString
, -1, -1);
1492 verify_noerr( AutoSizeColumns() );
1495 if ( style
& wxLC_LIST
|| style
& wxLC_NO_HEADER
)
1496 verify_noerr( SetHeaderButtonHeight( 0 ) );
1499 SetSortProperty( kMinColumnId
- 1 );
1501 SetSortProperty( kMinColumnId
);
1502 if ( style
& wxLC_SORT_ASCENDING
)
1504 m_sortOrder
= SortOrder_Text_Ascending
;
1505 SetSortOrder( kDataBrowserOrderIncreasing
);
1507 else if ( style
& wxLC_SORT_DESCENDING
)
1509 m_sortOrder
= SortOrder_Text_Descending
;
1510 SetSortOrder( kDataBrowserOrderDecreasing
);
1514 m_sortOrder
= SortOrder_None
;
1517 if ( style
& wxLC_VRULES
)
1519 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
1520 verify_noerr( DataBrowserChangeAttributes(m_controlRef
, kDataBrowserAttributeListViewDrawColumnDividers
, kDataBrowserAttributeNone
) );
1524 verify_noerr( SetHiliteStyle(kDataBrowserTableViewFillHilite
) );
1525 err
= SetHasScrollBars( (style
& wxHSCROLL
) != 0 , true );
1528 OSStatus
wxMacDataBrowserListCtrlControl::GetSetItemData(DataBrowserItemID itemID
,
1529 DataBrowserPropertyID property
,
1530 DataBrowserItemDataRef itemData
,
1531 Boolean changeValue
)
1535 short listColumn
= property
- kMinColumnId
;
1537 OSStatus err
= errDataBrowserPropertyNotSupported
;
1538 wxListCtrl
* list
= wxDynamicCast( GetPeer() , wxListCtrl
);
1539 wxMacListCtrlItem
* lcItem
;
1541 if (listColumn
>= 0)
1545 lcItem
= (wxMacListCtrlItem
*) itemID
;
1546 if (lcItem
->HasColumnInfo(listColumn
)){
1547 wxListItem
* item
= lcItem
->GetColumnInfo(listColumn
);
1548 if (item
->GetMask() & wxLIST_MASK_TEXT
)
1549 text
= item
->GetText();
1550 if (item
->GetMask() & wxLIST_MASK_IMAGE
)
1551 imgIndex
= item
->GetImage();
1556 text
= list
->OnGetItemText( (long)itemID
-1, listColumn
);
1557 imgIndex
= list
->OnGetItemColumnImage( (long)itemID
-1, listColumn
);
1565 case kDataBrowserItemIsEditableProperty
:
1566 if ( list
&& list
->HasFlag( wxLC_EDIT_LABELS
) )
1568 verify_noerr(SetDataBrowserItemDataBooleanValue( itemData
, true ));
1573 if ( property
>= kMinColumnId
)
1575 wxMacCFStringHolder cfStr
;
1578 cfStr
.Assign( text
, wxLocale::GetSystemEncoding() );
1579 err
= ::SetDataBrowserItemDataText( itemData
, cfStr
);
1585 if ( imgIndex
!= -1 )
1587 wxImageList
* imageList
= list
->GetImageList(wxIMAGE_LIST_SMALL
);
1588 if (imageList
&& imageList
->GetImageCount() > 0){
1589 wxBitmap bmp
= imageList
->GetBitmap(imgIndex
);
1590 IconRef icon
= bmp
.GetBitmapData()->GetIconRef();
1591 ::SetDataBrowserItemDataIcon(itemData
, icon
);
1605 if ( property
>= kMinColumnId
)
1607 short listColumn
= property
- kMinColumnId
;
1609 // TODO probably send the 'end edit' from here, as we
1610 // can then deal with the veto
1612 verify_noerr( GetDataBrowserItemDataText( itemData
, &sr
) ) ;
1613 wxMacCFStringHolder
cfStr(sr
) ;;
1615 list
->SetItem( (long)itemData
-1 , listColumn
, cfStr
.AsString() ) ;
1619 lcItem
->SetColumnTextValue( listColumn
, cfStr
.AsString() );
1629 void wxMacDataBrowserListCtrlControl::ItemNotification(DataBrowserItemID itemID
,
1630 DataBrowserItemNotification message
,
1631 DataBrowserItemDataRef itemData
)
1633 // we want to depend on as little as possible to make sure tear-down of controls is safe
1634 if ( message
== kDataBrowserItemRemoved
)
1636 // make sure MacDelete does the proper teardown.
1639 else if ( message
== kDataBrowserItemAdded
)
1641 // we don't issue events on adding, the item is not really stored in the list yet, so we
1642 // avoid asserts by gettting out now
1646 wxListCtrl
*list
= wxDynamicCast( GetPeer() , wxListCtrl
);
1649 bool trigger
= false;
1651 wxListEvent
event( wxEVT_COMMAND_LIST_ITEM_SELECTED
, list
->GetId() );
1652 bool isSingle
= list
->GetWindowStyle() | wxLC_SINGLE_SEL
;
1654 event
.SetEventObject( list
);
1655 if ( !list
->IsVirtual() )
1657 wxMacDataItem
* item
= (wxMacDataItem
*)itemID
;
1658 DataBrowserTableViewRowIndex result
= 0;
1659 verify_noerr( GetItemRow( itemID
, &result
) ) ;
1660 event
.m_itemIndex
= result
;
1662 if (event
.m_itemIndex
>= 0)
1663 MacGetColumnInfo(event
.m_itemIndex
,0,event
.m_item
);
1667 event
.m_itemIndex
= (long)itemID
;
1672 case kDataBrowserItemDeselected
:
1673 event
.SetEventType(wxEVT_COMMAND_LIST_ITEM_DESELECTED
);
1675 trigger
= IsSelectionSuppressed();
1678 case kDataBrowserItemSelected
:
1679 trigger
= IsSelectionSuppressed();
1682 case kDataBrowserItemDoubleClicked
:
1683 event
.SetEventType( wxEVT_LEFT_DCLICK
);
1687 case kDataBrowserEditStarted
:
1688 // TODO : how to veto ?
1689 event
.SetEventType( wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
) ;
1693 case kDataBrowserEditStopped
:
1694 // TODO probably trigger only upon the value store callback, because
1695 // here IIRC we cannot veto
1696 event
.SetEventType( wxEVT_COMMAND_LIST_END_LABEL_EDIT
) ;
1706 // direct notification is not always having the listbox GetSelection() having in synch with event
1707 wxPostEvent( list
->GetEventHandler(), event
);
1712 Boolean
wxMacDataBrowserListCtrlControl::CompareItems(DataBrowserItemID itemOneID
,
1713 DataBrowserItemID itemTwoID
,
1714 DataBrowserPropertyID sortProperty
)
1717 bool retval
= false;
1719 wxString otherItemText
;
1720 int colId
= sortProperty
- kMinColumnId
;
1722 long otherItemNum
= 0;
1724 wxListCtrl
* list
= wxDynamicCast( GetPeer() , wxListCtrl
);
1731 wxMacListCtrlItem
* item
= (wxMacListCtrlItem
*)itemOneID
;
1732 wxMacListCtrlItem
* otherItem
= (wxMacListCtrlItem
*)itemTwoID
;
1733 itemNum
= item
->GetOrder();
1734 otherItemNum
= otherItem
->GetOrder();
1735 if (item
->HasColumnInfo(colId
))
1736 itemText
= item
->GetColumnInfo(colId
)->GetText();
1737 if (otherItem
->HasColumnInfo(colId
))
1738 otherItemText
= otherItem
->GetColumnInfo(colId
)->GetText();
1742 itemNum
= (long)itemOneID
;
1743 otherItemNum
= (long)itemTwoID
;
1744 itemText
= list
->OnGetItemText( itemNum
-1, colId
);
1745 otherItemText
= list
->OnGetItemText( otherItemNum
-1, colId
);
1749 DataBrowserSortOrder sort
;
1750 verify_noerr(GetSortOrder(&sort
));
1752 if ( sort
== kDataBrowserOrderIncreasing
)
1754 retval
= itemText
.CmpNoCase( otherItemText
) > 0;
1756 else if ( sort
== kDataBrowserOrderDecreasing
)
1758 retval
= itemText
.CmpNoCase( otherItemText
) < 0;
1762 // fallback for undefined cases
1763 retval
= itemOneID
< itemTwoID
;
1769 wxMacDataBrowserListCtrlControl::~wxMacDataBrowserListCtrlControl()
1773 void wxMacDataBrowserListCtrlControl::MacSetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
* item
)
1775 wxMacDataItem
* dataItem
= GetItemFromLine(row
);
1778 wxMacListCtrlItem
* listItem
= dynamic_cast<wxMacListCtrlItem
*>(dataItem
);
1779 listItem
->SetColumnInfo( column
, item
);
1780 UpdateState(dataItem
, item
);
1784 // apply changes that need to happen immediately, rather than when the
1785 // databrowser control fires a callback.
1786 void wxMacDataBrowserListCtrlControl::UpdateState(wxMacDataItem
* dataItem
, wxListItem
* listItem
)
1788 bool isSelected
= IsItemSelected( dataItem
);
1789 bool isSelectedState
= (listItem
->GetState() == wxLIST_STATE_SELECTED
);
1791 // toggle the selection state if wxListInfo state and actual state don't match.
1792 if ( isSelected
!= isSelectedState
)
1794 DataBrowserSetOption options
= kDataBrowserItemsAdd
;
1795 if (!isSelectedState
)
1796 options
= kDataBrowserItemsRemove
;
1797 SetSelectedItem(dataItem
, options
);
1799 // TODO: Set column width if item width > than current column width
1802 void wxMacDataBrowserListCtrlControl::MacGetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
& item
)
1804 wxMacDataItem
* dataItem
= GetItemFromLine(row
);
1805 // CS should this guard against dataItem = 0 ? , as item is not a pointer if (item) is not appropriate
1808 wxMacListCtrlItem
* listItem
= dynamic_cast<wxMacListCtrlItem
*>(dataItem
);
1809 wxListItem
* oldItem
= listItem
->GetColumnInfo( column
);
1811 long mask
= item
.GetMask();
1813 // by default, get everything for backwards compatibility
1816 if ( mask
& wxLIST_MASK_TEXT
)
1817 item
.SetText(oldItem
->GetText());
1818 if ( mask
& wxLIST_MASK_IMAGE
)
1819 item
.SetImage(oldItem
->GetImage());
1820 if ( mask
& wxLIST_MASK_DATA
)
1821 item
.SetData(oldItem
->GetData());
1822 if ( mask
& wxLIST_MASK_STATE
)
1823 item
.SetState(oldItem
->GetState());
1824 if ( mask
& wxLIST_MASK_WIDTH
)
1825 item
.SetWidth(oldItem
->GetWidth());
1826 if ( mask
& wxLIST_MASK_FORMAT
)
1827 item
.SetAlign(oldItem
->GetAlign());
1829 item
.SetTextColour(oldItem
->GetTextColour());
1830 item
.SetBackgroundColour(oldItem
->GetBackgroundColour());
1831 item
.SetFont(oldItem
->GetFont());
1835 void wxMacDataBrowserListCtrlControl::MacInsertItem( unsigned int n
, wxListItem
* item
)
1837 wxMacDataItemBrowserControl::MacInsert(n
, item
->GetText());
1838 MacSetColumnInfo(n
, 0, item
);
1841 wxMacListCtrlItem
* wxMacDataBrowserListCtrlControl::CreateItem()
1843 return new wxMacListCtrlItem();
1846 wxMacListCtrlItem::wxMacListCtrlItem()
1848 m_rowItems
= wxListItemList();
1851 int wxMacListCtrlItem::GetColumnImageValue( unsigned int column
)
1853 return GetColumnInfo(column
)->GetImage();
1856 void wxMacListCtrlItem::SetColumnImageValue( unsigned int column
, int imageIndex
)
1858 GetColumnInfo(column
)->SetImage(imageIndex
);
1861 const wxString
& wxMacListCtrlItem::GetColumnTextValue( unsigned int column
)
1866 return GetColumnInfo(column
)->GetText();
1869 void wxMacListCtrlItem::SetColumnTextValue( unsigned int column
, const wxString
& text
)
1871 GetColumnInfo(column
)->SetText(text
);
1873 // for compatibility with superclass APIs
1878 wxListItem
* wxMacListCtrlItem::GetColumnInfo( unsigned int column
)
1880 wxListItemList::compatibility_iterator node
= m_rowItems
.Item( column
);
1881 wxASSERT_MSG( node
, _T("invalid column index in wxMacListCtrlItem") );
1883 return node
->GetData();
1886 bool wxMacListCtrlItem::HasColumnInfo( unsigned int column
)
1888 return m_rowItems
.GetCount() > column
;
1891 void wxMacListCtrlItem::SetColumnInfo( unsigned int column
, wxListItem
* item
)
1894 if ( column
>= m_rowItems
.GetCount() )
1896 wxListItem
* listItem
= new wxListItem(*item
);
1897 m_rowItems
.Append( listItem
);
1901 wxListItem
* listItem
= GetColumnInfo( column
);
1902 long mask
= item
->GetMask();
1903 if (mask
& wxLIST_MASK_TEXT
)
1904 listItem
->SetText(item
->GetText());
1905 if (mask
& wxLIST_MASK_DATA
)
1906 listItem
->SetData(item
->GetData());
1907 if (mask
& wxLIST_MASK_IMAGE
)
1908 listItem
->SetImage(item
->GetImage());
1909 if (mask
& wxLIST_MASK_STATE
)
1910 listItem
->SetState(item
->GetState());
1911 if (mask
& wxLIST_MASK_FORMAT
)
1912 listItem
->SetAlign(item
->GetAlign());
1913 if (mask
& wxLIST_MASK_WIDTH
)
1914 listItem
->SetWidth(item
->GetWidth());
1918 #endif // wxUSE_LISTCTRL