Implement vertical alignment in wxDataViewCtrl in wxOSX

When using non-default row height, text would be aligned to the top of
the row. This is a known limitation of NSTextFieldCell and the solution
is to either switch to modern view-based rendering or customize the cell
as this commit does.

See https://red-sweater.com/blog/148/what-a-difference-a-cell-makes for
Daniel Jalkut's description of this solution.
This commit is contained in:
Václav Slavík
2016-11-21 18:44:11 +01:00
parent 818b084b4b
commit 92dc929b3f
2 changed files with 98 additions and 6 deletions

View File

@@ -367,6 +367,16 @@ private:
-(NSSize) cellSize;
@end
// ============================================================================
// NSTextFieldCell customized to allow vertical alignment
// ============================================================================
@interface wxTextFieldCell : NSTextFieldCell
-(void) setWXAlignment:(int)alignment;
@end
// ============================================================================
// wxImageTextCell
// ============================================================================
@@ -382,7 +392,7 @@ private:
// into their reserved space. Smaller or not existing images use the fixed
// reserved size and are scaled if necessary.
//
@interface wxImageTextCell : NSTextFieldCell
@interface wxImageTextCell : wxTextFieldCell
{
@private
CGFloat xImageShift; // shift for the image in x-direction from border