]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/mac/carbon/private.h
optimise startup of wxDataViewIndexListModel
[wxWidgets.git] / include / wx / mac / carbon / private.h
index fb5430f738804722c3372cda747e0cdbbff82351..53aaa10dc53e8271bd3a77c414f9ae8439e06062 100644 (file)
@@ -49,6 +49,7 @@
 
 #ifdef __WXMAC_CARBON__
 #include "wx/mac/corefoundation/cfstring.h"
+#include "wx/mac/corefoundation/cfdataref.h"
 #endif
 
 #ifndef FixedToInt
@@ -202,16 +203,16 @@ bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec);
 #endif // wxUSE_GUI
 
 // filefn.h
-WXDLLEXPORT wxString wxMacFSSpec2MacFilename( const FSSpec *spec );
-WXDLLEXPORT void wxMacFilename2FSSpec( const wxString &path , FSSpec *spec );
+WXDLLIMPEXP_BASE wxString wxMacFSSpec2MacFilename( const FSSpec *spec );
+WXDLLIMPEXP_BASE void wxMacFilename2FSSpec( const wxString &path , FSSpec *spec );
 
 // utils.h
-WXDLLEXPORT wxString wxMacFindFolderNoSeparator(short vRefNum,
-                                                OSType folderType,
-                                                Boolean createFolder);
-WXDLLEXPORT wxString wxMacFindFolder(short vRefNum,
-                                     OSType folderType,
-                                     Boolean createFolder);
+WXDLLIMPEXP_BASE wxString wxMacFindFolderNoSeparator(short vRefNum,
+                                                     OSType folderType,
+                                                     Boolean createFolder);
+WXDLLIMPEXP_BASE wxString wxMacFindFolder(short vRefNum,
+                                          OSType folderType,
+                                          Boolean createFolder);
 
 template<typename T> EventParamType wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ); return 0; }
 template<> inline EventParamType wxMacGetEventParamType<RgnHandle>() { return typeQDRgnHandle; }
@@ -370,7 +371,7 @@ protected :
 template <typename procType, typename uppType , uppType (*newUPP)(procType) , void (*disposeUPP)(uppType) > class wxMacUPP
 {
 public :
-    wxMacUPP( procType proc )
+    wxMacUPP( procType WXUNUSED(proc) )
     {
         m_upp = NULL;
         m_upp = (*newUPP)( NULL );
@@ -429,6 +430,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 +444,40 @@ 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
+#if TARGET_CARBON
+    wxMacCFStringHolder m_helpTextRef ;
+#endif
+} ;
+
 /*
 GWorldPtr         wxMacCreateGWorld( int width , int height , int depth );
 void                 wxMacDestroyGWorld( GWorldPtr gw );
@@ -448,6 +488,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))
@@ -824,8 +865,7 @@ class wxMacListControl
 {
 public:
     virtual void            MacDelete( unsigned int n ) = 0;
-    virtual void            MacInsert( unsigned int n, const wxString& item, int column = -1 ) = 0;
-    virtual void            MacInsert( unsigned int n, const wxArrayString& items, int column = -1 ) = 0;
+    virtual void            MacInsert( unsigned int n, const wxArrayStringsAdapter& items, int column = -1 ) = 0;
     // returns index of newly created line
     virtual int             MacAppend( const wxString& item ) = 0;
     virtual void            MacSetString( unsigned int n, const wxString& item ) = 0;
@@ -975,8 +1015,7 @@ public :
     // add and remove
 
     virtual void            MacDelete( unsigned int n );
-    virtual void            MacInsert( unsigned int n, const wxString& item, int column = -1 );
-    virtual void            MacInsert( unsigned int n, const wxArrayString& items, int column = -1 );
+    virtual void            MacInsert( unsigned int n, const wxArrayStringsAdapter& items, int column = -1 );
     virtual int             MacAppend( const wxString& item );
     virtual void            MacClear();
 
@@ -1087,6 +1126,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<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
@@ -1175,8 +1234,8 @@ void wxMacMemoryBufferReleaseProc(void *info, const void *data, size_t size);
 
 class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData
 {
-    friend class WXDLLEXPORT wxIcon;
-    friend class WXDLLEXPORT wxCursor;
+    friend class WXDLLIMPEXP_FWD_CORE wxIcon;
+    friend class WXDLLIMPEXP_FWD_CORE wxCursor;
 public:
     wxBitmapRefData(int width , int height , int depth);
     wxBitmapRefData();
@@ -1227,9 +1286,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();
@@ -1247,10 +1310,14 @@ private :
 #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
@@ -1278,6 +1345,16 @@ private :
 
 // toplevel.cpp
 
+class wxMacDeferredWindowDeleter : public wxObject
+{
+public :
+    wxMacDeferredWindowDeleter( WindowRef windowRef );
+    virtual ~wxMacDeferredWindowDeleter();
+
+protected :
+    WindowRef m_macWindow ;
+} ;
+
 ControlRef wxMacFindControlUnderMouse( wxTopLevelWindowMac* toplevelWindow, const Point& location , WindowRef window , ControlPartCode *outPart );
 
 #ifndef __LP64__
@@ -1315,14 +1392,14 @@ UPP Get##x()                                \
 void wxMacSetupConverters();
 void wxMacCleanupConverters();
 
-void wxMacStringToPascal( const wxString&from , StringPtr to );
-wxString wxMacMakeStringFromPascal( ConstStringPtr from );
+WXDLLIMPEXP_BASE void wxMacStringToPascal( const wxString&from , StringPtr to );
+WXDLLIMPEXP_BASE wxString wxMacMakeStringFromPascal( ConstStringPtr from );
 
 // filefn.cpp
 
-wxString wxMacFSRefToPath( const FSRef *fsRef , CFStringRef additionalPathComponent = NULL );
-OSStatus wxMacPathToFSRef( const wxString&path , FSRef *fsRef );
-wxString wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname );
+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 );
 
 #if wxUSE_GUI
 
@@ -1333,5 +1410,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_