1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/carbon/datavgen.cpp
3 // Purpose: wxDataViewCtrl native mac implementation
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
13 #if wxUSE_DATAVIEWCTRL
15 #include "wx/dataview.h"
17 #if !defined(wxUSE_GENERICDATAVIEWCTRL) || (wxUSE_GENERICDATAVIEWCTRL == 0)
21 #include "wx/mac/carbon/databrow.h"
28 #include "wx/renderer.h"
30 //-----------------------------------------------------------------------------
32 //-----------------------------------------------------------------------------
34 // a list of all catchable events:
35 static EventTypeSpec
const eventList
[] =
37 {kEventClassControl
, kEventControlDraw
},
38 {kEventClassControl
, kEventControlHit
}
41 //-----------------------------------------------------------------------------
43 //-----------------------------------------------------------------------------
45 static pascal OSStatus
wxMacDataViewCtrlEventHandler(EventHandlerCallRef handler
, EventRef EventReference
, void* Data
)
47 wxDataViewCtrl
* DataViewCtrlPtr((wxDataViewCtrl
*) Data
); // the 'Data' variable always contains a pointer to the data view control that installed the handler
49 wxMacCarbonEvent
CarbonEvent(EventReference
) ;
52 switch (GetEventKind(EventReference
))
54 case kEventControlDraw
:
58 DataViewCtrlPtr
->MacSetDrawingContext(CarbonEvent
.GetParameter
<CGContextRef
>(kEventParamCGContextRef
,typeCGContextRef
));
59 status
= ::CallNextEventHandler(handler
,EventReference
);
60 DataViewCtrlPtr
->MacSetDrawingContext(NULL
);
63 case kEventControlHit
:
64 if (CarbonEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPart
,typeControlPartCode
) == kControlButtonPart
) // we only care about the header
66 ControlRef controlReference
;
67 DataBrowserPropertyID columnPropertyID
;
68 unsigned long columnIndex
;
70 wxDataViewEvent
DataViewEvent(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK
,DataViewCtrlPtr
->GetId());
72 CarbonEvent
.GetParameter(kEventParamDirectObject
,&controlReference
);
73 // determine the column that triggered the event (this is the column that is responsible for sorting the data view):
74 status
= ::GetDataBrowserSortProperty(controlReference
,&columnPropertyID
);
75 wxCHECK(status
== noErr
,status
);
76 status
= ::GetDataBrowserTableViewColumnPosition(controlReference
,columnPropertyID
,&columnIndex
);
77 if (status
== errDataBrowserPropertyNotFound
) // user clicked into part of the header that does not have a property
78 return ::CallNextEventHandler(handler
,EventReference
);
79 wxCHECK(status
== noErr
,status
);
80 // initialize wxWidget event handler:
81 DataViewEvent
.SetEventObject(DataViewCtrlPtr
);
82 DataViewEvent
.SetColumn(columnIndex
);
83 DataViewEvent
.SetDataViewColumn(DataViewCtrlPtr
->GetColumn(columnIndex
));
84 // finally sent the equivalent wxWidget event:
85 DataViewCtrlPtr
->GetEventHandler()->ProcessEvent(DataViewEvent
);
86 return ::CallNextEventHandler(handler
,EventReference
);
89 return eventNotHandledErr
;
92 return eventNotHandledErr
;
93 } /* wxMacDataViewCtrlEventHandler(EventHandlerCallRef, EventRef, void*) */
95 //-----------------------------------------------------------------------------
96 // local function pointers
97 //-----------------------------------------------------------------------------
99 DEFINE_ONE_SHOT_HANDLER_GETTER(wxMacDataViewCtrlEventHandler
)
101 // ---------------------------------------------------------
102 // wxMacDataViewModelNotifier
103 // ---------------------------------------------------------
105 class wxMacDataViewModelNotifier
: public wxDataViewModelNotifier
108 wxMacDataViewModelNotifier(wxMacDataViewDataBrowserListViewControl
* initDataViewControlPtr
) : m_dataViewControlPtr(initDataViewControlPtr
)
112 virtual bool ItemAdded(const wxDataViewItem
&parent
, const wxDataViewItem
&item
)
114 DataBrowserItemID
itemID(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
117 wxCHECK_MSG(item
.IsOk(),false,_("Added item is invalid."));
118 return (!(parent
.IsOk()) && (this->m_dataViewControlPtr
->AddItem(kDataBrowserNoItem
,&itemID
) == noErr
) ||
119 parent
.IsOk() && (this->m_dataViewControlPtr
->AddItem(reinterpret_cast<DataBrowserItemID
>(parent
.GetID()),&itemID
) == noErr
));
120 } /* ItemAdded(wxDataViewItem const&, wxDataViewItem const&) */
122 virtual bool ItemChanged(wxDataViewItem
const& item
)
124 DataBrowserItemID
itemID(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
127 wxCHECK_MSG(item
.IsOk(), false,_("Changed item is invalid."));
128 wxCHECK_MSG(this->GetOwner() != NULL
,false,_("Owner not initialized."));
129 if (this->m_dataViewControlPtr
->UpdateItems(&itemID
) == noErr
)
131 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->m_dataViewControlPtr
->GetPeer()));
133 // sent the equivalent wxWidget event:
134 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_CHANGED
,dataViewCtrlPtr
->GetId()); // variable defintion
136 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
137 dataViewEvent
.SetItem(item
);
138 // sent the equivalent wxWidget event:
139 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
145 } /* ItemChanged(wxDataViewItem const&) */
147 virtual bool ItemDeleted(wxDataViewItem
const& parent
, wxDataViewItem
const& item
)
151 // variable definition and initialization:
152 DataBrowserItemID
itemID(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
153 OSStatus errorStatus
;
154 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->m_dataViewControlPtr
->GetPeer()));
156 // when this method is called and currently an item is being edited this item may have already been deleted in the model (the passed item and the being edited item have
157 // not to be identical because the being edited item might be below the passed item in the hierarchy); therefore, the control is informed that currently a deleting process
158 // is started and that variables can currently not be updated even when requested by the system:
159 dataViewCtrlPtr
->SetDeleting(true);
160 errorStatus
= this->m_dataViewControlPtr
->RemoveItem(reinterpret_cast<DataBrowserItemID
>(parent
.GetID()),&itemID
);
161 dataViewCtrlPtr
->SetDeleting(false);
162 return (errorStatus
== noErr
);
166 } /* ItemDeleted(wxDataViewItem const&, wxDataViewItem const&) */
168 virtual bool ValueChanged(wxDataViewItem
const& item
, unsigned int col
)
170 DataBrowserItemID
itemID(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
171 DataBrowserItemID parentID
;
173 DataBrowserPropertyID propertyID
;
175 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->m_dataViewControlPtr
->GetPeer()));
178 wxCHECK_MSG(item
.IsOk(), false,_("Passed item is invalid."));
179 wxCHECK_MSG(this->GetOwner() != NULL
,false,_("Owner not initialized."));
180 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
, false,_("Control is wrongly initialized."));
181 parentID
= reinterpret_cast<DataBrowserItemID
>(this->GetOwner()->GetParent(item
).GetID());
182 if ((this->m_dataViewControlPtr
->GetPropertyID(col
,&propertyID
) == noErr
) &&
183 (this->m_dataViewControlPtr
->UpdateItems(parentID
,1,&itemID
,dataViewCtrlPtr
->GetColumn(col
)->GetPropertyID(),propertyID
) == noErr
))
185 // variable definition and initialization:
186 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_MODEL_VALUE_CHANGED
,dataViewCtrlPtr
->GetId());
188 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
189 dataViewEvent
.SetColumn(col
);
190 dataViewEvent
.SetItem(item
);
191 // send the equivalent wxWidget event:
192 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
198 } /* ValueChanged(wxDataViewItem const&, unsigned int) */
200 virtual bool Cleared(void)
202 if (this->m_dataViewControlPtr
->RemoveItems() == noErr
)
204 // variable definitions and initializations:
205 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->m_dataViewControlPtr
->GetPeer()));
206 wxDataViewEvent
dataViewEvent (wxEVT_COMMAND_DATAVIEW_MODEL_CLEARED
,dataViewCtrlPtr
->GetId());
208 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
209 // send the equivalent wxWidget event:
210 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
216 } /* Cleared(void) */
218 virtual void Resort(void)
220 this->m_dataViewControlPtr
->Resort();
228 wxMacDataViewDataBrowserListViewControl
* m_dataViewControlPtr
;
231 // ---------------------------------------------------------
232 // wxDataViewRenderer
233 // ---------------------------------------------------------
235 wxDataViewRenderer::wxDataViewRenderer(wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
236 :wxDataViewRendererBase(varianttype
,mode
,align
), m_alignment(align
), m_mode(mode
)
238 } /* wxDataViewRenderer::wxDataViewRenderer(wxString const&, wxDataViewCellMode) */
240 void wxDataViewRenderer::SetMode(wxDataViewCellMode mode
)
242 wxDataViewColumn
* dataViewColumnPtr
;
246 dataViewColumnPtr
= this->GetOwner();
247 if (dataViewColumnPtr
!= NULL
)
249 // variable definition and initialization:
250 wxDataViewCtrl
* dataViewCtrlPtr(dataViewColumnPtr
->GetOwner());
252 if (dataViewCtrlPtr
!= NULL
)
254 // variable definition and initialization:
255 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
257 if (macDataViewListCtrlPtr
!= NULL
)
259 // variable definition and initialization:
260 DataBrowserPropertyFlags flags
;
262 verify_noerr(macDataViewListCtrlPtr
->GetPropertyFlags(dataViewColumnPtr
->GetPropertyID(),&flags
));
263 if (mode
== wxDATAVIEW_CELL_EDITABLE
)
264 flags
|= kDataBrowserPropertyIsEditable
;
266 flags
&= ~kDataBrowserPropertyIsEditable
;
267 verify_noerr(macDataViewListCtrlPtr
->SetPropertyFlags(dataViewColumnPtr
->GetPropertyID(),flags
));
271 } /* wxDataViewRenderer::SetMode(wxDataViewCellMode) */
273 IMPLEMENT_ABSTRACT_CLASS(wxDataViewRenderer
,wxDataViewRendererBase
)
275 // ---------------------------------------------------------
276 // wxDataViewCustomRenderer
277 // ---------------------------------------------------------
279 wxDataViewCustomRenderer::wxDataViewCustomRenderer(wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
280 :wxDataViewRenderer(varianttype
,mode
,align
), m_editorCtrlPtr(NULL
), m_DCPtr(NULL
)
282 } /* wxDataViewCustomRenderer::wxDataViewCustomRenderer(wxString const&, wxDataViewCellMode) */
284 wxDataViewCustomRenderer::~wxDataViewCustomRenderer(void)
286 if (this->m_DCPtr
!= NULL
)
287 delete this->m_DCPtr
;
288 } /* wxDataViewCustomRenderer::~wxDataViewCustomRenderer(void) */
290 wxDC
* wxDataViewCustomRenderer::GetDC(void)
292 if (this->m_DCPtr
== NULL
)
294 if ((GetOwner() == NULL
) || (GetOwner()->GetOwner() == NULL
))
296 this->m_DCPtr
= new wxClientDC(this->GetOwner()->GetOwner());
298 return this->m_DCPtr
;
299 } /* wxDataViewCustomRenderer::GetDC(void) */
301 bool wxDataViewCustomRenderer::Render(void)
304 } /* wxDataViewCustomRenderer::Render(void) */
306 void wxDataViewCustomRenderer::SetDC(wxDC
* newDCPtr
)
308 delete this->m_DCPtr
;
309 this->m_DCPtr
= newDCPtr
;
310 } /* wxDataViewCustomRenderer::SetDC(wxDC*) */
313 IMPLEMENT_ABSTRACT_CLASS(wxDataViewCustomRenderer
, wxDataViewRenderer
)
315 // ---------------------------------------------------------
316 // wxDataViewTextRenderer
317 // ---------------------------------------------------------
319 wxDataViewTextRenderer::wxDataViewTextRenderer(wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
320 :wxDataViewRenderer(varianttype
,mode
,align
)
322 } /* wxDataViewTextRenderer::wxDataViewTextRenderer(wxString const&, wxDataViewCellMode, int) */
324 bool wxDataViewTextRenderer::Render(void)
326 if (this->GetValue().GetType() == this->GetVariantType())
328 // variable definition:
329 wxMacCFStringHolder
cfString(this->GetValue().GetString(),(this->GetView()->GetFont().Ok() ? this->GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
331 return (::SetDataBrowserItemDataText(this->GetDataReference(),cfString
) == noErr
);
335 } /* wxDataViewTextRenderer::Render(void) */
337 IMPLEMENT_CLASS(wxDataViewTextRenderer
,wxDataViewRenderer
)
339 // ---------------------------------------------------------
340 // wxDataViewBitmapRenderer
341 // ---------------------------------------------------------
343 wxDataViewBitmapRenderer::wxDataViewBitmapRenderer(wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
344 :wxDataViewRenderer(varianttype
,mode
,align
)
348 bool wxDataViewBitmapRenderer::Render(void)
350 if (this->GetValue().GetType() == this->GetVariantType())
354 bitmap
<< this->GetValue();
356 return (::SetDataBrowserItemDataIcon(this->GetDataReference(),bitmap
.GetBitmapData()->GetIconRef()) == noErr
);
362 } /* wxDataViewBitmapRenderer::Render(void) */
364 IMPLEMENT_CLASS(wxDataViewBitmapRenderer
,wxDataViewRenderer
)
366 // ---------------------------------------------------------
367 // wxDataViewIconTextRenderer
368 // ---------------------------------------------------------
370 wxDataViewIconTextRenderer::wxDataViewIconTextRenderer(wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
371 :wxDataViewRenderer(varianttype
,mode
)
375 bool wxDataViewIconTextRenderer::Render(void)
377 if (this->GetValue().GetType() == this->GetVariantType())
379 // variable definition:
380 wxDataViewIconText iconText
;
382 iconText
<< this->GetValue();
384 // variable definition:
385 wxMacCFStringHolder
cfString(iconText
.GetText(),(this->GetView()->GetFont().Ok() ? this->GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
387 return ((::SetDataBrowserItemDataIcon(this->GetDataReference(),MAC_WXHICON(iconText
.GetIcon().GetHICON())) == noErr
) &&
388 (::SetDataBrowserItemDataText(this->GetDataReference(),cfString
) == noErr
));
392 } /* wxDataViewIconTextRenderer::Render(void) */
394 IMPLEMENT_ABSTRACT_CLASS(wxDataViewIconTextRenderer
,wxDataViewRenderer
)
397 // ---------------------------------------------------------
398 // wxDataViewToggleRenderer
399 // ---------------------------------------------------------
401 wxDataViewToggleRenderer::wxDataViewToggleRenderer(wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
402 :wxDataViewRenderer(varianttype
,mode
)
406 bool wxDataViewToggleRenderer::Render(void)
408 if (this->GetValue().GetType() == this->GetVariantType())
409 return (::SetDataBrowserItemDataButtonValue(this->GetDataReference(),this->GetValue().GetBool()) == noErr
);
412 } /* wxDataViewToggleRenderer::Render(void) */
414 IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleRenderer
,wxDataViewRenderer
)
416 // ---------------------------------------------------------
417 // wxDataViewProgressRenderer
418 // ---------------------------------------------------------
420 wxDataViewProgressRenderer::wxDataViewProgressRenderer(wxString
const& label
, wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
421 :wxDataViewRenderer(varianttype
,mode
,align
)
425 bool wxDataViewProgressRenderer::Render(void)
427 if (this->GetValue().GetType() == this->GetVariantType())
428 return ((::SetDataBrowserItemDataMinimum(this->GetDataReference(), 0) == noErr
) &&
429 (::SetDataBrowserItemDataMaximum(this->GetDataReference(),100) == noErr
) &&
430 (::SetDataBrowserItemDataValue (this->GetDataReference(),this->GetValue().GetLong()) == noErr
));
433 } /* wxDataViewProgressRenderer::Render(void) */
435 IMPLEMENT_ABSTRACT_CLASS(wxDataViewProgressRenderer
,wxDataViewRenderer
)
437 // ---------------------------------------------------------
438 // wxDataViewDateRenderer
439 // ---------------------------------------------------------
441 wxDataViewDateRenderer::wxDataViewDateRenderer(wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
442 :wxDataViewRenderer(varianttype
,mode
,align
)
446 bool wxDataViewDateRenderer::Render(void)
448 if (this->GetValue().GetType() == this->GetVariantType())
449 return (::SetDataBrowserItemDataDateTime(this->GetDataReference(),this->GetValue().GetDateTime().Subtract(wxDateTime(1,wxDateTime::Jan
,1904)).GetSeconds().GetLo()) == noErr
);
452 } /* wxDataViewDateRenderer::Render(void) */
454 IMPLEMENT_ABSTRACT_CLASS(wxDataViewDateRenderer
,wxDataViewRenderer
)
456 // ---------------------------------------------------------
458 // ---------------------------------------------------------
460 wxDataViewColumn::wxDataViewColumn(wxString
const &title
, wxDataViewRenderer
*cell
, unsigned int model_column
, int width
, wxAlignment align
, int flags
)
461 :wxDataViewColumnBase(title
,cell
,model_column
,width
,wxALIGN_CENTER
,flags
), m_ascending(true),
462 m_flags(flags
& ~(wxDATAVIEW_COL_HIDDEN
)), m_maxWidth(30000), m_minWidth(0), m_width(width
>= 0 ? width
: wxDVC_DEFAULT_WIDTH
),
463 m_alignment(align
), m_title(title
)
465 } /* wxDataViewColumn::wxDataViewColumn(wxString const &title, wxDataViewRenderer*, unsigned int, int, wxAlignment, int) */
467 wxDataViewColumn::wxDataViewColumn(wxBitmap
const& bitmap
, wxDataViewRenderer
*cell
, unsigned int model_column
, int width
, wxAlignment align
, int flags
)
468 :wxDataViewColumnBase(bitmap
,cell
,model_column
,width
,wxALIGN_CENTER
,flags
), m_ascending(true),
469 m_flags(flags
& ~(wxDATAVIEW_COL_HIDDEN
)), m_maxWidth(30000), m_minWidth(0), m_width(width
>= 0 ? width
: wxDVC_DEFAULT_WIDTH
),
472 } /* wxDataViewColumn::wxDataViewColumn(wxBitmap const&, wxDataViewRenderer*, unsigned int, int, wxAlignment, int) */
474 void wxDataViewColumn::SetAlignment(wxAlignment align
)
476 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
479 this->m_alignment
= align
;
480 if (dataViewCtrlPtr
!= NULL
)
482 // variable definition and initialization:
483 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
485 if (macDataViewListCtrlPtr
!= NULL
)
487 // variable definition and initialization:
488 DataBrowserListViewHeaderDesc headerDescription
;
490 wxCHECK_RET(macDataViewListCtrlPtr
->GetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not get header description."));
494 case wxALIGN_CENTER_HORIZONTAL
:
495 headerDescription
.btnFontStyle
.just
= teCenter
;
498 headerDescription
.btnFontStyle
.just
= teFlushLeft
;
501 headerDescription
.btnFontStyle
.just
= teFlushRight
;
504 headerDescription
.btnFontStyle
.just
= teFlushDefault
;
506 wxCHECK_RET(macDataViewListCtrlPtr
->SetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not set alignment."));
509 } /* wxDataViewColumn::SetAlignment(wxAlignment) */
511 void wxDataViewColumn::SetBitmap(wxBitmap
const& bitmap
)
513 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
516 wxDataViewColumnBase::SetBitmap(bitmap
);
517 if (dataViewCtrlPtr
!= NULL
)
519 // variable definition and initialization:
520 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
522 if (macDataViewListCtrlPtr
!= NULL
)
524 // variable definition and initialization:
525 DataBrowserListViewHeaderDesc headerDescription
;
527 wxCHECK_RET(macDataViewListCtrlPtr
->GetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not get header description."));
528 if (this->GetBitmap().Ok())
529 headerDescription
.btnContentInfo
.u
.iconRef
= this->GetBitmap().GetBitmapData()->GetIconRef();
531 headerDescription
.btnContentInfo
.u
.iconRef
= NULL
;
532 wxCHECK_RET(macDataViewListCtrlPtr
->SetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not set icon."));
535 } /* wxDataViewColumn::SetBitmap(wxBitmap const&) */
537 void wxDataViewColumn::SetFlags(int flags
)
539 this->SetHidden ((flags
& wxDATAVIEW_COL_HIDDEN
) != 0);
540 this->SetResizeable((flags
& wxDATAVIEW_COL_RESIZABLE
) != 0);
541 this->SetSortable ((flags
& wxDATAVIEW_COL_SORTABLE
) != 0);
542 } /* wxDataViewColumn::SetFlags(int) */
544 void wxDataViewColumn::SetMaxWidth(int maxWidth
)
546 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
549 this->m_maxWidth
= maxWidth
;
550 if (dataViewCtrlPtr
!= NULL
)
552 // variable definition and initialization:
553 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
555 if (macDataViewListCtrlPtr
!= NULL
)
557 // variable definition and initialization:
558 DataBrowserListViewHeaderDesc headerDescription
;
560 wxCHECK_RET(macDataViewListCtrlPtr
->GetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not get header description."));
561 headerDescription
.maximumWidth
= static_cast<UInt16
>(maxWidth
);
562 wxCHECK_RET(macDataViewListCtrlPtr
->SetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not set maximum width."));
565 } /* wxDataViewColumn::SetMaxWidth(int) */
567 void wxDataViewColumn::SetMinWidth(int minWidth
)
569 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
572 this->m_minWidth
= minWidth
;
573 if (dataViewCtrlPtr
!= NULL
)
575 // variable definition and initialization:
576 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
578 if (macDataViewListCtrlPtr
!= NULL
)
580 // variable definition and initialization:
581 DataBrowserListViewHeaderDesc headerDescription
;
583 wxCHECK_RET(macDataViewListCtrlPtr
->GetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not get header description."));
584 headerDescription
.minimumWidth
= static_cast<UInt16
>(minWidth
);
585 wxCHECK_RET(macDataViewListCtrlPtr
->SetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not set minimum width."));
588 } /* wxDataViewColumn::SetMaxWidth(int) */
590 void wxDataViewColumn::SetResizeable(bool WXUNUSED(resizeable
))
592 } /* wxDataViewColumn::SetResizeable(bool) */
594 void wxDataViewColumn::SetSortable(bool sortable
)
596 // variable definition and initialization:
597 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
599 if (dataViewCtrlPtr
!= NULL
)
601 // variable definition and initialization:
602 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
604 if (macDataViewListCtrlPtr
!= NULL
)
606 // variable definition and initialization:
607 DataBrowserPropertyFlags flags
;
609 wxCHECK_RET(macDataViewListCtrlPtr
->GetPropertyFlags(this->GetPropertyID(),&flags
) == noErr
,_("Could not get property flags."));
612 this->m_flags
|= wxDATAVIEW_COL_SORTABLE
;
613 flags
|= kDataBrowserListViewSortableColumn
;
617 this->m_flags
&= ~wxDATAVIEW_COL_SORTABLE
;
618 flags
&= ~kDataBrowserPropertyIsEditable
;
620 wxCHECK_RET(macDataViewListCtrlPtr
->SetPropertyFlags(this->GetPropertyID(),flags
) == noErr
,_("Could not set property flags."));
623 } /* wxDataViewColumn::SetSortable(bool) */
625 void wxDataViewColumn::SetSortOrder(bool ascending
)
627 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
630 this->m_ascending
= ascending
;
631 if (dataViewCtrlPtr
!= NULL
)
633 // variable definition and initialization:
634 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
636 if (macDataViewListCtrlPtr
!= NULL
)
638 // variable definition and initialization:
639 DataBrowserListViewHeaderDesc headerDescription
;
641 verify_noerr(macDataViewListCtrlPtr
->GetHeaderDesc(this->GetPropertyID(),&headerDescription
));
643 headerDescription
.initialOrder
= kDataBrowserOrderIncreasing
;
645 headerDescription
.initialOrder
= kDataBrowserOrderDecreasing
;
646 verify_noerr(macDataViewListCtrlPtr
->SetHeaderDesc(this->GetPropertyID(),&headerDescription
));
649 } /* wxDataViewColumn::SetSortOrder(bool) */
651 void wxDataViewColumn::SetTitle(wxString
const& title
)
653 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
656 this->m_title
= title
;
657 if (dataViewCtrlPtr
!= NULL
)
659 // variable definition and initialization:
660 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
662 if (macDataViewListCtrlPtr
!= NULL
)
664 // variable definition and initialization:
665 DataBrowserListViewHeaderDesc headerDescription
;
666 wxMacCFStringHolder
cfTitle(title
,(dataViewCtrlPtr
->GetFont().Ok() ? dataViewCtrlPtr
->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
668 wxCHECK_RET(macDataViewListCtrlPtr
->GetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not get header description."));
669 headerDescription
.titleString
= cfTitle
;
670 wxCHECK_RET(macDataViewListCtrlPtr
->SetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not set header description."));
673 } /* wxDataViewColumn::SetTitle(wxString const&) */
675 void wxDataViewColumn::SetWidth(int width
)
677 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
680 if ((width
>= this->m_minWidth
) && (width
<= this->m_maxWidth
))
682 this->m_width
= width
;
683 if (dataViewCtrlPtr
!= NULL
)
685 // variable definition and initialization:
686 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
688 if (macDataViewListCtrlPtr
!= NULL
)
689 wxCHECK_RET(macDataViewListCtrlPtr
->SetColumnWidth(this->GetPropertyID(),static_cast<UInt16
>(width
)) == noErr
,_("Could not set column width."));
692 } /* wxDataViewColumn::SetWidth(int) */
694 IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumn
,wxDataViewColumnBase
)
696 //-----------------------------------------------------------------------------
698 //-----------------------------------------------------------------------------
700 void wxDataViewCtrl::Init(void)
702 this->m_Deleting
= false;
703 this->m_macIsUserPane
= false;
704 this->m_cgContext
= NULL
;
705 } /* wxDataViewCtrl::Init(void) */
707 bool wxDataViewCtrl::Create(wxWindow
*parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
, const wxValidator
& validator
)
709 if (!(this->wxControl::Create(parent
,id
,pos
,size
,(style
| wxSUNKEN_BORDER
) & ~(wxHSCROLL
| wxVSCROLL
),validator
)))
713 MacSetClipChildren(true) ;
716 this->m_peer
= new wxMacDataViewDataBrowserListViewControl(this,pos
,size
,style
);
717 this->MacPostControlCreate(pos
,size
);
718 ::SetAutomaticControlDragTrackingEnabledForWindow(::GetControlOwner(this->m_peer
->GetControlRef()),true);
720 InstallControlEventHandler(this->m_peer
->GetControlRef(),GetwxMacDataViewCtrlEventHandlerUPP(),GetEventTypeCount(eventList
),eventList
,this,NULL
);
723 } /* wxDataViewCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator) */
725 bool wxDataViewCtrl::AssociateModel(wxDataViewModel
* model
)
727 if (!wxDataViewCtrlBase::AssociateModel(model
))
730 model
->AddNotifier(new wxMacDataViewModelNotifier(dynamic_cast<wxMacDataViewDataBrowserListViewControl
*>(this->m_peer
)));
733 } /* wxDataViewCtrl::AssociateModel(wxDataViewModel*) */
735 bool wxDataViewCtrl::AppendColumn(wxDataViewColumn
* dataViewColumnPtr
)
737 DataBrowserPropertyID NewPropertyID
;
739 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
742 // first, some error checking:
743 wxCHECK_MSG(MacDataViewListCtrlPtr
!= NULL
, false,_("m_peer is not or incorrectly initialized"));
744 wxCHECK_MSG(dataViewColumnPtr
!= NULL
, false,_("Column pointer must not be NULL."));
745 wxCHECK_MSG(dataViewColumnPtr
->GetRenderer() != NULL
, false,_("Column does not have a renderer."));
746 wxCHECK_MSG(this->GetModel() != NULL
, false,_("No model associated with control."));
747 wxCHECK_MSG((dataViewColumnPtr
->GetModelColumn() >= 0) &&
748 (dataViewColumnPtr
->GetModelColumn() < this->GetModel()->GetColumnCount()),false,_("Column's model column has no equivalent in the associated model."));
749 if ((MacDataViewListCtrlPtr
->GetFreePropertyID(&NewPropertyID
) == noErr
) && this->wxDataViewCtrlBase::AppendColumn(dataViewColumnPtr
))
751 // insert column into hash map:
752 this->m_ColumnPointers
.insert(ColumnPointerHashMapType::value_type(NewPropertyID
,dataViewColumnPtr
));
754 // variable definitions:
755 DataBrowserListViewColumnDesc columnDescription
;
756 wxMacCFStringHolder
cfTitle(dataViewColumnPtr
->GetTitle(),(this->m_font
.Ok() ? this->m_font
.GetEncoding() : wxLocale::GetSystemEncoding()));
758 // initialize column description:
759 dataViewColumnPtr
->SetPropertyID(NewPropertyID
);
760 columnDescription
.propertyDesc
.propertyID
= NewPropertyID
;
761 columnDescription
.propertyDesc
.propertyType
= dataViewColumnPtr
->GetRenderer()->GetPropertyType();
762 columnDescription
.propertyDesc
.propertyFlags
= kDataBrowserListViewSelectionColumn
; // make the column selectable
763 if (dataViewColumnPtr
->IsSortable())
764 columnDescription
.propertyDesc
.propertyFlags
|= kDataBrowserListViewSortableColumn
;
766 if (dataViewColumnPtr
->IsMovable())
767 columnDescription
.propertyDesc
.propertyFlags
|= kDataBrowserListViewMovableColumn
;
769 if (dataViewColumnPtr
->GetRenderer()->GetMode() == wxDATAVIEW_CELL_EDITABLE
)
770 columnDescription
.propertyDesc
.propertyFlags
|= kDataBrowserPropertyIsEditable
;
771 #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
772 if ((columnDescription
.propertyDesc
.propertyType
== kDataBrowserTextType
) ||
773 (columnDescription
.propertyDesc
.propertyType
== kDataBrowserIconAndTextType
) ||
774 (columnDescription
.propertyDesc
.propertyType
== kDataBrowserDateTimeType
))
775 columnDescription
.propertyDesc
.propertyFlags
|= kDataBrowserListViewTypeSelectColumn
;
777 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
778 columnDescription
.propertyDesc
.propertyFlags
|= kDataBrowserListViewNoGapForIconInHeaderButton
;
780 columnDescription
.headerBtnDesc
.version
= kDataBrowserListViewLatestHeaderDesc
;
781 if (dataViewColumnPtr
->IsResizeable())
783 columnDescription
.headerBtnDesc
.minimumWidth
= 0;
784 columnDescription
.headerBtnDesc
.maximumWidth
= 30000;
788 columnDescription
.headerBtnDesc
.minimumWidth
= dataViewColumnPtr
->GetWidth();
789 columnDescription
.headerBtnDesc
.maximumWidth
= dataViewColumnPtr
->GetWidth();
791 columnDescription
.headerBtnDesc
.titleOffset
= 0;
792 columnDescription
.headerBtnDesc
.titleString
= cfTitle
; // we cannot directly use the wxMacCFStringHolder constructor call because then the CFStringRef is released
793 // having called 'AddColumn' where the title (CFStringRef) is going to be used
794 columnDescription
.headerBtnDesc
.initialOrder
= kDataBrowserOrderIncreasing
;
795 columnDescription
.headerBtnDesc
.btnFontStyle
.flags
= kControlUseFontMask
| kControlUseJustMask
;
796 switch (dataViewColumnPtr
->GetAlignment())
799 case wxALIGN_CENTER_HORIZONTAL
:
800 columnDescription
.headerBtnDesc
.btnFontStyle
.just
= teCenter
;
803 columnDescription
.headerBtnDesc
.btnFontStyle
.just
= teFlushLeft
;
806 columnDescription
.headerBtnDesc
.btnFontStyle
.just
= teFlushRight
;
809 columnDescription
.headerBtnDesc
.btnFontStyle
.just
= teFlushDefault
;
811 columnDescription
.headerBtnDesc
.btnFontStyle
.font
= kControlFontViewSystemFont
;
812 columnDescription
.headerBtnDesc
.btnFontStyle
.style
= normal
;
813 columnDescription
.headerBtnDesc
.btnContentInfo
.contentType
= kControlContentIconRef
;
814 if (dataViewColumnPtr
->GetBitmap().Ok())
815 columnDescription
.headerBtnDesc
.btnContentInfo
.u
.iconRef
= dataViewColumnPtr
->GetBitmap().GetBitmapData()->GetIconRef();
817 wxCHECK_MSG(MacDataViewListCtrlPtr
->AddColumn(&columnDescription
,kDataBrowserListViewAppendColumn
) == noErr
,false,_("Column could not be added."));
819 // final adjustments for the layout:
820 wxCHECK_MSG(MacDataViewListCtrlPtr
->SetColumnWidth(NewPropertyID
,dataViewColumnPtr
->GetWidth()) == noErr
,false,_("Column width could not be set."));
822 // make sure that the data is up-to-date...
823 // if the newly appended column is the first column add the initial data to the control and mark the column as an expander column,
824 // otherwise ask the control to 'update' the data in the newly appended column:
825 if (this->GetColumnCount() == 1)
827 this->SetExpanderColumn(dataViewColumnPtr
);
828 this->AddChildrenLevel(wxDataViewItem());
831 MacDataViewListCtrlPtr
->UpdateItems(kDataBrowserNoItem
,0,NULL
,kDataBrowserItemNoProperty
,NewPropertyID
);
837 } /* wxDataViewCtrl::AppendColumn(wxDataViewColumn*) */
839 bool wxDataViewCtrl::ClearColumns(void)
841 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
844 while (this->m_ColumnPointers
.begin() != this->m_ColumnPointers
.end())
846 wxCHECK_MSG(MacDataViewListCtrlPtr
->RemoveColumnByProperty(this->m_ColumnPointers
.begin()->first
) == noErr
,false,_("Could not remove column."));
847 delete this->m_ColumnPointers
.begin()->second
;
848 this->m_ColumnPointers
.erase(this->m_ColumnPointers
.begin());
851 } /* wxDataViewCtrl::ClearColumns(void) */
853 bool wxDataViewCtrl::DeleteColumn(wxDataViewColumn
* columnPtr
)
855 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
858 if ((MacDataViewListCtrlPtr
->RemoveColumnByProperty(columnPtr
->GetPropertyID()) == noErr
) && (this->m_ColumnPointers
.erase(columnPtr
->GetPropertyID()) > 0))
865 } /* wxDataViewCtrl::DeleteColumn(wxDataViewColumn*) */
867 wxDataViewColumn
* wxDataViewCtrl::GetColumn(unsigned int pos
) const
869 DataBrowserPropertyID propertyID
;
871 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
874 if (MacDataViewListCtrlPtr
->GetPropertyID(pos
,&propertyID
) == noErr
)
876 // variable definition:
877 ColumnPointerHashMapType::const_iterator
Result(this->m_ColumnPointers
.find(propertyID
));
879 if (Result
!= this->m_ColumnPointers
.end())
880 return Result
->second
;
886 } /* wxDataViewCtrl::GetColumn(unsigned int pos) const */
888 unsigned int wxDataViewCtrl::GetColumnCount(void) const
890 return this->m_ColumnPointers
.size();
891 } /* wxDataViewCtrl::GetColumnCount(void) const */
893 int wxDataViewCtrl::GetColumnPosition( const wxDataViewColumn
*column
) const
898 wxDataViewColumn
*wxDataViewCtrl::GetSortingColumn() const
903 void wxDataViewCtrl::Collapse(wxDataViewItem
const& item
)
905 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
908 MacDataViewListCtrlPtr
->CloseContainer(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
909 } /* wxDataViewCtrl::Collapse(wxDataViewItem const&) */
911 void wxDataViewCtrl::EnsureVisible(wxDataViewItem
const& item
, wxDataViewColumn
const* columnPtr
)
915 // variable definition and initialization:
916 DataBrowserPropertyID propertyID
;
917 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
919 if (columnPtr
!= NULL
)
920 propertyID
= columnPtr
->GetPropertyID();
922 propertyID
= kDataBrowserNoItem
;
923 MacDataViewListCtrlPtr
->RevealItem(reinterpret_cast<DataBrowserItemID
>(item
.GetID()),propertyID
,kDataBrowserRevealOnly
);
925 } /* wxDataViewCtrl::EnsureVisible(wxDataViewItem const&, wxDataViewColumn const*) */
927 void wxDataViewCtrl::Expand(wxDataViewItem
const& item
)
929 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
932 MacDataViewListCtrlPtr
->OpenContainer(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
933 } /* wxDataViewCtrl::Expand(wxDataViewItem const&) */
935 unsigned int wxDataViewCtrl::GetCount(void) const
940 wxCHECK_MSG(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
)->GetItemCount(&noOfItems
) == noErr
,0,_("Could not determine number of items"));
942 } /* wxDataViewCtrl::GetCount(void) const */
944 wxRect
wxDataViewCtrl::GetItemRect(wxDataViewItem
const& item
, wxDataViewColumn
const* columnPtr
) const
946 if (item
.IsOk() && (columnPtr
!= NULL
))
948 // variable definition:
950 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
952 if (MacDataViewListCtrlPtr
->GetPartBounds(reinterpret_cast<DataBrowserItemID
>(item
.GetID()),columnPtr
->GetPropertyID(),kDataBrowserPropertyContentPart
,&MacRectangle
) == noErr
)
954 // variable definition:
957 ::wxMacNativeToRect(&MacRectangle
,&rectangle
);
965 } /* wxDataViewCtrl::GetItemRect(wxDataViewItem const&, unsigned int) const */
967 wxDataViewItem
wxDataViewCtrl::GetSelection(void) const
969 wxArrayDataBrowserItemID itemIDs
;
971 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
974 if (MacDataViewListCtrlPtr
->GetSelectedItemIDs(itemIDs
) > 0)
975 return wxDataViewItem(reinterpret_cast<void*>(itemIDs
[0]));
977 return wxDataViewItem();
978 } /* wxDataViewCtrl::GetSelection(void) const */
980 int wxDataViewCtrl::GetSelections(wxDataViewItemArray
& sel
) const
982 size_t NoOfSelectedItems
;
984 wxArrayDataBrowserItemID itemIDs
;
986 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
989 NoOfSelectedItems
= MacDataViewListCtrlPtr
->GetSelectedItemIDs(itemIDs
);
991 sel
.SetCount(NoOfSelectedItems
);
992 for (size_t i
=0; i
<NoOfSelectedItems
; ++i
)
993 sel
[i
] = wxDataViewItem(reinterpret_cast<void*>(itemIDs
[i
]));
994 return static_cast<int>(NoOfSelectedItems
);
995 } /* wxDataViewCtrl::GetSelections(wxDataViewItemArray&) const */
997 void wxDataViewCtrl::HitTest(wxPoint
const& point
, wxDataViewItem
& item
, wxDataViewColumn
*& columnPtr
) const
999 item
= wxDataViewItem();
1001 } /* wxDataViewCtrl::HitTest(wxPoint const&, wxDataViewItem&, wxDataViewColumn*&) const */
1003 bool wxDataViewCtrl::IsSelected(wxDataViewItem
const& item
) const
1005 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1008 return MacDataViewListCtrlPtr
->IsItemSelected(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
1009 } /* wxDataViewCtrl::IsSelected(wxDataViewItem const&) const */
1011 void wxDataViewCtrl::SelectAll(void)
1013 DataBrowserItemID
* itemIDPtr
;
1015 Handle
handle(::NewHandle(0));
1019 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1022 wxCHECK_RET(MacDataViewListCtrlPtr
->GetItems(kDataBrowserNoItem
,true,kDataBrowserItemAnyState
,handle
) == noErr
,_("Could not get items."));
1023 NoOfItems
= static_cast<size_t>(::GetHandleSize(handle
)/sizeof(DataBrowserItemID
));
1025 itemIDPtr
= (DataBrowserItemID
*) (*handle
);
1026 MacDataViewListCtrlPtr
->SetSelectedItems(NoOfItems
,itemIDPtr
,kDataBrowserItemsAssign
);
1028 DisposeHandle(handle
);
1029 } /* wxDataViewCtrl::SelectAll(void) */
1031 void wxDataViewCtrl::Select(wxDataViewItem
const& item
)
1035 // variable definition and initialization:
1036 DataBrowserItemID
itemID(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
1037 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1039 MacDataViewListCtrlPtr
->SetSelectedItems(1,&itemID
,kDataBrowserItemsAdd
);
1041 } /* wxDataViewCtrl::Select(wxDataViewItem const&) */
1043 void wxDataViewCtrl::SetSelections(wxDataViewItemArray
const& sel
)
1045 size_t const NoOfSelections
= sel
.GetCount();
1047 DataBrowserItemID
* itemIDs
;
1049 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1052 itemIDs
= new DataBrowserItemID
[NoOfSelections
];
1053 for (size_t i
=0; i
<NoOfSelections
; ++i
)
1054 itemIDs
[i
] = reinterpret_cast<DataBrowserItemID
>(sel
[i
].GetID());
1055 MacDataViewListCtrlPtr
->SetSelectedItems(NoOfSelections
,itemIDs
,kDataBrowserItemsAssign
);
1057 } /* wxDataViewCtrl::SetSelections(wxDataViewItemArray const&) */
1059 void wxDataViewCtrl::Unselect(wxDataViewItem
const& item
)
1063 // variable definition and initialization:
1064 DataBrowserItemID
itemID(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
1065 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1067 MacDataViewListCtrlPtr
->SetSelectedItems(1,&itemID
,kDataBrowserItemsRemove
);
1069 } /* wxDataViewCtrl::Unselect(wxDataViewItem const&) */
1071 void wxDataViewCtrl::UnselectAll(void)
1073 DataBrowserItemID
* itemIDPtr
;
1075 Handle
handle(::NewHandle(0));
1079 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1082 wxCHECK_RET(MacDataViewListCtrlPtr
->GetItems(kDataBrowserNoItem
,true,kDataBrowserItemAnyState
,handle
) == noErr
,_("Could not get items."));
1083 NoOfItems
= static_cast<size_t>(::GetHandleSize(handle
)/sizeof(DataBrowserItemID
));
1085 itemIDPtr
= (DataBrowserItemID
*) (*handle
);
1086 MacDataViewListCtrlPtr
->SetSelectedItems(NoOfItems
,itemIDPtr
,kDataBrowserItemsRemove
);
1088 DisposeHandle(handle
);
1089 } /* wxDataViewCtrl::UnselectAll(void) */
1092 void wxDataViewCtrl::AddChildrenLevel(wxDataViewItem
const& parentItem
)
1096 wxDataViewItemArray items
;
1099 wxCHECK_RET(this->GetModel() != NULL
,_("Model pointer not initialized."));
1100 NoOfChildren
= this->GetModel()->GetChildren(parentItem
,items
);
1101 for (int i
=0; i
<NoOfChildren
; ++i
)
1102 (void) this->GetModel()->ItemAdded(parentItem
,items
[i
]);
1103 } /* wxDataViewCtrl::AddChildrenLevel(wxDataViewItem const&) */
1105 wxDataViewColumn
* wxDataViewCtrl::GetColumnPtr(DataBrowserPropertyID propertyID
) const
1107 // variable definition:
1108 ColumnPointerHashMapType::const_iterator
Result(this->m_ColumnPointers
.find(propertyID
));
1110 if (Result
!= this->m_ColumnPointers
.end())
1111 return Result
->second
;
1114 } /* wxDataViewCtrl::GetColumnPtr(DataBrowserPropertyID) const */
1116 // inherited methods from wxDataViewCtrlBase
1117 void wxDataViewCtrl::DoSetExpanderColumn(void)
1119 if (this->GetExpanderColumn() != NULL
)
1121 // variable definition and initialization:
1122 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1124 (void) MacDataViewListCtrlPtr
->SetDisclosureColumn(this->GetExpanderColumn()->GetPropertyID());
1126 } /* wxDataViewCtrl::DoSetExpanderColumn(void) */
1128 void wxDataViewCtrl::DoSetIndent(void)
1130 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1133 (void) MacDataViewListCtrlPtr
->SetIndent(static_cast<float>(this->GetIndent()));
1134 } /* wxDataViewCtrl::DoSetIndent(void) */
1137 void wxDataViewCtrl::OnSize(wxSizeEvent
& event
)
1139 unsigned int const NoOfColumns
= this->GetColumnCount();
1142 for (unsigned int i
=0; i
<NoOfColumns
; ++i
)
1144 // variable definition and initialization:
1145 wxDataViewColumn
* dataViewColumnPtr(this->GetColumn(i
));
1147 if (dataViewColumnPtr
!= NULL
)
1149 // variable definition and initialization:
1150 wxDataViewCustomRenderer
* dataViewCustomRendererPtr(dynamic_cast<wxDataViewCustomRenderer
*>(dataViewColumnPtr
->GetRenderer()));
1152 if (dataViewCustomRendererPtr
!= NULL
)
1153 dataViewCustomRendererPtr
->SetDC(NULL
); // reset DC because DC has changed
1157 } /* wxDataViewCtrl::OnSize(wxSizeEvent&) */
1159 IMPLEMENT_DYNAMIC_CLASS(wxDataViewCtrl
,wxDataViewCtrlBase
)
1161 BEGIN_EVENT_TABLE(wxDataViewCtrl
,wxDataViewCtrlBase
)
1162 EVT_SIZE(wxDataViewCtrl::OnSize
)
1166 // !wxUSE_GENERICDATAVIEWCTRL
1169 // wxUSE_DATAVIEWCTRL