#include "wx/wxprec.h"
+#if wxUSE_DATAVIEWCTRL
+
#include "wx/utils.h"
#ifndef WX_PRECOMP
return ::SetDataBrowserTableViewRowHeight(this->m_controlRef,height);
}
-OSStatus wxMacDataBrowserTableViewControl::SetHasScrollBars( bool horiz, bool vert )
+OSStatus wxMacDataBrowserTableViewControl::SetHasScrollBars(bool horiz, bool vert)
{
- return SetDataBrowserHasScrollBars(this->m_controlRef, horiz, vert );
-}
+ return ::SetDataBrowserHasScrollBars(this->m_controlRef,horiz,vert);
+} /* wxMacDataBrowserTableViewControl::SetHasScrollBars(bool, bool) */
OSStatus wxMacDataBrowserTableViewControl::SetHeaderButtonHeight(UInt16 height)
{
- return SetDataBrowserListViewHeaderBtnHeight(this->m_controlRef, height );
-}
+ return ::SetDataBrowserListViewHeaderBtnHeight(this->m_controlRef,height);
+} /* wxMacDataBrowserTableViewControl::SetHeaderButtonHeight(UInt16) */
-OSStatus wxMacDataBrowserTableViewControl::SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle )
+OSStatus wxMacDataBrowserTableViewControl::SetHiliteStyle(DataBrowserTableViewHiliteStyle hiliteStyle)
{
- return SetDataBrowserTableViewHiliteStyle(this->m_controlRef, hiliteStyle );
-}
+ return ::SetDataBrowserTableViewHiliteStyle(this->m_controlRef,hiliteStyle);
+} /*wxMacDataBrowserTableViewControl::SetHiliteStyle(DataBrowserTableViewHiliteStyle) */
+
+OSStatus wxMacDataBrowserTableViewControl::SetIndent(float Indent)
+{
+ return ::DataBrowserSetMetric(this->m_controlRef,kDataBrowserMetricDisclosureColumnPerDepthGap,true,Indent);
+} /* wxMacDataBrowserTableViewControl::SetIndent(float* Indent) */
OSStatus wxMacDataBrowserTableViewControl::SetRowHeight(DataBrowserItemID item, UInt16 height)
{
return ::GetDataBrowserTableViewColumnPosition(this->m_controlRef,propertyID,&index);
} /* wxMacDataBrowserTableViewControl::IsUsedPropertyId(DataBrowserPropertyID) const */
-OSStatus wxMacDataBrowserTableViewControl::RemoveColumn(DataBrowserTableViewColumnIndex index)
+OSStatus wxMacDataBrowserTableViewControl::RemoveColumnByProperty(DataBrowserTableViewColumnID propertyID)
+{
+ return ::RemoveDataBrowserTableViewColumn(this->m_controlRef,propertyID);
+} /* wxMacDataBrowserTableViewControl::RemoveColumnByProperty(DataBrowserTableViewColumnID) */
+
+OSStatus wxMacDataBrowserTableViewControl::RemoveColumnByIndex(DataBrowserTableViewColumnIndex index)
{
DataBrowserTableViewColumnID propertyID;
this->GetPropertyID(index,&propertyID);
return ::RemoveDataBrowserTableViewColumn(this->m_controlRef,propertyID);
-} /* wxMacDataBrowserTableViewControl::RemoveColumn(DataBrowserTableViewColumnIndex) */
+} /* wxMacDataBrowserTableViewControl::RemoveColumnByIndex(DataBrowserTableViewColumnIndex) */
OSStatus wxMacDataBrowserTableViewControl::SetColumnIndex(DataBrowserPropertyID propertyID, DataBrowserTableViewColumnIndex index)
{
return ::SetDataBrowserSortProperty(this->m_controlRef,propertyID);
}
+//
+// container handling
+//
+OSStatus wxMacDataBrowserTableViewControl::CloseContainer(DataBrowserItemID containerID)
+{
+ return ::CloseDataBrowserContainer(this->m_controlRef,containerID);
+} /* wxMacDataBrowserTableViewControl::CloseContainer(DataBrowserItemID) */
+
+OSStatus wxMacDataBrowserTableViewControl::OpenContainer(DataBrowserItemID containerID)
+{
+ return ::OpenDataBrowserContainer(this->m_controlRef,containerID);
+} /* wxMacDataBrowserTableViewControl::OpenContainer(DataBrowserItemID) */
+
IMPLEMENT_ABSTRACT_CLASS(wxMacDataBrowserTableViewControl,wxMacControl)
// ============================================================================
if (propertyID >= kMinPropertyID) // in case data columns set the data
{
// variable definitions:
- DataBrowserTableViewColumnIndex columnIndex;
- OSStatus errorStatus;
- wxVariant variant;
- wxDataViewColumn* dataViewColumnPtr;
- wxDataViewCtrl* dataViewCtrlPtr;
+ wxVariant variant;
+ wxDataViewColumn* dataViewColumnPtr;
+ wxDataViewCtrl* dataViewCtrlPtr;
dataViewCtrlPtr = dynamic_cast<wxDataViewCtrl*>(this->GetPeer());
wxCHECK_MSG(dataViewCtrlPtr != NULL,errDataBrowserNotConfigured,_("Pointer to data view control not set correctly."));
wxCHECK_MSG(dataViewCtrlPtr->GetModel() != NULL,errDataBrowserNotConfigured,_("Pointer to model not set correctly."));
- errorStatus = this->GetColumnIndex(propertyID,&columnIndex);
- wxCHECK_MSG(errorStatus == noErr,errorStatus,_("Column index does not exist."));
- dataViewColumnPtr = dataViewCtrlPtr->GetColumn(columnIndex);
+ dataViewColumnPtr = dataViewCtrlPtr->GetColumnPtr(propertyID);
wxCHECK_MSG(dataViewColumnPtr != NULL,errDataBrowserNotConfigured,_("No column for the specified column position existing."));
wxCHECK_MSG(dataViewColumnPtr->GetRenderer() != NULL,errDataBrowserNotConfigured,_("No renderer specified for column."));
dataViewCtrlPtr->GetModel()->GetValue(variant,wxDataViewItem(reinterpret_cast<void*>(itemID)),dataViewColumnPtr->GetModelColumn());
- dataViewColumnPtr->GetRenderer()->SetDataReference(itemData);
- dataViewColumnPtr->GetRenderer()->SetValue(variant);
- wxCHECK_MSG(dataViewColumnPtr->GetRenderer()->Render(),errDataBrowserNotConfigured,_("Rendering failed."));
+ if (!(variant.IsNull()))
+ {
+ dataViewColumnPtr->GetRenderer()->SetDataReference(itemData);
+ dataViewColumnPtr->GetRenderer()->SetValue(variant);
+ wxCHECK_MSG(dataViewColumnPtr->GetRenderer()->Render(),errDataBrowserNotConfigured,_("Rendering failed."));
+ } /* if */
return noErr;
} /* if */
else // react on special system requests
+ {
switch (propertyID)
{
case kDataBrowserContainerIsClosableProperty:
// opening the container is allowed if not vetoed:
return ::SetDataBrowserItemDataBooleanValue(itemData,dataViewEvent.IsAllowed());
} /* block */
- return noErr;
case kDataBrowserContainerIsOpenableProperty:
{
// variable definitions:
case kDataBrowserItemIsEditableProperty:
return ::SetDataBrowserItemDataBooleanValue(itemData,true);
} /* switch */
+ } /* if */
} /* if */
return errDataBrowserPropertyNotSupported;
} /* wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemDataRef, Boolean) */
-void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(DataBrowserItemID itemID, DataBrowserItemNotification message, DataBrowserItemDataRef WXUNUSED(itemData))
+void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(DataBrowserItemID itemID, DataBrowserItemNotification message, DataBrowserItemDataRef itemData)
{
switch (message)
{
dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
} /* block */
break;
+ case kDataBrowserEditStarted:
+ {
+ // variable definitions:
+ wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetPeer()));
+
+ if (dataViewCtrlPtr != NULL)
+ {
+ // initialize wxWidget event:
+ DataBrowserPropertyID propertyID;
+ wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED,dataViewCtrlPtr->GetId()); // variable definition
+
+ dataViewEvent.SetEventObject(dataViewCtrlPtr);
+ dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID)));
+ if (this->GetPropertyID(itemData,&propertyID) == noErr)
+ {
+ // variable definition and initialization:
+ DataBrowserTableViewColumnIndex columnIndex;
+
+ wxCHECK_RET(this->GetColumnIndex(propertyID,&columnIndex),_("Column index not found."));
+ dataViewEvent.SetColumn(columnIndex);
+ dataViewEvent.SetDataViewColumn(dataViewCtrlPtr->GetColumnPtr(propertyID));
+ } /* if */
+ // finally send the equivalent wxWidget event:
+ dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
+ } /* if */
+ } /* block */
+ break;
+ case kDataBrowserEditStopped:
+ {
+ // variable definitions:
+ wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetPeer()));
+
+ if (dataViewCtrlPtr != NULL)
+ {
+ // initialize wxWidget event:
+ DataBrowserPropertyID propertyID;
+ wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE,dataViewCtrlPtr->GetId()); // variable definition
+
+ dataViewEvent.SetEventObject(dataViewCtrlPtr);
+ dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID)));
+ if (this->GetPropertyID(itemData,&propertyID) == noErr)
+ {
+ // variable definition and initialization:
+ DataBrowserTableViewColumnIndex columnIndex;
+
+ wxCHECK_RET(this->GetColumnIndex(propertyID,&columnIndex),_("Column index not found."));
+ dataViewEvent.SetColumn(columnIndex);
+ dataViewEvent.SetDataViewColumn(dataViewCtrlPtr->GetColumnPtr(propertyID));
+ } /* if */
+ // finally send the equivalent wxWidget event:
+ dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
+ } /* if */
+ } /* block */
+ break;
case kDataBrowserItemAdded:
{
// variable definitions:
dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
} /* block */
break;
+ case kDataBrowserItemDeselected:
+ break; // not implemented by wxWidgets; see kDataBrowserSelectionSetChanged
case kDataBrowserItemDoubleClicked:
{
// variable definitions:
} /* block */
break;
case kDataBrowserItemSelected:
+ break; // not implemented by wxWidgets; see kDataBrowserSelectionSetChanged
+ case kDataBrowserSelectionSetChanged:
{
// variable definitions:
wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetPeer()));
wxCHECK_RET(dataViewCtrlPtr != NULL,_("Pointer to data view control not set correctly."));
// initialize wxWidget event:
- wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_SELECTED,dataViewCtrlPtr->GetId()); // variable definition
+ wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED,dataViewCtrlPtr->GetId()); // variable definition
dataViewEvent.SetEventObject(dataViewCtrlPtr);
- dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID)));
+ dataViewEvent.SetModel (dataViewCtrlPtr->GetModel());
// finally send the equivalent wxWidget event:
dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
} /* block */
break;
case kDataBrowserUserStateChanged:
{
+ // variable definitions and initialization:
DataBrowserPropertyID propertyID;
-
+ wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetPeer()));
+
+ wxCHECK_RET(dataViewCtrlPtr != NULL,_("Pointer to data view control not set correctly"));
+ // update column widths:
+ for (size_t i=0; i<dataViewCtrlPtr->GetColumnCount(); ++i)
+ {
+ // constant definition for abbreviational purposes:
+ wxDataViewColumn* const columnPtr = dataViewCtrlPtr->GetColumn(i);
+ // variable definition:
+ UInt16 columnWidth;
+
+ wxCHECK_RET(this->GetColumnWidth(columnPtr->GetPropertyID(),&columnWidth) == noErr,_("Column width could not be determined"));
+ columnPtr->SetWidthVariable(columnWidth);
+ } /* for */
+ // update order status:
if ((this->GetSortProperty(&propertyID) == noErr) && (propertyID >= kMinPropertyID))
{
DataBrowserSortOrder sortOrder;
{
// variable definition and initialization:
wxDataViewColumn* columnPtr;
- wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetPeer()));
-
- wxCHECK_RET(dataViewCtrlPtr != NULL,_("Pointer to data vie wcontrol not set correctly."));
columnPtr = dataViewCtrlPtr->GetColumn(columnIndex);
// check if the sort order has changed:
if ( columnPtr->IsSortOrderAscending() && (sortOrder == kDataBrowserOrderDecreasing) ||
} /* wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(DataBrowserItemID, DataBrowserItemNotification, DataBrowserItemDataRef) */
-#endif
- // wxUSE_GENERICDATAVIEWCTRL
+#endif // wxUSE_DATAVIEWCTRL
+#endif // wxUSE_GENERICDATAVIEWCTRL