Implement wxDataViewCtrl::SetRowHeight() on OS X
This commit is contained in:
		| @@ -157,6 +157,7 @@ wxOSX: | |||||||
| - Fix unnecessary indentation in list-like wxDataViewCtrl (Andreas Falkenhahn). | - Fix unnecessary indentation in list-like wxDataViewCtrl (Andreas Falkenhahn). | ||||||
| - Recognize macOS 10.12 Sierra in wxGetOsDescription() (Tobias Taschner). | - Recognize macOS 10.12 Sierra in wxGetOsDescription() (Tobias Taschner). | ||||||
| - Don't try to open command line arguments as files (Jeff Hostetler). | - Don't try to open command line arguments as files (Jeff Hostetler). | ||||||
|  | - Implement wxDataViewCtrl::SetRowHeight(). | ||||||
|  |  | ||||||
| Unix: | Unix: | ||||||
|  |  | ||||||
|   | |||||||
| @@ -506,6 +506,7 @@ public: | |||||||
|     virtual void HitTest(const wxPoint& point, |     virtual void HitTest(const wxPoint& point, | ||||||
|                          wxDataViewItem& item, |                          wxDataViewItem& item, | ||||||
|                          wxDataViewColumn*& columnPtr) const; |                          wxDataViewColumn*& columnPtr) const; | ||||||
|  |     virtual void SetRowHeight(int height); | ||||||
|     virtual void SetRowHeight(const wxDataViewItem& item, unsigned int height); |     virtual void SetRowHeight(const wxDataViewItem& item, unsigned int height); | ||||||
|     virtual void OnSize(); |     virtual void OnSize(); | ||||||
|      |      | ||||||
| @@ -520,6 +521,7 @@ public: | |||||||
|  |  | ||||||
| private: | private: | ||||||
|     void InitOutlineView(long style); |     void InitOutlineView(long style); | ||||||
|  |     int GetDefaultRowHeight() const; | ||||||
|  |  | ||||||
|     wxCocoaOutlineDataSource* m_DataSource; |     wxCocoaOutlineDataSource* m_DataSource; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -106,6 +106,7 @@ public: | |||||||
|   virtual void DoExpand    (wxDataViewItem const& item)                                                     = 0; // expands the passed item in the native control |   virtual void DoExpand    (wxDataViewItem const& item)                                                     = 0; // expands the passed item in the native control | ||||||
|  |  | ||||||
|   virtual void HitTest     (wxPoint const& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const = 0; // return the item and column pointer that contains with the passed point |   virtual void HitTest     (wxPoint const& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const = 0; // return the item and column pointer that contains with the passed point | ||||||
|  |   virtual void SetRowHeight(int height)                                                                     = 0; // sets the height of all rows | ||||||
|   virtual void SetRowHeight(wxDataViewItem const& item, unsigned int height)                                = 0; // sets the height of the row containg the passed item in the native control |   virtual void SetRowHeight(wxDataViewItem const& item, unsigned int height)                                = 0; // sets the height of the row containg the passed item in the native control | ||||||
|   virtual void OnSize      (void)                                                                           = 0; // updates the layout of the native control after a size event |   virtual void OnSize      (void)                                                                           = 0; // updates the layout of the native control after a size event | ||||||
|   virtual void StartEditor( const wxDataViewItem & item, unsigned int column )                              = 0; // starts editing the passed in item and column |   virtual void StartEditor( const wxDataViewItem & item, unsigned int column )                              = 0; // starts editing the passed in item and column | ||||||
|   | |||||||
| @@ -179,6 +179,8 @@ public: | |||||||
|  |  | ||||||
|   virtual void HitTest(const wxPoint& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const wxOVERRIDE; |   virtual void HitTest(const wxPoint& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const wxOVERRIDE; | ||||||
|  |  | ||||||
|  |   virtual bool SetRowHeight(int rowHeight) wxOVERRIDE; | ||||||
|  |  | ||||||
|   virtual bool IsSelected(const wxDataViewItem& item) const wxOVERRIDE; |   virtual bool IsSelected(const wxDataViewItem& item) const wxOVERRIDE; | ||||||
|  |  | ||||||
|   virtual void SelectAll() wxOVERRIDE; |   virtual void SelectAll() wxOVERRIDE; | ||||||
|   | |||||||
| @@ -1596,8 +1596,8 @@ public: | |||||||
|         This function can only be used when all rows have the same height, i.e. |         This function can only be used when all rows have the same height, i.e. | ||||||
|         when wxDV_VARIABLE_LINE_HEIGHT flag is not used. |         when wxDV_VARIABLE_LINE_HEIGHT flag is not used. | ||||||
|  |  | ||||||
|         Currently this is implemented in the generic and native GTK versions |         Currently this is implemented in the generic and native GTK and OS X | ||||||
|         only and nothing is done (and @false returned) when using OS X port. |         (since 3.1.1) versions. | ||||||
|  |  | ||||||
|         Also notice that this method can only be used to increase the row |         Also notice that this method can only be used to increase the row | ||||||
|         height compared with the default one (as determined by the return value |         height compared with the default one (as determined by the return value | ||||||
|   | |||||||
| @@ -1975,6 +1975,8 @@ wxCocoaDataViewControl::~wxCocoaDataViewControl() | |||||||
| // | // | ||||||
| bool wxCocoaDataViewControl::ClearColumns() | bool wxCocoaDataViewControl::ClearColumns() | ||||||
| { | { | ||||||
|  |     CGFloat rowHeight = [m_OutlineView rowHeight]; | ||||||
|  |  | ||||||
|     // as there is a bug in NSOutlineView version (OSX 10.5.6 #6555162) the |     // 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; |     // columns cannot be deleted if there is an outline column in the view; | ||||||
|     // therefore, the whole view is deleted and newly constructed: |     // therefore, the whole view is deleted and newly constructed: | ||||||
| @@ -1985,6 +1987,8 @@ bool wxCocoaDataViewControl::ClearColumns() | |||||||
|  |  | ||||||
|     InitOutlineView(GetDataViewCtrl()->GetWindowStyle()); |     InitOutlineView(GetDataViewCtrl()->GetWindowStyle()); | ||||||
|  |  | ||||||
|  |     [m_OutlineView setRowHeight:rowHeight]; | ||||||
|  |  | ||||||
|     return true; |     return true; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -2418,6 +2422,24 @@ void wxCocoaDataViewControl::HitTest(const wxPoint& point, wxDataViewItem& item, | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void wxCocoaDataViewControl::SetRowHeight(int height) | ||||||
|  | { | ||||||
|  |     [m_OutlineView setRowHeight:wxMax(height, GetDefaultRowHeight())]; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | int wxCocoaDataViewControl::GetDefaultRowHeight() const | ||||||
|  | { | ||||||
|  |     const int MINIMUM_NATIVE_HEIGHT = 17; | ||||||
|  |     // Custom setup of NSLayoutManager is necessary to match NSTableView sizing. | ||||||
|  |     // See http://stackoverflow.com/questions/17095927/dynamically-changing-row-height-after-font-size-of-entire-nstableview-nsoutlin | ||||||
|  |     NSLayoutManager *lm = [[NSLayoutManager alloc] init]; | ||||||
|  |     [lm setTypesetterBehavior:NSTypesetterBehavior_10_2_WithCompatibility]; | ||||||
|  |     [lm setUsesScreenFonts:NO]; | ||||||
|  |     CGFloat height = [lm defaultLineHeightForFont:GetWXPeer()->GetFont().OSXGetNSFont()]; | ||||||
|  |     [lm release]; | ||||||
|  |     return wxMax(MINIMUM_NATIVE_HEIGHT, int(height)); | ||||||
|  | } | ||||||
|  |  | ||||||
| void wxCocoaDataViewControl::SetRowHeight(const wxDataViewItem& WXUNUSED(item), unsigned int WXUNUSED(height)) | void wxCocoaDataViewControl::SetRowHeight(const wxDataViewItem& WXUNUSED(item), unsigned int WXUNUSED(height)) | ||||||
|     // Not supported by the native control |     // Not supported by the native control | ||||||
| { | { | ||||||
|   | |||||||
| @@ -568,6 +568,12 @@ void wxDataViewCtrl::HitTest(wxPoint const& point, wxDataViewItem& item, wxDataV | |||||||
|   return GetDataViewPeer()->HitTest(point,item,columnPtr); |   return GetDataViewPeer()->HitTest(point,item,columnPtr); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | bool wxDataViewCtrl::SetRowHeight(int rowHeight) | ||||||
|  | { | ||||||
|  |   GetDataViewPeer()->SetRowHeight(rowHeight); | ||||||
|  |   return true; | ||||||
|  | } | ||||||
|  |  | ||||||
| bool wxDataViewCtrl::IsSelected(wxDataViewItem const& item) const | bool wxDataViewCtrl::IsSelected(wxDataViewItem const& item) const | ||||||
| { | { | ||||||
|   return GetDataViewPeer()->IsSelected(item); |   return GetDataViewPeer()->IsSelected(item); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user