No real changes, just minor cleanup in Cocoa wxDataViewCtrl.

Start cleaning up Cocoa wxDataViewCtrl implementation:
 - Don't use "this->" which is not used anywhere else in wx code.
 - Use "()" instead of "(void)" as per wx coding standards.
 - Don't use end of function comments, this is inconsistent and
   unmaintainable.

No real changes otherwise.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62384 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2009-10-12 13:59:32 +00:00
parent 2d0d781336
commit de40d73647
6 changed files with 676 additions and 676 deletions

View File

@ -26,7 +26,7 @@ public:
//
// constructors / destructor
//
wxDataViewColumnNativeData(void)
wxDataViewColumnNativeData()
{
}
wxDataViewColumnNativeData(DataBrowserPropertyID initPropertyID)
@ -37,14 +37,14 @@ public:
//
// data access methods
//
DataBrowserPropertyID GetPropertyID(void) const
DataBrowserPropertyID GetPropertyID() const
{
return this->m_PropertyID;
return m_PropertyID;
}
void SetPropertyID(DataBrowserPropertyID newPropertyID)
{
this->m_PropertyID = newPropertyID;
m_PropertyID = newPropertyID;
}
protected:
@ -64,7 +64,7 @@ public:
//
// constructors / destructor
//
wxDataViewRendererNativeData(void)
wxDataViewRendererNativeData()
{
}
wxDataViewRendererNativeData(DataBrowserPropertyType initPropertyType, DataBrowserItemDataRef initItemDataRef=NULL)
@ -75,22 +75,22 @@ public:
//
// data access methods
//
DataBrowserItemDataRef GetItemDataRef(void) const
DataBrowserItemDataRef GetItemDataRef() const
{
return this->m_ItemDataRef;
return m_ItemDataRef;
}
DataBrowserPropertyType GetPropertyType(void) const
DataBrowserPropertyType GetPropertyType() const
{
return this->m_PropertyType;
return m_PropertyType;
}
void SetItemDataRef(DataBrowserItemDataRef newItemDataRef)
{
this->m_ItemDataRef = newItemDataRef;
m_ItemDataRef = newItemDataRef;
}
void SetPropertyType(DataBrowserPropertyType newPropertyType)
{
this->m_PropertyType = newPropertyType;
m_PropertyType = newPropertyType;
}
protected:
@ -126,10 +126,10 @@ public:
// constructors / destructor
//
wxMacDataBrowserTableViewControl(wxWindow* peer, const wxPoint& pos, const wxSize& size, long style);
wxMacDataBrowserTableViewControl(void)
wxMacDataBrowserTableViewControl()
{
}
~wxMacDataBrowserTableViewControl(void);
~wxMacDataBrowserTableViewControl();
//
// callback handling
@ -204,14 +204,14 @@ public:
//
OSStatus AddItem(DataBrowserItemID container, DataBrowserItemID const* itemID) // adds a single item
{
return this->AddItems(container,1,itemID,kDataBrowserItemNoProperty);
return AddItems(container,1,itemID,kDataBrowserItemNoProperty);
}
OSStatus AddItems(DataBrowserItemID container, UInt32 numItems, DataBrowserItemID const* items, DataBrowserPropertyID preSortProperty); // adds items to the data browser
OSStatus GetFreeItemID(DataBrowserItemID* id) const; // this method returns an item id that is valid and currently not used; if it cannot be found 'errDataBrowserItemNotAdded' is returned
OSStatus GetItemCount (ItemCount* numItems) const
{
return this->GetItemCount(kDataBrowserNoItem,true,kDataBrowserItemAnyState,numItems);
return GetItemCount(kDataBrowserNoItem,true,kDataBrowserItemAnyState,numItems);
}
OSStatus GetItemCount (DataBrowserItemID container, Boolean recurse, DataBrowserItemState state, ItemCount* numItems) const;
OSStatus GetItemID (DataBrowserTableViewRowIndex row, DataBrowserItemID* item) const;
@ -225,21 +225,21 @@ public:
OSStatus RemoveItem(DataBrowserItemID container, DataBrowserItemID const* itemID) // removes a single item
{
return this->RemoveItems(container,1,itemID,kDataBrowserItemNoProperty);
return RemoveItems(container,1,itemID,kDataBrowserItemNoProperty);
}
OSStatus RemoveItems(void) // removes all items
{
return this->RemoveItems(kDataBrowserNoItem,0,NULL,kDataBrowserItemNoProperty);
return RemoveItems(kDataBrowserNoItem,0,NULL,kDataBrowserItemNoProperty);
}
OSStatus RemoveItems(DataBrowserItemID container, UInt32 numItems, DataBrowserItemID const* items, DataBrowserPropertyID preSortProperty);
OSStatus UpdateItem(DataBrowserItemID container, DataBrowserItemID const* item) // updates all columns of the passed item
{
return this->UpdateItems(container,1,item,kDataBrowserItemNoProperty,kDataBrowserItemNoProperty);
return UpdateItems(container,1,item,kDataBrowserItemNoProperty,kDataBrowserItemNoProperty);
}
OSStatus UpdateItems(void) // updates all items
{
return this->UpdateItems(kDataBrowserNoItem,0,NULL,kDataBrowserItemNoProperty,kDataBrowserItemNoProperty);
return UpdateItems(kDataBrowserNoItem,0,NULL,kDataBrowserItemNoProperty,kDataBrowserItemNoProperty);
}
OSStatus UpdateItems(DataBrowserItemID container, UInt32 numItems, DataBrowserItemID const* items, DataBrowserPropertyID preSortProperty, DataBrowserPropertyID propertyID) const;
@ -370,7 +370,7 @@ public:
//
// column related methods (inherited from wxDataViewWidgetImpl)
//
virtual bool ClearColumns (void);
virtual bool ClearColumns ();
virtual bool DeleteColumn (wxDataViewColumn* columnPtr);
virtual void DoSetExpanderColumn(wxDataViewColumn const* columnPtr);
virtual wxDataViewColumn* GetColumn (unsigned int pos) const;
@ -385,10 +385,10 @@ public:
virtual void Collapse (wxDataViewItem const& item);
virtual void EnsureVisible(wxDataViewItem const& item, wxDataViewColumn const* columnPtr);
virtual void Expand (wxDataViewItem const& item);
virtual unsigned int GetCount (void) const;
virtual unsigned int GetCount () const;
virtual wxRect GetRectangle (wxDataViewItem const& item, wxDataViewColumn const* columnPtr);
virtual bool IsExpanded (wxDataViewItem const& item) const;
virtual bool Reload (void);
virtual bool Reload ();
virtual bool Remove (wxDataViewItem const& parent, wxDataViewItem const& item);
virtual bool Remove (wxDataViewItem const& parent, wxDataViewItemArray const& item);
virtual bool Update (wxDataViewColumn const* columnPtr);
@ -406,15 +406,15 @@ public:
virtual int GetSelections(wxDataViewItemArray& sel) const;
virtual bool IsSelected (wxDataViewItem const& item) const;
virtual void Select (wxDataViewItem const& item);
virtual void SelectAll (void);
virtual void SelectAll ();
virtual void Unselect (wxDataViewItem const& item);
virtual void UnselectAll (void);
virtual void UnselectAll ();
//
// sorting related methods
//
virtual wxDataViewColumn* GetSortingColumn (void) const;
virtual void Resort (void);
virtual wxDataViewColumn* GetSortingColumn () const;
virtual void Resort ();
//
// other methods (inherited from wxDataViewWidgetImpl)
@ -422,14 +422,14 @@ public:
virtual void DoSetIndent (int indent);
virtual void HitTest (wxPoint const& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const;
virtual void SetRowHeight(wxDataViewItem const& item, unsigned int height);
virtual void OnSize (void);
virtual void OnSize ();
//
// other methods
//
wxDataViewCtrl* GetDataViewCtrl(void) const
wxDataViewCtrl* GetDataViewCtrl() const
{
return dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer());
return dynamic_cast<wxDataViewCtrl*>(GetWXPeer());
}
protected:

View File

@ -100,14 +100,14 @@ public:
//
// data access methods
//
NSTableColumn* GetNativeColumnPtr(void) const
NSTableColumn* GetNativeColumnPtr() const
{
return this->m_NativeColumnPtr;
return m_NativeColumnPtr;
}
void SetNativeColumnPtr(NSTableColumn* newNativeColumnPtr)
{
this->m_NativeColumnPtr = newNativeColumnPtr;
m_NativeColumnPtr = newNativeColumnPtr;
}
protected:
@ -136,59 +136,59 @@ public:
wxDataViewRendererNativeData(NSCell* initColumnCell, id initObject) : m_Object([initObject retain]), m_ColumnCell([initColumnCell retain])
{
}
~wxDataViewRendererNativeData(void)
~wxDataViewRendererNativeData()
{
[this->m_ColumnCell release];
[this->m_Object release];
[m_ColumnCell release];
[m_Object release];
}
//
// data access methods
//
NSCell* GetColumnCell(void) const
NSCell* GetColumnCell() const
{
return this->m_ColumnCell;
return m_ColumnCell;
}
NSTableColumn* GetColumnPtr(void) const
NSTableColumn* GetColumnPtr() const
{
return this->m_TableColumnPtr;
return m_TableColumnPtr;
}
id GetItem(void) const
id GetItem() const
{
return this->m_Item;
return m_Item;
}
NSCell* GetItemCell(void) const
NSCell* GetItemCell() const
{
return this->m_ItemCell;
return m_ItemCell;
}
id GetObject(void) const
id GetObject() const
{
return this->m_Object;
return m_Object;
}
void SetColumnCell(NSCell* newCell)
{
[newCell retain];
[this->m_ColumnCell release];
this->m_ColumnCell = newCell;
[m_ColumnCell release];
m_ColumnCell = newCell;
}
void SetColumnPtr(NSTableColumn* newColumnPtr)
{
this->m_TableColumnPtr = newColumnPtr;
m_TableColumnPtr = newColumnPtr;
}
void SetItem(id newItem)
{
this->m_Item = newItem;
m_Item = newItem;
}
void SetItemCell(NSCell* newCell)
{
this->m_ItemCell = newCell;
m_ItemCell = newCell;
}
void SetObject(id newObject)
{
[newObject retain];
[this->m_Object release];
this->m_Object = newObject;
[m_Object release];
m_Object = newObject;
}
protected:
@ -405,12 +405,12 @@ public:
// constructors / destructor
//
wxCocoaDataViewControl(wxWindow* peer, wxPoint const& pos, wxSize const& size, long style);
~wxCocoaDataViewControl(void);
~wxCocoaDataViewControl();
//
// column related methods (inherited from wxDataViewWidgetImpl)
//
virtual bool ClearColumns (void);
virtual bool ClearColumns ();
virtual bool DeleteColumn (wxDataViewColumn* columnPtr);
virtual void DoSetExpanderColumn(wxDataViewColumn const* columnPtr);
virtual wxDataViewColumn* GetColumn (unsigned int pos) const;
@ -425,10 +425,10 @@ public:
virtual void Collapse (wxDataViewItem const& item);
virtual void EnsureVisible(wxDataViewItem const& item, wxDataViewColumn const* columnPtr);
virtual void Expand (wxDataViewItem const& item);
virtual unsigned int GetCount (void) const;
virtual unsigned int GetCount () const;
virtual wxRect GetRectangle (wxDataViewItem const& item, wxDataViewColumn const* columnPtr);
virtual bool IsExpanded (wxDataViewItem const& item) const;
virtual bool Reload (void);
virtual bool Reload ();
virtual bool Remove (wxDataViewItem const& parent, wxDataViewItem const& item);
virtual bool Remove (wxDataViewItem const& parent, wxDataViewItemArray const& item);
virtual bool Update (wxDataViewColumn const* columnPtr);
@ -446,15 +446,15 @@ public:
virtual int GetSelections(wxDataViewItemArray& sel) const;
virtual bool IsSelected (wxDataViewItem const& item) const;
virtual void Select (wxDataViewItem const& item);
virtual void SelectAll (void);
virtual void SelectAll ();
virtual void Unselect (wxDataViewItem const& item);
virtual void UnselectAll (void);
virtual void UnselectAll ();
//
// sorting related methods
//
virtual wxDataViewColumn* GetSortingColumn (void) const;
virtual void Resort (void);
virtual wxDataViewColumn* GetSortingColumn () const;
virtual void Resort ();
//
// other methods (inherited from wxDataViewWidgetImpl)
@ -462,14 +462,14 @@ public:
virtual void DoSetIndent (int indent);
virtual void HitTest (wxPoint const& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const;
virtual void SetRowHeight(wxDataViewItem const& item, unsigned int height);
virtual void OnSize (void);
virtual void OnSize ();
//
// other methods
//
wxDataViewCtrl* GetDataViewCtrl(void) const
wxDataViewCtrl* GetDataViewCtrl() const
{
return dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer());
return dynamic_cast<wxDataViewCtrl*>(GetWXPeer());
}
//

