X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a5fb925380c924f2e34dd3de0dc2fa8bb2391ee3..850df2d78866c3edcf848103b5dbc7e7fa1ee5fa:/src/mac/carbon/databrow.cpp diff --git a/src/mac/carbon/databrow.cpp b/src/mac/carbon/databrow.cpp index 744687c7c0..930effca50 100644 --- a/src/mac/carbon/databrow.cpp +++ b/src/mac/carbon/databrow.cpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // Name: src/mac/carbon/databrow.cpp // Purpose: Classes and functions for the Carbon data browser -// Author: +// Author: // Modified by: // Created: 2007-05-18 // RCS-ID: $Id$ @@ -9,23 +9,17 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifndef wxUSE_GENERICDATAVIEWCTRL -#if wxUSE_DATAVIEWCTRL +#include "wx/wxprec.h" + +#if wxUSE_DATAVIEWCTRL && !defined(wxUSE_GENERICDATAVIEWCTRL) #include -#ifdef __DARWIN__ - #include -#else - #include - #include - #include -#endif -#include "wx/wxprec.h" #ifndef WX_PRECOMP #include "wx/app.h" #include "wx/toplevel.h" #include "wx/font.h" + #include "wx/settings.h" #endif #include "wx/dataview.h" @@ -35,12 +29,6 @@ #include "wx/mac/private.h" #include "wx/mac/uma.h" -#if defined(__MWERKS__) && wxUSE_UNICODE -#if __MWERKS__ < 0x4100 || !defined(__DARWIN__) - #include -#endif -#endif - // ============================================================================ // wxMacDataBrowserTableViewControl // ============================================================================ @@ -105,11 +93,7 @@ wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow* pee if (gDataBrowserTableViewItemNotificationUPP == NULL) { gDataBrowserTableViewItemNotificationUPP = -#if TARGET_API_MAC_OSX (DataBrowserItemNotificationUPP) NewDataBrowserItemNotificationWithItemUPP(wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc); -#else - NewDataBrowserItemNotificationUPP(wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc); -#endif } DataBrowserCallbacks callbacks; @@ -139,9 +123,9 @@ wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow* pee flags |= kDataBrowserSelectOnlyOne; (void) this->SetSelectionFlags(flags); } /* if */ -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 + OptionBits attributes; // variable definition - + if (this->GetAttributes(&attributes) == noErr) // get default settings { if ((style & wxDV_VERT_RULES) != 0) @@ -150,7 +134,7 @@ wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow* pee attributes &= ~kDataBrowserAttributeListViewDrawColumnDividers; (void) this->SetAttributes(attributes); } /* if */ -#endif + if ((style & wxDV_NO_HEADER) != 0) this->SetHeaderButtonHeight(0); } /* wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow*, wxPoint const&, wxSize const&, long) */ @@ -195,12 +179,10 @@ OSStatus wxMacDataBrowserTableViewControl::EnableCellSizeModification(bool enabl return ::SetDataBrowserTableViewGeometry(this->GetControlRef(),enableWidth,enableHeight); } /* wxMacDataBrowserTableViewControl::EnableCellSizeModification(bool, bool) */ -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 OSStatus wxMacDataBrowserTableViewControl::GetAttributes(OptionBits* attributes) { return ::DataBrowserGetAttributes(this->GetControlRef(),attributes); } /* wxMacDataBrowserTableViewControl::GetAttributes(OptionBits*) */ -#endif OSStatus wxMacDataBrowserTableViewControl::GetColumnWidth(DataBrowserPropertyID propertyID, UInt16* width) const { @@ -237,12 +219,10 @@ OSStatus wxMacDataBrowserTableViewControl::GetScrollPosition( UInt32 *top , UInt return GetDataBrowserScrollPosition(this->m_controlRef, top , left ); } -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 OSStatus wxMacDataBrowserTableViewControl::SetAttributes(OptionBits attributes) { return ::DataBrowserChangeAttributes(this->GetControlRef(),attributes,~attributes); } /* wxMacDataBrowserTableViewControl::SetAttributes(OptionBits) */ -#endif OSStatus wxMacDataBrowserTableViewControl::SetColumnWidth(DataBrowserPropertyID propertyID, UInt16 width) { @@ -331,7 +311,7 @@ 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 */ @@ -375,8 +355,8 @@ OSStatus wxMacDataBrowserTableViewControl::AddItems(DataBrowserItemID container, OSStatus wxMacDataBrowserTableViewControl::GetFreeItemID(DataBrowserItemID* id) const { ItemCount NoOfItems; - - + + verify_noerr(this->GetItemCount(&NoOfItems)); if (NoOfItems == 0) { @@ -425,7 +405,7 @@ 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 */ @@ -452,7 +432,7 @@ size_t wxMacDataBrowserTableViewControl::GetSelectedItemIDs(wxArrayDataBrowserIt { DataBrowserItemID* itemIDPtr; Handle handle(::NewHandle(0)); - + size_t NoOfItems; @@ -569,9 +549,9 @@ Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserCompareProc(DataBrow DataBrowserSortOrder sortOrder; DataBrowserTableViewColumnIndex columnIndex; - + wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast(this->GetPeer())); - + 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.")); @@ -593,7 +573,7 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowse wxDataViewColumn* dataViewColumnPtr; wxDataViewCtrl* dataViewCtrlPtr; - + wxDataViewCustomRenderer* dataViewCustomRendererPtr; wxVariant dataToRender; @@ -628,11 +608,11 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowse content.left += 5; content.right -= 3; content.bottom -= 3; - // extra space for the scrollbars: + // extra space for the scrollbars: content.bottom -= wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y); content.right -= wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); - // make sure that 'Render' can draw only in the allowed area: + // make sure that 'Render' can draw only in the allowed area: dataViewCustomRendererPtr->GetDC()->SetClippingRegion(content.left,content.top,content.right-content.left+1,content.bottom-content.top+1); (void) (dataViewCustomRendererPtr->Render(wxRect(static_cast(rectangle->left),static_cast(rectangle->top), static_cast(1+rectangle->right-rectangle->left),static_cast(1+rectangle->bottom-rectangle->top)), @@ -646,7 +626,7 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc( { // variable definitions: wxDataViewCtrl* dataViewCtrlPtr; - + dataViewCtrlPtr = dynamic_cast(this->GetPeer()); wxCHECK_MSG(dataViewCtrlPtr != NULL,errDataBrowserNotConfigured,_("Pointer to data view control not set correctly.")); if (dataViewCtrlPtr->IsDeleting()) @@ -657,7 +637,7 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc( DataBrowserTableViewColumnIndex columnIndex; OSStatus errorStatus; wxDataViewColumn* dataViewColumnPtr; - + wxCHECK_MSG(dataViewCtrlPtr->GetModel() != NULL,errDataBrowserNotConfigured,_("Pointer to model not set correctly.")); errorStatus = this->GetColumnIndex(propertyID,&columnIndex); wxCHECK_MSG(errorStatus == noErr,errorStatus,_("Could not determine column index")); @@ -726,7 +706,7 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc( wxVariant variant; wxDataViewColumn* dataViewColumnPtr; wxDataViewCtrl* dataViewCtrlPtr; - + dataViewCtrlPtr = dynamic_cast(this->GetPeer()); wxCHECK_MSG(dataViewCtrlPtr != NULL,errDataBrowserNotConfigured,_("Pointer to data view control not set correctly.")); wxCHECK_MSG(dataViewCtrlPtr->GetModel() != NULL,errDataBrowserNotConfigured,_("Pointer to model not set correctly.")); @@ -750,11 +730,11 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc( { // variable definitions: wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast(this->GetPeer())); - + 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))); // finally send the equivalent wxWidget event: @@ -766,11 +746,11 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc( { // variable definitions: wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast(this->GetPeer())); - + 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 - + dataViewEvent.SetEventObject(dataViewCtrlPtr); dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast(itemID))); // finally send the equivalent wxWidget event: @@ -782,7 +762,7 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc( { // variable definition: wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast(this->GetPeer())); - + wxCHECK_MSG(dataViewCtrlPtr != NULL,errDataBrowserNotConfigured,_("Pointer to data view control not set correctly.")); wxCHECK_MSG(dataViewCtrlPtr->GetModel() != NULL,errDataBrowserNotConfigured,_("Pointer to model not set correctly.")); return ::SetDataBrowserItemDataBooleanValue(itemData,dataViewCtrlPtr->GetModel()->IsContainer(wxDataViewItem(reinterpret_cast(itemID)))); @@ -808,7 +788,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: @@ -819,7 +799,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: @@ -831,19 +811,19 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(Da case kDataBrowserEditStarted: { // 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) { // variable definition and initialization: DataBrowserTableViewColumnIndex columnIndex; - + wxCHECK_RET(this->GetColumnIndex(propertyID,&columnIndex),_("Column index not found.")); dataViewEvent.SetColumn(columnIndex); - dataViewEvent.SetDataViewColumn(dataViewCtrlPtr->GetColumnPtr(propertyID)); + dataViewEvent.SetDataViewColumn(dataViewCtrlPtr->GetColumnPtr(propertyID)); } /* if */ // finally send the equivalent wxWidget event: dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent); @@ -852,9 +832,9 @@ 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) @@ -864,7 +844,7 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(Da wxCHECK_RET(this->GetColumnIndex(propertyID,&columnIndex),_("Column index not found.")); dataViewEvent.SetColumn(columnIndex); - dataViewEvent.SetDataViewColumn(dataViewCtrlPtr->GetColumnPtr(propertyID)); + dataViewEvent.SetDataViewColumn(dataViewCtrlPtr->GetColumnPtr(propertyID)); } /* if */ // finally send the equivalent wxWidget event: dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent); @@ -909,7 +889,7 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(Da wxDataViewColumn* const columnPtr = dataViewCtrlPtr->GetColumn(i); // variable definition: UInt16 columnWidth; - + wxCHECK_RET(this->GetColumnWidth(columnPtr->GetPropertyID(),&columnWidth) == noErr,_("Column width could not be determined")); columnPtr->SetWidthVariable(columnWidth); } /* for */ @@ -920,7 +900,7 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(Da { DataBrowserSortOrder sortOrder; DataBrowserTableViewColumnIndex columnIndex; - + if ((this->GetSortOrder(&sortOrder) == noErr) && (this->GetColumnIndex(propertyID,&columnIndex) == noErr)) { // variable definition and initialization: @@ -948,5 +928,4 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(Da } /* wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(DataBrowserItemID, DataBrowserItemNotification, DataBrowserItemDataRef) */ -#endif // wxUSE_DATAVIEWCTRL -#endif // wxUSE_GENERICDATAVIEWCTRL +#endif // wxUSE_DATAVIEWCTRL && !wxUSE_GENERICDATAVIEWCTRL