OS X: Fix wxDataViewBitmapRenderer autosizing
wxDataViewCtrl code expects, quite reasonably, that NSCell's cellSize: will behave as documented and return the minimal size for image cells too. Unfortunately, that's not the case. A cell created as NSImageCell, which seems to exists for exactly this purpose, will always return the size as (0,0), regardless of whether it has any image set or not an regardless of its size. On the other hand, a cell created with NSCell.imageCell constructor sizes itself correctly, but is not a NSImageCell instance and somehow interferes with other wxDataViewCtrl rendering, presumably due to its special status. The simplest fix to make the sizing work correctly therefore seems to be to specialize NSImageCell and implement its (trivial) cellSize: method.
This commit is contained in:
@@ -350,6 +350,17 @@ private:
|
||||
-(NSSize) cellSize;
|
||||
@end
|
||||
|
||||
// ============================================================================
|
||||
// wxImageCell: used for bitmap renderer
|
||||
// ============================================================================
|
||||
|
||||
@interface wxImageCell : NSImageCell
|
||||
{
|
||||
}
|
||||
|
||||
-(NSSize) cellSize;
|
||||
@end
|
||||
|
||||
// ============================================================================
|
||||
// wxImageTextCell
|
||||
// ============================================================================
|
||||
|
@@ -1226,6 +1226,21 @@ outlineView:(NSOutlineView*)outlineView
|
||||
|
||||
@end
|
||||
|
||||
// ============================================================================
|
||||
// wxImageTextCell
|
||||
// ============================================================================
|
||||
@implementation wxImageCell
|
||||
|
||||
-(NSSize) cellSize
|
||||
{
|
||||
if ([self image] != nil)
|
||||
return [[self image] size];
|
||||
else
|
||||
return NSZeroSize;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// ============================================================================
|
||||
// wxImageTextCell
|
||||
// ============================================================================
|
||||
@@ -2804,10 +2819,7 @@ wxDataViewBitmapRenderer::wxDataViewBitmapRenderer(const wxString& varianttype,
|
||||
int align)
|
||||
: wxDataViewRenderer(varianttype,mode,align)
|
||||
{
|
||||
NSImageCell* cell;
|
||||
|
||||
|
||||
cell = [[NSImageCell alloc] init];
|
||||
NSCell* cell = [[wxImageCell alloc] init];
|
||||
SetNativeData(new wxDataViewRendererNativeData(cell));
|
||||
[cell release];
|
||||
}
|
||||
|
Reference in New Issue
Block a user