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 resizeable
)
872 // first set the internal flag of the column:
874 this->m_flags
|= wxDATAVIEW_COL_RESIZABLE
;
876 this->m_flags
&= ~wxDATAVIEW_COL_RESIZABLE
;
877 // if the column is associated with a control change also immediately the flags of the control:
878 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner()); // variable definition and initialization
880 if (dataViewCtrlPtr
!= NULL
)
882 // variable definition and initialization:
883 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
885 if (macDataViewListCtrlPtr
!= NULL
)
887 // variable definition and initialization:
888 DataBrowserListViewHeaderDesc headerDescription
;
890 verify_noerr(macDataViewListCtrlPtr
->GetHeaderDesc(this->GetPropertyID(),&headerDescription
));
892 headerDescription
.minimumWidth
= 0;
893 headerDescription
.maximumWidth
= 30000;
896 headerDescription
.minimumWidth
= this->m_width
;
897 headerDescription
.maximumWidth
= this->m_width
;
899 verify_noerr(macDataViewListCtrlPtr
->SetHeaderDesc(this->GetPropertyID(),&headerDescription
));
900 macDataViewListCtrlPtr
->SetSortProperty(this->GetPropertyID());
903 } /* wxDataViewColumn::SetResizeable(bool) */
905 void wxDataViewColumn::SetSortable(bool sortable
)
907 // first set the internal flag of the column:
909 this->m_flags
|= wxDATAVIEW_COL_SORTABLE
;
911 this->m_flags
&= ~wxDATAVIEW_COL_SORTABLE
;
912 // if the column is associated with a control change also immediately the flags of the control:
913 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner()); // variable definition and initialization
915 if (dataViewCtrlPtr
!= NULL
)
917 // variable definition and initialization:
918 DataBrowserPropertyFlags flags
;
919 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
921 wxCHECK_RET(macDataViewListCtrlPtr
!= NULL
, _("Valid pointer to native data view control does not exist"));
922 wxCHECK_RET(macDataViewListCtrlPtr
->GetPropertyFlags(this->GetPropertyID(),&flags
) == noErr
,_("Could not get property flags."));
924 flags
|= kDataBrowserListViewSortableColumn
;
926 flags
&= ~kDataBrowserListViewSortableColumn
;
927 wxCHECK_RET(macDataViewListCtrlPtr
->SetPropertyFlags(this->GetPropertyID(),flags
) == noErr
,_("Could not set property flags."));
929 } /* wxDataViewColumn::SetSortable(bool) */
931 void wxDataViewColumn::SetSortOrder(bool ascending
)
933 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
936 this->m_ascending
= ascending
;
937 if (dataViewCtrlPtr
!= NULL
)
939 // variable definition and initialization:
940 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
942 if (macDataViewListCtrlPtr
!= NULL
)
944 // variable definition and initialization:
945 DataBrowserListViewHeaderDesc headerDescription
;
947 verify_noerr(macDataViewListCtrlPtr
->GetHeaderDesc(this->GetPropertyID(),&headerDescription
));
949 headerDescription
.initialOrder
= kDataBrowserOrderIncreasing
;
951 headerDescription
.initialOrder
= kDataBrowserOrderDecreasing
;
952 verify_noerr(macDataViewListCtrlPtr
->SetHeaderDesc(this->GetPropertyID(),&headerDescription
));
953 macDataViewListCtrlPtr
->SetSortProperty(this->GetPropertyID());
956 } /* wxDataViewColumn::SetSortOrder(bool) */
958 void wxDataViewColumn::SetTitle(wxString
const& title
)
960 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
963 this->m_title
= title
;
964 if (dataViewCtrlPtr
!= NULL
)
966 // variable definition and initialization:
967 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
969 if (macDataViewListCtrlPtr
!= NULL
)
971 // variable definition and initialization:
972 DataBrowserListViewHeaderDesc headerDescription
;
973 #if wxCHECK_VERSION(2,9,0)
974 wxCFStringRef
cfTitle(title
,(dataViewCtrlPtr
->GetFont().Ok() ? dataViewCtrlPtr
->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
976 wxMacCFStringHolder
cfTitle(title
,(dataViewCtrlPtr
->GetFont().Ok() ? dataViewCtrlPtr
->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
979 wxCHECK_RET(macDataViewListCtrlPtr
->GetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not get header description."));
980 headerDescription
.titleString
= cfTitle
;
981 wxCHECK_RET(macDataViewListCtrlPtr
->SetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not set header description."));
984 } /* wxDataViewColumn::SetTitle(wxString const&) */
986 void wxDataViewColumn::SetWidth(int width
)
988 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
991 if ((width
>= this->m_minWidth
) && (width
<= this->m_maxWidth
))
993 this->m_width
= width
;
994 if (dataViewCtrlPtr
!= NULL
)
996 // variable definition and initialization:
997 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
999 if (macDataViewListCtrlPtr
!= NULL
)
1000 wxCHECK_RET(macDataViewListCtrlPtr
->SetColumnWidth(this->GetPropertyID(),static_cast<UInt16
>(width
)) == noErr
,_("Could not set column width."));
1003 } /* wxDataViewColumn::SetWidth(int) */
1005 IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumn
,wxDataViewColumnBase
)
1007 //-----------------------------------------------------------------------------
1009 //-----------------------------------------------------------------------------
1011 void wxDataViewCtrl::Init(void)
1013 this->m_CustomRendererPtr
= NULL
;
1014 this->m_Deleting
= false;
1015 this->m_macIsUserPane
= false;
1016 this->m_cgContext
= NULL
;
1017 } /* wxDataViewCtrl::Init(void) */
1019 bool wxDataViewCtrl::Create(wxWindow
*parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
, const wxValidator
& validator
)
1021 if (!(this->wxControl::Create(parent
,id
,pos
,size
,(style
| wxSUNKEN_BORDER
) & ~(wxHSCROLL
| wxVSCROLL
),validator
)))
1025 MacSetClipChildren(true) ;
1028 this->m_peer
= new wxMacDataViewDataBrowserListViewControl(this,pos
,size
,style
);
1029 this->MacPostControlCreate(pos
,size
);
1030 ::SetAutomaticControlDragTrackingEnabledForWindow(::GetControlOwner(this->m_peer
->GetControlRef()),true);
1032 InstallControlEventHandler(this->m_peer
->GetControlRef(),GetwxMacDataViewCtrlEventHandlerUPP(),GetEventTypeCount(eventList
),eventList
,this,NULL
);
1034 ::SetDataBrowserTableViewHiliteStyle( this->m_peer
->GetControlRef(), kDataBrowserTableViewFillHilite
);
1036 ::SetDataBrowserTableViewGeometry( this->m_peer
->GetControlRef(), true, false );
1039 } /* wxDataViewCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator) */
1042 wxVisualAttributes
wxDataViewCtrl::GetClassDefaultAttributes(wxWindowVariant variant
)
1044 wxVisualAttributes attr
;
1046 attr
.colFg
= wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT
);
1047 attr
.colBg
= wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOX
);
1048 attr
.font
.MacCreateFromThemeFont(kThemeViewsFont
);
1053 bool wxDataViewCtrl::AssociateModel(wxDataViewModel
* model
)
1055 if (!wxDataViewCtrlBase::AssociateModel(model
))
1058 model
->AddNotifier(new wxMacDataViewModelNotifier(dynamic_cast<wxMacDataViewDataBrowserListViewControl
*>(this->m_peer
)));
1061 } /* wxDataViewCtrl::AssociateModel(wxDataViewModel*) */
1063 bool wxDataViewCtrl::AppendColumn(wxDataViewColumn
* columnPtr
)
1065 DataBrowserListViewColumnDesc columnDescription
;
1067 DataBrowserPropertyID NewPropertyID
;
1069 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1071 #if wxCHECK_VERSION(2,9,0)
1072 wxCFStringRef
title(columnPtr
->GetTitle(),this->m_font
.Ok() ? this->GetFont().GetEncoding() : wxLocale::GetSystemEncoding());
1074 wxMacCFStringHolder
title(columnPtr
->GetTitle(),this->m_font
.Ok() ? this->GetFont().GetEncoding() : wxLocale::GetSystemEncoding());
1078 // first, some error checking:
1079 wxCHECK_MSG(MacDataViewListCtrlPtr
!= NULL
, false,_("m_peer is not or incorrectly initialized"));
1080 wxCHECK_MSG(columnPtr
!= NULL
, false,_("Column pointer must not be NULL."));
1081 wxCHECK_MSG(columnPtr
->GetRenderer() != NULL
, false,_("Column does not have a renderer."));
1082 wxCHECK_MSG(this->GetModel() != NULL
, false,_("No model associated with control."));
1083 wxCHECK_MSG((columnPtr
->GetModelColumn() >= 0) &&
1084 (columnPtr
->GetModelColumn() < this->GetModel()->GetColumnCount()),false,_("Column's model column has no equivalent in the associated model."));
1086 // try to get new ID for the column:
1087 wxCHECK_MSG(MacDataViewListCtrlPtr
->GetFreePropertyID(&NewPropertyID
) == noErr
,false,_("Cannot create new column's ID. Probably max. number of columns reached."));
1088 // full column variable initialization:
1089 columnPtr
->SetPropertyID(NewPropertyID
);
1090 // add column to wxWidget's internal structure:
1091 wxCHECK_MSG(this->wxDataViewCtrlBase::AppendColumn(columnPtr
) &&
1092 this->m_ColumnPointers
.insert(ColumnPointerHashMapType::value_type(NewPropertyID
,columnPtr
)).second
,false,_("Could not add column to internal structures."));
1093 // create a column description and add column to the native control:
1094 wxCHECK_MSG(::InitializeColumnDescription(columnDescription
,columnPtr
,NewPropertyID
,title
), false,_("Column description could not be initialized."));
1095 wxCHECK_MSG(MacDataViewListCtrlPtr
->AddColumn(&columnDescription
,kDataBrowserListViewAppendColumn
) == noErr
,false,_("Column could not be added."));
1097 // final adjustments for the layout:
1098 wxCHECK_MSG(MacDataViewListCtrlPtr
->SetColumnWidth(NewPropertyID
,columnPtr
->GetWidth()) == noErr
,false,_("Column width could not be set."));
1100 // make sure that the data is up-to-date...
1101 // if the newly appended column is the first column add the initial data to the control and mark the column as an expander column,
1102 // otherwise ask the control to 'update' the data in the newly appended column:
1103 if (this->GetColumnCount() == 1)
1105 this->SetExpanderColumn(columnPtr
);
1106 this->AddChildrenLevel(wxDataViewItem());
1109 MacDataViewListCtrlPtr
->UpdateItems(kDataBrowserNoItem
,0,NULL
,kDataBrowserItemNoProperty
,NewPropertyID
);
1112 } /* wxDataViewCtrl::AppendColumn(wxDataViewColumn*) */
1114 bool wxDataViewCtrl::ClearColumns(void)
1116 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1119 while (this->m_ColumnPointers
.begin() != this->m_ColumnPointers
.end())
1121 wxCHECK_MSG(MacDataViewListCtrlPtr
->RemoveColumnByProperty(this->m_ColumnPointers
.begin()->first
) == noErr
,false,_("Could not remove column."));
1122 delete this->m_ColumnPointers
.begin()->second
;
1123 this->m_ColumnPointers
.erase(this->m_ColumnPointers
.begin());
1126 } /* wxDataViewCtrl::ClearColumns(void) */
1128 bool wxDataViewCtrl::DeleteColumn(wxDataViewColumn
* columnPtr
)
1130 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1133 if ((MacDataViewListCtrlPtr
->RemoveColumnByProperty(columnPtr
->GetPropertyID()) == noErr
) && (this->m_ColumnPointers
.erase(columnPtr
->GetPropertyID()) > 0))
1140 } /* wxDataViewCtrl::DeleteColumn(wxDataViewColumn*) */
1142 wxDataViewColumn
* wxDataViewCtrl::GetColumn(unsigned int pos
) const
1144 DataBrowserPropertyID propertyID
;
1146 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1149 if (MacDataViewListCtrlPtr
->GetPropertyID(pos
,&propertyID
) == noErr
)
1151 // variable definition:
1152 ColumnPointerHashMapType::const_iterator
Result(this->m_ColumnPointers
.find(propertyID
));
1154 if (Result
!= this->m_ColumnPointers
.end())
1155 return Result
->second
;
1161 } /* wxDataViewCtrl::GetColumn(unsigned int pos) const */
1163 unsigned int wxDataViewCtrl::GetColumnCount(void) const
1165 return this->m_ColumnPointers
.size();
1166 } /* wxDataViewCtrl::GetColumnCount(void) const */
1168 int wxDataViewCtrl::GetColumnPosition(wxDataViewColumn
const* columnPtr
) const
1170 if (columnPtr
!= NULL
)
1172 // variable definition and initialization:
1173 DataBrowserTableViewColumnIndex Position
;
1174 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1176 wxCHECK_MSG(MacDataViewListCtrlPtr
->GetColumnIndex(columnPtr
->GetPropertyID(),&Position
) == noErr
,-1,_("Could not determine column's position"));
1177 return static_cast<int>(Position
);
1181 } /* wxDataViewCtrl::GetColumnPosition(wxDataViewColumn const*) const */
1183 bool wxDataViewCtrl::PrependColumn(wxDataViewColumn
* columnPtr
)
1185 DataBrowserListViewColumnDesc columnDescription
;
1187 DataBrowserPropertyID NewPropertyID
;
1189 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1191 #if wxCHECK_VERSION(2,9,0)
1192 wxCFStringRef
title(columnPtr
->GetTitle(),this->m_font
.Ok() ? this->GetFont().GetEncoding() : wxLocale::GetSystemEncoding());
1194 wxMacCFStringHolder
title(columnPtr
->GetTitle(),this->m_font
.Ok() ? this->GetFont().GetEncoding() : wxLocale::GetSystemEncoding());
1198 // first, some error checking:
1199 wxCHECK_MSG(MacDataViewListCtrlPtr
!= NULL
, false,_("m_peer is not or incorrectly initialized"));
1200 wxCHECK_MSG(columnPtr
!= NULL
, false,_("Column pointer must not be NULL."));
1201 wxCHECK_MSG(columnPtr
->GetRenderer() != NULL
, false,_("Column does not have a renderer."));
1202 wxCHECK_MSG(this->GetModel() != NULL
, false,_("No model associated with control."));
1203 wxCHECK_MSG((columnPtr
->GetModelColumn() >= 0) &&
1204 (columnPtr
->GetModelColumn() < this->GetModel()->GetColumnCount()),false,_("Column's model column has no equivalent in the associated model."));
1206 // try to get new ID for the column:
1207 wxCHECK_MSG(MacDataViewListCtrlPtr
->GetFreePropertyID(&NewPropertyID
) == noErr
,false,_("Cannot create new column's ID. Probably max. number of columns reached."));
1208 // full column variable initialization:
1209 columnPtr
->SetPropertyID(NewPropertyID
);
1210 // add column to wxWidget's internal structure:
1211 wxCHECK_MSG(this->wxDataViewCtrlBase::AppendColumn(columnPtr
) &&
1212 this->m_ColumnPointers
.insert(ColumnPointerHashMapType::value_type(NewPropertyID
,columnPtr
)).second
,false,_("Could not add column to internal structures."));
1213 // create a column description and add column to the native control:
1214 wxCHECK_MSG(::InitializeColumnDescription(columnDescription
,columnPtr
,NewPropertyID
,title
),false,_("Column description could not be initialized."));
1215 wxCHECK_MSG(MacDataViewListCtrlPtr
->AddColumn(&columnDescription
,0) == noErr
, false,_("Column could not be added."));
1217 // final adjustments for the layout:
1218 wxCHECK_MSG(MacDataViewListCtrlPtr
->SetColumnWidth(NewPropertyID
,columnPtr
->GetWidth()) == noErr
,false,_("Column width could not be set."));
1220 // make sure that the data is up-to-date...
1221 // if the newly appended column is the first column add the initial data to the control and mark the column as an expander column,
1222 // otherwise ask the control to 'update' the data in the newly appended column:
1223 if (this->GetColumnCount() == 1)
1225 this->SetExpanderColumn(columnPtr
);
1226 this->AddChildrenLevel(wxDataViewItem());
1229 MacDataViewListCtrlPtr
->UpdateItems(kDataBrowserNoItem
,0,NULL
,kDataBrowserItemNoProperty
,NewPropertyID
);
1232 } /* wxDataViewCtrl::PrependColumn(wxDataViewColumn*) */
1234 void wxDataViewCtrl::Collapse(wxDataViewItem
const& item
)
1236 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1239 MacDataViewListCtrlPtr
->CloseContainer(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
1240 } /* wxDataViewCtrl::Collapse(wxDataViewItem const&) */
1242 void wxDataViewCtrl::EnsureVisible(wxDataViewItem
const& item
, wxDataViewColumn
const* columnPtr
)
1246 // variable definition and initialization:
1247 DataBrowserPropertyID propertyID
;
1248 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1250 if (columnPtr
!= NULL
)
1251 propertyID
= columnPtr
->GetPropertyID();
1253 propertyID
= kDataBrowserNoItem
;
1254 MacDataViewListCtrlPtr
->RevealItem(reinterpret_cast<DataBrowserItemID
>(item
.GetID()),propertyID
,kDataBrowserRevealOnly
);
1256 } /* wxDataViewCtrl::EnsureVisible(wxDataViewItem const&, wxDataViewColumn const*) */
1258 void wxDataViewCtrl::Expand(wxDataViewItem
const& item
)
1260 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1263 MacDataViewListCtrlPtr
->OpenContainer(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
1264 } /* wxDataViewCtrl::Expand(wxDataViewItem const&) */
1266 wxDataViewColumn
* wxDataViewCtrl::GetSortingColumn(void) const
1268 DataBrowserPropertyID propertyID
;
1270 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1273 if (MacDataViewListCtrlPtr
->GetSortProperty(&propertyID
) == noErr
)
1274 return this->GetColumnPtr(propertyID
);
1277 } /* wxDataViewCtrl::GetSortingColumn(void) const */
1279 unsigned int wxDataViewCtrl::GetCount(void) const
1281 ItemCount noOfItems
;
1284 wxCHECK_MSG(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
)->GetItemCount(&noOfItems
) == noErr
,0,_("Could not determine number of items"));
1286 } /* wxDataViewCtrl::GetCount(void) const */
1288 wxRect
wxDataViewCtrl::GetItemRect(wxDataViewItem
const& item
, wxDataViewColumn
const* columnPtr
) const
1290 if (item
.IsOk() && (columnPtr
!= NULL
))
1292 // variable definition:
1294 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1296 if (MacDataViewListCtrlPtr
->GetPartBounds(reinterpret_cast<DataBrowserItemID
>(item
.GetID()),columnPtr
->GetPropertyID(),kDataBrowserPropertyContentPart
,&MacRectangle
) == noErr
)
1298 // variable definition:
1301 ::wxMacNativeToRect(&MacRectangle
,&rectangle
);
1309 } /* wxDataViewCtrl::GetItemRect(wxDataViewItem const&, unsigned int) const */
1311 wxDataViewItem
wxDataViewCtrl::GetSelection(void) const
1313 wxArrayDataBrowserItemID itemIDs
;
1315 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1318 if (MacDataViewListCtrlPtr
->GetSelectedItemIDs(itemIDs
) > 0)
1319 return wxDataViewItem(reinterpret_cast<void*>(itemIDs
[0]));
1321 return wxDataViewItem();
1322 } /* wxDataViewCtrl::GetSelection(void) const */
1324 int wxDataViewCtrl::GetSelections(wxDataViewItemArray
& sel
) const
1326 size_t NoOfSelectedItems
;
1328 wxArrayDataBrowserItemID itemIDs
;
1330 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1333 NoOfSelectedItems
= MacDataViewListCtrlPtr
->GetSelectedItemIDs(itemIDs
);
1335 sel
.SetCount(NoOfSelectedItems
);
1336 for (size_t i
=0; i
<NoOfSelectedItems
; ++i
)
1337 sel
[i
] = wxDataViewItem(reinterpret_cast<void*>(itemIDs
[i
]));
1338 return static_cast<int>(NoOfSelectedItems
);
1339 } /* wxDataViewCtrl::GetSelections(wxDataViewItemArray&) const */
1341 void wxDataViewCtrl::HitTest(wxPoint
const& point
, wxDataViewItem
& item
, wxDataViewColumn
*& columnPtr
) const
1343 item
= wxDataViewItem();
1345 } /* wxDataViewCtrl::HitTest(wxPoint const&, wxDataViewItem&, wxDataViewColumn*&) const */
1347 bool wxDataViewCtrl::IsSelected(wxDataViewItem
const& item
) const
1349 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1352 return MacDataViewListCtrlPtr
->IsItemSelected(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
1353 } /* wxDataViewCtrl::IsSelected(wxDataViewItem const&) const */
1355 void wxDataViewCtrl::SelectAll(void)
1357 DataBrowserItemID
* itemIDPtr
;
1359 Handle
handle(::NewHandle(0));
1363 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1366 wxCHECK_RET(MacDataViewListCtrlPtr
->GetItems(kDataBrowserNoItem
,true,kDataBrowserItemAnyState
,handle
) == noErr
,_("Could not get items."));
1367 NoOfItems
= static_cast<size_t>(::GetHandleSize(handle
)/sizeof(DataBrowserItemID
));
1369 itemIDPtr
= (DataBrowserItemID
*) (*handle
);
1370 MacDataViewListCtrlPtr
->SetSelectedItems(NoOfItems
,itemIDPtr
,kDataBrowserItemsAssign
);
1372 DisposeHandle(handle
);
1373 } /* wxDataViewCtrl::SelectAll(void) */
1375 void wxDataViewCtrl::Select(wxDataViewItem
const& item
)
1379 // variable definition and initialization:
1380 DataBrowserItemID
itemID(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
1381 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1383 MacDataViewListCtrlPtr
->SetSelectedItems(1,&itemID
,kDataBrowserItemsAdd
);
1385 } /* wxDataViewCtrl::Select(wxDataViewItem const&) */
1387 void wxDataViewCtrl::SetSelections(wxDataViewItemArray
const& sel
)
1389 size_t const NoOfSelections
= sel
.GetCount();
1391 DataBrowserItemID
* itemIDs
;
1393 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1396 itemIDs
= new DataBrowserItemID
[NoOfSelections
];
1397 for (size_t i
=0; i
<NoOfSelections
; ++i
)
1398 itemIDs
[i
] = reinterpret_cast<DataBrowserItemID
>(sel
[i
].GetID());
1399 MacDataViewListCtrlPtr
->SetSelectedItems(NoOfSelections
,itemIDs
,kDataBrowserItemsAssign
);
1401 } /* wxDataViewCtrl::SetSelections(wxDataViewItemArray const&) */
1403 void wxDataViewCtrl::Unselect(wxDataViewItem
const& item
)
1407 // variable definition and initialization:
1408 DataBrowserItemID
itemID(reinterpret_cast<DataBrowserItemID
>(item
.GetID()));
1409 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1411 MacDataViewListCtrlPtr
->SetSelectedItems(1,&itemID
,kDataBrowserItemsRemove
);
1413 } /* wxDataViewCtrl::Unselect(wxDataViewItem const&) */
1415 void wxDataViewCtrl::UnselectAll(void)
1417 DataBrowserItemID
* itemIDPtr
;
1419 Handle
handle(::NewHandle(0));
1423 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1426 wxCHECK_RET(MacDataViewListCtrlPtr
->GetItems(kDataBrowserNoItem
,true,kDataBrowserItemAnyState
,handle
) == noErr
,_("Could not get items."));
1427 NoOfItems
= static_cast<size_t>(::GetHandleSize(handle
)/sizeof(DataBrowserItemID
));
1429 itemIDPtr
= (DataBrowserItemID
*) (*handle
);
1430 MacDataViewListCtrlPtr
->SetSelectedItems(NoOfItems
,itemIDPtr
,kDataBrowserItemsRemove
);
1432 DisposeHandle(handle
);
1433 } /* wxDataViewCtrl::UnselectAll(void) */
1436 void wxDataViewCtrl::AddChildrenLevel(wxDataViewItem
const& parentItem
)
1440 wxDataViewItemArray items
;
1443 wxCHECK_RET(this->GetModel() != NULL
,_("Model pointer not initialized."));
1444 NoOfChildren
= this->GetModel()->GetChildren(parentItem
,items
);
1446 for (int i
=0; i
<NoOfChildren
; ++i
)
1447 (void) this->GetModel()->ItemAdded(parentItem
,items
[i
]);
1449 (void) this->GetModel()->ItemsAdded(parentItem
,items
);
1451 } /* wxDataViewCtrl::AddChildrenLevel(wxDataViewItem const&) */
1453 void wxDataViewCtrl::FinishCustomItemEditing(void)
1455 if (this->GetCustomRendererItem().IsOk())
1457 this->GetCustomRendererPtr()->FinishEditing();
1458 this->SetCustomRendererItem(wxDataViewItem());
1459 this->SetCustomRendererPtr (NULL
);
1461 } /* wxDataViewCtrl::FinishCustomItemEditing(void) */
1463 wxDataViewColumn
* wxDataViewCtrl::GetColumnPtr(WXDataBrowserPropertyID propertyID
) const
1465 // variable definition:
1466 ColumnPointerHashMapType::const_iterator
Result(this->m_ColumnPointers
.find(propertyID
));
1468 if (Result
!= this->m_ColumnPointers
.end())
1469 return Result
->second
;
1472 } /* wxDataViewCtrl::GetColumnPtr(DataBrowserPropertyID) const */
1474 // inherited methods from wxDataViewCtrlBase
1475 void wxDataViewCtrl::DoSetExpanderColumn(void)
1477 if (this->GetExpanderColumn() != NULL
)
1479 // variable definition and initialization:
1480 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1482 (void) MacDataViewListCtrlPtr
->SetDisclosureColumn(this->GetExpanderColumn()->GetPropertyID(),false); // second parameter explicitely passed to ensure that arrow is centered
1484 } /* wxDataViewCtrl::DoSetExpanderColumn(void) */
1486 void wxDataViewCtrl::DoSetIndent(void)
1488 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1491 (void) MacDataViewListCtrlPtr
->SetIndent(static_cast<float>(this->GetIndent()));
1492 } /* wxDataViewCtrl::DoSetIndent(void) */
1495 void wxDataViewCtrl::OnSize(wxSizeEvent
& event
)
1497 unsigned int const NoOfColumns
= this->GetColumnCount();
1500 for (unsigned int i
=0; i
<NoOfColumns
; ++i
)
1502 // variable definition and initialization:
1503 wxDataViewColumn
* dataViewColumnPtr(this->GetColumn(i
));
1505 if (dataViewColumnPtr
!= NULL
)
1507 // variable definition and initialization:
1508 wxDataViewCustomRenderer
* dataViewCustomRendererPtr(dynamic_cast<wxDataViewCustomRenderer
*>(dataViewColumnPtr
->GetRenderer()));
1510 if (dataViewCustomRendererPtr
!= NULL
)
1511 dataViewCustomRendererPtr
->SetDC(NULL
); // reset DC because DC has changed
1515 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1516 ControlRef ref
= MacDataViewListCtrlPtr
->GetControlRef();
1517 if (NoOfColumns
== 1)
1519 ::SetDataBrowserHasScrollBars( ref
, false, true );
1520 ::AutoSizeDataBrowserListViewColumns( ref
);
1522 if (NoOfColumns
> 1)
1524 ::SetDataBrowserHasScrollBars( ref
, true, true );
1528 } /* wxDataViewCtrl::OnSize(wxSizeEvent&) */
1530 IMPLEMENT_DYNAMIC_CLASS(wxDataViewCtrl
,wxDataViewCtrlBase
)
1532 BEGIN_EVENT_TABLE(wxDataViewCtrl
,wxDataViewCtrlBase
)
1533 EVT_SIZE(wxDataViewCtrl::OnSize
)
1537 // !wxUSE_GENERICDATAVIEWCTRL
1540 // wxUSE_DATAVIEWCTRL