X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c937bcac0fb8a8df7c0cbfc8c478a2874fec3eb9..681bf55c1c269d4abeca97ea4a1777718aa7fa63:/src/osx/carbon/dataview.cpp diff --git a/src/osx/carbon/dataview.cpp b/src/osx/carbon/dataview.cpp index 38f94678c9..ff748471c2 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,18 @@ 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::GetSelections(wxDataViewItemArray& sel) const { size_t noOfSelectedItems; @@ -1183,7 +1195,7 @@ wxDataViewColumn* wxMacDataViewDataBrowserListViewControl::GetSortingColumn() co void wxMacDataViewDataBrowserListViewControl::Resort() { - (void) Resort(); + (void) wxMacDataBrowserListViewControl::Resort(); } // @@ -1224,6 +1236,11 @@ void wxMacDataViewDataBrowserListViewControl::OnSize() SetHasScrollBars(true,true); } +void wxMacDataViewDataBrowserListViewControl::StartEditor( const wxDataViewItem & item, unsigned int column ) +{ + // implement me +} + // // callback functions (inherited from wxMacDataBrowserTableViewControl) // @@ -1318,8 +1335,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; @@ -1329,8 +1345,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; @@ -1357,8 +1372,7 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc( #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; @@ -1704,7 +1718,7 @@ wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowserItem { // 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 } @@ -2095,8 +2109,7 @@ wxDataObjectComposite* wxMacDataViewDataBrowserListViewControl::GetDnDDataObject dataObject->Add(textDataObject); else { - delete textDataObject; - textDataObject = NULL; + wxDELETE(textDataObject); } } } /* block */ @@ -2127,8 +2140,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 @@ -2286,14 +2298,11 @@ wxEllipsizeMode wxDataViewRenderer::GetEllipsizeMode() const return wxELLIPSIZE_NONE; if ( flags & kDataBrowserTruncateTextAtStart ) return wxELLIPSIZE_START; - if ( flags & kDataBrowserTruncateTextMiddle ) - return wxELLIPSIZE_MIDDLE; if ( flags & kDataBrowserTruncateTextAtEnd ) return wxELLIPSIZE_END; - wxFAIL_MSG( "unknown flags" ); - - return wxELLIPSIZE_NONE; + // kDataBrowserTruncateTextMiddle == 0 so there is no need to test for it + return wxELLIPSIZE_MIDDLE; } void wxDataViewRenderer::SetNativeData(wxDataViewRendererNativeData* newNativeDataPtr) @@ -2308,7 +2317,9 @@ 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) { SetNativeData(new wxDataViewRendererNativeData(kDataBrowserCustomType)); } @@ -2333,7 +2344,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); } @@ -2359,7 +2370,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) @@ -2384,7 +2395,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) @@ -2462,16 +2473,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() @@ -2479,6 +2492,13 @@ wxDataViewColumn::~wxDataViewColumn() delete m_NativeDataPtr; } +int wxDataViewColumn::GetWidth() const +{ + // 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; +} + bool wxDataViewColumn::IsSortKey() const { wxDataViewCtrl * const dataViewCtrlPtr(GetOwner()); @@ -2541,7 +2561,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; @@ -2617,10 +2637,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; @@ -2636,7 +2656,7 @@ void wxDataViewColumn::SetResizeable(bool resizeable) DataBrowserListViewHeaderDesc headerDescription; verify_noerr(macDataViewListCtrlPtr->GetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription)); - if (resizeable) + if (resizable) { if (GetMinWidth() >= GetMaxWidth()) { @@ -2720,7 +2740,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; @@ -2733,6 +2753,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)) { @@ -2747,6 +2777,17 @@ void wxDataViewColumn::SetWidth(int width) } } +void wxDataViewColumn::SetHidden(bool WXUNUSED(hidden)) +{ + // How to do that? +} + +bool wxDataViewColumn::IsHidden() const +{ + return true; +} + + void wxDataViewColumn::SetAsSortKey(bool WXUNUSED(sort)) { // see wxGTK native wxDataViewColumn implementation