1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/carbon/databrow.cpp
3 // Purpose: Classes and functions for the Carbon data browser
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
14 #if wxUSE_DATAVIEWCTRL && !defined(wxUSE_GENERICDATAVIEWCTRL)
20 #include "wx/toplevel.h"
22 #include "wx/settings.h"
25 #include "wx/dataview.h"
28 #include "wx/mac/carbon/databrow.h"
29 #include "wx/mac/private.h"
30 #include "wx/mac/uma.h"
32 // ============================================================================
33 // wxMacDataBrowserTableViewControl
34 // ============================================================================
36 pascal Boolean
wxMacDataBrowserTableViewControl::DataBrowserCompareProc(ControlRef browser
, DataBrowserItemID itemOneID
, DataBrowserItemID itemTwoID
, DataBrowserPropertyID sortProperty
)
38 wxMacDataBrowserTableViewControl
* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl
*>(wxMacControl::GetReferenceFromNativeControl(browser
)));
41 if (ControlPtr
!= NULL
)
42 return ControlPtr
->DataBrowserCompareProc(itemOneID
,itemTwoID
,sortProperty
);
44 return errDataBrowserPropertyNotSupported
;
45 } /* wxMacDataBrowserTableViewControl::DataBrowserCompareProc(ControlRef, DataBrowserItemID, DataBrowserItemID, DataBrowserPropertyID) */
47 pascal void wxMacDataBrowserTableViewControl::DataBrowserDrawItemProc(ControlRef browser
, DataBrowserItemID itemID
, DataBrowserPropertyID property
, DataBrowserItemState state
, Rect
const* rectangle
, SInt16 bitDepth
, Boolean colorDevice
)
49 wxMacDataBrowserTableViewControl
* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl
*>(wxMacControl::GetReferenceFromNativeControl(browser
)));
52 if (ControlPtr
!= NULL
)
53 ControlPtr
->DataBrowserDrawItemProc(itemID
,property
,state
,rectangle
,bitDepth
,colorDevice
);
54 } /* wxMacDataBrowserTableViewControl::DataBrowserDrawItemProc(ControlRef, DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemState, Rect const*, SInt16, Boolean) */
56 pascal OSStatus
wxMacDataBrowserTableViewControl::DataBrowserGetSetItemDataProc(ControlRef browser
, DataBrowserItemID itemID
, DataBrowserPropertyID property
, DataBrowserItemDataRef itemData
, Boolean getValue
)
58 wxMacDataBrowserTableViewControl
* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl
*>(wxMacControl::GetReferenceFromNativeControl(browser
)));
61 if (ControlPtr
!= NULL
)
62 return ControlPtr
->DataBrowserGetSetItemDataProc(itemID
,property
,itemData
,getValue
);
64 return errDataBrowserPropertyNotSupported
;
65 } /* wxMacDataBrowserTableViewControl::DataBrowserGetSetItemDataProc(ControlRef, DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemDataRef, Boolean) */
67 pascal void wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc(ControlRef browser
, DataBrowserItemID itemID
, DataBrowserItemNotification message
, DataBrowserItemDataRef itemData
)
69 wxMacDataBrowserTableViewControl
* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl
*>(wxMacControl::GetReferenceFromNativeControl(browser
)));
72 if (ControlPtr
!= NULL
)
73 ControlPtr
->DataBrowserItemNotificationProc(itemID
,message
,itemData
);
74 } /* wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc(ControlRef, DataBrowserItemID, DataBrowserItemNotification, DataBrowserItemDataRef) */
76 DataBrowserDrawItemUPP gDataBrowserTableViewDrawItemUPP
= NULL
;
77 DataBrowserItemCompareUPP gDataBrowserTableViewItemCompareUPP
= NULL
;
78 DataBrowserItemDataUPP gDataBrowserTableViewItemDataUPP
= NULL
;
79 DataBrowserItemNotificationUPP gDataBrowserTableViewItemNotificationUPP
= NULL
;
81 wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow
* peer
, wxPoint
const& pos
, wxSize
const& size
, long style
)
84 Rect bounds
= wxMacGetBoundsForControl(peer
,pos
,size
);
85 OSStatus err
= ::CreateDataBrowserControl(MAC_WXHWND(peer
->MacGetTopLevelWindowRef()),&bounds
,kDataBrowserListView
,&(this->m_controlRef
));
88 SetReferenceInNativeControl();
90 if (gDataBrowserTableViewDrawItemUPP
== NULL
) gDataBrowserTableViewDrawItemUPP
= NewDataBrowserDrawItemUPP (DataBrowserDrawItemProc
);
91 if (gDataBrowserTableViewItemCompareUPP
== NULL
) gDataBrowserTableViewItemCompareUPP
= NewDataBrowserItemCompareUPP(wxMacDataBrowserTableViewControl::DataBrowserCompareProc
);
92 if (gDataBrowserTableViewItemDataUPP
== NULL
) gDataBrowserTableViewItemDataUPP
= NewDataBrowserItemDataUPP (wxMacDataBrowserTableViewControl::DataBrowserGetSetItemDataProc
);
93 if (gDataBrowserTableViewItemNotificationUPP
== NULL
)
95 gDataBrowserTableViewItemNotificationUPP
=
96 (DataBrowserItemNotificationUPP
) NewDataBrowserItemNotificationWithItemUPP(wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc
);
99 DataBrowserCallbacks callbacks
;
100 DataBrowserCustomCallbacks customCallbacks
;
102 InitializeDataBrowserCallbacks (&callbacks
, kDataBrowserLatestCallbacks
);
103 InitializeDataBrowserCustomCallbacks(&customCallbacks
,kDataBrowserLatestCallbacks
);
105 callbacks
.u
.v1
.itemDataCallback
= gDataBrowserTableViewItemDataUPP
;
106 callbacks
.u
.v1
.itemCompareCallback
= gDataBrowserTableViewItemCompareUPP
;
107 callbacks
.u
.v1
.itemNotificationCallback
= gDataBrowserTableViewItemNotificationUPP
;
108 this->SetCallbacks(&callbacks
);
110 customCallbacks
.u
.v1
.drawItemCallback
= gDataBrowserTableViewDrawItemUPP
;
111 this->SetCustomCallbacks(&customCallbacks
);
114 this->EnableCellSizeModification();
116 DataBrowserSelectionFlags flags
; // variable definition
118 if (this->GetSelectionFlags(&flags
) == noErr
) // get default settings
120 if ((style
& wxDV_MULTIPLE
) != 0)
121 flags
&= ~kDataBrowserSelectOnlyOne
;
123 flags
|= kDataBrowserSelectOnlyOne
;
124 (void) this->SetSelectionFlags(flags
);
127 OptionBits attributes
; // variable definition
129 if (this->GetAttributes(&attributes
) == noErr
) // get default settings
131 if ((style
& wxDV_VERT_RULES
) != 0)
132 attributes
|= kDataBrowserAttributeListViewDrawColumnDividers
;
134 attributes
&= ~kDataBrowserAttributeListViewDrawColumnDividers
;
136 if ((style
& wxDV_ROW_LINES
) != 0)
137 attributes
|= kDataBrowserAttributeListViewAlternatingRowColors
;
139 (void) this->SetAttributes(attributes
);
142 if ((style
& wxDV_NO_HEADER
) != 0)
143 this->SetHeaderButtonHeight(0);
144 } /* wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow*, wxPoint const&, wxSize const&, long) */
149 OSStatus
wxMacDataBrowserTableViewControl::SetCallbacks(DataBrowserCallbacks
const* callbacks
)
151 return ::SetDataBrowserCallbacks(this->m_controlRef
,callbacks
);
152 } /* wxMacDataBrowserTableViewControl::SetCallbacks(DataBrowserCallbacks const*) */
154 OSStatus
wxMacDataBrowserTableViewControl::SetCustomCallbacks(DataBrowserCustomCallbacks
const* customCallbacks
)
156 return ::SetDataBrowserCustomCallbacks(this->m_controlRef
,customCallbacks
);
157 } /* xMacDataBrowserTableViewControl::SetCustomCallbacks(DataBrowserCustomCallbacks const*) */
162 OSStatus
wxMacDataBrowserTableViewControl::GetHeaderDesc(DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
* desc
) const
164 desc
->version
= kDataBrowserListViewLatestHeaderDesc
; // if this statement is missing the next call will fail (NOT DOCUMENTED!!)
165 return ::GetDataBrowserListViewHeaderDesc(this->m_controlRef
,property
,desc
);
168 OSStatus
wxMacDataBrowserTableViewControl::SetHeaderDesc(DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
* desc
)
170 return ::SetDataBrowserListViewHeaderDesc(this->m_controlRef
,property
,desc
);
176 OSStatus
wxMacDataBrowserTableViewControl::AutoSizeColumns()
178 return AutoSizeDataBrowserListViewColumns(this->m_controlRef
);
181 OSStatus
wxMacDataBrowserTableViewControl::EnableCellSizeModification(bool enableHeight
, bool enableWidth
)
183 return ::SetDataBrowserTableViewGeometry(this->GetControlRef(),enableWidth
,enableHeight
);
184 } /* wxMacDataBrowserTableViewControl::EnableCellSizeModification(bool, bool) */
186 OSStatus
wxMacDataBrowserTableViewControl::GetAttributes(OptionBits
* attributes
)
188 return ::DataBrowserGetAttributes(this->GetControlRef(),attributes
);
189 } /* wxMacDataBrowserTableViewControl::GetAttributes(OptionBits*) */
191 OSStatus
wxMacDataBrowserTableViewControl::GetColumnWidth(DataBrowserPropertyID propertyID
, UInt16
* width
) const
193 return ::GetDataBrowserTableViewNamedColumnWidth(this->m_controlRef
,propertyID
,width
);
196 OSStatus
wxMacDataBrowserTableViewControl::GetDefaultColumnWidth( UInt16
*width
) const
198 return GetDataBrowserTableViewColumnWidth(this->m_controlRef
, width
);
201 OSStatus
wxMacDataBrowserTableViewControl::GetDefaultRowHeight(UInt16
* height
) const
203 return ::GetDataBrowserTableViewRowHeight(this->m_controlRef
,height
);
206 OSStatus
wxMacDataBrowserTableViewControl::GetHeaderButtonHeight(UInt16
*height
)
208 return ::GetDataBrowserListViewHeaderBtnHeight(this->m_controlRef
,height
);
211 OSStatus
wxMacDataBrowserTableViewControl::GetPartBounds(DataBrowserItemID item
, DataBrowserPropertyID property
, DataBrowserPropertyPart part
, Rect
* bounds
)
213 return ::GetDataBrowserItemPartBounds(this->m_controlRef
,item
,property
,part
,bounds
);
214 } /* wxMacDataBrowserTableViewControl::GetPartBounds(DataBrowserItemID, DataBrowswerPropertyID, DataBrowserPropertyPart, Rect*) */
216 OSStatus
wxMacDataBrowserTableViewControl::GetRowHeight(DataBrowserItemID item
, UInt16
* height
) const
218 return ::GetDataBrowserTableViewItemRowHeight(this->m_controlRef
,item
,height
);
219 } /* wxMacDataBrowserTableViewControl::GetRowHeight(DataBrowserItemID, UInt16*) const */
221 OSStatus
wxMacDataBrowserTableViewControl::GetScrollPosition( UInt32
*top
, UInt32
*left
) const
223 return GetDataBrowserScrollPosition(this->m_controlRef
, top
, left
);
226 OSStatus
wxMacDataBrowserTableViewControl::SetAttributes(OptionBits attributes
)
228 return ::DataBrowserChangeAttributes(this->GetControlRef(),attributes
,~attributes
);
229 } /* wxMacDataBrowserTableViewControl::SetAttributes(OptionBits) */
231 OSStatus
wxMacDataBrowserTableViewControl::SetColumnWidth(DataBrowserPropertyID propertyID
, UInt16 width
)
233 return ::SetDataBrowserTableViewNamedColumnWidth(this->m_controlRef
,propertyID
,width
);
236 OSStatus
wxMacDataBrowserTableViewControl::SetDefaultColumnWidth(UInt16 width
)
238 return ::SetDataBrowserTableViewColumnWidth(this->m_controlRef
,width
);
241 OSStatus
wxMacDataBrowserTableViewControl::SetDefaultRowHeight(UInt16 height
)
243 return ::SetDataBrowserTableViewRowHeight(this->m_controlRef
,height
);
246 OSStatus
wxMacDataBrowserTableViewControl::SetHasScrollBars(bool horiz
, bool vert
)
248 return ::SetDataBrowserHasScrollBars(this->m_controlRef
,horiz
,vert
);
249 } /* wxMacDataBrowserTableViewControl::SetHasScrollBars(bool, bool) */
251 OSStatus
wxMacDataBrowserTableViewControl::SetHeaderButtonHeight(UInt16 height
)
253 return ::SetDataBrowserListViewHeaderBtnHeight(this->m_controlRef
,height
);
254 } /* wxMacDataBrowserTableViewControl::SetHeaderButtonHeight(UInt16) */
256 OSStatus
wxMacDataBrowserTableViewControl::SetHiliteStyle(DataBrowserTableViewHiliteStyle hiliteStyle
)
258 return ::SetDataBrowserTableViewHiliteStyle(this->m_controlRef
,hiliteStyle
);
259 } /*wxMacDataBrowserTableViewControl::SetHiliteStyle(DataBrowserTableViewHiliteStyle) */
261 OSStatus
wxMacDataBrowserTableViewControl::SetIndent(float Indent
)
263 return ::DataBrowserSetMetric(this->m_controlRef
,kDataBrowserMetricDisclosureColumnPerDepthGap
,true,Indent
);
264 } /* wxMacDataBrowserTableViewControl::SetIndent(float* Indent) */
266 OSStatus
wxMacDataBrowserTableViewControl::SetRowHeight(DataBrowserItemID item
, UInt16 height
)
268 return ::SetDataBrowserTableViewItemRowHeight(this->m_controlRef
,item
,height
);
271 OSStatus
wxMacDataBrowserTableViewControl::SetScrollPosition(UInt32 top
, UInt32 left
)
273 return ::SetDataBrowserScrollPosition(this->m_controlRef
,top
,left
);
279 OSStatus
wxMacDataBrowserTableViewControl::GetColumnCount(UInt32
* numColumns
) const
281 return ::GetDataBrowserTableViewColumnCount(this->m_controlRef
,numColumns
);
284 OSStatus
wxMacDataBrowserTableViewControl::GetColumnIndex(DataBrowserPropertyID propertyID
, DataBrowserTableViewColumnIndex
* index
) const
286 return ::GetDataBrowserTableViewColumnPosition(this->m_controlRef
,propertyID
,index
);
287 } /* wxMacDataBrowserTableViewControl::GetColumnIndex(DataBrowserPropertyID, DataBrowserTableViewColumnIndex*) const */
289 OSStatus
wxMacDataBrowserTableViewControl::GetFreePropertyID(DataBrowserPropertyID
* propertyID
) const
291 for (*propertyID
=kMinPropertyID
; *propertyID
<std::numeric_limits
<DataBrowserPropertyID
>::max(); ++(*propertyID
))
292 if (this->IsUsedPropertyID(*propertyID
) == errDataBrowserPropertyNotFound
)
294 return errDataBrowserPropertyNotSupported
;
295 } /* wxMacDataBrowserTableViewControl::GetFreePropertyID(DataBrowserPropertyID*) const */
297 OSStatus
wxMacDataBrowserTableViewControl::GetPropertyFlags(DataBrowserPropertyID propertyID
, DataBrowserPropertyFlags
*flags
) const
299 return ::GetDataBrowserPropertyFlags(this->m_controlRef
,propertyID
,flags
);
302 OSStatus
wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserItemDataRef itemData
, DataBrowserPropertyID
* propertyID
)
304 return ::GetDataBrowserItemDataProperty(itemData
,propertyID
);
305 } /* wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserItemDataRef, DataBrowserPropertyID*) */
307 OSStatus
wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserTableViewColumnIndex index
, DataBrowserTableViewColumnID
* propertyID
)
309 return ::GetDataBrowserTableViewColumnProperty(this->m_controlRef
,index
,propertyID
);
310 } /* wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserTableViewColumnIndex, DataBrowserTableViewColumnID*) */
312 OSStatus
wxMacDataBrowserTableViewControl::IsUsedPropertyID(DataBrowserPropertyID propertyID
) const
314 // as the Mac interface does not provide a function that checks if the property id is in use or not a function is chosen that should not
315 // lead to a large overhead for the call but returns an error code if the property id does not exist, here we use the function that returns
316 // the column position for the property id:
317 DataBrowserTableViewColumnIndex index
;
319 return ::GetDataBrowserTableViewColumnPosition(this->m_controlRef
,propertyID
,&index
);
320 } /* wxMacDataBrowserTableViewControl::IsUsedPropertyId(DataBrowserPropertyID) const */
322 OSStatus
wxMacDataBrowserTableViewControl::RemoveColumnByProperty(DataBrowserTableViewColumnID propertyID
)
324 return ::RemoveDataBrowserTableViewColumn(this->m_controlRef
,propertyID
);
325 } /* wxMacDataBrowserTableViewControl::RemoveColumnByProperty(DataBrowserTableViewColumnID) */
327 OSStatus
wxMacDataBrowserTableViewControl::RemoveColumnByIndex(DataBrowserTableViewColumnIndex index
)
329 DataBrowserTableViewColumnID propertyID
;
332 this->GetPropertyID(index
,&propertyID
);
333 return ::RemoveDataBrowserTableViewColumn(this->m_controlRef
,propertyID
);
334 } /* wxMacDataBrowserTableViewControl::RemoveColumnByIndex(DataBrowserTableViewColumnIndex) */
336 OSStatus
wxMacDataBrowserTableViewControl::SetColumnIndex(DataBrowserPropertyID propertyID
, DataBrowserTableViewColumnIndex index
)
338 return ::SetDataBrowserTableViewColumnPosition(this->m_controlRef
,propertyID
,index
);
339 } /* wxMacDataBrowserTableViewControl::SetColumnIndex(DataBrowserPropertyID, DataBrowserTableViewColumnIndex) */
341 OSStatus
wxMacDataBrowserTableViewControl::SetDisclosureColumn(DataBrowserPropertyID propertyID
, Boolean expandableRows
)
343 return ::SetDataBrowserListViewDisclosureColumn(this->m_controlRef
,propertyID
,expandableRows
);
346 OSStatus
wxMacDataBrowserTableViewControl::SetPropertyFlags(DataBrowserPropertyID propertyID
, DataBrowserPropertyFlags flags
)
348 return ::SetDataBrowserPropertyFlags(this->m_controlRef
,propertyID
,flags
);
349 } /* wxMacDataBrowserTableViewControl::SetPropertyFlags(DataBrowserPropertyID, DataBrowserPropertyFlags) */
354 OSStatus
wxMacDataBrowserTableViewControl::AddItems(DataBrowserItemID container
, UInt32 numItems
, DataBrowserItemID
const* items
, DataBrowserPropertyID preSortProperty
)
356 return ::AddDataBrowserItems(this->m_controlRef
,container
,numItems
,items
,preSortProperty
);
357 } /* wxMacDataBrowserTableViewControl::AddItems(DataBrowserItemID, UInt32, DataBrowserItemID const*, DataBrowserPropertyID) */
359 OSStatus
wxMacDataBrowserTableViewControl::GetFreeItemID(DataBrowserItemID
* id
) const
364 verify_noerr(this->GetItemCount(&NoOfItems
));
372 // as there might be a lot of items in the data browser and mostly the data is added item by item the largest used ID number is roughly in the order of magnitude
373 // as the number of items; therefore, start from the number of items to look for a new ID:
374 for (*id
=NoOfItems
; *id
<std::numeric_limits
<DataBrowserItemID
>::max(); ++(*id
))
375 if (this->IsUsedItemID(*id
) == errDataBrowserItemNotFound
)
377 // as the first approach was not successful, try from the beginning:
378 for (*id
=0; *id
<NoOfItems
; ++(*id
))
379 if (this->IsUsedItemID(*id
) == errDataBrowserItemNotFound
)
381 // sorry, data browser is full:
382 return errDataBrowserItemNotAdded
;
384 } /* wxMacDataBrowserTableViewControl::GetFreeItemID(DataBrowserItemID*) const */
386 OSStatus
wxMacDataBrowserTableViewControl::GetItemCount(DataBrowserItemID container
, Boolean recurse
, DataBrowserItemState state
, ItemCount
* numItems
) const
388 return GetDataBrowserItemCount(this->m_controlRef
,container
,recurse
,state
,numItems
);
389 } /* wxMacDataBrowserTableViewControl::GetItemCount(DataBrowserItemID, Boolean, DataBrowserItemState, ItemCount*) const */
391 OSStatus
wxMacDataBrowserTableViewControl::GetItemID( DataBrowserTableViewRowIndex row
, DataBrowserItemID
* item
) const
393 return GetDataBrowserTableViewItemID(this->m_controlRef
,row
,item
);
396 OSStatus
wxMacDataBrowserTableViewControl::GetItems(DataBrowserItemID container
, Boolean recurse
, DataBrowserItemState state
, Handle items
) const
398 return GetDataBrowserItems(this->m_controlRef
,container
,recurse
,state
,items
);
399 } /* wxMacDataBrowserTableViewControl::GetItems(DataBrowserItemID, Boolean, DataBrowserItemState, Handle) const */
401 OSStatus
wxMacDataBrowserTableViewControl::GetItemRow(DataBrowserItemID item
, DataBrowserTableViewRowIndex
* row
) const
403 return GetDataBrowserTableViewItemRow(this->m_controlRef
,item
,row
);
406 OSStatus
wxMacDataBrowserTableViewControl::IsUsedItemID(DataBrowserItemID itemID
) const
408 // as the Mac interface does not provide a function that checks if the property id is in use or not a function is chosen that should not
409 // lead to a large overhead for the call but returns an error code if the property id does not exist, here we use the function that returns
410 // the column position for the property id:
411 DataBrowserTableViewColumnIndex index
;
413 return ::GetDataBrowserTableViewItemRow(this->m_controlRef
,itemID
,&index
);
414 } /* wxMacDataBrowserTableViewControl::IsUsedItemID(DataBrowserItemID) const */
416 OSStatus
wxMacDataBrowserTableViewControl::RemoveItems(DataBrowserItemID container
, UInt32 numItems
, DataBrowserItemID
const* items
, DataBrowserPropertyID preSortProperty
)
418 return ::RemoveDataBrowserItems(this->m_controlRef
,container
,numItems
,items
,preSortProperty
);
421 OSStatus
wxMacDataBrowserTableViewControl::RevealItem(DataBrowserItemID item
, DataBrowserPropertyID propertyID
, DataBrowserRevealOptions options
) const
423 return ::RevealDataBrowserItem(this->m_controlRef
,item
,propertyID
,options
);
424 } /* wxMacDataBrowserTableViewControl::RevealItem(DataBrowserItemID item, DataBrowserPropertyID propertyID, DataBrowserRevealOptions options) const */
426 OSStatus
wxMacDataBrowserTableViewControl::UpdateItems(DataBrowserItemID container
, UInt32 numItems
, DataBrowserItemID
const* items
, DataBrowserPropertyID preSortProperty
,
427 DataBrowserPropertyID propertyID
) const
429 return UpdateDataBrowserItems(this->m_controlRef
,container
,numItems
,items
,preSortProperty
,propertyID
);
435 size_t wxMacDataBrowserTableViewControl::GetSelectedItemIDs(wxArrayDataBrowserItemID
& itemIDs
) const
437 DataBrowserItemID
* itemIDPtr
;
438 Handle
handle(::NewHandle(0));
443 wxCHECK_MSG(this->GetItems(kDataBrowserNoItem
,true,kDataBrowserItemIsSelected
,handle
) == noErr
,0,_("Could not get selected items."));
444 NoOfItems
= static_cast<size_t>(::GetHandleSize(handle
)/sizeof(DataBrowserItemID
));
446 itemIDs
.Alloc(NoOfItems
);
448 itemIDPtr
= (DataBrowserItemID
*) (*handle
);
449 for (size_t i
=0; i
<NoOfItems
; ++i
)
451 itemIDs
.Add(*itemIDPtr
);
455 DisposeHandle(handle
);
457 } /* wxMacDataBrowserTableViewControl::GetSelectedItemIDs(wxArrayDataBrowserItemID&) const*/
459 OSStatus
wxMacDataBrowserTableViewControl::GetSelectionAnchor(DataBrowserItemID
* first
, DataBrowserItemID
* last
) const
461 return ::GetDataBrowserSelectionAnchor(this->m_controlRef
,first
,last
);
462 } /* wxMacDataBrowserTableViewControl::GetSelectionAnchor(DataBrowserItemID*, DataBrowserItemID*) const */
464 OSStatus
wxMacDataBrowserTableViewControl::GetSelectionFlags(DataBrowserSelectionFlags
* flags
) const
466 return ::GetDataBrowserSelectionFlags(this->m_controlRef
,flags
);
467 } /* wxMacDataBrowserTableViewControl::GetSelectionFlags(DataBrowserSelectionFlags*) const */
469 bool wxMacDataBrowserTableViewControl::IsItemSelected(DataBrowserItemID item
) const
471 return ::IsDataBrowserItemSelected(this->m_controlRef
,item
);
472 } /* wxMacDataBrowserTableViewControl::IsItemSelected(DataBrowserItemID) const */
474 OSStatus
wxMacDataBrowserTableViewControl::SetSelectionFlags(DataBrowserSelectionFlags flags
)
476 return ::SetDataBrowserSelectionFlags(this->m_controlRef
,flags
);
477 } /* wxMacDataBrowserTableViewControl::SetSelectionFlags(DataBrowserSelectionFlags) */
479 OSStatus
wxMacDataBrowserTableViewControl::SetSelectedItems(UInt32 numItems
, DataBrowserItemID
const* items
, DataBrowserSetOption operation
)
481 return ::SetDataBrowserSelectedItems(this->m_controlRef
, numItems
, items
, operation
);
482 } /* wxMacDataBrowserTableViewControl::SetSelectedItems(UInt32, DataBrowserItemID const*, DataBrowserSetOption) */
484 OSStatus
wxMacDataBrowserTableViewControl::GetSortOrder(DataBrowserSortOrder
* order
) const
486 return ::GetDataBrowserSortOrder(this->m_controlRef
,order
);
489 OSStatus
wxMacDataBrowserTableViewControl::GetSortProperty(DataBrowserPropertyID
* propertyID
) const
491 return ::GetDataBrowserSortProperty(this->m_controlRef
,propertyID
);
494 OSStatus
wxMacDataBrowserTableViewControl::Resort(DataBrowserItemID container
, Boolean sortChildren
)
496 return ::SortDataBrowserContainer(this->m_controlRef
,container
,sortChildren
);
497 } /* wxMacDataBrowserTableViewControl::Resort(DataBrowserItemID, Boolean) */
499 OSStatus
wxMacDataBrowserTableViewControl::SetSortOrder(DataBrowserSortOrder order
)
501 return ::SetDataBrowserSortOrder(this->m_controlRef
,order
);
504 OSStatus
wxMacDataBrowserTableViewControl::SetSortProperty(DataBrowserPropertyID propertyID
)
506 return ::SetDataBrowserSortProperty(this->m_controlRef
,propertyID
);
510 // container handling
512 OSStatus
wxMacDataBrowserTableViewControl::CloseContainer(DataBrowserItemID containerID
)
514 return ::CloseDataBrowserContainer(this->m_controlRef
,containerID
);
515 } /* wxMacDataBrowserTableViewControl::CloseContainer(DataBrowserItemID) */
517 OSStatus
wxMacDataBrowserTableViewControl::OpenContainer(DataBrowserItemID containerID
)
519 return ::OpenDataBrowserContainer(this->m_controlRef
,containerID
);
520 } /* wxMacDataBrowserTableViewControl::OpenContainer(DataBrowserItemID) */
522 IMPLEMENT_ABSTRACT_CLASS(wxMacDataBrowserTableViewControl
,wxMacControl
)
524 // ============================================================================
525 // wxMacDataBrowserListViewControl
526 // ============================================================================
531 OSStatus
wxMacDataBrowserListViewControl::AddColumn(DataBrowserListViewColumnDesc
*columnDesc
, DataBrowserTableViewColumnIndex position
)
533 return AddDataBrowserListViewColumn(this->m_controlRef
,columnDesc
,position
);
534 } /* wxMacDataBrowserListViewControl::AddColumn(DataBrowserListViewColumnDesc*, DataBrowserTableViewColumnIndex) */
536 // ============================================================================
537 // wxMacDataViewDataBrowserListViewControl
538 // ============================================================================
541 // constructors / destructor
543 wxMacDataViewDataBrowserListViewControl::wxMacDataViewDataBrowserListViewControl(wxWindow
* peer
, wxPoint
const& pos
, wxSize
const& size
, long style
)
544 :wxMacDataBrowserListViewControl(peer
,pos
,size
,style
)
546 } /* wxMacDataViewDataBrowserListViewControl::wxMacDataViewDataBrowserListViewControl(wxWindow* , const wxPoint&, const wxSize&, long) */
549 // callback functions (inherited from wxMacDataBrowserTableViewControl)
551 Boolean
wxMacDataViewDataBrowserListViewControl::DataBrowserCompareProc(DataBrowserItemID itemOneID
, DataBrowserItemID itemTwoID
, DataBrowserPropertyID sortProperty
)
553 DataBrowserSortOrder sortOrder
;
555 DataBrowserTableViewColumnIndex columnIndex
;
557 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
560 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
, false,_("Pointer to data view control not set correctly."));
561 wxCHECK_MSG(dataViewCtrlPtr
->GetModel() != NULL
,false,_("Pointer to model not set correctly."));
562 if (sortProperty
>= kMinPropertyID
)
564 wxCHECK_MSG(this->GetColumnIndex(sortProperty
,&columnIndex
) == noErr
,false,_("Could not determine column index."));
568 this->GetSortOrder(&sortOrder
);
569 return static_cast<Boolean
>(dataViewCtrlPtr
->GetModel()->Compare(wxDataViewItem(reinterpret_cast<void*>(itemOneID
)),wxDataViewItem(reinterpret_cast<void*>(itemTwoID
)),
570 columnIndex
,sortOrder
!= kDataBrowserOrderDecreasing
) < 0);
571 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserCompareProc(DataBrowserItemID, DataBrowserItemID, DataBrowserPropertyID) */
573 void wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowserItemID itemID
, DataBrowserPropertyID propertyID
, DataBrowserItemState state
, Rect
const* rectangle
, SInt16
WXUNUSED(bitDepth
), Boolean
WXUNUSED(colorDevice
))
575 DataBrowserTableViewColumnIndex columnIndex
;
577 wxDataViewColumn
* dataViewColumnPtr
;
579 wxDataViewCtrl
* dataViewCtrlPtr
;
581 wxDataViewCustomRenderer
* dataViewCustomRendererPtr
;
583 wxVariant dataToRender
;
585 dataViewCtrlPtr
= dynamic_cast<wxDataViewCtrl
*>(this->GetPeer());
586 wxCHECK_RET(dataViewCtrlPtr
!= NULL
, _("Pointer to data view control not set correctly."));
587 wxCHECK_RET(dataViewCtrlPtr
->GetModel() != NULL
, _("Pointer to model not set correctly."));
588 wxCHECK_RET(this->GetColumnIndex(propertyID
,&columnIndex
) == noErr
,_("Could not determine column index."));
589 dataViewColumnPtr
= dataViewCtrlPtr
->GetColumn(columnIndex
);
590 wxCHECK_RET(dataViewColumnPtr
!= NULL
,_("No column for the specified column index existing."));
591 dataViewCustomRendererPtr
= dynamic_cast<wxDataViewCustomRenderer
*>(dataViewColumnPtr
->GetRenderer());
592 wxCHECK_RET(dataViewCustomRendererPtr
!= NULL
,_("No renderer or invalid renderer type specified for custom data column."));
594 wxDataViewItem
dataitem( reinterpret_cast<void*>(itemID
) );
595 dataViewCtrlPtr
->GetModel()->GetValue(dataToRender
,dataitem
,columnIndex
);
596 dataViewCustomRendererPtr
->SetValue(dataToRender
);
598 // try to determine the content's size (drawable part):
600 RgnHandle
rgn(NewRgn());
603 if (this->GetRegion(kControlContentMetaPart
,rgn
) == noErr
)
604 GetRegionBounds(rgn
,&content
);
606 this->GetRect(&content
);
608 // space for the header
609 this->GetHeaderButtonHeight(&headerHeight
);
610 content
.top
+= headerHeight
;
611 // extra space for the frame (todo: do not how to determine the space automatically from the control)
616 // extra space for the scrollbars:
617 content
.bottom
-= wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y
);
618 content
.right
-= wxSystemSettings::GetMetric(wxSYS_VSCROLL_X
);
620 wxDC
*dc
= dataViewCustomRendererPtr
->GetDC();
622 wxRect
cellrect( static_cast<int>(rectangle
->left
),
623 static_cast<int>(rectangle
->top
+2),
624 static_cast<int>(1+rectangle
->right
-rectangle
->left
),
625 static_cast<int>(rectangle
->bottom
-rectangle
->top
) );
627 bool is_active
= IsControlActive( this->m_controlRef
);
628 if (state
== kDataBrowserItemIsSelected
)
631 wxColour
col( wxMacCreateCGColorFromHITheme( (is_active
) ?
632 kThemeBrushAlternatePrimaryHighlightColor
633 : kThemeBrushSecondaryHighlightColor
) );
635 wxRect rect
= cellrect
;
637 GetDataBrowserItemPartBounds( this->m_controlRef
, itemID
, propertyID
,
638 kDataBrowserPropertyEnclosingPart
, &itemrect
);
639 rect
.x
= itemrect
.left
;
640 rect
.width
= itemrect
.right
-itemrect
.left
+1;
642 wxBrush
selBrush( col
);
643 wxPen
oldpen( dc
->GetPen() );
644 wxBrush
oldbrush( dc
->GetBrush() );
645 dc
->SetPen( *wxTRANSPARENT_PEN
);
646 dc
->SetBrush( selBrush
);
647 dc
->DrawRectangle(rect
);
648 dc
->SetBrush( oldbrush
);
649 dc
->SetPen( oldpen
);
652 wxDataViewModel
*model
= dataViewCtrlPtr
->GetModel();
653 if ((columnIndex
== 0) || !model
->IsContainer(dataitem
) || model
->HasContainerColumns(dataitem
))
655 // make sure that 'Render' can draw only in the allowed area:
656 dc
->SetClippingRegion(content
.left
,content
.top
,content
.right
-content
.left
+1,content
.bottom
-content
.top
+1);
657 (void) (dataViewCustomRendererPtr
->Render( cellrect
, dc
,
658 ((state
== kDataBrowserItemIsSelected
) ? wxDATAVIEW_CELL_SELECTED
: 0)));
659 dc
->DestroyClippingRegion(); // probably not necessary
662 dataViewCustomRendererPtr
->SetDC(NULL
);
663 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemState, Rect const*, SInt16, Boolean) */
665 OSStatus
wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(DataBrowserItemID itemID
, DataBrowserPropertyID propertyID
, DataBrowserItemDataRef itemData
, Boolean getValue
)
669 // variable definitions:
670 wxDataViewCtrl
* dataViewCtrlPtr
;
672 dataViewCtrlPtr
= dynamic_cast<wxDataViewCtrl
*>(this->GetPeer());
673 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
,errDataBrowserNotConfigured
,_("Pointer to data view control not set correctly."));
674 if (dataViewCtrlPtr
->IsDeleting())
675 return noErr
; // if a delete process is running the data of editable fields cannot be saved because the associated model variable may already have been deleted
678 // variable definitions:
679 DataBrowserTableViewColumnIndex columnIndex
;
680 OSStatus errorStatus
;
681 wxDataViewColumn
* dataViewColumnPtr
;
683 wxCHECK_MSG(dataViewCtrlPtr
->GetModel() != NULL
,errDataBrowserNotConfigured
,_("Pointer to model not set correctly."));
684 errorStatus
= this->GetColumnIndex(propertyID
,&columnIndex
);
685 wxCHECK_MSG(errorStatus
== noErr
,errorStatus
,_("Could not determine column index"));
686 dataViewColumnPtr
= dataViewCtrlPtr
->GetColumn(columnIndex
);
687 wxCHECK_MSG((dataViewColumnPtr
!= NULL
) && (dataViewColumnPtr
->GetRenderer() != NULL
),errDataBrowserNotConfigured
,_("There is no column or renderer for the specified column index."));
688 switch (dataViewColumnPtr
->GetRenderer()->GetPropertyType())
690 case kDataBrowserCheckboxType
:
692 // variable definition:
693 ThemeButtonValue buttonValue
;
695 errorStatus
= ::GetDataBrowserItemDataButtonValue(itemData
,&buttonValue
);
696 if (errorStatus
== noErr
)
698 if (buttonValue
== kThemeButtonOn
)
700 // variable definition and initialization:
701 wxVariant
modifiedData(true);
703 return (dataViewCtrlPtr
->GetModel()->SetValue(modifiedData
,wxDataViewItem(reinterpret_cast<void*>(itemID
)),static_cast<unsigned int>(columnIndex
)) ? OSStatus(noErr
) : OSStatus(errDataBrowserNotConfigured
));
705 else if (buttonValue
== kThemeButtonOff
)
707 // variable definition and initialization:
708 wxVariant
modifiedData(false);
710 return (dataViewCtrlPtr
->GetModel()->SetValue(modifiedData
,wxDataViewItem(reinterpret_cast<void*>(itemID
)),static_cast<unsigned int>(columnIndex
)) ? OSStatus(noErr
) : OSStatus(errDataBrowserNotConfigured
));
713 return errDataBrowserInvalidPropertyData
;
718 case kDataBrowserTextType
:
720 // variable definitions:
721 CFStringRef stringReference
;
723 errorStatus
= ::GetDataBrowserItemDataText(itemData
,&stringReference
);
724 if (errorStatus
== noErr
)
726 // variable definitions and initializations:
727 wxCFStringRef
modifiedString(stringReference
);
728 wxVariant
modifiedData(modifiedString
.AsString());
730 if (dataViewCtrlPtr
->GetModel()->SetValue(modifiedData
,wxDataViewItem(reinterpret_cast<void*>(itemID
)),static_cast<unsigned int>(columnIndex
)))
733 return errDataBrowserNotConfigured
;
739 return errDataBrowserPropertyNotSupported
;
745 if (propertyID
>= kMinPropertyID
) // in case data columns set the data
747 // variable definitions:
749 wxDataViewColumn
* dataViewColumnPtr
;
750 wxDataViewCtrl
* dataViewCtrlPtr
;
752 dataViewCtrlPtr
= dynamic_cast<wxDataViewCtrl
*>(this->GetPeer());
753 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
,errDataBrowserNotConfigured
,_("Pointer to data view control not set correctly."));
754 wxCHECK_MSG(dataViewCtrlPtr
->GetModel() != NULL
,errDataBrowserNotConfigured
,_("Pointer to model not set correctly."));
755 dataViewColumnPtr
= dataViewCtrlPtr
->GetColumnPtr(propertyID
);
756 wxCHECK_MSG(dataViewColumnPtr
!= NULL
,errDataBrowserNotConfigured
,_("No column for the specified column position existing."));
757 wxCHECK_MSG(dataViewColumnPtr
->GetRenderer() != NULL
,errDataBrowserNotConfigured
,_("No renderer specified for column."));
758 dataViewCtrlPtr
->GetModel()->GetValue(variant
,wxDataViewItem(reinterpret_cast<void*>(itemID
)),dataViewColumnPtr
->GetModelColumn());
759 if (!(variant
.IsNull()))
761 dataViewColumnPtr
->GetRenderer()->SetDataReference(itemData
);
762 dataViewColumnPtr
->GetRenderer()->SetValue(variant
);
763 wxCHECK_MSG(dataViewColumnPtr
->GetRenderer()->Render(),errDataBrowserNotConfigured
,_("Rendering failed."));
767 else // react on special system requests
771 case kDataBrowserContainerIsClosableProperty
:
773 // variable definitions:
774 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
776 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
,errDataBrowserNotConfigured
,_("Pointer to data view control not set correctly."));
777 // initialize wxWidget event:
778 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING
,dataViewCtrlPtr
->GetId()); // variable definition
780 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
781 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
782 // finally send the equivalent wxWidget event:
783 dataViewCtrlPtr
->HandleWindowEvent(dataViewEvent
);
784 // opening the container is allowed if not vetoed:
785 return ::SetDataBrowserItemDataBooleanValue(itemData
,dataViewEvent
.IsAllowed());
787 case kDataBrowserContainerIsOpenableProperty
:
789 // variable definitions:
790 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
792 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
,errDataBrowserNotConfigured
,_("Pointer to data view control not set correctly."));
793 // initialize wxWidget event:
794 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING
,dataViewCtrlPtr
->GetId()); // variable definition
796 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
797 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
798 // finally send the equivalent wxWidget event:
799 dataViewCtrlPtr
->HandleWindowEvent(dataViewEvent
);
800 // opening the container is allowed if not vetoed:
801 return ::SetDataBrowserItemDataBooleanValue(itemData
,dataViewEvent
.IsAllowed());
803 case kDataBrowserItemIsContainerProperty
:
805 // variable definition:
806 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
808 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
,errDataBrowserNotConfigured
,_("Pointer to data view control not set correctly."));
809 wxCHECK_MSG(dataViewCtrlPtr
->GetModel() != NULL
,errDataBrowserNotConfigured
,_("Pointer to model not set correctly."));
810 return ::SetDataBrowserItemDataBooleanValue(itemData
,dataViewCtrlPtr
->GetModel()->IsContainer(wxDataViewItem(reinterpret_cast<void*>(itemID
))));
812 case kDataBrowserItemIsEditableProperty
:
813 return ::SetDataBrowserItemDataBooleanValue(itemData
,true);
817 return errDataBrowserPropertyNotSupported
;
818 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemDataRef, Boolean) */
820 void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(DataBrowserItemID itemID
, DataBrowserItemNotification message
, DataBrowserItemDataRef itemData
)
822 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
825 // check if the data view control pointer still exists because this call back function can still be called when the control has already been deleted:
826 if (dataViewCtrlPtr
!= NULL
)
829 case kDataBrowserContainerClosed
:
831 // initialize wxWidget event:
832 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED
,dataViewCtrlPtr
->GetId()); // variable definition
834 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
835 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
836 // finally send the equivalent wxWidget event:
837 dataViewCtrlPtr
->HandleWindowEvent(dataViewEvent
);
840 case kDataBrowserContainerOpened
:
842 // initialize wxWidget event:
843 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED
,dataViewCtrlPtr
->GetId()); // variable definition
845 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
846 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
847 // finally send the equivalent wxWidget event:
848 dataViewCtrlPtr
->HandleWindowEvent(dataViewEvent
);
849 // add children to the expanded container:
850 dataViewCtrlPtr
->AddChildrenLevel(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
853 case kDataBrowserEditStarted
:
855 // initialize wxWidget event:
856 DataBrowserPropertyID propertyID
;
857 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED
,dataViewCtrlPtr
->GetId()); // variable definition
859 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
860 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
861 if (this->GetPropertyID(itemData
,&propertyID
) == noErr
)
863 // variable definition and initialization:
864 DataBrowserTableViewColumnIndex columnIndex
;
866 wxCHECK_RET(this->GetColumnIndex(propertyID
,&columnIndex
),_("Column index not found."));
867 dataViewEvent
.SetColumn(columnIndex
);
868 dataViewEvent
.SetDataViewColumn(dataViewCtrlPtr
->GetColumnPtr(propertyID
));
870 // finally send the equivalent wxWidget event:
871 dataViewCtrlPtr
->HandleWindowEvent(dataViewEvent
);
874 case kDataBrowserEditStopped
:
876 // initialize wxWidget event:
877 DataBrowserPropertyID propertyID
;
878 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE
,dataViewCtrlPtr
->GetId()); // variable definition
880 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
881 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
882 if (this->GetPropertyID(itemData
,&propertyID
) == noErr
)
884 // variable definition and initialization:
885 DataBrowserTableViewColumnIndex columnIndex
;
887 wxCHECK_RET(this->GetColumnIndex(propertyID
,&columnIndex
),_("Column index not found."));
888 dataViewEvent
.SetColumn(columnIndex
);
889 dataViewEvent
.SetDataViewColumn(dataViewCtrlPtr
->GetColumnPtr(propertyID
));
891 // finally send the equivalent wxWidget event:
892 dataViewCtrlPtr
->HandleWindowEvent(dataViewEvent
);
895 case kDataBrowserItemAdded
:
896 break; // not used anymore
897 case kDataBrowserItemDeselected
:
898 break; // not implemented by wxWidgets; see kDataBrowserSelectionSetChanged
899 case kDataBrowserItemDoubleClicked
:
901 // initialize wxWidget event:
902 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED
,dataViewCtrlPtr
->GetId()); // variable definition
904 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
905 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
906 // finally send the equivalent wxWidget event:
907 dataViewCtrlPtr
->HandleWindowEvent(dataViewEvent
);
910 case kDataBrowserItemRemoved
:
911 break; // not used anymore
912 case kDataBrowserItemSelected
:
913 break; // not implemented by wxWidgets; see kDataBrowserSelectionSetChanged
914 case kDataBrowserSelectionSetChanged
:
916 // initialize wxWidget event:
917 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED
,dataViewCtrlPtr
->GetId()); // variable definition
919 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
920 dataViewEvent
.SetModel (dataViewCtrlPtr
->GetModel());
921 // finally send the equivalent wxWidget event:
922 dataViewCtrlPtr
->HandleWindowEvent(dataViewEvent
);
925 case kDataBrowserUserStateChanged
:
927 // update column widths:
928 for (size_t i
=0; i
<dataViewCtrlPtr
->GetColumnCount(); ++i
)
930 // constant definition for abbreviational purposes:
931 wxDataViewColumn
* const columnPtr
= dataViewCtrlPtr
->GetColumn(i
);
932 // variable definition:
935 wxCHECK_RET(this->GetColumnWidth(columnPtr
->GetPropertyID(),&columnWidth
) == noErr
,_("Column width could not be determined"));
936 columnPtr
->SetWidthVariable(columnWidth
);
938 // update order status:
939 DataBrowserPropertyID propertyID
; // variable definition
941 if ((this->GetSortProperty(&propertyID
) == noErr
) && (propertyID
>= kMinPropertyID
))
943 DataBrowserSortOrder sortOrder
;
944 DataBrowserTableViewColumnIndex columnIndex
;
946 if ((this->GetSortOrder(&sortOrder
) == noErr
) && (this->GetColumnIndex(propertyID
,&columnIndex
) == noErr
))
948 // variable definition and initialization:
949 wxDataViewColumn
* columnPtr
;
950 columnPtr
= dataViewCtrlPtr
->GetColumn(columnIndex
);
951 // check if the sort order has changed:
952 if ( columnPtr
->IsSortOrderAscending() && (sortOrder
== kDataBrowserOrderDecreasing
) ||
953 !(columnPtr
->IsSortOrderAscending()) && (sortOrder
== kDataBrowserOrderIncreasing
))
955 columnPtr
->SetSortOrder(!(columnPtr
->IsSortOrderAscending()));
956 // initialize wxWidget event:
957 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED
,dataViewCtrlPtr
->GetId()); // variable defintion
959 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
960 dataViewEvent
.SetColumn(columnIndex
);
961 dataViewEvent
.SetDataViewColumn(columnPtr
);
962 // finally send the equivalent wxWidget event:
963 dataViewCtrlPtr
->HandleWindowEvent(dataViewEvent
);
970 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(DataBrowserItemID, DataBrowserItemNotification, DataBrowserItemDataRef) */
973 #endif // wxUSE_DATAVIEWCTRL && !wxUSE_GENERICDATAVIEWCTRL