1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/carbon/databrow.cpp
3 // Purpose: Classes and functions for the Carbon data browser
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef wxUSE_GENERICDATAVIEWCTRL
21 #include "wx/wxprec.h"
23 #if wxUSE_DATAVIEWCTRL
29 #include "wx/toplevel.h"
33 #include "wx/apptrait.h"
35 #include "wx/mac/uma.h"
39 #include <Carbon/Carbon.h>
41 #include <ATSUnicode.h>
42 #include <TextCommon.h>
43 #include <TextEncodingConverter.h>
46 #include "wx/mac/private.h"
48 #if defined(__MWERKS__) && wxUSE_UNICODE
49 #if __MWERKS__ < 0x4100 || !defined(__DARWIN__)
56 #include "wx/mac/carbon/databrow.h"
58 #include "wx/dataview.h"
60 // ============================================================================
61 // wxMacDataBrowserTableViewControl
62 // ============================================================================
64 pascal Boolean
wxMacDataBrowserTableViewControl::DataBrowserCompareProc(ControlRef browser
, DataBrowserItemID itemOneID
, DataBrowserItemID itemTwoID
, DataBrowserPropertyID sortProperty
)
66 wxMacDataBrowserTableViewControl
* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl
*>(wxMacControl::GetReferenceFromNativeControl(browser
)));
69 if (ControlPtr
!= NULL
)
70 return ControlPtr
->DataBrowserCompareProc(itemOneID
,itemTwoID
,sortProperty
);
72 return errDataBrowserPropertyNotSupported
;
73 } /* wxMacDataBrowserTableViewControl::DataBrowserCompareProc(ControlRef, DataBrowserItemID, DataBrowserItemID, DataBrowserPropertyID) */
75 pascal void wxMacDataBrowserTableViewControl::DataBrowserDrawItemProc(ControlRef browser
, DataBrowserItemID itemID
, DataBrowserPropertyID property
, DataBrowserItemState state
, Rect
const* rectangle
, SInt16 bitDepth
, Boolean colorDevice
)
77 wxMacDataBrowserTableViewControl
* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl
*>(wxMacControl::GetReferenceFromNativeControl(browser
)));
80 if (ControlPtr
!= NULL
)
81 ControlPtr
->DataBrowserDrawItemProc(itemID
,property
,state
,rectangle
,bitDepth
,colorDevice
);
82 } /* wxMacDataBrowserTableViewControl::DataBrowserDrawItemProc(ControlRef, DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemState, Rect const*, SInt16, Boolean) */
84 pascal OSStatus
wxMacDataBrowserTableViewControl::DataBrowserGetSetItemDataProc(ControlRef browser
, DataBrowserItemID itemID
, DataBrowserPropertyID property
, DataBrowserItemDataRef itemData
, Boolean getValue
)
86 wxMacDataBrowserTableViewControl
* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl
*>(wxMacControl::GetReferenceFromNativeControl(browser
)));
89 if (ControlPtr
!= NULL
)
90 return ControlPtr
->DataBrowserGetSetItemDataProc(itemID
,property
,itemData
,getValue
);
92 return errDataBrowserPropertyNotSupported
;
93 } /* wxMacDataBrowserTableViewControl::DataBrowserGetSetItemDataProc(ControlRef, DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemDataRef, Boolean) */
95 pascal void wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc(ControlRef browser
, DataBrowserItemID itemID
, DataBrowserItemNotification message
, DataBrowserItemDataRef itemData
)
97 wxMacDataBrowserTableViewControl
* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl
*>(wxMacControl::GetReferenceFromNativeControl(browser
)));
100 if (ControlPtr
!= NULL
)
101 ControlPtr
->DataBrowserItemNotificationProc(itemID
,message
,itemData
);
102 } /* wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc(ControlRef, DataBrowserItemID, DataBrowserItemNotification, DataBrowserItemDataRef) */
104 DataBrowserDrawItemUPP gDataBrowserTableViewDrawItemUPP
= NULL
;
105 DataBrowserItemCompareUPP gDataBrowserTableViewItemCompareUPP
= NULL
;
106 DataBrowserItemDataUPP gDataBrowserTableViewItemDataUPP
= NULL
;
107 DataBrowserItemNotificationUPP gDataBrowserTableViewItemNotificationUPP
= NULL
;
109 wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow
* peer
, wxPoint
const& pos
, wxSize
const& size
, long style
)
112 Rect bounds
= wxMacGetBoundsForControl(peer
,pos
,size
);
113 OSStatus err
= ::CreateDataBrowserControl(MAC_WXHWND(peer
->MacGetTopLevelWindowRef()),&bounds
,kDataBrowserListView
,&(this->m_controlRef
));
116 SetReferenceInNativeControl();
118 if (gDataBrowserTableViewDrawItemUPP
== NULL
) gDataBrowserTableViewDrawItemUPP
= NewDataBrowserDrawItemUPP (DataBrowserDrawItemProc
);
119 if (gDataBrowserTableViewItemCompareUPP
== NULL
) gDataBrowserTableViewItemCompareUPP
= NewDataBrowserItemCompareUPP(wxMacDataBrowserTableViewControl::DataBrowserCompareProc
);
120 if (gDataBrowserTableViewItemDataUPP
== NULL
) gDataBrowserTableViewItemDataUPP
= NewDataBrowserItemDataUPP (wxMacDataBrowserTableViewControl::DataBrowserGetSetItemDataProc
);
121 if (gDataBrowserTableViewItemNotificationUPP
== NULL
)
123 gDataBrowserTableViewItemNotificationUPP
=
124 #if TARGET_API_MAC_OSX
125 (DataBrowserItemNotificationUPP
) NewDataBrowserItemNotificationWithItemUPP(wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc
);
127 NewDataBrowserItemNotificationUPP(wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc
);
131 DataBrowserCallbacks callbacks
;
132 DataBrowserCustomCallbacks customCallbacks
;
134 InitializeDataBrowserCallbacks (&callbacks
, kDataBrowserLatestCallbacks
);
135 InitializeDataBrowserCustomCallbacks(&customCallbacks
,kDataBrowserLatestCallbacks
);
137 callbacks
.u
.v1
.itemDataCallback
= gDataBrowserTableViewItemDataUPP
;
138 callbacks
.u
.v1
.itemCompareCallback
= gDataBrowserTableViewItemCompareUPP
;
139 callbacks
.u
.v1
.itemNotificationCallback
= gDataBrowserTableViewItemNotificationUPP
;
140 this->SetCallbacks(&callbacks
);
142 customCallbacks
.u
.v1
.drawItemCallback
= gDataBrowserTableViewDrawItemUPP
;
143 this->SetCustomCallbacks(&customCallbacks
);
146 this->EnableCellSizeModification();
148 DataBrowserSelectionFlags flags
; // variable definition
150 if (this->GetSelectionFlags(&flags
) == noErr
) // get default settings
152 if ((style
& wxDV_MULTIPLE
) != 0)
153 flags
&= ~kDataBrowserSelectOnlyOne
;
155 flags
|= kDataBrowserSelectOnlyOne
;
156 (void) this->SetSelectionFlags(flags
);
158 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
159 OptionBits attributes
; // variable definition
161 if (this->GetAttributes(&attributes
) == noErr
) // get default settings
163 if ((style
& wxDV_VERT_RULES
) != 0)
164 attributes
|= kDataBrowserAttributeListViewDrawColumnDividers
;
166 attributes
&= ~kDataBrowserAttributeListViewDrawColumnDividers
;
167 (void) this->SetAttributes(attributes
);
170 if ((style
& wxDV_NO_HEADER
) != 0)
171 this->SetHeaderButtonHeight(0);
172 } /* wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow*, wxPoint const&, wxSize const&, long) */
177 OSStatus
wxMacDataBrowserTableViewControl::SetCallbacks(DataBrowserCallbacks
const* callbacks
)
179 return ::SetDataBrowserCallbacks(this->m_controlRef
,callbacks
);
180 } /* wxMacDataBrowserTableViewControl::SetCallbacks(DataBrowserCallbacks const*) */
182 OSStatus
wxMacDataBrowserTableViewControl::SetCustomCallbacks(DataBrowserCustomCallbacks
const* customCallbacks
)
184 return ::SetDataBrowserCustomCallbacks(this->m_controlRef
,customCallbacks
);
185 } /* xMacDataBrowserTableViewControl::SetCustomCallbacks(DataBrowserCustomCallbacks const*) */
190 OSStatus
wxMacDataBrowserTableViewControl::GetHeaderDesc(DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
* desc
) const
192 desc
->version
= kDataBrowserListViewLatestHeaderDesc
; // if this statement is missing the next call will fail (NOT DOCUMENTED!!)
193 return ::GetDataBrowserListViewHeaderDesc(this->m_controlRef
,property
,desc
);
196 OSStatus
wxMacDataBrowserTableViewControl::SetHeaderDesc(DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
* desc
)
198 return ::SetDataBrowserListViewHeaderDesc(this->m_controlRef
,property
,desc
);
204 OSStatus
wxMacDataBrowserTableViewControl::AutoSizeColumns()
206 return AutoSizeDataBrowserListViewColumns(this->m_controlRef
);
209 OSStatus
wxMacDataBrowserTableViewControl::EnableCellSizeModification(bool enableHeight
, bool enableWidth
)
211 return ::SetDataBrowserTableViewGeometry(this->GetControlRef(),enableWidth
,enableHeight
);
212 } /* wxMacDataBrowserTableViewControl::EnableCellSizeModification(bool, bool) */
214 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
215 OSStatus
wxMacDataBrowserTableViewControl::GetAttributes(OptionBits
* attributes
)
217 return ::DataBrowserGetAttributes(this->GetControlRef(),attributes
);
218 } /* wxMacDataBrowserTableViewControl::GetAttributes(OptionBits*) */
221 OSStatus
wxMacDataBrowserTableViewControl::GetColumnWidth(DataBrowserPropertyID propertyID
, UInt16
* width
) const
223 return ::GetDataBrowserTableViewNamedColumnWidth(this->m_controlRef
,propertyID
,width
);
226 OSStatus
wxMacDataBrowserTableViewControl::GetDefaultColumnWidth( UInt16
*width
) const
228 return GetDataBrowserTableViewColumnWidth(this->m_controlRef
, width
);
231 OSStatus
wxMacDataBrowserTableViewControl::GetDefaultRowHeight(UInt16
* height
) const
233 return ::GetDataBrowserTableViewRowHeight(this->m_controlRef
,height
);
236 OSStatus
wxMacDataBrowserTableViewControl::GetHeaderButtonHeight(UInt16
*height
)
238 return ::GetDataBrowserListViewHeaderBtnHeight(this->m_controlRef
,height
);
241 OSStatus
wxMacDataBrowserTableViewControl::GetPartBounds(DataBrowserItemID item
, DataBrowserPropertyID property
, DataBrowserPropertyPart part
, Rect
* bounds
)
243 return ::GetDataBrowserItemPartBounds(this->m_controlRef
,item
,property
,part
,bounds
);
244 } /* wxMacDataBrowserTableViewControl::GetPartBounds(DataBrowserItemID, DataBrowswerPropertyID, DataBrowserPropertyPart, Rect*) */
246 OSStatus
wxMacDataBrowserTableViewControl::GetRowHeight(DataBrowserItemID item
, UInt16
* height
) const
248 return ::GetDataBrowserTableViewItemRowHeight(this->m_controlRef
,item
,height
);
249 } /* wxMacDataBrowserTableViewControl::GetRowHeight(DataBrowserItemID, UInt16*) const */
251 OSStatus
wxMacDataBrowserTableViewControl::GetScrollPosition( UInt32
*top
, UInt32
*left
) const
253 return GetDataBrowserScrollPosition(this->m_controlRef
, top
, left
);
256 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
257 OSStatus
wxMacDataBrowserTableViewControl::SetAttributes(OptionBits attributes
)
259 return ::DataBrowserChangeAttributes(this->GetControlRef(),attributes
,~attributes
);
260 } /* wxMacDataBrowserTableViewControl::SetAttributes(OptionBits) */
263 OSStatus
wxMacDataBrowserTableViewControl::SetColumnWidth(DataBrowserPropertyID propertyID
, UInt16 width
)
265 return ::SetDataBrowserTableViewNamedColumnWidth(this->m_controlRef
,propertyID
,width
);
268 OSStatus
wxMacDataBrowserTableViewControl::SetDefaultColumnWidth(UInt16 width
)
270 return ::SetDataBrowserTableViewColumnWidth(this->m_controlRef
,width
);
273 OSStatus
wxMacDataBrowserTableViewControl::SetDefaultRowHeight(UInt16 height
)
275 return ::SetDataBrowserTableViewRowHeight(this->m_controlRef
,height
);
278 OSStatus
wxMacDataBrowserTableViewControl::SetHasScrollBars(bool horiz
, bool vert
)
280 return ::SetDataBrowserHasScrollBars(this->m_controlRef
,horiz
,vert
);
281 } /* wxMacDataBrowserTableViewControl::SetHasScrollBars(bool, bool) */
283 OSStatus
wxMacDataBrowserTableViewControl::SetHeaderButtonHeight(UInt16 height
)
285 return ::SetDataBrowserListViewHeaderBtnHeight(this->m_controlRef
,height
);
286 } /* wxMacDataBrowserTableViewControl::SetHeaderButtonHeight(UInt16) */
288 OSStatus
wxMacDataBrowserTableViewControl::SetHiliteStyle(DataBrowserTableViewHiliteStyle hiliteStyle
)
290 return ::SetDataBrowserTableViewHiliteStyle(this->m_controlRef
,hiliteStyle
);
291 } /*wxMacDataBrowserTableViewControl::SetHiliteStyle(DataBrowserTableViewHiliteStyle) */
293 OSStatus
wxMacDataBrowserTableViewControl::SetIndent(float Indent
)
295 return ::DataBrowserSetMetric(this->m_controlRef
,kDataBrowserMetricDisclosureColumnPerDepthGap
,true,Indent
);
296 } /* wxMacDataBrowserTableViewControl::SetIndent(float* Indent) */
298 OSStatus
wxMacDataBrowserTableViewControl::SetRowHeight(DataBrowserItemID item
, UInt16 height
)
300 return ::SetDataBrowserTableViewItemRowHeight(this->m_controlRef
,item
,height
);
303 OSStatus
wxMacDataBrowserTableViewControl::SetScrollPosition(UInt32 top
, UInt32 left
)
305 return ::SetDataBrowserScrollPosition(this->m_controlRef
,top
,left
);
311 OSStatus
wxMacDataBrowserTableViewControl::GetColumnCount(UInt32
* numColumns
) const
313 return ::GetDataBrowserTableViewColumnCount(this->m_controlRef
,numColumns
);
316 OSStatus
wxMacDataBrowserTableViewControl::GetColumnIndex(DataBrowserPropertyID propertyID
, DataBrowserTableViewColumnIndex
* index
) const
318 return ::GetDataBrowserTableViewColumnPosition(this->m_controlRef
,propertyID
,index
);
319 } /* wxMacDataBrowserTableViewControl::GetColumnIndex(DataBrowserPropertyID, DataBrowserTableViewColumnIndex*) const */
321 OSStatus
wxMacDataBrowserTableViewControl::GetFreePropertyID(DataBrowserPropertyID
* propertyID
) const
323 for (*propertyID
=kMinPropertyID
; *propertyID
<std::numeric_limits
<DataBrowserPropertyID
>::max(); ++(*propertyID
))
324 if (this->IsUsedPropertyID(*propertyID
) == errDataBrowserPropertyNotFound
)
326 return errDataBrowserPropertyNotSupported
;
327 } /* wxMacDataBrowserTableViewControl::GetFreePropertyID(DataBrowserPropertyID*) const */
329 OSStatus
wxMacDataBrowserTableViewControl::GetPropertyFlags(DataBrowserPropertyID propertyID
, DataBrowserPropertyFlags
*flags
) const
331 return ::GetDataBrowserPropertyFlags(this->m_controlRef
,propertyID
,flags
);
334 OSStatus
wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserItemDataRef itemData
, DataBrowserPropertyID
* propertyID
)
336 return ::GetDataBrowserItemDataProperty(itemData
,propertyID
);
337 } /* wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserItemDataRef, DataBrowserPropertyID*) */
339 OSStatus
wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserTableViewColumnIndex index
, DataBrowserTableViewColumnID
* propertyID
)
341 return ::GetDataBrowserTableViewColumnProperty(this->m_controlRef
,index
,propertyID
);
342 } /* wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserTableViewColumnIndex, DataBrowserTableViewColumnID*) */
344 OSStatus
wxMacDataBrowserTableViewControl::IsUsedPropertyID(DataBrowserPropertyID propertyID
) const
346 // 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
347 // 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
348 // the column position for the property id:
349 DataBrowserTableViewColumnIndex index
;
351 return ::GetDataBrowserTableViewColumnPosition(this->m_controlRef
,propertyID
,&index
);
352 } /* wxMacDataBrowserTableViewControl::IsUsedPropertyId(DataBrowserPropertyID) const */
354 OSStatus
wxMacDataBrowserTableViewControl::RemoveColumnByProperty(DataBrowserTableViewColumnID propertyID
)
356 return ::RemoveDataBrowserTableViewColumn(this->m_controlRef
,propertyID
);
357 } /* wxMacDataBrowserTableViewControl::RemoveColumnByProperty(DataBrowserTableViewColumnID) */
359 OSStatus
wxMacDataBrowserTableViewControl::RemoveColumnByIndex(DataBrowserTableViewColumnIndex index
)
361 DataBrowserTableViewColumnID propertyID
;
364 this->GetPropertyID(index
,&propertyID
);
365 return ::RemoveDataBrowserTableViewColumn(this->m_controlRef
,propertyID
);
366 } /* wxMacDataBrowserTableViewControl::RemoveColumnByIndex(DataBrowserTableViewColumnIndex) */
368 OSStatus
wxMacDataBrowserTableViewControl::SetColumnIndex(DataBrowserPropertyID propertyID
, DataBrowserTableViewColumnIndex index
)
370 return ::SetDataBrowserTableViewColumnPosition(this->m_controlRef
,propertyID
,index
);
371 } /* wxMacDataBrowserTableViewControl::SetColumnIndex(DataBrowserPropertyID, DataBrowserTableViewColumnIndex) */
373 OSStatus
wxMacDataBrowserTableViewControl::SetDisclosureColumn(DataBrowserPropertyID propertyID
, Boolean expandableRows
)
375 return ::SetDataBrowserListViewDisclosureColumn(this->m_controlRef
,propertyID
,expandableRows
);
378 OSStatus
wxMacDataBrowserTableViewControl::SetPropertyFlags(DataBrowserPropertyID propertyID
, DataBrowserPropertyFlags flags
)
380 return ::SetDataBrowserPropertyFlags(this->m_controlRef
,propertyID
,flags
);
381 } /* wxMacDataBrowserTableViewControl::SetPropertyFlags(DataBrowserPropertyID, DataBrowserPropertyFlags) */
386 OSStatus
wxMacDataBrowserTableViewControl::AddItems(DataBrowserItemID container
, UInt32 numItems
, DataBrowserItemID
const* items
, DataBrowserPropertyID preSortProperty
)
388 return ::AddDataBrowserItems(this->m_controlRef
,container
,numItems
,items
,preSortProperty
);
389 } /* wxMacDataBrowserTableViewControl::AddItems(DataBrowserItemID, UInt32, DataBrowserItemID const*, DataBrowserPropertyID) */
391 OSStatus
wxMacDataBrowserTableViewControl::GetFreeItemID(DataBrowserItemID
* id
) const
396 verify_noerr(this->GetItemCount(&NoOfItems
));
404 // 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
405 // as the number of items; therefore, start from the number of items to look for a new ID:
406 for (*id
=NoOfItems
; *id
<std::numeric_limits
<DataBrowserItemID
>::max(); ++(*id
))
407 if (this->IsUsedItemID(*id
) == errDataBrowserItemNotFound
)
409 // as the first approach was not successful, try from the beginning:
410 for (*id
=0; *id
<NoOfItems
; ++(*id
))
411 if (this->IsUsedItemID(*id
) == errDataBrowserItemNotFound
)
413 // sorry, data browser is full:
414 return errDataBrowserItemNotAdded
;
416 } /* wxMacDataBrowserTableViewControl::GetFreeItemID(DataBrowserItemID*) const */
418 OSStatus
wxMacDataBrowserTableViewControl::GetItemCount(DataBrowserItemID container
, Boolean recurse
, DataBrowserItemState state
, ItemCount
* numItems
) const
420 return GetDataBrowserItemCount(this->m_controlRef
,container
,recurse
,state
,numItems
);
421 } /* wxMacDataBrowserTableViewControl::GetItemCount(DataBrowserItemID, Boolean, DataBrowserItemState, ItemCount*) const */
423 OSStatus
wxMacDataBrowserTableViewControl::GetItemID( DataBrowserTableViewRowIndex row
, DataBrowserItemID
* item
) const
425 return GetDataBrowserTableViewItemID(this->m_controlRef
,row
,item
);
428 OSStatus
wxMacDataBrowserTableViewControl::GetItems(DataBrowserItemID container
, Boolean recurse
, DataBrowserItemState state
, Handle items
) const
430 return GetDataBrowserItems(this->m_controlRef
,container
,recurse
,state
,items
);
431 } /* wxMacDataBrowserTableViewControl::GetItems(DataBrowserItemID, Boolean, DataBrowserItemState, Handle) const */
433 OSStatus
wxMacDataBrowserTableViewControl::GetItemRow(DataBrowserItemID item
, DataBrowserTableViewRowIndex
* row
) const
435 return GetDataBrowserTableViewItemRow(this->m_controlRef
,item
,row
);
438 OSStatus
wxMacDataBrowserTableViewControl::IsUsedItemID(DataBrowserItemID itemID
) const
440 // 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
441 // 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
442 // the column position for the property id:
443 DataBrowserTableViewColumnIndex index
;
445 return ::GetDataBrowserTableViewItemRow(this->m_controlRef
,itemID
,&index
);
446 } /* wxMacDataBrowserTableViewControl::IsUsedItemID(DataBrowserItemID) const */
448 OSStatus
wxMacDataBrowserTableViewControl::RemoveItems(DataBrowserItemID container
, UInt32 numItems
, DataBrowserItemID
const* items
, DataBrowserPropertyID preSortProperty
)
450 return ::RemoveDataBrowserItems(this->m_controlRef
,container
,numItems
,items
,preSortProperty
);
453 OSStatus
wxMacDataBrowserTableViewControl::RevealItem(DataBrowserItemID item
, DataBrowserPropertyID propertyID
, DataBrowserRevealOptions options
) const
455 return ::RevealDataBrowserItem(this->m_controlRef
,item
,propertyID
,options
);
456 } /* wxMacDataBrowserTableViewControl::RevealItem(DataBrowserItemID item, DataBrowserPropertyID propertyID, DataBrowserRevealOptions options) const */
458 OSStatus
wxMacDataBrowserTableViewControl::UpdateItems(DataBrowserItemID container
, UInt32 numItems
, DataBrowserItemID
const* items
, DataBrowserPropertyID preSortProperty
,
459 DataBrowserPropertyID propertyID
) const
461 return UpdateDataBrowserItems(this->m_controlRef
,container
,numItems
,items
,preSortProperty
,propertyID
);
467 size_t wxMacDataBrowserTableViewControl::GetSelectedItemIDs(wxArrayDataBrowserItemID
& itemIDs
) const
469 DataBrowserItemID
* itemIDPtr
;
470 Handle
handle(::NewHandle(0));
475 wxCHECK_MSG(this->GetItems(kDataBrowserNoItem
,true,kDataBrowserItemIsSelected
,handle
) == noErr
,0,_("Could not get selected items."));
476 NoOfItems
= static_cast<size_t>(::GetHandleSize(handle
)/sizeof(DataBrowserItemID
));
478 itemIDs
.Alloc(NoOfItems
);
480 itemIDPtr
= (DataBrowserItemID
*) (*handle
);
481 for (size_t i
=0; i
<NoOfItems
; ++i
)
483 itemIDs
.Add(*itemIDPtr
);
487 DisposeHandle(handle
);
489 } /* wxMacDataBrowserTableViewControl::GetSelectedItemIDs(wxArrayDataBrowserItemID&) const*/
491 OSStatus
wxMacDataBrowserTableViewControl::GetSelectionAnchor(DataBrowserItemID
* first
, DataBrowserItemID
* last
) const
493 return ::GetDataBrowserSelectionAnchor(this->m_controlRef
,first
,last
);
494 } /* wxMacDataBrowserTableViewControl::GetSelectionAnchor(DataBrowserItemID*, DataBrowserItemID*) const */
496 OSStatus
wxMacDataBrowserTableViewControl::GetSelectionFlags(DataBrowserSelectionFlags
* flags
) const
498 return ::GetDataBrowserSelectionFlags(this->m_controlRef
,flags
);
499 } /* wxMacDataBrowserTableViewControl::GetSelectionFlags(DataBrowserSelectionFlags*) const */
501 bool wxMacDataBrowserTableViewControl::IsItemSelected(DataBrowserItemID item
) const
503 return ::IsDataBrowserItemSelected(this->m_controlRef
,item
);
504 } /* wxMacDataBrowserTableViewControl::IsItemSelected(DataBrowserItemID) const */
506 OSStatus
wxMacDataBrowserTableViewControl::SetSelectionFlags(DataBrowserSelectionFlags flags
)
508 return ::SetDataBrowserSelectionFlags(this->m_controlRef
,flags
);
509 } /* wxMacDataBrowserTableViewControl::SetSelectionFlags(DataBrowserSelectionFlags) */
511 OSStatus
wxMacDataBrowserTableViewControl::SetSelectedItems(UInt32 numItems
, DataBrowserItemID
const* items
, DataBrowserSetOption operation
)
513 return ::SetDataBrowserSelectedItems(this->m_controlRef
, numItems
, items
, operation
);
514 } /* wxMacDataBrowserTableViewControl::SetSelectedItems(UInt32, DataBrowserItemID const*, DataBrowserSetOption) */
516 OSStatus
wxMacDataBrowserTableViewControl::GetSortOrder(DataBrowserSortOrder
* order
) const
518 return ::GetDataBrowserSortOrder(this->m_controlRef
,order
);
521 OSStatus
wxMacDataBrowserTableViewControl::GetSortProperty(DataBrowserPropertyID
* propertyID
) const
523 return ::GetDataBrowserSortProperty(this->m_controlRef
,propertyID
);
526 OSStatus
wxMacDataBrowserTableViewControl::Resort(DataBrowserItemID container
, Boolean sortChildren
)
528 return ::SortDataBrowserContainer(this->m_controlRef
,container
,sortChildren
);
529 } /* wxMacDataBrowserTableViewControl::Resort(DataBrowserItemID, Boolean) */
531 OSStatus
wxMacDataBrowserTableViewControl::SetSortOrder(DataBrowserSortOrder order
)
533 return ::SetDataBrowserSortOrder(this->m_controlRef
,order
);
536 OSStatus
wxMacDataBrowserTableViewControl::SetSortProperty(DataBrowserPropertyID propertyID
)
538 return ::SetDataBrowserSortProperty(this->m_controlRef
,propertyID
);
542 // container handling
544 OSStatus
wxMacDataBrowserTableViewControl::CloseContainer(DataBrowserItemID containerID
)
546 return ::CloseDataBrowserContainer(this->m_controlRef
,containerID
);
547 } /* wxMacDataBrowserTableViewControl::CloseContainer(DataBrowserItemID) */
549 OSStatus
wxMacDataBrowserTableViewControl::OpenContainer(DataBrowserItemID containerID
)
551 return ::OpenDataBrowserContainer(this->m_controlRef
,containerID
);
552 } /* wxMacDataBrowserTableViewControl::OpenContainer(DataBrowserItemID) */
554 IMPLEMENT_ABSTRACT_CLASS(wxMacDataBrowserTableViewControl
,wxMacControl
)
556 // ============================================================================
557 // wxMacDataBrowserListViewControl
558 // ============================================================================
563 OSStatus
wxMacDataBrowserListViewControl::AddColumn(DataBrowserListViewColumnDesc
*columnDesc
, DataBrowserTableViewColumnIndex position
)
565 return AddDataBrowserListViewColumn(this->m_controlRef
,columnDesc
,position
);
566 } /* wxMacDataBrowserListViewControl::AddColumn(DataBrowserListViewColumnDesc*, DataBrowserTableViewColumnIndex) */
568 // ============================================================================
569 // wxMacDataViewDataBrowserListViewControl
570 // ============================================================================
573 // constructors / destructor
575 wxMacDataViewDataBrowserListViewControl::wxMacDataViewDataBrowserListViewControl(wxWindow
* peer
, wxPoint
const& pos
, wxSize
const& size
, long style
)
576 :wxMacDataBrowserListViewControl(peer
,pos
,size
,style
)
578 } /* wxMacDataViewDataBrowserListViewControl::wxMacDataViewDataBrowserListViewControl(wxWindow* , const wxPoint&, const wxSize&, long) */
581 // callback functions (inherited from wxMacDataBrowserTableViewControl)
583 Boolean
wxMacDataViewDataBrowserListViewControl::DataBrowserCompareProc(DataBrowserItemID itemOneID
, DataBrowserItemID itemTwoID
, DataBrowserPropertyID sortProperty
)
585 DataBrowserSortOrder sortOrder
;
587 DataBrowserTableViewColumnIndex columnIndex
;
589 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
592 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
, false,_("Pointer to data view control not set correctly."));
593 wxCHECK_MSG(dataViewCtrlPtr
->GetModel() != NULL
,false,_("Pointer to model not set correctly."));
594 if (sortProperty
>= kMinPropertyID
)
596 wxCHECK_MSG(this->GetColumnIndex(sortProperty
,&columnIndex
) == noErr
,false,_("Could not determine column index."));
600 this->GetSortOrder(&sortOrder
);
601 return static_cast<Boolean
>(dataViewCtrlPtr
->GetModel()->Compare(wxDataViewItem(reinterpret_cast<void*>(itemOneID
)),wxDataViewItem(reinterpret_cast<void*>(itemTwoID
)),
602 columnIndex
,sortOrder
!= kDataBrowserOrderDecreasing
) < 0);
603 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserCompareProc(DataBrowserItemID, DataBrowserItemID, DataBrowserPropertyID) */
605 void wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowserItemID itemID
, DataBrowserPropertyID propertyID
, DataBrowserItemState state
, Rect
const* rectangle
, SInt16 bitDepth
, Boolean colorDevice
)
607 DataBrowserTableViewColumnIndex columnIndex
;
609 wxDataViewColumn
* dataViewColumnPtr
;
611 wxDataViewCtrl
* dataViewCtrlPtr
;
613 wxDataViewCustomRenderer
* dataViewCustomRendererPtr
;
615 wxVariant dataToRender
;
618 dataViewCtrlPtr
= dynamic_cast<wxDataViewCtrl
*>(this->GetPeer());
619 wxCHECK_RET(dataViewCtrlPtr
!= NULL
, _("Pointer to data view control not set correctly."));
620 wxCHECK_RET(dataViewCtrlPtr
->GetModel() != NULL
, _("Pointer to model not set correctly."));
621 wxCHECK_RET(this->GetColumnIndex(propertyID
,&columnIndex
) == noErr
,_("Could not determine column index."));
622 dataViewColumnPtr
= dataViewCtrlPtr
->GetColumn(columnIndex
);
623 wxCHECK_RET(dataViewColumnPtr
!= NULL
,_("No column for the specified column index existing."));
624 dataViewCustomRendererPtr
= dynamic_cast<wxDataViewCustomRenderer
*>(dataViewColumnPtr
->GetRenderer());
625 wxCHECK_RET(dataViewCustomRendererPtr
!= NULL
,_("No renderer or invalid renderer type specified for custom data column."));
626 dataViewCtrlPtr
->GetModel()->GetValue(dataToRender
,wxDataViewItem(reinterpret_cast<void*>(itemID
)),columnIndex
);
627 dataViewCustomRendererPtr
->SetValue(dataToRender
);
629 // try to determine the content's size (drawable part):
631 RgnHandle
rgn(NewRgn());
634 if (this->GetRegion(kControlContentMetaPart
,rgn
) == noErr
)
635 GetRegionBounds(rgn
,&content
);
637 this->GetRect(&content
);
639 // space for the header
640 this->GetHeaderButtonHeight(&headerHeight
);
641 content
.top
+= headerHeight
;
642 // extra space for the frame (todo: do not how to determine the space automatically from the control)
647 // extra space for the scrollbars:
648 content
.bottom
-= wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y
);
649 content
.right
-= wxSystemSettings::GetMetric(wxSYS_VSCROLL_X
);
651 // make sure that 'Render' can draw only in the allowed area:
652 dataViewCustomRendererPtr
->GetDC()->SetClippingRegion(content
.left
,content
.top
,content
.right
-content
.left
+1,content
.bottom
-content
.top
+1);
653 (void) (dataViewCustomRendererPtr
->Render(wxRect(static_cast<int>(rectangle
->left
),static_cast<int>(rectangle
->top
),
654 static_cast<int>(1+rectangle
->right
-rectangle
->left
),static_cast<int>(1+rectangle
->bottom
-rectangle
->top
)),
655 dataViewCustomRendererPtr
->GetDC(),((state
== kDataBrowserItemIsSelected
) ? wxDATAVIEW_CELL_SELECTED
: 0)));
656 dataViewCustomRendererPtr
->GetDC()->DestroyClippingRegion(); // probably not necessary
657 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemState, Rect const*, SInt16, Boolean) */
659 OSStatus
wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(DataBrowserItemID itemID
, DataBrowserPropertyID propertyID
, DataBrowserItemDataRef itemData
, Boolean getValue
)
663 // variable definitions:
664 wxDataViewCtrl
* dataViewCtrlPtr
;
666 dataViewCtrlPtr
= dynamic_cast<wxDataViewCtrl
*>(this->GetPeer());
667 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
,errDataBrowserNotConfigured
,_("Pointer to data view control not set correctly."));
668 if (dataViewCtrlPtr
->IsDeleting())
669 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
672 // variable definitions:
673 DataBrowserTableViewColumnIndex columnIndex
;
674 OSStatus errorStatus
;
675 wxDataViewColumn
* dataViewColumnPtr
;
677 wxCHECK_MSG(dataViewCtrlPtr
->GetModel() != NULL
,errDataBrowserNotConfigured
,_("Pointer to model not set correctly."));
678 errorStatus
= this->GetColumnIndex(propertyID
,&columnIndex
);
679 wxCHECK_MSG(errorStatus
== noErr
,errorStatus
,_("Could not determine column index"));
680 dataViewColumnPtr
= dataViewCtrlPtr
->GetColumn(columnIndex
);
681 wxCHECK_MSG((dataViewColumnPtr
!= NULL
) && (dataViewColumnPtr
->GetRenderer() != NULL
),errDataBrowserNotConfigured
,_("There is no column or renderer for the specified column index."));
682 switch (dataViewColumnPtr
->GetRenderer()->GetPropertyType())
684 case kDataBrowserCheckboxType
:
686 // variable definition:
687 ThemeButtonValue buttonValue
;
689 errorStatus
= ::GetDataBrowserItemDataButtonValue(itemData
,&buttonValue
);
690 if (errorStatus
== noErr
)
692 if (buttonValue
== kThemeButtonOn
)
694 // variable definition and initialization:
695 wxVariant
modifiedData(true);
697 return (dataViewCtrlPtr
->GetModel()->SetValue(modifiedData
,wxDataViewItem(reinterpret_cast<void*>(itemID
)),static_cast<unsigned int>(columnIndex
)) ? OSStatus(noErr
) : OSStatus(errDataBrowserNotConfigured
));
699 else if (buttonValue
== kThemeButtonOff
)
701 // variable definition and initialization:
702 wxVariant
modifiedData(false);
704 return (dataViewCtrlPtr
->GetModel()->SetValue(modifiedData
,wxDataViewItem(reinterpret_cast<void*>(itemID
)),static_cast<unsigned int>(columnIndex
)) ? OSStatus(noErr
) : OSStatus(errDataBrowserNotConfigured
));
707 return errDataBrowserInvalidPropertyData
;
712 case kDataBrowserTextType
:
714 // variable definitions:
715 CFStringRef stringReference
;
717 errorStatus
= ::GetDataBrowserItemDataText(itemData
,&stringReference
);
718 if (errorStatus
== noErr
)
720 // variable definitions and initializations:
721 wxMacCFStringHolder
modifiedString(stringReference
);
722 wxVariant
modifiedData(modifiedString
.AsString());
724 if (dataViewCtrlPtr
->GetModel()->SetValue(modifiedData
,wxDataViewItem(reinterpret_cast<void*>(itemID
)),static_cast<unsigned int>(columnIndex
)))
727 return errDataBrowserNotConfigured
;
733 return errDataBrowserPropertyNotSupported
;
739 if (propertyID
>= kMinPropertyID
) // in case data columns set the data
741 // variable definitions:
743 wxDataViewColumn
* dataViewColumnPtr
;
744 wxDataViewCtrl
* dataViewCtrlPtr
;
746 dataViewCtrlPtr
= dynamic_cast<wxDataViewCtrl
*>(this->GetPeer());
747 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
,errDataBrowserNotConfigured
,_("Pointer to data view control not set correctly."));
748 wxCHECK_MSG(dataViewCtrlPtr
->GetModel() != NULL
,errDataBrowserNotConfigured
,_("Pointer to model not set correctly."));
749 dataViewColumnPtr
= dataViewCtrlPtr
->GetColumnPtr(propertyID
);
750 wxCHECK_MSG(dataViewColumnPtr
!= NULL
,errDataBrowserNotConfigured
,_("No column for the specified column position existing."));
751 wxCHECK_MSG(dataViewColumnPtr
->GetRenderer() != NULL
,errDataBrowserNotConfigured
,_("No renderer specified for column."));
752 dataViewCtrlPtr
->GetModel()->GetValue(variant
,wxDataViewItem(reinterpret_cast<void*>(itemID
)),dataViewColumnPtr
->GetModelColumn());
753 if (!(variant
.IsNull()))
755 dataViewColumnPtr
->GetRenderer()->SetDataReference(itemData
);
756 dataViewColumnPtr
->GetRenderer()->SetValue(variant
);
757 wxCHECK_MSG(dataViewColumnPtr
->GetRenderer()->Render(),errDataBrowserNotConfigured
,_("Rendering failed."));
761 else // react on special system requests
765 case kDataBrowserContainerIsClosableProperty
:
767 // variable definitions:
768 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
770 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
,errDataBrowserNotConfigured
,_("Pointer to data view control not set correctly."));
771 // initialize wxWidget event:
772 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING
,dataViewCtrlPtr
->GetId()); // variable definition
774 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
775 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
776 // finally send the equivalent wxWidget event:
777 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
778 // opening the container is allowed if not vetoed:
779 return ::SetDataBrowserItemDataBooleanValue(itemData
,dataViewEvent
.IsAllowed());
781 case kDataBrowserContainerIsOpenableProperty
:
783 // variable definitions:
784 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
786 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
,errDataBrowserNotConfigured
,_("Pointer to data view control not set correctly."));
787 // initialize wxWidget event:
788 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING
,dataViewCtrlPtr
->GetId()); // variable definition
790 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
791 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
792 // finally send the equivalent wxWidget event:
793 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
794 // opening the container is allowed if not vetoed:
795 return ::SetDataBrowserItemDataBooleanValue(itemData
,dataViewEvent
.IsAllowed());
797 case kDataBrowserItemIsContainerProperty
:
799 // variable definition:
800 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
802 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
,errDataBrowserNotConfigured
,_("Pointer to data view control not set correctly."));
803 wxCHECK_MSG(dataViewCtrlPtr
->GetModel() != NULL
,errDataBrowserNotConfigured
,_("Pointer to model not set correctly."));
804 return ::SetDataBrowserItemDataBooleanValue(itemData
,dataViewCtrlPtr
->GetModel()->IsContainer(wxDataViewItem(reinterpret_cast<void*>(itemID
))));
806 case kDataBrowserItemIsEditableProperty
:
807 return ::SetDataBrowserItemDataBooleanValue(itemData
,true);
811 return errDataBrowserPropertyNotSupported
;
812 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemDataRef, Boolean) */
814 void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(DataBrowserItemID itemID
, DataBrowserItemNotification message
, DataBrowserItemDataRef itemData
)
818 case kDataBrowserContainerClosed
:
820 // variable definitions:
821 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
823 if (dataViewCtrlPtr
!= NULL
) // can become NULL when the window is being deleted (wxWidget has already disposed the data before receiving this event
825 // initialize wxWidget event:
826 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED
,dataViewCtrlPtr
->GetId()); // variable definition
828 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
829 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
830 // finally send the equivalent wxWidget event:
831 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
835 case kDataBrowserContainerOpened
:
837 // variable definitions:
838 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
840 wxCHECK_RET(dataViewCtrlPtr
!= NULL
,_("Pointer to data view control not set correctly."));
841 dataViewCtrlPtr
->AddChildrenLevel(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
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
->GetEventHandler()->ProcessEvent(dataViewEvent
);
851 case kDataBrowserEditStarted
:
853 // variable definitions:
854 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
856 if (dataViewCtrlPtr
!= NULL
)
858 // initialize wxWidget event:
859 DataBrowserPropertyID propertyID
;
860 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED
,dataViewCtrlPtr
->GetId()); // variable definition
862 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
863 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
864 if (this->GetPropertyID(itemData
,&propertyID
) == noErr
)
866 // variable definition and initialization:
867 DataBrowserTableViewColumnIndex columnIndex
;
869 wxCHECK_RET(this->GetColumnIndex(propertyID
,&columnIndex
),_("Column index not found."));
870 dataViewEvent
.SetColumn(columnIndex
);
871 dataViewEvent
.SetDataViewColumn(dataViewCtrlPtr
->GetColumnPtr(propertyID
));
873 // finally send the equivalent wxWidget event:
874 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
878 case kDataBrowserEditStopped
:
880 // variable definitions:
881 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
883 if (dataViewCtrlPtr
!= NULL
)
885 // initialize wxWidget event:
886 DataBrowserPropertyID propertyID
;
887 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE
,dataViewCtrlPtr
->GetId()); // variable definition
889 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
890 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
891 if (this->GetPropertyID(itemData
,&propertyID
) == noErr
)
893 // variable definition and initialization:
894 DataBrowserTableViewColumnIndex columnIndex
;
896 wxCHECK_RET(this->GetColumnIndex(propertyID
,&columnIndex
),_("Column index not found."));
897 dataViewEvent
.SetColumn(columnIndex
);
898 dataViewEvent
.SetDataViewColumn(dataViewCtrlPtr
->GetColumnPtr(propertyID
));
900 // finally send the equivalent wxWidget event:
901 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
905 case kDataBrowserItemAdded
:
907 // variable definitions:
908 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
910 wxCHECK_RET(dataViewCtrlPtr
!= NULL
,_("Pointer to data view control not set correctly."));
911 // initialize wxWidget event:
912 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_ADDED
,dataViewCtrlPtr
->GetId()); // variable definition
914 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
915 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
916 // finally send the equivalent wxWidget event:
917 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
920 case kDataBrowserItemDeselected
:
922 // variable definitions:
923 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
925 if (dataViewCtrlPtr
!= NULL
) // can become NULL if an item is still selected while removing the data browser
927 // initialize wxWidget event:
928 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_DESELECTED
,dataViewCtrlPtr
->GetId()); // variable definition
930 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
931 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
932 // finally send the equivalent wxWidget event:
933 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
937 case kDataBrowserItemDoubleClicked
:
939 // variable definitions:
940 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
942 wxCHECK_RET(dataViewCtrlPtr
!= NULL
,_("Pointer to data view control not set correctly."));
943 // initialize wxWidget event:
944 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED
,dataViewCtrlPtr
->GetId()); // variable definition
946 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
947 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
948 // finally send the equivalent wxWidget event:
949 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
952 case kDataBrowserItemRemoved
:
954 // variable definitions:
955 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
957 if (dataViewCtrlPtr
!= NULL
) // can become NULL when the window is being deleted (wxWidget has already disposed the data before receiving this event
959 // initialize wxWidget event:
960 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_DELETED
,dataViewCtrlPtr
->GetId()); // variable definition
962 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
963 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
964 // finally send the equivalent wxWidget event:
965 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
969 case kDataBrowserItemSelected
:
971 // variable definitions:
972 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
974 wxCHECK_RET(dataViewCtrlPtr
!= NULL
,_("Pointer to data view control not set correctly."));
975 // initialize wxWidget event:
976 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_SELECTED
,dataViewCtrlPtr
->GetId()); // variable definition
978 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
979 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
980 // finally send the equivalent wxWidget event:
981 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
984 case kDataBrowserSelectionSetChanged
:
986 case kDataBrowserUserStateChanged
:
988 DataBrowserPropertyID propertyID
;
990 if ((this->GetSortProperty(&propertyID
) == noErr
) && (propertyID
>= kMinPropertyID
))
992 DataBrowserSortOrder sortOrder
;
993 DataBrowserTableViewColumnIndex columnIndex
;
995 if ((this->GetSortOrder(&sortOrder
) == noErr
) && (this->GetColumnIndex(propertyID
,&columnIndex
) == noErr
))
997 // variable definition and initialization:
998 wxDataViewColumn
* columnPtr
;
999 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
1001 wxCHECK_RET(dataViewCtrlPtr
!= NULL
,_("Pointer to data vie wcontrol not set correctly."));
1002 columnPtr
= dataViewCtrlPtr
->GetColumn(columnIndex
);
1003 // check if the sort order has changed:
1004 if ( columnPtr
->IsSortOrderAscending() && (sortOrder
== kDataBrowserOrderDecreasing
) ||
1005 !(columnPtr
->IsSortOrderAscending()) && (sortOrder
== kDataBrowserOrderIncreasing
))
1007 columnPtr
->SetSortOrder(!(columnPtr
->IsSortOrderAscending()));
1008 // initialize wxWidget event:
1009 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED
,dataViewCtrlPtr
->GetId()); // variable defintion
1011 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
1012 dataViewEvent
.SetColumn(columnIndex
);
1013 dataViewEvent
.SetDataViewColumn(columnPtr
);
1014 // finally send the equivalent wxWidget event:
1015 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
1022 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(DataBrowserItemID, DataBrowserItemNotification, DataBrowserItemDataRef) */
1025 #endif // wxUSE_DATAVIEWCTRL
1026 #endif // wxUSE_GENERICDATAVIEWCTRL