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
15 #if !defined(wxUSE_GENERICDATAVIEWCTRL) || wxUSE_GENERICDATAVIEWCTRL == 0
19 #include "wx/toplevel.h"
21 #include "wx/settings.h"
24 #include "wx/dataview.h"
27 #include "wx/mac/private.h"
28 #include "wx/mac/carbon/databrow.h"
29 #include "wx/mac/uma.h"
33 #if defined(__MWERKS__) && wxUSE_UNICODE
34 #if __MWERKS__ < 0x4100 || !defined(__DARWIN__)
39 // ============================================================================
40 // wxMacDataBrowserTableViewControl
41 // ============================================================================
43 pascal Boolean
wxMacDataBrowserTableViewControl::DataBrowserCompareProc(ControlRef browser
, DataBrowserItemID itemOneID
, DataBrowserItemID itemTwoID
, DataBrowserPropertyID sortProperty
)
45 wxMacDataBrowserTableViewControl
* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl
*>(wxMacControl::GetReferenceFromNativeControl(browser
)));
48 if (ControlPtr
!= NULL
)
49 return ControlPtr
->DataBrowserCompareProc(itemOneID
,itemTwoID
,sortProperty
);
51 return errDataBrowserPropertyNotSupported
;
52 } /* wxMacDataBrowserTableViewControl::DataBrowserCompareProc(ControlRef, DataBrowserItemID, DataBrowserItemID, DataBrowserPropertyID) */
54 pascal void wxMacDataBrowserTableViewControl::DataBrowserDrawItemProc(ControlRef browser
, DataBrowserItemID itemID
, DataBrowserPropertyID property
, DataBrowserItemState state
, Rect
const* rectangle
, SInt16 bitDepth
, Boolean colorDevice
)
56 wxMacDataBrowserTableViewControl
* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl
*>(wxMacControl::GetReferenceFromNativeControl(browser
)));
59 if (ControlPtr
!= NULL
)
60 ControlPtr
->DataBrowserDrawItemProc(itemID
,property
,state
,rectangle
,bitDepth
,colorDevice
);
61 } /* wxMacDataBrowserTableViewControl::DataBrowserDrawItemProc(ControlRef, DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemState, Rect const*, SInt16, Boolean) */
63 pascal OSStatus
wxMacDataBrowserTableViewControl::DataBrowserGetSetItemDataProc(ControlRef browser
, DataBrowserItemID itemID
, DataBrowserPropertyID property
, DataBrowserItemDataRef itemData
, Boolean getValue
)
65 wxMacDataBrowserTableViewControl
* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl
*>(wxMacControl::GetReferenceFromNativeControl(browser
)));
68 if (ControlPtr
!= NULL
)
69 return ControlPtr
->DataBrowserGetSetItemDataProc(itemID
,property
,itemData
,getValue
);
71 return errDataBrowserPropertyNotSupported
;
72 } /* wxMacDataBrowserTableViewControl::DataBrowserGetSetItemDataProc(ControlRef, DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemDataRef, Boolean) */
74 pascal void wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc(ControlRef browser
, DataBrowserItemID itemID
, DataBrowserItemNotification message
, DataBrowserItemDataRef itemData
)
76 wxMacDataBrowserTableViewControl
* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl
*>(wxMacControl::GetReferenceFromNativeControl(browser
)));
79 if (ControlPtr
!= NULL
)
80 ControlPtr
->DataBrowserItemNotificationProc(itemID
,message
,itemData
);
81 } /* wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc(ControlRef, DataBrowserItemID, DataBrowserItemNotification, DataBrowserItemDataRef) */
83 DataBrowserDrawItemUPP gDataBrowserTableViewDrawItemUPP
= NULL
;
84 DataBrowserItemCompareUPP gDataBrowserTableViewItemCompareUPP
= NULL
;
85 DataBrowserItemDataUPP gDataBrowserTableViewItemDataUPP
= NULL
;
86 DataBrowserItemNotificationUPP gDataBrowserTableViewItemNotificationUPP
= NULL
;
88 wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow
* peer
, wxPoint
const& pos
, wxSize
const& size
, long style
)
91 Rect bounds
= wxMacGetBoundsForControl(peer
,pos
,size
);
92 OSStatus err
= ::CreateDataBrowserControl(MAC_WXHWND(peer
->MacGetTopLevelWindowRef()),&bounds
,kDataBrowserListView
,&(this->m_controlRef
));
95 SetReferenceInNativeControl();
97 if (gDataBrowserTableViewDrawItemUPP
== NULL
) gDataBrowserTableViewDrawItemUPP
= NewDataBrowserDrawItemUPP (DataBrowserDrawItemProc
);
98 if (gDataBrowserTableViewItemCompareUPP
== NULL
) gDataBrowserTableViewItemCompareUPP
= NewDataBrowserItemCompareUPP(wxMacDataBrowserTableViewControl::DataBrowserCompareProc
);
99 if (gDataBrowserTableViewItemDataUPP
== NULL
) gDataBrowserTableViewItemDataUPP
= NewDataBrowserItemDataUPP (wxMacDataBrowserTableViewControl::DataBrowserGetSetItemDataProc
);
100 if (gDataBrowserTableViewItemNotificationUPP
== NULL
)
102 gDataBrowserTableViewItemNotificationUPP
=
103 #if TARGET_API_MAC_OSX
104 (DataBrowserItemNotificationUPP
) NewDataBrowserItemNotificationWithItemUPP(wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc
);
106 NewDataBrowserItemNotificationUPP(wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc
);
110 DataBrowserCallbacks callbacks
;
111 DataBrowserCustomCallbacks customCallbacks
;
113 InitializeDataBrowserCallbacks (&callbacks
, kDataBrowserLatestCallbacks
);
114 InitializeDataBrowserCustomCallbacks(&customCallbacks
,kDataBrowserLatestCallbacks
);
116 callbacks
.u
.v1
.itemDataCallback
= gDataBrowserTableViewItemDataUPP
;
117 callbacks
.u
.v1
.itemCompareCallback
= gDataBrowserTableViewItemCompareUPP
;
118 callbacks
.u
.v1
.itemNotificationCallback
= gDataBrowserTableViewItemNotificationUPP
;
119 this->SetCallbacks(&callbacks
);
121 customCallbacks
.u
.v1
.drawItemCallback
= gDataBrowserTableViewDrawItemUPP
;
122 this->SetCustomCallbacks(&customCallbacks
);
125 this->EnableCellSizeModification();
127 DataBrowserSelectionFlags flags
; // variable definition
129 if (this->GetSelectionFlags(&flags
) == noErr
) // get default settings
131 if ((style
& wxDV_MULTIPLE
) != 0)
132 flags
&= ~kDataBrowserSelectOnlyOne
;
134 flags
|= kDataBrowserSelectOnlyOne
;
135 (void) this->SetSelectionFlags(flags
);
137 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
138 OptionBits attributes
; // variable definition
140 if (this->GetAttributes(&attributes
) == noErr
) // get default settings
142 if ((style
& wxDV_VERT_RULES
) != 0)
143 attributes
|= kDataBrowserAttributeListViewDrawColumnDividers
;
145 attributes
&= ~kDataBrowserAttributeListViewDrawColumnDividers
;
146 (void) this->SetAttributes(attributes
);
149 if ((style
& wxDV_NO_HEADER
) != 0)
150 this->SetHeaderButtonHeight(0);
151 } /* wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow*, wxPoint const&, wxSize const&, long) */
156 OSStatus
wxMacDataBrowserTableViewControl::SetCallbacks(DataBrowserCallbacks
const* callbacks
)
158 return ::SetDataBrowserCallbacks(this->m_controlRef
,callbacks
);
159 } /* wxMacDataBrowserTableViewControl::SetCallbacks(DataBrowserCallbacks const*) */
161 OSStatus
wxMacDataBrowserTableViewControl::SetCustomCallbacks(DataBrowserCustomCallbacks
const* customCallbacks
)
163 return ::SetDataBrowserCustomCallbacks(this->m_controlRef
,customCallbacks
);
164 } /* xMacDataBrowserTableViewControl::SetCustomCallbacks(DataBrowserCustomCallbacks const*) */
169 OSStatus
wxMacDataBrowserTableViewControl::GetHeaderDesc(DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
* desc
) const
171 desc
->version
= kDataBrowserListViewLatestHeaderDesc
; // if this statement is missing the next call will fail (NOT DOCUMENTED!!)
172 return ::GetDataBrowserListViewHeaderDesc(this->m_controlRef
,property
,desc
);
175 OSStatus
wxMacDataBrowserTableViewControl::SetHeaderDesc(DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
* desc
)
177 return ::SetDataBrowserListViewHeaderDesc(this->m_controlRef
,property
,desc
);
183 OSStatus
wxMacDataBrowserTableViewControl::AutoSizeColumns()
185 return AutoSizeDataBrowserListViewColumns(this->m_controlRef
);
188 OSStatus
wxMacDataBrowserTableViewControl::EnableCellSizeModification(bool enableHeight
, bool enableWidth
)
190 return ::SetDataBrowserTableViewGeometry(this->GetControlRef(),enableWidth
,enableHeight
);
191 } /* wxMacDataBrowserTableViewControl::EnableCellSizeModification(bool, bool) */
193 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
194 OSStatus
wxMacDataBrowserTableViewControl::GetAttributes(OptionBits
* attributes
)
196 return ::DataBrowserGetAttributes(this->GetControlRef(),attributes
);
197 } /* wxMacDataBrowserTableViewControl::GetAttributes(OptionBits*) */
200 OSStatus
wxMacDataBrowserTableViewControl::GetColumnWidth(DataBrowserPropertyID propertyID
, UInt16
* width
) const
202 return ::GetDataBrowserTableViewNamedColumnWidth(this->m_controlRef
,propertyID
,width
);
205 OSStatus
wxMacDataBrowserTableViewControl::GetDefaultColumnWidth( UInt16
*width
) const
207 return GetDataBrowserTableViewColumnWidth(this->m_controlRef
, width
);
210 OSStatus
wxMacDataBrowserTableViewControl::GetDefaultRowHeight(UInt16
* height
) const
212 return ::GetDataBrowserTableViewRowHeight(this->m_controlRef
,height
);
215 OSStatus
wxMacDataBrowserTableViewControl::GetHeaderButtonHeight(UInt16
*height
)
217 return ::GetDataBrowserListViewHeaderBtnHeight(this->m_controlRef
,height
);
220 OSStatus
wxMacDataBrowserTableViewControl::GetPartBounds(DataBrowserItemID item
, DataBrowserPropertyID property
, DataBrowserPropertyPart part
, Rect
* bounds
)
222 return ::GetDataBrowserItemPartBounds(this->m_controlRef
,item
,property
,part
,bounds
);
223 } /* wxMacDataBrowserTableViewControl::GetPartBounds(DataBrowserItemID, DataBrowswerPropertyID, DataBrowserPropertyPart, Rect*) */
225 OSStatus
wxMacDataBrowserTableViewControl::GetRowHeight(DataBrowserItemID item
, UInt16
* height
) const
227 return ::GetDataBrowserTableViewItemRowHeight(this->m_controlRef
,item
,height
);
228 } /* wxMacDataBrowserTableViewControl::GetRowHeight(DataBrowserItemID, UInt16*) const */
230 OSStatus
wxMacDataBrowserTableViewControl::GetScrollPosition( UInt32
*top
, UInt32
*left
) const
232 return GetDataBrowserScrollPosition(this->m_controlRef
, top
, left
);
235 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
236 OSStatus
wxMacDataBrowserTableViewControl::SetAttributes(OptionBits attributes
)
238 return ::DataBrowserChangeAttributes(this->GetControlRef(),attributes
,~attributes
);
239 } /* wxMacDataBrowserTableViewControl::SetAttributes(OptionBits) */
242 OSStatus
wxMacDataBrowserTableViewControl::SetColumnWidth(DataBrowserPropertyID propertyID
, UInt16 width
)
244 return ::SetDataBrowserTableViewNamedColumnWidth(this->m_controlRef
,propertyID
,width
);
247 OSStatus
wxMacDataBrowserTableViewControl::SetDefaultColumnWidth(UInt16 width
)
249 return ::SetDataBrowserTableViewColumnWidth(this->m_controlRef
,width
);
252 OSStatus
wxMacDataBrowserTableViewControl::SetDefaultRowHeight(UInt16 height
)
254 return ::SetDataBrowserTableViewRowHeight(this->m_controlRef
,height
);
257 OSStatus
wxMacDataBrowserTableViewControl::SetHasScrollBars(bool horiz
, bool vert
)
259 return ::SetDataBrowserHasScrollBars(this->m_controlRef
,horiz
,vert
);
260 } /* wxMacDataBrowserTableViewControl::SetHasScrollBars(bool, bool) */
262 OSStatus
wxMacDataBrowserTableViewControl::SetHeaderButtonHeight(UInt16 height
)
264 return ::SetDataBrowserListViewHeaderBtnHeight(this->m_controlRef
,height
);
265 } /* wxMacDataBrowserTableViewControl::SetHeaderButtonHeight(UInt16) */
267 OSStatus
wxMacDataBrowserTableViewControl::SetHiliteStyle(DataBrowserTableViewHiliteStyle hiliteStyle
)
269 return ::SetDataBrowserTableViewHiliteStyle(this->m_controlRef
,hiliteStyle
);
270 } /*wxMacDataBrowserTableViewControl::SetHiliteStyle(DataBrowserTableViewHiliteStyle) */
272 OSStatus
wxMacDataBrowserTableViewControl::SetIndent(float Indent
)
274 return ::DataBrowserSetMetric(this->m_controlRef
,kDataBrowserMetricDisclosureColumnPerDepthGap
,true,Indent
);
275 } /* wxMacDataBrowserTableViewControl::SetIndent(float* Indent) */
277 OSStatus
wxMacDataBrowserTableViewControl::SetRowHeight(DataBrowserItemID item
, UInt16 height
)
279 return ::SetDataBrowserTableViewItemRowHeight(this->m_controlRef
,item
,height
);
282 OSStatus
wxMacDataBrowserTableViewControl::SetScrollPosition(UInt32 top
, UInt32 left
)
284 return ::SetDataBrowserScrollPosition(this->m_controlRef
,top
,left
);
290 OSStatus
wxMacDataBrowserTableViewControl::GetColumnCount(UInt32
* numColumns
) const
292 return ::GetDataBrowserTableViewColumnCount(this->m_controlRef
,numColumns
);
295 OSStatus
wxMacDataBrowserTableViewControl::GetColumnIndex(DataBrowserPropertyID propertyID
, DataBrowserTableViewColumnIndex
* index
) const
297 return ::GetDataBrowserTableViewColumnPosition(this->m_controlRef
,propertyID
,index
);
298 } /* wxMacDataBrowserTableViewControl::GetColumnIndex(DataBrowserPropertyID, DataBrowserTableViewColumnIndex*) const */
300 OSStatus
wxMacDataBrowserTableViewControl::GetFreePropertyID(DataBrowserPropertyID
* propertyID
) const
302 for (*propertyID
=kMinPropertyID
; *propertyID
<std::numeric_limits
<DataBrowserPropertyID
>::max(); ++(*propertyID
))
303 if (this->IsUsedPropertyID(*propertyID
) == errDataBrowserPropertyNotFound
)
305 return errDataBrowserPropertyNotSupported
;
306 } /* wxMacDataBrowserTableViewControl::GetFreePropertyID(DataBrowserPropertyID*) const */
308 OSStatus
wxMacDataBrowserTableViewControl::GetPropertyFlags(DataBrowserPropertyID propertyID
, DataBrowserPropertyFlags
*flags
) const
310 return ::GetDataBrowserPropertyFlags(this->m_controlRef
,propertyID
,flags
);
313 OSStatus
wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserItemDataRef itemData
, DataBrowserPropertyID
* propertyID
)
315 return ::GetDataBrowserItemDataProperty(itemData
,propertyID
);
316 } /* wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserItemDataRef, DataBrowserPropertyID*) */
318 OSStatus
wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserTableViewColumnIndex index
, DataBrowserTableViewColumnID
* propertyID
)
320 return ::GetDataBrowserTableViewColumnProperty(this->m_controlRef
,index
,propertyID
);
321 } /* wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserTableViewColumnIndex, DataBrowserTableViewColumnID*) */
323 OSStatus
wxMacDataBrowserTableViewControl::IsUsedPropertyID(DataBrowserPropertyID propertyID
) const
325 // 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
326 // 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
327 // the column position for the property id:
328 DataBrowserTableViewColumnIndex index
;
330 return ::GetDataBrowserTableViewColumnPosition(this->m_controlRef
,propertyID
,&index
);
331 } /* wxMacDataBrowserTableViewControl::IsUsedPropertyId(DataBrowserPropertyID) const */
333 OSStatus
wxMacDataBrowserTableViewControl::RemoveColumnByProperty(DataBrowserTableViewColumnID propertyID
)
335 return ::RemoveDataBrowserTableViewColumn(this->m_controlRef
,propertyID
);
336 } /* wxMacDataBrowserTableViewControl::RemoveColumnByProperty(DataBrowserTableViewColumnID) */
338 OSStatus
wxMacDataBrowserTableViewControl::RemoveColumnByIndex(DataBrowserTableViewColumnIndex index
)
340 DataBrowserTableViewColumnID propertyID
;
343 this->GetPropertyID(index
,&propertyID
);
344 return ::RemoveDataBrowserTableViewColumn(this->m_controlRef
,propertyID
);
345 } /* wxMacDataBrowserTableViewControl::RemoveColumnByIndex(DataBrowserTableViewColumnIndex) */
347 OSStatus
wxMacDataBrowserTableViewControl::SetColumnIndex(DataBrowserPropertyID propertyID
, DataBrowserTableViewColumnIndex index
)
349 return ::SetDataBrowserTableViewColumnPosition(this->m_controlRef
,propertyID
,index
);
350 } /* wxMacDataBrowserTableViewControl::SetColumnIndex(DataBrowserPropertyID, DataBrowserTableViewColumnIndex) */
352 OSStatus
wxMacDataBrowserTableViewControl::SetDisclosureColumn(DataBrowserPropertyID propertyID
, Boolean expandableRows
)
354 return ::SetDataBrowserListViewDisclosureColumn(this->m_controlRef
,propertyID
,expandableRows
);
357 OSStatus
wxMacDataBrowserTableViewControl::SetPropertyFlags(DataBrowserPropertyID propertyID
, DataBrowserPropertyFlags flags
)
359 return ::SetDataBrowserPropertyFlags(this->m_controlRef
,propertyID
,flags
);
360 } /* wxMacDataBrowserTableViewControl::SetPropertyFlags(DataBrowserPropertyID, DataBrowserPropertyFlags) */
365 OSStatus
wxMacDataBrowserTableViewControl::AddItems(DataBrowserItemID container
, UInt32 numItems
, DataBrowserItemID
const* items
, DataBrowserPropertyID preSortProperty
)
367 return ::AddDataBrowserItems(this->m_controlRef
,container
,numItems
,items
,preSortProperty
);
368 } /* wxMacDataBrowserTableViewControl::AddItems(DataBrowserItemID, UInt32, DataBrowserItemID const*, DataBrowserPropertyID) */
370 OSStatus
wxMacDataBrowserTableViewControl::GetFreeItemID(DataBrowserItemID
* id
) const
375 verify_noerr(this->GetItemCount(&NoOfItems
));
383 // 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
384 // as the number of items; therefore, start from the number of items to look for a new ID:
385 for (*id
=NoOfItems
; *id
<std::numeric_limits
<DataBrowserItemID
>::max(); ++(*id
))
386 if (this->IsUsedItemID(*id
) == errDataBrowserItemNotFound
)
388 // as the first approach was not successful, try from the beginning:
389 for (*id
=0; *id
<NoOfItems
; ++(*id
))
390 if (this->IsUsedItemID(*id
) == errDataBrowserItemNotFound
)
392 // sorry, data browser is full:
393 return errDataBrowserItemNotAdded
;
395 } /* wxMacDataBrowserTableViewControl::GetFreeItemID(DataBrowserItemID*) const */
397 OSStatus
wxMacDataBrowserTableViewControl::GetItemCount(DataBrowserItemID container
, Boolean recurse
, DataBrowserItemState state
, ItemCount
* numItems
) const
399 return GetDataBrowserItemCount(this->m_controlRef
,container
,recurse
,state
,numItems
);
400 } /* wxMacDataBrowserTableViewControl::GetItemCount(DataBrowserItemID, Boolean, DataBrowserItemState, ItemCount*) const */
402 OSStatus
wxMacDataBrowserTableViewControl::GetItemID( DataBrowserTableViewRowIndex row
, DataBrowserItemID
* item
) const
404 return GetDataBrowserTableViewItemID(this->m_controlRef
,row
,item
);
407 OSStatus
wxMacDataBrowserTableViewControl::GetItems(DataBrowserItemID container
, Boolean recurse
, DataBrowserItemState state
, Handle items
) const
409 return GetDataBrowserItems(this->m_controlRef
,container
,recurse
,state
,items
);
410 } /* wxMacDataBrowserTableViewControl::GetItems(DataBrowserItemID, Boolean, DataBrowserItemState, Handle) const */
412 OSStatus
wxMacDataBrowserTableViewControl::GetItemRow(DataBrowserItemID item
, DataBrowserTableViewRowIndex
* row
) const
414 return GetDataBrowserTableViewItemRow(this->m_controlRef
,item
,row
);
417 OSStatus
wxMacDataBrowserTableViewControl::IsUsedItemID(DataBrowserItemID itemID
) const
419 // 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
420 // 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
421 // the column position for the property id:
422 DataBrowserTableViewColumnIndex index
;
424 return ::GetDataBrowserTableViewItemRow(this->m_controlRef
,itemID
,&index
);
425 } /* wxMacDataBrowserTableViewControl::IsUsedItemID(DataBrowserItemID) const */
427 OSStatus
wxMacDataBrowserTableViewControl::RemoveItems(DataBrowserItemID container
, UInt32 numItems
, DataBrowserItemID
const* items
, DataBrowserPropertyID preSortProperty
)
429 return ::RemoveDataBrowserItems(this->m_controlRef
,container
,numItems
,items
,preSortProperty
);
432 OSStatus
wxMacDataBrowserTableViewControl::RevealItem(DataBrowserItemID item
, DataBrowserPropertyID propertyID
, DataBrowserRevealOptions options
) const
434 return ::RevealDataBrowserItem(this->m_controlRef
,item
,propertyID
,options
);
435 } /* wxMacDataBrowserTableViewControl::RevealItem(DataBrowserItemID item, DataBrowserPropertyID propertyID, DataBrowserRevealOptions options) const */
437 OSStatus
wxMacDataBrowserTableViewControl::UpdateItems(DataBrowserItemID container
, UInt32 numItems
, DataBrowserItemID
const* items
, DataBrowserPropertyID preSortProperty
,
438 DataBrowserPropertyID propertyID
) const
440 return UpdateDataBrowserItems(this->m_controlRef
,container
,numItems
,items
,preSortProperty
,propertyID
);
446 size_t wxMacDataBrowserTableViewControl::GetSelectedItemIDs(wxArrayDataBrowserItemID
& itemIDs
) const
448 DataBrowserItemID
* itemIDPtr
;
449 Handle
handle(::NewHandle(0));
454 wxCHECK_MSG(this->GetItems(kDataBrowserNoItem
,true,kDataBrowserItemIsSelected
,handle
) == noErr
,0,_("Could not get selected items."));
455 NoOfItems
= static_cast<size_t>(::GetHandleSize(handle
)/sizeof(DataBrowserItemID
));
457 itemIDs
.Alloc(NoOfItems
);
459 itemIDPtr
= (DataBrowserItemID
*) (*handle
);
460 for (size_t i
=0; i
<NoOfItems
; ++i
)
462 itemIDs
.Add(*itemIDPtr
);
466 DisposeHandle(handle
);
468 } /* wxMacDataBrowserTableViewControl::GetSelectedItemIDs(wxArrayDataBrowserItemID&) const*/
470 OSStatus
wxMacDataBrowserTableViewControl::GetSelectionAnchor(DataBrowserItemID
* first
, DataBrowserItemID
* last
) const
472 return ::GetDataBrowserSelectionAnchor(this->m_controlRef
,first
,last
);
473 } /* wxMacDataBrowserTableViewControl::GetSelectionAnchor(DataBrowserItemID*, DataBrowserItemID*) const */
475 OSStatus
wxMacDataBrowserTableViewControl::GetSelectionFlags(DataBrowserSelectionFlags
* flags
) const
477 return ::GetDataBrowserSelectionFlags(this->m_controlRef
,flags
);
478 } /* wxMacDataBrowserTableViewControl::GetSelectionFlags(DataBrowserSelectionFlags*) const */
480 bool wxMacDataBrowserTableViewControl::IsItemSelected(DataBrowserItemID item
) const
482 return ::IsDataBrowserItemSelected(this->m_controlRef
,item
);
483 } /* wxMacDataBrowserTableViewControl::IsItemSelected(DataBrowserItemID) const */
485 OSStatus
wxMacDataBrowserTableViewControl::SetSelectionFlags(DataBrowserSelectionFlags flags
)
487 return ::SetDataBrowserSelectionFlags(this->m_controlRef
,flags
);
488 } /* wxMacDataBrowserTableViewControl::SetSelectionFlags(DataBrowserSelectionFlags) */
490 OSStatus
wxMacDataBrowserTableViewControl::SetSelectedItems(UInt32 numItems
, DataBrowserItemID
const* items
, DataBrowserSetOption operation
)
492 return ::SetDataBrowserSelectedItems(this->m_controlRef
, numItems
, items
, operation
);
493 } /* wxMacDataBrowserTableViewControl::SetSelectedItems(UInt32, DataBrowserItemID const*, DataBrowserSetOption) */
495 OSStatus
wxMacDataBrowserTableViewControl::GetSortOrder(DataBrowserSortOrder
* order
) const
497 return ::GetDataBrowserSortOrder(this->m_controlRef
,order
);
500 OSStatus
wxMacDataBrowserTableViewControl::GetSortProperty(DataBrowserPropertyID
* propertyID
) const
502 return ::GetDataBrowserSortProperty(this->m_controlRef
,propertyID
);
505 OSStatus
wxMacDataBrowserTableViewControl::Resort(DataBrowserItemID container
, Boolean sortChildren
)
507 return ::SortDataBrowserContainer(this->m_controlRef
,container
,sortChildren
);
508 } /* wxMacDataBrowserTableViewControl::Resort(DataBrowserItemID, Boolean) */
510 OSStatus
wxMacDataBrowserTableViewControl::SetSortOrder(DataBrowserSortOrder order
)
512 return ::SetDataBrowserSortOrder(this->m_controlRef
,order
);
515 OSStatus
wxMacDataBrowserTableViewControl::SetSortProperty(DataBrowserPropertyID propertyID
)
517 return ::SetDataBrowserSortProperty(this->m_controlRef
,propertyID
);
521 // container handling
523 OSStatus
wxMacDataBrowserTableViewControl::CloseContainer(DataBrowserItemID containerID
)
525 return ::CloseDataBrowserContainer(this->m_controlRef
,containerID
);
526 } /* wxMacDataBrowserTableViewControl::CloseContainer(DataBrowserItemID) */
528 OSStatus
wxMacDataBrowserTableViewControl::OpenContainer(DataBrowserItemID containerID
)
530 return ::OpenDataBrowserContainer(this->m_controlRef
,containerID
);
531 } /* wxMacDataBrowserTableViewControl::OpenContainer(DataBrowserItemID) */
533 IMPLEMENT_ABSTRACT_CLASS(wxMacDataBrowserTableViewControl
,wxMacControl
)
535 // ============================================================================
536 // wxMacDataBrowserListViewControl
537 // ============================================================================
542 OSStatus
wxMacDataBrowserListViewControl::AddColumn(DataBrowserListViewColumnDesc
*columnDesc
, DataBrowserTableViewColumnIndex position
)
544 return AddDataBrowserListViewColumn(this->m_controlRef
,columnDesc
,position
);
545 } /* wxMacDataBrowserListViewControl::AddColumn(DataBrowserListViewColumnDesc*, DataBrowserTableViewColumnIndex) */
547 // ============================================================================
548 // wxMacDataViewDataBrowserListViewControl
549 // ============================================================================
552 // constructors / destructor
554 wxMacDataViewDataBrowserListViewControl::wxMacDataViewDataBrowserListViewControl(wxWindow
* peer
, wxPoint
const& pos
, wxSize
const& size
, long style
)
555 :wxMacDataBrowserListViewControl(peer
,pos
,size
,style
)
557 } /* wxMacDataViewDataBrowserListViewControl::wxMacDataViewDataBrowserListViewControl(wxWindow* , const wxPoint&, const wxSize&, long) */
560 // callback functions (inherited from wxMacDataBrowserTableViewControl)
562 Boolean
wxMacDataViewDataBrowserListViewControl::DataBrowserCompareProc(DataBrowserItemID itemOneID
, DataBrowserItemID itemTwoID
, DataBrowserPropertyID sortProperty
)
564 DataBrowserSortOrder sortOrder
;
566 DataBrowserTableViewColumnIndex columnIndex
;
568 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
571 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
, false,_("Pointer to data view control not set correctly."));
572 wxCHECK_MSG(dataViewCtrlPtr
->GetModel() != NULL
,false,_("Pointer to model not set correctly."));
573 if (sortProperty
>= kMinPropertyID
)
575 wxCHECK_MSG(this->GetColumnIndex(sortProperty
,&columnIndex
) == noErr
,false,_("Could not determine column index."));
579 this->GetSortOrder(&sortOrder
);
580 return static_cast<Boolean
>(dataViewCtrlPtr
->GetModel()->Compare(wxDataViewItem(reinterpret_cast<void*>(itemOneID
)),wxDataViewItem(reinterpret_cast<void*>(itemTwoID
)),
581 columnIndex
,sortOrder
!= kDataBrowserOrderDecreasing
) < 0);
582 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserCompareProc(DataBrowserItemID, DataBrowserItemID, DataBrowserPropertyID) */
584 void wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowserItemID itemID
, DataBrowserPropertyID propertyID
, DataBrowserItemState state
, Rect
const* rectangle
, SInt16 bitDepth
, Boolean colorDevice
)
586 DataBrowserTableViewColumnIndex columnIndex
;
588 wxDataViewColumn
* dataViewColumnPtr
;
590 wxDataViewCtrl
* dataViewCtrlPtr
;
592 wxDataViewCustomRenderer
* dataViewCustomRendererPtr
;
594 wxVariant dataToRender
;
597 dataViewCtrlPtr
= dynamic_cast<wxDataViewCtrl
*>(this->GetPeer());
598 wxCHECK_RET(dataViewCtrlPtr
!= NULL
, _("Pointer to data view control not set correctly."));
599 wxCHECK_RET(dataViewCtrlPtr
->GetModel() != NULL
, _("Pointer to model not set correctly."));
600 wxCHECK_RET(this->GetColumnIndex(propertyID
,&columnIndex
) == noErr
,_("Could not determine column index."));
601 dataViewColumnPtr
= dataViewCtrlPtr
->GetColumn(columnIndex
);
602 wxCHECK_RET(dataViewColumnPtr
!= NULL
,_("No column for the specified column index existing."));
603 dataViewCustomRendererPtr
= dynamic_cast<wxDataViewCustomRenderer
*>(dataViewColumnPtr
->GetRenderer());
604 wxCHECK_RET(dataViewCustomRendererPtr
!= NULL
,_("No renderer or invalid renderer type specified for custom data column."));
605 dataViewCtrlPtr
->GetModel()->GetValue(dataToRender
,wxDataViewItem(reinterpret_cast<void*>(itemID
)),columnIndex
);
606 dataViewCustomRendererPtr
->SetValue(dataToRender
);
608 // try to determine the content's size (drawable part):
610 RgnHandle
rgn(NewRgn());
613 if (this->GetRegion(kControlContentMetaPart
,rgn
) == noErr
)
614 GetRegionBounds(rgn
,&content
);
616 this->GetRect(&content
);
618 // space for the header
619 this->GetHeaderButtonHeight(&headerHeight
);
620 content
.top
+= headerHeight
;
621 // extra space for the frame (todo: do not how to determine the space automatically from the control)
626 // extra space for the scrollbars:
627 content
.bottom
-= wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y
);
628 content
.right
-= wxSystemSettings::GetMetric(wxSYS_VSCROLL_X
);
630 // make sure that 'Render' can draw only in the allowed area:
631 dataViewCustomRendererPtr
->GetDC()->SetClippingRegion(content
.left
,content
.top
,content
.right
-content
.left
+1,content
.bottom
-content
.top
+1);
632 (void) (dataViewCustomRendererPtr
->Render(wxRect(static_cast<int>(rectangle
->left
),static_cast<int>(rectangle
->top
),
633 static_cast<int>(1+rectangle
->right
-rectangle
->left
),static_cast<int>(1+rectangle
->bottom
-rectangle
->top
)),
634 dataViewCustomRendererPtr
->GetDC(),((state
== kDataBrowserItemIsSelected
) ? wxDATAVIEW_CELL_SELECTED
: 0)));
635 dataViewCustomRendererPtr
->GetDC()->DestroyClippingRegion(); // probably not necessary
636 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemState, Rect const*, SInt16, Boolean) */
638 OSStatus
wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(DataBrowserItemID itemID
, DataBrowserPropertyID propertyID
, DataBrowserItemDataRef itemData
, Boolean getValue
)
642 // variable definitions:
643 wxDataViewCtrl
* dataViewCtrlPtr
;
645 dataViewCtrlPtr
= dynamic_cast<wxDataViewCtrl
*>(this->GetPeer());
646 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
,errDataBrowserNotConfigured
,_("Pointer to data view control not set correctly."));
647 if (dataViewCtrlPtr
->IsDeleting())
648 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
651 // variable definitions:
652 DataBrowserTableViewColumnIndex columnIndex
;
653 OSStatus errorStatus
;
654 wxDataViewColumn
* dataViewColumnPtr
;
656 wxCHECK_MSG(dataViewCtrlPtr
->GetModel() != NULL
,errDataBrowserNotConfigured
,_("Pointer to model not set correctly."));
657 errorStatus
= this->GetColumnIndex(propertyID
,&columnIndex
);
658 wxCHECK_MSG(errorStatus
== noErr
,errorStatus
,_("Could not determine column index"));
659 dataViewColumnPtr
= dataViewCtrlPtr
->GetColumn(columnIndex
);
660 wxCHECK_MSG((dataViewColumnPtr
!= NULL
) && (dataViewColumnPtr
->GetRenderer() != NULL
),errDataBrowserNotConfigured
,_("There is no column or renderer for the specified column index."));
661 switch (dataViewColumnPtr
->GetRenderer()->GetPropertyType())
663 case kDataBrowserCheckboxType
:
665 // variable definition:
666 ThemeButtonValue buttonValue
;
668 errorStatus
= ::GetDataBrowserItemDataButtonValue(itemData
,&buttonValue
);
669 if (errorStatus
== noErr
)
671 if (buttonValue
== kThemeButtonOn
)
673 // variable definition and initialization:
674 wxVariant
modifiedData(true);
676 return (dataViewCtrlPtr
->GetModel()->SetValue(modifiedData
,wxDataViewItem(reinterpret_cast<void*>(itemID
)),static_cast<unsigned int>(columnIndex
)) ? OSStatus(noErr
) : OSStatus(errDataBrowserNotConfigured
));
678 else if (buttonValue
== kThemeButtonOff
)
680 // variable definition and initialization:
681 wxVariant
modifiedData(false);
683 return (dataViewCtrlPtr
->GetModel()->SetValue(modifiedData
,wxDataViewItem(reinterpret_cast<void*>(itemID
)),static_cast<unsigned int>(columnIndex
)) ? OSStatus(noErr
) : OSStatus(errDataBrowserNotConfigured
));
686 return errDataBrowserInvalidPropertyData
;
691 case kDataBrowserTextType
:
693 // variable definitions:
694 CFStringRef stringReference
;
696 errorStatus
= ::GetDataBrowserItemDataText(itemData
,&stringReference
);
697 if (errorStatus
== noErr
)
699 // variable definitions and initializations:
700 wxMacCFStringHolder
modifiedString(stringReference
);
701 wxVariant
modifiedData(modifiedString
.AsString());
703 if (dataViewCtrlPtr
->GetModel()->SetValue(modifiedData
,wxDataViewItem(reinterpret_cast<void*>(itemID
)),static_cast<unsigned int>(columnIndex
)))
706 return errDataBrowserNotConfigured
;
712 return errDataBrowserPropertyNotSupported
;
718 if (propertyID
>= kMinPropertyID
) // in case data columns set the data
720 // variable definitions:
722 wxDataViewColumn
* dataViewColumnPtr
;
723 wxDataViewCtrl
* dataViewCtrlPtr
;
725 dataViewCtrlPtr
= dynamic_cast<wxDataViewCtrl
*>(this->GetPeer());
726 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
,errDataBrowserNotConfigured
,_("Pointer to data view control not set correctly."));
727 wxCHECK_MSG(dataViewCtrlPtr
->GetModel() != NULL
,errDataBrowserNotConfigured
,_("Pointer to model not set correctly."));
728 dataViewColumnPtr
= dataViewCtrlPtr
->GetColumnPtr(propertyID
);
729 wxCHECK_MSG(dataViewColumnPtr
!= NULL
,errDataBrowserNotConfigured
,_("No column for the specified column position existing."));
730 wxCHECK_MSG(dataViewColumnPtr
->GetRenderer() != NULL
,errDataBrowserNotConfigured
,_("No renderer specified for column."));
731 dataViewCtrlPtr
->GetModel()->GetValue(variant
,wxDataViewItem(reinterpret_cast<void*>(itemID
)),dataViewColumnPtr
->GetModelColumn());
732 if (!(variant
.IsNull()))
734 dataViewColumnPtr
->GetRenderer()->SetDataReference(itemData
);
735 dataViewColumnPtr
->GetRenderer()->SetValue(variant
);
736 wxCHECK_MSG(dataViewColumnPtr
->GetRenderer()->Render(),errDataBrowserNotConfigured
,_("Rendering failed."));
740 else // react on special system requests
744 case kDataBrowserContainerIsClosableProperty
:
746 // variable definitions:
747 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
749 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
,errDataBrowserNotConfigured
,_("Pointer to data view control not set correctly."));
750 // initialize wxWidget event:
751 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING
,dataViewCtrlPtr
->GetId()); // variable definition
753 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
754 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
755 // finally send the equivalent wxWidget event:
756 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
757 // opening the container is allowed if not vetoed:
758 return ::SetDataBrowserItemDataBooleanValue(itemData
,dataViewEvent
.IsAllowed());
760 case kDataBrowserContainerIsOpenableProperty
:
762 // variable definitions:
763 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
765 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
,errDataBrowserNotConfigured
,_("Pointer to data view control not set correctly."));
766 // initialize wxWidget event:
767 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING
,dataViewCtrlPtr
->GetId()); // variable definition
769 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
770 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
771 // finally send the equivalent wxWidget event:
772 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
773 // opening the container is allowed if not vetoed:
774 return ::SetDataBrowserItemDataBooleanValue(itemData
,dataViewEvent
.IsAllowed());
776 case kDataBrowserItemIsContainerProperty
:
778 // variable definition:
779 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
781 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
,errDataBrowserNotConfigured
,_("Pointer to data view control not set correctly."));
782 wxCHECK_MSG(dataViewCtrlPtr
->GetModel() != NULL
,errDataBrowserNotConfigured
,_("Pointer to model not set correctly."));
783 return ::SetDataBrowserItemDataBooleanValue(itemData
,dataViewCtrlPtr
->GetModel()->IsContainer(wxDataViewItem(reinterpret_cast<void*>(itemID
))));
785 case kDataBrowserItemIsEditableProperty
:
786 return ::SetDataBrowserItemDataBooleanValue(itemData
,true);
790 return errDataBrowserPropertyNotSupported
;
791 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemDataRef, Boolean) */
793 void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(DataBrowserItemID itemID
, DataBrowserItemNotification message
, DataBrowserItemDataRef itemData
)
795 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
798 // 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:
799 if (dataViewCtrlPtr
!= NULL
)
802 case kDataBrowserContainerClosed
:
804 // initialize wxWidget event:
805 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED
,dataViewCtrlPtr
->GetId()); // variable definition
807 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
808 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
809 // finally send the equivalent wxWidget event:
810 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
813 case kDataBrowserContainerOpened
:
815 // initialize wxWidget event:
816 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED
,dataViewCtrlPtr
->GetId()); // variable definition
818 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
819 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
820 // finally send the equivalent wxWidget event:
821 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
822 // add children to the expanded container:
823 dataViewCtrlPtr
->AddChildrenLevel(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
826 case kDataBrowserEditStarted
:
828 // initialize wxWidget event:
829 DataBrowserPropertyID propertyID
;
830 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED
,dataViewCtrlPtr
->GetId()); // variable definition
832 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
833 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
834 if (this->GetPropertyID(itemData
,&propertyID
) == noErr
)
836 // variable definition and initialization:
837 DataBrowserTableViewColumnIndex columnIndex
;
839 wxCHECK_RET(this->GetColumnIndex(propertyID
,&columnIndex
),_("Column index not found."));
840 dataViewEvent
.SetColumn(columnIndex
);
841 dataViewEvent
.SetDataViewColumn(dataViewCtrlPtr
->GetColumnPtr(propertyID
));
843 // finally send the equivalent wxWidget event:
844 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
847 case kDataBrowserEditStopped
:
849 // initialize wxWidget event:
850 DataBrowserPropertyID propertyID
;
851 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE
,dataViewCtrlPtr
->GetId()); // variable definition
853 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
854 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
855 if (this->GetPropertyID(itemData
,&propertyID
) == noErr
)
857 // variable definition and initialization:
858 DataBrowserTableViewColumnIndex columnIndex
;
860 wxCHECK_RET(this->GetColumnIndex(propertyID
,&columnIndex
),_("Column index not found."));
861 dataViewEvent
.SetColumn(columnIndex
);
862 dataViewEvent
.SetDataViewColumn(dataViewCtrlPtr
->GetColumnPtr(propertyID
));
864 // finally send the equivalent wxWidget event:
865 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
868 case kDataBrowserItemAdded
:
869 break; // not used anymore
870 case kDataBrowserItemDeselected
:
871 break; // not implemented by wxWidgets; see kDataBrowserSelectionSetChanged
872 case kDataBrowserItemDoubleClicked
:
874 // initialize wxWidget event:
875 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED
,dataViewCtrlPtr
->GetId()); // variable definition
877 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
878 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
879 // finally send the equivalent wxWidget event:
880 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
883 case kDataBrowserItemRemoved
:
884 break; // not used anymore
885 case kDataBrowserItemSelected
:
886 break; // not implemented by wxWidgets; see kDataBrowserSelectionSetChanged
887 case kDataBrowserSelectionSetChanged
:
889 // initialize wxWidget event:
890 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED
,dataViewCtrlPtr
->GetId()); // variable definition
892 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
893 dataViewEvent
.SetModel (dataViewCtrlPtr
->GetModel());
894 // finally send the equivalent wxWidget event:
895 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
898 case kDataBrowserUserStateChanged
:
900 // update column widths:
901 for (size_t i
=0; i
<dataViewCtrlPtr
->GetColumnCount(); ++i
)
903 // constant definition for abbreviational purposes:
904 wxDataViewColumn
* const columnPtr
= dataViewCtrlPtr
->GetColumn(i
);
905 // variable definition:
908 wxCHECK_RET(this->GetColumnWidth(columnPtr
->GetPropertyID(),&columnWidth
) == noErr
,_("Column width could not be determined"));
909 columnPtr
->SetWidthVariable(columnWidth
);
911 // update order status:
912 DataBrowserPropertyID propertyID
; // variable definition
914 if ((this->GetSortProperty(&propertyID
) == noErr
) && (propertyID
>= kMinPropertyID
))
916 DataBrowserSortOrder sortOrder
;
917 DataBrowserTableViewColumnIndex columnIndex
;
919 if ((this->GetSortOrder(&sortOrder
) == noErr
) && (this->GetColumnIndex(propertyID
,&columnIndex
) == noErr
))
921 // variable definition and initialization:
922 wxDataViewColumn
* columnPtr
;
923 columnPtr
= dataViewCtrlPtr
->GetColumn(columnIndex
);
924 // check if the sort order has changed:
925 if ( columnPtr
->IsSortOrderAscending() && (sortOrder
== kDataBrowserOrderDecreasing
) ||
926 !(columnPtr
->IsSortOrderAscending()) && (sortOrder
== kDataBrowserOrderIncreasing
))
928 columnPtr
->SetSortOrder(!(columnPtr
->IsSortOrderAscending()));
929 // initialize wxWidget event:
930 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED
,dataViewCtrlPtr
->GetId()); // variable defintion
932 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
933 dataViewEvent
.SetColumn(columnIndex
);
934 dataViewEvent
.SetDataViewColumn(columnPtr
);
935 // finally send the equivalent wxWidget event:
936 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
943 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(DataBrowserItemID, DataBrowserItemNotification, DataBrowserItemDataRef) */
946 #endif // wxUSE_GENERICDATAVIEWCTRL
947 #endif // wxUSE_DATAVIEWCTRL