View File

@ -33,22 +33,22 @@ public:
//
wxDataViewRenderer(wxString const& varianttype, wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
virtual ~wxDataViewRenderer(void);
virtual ~wxDataViewRenderer();
//
// inherited methods from wxDataViewRendererBase
//
virtual int GetAlignment() const
{
return this->m_alignment;
return m_alignment;
}
virtual wxDataViewCellMode GetMode() const
{
return this->m_mode;
return m_mode;
}
virtual bool GetValue(wxVariant& value) const
{
value = this->m_value;
value = m_value;
return true;
}
@ -57,7 +57,7 @@ public:
virtual void SetMode(wxDataViewCellMode mode);
virtual bool SetValue(wxVariant const& newValue)
{
this->m_value = newValue;
m_value = newValue;
return true;
}
@ -66,12 +66,12 @@ public:
//
wxVariant const& GetValue() const
{
return this->m_value;
return m_value;
}
wxDataViewRendererNativeData* GetNativeData() const
{
return this->m_NativeDataPtr;
return m_NativeDataPtr;
}
virtual bool MacRender() = 0; // a call to the native data browser function to render the data;
@ -238,11 +238,11 @@ public:
//
wxString GetChoice(size_t index) const
{
return this->m_Choices[index];
return m_Choices[index];
}
wxArrayString const& GetChoices(void) const
wxArrayString const& GetChoices() const
{
return this->m_Choices;
return m_Choices;
}
private:
@ -352,7 +352,7 @@ public:
int width = wxDVC_DEFAULT_WIDTH,
wxAlignment align = wxALIGN_CENTER,
int flags = wxDATAVIEW_COL_RESIZABLE);
virtual ~wxDataViewColumn(void);
virtual ~wxDataViewColumn();
// implement wxHeaderColumnBase pure virtual methods
virtual wxAlignment GetAlignment() const { return m_alignment; }
@ -380,9 +380,9 @@ public:
virtual void SetAsSortKey (bool sort = true);
// implementation only
wxDataViewColumnNativeData* GetNativeData(void) const
wxDataViewColumnNativeData* GetNativeData() const
{
return this->m_NativeDataPtr;
return m_NativeDataPtr;
}
void SetNativeData(wxDataViewColumnNativeData* newNativeDataPtr); // class takes ownership of pointer
@ -435,13 +435,13 @@ public:
// Constructors / destructor:
wxDataViewCtrl()
{
this->Init();
Init();
}
wxDataViewCtrl(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator)
{
this->Init();
this->Create(parent, id, pos, size, style, validator );
Init();
Create(parent, id, pos, size, style, validator );
}
~wxDataViewCtrl();
@ -459,12 +459,12 @@ public:
virtual bool AssociateModel(wxDataViewModel* model);
virtual bool AppendColumn (wxDataViewColumn* columnPtr);
virtual bool ClearColumns (void);
virtual bool ClearColumns ();
virtual bool DeleteColumn (wxDataViewColumn* columnPtr);
virtual wxDataViewColumn* GetColumn (unsigned int pos) const;
virtual unsigned int GetColumnCount (void) const;
virtual unsigned int GetColumnCount () const;
virtual int GetColumnPosition(const wxDataViewColumn* columnPtr) const;
virtual wxDataViewColumn* GetSortingColumn (void) const;
virtual wxDataViewColumn* GetSortingColumn () const;
virtual bool InsertColumn (unsigned int pos, wxDataViewColumn *col);
virtual bool PrependColumn (wxDataViewColumn* columnPtr);
@ -494,36 +494,36 @@ public:
// implementation
//
// returns a pointer to the native implementation
wxDataViewWidgetImpl* GetDataViewPeer(void) const;
wxDataViewWidgetImpl* GetDataViewPeer() const;
// adds all children of the passed parent to the control; if 'parentItem' is invalid the root(s) is/are added:
void AddChildren(wxDataViewItem const& parentItem);
// finishes editing of custom items; if no custom item is currently edited the method does nothing
void FinishCustomItemEditing(void);
void FinishCustomItemEditing();
// returns the n-th pointer to a column;
// this method is different from GetColumn(unsigned int pos) because here 'n' is not a position in the control but the n-th
// position in the internal list/array of column pointers
wxDataViewColumn* GetColumnPtr(size_t n) const
{
return this->m_ColumnPtrs[n];
return m_ColumnPtrs[n];
}
// returns the current being rendered item of the customized renderer (this item is only valid during editing)
wxDataViewItem const& GetCustomRendererItem() const
{
return this->m_CustomRendererItem;
return m_CustomRendererItem;
}
// returns a pointer to a customized renderer (this pointer is only valid during editing)
wxDataViewCustomRenderer* GetCustomRendererPtr() const
{
return this->m_CustomRendererPtr;
return m_CustomRendererPtr;
}
// checks if currently a delete process is running
bool IsDeleting() const
{
return this->m_Deleting;
return m_Deleting;
}
// with CG, we need to get the context from an kEventControlDraw event
@ -532,27 +532,27 @@ public:
// events so we can access it in the callbacks.
void MacSetDrawingContext(void* context)
{
this->m_cgContext = context;
m_cgContext = context;
}
void* MacGetDrawingContext() const
{
return this->m_cgContext;
return m_cgContext;
}
// sets the currently being edited item of the custom renderer
void SetCustomRendererItem(wxDataViewItem const& NewItem)
{
this->m_CustomRendererItem = NewItem;
m_CustomRendererItem = NewItem;
}
// sets the custom renderer
void SetCustomRendererPtr(wxDataViewCustomRenderer* NewCustomRendererPtr)
{
this->m_CustomRendererPtr = NewCustomRendererPtr;
m_CustomRendererPtr = NewCustomRendererPtr;
}
// sets the flag indicating a deletion process:
void SetDeleting(bool deleting)
{
this->m_Deleting = deleting;
m_Deleting = deleting;
}
virtual wxVisualAttributes GetDefaultAttributes() const

File diff suppressed because it is too large Load Diff

View File

