@interface NSEvent (DeviceDelta)
- (CGFloat)deviceDeltaX;
- (CGFloat)deviceDeltaY;
+
+// 10.7+
+- (BOOL)hasPreciseScrollingDeltas;
+- (CGFloat)scrollingDeltaX;
+- (CGFloat)scrollingDeltaY;
@end
void wxWidgetCocoaImpl::SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEvent )
wxevent.SetEventType( wxEVT_MOUSEWHEEL ) ;
- // see http://developer.apple.com/qa/qa2005/qa1453.html
- // for more details on why we have to look for the exact type
-
- const EventRef cEvent = (EventRef) [nsEvent eventRef];
- bool isMouseScrollEvent = false;
- if ( cEvent )
- isMouseScrollEvent = ::GetEventKind(cEvent) == kEventMouseScroll;
-
- if ( isMouseScrollEvent )
+ if ( UMAGetSystemVersion() >= 0x1070 )
{
- deltaX = [nsEvent deviceDeltaX];
- deltaY = [nsEvent deviceDeltaY];
+ if ( [nsEvent hasPreciseScrollingDeltas] )
+ {
+ deltaX = [nsEvent scrollingDeltaX];
+ deltaY = [nsEvent scrollingDeltaY];
+ }
+ else
+ {
+ deltaX = [nsEvent scrollingDeltaX] * 10;
+ deltaY = [nsEvent scrollingDeltaY] * 10;
+ }
}
else
{
- deltaX = ([nsEvent deltaX] * 10);
- deltaY = ([nsEvent deltaY] * 10);
+ const EventRef cEvent = (EventRef) [nsEvent eventRef];
+ // see http://developer.apple.com/qa/qa2005/qa1453.html
+ // for more details on why we have to look for the exact type
+
+ bool isMouseScrollEvent = false;
+ if ( cEvent )
+ isMouseScrollEvent = ::GetEventKind(cEvent) == kEventMouseScroll;
+
+ if ( isMouseScrollEvent )
+ {
+ deltaX = [nsEvent deviceDeltaX];
+ deltaY = [nsEvent deviceDeltaY];
+ }
+ else
+ {
+ deltaX = ([nsEvent deltaX] * 10);
+ deltaY = ([nsEvent deltaY] * 10);
+ }
}
wxevent.m_wheelDelta = 10;
if ([cell respondsToSelector:@selector(setControlSize:)])
[cell setControlSize:size];
}
+
+ // we need to propagate this to inner views as well
+ if ( [m_osxView isKindOfClass:[NSScrollView class] ] )
+ {
+ NSView* targetView = [(NSScrollView*) m_osxView documentView];
+
+ if ( [targetView respondsToSelector:@selector(setControlSize:)] )
+ [targetView setControlSize:size];
+ else if ([targetView respondsToSelector:@selector(cell)])
+ {
+ id cell = [(id)targetView cell];
+ if ([cell respondsToSelector:@selector(setControlSize:)])
+ [cell setControlSize:size];
+ }
+ }
}
void wxWidgetCocoaImpl::SetFont(wxFont const& font, wxColour const&col, long, bool)
{
- if ([m_osxView respondsToSelector:@selector(setFont:)])
- [m_osxView setFont: font.OSXGetNSFont()];
- if ([m_osxView respondsToSelector:@selector(setTextColor:)])
- [m_osxView setTextColor:[NSColor colorWithCalibratedRed:(CGFloat) (col.Red() / 255.0)
+ NSView* targetView = m_osxView;
+ if ( [m_osxView isKindOfClass:[NSScrollView class] ] )
+ targetView = [(NSScrollView*) m_osxView documentView];
+
+ if ([targetView respondsToSelector:@selector(setFont:)])
+ [targetView setFont: font.OSXGetNSFont()];
+ if ([targetView respondsToSelector:@selector(setTextColor:)])
+ [targetView setTextColor:[NSColor colorWithCalibratedRed:(CGFloat) (col.Red() / 255.0)
green:(CGFloat) (col.Green() / 255.0)
blue:(CGFloat) (col.Blue() / 255.0)
alpha:(CGFloat) (col.Alpha() / 255.0)]];