Fix display of items without attributes in Cocoa wxDVC.

The attribute used for the last item was reused for the next item in the same
column unless it was overridden in the attribute of this item, fix this by
remembering the original attribute and using it if no attributes are
explicitly specified.

Also change the sample to show the items without attributes in a column with
attributes and make the label correspond to the attribute of the item.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62390 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-10-12 17:30:48 +00:00
parent a8afd748c7
commit 09a0ece0dc
3 changed files with 115 additions and 29 deletions

View File

@@ -129,17 +129,24 @@ public:
//
wxDataViewRendererNativeData(void) : m_Object(NULL), m_ColumnCell(NULL)
{
Init();
}
wxDataViewRendererNativeData(NSCell* initColumnCell) : m_Object(NULL), m_ColumnCell([initColumnCell retain])
{
Init();
}
wxDataViewRendererNativeData(NSCell* initColumnCell, id initObject) : m_Object([initObject retain]), m_ColumnCell([initColumnCell retain])
{
Init();
}
~wxDataViewRendererNativeData()
{
[m_ColumnCell release];
[m_Object release];
[m_origFont release];
[m_origTextColour release];
}
//
@@ -191,11 +198,34 @@ public:
m_Object = newObject;
}
protected:
// The original cell font and text colour stored here are NULL by default and
// are only initialized to the values retrieved from the cell when we change
// them from wxCocoaOutlineView:willDisplayCell:forTableColumn:item: which
// calls our SaveOriginalXXX() methods before changing the cell attributes.
//
// This allows us to avoid doing anything for the columns without any
// attributes but still be able to restore the correct attributes for the
// ones that do.
NSFont *GetOriginalFont() const { return m_origFont; }
NSColor *GetOriginalTextColour() const { return m_origTextColour; }
void SaveOriginalFont(NSFont *font)
{
m_origFont = [font retain];
}
void SaveOriginalTextColour(NSColor *textColour)
{
m_origTextColour = [textColour retain];
}
private:
//
// variables
//
void Init()
{
m_origFont = NULL;
m_origTextColour = NULL;
}
id m_Item; // item NOT owned by renderer
id m_Object; // object that can be used by renderer for storing special data (owned by renderer)
@@ -203,6 +233,10 @@ private:
NSCell* m_ItemCell; // item's cell is NOT owned by renderer
NSTableColumn* m_TableColumnPtr; // column NOT owned by renderer
// we own those if they're non-NULL
NSFont *m_origFont;
NSColor *m_origTextColour;
};
// ============================================================================