X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/35d85392ff011bc8d24b036ede54e69ab557ed32..bd235295fb3b35fdb29326084b87893cf5432eb5:/src/osx/carbon/dataview.cpp diff --git a/src/osx/carbon/dataview.cpp b/src/osx/carbon/dataview.cpp index ecacdf72b1..f64e35c430 100644 --- a/src/osx/carbon/dataview.cpp +++ b/src/osx/carbon/dataview.cpp @@ -66,6 +66,12 @@ static DataBrowserItemID* CreateDataBrowserItemIDArray(size_t& noOfEntries, wxDa 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 @@ -89,7 +95,9 @@ static pascal OSStatus DataBrowserCtrlEventHandler(EventHandlerCallRef handler, { ControlRef controlReference; DataBrowserPropertyID columnPropertyID; + DataBrowserSortOrder order; unsigned long columnIndex; + wxDataViewColumn* column; OSStatus status; wxDataViewEvent DataViewEvent(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK,DataViewCtrlPtr->GetId()); @@ -101,10 +109,15 @@ static pascal OSStatus DataBrowserCtrlEventHandler(EventHandlerCallRef handler, 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); @@ -211,8 +224,8 @@ pascal Boolean wxMacDataBrowserTableViewControl::DataBrowserCompareProc(ControlR if (ControlPtr != NULL) return ControlPtr->DataBrowserCompareProc(itemOneID,itemTwoID,sortProperty); else - return errDataBrowserPropertyNotSupported; -} /* wxMacDataBrowserTableViewControl::DataBrowserCompareProc(ControlRef, DataBrowserItemID, DataBrowserItemID, DataBrowserPropertyID) */ + return FALSE; +} pascal void wxMacDataBrowserTableViewControl::DataBrowserGetContextualMenuProc(ControlRef browser, MenuRef* menu, UInt32* helpType, CFStringRef* helpItemString, AEDesc* selection) { @@ -221,7 +234,7 @@ pascal void wxMacDataBrowserTableViewControl::DataBrowserGetContextualMenuProc(C if (ControlPtr != NULL) ControlPtr->DataBrowserGetContextualMenuProc(menu,helpType,helpItemString,selection); -} /* wxMacDataBrowserTableViewControl::DataBrowserGetContextualMenuProc(ControlRef, MenuRef*, UInt32*, CFStringRef*, AEDesc*) */ +} pascal OSStatus wxMacDataBrowserTableViewControl::DataBrowserGetSetItemDataProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID propertyID, DataBrowserItemDataRef itemData, Boolean getValue) { @@ -232,7 +245,7 @@ pascal OSStatus wxMacDataBrowserTableViewControl::DataBrowserGetSetItemDataProc( return ControlPtr->DataBrowserGetSetItemDataProc(itemID,propertyID,itemData,getValue); else return errDataBrowserPropertyNotSupported; -} /* wxMacDataBrowserTableViewControl::DataBrowserGetSetItemDataProc(ControlRef, DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemDataRef, Boolean) */ +} pascal void wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserItemNotification message, DataBrowserItemDataRef itemData) { @@ -241,7 +254,7 @@ pascal void wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc(Co if (ControlPtr != NULL) ControlPtr->DataBrowserItemNotificationProc(itemID,message,itemData); -} /* wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc(ControlRef, DataBrowserItemID, DataBrowserItemNotification, DataBrowserItemDataRef) */ +} pascal void wxMacDataBrowserTableViewControl::DataBrowserDrawItemProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID propertyID, DataBrowserItemState state, Rect const* rectangle, SInt16 bitDepth, Boolean colorDevice) { @@ -250,7 +263,7 @@ pascal void wxMacDataBrowserTableViewControl::DataBrowserDrawItemProc(ControlRef if (ControlPtr != NULL) ControlPtr->DataBrowserDrawItemProc(itemID,propertyID,state,rectangle,bitDepth,colorDevice); -} /* wxMacDataBrowserTableViewControl::DataBrowserDrawItemProc(ControlRef, DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemState, Rect const*, SInt16, Boolean) */ +} pascal Boolean wxMacDataBrowserTableViewControl::DataBrowserEditItemProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID propertyID, CFStringRef theString, Rect* maxEditTextRect, Boolean* shrinkToFit) { @@ -258,7 +271,7 @@ pascal Boolean wxMacDataBrowserTableViewControl::DataBrowserEditItemProc(Control return ((ControlPtr != NULL) && ControlPtr->DataBrowserEditItemProc(itemID,propertyID,theString,maxEditTextRect,shrinkToFit)); -} /* wxMacDataBrowserTableViewControl::DataBrowserEditItemProc(ControlRef, DataBrowserItemID, DataBrowserPropertyID, CFStringRef, Rect*, Boolean*) */ +} pascal Boolean wxMacDataBrowserTableViewControl::DataBrowserHitTestProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID propertyID, Rect const* theRect, Rect const* mouseRect) { @@ -266,7 +279,7 @@ pascal Boolean wxMacDataBrowserTableViewControl::DataBrowserHitTestProc(ControlR return ((ControlPtr != NULL) && ControlPtr->DataBrowserHitTestProc(itemID,propertyID,theRect,mouseRect)); -} /* wxMacDataBrowserTableViewControl::DataBrowserHitTestProc(ControlRef, DataBrowserItemID, DataBrowserPropertyID, Rect const*, Rect const*) */ +} pascal DataBrowserTrackingResult wxMacDataBrowserTableViewControl::DataBrowserTrackingProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID propertyID, Rect const* theRect, Point startPt, EventModifiers modifiers) { @@ -276,42 +289,45 @@ pascal DataBrowserTrackingResult wxMacDataBrowserTableViewControl::DataBrowserTr if (ControlPtr != NULL) return ControlPtr->DataBrowserTrackingProc(itemID,propertyID,theRect,startPt,modifiers); else - return kDataBrowserNothingHit; -} /* wxMacDataBrowserTableViewControl::DataBrowserTrackingProc(ControlRef, DataBrowserItemID, DataBrowserPropertyID, Rect const*, Point, EventModifiers) */ + return kDataBrowserNothingHit; +} pascal Boolean wxMacDataBrowserTableViewControl::DataBrowserAcceptDragProc(ControlRef browser, DragReference dragRef, DataBrowserItemID itemID) { wxMacDataBrowserTableViewControl* controlPtr(dynamic_cast(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(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(wxMacControl::GetReferenceFromNativeControl(browser))); - - + + return ((controlPtr != NULL) && controlPtr->DataBrowserReceiveDragProc(dragRef,itemID)); -} /* wxMacDataBrowserTableViewControl::DataBrowserReceiveDragProc(ControlRef, DragReference, DataBrowserItemID) */ +} wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow* peer, wxPoint const& pos, wxSize const& size, long style) :wxMacControl(peer) { Rect bounds = wxMacGetBoundsForControl(peer,pos,size); - OSStatus err = ::CreateDataBrowserControl(MAC_WXHWND(peer->MacGetTopLevelWindowRef()),&bounds,kDataBrowserListView,&(this->m_controlRef)); + OSStatus err = ::CreateDataBrowserControl(MAC_WXHWND(peer->MacGetTopLevelWindowRef()),&bounds,kDataBrowserListView,&(m_controlRef)); SetReferenceInNativeControl(); verify_noerr(err); + + ::InstallControlEventHandler(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); @@ -337,10 +353,10 @@ wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow* pee 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; - this->SetCallbacks(&callbacks); + callbacks.u.v1.acceptDragCallback = gDataBrowserTableViewAcceptDragUPP; + callbacks.u.v1.addDragItemCallback = gDataBrowserTableViewAddDragItemUPP; + callbacks.u.v1.receiveDragCallback = gDataBrowserTableViewReceiveDragUPP; + SetCallbacks(&callbacks); // setup callbacks for customized items: if (gDataBrowserTableViewDrawItemUPP == NULL) gDataBrowserTableViewDrawItemUPP = NewDataBrowserDrawItemUPP(wxMacDataBrowserTableViewControl::DataBrowserDrawItemProc); @@ -355,25 +371,25 @@ wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow* pee customCallbacks.u.v1.editTextCallback = gDataBrowserTableViewEditItemUPP; customCallbacks.u.v1.hitTestCallback = gDataBrowserTableViewHitTestUPP; customCallbacks.u.v1.trackingCallback = gDataBrowserTableViewTrackingUPP; - this->SetCustomCallbacks(&customCallbacks); + SetCustomCallbacks(&customCallbacks); // style setting: - this->EnableCellSizeModification( ((style & wxDV_VARIABLE_LINE_HEIGHT) != 0), true ); + EnableCellSizeModification( ((style & wxDV_VARIABLE_LINE_HEIGHT) != 0), true ); DataBrowserSelectionFlags flags; // variable definition - if (this->GetSelectionFlags(&flags) == noErr) // get default settings + if (GetSelectionFlags(&flags) == noErr) // get default settings { if ((style & wxDV_MULTIPLE) != 0) flags &= ~kDataBrowserSelectOnlyOne; else flags |= kDataBrowserSelectOnlyOne; - (void) this->SetSelectionFlags(flags); + (void) SetSelectionFlags(flags); } OptionBits attributes; // variable definition - - if (this->GetAttributes(&attributes) == noErr) // get default settings + + if (GetAttributes(&attributes) == noErr) // get default settings { if ((style & wxDV_VERT_RULES) != 0) attributes |= kDataBrowserAttributeListViewDrawColumnDividers; @@ -383,32 +399,37 @@ wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow* pee attributes |= kDataBrowserAttributeListViewAlternatingRowColors; else attributes &= ~kDataBrowserAttributeListViewAlternatingRowColors; - (void) this->SetAttributes(attributes); + (void) SetAttributes(attributes); } if ((style & wxDV_NO_HEADER) != 0) - this->SetHeaderButtonHeight(0); -} /* wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow*, wxPoint const&, wxSize const&, long) */ + SetHeaderButtonHeight(0); +} + +wxMacDataBrowserTableViewControl::~wxMacDataBrowserTableViewControl() +{ + ::RemoveEventHandler((EventHandlerRef) m_macDataViewCtrlEventHandler); +} // // callback handling // OSStatus wxMacDataBrowserTableViewControl::SetCallbacks(DataBrowserCallbacks const* callbacks) { - return ::SetDataBrowserCallbacks(this->m_controlRef,callbacks); -} /* wxMacDataBrowserTableViewControl::SetCallbacks(DataBrowserCallbacks const*) */ + return ::SetDataBrowserCallbacks(m_controlRef,callbacks); +} OSStatus wxMacDataBrowserTableViewControl::SetCustomCallbacks(DataBrowserCustomCallbacks const* customCallbacks) { - return ::SetDataBrowserCustomCallbacks(this->m_controlRef,customCallbacks); -} /* xMacDataBrowserTableViewControl::SetCustomCallbacks(DataBrowserCustomCallbacks const*) */ + return ::SetDataBrowserCustomCallbacks(m_controlRef,customCallbacks); +} // // DnD handling // OSStatus wxMacDataBrowserTableViewControl::EnableAutomaticDragTracking(bool enable) { - return ::SetAutomaticControlDragTrackingEnabledForWindow(::GetControlOwner(this->m_controlRef),enable); + return ::SetAutomaticControlDragTrackingEnabledForWindow(::GetControlOwner(m_controlRef),enable); } // @@ -417,12 +438,12 @@ OSStatus wxMacDataBrowserTableViewControl::EnableAutomaticDragTracking(bool enab OSStatus wxMacDataBrowserTableViewControl::GetHeaderDesc(DataBrowserPropertyID propertyID, DataBrowserListViewHeaderDesc* desc) const { desc->version = kDataBrowserListViewLatestHeaderDesc; // if this statement is missing the next call will fail (NOT DOCUMENTED!!) - return ::GetDataBrowserListViewHeaderDesc(this->m_controlRef,propertyID,desc); + return ::GetDataBrowserListViewHeaderDesc(m_controlRef,propertyID,desc); } OSStatus wxMacDataBrowserTableViewControl::SetHeaderDesc(DataBrowserPropertyID propertyID, DataBrowserListViewHeaderDesc* desc) { - return ::SetDataBrowserListViewHeaderDesc(this->m_controlRef,propertyID,desc); + return ::SetDataBrowserListViewHeaderDesc(m_controlRef,propertyID,desc); } // @@ -430,102 +451,102 @@ OSStatus wxMacDataBrowserTableViewControl::SetHeaderDesc(DataBrowserPropertyID p // OSStatus wxMacDataBrowserTableViewControl::AutoSizeColumns() { - return AutoSizeDataBrowserListViewColumns(this->m_controlRef); + return AutoSizeDataBrowserListViewColumns(m_controlRef); } OSStatus wxMacDataBrowserTableViewControl::EnableCellSizeModification(bool enableHeight, bool enableWidth) { - return ::SetDataBrowserTableViewGeometry(this->GetControlRef(),enableWidth,enableHeight); -} /* wxMacDataBrowserTableViewControl::EnableCellSizeModification(bool, bool) */ + return ::SetDataBrowserTableViewGeometry(GetControlRef(),enableWidth,enableHeight); +} OSStatus wxMacDataBrowserTableViewControl::GetAttributes(OptionBits* attributes) { - return ::DataBrowserGetAttributes(this->GetControlRef(),attributes); -} /* wxMacDataBrowserTableViewControl::GetAttributes(OptionBits*) */ + return ::DataBrowserGetAttributes(GetControlRef(),attributes); +} OSStatus wxMacDataBrowserTableViewControl::GetColumnWidth(DataBrowserPropertyID propertyID, UInt16* width) const { - return ::GetDataBrowserTableViewNamedColumnWidth(this->m_controlRef,propertyID,width); + return ::GetDataBrowserTableViewNamedColumnWidth(m_controlRef,propertyID,width); } OSStatus wxMacDataBrowserTableViewControl::GetDefaultColumnWidth( UInt16 *width ) const { - return GetDataBrowserTableViewColumnWidth(this->m_controlRef, width ); + return GetDataBrowserTableViewColumnWidth(m_controlRef, width ); } OSStatus wxMacDataBrowserTableViewControl::GetDefaultRowHeight(UInt16* height) const { - return ::GetDataBrowserTableViewRowHeight(this->m_controlRef,height); + return ::GetDataBrowserTableViewRowHeight(m_controlRef,height); } OSStatus wxMacDataBrowserTableViewControl::GetHeaderButtonHeight(UInt16 *height) { - return ::GetDataBrowserListViewHeaderBtnHeight(this->m_controlRef,height); + return ::GetDataBrowserListViewHeaderBtnHeight(m_controlRef,height); } OSStatus wxMacDataBrowserTableViewControl::GetPartBounds(DataBrowserItemID item, DataBrowserPropertyID propertyID, DataBrowserPropertyPart part, Rect* bounds) { - return ::GetDataBrowserItemPartBounds(this->m_controlRef,item,propertyID,part,bounds); -} /* wxMacDataBrowserTableViewControl::GetPartBounds(DataBrowserItemID, DataBrowswerPropertyID, DataBrowserPropertyPart, Rect*) */ + return ::GetDataBrowserItemPartBounds(m_controlRef,item,propertyID,part,bounds); +} OSStatus wxMacDataBrowserTableViewControl::GetRowHeight(DataBrowserItemID item, UInt16* height) const { - return ::GetDataBrowserTableViewItemRowHeight(this->m_controlRef,item,height); -} /* wxMacDataBrowserTableViewControl::GetRowHeight(DataBrowserItemID, UInt16*) const */ + return ::GetDataBrowserTableViewItemRowHeight(m_controlRef,item,height); +} OSStatus wxMacDataBrowserTableViewControl::GetScrollPosition( UInt32 *top , UInt32 *left ) const { - return GetDataBrowserScrollPosition(this->m_controlRef, top , left ); + return GetDataBrowserScrollPosition(m_controlRef, top , left ); } OSStatus wxMacDataBrowserTableViewControl::SetAttributes(OptionBits attributes) { - return ::DataBrowserChangeAttributes(this->GetControlRef(),attributes,~attributes); -} /* wxMacDataBrowserTableViewControl::SetAttributes(OptionBits) */ + return ::DataBrowserChangeAttributes(GetControlRef(),attributes,~attributes); +} OSStatus wxMacDataBrowserTableViewControl::SetColumnWidth(DataBrowserPropertyID propertyID, UInt16 width) { - return ::SetDataBrowserTableViewNamedColumnWidth(this->m_controlRef,propertyID,width); + return ::SetDataBrowserTableViewNamedColumnWidth(m_controlRef,propertyID,width); } OSStatus wxMacDataBrowserTableViewControl::SetDefaultColumnWidth(UInt16 width) { - return ::SetDataBrowserTableViewColumnWidth(this->m_controlRef,width); + return ::SetDataBrowserTableViewColumnWidth(m_controlRef,width); } OSStatus wxMacDataBrowserTableViewControl::SetDefaultRowHeight(UInt16 height) { - return ::SetDataBrowserTableViewRowHeight(this->m_controlRef,height); + return ::SetDataBrowserTableViewRowHeight(m_controlRef,height); } OSStatus wxMacDataBrowserTableViewControl::SetHasScrollBars(bool horiz, bool vert) { - return ::SetDataBrowserHasScrollBars(this->m_controlRef,horiz,vert); -} /* wxMacDataBrowserTableViewControl::SetHasScrollBars(bool, bool) */ + return ::SetDataBrowserHasScrollBars(m_controlRef,horiz,vert); +} OSStatus wxMacDataBrowserTableViewControl::SetHeaderButtonHeight(UInt16 height) { - return ::SetDataBrowserListViewHeaderBtnHeight(this->m_controlRef,height); -} /* wxMacDataBrowserTableViewControl::SetHeaderButtonHeight(UInt16) */ + return ::SetDataBrowserListViewHeaderBtnHeight(m_controlRef,height); +} OSStatus wxMacDataBrowserTableViewControl::SetHiliteStyle(DataBrowserTableViewHiliteStyle hiliteStyle) { - return ::SetDataBrowserTableViewHiliteStyle(this->m_controlRef,hiliteStyle); -} /*wxMacDataBrowserTableViewControl::SetHiliteStyle(DataBrowserTableViewHiliteStyle) */ + return ::SetDataBrowserTableViewHiliteStyle(m_controlRef,hiliteStyle); +} OSStatus wxMacDataBrowserTableViewControl::SetIndent(float Indent) { - return ::DataBrowserSetMetric(this->m_controlRef,kDataBrowserMetricDisclosureColumnPerDepthGap,true,Indent); -} /* wxMacDataBrowserTableViewControl::SetIndent(float* Indent) */ + return ::DataBrowserSetMetric(m_controlRef,kDataBrowserMetricDisclosureColumnPerDepthGap,true,Indent); +} OSStatus wxMacDataBrowserTableViewControl::SetItemRowHeight(DataBrowserItemID item, UInt16 height) { - return ::SetDataBrowserTableViewItemRowHeight(this->m_controlRef,item,height); + return ::SetDataBrowserTableViewItemRowHeight(m_controlRef,item,height); } OSStatus wxMacDataBrowserTableViewControl::SetScrollPosition(UInt32 top, UInt32 left) { - return ::SetDataBrowserScrollPosition(this->m_controlRef,top,left); + return ::SetDataBrowserScrollPosition(m_controlRef,top,left); } // @@ -533,36 +554,36 @@ OSStatus wxMacDataBrowserTableViewControl::SetScrollPosition(UInt32 top, UInt32 // OSStatus wxMacDataBrowserTableViewControl::GetColumnCount(UInt32* numColumns) const { - return ::GetDataBrowserTableViewColumnCount(this->m_controlRef,numColumns); + return ::GetDataBrowserTableViewColumnCount(m_controlRef,numColumns); } OSStatus wxMacDataBrowserTableViewControl::GetColumnIndex(DataBrowserPropertyID propertyID, DataBrowserTableViewColumnIndex* index) const { - return ::GetDataBrowserTableViewColumnPosition(this->m_controlRef,propertyID,index); -} /* wxMacDataBrowserTableViewControl::GetColumnIndex(DataBrowserPropertyID, DataBrowserTableViewColumnIndex*) const */ + return ::GetDataBrowserTableViewColumnPosition(m_controlRef,propertyID,index); +} OSStatus wxMacDataBrowserTableViewControl::GetFreePropertyID(DataBrowserPropertyID* propertyID) const { for (*propertyID=kMinPropertyID; *propertyID::max(); ++(*propertyID)) - if (this->IsUsedPropertyID(*propertyID) == errDataBrowserPropertyNotFound) + if (IsUsedPropertyID(*propertyID) == errDataBrowserPropertyNotFound) return noErr; return errDataBrowserPropertyNotSupported; -} /* wxMacDataBrowserTableViewControl::GetFreePropertyID(DataBrowserPropertyID*) const */ +} OSStatus wxMacDataBrowserTableViewControl::GetPropertyFlags(DataBrowserPropertyID propertyID, DataBrowserPropertyFlags *flags) const { - return ::GetDataBrowserPropertyFlags(this->m_controlRef,propertyID,flags); + return ::GetDataBrowserPropertyFlags(m_controlRef,propertyID,flags); } OSStatus wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserItemDataRef itemData, DataBrowserPropertyID* propertyID) const { return ::GetDataBrowserItemDataProperty(itemData,propertyID); -} /* wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserItemDataRef, DataBrowserPropertyID*) */ +} OSStatus wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserTableViewColumnIndex index, DataBrowserTableViewColumnID* propertyID) const { - return ::GetDataBrowserTableViewColumnProperty(this->m_controlRef,index,propertyID); -} /* wxMacDataBrowserTableViewControl::GetPropertyID(DataBrowserTableViewColumnIndex, DataBrowserTableViewColumnID*) */ + return ::GetDataBrowserTableViewColumnProperty(m_controlRef,index,propertyID); +} OSStatus wxMacDataBrowserTableViewControl::IsUsedPropertyID(DataBrowserPropertyID propertyID) const { @@ -570,55 +591,55 @@ OSStatus wxMacDataBrowserTableViewControl::IsUsedPropertyID(DataBrowserPropertyI // 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 */ + + return ::GetDataBrowserTableViewColumnPosition(m_controlRef,propertyID,&index); +} OSStatus wxMacDataBrowserTableViewControl::RemoveColumnByProperty(DataBrowserTableViewColumnID propertyID) { - return ::RemoveDataBrowserTableViewColumn(this->m_controlRef,propertyID); -} /* wxMacDataBrowserTableViewControl::RemoveColumnByProperty(DataBrowserTableViewColumnID) */ + return ::RemoveDataBrowserTableViewColumn(m_controlRef,propertyID); +} OSStatus wxMacDataBrowserTableViewControl::RemoveColumnByIndex(DataBrowserTableViewColumnIndex index) { DataBrowserTableViewColumnID propertyID; - this->GetPropertyID(index,&propertyID); - return ::RemoveDataBrowserTableViewColumn(this->m_controlRef,propertyID); -} /* wxMacDataBrowserTableViewControl::RemoveColumnByIndex(DataBrowserTableViewColumnIndex) */ + GetPropertyID(index,&propertyID); + return ::RemoveDataBrowserTableViewColumn(m_controlRef,propertyID); +} OSStatus wxMacDataBrowserTableViewControl::SetColumnIndex(DataBrowserPropertyID propertyID, DataBrowserTableViewColumnIndex index) { - return ::SetDataBrowserTableViewColumnPosition(this->m_controlRef,propertyID,index); -} /* wxMacDataBrowserTableViewControl::SetColumnIndex(DataBrowserPropertyID, DataBrowserTableViewColumnIndex) */ + return ::SetDataBrowserTableViewColumnPosition(m_controlRef,propertyID,index); +} OSStatus wxMacDataBrowserTableViewControl::SetDisclosureColumn(DataBrowserPropertyID propertyID, Boolean expandableRows) { - return ::SetDataBrowserListViewDisclosureColumn(this->m_controlRef,propertyID,expandableRows); + return ::SetDataBrowserListViewDisclosureColumn(m_controlRef,propertyID,expandableRows); } OSStatus wxMacDataBrowserTableViewControl::SetPropertyFlags(DataBrowserPropertyID propertyID, DataBrowserPropertyFlags flags) { - return ::SetDataBrowserPropertyFlags(this->m_controlRef,propertyID,flags); -} /* wxMacDataBrowserTableViewControl::SetPropertyFlags(DataBrowserPropertyID, DataBrowserPropertyFlags) */ + return ::SetDataBrowserPropertyFlags(m_controlRef,propertyID,flags); +} // // item handling // OSStatus wxMacDataBrowserTableViewControl::AddItems(DataBrowserItemID container, UInt32 numItems, DataBrowserItemID const* items, DataBrowserPropertyID preSortProperty) { - return ::AddDataBrowserItems(this->m_controlRef,container,numItems,items,preSortProperty); -} /* wxMacDataBrowserTableViewControl::AddItems(DataBrowserItemID, UInt32, DataBrowserItemID const*, DataBrowserPropertyID) */ + return ::AddDataBrowserItems(m_controlRef,container,numItems,items,preSortProperty); +} OSStatus wxMacDataBrowserTableViewControl::GetFreeItemID(DataBrowserItemID* id) const { ItemCount noOfItems; - + OSStatus status; - - - status = this->GetItemCount(&noOfItems); + + + status = GetItemCount(&noOfItems); wxCHECK_MSG(status == noErr,status,_("Could not retrieve number of items")); if (noOfItems == 0) { @@ -630,40 +651,40 @@ OSStatus wxMacDataBrowserTableViewControl::GetFreeItemID(DataBrowserItemID* id) // as there might be a lot of items in the data browser and mostly the data is added item by item the largest used ID number is roughly in the order of magnitude // as the number of items; therefore, start from the number of items to look for a new ID: for (*id=noOfItems; *id::max(); ++(*id)) - if (this->IsUsedItemID(*id) == errDataBrowserItemNotFound) + if (IsUsedItemID(*id) == errDataBrowserItemNotFound) return noErr; // as the first approach was not successful, try from the beginning: for (*id=0; *idIsUsedItemID(*id) == errDataBrowserItemNotFound) + if (IsUsedItemID(*id) == errDataBrowserItemNotFound) return noErr; // sorry, data browser is full: return errDataBrowserItemNotAdded; } -} /* wxMacDataBrowserTableViewControl::GetFreeItemID(DataBrowserItemID*) const */ +} OSStatus wxMacDataBrowserTableViewControl::GetItemCount(DataBrowserItemID container, Boolean recurse, DataBrowserItemState state, ItemCount* numItems) const { - return GetDataBrowserItemCount(this->m_controlRef,container,recurse,state,numItems); -} /* wxMacDataBrowserTableViewControl::GetItemCount(DataBrowserItemID, Boolean, DataBrowserItemState, ItemCount*) const */ + return GetDataBrowserItemCount(m_controlRef,container,recurse,state,numItems); +} OSStatus wxMacDataBrowserTableViewControl::GetItemID( DataBrowserTableViewRowIndex row, DataBrowserItemID * item ) const { - return GetDataBrowserTableViewItemID(this->m_controlRef,row,item); + return GetDataBrowserTableViewItemID(m_controlRef,row,item); } OSStatus wxMacDataBrowserTableViewControl::GetItems(DataBrowserItemID container, Boolean recurse, DataBrowserItemState state, Handle items) const { - return GetDataBrowserItems(this->m_controlRef,container,recurse,state,items); -} /* wxMacDataBrowserTableViewControl::GetItems(DataBrowserItemID, Boolean, DataBrowserItemState, Handle) const */ + return GetDataBrowserItems(m_controlRef,container,recurse,state,items); +} OSStatus wxMacDataBrowserTableViewControl::GetItemRow(DataBrowserItemID item, DataBrowserTableViewRowIndex* row) const { - return GetDataBrowserTableViewItemRow(this->m_controlRef,item,row); + return GetDataBrowserTableViewItemRow(m_controlRef,item,row); } OSStatus wxMacDataBrowserTableViewControl::GetItemState(DataBrowserItemID item, DataBrowserItemState* state) const { - return ::GetDataBrowserItemState(this->m_controlRef,item,state); + return ::GetDataBrowserItemState(m_controlRef,item,state); } OSStatus wxMacDataBrowserTableViewControl::IsUsedItemID(DataBrowserItemID itemID) const @@ -672,24 +693,24 @@ OSStatus wxMacDataBrowserTableViewControl::IsUsedItemID(DataBrowserItemID itemID // 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 */ + + return ::GetDataBrowserTableViewItemRow(m_controlRef,itemID,&index); +} OSStatus wxMacDataBrowserTableViewControl::RemoveItems(DataBrowserItemID container, UInt32 numItems, DataBrowserItemID const* items, DataBrowserPropertyID preSortProperty) { - return ::RemoveDataBrowserItems(this->m_controlRef,container,numItems,items,preSortProperty); + return ::RemoveDataBrowserItems(m_controlRef,container,numItems,items,preSortProperty); } OSStatus wxMacDataBrowserTableViewControl::RevealItem(DataBrowserItemID item, DataBrowserPropertyID propertyID, DataBrowserRevealOptions options) const { - return ::RevealDataBrowserItem(this->m_controlRef,item,propertyID,options); -} /* wxMacDataBrowserTableViewControl::RevealItem(DataBrowserItemID item, DataBrowserPropertyID propertyID, DataBrowserRevealOptions options) const */ + return ::RevealDataBrowserItem(m_controlRef,item,propertyID,options); +} OSStatus wxMacDataBrowserTableViewControl::UpdateItems(DataBrowserItemID container, UInt32 numItems, DataBrowserItemID const* items, DataBrowserPropertyID preSortProperty, DataBrowserPropertyID propertyID) const { - return UpdateDataBrowserItems(this->m_controlRef,container,numItems,items,preSortProperty,propertyID); + return UpdateDataBrowserItems(m_controlRef,container,numItems,items,preSortProperty,propertyID); } // @@ -699,11 +720,11 @@ size_t wxMacDataBrowserTableViewControl::GetSelectedItemIDs(wxArrayDataBrowserIt { DataBrowserItemID* itemIDPtr; Handle handle(::NewHandle(0)); - + size_t noOfItems; - wxCHECK_MSG(this->GetItems(kDataBrowserNoItem,true,kDataBrowserItemIsSelected,handle) == noErr,0,_("Could not get selected items.")); + wxCHECK_MSG(GetItems(kDataBrowserNoItem,true,kDataBrowserItemIsSelected,handle) == noErr,0,_("Could not get selected items.")); noOfItems = static_cast(::GetHandleSize(handle)/sizeof(DataBrowserItemID)); itemIDs.Empty(); itemIDs.Alloc(noOfItems); @@ -717,56 +738,56 @@ size_t wxMacDataBrowserTableViewControl::GetSelectedItemIDs(wxArrayDataBrowserIt HUnlock(handle); DisposeHandle(handle); return noOfItems; -} /* wxMacDataBrowserTableViewControl::GetSelectedItemIDs(wxArrayDataBrowserItemID&) const*/ +} OSStatus wxMacDataBrowserTableViewControl::GetSelectionAnchor(DataBrowserItemID* first, DataBrowserItemID* last) const { - return ::GetDataBrowserSelectionAnchor(this->m_controlRef,first,last); -} /* wxMacDataBrowserTableViewControl::GetSelectionAnchor(DataBrowserItemID*, DataBrowserItemID*) const */ + return ::GetDataBrowserSelectionAnchor(m_controlRef,first,last); +} OSStatus wxMacDataBrowserTableViewControl::GetSelectionFlags(DataBrowserSelectionFlags* flags) const { - return ::GetDataBrowserSelectionFlags(this->m_controlRef,flags); -} /* wxMacDataBrowserTableViewControl::GetSelectionFlags(DataBrowserSelectionFlags*) const */ + return ::GetDataBrowserSelectionFlags(m_controlRef,flags); +} bool wxMacDataBrowserTableViewControl::IsItemSelected(DataBrowserItemID item) const { - return ::IsDataBrowserItemSelected(this->m_controlRef,item); -} /* wxMacDataBrowserTableViewControl::IsItemSelected(DataBrowserItemID) const */ + return ::IsDataBrowserItemSelected(m_controlRef,item); +} OSStatus wxMacDataBrowserTableViewControl::SetSelectionFlags(DataBrowserSelectionFlags flags) { - return ::SetDataBrowserSelectionFlags(this->m_controlRef,flags); -} /* wxMacDataBrowserTableViewControl::SetSelectionFlags(DataBrowserSelectionFlags) */ + return ::SetDataBrowserSelectionFlags(m_controlRef,flags); +} OSStatus wxMacDataBrowserTableViewControl::SetSelectedItems(UInt32 numItems, DataBrowserItemID const* items, DataBrowserSetOption operation) { - return ::SetDataBrowserSelectedItems(this->m_controlRef, numItems, items, operation ); -} /* wxMacDataBrowserTableViewControl::SetSelectedItems(UInt32, DataBrowserItemID const*, DataBrowserSetOption) */ + return ::SetDataBrowserSelectedItems(m_controlRef, numItems, items, operation ); +} OSStatus wxMacDataBrowserTableViewControl::GetSortOrder(DataBrowserSortOrder* order) const { - return ::GetDataBrowserSortOrder(this->m_controlRef,order); + return ::GetDataBrowserSortOrder(m_controlRef,order); } OSStatus wxMacDataBrowserTableViewControl::GetSortProperty(DataBrowserPropertyID* propertyID) const { - return ::GetDataBrowserSortProperty(this->m_controlRef,propertyID); + return ::GetDataBrowserSortProperty(m_controlRef,propertyID); } OSStatus wxMacDataBrowserTableViewControl::Resort(DataBrowserItemID container, Boolean sortChildren) { - return ::SortDataBrowserContainer(this->m_controlRef,container,sortChildren); -} /* wxMacDataBrowserTableViewControl::Resort(DataBrowserItemID, Boolean) */ + return ::SortDataBrowserContainer(m_controlRef,container,sortChildren); +} OSStatus wxMacDataBrowserTableViewControl::SetSortOrder(DataBrowserSortOrder order) { - return ::SetDataBrowserSortOrder(this->m_controlRef,order); + return ::SetDataBrowserSortOrder(m_controlRef,order); } OSStatus wxMacDataBrowserTableViewControl::SetSortProperty(DataBrowserPropertyID propertyID) { - return ::SetDataBrowserSortProperty(this->m_controlRef,propertyID); + return ::SetDataBrowserSortProperty(m_controlRef,propertyID); } // @@ -774,13 +795,13 @@ OSStatus wxMacDataBrowserTableViewControl::SetSortProperty(DataBrowserPropertyID // OSStatus wxMacDataBrowserTableViewControl::CloseContainer(DataBrowserItemID containerID) { - return ::CloseDataBrowserContainer(this->m_controlRef,containerID); -} /* wxMacDataBrowserTableViewControl::CloseContainer(DataBrowserItemID) */ + return ::CloseDataBrowserContainer(m_controlRef,containerID); +} OSStatus wxMacDataBrowserTableViewControl::OpenContainer(DataBrowserItemID containerID) { - return ::OpenDataBrowserContainer(this->m_controlRef,containerID); -} /* wxMacDataBrowserTableViewControl::OpenContainer(DataBrowserItemID) */ + return ::OpenDataBrowserContainer(m_controlRef,containerID); +} IMPLEMENT_ABSTRACT_CLASS(wxMacDataBrowserTableViewControl,wxMacControl) @@ -793,8 +814,8 @@ IMPLEMENT_ABSTRACT_CLASS(wxMacDataBrowserTableViewControl,wxMacControl) // OSStatus wxMacDataBrowserListViewControl::AddColumn(DataBrowserListViewColumnDesc *columnDesc, DataBrowserTableViewColumnIndex position) { - return AddDataBrowserListViewColumn(this->m_controlRef,columnDesc,position); -} /* wxMacDataBrowserListViewControl::AddColumn(DataBrowserListViewColumnDesc*, DataBrowserTableViewColumnIndex) */ + return AddDataBrowserListViewColumn(m_controlRef,columnDesc,position); +} // ============================================================================ // wxMacDataViewDataBrowserListViewControl @@ -807,33 +828,33 @@ wxMacDataViewDataBrowserListViewControl::wxMacDataViewDataBrowserListViewControl :wxMacDataBrowserListViewControl(peer,pos,size,style) { if ((style & wxBORDER_NONE) != 0) - this->SetData(kControlNoPart,kControlDataBrowserIncludesFrameAndFocusTag,(Boolean) false); - (void) this->EnableAutomaticDragTracking(); - (void) this->SetHiliteStyle(kDataBrowserTableViewFillHilite); -} /* wxMacDataViewDataBrowserListViewControl::wxMacDataViewDataBrowserListViewControl(wxWindow* , const wxPoint&, const wxSize&, long) */ + SetData(kControlNoPart,kControlDataBrowserIncludesFrameAndFocusTag,(Boolean) false); + (void) EnableAutomaticDragTracking(); + (void) SetHiliteStyle(kDataBrowserTableViewFillHilite); +} // // column related methods (inherited from wxDataViewWidgetImpl) // -bool wxMacDataViewDataBrowserListViewControl::ClearColumns(void) +bool wxMacDataViewDataBrowserListViewControl::ClearColumns() { UInt32 noOfColumns; - - - wxCHECK_MSG(this->GetColumnCount(&noOfColumns) == noErr,false,_("Could not determine number of columns.")); + + + wxCHECK_MSG(GetColumnCount(&noOfColumns) == noErr,false,_("Could not determine number of columns.")); for (UInt32 i=0; iRemoveColumnByIndex(0) == noErr,false,_("Could not remove column.")); + wxCHECK_MSG(RemoveColumnByIndex(0) == noErr,false,_("Could not remove column.")); return true; } bool wxMacDataViewDataBrowserListViewControl::DeleteColumn(wxDataViewColumn* columnPtr) { - return (this->RemoveColumnByProperty(columnPtr->GetNativeData()->GetPropertyID()) == noErr); + return (RemoveColumnByProperty(columnPtr->GetNativeData()->GetPropertyID()) == noErr); } void wxMacDataViewDataBrowserListViewControl::DoSetExpanderColumn(wxDataViewColumn const* columnPtr) { - this->SetDisclosureColumn(columnPtr->GetNativeData()->GetPropertyID(),false); // second parameter explicitely passed to ensure that arrow is centered + SetDisclosureColumn(columnPtr->GetNativeData()->GetPropertyID(),false); // second parameter explicitely passed to ensure that arrow is centered } wxDataViewColumn* wxMacDataViewDataBrowserListViewControl::GetColumn(unsigned int pos) const @@ -841,8 +862,8 @@ wxDataViewColumn* wxMacDataViewDataBrowserListViewControl::GetColumn(unsigned in DataBrowserPropertyID propertyID; - if (this->GetPropertyID(pos,&propertyID) == noErr) - return this->GetColumnPtr(propertyID); + if (GetPropertyID(pos,&propertyID) == noErr) + return GetColumnPtr(propertyID); else return NULL; } @@ -853,7 +874,7 @@ int wxMacDataViewDataBrowserListViewControl::GetColumnPosition(wxDataViewColumn { DataBrowserTableViewColumnIndex Position; - wxCHECK_MSG(this->GetColumnIndex(columnPtr->GetNativeData()->GetPropertyID(),&Position) == noErr,wxNOT_FOUND,_("Could not determine column's position")); + wxCHECK_MSG(GetColumnIndex(columnPtr->GetNativeData()->GetPropertyID(),&Position) == noErr,wxNOT_FOUND,_("Could not determine column's position")); return static_cast(Position); } else @@ -868,28 +889,28 @@ bool wxMacDataViewDataBrowserListViewControl::InsertColumn(unsigned int pos, wxD UInt32 noOfColumns; - wxCFStringRef title(columnPtr->GetTitle(),m_font.Ok() ? dynamic_cast(this->GetWXPeer())->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()); + wxCFStringRef title(columnPtr->GetTitle(),m_font.Ok() ? dynamic_cast(GetWXPeer())->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()); // try to get new ID for the column: - wxCHECK_MSG(this->GetFreePropertyID(&newPropertyID) == noErr,false,_("Cannot create new column's ID. Probably max. number of columns reached.")); + wxCHECK_MSG(GetFreePropertyID(&newPropertyID) == noErr,false,_("Cannot create new column's ID. Probably max. number of columns reached.")); // set native data: columnPtr->GetNativeData()->SetPropertyID(newPropertyID); // create a column description, add column to the native control and do some final layout adjustments: wxCHECK_MSG(::InitializeColumnDescription(columnDescription,columnPtr,title), false,_("Column description could not be initialized.")); - wxCHECK_MSG(this->AddColumn(&columnDescription,pos) == noErr, false,_("Column could not be added.")); - wxCHECK_MSG(this->SetColumnWidth(newPropertyID,columnPtr->GetWidth()) == noErr,false,_("Column width could not be set.")); - wxCHECK_MSG(this->GetColumnCount(&noOfColumns) == noErr, false,_("Number of columns could not be determined.")); + wxCHECK_MSG(AddColumn(&columnDescription,pos) == noErr, false,_("Column could not be added.")); + wxCHECK_MSG(SetColumnWidth(newPropertyID,columnPtr->GetWidth()) == noErr,false,_("Column width could not be set.")); + wxCHECK_MSG(GetColumnCount(&noOfColumns) == noErr, false,_("Number of columns could not be determined.")); if (noOfColumns == 1) { - wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast(this->GetWXPeer())); - + wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast(GetWXPeer())); + wxCHECK_MSG(dataViewCtrlPtr != NULL,false,_("wxWidget's control not initialized.")); dataViewCtrlPtr->AddChildren(wxDataViewItem()); return true; } else - return this->Update(columnPtr); + return Update(columnPtr); } // @@ -900,8 +921,8 @@ bool wxMacDataViewDataBrowserListViewControl::Add(wxDataViewItem const& parent, DataBrowserItemID itemID(reinterpret_cast(item.GetID())); - return (( parent.IsOk() && this->AddItem(reinterpret_cast(parent.GetID()),&itemID) == noErr) || - (!(parent.IsOk()) && this->AddItem(kDataBrowserNoItem,&itemID) == noErr)); + return (( parent.IsOk() && AddItem(reinterpret_cast(parent.GetID()),&itemID) == noErr) || + (!(parent.IsOk()) && AddItem(kDataBrowserNoItem,&itemID) == noErr)); } bool wxMacDataViewDataBrowserListViewControl::Add(wxDataViewItem const& parent, wxDataViewItemArray const& items) @@ -917,8 +938,8 @@ bool wxMacDataViewDataBrowserListViewControl::Add(wxDataViewItem const& parent, itemIDs = ::CreateDataBrowserItemIDArray(noOfEntries,items); // insert all valid items into control: noFailureFlag = ((noOfEntries == 0) || - !(parent.IsOk()) && (this->AddItems(kDataBrowserNoItem,noOfEntries,itemIDs,kDataBrowserItemNoProperty) == noErr) || - parent.IsOk() && (this->AddItems(reinterpret_cast(parent.GetID()),noOfEntries,itemIDs,kDataBrowserItemNoProperty) == noErr)); + !(parent.IsOk()) && (AddItems(kDataBrowserNoItem,noOfEntries,itemIDs,kDataBrowserItemNoProperty) == noErr) || + parent.IsOk() && (AddItems(reinterpret_cast(parent.GetID()),noOfEntries,itemIDs,kDataBrowserItemNoProperty) == noErr)); // give allocated array space free again: delete[] itemIDs; // done: @@ -927,7 +948,7 @@ bool wxMacDataViewDataBrowserListViewControl::Add(wxDataViewItem const& parent, void wxMacDataViewDataBrowserListViewControl::Collapse(wxDataViewItem const& item) { - this->CloseContainer(reinterpret_cast(item.GetID())); + CloseContainer(reinterpret_cast(item.GetID())); } void wxMacDataViewDataBrowserListViewControl::EnsureVisible(wxDataViewItem const& item, const wxDataViewColumn* columnPtr) @@ -939,20 +960,20 @@ void wxMacDataViewDataBrowserListViewControl::EnsureVisible(wxDataViewItem const propertyID = columnPtr->GetNativeData()->GetPropertyID(); else propertyID = kDataBrowserNoItem; - this->RevealItem(reinterpret_cast(item.GetID()),propertyID,kDataBrowserRevealOnly); + RevealItem(reinterpret_cast(item.GetID()),propertyID,kDataBrowserRevealOnly); } void wxMacDataViewDataBrowserListViewControl::Expand(wxDataViewItem const& item) { - this->OpenContainer(reinterpret_cast(item.GetID())); + OpenContainer(reinterpret_cast(item.GetID())); } -unsigned int wxMacDataViewDataBrowserListViewControl::GetCount(void) const +unsigned int wxMacDataViewDataBrowserListViewControl::GetCount() const { ItemCount noOfItems; - wxCHECK_MSG(this->GetItemCount(&noOfItems) == noErr,0,_("Could not determine number of items")); + wxCHECK_MSG(GetItemCount(&noOfItems) == noErr,0,_("Could not determine number of items")); return noOfItems; } @@ -961,7 +982,7 @@ wxRect wxMacDataViewDataBrowserListViewControl::GetRectangle(wxDataViewItem cons Rect MacRectangle; - if (this->GetPartBounds(reinterpret_cast(item.GetID()),columnPtr->GetNativeData()->GetPropertyID(),kDataBrowserPropertyContentPart,&MacRectangle) == noErr) + if (GetPartBounds(reinterpret_cast(item.GetID()),columnPtr->GetNativeData()->GetPropertyID(),kDataBrowserPropertyContentPart,&MacRectangle) == noErr) { wxRect rectangle; @@ -974,24 +995,25 @@ wxRect wxMacDataViewDataBrowserListViewControl::GetRectangle(wxDataViewItem cons bool wxMacDataViewDataBrowserListViewControl::IsExpanded(wxDataViewItem const& item) const { - DataBrowserItemState state; + DataBrowserItemState state = 0; + if (GetItemState(reinterpret_cast(item.GetID()),&state) != noErr) + return false; - return ((this->GetItemState(reinterpret_cast(item.GetID()),&state) == noErr) && - (state & kDataBrowserContainerIsOpen != 0)); + return ((state & kDataBrowserContainerIsOpen) != 0); } -bool wxMacDataViewDataBrowserListViewControl::Reload(void) +bool wxMacDataViewDataBrowserListViewControl::Reload() { bool noFailureFlag; wxDataViewItemArray dataViewChildren; - noFailureFlag = (this->RemoveItems() == noErr); - this->SetScrollPosition(0,0); // even after having removed all items the scrollbars may remain at their old position -> reset them - this->GetDataViewCtrl()->GetModel()->GetChildren(wxDataViewItem(),dataViewChildren); - this->GetDataViewCtrl()->GetModel()->ItemsAdded(wxDataViewItem(),dataViewChildren); + noFailureFlag = (RemoveItems() == noErr); + SetScrollPosition(0,0); // even after having removed all items the scrollbars may remain at their old position -> reset them + GetDataViewCtrl()->GetModel()->GetChildren(wxDataViewItem(),dataViewChildren); + GetDataViewCtrl()->GetModel()->ItemsAdded(wxDataViewItem(),dataViewChildren); return noFailureFlag; } @@ -1001,7 +1023,7 @@ bool wxMacDataViewDataBrowserListViewControl::Remove(wxDataViewItem const& paren DataBrowserItemID itemID(reinterpret_cast(item.GetID())); - return (this->RemoveItem(reinterpret_cast(parent.GetID()),&itemID) == noErr); + return (RemoveItem(reinterpret_cast(parent.GetID()),&itemID) == noErr); } bool wxMacDataViewDataBrowserListViewControl::Remove(wxDataViewItem const& parent, wxDataViewItemArray const& items) @@ -1017,8 +1039,8 @@ bool wxMacDataViewDataBrowserListViewControl::Remove(wxDataViewItem const& paren itemIDs = ::CreateDataBrowserItemIDArray(noOfEntries,items); // insert all valid items into control: noFailureFlag = ((noOfEntries == 0) || - !(parent.IsOk()) && (this->RemoveItems(kDataBrowserNoItem,noOfEntries,itemIDs,kDataBrowserItemNoProperty) == noErr) || - parent.IsOk() && (this->RemoveItems(reinterpret_cast(parent.GetID()),noOfEntries,itemIDs,kDataBrowserItemNoProperty) == noErr)); + !(parent.IsOk()) && (RemoveItems(kDataBrowserNoItem,noOfEntries,itemIDs,kDataBrowserItemNoProperty) == noErr) || + parent.IsOk() && (RemoveItems(reinterpret_cast(parent.GetID()),noOfEntries,itemIDs,kDataBrowserItemNoProperty) == noErr)); // give allocated array space free again: delete[] itemIDs; // done: @@ -1027,7 +1049,7 @@ bool wxMacDataViewDataBrowserListViewControl::Remove(wxDataViewItem const& paren bool wxMacDataViewDataBrowserListViewControl::Update(wxDataViewColumn const* columnPtr) { - return (this->UpdateItems(kDataBrowserNoItem,0,NULL,kDataBrowserItemNoProperty,columnPtr->GetNativeData()->GetPropertyID()) == noErr); + return (UpdateItems(kDataBrowserNoItem,0,NULL,kDataBrowserItemNoProperty,columnPtr->GetNativeData()->GetPropertyID()) == noErr); } bool wxMacDataViewDataBrowserListViewControl::Update(wxDataViewItem const& parent, wxDataViewItem const& item) @@ -1036,9 +1058,9 @@ bool wxMacDataViewDataBrowserListViewControl::Update(wxDataViewItem const& paren if (parent.IsOk()) - return (this->UpdateItem(reinterpret_cast(parent.GetID()),&itemID) == noErr); + return (UpdateItem(reinterpret_cast(parent.GetID()),&itemID) == noErr); else - return (this->UpdateItem(kDataBrowserNoItem,&itemID) == noErr); + return (UpdateItem(kDataBrowserNoItem,&itemID) == noErr); } bool wxMacDataViewDataBrowserListViewControl::Update(wxDataViewItem const& parent, wxDataViewItemArray const& items) @@ -1053,9 +1075,9 @@ bool wxMacDataViewDataBrowserListViewControl::Update(wxDataViewItem const& paren // convert all valid data view items to data browser items: itemIDs = ::CreateDataBrowserItemIDArray(noOfEntries,items); if (parent.IsOk()) - noFailureFlag = (this->UpdateItems(reinterpret_cast(parent.GetID()),noOfEntries,itemIDs,kDataBrowserItemNoProperty,kDataBrowserItemNoProperty) == noErr); + noFailureFlag = (UpdateItems(reinterpret_cast(parent.GetID()),noOfEntries,itemIDs,kDataBrowserItemNoProperty,kDataBrowserItemNoProperty) == noErr); else - noFailureFlag = (this->UpdateItems(kDataBrowserNoItem,noOfEntries,itemIDs,kDataBrowserItemNoProperty,kDataBrowserItemNoProperty) == noErr); + noFailureFlag = (UpdateItems(kDataBrowserNoItem,noOfEntries,itemIDs,kDataBrowserItemNoProperty,kDataBrowserItemNoProperty) == noErr); // release allocated array space: delete[] itemIDs; // done: @@ -1080,7 +1102,7 @@ int wxMacDataViewDataBrowserListViewControl::GetSelections(wxDataViewItemArray& wxArrayDataBrowserItemID itemIDs; - noOfSelectedItems = this->GetSelectedItemIDs(itemIDs); + noOfSelectedItems = GetSelectedItemIDs(itemIDs); sel.Empty(); sel.SetCount(noOfSelectedItems); for (size_t i=0; iIsItemSelected(reinterpret_cast(item.GetID())); + return IsItemSelected(reinterpret_cast(item.GetID())); } void wxMacDataViewDataBrowserListViewControl::Select(wxDataViewItem const& item) @@ -1098,10 +1120,10 @@ void wxMacDataViewDataBrowserListViewControl::Select(wxDataViewItem const& item) DataBrowserItemID itemID(reinterpret_cast(item.GetID())); - this->SetSelectedItems(1,&itemID,kDataBrowserItemsAdd); + SetSelectedItems(1,&itemID,kDataBrowserItemsAdd); } -void wxMacDataViewDataBrowserListViewControl::SelectAll(void) +void wxMacDataViewDataBrowserListViewControl::SelectAll() { DataBrowserItemID* itemIDPtr; @@ -1110,11 +1132,11 @@ void wxMacDataViewDataBrowserListViewControl::SelectAll(void) size_t noOfItems; - wxCHECK_RET(this->GetItems(kDataBrowserNoItem,true,kDataBrowserItemAnyState,handle) == noErr,_("Could not get items.")); + wxCHECK_RET(GetItems(kDataBrowserNoItem,true,kDataBrowserItemAnyState,handle) == noErr,_("Could not get items.")); noOfItems = static_cast(::GetHandleSize(handle)/sizeof(DataBrowserItemID)); ::HLock(handle); itemIDPtr = (DataBrowserItemID*) (*handle); - this->SetSelectedItems(noOfItems,itemIDPtr,kDataBrowserItemsAssign); + SetSelectedItems(noOfItems,itemIDPtr,kDataBrowserItemsAssign); ::HUnlock(handle); ::DisposeHandle(handle); } @@ -1124,10 +1146,10 @@ void wxMacDataViewDataBrowserListViewControl::Unselect(wxDataViewItem const& ite DataBrowserItemID itemID(reinterpret_cast(item.GetID())); - this->SetSelectedItems(1,&itemID,kDataBrowserItemsRemove); + SetSelectedItems(1,&itemID,kDataBrowserItemsRemove); } -void wxMacDataViewDataBrowserListViewControl::UnselectAll(void) +void wxMacDataViewDataBrowserListViewControl::UnselectAll() { DataBrowserItemID* itemIDPtr; @@ -1136,11 +1158,11 @@ void wxMacDataViewDataBrowserListViewControl::UnselectAll(void) size_t noOfItems; - wxCHECK_RET(this->GetItems(kDataBrowserNoItem,true,kDataBrowserItemAnyState,handle) == noErr,_("Could not get items.")); + wxCHECK_RET(GetItems(kDataBrowserNoItem,true,kDataBrowserItemAnyState,handle) == noErr,_("Could not get items.")); noOfItems = static_cast(::GetHandleSize(handle)/sizeof(DataBrowserItemID)); ::HLock(handle); itemIDPtr = (DataBrowserItemID*) (*handle); - this->SetSelectedItems(noOfItems,itemIDPtr,kDataBrowserItemsRemove); + SetSelectedItems(noOfItems,itemIDPtr,kDataBrowserItemsRemove); ::HUnlock(handle); ::DisposeHandle(handle); } @@ -1148,26 +1170,29 @@ void wxMacDataViewDataBrowserListViewControl::UnselectAll(void) // // sorting related methods // -wxDataViewColumn* wxMacDataViewDataBrowserListViewControl::GetSortingColumn(void) const +wxDataViewColumn* wxMacDataViewDataBrowserListViewControl::GetSortingColumn() const { DataBrowserPropertyID propertyID; - if (this->GetSortProperty(&propertyID) == noErr) - return this->GetColumnPtr(propertyID); + if (GetSortProperty(&propertyID) == noErr) + return GetColumnPtr(propertyID); else return NULL; } -void wxMacDataViewDataBrowserListViewControl::Resort(void) +void wxMacDataViewDataBrowserListViewControl::Resort() { - (void) this->Resort(); + (void) Resort(); } // // 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(); @@ -1176,27 +1201,27 @@ void wxMacDataViewDataBrowserListViewControl::HitTest(wxPoint const& point, wxDa void wxMacDataViewDataBrowserListViewControl::DoSetIndent(int indent) { - this->SetIndent(static_cast(indent)); + SetIndent(static_cast(indent)); } void wxMacDataViewDataBrowserListViewControl::SetRowHeight(wxDataViewItem const& item, unsigned int height) { - this->SetItemRowHeight(reinterpret_cast(item.GetID()),static_cast(height)); + SetItemRowHeight(reinterpret_cast(item.GetID()),static_cast(height)); } -void wxMacDataViewDataBrowserListViewControl::OnSize(void) +void wxMacDataViewDataBrowserListViewControl::OnSize() { UInt32 noOfColumns; - - - this->GetColumnCount(&noOfColumns); + + + GetColumnCount(&noOfColumns); if (noOfColumns <= 1) // no horizontal scroll bar and the only column expands to the width of the whole control { - this->SetHasScrollBars(false,true); - this->AutoSizeColumns(); + SetHasScrollBars(false,true); + AutoSizeColumns(); } else // otherwise keep the current column size and have scrollbars in both directions - this->SetHasScrollBars(true,true); + SetHasScrollBars(true,true); } // @@ -1207,33 +1232,33 @@ Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserCompareProc(DataBrow DataBrowserSortOrder sortOrder; DataBrowserTableViewColumnIndex modelColumnIndex; - - wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast(this->GetWXPeer())); - + + wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast(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.")); if (sortProperty >= kMinPropertyID) { // variable definition and initialization: - wxDataViewColumn* ColumnPtr(this->GetColumnPtr(sortProperty)); - + wxDataViewColumn* ColumnPtr(GetColumnPtr(sortProperty)); + wxCHECK_MSG(ColumnPtr != NULL,false,_("Could not determine column index.")); modelColumnIndex = ColumnPtr->GetModelColumn(); } else modelColumnIndex = 0; - this->GetSortOrder(&sortOrder); + GetSortOrder(&sortOrder); return static_cast(dataViewCtrlPtr->GetModel()->Compare(wxDataViewItem(reinterpret_cast(itemOneID)),wxDataViewItem(reinterpret_cast(itemTwoID)), modelColumnIndex,sortOrder != kDataBrowserOrderDecreasing) < 0); -} /* wxMacDataViewDataBrowserListViewControl::DataBrowserCompareProc(DataBrowserItemID, DataBrowserItemID, DataBrowserPropertyID) */ +} void wxMacDataViewDataBrowserListViewControl::DataBrowserGetContextualMenuProc(MenuRef* menu, UInt32* helpType, CFStringRef* helpItemString, AEDesc* WXUNUSED(selection)) // In this method we do not supply a contextual menu handler at all but only send a wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU. { wxArrayDataBrowserItemID itemIDs; - wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast(this->GetWXPeer())); + wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast(GetWXPeer())); wxCHECK_RET(dataViewCtrlPtr != NULL,_("wxWidget control pointer is not a data view pointer")); @@ -1248,11 +1273,11 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserGetContextualMenuProc(M dataViewEvent.SetModel(dataViewCtrlPtr->GetModel()); // get the item information; // theoretically more than one ID can be returned but the event can only handle one item, therefore all item related data is using the data of the first item in the array: - if (this->GetSelectedItemIDs(itemIDs) > 0) + if (GetSelectedItemIDs(itemIDs) > 0) dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast(itemIDs[0]))); // finally send the equivalent wxWidget event: dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent); -} /* wxMacDataViewDataBrowserListViewControl::DataBrowserGetContextualMenuProc(MenuRef*, UInt32*, CFStringRef*, AEDesc*) */ +} OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, DataBrowserItemDataRef itemData, Boolean getValue) { @@ -1260,8 +1285,8 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc( { // variable definitions: wxDataViewCtrl* dataViewCtrlPtr; - - dataViewCtrlPtr = dynamic_cast(this->GetWXPeer()); + + dataViewCtrlPtr = dynamic_cast(GetWXPeer()); wxCHECK_MSG(dataViewCtrlPtr != NULL,errDataBrowserNotConfigured,_("Pointer to data view control not set correctly.")); if (dataViewCtrlPtr->IsDeleting()) return noErr; // if a delete process is running the data of editable fields cannot be saved because the associated model variable may already have been deleted @@ -1270,14 +1295,14 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc( // variable definitions: OSStatus errorStatus; wxDataViewColumn* dataViewColumnPtr; - + wxCHECK_MSG(dataViewCtrlPtr->GetModel() != NULL,errDataBrowserNotConfigured,_("Pointer to model not set correctly.")); - dataViewColumnPtr = this->GetColumnPtr(propertyID); + dataViewColumnPtr = 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(itemID)); unsigned int col = dataViewColumnPtr->GetModelColumn(); - + switch (dataViewColumnPtr->GetRenderer()->GetNativeData()->GetPropertyType()) { case kDataBrowserCheckboxType: @@ -1293,8 +1318,7 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc( // variable definition and initialization: wxVariant modifiedData(true); - if (dataViewCtrlPtr->GetModel()->SetValue(modifiedData, dvItem, col) && - dataViewCtrlPtr->GetModel()->ValueChanged(dvItem, col)) + if (dataViewCtrlPtr->GetModel()->ChangeValue(modifiedData, dvItem, col)) return noErr; else return errDataBrowserInvalidPropertyData; @@ -1304,8 +1328,7 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc( // variable definition and initialization: wxVariant modifiedData(false); - if (dataViewCtrlPtr->GetModel()->SetValue(modifiedData, dvItem, col) && - dataViewCtrlPtr->GetModel()->ValueChanged(dvItem, col)) + if (dataViewCtrlPtr->GetModel()->ChangeValue(modifiedData, dvItem, col)) return noErr; else return errDataBrowserInvalidPropertyData; @@ -1331,9 +1354,8 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc( wxMacCFStringHolder modifiedString(stringReference); #endif wxVariant modifiedData(modifiedString.AsString()); - - if (dataViewCtrlPtr->GetModel()->SetValue(modifiedData, dvItem, col) && - dataViewCtrlPtr->GetModel()->ValueChanged(dvItem, col)) + + if (dataViewCtrlPtr->GetModel()->ChangeValue(modifiedData, dvItem, col)) return noErr; else return errDataBrowserInvalidPropertyData; @@ -1354,11 +1376,11 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc( wxVariant variant; wxDataViewColumn* dataViewColumnPtr; wxDataViewCtrl* dataViewCtrlPtr; - - dataViewCtrlPtr = dynamic_cast(this->GetWXPeer()); + + dataViewCtrlPtr = dynamic_cast(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 = this->GetColumnPtr(propertyID); + dataViewColumnPtr = 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(itemID)),dataViewColumnPtr->GetModelColumn()); @@ -1366,7 +1388,7 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc( { 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; } @@ -1377,12 +1399,12 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc( case kDataBrowserContainerIsClosableProperty: { // variable definitions: - wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast(this->GetWXPeer())); - + wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast(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(itemID))); dataViewEvent.SetModel (dataViewCtrlPtr->GetModel()); @@ -1394,8 +1416,8 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc( case kDataBrowserContainerIsOpenableProperty: { // variable definitions: - wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast(this->GetWXPeer())); - + wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast(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 @@ -1411,8 +1433,8 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc( case kDataBrowserItemIsContainerProperty: { // variable definition: - wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast(this->GetWXPeer())); - + wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast(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(itemID)))); @@ -1423,11 +1445,11 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc( } } return errDataBrowserPropertyNotSupported; -} /* wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemDataRef, Boolean) */ +} void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(DataBrowserItemID itemID, DataBrowserItemNotification message, DataBrowserItemDataRef itemData) { - wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast(this->GetWXPeer())); + wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast(GetWXPeer())); // check if the data view control pointer still exists because this call back function can still be called when the control has already been deleted: @@ -1439,7 +1461,7 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(Da { // initialize wxWidget event: wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED,dataViewCtrlPtr->GetId()); // variable definition - + dataViewEvent.SetEventObject(dataViewCtrlPtr); dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast(itemID))); // finally send the equivalent wxWidget event: @@ -1451,7 +1473,7 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(Da { // initialize wxWidget event: wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED,dataViewCtrlPtr->GetId()); // variable definition - + dataViewEvent.SetEventObject(dataViewCtrlPtr); dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast(itemID))); // finally send the equivalent wxWidget event: @@ -1464,19 +1486,19 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(Da 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(itemID))); - if (this->GetPropertyID(itemData,&propertyID) == noErr) + if (GetPropertyID(itemData,&propertyID) == noErr) { // variable definition and initialization: DataBrowserTableViewColumnIndex columnIndex; - - wxCHECK_RET(this->GetColumnIndex(propertyID,&columnIndex),_("Column index not found.")); + + wxCHECK_RET(GetColumnIndex(propertyID,&columnIndex),_("Column index not found.")); dataViewEvent.SetColumn(columnIndex); - dataViewEvent.SetDataViewColumn(this->GetColumnPtr(propertyID)); + dataViewEvent.SetDataViewColumn(GetColumnPtr(propertyID)); } // finally send the equivalent wxWidget event: dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent); @@ -1485,19 +1507,19 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(Da 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(itemID))); - if (this->GetPropertyID(itemData,&propertyID) == noErr) + if (GetPropertyID(itemData,&propertyID) == noErr) { // variable definition and initialization: DataBrowserTableViewColumnIndex columnIndex; - wxCHECK_RET(this->GetColumnIndex(propertyID,&columnIndex),_("Column index not found.")); + wxCHECK_RET(GetColumnIndex(propertyID,&columnIndex),_("Column index not found.")); dataViewEvent.SetColumn(columnIndex); - dataViewEvent.SetDataViewColumn(this->GetColumnPtr(propertyID)); + dataViewEvent.SetDataViewColumn(GetColumnPtr(propertyID)); } // finally send the equivalent wxWidget event: dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent); @@ -1549,19 +1571,19 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(Da 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")); + + wxCHECK_RET(GetColumnWidth(columnPtr->GetNativeData()->GetPropertyID(),&columnWidth) == noErr,_("Column width could not be determined")); columnPtr->SetWidthVariable(columnWidth); } // update sorting orders: DataBrowserPropertyID propertyID; // variable definition - if ((this->GetSortProperty(&propertyID) == noErr) && (propertyID >= kMinPropertyID)) + if ((GetSortProperty(&propertyID) == noErr) && (propertyID >= kMinPropertyID)) { DataBrowserSortOrder sortOrder; DataBrowserTableViewColumnIndex columnIndex; - - if ((this->GetSortOrder(&sortOrder) == noErr) && (this->GetColumnIndex(propertyID,&columnIndex) == noErr)) + + if ((GetSortOrder(&sortOrder) == noErr) && (GetColumnIndex(propertyID,&columnIndex) == noErr)) { // variable definition and initialization: wxDataViewColumn* columnPtr; @@ -1585,25 +1607,31 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(Da } /* block */ break; } -} /* 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; - dataViewCtrlPtr = dynamic_cast(this->GetWXPeer()); + dataViewCtrlPtr = dynamic_cast(GetWXPeer()); wxCHECK_RET(dataViewCtrlPtr != NULL, _("Pointer to data view control not set correctly.")); wxCHECK_RET(dataViewCtrlPtr->GetModel() != NULL, _("Pointer to model not set correctly.")); - wxCHECK_RET(this->GetColumnIndex(propertyID,&columnIndex) == noErr,_("Could not determine column index.")); - dataViewColumnPtr = this->GetColumnPtr(propertyID); + wxCHECK_RET(GetColumnIndex(propertyID,&columnIndex) == noErr,_("Could not determine column index.")); + dataViewColumnPtr = GetColumnPtr(propertyID); wxCHECK_RET(dataViewColumnPtr != NULL,_("No column for the specified column existing.")); dataViewCustomRendererPtr = dynamic_cast(dataViewColumnPtr->GetRenderer()); wxCHECK_RET(dataViewCustomRendererPtr != NULL,_("No renderer or invalid renderer type specified for custom data column.")); @@ -1625,7 +1653,7 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowse GetControlBounds(m_controlRef, &content); ::DisposeRgn(rgn); // space for the header - this->GetHeaderButtonHeight(&headerHeight); + GetHeaderButtonHeight(&headerHeight); content.top += headerHeight; // extra space for the frame (todo: do not how to determine the space automatically from the control) content.top += 5; @@ -1637,83 +1665,83 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowse 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(rectangle->left + active_border_fudge), static_cast(rectangle->top + active_border_fudge), static_cast(1+rectangle->right-rectangle->left), static_cast(rectangle->bottom-rectangle->top) ); - - bool is_active = IsControlActive( this->m_controlRef ); + + bool is_active = IsControlActive( 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, + GetDataBrowserItemPartBounds( 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->WXCallRender( 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*) */ +} Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserHitTestProc(DataBrowserItemID WXUNUSED(itemID), DataBrowserPropertyID WXUNUSED(property), Rect const* WXUNUSED(theRect), Rect const* WXUNUSED(mouseRect)) { return true; -} /* wxMacDataViewDataBrowserListViewControl::DataBrowserHitTestProc(DataBrowserItemID, DataBrowserPropertyID, Rect const*, Rect const*) */ +} DataBrowserTrackingResult wxMacDataViewDataBrowserListViewControl::DataBrowserTrackingProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, Rect const* theRect, Point WXUNUSED(startPt), EventModifiers WXUNUSED(modifiers)) { wxDataViewColumn* dataViewColumnPtr; wxDataViewCtrl* dataViewCtrlPtr; - + wxDataViewCustomRenderer* dataViewCustomRendererPtr; - + wxDataViewItem dataViewCustomRendererItem; - dataViewCtrlPtr = dynamic_cast(this->GetWXPeer()); + dataViewCtrlPtr = dynamic_cast(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.")); dataViewCustomRendererItem = reinterpret_cast(itemID); wxCHECK_MSG(dataViewCustomRendererItem.IsOk(),kDataBrowserNothingHit,_("Invalid data view item")); - dataViewColumnPtr = this->GetColumnPtr(propertyID); + dataViewColumnPtr = GetColumnPtr(propertyID); wxCHECK_MSG(dataViewColumnPtr != NULL,kDataBrowserNothingHit,_("No column existing.")); dataViewCustomRendererPtr = dynamic_cast(dataViewColumnPtr->GetRenderer()); wxCHECK_MSG(dataViewCustomRendererPtr != NULL,kDataBrowserNothingHit,_("No renderer or invalid renderer type specified for custom data column.")); @@ -1732,14 +1760,14 @@ DataBrowserTrackingResult wxMacDataViewDataBrowserListViewControl::DataBrowserTr { // variable definition: wxRect wxRectangle; - + ::wxMacNativeToRect(theRect,&wxRectangle); dataViewCustomRendererPtr->StartEditing(dataViewCustomRendererItem,wxRectangle); dataViewCtrlPtr->SetCustomRendererItem(dataViewCustomRendererItem); dataViewCtrlPtr->SetCustomRendererPtr (dataViewCustomRendererPtr); } return kDataBrowserContentHit; -} /* wxMacDataViewDataBrowserListViewControl::DataBrowserTrackingProc(DataBrowserItemID, DataBrowserPropertyID, Rect const*, Point, EventModifiers) */ +} Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserAcceptDragProc(DragReference dragRef, DataBrowserItemID itemID) { @@ -1750,7 +1778,7 @@ Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserAcceptDragProc(DragR wxDataViewCtrl* dataViewCtrlPtr; - dataViewCtrlPtr = dynamic_cast(this->GetWXPeer()); + dataViewCtrlPtr = dynamic_cast(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.")); @@ -1762,9 +1790,9 @@ Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserAcceptDragProc(DragR ItemReference itemRef; wxDataObjectComposite* dataObjects; wxMemoryBuffer buffer; - + ::GetDragItemReferenceNumber(dragRef,indexDraggedItem,&itemRef); // the index begins with 1! - dataObjects = this->GetDnDDataObjects(dragRef,itemRef); + dataObjects = GetDnDDataObjects(dragRef,itemRef); // create wxWidget's event: wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE,dataViewCtrlPtr->GetId()); @@ -1773,7 +1801,7 @@ Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserAcceptDragProc(DragR // (can be an invalid item ID, this is especially useful if the dataview does not contain any items) dataViewEvent.SetModel(dataViewCtrlPtr->GetModel()); dataViewEvent.SetDataObject(dataObjects); - dataViewEvent.SetDataFormat(this->GetDnDDataFormat(dataObjects)); + dataViewEvent.SetDataFormat(GetDnDDataFormat(dataObjects)); if (dataViewEvent.GetDataFormat().GetType() != wxDF_INVALID) { dataViewEvent.SetDataSize(dataObjects->GetDataSize(dataViewEvent.GetDataFormat().GetType())); @@ -1789,18 +1817,18 @@ Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserAcceptDragProc(DragR return false; } return true; -} /* wxMacDataViewDataBrowserListViewControl::DataBrowserAcceptDragProc(DragReference, DataBrowserItemID) */ +} Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserAddDragItemProc(DragReference dragRef, DataBrowserItemID itemID, ItemReference* itemRef) { Boolean addDragItem; wxDataViewCtrl* dataViewCtrlPtr; - + wxDataViewItem dataViewItem; - dataViewCtrlPtr = dynamic_cast(this->GetWXPeer()); + dataViewCtrlPtr = dynamic_cast(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.")); dataViewItem = reinterpret_cast(itemID); @@ -1816,7 +1844,7 @@ Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserAddDragItemProc(Drag // 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: @@ -1836,12 +1864,12 @@ Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserAddDragItemProc(Drag { // 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; iGetDataSize(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) @@ -1869,14 +1897,14 @@ Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserAddDragItemProc(Drag 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(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); @@ -1914,7 +1942,7 @@ Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserAddDragItemProc(Drag // clean-up and return result: delete dataObject; return addDragItem; -} /* wxMacDataViewDataBrowserListViewControl::DataBrowserAddDragItemProc(DragReference, DataBrowserItemID, ItemReference*) */ +} Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserReceiveDragProc(DragReference dragRef, DataBrowserItemID itemID) { @@ -1923,7 +1951,7 @@ Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserReceiveDragProc(Drag wxDataViewCtrl* dataViewCtrlPtr; - dataViewCtrlPtr = dynamic_cast(this->GetWXPeer()); + dataViewCtrlPtr = dynamic_cast(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.")); @@ -1935,10 +1963,10 @@ Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserReceiveDragProc(Drag ItemReference itemRef; wxDataObjectComposite* dataObjects; wxMemoryBuffer buffer; - + // collect native information: ::GetDragItemReferenceNumber(dragRef,indexDraggedItem,&itemRef); // the index begins with 1! - dataObjects = this->GetDnDDataObjects(dragRef,itemRef); + dataObjects = GetDnDDataObjects(dragRef,itemRef); // create wxWidget's event: wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_DROP,dataViewCtrlPtr->GetId()); @@ -1947,7 +1975,7 @@ Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserReceiveDragProc(Drag // (can be an invalid item ID, this is especially useful if the dataview does not contain any items) dataViewEvent.SetModel(dataViewCtrlPtr->GetModel()); dataViewEvent.SetDataObject(dataObjects); - dataViewEvent.SetDataFormat(this->GetDnDDataFormat(dataObjects)); + dataViewEvent.SetDataFormat(GetDnDDataFormat(dataObjects)); if (dataViewEvent.GetDataFormat().GetType() != wxDF_INVALID) { dataViewEvent.SetDataSize(dataObjects->GetDataSize(dataViewEvent.GetDataFormat().GetType())); @@ -1963,7 +1991,7 @@ Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserReceiveDragProc(Drag return false; } return true; -} /* wxMacDataViewDataBrowserListViewControl::DataBrowserReceiveDragProc(DragReference, DataBrowserItemID) */ +} // // drag & drop helper methods @@ -1981,7 +2009,7 @@ wxDataFormat wxMacDataViewDataBrowserListViewControl::GetDnDDataFormat(wxDataObj 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): @@ -2024,7 +2052,7 @@ wxDataFormat wxMacDataViewDataBrowserListViewControl::GetDnDDataFormat(wxDataObj else resultFormat = wxDF_INVALID; return resultFormat; -} /* wxMacDataViewDataBrowserListViewControl::GetDnDDataFormat(wxDataObjectComposite*) */ +} wxDataObjectComposite* wxMacDataViewDataBrowserListViewControl::GetDnDDataObjects(DragReference dragRef, ItemReference itemRef) const { @@ -2044,7 +2072,7 @@ wxDataObjectComposite* wxMacDataViewDataBrowserListViewControl::GetDnDDataObject { // variable definition: FlavorType flavorDataObject; - + if (::GetFlavorType(dragRef,itemRef,indexFlavor,&flavorDataObject) == noErr) // GetFlavorType uses a 1 based index! switch (flavorDataObject) { @@ -2054,7 +2082,7 @@ wxDataObjectComposite* wxMacDataViewDataBrowserListViewControl::GetDnDDataObject // variable definitions: Size nativeDataSize; wxMemoryBuffer nativeData; - + if ((::GetFlavorDataSize(dragRef,itemRef,'TEXT',&nativeDataSize) == noErr) && (::GetFlavorData(dragRef,itemRef,'TEXT',nativeData.GetWriteBuf(nativeDataSize),&nativeDataSize,0) == noErr)) { @@ -2074,11 +2102,11 @@ wxDataObjectComposite* wxMacDataViewDataBrowserListViewControl::GetDnDDataObject { // 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) @@ -2086,7 +2114,7 @@ wxDataObjectComposite* wxMacDataViewDataBrowserListViewControl::GetDnDDataObject // 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) @@ -2117,19 +2145,19 @@ wxDataObjectComposite* wxMacDataViewDataBrowserListViewControl::GetDnDDataObject else dataObject = NULL; return dataObject; -} /* wxMacDataViewDataBrowserListViewControl::GetDnDDataObjects(DragReference, ItemReference) const */ +} // // other methods // wxDataViewColumn* wxMacDataViewDataBrowserListViewControl::GetColumnPtr(DataBrowserPropertyID propertyID) const { - wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast(this->GetWXPeer())); - + wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast(GetWXPeer())); + if (dataViewCtrlPtr != NULL) { size_t const noOfColumns = dataViewCtrlPtr->GetColumnCount(); - + for (size_t i=0; iGetColumnPtr(i)->GetNativeData()->GetPropertyID() == propertyID) return dataViewCtrlPtr->GetColumnPtr(i); @@ -2145,51 +2173,127 @@ wxDataViewRenderer::wxDataViewRenderer(wxString const& varianttype, wxDataViewCe { } -wxDataViewRenderer::~wxDataViewRenderer(void) +wxDataViewRenderer::~wxDataViewRenderer() { - delete this->m_NativeDataPtr; + delete m_NativeDataPtr; } void wxDataViewRenderer::SetAlignment(int align) { - this->m_alignment = align; + m_alignment = align; } +namespace +{ + +// get the browser control or NULL if anything went wrong (it's not supposed to +// so we assert if it did) +wxMacDataViewDataBrowserListViewControl * +GetBrowserFromCol(wxDataViewColumn *col) +{ + wxCHECK_MSG( col, NULL, "should have a valid column" ); + + wxDataViewCtrl * const dvc = col->GetOwner(); + wxCHECK_MSG( dvc, NULL, "column must be associated with the control" ); + + return static_cast(dvc->GetPeer()); +} + +} // anonymous namespace + void wxDataViewRenderer::SetMode(wxDataViewCellMode mode) { - wxDataViewColumn* dataViewColumnPtr; + wxDataViewColumn * const col = GetOwner(); + wxMacDataViewDataBrowserListViewControl * const + browser = GetBrowserFromCol(col); + wxCHECK_RET( browser, "must be fully initialized" ); + const DataBrowserPropertyID colID = col->GetNativeData()->GetPropertyID(); - m_mode = mode; - dataViewColumnPtr = this->GetOwner(); - if (dataViewColumnPtr != NULL) - { - wxDataViewCtrl* dataViewCtrlPtr(dataViewColumnPtr->GetOwner()); + DataBrowserPropertyFlags flags; + verify_noerr( browser->GetPropertyFlags(colID, &flags) ); - if (dataViewCtrlPtr != NULL) + if ( (mode == wxDATAVIEW_CELL_EDITABLE) || + (mode == wxDATAVIEW_CELL_ACTIVATABLE) ) + flags |= kDataBrowserPropertyIsEditable; + else + flags &= ~kDataBrowserPropertyIsEditable; + + verify_noerr( browser->SetPropertyFlags(colID, flags) ); +} + +void wxDataViewRenderer::EnableEllipsize(wxEllipsizeMode mode) +{ + wxDataViewColumn * const col = GetOwner(); + + wxMacDataViewDataBrowserListViewControl * const + browser = GetBrowserFromCol(col); + wxCHECK_RET( browser, "must be fully initialized" ); + + const DataBrowserPropertyID colID = col->GetNativeData()->GetPropertyID(); + + DataBrowserPropertyFlags flags; + browser->GetPropertyFlags(colID, &flags); + + flags &= ~(kDataBrowserDoNotTruncateText | + kDataBrowserTruncateTextAtStart | + kDataBrowserTruncateTextMiddle | + kDataBrowserTruncateTextAtEnd); + + int flagToSet = 0; + switch ( mode ) { - wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast(dataViewCtrlPtr->GetPeer())); + case wxELLIPSIZE_NONE: + flagToSet = kDataBrowserDoNotTruncateText; + break; - if (macDataViewListCtrlPtr != NULL) - { - DataBrowserPropertyFlags flags; - - verify_noerr(macDataViewListCtrlPtr->GetPropertyFlags(dataViewColumnPtr->GetNativeData()->GetPropertyID(),&flags)); - if ((mode == wxDATAVIEW_CELL_EDITABLE) || - (mode == wxDATAVIEW_CELL_ACTIVATABLE)) - flags |= kDataBrowserPropertyIsEditable; - else - flags &= ~kDataBrowserPropertyIsEditable; - verify_noerr(macDataViewListCtrlPtr->SetPropertyFlags(dataViewColumnPtr->GetNativeData()->GetPropertyID(),flags)); - } + case wxELLIPSIZE_START: + flagToSet = kDataBrowserTruncateTextAtStart; + break; + + case wxELLIPSIZE_MIDDLE: + flagToSet = kDataBrowserTruncateTextMiddle; + break; + + case wxELLIPSIZE_END: + flagToSet = kDataBrowserTruncateTextAtEnd; + break; } - } + + wxCHECK_RET( flagToSet, "unknown wxEllipsizeMode value" ); + + flags |= flagToSet; + verify_noerr( browser->SetPropertyFlags(colID, flags) ); +} + +wxEllipsizeMode wxDataViewRenderer::GetEllipsizeMode() const +{ + wxDataViewColumn * const col = GetOwner(); + + wxMacDataViewDataBrowserListViewControl * const + browser = GetBrowserFromCol(col); + wxCHECK_MSG( browser, wxELLIPSIZE_NONE, "must be fully initialized" ); + + const DataBrowserPropertyID colID = col->GetNativeData()->GetPropertyID(); + + DataBrowserPropertyFlags flags; + browser->GetPropertyFlags(colID, &flags); + + if ( flags & kDataBrowserDoNotTruncateText ) + return wxELLIPSIZE_NONE; + if ( flags & kDataBrowserTruncateTextAtStart ) + return wxELLIPSIZE_START; + if ( flags & kDataBrowserTruncateTextAtEnd ) + return wxELLIPSIZE_END; + + // kDataBrowserTruncateTextMiddle == 0 so there is no need to test for it + return wxELLIPSIZE_MIDDLE; } void wxDataViewRenderer::SetNativeData(wxDataViewRendererNativeData* newNativeDataPtr) { - delete this->m_NativeDataPtr; - this->m_NativeDataPtr = newNativeDataPtr; + delete m_NativeDataPtr; + m_NativeDataPtr = newNativeDataPtr; } IMPLEMENT_ABSTRACT_CLASS(wxDataViewRenderer,wxDataViewRendererBase) @@ -2198,12 +2302,14 @@ IMPLEMENT_ABSTRACT_CLASS(wxDataViewRenderer,wxDataViewRendererBase) // wxDataViewCustomRenderer // --------------------------------------------------------- wxDataViewCustomRenderer::wxDataViewCustomRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align) - :wxDataViewRenderer(varianttype,mode,align), m_editorCtrlPtr(NULL), m_DCPtr(NULL) + :wxDataViewCustomRendererBase(varianttype,mode,align), + m_editorCtrlPtr(NULL), + m_DCPtr(NULL) { - this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserCustomType)); + SetNativeData(new wxDataViewRendererNativeData(kDataBrowserCustomType)); } -bool wxDataViewCustomRenderer::Render() +bool wxDataViewCustomRenderer::MacRender() { return true; } @@ -2216,15 +2322,15 @@ IMPLEMENT_ABSTRACT_CLASS(wxDataViewCustomRenderer, wxDataViewRenderer) wxDataViewTextRenderer::wxDataViewTextRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align) :wxDataViewRenderer(varianttype,mode,align) { - this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserTextType)); + 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()); + wxCHECK_MSG(GetValue().GetType() == GetVariantType(),false,wxString(_("Text renderer cannot render value; value type: ")) << GetValue().GetType()); - wxCFStringRef cfString(this->GetValue().GetString(),(this->GetView()->GetFont().Ok() ? this->GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding())); - return (::SetDataBrowserItemDataText(this->GetNativeData()->GetItemDataRef(),cfString) == noErr); + wxCFStringRef cfString(GetValue().GetString(),(GetView()->GetFont().Ok() ? GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding())); + return (::SetDataBrowserItemDataText(GetNativeData()->GetItemDataRef(),cfString) == noErr); } IMPLEMENT_CLASS(wxDataViewTextRenderer,wxDataViewRenderer) @@ -2235,21 +2341,21 @@ IMPLEMENT_CLASS(wxDataViewTextRenderer,wxDataViewRenderer) wxDataViewBitmapRenderer::wxDataViewBitmapRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align) :wxDataViewRenderer(varianttype,mode,align) { - this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserIconType)); + 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. // In all other cases the method returns 'false'. { - wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Bitmap renderer cannot render value; value type: ")) << this->GetValue().GetType()); + wxCHECK_MSG(GetValue().GetType() == GetVariantType(),false,wxString(_("Bitmap renderer cannot render value; value type: ")) << GetValue().GetType()); wxBitmap bitmap; - bitmap << this->GetValue(); - return (!(bitmap.Ok()) || (::SetDataBrowserItemDataIcon(this->GetNativeData()->GetItemDataRef(),bitmap.GetIconRef()) == noErr)); + bitmap << GetValue(); + return (!(bitmap.Ok()) || (::SetDataBrowserItemDataIcon(GetNativeData()->GetItemDataRef(),bitmap.GetIconRef()) == noErr)); } IMPLEMENT_CLASS(wxDataViewBitmapRenderer,wxDataViewRenderer) @@ -2257,26 +2363,29 @@ IMPLEMENT_CLASS(wxDataViewBitmapRenderer,wxDataViewRenderer) // --------------------------------------------------------- // 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)); + 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()); + wxCHECK_MSG(GetValue().GetType() == GetVariantType(),false,wxString(_("Icon & text renderer cannot render value; value type: ")) << GetValue().GetType()); wxDataViewIconText iconText; - iconText << this->GetValue(); + iconText << GetValue(); - wxCFStringRef cfString(iconText.GetText(),(this->GetView()->GetFont().Ok() ? this->GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding())); + wxCFStringRef cfString(iconText.GetText(),(GetView()->GetFont().Ok() ? GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding())); if (iconText.GetIcon().IsOk()) - if (::SetDataBrowserItemDataIcon(this->GetNativeData()->GetItemDataRef(),MAC_WXHICON(iconText.GetIcon().GetHICON())) != noErr) + if (::SetDataBrowserItemDataIcon(GetNativeData()->GetItemDataRef(),MAC_WXHICON(iconText.GetIcon().GetHICON())) != noErr) return false; - return (::SetDataBrowserItemDataText(this->GetNativeData()->GetItemDataRef(),cfString) == noErr); + return (::SetDataBrowserItemDataText(GetNativeData()->GetItemDataRef(),cfString) == noErr); } IMPLEMENT_ABSTRACT_CLASS(wxDataViewIconTextRenderer,wxDataViewRenderer) @@ -2285,16 +2394,19 @@ IMPLEMENT_ABSTRACT_CLASS(wxDataViewIconTextRenderer,wxDataViewRenderer) // --------------------------------------------------------- // 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)); + 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); + wxCHECK_MSG(GetValue().GetType() == GetVariantType(),false,wxString(_("Toggle renderer cannot render value; value type: ")) << GetValue().GetType()); + return (::SetDataBrowserItemDataButtonValue(GetNativeData()->GetItemDataRef(),GetValue().GetBool()) == noErr); } IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleRenderer,wxDataViewRenderer) @@ -2302,18 +2414,22 @@ IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleRenderer,wxDataViewRenderer) // --------------------------------------------------------- // 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)); + 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) && - (::SetDataBrowserItemDataMaximum(this->GetNativeData()->GetItemDataRef(),100) == noErr) && - (::SetDataBrowserItemDataValue (this->GetNativeData()->GetItemDataRef(),this->GetValue().GetLong()) == noErr)); + wxCHECK_MSG(GetValue().GetType() == GetVariantType(),false,wxString(_("Progress renderer cannot render value type; value type: ")) << GetValue().GetType()); + return ((::SetDataBrowserItemDataMinimum(GetNativeData()->GetItemDataRef(), 0) == noErr) && + (::SetDataBrowserItemDataMaximum(GetNativeData()->GetItemDataRef(),100) == noErr) && + (::SetDataBrowserItemDataValue (GetNativeData()->GetItemDataRef(),GetValue().GetLong()) == noErr)); } IMPLEMENT_ABSTRACT_CLASS(wxDataViewProgressRenderer,wxDataViewRenderer) @@ -2324,13 +2440,13 @@ IMPLEMENT_ABSTRACT_CLASS(wxDataViewProgressRenderer,wxDataViewRenderer) wxDataViewDateRenderer::wxDataViewDateRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align) :wxDataViewRenderer(varianttype,mode,align) { - this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserDateTimeType)); + 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); + wxCHECK_MSG(GetValue().GetType() == GetVariantType(),false,wxString(_("Date renderer cannot render value; value type: ")) << GetValue().GetType()); + return (::SetDataBrowserItemDataDateTime(GetNativeData()->GetItemDataRef(),GetValue().GetDateTime().Subtract(wxDateTime(1,wxDateTime::Jan,1904)).GetSeconds().GetLo()) == noErr); } IMPLEMENT_ABSTRACT_CLASS(wxDataViewDateRenderer,wxDataViewRenderer) @@ -2341,7 +2457,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxDataViewDateRenderer,wxDataViewRenderer) wxDataViewColumn::wxDataViewColumn(const wxString& title, wxDataViewRenderer* renderer, unsigned int model_column, int width, wxAlignment align, int flags) :wxDataViewColumnBase(renderer, model_column), m_NativeDataPtr(new wxDataViewColumnNativeData()), m_title(title) { - this->InitCommon(width, align, flags); + InitCommon(width, align, flags); if ((renderer != NULL) && (renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT)) renderer->SetAlignment(align); } @@ -2349,14 +2465,21 @@ wxDataViewColumn::wxDataViewColumn(const wxString& title, wxDataViewRenderer* re wxDataViewColumn::wxDataViewColumn(const wxBitmap& bitmap, wxDataViewRenderer* renderer, unsigned int model_column, int width, wxAlignment align, int flags) :wxDataViewColumnBase(bitmap, renderer, model_column), m_NativeDataPtr(new wxDataViewColumnNativeData()) { - this->InitCommon(width, align, flags); + InitCommon(width, align, flags); if ((renderer != NULL) && (renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT)) renderer->SetAlignment(align); } -wxDataViewColumn::~wxDataViewColumn(void) +wxDataViewColumn::~wxDataViewColumn() +{ + delete m_NativeDataPtr; +} + +int wxDataViewColumn::GetWidth() const { - delete this->m_NativeDataPtr; + // FIXME: This returns the last programatically set width and will not work if + // the user changes the column's width by dragging it with the mouse. + return m_width; } bool wxDataViewColumn::IsSortKey() const @@ -2368,12 +2491,12 @@ bool wxDataViewColumn::IsSortKey() const DataBrowserPropertyID propertyID; return (macDataViewListCtrlPtr->GetSortProperty(&propertyID) == noErr) && - (propertyID == this->GetNativeData()->GetPropertyID()); + (propertyID == GetNativeData()->GetPropertyID()); } void wxDataViewColumn::SetAlignment(wxAlignment align) { - wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner()); + wxDataViewCtrl* dataViewCtrlPtr(GetOwner()); m_alignment = align; @@ -2385,7 +2508,7 @@ void wxDataViewColumn::SetAlignment(wxAlignment align) { DataBrowserListViewHeaderDesc headerDescription; - wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description.")); + wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description.")); switch (align) { case wxALIGN_CENTER: @@ -2401,14 +2524,14 @@ void wxDataViewColumn::SetAlignment(wxAlignment align) default: headerDescription.btnFontStyle.just = teFlushDefault; } - wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not set alignment.")); + wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not set alignment.")); } } } void wxDataViewColumn::SetBitmap(wxBitmap const& bitmap) { - wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner()); + wxDataViewCtrl* dataViewCtrlPtr(GetOwner()); wxDataViewColumnBase::SetBitmap(bitmap); @@ -2420,19 +2543,19 @@ void wxDataViewColumn::SetBitmap(wxBitmap const& bitmap) { DataBrowserListViewHeaderDesc headerDescription; - wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description.")); - if (this->GetBitmap().Ok()) - headerDescription.btnContentInfo.u.iconRef = this->GetBitmap().GetIconRef(); + wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description.")); + if (GetBitmap().Ok()) + headerDescription.btnContentInfo.u.iconRef = GetBitmap().GetIconRef(); else headerDescription.btnContentInfo.u.iconRef = NULL; - wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not set icon.")); + wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not set icon.")); } } } void wxDataViewColumn::SetMaxWidth(int maxWidth) { - wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner()); + wxDataViewCtrl* dataViewCtrlPtr(GetOwner()); m_maxWidth = maxWidth; @@ -2444,16 +2567,16 @@ void wxDataViewColumn::SetMaxWidth(int maxWidth) { DataBrowserListViewHeaderDesc headerDescription; - wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description.")); + wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description.")); headerDescription.maximumWidth = static_cast(maxWidth); - wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not set maximum width.")); + wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not set maximum width.")); } } } void wxDataViewColumn::SetMinWidth(int minWidth) { - wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner()); + wxDataViewCtrl* dataViewCtrlPtr(GetOwner()); m_minWidth = minWidth; @@ -2465,9 +2588,9 @@ void wxDataViewColumn::SetMinWidth(int minWidth) { DataBrowserListViewHeaderDesc headerDescription; - wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description.")); + wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description.")); headerDescription.minimumWidth = static_cast(minWidth); - wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not set minimum width.")); + wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not set minimum width.")); } } } @@ -2480,7 +2603,7 @@ void wxDataViewColumn::SetReorderable(bool reorderable) else m_flags &= ~wxDATAVIEW_COL_REORDERABLE; // if the column is associated with a control change also immediately the flags of the control: - wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner()); + wxDataViewCtrl* dataViewCtrlPtr(GetOwner()); if (dataViewCtrlPtr != NULL) { @@ -2488,12 +2611,12 @@ void wxDataViewColumn::SetReorderable(bool reorderable) wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast(dataViewCtrlPtr->GetPeer())); wxCHECK_RET(macDataViewListCtrlPtr != NULL, _("Valid pointer to native data view control does not exist")); - wxCHECK_RET(macDataViewListCtrlPtr->GetPropertyFlags(this->GetNativeData()->GetPropertyID(),&flags) == noErr,_("Could not get property flags.")); + wxCHECK_RET(macDataViewListCtrlPtr->GetPropertyFlags(GetNativeData()->GetPropertyID(),&flags) == noErr,_("Could not get property flags.")); if (reorderable) flags |= kDataBrowserListViewMovableColumn; else flags &= ~kDataBrowserListViewMovableColumn; - wxCHECK_RET(macDataViewListCtrlPtr->SetPropertyFlags(this->GetNativeData()->GetPropertyID(),flags) == noErr,_("Could not set property flags.")); + wxCHECK_RET(macDataViewListCtrlPtr->SetPropertyFlags(GetNativeData()->GetPropertyID(),flags) == noErr,_("Could not set property flags.")); } } @@ -2505,7 +2628,7 @@ void wxDataViewColumn::SetResizeable(bool resizeable) else m_flags &= ~wxDATAVIEW_COL_RESIZABLE; // if the column is associated with a control change also immediately the flags of the control: - wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner()); + wxDataViewCtrl* dataViewCtrlPtr(GetOwner()); if (dataViewCtrlPtr != NULL) { @@ -2515,24 +2638,24 @@ void wxDataViewColumn::SetResizeable(bool resizeable) { DataBrowserListViewHeaderDesc headerDescription; - verify_noerr(macDataViewListCtrlPtr->GetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription)); + verify_noerr(macDataViewListCtrlPtr->GetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription)); if (resizeable) { - if (this->GetMinWidth() >= this->GetMaxWidth()) + if (GetMinWidth() >= GetMaxWidth()) { - this->m_minWidth = 0; - this->m_maxWidth = 30000; + m_minWidth = 0; + m_maxWidth = 30000; } - headerDescription.minimumWidth = this->m_minWidth; - headerDescription.maximumWidth = this->m_maxWidth; + headerDescription.minimumWidth = m_minWidth; + headerDescription.maximumWidth = m_maxWidth; } else { - headerDescription.minimumWidth = this->m_width; - headerDescription.maximumWidth = this->m_width; + headerDescription.minimumWidth = m_width; + headerDescription.maximumWidth = m_width; } - verify_noerr(macDataViewListCtrlPtr->SetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription)); - macDataViewListCtrlPtr->SetSortProperty(this->GetNativeData()->GetPropertyID()); + verify_noerr(macDataViewListCtrlPtr->SetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription)); + macDataViewListCtrlPtr->SetSortProperty(GetNativeData()->GetPropertyID()); } } } @@ -2545,7 +2668,7 @@ void wxDataViewColumn::SetSortable(bool sortable) else m_flags &= ~wxDATAVIEW_COL_SORTABLE; // if the column is associated with a control change also immediately the flags of the control: - wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner()); + wxDataViewCtrl* dataViewCtrlPtr(GetOwner()); if (dataViewCtrlPtr != NULL) { @@ -2553,18 +2676,18 @@ void wxDataViewColumn::SetSortable(bool sortable) wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast(dataViewCtrlPtr->GetPeer())); wxCHECK_RET(macDataViewListCtrlPtr != NULL, _("Valid pointer to native data view control does not exist")); - wxCHECK_RET(macDataViewListCtrlPtr->GetPropertyFlags(this->GetNativeData()->GetPropertyID(),&flags) == noErr,_("Could not get property flags.")); + wxCHECK_RET(macDataViewListCtrlPtr->GetPropertyFlags(GetNativeData()->GetPropertyID(),&flags) == noErr,_("Could not get property flags.")); if (sortable) flags |= kDataBrowserListViewSortableColumn; else flags &= ~kDataBrowserListViewSortableColumn; - wxCHECK_RET(macDataViewListCtrlPtr->SetPropertyFlags(this->GetNativeData()->GetPropertyID(),flags) == noErr,_("Could not set property flags.")); + wxCHECK_RET(macDataViewListCtrlPtr->SetPropertyFlags(GetNativeData()->GetPropertyID(),flags) == noErr,_("Could not set property flags.")); } } void wxDataViewColumn::SetSortOrder(bool ascending) { - wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner()); + wxDataViewCtrl* dataViewCtrlPtr(GetOwner()); m_ascending = ascending; @@ -2576,20 +2699,20 @@ void wxDataViewColumn::SetSortOrder(bool ascending) { DataBrowserListViewHeaderDesc headerDescription; - verify_noerr(macDataViewListCtrlPtr->GetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription)); + verify_noerr(macDataViewListCtrlPtr->GetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription)); if (ascending) headerDescription.initialOrder = kDataBrowserOrderIncreasing; else headerDescription.initialOrder = kDataBrowserOrderDecreasing; - verify_noerr(macDataViewListCtrlPtr->SetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription)); - macDataViewListCtrlPtr->SetSortProperty(this->GetNativeData()->GetPropertyID()); + verify_noerr(macDataViewListCtrlPtr->SetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription)); + macDataViewListCtrlPtr->SetSortProperty(GetNativeData()->GetPropertyID()); } } } void wxDataViewColumn::SetTitle(wxString const& title) { - wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner()); + wxDataViewCtrl* dataViewCtrlPtr(GetOwner()); m_title = title; @@ -2602,16 +2725,16 @@ void wxDataViewColumn::SetTitle(wxString const& title) DataBrowserListViewHeaderDesc headerDescription; wxCFStringRef cfTitle(title,(dataViewCtrlPtr->GetFont().Ok() ? dataViewCtrlPtr->GetFont().GetEncoding() : wxLocale::GetSystemEncoding())); - wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description.")); + wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description.")); headerDescription.titleString = cfTitle; - wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not set header description.")); + wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not set header description.")); } } } void wxDataViewColumn::SetWidth(int width) { - wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner()); + wxDataViewCtrl* dataViewCtrlPtr(GetOwner()); if ((width >= m_minWidth) && (width <= m_maxWidth)) @@ -2622,7 +2745,7 @@ void wxDataViewColumn::SetWidth(int width) wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast(dataViewCtrlPtr->GetPeer())); if (macDataViewListCtrlPtr != NULL) - wxCHECK_RET(macDataViewListCtrlPtr->SetColumnWidth(this->GetNativeData()->GetPropertyID(),static_cast(width)) == noErr,_("Could not set column width.")); + wxCHECK_RET(macDataViewListCtrlPtr->SetColumnWidth(GetNativeData()->GetPropertyID(),static_cast(width)) == noErr,_("Could not set column width.")); } } } @@ -2635,8 +2758,8 @@ void wxDataViewColumn::SetAsSortKey(bool WXUNUSED(sort)) void wxDataViewColumn::SetNativeData(wxDataViewColumnNativeData* newNativeDataPtr) { - delete this->m_NativeDataPtr; - this->m_NativeDataPtr = newNativeDataPtr; + delete m_NativeDataPtr; + m_NativeDataPtr = newNativeDataPtr; } #endif // wxUSE_DATAVIEWCTRL && !wxUSE_GENERICDATAVIEWCTRL