#ifndef WX_PRECOMP
#include "wx/timer.h"
+ #include "wx/settings.h"
+ #include "wx/dcclient.h"
#endif
#include "wx/icon.h"
return eventNotHandledErr;
} /* wxMacDataViewCtrlEventHandler(EventHandlerCallRef, EventRef, void*) */
+static DataBrowserItemID* CreateDataBrowserItemIDArray(size_t& noOfEntries, wxDataViewItemArray const& items) // returns a newly allocated pointer to valid data browser item IDs
+{
+ size_t const noOfItems = items.GetCount();
+
+ DataBrowserItemID* itemIDs(new DataBrowserItemID[noOfItems]);
+
+
+ // convert all valid data view items to data browser items
+ noOfEntries = 0;
+ for (size_t i=0; i<noOfItems; ++i)
+ if (items[i].IsOk())
+ {
+ itemIDs[noOfEntries] = reinterpret_cast<DataBrowserItemID>(items[i].GetID());
+ ++noOfEntries;
+ } /* if */
+ // done:
+ return itemIDs;
+} /* CreateDataBrowserItemIDArray(size_t&, wxDataViewItemArray const&) */
+
//-----------------------------------------------------------------------------
// local function pointers
//-----------------------------------------------------------------------------
parent.IsOk() && (this->m_dataViewControlPtr->AddItem(reinterpret_cast<DataBrowserItemID>(parent.GetID()),&itemID) == noErr));
} /* ItemAdded(wxDataViewItem const&, wxDataViewItem const&) */
+ virtual bool ItemsAdded(wxDataViewItem const& parent, wxDataViewItemArray const& items)
+ {
+ bool noFailureFlag;
+
+ DataBrowserItemID* itemIDs;
+
+ size_t noOfEntries;
+
+
+ // convert all valid data view items to data browser items:
+ itemIDs = ::CreateDataBrowserItemIDArray(noOfEntries,items);
+ // insert all valid items into control:
+ noFailureFlag = ((noOfEntries == 0) ||
+ !(parent.IsOk()) && (this->m_dataViewControlPtr->AddItems(kDataBrowserNoItem,noOfEntries,itemIDs,kDataBrowserItemNoProperty) == noErr) ||
+ parent.IsOk() && (this->m_dataViewControlPtr->AddItems(reinterpret_cast<DataBrowserItemID>(parent.GetID()),noOfEntries,itemIDs,kDataBrowserItemNoProperty) == noErr));
+ // give allocated array space free again:
+ delete[] itemIDs;
+ // done:
+ return noFailureFlag;
+ } /* ItemsAdded(wxDataViewItem const&, wxDataViewItemArray const&) */
+
virtual bool ItemChanged(wxDataViewItem const& item)
{
DataBrowserItemID itemID(reinterpret_cast<DataBrowserItemID>(item.GetID()));
- wxCHECK_MSG(item.IsOk(), false,_("Changed item is invalid."));
- wxCHECK_MSG(this->GetOwner() != NULL,false,_("Owner not initialized."));
+ wxCHECK_MSG(item.IsOk(),false,_("Changed item is invalid."));
if (this->m_dataViewControlPtr->UpdateItems(&itemID) == noErr)
{
wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->m_dataViewControlPtr->GetPeer()));
// sent the equivalent wxWidget event:
- wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_CHANGED,dataViewCtrlPtr->GetId()); // variable defintion
+ wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED,dataViewCtrlPtr->GetId()); // variable defintion
dataViewEvent.SetEventObject(dataViewCtrlPtr);
dataViewEvent.SetItem(item);
return false;
} /* ItemChanged(wxDataViewItem const&) */
+ virtual bool ItemsChanged(wxDataViewItemArray const& items)
+ {
+ bool noFailureFlag;
+
+ DataBrowserItemID* itemIDs;
+
+ size_t noOfEntries;
+
+
+ // convert all valid data view items to data browser items:
+ itemIDs = ::CreateDataBrowserItemIDArray(noOfEntries,items);
+ // change items (ATTENTION: ONLY ITEMS OF THE ROOT ARE CHANGED BECAUSE THE PARENT PARAMETER IS MISSING):
+ noFailureFlag = (this->m_dataViewControlPtr->UpdateItems(kDataBrowserNoItem,noOfEntries,itemIDs,kDataBrowserItemNoProperty,kDataBrowserItemNoProperty) == noErr);
+ if (noFailureFlag)
+ {
+ wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->m_dataViewControlPtr->GetPeer()));
+
+ // send for all changed items a wxWidget event:
+ wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED,dataViewCtrlPtr->GetId()); // variable defintion
+
+ dataViewEvent.SetEventObject(dataViewCtrlPtr);
+ for (size_t i=0; i<noOfEntries; ++i)
+ {
+ dataViewEvent.SetItem(reinterpret_cast<void*>(itemIDs[i]));
+ dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
+ } /* for */
+ } /* if */
+ // release allocated array space:
+ delete[] itemIDs;
+ // done:
+ return noFailureFlag;
+ } /* ItemsChanged(wxDataViewItem const&) */
+
virtual bool ItemDeleted(wxDataViewItem const& parent, wxDataViewItem const& item)
{
if (item.IsOk())
wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->m_dataViewControlPtr->GetPeer()));
// when this method is called and currently an item is being edited this item may have already been deleted in the model (the passed item and the being edited item have
- // not to be identical because the being edited item might be below the passed item in the hierarchy); therefore, the control is informed that currently a deleting process
- // is started and that variables can currently not be updated even when requested by the system:
+ // not to be identical because the being edited item might be below the passed item in the hierarchy);
+ // to prevent the control trying to ask the model to update an already deleted item the control is informed that currently a deleting process
+ // has been started and that variables can currently not be updated even when requested by the system:
dataViewCtrlPtr->SetDeleting(true);
errorStatus = this->m_dataViewControlPtr->RemoveItem(reinterpret_cast<DataBrowserItemID>(parent.GetID()),&itemID);
+ // enable automatic updating again:
dataViewCtrlPtr->SetDeleting(false);
return (errorStatus == noErr);
} /* if */
return false;
} /* ItemDeleted(wxDataViewItem const&, wxDataViewItem const&) */
+ virtual bool ItemsDeleted(wxDataViewItem const& parent, wxDataViewItemArray const& items)
+ {
+ bool noFailureFlag;
+
+ DataBrowserItemID* itemIDs;
+
+ wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->m_dataViewControlPtr->GetPeer()));
+
+ size_t noOfEntries;
+
+
+ wxCHECK_MSG(dataViewCtrlPtr != NULL,false,_("Data view control is not correctly initialized"));
+ // convert all valid data view items to data browser items:
+ itemIDs = ::CreateDataBrowserItemIDArray(noOfEntries,items);
+ // when this method is called and currently an item is being edited this item may have already been deleted in the model (the passed item and the being edited item have
+ // not to be identical because the being edited item might be below the passed item in the hierarchy);
+ // to prevent the control trying to ask the model to update an already deleted item the control is informed that currently a deleting process
+ // has been started and that variables can currently not be updated even when requested by the system:
+ dataViewCtrlPtr->SetDeleting(true);
+ // insert all valid items into control:
+ noFailureFlag = ((noOfEntries == 0) ||
+ !(parent.IsOk()) && (this->m_dataViewControlPtr->RemoveItems(kDataBrowserNoItem,noOfEntries,itemIDs,kDataBrowserItemNoProperty) == noErr) ||
+ parent.IsOk() && (this->m_dataViewControlPtr->RemoveItems(reinterpret_cast<DataBrowserItemID>(parent.GetID()),noOfEntries,itemIDs,kDataBrowserItemNoProperty) == noErr));
+ // enable automatic updating again:
+ dataViewCtrlPtr->SetDeleting(false);
+ // give allocated array space free again:
+ delete[] itemIDs;
+ // done:
+ return noFailureFlag;
+ } /* ItemsDeleted(wxDataViewItem const&, wxDataViewItemArray const&) */
+
virtual bool ValueChanged(wxDataViewItem const& item, unsigned int col)
{
DataBrowserItemID itemID(reinterpret_cast<DataBrowserItemID>(item.GetID()));
(this->m_dataViewControlPtr->UpdateItems(parentID,1,&itemID,dataViewCtrlPtr->GetColumn(col)->GetPropertyID(),propertyID) == noErr))
{
// variable definition and initialization:
- wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_MODEL_VALUE_CHANGED,dataViewCtrlPtr->GetId());
+ wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED,dataViewCtrlPtr->GetId());
dataViewEvent.SetEventObject(dataViewCtrlPtr);
dataViewEvent.SetColumn(col);
virtual bool Cleared(void)
{
- if (this->m_dataViewControlPtr->RemoveItems() == noErr)
- {
- // variable definitions and initializations:
- wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->m_dataViewControlPtr->GetPeer()));
- wxDataViewEvent dataViewEvent (wxEVT_COMMAND_DATAVIEW_MODEL_CLEARED,dataViewCtrlPtr->GetId());
-
- dataViewEvent.SetEventObject(dataViewCtrlPtr);
- // send the equivalent wxWidget event:
- dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
- // done
- return true;
- } /* if */
- else
- return false;
+ return (this->m_dataViewControlPtr->RemoveItems() == noErr);
} /* Cleared(void) */
virtual void Resort(void)
delete this->m_DCPtr;
} /* wxDataViewCustomRenderer::~wxDataViewCustomRenderer(void) */
+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();
+ dc->SetTextForeground(col);
+ dc->DrawText( text, cell.x + xoffset, cell.y + ((cell.height - dc->GetCharHeight()) / 2));
+}
+
wxDC* wxDataViewCustomRenderer::GetDC(void)
{
if (this->m_DCPtr == NULL)
this->m_DCPtr = newDCPtr;
} /* wxDataViewCustomRenderer::SetDC(wxDC*) */
+WXDataBrowserPropertyType wxDataViewCustomRenderer::GetPropertyType() const
+{
+ return kDataBrowserCustomType;
+}
IMPLEMENT_ABSTRACT_CLASS(wxDataViewCustomRenderer, wxDataViewRenderer)
return false;
} /* wxDataViewTextRenderer::Render(void) */
+WXDataBrowserPropertyType wxDataViewTextRenderer::GetPropertyType() const
+{
+ return kDataBrowserTextType;
+}
+
IMPLEMENT_CLASS(wxDataViewTextRenderer,wxDataViewRenderer)
// ---------------------------------------------------------
return false;
} /* wxDataViewBitmapRenderer::Render(void) */
+WXDataBrowserPropertyType wxDataViewBitmapRenderer::GetPropertyType() const
+{
+ return kDataBrowserIconType;
+}
+
IMPLEMENT_CLASS(wxDataViewBitmapRenderer,wxDataViewRenderer)
// ---------------------------------------------------------
return false;
} /* wxDataViewIconTextRenderer::Render(void) */
+WXDataBrowserPropertyType wxDataViewIconTextRenderer::GetPropertyType() const
+{
+ return kDataBrowserIconAndTextType;
+}
+
IMPLEMENT_ABSTRACT_CLASS(wxDataViewIconTextRenderer,wxDataViewRenderer)
return false;
} /* wxDataViewToggleRenderer::Render(void) */
+WXDataBrowserPropertyType wxDataViewToggleRenderer::GetPropertyType() const
+{
+ return kDataBrowserCheckboxType;
+}
+
IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleRenderer,wxDataViewRenderer)
// ---------------------------------------------------------
return false;
} /* wxDataViewProgressRenderer::Render(void) */
+WXDataBrowserPropertyType wxDataViewProgressRenderer::GetPropertyType() const
+{
+ return kDataBrowserProgressBarType;
+}
+
IMPLEMENT_ABSTRACT_CLASS(wxDataViewProgressRenderer,wxDataViewRenderer)
// ---------------------------------------------------------
return false;
} /* wxDataViewDateRenderer::Render(void) */
+WXDataBrowserPropertyType wxDataViewDateRenderer::GetPropertyType() const
+{
+ return kDataBrowserDateTimeType;
+}
+
IMPLEMENT_ABSTRACT_CLASS(wxDataViewDateRenderer,wxDataViewRenderer)
// ---------------------------------------------------------
else
headerDescription.initialOrder = kDataBrowserOrderDecreasing;
verify_noerr(macDataViewListCtrlPtr->SetHeaderDesc(this->GetPropertyID(),&headerDescription));
+ macDataViewListCtrlPtr->SetSortProperty(this->GetPropertyID());
} /* if */
} /* if */
} /* wxDataViewColumn::SetSortOrder(bool) */
// initialize column description:
dataViewColumnPtr->SetPropertyID(NewPropertyID);
columnDescription.propertyDesc.propertyID = NewPropertyID;
- columnDescription.propertyDesc.propertyType = dataViewColumnPtr->GetRenderer()->GetPropertyType();
+ columnDescription.propertyDesc.propertyType = DataBrowserPropertyType(dataViewColumnPtr->GetRenderer()->GetPropertyType());
columnDescription.propertyDesc.propertyFlags = kDataBrowserListViewSelectionColumn; // make the column selectable
if (dataViewColumnPtr->IsSortable())
columnDescription.propertyDesc.propertyFlags |= kDataBrowserListViewSortableColumn;
#endif
if (dataViewColumnPtr->GetRenderer()->GetMode() == wxDATAVIEW_CELL_EDITABLE)
columnDescription.propertyDesc.propertyFlags |= kDataBrowserPropertyIsEditable;
-#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
+
if ((columnDescription.propertyDesc.propertyType == kDataBrowserTextType) ||
(columnDescription.propertyDesc.propertyType == kDataBrowserIconAndTextType) ||
(columnDescription.propertyDesc.propertyType == kDataBrowserDateTimeType))
columnDescription.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn;
-#endif
+
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
columnDescription.propertyDesc.propertyFlags |= kDataBrowserListViewNoGapForIconInHeaderButton;
#endif
return this->m_ColumnPointers.size();
} /* wxDataViewCtrl::GetColumnCount(void) const */
-int wxDataViewCtrl::GetColumnPosition( const wxDataViewColumn *column ) const
-{
- return -1;
-}
-
-wxDataViewColumn *wxDataViewCtrl::GetSortingColumn() const
+int wxDataViewCtrl::GetColumnPosition(wxDataViewColumn const* columnPtr) const
{
- return NULL;
-}
+ if (columnPtr != NULL)
+ {
+ // variable definition and initialization:
+ DataBrowserTableViewColumnIndex Position;
+ wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
+
+ wxCHECK_MSG(MacDataViewListCtrlPtr->GetColumnIndex(columnPtr->GetPropertyID(),&Position) == noErr,-1,_("Could not determine column's position"));
+ return static_cast<int>(Position);
+ } /* if */
+ else
+ return wxNOT_FOUND;
+} /* wxDataViewCtrl::GetColumnPosition(wxDataViewColumn const*) const */
void wxDataViewCtrl::Collapse(wxDataViewItem const& item)
{
MacDataViewListCtrlPtr->OpenContainer(reinterpret_cast<DataBrowserItemID>(item.GetID()));
} /* wxDataViewCtrl::Expand(wxDataViewItem const&) */
+wxDataViewColumn* wxDataViewCtrl::GetSortingColumn(void) const
+{
+ DataBrowserPropertyID propertyID;
+
+ wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
+
+
+ if (MacDataViewListCtrlPtr->GetSortProperty(&propertyID) == noErr)
+ return this->GetColumnPtr(propertyID);
+ else
+ return NULL;
+} /* wxDataViewCtrl::GetSortingColumn(void) const */
+
unsigned int wxDataViewCtrl::GetCount(void) const
{
ItemCount noOfItems;
wxCHECK_RET(this->GetModel() != NULL,_("Model pointer not initialized."));
NoOfChildren = this->GetModel()->GetChildren(parentItem,items);
+#if 0
for (int i=0; i<NoOfChildren; ++i)
(void) this->GetModel()->ItemAdded(parentItem,items[i]);
+#else
+ (void) this->GetModel()->ItemsAdded(parentItem,items);
+#endif
} /* wxDataViewCtrl::AddChildrenLevel(wxDataViewItem const&) */
-wxDataViewColumn* wxDataViewCtrl::GetColumnPtr(DataBrowserPropertyID propertyID) const
+wxDataViewColumn* wxDataViewCtrl::GetColumnPtr(WXDataBrowserPropertyID propertyID) const
{
// variable definition:
ColumnPointerHashMapType::const_iterator Result(this->m_ColumnPointers.find(propertyID));