forward port from 2.8

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49784 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2007-11-09 20:35:17 +00:00
parent fd87345120
commit ebf2a1eccf
14 changed files with 214 additions and 18 deletions

View File

@@ -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 ;

View File

@@ -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_ */

View File

@@ -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)

View File

@@ -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_

View File

@@ -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();

View File

@@ -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);

View File

@@ -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

View File

@@ -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

View File

@@ -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)
};

View File

@@ -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<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
@@ -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_

View File

@@ -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);

View File

@@ -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"

View File

@@ -109,12 +109,13 @@ OSStatus UMAGetHelpMenuDontCreate(
OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState ) ;
// Clipboard support
OSStatus UMAPutScrap( Size size , OSType type , void *data ) ;
#define GetWindowUpdateRgn( inWindow , updateRgn ) GetWindowRegion( inWindow , kWindowUpdateRgn, updateRgn )
// Quartz
CGDataProviderRef UMACGDataProviderCreateWithCFData( CFDataRef data );
CGDataConsumerRef UMACGDataConsumerCreateWithCFData( CFMutableDataRef data );
#endif // wxUSE_GUI
#endif

View File

@@ -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