return itemIDs;
}
+static const EventTypeSpec eventList[] =
+{
+ { kEventClassControl, kEventControlHit },
+ { kEventClassControl, kEventControlDraw }
+};
+
static pascal OSStatus DataBrowserCtrlEventHandler(EventHandlerCallRef handler, EventRef EventReference, void* Data)
{
wxDataViewCtrl* DataViewCtrlPtr((wxDataViewCtrl*) Data); // the 'Data' variable always contains a pointer to the data view control that installed the handler
{
ControlRef controlReference;
DataBrowserPropertyID columnPropertyID;
+ DataBrowserSortOrder order;
unsigned long columnIndex;
+ wxDataViewColumn* column;
OSStatus status;
wxDataViewEvent DataViewEvent(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK,DataViewCtrlPtr->GetId());
if (status == errDataBrowserPropertyNotFound) // user clicked into part of the header that does not have a property
return ::CallNextEventHandler(handler,EventReference);
wxCHECK(status == noErr,status);
+ column = DataViewCtrlPtr->GetColumn(columnIndex);
+ // set the column sort order:
+ status = ::GetDataBrowserSortOrder(controlReference,&order);
+ wxCHECK(status == noErr,status);
+ column->SetSortOrderVariable(order == kDataBrowserOrderIncreasing);
// initialize wxWidget event handler:
DataViewEvent.SetEventObject(DataViewCtrlPtr);
DataViewEvent.SetColumn(columnIndex);
- DataViewEvent.SetDataViewColumn(DataViewCtrlPtr->GetColumn(columnIndex));
+ DataViewEvent.SetDataViewColumn(column);
// finally sent the equivalent wxWidget event:
DataViewCtrlPtr->HandleWindowEvent(DataViewEvent);
return ::CallNextEventHandler(handler,EventReference);
if (ControlPtr != NULL)
return ControlPtr->DataBrowserCompareProc(itemOneID,itemTwoID,sortProperty);
else
- return errDataBrowserPropertyNotSupported;
+ return FALSE;
} /* wxMacDataBrowserTableViewControl::DataBrowserCompareProc(ControlRef, DataBrowserItemID, DataBrowserItemID, DataBrowserPropertyID) */
pascal void wxMacDataBrowserTableViewControl::DataBrowserGetContextualMenuProc(ControlRef browser, MenuRef* menu, UInt32* helpType, CFStringRef* helpItemString, AEDesc* selection)
if (ControlPtr != NULL)
return ControlPtr->DataBrowserTrackingProc(itemID,propertyID,theRect,startPt,modifiers);
else
- return kDataBrowserNothingHit;
+ return kDataBrowserNothingHit;
} /* wxMacDataBrowserTableViewControl::DataBrowserTrackingProc(ControlRef, DataBrowserItemID, DataBrowserPropertyID, Rect const*, Point, EventModifiers) */
pascal Boolean wxMacDataBrowserTableViewControl::DataBrowserAcceptDragProc(ControlRef browser, DragReference dragRef, DataBrowserItemID itemID)
{
wxMacDataBrowserTableViewControl* controlPtr(dynamic_cast<wxMacDataBrowserTableViewControl*>(wxMacControl::GetReferenceFromNativeControl(browser)));
-
-
+
+
return ((controlPtr != NULL) && controlPtr->DataBrowserAcceptDragProc(dragRef,itemID));
} /* wxMacDataBrowserTableViewControl::DataBrowserAcceptDragProc(ControlRef, DragReference, DataBrowserItemID) */
pascal Boolean wxMacDataBrowserTableViewControl::DataBrowserAddDragItemProc(ControlRef browser, DragReference dragRef, DataBrowserItemID itemID, ItemReference* itemRef)
{
wxMacDataBrowserTableViewControl* controlPtr(dynamic_cast<wxMacDataBrowserTableViewControl*>(wxMacControl::GetReferenceFromNativeControl(browser)));
-
-
+
+
return ((controlPtr != NULL) && controlPtr->DataBrowserAddDragItemProc(dragRef,itemID,itemRef));
} /* wxMacDataBrowserTableViewControl::DataBrowserAddDragItemProc(ControlRef, DragReference, DataBrowserItemID, ItemReference*) */
pascal Boolean wxMacDataBrowserTableViewControl::DataBrowserReceiveDragProc(ControlRef browser, DragReference dragRef, DataBrowserItemID itemID)
{
wxMacDataBrowserTableViewControl* controlPtr(dynamic_cast<wxMacDataBrowserTableViewControl*>(wxMacControl::GetReferenceFromNativeControl(browser)));
-
-
+
+
return ((controlPtr != NULL) && controlPtr->DataBrowserReceiveDragProc(dragRef,itemID));
} /* wxMacDataBrowserTableViewControl::DataBrowserReceiveDragProc(ControlRef, DragReference, DataBrowserItemID) */
SetReferenceInNativeControl();
verify_noerr(err);
+
+ ::InstallControlEventHandler(this->m_controlRef, GetDataBrowserCtrlEventHandlerUPP(), GetEventTypeCount(eventList), eventList, peer, (EventHandlerRef *)&m_macDataViewCtrlEventHandler);
+
// setup standard callbacks:
if (gDataBrowserTableViewGetContextualMenuUPP == NULL) gDataBrowserTableViewGetContextualMenuUPP = NewDataBrowserGetContextualMenuUPP(wxMacDataBrowserTableViewControl::DataBrowserGetContextualMenuProc);
if (gDataBrowserTableViewItemCompareUPP == NULL) gDataBrowserTableViewItemCompareUPP = NewDataBrowserItemCompareUPP (wxMacDataBrowserTableViewControl::DataBrowserCompareProc);
callbacks.u.v1.itemDataCallback = gDataBrowserTableViewItemDataUPP;
callbacks.u.v1.itemCompareCallback = gDataBrowserTableViewItemCompareUPP;
callbacks.u.v1.itemNotificationCallback = gDataBrowserTableViewItemNotificationUPP;
- callbacks.u.v1.acceptDragCallback = gDataBrowserTableViewAcceptDragUPP;
- callbacks.u.v1.addDragItemCallback = gDataBrowserTableViewAddDragItemUPP;
- callbacks.u.v1.receiveDragCallback = gDataBrowserTableViewReceiveDragUPP;
+ callbacks.u.v1.acceptDragCallback = gDataBrowserTableViewAcceptDragUPP;
+ callbacks.u.v1.addDragItemCallback = gDataBrowserTableViewAddDragItemUPP;
+ callbacks.u.v1.receiveDragCallback = gDataBrowserTableViewReceiveDragUPP;
this->SetCallbacks(&callbacks);
// setup callbacks for customized items:
}
OptionBits attributes; // variable definition
-
+
if (this->GetAttributes(&attributes) == noErr) // get default settings
{
if ((style & wxDV_VERT_RULES) != 0)
this->SetHeaderButtonHeight(0);
} /* wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow*, wxPoint const&, wxSize const&, long) */
+wxMacDataBrowserTableViewControl::~wxMacDataBrowserTableViewControl(void)
+{
+ ::RemoveEventHandler((EventHandlerRef) m_macDataViewCtrlEventHandler);
+} /* wxMacDataBrowserTableViewControl::~wxMacDataBrowserTableViewControl(void) */
+
//
// callback handling
//
// lead to a large overhead for the call but returns an error code if the property id does not exist, here we use the function that returns
// the column position for the property id:
DataBrowserTableViewColumnIndex index;
-
+
return ::GetDataBrowserTableViewColumnPosition(this->m_controlRef,propertyID,&index);
} /* wxMacDataBrowserTableViewControl::IsUsedPropertyId(DataBrowserPropertyID) const */
OSStatus wxMacDataBrowserTableViewControl::GetFreeItemID(DataBrowserItemID* id) const
{
ItemCount noOfItems;
-
+
OSStatus status;
-
-
+
+
status = this->GetItemCount(&noOfItems);
wxCHECK_MSG(status == noErr,status,_("Could not retrieve number of items"));
if (noOfItems == 0)
// lead to a large overhead for the call but returns an error code if the property id does not exist, here we use the function that returns
// the column position for the property id:
DataBrowserTableViewColumnIndex index;
-
+
return ::GetDataBrowserTableViewItemRow(this->m_controlRef,itemID,&index);
} /* wxMacDataBrowserTableViewControl::IsUsedItemID(DataBrowserItemID) const */
{
DataBrowserItemID* itemIDPtr;
Handle handle(::NewHandle(0));
-
+
size_t noOfItems;
bool wxMacDataViewDataBrowserListViewControl::ClearColumns(void)
{
UInt32 noOfColumns;
-
-
+
+
wxCHECK_MSG(this->GetColumnCount(&noOfColumns) == noErr,false,_("Could not determine number of columns."));
for (UInt32 i=0; i<noOfColumns; ++i)
wxCHECK_MSG(this->RemoveColumnByIndex(0) == noErr,false,_("Could not remove column."));
if (noOfColumns == 1)
{
wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer()));
-
+
wxCHECK_MSG(dataViewCtrlPtr != NULL,false,_("wxWidget's control not initialized."));
dataViewCtrlPtr->AddChildren(wxDataViewItem());
return true;
bool wxMacDataViewDataBrowserListViewControl::IsExpanded(wxDataViewItem const& item) const
{
- DataBrowserItemState state;
+ DataBrowserItemState state = 0;
+ if (this->GetItemState(reinterpret_cast<DataBrowserItemID>(item.GetID()),&state) != noErr)
+ return false;
- return ((this->GetItemState(reinterpret_cast<DataBrowserItemID>(item.GetID()),&state) == noErr) &&
- (state & kDataBrowserContainerIsOpen != 0));
+ return ((state & kDataBrowserContainerIsOpen) != 0);
}
bool wxMacDataViewDataBrowserListViewControl::Reload(void)
//
// other methods (inherited from wxDataViewWidgetImpl)
//
-void wxMacDataViewDataBrowserListViewControl::HitTest(wxPoint const& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const
+void
+wxMacDataViewDataBrowserListViewControl::HitTest(const wxPoint& WXUNUSED(point),
+ wxDataViewItem& item,
+ wxDataViewColumn*& columnPtr) const
{
// not yet implemented:
item = wxDataViewItem();
void wxMacDataViewDataBrowserListViewControl::OnSize(void)
{
UInt32 noOfColumns;
-
-
+
+
this->GetColumnCount(&noOfColumns);
if (noOfColumns <= 1) // no horizontal scroll bar and the only column expands to the width of the whole control
{
DataBrowserSortOrder sortOrder;
DataBrowserTableViewColumnIndex modelColumnIndex;
-
+
wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer()));
-
+
wxCHECK_MSG(dataViewCtrlPtr != NULL, false,_("Pointer to data view control not set correctly."));
wxCHECK_MSG(dataViewCtrlPtr->GetModel() != NULL,false,_("Pointer to model not set correctly."));
{
// variable definition and initialization:
wxDataViewColumn* ColumnPtr(this->GetColumnPtr(sortProperty));
-
+
wxCHECK_MSG(ColumnPtr != NULL,false,_("Could not determine column index."));
modelColumnIndex = ColumnPtr->GetModelColumn();
}
{
// variable definitions:
wxDataViewCtrl* dataViewCtrlPtr;
-
+
dataViewCtrlPtr = dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer());
wxCHECK_MSG(dataViewCtrlPtr != NULL,errDataBrowserNotConfigured,_("Pointer to data view control not set correctly."));
if (dataViewCtrlPtr->IsDeleting())
// variable definitions:
OSStatus errorStatus;
wxDataViewColumn* dataViewColumnPtr;
-
+
wxCHECK_MSG(dataViewCtrlPtr->GetModel() != NULL,errDataBrowserNotConfigured,_("Pointer to model not set correctly."));
dataViewColumnPtr = this->GetColumnPtr(propertyID);
wxCHECK_MSG((dataViewColumnPtr != NULL) && (dataViewColumnPtr->GetRenderer() != NULL),errDataBrowserNotConfigured,_("There is no column or renderer for the specified column index."));
wxDataViewItem dvItem(reinterpret_cast<void*>(itemID));
unsigned int col = dataViewColumnPtr->GetModelColumn();
-
+
switch (dataViewColumnPtr->GetRenderer()->GetNativeData()->GetPropertyType())
{
case kDataBrowserCheckboxType:
wxMacCFStringHolder modifiedString(stringReference);
#endif
wxVariant modifiedData(modifiedString.AsString());
-
+
if (dataViewCtrlPtr->GetModel()->SetValue(modifiedData, dvItem, col) &&
dataViewCtrlPtr->GetModel()->ValueChanged(dvItem, col))
return noErr;
wxVariant variant;
wxDataViewColumn* dataViewColumnPtr;
wxDataViewCtrl* dataViewCtrlPtr;
-
+
dataViewCtrlPtr = dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer());
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."));
{
dataViewColumnPtr->GetRenderer()->GetNativeData()->SetItemDataRef(itemData);
dataViewColumnPtr->GetRenderer()->SetValue(variant);
- wxCHECK_MSG(dataViewColumnPtr->GetRenderer()->Render(),errDataBrowserNotConfigured,_("Rendering failed."));
+ wxCHECK_MSG(dataViewColumnPtr->GetRenderer()->MacRender(),errDataBrowserNotConfigured,_("Rendering failed."));
}
return noErr;
}
{
// variable definitions:
wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer()));
-
+
wxCHECK_MSG(dataViewCtrlPtr != NULL,errDataBrowserNotConfigured,_("Pointer to data view control not set correctly."));
// initialize wxWidget event:
wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING,dataViewCtrlPtr->GetId()); // variable definition
-
+
dataViewEvent.SetEventObject(dataViewCtrlPtr);
dataViewEvent.SetItem (wxDataViewItem(reinterpret_cast<void*>(itemID)));
dataViewEvent.SetModel (dataViewCtrlPtr->GetModel());
{
// variable definitions:
wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer()));
-
+
wxCHECK_MSG(dataViewCtrlPtr != NULL,errDataBrowserNotConfigured,_("Pointer to data view control not set correctly."));
// initialize wxWidget event:
wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING,dataViewCtrlPtr->GetId()); // variable definition
{
// variable definition:
wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer()));
-
+
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."));
return ::SetDataBrowserItemDataBooleanValue(itemData,dataViewCtrlPtr->GetModel()->IsContainer(wxDataViewItem(reinterpret_cast<void*>(itemID))));
{
// initialize wxWidget event:
wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED,dataViewCtrlPtr->GetId()); // variable definition
-
+
dataViewEvent.SetEventObject(dataViewCtrlPtr);
dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID)));
// finally send the equivalent wxWidget event:
{
// initialize wxWidget event:
wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED,dataViewCtrlPtr->GetId()); // variable definition
-
+
dataViewEvent.SetEventObject(dataViewCtrlPtr);
dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID)));
// finally send the equivalent wxWidget event:
dataViewCtrlPtr->FinishCustomItemEditing(); // stop editing of a custom item first (if necessary)
{
// initialize wxWidget event:
- DataBrowserPropertyID propertyID;
+ 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(this->GetColumnPtr(propertyID));
+ dataViewEvent.SetDataViewColumn(this->GetColumnPtr(propertyID));
}
// finally send the equivalent wxWidget event:
dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
case kDataBrowserEditStopped:
{
// initialize wxWidget event:
- DataBrowserPropertyID propertyID;
+ 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)
wxCHECK_RET(this->GetColumnIndex(propertyID,&columnIndex),_("Column index not found."));
dataViewEvent.SetColumn(columnIndex);
- dataViewEvent.SetDataViewColumn(this->GetColumnPtr(propertyID));
+ dataViewEvent.SetDataViewColumn(this->GetColumnPtr(propertyID));
}
// finally send the equivalent wxWidget event:
dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
wxDataViewColumn* const columnPtr = dataViewCtrlPtr->GetColumnPtr(i);
// variable definition:
UInt16 columnWidth;
-
+
wxCHECK_RET(this->GetColumnWidth(columnPtr->GetNativeData()->GetPropertyID(),&columnWidth) == noErr,_("Column width could not be determined"));
columnPtr->SetWidthVariable(columnWidth);
}
{
DataBrowserSortOrder sortOrder;
DataBrowserTableViewColumnIndex columnIndex;
-
+
if ((this->GetSortOrder(&sortOrder) == noErr) && (this->GetColumnIndex(propertyID,&columnIndex) == noErr))
{
// variable definition and initialization:
}
} /* wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(DataBrowserItemID, DataBrowserItemNotification, DataBrowserItemDataRef) */
-void wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, DataBrowserItemState state, Rect const* rectangle, SInt16 bitDepth, Boolean colorDevice)
+void
+wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowserItemID itemID,
+ DataBrowserPropertyID propertyID,
+ DataBrowserItemState state,
+ Rect const* rectangle,
+ SInt16 WXUNUSED(bitDepth),
+ Boolean WXUNUSED(colorDevice))
{
DataBrowserTableViewColumnIndex columnIndex;
wxDataViewColumn* dataViewColumnPtr;
wxDataViewCtrl* dataViewCtrlPtr;
-
+
wxDataViewCustomRenderer* dataViewCustomRendererPtr;
wxVariant dataToRender;
content.right -= wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
wxDC *dc = dataViewCustomRendererPtr->GetDC();
-
+
int active_border_fudge = 0;
if (dataViewCtrlPtr->HasFocus() && !dataViewCtrlPtr->HasFlag( wxBORDER_NONE ))
active_border_fudge = 1;
else
active_border_fudge = -2;
-
+
wxRect cellrect( static_cast<int>(rectangle->left + active_border_fudge),
static_cast<int>(rectangle->top + active_border_fudge),
static_cast<int>(1+rectangle->right-rectangle->left),
static_cast<int>(rectangle->bottom-rectangle->top) );
-
+
bool is_active = IsControlActive( this->m_controlRef );
if (state == kDataBrowserItemIsSelected)
{
-
- wxColour col( wxMacCreateCGColorFromHITheme( (is_active) ?
+ wxColour col( wxMacCreateCGColorFromHITheme( (is_active) ?
kThemeBrushAlternatePrimaryHighlightColor
: kThemeBrushSecondaryHighlightColor ) );
-
+
wxRect rect = cellrect;
Rect itemrect;
GetDataBrowserItemPartBounds( this->m_controlRef, itemID, propertyID,
kDataBrowserPropertyEnclosingPart, &itemrect );
rect.x = itemrect.left-2;
rect.width = itemrect.right-itemrect.left+3;
-
- wxBrush selBrush( col );
- wxPen oldpen( dc->GetPen() );
- wxBrush oldbrush( dc->GetBrush() );
- dc->SetPen( *wxTRANSPARENT_PEN );
- dc->SetBrush( selBrush );
+
+ wxDCPenChanger setPen(*dc, *wxTRANSPARENT_PEN);
+ wxDCBrushChanger setBrush(*dc, col);
dc->DrawRectangle(rect);
- dc->SetBrush( oldbrush );
- dc->SetPen( oldpen );
}
wxDataViewModel *model = dataViewCtrlPtr->GetModel();
if ((columnIndex == 0) || !model->IsContainer(dataItem) || model->HasContainerColumns(dataItem))
- {
+ {
// make sure that 'Render' can draw only in the allowed area:
dc->SetClippingRegion(content.left,content.top,content.right-content.left+1,content.bottom-content.top+1);
- (void) (dataViewCustomRendererPtr->Render( cellrect, dc,
+ (void) (dataViewCustomRendererPtr->Render( cellrect, dc,
((state == kDataBrowserItemIsSelected) ? wxDATAVIEW_CELL_SELECTED : 0)));
dc->DestroyClippingRegion(); // probably not necessary
}
-
+
dataViewCustomRendererPtr->SetDC(NULL);
} /* wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemState, Rect const*, SInt16, Boolean) */
-Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserEditItemProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, CFStringRef theString, Rect* maxEditTextRect, Boolean* shrinkToFit)
+Boolean
+wxMacDataViewDataBrowserListViewControl::DataBrowserEditItemProc(
+ DataBrowserItemID WXUNUSED(itemID),
+ DataBrowserPropertyID WXUNUSED(propertyID),
+ CFStringRef WXUNUSED(theString),
+ Rect* WXUNUSED(maxEditTextRect),
+ Boolean* WXUNUSED(shrinkToFit))
{
return false;
} /* wxMacDataViewDataBrowserListViewControl::DataBrowserEditItemProc(DataBrowserItemID, DataBrowserPropertyID, CFStringRef, Rect*, Boolean*) */
wxDataViewColumn* dataViewColumnPtr;
wxDataViewCtrl* dataViewCtrlPtr;
-
+
wxDataViewCustomRenderer* dataViewCustomRendererPtr;
-
+
wxDataViewItem dataViewCustomRendererItem;
{
// variable definition:
wxRect wxRectangle;
-
+
::wxMacNativeToRect(theRect,&wxRectangle);
dataViewCustomRendererPtr->StartEditing(dataViewCustomRendererItem,wxRectangle);
dataViewCtrlPtr->SetCustomRendererItem(dataViewCustomRendererItem);
ItemReference itemRef;
wxDataObjectComposite* dataObjects;
wxMemoryBuffer buffer;
-
+
::GetDragItemReferenceNumber(dragRef,indexDraggedItem,&itemRef); // the index begins with 1!
dataObjects = this->GetDnDDataObjects(dragRef,itemRef);
// create wxWidget's event:
Boolean addDragItem;
wxDataViewCtrl* dataViewCtrlPtr;
-
+
wxDataViewItem dataViewItem;
// the object a wxDataObjectComposite object is used;
// currently, the composite object only contains a TAB concatenated string of all data:
wxDataObjectComposite* dataObject(new wxDataObjectComposite());
-
+
dataObject->Add(new wxTextDataObject(::ConcatenateDataViewItemValues(dataViewCtrlPtr,dataViewItem)));
dataViewEvent.SetDataObject(dataObject);
// check if event has not been vetoed:
{
// constant definition for abbreviational purposes:
size_t const noOfFormats = dataViewEvent.GetDataObject()->GetFormatCount();
-
+
if (noOfFormats > 0)
{
// variable definition:
wxDataFormat* dataFormats;
-
+
dataFormats = new wxDataFormat[noOfFormats];
dataViewEvent.GetDataObject()->GetAllFormats(dataFormats,wxDataObject::Get);
for (size_t i=0; i<noOfFormats; ++i)
size_t const dataSize = dataViewEvent.GetDataObject()->GetDataSize(wxDF_TEXT);
// variable definition and initialization:
wxMemoryBuffer dataObject(dataSize);
-
+
dataViewEvent.GetDataObject()->GetDataHere(wxDF_TEXT,dataObject.GetWriteBuf(dataSize));
dataObject.UngetWriteBuf(dataSize);
if (::AddDragItemFlavor(dragRef,*itemRef,'TEXT',dataObject.GetData(),dataSize,0) != noErr)
size_t const dataSize = dataViewEvent.GetDataObject()->GetDataSize(wxDF_TEXT);
// as there is no direct access to the data copy it to a memory buffer:
wxMemoryBuffer dataObject(dataSize);
-
+
dataViewEvent.GetDataObject()->GetDataHere(wxDF_TEXT,dataObject.GetWriteBuf(dataSize));
dataObject.UngetWriteBuf(dataSize);
// if the data is stored in unicode format the internal representation is utf-8 (not mentioned in the documentation but in the source code);
// DnD uses fixed utf-16 representation -> use the OSX functions for a conversion:
CFDataRef osxData (::CFDataCreateWithBytesNoCopy(kCFAllocatorDefault,reinterpret_cast<UInt8*>(dataObject.GetData()),dataSize,kCFAllocatorNull));
CFStringRef osxString(::CFStringCreateFromExternalRepresentation(kCFAllocatorDefault,osxData,kCFStringEncodingUTF8));
-
+
// the osxString contains now the data and therefore the previously occupied memory can be released and re-used:
::CFRelease(osxData);
osxData = ::CFStringCreateExternalRepresentation(kCFAllocatorDefault,osxString,kCFStringEncodingUTF16,32);
ItemReference itemRef;
wxDataObjectComposite* dataObjects;
wxMemoryBuffer buffer;
-
+
// collect native information:
::GetDragItemReferenceNumber(dragRef,indexDraggedItem,&itemRef); // the index begins with 1!
dataObjects = this->GetDnDDataObjects(dragRef,itemRef);
size_t indexFormat;
wxDataFormat* formats;
-
+
// get all formats and check afterwards if the formats are compatible; if they are compatible the preferred format is returned otherwise
// wxDF_INVALID is returned;
// currently compatible types (ordered by priority are):
{
// variable definition:
FlavorType flavorDataObject;
-
+
if (::GetFlavorType(dragRef,itemRef,indexFlavor,&flavorDataObject) == noErr) // GetFlavorType uses a 1 based index!
switch (flavorDataObject)
{
// variable definitions:
Size nativeDataSize;
wxMemoryBuffer nativeData;
-
+
if ((::GetFlavorDataSize(dragRef,itemRef,'TEXT',&nativeDataSize) == noErr) &&
(::GetFlavorData(dragRef,itemRef,'TEXT',nativeData.GetWriteBuf(nativeDataSize),&nativeDataSize,0) == noErr))
{
{
// variable definition:
Size nativeDataSize;
-
+
if (::GetFlavorDataSize(dragRef,itemRef,'utxt',&nativeDataSize) == noErr)
{
CFMutableDataRef draggedData;
-
+
draggedData = ::CFDataCreateMutable(kCFAllocatorDefault,nativeDataSize);
::CFDataSetLength(draggedData,nativeDataSize);
if (::GetFlavorData(dragRef,itemRef,'utxt',::CFDataGetMutableBytePtr(draggedData),&nativeDataSize,0) == noErr)
// convert internally used UTF-16 representation to a UTF-8 representation:
CFDataRef osxData;
CFStringRef osxString;
-
+
osxString = ::CFStringCreateFromExternalRepresentation(kCFAllocatorDefault,draggedData,kCFStringEncodingUTF16); // BOM character is handled by this function automatically
osxData = ::CFStringCreateExternalRepresentation(kCFAllocatorDefault,osxString,kCFStringEncodingUTF8,32);
if (textDataObject == NULL)
wxDataViewColumn* wxMacDataViewDataBrowserListViewControl::GetColumnPtr(DataBrowserPropertyID propertyID) const
{
wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer()));
-
+
if (dataViewCtrlPtr != NULL)
{
size_t const noOfColumns = dataViewCtrlPtr->GetColumnCount();
-
+
for (size_t i=0; i<noOfColumns; ++i)
if (dataViewCtrlPtr->GetColumnPtr(i)->GetNativeData()->GetPropertyID() == propertyID)
return dataViewCtrlPtr->GetColumnPtr(i);
this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserCustomType));
}
-bool wxDataViewCustomRenderer::Render()
+bool wxDataViewCustomRenderer::MacRender()
{
return true;
}
this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserTextType));
}
-bool wxDataViewTextRenderer::Render()
+bool wxDataViewTextRenderer::MacRender()
{
wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Text renderer cannot render value; value type: ")) << this->GetValue().GetType());
this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserIconType));
}
-bool wxDataViewBitmapRenderer::Render()
+bool wxDataViewBitmapRenderer::MacRender()
// This method returns 'true' if
// - the passed bitmap is valid and it could be assigned to the native data browser;
// - the passed bitmap is invalid (or is not initialized); this case simulates a non-existing bitmap.
// ---------------------------------------------------------
// wxDataViewIconTextRenderer
// ---------------------------------------------------------
-wxDataViewIconTextRenderer::wxDataViewIconTextRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align)
+wxDataViewIconTextRenderer::wxDataViewIconTextRenderer(
+ const wxString& varianttype,
+ wxDataViewCellMode mode,
+ int WXUNUSED(align))
:wxDataViewRenderer(varianttype,mode)
{
this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserIconAndTextType));
}
-bool wxDataViewIconTextRenderer::Render()
+bool wxDataViewIconTextRenderer::MacRender()
{
wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Icon & text renderer cannot render value; value type: ")) << this->GetValue().GetType());
// ---------------------------------------------------------
// wxDataViewToggleRenderer
// ---------------------------------------------------------
-wxDataViewToggleRenderer::wxDataViewToggleRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align)
+wxDataViewToggleRenderer::wxDataViewToggleRenderer(
+ const wxString& varianttype,
+ wxDataViewCellMode mode,
+ int WXUNUSED(align))
:wxDataViewRenderer(varianttype,mode)
{
this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserCheckboxType));
}
-bool wxDataViewToggleRenderer::Render()
+bool wxDataViewToggleRenderer::MacRender()
{
wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Toggle renderer cannot render value; value type: ")) << this->GetValue().GetType());
return (::SetDataBrowserItemDataButtonValue(this->GetNativeData()->GetItemDataRef(),this->GetValue().GetBool()) == noErr);
// ---------------------------------------------------------
// wxDataViewProgressRenderer
// ---------------------------------------------------------
-wxDataViewProgressRenderer::wxDataViewProgressRenderer(wxString const& label, wxString const& varianttype, wxDataViewCellMode mode, int align)
+wxDataViewProgressRenderer::wxDataViewProgressRenderer(
+ const wxString& WXUNUSED(label),
+ wxString const& varianttype,
+ wxDataViewCellMode mode,
+ int align)
:wxDataViewRenderer(varianttype,mode,align)
{
this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserProgressBarType));
}
-bool wxDataViewProgressRenderer::Render()
+bool wxDataViewProgressRenderer::MacRender()
{
wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Progress renderer cannot render value type; value type: ")) << this->GetValue().GetType());
return ((::SetDataBrowserItemDataMinimum(this->GetNativeData()->GetItemDataRef(), 0) == noErr) &&
this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserDateTimeType));
}
-bool wxDataViewDateRenderer::Render()
+bool wxDataViewDateRenderer::MacRender()
{
wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Date renderer cannot render value; value type: ")) << this->GetValue().GetType());
return (::SetDataBrowserItemDataDateTime(this->GetNativeData()->GetItemDataRef(),this->GetValue().GetDateTime().Subtract(wxDateTime(1,wxDateTime::Jan,1904)).GetSeconds().GetLo()) == noErr);