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 #if wxUSE_EXTENDED_RTTI
45 WX_DEFINE_FLAGS( wxListCtrlStyle
)
47 wxBEGIN_FLAGS( wxListCtrlStyle
)
48 // new style border flags, we put them first to
49 // use them for streaming out
50 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
51 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
52 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
53 wxFLAGS_MEMBER(wxBORDER_RAISED
)
54 wxFLAGS_MEMBER(wxBORDER_STATIC
)
55 wxFLAGS_MEMBER(wxBORDER_NONE
)
57 // old style border flags
58 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
59 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
60 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
61 wxFLAGS_MEMBER(wxRAISED_BORDER
)
62 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
63 wxFLAGS_MEMBER(wxBORDER
)
65 // standard window styles
66 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
67 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
68 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
69 wxFLAGS_MEMBER(wxWANTS_CHARS
)
70 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
71 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
72 wxFLAGS_MEMBER(wxVSCROLL
)
73 wxFLAGS_MEMBER(wxHSCROLL
)
75 wxFLAGS_MEMBER(wxLC_LIST
)
76 wxFLAGS_MEMBER(wxLC_REPORT
)
77 wxFLAGS_MEMBER(wxLC_ICON
)
78 wxFLAGS_MEMBER(wxLC_SMALL_ICON
)
79 wxFLAGS_MEMBER(wxLC_ALIGN_TOP
)
80 wxFLAGS_MEMBER(wxLC_ALIGN_LEFT
)
81 wxFLAGS_MEMBER(wxLC_AUTOARRANGE
)
82 wxFLAGS_MEMBER(wxLC_USER_TEXT
)
83 wxFLAGS_MEMBER(wxLC_EDIT_LABELS
)
84 wxFLAGS_MEMBER(wxLC_NO_HEADER
)
85 wxFLAGS_MEMBER(wxLC_SINGLE_SEL
)
86 wxFLAGS_MEMBER(wxLC_SORT_ASCENDING
)
87 wxFLAGS_MEMBER(wxLC_SORT_DESCENDING
)
88 wxFLAGS_MEMBER(wxLC_VIRTUAL
)
90 wxEND_FLAGS( wxListCtrlStyle
)
92 IMPLEMENT_DYNAMIC_CLASS_XTI(wxListCtrl
, wxControl
,"wx/listctrl.h")
94 wxBEGIN_PROPERTIES_TABLE(wxListCtrl
)
95 wxEVENT_PROPERTY( TextUpdated
, wxEVT_COMMAND_TEXT_UPDATED
, wxCommandEvent
)
97 wxPROPERTY_FLAGS( WindowStyle
, wxListCtrlStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
98 wxEND_PROPERTIES_TABLE()
100 wxBEGIN_HANDLERS_TABLE(wxListCtrl
)
101 wxEND_HANDLERS_TABLE()
103 wxCONSTRUCTOR_5( wxListCtrl
, wxWindow
* , Parent
, wxWindowID
, Id
, wxPoint
, Position
, wxSize
, Size
, long , WindowStyle
)
106 TODO : Expose more information of a list's layout etc. via appropriate objects (¢ la NotebookPageInfo)
109 IMPLEMENT_DYNAMIC_CLASS(wxListCtrl
, wxControl
)
112 IMPLEMENT_DYNAMIC_CLASS(wxListView
, wxListCtrl
)
113 IMPLEMENT_DYNAMIC_CLASS(wxListItem
, wxObject
)
115 IMPLEMENT_DYNAMIC_CLASS(wxListEvent
, wxNotifyEvent
)
117 WX_DECLARE_HASH_MAP( int, wxListItem
*, wxIntegerHash
, wxIntegerEqual
, wxListItemList
);
119 #include "wx/listimpl.cpp"
120 WX_DEFINE_LIST(wxColumnList
)
122 // so we can check for column clicks
123 static const EventTypeSpec eventList
[] =
125 { kEventClassControl
, kEventControlHit
},
126 { kEventClassControl
, kEventControlDraw
}
129 static pascal OSStatus
wxMacListCtrlEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
131 OSStatus result
= eventNotHandledErr
;
133 wxMacCarbonEvent
cEvent( event
) ;
135 ControlRef controlRef
;
136 cEvent
.GetParameter( kEventParamDirectObject
, &controlRef
) ;
138 wxListCtrl
*window
= (wxListCtrl
*) data
;
139 wxListEvent
le( wxEVT_COMMAND_LIST_COL_CLICK
, window
->GetId() );
140 le
.SetEventObject( window
);
142 switch ( GetEventKind( event
) )
144 // check if the column was clicked on and fire an event if so
145 case kEventControlHit
:
147 ControlPartCode result
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
) ;
148 if (result
== kControlButtonPart
){
149 DataBrowserPropertyID col
;
150 GetDataBrowserSortProperty(controlRef
, &col
);
152 DataBrowserTableViewColumnIndex column
= 0;
153 verify_noerr( GetDataBrowserTableViewColumnPosition( controlRef
, col
, &column
) );
156 // FIXME: we can't use the sort property for virtual listctrls
157 // so we need to find a better way to determine which column was clicked...
158 if (!window
->IsVirtual())
159 window
->HandleWindowEvent( le
);
161 result
= CallNextEventHandler(handler
, event
);
164 case kEventControlDraw
:
166 CGContextRef context
= cEvent
.GetParameter
<CGContextRef
>(kEventParamCGContextRef
, typeCGContextRef
) ;
167 window
->MacSetDrawingContext(context
);
168 result
= CallNextEventHandler(handler
, event
);
169 window
->MacSetDrawingContext(NULL
);
180 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacListCtrlEventHandler
)
182 class wxMacListCtrlItem
: public wxMacDataItem
187 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
188 DataBrowserItemNotification message
,
189 DataBrowserItemDataRef itemData
) const;
191 virtual void SetColumnInfo( unsigned int column
, wxListItem
* item
);
192 virtual wxListItem
* GetColumnInfo( unsigned int column
);
193 virtual bool HasColumnInfo( unsigned int column
);
195 virtual void SetColumnTextValue( unsigned int column
, const wxString
& text
);
196 virtual wxString
GetColumnTextValue( unsigned int column
);
198 virtual int GetColumnImageValue( unsigned int column
);
199 virtual void SetColumnImageValue( unsigned int column
, int imageIndex
);
201 virtual ~wxMacListCtrlItem();
203 wxListItemList m_rowItems
;
206 DataBrowserDrawItemUPP gDataBrowserDrawItemUPP
= NULL
;
207 //DataBrowserEditItemUPP gDataBrowserEditItemUPP = NULL;
208 DataBrowserHitTestUPP gDataBrowserHitTestUPP
= NULL
;
210 // TODO: Make a better name!!
211 class wxMacDataBrowserListCtrlControl
: public wxMacDataItemBrowserControl
214 wxMacDataBrowserListCtrlControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
215 wxMacDataBrowserListCtrlControl() {}
216 virtual ~wxMacDataBrowserListCtrlControl();
218 // create a list item (can be a subclass of wxMacListBoxItem)
220 virtual void MacInsertItem( unsigned int n
, wxListItem
* item
);
221 virtual void MacSetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
* item
);
222 virtual void MacGetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
& item
);
223 virtual void UpdateState(wxMacDataItem
* dataItem
, wxListItem
* item
);
224 int GetFlags() { return m_flags
; }
227 // we need to override to provide specialized handling for virtual wxListCtrls
228 virtual OSStatus
GetSetItemData(DataBrowserItemID itemID
,
229 DataBrowserPropertyID property
,
230 DataBrowserItemDataRef itemData
,
231 Boolean changeValue
);
233 virtual void ItemNotification(
234 DataBrowserItemID itemID
,
235 DataBrowserItemNotification message
,
236 DataBrowserItemDataRef itemData
);
238 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
239 DataBrowserItemID itemTwoID
,
240 DataBrowserPropertyID sortProperty
);
242 static pascal void DataBrowserDrawItemProc(ControlRef browser
,
243 DataBrowserItemID item
,
244 DataBrowserPropertyID property
,
245 DataBrowserItemState itemState
,
248 Boolean colorDevice
);
250 virtual void DrawItem(DataBrowserItemID itemID
,
251 DataBrowserPropertyID property
,
252 DataBrowserItemState itemState
,
253 const Rect
*itemRect
,
255 Boolean colorDevice
);
257 static pascal Boolean
DataBrowserEditTextProc(ControlRef browser
,
258 DataBrowserItemID item
,
259 DataBrowserPropertyID property
,
260 CFStringRef theString
,
261 Rect
*maxEditTextRect
,
262 Boolean
*shrinkToFit
);
264 static pascal Boolean
DataBrowserHitTestProc(ControlRef
WXUNUSED(browser
),
265 DataBrowserItemID
WXUNUSED(itemID
),
266 DataBrowserPropertyID
WXUNUSED(property
),
267 const Rect
*WXUNUSED(theRect
),
268 const Rect
*WXUNUSED(mouseRect
)) { return true; }
270 virtual bool ConfirmEditText(DataBrowserItemID item
,
271 DataBrowserPropertyID property
,
272 CFStringRef theString
,
273 Rect
*maxEditTextRect
,
274 Boolean
*shrinkToFit
);
278 wxClientDataType m_clientDataItemsType
;
281 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataBrowserListCtrlControl
)
284 class wxMacListCtrlEventDelegate
: public wxEvtHandler
287 wxMacListCtrlEventDelegate( wxListCtrl
* list
, int id
);
288 virtual bool ProcessEvent( wxEvent
& event
);
295 wxMacListCtrlEventDelegate::wxMacListCtrlEventDelegate( wxListCtrl
* list
, int id
)
301 bool wxMacListCtrlEventDelegate::ProcessEvent( wxEvent
& event
)
303 // even though we use a generic list ctrl underneath, make sure
304 // we present ourselves as wxListCtrl.
305 event
.SetEventObject( m_list
);
308 if ( !event
.IsKindOf( CLASSINFO( wxCommandEvent
) ) )
310 if (m_list
->HandleWindowEvent( event
))
313 return wxEvtHandler::ProcessEvent(event
);
316 //-----------------------------------------------------------------------------
317 // wxListCtrlRenameTimer (internal)
318 //-----------------------------------------------------------------------------
320 class wxListCtrlRenameTimer
: public wxTimer
326 wxListCtrlRenameTimer( wxListCtrl
*owner
);
330 //-----------------------------------------------------------------------------
331 // wxListCtrlTextCtrlWrapper: wraps a wxTextCtrl to make it work for inline editing
332 //-----------------------------------------------------------------------------
334 class wxListCtrlTextCtrlWrapper
: public wxEvtHandler
337 // NB: text must be a valid object but not Create()d yet
338 wxListCtrlTextCtrlWrapper(wxListCtrl
*owner
,
342 wxTextCtrl
*GetText() const { return m_text
; }
344 void AcceptChangesAndFinish();
347 void OnChar( wxKeyEvent
&event
);
348 void OnKeyUp( wxKeyEvent
&event
);
349 void OnKillFocus( wxFocusEvent
&event
);
351 bool AcceptChanges();
357 wxString m_startValue
;
360 bool m_aboutToFinish
;
362 DECLARE_EVENT_TABLE()
365 //-----------------------------------------------------------------------------
366 // wxListCtrlRenameTimer (internal)
367 //-----------------------------------------------------------------------------
369 wxListCtrlRenameTimer::wxListCtrlRenameTimer( wxListCtrl
*owner
)
374 void wxListCtrlRenameTimer::Notify()
376 m_owner
->OnRenameTimer();
379 //-----------------------------------------------------------------------------
380 // wxListCtrlTextCtrlWrapper (internal)
381 //-----------------------------------------------------------------------------
383 BEGIN_EVENT_TABLE(wxListCtrlTextCtrlWrapper
, wxEvtHandler
)
384 EVT_CHAR (wxListCtrlTextCtrlWrapper::OnChar
)
385 EVT_KEY_UP (wxListCtrlTextCtrlWrapper::OnKeyUp
)
386 EVT_KILL_FOCUS (wxListCtrlTextCtrlWrapper::OnKillFocus
)
389 wxListCtrlTextCtrlWrapper::wxListCtrlTextCtrlWrapper(wxListCtrl
*owner
,
392 : m_startValue(owner
->GetItemText(itemEdit
)),
393 m_itemEdited(itemEdit
)
398 m_aboutToFinish
= false;
402 owner
->GetItemRect(itemEdit
, rectLabel
);
404 m_text
->Create(owner
, wxID_ANY
, m_startValue
,
405 wxPoint(rectLabel
.x
+offset
,rectLabel
.y
),
406 wxSize(rectLabel
.width
-offset
,rectLabel
.height
));
409 m_text
->PushEventHandler(this);
412 void wxListCtrlTextCtrlWrapper::Finish()
418 m_text
->RemoveEventHandler(this);
419 m_owner
->FinishEditing(m_text
);
421 wxPendingDelete
.Append( this );
425 bool wxListCtrlTextCtrlWrapper::AcceptChanges()
427 const wxString value
= m_text
->GetValue();
429 if ( value
== m_startValue
)
430 // nothing changed, always accept
433 if ( !m_owner
->OnRenameAccept(m_itemEdited
, value
) )
434 // vetoed by the user
437 // accepted, do rename the item
438 m_owner
->SetItemText(m_itemEdited
, value
);
443 void wxListCtrlTextCtrlWrapper::AcceptChangesAndFinish()
445 m_aboutToFinish
= true;
447 // Notify the owner about the changes
450 // Even if vetoed, close the control (consistent with MSW)
454 void wxListCtrlTextCtrlWrapper::OnChar( wxKeyEvent
&event
)
456 switch ( event
.m_keyCode
)
459 AcceptChangesAndFinish();
463 m_owner
->OnRenameCancelled( m_itemEdited
);
472 void wxListCtrlTextCtrlWrapper::OnKeyUp( wxKeyEvent
&event
)
480 // auto-grow the textctrl:
481 wxSize parentSize
= m_owner
->GetSize();
482 wxPoint myPos
= m_text
->GetPosition();
483 wxSize mySize
= m_text
->GetSize();
485 m_text
->GetTextExtent(m_text
->GetValue() + _T("MM"), &sx
, &sy
);
486 if (myPos
.x
+ sx
> parentSize
.x
)
487 sx
= parentSize
.x
- myPos
.x
;
490 m_text
->SetSize(sx
, wxDefaultCoord
);
495 void wxListCtrlTextCtrlWrapper::OnKillFocus( wxFocusEvent
&event
)
497 if ( !m_finished
&& !m_aboutToFinish
)
499 if ( !AcceptChanges() )
500 m_owner
->OnRenameCancelled( m_itemEdited
);
505 // We must let the native text control handle focus
509 BEGIN_EVENT_TABLE(wxListCtrl
, wxControl
)
510 EVT_LEFT_DOWN(wxListCtrl::OnLeftDown
)
511 EVT_LEFT_DCLICK(wxListCtrl::OnDblClick
)
512 EVT_MIDDLE_DOWN(wxListCtrl::OnMiddleDown
)
513 EVT_RIGHT_DOWN(wxListCtrl::OnRightDown
)
514 EVT_CHAR(wxListCtrl::OnChar
)
517 // ============================================================================
519 // ============================================================================
521 wxMacDataBrowserListCtrlControl
* wxListCtrl::GetListPeer() const
523 return dynamic_cast<wxMacDataBrowserListCtrlControl
*> ( GetPeer() );
526 // ----------------------------------------------------------------------------
527 // wxListCtrl construction
528 // ----------------------------------------------------------------------------
530 void wxListCtrl::Init()
532 m_imageListNormal
= NULL
;
533 m_imageListSmall
= NULL
;
534 m_imageListState
= NULL
;
536 // keep track of if we created our own image lists, or if they were assigned
538 m_ownsImageListNormal
= m_ownsImageListSmall
= m_ownsImageListState
= false;
542 m_genericImpl
= NULL
;
544 m_compareFunc
= NULL
;
545 m_compareFuncData
= 0;
546 m_colsInfo
= wxColumnList();
547 m_textColor
= wxNullColour
;
548 m_bgColor
= wxNullColour
;
549 m_textctrlWrapper
= NULL
;
551 m_renameTimer
= new wxListCtrlRenameTimer( this );
554 class wxGenericListCtrlHook
: public wxGenericListCtrl
557 wxGenericListCtrlHook(wxListCtrl
* parent
,
562 const wxValidator
& validator
,
563 const wxString
& name
)
564 : wxGenericListCtrl(parent
, id
, pos
, size
, style
, validator
, name
),
565 m_nativeListCtrl(parent
)
570 virtual wxListItemAttr
* OnGetItemAttr(long item
) const
572 return m_nativeListCtrl
->OnGetItemAttr(item
);
575 virtual int OnGetItemImage(long item
) const
577 return m_nativeListCtrl
->OnGetItemImage(item
);
580 virtual int OnGetItemColumnImage(long item
, long column
) const
582 return m_nativeListCtrl
->OnGetItemColumnImage(item
, column
);
585 virtual wxString
OnGetItemText(long item
, long column
) const
587 return m_nativeListCtrl
->OnGetItemText(item
, column
);
590 wxListCtrl
* m_nativeListCtrl
;
594 void wxListCtrl::OnLeftDown(wxMouseEvent
& event
)
596 if ( m_textctrlWrapper
)
599 m_textctrlWrapper
->AcceptChangesAndFinish();
603 long current
= HitTest(event
.GetPosition(), hitResult
);
604 if ((current
== m_current
) &&
605 (hitResult
== wxLIST_HITTEST_ONITEM
) &&
606 HasFlag(wxLC_EDIT_LABELS
) )
608 m_renameTimer
->Start( 100, true );
617 void wxListCtrl::OnDblClick(wxMouseEvent
& event
)
623 #if wxABI_VERSION >= 20801
624 void wxListCtrl::OnRightDown(wxMouseEvent
& event
)
627 FireMouseEvent(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK
, event
.GetPosition());
631 void wxListCtrl::OnMiddleDown(wxMouseEvent
& event
)
634 FireMouseEvent(wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK
, event
.GetPosition());
638 void wxListCtrl::FireMouseEvent(wxEventType eventType
, wxPoint position
)
640 wxListEvent
le( eventType
, GetId() );
641 le
.SetEventObject(this);
642 le
.m_pointDrag
= position
;
646 long item
= HitTest(position
, flags
);
647 if (flags
& wxLIST_HITTEST_ONITEM
)
649 le
.m_itemIndex
= item
;
650 le
.m_item
.m_itemId
= item
;
652 HandleWindowEvent(le
);
656 void wxListCtrl::OnChar(wxKeyEvent
& event
)
662 wxListEvent
le( wxEVT_COMMAND_LIST_KEY_DOWN
, GetId() );
663 le
.SetEventObject(this);
664 le
.m_code
= event
.GetKeyCode();
669 // if m_current isn't set, check if there's been a selection
670 // made before continuing
671 m_current
= GetNextItem(-1, wxLIST_NEXT_BELOW
, wxLIST_STATE_SELECTED
);
674 // We need to determine m_current ourselves when navigation keys
675 // are used. Note that PAGEUP and PAGEDOWN do not alter the current
676 // item on native Mac ListCtrl, so we only handle up and down keys.
677 switch ( event
.GetKeyCode() )
688 if ( m_current
< GetItemCount() - 1 )
691 m_current
= GetItemCount() - 1;
698 le
.m_itemIndex
= m_current
;
699 le
.m_item
.m_itemId
= m_current
;
701 HandleWindowEvent(le
);
708 bool wxListCtrl::Create(wxWindow
*parent
,
713 const wxValidator
& validator
,
714 const wxString
& name
)
717 // for now, we'll always use the generic list control for ICON and LIST views,
718 // because they dynamically change the number of columns on resize.
719 // Also, allow the user to set it to use the list ctrl as well.
720 if ( (wxSystemOptions::HasOption( wxMAC_ALWAYS_USE_GENERIC_LISTCTRL
)
721 && (wxSystemOptions::GetOptionInt( wxMAC_ALWAYS_USE_GENERIC_LISTCTRL
) == 1)) ||
722 (style
& wxLC_ICON
) || (style
& wxLC_SMALL_ICON
) || (style
& wxLC_LIST
) )
724 m_macIsUserPane
= true;
726 long paneStyle
= style
;
727 paneStyle
&= ~wxSIMPLE_BORDER
;
728 paneStyle
&= ~wxDOUBLE_BORDER
;
729 paneStyle
&= ~wxSUNKEN_BORDER
;
730 paneStyle
&= ~wxRAISED_BORDER
;
731 paneStyle
&= ~wxSTATIC_BORDER
;
732 if ( !wxWindow::Create(parent
, id
, pos
, size
, paneStyle
| wxNO_BORDER
, name
) )
735 // since the generic control is a child, make sure we position it at 0, 0
736 m_genericImpl
= new wxGenericListCtrlHook(this, id
, wxPoint(0, 0), size
, style
, validator
, name
);
737 m_genericImpl
->PushEventHandler( new wxMacListCtrlEventDelegate( this, GetId() ) );
743 m_macIsUserPane
= false;
744 if ( !wxWindow::Create(parent
, id
, pos
, size
, style
& ~(wxHSCROLL
| wxVSCROLL
), name
) )
746 m_dbImpl
= new wxMacDataBrowserListCtrlControl( this, pos
, size
, style
);
749 MacPostControlCreate( pos
, size
);
751 InstallControlEventHandler( m_peer
->GetControlRef() , GetwxMacListCtrlEventHandlerUPP(),
752 GetEventTypeCount(eventList
), eventList
, this,
753 (EventHandlerRef
*)&m_macListCtrlEventHandler
);
759 wxListCtrl::~wxListCtrl()
763 m_genericImpl
->PopEventHandler(/* deleteHandler = */ true);
766 if (m_ownsImageListNormal
)
767 delete m_imageListNormal
;
768 if (m_ownsImageListSmall
)
769 delete m_imageListSmall
;
770 if (m_ownsImageListState
)
771 delete m_imageListState
;
773 delete m_renameTimer
;
775 WX_CLEAR_LIST(wxColumnList
, m_colsInfo
);
780 wxListCtrl::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
782 wxVisualAttributes attr
;
784 attr
.colFg
= wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT
);
785 attr
.colBg
= wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOX
);
786 #if wxOSX_USE_ATSU_TEXT
787 attr
.font
.MacCreateFromThemeFont( kThemeViewsFont
) ;
789 attr
.font
.MacCreateFromUIFont( kCTFontViewsFontType
) ;
795 // ----------------------------------------------------------------------------
796 // set/get/change style
797 // ----------------------------------------------------------------------------
799 // Add or remove a single window style
800 void wxListCtrl::SetSingleStyle(long style
, bool add
)
802 long flag
= GetWindowStyleFlag();
804 // Get rid of conflicting styles
807 if ( style
& wxLC_MASK_TYPE
)
808 flag
= flag
& ~wxLC_MASK_TYPE
;
809 if ( style
& wxLC_MASK_ALIGN
)
810 flag
= flag
& ~wxLC_MASK_ALIGN
;
811 if ( style
& wxLC_MASK_SORT
)
812 flag
= flag
& ~wxLC_MASK_SORT
;
820 SetWindowStyleFlag(flag
);
823 // Set the whole window style
824 void wxListCtrl::SetWindowStyleFlag(long flag
)
826 if ( flag
!= m_windowStyle
)
828 m_windowStyle
= flag
;
832 m_genericImpl
->SetWindowStyleFlag(flag
);
839 void wxListCtrl::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
841 wxControl::DoSetSize(x
, y
, width
, height
, sizeFlags
);
844 m_genericImpl
->SetSize(0, 0, width
, height
, sizeFlags
);
846 // determine if we need a horizontal scrollbar, and add it if so
850 for (int column
= 0; column
< GetColumnCount(); column
++)
852 totalWidth
+= m_dbImpl
->GetColumnWidth( column
);
855 if ( !(m_dbImpl
->GetFlags() & wxHSCROLL
) )
857 Boolean vertScrollBar
;
858 GetDataBrowserHasScrollBars( m_dbImpl
->GetControlRef(), NULL
, &vertScrollBar
);
859 if (totalWidth
> width
)
860 SetDataBrowserHasScrollBars( m_dbImpl
->GetControlRef(), true, vertScrollBar
);
862 SetDataBrowserHasScrollBars( m_dbImpl
->GetControlRef(), false, vertScrollBar
);
867 wxSize
wxListCtrl::DoGetBestSize() const
869 return wxWindow::DoGetBestSize();
872 bool wxListCtrl::SetFont(const wxFont
& font
)
875 rv
= wxControl::SetFont(font
);
877 rv
= m_genericImpl
->SetFont(font
);
881 bool wxListCtrl::SetForegroundColour(const wxColour
& colour
)
885 rv
= m_genericImpl
->SetForegroundColour(colour
);
887 SetTextColour(colour
);
891 bool wxListCtrl::SetBackgroundColour(const wxColour
& colour
)
895 rv
= m_genericImpl
->SetBackgroundColour(colour
);
901 wxColour
wxListCtrl::GetBackgroundColour() const
904 return m_genericImpl
->GetBackgroundColour();
911 // ----------------------------------------------------------------------------
913 // ----------------------------------------------------------------------------
915 // Gets information about this column
916 bool wxListCtrl::GetColumn(int col
, wxListItem
& item
) const
919 return m_genericImpl
->GetColumn(col
, item
);
925 wxColumnList::compatibility_iterator node
= m_colsInfo
.Item( col
);
926 wxASSERT_MSG( node
, _T("invalid column index in wxMacListCtrlItem") );
927 wxListItem
* column
= node
->GetData();
929 long mask
= column
->GetMask();
930 if (mask
& wxLIST_MASK_TEXT
)
931 item
.SetText(column
->GetText());
932 if (mask
& wxLIST_MASK_DATA
)
933 item
.SetData(column
->GetData());
934 if (mask
& wxLIST_MASK_IMAGE
)
935 item
.SetImage(column
->GetImage());
936 if (mask
& wxLIST_MASK_STATE
)
937 item
.SetState(column
->GetState());
938 if (mask
& wxLIST_MASK_FORMAT
)
939 item
.SetAlign(column
->GetAlign());
940 if (mask
& wxLIST_MASK_WIDTH
)
941 item
.SetWidth(column
->GetWidth());
947 // Sets information about this column
948 bool wxListCtrl::SetColumn(int col
, wxListItem
& item
)
951 return m_genericImpl
->SetColumn(col
, item
);
955 wxASSERT_MSG( col
< (int)m_colsInfo
.GetCount(), _T("invalid column index in wxMacListCtrlItem") );
957 long mask
= item
.GetMask();
960 GetColumn( col
, listItem
);
962 if (mask
& wxLIST_MASK_TEXT
)
963 listItem
.SetText(item
.GetText());
964 if (mask
& wxLIST_MASK_DATA
)
965 listItem
.SetData(item
.GetData());
966 if (mask
& wxLIST_MASK_IMAGE
)
967 listItem
.SetImage(item
.GetImage());
968 if (mask
& wxLIST_MASK_STATE
)
969 listItem
.SetState(item
.GetState());
970 if (mask
& wxLIST_MASK_FORMAT
)
971 listItem
.SetAlign(item
.GetAlign());
972 if (mask
& wxLIST_MASK_WIDTH
)
973 listItem
.SetWidth(item
.GetWidth());
976 // change the appearance in the databrowser.
977 DataBrowserListViewHeaderDesc columnDesc
;
978 columnDesc
.version
=kDataBrowserListViewLatestHeaderDesc
;
980 DataBrowserTableViewColumnID id
= 0;
981 verify_noerr( m_dbImpl
->GetColumnIDFromIndex( col
, &id
) );
982 verify_noerr( m_dbImpl
->GetHeaderDesc( id
, &columnDesc
) );
985 if (item.GetMask() & wxLIST_MASK_TEXT)
989 enc = GetFont().GetEncoding();
991 enc = wxLocale::GetSystemEncoding();
992 wxCFStringRef cfTitle;
993 cfTitle.Assign( item.GetText() , enc );
994 if(columnDesc.titleString)
995 CFRelease(columnDesc.titleString);
996 columnDesc.titleString = cfTitle;
1000 if (item
.GetMask() & wxLIST_MASK_IMAGE
&& item
.GetImage() != -1 )
1002 wxImageList
* imageList
= GetImageList(wxIMAGE_LIST_SMALL
);
1003 if (imageList
&& imageList
->GetImageCount() > 0 )
1005 wxBitmap bmp
= imageList
->GetBitmap( item
.GetImage() );
1006 IconRef icon
= bmp
.GetIconRef();
1007 columnDesc
.btnContentInfo
.u
.iconRef
= icon
;
1008 columnDesc
.btnContentInfo
.contentType
= kControlContentIconRef
;
1012 verify_noerr( m_dbImpl
->SetHeaderDesc( id
, &columnDesc
) );
1018 int wxListCtrl::GetColumnCount() const
1021 return m_genericImpl
->GetColumnCount();
1026 m_dbImpl
->GetColumnCount(&count
);
1033 // Gets the column width
1034 int wxListCtrl::GetColumnWidth(int col
) const
1037 return m_genericImpl
->GetColumnWidth(col
);
1041 return m_dbImpl
->GetColumnWidth(col
);
1047 // Sets the column width
1048 bool wxListCtrl::SetColumnWidth(int col
, int width
)
1051 return m_genericImpl
->SetColumnWidth(col
, width
);
1055 if ( width
== wxLIST_AUTOSIZE_USEHEADER
)
1057 width
= 150; // FIXME
1062 for (int column
= 0; column
< GetColumnCount(); column
++)
1065 GetColumn(column
, colInfo
);
1067 colInfo
.SetWidth(width
);
1068 SetColumn(column
, colInfo
);
1070 const int mywidth
= (width
== wxLIST_AUTOSIZE
)
1071 ? CalcColumnAutoWidth(column
) : width
;
1072 m_dbImpl
->SetColumnWidth(column
, mywidth
);
1077 if ( width
== wxLIST_AUTOSIZE
)
1078 width
= CalcColumnAutoWidth(col
);
1081 GetColumn(col
, colInfo
);
1083 colInfo
.SetWidth(width
);
1084 SetColumn(col
, colInfo
);
1085 m_dbImpl
->SetColumnWidth(col
, width
);
1093 // Gets the number of items that can fit vertically in the
1094 // visible area of the list control (list or report view)
1095 // or the total number of items in the list control (icon
1096 // or small icon view)
1097 int wxListCtrl::GetCountPerPage() const
1100 return m_genericImpl
->GetCountPerPage();
1105 m_dbImpl
->GetDefaultRowHeight( &height
);
1107 return GetClientSize().y
/ height
;
1113 // Gets the edit control for editing labels.
1114 wxTextCtrl
* wxListCtrl::GetEditControl() const
1117 return m_genericImpl
->GetEditControl();
1122 // Gets information about the item
1123 bool wxListCtrl::GetItem(wxListItem
& info
) const
1126 return m_genericImpl
->GetItem(info
);
1132 if (info
.m_itemId
>= 0 && info
.m_itemId
< GetItemCount())
1134 m_dbImpl
->MacGetColumnInfo(info
.m_itemId
, info
.m_col
, info
);
1135 if (info
.GetMask() & wxLIST_MASK_STATE
)
1137 DataBrowserItemID id
= (DataBrowserItemID
)m_dbImpl
->GetItemFromLine(info
.m_itemId
);
1138 if (IsDataBrowserItemSelected( m_dbImpl
->GetControlRef(), id
))
1139 info
.SetState(info
.GetState() | wxLIST_STATE_SELECTED
);
1145 if (info
.m_itemId
>= 0 && info
.m_itemId
< GetItemCount())
1147 info
.SetText( OnGetItemText(info
.m_itemId
, info
.m_col
) );
1148 info
.SetImage( OnGetItemColumnImage(info
.m_itemId
, info
.m_col
) );
1149 if (info
.GetMask() & wxLIST_MASK_STATE
)
1151 if (IsDataBrowserItemSelected( m_dbImpl
->GetControlRef(), info
.m_itemId
+1 ))
1152 info
.SetState(info
.GetState() | wxLIST_STATE_SELECTED
);
1155 wxListItemAttr
* attrs
= OnGetItemAttr( info
.m_itemId
);
1158 info
.SetFont( attrs
->GetFont() );
1159 info
.SetBackgroundColour( attrs
->GetBackgroundColour() );
1160 info
.SetTextColour( attrs
->GetTextColour() );
1165 bool success
= true;
1169 // Sets information about the item
1170 bool wxListCtrl::SetItem(wxListItem
& info
)
1173 return m_genericImpl
->SetItem(info
);
1176 m_dbImpl
->MacSetColumnInfo( info
.m_itemId
, info
.m_col
, &info
);
1181 long wxListCtrl::SetItem(long index
, int col
, const wxString
& label
, int imageId
)
1184 return m_genericImpl
->SetItem(index
, col
, label
, imageId
);
1187 info
.m_text
= label
;
1188 info
.m_mask
= wxLIST_MASK_TEXT
;
1189 info
.m_itemId
= index
;
1193 info
.m_image
= imageId
;
1194 info
.m_mask
|= wxLIST_MASK_IMAGE
;
1196 return SetItem(info
);
1200 // Gets the item state
1201 int wxListCtrl::GetItemState(long item
, long stateMask
) const
1204 return m_genericImpl
->GetItemState(item
, stateMask
);
1208 if ( HasFlag(wxLC_VIRTUAL
) )
1210 if (stateMask
== wxLIST_STATE_SELECTED
)
1212 if (IsDataBrowserItemSelected( m_dbImpl
->GetControlRef(), item
+1 ))
1213 return wxLIST_STATE_SELECTED
;
1222 info
.m_mask
= wxLIST_MASK_STATE
;
1223 info
.m_stateMask
= stateMask
;
1224 info
.m_itemId
= item
;
1229 return info
.m_state
;
1236 // Sets the item state
1237 bool wxListCtrl::SetItemState(long item
, long state
, long stateMask
)
1240 return m_genericImpl
->SetItemState(item
, state
, stateMask
);
1244 DataBrowserSetOption option
= kDataBrowserItemsAdd
;
1245 if ( (stateMask
& wxLIST_STATE_SELECTED
) && state
== 0 )
1246 option
= kDataBrowserItemsRemove
;
1250 if ( HasFlag(wxLC_VIRTUAL
) )
1252 wxMacDataItemBrowserSelectionSuppressor
suppressor(m_dbImpl
);
1253 m_dbImpl
->SetSelectedAllItems(option
);
1257 for(int i
= 0; i
< GetItemCount();i
++)
1261 info
.m_mask
= wxLIST_MASK_STATE
;
1262 info
.m_stateMask
= stateMask
;
1263 info
.m_state
= state
;
1270 if ( HasFlag(wxLC_VIRTUAL
) )
1272 long itemID
= item
+1;
1273 bool isSelected
= IsDataBrowserItemSelected(m_dbImpl
->GetControlRef(), (DataBrowserItemID
)itemID
);
1274 bool isSelectedState
= (state
== wxLIST_STATE_SELECTED
);
1276 // toggle the selection state if wxListInfo state and actual state don't match.
1277 if ( (stateMask
& wxLIST_STATE_SELECTED
) && isSelected
!= isSelectedState
)
1279 SetDataBrowserSelectedItems(m_dbImpl
->GetControlRef(), 1, (DataBrowserItemID
*)&itemID
, option
);
1285 info
.m_itemId
= item
;
1286 info
.m_mask
= wxLIST_MASK_STATE
;
1287 info
.m_stateMask
= stateMask
;
1288 info
.m_state
= state
;
1289 return SetItem(info
);
1296 // Sets the item image
1297 bool wxListCtrl::SetItemImage(long item
, int image
, int WXUNUSED(selImage
))
1299 return SetItemColumnImage(item
, 0, image
);
1302 // Sets the item image
1303 bool wxListCtrl::SetItemColumnImage(long item
, long column
, int image
)
1306 return m_genericImpl
->SetItemColumnImage(item
, column
, image
);
1310 info
.m_mask
= wxLIST_MASK_IMAGE
;
1311 info
.m_image
= image
;
1312 info
.m_itemId
= item
;
1313 info
.m_col
= column
;
1315 return SetItem(info
);
1318 // Gets the item text
1319 wxString
wxListCtrl::GetItemText(long item
) const
1322 return m_genericImpl
->GetItemText(item
);
1326 info
.m_mask
= wxLIST_MASK_TEXT
;
1327 info
.m_itemId
= item
;
1330 return wxEmptyString
;
1334 // Sets the item text
1335 void wxListCtrl::SetItemText(long item
, const wxString
& str
)
1338 return m_genericImpl
->SetItemText(item
, str
);
1342 info
.m_mask
= wxLIST_MASK_TEXT
;
1343 info
.m_itemId
= item
;
1349 // Gets the item data
1350 long wxListCtrl::GetItemData(long item
) const
1353 return m_genericImpl
->GetItemData(item
);
1357 info
.m_mask
= wxLIST_MASK_DATA
;
1358 info
.m_itemId
= item
;
1365 // Sets the item data
1366 bool wxListCtrl::SetItemPtrData(long item
, wxUIntPtr data
)
1369 return m_genericImpl
->SetItemData(item
, data
);
1373 info
.m_mask
= wxLIST_MASK_DATA
;
1374 info
.m_itemId
= item
;
1377 return SetItem(info
);
1380 wxRect
wxListCtrl::GetViewRect() const
1382 wxASSERT_MSG( !HasFlag(wxLC_REPORT
| wxLC_LIST
),
1383 _T("wxListCtrl::GetViewRect() only works in icon mode") );
1386 return m_genericImpl
->GetViewRect();
1392 bool wxListCtrl::GetSubItemRect( long item
, long subItem
, wxRect
& rect
, int code
) const
1395 return m_genericImpl
->GetItemRect(item
, rect
, code
);
1397 // TODO: implement for DataBrowser implementation
1401 // Gets the item rectangle
1402 bool wxListCtrl::GetItemRect(long item
, wxRect
& rect
, int code
) const
1405 return m_genericImpl
->GetItemRect(item
, rect
, code
);
1410 DataBrowserItemID id
;
1412 DataBrowserTableViewColumnID col
= 0;
1413 verify_noerr( m_dbImpl
->GetColumnIDFromIndex( 0, &col
) );
1416 DataBrowserPropertyPart part
= kDataBrowserPropertyEnclosingPart
;
1417 if ( code
== wxLIST_RECT_LABEL
)
1418 part
= kDataBrowserPropertyTextPart
;
1419 else if ( code
== wxLIST_RECT_ICON
)
1420 part
= kDataBrowserPropertyIconPart
;
1422 if ( !(GetWindowStyleFlag() & wxLC_VIRTUAL
) )
1424 wxMacDataItem
* thisItem
= m_dbImpl
->GetItemFromLine(item
);
1425 id
= (DataBrowserItemID
) thisItem
;
1430 GetDataBrowserItemPartBounds( m_dbImpl
->GetControlRef(), id
, col
, part
, &bounds
);
1432 rect
.x
= bounds
.left
;
1433 rect
.y
= bounds
.top
;
1434 rect
.width
= bounds
.right
- bounds
.left
; //GetClientSize().x; // we need the width of the whole row, not just the item.
1435 rect
.height
= bounds
.bottom
- bounds
.top
;
1436 //fprintf("id = %d, bounds = %d, %d, %d, %d\n", id, rect.x, rect.y, rect.width, rect.height);
1441 // Gets the item position
1442 bool wxListCtrl::GetItemPosition(long item
, wxPoint
& pos
) const
1445 return m_genericImpl
->GetItemPosition(item
, pos
);
1447 bool success
= false;
1452 GetItemRect(item
, itemRect
);
1453 pos
= itemRect
.GetPosition();
1460 // Sets the item position.
1461 bool wxListCtrl::SetItemPosition(long item
, const wxPoint
& pos
)
1464 return m_genericImpl
->SetItemPosition(item
, pos
);
1469 // Gets the number of items in the list control
1470 int wxListCtrl::GetItemCount() const
1473 return m_genericImpl
->GetItemCount();
1476 return m_dbImpl
->MacGetCount();
1481 void wxListCtrl::SetItemSpacing( int spacing
, bool isSmall
)
1484 m_genericImpl
->SetItemSpacing(spacing
, isSmall
);
1487 wxSize
wxListCtrl::GetItemSpacing() const
1490 return m_genericImpl
->GetItemSpacing();
1492 return wxSize(0, 0);
1495 void wxListCtrl::SetItemTextColour( long item
, const wxColour
&col
)
1499 m_genericImpl
->SetItemTextColour(item
, col
);
1504 info
.m_itemId
= item
;
1505 info
.SetTextColour( col
);
1509 wxColour
wxListCtrl::GetItemTextColour( long item
) const
1512 return m_genericImpl
->GetItemTextColour(item
);
1518 return info
.GetTextColour();
1520 return wxNullColour
;
1523 void wxListCtrl::SetItemBackgroundColour( long item
, const wxColour
&col
)
1527 m_genericImpl
->SetItemBackgroundColour(item
, col
);
1532 info
.m_itemId
= item
;
1533 info
.SetBackgroundColour( col
);
1537 wxColour
wxListCtrl::GetItemBackgroundColour( long item
) const
1540 return m_genericImpl
->GetItemBackgroundColour(item
);
1546 return info
.GetBackgroundColour();
1548 return wxNullColour
;
1551 void wxListCtrl::SetItemFont( long item
, const wxFont
&f
)
1555 m_genericImpl
->SetItemFont(item
, f
);
1560 info
.m_itemId
= item
;
1565 wxFont
wxListCtrl::GetItemFont( long item
) const
1568 return m_genericImpl
->GetItemFont(item
);
1574 return info
.GetFont();
1580 // Gets the number of selected items in the list control
1581 int wxListCtrl::GetSelectedItemCount() const
1584 return m_genericImpl
->GetSelectedItemCount();
1587 return m_dbImpl
->GetSelectedItemCount(NULL
, true);
1592 // Gets the text colour of the listview
1593 wxColour
wxListCtrl::GetTextColour() const
1596 return m_genericImpl
->GetTextColour();
1598 // TODO: we need owner drawn list items to customize text color.
1602 return wxNullColour
;
1605 // Sets the text colour of the listview
1606 void wxListCtrl::SetTextColour(const wxColour
& col
)
1610 m_genericImpl
->SetTextColour(col
);
1618 // Gets the index of the topmost visible item when in
1619 // list or report view
1620 long wxListCtrl::GetTopItem() const
1623 return m_genericImpl
->GetTopItem();
1628 long item
= HitTest( wxPoint(1, 1), flags
);
1629 if (flags
== wxLIST_HITTEST_ONITEM
)
1636 // Searches for an item, starting from 'item'.
1637 // 'geometry' is one of
1638 // wxLIST_NEXT_ABOVE/ALL/BELOW/LEFT/RIGHT.
1639 // 'state' is a state bit flag, one or more of
1640 // wxLIST_STATE_DROPHILITED/FOCUSED/SELECTED/CUT.
1641 // item can be -1 to find the first item that matches the
1643 // Returns the item or -1 if unsuccessful.
1644 long wxListCtrl::GetNextItem(long item
, int geom
, int state
) const
1647 return m_genericImpl
->GetNextItem(item
, geom
, state
);
1649 // TODO: implement all geometry and state options?
1652 if ( geom
== wxLIST_NEXT_ALL
|| geom
== wxLIST_NEXT_BELOW
)
1654 long count
= m_dbImpl
->MacGetCount() ;
1655 for ( long line
= item
+ 1 ; line
< count
; line
++ )
1657 DataBrowserItemID id
= line
+ 1;
1659 id
= (DataBrowserItemID
)m_dbImpl
->GetItemFromLine(line
);
1661 if ( (state
== wxLIST_STATE_DONTCARE
) )
1664 if ( (state
& wxLIST_STATE_SELECTED
) && IsDataBrowserItemSelected(m_dbImpl
->GetControlRef(), id
) )
1669 if ( geom
== wxLIST_NEXT_ABOVE
)
1673 item2
= m_dbImpl
->MacGetCount();
1675 for ( long line
= item2
- 1 ; line
>= 0; line
-- )
1677 DataBrowserItemID id
= line
+ 1;
1679 id
= (DataBrowserItemID
)m_dbImpl
->GetItemFromLine(line
);
1681 if ( (state
== wxLIST_STATE_DONTCARE
) )
1684 if ( (state
& wxLIST_STATE_SELECTED
) && IsDataBrowserItemSelected(m_dbImpl
->GetControlRef(), id
) )
1694 wxImageList
*wxListCtrl::GetImageList(int which
) const
1697 return m_genericImpl
->GetImageList(which
);
1699 if ( which
== wxIMAGE_LIST_NORMAL
)
1701 return m_imageListNormal
;
1703 else if ( which
== wxIMAGE_LIST_SMALL
)
1705 return m_imageListSmall
;
1707 else if ( which
== wxIMAGE_LIST_STATE
)
1709 return m_imageListState
;
1714 void wxListCtrl::SetImageList(wxImageList
*imageList
, int which
)
1718 m_genericImpl
->SetImageList(imageList
, which
);
1722 if ( which
== wxIMAGE_LIST_NORMAL
)
1724 if (m_ownsImageListNormal
) delete m_imageListNormal
;
1725 m_imageListNormal
= imageList
;
1726 m_ownsImageListNormal
= false;
1728 else if ( which
== wxIMAGE_LIST_SMALL
)
1730 if (m_ownsImageListSmall
) delete m_imageListSmall
;
1731 m_imageListSmall
= imageList
;
1732 m_ownsImageListSmall
= false;
1734 else if ( which
== wxIMAGE_LIST_STATE
)
1736 if (m_ownsImageListState
) delete m_imageListState
;
1737 m_imageListState
= imageList
;
1738 m_ownsImageListState
= false;
1742 void wxListCtrl::AssignImageList(wxImageList
*imageList
, int which
)
1746 m_genericImpl
->AssignImageList(imageList
, which
);
1750 SetImageList(imageList
, which
);
1751 if ( which
== wxIMAGE_LIST_NORMAL
)
1752 m_ownsImageListNormal
= true;
1753 else if ( which
== wxIMAGE_LIST_SMALL
)
1754 m_ownsImageListSmall
= true;
1755 else if ( which
== wxIMAGE_LIST_STATE
)
1756 m_ownsImageListState
= true;
1759 // ----------------------------------------------------------------------------
1761 // ----------------------------------------------------------------------------
1763 // Arranges the items
1764 bool wxListCtrl::Arrange(int flag
)
1767 return m_genericImpl
->Arrange(flag
);
1772 bool wxListCtrl::DeleteItem(long item
)
1775 return m_genericImpl
->DeleteItem(item
);
1779 m_dbImpl
->MacDelete(item
);
1780 wxListEvent
event( wxEVT_COMMAND_LIST_DELETE_ITEM
, GetId() );
1781 event
.SetEventObject( this );
1782 event
.m_itemIndex
= item
;
1783 HandleWindowEvent( event
);
1789 // Deletes all items
1790 bool wxListCtrl::DeleteAllItems()
1793 return m_genericImpl
->DeleteAllItems();
1797 m_dbImpl
->MacClear();
1798 wxListEvent
event( wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS
, GetId() );
1799 event
.SetEventObject( this );
1800 HandleWindowEvent( event
);
1805 // Deletes all items
1806 bool wxListCtrl::DeleteAllColumns()
1809 return m_genericImpl
->DeleteAllColumns();
1814 m_dbImpl
->GetColumnCount(&cols
);
1815 for (UInt32 col
= 0; col
< cols
; col
++)
1825 bool wxListCtrl::DeleteColumn(int col
)
1828 return m_genericImpl
->DeleteColumn(col
);
1832 OSStatus err
= m_dbImpl
->RemoveColumn(col
);
1833 return err
== noErr
;
1839 // Clears items, and columns if there are any.
1840 void wxListCtrl::ClearAll()
1844 m_genericImpl
->ClearAll();
1855 wxTextCtrl
* wxListCtrl::EditLabel(long item
, wxClassInfo
* textControlClass
)
1858 return m_genericImpl
->EditLabel(item
, textControlClass
);
1862 wxCHECK_MSG( (item
>= 0) && ((long)item
< GetItemCount()), NULL
,
1863 wxT("wrong index in wxListCtrl::EditLabel()") );
1865 wxASSERT_MSG( textControlClass
->IsKindOf(CLASSINFO(wxTextCtrl
)),
1866 wxT("EditLabel() needs a text control") );
1868 wxListEvent
le( wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
, GetParent()->GetId() );
1869 le
.SetEventObject( this );
1870 le
.m_itemIndex
= item
;
1872 GetItem( le
.m_item
);
1874 if ( GetParent()->HandleWindowEvent( le
) && !le
.IsAllowed() )
1876 // vetoed by user code
1880 wxTextCtrl
* const text
= (wxTextCtrl
*)textControlClass
->CreateObject();
1881 m_textctrlWrapper
= new wxListCtrlTextCtrlWrapper(this, text
, item
);
1882 return m_textctrlWrapper
->GetText();
1887 // End label editing, optionally cancelling the edit
1888 bool wxListCtrl::EndEditLabel(bool WXUNUSED(cancel
))
1890 // TODO: generic impl. doesn't have this method - is it needed for us?
1892 return true; // m_genericImpl->EndEditLabel(cancel);
1896 DataBrowserTableViewColumnID id
= 0;
1897 verify_noerr( m_dbImpl
->GetColumnIDFromIndex( 0, &id
) );
1898 verify_noerr( SetDataBrowserEditItem(m_dbImpl
->GetControlRef(), kDataBrowserNoItem
, id
) );
1903 // Ensures this item is visible
1904 bool wxListCtrl::EnsureVisible(long item
)
1907 return m_genericImpl
->EnsureVisible(item
);
1911 wxMacDataItem
* dataItem
= m_dbImpl
->GetItemFromLine(item
);
1912 m_dbImpl
->RevealItem(dataItem
, kDataBrowserRevealWithoutSelecting
);
1918 // Find an item whose label matches this string, starting from the item after 'start'
1919 // or the beginning if 'start' is -1.
1920 long wxListCtrl::FindItem(long start
, const wxString
& str
, bool partial
)
1923 return m_genericImpl
->FindItem(start
, str
, partial
);
1925 wxString str_upper
= str
.Upper();
1930 long count
= GetItemCount();
1934 wxString line_upper
= GetItemText(idx
).Upper();
1937 if (line_upper
== str_upper
)
1942 if (line_upper
.find(str_upper
) == 0)
1952 // Find an item whose data matches this data, starting from the item after 'start'
1953 // or the beginning if 'start' is -1.
1954 long wxListCtrl::FindItem(long start
, long data
)
1957 return m_genericImpl
->FindItem(start
, data
);
1962 long count
= GetItemCount();
1966 if (GetItemData(idx
) == data
)
1974 // Find an item nearest this position in the specified direction, starting from
1975 // the item after 'start' or the beginning if 'start' is -1.
1976 long wxListCtrl::FindItem(long start
, const wxPoint
& pt
, int direction
)
1979 return m_genericImpl
->FindItem(start
, pt
, direction
);
1983 // Determines which item (if any) is at the specified point,
1984 // giving details in 'flags' (see wxLIST_HITTEST_... flags above)
1986 wxListCtrl::HitTest(const wxPoint
& point
, int& flags
, long *ptrSubItem
) const
1989 return m_genericImpl
->HitTest(point
, flags
, ptrSubItem
);
1991 flags
= wxLIST_HITTEST_NOWHERE
;
1994 int colHeaderHeight
= 22; // TODO: Find a way to get this value from the db control?
1995 UInt16 rowHeight
= 0;
1996 m_dbImpl
->GetDefaultRowHeight(&rowHeight
);
1999 // get the actual row by taking scroll position into account
2000 UInt32 offsetX
, offsetY
;
2001 m_dbImpl
->GetScrollPosition( &offsetY
, &offsetX
);
2004 if ( !(GetWindowStyleFlag() & wxLC_NO_HEADER
) )
2005 y
-= colHeaderHeight
;
2010 int row
= y
/ rowHeight
;
2011 DataBrowserItemID id
;
2012 m_dbImpl
->GetItemID( (DataBrowserTableViewRowIndex
) row
, &id
);
2014 // TODO: Use GetDataBrowserItemPartBounds to return if we are in icon or label
2015 if ( !(GetWindowStyleFlag() & wxLC_VIRTUAL
) )
2017 wxMacListCtrlItem
* lcItem
;
2018 lcItem
= (wxMacListCtrlItem
*) id
;
2021 flags
= wxLIST_HITTEST_ONITEM
;
2027 if (row
< GetItemCount() )
2029 flags
= wxLIST_HITTEST_ONITEM
;
2038 int wxListCtrl::GetScrollPos(int orient
) const
2041 return m_genericImpl
->GetScrollPos(orient
);
2045 UInt32 offsetX
, offsetY
;
2046 m_dbImpl
->GetScrollPosition( &offsetY
, &offsetX
);
2047 if ( orient
== wxHORIZONTAL
)
2056 // Inserts an item, returning the index of the new item if successful,
2058 long wxListCtrl::InsertItem(wxListItem
& info
)
2060 wxASSERT_MSG( !IsVirtual(), _T("can't be used with virtual controls") );
2063 return m_genericImpl
->InsertItem(info
);
2065 if (m_dbImpl
&& !IsVirtual())
2067 int count
= GetItemCount();
2069 if (info
.m_itemId
> count
)
2070 info
.m_itemId
= count
;
2072 m_dbImpl
->MacInsertItem(info
.m_itemId
, &info
);
2074 wxListEvent
event( wxEVT_COMMAND_LIST_INSERT_ITEM
, GetId() );
2075 event
.SetEventObject( this );
2076 event
.m_itemIndex
= info
.m_itemId
;
2077 HandleWindowEvent( event
);
2078 return info
.m_itemId
;
2083 long wxListCtrl::InsertItem(long index
, const wxString
& label
)
2086 return m_genericImpl
->InsertItem(index
, label
);
2089 info
.m_text
= label
;
2090 info
.m_mask
= wxLIST_MASK_TEXT
;
2091 info
.m_itemId
= index
;
2092 return InsertItem(info
);
2095 // Inserts an image item
2096 long wxListCtrl::InsertItem(long index
, int imageIndex
)
2099 return m_genericImpl
->InsertItem(index
, imageIndex
);
2102 info
.m_image
= imageIndex
;
2103 info
.m_mask
= wxLIST_MASK_IMAGE
;
2104 info
.m_itemId
= index
;
2105 return InsertItem(info
);
2108 // Inserts an image/string item
2109 long wxListCtrl::InsertItem(long index
, const wxString
& label
, int imageIndex
)
2112 return m_genericImpl
->InsertItem(index
, label
, imageIndex
);
2115 info
.m_image
= imageIndex
;
2116 info
.m_text
= label
;
2117 info
.m_mask
= wxLIST_MASK_IMAGE
| wxLIST_MASK_TEXT
;
2118 info
.m_itemId
= index
;
2119 return InsertItem(info
);
2122 // For list view mode (only), inserts a column.
2123 long wxListCtrl::InsertColumn(long col
, wxListItem
& item
)
2126 return m_genericImpl
->InsertColumn(col
, item
);
2130 int width
= item
.GetWidth();
2131 if ( !(item
.GetMask() & wxLIST_MASK_WIDTH
) )
2134 DataBrowserPropertyType type
= kDataBrowserCustomType
; //kDataBrowserTextType;
2135 wxImageList
* imageList
= GetImageList(wxIMAGE_LIST_SMALL
);
2136 if (imageList
&& imageList
->GetImageCount() > 0)
2138 wxBitmap bmp
= imageList
->GetBitmap(0);
2140 // type = kDataBrowserIconAndTextType;
2143 SInt16 just
= teFlushDefault
;
2144 if (item
.GetMask() & wxLIST_MASK_FORMAT
)
2146 if (item
.GetAlign() == wxLIST_FORMAT_LEFT
)
2148 else if (item
.GetAlign() == wxLIST_FORMAT_CENTER
)
2150 else if (item
.GetAlign() == wxLIST_FORMAT_RIGHT
)
2151 just
= teFlushRight
;
2153 m_dbImpl
->InsertColumn(col
, type
, item
.GetText(), just
, width
);
2155 wxListItem
* listItem
= new wxListItem(item
);
2156 m_colsInfo
.Insert( col
, listItem
);
2157 SetColumn(col
, item
);
2159 // set/remove options based on the wxListCtrl type.
2160 DataBrowserTableViewColumnID id
;
2161 m_dbImpl
->GetColumnIDFromIndex(col
, &id
);
2162 DataBrowserPropertyFlags flags
;
2163 verify_noerr(m_dbImpl
->GetPropertyFlags(id
, &flags
));
2164 if (GetWindowStyleFlag() & wxLC_EDIT_LABELS
)
2165 flags
|= kDataBrowserPropertyIsEditable
;
2167 if (GetWindowStyleFlag() & wxLC_VIRTUAL
){
2168 flags
&= ~kDataBrowserListViewSortableColumn
;
2170 verify_noerr(m_dbImpl
->SetPropertyFlags(id
, flags
));
2176 long wxListCtrl::InsertColumn(long col
,
2177 const wxString
& heading
,
2182 return m_genericImpl
->InsertColumn(col
, heading
, format
, width
);
2185 item
.m_mask
= wxLIST_MASK_TEXT
| wxLIST_MASK_FORMAT
;
2186 item
.m_text
= heading
;
2189 item
.m_mask
|= wxLIST_MASK_WIDTH
;
2190 item
.m_width
= width
;
2192 item
.m_format
= format
;
2194 return InsertColumn(col
, item
);
2197 // scroll the control by the given number of pixels (exception: in list view,
2198 // dx is interpreted as number of columns)
2199 bool wxListCtrl::ScrollList(int dx
, int dy
)
2202 return m_genericImpl
->ScrollList(dx
, dy
);
2206 m_dbImpl
->SetScrollPosition(dx
, dy
);
2212 bool wxListCtrl::SortItems(wxListCtrlCompare fn
, long data
)
2215 return m_genericImpl
->SortItems(fn
, data
);
2220 m_compareFuncData
= data
;
2221 SortDataBrowserContainer( m_dbImpl
->GetControlRef(), kDataBrowserNoItem
, true);
2223 // we need to do this after each call, else we get a crash from wxPython when
2224 // SortItems is called the second time.
2225 m_compareFunc
= NULL
;
2226 m_compareFuncData
= 0;
2232 void wxListCtrl::OnRenameTimer()
2234 wxCHECK_RET( HasCurrent(), wxT("unexpected rename timer") );
2236 EditLabel( m_current
);
2239 bool wxListCtrl::OnRenameAccept(long itemEdit
, const wxString
& value
)
2241 wxListEvent
le( wxEVT_COMMAND_LIST_END_LABEL_EDIT
, GetId() );
2242 le
.SetEventObject( this );
2243 le
.m_itemIndex
= itemEdit
;
2245 GetItem( le
.m_item
);
2246 le
.m_item
.m_text
= value
;
2247 return !HandleWindowEvent( le
) ||
2251 void wxListCtrl::OnRenameCancelled(long itemEdit
)
2253 // let owner know that the edit was cancelled
2254 wxListEvent
le( wxEVT_COMMAND_LIST_END_LABEL_EDIT
, GetParent()->GetId() );
2256 le
.SetEditCanceled(true);
2258 le
.SetEventObject( this );
2259 le
.m_itemIndex
= itemEdit
;
2261 GetItem( le
.m_item
);
2262 HandleWindowEvent( le
);
2265 // ----------------------------------------------------------------------------
2266 // virtual list controls
2267 // ----------------------------------------------------------------------------
2269 wxString
wxListCtrl::OnGetItemText(long WXUNUSED(item
), long WXUNUSED(col
)) const
2271 // this is a pure virtual function, in fact - which is not really pure
2272 // because the controls which are not virtual don't need to implement it
2273 wxFAIL_MSG( _T("wxListCtrl::OnGetItemText not supposed to be called") );
2275 return wxEmptyString
;
2278 int wxListCtrl::OnGetItemImage(long WXUNUSED(item
)) const
2280 wxCHECK_MSG(!GetImageList(wxIMAGE_LIST_SMALL
),
2282 wxT("List control has an image list, OnGetItemImage or OnGetItemColumnImage should be overridden."));
2286 int wxListCtrl::OnGetItemColumnImage(long item
, long column
) const
2289 return OnGetItemImage(item
);
2294 wxListItemAttr
*wxListCtrl::OnGetItemAttr(long WXUNUSED_UNLESS_DEBUG(item
)) const
2296 wxASSERT_MSG( item
>= 0 && item
< GetItemCount(),
2297 _T("invalid item index in OnGetItemAttr()") );
2299 // no attributes by default
2303 void wxListCtrl::SetItemCount(long count
)
2305 wxASSERT_MSG( IsVirtual(), _T("this is for virtual controls only") );
2309 m_genericImpl
->SetItemCount(count
);
2315 // we need to temporarily disable the new item creation notification
2316 // procedure to speed things up
2317 // FIXME: Even this doesn't seem to help much...
2319 // FIXME: Find a more efficient way to do this.
2320 m_dbImpl
->MacClear();
2322 DataBrowserCallbacks callbacks
;
2323 DataBrowserItemNotificationUPP itemUPP
;
2324 GetDataBrowserCallbacks(m_dbImpl
->GetControlRef(), &callbacks
);
2325 itemUPP
= callbacks
.u
.v1
.itemNotificationCallback
;
2326 callbacks
.u
.v1
.itemNotificationCallback
= 0;
2327 m_dbImpl
->SetCallbacks(&callbacks
);
2328 ::AddDataBrowserItems(m_dbImpl
->GetControlRef(), kDataBrowserNoItem
,
2329 count
, NULL
, kDataBrowserItemNoProperty
);
2330 callbacks
.u
.v1
.itemNotificationCallback
= itemUPP
;
2331 m_dbImpl
->SetCallbacks(&callbacks
);
2336 void wxListCtrl::RefreshItem(long item
)
2340 m_genericImpl
->RefreshItem(item
);
2346 DataBrowserItemID id
;
2350 wxMacDataItem
* thisItem
= m_dbImpl
->GetItemFromLine(item
);
2351 id
= (DataBrowserItemID
) thisItem
;
2356 m_dbImpl
->wxMacDataBrowserControl::UpdateItems
2360 kDataBrowserItemNoProperty
, // preSortProperty
2361 kDataBrowserNoItem
// update all columns
2366 void wxListCtrl::RefreshItems(long itemFrom
, long itemTo
)
2370 m_genericImpl
->RefreshItems(itemFrom
, itemTo
);
2376 const long count
= itemTo
- itemFrom
+ 1;
2377 DataBrowserItemID
*ids
= new DataBrowserItemID
[count
];
2381 for ( long i
= 0; i
< count
; i
++ )
2383 wxMacDataItem
* thisItem
= m_dbImpl
->GetItemFromLine(itemFrom
+i
);
2384 ids
[i
] = (DataBrowserItemID
) thisItem
;
2389 for ( long i
= 0; i
< count
; i
++ )
2390 ids
[i
] = itemFrom
+i
+1;
2393 m_dbImpl
->wxMacDataBrowserControl::UpdateItems
2397 kDataBrowserItemNoProperty
, // preSortProperty
2398 kDataBrowserNoItem
// update all columns
2405 void wxListCtrl::SetDropTarget( wxDropTarget
*dropTarget
)
2407 #if wxUSE_DRAG_AND_DROP
2409 m_genericImpl
->SetDropTarget( dropTarget
);
2412 wxWindow::SetDropTarget( dropTarget
);
2416 wxDropTarget
*wxListCtrl::GetDropTarget() const
2418 #if wxUSE_DRAG_AND_DROP
2420 return m_genericImpl
->GetDropTarget();
2423 return wxWindow::GetDropTarget();
2428 #if wxABI_VERSION >= 20801
2429 void wxListCtrl::SetFocus()
2433 m_genericImpl
->SetFocus();
2437 wxWindow::SetFocus();
2441 // wxMac internal data structures
2443 wxMacListCtrlItem::~wxMacListCtrlItem()
2445 WX_CLEAR_HASH_MAP( wxListItemList
, m_rowItems
);
2448 void wxMacListCtrlItem::Notification(wxMacDataItemBrowserControl
*owner
,
2449 DataBrowserItemNotification message
,
2450 DataBrowserItemDataRef
WXUNUSED(itemData
) ) const
2453 wxMacDataBrowserListCtrlControl
*lb
= wxDynamicCast(owner
, wxMacDataBrowserListCtrlControl
);
2455 // we want to depend on as little as possible to make sure tear-down of controls is safe
2456 if ( message
== kDataBrowserItemRemoved
)
2461 else if ( message
== kDataBrowserItemAdded
)
2463 // we don't issue events on adding, the item is not really stored in the list yet, so we
2464 // avoid asserts by gettting out now
2468 wxListCtrl
*list
= wxDynamicCast( owner
->GetWXPeer() , wxListCtrl
);
2471 bool trigger
= false;
2473 wxListEvent
event( wxEVT_COMMAND_LIST_ITEM_SELECTED
, list
->GetId() );
2474 bool isSingle
= (list
->GetWindowStyle() & wxLC_SINGLE_SEL
) != 0;
2476 event
.SetEventObject( list
);
2477 event
.m_itemIndex
= owner
->GetLineFromItem( this ) ;
2478 event
.m_item
.m_itemId
= event
.m_itemIndex
;
2479 list
->GetItem(event
.m_item
);
2483 case kDataBrowserItemDeselected
:
2484 event
.SetEventType(wxEVT_COMMAND_LIST_ITEM_DESELECTED
);
2486 trigger
= !lb
->IsSelectionSuppressed();
2489 case kDataBrowserItemSelected
:
2490 trigger
= !lb
->IsSelectionSuppressed();
2493 case kDataBrowserItemDoubleClicked
:
2494 event
.SetEventType( wxEVT_COMMAND_LIST_ITEM_ACTIVATED
);
2498 case kDataBrowserEditStarted
:
2499 // TODO : how to veto ?
2500 event
.SetEventType( wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
) ;
2504 case kDataBrowserEditStopped
:
2505 // TODO probably trigger only upon the value store callback, because
2506 // here IIRC we cannot veto
2507 event
.SetEventType( wxEVT_COMMAND_LIST_END_LABEL_EDIT
) ;
2517 // direct notification is not always having the listbox GetSelection() having in synch with event
2518 wxPostEvent( list
->GetEventHandler(), event
);
2524 IMPLEMENT_DYNAMIC_CLASS(wxMacDataBrowserListCtrlControl
, wxMacDataItemBrowserControl
)
2526 wxMacDataBrowserListCtrlControl::wxMacDataBrowserListCtrlControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
)
2527 : wxMacDataItemBrowserControl( peer
, pos
, size
, style
)
2529 OSStatus err
= noErr
;
2530 m_clientDataItemsType
= wxClientData_None
;
2531 m_isVirtual
= false;
2534 if ( style
& wxLC_VIRTUAL
)
2537 DataBrowserSelectionFlags options
= kDataBrowserDragSelect
;
2538 if ( style
& wxLC_SINGLE_SEL
)
2540 options
|= kDataBrowserSelectOnlyOne
;
2544 options
|= kDataBrowserCmdTogglesSelection
;
2547 err
= SetSelectionFlags( options
);
2548 verify_noerr( err
);
2550 DataBrowserCustomCallbacks callbacks
;
2551 InitializeDataBrowserCustomCallbacks( &callbacks
, kDataBrowserLatestCustomCallbacks
);
2553 if ( gDataBrowserDrawItemUPP
== NULL
)
2554 gDataBrowserDrawItemUPP
= NewDataBrowserDrawItemUPP(DataBrowserDrawItemProc
);
2556 if ( gDataBrowserHitTestUPP
== NULL
)
2557 gDataBrowserHitTestUPP
= NewDataBrowserHitTestUPP(DataBrowserHitTestProc
);
2559 callbacks
.u
.v1
.drawItemCallback
= gDataBrowserDrawItemUPP
;
2560 callbacks
.u
.v1
.hitTestCallback
= gDataBrowserHitTestUPP
;
2562 SetDataBrowserCustomCallbacks( GetControlRef(), &callbacks
);
2564 if ( style
& wxLC_LIST
)
2566 InsertColumn(0, kDataBrowserIconAndTextType
, wxEmptyString
, -1, -1);
2567 verify_noerr( AutoSizeColumns() );
2570 if ( style
& wxLC_LIST
|| style
& wxLC_NO_HEADER
)
2571 verify_noerr( SetHeaderButtonHeight( 0 ) );
2574 SetSortProperty( kMinColumnId
- 1 );
2576 SetSortProperty( kMinColumnId
);
2578 m_sortOrder
= SortOrder_None
;
2580 if ( style
& wxLC_SORT_DESCENDING
)
2582 SetSortOrder( kDataBrowserOrderDecreasing
);
2584 else if ( style
& wxLC_SORT_ASCENDING
)
2586 SetSortOrder( kDataBrowserOrderIncreasing
);
2589 if ( style
& wxLC_VRULES
)
2591 verify_noerr( DataBrowserChangeAttributes(m_controlRef
, kDataBrowserAttributeListViewDrawColumnDividers
, kDataBrowserAttributeNone
) );
2594 verify_noerr( SetHiliteStyle(kDataBrowserTableViewFillHilite
) );
2595 verify_noerr( SetHasScrollBars( (style
& wxHSCROLL
) != 0 , true ) );
2598 pascal Boolean
wxMacDataBrowserListCtrlControl::DataBrowserEditTextProc(
2600 DataBrowserItemID itemID
,
2601 DataBrowserPropertyID property
,
2602 CFStringRef theString
,
2603 Rect
*maxEditTextRect
,
2604 Boolean
*shrinkToFit
)
2606 Boolean result
= false;
2607 wxMacDataBrowserListCtrlControl
* ctl
= wxDynamicCast(wxMacControl::GetReferenceFromNativeControl( browser
), wxMacDataBrowserListCtrlControl
);
2610 result
= ctl
->ConfirmEditText(itemID
, property
, theString
, maxEditTextRect
, shrinkToFit
);
2611 theString
= CFSTR("Hello!");
2616 bool wxMacDataBrowserListCtrlControl::ConfirmEditText(
2617 DataBrowserItemID
WXUNUSED(itemID
),
2618 DataBrowserPropertyID
WXUNUSED(property
),
2619 CFStringRef
WXUNUSED(theString
),
2620 Rect
*WXUNUSED(maxEditTextRect
),
2621 Boolean
*WXUNUSED(shrinkToFit
))
2626 pascal void wxMacDataBrowserListCtrlControl::DataBrowserDrawItemProc(
2628 DataBrowserItemID itemID
,
2629 DataBrowserPropertyID property
,
2630 DataBrowserItemState itemState
,
2631 const Rect
*itemRect
,
2633 Boolean colorDevice
)
2635 wxMacDataBrowserListCtrlControl
* ctl
= wxDynamicCast(wxMacControl::GetReferenceFromNativeControl( browser
), wxMacDataBrowserListCtrlControl
);
2638 ctl
->DrawItem(itemID
, property
, itemState
, itemRect
, gdDepth
, colorDevice
);
2642 // routines needed for DrawItem
2647 kTextBoxHeight
= 14,
2648 kIconTextSpacingV
= 2,
2650 kContentHeight
= kIconHeight
+ kTextBoxHeight
+ kIconTextSpacingV
2653 static void calculateCGDrawingBounds(CGRect inItemRect
, CGRect
*outIconRect
, CGRect
*outTextRect
, bool hasIcon
= false)
2656 float iconH
, iconW
= 0;
2657 float padding
= kItemPadding
;
2660 iconH
= kIconHeight
;
2662 padding
= padding
*2;
2665 textBottom
= inItemRect
.origin
.y
;
2667 *outIconRect
= CGRectMake(inItemRect
.origin
.x
+ kItemPadding
,
2668 textBottom
+ kIconTextSpacingV
, kIconWidth
,
2671 *outTextRect
= CGRectMake(inItemRect
.origin
.x
+ padding
+ iconW
,
2672 textBottom
+ kIconTextSpacingV
, inItemRect
.size
.width
- padding
- iconW
,
2673 inItemRect
.size
.height
- kIconTextSpacingV
);
2676 void wxMacDataBrowserListCtrlControl::DrawItem(
2677 DataBrowserItemID itemID
,
2678 DataBrowserPropertyID property
,
2679 DataBrowserItemState itemState
,
2680 const Rect
*WXUNUSED(itemRect
),
2682 Boolean colorDevice
)
2685 wxFont font
= wxNullFont
;
2688 DataBrowserTableViewColumnIndex listColumn
= 0;
2689 OSStatus err
= GetColumnPosition( property
, &listColumn
);
2691 wxListCtrl
* list
= wxDynamicCast( GetWXPeer() , wxListCtrl
);
2692 wxMacListCtrlItem
* lcItem
;
2693 wxColour color
= *wxBLACK
;
2694 wxColour bgColor
= wxNullColour
;
2696 if (listColumn
>= 0)
2700 lcItem
= (wxMacListCtrlItem
*) itemID
;
2701 if (lcItem
->HasColumnInfo(listColumn
))
2703 wxListItem
* item
= lcItem
->GetColumnInfo(listColumn
);
2705 // we always use the 0 column to get font and text/background colors.
2706 if (lcItem
->HasColumnInfo(0))
2708 wxListItem
* firstItem
= lcItem
->GetColumnInfo(0);
2709 color
= firstItem
->GetTextColour();
2710 bgColor
= firstItem
->GetBackgroundColour();
2711 font
= firstItem
->GetFont();
2714 if (item
->GetMask() & wxLIST_MASK_TEXT
)
2715 text
= item
->GetText();
2716 if (item
->GetMask() & wxLIST_MASK_IMAGE
)
2717 imgIndex
= item
->GetImage();
2723 long itemNum
= (long)itemID
-1;
2724 if (itemNum
>= 0 && itemNum
< list
->GetItemCount())
2726 text
= list
->OnGetItemText( itemNum
, listColumn
);
2727 imgIndex
= list
->OnGetItemColumnImage( itemNum
, listColumn
);
2728 wxListItemAttr
* attrs
= list
->OnGetItemAttr( itemNum
);
2731 if (attrs
->HasBackgroundColour())
2732 bgColor
= attrs
->GetBackgroundColour();
2733 if (attrs
->HasTextColour())
2734 color
= attrs
->GetTextColour();
2735 if (attrs
->HasFont())
2736 font
= attrs
->GetFont();
2742 wxColour listBgColor
= list
->GetBackgroundColour();
2743 if (bgColor
== wxNullColour
)
2744 bgColor
= listBgColor
;
2747 font
= list
->GetFont();
2749 wxCFStringRef
cfString( text
, wxLocale::GetSystemEncoding() );
2752 CGRect enclosingCGRect
, iconCGRect
, textCGRect
;
2754 ThemeDrawingState savedState
= NULL
;
2755 CGContextRef context
= (CGContextRef
)list
->MacGetDrawingContext();
2756 RGBColor labelColor
;
2758 labelColor
.green
= 0;
2759 labelColor
.blue
= 0;
2761 RGBColor backgroundColor
;
2762 backgroundColor
.red
= 255;
2763 backgroundColor
.green
= 255;
2764 backgroundColor
.blue
= 255;
2766 GetDataBrowserItemPartBounds(GetControlRef(), itemID
, property
, kDataBrowserPropertyEnclosingPart
,
2769 enclosingCGRect
= CGRectMake(enclosingRect
.left
,
2771 enclosingRect
.right
- enclosingRect
.left
,
2772 enclosingRect
.bottom
- enclosingRect
.top
);
2774 bool hasFocus
= (wxWindow::FindFocus() == list
);
2775 active
= IsControlActive(GetControlRef());
2777 // don't paint the background over the vertical rule line
2778 if ( list
->GetWindowStyleFlag() & wxLC_VRULES
)
2780 enclosingCGRect
.origin
.x
+= 1;
2781 enclosingCGRect
.size
.width
-= 1;
2783 if (itemState
== kDataBrowserItemIsSelected
)
2786 GetThemeDrawingState(&savedState
);
2788 if (active
&& hasFocus
)
2790 GetThemeBrushAsColor(kThemeBrushAlternatePrimaryHighlightColor
, 32, true, &backgroundColor
);
2791 GetThemeTextColor(kThemeTextColorWhite
, gdDepth
, colorDevice
, &labelColor
);
2795 GetThemeBrushAsColor(kThemeBrushSecondaryHighlightColor
, 32, true, &backgroundColor
);
2796 GetThemeTextColor(kThemeTextColorBlack
, gdDepth
, colorDevice
, &labelColor
);
2798 CGContextSaveGState(context
);
2800 CGContextSetRGBFillColor(context
, (CGFloat
)backgroundColor
.red
/ (CGFloat
)USHRT_MAX
,
2801 (CGFloat
)backgroundColor
.green
/ (CGFloat
)USHRT_MAX
,
2802 (CGFloat
)backgroundColor
.blue
/ (CGFloat
)USHRT_MAX
, (CGFloat
) 1.0);
2803 CGContextFillRect(context
, enclosingCGRect
);
2805 CGContextRestoreGState(context
);
2811 color
.GetRGBColor(&labelColor
);
2812 else if (list
->GetTextColour().Ok())
2813 list
->GetTextColour().GetRGBColor(&labelColor
);
2817 bgColor
.GetRGBColor(&backgroundColor
);
2818 CGContextSaveGState(context
);
2820 CGContextSetRGBFillColor(context
, (CGFloat
)backgroundColor
.red
/ (CGFloat
)USHRT_MAX
,
2821 (CGFloat
)backgroundColor
.green
/ (CGFloat
)USHRT_MAX
,
2822 (CGFloat
)backgroundColor
.blue
/ (CGFloat
)USHRT_MAX
, (CGFloat
) 1.0);
2823 CGContextFillRect(context
, enclosingCGRect
);
2825 CGContextRestoreGState(context
);
2829 calculateCGDrawingBounds(enclosingCGRect
, &iconCGRect
, &textCGRect
, (imgIndex
!= -1) );
2833 wxImageList
* imageList
= list
->GetImageList(wxIMAGE_LIST_SMALL
);
2834 if (imageList
&& imageList
->GetImageCount() > 0){
2835 wxBitmap bmp
= imageList
->GetBitmap(imgIndex
);
2836 IconRef icon
= bmp
.GetIconRef();
2838 CGContextSaveGState(context
);
2839 CGContextTranslateCTM(context
, 0,iconCGRect
.origin
.y
+ CGRectGetMaxY(iconCGRect
));
2840 CGContextScaleCTM(context
,1.0f
,-1.0f
);
2841 PlotIconRefInContext(context
, &iconCGRect
, kAlignNone
,
2842 active
? kTransformNone
: kTransformDisabled
, NULL
,
2843 kPlotIconRefNormalFlags
, icon
);
2845 CGContextRestoreGState(context
);
2849 HIThemeTextHorizontalFlush hFlush
= kHIThemeTextHorizontalFlushLeft
;
2850 HIThemeTextInfo info
;
2852 #if wxOSX_USE_CORE_TEXT
2853 if ( UMAGetSystemVersion() >= 0x1050 )
2855 info
.version
= kHIThemeTextInfoVersionOne
;
2856 info
.fontID
= kThemeViewsFont
;
2859 info
.fontID
= kThemeSpecifiedFont
;
2860 info
.font
= (CTFontRef
) font
.MacGetCTFont();
2865 #if wxOSX_USE_ATSU_TEXT
2868 info
.version
= kHIThemeTextInfoVersionZero
;
2869 info
.fontID
= kThemeViewsFont
;
2873 info
.fontID
= font
.MacGetThemeFontID();
2875 ::TextSize( (short)(font
.MacGetFontSize()) ) ;
2876 ::TextFace( font
.MacGetFontStyle() ) ;
2882 list
->GetColumn(listColumn
, item
);
2883 if (item
.GetMask() & wxLIST_MASK_FORMAT
)
2885 if (item
.GetAlign() == wxLIST_FORMAT_LEFT
)
2886 hFlush
= kHIThemeTextHorizontalFlushLeft
;
2887 else if (item
.GetAlign() == wxLIST_FORMAT_CENTER
)
2888 hFlush
= kHIThemeTextHorizontalFlushCenter
;
2889 else if (item
.GetAlign() == wxLIST_FORMAT_RIGHT
)
2891 hFlush
= kHIThemeTextHorizontalFlushRight
;
2892 textCGRect
.origin
.x
-= kItemPadding
; // give a little extra paddding
2896 info
.state
= active
? kThemeStateActive
: kThemeStateInactive
;
2897 info
.horizontalFlushness
= hFlush
;
2898 info
.verticalFlushness
= kHIThemeTextVerticalFlushCenter
;
2899 info
.options
= kHIThemeTextBoxOptionNone
;
2900 info
.truncationPosition
= kHIThemeTextTruncationEnd
;
2901 info
.truncationMaxLines
= 1;
2903 CGContextSaveGState(context
);
2904 CGContextSetRGBFillColor (context
, (CGFloat
)labelColor
.red
/ (CGFloat
)USHRT_MAX
,
2905 (CGFloat
)labelColor
.green
/ (CGFloat
)USHRT_MAX
,
2906 (CGFloat
)labelColor
.blue
/ (CGFloat
)USHRT_MAX
, (CGFloat
) 1.0);
2908 HIThemeDrawTextBox(cfString
, &textCGRect
, &info
, context
, kHIThemeOrientationNormal
);
2910 CGContextRestoreGState(context
);
2913 if (savedState
!= NULL
)
2914 SetThemeDrawingState(savedState
, true);
2918 OSStatus
wxMacDataBrowserListCtrlControl::GetSetItemData(DataBrowserItemID itemID
,
2919 DataBrowserPropertyID property
,
2920 DataBrowserItemDataRef itemData
,
2921 Boolean changeValue
)
2926 DataBrowserTableViewColumnIndex listColumn
= 0;
2927 verify_noerr( GetColumnPosition( property
, &listColumn
) );
2929 OSStatus err
= errDataBrowserPropertyNotSupported
;
2930 wxListCtrl
* list
= wxDynamicCast( GetWXPeer() , wxListCtrl
);
2931 wxMacListCtrlItem
* lcItem
= NULL
;
2933 if (listColumn
>= 0)
2937 lcItem
= (wxMacListCtrlItem
*) itemID
;
2938 if (lcItem
&& lcItem
->HasColumnInfo(listColumn
)){
2939 wxListItem
* item
= lcItem
->GetColumnInfo(listColumn
);
2940 if (item
->GetMask() & wxLIST_MASK_TEXT
)
2941 text
= item
->GetText();
2942 if (item
->GetMask() & wxLIST_MASK_IMAGE
)
2943 imgIndex
= item
->GetImage();
2948 long itemNum
= (long)itemID
-1;
2949 if (itemNum
>= 0 && itemNum
< list
->GetItemCount())
2951 text
= list
->OnGetItemText( itemNum
, listColumn
);
2952 imgIndex
= list
->OnGetItemColumnImage( itemNum
, listColumn
);
2961 case kDataBrowserItemIsEditableProperty
:
2962 if ( list
&& list
->HasFlag( wxLC_EDIT_LABELS
) )
2964 verify_noerr(SetDataBrowserItemDataBooleanValue( itemData
, true ));
2969 if ( property
>= kMinColumnId
)
2971 if (!text
.IsEmpty()){
2972 wxCFStringRef
cfStr( text
, wxLocale::GetSystemEncoding() );
2973 err
= ::SetDataBrowserItemDataText( itemData
, cfStr
);
2979 if ( imgIndex
!= -1 )
2981 wxImageList
* imageList
= list
->GetImageList(wxIMAGE_LIST_SMALL
);
2982 if (imageList
&& imageList
->GetImageCount() > 0){
2983 wxBitmap bmp
= imageList
->GetBitmap(imgIndex
);
2984 IconRef icon
= bmp
.GetIconRef();
2985 ::SetDataBrowserItemDataIcon(itemData
, icon
);
2999 if ( property
>= kMinColumnId
)
3001 DataBrowserTableViewColumnIndex listColumn
= 0;
3002 verify_noerr( GetColumnPosition( property
, &listColumn
) );
3004 // TODO probably send the 'end edit' from here, as we
3005 // can then deal with the veto
3007 verify_noerr( GetDataBrowserItemDataText( itemData
, &sr
) ) ;
3008 wxCFStringRef
cfStr(sr
) ;;
3010 list
->SetItem( (long)itemData
-1 , listColumn
, cfStr
.AsString() ) ;
3014 lcItem
->SetColumnTextValue( listColumn
, cfStr
.AsString() );
3024 void wxMacDataBrowserListCtrlControl::ItemNotification(DataBrowserItemID itemID
,
3025 DataBrowserItemNotification message
,
3026 DataBrowserItemDataRef itemData
)
3028 wxMacListCtrlItem
*item
= NULL
;
3031 item
= (wxMacListCtrlItem
*) itemID
;
3034 // we want to depend on as little as possible to make sure tear-down of controls is safe
3035 if ( message
== kDataBrowserItemRemoved
)
3038 item
->Notification(this, message
, itemData
);
3041 else if ( message
== kDataBrowserItemAdded
)
3043 // we don't issue events on adding, the item is not really stored in the list yet, so we
3044 // avoid asserts by getting out now
3046 item
->Notification(this, message
, itemData
);
3050 wxListCtrl
*list
= wxDynamicCast( GetWXPeer() , wxListCtrl
);
3053 bool trigger
= false;
3055 wxListEvent
event( wxEVT_COMMAND_LIST_ITEM_SELECTED
, list
->GetId() );
3057 event
.SetEventObject( list
);
3058 if ( !list
->IsVirtual() )
3060 DataBrowserTableViewRowIndex result
= 0;
3061 verify_noerr( GetItemRow( itemID
, &result
) ) ;
3062 event
.m_itemIndex
= result
;
3066 event
.m_itemIndex
= (long)itemID
-1;
3068 event
.m_item
.m_itemId
= event
.m_itemIndex
;
3069 list
->GetItem(event
.m_item
);
3073 case kDataBrowserItemDeselected
:
3074 event
.SetEventType(wxEVT_COMMAND_LIST_ITEM_DESELECTED
);
3075 // as the generic implementation is also triggering this
3076 // event for single selection, we do the same (different than listbox)
3077 trigger
= !IsSelectionSuppressed();
3080 case kDataBrowserItemSelected
:
3081 trigger
= !IsSelectionSuppressed();
3085 case kDataBrowserItemDoubleClicked
:
3086 event
.SetEventType( wxEVT_COMMAND_LIST_ITEM_ACTIVATED
);
3090 case kDataBrowserEditStarted
:
3091 // TODO : how to veto ?
3092 event
.SetEventType( wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
) ;
3096 case kDataBrowserEditStopped
:
3097 // TODO probably trigger only upon the value store callback, because
3098 // here IIRC we cannot veto
3099 event
.SetEventType( wxEVT_COMMAND_LIST_END_LABEL_EDIT
) ;
3109 // direct notification is not always having the listbox GetSelection() having in synch with event
3110 wxPostEvent( list
->GetEventHandler(), event
);
3115 Boolean
wxMacDataBrowserListCtrlControl::CompareItems(DataBrowserItemID itemOneID
,
3116 DataBrowserItemID itemTwoID
,
3117 DataBrowserPropertyID sortProperty
)
3120 bool retval
= false;
3122 wxString otherItemText
;
3124 long otherItemOrder
;
3126 DataBrowserTableViewColumnIndex colId
= 0;
3127 verify_noerr( GetColumnPosition( sortProperty
, &colId
) );
3129 wxListCtrl
* list
= wxDynamicCast( GetWXPeer() , wxListCtrl
);
3131 DataBrowserSortOrder sort
;
3132 verify_noerr(GetSortOrder(&sort
));
3138 wxMacListCtrlItem
* item
= (wxMacListCtrlItem
*)itemOneID
;
3139 wxMacListCtrlItem
* otherItem
= (wxMacListCtrlItem
*)itemTwoID
;
3141 itemOrder
= item
->GetOrder();
3142 otherItemOrder
= otherItem
->GetOrder();
3144 wxListCtrlCompare func
= list
->GetCompareFunc();
3150 if (item
&& item
->HasColumnInfo(0))
3151 item1
= item
->GetColumnInfo(0)->GetData();
3152 if (otherItem
&& otherItem
->HasColumnInfo(0))
3153 item2
= otherItem
->GetColumnInfo(0)->GetData();
3155 if (item1
> -1 && item2
> -1)
3157 int result
= func(item1
, item2
, list
->GetCompareFuncData());
3158 if (sort
== kDataBrowserOrderIncreasing
)
3165 // we can't use the native control's sorting abilities, so just
3167 return itemOrder
< otherItemOrder
;
3172 long itemNum
= (long)itemOneID
;
3173 long otherItemNum
= (long)itemTwoID
;
3175 // virtual listctrls don't support sorting
3176 return itemNum
< otherItemNum
;
3180 // fallback for undefined cases
3181 retval
= itemOneID
< itemTwoID
;
3187 wxMacDataBrowserListCtrlControl::~wxMacDataBrowserListCtrlControl()
3191 void wxMacDataBrowserListCtrlControl::MacSetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
* item
)
3193 wxMacDataItem
* dataItem
= GetItemFromLine(row
);
3194 wxASSERT_MSG( dataItem
, _T("could not obtain wxMacDataItem for row in MacSetColumnInfo. Is row a valid wxListCtrl row?") );
3197 wxMacListCtrlItem
* listItem
= static_cast<wxMacListCtrlItem
*>(dataItem
);
3198 bool hasInfo
= listItem
->HasColumnInfo( column
);
3199 listItem
->SetColumnInfo( column
, item
);
3200 listItem
->SetOrder(row
);
3201 UpdateState(dataItem
, item
);
3203 wxListCtrl
* list
= wxDynamicCast( GetWXPeer() , wxListCtrl
);
3205 // NB: When this call was made before a control was completely shown, it would
3206 // update the item prematurely (i.e. no text would be listed) and, on show,
3207 // only the sorted column would be refreshed, meaning only first column text labels
3208 // would be shown. Making sure not to update items until the control is visible
3209 // seems to fix this issue.
3210 if (hasInfo
&& list
->IsShown())
3212 DataBrowserTableViewColumnID id
= 0;
3213 verify_noerr( GetColumnIDFromIndex( column
, &id
) );
3214 UpdateItem( wxMacDataBrowserRootContainer
, listItem
, id
);
3219 // apply changes that need to happen immediately, rather than when the
3220 // databrowser control fires a callback.
3221 void wxMacDataBrowserListCtrlControl::UpdateState(wxMacDataItem
* dataItem
, wxListItem
* listItem
)
3223 bool isSelected
= IsItemSelected( dataItem
);
3224 bool isSelectedState
= (listItem
->GetState() == wxLIST_STATE_SELECTED
);
3226 // toggle the selection state if wxListInfo state and actual state don't match.
3227 if ( listItem
->GetMask() & wxLIST_MASK_STATE
&& isSelected
!= isSelectedState
)
3229 DataBrowserSetOption options
= kDataBrowserItemsAdd
;
3230 if (!isSelectedState
)
3231 options
= kDataBrowserItemsRemove
;
3232 SetSelectedItem(dataItem
, options
);
3234 // TODO: Set column width if item width > than current column width
3237 void wxMacDataBrowserListCtrlControl::MacGetColumnInfo( unsigned int row
, unsigned int column
, wxListItem
& item
)
3239 wxMacDataItem
* dataItem
= GetItemFromLine(row
);
3240 wxASSERT_MSG( dataItem
, _T("could not obtain wxMacDataItem in MacGetColumnInfo. Is row a valid wxListCtrl row?") );
3241 // CS should this guard against dataItem = 0 ? , as item is not a pointer if (item) is not appropriate
3244 wxMacListCtrlItem
* listItem
= static_cast<wxMacListCtrlItem
*>(dataItem
);
3246 if (!listItem
->HasColumnInfo( column
))
3249 wxListItem
* oldItem
= listItem
->GetColumnInfo( column
);
3253 long mask
= item
.GetMask();
3255 // by default, get everything for backwards compatibility
3258 if ( mask
& wxLIST_MASK_TEXT
)
3259 item
.SetText(oldItem
->GetText());
3260 if ( mask
& wxLIST_MASK_IMAGE
)
3261 item
.SetImage(oldItem
->GetImage());
3262 if ( mask
& wxLIST_MASK_DATA
)
3263 item
.SetData(oldItem
->GetData());
3264 if ( mask
& wxLIST_MASK_STATE
)
3265 item
.SetState(oldItem
->GetState());
3266 if ( mask
& wxLIST_MASK_WIDTH
)
3267 item
.SetWidth(oldItem
->GetWidth());
3268 if ( mask
& wxLIST_MASK_FORMAT
)
3269 item
.SetAlign(oldItem
->GetAlign());
3271 item
.SetTextColour(oldItem
->GetTextColour());
3272 item
.SetBackgroundColour(oldItem
->GetBackgroundColour());
3273 item
.SetFont(oldItem
->GetFont());
3278 void wxMacDataBrowserListCtrlControl::MacInsertItem( unsigned int n
, wxListItem
* item
)
3281 wxMacDataItemBrowserControl::MacInsert(n
, new wxMacListCtrlItem() );
3282 MacSetColumnInfo(n
, 0, item
);
3285 wxMacListCtrlItem::wxMacListCtrlItem()
3287 m_rowItems
= wxListItemList();
3290 int wxMacListCtrlItem::GetColumnImageValue( unsigned int column
)
3292 if ( HasColumnInfo(column
) )
3293 return GetColumnInfo(column
)->GetImage();
3298 void wxMacListCtrlItem::SetColumnImageValue( unsigned int column
, int imageIndex
)
3300 if ( HasColumnInfo(column
) )
3301 GetColumnInfo(column
)->SetImage(imageIndex
);
3304 wxString
wxMacListCtrlItem::GetColumnTextValue( unsigned int column
)
3306 /* TODO CHECK REMOVE
3310 if ( HasColumnInfo(column
) )
3311 return GetColumnInfo(column
)->GetText();
3313 return wxEmptyString
;
3316 void wxMacListCtrlItem::SetColumnTextValue( unsigned int column
, const wxString
& text
)
3318 if ( HasColumnInfo(column
) )
3319 GetColumnInfo(column
)->SetText(text
);
3321 /* TODO CHECK REMOVE
3322 // for compatibility with superclass APIs
3328 wxListItem
* wxMacListCtrlItem::GetColumnInfo( unsigned int column
)
3330 wxASSERT_MSG( HasColumnInfo(column
), _T("invalid column index in wxMacListCtrlItem") );
3331 return m_rowItems
[column
];
3334 bool wxMacListCtrlItem::HasColumnInfo( unsigned int column
)
3336 return !(m_rowItems
.find( column
) == m_rowItems
.end());
3339 void wxMacListCtrlItem::SetColumnInfo( unsigned int column
, wxListItem
* item
)
3342 if ( !HasColumnInfo(column
) )
3344 wxListItem
* listItem
= new wxListItem(*item
);
3345 m_rowItems
[column
] = listItem
;
3349 wxListItem
* listItem
= GetColumnInfo( column
);
3350 long mask
= item
->GetMask();
3351 if (mask
& wxLIST_MASK_TEXT
)
3352 listItem
->SetText(item
->GetText());
3353 if (mask
& wxLIST_MASK_DATA
)
3354 listItem
->SetData(item
->GetData());
3355 if (mask
& wxLIST_MASK_IMAGE
)
3356 listItem
->SetImage(item
->GetImage());
3357 if (mask
& wxLIST_MASK_STATE
)
3358 listItem
->SetState(item
->GetState());
3359 if (mask
& wxLIST_MASK_FORMAT
)
3360 listItem
->SetAlign(item
->GetAlign());
3361 if (mask
& wxLIST_MASK_WIDTH
)
3362 listItem
->SetWidth(item
->GetWidth());
3364 if ( item
->HasAttributes() )
3366 if ( listItem
->HasAttributes() )
3367 listItem
->GetAttributes()->AssignFrom(*item
->GetAttributes());
3370 listItem
->SetTextColour(item
->GetTextColour());
3371 listItem
->SetBackgroundColour(item
->GetBackgroundColour());
3372 listItem
->SetFont(item
->GetFont());
3378 int wxListCtrl::CalcColumnAutoWidth(int col
) const
3382 for ( int i
= 0; i
< GetItemCount(); i
++ )
3385 info
.SetMask(wxLIST_MASK_TEXT
| wxLIST_MASK_IMAGE
);
3387 info
.SetColumn(col
);
3390 const wxFont font
= info
.GetFont();
3394 GetTextExtent(info
.GetText(), &w
, NULL
, NULL
, NULL
, &font
);
3396 GetTextExtent(info
.GetText(), &w
, NULL
);
3398 w
+= 2 * kItemPadding
;
3400 if ( info
.GetImage() != -1 )
3403 width
= wxMax(width
, w
);
3409 #endif // wxUSE_LISTCTRL