1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/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 WX_DECLARE_HASH_MAP( int, wxListItem
*, wxIntegerHash
, wxIntegerEqual
, wxListItemList
);
46 #include "wx/listimpl.cpp"
47 WX_DEFINE_LIST(wxColumnList
)
49 // so we can check for column clicks
50 static const EventTypeSpec eventList
[] =
52 { kEventClassControl
, kEventControlHit
},
53 { kEventClassControl
, kEventControlDraw
}
56 static pascal OSStatus
wxMacListCtrlEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
58 OSStatus result
= eventNotHandledErr
;
60 wxMacCarbonEvent
cEvent( event
) ;
62 ControlRef controlRef
;
63 cEvent
.GetParameter( kEventParamDirectObject
, &controlRef
) ;
65 wxListCtrl
*window
= (wxListCtrl
*) data
;
66 wxListEvent
le( wxEVT_COMMAND_LIST_COL_CLICK
, window
->GetId() );
67 le
.SetEventObject( window
);
69 switch ( GetEventKind( event
) )
71 // check if the column was clicked on and fire an event if so
72 case kEventControlHit
:
74 ControlPartCode result
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
) ;
75 if (result
== kControlButtonPart
){
76 DataBrowserPropertyID col
;
77 GetDataBrowserSortProperty(controlRef
, &col
);
79 DataBrowserTableViewColumnIndex column
= 0;
80 verify_noerr( GetDataBrowserTableViewColumnPosition( controlRef
, col
, &column
) );
83 // FIXME: we can't use the sort property for virtual listctrls
84 // so we need to find a better way to determine which column was clicked...
85 if (!window
->IsVirtual())
86 window
->HandleWindowEvent( le
);
88 result
= CallNextEventHandler(handler
, event
);
91 case kEventControlDraw
:
93 CGContextRef context
= cEvent
.GetParameter
<CGContextRef
>(kEventParamCGContextRef
, typeCGContextRef
) ;
94 window
->MacSetDrawingContext(context
);
95 result
= CallNextEventHandler(handler
, event
);
96 window
->MacSetDrawingContext(NULL
);
107 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacListCtrlEventHandler
)
109 class wxMacListCtrlItem
: public wxMacDataItem
114 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
115 DataBrowserItemNotification message
,
116 DataBrowserItemDataRef itemData
) const;
118 virtual void SetColumnInfo( unsigned int column
, wxListItem
* item
);
119 virtual wxListItem
* GetColumnInfo( unsigned int column
);
120 virtual bool HasColumnInfo( unsigned int column
);
122 virtual void SetColumnTextValue( unsigned int column
, const wxString
& text
);
123 virtual wxString
GetColumnTextValue( unsigned int column
);
125 virtual int GetColumnImageValue( unsigned int column
);
126 virtual void SetColumnImageValue( unsigned int column
, int imageIndex
);
128 virtual ~wxMacListCtrlItem();
130 wxListItemList m_rowItems
;
133 DataBrowserDrawItemUPP gDataBrowserDrawItemUPP
= NULL
;
134 //DataBrowserEditItemUPP gDataBrowserEditItemUPP = NULL;
135 DataBrowserHitTestUPP gDataBrowserHitTestUPP
= NULL
;
137 // TODO: Make a better name!!
138 class wxMacDataBrowserListCtrlControl
: public wxMacDataItemBrowserControl
141 wxMacDataBrowserListCtrlControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
142 wxMacDataBrowserListCtrlControl() {}
143 virtual ~wxMacDataBrowserListCtrlControl();
145 // create a list item (can be a subclass of wxMacListBoxItem)
147 virtual void MacInsertItem( unsigned int n
, wxListItem
* item
);
148 virtual void MacSetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
* item
);
149 virtual void MacGetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
& item
);
150 virtual void UpdateState(wxMacDataItem
* dataItem
, wxListItem
* item
);
151 int GetFlags() { return m_flags
; }
154 // we need to override to provide specialized handling for virtual wxListCtrls
155 virtual OSStatus
GetSetItemData(DataBrowserItemID itemID
,
156 DataBrowserPropertyID property
,
157 DataBrowserItemDataRef itemData
,
158 Boolean changeValue
);
160 virtual void ItemNotification(
161 DataBrowserItemID itemID
,
162 DataBrowserItemNotification message
,
163 DataBrowserItemDataRef itemData
);
165 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
166 DataBrowserItemID itemTwoID
,
167 DataBrowserPropertyID sortProperty
);
169 static pascal void DataBrowserDrawItemProc(ControlRef browser
,
170 DataBrowserItemID item
,
171 DataBrowserPropertyID property
,
172 DataBrowserItemState itemState
,
175 Boolean colorDevice
);
177 virtual void DrawItem(DataBrowserItemID itemID
,
178 DataBrowserPropertyID property
,
179 DataBrowserItemState itemState
,
180 const Rect
*itemRect
,
182 Boolean colorDevice
);
184 static pascal Boolean
DataBrowserEditTextProc(ControlRef browser
,
185 DataBrowserItemID item
,
186 DataBrowserPropertyID property
,
187 CFStringRef theString
,
188 Rect
*maxEditTextRect
,
189 Boolean
*shrinkToFit
);
191 static pascal Boolean
DataBrowserHitTestProc(ControlRef
WXUNUSED(browser
),
192 DataBrowserItemID
WXUNUSED(itemID
),
193 DataBrowserPropertyID
WXUNUSED(property
),
194 const Rect
*WXUNUSED(theRect
),
195 const Rect
*WXUNUSED(mouseRect
)) { return true; }
197 virtual bool ConfirmEditText(DataBrowserItemID item
,
198 DataBrowserPropertyID property
,
199 CFStringRef theString
,
200 Rect
*maxEditTextRect
,
201 Boolean
*shrinkToFit
);
205 wxClientDataType m_clientDataItemsType
;
208 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataBrowserListCtrlControl
)
211 class wxMacListCtrlEventDelegate
: public wxEvtHandler
214 wxMacListCtrlEventDelegate( wxListCtrl
* list
, int id
);
215 virtual bool ProcessEvent( wxEvent
& event
);
222 wxMacListCtrlEventDelegate::wxMacListCtrlEventDelegate( wxListCtrl
* list
, int id
)
228 bool wxMacListCtrlEventDelegate::ProcessEvent( wxEvent
& event
)
230 int id
= event
.GetId();
231 wxObject
* obj
= event
.GetEventObject();
233 // even though we use a generic list ctrl underneath, make sure
234 // we present ourselves as wxListCtrl.
235 event
.SetEventObject( m_list
);
238 if ( !event
.IsKindOf( CLASSINFO( wxCommandEvent
) ) )
240 if (m_list
->GetEventHandler()->ProcessEvent( event
))
243 event
.SetEventObject(obj
);
247 // Also try with the original id
248 bool success
= wxEvtHandler::ProcessEvent(event
);
250 event
.SetEventObject(obj
);
251 if (!success
&& id
!= m_id
)
252 success
= wxEvtHandler::ProcessEvent(event
);
256 //-----------------------------------------------------------------------------
257 // wxListCtrlRenameTimer (internal)
258 //-----------------------------------------------------------------------------
260 class wxListCtrlRenameTimer
: public wxTimer
266 wxListCtrlRenameTimer( wxListCtrl
*owner
);
270 //-----------------------------------------------------------------------------
271 // wxListCtrlTextCtrlWrapper: wraps a wxTextCtrl to make it work for inline editing
272 //-----------------------------------------------------------------------------
274 class wxListCtrlTextCtrlWrapper
: public wxEvtHandler
277 // NB: text must be a valid object but not Create()d yet
278 wxListCtrlTextCtrlWrapper(wxListCtrl
*owner
,
282 wxTextCtrl
*GetText() const { return m_text
; }
284 void AcceptChangesAndFinish();
287 void OnChar( wxKeyEvent
&event
);
288 void OnKeyUp( wxKeyEvent
&event
);
289 void OnKillFocus( wxFocusEvent
&event
);
291 bool AcceptChanges();
297 wxString m_startValue
;
300 bool m_aboutToFinish
;
302 DECLARE_EVENT_TABLE()
305 //-----------------------------------------------------------------------------
306 // wxListCtrlRenameTimer (internal)
307 //-----------------------------------------------------------------------------
309 wxListCtrlRenameTimer::wxListCtrlRenameTimer( wxListCtrl
*owner
)
314 void wxListCtrlRenameTimer::Notify()
316 m_owner
->OnRenameTimer();
319 //-----------------------------------------------------------------------------
320 // wxListCtrlTextCtrlWrapper (internal)
321 //-----------------------------------------------------------------------------
323 BEGIN_EVENT_TABLE(wxListCtrlTextCtrlWrapper
, wxEvtHandler
)
324 EVT_CHAR (wxListCtrlTextCtrlWrapper::OnChar
)
325 EVT_KEY_UP (wxListCtrlTextCtrlWrapper::OnKeyUp
)
326 EVT_KILL_FOCUS (wxListCtrlTextCtrlWrapper::OnKillFocus
)
329 wxListCtrlTextCtrlWrapper::wxListCtrlTextCtrlWrapper(wxListCtrl
*owner
,
332 : m_startValue(owner
->GetItemText(itemEdit
)),
333 m_itemEdited(itemEdit
)
338 m_aboutToFinish
= false;
342 owner
->GetItemRect(itemEdit
, rectLabel
);
344 m_text
->Create(owner
, wxID_ANY
, m_startValue
,
345 wxPoint(rectLabel
.x
+offset
,rectLabel
.y
),
346 wxSize(rectLabel
.width
-offset
,rectLabel
.height
));
349 m_text
->PushEventHandler(this);
352 void wxListCtrlTextCtrlWrapper::Finish()
358 m_text
->RemoveEventHandler(this);
359 m_owner
->FinishEditing(m_text
);
361 wxPendingDelete
.Append( this );
365 bool wxListCtrlTextCtrlWrapper::AcceptChanges()
367 const wxString value
= m_text
->GetValue();
369 if ( value
== m_startValue
)
370 // nothing changed, always accept
373 if ( !m_owner
->OnRenameAccept(m_itemEdited
, value
) )
374 // vetoed by the user
377 // accepted, do rename the item
378 m_owner
->SetItemText(m_itemEdited
, value
);
383 void wxListCtrlTextCtrlWrapper::AcceptChangesAndFinish()
385 m_aboutToFinish
= true;
387 // Notify the owner about the changes
390 // Even if vetoed, close the control (consistent with MSW)
394 void wxListCtrlTextCtrlWrapper::OnChar( wxKeyEvent
&event
)
396 switch ( event
.m_keyCode
)
399 AcceptChangesAndFinish();
403 m_owner
->OnRenameCancelled( m_itemEdited
);
412 void wxListCtrlTextCtrlWrapper::OnKeyUp( wxKeyEvent
&event
)
420 // auto-grow the textctrl:
421 wxSize parentSize
= m_owner
->GetSize();
422 wxPoint myPos
= m_text
->GetPosition();
423 wxSize mySize
= m_text
->GetSize();
425 m_text
->GetTextExtent(m_text
->GetValue() + wxT("MM"), &sx
, &sy
);
426 if (myPos
.x
+ sx
> parentSize
.x
)
427 sx
= parentSize
.x
- myPos
.x
;
430 m_text
->SetSize(sx
, wxDefaultCoord
);
435 void wxListCtrlTextCtrlWrapper::OnKillFocus( wxFocusEvent
&event
)
437 if ( !m_finished
&& !m_aboutToFinish
)
439 if ( !AcceptChanges() )
440 m_owner
->OnRenameCancelled( m_itemEdited
);
445 // We must let the native text control handle focus
449 // ============================================================================
451 // ============================================================================
453 wxMacDataBrowserListCtrlControl
* wxListCtrl::GetListPeer() const
455 return dynamic_cast<wxMacDataBrowserListCtrlControl
*> ( GetPeer() );
458 // ----------------------------------------------------------------------------
459 // wxListCtrl construction
460 // ----------------------------------------------------------------------------
462 void wxListCtrl::Init()
464 m_imageListNormal
= NULL
;
465 m_imageListSmall
= NULL
;
466 m_imageListState
= NULL
;
468 // keep track of if we created our own image lists, or if they were assigned
470 m_ownsImageListNormal
= m_ownsImageListSmall
= m_ownsImageListState
= false;
474 m_genericImpl
= NULL
;
476 m_compareFunc
= NULL
;
477 m_compareFuncData
= 0;
478 m_colsInfo
= wxColumnList();
479 m_textColor
= wxNullColour
;
480 m_bgColor
= wxNullColour
;
481 m_textctrlWrapper
= NULL
;
483 m_renameTimer
= NULL
;
486 class wxGenericListCtrlHook
: public wxGenericListCtrl
489 wxGenericListCtrlHook(wxListCtrl
* parent
,
494 const wxValidator
& validator
,
495 const wxString
& name
)
496 : wxGenericListCtrl(parent
, id
, pos
, size
, style
, validator
, name
),
497 m_nativeListCtrl(parent
)
502 virtual wxListItemAttr
* OnGetItemAttr(long item
) const
504 return m_nativeListCtrl
->OnGetItemAttr(item
);
507 virtual int OnGetItemImage(long item
) const
509 return m_nativeListCtrl
->OnGetItemImage(item
);
512 virtual int OnGetItemColumnImage(long item
, long column
) const
514 return m_nativeListCtrl
->OnGetItemColumnImage(item
, column
);
517 virtual wxString
OnGetItemText(long item
, long column
) const
519 return m_nativeListCtrl
->OnGetItemText(item
, column
);
522 wxListCtrl
* m_nativeListCtrl
;
526 void wxListCtrl::OnLeftDown(wxMouseEvent
& event
)
528 if ( m_textctrlWrapper
)
531 m_textctrlWrapper
->AcceptChangesAndFinish();
535 long current
= HitTest(event
.GetPosition(), hitResult
);
536 if ((current
== m_current
) &&
537 (hitResult
& wxLIST_HITTEST_ONITEMLABEL
) &&
538 HasFlag(wxLC_EDIT_LABELS
) )
541 m_renameTimer
->Start( 250, true );
550 void wxListCtrl::OnDblClick(wxMouseEvent
& event
)
552 if ( m_renameTimer
&& m_renameTimer
->IsRunning() )
553 m_renameTimer
->Stop();
557 #if wxABI_VERSION >= 20801
558 void wxListCtrl::OnRightDown(wxMouseEvent
& event
)
561 FireMouseEvent(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK
, event
.GetPosition());
565 void wxListCtrl::OnMiddleDown(wxMouseEvent
& event
)
568 FireMouseEvent(wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK
, event
.GetPosition());
572 void wxListCtrl::FireMouseEvent(wxEventType eventType
, wxPoint position
)
574 wxListEvent
le( eventType
, GetId() );
575 le
.SetEventObject(this);
576 le
.m_pointDrag
= position
;
580 long item
= HitTest(position
, flags
);
581 if (flags
& wxLIST_HITTEST_ONITEM
)
583 le
.m_itemIndex
= item
;
584 le
.m_item
.m_itemId
= item
;
586 HandleWindowEvent(le
);
590 void wxListCtrl::OnChar(wxKeyEvent
& event
)
596 wxListEvent
le( wxEVT_COMMAND_LIST_KEY_DOWN
, GetId() );
597 le
.SetEventObject(this);
598 le
.m_code
= event
.GetKeyCode();
603 // if m_current isn't set, check if there's been a selection
604 // made before continuing
605 m_current
= GetNextItem(-1, wxLIST_NEXT_BELOW
, wxLIST_STATE_SELECTED
);
608 // We need to determine m_current ourselves when navigation keys
609 // are used. Note that PAGEUP and PAGEDOWN do not alter the current
610 // item on native Mac ListCtrl, so we only handle up and down keys.
611 switch ( event
.GetKeyCode() )
622 if ( m_current
< GetItemCount() - 1 )
625 m_current
= GetItemCount() - 1;
632 le
.m_itemIndex
= m_current
;
633 le
.m_item
.m_itemId
= m_current
;
635 HandleWindowEvent(le
);
642 bool wxListCtrl::Create(wxWindow
*parent
,
647 const wxValidator
& validator
,
648 const wxString
& name
)
651 // for now, we'll always use the generic list control for ICON and LIST views,
652 // because they dynamically change the number of columns on resize.
653 // Also, allow the user to set it to use the list ctrl as well.
654 if ( (wxSystemOptions::HasOption( wxMAC_ALWAYS_USE_GENERIC_LISTCTRL
)
655 && (wxSystemOptions::GetOptionInt( wxMAC_ALWAYS_USE_GENERIC_LISTCTRL
) == 1)) ||
656 (style
& wxLC_ICON
) || (style
& wxLC_SMALL_ICON
) || (style
& wxLC_LIST
) )
658 long paneStyle
= style
;
659 paneStyle
&= ~wxSIMPLE_BORDER
;
660 paneStyle
&= ~wxDOUBLE_BORDER
;
661 paneStyle
&= ~wxSUNKEN_BORDER
;
662 paneStyle
&= ~wxRAISED_BORDER
;
663 paneStyle
&= ~wxSTATIC_BORDER
;
664 if ( !wxWindow::Create(parent
, id
, pos
, size
, paneStyle
| wxNO_BORDER
, name
) )
667 // since the generic control is a child, make sure we position it at 0, 0
668 m_genericImpl
= new wxGenericListCtrlHook(this, id
, wxPoint(0, 0), size
, style
, validator
, name
);
669 m_genericImpl
->PushEventHandler( new wxMacListCtrlEventDelegate( this, GetId() ) );
676 if ( !wxWindow::Create(parent
, id
, pos
, size
, style
& ~(wxHSCROLL
| wxVSCROLL
), name
) )
678 m_dbImpl
= new wxMacDataBrowserListCtrlControl( this, pos
, size
, style
);
681 MacPostControlCreate( pos
, size
);
683 InstallControlEventHandler( GetPeer()->GetControlRef() , GetwxMacListCtrlEventHandlerUPP(),
684 GetEventTypeCount(eventList
), eventList
, this,
685 (EventHandlerRef
*)&m_macListCtrlEventHandler
);
687 m_renameTimer
= new wxListCtrlRenameTimer( this );
689 Connect( wxID_ANY
, wxEVT_CHAR
, wxCharEventHandler(wxListCtrl::OnChar
), NULL
, this );
690 Connect( wxID_ANY
, wxEVT_LEFT_DOWN
, wxMouseEventHandler(wxListCtrl::OnLeftDown
), NULL
, this );
691 Connect( wxID_ANY
, wxEVT_LEFT_DCLICK
, wxMouseEventHandler(wxListCtrl::OnDblClick
), NULL
, this );
692 Connect( wxID_ANY
, wxEVT_MIDDLE_DOWN
, wxMouseEventHandler(wxListCtrl::OnMiddleDown
), NULL
, this );
693 Connect( wxID_ANY
, wxEVT_RIGHT_DOWN
, wxMouseEventHandler(wxListCtrl::OnRightDown
), NULL
, this );
699 wxListCtrl::~wxListCtrl()
703 m_genericImpl
->PopEventHandler(/* deleteHandler = */ true);
706 if (m_ownsImageListNormal
)
707 delete m_imageListNormal
;
708 if (m_ownsImageListSmall
)
709 delete m_imageListSmall
;
710 if (m_ownsImageListState
)
711 delete m_imageListState
;
713 delete m_renameTimer
;
715 WX_CLEAR_LIST(wxColumnList
, m_colsInfo
);
720 wxListCtrl::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
722 wxVisualAttributes attr
;
724 attr
.colFg
= wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT
);
725 attr
.colBg
= wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOX
);
726 static wxFont font
= wxFont(wxOSX_SYSTEM_FONT_VIEWS
);
732 // ----------------------------------------------------------------------------
733 // set/get/change style
734 // ----------------------------------------------------------------------------
736 // Add or remove a single window style
737 void wxListCtrl::SetSingleStyle(long style
, bool add
)
739 long flag
= GetWindowStyleFlag();
741 // Get rid of conflicting styles
744 if ( style
& wxLC_MASK_TYPE
)
745 flag
= flag
& ~wxLC_MASK_TYPE
;
746 if ( style
& wxLC_MASK_ALIGN
)
747 flag
= flag
& ~wxLC_MASK_ALIGN
;
748 if ( style
& wxLC_MASK_SORT
)
749 flag
= flag
& ~wxLC_MASK_SORT
;
757 SetWindowStyleFlag(flag
);
760 // Set the whole window style
761 void wxListCtrl::SetWindowStyleFlag(long flag
)
763 if ( flag
!= m_windowStyle
)
765 m_windowStyle
= flag
;
769 m_genericImpl
->SetWindowStyleFlag(flag
);
776 void wxListCtrl::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
778 wxControl::DoSetSize(x
, y
, width
, height
, sizeFlags
);
781 m_genericImpl
->SetSize(0, 0, width
, height
, sizeFlags
);
783 // determine if we need a horizontal scrollbar, and add it if so
787 for (int column
= 0; column
< GetColumnCount(); column
++)
789 totalWidth
+= m_dbImpl
->GetColumnWidth( column
);
792 if ( !(m_dbImpl
->GetFlags() & wxHSCROLL
) )
794 Boolean vertScrollBar
;
795 GetDataBrowserHasScrollBars( m_dbImpl
->GetControlRef(), NULL
, &vertScrollBar
);
796 if (totalWidth
> width
)
797 SetDataBrowserHasScrollBars( m_dbImpl
->GetControlRef(), true, vertScrollBar
);
799 SetDataBrowserHasScrollBars( m_dbImpl
->GetControlRef(), false, vertScrollBar
);
804 wxSize
wxListCtrl::DoGetBestSize() const
806 return wxWindow::DoGetBestSize();
809 bool wxListCtrl::SetFont(const wxFont
& font
)
812 rv
= wxControl::SetFont(font
);
814 rv
= m_genericImpl
->SetFont(font
);
818 bool wxListCtrl::SetForegroundColour(const wxColour
& colour
)
822 rv
= m_genericImpl
->SetForegroundColour(colour
);
824 SetTextColour(colour
);
828 bool wxListCtrl::SetBackgroundColour(const wxColour
& colour
)
832 rv
= m_genericImpl
->SetBackgroundColour(colour
);
838 wxColour
wxListCtrl::GetBackgroundColour() const
841 return m_genericImpl
->GetBackgroundColour();
848 void wxListCtrl::Freeze ()
851 m_genericImpl
->Freeze();
855 void wxListCtrl::Thaw ()
858 m_genericImpl
->Thaw();
862 void wxListCtrl::Update ()
865 m_genericImpl
->Update();
869 // ----------------------------------------------------------------------------
871 // ----------------------------------------------------------------------------
873 // Gets information about this column
874 bool wxListCtrl::GetColumn(int col
, wxListItem
& item
) const
877 return m_genericImpl
->GetColumn(col
, item
);
883 wxColumnList::compatibility_iterator node
= m_colsInfo
.Item( col
);
884 wxASSERT_MSG( node
, wxT("invalid column index in wxMacListCtrlItem") );
885 wxListItem
* column
= node
->GetData();
887 long mask
= column
->GetMask();
888 if (mask
& wxLIST_MASK_TEXT
)
889 item
.SetText(column
->GetText());
890 if (mask
& wxLIST_MASK_DATA
)
891 item
.SetData(column
->GetData());
892 if (mask
& wxLIST_MASK_IMAGE
)
893 item
.SetImage(column
->GetImage());
894 if (mask
& wxLIST_MASK_STATE
)
895 item
.SetState(column
->GetState());
896 if (mask
& wxLIST_MASK_FORMAT
)
897 item
.SetAlign(column
->GetAlign());
898 if (mask
& wxLIST_MASK_WIDTH
)
899 item
.SetWidth(column
->GetWidth());
905 // Sets information about this column
906 bool wxListCtrl::SetColumn(int col
, wxListItem
& item
)
909 return m_genericImpl
->SetColumn(col
, item
);
913 wxASSERT_MSG( col
< (int)m_colsInfo
.GetCount(), wxT("invalid column index in wxMacListCtrlItem") );
915 long mask
= item
.GetMask();
918 GetColumn( col
, listItem
);
920 if (mask
& wxLIST_MASK_TEXT
)
921 listItem
.SetText(item
.GetText());
922 if (mask
& wxLIST_MASK_DATA
)
923 listItem
.SetData(item
.GetData());
924 if (mask
& wxLIST_MASK_IMAGE
)
925 listItem
.SetImage(item
.GetImage());
926 if (mask
& wxLIST_MASK_STATE
)
927 listItem
.SetState(item
.GetState());
928 if (mask
& wxLIST_MASK_FORMAT
)
929 listItem
.SetAlign(item
.GetAlign());
930 if (mask
& wxLIST_MASK_WIDTH
)
931 listItem
.SetWidth(item
.GetWidth());
934 // change the appearance in the databrowser.
935 DataBrowserListViewHeaderDesc columnDesc
;
936 columnDesc
.version
=kDataBrowserListViewLatestHeaderDesc
;
938 DataBrowserTableViewColumnID id
= 0;
939 verify_noerr( m_dbImpl
->GetColumnIDFromIndex( col
, &id
) );
940 verify_noerr( m_dbImpl
->GetHeaderDesc( id
, &columnDesc
) );
943 if (item.GetMask() & wxLIST_MASK_TEXT)
947 enc = GetFont().GetEncoding();
949 enc = wxLocale::GetSystemEncoding();
950 wxCFStringRef cfTitle;
951 cfTitle.Assign( item.GetText() , enc );
952 if(columnDesc.titleString)
953 CFRelease(columnDesc.titleString);
954 columnDesc.titleString = cfTitle;
958 if (item
.GetMask() & wxLIST_MASK_IMAGE
&& item
.GetImage() != -1 )
960 wxImageList
* imageList
= GetImageList(wxIMAGE_LIST_SMALL
);
961 if (imageList
&& imageList
->GetImageCount() > 0 )
963 wxBitmap bmp
= imageList
->GetBitmap( item
.GetImage() );
964 IconRef icon
= bmp
.GetIconRef();
965 columnDesc
.btnContentInfo
.u
.iconRef
= icon
;
966 columnDesc
.btnContentInfo
.contentType
= kControlContentIconRef
;
970 verify_noerr( m_dbImpl
->SetHeaderDesc( id
, &columnDesc
) );
976 int wxListCtrl::GetColumnCount() const
979 return m_genericImpl
->GetColumnCount();
984 m_dbImpl
->GetColumnCount(&count
);
991 // Gets the column width
992 int wxListCtrl::GetColumnWidth(int col
) const
995 return m_genericImpl
->GetColumnWidth(col
);
999 return m_dbImpl
->GetColumnWidth(col
);
1005 // Sets the column width
1006 bool wxListCtrl::SetColumnWidth(int col
, int width
)
1009 return m_genericImpl
->SetColumnWidth(col
, width
);
1013 if ( width
== wxLIST_AUTOSIZE_USEHEADER
)
1015 width
= 150; // FIXME
1020 for (int column
= 0; column
< GetColumnCount(); column
++)
1023 GetColumn(column
, colInfo
);
1025 colInfo
.SetWidth(width
);
1026 SetColumn(column
, colInfo
);
1028 const int mywidth
= (width
== wxLIST_AUTOSIZE
)
1029 ? CalcColumnAutoWidth(column
) : width
;
1030 m_dbImpl
->SetColumnWidth(column
, mywidth
);
1035 if ( width
== wxLIST_AUTOSIZE
)
1036 width
= CalcColumnAutoWidth(col
);
1039 GetColumn(col
, colInfo
);
1041 colInfo
.SetWidth(width
);
1042 SetColumn(col
, colInfo
);
1043 m_dbImpl
->SetColumnWidth(col
, width
);
1051 // Gets the number of items that can fit vertically in the
1052 // visible area of the list control (list or report view)
1053 // or the total number of items in the list control (icon
1054 // or small icon view)
1055 int wxListCtrl::GetCountPerPage() const
1058 return m_genericImpl
->GetCountPerPage();
1063 m_dbImpl
->GetDefaultRowHeight( &height
);
1065 return GetClientSize().y
/ height
;
1071 // Gets the edit control for editing labels.
1072 wxTextCtrl
* wxListCtrl::GetEditControl() const
1075 return m_genericImpl
->GetEditControl();
1080 // Gets information about the item
1081 bool wxListCtrl::GetItem(wxListItem
& info
) const
1084 return m_genericImpl
->GetItem(info
);
1090 if (info
.m_itemId
>= 0 && info
.m_itemId
< GetItemCount())
1092 m_dbImpl
->MacGetColumnInfo(info
.m_itemId
, info
.m_col
, info
);
1093 // MacGetColumnInfo returns erroneous information in the state field, so zero it.
1095 if (info
.GetMask() & wxLIST_MASK_STATE
)
1097 DataBrowserItemID id
= (DataBrowserItemID
)m_dbImpl
->GetItemFromLine(info
.m_itemId
);
1098 if (IsDataBrowserItemSelected( m_dbImpl
->GetControlRef(), id
))
1099 info
.SetState(info
.GetState() | wxLIST_STATE_SELECTED
);
1105 if (info
.m_itemId
>= 0 && info
.m_itemId
< GetItemCount())
1107 info
.SetText( OnGetItemText(info
.m_itemId
, info
.m_col
) );
1108 info
.SetImage( OnGetItemColumnImage(info
.m_itemId
, info
.m_col
) );
1109 if (info
.GetMask() & wxLIST_MASK_STATE
)
1111 if (IsDataBrowserItemSelected( m_dbImpl
->GetControlRef(), info
.m_itemId
+1 ))
1112 info
.SetState(info
.GetState() | wxLIST_STATE_SELECTED
);
1115 wxListItemAttr
* attrs
= OnGetItemAttr( info
.m_itemId
);
1118 info
.SetFont( attrs
->GetFont() );
1119 info
.SetBackgroundColour( attrs
->GetBackgroundColour() );
1120 info
.SetTextColour( attrs
->GetTextColour() );
1125 bool success
= true;
1129 // Sets information about the item
1130 bool wxListCtrl::SetItem(wxListItem
& info
)
1133 return m_genericImpl
->SetItem(info
);
1136 m_dbImpl
->MacSetColumnInfo( info
.m_itemId
, info
.m_col
, &info
);
1141 long wxListCtrl::SetItem(long index
, int col
, const wxString
& label
, int imageId
)
1144 return m_genericImpl
->SetItem(index
, col
, label
, imageId
);
1147 info
.m_text
= label
;
1148 info
.m_mask
= wxLIST_MASK_TEXT
;
1149 info
.m_itemId
= index
;
1153 info
.m_image
= imageId
;
1154 info
.m_mask
|= wxLIST_MASK_IMAGE
;
1156 return SetItem(info
);
1160 // Gets the item state
1161 int wxListCtrl::GetItemState(long item
, long stateMask
) const
1164 return m_genericImpl
->GetItemState(item
, stateMask
);
1168 if ( HasFlag(wxLC_VIRTUAL
) )
1170 if (stateMask
== wxLIST_STATE_SELECTED
)
1172 if (IsDataBrowserItemSelected( m_dbImpl
->GetControlRef(), item
+1 ))
1173 return wxLIST_STATE_SELECTED
;
1182 info
.m_mask
= wxLIST_MASK_STATE
;
1183 info
.m_stateMask
= stateMask
;
1184 info
.m_itemId
= item
;
1189 return info
.m_state
;
1196 // Sets the item state
1197 bool wxListCtrl::SetItemState(long item
, long state
, long stateMask
)
1200 return m_genericImpl
->SetItemState(item
, state
, stateMask
);
1204 DataBrowserSetOption option
= kDataBrowserItemsAdd
;
1205 if ( (stateMask
& wxLIST_STATE_SELECTED
) && state
== 0 )
1206 option
= kDataBrowserItemsRemove
;
1210 if ( HasFlag(wxLC_VIRTUAL
) )
1212 wxMacDataItemBrowserSelectionSuppressor
suppressor(m_dbImpl
);
1213 m_dbImpl
->SetSelectedAllItems(option
);
1217 for(int i
= 0; i
< GetItemCount();i
++)
1221 info
.m_mask
= wxLIST_MASK_STATE
;
1222 info
.m_stateMask
= stateMask
;
1223 info
.m_state
= state
;
1230 if ( HasFlag(wxLC_VIRTUAL
) )
1232 long itemID
= item
+1;
1233 bool isSelected
= IsDataBrowserItemSelected(m_dbImpl
->GetControlRef(), (DataBrowserItemID
)itemID
);
1234 bool isSelectedState
= (state
== wxLIST_STATE_SELECTED
);
1236 // toggle the selection state if wxListInfo state and actual state don't match.
1237 if ( (stateMask
& wxLIST_STATE_SELECTED
) && isSelected
!= isSelectedState
)
1239 SetDataBrowserSelectedItems(m_dbImpl
->GetControlRef(), 1, (DataBrowserItemID
*)&itemID
, option
);
1245 info
.m_itemId
= item
;
1246 info
.m_mask
= wxLIST_MASK_STATE
;
1247 info
.m_stateMask
= stateMask
;
1248 info
.m_state
= state
;
1249 return SetItem(info
);
1256 // Sets the item image
1257 bool wxListCtrl::SetItemImage(long item
, int image
, int WXUNUSED(selImage
))
1259 return SetItemColumnImage(item
, 0, image
);
1262 // Sets the item image
1263 bool wxListCtrl::SetItemColumnImage(long item
, long column
, int image
)
1266 return m_genericImpl
->SetItemColumnImage(item
, column
, image
);
1270 info
.m_mask
= wxLIST_MASK_IMAGE
;
1271 info
.m_image
= image
;
1272 info
.m_itemId
= item
;
1273 info
.m_col
= column
;
1275 return SetItem(info
);
1278 // Gets the item text
1279 wxString
wxListCtrl::GetItemText(long item
, int column
) const
1282 return m_genericImpl
->GetItemText(item
, column
);
1286 info
.m_mask
= wxLIST_MASK_TEXT
;
1287 info
.m_itemId
= item
;
1288 info
.m_col
= column
;
1291 return wxEmptyString
;
1295 // Sets the item text
1296 void wxListCtrl::SetItemText(long item
, const wxString
& str
)
1299 return m_genericImpl
->SetItemText(item
, str
);
1303 info
.m_mask
= wxLIST_MASK_TEXT
;
1304 info
.m_itemId
= item
;
1310 // Gets the item data
1311 long wxListCtrl::GetItemData(long item
) const
1314 return m_genericImpl
->GetItemData(item
);
1318 info
.m_mask
= wxLIST_MASK_DATA
;
1319 info
.m_itemId
= item
;
1326 // Sets the item data
1327 bool wxListCtrl::SetItemPtrData(long item
, wxUIntPtr data
)
1330 return m_genericImpl
->SetItemData(item
, data
);
1334 info
.m_mask
= wxLIST_MASK_DATA
;
1335 info
.m_itemId
= item
;
1338 return SetItem(info
);
1341 wxRect
wxListCtrl::GetViewRect() const
1343 wxASSERT_MSG( !HasFlag(wxLC_REPORT
| wxLC_LIST
),
1344 wxT("wxListCtrl::GetViewRect() only works in icon mode") );
1347 return m_genericImpl
->GetViewRect();
1353 bool wxListCtrl::GetSubItemRect( long item
, long subItem
, wxRect
& rect
, int code
) const
1356 return m_genericImpl
->GetSubItemRect(item
, subItem
, rect
, code
);
1358 // TODO: implement for DataBrowser implementation
1362 // Gets the item rectangle
1363 bool wxListCtrl::GetItemRect(long item
, wxRect
& rect
, int code
) const
1366 return m_genericImpl
->GetItemRect(item
, rect
, code
);
1371 DataBrowserItemID id
;
1373 DataBrowserTableViewColumnID col
= 0;
1374 verify_noerr( m_dbImpl
->GetColumnIDFromIndex( 0, &col
) );
1377 DataBrowserPropertyPart part
= kDataBrowserPropertyEnclosingPart
;
1378 if ( code
== wxLIST_RECT_LABEL
)
1379 part
= kDataBrowserPropertyTextPart
;
1380 else if ( code
== wxLIST_RECT_ICON
)
1381 part
= kDataBrowserPropertyIconPart
;
1383 if ( !(GetWindowStyleFlag() & wxLC_VIRTUAL
) )
1385 wxMacDataItem
* thisItem
= m_dbImpl
->GetItemFromLine(item
);
1386 id
= (DataBrowserItemID
) thisItem
;
1391 GetDataBrowserItemPartBounds( m_dbImpl
->GetControlRef(), id
, col
, part
, &bounds
);
1393 rect
.x
= bounds
.left
;
1394 rect
.y
= bounds
.top
;
1395 rect
.width
= bounds
.right
- bounds
.left
; //GetClientSize().x; // we need the width of the whole row, not just the item.
1396 rect
.height
= bounds
.bottom
- bounds
.top
;
1397 //fprintf("id = %d, bounds = %d, %d, %d, %d\n", id, rect.x, rect.y, rect.width, rect.height);
1402 // Gets the item position
1403 bool wxListCtrl::GetItemPosition(long item
, wxPoint
& pos
) const
1406 return m_genericImpl
->GetItemPosition(item
, pos
);
1408 bool success
= false;
1413 GetItemRect(item
, itemRect
);
1414 pos
= itemRect
.GetPosition();
1421 // Sets the item position.
1422 bool wxListCtrl::SetItemPosition(long item
, const wxPoint
& pos
)
1425 return m_genericImpl
->SetItemPosition(item
, pos
);
1430 // Gets the number of items in the list control
1431 int wxListCtrl::GetItemCount() const
1434 return m_genericImpl
->GetItemCount();
1437 return m_dbImpl
->MacGetCount();
1442 void wxListCtrl::SetItemSpacing( int spacing
, bool isSmall
)
1445 m_genericImpl
->SetItemSpacing(spacing
, isSmall
);
1448 wxSize
wxListCtrl::GetItemSpacing() const
1451 return m_genericImpl
->GetItemSpacing();
1453 return wxSize(0, 0);
1456 void wxListCtrl::SetItemTextColour( long item
, const wxColour
&col
)
1460 m_genericImpl
->SetItemTextColour(item
, col
);
1465 info
.m_itemId
= item
;
1466 info
.SetTextColour( col
);
1470 wxColour
wxListCtrl::GetItemTextColour( long item
) const
1473 return m_genericImpl
->GetItemTextColour(item
);
1479 return info
.GetTextColour();
1481 return wxNullColour
;
1484 void wxListCtrl::SetItemBackgroundColour( long item
, const wxColour
&col
)
1488 m_genericImpl
->SetItemBackgroundColour(item
, col
);
1493 info
.m_itemId
= item
;
1494 info
.SetBackgroundColour( col
);
1498 wxColour
wxListCtrl::GetItemBackgroundColour( long item
) const
1501 return m_genericImpl
->GetItemBackgroundColour(item
);
1507 return info
.GetBackgroundColour();
1509 return wxNullColour
;
1512 void wxListCtrl::SetItemFont( long item
, const wxFont
&f
)
1516 m_genericImpl
->SetItemFont(item
, f
);
1521 info
.m_itemId
= item
;
1526 wxFont
wxListCtrl::GetItemFont( long item
) const
1529 return m_genericImpl
->GetItemFont(item
);
1535 return info
.GetFont();
1541 // Gets the number of selected items in the list control
1542 int wxListCtrl::GetSelectedItemCount() const
1545 return m_genericImpl
->GetSelectedItemCount();
1548 return m_dbImpl
->GetSelectedItemCount(NULL
, true);
1553 // Gets the text colour of the listview
1554 wxColour
wxListCtrl::GetTextColour() const
1557 return m_genericImpl
->GetTextColour();
1559 // TODO: we need owner drawn list items to customize text color.
1563 return wxNullColour
;
1566 // Sets the text colour of the listview
1567 void wxListCtrl::SetTextColour(const wxColour
& col
)
1571 m_genericImpl
->SetTextColour(col
);
1579 // Gets the index of the topmost visible item when in
1580 // list or report view
1581 long wxListCtrl::GetTopItem() const
1584 return m_genericImpl
->GetTopItem();
1589 long item
= HitTest( wxPoint(1, 1), flags
);
1590 if (flags
== wxLIST_HITTEST_ONITEM
)
1597 // Searches for an item, starting from 'item'.
1598 // 'geometry' is one of
1599 // wxLIST_NEXT_ABOVE/ALL/BELOW/LEFT/RIGHT.
1600 // 'state' is a state bit flag, one or more of
1601 // wxLIST_STATE_DROPHILITED/FOCUSED/SELECTED/CUT.
1602 // item can be -1 to find the first item that matches the
1604 // Returns the item or -1 if unsuccessful.
1605 long wxListCtrl::GetNextItem(long item
, int geom
, int state
) const
1608 return m_genericImpl
->GetNextItem(item
, geom
, state
);
1610 // TODO: implement all geometry and state options?
1613 if ( geom
== wxLIST_NEXT_ALL
|| geom
== wxLIST_NEXT_BELOW
)
1615 long count
= m_dbImpl
->MacGetCount() ;
1616 for ( long line
= item
+ 1 ; line
< count
; line
++ )
1618 DataBrowserItemID id
= line
+ 1;
1620 id
= (DataBrowserItemID
)m_dbImpl
->GetItemFromLine(line
);
1622 if ( (state
& wxLIST_STATE_FOCUSED
) && (m_current
== line
))
1625 if ( (state
== wxLIST_STATE_DONTCARE
) )
1628 if ( (state
& wxLIST_STATE_SELECTED
) && IsDataBrowserItemSelected(m_dbImpl
->GetControlRef(), id
) )
1633 if ( geom
== wxLIST_NEXT_ABOVE
)
1637 item2
= m_dbImpl
->MacGetCount();
1639 for ( long line
= item2
- 1 ; line
>= 0; line
-- )
1641 DataBrowserItemID id
= line
+ 1;
1643 id
= (DataBrowserItemID
)m_dbImpl
->GetItemFromLine(line
);
1645 if ( (state
& wxLIST_STATE_FOCUSED
) && (m_current
== line
))
1648 if ( (state
== wxLIST_STATE_DONTCARE
) )
1651 if ( (state
& wxLIST_STATE_SELECTED
) && IsDataBrowserItemSelected(m_dbImpl
->GetControlRef(), id
) )
1661 wxImageList
*wxListCtrl::GetImageList(int which
) const
1664 return m_genericImpl
->GetImageList(which
);
1666 if ( which
== wxIMAGE_LIST_NORMAL
)
1668 return m_imageListNormal
;
1670 else if ( which
== wxIMAGE_LIST_SMALL
)
1672 return m_imageListSmall
;
1674 else if ( which
== wxIMAGE_LIST_STATE
)
1676 return m_imageListState
;
1681 void wxListCtrl::SetImageList(wxImageList
*imageList
, int which
)
1685 m_genericImpl
->SetImageList(imageList
, which
);
1689 if ( which
== wxIMAGE_LIST_NORMAL
)
1691 if (m_ownsImageListNormal
) delete m_imageListNormal
;
1692 m_imageListNormal
= imageList
;
1693 m_ownsImageListNormal
= false;
1695 else if ( which
== wxIMAGE_LIST_SMALL
)
1697 if (m_ownsImageListSmall
) delete m_imageListSmall
;
1698 m_imageListSmall
= imageList
;
1699 m_ownsImageListSmall
= false;
1701 else if ( which
== wxIMAGE_LIST_STATE
)
1703 if (m_ownsImageListState
) delete m_imageListState
;
1704 m_imageListState
= imageList
;
1705 m_ownsImageListState
= false;
1709 void wxListCtrl::AssignImageList(wxImageList
*imageList
, int which
)
1713 m_genericImpl
->AssignImageList(imageList
, which
);
1717 SetImageList(imageList
, which
);
1718 if ( which
== wxIMAGE_LIST_NORMAL
)
1719 m_ownsImageListNormal
= true;
1720 else if ( which
== wxIMAGE_LIST_SMALL
)
1721 m_ownsImageListSmall
= true;
1722 else if ( which
== wxIMAGE_LIST_STATE
)
1723 m_ownsImageListState
= true;
1726 // ----------------------------------------------------------------------------
1728 // ----------------------------------------------------------------------------
1730 // Arranges the items
1731 bool wxListCtrl::Arrange(int flag
)
1734 return m_genericImpl
->Arrange(flag
);
1739 bool wxListCtrl::DeleteItem(long item
)
1742 return m_genericImpl
->DeleteItem(item
);
1746 m_dbImpl
->MacDelete(item
);
1747 wxListEvent
event( wxEVT_COMMAND_LIST_DELETE_ITEM
, GetId() );
1748 event
.SetEventObject( this );
1749 event
.m_itemIndex
= item
;
1750 HandleWindowEvent( event
);
1756 // Deletes all items
1757 bool wxListCtrl::DeleteAllItems()
1761 return m_genericImpl
->DeleteAllItems();
1765 m_dbImpl
->MacClear();
1766 wxListEvent
event( wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS
, GetId() );
1767 event
.SetEventObject( this );
1768 HandleWindowEvent( event
);
1773 // Deletes all items
1774 bool wxListCtrl::DeleteAllColumns()
1777 return m_genericImpl
->DeleteAllColumns();
1782 m_dbImpl
->GetColumnCount(&cols
);
1783 for (UInt32 col
= 0; col
< cols
; col
++)
1793 bool wxListCtrl::DeleteColumn(int col
)
1796 return m_genericImpl
->DeleteColumn(col
);
1800 OSStatus err
= m_dbImpl
->RemoveColumn(col
);
1801 return err
== noErr
;
1807 // Clears items, and columns if there are any.
1808 void wxListCtrl::ClearAll()
1812 m_genericImpl
->ClearAll();
1823 wxTextCtrl
* wxListCtrl::EditLabel(long item
, wxClassInfo
* textControlClass
)
1826 return m_genericImpl
->EditLabel(item
, textControlClass
);
1830 wxCHECK_MSG( (item
>= 0) && ((long)item
< GetItemCount()), NULL
,
1831 wxT("wrong index in wxListCtrl::EditLabel()") );
1833 wxASSERT_MSG( textControlClass
->IsKindOf(CLASSINFO(wxTextCtrl
)),
1834 wxT("EditLabel() needs a text control") );
1836 wxListEvent
le( wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
, GetParent()->GetId() );
1837 le
.SetEventObject( this );
1838 le
.m_itemIndex
= item
;
1840 GetItem( le
.m_item
);
1842 if ( GetParent()->HandleWindowEvent( le
) && !le
.IsAllowed() )
1844 // vetoed by user code
1848 wxTextCtrl
* const text
= (wxTextCtrl
*)textControlClass
->CreateObject();
1849 m_textctrlWrapper
= new wxListCtrlTextCtrlWrapper(this, text
, item
);
1850 return m_textctrlWrapper
->GetText();
1855 // End label editing, optionally cancelling the edit
1856 bool wxListCtrl::EndEditLabel(bool WXUNUSED(cancel
))
1858 // TODO: generic impl. doesn't have this method - is it needed for us?
1860 return true; // m_genericImpl->EndEditLabel(cancel);
1864 DataBrowserTableViewColumnID id
= 0;
1865 verify_noerr( m_dbImpl
->GetColumnIDFromIndex( 0, &id
) );
1866 verify_noerr( SetDataBrowserEditItem(m_dbImpl
->GetControlRef(), kDataBrowserNoItem
, id
) );
1871 // Ensures this item is visible
1872 bool wxListCtrl::EnsureVisible(long item
)
1875 return m_genericImpl
->EnsureVisible(item
);
1879 wxMacDataItem
* dataItem
= m_dbImpl
->GetItemFromLine(item
);
1880 m_dbImpl
->RevealItem(dataItem
, kDataBrowserRevealWithoutSelecting
);
1886 // Find an item whose label matches this string, starting from the item after 'start'
1887 // or the beginning if 'start' is -1.
1888 long wxListCtrl::FindItem(long start
, const wxString
& str
, bool partial
)
1891 return m_genericImpl
->FindItem(start
, str
, partial
);
1893 wxString str_upper
= str
.Upper();
1898 long count
= GetItemCount();
1902 wxString line_upper
= GetItemText(idx
).Upper();
1905 if (line_upper
== str_upper
)
1910 if (line_upper
.find(str_upper
) == 0)
1920 // Find an item whose data matches this data, starting from the item after 'start'
1921 // or the beginning if 'start' is -1.
1922 long wxListCtrl::FindItem(long start
, long data
)
1925 return m_genericImpl
->FindItem(start
, data
);
1930 long count
= GetItemCount();
1934 if (GetItemData(idx
) == data
)
1942 // Find an item nearest this position in the specified direction, starting from
1943 // the item after 'start' or the beginning if 'start' is -1.
1944 long wxListCtrl::FindItem(long start
, const wxPoint
& pt
, int direction
)
1947 return m_genericImpl
->FindItem(start
, pt
, direction
);
1951 static void calculateCGDrawingBounds(CGRect inItemRect
, CGRect
*outIconRect
, CGRect
*outTextRect
, bool hasIcon
);
1953 // Determines which item (if any) is at the specified point,
1954 // giving details in 'flags' (see wxLIST_HITTEST_... flags above)
1956 wxListCtrl::HitTest(const wxPoint
& point
, int& flags
, long *ptrSubItem
) const
1962 return m_genericImpl
->HitTest(point
, flags
, ptrSubItem
);
1964 flags
= wxLIST_HITTEST_NOWHERE
;
1967 int colHeaderHeight
= 22; // TODO: Find a way to get this value from the db control?
1968 UInt16 rowHeight
= 0;
1969 m_dbImpl
->GetDefaultRowHeight(&rowHeight
);
1972 // get the actual row by taking scroll position into account
1973 UInt32 offsetX
, offsetY
;
1974 m_dbImpl
->GetScrollPosition( &offsetY
, &offsetX
);
1977 if ( !(GetWindowStyleFlag() & wxLC_NO_HEADER
) )
1978 y
-= colHeaderHeight
;
1983 int row
= y
/ rowHeight
;
1984 DataBrowserItemID id
;
1985 m_dbImpl
->GetItemID( (DataBrowserTableViewRowIndex
) row
, &id
);
1987 CGPoint click_point
= CGPointMake( point
.x
, point
.y
);
1988 if (row
< GetItemCount() )
1991 for( column
= 0; column
< GetColumnCount(); column
++ )
1994 CGRect enclosingCGRect
, iconCGRect
, textCGRect
;
1996 wxMacListCtrlItem
* lcItem
;
1998 WXUNUSED_UNLESS_DEBUG( OSStatus status
= ) m_dbImpl
->GetItemPartBounds( id
, kMinColumnId
+ column
, kDataBrowserPropertyEnclosingPart
, &enclosingRect
);
1999 wxASSERT( status
== noErr
);
2001 enclosingCGRect
= CGRectMake(enclosingRect
.left
,
2003 enclosingRect
.right
- enclosingRect
.left
,
2004 enclosingRect
.bottom
- enclosingRect
.top
);
2008 if ( !(GetWindowStyleFlag() & wxLC_VIRTUAL
) )
2010 lcItem
= (wxMacListCtrlItem
*) id
;
2011 if (lcItem
->HasColumnInfo(column
))
2013 wxListItem
* item
= lcItem
->GetColumnInfo(column
);
2015 if (item
->GetMask() & wxLIST_MASK_IMAGE
)
2017 imgIndex
= item
->GetImage();
2023 long itemNum
= (long)id
-1;
2024 if (itemNum
>= 0 && itemNum
< GetItemCount())
2026 imgIndex
= OnGetItemColumnImage( itemNum
, column
);
2031 calculateCGDrawingBounds(enclosingCGRect
, &iconCGRect
, &textCGRect
, (imgIndex
!= -1) );
2033 if ( CGRectContainsPoint( iconCGRect
, click_point
) )
2035 flags
= wxLIST_HITTEST_ONITEMICON
;
2037 *ptrSubItem
= column
;
2040 else if ( CGRectContainsPoint( textCGRect
, click_point
) )
2042 flags
= wxLIST_HITTEST_ONITEMLABEL
;
2044 *ptrSubItem
= column
;
2049 if ( !(GetWindowStyleFlag() & wxLC_VIRTUAL
) )
2051 wxMacListCtrlItem
* lcItem
;
2052 lcItem
= (wxMacListCtrlItem
*) id
;
2055 flags
= wxLIST_HITTEST_ONITEM
;
2057 *ptrSubItem
= column
;
2063 flags
= wxLIST_HITTEST_ONITEM
;
2065 *ptrSubItem
= column
;
2071 if ( wxControl::HitTest( point
) )
2072 flags
= wxLIST_HITTEST_NOWHERE
;
2079 int wxListCtrl::GetScrollPos(int orient
) const
2082 return m_genericImpl
->GetScrollPos(orient
);
2086 UInt32 offsetX
, offsetY
;
2087 m_dbImpl
->GetScrollPosition( &offsetY
, &offsetX
);
2088 if ( orient
== wxHORIZONTAL
)
2097 // Inserts an item, returning the index of the new item if successful,
2099 long wxListCtrl::InsertItem(wxListItem
& info
)
2101 wxASSERT_MSG( !IsVirtual(), wxT("can't be used with virtual controls") );
2104 return m_genericImpl
->InsertItem(info
);
2106 if (m_dbImpl
&& !IsVirtual())
2108 int count
= GetItemCount();
2110 if (info
.m_itemId
> count
)
2111 info
.m_itemId
= count
;
2113 m_dbImpl
->MacInsertItem(info
.m_itemId
, &info
);
2115 wxListEvent
event( wxEVT_COMMAND_LIST_INSERT_ITEM
, GetId() );
2116 event
.SetEventObject( this );
2117 event
.m_itemIndex
= info
.m_itemId
;
2118 HandleWindowEvent( event
);
2119 return info
.m_itemId
;
2124 long wxListCtrl::InsertItem(long index
, const wxString
& label
)
2127 return m_genericImpl
->InsertItem(index
, label
);
2130 info
.m_text
= label
;
2131 info
.m_mask
= wxLIST_MASK_TEXT
;
2132 info
.m_itemId
= index
;
2133 return InsertItem(info
);
2136 // Inserts an image item
2137 long wxListCtrl::InsertItem(long index
, int imageIndex
)
2140 return m_genericImpl
->InsertItem(index
, imageIndex
);
2143 info
.m_image
= imageIndex
;
2144 info
.m_mask
= wxLIST_MASK_IMAGE
;
2145 info
.m_itemId
= index
;
2146 return InsertItem(info
);
2149 // Inserts an image/string item
2150 long wxListCtrl::InsertItem(long index
, const wxString
& label
, int imageIndex
)
2153 return m_genericImpl
->InsertItem(index
, label
, imageIndex
);
2156 info
.m_image
= imageIndex
;
2157 info
.m_text
= label
;
2158 info
.m_mask
= wxLIST_MASK_IMAGE
| wxLIST_MASK_TEXT
;
2159 info
.m_itemId
= index
;
2160 return InsertItem(info
);
2163 // For list view mode (only), inserts a column.
2164 long wxListCtrl::InsertColumn(long col
, wxListItem
& item
)
2167 return m_genericImpl
->InsertColumn(col
, item
);
2171 int width
= item
.GetWidth();
2172 if ( !(item
.GetMask() & wxLIST_MASK_WIDTH
) )
2175 DataBrowserPropertyType type
= kDataBrowserCustomType
; //kDataBrowserTextType;
2176 wxImageList
* imageList
= GetImageList(wxIMAGE_LIST_SMALL
);
2177 if (imageList
&& imageList
->GetImageCount() > 0)
2179 wxBitmap bmp
= imageList
->GetBitmap(0);
2181 // type = kDataBrowserIconAndTextType;
2184 SInt16 just
= teFlushDefault
;
2185 if (item
.GetMask() & wxLIST_MASK_FORMAT
)
2187 if (item
.GetAlign() == wxLIST_FORMAT_LEFT
)
2189 else if (item
.GetAlign() == wxLIST_FORMAT_CENTER
)
2191 else if (item
.GetAlign() == wxLIST_FORMAT_RIGHT
)
2192 just
= teFlushRight
;
2194 m_dbImpl
->InsertColumn(col
, type
, item
.GetText(), just
, width
);
2196 wxListItem
* listItem
= new wxListItem(item
);
2197 m_colsInfo
.Insert( col
, listItem
);
2198 SetColumn(col
, item
);
2200 // set/remove options based on the wxListCtrl type.
2201 DataBrowserTableViewColumnID id
;
2202 m_dbImpl
->GetColumnIDFromIndex(col
, &id
);
2203 DataBrowserPropertyFlags flags
;
2204 verify_noerr(m_dbImpl
->GetPropertyFlags(id
, &flags
));
2205 if (GetWindowStyleFlag() & wxLC_EDIT_LABELS
)
2206 flags
|= kDataBrowserPropertyIsEditable
;
2208 if (GetWindowStyleFlag() & wxLC_VIRTUAL
){
2209 flags
&= ~kDataBrowserListViewSortableColumn
;
2211 verify_noerr(m_dbImpl
->SetPropertyFlags(id
, flags
));
2217 long wxListCtrl::InsertColumn(long col
,
2218 const wxString
& heading
,
2223 return m_genericImpl
->InsertColumn(col
, heading
, format
, width
);
2226 item
.m_mask
= wxLIST_MASK_TEXT
| wxLIST_MASK_FORMAT
;
2227 item
.m_text
= heading
;
2230 item
.m_mask
|= wxLIST_MASK_WIDTH
;
2231 item
.m_width
= width
;
2233 item
.m_format
= format
;
2235 return InsertColumn(col
, item
);
2238 // scroll the control by the given number of pixels (exception: in list view,
2239 // dx is interpreted as number of columns)
2240 bool wxListCtrl::ScrollList(int dx
, int dy
)
2243 return m_genericImpl
->ScrollList(dx
, dy
);
2247 // Notice that the parameter order is correct here: first argument is
2248 // the "top" displacement, second one is the "left" one.
2249 m_dbImpl
->SetScrollPosition(dy
, dx
);
2255 bool wxListCtrl::SortItems(wxListCtrlCompare fn
, wxIntPtr data
)
2258 return m_genericImpl
->SortItems(fn
, data
);
2263 m_compareFuncData
= data
;
2264 SortDataBrowserContainer( m_dbImpl
->GetControlRef(), kDataBrowserNoItem
, true);
2266 // we need to do this after each call, else we get a crash from wxPython when
2267 // SortItems is called the second time.
2268 m_compareFunc
= NULL
;
2269 m_compareFuncData
= 0;
2275 void wxListCtrl::OnRenameTimer()
2277 wxCHECK_RET( HasCurrent(), wxT("unexpected rename timer") );
2279 EditLabel( m_current
);
2282 bool wxListCtrl::OnRenameAccept(long itemEdit
, const wxString
& value
)
2284 wxListEvent
le( wxEVT_COMMAND_LIST_END_LABEL_EDIT
, GetId() );
2285 le
.SetEventObject( this );
2286 le
.m_itemIndex
= itemEdit
;
2288 GetItem( le
.m_item
);
2289 le
.m_item
.m_text
= value
;
2290 return !HandleWindowEvent( le
) ||
2294 void wxListCtrl::OnRenameCancelled(long itemEdit
)
2296 // let owner know that the edit was cancelled
2297 wxListEvent
le( wxEVT_COMMAND_LIST_END_LABEL_EDIT
, GetParent()->GetId() );
2299 le
.SetEditCanceled(true);
2301 le
.SetEventObject( this );
2302 le
.m_itemIndex
= itemEdit
;
2304 GetItem( le
.m_item
);
2305 HandleWindowEvent( le
);
2308 // ----------------------------------------------------------------------------
2309 // virtual list controls
2310 // ----------------------------------------------------------------------------
2312 wxString
wxListCtrl::OnGetItemText(long WXUNUSED(item
), long WXUNUSED(col
)) const
2314 // this is a pure virtual function, in fact - which is not really pure
2315 // because the controls which are not virtual don't need to implement it
2316 wxFAIL_MSG( wxT("wxListCtrl::OnGetItemText not supposed to be called") );
2318 return wxEmptyString
;
2321 int wxListCtrl::OnGetItemImage(long WXUNUSED(item
)) const
2323 wxCHECK_MSG(!GetImageList(wxIMAGE_LIST_SMALL
),
2325 wxT("List control has an image list, OnGetItemImage or OnGetItemColumnImage should be overridden."));
2329 int wxListCtrl::OnGetItemColumnImage(long item
, long column
) const
2332 return OnGetItemImage(item
);
2337 wxListItemAttr
*wxListCtrl::OnGetItemAttr(long WXUNUSED_UNLESS_DEBUG(item
)) const
2339 wxASSERT_MSG( item
>= 0 && item
< GetItemCount(),
2340 wxT("invalid item index in OnGetItemAttr()") );
2342 // no attributes by default
2346 void wxListCtrl::SetItemCount(long count
)
2348 wxASSERT_MSG( IsVirtual(), wxT("this is for virtual controls only") );
2352 m_genericImpl
->SetItemCount(count
);
2358 // we need to temporarily disable the new item creation notification
2359 // procedure to speed things up
2360 // FIXME: Even this doesn't seem to help much...
2362 // FIXME: Find a more efficient way to do this.
2363 m_dbImpl
->MacClear();
2365 DataBrowserCallbacks callbacks
;
2366 DataBrowserItemNotificationUPP itemUPP
;
2367 GetDataBrowserCallbacks(m_dbImpl
->GetControlRef(), &callbacks
);
2368 itemUPP
= callbacks
.u
.v1
.itemNotificationCallback
;
2369 callbacks
.u
.v1
.itemNotificationCallback
= 0;
2370 m_dbImpl
->SetCallbacks(&callbacks
);
2371 ::AddDataBrowserItems(m_dbImpl
->GetControlRef(), kDataBrowserNoItem
,
2372 count
, NULL
, kDataBrowserItemNoProperty
);
2373 callbacks
.u
.v1
.itemNotificationCallback
= itemUPP
;
2374 m_dbImpl
->SetCallbacks(&callbacks
);
2379 void wxListCtrl::RefreshItem(long item
)
2383 m_genericImpl
->RefreshItem(item
);
2389 DataBrowserItemID id
;
2393 wxMacDataItem
* thisItem
= m_dbImpl
->GetItemFromLine(item
);
2394 id
= (DataBrowserItemID
) thisItem
;
2399 m_dbImpl
->wxMacDataBrowserControl::UpdateItems
2403 kDataBrowserItemNoProperty
, // preSortProperty
2404 kDataBrowserNoItem
// update all columns
2409 void wxListCtrl::RefreshItems(long itemFrom
, long itemTo
)
2413 m_genericImpl
->RefreshItems(itemFrom
, itemTo
);
2419 const long count
= itemTo
- itemFrom
+ 1;
2420 DataBrowserItemID
*ids
= new DataBrowserItemID
[count
];
2424 for ( long i
= 0; i
< count
; i
++ )
2426 wxMacDataItem
* thisItem
= m_dbImpl
->GetItemFromLine(itemFrom
+i
);
2427 ids
[i
] = (DataBrowserItemID
) thisItem
;
2432 for ( long i
= 0; i
< count
; i
++ )
2433 ids
[i
] = itemFrom
+i
+1;
2436 m_dbImpl
->wxMacDataBrowserControl::UpdateItems
2440 kDataBrowserItemNoProperty
, // preSortProperty
2441 kDataBrowserNoItem
// update all columns
2448 void wxListCtrl::SetDropTarget( wxDropTarget
*dropTarget
)
2450 #if wxUSE_DRAG_AND_DROP
2452 m_genericImpl
->SetDropTarget( dropTarget
);
2455 wxWindow::SetDropTarget( dropTarget
);
2459 wxDropTarget
*wxListCtrl::GetDropTarget() const
2461 #if wxUSE_DRAG_AND_DROP
2463 return m_genericImpl
->GetDropTarget();
2466 return wxWindow::GetDropTarget();
2471 #if wxABI_VERSION >= 20801
2472 void wxListCtrl::SetFocus()
2476 m_genericImpl
->SetFocus();
2480 wxWindow::SetFocus();
2484 // wxMac internal data structures
2486 wxMacListCtrlItem::~wxMacListCtrlItem()
2488 WX_CLEAR_HASH_MAP( wxListItemList
, m_rowItems
);
2491 void wxMacListCtrlItem::Notification(wxMacDataItemBrowserControl
*owner
,
2492 DataBrowserItemNotification message
,
2493 DataBrowserItemDataRef
WXUNUSED(itemData
) ) const
2496 wxMacDataBrowserListCtrlControl
*lb
= wxDynamicCast(owner
, wxMacDataBrowserListCtrlControl
);
2498 // we want to depend on as little as possible to make sure tear-down of controls is safe
2499 if ( message
== kDataBrowserItemRemoved
)
2504 else if ( message
== kDataBrowserItemAdded
)
2506 // we don't issue events on adding, the item is not really stored in the list yet, so we
2507 // avoid asserts by gettting out now
2511 wxListCtrl
*list
= wxDynamicCast( owner
->GetWXPeer() , wxListCtrl
);
2514 bool trigger
= false;
2516 wxListEvent
event( wxEVT_COMMAND_LIST_ITEM_SELECTED
, list
->GetId() );
2517 bool isSingle
= (list
->GetWindowStyle() & wxLC_SINGLE_SEL
) != 0;
2519 event
.SetEventObject( list
);
2520 event
.m_itemIndex
= owner
->GetLineFromItem( this ) ;
2521 event
.m_item
.m_itemId
= event
.m_itemIndex
;
2522 list
->GetItem(event
.m_item
);
2526 case kDataBrowserItemDeselected
:
2527 event
.SetEventType(wxEVT_COMMAND_LIST_ITEM_DESELECTED
);
2529 trigger
= !lb
->IsSelectionSuppressed();
2532 case kDataBrowserItemSelected
:
2533 trigger
= !lb
->IsSelectionSuppressed();
2536 case kDataBrowserItemDoubleClicked
:
2537 event
.SetEventType( wxEVT_COMMAND_LIST_ITEM_ACTIVATED
);
2541 case kDataBrowserEditStarted
:
2542 // TODO : how to veto ?
2543 event
.SetEventType( wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
) ;
2547 case kDataBrowserEditStopped
:
2548 // TODO probably trigger only upon the value store callback, because
2549 // here IIRC we cannot veto
2550 event
.SetEventType( wxEVT_COMMAND_LIST_END_LABEL_EDIT
) ;
2560 // direct notification is not always having the listbox GetSelection() having in synch with event
2561 wxPostEvent( list
->GetEventHandler(), event
);
2567 IMPLEMENT_DYNAMIC_CLASS(wxMacDataBrowserListCtrlControl
, wxMacDataItemBrowserControl
)
2569 wxMacDataBrowserListCtrlControl::wxMacDataBrowserListCtrlControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
)
2570 : wxMacDataItemBrowserControl( peer
, pos
, size
, style
)
2572 OSStatus err
= noErr
;
2573 m_clientDataItemsType
= wxClientData_None
;
2574 m_isVirtual
= false;
2577 if ( style
& wxLC_VIRTUAL
)
2580 DataBrowserSelectionFlags options
= kDataBrowserDragSelect
;
2581 if ( style
& wxLC_SINGLE_SEL
)
2583 options
|= kDataBrowserSelectOnlyOne
;
2587 options
|= kDataBrowserCmdTogglesSelection
;
2590 err
= SetSelectionFlags( options
);
2591 verify_noerr( err
);
2593 DataBrowserCustomCallbacks callbacks
;
2594 InitializeDataBrowserCustomCallbacks( &callbacks
, kDataBrowserLatestCustomCallbacks
);
2596 if ( gDataBrowserDrawItemUPP
== NULL
)
2597 gDataBrowserDrawItemUPP
= NewDataBrowserDrawItemUPP(DataBrowserDrawItemProc
);
2599 if ( gDataBrowserHitTestUPP
== NULL
)
2600 gDataBrowserHitTestUPP
= NewDataBrowserHitTestUPP(DataBrowserHitTestProc
);
2602 callbacks
.u
.v1
.drawItemCallback
= gDataBrowserDrawItemUPP
;
2603 callbacks
.u
.v1
.hitTestCallback
= gDataBrowserHitTestUPP
;
2605 SetDataBrowserCustomCallbacks( GetControlRef(), &callbacks
);
2607 if ( style
& wxLC_LIST
)
2609 InsertColumn(0, kDataBrowserIconAndTextType
, wxEmptyString
, -1, -1);
2610 verify_noerr( AutoSizeColumns() );
2613 if ( style
& wxLC_LIST
|| style
& wxLC_NO_HEADER
)
2614 verify_noerr( SetHeaderButtonHeight( 0 ) );
2617 SetSortProperty( kMinColumnId
- 1 );
2619 SetSortProperty( kMinColumnId
);
2621 m_sortOrder
= SortOrder_None
;
2623 if ( style
& wxLC_SORT_DESCENDING
)
2625 SetSortOrder( kDataBrowserOrderDecreasing
);
2627 else if ( style
& wxLC_SORT_ASCENDING
)
2629 SetSortOrder( kDataBrowserOrderIncreasing
);
2632 if ( style
& wxLC_VRULES
)
2634 verify_noerr( DataBrowserChangeAttributes(m_controlRef
, kDataBrowserAttributeListViewDrawColumnDividers
, kDataBrowserAttributeNone
) );
2637 verify_noerr( SetHiliteStyle(kDataBrowserTableViewFillHilite
) );
2638 verify_noerr( SetHasScrollBars( (style
& wxHSCROLL
) != 0 , true ) );
2641 pascal Boolean
wxMacDataBrowserListCtrlControl::DataBrowserEditTextProc(
2643 DataBrowserItemID itemID
,
2644 DataBrowserPropertyID property
,
2645 CFStringRef theString
,
2646 Rect
*maxEditTextRect
,
2647 Boolean
*shrinkToFit
)
2649 Boolean result
= false;
2650 wxMacDataBrowserListCtrlControl
* ctl
= wxDynamicCast(wxMacControl::GetReferenceFromNativeControl( browser
), wxMacDataBrowserListCtrlControl
);
2653 result
= ctl
->ConfirmEditText(itemID
, property
, theString
, maxEditTextRect
, shrinkToFit
);
2654 theString
= CFSTR("Hello!");
2659 bool wxMacDataBrowserListCtrlControl::ConfirmEditText(
2660 DataBrowserItemID
WXUNUSED(itemID
),
2661 DataBrowserPropertyID
WXUNUSED(property
),
2662 CFStringRef
WXUNUSED(theString
),
2663 Rect
*WXUNUSED(maxEditTextRect
),
2664 Boolean
*WXUNUSED(shrinkToFit
))
2669 pascal void wxMacDataBrowserListCtrlControl::DataBrowserDrawItemProc(
2671 DataBrowserItemID itemID
,
2672 DataBrowserPropertyID property
,
2673 DataBrowserItemState itemState
,
2674 const Rect
*itemRect
,
2676 Boolean colorDevice
)
2678 wxMacDataBrowserListCtrlControl
* ctl
= wxDynamicCast(wxMacControl::GetReferenceFromNativeControl( browser
), wxMacDataBrowserListCtrlControl
);
2681 ctl
->DrawItem(itemID
, property
, itemState
, itemRect
, gdDepth
, colorDevice
);
2685 // routines needed for DrawItem
2690 kTextBoxHeight
= 14,
2691 kIconTextSpacingV
= 2,
2693 kContentHeight
= kIconHeight
+ kTextBoxHeight
+ kIconTextSpacingV
2696 static void calculateCGDrawingBounds(CGRect inItemRect
, CGRect
*outIconRect
, CGRect
*outTextRect
, bool hasIcon
= false)
2699 float iconH
, iconW
= 0;
2700 float padding
= kItemPadding
;
2703 iconH
= kIconHeight
;
2705 padding
= padding
*2;
2708 textBottom
= inItemRect
.origin
.y
;
2710 *outIconRect
= CGRectMake(inItemRect
.origin
.x
+ kItemPadding
,
2711 textBottom
+ kIconTextSpacingV
, kIconWidth
,
2714 *outTextRect
= CGRectMake(inItemRect
.origin
.x
+ padding
+ iconW
,
2715 textBottom
+ kIconTextSpacingV
, inItemRect
.size
.width
- padding
- iconW
,
2716 inItemRect
.size
.height
- kIconTextSpacingV
);
2719 void wxMacDataBrowserListCtrlControl::DrawItem(
2720 DataBrowserItemID itemID
,
2721 DataBrowserPropertyID property
,
2722 DataBrowserItemState itemState
,
2723 const Rect
*WXUNUSED(itemRect
),
2725 Boolean colorDevice
)
2728 wxFont font
= wxNullFont
;
2731 DataBrowserTableViewColumnIndex listColumn
= 0;
2732 GetColumnPosition( property
, &listColumn
);
2734 wxListCtrl
* list
= wxDynamicCast( GetWXPeer() , wxListCtrl
);
2735 wxMacListCtrlItem
* lcItem
;
2736 wxColour color
= *wxBLACK
;
2737 wxColour bgColor
= wxNullColour
;
2739 if (listColumn
>= 0)
2743 lcItem
= (wxMacListCtrlItem
*) itemID
;
2744 if (lcItem
->HasColumnInfo(listColumn
))
2746 wxListItem
* item
= lcItem
->GetColumnInfo(listColumn
);
2748 // we always use the 0 column to get font and text/background colors.
2749 if (lcItem
->HasColumnInfo(0))
2751 wxListItem
* firstItem
= lcItem
->GetColumnInfo(0);
2752 color
= firstItem
->GetTextColour();
2753 bgColor
= firstItem
->GetBackgroundColour();
2754 font
= firstItem
->GetFont();
2757 if (item
->GetMask() & wxLIST_MASK_TEXT
)
2758 text
= item
->GetText();
2759 if (item
->GetMask() & wxLIST_MASK_IMAGE
)
2760 imgIndex
= item
->GetImage();
2766 long itemNum
= (long)itemID
-1;
2767 if (itemNum
>= 0 && itemNum
< list
->GetItemCount())
2769 text
= list
->OnGetItemText( itemNum
, listColumn
);
2770 imgIndex
= list
->OnGetItemColumnImage( itemNum
, listColumn
);
2771 wxListItemAttr
* attrs
= list
->OnGetItemAttr( itemNum
);
2774 if (attrs
->HasBackgroundColour())
2775 bgColor
= attrs
->GetBackgroundColour();
2776 if (attrs
->HasTextColour())
2777 color
= attrs
->GetTextColour();
2778 if (attrs
->HasFont())
2779 font
= attrs
->GetFont();
2785 wxColour listBgColor
= list
->GetBackgroundColour();
2786 if (bgColor
== wxNullColour
)
2787 bgColor
= listBgColor
;
2790 font
= list
->GetFont();
2792 wxCFStringRef
cfString( text
, wxLocale::GetSystemEncoding() );
2795 CGRect enclosingCGRect
, iconCGRect
, textCGRect
;
2797 ThemeDrawingState savedState
= NULL
;
2798 CGContextRef context
= (CGContextRef
)list
->MacGetDrawingContext();
2799 wxMacCGContextStateSaver
top_saver_cg( context
);
2801 RGBColor labelColor
;
2803 labelColor
.green
= 0;
2804 labelColor
.blue
= 0;
2806 RGBColor backgroundColor
;
2807 backgroundColor
.red
= 255;
2808 backgroundColor
.green
= 255;
2809 backgroundColor
.blue
= 255;
2811 GetDataBrowserItemPartBounds(GetControlRef(), itemID
, property
, kDataBrowserPropertyEnclosingPart
,
2814 enclosingCGRect
= CGRectMake(enclosingRect
.left
,
2816 enclosingRect
.right
- enclosingRect
.left
,
2817 enclosingRect
.bottom
- enclosingRect
.top
);
2819 bool hasFocus
= (wxWindow::FindFocus() == list
);
2820 active
= IsControlActive(GetControlRef());
2822 // don't paint the background over the vertical rule line
2823 if ( list
->GetWindowStyleFlag() & wxLC_VRULES
)
2825 enclosingCGRect
.origin
.x
+= 1;
2826 enclosingCGRect
.size
.width
-= 1;
2828 if (itemState
== kDataBrowserItemIsSelected
)
2831 GetThemeDrawingState(&savedState
);
2833 if (active
&& hasFocus
)
2835 GetThemeBrushAsColor(kThemeBrushAlternatePrimaryHighlightColor
, 32, true, &backgroundColor
);
2836 GetThemeTextColor(kThemeTextColorWhite
, gdDepth
, colorDevice
, &labelColor
);
2840 GetThemeBrushAsColor(kThemeBrushSecondaryHighlightColor
, 32, true, &backgroundColor
);
2841 GetThemeTextColor(kThemeTextColorBlack
, gdDepth
, colorDevice
, &labelColor
);
2843 wxMacCGContextStateSaver
cg( context
);
2845 CGContextSetRGBFillColor(context
, (CGFloat
)backgroundColor
.red
/ (CGFloat
)USHRT_MAX
,
2846 (CGFloat
)backgroundColor
.green
/ (CGFloat
)USHRT_MAX
,
2847 (CGFloat
)backgroundColor
.blue
/ (CGFloat
)USHRT_MAX
, (CGFloat
) 1.0);
2848 CGContextFillRect(context
, enclosingCGRect
);
2854 color
.GetRGBColor(&labelColor
);
2855 else if (list
->GetTextColour().IsOk())
2856 list
->GetTextColour().GetRGBColor(&labelColor
);
2860 bgColor
.GetRGBColor(&backgroundColor
);
2861 CGContextSaveGState(context
);
2863 CGContextSetRGBFillColor(context
, (CGFloat
)backgroundColor
.red
/ (CGFloat
)USHRT_MAX
,
2864 (CGFloat
)backgroundColor
.green
/ (CGFloat
)USHRT_MAX
,
2865 (CGFloat
)backgroundColor
.blue
/ (CGFloat
)USHRT_MAX
, (CGFloat
) 1.0);
2866 CGContextFillRect(context
, enclosingCGRect
);
2868 CGContextRestoreGState(context
);
2872 calculateCGDrawingBounds(enclosingCGRect
, &iconCGRect
, &textCGRect
, (imgIndex
!= -1) );
2876 wxImageList
* imageList
= list
->GetImageList(wxIMAGE_LIST_SMALL
);
2877 if (imageList
&& imageList
->GetImageCount() > 0)
2879 wxBitmap bmp
= imageList
->GetBitmap(imgIndex
);
2880 IconRef icon
= bmp
.GetIconRef();
2882 wxMacCGContextStateSaver
cg( context
);
2884 CGContextTranslateCTM(context
, 0,iconCGRect
.origin
.y
+ CGRectGetMaxY(iconCGRect
));
2885 CGContextScaleCTM(context
,1.0f
,-1.0f
);
2886 PlotIconRefInContext(context
, &iconCGRect
, kAlignNone
,
2887 active
? kTransformNone
: kTransformDisabled
, NULL
,
2888 kPlotIconRefNormalFlags
, icon
);
2892 HIThemeTextHorizontalFlush hFlush
= kHIThemeTextHorizontalFlushLeft
;
2893 HIThemeTextInfo info
;
2895 #if wxOSX_USE_CORE_TEXT
2896 if ( UMAGetSystemVersion() >= 0x1050 )
2898 info
.version
= kHIThemeTextInfoVersionOne
;
2899 info
.fontID
= kThemeViewsFont
;
2902 info
.fontID
= kThemeSpecifiedFont
;
2903 info
.font
= (CTFontRef
) font
.OSXGetCTFont();
2908 #if wxOSX_USE_ATSU_TEXT
2911 info
.version
= kHIThemeTextInfoVersionZero
;
2912 info
.fontID
= kThemeViewsFont
;
2916 info
.fontID
= font
.MacGetThemeFontID();
2918 ::TextSize( (short)(font
.GetPointSize()) ) ;
2919 ::TextFace( font
.MacGetFontStyle() ) ;
2925 list
->GetColumn(listColumn
, item
);
2926 if (item
.GetMask() & wxLIST_MASK_FORMAT
)
2928 if (item
.GetAlign() == wxLIST_FORMAT_LEFT
)
2929 hFlush
= kHIThemeTextHorizontalFlushLeft
;
2930 else if (item
.GetAlign() == wxLIST_FORMAT_CENTER
)
2931 hFlush
= kHIThemeTextHorizontalFlushCenter
;
2932 else if (item
.GetAlign() == wxLIST_FORMAT_RIGHT
)
2934 hFlush
= kHIThemeTextHorizontalFlushRight
;
2935 textCGRect
.origin
.x
-= kItemPadding
; // give a little extra paddding
2939 info
.state
= active
? kThemeStateActive
: kThemeStateInactive
;
2940 info
.horizontalFlushness
= hFlush
;
2941 info
.verticalFlushness
= kHIThemeTextVerticalFlushCenter
;
2942 info
.options
= kHIThemeTextBoxOptionNone
;
2943 info
.truncationPosition
= kHIThemeTextTruncationEnd
;
2944 info
.truncationMaxLines
= 1;
2947 wxMacCGContextStateSaver
cg( context
);
2948 CGContextSetRGBFillColor (context
, (CGFloat
)labelColor
.red
/ (CGFloat
)USHRT_MAX
,
2949 (CGFloat
)labelColor
.green
/ (CGFloat
)USHRT_MAX
,
2950 (CGFloat
)labelColor
.blue
/ (CGFloat
)USHRT_MAX
, (CGFloat
) 1.0);
2952 HIThemeDrawTextBox(cfString
, &textCGRect
, &info
, context
, kHIThemeOrientationNormal
);
2956 if (savedState
!= NULL
)
2957 SetThemeDrawingState(savedState
, true);
2961 OSStatus
wxMacDataBrowserListCtrlControl::GetSetItemData(DataBrowserItemID itemID
,
2962 DataBrowserPropertyID property
,
2963 DataBrowserItemDataRef itemData
,
2964 Boolean changeValue
)
2969 DataBrowserTableViewColumnIndex listColumn
= 0;
2970 verify_noerr( GetColumnPosition( property
, &listColumn
) );
2972 OSStatus err
= errDataBrowserPropertyNotSupported
;
2973 wxListCtrl
* list
= wxDynamicCast( GetWXPeer() , wxListCtrl
);
2974 wxMacListCtrlItem
* lcItem
= NULL
;
2976 if (listColumn
>= 0)
2980 lcItem
= (wxMacListCtrlItem
*) itemID
;
2981 if (lcItem
&& lcItem
->HasColumnInfo(listColumn
)){
2982 wxListItem
* item
= lcItem
->GetColumnInfo(listColumn
);
2983 if (item
->GetMask() & wxLIST_MASK_TEXT
)
2984 text
= item
->GetText();
2985 if (item
->GetMask() & wxLIST_MASK_IMAGE
)
2986 imgIndex
= item
->GetImage();
2991 long itemNum
= (long)itemID
-1;
2992 if (itemNum
>= 0 && itemNum
< list
->GetItemCount())
2994 text
= list
->OnGetItemText( itemNum
, listColumn
);
2995 imgIndex
= list
->OnGetItemColumnImage( itemNum
, listColumn
);
3004 case kDataBrowserItemIsEditableProperty
:
3005 if ( list
&& list
->HasFlag( wxLC_EDIT_LABELS
) )
3007 verify_noerr(SetDataBrowserItemDataBooleanValue( itemData
, true ));
3012 if ( property
>= kMinColumnId
)
3014 if (!text
.IsEmpty()){
3015 wxCFStringRef
cfStr( text
, wxLocale::GetSystemEncoding() );
3016 err
= ::SetDataBrowserItemDataText( itemData
, cfStr
);
3022 if ( imgIndex
!= -1 )
3024 wxImageList
* imageList
= list
->GetImageList(wxIMAGE_LIST_SMALL
);
3025 if (imageList
&& imageList
->GetImageCount() > 0){
3026 wxBitmap bmp
= imageList
->GetBitmap(imgIndex
);
3027 IconRef icon
= bmp
.GetIconRef();
3028 ::SetDataBrowserItemDataIcon(itemData
, icon
);
3042 if ( property
>= kMinColumnId
)
3044 DataBrowserTableViewColumnIndex listColumn
= 0;
3045 verify_noerr( GetColumnPosition( property
, &listColumn
) );
3047 // TODO probably send the 'end edit' from here, as we
3048 // can then deal with the veto
3050 verify_noerr( GetDataBrowserItemDataText( itemData
, &sr
) ) ;
3051 wxCFStringRef
cfStr(sr
) ;;
3053 list
->SetItem( (long)itemData
-1 , listColumn
, cfStr
.AsString() ) ;
3057 lcItem
->SetColumnTextValue( listColumn
, cfStr
.AsString() );
3067 void wxMacDataBrowserListCtrlControl::ItemNotification(DataBrowserItemID itemID
,
3068 DataBrowserItemNotification message
,
3069 DataBrowserItemDataRef itemData
)
3071 wxMacListCtrlItem
*item
= NULL
;
3074 item
= (wxMacListCtrlItem
*) itemID
;
3077 // we want to depend on as little as possible to make sure tear-down of controls is safe
3078 if ( message
== kDataBrowserItemRemoved
)
3081 item
->Notification(this, message
, itemData
);
3084 else if ( message
== kDataBrowserItemAdded
)
3086 // we don't issue events on adding, the item is not really stored in the list yet, so we
3087 // avoid asserts by getting out now
3089 item
->Notification(this, message
, itemData
);
3093 wxListCtrl
*list
= wxDynamicCast( GetWXPeer() , wxListCtrl
);
3096 bool trigger
= false;
3098 wxListEvent
event( wxEVT_COMMAND_LIST_ITEM_SELECTED
, list
->GetId() );
3100 event
.SetEventObject( list
);
3101 if ( !list
->IsVirtual() )
3103 DataBrowserTableViewRowIndex result
= 0;
3104 verify_noerr( GetItemRow( itemID
, &result
) ) ;
3105 event
.m_itemIndex
= result
;
3109 event
.m_itemIndex
= (long)itemID
-1;
3111 event
.m_item
.m_itemId
= event
.m_itemIndex
;
3112 list
->GetItem(event
.m_item
);
3116 case kDataBrowserItemDeselected
:
3117 event
.SetEventType(wxEVT_COMMAND_LIST_ITEM_DESELECTED
);
3118 // as the generic implementation is also triggering this
3119 // event for single selection, we do the same (different than listbox)
3120 trigger
= !IsSelectionSuppressed();
3123 case kDataBrowserItemSelected
:
3124 trigger
= !IsSelectionSuppressed();
3128 case kDataBrowserItemDoubleClicked
:
3129 event
.SetEventType( wxEVT_COMMAND_LIST_ITEM_ACTIVATED
);
3133 case kDataBrowserEditStarted
:
3134 // TODO : how to veto ?
3135 event
.SetEventType( wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
) ;
3139 case kDataBrowserEditStopped
:
3140 // TODO probably trigger only upon the value store callback, because
3141 // here IIRC we cannot veto
3142 event
.SetEventType( wxEVT_COMMAND_LIST_END_LABEL_EDIT
) ;
3152 // direct notification is not always having the listbox GetSelection() having in synch with event
3153 wxPostEvent( list
->GetEventHandler(), event
);
3158 Boolean
wxMacDataBrowserListCtrlControl::CompareItems(DataBrowserItemID itemOneID
,
3159 DataBrowserItemID itemTwoID
,
3160 DataBrowserPropertyID sortProperty
)
3163 bool retval
= false;
3165 wxString otherItemText
;
3167 long otherItemOrder
;
3169 DataBrowserTableViewColumnIndex colId
= 0;
3170 verify_noerr( GetColumnPosition( sortProperty
, &colId
) );
3172 wxListCtrl
* list
= wxDynamicCast( GetWXPeer() , wxListCtrl
);
3174 DataBrowserSortOrder sort
;
3175 verify_noerr(GetSortOrder(&sort
));
3181 wxMacListCtrlItem
* item
= (wxMacListCtrlItem
*)itemOneID
;
3182 wxMacListCtrlItem
* otherItem
= (wxMacListCtrlItem
*)itemTwoID
;
3184 itemOrder
= item
->GetOrder();
3185 otherItemOrder
= otherItem
->GetOrder();
3187 wxListCtrlCompare func
= list
->GetCompareFunc();
3193 if (item
&& item
->HasColumnInfo(0))
3194 item1
= item
->GetColumnInfo(0)->GetData();
3195 if (otherItem
&& otherItem
->HasColumnInfo(0))
3196 item2
= otherItem
->GetColumnInfo(0)->GetData();
3198 if (item1
> -1 && item2
> -1)
3200 int result
= func(item1
, item2
, list
->GetCompareFuncData());
3201 if (sort
== kDataBrowserOrderIncreasing
)
3208 // we can't use the native control's sorting abilities, so just
3210 return itemOrder
< otherItemOrder
;
3215 long itemNum
= (long)itemOneID
;
3216 long otherItemNum
= (long)itemTwoID
;
3218 // virtual listctrls don't support sorting
3219 return itemNum
< otherItemNum
;
3223 // fallback for undefined cases
3224 retval
= itemOneID
< itemTwoID
;
3230 wxMacDataBrowserListCtrlControl::~wxMacDataBrowserListCtrlControl()
3234 void wxMacDataBrowserListCtrlControl::MacSetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
* item
)
3236 wxMacDataItem
* dataItem
= GetItemFromLine(row
);
3237 wxASSERT_MSG( dataItem
, wxT("could not obtain wxMacDataItem for row in MacSetColumnInfo. Is row a valid wxListCtrl row?") );
3240 wxMacListCtrlItem
* listItem
= static_cast<wxMacListCtrlItem
*>(dataItem
);
3241 bool hasInfo
= listItem
->HasColumnInfo( column
);
3242 listItem
->SetColumnInfo( column
, item
);
3243 listItem
->SetOrder(row
);
3244 UpdateState(dataItem
, item
);
3246 wxListCtrl
* list
= wxDynamicCast( GetWXPeer() , wxListCtrl
);
3248 // NB: When this call was made before a control was completely shown, it would
3249 // update the item prematurely (i.e. no text would be listed) and, on show,
3250 // only the sorted column would be refreshed, meaning only first column text labels
3251 // would be shown. Making sure not to update items until the control is visible
3252 // seems to fix this issue.
3253 if (hasInfo
&& list
->IsShown())
3255 DataBrowserTableViewColumnID id
= 0;
3256 verify_noerr( GetColumnIDFromIndex( column
, &id
) );
3257 UpdateItem( wxMacDataBrowserRootContainer
, listItem
, id
);
3262 // apply changes that need to happen immediately, rather than when the
3263 // databrowser control fires a callback.
3264 void wxMacDataBrowserListCtrlControl::UpdateState(wxMacDataItem
* dataItem
, wxListItem
* listItem
)
3266 bool isSelected
= IsItemSelected( dataItem
);
3267 bool isSelectedState
= (listItem
->GetState() == wxLIST_STATE_SELECTED
);
3269 // toggle the selection state if wxListInfo state and actual state don't match.
3270 if ( listItem
->GetMask() & wxLIST_MASK_STATE
&& isSelected
!= isSelectedState
)
3272 DataBrowserSetOption options
= kDataBrowserItemsAdd
;
3273 if (!isSelectedState
)
3274 options
= kDataBrowserItemsRemove
;
3275 SetSelectedItem(dataItem
, options
);
3277 // TODO: Set column width if item width > than current column width
3280 void wxMacDataBrowserListCtrlControl::MacGetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
& item
)
3282 wxMacDataItem
* dataItem
= GetItemFromLine(row
);
3283 wxASSERT_MSG( dataItem
, wxT("could not obtain wxMacDataItem in MacGetColumnInfo. Is row a valid wxListCtrl row?") );
3284 // CS should this guard against dataItem = 0 ? , as item is not a pointer if (item) is not appropriate
3287 wxMacListCtrlItem
* listItem
= static_cast<wxMacListCtrlItem
*>(dataItem
);
3289 if (!listItem
->HasColumnInfo( column
))
3292 wxListItem
* oldItem
= listItem
->GetColumnInfo( column
);
3296 long mask
= item
.GetMask();
3298 // by default, get everything for backwards compatibility
3301 if ( mask
& wxLIST_MASK_TEXT
)
3302 item
.SetText(oldItem
->GetText());
3303 if ( mask
& wxLIST_MASK_IMAGE
)
3304 item
.SetImage(oldItem
->GetImage());
3305 if ( mask
& wxLIST_MASK_DATA
)
3306 item
.SetData(oldItem
->GetData());
3307 if ( mask
& wxLIST_MASK_STATE
)
3308 item
.SetState(oldItem
->GetState());
3309 if ( mask
& wxLIST_MASK_WIDTH
)
3310 item
.SetWidth(oldItem
->GetWidth());
3311 if ( mask
& wxLIST_MASK_FORMAT
)
3312 item
.SetAlign(oldItem
->GetAlign());
3314 item
.SetTextColour(oldItem
->GetTextColour());
3315 item
.SetBackgroundColour(oldItem
->GetBackgroundColour());
3316 item
.SetFont(oldItem
->GetFont());
3321 void wxMacDataBrowserListCtrlControl::MacInsertItem( unsigned int n
, wxListItem
* item
)
3324 wxMacDataItemBrowserControl::MacInsert(n
, new wxMacListCtrlItem() );
3325 MacSetColumnInfo(n
, 0, item
);
3328 wxMacListCtrlItem::wxMacListCtrlItem()
3330 m_rowItems
= wxListItemList();
3333 int wxMacListCtrlItem::GetColumnImageValue( unsigned int column
)
3335 if ( HasColumnInfo(column
) )
3336 return GetColumnInfo(column
)->GetImage();
3341 void wxMacListCtrlItem::SetColumnImageValue( unsigned int column
, int imageIndex
)
3343 if ( HasColumnInfo(column
) )
3344 GetColumnInfo(column
)->SetImage(imageIndex
);
3347 wxString
wxMacListCtrlItem::GetColumnTextValue( unsigned int column
)
3349 /* TODO CHECK REMOVE
3353 if ( HasColumnInfo(column
) )
3354 return GetColumnInfo(column
)->GetText();
3356 return wxEmptyString
;
3359 void wxMacListCtrlItem::SetColumnTextValue( unsigned int column
, const wxString
& text
)
3361 if ( HasColumnInfo(column
) )
3362 GetColumnInfo(column
)->SetText(text
);
3364 /* TODO CHECK REMOVE
3365 // for compatibility with superclass APIs
3371 wxListItem
* wxMacListCtrlItem::GetColumnInfo( unsigned int column
)
3373 wxASSERT_MSG( HasColumnInfo(column
), wxT("invalid column index in wxMacListCtrlItem") );
3374 return m_rowItems
[column
];
3377 bool wxMacListCtrlItem::HasColumnInfo( unsigned int column
)
3379 return !(m_rowItems
.find( column
) == m_rowItems
.end());
3382 void wxMacListCtrlItem::SetColumnInfo( unsigned int column
, wxListItem
* item
)
3385 if ( !HasColumnInfo(column
) )
3387 wxListItem
* listItem
= new wxListItem(*item
);
3388 m_rowItems
[column
] = listItem
;
3392 wxListItem
* listItem
= GetColumnInfo( column
);
3393 long mask
= item
->GetMask();
3394 if (mask
& wxLIST_MASK_TEXT
)
3395 listItem
->SetText(item
->GetText());
3396 if (mask
& wxLIST_MASK_DATA
)
3397 listItem
->SetData(item
->GetData());
3398 if (mask
& wxLIST_MASK_IMAGE
)
3399 listItem
->SetImage(item
->GetImage());
3400 if (mask
& wxLIST_MASK_STATE
)
3401 listItem
->SetState(item
->GetState());
3402 if (mask
& wxLIST_MASK_FORMAT
)
3403 listItem
->SetAlign(item
->GetAlign());
3404 if (mask
& wxLIST_MASK_WIDTH
)
3405 listItem
->SetWidth(item
->GetWidth());
3407 if ( item
->HasAttributes() )
3409 if ( listItem
->HasAttributes() )
3410 listItem
->GetAttributes()->AssignFrom(*item
->GetAttributes());
3413 listItem
->SetTextColour(item
->GetTextColour());
3414 listItem
->SetBackgroundColour(item
->GetBackgroundColour());
3415 listItem
->SetFont(item
->GetFont());
3421 int wxListCtrl::CalcColumnAutoWidth(int col
) const
3425 for ( int i
= 0; i
< GetItemCount(); i
++ )
3428 info
.SetMask(wxLIST_MASK_TEXT
| wxLIST_MASK_IMAGE
);
3430 info
.SetColumn(col
);
3433 const wxFont font
= info
.GetFont();
3437 GetTextExtent(info
.GetText(), &w
, NULL
, NULL
, NULL
, &font
);
3439 GetTextExtent(info
.GetText(), &w
, NULL
);
3441 w
+= 2 * kItemPadding
;
3443 if ( info
.GetImage() != -1 )
3446 width
= wxMax(width
, w
);
3452 #endif // wxUSE_LISTCTRL