]> git.saurik.com Git - wxWidgets.git/blob - src/osx/carbon/dataview.cpp
Fix hangups when using sockets under OS X.
[wxWidgets.git] / src / osx / carbon / dataview.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/carbon/dataview.cpp
3 // Purpose: wxDataViewCtrl native carbon implementation
4 // Author:
5 // Id: $Id: dataview.cpp 58317 2009-01-23
6 // Copyright: (c) 2009
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
12
13 #if (wxUSE_DATAVIEWCTRL == 1) && !defined(wxUSE_GENERICDATAVIEWCTRL)
14
15 #ifndef WX_PRECOMP
16 #include "wx/app.h"
17 #include "wx/toplevel.h"
18 #include "wx/font.h"
19 #include "wx/settings.h"
20 #include "wx/utils.h"
21 #endif
22
23 #include "wx/osx/carbon/dataview.h"
24 #include "wx/osx/private.h"
25 #include "wx/osx/uma.h"
26 #include "wx/renderer.h"
27
28 #include <limits>
29
30 // ============================================================================
31 // Variables used locally in dataview.cpp
32 // ============================================================================
33 static DataBrowserGetContextualMenuUPP gDataBrowserTableViewGetContextualMenuUPP = NULL;
34 static DataBrowserItemCompareUPP gDataBrowserTableViewItemCompareUPP = NULL;
35 static DataBrowserItemDataUPP gDataBrowserTableViewItemDataUPP = NULL;
36 static DataBrowserItemNotificationUPP gDataBrowserTableViewItemNotificationUPP = NULL;
37
38 static DataBrowserAcceptDragUPP gDataBrowserTableViewAcceptDragUPP = NULL;
39 static DataBrowserAddDragItemUPP gDataBrowserTableViewAddDragItemUPP = NULL;
40 static DataBrowserReceiveDragUPP gDataBrowserTableViewReceiveDragUPP = NULL;
41
42 static DataBrowserDrawItemUPP gDataBrowserTableViewDrawItemUPP = NULL;
43 static DataBrowserEditItemUPP gDataBrowserTableViewEditItemUPP = NULL;
44 static DataBrowserHitTestUPP gDataBrowserTableViewHitTestUPP = NULL;
45 static DataBrowserTrackingUPP gDataBrowserTableViewTrackingUPP = NULL;
46
47 // ============================================================================
48 // Functions used locally in dataview.cpp
49 // ============================================================================
50 static DataBrowserItemID* CreateDataBrowserItemIDArray(size_t& noOfEntries, wxDataViewItemArray const& items) // returns a newly allocated pointer to valid data browser item IDs
51 {
52 size_t const noOfItems = items.GetCount();
53
54 DataBrowserItemID* itemIDs(new DataBrowserItemID[noOfItems]);
55
56
57 // convert all valid data view items to data browser items
58 noOfEntries = 0;
59 for (size_t i=0; i<noOfItems; ++i)
60 if (items[i].IsOk())
61 {
62 itemIDs[noOfEntries] = reinterpret_cast<DataBrowserItemID>(items[i].GetID());
63 ++noOfEntries;
64 }
65 // done:
66 return itemIDs;
67 }
68
69 static const EventTypeSpec eventList[] =
70 {
71 { kEventClassControl, kEventControlHit },
72 { kEventClassControl, kEventControlDraw }
73 };
74
75 static pascal OSStatus DataBrowserCtrlEventHandler(EventHandlerCallRef handler, EventRef EventReference, void* Data)
76 {
77 wxDataViewCtrl* DataViewCtrlPtr((wxDataViewCtrl*) Data); // the 'Data' variable always contains a pointer to the data view control that installed the handler
78
79 wxMacCarbonEvent CarbonEvent(EventReference) ;
80
81
82 switch (GetEventKind(EventReference))
83 {
84 case kEventControlDraw:
85 {
86 OSStatus status;
87
88 DataViewCtrlPtr->MacSetDrawingContext(CarbonEvent.GetParameter<CGContextRef>(kEventParamCGContextRef,typeCGContextRef));
89 status = ::CallNextEventHandler(handler,EventReference);
90 DataViewCtrlPtr->MacSetDrawingContext(NULL);
91 return status;
92 }
93 case kEventControlHit :
94 if (CarbonEvent.GetParameter<ControlPartCode>(kEventParamControlPart,typeControlPartCode) == kControlButtonPart) // we only care about the header
95 {
96 ControlRef controlReference;
97 DataBrowserPropertyID columnPropertyID;
98 DataBrowserSortOrder order;
99 unsigned long columnIndex;
100 wxDataViewColumn* column;
101 OSStatus status;
102 wxDataViewEvent DataViewEvent(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK,DataViewCtrlPtr->GetId());
103
104 CarbonEvent.GetParameter(kEventParamDirectObject,&controlReference);
105 // determine the column that triggered the event (this is the column that is responsible for sorting the data view):
106 status = ::GetDataBrowserSortProperty(controlReference,&columnPropertyID);
107 wxCHECK(status == noErr,status);
108 status = ::GetDataBrowserTableViewColumnPosition(controlReference,columnPropertyID,&columnIndex);
109 if (status == errDataBrowserPropertyNotFound) // user clicked into part of the header that does not have a property
110 return ::CallNextEventHandler(handler,EventReference);
111 wxCHECK(status == noErr,status);
112 column = DataViewCtrlPtr->GetColumn(columnIndex);
113 // set the column sort order:
114 status = ::GetDataBrowserSortOrder(controlReference,&order);
115 wxCHECK(status == noErr,status);
116 column->SetSortOrderVariable(order == kDataBrowserOrderIncreasing);
117 // initialize wxWidget event handler:
118 DataViewEvent.SetEventObject(DataViewCtrlPtr);
119 DataViewEvent.SetColumn(columnIndex);
120 DataViewEvent.SetDataViewColumn(column);
121 // finally sent the equivalent wxWidget event:
122 DataViewCtrlPtr->HandleWindowEvent(DataViewEvent);
123 return ::CallNextEventHandler(handler,EventReference);
124 }
125 else
126 return eventNotHandledErr;
127 }
128 return eventNotHandledErr;
129 }
130
131 static bool InitializeColumnDescription(DataBrowserListViewColumnDesc& columnDescription, wxDataViewColumn const* columnPtr, wxCFStringRef const& title)
132 {
133 // set properties for the column:
134 columnDescription.propertyDesc.propertyID = columnPtr->GetNativeData()->GetPropertyID();
135 columnDescription.propertyDesc.propertyType = columnPtr->GetRenderer()->GetNativeData()->GetPropertyType();
136 columnDescription.propertyDesc.propertyFlags = kDataBrowserListViewSelectionColumn; // make the column selectable
137 if (columnPtr->IsReorderable())
138 columnDescription.propertyDesc.propertyFlags |= kDataBrowserListViewMovableColumn;
139 if (columnPtr->IsResizeable())
140 {
141 columnDescription.headerBtnDesc.minimumWidth = 0;
142 columnDescription.headerBtnDesc.maximumWidth = 30000; // 32767 is the theoretical maximum though but 30000 looks nicer
143 }
144 else
145 {
146 columnDescription.headerBtnDesc.minimumWidth = columnPtr->GetWidth();
147 columnDescription.headerBtnDesc.maximumWidth = columnPtr->GetWidth();
148 }
149 if (columnPtr->IsSortable())
150 columnDescription.propertyDesc.propertyFlags |= kDataBrowserListViewSortableColumn;
151 if ((columnPtr->GetRenderer()->GetMode() == wxDATAVIEW_CELL_EDITABLE) ||
152 (columnPtr->GetRenderer()->GetMode() == wxDATAVIEW_CELL_ACTIVATABLE))
153 columnDescription.propertyDesc.propertyFlags |= kDataBrowserPropertyIsEditable;
154 if ((columnDescription.propertyDesc.propertyType == kDataBrowserCustomType) ||
155 (columnDescription.propertyDesc.propertyType == kDataBrowserDateTimeType) ||
156 (columnDescription.propertyDesc.propertyType == kDataBrowserIconAndTextType) ||
157 (columnDescription.propertyDesc.propertyType == kDataBrowserTextType))
158 columnDescription.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn; // enables generally the possibility to have user input for the mentioned types
159 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
160 columnDescription.propertyDesc.propertyFlags |= kDataBrowserListViewNoGapForIconInHeaderButton;
161 #endif
162 // set header's properties:
163 columnDescription.headerBtnDesc.version = kDataBrowserListViewLatestHeaderDesc;
164 columnDescription.headerBtnDesc.titleOffset = 0;
165 columnDescription.headerBtnDesc.titleString = ::CFStringCreateCopy(kCFAllocatorDefault,title);
166 columnDescription.headerBtnDesc.initialOrder = kDataBrowserOrderIncreasing; // choose one of the orders as "undefined" is not supported anyway (s. ControlDefs.h in the HIToolbox framework)
167 columnDescription.headerBtnDesc.btnFontStyle.flags = kControlUseFontMask | kControlUseJustMask;
168 switch (columnPtr->GetAlignment())
169 {
170 case wxALIGN_CENTER:
171 case wxALIGN_CENTER_HORIZONTAL:
172 columnDescription.headerBtnDesc.btnFontStyle.just = teCenter;
173 break;
174 case wxALIGN_LEFT:
175 columnDescription.headerBtnDesc.btnFontStyle.just = teFlushLeft;
176 break;
177 case wxALIGN_RIGHT:
178 columnDescription.headerBtnDesc.btnFontStyle.just = teFlushRight;
179 break;
180 default:
181 columnDescription.headerBtnDesc.btnFontStyle.just = teFlushDefault;
182 }
183 columnDescription.headerBtnDesc.btnFontStyle.font = kControlFontViewSystemFont;
184 columnDescription.headerBtnDesc.btnFontStyle.style = normal;
185 if (columnPtr->GetBitmap().IsOk())
186 {
187 columnDescription.headerBtnDesc.btnContentInfo.contentType = kControlContentIconRef;
188 columnDescription.headerBtnDesc.btnContentInfo.u.iconRef = columnPtr->GetBitmap().GetIconRef();
189 }
190 else
191 {
192 // not text only as we otherwise could not add a bitmap later
193 // columnDescription.headerBtnDesc.btnContentInfo.contentType = kControlContentTextOnly;
194 columnDescription.headerBtnDesc.btnContentInfo.contentType = kControlContentIconRef;
195 columnDescription.headerBtnDesc.btnContentInfo.u.iconRef = NULL;
196 }
197
198 // done:
199 return true;
200 }
201
202 // ============================================================================
203 // Type definitions of locally used function pointers
204 // ============================================================================
205 DEFINE_ONE_SHOT_HANDLER_GETTER(DataBrowserCtrlEventHandler)
206
207 // ============================================================================
208 // Helper functions for dataview implementation on OSX
209 // ============================================================================
210 wxWidgetImplType* CreateDataView(wxWindowMac* wxpeer, wxWindowMac* WXUNUSED(parent), wxWindowID WXUNUSED(id), wxPoint const& pos, wxSize const& size,
211 long style, long WXUNUSED(extraStyle))
212 {
213 return new wxMacDataViewDataBrowserListViewControl(wxpeer,pos,size,style);
214 }
215
216 // ============================================================================
217 // wxMacDataBrowserTableViewControl
218 // ============================================================================
219 pascal Boolean wxMacDataBrowserTableViewControl::DataBrowserCompareProc(ControlRef browser, DataBrowserItemID itemOneID, DataBrowserItemID itemTwoID, DataBrowserPropertyID sortProperty)
220 {
221 wxMacDataBrowserTableViewControl* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl*>(wxMacControl::GetReferenceFromNativeControl(browser)));
222
223
224 if (ControlPtr != NULL)
225 return ControlPtr->DataBrowserCompareProc(itemOneID,itemTwoID,sortProperty);
226 else
227 return FALSE;
228 } /* wxMacDataBrowserTableViewControl::DataBrowserCompareProc(ControlRef, DataBrowserItemID, DataBrowserItemID, DataBrowserPropertyID) */
229
230 pascal void wxMacDataBrowserTableViewControl::DataBrowserGetContextualMenuProc(ControlRef browser, MenuRef* menu, UInt32* helpType, CFStringRef* helpItemString, AEDesc* selection)
231 {
232 wxMacDataBrowserTableViewControl* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl*>(wxMacControl::GetReferenceFromNativeControl(browser)));
233
234
235 if (ControlPtr != NULL)
236 ControlPtr->DataBrowserGetContextualMenuProc(menu,helpType,helpItemString,selection);
237 } /* wxMacDataBrowserTableViewControl::DataBrowserGetContextualMenuProc(ControlRef, MenuRef*, UInt32*, CFStringRef*, AEDesc*) */
238
239 pascal OSStatus wxMacDataBrowserTableViewControl::DataBrowserGetSetItemDataProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID propertyID, DataBrowserItemDataRef itemData, Boolean getValue)
240 {
241 wxMacDataBrowserTableViewControl* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl*>(wxMacControl::GetReferenceFromNativeControl(browser)));
242
243
244 if (ControlPtr != NULL)
245 return ControlPtr->DataBrowserGetSetItemDataProc(itemID,propertyID,itemData,getValue);
246 else
247 return errDataBrowserPropertyNotSupported;
248 } /* wxMacDataBrowserTableViewControl::DataBrowserGetSetItemDataProc(ControlRef, DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemDataRef, Boolean) */
249
250 pascal void wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserItemNotification message, DataBrowserItemDataRef itemData)
251 {
252 wxMacDataBrowserTableViewControl* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl*>(wxMacControl::GetReferenceFromNativeControl(browser)));
253
254
255 if (ControlPtr != NULL)
256 ControlPtr->DataBrowserItemNotificationProc(itemID,message,itemData);
257 } /* wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc(ControlRef, DataBrowserItemID, DataBrowserItemNotification, DataBrowserItemDataRef) */
258
259 pascal void wxMacDataBrowserTableViewControl::DataBrowserDrawItemProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID propertyID, DataBrowserItemState state, Rect const* rectangle, SInt16 bitDepth, Boolean colorDevice)
260 {
261 wxMacDataBrowserTableViewControl* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl*>(wxMacControl::GetReferenceFromNativeControl(browser)));
262
263
264 if (ControlPtr != NULL)
265 ControlPtr->DataBrowserDrawItemProc(itemID,propertyID,state,rectangle,bitDepth,colorDevice);
266 } /* wxMacDataBrowserTableViewControl::DataBrowserDrawItemProc(ControlRef, DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemState, Rect const*, SInt16, Boolean) */
267
268 pascal Boolean wxMacDataBrowserTableViewControl::DataBrowserEditItemProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID propertyID, CFStringRef theString, Rect* maxEditTextRect, Boolean* shrinkToFit)
269 {
270 wxMacDataBrowserTableViewControl* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl*>(wxMacControl::GetReferenceFromNativeControl(browser)));
271
272
273 return ((ControlPtr != NULL) && ControlPtr->DataBrowserEditItemProc(itemID,propertyID,theString,maxEditTextRect,shrinkToFit));
274 } /* wxMacDataBrowserTableViewControl::DataBrowserEditItemProc(ControlRef, DataBrowserItemID, DataBrowserPropertyID, CFStringRef, Rect*, Boolean*) */
275
276 pascal Boolean wxMacDataBrowserTableViewControl::DataBrowserHitTestProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID propertyID, Rect const* theRect, Rect const* mouseRect)
277 {
278 wxMacDataBrowserTableViewControl* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl*>(wxMacControl::GetReferenceFromNativeControl(browser)));
279
280
281 return ((ControlPtr != NULL) && ControlPtr->DataBrowserHitTestProc(itemID,propertyID,theRect,mouseRect));
282 } /* wxMacDataBrowserTableViewControl::DataBrowserHitTestProc(ControlRef, DataBrowserItemID, DataBrowserPropertyID, Rect const*, Rect const*) */
283
284 pascal DataBrowserTrackingResult wxMacDataBrowserTableViewControl::DataBrowserTrackingProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID propertyID, Rect const* theRect, Point startPt, EventModifiers modifiers)
285 {
286 wxMacDataBrowserTableViewControl* ControlPtr(dynamic_cast<wxMacDataBrowserTableViewControl*>(wxMacControl::GetReferenceFromNativeControl(browser)));
287
288
289 if (ControlPtr != NULL)
290 return ControlPtr->DataBrowserTrackingProc(itemID,propertyID,theRect,startPt,modifiers);
291 else
292 return kDataBrowserNothingHit;
293 } /* wxMacDataBrowserTableViewControl::DataBrowserTrackingProc(ControlRef, DataBrowserItemID, DataBrowserPropertyID, Rect const*, Point, EventModifiers) */
294
295 pascal Boolean wxMacDataBrowserTableViewControl::DataBrowserAcceptDragProc(ControlRef browser, DragReference dragRef, DataBrowserItemID itemID)
296 {
297 wxMacDataBrowserTableViewControl* controlPtr(dynamic_cast<wxMacDataBrowserTableViewControl*>(wxMacControl::GetReferenceFromNativeControl(browser)));
298
299
300 return ((controlPtr != NULL) && controlPtr->DataBrowserAcceptDragProc(dragRef,itemID));
301 } /* wxMacDataBrowserTableViewControl::DataBrowserAcceptDragProc(ControlRef, DragReference, DataBrowserItemID) */
302
303 pascal Boolean wxMacDataBrowserTableViewControl::DataBrowserAddDragItemProc(ControlRef browser, DragReference dragRef, DataBrowserItemID itemID, ItemReference* itemRef)
304 {
305 wxMacDataBrowserTableViewControl* controlPtr(dynamic_cast<wxMacDataBrowserTableViewControl*>(wxMacControl::GetReferenceFromNativeControl(browser)));
306
307
308 return ((controlPtr != NULL) && controlPtr->DataBrowserAddDragItemProc(dragRef,itemID,itemRef));
309 } /* wxMacDataBrowserTableViewControl::DataBrowserAddDragItemProc(ControlRef, DragReference, DataBrowserItemID, ItemReference*) */
310
311 pascal Boolean wxMacDataBrowserTableViewControl::DataBrowserReceiveDragProc(ControlRef browser, DragReference dragRef, DataBrowserItemID itemID)
312 {
313 wxMacDataBrowserTableViewControl* controlPtr(dynamic_cast<wxMacDataBrowserTableViewControl*>(wxMacControl::GetReferenceFromNativeControl(browser)));
314
315
316 return ((controlPtr != NULL) && controlPtr->DataBrowserReceiveDragProc(dragRef,itemID));
317 } /* wxMacDataBrowserTableViewControl::DataBrowserReceiveDragProc(ControlRef, DragReference, DataBrowserItemID) */
318
319 wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow* peer, wxPoint const& pos, wxSize const& size, long style)
320 :wxMacControl(peer)
321 {
322 Rect bounds = wxMacGetBoundsForControl(peer,pos,size);
323 OSStatus err = ::CreateDataBrowserControl(MAC_WXHWND(peer->MacGetTopLevelWindowRef()),&bounds,kDataBrowserListView,&(this->m_controlRef));
324
325
326 SetReferenceInNativeControl();
327 verify_noerr(err);
328
329 ::InstallControlEventHandler(this->m_controlRef, GetDataBrowserCtrlEventHandlerUPP(), GetEventTypeCount(eventList), eventList, peer, (EventHandlerRef *)&m_macDataViewCtrlEventHandler);
330
331 // setup standard callbacks:
332 if (gDataBrowserTableViewGetContextualMenuUPP == NULL) gDataBrowserTableViewGetContextualMenuUPP = NewDataBrowserGetContextualMenuUPP(wxMacDataBrowserTableViewControl::DataBrowserGetContextualMenuProc);
333 if (gDataBrowserTableViewItemCompareUPP == NULL) gDataBrowserTableViewItemCompareUPP = NewDataBrowserItemCompareUPP (wxMacDataBrowserTableViewControl::DataBrowserCompareProc);
334 if (gDataBrowserTableViewItemDataUPP == NULL) gDataBrowserTableViewItemDataUPP = NewDataBrowserItemDataUPP (wxMacDataBrowserTableViewControl::DataBrowserGetSetItemDataProc);
335 if (gDataBrowserTableViewItemNotificationUPP == NULL)
336 {
337 gDataBrowserTableViewItemNotificationUPP =
338 #if TARGET_API_MAC_OSX
339 (DataBrowserItemNotificationUPP) NewDataBrowserItemNotificationWithItemUPP(wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc);
340 #else
341 NewDataBrowserItemNotificationUPP(wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc);
342 #endif
343 }
344 // setup drag and drop callbacks:
345 if (gDataBrowserTableViewAcceptDragUPP == NULL) gDataBrowserTableViewAcceptDragUPP = NewDataBrowserAcceptDragUPP (wxMacDataBrowserTableViewControl::DataBrowserAcceptDragProc);
346 if (gDataBrowserTableViewAddDragItemUPP == NULL) gDataBrowserTableViewAddDragItemUPP = NewDataBrowserAddDragItemUPP(wxMacDataBrowserTableViewControl::DataBrowserAddDragItemProc);
347 if (gDataBrowserTableViewReceiveDragUPP == NULL) gDataBrowserTableViewReceiveDragUPP = NewDataBrowserReceiveDragUPP(wxMacDataBrowserTableViewControl::DataBrowserReceiveDragProc);
348
349 DataBrowserCallbacks callbacks; // variable definition
350
351 InitializeDataBrowserCallbacks(&callbacks,kDataBrowserLatestCallbacks);
352 callbacks.u.v1.getContextualMenuCallback = gDataBrowserTableViewGetContextualMenuUPP;
353 callbacks.u.v1.itemDataCallback = gDataBrowserTableViewItemDataUPP;
354 callbacks.u.v1.itemCompareCallback = gDataBrowserTableViewItemCompareUPP;
355 callbacks.u.v1.itemNotificationCallback = gDataBrowserTableViewItemNotificationUPP;
356 callbacks.u.v1.acceptDragCallback = gDataBrowserTableViewAcceptDragUPP;
357 callbacks.u.v1.addDragItemCallback = gDataBrowserTableViewAddDragItemUPP;
358 callbacks.u.v1.receiveDragCallback = gDataBrowserTableViewReceiveDragUPP;
359 this->SetCallbacks(&callbacks);
360
361 // setup callbacks for customized items:
362 if (gDataBrowserTableViewDrawItemUPP == NULL) gDataBrowserTableViewDrawItemUPP = NewDataBrowserDrawItemUPP(wxMacDataBrowserTableViewControl::DataBrowserDrawItemProc);
363 if (gDataBrowserTableViewEditItemUPP == NULL) gDataBrowserTableViewEditItemUPP = NewDataBrowserEditItemUPP(wxMacDataBrowserTableViewControl::DataBrowserEditItemProc);
364 if (gDataBrowserTableViewHitTestUPP == NULL) gDataBrowserTableViewHitTestUPP = NewDataBrowserHitTestUPP (wxMacDataBrowserTableViewControl::DataBrowserHitTestProc);
365 if (gDataBrowserTableViewTrackingUPP == NULL) gDataBrowserTableViewTrackingUPP = NewDataBrowserTrackingUPP(wxMacDataBrowserTableViewControl::DataBrowserTrackingProc);
366
367 DataBrowserCustomCallbacks customCallbacks; // variable definition
368
369 InitializeDataBrowserCustomCallbacks(&customCallbacks,kDataBrowserLatestCallbacks);
370 customCallbacks.u.v1.drawItemCallback = gDataBrowserTableViewDrawItemUPP;
371 customCallbacks.u.v1.editTextCallback = gDataBrowserTableViewEditItemUPP;
372 customCallbacks.u.v1.hitTestCallback = gDataBrowserTableViewHitTestUPP;
373 customCallbacks.u.v1.trackingCallback = gDataBrowserTableViewTrackingUPP;
374 this->SetCustomCallbacks(&customCallbacks);
375
376 // style setting:
377 this->EnableCellSizeModification( ((style & wxDV_VARIABLE_LINE_HEIGHT) != 0), true );
378
379 DataBrowserSelectionFlags flags; // variable definition
380
381 if (this->GetSelectionFlags(&flags) == noErr) // get default settings
382 {
383 if ((style & wxDV_MULTIPLE) != 0)
384 flags &= ~kDataBrowserSelectOnlyOne;
385 else
386 flags |= kDataBrowserSelectOnlyOne;
387 (void) this->SetSelectionFlags(flags);
388 }
389
390 OptionBits attributes; // variable definition
391
392 if (this->GetAttributes(&attributes) == noErr) // get default settings
393 {
394 if ((style & wxDV_VERT_RULES) != 0)
395 attributes |= kDataBrowserAttributeListViewDrawColumnDividers;
396 else
397 attributes &= ~kDataBrowserAttributeListViewDrawColumnDividers;
398 if ((style & wxDV_ROW_LINES) != 0)
399 attributes |= kDataBrowserAttributeListViewAlternatingRowColors;
400 else
401 attributes &= ~kDataBrowserAttributeListViewAlternatingRowColors;
402 (void) this->SetAttributes(attributes);
403 }
404
405 if ((style & wxDV_NO_HEADER) != 0)
406 this->SetHeaderButtonHeight(0);
407 } /* wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow*, wxPoint const&, wxSize const&, long) */
408
409 wxMacDataBrowserTableViewControl::~wxMacDataBrowserTableViewControl(void)
410 {
411 ::RemoveEventHandler((EventHandlerRef) m_macDataViewCtrlEventHandler);
412 } /* wxMacDataBrowserTableViewControl::~wxMacDataBrowserTableViewControl(void) */
413
414 //
415 // callback handling
416 //
417 OSStatus wxMacDataBrowserTableViewControl::SetCallbacks(DataBrowserCallbacks const* callbacks)
418 {
419 return ::SetDataBrowserCallbacks(this->m_controlRef,callbacks);
420 } /* wxMacDataBrowserTableViewControl::SetCallbacks(DataBrowserCallbacks const*) */
421
422 OSStatus wxMacDataBrowserTableViewControl::SetCustomCallbacks(DataBrowserCustomCallbacks const* customCallbacks)
423 {
424 return ::SetDataBrowserCustomCallbacks(this->m_controlRef,customCallbacks);
425 } /* xMacDataBrowserTableViewControl::SetCustomCallbacks(DataBrowserCustomCallbacks const*) */
426
427 //
428 // DnD handling
429 //
430 OSStatus wxMacDataBrowserTableViewControl::EnableAutomaticDragTracking(bool enable)
431 {
432 return ::SetAutomaticControlDragTrackingEnabledForWindow(::GetControlOwner(this->m_controlRef),enable);
433 }
434
435 //
436 // header handling
437 //
438 OSStatus wxMacDataBrowserTableViewControl::GetHeaderDesc(DataBrowserPropertyID propertyID, DataBrowserListViewHeaderDesc* desc) const
439 {
440 desc->version = kDataBrowserListViewLatestHeaderDesc; // if this statement is missing the next call will fail (NOT DOCUMENTED!!)
441 return ::GetDataBrowserListViewHeaderDesc(this->m_controlRef,propertyID,desc);
442 }
443
444 OSStatus wxMacDataBrowserTableViewControl::SetHeaderDesc(DataBrowserPropertyID propertyID, DataBrowserListViewHeaderDesc* desc)
445 {
446 return ::SetDataBrowserListViewHeaderDesc(this->m_controlRef,propertyID,desc);
447 }
448
449 //
450 // layout handling
451 //
452 OSStatus wxMacDataBrowserTableViewControl::AutoSizeColumns()
453 {
454 return AutoSizeDataBrowserListViewColumns(this->m_controlRef);
455 }
456
457 OSStatus wxMacDataBrowserTableViewControl::EnableCellSizeModification(bool enableHeight, bool enableWidth)
458 {
459 return ::SetDataBrowserTableViewGeometry(this->GetControlRef(),enableWidth,enableHeight);
460 } /* wxMacDataBrowserTableViewControl::EnableCellSizeModification(bool, bool) */
461
462 OSStatus wxMacDataBrowserTableViewControl::GetAttributes(OptionBits* attributes)
463 {
464 return ::DataBrowserGetAttributes(this->GetControlRef(),attributes);
465 } /* wxMacDataBrowserTableViewControl::GetAttributes(OptionBits*) */
466
467 OSStatus wxMacDataBrowserTableViewControl::GetColumnWidth(DataBrowserPropertyID propertyID, UInt16* width) const
468 {
469 return ::GetDataBrowserTableViewNamedColumnWidth(this->m_controlRef,propertyID,width);
470 }
471
472 OSStatus wxMacDataBrowserTableViewControl::GetDefaultColumnWidth( UInt16 *width ) const
473 {
474 return GetDataBrowserTableViewColumnWidth(this->m_controlRef, width );
475 }
476
477 OSStatus wxMacDataBrowserTableViewControl::GetDefaultRowHeight(UInt16* height) const
478 {
479 return ::GetDataBrowserTableViewRowHeight(this->m_controlRef,height);
480 }
481
482 OSStatus wxMacDataBrowserTableViewControl::GetHeaderButtonHeight(UInt16 *height)
483 {
484 return ::GetDataBrowserListViewHeaderBtnHeight(this->m_controlRef,height);
485 }
486
487 OSStatus wxMacDataBrowserTableViewControl::GetPartBounds(DataBrowserItemID item, DataBrowserPropertyID propertyID, DataBrowserPropertyPart part, Rect* bounds)
488 {
489 return ::GetDataBrowserItemPartBounds(this->m_controlRef,item,propertyID,part,bounds);
490 } /* wxMacDataBrowserTableViewControl::GetPartBounds(DataBrowserItemID, DataBrowswerPropertyID, DataBrowserPropertyPart, Rect*) */
491
492 OSStatus wxMacDataBrowserTableViewControl::GetRowHeight(DataBrowserItemID item, UInt16* height) const
493 {
494 return ::GetDataBrowserTableViewItemRowHeight(this->m_controlRef,item,height);
495 } /* wxMacDataBrowserTableViewControl::GetRowHeight(DataBrowserItemID, UInt16*) const */
496
497 OSStatus wxMacDataBrowserTableViewControl::GetScrollPosition( UInt32 *top , UInt32 *left ) const
498 {
499 return GetDataBrowserScrollPosition(this->m_controlRef, top , left );
500 }
501
502 OSStatus wxMacDataBrowserTableViewControl::SetAttributes(OptionBits attributes)
503 {
504 return ::DataBrowserChangeAttributes(this->GetControlRef(),attributes,~attributes);
505 } /* wxMacDataBrowserTableViewControl::SetAttributes(OptionBits) */
506
507 OSStatus wxMacDataBrowserTableViewControl::SetColumnWidth(DataBrowserPropertyID propertyID, UInt16 width)
508 {
509 return ::SetDataBrowserTableViewNamedColumnWidth(this->m_controlRef,propertyID,width);
510 }
511
512 OSStatus wxMacDataBrowserTableViewControl::SetDefaultColumnWidth(UInt16 width)
513 {
514 return ::SetDataBrowserTableViewColumnWidth(this->m_controlRef,width);
515 }
516
517 OSStatus wxMacDataBrowserTableViewControl::SetDefaultRowHeight(UInt16 height)
518 {
519 return ::SetDataBrowserTableViewRowHeight(this->m_controlRef,height);
520 }
521
522 OSStatus wxMacDataBrowserTableViewControl::SetHasScrollBars(bool horiz, bool vert)
523 {
524 return ::SetDataBrowserHasScrollBars(this->m_controlRef,horiz,vert);
525 } /* wxMacDataBrowserTableViewControl::SetHasScrollBars(bool, bool) */
526
527 OSStatus wxMacDataBrowserTableViewControl::SetHeaderButtonHeight(UInt16 height)
528 {
529 return ::SetDataBrowserListViewHeaderBtnHeight(this->m_controlRef,height);
530 } /* wxMacDataBrowserTableViewControl::SetHeaderButtonHeight(UInt16) */
531
532 OSStatus wxMacDataBrowserTableViewControl::SetHiliteStyle(DataBrowserTableViewHiliteStyle hiliteStyle)
533 {
534 return ::SetDataBrowserTableViewHiliteStyle(this->m_controlRef,hiliteStyle);
535 } /*wxMacDataBrowserTableViewControl::SetHiliteStyle(DataBrowserTableViewHiliteStyle) */
536
537 OSStatus wxMacDataBrowserTableViewControl::SetIndent(float Indent)
538 {
539 return ::DataBrowserSetMetric(this->m_controlRef,kDataBrowserMetricDisclosureColumnPerDepthGap,true,Indent);
540 } /* wxMacDataBrowserTableViewControl::SetIndent(float* Indent) */
541
542 OSStatus wxMacDataBrowserTableViewControl::SetItemRowHeight(DataBrowserItemID item, UInt16 height)
543 {
544 return ::SetDataBrowserTableViewItemRowHeight(this->m_controlRef,item,height);
545 }
546
547 OSStatus wxMacDataBrowserTableViewControl::SetScrollPosition(UInt32 top, UInt32 left)
548 {
549 return ::SetDataBrowserScrollPosition(this->m_controlRef,top,left);
550 }
551
552 //
553 // column handling
554 //
555 OSStatus wxMacDataBrowserTableViewControl::GetColumnCount(UInt32* numColumns) const
556 {
557 return ::GetDataBrowserTableViewColumnCount(this->m_controlRef,numColumns);
558 }
559
560 OSStatus wxMacDataBrowserTableViewControl::GetColumnIndex(DataBrowserPropertyID propertyID, DataBrowserTableViewColumnIndex* index) const
561 {
562 return ::GetDataBrowserTableViewColumnPosition(this->m_controlRef,propertyID,index);
563 } /* wxMacDataBrowserTableViewControl::GetColumnIndex(DataBrowserPropertyID, DataBrowserTableViewColumnIndex*) const */
564
565 OSStatus wxMacDataBrowserTableViewControl::GetFreePropertyID(DataBrowserPropertyID* propertyID) const
566 {
567 for (*propertyID=kMinPropertyID; *propertyID<std::numeric_limits<DataBrowserPropertyID>::max(); ++(*propertyID))
568 if (this->IsUsedPropertyID(*propertyID) == errDataBrowserPropertyNotFound)
569 return noErr;
570 return errDataBrowserPropertyNotSupported;
571 } /* wxMacDataBrowserTableViewControl::GetFreePropertyID(DataBrowserPropertyID*) const */
572
573 OSStatus wxMacDataBrowserTableViewControl::GetPropertyFlags(DataBrowserPropertyID propertyID, DataBrowserPropertyFlags *flags) const
574 {
575 return ::GetDataBrowserPropertyFlags(this->m_controlRef,propertyID,flags);
576 }
577
578 OSStatus wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserItemDataRef itemData, DataBrowserPropertyID* propertyID) const
579 {
580 return ::GetDataBrowserItemDataProperty(itemData,propertyID);
581 } /* wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserItemDataRef, DataBrowserPropertyID*) */
582
583 OSStatus wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserTableViewColumnIndex index, DataBrowserTableViewColumnID* propertyID) const
584 {
585 return ::GetDataBrowserTableViewColumnProperty(this->m_controlRef,index,propertyID);
586 } /* wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserTableViewColumnIndex, DataBrowserTableViewColumnID*) */
587
588 OSStatus wxMacDataBrowserTableViewControl::IsUsedPropertyID(DataBrowserPropertyID propertyID) const
589 {
590 // 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
591 // 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
592 // the column position for the property id:
593 DataBrowserTableViewColumnIndex index;
594
595 return ::GetDataBrowserTableViewColumnPosition(this->m_controlRef,propertyID,&index);
596 } /* wxMacDataBrowserTableViewControl::IsUsedPropertyId(DataBrowserPropertyID) const */
597
598 OSStatus wxMacDataBrowserTableViewControl::RemoveColumnByProperty(DataBrowserTableViewColumnID propertyID)
599 {
600 return ::RemoveDataBrowserTableViewColumn(this->m_controlRef,propertyID);
601 } /* wxMacDataBrowserTableViewControl::RemoveColumnByProperty(DataBrowserTableViewColumnID) */
602
603 OSStatus wxMacDataBrowserTableViewControl::RemoveColumnByIndex(DataBrowserTableViewColumnIndex index)
604 {
605 DataBrowserTableViewColumnID propertyID;
606
607
608 this->GetPropertyID(index,&propertyID);
609 return ::RemoveDataBrowserTableViewColumn(this->m_controlRef,propertyID);
610 } /* wxMacDataBrowserTableViewControl::RemoveColumnByIndex(DataBrowserTableViewColumnIndex) */
611
612 OSStatus wxMacDataBrowserTableViewControl::SetColumnIndex(DataBrowserPropertyID propertyID, DataBrowserTableViewColumnIndex index)
613 {
614 return ::SetDataBrowserTableViewColumnPosition(this->m_controlRef,propertyID,index);
615 } /* wxMacDataBrowserTableViewControl::SetColumnIndex(DataBrowserPropertyID, DataBrowserTableViewColumnIndex) */
616
617 OSStatus wxMacDataBrowserTableViewControl::SetDisclosureColumn(DataBrowserPropertyID propertyID, Boolean expandableRows)
618 {
619 return ::SetDataBrowserListViewDisclosureColumn(this->m_controlRef,propertyID,expandableRows);
620 }
621
622 OSStatus wxMacDataBrowserTableViewControl::SetPropertyFlags(DataBrowserPropertyID propertyID, DataBrowserPropertyFlags flags)
623 {
624 return ::SetDataBrowserPropertyFlags(this->m_controlRef,propertyID,flags);
625 } /* wxMacDataBrowserTableViewControl::SetPropertyFlags(DataBrowserPropertyID, DataBrowserPropertyFlags) */
626
627 //
628 // item handling
629 //
630 OSStatus wxMacDataBrowserTableViewControl::AddItems(DataBrowserItemID container, UInt32 numItems, DataBrowserItemID const* items, DataBrowserPropertyID preSortProperty)
631 {
632 return ::AddDataBrowserItems(this->m_controlRef,container,numItems,items,preSortProperty);
633 } /* wxMacDataBrowserTableViewControl::AddItems(DataBrowserItemID, UInt32, DataBrowserItemID const*, DataBrowserPropertyID) */
634
635 OSStatus wxMacDataBrowserTableViewControl::GetFreeItemID(DataBrowserItemID* id) const
636 {
637 ItemCount noOfItems;
638
639 OSStatus status;
640
641
642 status = this->GetItemCount(&noOfItems);
643 wxCHECK_MSG(status == noErr,status,_("Could not retrieve number of items"));
644 if (noOfItems == 0)
645 {
646 *id = 1;
647 return noErr;
648 }
649 else
650 {
651 // 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
652 // as the number of items; therefore, start from the number of items to look for a new ID:
653 for (*id=noOfItems; *id<std::numeric_limits<DataBrowserItemID>::max(); ++(*id))
654 if (this->IsUsedItemID(*id) == errDataBrowserItemNotFound)
655 return noErr;
656 // as the first approach was not successful, try from the beginning:
657 for (*id=0; *id<noOfItems; ++(*id))
658 if (this->IsUsedItemID(*id) == errDataBrowserItemNotFound)
659 return noErr;
660 // sorry, data browser is full:
661 return errDataBrowserItemNotAdded;
662 }
663 } /* wxMacDataBrowserTableViewControl::GetFreeItemID(DataBrowserItemID*) const */
664
665 OSStatus wxMacDataBrowserTableViewControl::GetItemCount(DataBrowserItemID container, Boolean recurse, DataBrowserItemState state, ItemCount* numItems) const
666 {
667 return GetDataBrowserItemCount(this->m_controlRef,container,recurse,state,numItems);
668 } /* wxMacDataBrowserTableViewControl::GetItemCount(DataBrowserItemID, Boolean, DataBrowserItemState, ItemCount*) const */
669
670 OSStatus wxMacDataBrowserTableViewControl::GetItemID( DataBrowserTableViewRowIndex row, DataBrowserItemID * item ) const
671 {
672 return GetDataBrowserTableViewItemID(this->m_controlRef,row,item);
673 }
674
675 OSStatus wxMacDataBrowserTableViewControl::GetItems(DataBrowserItemID container, Boolean recurse, DataBrowserItemState state, Handle items) const
676 {
677 return GetDataBrowserItems(this->m_controlRef,container,recurse,state,items);
678 } /* wxMacDataBrowserTableViewControl::GetItems(DataBrowserItemID, Boolean, DataBrowserItemState, Handle) const */
679
680 OSStatus wxMacDataBrowserTableViewControl::GetItemRow(DataBrowserItemID item, DataBrowserTableViewRowIndex* row) const
681 {
682 return GetDataBrowserTableViewItemRow(this->m_controlRef,item,row);
683 }
684
685 OSStatus wxMacDataBrowserTableViewControl::GetItemState(DataBrowserItemID item, DataBrowserItemState* state) const
686 {
687 return ::GetDataBrowserItemState(this->m_controlRef,item,state);
688 }
689
690 OSStatus wxMacDataBrowserTableViewControl::IsUsedItemID(DataBrowserItemID itemID) const
691 {
692 // 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
693 // 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
694 // the column position for the property id:
695 DataBrowserTableViewColumnIndex index;
696
697 return ::GetDataBrowserTableViewItemRow(this->m_controlRef,itemID,&index);
698 } /* wxMacDataBrowserTableViewControl::IsUsedItemID(DataBrowserItemID) const */
699
700 OSStatus wxMacDataBrowserTableViewControl::RemoveItems(DataBrowserItemID container, UInt32 numItems, DataBrowserItemID const* items, DataBrowserPropertyID preSortProperty)
701 {
702 return ::RemoveDataBrowserItems(this->m_controlRef,container,numItems,items,preSortProperty);
703 }
704
705 OSStatus wxMacDataBrowserTableViewControl::RevealItem(DataBrowserItemID item, DataBrowserPropertyID propertyID, DataBrowserRevealOptions options) const
706 {
707 return ::RevealDataBrowserItem(this->m_controlRef,item,propertyID,options);
708 } /* wxMacDataBrowserTableViewControl::RevealItem(DataBrowserItemID item, DataBrowserPropertyID propertyID, DataBrowserRevealOptions options) const */
709
710 OSStatus wxMacDataBrowserTableViewControl::UpdateItems(DataBrowserItemID container, UInt32 numItems, DataBrowserItemID const* items, DataBrowserPropertyID preSortProperty,
711 DataBrowserPropertyID propertyID) const
712 {
713 return UpdateDataBrowserItems(this->m_controlRef,container,numItems,items,preSortProperty,propertyID);
714 }
715
716 //
717 // item selection
718 //
719 size_t wxMacDataBrowserTableViewControl::GetSelectedItemIDs(wxArrayDataBrowserItemID& itemIDs) const
720 {
721 DataBrowserItemID* itemIDPtr;
722 Handle handle(::NewHandle(0));
723
724 size_t noOfItems;
725
726
727 wxCHECK_MSG(this->GetItems(kDataBrowserNoItem,true,kDataBrowserItemIsSelected,handle) == noErr,0,_("Could not get selected items."));
728 noOfItems = static_cast<size_t>(::GetHandleSize(handle)/sizeof(DataBrowserItemID));
729 itemIDs.Empty();
730 itemIDs.Alloc(noOfItems);
731 HLock(handle);
732 itemIDPtr = (DataBrowserItemID*) (*handle);
733 for (size_t i=0; i<noOfItems; ++i)
734 {
735 itemIDs.Add(*itemIDPtr);
736 ++itemIDPtr;
737 }
738 HUnlock(handle);
739 DisposeHandle(handle);
740 return noOfItems;
741 } /* wxMacDataBrowserTableViewControl::GetSelectedItemIDs(wxArrayDataBrowserItemID&) const*/
742
743 OSStatus wxMacDataBrowserTableViewControl::GetSelectionAnchor(DataBrowserItemID* first, DataBrowserItemID* last) const
744 {
745 return ::GetDataBrowserSelectionAnchor(this->m_controlRef,first,last);
746 } /* wxMacDataBrowserTableViewControl::GetSelectionAnchor(DataBrowserItemID*, DataBrowserItemID*) const */
747
748 OSStatus wxMacDataBrowserTableViewControl::GetSelectionFlags(DataBrowserSelectionFlags* flags) const
749 {
750 return ::GetDataBrowserSelectionFlags(this->m_controlRef,flags);
751 } /* wxMacDataBrowserTableViewControl::GetSelectionFlags(DataBrowserSelectionFlags*) const */
752
753 bool wxMacDataBrowserTableViewControl::IsItemSelected(DataBrowserItemID item) const
754 {
755 return ::IsDataBrowserItemSelected(this->m_controlRef,item);
756 } /* wxMacDataBrowserTableViewControl::IsItemSelected(DataBrowserItemID) const */
757
758 OSStatus wxMacDataBrowserTableViewControl::SetSelectionFlags(DataBrowserSelectionFlags flags)
759 {
760 return ::SetDataBrowserSelectionFlags(this->m_controlRef,flags);
761 } /* wxMacDataBrowserTableViewControl::SetSelectionFlags(DataBrowserSelectionFlags) */
762
763 OSStatus wxMacDataBrowserTableViewControl::SetSelectedItems(UInt32 numItems, DataBrowserItemID const* items, DataBrowserSetOption operation)
764 {
765 return ::SetDataBrowserSelectedItems(this->m_controlRef, numItems, items, operation );
766 } /* wxMacDataBrowserTableViewControl::SetSelectedItems(UInt32, DataBrowserItemID const*, DataBrowserSetOption) */
767
768 OSStatus wxMacDataBrowserTableViewControl::GetSortOrder(DataBrowserSortOrder* order) const
769 {
770 return ::GetDataBrowserSortOrder(this->m_controlRef,order);
771 }
772
773 OSStatus wxMacDataBrowserTableViewControl::GetSortProperty(DataBrowserPropertyID* propertyID) const
774 {
775 return ::GetDataBrowserSortProperty(this->m_controlRef,propertyID);
776 }
777
778 OSStatus wxMacDataBrowserTableViewControl::Resort(DataBrowserItemID container, Boolean sortChildren)
779 {
780 return ::SortDataBrowserContainer(this->m_controlRef,container,sortChildren);
781 } /* wxMacDataBrowserTableViewControl::Resort(DataBrowserItemID, Boolean) */
782
783 OSStatus wxMacDataBrowserTableViewControl::SetSortOrder(DataBrowserSortOrder order)
784 {
785 return ::SetDataBrowserSortOrder(this->m_controlRef,order);
786 }
787
788 OSStatus wxMacDataBrowserTableViewControl::SetSortProperty(DataBrowserPropertyID propertyID)
789 {
790 return ::SetDataBrowserSortProperty(this->m_controlRef,propertyID);
791 }
792
793 //
794 // container handling
795 //
796 OSStatus wxMacDataBrowserTableViewControl::CloseContainer(DataBrowserItemID containerID)
797 {
798 return ::CloseDataBrowserContainer(this->m_controlRef,containerID);
799 } /* wxMacDataBrowserTableViewControl::CloseContainer(DataBrowserItemID) */
800
801 OSStatus wxMacDataBrowserTableViewControl::OpenContainer(DataBrowserItemID containerID)
802 {
803 return ::OpenDataBrowserContainer(this->m_controlRef,containerID);
804 } /* wxMacDataBrowserTableViewControl::OpenContainer(DataBrowserItemID) */
805
806 IMPLEMENT_ABSTRACT_CLASS(wxMacDataBrowserTableViewControl,wxMacControl)
807
808 // ============================================================================
809 // wxMacDataBrowserListViewControl
810 // ============================================================================
811 #pragma mark -
812 //
813 // column handling
814 //
815 OSStatus wxMacDataBrowserListViewControl::AddColumn(DataBrowserListViewColumnDesc *columnDesc, DataBrowserTableViewColumnIndex position)
816 {
817 return AddDataBrowserListViewColumn(this->m_controlRef,columnDesc,position);
818 } /* wxMacDataBrowserListViewControl::AddColumn(DataBrowserListViewColumnDesc*, DataBrowserTableViewColumnIndex) */
819
820 // ============================================================================
821 // wxMacDataViewDataBrowserListViewControl
822 // ============================================================================
823 #pragma mark -
824 //
825 // constructors / destructor
826 //
827 wxMacDataViewDataBrowserListViewControl::wxMacDataViewDataBrowserListViewControl(wxWindow* peer, wxPoint const& pos, wxSize const& size, long style)
828 :wxMacDataBrowserListViewControl(peer,pos,size,style)
829 {
830 if ((style & wxBORDER_NONE) != 0)
831 this->SetData(kControlNoPart,kControlDataBrowserIncludesFrameAndFocusTag,(Boolean) false);
832 (void) this->EnableAutomaticDragTracking();
833 (void) this->SetHiliteStyle(kDataBrowserTableViewFillHilite);
834 } /* wxMacDataViewDataBrowserListViewControl::wxMacDataViewDataBrowserListViewControl(wxWindow* , const wxPoint&, const wxSize&, long) */
835
836 //
837 // column related methods (inherited from wxDataViewWidgetImpl)
838 //
839 bool wxMacDataViewDataBrowserListViewControl::ClearColumns(void)
840 {
841 UInt32 noOfColumns;
842
843
844 wxCHECK_MSG(this->GetColumnCount(&noOfColumns) == noErr,false,_("Could not determine number of columns."));
845 for (UInt32 i=0; i<noOfColumns; ++i)
846 wxCHECK_MSG(this->RemoveColumnByIndex(0) == noErr,false,_("Could not remove column."));
847 return true;
848 }
849
850 bool wxMacDataViewDataBrowserListViewControl::DeleteColumn(wxDataViewColumn* columnPtr)
851 {
852 return (this->RemoveColumnByProperty(columnPtr->GetNativeData()->GetPropertyID()) == noErr);
853 }
854
855 void wxMacDataViewDataBrowserListViewControl::DoSetExpanderColumn(wxDataViewColumn const* columnPtr)
856 {
857 this->SetDisclosureColumn(columnPtr->GetNativeData()->GetPropertyID(),false); // second parameter explicitely passed to ensure that arrow is centered
858 }
859
860 wxDataViewColumn* wxMacDataViewDataBrowserListViewControl::GetColumn(unsigned int pos) const
861 {
862 DataBrowserPropertyID propertyID;
863
864
865 if (this->GetPropertyID(pos,&propertyID) == noErr)
866 return this->GetColumnPtr(propertyID);
867 else
868 return NULL;
869 }
870
871 int wxMacDataViewDataBrowserListViewControl::GetColumnPosition(wxDataViewColumn const* columnPtr) const
872 {
873 if (columnPtr != NULL)
874 {
875 DataBrowserTableViewColumnIndex Position;
876
877 wxCHECK_MSG(this->GetColumnIndex(columnPtr->GetNativeData()->GetPropertyID(),&Position) == noErr,wxNOT_FOUND,_("Could not determine column's position"));
878 return static_cast<int>(Position);
879 }
880 else
881 return wxNOT_FOUND;
882 }
883
884 bool wxMacDataViewDataBrowserListViewControl::InsertColumn(unsigned int pos, wxDataViewColumn* columnPtr)
885 {
886 DataBrowserListViewColumnDesc columnDescription;
887
888 DataBrowserPropertyID newPropertyID;
889
890 UInt32 noOfColumns;
891
892 wxCFStringRef title(columnPtr->GetTitle(),m_font.Ok() ? dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer())->GetFont().GetEncoding() : wxLocale::GetSystemEncoding());
893
894
895 // try to get new ID for the column:
896 wxCHECK_MSG(this->GetFreePropertyID(&newPropertyID) == noErr,false,_("Cannot create new column's ID. Probably max. number of columns reached."));
897 // set native data:
898 columnPtr->GetNativeData()->SetPropertyID(newPropertyID);
899 // create a column description, add column to the native control and do some final layout adjustments:
900 wxCHECK_MSG(::InitializeColumnDescription(columnDescription,columnPtr,title), false,_("Column description could not be initialized."));
901 wxCHECK_MSG(this->AddColumn(&columnDescription,pos) == noErr, false,_("Column could not be added."));
902 wxCHECK_MSG(this->SetColumnWidth(newPropertyID,columnPtr->GetWidth()) == noErr,false,_("Column width could not be set."));
903 wxCHECK_MSG(this->GetColumnCount(&noOfColumns) == noErr, false,_("Number of columns could not be determined."));
904 if (noOfColumns == 1)
905 {
906 wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer()));
907
908 wxCHECK_MSG(dataViewCtrlPtr != NULL,false,_("wxWidget's control not initialized."));
909 dataViewCtrlPtr->AddChildren(wxDataViewItem());
910 return true;
911 }
912 else
913 return this->Update(columnPtr);
914 }
915
916 //
917 // item related methods (inherited from wxDataViewWidgetImpl)
918 //
919 bool wxMacDataViewDataBrowserListViewControl::Add(wxDataViewItem const& parent, wxDataViewItem const& item)
920 {
921 DataBrowserItemID itemID(reinterpret_cast<DataBrowserItemID>(item.GetID()));
922
923
924 return (( parent.IsOk() && this->AddItem(reinterpret_cast<DataBrowserItemID>(parent.GetID()),&itemID) == noErr) ||
925 (!(parent.IsOk()) && this->AddItem(kDataBrowserNoItem,&itemID) == noErr));
926 }
927
928 bool wxMacDataViewDataBrowserListViewControl::Add(wxDataViewItem const& parent, wxDataViewItemArray const& items)
929 {
930 bool noFailureFlag;
931
932 DataBrowserItemID* itemIDs;
933
934 size_t noOfEntries;
935
936
937 // convert all valid data view items to data browser items:
938 itemIDs = ::CreateDataBrowserItemIDArray(noOfEntries,items);
939 // insert all valid items into control:
940 noFailureFlag = ((noOfEntries == 0) ||
941 !(parent.IsOk()) && (this->AddItems(kDataBrowserNoItem,noOfEntries,itemIDs,kDataBrowserItemNoProperty) == noErr) ||
942 parent.IsOk() && (this->AddItems(reinterpret_cast<DataBrowserItemID>(parent.GetID()),noOfEntries,itemIDs,kDataBrowserItemNoProperty) == noErr));
943 // give allocated array space free again:
944 delete[] itemIDs;
945 // done:
946 return noFailureFlag;
947 }
948
949 void wxMacDataViewDataBrowserListViewControl::Collapse(wxDataViewItem const& item)
950 {
951 this->CloseContainer(reinterpret_cast<DataBrowserItemID>(item.GetID()));
952 }
953
954 void wxMacDataViewDataBrowserListViewControl::EnsureVisible(wxDataViewItem const& item, const wxDataViewColumn* columnPtr)
955 {
956 DataBrowserPropertyID propertyID;
957
958
959 if (columnPtr != NULL)
960 propertyID = columnPtr->GetNativeData()->GetPropertyID();
961 else
962 propertyID = kDataBrowserNoItem;
963 this->RevealItem(reinterpret_cast<DataBrowserItemID>(item.GetID()),propertyID,kDataBrowserRevealOnly);
964 }
965
966 void wxMacDataViewDataBrowserListViewControl::Expand(wxDataViewItem const& item)
967 {
968 this->OpenContainer(reinterpret_cast<DataBrowserItemID>(item.GetID()));
969 }
970
971 unsigned int wxMacDataViewDataBrowserListViewControl::GetCount(void) const
972 {
973 ItemCount noOfItems;
974
975
976 wxCHECK_MSG(this->GetItemCount(&noOfItems) == noErr,0,_("Could not determine number of items"));
977 return noOfItems;
978 }
979
980 wxRect wxMacDataViewDataBrowserListViewControl::GetRectangle(wxDataViewItem const& item, wxDataViewColumn const* columnPtr)
981 {
982 Rect MacRectangle;
983
984
985 if (this->GetPartBounds(reinterpret_cast<DataBrowserItemID>(item.GetID()),columnPtr->GetNativeData()->GetPropertyID(),kDataBrowserPropertyContentPart,&MacRectangle) == noErr)
986 {
987 wxRect rectangle;
988
989 ::wxMacNativeToRect(&MacRectangle,&rectangle);
990 return rectangle;
991 }
992 else
993 return wxRect();
994 }
995
996 bool wxMacDataViewDataBrowserListViewControl::IsExpanded(wxDataViewItem const& item) const
997 {
998 DataBrowserItemState state = 0;
999
1000 if (this->GetItemState(reinterpret_cast<DataBrowserItemID>(item.GetID()),&state) != noErr)
1001 return false;
1002
1003 return ((state & kDataBrowserContainerIsOpen) != 0);
1004 }
1005
1006 bool wxMacDataViewDataBrowserListViewControl::Reload(void)
1007 {
1008 bool noFailureFlag;
1009
1010 wxDataViewItemArray dataViewChildren;
1011
1012
1013 noFailureFlag = (this->RemoveItems() == noErr);
1014 this->SetScrollPosition(0,0); // even after having removed all items the scrollbars may remain at their old position -> reset them
1015 this->GetDataViewCtrl()->GetModel()->GetChildren(wxDataViewItem(),dataViewChildren);
1016 this->GetDataViewCtrl()->GetModel()->ItemsAdded(wxDataViewItem(),dataViewChildren);
1017
1018 return noFailureFlag;
1019 }
1020
1021 bool wxMacDataViewDataBrowserListViewControl::Remove(wxDataViewItem const& parent, wxDataViewItem const& item)
1022 {
1023 DataBrowserItemID itemID(reinterpret_cast<DataBrowserItemID>(item.GetID()));
1024
1025
1026 return (this->RemoveItem(reinterpret_cast<DataBrowserItemID>(parent.GetID()),&itemID) == noErr);
1027 }
1028
1029 bool wxMacDataViewDataBrowserListViewControl::Remove(wxDataViewItem const& parent, wxDataViewItemArray const& items)
1030 {
1031 bool noFailureFlag;
1032
1033 DataBrowserItemID* itemIDs;
1034
1035 size_t noOfEntries;
1036
1037
1038 // convert all valid data view items to data browser items:
1039 itemIDs = ::CreateDataBrowserItemIDArray(noOfEntries,items);
1040 // insert all valid items into control:
1041 noFailureFlag = ((noOfEntries == 0) ||
1042 !(parent.IsOk()) && (this->RemoveItems(kDataBrowserNoItem,noOfEntries,itemIDs,kDataBrowserItemNoProperty) == noErr) ||
1043 parent.IsOk() && (this->RemoveItems(reinterpret_cast<DataBrowserItemID>(parent.GetID()),noOfEntries,itemIDs,kDataBrowserItemNoProperty) == noErr));
1044 // give allocated array space free again:
1045 delete[] itemIDs;
1046 // done:
1047 return noFailureFlag;
1048 }
1049
1050 bool wxMacDataViewDataBrowserListViewControl::Update(wxDataViewColumn const* columnPtr)
1051 {
1052 return (this->UpdateItems(kDataBrowserNoItem,0,NULL,kDataBrowserItemNoProperty,columnPtr->GetNativeData()->GetPropertyID()) == noErr);
1053 }
1054
1055 bool wxMacDataViewDataBrowserListViewControl::Update(wxDataViewItem const& parent, wxDataViewItem const& item)
1056 {
1057 DataBrowserItemID itemID(reinterpret_cast<DataBrowserItemID>(item.GetID()));
1058
1059
1060 if (parent.IsOk())
1061 return (this->UpdateItem(reinterpret_cast<DataBrowserItemID>(parent.GetID()),&itemID) == noErr);
1062 else
1063 return (this->UpdateItem(kDataBrowserNoItem,&itemID) == noErr);
1064 }
1065
1066 bool wxMacDataViewDataBrowserListViewControl::Update(wxDataViewItem const& parent, wxDataViewItemArray const& items)
1067 {
1068 bool noFailureFlag;
1069
1070 DataBrowserItemID* itemIDs;
1071
1072 size_t noOfEntries;
1073
1074
1075 // convert all valid data view items to data browser items:
1076 itemIDs = ::CreateDataBrowserItemIDArray(noOfEntries,items);
1077 if (parent.IsOk())
1078 noFailureFlag = (this->UpdateItems(reinterpret_cast<DataBrowserItemID>(parent.GetID()),noOfEntries,itemIDs,kDataBrowserItemNoProperty,kDataBrowserItemNoProperty) == noErr);
1079 else
1080 noFailureFlag = (this->UpdateItems(kDataBrowserNoItem,noOfEntries,itemIDs,kDataBrowserItemNoProperty,kDataBrowserItemNoProperty) == noErr);
1081 // release allocated array space:
1082 delete[] itemIDs;
1083 // done:
1084 return noFailureFlag;
1085 }
1086
1087 //
1088 // model related methods
1089 //
1090 bool wxMacDataViewDataBrowserListViewControl::AssociateModel(wxDataViewModel* WXUNUSED(model))
1091 {
1092 return true;
1093 }
1094
1095 //
1096 // selection related methods (inherited from wxDataViewWidgetImpl)
1097 //
1098 int wxMacDataViewDataBrowserListViewControl::GetSelections(wxDataViewItemArray& sel) const
1099 {
1100 size_t noOfSelectedItems;
1101
1102 wxArrayDataBrowserItemID itemIDs;
1103
1104
1105 noOfSelectedItems = this->GetSelectedItemIDs(itemIDs);
1106 sel.Empty();
1107 sel.SetCount(noOfSelectedItems);
1108 for (size_t i=0; i<noOfSelectedItems; ++i)
1109 sel[i] = wxDataViewItem(reinterpret_cast<void*>(itemIDs[i]));
1110 return static_cast<int>(noOfSelectedItems);
1111 }
1112
1113 bool wxMacDataViewDataBrowserListViewControl::IsSelected(wxDataViewItem const& item) const
1114 {
1115 return this->IsItemSelected(reinterpret_cast<DataBrowserItemID>(item.GetID()));
1116 }
1117
1118 void wxMacDataViewDataBrowserListViewControl::Select(wxDataViewItem const& item)
1119 {
1120 DataBrowserItemID itemID(reinterpret_cast<DataBrowserItemID>(item.GetID()));
1121
1122
1123 this->SetSelectedItems(1,&itemID,kDataBrowserItemsAdd);
1124 }
1125
1126 void wxMacDataViewDataBrowserListViewControl::SelectAll(void)
1127 {
1128 DataBrowserItemID* itemIDPtr;
1129
1130 Handle handle(::NewHandle(0));
1131
1132 size_t noOfItems;
1133
1134
1135 wxCHECK_RET(this->GetItems(kDataBrowserNoItem,true,kDataBrowserItemAnyState,handle) == noErr,_("Could not get items."));
1136 noOfItems = static_cast<size_t>(::GetHandleSize(handle)/sizeof(DataBrowserItemID));
1137 ::HLock(handle);
1138 itemIDPtr = (DataBrowserItemID*) (*handle);
1139 this->SetSelectedItems(noOfItems,itemIDPtr,kDataBrowserItemsAssign);
1140 ::HUnlock(handle);
1141 ::DisposeHandle(handle);
1142 }
1143
1144 void wxMacDataViewDataBrowserListViewControl::Unselect(wxDataViewItem const& item)
1145 {
1146 DataBrowserItemID itemID(reinterpret_cast<DataBrowserItemID>(item.GetID()));
1147
1148
1149 this->SetSelectedItems(1,&itemID,kDataBrowserItemsRemove);
1150 }
1151
1152 void wxMacDataViewDataBrowserListViewControl::UnselectAll(void)
1153 {
1154 DataBrowserItemID* itemIDPtr;
1155
1156 Handle handle(::NewHandle(0));
1157
1158 size_t noOfItems;
1159
1160
1161 wxCHECK_RET(this->GetItems(kDataBrowserNoItem,true,kDataBrowserItemAnyState,handle) == noErr,_("Could not get items."));
1162 noOfItems = static_cast<size_t>(::GetHandleSize(handle)/sizeof(DataBrowserItemID));
1163 ::HLock(handle);
1164 itemIDPtr = (DataBrowserItemID*) (*handle);
1165 this->SetSelectedItems(noOfItems,itemIDPtr,kDataBrowserItemsRemove);
1166 ::HUnlock(handle);
1167 ::DisposeHandle(handle);
1168 }
1169
1170 //
1171 // sorting related methods
1172 //
1173 wxDataViewColumn* wxMacDataViewDataBrowserListViewControl::GetSortingColumn(void) const
1174 {
1175 DataBrowserPropertyID propertyID;
1176
1177
1178 if (this->GetSortProperty(&propertyID) == noErr)
1179 return this->GetColumnPtr(propertyID);
1180 else
1181 return NULL;
1182 }
1183
1184 void wxMacDataViewDataBrowserListViewControl::Resort(void)
1185 {
1186 (void) this->Resort();
1187 }
1188
1189 //
1190 // other methods (inherited from wxDataViewWidgetImpl)
1191 //
1192 void
1193 wxMacDataViewDataBrowserListViewControl::HitTest(const wxPoint& WXUNUSED(point),
1194 wxDataViewItem& item,
1195 wxDataViewColumn*& columnPtr) const
1196 {
1197 // not yet implemented:
1198 item = wxDataViewItem();
1199 columnPtr = NULL;
1200 }
1201
1202 void wxMacDataViewDataBrowserListViewControl::DoSetIndent(int indent)
1203 {
1204 this->SetIndent(static_cast<float>(indent));
1205 }
1206
1207 void wxMacDataViewDataBrowserListViewControl::SetRowHeight(wxDataViewItem const& item, unsigned int height)
1208 {
1209 this->SetItemRowHeight(reinterpret_cast<DataBrowserItemID>(item.GetID()),static_cast<UInt16>(height));
1210 }
1211
1212 void wxMacDataViewDataBrowserListViewControl::OnSize(void)
1213 {
1214 UInt32 noOfColumns;
1215
1216
1217 this->GetColumnCount(&noOfColumns);
1218 if (noOfColumns <= 1) // no horizontal scroll bar and the only column expands to the width of the whole control
1219 {
1220 this->SetHasScrollBars(false,true);
1221 this->AutoSizeColumns();
1222 }
1223 else // otherwise keep the current column size and have scrollbars in both directions
1224 this->SetHasScrollBars(true,true);
1225 }
1226
1227 //
1228 // callback functions (inherited from wxMacDataBrowserTableViewControl)
1229 //
1230 Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserCompareProc(DataBrowserItemID itemOneID, DataBrowserItemID itemTwoID, DataBrowserPropertyID sortProperty)
1231 {
1232 DataBrowserSortOrder sortOrder;
1233
1234 DataBrowserTableViewColumnIndex modelColumnIndex;
1235
1236 wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer()));
1237
1238
1239 wxCHECK_MSG(dataViewCtrlPtr != NULL, false,_("Pointer to data view control not set correctly."));
1240 wxCHECK_MSG(dataViewCtrlPtr->GetModel() != NULL,false,_("Pointer to model not set correctly."));
1241 if (sortProperty >= kMinPropertyID)
1242 {
1243 // variable definition and initialization:
1244 wxDataViewColumn* ColumnPtr(this->GetColumnPtr(sortProperty));
1245
1246 wxCHECK_MSG(ColumnPtr != NULL,false,_("Could not determine column index."));
1247 modelColumnIndex = ColumnPtr->GetModelColumn();
1248 }
1249 else
1250 modelColumnIndex = 0;
1251 this->GetSortOrder(&sortOrder);
1252 return static_cast<Boolean>(dataViewCtrlPtr->GetModel()->Compare(wxDataViewItem(reinterpret_cast<void*>(itemOneID)),wxDataViewItem(reinterpret_cast<void*>(itemTwoID)),
1253 modelColumnIndex,sortOrder != kDataBrowserOrderDecreasing) < 0);
1254 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserCompareProc(DataBrowserItemID, DataBrowserItemID, DataBrowserPropertyID) */
1255
1256 void wxMacDataViewDataBrowserListViewControl::DataBrowserGetContextualMenuProc(MenuRef* menu, UInt32* helpType, CFStringRef* helpItemString, AEDesc* WXUNUSED(selection))
1257 // In this method we do not supply a contextual menu handler at all but only send a wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU.
1258 {
1259 wxArrayDataBrowserItemID itemIDs;
1260
1261 wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer()));
1262
1263
1264 wxCHECK_RET(dataViewCtrlPtr != NULL,_("wxWidget control pointer is not a data view pointer"));
1265 // initialize parameters so that no context menu will be displayed automatically by the native data browser:
1266 *menu = NULL;
1267 *helpType = kCMHelpItemNoHelp;
1268 *helpItemString = NULL;
1269 // create information for a context menu event:
1270 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU,dataViewCtrlPtr->GetId());
1271
1272 dataViewEvent.SetEventObject(dataViewCtrlPtr);
1273 dataViewEvent.SetModel(dataViewCtrlPtr->GetModel());
1274 // get the item information;
1275 // 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:
1276 if (this->GetSelectedItemIDs(itemIDs) > 0)
1277 dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemIDs[0])));
1278 // finally send the equivalent wxWidget event:
1279 dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
1280 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserGetContextualMenuProc(MenuRef*, UInt32*, CFStringRef*, AEDesc*) */
1281
1282 OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, DataBrowserItemDataRef itemData, Boolean getValue)
1283 {
1284 if (getValue)
1285 {
1286 // variable definitions:
1287 wxDataViewCtrl* dataViewCtrlPtr;
1288
1289 dataViewCtrlPtr = dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer());
1290 wxCHECK_MSG(dataViewCtrlPtr != NULL,errDataBrowserNotConfigured,_("Pointer to data view control not set correctly."));
1291 if (dataViewCtrlPtr->IsDeleting())
1292 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
1293 else
1294 {
1295 // variable definitions:
1296 OSStatus errorStatus;
1297 wxDataViewColumn* dataViewColumnPtr;
1298
1299 wxCHECK_MSG(dataViewCtrlPtr->GetModel() != NULL,errDataBrowserNotConfigured,_("Pointer to model not set correctly."));
1300 dataViewColumnPtr = this->GetColumnPtr(propertyID);
1301 wxCHECK_MSG((dataViewColumnPtr != NULL) && (dataViewColumnPtr->GetRenderer() != NULL),errDataBrowserNotConfigured,_("There is no column or renderer for the specified column index."));
1302
1303 wxDataViewItem dvItem(reinterpret_cast<void*>(itemID));
1304 unsigned int col = dataViewColumnPtr->GetModelColumn();
1305
1306 switch (dataViewColumnPtr->GetRenderer()->GetNativeData()->GetPropertyType())
1307 {
1308 case kDataBrowserCheckboxType:
1309 {
1310 // variable definition:
1311 ThemeButtonValue buttonValue;
1312
1313 errorStatus = ::GetDataBrowserItemDataButtonValue(itemData,&buttonValue);
1314 if (errorStatus == noErr)
1315 {
1316 if (buttonValue == kThemeButtonOn)
1317 {
1318 // variable definition and initialization:
1319 wxVariant modifiedData(true);
1320
1321 if (dataViewCtrlPtr->GetModel()->SetValue(modifiedData, dvItem, col) &&
1322 dataViewCtrlPtr->GetModel()->ValueChanged(dvItem, col))
1323 return noErr;
1324 else
1325 return errDataBrowserInvalidPropertyData;
1326 }
1327 else if (buttonValue == kThemeButtonOff)
1328 {
1329 // variable definition and initialization:
1330 wxVariant modifiedData(false);
1331
1332 if (dataViewCtrlPtr->GetModel()->SetValue(modifiedData, dvItem, col) &&
1333 dataViewCtrlPtr->GetModel()->ValueChanged(dvItem, col))
1334 return noErr;
1335 else
1336 return errDataBrowserInvalidPropertyData;
1337 }
1338 else
1339 return errDataBrowserInvalidPropertyData;
1340 }
1341 else
1342 return errorStatus;
1343 } /* block */
1344 case kDataBrowserTextType:
1345 {
1346 // variable definitions:
1347 CFStringRef stringReference;
1348
1349 errorStatus = ::GetDataBrowserItemDataText(itemData,&stringReference);
1350 if (errorStatus == noErr)
1351 {
1352 // variable definitions and initializations:
1353 #if wxCHECK_VERSION(2,9,0)
1354 wxCFStringRef modifiedString(stringReference);
1355 #else
1356 wxMacCFStringHolder modifiedString(stringReference);
1357 #endif
1358 wxVariant modifiedData(modifiedString.AsString());
1359
1360 if (dataViewCtrlPtr->GetModel()->SetValue(modifiedData, dvItem, col) &&
1361 dataViewCtrlPtr->GetModel()->ValueChanged(dvItem, col))
1362 return noErr;
1363 else
1364 return errDataBrowserInvalidPropertyData;
1365 }
1366 else
1367 return errorStatus;
1368 } /* block */
1369 default:
1370 return errDataBrowserPropertyNotSupported;
1371 }
1372 }
1373 }
1374 else
1375 {
1376 if (propertyID >= kMinPropertyID) // in case data columns set the data
1377 {
1378 // variable definitions:
1379 wxVariant variant;
1380 wxDataViewColumn* dataViewColumnPtr;
1381 wxDataViewCtrl* dataViewCtrlPtr;
1382
1383 dataViewCtrlPtr = dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer());
1384 wxCHECK_MSG(dataViewCtrlPtr != NULL,errDataBrowserNotConfigured,_("Pointer to data view control not set correctly."));
1385 wxCHECK_MSG(dataViewCtrlPtr->GetModel() != NULL,errDataBrowserNotConfigured,_("Pointer to model not set correctly."));
1386 dataViewColumnPtr = this->GetColumnPtr(propertyID);
1387 wxCHECK_MSG(dataViewColumnPtr != NULL,errDataBrowserNotConfigured,_("No column for the specified column position existing."));
1388 wxCHECK_MSG(dataViewColumnPtr->GetRenderer() != NULL,errDataBrowserNotConfigured,_("No renderer specified for column."));
1389 dataViewCtrlPtr->GetModel()->GetValue(variant,wxDataViewItem(reinterpret_cast<void*>(itemID)),dataViewColumnPtr->GetModelColumn());
1390 if (!(variant.IsNull()))
1391 {
1392 dataViewColumnPtr->GetRenderer()->GetNativeData()->SetItemDataRef(itemData);
1393 dataViewColumnPtr->GetRenderer()->SetValue(variant);
1394 wxCHECK_MSG(dataViewColumnPtr->GetRenderer()->MacRender(),errDataBrowserNotConfigured,_("Rendering failed."));
1395 }
1396 return noErr;
1397 }
1398 else // react on special system requests
1399 {
1400 switch (propertyID)
1401 {
1402 case kDataBrowserContainerIsClosableProperty:
1403 {
1404 // variable definitions:
1405 wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer()));
1406
1407 wxCHECK_MSG(dataViewCtrlPtr != NULL,errDataBrowserNotConfigured,_("Pointer to data view control not set correctly."));
1408 // initialize wxWidget event:
1409 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING,dataViewCtrlPtr->GetId()); // variable definition
1410
1411 dataViewEvent.SetEventObject(dataViewCtrlPtr);
1412 dataViewEvent.SetItem (wxDataViewItem(reinterpret_cast<void*>(itemID)));
1413 dataViewEvent.SetModel (dataViewCtrlPtr->GetModel());
1414 // finally send the equivalent wxWidget event:
1415 dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
1416 // opening the container is allowed if not vetoed:
1417 return ::SetDataBrowserItemDataBooleanValue(itemData,dataViewEvent.IsAllowed());
1418 } /* block */
1419 case kDataBrowserContainerIsOpenableProperty:
1420 {
1421 // variable definitions:
1422 wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer()));
1423
1424 wxCHECK_MSG(dataViewCtrlPtr != NULL,errDataBrowserNotConfigured,_("Pointer to data view control not set correctly."));
1425 // initialize wxWidget event:
1426 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING,dataViewCtrlPtr->GetId()); // variable definition
1427
1428 dataViewEvent.SetEventObject(dataViewCtrlPtr);
1429 dataViewEvent.SetItem (wxDataViewItem(reinterpret_cast<void*>(itemID)));
1430 dataViewEvent.SetModel (dataViewCtrlPtr->GetModel());
1431 // finally send the equivalent wxWidget event:
1432 dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
1433 // opening the container is allowed if not vetoed:
1434 return ::SetDataBrowserItemDataBooleanValue(itemData,dataViewEvent.IsAllowed());
1435 } /* block */
1436 case kDataBrowserItemIsContainerProperty:
1437 {
1438 // variable definition:
1439 wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer()));
1440
1441 wxCHECK_MSG(dataViewCtrlPtr != NULL,errDataBrowserNotConfigured,_("Pointer to data view control not set correctly."));
1442 wxCHECK_MSG(dataViewCtrlPtr->GetModel() != NULL,errDataBrowserNotConfigured,_("Pointer to model not set correctly."));
1443 return ::SetDataBrowserItemDataBooleanValue(itemData,dataViewCtrlPtr->GetModel()->IsContainer(wxDataViewItem(reinterpret_cast<void*>(itemID))));
1444 } /* block */
1445 case kDataBrowserItemIsEditableProperty:
1446 return ::SetDataBrowserItemDataBooleanValue(itemData,true);
1447 }
1448 }
1449 }
1450 return errDataBrowserPropertyNotSupported;
1451 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemDataRef, Boolean) */
1452
1453 void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(DataBrowserItemID itemID, DataBrowserItemNotification message, DataBrowserItemDataRef itemData)
1454 {
1455 wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer()));
1456
1457
1458 // 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:
1459 if (dataViewCtrlPtr != NULL)
1460 switch (message)
1461 {
1462 case kDataBrowserContainerClosed:
1463 dataViewCtrlPtr->FinishCustomItemEditing(); // stop editing of a custom item first (if necessary)
1464 {
1465 // initialize wxWidget event:
1466 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED,dataViewCtrlPtr->GetId()); // variable definition
1467
1468 dataViewEvent.SetEventObject(dataViewCtrlPtr);
1469 dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID)));
1470 // finally send the equivalent wxWidget event:
1471 dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
1472 } /* block */
1473 break;
1474 case kDataBrowserContainerOpened:
1475 dataViewCtrlPtr->FinishCustomItemEditing(); // stop editing of a custom item first (if necessary)
1476 {
1477 // initialize wxWidget event:
1478 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED,dataViewCtrlPtr->GetId()); // variable definition
1479
1480 dataViewEvent.SetEventObject(dataViewCtrlPtr);
1481 dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID)));
1482 // finally send the equivalent wxWidget event:
1483 dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
1484 // add children to the expanded container:
1485 dataViewCtrlPtr->AddChildren(wxDataViewItem(reinterpret_cast<void*>(itemID)));
1486 } /* block */
1487 break;
1488 case kDataBrowserEditStarted:
1489 dataViewCtrlPtr->FinishCustomItemEditing(); // stop editing of a custom item first (if necessary)
1490 {
1491 // initialize wxWidget event:
1492 DataBrowserPropertyID propertyID;
1493 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED,dataViewCtrlPtr->GetId()); // variable definition
1494
1495 dataViewEvent.SetEventObject(dataViewCtrlPtr);
1496 dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID)));
1497 if (this->GetPropertyID(itemData,&propertyID) == noErr)
1498 {
1499 // variable definition and initialization:
1500 DataBrowserTableViewColumnIndex columnIndex;
1501
1502 wxCHECK_RET(this->GetColumnIndex(propertyID,&columnIndex),_("Column index not found."));
1503 dataViewEvent.SetColumn(columnIndex);
1504 dataViewEvent.SetDataViewColumn(this->GetColumnPtr(propertyID));
1505 }
1506 // finally send the equivalent wxWidget event:
1507 dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
1508 } /* block */
1509 break;
1510 case kDataBrowserEditStopped:
1511 {
1512 // initialize wxWidget event:
1513 DataBrowserPropertyID propertyID;
1514 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE,dataViewCtrlPtr->GetId()); // variable definition
1515
1516 dataViewEvent.SetEventObject(dataViewCtrlPtr);
1517 dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID)));
1518 if (this->GetPropertyID(itemData,&propertyID) == noErr)
1519 {
1520 // variable definition and initialization:
1521 DataBrowserTableViewColumnIndex columnIndex;
1522
1523 wxCHECK_RET(this->GetColumnIndex(propertyID,&columnIndex),_("Column index not found."));
1524 dataViewEvent.SetColumn(columnIndex);
1525 dataViewEvent.SetDataViewColumn(this->GetColumnPtr(propertyID));
1526 }
1527 // finally send the equivalent wxWidget event:
1528 dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
1529 } /* block */
1530 break;
1531 case kDataBrowserItemAdded:
1532 dataViewCtrlPtr->FinishCustomItemEditing();
1533 break;
1534 case kDataBrowserItemDeselected:
1535 dataViewCtrlPtr->FinishCustomItemEditing();
1536 break;
1537 case kDataBrowserItemDoubleClicked:
1538 {
1539 // initialize wxWidget event:
1540 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED,dataViewCtrlPtr->GetId()); // variable definition
1541
1542 dataViewEvent.SetEventObject(dataViewCtrlPtr);
1543 dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID)));
1544 // finally send the equivalent wxWidget event:
1545 dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
1546 } /* block */
1547 break;
1548 case kDataBrowserItemRemoved:
1549 dataViewCtrlPtr->FinishCustomItemEditing(); // stop editing of a custom item first (if necessary)
1550 break;
1551 case kDataBrowserItemSelected:
1552 break; // not implemented by wxWidgets; see kDataBrowserSelectionSetChanged
1553 case kDataBrowserSelectionSetChanged:
1554 {
1555 // initialize wxWidget event:
1556 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED,dataViewCtrlPtr->GetId()); // variable definition
1557
1558 dataViewEvent.SetEventObject(dataViewCtrlPtr);
1559 dataViewEvent.SetModel (dataViewCtrlPtr->GetModel());
1560 // finally send the equivalent wxWidget event:
1561 dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
1562 } /* block */
1563 break;
1564 case kDataBrowserTargetChanged: // no idea if this notification is ever sent
1565 break;
1566 case kDataBrowserUserStateChanged:
1567 {
1568 // finish custom item editing if necessary:
1569 dataViewCtrlPtr->FinishCustomItemEditing();
1570 // update column widths:
1571 for (size_t i=0; i<dataViewCtrlPtr->GetColumnCount(); ++i)
1572 {
1573 // constant definition for abbreviational purposes:
1574 wxDataViewColumn* const columnPtr = dataViewCtrlPtr->GetColumnPtr(i);
1575 // variable definition:
1576 UInt16 columnWidth;
1577
1578 wxCHECK_RET(this->GetColumnWidth(columnPtr->GetNativeData()->GetPropertyID(),&columnWidth) == noErr,_("Column width could not be determined"));
1579 columnPtr->SetWidthVariable(columnWidth);
1580 }
1581 // update sorting orders:
1582 DataBrowserPropertyID propertyID; // variable definition
1583
1584 if ((this->GetSortProperty(&propertyID) == noErr) && (propertyID >= kMinPropertyID))
1585 {
1586 DataBrowserSortOrder sortOrder;
1587 DataBrowserTableViewColumnIndex columnIndex;
1588
1589 if ((this->GetSortOrder(&sortOrder) == noErr) && (this->GetColumnIndex(propertyID,&columnIndex) == noErr))
1590 {
1591 // variable definition and initialization:
1592 wxDataViewColumn* columnPtr;
1593 columnPtr = dataViewCtrlPtr->GetColumn(columnIndex);
1594 // check if the sort order has changed:
1595 if ( columnPtr->IsSortOrderAscending() && (sortOrder == kDataBrowserOrderDecreasing) ||
1596 !(columnPtr->IsSortOrderAscending()) && (sortOrder == kDataBrowserOrderIncreasing))
1597 {
1598 columnPtr->SetSortOrder(!(columnPtr->IsSortOrderAscending()));
1599 // initialize wxWidget event:
1600 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED,dataViewCtrlPtr->GetId()); // variable defintion
1601
1602 dataViewEvent.SetEventObject(dataViewCtrlPtr);
1603 dataViewEvent.SetColumn(columnIndex);
1604 dataViewEvent.SetDataViewColumn(columnPtr);
1605 // finally send the equivalent wxWidget event:
1606 dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
1607 }
1608 }
1609 }
1610 } /* block */
1611 break;
1612 }
1613 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(DataBrowserItemID, DataBrowserItemNotification, DataBrowserItemDataRef) */
1614
1615 void
1616 wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowserItemID itemID,
1617 DataBrowserPropertyID propertyID,
1618 DataBrowserItemState state,
1619 Rect const* rectangle,
1620 SInt16 WXUNUSED(bitDepth),
1621 Boolean WXUNUSED(colorDevice))
1622 {
1623 DataBrowserTableViewColumnIndex columnIndex;
1624
1625 wxDataViewColumn* dataViewColumnPtr;
1626
1627 wxDataViewCtrl* dataViewCtrlPtr;
1628
1629 wxDataViewCustomRenderer* dataViewCustomRendererPtr;
1630
1631 wxVariant dataToRender;
1632
1633 dataViewCtrlPtr = dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer());
1634 wxCHECK_RET(dataViewCtrlPtr != NULL, _("Pointer to data view control not set correctly."));
1635 wxCHECK_RET(dataViewCtrlPtr->GetModel() != NULL, _("Pointer to model not set correctly."));
1636 wxCHECK_RET(this->GetColumnIndex(propertyID,&columnIndex) == noErr,_("Could not determine column index."));
1637 dataViewColumnPtr = this->GetColumnPtr(propertyID);
1638 wxCHECK_RET(dataViewColumnPtr != NULL,_("No column for the specified column existing."));
1639 dataViewCustomRendererPtr = dynamic_cast<wxDataViewCustomRenderer*>(dataViewColumnPtr->GetRenderer());
1640 wxCHECK_RET(dataViewCustomRendererPtr != NULL,_("No renderer or invalid renderer type specified for custom data column."));
1641 dataViewCtrlPtr->GetModel()->GetValue(dataToRender,wxDataViewItem(reinterpret_cast<void*>(itemID)),dataViewColumnPtr->GetModelColumn());
1642 dataViewCustomRendererPtr->SetValue(dataToRender);
1643
1644 wxDataViewItem dataItem( reinterpret_cast<void*>(itemID) );
1645 dataViewCtrlPtr->GetModel()->GetValue(dataToRender,dataItem,dataViewColumnPtr->GetModelColumn());
1646 dataViewCustomRendererPtr->SetValue(dataToRender);
1647
1648 // try to determine the content's size (drawable part):
1649 Rect content;
1650 RgnHandle rgn(NewRgn());
1651 UInt16 headerHeight;
1652
1653 if (GetControlRegion(m_controlRef,kControlContentMetaPart,rgn) == noErr)
1654 GetRegionBounds(rgn,&content);
1655 else
1656 GetControlBounds(m_controlRef, &content);
1657 ::DisposeRgn(rgn);
1658 // space for the header
1659 this->GetHeaderButtonHeight(&headerHeight);
1660 content.top += headerHeight;
1661 // extra space for the frame (todo: do not how to determine the space automatically from the control)
1662 content.top += 5;
1663 content.left += 5;
1664 content.right -= 3;
1665 content.bottom -= 3;
1666 // extra space for the scrollbars:
1667 content.bottom -= wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y);
1668 content.right -= wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
1669
1670 wxDC *dc = dataViewCustomRendererPtr->GetDC();
1671
1672 int active_border_fudge = 0;
1673 if (dataViewCtrlPtr->HasFocus() && !dataViewCtrlPtr->HasFlag( wxBORDER_NONE ))
1674 active_border_fudge = 1;
1675 else
1676 active_border_fudge = -2;
1677
1678 wxRect cellrect( static_cast<int>(rectangle->left + active_border_fudge),
1679 static_cast<int>(rectangle->top + active_border_fudge),
1680 static_cast<int>(1+rectangle->right-rectangle->left),
1681 static_cast<int>(rectangle->bottom-rectangle->top) );
1682
1683 bool is_active = IsControlActive( this->m_controlRef );
1684 if (state == kDataBrowserItemIsSelected)
1685 {
1686
1687 wxColour col( wxMacCreateCGColorFromHITheme( (is_active) ?
1688 kThemeBrushAlternatePrimaryHighlightColor
1689 : kThemeBrushSecondaryHighlightColor ) );
1690
1691 wxRect rect = cellrect;
1692 Rect itemrect;
1693 GetDataBrowserItemPartBounds( this->m_controlRef, itemID, propertyID,
1694 kDataBrowserPropertyEnclosingPart, &itemrect );
1695 rect.x = itemrect.left-2;
1696 rect.width = itemrect.right-itemrect.left+3;
1697
1698 wxBrush selBrush( col );
1699 wxPen oldpen( dc->GetPen() );
1700 wxBrush oldbrush( dc->GetBrush() );
1701 dc->SetPen( *wxTRANSPARENT_PEN );
1702 dc->SetBrush( selBrush );
1703 dc->DrawRectangle(rect);
1704 dc->SetBrush( oldbrush );
1705 dc->SetPen( oldpen );
1706 }
1707
1708 wxDataViewModel *model = dataViewCtrlPtr->GetModel();
1709 if ((columnIndex == 0) || !model->IsContainer(dataItem) || model->HasContainerColumns(dataItem))
1710 {
1711 // make sure that 'Render' can draw only in the allowed area:
1712 dc->SetClippingRegion(content.left,content.top,content.right-content.left+1,content.bottom-content.top+1);
1713 (void) (dataViewCustomRendererPtr->Render( cellrect, dc,
1714 ((state == kDataBrowserItemIsSelected) ? wxDATAVIEW_CELL_SELECTED : 0)));
1715 dc->DestroyClippingRegion(); // probably not necessary
1716 }
1717
1718 dataViewCustomRendererPtr->SetDC(NULL);
1719 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemState, Rect const*, SInt16, Boolean) */
1720
1721 Boolean
1722 wxMacDataViewDataBrowserListViewControl::DataBrowserEditItemProc(
1723 DataBrowserItemID WXUNUSED(itemID),
1724 DataBrowserPropertyID WXUNUSED(propertyID),
1725 CFStringRef WXUNUSED(theString),
1726 Rect* WXUNUSED(maxEditTextRect),
1727 Boolean* WXUNUSED(shrinkToFit))
1728 {
1729 return false;
1730 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserEditItemProc(DataBrowserItemID, DataBrowserPropertyID, CFStringRef, Rect*, Boolean*) */
1731
1732 Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserHitTestProc(DataBrowserItemID WXUNUSED(itemID), DataBrowserPropertyID WXUNUSED(property), Rect const* WXUNUSED(theRect), Rect const* WXUNUSED(mouseRect))
1733 {
1734 return true;
1735 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserHitTestProc(DataBrowserItemID, DataBrowserPropertyID, Rect const*, Rect const*) */
1736
1737 DataBrowserTrackingResult wxMacDataViewDataBrowserListViewControl::DataBrowserTrackingProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, Rect const* theRect, Point WXUNUSED(startPt), EventModifiers WXUNUSED(modifiers))
1738 {
1739 wxDataViewColumn* dataViewColumnPtr;
1740
1741 wxDataViewCtrl* dataViewCtrlPtr;
1742
1743 wxDataViewCustomRenderer* dataViewCustomRendererPtr;
1744
1745 wxDataViewItem dataViewCustomRendererItem;
1746
1747
1748 dataViewCtrlPtr = dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer());
1749 wxCHECK_MSG(dataViewCtrlPtr != NULL, false,_("Pointer to data view control not set correctly."));
1750 wxCHECK_MSG(dataViewCtrlPtr->GetModel() != NULL,false,_("Pointer to model not set correctly."));
1751 dataViewCustomRendererItem = reinterpret_cast<void*>(itemID);
1752 wxCHECK_MSG(dataViewCustomRendererItem.IsOk(),kDataBrowserNothingHit,_("Invalid data view item"));
1753 dataViewColumnPtr = this->GetColumnPtr(propertyID);
1754 wxCHECK_MSG(dataViewColumnPtr != NULL,kDataBrowserNothingHit,_("No column existing."));
1755 dataViewCustomRendererPtr = dynamic_cast<wxDataViewCustomRenderer*>(dataViewColumnPtr->GetRenderer());
1756 wxCHECK_MSG(dataViewCustomRendererPtr != NULL,kDataBrowserNothingHit,_("No renderer or invalid renderer type specified for custom data column."));
1757 // 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):
1758 if (dataViewCtrlPtr->GetCustomRendererItem() == dataViewCustomRendererItem)
1759 return kDataBrowserContentHit;
1760 // an(other) item is going to be edited and therefore the current editing - if existing - has to be finished:
1761 if (dataViewCtrlPtr->GetCustomRendererPtr() != NULL)
1762 {
1763 dataViewCtrlPtr->GetCustomRendererPtr()->FinishEditing();
1764 dataViewCtrlPtr->SetCustomRendererItem(wxDataViewItem());
1765 dataViewCtrlPtr->SetCustomRendererPtr (NULL);
1766 }
1767 // check if renderer has got a valid editor control for editing; if this is the case start editing of the new item:
1768 if (dataViewCustomRendererPtr->HasEditorCtrl())
1769 {
1770 // variable definition:
1771 wxRect wxRectangle;
1772
1773 ::wxMacNativeToRect(theRect,&wxRectangle);
1774 dataViewCustomRendererPtr->StartEditing(dataViewCustomRendererItem,wxRectangle);
1775 dataViewCtrlPtr->SetCustomRendererItem(dataViewCustomRendererItem);
1776 dataViewCtrlPtr->SetCustomRendererPtr (dataViewCustomRendererPtr);
1777 }
1778 return kDataBrowserContentHit;
1779 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserTrackingProc(DataBrowserItemID, DataBrowserPropertyID, Rect const*, Point, EventModifiers) */
1780
1781 Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserAcceptDragProc(DragReference dragRef, DataBrowserItemID itemID)
1782 {
1783 bool acceptDrag;
1784
1785 UInt16 noOfDraggedItems;
1786
1787 wxDataViewCtrl* dataViewCtrlPtr;
1788
1789
1790 dataViewCtrlPtr = dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer());
1791 wxCHECK_MSG(dataViewCtrlPtr != NULL, false,_("Pointer to data view control not set correctly."));
1792 wxCHECK_MSG(dataViewCtrlPtr->GetModel() != NULL,false,_("Pointer to model not set correctly."));
1793
1794 // send a drag possible event for each available and item und proceed with it unless the event is vetoed:
1795 ::CountDragItems(dragRef,&noOfDraggedItems);
1796 for (UInt16 indexDraggedItem=1; indexDraggedItem<=noOfDraggedItems; ++indexDraggedItem)
1797 {
1798 // collect native information:
1799 ItemReference itemRef;
1800 wxDataObjectComposite* dataObjects;
1801 wxMemoryBuffer buffer;
1802
1803 ::GetDragItemReferenceNumber(dragRef,indexDraggedItem,&itemRef); // the index begins with 1!
1804 dataObjects = this->GetDnDDataObjects(dragRef,itemRef);
1805 // create wxWidget's event:
1806 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE,dataViewCtrlPtr->GetId());
1807
1808 dataViewEvent.SetEventObject(dataViewCtrlPtr);
1809 dataViewEvent.SetItem(reinterpret_cast<void*>(itemID)); // this is the item that receives the event
1810 // (can be an invalid item ID, this is especially useful if the dataview does not contain any items)
1811 dataViewEvent.SetModel(dataViewCtrlPtr->GetModel());
1812 dataViewEvent.SetDataObject(dataObjects);
1813 dataViewEvent.SetDataFormat(this->GetDnDDataFormat(dataObjects));
1814 if (dataViewEvent.GetDataFormat().GetType() != wxDF_INVALID)
1815 {
1816 dataViewEvent.SetDataSize(dataObjects->GetDataSize(dataViewEvent.GetDataFormat().GetType()));
1817 dataObjects->GetDataHere(dataViewEvent.GetDataFormat().GetType(),buffer.GetWriteBuf(dataViewEvent.GetDataSize()));
1818 buffer.UngetWriteBuf(dataViewEvent.GetDataSize());
1819 dataViewEvent.SetDataBuffer(buffer.GetData());
1820 }
1821
1822 // send event:
1823 acceptDrag = dataViewCtrlPtr->HandleWindowEvent(dataViewEvent) && dataViewEvent.IsAllowed();
1824 delete dataObjects;
1825 if (!acceptDrag)
1826 return false;
1827 }
1828 return true;
1829 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserAcceptDragProc(DragReference, DataBrowserItemID) */
1830
1831 Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserAddDragItemProc(DragReference dragRef, DataBrowserItemID itemID, ItemReference* itemRef)
1832 {
1833 Boolean addDragItem;
1834
1835 wxDataViewCtrl* dataViewCtrlPtr;
1836
1837 wxDataViewItem dataViewItem;
1838
1839
1840 dataViewCtrlPtr = dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer());
1841 wxCHECK_MSG(dataViewCtrlPtr != NULL, false,_("Pointer to data view control not set correctly."));
1842 wxCHECK_MSG(dataViewCtrlPtr->GetModel() != NULL,false,_("Pointer to model not set correctly."));
1843 dataViewItem = reinterpret_cast<void*>(itemID);
1844 wxCHECK_MSG(dataViewItem.IsOk(),false,_("Invalid data view item"));
1845
1846 // send a begin drag event and proceed with dragging unless the event is vetoed:
1847 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG,dataViewCtrlPtr->GetId());
1848
1849 dataViewEvent.SetEventObject(dataViewCtrlPtr);
1850 dataViewEvent.SetItem(dataViewItem);
1851 dataViewEvent.SetModel(dataViewCtrlPtr->GetModel());
1852 // the dataview event object is also initialized with a default set of data; as it is a set of data and the user should be able to easily complete
1853 // the object a wxDataObjectComposite object is used;
1854 // currently, the composite object only contains a TAB concatenated string of all data:
1855 wxDataObjectComposite* dataObject(new wxDataObjectComposite());
1856
1857 dataObject->Add(new wxTextDataObject(::ConcatenateDataViewItemValues(dataViewCtrlPtr,dataViewItem)));
1858 dataViewEvent.SetDataObject(dataObject);
1859 // check if event has not been vetoed:
1860 addDragItem = dataViewCtrlPtr->HandleWindowEvent(dataViewEvent) && dataViewEvent.IsAllowed();
1861 if (addDragItem)
1862 {
1863 // for the internal drag & drop functions create two flavors:
1864 // - the data browser's item id;
1865 // - the data contained the dataview event object (if available).
1866 // Definition: a flavor is the type dependent representation of identical data.
1867 // Example: a number can be represented by its value and by its value converted to a string. In this case the flavor
1868 // of the number's internal representation is typeSInt32 while its string representation has got the flavor 'TEXT'.
1869 // Item id is one of the flavors:
1870 wxCHECK_MSG(::AddDragItemFlavor(dragRef,*itemRef,typeUInt32,&itemID,sizeof(itemID),0) == noErr,false,_("Unable to handle native drag&drop data"));
1871 // if the dataview event object contains data it is used for additional flavors; all natively known flavors are supported:
1872 if (dataViewEvent.GetDataObject() != NULL)
1873 {
1874 // constant definition for abbreviational purposes:
1875 size_t const noOfFormats = dataViewEvent.GetDataObject()->GetFormatCount();
1876
1877 if (noOfFormats > 0)
1878 {
1879 // variable definition:
1880 wxDataFormat* dataFormats;
1881
1882 dataFormats = new wxDataFormat[noOfFormats];
1883 dataViewEvent.GetDataObject()->GetAllFormats(dataFormats,wxDataObject::Get);
1884 for (size_t i=0; i<noOfFormats; ++i)
1885 switch (dataFormats[i].GetType())
1886 {
1887 case wxDF_INVALID:
1888 wxFAIL_MSG(_("Data object has invalid data format"));
1889 break;
1890 case wxDF_TEXT:
1891 {
1892 // constant definition for abbreviational purposes:
1893 size_t const dataSize = dataViewEvent.GetDataObject()->GetDataSize(wxDF_TEXT);
1894 // variable definition and initialization:
1895 wxMemoryBuffer dataObject(dataSize);
1896
1897 dataViewEvent.GetDataObject()->GetDataHere(wxDF_TEXT,dataObject.GetWriteBuf(dataSize));
1898 dataObject.UngetWriteBuf(dataSize);
1899 if (::AddDragItemFlavor(dragRef,*itemRef,'TEXT',dataObject.GetData(),dataSize,0) != noErr)
1900 wxFAIL_MSG(_("Adding flavor TEXT failed"));
1901 } /* block */
1902 break;
1903 case wxDF_UNICODETEXT:
1904 {
1905 // constant definition for abbreviational purposes:
1906 size_t const dataSize = dataViewEvent.GetDataObject()->GetDataSize(wxDF_TEXT);
1907 // as there is no direct access to the data copy it to a memory buffer:
1908 wxMemoryBuffer dataObject(dataSize);
1909
1910 dataViewEvent.GetDataObject()->GetDataHere(wxDF_TEXT,dataObject.GetWriteBuf(dataSize));
1911 dataObject.UngetWriteBuf(dataSize);
1912 // if the data is stored in unicode format the internal representation is utf-8 (not mentioned in the documentation but in the source code);
1913 // DnD uses fixed utf-16 representation -> use the OSX functions for a conversion:
1914 CFDataRef osxData (::CFDataCreateWithBytesNoCopy(kCFAllocatorDefault,reinterpret_cast<UInt8*>(dataObject.GetData()),dataSize,kCFAllocatorNull));
1915 CFStringRef osxString(::CFStringCreateFromExternalRepresentation(kCFAllocatorDefault,osxData,kCFStringEncodingUTF8));
1916
1917 // the osxString contains now the data and therefore the previously occupied memory can be released and re-used:
1918 ::CFRelease(osxData);
1919 osxData = ::CFStringCreateExternalRepresentation(kCFAllocatorDefault,osxString,kCFStringEncodingUTF16,32);
1920 if (::AddDragItemFlavor(dragRef,*itemRef,'utxt',::CFDataGetBytePtr(osxData),::CFDataGetLength(osxData),0) != noErr)
1921 wxFAIL_MSG(_("Adding flavor utxt failed"));
1922 // clean up:
1923 ::CFRelease(osxData);
1924 ::CFRelease(osxString);
1925 } /* block */
1926 break;
1927 case wxDF_BITMAP:
1928 case wxDF_METAFILE:
1929 case wxDF_SYLK:
1930 case wxDF_DIF:
1931 case wxDF_TIFF:
1932 case wxDF_OEMTEXT:
1933 case wxDF_DIB:
1934 case wxDF_PALETTE:
1935 case wxDF_PENDATA:
1936 case wxDF_RIFF:
1937 case wxDF_WAVE:
1938 case wxDF_ENHMETAFILE:
1939 case wxDF_FILENAME:
1940 case wxDF_LOCALE:
1941 case wxDF_PRIVATE:
1942 case wxDF_HTML:
1943 break; // not (yet) supported data formats
1944 default:
1945 wxFAIL_MSG(_("Unknown data format"));
1946 }
1947 delete[] dataFormats;
1948 }
1949 }
1950 }
1951 // clean-up and return result:
1952 delete dataObject;
1953 return addDragItem;
1954 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserAddDragItemProc(DragReference, DataBrowserItemID, ItemReference*) */
1955
1956 Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserReceiveDragProc(DragReference dragRef, DataBrowserItemID itemID)
1957 {
1958 UInt16 noOfDraggedItems;
1959
1960 wxDataViewCtrl* dataViewCtrlPtr;
1961
1962
1963 dataViewCtrlPtr = dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer());
1964 wxCHECK_MSG(dataViewCtrlPtr != NULL, false,_("Pointer to data view control not set correctly."));
1965 wxCHECK_MSG(dataViewCtrlPtr->GetModel() != NULL,false,_("Pointer to model not set correctly."));
1966
1967 // send a drag possible event for each available and item und proceed with it unless the event is vetoed:
1968 ::CountDragItems(dragRef,&noOfDraggedItems);
1969 for (UInt16 indexDraggedItem=1; indexDraggedItem<=noOfDraggedItems; ++indexDraggedItem)
1970 {
1971 bool receiveDrag;
1972 ItemReference itemRef;
1973 wxDataObjectComposite* dataObjects;
1974 wxMemoryBuffer buffer;
1975
1976 // collect native information:
1977 ::GetDragItemReferenceNumber(dragRef,indexDraggedItem,&itemRef); // the index begins with 1!
1978 dataObjects = this->GetDnDDataObjects(dragRef,itemRef);
1979 // create wxWidget's event:
1980 wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_DROP,dataViewCtrlPtr->GetId());
1981
1982 dataViewEvent.SetEventObject(dataViewCtrlPtr);
1983 dataViewEvent.SetItem(reinterpret_cast<void*>(itemID)); // this is the item that receives the event
1984 // (can be an invalid item ID, this is especially useful if the dataview does not contain any items)
1985 dataViewEvent.SetModel(dataViewCtrlPtr->GetModel());
1986 dataViewEvent.SetDataObject(dataObjects);
1987 dataViewEvent.SetDataFormat(this->GetDnDDataFormat(dataObjects));
1988 if (dataViewEvent.GetDataFormat().GetType() != wxDF_INVALID)
1989 {
1990 dataViewEvent.SetDataSize(dataObjects->GetDataSize(dataViewEvent.GetDataFormat().GetType()));
1991 dataObjects->GetDataHere(dataViewEvent.GetDataFormat().GetType(),buffer.GetWriteBuf(dataViewEvent.GetDataSize()));
1992 buffer.UngetWriteBuf(dataViewEvent.GetDataSize());
1993 dataViewEvent.SetDataBuffer(buffer.GetData());
1994 }
1995
1996 // send event:
1997 receiveDrag = dataViewCtrlPtr->HandleWindowEvent(dataViewEvent) && dataViewEvent.IsAllowed();
1998 delete dataObjects;
1999 if (!receiveDrag)
2000 return false;
2001 }
2002 return true;
2003 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserReceiveDragProc(DragReference, DataBrowserItemID) */
2004
2005 //
2006 // drag & drop helper methods
2007 //
2008 wxDataFormat wxMacDataViewDataBrowserListViewControl::GetDnDDataFormat(wxDataObjectComposite* dataObjects)
2009 {
2010 wxDataFormat resultFormat;
2011
2012
2013 if (dataObjects != NULL)
2014 {
2015 bool compatible(true);
2016
2017 size_t const noOfFormats = dataObjects->GetFormatCount();
2018 size_t indexFormat;
2019
2020 wxDataFormat* formats;
2021
2022 // get all formats and check afterwards if the formats are compatible; if they are compatible the preferred format is returned otherwise
2023 // wxDF_INVALID is returned;
2024 // currently compatible types (ordered by priority are):
2025 // - wxDF_UNICODETEXT - wxDF_TEXT
2026 formats = new wxDataFormat[noOfFormats];
2027 dataObjects->GetAllFormats(formats);
2028 indexFormat = 0;
2029 while ((indexFormat < noOfFormats) && compatible)
2030 {
2031 switch (resultFormat.GetType())
2032 {
2033 case wxDF_INVALID:
2034 resultFormat.SetType(formats[indexFormat].GetType()); // first format (should only be reached if indexFormat == 0
2035 break;
2036 case wxDF_TEXT:
2037 if (formats[indexFormat].GetType() == wxDF_UNICODETEXT)
2038 resultFormat.SetType(wxDF_UNICODETEXT);
2039 else // incompatible
2040 {
2041 resultFormat.SetType(wxDF_INVALID);
2042 compatible = false;
2043 }
2044 break;
2045 case wxDF_UNICODETEXT:
2046 if (formats[indexFormat].GetType() != wxDF_TEXT)
2047 {
2048 resultFormat.SetType(wxDF_INVALID);
2049 compatible = false;
2050 }
2051 break;
2052 default:
2053 resultFormat.SetType(wxDF_INVALID); // not (yet) supported format
2054 compatible = false;
2055 }
2056 ++indexFormat;
2057 } /* while */
2058 // clean up:
2059 delete[] formats;
2060 }
2061 else
2062 resultFormat = wxDF_INVALID;
2063 return resultFormat;
2064 } /* wxMacDataViewDataBrowserListViewControl::GetDnDDataFormat(wxDataObjectComposite*) */
2065
2066 wxDataObjectComposite* wxMacDataViewDataBrowserListViewControl::GetDnDDataObjects(DragReference dragRef, ItemReference itemRef) const
2067 {
2068 UInt16 noOfFlavors;
2069
2070 wxDataObjectComposite* dataObject;
2071
2072
2073 ::CountDragItemFlavors(dragRef,itemRef,&noOfFlavors);
2074 if (noOfFlavors > 0)
2075 {
2076 // as the native drag data can be separated into TEXT and UTXT a pointer to a wxTextDataObject is used to track the existence of 'TEXT' and 'utxt' flavors:
2077 wxTextDataObject* textDataObject(NULL);
2078
2079 dataObject = new wxDataObjectComposite();
2080 for (UInt16 indexFlavor=1; indexFlavor<=noOfFlavors; ++indexFlavor)
2081 {
2082 // variable definition:
2083 FlavorType flavorDataObject;
2084
2085 if (::GetFlavorType(dragRef,itemRef,indexFlavor,&flavorDataObject) == noErr) // GetFlavorType uses a 1 based index!
2086 switch (flavorDataObject)
2087 {
2088 case 'TEXT':
2089 if (textDataObject == NULL) // otherwise a 'utxt' flavor has already been found that gets priority compared to the 'TEXT' flavor
2090 {
2091 // variable definitions:
2092 Size nativeDataSize;
2093 wxMemoryBuffer nativeData;
2094
2095 if ((::GetFlavorDataSize(dragRef,itemRef,'TEXT',&nativeDataSize) == noErr) &&
2096 (::GetFlavorData(dragRef,itemRef,'TEXT',nativeData.GetWriteBuf(nativeDataSize),&nativeDataSize,0) == noErr))
2097 {
2098 nativeData.UngetWriteBuf(nativeDataSize);
2099 textDataObject = new wxTextDataObject();
2100 if (textDataObject->SetData(nativeData.GetDataLen(),nativeData.GetData()))
2101 dataObject->Add(textDataObject);
2102 else
2103 {
2104 delete textDataObject;
2105 textDataObject = NULL;
2106 }
2107 }
2108 } /* block */
2109 break;
2110 case 'utxt':
2111 {
2112 // variable definition:
2113 Size nativeDataSize;
2114
2115 if (::GetFlavorDataSize(dragRef,itemRef,'utxt',&nativeDataSize) == noErr)
2116 {
2117 CFMutableDataRef draggedData;
2118
2119 draggedData = ::CFDataCreateMutable(kCFAllocatorDefault,nativeDataSize);
2120 ::CFDataSetLength(draggedData,nativeDataSize);
2121 if (::GetFlavorData(dragRef,itemRef,'utxt',::CFDataGetMutableBytePtr(draggedData),&nativeDataSize,0) == noErr)
2122 {
2123 // convert internally used UTF-16 representation to a UTF-8 representation:
2124 CFDataRef osxData;
2125 CFStringRef osxString;
2126
2127 osxString = ::CFStringCreateFromExternalRepresentation(kCFAllocatorDefault,draggedData,kCFStringEncodingUTF16); // BOM character is handled by this function automatically
2128 osxData = ::CFStringCreateExternalRepresentation(kCFAllocatorDefault,osxString,kCFStringEncodingUTF8,32);
2129 if (textDataObject == NULL)
2130 {
2131 textDataObject = new wxTextDataObject();
2132 if (textDataObject->SetData(::CFDataGetLength(osxData),::CFDataGetBytePtr(osxData)))
2133 dataObject->Add(textDataObject);
2134 else
2135 {
2136 delete textDataObject;
2137 textDataObject = NULL;
2138 }
2139 }
2140 else // overwrite data because the 'utxt' flavor has priority over the 'TEXT' flavor
2141 (void) textDataObject->SetData(::CFDataGetLength(osxData),::CFDataGetBytePtr(osxData));
2142 // clean up:
2143 ::CFRelease(osxData);
2144 ::CFRelease(osxString);
2145 }
2146 // clean up:
2147 ::CFRelease(draggedData);
2148 }
2149 } /* block */
2150 break;
2151 }
2152 }
2153 }
2154 else
2155 dataObject = NULL;
2156 return dataObject;
2157 } /* wxMacDataViewDataBrowserListViewControl::GetDnDDataObjects(DragReference, ItemReference) const */
2158
2159 //
2160 // other methods
2161 //
2162 wxDataViewColumn* wxMacDataViewDataBrowserListViewControl::GetColumnPtr(DataBrowserPropertyID propertyID) const
2163 {
2164 wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer()));
2165
2166 if (dataViewCtrlPtr != NULL)
2167 {
2168 size_t const noOfColumns = dataViewCtrlPtr->GetColumnCount();
2169
2170 for (size_t i=0; i<noOfColumns; ++i)
2171 if (dataViewCtrlPtr->GetColumnPtr(i)->GetNativeData()->GetPropertyID() == propertyID)
2172 return dataViewCtrlPtr->GetColumnPtr(i);
2173 }
2174 return NULL;
2175 }
2176
2177 // ---------------------------------------------------------
2178 // wxDataViewRenderer
2179 // ---------------------------------------------------------
2180 wxDataViewRenderer::wxDataViewRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align)
2181 :wxDataViewRendererBase(varianttype,mode,align), m_alignment(align), m_mode(mode), m_NativeDataPtr(NULL)
2182 {
2183 }
2184
2185 wxDataViewRenderer::~wxDataViewRenderer(void)
2186 {
2187 delete this->m_NativeDataPtr;
2188 }
2189
2190 void wxDataViewRenderer::SetAlignment(int align)
2191 {
2192 this->m_alignment = align;
2193 }
2194
2195 void wxDataViewRenderer::SetMode(wxDataViewCellMode mode)
2196 {
2197 wxDataViewColumn* dataViewColumnPtr;
2198
2199
2200 m_mode = mode;
2201 dataViewColumnPtr = this->GetOwner();
2202 if (dataViewColumnPtr != NULL)
2203 {
2204 wxDataViewCtrl* dataViewCtrlPtr(dataViewColumnPtr->GetOwner());
2205
2206 if (dataViewCtrlPtr != NULL)
2207 {
2208 wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
2209
2210 if (macDataViewListCtrlPtr != NULL)
2211 {
2212 DataBrowserPropertyFlags flags;
2213
2214 verify_noerr(macDataViewListCtrlPtr->GetPropertyFlags(dataViewColumnPtr->GetNativeData()->GetPropertyID(),&flags));
2215 if ((mode == wxDATAVIEW_CELL_EDITABLE) ||
2216 (mode == wxDATAVIEW_CELL_ACTIVATABLE))
2217 flags |= kDataBrowserPropertyIsEditable;
2218 else
2219 flags &= ~kDataBrowserPropertyIsEditable;
2220 verify_noerr(macDataViewListCtrlPtr->SetPropertyFlags(dataViewColumnPtr->GetNativeData()->GetPropertyID(),flags));
2221 }
2222 }
2223 }
2224 }
2225
2226 void wxDataViewRenderer::SetNativeData(wxDataViewRendererNativeData* newNativeDataPtr)
2227 {
2228 delete this->m_NativeDataPtr;
2229 this->m_NativeDataPtr = newNativeDataPtr;
2230 }
2231
2232 IMPLEMENT_ABSTRACT_CLASS(wxDataViewRenderer,wxDataViewRendererBase)
2233
2234 // ---------------------------------------------------------
2235 // wxDataViewCustomRenderer
2236 // ---------------------------------------------------------
2237 wxDataViewCustomRenderer::wxDataViewCustomRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align)
2238 :wxDataViewRenderer(varianttype,mode,align), m_editorCtrlPtr(NULL), m_DCPtr(NULL)
2239 {
2240 this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserCustomType));
2241 }
2242
2243 bool wxDataViewCustomRenderer::MacRender()
2244 {
2245 return true;
2246 }
2247
2248 IMPLEMENT_ABSTRACT_CLASS(wxDataViewCustomRenderer, wxDataViewRenderer)
2249
2250 // ---------------------------------------------------------
2251 // wxDataViewTextRenderer
2252 // ---------------------------------------------------------
2253 wxDataViewTextRenderer::wxDataViewTextRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align)
2254 :wxDataViewRenderer(varianttype,mode,align)
2255 {
2256 this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserTextType));
2257 }
2258
2259 bool wxDataViewTextRenderer::MacRender()
2260 {
2261 wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Text renderer cannot render value; value type: ")) << this->GetValue().GetType());
2262
2263 wxCFStringRef cfString(this->GetValue().GetString(),(this->GetView()->GetFont().Ok() ? this->GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
2264 return (::SetDataBrowserItemDataText(this->GetNativeData()->GetItemDataRef(),cfString) == noErr);
2265 }
2266
2267 IMPLEMENT_CLASS(wxDataViewTextRenderer,wxDataViewRenderer)
2268
2269 // ---------------------------------------------------------
2270 // wxDataViewBitmapRenderer
2271 // ---------------------------------------------------------
2272 wxDataViewBitmapRenderer::wxDataViewBitmapRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align)
2273 :wxDataViewRenderer(varianttype,mode,align)
2274 {
2275 this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserIconType));
2276 }
2277
2278 bool wxDataViewBitmapRenderer::MacRender()
2279 // This method returns 'true' if
2280 // - the passed bitmap is valid and it could be assigned to the native data browser;
2281 // - the passed bitmap is invalid (or is not initialized); this case simulates a non-existing bitmap.
2282 // In all other cases the method returns 'false'.
2283 {
2284 wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Bitmap renderer cannot render value; value type: ")) << this->GetValue().GetType());
2285
2286 wxBitmap bitmap;
2287
2288 bitmap << this->GetValue();
2289 return (!(bitmap.Ok()) || (::SetDataBrowserItemDataIcon(this->GetNativeData()->GetItemDataRef(),bitmap.GetIconRef()) == noErr));
2290 }
2291
2292 IMPLEMENT_CLASS(wxDataViewBitmapRenderer,wxDataViewRenderer)
2293
2294 // ---------------------------------------------------------
2295 // wxDataViewIconTextRenderer
2296 // ---------------------------------------------------------
2297 wxDataViewIconTextRenderer::wxDataViewIconTextRenderer(
2298 const wxString& varianttype,
2299 wxDataViewCellMode mode,
2300 int WXUNUSED(align))
2301 :wxDataViewRenderer(varianttype,mode)
2302 {
2303 this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserIconAndTextType));
2304 }
2305
2306 bool wxDataViewIconTextRenderer::MacRender()
2307 {
2308 wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Icon & text renderer cannot render value; value type: ")) << this->GetValue().GetType());
2309
2310 wxDataViewIconText iconText;
2311
2312 iconText << this->GetValue();
2313
2314 wxCFStringRef cfString(iconText.GetText(),(this->GetView()->GetFont().Ok() ? this->GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
2315
2316 if (iconText.GetIcon().IsOk())
2317 if (::SetDataBrowserItemDataIcon(this->GetNativeData()->GetItemDataRef(),MAC_WXHICON(iconText.GetIcon().GetHICON())) != noErr)
2318 return false;
2319 return (::SetDataBrowserItemDataText(this->GetNativeData()->GetItemDataRef(),cfString) == noErr);
2320 }
2321
2322 IMPLEMENT_ABSTRACT_CLASS(wxDataViewIconTextRenderer,wxDataViewRenderer)
2323
2324
2325 // ---------------------------------------------------------
2326 // wxDataViewToggleRenderer
2327 // ---------------------------------------------------------
2328 wxDataViewToggleRenderer::wxDataViewToggleRenderer(
2329 const wxString& varianttype,
2330 wxDataViewCellMode mode,
2331 int WXUNUSED(align))
2332 :wxDataViewRenderer(varianttype,mode)
2333 {
2334 this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserCheckboxType));
2335 }
2336
2337 bool wxDataViewToggleRenderer::MacRender()
2338 {
2339 wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Toggle renderer cannot render value; value type: ")) << this->GetValue().GetType());
2340 return (::SetDataBrowserItemDataButtonValue(this->GetNativeData()->GetItemDataRef(),this->GetValue().GetBool()) == noErr);
2341 }
2342
2343 IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleRenderer,wxDataViewRenderer)
2344
2345 // ---------------------------------------------------------
2346 // wxDataViewProgressRenderer
2347 // ---------------------------------------------------------
2348 wxDataViewProgressRenderer::wxDataViewProgressRenderer(
2349 const wxString& WXUNUSED(label),
2350 wxString const& varianttype,
2351 wxDataViewCellMode mode,
2352 int align)
2353 :wxDataViewRenderer(varianttype,mode,align)
2354 {
2355 this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserProgressBarType));
2356 }
2357
2358 bool wxDataViewProgressRenderer::MacRender()
2359 {
2360 wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Progress renderer cannot render value type; value type: ")) << this->GetValue().GetType());
2361 return ((::SetDataBrowserItemDataMinimum(this->GetNativeData()->GetItemDataRef(), 0) == noErr) &&
2362 (::SetDataBrowserItemDataMaximum(this->GetNativeData()->GetItemDataRef(),100) == noErr) &&
2363 (::SetDataBrowserItemDataValue (this->GetNativeData()->GetItemDataRef(),this->GetValue().GetLong()) == noErr));
2364 }
2365
2366 IMPLEMENT_ABSTRACT_CLASS(wxDataViewProgressRenderer,wxDataViewRenderer)
2367
2368 // ---------------------------------------------------------
2369 // wxDataViewDateRenderer
2370 // ---------------------------------------------------------
2371 wxDataViewDateRenderer::wxDataViewDateRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align)
2372 :wxDataViewRenderer(varianttype,mode,align)
2373 {
2374 this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserDateTimeType));
2375 }
2376
2377 bool wxDataViewDateRenderer::MacRender()
2378 {
2379 wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Date renderer cannot render value; value type: ")) << this->GetValue().GetType());
2380 return (::SetDataBrowserItemDataDateTime(this->GetNativeData()->GetItemDataRef(),this->GetValue().GetDateTime().Subtract(wxDateTime(1,wxDateTime::Jan,1904)).GetSeconds().GetLo()) == noErr);
2381 }
2382
2383 IMPLEMENT_ABSTRACT_CLASS(wxDataViewDateRenderer,wxDataViewRenderer)
2384
2385 // ---------------------------------------------------------
2386 // wxDataViewColumn
2387 // ---------------------------------------------------------
2388 wxDataViewColumn::wxDataViewColumn(const wxString& title, wxDataViewRenderer* renderer, unsigned int model_column, int width, wxAlignment align, int flags)
2389 :wxDataViewColumnBase(renderer, model_column), m_NativeDataPtr(new wxDataViewColumnNativeData()), m_title(title)
2390 {
2391 this->InitCommon(width, align, flags);
2392 if ((renderer != NULL) && (renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT))
2393 renderer->SetAlignment(align);
2394 }
2395
2396 wxDataViewColumn::wxDataViewColumn(const wxBitmap& bitmap, wxDataViewRenderer* renderer, unsigned int model_column, int width, wxAlignment align, int flags)
2397 :wxDataViewColumnBase(bitmap, renderer, model_column), m_NativeDataPtr(new wxDataViewColumnNativeData())
2398 {
2399 this->InitCommon(width, align, flags);
2400 if ((renderer != NULL) && (renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT))
2401 renderer->SetAlignment(align);
2402 }
2403
2404 wxDataViewColumn::~wxDataViewColumn(void)
2405 {
2406 delete this->m_NativeDataPtr;
2407 }
2408
2409 bool wxDataViewColumn::IsSortKey() const
2410 {
2411 wxDataViewCtrl * const dataViewCtrlPtr(GetOwner());
2412 wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(
2413 dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(
2414 dataViewCtrlPtr->GetPeer()));
2415
2416 DataBrowserPropertyID propertyID;
2417 return (macDataViewListCtrlPtr->GetSortProperty(&propertyID) == noErr) &&
2418 (propertyID == this->GetNativeData()->GetPropertyID());
2419 }
2420
2421 void wxDataViewColumn::SetAlignment(wxAlignment align)
2422 {
2423 wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner());
2424
2425
2426 m_alignment = align;
2427 if (dataViewCtrlPtr != NULL)
2428 {
2429 wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
2430
2431 if (macDataViewListCtrlPtr != NULL)
2432 {
2433 DataBrowserListViewHeaderDesc headerDescription;
2434
2435 wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description."));
2436 switch (align)
2437 {
2438 case wxALIGN_CENTER:
2439 case wxALIGN_CENTER_HORIZONTAL:
2440 headerDescription.btnFontStyle.just = teCenter;
2441 break;
2442 case wxALIGN_LEFT:
2443 headerDescription.btnFontStyle.just = teFlushLeft;
2444 break;
2445 case wxALIGN_RIGHT:
2446 headerDescription.btnFontStyle.just = teFlushRight;
2447 break;
2448 default:
2449 headerDescription.btnFontStyle.just = teFlushDefault;
2450 }
2451 wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not set alignment."));
2452 }
2453 }
2454 }
2455
2456 void wxDataViewColumn::SetBitmap(wxBitmap const& bitmap)
2457 {
2458 wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner());
2459
2460
2461 wxDataViewColumnBase::SetBitmap(bitmap);
2462 if (dataViewCtrlPtr != NULL)
2463 {
2464 wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
2465
2466 if (macDataViewListCtrlPtr != NULL)
2467 {
2468 DataBrowserListViewHeaderDesc headerDescription;
2469
2470 wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description."));
2471 if (this->GetBitmap().Ok())
2472 headerDescription.btnContentInfo.u.iconRef = this->GetBitmap().GetIconRef();
2473 else
2474 headerDescription.btnContentInfo.u.iconRef = NULL;
2475 wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not set icon."));
2476 }
2477 }
2478 }
2479
2480 void wxDataViewColumn::SetMaxWidth(int maxWidth)
2481 {
2482 wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner());
2483
2484
2485 m_maxWidth = maxWidth;
2486 if (dataViewCtrlPtr != NULL)
2487 {
2488 wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
2489
2490 if (macDataViewListCtrlPtr != NULL)
2491 {
2492 DataBrowserListViewHeaderDesc headerDescription;
2493
2494 wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description."));
2495 headerDescription.maximumWidth = static_cast<UInt16>(maxWidth);
2496 wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not set maximum width."));
2497 }
2498 }
2499 }
2500
2501 void wxDataViewColumn::SetMinWidth(int minWidth)
2502 {
2503 wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner());
2504
2505
2506 m_minWidth = minWidth;
2507 if (dataViewCtrlPtr != NULL)
2508 {
2509 wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
2510
2511 if (macDataViewListCtrlPtr != NULL)
2512 {
2513 DataBrowserListViewHeaderDesc headerDescription;
2514
2515 wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description."));
2516 headerDescription.minimumWidth = static_cast<UInt16>(minWidth);
2517 wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not set minimum width."));
2518 }
2519 }
2520 }
2521
2522 void wxDataViewColumn::SetReorderable(bool reorderable)
2523 {
2524 // first set the internal flag of the column:
2525 if (reorderable)
2526 m_flags |= wxDATAVIEW_COL_REORDERABLE;
2527 else
2528 m_flags &= ~wxDATAVIEW_COL_REORDERABLE;
2529 // if the column is associated with a control change also immediately the flags of the control:
2530 wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner());
2531
2532 if (dataViewCtrlPtr != NULL)
2533 {
2534 DataBrowserPropertyFlags flags;
2535 wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
2536
2537 wxCHECK_RET(macDataViewListCtrlPtr != NULL, _("Valid pointer to native data view control does not exist"));
2538 wxCHECK_RET(macDataViewListCtrlPtr->GetPropertyFlags(this->GetNativeData()->GetPropertyID(),&flags) == noErr,_("Could not get property flags."));
2539 if (reorderable)
2540 flags |= kDataBrowserListViewMovableColumn;
2541 else
2542 flags &= ~kDataBrowserListViewMovableColumn;
2543 wxCHECK_RET(macDataViewListCtrlPtr->SetPropertyFlags(this->GetNativeData()->GetPropertyID(),flags) == noErr,_("Could not set property flags."));
2544 }
2545 }
2546
2547 void wxDataViewColumn::SetResizeable(bool resizeable)
2548 {
2549 // first set the internal flag of the column:
2550 if (resizeable)
2551 m_flags |= wxDATAVIEW_COL_RESIZABLE;
2552 else
2553 m_flags &= ~wxDATAVIEW_COL_RESIZABLE;
2554 // if the column is associated with a control change also immediately the flags of the control:
2555 wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner());
2556
2557 if (dataViewCtrlPtr != NULL)
2558 {
2559 wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
2560
2561 if (macDataViewListCtrlPtr != NULL)
2562 {
2563 DataBrowserListViewHeaderDesc headerDescription;
2564
2565 verify_noerr(macDataViewListCtrlPtr->GetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription));
2566 if (resizeable)
2567 {
2568 if (this->GetMinWidth() >= this->GetMaxWidth())
2569 {
2570 this->m_minWidth = 0;
2571 this->m_maxWidth = 30000;
2572 }
2573 headerDescription.minimumWidth = this->m_minWidth;
2574 headerDescription.maximumWidth = this->m_maxWidth;
2575 }
2576 else
2577 {
2578 headerDescription.minimumWidth = this->m_width;
2579 headerDescription.maximumWidth = this->m_width;
2580 }
2581 verify_noerr(macDataViewListCtrlPtr->SetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription));
2582 macDataViewListCtrlPtr->SetSortProperty(this->GetNativeData()->GetPropertyID());
2583 }
2584 }
2585 }
2586
2587 void wxDataViewColumn::SetSortable(bool sortable)
2588 {
2589 // first set the internal flag of the column:
2590 if (sortable)
2591 m_flags |= wxDATAVIEW_COL_SORTABLE;
2592 else
2593 m_flags &= ~wxDATAVIEW_COL_SORTABLE;
2594 // if the column is associated with a control change also immediately the flags of the control:
2595 wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner());
2596
2597 if (dataViewCtrlPtr != NULL)
2598 {
2599 DataBrowserPropertyFlags flags;
2600 wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
2601
2602 wxCHECK_RET(macDataViewListCtrlPtr != NULL, _("Valid pointer to native data view control does not exist"));
2603 wxCHECK_RET(macDataViewListCtrlPtr->GetPropertyFlags(this->GetNativeData()->GetPropertyID(),&flags) == noErr,_("Could not get property flags."));
2604 if (sortable)
2605 flags |= kDataBrowserListViewSortableColumn;
2606 else
2607 flags &= ~kDataBrowserListViewSortableColumn;
2608 wxCHECK_RET(macDataViewListCtrlPtr->SetPropertyFlags(this->GetNativeData()->GetPropertyID(),flags) == noErr,_("Could not set property flags."));
2609 }
2610 }
2611
2612 void wxDataViewColumn::SetSortOrder(bool ascending)
2613 {
2614 wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner());
2615
2616
2617 m_ascending = ascending;
2618 if (dataViewCtrlPtr != NULL)
2619 {
2620 wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
2621
2622 if (macDataViewListCtrlPtr != NULL)
2623 {
2624 DataBrowserListViewHeaderDesc headerDescription;
2625
2626 verify_noerr(macDataViewListCtrlPtr->GetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription));
2627 if (ascending)
2628 headerDescription.initialOrder = kDataBrowserOrderIncreasing;
2629 else
2630 headerDescription.initialOrder = kDataBrowserOrderDecreasing;
2631 verify_noerr(macDataViewListCtrlPtr->SetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription));
2632 macDataViewListCtrlPtr->SetSortProperty(this->GetNativeData()->GetPropertyID());
2633 }
2634 }
2635 }
2636
2637 void wxDataViewColumn::SetTitle(wxString const& title)
2638 {
2639 wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner());
2640
2641
2642 m_title = title;
2643 if (dataViewCtrlPtr != NULL)
2644 {
2645 wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
2646
2647 if (macDataViewListCtrlPtr != NULL)
2648 {
2649 DataBrowserListViewHeaderDesc headerDescription;
2650 wxCFStringRef cfTitle(title,(dataViewCtrlPtr->GetFont().Ok() ? dataViewCtrlPtr->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
2651
2652 wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description."));
2653 headerDescription.titleString = cfTitle;
2654 wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not set header description."));
2655 }
2656 }
2657 }
2658
2659 void wxDataViewColumn::SetWidth(int width)
2660 {
2661 wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner());
2662
2663
2664 if ((width >= m_minWidth) && (width <= m_maxWidth))
2665 {
2666 m_width = width;
2667 if (dataViewCtrlPtr != NULL)
2668 {
2669 wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
2670
2671 if (macDataViewListCtrlPtr != NULL)
2672 wxCHECK_RET(macDataViewListCtrlPtr->SetColumnWidth(this->GetNativeData()->GetPropertyID(),static_cast<UInt16>(width)) == noErr,_("Could not set column width."));
2673 }
2674 }
2675 }
2676
2677 void wxDataViewColumn::SetAsSortKey(bool WXUNUSED(sort))
2678 {
2679 // see wxGTK native wxDataViewColumn implementation
2680 wxFAIL_MSG( "not implemented" );
2681 }
2682
2683 void wxDataViewColumn::SetNativeData(wxDataViewColumnNativeData* newNativeDataPtr)
2684 {
2685 delete this->m_NativeDataPtr;
2686 this->m_NativeDataPtr = newNativeDataPtr;
2687 }
2688
2689 #endif // wxUSE_DATAVIEWCTRL && !wxUSE_GENERICDATAVIEWCTRL