]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/databrow.cpp
Tests for declarations of snprintf/vsnprintf/vsscanf should be done in C++.
[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
99c75ebc 4// Author:
c0a66d92
RR
5// Modified by:
6// Created: 2007-05-18
7// RCS-ID: $Id$
8// Copyright: (c)
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
a2426623 12#include "wx/wxprec.h"
a3fd36e7 13
7fc2ce00 14#if wxUSE_DATAVIEWCTRL
a2426623 15#ifndef wxUSE_GENERICDATAVIEWCTRL
c0a66d92 16
a5fb9253
RR
17#ifndef WX_PRECOMP
18 #include "wx/app.h"
19 #include "wx/toplevel.h"
20 #include "wx/font.h"
a2426623
PC
21 #include "wx/settings.h"
22 #include "wx/utils.h"
a5fb9253
RR
23#endif
24
25#include "wx/dataview.h"
f53c8638 26#include "wx/mac/carbon/databrow.h"
594d5596 27#include "wx/mac/private.h"
a5fb9253 28#include "wx/mac/uma.h"
c0a66d92 29
a2426623
PC
30#include <limits>
31
99c75ebc
RR
32// ============================================================================
33// Variables used globally in databrow.cpp
34// ============================================================================
35DataBrowserGetContextualMenuUPP gDataBrowserTableViewGetContextualMenuUPP = NULL;
36DataBrowserItemCompareUPP gDataBrowserTableViewItemCompareUPP = NULL;
37DataBrowserItemDataUPP gDataBrowserTableViewItemDataUPP = NULL;
38DataBrowserItemNotificationUPP gDataBrowserTableViewItemNotificationUPP = NULL;
39
40DataBrowserDrawItemUPP gDataBrowserTableViewDrawItemUPP = NULL;
41DataBrowserEditItemUPP gDataBrowserTableViewEditItemUPP = NULL;
42DataBrowserHitTestUPP gDataBrowserTableViewHitTestUPP = NULL;
43DataBrowserTrackingUPP gDataBrowserTableViewTrackingUPP = NULL;
44
c0a66d92 45// ============================================================================
194027ac 46// wxMacDataBrowserTableViewControl
c0a66d92 47// ============================================================================
c0a66d92
RR
48
49pascal Boolean wxMacDataBrowserTableViewControl::DataBrowserCompareProc(ControlRef browser, DataBrowserItemID itemOneID, DataBrowserItemID itemTwoID, DataBrowserPropertyID sortProperty)
50{
51 wxMacDataBrowserTableViewControl* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl*>(wxMacControl::GetReferenceFromNativeControl(browser)));
52
53
54 if (ControlPtr != NULL)
55 return ControlPtr->DataBrowserCompareProc(itemOneID,itemTwoID,sortProperty);
56 else
57 return errDataBrowserPropertyNotSupported;
58} /* wxMacDataBrowserTableViewControl::DataBrowserCompareProc(ControlRef, DataBrowserItemID, DataBrowserItemID, DataBrowserPropertyID) */
59
99c75ebc 60pascal void wxMacDataBrowserTableViewControl::DataBrowserGetContextualMenuProc(ControlRef browser, MenuRef* menu, UInt32* helpType, CFStringRef* helpItemString, AEDesc* selection)
c0a66d92
RR
61{
62 wxMacDataBrowserTableViewControl* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl*>(wxMacControl::GetReferenceFromNativeControl(browser)));
63
64
65 if (ControlPtr != NULL)
99c75ebc
RR
66 ControlPtr->DataBrowserGetContextualMenuProc(menu,helpType,helpItemString,selection);
67} /* wxMacDataBrowserTableViewControl::DataBrowserGetContextualMenuProc(ControlRef, MenuRef*, UInt32*, CFStringRef*, AEDesc*) */
c0a66d92 68
99c75ebc 69pascal OSStatus wxMacDataBrowserTableViewControl::DataBrowserGetSetItemDataProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID propertyID, DataBrowserItemDataRef itemData, Boolean getValue)
c0a66d92
RR
70{
71 wxMacDataBrowserTableViewControl* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl*>(wxMacControl::GetReferenceFromNativeControl(browser)));
72
73
74 if (ControlPtr != NULL)
99c75ebc 75 return ControlPtr->DataBrowserGetSetItemDataProc(itemID,propertyID,itemData,getValue);
c0a66d92
RR
76 else
77 return errDataBrowserPropertyNotSupported;
78} /* wxMacDataBrowserTableViewControl::DataBrowserGetSetItemDataProc(ControlRef, DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemDataRef, Boolean) */
79
80pascal void wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserItemNotification message, DataBrowserItemDataRef itemData)
81{
82 wxMacDataBrowserTableViewControl* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl*>(wxMacControl::GetReferenceFromNativeControl(browser)));
83
84
85 if (ControlPtr != NULL)
86 ControlPtr->DataBrowserItemNotificationProc(itemID,message,itemData);
87} /* wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc(ControlRef, DataBrowserItemID, DataBrowserItemNotification, DataBrowserItemDataRef) */
88
99c75ebc
RR
89pascal void wxMacDataBrowserTableViewControl::DataBrowserDrawItemProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID propertyID, DataBrowserItemState state, Rect const* rectangle, SInt16 bitDepth, Boolean colorDevice)
90{
91 wxMacDataBrowserTableViewControl* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl*>(wxMacControl::GetReferenceFromNativeControl(browser)));
92
93
94 if (ControlPtr != NULL)
95 ControlPtr->DataBrowserDrawItemProc(itemID,propertyID,state,rectangle,bitDepth,colorDevice);
96} /* wxMacDataBrowserTableViewControl::DataBrowserDrawItemProc(ControlRef, DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemState, Rect const*, SInt16, Boolean) */
97
98pascal Boolean wxMacDataBrowserTableViewControl::DataBrowserEditItemProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID propertyID, CFStringRef theString, Rect* maxEditTextRect, Boolean* shrinkToFit)
99{
100 wxMacDataBrowserTableViewControl* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl*>(wxMacControl::GetReferenceFromNativeControl(browser)));
101
102
103 return ((ControlPtr != NULL) && ControlPtr->DataBrowserEditItemProc(itemID,propertyID,theString,maxEditTextRect,shrinkToFit));
104} /* wxMacDataBrowserTableViewControl::DataBrowserEditItemProc(ControlRef, DataBrowserItemID, DataBrowserPropertyID, CFStringRef, Rect*, Boolean*) */
105
106pascal Boolean wxMacDataBrowserTableViewControl::DataBrowserHitTestProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID propertyID, Rect const* theRect, Rect const* mouseRect)
107{
108 wxMacDataBrowserTableViewControl* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl*>(wxMacControl::GetReferenceFromNativeControl(browser)));
109
110
111 return ((ControlPtr != NULL) && ControlPtr->DataBrowserHitTestProc(itemID,propertyID,theRect,mouseRect));
112} /* wxMacDataBrowserTableViewControl::DataBrowserHitTestProc(ControlRef, DataBrowserItemID, DataBrowserPropertyID, Rect const*, Rect const*) */
113
114pascal DataBrowserTrackingResult wxMacDataBrowserTableViewControl::DataBrowserTrackingProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID propertyID, Rect const* theRect, Point startPt, EventModifiers modifiers)
115{
116 wxMacDataBrowserTableViewControl* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl*>(wxMacControl::GetReferenceFromNativeControl(browser)));
117
118
119 if (ControlPtr != NULL)
120 return ControlPtr->DataBrowserTrackingProc(itemID,propertyID,theRect,startPt,modifiers);
121 else
122 return kDataBrowserNothingHit;
123} /* wxMacDataBrowserTableViewControl::DataBrowserTrackingProc(ControlRef, DataBrowserItemID, DataBrowserPropertyID, Rect const*, Point, EventModifiers) */
c0a66d92
RR
124
125wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow* peer, wxPoint const& pos, wxSize const& size, long style)
126 :wxMacControl(peer)
127{
128 Rect bounds = wxMacGetBoundsForControl(peer,pos,size);
129 OSStatus err = ::CreateDataBrowserControl(MAC_WXHWND(peer->MacGetTopLevelWindowRef()),&bounds,kDataBrowserListView,&(this->m_controlRef));
130
131
132 SetReferenceInNativeControl();
133 verify_noerr(err);
99c75ebc
RR
134 // setup standard callbacks:
135 if (gDataBrowserTableViewGetContextualMenuUPP == NULL) gDataBrowserTableViewGetContextualMenuUPP = NewDataBrowserGetContextualMenuUPP(wxMacDataBrowserTableViewControl::DataBrowserGetContextualMenuProc);
136 if (gDataBrowserTableViewItemCompareUPP == NULL) gDataBrowserTableViewItemCompareUPP = NewDataBrowserItemCompareUPP (wxMacDataBrowserTableViewControl::DataBrowserCompareProc);
137 if (gDataBrowserTableViewItemDataUPP == NULL) gDataBrowserTableViewItemDataUPP = NewDataBrowserItemDataUPP (wxMacDataBrowserTableViewControl::DataBrowserGetSetItemDataProc);
c0a66d92
RR
138 if (gDataBrowserTableViewItemNotificationUPP == NULL)
139 {
140 gDataBrowserTableViewItemNotificationUPP =
99c75ebc 141#if TARGET_API_MAC_OSX
c0a66d92 142 (DataBrowserItemNotificationUPP) NewDataBrowserItemNotificationWithItemUPP(wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc);
99c75ebc
RR
143#else
144 NewDataBrowserItemNotificationUPP(wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc);
145#endif
c0a66d92 146 }
99c75ebc 147 DataBrowserCallbacks callbacks; // variable definition
c0a66d92 148
99c75ebc
RR
149 InitializeDataBrowserCallbacks(&callbacks,kDataBrowserLatestCallbacks);
150 callbacks.u.v1.getContextualMenuCallback = gDataBrowserTableViewGetContextualMenuUPP;
151 callbacks.u.v1.itemDataCallback = gDataBrowserTableViewItemDataUPP;
152 callbacks.u.v1.itemCompareCallback = gDataBrowserTableViewItemCompareUPP;
153 callbacks.u.v1.itemNotificationCallback = gDataBrowserTableViewItemNotificationUPP;
154 this->SetCallbacks(&callbacks);
c0a66d92 155
99c75ebc
RR
156 // setup callbacks for customized items:
157 if (gDataBrowserTableViewDrawItemUPP == NULL) gDataBrowserTableViewDrawItemUPP = NewDataBrowserDrawItemUPP(wxMacDataBrowserTableViewControl::DataBrowserDrawItemProc);
158 if (gDataBrowserTableViewEditItemUPP == NULL) gDataBrowserTableViewEditItemUPP = NewDataBrowserEditItemUPP(wxMacDataBrowserTableViewControl::DataBrowserEditItemProc);
159 if (gDataBrowserTableViewHitTestUPP == NULL) gDataBrowserTableViewHitTestUPP = NewDataBrowserHitTestUPP (wxMacDataBrowserTableViewControl::DataBrowserHitTestProc);
160 if (gDataBrowserTableViewTrackingUPP == NULL) gDataBrowserTableViewTrackingUPP = NewDataBrowserTrackingUPP(wxMacDataBrowserTableViewControl::DataBrowserTrackingProc);
c0a66d92 161
99c75ebc 162 DataBrowserCustomCallbacks customCallbacks; // variable definition
c0a66d92 163
99c75ebc 164 InitializeDataBrowserCustomCallbacks(&customCallbacks,kDataBrowserLatestCallbacks);
c0a66d92 165 customCallbacks.u.v1.drawItemCallback = gDataBrowserTableViewDrawItemUPP;
99c75ebc
RR
166 customCallbacks.u.v1.editTextCallback = gDataBrowserTableViewEditItemUPP;
167 customCallbacks.u.v1.hitTestCallback = gDataBrowserTableViewHitTestUPP;
168 customCallbacks.u.v1.trackingCallback = gDataBrowserTableViewTrackingUPP;
c0a66d92
RR
169 this->SetCustomCallbacks(&customCallbacks);
170
171 // style setting:
172 this->EnableCellSizeModification();
173
174 DataBrowserSelectionFlags flags; // variable definition
175
176 if (this->GetSelectionFlags(&flags) == noErr) // get default settings
177 {
178 if ((style & wxDV_MULTIPLE) != 0)
179 flags &= ~kDataBrowserSelectOnlyOne;
180 else
181 flags |= kDataBrowserSelectOnlyOne;
182 (void) this->SetSelectionFlags(flags);
183 } /* if */
594d5596 184
c0a66d92 185 OptionBits attributes; // variable definition
99c75ebc 186
c0a66d92
RR
187 if (this->GetAttributes(&attributes) == noErr) // get default settings
188 {
189 if ((style & wxDV_VERT_RULES) != 0)
190 attributes |= kDataBrowserAttributeListViewDrawColumnDividers;
191 else
192 attributes &= ~kDataBrowserAttributeListViewDrawColumnDividers;
6ab2382a
RR
193 if ((style & wxDV_ROW_LINES) != 0)
194 attributes |= kDataBrowserAttributeListViewAlternatingRowColors;
99c75ebc
RR
195 else
196 attributes &= ~kDataBrowserAttributeListViewAlternatingRowColors;
c0a66d92
RR
197 (void) this->SetAttributes(attributes);
198 } /* if */
594d5596 199
c0a66d92
RR
200 if ((style & wxDV_NO_HEADER) != 0)
201 this->SetHeaderButtonHeight(0);
202} /* wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow*, wxPoint const&, wxSize const&, long) */
203
204//
205// callback handling
206//
207OSStatus wxMacDataBrowserTableViewControl::SetCallbacks(DataBrowserCallbacks const* callbacks)
208{
209 return ::SetDataBrowserCallbacks(this->m_controlRef,callbacks);
210} /* wxMacDataBrowserTableViewControl::SetCallbacks(DataBrowserCallbacks const*) */
211
212OSStatus wxMacDataBrowserTableViewControl::SetCustomCallbacks(DataBrowserCustomCallbacks const* customCallbacks)
213{
214 return ::SetDataBrowserCustomCallbacks(this->m_controlRef,customCallbacks);
215} /* xMacDataBrowserTableViewControl::SetCustomCallbacks(DataBrowserCustomCallbacks const*) */
216
217//
218// header handling
219//
99c75ebc 220OSStatus wxMacDataBrowserTableViewControl::GetHeaderDesc(DataBrowserPropertyID propertyID, DataBrowserListViewHeaderDesc* desc) const
c0a66d92
RR
221{
222 desc->version = kDataBrowserListViewLatestHeaderDesc; // if this statement is missing the next call will fail (NOT DOCUMENTED!!)
99c75ebc 223 return ::GetDataBrowserListViewHeaderDesc(this->m_controlRef,propertyID,desc);
c0a66d92
RR
224}
225
99c75ebc 226OSStatus wxMacDataBrowserTableViewControl::SetHeaderDesc(DataBrowserPropertyID propertyID, DataBrowserListViewHeaderDesc* desc)
c0a66d92 227{
99c75ebc 228 return ::SetDataBrowserListViewHeaderDesc(this->m_controlRef,propertyID,desc);
c0a66d92
RR
229}
230
231//
232// layout handling
233//
234OSStatus wxMacDataBrowserTableViewControl::AutoSizeColumns()
235{
236 return AutoSizeDataBrowserListViewColumns(this->m_controlRef);
237}
238
239OSStatus wxMacDataBrowserTableViewControl::EnableCellSizeModification(bool enableHeight, bool enableWidth)
240{
241 return ::SetDataBrowserTableViewGeometry(this->GetControlRef(),enableWidth,enableHeight);
242} /* wxMacDataBrowserTableViewControl::EnableCellSizeModification(bool, bool) */
243
c0a66d92
RR
244OSStatus wxMacDataBrowserTableViewControl::GetAttributes(OptionBits* attributes)
245{
246 return ::DataBrowserGetAttributes(this->GetControlRef(),attributes);
247} /* wxMacDataBrowserTableViewControl::GetAttributes(OptionBits*) */
c0a66d92 248
194027ac 249OSStatus wxMacDataBrowserTableViewControl::GetColumnWidth(DataBrowserPropertyID propertyID, UInt16* width) const
c0a66d92 250{
194027ac 251 return ::GetDataBrowserTableViewNamedColumnWidth(this->m_controlRef,propertyID,width);
c0a66d92
RR
252}
253
07c51ff1
RR
254OSStatus wxMacDataBrowserTableViewControl::GetDefaultColumnWidth( UInt16 *width ) const
255{
256 return GetDataBrowserTableViewColumnWidth(this->m_controlRef, width );
257}
258
194027ac 259OSStatus wxMacDataBrowserTableViewControl::GetDefaultRowHeight(UInt16* height) const
c0a66d92 260{
194027ac 261 return ::GetDataBrowserTableViewRowHeight(this->m_controlRef,height);
c0a66d92
RR
262}
263
264OSStatus wxMacDataBrowserTableViewControl::GetHeaderButtonHeight(UInt16 *height)
265{
194027ac 266 return ::GetDataBrowserListViewHeaderBtnHeight(this->m_controlRef,height);
c0a66d92
RR
267}
268
99c75ebc 269OSStatus wxMacDataBrowserTableViewControl::GetPartBounds(DataBrowserItemID item, DataBrowserPropertyID propertyID, DataBrowserPropertyPart part, Rect* bounds)
c0a66d92 270{
99c75ebc 271 return ::GetDataBrowserItemPartBounds(this->m_controlRef,item,propertyID,part,bounds);
07c51ff1 272} /* wxMacDataBrowserTableViewControl::GetPartBounds(DataBrowserItemID, DataBrowswerPropertyID, DataBrowserPropertyPart, Rect*) */
c0a66d92 273
07c51ff1 274OSStatus wxMacDataBrowserTableViewControl::GetRowHeight(DataBrowserItemID item, UInt16* height) const
c0a66d92 275{
07c51ff1
RR
276 return ::GetDataBrowserTableViewItemRowHeight(this->m_controlRef,item,height);
277} /* wxMacDataBrowserTableViewControl::GetRowHeight(DataBrowserItemID, UInt16*) const */
c0a66d92
RR
278
279OSStatus wxMacDataBrowserTableViewControl::GetScrollPosition( UInt32 *top , UInt32 *left ) const
280{
194027ac 281 return GetDataBrowserScrollPosition(this->m_controlRef, top , left );
c0a66d92
RR
282}
283
c0a66d92
RR
284OSStatus wxMacDataBrowserTableViewControl::SetAttributes(OptionBits attributes)
285{
286 return ::DataBrowserChangeAttributes(this->GetControlRef(),attributes,~attributes);
287} /* wxMacDataBrowserTableViewControl::SetAttributes(OptionBits) */
c0a66d92 288
194027ac 289OSStatus wxMacDataBrowserTableViewControl::SetColumnWidth(DataBrowserPropertyID propertyID, UInt16 width)
c0a66d92 290{
194027ac 291 return ::SetDataBrowserTableViewNamedColumnWidth(this->m_controlRef,propertyID,width);
c0a66d92
RR
292}
293
194027ac 294OSStatus wxMacDataBrowserTableViewControl::SetDefaultColumnWidth(UInt16 width)
c0a66d92 295{
194027ac 296 return ::SetDataBrowserTableViewColumnWidth(this->m_controlRef,width);
c0a66d92
RR
297}
298
194027ac 299OSStatus wxMacDataBrowserTableViewControl::SetDefaultRowHeight(UInt16 height)
c0a66d92 300{
194027ac 301 return ::SetDataBrowserTableViewRowHeight(this->m_controlRef,height);
c0a66d92
RR
302}
303
c17b2e31 304OSStatus wxMacDataBrowserTableViewControl::SetHasScrollBars(bool horiz, bool vert)
c0a66d92 305{
c17b2e31
RR
306 return ::SetDataBrowserHasScrollBars(this->m_controlRef,horiz,vert);
307} /* wxMacDataBrowserTableViewControl::SetHasScrollBars(bool, bool) */
c0a66d92
RR
308
309OSStatus wxMacDataBrowserTableViewControl::SetHeaderButtonHeight(UInt16 height)
310{
c17b2e31
RR
311 return ::SetDataBrowserListViewHeaderBtnHeight(this->m_controlRef,height);
312} /* wxMacDataBrowserTableViewControl::SetHeaderButtonHeight(UInt16) */
c0a66d92 313
c17b2e31 314OSStatus wxMacDataBrowserTableViewControl::SetHiliteStyle(DataBrowserTableViewHiliteStyle hiliteStyle)
c0a66d92 315{
c17b2e31
RR
316 return ::SetDataBrowserTableViewHiliteStyle(this->m_controlRef,hiliteStyle);
317} /*wxMacDataBrowserTableViewControl::SetHiliteStyle(DataBrowserTableViewHiliteStyle) */
318
319OSStatus wxMacDataBrowserTableViewControl::SetIndent(float Indent)
320{
321 return ::DataBrowserSetMetric(this->m_controlRef,kDataBrowserMetricDisclosureColumnPerDepthGap,true,Indent);
322} /* wxMacDataBrowserTableViewControl::SetIndent(float* Indent) */
c0a66d92
RR
323
324OSStatus wxMacDataBrowserTableViewControl::SetRowHeight(DataBrowserItemID item, UInt16 height)
325{
326 return ::SetDataBrowserTableViewItemRowHeight(this->m_controlRef,item,height);
327}
328
329OSStatus wxMacDataBrowserTableViewControl::SetScrollPosition(UInt32 top, UInt32 left)
330{
331 return ::SetDataBrowserScrollPosition(this->m_controlRef,top,left);
332}
333
334//
335// column handling
336//
337OSStatus wxMacDataBrowserTableViewControl::GetColumnCount(UInt32* numColumns) const
338{
194027ac 339 return ::GetDataBrowserTableViewColumnCount(this->m_controlRef,numColumns);
c0a66d92
RR
340}
341
194027ac 342OSStatus wxMacDataBrowserTableViewControl::GetColumnIndex(DataBrowserPropertyID propertyID, DataBrowserTableViewColumnIndex* index) const
c0a66d92 343{
194027ac
RR
344 return ::GetDataBrowserTableViewColumnPosition(this->m_controlRef,propertyID,index);
345} /* wxMacDataBrowserTableViewControl::GetColumnIndex(DataBrowserPropertyID, DataBrowserTableViewColumnIndex*) const */
c0a66d92 346
194027ac 347OSStatus wxMacDataBrowserTableViewControl::GetFreePropertyID(DataBrowserPropertyID* propertyID) const
c0a66d92 348{
194027ac
RR
349 for (*propertyID=kMinPropertyID; *propertyID<std::numeric_limits<DataBrowserPropertyID>::max(); ++(*propertyID))
350 if (this->IsUsedPropertyID(*propertyID) == errDataBrowserPropertyNotFound)
c0a66d92
RR
351 return noErr;
352 return errDataBrowserPropertyNotSupported;
353} /* wxMacDataBrowserTableViewControl::GetFreePropertyID(DataBrowserPropertyID*) const */
354
194027ac 355OSStatus wxMacDataBrowserTableViewControl::GetPropertyFlags(DataBrowserPropertyID propertyID, DataBrowserPropertyFlags *flags) const
c0a66d92 356{
194027ac
RR
357 return ::GetDataBrowserPropertyFlags(this->m_controlRef,propertyID,flags);
358}
c0a66d92 359
07c51ff1
RR
360OSStatus wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserItemDataRef itemData, DataBrowserPropertyID* propertyID)
361{
362 return ::GetDataBrowserItemDataProperty(itemData,propertyID);
363} /* wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserItemDataRef, DataBrowserPropertyID*) */
364
194027ac 365OSStatus wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserTableViewColumnIndex index, DataBrowserTableViewColumnID* propertyID)
c0a66d92 366{
194027ac
RR
367 return ::GetDataBrowserTableViewColumnProperty(this->m_controlRef,index,propertyID);
368} /* wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserTableViewColumnIndex, DataBrowserTableViewColumnID*) */
c0a66d92
RR
369
370OSStatus wxMacDataBrowserTableViewControl::IsUsedPropertyID(DataBrowserPropertyID propertyID) const
371{
372 // 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
373 // 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
374 // the column position for the property id:
375 DataBrowserTableViewColumnIndex index;
99c75ebc 376
c0a66d92
RR
377 return ::GetDataBrowserTableViewColumnPosition(this->m_controlRef,propertyID,&index);
378} /* wxMacDataBrowserTableViewControl::IsUsedPropertyId(DataBrowserPropertyID) const */
379
c17b2e31
RR
380OSStatus wxMacDataBrowserTableViewControl::RemoveColumnByProperty(DataBrowserTableViewColumnID propertyID)
381{
382 return ::RemoveDataBrowserTableViewColumn(this->m_controlRef,propertyID);
383} /* wxMacDataBrowserTableViewControl::RemoveColumnByProperty(DataBrowserTableViewColumnID) */
384
385OSStatus wxMacDataBrowserTableViewControl::RemoveColumnByIndex(DataBrowserTableViewColumnIndex index)
c0a66d92 386{
194027ac 387 DataBrowserTableViewColumnID propertyID;
c0a66d92 388
c0a66d92 389
194027ac
RR
390 this->GetPropertyID(index,&propertyID);
391 return ::RemoveDataBrowserTableViewColumn(this->m_controlRef,propertyID);
c17b2e31 392} /* wxMacDataBrowserTableViewControl::RemoveColumnByIndex(DataBrowserTableViewColumnIndex) */
194027ac
RR
393
394OSStatus wxMacDataBrowserTableViewControl::SetColumnIndex(DataBrowserPropertyID propertyID, DataBrowserTableViewColumnIndex index)
c0a66d92 395{
194027ac
RR
396 return ::SetDataBrowserTableViewColumnPosition(this->m_controlRef,propertyID,index);
397} /* wxMacDataBrowserTableViewControl::SetColumnIndex(DataBrowserPropertyID, DataBrowserTableViewColumnIndex) */
c0a66d92 398
194027ac 399OSStatus wxMacDataBrowserTableViewControl::SetDisclosureColumn(DataBrowserPropertyID propertyID, Boolean expandableRows)
c0a66d92 400{
194027ac 401 return ::SetDataBrowserListViewDisclosureColumn(this->m_controlRef,propertyID,expandableRows);
c0a66d92
RR
402}
403
194027ac
RR
404OSStatus wxMacDataBrowserTableViewControl::SetPropertyFlags(DataBrowserPropertyID propertyID, DataBrowserPropertyFlags flags)
405{
406 return ::SetDataBrowserPropertyFlags(this->m_controlRef,propertyID,flags);
407} /* wxMacDataBrowserTableViewControl::SetPropertyFlags(DataBrowserPropertyID, DataBrowserPropertyFlags) */
408
c0a66d92
RR
409//
410// item handling
411//
412OSStatus wxMacDataBrowserTableViewControl::AddItems(DataBrowserItemID container, UInt32 numItems, DataBrowserItemID const* items, DataBrowserPropertyID preSortProperty)
413{
414 return ::AddDataBrowserItems(this->m_controlRef,container,numItems,items,preSortProperty);
415} /* wxMacDataBrowserTableViewControl::AddItems(DataBrowserItemID, UInt32, DataBrowserItemID const*, DataBrowserPropertyID) */
416
417OSStatus wxMacDataBrowserTableViewControl::GetFreeItemID(DataBrowserItemID* id) const
418{
419 ItemCount NoOfItems;
99c75ebc
RR
420
421 OSStatus status;
422
423
424 status = this->GetItemCount(&NoOfItems);
425 wxCHECK_MSG(status == noErr,status,_("Could not retrieve number of items"));
c0a66d92
RR
426 if (NoOfItems == 0)
427 {
428 *id = 1;
429 return noErr;
430 } /* if */
431 else
432 {
433 // 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
434 // as the number of items; therefore, start from the number of items to look for a new ID:
435 for (*id=NoOfItems; *id<std::numeric_limits<DataBrowserItemID>::max(); ++(*id))
436 if (this->IsUsedItemID(*id) == errDataBrowserItemNotFound)
437 return noErr;
438 // as the first approach was not successful, try from the beginning:
439 for (*id=0; *id<NoOfItems; ++(*id))
440 if (this->IsUsedItemID(*id) == errDataBrowserItemNotFound)
441 return noErr;
442 // sorry, data browser is full:
443 return errDataBrowserItemNotAdded;
444 } /* if */
445} /* wxMacDataBrowserTableViewControl::GetFreeItemID(DataBrowserItemID*) const */
446
447OSStatus wxMacDataBrowserTableViewControl::GetItemCount(DataBrowserItemID container, Boolean recurse, DataBrowserItemState state, ItemCount* numItems) const
448{
449 return GetDataBrowserItemCount(this->m_controlRef,container,recurse,state,numItems);
450} /* wxMacDataBrowserTableViewControl::GetItemCount(DataBrowserItemID, Boolean, DataBrowserItemState, ItemCount*) const */
451
452OSStatus wxMacDataBrowserTableViewControl::GetItemID( DataBrowserTableViewRowIndex row, DataBrowserItemID * item ) const
453{
454 return GetDataBrowserTableViewItemID(this->m_controlRef,row,item);
455}
456
457OSStatus wxMacDataBrowserTableViewControl::GetItems(DataBrowserItemID container, Boolean recurse, DataBrowserItemState state, Handle items) const
458{
459 return GetDataBrowserItems(this->m_controlRef,container,recurse,state,items);
460} /* wxMacDataBrowserTableViewControl::GetItems(DataBrowserItemID, Boolean, DataBrowserItemState, Handle) const */
461
462OSStatus wxMacDataBrowserTableViewControl::GetItemRow(DataBrowserItemID item, DataBrowserTableViewRowIndex* row) const
463{
464 return GetDataBrowserTableViewItemRow(this->m_controlRef,item,row);
465}
466
467OSStatus wxMacDataBrowserTableViewControl::IsUsedItemID(DataBrowserItemID itemID) const
468{
469 // 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
470 // 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
471 // the column position for the property id:
472 DataBrowserTableViewColumnIndex index;
99c75ebc 473
c0a66d92
RR
474 return ::GetDataBrowserTableViewItemRow(this->m_controlRef,itemID,&index);
475} /* wxMacDataBrowserTableViewControl::IsUsedItemID(DataBrowserItemID) const */
476
477OSStatus wxMacDataBrowserTableViewControl::RemoveItems(DataBrowserItemID container, UInt32 numItems, DataBrowserItemID const* items, DataBrowserPropertyID preSortProperty)
478{
479 return ::RemoveDataBrowserItems(this->m_controlRef,container,numItems,items,preSortProperty);
480}
481
482OSStatus wxMacDataBrowserTableViewControl::RevealItem(DataBrowserItemID item, DataBrowserPropertyID propertyID, DataBrowserRevealOptions options) const
483{
484 return ::RevealDataBrowserItem(this->m_controlRef,item,propertyID,options);
485} /* wxMacDataBrowserTableViewControl::RevealItem(DataBrowserItemID item, DataBrowserPropertyID propertyID, DataBrowserRevealOptions options) const */
486
487OSStatus wxMacDataBrowserTableViewControl::UpdateItems(DataBrowserItemID container, UInt32 numItems, DataBrowserItemID const* items, DataBrowserPropertyID preSortProperty,
488 DataBrowserPropertyID propertyID) const
489{
490 return UpdateDataBrowserItems(this->m_controlRef,container,numItems,items,preSortProperty,propertyID);
491}
492
493//
494// item selection
495//
496size_t wxMacDataBrowserTableViewControl::GetSelectedItemIDs(wxArrayDataBrowserItemID& itemIDs) const
497{
498 DataBrowserItemID* itemIDPtr;
499 Handle handle(::NewHandle(0));
99c75ebc 500
c0a66d92
RR
501 size_t NoOfItems;
502
503
504 wxCHECK_MSG(this->GetItems(kDataBrowserNoItem,true,kDataBrowserItemIsSelected,handle) == noErr,0,_("Could not get selected items."));
505 NoOfItems = static_cast<size_t>(::GetHandleSize(handle)/sizeof(DataBrowserItemID));
506 itemIDs.Empty();
507 itemIDs.Alloc(NoOfItems);
508 HLock(handle);
509 itemIDPtr = (DataBrowserItemID*) (*handle);
510 for (size_t i=0; i<NoOfItems; ++i)
511 {
512 itemIDs.Add(*itemIDPtr);
513 ++itemIDPtr;
514 } /* for */
515 HUnlock(handle);
516 DisposeHandle(handle);
517 return NoOfItems;
518} /* wxMacDataBrowserTableViewControl::GetSelectedItemIDs(wxArrayDataBrowserItemID&) const*/
519
194027ac 520OSStatus wxMacDataBrowserTableViewControl::GetSelectionAnchor(DataBrowserItemID* first, DataBrowserItemID* last) const
c0a66d92 521{
194027ac
RR
522 return ::GetDataBrowserSelectionAnchor(this->m_controlRef,first,last);
523} /* wxMacDataBrowserTableViewControl::GetSelectionAnchor(DataBrowserItemID*, DataBrowserItemID*) const */
c0a66d92
RR
524
525OSStatus wxMacDataBrowserTableViewControl::GetSelectionFlags(DataBrowserSelectionFlags* flags) const
526{
527 return ::GetDataBrowserSelectionFlags(this->m_controlRef,flags);
528} /* wxMacDataBrowserTableViewControl::GetSelectionFlags(DataBrowserSelectionFlags*) const */
529
530bool wxMacDataBrowserTableViewControl::IsItemSelected(DataBrowserItemID item) const
531{
532 return ::IsDataBrowserItemSelected(this->m_controlRef,item);
533} /* wxMacDataBrowserTableViewControl::IsItemSelected(DataBrowserItemID) const */
534
535OSStatus wxMacDataBrowserTableViewControl::SetSelectionFlags(DataBrowserSelectionFlags flags)
536{
537 return ::SetDataBrowserSelectionFlags(this->m_controlRef,flags);
538} /* wxMacDataBrowserTableViewControl::SetSelectionFlags(DataBrowserSelectionFlags) */
539
540OSStatus wxMacDataBrowserTableViewControl::SetSelectedItems(UInt32 numItems, DataBrowserItemID const* items, DataBrowserSetOption operation)
541{
194027ac 542 return ::SetDataBrowserSelectedItems(this->m_controlRef, numItems, items, operation );
c0a66d92
RR
543} /* wxMacDataBrowserTableViewControl::SetSelectedItems(UInt32, DataBrowserItemID const*, DataBrowserSetOption) */
544
07c51ff1 545OSStatus wxMacDataBrowserTableViewControl::GetSortOrder(DataBrowserSortOrder* order) const
c0a66d92 546{
07c51ff1 547 return ::GetDataBrowserSortOrder(this->m_controlRef,order);
c0a66d92
RR
548}
549
07c51ff1 550OSStatus wxMacDataBrowserTableViewControl::GetSortProperty(DataBrowserPropertyID* propertyID) const
c0a66d92 551{
07c51ff1 552 return ::GetDataBrowserSortProperty(this->m_controlRef,propertyID);
c0a66d92
RR
553}
554
07c51ff1 555OSStatus wxMacDataBrowserTableViewControl::Resort(DataBrowserItemID container, Boolean sortChildren)
c0a66d92 556{
07c51ff1
RR
557 return ::SortDataBrowserContainer(this->m_controlRef,container,sortChildren);
558} /* wxMacDataBrowserTableViewControl::Resort(DataBrowserItemID, Boolean) */
c0a66d92 559
194027ac 560OSStatus wxMacDataBrowserTableViewControl::SetSortOrder(DataBrowserSortOrder order)
c0a66d92 561{
194027ac 562 return ::SetDataBrowserSortOrder(this->m_controlRef,order);
c0a66d92
RR
563}
564
07c51ff1
RR
565OSStatus wxMacDataBrowserTableViewControl::SetSortProperty(DataBrowserPropertyID propertyID)
566{
567 return ::SetDataBrowserSortProperty(this->m_controlRef,propertyID);
568}
569
c17b2e31
RR
570//
571// container handling
572//
573OSStatus wxMacDataBrowserTableViewControl::CloseContainer(DataBrowserItemID containerID)
574{
575 return ::CloseDataBrowserContainer(this->m_controlRef,containerID);
576} /* wxMacDataBrowserTableViewControl::CloseContainer(DataBrowserItemID) */
577
578OSStatus wxMacDataBrowserTableViewControl::OpenContainer(DataBrowserItemID containerID)
579{
580 return ::OpenDataBrowserContainer(this->m_controlRef,containerID);
581} /* wxMacDataBrowserTableViewControl::OpenContainer(DataBrowserItemID) */
582
c0a66d92
RR
583IMPLEMENT_ABSTRACT_CLASS(wxMacDataBrowserTableViewControl,wxMacControl)
584
585// ============================================================================
194027ac 586// wxMacDataBrowserListViewControl
c0a66d92 587// ============================================================================
c0a66d92
RR
588#pragma mark -
589//
590// column handling
591//
592OSStatus wxMacDataBrowserListViewControl::AddColumn(DataBrowserListViewColumnDesc *columnDesc, DataBrowserTableViewColumnIndex position)
593{
594 return AddDataBrowserListViewColumn(this->m_controlRef,columnDesc,position);
595} /* wxMacDataBrowserListViewControl::AddColumn(DataBrowserListViewColumnDesc*, DataBrowserTableViewColumnIndex) */
596
597// ============================================================================
194027ac 598// wxMacDataViewDataBrowserListViewControl
c0a66d92 599// ============================================================================
c0a66d92
RR
600#pragma mark -
601//
602// constructors / destructor
603//
604wxMacDataViewDataBrowserListViewControl::wxMacDataViewDataBrowserListViewControl(wxWindow* peer, wxPoint const& pos, wxSize const& size, long style)
605 :wxMacDataBrowserListViewControl(peer,pos,size,style)
606{
607} /* wxMacDataViewDataBrowserListViewControl::wxMacDataViewDataBrowserListViewControl(wxWindow* , const wxPoint&, const wxSize&, long) */
608
609//
194027ac 610// callback functions (inherited from wxMacDataBrowserTableViewControl)
c0a66d92 611//
194027ac 612Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserCompareProc(DataBrowserItemID itemOneID, DataBrowserItemID itemTwoID, DataBrowserPropertyID sortProperty)
c0a66d92 613{
07c51ff1
RR
614 DataBrowserSortOrder sortOrder;
615
6edc7480 616 DataBrowserTableViewColumnIndex modelColumnIndex;
99c75ebc 617
194027ac 618 wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetPeer()));
99c75ebc 619
c0a66d92 620
194027ac
RR
621 wxCHECK_MSG(dataViewCtrlPtr != NULL, false,_("Pointer to data view control not set correctly."));
622 wxCHECK_MSG(dataViewCtrlPtr->GetModel() != NULL,false,_("Pointer to model not set correctly."));
623 if (sortProperty >= kMinPropertyID)
c0a66d92 624 {
6edc7480
RR
625 // variable definition and initialization:
626 wxDataViewColumn* ColumnPtr(dataViewCtrlPtr->GetColumnPtr(sortProperty));
627
628 wxCHECK_MSG(ColumnPtr != NULL,false,_("Could not determine column index."));
629 modelColumnIndex = ColumnPtr->GetModelColumn();
c0a66d92 630 } /* if */
07c51ff1 631 else
6edc7480 632 modelColumnIndex = 0;
07c51ff1
RR
633 this->GetSortOrder(&sortOrder);
634 return static_cast<Boolean>(dataViewCtrlPtr->GetModel()->Compare(wxDataViewItem(reinterpret_cast<void*>(itemOneID)),wxDataViewItem(reinterpret_cast<void*>(itemTwoID)),
6edc7480 635 modelColumnIndex,sortOrder != kDataBrowserOrderDecreasing) < 0);
c0a66d92
RR
636} /* wxMacDataViewDataBrowserListViewControl::DataBrowserCompareProc(DataBrowserItemID, DataBrowserItemID, DataBrowserPropertyID) */
637
99c75ebc
RR
638void wxMacDataViewDataBrowserListViewControl::DataBrowserGetContextualMenuProc(MenuRef* menu, UInt32* helpType, CFStringRef* helpItemString, AEDesc* WXUNUSED(selection))
639 // In this method we do not supply a contextual menu handler at all but only send a wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU.
c0a66d92 640{
99c75ebc 641 wxArrayDataBrowserItemID itemIDs;
c0a66d92 642
99c75ebc 643 wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetPeer()));
c0a66d92 644
350df6ae 645
99c75ebc
RR
646 wxCHECK_RET(dataViewCtrlPtr != NULL,_("wxWidget control pointer is not a data view pointer"));
647 // initialize parameters so that no context menu will be displayed automatically by the native data browser:
648 *menu = NULL;
649 *helpType = kCMHelpItemNoHelp;
650 *helpItemString = NULL;
651 // create information for a context menu event:
652 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU,dataViewCtrlPtr->GetId());
350df6ae 653
99c75ebc
RR
654 dataViewEvent.SetModel(dataViewCtrlPtr->GetModel());
655 // get the item information;
656 // theoretically more than one ID can be returned but the event can only handle one item, therefore all item related data is using the data of the first item in the array:
657 if (this->GetSelectedItemIDs(itemIDs) > 0)
658 dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemIDs[0])));
659 // finally send the equivalent wxWidget event:
660 dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
661} /* wxMacDataViewDataBrowserListViewControl::DataBrowserGetContextualMenuProc(MenuRef*, UInt32*, CFStringRef*, AEDesc*) */
c0a66d92 662
194027ac 663OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, DataBrowserItemDataRef itemData, Boolean getValue)
c0a66d92
RR
664{
665 if (getValue)
666 {
194027ac 667 // variable definitions:
07c51ff1 668 wxDataViewCtrl* dataViewCtrlPtr;
99c75ebc 669
c0a66d92 670 dataViewCtrlPtr = dynamic_cast<wxDataViewCtrl*>(this->GetPeer());
07c51ff1
RR
671 wxCHECK_MSG(dataViewCtrlPtr != NULL,errDataBrowserNotConfigured,_("Pointer to data view control not set correctly."));
672 if (dataViewCtrlPtr->IsDeleting())
673 return noErr; // if a delete process is running the data of editable fields cannot be saved because the associated model variable may already have been deleted
674 else
c0a66d92 675 {
07c51ff1 676 // variable definitions:
6edc7480
RR
677 OSStatus errorStatus;
678 wxDataViewColumn* dataViewColumnPtr;
99c75ebc 679
07c51ff1 680 wxCHECK_MSG(dataViewCtrlPtr->GetModel() != NULL,errDataBrowserNotConfigured,_("Pointer to model not set correctly."));
6edc7480 681 dataViewColumnPtr = dataViewCtrlPtr->GetColumnPtr(propertyID);
07c51ff1 682 wxCHECK_MSG((dataViewColumnPtr != NULL) && (dataViewColumnPtr->GetRenderer() != NULL),errDataBrowserNotConfigured,_("There is no column or renderer for the specified column index."));
17792930
RD
683
684 wxDataViewItem dvItem(reinterpret_cast<void*>(itemID));
685 unsigned int col = dataViewColumnPtr->GetModelColumn();
686
07c51ff1
RR
687 switch (dataViewColumnPtr->GetRenderer()->GetPropertyType())
688 {
689 case kDataBrowserCheckboxType:
c0a66d92 690 {
07c51ff1
RR
691 // variable definition:
692 ThemeButtonValue buttonValue;
c0a66d92 693
07c51ff1
RR
694 errorStatus = ::GetDataBrowserItemDataButtonValue(itemData,&buttonValue);
695 if (errorStatus == noErr)
c0a66d92 696 {
07c51ff1
RR
697 if (buttonValue == kThemeButtonOn)
698 {
699 // variable definition and initialization:
700 wxVariant modifiedData(true);
701
17792930
RD
702 if (dataViewCtrlPtr->GetModel()->SetValue(modifiedData, dvItem, col))
703 {
704 dataViewCtrlPtr->GetModel()->ValueChanged(dvItem, col);
705 return noErr;
706 }
707 else
708 return errDataBrowserNotConfigured;
07c51ff1
RR
709 } /* if */
710 else if (buttonValue == kThemeButtonOff)
711 {
712 // variable definition and initialization:
713 wxVariant modifiedData(false);
714
17792930
RD
715 if (dataViewCtrlPtr->GetModel()->SetValue(modifiedData, dvItem, col))
716 {
717 dataViewCtrlPtr->GetModel()->ValueChanged(dvItem, col);
718 return noErr;
719 }
720 else
721 return errDataBrowserNotConfigured;
07c51ff1
RR
722 } /* if */
723 else
724 return errDataBrowserInvalidPropertyData;
c0a66d92
RR
725 } /* if */
726 else
07c51ff1
RR
727 return errorStatus;
728 } /* block */
729 case kDataBrowserTextType:
c0a66d92 730 {
07c51ff1
RR
731 // variable definitions:
732 CFStringRef stringReference;
c0a66d92 733
07c51ff1
RR
734 errorStatus = ::GetDataBrowserItemDataText(itemData,&stringReference);
735 if (errorStatus == noErr)
736 {
737 // variable definitions and initializations:
99c75ebc 738#if wxCHECK_VERSION(2,9,0)
dbe4a80c 739 wxCFStringRef modifiedString(stringReference);
99c75ebc
RR
740#else
741 wxMacCFStringHolder modifiedString(stringReference);
742#endif
07c51ff1 743 wxVariant modifiedData(modifiedString.AsString());
17792930
RD
744
745 if (dataViewCtrlPtr->GetModel()->SetValue(modifiedData, dvItem, col))
746 {
747 dataViewCtrlPtr->GetModel()->ValueChanged(dvItem, col);
748 return noErr;
749 }
07c51ff1
RR
750 else
751 return errDataBrowserNotConfigured;
752 } /* if */
c0a66d92 753 else
07c51ff1
RR
754 return errorStatus;
755 } /* block */
756 default:
757 return errDataBrowserPropertyNotSupported;
758 } /* switch */
759 } /* if */
c0a66d92
RR
760 } /* if */
761 else
762 {
07c51ff1 763 if (propertyID >= kMinPropertyID) // in case data columns set the data
c0a66d92
RR
764 {
765 // variable definitions:
c17b2e31
RR
766 wxVariant variant;
767 wxDataViewColumn* dataViewColumnPtr;
768 wxDataViewCtrl* dataViewCtrlPtr;
99c75ebc 769
194027ac
RR
770 dataViewCtrlPtr = dynamic_cast<wxDataViewCtrl*>(this->GetPeer());
771 wxCHECK_MSG(dataViewCtrlPtr != NULL,errDataBrowserNotConfigured,_("Pointer to data view control not set correctly."));
772 wxCHECK_MSG(dataViewCtrlPtr->GetModel() != NULL,errDataBrowserNotConfigured,_("Pointer to model not set correctly."));
c17b2e31 773 dataViewColumnPtr = dataViewCtrlPtr->GetColumnPtr(propertyID);
194027ac 774 wxCHECK_MSG(dataViewColumnPtr != NULL,errDataBrowserNotConfigured,_("No column for the specified column position existing."));
c0a66d92 775 wxCHECK_MSG(dataViewColumnPtr->GetRenderer() != NULL,errDataBrowserNotConfigured,_("No renderer specified for column."));
194027ac 776 dataViewCtrlPtr->GetModel()->GetValue(variant,wxDataViewItem(reinterpret_cast<void*>(itemID)),dataViewColumnPtr->GetModelColumn());
c17b2e31
RR
777 if (!(variant.IsNull()))
778 {
779 dataViewColumnPtr->GetRenderer()->SetDataReference(itemData);
780 dataViewColumnPtr->GetRenderer()->SetValue(variant);
781 wxCHECK_MSG(dataViewColumnPtr->GetRenderer()->Render(),errDataBrowserNotConfigured,_("Rendering failed."));
782 } /* if */
07c51ff1 783 return noErr;
c0a66d92
RR
784 } /* if */
785 else // react on special system requests
c17b2e31 786 {
194027ac 787 switch (propertyID)
c0a66d92 788 {
07c51ff1
RR
789 case kDataBrowserContainerIsClosableProperty:
790 {
791 // variable definitions:
792 wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetPeer()));
99c75ebc 793
07c51ff1
RR
794 wxCHECK_MSG(dataViewCtrlPtr != NULL,errDataBrowserNotConfigured,_("Pointer to data view control not set correctly."));
795 // initialize wxWidget event:
796 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING,dataViewCtrlPtr->GetId()); // variable definition
99c75ebc 797
07c51ff1 798 dataViewEvent.SetEventObject(dataViewCtrlPtr);
99c75ebc
RR
799 dataViewEvent.SetItem (wxDataViewItem(reinterpret_cast<void*>(itemID)));
800 dataViewEvent.SetModel (dataViewCtrlPtr->GetModel());
07c51ff1 801 // finally send the equivalent wxWidget event:
99c75ebc 802 dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
07c51ff1
RR
803 // opening the container is allowed if not vetoed:
804 return ::SetDataBrowserItemDataBooleanValue(itemData,dataViewEvent.IsAllowed());
805 } /* block */
07c51ff1
RR
806 case kDataBrowserContainerIsOpenableProperty:
807 {
808 // variable definitions:
809 wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetPeer()));
99c75ebc 810
07c51ff1
RR
811 wxCHECK_MSG(dataViewCtrlPtr != NULL,errDataBrowserNotConfigured,_("Pointer to data view control not set correctly."));
812 // initialize wxWidget event:
813 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING,dataViewCtrlPtr->GetId()); // variable definition
6e1609b1 814
07c51ff1 815 dataViewEvent.SetEventObject(dataViewCtrlPtr);
99c75ebc
RR
816 dataViewEvent.SetItem (wxDataViewItem(reinterpret_cast<void*>(itemID)));
817 dataViewEvent.SetModel (dataViewCtrlPtr->GetModel());
07c51ff1 818 // finally send the equivalent wxWidget event:
99c75ebc 819 dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
07c51ff1
RR
820 // opening the container is allowed if not vetoed:
821 return ::SetDataBrowserItemDataBooleanValue(itemData,dataViewEvent.IsAllowed());
822 } /* block */
c0a66d92 823 case kDataBrowserItemIsContainerProperty:
194027ac
RR
824 {
825 // variable definition:
826 wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetPeer()));
99c75ebc 827
194027ac
RR
828 wxCHECK_MSG(dataViewCtrlPtr != NULL,errDataBrowserNotConfigured,_("Pointer to data view control not set correctly."));
829 wxCHECK_MSG(dataViewCtrlPtr->GetModel() != NULL,errDataBrowserNotConfigured,_("Pointer to model not set correctly."));
830 return ::SetDataBrowserItemDataBooleanValue(itemData,dataViewCtrlPtr->GetModel()->IsContainer(wxDataViewItem(reinterpret_cast<void*>(itemID))));
831 } /* block */
c0a66d92
RR
832 case kDataBrowserItemIsEditableProperty:
833 return ::SetDataBrowserItemDataBooleanValue(itemData,true);
834 } /* switch */
c17b2e31 835 } /* if */
c0a66d92
RR
836 } /* if */
837 return errDataBrowserPropertyNotSupported;
838} /* wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemDataRef, Boolean) */
839
c17b2e31 840void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(DataBrowserItemID itemID, DataBrowserItemNotification message, DataBrowserItemDataRef itemData)
c0a66d92 841{
a5fb9253
RR
842 wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetPeer()));
843
844
845 // 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:
846 if (dataViewCtrlPtr != NULL)
847 switch (message)
848 {
849 case kDataBrowserContainerClosed:
99c75ebc 850 dataViewCtrlPtr->FinishCustomItemEditing(); // stop editing of a custom item first (if necessary)
07c51ff1
RR
851 {
852 // initialize wxWidget event:
853 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED,dataViewCtrlPtr->GetId()); // variable definition
99c75ebc 854
07c51ff1
RR
855 dataViewEvent.SetEventObject(dataViewCtrlPtr);
856 dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID)));
857 // finally send the equivalent wxWidget event:
99c75ebc 858 dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
a5fb9253
RR
859 } /* block */
860 break;
861 case kDataBrowserContainerOpened:
99c75ebc 862 dataViewCtrlPtr->FinishCustomItemEditing(); // stop editing of a custom item first (if necessary)
a5fb9253
RR
863 {
864 // initialize wxWidget event:
865 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED,dataViewCtrlPtr->GetId()); // variable definition
99c75ebc 866
a5fb9253
RR
867 dataViewEvent.SetEventObject(dataViewCtrlPtr);
868 dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID)));
869 // finally send the equivalent wxWidget event:
99c75ebc 870 dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
a5fb9253
RR
871 // add children to the expanded container:
872 dataViewCtrlPtr->AddChildrenLevel(wxDataViewItem(reinterpret_cast<void*>(itemID)));
873 } /* block */
874 break;
875 case kDataBrowserEditStarted:
99c75ebc 876 dataViewCtrlPtr->FinishCustomItemEditing(); // stop editing of a custom item first (if necessary)
c17b2e31
RR
877 {
878 // initialize wxWidget event:
99c75ebc 879 DataBrowserPropertyID propertyID;
c17b2e31 880 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED,dataViewCtrlPtr->GetId()); // variable definition
99c75ebc 881
c17b2e31
RR
882 dataViewEvent.SetEventObject(dataViewCtrlPtr);
883 dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID)));
884 if (this->GetPropertyID(itemData,&propertyID) == noErr)
885 {
886 // variable definition and initialization:
887 DataBrowserTableViewColumnIndex columnIndex;
99c75ebc 888
c17b2e31
RR
889 wxCHECK_RET(this->GetColumnIndex(propertyID,&columnIndex),_("Column index not found."));
890 dataViewEvent.SetColumn(columnIndex);
99c75ebc 891 dataViewEvent.SetDataViewColumn(dataViewCtrlPtr->GetColumnPtr(propertyID));
c17b2e31
RR
892 } /* if */
893 // finally send the equivalent wxWidget event:
99c75ebc 894 dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
a5fb9253
RR
895 } /* block */
896 break;
897 case kDataBrowserEditStopped:
07c51ff1
RR
898 {
899 // initialize wxWidget event:
99c75ebc 900 DataBrowserPropertyID propertyID;
a5fb9253 901 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE,dataViewCtrlPtr->GetId()); // variable definition
99c75ebc 902
07c51ff1
RR
903 dataViewEvent.SetEventObject(dataViewCtrlPtr);
904 dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID)));
a5fb9253
RR
905 if (this->GetPropertyID(itemData,&propertyID) == noErr)
906 {
907 // variable definition and initialization:
908 DataBrowserTableViewColumnIndex columnIndex;
909
910 wxCHECK_RET(this->GetColumnIndex(propertyID,&columnIndex),_("Column index not found."));
911 dataViewEvent.SetColumn(columnIndex);
99c75ebc 912 dataViewEvent.SetDataViewColumn(dataViewCtrlPtr->GetColumnPtr(propertyID));
a5fb9253 913 } /* if */
07c51ff1 914 // finally send the equivalent wxWidget event:
99c75ebc 915 dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
a5fb9253
RR
916 } /* block */
917 break;
918 case kDataBrowserItemAdded:
99c75ebc
RR
919 dataViewCtrlPtr->FinishCustomItemEditing();
920 break;
a5fb9253 921 case kDataBrowserItemDeselected:
99c75ebc
RR
922 dataViewCtrlPtr->FinishCustomItemEditing();
923 break;
a5fb9253
RR
924 case kDataBrowserItemDoubleClicked:
925 {
926 // initialize wxWidget event:
927 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED,dataViewCtrlPtr->GetId()); // variable definition
6d9ecc87 928
a5fb9253
RR
929 dataViewEvent.SetEventObject(dataViewCtrlPtr);
930 dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID)));
931 // finally send the equivalent wxWidget event:
99c75ebc 932 dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
a5fb9253
RR
933 } /* block */
934 break;
935 case kDataBrowserItemRemoved:
99c75ebc
RR
936 dataViewCtrlPtr->FinishCustomItemEditing(); // stop editing of a custom item first (if necessary)
937 break;
a5fb9253
RR
938 case kDataBrowserItemSelected:
939 break; // not implemented by wxWidgets; see kDataBrowserSelectionSetChanged
940 case kDataBrowserSelectionSetChanged:
6d9ecc87 941 {
a5fb9253
RR
942 // initialize wxWidget event:
943 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED,dataViewCtrlPtr->GetId()); // variable definition
944
945 dataViewEvent.SetEventObject(dataViewCtrlPtr);
946 dataViewEvent.SetModel (dataViewCtrlPtr->GetModel());
947 // finally send the equivalent wxWidget event:
99c75ebc 948 dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
a5fb9253
RR
949 } /* block */
950 break;
99c75ebc
RR
951 case kDataBrowserTargetChanged: // no idea if this notification is ever sent
952 break;
a5fb9253 953 case kDataBrowserUserStateChanged:
c0a66d92 954 {
99c75ebc
RR
955 // finish custom item editing if necessary:
956 dataViewCtrlPtr->FinishCustomItemEditing();
a5fb9253
RR
957 // update column widths:
958 for (size_t i=0; i<dataViewCtrlPtr->GetColumnCount(); ++i)
c0a66d92 959 {
a5fb9253
RR
960 // constant definition for abbreviational purposes:
961 wxDataViewColumn* const columnPtr = dataViewCtrlPtr->GetColumn(i);
962 // variable definition:
963 UInt16 columnWidth;
99c75ebc 964
a5fb9253
RR
965 wxCHECK_RET(this->GetColumnWidth(columnPtr->GetPropertyID(),&columnWidth) == noErr,_("Column width could not be determined"));
966 columnPtr->SetWidthVariable(columnWidth);
967 } /* for */
99c75ebc 968 // update sorting orders:
a5fb9253
RR
969 DataBrowserPropertyID propertyID; // variable definition
970
971 if ((this->GetSortProperty(&propertyID) == noErr) && (propertyID >= kMinPropertyID))
972 {
973 DataBrowserSortOrder sortOrder;
974 DataBrowserTableViewColumnIndex columnIndex;
99c75ebc 975
a5fb9253 976 if ((this->GetSortOrder(&sortOrder) == noErr) && (this->GetColumnIndex(propertyID,&columnIndex) == noErr))
c0a66d92 977 {
a5fb9253
RR
978 // variable definition and initialization:
979 wxDataViewColumn* columnPtr;
980 columnPtr = dataViewCtrlPtr->GetColumn(columnIndex);
981 // check if the sort order has changed:
982 if ( columnPtr->IsSortOrderAscending() && (sortOrder == kDataBrowserOrderDecreasing) ||
983 !(columnPtr->IsSortOrderAscending()) && (sortOrder == kDataBrowserOrderIncreasing))
984 {
985 columnPtr->SetSortOrder(!(columnPtr->IsSortOrderAscending()));
986 // initialize wxWidget event:
987 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED,dataViewCtrlPtr->GetId()); // variable defintion
988
989 dataViewEvent.SetEventObject(dataViewCtrlPtr);
990 dataViewEvent.SetColumn(columnIndex);
991 dataViewEvent.SetDataViewColumn(columnPtr);
992 // finally send the equivalent wxWidget event:
99c75ebc 993 dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
a5fb9253 994 } /* if */
c0a66d92
RR
995 } /* if */
996 } /* if */
a5fb9253
RR
997 } /* block */
998 break;
999 } /* switch */
c0a66d92
RR
1000} /* wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(DataBrowserItemID, DataBrowserItemNotification, DataBrowserItemDataRef) */
1001
99c75ebc
RR
1002void wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, DataBrowserItemState state, Rect const* rectangle, SInt16 bitDepth, Boolean colorDevice)
1003{
360b068c
RR
1004 DataBrowserTableViewColumnIndex columnIndex;
1005
99c75ebc
RR
1006 wxDataViewColumn* dataViewColumnPtr;
1007
1008 wxDataViewCtrl* dataViewCtrlPtr;
1009
1010 wxDataViewCustomRenderer* dataViewCustomRendererPtr;
1011
1012 wxVariant dataToRender;
1013
99c75ebc
RR
1014 dataViewCtrlPtr = dynamic_cast<wxDataViewCtrl*>(this->GetPeer());
1015 wxCHECK_RET(dataViewCtrlPtr != NULL, _("Pointer to data view control not set correctly."));
1016 wxCHECK_RET(dataViewCtrlPtr->GetModel() != NULL,_("Pointer to model not set correctly."));
360b068c 1017 wxCHECK_RET(this->GetColumnIndex(propertyID,&columnIndex) == noErr,_("Could not determine column index."));
99c75ebc
RR
1018 dataViewColumnPtr = dataViewCtrlPtr->GetColumnPtr(propertyID);
1019 wxCHECK_RET(dataViewColumnPtr != NULL,_("No column for the specified column index existing."));
1020 dataViewCustomRendererPtr = dynamic_cast<wxDataViewCustomRenderer*>(dataViewColumnPtr->GetRenderer());
1021 wxCHECK_RET(dataViewCustomRendererPtr != NULL,_("No renderer or invalid renderer type specified for custom data column."));
1022 dataViewCtrlPtr->GetModel()->GetValue(dataToRender,wxDataViewItem(reinterpret_cast<void*>(itemID)),dataViewColumnPtr->GetModelColumn());
1023 dataViewCustomRendererPtr->SetValue(dataToRender);
1024
360b068c
RR
1025 wxDataViewItem dataitem( reinterpret_cast<void*>(itemID) );
1026 dataViewCtrlPtr->GetModel()->GetValue(dataToRender,dataitem,columnIndex);
1027 dataViewCustomRendererPtr->SetValue(dataToRender);
1028
99c75ebc
RR
1029 // try to determine the content's size (drawable part):
1030 Rect content;
1031 RgnHandle rgn(NewRgn());
1032 UInt16 headerHeight;
1033
1034 if (this->GetRegion(kControlContentMetaPart,rgn) == noErr)
1035 GetRegionBounds(rgn,&content);
1036 else
1037 this->GetRect(&content);
1038 ::DisposeRgn(rgn);
1039 // space for the header
1040 this->GetHeaderButtonHeight(&headerHeight);
1041 content.top += headerHeight;
1042 // extra space for the frame (todo: do not how to determine the space automatically from the control)
1043 content.top += 5;
1044 content.left += 5;
1045 content.right -= 3;
1046 content.bottom -= 3;
360b068c 1047 // extra space for the scrollbars:
99c75ebc
RR
1048 content.bottom -= wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y);
1049 content.right -= wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
1050
360b068c
RR
1051 wxDC *dc = dataViewCustomRendererPtr->GetDC();
1052
1053 wxRect cellrect( static_cast<int>(rectangle->left),
1054 static_cast<int>(rectangle->top+2),
1055 static_cast<int>(1+rectangle->right-rectangle->left),
1056 static_cast<int>(rectangle->bottom-rectangle->top) );
1057
1058 bool is_active = IsControlActive( this->m_controlRef );
1059 if (state == kDataBrowserItemIsSelected)
1060 {
1061
1062 wxColour col( wxMacCreateCGColorFromHITheme( (is_active) ?
1063 kThemeBrushAlternatePrimaryHighlightColor
1064 : kThemeBrushSecondaryHighlightColor ) );
1065
1066 wxRect rect = cellrect;
1067 Rect itemrect;
1068 GetDataBrowserItemPartBounds( this->m_controlRef, itemID, propertyID,
1069 kDataBrowserPropertyEnclosingPart, &itemrect );
1070 rect.x = itemrect.left;
1071 rect.width = itemrect.right-itemrect.left+1;
1072
1073 wxBrush selBrush( col );
1074 wxPen oldpen( dc->GetPen() );
1075 wxBrush oldbrush( dc->GetBrush() );
1076 dc->SetPen( *wxTRANSPARENT_PEN );
1077 dc->SetBrush( selBrush );
1078 dc->DrawRectangle(rect);
1079 dc->SetBrush( oldbrush );
1080 dc->SetPen( oldpen );
1081 }
1082
1083 wxDataViewModel *model = dataViewCtrlPtr->GetModel();
1084 if ((columnIndex == 0) || !model->IsContainer(dataitem) || model->HasContainerColumns(dataitem))
1085 {
1086 // make sure that 'Render' can draw only in the allowed area:
1087 dc->SetClippingRegion(content.left,content.top,content.right-content.left+1,content.bottom-content.top+1);
1088 (void) (dataViewCustomRendererPtr->Render( cellrect, dc,
1089 ((state == kDataBrowserItemIsSelected) ? wxDATAVIEW_CELL_SELECTED : 0)));
1090 dc->DestroyClippingRegion(); // probably not necessary
1091 }
1092
1093 dataViewCustomRendererPtr->SetDC(NULL);
99c75ebc
RR
1094} /* wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemState, Rect const*, SInt16, Boolean) */
1095
1096Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserEditItemProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, CFStringRef theString, Rect* maxEditTextRect, Boolean* shrinkToFit)
1097{
1098 return false;
1099} /* wxMacDataViewDataBrowserListViewControl::DataBrowserEditItemProc(DataBrowserItemID, DataBrowserPropertyID, CFStringRef, Rect*, Boolean*) */
1100
1101Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserHitTestProc(DataBrowserItemID WXUNUSED(itemID), DataBrowserPropertyID WXUNUSED(property), Rect const* WXUNUSED(theRect), Rect const* WXUNUSED(mouseRect))
1102{
1103 return true;
1104} /* wxMacDataViewDataBrowserListViewControl::DataBrowserHitTestProc(DataBrowserItemID, DataBrowserPropertyID, Rect const*, Rect const*) */
1105
1106DataBrowserTrackingResult wxMacDataViewDataBrowserListViewControl::DataBrowserTrackingProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, Rect const* theRect, Point WXUNUSED(startPt), EventModifiers WXUNUSED(modifiers))
1107{
1108 wxDataViewColumn* dataViewColumnPtr;
1109
1110 wxDataViewCtrl* dataViewCtrlPtr;
1111
1112 wxDataViewCustomRenderer* dataViewCustomRendererPtr;
1113
1114 wxDataViewItem dataViewCustomRendererItem;
1115
1116
1117 dataViewCustomRendererItem = reinterpret_cast<void*>(itemID);
1118 wxCHECK_MSG(dataViewCustomRendererItem.IsOk(),kDataBrowserNothingHit,_("Invalid data view item"));
1119 dataViewCtrlPtr = dynamic_cast<wxDataViewCtrl*>(this->GetPeer());
1120 wxCHECK_MSG(dataViewCtrlPtr != NULL,kDataBrowserNothingHit,_("Pointer to data view control not set correctly."));
1121 dataViewColumnPtr = dataViewCtrlPtr->GetColumnPtr(propertyID);
1122 wxCHECK_MSG(dataViewColumnPtr != NULL,kDataBrowserNothingHit,_("No column existing."));
1123 dataViewCustomRendererPtr = dynamic_cast<wxDataViewCustomRenderer*>(dataViewColumnPtr->GetRenderer());
1124 wxCHECK_MSG(dataViewCustomRendererPtr != NULL,kDataBrowserNothingHit,_("No renderer or invalid renderer type specified for custom data column."));
1125 // if the currently edited item is identical to the to be edited nothing is done (this hit should only be handled in the control itself):
1126 if (dataViewCtrlPtr->GetCustomRendererItem() == dataViewCustomRendererItem)
1127 return kDataBrowserContentHit;
1128 // an(other) item is going to be edited and therefore the current editing - if existing - has to be finished:
1129 if (dataViewCtrlPtr->GetCustomRendererPtr() != NULL)
1130 {
1131 dataViewCtrlPtr->GetCustomRendererPtr()->FinishEditing();
1132 dataViewCtrlPtr->SetCustomRendererItem(wxDataViewItem());
1133 dataViewCtrlPtr->SetCustomRendererPtr (NULL);
1134 } /* if */
1135 // check if renderer has got a valid editor control for editing; if this is the case start editing of the new item:
1136 if (dataViewCustomRendererPtr->HasEditorCtrl())
1137 {
1138 // variable definition:
1139 wxRect wxRectangle;
1140
1141 ::wxMacNativeToRect(theRect,&wxRectangle);
1142 dataViewCustomRendererPtr->StartEditing(dataViewCustomRendererItem,wxRectangle);
1143 dataViewCtrlPtr->SetCustomRendererItem(dataViewCustomRendererItem);
1144 dataViewCtrlPtr->SetCustomRendererPtr (dataViewCustomRendererPtr);
1145 } /* if */
1146 return kDataBrowserContentHit;
1147} /* wxMacDataViewDataBrowserListViewControl::DataBrowserTrackingProc(DataBrowserItemID, DataBrowserPropertyID, Rect const*, Point, EventModifiers) */
c0a66d92 1148
99c75ebc 1149#endif // wxUSE_GENERICDATAVIEWCTRL
7fc2ce00 1150#endif // wxUSE_DATAVIEWCTRL