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
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 OptionBits attributes
; // variable definition
139 if (this->GetAttributes(&attributes
) == noErr
) // get default settings
141 if ((style
& wxDV_VERT_RULES
) != 0)
142 attributes
|= kDataBrowserAttributeListViewDrawColumnDividers
;
144 attributes
&= ~kDataBrowserAttributeListViewDrawColumnDividers
;
145 (void) this->SetAttributes(attributes
);
147 if ((style
& wxDV_NO_HEADER
) != 0)
148 this->SetHeaderButtonHeight(0);
149 } /* wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow*, wxPoint const&, wxSize const&, long) */
154 OSStatus
wxMacDataBrowserTableViewControl::SetCallbacks(DataBrowserCallbacks
const* callbacks
)
156 return ::SetDataBrowserCallbacks(this->m_controlRef
,callbacks
);
157 } /* wxMacDataBrowserTableViewControl::SetCallbacks(DataBrowserCallbacks const*) */
159 OSStatus
wxMacDataBrowserTableViewControl::SetCustomCallbacks(DataBrowserCustomCallbacks
const* customCallbacks
)
161 return ::SetDataBrowserCustomCallbacks(this->m_controlRef
,customCallbacks
);
162 } /* xMacDataBrowserTableViewControl::SetCustomCallbacks(DataBrowserCustomCallbacks const*) */
167 OSStatus
wxMacDataBrowserTableViewControl::GetHeaderDesc(DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
* desc
) const
169 desc
->version
= kDataBrowserListViewLatestHeaderDesc
; // if this statement is missing the next call will fail (NOT DOCUMENTED!!)
170 return ::GetDataBrowserListViewHeaderDesc(this->m_controlRef
,property
,desc
);
173 OSStatus
wxMacDataBrowserTableViewControl::SetHeaderDesc(DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
* desc
)
175 return ::SetDataBrowserListViewHeaderDesc(this->m_controlRef
,property
,desc
);
181 OSStatus
wxMacDataBrowserTableViewControl::AutoSizeColumns()
183 return AutoSizeDataBrowserListViewColumns(this->m_controlRef
);
186 OSStatus
wxMacDataBrowserTableViewControl::EnableCellSizeModification(bool enableHeight
, bool enableWidth
)
188 return ::SetDataBrowserTableViewGeometry(this->GetControlRef(),enableWidth
,enableHeight
);
189 } /* wxMacDataBrowserTableViewControl::EnableCellSizeModification(bool, bool) */
191 OSStatus
wxMacDataBrowserTableViewControl::GetAttributes(OptionBits
* attributes
)
193 return ::DataBrowserGetAttributes(this->GetControlRef(),attributes
);
194 } /* wxMacDataBrowserTableViewControl::GetAttributes(OptionBits*) */
196 OSStatus
wxMacDataBrowserTableViewControl::GetColumnWidth(DataBrowserPropertyID propertyID
, UInt16
* width
) const
198 return ::GetDataBrowserTableViewNamedColumnWidth(this->m_controlRef
,propertyID
,width
);
201 OSStatus
wxMacDataBrowserTableViewControl::GetDefaultColumnWidth( UInt16
*width
) const
203 return GetDataBrowserTableViewColumnWidth(this->m_controlRef
, width
);
206 OSStatus
wxMacDataBrowserTableViewControl::GetDefaultRowHeight(UInt16
* height
) const
208 return ::GetDataBrowserTableViewRowHeight(this->m_controlRef
,height
);
211 OSStatus
wxMacDataBrowserTableViewControl::GetHeaderButtonHeight(UInt16
*height
)
213 return ::GetDataBrowserListViewHeaderBtnHeight(this->m_controlRef
,height
);
216 OSStatus
wxMacDataBrowserTableViewControl::GetPartBounds(DataBrowserItemID item
, DataBrowserPropertyID property
, DataBrowserPropertyPart part
, Rect
* bounds
)
218 return ::GetDataBrowserItemPartBounds(this->m_controlRef
,item
,property
,part
,bounds
);
219 } /* wxMacDataBrowserTableViewControl::GetPartBounds(DataBrowserItemID, DataBrowswerPropertyID, DataBrowserPropertyPart, Rect*) */
221 OSStatus
wxMacDataBrowserTableViewControl::GetRowHeight(DataBrowserItemID item
, UInt16
* height
) const
223 return ::GetDataBrowserTableViewItemRowHeight(this->m_controlRef
,item
,height
);
224 } /* wxMacDataBrowserTableViewControl::GetRowHeight(DataBrowserItemID, UInt16*) const */
226 OSStatus
wxMacDataBrowserTableViewControl::GetScrollPosition( UInt32
*top
, UInt32
*left
) const
228 return GetDataBrowserScrollPosition(this->m_controlRef
, top
, left
);
231 OSStatus
wxMacDataBrowserTableViewControl::SetAttributes(OptionBits attributes
)
233 return ::DataBrowserChangeAttributes(this->GetControlRef(),attributes
,~attributes
);
234 } /* wxMacDataBrowserTableViewControl::SetAttributes(OptionBits) */
236 OSStatus
wxMacDataBrowserTableViewControl::SetColumnWidth(DataBrowserPropertyID propertyID
, UInt16 width
)
238 return ::SetDataBrowserTableViewNamedColumnWidth(this->m_controlRef
,propertyID
,width
);
241 OSStatus
wxMacDataBrowserTableViewControl::SetDefaultColumnWidth(UInt16 width
)
243 return ::SetDataBrowserTableViewColumnWidth(this->m_controlRef
,width
);
246 OSStatus
wxMacDataBrowserTableViewControl::SetDefaultRowHeight(UInt16 height
)
248 return ::SetDataBrowserTableViewRowHeight(this->m_controlRef
,height
);
251 OSStatus
wxMacDataBrowserTableViewControl::SetHasScrollBars(bool horiz
, bool vert
)
253 return ::SetDataBrowserHasScrollBars(this->m_controlRef
,horiz
,vert
);
254 } /* wxMacDataBrowserTableViewControl::SetHasScrollBars(bool, bool) */
256 OSStatus
wxMacDataBrowserTableViewControl::SetHeaderButtonHeight(UInt16 height
)
258 return ::SetDataBrowserListViewHeaderBtnHeight(this->m_controlRef
,height
);
259 } /* wxMacDataBrowserTableViewControl::SetHeaderButtonHeight(UInt16) */
261 OSStatus
wxMacDataBrowserTableViewControl::SetHiliteStyle(DataBrowserTableViewHiliteStyle hiliteStyle
)
263 return ::SetDataBrowserTableViewHiliteStyle(this->m_controlRef
,hiliteStyle
);
264 } /*wxMacDataBrowserTableViewControl::SetHiliteStyle(DataBrowserTableViewHiliteStyle) */
266 OSStatus
wxMacDataBrowserTableViewControl::SetIndent(float Indent
)
268 return ::DataBrowserSetMetric(this->m_controlRef
,kDataBrowserMetricDisclosureColumnPerDepthGap
,true,Indent
);
269 } /* wxMacDataBrowserTableViewControl::SetIndent(float* Indent) */
271 OSStatus
wxMacDataBrowserTableViewControl::SetRowHeight(DataBrowserItemID item
, UInt16 height
)
273 return ::SetDataBrowserTableViewItemRowHeight(this->m_controlRef
,item
,height
);
276 OSStatus
wxMacDataBrowserTableViewControl::SetScrollPosition(UInt32 top
, UInt32 left
)
278 return ::SetDataBrowserScrollPosition(this->m_controlRef
,top
,left
);
284 OSStatus
wxMacDataBrowserTableViewControl::GetColumnCount(UInt32
* numColumns
) const
286 return ::GetDataBrowserTableViewColumnCount(this->m_controlRef
,numColumns
);
289 OSStatus
wxMacDataBrowserTableViewControl::GetColumnIndex(DataBrowserPropertyID propertyID
, DataBrowserTableViewColumnIndex
* index
) const
291 return ::GetDataBrowserTableViewColumnPosition(this->m_controlRef
,propertyID
,index
);
292 } /* wxMacDataBrowserTableViewControl::GetColumnIndex(DataBrowserPropertyID, DataBrowserTableViewColumnIndex*) const */
294 OSStatus
wxMacDataBrowserTableViewControl::GetFreePropertyID(DataBrowserPropertyID
* propertyID
) const
296 for (*propertyID
=kMinPropertyID
; *propertyID
<std::numeric_limits
<DataBrowserPropertyID
>::max(); ++(*propertyID
))
297 if (this->IsUsedPropertyID(*propertyID
) == errDataBrowserPropertyNotFound
)
299 return errDataBrowserPropertyNotSupported
;
300 } /* wxMacDataBrowserTableViewControl::GetFreePropertyID(DataBrowserPropertyID*) const */
302 OSStatus
wxMacDataBrowserTableViewControl::GetPropertyFlags(DataBrowserPropertyID propertyID
, DataBrowserPropertyFlags
*flags
) const
304 return ::GetDataBrowserPropertyFlags(this->m_controlRef
,propertyID
,flags
);
307 OSStatus
wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserItemDataRef itemData
, DataBrowserPropertyID
* propertyID
)
309 return ::GetDataBrowserItemDataProperty(itemData
,propertyID
);
310 } /* wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserItemDataRef, DataBrowserPropertyID*) */
312 OSStatus
wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserTableViewColumnIndex index
, DataBrowserTableViewColumnID
* propertyID
)
314 return ::GetDataBrowserTableViewColumnProperty(this->m_controlRef
,index
,propertyID
);
315 } /* wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserTableViewColumnIndex, DataBrowserTableViewColumnID*) */
317 OSStatus
wxMacDataBrowserTableViewControl::IsUsedPropertyID(DataBrowserPropertyID propertyID
) const
319 // 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
320 // 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
321 // the column position for the property id:
322 DataBrowserTableViewColumnIndex index
;
324 return ::GetDataBrowserTableViewColumnPosition(this->m_controlRef
,propertyID
,&index
);
325 } /* wxMacDataBrowserTableViewControl::IsUsedPropertyId(DataBrowserPropertyID) const */
327 OSStatus
wxMacDataBrowserTableViewControl::RemoveColumnByProperty(DataBrowserTableViewColumnID propertyID
)
329 return ::RemoveDataBrowserTableViewColumn(this->m_controlRef
,propertyID
);
330 } /* wxMacDataBrowserTableViewControl::RemoveColumnByProperty(DataBrowserTableViewColumnID) */
332 OSStatus
wxMacDataBrowserTableViewControl::RemoveColumnByIndex(DataBrowserTableViewColumnIndex index
)
334 DataBrowserTableViewColumnID propertyID
;
337 this->GetPropertyID(index
,&propertyID
);
338 return ::RemoveDataBrowserTableViewColumn(this->m_controlRef
,propertyID
);
339 } /* wxMacDataBrowserTableViewControl::RemoveColumnByIndex(DataBrowserTableViewColumnIndex) */
341 OSStatus
wxMacDataBrowserTableViewControl::SetColumnIndex(DataBrowserPropertyID propertyID
, DataBrowserTableViewColumnIndex index
)
343 return ::SetDataBrowserTableViewColumnPosition(this->m_controlRef
,propertyID
,index
);
344 } /* wxMacDataBrowserTableViewControl::SetColumnIndex(DataBrowserPropertyID, DataBrowserTableViewColumnIndex) */
346 OSStatus
wxMacDataBrowserTableViewControl::SetDisclosureColumn(DataBrowserPropertyID propertyID
, Boolean expandableRows
)
348 return ::SetDataBrowserListViewDisclosureColumn(this->m_controlRef
,propertyID
,expandableRows
);
351 OSStatus
wxMacDataBrowserTableViewControl::SetPropertyFlags(DataBrowserPropertyID propertyID
, DataBrowserPropertyFlags flags
)
353 return ::SetDataBrowserPropertyFlags(this->m_controlRef
,propertyID
,flags
);
354 } /* wxMacDataBrowserTableViewControl::SetPropertyFlags(DataBrowserPropertyID, DataBrowserPropertyFlags) */
359 OSStatus
wxMacDataBrowserTableViewControl::AddItems(DataBrowserItemID container
, UInt32 numItems
, DataBrowserItemID
const* items
, DataBrowserPropertyID preSortProperty
)
361 return ::AddDataBrowserItems(this->m_controlRef
,container
,numItems
,items
,preSortProperty
);
362 } /* wxMacDataBrowserTableViewControl::AddItems(DataBrowserItemID, UInt32, DataBrowserItemID const*, DataBrowserPropertyID) */
364 OSStatus
wxMacDataBrowserTableViewControl::GetFreeItemID(DataBrowserItemID
* id
) const
369 verify_noerr(this->GetItemCount(&NoOfItems
));
377 // 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
378 // as the number of items; therefore, start from the number of items to look for a new ID:
379 for (*id
=NoOfItems
; *id
<std::numeric_limits
<DataBrowserItemID
>::max(); ++(*id
))
380 if (this->IsUsedItemID(*id
) == errDataBrowserItemNotFound
)
382 // as the first approach was not successful, try from the beginning:
383 for (*id
=0; *id
<NoOfItems
; ++(*id
))
384 if (this->IsUsedItemID(*id
) == errDataBrowserItemNotFound
)
386 // sorry, data browser is full:
387 return errDataBrowserItemNotAdded
;
389 } /* wxMacDataBrowserTableViewControl::GetFreeItemID(DataBrowserItemID*) const */
391 OSStatus
wxMacDataBrowserTableViewControl::GetItemCount(DataBrowserItemID container
, Boolean recurse
, DataBrowserItemState state
, ItemCount
* numItems
) const
393 return GetDataBrowserItemCount(this->m_controlRef
,container
,recurse
,state
,numItems
);
394 } /* wxMacDataBrowserTableViewControl::GetItemCount(DataBrowserItemID, Boolean, DataBrowserItemState, ItemCount*) const */
396 OSStatus
wxMacDataBrowserTableViewControl::GetItemID( DataBrowserTableViewRowIndex row
, DataBrowserItemID
* item
) const
398 return GetDataBrowserTableViewItemID(this->m_controlRef
,row
,item
);
401 OSStatus
wxMacDataBrowserTableViewControl::GetItems(DataBrowserItemID container
, Boolean recurse
, DataBrowserItemState state
, Handle items
) const
403 return GetDataBrowserItems(this->m_controlRef
,container
,recurse
,state
,items
);
404 } /* wxMacDataBrowserTableViewControl::GetItems(DataBrowserItemID, Boolean, DataBrowserItemState, Handle) const */
406 OSStatus
wxMacDataBrowserTableViewControl::GetItemRow(DataBrowserItemID item
, DataBrowserTableViewRowIndex
* row
) const
408 return GetDataBrowserTableViewItemRow(this->m_controlRef
,item
,row
);
411 OSStatus
wxMacDataBrowserTableViewControl::IsUsedItemID(DataBrowserItemID itemID
) const
413 // 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
414 // 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
415 // the column position for the property id:
416 DataBrowserTableViewColumnIndex index
;
418 return ::GetDataBrowserTableViewItemRow(this->m_controlRef
,itemID
,&index
);
419 } /* wxMacDataBrowserTableViewControl::IsUsedItemID(DataBrowserItemID) const */
421 OSStatus
wxMacDataBrowserTableViewControl::RemoveItems(DataBrowserItemID container
, UInt32 numItems
, DataBrowserItemID
const* items
, DataBrowserPropertyID preSortProperty
)
423 return ::RemoveDataBrowserItems(this->m_controlRef
,container
,numItems
,items
,preSortProperty
);
426 OSStatus
wxMacDataBrowserTableViewControl::RevealItem(DataBrowserItemID item
, DataBrowserPropertyID propertyID
, DataBrowserRevealOptions options
) const
428 return ::RevealDataBrowserItem(this->m_controlRef
,item
,propertyID
,options
);
429 } /* wxMacDataBrowserTableViewControl::RevealItem(DataBrowserItemID item, DataBrowserPropertyID propertyID, DataBrowserRevealOptions options) const */
431 OSStatus
wxMacDataBrowserTableViewControl::UpdateItems(DataBrowserItemID container
, UInt32 numItems
, DataBrowserItemID
const* items
, DataBrowserPropertyID preSortProperty
,
432 DataBrowserPropertyID propertyID
) const
434 return UpdateDataBrowserItems(this->m_controlRef
,container
,numItems
,items
,preSortProperty
,propertyID
);
440 size_t wxMacDataBrowserTableViewControl::GetSelectedItemIDs(wxArrayDataBrowserItemID
& itemIDs
) const
442 DataBrowserItemID
* itemIDPtr
;
443 Handle
handle(::NewHandle(0));
448 wxCHECK_MSG(this->GetItems(kDataBrowserNoItem
,true,kDataBrowserItemIsSelected
,handle
) == noErr
,0,_("Could not get selected items."));
449 NoOfItems
= static_cast<size_t>(::GetHandleSize(handle
)/sizeof(DataBrowserItemID
));
451 itemIDs
.Alloc(NoOfItems
);
453 itemIDPtr
= (DataBrowserItemID
*) (*handle
);
454 for (size_t i
=0; i
<NoOfItems
; ++i
)
456 itemIDs
.Add(*itemIDPtr
);
460 DisposeHandle(handle
);
462 } /* wxMacDataBrowserTableViewControl::GetSelectedItemIDs(wxArrayDataBrowserItemID&) const*/
464 OSStatus
wxMacDataBrowserTableViewControl::GetSelectionAnchor(DataBrowserItemID
* first
, DataBrowserItemID
* last
) const
466 return ::GetDataBrowserSelectionAnchor(this->m_controlRef
,first
,last
);
467 } /* wxMacDataBrowserTableViewControl::GetSelectionAnchor(DataBrowserItemID*, DataBrowserItemID*) const */
469 OSStatus
wxMacDataBrowserTableViewControl::GetSelectionFlags(DataBrowserSelectionFlags
* flags
) const
471 return ::GetDataBrowserSelectionFlags(this->m_controlRef
,flags
);
472 } /* wxMacDataBrowserTableViewControl::GetSelectionFlags(DataBrowserSelectionFlags*) const */
474 bool wxMacDataBrowserTableViewControl::IsItemSelected(DataBrowserItemID item
) const
476 return ::IsDataBrowserItemSelected(this->m_controlRef
,item
);
477 } /* wxMacDataBrowserTableViewControl::IsItemSelected(DataBrowserItemID) const */
479 OSStatus
wxMacDataBrowserTableViewControl::SetSelectionFlags(DataBrowserSelectionFlags flags
)
481 return ::SetDataBrowserSelectionFlags(this->m_controlRef
,flags
);
482 } /* wxMacDataBrowserTableViewControl::SetSelectionFlags(DataBrowserSelectionFlags) */
484 OSStatus
wxMacDataBrowserTableViewControl::SetSelectedItems(UInt32 numItems
, DataBrowserItemID
const* items
, DataBrowserSetOption operation
)
486 return ::SetDataBrowserSelectedItems(this->m_controlRef
, numItems
, items
, operation
);
487 } /* wxMacDataBrowserTableViewControl::SetSelectedItems(UInt32, DataBrowserItemID const*, DataBrowserSetOption) */
489 OSStatus
wxMacDataBrowserTableViewControl::GetSortOrder(DataBrowserSortOrder
* order
) const
491 return ::GetDataBrowserSortOrder(this->m_controlRef
,order
);
494 OSStatus
wxMacDataBrowserTableViewControl::GetSortProperty(DataBrowserPropertyID
* propertyID
) const
496 return ::GetDataBrowserSortProperty(this->m_controlRef
,propertyID
);
499 OSStatus
wxMacDataBrowserTableViewControl::Resort(DataBrowserItemID container
, Boolean sortChildren
)
501 return ::SortDataBrowserContainer(this->m_controlRef
,container
,sortChildren
);
502 } /* wxMacDataBrowserTableViewControl::Resort(DataBrowserItemID, Boolean) */
504 OSStatus
wxMacDataBrowserTableViewControl::SetSortOrder(DataBrowserSortOrder order
)
506 return ::SetDataBrowserSortOrder(this->m_controlRef
,order
);
509 OSStatus
wxMacDataBrowserTableViewControl::SetSortProperty(DataBrowserPropertyID propertyID
)
511 return ::SetDataBrowserSortProperty(this->m_controlRef
,propertyID
);
515 // container handling
517 OSStatus
wxMacDataBrowserTableViewControl::CloseContainer(DataBrowserItemID containerID
)
519 return ::CloseDataBrowserContainer(this->m_controlRef
,containerID
);
520 } /* wxMacDataBrowserTableViewControl::CloseContainer(DataBrowserItemID) */
522 OSStatus
wxMacDataBrowserTableViewControl::OpenContainer(DataBrowserItemID containerID
)
524 return ::OpenDataBrowserContainer(this->m_controlRef
,containerID
);
525 } /* wxMacDataBrowserTableViewControl::OpenContainer(DataBrowserItemID) */
527 IMPLEMENT_ABSTRACT_CLASS(wxMacDataBrowserTableViewControl
,wxMacControl
)
529 // ============================================================================
530 // wxMacDataBrowserListViewControl
531 // ============================================================================
536 OSStatus
wxMacDataBrowserListViewControl::AddColumn(DataBrowserListViewColumnDesc
*columnDesc
, DataBrowserTableViewColumnIndex position
)
538 return AddDataBrowserListViewColumn(this->m_controlRef
,columnDesc
,position
);
539 } /* wxMacDataBrowserListViewControl::AddColumn(DataBrowserListViewColumnDesc*, DataBrowserTableViewColumnIndex) */
541 // ============================================================================
542 // wxMacDataViewDataBrowserListViewControl
543 // ============================================================================
546 // constructors / destructor
548 wxMacDataViewDataBrowserListViewControl::wxMacDataViewDataBrowserListViewControl(wxWindow
* peer
, wxPoint
const& pos
, wxSize
const& size
, long style
)
549 :wxMacDataBrowserListViewControl(peer
,pos
,size
,style
)
551 } /* wxMacDataViewDataBrowserListViewControl::wxMacDataViewDataBrowserListViewControl(wxWindow* , const wxPoint&, const wxSize&, long) */
554 // callback functions (inherited from wxMacDataBrowserTableViewControl)
556 Boolean
wxMacDataViewDataBrowserListViewControl::DataBrowserCompareProc(DataBrowserItemID itemOneID
, DataBrowserItemID itemTwoID
, DataBrowserPropertyID sortProperty
)
558 DataBrowserSortOrder sortOrder
;
560 DataBrowserTableViewColumnIndex columnIndex
;
562 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
565 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
, false,_("Pointer to data view control not set correctly."));
566 wxCHECK_MSG(dataViewCtrlPtr
->GetModel() != NULL
,false,_("Pointer to model not set correctly."));
567 if (sortProperty
>= kMinPropertyID
)
569 wxCHECK_MSG(this->GetColumnIndex(sortProperty
,&columnIndex
) == noErr
,false,_("Could not determine column index."));
573 this->GetSortOrder(&sortOrder
);
574 return static_cast<Boolean
>(dataViewCtrlPtr
->GetModel()->Compare(wxDataViewItem(reinterpret_cast<void*>(itemOneID
)),wxDataViewItem(reinterpret_cast<void*>(itemTwoID
)),
575 columnIndex
,sortOrder
!= kDataBrowserOrderDecreasing
) < 0);
576 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserCompareProc(DataBrowserItemID, DataBrowserItemID, DataBrowserPropertyID) */
578 void wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowserItemID itemID
, DataBrowserPropertyID propertyID
, DataBrowserItemState state
, Rect
const* rectangle
, SInt16 bitDepth
, Boolean colorDevice
)
580 DataBrowserTableViewColumnIndex columnIndex
;
582 wxDataViewColumn
* dataViewColumnPtr
;
584 wxDataViewCtrl
* dataViewCtrlPtr
;
586 wxDataViewCustomRenderer
* dataViewCustomRendererPtr
;
588 wxVariant dataToRender
;
591 dataViewCtrlPtr
= dynamic_cast<wxDataViewCtrl
*>(this->GetPeer());
592 wxCHECK_RET(dataViewCtrlPtr
!= NULL
, _("Pointer to data view control not set correctly."));
593 wxCHECK_RET(dataViewCtrlPtr
->GetModel() != NULL
, _("Pointer to model not set correctly."));
594 wxCHECK_RET(this->GetColumnIndex(propertyID
,&columnIndex
) == noErr
,_("Could not determine column index."));
595 dataViewColumnPtr
= dataViewCtrlPtr
->GetColumn(columnIndex
);
596 wxCHECK_RET(dataViewColumnPtr
!= NULL
,_("No column for the specified column index existing."));
597 dataViewCustomRendererPtr
= dynamic_cast<wxDataViewCustomRenderer
*>(dataViewColumnPtr
->GetRenderer());
598 wxCHECK_RET(dataViewCustomRendererPtr
!= NULL
,_("No renderer or invalid renderer type specified for custom data column."));
599 dataViewCtrlPtr
->GetModel()->GetValue(dataToRender
,wxDataViewItem(reinterpret_cast<void*>(itemID
)),columnIndex
);
600 dataViewCustomRendererPtr
->SetValue(dataToRender
);
602 // try to determine the content's size (drawable part):
604 RgnHandle
rgn(NewRgn());
607 if (this->GetRegion(kControlContentMetaPart
,rgn
) == noErr
)
608 GetRegionBounds(rgn
,&content
);
610 this->GetRect(&content
);
612 // space for the header
613 this->GetHeaderButtonHeight(&headerHeight
);
614 content
.top
+= headerHeight
;
615 // extra space for the frame (todo: do not how to determine the space automatically from the control)
620 // extra space for the scrollbars:
621 content
.bottom
-= wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y
);
622 content
.right
-= wxSystemSettings::GetMetric(wxSYS_VSCROLL_X
);
624 // make sure that 'Render' can draw only in the allowed area:
625 dataViewCustomRendererPtr
->GetDC()->SetClippingRegion(content
.left
,content
.top
,content
.right
-content
.left
+1,content
.bottom
-content
.top
+1);
626 (void) (dataViewCustomRendererPtr
->Render(wxRect(static_cast<int>(rectangle
->left
),static_cast<int>(rectangle
->top
),
627 static_cast<int>(1+rectangle
->right
-rectangle
->left
),static_cast<int>(1+rectangle
->bottom
-rectangle
->top
)),
628 dataViewCustomRendererPtr
->GetDC(),((state
== kDataBrowserItemIsSelected
) ? wxDATAVIEW_CELL_SELECTED
: 0)));
629 dataViewCustomRendererPtr
->GetDC()->DestroyClippingRegion(); // probably not necessary
630 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemState, Rect const*, SInt16, Boolean) */
632 OSStatus
wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(DataBrowserItemID itemID
, DataBrowserPropertyID propertyID
, DataBrowserItemDataRef itemData
, Boolean getValue
)
636 // variable definitions:
637 wxDataViewCtrl
* dataViewCtrlPtr
;
639 dataViewCtrlPtr
= dynamic_cast<wxDataViewCtrl
*>(this->GetPeer());
640 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
,errDataBrowserNotConfigured
,_("Pointer to data view control not set correctly."));
641 if (dataViewCtrlPtr
->IsDeleting())
642 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
645 // variable definitions:
646 DataBrowserTableViewColumnIndex columnIndex
;
647 OSStatus errorStatus
;
648 wxDataViewColumn
* dataViewColumnPtr
;
650 wxCHECK_MSG(dataViewCtrlPtr
->GetModel() != NULL
,errDataBrowserNotConfigured
,_("Pointer to model not set correctly."));
651 errorStatus
= this->GetColumnIndex(propertyID
,&columnIndex
);
652 wxCHECK_MSG(errorStatus
== noErr
,errorStatus
,_("Could not determine column index"));
653 dataViewColumnPtr
= dataViewCtrlPtr
->GetColumn(columnIndex
);
654 wxCHECK_MSG((dataViewColumnPtr
!= NULL
) && (dataViewColumnPtr
->GetRenderer() != NULL
),errDataBrowserNotConfigured
,_("There is no column or renderer for the specified column index."));
655 switch (dataViewColumnPtr
->GetRenderer()->GetPropertyType())
657 case kDataBrowserCheckboxType
:
659 // variable definition:
660 ThemeButtonValue buttonValue
;
662 errorStatus
= ::GetDataBrowserItemDataButtonValue(itemData
,&buttonValue
);
663 if (errorStatus
== noErr
)
665 if (buttonValue
== kThemeButtonOn
)
667 // variable definition and initialization:
668 wxVariant
modifiedData(true);
670 return (dataViewCtrlPtr
->GetModel()->SetValue(modifiedData
,wxDataViewItem(reinterpret_cast<void*>(itemID
)),static_cast<unsigned int>(columnIndex
)) ? OSStatus(noErr
) : OSStatus(errDataBrowserNotConfigured
));
672 else if (buttonValue
== kThemeButtonOff
)
674 // variable definition and initialization:
675 wxVariant
modifiedData(false);
677 return (dataViewCtrlPtr
->GetModel()->SetValue(modifiedData
,wxDataViewItem(reinterpret_cast<void*>(itemID
)),static_cast<unsigned int>(columnIndex
)) ? OSStatus(noErr
) : OSStatus(errDataBrowserNotConfigured
));
680 return errDataBrowserInvalidPropertyData
;
685 case kDataBrowserTextType
:
687 // variable definitions:
688 CFStringRef stringReference
;
690 errorStatus
= ::GetDataBrowserItemDataText(itemData
,&stringReference
);
691 if (errorStatus
== noErr
)
693 // variable definitions and initializations:
694 wxMacCFStringHolder
modifiedString(stringReference
);
695 wxVariant
modifiedData(modifiedString
.AsString());
697 if (dataViewCtrlPtr
->GetModel()->SetValue(modifiedData
,wxDataViewItem(reinterpret_cast<void*>(itemID
)),static_cast<unsigned int>(columnIndex
)))
700 return errDataBrowserNotConfigured
;
706 return errDataBrowserPropertyNotSupported
;
712 if (propertyID
>= kMinPropertyID
) // in case data columns set the data
714 // variable definitions:
716 wxDataViewColumn
* dataViewColumnPtr
;
717 wxDataViewCtrl
* dataViewCtrlPtr
;
719 dataViewCtrlPtr
= dynamic_cast<wxDataViewCtrl
*>(this->GetPeer());
720 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
,errDataBrowserNotConfigured
,_("Pointer to data view control not set correctly."));
721 wxCHECK_MSG(dataViewCtrlPtr
->GetModel() != NULL
,errDataBrowserNotConfigured
,_("Pointer to model not set correctly."));
722 dataViewColumnPtr
= dataViewCtrlPtr
->GetColumnPtr(propertyID
);
723 wxCHECK_MSG(dataViewColumnPtr
!= NULL
,errDataBrowserNotConfigured
,_("No column for the specified column position existing."));
724 wxCHECK_MSG(dataViewColumnPtr
->GetRenderer() != NULL
,errDataBrowserNotConfigured
,_("No renderer specified for column."));
725 dataViewCtrlPtr
->GetModel()->GetValue(variant
,wxDataViewItem(reinterpret_cast<void*>(itemID
)),dataViewColumnPtr
->GetModelColumn());
726 if (!(variant
.IsNull()))
728 dataViewColumnPtr
->GetRenderer()->SetDataReference(itemData
);
729 dataViewColumnPtr
->GetRenderer()->SetValue(variant
);
730 wxCHECK_MSG(dataViewColumnPtr
->GetRenderer()->Render(),errDataBrowserNotConfigured
,_("Rendering failed."));
734 else // react on special system requests
738 case kDataBrowserContainerIsClosableProperty
:
740 // variable definitions:
741 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
743 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
,errDataBrowserNotConfigured
,_("Pointer to data view control not set correctly."));
744 // initialize wxWidget event:
745 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING
,dataViewCtrlPtr
->GetId()); // variable definition
747 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
748 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
749 // finally send the equivalent wxWidget event:
750 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
751 // opening the container is allowed if not vetoed:
752 return ::SetDataBrowserItemDataBooleanValue(itemData
,dataViewEvent
.IsAllowed());
754 case kDataBrowserContainerIsOpenableProperty
:
756 // variable definitions:
757 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
759 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
,errDataBrowserNotConfigured
,_("Pointer to data view control not set correctly."));
760 // initialize wxWidget event:
761 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING
,dataViewCtrlPtr
->GetId()); // variable definition
763 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
764 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
765 // finally send the equivalent wxWidget event:
766 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
767 // opening the container is allowed if not vetoed:
768 return ::SetDataBrowserItemDataBooleanValue(itemData
,dataViewEvent
.IsAllowed());
770 case kDataBrowserItemIsContainerProperty
:
772 // variable definition:
773 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
775 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
,errDataBrowserNotConfigured
,_("Pointer to data view control not set correctly."));
776 wxCHECK_MSG(dataViewCtrlPtr
->GetModel() != NULL
,errDataBrowserNotConfigured
,_("Pointer to model not set correctly."));
777 return ::SetDataBrowserItemDataBooleanValue(itemData
,dataViewCtrlPtr
->GetModel()->IsContainer(wxDataViewItem(reinterpret_cast<void*>(itemID
))));
779 case kDataBrowserItemIsEditableProperty
:
780 return ::SetDataBrowserItemDataBooleanValue(itemData
,true);
784 return errDataBrowserPropertyNotSupported
;
785 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemDataRef, Boolean) */
787 void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(DataBrowserItemID itemID
, DataBrowserItemNotification message
, DataBrowserItemDataRef itemData
)
789 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->GetPeer()));
792 // 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:
793 if (dataViewCtrlPtr
!= NULL
)
796 case kDataBrowserContainerClosed
:
798 // initialize wxWidget event:
799 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED
,dataViewCtrlPtr
->GetId()); // variable definition
801 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
802 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
803 // finally send the equivalent wxWidget event:
804 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
807 case kDataBrowserContainerOpened
:
809 // initialize wxWidget event:
810 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED
,dataViewCtrlPtr
->GetId()); // variable definition
812 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
813 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
814 // finally send the equivalent wxWidget event:
815 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
816 // add children to the expanded container:
817 dataViewCtrlPtr
->AddChildrenLevel(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
820 case kDataBrowserEditStarted
:
822 // initialize wxWidget event:
823 DataBrowserPropertyID propertyID
;
824 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED
,dataViewCtrlPtr
->GetId()); // variable definition
826 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
827 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
828 if (this->GetPropertyID(itemData
,&propertyID
) == noErr
)
830 // variable definition and initialization:
831 DataBrowserTableViewColumnIndex columnIndex
;
833 wxCHECK_RET(this->GetColumnIndex(propertyID
,&columnIndex
),_("Column index not found."));
834 dataViewEvent
.SetColumn(columnIndex
);
835 dataViewEvent
.SetDataViewColumn(dataViewCtrlPtr
->GetColumnPtr(propertyID
));
837 // finally send the equivalent wxWidget event:
838 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
841 case kDataBrowserEditStopped
:
843 // initialize wxWidget event:
844 DataBrowserPropertyID propertyID
;
845 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE
,dataViewCtrlPtr
->GetId()); // variable definition
847 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
848 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
849 if (this->GetPropertyID(itemData
,&propertyID
) == noErr
)
851 // variable definition and initialization:
852 DataBrowserTableViewColumnIndex columnIndex
;
854 wxCHECK_RET(this->GetColumnIndex(propertyID
,&columnIndex
),_("Column index not found."));
855 dataViewEvent
.SetColumn(columnIndex
);
856 dataViewEvent
.SetDataViewColumn(dataViewCtrlPtr
->GetColumnPtr(propertyID
));
858 // finally send the equivalent wxWidget event:
859 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
862 case kDataBrowserItemAdded
:
863 break; // not used anymore
864 case kDataBrowserItemDeselected
:
865 break; // not implemented by wxWidgets; see kDataBrowserSelectionSetChanged
866 case kDataBrowserItemDoubleClicked
:
868 // initialize wxWidget event:
869 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED
,dataViewCtrlPtr
->GetId()); // variable definition
871 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
872 dataViewEvent
.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID
)));
873 // finally send the equivalent wxWidget event:
874 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
877 case kDataBrowserItemRemoved
:
878 break; // not used anymore
879 case kDataBrowserItemSelected
:
880 break; // not implemented by wxWidgets; see kDataBrowserSelectionSetChanged
881 case kDataBrowserSelectionSetChanged
:
883 // initialize wxWidget event:
884 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED
,dataViewCtrlPtr
->GetId()); // variable definition
886 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
887 dataViewEvent
.SetModel (dataViewCtrlPtr
->GetModel());
888 // finally send the equivalent wxWidget event:
889 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
892 case kDataBrowserUserStateChanged
:
894 // update column widths:
895 for (size_t i
=0; i
<dataViewCtrlPtr
->GetColumnCount(); ++i
)
897 // constant definition for abbreviational purposes:
898 wxDataViewColumn
* const columnPtr
= dataViewCtrlPtr
->GetColumn(i
);
899 // variable definition:
902 wxCHECK_RET(this->GetColumnWidth(columnPtr
->GetPropertyID(),&columnWidth
) == noErr
,_("Column width could not be determined"));
903 columnPtr
->SetWidthVariable(columnWidth
);
905 // update order status:
906 DataBrowserPropertyID propertyID
; // variable definition
908 if ((this->GetSortProperty(&propertyID
) == noErr
) && (propertyID
>= kMinPropertyID
))
910 DataBrowserSortOrder sortOrder
;
911 DataBrowserTableViewColumnIndex columnIndex
;
913 if ((this->GetSortOrder(&sortOrder
) == noErr
) && (this->GetColumnIndex(propertyID
,&columnIndex
) == noErr
))
915 // variable definition and initialization:
916 wxDataViewColumn
* columnPtr
;
917 columnPtr
= dataViewCtrlPtr
->GetColumn(columnIndex
);
918 // check if the sort order has changed:
919 if ( columnPtr
->IsSortOrderAscending() && (sortOrder
== kDataBrowserOrderDecreasing
) ||
920 !(columnPtr
->IsSortOrderAscending()) && (sortOrder
== kDataBrowserOrderIncreasing
))
922 columnPtr
->SetSortOrder(!(columnPtr
->IsSortOrderAscending()));
923 // initialize wxWidget event:
924 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED
,dataViewCtrlPtr
->GetId()); // variable defintion
926 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
927 dataViewEvent
.SetColumn(columnIndex
);
928 dataViewEvent
.SetDataViewColumn(columnPtr
);
929 // finally send the equivalent wxWidget event:
930 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
937 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(DataBrowserItemID, DataBrowserItemNotification, DataBrowserItemDataRef) */
940 #endif // wxUSE_GENERICDATAVIEWCTRL
941 #endif // wxUSE_DATAVIEWCTRL