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 m_macIsUserPane
= true;
660 long paneStyle
= style
;
661 paneStyle
&= ~wxSIMPLE_BORDER
;
662 paneStyle
&= ~wxDOUBLE_BORDER
;
663 paneStyle
&= ~wxSUNKEN_BORDER
;
664 paneStyle
&= ~wxRAISED_BORDER
;
665 paneStyle
&= ~wxSTATIC_BORDER
;
666 if ( !wxWindow::Create(parent
, id
, pos
, size
, paneStyle
| wxNO_BORDER
, name
) )
669 // since the generic control is a child, make sure we position it at 0, 0
670 m_genericImpl
= new wxGenericListCtrlHook(this, id
, wxPoint(0, 0), size
, style
, validator
, name
);
671 m_genericImpl
->PushEventHandler( new wxMacListCtrlEventDelegate( this, GetId() ) );
677 m_macIsUserPane
= false;
678 if ( !wxWindow::Create(parent
, id
, pos
, size
, style
& ~(wxHSCROLL
| wxVSCROLL
), name
) )
680 m_dbImpl
= new wxMacDataBrowserListCtrlControl( this, pos
, size
, style
);
683 MacPostControlCreate( pos
, size
);
685 InstallControlEventHandler( m_peer
->GetControlRef() , GetwxMacListCtrlEventHandlerUPP(),
686 GetEventTypeCount(eventList
), eventList
, this,
687 (EventHandlerRef
*)&m_macListCtrlEventHandler
);
689 m_renameTimer
= new wxListCtrlRenameTimer( this );
691 Connect( wxID_ANY
, wxEVT_CHAR
, wxCharEventHandler(wxListCtrl::OnChar
), NULL
, this );
692 Connect( wxID_ANY
, wxEVT_LEFT_DOWN
, wxMouseEventHandler(wxListCtrl::OnLeftDown
), NULL
, this );
693 Connect( wxID_ANY
, wxEVT_LEFT_DCLICK
, wxMouseEventHandler(wxListCtrl::OnDblClick
), NULL
, this );
694 Connect( wxID_ANY
, wxEVT_MIDDLE_DOWN
, wxMouseEventHandler(wxListCtrl::OnMiddleDown
), NULL
, this );
695 Connect( wxID_ANY
, wxEVT_RIGHT_DOWN
, wxMouseEventHandler(wxListCtrl::OnRightDown
), NULL
, this );
701 wxListCtrl::~wxListCtrl()
705 m_genericImpl
->PopEventHandler(/* deleteHandler = */ true);
708 if (m_ownsImageListNormal
)
709 delete m_imageListNormal
;
710 if (m_ownsImageListSmall
)
711 delete m_imageListSmall
;
712 if (m_ownsImageListState
)
713 delete m_imageListState
;
715 delete m_renameTimer
;
717 WX_CLEAR_LIST(wxColumnList
, m_colsInfo
);
722 wxListCtrl::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
724 wxVisualAttributes attr
;
726 attr
.colFg
= wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT
);
727 attr
.colBg
= wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOX
);
728 static wxFont font
= wxFont(wxOSX_SYSTEM_FONT_VIEWS
);
734 // ----------------------------------------------------------------------------
735 // set/get/change style
736 // ----------------------------------------------------------------------------
738 // Add or remove a single window style
739 void wxListCtrl::SetSingleStyle(long style
, bool add
)
741 long flag
= GetWindowStyleFlag();
743 // Get rid of conflicting styles
746 if ( style
& wxLC_MASK_TYPE
)
747 flag
= flag
& ~wxLC_MASK_TYPE
;
748 if ( style
& wxLC_MASK_ALIGN
)
749 flag
= flag
& ~wxLC_MASK_ALIGN
;
750 if ( style
& wxLC_MASK_SORT
)
751 flag
= flag
& ~wxLC_MASK_SORT
;
759 SetWindowStyleFlag(flag
);
762 // Set the whole window style
763 void wxListCtrl::SetWindowStyleFlag(long flag
)
765 if ( flag
!= m_windowStyle
)
767 m_windowStyle
= flag
;
771 m_genericImpl
->SetWindowStyleFlag(flag
);
778 void wxListCtrl::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
780 wxControl::DoSetSize(x
, y
, width
, height
, sizeFlags
);
783 m_genericImpl
->SetSize(0, 0, width
, height
, sizeFlags
);
785 // determine if we need a horizontal scrollbar, and add it if so
789 for (int column
= 0; column
< GetColumnCount(); column
++)
791 totalWidth
+= m_dbImpl
->GetColumnWidth( column
);
794 if ( !(m_dbImpl
->GetFlags() & wxHSCROLL
) )
796 Boolean vertScrollBar
;
797 GetDataBrowserHasScrollBars( m_dbImpl
->GetControlRef(), NULL
, &vertScrollBar
);
798 if (totalWidth
> width
)
799 SetDataBrowserHasScrollBars( m_dbImpl
->GetControlRef(), true, vertScrollBar
);
801 SetDataBrowserHasScrollBars( m_dbImpl
->GetControlRef(), false, vertScrollBar
);
806 wxSize
wxListCtrl::DoGetBestSize() const
808 return wxWindow::DoGetBestSize();
811 bool wxListCtrl::SetFont(const wxFont
& font
)
814 rv
= wxControl::SetFont(font
);
816 rv
= m_genericImpl
->SetFont(font
);
820 bool wxListCtrl::SetForegroundColour(const wxColour
& colour
)
824 rv
= m_genericImpl
->SetForegroundColour(colour
);
826 SetTextColour(colour
);
830 bool wxListCtrl::SetBackgroundColour(const wxColour
& colour
)
834 rv
= m_genericImpl
->SetBackgroundColour(colour
);
840 wxColour
wxListCtrl::GetBackgroundColour() const
843 return m_genericImpl
->GetBackgroundColour();
850 void wxListCtrl::Freeze ()
853 m_genericImpl
->Freeze();
857 void wxListCtrl::Thaw ()
860 m_genericImpl
->Thaw();
864 void wxListCtrl::Update ()
867 m_genericImpl
->Update();
871 // ----------------------------------------------------------------------------
873 // ----------------------------------------------------------------------------
875 // Gets information about this column
876 bool wxListCtrl::GetColumn(int col
, wxListItem
& item
) const
879 return m_genericImpl
->GetColumn(col
, item
);
885 wxColumnList::compatibility_iterator node
= m_colsInfo
.Item( col
);
886 wxASSERT_MSG( node
, wxT("invalid column index in wxMacListCtrlItem") );
887 wxListItem
* column
= node
->GetData();
889 long mask
= column
->GetMask();
890 if (mask
& wxLIST_MASK_TEXT
)
891 item
.SetText(column
->GetText());
892 if (mask
& wxLIST_MASK_DATA
)
893 item
.SetData(column
->GetData());
894 if (mask
& wxLIST_MASK_IMAGE
)
895 item
.SetImage(column
->GetImage());
896 if (mask
& wxLIST_MASK_STATE
)
897 item
.SetState(column
->GetState());
898 if (mask
& wxLIST_MASK_FORMAT
)
899 item
.SetAlign(column
->GetAlign());
900 if (mask
& wxLIST_MASK_WIDTH
)
901 item
.SetWidth(column
->GetWidth());
907 // Sets information about this column
908 bool wxListCtrl::SetColumn(int col
, wxListItem
& item
)
911 return m_genericImpl
->SetColumn(col
, item
);
915 wxASSERT_MSG( col
< (int)m_colsInfo
.GetCount(), wxT("invalid column index in wxMacListCtrlItem") );
917 long mask
= item
.GetMask();
920 GetColumn( col
, listItem
);
922 if (mask
& wxLIST_MASK_TEXT
)
923 listItem
.SetText(item
.GetText());
924 if (mask
& wxLIST_MASK_DATA
)
925 listItem
.SetData(item
.GetData());
926 if (mask
& wxLIST_MASK_IMAGE
)
927 listItem
.SetImage(item
.GetImage());
928 if (mask
& wxLIST_MASK_STATE
)
929 listItem
.SetState(item
.GetState());
930 if (mask
& wxLIST_MASK_FORMAT
)
931 listItem
.SetAlign(item
.GetAlign());
932 if (mask
& wxLIST_MASK_WIDTH
)
933 listItem
.SetWidth(item
.GetWidth());
936 // change the appearance in the databrowser.
937 DataBrowserListViewHeaderDesc columnDesc
;
938 columnDesc
.version
=kDataBrowserListViewLatestHeaderDesc
;
940 DataBrowserTableViewColumnID id
= 0;
941 verify_noerr( m_dbImpl
->GetColumnIDFromIndex( col
, &id
) );
942 verify_noerr( m_dbImpl
->GetHeaderDesc( id
, &columnDesc
) );
945 if (item.GetMask() & wxLIST_MASK_TEXT)
949 enc = GetFont().GetEncoding();
951 enc = wxLocale::GetSystemEncoding();
952 wxCFStringRef cfTitle;
953 cfTitle.Assign( item.GetText() , enc );
954 if(columnDesc.titleString)
955 CFRelease(columnDesc.titleString);
956 columnDesc.titleString = cfTitle;
960 if (item
.GetMask() & wxLIST_MASK_IMAGE
&& item
.GetImage() != -1 )
962 wxImageList
* imageList
= GetImageList(wxIMAGE_LIST_SMALL
);
963 if (imageList
&& imageList
->GetImageCount() > 0 )
965 wxBitmap bmp
= imageList
->GetBitmap( item
.GetImage() );
966 IconRef icon
= bmp
.GetIconRef();
967 columnDesc
.btnContentInfo
.u
.iconRef
= icon
;
968 columnDesc
.btnContentInfo
.contentType
= kControlContentIconRef
;
972 verify_noerr( m_dbImpl
->SetHeaderDesc( id
, &columnDesc
) );
978 int wxListCtrl::GetColumnCount() const
981 return m_genericImpl
->GetColumnCount();
986 m_dbImpl
->GetColumnCount(&count
);
993 // Gets the column width
994 int wxListCtrl::GetColumnWidth(int col
) const
997 return m_genericImpl
->GetColumnWidth(col
);
1001 return m_dbImpl
->GetColumnWidth(col
);
1007 // Sets the column width
1008 bool wxListCtrl::SetColumnWidth(int col
, int width
)
1011 return m_genericImpl
->SetColumnWidth(col
, width
);
1015 if ( width
== wxLIST_AUTOSIZE_USEHEADER
)
1017 width
= 150; // FIXME
1022 for (int column
= 0; column
< GetColumnCount(); column
++)
1025 GetColumn(column
, colInfo
);
1027 colInfo
.SetWidth(width
);
1028 SetColumn(column
, colInfo
);
1030 const int mywidth
= (width
== wxLIST_AUTOSIZE
)
1031 ? CalcColumnAutoWidth(column
) : width
;
1032 m_dbImpl
->SetColumnWidth(column
, mywidth
);
1037 if ( width
== wxLIST_AUTOSIZE
)
1038 width
= CalcColumnAutoWidth(col
);
1041 GetColumn(col
, colInfo
);
1043 colInfo
.SetWidth(width
);
1044 SetColumn(col
, colInfo
);
1045 m_dbImpl
->SetColumnWidth(col
, width
);
1053 // Gets the number of items that can fit vertically in the
1054 // visible area of the list control (list or report view)
1055 // or the total number of items in the list control (icon
1056 // or small icon view)
1057 int wxListCtrl::GetCountPerPage() const
1060 return m_genericImpl
->GetCountPerPage();
1065 m_dbImpl
->GetDefaultRowHeight( &height
);
1067 return GetClientSize().y
/ height
;
1073 // Gets the edit control for editing labels.
1074 wxTextCtrl
* wxListCtrl::GetEditControl() const
1077 return m_genericImpl
->GetEditControl();
1082 // Gets information about the item
1083 bool wxListCtrl::GetItem(wxListItem
& info
) const
1086 return m_genericImpl
->GetItem(info
);
1092 if (info
.m_itemId
>= 0 && info
.m_itemId
< GetItemCount())
1094 m_dbImpl
->MacGetColumnInfo(info
.m_itemId
, info
.m_col
, info
);
1095 // MacGetColumnInfo returns erroneous information in the state field, so zero it.
1097 if (info
.GetMask() & wxLIST_MASK_STATE
)
1099 DataBrowserItemID id
= (DataBrowserItemID
)m_dbImpl
->GetItemFromLine(info
.m_itemId
);
1100 if (IsDataBrowserItemSelected( m_dbImpl
->GetControlRef(), id
))
1101 info
.SetState(info
.GetState() | wxLIST_STATE_SELECTED
);
1107 if (info
.m_itemId
>= 0 && info
.m_itemId
< GetItemCount())
1109 info
.SetText( OnGetItemText(info
.m_itemId
, info
.m_col
) );
1110 info
.SetImage( OnGetItemColumnImage(info
.m_itemId
, info
.m_col
) );
1111 if (info
.GetMask() & wxLIST_MASK_STATE
)
1113 if (IsDataBrowserItemSelected( m_dbImpl
->GetControlRef(), info
.m_itemId
+1 ))
1114 info
.SetState(info
.GetState() | wxLIST_STATE_SELECTED
);
1117 wxListItemAttr
* attrs
= OnGetItemAttr( info
.m_itemId
);
1120 info
.SetFont( attrs
->GetFont() );
1121 info
.SetBackgroundColour( attrs
->GetBackgroundColour() );
1122 info
.SetTextColour( attrs
->GetTextColour() );
1127 bool success
= true;
1131 // Sets information about the item
1132 bool wxListCtrl::SetItem(wxListItem
& info
)
1135 return m_genericImpl
->SetItem(info
);
1138 m_dbImpl
->MacSetColumnInfo( info
.m_itemId
, info
.m_col
, &info
);
1143 long wxListCtrl::SetItem(long index
, int col
, const wxString
& label
, int imageId
)
1146 return m_genericImpl
->SetItem(index
, col
, label
, imageId
);
1149 info
.m_text
= label
;
1150 info
.m_mask
= wxLIST_MASK_TEXT
;
1151 info
.m_itemId
= index
;
1155 info
.m_image
= imageId
;
1156 info
.m_mask
|= wxLIST_MASK_IMAGE
;
1158 return SetItem(info
);
1162 // Gets the item state
1163 int wxListCtrl::GetItemState(long item
, long stateMask
) const
1166 return m_genericImpl
->GetItemState(item
, stateMask
);
1170 if ( HasFlag(wxLC_VIRTUAL
) )
1172 if (stateMask
== wxLIST_STATE_SELECTED
)
1174 if (IsDataBrowserItemSelected( m_dbImpl
->GetControlRef(), item
+1 ))
1175 return wxLIST_STATE_SELECTED
;
1184 info
.m_mask
= wxLIST_MASK_STATE
;
1185 info
.m_stateMask
= stateMask
;
1186 info
.m_itemId
= item
;
1191 return info
.m_state
;
1198 // Sets the item state
1199 bool wxListCtrl::SetItemState(long item
, long state
, long stateMask
)
1202 return m_genericImpl
->SetItemState(item
, state
, stateMask
);
1206 DataBrowserSetOption option
= kDataBrowserItemsAdd
;
1207 if ( (stateMask
& wxLIST_STATE_SELECTED
) && state
== 0 )
1208 option
= kDataBrowserItemsRemove
;
1212 if ( HasFlag(wxLC_VIRTUAL
) )
1214 wxMacDataItemBrowserSelectionSuppressor
suppressor(m_dbImpl
);
1215 m_dbImpl
->SetSelectedAllItems(option
);
1219 for(int i
= 0; i
< GetItemCount();i
++)
1223 info
.m_mask
= wxLIST_MASK_STATE
;
1224 info
.m_stateMask
= stateMask
;
1225 info
.m_state
= state
;
1232 if ( HasFlag(wxLC_VIRTUAL
) )
1234 long itemID
= item
+1;
1235 bool isSelected
= IsDataBrowserItemSelected(m_dbImpl
->GetControlRef(), (DataBrowserItemID
)itemID
);
1236 bool isSelectedState
= (state
== wxLIST_STATE_SELECTED
);
1238 // toggle the selection state if wxListInfo state and actual state don't match.
1239 if ( (stateMask
& wxLIST_STATE_SELECTED
) && isSelected
!= isSelectedState
)
1241 SetDataBrowserSelectedItems(m_dbImpl
->GetControlRef(), 1, (DataBrowserItemID
*)&itemID
, option
);
1247 info
.m_itemId
= item
;
1248 info
.m_mask
= wxLIST_MASK_STATE
;
1249 info
.m_stateMask
= stateMask
;
1250 info
.m_state
= state
;
1251 return SetItem(info
);
1258 // Sets the item image
1259 bool wxListCtrl::SetItemImage(long item
, int image
, int WXUNUSED(selImage
))
1261 return SetItemColumnImage(item
, 0, image
);
1264 // Sets the item image
1265 bool wxListCtrl::SetItemColumnImage(long item
, long column
, int image
)
1268 return m_genericImpl
->SetItemColumnImage(item
, column
, image
);
1272 info
.m_mask
= wxLIST_MASK_IMAGE
;
1273 info
.m_image
= image
;
1274 info
.m_itemId
= item
;
1275 info
.m_col
= column
;
1277 return SetItem(info
);
1280 // Gets the item text
1281 wxString
wxListCtrl::GetItemText(long item
, int column
) const
1284 return m_genericImpl
->GetItemText(item
, column
);
1288 info
.m_mask
= wxLIST_MASK_TEXT
;
1289 info
.m_itemId
= item
;
1290 info
.m_col
= column
;
1293 return wxEmptyString
;
1297 // Sets the item text
1298 void wxListCtrl::SetItemText(long item
, const wxString
& str
)
1301 return m_genericImpl
->SetItemText(item
, str
);
1305 info
.m_mask
= wxLIST_MASK_TEXT
;
1306 info
.m_itemId
= item
;
1312 // Gets the item data
1313 long wxListCtrl::GetItemData(long item
) const
1316 return m_genericImpl
->GetItemData(item
);
1320 info
.m_mask
= wxLIST_MASK_DATA
;
1321 info
.m_itemId
= item
;
1328 // Sets the item data
1329 bool wxListCtrl::SetItemPtrData(long item
, wxUIntPtr data
)
1332 return m_genericImpl
->SetItemData(item
, data
);
1336 info
.m_mask
= wxLIST_MASK_DATA
;
1337 info
.m_itemId
= item
;
1340 return SetItem(info
);
1343 wxRect
wxListCtrl::GetViewRect() const
1345 wxASSERT_MSG( !HasFlag(wxLC_REPORT
| wxLC_LIST
),
1346 wxT("wxListCtrl::GetViewRect() only works in icon mode") );
1349 return m_genericImpl
->GetViewRect();
1355 bool wxListCtrl::GetSubItemRect( long item
, long subItem
, wxRect
& rect
, int code
) const
1358 return m_genericImpl
->GetSubItemRect(item
, subItem
, rect
, code
);
1360 // TODO: implement for DataBrowser implementation
1364 // Gets the item rectangle
1365 bool wxListCtrl::GetItemRect(long item
, wxRect
& rect
, int code
) const
1368 return m_genericImpl
->GetItemRect(item
, rect
, code
);
1373 DataBrowserItemID id
;
1375 DataBrowserTableViewColumnID col
= 0;
1376 verify_noerr( m_dbImpl
->GetColumnIDFromIndex( 0, &col
) );
1379 DataBrowserPropertyPart part
= kDataBrowserPropertyEnclosingPart
;
1380 if ( code
== wxLIST_RECT_LABEL
)
1381 part
= kDataBrowserPropertyTextPart
;
1382 else if ( code
== wxLIST_RECT_ICON
)
1383 part
= kDataBrowserPropertyIconPart
;
1385 if ( !(GetWindowStyleFlag() & wxLC_VIRTUAL
) )
1387 wxMacDataItem
* thisItem
= m_dbImpl
->GetItemFromLine(item
);
1388 id
= (DataBrowserItemID
) thisItem
;
1393 GetDataBrowserItemPartBounds( m_dbImpl
->GetControlRef(), id
, col
, part
, &bounds
);
1395 rect
.x
= bounds
.left
;
1396 rect
.y
= bounds
.top
;
1397 rect
.width
= bounds
.right
- bounds
.left
; //GetClientSize().x; // we need the width of the whole row, not just the item.
1398 rect
.height
= bounds
.bottom
- bounds
.top
;
1399 //fprintf("id = %d, bounds = %d, %d, %d, %d\n", id, rect.x, rect.y, rect.width, rect.height);
1404 // Gets the item position
1405 bool wxListCtrl::GetItemPosition(long item
, wxPoint
& pos
) const
1408 return m_genericImpl
->GetItemPosition(item
, pos
);
1410 bool success
= false;
1415 GetItemRect(item
, itemRect
);
1416 pos
= itemRect
.GetPosition();
1423 // Sets the item position.
1424 bool wxListCtrl::SetItemPosition(long item
, const wxPoint
& pos
)
1427 return m_genericImpl
->SetItemPosition(item
, pos
);
1432 // Gets the number of items in the list control
1433 int wxListCtrl::GetItemCount() const
1436 return m_genericImpl
->GetItemCount();
1439 return m_dbImpl
->MacGetCount();
1444 void wxListCtrl::SetItemSpacing( int spacing
, bool isSmall
)
1447 m_genericImpl
->SetItemSpacing(spacing
, isSmall
);
1450 wxSize
wxListCtrl::GetItemSpacing() const
1453 return m_genericImpl
->GetItemSpacing();
1455 return wxSize(0, 0);
1458 void wxListCtrl::SetItemTextColour( long item
, const wxColour
&col
)
1462 m_genericImpl
->SetItemTextColour(item
, col
);
1467 info
.m_itemId
= item
;
1468 info
.SetTextColour( col
);
1472 wxColour
wxListCtrl::GetItemTextColour( long item
) const
1475 return m_genericImpl
->GetItemTextColour(item
);
1481 return info
.GetTextColour();
1483 return wxNullColour
;
1486 void wxListCtrl::SetItemBackgroundColour( long item
, const wxColour
&col
)
1490 m_genericImpl
->SetItemBackgroundColour(item
, col
);
1495 info
.m_itemId
= item
;
1496 info
.SetBackgroundColour( col
);
1500 wxColour
wxListCtrl::GetItemBackgroundColour( long item
) const
1503 return m_genericImpl
->GetItemBackgroundColour(item
);
1509 return info
.GetBackgroundColour();
1511 return wxNullColour
;
1514 void wxListCtrl::SetItemFont( long item
, const wxFont
&f
)
1518 m_genericImpl
->SetItemFont(item
, f
);
1523 info
.m_itemId
= item
;
1528 wxFont
wxListCtrl::GetItemFont( long item
) const
1531 return m_genericImpl
->GetItemFont(item
);
1537 return info
.GetFont();
1543 // Gets the number of selected items in the list control
1544 int wxListCtrl::GetSelectedItemCount() const
1547 return m_genericImpl
->GetSelectedItemCount();
1550 return m_dbImpl
->GetSelectedItemCount(NULL
, true);
1555 // Gets the text colour of the listview
1556 wxColour
wxListCtrl::GetTextColour() const
1559 return m_genericImpl
->GetTextColour();
1561 // TODO: we need owner drawn list items to customize text color.
1565 return wxNullColour
;
1568 // Sets the text colour of the listview
1569 void wxListCtrl::SetTextColour(const wxColour
& col
)
1573 m_genericImpl
->SetTextColour(col
);
1581 // Gets the index of the topmost visible item when in
1582 // list or report view
1583 long wxListCtrl::GetTopItem() const
1586 return m_genericImpl
->GetTopItem();
1591 long item
= HitTest( wxPoint(1, 1), flags
);
1592 if (flags
== wxLIST_HITTEST_ONITEM
)
1599 // Searches for an item, starting from 'item'.
1600 // 'geometry' is one of
1601 // wxLIST_NEXT_ABOVE/ALL/BELOW/LEFT/RIGHT.
1602 // 'state' is a state bit flag, one or more of
1603 // wxLIST_STATE_DROPHILITED/FOCUSED/SELECTED/CUT.
1604 // item can be -1 to find the first item that matches the
1606 // Returns the item or -1 if unsuccessful.
1607 long wxListCtrl::GetNextItem(long item
, int geom
, int state
) const
1610 return m_genericImpl
->GetNextItem(item
, geom
, state
);
1612 // TODO: implement all geometry and state options?
1615 if ( geom
== wxLIST_NEXT_ALL
|| geom
== wxLIST_NEXT_BELOW
)
1617 long count
= m_dbImpl
->MacGetCount() ;
1618 for ( long line
= item
+ 1 ; line
< count
; line
++ )
1620 DataBrowserItemID id
= line
+ 1;
1622 id
= (DataBrowserItemID
)m_dbImpl
->GetItemFromLine(line
);
1624 if ( (state
& wxLIST_STATE_FOCUSED
) && (m_current
== line
))
1627 if ( (state
== wxLIST_STATE_DONTCARE
) )
1630 if ( (state
& wxLIST_STATE_SELECTED
) && IsDataBrowserItemSelected(m_dbImpl
->GetControlRef(), id
) )
1635 if ( geom
== wxLIST_NEXT_ABOVE
)
1639 item2
= m_dbImpl
->MacGetCount();
1641 for ( long line
= item2
- 1 ; line
>= 0; line
-- )
1643 DataBrowserItemID id
= line
+ 1;
1645 id
= (DataBrowserItemID
)m_dbImpl
->GetItemFromLine(line
);
1647 if ( (state
& wxLIST_STATE_FOCUSED
) && (m_current
== line
))
1650 if ( (state
== wxLIST_STATE_DONTCARE
) )
1653 if ( (state
& wxLIST_STATE_SELECTED
) && IsDataBrowserItemSelected(m_dbImpl
->GetControlRef(), id
) )
1663 wxImageList
*wxListCtrl::GetImageList(int which
) const
1666 return m_genericImpl
->GetImageList(which
);
1668 if ( which
== wxIMAGE_LIST_NORMAL
)
1670 return m_imageListNormal
;
1672 else if ( which
== wxIMAGE_LIST_SMALL
)
1674 return m_imageListSmall
;
1676 else if ( which
== wxIMAGE_LIST_STATE
)
1678 return m_imageListState
;
1683 void wxListCtrl::SetImageList(wxImageList
*imageList
, int which
)
1687 m_genericImpl
->SetImageList(imageList
, which
);
1691 if ( which
== wxIMAGE_LIST_NORMAL
)
1693 if (m_ownsImageListNormal
) delete m_imageListNormal
;
1694 m_imageListNormal
= imageList
;
1695 m_ownsImageListNormal
= false;
1697 else if ( which
== wxIMAGE_LIST_SMALL
)
1699 if (m_ownsImageListSmall
) delete m_imageListSmall
;
1700 m_imageListSmall
= imageList
;
1701 m_ownsImageListSmall
= false;
1703 else if ( which
== wxIMAGE_LIST_STATE
)
1705 if (m_ownsImageListState
) delete m_imageListState
;
1706 m_imageListState
= imageList
;
1707 m_ownsImageListState
= false;
1711 void wxListCtrl::AssignImageList(wxImageList
*imageList
, int which
)
1715 m_genericImpl
->AssignImageList(imageList
, which
);
1719 SetImageList(imageList
, which
);
1720 if ( which
== wxIMAGE_LIST_NORMAL
)
1721 m_ownsImageListNormal
= true;
1722 else if ( which
== wxIMAGE_LIST_SMALL
)
1723 m_ownsImageListSmall
= true;
1724 else if ( which
== wxIMAGE_LIST_STATE
)
1725 m_ownsImageListState
= true;
1728 // ----------------------------------------------------------------------------
1730 // ----------------------------------------------------------------------------
1732 // Arranges the items
1733 bool wxListCtrl::Arrange(int flag
)
1736 return m_genericImpl
->Arrange(flag
);
1741 bool wxListCtrl::DeleteItem(long item
)
1744 return m_genericImpl
->DeleteItem(item
);
1748 m_dbImpl
->MacDelete(item
);
1749 wxListEvent
event( wxEVT_COMMAND_LIST_DELETE_ITEM
, GetId() );
1750 event
.SetEventObject( this );
1751 event
.m_itemIndex
= item
;
1752 HandleWindowEvent( event
);
1758 // Deletes all items
1759 bool wxListCtrl::DeleteAllItems()
1763 return m_genericImpl
->DeleteAllItems();
1767 m_dbImpl
->MacClear();
1768 wxListEvent
event( wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS
, GetId() );
1769 event
.SetEventObject( this );
1770 HandleWindowEvent( event
);
1775 // Deletes all items
1776 bool wxListCtrl::DeleteAllColumns()
1779 return m_genericImpl
->DeleteAllColumns();
1784 m_dbImpl
->GetColumnCount(&cols
);
1785 for (UInt32 col
= 0; col
< cols
; col
++)
1795 bool wxListCtrl::DeleteColumn(int col
)
1798 return m_genericImpl
->DeleteColumn(col
);
1802 OSStatus err
= m_dbImpl
->RemoveColumn(col
);
1803 return err
== noErr
;
1809 // Clears items, and columns if there are any.
1810 void wxListCtrl::ClearAll()
1814 m_genericImpl
->ClearAll();
1825 wxTextCtrl
* wxListCtrl::EditLabel(long item
, wxClassInfo
* textControlClass
)
1828 return m_genericImpl
->EditLabel(item
, textControlClass
);
1832 wxCHECK_MSG( (item
>= 0) && ((long)item
< GetItemCount()), NULL
,
1833 wxT("wrong index in wxListCtrl::EditLabel()") );
1835 wxASSERT_MSG( textControlClass
->IsKindOf(CLASSINFO(wxTextCtrl
)),
1836 wxT("EditLabel() needs a text control") );
1838 wxListEvent
le( wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
, GetParent()->GetId() );
1839 le
.SetEventObject( this );
1840 le
.m_itemIndex
= item
;
1842 GetItem( le
.m_item
);
1844 if ( GetParent()->HandleWindowEvent( le
) && !le
.IsAllowed() )
1846 // vetoed by user code
1850 wxTextCtrl
* const text
= (wxTextCtrl
*)textControlClass
->CreateObject();
1851 m_textctrlWrapper
= new wxListCtrlTextCtrlWrapper(this, text
, item
);
1852 return m_textctrlWrapper
->GetText();
1857 // End label editing, optionally cancelling the edit
1858 bool wxListCtrl::EndEditLabel(bool WXUNUSED(cancel
))
1860 // TODO: generic impl. doesn't have this method - is it needed for us?
1862 return true; // m_genericImpl->EndEditLabel(cancel);
1866 DataBrowserTableViewColumnID id
= 0;
1867 verify_noerr( m_dbImpl
->GetColumnIDFromIndex( 0, &id
) );
1868 verify_noerr( SetDataBrowserEditItem(m_dbImpl
->GetControlRef(), kDataBrowserNoItem
, id
) );
1873 // Ensures this item is visible
1874 bool wxListCtrl::EnsureVisible(long item
)
1877 return m_genericImpl
->EnsureVisible(item
);
1881 wxMacDataItem
* dataItem
= m_dbImpl
->GetItemFromLine(item
);
1882 m_dbImpl
->RevealItem(dataItem
, kDataBrowserRevealWithoutSelecting
);
1888 // Find an item whose label matches this string, starting from the item after 'start'
1889 // or the beginning if 'start' is -1.
1890 long wxListCtrl::FindItem(long start
, const wxString
& str
, bool partial
)
1893 return m_genericImpl
->FindItem(start
, str
, partial
);
1895 wxString str_upper
= str
.Upper();
1900 long count
= GetItemCount();
1904 wxString line_upper
= GetItemText(idx
).Upper();
1907 if (line_upper
== str_upper
)
1912 if (line_upper
.find(str_upper
) == 0)
1922 // Find an item whose data matches this data, starting from the item after 'start'
1923 // or the beginning if 'start' is -1.
1924 long wxListCtrl::FindItem(long start
, long data
)
1927 return m_genericImpl
->FindItem(start
, data
);
1932 long count
= GetItemCount();
1936 if (GetItemData(idx
) == data
)
1944 // Find an item nearest this position in the specified direction, starting from
1945 // the item after 'start' or the beginning if 'start' is -1.
1946 long wxListCtrl::FindItem(long start
, const wxPoint
& pt
, int direction
)
1949 return m_genericImpl
->FindItem(start
, pt
, direction
);
1953 static void calculateCGDrawingBounds(CGRect inItemRect
, CGRect
*outIconRect
, CGRect
*outTextRect
, bool hasIcon
);
1955 // Determines which item (if any) is at the specified point,
1956 // giving details in 'flags' (see wxLIST_HITTEST_... flags above)
1958 wxListCtrl::HitTest(const wxPoint
& point
, int& flags
, long *ptrSubItem
) const
1964 return m_genericImpl
->HitTest(point
, flags
, ptrSubItem
);
1966 flags
= wxLIST_HITTEST_NOWHERE
;
1969 int colHeaderHeight
= 22; // TODO: Find a way to get this value from the db control?
1970 UInt16 rowHeight
= 0;
1971 m_dbImpl
->GetDefaultRowHeight(&rowHeight
);
1974 // get the actual row by taking scroll position into account
1975 UInt32 offsetX
, offsetY
;
1976 m_dbImpl
->GetScrollPosition( &offsetY
, &offsetX
);
1979 if ( !(GetWindowStyleFlag() & wxLC_NO_HEADER
) )
1980 y
-= colHeaderHeight
;
1985 int row
= y
/ rowHeight
;
1986 DataBrowserItemID id
;
1987 m_dbImpl
->GetItemID( (DataBrowserTableViewRowIndex
) row
, &id
);
1989 CGPoint click_point
= CGPointMake( point
.x
, point
.y
);
1990 if (row
< GetItemCount() )
1993 for( column
= 0; column
< GetColumnCount(); column
++ )
1996 CGRect enclosingCGRect
, iconCGRect
, textCGRect
;
1998 wxMacListCtrlItem
* lcItem
;
2000 WXUNUSED_UNLESS_DEBUG( OSStatus status
= ) m_dbImpl
->GetItemPartBounds( id
, kMinColumnId
+ column
, kDataBrowserPropertyEnclosingPart
, &enclosingRect
);
2001 wxASSERT( status
== noErr
);
2003 enclosingCGRect
= CGRectMake(enclosingRect
.left
,
2005 enclosingRect
.right
- enclosingRect
.left
,
2006 enclosingRect
.bottom
- enclosingRect
.top
);
2010 if ( !(GetWindowStyleFlag() & wxLC_VIRTUAL
) )
2012 lcItem
= (wxMacListCtrlItem
*) id
;
2013 if (lcItem
->HasColumnInfo(column
))
2015 wxListItem
* item
= lcItem
->GetColumnInfo(column
);
2017 if (item
->GetMask() & wxLIST_MASK_IMAGE
)
2019 imgIndex
= item
->GetImage();
2025 long itemNum
= (long)id
-1;
2026 if (itemNum
>= 0 && itemNum
< GetItemCount())
2028 imgIndex
= OnGetItemColumnImage( itemNum
, column
);
2033 calculateCGDrawingBounds(enclosingCGRect
, &iconCGRect
, &textCGRect
, (imgIndex
!= -1) );
2035 if ( CGRectContainsPoint( iconCGRect
, click_point
) )
2037 flags
= wxLIST_HITTEST_ONITEMICON
;
2039 *ptrSubItem
= column
;
2042 else if ( CGRectContainsPoint( textCGRect
, click_point
) )
2044 flags
= wxLIST_HITTEST_ONITEMLABEL
;
2046 *ptrSubItem
= column
;
2051 if ( !(GetWindowStyleFlag() & wxLC_VIRTUAL
) )
2053 wxMacListCtrlItem
* lcItem
;
2054 lcItem
= (wxMacListCtrlItem
*) id
;
2057 flags
= wxLIST_HITTEST_ONITEM
;
2059 *ptrSubItem
= column
;
2065 flags
= wxLIST_HITTEST_ONITEM
;
2067 *ptrSubItem
= column
;
2073 if ( wxControl::HitTest( point
) )
2074 flags
= wxLIST_HITTEST_NOWHERE
;
2081 int wxListCtrl::GetScrollPos(int orient
) const
2084 return m_genericImpl
->GetScrollPos(orient
);
2088 UInt32 offsetX
, offsetY
;
2089 m_dbImpl
->GetScrollPosition( &offsetY
, &offsetX
);
2090 if ( orient
== wxHORIZONTAL
)
2099 // Inserts an item, returning the index of the new item if successful,
2101 long wxListCtrl::InsertItem(wxListItem
& info
)
2103 wxASSERT_MSG( !IsVirtual(), wxT("can't be used with virtual controls") );
2106 return m_genericImpl
->InsertItem(info
);
2108 if (m_dbImpl
&& !IsVirtual())
2110 int count
= GetItemCount();
2112 if (info
.m_itemId
> count
)
2113 info
.m_itemId
= count
;
2115 m_dbImpl
->MacInsertItem(info
.m_itemId
, &info
);
2117 wxListEvent
event( wxEVT_COMMAND_LIST_INSERT_ITEM
, GetId() );
2118 event
.SetEventObject( this );
2119 event
.m_itemIndex
= info
.m_itemId
;
2120 HandleWindowEvent( event
);
2121 return info
.m_itemId
;
2126 long wxListCtrl::InsertItem(long index
, const wxString
& label
)
2129 return m_genericImpl
->InsertItem(index
, label
);
2132 info
.m_text
= label
;
2133 info
.m_mask
= wxLIST_MASK_TEXT
;
2134 info
.m_itemId
= index
;
2135 return InsertItem(info
);
2138 // Inserts an image item
2139 long wxListCtrl::InsertItem(long index
, int imageIndex
)
2142 return m_genericImpl
->InsertItem(index
, imageIndex
);
2145 info
.m_image
= imageIndex
;
2146 info
.m_mask
= wxLIST_MASK_IMAGE
;
2147 info
.m_itemId
= index
;
2148 return InsertItem(info
);
2151 // Inserts an image/string item
2152 long wxListCtrl::InsertItem(long index
, const wxString
& label
, int imageIndex
)
2155 return m_genericImpl
->InsertItem(index
, label
, imageIndex
);
2158 info
.m_image
= imageIndex
;
2159 info
.m_text
= label
;
2160 info
.m_mask
= wxLIST_MASK_IMAGE
| wxLIST_MASK_TEXT
;
2161 info
.m_itemId
= index
;
2162 return InsertItem(info
);
2165 // For list view mode (only), inserts a column.
2166 long wxListCtrl::InsertColumn(long col
, wxListItem
& item
)
2169 return m_genericImpl
->InsertColumn(col
, item
);
2173 int width
= item
.GetWidth();
2174 if ( !(item
.GetMask() & wxLIST_MASK_WIDTH
) )
2177 DataBrowserPropertyType type
= kDataBrowserCustomType
; //kDataBrowserTextType;
2178 wxImageList
* imageList
= GetImageList(wxIMAGE_LIST_SMALL
);
2179 if (imageList
&& imageList
->GetImageCount() > 0)
2181 wxBitmap bmp
= imageList
->GetBitmap(0);
2183 // type = kDataBrowserIconAndTextType;
2186 SInt16 just
= teFlushDefault
;
2187 if (item
.GetMask() & wxLIST_MASK_FORMAT
)
2189 if (item
.GetAlign() == wxLIST_FORMAT_LEFT
)
2191 else if (item
.GetAlign() == wxLIST_FORMAT_CENTER
)
2193 else if (item
.GetAlign() == wxLIST_FORMAT_RIGHT
)
2194 just
= teFlushRight
;
2196 m_dbImpl
->InsertColumn(col
, type
, item
.GetText(), just
, width
);
2198 wxListItem
* listItem
= new wxListItem(item
);
2199 m_colsInfo
.Insert( col
, listItem
);
2200 SetColumn(col
, item
);
2202 // set/remove options based on the wxListCtrl type.
2203 DataBrowserTableViewColumnID id
;
2204 m_dbImpl
->GetColumnIDFromIndex(col
, &id
);
2205 DataBrowserPropertyFlags flags
;
2206 verify_noerr(m_dbImpl
->GetPropertyFlags(id
, &flags
));
2207 if (GetWindowStyleFlag() & wxLC_EDIT_LABELS
)
2208 flags
|= kDataBrowserPropertyIsEditable
;
2210 if (GetWindowStyleFlag() & wxLC_VIRTUAL
){
2211 flags
&= ~kDataBrowserListViewSortableColumn
;
2213 verify_noerr(m_dbImpl
->SetPropertyFlags(id
, flags
));
2219 long wxListCtrl::InsertColumn(long col
,
2220 const wxString
& heading
,
2225 return m_genericImpl
->InsertColumn(col
, heading
, format
, width
);
2228 item
.m_mask
= wxLIST_MASK_TEXT
| wxLIST_MASK_FORMAT
;
2229 item
.m_text
= heading
;
2232 item
.m_mask
|= wxLIST_MASK_WIDTH
;
2233 item
.m_width
= width
;
2235 item
.m_format
= format
;
2237 return InsertColumn(col
, item
);
2240 // scroll the control by the given number of pixels (exception: in list view,
2241 // dx is interpreted as number of columns)
2242 bool wxListCtrl::ScrollList(int dx
, int dy
)
2245 return m_genericImpl
->ScrollList(dx
, dy
);
2249 // Notice that the parameter order is correct here: first argument is
2250 // the "top" displacement, second one is the "left" one.
2251 m_dbImpl
->SetScrollPosition(dy
, dx
);
2257 bool wxListCtrl::SortItems(wxListCtrlCompare fn
, wxIntPtr data
)
2260 return m_genericImpl
->SortItems(fn
, data
);
2265 m_compareFuncData
= data
;
2266 SortDataBrowserContainer( m_dbImpl
->GetControlRef(), kDataBrowserNoItem
, true);
2268 // we need to do this after each call, else we get a crash from wxPython when
2269 // SortItems is called the second time.
2270 m_compareFunc
= NULL
;
2271 m_compareFuncData
= 0;
2277 void wxListCtrl::OnRenameTimer()
2279 wxCHECK_RET( HasCurrent(), wxT("unexpected rename timer") );
2281 EditLabel( m_current
);
2284 bool wxListCtrl::OnRenameAccept(long itemEdit
, const wxString
& value
)
2286 wxListEvent
le( wxEVT_COMMAND_LIST_END_LABEL_EDIT
, GetId() );
2287 le
.SetEventObject( this );
2288 le
.m_itemIndex
= itemEdit
;
2290 GetItem( le
.m_item
);
2291 le
.m_item
.m_text
= value
;
2292 return !HandleWindowEvent( le
) ||
2296 void wxListCtrl::OnRenameCancelled(long itemEdit
)
2298 // let owner know that the edit was cancelled
2299 wxListEvent
le( wxEVT_COMMAND_LIST_END_LABEL_EDIT
, GetParent()->GetId() );
2301 le
.SetEditCanceled(true);
2303 le
.SetEventObject( this );
2304 le
.m_itemIndex
= itemEdit
;
2306 GetItem( le
.m_item
);
2307 HandleWindowEvent( le
);
2310 // ----------------------------------------------------------------------------
2311 // virtual list controls
2312 // ----------------------------------------------------------------------------
2314 wxString
wxListCtrl::OnGetItemText(long WXUNUSED(item
), long WXUNUSED(col
)) const
2316 // this is a pure virtual function, in fact - which is not really pure
2317 // because the controls which are not virtual don't need to implement it
2318 wxFAIL_MSG( wxT("wxListCtrl::OnGetItemText not supposed to be called") );
2320 return wxEmptyString
;
2323 int wxListCtrl::OnGetItemImage(long WXUNUSED(item
)) const
2325 wxCHECK_MSG(!GetImageList(wxIMAGE_LIST_SMALL
),
2327 wxT("List control has an image list, OnGetItemImage or OnGetItemColumnImage should be overridden."));
2331 int wxListCtrl::OnGetItemColumnImage(long item
, long column
) const
2334 return OnGetItemImage(item
);
2339 wxListItemAttr
*wxListCtrl::OnGetItemAttr(long WXUNUSED_UNLESS_DEBUG(item
)) const
2341 wxASSERT_MSG( item
>= 0 && item
< GetItemCount(),
2342 wxT("invalid item index in OnGetItemAttr()") );
2344 // no attributes by default
2348 void wxListCtrl::SetItemCount(long count
)
2350 wxASSERT_MSG( IsVirtual(), wxT("this is for virtual controls only") );
2354 m_genericImpl
->SetItemCount(count
);
2360 // we need to temporarily disable the new item creation notification
2361 // procedure to speed things up
2362 // FIXME: Even this doesn't seem to help much...
2364 // FIXME: Find a more efficient way to do this.
2365 m_dbImpl
->MacClear();
2367 DataBrowserCallbacks callbacks
;
2368 DataBrowserItemNotificationUPP itemUPP
;
2369 GetDataBrowserCallbacks(m_dbImpl
->GetControlRef(), &callbacks
);
2370 itemUPP
= callbacks
.u
.v1
.itemNotificationCallback
;
2371 callbacks
.u
.v1
.itemNotificationCallback
= 0;
2372 m_dbImpl
->SetCallbacks(&callbacks
);
2373 ::AddDataBrowserItems(m_dbImpl
->GetControlRef(), kDataBrowserNoItem
,
2374 count
, NULL
, kDataBrowserItemNoProperty
);
2375 callbacks
.u
.v1
.itemNotificationCallback
= itemUPP
;
2376 m_dbImpl
->SetCallbacks(&callbacks
);
2381 void wxListCtrl::RefreshItem(long item
)
2385 m_genericImpl
->RefreshItem(item
);
2391 DataBrowserItemID id
;
2395 wxMacDataItem
* thisItem
= m_dbImpl
->GetItemFromLine(item
);
2396 id
= (DataBrowserItemID
) thisItem
;
2401 m_dbImpl
->wxMacDataBrowserControl::UpdateItems
2405 kDataBrowserItemNoProperty
, // preSortProperty
2406 kDataBrowserNoItem
// update all columns
2411 void wxListCtrl::RefreshItems(long itemFrom
, long itemTo
)
2415 m_genericImpl
->RefreshItems(itemFrom
, itemTo
);
2421 const long count
= itemTo
- itemFrom
+ 1;
2422 DataBrowserItemID
*ids
= new DataBrowserItemID
[count
];
2426 for ( long i
= 0; i
< count
; i
++ )
2428 wxMacDataItem
* thisItem
= m_dbImpl
->GetItemFromLine(itemFrom
+i
);
2429 ids
[i
] = (DataBrowserItemID
) thisItem
;
2434 for ( long i
= 0; i
< count
; i
++ )
2435 ids
[i
] = itemFrom
+i
+1;
2438 m_dbImpl
->wxMacDataBrowserControl::UpdateItems
2442 kDataBrowserItemNoProperty
, // preSortProperty
2443 kDataBrowserNoItem
// update all columns
2450 void wxListCtrl::SetDropTarget( wxDropTarget
*dropTarget
)
2452 #if wxUSE_DRAG_AND_DROP
2454 m_genericImpl
->SetDropTarget( dropTarget
);
2457 wxWindow::SetDropTarget( dropTarget
);
2461 wxDropTarget
*wxListCtrl::GetDropTarget() const
2463 #if wxUSE_DRAG_AND_DROP
2465 return m_genericImpl
->GetDropTarget();
2468 return wxWindow::GetDropTarget();
2473 #if wxABI_VERSION >= 20801
2474 void wxListCtrl::SetFocus()
2478 m_genericImpl
->SetFocus();
2482 wxWindow::SetFocus();
2486 // wxMac internal data structures
2488 wxMacListCtrlItem::~wxMacListCtrlItem()
2490 WX_CLEAR_HASH_MAP( wxListItemList
, m_rowItems
);
2493 void wxMacListCtrlItem::Notification(wxMacDataItemBrowserControl
*owner
,
2494 DataBrowserItemNotification message
,
2495 DataBrowserItemDataRef
WXUNUSED(itemData
) ) const
2498 wxMacDataBrowserListCtrlControl
*lb
= wxDynamicCast(owner
, wxMacDataBrowserListCtrlControl
);
2500 // we want to depend on as little as possible to make sure tear-down of controls is safe
2501 if ( message
== kDataBrowserItemRemoved
)
2506 else if ( message
== kDataBrowserItemAdded
)
2508 // we don't issue events on adding, the item is not really stored in the list yet, so we
2509 // avoid asserts by gettting out now
2513 wxListCtrl
*list
= wxDynamicCast( owner
->GetWXPeer() , wxListCtrl
);
2516 bool trigger
= false;
2518 wxListEvent
event( wxEVT_COMMAND_LIST_ITEM_SELECTED
, list
->GetId() );
2519 bool isSingle
= (list
->GetWindowStyle() & wxLC_SINGLE_SEL
) != 0;
2521 event
.SetEventObject( list
);
2522 event
.m_itemIndex
= owner
->GetLineFromItem( this ) ;
2523 event
.m_item
.m_itemId
= event
.m_itemIndex
;
2524 list
->GetItem(event
.m_item
);
2528 case kDataBrowserItemDeselected
:
2529 event
.SetEventType(wxEVT_COMMAND_LIST_ITEM_DESELECTED
);
2531 trigger
= !lb
->IsSelectionSuppressed();
2534 case kDataBrowserItemSelected
:
2535 trigger
= !lb
->IsSelectionSuppressed();
2538 case kDataBrowserItemDoubleClicked
:
2539 event
.SetEventType( wxEVT_COMMAND_LIST_ITEM_ACTIVATED
);
2543 case kDataBrowserEditStarted
:
2544 // TODO : how to veto ?
2545 event
.SetEventType( wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
) ;
2549 case kDataBrowserEditStopped
:
2550 // TODO probably trigger only upon the value store callback, because
2551 // here IIRC we cannot veto
2552 event
.SetEventType( wxEVT_COMMAND_LIST_END_LABEL_EDIT
) ;
2562 // direct notification is not always having the listbox GetSelection() having in synch with event
2563 wxPostEvent( list
->GetEventHandler(), event
);
2569 IMPLEMENT_DYNAMIC_CLASS(wxMacDataBrowserListCtrlControl
, wxMacDataItemBrowserControl
)
2571 wxMacDataBrowserListCtrlControl::wxMacDataBrowserListCtrlControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
)
2572 : wxMacDataItemBrowserControl( peer
, pos
, size
, style
)
2574 OSStatus err
= noErr
;
2575 m_clientDataItemsType
= wxClientData_None
;
2576 m_isVirtual
= false;
2579 if ( style
& wxLC_VIRTUAL
)
2582 DataBrowserSelectionFlags options
= kDataBrowserDragSelect
;
2583 if ( style
& wxLC_SINGLE_SEL
)
2585 options
|= kDataBrowserSelectOnlyOne
;
2589 options
|= kDataBrowserCmdTogglesSelection
;
2592 err
= SetSelectionFlags( options
);
2593 verify_noerr( err
);
2595 DataBrowserCustomCallbacks callbacks
;
2596 InitializeDataBrowserCustomCallbacks( &callbacks
, kDataBrowserLatestCustomCallbacks
);
2598 if ( gDataBrowserDrawItemUPP
== NULL
)
2599 gDataBrowserDrawItemUPP
= NewDataBrowserDrawItemUPP(DataBrowserDrawItemProc
);
2601 if ( gDataBrowserHitTestUPP
== NULL
)
2602 gDataBrowserHitTestUPP
= NewDataBrowserHitTestUPP(DataBrowserHitTestProc
);
2604 callbacks
.u
.v1
.drawItemCallback
= gDataBrowserDrawItemUPP
;
2605 callbacks
.u
.v1
.hitTestCallback
= gDataBrowserHitTestUPP
;
2607 SetDataBrowserCustomCallbacks( GetControlRef(), &callbacks
);
2609 if ( style
& wxLC_LIST
)
2611 InsertColumn(0, kDataBrowserIconAndTextType
, wxEmptyString
, -1, -1);
2612 verify_noerr( AutoSizeColumns() );
2615 if ( style
& wxLC_LIST
|| style
& wxLC_NO_HEADER
)
2616 verify_noerr( SetHeaderButtonHeight( 0 ) );
2619 SetSortProperty( kMinColumnId
- 1 );
2621 SetSortProperty( kMinColumnId
);
2623 m_sortOrder
= SortOrder_None
;
2625 if ( style
& wxLC_SORT_DESCENDING
)
2627 SetSortOrder( kDataBrowserOrderDecreasing
);
2629 else if ( style
& wxLC_SORT_ASCENDING
)
2631 SetSortOrder( kDataBrowserOrderIncreasing
);
2634 if ( style
& wxLC_VRULES
)
2636 verify_noerr( DataBrowserChangeAttributes(m_controlRef
, kDataBrowserAttributeListViewDrawColumnDividers
, kDataBrowserAttributeNone
) );
2639 verify_noerr( SetHiliteStyle(kDataBrowserTableViewFillHilite
) );
2640 verify_noerr( SetHasScrollBars( (style
& wxHSCROLL
) != 0 , true ) );
2643 pascal Boolean
wxMacDataBrowserListCtrlControl::DataBrowserEditTextProc(
2645 DataBrowserItemID itemID
,
2646 DataBrowserPropertyID property
,
2647 CFStringRef theString
,
2648 Rect
*maxEditTextRect
,
2649 Boolean
*shrinkToFit
)
2651 Boolean result
= false;
2652 wxMacDataBrowserListCtrlControl
* ctl
= wxDynamicCast(wxMacControl::GetReferenceFromNativeControl( browser
), wxMacDataBrowserListCtrlControl
);
2655 result
= ctl
->ConfirmEditText(itemID
, property
, theString
, maxEditTextRect
, shrinkToFit
);
2656 theString
= CFSTR("Hello!");
2661 bool wxMacDataBrowserListCtrlControl::ConfirmEditText(
2662 DataBrowserItemID
WXUNUSED(itemID
),
2663 DataBrowserPropertyID
WXUNUSED(property
),
2664 CFStringRef
WXUNUSED(theString
),
2665 Rect
*WXUNUSED(maxEditTextRect
),
2666 Boolean
*WXUNUSED(shrinkToFit
))
2671 pascal void wxMacDataBrowserListCtrlControl::DataBrowserDrawItemProc(
2673 DataBrowserItemID itemID
,
2674 DataBrowserPropertyID property
,
2675 DataBrowserItemState itemState
,
2676 const Rect
*itemRect
,
2678 Boolean colorDevice
)
2680 wxMacDataBrowserListCtrlControl
* ctl
= wxDynamicCast(wxMacControl::GetReferenceFromNativeControl( browser
), wxMacDataBrowserListCtrlControl
);
2683 ctl
->DrawItem(itemID
, property
, itemState
, itemRect
, gdDepth
, colorDevice
);
2687 // routines needed for DrawItem
2692 kTextBoxHeight
= 14,
2693 kIconTextSpacingV
= 2,
2695 kContentHeight
= kIconHeight
+ kTextBoxHeight
+ kIconTextSpacingV
2698 static void calculateCGDrawingBounds(CGRect inItemRect
, CGRect
*outIconRect
, CGRect
*outTextRect
, bool hasIcon
= false)
2701 float iconH
, iconW
= 0;
2702 float padding
= kItemPadding
;
2705 iconH
= kIconHeight
;
2707 padding
= padding
*2;
2710 textBottom
= inItemRect
.origin
.y
;
2712 *outIconRect
= CGRectMake(inItemRect
.origin
.x
+ kItemPadding
,
2713 textBottom
+ kIconTextSpacingV
, kIconWidth
,
2716 *outTextRect
= CGRectMake(inItemRect
.origin
.x
+ padding
+ iconW
,
2717 textBottom
+ kIconTextSpacingV
, inItemRect
.size
.width
- padding
- iconW
,
2718 inItemRect
.size
.height
- kIconTextSpacingV
);
2721 void wxMacDataBrowserListCtrlControl::DrawItem(
2722 DataBrowserItemID itemID
,
2723 DataBrowserPropertyID property
,
2724 DataBrowserItemState itemState
,
2725 const Rect
*WXUNUSED(itemRect
),
2727 Boolean colorDevice
)
2730 wxFont font
= wxNullFont
;
2733 DataBrowserTableViewColumnIndex listColumn
= 0;
2734 GetColumnPosition( property
, &listColumn
);
2736 wxListCtrl
* list
= wxDynamicCast( GetWXPeer() , wxListCtrl
);
2737 wxMacListCtrlItem
* lcItem
;
2738 wxColour color
= *wxBLACK
;
2739 wxColour bgColor
= wxNullColour
;
2741 if (listColumn
>= 0)
2745 lcItem
= (wxMacListCtrlItem
*) itemID
;
2746 if (lcItem
->HasColumnInfo(listColumn
))
2748 wxListItem
* item
= lcItem
->GetColumnInfo(listColumn
);
2750 // we always use the 0 column to get font and text/background colors.
2751 if (lcItem
->HasColumnInfo(0))
2753 wxListItem
* firstItem
= lcItem
->GetColumnInfo(0);
2754 color
= firstItem
->GetTextColour();
2755 bgColor
= firstItem
->GetBackgroundColour();
2756 font
= firstItem
->GetFont();
2759 if (item
->GetMask() & wxLIST_MASK_TEXT
)
2760 text
= item
->GetText();
2761 if (item
->GetMask() & wxLIST_MASK_IMAGE
)
2762 imgIndex
= item
->GetImage();
2768 long itemNum
= (long)itemID
-1;
2769 if (itemNum
>= 0 && itemNum
< list
->GetItemCount())
2771 text
= list
->OnGetItemText( itemNum
, listColumn
);
2772 imgIndex
= list
->OnGetItemColumnImage( itemNum
, listColumn
);
2773 wxListItemAttr
* attrs
= list
->OnGetItemAttr( itemNum
);
2776 if (attrs
->HasBackgroundColour())
2777 bgColor
= attrs
->GetBackgroundColour();
2778 if (attrs
->HasTextColour())
2779 color
= attrs
->GetTextColour();
2780 if (attrs
->HasFont())
2781 font
= attrs
->GetFont();
2787 wxColour listBgColor
= list
->GetBackgroundColour();
2788 if (bgColor
== wxNullColour
)
2789 bgColor
= listBgColor
;
2792 font
= list
->GetFont();
2794 wxCFStringRef
cfString( text
, wxLocale::GetSystemEncoding() );
2797 CGRect enclosingCGRect
, iconCGRect
, textCGRect
;
2799 ThemeDrawingState savedState
= NULL
;
2800 CGContextRef context
= (CGContextRef
)list
->MacGetDrawingContext();
2801 wxMacCGContextStateSaver
top_saver_cg( context
);
2803 RGBColor labelColor
;
2805 labelColor
.green
= 0;
2806 labelColor
.blue
= 0;
2808 RGBColor backgroundColor
;
2809 backgroundColor
.red
= 255;
2810 backgroundColor
.green
= 255;
2811 backgroundColor
.blue
= 255;
2813 GetDataBrowserItemPartBounds(GetControlRef(), itemID
, property
, kDataBrowserPropertyEnclosingPart
,
2816 enclosingCGRect
= CGRectMake(enclosingRect
.left
,
2818 enclosingRect
.right
- enclosingRect
.left
,
2819 enclosingRect
.bottom
- enclosingRect
.top
);
2821 bool hasFocus
= (wxWindow::FindFocus() == list
);
2822 active
= IsControlActive(GetControlRef());
2824 // don't paint the background over the vertical rule line
2825 if ( list
->GetWindowStyleFlag() & wxLC_VRULES
)
2827 enclosingCGRect
.origin
.x
+= 1;
2828 enclosingCGRect
.size
.width
-= 1;
2830 if (itemState
== kDataBrowserItemIsSelected
)
2833 GetThemeDrawingState(&savedState
);
2835 if (active
&& hasFocus
)
2837 GetThemeBrushAsColor(kThemeBrushAlternatePrimaryHighlightColor
, 32, true, &backgroundColor
);
2838 GetThemeTextColor(kThemeTextColorWhite
, gdDepth
, colorDevice
, &labelColor
);
2842 GetThemeBrushAsColor(kThemeBrushSecondaryHighlightColor
, 32, true, &backgroundColor
);
2843 GetThemeTextColor(kThemeTextColorBlack
, gdDepth
, colorDevice
, &labelColor
);
2845 wxMacCGContextStateSaver
cg( context
);
2847 CGContextSetRGBFillColor(context
, (CGFloat
)backgroundColor
.red
/ (CGFloat
)USHRT_MAX
,
2848 (CGFloat
)backgroundColor
.green
/ (CGFloat
)USHRT_MAX
,
2849 (CGFloat
)backgroundColor
.blue
/ (CGFloat
)USHRT_MAX
, (CGFloat
) 1.0);
2850 CGContextFillRect(context
, enclosingCGRect
);
2856 color
.GetRGBColor(&labelColor
);
2857 else if (list
->GetTextColour().Ok())
2858 list
->GetTextColour().GetRGBColor(&labelColor
);
2862 bgColor
.GetRGBColor(&backgroundColor
);
2863 CGContextSaveGState(context
);
2865 CGContextSetRGBFillColor(context
, (CGFloat
)backgroundColor
.red
/ (CGFloat
)USHRT_MAX
,
2866 (CGFloat
)backgroundColor
.green
/ (CGFloat
)USHRT_MAX
,
2867 (CGFloat
)backgroundColor
.blue
/ (CGFloat
)USHRT_MAX
, (CGFloat
) 1.0);
2868 CGContextFillRect(context
, enclosingCGRect
);
2870 CGContextRestoreGState(context
);
2874 calculateCGDrawingBounds(enclosingCGRect
, &iconCGRect
, &textCGRect
, (imgIndex
!= -1) );
2878 wxImageList
* imageList
= list
->GetImageList(wxIMAGE_LIST_SMALL
);
2879 if (imageList
&& imageList
->GetImageCount() > 0)
2881 wxBitmap bmp
= imageList
->GetBitmap(imgIndex
);
2882 IconRef icon
= bmp
.GetIconRef();
2884 wxMacCGContextStateSaver
cg( context
);
2886 CGContextTranslateCTM(context
, 0,iconCGRect
.origin
.y
+ CGRectGetMaxY(iconCGRect
));
2887 CGContextScaleCTM(context
,1.0f
,-1.0f
);
2888 PlotIconRefInContext(context
, &iconCGRect
, kAlignNone
,
2889 active
? kTransformNone
: kTransformDisabled
, NULL
,
2890 kPlotIconRefNormalFlags
, icon
);
2894 HIThemeTextHorizontalFlush hFlush
= kHIThemeTextHorizontalFlushLeft
;
2895 HIThemeTextInfo info
;
2897 #if wxOSX_USE_CORE_TEXT
2898 if ( UMAGetSystemVersion() >= 0x1050 )
2900 info
.version
= kHIThemeTextInfoVersionOne
;
2901 info
.fontID
= kThemeViewsFont
;
2904 info
.fontID
= kThemeSpecifiedFont
;
2905 info
.font
= (CTFontRef
) font
.OSXGetCTFont();
2910 #if wxOSX_USE_ATSU_TEXT
2913 info
.version
= kHIThemeTextInfoVersionZero
;
2914 info
.fontID
= kThemeViewsFont
;
2918 info
.fontID
= font
.MacGetThemeFontID();
2920 ::TextSize( (short)(font
.GetPointSize()) ) ;
2921 ::TextFace( font
.MacGetFontStyle() ) ;
2927 list
->GetColumn(listColumn
, item
);
2928 if (item
.GetMask() & wxLIST_MASK_FORMAT
)
2930 if (item
.GetAlign() == wxLIST_FORMAT_LEFT
)
2931 hFlush
= kHIThemeTextHorizontalFlushLeft
;
2932 else if (item
.GetAlign() == wxLIST_FORMAT_CENTER
)
2933 hFlush
= kHIThemeTextHorizontalFlushCenter
;
2934 else if (item
.GetAlign() == wxLIST_FORMAT_RIGHT
)
2936 hFlush
= kHIThemeTextHorizontalFlushRight
;
2937 textCGRect
.origin
.x
-= kItemPadding
; // give a little extra paddding
2941 info
.state
= active
? kThemeStateActive
: kThemeStateInactive
;
2942 info
.horizontalFlushness
= hFlush
;
2943 info
.verticalFlushness
= kHIThemeTextVerticalFlushCenter
;
2944 info
.options
= kHIThemeTextBoxOptionNone
;
2945 info
.truncationPosition
= kHIThemeTextTruncationEnd
;
2946 info
.truncationMaxLines
= 1;
2949 wxMacCGContextStateSaver
cg( context
);
2950 CGContextSetRGBFillColor (context
, (CGFloat
)labelColor
.red
/ (CGFloat
)USHRT_MAX
,
2951 (CGFloat
)labelColor
.green
/ (CGFloat
)USHRT_MAX
,
2952 (CGFloat
)labelColor
.blue
/ (CGFloat
)USHRT_MAX
, (CGFloat
) 1.0);
2954 HIThemeDrawTextBox(cfString
, &textCGRect
, &info
, context
, kHIThemeOrientationNormal
);
2958 if (savedState
!= NULL
)
2959 SetThemeDrawingState(savedState
, true);
2963 OSStatus
wxMacDataBrowserListCtrlControl::GetSetItemData(DataBrowserItemID itemID
,
2964 DataBrowserPropertyID property
,
2965 DataBrowserItemDataRef itemData
,
2966 Boolean changeValue
)
2971 DataBrowserTableViewColumnIndex listColumn
= 0;
2972 verify_noerr( GetColumnPosition( property
, &listColumn
) );
2974 OSStatus err
= errDataBrowserPropertyNotSupported
;
2975 wxListCtrl
* list
= wxDynamicCast( GetWXPeer() , wxListCtrl
);
2976 wxMacListCtrlItem
* lcItem
= NULL
;
2978 if (listColumn
>= 0)
2982 lcItem
= (wxMacListCtrlItem
*) itemID
;
2983 if (lcItem
&& lcItem
->HasColumnInfo(listColumn
)){
2984 wxListItem
* item
= lcItem
->GetColumnInfo(listColumn
);
2985 if (item
->GetMask() & wxLIST_MASK_TEXT
)
2986 text
= item
->GetText();
2987 if (item
->GetMask() & wxLIST_MASK_IMAGE
)
2988 imgIndex
= item
->GetImage();
2993 long itemNum
= (long)itemID
-1;
2994 if (itemNum
>= 0 && itemNum
< list
->GetItemCount())
2996 text
= list
->OnGetItemText( itemNum
, listColumn
);
2997 imgIndex
= list
->OnGetItemColumnImage( itemNum
, listColumn
);
3006 case kDataBrowserItemIsEditableProperty
:
3007 if ( list
&& list
->HasFlag( wxLC_EDIT_LABELS
) )
3009 verify_noerr(SetDataBrowserItemDataBooleanValue( itemData
, true ));
3014 if ( property
>= kMinColumnId
)
3016 if (!text
.IsEmpty()){
3017 wxCFStringRef
cfStr( text
, wxLocale::GetSystemEncoding() );
3018 err
= ::SetDataBrowserItemDataText( itemData
, cfStr
);
3024 if ( imgIndex
!= -1 )
3026 wxImageList
* imageList
= list
->GetImageList(wxIMAGE_LIST_SMALL
);
3027 if (imageList
&& imageList
->GetImageCount() > 0){
3028 wxBitmap bmp
= imageList
->GetBitmap(imgIndex
);
3029 IconRef icon
= bmp
.GetIconRef();
3030 ::SetDataBrowserItemDataIcon(itemData
, icon
);
3044 if ( property
>= kMinColumnId
)
3046 DataBrowserTableViewColumnIndex listColumn
= 0;
3047 verify_noerr( GetColumnPosition( property
, &listColumn
) );
3049 // TODO probably send the 'end edit' from here, as we
3050 // can then deal with the veto
3052 verify_noerr( GetDataBrowserItemDataText( itemData
, &sr
) ) ;
3053 wxCFStringRef
cfStr(sr
) ;;
3055 list
->SetItem( (long)itemData
-1 , listColumn
, cfStr
.AsString() ) ;
3059 lcItem
->SetColumnTextValue( listColumn
, cfStr
.AsString() );
3069 void wxMacDataBrowserListCtrlControl::ItemNotification(DataBrowserItemID itemID
,
3070 DataBrowserItemNotification message
,
3071 DataBrowserItemDataRef itemData
)
3073 wxMacListCtrlItem
*item
= NULL
;
3076 item
= (wxMacListCtrlItem
*) itemID
;
3079 // we want to depend on as little as possible to make sure tear-down of controls is safe
3080 if ( message
== kDataBrowserItemRemoved
)
3083 item
->Notification(this, message
, itemData
);
3086 else if ( message
== kDataBrowserItemAdded
)
3088 // we don't issue events on adding, the item is not really stored in the list yet, so we
3089 // avoid asserts by getting out now
3091 item
->Notification(this, message
, itemData
);
3095 wxListCtrl
*list
= wxDynamicCast( GetWXPeer() , wxListCtrl
);
3098 bool trigger
= false;
3100 wxListEvent
event( wxEVT_COMMAND_LIST_ITEM_SELECTED
, list
->GetId() );
3102 event
.SetEventObject( list
);
3103 if ( !list
->IsVirtual() )
3105 DataBrowserTableViewRowIndex result
= 0;
3106 verify_noerr( GetItemRow( itemID
, &result
) ) ;
3107 event
.m_itemIndex
= result
;
3111 event
.m_itemIndex
= (long)itemID
-1;
3113 event
.m_item
.m_itemId
= event
.m_itemIndex
;
3114 list
->GetItem(event
.m_item
);
3118 case kDataBrowserItemDeselected
:
3119 event
.SetEventType(wxEVT_COMMAND_LIST_ITEM_DESELECTED
);
3120 // as the generic implementation is also triggering this
3121 // event for single selection, we do the same (different than listbox)
3122 trigger
= !IsSelectionSuppressed();
3125 case kDataBrowserItemSelected
:
3126 trigger
= !IsSelectionSuppressed();
3130 case kDataBrowserItemDoubleClicked
:
3131 event
.SetEventType( wxEVT_COMMAND_LIST_ITEM_ACTIVATED
);
3135 case kDataBrowserEditStarted
:
3136 // TODO : how to veto ?
3137 event
.SetEventType( wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
) ;
3141 case kDataBrowserEditStopped
:
3142 // TODO probably trigger only upon the value store callback, because
3143 // here IIRC we cannot veto
3144 event
.SetEventType( wxEVT_COMMAND_LIST_END_LABEL_EDIT
) ;
3154 // direct notification is not always having the listbox GetSelection() having in synch with event
3155 wxPostEvent( list
->GetEventHandler(), event
);
3160 Boolean
wxMacDataBrowserListCtrlControl::CompareItems(DataBrowserItemID itemOneID
,
3161 DataBrowserItemID itemTwoID
,
3162 DataBrowserPropertyID sortProperty
)
3165 bool retval
= false;
3167 wxString otherItemText
;
3169 long otherItemOrder
;
3171 DataBrowserTableViewColumnIndex colId
= 0;
3172 verify_noerr( GetColumnPosition( sortProperty
, &colId
) );
3174 wxListCtrl
* list
= wxDynamicCast( GetWXPeer() , wxListCtrl
);
3176 DataBrowserSortOrder sort
;
3177 verify_noerr(GetSortOrder(&sort
));
3183 wxMacListCtrlItem
* item
= (wxMacListCtrlItem
*)itemOneID
;
3184 wxMacListCtrlItem
* otherItem
= (wxMacListCtrlItem
*)itemTwoID
;
3186 itemOrder
= item
->GetOrder();
3187 otherItemOrder
= otherItem
->GetOrder();
3189 wxListCtrlCompare func
= list
->GetCompareFunc();
3195 if (item
&& item
->HasColumnInfo(0))
3196 item1
= item
->GetColumnInfo(0)->GetData();
3197 if (otherItem
&& otherItem
->HasColumnInfo(0))
3198 item2
= otherItem
->GetColumnInfo(0)->GetData();
3200 if (item1
> -1 && item2
> -1)
3202 int result
= func(item1
, item2
, list
->GetCompareFuncData());
3203 if (sort
== kDataBrowserOrderIncreasing
)
3210 // we can't use the native control's sorting abilities, so just
3212 return itemOrder
< otherItemOrder
;
3217 long itemNum
= (long)itemOneID
;
3218 long otherItemNum
= (long)itemTwoID
;
3220 // virtual listctrls don't support sorting
3221 return itemNum
< otherItemNum
;
3225 // fallback for undefined cases
3226 retval
= itemOneID
< itemTwoID
;
3232 wxMacDataBrowserListCtrlControl::~wxMacDataBrowserListCtrlControl()
3236 void wxMacDataBrowserListCtrlControl::MacSetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
* item
)
3238 wxMacDataItem
* dataItem
= GetItemFromLine(row
);
3239 wxASSERT_MSG( dataItem
, wxT("could not obtain wxMacDataItem for row in MacSetColumnInfo. Is row a valid wxListCtrl row?") );
3242 wxMacListCtrlItem
* listItem
= static_cast<wxMacListCtrlItem
*>(dataItem
);
3243 bool hasInfo
= listItem
->HasColumnInfo( column
);
3244 listItem
->SetColumnInfo( column
, item
);
3245 listItem
->SetOrder(row
);
3246 UpdateState(dataItem
, item
);
3248 wxListCtrl
* list
= wxDynamicCast( GetWXPeer() , wxListCtrl
);
3250 // NB: When this call was made before a control was completely shown, it would
3251 // update the item prematurely (i.e. no text would be listed) and, on show,
3252 // only the sorted column would be refreshed, meaning only first column text labels
3253 // would be shown. Making sure not to update items until the control is visible
3254 // seems to fix this issue.
3255 if (hasInfo
&& list
->IsShown())
3257 DataBrowserTableViewColumnID id
= 0;
3258 verify_noerr( GetColumnIDFromIndex( column
, &id
) );
3259 UpdateItem( wxMacDataBrowserRootContainer
, listItem
, id
);
3264 // apply changes that need to happen immediately, rather than when the
3265 // databrowser control fires a callback.
3266 void wxMacDataBrowserListCtrlControl::UpdateState(wxMacDataItem
* dataItem
, wxListItem
* listItem
)
3268 bool isSelected
= IsItemSelected( dataItem
);
3269 bool isSelectedState
= (listItem
->GetState() == wxLIST_STATE_SELECTED
);
3271 // toggle the selection state if wxListInfo state and actual state don't match.
3272 if ( listItem
->GetMask() & wxLIST_MASK_STATE
&& isSelected
!= isSelectedState
)
3274 DataBrowserSetOption options
= kDataBrowserItemsAdd
;
3275 if (!isSelectedState
)
3276 options
= kDataBrowserItemsRemove
;
3277 SetSelectedItem(dataItem
, options
);
3279 // TODO: Set column width if item width > than current column width
3282 void wxMacDataBrowserListCtrlControl::MacGetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
& item
)
3284 wxMacDataItem
* dataItem
= GetItemFromLine(row
);
3285 wxASSERT_MSG( dataItem
, wxT("could not obtain wxMacDataItem in MacGetColumnInfo. Is row a valid wxListCtrl row?") );
3286 // CS should this guard against dataItem = 0 ? , as item is not a pointer if (item) is not appropriate
3289 wxMacListCtrlItem
* listItem
= static_cast<wxMacListCtrlItem
*>(dataItem
);
3291 if (!listItem
->HasColumnInfo( column
))
3294 wxListItem
* oldItem
= listItem
->GetColumnInfo( column
);
3298 long mask
= item
.GetMask();
3300 // by default, get everything for backwards compatibility
3303 if ( mask
& wxLIST_MASK_TEXT
)
3304 item
.SetText(oldItem
->GetText());
3305 if ( mask
& wxLIST_MASK_IMAGE
)
3306 item
.SetImage(oldItem
->GetImage());
3307 if ( mask
& wxLIST_MASK_DATA
)
3308 item
.SetData(oldItem
->GetData());
3309 if ( mask
& wxLIST_MASK_STATE
)
3310 item
.SetState(oldItem
->GetState());
3311 if ( mask
& wxLIST_MASK_WIDTH
)
3312 item
.SetWidth(oldItem
->GetWidth());
3313 if ( mask
& wxLIST_MASK_FORMAT
)
3314 item
.SetAlign(oldItem
->GetAlign());
3316 item
.SetTextColour(oldItem
->GetTextColour());
3317 item
.SetBackgroundColour(oldItem
->GetBackgroundColour());
3318 item
.SetFont(oldItem
->GetFont());
3323 void wxMacDataBrowserListCtrlControl::MacInsertItem( unsigned int n
, wxListItem
* item
)
3326 wxMacDataItemBrowserControl::MacInsert(n
, new wxMacListCtrlItem() );
3327 MacSetColumnInfo(n
, 0, item
);
3330 wxMacListCtrlItem::wxMacListCtrlItem()
3332 m_rowItems
= wxListItemList();
3335 int wxMacListCtrlItem::GetColumnImageValue( unsigned int column
)
3337 if ( HasColumnInfo(column
) )
3338 return GetColumnInfo(column
)->GetImage();
3343 void wxMacListCtrlItem::SetColumnImageValue( unsigned int column
, int imageIndex
)
3345 if ( HasColumnInfo(column
) )
3346 GetColumnInfo(column
)->SetImage(imageIndex
);
3349 wxString
wxMacListCtrlItem::GetColumnTextValue( unsigned int column
)
3351 /* TODO CHECK REMOVE
3355 if ( HasColumnInfo(column
) )
3356 return GetColumnInfo(column
)->GetText();
3358 return wxEmptyString
;
3361 void wxMacListCtrlItem::SetColumnTextValue( unsigned int column
, const wxString
& text
)
3363 if ( HasColumnInfo(column
) )
3364 GetColumnInfo(column
)->SetText(text
);
3366 /* TODO CHECK REMOVE
3367 // for compatibility with superclass APIs
3373 wxListItem
* wxMacListCtrlItem::GetColumnInfo( unsigned int column
)
3375 wxASSERT_MSG( HasColumnInfo(column
), wxT("invalid column index in wxMacListCtrlItem") );
3376 return m_rowItems
[column
];
3379 bool wxMacListCtrlItem::HasColumnInfo( unsigned int column
)
3381 return !(m_rowItems
.find( column
) == m_rowItems
.end());
3384 void wxMacListCtrlItem::SetColumnInfo( unsigned int column
, wxListItem
* item
)
3387 if ( !HasColumnInfo(column
) )
3389 wxListItem
* listItem
= new wxListItem(*item
);
3390 m_rowItems
[column
] = listItem
;
3394 wxListItem
* listItem
= GetColumnInfo( column
);
3395 long mask
= item
->GetMask();
3396 if (mask
& wxLIST_MASK_TEXT
)
3397 listItem
->SetText(item
->GetText());
3398 if (mask
& wxLIST_MASK_DATA
)
3399 listItem
->SetData(item
->GetData());
3400 if (mask
& wxLIST_MASK_IMAGE
)
3401 listItem
->SetImage(item
->GetImage());
3402 if (mask
& wxLIST_MASK_STATE
)
3403 listItem
->SetState(item
->GetState());
3404 if (mask
& wxLIST_MASK_FORMAT
)
3405 listItem
->SetAlign(item
->GetAlign());
3406 if (mask
& wxLIST_MASK_WIDTH
)
3407 listItem
->SetWidth(item
->GetWidth());
3409 if ( item
->HasAttributes() )
3411 if ( listItem
->HasAttributes() )
3412 listItem
->GetAttributes()->AssignFrom(*item
->GetAttributes());
3415 listItem
->SetTextColour(item
->GetTextColour());
3416 listItem
->SetBackgroundColour(item
->GetBackgroundColour());
3417 listItem
->SetFont(item
->GetFont());
3423 int wxListCtrl::CalcColumnAutoWidth(int col
) const
3427 for ( int i
= 0; i
< GetItemCount(); i
++ )
3430 info
.SetMask(wxLIST_MASK_TEXT
| wxLIST_MASK_IMAGE
);
3432 info
.SetColumn(col
);
3435 const wxFont font
= info
.GetFont();
3439 GetTextExtent(info
.GetText(), &w
, NULL
, NULL
, NULL
, &font
);
3441 GetTextExtent(info
.GetText(), &w
, NULL
);
3443 w
+= 2 * kItemPadding
;
3445 if ( info
.GetImage() != -1 )
3448 width
= wxMax(width
, w
);
3454 #endif // wxUSE_LISTCTRL