X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/212e8ef365cbf061ad24b1d03aa6f393c411ed6f..08670ea85abf4b4946a9ce64971b591d7b1ee30b:/src/osx/carbon/dataview.cpp diff --git a/src/osx/carbon/dataview.cpp b/src/osx/carbon/dataview.cpp index 1bcd605657..13765f900d 100644 --- a/src/osx/carbon/dataview.cpp +++ b/src/osx/carbon/dataview.cpp @@ -854,7 +854,7 @@ bool wxMacDataViewDataBrowserListViewControl::DeleteColumn(wxDataViewColumn* col void wxMacDataViewDataBrowserListViewControl::DoSetExpanderColumn(wxDataViewColumn const* columnPtr) { - SetDisclosureColumn(columnPtr->GetNativeData()->GetPropertyID(),false); // second parameter explicitely passed to ensure that arrow is centered + SetDisclosureColumn(columnPtr->GetNativeData()->GetPropertyID(),false); // second parameter explicitly passed to ensure that arrow is centered } wxDataViewColumn* wxMacDataViewDataBrowserListViewControl::GetColumn(unsigned int pos) const @@ -889,7 +889,7 @@ bool wxMacDataViewDataBrowserListViewControl::InsertColumn(unsigned int pos, wxD UInt32 noOfColumns; - wxCFStringRef title(columnPtr->GetTitle(),m_font.Ok() ? dynamic_cast(GetWXPeer())->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()); + wxCFStringRef title(columnPtr->GetTitle(),m_font.IsOk() ? dynamic_cast(GetWXPeer())->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()); // try to get new ID for the column: @@ -1095,6 +1095,35 @@ bool wxMacDataViewDataBrowserListViewControl::AssociateModel(wxDataViewModel* WX // // selection related methods (inherited from wxDataViewWidgetImpl) // +wxDataViewItem wxMacDataViewDataBrowserListViewControl::GetCurrentItem() const +{ + wxFAIL_MSG( "unimplemented for Carbon" ); + + return wxDataViewItem(); +} + +void wxMacDataViewDataBrowserListViewControl::SetCurrentItem(const wxDataViewItem& WXUNUSED(item)) +{ + wxFAIL_MSG( "unimplemented for Carbon" ); +} + +int wxMacDataViewDataBrowserListViewControl::GetSelectedItemsCount() const +{ + Handle handle(::NewHandle(0)); + + if ( GetItems(kDataBrowserNoItem,true,kDataBrowserItemIsSelected,handle) != noErr ) + { + wxFAIL_MSG( "failed to get selected items" ); + return 0; + } + + size_t noOfItems = static_cast(::GetHandleSize(handle)/sizeof(DataBrowserItemID)); + HUnlock(handle); + DisposeHandle(handle); + + return noOfItems; +} + int wxMacDataViewDataBrowserListViewControl::GetSelections(wxDataViewItemArray& sel) const { size_t noOfSelectedItems; @@ -1224,6 +1253,11 @@ void wxMacDataViewDataBrowserListViewControl::OnSize() SetHasScrollBars(true,true); } +void wxMacDataViewDataBrowserListViewControl::StartEditor( const wxDataViewItem & item, unsigned int column ) +{ + // implement me +} + // // callback functions (inherited from wxMacDataBrowserTableViewControl) // @@ -1739,7 +1773,7 @@ DataBrowserTrackingResult wxMacDataViewDataBrowserListViewControl::DataBrowserTr 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); + dataViewCustomRendererItem = wxDataViewItem(reinterpret_cast(itemID)); wxCHECK_MSG(dataViewCustomRendererItem.IsOk(),kDataBrowserNothingHit,_("Invalid data view item")); dataViewColumnPtr = GetColumnPtr(propertyID); wxCHECK_MSG(dataViewColumnPtr != NULL,kDataBrowserNothingHit,_("No column existing.")); @@ -1797,8 +1831,11 @@ Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserAcceptDragProc(DragR wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE,dataViewCtrlPtr->GetId()); dataViewEvent.SetEventObject(dataViewCtrlPtr); - dataViewEvent.SetItem(reinterpret_cast(itemID)); // this is the item that receives the event - // (can be an invalid item ID, this is especially useful if the dataview does not contain any items) + + // this is the item that receives the event (can be an invalid item ID, this is + // especially useful if the dataview does not contain any items) + dataViewEvent.SetItem( wxDataViewItem(reinterpret_cast(itemID)) ); + dataViewEvent.SetModel(dataViewCtrlPtr->GetModel()); dataViewEvent.SetDataObject(dataObjects); dataViewEvent.SetDataFormat(GetDnDDataFormat(dataObjects)); @@ -1831,7 +1868,7 @@ Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserAddDragItemProc(Drag 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); + dataViewItem = wxDataViewItem(reinterpret_cast(itemID)); wxCHECK_MSG(dataViewItem.IsOk(),false,_("Invalid data view item")); // send a begin drag event and proceed with dragging unless the event is vetoed: @@ -1971,8 +2008,11 @@ Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserReceiveDragProc(Drag wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_DROP,dataViewCtrlPtr->GetId()); dataViewEvent.SetEventObject(dataViewCtrlPtr); - dataViewEvent.SetItem(reinterpret_cast(itemID)); // this is the item that receives the event - // (can be an invalid item ID, this is especially useful if the dataview does not contain any items) + + // this is the item that receives the event (can be an invalid item ID, this is + // especially useful if the dataview does not contain any items) + dataViewEvent.SetItem( wxDataViewItem(reinterpret_cast(itemID)) ); + dataViewEvent.SetModel(dataViewCtrlPtr->GetModel()); dataViewEvent.SetDataObject(dataObjects); dataViewEvent.SetDataFormat(GetDnDDataFormat(dataObjects)); @@ -2092,8 +2132,7 @@ wxDataObjectComposite* wxMacDataViewDataBrowserListViewControl::GetDnDDataObject dataObject->Add(textDataObject); else { - delete textDataObject; - textDataObject = NULL; + wxDELETE(textDataObject); } } } /* block */ @@ -2124,8 +2163,7 @@ wxDataObjectComposite* wxMacDataViewDataBrowserListViewControl::GetDnDDataObject dataObject->Add(textDataObject); else { - delete textDataObject; - textDataObject = NULL; + wxDELETE(textDataObject); } } else // overwrite data because the 'utxt' flavor has priority over the 'TEXT' flavor @@ -2329,7 +2367,7 @@ bool wxDataViewTextRenderer::MacRender() { wxCHECK_MSG(GetValue().GetType() == GetVariantType(),false,wxString(_("Text renderer cannot render value; value type: ")) << GetValue().GetType()); - wxCFStringRef cfString(GetValue().GetString(),(GetView()->GetFont().Ok() ? GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding())); + wxCFStringRef cfString(GetValue().GetString(),(GetView()->GetFont().IsOk() ? GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding())); return (::SetDataBrowserItemDataText(GetNativeData()->GetItemDataRef(),cfString) == noErr); } @@ -2355,7 +2393,7 @@ bool wxDataViewBitmapRenderer::MacRender() wxBitmap bitmap; bitmap << GetValue(); - return (!(bitmap.Ok()) || (::SetDataBrowserItemDataIcon(GetNativeData()->GetItemDataRef(),bitmap.GetIconRef()) == noErr)); + return (!(bitmap.IsOk()) || (::SetDataBrowserItemDataIcon(GetNativeData()->GetItemDataRef(),bitmap.GetIconRef()) == noErr)); } IMPLEMENT_CLASS(wxDataViewBitmapRenderer,wxDataViewRenderer) @@ -2380,7 +2418,7 @@ bool wxDataViewIconTextRenderer::MacRender() iconText << GetValue(); - wxCFStringRef cfString(iconText.GetText(),(GetView()->GetFont().Ok() ? GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding())); + wxCFStringRef cfString(iconText.GetText(),(GetView()->GetFont().IsOk() ? GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding())); if (iconText.GetIcon().IsOk()) if (::SetDataBrowserItemDataIcon(GetNativeData()->GetItemDataRef(),MAC_WXHICON(iconText.GetIcon().GetHICON())) != noErr) @@ -2458,16 +2496,18 @@ wxDataViewColumn::wxDataViewColumn(const wxString& title, wxDataViewRenderer* re :wxDataViewColumnBase(renderer, model_column), m_NativeDataPtr(new wxDataViewColumnNativeData()), m_title(title) { InitCommon(width, align, flags); - if ((renderer != NULL) && (renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT)) - renderer->SetAlignment(align); + if ((renderer != NULL) && !renderer->IsCustomRenderer() && + (renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT)) + renderer->SetAlignment(align); } 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()) { InitCommon(width, align, flags); - if ((renderer != NULL) && (renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT)) - renderer->SetAlignment(align); + if ((renderer != NULL) && !renderer->IsCustomRenderer() && + (renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT)) + renderer->SetAlignment(align); } wxDataViewColumn::~wxDataViewColumn() @@ -2477,7 +2517,7 @@ wxDataViewColumn::~wxDataViewColumn() int wxDataViewColumn::GetWidth() const { - // FIXME: This returns the last programatically set width and will not work if + // FIXME: This returns the last programmatically set width and will not work if // the user changes the column's width by dragging it with the mouse. return m_width; } @@ -2544,7 +2584,7 @@ void wxDataViewColumn::SetBitmap(wxBitmap const& bitmap) DataBrowserListViewHeaderDesc headerDescription; wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description.")); - if (GetBitmap().Ok()) + if (GetBitmap().IsOk()) headerDescription.btnContentInfo.u.iconRef = GetBitmap().GetIconRef(); else headerDescription.btnContentInfo.u.iconRef = NULL; @@ -2620,10 +2660,10 @@ void wxDataViewColumn::SetReorderable(bool reorderable) } } -void wxDataViewColumn::SetResizeable(bool resizeable) +void wxDataViewColumn::SetResizeable(bool resizable) { // first set the internal flag of the column: - if (resizeable) + if (resizable) m_flags |= wxDATAVIEW_COL_RESIZABLE; else m_flags &= ~wxDATAVIEW_COL_RESIZABLE; @@ -2639,7 +2679,7 @@ void wxDataViewColumn::SetResizeable(bool resizeable) DataBrowserListViewHeaderDesc headerDescription; verify_noerr(macDataViewListCtrlPtr->GetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription)); - if (resizeable) + if (resizable) { if (GetMinWidth() >= GetMaxWidth()) { @@ -2723,7 +2763,7 @@ void wxDataViewColumn::SetTitle(wxString const& title) if (macDataViewListCtrlPtr != NULL) { DataBrowserListViewHeaderDesc headerDescription; - wxCFStringRef cfTitle(title,(dataViewCtrlPtr->GetFont().Ok() ? dataViewCtrlPtr->GetFont().GetEncoding() : wxLocale::GetSystemEncoding())); + wxCFStringRef cfTitle(title,(dataViewCtrlPtr->GetFont().IsOk() ? dataViewCtrlPtr->GetFont().GetEncoding() : wxLocale::GetSystemEncoding())); wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description.")); headerDescription.titleString = cfTitle; @@ -2736,6 +2776,16 @@ void wxDataViewColumn::SetWidth(int width) { wxDataViewCtrl* dataViewCtrlPtr(GetOwner()); + switch ( width ) + { + case wxCOL_WIDTH_AUTOSIZE: + // not implemented, fall through + case wxCOL_WIDTH_DEFAULT: + width = wxDVC_DEFAULT_WIDTH; + break; + default: + break; + } if ((width >= m_minWidth) && (width <= m_maxWidth)) { @@ -2750,12 +2800,17 @@ void wxDataViewColumn::SetWidth(int width) } } -void wxDataViewColumn::SetAsSortKey(bool WXUNUSED(sort)) +void wxDataViewColumn::SetHidden(bool WXUNUSED(hidden)) { - // see wxGTK native wxDataViewColumn implementation - wxFAIL_MSG( "not implemented" ); + // How to do that? } +bool wxDataViewColumn::IsHidden() const +{ + return true; +} + + void wxDataViewColumn::SetNativeData(wxDataViewColumnNativeData* newNativeDataPtr) { delete m_NativeDataPtr;