try support for native isFlipped usage and coalesce update rects into bounding box by default
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73264 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -20,6 +20,13 @@
|
|||||||
#define wxOSX_USE_NATIVE_TOOLBAR 1
|
#define wxOSX_USE_NATIVE_TOOLBAR 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* leave is isFlipped and don't override
|
||||||
|
*/
|
||||||
|
#ifndef wxOSX_USE_NATIVE_FLIPPED
|
||||||
|
#define wxOSX_USE_NATIVE_FLIPPED 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* text rendering system
|
* text rendering system
|
||||||
*/
|
*/
|
||||||
|
@@ -140,8 +140,10 @@ public :
|
|||||||
virtual void SetupMouseEvent(wxMouseEvent &wxevent, NSEvent * nsEvent);
|
virtual void SetupMouseEvent(wxMouseEvent &wxevent, NSEvent * nsEvent);
|
||||||
|
|
||||||
|
|
||||||
|
#if !wxOSX_USE_NATIVE_FLIPPED
|
||||||
void SetFlipped(bool flipped);
|
void SetFlipped(bool flipped);
|
||||||
virtual bool IsFlipped() const { return m_isFlipped; }
|
virtual bool IsFlipped() const { return m_isFlipped; }
|
||||||
|
#endif
|
||||||
|
|
||||||
// cocoa thunk connected calls
|
// cocoa thunk connected calls
|
||||||
|
|
||||||
@@ -157,7 +159,9 @@ public :
|
|||||||
virtual bool acceptsFirstResponder(WXWidget slf, void* _cmd);
|
virtual bool acceptsFirstResponder(WXWidget slf, void* _cmd);
|
||||||
virtual bool becomeFirstResponder(WXWidget slf, void* _cmd);
|
virtual bool becomeFirstResponder(WXWidget slf, void* _cmd);
|
||||||
virtual bool resignFirstResponder(WXWidget slf, void* _cmd);
|
virtual bool resignFirstResponder(WXWidget slf, void* _cmd);
|
||||||
|
#if !wxOSX_USE_NATIVE_FLIPPED
|
||||||
virtual bool isFlipped(WXWidget slf, void* _cmd);
|
virtual bool isFlipped(WXWidget slf, void* _cmd);
|
||||||
|
#endif
|
||||||
virtual void drawRect(void* rect, WXWidget slf, void* _cmd);
|
virtual void drawRect(void* rect, WXWidget slf, void* _cmd);
|
||||||
|
|
||||||
virtual void controlAction(WXWidget slf, void* _cmd, void* sender);
|
virtual void controlAction(WXWidget slf, void* _cmd, void* sender);
|
||||||
@@ -170,7 +174,9 @@ public :
|
|||||||
protected:
|
protected:
|
||||||
WXWidget m_osxView;
|
WXWidget m_osxView;
|
||||||
NSEvent* m_lastKeyDownEvent;
|
NSEvent* m_lastKeyDownEvent;
|
||||||
|
#if !wxOSX_USE_NATIVE_FLIPPED
|
||||||
bool m_isFlipped;
|
bool m_isFlipped;
|
||||||
|
#endif
|
||||||
// if it the control has an editor, that editor will already send some
|
// if it the control has an editor, that editor will already send some
|
||||||
// events, don't resend them
|
// events, don't resend them
|
||||||
bool m_hasEditor;
|
bool m_hasEditor;
|
||||||
|
@@ -172,7 +172,9 @@ wxDateTimeWidgetImpl::CreateDateTimePicker(wxDateTimePickerCtrl* wxpeer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
wxDateTimeWidgetImpl* c = new wxDateTimeWidgetCocoaImpl(wxpeer, v);
|
wxDateTimeWidgetImpl* c = new wxDateTimeWidgetCocoaImpl(wxpeer, v);
|
||||||
|
#if !wxOSX_USE_NATIVE_FLIPPED
|
||||||
c->SetFlipped(false);
|
c->SetFlipped(false);
|
||||||
|
#endif
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -73,7 +73,9 @@ wxWidgetImplType* wxWidgetImpl::CreateGroupBox( wxWindowMac* wxpeer,
|
|||||||
NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
|
NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
|
||||||
wxNSBox* v = [[wxNSBox alloc] initWithFrame:r];
|
wxNSBox* v = [[wxNSBox alloc] initWithFrame:r];
|
||||||
wxStaticBoxCocoaImpl* c = new wxStaticBoxCocoaImpl( wxpeer, v );
|
wxStaticBoxCocoaImpl* c = new wxStaticBoxCocoaImpl( wxpeer, v );
|
||||||
|
#if !wxOSX_USE_NATIVE_FLIPPED
|
||||||
c->SetFlipped(false);
|
c->SetFlipped(false);
|
||||||
|
#endif
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -911,6 +911,8 @@ BOOL wxOSX_resignFirstResponder(NSView* self, SEL _cmd)
|
|||||||
return impl->resignFirstResponder(self, _cmd);
|
return impl->resignFirstResponder(self, _cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !wxOSX_USE_NATIVE_FLIPPED
|
||||||
|
|
||||||
BOOL wxOSX_isFlipped(NSView* self, SEL _cmd)
|
BOOL wxOSX_isFlipped(NSView* self, SEL _cmd)
|
||||||
{
|
{
|
||||||
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
|
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
|
||||||
@@ -920,6 +922,8 @@ BOOL wxOSX_isFlipped(NSView* self, SEL _cmd)
|
|||||||
return impl->isFlipped(self, _cmd) ? YES:NO;
|
return impl->isFlipped(self, _cmd) ? YES:NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef void (*wxOSX_DrawRectHandlerPtr)(NSView* self, SEL _cmd, NSRect rect);
|
typedef void (*wxOSX_DrawRectHandlerPtr)(NSView* self, SEL _cmd, NSRect rect);
|
||||||
|
|
||||||
void wxOSX_drawRect(NSView* self, SEL _cmd, NSRect rect)
|
void wxOSX_drawRect(NSView* self, SEL _cmd, NSRect rect)
|
||||||
@@ -1297,11 +1301,14 @@ bool wxWidgetCocoaImpl::resignFirstResponder(WXWidget slf, void *_cmd)
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWidgetCocoaImpl::isFlipped(WXWidget WXUNUSED(slf), void *WXUNUSED(_cmd))
|
#if !wxOSX_USE_NATIVE_FLIPPED
|
||||||
|
|
||||||
|
bool wxWidgetCocoaImpl::isFlipped(WXWidget slf, void *WXUNUSED(_cmd))
|
||||||
{
|
{
|
||||||
return m_isFlipped;
|
return m_isFlipped;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#define OSX_DEBUG_DRAWING 0
|
#define OSX_DEBUG_DRAWING 0
|
||||||
|
|
||||||
@@ -1310,15 +1317,20 @@ void wxWidgetCocoaImpl::drawRect(void* rect, WXWidget slf, void *WXUNUSED(_cmd))
|
|||||||
// preparing the update region
|
// preparing the update region
|
||||||
|
|
||||||
wxRegion updateRgn;
|
wxRegion updateRgn;
|
||||||
|
|
||||||
|
// since adding many rects to a region is a costly process, by default use the bounding rect
|
||||||
|
#if 0
|
||||||
const NSRect *rects;
|
const NSRect *rects;
|
||||||
NSInteger count;
|
NSInteger count;
|
||||||
|
|
||||||
[slf getRectsBeingDrawn:&rects count:&count];
|
[slf getRectsBeingDrawn:&rects count:&count];
|
||||||
for ( int i = 0 ; i < count ; ++i )
|
for ( int i = 0 ; i < count ; ++i )
|
||||||
{
|
{
|
||||||
updateRgn.Union(wxFromNSRect(slf, rects[i]));
|
updateRgn.Union(wxFromNSRect(slf, rects[i]));
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
updateRgn.Union(wxFromNSRect(slf,*(NSRect*)rect));
|
||||||
|
#endif
|
||||||
|
|
||||||
wxWindow* wxpeer = GetWXPeer();
|
wxWindow* wxpeer = GetWXPeer();
|
||||||
|
|
||||||
if ( wxpeer->MacGetLeftBorderSize() != 0 || wxpeer->MacGetTopBorderSize() != 0 )
|
if ( wxpeer->MacGetLeftBorderSize() != 0 || wxpeer->MacGetTopBorderSize() != 0 )
|
||||||
@@ -1373,7 +1385,7 @@ void wxWidgetCocoaImpl::drawRect(void* rect, WXWidget slf, void *WXUNUSED(_cmd))
|
|||||||
CGContextStrokePath(context);
|
CGContextStrokePath(context);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( !m_isFlipped )
|
if ( ![slf isFlipped] )
|
||||||
{
|
{
|
||||||
CGContextTranslateCTM( context, 0, [m_osxView bounds].size.height );
|
CGContextTranslateCTM( context, 0, [m_osxView bounds].size.height );
|
||||||
CGContextScaleCTM( context, 1, -1 );
|
CGContextScaleCTM( context, 1, -1 );
|
||||||
@@ -1395,7 +1407,7 @@ void wxWidgetCocoaImpl::drawRect(void* rect, WXWidget slf, void *WXUNUSED(_cmd))
|
|||||||
CGContextSaveGState( context );
|
CGContextSaveGState( context );
|
||||||
}
|
}
|
||||||
// as we called restore above, we have to flip again if necessary
|
// as we called restore above, we have to flip again if necessary
|
||||||
if ( !m_isFlipped )
|
if ( ![slf isFlipped] )
|
||||||
{
|
{
|
||||||
CGContextTranslateCTM( context, 0, [m_osxView bounds].size.height );
|
CGContextTranslateCTM( context, 0, [m_osxView bounds].size.height );
|
||||||
CGContextScaleCTM( context, 1, -1 );
|
CGContextScaleCTM( context, 1, -1 );
|
||||||
@@ -1523,7 +1535,9 @@ void wxOSXCocoaClassAddWXMethods(Class c)
|
|||||||
wxOSX_CLASS_ADD_METHOD(c, @selector(becomeFirstResponder), (IMP) wxOSX_becomeFirstResponder, "c@:" )
|
wxOSX_CLASS_ADD_METHOD(c, @selector(becomeFirstResponder), (IMP) wxOSX_becomeFirstResponder, "c@:" )
|
||||||
wxOSX_CLASS_ADD_METHOD(c, @selector(resignFirstResponder), (IMP) wxOSX_resignFirstResponder, "c@:" )
|
wxOSX_CLASS_ADD_METHOD(c, @selector(resignFirstResponder), (IMP) wxOSX_resignFirstResponder, "c@:" )
|
||||||
|
|
||||||
|
#if !wxOSX_USE_NATIVE_FLIPPED
|
||||||
wxOSX_CLASS_ADD_METHOD(c, @selector(isFlipped), (IMP) wxOSX_isFlipped, "c@:" )
|
wxOSX_CLASS_ADD_METHOD(c, @selector(isFlipped), (IMP) wxOSX_isFlipped, "c@:" )
|
||||||
|
#endif
|
||||||
wxOSX_CLASS_ADD_METHOD(c, @selector(drawRect:), (IMP) wxOSX_drawRect, "v@:{_NSRect={_NSPoint=ff}{_NSSize=ff}}" )
|
wxOSX_CLASS_ADD_METHOD(c, @selector(drawRect:), (IMP) wxOSX_drawRect, "v@:{_NSRect={_NSPoint=ff}{_NSSize=ff}}" )
|
||||||
|
|
||||||
wxOSX_CLASS_ADD_METHOD(c, @selector(controlAction:), (IMP) wxOSX_controlAction, "v@:@" )
|
wxOSX_CLASS_ADD_METHOD(c, @selector(controlAction:), (IMP) wxOSX_controlAction, "v@:@" )
|
||||||
@@ -1581,7 +1595,9 @@ wxWidgetCocoaImpl::wxWidgetCocoaImpl()
|
|||||||
void wxWidgetCocoaImpl::Init()
|
void wxWidgetCocoaImpl::Init()
|
||||||
{
|
{
|
||||||
m_osxView = NULL;
|
m_osxView = NULL;
|
||||||
|
#if !wxOSX_USE_NATIVE_FLIPPED
|
||||||
m_isFlipped = true;
|
m_isFlipped = true;
|
||||||
|
#endif
|
||||||
m_lastKeyDownEvent = NULL;
|
m_lastKeyDownEvent = NULL;
|
||||||
m_hasEditor = false;
|
m_hasEditor = false;
|
||||||
}
|
}
|
||||||
@@ -2587,11 +2603,15 @@ void wxWidgetCocoaImpl::ReleaseMouse()
|
|||||||
// [[m_osxView window] enableCursorRects];
|
// [[m_osxView window] enableCursorRects];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !wxOSX_USE_NATIVE_FLIPPED
|
||||||
|
|
||||||
void wxWidgetCocoaImpl::SetFlipped(bool flipped)
|
void wxWidgetCocoaImpl::SetFlipped(bool flipped)
|
||||||
{
|
{
|
||||||
m_isFlipped = flipped;
|
m_isFlipped = flipped;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void wxWidgetCocoaImpl::SetDrawingEnabled(bool enabled)
|
void wxWidgetCocoaImpl::SetDrawingEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
if ( enabled )
|
if ( enabled )
|
||||||
|
Reference in New Issue
Block a user