X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/33ba5a05623023af942a6b34b0758a98b12d4c82..f7d2128f3c89b2d00fbac0d8c9798409ae23b408:/src/mac/carbon/dataview.cpp diff --git a/src/mac/carbon/dataview.cpp b/src/mac/carbon/dataview.cpp index 9b4a88fff9..5e2df96b5b 100644 --- a/src/mac/carbon/dataview.cpp +++ b/src/mac/carbon/dataview.cpp @@ -84,7 +84,11 @@ static pascal OSStatus wxMacDataViewCtrlEventHandler(EventHandlerCallRef handler DataViewEvent.SetColumn(columnIndex); DataViewEvent.SetDataViewColumn(DataViewCtrlPtr->GetColumn(columnIndex)); // finally sent the equivalent wxWidget event: +#if wxCHECK_VERSION(2,9,0) DataViewCtrlPtr->HandleWindowEvent(DataViewEvent); +#else + DataViewCtrlPtr->GetEventHandler()->ProcessEvent(DataViewEvent); +#endif return ::CallNextEventHandler(handler,EventReference); } /* if */ else @@ -113,29 +117,18 @@ static DataBrowserItemID* CreateDataBrowserItemIDArray(size_t& noOfEntries, wxDa return itemIDs; } /* CreateDataBrowserItemIDArray(size_t&, wxDataViewItemArray const&) */ +#if wxCHECK_VERSION(2,9,0) static bool InitializeColumnDescription(DataBrowserListViewColumnDesc& columnDescription, wxDataViewColumn const* columnPtr, DataBrowserPropertyID columnPropertyID, wxCFStringRef const& title) +#else +static bool InitializeColumnDescription(DataBrowserListViewColumnDesc& columnDescription, wxDataViewColumn const* columnPtr, DataBrowserPropertyID columnPropertyID, wxMacCFStringHolder const& title) +#endif { // set properties for the column: columnDescription.propertyDesc.propertyID = columnPropertyID; columnDescription.propertyDesc.propertyType = columnPtr->GetRenderer()->GetPropertyType(); columnDescription.propertyDesc.propertyFlags = kDataBrowserListViewSelectionColumn; // make the column selectable - if (columnPtr->IsSortable()) - columnDescription.propertyDesc.propertyFlags |= kDataBrowserListViewSortableColumn; -#if 0 - if (columnPtr->IsMovable()) + if (columnPtr->IsReorderable()) columnDescription.propertyDesc.propertyFlags |= kDataBrowserListViewMovableColumn; -#endif - if (columnPtr->GetRenderer()->GetMode() == wxDATAVIEW_CELL_EDITABLE) - columnDescription.propertyDesc.propertyFlags |= kDataBrowserPropertyIsEditable; - if ((columnDescription.propertyDesc.propertyType == kDataBrowserTextType) || - (columnDescription.propertyDesc.propertyType == kDataBrowserIconAndTextType) || - (columnDescription.propertyDesc.propertyType == kDataBrowserDateTimeType)) - columnDescription.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn; // enables generally the possibility to have user input for the mentioned types -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 - columnDescription.propertyDesc.propertyFlags |= kDataBrowserListViewNoGapForIconInHeaderButton; -#endif - // set header's properties: - columnDescription.headerBtnDesc.version = kDataBrowserListViewLatestHeaderDesc; if (columnPtr->IsResizeable()) { columnDescription.headerBtnDesc.minimumWidth = 0; @@ -146,6 +139,20 @@ static bool InitializeColumnDescription(DataBrowserListViewColumnDesc& columnDes columnDescription.headerBtnDesc.minimumWidth = columnPtr->GetWidth(); columnDescription.headerBtnDesc.maximumWidth = columnPtr->GetWidth(); } /* if */ + if (columnPtr->IsSortable()) + columnDescription.propertyDesc.propertyFlags |= kDataBrowserListViewSortableColumn; + if (columnPtr->GetRenderer()->GetMode() == wxDATAVIEW_CELL_EDITABLE) + columnDescription.propertyDesc.propertyFlags |= kDataBrowserPropertyIsEditable; + if ((columnDescription.propertyDesc.propertyType == kDataBrowserCustomType) || + (columnDescription.propertyDesc.propertyType == kDataBrowserDateTimeType) || + (columnDescription.propertyDesc.propertyType == kDataBrowserIconAndTextType) || + (columnDescription.propertyDesc.propertyType == kDataBrowserTextType)) + columnDescription.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn; // enables generally the possibility to have user input for the mentioned types +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 + columnDescription.propertyDesc.propertyFlags |= kDataBrowserListViewNoGapForIconInHeaderButton; +#endif + // set header's properties: + columnDescription.headerBtnDesc.version = kDataBrowserListViewLatestHeaderDesc; columnDescription.headerBtnDesc.titleOffset = 0; columnDescription.headerBtnDesc.titleString = ::CFStringCreateCopy(kCFAllocatorDefault,title); columnDescription.headerBtnDesc.initialOrder = kDataBrowserOrderIncreasing; // choose one of the orders as "undefined" is not supported anyway (s. ControlDefs.h in the HIToolbox framework) @@ -167,12 +174,26 @@ static bool InitializeColumnDescription(DataBrowserListViewColumnDesc& columnDes } /* switch */ columnDescription.headerBtnDesc.btnFontStyle.font = kControlFontViewSystemFont; columnDescription.headerBtnDesc.btnFontStyle.style = normal; - columnDescription.headerBtnDesc.btnContentInfo.contentType = kControlContentIconRef; - if (columnPtr->GetBitmap().Ok()) + if (columnPtr->GetBitmap().IsOk()) + { + columnDescription.headerBtnDesc.btnContentInfo.contentType = kControlContentIconRef; +#if wxCHECK_VERSION(2,9,0) columnDescription.headerBtnDesc.btnContentInfo.u.iconRef = columnPtr->GetBitmap().GetIconRef(); +#else + columnDescription.headerBtnDesc.btnContentInfo.u.iconRef = columnPtr->GetBitmap().GetBitmapData()->GetIconRef(); +#endif + } + else + { + // not text only as we otherwise could not add a bitmap later + // columnDescription.headerBtnDesc.btnContentInfo.contentType = kControlContentTextOnly; + columnDescription.headerBtnDesc.btnContentInfo.contentType = kControlContentIconRef; + columnDescription.headerBtnDesc.btnContentInfo.u.iconRef = NULL; + } + // done: return true; -} /* InitializeColumnDescription(DataBrowserListViewColumnDesc&, wxDataViewColumn const*, DataBrowserPropertyID, wxCFStringRef const&) */ +} /* InitializeColumnDescription(DataBrowserListViewColumnDesc&, wxDataViewColumn const*, DataBrowserPropertyID, wxMacCFStringHolder const&) */ //----------------------------------------------------------------------------- // local function pointers @@ -194,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) @@ -218,6 +269,46 @@ 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) + { + wxDataViewModel *model = GetOwner(); + unsigned int colnum = dvc->GetColumnCount(); + + size_t i; + size_t count = items.GetCount(); + for (i = 0; i < count; i++) + { + wxDataViewItem item = items[i]; + DataBrowserItemID itemID(reinterpret_cast(item.GetID())); + + int height = 20; // TODO find out standard height + unsigned int col; + for (col = 0; col < colnum; col++) + { + wxDataViewColumn *column = dvc->GetColumn( col ); + if (column->IsHidden()) + continue; // skip it! + + if ((col != 0) && model->IsContainer(item) && !model->HasContainerColumns(item)) + continue; // skip it! + + 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&) */ @@ -238,7 +329,11 @@ public: dataViewEvent.SetEventObject(dataViewCtrlPtr); dataViewEvent.SetItem(item); // sent the equivalent wxWidget event: +#if wxCHECK_VERSION(2,9,0) dataViewCtrlPtr->HandleWindowEvent(dataViewEvent); +#else + dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent); +#endif // done return true; } /* if */ @@ -270,7 +365,11 @@ public: for (size_t i=0; i(itemIDs[i])); +#if wxCHECK_VERSION(2,9,0) dataViewCtrlPtr->HandleWindowEvent(dataViewEvent); +#else + dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent); +#endif } /* for */ } /* if */ // release allocated array space: @@ -357,7 +456,11 @@ public: dataViewEvent.SetColumn(col); dataViewEvent.SetItem(item); // send the equivalent wxWidget event: +#if wxCHECK_VERSION(2,9,0) dataViewCtrlPtr->HandleWindowEvent(dataViewEvent); +#else + dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent); +#endif // done return true; } /* if */ @@ -365,7 +468,7 @@ public: return false; } /* ValueChanged(wxDataViewItem const&, unsigned int) */ - virtual bool Cleared(void) + virtual bool Cleared() { bool noFailureFlag = (this->m_dataViewControlPtr->RemoveItems() == noErr); wxDataViewItem item; @@ -373,9 +476,9 @@ public: GetOwner()->GetChildren( item, array ); ItemsAdded( item, array ); return noFailureFlag; - } /* Cleared(void) */ + } /* Cleared() */ - virtual void Resort(void) + virtual void Resort() { this->m_dataViewControlPtr->Resort(); } @@ -441,21 +544,22 @@ wxDataViewCustomRenderer::wxDataViewCustomRenderer(wxString const& varianttype, { } /* wxDataViewCustomRenderer::wxDataViewCustomRenderer(wxString const&, wxDataViewCellMode) */ -wxDataViewCustomRenderer::~wxDataViewCustomRenderer(void) +wxDataViewCustomRenderer::~wxDataViewCustomRenderer() { if (this->m_DCPtr != NULL) delete this->m_DCPtr; -} /* wxDataViewCustomRenderer::~wxDataViewCustomRenderer(void) */ +} /* wxDataViewCustomRenderer::~wxDataViewCustomRenderer() */ void wxDataViewCustomRenderer::RenderText( const wxString &text, int xoffset, wxRect cell, wxDC *dc, int state ) { wxDataViewCtrl *view = GetOwner()->GetOwner(); +// wxColour col = (state & wxDATAVIEW_CELL_SELECTED) ? wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT) : view->GetForegroundColour(); wxColour col = (state & wxDATAVIEW_CELL_SELECTED) ? *wxWHITE : view->GetForegroundColour(); dc->SetTextForeground(col); dc->DrawText( text, cell.x + xoffset, cell.y + ((cell.height - dc->GetCharHeight()) / 2)); } -wxDC* wxDataViewCustomRenderer::GetDC(void) +wxDC* wxDataViewCustomRenderer::GetDC() { if (this->m_DCPtr == NULL) { @@ -464,12 +568,12 @@ wxDC* wxDataViewCustomRenderer::GetDC(void) this->m_DCPtr = new wxWindowDC(this->GetOwner()->GetOwner()); } /* if */ return this->m_DCPtr; -} /* wxDataViewCustomRenderer::GetDC(void) */ +} /* wxDataViewCustomRenderer::GetDC() */ -bool wxDataViewCustomRenderer::Render(void) +bool wxDataViewCustomRenderer::Render() { return true; -} /* wxDataViewCustomRenderer::Render(void) */ +} /* wxDataViewCustomRenderer::Render() */ void wxDataViewCustomRenderer::SetDC(wxDC* newDCPtr) { @@ -477,10 +581,10 @@ void wxDataViewCustomRenderer::SetDC(wxDC* newDCPtr) this->m_DCPtr = newDCPtr; } /* wxDataViewCustomRenderer::SetDC(wxDC*) */ -WXDataBrowserPropertyType wxDataViewCustomRenderer::GetPropertyType(void) const +WXDataBrowserPropertyType wxDataViewCustomRenderer::GetPropertyType() const { return kDataBrowserCustomType; -} /* wxDataViewCustomRenderer::GetPropertyType(void) const */ +} /* wxDataViewCustomRenderer::GetPropertyType() const */ IMPLEMENT_ABSTRACT_CLASS(wxDataViewCustomRenderer, wxDataViewRenderer) @@ -493,23 +597,23 @@ wxDataViewTextRenderer::wxDataViewTextRenderer(wxString const& varianttype, wxDa { } /* wxDataViewTextRenderer::wxDataViewTextRenderer(wxString const&, wxDataViewCellMode, int) */ -bool wxDataViewTextRenderer::Render(void) +bool wxDataViewTextRenderer::Render() { - if (this->GetValue().GetType() == this->GetVariantType()) - { - // variable definition: - wxCFStringRef cfString(this->GetValue().GetString(),(this->GetView()->GetFont().Ok() ? this->GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding())); + wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Text renderer cannot render value; value type: ")) << this->GetValue().GetType()); - return (::SetDataBrowserItemDataText(this->GetDataReference(),cfString) == noErr); - } /* if */ - else - return false; -} /* wxDataViewTextRenderer::Render(void) */ + // variable definition: +#if wxCHECK_VERSION(2,9,0) + wxCFStringRef cfString(this->GetValue().GetString(),(this->GetView()->GetFont().Ok() ? this->GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding())); +#else + wxMacCFStringHolder cfString(this->GetValue().GetString(),(this->GetView()->GetFont().Ok() ? this->GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding())); +#endif + return (::SetDataBrowserItemDataText(this->GetDataReference(),cfString) == noErr); +} /* wxDataViewTextRenderer::Render() */ -WXDataBrowserPropertyType wxDataViewTextRenderer::GetPropertyType(void) const +WXDataBrowserPropertyType wxDataViewTextRenderer::GetPropertyType() const { return kDataBrowserTextType; -} /* wxDataViewTextRenderer::GetPropertyType(void) const */ +} /* wxDataViewTextRenderer::GetPropertyType() const */ IMPLEMENT_CLASS(wxDataViewTextRenderer,wxDataViewRenderer) @@ -533,26 +637,32 @@ wxDataViewBitmapRenderer::wxDataViewBitmapRenderer(wxString const& varianttype, { } -bool wxDataViewBitmapRenderer::Render(void) +bool wxDataViewBitmapRenderer::Render() + // 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'. { - if (this->GetValue().GetType() == this->GetVariantType()) - { - wxBitmap bitmap; - - bitmap << this->GetValue(); - if (bitmap.Ok()) - return (::SetDataBrowserItemDataIcon(this->GetDataReference(),bitmap.GetIconRef()) == noErr); - else - return true; - } /* if */ + wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Bitmap renderer cannot render value; value type: ")) << this->GetValue().GetType()); + + // variable definition: + wxBitmap bitmap; + + bitmap << this->GetValue(); + if (bitmap.Ok()) +#if wxCHECK_VERSION(2,9,0) + return (::SetDataBrowserItemDataIcon(this->GetDataReference(),bitmap.GetIconRef()) == noErr); +#else + return (::SetDataBrowserItemDataIcon(this->GetDataReference(),bitmap.GetBitmapData()->GetIconRef()) == noErr); +#endif else - return false; -} /* wxDataViewBitmapRenderer::Render(void) */ + return true; +} /* wxDataViewBitmapRenderer::Render() */ -WXDataBrowserPropertyType wxDataViewBitmapRenderer::GetPropertyType(void) const +WXDataBrowserPropertyType wxDataViewBitmapRenderer::GetPropertyType() const { return kDataBrowserIconType; -} /* wxDataViewBitmapRenderer::GetPropertyType(void) const */ +} /* wxDataViewBitmapRenderer::GetPropertyType() const */ IMPLEMENT_CLASS(wxDataViewBitmapRenderer,wxDataViewRenderer) @@ -565,34 +675,32 @@ wxDataViewIconTextRenderer::wxDataViewIconTextRenderer(wxString const& variantty { } -bool wxDataViewIconTextRenderer::Render(void) +bool wxDataViewIconTextRenderer::Render() { - if (this->GetValue().GetType() == this->GetVariantType()) - { - // variable definition: - wxDataViewIconText iconText; - - iconText << this->GetValue(); + wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Icon & text renderer cannot render value; value type: ")) << this->GetValue().GetType()); - // variable definition: - wxCFStringRef cfString(iconText.GetText(),(this->GetView()->GetFont().Ok() ? this->GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding())); + // variable definition: + wxDataViewIconText iconText; + + iconText << this->GetValue(); - if (iconText.GetIcon().IsOk()) - { - if (::SetDataBrowserItemDataIcon(this->GetDataReference(),MAC_WXHICON(iconText.GetIcon().GetHICON())) != noErr) - return false; - } - - return (::SetDataBrowserItemDataText(this->GetDataReference(),cfString) == noErr); - } /* if */ - else - return false; -} /* wxDataViewIconTextRenderer::Render(void) */ + // variable definition: +#if wxCHECK_VERSION(2,9,0) + wxCFStringRef cfString(iconText.GetText(),(this->GetView()->GetFont().Ok() ? this->GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding())); +#else + wxMacCFStringHolder cfString(iconText.GetText(),(this->GetView()->GetFont().Ok() ? this->GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding())); +#endif + + if (iconText.GetIcon().IsOk()) + if (::SetDataBrowserItemDataIcon(this->GetDataReference(),MAC_WXHICON(iconText.GetIcon().GetHICON())) != noErr) + return false; + return (::SetDataBrowserItemDataText(this->GetDataReference(),cfString) == noErr); +} /* wxDataViewIconTextRenderer::Render() */ -WXDataBrowserPropertyType wxDataViewIconTextRenderer::GetPropertyType(void) const +WXDataBrowserPropertyType wxDataViewIconTextRenderer::GetPropertyType() const { return kDataBrowserIconAndTextType; -} /* wxDataViewIconTextRenderer::GetPropertyType(void) const */ +} /* wxDataViewIconTextRenderer::GetPropertyType() const */ IMPLEMENT_ABSTRACT_CLASS(wxDataViewIconTextRenderer,wxDataViewRenderer) @@ -606,18 +714,16 @@ wxDataViewToggleRenderer::wxDataViewToggleRenderer(wxString const& varianttype, { } -bool wxDataViewToggleRenderer::Render(void) +bool wxDataViewToggleRenderer::Render() { - if (this->GetValue().GetType() == this->GetVariantType()) - return (::SetDataBrowserItemDataButtonValue(this->GetDataReference(),this->GetValue().GetBool()) == noErr); - else - return false; -} /* wxDataViewToggleRenderer::Render(void) */ + wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Toggle renderer cannot render value; value type: ")) << this->GetValue().GetType()); + return (::SetDataBrowserItemDataButtonValue(this->GetDataReference(),this->GetValue().GetBool()) == noErr); +} /* wxDataViewToggleRenderer::Render() */ -WXDataBrowserPropertyType wxDataViewToggleRenderer::GetPropertyType(void) const +WXDataBrowserPropertyType wxDataViewToggleRenderer::GetPropertyType() const { return kDataBrowserCheckboxType; -} /* wxDataViewToggleRenderer::GetPropertyType(void) const */ +} /* wxDataViewToggleRenderer::GetPropertyType() const */ IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleRenderer,wxDataViewRenderer) @@ -630,20 +736,18 @@ wxDataViewProgressRenderer::wxDataViewProgressRenderer(wxString const& label, wx { } -bool wxDataViewProgressRenderer::Render(void) +bool wxDataViewProgressRenderer::Render() { - if (this->GetValue().GetType() == this->GetVariantType()) - return ((::SetDataBrowserItemDataMinimum(this->GetDataReference(), 0) == noErr) && - (::SetDataBrowserItemDataMaximum(this->GetDataReference(),100) == noErr) && - (::SetDataBrowserItemDataValue (this->GetDataReference(),this->GetValue().GetLong()) == noErr)); - else - return false; -} /* wxDataViewProgressRenderer::Render(void) */ + wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Progress renderer cannot render value type; value type: ")) << this->GetValue().GetType()); + return ((::SetDataBrowserItemDataMinimum(this->GetDataReference(), 0) == noErr) && + (::SetDataBrowserItemDataMaximum(this->GetDataReference(),100) == noErr) && + (::SetDataBrowserItemDataValue (this->GetDataReference(),this->GetValue().GetLong()) == noErr)); +} /* wxDataViewProgressRenderer::Render() */ -WXDataBrowserPropertyType wxDataViewProgressRenderer::GetPropertyType(void) const +WXDataBrowserPropertyType wxDataViewProgressRenderer::GetPropertyType() const { return kDataBrowserProgressBarType; -} /* wxDataViewProgressRenderer::GetPropertyType(void) const */ +} /* wxDataViewProgressRenderer::GetPropertyType() const */ IMPLEMENT_ABSTRACT_CLASS(wxDataViewProgressRenderer,wxDataViewRenderer) @@ -656,18 +760,16 @@ wxDataViewDateRenderer::wxDataViewDateRenderer(wxString const& varianttype, wxDa { } -bool wxDataViewDateRenderer::Render(void) +bool wxDataViewDateRenderer::Render() { - if (this->GetValue().GetType() == this->GetVariantType()) - return (::SetDataBrowserItemDataDateTime(this->GetDataReference(),this->GetValue().GetDateTime().Subtract(wxDateTime(1,wxDateTime::Jan,1904)).GetSeconds().GetLo()) == noErr); - else - return false; -} /* wxDataViewDateRenderer::Render(void) */ + wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Date renderer cannot render value; value type: ")) << this->GetValue().GetType()); + return (::SetDataBrowserItemDataDateTime(this->GetDataReference(),this->GetValue().GetDateTime().Subtract(wxDateTime(1,wxDateTime::Jan,1904)).GetSeconds().GetLo()) == noErr); +} /* wxDataViewDateRenderer::Render() */ -WXDataBrowserPropertyType wxDataViewDateRenderer::GetPropertyType(void) const +WXDataBrowserPropertyType wxDataViewDateRenderer::GetPropertyType() const { return kDataBrowserDateTimeType; -} /* wxDataViewDateRenderer::GetPropertyType(void) const */ +} /* wxDataViewDateRenderer::GetPropertyType() const */ IMPLEMENT_ABSTRACT_CLASS(wxDataViewDateRenderer,wxDataViewRenderer) @@ -676,14 +778,14 @@ IMPLEMENT_ABSTRACT_CLASS(wxDataViewDateRenderer,wxDataViewRenderer) // --------------------------------------------------------- #pragma mark - wxDataViewColumn::wxDataViewColumn(wxString const &title, wxDataViewRenderer *cell, unsigned int model_column, int width, wxAlignment align, int flags) - :wxDataViewColumnBase(title,cell,model_column,width,wxALIGN_CENTER,flags), m_ascending(true), + :wxDataViewColumnBase(title,cell,model_column,width,align,flags), m_ascending(true), m_flags(flags & ~(wxDATAVIEW_COL_HIDDEN)), m_maxWidth(30000), m_minWidth(0), m_width(width >= 0 ? width : wxDVC_DEFAULT_WIDTH), m_alignment(align), m_title(title) { } /* wxDataViewColumn::wxDataViewColumn(wxString const &title, wxDataViewRenderer*, unsigned int, int, wxAlignment, int) */ wxDataViewColumn::wxDataViewColumn(wxBitmap const& bitmap, wxDataViewRenderer *cell, unsigned int model_column, int width, wxAlignment align, int flags) - :wxDataViewColumnBase(bitmap,cell,model_column,width,wxALIGN_CENTER,flags), m_ascending(true), + :wxDataViewColumnBase(bitmap,cell,model_column,width,align,flags), m_ascending(true), m_flags(flags & ~(wxDATAVIEW_COL_HIDDEN)), m_maxWidth(30000), m_minWidth(0), m_width(width >= 0 ? width : wxDVC_DEFAULT_WIDTH), m_alignment(align) { @@ -744,7 +846,11 @@ void wxDataViewColumn::SetBitmap(wxBitmap const& bitmap) wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(this->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description.")); if (this->GetBitmap().Ok()) +#if wxCHECK_VERSION(2,9,0) headerDescription.btnContentInfo.u.iconRef = this->GetBitmap().GetIconRef(); +#else + headerDescription.btnContentInfo.u.iconRef = this->GetBitmap().GetBitmapData()->GetIconRef(); +#endif else headerDescription.btnContentInfo.u.iconRef = NULL; wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(this->GetPropertyID(),&headerDescription) == noErr,_("Could not set icon.")); @@ -754,9 +860,10 @@ void wxDataViewColumn::SetBitmap(wxBitmap const& bitmap) void wxDataViewColumn::SetFlags(int flags) { - this->SetHidden ((flags & wxDATAVIEW_COL_HIDDEN) != 0); - this->SetResizeable((flags & wxDATAVIEW_COL_RESIZABLE) != 0); - this->SetSortable ((flags & wxDATAVIEW_COL_SORTABLE) != 0); + this->SetHidden ((flags & wxDATAVIEW_COL_HIDDEN) != 0); + this->SetReorderable((flags & wxDATAVIEW_COL_REORDERABLE) != 0); + this->SetResizeable ((flags & wxDATAVIEW_COL_RESIZABLE) != 0); + this->SetSortable ((flags & wxDATAVIEW_COL_SORTABLE) != 0); } /* wxDataViewColumn::SetFlags(int) */ void wxDataViewColumn::SetMaxWidth(int maxWidth) @@ -805,15 +912,42 @@ void wxDataViewColumn::SetMinWidth(int minWidth) } /* if */ } /* wxDataViewColumn::SetMaxWidth(int) */ -void wxDataViewColumn::SetResizeable(bool WXUNUSED(resizeable)) +void wxDataViewColumn::SetReorderable(bool reorderable) { -} /* wxDataViewColumn::SetResizeable(bool) */ + // first set the internal flag of the column: + if (reorderable) + this->m_flags |= wxDATAVIEW_COL_REORDERABLE; + else + this->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()); // variable definition and initialization -void wxDataViewColumn::SetSortable(bool sortable) + if (dataViewCtrlPtr != NULL) + { + // variable definition and initialization: + DataBrowserPropertyFlags flags; + 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->GetPropertyID(),&flags) == noErr,_("Could not get property flags.")); + if (reorderable) + flags |= kDataBrowserListViewMovableColumn; + else + flags &= ~kDataBrowserListViewMovableColumn; + wxCHECK_RET(macDataViewListCtrlPtr->SetPropertyFlags(this->GetPropertyID(),flags) == noErr,_("Could not set property flags.")); + } /* if */ +} /* wxDataViewColumn::SetReorderable(bool) */ + +void wxDataViewColumn::SetResizeable(bool resizeable) { - // variable definition and initialization: - wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner()); - + // first set the internal flag of the column: + if (resizeable) + this->m_flags |= wxDATAVIEW_COL_RESIZABLE; + else + this->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()); // variable definition and initialization + if (dataViewCtrlPtr != NULL) { // variable definition and initialization: @@ -822,22 +956,47 @@ void wxDataViewColumn::SetSortable(bool sortable) if (macDataViewListCtrlPtr != NULL) { // variable definition and initialization: - DataBrowserPropertyFlags flags; + DataBrowserListViewHeaderDesc headerDescription; - wxCHECK_RET(macDataViewListCtrlPtr->GetPropertyFlags(this->GetPropertyID(),&flags) == noErr,_("Could not get property flags.")); - if (sortable) - { - this->m_flags |= wxDATAVIEW_COL_SORTABLE; - flags |= kDataBrowserListViewSortableColumn; - } /* if */ - else - { - this->m_flags &= ~wxDATAVIEW_COL_SORTABLE; - flags &= ~kDataBrowserPropertyIsEditable; - } /* if */ - wxCHECK_RET(macDataViewListCtrlPtr->SetPropertyFlags(this->GetPropertyID(),flags) == noErr,_("Could not set property flags.")); + verify_noerr(macDataViewListCtrlPtr->GetHeaderDesc(this->GetPropertyID(),&headerDescription)); + if (resizeable) { + headerDescription.minimumWidth = 0; + headerDescription.maximumWidth = 30000; + } + else { + headerDescription.minimumWidth = this->m_width; + headerDescription.maximumWidth = this->m_width; + } + verify_noerr(macDataViewListCtrlPtr->SetHeaderDesc(this->GetPropertyID(),&headerDescription)); + macDataViewListCtrlPtr->SetSortProperty(this->GetPropertyID()); } /* if */ } /* if */ +} /* wxDataViewColumn::SetResizeable(bool) */ + +void wxDataViewColumn::SetSortable(bool sortable) +{ + // first set the internal flag of the column: + if (sortable) + this->m_flags |= wxDATAVIEW_COL_SORTABLE; + else + this->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()); // variable definition and initialization + + if (dataViewCtrlPtr != NULL) + { + // variable definition and initialization: + DataBrowserPropertyFlags flags; + 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->GetPropertyID(),&flags) == noErr,_("Could not get property flags.")); + if (sortable) + flags |= kDataBrowserListViewSortableColumn; + else + flags &= ~kDataBrowserListViewSortableColumn; + wxCHECK_RET(macDataViewListCtrlPtr->SetPropertyFlags(this->GetPropertyID(),flags) == noErr,_("Could not set property flags.")); + } /* if */ } /* wxDataViewColumn::SetSortable(bool) */ void wxDataViewColumn::SetSortOrder(bool ascending) @@ -882,7 +1041,11 @@ void wxDataViewColumn::SetTitle(wxString const& title) { // variable definition and initialization: DataBrowserListViewHeaderDesc headerDescription; +#if wxCHECK_VERSION(2,9,0) wxCFStringRef cfTitle(title,(dataViewCtrlPtr->GetFont().Ok() ? dataViewCtrlPtr->GetFont().GetEncoding() : wxLocale::GetSystemEncoding())); +#else + wxMacCFStringHolder cfTitle(title,(dataViewCtrlPtr->GetFont().Ok() ? dataViewCtrlPtr->GetFont().GetEncoding() : wxLocale::GetSystemEncoding())); +#endif wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(this->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description.")); headerDescription.titleString = cfTitle; @@ -916,12 +1079,13 @@ IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumn,wxDataViewColumnBase) // wxDataViewCtrl //----------------------------------------------------------------------------- #pragma mark - -void wxDataViewCtrl::Init(void) +void wxDataViewCtrl::Init() { - this->m_Deleting = false; - this->m_macIsUserPane = false; - this->m_cgContext = NULL; -} /* wxDataViewCtrl::Init(void) */ + this->m_CustomRendererPtr = NULL; + this->m_Deleting = false; + this->m_macIsUserPane = false; + this->m_cgContext = NULL; +} /* wxDataViewCtrl::Init() */ bool wxDataViewCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator ) { @@ -939,10 +1103,22 @@ bool wxDataViewCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, InstallControlEventHandler(this->m_peer->GetControlRef(),GetwxMacDataViewCtrlEventHandlerUPP(),GetEventTypeCount(eventList),eventList,this,NULL); ::SetDataBrowserTableViewHiliteStyle( this->m_peer->GetControlRef(), kDataBrowserTableViewFillHilite ); - + return true; } /* wxDataViewCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator) */ +/*static*/ +wxVisualAttributes wxDataViewCtrl::GetClassDefaultAttributes(wxWindowVariant variant) +{ + wxVisualAttributes attr; + + attr.colFg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ); + attr.colBg = wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOX ); + attr.font.MacCreateFromThemeFont(kThemeViewsFont); + + return attr; +} + bool wxDataViewCtrl::AssociateModel(wxDataViewModel* model) { if (!wxDataViewCtrlBase::AssociateModel(model)) @@ -951,9 +1127,19 @@ bool wxDataViewCtrl::AssociateModel(wxDataViewModel* model) model->AddNotifier(new wxMacDataViewModelNotifier(dynamic_cast(this->m_peer))); return true; -} /* wxDataViewCtrl::AssociateModel(wxDataViewModel*) */ +} bool wxDataViewCtrl::AppendColumn(wxDataViewColumn* columnPtr) +{ + return InsertColumn( kDataBrowserListViewAppendColumn, columnPtr ); +} + +bool wxDataViewCtrl::PrependColumn(wxDataViewColumn* columnPtr) +{ + return InsertColumn( 0, columnPtr ); +} + +bool wxDataViewCtrl::InsertColumn(unsigned int pos, wxDataViewColumn* columnPtr) { DataBrowserListViewColumnDesc columnDescription; @@ -961,7 +1147,11 @@ bool wxDataViewCtrl::AppendColumn(wxDataViewColumn* columnPtr) wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast(this->m_peer)); - wxCFStringRef title(columnPtr->GetTitle(),this->m_font.Ok() ? this->m_font.GetEncoding() : wxLocale::GetSystemEncoding()); +#if wxCHECK_VERSION(2,9,0) + wxCFStringRef title(columnPtr->GetTitle(),this->m_font.Ok() ? this->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()); +#else + wxMacCFStringHolder title(columnPtr->GetTitle(),this->m_font.Ok() ? this->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()); +#endif // first, some error checking: @@ -981,7 +1171,7 @@ bool wxDataViewCtrl::AppendColumn(wxDataViewColumn* columnPtr) this->m_ColumnPointers.insert(ColumnPointerHashMapType::value_type(NewPropertyID,columnPtr)).second,false,_("Could not add column to internal structures.")); // create a column description and add column to the native control: wxCHECK_MSG(::InitializeColumnDescription(columnDescription,columnPtr,NewPropertyID,title), false,_("Column description could not be initialized.")); - wxCHECK_MSG(MacDataViewListCtrlPtr->AddColumn(&columnDescription,kDataBrowserListViewAppendColumn) == noErr,false,_("Column could not be added.")); + wxCHECK_MSG(MacDataViewListCtrlPtr->AddColumn(&columnDescription,pos) == noErr,false,_("Column could not be added.")); // final adjustments for the layout: wxCHECK_MSG(MacDataViewListCtrlPtr->SetColumnWidth(NewPropertyID,columnPtr->GetWidth()) == noErr,false,_("Column width could not be set.")); @@ -998,9 +1188,9 @@ bool wxDataViewCtrl::AppendColumn(wxDataViewColumn* columnPtr) MacDataViewListCtrlPtr->UpdateItems(kDataBrowserNoItem,0,NULL,kDataBrowserItemNoProperty,NewPropertyID); // done: return true; -} /* wxDataViewCtrl::AppendColumn(wxDataViewColumn*) */ +} -bool wxDataViewCtrl::ClearColumns(void) +bool wxDataViewCtrl::ClearColumns() { wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast(this->m_peer)); @@ -1012,7 +1202,7 @@ bool wxDataViewCtrl::ClearColumns(void) this->m_ColumnPointers.erase(this->m_ColumnPointers.begin()); } /* while */ return true; -} /* wxDataViewCtrl::ClearColumns(void) */ +} bool wxDataViewCtrl::DeleteColumn(wxDataViewColumn* columnPtr) { @@ -1049,10 +1239,10 @@ wxDataViewColumn* wxDataViewCtrl::GetColumn(unsigned int pos) const return NULL; } /* wxDataViewCtrl::GetColumn(unsigned int pos) const */ -unsigned int wxDataViewCtrl::GetColumnCount(void) const +unsigned int wxDataViewCtrl::GetColumnCount() const { return this->m_ColumnPointers.size(); -} /* wxDataViewCtrl::GetColumnCount(void) const */ +} /* wxDataViewCtrl::GetColumnCount() const */ int wxDataViewCtrl::GetColumnPosition(wxDataViewColumn const* columnPtr) const { @@ -1069,53 +1259,6 @@ int wxDataViewCtrl::GetColumnPosition(wxDataViewColumn const* columnPtr) const return wxNOT_FOUND; } /* wxDataViewCtrl::GetColumnPosition(wxDataViewColumn const*) const */ -bool wxDataViewCtrl::PrependColumn(wxDataViewColumn* columnPtr) -{ - DataBrowserListViewColumnDesc columnDescription; - - DataBrowserPropertyID NewPropertyID; - - wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast(this->m_peer)); - - wxCFStringRef title(columnPtr->GetTitle(),this->m_font.Ok() ? this->m_font.GetEncoding() : wxLocale::GetSystemEncoding()); - - - // first, some error checking: - wxCHECK_MSG(MacDataViewListCtrlPtr != NULL, false,_("m_peer is not or incorrectly initialized")); - wxCHECK_MSG(columnPtr != NULL, false,_("Column pointer must not be NULL.")); - wxCHECK_MSG(columnPtr->GetRenderer() != NULL, false,_("Column does not have a renderer.")); - wxCHECK_MSG(this->GetModel() != NULL, false,_("No model associated with control.")); - wxCHECK_MSG((columnPtr->GetModelColumn() >= 0) && - (columnPtr->GetModelColumn() < this->GetModel()->GetColumnCount()),false,_("Column's model column has no equivalent in the associated model.")); - - // try to get new ID for the column: - wxCHECK_MSG(MacDataViewListCtrlPtr->GetFreePropertyID(&NewPropertyID) == noErr,false,_("Cannot create new column's ID. Probably max. number of columns reached.")); - // full column variable initialization: - columnPtr->SetPropertyID(NewPropertyID); - // add column to wxWidget's internal structure: - wxCHECK_MSG(this->wxDataViewCtrlBase::AppendColumn(columnPtr) && - this->m_ColumnPointers.insert(ColumnPointerHashMapType::value_type(NewPropertyID,columnPtr)).second,false,_("Could not add column to internal structures.")); - // create a column description and add column to the native control: - wxCHECK_MSG(::InitializeColumnDescription(columnDescription,columnPtr,NewPropertyID,title),false,_("Column description could not be initialized.")); - wxCHECK_MSG(MacDataViewListCtrlPtr->AddColumn(&columnDescription,0) == noErr, false,_("Column could not be added.")); - - // final adjustments for the layout: - wxCHECK_MSG(MacDataViewListCtrlPtr->SetColumnWidth(NewPropertyID,columnPtr->GetWidth()) == noErr,false,_("Column width could not be set.")); - - // make sure that the data is up-to-date... - // if the newly appended column is the first column add the initial data to the control and mark the column as an expander column, - // otherwise ask the control to 'update' the data in the newly appended column: - if (this->GetColumnCount() == 1) - { - this->SetExpanderColumn(columnPtr); - this->AddChildrenLevel(wxDataViewItem()); - } /* if */ - else - MacDataViewListCtrlPtr->UpdateItems(kDataBrowserNoItem,0,NULL,kDataBrowserItemNoProperty,NewPropertyID); - // done: - return true; -} /* wxDataViewCtrl::PrependColumn(wxDataViewColumn*) */ - void wxDataViewCtrl::Collapse(wxDataViewItem const& item) { wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast(this->m_peer)); @@ -1148,7 +1291,7 @@ void wxDataViewCtrl::Expand(wxDataViewItem const& item) MacDataViewListCtrlPtr->OpenContainer(reinterpret_cast(item.GetID())); } /* wxDataViewCtrl::Expand(wxDataViewItem const&) */ -wxDataViewColumn* wxDataViewCtrl::GetSortingColumn(void) const +wxDataViewColumn* wxDataViewCtrl::GetSortingColumn() const { DataBrowserPropertyID propertyID; @@ -1159,16 +1302,16 @@ wxDataViewColumn* wxDataViewCtrl::GetSortingColumn(void) const return this->GetColumnPtr(propertyID); else return NULL; -} /* wxDataViewCtrl::GetSortingColumn(void) const */ +} /* wxDataViewCtrl::GetSortingColumn() const */ -unsigned int wxDataViewCtrl::GetCount(void) const +unsigned int wxDataViewCtrl::GetCount() const { ItemCount noOfItems; wxCHECK_MSG(dynamic_cast(this->m_peer)->GetItemCount(&noOfItems) == noErr,0,_("Could not determine number of items")); return noOfItems; -} /* wxDataViewCtrl::GetCount(void) const */ +} /* wxDataViewCtrl::GetCount() const */ wxRect wxDataViewCtrl::GetItemRect(wxDataViewItem const& item, wxDataViewColumn const* columnPtr) const { @@ -1193,7 +1336,7 @@ wxRect wxDataViewCtrl::GetItemRect(wxDataViewItem const& item, wxDataViewColumn return wxRect(); } /* wxDataViewCtrl::GetItemRect(wxDataViewItem const&, unsigned int) const */ -wxDataViewItem wxDataViewCtrl::GetSelection(void) const +wxDataViewItem wxDataViewCtrl::GetSelection() const { wxArrayDataBrowserItemID itemIDs; @@ -1204,7 +1347,7 @@ wxDataViewItem wxDataViewCtrl::GetSelection(void) const return wxDataViewItem(reinterpret_cast(itemIDs[0])); else return wxDataViewItem(); -} /* wxDataViewCtrl::GetSelection(void) const */ +} /* wxDataViewCtrl::GetSelection() const */ int wxDataViewCtrl::GetSelections(wxDataViewItemArray& sel) const { @@ -1237,7 +1380,7 @@ bool wxDataViewCtrl::IsSelected(wxDataViewItem const& item) const return MacDataViewListCtrlPtr->IsItemSelected(reinterpret_cast(item.GetID())); } /* wxDataViewCtrl::IsSelected(wxDataViewItem const&) const */ -void wxDataViewCtrl::SelectAll(void) +void wxDataViewCtrl::SelectAll() { DataBrowserItemID* itemIDPtr; @@ -1255,7 +1398,7 @@ void wxDataViewCtrl::SelectAll(void) MacDataViewListCtrlPtr->SetSelectedItems(NoOfItems,itemIDPtr,kDataBrowserItemsAssign); HUnlock(handle); DisposeHandle(handle); -} /* wxDataViewCtrl::SelectAll(void) */ +} /* wxDataViewCtrl::SelectAll() */ void wxDataViewCtrl::Select(wxDataViewItem const& item) { @@ -1297,7 +1440,7 @@ void wxDataViewCtrl::Unselect(wxDataViewItem const& item) } /* if */ } /* wxDataViewCtrl::Unselect(wxDataViewItem const&) */ -void wxDataViewCtrl::UnselectAll(void) +void wxDataViewCtrl::UnselectAll() { DataBrowserItemID* itemIDPtr; @@ -1315,7 +1458,7 @@ void wxDataViewCtrl::UnselectAll(void) MacDataViewListCtrlPtr->SetSelectedItems(NoOfItems,itemIDPtr,kDataBrowserItemsRemove); HUnlock(handle); DisposeHandle(handle); -} /* wxDataViewCtrl::UnselectAll(void) */ +} /* wxDataViewCtrl::UnselectAll() */ // data handling: void wxDataViewCtrl::AddChildrenLevel(wxDataViewItem const& parentItem) @@ -1333,7 +1476,17 @@ void wxDataViewCtrl::AddChildrenLevel(wxDataViewItem const& parentItem) #else (void) this->GetModel()->ItemsAdded(parentItem,items); #endif -} /* wxDataViewCtrl::AddChildrenLevel(wxDataViewItem const&) */ +} + +void wxDataViewCtrl::FinishCustomItemEditing() +{ + if (this->GetCustomRendererItem().IsOk()) + { + this->GetCustomRendererPtr()->FinishEditing(); + this->SetCustomRendererItem(wxDataViewItem()); + this->SetCustomRendererPtr (NULL); + } +} wxDataViewColumn* wxDataViewCtrl::GetColumnPtr(WXDataBrowserPropertyID propertyID) const { @@ -1344,27 +1497,26 @@ wxDataViewColumn* wxDataViewCtrl::GetColumnPtr(WXDataBrowserPropertyID propertyI return Result->second; else return NULL; -} /* wxDataViewCtrl::GetColumnPtr(DataBrowserPropertyID) const */ +} // inherited methods from wxDataViewCtrlBase -void wxDataViewCtrl::DoSetExpanderColumn(void) +void wxDataViewCtrl::DoSetExpanderColumn() { if (this->GetExpanderColumn() != NULL) { // variable definition and initialization: wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast(this->m_peer)); - (void) MacDataViewListCtrlPtr->SetDisclosureColumn(this->GetExpanderColumn()->GetPropertyID()); - } /* if */ -} /* wxDataViewCtrl::DoSetExpanderColumn(void) */ + (void) MacDataViewListCtrlPtr->SetDisclosureColumn(this->GetExpanderColumn()->GetPropertyID(),false); // second parameter explicitely passed to ensure that arrow is centered + } +} -void wxDataViewCtrl::DoSetIndent(void) +void wxDataViewCtrl::DoSetIndent() { wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast(this->m_peer)); - (void) MacDataViewListCtrlPtr->SetIndent(static_cast(this->GetIndent())); -} /* wxDataViewCtrl::DoSetIndent(void) */ +} // event handling: void wxDataViewCtrl::OnSize(wxSizeEvent& event) @@ -1386,6 +1538,19 @@ void wxDataViewCtrl::OnSize(wxSizeEvent& event) dataViewCustomRendererPtr->SetDC(NULL); // reset DC because DC has changed } /* if */ } /* for */ + + wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast(this->m_peer)); + ControlRef ref = MacDataViewListCtrlPtr->GetControlRef(); + if (NoOfColumns == 1) + { + ::SetDataBrowserHasScrollBars( ref, false, true ); + ::AutoSizeDataBrowserListViewColumns( ref ); + } + if (NoOfColumns > 1) + { + ::SetDataBrowserHasScrollBars( ref, true, true ); + } + event.Skip(); } /* wxDataViewCtrl::OnSize(wxSizeEvent&) */