@ -1020,7 +1020,7 @@ wxWidgetImplType* CreateDataView(wxWindowMac* wxpeer, wxWindowMac* WXUNUSED(pare
customRendererObject->customRenderer->LeftClick(wxFromNSPoint(controlView,point),wxFromNSRect(controlView,cellFrame),
customRendererObject->GetOwner()->GetOwner(),wxDataViewItem([customRendererObject->item pointer]),
[this->m_OutlineView columnWithIdentifier:[customRendererObject->GetColumnPtr() identifier]]);
[m_OutlineView columnWithIdentifier:[customRendererObject->GetColumnPtr() identifier]]);
return NSCellHitContentArea;
}
#endif
@ -1643,7 +1643,7 @@ wxCocoaDataViewControl::wxCocoaDataViewControl(wxWindow* peer, wxPoint const& po
m_DataSource(NULL), m_OutlineView([[wxCocoaOutlineView alloc] init])
{
// initialize scrollview (the outline view is part of a scrollview):
NSScrollView* scrollview = (NSScrollView*) this->GetWXWidget(); // definition for abbreviational purposes
NSScrollView* scrollview = (NSScrollView*) GetWXWidget(); // definition for abbreviational purposes
[scrollview setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
@ -1651,76 +1651,76 @@ wxCocoaDataViewControl::wxCocoaDataViewControl(wxWindow* peer, wxPoint const& po
[scrollview setHasVerticalScroller:YES];
[scrollview setHasHorizontalScroller:YES];
[scrollview setAutohidesScrollers:YES];
[scrollview setDocumentView:this->m_OutlineView];
[scrollview setDocumentView:m_OutlineView];
// setting up the native control itself
NSUInteger maskGridStyle(NSTableViewGridNone);
[this->m_OutlineView setImplementation:this];
[this->m_OutlineView setColumnAutoresizingStyle:NSTableViewSequentialColumnAutoresizingStyle];
[this->m_OutlineView setIndentationPerLevel:this->GetDataViewCtrl()->GetIndent()];
[m_OutlineView setImplementation:this];
[m_OutlineView setColumnAutoresizingStyle:NSTableViewSequentialColumnAutoresizingStyle];
[m_OutlineView setIndentationPerLevel:GetDataViewCtrl()->GetIndent()];
if (style & wxDV_HORIZ_RULES)
maskGridStyle |= NSTableViewSolidHorizontalGridLineMask;
if (style & wxDV_VERT_RULES)
maskGridStyle |= NSTableViewSolidVerticalGridLineMask;
[this->m_OutlineView setGridStyleMask:maskGridStyle];
[this->m_OutlineView setAllowsMultipleSelection: (style & wxDV_MULTIPLE) != 0];
[this->m_OutlineView setUsesAlternatingRowBackgroundColors:(style & wxDV_ROW_LINES) != 0];
[m_OutlineView setGridStyleMask:maskGridStyle];
[m_OutlineView setAllowsMultipleSelection: (style & wxDV_MULTIPLE) != 0];
[m_OutlineView setUsesAlternatingRowBackgroundColors:(style & wxDV_ROW_LINES) != 0];
}
wxCocoaDataViewControl::~wxCocoaDataViewControl(void)
wxCocoaDataViewControl::~wxCocoaDataViewControl()
{
[this->m_DataSource release];
[this->m_OutlineView release];
[m_DataSource release];
[m_OutlineView release];
}
//
// column related methods (inherited from wxDataViewWidgetImpl)
//
bool wxCocoaDataViewControl::ClearColumns(void)
bool wxCocoaDataViewControl::ClearColumns()
{
bool const bufAllowsMultipleSelection = [this->m_OutlineView allowsMultipleSelection];
bool const bufAllowsMultipleSelection = [m_OutlineView allowsMultipleSelection];
// as there is a bug in NSOutlineView version (OSX 10.5.6 #6555162) the columns cannot be deleted if there is an outline column in the view;
// therefore, the whole view is deleted and newly constructed:
[this->m_OutlineView release];
this->m_OutlineView = [[wxCocoaOutlineView alloc] init];
[((NSScrollView*) this->GetWXWidget()) setDocumentView:this->m_OutlineView];
[m_OutlineView release];
m_OutlineView = [[wxCocoaOutlineView alloc] init];
[((NSScrollView*) GetWXWidget()) setDocumentView:m_OutlineView];
// setting up the native control itself
[this->m_OutlineView setImplementation:this];
[this->m_OutlineView setColumnAutoresizingStyle:NSTableViewSequentialColumnAutoresizingStyle];
[this->m_OutlineView setIndentationPerLevel:this->GetDataViewCtrl()->GetIndent()];
[m_OutlineView setImplementation:this];
[m_OutlineView setColumnAutoresizingStyle:NSTableViewSequentialColumnAutoresizingStyle];
[m_OutlineView setIndentationPerLevel:GetDataViewCtrl()->GetIndent()];
if (bufAllowsMultipleSelection)
[this->m_OutlineView setAllowsMultipleSelection:YES];
[this->m_OutlineView setDataSource:this->m_DataSource];
[m_OutlineView setAllowsMultipleSelection:YES];
[m_OutlineView setDataSource:m_DataSource];
// done:
return true;
}
bool wxCocoaDataViewControl::DeleteColumn(wxDataViewColumn* columnPtr)
{
if ([this->m_OutlineView outlineTableColumn] == columnPtr->GetNativeData()->GetNativeColumnPtr())
[this->m_OutlineView setOutlineTableColumn:nil]; // due to a bug this does not work
[this->m_OutlineView removeTableColumn:columnPtr->GetNativeData()->GetNativeColumnPtr()]; // due to a confirmed bug #6555162 the deletion does not work for
if ([m_OutlineView outlineTableColumn] == columnPtr->GetNativeData()->GetNativeColumnPtr())
[m_OutlineView setOutlineTableColumn:nil]; // due to a bug this does not work
[m_OutlineView removeTableColumn:columnPtr->GetNativeData()->GetNativeColumnPtr()]; // due to a confirmed bug #6555162 the deletion does not work for
// outline table columns (... and there is no workaround)
return (([this->m_OutlineView columnWithIdentifier:[[[wxPointerObject alloc] initWithPointer:columnPtr] autorelease]]) == -1);
return (([m_OutlineView columnWithIdentifier:[[[wxPointerObject alloc] initWithPointer:columnPtr] autorelease]]) == -1);
}
void wxCocoaDataViewControl::DoSetExpanderColumn(wxDataViewColumn const* columnPtr)
{
[this->m_OutlineView setOutlineTableColumn:columnPtr->GetNativeData()->GetNativeColumnPtr()];
[m_OutlineView setOutlineTableColumn:columnPtr->GetNativeData()->GetNativeColumnPtr()];
}
wxDataViewColumn* wxCocoaDataViewControl::GetColumn(unsigned int pos) const
{
return reinterpret_cast<wxDataViewColumn*>([[[[this->m_OutlineView tableColumns] objectAtIndex:pos] identifier] pointer]);
return reinterpret_cast<wxDataViewColumn*>([[[[m_OutlineView tableColumns] objectAtIndex:pos] identifier] pointer]);
}
int wxCocoaDataViewControl::GetColumnPosition(wxDataViewColumn const* columnPtr) const
{
return [this->m_OutlineView columnWithIdentifier:[[[wxPointerObject alloc] initWithPointer:const_cast<wxDataViewColumn*>(columnPtr)] autorelease]];
return [m_OutlineView columnWithIdentifier:[[[wxPointerObject alloc] initWithPointer:const_cast<wxDataViewColumn*>(columnPtr)] autorelease]];
}
bool wxCocoaDataViewControl::InsertColumn(unsigned int pos, wxDataViewColumn* columnPtr)
@ -1733,9 +1733,9 @@ bool wxCocoaDataViewControl::InsertColumn(unsigned int pos, wxDataViewColumn* co
columnPtr->GetNativeData()->SetNativeColumnPtr(nativeColumn);
// as the native control does not allow the insertion of a column at a specified position the column is first appended and
// - if necessary - moved to its final position:
[this->m_OutlineView addTableColumn:nativeColumn];
if (pos != static_cast<unsigned int>([this->m_OutlineView numberOfColumns]-1))
[this->m_OutlineView moveColumn:[this->m_OutlineView numberOfColumns]-1 toColumn:pos];
[m_OutlineView addTableColumn:nativeColumn];
if (pos != static_cast<unsigned int>([m_OutlineView numberOfColumns]-1))
[m_OutlineView moveColumn:[m_OutlineView numberOfColumns]-1 toColumn:pos];
// done:
return true;
}
@ -1746,81 +1746,81 @@ bool wxCocoaDataViewControl::InsertColumn(unsigned int pos, wxDataViewColumn* co
bool wxCocoaDataViewControl::Add(wxDataViewItem const& parent, wxDataViewItem const& WXUNUSED(item))
{
if (parent.IsOk())
[this->m_OutlineView reloadItem:[this->m_DataSource getDataViewItemFromBuffer:parent] reloadChildren:YES];
[m_OutlineView reloadItem:[m_DataSource getDataViewItemFromBuffer:parent] reloadChildren:YES];
else
[this->m_OutlineView reloadData];
[m_OutlineView reloadData];
return true;
}
bool wxCocoaDataViewControl::Add(wxDataViewItem const& parent, wxDataViewItemArray const& WXUNUSED(items))
{
if (parent.IsOk())
[this->m_OutlineView reloadItem:[this->m_DataSource getDataViewItemFromBuffer:parent] reloadChildren:YES];
[m_OutlineView reloadItem:[m_DataSource getDataViewItemFromBuffer:parent] reloadChildren:YES];
else
[this->m_OutlineView reloadData];
[m_OutlineView reloadData];
return true;
}
void wxCocoaDataViewControl::Collapse(wxDataViewItem const& item)
{
[this->m_OutlineView collapseItem:[this->m_DataSource getDataViewItemFromBuffer:item]];
[m_OutlineView collapseItem:[m_DataSource getDataViewItemFromBuffer:item]];
}
void wxCocoaDataViewControl::EnsureVisible(wxDataViewItem const& item, wxDataViewColumn const* columnPtr)
{
if (item.IsOk())
{
[this->m_OutlineView scrollRowToVisible:[this->m_OutlineView rowForItem:[this->m_DataSource getDataViewItemFromBuffer:item]]];
[m_OutlineView scrollRowToVisible:[m_OutlineView rowForItem:[m_DataSource getDataViewItemFromBuffer:item]]];
if (columnPtr != NULL)
[this->m_OutlineView scrollColumnToVisible:this->GetColumnPosition(columnPtr)];
[m_OutlineView scrollColumnToVisible:GetColumnPosition(columnPtr)];
}
}
void wxCocoaDataViewControl::Expand(wxDataViewItem const& item)
{
[this->m_OutlineView expandItem:[this->m_DataSource getDataViewItemFromBuffer:item]];
[m_OutlineView expandItem:[m_DataSource getDataViewItemFromBuffer:item]];
}
unsigned int wxCocoaDataViewControl::GetCount(void) const
unsigned int wxCocoaDataViewControl::GetCount() const
{
return [this->m_OutlineView numberOfRows];
return [m_OutlineView numberOfRows];
}
wxRect wxCocoaDataViewControl::GetRectangle(wxDataViewItem const& item, wxDataViewColumn const* columnPtr)
{
return wxFromNSRect([m_osxView superview],[this->m_OutlineView frameOfCellAtColumn:this->GetColumnPosition(columnPtr)
row:[this->m_OutlineView rowForItem:[this->m_DataSource getDataViewItemFromBuffer:item]]]);
return wxFromNSRect([m_osxView superview],[m_OutlineView frameOfCellAtColumn:GetColumnPosition(columnPtr)
row:[m_OutlineView rowForItem:[m_DataSource getDataViewItemFromBuffer:item]]]);
}
bool wxCocoaDataViewControl::IsExpanded(wxDataViewItem const& item) const
{
return [this->m_OutlineView isItemExpanded:[this->m_DataSource getDataViewItemFromBuffer:item]];
return [m_OutlineView isItemExpanded:[m_DataSource getDataViewItemFromBuffer:item]];
}
bool wxCocoaDataViewControl::Reload(void)
bool wxCocoaDataViewControl::Reload()
{
[this->m_DataSource clearBuffers];
[this->m_OutlineView scrollColumnToVisible:0];
[this->m_OutlineView scrollRowToVisible:0];
[this->m_OutlineView reloadData];
[m_DataSource clearBuffers];
[m_OutlineView scrollColumnToVisible:0];
[m_OutlineView scrollRowToVisible:0];
[m_OutlineView reloadData];
return true;
}
bool wxCocoaDataViewControl::Remove(wxDataViewItem const& parent, wxDataViewItem const& WXUNUSED(item))
{
if (parent.IsOk())
[this->m_OutlineView reloadItem:[this->m_DataSource getDataViewItemFromBuffer:parent] reloadChildren:YES];
[m_OutlineView reloadItem:[m_DataSource getDataViewItemFromBuffer:parent] reloadChildren:YES];
else
[this->m_OutlineView reloadData];
[m_OutlineView reloadData];
return true;
}
bool wxCocoaDataViewControl::Remove(wxDataViewItem const& parent, wxDataViewItemArray const& WXUNUSED(item))
{
if (parent.IsOk())
[this->m_OutlineView reloadItem:[this->m_DataSource getDataViewItemFromBuffer:parent] reloadChildren:YES];
[m_OutlineView reloadItem:[m_DataSource getDataViewItemFromBuffer:parent] reloadChildren:YES];
else
[this->m_OutlineView reloadData];
[m_OutlineView reloadData];
return true;
}
@ -1831,14 +1831,14 @@ bool wxCocoaDataViewControl::Update(wxDataViewColumn const* columnPtr)
bool wxCocoaDataViewControl::Update(wxDataViewItem const& WXUNUSED(parent), wxDataViewItem const& item)
{
[this->m_OutlineView reloadItem:[this->m_DataSource getDataViewItemFromBuffer:item]];
[m_OutlineView reloadItem:[m_DataSource getDataViewItemFromBuffer:item]];
return true;
}
bool wxCocoaDataViewControl::Update(wxDataViewItem const& WXUNUSED(parent), wxDataViewItemArray const& items)
{
for (size_t i=0; i<items.GetCount(); ++i)
[this->m_OutlineView reloadItem:[this->m_DataSource getDataViewItemFromBuffer:items[i]]];
[m_OutlineView reloadItem:[m_DataSource getDataViewItemFromBuffer:items[i]]];
return true;
}
@ -1847,16 +1847,16 @@ bool wxCocoaDataViewControl::Update(wxDataViewItem const& WXUNUSED(parent), wxDa
//
bool wxCocoaDataViewControl::AssociateModel(wxDataViewModel* model)
{
[this->m_DataSource release];
[m_DataSource release];
if (model != NULL)
{
this->m_DataSource = [[wxCocoaOutlineDataSource alloc] init];
[this->m_DataSource setImplementation:this];
[this->m_DataSource setModel:model];
m_DataSource = [[wxCocoaOutlineDataSource alloc] init];
[m_DataSource setImplementation:this];
[m_DataSource setModel:model];
}
else
this->m_DataSource = NULL;
[this->m_OutlineView setDataSource:this->m_DataSource]; // if there is a data source the data is immediately going to be requested
m_DataSource = NULL;
[m_OutlineView setDataSource:m_DataSource]; // if there is a data source the data is immediately going to be requested
return true;
}
@ -1865,7 +1865,7 @@ bool wxCocoaDataViewControl::AssociateModel(wxDataViewModel* model)
//
int wxCocoaDataViewControl::GetSelections(wxDataViewItemArray& sel) const
{
NSIndexSet* selectedRowIndexes([this->m_OutlineView selectedRowIndexes]);
NSIndexSet* selectedRowIndexes([m_OutlineView selectedRowIndexes]);
NSUInteger indexRow;
@ -1875,7 +1875,7 @@ int wxCocoaDataViewControl::GetSelections(wxDataViewItemArray& sel) const
indexRow = [selectedRowIndexes firstIndex];
while (indexRow != NSNotFound)
{
sel.Add(wxDataViewItem([[this->m_OutlineView itemAtRow:indexRow] pointer]));
sel.Add(wxDataViewItem([[m_OutlineView itemAtRow:indexRow] pointer]));
indexRow = [selectedRowIndexes indexGreaterThanIndex:indexRow];
}
return sel.GetCount();
@ -1883,38 +1883,38 @@ int wxCocoaDataViewControl::GetSelections(wxDataViewItemArray& sel) const
bool wxCocoaDataViewControl::IsSelected(wxDataViewItem const& item) const
{
return [this->m_OutlineView isRowSelected:[this->m_OutlineView rowForItem:[this->m_DataSource getDataViewItemFromBuffer:item]]];
return [m_OutlineView isRowSelected:[m_OutlineView rowForItem:[m_DataSource getDataViewItemFromBuffer:item]]];
}
void wxCocoaDataViewControl::Select(wxDataViewItem const& item)
{
if (item.IsOk())
[this->m_OutlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:[this->m_OutlineView rowForItem:[this->m_DataSource getDataViewItemFromBuffer:item]]]
[m_OutlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:[m_OutlineView rowForItem:[m_DataSource getDataViewItemFromBuffer:item]]]
byExtendingSelection:NO];
}
void wxCocoaDataViewControl::SelectAll(void)
void wxCocoaDataViewControl::SelectAll()
{
[this->m_OutlineView selectAll:this->m_OutlineView];
[m_OutlineView selectAll:m_OutlineView];
}
void wxCocoaDataViewControl::Unselect(wxDataViewItem const& item)
{
if (item.IsOk())
[this->m_OutlineView deselectRow:[this->m_OutlineView rowForItem:[this->m_DataSource getDataViewItemFromBuffer:item]]];
[m_OutlineView deselectRow:[m_OutlineView rowForItem:[m_DataSource getDataViewItemFromBuffer:item]]];
}
void wxCocoaDataViewControl::UnselectAll(void)
void wxCocoaDataViewControl::UnselectAll()
{
[this->m_OutlineView deselectAll:this->m_OutlineView];
[m_OutlineView deselectAll:m_OutlineView];
}
//
// sorting related methods
//
wxDataViewColumn* wxCocoaDataViewControl::GetSortingColumn(void) const
wxDataViewColumn* wxCocoaDataViewControl::GetSortingColumn() const
{
NSArray* const columns = [this->m_OutlineView tableColumns];
NSArray* const columns = [m_OutlineView tableColumns];
UInt32 const noOfColumns = [columns count];
@ -1925,10 +1925,10 @@ wxDataViewColumn* wxCocoaDataViewControl::GetSortingColumn(void) const
return NULL;
}
void wxCocoaDataViewControl::Resort(void)
void wxCocoaDataViewControl::Resort()
{
[this->m_DataSource clearChildren];
[this->m_OutlineView reloadData];
[m_DataSource clearChildren];
[m_OutlineView reloadData];
}
//
@ -1936,23 +1936,23 @@ void wxCocoaDataViewControl::Resort(void)
//
void wxCocoaDataViewControl::DoSetIndent(int indent)
{
[this->m_OutlineView setIndentationPerLevel:static_cast<CGFloat>(indent)];
[m_OutlineView setIndentationPerLevel:static_cast<CGFloat>(indent)];
}
void wxCocoaDataViewControl::HitTest(wxPoint const& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const
{
NSPoint const nativePoint = wxToNSPoint((NSScrollView*) this->GetWXWidget(),point);
NSPoint const nativePoint = wxToNSPoint((NSScrollView*) GetWXWidget(),point);
int indexColumn;
int indexRow;
indexColumn = [this->m_OutlineView columnAtPoint:nativePoint];
indexRow = [this->m_OutlineView rowAtPoint: nativePoint];
indexColumn = [m_OutlineView columnAtPoint:nativePoint];
indexRow = [m_OutlineView rowAtPoint: nativePoint];
if ((indexColumn >= 0) && (indexRow >= 0))
{
columnPtr = reinterpret_cast<wxDataViewColumn*>([[[[this->m_OutlineView tableColumns] objectAtIndex:indexColumn] identifier] pointer]);
item = wxDataViewItem([[this->m_OutlineView itemAtRow:indexRow] pointer]);
columnPtr = reinterpret_cast<wxDataViewColumn*>([[[[m_OutlineView tableColumns] objectAtIndex:indexColumn] identifier] pointer]);
item = wxDataViewItem([[m_OutlineView itemAtRow:indexRow] pointer]);
}
else
{
@ -1966,10 +1966,10 @@ void wxCocoaDataViewControl::SetRowHeight(wxDataViewItem const& WXUNUSED(item),
{
}
void wxCocoaDataViewControl::OnSize(void)
void wxCocoaDataViewControl::OnSize()
{
if ([this->m_OutlineView numberOfColumns] == 1)
[this->m_OutlineView sizeLastColumnToFit];
if ([m_OutlineView numberOfColumns] == 1)
[m_OutlineView sizeLastColumnToFit];
}
//
@ -2071,28 +2071,28 @@ wxDataViewRenderer::wxDataViewRenderer(wxString const& varianttype, wxDataViewCe
{
}
wxDataViewRenderer::~wxDataViewRenderer(void)
wxDataViewRenderer::~wxDataViewRenderer()
{
delete this->m_NativeDataPtr;
delete m_NativeDataPtr;
}
void wxDataViewRenderer::SetAlignment(int align)
{
this->m_alignment = align;
[this->GetNativeData()->GetColumnCell() setAlignment:ConvertToNativeHorizontalTextAlignment(align)];
m_alignment = align;
[GetNativeData()->GetColumnCell() setAlignment:ConvertToNativeHorizontalTextAlignment(align)];
}
void wxDataViewRenderer::SetMode(wxDataViewCellMode mode)
{
this->m_mode = mode;
if (this->GetOwner() != NULL)
[this->GetOwner()->GetNativeData()->GetNativeColumnPtr() setEditable:(mode == wxDATAVIEW_CELL_EDITABLE)];
m_mode = mode;
if (GetOwner() != NULL)
[GetOwner()->GetNativeData()->GetNativeColumnPtr() setEditable:(mode == wxDATAVIEW_CELL_EDITABLE)];
}
void wxDataViewRenderer::SetNativeData(wxDataViewRendererNativeData* newNativeDataPtr)
{
delete this->m_NativeDataPtr;
this->m_NativeDataPtr = newNativeDataPtr;
delete m_NativeDataPtr;
m_NativeDataPtr = newNativeDataPtr;
}
IMPLEMENT_ABSTRACT_CLASS(wxDataViewRenderer,wxDataViewRendererBase)
@ -2103,14 +2103,14 @@ IMPLEMENT_ABSTRACT_CLASS(wxDataViewRenderer,wxDataViewRendererBase)
wxDataViewCustomRenderer::wxDataViewCustomRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align)
:wxDataViewRenderer(varianttype,mode,align), m_editorCtrlPtr(NULL), m_DCPtr(NULL)
{
this->SetNativeData(new wxDataViewRendererNativeData([[wxCustomCell alloc] init]));
SetNativeData(new wxDataViewRendererNativeData([[wxCustomCell alloc] init]));
}
bool wxDataViewCustomRenderer::MacRender()
{
[this->GetNativeData()->GetItemCell() setObjectValue:[[[wxCustomRendererObject alloc] initWithRenderer:this
item:this->GetNativeData()->GetItem()
column:this->GetNativeData()->GetColumnPtr()] autorelease]];
[GetNativeData()->GetItemCell() setObjectValue:[[[wxCustomRendererObject alloc] initWithRenderer:this
item:GetNativeData()->GetItem()
column:GetNativeData()->GetColumnPtr()] autorelease]];
return true;
}
@ -2128,20 +2128,20 @@ wxDataViewTextRenderer::wxDataViewTextRenderer(wxString const& varianttype, wxDa
cell = [[NSTextFieldCell alloc] init];
[cell setAlignment:ConvertToNativeHorizontalTextAlignment(align)];
[cell setLineBreakMode:NSLineBreakByTruncatingMiddle];
this->SetNativeData(new wxDataViewRendererNativeData(cell));
SetNativeData(new wxDataViewRendererNativeData(cell));
[cell release];
}
bool wxDataViewTextRenderer::MacRender()
{
if (this->GetValue().GetType() == this->GetVariantType())
if (GetValue().GetType() == GetVariantType())
{
[this->GetNativeData()->GetItemCell() setObjectValue:wxCFStringRef(this->GetValue().GetString()).AsNSString()];
[GetNativeData()->GetItemCell() setObjectValue:wxCFStringRef(GetValue().GetString()).AsNSString()];
return true;
}
else
{
wxFAIL_MSG(wxString(_("Text renderer cannot render value because of wrong value type; value type: ")) << this->GetValue().GetType());
wxFAIL_MSG(wxString(_("Text renderer cannot render value because of wrong value type; value type: ")) << GetValue().GetType());
return false;
}
}
@ -2158,7 +2158,7 @@ wxDataViewBitmapRenderer::wxDataViewBitmapRenderer(wxString const& varianttype,
cell = [[NSImageCell alloc] init];
this->SetNativeData(new wxDataViewRendererNativeData(cell));
SetNativeData(new wxDataViewRendererNativeData(cell));
[cell release];
}
@ -2168,13 +2168,13 @@ bool wxDataViewBitmapRenderer::MacRender()
// - the passed bitmap is invalid (or is not initialized); this case simulates a non-existing bitmap.
// In all other cases the method returns 'false'.
{
wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Bitmap renderer cannot render value; value type: ")) << this->GetValue().GetType());
wxCHECK_MSG(GetValue().GetType() == GetVariantType(),false,wxString(_("Bitmap renderer cannot render value; value type: ")) << GetValue().GetType());
wxBitmap bitmap;
bitmap << this->GetValue();
bitmap << GetValue();
if (bitmap.IsOk())
[this->GetNativeData()->GetItemCell() setObjectValue:[[bitmap.GetNSImage() retain] autorelease]];
[GetNativeData()->GetItemCell() setObjectValue:[[bitmap.GetNSImage() retain] autorelease]];
return true;
}
@ -2194,20 +2194,20 @@ wxDataViewChoiceRenderer::wxDataViewChoiceRenderer(wxArrayString const& choices,
[cell setFont:[[NSFont fontWithName:[[cell font] fontName] size:[NSFont systemFontSizeForControlSize:NSMiniControlSize]] autorelease]];
for (size_t i=0; i<choices.GetCount(); ++i)
[cell addItemWithTitle:[[wxCFStringRef(choices[i]).AsNSString() retain] autorelease]];
this->SetNativeData(new wxDataViewRendererNativeData(cell));
SetNativeData(new wxDataViewRendererNativeData(cell));
[cell release];
}
bool wxDataViewChoiceRenderer::MacRender()
{
if (this->GetValue().GetType() == this->GetVariantType())
if (GetValue().GetType() == GetVariantType())
{
[((NSPopUpButtonCell*) this->GetNativeData()->GetItemCell()) selectItemWithTitle:[[wxCFStringRef(this->GetValue().GetString()).AsNSString() retain] autorelease]];
[((NSPopUpButtonCell*) GetNativeData()->GetItemCell()) selectItemWithTitle:[[wxCFStringRef(GetValue().GetString()).AsNSString() retain] autorelease]];
return true;
}
else
{
wxFAIL_MSG(wxString(_("Choice renderer cannot render value because of wrong value type; value type: ")) << this->GetValue().GetType());
wxFAIL_MSG(wxString(_("Choice renderer cannot render value because of wrong value type; value type: ")) << GetValue().GetType());
return false;
}
}
@ -2231,16 +2231,16 @@ wxDataViewDateRenderer::wxDataViewDateRenderer(wxString const& varianttype, wxDa
cell = [[NSTextFieldCell alloc] init];
[cell setFormatter:dateFormatter];
[cell setLineBreakMode:NSLineBreakByTruncatingMiddle];
this->SetNativeData(new wxDataViewRendererNativeData(cell,[NSDate dateWithString:@"2000-12-30 20:00:00 +0000"]));
SetNativeData(new wxDataViewRendererNativeData(cell,[NSDate dateWithString:@"2000-12-30 20:00:00 +0000"]));
[cell release];
[dateFormatter release];
}
bool wxDataViewDateRenderer::MacRender()
{
if (this->GetValue().GetType() == this->GetVariantType())
if (GetValue().GetType() == GetVariantType())
{
if (this->GetValue().GetDateTime().IsValid())
if (GetValue().GetDateTime().IsValid())
{
// -- find best fitting style to show the date --
// as the style should be identical for all cells a reference date instead of the actual cell's date
@ -2252,31 +2252,31 @@ bool wxDataViewDateRenderer::MacRender()
// if the shortest time and date format does not fit into the cell the time part is dropped;
// remark: the time part itself is not modified per iteration loop and only uses the short style,
// means that only the hours and minutes are being shown
[this->GetNativeData()->GetItemCell() setObjectValue:this->GetNativeData()->GetObject()]; // GetObject() returns a date for testing the size of a date object
[[this->GetNativeData()->GetItemCell() formatter] setTimeStyle:NSDateFormatterShortStyle];
[GetNativeData()->GetItemCell() setObjectValue:GetNativeData()->GetObject()]; // GetObject() returns a date for testing the size of a date object
[[GetNativeData()->GetItemCell() formatter] setTimeStyle:NSDateFormatterShortStyle];
for (int dateFormatterStyle=4; dateFormatterStyle>0; --dateFormatterStyle)
{
[[this->GetNativeData()->GetItemCell() formatter] setDateStyle:(NSDateFormatterStyle)dateFormatterStyle];
[[GetNativeData()->GetItemCell() formatter] setDateStyle:(NSDateFormatterStyle)dateFormatterStyle];
if (dateFormatterStyle == 1)
{
// if the shortest style for displaying the date and time is too long to be fully visible remove the time part of the date:
if ([this->GetNativeData()->GetItemCell() cellSize].width > [this->GetNativeData()->GetColumnPtr() width])
[[this->GetNativeData()->GetItemCell() formatter] setTimeStyle:NSDateFormatterNoStyle];
if ([GetNativeData()->GetItemCell() cellSize].width > [GetNativeData()->GetColumnPtr() width])
[[GetNativeData()->GetItemCell() formatter] setTimeStyle:NSDateFormatterNoStyle];
break; // basically not necessary as the loop would end anyway but let's save the last comparison
}
else if ([this->GetNativeData()->GetItemCell() cellSize].width <= [this->GetNativeData()->GetColumnPtr() width])
else if ([GetNativeData()->GetItemCell() cellSize].width <= [GetNativeData()->GetColumnPtr() width])
break;
}
// set data (the style is set by the previous loop);
// on OSX the date has to be specified with respect to UTC; in wxWidgets the date is always entered in the local timezone; so, we have to do a conversion
// from the local to UTC timezone when adding the seconds to 1970-01-01 UTC:
[this->GetNativeData()->GetItemCell() setObjectValue:[NSDate dateWithTimeIntervalSince1970:this->GetValue().GetDateTime().ToUTC().Subtract(wxDateTime(1,wxDateTime::Jan,1970)).GetSeconds().ToDouble()]];
[GetNativeData()->GetItemCell() setObjectValue:[NSDate dateWithTimeIntervalSince1970:GetValue().GetDateTime().ToUTC().Subtract(wxDateTime(1,wxDateTime::Jan,1970)).GetSeconds().ToDouble()]];
}
return true;
}
else
{
wxFAIL_MSG(wxString(_("Date renderer cannot render value because of wrong value type; value type: ")) << this->GetValue().GetType());
wxFAIL_MSG(wxString(_("Date renderer cannot render value because of wrong value type; value type: ")) << GetValue().GetType());
return false;
}
}
@ -2294,20 +2294,20 @@ wxDataViewIconTextRenderer::wxDataViewIconTextRenderer(wxString const& variantty
cell = [[wxImageTextCell alloc] init];
[cell setAlignment:ConvertToNativeHorizontalTextAlignment(align)];
this->SetNativeData(new wxDataViewRendererNativeData(cell));
SetNativeData(new wxDataViewRendererNativeData(cell));
[cell release];
}
bool wxDataViewIconTextRenderer::MacRender()
{
if (this->GetValue().GetType() == this->GetVariantType())
if (GetValue().GetType() == GetVariantType())
{
wxDataViewIconText iconText;
wxImageTextCell* cell;
cell = (wxImageTextCell*) this->GetNativeData()->GetItemCell();
iconText << this->GetValue();
cell = (wxImageTextCell*) GetNativeData()->GetItemCell();
iconText << GetValue();
if (iconText.GetIcon().IsOk())
[cell setImage:[[wxBitmap(iconText.GetIcon()).GetNSImage() retain] autorelease]];
[cell setStringValue:[[wxCFStringRef(iconText.GetText()).AsNSString() retain] autorelease]];
@ -2315,7 +2315,7 @@ bool wxDataViewIconTextRenderer::MacRender()
}
else
{
wxFAIL_MSG(wxString(_("Icon & text renderer cannot render value because of wrong value type; value type: ")) << this->GetValue().GetType());
wxFAIL_MSG(wxString(_("Icon & text renderer cannot render value because of wrong value type; value type: ")) << GetValue().GetType());
return false;
}
}
@ -2335,20 +2335,20 @@ wxDataViewToggleRenderer::wxDataViewToggleRenderer(wxString const& varianttype,
[cell setAlignment:ConvertToNativeHorizontalTextAlignment(align)];
[cell setButtonType:NSSwitchButton];
[cell setImagePosition:NSImageOnly];
this->SetNativeData(new wxDataViewRendererNativeData(cell));
SetNativeData(new wxDataViewRendererNativeData(cell));
[cell release];
}
bool wxDataViewToggleRenderer::MacRender()
{
if (this->GetValue().GetType() == this->GetVariantType())
if (GetValue().GetType() == GetVariantType())
{
[this->GetNativeData()->GetItemCell() setIntValue:this->GetValue().GetLong()];
[GetNativeData()->GetItemCell() setIntValue:GetValue().GetLong()];
return true;
}
else
{
wxFAIL_MSG(wxString(_("Toggle renderer cannot render value because of wrong value type; value type: ")) << this->GetValue().GetType());
wxFAIL_MSG(wxString(_("Toggle renderer cannot render value because of wrong value type; value type: ")) << GetValue().GetType());
return false;
}
}
@ -2367,20 +2367,20 @@ wxDataViewProgressRenderer::wxDataViewProgressRenderer(wxString const& label, wx
cell = [[NSLevelIndicatorCell alloc] initWithLevelIndicatorStyle:NSContinuousCapacityLevelIndicatorStyle];
[cell setMinValue:0];
[cell setMaxValue:100];
this->SetNativeData(new wxDataViewRendererNativeData(cell));
SetNativeData(new wxDataViewRendererNativeData(cell));
[cell release];
}
bool wxDataViewProgressRenderer::MacRender()
{
if (this->GetValue().GetType() == this->GetVariantType())
if (GetValue().GetType() == GetVariantType())
{
[this->GetNativeData()->GetItemCell() setIntValue:this->GetValue().GetLong()];
[GetNativeData()->GetItemCell() setIntValue:GetValue().GetLong()];
return true;
}
else
{
wxFAIL_MSG(wxString(_("Progress renderer cannot render value because of wrong value type; value type: ")) << this->GetValue().GetType());
wxFAIL_MSG(wxString(_("Progress renderer cannot render value because of wrong value type; value type: ")) << GetValue().GetType());
return false;
}
}
@ -2393,7 +2393,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxDataViewProgressRenderer,wxDataViewRenderer)
wxDataViewColumn::wxDataViewColumn(const wxString& title, wxDataViewRenderer* renderer, unsigned int model_column, int width, wxAlignment align, int flags)
:wxDataViewColumnBase(renderer, model_column), m_NativeDataPtr(new wxDataViewColumnNativeData()), m_title(title)
{
this->InitCommon(width, align, flags);
InitCommon(width, align, flags);
if ((renderer != NULL) && (renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT))
renderer->SetAlignment(align);
}
@ -2401,47 +2401,47 @@ wxDataViewColumn::wxDataViewColumn(const wxString& title, wxDataViewRenderer* re
wxDataViewColumn::wxDataViewColumn(const wxBitmap& bitmap, wxDataViewRenderer* renderer, unsigned int model_column, int width, wxAlignment align, int flags)
:wxDataViewColumnBase(bitmap, renderer, model_column), m_NativeDataPtr(new wxDataViewColumnNativeData())
{
this->InitCommon(width, align, flags);
InitCommon(width, align, flags);
if ((renderer != NULL) && (renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT))
renderer->SetAlignment(align);
}
wxDataViewColumn::~wxDataViewColumn(void)
wxDataViewColumn::~wxDataViewColumn()
{
delete this->m_NativeDataPtr;
delete m_NativeDataPtr;
}
bool wxDataViewColumn::IsSortKey() const
{
return ((this->GetNativeData()->GetNativeColumnPtr() != NULL) && ([this->GetNativeData()->GetNativeColumnPtr() sortDescriptorPrototype] != nil));
return ((GetNativeData()->GetNativeColumnPtr() != NULL) && ([GetNativeData()->GetNativeColumnPtr() sortDescriptorPrototype] != nil));
}
void wxDataViewColumn::SetAlignment(wxAlignment align)
{
this->m_alignment = align;
[[this->m_NativeDataPtr->GetNativeColumnPtr() headerCell] setAlignment:ConvertToNativeHorizontalTextAlignment(align)];
if ((this->m_renderer != NULL) && (this->m_renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT))
this->m_renderer->SetAlignment(align);
m_alignment = align;
[[m_NativeDataPtr->GetNativeColumnPtr() headerCell] setAlignment:ConvertToNativeHorizontalTextAlignment(align)];
if ((m_renderer != NULL) && (m_renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT))
m_renderer->SetAlignment(align);
}
void wxDataViewColumn::SetBitmap(wxBitmap const& bitmap)
{
// bitmaps and titles cannot exist at the same time - if the bitmap is set the title is removed:
this->m_title = wxEmptyString;
this->wxDataViewColumnBase::SetBitmap(bitmap);
[[this->m_NativeDataPtr->GetNativeColumnPtr() headerCell] setImage:[[bitmap.GetNSImage() retain] autorelease]];
m_title = wxEmptyString;
wxDataViewColumnBase::SetBitmap(bitmap);
[[m_NativeDataPtr->GetNativeColumnPtr() headerCell] setImage:[[bitmap.GetNSImage() retain] autorelease]];
}
void wxDataViewColumn::SetMaxWidth(int maxWidth)
{
this->m_maxWidth = maxWidth;
[this->m_NativeDataPtr->GetNativeColumnPtr() setMaxWidth:maxWidth];
m_maxWidth = maxWidth;
[m_NativeDataPtr->GetNativeColumnPtr() setMaxWidth:maxWidth];
}
void wxDataViewColumn::SetMinWidth(int minWidth)
{
this->m_minWidth = minWidth;
[this->m_NativeDataPtr->GetNativeColumnPtr() setMinWidth:minWidth];
m_minWidth = minWidth;
[m_NativeDataPtr->GetNativeColumnPtr() setMinWidth:minWidth];
}
void wxDataViewColumn::SetReorderable(bool reorderable)
@ -2450,16 +2450,16 @@ void wxDataViewColumn::SetReorderable(bool reorderable)
void wxDataViewColumn::SetResizeable(bool resizeable)
{
this->wxDataViewColumnBase::SetResizeable(resizeable);
wxDataViewColumnBase::SetResizeable(resizeable);
if (resizeable)
[this->m_NativeDataPtr->GetNativeColumnPtr() setResizingMask:NSTableColumnUserResizingMask];
[m_NativeDataPtr->GetNativeColumnPtr() setResizingMask:NSTableColumnUserResizingMask];
else
[this->m_NativeDataPtr->GetNativeColumnPtr() setResizingMask:NSTableColumnNoResizing];
[m_NativeDataPtr->GetNativeColumnPtr() setResizingMask:NSTableColumnNoResizing];
}
void wxDataViewColumn::SetSortable(bool sortable)
{
this->wxDataViewColumnBase::SetSortable(sortable);
wxDataViewColumnBase::SetSortable(sortable);
}
void wxDataViewColumn::SetSortOrder(bool ascending)
@ -2467,14 +2467,14 @@ void wxDataViewColumn::SetSortOrder(bool ascending)
if (m_ascending != ascending)
{
m_ascending = ascending;
if (this->IsSortKey())
if (IsSortKey())
{
// change sorting order:
NSArray* sortDescriptors;
NSSortDescriptor* sortDescriptor;
NSTableColumn* tableColumn;
tableColumn = this->m_NativeDataPtr->GetNativeColumnPtr();
tableColumn = m_NativeDataPtr->GetNativeColumnPtr();
sortDescriptor = [[NSSortDescriptor alloc] initWithKey:[[tableColumn sortDescriptorPrototype] key] ascending:m_ascending];
sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
[tableColumn setSortDescriptorPrototype:sortDescriptor];
@ -2487,15 +2487,15 @@ void wxDataViewColumn::SetSortOrder(bool ascending)
void wxDataViewColumn::SetTitle(wxString const& title)
{
// bitmaps and titles cannot exist at the same time - if the title is set the bitmap is removed:
this->wxDataViewColumnBase::SetBitmap(wxBitmap());
this->m_title = title;
[[this->m_NativeDataPtr->GetNativeColumnPtr() headerCell] setStringValue:[[wxCFStringRef(title).AsNSString() retain] autorelease]];
wxDataViewColumnBase::SetBitmap(wxBitmap());
m_title = title;
[[m_NativeDataPtr->GetNativeColumnPtr() headerCell] setStringValue:[[wxCFStringRef(title).AsNSString() retain] autorelease]];
}
void wxDataViewColumn::SetWidth(int width)
{
[this->m_NativeDataPtr->GetNativeColumnPtr() setWidth:width];
this->m_width = width;
[m_NativeDataPtr->GetNativeColumnPtr() setWidth:width];
m_width = width;
}
void wxDataViewColumn::SetAsSortKey(bool WXUNUSED(sort))
@ -2506,7 +2506,7 @@ void wxDataViewColumn::SetAsSortKey(bool WXUNUSED(sort))
void wxDataViewColumn::SetNativeData(wxDataViewColumnNativeData* newNativeDataPtr)
{
delete this->m_NativeDataPtr;
this->m_NativeDataPtr = newNativeDataPtr;
delete m_NativeDataPtr;
m_NativeDataPtr = newNativeDataPtr;
}
#endif // (wxUSE_DATAVIEWCTRL == 1) && !defined(wxUSE_GENERICDATAVIEWCTRL)

View File

@ -97,8 +97,8 @@ bool wxOSXDataViewModelNotifier::ItemAdded(wxDataViewItem const& parent, wxDataV
wxCHECK_MSG(item.IsOk(),false,_("Added item is invalid."));
noFailureFlag = this->m_DataViewCtrlPtr->GetDataViewPeer()->Add(parent,item);
this->AdjustRowHeight(item);
noFailureFlag = m_DataViewCtrlPtr->GetDataViewPeer()->Add(parent,item);
AdjustRowHeight(item);
return noFailureFlag;
}
@ -108,9 +108,9 @@ bool wxOSXDataViewModelNotifier::ItemsAdded(wxDataViewItem const& parent, wxData
// insert all valid items into control:
noFailureFlag = this->m_DataViewCtrlPtr->GetDataViewPeer()->Add(parent,items);
noFailureFlag = m_DataViewCtrlPtr->GetDataViewPeer()->Add(parent,items);
// adjust row heights:
this->AdjustRowHeights(items);
AdjustRowHeights(items);
// done:
return noFailureFlag;
}
@ -118,18 +118,18 @@ bool wxOSXDataViewModelNotifier::ItemsAdded(wxDataViewItem const& parent, wxData
bool wxOSXDataViewModelNotifier::ItemChanged(wxDataViewItem const& item)
{
wxCHECK_MSG(item.IsOk(), false,_("Changed item is invalid."));
wxCHECK_MSG(this->GetOwner() != NULL,false,_("Owner not initialized."));
if (this->m_DataViewCtrlPtr->GetDataViewPeer()->Update(this->GetOwner()->GetParent(item),item))
wxCHECK_MSG(GetOwner() != NULL,false,_("Owner not initialized."));
if (m_DataViewCtrlPtr->GetDataViewPeer()->Update(GetOwner()->GetParent(item),item))
{
// sent the equivalent wxWidget event:
wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED,this->m_DataViewCtrlPtr->GetId());
wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED,m_DataViewCtrlPtr->GetId());
dataViewEvent.SetEventObject(this->m_DataViewCtrlPtr);
dataViewEvent.SetEventObject(m_DataViewCtrlPtr);
dataViewEvent.SetItem(item);
// sent the equivalent wxWidget event:
this->m_DataViewCtrlPtr->HandleWindowEvent(dataViewEvent);
m_DataViewCtrlPtr->HandleWindowEvent(dataViewEvent);
// row height may have to be adjusted:
this->AdjustRowHeight(item);
AdjustRowHeight(item);
// done
return true;
}
@ -141,21 +141,21 @@ bool wxOSXDataViewModelNotifier::ItemsChanged(wxDataViewItemArray const& items)
{
size_t const noOfItems = items.GetCount();
wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED,this->m_DataViewCtrlPtr->GetId());
wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED,m_DataViewCtrlPtr->GetId());
dataViewEvent.SetEventObject(this->m_DataViewCtrlPtr);
dataViewEvent.SetEventObject(m_DataViewCtrlPtr);
for (size_t indexItem=0; indexItem<noOfItems; ++indexItem)
if (this->m_DataViewCtrlPtr->GetDataViewPeer()->Update(this->GetOwner()->GetParent(items[indexItem]),items[indexItem]))
if (m_DataViewCtrlPtr->GetDataViewPeer()->Update(GetOwner()->GetParent(items[indexItem]),items[indexItem]))
{
// send for all changed items a wxWidget event:
dataViewEvent.SetItem(items[indexItem]);
this->m_DataViewCtrlPtr->HandleWindowEvent(dataViewEvent);
m_DataViewCtrlPtr->HandleWindowEvent(dataViewEvent);
}
else
return false;
// if this location is reached all items have been updated:
this->AdjustRowHeights(items);
AdjustRowHeights(items);
// done:
return true;
}
@ -170,10 +170,10 @@ bool wxOSXDataViewModelNotifier::ItemDeleted(wxDataViewItem const& parent, wxDat
// 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:
this->m_DataViewCtrlPtr->SetDeleting(true);
noFailureFlag = this->m_DataViewCtrlPtr->GetDataViewPeer()->Remove(parent,item);
m_DataViewCtrlPtr->SetDeleting(true);
noFailureFlag = m_DataViewCtrlPtr->GetDataViewPeer()->Remove(parent,item);
// enable automatic updating again:
this->m_DataViewCtrlPtr->SetDeleting(false);
m_DataViewCtrlPtr->SetDeleting(false);
// done:
return noFailureFlag;
}
@ -187,11 +187,11 @@ bool wxOSXDataViewModelNotifier::ItemsDeleted(wxDataViewItem const& parent, wxDa
// 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:
this->m_DataViewCtrlPtr->SetDeleting(true);
m_DataViewCtrlPtr->SetDeleting(true);
// delete all specified items:
noFailureFlag = this->m_DataViewCtrlPtr->GetDataViewPeer()->Remove(parent,items);
noFailureFlag = m_DataViewCtrlPtr->GetDataViewPeer()->Remove(parent,items);
// enable automatic updating again:
this->m_DataViewCtrlPtr->SetDeleting(false);
m_DataViewCtrlPtr->SetDeleting(false);
// done:
return noFailureFlag;
}
@ -199,16 +199,16 @@ bool wxOSXDataViewModelNotifier::ItemsDeleted(wxDataViewItem const& parent, wxDa
bool wxOSXDataViewModelNotifier::ValueChanged(wxDataViewItem const& item, unsigned int col)
{
wxCHECK_MSG(item.IsOk(), false,_("Passed item is invalid."));
wxCHECK_MSG(this->GetOwner() != NULL,false,_("Owner not initialized."));
if (this->m_DataViewCtrlPtr->GetDataViewPeer()->Update(this->GetOwner()->GetParent(item),item))
wxCHECK_MSG(GetOwner() != NULL,false,_("Owner not initialized."));
if (m_DataViewCtrlPtr->GetDataViewPeer()->Update(GetOwner()->GetParent(item),item))
{
wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED,this->m_DataViewCtrlPtr->GetId());
wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED,m_DataViewCtrlPtr->GetId());
dataViewEvent.SetEventObject(this->m_DataViewCtrlPtr);
dataViewEvent.SetEventObject(m_DataViewCtrlPtr);
dataViewEvent.SetColumn(col);
dataViewEvent.SetItem(item);
// send the equivalent wxWidget event:
this->m_DataViewCtrlPtr->HandleWindowEvent(dataViewEvent);
m_DataViewCtrlPtr->HandleWindowEvent(dataViewEvent);
// done
return true;
}
@ -218,26 +218,26 @@ bool wxOSXDataViewModelNotifier::ValueChanged(wxDataViewItem const& item, unsign
bool wxOSXDataViewModelNotifier::Cleared()
{
return this->m_DataViewCtrlPtr->GetDataViewPeer()->Reload();
return m_DataViewCtrlPtr->GetDataViewPeer()->Reload();
}
void wxOSXDataViewModelNotifier::Resort()
{
this->m_DataViewCtrlPtr->GetDataViewPeer()->Resort();
m_DataViewCtrlPtr->GetDataViewPeer()->Resort();
}
void wxOSXDataViewModelNotifier::AdjustRowHeight(wxDataViewItem const& item)
{
if ((this->m_DataViewCtrlPtr->GetWindowStyle() & wxDV_VARIABLE_LINE_HEIGHT) != 0)
if ((m_DataViewCtrlPtr->GetWindowStyle() & wxDV_VARIABLE_LINE_HEIGHT) != 0)
{
wxDataViewModel *model = this->GetOwner();
wxDataViewModel *model = GetOwner();
int height = 20; // TODO find out standard height
unsigned int num = this->m_DataViewCtrlPtr->GetColumnCount();
unsigned int num = m_DataViewCtrlPtr->GetColumnCount();
unsigned int col;
for (col = 0; col < num; col++)
{
wxDataViewColumn* column(this->m_DataViewCtrlPtr->GetColumnPtr(col));
wxDataViewColumn* column(m_DataViewCtrlPtr->GetColumnPtr(col));
if (!(column->IsHidden()))
{
@ -252,27 +252,27 @@ void wxOSXDataViewModelNotifier::AdjustRowHeight(wxDataViewItem const& item)
}
}
if (height > 20)
this->m_DataViewCtrlPtr->GetDataViewPeer()->SetRowHeight(item,height);
m_DataViewCtrlPtr->GetDataViewPeer()->SetRowHeight(item,height);
}
}
void wxOSXDataViewModelNotifier::AdjustRowHeights(wxDataViewItemArray const& items)
{
if ((this->m_DataViewCtrlPtr->GetWindowStyle() & wxDV_VARIABLE_LINE_HEIGHT) != 0)
if ((m_DataViewCtrlPtr->GetWindowStyle() & wxDV_VARIABLE_LINE_HEIGHT) != 0)
{
size_t const noOfItems = items.GetCount();
wxDataViewModel *model = this->GetOwner();
wxDataViewModel *model = GetOwner();
for (size_t itemIndex=0; itemIndex<noOfItems; ++itemIndex)
{
int height = 20; // TODO find out standard height
unsigned int num = this->m_DataViewCtrlPtr->GetColumnCount();
unsigned int num = m_DataViewCtrlPtr->GetColumnCount();
unsigned int col;
for (col = 0; col < num; col++)
{
wxDataViewColumn* column(this->m_DataViewCtrlPtr->GetColumnPtr(col));
wxDataViewColumn* column(m_DataViewCtrlPtr->GetColumnPtr(col));
if (!(column->IsHidden()))
{
@ -287,7 +287,7 @@ void wxOSXDataViewModelNotifier::AdjustRowHeights(wxDataViewItemArray const& ite
}
}
if (height > 20)
this->m_DataViewCtrlPtr->GetDataViewPeer()->SetRowHeight(items[itemIndex],height);
m_DataViewCtrlPtr->GetDataViewPeer()->SetRowHeight(items[itemIndex],height);
}
}
}
@ -298,9 +298,9 @@ void wxOSXDataViewModelNotifier::AdjustRowHeights(wxDataViewItemArray const& ite
// dependent methods can be found in the environment's
// source file.
// ---------------------------------------------------------
wxDataViewCustomRenderer::~wxDataViewCustomRenderer(void)
wxDataViewCustomRenderer::~wxDataViewCustomRenderer()
{
delete this->m_DCPtr;
delete m_DCPtr;
}
void wxDataViewCustomRenderer::RenderText( const wxString &text, int xoffset, wxRect cell, wxDC *dc, int state )
@ -314,9 +314,9 @@ void wxDataViewCustomRenderer::RenderText( const wxString &text, int xoffset, wx
wxDC* wxDataViewCustomRenderer::GetDC()
{
if ((this->m_DCPtr == NULL) && (this->GetOwner() != NULL) && (this->GetOwner()->GetOwner() != NULL))
this->m_DCPtr = new wxClientDC(this->GetOwner()->GetOwner());
return this->m_DCPtr;
if ((m_DCPtr == NULL) && (GetOwner() != NULL) && (GetOwner()->GetOwner() != NULL))
m_DCPtr = new wxClientDC(GetOwner()->GetOwner());
return m_DCPtr;
}
void wxDataViewCustomRenderer::SetDC(wxDC* newDCPtr)
@ -331,7 +331,7 @@ void wxDataViewCustomRenderer::SetDC(wxDC* newDCPtr)
wxDataViewCtrl::~wxDataViewCtrl()
{
this->ClearColumns();
ClearColumns();
}
void wxDataViewCtrl::Init()
@ -344,18 +344,18 @@ void wxDataViewCtrl::Init()
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 & ~(wxHSCROLL | wxVSCROLL),validator)))
if (!(wxControl::Create(parent,id,pos,size,style & ~(wxHSCROLL | wxVSCROLL),validator)))
return false;
m_peer = ::CreateDataView(this,parent,id,pos,size,style,this->GetExtraStyle());
m_peer = ::CreateDataView(this,parent,id,pos,size,style,GetExtraStyle());
this->MacPostControlCreate(pos,size);
MacPostControlCreate(pos,size);
return true;
}
bool wxDataViewCtrl::AssociateModel(wxDataViewModel* model)
{
wxDataViewWidgetImpl* dataViewWidgetPtr(this->GetDataViewPeer());
wxDataViewWidgetImpl* dataViewWidgetPtr(GetDataViewPeer());
wxCHECK_MSG(dataViewWidgetPtr != NULL,false,_("Pointer to native control must not be NULL."));
@ -381,35 +381,35 @@ bool wxDataViewCtrl::PrependColumn(wxDataViewColumn* columnPtr)
bool wxDataViewCtrl::InsertColumn(unsigned int pos, wxDataViewColumn* columnPtr)
{
wxDataViewWidgetImpl* dataViewWidgetPtr(this->GetDataViewPeer());
wxDataViewWidgetImpl* dataViewWidgetPtr(GetDataViewPeer());
// first, some error checking:
wxCHECK_MSG(dataViewWidgetPtr != NULL, false,_("Pointer to native control must not be NULL."));
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(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."));
(columnPtr->GetModelColumn() < GetModel()->GetColumnCount()),false,_("Column's model column has no equivalent in the associated model."));
// add column to wxWidget's internal structure:
if (this->wxDataViewCtrlBase::InsertColumn(pos,columnPtr))
if (wxDataViewCtrlBase::InsertColumn(pos,columnPtr))
{
this->m_ColumnPtrs.Add(columnPtr);
m_ColumnPtrs.Add(columnPtr);
// if the insertion in the native control is successful the rest can also be initialized:
if (dataViewWidgetPtr->InsertColumn(pos,columnPtr))
{
// 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);
if (GetColumnCount() == 1)
SetExpanderColumn(columnPtr);
// done:
return true;
}
else
{
// clean-up:
this->m_ColumnPtrs.Remove(columnPtr);
m_ColumnPtrs.Remove(columnPtr);
delete columnPtr;
// and send a message in debug mode:
wxFAIL_MSG(_("Column could not be added to native control."));
@ -429,9 +429,9 @@ bool wxDataViewCtrl::InsertColumn(unsigned int pos, wxDataViewColumn* columnPtr)
bool wxDataViewCtrl::ClearColumns()
{
if (this->GetDataViewPeer()->ClearColumns())
if (GetDataViewPeer()->ClearColumns())
{
WX_CLEAR_ARRAY(this->m_ColumnPtrs);
WX_CLEAR_ARRAY(m_ColumnPtrs);
return true;
}
else
@ -440,9 +440,9 @@ bool wxDataViewCtrl::ClearColumns()
bool wxDataViewCtrl::DeleteColumn(wxDataViewColumn* columnPtr)
{
if (this->GetDataViewPeer()->DeleteColumn(columnPtr))
if (GetDataViewPeer()->DeleteColumn(columnPtr))
{
this->m_ColumnPtrs.Remove(columnPtr);
m_ColumnPtrs.Remove(columnPtr);
delete columnPtr;
return true;
}
@ -452,57 +452,57 @@ bool wxDataViewCtrl::DeleteColumn(wxDataViewColumn* columnPtr)
wxDataViewColumn* wxDataViewCtrl::GetColumn(unsigned int pos) const
{
return this->GetDataViewPeer()->GetColumn(pos);
return GetDataViewPeer()->GetColumn(pos);
}
unsigned int wxDataViewCtrl::GetColumnCount() const
{
return this->m_ColumnPtrs.GetCount();
return m_ColumnPtrs.GetCount();
}
int wxDataViewCtrl::GetColumnPosition(wxDataViewColumn const* columnPtr) const
{
return this->GetDataViewPeer()->GetColumnPosition(columnPtr);
return GetDataViewPeer()->GetColumnPosition(columnPtr);
}
void wxDataViewCtrl::Collapse(wxDataViewItem const& item)
{
this->GetDataViewPeer()->Collapse(item);
GetDataViewPeer()->Collapse(item);
}
void wxDataViewCtrl::EnsureVisible(wxDataViewItem const& item, wxDataViewColumn const* columnPtr)
{
if (item.IsOk())
{
this->ExpandAncestors(item); // make sure that the item exists in the control
this->GetDataViewPeer()->EnsureVisible(item,columnPtr);
ExpandAncestors(item); // make sure that the item exists in the control
GetDataViewPeer()->EnsureVisible(item,columnPtr);
}
}
void wxDataViewCtrl::Expand(wxDataViewItem const& item)
{
return this->GetDataViewPeer()->Expand(item);
return GetDataViewPeer()->Expand(item);
}
bool wxDataViewCtrl::IsExpanded( const wxDataViewItem & item ) const
{
return (item.IsOk() && this->GetDataViewPeer()->IsExpanded(item));
return (item.IsOk() && GetDataViewPeer()->IsExpanded(item));
}
wxDataViewColumn* wxDataViewCtrl::GetSortingColumn() const
{
return this->GetDataViewPeer()->GetSortingColumn();
return GetDataViewPeer()->GetSortingColumn();
}
unsigned int wxDataViewCtrl::GetCount() const
{
return this->GetDataViewPeer()->GetCount();
return GetDataViewPeer()->GetCount();
}
wxRect wxDataViewCtrl::GetItemRect(wxDataViewItem const& item, wxDataViewColumn const* columnPtr) const
{
if (item.IsOk() && (columnPtr != NULL))
return this->GetDataViewPeer()->GetRectangle(item,columnPtr);
return GetDataViewPeer()->GetRectangle(item,columnPtr);
else
return wxRect();
}
@ -512,7 +512,7 @@ wxDataViewItem wxDataViewCtrl::GetSelection() const
wxDataViewItemArray itemIDs;
if (this->GetDataViewPeer()->GetSelections(itemIDs) > 0)
if (GetDataViewPeer()->GetSelections(itemIDs) > 0)
return itemIDs[0];
else
return wxDataViewItem();
@ -520,31 +520,31 @@ wxDataViewItem wxDataViewCtrl::GetSelection() const
int wxDataViewCtrl::GetSelections(wxDataViewItemArray& sel) const
{
return this->GetDataViewPeer()->GetSelections(sel);
return GetDataViewPeer()->GetSelections(sel);
}
void wxDataViewCtrl::HitTest(wxPoint const& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const
{
return this->GetDataViewPeer()->HitTest(point,item,columnPtr);
return GetDataViewPeer()->HitTest(point,item,columnPtr);
}
bool wxDataViewCtrl::IsSelected(wxDataViewItem const& item) const
{
return this->GetDataViewPeer()->IsSelected(item);
return GetDataViewPeer()->IsSelected(item);
}
void wxDataViewCtrl::Select(wxDataViewItem const& item)
{
if (item.IsOk())
{
this->ExpandAncestors(item); // make sure that the item exists in the control
this->GetDataViewPeer()->Select(item);
ExpandAncestors(item); // make sure that the item exists in the control
GetDataViewPeer()->Select(item);
}
}
void wxDataViewCtrl::SelectAll(void)
void wxDataViewCtrl::SelectAll()
{
this->GetDataViewPeer()->SelectAll();
GetDataViewPeer()->SelectAll();
}
void wxDataViewCtrl::SetSelections(wxDataViewItemArray const& sel)
@ -560,15 +560,15 @@ void wxDataViewCtrl::SetSelections(wxDataViewItemArray const& sel)
for (i = 0; i < noOfSelections; i++)
{
wxDataViewItem item = sel[i];
wxDataViewItem parent = this->GetModel()->GetParent( item );
wxDataViewItem parent = GetModel()->GetParent( item );
if (parent.IsOk() && (parent != last_parent))
this->ExpandAncestors(item);
ExpandAncestors(item);
last_parent = parent;
}
// finally select the items:
wxDataViewWidgetImpl* dataViewWidgetPtr(this->GetDataViewPeer()); // variable definition for abbreviational purposes
wxDataViewWidgetImpl* dataViewWidgetPtr(GetDataViewPeer()); // variable definition for abbreviational purposes
for (i=0; i<noOfSelections; ++i)
dataViewWidgetPtr->Select(sel[i]);
@ -577,20 +577,20 @@ void wxDataViewCtrl::SetSelections(wxDataViewItemArray const& sel)
void wxDataViewCtrl::Unselect(wxDataViewItem const& item)
{
if (item.IsOk())
this->GetDataViewPeer()->Unselect(item);
GetDataViewPeer()->Unselect(item);
}
void wxDataViewCtrl::UnselectAll(void)
void wxDataViewCtrl::UnselectAll()
{
this->GetDataViewPeer()->UnselectAll();
GetDataViewPeer()->UnselectAll();
}
//
// implementation
//
wxDataViewWidgetImpl* wxDataViewCtrl::GetDataViewPeer(void) const
wxDataViewWidgetImpl* wxDataViewCtrl::GetDataViewPeer() const
{
return dynamic_cast<wxDataViewWidgetImpl*>(this->GetPeer());
return dynamic_cast<wxDataViewWidgetImpl*>(GetPeer());
}
void wxDataViewCtrl::AddChildren(wxDataViewItem const& parentItem)
@ -600,18 +600,18 @@ void wxDataViewCtrl::AddChildren(wxDataViewItem const& parentItem)
wxDataViewItemArray items;
wxCHECK_RET(this->GetModel() != NULL,_("Model pointer not initialized."));
noOfChildren = this->GetModel()->GetChildren(parentItem,items);
(void) this->GetModel()->ItemsAdded(parentItem,items);
wxCHECK_RET(GetModel() != NULL,_("Model pointer not initialized."));
noOfChildren = GetModel()->GetChildren(parentItem,items);
(void) GetModel()->ItemsAdded(parentItem,items);
}
void wxDataViewCtrl::FinishCustomItemEditing(void)
void wxDataViewCtrl::FinishCustomItemEditing()
{
if (this->GetCustomRendererItem().IsOk())
if (GetCustomRendererItem().IsOk())
{
this->GetCustomRendererPtr()->FinishEditing();
this->SetCustomRendererItem(wxDataViewItem());
this->SetCustomRendererPtr (NULL);
GetCustomRendererPtr()->FinishEditing();
SetCustomRendererItem(wxDataViewItem());
SetCustomRendererPtr (NULL);
}
}
@ -631,25 +631,25 @@ wxDataViewCtrl::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
// inherited methods from wxDataViewCtrlBase
void wxDataViewCtrl::DoSetExpanderColumn()
{
if (this->GetExpanderColumn() != NULL)
this->GetDataViewPeer()->DoSetExpanderColumn(this->GetExpanderColumn());
if (GetExpanderColumn() != NULL)
GetDataViewPeer()->DoSetExpanderColumn(GetExpanderColumn());
}
void wxDataViewCtrl::DoSetIndent()
{
this->GetDataViewPeer()->DoSetIndent(this->GetIndent());
GetDataViewPeer()->DoSetIndent(GetIndent());
}
// event handling:
void wxDataViewCtrl::OnSize(wxSizeEvent& event)
{
unsigned int const noOfColumns = this->GetColumnCount();
unsigned int const noOfColumns = GetColumnCount();
// reset DC of all custom renderers because DC has changed:
for (unsigned int i=0; i<noOfColumns; ++i)
{
wxDataViewColumn* dataViewColumnPtr(this->GetColumn(i));
wxDataViewColumn* dataViewColumnPtr(GetColumn(i));
if (dataViewColumnPtr != NULL)
{
@ -661,7 +661,7 @@ void wxDataViewCtrl::OnSize(wxSizeEvent& event)
}
// update the layout of the native control after a size event:
this->GetDataViewPeer()->OnSize();
GetDataViewPeer()->OnSize();
event.Skip();
}