diff --git a/include/wx/osx/glcanvas.h b/include/wx/osx/glcanvas.h index dda9ab2ed4..e1948c2f70 100644 --- a/include/wx/osx/glcanvas.h +++ b/include/wx/osx/glcanvas.h @@ -158,7 +158,6 @@ public: // implementation-only from now on protected: -#if wxOSX_USE_IPHONE bool DoCreate(wxWindow *parent, wxWindowID id, const wxPoint& pos, @@ -166,7 +165,6 @@ protected: long style, const wxString& name); -#endif WXGLPixelFormat m_glFormat; wxGLAttributes m_GLAttrs; diff --git a/samples/aui/minimal_iphone.xcodeproj/project.pbxproj b/samples/aui/minimal_iphone.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..d58c9ee111 --- /dev/null +++ b/samples/aui/minimal_iphone.xcodeproj/project.pbxproj @@ -0,0 +1,265 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 45; + objects = { + +/* Begin PBXBuildFile section */ + 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; + 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; + 288765FD0DF74451002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765FC0DF74451002DB57D /* CoreGraphics.framework */; }; + 407A98E11370835D00E92356 /* minimal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 407A98E01370835D00E92356 /* minimal.cpp */; }; + 407EE18312F04CD500D0F171 /* libwx_osx_iphone.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4074F5E912ED969C00693A3F /* libwx_osx_iphone.a */; }; + 407EE18A12F04CF900D0F171 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 407EE18912F04CF900D0F171 /* AudioToolbox.framework */; }; + 40803704158A894A00EC5CA7 /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 40803703158A894A00EC5CA7 /* CoreText.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 4074F5E812ED969C00693A3F /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 404BECC510EBDB420080E2B8 /* wxiphone.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = B4DEA098A05736AE94F01926; + remoteInfo = static; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 1D6058910D05DD3D006BFB54 /* minimal_iphone.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = minimal_iphone.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + 288765FC0DF74451002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + 404BECC510EBDB420080E2B8 /* wxiphone.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = wxiphone.xcodeproj; path = ../../build/osx/wxiPhone.xcodeproj; sourceTree = SOURCE_ROOT; }; + 404BEE0510EC7BF20080E2B8 /* wxiphone.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = wxiphone.xcconfig; path = ../../build/osx/wxiphone.xcconfig; sourceTree = SOURCE_ROOT; }; + 407A98E01370835D00E92356 /* minimal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = minimal.cpp; sourceTree = ""; }; + 407A98FA137084FB00E92356 /* Info_iphone.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info_iphone.plist; sourceTree = ""; }; + 407EE18912F04CF900D0F171 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; + 40803703158A894A00EC5CA7 /* CoreText.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = System/Library/Frameworks/CoreText.framework; sourceTree = SDKROOT; }; + 409CBDC913B13C7100AB1F39 /* wxdebug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = wxdebug.xcconfig; path = ../../build/osx/wxdebug.xcconfig; sourceTree = SOURCE_ROOT; }; + 409CBDCA13B13C7100AB1F39 /* wxrelease.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = wxrelease.xcconfig; path = ../../build/osx/wxrelease.xcconfig; sourceTree = SOURCE_ROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 1D60588F0D05DD3D006BFB54 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */, + 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */, + 288765FD0DF74451002DB57D /* CoreGraphics.framework in Frameworks */, + 407EE18312F04CD500D0F171 /* libwx_osx_iphone.a in Frameworks */, + 407EE18A12F04CF900D0F171 /* AudioToolbox.framework in Frameworks */, + 40803704158A894A00EC5CA7 /* CoreText.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 19C28FACFE9D520D11CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + 1D6058910D05DD3D006BFB54 /* minimal_iphone.app */, + ); + name = Products; + sourceTree = ""; + }; + 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { + isa = PBXGroup; + children = ( + 407A98FA137084FB00E92356 /* Info_iphone.plist */, + 404BEE0510EC7BF20080E2B8 /* wxiphone.xcconfig */, + 409CBDC913B13C7100AB1F39 /* wxdebug.xcconfig */, + 409CBDCA13B13C7100AB1F39 /* wxrelease.xcconfig */, + 404BECC510EBDB420080E2B8 /* wxiphone.xcodeproj */, + 404BECD110EBDC6F0080E2B8 /* src */, + 29B97317FDCFA39411CA2CEA /* Resources */, + 29B97323FDCFA39411CA2CEA /* Frameworks */, + 19C28FACFE9D520D11CA2CBB /* Products */, + ); + name = CustomTemplate; + sourceTree = ""; + }; + 29B97317FDCFA39411CA2CEA /* Resources */ = { + isa = PBXGroup; + children = ( + ); + name = Resources; + sourceTree = ""; + }; + 29B97323FDCFA39411CA2CEA /* Frameworks */ = { + isa = PBXGroup; + children = ( + 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */, + 1D30AB110D05D00D00671497 /* Foundation.framework */, + 288765FC0DF74451002DB57D /* CoreGraphics.framework */, + 407EE18912F04CF900D0F171 /* AudioToolbox.framework */, + 40803703158A894A00EC5CA7 /* CoreText.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 404BECC610EBDB420080E2B8 /* Products */ = { + isa = PBXGroup; + children = ( + 4074F5E912ED969C00693A3F /* libwx_osx_iphone.a */, + ); + name = Products; + sourceTree = ""; + }; + 404BECD110EBDC6F0080E2B8 /* src */ = { + isa = PBXGroup; + children = ( + 407A98E01370835D00E92356 /* minimal.cpp */, + ); + name = src; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 1D6058900D05DD3D006BFB54 /* static */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "static" */; + buildPhases = ( + 1D60588D0D05DD3D006BFB54 /* Resources */, + 1D60588E0D05DD3D006BFB54 /* Sources */, + 1D60588F0D05DD3D006BFB54 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = static; + productName = minimal_iphone; + productReference = 1D6058910D05DD3D006BFB54 /* minimal_iphone.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 29B97313FDCFA39411CA2CEA /* Project object */ = { + isa = PBXProject; + buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "minimal_iphone" */; + compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; + hasScannedForEncodings = 1; + knownRegions = ( + English, + Japanese, + French, + German, + ); + mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */; + projectDirPath = ""; + projectReferences = ( + { + ProductGroup = 404BECC610EBDB420080E2B8 /* Products */; + ProjectRef = 404BECC510EBDB420080E2B8 /* wxiphone.xcodeproj */; + }, + ); + projectRoot = ""; + targets = ( + 1D6058900D05DD3D006BFB54 /* static */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXReferenceProxy section */ + 4074F5E912ED969C00693A3F /* libwx_osx_iphone.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libwx_osx_iphone.a; + remoteRef = 4074F5E812ED969C00693A3F /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; +/* End PBXReferenceProxy section */ + +/* Begin PBXResourcesBuildPhase section */ + 1D60588D0D05DD3D006BFB54 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 1D60588E0D05DD3D006BFB54 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 407A98E11370835D00E92356 /* minimal.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 1D6058940D05DD3E006BFB54 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 404BEE0510EC7BF20080E2B8 /* wxiphone.xcconfig */; + buildSettings = { + OTHER_LDFLAGS = ""; + PRODUCT_NAME = minimal_iphone; + }; + name = Debug; + }; + 1D6058950D05DD3E006BFB54 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 404BEE0510EC7BF20080E2B8 /* wxiphone.xcconfig */; + buildSettings = { + PRODUCT_NAME = minimal_iphone; + }; + name = Release; + }; + C01FCF4F08A954540054247B /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 409CBDC913B13C7100AB1F39 /* wxdebug.xcconfig */; + buildSettings = { + CODE_SIGN_IDENTITY = "iPhone Developer"; + INFOPLIST_FILE = Info_iphone.plist; + PROVISIONING_PROFILE = ""; + WXROOT = "$(PROJECT_DIR)/../.."; + }; + name = Debug; + }; + C01FCF5008A954540054247B /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 409CBDCA13B13C7100AB1F39 /* wxrelease.xcconfig */; + buildSettings = { + CODE_SIGN_IDENTITY = "iPhone Distribution"; + INFOPLIST_FILE = Info_iphone.plist; + PROVISIONING_PROFILE = ""; + WXROOT = "$(PROJECT_DIR)/../.."; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "static" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1D6058940D05DD3E006BFB54 /* Debug */, + 1D6058950D05DD3E006BFB54 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C01FCF4E08A954540054247B /* Build configuration list for PBXProject "minimal_iphone" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C01FCF4F08A954540054247B /* Debug */, + C01FCF5008A954540054247B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; +} diff --git a/src/osx/carbon/dcclient.cpp b/src/osx/carbon/dcclient.cpp index 807ac1ace1..c05a31f9d7 100644 --- a/src/osx/carbon/dcclient.cpp +++ b/src/osx/carbon/dcclient.cpp @@ -152,7 +152,6 @@ wxPaintDCImpl::wxPaintDCImpl( wxDC *owner ) wxPaintDCImpl::wxPaintDCImpl( wxDC *owner, wxWindow *window ) : wxWindowDCImpl( owner, window ) { - wxASSERT_MSG( window->MacGetCGContextRef() != NULL, wxT("using wxPaintDC without being in a native paint event") ); wxPoint origin = window->GetClientAreaOrigin() ; m_window->GetClientSize( &m_width , &m_height); SetDeviceOrigin( origin.x, origin.y ); diff --git a/src/osx/cocoa/glcanvas.mm b/src/osx/cocoa/glcanvas.mm index 7afbc6c39e..cc889507e7 100644 --- a/src/osx/cocoa/glcanvas.mm +++ b/src/osx/cocoa/glcanvas.mm @@ -112,9 +112,8 @@ WXGLPixelFormat WXGLChoosePixelFormat(const int *GLAttrs, return [[NSOpenGLPixelFormat alloc] initWithAttributes:(NSOpenGLPixelFormatAttribute*) attribs]; } -@interface wxNSCustomOpenGLView : NSView +@interface wxNSCustomOpenGLView : NSOpenGLView { - NSOpenGLContext* context; } @end @@ -138,6 +137,30 @@ WXGLPixelFormat WXGLChoosePixelFormat(const int *GLAttrs, @end +bool wxGLCanvas::DoCreate(wxWindow *parent, + wxWindowID id, + const wxPoint& pos, + const wxSize& size, + long style, + const wxString& name) +{ + + DontCreatePeer(); + + if ( !wxWindow::Create(parent, id, pos, size, style, name) ) + return false; + + + NSRect r = wxOSXGetFrameForControl( this, pos , size ) ; + wxNSCustomOpenGLView* v = [[wxNSCustomOpenGLView alloc] initWithFrame:r]; + + wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( this, v, false, true ); + SetPeer(c); + MacPostControlCreate(pos, size) ; + return true; +} + + wxGLCanvas::~wxGLCanvas() { if ( m_glFormat ) diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index ea145aafb3..c33cd56dba 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -2291,84 +2291,96 @@ void wxWidgetCocoaImpl::drawRect(void* rect, WXWidget slf, void *WXUNUSED(_cmd)) wxpeer->GetUpdateRegion() = updateRgn; // setting up the drawing context - + // note that starting from 10.14 this may be NULL in certain views CGContextRef context = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort]; - CGContextSaveGState( context ); - -#if OSX_DEBUG_DRAWING - CGContextBeginPath( context ); - CGContextMoveToPoint(context, 0, 0); - NSRect bounds = [slf bounds]; - CGContextAddLineToPoint(context, 10, 0); - CGContextMoveToPoint(context, 0, 0); - CGContextAddLineToPoint(context, 0, 10); - CGContextMoveToPoint(context, bounds.size.width, bounds.size.height); - CGContextAddLineToPoint(context, bounds.size.width, bounds.size.height-10); - CGContextMoveToPoint(context, bounds.size.width, bounds.size.height); - CGContextAddLineToPoint(context, bounds.size.width-10, bounds.size.height); - CGContextClosePath( context ); - CGContextStrokePath(context); -#endif - - if ( ![slf isFlipped] ) - { - CGContextTranslateCTM( context, 0, [m_osxView bounds].size.height ); - CGContextScaleCTM( context, 1, -1 ); - } - wxpeer->MacSetCGContextRef( context ); + if ( context != NULL ) + { + CGContextSaveGState( context ); + +#if OSX_DEBUG_DRAWING + CGContextBeginPath( context ); + CGContextMoveToPoint(context, 0, 0); + NSRect bounds = [slf bounds]; + CGContextAddLineToPoint(context, 10, 0); + CGContextMoveToPoint(context, 0, 0); + CGContextAddLineToPoint(context, 0, 10); + CGContextMoveToPoint(context, bounds.size.width, bounds.size.height); + CGContextAddLineToPoint(context, bounds.size.width, bounds.size.height-10); + CGContextMoveToPoint(context, bounds.size.width, bounds.size.height); + CGContextAddLineToPoint(context, bounds.size.width-10, bounds.size.height); + CGContextClosePath( context ); + CGContextStrokePath(context); +#endif + + if ( ![slf isFlipped] ) + { + CGContextTranslateCTM( context, 0, [m_osxView bounds].size.height ); + CGContextScaleCTM( context, 1, -1 ); + } + } bool handled = wxpeer->MacDoRedraw( 0 ); - CGContextRestoreGState( context ); - - CGContextSaveGState( context ); + if ( context != NULL ) + { + CGContextRestoreGState( context ); + CGContextSaveGState( context ); + } + if ( !handled ) { // call super SEL _cmd = @selector(drawRect:); wxOSX_DrawRectHandlerPtr superimpl = (wxOSX_DrawRectHandlerPtr) [[slf superclass] instanceMethodForSelector:_cmd]; superimpl(slf, _cmd, *(NSRect*)rect); - CGContextRestoreGState( context ); - CGContextSaveGState( context ); - } - // as we called restore above, we have to flip again if necessary - if ( ![slf isFlipped] ) - { - CGContextTranslateCTM( context, 0, [m_osxView bounds].size.height ); - CGContextScaleCTM( context, 1, -1 ); - } - - if ( isTopLevel ) - { - // We also need to explicitly draw the part of the top level window - // outside of its region with transparent colour to ensure that it is - // really transparent. - if ( clearRgn.IsOk() ) + if ( context != NULL ) { - wxMacCGContextStateSaver saveState(context); - wxWindowDC dc(wxpeer); - dc.SetBackground(wxBrush(wxTransparentColour)); - dc.SetDeviceClippingRegion(clearRgn); - dc.Clear(); + CGContextRestoreGState( context ); + CGContextSaveGState( context ); } - + } + + if ( context != NULL ) + { + // as we called restore above, we have to flip again if necessary + if ( ![slf isFlipped] ) + { + CGContextTranslateCTM( context, 0, [m_osxView bounds].size.height ); + CGContextScaleCTM( context, 1, -1 ); + } + + if ( isTopLevel ) + { + // We also need to explicitly draw the part of the top level window + // outside of its region with transparent colour to ensure that it is + // really transparent. + if ( clearRgn.IsOk() ) + { + wxMacCGContextStateSaver saveState(context); + wxWindowDC dc(wxpeer); + dc.SetBackground(wxBrush(wxTransparentColour)); + dc.SetDeviceClippingRegion(clearRgn); + dc.Clear(); + } + #if wxUSE_GRAPHICS_CONTEXT - // If the window shape is defined by a path, stroke the path to show - // the window border. - const wxGraphicsPath& path = tlwParent->GetShapePath(); - if ( !path.IsNull() ) - { - CGContextSetLineWidth(context, 1); - CGContextSetStrokeColorWithColor(context, wxLIGHT_GREY->GetCGColor()); - CGContextAddPath(context, (CGPathRef) path.GetNativePath()); - CGContextStrokePath(context); - } + // If the window shape is defined by a path, stroke the path to show + // the window border. + const wxGraphicsPath& path = tlwParent->GetShapePath(); + if ( !path.IsNull() ) + { + CGContextSetLineWidth(context, 1); + CGContextSetStrokeColorWithColor(context, wxLIGHT_GREY->GetCGColor()); + CGContextAddPath(context, (CGPathRef) path.GetNativePath()); + CGContextStrokePath(context); + } #endif // wxUSE_GRAPHICS_CONTEXT + } + + wxpeer->MacPaintChildrenBorders(); + CGContextRestoreGState( context ); } - - wxpeer->MacPaintChildrenBorders(); wxpeer->MacSetCGContextRef( NULL ); - CGContextRestoreGState( context ); } void wxWidgetCocoaImpl::controlAction( WXWidget WXUNUSED(slf), void *WXUNUSED(_cmd), void *WXUNUSED(sender)) diff --git a/src/osx/glcanvas_osx.cpp b/src/osx/glcanvas_osx.cpp index 66d4c3cd77..71d7dd02cf 100644 --- a/src/osx/glcanvas_osx.cpp +++ b/src/osx/glcanvas_osx.cpp @@ -501,13 +501,8 @@ bool wxGLCanvas::Create(wxWindow *parent, // Make a copy of attributes. Will use at wxGLContext ctor m_GLAttrs = dispAttrs; -#if wxOSX_USE_IPHONE if ( !wxGLCanvas::DoCreate(parent,id,pos,size,style,name) ) return false; -#else - if ( !wxWindow::Create(parent, id, pos, size, style, name) ) - return false; -#endif return true; }