]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/osx/cocoa/dataview.h
Fixes to comparison operators for wxDVC classes.
[wxWidgets.git] / include / wx / osx / cocoa / dataview.h
index 25a60f38f338f3db9b557f59bf4caa3300e692e1..a5aa4509b339d0f5b36937de92d6bf6e3fffcc67 100644 (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:
@@ -129,73 +129,103 @@ 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(void)
+
+  ~wxDataViewRendererNativeData()
   {
-    [this->m_ColumnCell release];
-    [this->m_Object     release];
+    [m_ColumnCell release];
+    [m_Object     release];
+
+    [m_origFont release];
+    [m_origTextColour 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;
+  }
+
+  // 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];
   }
 
-protected:
 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;
 };
 
 // ============================================================================
@@ -235,11 +269,11 @@ private:
   NSMutableArray* children; // buffered children
 
   NSMutableSet* items; // stores all items that are in use by the control
-  
+
   wxCocoaDataViewControl* implementation;
-  
+
   wxDataViewModel* model;
-  
+
   wxPointerObject* currentParentItem; // parent of the buffered children; the object is owned
 }
 
@@ -338,11 +372,11 @@ private:
 @private
   CGFloat xImageShift;    // shift for the image in x-direction from border
   CGFloat spaceImageText; // space between image and text ("belongs" to the image)
-  
+
   NSImage* image; // the image itself
-  
+
   NSSize imageSize; // largest size of the image; default size is (16, 16)
-  
+
   NSTextAlignment cellAlignment; // the text alignment is used to align the whole
                                  // cell (image and text)
 }
@@ -405,12 +439,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 +459,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 +480,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 +496,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());
   }
 
 //