1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/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/osx/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()));
219 wxCHECK_MSG(item
.IsOk(),false,_("Added item is invalid."));
220 bool noFailureFlag
= (!(parent
.IsOk()) && (this->m_dataViewControlPtr
->AddItem(kDataBrowserNoItem
,&itemID
) == noErr
) ||
221 parent
.IsOk() && (this->m_dataViewControlPtr
->AddItem(reinterpret_cast<DataBrowserItemID
>(parent
.GetID()),&itemID
) == noErr
));
223 wxDataViewCtrl
*dvc
= (wxDataViewCtrl
*) this->m_dataViewControlPtr
->GetWXPeer();
224 if (dvc
->GetWindowStyle() & wxDV_VARIABLE_LINE_HEIGHT
)
226 wxDataViewModel
*model
= GetOwner();
228 int height
= 20; // TODO find out standard height
229 unsigned int num
= dvc
->GetColumnCount();
231 for (col
= 0; col
< num
; col
++)
233 wxDataViewColumn
*column
= dvc
->GetColumn( col
);
234 if (column
->IsHidden())
237 wxDataViewCustomRenderer
*renderer
= wxDynamicCast( column
->GetRenderer(), wxDataViewCustomRenderer
);
241 model
->GetValue( value
, item
, column
->GetModelColumn() );
242 renderer
->SetValue( value
);
243 height
= wxMax( height
, renderer
->GetSize().y
);
249 this->m_dataViewControlPtr
->SetRowHeight( itemID
, height
);
252 return noFailureFlag
;
253 } /* ItemAdded(wxDataViewItem const&, wxDataViewItem const&) */
255 virtual bool ItemsAdded(wxDataViewItem
const& parent
, wxDataViewItemArray
const& items
)
259 DataBrowserItemID
* itemIDs
;
264 // convert all valid data view items to data browser items:
265 itemIDs
= ::CreateDataBrowserItemIDArray(noOfEntries
,items
);
266 // insert all valid items into control:
267 noFailureFlag
= ((noOfEntries
== 0) ||
268 !(parent
.IsOk()) && (this->m_dataViewControlPtr
->AddItems(kDataBrowserNoItem
,noOfEntries
,itemIDs
,kDataBrowserItemNoProperty
) == noErr
) ||
269 parent
.IsOk() && (this->m_dataViewControlPtr
->AddItems(reinterpret_cast<DataBrowserItemID
>(parent
.GetID()),noOfEntries
,itemIDs
,kDataBrowserItemNoProperty
) == noErr
));
270 // give allocated array space free again:
273 wxDataViewCtrl
*dvc
= (wxDataViewCtrl
*) this->m_dataViewControlPtr
->GetWXPeer();
274 if (dvc
->GetWindowStyle() & wxDV_VARIABLE_LINE_HEIGHT
)
276 wxDataViewModel
*model
= GetOwner();
277 unsigned int colnum
= dvc
->GetColumnCount();
280 size_t count
= items
.GetCount();
281 for (i
= 0; i
< count
; i
++)
283 wxDataViewItem item
= items
[i
];
284 DataBrowserItemID
itemID(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
286 int height
= 20; // TODO find out standard height
288 for (col
= 0; col
< colnum
; col
++)
290 wxDataViewColumn
*column
= dvc
->GetColumn( col
);
291 if (column
->IsHidden())
292 continue; // skip it!
294 if ((col
!= 0) && model
->IsContainer(item
) && !model
->HasContainerColumns(item
))
295 continue; // skip it!
297 wxDataViewCustomRenderer
*renderer
= wxDynamicCast( column
->GetRenderer(), wxDataViewCustomRenderer
);
301 model
->GetValue( value
, item
, column
->GetModelColumn() );
302 renderer
->SetValue( value
);
303 height
= wxMax( height
, renderer
->GetSize().y
);
308 this->m_dataViewControlPtr
->SetRowHeight( itemID
, height
);
313 return noFailureFlag
;
314 } /* ItemsAdded(wxDataViewItem const&, wxDataViewItemArray const&) */
316 virtual bool ItemChanged(wxDataViewItem
const& item
)
318 DataBrowserItemID
itemID(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
321 wxCHECK_MSG(item
.IsOk(),false,_("Changed item is invalid."));
322 if (this->m_dataViewControlPtr
->UpdateItems(&itemID
) == noErr
)
324 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->m_dataViewControlPtr
->GetWXPeer()));
326 // sent the equivalent wxWidget event:
327 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED
,dataViewCtrlPtr
->GetId()); // variable defintion
329 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
330 dataViewEvent
.SetItem(item
);
331 // sent the equivalent wxWidget event:
332 #if wxCHECK_VERSION(2,9,0)
333 dataViewCtrlPtr
->HandleWindowEvent(dataViewEvent
);
335 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
342 } /* ItemChanged(wxDataViewItem const&) */
344 virtual bool ItemsChanged(wxDataViewItemArray
const& items
)
348 DataBrowserItemID
* itemIDs
;
353 // convert all valid data view items to data browser items:
354 itemIDs
= ::CreateDataBrowserItemIDArray(noOfEntries
,items
);
355 // change items (ATTENTION: ONLY ITEMS OF THE ROOT ARE CHANGED BECAUSE THE PARENT PARAMETER IS MISSING):
356 noFailureFlag
= (this->m_dataViewControlPtr
->UpdateItems(kDataBrowserNoItem
,noOfEntries
,itemIDs
,kDataBrowserItemNoProperty
,kDataBrowserItemNoProperty
) == noErr
);
359 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->m_dataViewControlPtr
->GetWXPeer()));
361 // send for all changed items a wxWidget event:
362 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED
,dataViewCtrlPtr
->GetId()); // variable defintion
364 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
365 for (size_t i
=0; i
<noOfEntries
; ++i
)
367 dataViewEvent
.SetItem(reinterpret_cast<void*>(itemIDs
[i
]));
368 #if wxCHECK_VERSION(2,9,0)
369 dataViewCtrlPtr
->HandleWindowEvent(dataViewEvent
);
371 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
375 // release allocated array space:
378 return noFailureFlag
;
379 } /* ItemsChanged(wxDataViewItem const&) */
381 virtual bool ItemDeleted(wxDataViewItem
const& parent
, wxDataViewItem
const& item
)
385 // variable definition and initialization:
386 DataBrowserItemID
itemID(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
387 OSStatus errorStatus
;
388 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->m_dataViewControlPtr
->GetWXPeer()));
390 // 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
391 // not to be identical because the being edited item might be below the passed item in the hierarchy);
392 // to prevent the control trying to ask the model to update an already deleted item the control is informed that currently a deleting process
393 // has been started and that variables can currently not be updated even when requested by the system:
394 dataViewCtrlPtr
->SetDeleting(true);
395 errorStatus
= this->m_dataViewControlPtr
->RemoveItem(reinterpret_cast<DataBrowserItemID
>(parent
.GetID()),&itemID
);
396 // enable automatic updating again:
397 dataViewCtrlPtr
->SetDeleting(false);
398 return (errorStatus
== noErr
);
402 } /* ItemDeleted(wxDataViewItem const&, wxDataViewItem const&) */
404 virtual bool ItemsDeleted(wxDataViewItem
const& parent
, wxDataViewItemArray
const& items
)
408 DataBrowserItemID
* itemIDs
;
410 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->m_dataViewControlPtr
->GetWXPeer()));
415 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
,false,_("Data view control is not correctly initialized"));
416 // convert all valid data view items to data browser items:
417 itemIDs
= ::CreateDataBrowserItemIDArray(noOfEntries
,items
);
418 // 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
419 // not to be identical because the being edited item might be below the passed item in the hierarchy);
420 // to prevent the control trying to ask the model to update an already deleted item the control is informed that currently a deleting process
421 // has been started and that variables can currently not be updated even when requested by the system:
422 dataViewCtrlPtr
->SetDeleting(true);
423 // insert all valid items into control:
424 noFailureFlag
= ((noOfEntries
== 0) ||
425 !(parent
.IsOk()) && (this->m_dataViewControlPtr
->RemoveItems(kDataBrowserNoItem
,noOfEntries
,itemIDs
,kDataBrowserItemNoProperty
) == noErr
) ||
426 parent
.IsOk() && (this->m_dataViewControlPtr
->RemoveItems(reinterpret_cast<DataBrowserItemID
>(parent
.GetID()),noOfEntries
,itemIDs
,kDataBrowserItemNoProperty
) == noErr
));
427 // enable automatic updating again:
428 dataViewCtrlPtr
->SetDeleting(false);
429 // give allocated array space free again:
432 return noFailureFlag
;
433 } /* ItemsDeleted(wxDataViewItem const&, wxDataViewItemArray const&) */
435 virtual bool ValueChanged(wxDataViewItem
const& item
, unsigned int col
)
437 DataBrowserItemID
itemID(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
438 DataBrowserItemID parentID
;
440 DataBrowserPropertyID propertyID
;
442 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->m_dataViewControlPtr
->GetWXPeer()));
445 wxCHECK_MSG(item
.IsOk(), false,_("Passed item is invalid."));
446 wxCHECK_MSG(this->GetOwner() != NULL
,false,_("Owner not initialized."));
447 wxCHECK_MSG(dataViewCtrlPtr
!= NULL
, false,_("Control is wrongly initialized."));
448 parentID
= reinterpret_cast<DataBrowserItemID
>(this->GetOwner()->GetParent(item
).GetID());
449 if ((this->m_dataViewControlPtr
->GetPropertyID(col
,&propertyID
) == noErr
) &&
450 (this->m_dataViewControlPtr
->UpdateItems(parentID
,1,&itemID
,dataViewCtrlPtr
->GetColumn(col
)->GetPropertyID(),propertyID
) == noErr
))
452 // variable definition and initialization:
453 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED
,dataViewCtrlPtr
->GetId());
455 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
456 dataViewEvent
.SetColumn(col
);
457 dataViewEvent
.SetItem(item
);
458 // send the equivalent wxWidget event:
459 #if wxCHECK_VERSION(2,9,0)
460 dataViewCtrlPtr
->HandleWindowEvent(dataViewEvent
);
462 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
469 } /* ValueChanged(wxDataViewItem const&, unsigned int) */
471 virtual bool Cleared()
473 bool noFailureFlag
= (this->m_dataViewControlPtr
->RemoveItems() == noErr
);
475 wxDataViewItemArray array
;
476 GetOwner()->GetChildren( item
, array
);
477 ItemsAdded( item
, array
);
478 this->m_dataViewControlPtr
->SetScrollPosition(0, 0);
479 return noFailureFlag
;
482 virtual void Resort()
484 this->m_dataViewControlPtr
->Resort();
492 wxMacDataViewDataBrowserListViewControl
* m_dataViewControlPtr
;
495 // ---------------------------------------------------------
496 // wxDataViewRenderer
497 // ---------------------------------------------------------
499 wxDataViewRenderer::wxDataViewRenderer(wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
500 :wxDataViewRendererBase(varianttype
,mode
,align
), m_alignment(align
), m_mode(mode
)
502 } /* wxDataViewRenderer::wxDataViewRenderer(wxString const&, wxDataViewCellMode) */
504 void wxDataViewRenderer::SetMode(wxDataViewCellMode mode
)
506 wxDataViewColumn
* dataViewColumnPtr
;
510 dataViewColumnPtr
= this->GetOwner();
511 if (dataViewColumnPtr
!= NULL
)
513 // variable definition and initialization:
514 wxDataViewCtrl
* dataViewCtrlPtr(dataViewColumnPtr
->GetOwner());
516 if (dataViewCtrlPtr
!= NULL
)
518 // variable definition and initialization:
519 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
521 if (macDataViewListCtrlPtr
!= NULL
)
523 // variable definition and initialization:
524 DataBrowserPropertyFlags flags
;
526 verify_noerr(macDataViewListCtrlPtr
->GetPropertyFlags(dataViewColumnPtr
->GetPropertyID(),&flags
));
527 if (mode
== wxDATAVIEW_CELL_EDITABLE
)
528 flags
|= kDataBrowserPropertyIsEditable
;
530 flags
&= ~kDataBrowserPropertyIsEditable
;
531 verify_noerr(macDataViewListCtrlPtr
->SetPropertyFlags(dataViewColumnPtr
->GetPropertyID(),flags
));
535 } /* wxDataViewRenderer::SetMode(wxDataViewCellMode) */
537 IMPLEMENT_ABSTRACT_CLASS(wxDataViewRenderer
,wxDataViewRendererBase
)
539 // ---------------------------------------------------------
540 // wxDataViewCustomRenderer
541 // ---------------------------------------------------------
543 wxDataViewCustomRenderer::wxDataViewCustomRenderer(wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
544 :wxDataViewRenderer(varianttype
,mode
,align
), m_editorCtrlPtr(NULL
), m_DCPtr(NULL
)
546 } /* wxDataViewCustomRenderer::wxDataViewCustomRenderer(wxString const&, wxDataViewCellMode) */
548 wxDataViewCustomRenderer::~wxDataViewCustomRenderer()
550 delete this->m_DCPtr
;
551 } /* wxDataViewCustomRenderer::~wxDataViewCustomRenderer() */
553 void wxDataViewCustomRenderer::RenderText( const wxString
&text
, int xoffset
, wxRect cell
, wxDC
*dc
, int state
)
555 wxDataViewCtrl
*view
= GetOwner()->GetOwner();
556 // wxColour col = (state & wxDATAVIEW_CELL_SELECTED) ? wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT) : view->GetForegroundColour();
557 wxColour col
= (state
& wxDATAVIEW_CELL_SELECTED
) ? *wxWHITE
: view
->GetForegroundColour();
558 dc
->SetTextForeground(col
);
559 dc
->DrawText( text
, cell
.x
+ xoffset
, cell
.y
+ ((cell
.height
- dc
->GetCharHeight()) / 2));
562 wxDC
* wxDataViewCustomRenderer::GetDC()
564 if (this->m_DCPtr
== NULL
)
566 if ((GetOwner() == NULL
) || (GetOwner()->GetOwner() == NULL
))
568 this->m_DCPtr
= new wxWindowDC(this->GetOwner()->GetOwner());
570 return this->m_DCPtr
;
571 } /* wxDataViewCustomRenderer::GetDC() */
573 bool wxDataViewCustomRenderer::Render()
576 } /* wxDataViewCustomRenderer::Render() */
578 void wxDataViewCustomRenderer::SetDC(wxDC
* newDCPtr
)
580 delete this->m_DCPtr
;
581 this->m_DCPtr
= newDCPtr
;
582 } /* wxDataViewCustomRenderer::SetDC(wxDC*) */
584 WXDataBrowserPropertyType
wxDataViewCustomRenderer::GetPropertyType() const
586 return kDataBrowserCustomType
;
587 } /* wxDataViewCustomRenderer::GetPropertyType() const */
589 IMPLEMENT_ABSTRACT_CLASS(wxDataViewCustomRenderer
, wxDataViewRenderer
)
591 // ---------------------------------------------------------
592 // wxDataViewTextRenderer
593 // ---------------------------------------------------------
595 wxDataViewTextRenderer::wxDataViewTextRenderer(wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
596 :wxDataViewRenderer(varianttype
,mode
,align
)
598 } /* wxDataViewTextRenderer::wxDataViewTextRenderer(wxString const&, wxDataViewCellMode, int) */
600 bool wxDataViewTextRenderer::Render()
602 wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Text renderer cannot render value; value type: ")) << this->GetValue().GetType());
604 // variable definition:
605 #if wxCHECK_VERSION(2,9,0)
606 wxCFStringRef
cfString(this->GetValue().GetString(),(this->GetView()->GetFont().Ok() ? this->GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
608 wxMacCFStringHolder
cfString(this->GetValue().GetString(),(this->GetView()->GetFont().Ok() ? this->GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
610 return (::SetDataBrowserItemDataText(this->GetDataReference(),cfString
) == noErr
);
611 } /* wxDataViewTextRenderer::Render() */
613 WXDataBrowserPropertyType
wxDataViewTextRenderer::GetPropertyType() const
615 return kDataBrowserTextType
;
616 } /* wxDataViewTextRenderer::GetPropertyType() const */
618 IMPLEMENT_CLASS(wxDataViewTextRenderer
,wxDataViewRenderer
)
620 // ---------------------------------------------------------
621 // wxDataViewTextRendererAttr
622 // ---------------------------------------------------------
624 wxDataViewTextRendererAttr::wxDataViewTextRendererAttr(wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
625 :wxDataViewTextRenderer(varianttype
,mode
,align
)
627 } /* wxDataViewTextRendererAttr::wxDataViewTextRendererAttr(wxString const&, wxDataViewCellMode, int) */
629 IMPLEMENT_CLASS(wxDataViewTextRendererAttr
,wxDataViewTextRenderer
)
631 // ---------------------------------------------------------
632 // wxDataViewBitmapRenderer
633 // ---------------------------------------------------------
635 wxDataViewBitmapRenderer::wxDataViewBitmapRenderer(wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
636 :wxDataViewRenderer(varianttype
,mode
,align
)
640 bool wxDataViewBitmapRenderer::Render()
641 // This method returns 'true' if
642 // - the passed bitmap is valid and it could be assigned to the native data browser;
643 // - the passed bitmap is invalid (or is not initialized); this case simulates a non-existing bitmap.
644 // In all other cases the method returns 'false'.
646 wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Bitmap renderer cannot render value; value type: ")) << this->GetValue().GetType());
648 // variable definition:
651 bitmap
<< this->GetValue();
653 #if wxCHECK_VERSION(2,9,0)
654 return (::SetDataBrowserItemDataIcon(this->GetDataReference(),bitmap
.GetIconRef()) == noErr
);
656 return (::SetDataBrowserItemDataIcon(this->GetDataReference(),bitmap
.GetBitmapData()->GetIconRef()) == noErr
);
660 } /* wxDataViewBitmapRenderer::Render() */
662 WXDataBrowserPropertyType
wxDataViewBitmapRenderer::GetPropertyType() const
664 return kDataBrowserIconType
;
665 } /* wxDataViewBitmapRenderer::GetPropertyType() const */
667 IMPLEMENT_CLASS(wxDataViewBitmapRenderer
,wxDataViewRenderer
)
669 // ---------------------------------------------------------
670 // wxDataViewIconTextRenderer
671 // ---------------------------------------------------------
673 wxDataViewIconTextRenderer::wxDataViewIconTextRenderer(wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
674 :wxDataViewRenderer(varianttype
,mode
)
678 bool wxDataViewIconTextRenderer::Render()
680 wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Icon & text renderer cannot render value; value type: ")) << this->GetValue().GetType());
682 // variable definition:
683 wxDataViewIconText iconText
;
685 iconText
<< this->GetValue();
687 // variable definition:
688 #if wxCHECK_VERSION(2,9,0)
689 wxCFStringRef
cfString(iconText
.GetText(),(this->GetView()->GetFont().Ok() ? this->GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
691 wxMacCFStringHolder
cfString(iconText
.GetText(),(this->GetView()->GetFont().Ok() ? this->GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
694 if (iconText
.GetIcon().IsOk())
695 if (::SetDataBrowserItemDataIcon(this->GetDataReference(),MAC_WXHICON(iconText
.GetIcon().GetHICON())) != noErr
)
697 return (::SetDataBrowserItemDataText(this->GetDataReference(),cfString
) == noErr
);
698 } /* wxDataViewIconTextRenderer::Render() */
700 WXDataBrowserPropertyType
wxDataViewIconTextRenderer::GetPropertyType() const
702 return kDataBrowserIconAndTextType
;
703 } /* wxDataViewIconTextRenderer::GetPropertyType() const */
705 IMPLEMENT_ABSTRACT_CLASS(wxDataViewIconTextRenderer
,wxDataViewRenderer
)
708 // ---------------------------------------------------------
709 // wxDataViewToggleRenderer
710 // ---------------------------------------------------------
712 wxDataViewToggleRenderer::wxDataViewToggleRenderer(wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
713 :wxDataViewRenderer(varianttype
,mode
)
717 bool wxDataViewToggleRenderer::Render()
719 wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Toggle renderer cannot render value; value type: ")) << this->GetValue().GetType());
720 return (::SetDataBrowserItemDataButtonValue(this->GetDataReference(),this->GetValue().GetBool()) == noErr
);
721 } /* wxDataViewToggleRenderer::Render() */
723 WXDataBrowserPropertyType
wxDataViewToggleRenderer::GetPropertyType() const
725 return kDataBrowserCheckboxType
;
726 } /* wxDataViewToggleRenderer::GetPropertyType() const */
728 IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleRenderer
,wxDataViewRenderer
)
730 // ---------------------------------------------------------
731 // wxDataViewProgressRenderer
732 // ---------------------------------------------------------
734 wxDataViewProgressRenderer::wxDataViewProgressRenderer(wxString
const& label
, wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
735 :wxDataViewRenderer(varianttype
,mode
,align
)
739 bool wxDataViewProgressRenderer::Render()
741 wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Progress renderer cannot render value type; value type: ")) << this->GetValue().GetType());
742 return ((::SetDataBrowserItemDataMinimum(this->GetDataReference(), 0) == noErr
) &&
743 (::SetDataBrowserItemDataMaximum(this->GetDataReference(),100) == noErr
) &&
744 (::SetDataBrowserItemDataValue (this->GetDataReference(),this->GetValue().GetLong()) == noErr
));
745 } /* wxDataViewProgressRenderer::Render() */
747 WXDataBrowserPropertyType
wxDataViewProgressRenderer::GetPropertyType() const
749 return kDataBrowserProgressBarType
;
750 } /* wxDataViewProgressRenderer::GetPropertyType() const */
752 IMPLEMENT_ABSTRACT_CLASS(wxDataViewProgressRenderer
,wxDataViewRenderer
)
754 // ---------------------------------------------------------
755 // wxDataViewDateRenderer
756 // ---------------------------------------------------------
758 wxDataViewDateRenderer::wxDataViewDateRenderer(wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
759 :wxDataViewRenderer(varianttype
,mode
,align
)
763 bool wxDataViewDateRenderer::Render()
765 wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Date renderer cannot render value; value type: ")) << this->GetValue().GetType());
766 return (::SetDataBrowserItemDataDateTime(this->GetDataReference(),this->GetValue().GetDateTime().Subtract(wxDateTime(1,wxDateTime::Jan
,1904)).GetSeconds().GetLo()) == noErr
);
767 } /* wxDataViewDateRenderer::Render() */
769 WXDataBrowserPropertyType
wxDataViewDateRenderer::GetPropertyType() const
771 return kDataBrowserDateTimeType
;
772 } /* wxDataViewDateRenderer::GetPropertyType() const */
774 IMPLEMENT_ABSTRACT_CLASS(wxDataViewDateRenderer
,wxDataViewRenderer
)
776 // ---------------------------------------------------------
778 // ---------------------------------------------------------
780 wxDataViewColumn::wxDataViewColumn(wxString
const &title
, wxDataViewRenderer
*cell
, unsigned int model_column
, int width
, wxAlignment align
, int flags
)
781 :wxDataViewColumnBase(title
,cell
,model_column
,width
,align
,flags
), m_ascending(true),
782 m_flags(flags
& ~(wxDATAVIEW_COL_HIDDEN
)), m_maxWidth(30000), m_minWidth(0), m_width(width
>= 0 ? width
: wxDVC_DEFAULT_WIDTH
),
783 m_alignment(align
), m_title(title
)
785 } /* wxDataViewColumn::wxDataViewColumn(wxString const &title, wxDataViewRenderer*, unsigned int, int, wxAlignment, int) */
787 wxDataViewColumn::wxDataViewColumn(wxBitmap
const& bitmap
, wxDataViewRenderer
*cell
, unsigned int model_column
, int width
, wxAlignment align
, int flags
)
788 :wxDataViewColumnBase(bitmap
,cell
,model_column
,width
,align
,flags
), m_ascending(true),
789 m_flags(flags
& ~(wxDATAVIEW_COL_HIDDEN
)), m_maxWidth(30000), m_minWidth(0), m_width(width
>= 0 ? width
: wxDVC_DEFAULT_WIDTH
),
792 } /* wxDataViewColumn::wxDataViewColumn(wxBitmap const&, wxDataViewRenderer*, unsigned int, int, wxAlignment, int) */
794 void wxDataViewColumn::SetAlignment(wxAlignment align
)
796 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
799 this->m_alignment
= align
;
800 if (dataViewCtrlPtr
!= NULL
)
802 // variable definition and initialization:
803 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
805 if (macDataViewListCtrlPtr
!= NULL
)
807 // variable definition and initialization:
808 DataBrowserListViewHeaderDesc headerDescription
;
810 wxCHECK_RET(macDataViewListCtrlPtr
->GetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not get header description."));
814 case wxALIGN_CENTER_HORIZONTAL
:
815 headerDescription
.btnFontStyle
.just
= teCenter
;
818 headerDescription
.btnFontStyle
.just
= teFlushLeft
;
821 headerDescription
.btnFontStyle
.just
= teFlushRight
;
824 headerDescription
.btnFontStyle
.just
= teFlushDefault
;
826 wxCHECK_RET(macDataViewListCtrlPtr
->SetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not set alignment."));
829 } /* wxDataViewColumn::SetAlignment(wxAlignment) */
831 void wxDataViewColumn::SetBitmap(wxBitmap
const& bitmap
)
833 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
836 wxDataViewColumnBase::SetBitmap(bitmap
);
837 if (dataViewCtrlPtr
!= NULL
)
839 // variable definition and initialization:
840 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
842 if (macDataViewListCtrlPtr
!= NULL
)
844 // variable definition and initialization:
845 DataBrowserListViewHeaderDesc headerDescription
;
847 wxCHECK_RET(macDataViewListCtrlPtr
->GetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not get header description."));
848 if (this->GetBitmap().Ok())
849 #if wxCHECK_VERSION(2,9,0)
850 headerDescription
.btnContentInfo
.u
.iconRef
= this->GetBitmap().GetIconRef();
852 headerDescription
.btnContentInfo
.u
.iconRef
= this->GetBitmap().GetBitmapData()->GetIconRef();
855 headerDescription
.btnContentInfo
.u
.iconRef
= NULL
;
856 wxCHECK_RET(macDataViewListCtrlPtr
->SetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not set icon."));
859 } /* wxDataViewColumn::SetBitmap(wxBitmap const&) */
861 void wxDataViewColumn::SetFlags(int flags
)
863 this->SetHidden ((flags
& wxDATAVIEW_COL_HIDDEN
) != 0);
864 this->SetReorderable((flags
& wxDATAVIEW_COL_REORDERABLE
) != 0);
865 this->SetResizeable ((flags
& wxDATAVIEW_COL_RESIZABLE
) != 0);
866 this->SetSortable ((flags
& wxDATAVIEW_COL_SORTABLE
) != 0);
867 } /* wxDataViewColumn::SetFlags(int) */
869 void wxDataViewColumn::SetMaxWidth(int maxWidth
)
871 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
874 this->m_maxWidth
= maxWidth
;
875 if (dataViewCtrlPtr
!= NULL
)
877 // variable definition and initialization:
878 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
880 if (macDataViewListCtrlPtr
!= NULL
)
882 // variable definition and initialization:
883 DataBrowserListViewHeaderDesc headerDescription
;
885 wxCHECK_RET(macDataViewListCtrlPtr
->GetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not get header description."));
886 headerDescription
.maximumWidth
= static_cast<UInt16
>(maxWidth
);
887 wxCHECK_RET(macDataViewListCtrlPtr
->SetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not set maximum width."));
890 } /* wxDataViewColumn::SetMaxWidth(int) */
892 void wxDataViewColumn::SetMinWidth(int minWidth
)
894 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
897 this->m_minWidth
= minWidth
;
898 if (dataViewCtrlPtr
!= NULL
)
900 // variable definition and initialization:
901 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
903 if (macDataViewListCtrlPtr
!= NULL
)
905 // variable definition and initialization:
906 DataBrowserListViewHeaderDesc headerDescription
;
908 wxCHECK_RET(macDataViewListCtrlPtr
->GetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not get header description."));
909 headerDescription
.minimumWidth
= static_cast<UInt16
>(minWidth
);
910 wxCHECK_RET(macDataViewListCtrlPtr
->SetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not set minimum width."));
913 } /* wxDataViewColumn::SetMaxWidth(int) */
915 void wxDataViewColumn::SetReorderable(bool reorderable
)
917 // first set the internal flag of the column:
919 this->m_flags
|= wxDATAVIEW_COL_REORDERABLE
;
921 this->m_flags
&= ~wxDATAVIEW_COL_REORDERABLE
;
922 // if the column is associated with a control change also immediately the flags of the control:
923 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner()); // variable definition and initialization
925 if (dataViewCtrlPtr
!= NULL
)
927 // variable definition and initialization:
928 DataBrowserPropertyFlags flags
;
929 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
931 wxCHECK_RET(macDataViewListCtrlPtr
!= NULL
, _("Valid pointer to native data view control does not exist"));
932 wxCHECK_RET(macDataViewListCtrlPtr
->GetPropertyFlags(this->GetPropertyID(),&flags
) == noErr
,_("Could not get property flags."));
934 flags
|= kDataBrowserListViewMovableColumn
;
936 flags
&= ~kDataBrowserListViewMovableColumn
;
937 wxCHECK_RET(macDataViewListCtrlPtr
->SetPropertyFlags(this->GetPropertyID(),flags
) == noErr
,_("Could not set property flags."));
939 } /* wxDataViewColumn::SetReorderable(bool) */
941 void wxDataViewColumn::SetResizeable(bool resizeable
)
943 // first set the internal flag of the column:
945 this->m_flags
|= wxDATAVIEW_COL_RESIZABLE
;
947 this->m_flags
&= ~wxDATAVIEW_COL_RESIZABLE
;
948 // if the column is associated with a control change also immediately the flags of the control:
949 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner()); // variable definition and initialization
951 if (dataViewCtrlPtr
!= NULL
)
953 // variable definition and initialization:
954 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
956 if (macDataViewListCtrlPtr
!= NULL
)
958 // variable definition and initialization:
959 DataBrowserListViewHeaderDesc headerDescription
;
961 verify_noerr(macDataViewListCtrlPtr
->GetHeaderDesc(this->GetPropertyID(),&headerDescription
));
963 headerDescription
.minimumWidth
= 0;
964 headerDescription
.maximumWidth
= 30000;
967 headerDescription
.minimumWidth
= this->m_width
;
968 headerDescription
.maximumWidth
= this->m_width
;
970 verify_noerr(macDataViewListCtrlPtr
->SetHeaderDesc(this->GetPropertyID(),&headerDescription
));
971 macDataViewListCtrlPtr
->SetSortProperty(this->GetPropertyID());
974 } /* wxDataViewColumn::SetResizeable(bool) */
976 void wxDataViewColumn::SetSortable(bool sortable
)
978 // first set the internal flag of the column:
980 this->m_flags
|= wxDATAVIEW_COL_SORTABLE
;
982 this->m_flags
&= ~wxDATAVIEW_COL_SORTABLE
;
983 // if the column is associated with a control change also immediately the flags of the control:
984 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner()); // variable definition and initialization
986 if (dataViewCtrlPtr
!= NULL
)
988 // variable definition and initialization:
989 DataBrowserPropertyFlags flags
;
990 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
992 wxCHECK_RET(macDataViewListCtrlPtr
!= NULL
, _("Valid pointer to native data view control does not exist"));
993 wxCHECK_RET(macDataViewListCtrlPtr
->GetPropertyFlags(this->GetPropertyID(),&flags
) == noErr
,_("Could not get property flags."));
995 flags
|= kDataBrowserListViewSortableColumn
;
997 flags
&= ~kDataBrowserListViewSortableColumn
;
998 wxCHECK_RET(macDataViewListCtrlPtr
->SetPropertyFlags(this->GetPropertyID(),flags
) == noErr
,_("Could not set property flags."));
1000 } /* wxDataViewColumn::SetSortable(bool) */
1002 void wxDataViewColumn::SetSortOrder(bool ascending
)
1004 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
1007 this->m_ascending
= ascending
;
1008 if (dataViewCtrlPtr
!= NULL
)
1010 // variable definition and initialization:
1011 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
1013 if (macDataViewListCtrlPtr
!= NULL
)
1015 // variable definition and initialization:
1016 DataBrowserListViewHeaderDesc headerDescription
;
1018 verify_noerr(macDataViewListCtrlPtr
->GetHeaderDesc(this->GetPropertyID(),&headerDescription
));
1020 headerDescription
.initialOrder
= kDataBrowserOrderIncreasing
;
1022 headerDescription
.initialOrder
= kDataBrowserOrderDecreasing
;
1023 verify_noerr(macDataViewListCtrlPtr
->SetHeaderDesc(this->GetPropertyID(),&headerDescription
));
1024 macDataViewListCtrlPtr
->SetSortProperty(this->GetPropertyID());
1027 } /* wxDataViewColumn::SetSortOrder(bool) */
1029 void wxDataViewColumn::SetTitle(wxString
const& title
)
1031 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
1034 this->m_title
= title
;
1035 if (dataViewCtrlPtr
!= NULL
)
1037 // variable definition and initialization:
1038 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
1040 if (macDataViewListCtrlPtr
!= NULL
)
1042 // variable definition and initialization:
1043 DataBrowserListViewHeaderDesc headerDescription
;
1044 #if wxCHECK_VERSION(2,9,0)
1045 wxCFStringRef
cfTitle(title
,(dataViewCtrlPtr
->GetFont().Ok() ? dataViewCtrlPtr
->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
1047 wxMacCFStringHolder
cfTitle(title
,(dataViewCtrlPtr
->GetFont().Ok() ? dataViewCtrlPtr
->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
1050 wxCHECK_RET(macDataViewListCtrlPtr
->GetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not get header description."));
1051 headerDescription
.titleString
= cfTitle
;
1052 wxCHECK_RET(macDataViewListCtrlPtr
->SetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not set header description."));
1055 } /* wxDataViewColumn::SetTitle(wxString const&) */
1057 void wxDataViewColumn::SetWidth(int width
)
1059 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
1062 if ((width
>= this->m_minWidth
) && (width
<= this->m_maxWidth
))
1064 this->m_width
= width
;
1065 if (dataViewCtrlPtr
!= NULL
)
1067 // variable definition and initialization:
1068 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
1070 if (macDataViewListCtrlPtr
!= NULL
)
1071 wxCHECK_RET(macDataViewListCtrlPtr
->SetColumnWidth(this->GetPropertyID(),static_cast<UInt16
>(width
)) == noErr
,_("Could not set column width."));
1074 } /* wxDataViewColumn::SetWidth(int) */
1076 IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumn
,wxDataViewColumnBase
)
1078 //-----------------------------------------------------------------------------
1080 //-----------------------------------------------------------------------------
1083 wxDataViewCtrl::~wxDataViewCtrl()
1089 void wxDataViewCtrl::Init()
1091 this->m_CustomRendererPtr
= NULL
;
1092 this->m_Deleting
= false;
1093 this->m_macIsUserPane
= false;
1094 this->m_cgContext
= NULL
;
1095 } /* wxDataViewCtrl::Init() */
1097 bool wxDataViewCtrl::Create(wxWindow
*parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
, const wxValidator
& validator
)
1099 if (!(this->wxControl::Create(parent
,id
,pos
,size
,style
& ~(wxHSCROLL
| wxVSCROLL
),validator
)))
1103 MacSetClipChildren(true) ;
1106 this->m_peer
= new wxMacDataViewDataBrowserListViewControl(this,pos
,size
,style
);
1108 if ( style
& wxBORDER_NONE
)
1109 this->m_peer
->SetData( kControlNoPart
, kControlDataBrowserIncludesFrameAndFocusTag
, (Boolean
) false ) ;
1111 this->MacPostControlCreate(pos
,size
);
1112 ::SetAutomaticControlDragTrackingEnabledForWindow(::GetControlOwner(this->m_peer
->GetControlRef()),true);
1114 InstallControlEventHandler(this->m_peer
->GetControlRef(),GetwxMacDataViewCtrlEventHandlerUPP(),GetEventTypeCount(eventList
),eventList
,this,NULL
);
1116 ::SetDataBrowserTableViewHiliteStyle( this->m_peer
->GetControlRef(), kDataBrowserTableViewFillHilite
);
1119 } /* wxDataViewCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator) */
1122 wxVisualAttributes
wxDataViewCtrl::GetClassDefaultAttributes(wxWindowVariant variant
)
1124 wxVisualAttributes attr
;
1126 attr
.colFg
= wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT
);
1127 attr
.colBg
= wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOX
);
1128 attr
.font
.MacCreateFromThemeFont(kThemeViewsFont
);
1133 bool wxDataViewCtrl::AssociateModel(wxDataViewModel
* model
)
1135 if (!wxDataViewCtrlBase::AssociateModel(model
))
1138 model
->AddNotifier(new wxMacDataViewModelNotifier(dynamic_cast<wxMacDataViewDataBrowserListViewControl
*>(this->m_peer
)));
1143 bool wxDataViewCtrl::AppendColumn(wxDataViewColumn
* columnPtr
)
1145 return InsertColumn( kDataBrowserListViewAppendColumn
, columnPtr
);
1148 bool wxDataViewCtrl::PrependColumn(wxDataViewColumn
* columnPtr
)
1150 return InsertColumn( 0, columnPtr
);
1153 bool wxDataViewCtrl::InsertColumn(unsigned int pos
, wxDataViewColumn
* columnPtr
)
1155 DataBrowserListViewColumnDesc columnDescription
;
1157 DataBrowserPropertyID NewPropertyID
;
1159 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1161 #if wxCHECK_VERSION(2,9,0)
1162 wxCFStringRef
title(columnPtr
->GetTitle(),this->m_font
.Ok() ? this->GetFont().GetEncoding() : wxLocale::GetSystemEncoding());
1164 wxMacCFStringHolder
title(columnPtr
->GetTitle(),this->m_font
.Ok() ? this->GetFont().GetEncoding() : wxLocale::GetSystemEncoding());
1168 // first, some error checking:
1169 wxCHECK_MSG(MacDataViewListCtrlPtr
!= NULL
, false,_("m_peer is not or incorrectly initialized"));
1170 wxCHECK_MSG(columnPtr
!= NULL
, false,_("Column pointer must not be NULL."));
1171 wxCHECK_MSG(columnPtr
->GetRenderer() != NULL
, false,_("Column does not have a renderer."));
1172 wxCHECK_MSG(this->GetModel() != NULL
, false,_("No model associated with control."));
1173 wxCHECK_MSG((columnPtr
->GetModelColumn() >= 0) &&
1174 (columnPtr
->GetModelColumn() < this->GetModel()->GetColumnCount()),false,_("Column's model column has no equivalent in the associated model."));
1176 // try to get new ID for the column:
1177 wxCHECK_MSG(MacDataViewListCtrlPtr
->GetFreePropertyID(&NewPropertyID
) == noErr
,false,_("Cannot create new column's ID. Probably max. number of columns reached."));
1178 // full column variable initialization:
1179 columnPtr
->SetPropertyID(NewPropertyID
);
1180 // add column to wxWidget's internal structure:
1181 wxCHECK_MSG(this->wxDataViewCtrlBase::AppendColumn(columnPtr
) &&
1182 this->m_ColumnPointers
.insert(ColumnPointerHashMapType::value_type(NewPropertyID
,columnPtr
)).second
,false,_("Could not add column to internal structures."));
1183 // create a column description and add column to the native control:
1184 wxCHECK_MSG(::InitializeColumnDescription(columnDescription
,columnPtr
,NewPropertyID
,title
), false,_("Column description could not be initialized."));
1185 wxCHECK_MSG(MacDataViewListCtrlPtr
->AddColumn(&columnDescription
,pos
) == noErr
,false,_("Column could not be added."));
1187 // final adjustments for the layout:
1188 wxCHECK_MSG(MacDataViewListCtrlPtr
->SetColumnWidth(NewPropertyID
,columnPtr
->GetWidth()) == noErr
,false,_("Column width could not be set."));
1190 // make sure that the data is up-to-date...
1191 // if the newly appended column is the first column add the initial data to the control and mark the column as an expander column,
1192 // otherwise ask the control to 'update' the data in the newly appended column:
1193 if (this->GetColumnCount() == 1)
1195 this->SetExpanderColumn(columnPtr
);
1196 this->AddChildrenLevel(wxDataViewItem());
1199 MacDataViewListCtrlPtr
->UpdateItems(kDataBrowserNoItem
,0,NULL
,kDataBrowserItemNoProperty
,NewPropertyID
);
1204 bool wxDataViewCtrl::ClearColumns()
1206 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1209 while (this->m_ColumnPointers
.begin() != this->m_ColumnPointers
.end())
1211 wxCHECK_MSG(MacDataViewListCtrlPtr
->RemoveColumnByProperty(this->m_ColumnPointers
.begin()->first
) == noErr
,false,_("Could not remove column."));
1212 delete this->m_ColumnPointers
.begin()->second
;
1213 this->m_ColumnPointers
.erase(this->m_ColumnPointers
.begin());
1218 bool wxDataViewCtrl::DeleteColumn(wxDataViewColumn
* columnPtr
)
1220 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1223 if ((MacDataViewListCtrlPtr
->RemoveColumnByProperty(columnPtr
->GetPropertyID()) == noErr
) && (this->m_ColumnPointers
.erase(columnPtr
->GetPropertyID()) > 0))
1230 } /* wxDataViewCtrl::DeleteColumn(wxDataViewColumn*) */
1232 wxDataViewColumn
* wxDataViewCtrl::GetColumn(unsigned int pos
) const
1234 DataBrowserPropertyID propertyID
;
1236 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1239 if (MacDataViewListCtrlPtr
->GetPropertyID(pos
,&propertyID
) == noErr
)
1241 // variable definition:
1242 ColumnPointerHashMapType::const_iterator
Result(this->m_ColumnPointers
.find(propertyID
));
1244 if (Result
!= this->m_ColumnPointers
.end())
1245 return Result
->second
;
1251 } /* wxDataViewCtrl::GetColumn(unsigned int pos) const */
1253 unsigned int wxDataViewCtrl::GetColumnCount() const
1255 return this->m_ColumnPointers
.size();
1256 } /* wxDataViewCtrl::GetColumnCount() const */
1258 int wxDataViewCtrl::GetColumnPosition(wxDataViewColumn
const* columnPtr
) const
1260 if (columnPtr
!= NULL
)
1262 // variable definition and initialization:
1263 DataBrowserTableViewColumnIndex Position
;
1264 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1266 wxCHECK_MSG(MacDataViewListCtrlPtr
->GetColumnIndex(columnPtr
->GetPropertyID(),&Position
) == noErr
,-1,_("Could not determine column's position"));
1267 return static_cast<int>(Position
);
1271 } /* wxDataViewCtrl::GetColumnPosition(wxDataViewColumn const*) const */
1273 void wxDataViewCtrl::Collapse(wxDataViewItem
const& item
)
1275 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1278 MacDataViewListCtrlPtr
->CloseContainer(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
1279 } /* wxDataViewCtrl::Collapse(wxDataViewItem const&) */
1281 void wxDataViewCtrl::EnsureVisible(wxDataViewItem
const& item
, wxDataViewColumn
const* columnPtr
)
1285 // variable definition and initialization:
1286 DataBrowserPropertyID propertyID
;
1287 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1289 if (columnPtr
!= NULL
)
1290 propertyID
= columnPtr
->GetPropertyID();
1292 propertyID
= kDataBrowserNoItem
;
1293 MacDataViewListCtrlPtr
->RevealItem(reinterpret_cast<DataBrowserItemID
>(item
.GetID()),propertyID
,kDataBrowserRevealOnly
);
1295 } /* wxDataViewCtrl::EnsureVisible(wxDataViewItem const&, wxDataViewColumn const*) */
1297 void wxDataViewCtrl::Expand(wxDataViewItem
const& item
)
1299 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1302 MacDataViewListCtrlPtr
->OpenContainer(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
1303 } /* wxDataViewCtrl::Expand(wxDataViewItem const&) */
1305 wxDataViewColumn
* wxDataViewCtrl::GetSortingColumn() const
1307 DataBrowserPropertyID propertyID
;
1309 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1312 if (MacDataViewListCtrlPtr
->GetSortProperty(&propertyID
) == noErr
)
1313 return this->GetColumnPtr(propertyID
);
1316 } /* wxDataViewCtrl::GetSortingColumn() const */
1318 unsigned int wxDataViewCtrl::GetCount() const
1320 ItemCount noOfItems
;
1323 wxCHECK_MSG(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
)->GetItemCount(&noOfItems
) == noErr
,0,_("Could not determine number of items"));
1325 } /* wxDataViewCtrl::GetCount() const */
1327 wxRect
wxDataViewCtrl::GetItemRect(wxDataViewItem
const& item
, wxDataViewColumn
const* columnPtr
) const
1329 if (item
.IsOk() && (columnPtr
!= NULL
))
1331 // variable definition:
1333 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1335 if (MacDataViewListCtrlPtr
->GetPartBounds(reinterpret_cast<DataBrowserItemID
>(item
.GetID()),columnPtr
->GetPropertyID(),kDataBrowserPropertyContentPart
,&MacRectangle
) == noErr
)
1337 // variable definition:
1340 ::wxMacNativeToRect(&MacRectangle
,&rectangle
);
1348 } /* wxDataViewCtrl::GetItemRect(wxDataViewItem const&, unsigned int) const */
1350 wxDataViewItem
wxDataViewCtrl::GetSelection() const
1352 wxArrayDataBrowserItemID itemIDs
;
1354 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1357 if (MacDataViewListCtrlPtr
->GetSelectedItemIDs(itemIDs
) > 0)
1358 return wxDataViewItem(reinterpret_cast<void*>(itemIDs
[0]));
1360 return wxDataViewItem();
1361 } /* wxDataViewCtrl::GetSelection() const */
1363 int wxDataViewCtrl::GetSelections(wxDataViewItemArray
& sel
) const
1365 size_t NoOfSelectedItems
;
1367 wxArrayDataBrowserItemID itemIDs
;
1369 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1372 NoOfSelectedItems
= MacDataViewListCtrlPtr
->GetSelectedItemIDs(itemIDs
);
1374 sel
.SetCount(NoOfSelectedItems
);
1375 for (size_t i
=0; i
<NoOfSelectedItems
; ++i
)
1376 sel
[i
] = wxDataViewItem(reinterpret_cast<void*>(itemIDs
[i
]));
1377 return static_cast<int>(NoOfSelectedItems
);
1378 } /* wxDataViewCtrl::GetSelections(wxDataViewItemArray&) const */
1380 void wxDataViewCtrl::HitTest(wxPoint
const& point
, wxDataViewItem
& item
, wxDataViewColumn
*& columnPtr
) const
1382 item
= wxDataViewItem();
1384 } /* wxDataViewCtrl::HitTest(wxPoint const&, wxDataViewItem&, wxDataViewColumn*&) const */
1386 bool wxDataViewCtrl::IsSelected(wxDataViewItem
const& item
) const
1388 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1391 return MacDataViewListCtrlPtr
->IsItemSelected(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
1392 } /* wxDataViewCtrl::IsSelected(wxDataViewItem const&) const */
1394 void wxDataViewCtrl::SelectAll()
1396 DataBrowserItemID
* itemIDPtr
;
1398 Handle
handle(::NewHandle(0));
1402 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1405 wxCHECK_RET(MacDataViewListCtrlPtr
->GetItems(kDataBrowserNoItem
,true,kDataBrowserItemAnyState
,handle
) == noErr
,_("Could not get items."));
1406 NoOfItems
= static_cast<size_t>(::GetHandleSize(handle
)/sizeof(DataBrowserItemID
));
1408 itemIDPtr
= (DataBrowserItemID
*) (*handle
);
1409 MacDataViewListCtrlPtr
->SetSelectedItems(NoOfItems
,itemIDPtr
,kDataBrowserItemsAssign
);
1411 DisposeHandle(handle
);
1412 } /* wxDataViewCtrl::SelectAll() */
1414 void wxDataViewCtrl::Select(wxDataViewItem
const& item
)
1418 // variable definition and initialization:
1419 DataBrowserItemID
itemID(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
1420 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1422 MacDataViewListCtrlPtr
->SetSelectedItems(1,&itemID
,kDataBrowserItemsAdd
);
1424 } /* wxDataViewCtrl::Select(wxDataViewItem const&) */
1426 void wxDataViewCtrl::SetSelections(wxDataViewItemArray
const& sel
)
1428 size_t const NoOfSelections
= sel
.GetCount();
1430 DataBrowserItemID
* itemIDs
;
1432 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1435 itemIDs
= new DataBrowserItemID
[NoOfSelections
];
1436 for (size_t i
=0; i
<NoOfSelections
; ++i
)
1437 itemIDs
[i
] = reinterpret_cast<DataBrowserItemID
>(sel
[i
].GetID());
1438 MacDataViewListCtrlPtr
->SetSelectedItems(NoOfSelections
,itemIDs
,kDataBrowserItemsAssign
);
1440 } /* wxDataViewCtrl::SetSelections(wxDataViewItemArray const&) */
1442 void wxDataViewCtrl::Unselect(wxDataViewItem
const& item
)
1446 // variable definition and initialization:
1447 DataBrowserItemID
itemID(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
1448 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1450 MacDataViewListCtrlPtr
->SetSelectedItems(1,&itemID
,kDataBrowserItemsRemove
);
1452 } /* wxDataViewCtrl::Unselect(wxDataViewItem const&) */
1454 void wxDataViewCtrl::UnselectAll()
1456 DataBrowserItemID
* itemIDPtr
;
1458 Handle
handle(::NewHandle(0));
1462 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1465 wxCHECK_RET(MacDataViewListCtrlPtr
->GetItems(kDataBrowserNoItem
,true,kDataBrowserItemAnyState
,handle
) == noErr
,_("Could not get items."));
1466 NoOfItems
= static_cast<size_t>(::GetHandleSize(handle
)/sizeof(DataBrowserItemID
));
1468 itemIDPtr
= (DataBrowserItemID
*) (*handle
);
1469 MacDataViewListCtrlPtr
->SetSelectedItems(NoOfItems
,itemIDPtr
,kDataBrowserItemsRemove
);
1471 DisposeHandle(handle
);
1472 } /* wxDataViewCtrl::UnselectAll() */
1475 void wxDataViewCtrl::AddChildrenLevel(wxDataViewItem
const& parentItem
)
1479 wxDataViewItemArray items
;
1482 wxCHECK_RET(this->GetModel() != NULL
,_("Model pointer not initialized."));
1483 NoOfChildren
= this->GetModel()->GetChildren(parentItem
,items
);
1485 for (int i
=0; i
<NoOfChildren
; ++i
)
1486 (void) this->GetModel()->ItemAdded(parentItem
,items
[i
]);
1488 (void) this->GetModel()->ItemsAdded(parentItem
,items
);
1492 void wxDataViewCtrl::FinishCustomItemEditing()
1494 if (this->GetCustomRendererItem().IsOk())
1496 this->GetCustomRendererPtr()->FinishEditing();
1497 this->SetCustomRendererItem(wxDataViewItem());
1498 this->SetCustomRendererPtr (NULL
);
1502 wxDataViewColumn
* wxDataViewCtrl::GetColumnPtr(WXDataBrowserPropertyID propertyID
) const
1504 // variable definition:
1505 ColumnPointerHashMapType::const_iterator
Result(this->m_ColumnPointers
.find(propertyID
));
1507 if (Result
!= this->m_ColumnPointers
.end())
1508 return Result
->second
;
1513 // inherited methods from wxDataViewCtrlBase
1514 void wxDataViewCtrl::DoSetExpanderColumn()
1516 if (this->GetExpanderColumn() != NULL
)
1518 // variable definition and initialization:
1519 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1521 (void) MacDataViewListCtrlPtr
->SetDisclosureColumn(this->GetExpanderColumn()->GetPropertyID(),false); // second parameter explicitely passed to ensure that arrow is centered
1525 void wxDataViewCtrl::DoSetIndent()
1527 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1529 (void) MacDataViewListCtrlPtr
->SetIndent(static_cast<float>(this->GetIndent()));
1533 void wxDataViewCtrl::OnSize(wxSizeEvent
& event
)
1535 unsigned int const NoOfColumns
= this->GetColumnCount();
1538 for (unsigned int i
=0; i
<NoOfColumns
; ++i
)
1540 // variable definition and initialization:
1541 wxDataViewColumn
* dataViewColumnPtr(this->GetColumn(i
));
1543 if (dataViewColumnPtr
!= NULL
)
1545 // variable definition and initialization:
1546 wxDataViewCustomRenderer
* dataViewCustomRendererPtr(dynamic_cast<wxDataViewCustomRenderer
*>(dataViewColumnPtr
->GetRenderer()));
1548 if (dataViewCustomRendererPtr
!= NULL
)
1549 dataViewCustomRendererPtr
->SetDC(NULL
); // reset DC because DC has changed
1553 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1554 ControlRef ref
= MacDataViewListCtrlPtr
->GetControlRef();
1555 if (NoOfColumns
== 1)
1557 ::SetDataBrowserHasScrollBars( ref
, false, true );
1558 ::AutoSizeDataBrowserListViewColumns( ref
);
1560 if (NoOfColumns
> 1)
1562 ::SetDataBrowserHasScrollBars( ref
, true, true );
1566 } /* wxDataViewCtrl::OnSize(wxSizeEvent&) */
1568 IMPLEMENT_DYNAMIC_CLASS(wxDataViewCtrl
,wxDataViewCtrlBase
)
1570 BEGIN_EVENT_TABLE(wxDataViewCtrl
,wxDataViewCtrlBase
)
1571 EVT_SIZE(wxDataViewCtrl::OnSize
)
1575 // !wxUSE_GENERICDATAVIEWCTRL
1578 // wxUSE_DATAVIEWCTRL