From ebf2a1eccf40660111f35746acd1509b7bb11b70 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Fri, 9 Nov 2007 20:35:17 +0000 Subject: [PATCH] forward port from 2.8 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49784 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/mac/carbon/app.h | 1 + include/wx/mac/carbon/chkconf.h | 8 ++ include/wx/mac/carbon/dataform.h | 5 + include/wx/mac/carbon/dataobj.h | 6 ++ include/wx/mac/carbon/font.h | 12 ++- include/wx/mac/carbon/menu.h | 3 + include/wx/mac/carbon/menuitem.h | 2 + include/wx/mac/carbon/metafile.h | 4 + include/wx/mac/carbon/popupwin.h | 8 ++ include/wx/mac/carbon/private.h | 154 ++++++++++++++++++++++++++++++- include/wx/mac/carbon/radiobox.h | 12 +-- include/wx/mac/carbon/textctrl.h | 3 + include/wx/mac/carbon/uma.h | 7 +- include/wx/mac/carbon/window.h | 5 +- 14 files changed, 213 insertions(+), 17 deletions(-) diff --git a/include/wx/mac/carbon/app.h b/include/wx/mac/carbon/app.h index 00d42f2ad8..323ba1f98b 100644 --- a/include/wx/mac/carbon/app.h +++ b/include/wx/mac/carbon/app.h @@ -78,6 +78,7 @@ public: // adding a CFType object to be released only at the end of the current event cycle (increases the // refcount of the object passed), needed in case we are in the middle of an event concering an object // we want to delete and cannot do it immediately + // TODO change semantics to be in line with cocoa (make autrelease NOT increase the count) void MacAddToAutorelease( void* cfrefobj ); public: static wxWindow* s_captureWindow ; diff --git a/include/wx/mac/carbon/chkconf.h b/include/wx/mac/carbon/chkconf.h index ec1bfa37ff..25ab6194ee 100644 --- a/include/wx/mac/carbon/chkconf.h +++ b/include/wx/mac/carbon/chkconf.h @@ -58,6 +58,14 @@ #define wxMAC_USE_NATIVE_TOOLBAR 1 #endif +/* + * using mixins of cocoa functionality + */ + +#ifndef wxMAC_USE_COCOA + #define wxMAC_USE_COCOA 0 +#endif + #endif /* _WX_MAC_CHKCONF_H_ */ diff --git a/include/wx/mac/carbon/dataform.h b/include/wx/mac/carbon/dataform.h index 7fa7cb6e0c..96a108c335 100644 --- a/include/wx/mac/carbon/dataform.h +++ b/include/wx/mac/carbon/dataform.h @@ -19,8 +19,11 @@ public: wxDataFormat(); wxDataFormat(wxDataFormatId vType); + wxDataFormat(const wxDataFormat& rFormat); wxDataFormat(const wxString& rId); + wxDataFormat(const wxChar* pId); wxDataFormat(NativeFormat vFormat); + ~wxDataFormat(); wxDataFormat& operator=(NativeFormat vFormat) { SetId(vFormat); return *this; } @@ -34,6 +37,8 @@ public: bool operator!=(wxDataFormatId format) const { return m_type != (wxDataFormatId)format; } + wxDataFormat& operator=(const wxDataFormat& format); + // explicit and implicit conversions to NativeFormat which is one of // standard data types (implicit conversion is useful for preserving the // compatibility with old code) diff --git a/include/wx/mac/carbon/dataobj.h b/include/wx/mac/carbon/dataobj.h index fa1aa17600..e5c0fda881 100644 --- a/include/wx/mac/carbon/dataobj.h +++ b/include/wx/mac/carbon/dataobj.h @@ -25,6 +25,12 @@ public: #endif virtual bool IsSupportedFormat( const wxDataFormat& format, Direction dir = Get ) const; + void AddToPasteboard( void * pasteboardRef , int itemID ); + // returns true if the passed in format is present in the pasteboard + static bool IsFormatInPasteboard( void * pasteboardRef, const wxDataFormat &dataFormat ); + // returns true if any of the accepted formats of this dataobj is in the pasteboard + bool HasDataInPasteboard( void * pasteboardRef ); + bool GetFromPasteboard( void * pasteboardRef ); }; #endif // _WX_MAC_DATAOBJ_H_ diff --git a/include/wx/mac/carbon/font.h b/include/wx/mac/carbon/font.h index 2113b75709..9fc1171abb 100644 --- a/include/wx/mac/carbon/font.h +++ b/include/wx/mac/carbon/font.h @@ -51,6 +51,9 @@ public: bool Create(const wxNativeFontInfo& info); bool MacCreateThemeFont( wxUint16 themeFontID ) ; +#ifdef __LP64__ + bool MacCreateUIFont( wxUint32 coreTextFontType ); +#endif virtual ~wxFont(); @@ -84,19 +87,24 @@ public: // Mac-specific, risks to change, don't use in portable code +#ifndef __LP64__ // 'old' Quickdraw accessors - short MacGetFontNum() const; short MacGetFontSize() const; wxByte MacGetFontStyle() const; // 'new' ATSUI accessors - wxUint32 MacGetATSUFontID() const; wxUint32 MacGetATSUAdditionalQDStyles() const; wxUint16 MacGetThemeFontID() const ; + // Returns an ATSUStyle not ATSUStyle* void* MacGetATSUStyle() const ; +#else + const void * MacGetCTFont() const; + // soon to be removed for 64bit, Returns an ATSUStyle not ATSUStyle* + void* MacGetATSUStyle() const ; +#endif private: void Unshare(); diff --git a/include/wx/mac/carbon/menu.h b/include/wx/mac/carbon/menu.h index 634ee2fe87..1b78b37649 100644 --- a/include/wx/mac/carbon/menu.h +++ b/include/wx/mac/carbon/menu.h @@ -61,6 +61,9 @@ public: short MacGetMenuId() { return m_macMenuId ; } + wxInt32 MacHandleCommandProcess( wxMenuItem* item, int id, wxWindow* targetWindow = NULL ); + wxInt32 MacHandleCommandUpdateStatus( wxMenuItem* item, int id, wxWindow* targetWindow = NULL); + protected: virtual wxMenuItem* DoAppend(wxMenuItem *item); virtual wxMenuItem* DoInsert(size_t pos, wxMenuItem *item); diff --git a/include/wx/mac/carbon/menuitem.h b/include/wx/mac/carbon/menuitem.h index a5b087cb5a..4be07df17b 100644 --- a/include/wx/mac/carbon/menuitem.h +++ b/include/wx/mac/carbon/menuitem.h @@ -54,6 +54,8 @@ public: void SetRadioGroupEnd(int end); private: + void DoUpdateItemBitmap( WXHMENU menu, wxUint16 index) ; + void UncheckRadio() ; // the positions of the first and last items of the radio group this item diff --git a/include/wx/mac/carbon/metafile.h b/include/wx/mac/carbon/metafile.h index d6f7fe2cb7..d005640506 100644 --- a/include/wx/mac/carbon/metafile.h +++ b/include/wx/mac/carbon/metafile.h @@ -57,6 +57,10 @@ public: // Implementation WXHMETAFILE GetHMETAFILE() const ; void SetHMETAFILE(WXHMETAFILE mf) ; + // Since the native metafile format is PDF for Quartz + // we need a call that allows setting PICT content for + // backwards compatibility + void SetPICT(void* pictHandle) ; }; class WXDLLEXPORT wxMetafileDC: public wxDC diff --git a/include/wx/mac/carbon/popupwin.h b/include/wx/mac/carbon/popupwin.h index b3ec56577d..c1590abc73 100644 --- a/include/wx/mac/carbon/popupwin.h +++ b/include/wx/mac/carbon/popupwin.h @@ -20,6 +20,7 @@ class WXDLLEXPORT wxPopupWindow : public wxPopupWindowBase { public: wxPopupWindow() { } + ~wxPopupWindow(); wxPopupWindow(wxWindow *parent, int flags = wxBORDER_NONE) { (void)Create(parent, flags); } @@ -28,9 +29,16 @@ public: virtual bool Show(bool show = true); + WXWindow MacGetPopupWindowRef() const ; + protected: // popups handle the position like wxTopLevelWindow, not wxWindow virtual void DoGetPosition(int *x, int *y) const; + virtual void DoMoveWindow(int x, int y, int width, int height); + virtual void DoGetSize( int *width, int *height ) const; + virtual void DoGetClientSize( int *width, int *height ) const; + + WXWindow m_popupWindowRef ; DECLARE_DYNAMIC_CLASS_NO_COPY(wxPopupWindow) }; diff --git a/include/wx/mac/carbon/private.h b/include/wx/mac/carbon/private.h index 65216bbcfb..53aaa10dc5 100644 --- a/include/wx/mac/carbon/private.h +++ b/include/wx/mac/carbon/private.h @@ -49,6 +49,7 @@ #ifdef __WXMAC_CARBON__ #include "wx/mac/corefoundation/cfstring.h" +#include "wx/mac/corefoundation/cfdataref.h" #endif #ifndef FixedToInt @@ -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)) @@ -1085,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 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 @@ -1225,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(); @@ -1245,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 @@ -1276,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__ @@ -1331,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_ diff --git a/include/wx/mac/carbon/radiobox.h b/include/wx/mac/carbon/radiobox.h index 177d4a17c8..c7e6e4bd0e 100644 --- a/include/wx/mac/carbon/radiobox.h +++ b/include/wx/mac/carbon/radiobox.h @@ -57,20 +57,12 @@ public: // Enabling virtual bool Enable(bool enable = true); virtual bool Enable(unsigned int item, bool enable = true); - virtual bool IsItemEnabled(unsigned int WXUNUSED(n)) const - { - /* TODO */ - return true; - } + virtual bool IsItemEnabled(unsigned int item) const; // Showing virtual bool Show(bool show = true); virtual bool Show(unsigned int item, bool show = true); - virtual bool IsItemShown(unsigned int WXUNUSED(n)) const - { - /* TODO */ - return true; - } + virtual bool IsItemShown(unsigned int item) const; // Specific functions (in wxWidgets2 reference) virtual void SetSelection(int item); diff --git a/include/wx/mac/carbon/textctrl.h b/include/wx/mac/carbon/textctrl.h index 0c0bb75464..39cf86c3dc 100644 --- a/include/wx/mac/carbon/textctrl.h +++ b/include/wx/mac/carbon/textctrl.h @@ -18,6 +18,9 @@ // has more features (backgrounds etc.), but may show redraw artefacts and other // problems depending on your usage; hence, the default is 'false'. #define wxMAC_TEXTCONTROL_USE_MLTE wxT("mac.textcontrol-use-mlte") + // set this to 'true' if you want editable text controls to have spell checking turned + // on by default, you can change this setting individually on a control using MacCheckSpelling + #define wxMAC_TEXTCONTROL_USE_SPELL_CHECKER wxT("mac.textcontrol-use-spell-checker") #endif #include "wx/control.h" diff --git a/include/wx/mac/carbon/uma.h b/include/wx/mac/carbon/uma.h index 23bb3d31ce..641b26eb14 100644 --- a/include/wx/mac/carbon/uma.h +++ b/include/wx/mac/carbon/uma.h @@ -109,11 +109,12 @@ OSStatus UMAGetHelpMenuDontCreate( OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState ) ; -// Clipboard support +#define GetWindowUpdateRgn( inWindow , updateRgn ) GetWindowRegion( inWindow , kWindowUpdateRgn, updateRgn ) -OSStatus UMAPutScrap( Size size , OSType type , void *data ) ; +// Quartz -#define GetWindowUpdateRgn( inWindow , updateRgn ) GetWindowRegion( inWindow , kWindowUpdateRgn, updateRgn ) +CGDataProviderRef UMACGDataProviderCreateWithCFData( CFDataRef data ); +CGDataConsumerRef UMACGDataConsumerCreateWithCFData( CFMutableDataRef data ); #endif // wxUSE_GUI diff --git a/include/wx/mac/carbon/window.h b/include/wx/mac/carbon/window.h index 53b40f6f5f..2ea9b49990 100644 --- a/include/wx/mac/carbon/window.h +++ b/include/wx/mac/carbon/window.h @@ -145,7 +145,7 @@ public: void MacOnScroll( wxScrollEvent&event ); - bool AcceptsFocus() const; + virtual bool AcceptsFocus() const; virtual bool IsDoubleBuffered() const { return true; } @@ -170,6 +170,7 @@ public: // because it is called from its destructor via DeleteChildren virtual void RemoveChild( wxWindowBase *child ); virtual void MacPaintBorders( int left , int top ) ; + void MacPaintGrowBox(); // invalidates the borders and focus area around the control; // must not be virtual as it will be called during destruction @@ -321,11 +322,13 @@ protected: virtual bool MacIsChildOfClientArea( const wxWindow* child ) const ; + bool MacHasScrollBarCorner() const; void MacCreateScrollBars( long style ) ; void MacRepositionScrollBars() ; void MacUpdateControlFont() ; void MacPropagateVisibilityChanged() ; + void MacPropagateEnabledStateChanged() ; void MacPropagateHiliteChanged() ; // implement the base class pure virtuals -- 2.45.2