#include "wx/defs.h"
-#ifdef __DARWIN__
-# include <Carbon/Carbon.h>
-#else
-# include <Debugging.h>
-# include <Quickdraw.h>
-# include <Appearance.h>
-# include <Folders.h>
-# include <Controls.h>
-# include <ControlDefinitions.h>
-# include <LowMem.h>
-# include <Gestalt.h>
-# include <FixMath.h>
-# include <CoreServices.h>
-#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 <Carbon/Carbon.h>
-#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;
template<> inline EventParamType wxMacGetEventParamType<SInt32>() { return typeSInt32; }
template<> inline EventParamType wxMacGetEventParamType<UInt32>() { return typeUInt32; }
template<> inline EventParamType wxMacGetEventParamType<RGBColor>() { return typeRGBColor; }
-#if TARGET_API_MAC_OSX
template<> inline EventParamType wxMacGetEventParamType<HICommand>() { return typeHICommand; }
template<> inline EventParamType wxMacGetEventParamType<HIPoint>() { return typeHIPoint; }
template<> inline EventParamType wxMacGetEventParamType<HISize>() { return typeHISize; }
template<> inline EventParamType wxMacGetEventParamType<HIRect>() { return typeHIRect; }
template<> inline EventParamType wxMacGetEventParamType<void*>() { return typeVoidPtr; }
-#endif
-#if TARGET_API_MAC_OSX && ( MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2 )
template<> inline EventParamType wxMacGetEventParamType<CFDictionaryRef>() { return typeCFDictionaryRef; }
-#endif
template<> inline EventParamType wxMacGetEventParamType<Collection>() { return typeCollection; }
template<> inline EventParamType wxMacGetEventParamType<CGContextRef>() { return typeCGContextRef; }
/*
operator refType () const { return m_ref; }
+ wxMacCFRefHolder& operator=(refType r)
+ {
+ Set( r );
+ return *this;
+ }
private :
refType m_ref;
bool m_release;
#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 );
*/
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))
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();
// 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
// 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<CGColorRef> m_color;
+ wxMacCFRefHolder<CGColorSpaceRef> m_colorSpace;
+
+ bool m_isPattern;
+ wxMacCFRefHolder<CGPatternRef> m_pattern;
+ CGFloat* m_patternColorComponents;
+} ;
+
#if wxMAC_USE_CORE_GRAPHICS && !wxUSE_GRAPHICS_CONTEXT
class WXDLLEXPORT wxMacCGPath : public wxGraphicPath
#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;
#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
// 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();
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
// 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__
#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_