]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/databrow.cpp
removed not implemented anyhow SetIcons()
[wxWidgets.git] / src / mac / carbon / databrow.cpp
CommitLineData
c0a66d92
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/mac/carbon/databrow.cpp
3// Purpose: Classes and functions for the Carbon data browser
4// Author:
5// Modified by:
6// Created: 2007-05-18
7// RCS-ID: $Id$
8// Copyright: (c)
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
594d5596 12#ifndef wxUSE_GENERICDATAVIEWCTRL
a3fd36e7 13
594d5596 14#include <limits>
c0a66d92 15
594d5596 16#include "wx/wxprec.h"
a5fb9253
RR
17#ifndef WX_PRECOMP
18 #include "wx/app.h"
19 #include "wx/toplevel.h"
20 #include "wx/font.h"
21#endif
22
23#include "wx/dataview.h"
24#include "wx/utils.h"
25
f53c8638 26#include "wx/mac/carbon/databrow.h"
594d5596 27#include "wx/mac/private.h"
a5fb9253 28#include "wx/mac/uma.h"
c0a66d92 29
c0a66d92 30// ============================================================================
194027ac 31// wxMacDataBrowserTableViewControl
c0a66d92 32// ============================================================================
c0a66d92
RR
33
34pascal Boolean wxMacDataBrowserTableViewControl::DataBrowserCompareProc(ControlRef browser, DataBrowserItemID itemOneID, DataBrowserItemID itemTwoID, DataBrowserPropertyID sortProperty)
35{
36 wxMacDataBrowserTableViewControl* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl*>(wxMacControl::GetReferenceFromNativeControl(browser)));
37
38
39 if (ControlPtr != NULL)
40 return ControlPtr->DataBrowserCompareProc(itemOneID,itemTwoID,sortProperty);
41 else
42 return errDataBrowserPropertyNotSupported;
43} /* wxMacDataBrowserTableViewControl::DataBrowserCompareProc(ControlRef, DataBrowserItemID, DataBrowserItemID, DataBrowserPropertyID) */
44
45pascal void wxMacDataBrowserTableViewControl::DataBrowserDrawItemProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID property, DataBrowserItemState state, Rect const* rectangle, SInt16 bitDepth, Boolean colorDevice)
46{
47 wxMacDataBrowserTableViewControl* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl*>(wxMacControl::GetReferenceFromNativeControl(browser)));
48
49
50 if (ControlPtr != NULL)
51 ControlPtr->DataBrowserDrawItemProc(itemID,property,state,rectangle,bitDepth,colorDevice);
52} /* wxMacDataBrowserTableViewControl::DataBrowserDrawItemProc(ControlRef, DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemState, Rect const*, SInt16, Boolean) */
53
54pascal OSStatus wxMacDataBrowserTableViewControl::DataBrowserGetSetItemDataProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID property, DataBrowserItemDataRef itemData, Boolean getValue)
55{
56 wxMacDataBrowserTableViewControl* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl*>(wxMacControl::GetReferenceFromNativeControl(browser)));
57
58
59 if (ControlPtr != NULL)
60 return ControlPtr->DataBrowserGetSetItemDataProc(itemID,property,itemData,getValue);
61 else
62 return errDataBrowserPropertyNotSupported;
63} /* wxMacDataBrowserTableViewControl::DataBrowserGetSetItemDataProc(ControlRef, DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemDataRef, Boolean) */
64
65pascal void wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserItemNotification message, DataBrowserItemDataRef itemData)
66{
67 wxMacDataBrowserTableViewControl* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl*>(wxMacControl::GetReferenceFromNativeControl(browser)));
68
69
70 if (ControlPtr != NULL)
71 ControlPtr->DataBrowserItemNotificationProc(itemID,message,itemData);
72} /* wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc(ControlRef, DataBrowserItemID, DataBrowserItemNotification, DataBrowserItemDataRef) */
73
74DataBrowserDrawItemUPP gDataBrowserTableViewDrawItemUPP = NULL;
75DataBrowserItemCompareUPP gDataBrowserTableViewItemCompareUPP = NULL;
76DataBrowserItemDataUPP gDataBrowserTableViewItemDataUPP = NULL;
77DataBrowserItemNotificationUPP gDataBrowserTableViewItemNotificationUPP = NULL;
78
79wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow* peer, wxPoint const& pos, wxSize const& size, long style)
80 :wxMacControl(peer)
81{
82 Rect bounds = wxMacGetBoundsForControl(peer,pos,size);
83 OSStatus err = ::CreateDataBrowserControl(MAC_WXHWND(peer->MacGetTopLevelWindowRef()),&bounds,kDataBrowserListView,&(this->m_controlRef));
84
85
86 SetReferenceInNativeControl();
87 verify_noerr(err);
88 if (gDataBrowserTableViewDrawItemUPP == NULL) gDataBrowserTableViewDrawItemUPP = NewDataBrowserDrawItemUPP (DataBrowserDrawItemProc);
89 if (gDataBrowserTableViewItemCompareUPP == NULL) gDataBrowserTableViewItemCompareUPP = NewDataBrowserItemCompareUPP(wxMacDataBrowserTableViewControl::DataBrowserCompareProc);
90 if (gDataBrowserTableViewItemDataUPP == NULL) gDataBrowserTableViewItemDataUPP = NewDataBrowserItemDataUPP (wxMacDataBrowserTableViewControl::DataBrowserGetSetItemDataProc);
91 if (gDataBrowserTableViewItemNotificationUPP == NULL)
92 {
93 gDataBrowserTableViewItemNotificationUPP =
94#if TARGET_API_MAC_OSX
95 (DataBrowserItemNotificationUPP) NewDataBrowserItemNotificationWithItemUPP(wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc);
96#else
97 NewDataBrowserItemNotificationUPP(wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc);
98#endif
99 }
100
101 DataBrowserCallbacks callbacks;
102 DataBrowserCustomCallbacks customCallbacks;
103
104 InitializeDataBrowserCallbacks (&callbacks, kDataBrowserLatestCallbacks);
105 InitializeDataBrowserCustomCallbacks(&customCallbacks,kDataBrowserLatestCallbacks);
106
107 callbacks.u.v1.itemDataCallback = gDataBrowserTableViewItemDataUPP;
108 callbacks.u.v1.itemCompareCallback = gDataBrowserTableViewItemCompareUPP;
109 callbacks.u.v1.itemNotificationCallback = gDataBrowserTableViewItemNotificationUPP;
110 this->SetCallbacks(&callbacks);
111
112 customCallbacks.u.v1.drawItemCallback = gDataBrowserTableViewDrawItemUPP;
113 this->SetCustomCallbacks(&customCallbacks);
114
115 // style setting:
116 this->EnableCellSizeModification();
117
118 DataBrowserSelectionFlags flags; // variable definition
119
120 if (this->GetSelectionFlags(&flags) == noErr) // get default settings
121 {
122 if ((style & wxDV_MULTIPLE) != 0)
123 flags &= ~kDataBrowserSelectOnlyOne;
124 else
125 flags |= kDataBrowserSelectOnlyOne;
126 (void) this->SetSelectionFlags(flags);
127 } /* if */
594d5596 128
c0a66d92
RR
129 OptionBits attributes; // variable definition
130
131 if (this->GetAttributes(&attributes) == noErr) // get default settings
132 {
133 if ((style & wxDV_VERT_RULES) != 0)
134 attributes |= kDataBrowserAttributeListViewDrawColumnDividers;
135 else
136 attributes &= ~kDataBrowserAttributeListViewDrawColumnDividers;
137 (void) this->SetAttributes(attributes);
138 } /* if */
594d5596 139
c0a66d92
RR
140 if ((style & wxDV_NO_HEADER) != 0)
141 this->SetHeaderButtonHeight(0);
142} /* wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow*, wxPoint const&, wxSize const&, long) */
143
144//
145// callback handling
146//
147OSStatus wxMacDataBrowserTableViewControl::SetCallbacks(DataBrowserCallbacks const* callbacks)
148{
149 return ::SetDataBrowserCallbacks(this->m_controlRef,callbacks);
150} /* wxMacDataBrowserTableViewControl::SetCallbacks(DataBrowserCallbacks const*) */
151
152OSStatus wxMacDataBrowserTableViewControl::SetCustomCallbacks(DataBrowserCustomCallbacks const* customCallbacks)
153{
154 return ::SetDataBrowserCustomCallbacks(this->m_controlRef,customCallbacks);
155} /* xMacDataBrowserTableViewControl::SetCustomCallbacks(DataBrowserCustomCallbacks const*) */
156
157//
158// header handling
159//
160OSStatus wxMacDataBrowserTableViewControl::GetHeaderDesc(DataBrowserPropertyID property, DataBrowserListViewHeaderDesc* desc) const
161{
162 desc->version = kDataBrowserListViewLatestHeaderDesc; // if this statement is missing the next call will fail (NOT DOCUMENTED!!)
163 return ::GetDataBrowserListViewHeaderDesc(this->m_controlRef,property,desc);
164}
165
166OSStatus wxMacDataBrowserTableViewControl::SetHeaderDesc(DataBrowserPropertyID property, DataBrowserListViewHeaderDesc* desc)
167{
168 return ::SetDataBrowserListViewHeaderDesc(this->m_controlRef,property,desc);
169}
170
171//
172// layout handling
173//
174OSStatus wxMacDataBrowserTableViewControl::AutoSizeColumns()
175{
176 return AutoSizeDataBrowserListViewColumns(this->m_controlRef);
177}
178
179OSStatus wxMacDataBrowserTableViewControl::EnableCellSizeModification(bool enableHeight, bool enableWidth)
180{
181 return ::SetDataBrowserTableViewGeometry(this->GetControlRef(),enableWidth,enableHeight);
182} /* wxMacDataBrowserTableViewControl::EnableCellSizeModification(bool, bool) */
183
c0a66d92
RR
184OSStatus wxMacDataBrowserTableViewControl::GetAttributes(OptionBits* attributes)
185{
186 return ::DataBrowserGetAttributes(this->GetControlRef(),attributes);
187} /* wxMacDataBrowserTableViewControl::GetAttributes(OptionBits*) */
c0a66d92 188
194027ac 189OSStatus wxMacDataBrowserTableViewControl::GetColumnWidth(DataBrowserPropertyID propertyID, UInt16* width) const
c0a66d92 190{
194027ac 191 return ::GetDataBrowserTableViewNamedColumnWidth(this->m_controlRef,propertyID,width);
c0a66d92
RR
192}
193
07c51ff1
RR
194OSStatus wxMacDataBrowserTableViewControl::GetDefaultColumnWidth( UInt16 *width ) const
195{
196 return GetDataBrowserTableViewColumnWidth(this->m_controlRef, width );
197}
198
194027ac 199OSStatus wxMacDataBrowserTableViewControl::GetDefaultRowHeight(UInt16* height) const
c0a66d92 200{
194027ac 201 return ::GetDataBrowserTableViewRowHeight(this->m_controlRef,height);
c0a66d92
RR
202}
203
204OSStatus wxMacDataBrowserTableViewControl::GetHeaderButtonHeight(UInt16 *height)
205{
194027ac 206 return ::GetDataBrowserListViewHeaderBtnHeight(this->m_controlRef,height);
c0a66d92
RR
207}
208
07c51ff1 209OSStatus wxMacDataBrowserTableViewControl::GetPartBounds(DataBrowserItemID item, DataBrowserPropertyID property, DataBrowserPropertyPart part, Rect* bounds)
c0a66d92 210{
07c51ff1
RR
211 return ::GetDataBrowserItemPartBounds(this->m_controlRef,item,property,part,bounds);
212} /* wxMacDataBrowserTableViewControl::GetPartBounds(DataBrowserItemID, DataBrowswerPropertyID, DataBrowserPropertyPart, Rect*) */
c0a66d92 213
07c51ff1 214OSStatus wxMacDataBrowserTableViewControl::GetRowHeight(DataBrowserItemID item, UInt16* height) const
c0a66d92 215{
07c51ff1
RR
216 return ::GetDataBrowserTableViewItemRowHeight(this->m_controlRef,item,height);
217} /* wxMacDataBrowserTableViewControl::GetRowHeight(DataBrowserItemID, UInt16*) const */
c0a66d92
RR
218
219OSStatus wxMacDataBrowserTableViewControl::GetScrollPosition( UInt32 *top , UInt32 *left ) const
220{
194027ac 221 return GetDataBrowserScrollPosition(this->m_controlRef, top , left );
c0a66d92
RR
222}
223
c0a66d92
RR
224OSStatus wxMacDataBrowserTableViewControl::SetAttributes(OptionBits attributes)
225{
226 return ::DataBrowserChangeAttributes(this->GetControlRef(),attributes,~attributes);
227} /* wxMacDataBrowserTableViewControl::SetAttributes(OptionBits) */
c0a66d92 228
194027ac 229OSStatus wxMacDataBrowserTableViewControl::SetColumnWidth(DataBrowserPropertyID propertyID, UInt16 width)
c0a66d92 230{
194027ac 231 return ::SetDataBrowserTableViewNamedColumnWidth(this->m_controlRef,propertyID,width);
c0a66d92
RR
232}
233
194027ac 234OSStatus wxMacDataBrowserTableViewControl::SetDefaultColumnWidth(UInt16 width)
c0a66d92 235{
194027ac 236 return ::SetDataBrowserTableViewColumnWidth(this->m_controlRef,width);
c0a66d92
RR
237}
238
194027ac 239OSStatus wxMacDataBrowserTableViewControl::SetDefaultRowHeight(UInt16 height)
c0a66d92 240{
194027ac 241 return ::SetDataBrowserTableViewRowHeight(this->m_controlRef,height);
c0a66d92
RR
242}
243
c17b2e31 244OSStatus wxMacDataBrowserTableViewControl::SetHasScrollBars(bool horiz, bool vert)
c0a66d92 245{
c17b2e31
RR
246 return ::SetDataBrowserHasScrollBars(this->m_controlRef,horiz,vert);
247} /* wxMacDataBrowserTableViewControl::SetHasScrollBars(bool, bool) */
c0a66d92
RR
248
249OSStatus wxMacDataBrowserTableViewControl::SetHeaderButtonHeight(UInt16 height)
250{
c17b2e31
RR
251 return ::SetDataBrowserListViewHeaderBtnHeight(this->m_controlRef,height);
252} /* wxMacDataBrowserTableViewControl::SetHeaderButtonHeight(UInt16) */
c0a66d92 253
c17b2e31 254OSStatus wxMacDataBrowserTableViewControl::SetHiliteStyle(DataBrowserTableViewHiliteStyle hiliteStyle)
c0a66d92 255{
c17b2e31
RR
256 return ::SetDataBrowserTableViewHiliteStyle(this->m_controlRef,hiliteStyle);
257} /*wxMacDataBrowserTableViewControl::SetHiliteStyle(DataBrowserTableViewHiliteStyle) */
258
259OSStatus wxMacDataBrowserTableViewControl::SetIndent(float Indent)
260{
261 return ::DataBrowserSetMetric(this->m_controlRef,kDataBrowserMetricDisclosureColumnPerDepthGap,true,Indent);
262} /* wxMacDataBrowserTableViewControl::SetIndent(float* Indent) */
c0a66d92
RR
263
264OSStatus wxMacDataBrowserTableViewControl::SetRowHeight(DataBrowserItemID item, UInt16 height)
265{
266 return ::SetDataBrowserTableViewItemRowHeight(this->m_controlRef,item,height);
267}
268
269OSStatus wxMacDataBrowserTableViewControl::SetScrollPosition(UInt32 top, UInt32 left)
270{
271 return ::SetDataBrowserScrollPosition(this->m_controlRef,top,left);
272}
273
274//
275// column handling
276//
277OSStatus wxMacDataBrowserTableViewControl::GetColumnCount(UInt32* numColumns) const
278{
194027ac 279 return ::GetDataBrowserTableViewColumnCount(this->m_controlRef,numColumns);
c0a66d92
RR
280}
281
194027ac 282OSStatus wxMacDataBrowserTableViewControl::GetColumnIndex(DataBrowserPropertyID propertyID, DataBrowserTableViewColumnIndex* index) const
c0a66d92 283{
194027ac
RR
284 return ::GetDataBrowserTableViewColumnPosition(this->m_controlRef,propertyID,index);
285} /* wxMacDataBrowserTableViewControl::GetColumnIndex(DataBrowserPropertyID, DataBrowserTableViewColumnIndex*) const */
c0a66d92 286
194027ac 287OSStatus wxMacDataBrowserTableViewControl::GetFreePropertyID(DataBrowserPropertyID* propertyID) const
c0a66d92 288{
194027ac
RR
289 for (*propertyID=kMinPropertyID; *propertyID<std::numeric_limits<DataBrowserPropertyID>::max(); ++(*propertyID))
290 if (this->IsUsedPropertyID(*propertyID) == errDataBrowserPropertyNotFound)
c0a66d92
RR
291 return noErr;
292 return errDataBrowserPropertyNotSupported;
293} /* wxMacDataBrowserTableViewControl::GetFreePropertyID(DataBrowserPropertyID*) const */
294
194027ac 295OSStatus wxMacDataBrowserTableViewControl::GetPropertyFlags(DataBrowserPropertyID propertyID, DataBrowserPropertyFlags *flags) const
c0a66d92 296{
194027ac
RR
297 return ::GetDataBrowserPropertyFlags(this->m_controlRef,propertyID,flags);
298}
c0a66d92 299
07c51ff1
RR
300OSStatus wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserItemDataRef itemData, DataBrowserPropertyID* propertyID)
301{
302 return ::GetDataBrowserItemDataProperty(itemData,propertyID);
303} /* wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserItemDataRef, DataBrowserPropertyID*) */
304
194027ac 305OSStatus wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserTableViewColumnIndex index, DataBrowserTableViewColumnID* propertyID)
c0a66d92 306{
194027ac
RR
307 return ::GetDataBrowserTableViewColumnProperty(this->m_controlRef,index,propertyID);
308} /* wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserTableViewColumnIndex, DataBrowserTableViewColumnID*) */
c0a66d92
RR
309
310OSStatus wxMacDataBrowserTableViewControl::IsUsedPropertyID(DataBrowserPropertyID propertyID) const
311{
312 // 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
313 // 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
314 // the column position for the property id:
315 DataBrowserTableViewColumnIndex index;
316
317 return ::GetDataBrowserTableViewColumnPosition(this->m_controlRef,propertyID,&index);
318} /* wxMacDataBrowserTableViewControl::IsUsedPropertyId(DataBrowserPropertyID) const */
319
c17b2e31
RR
320OSStatus wxMacDataBrowserTableViewControl::RemoveColumnByProperty(DataBrowserTableViewColumnID propertyID)
321{
322 return ::RemoveDataBrowserTableViewColumn(this->m_controlRef,propertyID);
323} /* wxMacDataBrowserTableViewControl::RemoveColumnByProperty(DataBrowserTableViewColumnID) */
324
325OSStatus wxMacDataBrowserTableViewControl::RemoveColumnByIndex(DataBrowserTableViewColumnIndex index)
c0a66d92 326{
194027ac 327 DataBrowserTableViewColumnID propertyID;
c0a66d92 328
c0a66d92 329
194027ac
RR
330 this->GetPropertyID(index,&propertyID);
331 return ::RemoveDataBrowserTableViewColumn(this->m_controlRef,propertyID);
c17b2e31 332} /* wxMacDataBrowserTableViewControl::RemoveColumnByIndex(DataBrowserTableViewColumnIndex) */
194027ac
RR
333
334OSStatus wxMacDataBrowserTableViewControl::SetColumnIndex(DataBrowserPropertyID propertyID, DataBrowserTableViewColumnIndex index)
c0a66d92 335{
194027ac
RR
336 return ::SetDataBrowserTableViewColumnPosition(this->m_controlRef,propertyID,index);
337} /* wxMacDataBrowserTableViewControl::SetColumnIndex(DataBrowserPropertyID, DataBrowserTableViewColumnIndex) */
c0a66d92 338
194027ac 339OSStatus wxMacDataBrowserTableViewControl::SetDisclosureColumn(DataBrowserPropertyID propertyID, Boolean expandableRows)
c0a66d92 340{
194027ac 341 return ::SetDataBrowserListViewDisclosureColumn(this->m_controlRef,propertyID,expandableRows);
c0a66d92
RR
342}
343
194027ac
RR
344OSStatus wxMacDataBrowserTableViewControl::SetPropertyFlags(DataBrowserPropertyID propertyID, DataBrowserPropertyFlags flags)
345{
346 return ::SetDataBrowserPropertyFlags(this->m_controlRef,propertyID,flags);
347} /* wxMacDataBrowserTableViewControl::SetPropertyFlags(DataBrowserPropertyID, DataBrowserPropertyFlags) */
348
c0a66d92
RR
349//
350// item handling
351//
352OSStatus wxMacDataBrowserTableViewControl::AddItems(DataBrowserItemID container, UInt32 numItems, DataBrowserItemID const* items, DataBrowserPropertyID preSortProperty)
353{
354 return ::AddDataBrowserItems(this->m_controlRef,container,numItems,items,preSortProperty);
355} /* wxMacDataBrowserTableViewControl::AddItems(DataBrowserItemID, UInt32, DataBrowserItemID const*, DataBrowserPropertyID) */
356
357OSStatus wxMacDataBrowserTableViewControl::GetFreeItemID(DataBrowserItemID* id) const
358{
359 ItemCount NoOfItems;
360
361
362 verify_noerr(this->GetItemCount(&NoOfItems));
363 if (NoOfItems == 0)
364 {
365 *id = 1;
366 return noErr;
367 } /* if */
368 else
369 {
370 // 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
371 // as the number of items; therefore, start from the number of items to look for a new ID:
372 for (*id=NoOfItems; *id<std::numeric_limits<DataBrowserItemID>::max(); ++(*id))
373 if (this->IsUsedItemID(*id) == errDataBrowserItemNotFound)
374 return noErr;
375 // as the first approach was not successful, try from the beginning:
376 for (*id=0; *id<NoOfItems; ++(*id))
377 if (this->IsUsedItemID(*id) == errDataBrowserItemNotFound)
378 return noErr;
379 // sorry, data browser is full:
380 return errDataBrowserItemNotAdded;
381 } /* if */
382} /* wxMacDataBrowserTableViewControl::GetFreeItemID(DataBrowserItemID*) const */
383
384OSStatus wxMacDataBrowserTableViewControl::GetItemCount(DataBrowserItemID container, Boolean recurse, DataBrowserItemState state, ItemCount* numItems) const
385{
386 return GetDataBrowserItemCount(this->m_controlRef,container,recurse,state,numItems);
387} /* wxMacDataBrowserTableViewControl::GetItemCount(DataBrowserItemID, Boolean, DataBrowserItemState, ItemCount*) const */
388
389OSStatus wxMacDataBrowserTableViewControl::GetItemID( DataBrowserTableViewRowIndex row, DataBrowserItemID * item ) const
390{
391 return GetDataBrowserTableViewItemID(this->m_controlRef,row,item);
392}
393
394OSStatus wxMacDataBrowserTableViewControl::GetItems(DataBrowserItemID container, Boolean recurse, DataBrowserItemState state, Handle items) const
395{
396 return GetDataBrowserItems(this->m_controlRef,container,recurse,state,items);
397} /* wxMacDataBrowserTableViewControl::GetItems(DataBrowserItemID, Boolean, DataBrowserItemState, Handle) const */
398
399OSStatus wxMacDataBrowserTableViewControl::GetItemRow(DataBrowserItemID item, DataBrowserTableViewRowIndex* row) const
400{
401 return GetDataBrowserTableViewItemRow(this->m_controlRef,item,row);
402}
403
404OSStatus wxMacDataBrowserTableViewControl::IsUsedItemID(DataBrowserItemID itemID) const
405{
406 // 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
407 // 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
408 // the column position for the property id:
409 DataBrowserTableViewColumnIndex index;
410
411 return ::GetDataBrowserTableViewItemRow(this->m_controlRef,itemID,&index);
412} /* wxMacDataBrowserTableViewControl::IsUsedItemID(DataBrowserItemID) const */
413
414OSStatus wxMacDataBrowserTableViewControl::RemoveItems(DataBrowserItemID container, UInt32 numItems, DataBrowserItemID const* items, DataBrowserPropertyID preSortProperty)
415{
416 return ::RemoveDataBrowserItems(this->m_controlRef,container,numItems,items,preSortProperty);
417}
418
419OSStatus wxMacDataBrowserTableViewControl::RevealItem(DataBrowserItemID item, DataBrowserPropertyID propertyID, DataBrowserRevealOptions options) const
420{
421 return ::RevealDataBrowserItem(this->m_controlRef,item,propertyID,options);
422} /* wxMacDataBrowserTableViewControl::RevealItem(DataBrowserItemID item, DataBrowserPropertyID propertyID, DataBrowserRevealOptions options) const */
423
424OSStatus wxMacDataBrowserTableViewControl::UpdateItems(DataBrowserItemID container, UInt32 numItems, DataBrowserItemID const* items, DataBrowserPropertyID preSortProperty,
425 DataBrowserPropertyID propertyID) const
426{
427 return UpdateDataBrowserItems(this->m_controlRef,container,numItems,items,preSortProperty,propertyID);
428}
429
430//
431// item selection
432//
433size_t wxMacDataBrowserTableViewControl::GetSelectedItemIDs(wxArrayDataBrowserItemID& itemIDs) const
434{
435 DataBrowserItemID* itemIDPtr;
436 Handle handle(::NewHandle(0));
437
438 size_t NoOfItems;
439
440
441 wxCHECK_MSG(this->GetItems(kDataBrowserNoItem,true,kDataBrowserItemIsSelected,handle) == noErr,0,_("Could not get selected items."));
442 NoOfItems = static_cast<size_t>(::GetHandleSize(handle)/sizeof(DataBrowserItemID));
443 itemIDs.Empty();
444 itemIDs.Alloc(NoOfItems);
445 HLock(handle);
446 itemIDPtr = (DataBrowserItemID*) (*handle);
447 for (size_t i=0; i<NoOfItems; ++i)
448 {
449 itemIDs.Add(*itemIDPtr);
450 ++itemIDPtr;
451 } /* for */
452 HUnlock(handle);
453 DisposeHandle(handle);
454 return NoOfItems;
455} /* wxMacDataBrowserTableViewControl::GetSelectedItemIDs(wxArrayDataBrowserItemID&) const*/
456
194027ac 457OSStatus wxMacDataBrowserTableViewControl::GetSelectionAnchor(DataBrowserItemID* first, DataBrowserItemID* last) const
c0a66d92 458{
194027ac
RR
459 return ::GetDataBrowserSelectionAnchor(this->m_controlRef,first,last);
460} /* wxMacDataBrowserTableViewControl::GetSelectionAnchor(DataBrowserItemID*, DataBrowserItemID*) const */
c0a66d92
RR
461
462OSStatus wxMacDataBrowserTableViewControl::GetSelectionFlags(DataBrowserSelectionFlags* flags) const
463{
464 return ::GetDataBrowserSelectionFlags(this->m_controlRef,flags);
465} /* wxMacDataBrowserTableViewControl::GetSelectionFlags(DataBrowserSelectionFlags*) const */
466
467bool wxMacDataBrowserTableViewControl::IsItemSelected(DataBrowserItemID item) const
468{
469 return ::IsDataBrowserItemSelected(this->m_controlRef,item);
470} /* wxMacDataBrowserTableViewControl::IsItemSelected(DataBrowserItemID) const */
471
472OSStatus wxMacDataBrowserTableViewControl::SetSelectionFlags(DataBrowserSelectionFlags flags)
473{
474 return ::SetDataBrowserSelectionFlags(this->m_controlRef,flags);
475} /* wxMacDataBrowserTableViewControl::SetSelectionFlags(DataBrowserSelectionFlags) */
476
477OSStatus wxMacDataBrowserTableViewControl::SetSelectedItems(UInt32 numItems, DataBrowserItemID const* items, DataBrowserSetOption operation)
478{
194027ac 479 return ::SetDataBrowserSelectedItems(this->m_controlRef, numItems, items, operation );
c0a66d92
RR
480} /* wxMacDataBrowserTableViewControl::SetSelectedItems(UInt32, DataBrowserItemID const*, DataBrowserSetOption) */
481
07c51ff1 482OSStatus wxMacDataBrowserTableViewControl::GetSortOrder(DataBrowserSortOrder* order) const
c0a66d92 483{
07c51ff1 484 return ::GetDataBrowserSortOrder(this->m_controlRef,order);
c0a66d92
RR
485}
486
07c51ff1 487OSStatus wxMacDataBrowserTableViewControl::GetSortProperty(DataBrowserPropertyID* propertyID) const
c0a66d92 488{
07c51ff1 489 return ::GetDataBrowserSortProperty(this->m_controlRef,propertyID);
c0a66d92
RR
490}
491
07c51ff1 492OSStatus wxMacDataBrowserTableViewControl::Resort(DataBrowserItemID container, Boolean sortChildren)
c0a66d92 493{
07c51ff1
RR
494 return ::SortDataBrowserContainer(this->m_controlRef,container,sortChildren);
495} /* wxMacDataBrowserTableViewControl::Resort(DataBrowserItemID, Boolean) */
c0a66d92 496
194027ac 497OSStatus wxMacDataBrowserTableViewControl::SetSortOrder(DataBrowserSortOrder order)
c0a66d92 498{
194027ac 499 return ::SetDataBrowserSortOrder(this->m_controlRef,order);
c0a66d92
RR
500}
501
07c51ff1
RR
502OSStatus wxMacDataBrowserTableViewControl::SetSortProperty(DataBrowserPropertyID propertyID)
503{
504 return ::SetDataBrowserSortProperty(this->m_controlRef,propertyID);
505}
506
c17b2e31
RR
507//
508// container handling
509//
510OSStatus wxMacDataBrowserTableViewControl::CloseContainer(DataBrowserItemID containerID)
511{
512 return ::CloseDataBrowserContainer(this->m_controlRef,containerID);
513} /* wxMacDataBrowserTableViewControl::CloseContainer(DataBrowserItemID) */
514
515OSStatus wxMacDataBrowserTableViewControl::OpenContainer(DataBrowserItemID containerID)
516{
517 return ::OpenDataBrowserContainer(this->m_controlRef,containerID);
518} /* wxMacDataBrowserTableViewControl::OpenContainer(DataBrowserItemID) */
519
c0a66d92
RR
520IMPLEMENT_ABSTRACT_CLASS(wxMacDataBrowserTableViewControl,wxMacControl)
521
522// ============================================================================
194027ac 523// wxMacDataBrowserListViewControl
c0a66d92 524// ============================================================================
c0a66d92
RR
525#pragma mark -
526//
527// column handling
528//
529OSStatus wxMacDataBrowserListViewControl::AddColumn(DataBrowserListViewColumnDesc *columnDesc, DataBrowserTableViewColumnIndex position)
530{
531 return AddDataBrowserListViewColumn(this->m_controlRef,columnDesc,position);
532} /* wxMacDataBrowserListViewControl::AddColumn(DataBrowserListViewColumnDesc*, DataBrowserTableViewColumnIndex) */
533
534// ============================================================================
194027ac 535// wxMacDataViewDataBrowserListViewControl
c0a66d92 536// ============================================================================
c0a66d92
RR
537#pragma mark -
538//
539// constructors / destructor
540//
541wxMacDataViewDataBrowserListViewControl::wxMacDataViewDataBrowserListViewControl(wxWindow* peer, wxPoint const& pos, wxSize const& size, long style)
542 :wxMacDataBrowserListViewControl(peer,pos,size,style)
543{
544} /* wxMacDataViewDataBrowserListViewControl::wxMacDataViewDataBrowserListViewControl(wxWindow* , const wxPoint&, const wxSize&, long) */
545
546//
194027ac 547// callback functions (inherited from wxMacDataBrowserTableViewControl)
c0a66d92 548//
194027ac 549Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserCompareProc(DataBrowserItemID itemOneID, DataBrowserItemID itemTwoID, DataBrowserPropertyID sortProperty)
c0a66d92 550{
07c51ff1
RR
551 DataBrowserSortOrder sortOrder;
552
553 DataBrowserTableViewColumnIndex columnIndex;
554
194027ac 555 wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetPeer()));
c0a66d92 556
c0a66d92 557
194027ac
RR
558 wxCHECK_MSG(dataViewCtrlPtr != NULL, false,_("Pointer to data view control not set correctly."));
559 wxCHECK_MSG(dataViewCtrlPtr->GetModel() != NULL,false,_("Pointer to model not set correctly."));
560 if (sortProperty >= kMinPropertyID)
c0a66d92 561 {
194027ac 562 wxCHECK_MSG(this->GetColumnIndex(sortProperty,&columnIndex) == noErr,false,_("Could not determine column index."));
c0a66d92 563 } /* if */
07c51ff1
RR
564 else
565 columnIndex = 0;
566 this->GetSortOrder(&sortOrder);
567 return static_cast<Boolean>(dataViewCtrlPtr->GetModel()->Compare(wxDataViewItem(reinterpret_cast<void*>(itemOneID)),wxDataViewItem(reinterpret_cast<void*>(itemTwoID)),
568 columnIndex,sortOrder != kDataBrowserOrderDecreasing) < 0);
c0a66d92
RR
569} /* wxMacDataViewDataBrowserListViewControl::DataBrowserCompareProc(DataBrowserItemID, DataBrowserItemID, DataBrowserPropertyID) */
570
194027ac 571void wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, DataBrowserItemState state, Rect const* rectangle, SInt16 bitDepth, Boolean colorDevice)
c0a66d92 572{
194027ac 573 DataBrowserTableViewColumnIndex columnIndex;
c0a66d92
RR
574
575 wxDataViewColumn* dataViewColumnPtr;
576
577 wxDataViewCtrl* dataViewCtrlPtr;
578
579 wxDataViewCustomRenderer* dataViewCustomRendererPtr;
580
581 wxVariant dataToRender;
582
583
c0a66d92 584 dataViewCtrlPtr = dynamic_cast<wxDataViewCtrl*>(this->GetPeer());
194027ac
RR
585 wxCHECK_RET(dataViewCtrlPtr != NULL, _("Pointer to data view control not set correctly."));
586 wxCHECK_RET(dataViewCtrlPtr->GetModel() != NULL, _("Pointer to model not set correctly."));
587 wxCHECK_RET(this->GetColumnIndex(propertyID,&columnIndex) == noErr,_("Could not determine column index."));
588 dataViewColumnPtr = dataViewCtrlPtr->GetColumn(columnIndex);
c0a66d92
RR
589 wxCHECK_RET(dataViewColumnPtr != NULL,_("No column for the specified column index existing."));
590 dataViewCustomRendererPtr = dynamic_cast<wxDataViewCustomRenderer*>(dataViewColumnPtr->GetRenderer());
591 wxCHECK_RET(dataViewCustomRendererPtr != NULL,_("No renderer or invalid renderer type specified for custom data column."));
194027ac 592 dataViewCtrlPtr->GetModel()->GetValue(dataToRender,wxDataViewItem(reinterpret_cast<void*>(itemID)),columnIndex);
c0a66d92
RR
593 dataViewCustomRendererPtr->SetValue(dataToRender);
594
595 // try to determine the content's size (drawable part):
596 Rect content;
597 RgnHandle rgn(NewRgn());
598 UInt16 headerHeight;
599
600 if (this->GetRegion(kControlContentMetaPart,rgn) == noErr)
601 GetRegionBounds(rgn,&content);
602 else
603 this->GetRect(&content);
604 ::DisposeRgn(rgn);
605 // space for the header
606 this->GetHeaderButtonHeight(&headerHeight);
607 content.top += headerHeight;
608 // extra space for the frame (todo: do not how to determine the space automatically from the control)
609 content.top += 5;
610 content.left += 5;
611 content.right -= 3;
612 content.bottom -= 3;
613 // extra space for the scrollbars:
614 content.bottom -= wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y);
615 content.right -= wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
616
617 // make sure that 'Render' can draw only in the allowed area:
618 dataViewCustomRendererPtr->GetDC()->SetClippingRegion(content.left,content.top,content.right-content.left+1,content.bottom-content.top+1);
619 (void) (dataViewCustomRendererPtr->Render(wxRect(static_cast<int>(rectangle->left),static_cast<int>(rectangle->top),
620 static_cast<int>(1+rectangle->right-rectangle->left),static_cast<int>(1+rectangle->bottom-rectangle->top)),
621 dataViewCustomRendererPtr->GetDC(),((state == kDataBrowserItemIsSelected) ? wxDATAVIEW_CELL_SELECTED : 0)));
622 dataViewCustomRendererPtr->GetDC()->DestroyClippingRegion(); // probably not necessary
623} /* wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemState, Rect const*, SInt16, Boolean) */
624
194027ac 625OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, DataBrowserItemDataRef itemData, Boolean getValue)
c0a66d92
RR
626{
627 if (getValue)
628 {
194027ac 629 // variable definitions:
07c51ff1 630 wxDataViewCtrl* dataViewCtrlPtr;
c0a66d92 631
c0a66d92 632 dataViewCtrlPtr = dynamic_cast<wxDataViewCtrl*>(this->GetPeer());
07c51ff1
RR
633 wxCHECK_MSG(dataViewCtrlPtr != NULL,errDataBrowserNotConfigured,_("Pointer to data view control not set correctly."));
634 if (dataViewCtrlPtr->IsDeleting())
635 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
636 else
c0a66d92 637 {
07c51ff1
RR
638 // variable definitions:
639 DataBrowserTableViewColumnIndex columnIndex;
640 OSStatus errorStatus;
641 wxDataViewColumn* dataViewColumnPtr;
642
643 wxCHECK_MSG(dataViewCtrlPtr->GetModel() != NULL,errDataBrowserNotConfigured,_("Pointer to model not set correctly."));
644 errorStatus = this->GetColumnIndex(propertyID,&columnIndex);
645 wxCHECK_MSG(errorStatus == noErr,errorStatus,_("Could not determine column index"));
646 dataViewColumnPtr = dataViewCtrlPtr->GetColumn(columnIndex);
647 wxCHECK_MSG((dataViewColumnPtr != NULL) && (dataViewColumnPtr->GetRenderer() != NULL),errDataBrowserNotConfigured,_("There is no column or renderer for the specified column index."));
648 switch (dataViewColumnPtr->GetRenderer()->GetPropertyType())
649 {
650 case kDataBrowserCheckboxType:
c0a66d92 651 {
07c51ff1
RR
652 // variable definition:
653 ThemeButtonValue buttonValue;
c0a66d92 654
07c51ff1
RR
655 errorStatus = ::GetDataBrowserItemDataButtonValue(itemData,&buttonValue);
656 if (errorStatus == noErr)
c0a66d92 657 {
07c51ff1
RR
658 if (buttonValue == kThemeButtonOn)
659 {
660 // variable definition and initialization:
661 wxVariant modifiedData(true);
662
663 return (dataViewCtrlPtr->GetModel()->SetValue(modifiedData,wxDataViewItem(reinterpret_cast<void*>(itemID)),static_cast<unsigned int>(columnIndex)) ? OSStatus(noErr) : OSStatus(errDataBrowserNotConfigured));
664 } /* if */
665 else if (buttonValue == kThemeButtonOff)
666 {
667 // variable definition and initialization:
668 wxVariant modifiedData(false);
669
670 return (dataViewCtrlPtr->GetModel()->SetValue(modifiedData,wxDataViewItem(reinterpret_cast<void*>(itemID)),static_cast<unsigned int>(columnIndex)) ? OSStatus(noErr) : OSStatus(errDataBrowserNotConfigured));
671 } /* if */
672 else
673 return errDataBrowserInvalidPropertyData;
c0a66d92
RR
674 } /* if */
675 else
07c51ff1
RR
676 return errorStatus;
677 } /* block */
678 case kDataBrowserTextType:
c0a66d92 679 {
07c51ff1
RR
680 // variable definitions:
681 CFStringRef stringReference;
c0a66d92 682
07c51ff1
RR
683 errorStatus = ::GetDataBrowserItemDataText(itemData,&stringReference);
684 if (errorStatus == noErr)
685 {
686 // variable definitions and initializations:
687 wxMacCFStringHolder modifiedString(stringReference);
688 wxVariant modifiedData(modifiedString.AsString());
689
690 if (dataViewCtrlPtr->GetModel()->SetValue(modifiedData,wxDataViewItem(reinterpret_cast<void*>(itemID)),static_cast<unsigned int>(columnIndex)))
691 return noErr;
692 else
693 return errDataBrowserNotConfigured;
694 } /* if */
c0a66d92 695 else
07c51ff1
RR
696 return errorStatus;
697 } /* block */
698 default:
699 return errDataBrowserPropertyNotSupported;
700 } /* switch */
701 } /* if */
c0a66d92
RR
702 } /* if */
703 else
704 {
07c51ff1 705 if (propertyID >= kMinPropertyID) // in case data columns set the data
c0a66d92
RR
706 {
707 // variable definitions:
c17b2e31
RR
708 wxVariant variant;
709 wxDataViewColumn* dataViewColumnPtr;
710 wxDataViewCtrl* dataViewCtrlPtr;
c0a66d92 711
194027ac
RR
712 dataViewCtrlPtr = dynamic_cast<wxDataViewCtrl*>(this->GetPeer());
713 wxCHECK_MSG(dataViewCtrlPtr != NULL,errDataBrowserNotConfigured,_("Pointer to data view control not set correctly."));
714 wxCHECK_MSG(dataViewCtrlPtr->GetModel() != NULL,errDataBrowserNotConfigured,_("Pointer to model not set correctly."));
c17b2e31 715 dataViewColumnPtr = dataViewCtrlPtr->GetColumnPtr(propertyID);
194027ac 716 wxCHECK_MSG(dataViewColumnPtr != NULL,errDataBrowserNotConfigured,_("No column for the specified column position existing."));
c0a66d92 717 wxCHECK_MSG(dataViewColumnPtr->GetRenderer() != NULL,errDataBrowserNotConfigured,_("No renderer specified for column."));
194027ac 718 dataViewCtrlPtr->GetModel()->GetValue(variant,wxDataViewItem(reinterpret_cast<void*>(itemID)),dataViewColumnPtr->GetModelColumn());
c17b2e31
RR
719 if (!(variant.IsNull()))
720 {
721 dataViewColumnPtr->GetRenderer()->SetDataReference(itemData);
722 dataViewColumnPtr->GetRenderer()->SetValue(variant);
723 wxCHECK_MSG(dataViewColumnPtr->GetRenderer()->Render(),errDataBrowserNotConfigured,_("Rendering failed."));
724 } /* if */
07c51ff1 725 return noErr;
c0a66d92
RR
726 } /* if */
727 else // react on special system requests
c17b2e31 728 {
194027ac 729 switch (propertyID)
c0a66d92 730 {
07c51ff1
RR
731 case kDataBrowserContainerIsClosableProperty:
732 {
733 // variable definitions:
734 wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetPeer()));
735
736 wxCHECK_MSG(dataViewCtrlPtr != NULL,errDataBrowserNotConfigured,_("Pointer to data view control not set correctly."));
737 // initialize wxWidget event:
738 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING,dataViewCtrlPtr->GetId()); // variable definition
739
740 dataViewEvent.SetEventObject(dataViewCtrlPtr);
741 dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID)));
742 // finally send the equivalent wxWidget event:
743 dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
744 // opening the container is allowed if not vetoed:
745 return ::SetDataBrowserItemDataBooleanValue(itemData,dataViewEvent.IsAllowed());
746 } /* block */
07c51ff1
RR
747 case kDataBrowserContainerIsOpenableProperty:
748 {
749 // variable definitions:
750 wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetPeer()));
751
752 wxCHECK_MSG(dataViewCtrlPtr != NULL,errDataBrowserNotConfigured,_("Pointer to data view control not set correctly."));
753 // initialize wxWidget event:
754 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING,dataViewCtrlPtr->GetId()); // variable definition
755
756 dataViewEvent.SetEventObject(dataViewCtrlPtr);
757 dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID)));
758 // finally send the equivalent wxWidget event:
759 dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
760 // opening the container is allowed if not vetoed:
761 return ::SetDataBrowserItemDataBooleanValue(itemData,dataViewEvent.IsAllowed());
762 } /* block */
c0a66d92 763 case kDataBrowserItemIsContainerProperty:
194027ac
RR
764 {
765 // variable definition:
766 wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetPeer()));
767
768 wxCHECK_MSG(dataViewCtrlPtr != NULL,errDataBrowserNotConfigured,_("Pointer to data view control not set correctly."));
769 wxCHECK_MSG(dataViewCtrlPtr->GetModel() != NULL,errDataBrowserNotConfigured,_("Pointer to model not set correctly."));
770 return ::SetDataBrowserItemDataBooleanValue(itemData,dataViewCtrlPtr->GetModel()->IsContainer(wxDataViewItem(reinterpret_cast<void*>(itemID))));
771 } /* block */
c0a66d92
RR
772 case kDataBrowserItemIsEditableProperty:
773 return ::SetDataBrowserItemDataBooleanValue(itemData,true);
774 } /* switch */
c17b2e31 775 } /* if */
c0a66d92
RR
776 } /* if */
777 return errDataBrowserPropertyNotSupported;
778} /* wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemDataRef, Boolean) */
779
c17b2e31 780void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(DataBrowserItemID itemID, DataBrowserItemNotification message, DataBrowserItemDataRef itemData)
c0a66d92 781{
a5fb9253
RR
782 wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetPeer()));
783
784
785 // 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:
786 if (dataViewCtrlPtr != NULL)
787 switch (message)
788 {
789 case kDataBrowserContainerClosed:
07c51ff1
RR
790 {
791 // initialize wxWidget event:
792 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED,dataViewCtrlPtr->GetId()); // variable definition
793
794 dataViewEvent.SetEventObject(dataViewCtrlPtr);
795 dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID)));
796 // finally send the equivalent wxWidget event:
797 dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
a5fb9253
RR
798 } /* block */
799 break;
800 case kDataBrowserContainerOpened:
801 {
802 // initialize wxWidget event:
803 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED,dataViewCtrlPtr->GetId()); // variable definition
804
805 dataViewEvent.SetEventObject(dataViewCtrlPtr);
806 dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID)));
807 // finally send the equivalent wxWidget event:
808 dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
809 // add children to the expanded container:
810 dataViewCtrlPtr->AddChildrenLevel(wxDataViewItem(reinterpret_cast<void*>(itemID)));
811 } /* block */
812 break;
813 case kDataBrowserEditStarted:
c17b2e31
RR
814 {
815 // initialize wxWidget event:
816 DataBrowserPropertyID propertyID;
817 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED,dataViewCtrlPtr->GetId()); // variable definition
818
819 dataViewEvent.SetEventObject(dataViewCtrlPtr);
820 dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID)));
821 if (this->GetPropertyID(itemData,&propertyID) == noErr)
822 {
823 // variable definition and initialization:
824 DataBrowserTableViewColumnIndex columnIndex;
825
826 wxCHECK_RET(this->GetColumnIndex(propertyID,&columnIndex),_("Column index not found."));
827 dataViewEvent.SetColumn(columnIndex);
828 dataViewEvent.SetDataViewColumn(dataViewCtrlPtr->GetColumnPtr(propertyID));
829 } /* if */
830 // finally send the equivalent wxWidget event:
831 dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
a5fb9253
RR
832 } /* block */
833 break;
834 case kDataBrowserEditStopped:
07c51ff1
RR
835 {
836 // initialize wxWidget event:
a5fb9253
RR
837 DataBrowserPropertyID propertyID;
838 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE,dataViewCtrlPtr->GetId()); // variable definition
07c51ff1
RR
839
840 dataViewEvent.SetEventObject(dataViewCtrlPtr);
841 dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID)));
a5fb9253
RR
842 if (this->GetPropertyID(itemData,&propertyID) == noErr)
843 {
844 // variable definition and initialization:
845 DataBrowserTableViewColumnIndex columnIndex;
846
847 wxCHECK_RET(this->GetColumnIndex(propertyID,&columnIndex),_("Column index not found."));
848 dataViewEvent.SetColumn(columnIndex);
849 dataViewEvent.SetDataViewColumn(dataViewCtrlPtr->GetColumnPtr(propertyID));
850 } /* if */
07c51ff1
RR
851 // finally send the equivalent wxWidget event:
852 dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
a5fb9253
RR
853 } /* block */
854 break;
855 case kDataBrowserItemAdded:
856 break; // not used anymore
857 case kDataBrowserItemDeselected:
858 break; // not implemented by wxWidgets; see kDataBrowserSelectionSetChanged
859 case kDataBrowserItemDoubleClicked:
860 {
861 // initialize wxWidget event:
862 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED,dataViewCtrlPtr->GetId()); // variable definition
6d9ecc87 863
a5fb9253
RR
864 dataViewEvent.SetEventObject(dataViewCtrlPtr);
865 dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID)));
866 // finally send the equivalent wxWidget event:
867 dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
868 } /* block */
869 break;
870 case kDataBrowserItemRemoved:
871 break; // not used anymore
872 case kDataBrowserItemSelected:
873 break; // not implemented by wxWidgets; see kDataBrowserSelectionSetChanged
874 case kDataBrowserSelectionSetChanged:
6d9ecc87 875 {
a5fb9253
RR
876 // initialize wxWidget event:
877 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED,dataViewCtrlPtr->GetId()); // variable definition
878
879 dataViewEvent.SetEventObject(dataViewCtrlPtr);
880 dataViewEvent.SetModel (dataViewCtrlPtr->GetModel());
881 // finally send the equivalent wxWidget event:
882 dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
883 } /* block */
884 break;
885 case kDataBrowserUserStateChanged:
c0a66d92 886 {
a5fb9253
RR
887 // update column widths:
888 for (size_t i=0; i<dataViewCtrlPtr->GetColumnCount(); ++i)
c0a66d92 889 {
a5fb9253
RR
890 // constant definition for abbreviational purposes:
891 wxDataViewColumn* const columnPtr = dataViewCtrlPtr->GetColumn(i);
892 // variable definition:
893 UInt16 columnWidth;
894
895 wxCHECK_RET(this->GetColumnWidth(columnPtr->GetPropertyID(),&columnWidth) == noErr,_("Column width could not be determined"));
896 columnPtr->SetWidthVariable(columnWidth);
897 } /* for */
898 // update order status:
899 DataBrowserPropertyID propertyID; // variable definition
900
901 if ((this->GetSortProperty(&propertyID) == noErr) && (propertyID >= kMinPropertyID))
902 {
903 DataBrowserSortOrder sortOrder;
904 DataBrowserTableViewColumnIndex columnIndex;
905
906 if ((this->GetSortOrder(&sortOrder) == noErr) && (this->GetColumnIndex(propertyID,&columnIndex) == noErr))
c0a66d92 907 {
a5fb9253
RR
908 // variable definition and initialization:
909 wxDataViewColumn* columnPtr;
910 columnPtr = dataViewCtrlPtr->GetColumn(columnIndex);
911 // check if the sort order has changed:
912 if ( columnPtr->IsSortOrderAscending() && (sortOrder == kDataBrowserOrderDecreasing) ||
913 !(columnPtr->IsSortOrderAscending()) && (sortOrder == kDataBrowserOrderIncreasing))
914 {
915 columnPtr->SetSortOrder(!(columnPtr->IsSortOrderAscending()));
916 // initialize wxWidget event:
917 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED,dataViewCtrlPtr->GetId()); // variable defintion
918
919 dataViewEvent.SetEventObject(dataViewCtrlPtr);
920 dataViewEvent.SetColumn(columnIndex);
921 dataViewEvent.SetDataViewColumn(columnPtr);
922 // finally send the equivalent wxWidget event:
923 dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
924 } /* if */
c0a66d92
RR
925 } /* if */
926 } /* if */
a5fb9253
RR
927 } /* block */
928 break;
929 } /* switch */
c0a66d92
RR
930} /* wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(DataBrowserItemID, DataBrowserItemNotification, DataBrowserItemDataRef) */
931
932
a3fd36e7 933#endif // wxUSE_GENERICDATAVIEWCTRL