/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/carbon/datavgen.cpp
+// Name: src/osx/carbon/datavgen.cpp
// Purpose: wxDataViewCtrl native mac implementation
-// Author:
+// Author:
// Id: $Id$
// Copyright: (c) 2007
// Licence: wxWindows licence
static pascal OSStatus wxMacDataViewCtrlEventHandler(EventHandlerCallRef handler, EventRef EventReference, void* Data)
{
- wxDataViewCtrl* DataViewCtrlPtr((wxDataViewCtrl*) Data); // the 'Data' variable always contains a pointer to the data view control that installed the handler
+ wxDataViewCtrl* DataViewCtrlPtr((wxDataViewCtrl*) Data); // the 'Data' variable always contains a pointer to the data view control that installed the handler
wxMacCarbonEvent CarbonEvent(EventReference) ;
status = ::CallNextEventHandler(handler,EventReference);
DataViewCtrlPtr->MacSetDrawingContext(NULL);
return status;
- } /* block */
+ }
case kEventControlHit :
if (CarbonEvent.GetParameter<ControlPartCode>(kEventParamControlPart,typeControlPartCode) == kControlButtonPart) // we only care about the header
{
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
return eventNotHandledErr;
- } /* switch */
+ }
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;
{
itemIDs[noOfEntries] = reinterpret_cast<DataBrowserItemID>(items[i].GetID());
++noOfEntries;
- } /* if */
+ }
// done:
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.headerBtnDesc.minimumWidth = 0;
columnDescription.headerBtnDesc.maximumWidth = 30000; // 32767 is the theoretical maximum though but 30000 looks nicer
- } /* if */
+ }
else
{
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)
break;
default:
columnDescription.headerBtnDesc.btnFontStyle.just = teFlushDefault;
- } /* switch */
+ }
columnDescription.headerBtnDesc.btnFontStyle.font = kControlFontViewSystemFont;
columnDescription.headerBtnDesc.btnFontStyle.style = normal;
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
{
columnDescription.headerBtnDesc.btnContentInfo.contentType = kControlContentIconRef;
columnDescription.headerBtnDesc.btnContentInfo.u.iconRef = NULL;
}
-
+
// done:
return true;
-} /* InitializeColumnDescription(DataBrowserListViewColumnDesc&, wxDataViewColumn const*, DataBrowserPropertyID, wxMacCFStringHolder const&) */
+}
//-----------------------------------------------------------------------------
// local function pointers
// ---------------------------------------------------------
// wxMacDataViewModelNotifier
// ---------------------------------------------------------
-#pragma mark -
class wxMacDataViewModelNotifier : public wxDataViewModelNotifier
{
public:
virtual bool ItemAdded(const wxDataViewItem &parent, const wxDataViewItem &item)
{
DataBrowserItemID itemID(reinterpret_cast<DataBrowserItemID>(item.GetID()));
-
+
wxCHECK_MSG(item.IsOk(),false,_("Added item is invalid."));
- bool noFailureFlag = (!(parent.IsOk()) && (this->m_dataViewControlPtr->AddItem(kDataBrowserNoItem,&itemID) == noErr) ||
- parent.IsOk() && (this->m_dataViewControlPtr->AddItem(reinterpret_cast<DataBrowserItemID>(parent.GetID()),&itemID) == noErr));
-
- wxDataViewCtrl *dvc = (wxDataViewCtrl*) this->m_dataViewControlPtr->GetPeer();
+ bool noFailureFlag = (!(parent.IsOk()) && (m_dataViewControlPtr->AddItem(kDataBrowserNoItem,&itemID) == noErr) ||
+ parent.IsOk() && (m_dataViewControlPtr->AddItem(reinterpret_cast<DataBrowserItemID>(parent.GetID()),&itemID) == noErr));
+
+ wxDataViewCtrl *dvc = (wxDataViewCtrl*) m_dataViewControlPtr->GetWXPeer();
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;
wxDataViewColumn *column = dvc->GetColumn( col );
if (column->IsHidden())
continue;
-
+
wxDataViewCustomRenderer *renderer = wxDynamicCast( column->GetRenderer(), wxDataViewCustomRenderer );
if (renderer)
{
renderer->SetValue( value );
height = wxMax( height, renderer->GetSize().y );
}
-
+
}
-
+
if (height > 20)
- this->m_dataViewControlPtr->SetRowHeight( itemID, height );
+ m_dataViewControlPtr->SetRowHeight( itemID, height );
}
-
+
return noFailureFlag;
- } /* 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));
+ !(parent.IsOk()) && (m_dataViewControlPtr->AddItems(kDataBrowserNoItem,noOfEntries,itemIDs,kDataBrowserItemNoProperty) == noErr) ||
+ parent.IsOk() && (m_dataViewControlPtr->AddItems(reinterpret_cast<DataBrowserItemID>(parent.GetID()),noOfEntries,itemIDs,kDataBrowserItemNoProperty) == noErr));
// give allocated array space free again:
delete[] itemIDs;
- wxDataViewCtrl *dvc = (wxDataViewCtrl*) this->m_dataViewControlPtr->GetPeer();
+ wxDataViewCtrl *dvc = (wxDataViewCtrl*) m_dataViewControlPtr->GetWXPeer();
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<DataBrowserItemID>(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)
{
height = wxMax( height, renderer->GetSize().y );
}
}
-
+
if (height > 20)
- this->m_dataViewControlPtr->SetRowHeight( itemID, height );
+ m_dataViewControlPtr->SetRowHeight( itemID, height );
}
- }
-
+ }
+
// 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."));
- if (this->m_dataViewControlPtr->UpdateItems(&itemID) == noErr)
+ if (m_dataViewControlPtr->UpdateItems(&itemID) == noErr)
{
- wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->m_dataViewControlPtr->GetPeer()));
-
+ wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(m_dataViewControlPtr->GetWXPeer()));
+
// sent the equivalent wxWidget event:
- wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED,dataViewCtrlPtr->GetId()); // variable defintion
+ wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED,dataViewCtrlPtr->GetId());
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 */
+ }
else
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);
+ noFailureFlag = (m_dataViewControlPtr->UpdateItems(kDataBrowserNoItem,noOfEntries,itemIDs,kDataBrowserItemNoProperty,kDataBrowserItemNoProperty) == noErr);
if (noFailureFlag)
{
- wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->m_dataViewControlPtr->GetPeer()));
-
+ wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(m_dataViewControlPtr->GetWXPeer()));
+
// send for all changed items a wxWidget event:
- wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED,dataViewCtrlPtr->GetId()); // variable defintion
+ wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED,dataViewCtrlPtr->GetId());
dataViewEvent.SetEventObject(dataViewCtrlPtr);
for (size_t i=0; i<noOfEntries; ++i)
{
dataViewEvent.SetItem(reinterpret_cast<void*>(itemIDs[i]));
-#if wxCHECK_VERSION(2,9,0)
dataViewCtrlPtr->HandleWindowEvent(dataViewEvent);
-#else
- dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
-#endif
- } /* 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())
{
- // variable definition and initialization:
DataBrowserItemID itemID(reinterpret_cast<DataBrowserItemID>(item.GetID()));
OSStatus errorStatus;
- wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->m_dataViewControlPtr->GetPeer()));
-
+ wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(m_dataViewControlPtr->GetWXPeer()));
+
// 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);
- errorStatus = this->m_dataViewControlPtr->RemoveItem(reinterpret_cast<DataBrowserItemID>(parent.GetID()),&itemID);
+ errorStatus = m_dataViewControlPtr->RemoveItem(reinterpret_cast<DataBrowserItemID>(parent.GetID()),&itemID);
// enable automatic updating again:
dataViewCtrlPtr->SetDeleting(false);
return (errorStatus == noErr);
- } /* if */
+ }
else
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()));
+
+ wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(m_dataViewControlPtr->GetWXPeer()));
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:
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));
+ !(parent.IsOk()) && (m_dataViewControlPtr->RemoveItems(kDataBrowserNoItem,noOfEntries,itemIDs,kDataBrowserItemNoProperty) == noErr) ||
+ parent.IsOk() && (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()));
DataBrowserItemID parentID;
-
+
DataBrowserPropertyID propertyID;
- wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->m_dataViewControlPtr->GetPeer()));
+ wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(m_dataViewControlPtr->GetWXPeer()));
wxCHECK_MSG(item.IsOk(), false,_("Passed item is invalid."));
wxCHECK_MSG(this->GetOwner() != NULL,false,_("Owner not initialized."));
wxCHECK_MSG(dataViewCtrlPtr != NULL, false,_("Control is wrongly initialized."));
parentID = reinterpret_cast<DataBrowserItemID>(this->GetOwner()->GetParent(item).GetID());
- if ((this->m_dataViewControlPtr->GetPropertyID(col,&propertyID) == noErr) &&
- (this->m_dataViewControlPtr->UpdateItems(parentID,1,&itemID,dataViewCtrlPtr->GetColumn(col)->GetPropertyID(),propertyID) == noErr))
+ if ((m_dataViewControlPtr->GetPropertyID(col,&propertyID) == noErr) &&
+ (m_dataViewControlPtr->UpdateItems(parentID,1,&itemID,dataViewCtrlPtr->GetColumn(col)->GetPropertyID(),propertyID) == noErr))
{
- // variable definition and initialization:
wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED,dataViewCtrlPtr->GetId());
dataViewEvent.SetEventObject(dataViewCtrlPtr);
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 */
+ }
else
return false;
- } /* ValueChanged(wxDataViewItem const&, unsigned int) */
+ }
virtual bool Cleared()
{
- bool noFailureFlag = (this->m_dataViewControlPtr->RemoveItems() == noErr);
+ bool noFailureFlag = (m_dataViewControlPtr->RemoveItems() == noErr);
wxDataViewItem item;
wxDataViewItemArray array;
GetOwner()->GetChildren( item, array );
ItemsAdded( item, array );
- this->m_dataViewControlPtr->SetScrollPosition(0, 0);
+ m_dataViewControlPtr->SetScrollPosition(0, 0);
return noFailureFlag;
- } /* Cleared() */
+ }
virtual void Resort()
{
- this->m_dataViewControlPtr->Resort();
+ m_dataViewControlPtr->Resort();
}
-protected:
private:
-//
-// variables
-//
wxMacDataViewDataBrowserListViewControl* m_dataViewControlPtr;
};
// ---------------------------------------------------------
// wxDataViewRenderer
// ---------------------------------------------------------
-#pragma mark -
wxDataViewRenderer::wxDataViewRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align)
:wxDataViewRendererBase(varianttype,mode,align), m_alignment(align), m_mode(mode)
{
-} /* wxDataViewRenderer::wxDataViewRenderer(wxString const&, wxDataViewCellMode) */
+}
void wxDataViewRenderer::SetMode(wxDataViewCellMode mode)
{
wxDataViewColumn* dataViewColumnPtr;
- this->m_mode = mode;
+ m_mode = mode;
dataViewColumnPtr = this->GetOwner();
if (dataViewColumnPtr != NULL)
{
- // variable definition and initialization:
wxDataViewCtrl* dataViewCtrlPtr(dataViewColumnPtr->GetOwner());
-
+
if (dataViewCtrlPtr != NULL)
{
- // variable definition and initialization:
wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
-
+
if (macDataViewListCtrlPtr != NULL)
{
- // variable definition and initialization:
DataBrowserPropertyFlags flags;
-
+
verify_noerr(macDataViewListCtrlPtr->GetPropertyFlags(dataViewColumnPtr->GetPropertyID(),&flags));
if (mode == wxDATAVIEW_CELL_EDITABLE)
flags |= kDataBrowserPropertyIsEditable;
else
flags &= ~kDataBrowserPropertyIsEditable;
verify_noerr(macDataViewListCtrlPtr->SetPropertyFlags(dataViewColumnPtr->GetPropertyID(),flags));
- } /* if */
- } /* if */
- } /* if */
-} /* wxDataViewRenderer::SetMode(wxDataViewCellMode) */
+ }
+ }
+ }
+}
IMPLEMENT_ABSTRACT_CLASS(wxDataViewRenderer,wxDataViewRendererBase)
// ---------------------------------------------------------
// wxDataViewCustomRenderer
// ---------------------------------------------------------
-#pragma mark -
wxDataViewCustomRenderer::wxDataViewCustomRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align)
:wxDataViewRenderer(varianttype,mode,align), m_editorCtrlPtr(NULL), m_DCPtr(NULL)
{
-} /* wxDataViewCustomRenderer::wxDataViewCustomRenderer(wxString const&, wxDataViewCellMode) */
+}
wxDataViewCustomRenderer::~wxDataViewCustomRenderer()
{
- if (this->m_DCPtr != NULL)
- delete this->m_DCPtr;
-} /* wxDataViewCustomRenderer::~wxDataViewCustomRenderer() */
+ delete m_DCPtr;
+}
void wxDataViewCustomRenderer::RenderText( const wxString &text, int xoffset, wxRect cell, wxDC *dc, int state )
{
wxDC* wxDataViewCustomRenderer::GetDC()
{
- if (this->m_DCPtr == NULL)
+ if (m_DCPtr == NULL)
{
if ((GetOwner() == NULL) || (GetOwner()->GetOwner() == NULL))
return NULL;
- this->m_DCPtr = new wxWindowDC(this->GetOwner()->GetOwner());
- } /* if */
- return this->m_DCPtr;
-} /* wxDataViewCustomRenderer::GetDC() */
+ m_DCPtr = new wxWindowDC(this->GetOwner()->GetOwner());
+ }
+ return m_DCPtr;
+}
bool wxDataViewCustomRenderer::Render()
{
return true;
-} /* wxDataViewCustomRenderer::Render() */
+}
void wxDataViewCustomRenderer::SetDC(wxDC* newDCPtr)
{
- delete this->m_DCPtr;
- this->m_DCPtr = newDCPtr;
-} /* wxDataViewCustomRenderer::SetDC(wxDC*) */
+ delete m_DCPtr;
+ m_DCPtr = newDCPtr;
+}
WXDataBrowserPropertyType wxDataViewCustomRenderer::GetPropertyType() const
{
return kDataBrowserCustomType;
-} /* wxDataViewCustomRenderer::GetPropertyType() const */
+}
IMPLEMENT_ABSTRACT_CLASS(wxDataViewCustomRenderer, wxDataViewRenderer)
// ---------------------------------------------------------
// wxDataViewTextRenderer
// ---------------------------------------------------------
-#pragma mark -
wxDataViewTextRenderer::wxDataViewTextRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align)
:wxDataViewRenderer(varianttype,mode,align)
{
-} /* wxDataViewTextRenderer::wxDataViewTextRenderer(wxString const&, wxDataViewCellMode, int) */
+}
bool wxDataViewTextRenderer::Render()
{
wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Text renderer cannot render value; value type: ")) << this->GetValue().GetType());
- // 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() const
{
return kDataBrowserTextType;
-} /* wxDataViewTextRenderer::GetPropertyType() const */
+}
IMPLEMENT_CLASS(wxDataViewTextRenderer,wxDataViewRenderer)
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewTextRendererAttr
-// ---------------------------------------------------------
-#pragma mark -
+// ---------------------------------------------------------
wxDataViewTextRendererAttr::wxDataViewTextRendererAttr(wxString const& varianttype, wxDataViewCellMode mode, int align)
:wxDataViewTextRenderer(varianttype,mode,align)
{
-} /* wxDataViewTextRendererAttr::wxDataViewTextRendererAttr(wxString const&, wxDataViewCellMode, int) */
-
+}
+
IMPLEMENT_CLASS(wxDataViewTextRendererAttr,wxDataViewTextRenderer)
// ---------------------------------------------------------
// wxDataViewBitmapRenderer
// ---------------------------------------------------------
-#pragma mark -
wxDataViewBitmapRenderer::wxDataViewBitmapRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align)
:wxDataViewRenderer(varianttype,mode,align)
{
{
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 true;
-} /* wxDataViewBitmapRenderer::Render() */
+}
WXDataBrowserPropertyType wxDataViewBitmapRenderer::GetPropertyType() const
{
return kDataBrowserIconType;
-} /* wxDataViewBitmapRenderer::GetPropertyType() const */
+}
IMPLEMENT_CLASS(wxDataViewBitmapRenderer,wxDataViewRenderer)
// ---------------------------------------------------------
// wxDataViewIconTextRenderer
// ---------------------------------------------------------
-#pragma mark -
wxDataViewIconTextRenderer::wxDataViewIconTextRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align)
:wxDataViewRenderer(varianttype,mode)
{
{
wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Icon & text renderer cannot render value; value type: ")) << this->GetValue().GetType());
- // variable definition:
wxDataViewIconText iconText;
-
+
iconText << this->GetValue();
- // 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() const
{
return kDataBrowserIconAndTextType;
-} /* wxDataViewIconTextRenderer::GetPropertyType() const */
+}
IMPLEMENT_ABSTRACT_CLASS(wxDataViewIconTextRenderer,wxDataViewRenderer)
// ---------------------------------------------------------
// wxDataViewToggleRenderer
// ---------------------------------------------------------
-#pragma mark -
wxDataViewToggleRenderer::wxDataViewToggleRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align)
:wxDataViewRenderer(varianttype,mode)
{
{
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() const
{
return kDataBrowserCheckboxType;
-} /* wxDataViewToggleRenderer::GetPropertyType() const */
+}
IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleRenderer,wxDataViewRenderer)
// ---------------------------------------------------------
// wxDataViewProgressRenderer
// ---------------------------------------------------------
-#pragma mark -
wxDataViewProgressRenderer::wxDataViewProgressRenderer(wxString const& label, wxString const& varianttype, wxDataViewCellMode mode, int align)
:wxDataViewRenderer(varianttype,mode,align)
{
return ((::SetDataBrowserItemDataMinimum(this->GetDataReference(), 0) == noErr) &&
(::SetDataBrowserItemDataMaximum(this->GetDataReference(),100) == noErr) &&
(::SetDataBrowserItemDataValue (this->GetDataReference(),this->GetValue().GetLong()) == noErr));
-} /* wxDataViewProgressRenderer::Render() */
+}
WXDataBrowserPropertyType wxDataViewProgressRenderer::GetPropertyType() const
{
return kDataBrowserProgressBarType;
-} /* wxDataViewProgressRenderer::GetPropertyType() const */
+}
IMPLEMENT_ABSTRACT_CLASS(wxDataViewProgressRenderer,wxDataViewRenderer)
// ---------------------------------------------------------
// wxDataViewDateRenderer
// ---------------------------------------------------------
-#pragma mark -
wxDataViewDateRenderer::wxDataViewDateRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align)
:wxDataViewRenderer(varianttype,mode,align)
{
{
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() const
{
return kDataBrowserDateTimeType;
-} /* wxDataViewDateRenderer::GetPropertyType() const */
+}
IMPLEMENT_ABSTRACT_CLASS(wxDataViewDateRenderer,wxDataViewRenderer)
// ---------------------------------------------------------
// wxDataViewColumn
// ---------------------------------------------------------
-#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,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,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)
-{
-} /* wxDataViewColumn::wxDataViewColumn(wxBitmap const&, wxDataViewRenderer*, unsigned int, int, wxAlignment, int) */
void wxDataViewColumn::SetAlignment(wxAlignment align)
{
wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner());
-
- this->m_alignment = align;
+
+ m_alignment = align;
if (dataViewCtrlPtr != NULL)
{
- // variable definition and initialization:
wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
-
+
if (macDataViewListCtrlPtr != NULL)
{
- // variable definition and initialization:
DataBrowserListViewHeaderDesc headerDescription;
wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(this->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description."));
break;
default:
headerDescription.btnFontStyle.just = teFlushDefault;
- } /* switch */
+ }
wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(this->GetPropertyID(),&headerDescription) == noErr,_("Could not set alignment."));
- } /* if */
- } /* if */
-} /* wxDataViewColumn::SetAlignment(wxAlignment) */
+ }
+ }
+}
void wxDataViewColumn::SetBitmap(wxBitmap const& bitmap)
{
wxDataViewColumnBase::SetBitmap(bitmap);
if (dataViewCtrlPtr != NULL)
{
- // variable definition and initialization:
wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
-
+
if (macDataViewListCtrlPtr != NULL)
{
- // variable definition and initialization:
DataBrowserListViewHeaderDesc headerDescription;
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."));
- } /* if */
- } /* if */
-} /* wxDataViewColumn::SetBitmap(wxBitmap const&) */
-
-void wxDataViewColumn::SetFlags(int flags)
-{
- 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)
{
wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner());
-
- this->m_maxWidth = maxWidth;
+
+ m_maxWidth = maxWidth;
if (dataViewCtrlPtr != NULL)
{
- // variable definition and initialization:
wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
-
+
if (macDataViewListCtrlPtr != NULL)
{
- // variable definition and initialization:
DataBrowserListViewHeaderDesc headerDescription;
-
+
wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(this->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description."));
headerDescription.maximumWidth = static_cast<UInt16>(maxWidth);
wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(this->GetPropertyID(),&headerDescription) == noErr,_("Could not set maximum width."));
- } /* if */
- } /* if */
-} /* wxDataViewColumn::SetMaxWidth(int) */
+ }
+ }
+}
void wxDataViewColumn::SetMinWidth(int minWidth)
{
wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner());
-
- this->m_minWidth = minWidth;
+
+ m_minWidth = minWidth;
if (dataViewCtrlPtr != NULL)
{
- // variable definition and initialization:
wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
-
+
if (macDataViewListCtrlPtr != NULL)
{
- // variable definition and initialization:
DataBrowserListViewHeaderDesc headerDescription;
-
+
wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(this->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description."));
headerDescription.minimumWidth = static_cast<UInt16>(minWidth);
wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(this->GetPropertyID(),&headerDescription) == noErr,_("Could not set minimum width."));
- } /* if */
- } /* if */
-} /* wxDataViewColumn::SetMaxWidth(int) */
+ }
+ }
+}
void wxDataViewColumn::SetReorderable(bool reorderable)
{
// first set the internal flag of the column:
if (reorderable)
- this->m_flags |= wxDATAVIEW_COL_REORDERABLE;
+ m_flags |= wxDATAVIEW_COL_REORDERABLE;
else
- this->m_flags &= ~wxDATAVIEW_COL_REORDERABLE;
+ 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
+ wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner());
if (dataViewCtrlPtr != NULL)
{
- // variable definition and initialization:
DataBrowserPropertyFlags flags;
wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(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)
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)
{
// first set the internal flag of the column:
if (resizeable)
- this->m_flags |= wxDATAVIEW_COL_RESIZABLE;
+ m_flags |= wxDATAVIEW_COL_RESIZABLE;
else
- this->m_flags &= ~wxDATAVIEW_COL_RESIZABLE;
+ 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
+ wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner());
if (dataViewCtrlPtr != NULL)
{
- // variable definition and initialization:
wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
-
+
if (macDataViewListCtrlPtr != NULL)
{
- // variable definition and initialization:
DataBrowserListViewHeaderDesc headerDescription;
-
+
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;
+ headerDescription.minimumWidth = m_width;
+ headerDescription.maximumWidth = 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;
+ m_flags |= wxDATAVIEW_COL_SORTABLE;
else
- this->m_flags &= ~wxDATAVIEW_COL_SORTABLE;
+ 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
+ wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner());
if (dataViewCtrlPtr != NULL)
{
- // variable definition and initialization:
DataBrowserPropertyFlags flags;
wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(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)
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)
{
wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner());
-
- this->m_ascending = ascending;
+
+ m_ascending = ascending;
if (dataViewCtrlPtr != NULL)
{
- // variable definition and initialization:
wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
-
+
if (macDataViewListCtrlPtr != NULL)
{
- // variable definition and initialization:
DataBrowserListViewHeaderDesc headerDescription;
-
+
verify_noerr(macDataViewListCtrlPtr->GetHeaderDesc(this->GetPropertyID(),&headerDescription));
if (ascending)
headerDescription.initialOrder = kDataBrowserOrderIncreasing;
headerDescription.initialOrder = kDataBrowserOrderDecreasing;
verify_noerr(macDataViewListCtrlPtr->SetHeaderDesc(this->GetPropertyID(),&headerDescription));
macDataViewListCtrlPtr->SetSortProperty(this->GetPropertyID());
- } /* if */
- } /* if */
-} /* wxDataViewColumn::SetSortOrder(bool) */
+ }
+ }
+}
void wxDataViewColumn::SetTitle(wxString const& title)
{
wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner());
-
- this->m_title = title;
+
+ m_title = title;
if (dataViewCtrlPtr != NULL)
{
- // variable definition and initialization:
wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
-
+
if (macDataViewListCtrlPtr != NULL)
{
- // 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;
wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(this->GetPropertyID(),&headerDescription) == noErr,_("Could not set header description."));
- } /* if */
- } /* if */
-} /* wxDataViewColumn::SetTitle(wxString const&) */
+ }
+ }
+}
void wxDataViewColumn::SetWidth(int width)
{
wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner());
-
- if ((width >= this->m_minWidth) && (width <= this->m_maxWidth))
+
+ if ((width >= m_minWidth) && (width <= m_maxWidth))
{
- this->m_width = width;
+ m_width = width;
if (dataViewCtrlPtr != NULL)
{
- // variable definition and initialization:
wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
-
+
if (macDataViewListCtrlPtr != NULL)
wxCHECK_RET(macDataViewListCtrlPtr->SetColumnWidth(this->GetPropertyID(),static_cast<UInt16>(width)) == noErr,_("Could not set column width."));
- } /* if */
- } /* if */
-} /* wxDataViewColumn::SetWidth(int) */
+ }
+ }
+}
+
+void wxDataViewColumn::SetAsSortKey(bool WXUNUSED(sort))
+{
+ // see wxGTK native wxDataViewColumn implementation
+ wxFAIL_MSG( "not implemented" );
+}
+
+bool wxDataViewColumn::IsSortKey() const
+{
+ wxDataViewCtrl * const dataViewCtrlPtr(GetOwner());
+ wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(
+ dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(
+ dataViewCtrlPtr->GetPeer()));
-IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumn,wxDataViewColumnBase)
+ DataBrowserPropertyID propertyID;
+ return macDataViewListCtrlPtr->GetSortProperty(&propertyID) == noErr &&
+ propertyID == m_propertyID;
+}
//-----------------------------------------------------------------------------
// wxDataViewCtrl
ClearColumns();
}
-#pragma mark -
void wxDataViewCtrl::Init()
{
- this->m_CustomRendererPtr = NULL;
- this->m_Deleting = false;
- this->m_macIsUserPane = false;
- this->m_cgContext = NULL;
-} /* wxDataViewCtrl::Init() */
+ m_CustomRendererPtr = NULL;
+ m_Deleting = false;
+ m_macIsUserPane = false;
+ m_cgContext = NULL;
+}
bool wxDataViewCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator )
{
- if (!(this->wxControl::Create(parent,id,pos,size,(style | wxSUNKEN_BORDER) & ~(wxHSCROLL | wxVSCROLL),validator)))
+ if (!(this->wxControl::Create(parent,id,pos,size,style & ~(wxHSCROLL | wxVSCROLL),validator)))
return false;
#ifdef __WXMAC__
MacSetClipChildren(true) ;
#endif
- this->m_peer = new wxMacDataViewDataBrowserListViewControl(this,pos,size,style);
+ m_peer = new wxMacDataViewDataBrowserListViewControl(this,pos,size,style);
+
+ if ( style & wxBORDER_NONE )
+ m_peer->SetData( kControlNoPart, kControlDataBrowserIncludesFrameAndFocusTag, (Boolean) false ) ;
+
this->MacPostControlCreate(pos,size);
- ::SetAutomaticControlDragTrackingEnabledForWindow(::GetControlOwner(this->m_peer->GetControlRef()),true);
+ ::SetAutomaticControlDragTrackingEnabledForWindow(::GetControlOwner(m_peer->GetControlRef()),true);
- InstallControlEventHandler(this->m_peer->GetControlRef(),GetwxMacDataViewCtrlEventHandlerUPP(),GetEventTypeCount(eventList),eventList,this,NULL);
+ InstallControlEventHandler(m_peer->GetControlRef(),GetwxMacDataViewCtrlEventHandlerUPP(),GetEventTypeCount(eventList),eventList,this,NULL);
+
+ ::SetDataBrowserTableViewHiliteStyle( m_peer->GetControlRef(), kDataBrowserTableViewFillHilite );
- ::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)
{
if (!wxDataViewCtrlBase::AssociateModel(model))
return false;
-
- model->AddNotifier(new wxMacDataViewModelNotifier(dynamic_cast<wxMacDataViewDataBrowserListViewControl*>(this->m_peer)));
+
+ model->AddNotifier(new wxMacDataViewModelNotifier(dynamic_cast<wxMacDataViewDataBrowserListViewControl*>(m_peer)));
return true;
}
bool wxDataViewCtrl::AppendColumn(wxDataViewColumn* columnPtr)
{
- return InsertColumn( kDataBrowserListViewAppendColumn, columnPtr );
-}
+ return wxDataViewCtrl::InsertColumn( GetColumnCount(), columnPtr );
+}
bool wxDataViewCtrl::PrependColumn(wxDataViewColumn* columnPtr)
{
- return InsertColumn( 0, columnPtr );
+ return wxDataViewCtrl::InsertColumn( 0, columnPtr );
}
bool wxDataViewCtrl::InsertColumn(unsigned int pos, wxDataViewColumn* columnPtr)
DataBrowserPropertyID NewPropertyID;
- wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
+ wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(m_peer));
-#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
+ wxCFStringRef title(columnPtr->GetTitle(),m_font.Ok() ? this->GetFont().GetEncoding() : wxLocale::GetSystemEncoding());
// first, some error checking:
// 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."));
+ wxCHECK_MSG(this->wxDataViewCtrlBase::InsertColumn(pos,columnPtr) &&
+ 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,pos) == noErr,false,_("Column could not be added."));
{
this->SetExpanderColumn(columnPtr);
this->AddChildrenLevel(wxDataViewItem());
- } /* if */
+ }
else
MacDataViewListCtrlPtr->UpdateItems(kDataBrowserNoItem,0,NULL,kDataBrowserItemNoProperty,NewPropertyID);
// done:
bool wxDataViewCtrl::ClearColumns()
{
- wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
+ wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(m_peer));
-
- while (this->m_ColumnPointers.begin() != this->m_ColumnPointers.end())
+
+ while (m_ColumnPointers.begin() != m_ColumnPointers.end())
{
- wxCHECK_MSG(MacDataViewListCtrlPtr->RemoveColumnByProperty(this->m_ColumnPointers.begin()->first) == noErr,false,_("Could not remove column."));
- delete this->m_ColumnPointers.begin()->second;
- this->m_ColumnPointers.erase(this->m_ColumnPointers.begin());
- } /* while */
+ wxCHECK_MSG(MacDataViewListCtrlPtr->RemoveColumnByProperty(m_ColumnPointers.begin()->first) == noErr,false,_("Could not remove column."));
+ delete m_ColumnPointers.begin()->second;
+ m_ColumnPointers.erase(m_ColumnPointers.begin());
+ }
return true;
-}
+}
bool wxDataViewCtrl::DeleteColumn(wxDataViewColumn* columnPtr)
{
- wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
+ wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(m_peer));
-
- if ((MacDataViewListCtrlPtr->RemoveColumnByProperty(columnPtr->GetPropertyID()) == noErr) && (this->m_ColumnPointers.erase(columnPtr->GetPropertyID()) > 0))
+
+ if ((MacDataViewListCtrlPtr->RemoveColumnByProperty(columnPtr->GetPropertyID()) == noErr) && (m_ColumnPointers.erase(columnPtr->GetPropertyID()) > 0))
{
delete columnPtr;
return true;
- } /* if */
+ }
else
return false;
-} /* wxDataViewCtrl::DeleteColumn(wxDataViewColumn*) */
+}
wxDataViewColumn* wxDataViewCtrl::GetColumn(unsigned int pos) const
{
DataBrowserPropertyID propertyID;
-
- wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
-
+ wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(m_peer));
+
+
if (MacDataViewListCtrlPtr->GetPropertyID(pos,&propertyID) == noErr)
{
- // variable definition:
- ColumnPointerHashMapType::const_iterator Result(this->m_ColumnPointers.find(propertyID));
-
- if (Result != this->m_ColumnPointers.end())
+ ColumnPointerHashMapType::const_iterator Result(m_ColumnPointers.find(propertyID));
+
+ if (Result != m_ColumnPointers.end())
return Result->second;
else
return NULL;
- } /* if */
+ }
else
return NULL;
-} /* wxDataViewCtrl::GetColumn(unsigned int pos) const */
+}
unsigned int wxDataViewCtrl::GetColumnCount() const
{
- return this->m_ColumnPointers.size();
-} /* wxDataViewCtrl::GetColumnCount() const */
+ return m_ColumnPointers.size();
+}
int wxDataViewCtrl::GetColumnPosition(wxDataViewColumn const* columnPtr) const
{
if (columnPtr != NULL)
{
- // variable definition and initialization:
DataBrowserTableViewColumnIndex Position;
- wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
-
+ wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(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)
{
- wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
+ wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(m_peer));
MacDataViewListCtrlPtr->CloseContainer(reinterpret_cast<DataBrowserItemID>(item.GetID()));
-} /* wxDataViewCtrl::Collapse(wxDataViewItem const&) */
+}
void wxDataViewCtrl::EnsureVisible(wxDataViewItem const& item, wxDataViewColumn const* columnPtr)
{
+ ExpandAncestors(item);
+
if (item.IsOk())
{
- // variable definition and initialization:
DataBrowserPropertyID propertyID;
- wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
+ wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(m_peer));
if (columnPtr != NULL)
propertyID = columnPtr->GetPropertyID();
else
propertyID = kDataBrowserNoItem;
MacDataViewListCtrlPtr->RevealItem(reinterpret_cast<DataBrowserItemID>(item.GetID()),propertyID,kDataBrowserRevealOnly);
- } /* if */
-} /* wxDataViewCtrl::EnsureVisible(wxDataViewItem const&, wxDataViewColumn const*) */
+ }
+}
void wxDataViewCtrl::Expand(wxDataViewItem const& item)
{
- wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
-
-
+ wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(m_peer));
+
+
MacDataViewListCtrlPtr->OpenContainer(reinterpret_cast<DataBrowserItemID>(item.GetID()));
-} /* wxDataViewCtrl::Expand(wxDataViewItem const&) */
+}
+
+bool wxDataViewCtrl::IsExpanded( const wxDataViewItem & item ) const
+{
+ if (item.IsOk())
+ {
+ wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(m_peer));
+
+ DataBrowserItemState state = 0;
+ OSStatus err = ::GetDataBrowserItemState(
+ MacDataViewListCtrlPtr->GetControlRef(),
+ reinterpret_cast<DataBrowserItemID>(item.GetID()),
+ &state );
+ if ((err == 0) && (state & kDataBrowserContainerIsOpen))
+ return true;
+ }
+ return false;
+}
wxDataViewColumn* wxDataViewCtrl::GetSortingColumn() const
{
DataBrowserPropertyID propertyID;
- wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
-
-
+ wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(m_peer));
+
+
if (MacDataViewListCtrlPtr->GetSortProperty(&propertyID) == noErr)
return this->GetColumnPtr(propertyID);
else
return NULL;
-} /* wxDataViewCtrl::GetSortingColumn() const */
+}
unsigned int wxDataViewCtrl::GetCount() const
{
ItemCount noOfItems;
- wxCHECK_MSG(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer)->GetItemCount(&noOfItems) == noErr,0,_("Could not determine number of items"));
+ wxCHECK_MSG(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(m_peer)->GetItemCount(&noOfItems) == noErr,0,_("Could not determine number of items"));
return noOfItems;
-} /* wxDataViewCtrl::GetCount() const */
+}
wxRect wxDataViewCtrl::GetItemRect(wxDataViewItem const& item, wxDataViewColumn const* columnPtr) const
{
if (item.IsOk() && (columnPtr != NULL))
{
- // variable definition:
Rect MacRectangle;
- wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
-
+ wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(m_peer));
+
if (MacDataViewListCtrlPtr->GetPartBounds(reinterpret_cast<DataBrowserItemID>(item.GetID()),columnPtr->GetPropertyID(),kDataBrowserPropertyContentPart,&MacRectangle) == noErr)
{
- // variable definition:
wxRect rectangle;
-
+
::wxMacNativeToRect(&MacRectangle,&rectangle);
return rectangle;
- } /* if */
+ }
else
return wxRect();
- } /* if */
+ }
else
return wxRect();
-} /* wxDataViewCtrl::GetItemRect(wxDataViewItem const&, unsigned int) const */
+}
wxDataViewItem wxDataViewCtrl::GetSelection() const
{
wxArrayDataBrowserItemID itemIDs;
-
- wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
-
+ wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(m_peer));
+
+
if (MacDataViewListCtrlPtr->GetSelectedItemIDs(itemIDs) > 0)
return wxDataViewItem(reinterpret_cast<void*>(itemIDs[0]));
else
return wxDataViewItem();
-} /* wxDataViewCtrl::GetSelection() const */
+}
int wxDataViewCtrl::GetSelections(wxDataViewItemArray& sel) const
{
size_t NoOfSelectedItems;
wxArrayDataBrowserItemID itemIDs;
-
- wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
-
-
+
+ wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(m_peer));
+
+
NoOfSelectedItems = MacDataViewListCtrlPtr->GetSelectedItemIDs(itemIDs);
sel.Empty();
sel.SetCount(NoOfSelectedItems);
for (size_t i=0; i<NoOfSelectedItems; ++i)
sel[i] = wxDataViewItem(reinterpret_cast<void*>(itemIDs[i]));
return static_cast<int>(NoOfSelectedItems);
-} /* wxDataViewCtrl::GetSelections(wxDataViewItemArray&) const */
+}
void wxDataViewCtrl::HitTest(wxPoint const& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const
{
item = wxDataViewItem();
columnPtr = NULL;
-} /* wxDataViewCtrl::HitTest(wxPoint const&, wxDataViewItem&, wxDataViewColumn*&) const */
+}
bool wxDataViewCtrl::IsSelected(wxDataViewItem const& item) const
{
- wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
-
-
+ wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(m_peer));
+
+
return MacDataViewListCtrlPtr->IsItemSelected(reinterpret_cast<DataBrowserItemID>(item.GetID()));
-} /* wxDataViewCtrl::IsSelected(wxDataViewItem const&) const */
+}
void wxDataViewCtrl::SelectAll()
{
DataBrowserItemID* itemIDPtr;
Handle handle(::NewHandle(0));
-
+
size_t NoOfItems;
-
- wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
-
-
+
+ wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(m_peer));
+
+
wxCHECK_RET(MacDataViewListCtrlPtr->GetItems(kDataBrowserNoItem,true,kDataBrowserItemAnyState,handle) == noErr,_("Could not get items."));
NoOfItems = static_cast<size_t>(::GetHandleSize(handle)/sizeof(DataBrowserItemID));
HLock(handle);
MacDataViewListCtrlPtr->SetSelectedItems(NoOfItems,itemIDPtr,kDataBrowserItemsAssign);
HUnlock(handle);
DisposeHandle(handle);
-} /* wxDataViewCtrl::SelectAll() */
+}
void wxDataViewCtrl::Select(wxDataViewItem const& item)
{
if (item.IsOk())
{
- // variable definition and initialization:
- DataBrowserItemID itemID(reinterpret_cast<DataBrowserItemID>(item.GetID()));
- wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
+ ExpandAncestors(item);
+ DataBrowserItemID itemID(reinterpret_cast<DataBrowserItemID>(item.GetID()));
+ wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(m_peer));
+
MacDataViewListCtrlPtr->SetSelectedItems(1,&itemID,kDataBrowserItemsAdd);
- } /* if */
-} /* wxDataViewCtrl::Select(wxDataViewItem const&) */
+ }
+}
void wxDataViewCtrl::SetSelections(wxDataViewItemArray const& sel)
{
- size_t const NoOfSelections = sel.GetCount();
+ size_t const NoOfSelections = sel.GetCount();
- DataBrowserItemID* itemIDs;
+ wxDataViewItem last_parent;
- wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
-
-
- itemIDs = new DataBrowserItemID[NoOfSelections];
- for (size_t i=0; i<NoOfSelections; ++i)
- itemIDs[i] = reinterpret_cast<DataBrowserItemID>(sel[i].GetID());
- MacDataViewListCtrlPtr->SetSelectedItems(NoOfSelections,itemIDs,kDataBrowserItemsAssign);
- delete[] itemIDs;
-} /* wxDataViewCtrl::SetSelections(wxDataViewItemArray const&) */
+ size_t i;
+ for (i = 0; i < NoOfSelections; i++)
+ {
+ wxDataViewItem item = sel[i];
+ wxDataViewItem parent = GetModel()->GetParent( item );
+ if (parent)
+ {
+ if (parent != last_parent)
+ ExpandAncestors(item);
+ }
+ last_parent = parent;
+ }
+
+ DataBrowserItemID* itemIDs;
+ wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(m_peer));
+
+ itemIDs = new DataBrowserItemID[NoOfSelections];
+ for (i=0; i<NoOfSelections; ++i)
+ itemIDs[i] = reinterpret_cast<DataBrowserItemID>(sel[i].GetID());
+ MacDataViewListCtrlPtr->SetSelectedItems(NoOfSelections,itemIDs,kDataBrowserItemsAssign);
+ delete[] itemIDs;
+}
void wxDataViewCtrl::Unselect(wxDataViewItem const& item)
{
if (item.IsOk())
{
- // variable definition and initialization:
DataBrowserItemID itemID(reinterpret_cast<DataBrowserItemID>(item.GetID()));
- wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
-
+ wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(m_peer));
+
MacDataViewListCtrlPtr->SetSelectedItems(1,&itemID,kDataBrowserItemsRemove);
- } /* if */
-} /* wxDataViewCtrl::Unselect(wxDataViewItem const&) */
+ }
+}
void wxDataViewCtrl::UnselectAll()
{
DataBrowserItemID* itemIDPtr;
-
+
Handle handle(::NewHandle(0));
-
+
size_t NoOfItems;
-
- wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
-
-
+
+ wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(m_peer));
+
+
wxCHECK_RET(MacDataViewListCtrlPtr->GetItems(kDataBrowserNoItem,true,kDataBrowserItemAnyState,handle) == noErr,_("Could not get items."));
NoOfItems = static_cast<size_t>(::GetHandleSize(handle)/sizeof(DataBrowserItemID));
HLock(handle);
MacDataViewListCtrlPtr->SetSelectedItems(NoOfItems,itemIDPtr,kDataBrowserItemsRemove);
HUnlock(handle);
DisposeHandle(handle);
-} /* wxDataViewCtrl::UnselectAll() */
+}
// data handling:
void wxDataViewCtrl::AddChildrenLevel(wxDataViewItem const& parentItem)
int NoOfChildren;
wxDataViewItemArray items;
-
-
+
+
wxCHECK_RET(this->GetModel() != NULL,_("Model pointer not initialized."));
NoOfChildren = this->GetModel()->GetChildren(parentItem,items);
#if 0
#else
(void) this->GetModel()->ItemsAdded(parentItem,items);
#endif
-}
+}
void wxDataViewCtrl::FinishCustomItemEditing()
{
this->SetCustomRendererItem(wxDataViewItem());
this->SetCustomRendererPtr (NULL);
}
-}
+}
wxDataViewColumn* wxDataViewCtrl::GetColumnPtr(WXDataBrowserPropertyID propertyID) const
{
- // variable definition:
- ColumnPointerHashMapType::const_iterator Result(this->m_ColumnPointers.find(propertyID));
-
- if (Result != this->m_ColumnPointers.end())
+ ColumnPointerHashMapType::const_iterator Result(m_ColumnPointers.find(propertyID));
+
+ if (Result != m_ColumnPointers.end())
return Result->second;
else
return NULL;
-}
+}
// inherited methods from wxDataViewCtrlBase
void wxDataViewCtrl::DoSetExpanderColumn()
{
if (this->GetExpanderColumn() != NULL)
{
- // variable definition and initialization:
- wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
+ wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(m_peer));
(void) MacDataViewListCtrlPtr->SetDisclosureColumn(this->GetExpanderColumn()->GetPropertyID(),false); // second parameter explicitely passed to ensure that arrow is centered
- }
-}
+ }
+}
void wxDataViewCtrl::DoSetIndent()
{
- wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
+ wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(m_peer));
(void) MacDataViewListCtrlPtr->SetIndent(static_cast<float>(this->GetIndent()));
-}
+}
// event handling:
+void wxDataViewCtrl::OnMouse(wxMouseEvent& event)
+{
+ event.Skip();
+
+ if (GetModel() == NULL)
+ return;
+
+ wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(m_peer));
+
+ int NoOfChildren;
+ wxDataViewItemArray items;
+ NoOfChildren = GetModel()->GetChildren( wxDataViewItem(), items);
+ if (NoOfChildren == 0)
+ return;
+ wxDataViewItem firstChild = items[0];
+
+ UInt16 headerHeight = 0;
+ MacDataViewListCtrlPtr->GetHeaderButtonHeight(&headerHeight);
+
+
+ if (event.GetY() < headerHeight)
+ {
+ unsigned int col_count = GetColumnCount();
+ unsigned int col;
+ for (col = 0; col < col_count; col++)
+ {
+ wxDataViewColumn *column = GetColumn( col );
+ if (column->IsHidden())
+ continue;
+
+ Rect itemrect;
+ ::GetDataBrowserItemPartBounds( MacDataViewListCtrlPtr->GetControlRef(),
+ reinterpret_cast<DataBrowserItemID>(firstChild.GetID()), column->GetPropertyID(),
+ kDataBrowserPropertyEnclosingPart, &itemrect );
+
+ if (abs( event.GetX() - itemrect.right) < 3)
+ {
+ if (column->GetFlags() & wxDATAVIEW_COL_RESIZABLE)
+ SetCursor( wxCursor( wxCURSOR_SIZEWE ) );
+ else
+ SetCursor( *wxSTANDARD_CURSOR );
+ return;
+ }
+ }
+
+ }
+
+ SetCursor( *wxSTANDARD_CURSOR );
+}
+
void wxDataViewCtrl::OnSize(wxSizeEvent& event)
{
unsigned int const NoOfColumns = this->GetColumnCount();
for (unsigned int i=0; i<NoOfColumns; ++i)
{
- // variable definition and initialization:
wxDataViewColumn* dataViewColumnPtr(this->GetColumn(i));
-
+
if (dataViewColumnPtr != NULL)
{
- // variable definition and initialization:
wxDataViewCustomRenderer* dataViewCustomRendererPtr(dynamic_cast<wxDataViewCustomRenderer*>(dataViewColumnPtr->GetRenderer()));
-
+
if (dataViewCustomRendererPtr != NULL)
dataViewCustomRendererPtr->SetDC(NULL); // reset DC because DC has changed
- } /* if */
- } /* for */
-
- wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
+ }
+ }
+
+ wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(m_peer));
ControlRef ref = MacDataViewListCtrlPtr->GetControlRef();
if (NoOfColumns == 1)
{
{
::SetDataBrowserHasScrollBars( ref, true, true );
}
-
+
event.Skip();
-} /* wxDataViewCtrl::OnSize(wxSizeEvent&) */
+}
IMPLEMENT_DYNAMIC_CLASS(wxDataViewCtrl,wxDataViewCtrlBase)
BEGIN_EVENT_TABLE(wxDataViewCtrl,wxDataViewCtrlBase)
EVT_SIZE(wxDataViewCtrl::OnSize)
+ EVT_MOTION(wxDataViewCtrl::OnMouse)
END_EVENT_TABLE()
-#endif
- // !wxUSE_GENERICDATAVIEWCTRL
+#endif // !wxUSE_GENERICDATAVIEWCTRL
-#endif
- // wxUSE_DATAVIEWCTRL
+#endif // wxUSE_DATAVIEWCTRL