diff --git a/include/wx/osx/carbon/private.h b/include/wx/osx/carbon/private.h index 59897c621a..fbe7ef5e13 100644 --- a/include/wx/osx/carbon/private.h +++ b/include/wx/osx/carbon/private.h @@ -14,10 +14,6 @@ #ifndef _WX_PRIVATE_H_ #define _WX_PRIVATE_H_ -#include "wx/osx/core/private.h" - -#include - #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 typedef UInt32 URefCon; typedef SInt32 SRefCon; @@ -942,16 +938,6 @@ UPP Get##x() \ return sHandler; \ } -//--------------------------------------------------------------------------- -// wxMac string conversions -//--------------------------------------------------------------------------- - -// filefn.cpp - -WXDLLIMPEXP_BASE wxString wxMacFSRefToPath( const FSRef *fsRef , CFStringRef additionalPathComponent = NULL ); -WXDLLIMPEXP_BASE OSStatus wxMacPathToFSRef( const wxString&path , FSRef *fsRef ); -WXDLLIMPEXP_BASE wxString wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname ); - //--------------------------------------------------------------------------- // cocoa bridging utilities //--------------------------------------------------------------------------- diff --git a/include/wx/osx/chkconf.h b/include/wx/osx/chkconf.h index 243b9899e7..70b39c1679 100644 --- a/include/wx/osx/chkconf.h +++ b/include/wx/osx/chkconf.h @@ -41,7 +41,8 @@ * to configure the build otherwise and give error messages */ -#if !wxUSE_GRAPHICS_CONTEXT || ( defined( wxMAC_USE_CORE_GRAPHICS ) && !wxMAC_USE_CORE_GRAPHICS ) +#if wxUSE_GUI && (!wxUSE_GRAPHICS_CONTEXT || \ + ( defined( wxMAC_USE_CORE_GRAPHICS ) && !wxMAC_USE_CORE_GRAPHICS )) # error "OS X builds use CoreGraphics in this wx version, you cannot turn back to QuickDraw completely" #endif diff --git a/include/wx/osx/cocoa/private.h b/include/wx/osx/cocoa/private.h index 5381ba3b07..6b6bef8e82 100644 --- a/include/wx/osx/cocoa/private.h +++ b/include/wx/osx/cocoa/private.h @@ -14,20 +14,8 @@ #ifndef _WX_PRIVATE_COCOA_H_ #define _WX_PRIVATE_COCOA_H_ -#include "wx/osx/core/private.h" - -#include "wx/defs.h" - #include -#if wxOSX_USE_ATSU_TEXT - // we need theming and atsu - #include -#else - // we only need theming, if we find a better include replace the following - #include -#endif - #ifdef __OBJC__ #import #endif @@ -53,22 +41,9 @@ OSStatus WXDLLIMPEXP_CORE wxMacDrawCGImage( CGImageRef inImage) ; WX_NSImage WXDLLIMPEXP_CORE wxOSXGetNSImageFromCGImage( CGImageRef image ); CGImageRef WXDLLIMPEXP_CORE wxOSXCreateCGImageFromNSImage( WX_NSImage nsimage ); -#endif - -long UMAGetSystemVersion() ; -WXDLLIMPEXP_BASE void wxMacStringToPascal( const wxString&from , StringPtr to ); -WXDLLIMPEXP_BASE wxString wxMacFSRefToPath( const FSRef *fsRef , CFStringRef additionalPathComponent = NULL ); -WXDLLIMPEXP_BASE OSStatus wxMacPathToFSRef( const wxString&path , FSRef *fsRef ); -WXDLLIMPEXP_BASE wxString wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname ); class WXDLLIMPEXP_FWD_CORE wxDialog; -// -// -// - -#if wxUSE_GUI - class WXDLLIMPEXP_CORE wxWidgetCocoaImpl : public wxWidgetImpl { public : diff --git a/include/wx/osx/core/private.h b/include/wx/osx/core/private.h index d423355b2e..0e0ff542ae 100644 --- a/include/wx/osx/core/private.h +++ b/include/wx/osx/core/private.h @@ -32,13 +32,21 @@ #define wxOSX_10_6_AND_LATER(x) #endif -#if wxOSX_USE_COCOA_OR_CARBON +#if !wxUSE_GUI || wxOSX_USE_COCOA_OR_CARBON + +// Carbon functions are currently still used in wxOSX/Cocoa too (including +// wxBase part of it). +#include WXDLLIMPEXP_BASE long UMAGetSystemVersion() ; void WXDLLIMPEXP_CORE wxMacStringToPascal( const wxString&from , unsigned char * to ); wxString WXDLLIMPEXP_CORE wxMacMakeStringFromPascal( const unsigned char * from ); +WXDLLIMPEXP_BASE wxString wxMacFSRefToPath( const FSRef *fsRef , CFStringRef additionalPathComponent = NULL ); +WXDLLIMPEXP_BASE OSStatus wxMacPathToFSRef( const wxString&path , FSRef *fsRef ); +WXDLLIMPEXP_BASE wxString wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname ); + #endif #if wxUSE_GUI diff --git a/include/wx/osx/iphone/private.h b/include/wx/osx/iphone/private.h index 250ff2512f..fd9c022af2 100644 --- a/include/wx/osx/iphone/private.h +++ b/include/wx/osx/iphone/private.h @@ -14,8 +14,6 @@ #ifndef _WX_PRIVATE_IPHONE_H_ #define _WX_PRIVATE_IPHONE_H_ -#include "wx/osx/core/private.h" - #ifdef __OBJC__ #import #endif diff --git a/include/wx/osx/private.h b/include/wx/osx/private.h index a309aea5ac..5b33475f99 100644 --- a/include/wx/osx/private.h +++ b/include/wx/osx/private.h @@ -1,18 +1,16 @@ -/* common warning snippet for all osx direct includes */ - -#ifndef wxOSX_USE_CARBON -#error "this files should only be included after platform.h was included" -#endif - #ifndef _WX_PRIVATE_OSX_H_ #define _WX_PRIVATE_OSX_H_ +#include "wx/osx/core/private.h" + #if wxOSX_USE_IPHONE #include "wx/osx/iphone/private.h" #elif wxOSX_USE_CARBON #include "wx/osx/carbon/private.h" #elif wxOSX_USE_COCOA #include "wx/osx/cocoa/private.h" +#elif wxUSE_GUI + #error "Must include wx/defs.h first" #endif #endif diff --git a/include/wx/platform.h b/include/wx/platform.h index 21c605a99f..e4197527ed 100644 --- a/include/wx/platform.h +++ b/include/wx/platform.h @@ -27,95 +27,13 @@ # endif #endif -/* - WXOSX targets - __WXOSX_MAC__ means Mac OS X, non embedded - __WXOSX_IPHONE__ means OS X iPhone -*/ - -/* - Normally all of __WXOSX_XXX__, __WXOSX__ and __WXMAC__ are defined by - configure but ensure that we also define them if configure was not used for - whatever reason. - - The primare symbol remains __WXOSX_XXX__ one, __WXOSX__ exists to allow - checking for any OS X port (Carbon and Cocoa) and __WXMAC__ is an old name - for it. - */ -#if defined(__WXOSX_CARBON__) || defined(__WXOSX_COCOA__) || defined(__WXOSX_IPHONE__) -# ifndef __WXOSX__ -# define __WXOSX__ 1 -# endif -# ifndef __WXMAC__ -# define __WXMAC__ 1 -# endif +#ifdef __WXMAC_XCODE__ +# include +# include +# include +# include "wx/osx/config_xcode.h" #endif -#ifdef __WXOSX__ -/* setup precise defines according to sdk used */ -# include -# if defined(__WXOSX_IPHONE__) -# if !( defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE ) -# error "incorrect SDK for an iPhone build" -# endif -# elif defined(__WXOSX_CARBON__) || defined(__WXOSX_COCOA__) -# if !( defined(TARGET_OS_MAC) && TARGET_OS_MAC ) -# error "incorrect SDK for a Mac OS X build" -# endif -# define __WXOSX_MAC__ 1 -# else -# error "one of __WXOSX_IPHONE__, __WXOSX_CARBON__ or __WXOSX_COCOA__ must be defined" -# endif -#endif - -#ifdef __WXOSX_MAC__ -# if defined(__MACH__) -# include -# ifndef MAC_OS_X_VERSION_10_4 -# define MAC_OS_X_VERSION_10_4 1040 -# endif -# ifndef MAC_OS_X_VERSION_10_5 -# define MAC_OS_X_VERSION_10_5 1050 -# endif -# ifndef MAC_OS_X_VERSION_10_6 -# define MAC_OS_X_VERSION_10_6 1060 -# endif -# else -# error "only mach-o configurations are supported" -# endif -#endif - -/* - __WXOSX_OR_COCOA__ is a common define to wxOSX (Carbon or Cocoa) and wxCocoa ports under OS X. - - DO NOT use this define in base library code. Although wxMac has its own - private base library (and thus __WXOSX_OR_COCOA__,__WXMAC__ and related defines are - valid there), wxCocoa shares its library with other ports like wxGTK and wxX11. - - To keep wx authors from screwing this up, only enable __WXOSX_OR_COCOA__ for wxCocoa when - not compiling the base library. We determine this by first checking if - wxUSE_BASE is not defined. If it is not defined, then we're not buildling - the base library, and possibly not building wx at all (but actually building - user code that's using wx). If it is defined then we must check to make sure - it is not true. If it is true, we're building base. - - If you want it in the common darwin base library then use __DARWIN__. You - can use any Darwin-available libraries like CoreFoundation but please avoid - using OS X libraries like Carbon or CoreServices. - - */ -#if defined(__WXOSX__) || (defined(__WXCOCOA__) && (!defined(wxUSE_BASE) || !wxUSE_BASE)) -# define __WXOSX_OR_COCOA__ 1 -#endif - -#ifdef __WXOSX_OR_COCOA__ -# ifdef __WXMAC_XCODE__ -# include -# include -# include -# include "wx/osx/config_xcode.h" -# endif -#endif /* first define Windows symbols if they're not defined on the command line: we can autodetect everything we need if _WIN32 is defined @@ -725,6 +643,91 @@ # define SIZEOF_SIZE_T 4 # endif #endif + +/* + Define various OS X symbols before including wx/chkconf.h which uses them. + + __WXOSX_MAC__ means Mac OS X, non embedded + __WXOSX_IPHONE__ means OS X iPhone + */ + +/* + Normally all of __WXOSX_XXX__, __WXOSX__ and __WXMAC__ are defined by + configure but ensure that we also define them if configure was not used for + whatever reason. + + The primary symbol remains __WXOSX_XXX__ one, __WXOSX__ exists to allow + checking for any OS X port (Carbon and Cocoa) and __WXMAC__ is an old name + for it. + */ +#if defined(__WXOSX_CARBON__) || defined(__WXOSX_COCOA__) || defined(__WXOSX_IPHONE__) \ + || (defined(__DARWIN__) && !wxUSE_GUI) +# ifndef __WXOSX__ +# define __WXOSX__ 1 +# endif +# ifndef __WXMAC__ +# define __WXMAC__ 1 +# endif +#endif + +#ifdef __WXOSX__ +/* setup precise defines according to sdk used */ +# include +# if defined(__WXOSX_IPHONE__) +# if !( defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE ) +# error "incorrect SDK for an iPhone build" +# endif +# else +# if wxUSE_GUI && !(defined(__WXOSX_CARBON__) || defined(__WXOSX_COCOA__)) +# error "one of __WXOSX_IPHONE__, __WXOSX_CARBON__ or __WXOSX_COCOA__ must be defined for the GUI build" +# endif +# if !( defined(TARGET_OS_MAC) && TARGET_OS_MAC ) +# error "incorrect SDK for a Mac OS X build" +# endif +# define __WXOSX_MAC__ 1 +# endif +#endif + +#ifdef __WXOSX_MAC__ +# if defined(__MACH__) +# include +# ifndef MAC_OS_X_VERSION_10_4 +# define MAC_OS_X_VERSION_10_4 1040 +# endif +# ifndef MAC_OS_X_VERSION_10_5 +# define MAC_OS_X_VERSION_10_5 1050 +# endif +# ifndef MAC_OS_X_VERSION_10_6 +# define MAC_OS_X_VERSION_10_6 1060 +# endif +# else +# error "only mach-o configurations are supported" +# endif +#endif + +/* + __WXOSX_OR_COCOA__ is a common define to wxOSX (Carbon or Cocoa) and wxCocoa ports under OS X. + + DO NOT use this define in base library code. Although wxMac has its own + private base library (and thus __WXOSX_OR_COCOA__,__WXMAC__ and related defines are + valid there), wxCocoa shares its library with other ports like wxGTK and wxX11. + + To keep wx authors from screwing this up, only enable __WXOSX_OR_COCOA__ for wxCocoa when + not compiling the base library. We determine this by first checking if + wxUSE_BASE is not defined. If it is not defined, then we're not buildling + the base library, and possibly not building wx at all (but actually building + user code that's using wx). If it is defined then we must check to make sure + it is not true. If it is true, we're building base. + + If you want it in the common darwin base library then use __DARWIN__. You + can use any Darwin-available libraries like CoreFoundation but please avoid + using OS X libraries like Carbon or CoreServices. + + */ +#if defined(__WXOSX__) || (defined(__WXCOCOA__) && (!defined(wxUSE_BASE) || !wxUSE_BASE)) +# define __WXOSX_OR_COCOA__ 1 +#endif + /* check the consistency of the settings in setup.h: note that this must be done after setting wxUSE_UNICODE correctly as it is used in wx/chkconf.h @@ -815,15 +818,6 @@ # define wxUSE_WXDIB 1 #endif -/* - We need AvailabilityMacros.h for ifdefing out things that don't exist on - OSX 10.2 and lower - FIXME: We need a better way to detect for 10.3 then including a system header -*/ -#ifdef __DARWIN__ - #include -#endif - #if defined (__WXPALMOS__) #include "wx/palmos/missing.h" #endif // __WXPALMOS__ diff --git a/src/osx/core/utilsexc_base.cpp b/src/osx/core/utilsexc_base.cpp index 7c5c828048..c9380d7195 100644 --- a/src/osx/core/utilsexc_base.cpp +++ b/src/osx/core/utilsexc_base.cpp @@ -60,7 +60,7 @@ extern bool WXDLLEXPORT wxIsDebuggerRunning() return false; } -#if wxOSX_USE_COCOA_OR_CARBON +#if !wxUSE_GUI || wxOSX_USE_COCOA_OR_CARBON // have a fast version for mac code that returns the version as a return value