1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/carbon/datavgen.cpp
3 // Purpose: wxDataViewCtrl native mac implementation
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
13 #if wxUSE_DATAVIEWCTRL
15 #include "wx/dataview.h"
17 #if !defined(wxUSE_GENERICDATAVIEWCTRL) || (wxUSE_GENERICDATAVIEWCTRL == 0)
21 #include "wx/mac/carbon/databrow.h"
28 #include "wx/renderer.h"
30 //-----------------------------------------------------------------------------
32 //-----------------------------------------------------------------------------
34 // a list of all catchable events:
35 static EventTypeSpec
const eventList
[] =
37 {kEventClassControl
, kEventControlDraw
},
38 {kEventClassControl
, kEventControlHit
}
41 //-----------------------------------------------------------------------------
43 //-----------------------------------------------------------------------------
45 static pascal OSStatus
wxMacDataViewCtrlEventHandler(EventHandlerCallRef handler
, EventRef EventReference
, void* Data
)
47 wxDataViewCtrl
* DataViewCtrlPtr((wxDataViewCtrl
*) Data
); // the 'Data' variable always contains a pointer to the data view control that installed the handler
49 wxMacCarbonEvent
CarbonEvent(EventReference
) ;
52 switch (GetEventKind(EventReference
))
54 case kEventControlDraw
:
58 DataViewCtrlPtr
->MacSetDrawingContext(CarbonEvent
.GetParameter
<CGContextRef
>(kEventParamCGContextRef
,typeCGContextRef
));
59 status
= ::CallNextEventHandler(handler
,EventReference
);
60 DataViewCtrlPtr
->MacSetDrawingContext(NULL
);
63 case kEventControlHit
:
64 if (CarbonEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPart
,typeControlPartCode
) == kControlButtonPart
) // we only care about the header
66 ControlRef controlReference
;
67 DataBrowserPropertyID columnPropertyID
;
68 unsigned long columnIndex
;
70 wxDataViewEvent
DataViewEvent(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK
,DataViewCtrlPtr
->GetId());
72 CarbonEvent
.GetParameter(kEventParamDirectObject
,&controlReference
);
73 // determine the column that triggered the event (this is the column that is responsible for sorting the data view):
74 status
= ::GetDataBrowserSortProperty(controlReference
,&columnPropertyID
);
75 wxCHECK(status
== noErr
,status
);
76 status
= ::GetDataBrowserTableViewColumnPosition(controlReference
,columnPropertyID
,&columnIndex
);
77 if (status
== errDataBrowserPropertyNotFound
) // user clicked into part of the header that does not have a property
78 return ::CallNextEventHandler(handler
,EventReference
);
79 wxCHECK(status
== noErr
,status
);
80 // initialize wxWidget event handler:
81 DataViewEvent
.SetEventObject(DataViewCtrlPtr
);
82 DataViewEvent
.SetColumn(columnIndex
);
83 DataViewEvent
.SetDataViewColumn(DataViewCtrlPtr
->GetColumn(columnIndex
));
84 // finally sent the equivalent wxWidget event:
85 DataViewCtrlPtr
->GetEventHandler()->ProcessEvent(DataViewEvent
);
86 return ::CallNextEventHandler(handler
,EventReference
);
89 return eventNotHandledErr
;
92 return eventNotHandledErr
;
93 } /* wxMacDataViewCtrlEventHandler(EventHandlerCallRef, EventRef, void*) */
95 //-----------------------------------------------------------------------------
96 // local function pointers
97 //-----------------------------------------------------------------------------
99 DEFINE_ONE_SHOT_HANDLER_GETTER(wxMacDataViewCtrlEventHandler
)
101 // ---------------------------------------------------------
102 // wxMacDataViewListModelNotifier
103 // ---------------------------------------------------------
105 class wxMacDataViewListModelNotifier
: public wxDataViewListModelNotifier
108 wxMacDataViewListModelNotifier(wxMacDataViewDataBrowserListViewControl
* initDataViewControlPtr
) : m_dataViewControlPtr(initDataViewControlPtr
)
112 virtual bool RowAppended(void)
114 DataBrowserItemID newRowID
;
117 if ((this->m_dataViewControlPtr
->GetFreeItemID(&newRowID
) == noErr
) &&
118 this->m_dataViewControlPtr
->InsertItemIDRowPair(newRowID
,this->GetOwner()->GetRowCount()-1) &&
119 (this->m_dataViewControlPtr
->AddItem(kDataBrowserNoItem
,&newRowID
) == noErr
))
121 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->m_dataViewControlPtr
->GetPeer()));
123 // sent the equivalent wxWidget event:
124 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_MODEL_ROW_APPENDED
,dataViewCtrlPtr
->GetId()); // variable defintion
126 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
127 dataViewEvent
.SetRow(this->GetOwner()->GetRowCount()-1);
128 // sent the equivalent wxWidget event:
129 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
136 virtual bool RowChanged(unsigned int row
)
138 DataBrowserItemID itemID
;
141 if (this->m_dataViewControlPtr
->GetItemID(row
,&itemID
) == noErr
)
143 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->m_dataViewControlPtr
->GetPeer()));
145 // sent the equivalent wxWidget event:
146 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_MODEL_ROW_CHANGED
,dataViewCtrlPtr
->GetId()); // variable defintion
148 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
149 dataViewEvent
.SetRow(row
);
150 // sent the equivalent wxWidget event:
151 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
158 virtual bool RowDeleted(unsigned int row
)
160 DataBrowserItemID itemID
;
163 if (this->m_dataViewControlPtr
->GetItemID(row
,&itemID
) == noErr
)
165 // variable definition:
166 unsigned long rowIndex
;
168 wxCHECK_MSG(this->m_dataViewControlPtr
->GetRowIndex(rowIndex
,itemID
) && this->m_dataViewControlPtr
->DeleteItemIDRowPair(itemID
),false,_("Unable to delete row data."));
169 this->m_dataViewControlPtr
->RenumberItemIDRowIndicesDeletion(rowIndex
);
170 if (this->m_dataViewControlPtr
->RemoveItem(kDataBrowserNoItem
,&itemID
) == noErr
)
172 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->m_dataViewControlPtr
->GetPeer()));
174 // sent the equivalent wxWidget event:
175 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_MODEL_ROW_DELETED
,dataViewCtrlPtr
->GetId()); // variable defintion
177 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
178 dataViewEvent
.SetRow(row
);
179 // sent the equivalent wxWidget event:
180 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
190 virtual bool RowInserted(unsigned int before
)
192 DataBrowserItemID newRowID
;
195 if (this->m_dataViewControlPtr
->GetFreeItemID(&newRowID
) == noErr
)
197 this->m_dataViewControlPtr
->RenumberItemIDRowIndicesInsertion(before
);
198 if (this->m_dataViewControlPtr
->InsertItemIDRowPair(newRowID
,before
) && (this->m_dataViewControlPtr
->AddItem(kDataBrowserNoItem
,&newRowID
) == noErr
))
200 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->m_dataViewControlPtr
->GetPeer()));
202 // sent the equivalent wxWidget event:
203 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_MODEL_ROW_INSERTED
,dataViewCtrlPtr
->GetId()); // variable defintion
205 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
206 dataViewEvent
.SetRow(before
);
207 // sent the equivalent wxWidget event:
208 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
218 virtual bool RowPrepended(void)
220 DataBrowserItemID newRowID
;
223 if (this->m_dataViewControlPtr
->GetFreeItemID(&newRowID
) == noErr
)
225 this->m_dataViewControlPtr
->RenumberItemIDRowIndicesInsertion(0);
226 if (this->m_dataViewControlPtr
->InsertItemIDRowPair(newRowID
,0) && (this->m_dataViewControlPtr
->AddItem(kDataBrowserNoItem
,&newRowID
) == noErr
))
228 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->m_dataViewControlPtr
->GetPeer()));
230 // sent the equivalent wxWidget event:
231 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_MODEL_ROW_PREPENDED
,dataViewCtrlPtr
->GetId()); // variable defintion
233 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
234 dataViewEvent
.SetRow(0);
235 // sent the equivalent wxWidget event:
236 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
246 virtual bool ValueChanged(unsigned int col
, unsigned int row
)
248 DataBrowserItemID itemID
;
250 DataBrowserPropertyID propertyID
;
253 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->m_dataViewControlPtr
->GetPeer()));
255 if ((dataViewCtrlPtr
!= NULL
) && (this->m_dataViewControlPtr
->GetItemID(row
,&itemID
) == noErr
) && (this->m_dataViewControlPtr
->GetColumnID(col
,&propertyID
) == noErr
) &&
256 (this->m_dataViewControlPtr
->UpdateItems(kDataBrowserNoItem
,1,&itemID
,dataViewCtrlPtr
->GetColumn(col
)->GetPropertyID(),propertyID
) == noErr
))
258 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->m_dataViewControlPtr
->GetPeer()));
260 // sent the equivalent wxWidget event:
261 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_MODEL_VALUE_CHANGED
,dataViewCtrlPtr
->GetId()); // variable defintion
263 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
264 dataViewEvent
.SetColumn(col
);
265 dataViewEvent
.SetRow(row
);
266 // sent the equivalent wxWidget event:
267 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
274 virtual bool RowsReordered(unsigned int* new_order
)
276 DataBrowserPropertyID propertyId
;
279 if ((new_order
!= NULL
) && (this->m_dataViewControlPtr
->GetSortProperty(&propertyId
) == noErr
) && (propertyId
>= kMinPropertyID
))
281 DataBrowserSortOrder sortOrder
;
282 unsigned long column
;
284 if ((this->m_dataViewControlPtr
->GetSortOrder(&sortOrder
) == noErr
) && (this->m_dataViewControlPtr
->GetPropertyColumn(propertyId
,&column
) == noErr
))
286 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->m_dataViewControlPtr
->GetPeer()));
288 if (dataViewCtrlPtr
->GetColumn(column
)->IsSortOrderAscending())
289 this->m_dataViewControlPtr
->RenumberItemIDRowIndices(new_order
);
290 else // the sort order of the control is descending but the passed sort order is always ordered top - down
294 if (this->m_dataViewControlPtr
->GetItemCount(&itemCount
) != noErr
)
296 unsigned int* reversedOrder(new unsigned int[itemCount
]);
298 for (ItemCount i
=0; i
<itemCount
; ++i
)
299 reversedOrder
[i
] = itemCount
-new_order
[i
];
300 this->m_dataViewControlPtr
->RenumberItemIDRowIndices(reversedOrder
);
301 delete[] reversedOrder
;
303 if (this->m_dataViewControlPtr
->UpdateItems())
305 // sent the equivalent wxWidget event:
306 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_MODEL_ROWS_REORDERED
,dataViewCtrlPtr
->GetId()); // variable defintion
308 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
309 // sent the equivalent wxWidget event:
310 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
323 virtual bool Cleared(void)
325 this->m_dataViewControlPtr
->ClearItemIDRowPairs();
326 if (this->m_dataViewControlPtr
->RemoveItems() == noErr
)
328 wxDataViewCtrl
* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl
*>(this->m_dataViewControlPtr
->GetPeer()));
330 // sent the equivalent wxWidget event:
331 wxDataViewEvent
dataViewEvent(wxEVT_COMMAND_DATAVIEW_MODEL_CLEARED
,dataViewCtrlPtr
->GetId()); // variable defintion
333 dataViewEvent
.SetEventObject(dataViewCtrlPtr
);
334 // sent the equivalent wxWidget event:
335 dataViewCtrlPtr
->GetEventHandler()->ProcessEvent(dataViewEvent
);
348 wxMacDataViewDataBrowserListViewControl
* m_dataViewControlPtr
;
351 // ---------------------------------------------------------
352 // wxDataViewRenderer
353 // ---------------------------------------------------------
355 wxDataViewRenderer::wxDataViewRenderer(wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
356 :wxDataViewRendererBase(varianttype
,mode
,align
), m_alignment(align
), m_mode(mode
)
358 } /* wxDataViewRenderer::wxDataViewRenderer(wxString const&, wxDataViewCellMode) */
360 void wxDataViewRenderer::SetMode(wxDataViewCellMode mode
)
362 wxDataViewColumn
* dataViewColumnPtr
;
366 dataViewColumnPtr
= this->GetOwner();
367 if (dataViewColumnPtr
!= NULL
)
369 // variable definition and initialization:
370 wxDataViewCtrl
* dataViewCtrlPtr(dataViewColumnPtr
->GetOwner());
372 if (dataViewCtrlPtr
!= NULL
)
374 // variable definition and initialization:
375 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
377 if (macDataViewListCtrlPtr
!= NULL
)
379 // variable definition and initialization:
380 DataBrowserPropertyFlags flags
;
382 verify_noerr(macDataViewListCtrlPtr
->GetPropertyFlags(dataViewColumnPtr
->GetPropertyID(),&flags
));
383 if (mode
== wxDATAVIEW_CELL_EDITABLE
)
384 flags
|= kDataBrowserPropertyIsEditable
;
386 flags
&= ~kDataBrowserPropertyIsEditable
;
387 verify_noerr(macDataViewListCtrlPtr
->SetPropertyFlags(dataViewColumnPtr
->GetPropertyID(),flags
));
391 } /* wxDataViewRenderer::SetMode(wxDataViewCellMode) */
393 IMPLEMENT_ABSTRACT_CLASS(wxDataViewRenderer
,wxDataViewRendererBase
)
395 // ---------------------------------------------------------
396 // wxDataViewCustomRenderer
397 // ---------------------------------------------------------
399 wxDataViewCustomRenderer::wxDataViewCustomRenderer(wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
400 :wxDataViewRenderer(varianttype
,mode
,align
), m_editorCtrlPtr(NULL
)
402 } /* wxDataViewCustomRenderer::wxDataViewCustomRenderer(wxString const&, wxDataViewCellMode) */
404 wxDataViewCustomRenderer::~wxDataViewCustomRenderer(void)
406 if (this->m_DCPtr
!= NULL
)
407 delete this->m_DCPtr
;
408 } /* wxDataViewCustomRenderer::~wxDataViewCustomRenderer(void) */
410 wxDC
* wxDataViewCustomRenderer::GetDC(void)
412 if (this->m_DCPtr
== NULL
)
414 if ((GetOwner() == NULL
) || (GetOwner()->GetOwner() == NULL
))
416 this->m_DCPtr
= new wxClientDC(this->GetOwner()->GetOwner());
418 return this->m_DCPtr
;
419 } /* wxDataViewCustomRenderer::GetDC(void) */
421 bool wxDataViewCustomRenderer::Render(void)
424 } /* wxDataViewCustomRenderer::Render(void) */
426 void wxDataViewCustomRenderer::SetDC(wxDC
* newDCPtr
)
428 delete this->m_DCPtr
;
429 this->m_DCPtr
= newDCPtr
;
430 } /* wxDataViewCustomRenderer::SetDC(wxDC*) */
433 IMPLEMENT_ABSTRACT_CLASS(wxDataViewCustomRenderer
, wxDataViewRenderer
)
435 // ---------------------------------------------------------
436 // wxDataViewTextRenderer
437 // ---------------------------------------------------------
439 wxDataViewTextRenderer::wxDataViewTextRenderer(wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
440 :wxDataViewRenderer(varianttype
,mode
,align
)
442 } /* wxDataViewTextRenderer::wxDataViewTextRenderer(wxString const&, wxDataViewCellMode, int) */
444 bool wxDataViewTextRenderer::Render(void)
446 if (this->GetValue().GetType() == this->GetVariantType())
448 // variable definition:
449 wxMacCFStringHolder
cfString(this->GetValue().GetString(),(this->GetView()->GetFont().Ok() ? this->GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
451 return (::SetDataBrowserItemDataText(this->GetDataReference(),cfString
) == noErr
);
455 } /* wxDataViewTextRenderer::Render(void) */
457 IMPLEMENT_CLASS(wxDataViewTextRenderer
,wxDataViewRenderer
)
459 // ---------------------------------------------------------
460 // wxDataViewBitmapRenderer
461 // ---------------------------------------------------------
463 wxDataViewBitmapRenderer::wxDataViewBitmapRenderer(wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
464 :wxDataViewRenderer(varianttype
,mode
,align
)
468 bool wxDataViewBitmapRenderer::Render(void)
470 if (this->GetValue().GetType() == this->GetVariantType())
474 bitmap
<< this->GetValue();
476 return (::SetDataBrowserItemDataIcon(this->GetDataReference(),bitmap
.GetBitmapData()->GetIconRef()) == noErr
);
482 } /* wxDataViewBitmapRenderer::Render(void) */
484 IMPLEMENT_CLASS(wxDataViewBitmapRenderer
,wxDataViewRenderer
)
486 // ---------------------------------------------------------
487 // wxDataViewToggleRenderer
488 // ---------------------------------------------------------
490 wxDataViewToggleRenderer::wxDataViewToggleRenderer(wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
491 :wxDataViewRenderer(varianttype
,mode
)
495 bool wxDataViewToggleRenderer::Render(void)
497 if (this->GetValue().GetType() == this->GetVariantType())
498 return (::SetDataBrowserItemDataButtonValue(this->GetDataReference(),this->GetValue().GetBool()) == noErr
);
501 } /* wxDataViewToggleRenderer::Render(void) */
503 IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleRenderer
,wxDataViewRenderer
)
505 // ---------------------------------------------------------
506 // wxDataViewProgressRenderer
507 // ---------------------------------------------------------
509 wxDataViewProgressRenderer::wxDataViewProgressRenderer(wxString
const& label
, wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
510 :wxDataViewRenderer(varianttype
,mode
,align
)
514 bool wxDataViewProgressRenderer::Render(void)
516 if (this->GetValue().GetType() == this->GetVariantType())
517 return ((::SetDataBrowserItemDataMinimum(this->GetDataReference(), 0) == noErr
) &&
518 (::SetDataBrowserItemDataMaximum(this->GetDataReference(),100) == noErr
) &&
519 (::SetDataBrowserItemDataValue (this->GetDataReference(),this->GetValue().GetLong()) == noErr
));
522 } /* wxDataViewProgressRenderer::Render(void) */
524 IMPLEMENT_ABSTRACT_CLASS(wxDataViewProgressRenderer
,wxDataViewRenderer
)
526 // ---------------------------------------------------------
527 // wxDataViewDateRenderer
528 // ---------------------------------------------------------
530 wxDataViewDateRenderer::wxDataViewDateRenderer(wxString
const& varianttype
, wxDataViewCellMode mode
, int align
)
531 :wxDataViewRenderer(varianttype
,mode
,align
)
535 bool wxDataViewDateRenderer::Render(void)
537 if (this->GetValue().GetType() == this->GetVariantType())
538 return (::SetDataBrowserItemDataDateTime(this->GetDataReference(),this->GetValue().GetDateTime().Subtract(wxDateTime(1,wxDateTime::Jan
,1904)).GetSeconds().GetLo()) == noErr
);
541 } /* wxDataViewDateRenderer::Render(void) */
543 IMPLEMENT_ABSTRACT_CLASS(wxDataViewDateRenderer
,wxDataViewRenderer
)
545 // ---------------------------------------------------------
547 // ---------------------------------------------------------
549 wxDataViewColumn::wxDataViewColumn(wxString
const &title
, wxDataViewRenderer
*cell
, unsigned int model_column
, int width
, wxAlignment align
, int flags
)
550 :wxDataViewColumnBase(title
,cell
,model_column
,width
,wxALIGN_CENTER
,flags
), m_alignment(align
), m_ascending(true),
551 m_flags(flags
& ~(wxDATAVIEW_COL_HIDDEN
| wxDATAVIEW_COL_RESIZABLE
)), m_minWidth(0), m_maxWidth(std::numeric_limits
<int>::max()), m_width(width
), m_title(title
)
553 } /* wxDataViewColumn::wxDataViewColumn(wxString const &title, wxDataViewRenderer*, unsigned int, int, wxAlignment, int) */
555 wxDataViewColumn::wxDataViewColumn(wxBitmap
const& bitmap
, wxDataViewRenderer
*cell
, unsigned int model_column
, int width
, wxAlignment align
, int flags
)
556 :wxDataViewColumnBase(bitmap
,cell
,model_column
,width
,wxALIGN_CENTER
,flags
), m_ascending(true), m_alignment(align
),
557 m_flags(flags
& (wxDATAVIEW_COL_HIDDEN
| wxDATAVIEW_COL_RESIZABLE
)), m_minWidth(0), m_maxWidth(std::numeric_limits
<int>::max()), m_width(width
)
559 } /* wxDataViewColumn::wxDataViewColumn(wxBitmap const&, wxDataViewRenderer*, unsigned int, int, wxAlignment, int) */
561 void wxDataViewColumn::SetAlignment(wxAlignment align
)
563 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
566 this->m_alignment
= align
;
567 if (dataViewCtrlPtr
!= NULL
)
569 // variable definition and initialization:
570 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
572 if (macDataViewListCtrlPtr
!= NULL
)
574 // variable definition and initialization:
575 DataBrowserListViewHeaderDesc headerDescription
;
577 wxCHECK_RET(macDataViewListCtrlPtr
->GetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not get header description."));
581 case wxALIGN_CENTER_HORIZONTAL
:
582 headerDescription
.btnFontStyle
.just
= teCenter
;
585 headerDescription
.btnFontStyle
.just
= teFlushLeft
;
588 headerDescription
.btnFontStyle
.just
= teFlushRight
;
591 headerDescription
.btnFontStyle
.just
= teFlushDefault
;
593 wxCHECK_RET(macDataViewListCtrlPtr
->SetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not set alignment."));
596 } /* wxDataViewColumn::SetAlignment(wxAlignment) */
598 void wxDataViewColumn::SetBitmap(wxBitmap
const& bitmap
)
600 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
603 wxDataViewColumnBase::SetBitmap(bitmap
);
604 if (dataViewCtrlPtr
!= NULL
)
606 // variable definition and initialization:
607 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
609 if (macDataViewListCtrlPtr
!= NULL
)
611 // variable definition and initialization:
612 DataBrowserListViewHeaderDesc headerDescription
;
614 wxCHECK_RET(macDataViewListCtrlPtr
->GetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not get header description."));
615 if (this->GetBitmap().Ok())
616 headerDescription
.btnContentInfo
.u
.iconRef
= this->GetBitmap().GetBitmapData()->GetIconRef();
618 headerDescription
.btnContentInfo
.u
.iconRef
= NULL
;
619 wxCHECK_RET(macDataViewListCtrlPtr
->SetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not set icon."));
622 } /* wxDataViewColumn::SetBitmap(wxBitmap const&) */
624 void wxDataViewColumn::SetFlags(int flags
)
626 this->SetHidden ((flags
& wxDATAVIEW_COL_HIDDEN
) != 0);
627 this->SetResizeable((flags
& wxDATAVIEW_COL_RESIZABLE
) != 0);
628 this->SetSortable ((flags
& wxDATAVIEW_COL_SORTABLE
) != 0);
629 } /* wxDataViewColumn::SetFlags(int) */
631 void wxDataViewColumn::SetMaxWidth(int maxWidth
)
633 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
636 this->m_maxWidth
= maxWidth
;
637 if (dataViewCtrlPtr
!= NULL
)
639 // variable definition and initialization:
640 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
642 if (macDataViewListCtrlPtr
!= NULL
)
644 // variable definition and initialization:
645 DataBrowserListViewHeaderDesc headerDescription
;
647 wxCHECK_RET(macDataViewListCtrlPtr
->GetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not get header description."));
648 headerDescription
.maximumWidth
= static_cast<UInt16
>(maxWidth
);
649 wxCHECK_RET(macDataViewListCtrlPtr
->SetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not set maximum width."));
652 } /* wxDataViewColumn::SetMaxWidth(int) */
654 void wxDataViewColumn::SetMinWidth(int minWidth
)
656 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
659 this->m_minWidth
= minWidth
;
660 if (dataViewCtrlPtr
!= NULL
)
662 // variable definition and initialization:
663 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
665 if (macDataViewListCtrlPtr
!= NULL
)
667 // variable definition and initialization:
668 DataBrowserListViewHeaderDesc headerDescription
;
670 wxCHECK_RET(macDataViewListCtrlPtr
->GetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not get header description."));
671 headerDescription
.minimumWidth
= static_cast<UInt16
>(minWidth
);
672 wxCHECK_RET(macDataViewListCtrlPtr
->SetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not set minimum width."));
675 } /* wxDataViewColumn::SetMaxWidth(int) */
677 void wxDataViewColumn::SetResizeable(bool WXUNUSED(resizeable
))
679 } /* wxDataViewColumn::SetResizeable(bool) */
681 void wxDataViewColumn::SetSortable(bool sortable
)
683 // variable definition and initialization:
684 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
686 if (dataViewCtrlPtr
!= NULL
)
688 // variable definition and initialization:
689 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
691 if (macDataViewListCtrlPtr
!= NULL
)
693 // variable definition and initialization:
694 DataBrowserPropertyFlags flags
;
696 wxCHECK_RET(macDataViewListCtrlPtr
->GetPropertyFlags(this->GetPropertyID(),&flags
) == noErr
,_("Could not get property flags."));
699 this->m_flags
|= wxDATAVIEW_COL_SORTABLE
;
700 flags
|= kDataBrowserListViewSortableColumn
;
704 this->m_flags
&= ~wxDATAVIEW_COL_SORTABLE
;
705 flags
&= ~kDataBrowserPropertyIsEditable
;
707 wxCHECK_RET(macDataViewListCtrlPtr
->SetPropertyFlags(this->GetPropertyID(),flags
) == noErr
,_("Could not set property flags."));
710 } /* wxDataViewColumn::SetSortable(bool) */
712 void wxDataViewColumn::SetSortOrder(bool ascending
)
714 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
717 this->m_ascending
= ascending
;
718 if (dataViewCtrlPtr
!= NULL
)
720 // variable definition and initialization:
721 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
723 if (macDataViewListCtrlPtr
!= NULL
)
725 // variable definition and initialization:
726 DataBrowserListViewHeaderDesc headerDescription
;
728 verify_noerr(macDataViewListCtrlPtr
->GetHeaderDesc(this->GetPropertyID(),&headerDescription
));
730 headerDescription
.initialOrder
= kDataBrowserOrderIncreasing
;
732 headerDescription
.initialOrder
= kDataBrowserOrderDecreasing
;
733 verify_noerr(macDataViewListCtrlPtr
->SetHeaderDesc(this->GetPropertyID(),&headerDescription
));
736 } /* wxDataViewColumn::SetSortOrder(bool) */
738 void wxDataViewColumn::SetTitle(wxString
const& title
)
740 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
743 this->m_title
= title
;
744 if (dataViewCtrlPtr
!= NULL
)
746 // variable definition and initialization:
747 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
749 if (macDataViewListCtrlPtr
!= NULL
)
751 // variable definition and initialization:
752 DataBrowserListViewHeaderDesc headerDescription
;
753 wxMacCFStringHolder
cfTitle(title
,(dataViewCtrlPtr
->GetFont().Ok() ? dataViewCtrlPtr
->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
755 wxCHECK_RET(macDataViewListCtrlPtr
->GetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not get header description."));
756 headerDescription
.titleString
= cfTitle
;
757 wxCHECK_RET(macDataViewListCtrlPtr
->SetHeaderDesc(this->GetPropertyID(),&headerDescription
) == noErr
,_("Could not set header description."));
760 } /* wxDataViewColumn::SetTitle(wxString const&) */
762 void wxDataViewColumn::SetWidth(int width
)
764 wxDataViewCtrl
* dataViewCtrlPtr(this->GetOwner());
767 if ((width
>= this->m_minWidth
) && (width
<= this->m_maxWidth
))
769 this->m_width
= width
;
770 if (dataViewCtrlPtr
!= NULL
)
772 // variable definition and initialization:
773 wxMacDataViewDataBrowserListViewControlPointer
macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(dataViewCtrlPtr
->GetPeer()));
775 if (macDataViewListCtrlPtr
!= NULL
)
776 wxCHECK_RET(macDataViewListCtrlPtr
->SetColumnWidth(this->GetPropertyID(),static_cast<UInt16
>(width
)) == noErr
,_("Could not set column width."));
779 } /* wxDataViewColumn::SetWidth(int) */
781 IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumn
,wxDataViewColumnBase
)
783 //-----------------------------------------------------------------------------
785 //-----------------------------------------------------------------------------
787 void wxDataViewCtrl::Init(void)
789 this->m_macIsUserPane
= false;
790 this->m_NotifierPtr
= NULL
;
791 this->m_cgContext
= NULL
;
792 } /* wxDataViewCtrl::Init(void) */
794 bool wxDataViewCtrl::Create(wxWindow
*parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
, const wxValidator
& validator
)
796 if (!(this->wxControl::Create(parent
,id
,pos
,size
,(style
| wxSUNKEN_BORDER
) & ~(wxHSCROLL
| wxVSCROLL
),validator
)))
800 MacSetClipChildren(true) ;
803 this->m_peer
= new wxMacDataViewDataBrowserListViewControl(this,pos
,size
,style
);
804 this->MacPostControlCreate(pos
,size
);
806 InstallControlEventHandler(this->m_peer
->GetControlRef(),GetwxMacDataViewCtrlEventHandlerUPP(),GetEventTypeCount(eventList
),eventList
,this,NULL
);
809 } /* wxDataViewCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator) */
811 void wxDataViewCtrl::OnSize(wxSizeEvent
& event
)
813 unsigned int const NoOfColumns
= this->GetColumnCount();
816 for (unsigned int i
=0; i
<NoOfColumns
; ++i
)
818 // variable definition and initialization:
819 wxDataViewColumn
* dataViewColumnPtr(this->GetColumn(i
));
821 if (dataViewColumnPtr
!= NULL
)
823 // variable definition and initialization:
824 wxDataViewCustomRenderer
* dataViewCustomRendererPtr(dynamic_cast<wxDataViewCustomRenderer
*>(dataViewColumnPtr
->GetRenderer()));
826 if (dataViewCustomRendererPtr
!= NULL
)
827 dataViewCustomRendererPtr
->SetDC(NULL
); // reset DC because DC has changed
831 } /* wxDataViewCtrl::OnSize(wxSizeEvent&) */
833 bool wxDataViewCtrl::AssociateModel(wxDataViewListModel
*model
)
835 if (!wxDataViewCtrlBase::AssociateModel(model
))
838 this->m_NotifierPtr
= new wxMacDataViewListModelNotifier(dynamic_cast<wxMacDataViewDataBrowserListViewControl
*>(this->m_peer
));
839 model
->AddNotifier(this->m_NotifierPtr
);
844 bool wxDataViewCtrl::AppendColumn(wxDataViewColumn
* dataViewColumnPtr
)
846 wxCHECK_MSG(dataViewColumnPtr
!= NULL
, false,_("Column pointer must not be NULL."));
847 wxCHECK_MSG(dataViewColumnPtr
->GetRenderer() != NULL
,false,_("Column does not have a renderer."));
848 if (this->wxDataViewCtrlBase::AppendColumn(dataViewColumnPtr
))
850 // variable definition:
851 DataBrowserPropertyID FreeID
;
852 DataBrowserListViewColumnDesc columnDescription
;
853 wxMacCFStringHolder
cfTitle(dataViewColumnPtr
->GetTitle(),(this->m_font
.Ok() ? this->m_font
.GetEncoding() : wxLocale::GetSystemEncoding()));
854 wxMacDataViewDataBrowserListViewControlPointer
MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
856 // initialize column description:
857 wxCHECK_MSG (MacDataViewListCtrlPtr
!= NULL
,false,_("m_peer is not or incorrectly initialized"));
858 verify_noerr(MacDataViewListCtrlPtr
->GetFreePropertyID(&FreeID
));
859 dataViewColumnPtr
->SetPropertyID(FreeID
);
860 columnDescription
.propertyDesc
.propertyID
= FreeID
;
861 columnDescription
.propertyDesc
.propertyType
= dataViewColumnPtr
->GetRenderer()->GetPropertyType();
862 columnDescription
.propertyDesc
.propertyFlags
= kDataBrowserListViewSelectionColumn
;
863 if (dataViewColumnPtr
->IsSortable())
864 columnDescription
.propertyDesc
.propertyFlags
|= kDataBrowserListViewSortableColumn
;
865 if (dataViewColumnPtr
->IsResizeable())
866 columnDescription
.propertyDesc
.propertyFlags
|= kDataBrowserListViewMovableColumn
;
867 if (dataViewColumnPtr
->GetRenderer()->GetMode() == wxDATAVIEW_CELL_EDITABLE
)
868 columnDescription
.propertyDesc
.propertyFlags
|= kDataBrowserPropertyIsEditable
;
869 #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
870 if ((columnDescription
.propertyDesc
.propertyType
== kDataBrowserTextType
) ||
871 (columnDescription
.propertyDesc
.propertyType
== kDataBrowserIconAndTextType
) ||
872 (columnDescription
.propertyDesc
.propertyType
== kDataBrowserDateTimeType
))
873 columnDescription
.propertyDesc
.propertyFlags
|= kDataBrowserListViewTypeSelectColumn
;
875 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
876 columnDescription
.propertyDesc
.propertyFlags
|= kDataBrowserListViewNoGapForIconInHeaderButton
;
878 columnDescription
.headerBtnDesc
.version
= kDataBrowserListViewLatestHeaderDesc
;
879 columnDescription
.headerBtnDesc
.minimumWidth
= 0;
880 columnDescription
.headerBtnDesc
.maximumWidth
= 30000;
881 columnDescription
.headerBtnDesc
.titleOffset
= 0;
882 columnDescription
.headerBtnDesc
.titleString
= cfTitle
; // we cannot directly use the wxMacCFStringHolder constructor call because then the CFStringRef is released
883 // having called 'AddColumn' where the title (CFStringRef) is going to be used
884 columnDescription
.headerBtnDesc
.initialOrder
= kDataBrowserOrderIncreasing
;
885 columnDescription
.headerBtnDesc
.btnFontStyle
.flags
= kControlUseFontMask
| kControlUseJustMask
;
886 switch (dataViewColumnPtr
->GetAlignment())
889 case wxALIGN_CENTER_HORIZONTAL
:
890 columnDescription
.headerBtnDesc
.btnFontStyle
.just
= teCenter
;
893 columnDescription
.headerBtnDesc
.btnFontStyle
.just
= teFlushLeft
;
896 columnDescription
.headerBtnDesc
.btnFontStyle
.just
= teFlushRight
;
899 columnDescription
.headerBtnDesc
.btnFontStyle
.just
= teFlushDefault
;
901 columnDescription
.headerBtnDesc
.btnFontStyle
.font
= kControlFontViewSystemFont
;
902 columnDescription
.headerBtnDesc
.btnFontStyle
.style
= normal
;
903 columnDescription
.headerBtnDesc
.btnContentInfo
.contentType
= kControlContentIconRef
;
904 if (dataViewColumnPtr
->GetBitmap().Ok())
905 columnDescription
.headerBtnDesc
.btnContentInfo
.u
.iconRef
= dataViewColumnPtr
->GetBitmap().GetBitmapData()->GetIconRef();
907 verify_noerr(MacDataViewListCtrlPtr
->AddColumn(&columnDescription
,kDataBrowserListViewAppendColumn
));
908 // final adjustments for the layout:
909 if (dataViewColumnPtr
->GetWidth() <= 0)
911 // variable definition:
912 UInt16 defaultColumnWidth
;
914 MacDataViewListCtrlPtr
->GetDefaultColumnWidth(&defaultColumnWidth
);
915 dataViewColumnPtr
->SetWidth(defaultColumnWidth
);
917 verify_noerr(MacDataViewListCtrlPtr
->SetColumnWidth(dataViewColumnPtr
->GetPropertyID(),dataViewColumnPtr
->GetWidth()));
918 if (dataViewColumnPtr
->IsSortable()) // if the current column is sortable and there is no active sortable column yet, the new column will become active
920 // variable definition:
921 DataBrowserPropertyID sortedProperty
;
923 if ((MacDataViewListCtrlPtr
->GetSortProperty(&sortedProperty
) == noErr
) && (sortedProperty
< kMinPropertyID
))
924 MacDataViewListCtrlPtr
->SetSortProperty(dataViewColumnPtr
->GetPropertyID());
927 // now, make sure that data is shown in the newly appended column:
928 if ((this->GetModel() != NULL
) && (this->m_NotifierPtr
!= NULL
) && (dataViewColumnPtr
->GetModelColumn() >= 0) && (dataViewColumnPtr
->GetModelColumn() < this->GetModel()->GetColumnCount()))
929 if (this->GetColumnCount() == 1) // the newly appended column is the only one and this means that no data has been inserted yet, so do it now:
931 // variable definition:
932 DataBrowserItemID newID
;
934 for (size_t i
=0; i
<this->GetModel()->GetRowCount(); ++i
)
935 if (!((MacDataViewListCtrlPtr
->GetFreeItemID(&newID
) == noErr
) && MacDataViewListCtrlPtr
->InsertItemIDRowPair(newID
,i
) && (MacDataViewListCtrlPtr
->AddItem(kDataBrowserNoItem
,&newID
) == noErr
)))
939 for (size_t i
=0; i
<this->GetModel()->GetRowCount(); ++i
)
940 (void) this->m_NotifierPtr
->ValueChanged(dataViewColumnPtr
->GetModelColumn(),i
);
946 } /* wxDataViewCtrl::AppendColumn(wxDataViewColumn*) */
948 int wxDataViewCtrl::GetSelection(void) const
950 wxArrayInt selectedRows
;
953 if (this->GetSelections(selectedRows
) > 0)
954 return selectedRows
[0];
957 } /* wxDataViewCtrl::GetSelection(void) const */
959 int wxDataViewCtrl::GetSelections(wxArrayInt
& selectedRows
) const
961 size_t NoOfSelections
;
963 wxArrayDataBrowserItemID itemIDs
;
965 wxMacDataViewDataBrowserListViewControlPointer
dataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
968 if (dataViewListCtrlPtr
== NULL
)
971 NoOfSelections
= dataViewListCtrlPtr
->GetSelectedItemIDs(itemIDs
);
972 selectedRows
.Empty();
973 selectedRows
.Alloc(NoOfSelections
);
974 for (size_t i
=0; i
<NoOfSelections
; ++i
)
976 // variable definition:
977 DataBrowserTableViewRowIndex rowIndex
;
979 wxCHECK_MSG(dataViewListCtrlPtr
->GetRowIndex(rowIndex
,itemIDs
[i
]),0,_("Could not determine row index."));
980 selectedRows
[i
] = static_cast<int>(rowIndex
);
982 return static_cast<int>(NoOfSelections
);
983 } /* wxDataViewCtrl::GetSelections(wxArrayInt&) const */
985 bool wxDataViewCtrl::IsSelected(unsigned int row
) const
987 DataBrowserItemID itemID
;
989 wxMacDataViewDataBrowserListViewControlPointer
dataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
992 return ((dataViewListCtrlPtr
!= NULL
) && (dataViewListCtrlPtr
->GetItemID(row
,&itemID
) == noErr
) && dataViewListCtrlPtr
->IsItemSelected(itemID
));
993 } /* wxDataViewCtrl::IsSelected(unsigned int row) const */
995 void wxDataViewCtrl::SetSelection(int row
)
997 wxArrayDataBrowserItemID selectedItemIDs
;
999 size_t NoOfSelections
;
1001 wxMacDataViewDataBrowserListViewControlPointer
dataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1004 wxCHECK_RET(dataViewListCtrlPtr
!= NULL
,_("Peer pointer not initialized."));
1005 if (row
== -1) // unselect all selected items
1007 NoOfSelections
= dataViewListCtrlPtr
->GetSelectedItemIDs(selectedItemIDs
);
1008 for (size_t i
=0; i
<NoOfSelections
; ++i
)
1009 (void) dataViewListCtrlPtr
->SetSelectedItems(1,&(selectedItemIDs
[i
]),kDataBrowserItemsRemove
);
1011 else if (row
>= 0) // select specified item
1013 // variable definition:
1014 DataBrowserItemID itemID
;
1016 verify_noerr(dataViewListCtrlPtr
->GetItemID(row
,&itemID
));
1017 verify_noerr(dataViewListCtrlPtr
->SetSelectedItems(1,&itemID
,kDataBrowserItemsAdd
)); // should also deselect automatically all other items
1019 } /* wxDataViewCtrl::SetSelection(int) */
1021 void wxDataViewCtrl::SetSelectionRange(unsigned int from
, unsigned int to
)
1023 wxCHECK_RET(from
<= to
,_("Invalid specified range ('from' has to be smaller or equal to 'to')."));
1025 // variable definition:
1026 wxArrayInt selectedRows
;
1028 selectedRows
.Alloc(to
-from
+1);
1029 for (unsigned int i
=from
; i
<=to
; ++i
)
1030 selectedRows
.Add(i
);
1031 this->SetSelections(selectedRows
);
1032 } /* wxDataViewCtrl::SetSelectionRange(unsigned int, unsigned int) */
1034 void wxDataViewCtrl::SetSelections(wxArrayInt
const& selectedRows
)
1036 wxMacDataViewDataBrowserListViewControlPointer
dataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1039 wxCHECK_RET(dataViewListCtrlPtr
!= NULL
,_("Peer pointer not initialized."));
1040 // unselect all selected items:
1041 this->SetSelection(-1);
1042 for (size_t i
=0; i
<selectedRows
.GetCount(); ++i
)
1044 // variable definition:
1045 DataBrowserItemID itemID
;
1047 verify_noerr(dataViewListCtrlPtr
->GetItemID(selectedRows
[i
],&itemID
));
1048 verify_noerr(dataViewListCtrlPtr
->SetSelectedItems(1,&itemID
,kDataBrowserItemsAssign
));
1050 } /* wxDataViewCtrl::SetSelections(wxArrayInt const&) */
1052 void wxDataViewCtrl::Unselect(unsigned int row
)
1054 DataBrowserItemID itemID
;
1056 wxMacDataViewDataBrowserListViewControlPointer
dataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1059 wxCHECK_RET( dataViewListCtrlPtr
!= NULL
, _("Peer pointer not initialized."));
1060 wxCHECK_RET((dataViewListCtrlPtr
->GetItemID(row
,&itemID
) == noErr
) && (dataViewListCtrlPtr
->SetSelectedItems(1,&itemID
,kDataBrowserItemsRemove
) == noErr
),_("Unselection impossible."));
1061 } /* wxDataViewCtrl::Unselect(unsigned int) */
1063 void wxDataViewCtrl::ReverseSorting(DataBrowserPropertyID columnID
)
1066 if (columnID
>= kMinPropertyID
)
1068 // variable definition and initialization:
1069 DataBrowserPropertyID sortPropertyID
;
1070 wxMacDataViewDataBrowserListViewControlPointer
dataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer
>(this->m_peer
));
1072 wxCHECK_RET(dataViewListCtrlPtr
!= NULL
,_("Peer pointer not initialized."));
1073 wxCHECK_RET(dataViewListCtrlPtr
->GetSortProperty(&sortPropertyID
) == noErr
,_("Determination of sort property impossible."));
1074 if (sortPropertyID
== columnID
)
1076 // variable defintion:
1077 DataBrowserSortOrder sortOrderCtrl
;
1078 DataBrowserTableViewColumnID columnIndex
;
1079 wxDataViewColumn
* dataViewColumnPtr
;
1081 wxCHECK_RET(dataViewListCtrlPtr
->GetPropertyColumn(columnID
,&columnIndex
) == noErr
,_("Determination of column index impossible"));
1082 wxCHECK_RET(dataViewListCtrlPtr
->GetSortOrder(&sortOrderCtrl
) == noErr
,_("Determination of sort order impossible"));
1083 dataViewColumnPtr
= this->GetColumn(columnIndex
);
1084 wxCHECK_RET(dataViewColumnPtr
!= NULL
,_("Column could not be obtained."));
1085 if ((sortOrderCtrl
== kDataBrowserOrderIncreasing
) && !(dataViewColumnPtr
->IsSortOrderAscending()) ||
1086 (sortOrderCtrl
== kDataBrowserOrderDecreasing
) && dataViewColumnPtr
->IsSortOrderAscending())
1087 dataViewListCtrlPtr
->ReverseRowIndexNumbering();
1090 } /* wxDataViewCtrl::ReverseSorting(DataBrowserPropertyID columnID) */
1092 IMPLEMENT_DYNAMIC_CLASS(wxDataViewCtrl
,wxDataViewCtrlBase
)
1094 BEGIN_EVENT_TABLE(wxDataViewCtrl
,wxDataViewCtrlBase
)
1095 EVT_SIZE(wxDataViewCtrl::OnSize
)
1099 // !wxUSE_GENERICDATAVIEWCTRL
1102 // wxUSE_DATAVIEWCTRL