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"
25 #include "wx/settings.h"
26 #include "wx/dcclient.h"
30 #include "wx/renderer.h"
32 //-----------------------------------------------------------------------------
34 //-----------------------------------------------------------------------------
36 // a list of all catchable events:
37 static EventTypeSpec
const eventList
[] =
39 {kEventClassControl
, kEventControlDraw
},
40 {kEventClassControl
, kEventControlHit
}
43 //-----------------------------------------------------------------------------
45 //-----------------------------------------------------------------------------
47 static pascal OSStatus
wxMacDataViewCtrlEventHandler(EventHandlerCallRef handler
, EventRef EventReference
, void* Data
)
49 wxDataViewCtrl
* DataViewCtrlPtr((wxDataViewCtrl
*) Data
); // the 'Data' variable always contains a pointer to the data view control that installed the handler
51 wxMacCarbonEvent
CarbonEvent(EventReference
) ;
54 switch (GetEventKind(EventReference
))
56 case kEventControlDraw
:
60 DataViewCtrlPtr
->MacSetDrawingContext(CarbonEvent
.GetParameter
<CGContextRef
>(kEventParamCGContextRef
,typeCGContextRef
));
61 status
= ::CallNextEventHandler(handler
,EventReference
);
62 DataViewCtrlPtr
->MacSetDrawingContext(NULL
);
65 case kEventControlHit
:
66 if (CarbonEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPart
,typeControlPartCode
) == kControlButtonPart
) // we only care about the header
68 ControlRef controlReference
;
69 DataBrowserPropertyID columnPropertyID
;
70 unsigned long columnIndex
;
72 wxDataViewEvent
DataViewEvent(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK
,DataViewCtrlPtr
->GetId());
74 CarbonEvent
.GetParameter(kEventParamDirectObject
,&controlReference
);
75 // determine the column that triggered the event (this is the column that is responsible for sorting the data view):
76 status
= ::GetDataBrowserSortProperty(controlReference
,&columnPropertyID
);
77 wxCHECK(status
== noErr
,status
);
78 status
= ::GetDataBrowserTableViewColumnPosition(controlReference
,columnPropertyID
,&columnIndex
);
79 if (status
== errDataBrowserPropertyNotFound
) // user clicked into part of the header that does not have a property
80 return ::CallNextEventHandler(handler
,EventReference
);
81 wxCHECK(status
== noErr
,status
);
82 // initialize wxWidget event handler:
83 DataViewEvent
.SetEventObject(DataViewCtrlPtr
);
84 DataViewEvent
.SetColumn(columnIndex
);
85 DataViewEvent
.SetDataViewColumn(DataViewCtrlPtr
->GetColumn(columnIndex
));
86 // finally sent the equivalent wxWidget event:
87 #if wxCHECK_VERSION(2,9,0)
88 DataViewCtrlPtr
->HandleWindowEvent(DataViewEvent
);
90 DataViewCtrlPtr
->GetEventHandler()->ProcessEvent(DataViewEvent
);
92 return ::CallNextEventHandler(handler
,EventReference
);
95 return eventNotHandledErr
;
98 return eventNotHandledErr
;
99 } /* wxMacDataViewCtrlEventHandler(EventHandlerCallRef, EventRef, void*) */
101 static DataBrowserItemID
* CreateDataBrowserItemIDArray(size_t& noOfEntries
, wxDataViewItemArray
const& items
) // returns a newly allocated pointer to valid data browser item IDs
103 size_t const noOfItems
= items
.GetCount();
105 DataBrowserItemID
* itemIDs(new DataBrowserItemID
[noOfItems
]);
108 // convert all valid data view items to data browser items
110 for (size_t i
=0; i
<noOfItems
; ++i
)
113 itemIDs
[noOfEntries
] = reinterpret_cast<DataBrowserItemID
>(items
[i
].GetID());
118 } /* CreateDataBrowserItemIDArray(size_t&, wxDataViewItemArray const&) */
120 #if wxCHECK_VERSION(2,9,0)
121 static bool InitializeColumnDescription(DataBrowserListViewColumnDesc
& columnDescription
, wxDataViewColumn
const* columnPtr
, DataBrowserPropertyID columnPropertyID
, wxCFStringRef
const& title
)
123 static bool InitializeColumnDescription(DataBrowserListViewColumnDesc
& columnDescription
, wxDataViewColumn
const* columnPtr
, DataBrowserPropertyID columnPropertyID
, wxMacCFStringHolder
const& title
)
126 // set properties for the column:
127 columnDescription
.propertyDesc
.propertyID
= columnPropertyID
;
128 columnDescription
.propertyDesc
.propertyType
= columnPtr
->GetRenderer()->GetPropertyType();
129 columnDescription
.propertyDesc
.propertyFlags
= kDataBrowserListViewSelectionColumn
; // make the column selectable
130 if (columnPtr
->IsReorderable())
131 columnDescription
.propertyDesc
.propertyFlags
|= kDataBrowserListViewMovableColumn
;
132 if (columnPtr
->IsResizeable())
134 columnDescription
.headerBtnDesc
.minimumWidth
= 0;
135 columnDescription
.headerBtnDesc
.maximumWidth
= 30000; // 32767 is the theoretical maximum though but 30000 looks nicer
139 columnDescription
.headerBtnDesc
.minimumWidth
= columnPtr
->GetWidth();
140 columnDescription
.headerBtnDesc
.maximumWidth
= columnPtr
->GetWidth();
142 if (columnPtr
->IsSortable())
143 columnDescription
.propertyDesc
.propertyFlags
|= kDataBrowserListViewSortableColumn
;
144 if (columnPtr
->GetRenderer()->GetMode() == wxDATAVIEW_CELL_EDITABLE
)
145 columnDescription
.propertyDesc
.propertyFlags
|= kDataBrowserPropertyIsEditable
;
146 if ((columnDescription
.propertyDesc
.propertyType
== kDataBrowserCustomType
) ||
147 (columnDescription
.propertyDesc
.propertyType
== kDataBrowserDateTimeType
) ||
148 (columnDescription
.propertyDesc
.propertyType
== kDataBrowserIconAndTextType
) ||
149 (columnDescription
.propertyDesc
.propertyType
== kDataBrowserTextType
))
150 columnDescription
.propertyDesc
.propertyFlags
|= kDataBrowserListViewTypeSelectColumn
; // enables generally the possibility to have user input for the mentioned types
151 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
152 columnDescription
.propertyDesc
.propertyFlags
|= kDataBrowserListViewNoGapForIconInHeaderButton
;
154 // set header's properties:
155 columnDescription
.headerBtnDesc
.version
= kDataBrowserListViewLatestHeaderDesc
;
156 columnDescription
.headerBtnDesc
.titleOffset
= 0;
157 columnDescription
.headerBtnDesc
.titleString
= ::CFStringCreateCopy(kCFAllocatorDefault
,title
);
158 columnDescription
.headerBtnDesc
.initialOrder
= kDataBrowserOrderIncreasing
; // choose one of the orders as "undefined" is not supported anyway (s. ControlDefs.h in the HIToolbox framework)
159 columnDescription
.headerBtnDesc
.btnFontStyle
.flags
= kControlUseFontMask
| kControlUseJustMask
;
160 switch (columnPtr
->GetAlignment())
163 case wxALIGN_CENTER_HORIZONTAL
:
164 columnDescription
.headerBtnDesc
.btnFontStyle
.just
= teCenter
;
167 columnDescription
.headerBtnDesc
.btnFontStyle
.just
= teFlushLeft
;
170 columnDescription
.headerBtnDesc
.btnFontStyle
.just
= teFlushRight
;
173 columnDescription
.headerBtnDesc
.btnFontStyle
.just
= teFlushDefault
;
175 columnDescription
.headerBtnDesc
.btnFontStyle
.font
= kControlFontViewSystemFont
;
176 columnDescription
.headerBtnDesc
.btnFontStyle
.style
= normal
;
177 if (columnPtr
->GetBitmap().IsOk())
179 columnDescription
.headerBtnDesc
.btnContentInfo
.contentType
= kControlContentIconRef
;
180 #if wxCHECK_VERSION(2,9,0)
181 columnDescription
.headerBtnDesc
.btnContentInfo
.u
.iconRef
= columnPtr
->GetBitmap().GetIconRef();
183 columnDescription
.headerBtnDesc
.btnContentInfo
.u
.iconRef
= columnPtr
->GetBitmap().GetBitmapData()->GetIconRef();
188 // not text only as we otherwise could not add a bitmap later
189 // columnDescription.headerBtnDesc.btnContentInfo.contentType = kControlContentTextOnly;
190 columnDescription
.headerBtnDesc
.btnContentInfo
.contentType
= kControlContentIconRef
;
191 columnDescription
.headerBtnDesc
.btnContentInfo
.u
.iconRef
= NULL
;
196 } /* InitializeColumnDescription(DataBrowserListViewColumnDesc&, wxDataViewColumn const*, DataBrowserPropertyID, wxMacCFStringHolder const&) */
198 //-----------------------------------------------------------------------------
199 // local function pointers
200 //-----------------------------------------------------------------------------
202 DEFINE_ONE_SHOT_HANDLER_GETTER(wxMacDataViewCtrlEventHandler
)
204 // ---------------------------------------------------------
205 // wxMacDataViewModelNotifier
206 // ---------------------------------------------------------
208 class wxMacDataViewModelNotifier
: public wxDataViewModelNotifier
211 wxMacDataViewModelNotifier(wxMacDataViewDataBrowserListViewControl
* initDataViewControlPtr
) : m_dataViewControlPtr(initDataViewControlPtr
)
215 virtual bool ItemAdded(const wxDataViewItem
&parent
, const wxDataViewItem
&item
)
217 DataBrowserItemID
itemID(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
220 wxCHECK_MSG(item
.IsOk(),false,_("Added item is invalid."));
221 return (!(parent
.IsOk()) && (this->m_dataViewControlPtr
->AddItem(kDataBrowserNoItem
,&itemID
) == noErr
) ||
222 parent
.IsOk() && (this->m_dataViewControlPtr
->AddItem(reinterpret_cast<DataBrowserItemID
>(parent
.GetID()),&itemID
) == noErr
));
223 } /* ItemAdded(wxDataViewItem const&, wxDataViewItem const&) */
225 virtual bool ItemsAdded(wxDataViewItem
const& parent
, wxDataViewItemArray
const& items
)
229 DataBrowserItemID
* itemIDs
;
234 // convert all valid data view items to data browser items:
235 itemIDs
= ::CreateDataBrowserItemIDArray(noOfEntries
,items
);
236 // insert all valid items into control:
237 noFailureFlag
= ((noOfEntries
== 0) ||
238 !(parent
.IsOk()) && (this->m_dataViewControlPtr
->AddItems(kDataBrowserNoItem
,noOfEntries
,itemIDs
,kDataBrowserItemNoProperty
) == noErr
) ||
239 parent
.IsOk() && (this->m_dataViewControlPtr
->AddItems(reinterpret_cast<DataBrowserItemID
>(parent
.GetID()),noOfEntries
,itemIDs
,kDataBrowserItemNoProperty
) == noErr
));
240 // give allocated array space free again:
243 return noFailureFlag
;
244 } /* ItemsAdded(wxDataViewItem const&, wxDataViewItemArray const&) */
246 virtual bool ItemChanged(wxDataViewItem
const& item
)
248 DataBrowserItemID
itemID(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
251 wxCHECK_MSG(item
.IsOk(),false,_("Changed item is invalid."));
252 if (this->m_dataViewControlPtr
->UpdateItems(&itemID
) == noErr
)
254 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->m_dataViewControlPtr
->GetPeer()));
256 // sent the equivalent wxWidget event:
257 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED
,dataViewCtrlPtr
->GetId()); // variable defintion
259 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
260 dataViewEvent
.SetItem(item
);
261 // sent the equivalent wxWidget event:
262 #if wxCHECK_VERSION(2,9,0)
263 dataViewCtrlPtr
->HandleWindowEvent(dataViewEvent
);
265 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
272 } /* ItemChanged(wxDataViewItem const&) */
274 virtual bool ItemsChanged(wxDataViewItemArray
const& items
)
278 DataBrowserItemID
* itemIDs
;
283 // convert all valid data view items to data browser items:
284 itemIDs
= ::CreateDataBrowserItemIDArray(noOfEntries
,items
);
285 // change items (ATTENTION: ONLY ITEMS OF THE ROOT ARE CHANGED BECAUSE THE PARENT PARAMETER IS MISSING):
286 noFailureFlag
= (this->m_dataViewControlPtr
->UpdateItems(kDataBrowserNoItem
,noOfEntries
,itemIDs
,kDataBrowserItemNoProperty
,kDataBrowserItemNoProperty
) == noErr
);
289 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->m_dataViewControlPtr
->GetPeer()));
291 // send for all changed items a wxWidget event:
292 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED
,dataViewCtrlPtr
->GetId()); // variable defintion
294 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
295 for (size_t i
=0; i
<noOfEntries
; ++i
)
297 dataViewEvent
.SetItem(reinterpret_cast<void*>(itemIDs
[i
]));
298 #if wxCHECK_VERSION(2,9,0)
299 dataViewCtrlPtr
->HandleWindowEvent(dataViewEvent
);
301 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
305 // release allocated array space:
308 return noFailureFlag
;
309 } /* ItemsChanged(wxDataViewItem const&) */
311 virtual bool ItemDeleted(wxDataViewItem
const& parent
, wxDataViewItem
const& item
)
315 // variable definition and initialization:
316 DataBrowserItemID
itemID(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
317 OSStatus errorStatus
;
318 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->m_dataViewControlPtr
->GetPeer()));
320 // 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
321 // not to be identical because the being edited item might be below the passed item in the hierarchy);
322 // to prevent the control trying to ask the model to update an already deleted item the control is informed that currently a deleting process
323 // has been started and that variables can currently not be updated even when requested by the system:
324 dataViewCtrlPtr
->SetDeleting(true);
325 errorStatus
= this->m_dataViewControlPtr
->RemoveItem(reinterpret_cast<DataBrowserItemID
>(parent
.GetID()),&itemID
);
326 // enable automatic updating again:
327 dataViewCtrlPtr
->SetDeleting(false);
328 return (errorStatus
== noErr
);
332 } /* ItemDeleted(wxDataViewItem const&, wxDataViewItem const&) */
334 virtual bool ItemsDeleted(wxDataViewItem
const& parent
, wxDataViewItemArray
const& items
)
338 DataBrowserItemID
* itemIDs
;
340 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->m_dataViewControlPtr
->GetPeer()));
345 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
,false,_("Data view control is not correctly initialized"));
346 // convert all valid data view items to data browser items:
347 itemIDs
= ::CreateDataBrowserItemIDArray(noOfEntries
,items
);
348 // 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
349 // not to be identical because the being edited item might be below the passed item in the hierarchy);
350 // to prevent the control trying to ask the model to update an already deleted item the control is informed that currently a deleting process
351 // has been started and that variables can currently not be updated even when requested by the system:
352 dataViewCtrlPtr
->SetDeleting(true);
353 // insert all valid items into control:
354 noFailureFlag
= ((noOfEntries
== 0) ||
355 !(parent
.IsOk()) && (this->m_dataViewControlPtr
->RemoveItems(kDataBrowserNoItem
,noOfEntries
,itemIDs
,kDataBrowserItemNoProperty
) == noErr
) ||
356 parent
.IsOk() && (this->m_dataViewControlPtr
->RemoveItems(reinterpret_cast<DataBrowserItemID
>(parent
.GetID()),noOfEntries
,itemIDs
,kDataBrowserItemNoProperty
) == noErr
));
357 // enable automatic updating again:
358 dataViewCtrlPtr
->SetDeleting(false);
359 // give allocated array space free again:
362 return noFailureFlag
;
363 } /* ItemsDeleted(wxDataViewItem const&, wxDataViewItemArray const&) */
365 virtual bool ValueChanged(wxDataViewItem
const& item
, unsigned int col
)
367 DataBrowserItemID
itemID(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
368 DataBrowserItemID parentID
;
370 DataBrowserPropertyID propertyID
;
372 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->m_dataViewControlPtr
->GetPeer()));
375 wxCHECK_MSG(item
.IsOk(), false,_("Passed item is invalid."));
376 wxCHECK_MSG(this->GetOwner() != NULL
,false,_("Owner not initialized."));
377 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
, false,_("Control is wrongly initialized."));
378 parentID
= reinterpret_cast<DataBrowserItemID
>(this->GetOwner()->GetParent(item
).GetID());
379 if ((this->m_dataViewControlPtr
->GetPropertyID(col
,&propertyID
) == noErr
) &&
380 (this->m_dataViewControlPtr
->UpdateItems(parentID
,1,&itemID
,dataViewCtrlPtr
->GetColumn(col
)->GetPropertyID(),propertyID
) == noErr
))
382 // variable definition and initialization:
383 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED
,dataViewCtrlPtr
->GetId());
385 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
386 dataViewEvent
.SetColumn(col
);
387 dataViewEvent
.SetItem(item
);
388 // send the equivalent wxWidget event:
389 #if wxCHECK_VERSION(2,9,0)
390 dataViewCtrlPtr
->HandleWindowEvent(dataViewEvent
);
392 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
399 } /* ValueChanged(wxDataViewItem const&, unsigned int) */
401 virtual bool Cleared(void)
403 bool noFailureFlag
= (this->m_dataViewControlPtr
->RemoveItems() == noErr
);
405 wxDataViewItemArray array
;
406 GetOwner()->GetChildren( item
, array
);
407 ItemsAdded( item
, array
);
408 return noFailureFlag
;
409 } /* Cleared(void) */
411 virtual void Resort(void)
413 this->m_dataViewControlPtr
->Resort();
421 wxMacDataViewDataBrowserListViewControl
* m_dataViewControlPtr
;
424 // ---------------------------------------------------------
425 // wxDataViewRenderer
426 // ---------------------------------------------------------
428 wxDataViewRenderer::wxDataViewRenderer(wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
429 :wxDataViewRendererBase(varianttype
,mode
,align
), m_alignment(align
), m_mode(mode
)
431 } /* wxDataViewRenderer::wxDataViewRenderer(wxString const&, wxDataViewCellMode) */
433 void wxDataViewRenderer::SetMode(wxDataViewCellMode mode
)
435 wxDataViewColumn
* dataViewColumnPtr
;
439 dataViewColumnPtr
= this->GetOwner();
440 if (dataViewColumnPtr
!= NULL
)
442 // variable definition and initialization:
443 wxDataViewCtrl
* dataViewCtrlPtr(dataViewColumnPtr
->GetOwner());
445 if (dataViewCtrlPtr
!= NULL
)
447 // variable definition and initialization:
448 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
450 if (macDataViewListCtrlPtr
!= NULL
)
452 // variable definition and initialization:
453 DataBrowserPropertyFlags flags
;
455 verify_noerr(macDataViewListCtrlPtr
->GetPropertyFlags(dataViewColumnPtr
->GetPropertyID(),&flags
));
456 if (mode
== wxDATAVIEW_CELL_EDITABLE
)
457 flags
|= kDataBrowserPropertyIsEditable
;
459 flags
&= ~kDataBrowserPropertyIsEditable
;
460 verify_noerr(macDataViewListCtrlPtr
->SetPropertyFlags(dataViewColumnPtr
->GetPropertyID(),flags
));
464 } /* wxDataViewRenderer::SetMode(wxDataViewCellMode) */
466 IMPLEMENT_ABSTRACT_CLASS(wxDataViewRenderer
,wxDataViewRendererBase
)
468 // ---------------------------------------------------------
469 // wxDataViewCustomRenderer
470 // ---------------------------------------------------------
472 wxDataViewCustomRenderer::wxDataViewCustomRenderer(wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
473 :wxDataViewRenderer(varianttype
,mode
,align
), m_editorCtrlPtr(NULL
), m_DCPtr(NULL
)
475 } /* wxDataViewCustomRenderer::wxDataViewCustomRenderer(wxString const&, wxDataViewCellMode) */
477 wxDataViewCustomRenderer::~wxDataViewCustomRenderer(void)
479 if (this->m_DCPtr
!= NULL
)
480 delete this->m_DCPtr
;
481 } /* wxDataViewCustomRenderer::~wxDataViewCustomRenderer(void) */
483 void wxDataViewCustomRenderer::RenderText( const wxString
&text
, int xoffset
, wxRect cell
, wxDC
*dc
, int state
)
485 wxDataViewCtrl
*view
= GetOwner()->GetOwner();
486 wxColour col
= (state
& wxDATAVIEW_CELL_SELECTED
) ? wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT
) : view
->GetForegroundColour();
487 dc
->SetTextForeground(col
);
488 dc
->DrawText( text
, cell
.x
+ xoffset
, cell
.y
+ ((cell
.height
- dc
->GetCharHeight()) / 2));
491 wxDC
* wxDataViewCustomRenderer::GetDC(void)
493 if (this->m_DCPtr
== NULL
)
495 if ((GetOwner() == NULL
) || (GetOwner()->GetOwner() == NULL
))
497 this->m_DCPtr
= new wxWindowDC(this->GetOwner()->GetOwner());
499 return this->m_DCPtr
;
500 } /* wxDataViewCustomRenderer::GetDC(void) */
502 bool wxDataViewCustomRenderer::Render(void)
505 } /* wxDataViewCustomRenderer::Render(void) */
507 void wxDataViewCustomRenderer::SetDC(wxDC
* newDCPtr
)
509 delete this->m_DCPtr
;
510 this->m_DCPtr
= newDCPtr
;
511 } /* wxDataViewCustomRenderer::SetDC(wxDC*) */
513 WXDataBrowserPropertyType
wxDataViewCustomRenderer::GetPropertyType(void) const
515 return kDataBrowserCustomType
;
516 } /* wxDataViewCustomRenderer::GetPropertyType(void) const */
518 IMPLEMENT_ABSTRACT_CLASS(wxDataViewCustomRenderer
, wxDataViewRenderer
)
520 // ---------------------------------------------------------
521 // wxDataViewTextRenderer
522 // ---------------------------------------------------------
524 wxDataViewTextRenderer::wxDataViewTextRenderer(wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
525 :wxDataViewRenderer(varianttype
,mode
,align
)
527 } /* wxDataViewTextRenderer::wxDataViewTextRenderer(wxString const&, wxDataViewCellMode, int) */
529 bool wxDataViewTextRenderer::Render(void)
531 wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Text renderer cannot render value; value type: ")) << this->GetValue().GetType());
533 // variable definition:
534 #if wxCHECK_VERSION(2,9,0)
535 wxCFStringRef
cfString(this->GetValue().GetString(),(this->GetView()->GetFont().Ok() ? this->GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
537 wxMacCFStringHolder
cfString(this->GetValue().GetString(),(this->GetView()->GetFont().Ok() ? this->GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
539 return (::SetDataBrowserItemDataText(this->GetDataReference(),cfString
) == noErr
);
540 } /* wxDataViewTextRenderer::Render(void) */
542 WXDataBrowserPropertyType
wxDataViewTextRenderer::GetPropertyType(void) const
544 return kDataBrowserTextType
;
545 } /* wxDataViewTextRenderer::GetPropertyType(void) const */
547 IMPLEMENT_CLASS(wxDataViewTextRenderer
,wxDataViewRenderer
)
549 // ---------------------------------------------------------
550 // wxDataViewTextRendererAttr
551 // ---------------------------------------------------------
553 wxDataViewTextRendererAttr::wxDataViewTextRendererAttr(wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
554 :wxDataViewTextRenderer(varianttype
,mode
,align
)
556 } /* wxDataViewTextRendererAttr::wxDataViewTextRendererAttr(wxString const&, wxDataViewCellMode, int) */
558 IMPLEMENT_CLASS(wxDataViewTextRendererAttr
,wxDataViewTextRenderer
)
560 // ---------------------------------------------------------
561 // wxDataViewBitmapRenderer
562 // ---------------------------------------------------------
564 wxDataViewBitmapRenderer::wxDataViewBitmapRenderer(wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
565 :wxDataViewRenderer(varianttype
,mode
,align
)
569 bool wxDataViewBitmapRenderer::Render(void)
570 // This method returns 'true' if
571 // - the passed bitmap is valid and it could be assigned to the native data browser;
572 // - the passed bitmap is invalid (or is not initialized); this case simulates a non-existing bitmap.
573 // In all other cases the method returns 'false'.
575 wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Bitmap renderer cannot render value; value type: ")) << this->GetValue().GetType());
577 // variable definition:
580 bitmap
<< this->GetValue();
582 #if wxCHECK_VERSION(2,9,0)
583 return (::SetDataBrowserItemDataIcon(this->GetDataReference(),bitmap
.GetIconRef()) == noErr
);
585 return (::SetDataBrowserItemDataIcon(this->GetDataReference(),bitmap
.GetBitmapData()->GetIconRef()) == noErr
);
589 } /* wxDataViewBitmapRenderer::Render(void) */
591 WXDataBrowserPropertyType
wxDataViewBitmapRenderer::GetPropertyType(void) const
593 return kDataBrowserIconType
;
594 } /* wxDataViewBitmapRenderer::GetPropertyType(void) const */
596 IMPLEMENT_CLASS(wxDataViewBitmapRenderer
,wxDataViewRenderer
)
598 // ---------------------------------------------------------
599 // wxDataViewIconTextRenderer
600 // ---------------------------------------------------------
602 wxDataViewIconTextRenderer::wxDataViewIconTextRenderer(wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
603 :wxDataViewRenderer(varianttype
,mode
)
607 bool wxDataViewIconTextRenderer::Render(void)
609 wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Icon & text renderer cannot render value; value type: ")) << this->GetValue().GetType());
611 // variable definition:
612 wxDataViewIconText iconText
;
614 iconText
<< this->GetValue();
616 // variable definition:
617 #if wxCHECK_VERSION(2,9,0)
618 wxCFStringRef
cfString(iconText
.GetText(),(this->GetView()->GetFont().Ok() ? this->GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
620 wxMacCFStringHolder
cfString(iconText
.GetText(),(this->GetView()->GetFont().Ok() ? this->GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
623 if (iconText
.GetIcon().IsOk())
624 if (::SetDataBrowserItemDataIcon(this->GetDataReference(),MAC_WXHICON(iconText
.GetIcon().GetHICON())) != noErr
)
626 return (::SetDataBrowserItemDataText(this->GetDataReference(),cfString
) == noErr
);
627 } /* wxDataViewIconTextRenderer::Render(void) */
629 WXDataBrowserPropertyType
wxDataViewIconTextRenderer::GetPropertyType(void) const
631 return kDataBrowserIconAndTextType
;
632 } /* wxDataViewIconTextRenderer::GetPropertyType(void) const */
634 IMPLEMENT_ABSTRACT_CLASS(wxDataViewIconTextRenderer
,wxDataViewRenderer
)
637 // ---------------------------------------------------------
638 // wxDataViewToggleRenderer
639 // ---------------------------------------------------------
641 wxDataViewToggleRenderer::wxDataViewToggleRenderer(wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
642 :wxDataViewRenderer(varianttype
,mode
)
646 bool wxDataViewToggleRenderer::Render(void)
648 wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Toggle renderer cannot render value; value type: ")) << this->GetValue().GetType());
649 return (::SetDataBrowserItemDataButtonValue(this->GetDataReference(),this->GetValue().GetBool()) == noErr
);
650 } /* wxDataViewToggleRenderer::Render(void) */
652 WXDataBrowserPropertyType
wxDataViewToggleRenderer::GetPropertyType(void) const
654 return kDataBrowserCheckboxType
;
655 } /* wxDataViewToggleRenderer::GetPropertyType(void) const */
657 IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleRenderer
,wxDataViewRenderer
)
659 // ---------------------------------------------------------
660 // wxDataViewProgressRenderer
661 // ---------------------------------------------------------
663 wxDataViewProgressRenderer::wxDataViewProgressRenderer(wxString
const& label
, wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
664 :wxDataViewRenderer(varianttype
,mode
,align
)
668 bool wxDataViewProgressRenderer::Render(void)
670 wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Progress renderer cannot render value type; value type: ")) << this->GetValue().GetType());
671 return ((::SetDataBrowserItemDataMinimum(this->GetDataReference(), 0) == noErr
) &&
672 (::SetDataBrowserItemDataMaximum(this->GetDataReference(),100) == noErr
) &&
673 (::SetDataBrowserItemDataValue (this->GetDataReference(),this->GetValue().GetLong()) == noErr
));
674 } /* wxDataViewProgressRenderer::Render(void) */
676 WXDataBrowserPropertyType
wxDataViewProgressRenderer::GetPropertyType(void) const
678 return kDataBrowserProgressBarType
;
679 } /* wxDataViewProgressRenderer::GetPropertyType(void) const */
681 IMPLEMENT_ABSTRACT_CLASS(wxDataViewProgressRenderer
,wxDataViewRenderer
)
683 // ---------------------------------------------------------
684 // wxDataViewDateRenderer
685 // ---------------------------------------------------------
687 wxDataViewDateRenderer::wxDataViewDateRenderer(wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
688 :wxDataViewRenderer(varianttype
,mode
,align
)
692 bool wxDataViewDateRenderer::Render(void)
694 wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Date renderer cannot render value; value type: ")) << this->GetValue().GetType());
695 return (::SetDataBrowserItemDataDateTime(this->GetDataReference(),this->GetValue().GetDateTime().Subtract(wxDateTime(1,wxDateTime::Jan
,1904)).GetSeconds().GetLo()) == noErr
);
696 } /* wxDataViewDateRenderer::Render(void) */
698 WXDataBrowserPropertyType
wxDataViewDateRenderer::GetPropertyType(void) const
700 return kDataBrowserDateTimeType
;
701 } /* wxDataViewDateRenderer::GetPropertyType(void) const */
703 IMPLEMENT_ABSTRACT_CLASS(wxDataViewDateRenderer
,wxDataViewRenderer
)
705 // ---------------------------------------------------------
707 // ---------------------------------------------------------
709 wxDataViewColumn::wxDataViewColumn(wxString
const &title
, wxDataViewRenderer
*cell
, unsigned int model_column
, int width
, wxAlignment align
, int flags
)
710 :wxDataViewColumnBase(title
,cell
,model_column
,width
,align
,flags
), m_ascending(true),
711 m_flags(flags
& ~(wxDATAVIEW_COL_HIDDEN
)), m_maxWidth(30000), m_minWidth(0), m_width(width
>= 0 ? width
: wxDVC_DEFAULT_WIDTH
),
712 m_alignment(align
), m_title(title
)
714 } /* wxDataViewColumn::wxDataViewColumn(wxString const &title, wxDataViewRenderer*, unsigned int, int, wxAlignment, int) */
716 wxDataViewColumn::wxDataViewColumn(wxBitmap
const& bitmap
, wxDataViewRenderer
*cell
, unsigned int model_column
, int width
, wxAlignment align
, int flags
)
717 :wxDataViewColumnBase(bitmap
,cell
,model_column
,width
,align
,flags
), m_ascending(true),
718 m_flags(flags
& ~(wxDATAVIEW_COL_HIDDEN
)), m_maxWidth(30000), m_minWidth(0), m_width(width
>= 0 ? width
: wxDVC_DEFAULT_WIDTH
),
721 } /* wxDataViewColumn::wxDataViewColumn(wxBitmap const&, wxDataViewRenderer*, unsigned int, int, wxAlignment, int) */
723 void wxDataViewColumn::SetAlignment(wxAlignment align
)
725 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
728 this->m_alignment
= align
;
729 if (dataViewCtrlPtr
!= NULL
)
731 // variable definition and initialization:
732 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
734 if (macDataViewListCtrlPtr
!= NULL
)
736 // variable definition and initialization:
737 DataBrowserListViewHeaderDesc headerDescription
;
739 wxCHECK_RET(macDataViewListCtrlPtr
->GetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not get header description."));
743 case wxALIGN_CENTER_HORIZONTAL
:
744 headerDescription
.btnFontStyle
.just
= teCenter
;
747 headerDescription
.btnFontStyle
.just
= teFlushLeft
;
750 headerDescription
.btnFontStyle
.just
= teFlushRight
;
753 headerDescription
.btnFontStyle
.just
= teFlushDefault
;
755 wxCHECK_RET(macDataViewListCtrlPtr
->SetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not set alignment."));
758 } /* wxDataViewColumn::SetAlignment(wxAlignment) */
760 void wxDataViewColumn::SetBitmap(wxBitmap
const& bitmap
)
762 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
765 wxDataViewColumnBase::SetBitmap(bitmap
);
766 if (dataViewCtrlPtr
!= NULL
)
768 // variable definition and initialization:
769 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
771 if (macDataViewListCtrlPtr
!= NULL
)
773 // variable definition and initialization:
774 DataBrowserListViewHeaderDesc headerDescription
;
776 wxCHECK_RET(macDataViewListCtrlPtr
->GetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not get header description."));
777 if (this->GetBitmap().Ok())
778 #if wxCHECK_VERSION(2,9,0)
779 headerDescription
.btnContentInfo
.u
.iconRef
= this->GetBitmap().GetIconRef();
781 headerDescription
.btnContentInfo
.u
.iconRef
= this->GetBitmap().GetBitmapData()->GetIconRef();
784 headerDescription
.btnContentInfo
.u
.iconRef
= NULL
;
785 wxCHECK_RET(macDataViewListCtrlPtr
->SetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not set icon."));
788 } /* wxDataViewColumn::SetBitmap(wxBitmap const&) */
790 void wxDataViewColumn::SetFlags(int flags
)
792 this->SetHidden ((flags
& wxDATAVIEW_COL_HIDDEN
) != 0);
793 this->SetReorderable((flags
& wxDATAVIEW_COL_REORDERABLE
) != 0);
794 this->SetResizeable ((flags
& wxDATAVIEW_COL_RESIZABLE
) != 0);
795 this->SetSortable ((flags
& wxDATAVIEW_COL_SORTABLE
) != 0);
796 } /* wxDataViewColumn::SetFlags(int) */
798 void wxDataViewColumn::SetMaxWidth(int maxWidth
)
800 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
803 this->m_maxWidth
= maxWidth
;
804 if (dataViewCtrlPtr
!= NULL
)
806 // variable definition and initialization:
807 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
809 if (macDataViewListCtrlPtr
!= NULL
)
811 // variable definition and initialization:
812 DataBrowserListViewHeaderDesc headerDescription
;
814 wxCHECK_RET(macDataViewListCtrlPtr
->GetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not get header description."));
815 headerDescription
.maximumWidth
= static_cast<UInt16
>(maxWidth
);
816 wxCHECK_RET(macDataViewListCtrlPtr
->SetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not set maximum width."));
819 } /* wxDataViewColumn::SetMaxWidth(int) */
821 void wxDataViewColumn::SetMinWidth(int minWidth
)
823 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
826 this->m_minWidth
= minWidth
;
827 if (dataViewCtrlPtr
!= NULL
)
829 // variable definition and initialization:
830 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
832 if (macDataViewListCtrlPtr
!= NULL
)
834 // variable definition and initialization:
835 DataBrowserListViewHeaderDesc headerDescription
;
837 wxCHECK_RET(macDataViewListCtrlPtr
->GetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not get header description."));
838 headerDescription
.minimumWidth
= static_cast<UInt16
>(minWidth
);
839 wxCHECK_RET(macDataViewListCtrlPtr
->SetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not set minimum width."));
842 } /* wxDataViewColumn::SetMaxWidth(int) */
844 void wxDataViewColumn::SetReorderable(bool reorderable
)
846 // first set the internal flag of the column:
848 this->m_flags
|= wxDATAVIEW_COL_REORDERABLE
;
850 this->m_flags
&= ~wxDATAVIEW_COL_REORDERABLE
;
851 // if the column is associated with a control change also immediately the flags of the control:
852 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner()); // variable definition and initialization
854 if (dataViewCtrlPtr
!= NULL
)
856 // variable definition and initialization:
857 DataBrowserPropertyFlags flags
;
858 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
860 wxCHECK_RET(macDataViewListCtrlPtr
!= NULL
, _("Valid pointer to native data view control does not exist"));
861 wxCHECK_RET(macDataViewListCtrlPtr
->GetPropertyFlags(this->GetPropertyID(),&flags
) == noErr
,_("Could not get property flags."));
863 flags
|= kDataBrowserListViewMovableColumn
;
865 flags
&= ~kDataBrowserListViewMovableColumn
;
866 wxCHECK_RET(macDataViewListCtrlPtr
->SetPropertyFlags(this->GetPropertyID(),flags
) == noErr
,_("Could not set property flags."));
868 } /* wxDataViewColumn::SetReorderable(bool) */
870 void wxDataViewColumn::SetResizeable(bool WXUNUSED(resizeable
))
872 } /* wxDataViewColumn::SetResizeable(bool) */
874 void wxDataViewColumn::SetSortable(bool sortable
)
876 // first set the internal flag of the column:
878 this->m_flags
|= wxDATAVIEW_COL_SORTABLE
;
880 this->m_flags
&= ~wxDATAVIEW_COL_SORTABLE
;
881 // if the column is associated with a control change also immediately the flags of the control:
882 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner()); // variable definition and initialization
884 if (dataViewCtrlPtr
!= NULL
)
886 // variable definition and initialization:
887 DataBrowserPropertyFlags flags
;
888 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
890 wxCHECK_RET(macDataViewListCtrlPtr
!= NULL
, _("Valid pointer to native data view control does not exist"));
891 wxCHECK_RET(macDataViewListCtrlPtr
->GetPropertyFlags(this->GetPropertyID(),&flags
) == noErr
,_("Could not get property flags."));
893 flags
|= kDataBrowserListViewSortableColumn
;
895 flags
&= ~kDataBrowserListViewSortableColumn
;
896 wxCHECK_RET(macDataViewListCtrlPtr
->SetPropertyFlags(this->GetPropertyID(),flags
) == noErr
,_("Could not set property flags."));
898 } /* wxDataViewColumn::SetSortable(bool) */
900 void wxDataViewColumn::SetSortOrder(bool ascending
)
902 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
905 this->m_ascending
= ascending
;
906 if (dataViewCtrlPtr
!= NULL
)
908 // variable definition and initialization:
909 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
911 if (macDataViewListCtrlPtr
!= NULL
)
913 // variable definition and initialization:
914 DataBrowserListViewHeaderDesc headerDescription
;
916 verify_noerr(macDataViewListCtrlPtr
->GetHeaderDesc(this->GetPropertyID(),&headerDescription
));
918 headerDescription
.initialOrder
= kDataBrowserOrderIncreasing
;
920 headerDescription
.initialOrder
= kDataBrowserOrderDecreasing
;
921 verify_noerr(macDataViewListCtrlPtr
->SetHeaderDesc(this->GetPropertyID(),&headerDescription
));
922 macDataViewListCtrlPtr
->SetSortProperty(this->GetPropertyID());
925 } /* wxDataViewColumn::SetSortOrder(bool) */
927 void wxDataViewColumn::SetTitle(wxString
const& title
)
929 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
932 this->m_title
= title
;
933 if (dataViewCtrlPtr
!= NULL
)
935 // variable definition and initialization:
936 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
938 if (macDataViewListCtrlPtr
!= NULL
)
940 // variable definition and initialization:
941 DataBrowserListViewHeaderDesc headerDescription
;
942 #if wxCHECK_VERSION(2,9,0)
943 wxCFStringRef
cfTitle(title
,(dataViewCtrlPtr
->GetFont().Ok() ? dataViewCtrlPtr
->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
945 wxMacCFStringHolder
cfTitle(title
,(dataViewCtrlPtr
->GetFont().Ok() ? dataViewCtrlPtr
->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
948 wxCHECK_RET(macDataViewListCtrlPtr
->GetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not get header description."));
949 headerDescription
.titleString
= cfTitle
;
950 wxCHECK_RET(macDataViewListCtrlPtr
->SetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not set header description."));
953 } /* wxDataViewColumn::SetTitle(wxString const&) */
955 void wxDataViewColumn::SetWidth(int width
)
957 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
960 if ((width
>= this->m_minWidth
) && (width
<= this->m_maxWidth
))
962 this->m_width
= width
;
963 if (dataViewCtrlPtr
!= NULL
)
965 // variable definition and initialization:
966 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
968 if (macDataViewListCtrlPtr
!= NULL
)
969 wxCHECK_RET(macDataViewListCtrlPtr
->SetColumnWidth(this->GetPropertyID(),static_cast<UInt16
>(width
)) == noErr
,_("Could not set column width."));
972 } /* wxDataViewColumn::SetWidth(int) */
974 IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumn
,wxDataViewColumnBase
)
976 //-----------------------------------------------------------------------------
978 //-----------------------------------------------------------------------------
980 void wxDataViewCtrl::Init(void)
982 this->m_CustomRendererPtr
= NULL
;
983 this->m_Deleting
= false;
984 this->m_macIsUserPane
= false;
985 this->m_cgContext
= NULL
;
986 } /* wxDataViewCtrl::Init(void) */
988 bool wxDataViewCtrl::Create(wxWindow
*parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
, const wxValidator
& validator
)
990 if (!(this->wxControl::Create(parent
,id
,pos
,size
,(style
| wxSUNKEN_BORDER
) & ~(wxHSCROLL
| wxVSCROLL
),validator
)))
994 MacSetClipChildren(true) ;
997 this->m_peer
= new wxMacDataViewDataBrowserListViewControl(this,pos
,size
,style
);
998 this->MacPostControlCreate(pos
,size
);
999 ::SetAutomaticControlDragTrackingEnabledForWindow(::GetControlOwner(this->m_peer
->GetControlRef()),true);
1001 InstallControlEventHandler(this->m_peer
->GetControlRef(),GetwxMacDataViewCtrlEventHandlerUPP(),GetEventTypeCount(eventList
),eventList
,this,NULL
);
1003 ::SetDataBrowserTableViewHiliteStyle( this->m_peer
->GetControlRef(), kDataBrowserTableViewFillHilite
);
1005 ::SetDataBrowserTableViewGeometry( this->m_peer
->GetControlRef(), true, false );
1008 } /* wxDataViewCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator) */
1011 wxVisualAttributes
wxDataViewCtrl::GetClassDefaultAttributes(wxWindowVariant variant
)
1013 wxVisualAttributes attr
;
1015 attr
.colFg
= wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT
);
1016 attr
.colBg
= wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOX
);
1017 attr
.font
.MacCreateFromThemeFont(kThemeViewsFont
);
1022 bool wxDataViewCtrl::AssociateModel(wxDataViewModel
* model
)
1024 if (!wxDataViewCtrlBase::AssociateModel(model
))
1027 model
->AddNotifier(new wxMacDataViewModelNotifier(dynamic_cast<wxMacDataViewDataBrowserListViewControl
*>(this->m_peer
)));
1030 } /* wxDataViewCtrl::AssociateModel(wxDataViewModel*) */
1032 bool wxDataViewCtrl::AppendColumn(wxDataViewColumn
* columnPtr
)
1034 DataBrowserListViewColumnDesc columnDescription
;
1036 DataBrowserPropertyID NewPropertyID
;
1038 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1040 #if wxCHECK_VERSION(2,9,0)
1041 wxCFStringRef
title(columnPtr
->GetTitle(),this->m_font
.Ok() ? this->GetFont().GetEncoding() : wxLocale::GetSystemEncoding());
1043 wxMacCFStringHolder
title(columnPtr
->GetTitle(),this->m_font
.Ok() ? this->GetFont().GetEncoding() : wxLocale::GetSystemEncoding());
1047 // first, some error checking:
1048 wxCHECK_MSG(MacDataViewListCtrlPtr
!= NULL
, false,_("m_peer is not or incorrectly initialized"));
1049 wxCHECK_MSG(columnPtr
!= NULL
, false,_("Column pointer must not be NULL."));
1050 wxCHECK_MSG(columnPtr
->GetRenderer() != NULL
, false,_("Column does not have a renderer."));
1051 wxCHECK_MSG(this->GetModel() != NULL
, false,_("No model associated with control."));
1052 wxCHECK_MSG((columnPtr
->GetModelColumn() >= 0) &&
1053 (columnPtr
->GetModelColumn() < this->GetModel()->GetColumnCount()),false,_("Column's model column has no equivalent in the associated model."));
1055 // try to get new ID for the column:
1056 wxCHECK_MSG(MacDataViewListCtrlPtr
->GetFreePropertyID(&NewPropertyID
) == noErr
,false,_("Cannot create new column's ID. Probably max. number of columns reached."));
1057 // full column variable initialization:
1058 columnPtr
->SetPropertyID(NewPropertyID
);
1059 // add column to wxWidget's internal structure:
1060 wxCHECK_MSG(this->wxDataViewCtrlBase::AppendColumn(columnPtr
) &&
1061 this->m_ColumnPointers
.insert(ColumnPointerHashMapType::value_type(NewPropertyID
,columnPtr
)).second
,false,_("Could not add column to internal structures."));
1062 // create a column description and add column to the native control:
1063 wxCHECK_MSG(::InitializeColumnDescription(columnDescription
,columnPtr
,NewPropertyID
,title
), false,_("Column description could not be initialized."));
1064 wxCHECK_MSG(MacDataViewListCtrlPtr
->AddColumn(&columnDescription
,kDataBrowserListViewAppendColumn
) == noErr
,false,_("Column could not be added."));
1066 // final adjustments for the layout:
1067 wxCHECK_MSG(MacDataViewListCtrlPtr
->SetColumnWidth(NewPropertyID
,columnPtr
->GetWidth()) == noErr
,false,_("Column width could not be set."));
1069 // make sure that the data is up-to-date...
1070 // if the newly appended column is the first column add the initial data to the control and mark the column as an expander column,
1071 // otherwise ask the control to 'update' the data in the newly appended column:
1072 if (this->GetColumnCount() == 1)
1074 this->SetExpanderColumn(columnPtr
);
1075 this->AddChildrenLevel(wxDataViewItem());
1078 MacDataViewListCtrlPtr
->UpdateItems(kDataBrowserNoItem
,0,NULL
,kDataBrowserItemNoProperty
,NewPropertyID
);
1081 } /* wxDataViewCtrl::AppendColumn(wxDataViewColumn*) */
1083 bool wxDataViewCtrl::ClearColumns(void)
1085 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1088 while (this->m_ColumnPointers
.begin() != this->m_ColumnPointers
.end())
1090 wxCHECK_MSG(MacDataViewListCtrlPtr
->RemoveColumnByProperty(this->m_ColumnPointers
.begin()->first
) == noErr
,false,_("Could not remove column."));
1091 delete this->m_ColumnPointers
.begin()->second
;
1092 this->m_ColumnPointers
.erase(this->m_ColumnPointers
.begin());
1095 } /* wxDataViewCtrl::ClearColumns(void) */
1097 bool wxDataViewCtrl::DeleteColumn(wxDataViewColumn
* columnPtr
)
1099 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1102 if ((MacDataViewListCtrlPtr
->RemoveColumnByProperty(columnPtr
->GetPropertyID()) == noErr
) && (this->m_ColumnPointers
.erase(columnPtr
->GetPropertyID()) > 0))
1109 } /* wxDataViewCtrl::DeleteColumn(wxDataViewColumn*) */
1111 wxDataViewColumn
* wxDataViewCtrl::GetColumn(unsigned int pos
) const
1113 DataBrowserPropertyID propertyID
;
1115 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1118 if (MacDataViewListCtrlPtr
->GetPropertyID(pos
,&propertyID
) == noErr
)
1120 // variable definition:
1121 ColumnPointerHashMapType::const_iterator
Result(this->m_ColumnPointers
.find(propertyID
));
1123 if (Result
!= this->m_ColumnPointers
.end())
1124 return Result
->second
;
1130 } /* wxDataViewCtrl::GetColumn(unsigned int pos) const */
1132 unsigned int wxDataViewCtrl::GetColumnCount(void) const
1134 return this->m_ColumnPointers
.size();
1135 } /* wxDataViewCtrl::GetColumnCount(void) const */
1137 int wxDataViewCtrl::GetColumnPosition(wxDataViewColumn
const* columnPtr
) const
1139 if (columnPtr
!= NULL
)
1141 // variable definition and initialization:
1142 DataBrowserTableViewColumnIndex Position
;
1143 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1145 wxCHECK_MSG(MacDataViewListCtrlPtr
->GetColumnIndex(columnPtr
->GetPropertyID(),&Position
) == noErr
,-1,_("Could not determine column's position"));
1146 return static_cast<int>(Position
);
1150 } /* wxDataViewCtrl::GetColumnPosition(wxDataViewColumn const*) const */
1152 bool wxDataViewCtrl::PrependColumn(wxDataViewColumn
* columnPtr
)
1154 DataBrowserListViewColumnDesc columnDescription
;
1156 DataBrowserPropertyID NewPropertyID
;
1158 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1160 #if wxCHECK_VERSION(2,9,0)
1161 wxCFStringRef
title(columnPtr
->GetTitle(),this->m_font
.Ok() ? this->GetFont().GetEncoding() : wxLocale::GetSystemEncoding());
1163 wxMacCFStringHolder
title(columnPtr
->GetTitle(),this->m_font
.Ok() ? this->GetFont().GetEncoding() : wxLocale::GetSystemEncoding());
1167 // first, some error checking:
1168 wxCHECK_MSG(MacDataViewListCtrlPtr
!= NULL
, false,_("m_peer is not or incorrectly initialized"));
1169 wxCHECK_MSG(columnPtr
!= NULL
, false,_("Column pointer must not be NULL."));
1170 wxCHECK_MSG(columnPtr
->GetRenderer() != NULL
, false,_("Column does not have a renderer."));
1171 wxCHECK_MSG(this->GetModel() != NULL
, false,_("No model associated with control."));
1172 wxCHECK_MSG((columnPtr
->GetModelColumn() >= 0) &&
1173 (columnPtr
->GetModelColumn() < this->GetModel()->GetColumnCount()),false,_("Column's model column has no equivalent in the associated model."));
1175 // try to get new ID for the column:
1176 wxCHECK_MSG(MacDataViewListCtrlPtr
->GetFreePropertyID(&NewPropertyID
) == noErr
,false,_("Cannot create new column's ID. Probably max. number of columns reached."));
1177 // full column variable initialization:
1178 columnPtr
->SetPropertyID(NewPropertyID
);
1179 // add column to wxWidget's internal structure:
1180 wxCHECK_MSG(this->wxDataViewCtrlBase::AppendColumn(columnPtr
) &&
1181 this->m_ColumnPointers
.insert(ColumnPointerHashMapType::value_type(NewPropertyID
,columnPtr
)).second
,false,_("Could not add column to internal structures."));
1182 // create a column description and add column to the native control:
1183 wxCHECK_MSG(::InitializeColumnDescription(columnDescription
,columnPtr
,NewPropertyID
,title
),false,_("Column description could not be initialized."));
1184 wxCHECK_MSG(MacDataViewListCtrlPtr
->AddColumn(&columnDescription
,0) == noErr
, false,_("Column could not be added."));
1186 // final adjustments for the layout:
1187 wxCHECK_MSG(MacDataViewListCtrlPtr
->SetColumnWidth(NewPropertyID
,columnPtr
->GetWidth()) == noErr
,false,_("Column width could not be set."));
1189 // make sure that the data is up-to-date...
1190 // if the newly appended column is the first column add the initial data to the control and mark the column as an expander column,
1191 // otherwise ask the control to 'update' the data in the newly appended column:
1192 if (this->GetColumnCount() == 1)
1194 this->SetExpanderColumn(columnPtr
);
1195 this->AddChildrenLevel(wxDataViewItem());
1198 MacDataViewListCtrlPtr
->UpdateItems(kDataBrowserNoItem
,0,NULL
,kDataBrowserItemNoProperty
,NewPropertyID
);
1201 } /* wxDataViewCtrl::PrependColumn(wxDataViewColumn*) */
1203 void wxDataViewCtrl::Collapse(wxDataViewItem
const& item
)
1205 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1208 MacDataViewListCtrlPtr
->CloseContainer(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
1209 } /* wxDataViewCtrl::Collapse(wxDataViewItem const&) */
1211 void wxDataViewCtrl::EnsureVisible(wxDataViewItem
const& item
, wxDataViewColumn
const* columnPtr
)
1215 // variable definition and initialization:
1216 DataBrowserPropertyID propertyID
;
1217 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1219 if (columnPtr
!= NULL
)
1220 propertyID
= columnPtr
->GetPropertyID();
1222 propertyID
= kDataBrowserNoItem
;
1223 MacDataViewListCtrlPtr
->RevealItem(reinterpret_cast<DataBrowserItemID
>(item
.GetID()),propertyID
,kDataBrowserRevealOnly
);
1225 } /* wxDataViewCtrl::EnsureVisible(wxDataViewItem const&, wxDataViewColumn const*) */
1227 void wxDataViewCtrl::Expand(wxDataViewItem
const& item
)
1229 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1232 MacDataViewListCtrlPtr
->OpenContainer(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
1233 } /* wxDataViewCtrl::Expand(wxDataViewItem const&) */
1235 wxDataViewColumn
* wxDataViewCtrl::GetSortingColumn(void) const
1237 DataBrowserPropertyID propertyID
;
1239 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1242 if (MacDataViewListCtrlPtr
->GetSortProperty(&propertyID
) == noErr
)
1243 return this->GetColumnPtr(propertyID
);
1246 } /* wxDataViewCtrl::GetSortingColumn(void) const */
1248 unsigned int wxDataViewCtrl::GetCount(void) const
1250 ItemCount noOfItems
;
1253 wxCHECK_MSG(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
)->GetItemCount(&noOfItems
) == noErr
,0,_("Could not determine number of items"));
1255 } /* wxDataViewCtrl::GetCount(void) const */
1257 wxRect
wxDataViewCtrl::GetItemRect(wxDataViewItem
const& item
, wxDataViewColumn
const* columnPtr
) const
1259 if (item
.IsOk() && (columnPtr
!= NULL
))
1261 // variable definition:
1263 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1265 if (MacDataViewListCtrlPtr
->GetPartBounds(reinterpret_cast<DataBrowserItemID
>(item
.GetID()),columnPtr
->GetPropertyID(),kDataBrowserPropertyContentPart
,&MacRectangle
) == noErr
)
1267 // variable definition:
1270 ::wxMacNativeToRect(&MacRectangle
,&rectangle
);
1278 } /* wxDataViewCtrl::GetItemRect(wxDataViewItem const&, unsigned int) const */
1280 wxDataViewItem
wxDataViewCtrl::GetSelection(void) const
1282 wxArrayDataBrowserItemID itemIDs
;
1284 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1287 if (MacDataViewListCtrlPtr
->GetSelectedItemIDs(itemIDs
) > 0)
1288 return wxDataViewItem(reinterpret_cast<void*>(itemIDs
[0]));
1290 return wxDataViewItem();
1291 } /* wxDataViewCtrl::GetSelection(void) const */
1293 int wxDataViewCtrl::GetSelections(wxDataViewItemArray
& sel
) const
1295 size_t NoOfSelectedItems
;
1297 wxArrayDataBrowserItemID itemIDs
;
1299 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1302 NoOfSelectedItems
= MacDataViewListCtrlPtr
->GetSelectedItemIDs(itemIDs
);
1304 sel
.SetCount(NoOfSelectedItems
);
1305 for (size_t i
=0; i
<NoOfSelectedItems
; ++i
)
1306 sel
[i
] = wxDataViewItem(reinterpret_cast<void*>(itemIDs
[i
]));
1307 return static_cast<int>(NoOfSelectedItems
);
1308 } /* wxDataViewCtrl::GetSelections(wxDataViewItemArray&) const */
1310 void wxDataViewCtrl::HitTest(wxPoint
const& point
, wxDataViewItem
& item
, wxDataViewColumn
*& columnPtr
) const
1312 item
= wxDataViewItem();
1314 } /* wxDataViewCtrl::HitTest(wxPoint const&, wxDataViewItem&, wxDataViewColumn*&) const */
1316 bool wxDataViewCtrl::IsSelected(wxDataViewItem
const& item
) const
1318 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1321 return MacDataViewListCtrlPtr
->IsItemSelected(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
1322 } /* wxDataViewCtrl::IsSelected(wxDataViewItem const&) const */
1324 void wxDataViewCtrl::SelectAll(void)
1326 DataBrowserItemID
* itemIDPtr
;
1328 Handle
handle(::NewHandle(0));
1332 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1335 wxCHECK_RET(MacDataViewListCtrlPtr
->GetItems(kDataBrowserNoItem
,true,kDataBrowserItemAnyState
,handle
) == noErr
,_("Could not get items."));
1336 NoOfItems
= static_cast<size_t>(::GetHandleSize(handle
)/sizeof(DataBrowserItemID
));
1338 itemIDPtr
= (DataBrowserItemID
*) (*handle
);
1339 MacDataViewListCtrlPtr
->SetSelectedItems(NoOfItems
,itemIDPtr
,kDataBrowserItemsAssign
);
1341 DisposeHandle(handle
);
1342 } /* wxDataViewCtrl::SelectAll(void) */
1344 void wxDataViewCtrl::Select(wxDataViewItem
const& item
)
1348 // variable definition and initialization:
1349 DataBrowserItemID
itemID(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
1350 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1352 MacDataViewListCtrlPtr
->SetSelectedItems(1,&itemID
,kDataBrowserItemsAdd
);
1354 } /* wxDataViewCtrl::Select(wxDataViewItem const&) */
1356 void wxDataViewCtrl::SetSelections(wxDataViewItemArray
const& sel
)
1358 size_t const NoOfSelections
= sel
.GetCount();
1360 DataBrowserItemID
* itemIDs
;
1362 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1365 itemIDs
= new DataBrowserItemID
[NoOfSelections
];
1366 for (size_t i
=0; i
<NoOfSelections
; ++i
)
1367 itemIDs
[i
] = reinterpret_cast<DataBrowserItemID
>(sel
[i
].GetID());
1368 MacDataViewListCtrlPtr
->SetSelectedItems(NoOfSelections
,itemIDs
,kDataBrowserItemsAssign
);
1370 } /* wxDataViewCtrl::SetSelections(wxDataViewItemArray const&) */
1372 void wxDataViewCtrl::Unselect(wxDataViewItem
const& item
)
1376 // variable definition and initialization:
1377 DataBrowserItemID
itemID(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
1378 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1380 MacDataViewListCtrlPtr
->SetSelectedItems(1,&itemID
,kDataBrowserItemsRemove
);
1382 } /* wxDataViewCtrl::Unselect(wxDataViewItem const&) */
1384 void wxDataViewCtrl::UnselectAll(void)
1386 DataBrowserItemID
* itemIDPtr
;
1388 Handle
handle(::NewHandle(0));
1392 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1395 wxCHECK_RET(MacDataViewListCtrlPtr
->GetItems(kDataBrowserNoItem
,true,kDataBrowserItemAnyState
,handle
) == noErr
,_("Could not get items."));
1396 NoOfItems
= static_cast<size_t>(::GetHandleSize(handle
)/sizeof(DataBrowserItemID
));
1398 itemIDPtr
= (DataBrowserItemID
*) (*handle
);
1399 MacDataViewListCtrlPtr
->SetSelectedItems(NoOfItems
,itemIDPtr
,kDataBrowserItemsRemove
);
1401 DisposeHandle(handle
);
1402 } /* wxDataViewCtrl::UnselectAll(void) */
1405 void wxDataViewCtrl::AddChildrenLevel(wxDataViewItem
const& parentItem
)
1409 wxDataViewItemArray items
;
1412 wxCHECK_RET(this->GetModel() != NULL
,_("Model pointer not initialized."));
1413 NoOfChildren
= this->GetModel()->GetChildren(parentItem
,items
);
1415 for (int i
=0; i
<NoOfChildren
; ++i
)
1416 (void) this->GetModel()->ItemAdded(parentItem
,items
[i
]);
1418 (void) this->GetModel()->ItemsAdded(parentItem
,items
);
1420 } /* wxDataViewCtrl::AddChildrenLevel(wxDataViewItem const&) */
1422 void wxDataViewCtrl::FinishCustomItemEditing(void)
1424 if (this->GetCustomRendererItem().IsOk())
1426 this->GetCustomRendererPtr()->FinishEditing();
1427 this->SetCustomRendererItem(wxDataViewItem());
1428 this->SetCustomRendererPtr (NULL
);
1430 } /* wxDataViewCtrl::FinishCustomItemEditing(void) */
1432 wxDataViewColumn
* wxDataViewCtrl::GetColumnPtr(WXDataBrowserPropertyID propertyID
) const
1434 // variable definition:
1435 ColumnPointerHashMapType::const_iterator
Result(this->m_ColumnPointers
.find(propertyID
));
1437 if (Result
!= this->m_ColumnPointers
.end())
1438 return Result
->second
;
1441 } /* wxDataViewCtrl::GetColumnPtr(DataBrowserPropertyID) const */
1443 // inherited methods from wxDataViewCtrlBase
1444 void wxDataViewCtrl::DoSetExpanderColumn(void)
1446 if (this->GetExpanderColumn() != NULL
)
1448 // variable definition and initialization:
1449 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1451 (void) MacDataViewListCtrlPtr
->SetDisclosureColumn(this->GetExpanderColumn()->GetPropertyID(),false); // second parameter explicitely passed to ensure that arrow is centered
1453 } /* wxDataViewCtrl::DoSetExpanderColumn(void) */
1455 void wxDataViewCtrl::DoSetIndent(void)
1457 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1460 (void) MacDataViewListCtrlPtr
->SetIndent(static_cast<float>(this->GetIndent()));
1461 } /* wxDataViewCtrl::DoSetIndent(void) */
1464 void wxDataViewCtrl::OnSize(wxSizeEvent
& event
)
1466 unsigned int const NoOfColumns
= this->GetColumnCount();
1469 for (unsigned int i
=0; i
<NoOfColumns
; ++i
)
1471 // variable definition and initialization:
1472 wxDataViewColumn
* dataViewColumnPtr(this->GetColumn(i
));
1474 if (dataViewColumnPtr
!= NULL
)
1476 // variable definition and initialization:
1477 wxDataViewCustomRenderer
* dataViewCustomRendererPtr(dynamic_cast<wxDataViewCustomRenderer
*>(dataViewColumnPtr
->GetRenderer()));
1479 if (dataViewCustomRendererPtr
!= NULL
)
1480 dataViewCustomRendererPtr
->SetDC(NULL
); // reset DC because DC has changed
1484 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1485 ControlRef ref
= MacDataViewListCtrlPtr
->GetControlRef();
1486 if (NoOfColumns
== 1)
1488 ::SetDataBrowserHasScrollBars( ref
, false, true );
1489 ::AutoSizeDataBrowserListViewColumns( ref
);
1491 if (NoOfColumns
> 1)
1493 ::SetDataBrowserHasScrollBars( ref
, true, true );
1497 } /* wxDataViewCtrl::OnSize(wxSizeEvent&) */
1499 IMPLEMENT_DYNAMIC_CLASS(wxDataViewCtrl
,wxDataViewCtrlBase
)
1501 BEGIN_EVENT_TABLE(wxDataViewCtrl
,wxDataViewCtrlBase
)
1502 EVT_SIZE(wxDataViewCtrl::OnSize
)
1506 // !wxUSE_GENERICDATAVIEWCTRL
1509 // wxUSE_DATAVIEWCTRL