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
;
135 (void) this->SetAttributes(attributes
);
138 if ((style
& wxDV_NO_HEADER
) != 0)
139 this->SetHeaderButtonHeight(0);
140 } /* wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow*, wxPoint const&, wxSize const&, long) */
145 OSStatus
wxMacDataBrowserTableViewControl::SetCallbacks(DataBrowserCallbacks
const* callbacks
)
147 return ::SetDataBrowserCallbacks(this->m_controlRef
,callbacks
);
148 } /* wxMacDataBrowserTableViewControl::SetCallbacks(DataBrowserCallbacks const*) */
150 OSStatus
wxMacDataBrowserTableViewControl::SetCustomCallbacks(DataBrowserCustomCallbacks
const* customCallbacks
)
152 return ::SetDataBrowserCustomCallbacks(this->m_controlRef
,customCallbacks
);
153 } /* xMacDataBrowserTableViewControl::SetCustomCallbacks(DataBrowserCustomCallbacks const*) */
158 OSStatus
wxMacDataBrowserTableViewControl::GetHeaderDesc(DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
* desc
) const
160 desc
->version
= kDataBrowserListViewLatestHeaderDesc
; // if this statement is missing the next call will fail (NOT DOCUMENTED!!)
161 return ::GetDataBrowserListViewHeaderDesc(this->m_controlRef
,property
,desc
);
164 OSStatus
wxMacDataBrowserTableViewControl::SetHeaderDesc(DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
* desc
)
166 return ::SetDataBrowserListViewHeaderDesc(this->m_controlRef
,property
,desc
);
172 OSStatus
wxMacDataBrowserTableViewControl::AutoSizeColumns()
174 return AutoSizeDataBrowserListViewColumns(this->m_controlRef
);
177 OSStatus
wxMacDataBrowserTableViewControl::EnableCellSizeModification(bool enableHeight
, bool enableWidth
)
179 return ::SetDataBrowserTableViewGeometry(this->GetControlRef(),enableWidth
,enableHeight
);
180 } /* wxMacDataBrowserTableViewControl::EnableCellSizeModification(bool, bool) */
182 OSStatus
wxMacDataBrowserTableViewControl::GetAttributes(OptionBits
* attributes
)
184 return ::DataBrowserGetAttributes(this->GetControlRef(),attributes
);
185 } /* wxMacDataBrowserTableViewControl::GetAttributes(OptionBits*) */
187 OSStatus
wxMacDataBrowserTableViewControl::GetColumnWidth(DataBrowserPropertyID propertyID
, UInt16
* width
) const
189 return ::GetDataBrowserTableViewNamedColumnWidth(this->m_controlRef
,propertyID
,width
);
192 OSStatus
wxMacDataBrowserTableViewControl::GetDefaultColumnWidth( UInt16
*width
) const
194 return GetDataBrowserTableViewColumnWidth(this->m_controlRef
, width
);
197 OSStatus
wxMacDataBrowserTableViewControl::GetDefaultRowHeight(UInt16
* height
) const
199 return ::GetDataBrowserTableViewRowHeight(this->m_controlRef
,height
);
202 OSStatus
wxMacDataBrowserTableViewControl::GetHeaderButtonHeight(UInt16
*height
)
204 return ::GetDataBrowserListViewHeaderBtnHeight(this->m_controlRef
,height
);
207 OSStatus
wxMacDataBrowserTableViewControl::GetPartBounds(DataBrowserItemID item
, DataBrowserPropertyID property
, DataBrowserPropertyPart part
, Rect
* bounds
)
209 return ::GetDataBrowserItemPartBounds(this->m_controlRef
,item
,property
,part
,bounds
);
210 } /* wxMacDataBrowserTableViewControl::GetPartBounds(DataBrowserItemID, DataBrowswerPropertyID, DataBrowserPropertyPart, Rect*) */
212 OSStatus
wxMacDataBrowserTableViewControl::GetRowHeight(DataBrowserItemID item
, UInt16
* height
) const
214 return ::GetDataBrowserTableViewItemRowHeight(this->m_controlRef
,item
,height
);
215 } /* wxMacDataBrowserTableViewControl::GetRowHeight(DataBrowserItemID, UInt16*) const */
217 OSStatus
wxMacDataBrowserTableViewControl::GetScrollPosition( UInt32
*top
, UInt32
*left
) const
219 return GetDataBrowserScrollPosition(this->m_controlRef
, top
, left
);
222 OSStatus
wxMacDataBrowserTableViewControl::SetAttributes(OptionBits attributes
)
224 return ::DataBrowserChangeAttributes(this->GetControlRef(),attributes
,~attributes
);
225 } /* wxMacDataBrowserTableViewControl::SetAttributes(OptionBits) */
227 OSStatus
wxMacDataBrowserTableViewControl::SetColumnWidth(DataBrowserPropertyID propertyID
, UInt16 width
)
229 return ::SetDataBrowserTableViewNamedColumnWidth(this->m_controlRef
,propertyID
,width
);
232 OSStatus
wxMacDataBrowserTableViewControl::SetDefaultColumnWidth(UInt16 width
)
234 return ::SetDataBrowserTableViewColumnWidth(this->m_controlRef
,width
);
237 OSStatus
wxMacDataBrowserTableViewControl::SetDefaultRowHeight(UInt16 height
)
239 return ::SetDataBrowserTableViewRowHeight(this->m_controlRef
,height
);
242 OSStatus
wxMacDataBrowserTableViewControl::SetHasScrollBars(bool horiz
, bool vert
)
244 return ::SetDataBrowserHasScrollBars(this->m_controlRef
,horiz
,vert
);
245 } /* wxMacDataBrowserTableViewControl::SetHasScrollBars(bool, bool) */
247 OSStatus
wxMacDataBrowserTableViewControl::SetHeaderButtonHeight(UInt16 height
)
249 return ::SetDataBrowserListViewHeaderBtnHeight(this->m_controlRef
,height
);
250 } /* wxMacDataBrowserTableViewControl::SetHeaderButtonHeight(UInt16) */
252 OSStatus
wxMacDataBrowserTableViewControl::SetHiliteStyle(DataBrowserTableViewHiliteStyle hiliteStyle
)
254 return ::SetDataBrowserTableViewHiliteStyle(this->m_controlRef
,hiliteStyle
);
255 } /*wxMacDataBrowserTableViewControl::SetHiliteStyle(DataBrowserTableViewHiliteStyle) */
257 OSStatus
wxMacDataBrowserTableViewControl::SetIndent(float Indent
)
259 return ::DataBrowserSetMetric(this->m_controlRef
,kDataBrowserMetricDisclosureColumnPerDepthGap
,true,Indent
);
260 } /* wxMacDataBrowserTableViewControl::SetIndent(float* Indent) */
262 OSStatus
wxMacDataBrowserTableViewControl::SetRowHeight(DataBrowserItemID item
, UInt16 height
)
264 return ::SetDataBrowserTableViewItemRowHeight(this->m_controlRef
,item
,height
);
267 OSStatus
wxMacDataBrowserTableViewControl::SetScrollPosition(UInt32 top
, UInt32 left
)
269 return ::SetDataBrowserScrollPosition(this->m_controlRef
,top
,left
);
275 OSStatus
wxMacDataBrowserTableViewControl::GetColumnCount(UInt32
* numColumns
) const
277 return ::GetDataBrowserTableViewColumnCount(this->m_controlRef
,numColumns
);
280 OSStatus
wxMacDataBrowserTableViewControl::GetColumnIndex(DataBrowserPropertyID propertyID
, DataBrowserTableViewColumnIndex
* index
) const
282 return ::GetDataBrowserTableViewColumnPosition(this->m_controlRef
,propertyID
,index
);
283 } /* wxMacDataBrowserTableViewControl::GetColumnIndex(DataBrowserPropertyID, DataBrowserTableViewColumnIndex*) const */
285 OSStatus
wxMacDataBrowserTableViewControl::GetFreePropertyID(DataBrowserPropertyID
* propertyID
) const
287 for (*propertyID
=kMinPropertyID
; *propertyID
<std::numeric_limits
<DataBrowserPropertyID
>::max(); ++(*propertyID
))
288 if (this->IsUsedPropertyID(*propertyID
) == errDataBrowserPropertyNotFound
)
290 return errDataBrowserPropertyNotSupported
;
291 } /* wxMacDataBrowserTableViewControl::GetFreePropertyID(DataBrowserPropertyID*) const */
293 OSStatus
wxMacDataBrowserTableViewControl::GetPropertyFlags(DataBrowserPropertyID propertyID
, DataBrowserPropertyFlags
*flags
) const
295 return ::GetDataBrowserPropertyFlags(this->m_controlRef
,propertyID
,flags
);
298 OSStatus
wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserItemDataRef itemData
, DataBrowserPropertyID
* propertyID
)
300 return ::GetDataBrowserItemDataProperty(itemData
,propertyID
);
301 } /* wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserItemDataRef, DataBrowserPropertyID*) */
303 OSStatus
wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserTableViewColumnIndex index
, DataBrowserTableViewColumnID
* propertyID
)
305 return ::GetDataBrowserTableViewColumnProperty(this->m_controlRef
,index
,propertyID
);
306 } /* wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserTableViewColumnIndex, DataBrowserTableViewColumnID*) */
308 OSStatus
wxMacDataBrowserTableViewControl::IsUsedPropertyID(DataBrowserPropertyID propertyID
) const
310 // 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
311 // 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
312 // the column position for the property id:
313 DataBrowserTableViewColumnIndex index
;
315 return ::GetDataBrowserTableViewColumnPosition(this->m_controlRef
,propertyID
,&index
);
316 } /* wxMacDataBrowserTableViewControl::IsUsedPropertyId(DataBrowserPropertyID) const */
318 OSStatus
wxMacDataBrowserTableViewControl::RemoveColumnByProperty(DataBrowserTableViewColumnID propertyID
)
320 return ::RemoveDataBrowserTableViewColumn(this->m_controlRef
,propertyID
);
321 } /* wxMacDataBrowserTableViewControl::RemoveColumnByProperty(DataBrowserTableViewColumnID) */
323 OSStatus
wxMacDataBrowserTableViewControl::RemoveColumnByIndex(DataBrowserTableViewColumnIndex index
)
325 DataBrowserTableViewColumnID propertyID
;
328 this->GetPropertyID(index
,&propertyID
);
329 return ::RemoveDataBrowserTableViewColumn(this->m_controlRef
,propertyID
);
330 } /* wxMacDataBrowserTableViewControl::RemoveColumnByIndex(DataBrowserTableViewColumnIndex) */
332 OSStatus
wxMacDataBrowserTableViewControl::SetColumnIndex(DataBrowserPropertyID propertyID
, DataBrowserTableViewColumnIndex index
)
334 return ::SetDataBrowserTableViewColumnPosition(this->m_controlRef
,propertyID
,index
);
335 } /* wxMacDataBrowserTableViewControl::SetColumnIndex(DataBrowserPropertyID, DataBrowserTableViewColumnIndex) */
337 OSStatus
wxMacDataBrowserTableViewControl::SetDisclosureColumn(DataBrowserPropertyID propertyID
, Boolean expandableRows
)
339 return ::SetDataBrowserListViewDisclosureColumn(this->m_controlRef
,propertyID
,expandableRows
);
342 OSStatus
wxMacDataBrowserTableViewControl::SetPropertyFlags(DataBrowserPropertyID propertyID
, DataBrowserPropertyFlags flags
)
344 return ::SetDataBrowserPropertyFlags(this->m_controlRef
,propertyID
,flags
);
345 } /* wxMacDataBrowserTableViewControl::SetPropertyFlags(DataBrowserPropertyID, DataBrowserPropertyFlags) */
350 OSStatus
wxMacDataBrowserTableViewControl::AddItems(DataBrowserItemID container
, UInt32 numItems
, DataBrowserItemID
const* items
, DataBrowserPropertyID preSortProperty
)
352 return ::AddDataBrowserItems(this->m_controlRef
,container
,numItems
,items
,preSortProperty
);
353 } /* wxMacDataBrowserTableViewControl::AddItems(DataBrowserItemID, UInt32, DataBrowserItemID const*, DataBrowserPropertyID) */
355 OSStatus
wxMacDataBrowserTableViewControl::GetFreeItemID(DataBrowserItemID
* id
) const
360 verify_noerr(this->GetItemCount(&NoOfItems
));
368 // 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
369 // as the number of items; therefore, start from the number of items to look for a new ID:
370 for (*id
=NoOfItems
; *id
<std::numeric_limits
<DataBrowserItemID
>::max(); ++(*id
))
371 if (this->IsUsedItemID(*id
) == errDataBrowserItemNotFound
)
373 // as the first approach was not successful, try from the beginning:
374 for (*id
=0; *id
<NoOfItems
; ++(*id
))
375 if (this->IsUsedItemID(*id
) == errDataBrowserItemNotFound
)
377 // sorry, data browser is full:
378 return errDataBrowserItemNotAdded
;
380 } /* wxMacDataBrowserTableViewControl::GetFreeItemID(DataBrowserItemID*) const */
382 OSStatus
wxMacDataBrowserTableViewControl::GetItemCount(DataBrowserItemID container
, Boolean recurse
, DataBrowserItemState state
, ItemCount
* numItems
) const
384 return GetDataBrowserItemCount(this->m_controlRef
,container
,recurse
,state
,numItems
);
385 } /* wxMacDataBrowserTableViewControl::GetItemCount(DataBrowserItemID, Boolean, DataBrowserItemState, ItemCount*) const */
387 OSStatus
wxMacDataBrowserTableViewControl::GetItemID( DataBrowserTableViewRowIndex row
, DataBrowserItemID
* item
) const
389 return GetDataBrowserTableViewItemID(this->m_controlRef
,row
,item
);
392 OSStatus
wxMacDataBrowserTableViewControl::GetItems(DataBrowserItemID container
, Boolean recurse
, DataBrowserItemState state
, Handle items
) const
394 return GetDataBrowserItems(this->m_controlRef
,container
,recurse
,state
,items
);
395 } /* wxMacDataBrowserTableViewControl::GetItems(DataBrowserItemID, Boolean, DataBrowserItemState, Handle) const */
397 OSStatus
wxMacDataBrowserTableViewControl::GetItemRow(DataBrowserItemID item
, DataBrowserTableViewRowIndex
* row
) const
399 return GetDataBrowserTableViewItemRow(this->m_controlRef
,item
,row
);
402 OSStatus
wxMacDataBrowserTableViewControl::IsUsedItemID(DataBrowserItemID itemID
) const
404 // 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
405 // 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
406 // the column position for the property id:
407 DataBrowserTableViewColumnIndex index
;
409 return ::GetDataBrowserTableViewItemRow(this->m_controlRef
,itemID
,&index
);
410 } /* wxMacDataBrowserTableViewControl::IsUsedItemID(DataBrowserItemID) const */
412 OSStatus
wxMacDataBrowserTableViewControl::RemoveItems(DataBrowserItemID container
, UInt32 numItems
, DataBrowserItemID
const* items
, DataBrowserPropertyID preSortProperty
)
414 return ::RemoveDataBrowserItems(this->m_controlRef
,container
,numItems
,items
,preSortProperty
);
417 OSStatus
wxMacDataBrowserTableViewControl::RevealItem(DataBrowserItemID item
, DataBrowserPropertyID propertyID
, DataBrowserRevealOptions options
) const
419 return ::RevealDataBrowserItem(this->m_controlRef
,item
,propertyID
,options
);
420 } /* wxMacDataBrowserTableViewControl::RevealItem(DataBrowserItemID item, DataBrowserPropertyID propertyID, DataBrowserRevealOptions options) const */
422 OSStatus
wxMacDataBrowserTableViewControl::UpdateItems(DataBrowserItemID container
, UInt32 numItems
, DataBrowserItemID
const* items
, DataBrowserPropertyID preSortProperty
,
423 DataBrowserPropertyID propertyID
) const
425 return UpdateDataBrowserItems(this->m_controlRef
,container
,numItems
,items
,preSortProperty
,propertyID
);
431 size_t wxMacDataBrowserTableViewControl::GetSelectedItemIDs(wxArrayDataBrowserItemID
& itemIDs
) const
433 DataBrowserItemID
* itemIDPtr
;
434 Handle
handle(::NewHandle(0));
439 wxCHECK_MSG(this->GetItems(kDataBrowserNoItem
,true,kDataBrowserItemIsSelected
,handle
) == noErr
,0,_("Could not get selected items."));
440 NoOfItems
= static_cast<size_t>(::GetHandleSize(handle
)/sizeof(DataBrowserItemID
));
442 itemIDs
.Alloc(NoOfItems
);
444 itemIDPtr
= (DataBrowserItemID
*) (*handle
);
445 for (size_t i
=0; i
<NoOfItems
; ++i
)
447 itemIDs
.Add(*itemIDPtr
);
451 DisposeHandle(handle
);
453 } /* wxMacDataBrowserTableViewControl::GetSelectedItemIDs(wxArrayDataBrowserItemID&) const*/
455 OSStatus
wxMacDataBrowserTableViewControl::GetSelectionAnchor(DataBrowserItemID
* first
, DataBrowserItemID
* last
) const
457 return ::GetDataBrowserSelectionAnchor(this->m_controlRef
,first
,last
);
458 } /* wxMacDataBrowserTableViewControl::GetSelectionAnchor(DataBrowserItemID*, DataBrowserItemID*) const */
460 OSStatus
wxMacDataBrowserTableViewControl::GetSelectionFlags(DataBrowserSelectionFlags
* flags
) const
462 return ::GetDataBrowserSelectionFlags(this->m_controlRef
,flags
);
463 } /* wxMacDataBrowserTableViewControl::GetSelectionFlags(DataBrowserSelectionFlags*) const */
465 bool wxMacDataBrowserTableViewControl::IsItemSelected(DataBrowserItemID item
) const
467 return ::IsDataBrowserItemSelected(this->m_controlRef
,item
);
468 } /* wxMacDataBrowserTableViewControl::IsItemSelected(DataBrowserItemID) const */
470 OSStatus
wxMacDataBrowserTableViewControl::SetSelectionFlags(DataBrowserSelectionFlags flags
)
472 return ::SetDataBrowserSelectionFlags(this->m_controlRef
,flags
);
473 } /* wxMacDataBrowserTableViewControl::SetSelectionFlags(DataBrowserSelectionFlags) */
475 OSStatus
wxMacDataBrowserTableViewControl::SetSelectedItems(UInt32 numItems
, DataBrowserItemID
const* items
, DataBrowserSetOption operation
)
477 return ::SetDataBrowserSelectedItems(this->m_controlRef
, numItems
, items
, operation
);
478 } /* wxMacDataBrowserTableViewControl::SetSelectedItems(UInt32, DataBrowserItemID const*, DataBrowserSetOption) */
480 OSStatus
wxMacDataBrowserTableViewControl::GetSortOrder(DataBrowserSortOrder
* order
) const
482 return ::GetDataBrowserSortOrder(this->m_controlRef
,order
);
485 OSStatus
wxMacDataBrowserTableViewControl::GetSortProperty(DataBrowserPropertyID
* propertyID
) const
487 return ::GetDataBrowserSortProperty(this->m_controlRef
,propertyID
);
490 OSStatus
wxMacDataBrowserTableViewControl::Resort(DataBrowserItemID container
, Boolean sortChildren
)
492 return ::SortDataBrowserContainer(this->m_controlRef
,container
,sortChildren
);
493 } /* wxMacDataBrowserTableViewControl::Resort(DataBrowserItemID, Boolean) */
495 OSStatus
wxMacDataBrowserTableViewControl::SetSortOrder(DataBrowserSortOrder order
)
497 return ::SetDataBrowserSortOrder(this->m_controlRef
,order
);
500 OSStatus
wxMacDataBrowserTableViewControl::SetSortProperty(DataBrowserPropertyID propertyID
)
502 return ::SetDataBrowserSortProperty(this->m_controlRef
,propertyID
);
506 // container handling
508 OSStatus
wxMacDataBrowserTableViewControl::CloseContainer(DataBrowserItemID containerID
)
510 return ::CloseDataBrowserContainer(this->m_controlRef
,containerID
);
511 } /* wxMacDataBrowserTableViewControl::CloseContainer(DataBrowserItemID) */
513 OSStatus
wxMacDataBrowserTableViewControl::OpenContainer(DataBrowserItemID containerID
)
515 return ::OpenDataBrowserContainer(this->m_controlRef
,containerID
);
516 } /* wxMacDataBrowserTableViewControl::OpenContainer(DataBrowserItemID) */
518 IMPLEMENT_ABSTRACT_CLASS(wxMacDataBrowserTableViewControl
,wxMacControl
)
520 // ============================================================================
521 // wxMacDataBrowserListViewControl
522 // ============================================================================
527 OSStatus
wxMacDataBrowserListViewControl::AddColumn(DataBrowserListViewColumnDesc
*columnDesc
, DataBrowserTableViewColumnIndex position
)
529 return AddDataBrowserListViewColumn(this->m_controlRef
,columnDesc
,position
);
530 } /* wxMacDataBrowserListViewControl::AddColumn(DataBrowserListViewColumnDesc*, DataBrowserTableViewColumnIndex) */
532 // ============================================================================
533 // wxMacDataViewDataBrowserListViewControl
534 // ============================================================================
537 // constructors / destructor
539 wxMacDataViewDataBrowserListViewControl::wxMacDataViewDataBrowserListViewControl(wxWindow
* peer
, wxPoint
const& pos
, wxSize
const& size
, long style
)
540 :wxMacDataBrowserListViewControl(peer
,pos
,size
,style
)
542 } /* wxMacDataViewDataBrowserListViewControl::wxMacDataViewDataBrowserListViewControl(wxWindow* , const wxPoint&, const wxSize&, long) */
545 // callback functions (inherited from wxMacDataBrowserTableViewControl)
547 Boolean
wxMacDataViewDataBrowserListViewControl::DataBrowserCompareProc(DataBrowserItemID itemOneID
, DataBrowserItemID itemTwoID
, DataBrowserPropertyID sortProperty
)
549 DataBrowserSortOrder sortOrder
;
551 DataBrowserTableViewColumnIndex columnIndex
;
553 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
556 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
, false,_("Pointer to data view control not set correctly."));
557 wxCHECK_MSG(dataViewCtrlPtr
->GetModel() != NULL
,false,_("Pointer to model not set correctly."));
558 if (sortProperty
>= kMinPropertyID
)
560 wxCHECK_MSG(this->GetColumnIndex(sortProperty
,&columnIndex
) == noErr
,false,_("Could not determine column index."));
564 this->GetSortOrder(&sortOrder
);
565 return static_cast<Boolean
>(dataViewCtrlPtr
->GetModel()->Compare(wxDataViewItem(reinterpret_cast<void*>(itemOneID
)),wxDataViewItem(reinterpret_cast<void*>(itemTwoID
)),
566 columnIndex
,sortOrder
!= kDataBrowserOrderDecreasing
) < 0);
567 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserCompareProc(DataBrowserItemID, DataBrowserItemID, DataBrowserPropertyID) */
569 void wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowserItemID itemID
, DataBrowserPropertyID propertyID
, DataBrowserItemState state
, Rect
const* rectangle
, SInt16 bitDepth
, Boolean colorDevice
)
571 DataBrowserTableViewColumnIndex columnIndex
;
573 wxDataViewColumn
* dataViewColumnPtr
;
575 wxDataViewCtrl
* dataViewCtrlPtr
;
577 wxDataViewCustomRenderer
* dataViewCustomRendererPtr
;
579 wxVariant dataToRender
;
581 dataViewCtrlPtr
= dynamic_cast<wxDataViewCtrl
*>(this->GetPeer());
582 wxCHECK_RET(dataViewCtrlPtr
!= NULL
, _("Pointer to data view control not set correctly."));
583 wxCHECK_RET(dataViewCtrlPtr
->GetModel() != NULL
, _("Pointer to model not set correctly."));
584 wxCHECK_RET(this->GetColumnIndex(propertyID
,&columnIndex
) == noErr
,_("Could not determine column index."));
585 dataViewColumnPtr
= dataViewCtrlPtr
->GetColumn(columnIndex
);
586 wxCHECK_RET(dataViewColumnPtr
!= NULL
,_("No column for the specified column index existing."));
587 dataViewCustomRendererPtr
= dynamic_cast<wxDataViewCustomRenderer
*>(dataViewColumnPtr
->GetRenderer());
588 wxCHECK_RET(dataViewCustomRendererPtr
!= NULL
,_("No renderer or invalid renderer type specified for custom data column."));
590 wxDataViewItem
dataitem( reinterpret_cast<void*>(itemID
) );
591 dataViewCtrlPtr
->GetModel()->GetValue(dataToRender
,dataitem
,columnIndex
);
592 dataViewCustomRendererPtr
->SetValue(dataToRender
);
594 // try to determine the content's size (drawable part):
596 RgnHandle
rgn(NewRgn());
599 if (this->GetRegion(kControlContentMetaPart
,rgn
) == noErr
)
600 GetRegionBounds(rgn
,&content
);
602 this->GetRect(&content
);
604 // space for the header
605 this->GetHeaderButtonHeight(&headerHeight
);
606 content
.top
+= headerHeight
;
607 // extra space for the frame (todo: do not how to determine the space automatically from the control)
612 // extra space for the scrollbars:
613 content
.bottom
-= wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y
);
614 content
.right
-= wxSystemSettings::GetMetric(wxSYS_VSCROLL_X
);
616 wxDC
*dc
= dataViewCustomRendererPtr
->GetDC();
618 wxRect
cellrect( static_cast<int>(rectangle
->left
),
619 static_cast<int>(rectangle
->top
+2),
620 static_cast<int>(1+rectangle
->right
-rectangle
->left
),
621 static_cast<int>(rectangle
->bottom
-rectangle
->top
) );
623 bool is_active
= IsControlActive( this->m_controlRef
);
624 if (state
== kDataBrowserItemIsSelected
)
627 wxColour
col( wxMacCreateCGColorFromHITheme( (is_active
) ?
628 kThemeBrushAlternatePrimaryHighlightColor
629 : kThemeBrushSecondaryHighlightColor
) );
631 wxRect rect
= cellrect
;
633 GetDataBrowserItemPartBounds( this->m_controlRef
, itemID
, propertyID
,
634 kDataBrowserPropertyEnclosingPart
, &itemrect
);
635 rect
.x
= itemrect
.left
;
636 rect
.width
= itemrect
.right
-itemrect
.left
+1;
638 wxBrush
selBrush( col
);
639 wxPen
oldpen( dc
->GetPen() );
640 wxBrush
oldbrush( dc
->GetBrush() );
641 dc
->SetPen( *wxTRANSPARENT_PEN
);
642 dc
->SetBrush( selBrush
);
643 dc
->DrawRectangle(rect
);
644 dc
->SetBrush( oldbrush
);
645 dc
->SetPen( oldpen
);
648 wxDataViewModel
*model
= dataViewCtrlPtr
->GetModel();
649 if ((columnIndex
== 0) || !model
->IsContainer(dataitem
) || model
->HasContainerColumns(dataitem
))
651 // make sure that 'Render' can draw only in the allowed area:
652 dc
->SetClippingRegion(content
.left
,content
.top
,content
.right
-content
.left
+1,content
.bottom
-content
.top
+1);
653 (void) (dataViewCustomRendererPtr
->Render( cellrect
, dc
,
654 ((state
== kDataBrowserItemIsSelected
) ? wxDATAVIEW_CELL_SELECTED
: 0)));
655 dc
->DestroyClippingRegion(); // probably not necessary
658 dataViewCustomRendererPtr
->SetDC(NULL
);
659 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemState, Rect const*, SInt16, Boolean) */
661 OSStatus
wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(DataBrowserItemID itemID
, DataBrowserPropertyID propertyID
, DataBrowserItemDataRef itemData
, Boolean getValue
)
665 // variable definitions:
666 wxDataViewCtrl
* dataViewCtrlPtr
;
668 dataViewCtrlPtr
= dynamic_cast<wxDataViewCtrl
*>(this->GetPeer());
669 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
,errDataBrowserNotConfigured
,_("Pointer to data view control not set correctly."));
670 if (dataViewCtrlPtr
->IsDeleting())
671 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
674 // variable definitions:
675 DataBrowserTableViewColumnIndex columnIndex
;
676 OSStatus errorStatus
;
677 wxDataViewColumn
* dataViewColumnPtr
;
679 wxCHECK_MSG(dataViewCtrlPtr
->GetModel() != NULL
,errDataBrowserNotConfigured
,_("Pointer to model not set correctly."));
680 errorStatus
= this->GetColumnIndex(propertyID
,&columnIndex
);
681 wxCHECK_MSG(errorStatus
== noErr
,errorStatus
,_("Could not determine column index"));
682 dataViewColumnPtr
= dataViewCtrlPtr
->GetColumn(columnIndex
);
683 wxCHECK_MSG((dataViewColumnPtr
!= NULL
) && (dataViewColumnPtr
->GetRenderer() != NULL
),errDataBrowserNotConfigured
,_("There is no column or renderer for the specified column index."));
684 switch (dataViewColumnPtr
->GetRenderer()->GetPropertyType())
686 case kDataBrowserCheckboxType
:
688 // variable definition:
689 ThemeButtonValue buttonValue
;
691 errorStatus
= ::GetDataBrowserItemDataButtonValue(itemData
,&buttonValue
);
692 if (errorStatus
== noErr
)
694 if (buttonValue
== kThemeButtonOn
)
696 // variable definition and initialization:
697 wxVariant
modifiedData(true);
699 return (dataViewCtrlPtr
->GetModel()->SetValue(modifiedData
,wxDataViewItem(reinterpret_cast<void*>(itemID
)),static_cast<unsigned int>(columnIndex
)) ? OSStatus(noErr
) : OSStatus(errDataBrowserNotConfigured
));
701 else if (buttonValue
== kThemeButtonOff
)
703 // variable definition and initialization:
704 wxVariant
modifiedData(false);
706 return (dataViewCtrlPtr
->GetModel()->SetValue(modifiedData
,wxDataViewItem(reinterpret_cast<void*>(itemID
)),static_cast<unsigned int>(columnIndex
)) ? OSStatus(noErr
) : OSStatus(errDataBrowserNotConfigured
));
709 return errDataBrowserInvalidPropertyData
;
714 case kDataBrowserTextType
:
716 // variable definitions:
717 CFStringRef stringReference
;
719 errorStatus
= ::GetDataBrowserItemDataText(itemData
,&stringReference
);
720 if (errorStatus
== noErr
)
722 // variable definitions and initializations:
723 wxCFStringRef
modifiedString(stringReference
);
724 wxVariant
modifiedData(modifiedString
.AsString());
726 if (dataViewCtrlPtr
->GetModel()->SetValue(modifiedData
,wxDataViewItem(reinterpret_cast<void*>(itemID
)),static_cast<unsigned int>(columnIndex
)))
729 return errDataBrowserNotConfigured
;
735 return errDataBrowserPropertyNotSupported
;
741 if (propertyID
>= kMinPropertyID
) // in case data columns set the data
743 // variable definitions:
745 wxDataViewColumn
* dataViewColumnPtr
;
746 wxDataViewCtrl
* dataViewCtrlPtr
;
748 dataViewCtrlPtr
= dynamic_cast<wxDataViewCtrl
*>(this->GetPeer());
749 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
,errDataBrowserNotConfigured
,_("Pointer to data view control not set correctly."));
750 wxCHECK_MSG(dataViewCtrlPtr
->GetModel() != NULL
,errDataBrowserNotConfigured
,_("Pointer to model not set correctly."));
751 dataViewColumnPtr
= dataViewCtrlPtr
->GetColumnPtr(propertyID
);
752 wxCHECK_MSG(dataViewColumnPtr
!= NULL
,errDataBrowserNotConfigured
,_("No column for the specified column position existing."));
753 wxCHECK_MSG(dataViewColumnPtr
->GetRenderer() != NULL
,errDataBrowserNotConfigured
,_("No renderer specified for column."));
754 dataViewCtrlPtr
->GetModel()->GetValue(variant
,wxDataViewItem(reinterpret_cast<void*>(itemID
)),dataViewColumnPtr
->GetModelColumn());
755 if (!(variant
.IsNull()))
757 dataViewColumnPtr
->GetRenderer()->SetDataReference(itemData
);
758 dataViewColumnPtr
->GetRenderer()->SetValue(variant
);
759 wxCHECK_MSG(dataViewColumnPtr
->GetRenderer()->Render(),errDataBrowserNotConfigured
,_("Rendering failed."));
763 else // react on special system requests
767 case kDataBrowserContainerIsClosableProperty
:
769 // variable definitions:
770 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
772 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
,errDataBrowserNotConfigured
,_("Pointer to data view control not set correctly."));
773 // initialize wxWidget event:
774 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING
,dataViewCtrlPtr
->GetId()); // variable definition
776 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
777 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
778 // finally send the equivalent wxWidget event:
779 dataViewCtrlPtr
->HandleWindowEvent(dataViewEvent
);
780 // opening the container is allowed if not vetoed:
781 return ::SetDataBrowserItemDataBooleanValue(itemData
,dataViewEvent
.IsAllowed());
783 case kDataBrowserContainerIsOpenableProperty
:
785 // variable definitions:
786 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
788 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
,errDataBrowserNotConfigured
,_("Pointer to data view control not set correctly."));
789 // initialize wxWidget event:
790 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING
,dataViewCtrlPtr
->GetId()); // variable definition
792 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
793 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
794 // finally send the equivalent wxWidget event:
795 dataViewCtrlPtr
->HandleWindowEvent(dataViewEvent
);
796 // opening the container is allowed if not vetoed:
797 return ::SetDataBrowserItemDataBooleanValue(itemData
,dataViewEvent
.IsAllowed());
799 case kDataBrowserItemIsContainerProperty
:
801 // variable definition:
802 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
804 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
,errDataBrowserNotConfigured
,_("Pointer to data view control not set correctly."));
805 wxCHECK_MSG(dataViewCtrlPtr
->GetModel() != NULL
,errDataBrowserNotConfigured
,_("Pointer to model not set correctly."));
806 return ::SetDataBrowserItemDataBooleanValue(itemData
,dataViewCtrlPtr
->GetModel()->IsContainer(wxDataViewItem(reinterpret_cast<void*>(itemID
))));
808 case kDataBrowserItemIsEditableProperty
:
809 return ::SetDataBrowserItemDataBooleanValue(itemData
,true);
813 return errDataBrowserPropertyNotSupported
;
814 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemDataRef, Boolean) */
816 void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(DataBrowserItemID itemID
, DataBrowserItemNotification message
, DataBrowserItemDataRef itemData
)
818 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
821 // 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:
822 if (dataViewCtrlPtr
!= NULL
)
825 case kDataBrowserContainerClosed
:
827 // initialize wxWidget event:
828 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED
,dataViewCtrlPtr
->GetId()); // variable definition
830 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
831 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
832 // finally send the equivalent wxWidget event:
833 dataViewCtrlPtr
->HandleWindowEvent(dataViewEvent
);
836 case kDataBrowserContainerOpened
:
838 // initialize wxWidget event:
839 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED
,dataViewCtrlPtr
->GetId()); // variable definition
841 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
842 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
843 // finally send the equivalent wxWidget event:
844 dataViewCtrlPtr
->HandleWindowEvent(dataViewEvent
);
845 // add children to the expanded container:
846 dataViewCtrlPtr
->AddChildrenLevel(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
849 case kDataBrowserEditStarted
:
851 // initialize wxWidget event:
852 DataBrowserPropertyID propertyID
;
853 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED
,dataViewCtrlPtr
->GetId()); // variable definition
855 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
856 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
857 if (this->GetPropertyID(itemData
,&propertyID
) == noErr
)
859 // variable definition and initialization:
860 DataBrowserTableViewColumnIndex columnIndex
;
862 wxCHECK_RET(this->GetColumnIndex(propertyID
,&columnIndex
),_("Column index not found."));
863 dataViewEvent
.SetColumn(columnIndex
);
864 dataViewEvent
.SetDataViewColumn(dataViewCtrlPtr
->GetColumnPtr(propertyID
));
866 // finally send the equivalent wxWidget event:
867 dataViewCtrlPtr
->HandleWindowEvent(dataViewEvent
);
870 case kDataBrowserEditStopped
:
872 // initialize wxWidget event:
873 DataBrowserPropertyID propertyID
;
874 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE
,dataViewCtrlPtr
->GetId()); // variable definition
876 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
877 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
878 if (this->GetPropertyID(itemData
,&propertyID
) == noErr
)
880 // variable definition and initialization:
881 DataBrowserTableViewColumnIndex columnIndex
;
883 wxCHECK_RET(this->GetColumnIndex(propertyID
,&columnIndex
),_("Column index not found."));
884 dataViewEvent
.SetColumn(columnIndex
);
885 dataViewEvent
.SetDataViewColumn(dataViewCtrlPtr
->GetColumnPtr(propertyID
));
887 // finally send the equivalent wxWidget event:
888 dataViewCtrlPtr
->HandleWindowEvent(dataViewEvent
);
891 case kDataBrowserItemAdded
:
892 break; // not used anymore
893 case kDataBrowserItemDeselected
:
894 break; // not implemented by wxWidgets; see kDataBrowserSelectionSetChanged
895 case kDataBrowserItemDoubleClicked
:
897 // initialize wxWidget event:
898 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED
,dataViewCtrlPtr
->GetId()); // variable definition
900 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
901 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
902 // finally send the equivalent wxWidget event:
903 dataViewCtrlPtr
->HandleWindowEvent(dataViewEvent
);
906 case kDataBrowserItemRemoved
:
907 break; // not used anymore
908 case kDataBrowserItemSelected
:
909 break; // not implemented by wxWidgets; see kDataBrowserSelectionSetChanged
910 case kDataBrowserSelectionSetChanged
:
912 // initialize wxWidget event:
913 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED
,dataViewCtrlPtr
->GetId()); // variable definition
915 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
916 dataViewEvent
.SetModel (dataViewCtrlPtr
->GetModel());
917 // finally send the equivalent wxWidget event:
918 dataViewCtrlPtr
->HandleWindowEvent(dataViewEvent
);
921 case kDataBrowserUserStateChanged
:
923 // update column widths:
924 for (size_t i
=0; i
<dataViewCtrlPtr
->GetColumnCount(); ++i
)
926 // constant definition for abbreviational purposes:
927 wxDataViewColumn
* const columnPtr
= dataViewCtrlPtr
->GetColumn(i
);
928 // variable definition:
931 wxCHECK_RET(this->GetColumnWidth(columnPtr
->GetPropertyID(),&columnWidth
) == noErr
,_("Column width could not be determined"));
932 columnPtr
->SetWidthVariable(columnWidth
);
934 // update order status:
935 DataBrowserPropertyID propertyID
; // variable definition
937 if ((this->GetSortProperty(&propertyID
) == noErr
) && (propertyID
>= kMinPropertyID
))
939 DataBrowserSortOrder sortOrder
;
940 DataBrowserTableViewColumnIndex columnIndex
;
942 if ((this->GetSortOrder(&sortOrder
) == noErr
) && (this->GetColumnIndex(propertyID
,&columnIndex
) == noErr
))
944 // variable definition and initialization:
945 wxDataViewColumn
* columnPtr
;
946 columnPtr
= dataViewCtrlPtr
->GetColumn(columnIndex
);
947 // check if the sort order has changed:
948 if ( columnPtr
->IsSortOrderAscending() && (sortOrder
== kDataBrowserOrderDecreasing
) ||
949 !(columnPtr
->IsSortOrderAscending()) && (sortOrder
== kDataBrowserOrderIncreasing
))
951 columnPtr
->SetSortOrder(!(columnPtr
->IsSortOrderAscending()));
952 // initialize wxWidget event:
953 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED
,dataViewCtrlPtr
->GetId()); // variable defintion
955 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
956 dataViewEvent
.SetColumn(columnIndex
);
957 dataViewEvent
.SetDataViewColumn(columnPtr
);
958 // finally send the equivalent wxWidget event:
959 dataViewCtrlPtr
->HandleWindowEvent(dataViewEvent
);
966 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(DataBrowserItemID, DataBrowserItemNotification, DataBrowserItemDataRef) */
969 #endif // wxUSE_DATAVIEWCTRL && !wxUSE_GENERICDATAVIEWCTRL