From: Robert Roebling Date: Fri, 16 May 2008 22:05:26 +0000 (+0000) Subject: Tried unsuccessfully to change individual line height X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/04d85d788bcc8ec5620d424dd68ee826766f9e1c Tried unsuccessfully to change individual line height git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53611 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/mac/carbon/dataview.cpp b/src/mac/carbon/dataview.cpp index 0dda1609bc..3afab916aa 100644 --- a/src/mac/carbon/dataview.cpp +++ b/src/mac/carbon/dataview.cpp @@ -215,11 +215,41 @@ public: virtual bool ItemAdded(const wxDataViewItem &parent, const wxDataViewItem &item) { DataBrowserItemID itemID(reinterpret_cast(item.GetID())); - - + wxCHECK_MSG(item.IsOk(),false,_("Added item is invalid.")); - return (!(parent.IsOk()) && (this->m_dataViewControlPtr->AddItem(kDataBrowserNoItem,&itemID) == noErr) || - parent.IsOk() && (this->m_dataViewControlPtr->AddItem(reinterpret_cast(parent.GetID()),&itemID) == noErr)); + bool noFailureFlag = (!(parent.IsOk()) && (this->m_dataViewControlPtr->AddItem(kDataBrowserNoItem,&itemID) == noErr) || + parent.IsOk() && (this->m_dataViewControlPtr->AddItem(reinterpret_cast(parent.GetID()),&itemID) == noErr)); + + wxDataViewCtrl *dvc = (wxDataViewCtrl*) this->m_dataViewControlPtr->GetPeer(); + if (dvc->GetWindowStyle() & wxDV_VARIABLE_LINE_HEIGHT) + { + wxDataViewModel *model = GetOwner(); + + int height = 20; // TODO find out standard height + unsigned int num = dvc->GetColumnCount(); + unsigned int col; + for (col = 0; col < num; col++) + { + wxDataViewColumn *column = dvc->GetColumn( col ); + if (column->IsHidden()) + continue; + + wxDataViewCustomRenderer *renderer = wxDynamicCast( column->GetRenderer(), wxDataViewCustomRenderer ); + if (renderer) + { + wxVariant value; + model->GetValue( value, item, column->GetModelColumn() ); + renderer->SetValue( value ); + height = wxMax( height, renderer->GetSize().y ); + } + + } + + if (height > 20) + this->m_dataViewControlPtr->SetRowHeight( itemID, height ); + } + + return noFailureFlag; } /* ItemAdded(wxDataViewItem const&, wxDataViewItem const&) */ virtual bool ItemsAdded(wxDataViewItem const& parent, wxDataViewItemArray const& items) @@ -239,6 +269,39 @@ public: parent.IsOk() && (this->m_dataViewControlPtr->AddItems(reinterpret_cast(parent.GetID()),noOfEntries,itemIDs,kDataBrowserItemNoProperty) == noErr)); // give allocated array space free again: delete[] itemIDs; + + wxDataViewCtrl *dvc = (wxDataViewCtrl*) this->m_dataViewControlPtr->GetPeer(); + if (dvc->GetWindowStyle() & wxDV_VARIABLE_LINE_HEIGHT) + { + wxDataViewItem item = items[0]; // TODO get all items + DataBrowserItemID itemID(reinterpret_cast(item.GetID())); + + wxDataViewModel *model = GetOwner(); + + int height = 20; // TODO find out standard height + unsigned int num = dvc->GetColumnCount(); + unsigned int col; + for (col = 0; col < num; col++) + { + wxDataViewColumn *column = dvc->GetColumn( col ); + if (column->IsHidden()) + continue; + + wxDataViewCustomRenderer *renderer = wxDynamicCast( column->GetRenderer(), wxDataViewCustomRenderer ); + if (renderer) + { + wxVariant value; + model->GetValue( value, item, column->GetModelColumn() ); + renderer->SetValue( value ); + height = wxMax( height, renderer->GetSize().y ); + } + + } + + if (height > 20) + this->m_dataViewControlPtr->SetRowHeight( itemID, height ); + } + // done: return noFailureFlag; } /* ItemsAdded(wxDataViewItem const&, wxDataViewItemArray const&) */