X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/899544330f37440c140b72a014c518a911b5b7a4..0d6fba37931bde89e7161ff173e2f818e4b15ac0:/include/wx/mac/carbon/private.h diff --git a/include/wx/mac/carbon/private.h b/include/wx/mac/carbon/private.h index 65216bbcfb..19d4470e57 100644 --- a/include/wx/mac/carbon/private.h +++ b/include/wx/mac/carbon/private.h @@ -16,53 +16,10 @@ #include "wx/defs.h" -#ifdef __DARWIN__ -# include -#else -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -#endif - -#if UNIVERSAL_INTERFACES_VERSION < 0x0342 - #error "please update to Apple's latest universal headers from http://developer.apple.com/sdk/" -#endif - -#ifndef MAC_OS_X_VERSION_10_3 - #define MAC_OS_X_VERSION_10_3 1030 -#endif +#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 - -#ifdef __WXMAC_CARBON__ #include "wx/mac/corefoundation/cfstring.h" -#endif - -#ifndef FixedToInt -// as macro in FixMath.h for 10.3 -inline Fixed IntToFixed( int inInt ) -{ - return (((SInt32) inInt) << 16); -} - -inline int FixedToInt( Fixed inFixed ) -{ - return (((SInt32) inFixed) >> 16); -} -#endif +#include "wx/mac/corefoundation/cfdataref.h" #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 typedef UInt32 URefCon; @@ -226,16 +183,12 @@ template<> inline EventParamType wxMacGetEventParamType() { return typeS template<> inline EventParamType wxMacGetEventParamType() { return typeSInt32; } template<> inline EventParamType wxMacGetEventParamType() { return typeUInt32; } template<> inline EventParamType wxMacGetEventParamType() { return typeRGBColor; } -#if TARGET_API_MAC_OSX template<> inline EventParamType wxMacGetEventParamType() { return typeHICommand; } template<> inline EventParamType wxMacGetEventParamType() { return typeHIPoint; } template<> inline EventParamType wxMacGetEventParamType() { return typeHISize; } template<> inline EventParamType wxMacGetEventParamType() { return typeHIRect; } template<> inline EventParamType wxMacGetEventParamType() { return typeVoidPtr; } -#endif -#if TARGET_API_MAC_OSX && ( MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2 ) template<> inline EventParamType wxMacGetEventParamType() { return typeCFDictionaryRef; } -#endif template<> inline EventParamType wxMacGetEventParamType() { return typeCollection; } template<> inline EventParamType wxMacGetEventParamType() { return typeCGContextRef; } /* @@ -429,6 +382,11 @@ public : operator refType () const { return m_ref; } + wxMacCFRefHolder& operator=(refType r) + { + Set( r ); + return *this; + } private : refType m_ref; bool m_release; @@ -438,6 +396,38 @@ private : #if wxUSE_GUI +class wxMacToolTipTimer ; + +class wxMacToolTip +{ +public : + wxMacToolTip() ; + ~wxMacToolTip() ; + + void Setup( WindowRef window , const wxString& text , const wxPoint& localPosition ) ; + void Draw() ; + void Clear() ; + + long GetMark() + { return m_mark ; } + + bool IsShown() + { return m_shown ; } + +private : + wxString m_label ; + wxPoint m_position ; + Rect m_rect ; + WindowRef m_window ; + PicHandle m_backpict ; + bool m_shown ; + long m_mark ; +#if wxUSE_TIMER + wxMacToolTipTimer* m_timer ; +#endif + wxMacCFStringHolder m_helpTextRef ; +} ; + /* GWorldPtr wxMacCreateGWorld( int width , int height , int depth ); void wxMacDestroyGWorld( GWorldPtr gw ); @@ -448,6 +438,7 @@ CTabHandle wxMacCreateColorTable( int numColors ); */ void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType = 0 ); void wxMacReleaseBitmapButton( ControlButtonContentInfo*info ); +CGImageRef wxMacCreateCGImageFromBitmap( const wxBitmap& bitmap ); #define MAC_WXCOLORREF(a) (*((RGBColor*)&(a))) #define MAC_WXHBITMAP(a) (GWorldPtr(a)) @@ -473,17 +464,17 @@ void wxMacNativeToRect( const Rect *n , wxRect* wx ); void wxMacPointToNative( const wxPoint* wx , Point *n ); void wxMacNativeToPoint( const Point *n , wxPoint* wx ); -wxWindow * wxFindControlFromMacControl(ControlRef inControl ); -wxTopLevelWindowMac* wxFindWinFromMacWindow( WindowRef inWindow ); -wxMenu* wxFindMenuFromMacMenu(MenuRef inMenuRef); +WXDLLIMPEXP_CORE wxWindow * wxFindControlFromMacControl(ControlRef inControl ); +WXDLLIMPEXP_CORE wxTopLevelWindowMac* wxFindWinFromMacWindow( WindowRef inWindow ); +WXDLLIMPEXP_CORE wxMenu* wxFindMenuFromMacMenu(MenuRef inMenuRef); -int wxMacCommandToId( UInt32 macCommandId ); -UInt32 wxIdToMacCommand( int wxId ); -wxMenu* wxFindMenuFromMacCommand( const HICommand &macCommandId , wxMenuItem* &item ); +WXDLLIMPEXP_CORE int wxMacCommandToId( UInt32 macCommandId ); +WXDLLIMPEXP_CORE UInt32 wxIdToMacCommand( int wxId ); +WXDLLIMPEXP_CORE wxMenu* wxFindMenuFromMacCommand( const HICommand &macCommandId , wxMenuItem* &item ); extern wxWindow* g_MacLastWindow; -pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data ); -Rect wxMacGetBoundsForControl( wxWindow* window , const wxPoint& pos , const wxSize &size , bool adjustForOrigin = true ); +WXDLLIMPEXP_CORE pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data ); +WXDLLIMPEXP_CORE Rect wxMacGetBoundsForControl( wxWindow* window , const wxPoint& pos , const wxSize &size , bool adjustForOrigin = true ); ControlActionUPP GetwxMacLiveScrollbarActionProc(); @@ -613,9 +604,8 @@ public : // invalidates this control and all children virtual void InvalidateWithChildren(); virtual void SetDrawingEnabled( bool enable ); -#ifdef __WXMAC_OSX__ virtual bool GetNeedsDisplay() const; -#endif + // where is in native window relative coordinates virtual void SetNeedsDisplay( RgnHandle where ); // where is in native window relative coordinates @@ -1085,6 +1075,26 @@ public: // graphics implementation // ============================================================================ +// make sure we all use one class for all conversions from wx to native colour + +class wxMacCoreGraphicsColour +{ +public: + wxMacCoreGraphicsColour(); + wxMacCoreGraphicsColour(const wxBrush &brush); + ~wxMacCoreGraphicsColour(); + + void Apply( CGContextRef cgContext ); +protected: + void Init(); + wxMacCFRefHolder m_color; + wxMacCFRefHolder m_colorSpace; + + bool m_isPattern; + wxMacCFRefHolder m_pattern; + CGFloat* m_patternColorComponents; +} ; + #if wxMAC_USE_CORE_GRAPHICS && !wxUSE_GRAPHICS_CONTEXT class WXDLLEXPORT wxMacCGPath : public wxGraphicPath @@ -1164,13 +1174,9 @@ private: #endif // wxMAC_USE_CORE_GRAPHICS -#ifdef __WXMAC_OSX__ - CGColorSpaceRef wxMacGetGenericRGBColorSpace(void); void wxMacMemoryBufferReleaseProc(void *info, const void *data, size_t size); -#endif - class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData { friend class WXDLLIMPEXP_FWD_CORE wxIcon; @@ -1208,9 +1214,7 @@ public: #endif // wxUSE_PALETTE wxMask * m_bitmapMask; // Optional mask -#ifdef __WXMAC_OSX__ CGImageRef CGImageCreate() const; -#endif // returns true if the bitmap has a size that // can be natively transferred into a true icon @@ -1225,9 +1229,13 @@ public: // returns a Pict from the bitmap content PicHandle GetPictHandle(); +#if wxMAC_USE_CORE_GRAPHICS + CGContextRef GetBitmapContext() const; +#else GWorldPtr GetHBITMAP(GWorldPtr * mask = NULL ) const; void UpdateAlphaMask() const; - +#endif + int GetBytesPerRow() const { return m_bytesPerRow; } private : bool Create(int width , int height , int depth); void Init(); @@ -1240,15 +1248,18 @@ private : wxMemoryBuffer m_memBuf; int m_rawAccessCount; bool m_ok; -#ifdef __WXMAC_OSX__ mutable CGImageRef m_cgImageRef; -#endif + IconRef m_iconRef; PicHandle m_pictHandle; +#if wxMAC_USE_CORE_GRAPHICS + CGContextRef m_hBitmap; +#else GWorldPtr m_hBitmap; GWorldPtr m_hMaskBitmap; wxMemoryBuffer m_maskMemBuf; int m_maskBytesPerRow; +#endif }; class WXDLLEXPORT wxIconRefData : public wxGDIRefData @@ -1276,7 +1287,15 @@ private : // toplevel.cpp -ControlRef wxMacFindControlUnderMouse( wxTopLevelWindowMac* toplevelWindow, const Point& location , WindowRef window , ControlPartCode *outPart ); +class wxMacDeferredWindowDeleter : public wxObject +{ +public : + wxMacDeferredWindowDeleter( WindowRef windowRef ); + virtual ~wxMacDeferredWindowDeleter(); + +protected : + WindowRef m_macWindow ; +} ; #ifndef __LP64__ @@ -1331,5 +1350,78 @@ void wxMacGlobalToLocal( WindowRef window , Point*pt ); #endif +//--------------------------------------------------------------------------- +// cocoa bridging utilities +//--------------------------------------------------------------------------- + +bool wxMacInitCocoa(); + +class wxMacAutoreleasePool +{ +public : + wxMacAutoreleasePool(); + ~wxMacAutoreleasePool(); +private : + void* m_pool; +}; + +// NSObject + +void wxMacCocoaRelease( void* obj ); +void wxMacCocoaAutorelease( void* obj ); +void wxMacCocoaRetain( void* obj ); + +#if wxMAC_USE_COCOA + +// NSCursor + +WX_NSCursor wxMacCocoaCreateStockCursor( int cursor_type ); +WX_NSCursor wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef, float hotSpotX, float hotSpotY ); +void wxMacCocoaSetCursor( WX_NSCursor cursor ); +void wxMacCocoaHideCursor(); +void wxMacCocoaShowCursor(); + +typedef struct tagClassicCursor +{ + wxUint16 bits[16]; + wxUint16 mask[16]; + wxInt16 hotspot[2]; +}ClassicCursor; + +#else // !wxMAC_USE_COCOA + +// non Darwin + +typedef Cursor ClassicCursor; + +#endif // wxMAC_USE_COCOA + +// ------------- +// Common to all +// ------------- + +// Cursor support + +const short kwxCursorBullseye = 0; +const short kwxCursorBlank = 1; +const short kwxCursorPencil = 2; +const short kwxCursorMagnifier = 3; +const short kwxCursorNoEntry = 4; +const short kwxCursorPaintBrush = 5; +const short kwxCursorPointRight = 6; +const short kwxCursorPointLeft = 7; +const short kwxCursorQuestionArrow = 8; +const short kwxCursorRightArrow = 9; +const short kwxCursorSizeNS = 10; +const short kwxCursorSize = 11; +const short kwxCursorSizeNESW = 12; +const short kwxCursorSizeNWSE = 13; +const short kwxCursorRoller = 14; +const short kwxCursorLast = kwxCursorRoller; + +// exposing our fallback cursor map + +extern ClassicCursor gMacCursors[]; + #endif // _WX_PRIVATE_H_