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"
33 #include "wx/settings.h"
36 #include "wx/osx/uma.h"
38 #include "wx/imaglist.h"
39 #include "wx/sysopt.h"
42 #include "wx/hashmap.h"
44 #if wxUSE_EXTENDED_RTTI
45 WX_DEFINE_FLAGS( wxListCtrlStyle
)
47 wxBEGIN_FLAGS( wxListCtrlStyle
)
48 // new style border flags, we put them first to
49 // use them for streaming out
50 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
51 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
52 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
53 wxFLAGS_MEMBER(wxBORDER_RAISED
)
54 wxFLAGS_MEMBER(wxBORDER_STATIC
)
55 wxFLAGS_MEMBER(wxBORDER_NONE
)
57 // old style border flags
58 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
59 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
60 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
61 wxFLAGS_MEMBER(wxRAISED_BORDER
)
62 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
63 wxFLAGS_MEMBER(wxBORDER
)
65 // standard window styles
66 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
67 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
68 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
69 wxFLAGS_MEMBER(wxWANTS_CHARS
)
70 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
71 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
72 wxFLAGS_MEMBER(wxVSCROLL
)
73 wxFLAGS_MEMBER(wxHSCROLL
)
75 wxFLAGS_MEMBER(wxLC_LIST
)
76 wxFLAGS_MEMBER(wxLC_REPORT
)
77 wxFLAGS_MEMBER(wxLC_ICON
)
78 wxFLAGS_MEMBER(wxLC_SMALL_ICON
)
79 wxFLAGS_MEMBER(wxLC_ALIGN_TOP
)
80 wxFLAGS_MEMBER(wxLC_ALIGN_LEFT
)
81 wxFLAGS_MEMBER(wxLC_AUTOARRANGE
)
82 wxFLAGS_MEMBER(wxLC_USER_TEXT
)
83 wxFLAGS_MEMBER(wxLC_EDIT_LABELS
)
84 wxFLAGS_MEMBER(wxLC_NO_HEADER
)
85 wxFLAGS_MEMBER(wxLC_SINGLE_SEL
)
86 wxFLAGS_MEMBER(wxLC_SORT_ASCENDING
)
87 wxFLAGS_MEMBER(wxLC_SORT_DESCENDING
)
88 wxFLAGS_MEMBER(wxLC_VIRTUAL
)
90 wxEND_FLAGS( wxListCtrlStyle
)
92 IMPLEMENT_DYNAMIC_CLASS_XTI(wxListCtrl
, wxControl
,"wx/listctrl.h")
94 wxBEGIN_PROPERTIES_TABLE(wxListCtrl
)
95 wxEVENT_PROPERTY( TextUpdated
, wxEVT_COMMAND_TEXT_UPDATED
, wxCommandEvent
)
97 wxPROPERTY_FLAGS( WindowStyle
, wxListCtrlStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
98 wxEND_PROPERTIES_TABLE()
100 wxBEGIN_HANDLERS_TABLE(wxListCtrl
)
101 wxEND_HANDLERS_TABLE()
103 wxCONSTRUCTOR_5( wxListCtrl
, wxWindow
* , Parent
, wxWindowID
, Id
, wxPoint
, Position
, wxSize
, Size
, long , WindowStyle
)
106 TODO : Expose more information of a list's layout etc. via appropriate objects (¢ la NotebookPageInfo)
109 IMPLEMENT_DYNAMIC_CLASS(wxListCtrl
, wxControl
)
112 IMPLEMENT_DYNAMIC_CLASS(wxListView
, wxListCtrl
)
113 IMPLEMENT_DYNAMIC_CLASS(wxListItem
, wxObject
)
115 IMPLEMENT_DYNAMIC_CLASS(wxListEvent
, wxNotifyEvent
)
117 WX_DECLARE_HASH_MAP( int, wxListItem
*, wxIntegerHash
, wxIntegerEqual
, wxListItemList
);
119 #include "wx/listimpl.cpp"
120 WX_DEFINE_LIST(wxColumnList
)
122 // so we can check for column clicks
123 static const EventTypeSpec eventList
[] =
125 { kEventClassControl
, kEventControlHit
},
126 { kEventClassControl
, kEventControlDraw
}
129 static pascal OSStatus
wxMacListCtrlEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
131 OSStatus result
= eventNotHandledErr
;
133 wxMacCarbonEvent
cEvent( event
) ;
135 ControlRef controlRef
;
136 cEvent
.GetParameter( kEventParamDirectObject
, &controlRef
) ;
138 wxListCtrl
*window
= (wxListCtrl
*) data
;
139 wxListEvent
le( wxEVT_COMMAND_LIST_COL_CLICK
, window
->GetId() );
140 le
.SetEventObject( window
);
142 switch ( GetEventKind( event
) )
144 // check if the column was clicked on and fire an event if so
145 case kEventControlHit
:
147 ControlPartCode result
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
) ;
148 if (result
== kControlButtonPart
){
149 DataBrowserPropertyID col
;
150 GetDataBrowserSortProperty(controlRef
, &col
);
151 int column
= col
- kMinColumnId
;
153 // FIXME: we can't use the sort property for virtual listctrls
154 // so we need to find a better way to determine which column was clicked...
155 if (!window
->IsVirtual())
156 window
->HandleWindowEvent( le
);
158 result
= CallNextEventHandler(handler
, event
);
161 case kEventControlDraw
:
163 CGContextRef context
= cEvent
.GetParameter
<CGContextRef
>(kEventParamCGContextRef
, typeCGContextRef
) ;
164 window
->MacSetDrawingContext(context
);
165 result
= CallNextEventHandler(handler
, event
);
166 window
->MacSetDrawingContext(NULL
);
177 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacListCtrlEventHandler
)
179 class wxMacListCtrlItem
: public wxMacListBoxItem
184 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
185 DataBrowserItemNotification message
,
186 DataBrowserItemDataRef itemData
) const;
188 virtual void SetColumnInfo( unsigned int column
, wxListItem
* item
);
189 virtual wxListItem
* GetColumnInfo( unsigned int column
);
190 virtual bool HasColumnInfo( unsigned int column
);
192 virtual void SetColumnTextValue( unsigned int column
, const wxString
& text
);
193 virtual wxString
GetColumnTextValue( unsigned int column
);
195 virtual int GetColumnImageValue( unsigned int column
);
196 virtual void SetColumnImageValue( unsigned int column
, int imageIndex
);
198 virtual ~wxMacListCtrlItem();
200 wxListItemList m_rowItems
;
203 DataBrowserDrawItemUPP gDataBrowserDrawItemUPP
= NULL
;
204 //DataBrowserEditItemUPP gDataBrowserEditItemUPP = NULL;
205 DataBrowserHitTestUPP gDataBrowserHitTestUPP
= NULL
;
207 // TODO: Make a better name!!
208 class wxMacDataBrowserListCtrlControl
: public wxMacDataItemBrowserControl
211 wxMacDataBrowserListCtrlControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
212 wxMacDataBrowserListCtrlControl() {}
213 virtual ~wxMacDataBrowserListCtrlControl();
215 // create a list item (can be a subclass of wxMacListBoxItem)
217 virtual wxMacDataItem
* CreateItem();
219 virtual void MacInsertItem( unsigned int n
, wxListItem
* item
);
220 virtual void MacSetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
* item
);
221 virtual void MacGetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
& item
);
222 virtual void UpdateState(wxMacDataItem
* dataItem
, wxListItem
* item
);
223 int GetFlags() { return m_flags
; }
226 // we need to override to provide specialized handling for virtual wxListCtrls
227 virtual OSStatus
GetSetItemData(DataBrowserItemID itemID
,
228 DataBrowserPropertyID property
,
229 DataBrowserItemDataRef itemData
,
230 Boolean changeValue
);
232 virtual void ItemNotification(
233 DataBrowserItemID itemID
,
234 DataBrowserItemNotification message
,
235 DataBrowserItemDataRef itemData
);
237 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
238 DataBrowserItemID itemTwoID
,
239 DataBrowserPropertyID sortProperty
);
241 static pascal void DataBrowserDrawItemProc(ControlRef browser
,
242 DataBrowserItemID item
,
243 DataBrowserPropertyID property
,
244 DataBrowserItemState itemState
,
247 Boolean colorDevice
);
249 virtual void DrawItem(DataBrowserItemID itemID
,
250 DataBrowserPropertyID property
,
251 DataBrowserItemState itemState
,
252 const Rect
*itemRect
,
254 Boolean colorDevice
);
256 static pascal Boolean
DataBrowserEditTextProc(ControlRef browser
,
257 DataBrowserItemID item
,
258 DataBrowserPropertyID property
,
259 CFStringRef theString
,
260 Rect
*maxEditTextRect
,
261 Boolean
*shrinkToFit
);
263 static pascal Boolean
DataBrowserHitTestProc(ControlRef
WXUNUSED(browser
),
264 DataBrowserItemID
WXUNUSED(itemID
),
265 DataBrowserPropertyID
WXUNUSED(property
),
266 const Rect
*WXUNUSED(theRect
),
267 const Rect
*WXUNUSED(mouseRect
)) { return true; }
269 virtual bool ConfirmEditText(DataBrowserItemID item
,
270 DataBrowserPropertyID property
,
271 CFStringRef theString
,
272 Rect
*maxEditTextRect
,
273 Boolean
*shrinkToFit
);
277 wxClientDataType m_clientDataItemsType
;
280 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataBrowserListCtrlControl
)
283 class wxMacListCtrlEventDelegate
: public wxEvtHandler
286 wxMacListCtrlEventDelegate( wxListCtrl
* list
, int id
);
287 virtual bool ProcessEvent( wxEvent
& event
);
294 wxMacListCtrlEventDelegate::wxMacListCtrlEventDelegate( wxListCtrl
* list
, int id
)
300 bool wxMacListCtrlEventDelegate::ProcessEvent( wxEvent
& event
)
302 // even though we use a generic list ctrl underneath, make sure
303 // we present ourselves as wxListCtrl.
304 event
.SetEventObject( m_list
);
307 if ( !event
.IsKindOf( CLASSINFO( wxCommandEvent
) ) )
309 if (m_list
->HandleWindowEvent( event
))
312 return wxEvtHandler::ProcessEvent(event
);
315 //-----------------------------------------------------------------------------
316 // wxListCtrlRenameTimer (internal)
317 //-----------------------------------------------------------------------------
319 class wxListCtrlRenameTimer
: public wxTimer
325 wxListCtrlRenameTimer( wxListCtrl
*owner
);
329 //-----------------------------------------------------------------------------
330 // wxListCtrlTextCtrlWrapper: wraps a wxTextCtrl to make it work for inline editing
331 //-----------------------------------------------------------------------------
333 class wxListCtrlTextCtrlWrapper
: public wxEvtHandler
336 // NB: text must be a valid object but not Create()d yet
337 wxListCtrlTextCtrlWrapper(wxListCtrl
*owner
,
341 wxTextCtrl
*GetText() const { return m_text
; }
343 void AcceptChangesAndFinish();
346 void OnChar( wxKeyEvent
&event
);
347 void OnKeyUp( wxKeyEvent
&event
);
348 void OnKillFocus( wxFocusEvent
&event
);
350 bool AcceptChanges();
356 wxString m_startValue
;
359 bool m_aboutToFinish
;
361 DECLARE_EVENT_TABLE()
364 //-----------------------------------------------------------------------------
365 // wxListCtrlRenameTimer (internal)
366 //-----------------------------------------------------------------------------
368 wxListCtrlRenameTimer::wxListCtrlRenameTimer( wxListCtrl
*owner
)
373 void wxListCtrlRenameTimer::Notify()
375 m_owner
->OnRenameTimer();
378 //-----------------------------------------------------------------------------
379 // wxListCtrlTextCtrlWrapper (internal)
380 //-----------------------------------------------------------------------------
382 BEGIN_EVENT_TABLE(wxListCtrlTextCtrlWrapper
, wxEvtHandler
)
383 EVT_CHAR (wxListCtrlTextCtrlWrapper::OnChar
)
384 EVT_KEY_UP (wxListCtrlTextCtrlWrapper::OnKeyUp
)
385 EVT_KILL_FOCUS (wxListCtrlTextCtrlWrapper::OnKillFocus
)
388 wxListCtrlTextCtrlWrapper::wxListCtrlTextCtrlWrapper(wxListCtrl
*owner
,
391 : m_startValue(owner
->GetItemText(itemEdit
)),
392 m_itemEdited(itemEdit
)
397 m_aboutToFinish
= false;
401 owner
->GetItemRect(itemEdit
, rectLabel
);
403 m_text
->Create(owner
, wxID_ANY
, m_startValue
,
404 wxPoint(rectLabel
.x
+offset
,rectLabel
.y
),
405 wxSize(rectLabel
.width
-offset
,rectLabel
.height
));
408 m_text
->PushEventHandler(this);
411 void wxListCtrlTextCtrlWrapper::Finish()
417 m_text
->RemoveEventHandler(this);
418 m_owner
->FinishEditing(m_text
);
420 wxPendingDelete
.Append( this );
424 bool wxListCtrlTextCtrlWrapper::AcceptChanges()
426 const wxString value
= m_text
->GetValue();
428 if ( value
== m_startValue
)
429 // nothing changed, always accept
432 if ( !m_owner
->OnRenameAccept(m_itemEdited
, value
) )
433 // vetoed by the user
436 // accepted, do rename the item
437 m_owner
->SetItemText(m_itemEdited
, value
);
442 void wxListCtrlTextCtrlWrapper::AcceptChangesAndFinish()
444 m_aboutToFinish
= true;
446 // Notify the owner about the changes
449 // Even if vetoed, close the control (consistent with MSW)
453 void wxListCtrlTextCtrlWrapper::OnChar( wxKeyEvent
&event
)
455 switch ( event
.m_keyCode
)
458 AcceptChangesAndFinish();
462 m_owner
->OnRenameCancelled( m_itemEdited
);
471 void wxListCtrlTextCtrlWrapper::OnKeyUp( wxKeyEvent
&event
)
479 // auto-grow the textctrl:
480 wxSize parentSize
= m_owner
->GetSize();
481 wxPoint myPos
= m_text
->GetPosition();
482 wxSize mySize
= m_text
->GetSize();
484 m_text
->GetTextExtent(m_text
->GetValue() + _T("MM"), &sx
, &sy
);
485 if (myPos
.x
+ sx
> parentSize
.x
)
486 sx
= parentSize
.x
- myPos
.x
;
489 m_text
->SetSize(sx
, wxDefaultCoord
);
494 void wxListCtrlTextCtrlWrapper::OnKillFocus( wxFocusEvent
&event
)
496 if ( !m_finished
&& !m_aboutToFinish
)
498 if ( !AcceptChanges() )
499 m_owner
->OnRenameCancelled( m_itemEdited
);
504 // We must let the native text control handle focus
508 BEGIN_EVENT_TABLE(wxListCtrl
, wxControl
)
509 EVT_LEFT_DOWN(wxListCtrl::OnLeftDown
)
510 EVT_LEFT_DCLICK(wxListCtrl::OnDblClick
)
511 EVT_MIDDLE_DOWN(wxListCtrl::OnMiddleDown
)
512 EVT_RIGHT_DOWN(wxListCtrl::OnRightDown
)
513 EVT_CHAR(wxListCtrl::OnChar
)
516 // ============================================================================
518 // ============================================================================
520 wxMacListControl
* wxListCtrl::GetPeer() const
522 wxMacDataBrowserListCtrlControl
*lb
= wxDynamicCast(m_peer
,wxMacDataBrowserListCtrlControl
);
523 return lb
? wx_static_cast(wxMacListControl
*,lb
) : 0 ;
526 // ----------------------------------------------------------------------------
527 // wxListCtrl construction
528 // ----------------------------------------------------------------------------
530 void wxListCtrl::Init()
532 m_imageListNormal
= NULL
;
533 m_imageListSmall
= NULL
;
534 m_imageListState
= NULL
;
536 // keep track of if we created our own image lists, or if they were assigned
538 m_ownsImageListNormal
= m_ownsImageListSmall
= m_ownsImageListState
= false;
542 m_genericImpl
= NULL
;
544 m_compareFunc
= NULL
;
545 m_compareFuncData
= 0;
546 m_colsInfo
= wxColumnList();
547 m_textColor
= wxNullColour
;
548 m_bgColor
= wxNullColour
;
549 m_textctrlWrapper
= NULL
;
551 m_renameTimer
= new wxListCtrlRenameTimer( this );
554 class wxGenericListCtrlHook
: public wxGenericListCtrl
557 wxGenericListCtrlHook(wxListCtrl
* parent
,
562 const wxValidator
& validator
,
563 const wxString
& name
)
564 : wxGenericListCtrl(parent
, id
, pos
, size
, style
, validator
, name
),
565 m_nativeListCtrl(parent
)
570 virtual wxListItemAttr
* OnGetItemAttr(long item
) const
572 return m_nativeListCtrl
->OnGetItemAttr(item
);
575 virtual int OnGetItemImage(long item
) const
577 return m_nativeListCtrl
->OnGetItemImage(item
);
580 virtual int OnGetItemColumnImage(long item
, long column
) const
582 return m_nativeListCtrl
->OnGetItemColumnImage(item
, column
);
585 virtual wxString
OnGetItemText(long item
, long column
) const
587 return m_nativeListCtrl
->OnGetItemText(item
, column
);
590 wxListCtrl
* m_nativeListCtrl
;
594 void wxListCtrl::OnLeftDown(wxMouseEvent
& event
)
596 if ( m_textctrlWrapper
)
599 m_textctrlWrapper
->AcceptChangesAndFinish();
603 long current
= HitTest(event
.GetPosition(), hitResult
);
604 if ((current
== m_current
) &&
605 (hitResult
== wxLIST_HITTEST_ONITEM
) &&
606 HasFlag(wxLC_EDIT_LABELS
) )
608 m_renameTimer
->Start( 100, true );
617 void wxListCtrl::OnDblClick(wxMouseEvent
& event
)
623 #if wxABI_VERSION >= 20801
624 void wxListCtrl::OnRightDown(wxMouseEvent
& event
)
627 FireMouseEvent(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK
, event
.GetPosition());
631 void wxListCtrl::OnMiddleDown(wxMouseEvent
& event
)
634 FireMouseEvent(wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK
, event
.GetPosition());
638 void wxListCtrl::FireMouseEvent(wxEventType eventType
, wxPoint position
)
640 wxListEvent
le( eventType
, GetId() );
641 le
.SetEventObject(this);
642 le
.m_pointDrag
= position
;
646 long item
= HitTest(position
, flags
);
647 if (flags
& wxLIST_HITTEST_ONITEM
)
649 le
.m_itemIndex
= item
;
650 le
.m_item
.m_itemId
= item
;
652 HandleWindowEvent(le
);
656 void wxListCtrl::OnChar(wxKeyEvent
& event
)
662 wxListEvent
le( wxEVT_COMMAND_LIST_KEY_DOWN
, GetId() );
663 le
.SetEventObject(this);
664 le
.m_code
= event
.GetKeyCode();
669 // if m_current isn't set, check if there's been a selection
670 // made before continuing
671 m_current
= GetNextItem(-1, wxLIST_NEXT_BELOW
, wxLIST_STATE_SELECTED
);
674 // We need to determine m_current ourselves when navigation keys
675 // are used. Note that PAGEUP and PAGEDOWN do not alter the current
676 // item on native Mac ListCtrl, so we only handle up and down keys.
677 switch ( event
.GetKeyCode() )
688 if ( m_current
< GetItemCount() - 1 )
691 m_current
= GetItemCount() - 1;
698 le
.m_itemIndex
= m_current
;
699 le
.m_item
.m_itemId
= m_current
;
701 HandleWindowEvent(le
);
708 bool wxListCtrl::Create(wxWindow
*parent
,
713 const wxValidator
& validator
,
714 const wxString
& name
)
717 // for now, we'll always use the generic list control for ICON and LIST views,
718 // because they dynamically change the number of columns on resize.
719 // Also, allow the user to set it to use the list ctrl as well.
720 if ( (wxSystemOptions::HasOption( wxMAC_ALWAYS_USE_GENERIC_LISTCTRL
)
721 && (wxSystemOptions::GetOptionInt( wxMAC_ALWAYS_USE_GENERIC_LISTCTRL
) == 1)) ||
722 (style
& wxLC_ICON
) || (style
& wxLC_SMALL_ICON
) || (style
& wxLC_LIST
) )
724 m_macIsUserPane
= true;
726 long paneStyle
= style
;
727 paneStyle
&= ~wxSIMPLE_BORDER
;
728 paneStyle
&= ~wxDOUBLE_BORDER
;
729 paneStyle
&= ~wxSUNKEN_BORDER
;
730 paneStyle
&= ~wxRAISED_BORDER
;
731 paneStyle
&= ~wxSTATIC_BORDER
;
732 if ( !wxWindow::Create(parent
, id
, pos
, size
, paneStyle
| wxNO_BORDER
, name
) )
735 // since the generic control is a child, make sure we position it at 0, 0
736 m_genericImpl
= new wxGenericListCtrlHook(this, id
, wxPoint(0, 0), size
, style
, validator
, name
);
737 m_genericImpl
->PushEventHandler( new wxMacListCtrlEventDelegate( this, GetId() ) );
743 m_macIsUserPane
= false;
744 if ( !wxWindow::Create(parent
, id
, pos
, size
, style
& ~(wxHSCROLL
| wxVSCROLL
), name
) )
746 m_dbImpl
= new wxMacDataBrowserListCtrlControl( this, pos
, size
, style
);
749 MacPostControlCreate( pos
, size
);
751 InstallControlEventHandler( m_peer
->GetControlRef() , GetwxMacListCtrlEventHandlerUPP(),
752 GetEventTypeCount(eventList
), eventList
, this,
753 (EventHandlerRef
*)&m_macListCtrlEventHandler
);
759 wxListCtrl::~wxListCtrl()
763 m_genericImpl
->PopEventHandler(/* deleteHandler = */ true);
766 if (m_ownsImageListNormal
)
767 delete m_imageListNormal
;
768 if (m_ownsImageListSmall
)
769 delete m_imageListSmall
;
770 if (m_ownsImageListState
)
771 delete m_imageListState
;
773 delete m_renameTimer
;
775 WX_CLEAR_LIST(wxColumnList
, m_colsInfo
);
780 wxListCtrl::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
782 wxVisualAttributes attr
;
784 attr
.colFg
= wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT
);
785 attr
.colBg
= wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOX
);
786 attr
.font
.MacCreateFromThemeFont(kThemeViewsFont
);
791 // ----------------------------------------------------------------------------
792 // set/get/change style
793 // ----------------------------------------------------------------------------
795 // Add or remove a single window style
796 void wxListCtrl::SetSingleStyle(long style
, bool add
)
798 long flag
= GetWindowStyleFlag();
800 // Get rid of conflicting styles
803 if ( style
& wxLC_MASK_TYPE
)
804 flag
= flag
& ~wxLC_MASK_TYPE
;
805 if ( style
& wxLC_MASK_ALIGN
)
806 flag
= flag
& ~wxLC_MASK_ALIGN
;
807 if ( style
& wxLC_MASK_SORT
)
808 flag
= flag
& ~wxLC_MASK_SORT
;
816 SetWindowStyleFlag(flag
);
819 // Set the whole window style
820 void wxListCtrl::SetWindowStyleFlag(long flag
)
822 if ( flag
!= m_windowStyle
)
824 m_windowStyle
= flag
;
828 m_genericImpl
->SetWindowStyleFlag(flag
);
835 void wxListCtrl::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
837 wxControl::DoSetSize(x
, y
, width
, height
, sizeFlags
);
840 m_genericImpl
->SetSize(0, 0, width
, height
, sizeFlags
);
842 // determine if we need a horizontal scrollbar, and add it if so
846 for (int column
= 0; column
< GetColumnCount(); column
++)
848 totalWidth
+= m_dbImpl
->GetColumnWidth( column
);
851 if ( !(m_dbImpl
->GetFlags() & wxHSCROLL
) )
853 Boolean vertScrollBar
;
854 GetDataBrowserHasScrollBars( m_dbImpl
->GetControlRef(), NULL
, &vertScrollBar
);
855 if (totalWidth
> width
)
856 SetDataBrowserHasScrollBars( m_dbImpl
->GetControlRef(), true, vertScrollBar
);
858 SetDataBrowserHasScrollBars( m_dbImpl
->GetControlRef(), false, vertScrollBar
);
863 wxSize
wxListCtrl::DoGetBestSize() const
865 return wxWindow::DoGetBestSize();
868 bool wxListCtrl::SetFont(const wxFont
& font
)
871 rv
= wxControl::SetFont(font
);
873 rv
= m_genericImpl
->SetFont(font
);
877 bool wxListCtrl::SetForegroundColour(const wxColour
& colour
)
881 rv
= m_genericImpl
->SetForegroundColour(colour
);
883 SetTextColour(colour
);
887 bool wxListCtrl::SetBackgroundColour(const wxColour
& colour
)
891 rv
= m_genericImpl
->SetBackgroundColour(colour
);
897 wxColour
wxListCtrl::GetBackgroundColour()
900 return m_genericImpl
->GetBackgroundColour();
907 // ----------------------------------------------------------------------------
909 // ----------------------------------------------------------------------------
911 // Gets information about this column
912 bool wxListCtrl::GetColumn(int col
, wxListItem
& item
) const
915 return m_genericImpl
->GetColumn(col
, item
);
921 wxColumnList::compatibility_iterator node
= m_colsInfo
.Item( col
);
922 wxASSERT_MSG( node
, _T("invalid column index in wxMacListCtrlItem") );
923 wxListItem
* column
= node
->GetData();
925 long mask
= column
->GetMask();
926 if (mask
& wxLIST_MASK_TEXT
)
927 item
.SetText(column
->GetText());
928 if (mask
& wxLIST_MASK_DATA
)
929 item
.SetData(column
->GetData());
930 if (mask
& wxLIST_MASK_IMAGE
)
931 item
.SetImage(column
->GetImage());
932 if (mask
& wxLIST_MASK_STATE
)
933 item
.SetState(column
->GetState());
934 if (mask
& wxLIST_MASK_FORMAT
)
935 item
.SetAlign(column
->GetAlign());
936 if (mask
& wxLIST_MASK_WIDTH
)
937 item
.SetWidth(column
->GetWidth());
943 // Sets information about this column
944 bool wxListCtrl::SetColumn(int col
, wxListItem
& item
)
947 return m_genericImpl
->SetColumn(col
, item
);
951 long mask
= item
.GetMask();
952 if ( col
>= (int)m_colsInfo
.GetCount() )
954 wxListItem
* listItem
= new wxListItem(item
);
955 m_colsInfo
.Append( listItem
);
960 GetColumn( col
, listItem
);
962 if (mask
& wxLIST_MASK_TEXT
)
963 listItem
.SetText(item
.GetText());
964 if (mask
& wxLIST_MASK_DATA
)
965 listItem
.SetData(item
.GetData());
966 if (mask
& wxLIST_MASK_IMAGE
)
967 listItem
.SetImage(item
.GetImage());
968 if (mask
& wxLIST_MASK_STATE
)
969 listItem
.SetState(item
.GetState());
970 if (mask
& wxLIST_MASK_FORMAT
)
971 listItem
.SetAlign(item
.GetAlign());
972 if (mask
& wxLIST_MASK_WIDTH
)
973 listItem
.SetWidth(item
.GetWidth());
976 // change the appearance in the databrowser.
977 DataBrowserListViewHeaderDesc columnDesc
;
978 columnDesc
.version
=kDataBrowserListViewLatestHeaderDesc
;
979 verify_noerr( m_dbImpl
->GetHeaderDesc( kMinColumnId
+ col
, &columnDesc
) );
982 if (item.GetMask() & wxLIST_MASK_TEXT)
986 enc = GetFont().GetEncoding();
988 enc = wxLocale::GetSystemEncoding();
989 wxCFStringRef cfTitle;
990 cfTitle.Assign( item.GetText() , enc );
991 if(columnDesc.titleString)
992 CFRelease(columnDesc.titleString);
993 columnDesc.titleString = cfTitle;
997 if (item
.GetMask() & wxLIST_MASK_IMAGE
&& item
.GetImage() != -1 )
999 wxImageList
* imageList
= GetImageList(wxIMAGE_LIST_SMALL
);
1000 if (imageList
&& imageList
->GetImageCount() > 0 )
1002 wxBitmap bmp
= imageList
->GetBitmap( item
.GetImage() );
1003 IconRef icon
= bmp
.GetIconRef();
1004 columnDesc
.btnContentInfo
.u
.iconRef
= icon
;
1005 columnDesc
.btnContentInfo
.contentType
= kControlContentIconRef
;
1009 verify_noerr( m_dbImpl
->SetHeaderDesc( kMinColumnId
+ col
, &columnDesc
) );
1015 int wxListCtrl::GetColumnCount() const
1018 return m_genericImpl
->GetColumnCount();
1023 m_dbImpl
->GetColumnCount(&count
);
1030 // Gets the column width
1031 int wxListCtrl::GetColumnWidth(int col
) const
1034 return m_genericImpl
->GetColumnWidth(col
);
1038 return m_dbImpl
->GetColumnWidth(col
);
1044 // Sets the column width
1045 bool wxListCtrl::SetColumnWidth(int col
, int width
)
1048 return m_genericImpl
->SetColumnWidth(col
, width
);
1052 if ( width
== wxLIST_AUTOSIZE_USEHEADER
)
1054 width
= 150; // FIXME
1059 for (int column
= 0; column
< GetColumnCount(); column
++)
1062 GetColumn(column
, colInfo
);
1064 colInfo
.SetWidth(width
);
1065 SetColumn(column
, colInfo
);
1067 const int mywidth
= (width
== wxLIST_AUTOSIZE
)
1068 ? CalcColumnAutoWidth(column
) : width
;
1069 m_dbImpl
->SetColumnWidth(column
, mywidth
);
1074 if ( width
== wxLIST_AUTOSIZE
)
1075 width
= CalcColumnAutoWidth(col
);
1078 GetColumn(col
, colInfo
);
1080 colInfo
.SetWidth(width
);
1081 SetColumn(col
, colInfo
);
1082 m_dbImpl
->SetColumnWidth(col
, width
);
1090 // Gets the number of items that can fit vertically in the
1091 // visible area of the list control (list or report view)
1092 // or the total number of items in the list control (icon
1093 // or small icon view)
1094 int wxListCtrl::GetCountPerPage() const
1097 return m_genericImpl
->GetCountPerPage();
1102 m_dbImpl
->GetDefaultRowHeight( &height
);
1104 return GetClientSize().y
/ height
;
1110 // Gets the edit control for editing labels.
1111 wxTextCtrl
* wxListCtrl::GetEditControl() const
1114 return m_genericImpl
->GetEditControl();
1119 // Gets information about the item
1120 bool wxListCtrl::GetItem(wxListItem
& info
) const
1123 return m_genericImpl
->GetItem(info
);
1129 if (info
.m_itemId
>= 0 && info
.m_itemId
< GetItemCount())
1131 m_dbImpl
->MacGetColumnInfo(info
.m_itemId
, info
.m_col
, info
);
1132 if (info
.GetMask() & wxLIST_MASK_STATE
)
1134 DataBrowserItemID id
= (DataBrowserItemID
)m_dbImpl
->GetItemFromLine(info
.m_itemId
);
1135 if (IsDataBrowserItemSelected( m_dbImpl
->GetControlRef(), id
))
1136 info
.SetState(info
.GetState() | wxLIST_STATE_SELECTED
);
1142 if (info
.m_itemId
>= 0 && info
.m_itemId
< GetItemCount())
1144 info
.SetText( OnGetItemText(info
.m_itemId
, info
.m_col
) );
1145 info
.SetImage( OnGetItemColumnImage(info
.m_itemId
, info
.m_col
) );
1146 if (info
.GetMask() & wxLIST_MASK_STATE
)
1148 if (IsDataBrowserItemSelected( m_dbImpl
->GetControlRef(), info
.m_itemId
+1 ))
1149 info
.SetState(info
.GetState() | wxLIST_STATE_SELECTED
);
1152 wxListItemAttr
* attrs
= OnGetItemAttr( info
.m_itemId
);
1155 info
.SetFont( attrs
->GetFont() );
1156 info
.SetBackgroundColour( attrs
->GetBackgroundColour() );
1157 info
.SetTextColour( attrs
->GetTextColour() );
1162 bool success
= true;
1166 // Sets information about the item
1167 bool wxListCtrl::SetItem(wxListItem
& info
)
1170 return m_genericImpl
->SetItem(info
);
1173 m_dbImpl
->MacSetColumnInfo( info
.m_itemId
, info
.m_col
, &info
);
1178 long wxListCtrl::SetItem(long index
, int col
, const wxString
& label
, int imageId
)
1181 return m_genericImpl
->SetItem(index
, col
, label
, imageId
);
1184 info
.m_text
= label
;
1185 info
.m_mask
= wxLIST_MASK_TEXT
;
1186 info
.m_itemId
= index
;
1190 info
.m_image
= imageId
;
1191 info
.m_mask
|= wxLIST_MASK_IMAGE
;
1193 return SetItem(info
);
1197 // Gets the item state
1198 int wxListCtrl::GetItemState(long item
, long stateMask
) const
1201 return m_genericImpl
->GetItemState(item
, stateMask
);
1205 if ( HasFlag(wxLC_VIRTUAL
) )
1207 if (stateMask
== wxLIST_STATE_SELECTED
)
1209 if (IsDataBrowserItemSelected( m_dbImpl
->GetControlRef(), item
+1 ))
1210 return wxLIST_STATE_SELECTED
;
1219 info
.m_mask
= wxLIST_MASK_STATE
;
1220 info
.m_stateMask
= stateMask
;
1221 info
.m_itemId
= item
;
1226 return info
.m_state
;
1233 // Sets the item state
1234 bool wxListCtrl::SetItemState(long item
, long state
, long stateMask
)
1237 return m_genericImpl
->SetItemState(item
, state
, stateMask
);
1241 DataBrowserSetOption option
= kDataBrowserItemsAdd
;
1242 if ( (stateMask
& wxLIST_STATE_SELECTED
) && state
== 0 )
1243 option
= kDataBrowserItemsRemove
;
1247 if ( HasFlag(wxLC_VIRTUAL
) )
1249 wxMacDataItemBrowserSelectionSuppressor
suppressor(m_dbImpl
);
1250 m_dbImpl
->SetSelectedAllItems(option
);
1254 for(int i
= 0; i
< GetItemCount();i
++)
1258 info
.m_mask
= wxLIST_MASK_STATE
;
1259 info
.m_stateMask
= stateMask
;
1260 info
.m_state
= state
;
1267 if ( HasFlag(wxLC_VIRTUAL
) )
1269 long itemID
= item
+1;
1270 bool isSelected
= IsDataBrowserItemSelected(m_dbImpl
->GetControlRef(), (DataBrowserItemID
)itemID
);
1271 bool isSelectedState
= (state
== wxLIST_STATE_SELECTED
);
1273 // toggle the selection state if wxListInfo state and actual state don't match.
1274 if ( (stateMask
& wxLIST_STATE_SELECTED
) && isSelected
!= isSelectedState
)
1276 SetDataBrowserSelectedItems(m_dbImpl
->GetControlRef(), 1, (DataBrowserItemID
*)&itemID
, option
);
1282 info
.m_itemId
= item
;
1283 info
.m_mask
= wxLIST_MASK_STATE
;
1284 info
.m_stateMask
= stateMask
;
1285 info
.m_state
= state
;
1286 return SetItem(info
);
1293 // Sets the item image
1294 bool wxListCtrl::SetItemImage(long item
, int image
, int WXUNUSED(selImage
))
1296 return SetItemColumnImage(item
, 0, image
);
1299 // Sets the item image
1300 bool wxListCtrl::SetItemColumnImage(long item
, long column
, int image
)
1303 return m_genericImpl
->SetItemColumnImage(item
, column
, image
);
1307 info
.m_mask
= wxLIST_MASK_IMAGE
;
1308 info
.m_image
= image
;
1309 info
.m_itemId
= item
;
1310 info
.m_col
= column
;
1312 return SetItem(info
);
1315 // Gets the item text
1316 wxString
wxListCtrl::GetItemText(long item
) const
1319 return m_genericImpl
->GetItemText(item
);
1323 info
.m_mask
= wxLIST_MASK_TEXT
;
1324 info
.m_itemId
= item
;
1327 return wxEmptyString
;
1331 // Sets the item text
1332 void wxListCtrl::SetItemText(long item
, const wxString
& str
)
1335 return m_genericImpl
->SetItemText(item
, str
);
1339 info
.m_mask
= wxLIST_MASK_TEXT
;
1340 info
.m_itemId
= item
;
1346 // Gets the item data
1347 long wxListCtrl::GetItemData(long item
) const
1350 return m_genericImpl
->GetItemData(item
);
1354 info
.m_mask
= wxLIST_MASK_DATA
;
1355 info
.m_itemId
= item
;
1362 // Sets the item data
1363 bool wxListCtrl::SetItemPtrData(long item
, wxUIntPtr data
)
1366 return m_genericImpl
->SetItemData(item
, data
);
1370 info
.m_mask
= wxLIST_MASK_DATA
;
1371 info
.m_itemId
= item
;
1374 return SetItem(info
);
1377 wxRect
wxListCtrl::GetViewRect() const
1379 wxASSERT_MSG( !HasFlag(wxLC_REPORT
| wxLC_LIST
),
1380 _T("wxListCtrl::GetViewRect() only works in icon mode") );
1383 return m_genericImpl
->GetViewRect();
1389 // Gets the item rectangle
1390 bool wxListCtrl::GetItemRect(long item
, wxRect
& rect
, int code
) const
1393 return m_genericImpl
->GetItemRect(item
, rect
, code
);
1398 DataBrowserItemID id
;
1399 DataBrowserPropertyID col
= kMinColumnId
;
1401 DataBrowserPropertyPart part
= kDataBrowserPropertyEnclosingPart
;
1402 if ( code
== wxLIST_RECT_LABEL
)
1403 part
= kDataBrowserPropertyTextPart
;
1404 else if ( code
== wxLIST_RECT_ICON
)
1405 part
= kDataBrowserPropertyIconPart
;
1407 if ( !(GetWindowStyleFlag() & wxLC_VIRTUAL
) )
1409 wxMacDataItem
* thisItem
= m_dbImpl
->GetItemFromLine(item
);
1410 id
= (DataBrowserItemID
) thisItem
;
1415 GetDataBrowserItemPartBounds( m_dbImpl
->GetControlRef(), id
, col
, part
, &bounds
);
1417 rect
.x
= bounds
.left
;
1418 rect
.y
= bounds
.top
;
1419 rect
.width
= bounds
.right
- bounds
.left
; //GetClientSize().x; // we need the width of the whole row, not just the item.
1420 rect
.height
= bounds
.bottom
- bounds
.top
;
1421 //fprintf("id = %d, bounds = %d, %d, %d, %d\n", id, rect.x, rect.y, rect.width, rect.height);
1426 // Gets the item position
1427 bool wxListCtrl::GetItemPosition(long item
, wxPoint
& pos
) const
1430 return m_genericImpl
->GetItemPosition(item
, pos
);
1432 bool success
= false;
1437 GetItemRect(item
, itemRect
);
1438 pos
= itemRect
.GetPosition();
1445 // Sets the item position.
1446 bool wxListCtrl::SetItemPosition(long item
, const wxPoint
& pos
)
1449 return m_genericImpl
->SetItemPosition(item
, pos
);
1454 // Gets the number of items in the list control
1455 int wxListCtrl::GetItemCount() const
1458 return m_genericImpl
->GetItemCount();
1461 return m_dbImpl
->MacGetCount();
1466 void wxListCtrl::SetItemSpacing( int spacing
, bool isSmall
)
1469 m_genericImpl
->SetItemSpacing(spacing
, isSmall
);
1472 wxSize
wxListCtrl::GetItemSpacing() const
1475 return m_genericImpl
->GetItemSpacing();
1477 return wxSize(0, 0);
1480 void wxListCtrl::SetItemTextColour( long item
, const wxColour
&col
)
1484 m_genericImpl
->SetItemTextColour(item
, col
);
1489 info
.m_itemId
= item
;
1490 info
.SetTextColour( col
);
1494 wxColour
wxListCtrl::GetItemTextColour( long item
) const
1497 return m_genericImpl
->GetItemTextColour(item
);
1503 return info
.GetTextColour();
1505 return wxNullColour
;
1508 void wxListCtrl::SetItemBackgroundColour( long item
, const wxColour
&col
)
1512 m_genericImpl
->SetItemBackgroundColour(item
, col
);
1517 info
.m_itemId
= item
;
1518 info
.SetBackgroundColour( col
);
1522 wxColour
wxListCtrl::GetItemBackgroundColour( long item
) const
1525 return m_genericImpl
->GetItemBackgroundColour(item
);
1531 return info
.GetBackgroundColour();
1533 return wxNullColour
;
1536 void wxListCtrl::SetItemFont( long item
, const wxFont
&f
)
1540 m_genericImpl
->SetItemFont(item
, f
);
1545 info
.m_itemId
= item
;
1550 wxFont
wxListCtrl::GetItemFont( long item
) const
1553 return m_genericImpl
->GetItemFont(item
);
1559 return info
.GetFont();
1565 // Gets the number of selected items in the list control
1566 int wxListCtrl::GetSelectedItemCount() const
1569 return m_genericImpl
->GetSelectedItemCount();
1572 return m_dbImpl
->GetSelectedItemCount(NULL
, true);
1577 // Gets the text colour of the listview
1578 wxColour
wxListCtrl::GetTextColour() const
1581 return m_genericImpl
->GetTextColour();
1583 // TODO: we need owner drawn list items to customize text color.
1587 return wxNullColour
;
1590 // Sets the text colour of the listview
1591 void wxListCtrl::SetTextColour(const wxColour
& col
)
1595 m_genericImpl
->SetTextColour(col
);
1603 // Gets the index of the topmost visible item when in
1604 // list or report view
1605 long wxListCtrl::GetTopItem() const
1608 return m_genericImpl
->GetTopItem();
1613 long item
= HitTest( wxPoint(1, 1), flags
);
1614 if (flags
== wxLIST_HITTEST_ONITEM
)
1621 // Searches for an item, starting from 'item'.
1622 // 'geometry' is one of
1623 // wxLIST_NEXT_ABOVE/ALL/BELOW/LEFT/RIGHT.
1624 // 'state' is a state bit flag, one or more of
1625 // wxLIST_STATE_DROPHILITED/FOCUSED/SELECTED/CUT.
1626 // item can be -1 to find the first item that matches the
1628 // Returns the item or -1 if unsuccessful.
1629 long wxListCtrl::GetNextItem(long item
, int geom
, int state
) const
1632 return m_genericImpl
->GetNextItem(item
, geom
, state
);
1634 // TODO: implement all geometry and state options?
1637 if ( geom
== wxLIST_NEXT_ALL
|| geom
== wxLIST_NEXT_BELOW
)
1639 long count
= m_dbImpl
->MacGetCount() ;
1640 for ( long line
= item
+ 1 ; line
< count
; line
++ )
1642 DataBrowserItemID id
= line
+ 1;
1644 id
= (DataBrowserItemID
)m_dbImpl
->GetItemFromLine(line
);
1646 if ( (state
== wxLIST_STATE_DONTCARE
) )
1649 if ( (state
& wxLIST_STATE_SELECTED
) && IsDataBrowserItemSelected(m_dbImpl
->GetControlRef(), id
) )
1654 if ( geom
== wxLIST_NEXT_ABOVE
)
1658 item2
= m_dbImpl
->MacGetCount();
1660 for ( long line
= item2
- 1 ; line
>= 0; line
-- )
1662 DataBrowserItemID id
= line
+ 1;
1664 id
= (DataBrowserItemID
)m_dbImpl
->GetItemFromLine(line
);
1666 if ( (state
== wxLIST_STATE_DONTCARE
) )
1669 if ( (state
& wxLIST_STATE_SELECTED
) && IsDataBrowserItemSelected(m_dbImpl
->GetControlRef(), id
) )
1679 wxImageList
*wxListCtrl::GetImageList(int which
) const
1682 return m_genericImpl
->GetImageList(which
);
1684 if ( which
== wxIMAGE_LIST_NORMAL
)
1686 return m_imageListNormal
;
1688 else if ( which
== wxIMAGE_LIST_SMALL
)
1690 return m_imageListSmall
;
1692 else if ( which
== wxIMAGE_LIST_STATE
)
1694 return m_imageListState
;
1699 void wxListCtrl::SetImageList(wxImageList
*imageList
, int which
)
1703 m_genericImpl
->SetImageList(imageList
, which
);
1707 if ( which
== wxIMAGE_LIST_NORMAL
)
1709 if (m_ownsImageListNormal
) delete m_imageListNormal
;
1710 m_imageListNormal
= imageList
;
1711 m_ownsImageListNormal
= false;
1713 else if ( which
== wxIMAGE_LIST_SMALL
)
1715 if (m_ownsImageListSmall
) delete m_imageListSmall
;
1716 m_imageListSmall
= imageList
;
1717 m_ownsImageListSmall
= false;
1719 else if ( which
== wxIMAGE_LIST_STATE
)
1721 if (m_ownsImageListState
) delete m_imageListState
;
1722 m_imageListState
= imageList
;
1723 m_ownsImageListState
= false;
1727 void wxListCtrl::AssignImageList(wxImageList
*imageList
, int which
)
1731 m_genericImpl
->AssignImageList(imageList
, which
);
1735 SetImageList(imageList
, which
);
1736 if ( which
== wxIMAGE_LIST_NORMAL
)
1737 m_ownsImageListNormal
= true;
1738 else if ( which
== wxIMAGE_LIST_SMALL
)
1739 m_ownsImageListSmall
= true;
1740 else if ( which
== wxIMAGE_LIST_STATE
)
1741 m_ownsImageListState
= true;
1744 // ----------------------------------------------------------------------------
1746 // ----------------------------------------------------------------------------
1748 // Arranges the items
1749 bool wxListCtrl::Arrange(int flag
)
1752 return m_genericImpl
->Arrange(flag
);
1757 bool wxListCtrl::DeleteItem(long item
)
1760 return m_genericImpl
->DeleteItem(item
);
1764 m_dbImpl
->MacDelete(item
);
1765 wxListEvent
event( wxEVT_COMMAND_LIST_DELETE_ITEM
, GetId() );
1766 event
.SetEventObject( this );
1767 event
.m_itemIndex
= item
;
1768 HandleWindowEvent( event
);
1774 // Deletes all items
1775 bool wxListCtrl::DeleteAllItems()
1778 return m_genericImpl
->DeleteAllItems();
1782 m_dbImpl
->MacClear();
1783 wxListEvent
event( wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS
, GetId() );
1784 event
.SetEventObject( this );
1785 HandleWindowEvent( event
);
1790 // Deletes all items
1791 bool wxListCtrl::DeleteAllColumns()
1794 return m_genericImpl
->DeleteAllColumns();
1799 m_dbImpl
->GetColumnCount(&cols
);
1800 for (UInt32 col
= 0; col
< cols
; col
++)
1810 bool wxListCtrl::DeleteColumn(int col
)
1813 return m_genericImpl
->DeleteColumn(col
);
1817 OSStatus err
= m_dbImpl
->RemoveColumn(col
);
1818 return err
== noErr
;
1824 // Clears items, and columns if there are any.
1825 void wxListCtrl::ClearAll()
1829 m_genericImpl
->ClearAll();
1840 wxTextCtrl
* wxListCtrl::EditLabel(long item
, wxClassInfo
* textControlClass
)
1843 return m_genericImpl
->EditLabel(item
, textControlClass
);
1847 wxCHECK_MSG( (item
>= 0) && ((long)item
< GetItemCount()), NULL
,
1848 wxT("wrong index in wxListCtrl::EditLabel()") );
1850 wxASSERT_MSG( textControlClass
->IsKindOf(CLASSINFO(wxTextCtrl
)),
1851 wxT("EditLabel() needs a text control") );
1853 wxListEvent
le( wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
, GetParent()->GetId() );
1854 le
.SetEventObject( this );
1855 le
.m_itemIndex
= item
;
1857 GetItem( le
.m_item
);
1859 if ( GetParent()->HandleWindowEvent( le
) && !le
.IsAllowed() )
1861 // vetoed by user code
1865 wxTextCtrl
* const text
= (wxTextCtrl
*)textControlClass
->CreateObject();
1866 m_textctrlWrapper
= new wxListCtrlTextCtrlWrapper(this, text
, item
);
1867 return m_textctrlWrapper
->GetText();
1872 // End label editing, optionally cancelling the edit
1873 bool wxListCtrl::EndEditLabel(bool WXUNUSED(cancel
))
1875 // TODO: generic impl. doesn't have this method - is it needed for us?
1877 return true; // m_genericImpl->EndEditLabel(cancel);
1880 verify_noerr( SetDataBrowserEditItem(m_dbImpl
->GetControlRef(), kDataBrowserNoItem
, kMinColumnId
) );
1884 // Ensures this item is visible
1885 bool wxListCtrl::EnsureVisible(long item
)
1888 return m_genericImpl
->EnsureVisible(item
);
1892 wxMacDataItem
* dataItem
= m_dbImpl
->GetItemFromLine(item
);
1893 m_dbImpl
->RevealItem(dataItem
, kDataBrowserRevealWithoutSelecting
);
1899 // Find an item whose label matches this string, starting from the item after 'start'
1900 // or the beginning if 'start' is -1.
1901 long wxListCtrl::FindItem(long start
, const wxString
& str
, bool partial
)
1904 return m_genericImpl
->FindItem(start
, str
, partial
);
1906 wxString str_upper
= str
.Upper();
1911 long count
= GetItemCount();
1915 wxString line_upper
= GetItemText(idx
).Upper();
1918 if (line_upper
== str_upper
)
1923 if (line_upper
.find(str_upper
) == 0)
1933 // Find an item whose data matches this data, starting from the item after 'start'
1934 // or the beginning if 'start' is -1.
1935 long wxListCtrl::FindItem(long start
, long data
)
1938 return m_genericImpl
->FindItem(start
, data
);
1943 long count
= GetItemCount();
1947 if (GetItemData(idx
) == data
)
1955 // Find an item nearest this position in the specified direction, starting from
1956 // the item after 'start' or the beginning if 'start' is -1.
1957 long wxListCtrl::FindItem(long start
, const wxPoint
& pt
, int direction
)
1960 return m_genericImpl
->FindItem(start
, pt
, direction
);
1964 // Determines which item (if any) is at the specified point,
1965 // giving details in 'flags' (see wxLIST_HITTEST_... flags above)
1967 wxListCtrl::HitTest(const wxPoint
& point
, int& flags
, long *ptrSubItem
) const
1970 return m_genericImpl
->HitTest(point
, flags
, ptrSubItem
);
1972 flags
= wxLIST_HITTEST_NOWHERE
;
1975 int colHeaderHeight
= 22; // TODO: Find a way to get this value from the db control?
1976 UInt16 rowHeight
= 0;
1977 m_dbImpl
->GetDefaultRowHeight(&rowHeight
);
1980 // get the actual row by taking scroll position into account
1981 UInt32 offsetX
, offsetY
;
1982 m_dbImpl
->GetScrollPosition( &offsetY
, &offsetX
);
1985 if ( !(GetWindowStyleFlag() & wxLC_NO_HEADER
) )
1986 y
-= colHeaderHeight
;
1991 int row
= y
/ rowHeight
;
1992 DataBrowserItemID id
;
1993 m_dbImpl
->GetItemID( (DataBrowserTableViewRowIndex
) row
, &id
);
1995 // TODO: Use GetDataBrowserItemPartBounds to return if we are in icon or label
1996 if ( !(GetWindowStyleFlag() & wxLC_VIRTUAL
) )
1998 wxMacListCtrlItem
* lcItem
;
1999 lcItem
= (wxMacListCtrlItem
*) id
;
2002 flags
= wxLIST_HITTEST_ONITEM
;
2008 if (row
< GetItemCount() )
2010 flags
= wxLIST_HITTEST_ONITEM
;
2019 int wxListCtrl::GetScrollPos(int orient
) const
2022 return m_genericImpl
->GetScrollPos(orient
);
2026 UInt32 offsetX
, offsetY
;
2027 m_dbImpl
->GetScrollPosition( &offsetY
, &offsetX
);
2028 if ( orient
== wxHORIZONTAL
)
2037 // Inserts an item, returning the index of the new item if successful,
2039 long wxListCtrl::InsertItem(wxListItem
& info
)
2041 wxASSERT_MSG( !IsVirtual(), _T("can't be used with virtual controls") );
2044 return m_genericImpl
->InsertItem(info
);
2046 if (m_dbImpl
&& !IsVirtual())
2048 int count
= GetItemCount();
2050 if (info
.m_itemId
> count
)
2051 info
.m_itemId
= count
;
2053 m_dbImpl
->MacInsertItem(info
.m_itemId
, &info
);
2055 wxListEvent
event( wxEVT_COMMAND_LIST_INSERT_ITEM
, GetId() );
2056 event
.SetEventObject( this );
2057 event
.m_itemIndex
= info
.m_itemId
;
2058 HandleWindowEvent( event
);
2059 return info
.m_itemId
;
2064 long wxListCtrl::InsertItem(long index
, const wxString
& label
)
2067 return m_genericImpl
->InsertItem(index
, label
);
2070 info
.m_text
= label
;
2071 info
.m_mask
= wxLIST_MASK_TEXT
;
2072 info
.m_itemId
= index
;
2073 return InsertItem(info
);
2076 // Inserts an image item
2077 long wxListCtrl::InsertItem(long index
, int imageIndex
)
2080 return m_genericImpl
->InsertItem(index
, imageIndex
);
2083 info
.m_image
= imageIndex
;
2084 info
.m_mask
= wxLIST_MASK_IMAGE
;
2085 info
.m_itemId
= index
;
2086 return InsertItem(info
);
2089 // Inserts an image/string item
2090 long wxListCtrl::InsertItem(long index
, const wxString
& label
, int imageIndex
)
2093 return m_genericImpl
->InsertItem(index
, label
, imageIndex
);
2096 info
.m_image
= imageIndex
;
2097 info
.m_text
= label
;
2098 info
.m_mask
= wxLIST_MASK_IMAGE
| wxLIST_MASK_TEXT
;
2099 info
.m_itemId
= index
;
2100 return InsertItem(info
);
2103 // For list view mode (only), inserts a column.
2104 long wxListCtrl::InsertColumn(long col
, wxListItem
& item
)
2107 return m_genericImpl
->InsertColumn(col
, item
);
2111 int width
= item
.GetWidth();
2112 if ( !(item
.GetMask() & wxLIST_MASK_WIDTH
) )
2115 DataBrowserPropertyType type
= kDataBrowserCustomType
; //kDataBrowserTextType;
2116 wxImageList
* imageList
= GetImageList(wxIMAGE_LIST_SMALL
);
2117 if (imageList
&& imageList
->GetImageCount() > 0)
2119 wxBitmap bmp
= imageList
->GetBitmap(0);
2121 // type = kDataBrowserIconAndTextType;
2124 SInt16 just
= teFlushDefault
;
2125 if (item
.GetMask() & wxLIST_MASK_FORMAT
)
2127 if (item
.GetAlign() == wxLIST_FORMAT_LEFT
)
2129 else if (item
.GetAlign() == wxLIST_FORMAT_CENTER
)
2131 else if (item
.GetAlign() == wxLIST_FORMAT_RIGHT
)
2132 just
= teFlushRight
;
2134 m_dbImpl
->InsertColumn(col
, type
, item
.GetText(), just
, width
);
2135 SetColumn(col
, item
);
2137 // set/remove options based on the wxListCtrl type.
2138 DataBrowserTableViewColumnID id
;
2139 m_dbImpl
->GetColumnIDFromIndex(col
, &id
);
2140 DataBrowserPropertyFlags flags
;
2141 verify_noerr(m_dbImpl
->GetPropertyFlags(id
, &flags
));
2142 if (GetWindowStyleFlag() & wxLC_EDIT_LABELS
)
2143 flags
|= kDataBrowserPropertyIsEditable
;
2145 if (GetWindowStyleFlag() & wxLC_VIRTUAL
){
2146 flags
&= ~kDataBrowserListViewSortableColumn
;
2148 verify_noerr(m_dbImpl
->SetPropertyFlags(id
, flags
));
2154 long wxListCtrl::InsertColumn(long col
,
2155 const wxString
& heading
,
2160 return m_genericImpl
->InsertColumn(col
, heading
, format
, width
);
2163 item
.m_mask
= wxLIST_MASK_TEXT
| wxLIST_MASK_FORMAT
;
2164 item
.m_text
= heading
;
2167 item
.m_mask
|= wxLIST_MASK_WIDTH
;
2168 item
.m_width
= width
;
2170 item
.m_format
= format
;
2172 return InsertColumn(col
, item
);
2175 // scroll the control by the given number of pixels (exception: in list view,
2176 // dx is interpreted as number of columns)
2177 bool wxListCtrl::ScrollList(int dx
, int dy
)
2180 return m_genericImpl
->ScrollList(dx
, dy
);
2184 m_dbImpl
->SetScrollPosition(dx
, dy
);
2190 bool wxListCtrl::SortItems(wxListCtrlCompare fn
, long data
)
2193 return m_genericImpl
->SortItems(fn
, data
);
2198 m_compareFuncData
= data
;
2199 SortDataBrowserContainer( m_dbImpl
->GetControlRef(), kDataBrowserNoItem
, true);
2201 // we need to do this after each call, else we get a crash from wxPython when
2202 // SortItems is called the second time.
2203 m_compareFunc
= NULL
;
2204 m_compareFuncData
= 0;
2210 void wxListCtrl::OnRenameTimer()
2212 wxCHECK_RET( HasCurrent(), wxT("unexpected rename timer") );
2214 EditLabel( m_current
);
2217 bool wxListCtrl::OnRenameAccept(long itemEdit
, const wxString
& value
)
2219 wxListEvent
le( wxEVT_COMMAND_LIST_END_LABEL_EDIT
, GetId() );
2220 le
.SetEventObject( this );
2221 le
.m_itemIndex
= itemEdit
;
2223 GetItem( le
.m_item
);
2224 le
.m_item
.m_text
= value
;
2225 return !HandleWindowEvent( le
) ||
2229 void wxListCtrl::OnRenameCancelled(long itemEdit
)
2231 // let owner know that the edit was cancelled
2232 wxListEvent
le( wxEVT_COMMAND_LIST_END_LABEL_EDIT
, GetParent()->GetId() );
2234 le
.SetEditCanceled(true);
2236 le
.SetEventObject( this );
2237 le
.m_itemIndex
= itemEdit
;
2239 GetItem( le
.m_item
);
2240 HandleWindowEvent( le
);
2243 // ----------------------------------------------------------------------------
2244 // virtual list controls
2245 // ----------------------------------------------------------------------------
2247 wxString
wxListCtrl::OnGetItemText(long WXUNUSED(item
), long WXUNUSED(col
)) const
2249 // this is a pure virtual function, in fact - which is not really pure
2250 // because the controls which are not virtual don't need to implement it
2251 wxFAIL_MSG( _T("wxListCtrl::OnGetItemText not supposed to be called") );
2253 return wxEmptyString
;
2256 int wxListCtrl::OnGetItemImage(long WXUNUSED(item
)) const
2258 wxCHECK_MSG(!GetImageList(wxIMAGE_LIST_SMALL
),
2260 wxT("List control has an image list, OnGetItemImage or OnGetItemColumnImage should be overridden."));
2264 int wxListCtrl::OnGetItemColumnImage(long item
, long column
) const
2267 return OnGetItemImage(item
);
2272 wxListItemAttr
*wxListCtrl::OnGetItemAttr(long WXUNUSED_UNLESS_DEBUG(item
)) const
2274 wxASSERT_MSG( item
>= 0 && item
< GetItemCount(),
2275 _T("invalid item index in OnGetItemAttr()") );
2277 // no attributes by default
2281 void wxListCtrl::SetItemCount(long count
)
2283 wxASSERT_MSG( IsVirtual(), _T("this is for virtual controls only") );
2287 m_genericImpl
->SetItemCount(count
);
2293 // we need to temporarily disable the new item creation notification
2294 // procedure to speed things up
2295 // FIXME: Even this doesn't seem to help much...
2297 // FIXME: Find a more efficient way to do this.
2298 m_dbImpl
->MacClear();
2300 DataBrowserCallbacks callbacks
;
2301 DataBrowserItemNotificationUPP itemUPP
;
2302 GetDataBrowserCallbacks(m_dbImpl
->GetControlRef(), &callbacks
);
2303 itemUPP
= callbacks
.u
.v1
.itemNotificationCallback
;
2304 callbacks
.u
.v1
.itemNotificationCallback
= 0;
2305 m_dbImpl
->SetCallbacks(&callbacks
);
2306 ::AddDataBrowserItems(m_dbImpl
->GetControlRef(), kDataBrowserNoItem
,
2307 count
, NULL
, kDataBrowserItemNoProperty
);
2308 callbacks
.u
.v1
.itemNotificationCallback
= itemUPP
;
2309 m_dbImpl
->SetCallbacks(&callbacks
);
2314 void wxListCtrl::RefreshItem(long item
)
2318 m_genericImpl
->RefreshItem(item
);
2324 DataBrowserItemID id
;
2328 wxMacDataItem
* thisItem
= m_dbImpl
->GetItemFromLine(item
);
2329 id
= (DataBrowserItemID
) thisItem
;
2334 m_dbImpl
->wxMacDataBrowserControl::UpdateItems
2338 kDataBrowserItemNoProperty
, // preSortProperty
2339 kDataBrowserNoItem
// update all columns
2344 void wxListCtrl::RefreshItems(long itemFrom
, long itemTo
)
2348 m_genericImpl
->RefreshItems(itemFrom
, itemTo
);
2354 const long count
= itemTo
- itemFrom
+ 1;
2355 DataBrowserItemID
*ids
= new DataBrowserItemID
[count
];
2359 for ( long i
= 0; i
< count
; i
++ )
2361 wxMacDataItem
* thisItem
= m_dbImpl
->GetItemFromLine(itemFrom
+i
);
2362 ids
[i
] = (DataBrowserItemID
) thisItem
;
2367 for ( long i
= 0; i
< count
; i
++ )
2368 ids
[i
] = itemFrom
+i
+1;
2371 m_dbImpl
->wxMacDataBrowserControl::UpdateItems
2375 kDataBrowserItemNoProperty
, // preSortProperty
2376 kDataBrowserNoItem
// update all columns
2383 void wxListCtrl::SetDropTarget( wxDropTarget
*dropTarget
)
2385 #if wxUSE_DRAG_AND_DROP
2387 m_genericImpl
->SetDropTarget( dropTarget
);
2390 wxWindow::SetDropTarget( dropTarget
);
2394 wxDropTarget
*wxListCtrl::GetDropTarget() const
2396 #if wxUSE_DRAG_AND_DROP
2398 return m_genericImpl
->GetDropTarget();
2401 return wxWindow::GetDropTarget();
2406 #if wxABI_VERSION >= 20801
2407 void wxListCtrl::SetFocus()
2411 m_genericImpl
->SetFocus();
2415 wxWindow::SetFocus();
2419 // wxMac internal data structures
2421 wxMacListCtrlItem::~wxMacListCtrlItem()
2423 WX_CLEAR_HASH_MAP( wxListItemList
, m_rowItems
);
2426 void wxMacListCtrlItem::Notification(wxMacDataItemBrowserControl
*owner
,
2427 DataBrowserItemNotification message
,
2428 DataBrowserItemDataRef
WXUNUSED(itemData
) ) const
2431 wxMacDataBrowserListCtrlControl
*lb
= wxDynamicCast(owner
, wxMacDataBrowserListCtrlControl
);
2433 // we want to depend on as little as possible to make sure tear-down of controls is safe
2434 if ( message
== kDataBrowserItemRemoved
)
2436 if ( lb
!= NULL
&& lb
->GetClientDataType() == wxClientData_Object
)
2438 delete (wxClientData
*) (m_data
);
2444 else if ( message
== kDataBrowserItemAdded
)
2446 // we don't issue events on adding, the item is not really stored in the list yet, so we
2447 // avoid asserts by gettting out now
2451 wxListCtrl
*list
= wxDynamicCast( owner
->GetWXPeer() , wxListCtrl
);
2454 bool trigger
= false;
2456 wxListEvent
event( wxEVT_COMMAND_LIST_ITEM_SELECTED
, list
->GetId() );
2457 bool isSingle
= (list
->GetWindowStyle() & wxLC_SINGLE_SEL
) != 0;
2459 event
.SetEventObject( list
);
2460 event
.m_itemIndex
= owner
->GetLineFromItem( this ) ;
2461 event
.m_item
.m_itemId
= event
.m_itemIndex
;
2462 list
->GetItem(event
.m_item
);
2466 case kDataBrowserItemDeselected
:
2467 event
.SetEventType(wxEVT_COMMAND_LIST_ITEM_DESELECTED
);
2469 trigger
= !lb
->IsSelectionSuppressed();
2472 case kDataBrowserItemSelected
:
2473 trigger
= !lb
->IsSelectionSuppressed();
2476 case kDataBrowserItemDoubleClicked
:
2477 event
.SetEventType( wxEVT_COMMAND_LIST_ITEM_ACTIVATED
);
2481 case kDataBrowserEditStarted
:
2482 // TODO : how to veto ?
2483 event
.SetEventType( wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
) ;
2487 case kDataBrowserEditStopped
:
2488 // TODO probably trigger only upon the value store callback, because
2489 // here IIRC we cannot veto
2490 event
.SetEventType( wxEVT_COMMAND_LIST_END_LABEL_EDIT
) ;
2500 // direct notification is not always having the listbox GetSelection() having in synch with event
2501 wxPostEvent( list
->GetEventHandler(), event
);
2507 IMPLEMENT_DYNAMIC_CLASS(wxMacDataBrowserListCtrlControl
, wxMacDataItemBrowserControl
)
2509 wxMacDataBrowserListCtrlControl::wxMacDataBrowserListCtrlControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
)
2510 : wxMacDataItemBrowserControl( peer
, pos
, size
, style
)
2512 OSStatus err
= noErr
;
2513 m_clientDataItemsType
= wxClientData_None
;
2514 m_isVirtual
= false;
2517 if ( style
& wxLC_VIRTUAL
)
2520 DataBrowserSelectionFlags options
= kDataBrowserDragSelect
;
2521 if ( style
& wxLC_SINGLE_SEL
)
2523 options
|= kDataBrowserSelectOnlyOne
;
2527 options
|= kDataBrowserCmdTogglesSelection
;
2530 err
= SetSelectionFlags( options
);
2531 verify_noerr( err
);
2533 DataBrowserCustomCallbacks callbacks
;
2534 InitializeDataBrowserCustomCallbacks( &callbacks
, kDataBrowserLatestCustomCallbacks
);
2536 if ( gDataBrowserDrawItemUPP
== NULL
)
2537 gDataBrowserDrawItemUPP
= NewDataBrowserDrawItemUPP(DataBrowserDrawItemProc
);
2539 if ( gDataBrowserHitTestUPP
== NULL
)
2540 gDataBrowserHitTestUPP
= NewDataBrowserHitTestUPP(DataBrowserHitTestProc
);
2542 callbacks
.u
.v1
.drawItemCallback
= gDataBrowserDrawItemUPP
;
2543 callbacks
.u
.v1
.hitTestCallback
= gDataBrowserHitTestUPP
;
2545 SetDataBrowserCustomCallbacks( GetControlRef(), &callbacks
);
2547 if ( style
& wxLC_LIST
)
2549 InsertColumn(0, kDataBrowserIconAndTextType
, wxEmptyString
, -1, -1);
2550 verify_noerr( AutoSizeColumns() );
2553 if ( style
& wxLC_LIST
|| style
& wxLC_NO_HEADER
)
2554 verify_noerr( SetHeaderButtonHeight( 0 ) );
2557 SetSortProperty( kMinColumnId
- 1 );
2559 SetSortProperty( kMinColumnId
);
2561 m_sortOrder
= SortOrder_None
;
2563 if ( style
& wxLC_SORT_DESCENDING
)
2565 SetSortOrder( kDataBrowserOrderDecreasing
);
2567 else if ( style
& wxLC_SORT_ASCENDING
)
2569 SetSortOrder( kDataBrowserOrderIncreasing
);
2572 if ( style
& wxLC_VRULES
)
2574 verify_noerr( DataBrowserChangeAttributes(m_controlRef
, kDataBrowserAttributeListViewDrawColumnDividers
, kDataBrowserAttributeNone
) );
2577 verify_noerr( SetHiliteStyle(kDataBrowserTableViewFillHilite
) );
2578 verify_noerr( SetHasScrollBars( (style
& wxHSCROLL
) != 0 , true ) );
2581 pascal Boolean
wxMacDataBrowserListCtrlControl::DataBrowserEditTextProc(
2583 DataBrowserItemID itemID
,
2584 DataBrowserPropertyID property
,
2585 CFStringRef theString
,
2586 Rect
*maxEditTextRect
,
2587 Boolean
*shrinkToFit
)
2589 Boolean result
= false;
2590 wxMacDataBrowserListCtrlControl
* ctl
= wxDynamicCast(wxMacControl::GetReferenceFromNativeControl( browser
), wxMacDataBrowserListCtrlControl
);
2593 result
= ctl
->ConfirmEditText(itemID
, property
, theString
, maxEditTextRect
, shrinkToFit
);
2594 theString
= CFSTR("Hello!");
2599 bool wxMacDataBrowserListCtrlControl::ConfirmEditText(
2600 DataBrowserItemID
WXUNUSED(itemID
),
2601 DataBrowserPropertyID
WXUNUSED(property
),
2602 CFStringRef
WXUNUSED(theString
),
2603 Rect
*WXUNUSED(maxEditTextRect
),
2604 Boolean
*WXUNUSED(shrinkToFit
))
2609 pascal void wxMacDataBrowserListCtrlControl::DataBrowserDrawItemProc(
2611 DataBrowserItemID itemID
,
2612 DataBrowserPropertyID property
,
2613 DataBrowserItemState itemState
,
2614 const Rect
*itemRect
,
2616 Boolean colorDevice
)
2618 wxMacDataBrowserListCtrlControl
* ctl
= wxDynamicCast(wxMacControl::GetReferenceFromNativeControl( browser
), wxMacDataBrowserListCtrlControl
);
2621 ctl
->DrawItem(itemID
, property
, itemState
, itemRect
, gdDepth
, colorDevice
);
2625 // routines needed for DrawItem
2630 kTextBoxHeight
= 14,
2631 kIconTextSpacingV
= 2,
2633 kContentHeight
= kIconHeight
+ kTextBoxHeight
+ kIconTextSpacingV
2636 static void calculateCGDrawingBounds(CGRect inItemRect
, CGRect
*outIconRect
, CGRect
*outTextRect
, bool hasIcon
= false)
2639 float iconH
, iconW
= 0;
2640 float padding
= kItemPadding
;
2643 iconH
= kIconHeight
;
2645 padding
= padding
*2;
2648 textBottom
= inItemRect
.origin
.y
;
2650 *outIconRect
= CGRectMake(inItemRect
.origin
.x
+ kItemPadding
,
2651 textBottom
+ kIconTextSpacingV
, kIconWidth
,
2654 *outTextRect
= CGRectMake(inItemRect
.origin
.x
+ padding
+ iconW
,
2655 textBottom
+ kIconTextSpacingV
, inItemRect
.size
.width
- padding
- iconW
,
2656 inItemRect
.size
.height
- kIconTextSpacingV
);
2659 void wxMacDataBrowserListCtrlControl::DrawItem(
2660 DataBrowserItemID itemID
,
2661 DataBrowserPropertyID property
,
2662 DataBrowserItemState itemState
,
2663 const Rect
*WXUNUSED(itemRect
),
2665 Boolean colorDevice
)
2668 wxFont font
= wxNullFont
;
2670 short listColumn
= property
- kMinColumnId
;
2672 wxListCtrl
* list
= wxDynamicCast( GetWXPeer() , wxListCtrl
);
2673 wxMacListCtrlItem
* lcItem
;
2674 wxColour color
= *wxBLACK
;
2675 wxColour bgColor
= wxNullColour
;
2677 if (listColumn
>= 0)
2681 lcItem
= (wxMacListCtrlItem
*) itemID
;
2682 if (lcItem
->HasColumnInfo(listColumn
)){
2683 wxListItem
* item
= lcItem
->GetColumnInfo(listColumn
);
2685 // we always use the 0 column to get font and text/background colors.
2686 if (lcItem
->HasColumnInfo(0))
2688 wxListItem
* firstItem
= lcItem
->GetColumnInfo(0);
2689 color
= firstItem
->GetTextColour();
2690 bgColor
= firstItem
->GetBackgroundColour();
2691 font
= firstItem
->GetFont();
2694 if (item
->GetMask() & wxLIST_MASK_TEXT
)
2695 text
= item
->GetText();
2696 if (item
->GetMask() & wxLIST_MASK_IMAGE
)
2697 imgIndex
= item
->GetImage();
2703 long itemNum
= (long)itemID
-1;
2704 if (itemNum
>= 0 && itemNum
< list
->GetItemCount())
2706 text
= list
->OnGetItemText( itemNum
, listColumn
);
2707 imgIndex
= list
->OnGetItemColumnImage( itemNum
, listColumn
);
2708 wxListItemAttr
* attrs
= list
->OnGetItemAttr( itemNum
);
2711 if (attrs
->HasBackgroundColour())
2712 bgColor
= attrs
->GetBackgroundColour();
2713 if (attrs
->HasTextColour())
2714 color
= attrs
->GetTextColour();
2715 if (attrs
->HasFont())
2716 font
= attrs
->GetFont();
2722 wxColour listBgColor
= list
->GetBackgroundColour();
2723 if (bgColor
== wxNullColour
)
2724 bgColor
= listBgColor
;
2727 font
= list
->GetFont();
2729 wxCFStringRef
cfString( text
, wxLocale::GetSystemEncoding() );
2732 CGRect enclosingCGRect
, iconCGRect
, textCGRect
;
2734 ThemeDrawingState savedState
= NULL
;
2735 CGContextRef context
= (CGContextRef
)list
->MacGetDrawingContext();
2736 RGBColor labelColor
;
2738 labelColor
.green
= 0;
2739 labelColor
.blue
= 0;
2741 RGBColor backgroundColor
;
2742 backgroundColor
.red
= 255;
2743 backgroundColor
.green
= 255;
2744 backgroundColor
.blue
= 255;
2746 GetDataBrowserItemPartBounds(GetControlRef(), itemID
, property
, kDataBrowserPropertyEnclosingPart
,
2749 enclosingCGRect
= CGRectMake(enclosingRect
.left
,
2751 enclosingRect
.right
- enclosingRect
.left
,
2752 enclosingRect
.bottom
- enclosingRect
.top
);
2754 bool hasFocus
= (wxWindow::FindFocus() == list
);
2755 active
= IsControlActive(GetControlRef());
2757 // don't paint the background over the vertical rule line
2758 if ( list
->GetWindowStyleFlag() & wxLC_VRULES
)
2760 enclosingCGRect
.origin
.x
+= 1;
2761 enclosingCGRect
.size
.width
-= 1;
2763 if (itemState
== kDataBrowserItemIsSelected
)
2766 GetThemeDrawingState(&savedState
);
2768 if (active
&& hasFocus
)
2770 GetThemeBrushAsColor(kThemeBrushAlternatePrimaryHighlightColor
, 32, true, &backgroundColor
);
2771 GetThemeTextColor(kThemeTextColorWhite
, gdDepth
, colorDevice
, &labelColor
);
2775 GetThemeBrushAsColor(kThemeBrushSecondaryHighlightColor
, 32, true, &backgroundColor
);
2776 GetThemeTextColor(kThemeTextColorBlack
, gdDepth
, colorDevice
, &labelColor
);
2778 CGContextSaveGState(context
);
2780 CGContextSetRGBFillColor(context
, (CGFloat
)backgroundColor
.red
/ (CGFloat
)USHRT_MAX
,
2781 (CGFloat
)backgroundColor
.green
/ (CGFloat
)USHRT_MAX
,
2782 (CGFloat
)backgroundColor
.blue
/ (CGFloat
)USHRT_MAX
, (CGFloat
) 1.0);
2783 CGContextFillRect(context
, enclosingCGRect
);
2785 CGContextRestoreGState(context
);
2791 color
.GetRGBColor(&labelColor
);
2792 else if (list
->GetTextColour().Ok())
2793 list
->GetTextColour().GetRGBColor(&labelColor
);
2797 bgColor
.GetRGBColor(&backgroundColor
);
2798 CGContextSaveGState(context
);
2800 CGContextSetRGBFillColor(context
, (CGFloat
)backgroundColor
.red
/ (CGFloat
)USHRT_MAX
,
2801 (CGFloat
)backgroundColor
.green
/ (CGFloat
)USHRT_MAX
,
2802 (CGFloat
)backgroundColor
.blue
/ (CGFloat
)USHRT_MAX
, (CGFloat
) 1.0);
2803 CGContextFillRect(context
, enclosingCGRect
);
2805 CGContextRestoreGState(context
);
2809 calculateCGDrawingBounds(enclosingCGRect
, &iconCGRect
, &textCGRect
, (imgIndex
!= -1) );
2813 wxImageList
* imageList
= list
->GetImageList(wxIMAGE_LIST_SMALL
);
2814 if (imageList
&& imageList
->GetImageCount() > 0){
2815 wxBitmap bmp
= imageList
->GetBitmap(imgIndex
);
2816 IconRef icon
= bmp
.GetIconRef();
2818 CGContextSaveGState(context
);
2819 CGContextTranslateCTM(context
, 0,iconCGRect
.origin
.y
+ CGRectGetMaxY(iconCGRect
));
2820 CGContextScaleCTM(context
,1.0f
,-1.0f
);
2821 PlotIconRefInContext(context
, &iconCGRect
, kAlignNone
,
2822 active
? kTransformNone
: kTransformDisabled
, NULL
,
2823 kPlotIconRefNormalFlags
, icon
);
2825 CGContextRestoreGState(context
);
2829 HIThemeTextHorizontalFlush hFlush
= kHIThemeTextHorizontalFlushLeft
;
2830 HIThemeTextInfo info
;
2832 #if wxMAC_USE_CORE_TEXT
2833 if ( UMAGetSystemVersion() >= 0x1050 )
2835 info
.version
= kHIThemeTextInfoVersionOne
;
2836 info
.fontID
= kThemeViewsFont
;
2839 info
.fontID
= kThemeSpecifiedFont
;
2840 info
.font
= (CTFontRef
) font
.MacGetCTFont();
2845 #if wxMAC_USE_ATSU_TEXT
2848 info
.version
= kHIThemeTextInfoVersionZero
;
2849 info
.fontID
= kThemeViewsFont
;
2853 info
.fontID
= font
.MacGetThemeFontID();
2855 ::TextSize( (short)(font
.MacGetFontSize()) ) ;
2856 ::TextFace( font
.MacGetFontStyle() ) ;
2862 list
->GetColumn(listColumn
, item
);
2863 if (item
.GetMask() & wxLIST_MASK_FORMAT
)
2865 if (item
.GetAlign() == wxLIST_FORMAT_LEFT
)
2866 hFlush
= kHIThemeTextHorizontalFlushLeft
;
2867 else if (item
.GetAlign() == wxLIST_FORMAT_CENTER
)
2868 hFlush
= kHIThemeTextHorizontalFlushCenter
;
2869 else if (item
.GetAlign() == wxLIST_FORMAT_RIGHT
)
2871 hFlush
= kHIThemeTextHorizontalFlushRight
;
2872 textCGRect
.origin
.x
-= kItemPadding
; // give a little extra paddding
2876 info
.state
= active
? kThemeStateActive
: kThemeStateInactive
;
2877 info
.horizontalFlushness
= hFlush
;
2878 info
.verticalFlushness
= kHIThemeTextVerticalFlushCenter
;
2879 info
.options
= kHIThemeTextBoxOptionNone
;
2880 info
.truncationPosition
= kHIThemeTextTruncationEnd
;
2881 info
.truncationMaxLines
= 1;
2883 CGContextSaveGState(context
);
2884 CGContextSetRGBFillColor (context
, (CGFloat
)labelColor
.red
/ (CGFloat
)USHRT_MAX
,
2885 (CGFloat
)labelColor
.green
/ (CGFloat
)USHRT_MAX
,
2886 (CGFloat
)labelColor
.blue
/ (CGFloat
)USHRT_MAX
, (CGFloat
) 1.0);
2888 HIThemeDrawTextBox(cfString
, &textCGRect
, &info
, context
, kHIThemeOrientationNormal
);
2890 CGContextRestoreGState(context
);
2893 if (savedState
!= NULL
)
2894 SetThemeDrawingState(savedState
, true);
2898 OSStatus
wxMacDataBrowserListCtrlControl::GetSetItemData(DataBrowserItemID itemID
,
2899 DataBrowserPropertyID property
,
2900 DataBrowserItemDataRef itemData
,
2901 Boolean changeValue
)
2905 short listColumn
= property
- kMinColumnId
;
2907 OSStatus err
= errDataBrowserPropertyNotSupported
;
2908 wxListCtrl
* list
= wxDynamicCast( GetWXPeer() , wxListCtrl
);
2909 wxMacListCtrlItem
* lcItem
= NULL
;
2911 if (listColumn
>= 0)
2915 lcItem
= (wxMacListCtrlItem
*) itemID
;
2916 if (lcItem
&& lcItem
->HasColumnInfo(listColumn
)){
2917 wxListItem
* item
= lcItem
->GetColumnInfo(listColumn
);
2918 if (item
->GetMask() & wxLIST_MASK_TEXT
)
2919 text
= item
->GetText();
2920 if (item
->GetMask() & wxLIST_MASK_IMAGE
)
2921 imgIndex
= item
->GetImage();
2926 long itemNum
= (long)itemID
-1;
2927 if (itemNum
>= 0 && itemNum
< list
->GetItemCount())
2929 text
= list
->OnGetItemText( itemNum
, listColumn
);
2930 imgIndex
= list
->OnGetItemColumnImage( itemNum
, listColumn
);
2939 case kDataBrowserItemIsEditableProperty
:
2940 if ( list
&& list
->HasFlag( wxLC_EDIT_LABELS
) )
2942 verify_noerr(SetDataBrowserItemDataBooleanValue( itemData
, true ));
2947 if ( property
>= kMinColumnId
)
2949 if (!text
.IsEmpty()){
2950 wxCFStringRef
cfStr( text
, wxLocale::GetSystemEncoding() );
2951 err
= ::SetDataBrowserItemDataText( itemData
, cfStr
);
2957 if ( imgIndex
!= -1 )
2959 wxImageList
* imageList
= list
->GetImageList(wxIMAGE_LIST_SMALL
);
2960 if (imageList
&& imageList
->GetImageCount() > 0){
2961 wxBitmap bmp
= imageList
->GetBitmap(imgIndex
);
2962 IconRef icon
= bmp
.GetIconRef();
2963 ::SetDataBrowserItemDataIcon(itemData
, icon
);
2977 if ( property
>= kMinColumnId
)
2979 short listColumn
= property
- kMinColumnId
;
2981 // TODO probably send the 'end edit' from here, as we
2982 // can then deal with the veto
2984 verify_noerr( GetDataBrowserItemDataText( itemData
, &sr
) ) ;
2985 wxCFStringRef
cfStr(sr
) ;;
2987 list
->SetItem( (long)itemData
-1 , listColumn
, cfStr
.AsString() ) ;
2991 lcItem
->SetColumnTextValue( listColumn
, cfStr
.AsString() );
3001 void wxMacDataBrowserListCtrlControl::ItemNotification(DataBrowserItemID itemID
,
3002 DataBrowserItemNotification message
,
3003 DataBrowserItemDataRef itemData
)
3005 wxMacListCtrlItem
*item
= NULL
;
3008 item
= (wxMacListCtrlItem
*) itemID
;
3011 // we want to depend on as little as possible to make sure tear-down of controls is safe
3012 if ( message
== kDataBrowserItemRemoved
)
3015 item
->Notification(this, message
, itemData
);
3018 else if ( message
== kDataBrowserItemAdded
)
3020 // we don't issue events on adding, the item is not really stored in the list yet, so we
3021 // avoid asserts by getting out now
3023 item
->Notification(this, message
, itemData
);
3027 wxListCtrl
*list
= wxDynamicCast( GetWXPeer() , wxListCtrl
);
3030 bool trigger
= false;
3032 wxListEvent
event( wxEVT_COMMAND_LIST_ITEM_SELECTED
, list
->GetId() );
3034 event
.SetEventObject( list
);
3035 if ( !list
->IsVirtual() )
3037 DataBrowserTableViewRowIndex result
= 0;
3038 verify_noerr( GetItemRow( itemID
, &result
) ) ;
3039 event
.m_itemIndex
= result
;
3043 event
.m_itemIndex
= (long)itemID
-1;
3045 event
.m_item
.m_itemId
= event
.m_itemIndex
;
3046 list
->GetItem(event
.m_item
);
3050 case kDataBrowserItemDeselected
:
3051 event
.SetEventType(wxEVT_COMMAND_LIST_ITEM_DESELECTED
);
3052 // as the generic implementation is also triggering this
3053 // event for single selection, we do the same (different than listbox)
3054 trigger
= !IsSelectionSuppressed();
3057 case kDataBrowserItemSelected
:
3058 trigger
= !IsSelectionSuppressed();
3062 case kDataBrowserItemDoubleClicked
:
3063 event
.SetEventType( wxEVT_COMMAND_LIST_ITEM_ACTIVATED
);
3067 case kDataBrowserEditStarted
:
3068 // TODO : how to veto ?
3069 event
.SetEventType( wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
) ;
3073 case kDataBrowserEditStopped
:
3074 // TODO probably trigger only upon the value store callback, because
3075 // here IIRC we cannot veto
3076 event
.SetEventType( wxEVT_COMMAND_LIST_END_LABEL_EDIT
) ;
3086 // direct notification is not always having the listbox GetSelection() having in synch with event
3087 wxPostEvent( list
->GetEventHandler(), event
);
3092 Boolean
wxMacDataBrowserListCtrlControl::CompareItems(DataBrowserItemID itemOneID
,
3093 DataBrowserItemID itemTwoID
,
3094 DataBrowserPropertyID sortProperty
)
3097 bool retval
= false;
3099 wxString otherItemText
;
3101 long otherItemOrder
;
3103 int colId
= sortProperty
- kMinColumnId
;
3105 wxListCtrl
* list
= wxDynamicCast( GetWXPeer() , wxListCtrl
);
3107 DataBrowserSortOrder sort
;
3108 verify_noerr(GetSortOrder(&sort
));
3114 wxMacListCtrlItem
* item
= (wxMacListCtrlItem
*)itemOneID
;
3115 wxMacListCtrlItem
* otherItem
= (wxMacListCtrlItem
*)itemTwoID
;
3117 itemOrder
= item
->GetOrder();
3118 otherItemOrder
= item
->GetOrder();
3120 wxListCtrlCompare func
= list
->GetCompareFunc();
3125 if (item
&& item
->HasColumnInfo(0))
3126 item1
= item
->GetColumnInfo(0)->GetData();
3127 if (otherItem
&& otherItem
->HasColumnInfo(0))
3128 item2
= otherItem
->GetColumnInfo(0)->GetData();
3130 if (item1
> -1 && item2
> -1)
3132 int result
= func(item1
, item2
, list
->GetCompareFuncData());
3133 if (sort
== kDataBrowserOrderIncreasing
)
3140 // we can't use the native control's sorting abilities, so just
3142 return itemOrder
< otherItemOrder
;
3147 long itemNum
= (long)itemOneID
;
3148 long otherItemNum
= (long)itemTwoID
;
3150 // virtual listctrls don't support sorting
3151 return itemNum
< otherItemNum
;
3155 // fallback for undefined cases
3156 retval
= itemOneID
< itemTwoID
;
3162 wxMacDataBrowserListCtrlControl::~wxMacDataBrowserListCtrlControl()
3166 void wxMacDataBrowserListCtrlControl::MacSetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
* item
)
3168 wxMacDataItem
* dataItem
= GetItemFromLine(row
);
3169 wxASSERT_MSG( dataItem
, _T("could not obtain wxMacDataItem for row in MacSetColumnInfo. Is row a valid wxListCtrl row?") );
3172 wxMacListCtrlItem
* listItem
= wx_static_cast(wxMacListCtrlItem
*,dataItem
);
3173 bool hasInfo
= listItem
->HasColumnInfo( column
);
3174 listItem
->SetColumnInfo( column
, item
);
3175 listItem
->SetOrder(row
);
3176 UpdateState(dataItem
, item
);
3178 wxListCtrl
* list
= wxDynamicCast( GetWXPeer() , wxListCtrl
);
3180 // NB: When this call was made before a control was completely shown, it would
3181 // update the item prematurely (i.e. no text would be listed) and, on show,
3182 // only the sorted column would be refreshed, meaning only first column text labels
3183 // would be shown. Making sure not to update items until the control is visible
3184 // seems to fix this issue.
3185 if (hasInfo
&& list
->IsShown())
3186 UpdateItem( wxMacDataBrowserRootContainer
, listItem
, kMinColumnId
+ column
);
3190 // apply changes that need to happen immediately, rather than when the
3191 // databrowser control fires a callback.
3192 void wxMacDataBrowserListCtrlControl::UpdateState(wxMacDataItem
* dataItem
, wxListItem
* listItem
)
3194 bool isSelected
= IsItemSelected( dataItem
);
3195 bool isSelectedState
= (listItem
->GetState() == wxLIST_STATE_SELECTED
);
3197 // toggle the selection state if wxListInfo state and actual state don't match.
3198 if ( listItem
->GetMask() & wxLIST_MASK_STATE
&& isSelected
!= isSelectedState
)
3200 DataBrowserSetOption options
= kDataBrowserItemsAdd
;
3201 if (!isSelectedState
)
3202 options
= kDataBrowserItemsRemove
;
3203 SetSelectedItem(dataItem
, options
);
3205 // TODO: Set column width if item width > than current column width
3208 void wxMacDataBrowserListCtrlControl::MacGetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
& item
)
3210 wxMacDataItem
* dataItem
= GetItemFromLine(row
);
3211 wxASSERT_MSG( dataItem
, _T("could not obtain wxMacDataItem in MacGetColumnInfo. Is row a valid wxListCtrl row?") );
3212 // CS should this guard against dataItem = 0 ? , as item is not a pointer if (item) is not appropriate
3215 wxMacListCtrlItem
* listItem
=wx_static_cast(wxMacListCtrlItem
*,dataItem
);
3217 if (!listItem
->HasColumnInfo( column
))
3220 wxListItem
* oldItem
= listItem
->GetColumnInfo( column
);
3224 long mask
= item
.GetMask();
3226 // by default, get everything for backwards compatibility
3229 if ( mask
& wxLIST_MASK_TEXT
)
3230 item
.SetText(oldItem
->GetText());
3231 if ( mask
& wxLIST_MASK_IMAGE
)
3232 item
.SetImage(oldItem
->GetImage());
3233 if ( mask
& wxLIST_MASK_DATA
)
3234 item
.SetData(oldItem
->GetData());
3235 if ( mask
& wxLIST_MASK_STATE
)
3236 item
.SetState(oldItem
->GetState());
3237 if ( mask
& wxLIST_MASK_WIDTH
)
3238 item
.SetWidth(oldItem
->GetWidth());
3239 if ( mask
& wxLIST_MASK_FORMAT
)
3240 item
.SetAlign(oldItem
->GetAlign());
3242 item
.SetTextColour(oldItem
->GetTextColour());
3243 item
.SetBackgroundColour(oldItem
->GetBackgroundColour());
3244 item
.SetFont(oldItem
->GetFont());
3249 void wxMacDataBrowserListCtrlControl::MacInsertItem( unsigned int n
, wxListItem
* item
)
3251 wxMacDataItemBrowserControl::MacInsert(n
, item
->GetText());
3252 MacSetColumnInfo(n
, 0, item
);
3255 wxMacDataItem
* wxMacDataBrowserListCtrlControl::CreateItem()
3257 return new wxMacListCtrlItem();
3260 wxMacListCtrlItem::wxMacListCtrlItem()
3262 m_rowItems
= wxListItemList();
3265 int wxMacListCtrlItem::GetColumnImageValue( unsigned int column
)
3267 if ( HasColumnInfo(column
) )
3268 return GetColumnInfo(column
)->GetImage();
3273 void wxMacListCtrlItem::SetColumnImageValue( unsigned int column
, int imageIndex
)
3275 if ( HasColumnInfo(column
) )
3276 GetColumnInfo(column
)->SetImage(imageIndex
);
3279 wxString
wxMacListCtrlItem::GetColumnTextValue( unsigned int column
)
3284 if ( HasColumnInfo(column
) )
3285 return GetColumnInfo(column
)->GetText();
3287 return wxEmptyString
;
3290 void wxMacListCtrlItem::SetColumnTextValue( unsigned int column
, const wxString
& text
)
3292 if ( HasColumnInfo(column
) )
3293 GetColumnInfo(column
)->SetText(text
);
3295 // for compatibility with superclass APIs
3300 wxListItem
* wxMacListCtrlItem::GetColumnInfo( unsigned int column
)
3302 wxASSERT_MSG( HasColumnInfo(column
), _T("invalid column index in wxMacListCtrlItem") );
3303 return m_rowItems
[column
];
3306 bool wxMacListCtrlItem::HasColumnInfo( unsigned int column
)
3308 return !(m_rowItems
.find( column
) == m_rowItems
.end());
3311 void wxMacListCtrlItem::SetColumnInfo( unsigned int column
, wxListItem
* item
)
3314 if ( !HasColumnInfo(column
) )
3316 wxListItem
* listItem
= new wxListItem(*item
);
3317 m_rowItems
[column
] = listItem
;
3321 wxListItem
* listItem
= GetColumnInfo( column
);
3322 long mask
= item
->GetMask();
3323 if (mask
& wxLIST_MASK_TEXT
)
3324 listItem
->SetText(item
->GetText());
3325 if (mask
& wxLIST_MASK_DATA
)
3326 listItem
->SetData(item
->GetData());
3327 if (mask
& wxLIST_MASK_IMAGE
)
3328 listItem
->SetImage(item
->GetImage());
3329 if (mask
& wxLIST_MASK_STATE
)
3330 listItem
->SetState(item
->GetState());
3331 if (mask
& wxLIST_MASK_FORMAT
)
3332 listItem
->SetAlign(item
->GetAlign());
3333 if (mask
& wxLIST_MASK_WIDTH
)
3334 listItem
->SetWidth(item
->GetWidth());
3336 if ( item
->HasAttributes() )
3338 if ( listItem
->HasAttributes() )
3339 listItem
->GetAttributes()->AssignFrom(*item
->GetAttributes());
3342 listItem
->SetTextColour(item
->GetTextColour());
3343 listItem
->SetBackgroundColour(item
->GetBackgroundColour());
3344 listItem
->SetFont(item
->GetFont());
3350 int wxListCtrl::CalcColumnAutoWidth(int col
) const
3354 for ( int i
= 0; i
< GetItemCount(); i
++ )
3357 info
.SetMask(wxLIST_MASK_TEXT
| wxLIST_MASK_IMAGE
);
3359 info
.SetColumn(col
);
3362 const wxFont font
= info
.GetFont();
3366 GetTextExtent(info
.GetText(), &w
, NULL
, NULL
, NULL
, &font
);
3368 GetTextExtent(info
.GetText(), &w
, NULL
);
3370 w
+= 2 * kItemPadding
;
3372 if ( info
.GetImage() != -1 )
3375 width
= wxMax(width
, w
);
3381 #endif // wxUSE_LISTCTRL