Merge branch 'better-mac-32bit-fix'
Re-enable alignment support for wxDataViewCtrl cells in wxOSX which was previously disabled just to allow the library to compile in 32 bits. Closes https://github.com/wxWidgets/wxWidgets/pull/377
This commit is contained in:
@@ -376,6 +376,12 @@ private:
|
||||
#define wxTextFieldCell NSTextFieldCell
|
||||
#else
|
||||
@interface wxTextFieldCell : NSTextFieldCell
|
||||
{
|
||||
@private
|
||||
int alignment_;
|
||||
BOOL adjustRect_;
|
||||
}
|
||||
|
||||
-(void) setWXAlignment:(int)alignment;
|
||||
@end
|
||||
#endif
|
||||
|
@@ -1252,26 +1252,12 @@ outlineView:(NSOutlineView*)outlineView
|
||||
// wxTextFieldCell
|
||||
// ============================================================================
|
||||
|
||||
#ifndef _LP64
|
||||
// The code below doesn't compile in 32 bits failing with
|
||||
//
|
||||
// error: instance variables may not be placed in class extension
|
||||
//
|
||||
// Until this can be fixed, disable it to at least fix compilation.
|
||||
#else
|
||||
@interface wxTextFieldCell ()
|
||||
{
|
||||
int _wxAlignment;
|
||||
BOOL _adjustRect;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation wxTextFieldCell
|
||||
|
||||
- (void)setWXAlignment:(int)alignment
|
||||
{
|
||||
_wxAlignment = alignment;
|
||||
_adjustRect = (alignment & (wxALIGN_CENTRE_VERTICAL | wxALIGN_BOTTOM)) != 0;
|
||||
alignment_ = alignment;
|
||||
adjustRect_ = (alignment & (wxALIGN_CENTRE_VERTICAL | wxALIGN_BOTTOM)) != 0;
|
||||
}
|
||||
|
||||
// These three overrides implement vertical alignment of text cells.
|
||||
@@ -1283,7 +1269,7 @@ outlineView:(NSOutlineView*)outlineView
|
||||
// Get the parent's idea of where we should draw
|
||||
NSRect r = [super drawingRectForBounds:theRect];
|
||||
|
||||
if (!_adjustRect)
|
||||
if (!adjustRect_)
|
||||
return r;
|
||||
if (theRect.size.height <= MINIMUM_NATIVE_ROW_HEIGHT)
|
||||
return r; // don't mess with default-sized rows as they are centered
|
||||
@@ -1291,12 +1277,12 @@ outlineView:(NSOutlineView*)outlineView
|
||||
NSSize bestSize = [self cellSizeForBounds:theRect];
|
||||
if (bestSize.height < r.size.height)
|
||||
{
|
||||
if (_wxAlignment & wxALIGN_CENTER_VERTICAL)
|
||||
if (alignment_ & wxALIGN_CENTER_VERTICAL)
|
||||
{
|
||||
r.origin.y += int(r.size.height - bestSize.height) / 2;
|
||||
r.size.height = bestSize.height;
|
||||
}
|
||||
else if (_wxAlignment & wxALIGN_BOTTOM)
|
||||
else if (alignment_ & wxALIGN_BOTTOM)
|
||||
{
|
||||
r.origin.y += r.size.height - bestSize.height;
|
||||
r.size.height = bestSize.height;
|
||||
@@ -1308,30 +1294,29 @@ outlineView:(NSOutlineView*)outlineView
|
||||
|
||||
- (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject start:(NSInteger)selStart length:(NSInteger)selLength
|
||||
{
|
||||
BOOL oldAdjustRect = _adjustRect;
|
||||
BOOL oldAdjustRect = adjustRect_;
|
||||
if (oldAdjustRect)
|
||||
{
|
||||
aRect = [self drawingRectForBounds:aRect];
|
||||
_adjustRect = NO;
|
||||
adjustRect_ = NO;
|
||||
}
|
||||
[super selectWithFrame:aRect inView:controlView editor:textObj delegate:anObject start:selStart length:selLength];
|
||||
_adjustRect = oldAdjustRect;
|
||||
adjustRect_ = oldAdjustRect;
|
||||
}
|
||||
|
||||
- (void)editWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject event:(NSEvent *)theEvent
|
||||
{
|
||||
BOOL oldAdjustRect = _adjustRect;
|
||||
BOOL oldAdjustRect = adjustRect_;
|
||||
if (oldAdjustRect)
|
||||
{
|
||||
aRect = [self drawingRectForBounds:aRect];
|
||||
_adjustRect = NO;
|
||||
adjustRect_ = NO;
|
||||
}
|
||||
[super editWithFrame:aRect inView:controlView editor:textObj delegate:anObject event:theEvent];
|
||||
_adjustRect = oldAdjustRect;
|
||||
adjustRect_ = oldAdjustRect;
|
||||
}
|
||||
|
||||
@end
|
||||
#endif // 32/64 bits
|
||||
|
||||
|
||||
// ============================================================================
|
||||
@@ -2763,10 +2748,8 @@ void wxDataViewRenderer::OSXUpdateAlignment()
|
||||
int align = GetEffectiveAlignment();
|
||||
NSCell *cell = GetNativeData()->GetColumnCell();
|
||||
[cell setAlignment:ConvertToNativeHorizontalTextAlignment(align)];
|
||||
#ifdef _LP64
|
||||
if ([cell respondsToSelector:@selector(setWXAlignment:)])
|
||||
[(wxTextFieldCell*)cell setWXAlignment:align];
|
||||
#endif // _LP64
|
||||
}
|
||||
|
||||
void wxDataViewRenderer::SetMode(wxDataViewCellMode mode)
|
||||
|
Reference in New Issue
Block a user