Mac Core Graphics Implementation
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31959 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -2218,9 +2218,10 @@ enum wxUpdateUI
|
|||||||
#define WX_OPAQUE_TYPE( name ) struct wxOpaque##name
|
#define WX_OPAQUE_TYPE( name ) struct wxOpaque##name
|
||||||
|
|
||||||
typedef unsigned char WXCOLORREF[6];
|
typedef unsigned char WXCOLORREF[6];
|
||||||
|
typedef void* WXCGIMAGEREF;
|
||||||
typedef void* WXHBITMAP;
|
typedef void* WXHBITMAP;
|
||||||
typedef void* WXHMETAFILE;
|
//typedef void* WXHMETAFILE;
|
||||||
typedef void* WXHICON;
|
//typedef void* WXHICON;
|
||||||
typedef void* WXHCURSOR;
|
typedef void* WXHCURSOR;
|
||||||
typedef void* WXHRGN;
|
typedef void* WXHRGN;
|
||||||
typedef void* WXRECTPTR;
|
typedef void* WXRECTPTR;
|
||||||
@@ -2236,6 +2237,9 @@ typedef unsigned int WXUINT;
|
|||||||
typedef unsigned long WXDWORD;
|
typedef unsigned long WXDWORD;
|
||||||
typedef unsigned short WXWORD;
|
typedef unsigned short WXWORD;
|
||||||
|
|
||||||
|
typedef WX_OPAQUE_TYPE(CIconHandle ) * WXHICON ;
|
||||||
|
typedef WX_OPAQUE_TYPE(PicHandle ) * WXHMETAFILE ;
|
||||||
|
|
||||||
|
|
||||||
/* typedef void* WXWidget; */
|
/* typedef void* WXWidget; */
|
||||||
/* typedef void* WXWindow; */
|
/* typedef void* WXWindow; */
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
// Bitmap
|
// Bitmap
|
||||||
class WXDLLEXPORT wxBitmap;
|
class WXDLLEXPORT wxBitmap;
|
||||||
|
class wxBitmapRefData ;
|
||||||
class WXDLLEXPORT wxBitmapHandler;
|
class WXDLLEXPORT wxBitmapHandler;
|
||||||
class WXDLLEXPORT wxControl;
|
class WXDLLEXPORT wxControl;
|
||||||
class WXDLLEXPORT wxCursor;
|
class WXDLLEXPORT wxCursor;
|
||||||
@@ -29,78 +30,58 @@ class WXDLLEXPORT wxImage;
|
|||||||
class WXDLLEXPORT wxPixelDataBase;
|
class WXDLLEXPORT wxPixelDataBase;
|
||||||
|
|
||||||
// A mask is a bitmap used for drawing bitmaps
|
// A mask is a bitmap used for drawing bitmaps
|
||||||
// it can be a monochrome bitmap or a multi-bit bitmap which transfers to alpha channels
|
// Internally it is stored as a 8 bit deep memory chunk, 0 = black means the source will be drawn
|
||||||
// transparently.
|
// 255 = white means the source will not be drawn, no other values will be present
|
||||||
|
// 8 bit is chosen only for performance reasons, note also that this is the inverse value range
|
||||||
|
// from alpha, where 0 = invisible , 255 = fully drawn
|
||||||
|
|
||||||
class WXDLLEXPORT wxMask: public wxObject
|
class WXDLLEXPORT wxMask: public wxObject
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxMask)
|
DECLARE_DYNAMIC_CLASS(wxMask)
|
||||||
DECLARE_NO_COPY_CLASS(wxMask)
|
DECLARE_NO_COPY_CLASS(wxMask)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxMask();
|
wxMask();
|
||||||
|
|
||||||
// Construct a mask from a bitmap and a colour indicating
|
// Construct a mask from a bitmap and a colour indicating
|
||||||
// the transparent area
|
// the transparent area
|
||||||
wxMask(const wxBitmap& bitmap, const wxColour& colour);
|
wxMask(const wxBitmap& bitmap, const wxColour& colour);
|
||||||
|
|
||||||
// Construct a mask from a bitmap and a palette index indicating
|
// Construct a mask from a mono bitmap (black meaning show pixels, white meaning transparent)
|
||||||
// the transparent area
|
wxMask(const wxBitmap& bitmap);
|
||||||
wxMask(const wxBitmap& bitmap, int paletteIndex);
|
|
||||||
|
// implementation helper only : construct a mask from a 8 bit memory buffer
|
||||||
|
wxMask(const wxMemoryBuffer& buf, int width , int height , int bytesPerRow ) ;
|
||||||
|
|
||||||
// Construct a mask from a mono bitmap (copies the bitmap).
|
~wxMask();
|
||||||
wxMask(const wxBitmap& bitmap);
|
|
||||||
|
|
||||||
~wxMask();
|
bool Create(const wxBitmap& bitmap, const wxColour& colour);
|
||||||
|
bool Create(const wxBitmap& bitmap);
|
||||||
|
bool Create(const wxMemoryBuffer& buf, int width , int height , int bytesPerRow ) ;
|
||||||
|
|
||||||
bool Create(const wxBitmap& bitmap, const wxColour& colour);
|
// Implementation below
|
||||||
bool Create(const wxBitmap& bitmap, int paletteIndex);
|
|
||||||
bool Create(const wxBitmap& bitmap);
|
|
||||||
|
|
||||||
// Implementation
|
void Init() ;
|
||||||
bool PointMasked(int x, int y);
|
|
||||||
inline WXHBITMAP GetMaskBitmap() const { return m_maskBitmap; }
|
// a 8 bit depth mask
|
||||||
inline void SetMaskBitmap(WXHBITMAP bmp) { m_maskBitmap = bmp; }
|
void* GetRawAccess() const;
|
||||||
int GetDepth() const { return m_depth ; }
|
int GetBytesPerRow() const { return m_bytesPerRow ; }
|
||||||
void SetDepth( int depth ) { m_depth = depth ; }
|
// renders/updates native representation when necessary
|
||||||
protected:
|
void RealizeNative() ;
|
||||||
WXHBITMAP m_maskBitmap;
|
#if !wxMAC_USE_CORE_GRAPHICS
|
||||||
int m_depth ;
|
WXHBITMAP GetHBITMAP() const ;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxMemoryBuffer m_memBuf ;
|
||||||
|
int m_bytesPerRow ;
|
||||||
|
int m_width ;
|
||||||
|
int m_height ;
|
||||||
|
#if !wxMAC_USE_CORE_GRAPHICS
|
||||||
|
WXHBITMAP m_maskBitmap ;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
enum { kMacBitmapTypeUnknownType , kMacBitmapTypeGrafWorld, kMacBitmapTypePict , kMacBitmapTypeIcon } ;
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData
|
|
||||||
{
|
|
||||||
DECLARE_NO_COPY_CLASS(wxBitmapRefData)
|
|
||||||
|
|
||||||
friend class WXDLLEXPORT wxBitmap;
|
|
||||||
friend class WXDLLEXPORT wxIcon;
|
|
||||||
friend class WXDLLEXPORT wxCursor;
|
|
||||||
public:
|
|
||||||
wxBitmapRefData();
|
|
||||||
~wxBitmapRefData();
|
|
||||||
|
|
||||||
public:
|
|
||||||
int m_width;
|
|
||||||
int m_height;
|
|
||||||
int m_depth;
|
|
||||||
bool m_ok;
|
|
||||||
int m_numColors;
|
|
||||||
#if wxUSE_PALETTE
|
|
||||||
wxPalette m_bitmapPalette;
|
|
||||||
#endif // wxUSE_PALETTE
|
|
||||||
int m_quality;
|
|
||||||
|
|
||||||
int m_bitmapType ;
|
|
||||||
WXHMETAFILE m_hPict ;
|
|
||||||
WXHBITMAP m_hBitmap;
|
|
||||||
WXHICON m_hIcon ;
|
|
||||||
wxMask * m_bitmapMask; // Optional mask
|
|
||||||
bool m_hasAlpha;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define M_BITMAPDATA ((wxBitmapRefData *)m_refData)
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxBitmapHandler: public wxBitmapHandlerBase
|
class WXDLLEXPORT wxBitmapHandler: public wxBitmapHandlerBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -120,96 +101,113 @@ private:
|
|||||||
|
|
||||||
class WXDLLEXPORT wxBitmap: public wxBitmapBase
|
class WXDLLEXPORT wxBitmap: public wxBitmapBase
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxBitmap)
|
DECLARE_DYNAMIC_CLASS(wxBitmap)
|
||||||
|
|
||||||
friend class WXDLLEXPORT wxBitmapHandler;
|
friend class WXDLLEXPORT wxBitmapHandler;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxBitmap(); // Platform-specific
|
wxBitmap(); // Platform-specific
|
||||||
|
|
||||||
// Copy constructors
|
// Copy constructors
|
||||||
wxBitmap(const wxBitmap& bitmap)
|
wxBitmap(const wxBitmap& bitmap)
|
||||||
: wxBitmapBase()
|
{ Ref(bitmap); }
|
||||||
{ Ref(bitmap); }
|
|
||||||
|
|
||||||
// Initialize with raw data.
|
// Initialize with raw data.
|
||||||
wxBitmap(const char bits[], int width, int height, int depth = 1);
|
wxBitmap(const char bits[], int width, int height, int depth = 1);
|
||||||
|
|
||||||
// Initialize with XPM data
|
// Initialize with XPM data
|
||||||
bool CreateFromXpm(const char **bits);
|
bool CreateFromXpm(const char **bits);
|
||||||
wxBitmap(const char **bits);
|
wxBitmap(const char **bits);
|
||||||
wxBitmap(char **bits);
|
wxBitmap(char **bits);
|
||||||
|
|
||||||
// Load a file or resource
|
// Load a file or resource
|
||||||
wxBitmap(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_PICT_RESOURCE);
|
wxBitmap(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_PICT_RESOURCE);
|
||||||
|
|
||||||
// Constructor for generalised creation from data
|
// Constructor for generalised creation from data
|
||||||
wxBitmap(void *data, wxBitmapType type, int width, int height, int depth = 1);
|
wxBitmap(void *data, wxBitmapType type, int width, int height, int depth = 1);
|
||||||
|
|
||||||
// If depth is omitted, will create a bitmap compatible with the display
|
// If depth is omitted, will create a bitmap compatible with the display
|
||||||
wxBitmap(int width, int height, int depth = -1);
|
wxBitmap(int width, int height, int depth = -1);
|
||||||
|
|
||||||
// Convert from wxImage:
|
|
||||||
wxBitmap(const wxImage& image, int depth = -1);
|
|
||||||
|
|
||||||
~wxBitmap();
|
|
||||||
|
|
||||||
wxImage ConvertToImage() const;
|
|
||||||
|
|
||||||
// get the given part of bitmap
|
// Convert from wxImage:
|
||||||
wxBitmap GetSubBitmap( const wxRect& rect ) const;
|
wxBitmap(const wxImage& image, int depth = -1);
|
||||||
|
|
||||||
virtual bool Create(int width, int height, int depth = -1);
|
// Convert from wxIcon
|
||||||
virtual bool Create(void *data, wxBitmapType type, int width, int height, int depth = 1);
|
wxBitmap(const wxIcon& icon) { CopyFromIcon(icon); }
|
||||||
virtual bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_BMP_RESOURCE);
|
|
||||||
virtual bool SaveFile(const wxString& name, wxBitmapType type, const wxPalette *cmap = NULL) const;
|
|
||||||
|
|
||||||
// copies the contents and mask of the given (colour) icon to the bitmap
|
~wxBitmap();
|
||||||
virtual bool CopyFromIcon(const wxIcon& icon);
|
|
||||||
|
|
||||||
bool Ok() const;
|
wxImage ConvertToImage() const;
|
||||||
int GetWidth() const;
|
|
||||||
int GetHeight() const;
|
// get the given part of bitmap
|
||||||
int GetDepth() const;
|
wxBitmap GetSubBitmap( const wxRect& rect ) const;
|
||||||
int GetQuality() const;
|
|
||||||
void SetWidth(int w);
|
virtual bool Create(int width, int height, int depth = -1);
|
||||||
void SetHeight(int h);
|
virtual bool Create(void *data, wxBitmapType type, int width, int height, int depth = 1);
|
||||||
void SetDepth(int d);
|
// virtual bool Create( WXHICON icon) ;
|
||||||
void SetQuality(int q);
|
virtual bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_BMP_RESOURCE);
|
||||||
void SetOk(bool isOk);
|
virtual bool SaveFile(const wxString& name, wxBitmapType type, const wxPalette *cmap = NULL) const;
|
||||||
|
|
||||||
|
wxBitmapRefData *GetBitmapData() const
|
||||||
|
{ return (wxBitmapRefData *)m_refData; }
|
||||||
|
|
||||||
|
// copies the contents and mask of the given (colour) icon to the bitmap
|
||||||
|
virtual bool CopyFromIcon(const wxIcon& icon);
|
||||||
|
|
||||||
|
bool Ok() const;
|
||||||
|
int GetWidth() const;
|
||||||
|
int GetHeight() const;
|
||||||
|
int GetDepth() const;
|
||||||
|
void SetWidth(int w);
|
||||||
|
void SetHeight(int h);
|
||||||
|
void SetDepth(int d);
|
||||||
|
void SetOk(bool isOk);
|
||||||
|
|
||||||
|
#if WXWIN_COMPATIBILITY_2_4
|
||||||
|
// these functions do nothing and are only there for backwards
|
||||||
|
// compatibility
|
||||||
|
wxDEPRECATED( int GetQuality() const );
|
||||||
|
wxDEPRECATED( void SetQuality(int quality) );
|
||||||
|
#endif // WXWIN_COMPATIBILITY_2_4
|
||||||
|
|
||||||
#if wxUSE_PALETTE
|
#if wxUSE_PALETTE
|
||||||
wxPalette* GetPalette() const;
|
wxPalette* GetPalette() const;
|
||||||
void SetPalette(const wxPalette& palette);
|
void SetPalette(const wxPalette& palette);
|
||||||
#endif // wxUSE_PALETTE
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
wxMask *GetMask() const;
|
wxMask *GetMask() const;
|
||||||
void SetMask(wxMask *mask) ;
|
void SetMask(wxMask *mask) ;
|
||||||
|
|
||||||
int GetBitmapType() const;
|
inline wxBitmap& operator = (const wxBitmap& bitmap) { if (*this == bitmap) return (*this); Ref(bitmap); return *this; }
|
||||||
|
inline bool operator == (const wxBitmap& bitmap) const { return m_refData == bitmap.m_refData; }
|
||||||
inline wxBitmap& operator = (const wxBitmap& bitmap) { if (*this == bitmap) return (*this); Ref(bitmap); return *this; }
|
inline bool operator != (const wxBitmap& bitmap) const { return m_refData != bitmap.m_refData; }
|
||||||
inline bool operator == (const wxBitmap& bitmap) const { return m_refData == bitmap.m_refData; }
|
|
||||||
inline bool operator != (const wxBitmap& bitmap) const { return m_refData != bitmap.m_refData; }
|
|
||||||
|
|
||||||
static void InitStandardHandlers();
|
static void InitStandardHandlers();
|
||||||
|
|
||||||
// raw bitmap access support functions, for internal use only
|
// raw bitmap access support functions, for internal use only
|
||||||
void *GetRawData(wxPixelDataBase& data, int bpp);
|
void *GetRawData(wxPixelDataBase& data, int bpp);
|
||||||
void UngetRawData(wxPixelDataBase& data);
|
void UngetRawData(wxPixelDataBase& data);
|
||||||
|
|
||||||
|
// these functions are internal and shouldn't be used, they risk to
|
||||||
|
// disappear in the future
|
||||||
|
bool HasAlpha() const;
|
||||||
void UseAlpha();
|
void UseAlpha();
|
||||||
|
|
||||||
public:
|
#if !wxMAC_USE_CORE_GRAPHICS
|
||||||
WXHBITMAP GetHBITMAP() const;
|
// returns the 'native' implementation, a GWorldPtr for the content and one for the mask
|
||||||
inline WXHICON GetHICON() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_hIcon : 0); }
|
WXHBITMAP GetHBITMAP( WXHBITMAP * mask = NULL ) const;
|
||||||
WXHMETAFILE GetPict(bool *created = NULL ) const;
|
#endif
|
||||||
|
|
||||||
void SetHBITMAP(WXHBITMAP bmp);
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
void SetHICON(WXHICON ico);
|
// returns a CGImageRef which must released after usage with CGImageRelease
|
||||||
void SetPict( WXHMETAFILE pict ) ;
|
WXCGIMAGEREF CGImageCreate() const ;
|
||||||
|
#endif
|
||||||
bool FreeResource(bool force = FALSE);
|
// get read only access to the underlying buffer
|
||||||
|
void *GetRawAccess() const ;
|
||||||
|
// brackets to the underlying OS structure for read/write access
|
||||||
|
// makes sure that no cached images will be constructed until terminated
|
||||||
|
void *BeginRawAccess() ;
|
||||||
|
void EndRawAccess() ;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
// _WX_BITMAP_H_
|
// _WX_BITMAP_H_
|
||||||
|
@@ -25,6 +25,14 @@
|
|||||||
#define wxUSE_DEBUG_NEW_ALWAYS 0
|
#define wxUSE_DEBUG_NEW_ALWAYS 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* use OS X CoreGraphics (1) or QuickDraw (0) for rendering
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef wxMAC_USE_CORE_GRAPHICS
|
||||||
|
#define wxMAC_USE_CORE_GRAPHICS 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/* _WX_MAC_CHKCONF_H_ */
|
/* _WX_MAC_CHKCONF_H_ */
|
||||||
|
|
||||||
|
@@ -18,27 +18,6 @@
|
|||||||
|
|
||||||
#include "wx/bitmap.h"
|
#include "wx/bitmap.h"
|
||||||
|
|
||||||
class WXDLLEXPORT wxCursorRefData: public wxBitmapRefData
|
|
||||||
{
|
|
||||||
DECLARE_NO_COPY_CLASS(wxCursorRefData)
|
|
||||||
|
|
||||||
friend class WXDLLEXPORT wxBitmap;
|
|
||||||
friend class WXDLLEXPORT wxCursor;
|
|
||||||
public:
|
|
||||||
wxCursorRefData();
|
|
||||||
~wxCursorRefData();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
WXHCURSOR m_hCursor;
|
|
||||||
bool m_disposeHandle;
|
|
||||||
bool m_releaseHandle;
|
|
||||||
bool m_isColorCursor ;
|
|
||||||
long m_themeCursor ;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define M_CURSORDATA ((wxCursorRefData *)m_refData)
|
|
||||||
#define M_CURSORHANDLERDATA ((wxCursorRefData *)bitmap->m_refData)
|
|
||||||
|
|
||||||
// Cursor
|
// Cursor
|
||||||
class WXDLLEXPORT wxCursor: public wxBitmap
|
class WXDLLEXPORT wxCursor: public wxBitmap
|
||||||
{
|
{
|
||||||
@@ -65,7 +44,7 @@ public:
|
|||||||
~wxCursor();
|
~wxCursor();
|
||||||
|
|
||||||
bool CreateFromXpm(const char **bits) ;
|
bool CreateFromXpm(const char **bits) ;
|
||||||
virtual bool Ok() const { return (m_refData != NULL && ( M_CURSORDATA->m_hCursor != NULL || M_CURSORDATA->m_themeCursor != -1 ) ) ; }
|
virtual bool Ok() const ;
|
||||||
|
|
||||||
inline wxCursor& operator = (const wxCursor& cursor) { if (*this == cursor) return (*this); Ref(cursor); return *this; }
|
inline wxCursor& operator = (const wxCursor& cursor) { if (*this == cursor) return (*this); Ref(cursor); return *this; }
|
||||||
inline bool operator == (const wxCursor& cursor) const { return m_refData == cursor.m_refData; }
|
inline bool operator == (const wxCursor& cursor) const { return m_refData == cursor.m_refData; }
|
||||||
@@ -74,7 +53,7 @@ public:
|
|||||||
void MacInstall() const ;
|
void MacInstall() const ;
|
||||||
|
|
||||||
void SetHCURSOR(WXHCURSOR cursor);
|
void SetHCURSOR(WXHCURSOR cursor);
|
||||||
inline WXHCURSOR GetHCURSOR() const { return (M_CURSORDATA ? M_CURSORDATA->m_hCursor : 0); }
|
inline WXHCURSOR GetHCURSOR() const ;
|
||||||
private :
|
private :
|
||||||
void CreateFromImage(const wxImage & image) ;
|
void CreateFromImage(const wxImage & image) ;
|
||||||
};
|
};
|
||||||
|
@@ -44,7 +44,43 @@
|
|||||||
extern int wxPageNumber;
|
extern int wxPageNumber;
|
||||||
|
|
||||||
class wxMacPortStateHelper ;
|
class wxMacPortStateHelper ;
|
||||||
class wxMacCGContext ;
|
|
||||||
|
class WXDLLEXPORT wxGraphicPath
|
||||||
|
{
|
||||||
|
public :
|
||||||
|
virtual ~wxGraphicPath() {}
|
||||||
|
|
||||||
|
virtual void MoveToPoint( wxCoord x1 , wxCoord y1 ) = 0 ;
|
||||||
|
|
||||||
|
virtual void AddLineToPoint( wxCoord x1 , wxCoord y1 ) = 0 ;
|
||||||
|
|
||||||
|
virtual void AddRectangle( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) = 0 ;
|
||||||
|
|
||||||
|
virtual void AddCircle( wxCoord x, wxCoord y , wxCoord r ) = 0 ;
|
||||||
|
|
||||||
|
virtual void CloseSubpath() = 0 ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxGraphicContext
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~wxGraphicContext() {}
|
||||||
|
|
||||||
|
virtual void Clip( const wxRegion ®ion ) = 0 ;
|
||||||
|
|
||||||
|
virtual void StrokePath( const wxGraphicPath *path ) = 0 ;
|
||||||
|
|
||||||
|
virtual void DrawPath( const wxGraphicPath *path , int fillStyle = wxWINDING_RULE ) = 0 ;
|
||||||
|
|
||||||
|
virtual void FillPath( const wxGraphicPath *path , const wxColor &fillColor , int fillStyle = wxWINDING_RULE ) = 0 ;
|
||||||
|
|
||||||
|
virtual void SetPen( const wxPen &pen ) = 0 ;
|
||||||
|
|
||||||
|
virtual void SetBrush( const wxBrush &brush ) = 0 ;
|
||||||
|
|
||||||
|
virtual wxGraphicPath* CreatePath() = 0 ;
|
||||||
|
} ;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxDC
|
// wxDC
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -186,9 +222,10 @@ class WXDLLEXPORT wxDC: public wxDCBase
|
|||||||
else
|
else
|
||||||
return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY + m_macLocalOrigin.y ;
|
return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY + m_macLocalOrigin.y ;
|
||||||
}
|
}
|
||||||
|
#if !wxMAC_USE_CORE_GRAPHICS
|
||||||
WXHRGN MacGetCurrentClipRgn() { return m_macCurrentClipRgn ; }
|
WXHRGN MacGetCurrentClipRgn() { return m_macCurrentClipRgn ; }
|
||||||
static void MacSetupBackgroundForCurrentPort(const wxBrush& background ) ;
|
static void MacSetupBackgroundForCurrentPort(const wxBrush& background ) ;
|
||||||
|
#endif
|
||||||
//
|
//
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -257,37 +294,45 @@ protected:
|
|||||||
// Begin implementation for Mac
|
// Begin implementation for Mac
|
||||||
public:
|
public:
|
||||||
|
|
||||||
WXHDC m_macPort ;
|
#if !wxMAC_USE_CORE_GRAPHICS
|
||||||
WXHBITMAP m_macMask ;
|
WXHBITMAP m_macMask ;
|
||||||
|
#endif
|
||||||
|
|
||||||
// in order to preserve the const inheritance of the virtual functions, we have to
|
// in order to preserve the const inheritance of the virtual functions, we have to
|
||||||
// use mutable variables starting from CWPro 5
|
// use mutable variables starting from CWPro 5
|
||||||
|
|
||||||
void MacInstallFont() const ;
|
void MacInstallFont() const ;
|
||||||
|
#if !wxMAC_USE_CORE_GRAPHICS
|
||||||
void MacInstallPen() const ;
|
void MacInstallPen() const ;
|
||||||
void MacInstallBrush() const ;
|
void MacInstallBrush() const ;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
wxPoint m_macLocalOrigin ;
|
||||||
|
mutable void* m_macATSUIStyle ;
|
||||||
|
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
// CoreGraphics
|
||||||
|
wxGraphicContext * m_graphicContext ;
|
||||||
|
#else
|
||||||
|
WXHDC m_macPort ;
|
||||||
mutable bool m_macFontInstalled ;
|
mutable bool m_macFontInstalled ;
|
||||||
mutable bool m_macPenInstalled ;
|
mutable bool m_macPenInstalled ;
|
||||||
mutable bool m_macBrushInstalled ;
|
mutable bool m_macBrushInstalled ;
|
||||||
|
|
||||||
WXHRGN m_macBoundaryClipRgn ;
|
WXHRGN m_macBoundaryClipRgn ;
|
||||||
WXHRGN m_macCurrentClipRgn ;
|
WXHRGN m_macCurrentClipRgn ;
|
||||||
wxPoint m_macLocalOrigin ;
|
|
||||||
void MacSetupPort( wxMacPortStateHelper* ph ) const ;
|
void MacSetupPort( wxMacPortStateHelper* ph ) const ;
|
||||||
void MacCleanupPort( wxMacPortStateHelper* ph ) const ;
|
void MacCleanupPort( wxMacPortStateHelper* ph ) const ;
|
||||||
mutable void* m_macATSUIStyle ;
|
|
||||||
mutable wxMacPortStateHelper* m_macCurrentPortStateHelper ;
|
mutable wxMacPortStateHelper* m_macCurrentPortStateHelper ;
|
||||||
mutable bool m_macFormerAliasState ;
|
mutable bool m_macFormerAliasState ;
|
||||||
mutable short m_macFormerAliasSize ;
|
mutable short m_macFormerAliasSize ;
|
||||||
mutable bool m_macAliasWasEnabled ;
|
mutable bool m_macAliasWasEnabled ;
|
||||||
mutable void* m_macForegroundPixMap ;
|
mutable void* m_macForegroundPixMap ;
|
||||||
mutable void* m_macBackgroundPixMap ;
|
mutable void* m_macBackgroundPixMap ;
|
||||||
|
#endif
|
||||||
|
|
||||||
// CoreGraphics
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
#endif
|
||||||
wxMacCGContext * m_macGraphicContext ;
|
|
||||||
void MacSetupGraphicContext() ;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -37,7 +37,9 @@ class WXDLLEXPORT wxPrinterDC: public wxDC
|
|||||||
virtual void EndPage(void) ;
|
virtual void EndPage(void) ;
|
||||||
wxPrintData& GetPrintData() { return m_printData; }
|
wxPrintData& GetPrintData() { return m_printData; }
|
||||||
virtual void DoGetSize( int *width, int *height ) const;
|
virtual void DoGetSize( int *width, int *height ) const;
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
void MacSetCGContext( void * cg ) ;
|
||||||
|
#endif
|
||||||
protected:
|
protected:
|
||||||
wxPrintData m_printData ;
|
wxPrintData m_printData ;
|
||||||
wxNativePrinterDC* m_nativePrinterDC ;
|
wxNativePrinterDC* m_nativePrinterDC ;
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: display.h
|
// Name: display.h
|
||||||
// Purpose: wxDisplay class customization for Mac
|
// Purpose: wxDisplay class customization for Mac
|
||||||
// Author: Brian Victor
|
// Author: Brian Victor/Royce Mitchel for non OSX / Ryan Norton for OS X
|
||||||
// Modified by: Royce Mitchell III
|
// Modified by:
|
||||||
// Created: 06/21/02
|
// Created: 06/21/02
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) wxWidgets team
|
// Copyright: (c) wxWidgets team
|
||||||
|
@@ -19,43 +19,53 @@
|
|||||||
#include "wx/bitmap.h"
|
#include "wx/bitmap.h"
|
||||||
|
|
||||||
// Icon
|
// Icon
|
||||||
class WXDLLEXPORT wxIcon: public wxBitmap
|
class WXDLLEXPORT wxIcon: public wxGDIObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxIcon();
|
wxIcon();
|
||||||
|
|
||||||
// Copy constructors
|
// Copy constructors
|
||||||
wxIcon(const wxIcon& icon)
|
wxIcon(const wxIcon& icon)
|
||||||
: wxBitmap()
|
|
||||||
{ Ref(icon); }
|
{ Ref(icon); }
|
||||||
|
|
||||||
wxIcon(const char **data);
|
wxIcon(const char **data);
|
||||||
wxIcon(char **data);
|
wxIcon(char **data);
|
||||||
wxIcon(const char bits[], int width , int height );
|
wxIcon(const char bits[], int width , int height );
|
||||||
wxIcon(const wxString& name, int flags = wxBITMAP_TYPE_ICON_RESOURCE,
|
wxIcon(const wxString& name, int flags = wxBITMAP_TYPE_ICON_RESOURCE,
|
||||||
int desiredWidth = -1, int desiredHeight = -1);
|
int desiredWidth = -1, int desiredHeight = -1);
|
||||||
wxIcon(const wxIconLocation& loc)
|
wxIcon(const wxIconLocation& loc)
|
||||||
{
|
{
|
||||||
LoadFile(loc.GetFileName(), wxBITMAP_TYPE_ICON);
|
LoadFile(loc.GetFileName(), wxBITMAP_TYPE_ICON);
|
||||||
}
|
}
|
||||||
~wxIcon();
|
~wxIcon();
|
||||||
|
|
||||||
bool LoadFile(const wxString& name, wxBitmapType flags /* = wxBITMAP_TYPE_ICON_RESOURCE */ ,
|
bool LoadFile(const wxString& name, wxBitmapType flags /* = wxBITMAP_TYPE_ICON_RESOURCE */ ,
|
||||||
int desiredWidth /* = -1 */ , int desiredHeight = -1);
|
int desiredWidth /* = -1 */ , int desiredHeight = -1);
|
||||||
bool LoadFile(const wxString& name ,wxBitmapType flags = wxBITMAP_TYPE_ICON_RESOURCE )
|
bool LoadFile(const wxString& name ,wxBitmapType flags = wxBITMAP_TYPE_ICON_RESOURCE )
|
||||||
{ return LoadFile( name , flags , -1 , -1 ) ; }
|
{ return LoadFile( name , flags , -1 , -1 ) ; }
|
||||||
|
|
||||||
wxIcon& operator=(const wxIcon& icon)
|
wxIcon& operator=(const wxIcon& icon)
|
||||||
{ if (this != &icon) Ref(icon); return *this; }
|
{ if (this != &icon) Ref(icon); return *this; }
|
||||||
bool operator==(const wxIcon& icon) const { return m_refData == icon.m_refData; }
|
bool operator==(const wxIcon& icon) const { return m_refData == icon.m_refData; }
|
||||||
bool operator!=(const wxIcon& icon) const { return !(*this == icon); }
|
bool operator!=(const wxIcon& icon) const { return !(*this == icon); }
|
||||||
|
|
||||||
// create from bitmap (which should have a mask unless it's monochrome):
|
// create from bitmap (which should have a mask unless it's monochrome):
|
||||||
// there shouldn't be any implicit bitmap -> icon conversion (i.e. no
|
// there shouldn't be any implicit bitmap -> icon conversion (i.e. no
|
||||||
// ctors, assignment operators...), but it's ok to have such function
|
// ctors, assignment operators...), but it's ok to have such function
|
||||||
void CopyFromBitmap(const wxBitmap& bmp);
|
void CopyFromBitmap(const wxBitmap& bmp);
|
||||||
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxIcon)
|
bool Ok() const;
|
||||||
|
int GetWidth() const;
|
||||||
|
int GetHeight() const;
|
||||||
|
int GetDepth() const;
|
||||||
|
void SetWidth(int w);
|
||||||
|
void SetHeight(int h);
|
||||||
|
void SetDepth(int d);
|
||||||
|
void SetOk(bool isOk);
|
||||||
|
|
||||||
|
WXHICON GetHICON() const ;
|
||||||
|
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxIcon)
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -58,6 +58,7 @@ inline int FixedToInt( Fixed inFixed )
|
|||||||
|
|
||||||
#if wxUSE_GUI
|
#if wxUSE_GUI
|
||||||
|
|
||||||
|
#include "wx/dc.h"
|
||||||
#include "wx/window.h"
|
#include "wx/window.h"
|
||||||
|
|
||||||
class wxMacPortStateHelper
|
class wxMacPortStateHelper
|
||||||
@@ -345,19 +346,22 @@ private :
|
|||||||
typedef wxMacUPP<NMProcPtr,NMUPP,NewNMUPP,DisposeNMUPP> wxMacNMUPP ;
|
typedef wxMacUPP<NMProcPtr,NMUPP,NewNMUPP,DisposeNMUPP> wxMacNMUPP ;
|
||||||
|
|
||||||
#if wxUSE_GUI
|
#if wxUSE_GUI
|
||||||
|
/*
|
||||||
GWorldPtr wxMacCreateGWorld( int width , int height , int depth ) ;
|
GWorldPtr wxMacCreateGWorld( int width , int height , int depth ) ;
|
||||||
void wxMacDestroyGWorld( GWorldPtr gw ) ;
|
void wxMacDestroyGWorld( GWorldPtr gw ) ;
|
||||||
PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL ) ;
|
PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL ) ;
|
||||||
CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize ) ;
|
CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize ) ;
|
||||||
void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) ;
|
void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) ;
|
||||||
CTabHandle wxMacCreateColorTable( int numColors ) ;
|
CTabHandle wxMacCreateColorTable( int numColors ) ;
|
||||||
|
*/
|
||||||
|
IconRef wxMacCreateIconRef(const wxBitmap& bmp) ;
|
||||||
void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType = 0 ) ;
|
void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType = 0 ) ;
|
||||||
|
void wxMacReleaseBitmapButton( ControlButtonContentInfo*info ) ;
|
||||||
|
|
||||||
#define MAC_WXCOLORREF(a) (*((RGBColor*)&(a)))
|
#define MAC_WXCOLORREF(a) (*((RGBColor*)&(a)))
|
||||||
#define MAC_WXHBITMAP(a) (GWorldPtr(a))
|
#define MAC_WXHBITMAP(a) (GWorldPtr(a))
|
||||||
#define MAC_WXHMETAFILE(a) (PicHandle(a))
|
#define MAC_WXHMETAFILE(a) (PicHandle(a))
|
||||||
#define MAC_WXHICON(a) (CIconHandle(a))
|
#define MAC_WXHICON(a) (IconRef(a))
|
||||||
#define MAC_WXHCURSOR(a) (CursHandle(a))
|
#define MAC_WXHCURSOR(a) (CursHandle(a))
|
||||||
#define MAC_WXHRGN(a) (RgnHandle(a))
|
#define MAC_WXHRGN(a) (RgnHandle(a))
|
||||||
#define MAC_WXHWND(a) (WindowPtr(a))
|
#define MAC_WXHWND(a) (WindowPtr(a))
|
||||||
@@ -540,6 +544,142 @@ protected :
|
|||||||
long m_windowStyle ;
|
long m_windowStyle ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxMacCGPath : public wxGraphicPath
|
||||||
|
{
|
||||||
|
DECLARE_NO_COPY_CLASS(wxMacCGPath)
|
||||||
|
public :
|
||||||
|
wxMacCGPath() ;
|
||||||
|
~wxMacCGPath() ;
|
||||||
|
|
||||||
|
// Starts a new subpath at
|
||||||
|
void MoveToPoint( wxCoord x1 , wxCoord y1 ) ;
|
||||||
|
void AddLineToPoint( wxCoord x1 , wxCoord y1 ) ;
|
||||||
|
void AddRectangle( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) ;
|
||||||
|
void AddCircle( wxCoord x, wxCoord y , wxCoord r ) ;
|
||||||
|
|
||||||
|
// closes the current subpath
|
||||||
|
void CloseSubpath() ;
|
||||||
|
|
||||||
|
CGPathRef GetPath() const ;
|
||||||
|
private :
|
||||||
|
CGMutablePathRef m_path ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxMacCGContext : public wxGraphicContext
|
||||||
|
{
|
||||||
|
DECLARE_NO_COPY_CLASS(wxMacCGContext)
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxMacCGContext( CGrafPtr port ) ;
|
||||||
|
wxMacCGContext( CGContextRef cgcontext ) ;
|
||||||
|
wxMacCGContext() ;
|
||||||
|
~wxMacCGContext() ;
|
||||||
|
|
||||||
|
virtual void Clip( const wxRegion ®ion ) ;
|
||||||
|
virtual void StrokePath( const wxGraphicPath *p ) ;
|
||||||
|
virtual void DrawPath( const wxGraphicPath *p , int fillStyle = wxWINDING_RULE ) ;
|
||||||
|
virtual void FillPath( const wxGraphicPath *p , const wxColor &fillColor , int fillStyle = wxWINDING_RULE ) ;
|
||||||
|
|
||||||
|
virtual wxGraphicPath* CreatePath() ;
|
||||||
|
virtual void SetPen( const wxPen &pen ) ;
|
||||||
|
virtual void SetBrush( const wxBrush &brush ) ;
|
||||||
|
CGContextRef GetNativeContext() ;
|
||||||
|
void SetNativeContext( CGContextRef cg ) ;
|
||||||
|
CGPathDrawingMode GetDrawingMode() const { return m_mode ; }
|
||||||
|
private:
|
||||||
|
CGContextRef m_cgContext ;
|
||||||
|
CGrafPtr m_qdPort ;
|
||||||
|
CGPathDrawingMode m_mode ;
|
||||||
|
wxPen m_pen ;
|
||||||
|
wxBrush m_brush ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
CGColorSpaceRef wxMacGetGenericRGBColorSpace(void) ;
|
||||||
|
|
||||||
|
#endif // wxMAC_USE_CORE_GRAPHICS
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData
|
||||||
|
{
|
||||||
|
DECLARE_NO_COPY_CLASS(wxBitmapRefData)
|
||||||
|
|
||||||
|
friend class WXDLLEXPORT wxIcon;
|
||||||
|
friend class WXDLLEXPORT wxCursor;
|
||||||
|
public:
|
||||||
|
wxBitmapRefData(int width , int height , int depth);
|
||||||
|
wxBitmapRefData();
|
||||||
|
~wxBitmapRefData();
|
||||||
|
|
||||||
|
void Free() ;
|
||||||
|
bool Ok() const { return m_ok ; }
|
||||||
|
void SetOk( bool isOk) { m_ok = isOk ; }
|
||||||
|
|
||||||
|
void SetWidth( int width ) { m_width = width ; }
|
||||||
|
void SetHeight( int height ) { m_height = height ; }
|
||||||
|
void SetDepth( int depth ) { m_depth = depth ; }
|
||||||
|
|
||||||
|
int GetWidth() const { return m_width ; }
|
||||||
|
int GetHeight() const { return m_height ; }
|
||||||
|
int GetDepth() const { return m_depth ; }
|
||||||
|
|
||||||
|
void *GetRawAccess() const ;
|
||||||
|
void *BeginRawAccess() ;
|
||||||
|
void EndRawAccess() ;
|
||||||
|
|
||||||
|
bool HasAlpha() const { return m_hasAlpha ; }
|
||||||
|
void UseAlpha( bool useAlpha ) ;
|
||||||
|
|
||||||
|
public:
|
||||||
|
#if wxUSE_PALETTE
|
||||||
|
wxPalette m_bitmapPalette;
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
|
wxMask * m_bitmapMask; // Optional mask
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
CGImageRef CGImageCreate() const ;
|
||||||
|
#else
|
||||||
|
GWorldPtr GetHBITMAP(GWorldPtr * mask = NULL ) const ;
|
||||||
|
void UpdateAlphaMask() const ;
|
||||||
|
#endif
|
||||||
|
private :
|
||||||
|
bool Create(int width , int height , int depth) ;
|
||||||
|
void Init() ;
|
||||||
|
|
||||||
|
int m_width;
|
||||||
|
int m_height;
|
||||||
|
int m_bytesPerRow ;
|
||||||
|
int m_depth;
|
||||||
|
bool m_hasAlpha;
|
||||||
|
wxMemoryBuffer m_memBuf ;
|
||||||
|
int m_rawAccessCount ;
|
||||||
|
bool m_ok;
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
mutable CGImageRef m_cgImageRef ;
|
||||||
|
#else
|
||||||
|
GWorldPtr m_hBitmap;
|
||||||
|
GWorldPtr m_hMaskBitmap ;
|
||||||
|
wxMemoryBuffer m_maskMemBuf ;
|
||||||
|
int m_maskBytesPerRow ;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#define M_BITMAPDATA ((wxBitmapRefData *)m_refData)
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxIconRefData : public wxGDIRefData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxIconRefData() ;
|
||||||
|
wxIconRefData( WXHICON ) ;
|
||||||
|
virtual ~wxIconRefData() { Free(); }
|
||||||
|
|
||||||
|
void Init() ;
|
||||||
|
virtual void Free();
|
||||||
|
WXHICON GetHICON() const { return (WXHICON) m_iconRef ; }
|
||||||
|
private :
|
||||||
|
IconRef m_iconRef ;
|
||||||
|
};
|
||||||
|
|
||||||
#endif // wxUSE_GUI
|
#endif // wxUSE_GUI
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@@ -22,9 +22,9 @@ class WXDLLEXPORT wxStaticBitmap: public wxStaticBitmapBase
|
|||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxStaticBitmap)
|
DECLARE_DYNAMIC_CLASS(wxStaticBitmap)
|
||||||
public:
|
public:
|
||||||
inline wxStaticBitmap() { }
|
wxStaticBitmap() { }
|
||||||
|
|
||||||
inline wxStaticBitmap(wxWindow *parent, wxWindowID id,
|
wxStaticBitmap(wxWindow *parent, wxWindowID id,
|
||||||
const wxBitmap& label,
|
const wxBitmap& label,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
@@ -60,7 +60,7 @@ class WXDLLEXPORT wxStaticBitmap: public wxStaticBitmapBase
|
|||||||
virtual wxSize DoGetBestSize() const ;
|
virtual wxSize DoGetBestSize() const ;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxBitmap m_bitmap;
|
wxBitmap m_bitmap;
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -163,7 +163,7 @@ public:
|
|||||||
|
|
||||||
virtual void MacVisibilityChanged() ;
|
virtual void MacVisibilityChanged() ;
|
||||||
virtual void MacEnabledStateChanged() ;
|
virtual void MacEnabledStateChanged() ;
|
||||||
|
#ifndef __WXMAC_OSX__
|
||||||
virtual void MacControlUserPaneDrawProc(wxInt16 part) ;
|
virtual void MacControlUserPaneDrawProc(wxInt16 part) ;
|
||||||
virtual wxInt16 MacControlUserPaneHitTestProc(wxInt16 x, wxInt16 y) ;
|
virtual wxInt16 MacControlUserPaneHitTestProc(wxInt16 x, wxInt16 y) ;
|
||||||
virtual wxInt16 MacControlUserPaneTrackingProc(wxInt16 x, wxInt16 y, void* actionProc) ;
|
virtual wxInt16 MacControlUserPaneTrackingProc(wxInt16 x, wxInt16 y, void* actionProc) ;
|
||||||
@@ -172,6 +172,7 @@ public:
|
|||||||
virtual void MacControlUserPaneActivateProc(bool activating) ;
|
virtual void MacControlUserPaneActivateProc(bool activating) ;
|
||||||
virtual wxInt16 MacControlUserPaneFocusProc(wxInt16 action) ;
|
virtual wxInt16 MacControlUserPaneFocusProc(wxInt16 action) ;
|
||||||
virtual void MacControlUserPaneBackgroundProc(void* info) ;
|
virtual void MacControlUserPaneBackgroundProc(void* info) ;
|
||||||
|
#endif
|
||||||
|
|
||||||
wxMacTextControl* GetPeer() const { return (wxMacTextControl*) m_peer ; }
|
wxMacTextControl* GetPeer() const { return (wxMacTextControl*) m_peer ; }
|
||||||
protected:
|
protected:
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/brush.h"
|
#include "wx/brush.h"
|
||||||
|
#include "wx/dc.h"
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// forward declarations
|
// forward declarations
|
||||||
@@ -161,7 +162,6 @@ public:
|
|||||||
public:
|
public:
|
||||||
virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) ;
|
virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) ;
|
||||||
virtual bool MacDoRedraw( WXHRGN updatergn , long time ) ;
|
virtual bool MacDoRedraw( WXHRGN updatergn , long time ) ;
|
||||||
virtual void MacRedraw( WXHRGN updatergn , long time , bool erase) ;
|
|
||||||
virtual bool MacCanFocus() const ;
|
virtual bool MacCanFocus() const ;
|
||||||
|
|
||||||
// this should not be overriden in classes above wxWindowMac because it is called from its destructor via DeleteChildren
|
// this should not be overriden in classes above wxWindowMac because it is called from its destructor via DeleteChildren
|
||||||
@@ -212,10 +212,9 @@ public:
|
|||||||
|
|
||||||
wxList& GetSubcontrols() { return m_subControls; }
|
wxList& GetSubcontrols() { return m_subControls; }
|
||||||
virtual void MacInstallEventHandler(WXWidget native) ;
|
virtual void MacInstallEventHandler(WXWidget native) ;
|
||||||
virtual void MacRedrawControl();
|
|
||||||
WXEVENTHANDLERREF MacGetControlEventHandler() { return m_macControlEventHandler ; }
|
WXEVENTHANDLERREF MacGetControlEventHandler() { return m_macControlEventHandler ; }
|
||||||
void MacPostControlCreate(const wxPoint& pos, const wxSize& size) ;
|
void MacPostControlCreate(const wxPoint& pos, const wxSize& size) ;
|
||||||
|
#ifndef __WXMAC_OSX__
|
||||||
virtual void MacControlUserPaneDrawProc(wxInt16 part) ;
|
virtual void MacControlUserPaneDrawProc(wxInt16 part) ;
|
||||||
virtual wxInt16 MacControlUserPaneHitTestProc(wxInt16 x, wxInt16 y) ;
|
virtual wxInt16 MacControlUserPaneHitTestProc(wxInt16 x, wxInt16 y) ;
|
||||||
virtual wxInt16 MacControlUserPaneTrackingProc(wxInt16 x, wxInt16 y, void* actionProc) ;
|
virtual wxInt16 MacControlUserPaneTrackingProc(wxInt16 x, wxInt16 y, void* actionProc) ;
|
||||||
@@ -224,7 +223,7 @@ public:
|
|||||||
virtual void MacControlUserPaneActivateProc(bool activating) ;
|
virtual void MacControlUserPaneActivateProc(bool activating) ;
|
||||||
virtual wxInt16 MacControlUserPaneFocusProc(wxInt16 action) ;
|
virtual wxInt16 MacControlUserPaneFocusProc(wxInt16 action) ;
|
||||||
virtual void MacControlUserPaneBackgroundProc(void* info) ;
|
virtual void MacControlUserPaneBackgroundProc(void* info) ;
|
||||||
|
#endif
|
||||||
// translate wxWidgets coords into ones suitable to be passed to
|
// translate wxWidgets coords into ones suitable to be passed to
|
||||||
// the CreateControl calls
|
// the CreateControl calls
|
||||||
//
|
//
|
||||||
@@ -241,7 +240,10 @@ public:
|
|||||||
|
|
||||||
// flash the current invalid area, useful for debugging in OSX double buffered situation
|
// flash the current invalid area, useful for debugging in OSX double buffered situation
|
||||||
void MacFlashInvalidAreas() ;
|
void MacFlashInvalidAreas() ;
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
void * MacGetCGContextRef() { return m_cgContextRef ; }
|
||||||
|
void MacSetCGContextRef(void * cg) { m_cgContextRef = cg ; }
|
||||||
|
#endif
|
||||||
protected:
|
protected:
|
||||||
// For controls like radiobuttons which are really composite
|
// For controls like radiobuttons which are really composite
|
||||||
wxList m_subControls;
|
wxList m_subControls;
|
||||||
@@ -249,6 +251,9 @@ protected:
|
|||||||
unsigned int m_frozenness;
|
unsigned int m_frozenness;
|
||||||
// the peer object, allowing for cleaner API support
|
// the peer object, allowing for cleaner API support
|
||||||
wxMacControl* m_peer ;
|
wxMacControl* m_peer ;
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
void * m_cgContextRef ;
|
||||||
|
#endif
|
||||||
// true if is is not a native control but a wxWindow control
|
// true if is is not a native control but a wxWindow control
|
||||||
bool m_macIsUserPane ;
|
bool m_macIsUserPane ;
|
||||||
wxBrush m_macBackgroundBrush ;
|
wxBrush m_macBackgroundBrush ;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -65,12 +65,7 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_bmpNormal = bitmap;
|
m_bmpNormal = bitmap;
|
||||||
|
|
||||||
wxBitmapRefData * bmap = NULL ;
|
|
||||||
|
|
||||||
if ( m_bmpNormal.Ok() )
|
|
||||||
bmap = (wxBitmapRefData*) ( m_bmpNormal.GetRefData()) ;
|
|
||||||
|
|
||||||
ControlButtonContentInfo info ;
|
ControlButtonContentInfo info ;
|
||||||
wxMacCreateBitmapButton( &info , m_bmpNormal ) ;
|
wxMacCreateBitmapButton( &info , m_bmpNormal ) ;
|
||||||
|
|
||||||
@@ -80,7 +75,7 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
|
|||||||
(( style & wxBU_AUTODRAW ) ? kControlBevelButtonSmallBevel : kControlBevelButtonNormalBevel ) ,
|
(( style & wxBU_AUTODRAW ) ? kControlBevelButtonSmallBevel : kControlBevelButtonNormalBevel ) ,
|
||||||
kControlBehaviorOffsetContents , &info , 0 , 0 , 0 , m_peer->GetControlRefAddr() ) );
|
kControlBehaviorOffsetContents , &info , 0 , 0 , 0 , m_peer->GetControlRefAddr() ) );
|
||||||
|
|
||||||
|
wxMacReleaseBitmapButton( &info ) ;
|
||||||
wxASSERT_MSG( m_peer != NULL && m_peer->Ok() , wxT("No valid mac control") ) ;
|
wxASSERT_MSG( m_peer != NULL && m_peer->Ok() , wxT("No valid mac control") ) ;
|
||||||
|
|
||||||
MacPostControlCreate(pos,size) ;
|
MacPostControlCreate(pos,size) ;
|
||||||
@@ -99,6 +94,7 @@ void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
|
|||||||
{
|
{
|
||||||
m_peer->SetData( kControlButtonPart , kControlBevelButtonContentTag , info ) ;
|
m_peer->SetData( kControlButtonPart , kControlBevelButtonContentTag , info ) ;
|
||||||
}
|
}
|
||||||
|
wxMacReleaseBitmapButton( &info ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -27,6 +27,27 @@
|
|||||||
IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
|
IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxCursorRefData: public wxBitmapRefData
|
||||||
|
{
|
||||||
|
DECLARE_NO_COPY_CLASS(wxCursorRefData)
|
||||||
|
|
||||||
|
friend class WXDLLEXPORT wxBitmap;
|
||||||
|
friend class WXDLLEXPORT wxCursor;
|
||||||
|
public:
|
||||||
|
wxCursorRefData();
|
||||||
|
~wxCursorRefData();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
WXHCURSOR m_hCursor;
|
||||||
|
bool m_disposeHandle;
|
||||||
|
bool m_releaseHandle;
|
||||||
|
bool m_isColorCursor ;
|
||||||
|
long m_themeCursor ;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define M_CURSORDATA ((wxCursorRefData *)m_refData)
|
||||||
|
#define M_CURSORHANDLERDATA ((wxCursorRefData *)bitmap->m_refData)
|
||||||
|
|
||||||
const short kwxCursorBullseye = 0 ;
|
const short kwxCursorBullseye = 0 ;
|
||||||
const short kwxCursorBlank = 1 ;
|
const short kwxCursorBlank = 1 ;
|
||||||
const short kwxCursorPencil = 2 ;
|
const short kwxCursorPencil = 2 ;
|
||||||
@@ -181,8 +202,8 @@ CursHandle wxGetStockCursor( int number )
|
|||||||
|
|
||||||
wxCursorRefData::wxCursorRefData()
|
wxCursorRefData::wxCursorRefData()
|
||||||
{
|
{
|
||||||
m_width = 16;
|
SetWidth( 16 );
|
||||||
m_height = 16;
|
SetHeight( 16 );
|
||||||
m_hCursor = NULL ;
|
m_hCursor = NULL ;
|
||||||
m_disposeHandle = false ;
|
m_disposeHandle = false ;
|
||||||
m_releaseHandle = false ;
|
m_releaseHandle = false ;
|
||||||
@@ -242,6 +263,16 @@ bool wxCursor::CreateFromXpm(const char **bits)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WXHCURSOR wxCursor::GetHCURSOR() const
|
||||||
|
{
|
||||||
|
return (M_CURSORDATA ? M_CURSORDATA->m_hCursor : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxCursor::Ok() const
|
||||||
|
{
|
||||||
|
return (m_refData != NULL && ( M_CURSORDATA->m_hCursor != NULL || M_CURSORDATA->m_themeCursor != -1 ) ) ;
|
||||||
|
}
|
||||||
|
|
||||||
short GetCTabIndex( CTabHandle colors , RGBColor *col )
|
short GetCTabIndex( CTabHandle colors , RGBColor *col )
|
||||||
{
|
{
|
||||||
short retval = 0 ;
|
short retval = 0 ;
|
||||||
|
@@ -250,7 +250,9 @@ wxBitmapDataObject::wxBitmapDataObject(
|
|||||||
Init();
|
Init();
|
||||||
if ( m_bitmap.Ok() )
|
if ( m_bitmap.Ok() )
|
||||||
{
|
{
|
||||||
m_pictHandle = m_bitmap.GetPict( &m_pictCreated ) ;
|
/*
|
||||||
|
m_pictHandle = m_bitmap.GetBitmapData()->GetPict( &m_pictCreated ) ;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,7 +269,9 @@ void wxBitmapDataObject::SetBitmap(
|
|||||||
wxBitmapDataObjectBase::SetBitmap(rBitmap);
|
wxBitmapDataObjectBase::SetBitmap(rBitmap);
|
||||||
if ( m_bitmap.Ok() )
|
if ( m_bitmap.Ok() )
|
||||||
{
|
{
|
||||||
m_pictHandle = m_bitmap.GetPict( &m_pictCreated ) ;
|
/*
|
||||||
|
m_pictHandle = m_bitmap.GetBitmapData()->GetPict( &m_pictCreated ) ;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,11 +317,13 @@ bool wxBitmapDataObject::SetData(
|
|||||||
PicHandle picHandle = (PicHandle) NewHandle( nSize ) ;
|
PicHandle picHandle = (PicHandle) NewHandle( nSize ) ;
|
||||||
memcpy( *picHandle , pBuf , nSize ) ;
|
memcpy( *picHandle , pBuf , nSize ) ;
|
||||||
m_pictHandle = picHandle ;
|
m_pictHandle = picHandle ;
|
||||||
|
// ownership is transferred to the bitmap
|
||||||
m_pictCreated = false ;
|
m_pictCreated = false ;
|
||||||
Rect frame = (**picHandle).picFrame ;
|
Rect frame = (**picHandle).picFrame ;
|
||||||
|
/*
|
||||||
m_bitmap.SetPict( picHandle ) ;
|
m_bitmap.GetBitmapData()->SetPict( (WXHMETAFILE) picHandle ) ;
|
||||||
m_bitmap.SetWidth( frame.right - frame.left ) ;
|
m_bitmap.SetWidth( frame.right - frame.left ) ;
|
||||||
m_bitmap.SetHeight( frame.bottom - frame.top ) ;
|
m_bitmap.SetHeight( frame.bottom - frame.top ) ;
|
||||||
|
*/
|
||||||
return m_bitmap.Ok();
|
return m_bitmap.Ok();
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
#include "wx/wxprec.h"
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
#include "wx/dc.h"
|
#include "wx/dc.h"
|
||||||
|
|
||||||
|
#if !wxMAC_USE_CORE_GRAPHICS
|
||||||
#include "wx/app.h"
|
#include "wx/app.h"
|
||||||
#include "wx/mac/uma.h"
|
#include "wx/mac/uma.h"
|
||||||
#include "wx/dcmemory.h"
|
#include "wx/dcmemory.h"
|
||||||
@@ -285,11 +287,6 @@ wxDC::~wxDC(void)
|
|||||||
DisposeRgn( (RgnHandle) m_macCurrentClipRgn ) ;
|
DisposeRgn( (RgnHandle) m_macCurrentClipRgn ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDC::MacSetupGraphicContext()
|
|
||||||
{
|
|
||||||
// no-op for QuickDraw
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxDC::MacSetupPort(wxMacPortStateHelper* help) const
|
void wxDC::MacSetupPort(wxMacPortStateHelper* help) const
|
||||||
{
|
{
|
||||||
#ifdef __WXDEBUG__
|
#ifdef __WXDEBUG__
|
||||||
@@ -360,62 +357,51 @@ void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask
|
|||||||
//m_logicalFunction == wxSRC_OR ? srcOr :
|
//m_logicalFunction == wxSRC_OR ? srcOr :
|
||||||
//m_logicalFunction == wxSRC_AND ? SRCAND :
|
//m_logicalFunction == wxSRC_AND ? SRCAND :
|
||||||
srcCopy );
|
srcCopy );
|
||||||
if ( bmp.GetBitmapType() == kMacBitmapTypePict ) {
|
|
||||||
Rect bitmaprect = { 0 , 0 , hh, ww };
|
GWorldPtr maskworld = NULL ;
|
||||||
::OffsetRect( &bitmaprect, xx, yy ) ;
|
GWorldPtr bmapworld = MAC_WXHBITMAP( bmp.GetHBITMAP((WXHBITMAP*)&maskworld) );
|
||||||
::DrawPicture( (PicHandle) bmp.GetPict(), &bitmaprect ) ;
|
PixMapHandle bmappixels ;
|
||||||
}
|
// Set foreground and background colours (for bitmaps depth = 1)
|
||||||
else if ( bmp.GetBitmapType() == kMacBitmapTypeGrafWorld )
|
if(bmp.GetDepth() == 1)
|
||||||
{
|
{
|
||||||
GWorldPtr bmapworld = MAC_WXHBITMAP( bmp.GetHBITMAP() );
|
RGBColor fore = MAC_WXCOLORREF(m_textForegroundColour.GetPixel());
|
||||||
PixMapHandle bmappixels ;
|
RGBColor back = MAC_WXCOLORREF(m_textBackgroundColour.GetPixel());
|
||||||
// Set foreground and background colours (for bitmaps depth = 1)
|
RGBForeColor(&fore);
|
||||||
if(bmp.GetDepth() == 1)
|
RGBBackColor(&back);
|
||||||
{
|
|
||||||
RGBColor fore = MAC_WXCOLORREF(m_textForegroundColour.GetPixel());
|
|
||||||
RGBColor back = MAC_WXCOLORREF(m_textBackgroundColour.GetPixel());
|
|
||||||
RGBForeColor(&fore);
|
|
||||||
RGBBackColor(&back);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ;
|
|
||||||
RGBColor black = { 0,0,0} ;
|
|
||||||
RGBForeColor( &black ) ;
|
|
||||||
RGBBackColor( &white ) ;
|
|
||||||
}
|
|
||||||
bmappixels = GetGWorldPixMap( bmapworld ) ;
|
|
||||||
wxCHECK_RET(LockPixels(bmappixels),
|
|
||||||
wxT("DoDrawBitmap: Unable to lock pixels"));
|
|
||||||
Rect source = { 0, 0, h, w };
|
|
||||||
Rect dest = { yy, xx, yy + hh, xx + ww };
|
|
||||||
if ( useMask && bmp.GetMask() )
|
|
||||||
{
|
|
||||||
if( LockPixels(GetGWorldPixMap(MAC_WXHBITMAP(bmp.GetMask()->GetMaskBitmap()))))
|
|
||||||
{
|
|
||||||
CopyDeepMask
|
|
||||||
(
|
|
||||||
GetPortBitMapForCopyBits(bmapworld),
|
|
||||||
GetPortBitMapForCopyBits(MAC_WXHBITMAP(bmp.GetMask()->GetMaskBitmap())),
|
|
||||||
GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ),
|
|
||||||
&source, &source, &dest, mode, NULL
|
|
||||||
);
|
|
||||||
UnlockPixels(GetGWorldPixMap(MAC_WXHBITMAP(bmp.GetMask()->GetMaskBitmap())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
CopyBits( GetPortBitMapForCopyBits( bmapworld ),
|
|
||||||
GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ),
|
|
||||||
&source, &dest, mode, NULL ) ;
|
|
||||||
}
|
|
||||||
UnlockPixels( bmappixels ) ;
|
|
||||||
}
|
}
|
||||||
else if ( bmp.GetBitmapType() == kMacBitmapTypeIcon )
|
else
|
||||||
{
|
{
|
||||||
Rect bitmaprect = { 0 , 0 , bmp.GetHeight(), bmp.GetWidth() } ;
|
RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ;
|
||||||
OffsetRect( &bitmaprect, xx, yy ) ;
|
RGBColor black = { 0,0,0} ;
|
||||||
PlotCIconHandle( &bitmaprect , atNone , ttNone , MAC_WXHICON(bmp.GetHICON()) ) ;
|
RGBForeColor( &black ) ;
|
||||||
|
RGBBackColor( &white ) ;
|
||||||
}
|
}
|
||||||
|
bmappixels = GetGWorldPixMap( bmapworld ) ;
|
||||||
|
wxCHECK_RET(LockPixels(bmappixels),
|
||||||
|
wxT("DoDrawBitmap: Unable to lock pixels"));
|
||||||
|
Rect source = { 0, 0, h, w };
|
||||||
|
Rect dest = { yy, xx, yy + hh, xx + ww };
|
||||||
|
if ( useMask && maskworld )
|
||||||
|
{
|
||||||
|
if( LockPixels(GetGWorldPixMap(MAC_WXHBITMAP(maskworld))))
|
||||||
|
{
|
||||||
|
CopyDeepMask
|
||||||
|
(
|
||||||
|
GetPortBitMapForCopyBits(bmapworld),
|
||||||
|
GetPortBitMapForCopyBits(MAC_WXHBITMAP(maskworld)),
|
||||||
|
GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ),
|
||||||
|
&source, &source, &dest, mode, NULL
|
||||||
|
);
|
||||||
|
UnlockPixels(GetGWorldPixMap(MAC_WXHBITMAP(maskworld)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
CopyBits( GetPortBitMapForCopyBits( bmapworld ),
|
||||||
|
GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ),
|
||||||
|
&source, &dest, mode, NULL ) ;
|
||||||
|
}
|
||||||
|
UnlockPixels( bmappixels ) ;
|
||||||
|
|
||||||
m_macPenInstalled = false ;
|
m_macPenInstalled = false ;
|
||||||
m_macBrushInstalled = false ;
|
m_macBrushInstalled = false ;
|
||||||
m_macFontInstalled = false ;
|
m_macFontInstalled = false ;
|
||||||
@@ -425,7 +411,13 @@ void wxDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y )
|
|||||||
{
|
{
|
||||||
wxCHECK_RET(Ok(), wxT("Invalid dc wxDC::DoDrawIcon"));
|
wxCHECK_RET(Ok(), wxT("Invalid dc wxDC::DoDrawIcon"));
|
||||||
wxCHECK_RET(icon.Ok(), wxT("Invalid icon wxDC::DoDrawIcon"));
|
wxCHECK_RET(icon.Ok(), wxT("Invalid icon wxDC::DoDrawIcon"));
|
||||||
DoDrawBitmap( icon , x , y , icon.GetMask() != NULL ) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
|
|
||||||
|
wxCoord xx = XLOG2DEVMAC(x);
|
||||||
|
wxCoord yy = YLOG2DEVMAC(y);
|
||||||
|
|
||||||
|
Rect r = { yy , xx, yy + 32 , xx + 32 } ;
|
||||||
|
PlotIconRef( &r , kAlignNone , kTransformNone , kPlotIconRefNormalFlags , MAC_WXHICON( icon.GetHICON() ) ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
|
void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
|
||||||
@@ -1942,9 +1934,9 @@ void wxDC::MacInstallBrush() const
|
|||||||
int height = bitmap->GetHeight() ;
|
int height = bitmap->GetHeight() ;
|
||||||
GWorldPtr gw = NULL ;
|
GWorldPtr gw = NULL ;
|
||||||
if ( m_brush.GetStyle() == wxSTIPPLE )
|
if ( m_brush.GetStyle() == wxSTIPPLE )
|
||||||
gw = MAC_WXHBITMAP(bitmap->GetHBITMAP()) ;
|
gw = MAC_WXHBITMAP(bitmap->GetHBITMAP(NULL)) ;
|
||||||
else
|
else
|
||||||
gw = MAC_WXHBITMAP(bitmap->GetMask()->GetMaskBitmap()) ;
|
gw = MAC_WXHBITMAP(bitmap->GetMask()->GetHBITMAP()) ;
|
||||||
PixMapHandle gwpixmaphandle = GetGWorldPixMap( gw ) ;
|
PixMapHandle gwpixmaphandle = GetGWorldPixMap( gw ) ;
|
||||||
LockPixels( gwpixmaphandle ) ;
|
LockPixels( gwpixmaphandle ) ;
|
||||||
bool isMonochrome = !IsPortColor( gw ) ;
|
bool isMonochrome = !IsPortColor( gw ) ;
|
||||||
@@ -2098,3 +2090,5 @@ wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const
|
|||||||
{
|
{
|
||||||
return ((wxDC *)this)->YLOG2DEVREL(y);
|
return ((wxDC *)this)->YLOG2DEVREL(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // !wxMAC_USE_CORE_GRAPHICS
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -109,9 +109,20 @@ wxWindowDC::wxWindowDC()
|
|||||||
wxWindowDC::wxWindowDC(wxWindow *window)
|
wxWindowDC::wxWindowDC(wxWindow *window)
|
||||||
{
|
{
|
||||||
m_window = window ;
|
m_window = window ;
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
if ( window->MacGetCGContextRef() )
|
||||||
|
{
|
||||||
|
m_graphicContext = new wxMacCGContext( (CGContextRef) window->MacGetCGContextRef() ) ;
|
||||||
|
m_graphicContext->SetPen( m_pen ) ;
|
||||||
|
m_graphicContext->SetBrush( m_brush ) ;
|
||||||
|
SetBackground(MacGetBackgroundBrush(window));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_graphicContext = NULL ;
|
||||||
|
// there is no out-of-order drawing on OSX
|
||||||
|
#else
|
||||||
wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
|
wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
|
||||||
WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ;
|
WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ;
|
||||||
|
|
||||||
int x , y ;
|
int x , y ;
|
||||||
x = y = 0 ;
|
x = y = 0 ;
|
||||||
window->MacWindowToRootWindow( &x , &y ) ;
|
window->MacWindowToRootWindow( &x , &y ) ;
|
||||||
@@ -121,9 +132,10 @@ wxWindowDC::wxWindowDC(wxWindow *window)
|
|||||||
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
|
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
|
||||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
||||||
m_macPort = UMAGetWindowPort( windowref ) ;
|
m_macPort = UMAGetWindowPort( windowref ) ;
|
||||||
m_ok = TRUE ;
|
|
||||||
MacSetupGraphicContext() ;
|
|
||||||
SetBackground(MacGetBackgroundBrush(window));
|
SetBackground(MacGetBackgroundBrush(window));
|
||||||
|
#endif
|
||||||
|
m_ok = TRUE ;
|
||||||
|
SetFont( window->GetFont() ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxWindowDC::~wxWindowDC()
|
wxWindowDC::~wxWindowDC()
|
||||||
@@ -149,6 +161,41 @@ wxClientDC::wxClientDC()
|
|||||||
wxClientDC::wxClientDC(wxWindow *window)
|
wxClientDC::wxClientDC(wxWindow *window)
|
||||||
{
|
{
|
||||||
m_window = window ;
|
m_window = window ;
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
m_graphicContext = NULL ;
|
||||||
|
if ( window->MacGetCGContextRef() )
|
||||||
|
{
|
||||||
|
m_graphicContext = new wxMacCGContext( (CGContextRef) window->MacGetCGContextRef() ) ;
|
||||||
|
m_graphicContext->SetPen( m_pen ) ;
|
||||||
|
m_graphicContext->SetBrush( m_brush ) ;
|
||||||
|
SetBackground(MacGetBackgroundBrush(window));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
|
||||||
|
if (!rootwindow)
|
||||||
|
return;
|
||||||
|
WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ;
|
||||||
|
wxPoint origin = window->GetClientAreaOrigin() ;
|
||||||
|
wxSize size = window->GetClientSize() ;
|
||||||
|
int x , y ;
|
||||||
|
x = origin.x ;
|
||||||
|
y = origin.y ;
|
||||||
|
window->MacWindowToRootWindow( &x , &y ) ;
|
||||||
|
m_macLocalOrigin.x = x ;
|
||||||
|
m_macLocalOrigin.y = y ;
|
||||||
|
CGrafPtr port = UMAGetWindowPort( windowref ) ;
|
||||||
|
|
||||||
|
m_graphicContext = new wxMacCGContext( port ) ;
|
||||||
|
m_graphicContext->SetPen( m_pen ) ;
|
||||||
|
m_graphicContext->SetBrush( m_brush ) ;
|
||||||
|
SetBackground(MacGetBackgroundBrush(window));
|
||||||
|
m_ok = TRUE ;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
m_ok = TRUE ;
|
||||||
|
#else
|
||||||
wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
|
wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
|
||||||
if (!rootwindow)
|
if (!rootwindow)
|
||||||
return;
|
return;
|
||||||
@@ -167,9 +214,8 @@ wxClientDC::wxClientDC(wxWindow *window)
|
|||||||
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
|
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
|
||||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ;
|
CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ;
|
||||||
m_macPort = UMAGetWindowPort( windowref ) ;
|
m_macPort = UMAGetWindowPort( windowref ) ;
|
||||||
|
|
||||||
m_ok = TRUE ;
|
m_ok = TRUE ;
|
||||||
MacSetupGraphicContext() ;
|
#endif
|
||||||
SetBackground(MacGetBackgroundBrush(window));
|
SetBackground(MacGetBackgroundBrush(window));
|
||||||
SetFont( window->GetFont() ) ;
|
SetFont( window->GetFont() ) ;
|
||||||
}
|
}
|
||||||
@@ -198,6 +244,23 @@ wxPaintDC::wxPaintDC()
|
|||||||
wxPaintDC::wxPaintDC(wxWindow *window)
|
wxPaintDC::wxPaintDC(wxWindow *window)
|
||||||
{
|
{
|
||||||
m_window = window ;
|
m_window = window ;
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
if ( window->MacGetCGContextRef() )
|
||||||
|
{
|
||||||
|
m_graphicContext = new wxMacCGContext( (CGContextRef) window->MacGetCGContextRef() ) ;
|
||||||
|
m_graphicContext->SetPen( m_pen ) ;
|
||||||
|
m_graphicContext->SetBrush( m_brush ) ;
|
||||||
|
SetBackground(MacGetBackgroundBrush(window));
|
||||||
|
m_ok = TRUE ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxLogDebug(wxT("You cannot create a wxPaintDC outside an OS-draw event") ) ;
|
||||||
|
m_graphicContext = NULL ;
|
||||||
|
m_ok = TRUE ;
|
||||||
|
}
|
||||||
|
// there is no out-of-order drawing on OSX
|
||||||
|
#else
|
||||||
wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
|
wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
|
||||||
WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ;
|
WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ;
|
||||||
wxPoint origin = window->GetClientAreaOrigin() ;
|
wxPoint origin = window->GetClientAreaOrigin() ;
|
||||||
@@ -215,10 +278,9 @@ wxPaintDC::wxPaintDC(wxWindow *window)
|
|||||||
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
|
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
|
||||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
||||||
m_macPort = UMAGetWindowPort( windowref ) ;
|
m_macPort = UMAGetWindowPort( windowref ) ;
|
||||||
|
|
||||||
m_ok = TRUE ;
|
|
||||||
MacSetupGraphicContext() ;
|
|
||||||
SetBackground(MacGetBackgroundBrush(window));
|
SetBackground(MacGetBackgroundBrush(window));
|
||||||
|
m_ok = TRUE ;
|
||||||
|
#endif
|
||||||
SetFont( window->GetFont() ) ;
|
SetFont( window->GetFont() ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -31,6 +31,7 @@ wxMemoryDC::wxMemoryDC(void)
|
|||||||
SetBackground(*wxWHITE_BRUSH);
|
SetBackground(*wxWHITE_BRUSH);
|
||||||
SetBrush(*wxWHITE_BRUSH);
|
SetBrush(*wxWHITE_BRUSH);
|
||||||
SetPen(*wxBLACK_PEN);
|
SetPen(*wxBLACK_PEN);
|
||||||
|
SetFont(*wxNORMAL_FONT) ;
|
||||||
m_ok = FALSE;
|
m_ok = FALSE;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -41,6 +42,7 @@ wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
|
|||||||
SetBackground(*wxWHITE_BRUSH);
|
SetBackground(*wxWHITE_BRUSH);
|
||||||
SetBrush(*wxWHITE_BRUSH);
|
SetBrush(*wxWHITE_BRUSH);
|
||||||
SetPen(*wxBLACK_PEN);
|
SetPen(*wxBLACK_PEN);
|
||||||
|
SetFont(*wxNORMAL_FONT) ;
|
||||||
m_ok = FALSE;
|
m_ok = FALSE;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -48,7 +50,15 @@ wxMemoryDC::~wxMemoryDC()
|
|||||||
{
|
{
|
||||||
if ( m_selected.Ok() )
|
if ( m_selected.Ok() )
|
||||||
{
|
{
|
||||||
UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) );
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
m_selected.EndRawAccess() ;
|
||||||
|
CGContextRef bmCtx = dynamic_cast<wxMacCGContext*>(m_graphicContext)->GetNativeContext() ;
|
||||||
|
delete m_graphicContext ;
|
||||||
|
m_graphicContext = NULL ;
|
||||||
|
CGContextRelease( bmCtx ) ;
|
||||||
|
#else
|
||||||
|
// TODO UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -56,20 +66,55 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
|
|||||||
{
|
{
|
||||||
if ( m_selected.Ok() )
|
if ( m_selected.Ok() )
|
||||||
{
|
{
|
||||||
UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) );
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
m_selected.EndRawAccess() ;
|
||||||
|
CGContextRef bmCtx = dynamic_cast<wxMacCGContext*>(m_graphicContext)->GetNativeContext() ;
|
||||||
|
delete m_graphicContext ;
|
||||||
|
m_graphicContext = NULL ;
|
||||||
|
CGContextRelease( bmCtx ) ;
|
||||||
|
#else
|
||||||
|
// TODO UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
m_selected = bitmap;
|
m_selected = bitmap;
|
||||||
if (m_selected.Ok())
|
if (m_selected.Ok())
|
||||||
{
|
{
|
||||||
if ( m_selected.GetHBITMAP() )
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
m_selected.UseAlpha() ;
|
||||||
|
void * data = m_selected.BeginRawAccess() ;
|
||||||
|
|
||||||
|
int bitsPerComp = 8 ;
|
||||||
|
int bytesPerPixel = 4 ;
|
||||||
|
int w = bitmap.GetWidth() ;
|
||||||
|
int h = bitmap.GetHeight() ;
|
||||||
|
CGImageAlphaInfo a = kCGImageAlphaNoneSkipFirst ;
|
||||||
|
CGColorSpaceRef genericColorSpace = wxMacGetGenericRGBColorSpace();
|
||||||
|
CGContextRef bmCtx = CGBitmapContextCreate(data , w, h, bitsPerComp , bytesPerPixel * w , genericColorSpace, a);
|
||||||
|
wxASSERT_MSG( bmCtx , wxT("Unable to create bitmap context") ) ;
|
||||||
|
|
||||||
|
CGContextSetFillColorSpace(bmCtx, genericColorSpace);
|
||||||
|
CGContextSetStrokeColorSpace(bmCtx, genericColorSpace);
|
||||||
|
|
||||||
|
if( bmCtx )
|
||||||
|
{
|
||||||
|
CGContextTranslateCTM( bmCtx , 0 , m_selected.GetHeight() ) ;
|
||||||
|
CGContextScaleCTM( bmCtx , 1 , -1 ) ;
|
||||||
|
m_graphicContext = new wxMacCGContext( bmCtx ) ;
|
||||||
|
m_graphicContext->SetPen( m_pen ) ;
|
||||||
|
m_graphicContext->SetBrush( m_brush ) ;
|
||||||
|
}
|
||||||
|
m_ok = (m_graphicContext != NULL) ;
|
||||||
|
#else
|
||||||
|
if ( ( m_macPort = m_selected.GetHBITMAP( &m_macMask ) ) != NULL )
|
||||||
{
|
{
|
||||||
m_macPort = (GrafPtr) m_selected.GetHBITMAP() ;
|
|
||||||
LockPixels( GetGWorldPixMap( (CGrafPtr) m_macPort ) ) ;
|
LockPixels( GetGWorldPixMap( (CGrafPtr) m_macPort ) ) ;
|
||||||
|
/*
|
||||||
wxMask * mask = bitmap.GetMask() ;
|
wxMask * mask = bitmap.GetMask() ;
|
||||||
if ( mask )
|
if ( mask )
|
||||||
{
|
{
|
||||||
m_macMask = mask->GetMaskBitmap() ;
|
m_macMask = mask->GetHBITMAP() ;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , 0 , 0 , m_selected.GetWidth() , m_selected.GetHeight() ) ;
|
SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , 0 , 0 , m_selected.GetWidth() , m_selected.GetHeight() ) ;
|
||||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ;
|
CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ;
|
||||||
m_ok = TRUE ;
|
m_ok = TRUE ;
|
||||||
@@ -78,6 +123,7 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
|
|||||||
{
|
{
|
||||||
m_ok = FALSE;
|
m_ok = FALSE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -106,6 +106,15 @@ bool wxMacCarbonPrinterDC::StartDoc( wxPrinterDC* dc , const wxString& WXUNUSED
|
|||||||
|
|
||||||
wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) dc->GetPrintData().m_nativePrintData ;
|
wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) dc->GetPrintData().m_nativePrintData ;
|
||||||
|
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
{
|
||||||
|
CFStringRef s[1] = { kPMGraphicsContextCoreGraphics };
|
||||||
|
CFArrayRef graphicsContextsArray = CFArrayCreate(NULL, (const void**)s, 1, &kCFTypeArrayCallBacks);
|
||||||
|
PMSessionSetDocumentFormatGeneration(native->m_macPrintSession, kPMDocumentFormatPDF, graphicsContextsArray, NULL);
|
||||||
|
CFRelease(graphicsContextsArray);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
m_err = PMSessionBeginDocument(native->m_macPrintSession,
|
m_err = PMSessionBeginDocument(native->m_macPrintSession,
|
||||||
native->m_macPrintSettings,
|
native->m_macPrintSettings,
|
||||||
native->m_macPageFormat);
|
native->m_macPageFormat);
|
||||||
@@ -143,11 +152,21 @@ void wxMacCarbonPrinterDC::StartPage( wxPrinterDC* dc )
|
|||||||
native->m_macPageFormat,
|
native->m_macPageFormat,
|
||||||
nil);
|
nil);
|
||||||
|
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
CGContextRef pageContext;
|
||||||
|
#endif
|
||||||
if ( m_err == noErr )
|
if ( m_err == noErr )
|
||||||
{
|
{
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
m_err = PMSessionGetGraphicsContext(native->m_macPrintSession,
|
m_err = PMSessionGetGraphicsContext(native->m_macPrintSession,
|
||||||
nil,
|
kPMGraphicsContextCoreGraphics,
|
||||||
|
(void**) &pageContext );
|
||||||
|
dc->MacSetCGContext(pageContext) ;
|
||||||
|
#else
|
||||||
|
m_err = PMSessionGetGraphicsContext(native->m_macPrintSession,
|
||||||
|
kPMGraphicsContextQuickdraw,
|
||||||
(void**) &dc->m_macPort );
|
(void**) &dc->m_macPort );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m_err != noErr )
|
if ( m_err != noErr )
|
||||||
@@ -162,8 +181,13 @@ void wxMacCarbonPrinterDC::StartPage( wxPrinterDC* dc )
|
|||||||
m_err = PMGetAdjustedPageRect(native->m_macPageFormat, &rPage);
|
m_err = PMGetAdjustedPageRect(native->m_macPageFormat, &rPage);
|
||||||
if ( !m_err )
|
if ( !m_err )
|
||||||
{
|
{
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
CGContextTranslateCTM( pageContext , 0 , rPage.bottom - rPage.top ) ;
|
||||||
|
CGContextScaleCTM( pageContext , 1 , -1 ) ;
|
||||||
|
#else
|
||||||
dc->m_macLocalOrigin.x = (int) rPage.left;
|
dc->m_macLocalOrigin.x = (int) rPage.left;
|
||||||
dc->m_macLocalOrigin.y = (int) rPage.top;
|
dc->m_macLocalOrigin.y = (int) rPage.top;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
// since this is a non-critical error, we set the flag back
|
// since this is a non-critical error, we set the flag back
|
||||||
m_err = noErr ;
|
m_err = noErr ;
|
||||||
@@ -313,7 +337,6 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
|
|||||||
if ( m_nativePrinterDC )
|
if ( m_nativePrinterDC )
|
||||||
{
|
{
|
||||||
m_ok = m_nativePrinterDC->Ok() ;
|
m_ok = m_nativePrinterDC->Ok() ;
|
||||||
|
|
||||||
if ( !m_ok )
|
if ( !m_ok )
|
||||||
{
|
{
|
||||||
wxString message ;
|
wxString message ;
|
||||||
@@ -321,6 +344,10 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
|
|||||||
wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ;
|
wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ;
|
||||||
dialog.ShowModal();
|
dialog.ShowModal();
|
||||||
}
|
}
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
// the cgContext will only be handed over page by page
|
||||||
|
m_graphicContext = new wxMacCGContext() ;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,6 +356,14 @@ wxPrinterDC::~wxPrinterDC(void)
|
|||||||
delete m_nativePrinterDC ;
|
delete m_nativePrinterDC ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
void wxPrinterDC::MacSetCGContext( void * cg )
|
||||||
|
{
|
||||||
|
dynamic_cast<wxMacCGContext*>(m_graphicContext)->SetNativeContext( (CGContextRef) cg ) ;
|
||||||
|
m_graphicContext->SetPen( m_pen ) ;
|
||||||
|
m_graphicContext->SetBrush( m_brush ) ;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
bool wxPrinterDC::StartDoc( const wxString& message )
|
bool wxPrinterDC::StartDoc( const wxString& message )
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( Ok() , wxT("Called wxPrinterDC::StartDoc from an invalid object") ) ;
|
wxASSERT_MSG( Ok() , wxT("Called wxPrinterDC::StartDoc from an invalid object") ) ;
|
||||||
@@ -384,10 +419,11 @@ void wxPrinterDC::StartPage(void)
|
|||||||
m_font = *wxNORMAL_FONT;
|
m_font = *wxNORMAL_FONT;
|
||||||
m_brush = *wxTRANSPARENT_BRUSH;
|
m_brush = *wxTRANSPARENT_BRUSH;
|
||||||
m_backgroundBrush = *wxWHITE_BRUSH;
|
m_backgroundBrush = *wxWHITE_BRUSH;
|
||||||
|
#if !wxMAC_USE_CORE_GRAPHICS
|
||||||
m_macFontInstalled = false ;
|
m_macFontInstalled = false ;
|
||||||
m_macBrushInstalled = false ;
|
m_macBrushInstalled = false ;
|
||||||
m_macPenInstalled = false ;
|
m_macPenInstalled = false ;
|
||||||
|
#endif
|
||||||
|
|
||||||
m_nativePrinterDC->StartPage(this) ;
|
m_nativePrinterDC->StartPage(this) ;
|
||||||
m_ok = m_nativePrinterDC->Ok() ;
|
m_ok = m_nativePrinterDC->Ok() ;
|
||||||
|
@@ -25,7 +25,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC)
|
|||||||
// Create a DC representing the whole screen
|
// Create a DC representing the whole screen
|
||||||
wxScreenDC::wxScreenDC()
|
wxScreenDC::wxScreenDC()
|
||||||
{
|
{
|
||||||
#if TARGET_CARBON
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
#else
|
||||||
m_macPort = CreateNewPort() ;
|
m_macPort = CreateNewPort() ;
|
||||||
GrafPtr port ;
|
GrafPtr port ;
|
||||||
GetPort( &port ) ;
|
GetPort( &port ) ;
|
||||||
@@ -35,31 +36,29 @@ wxScreenDC::wxScreenDC()
|
|||||||
SetPort( port ) ;
|
SetPort( port ) ;
|
||||||
m_macLocalOrigin.x = -pt.h ;
|
m_macLocalOrigin.x = -pt.h ;
|
||||||
m_macLocalOrigin.y = -pt.v ;
|
m_macLocalOrigin.y = -pt.v ;
|
||||||
#else
|
|
||||||
m_macPort = LMGetWMgrPort() ;
|
|
||||||
m_macLocalOrigin.x = 0 ;
|
|
||||||
m_macLocalOrigin.y = 0 ;
|
|
||||||
#endif
|
|
||||||
m_ok = TRUE ;
|
m_ok = TRUE ;
|
||||||
BitMap screenBits;
|
BitMap screenBits;
|
||||||
GetQDGlobalsScreenBits( &screenBits );
|
GetQDGlobalsScreenBits( &screenBits );
|
||||||
m_minX = screenBits.bounds.left ;
|
m_minX = screenBits.bounds.left ;
|
||||||
#if TARGET_CARBON
|
|
||||||
SInt16 height ;
|
SInt16 height ;
|
||||||
GetThemeMenuBarHeight( &height ) ;
|
GetThemeMenuBarHeight( &height ) ;
|
||||||
m_minY = screenBits.bounds.top + height ;
|
m_minY = screenBits.bounds.top + height ;
|
||||||
#else
|
|
||||||
m_minY = screenBits.bounds.top + LMGetMBarHeight() ;
|
|
||||||
#endif
|
|
||||||
m_maxX = screenBits.bounds.right ;
|
m_maxX = screenBits.bounds.right ;
|
||||||
m_maxY = screenBits.bounds.bottom ;
|
m_maxY = screenBits.bounds.bottom ;
|
||||||
MacSetRectRgn( (RgnHandle) m_macBoundaryClipRgn , m_minX , m_minY , m_maxX , m_maxY ) ;
|
MacSetRectRgn( (RgnHandle) m_macBoundaryClipRgn , m_minX , m_minY , m_maxX , m_maxY ) ;
|
||||||
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
|
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
|
||||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
wxScreenDC::~wxScreenDC()
|
wxScreenDC::~wxScreenDC()
|
||||||
{
|
{
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
#else
|
||||||
DisposePort( (CGrafPtr) m_macPort ) ;
|
DisposePort( (CGrafPtr) m_macPort ) ;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -46,6 +46,176 @@
|
|||||||
// private classes
|
// private classes
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifdef __WXMAC_OSX__
|
||||||
|
|
||||||
|
class wxDisplayMacPriv
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CGDirectDisplayID m_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
size_t wxDisplayBase::GetCount()
|
||||||
|
{
|
||||||
|
CGDisplayCount count;
|
||||||
|
#ifdef __WXDEBUG__
|
||||||
|
CGDisplayErr err =
|
||||||
|
#endif
|
||||||
|
CGGetActiveDisplayList(0, NULL, &count);
|
||||||
|
|
||||||
|
wxASSERT(err == CGDisplayNoErr);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxDisplayBase::GetFromPoint(const wxPoint &p)
|
||||||
|
{
|
||||||
|
CGPoint thePoint = {(float)p.x, (float)p.y};
|
||||||
|
CGDirectDisplayID theID;
|
||||||
|
CGDisplayCount theCount;
|
||||||
|
CGDisplayErr err = CGGetDisplaysWithPoint(thePoint, 1, &theID, &theCount);
|
||||||
|
wxASSERT(err == CGDisplayNoErr);
|
||||||
|
int nWhich = -1;
|
||||||
|
|
||||||
|
if (theCount)
|
||||||
|
{
|
||||||
|
theCount = GetCount();
|
||||||
|
CGDirectDisplayID* theIDs = new CGDirectDisplayID[theCount];
|
||||||
|
err = CGGetActiveDisplayList(theCount, theIDs, &theCount);
|
||||||
|
wxASSERT(err == CGDisplayNoErr);
|
||||||
|
|
||||||
|
for(nWhich = 0; nWhich < (int) theCount; ++nWhich)
|
||||||
|
{
|
||||||
|
if(theIDs[nWhich] == theID)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete[] theIDs;
|
||||||
|
|
||||||
|
if(nWhich == (int) theCount)
|
||||||
|
{
|
||||||
|
wxFAIL_MSG(wxT("Failed to find display in display list"));
|
||||||
|
nWhich = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nWhich;
|
||||||
|
}//CFUserNotification[NSBundle bundleForClass:[self class]]
|
||||||
|
|
||||||
|
wxDisplay::wxDisplay(size_t index) : wxDisplayBase ( index ) ,
|
||||||
|
m_priv ( new wxDisplayMacPriv() )
|
||||||
|
{
|
||||||
|
CGDisplayCount theCount = GetCount();
|
||||||
|
CGDirectDisplayID* theIDs = new CGDirectDisplayID[theCount];
|
||||||
|
#ifdef __WXDEBUG__
|
||||||
|
CGDisplayErr err =
|
||||||
|
#endif
|
||||||
|
CGGetActiveDisplayList(theCount, theIDs, &theCount);
|
||||||
|
|
||||||
|
wxASSERT(err == CGDisplayNoErr);
|
||||||
|
wxASSERT(index < theCount);
|
||||||
|
|
||||||
|
m_priv->m_id = theIDs[index];
|
||||||
|
|
||||||
|
delete[] theIDs;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxRect wxDisplay::GetGeometry() const
|
||||||
|
{
|
||||||
|
CGRect theRect = CGDisplayBounds(m_priv->m_id);
|
||||||
|
return wxRect( (int)theRect.origin.x,
|
||||||
|
(int)theRect.origin.y,
|
||||||
|
(int)theRect.size.width,
|
||||||
|
(int)theRect.size.height ); //floats
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxDisplay::GetDepth() const
|
||||||
|
{
|
||||||
|
return (int) CGDisplayBitsPerPixel(m_priv->m_id); //size_t
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString wxDisplay::GetName() const
|
||||||
|
{
|
||||||
|
// Macs don't name their displays...
|
||||||
|
return wxEmptyString;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int wxCFDictKeyToInt( CFDictionaryRef desc, CFStringRef key )
|
||||||
|
{
|
||||||
|
CFNumberRef value;
|
||||||
|
int num = 0;
|
||||||
|
|
||||||
|
if ( (value = (CFNumberRef) CFDictionaryGetValue(desc, key)) == NULL )
|
||||||
|
return 0;
|
||||||
|
CFNumberGetValue(value, kCFNumberIntType, &num);
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxArrayVideoModes
|
||||||
|
wxDisplay::GetModes(const wxVideoMode& mode) const
|
||||||
|
{
|
||||||
|
wxArrayVideoModes Modes;
|
||||||
|
|
||||||
|
CFArrayRef theArray = CGDisplayAvailableModes(m_priv->m_id);
|
||||||
|
|
||||||
|
for(CFIndex i = 0; i < CFArrayGetCount(theArray); ++i)
|
||||||
|
{
|
||||||
|
CFDictionaryRef theValue = (CFDictionaryRef) CFArrayGetValueAtIndex(theArray, i);
|
||||||
|
|
||||||
|
wxVideoMode theMode(wxCFDictKeyToInt(theValue, kCGDisplayWidth),
|
||||||
|
wxCFDictKeyToInt(theValue, kCGDisplayHeight),
|
||||||
|
wxCFDictKeyToInt(theValue, kCGDisplayBitsPerPixel),
|
||||||
|
wxCFDictKeyToInt(theValue, kCGDisplayRefreshRate));
|
||||||
|
|
||||||
|
if (theMode.Matches(mode))
|
||||||
|
Modes.Add(theMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Modes;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxVideoMode wxDisplay::GetCurrentMode() const
|
||||||
|
{
|
||||||
|
CFDictionaryRef theValue = CGDisplayCurrentMode (m_priv->m_id);
|
||||||
|
|
||||||
|
return wxVideoMode(wxCFDictKeyToInt(theValue, kCGDisplayWidth),
|
||||||
|
wxCFDictKeyToInt(theValue, kCGDisplayHeight),
|
||||||
|
wxCFDictKeyToInt(theValue, kCGDisplayBitsPerPixel),
|
||||||
|
wxCFDictKeyToInt(theValue, kCGDisplayRefreshRate));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxDisplay::ChangeMode(const wxVideoMode& mode)
|
||||||
|
{
|
||||||
|
//Changing to default mode (wxDefualtVideoMode) doesn't
|
||||||
|
//work because we don't have access to the system's 'scrn'
|
||||||
|
//resource which holds the user's mode which the system
|
||||||
|
//will return to after this app is done
|
||||||
|
boolean_t bExactMatch;
|
||||||
|
CFDictionaryRef theCGMode = CGDisplayBestModeForParametersAndRefreshRate (
|
||||||
|
m_priv->m_id,
|
||||||
|
(size_t)mode.bpp,
|
||||||
|
(size_t)mode.w,
|
||||||
|
(size_t)mode.h,
|
||||||
|
(double)mode.refresh,
|
||||||
|
&bExactMatch);
|
||||||
|
|
||||||
|
bool bOK = bExactMatch;
|
||||||
|
|
||||||
|
if(bOK)
|
||||||
|
bOK = CGDisplaySwitchToMode(m_priv->m_id, theCGMode) == CGDisplayNoErr;
|
||||||
|
|
||||||
|
return bOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDisplay::~wxDisplay()
|
||||||
|
{
|
||||||
|
if ( m_priv )
|
||||||
|
{
|
||||||
|
delete m_priv;
|
||||||
|
m_priv = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
class wxDisplayMacPriv
|
class wxDisplayMacPriv
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -460,4 +630,6 @@ wxDisplay::~wxDisplay()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // !OSX
|
||||||
|
|
||||||
#endif // wxUSE_DISPLAY
|
#endif // wxUSE_DISPLAY
|
||||||
|
@@ -33,20 +33,22 @@ wxIcon::wxIcon()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
wxIcon::wxIcon(const char bits[], int width, int height) :
|
wxIcon::wxIcon(const char bits[], int width, int height)
|
||||||
wxBitmap(bits, width, height)
|
|
||||||
{
|
{
|
||||||
|
wxBitmap bmp(bits,width,height) ;
|
||||||
|
CopyFromBitmap( bmp ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxIcon::wxIcon( const char **bits ) :
|
wxIcon::wxIcon( const char **bits )
|
||||||
wxBitmap(bits)
|
|
||||||
{
|
{
|
||||||
|
wxBitmap bmp(bits) ;
|
||||||
|
CopyFromBitmap( bmp ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxIcon::wxIcon( char **bits ) :
|
wxIcon::wxIcon( char **bits )
|
||||||
wxBitmap(bits)
|
|
||||||
{
|
{
|
||||||
|
wxBitmap bmp(bits) ;
|
||||||
|
CopyFromBitmap( bmp ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxIcon::wxIcon(const wxString& icon_file, int flags,
|
wxIcon::wxIcon(const wxString& icon_file, int flags,
|
||||||
@@ -59,42 +61,135 @@ wxIcon::~wxIcon()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WXHICON wxIcon::GetHICON() const
|
||||||
|
{
|
||||||
|
wxASSERT( Ok() ) ;
|
||||||
|
return (WXHICON) ((wxIconRefData*)m_refData)->GetHICON() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxIcon::GetWidth() const
|
||||||
|
{
|
||||||
|
return 32 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxIcon::GetHeight() const
|
||||||
|
{
|
||||||
|
return 32 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxIcon::Ok() const
|
||||||
|
{
|
||||||
|
return m_refData != NULL ;
|
||||||
|
}
|
||||||
|
|
||||||
bool wxIcon::LoadFile(const wxString& filename, wxBitmapType type,
|
bool wxIcon::LoadFile(const wxString& filename, wxBitmapType type,
|
||||||
int desiredWidth, int desiredHeight)
|
int desiredWidth, int desiredHeight)
|
||||||
{
|
{
|
||||||
UnRef();
|
UnRef();
|
||||||
|
|
||||||
wxBitmapHandler *handler = FindHandler(type);
|
if ( type == wxBITMAP_TYPE_ICON_RESOURCE )
|
||||||
|
|
||||||
if ( handler )
|
|
||||||
{
|
{
|
||||||
m_refData = new wxBitmapRefData;
|
OSType theId = 0 ;
|
||||||
return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight );
|
if ( filename == wxT("wxICON_INFORMATION") )
|
||||||
|
{
|
||||||
|
theId = kAlertNoteIcon ;
|
||||||
|
}
|
||||||
|
else if ( filename == wxT("wxICON_QUESTION") )
|
||||||
|
{
|
||||||
|
theId = kAlertCautionIcon ;
|
||||||
|
}
|
||||||
|
else if ( filename == wxT("wxICON_WARNING") )
|
||||||
|
{
|
||||||
|
theId = kAlertCautionIcon ;
|
||||||
|
}
|
||||||
|
else if ( filename == wxT("wxICON_ERROR") )
|
||||||
|
{
|
||||||
|
theId = kAlertStopIcon ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{/*
|
||||||
|
Str255 theName ;
|
||||||
|
OSType theType ;
|
||||||
|
wxMacStringToPascal( name , theName ) ;
|
||||||
|
|
||||||
|
Handle resHandle = GetNamedResource( 'cicn' , theName ) ;
|
||||||
|
if ( resHandle != 0L )
|
||||||
|
{
|
||||||
|
GetResInfo( resHandle , &theId , &theType , theName ) ;
|
||||||
|
ReleaseResource( resHandle ) ;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
if ( theId != 0 )
|
||||||
|
{
|
||||||
|
IconRef iconRef = NULL ;
|
||||||
|
verify_noerr(GetIconRef(kOnSystemDisk,kSystemIconsCreator,theId, &iconRef)) ;
|
||||||
|
if ( iconRef )
|
||||||
|
{
|
||||||
|
m_refData = new wxIconRefData( (WXHICON) iconRef ) ;
|
||||||
|
return TRUE ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return FALSE ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxImage loadimage(filename, type);
|
wxBitmapHandler *handler = wxBitmap::FindHandler(type);
|
||||||
if (loadimage.Ok())
|
|
||||||
|
if ( handler )
|
||||||
{
|
{
|
||||||
if ( desiredWidth == -1 )
|
wxBitmap bmp ;
|
||||||
desiredWidth = loadimage.GetWidth() ;
|
if ( handler->LoadFile(&bmp , filename, type, desiredWidth, desiredHeight ))
|
||||||
if ( desiredHeight == -1 )
|
{
|
||||||
desiredHeight = loadimage.GetHeight() ;
|
CopyFromBitmap( bmp ) ;
|
||||||
if ( desiredWidth != loadimage.GetWidth() || desiredHeight != loadimage.GetHeight() )
|
return true ;
|
||||||
loadimage.Rescale( desiredWidth , desiredHeight ) ;
|
}
|
||||||
wxBitmap bmp( loadimage );
|
return false ;
|
||||||
wxIcon *icon = (wxIcon*)(&bmp);
|
}
|
||||||
*this = *icon;
|
else
|
||||||
return true;
|
{
|
||||||
|
wxImage loadimage(filename, type);
|
||||||
|
if (loadimage.Ok())
|
||||||
|
{
|
||||||
|
if ( desiredWidth == -1 )
|
||||||
|
desiredWidth = loadimage.GetWidth() ;
|
||||||
|
if ( desiredHeight == -1 )
|
||||||
|
desiredHeight = loadimage.GetHeight() ;
|
||||||
|
if ( desiredWidth != loadimage.GetWidth() || desiredHeight != loadimage.GetHeight() )
|
||||||
|
loadimage.Rescale( desiredWidth , desiredHeight ) ;
|
||||||
|
wxBitmap bmp( loadimage );
|
||||||
|
CopyFromBitmap( bmp ) ;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxIcon::CopyFromBitmap(const wxBitmap& bmp)
|
void wxIcon::CopyFromBitmap(const wxBitmap& bmp)
|
||||||
{
|
{
|
||||||
wxIcon *icon = (wxIcon*)(&bmp);
|
UnRef() ;
|
||||||
*this = *icon;
|
|
||||||
|
m_refData = new wxIconRefData( (WXHICON) wxMacCreateIconRef( bmp ) ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxIconRefData::wxIconRefData( WXHICON icon )
|
||||||
|
{
|
||||||
|
m_iconRef = MAC_WXHICON( icon ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxIconRefData::Init()
|
||||||
|
{
|
||||||
|
m_iconRef = NULL ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxIconRefData::Free()
|
||||||
|
{
|
||||||
|
if ( m_iconRef )
|
||||||
|
{
|
||||||
|
ReleaseIconRef( m_iconRef ) ;
|
||||||
|
m_iconRef = NULL ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxICONResourceHandler, wxBitmapHandler)
|
IMPLEMENT_DYNAMIC_CLASS(wxICONResourceHandler, wxBitmapHandler)
|
||||||
@@ -102,51 +197,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxICONResourceHandler, wxBitmapHandler)
|
|||||||
bool wxICONResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
bool wxICONResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
||||||
int desiredWidth, int desiredHeight)
|
int desiredWidth, int desiredHeight)
|
||||||
{
|
{
|
||||||
short theId = -1 ;
|
wxIcon icon ;
|
||||||
if ( name == wxT("wxICON_INFORMATION") )
|
icon.LoadFile( name , wxBITMAP_TYPE_ICON_RESOURCE , desiredWidth , desiredHeight ) ;
|
||||||
{
|
bitmap->CopyFromIcon( icon ) ;
|
||||||
theId = kNoteIcon ;
|
return bitmap->Ok() ;
|
||||||
}
|
|
||||||
else if ( name == wxT("wxICON_QUESTION") )
|
|
||||||
{
|
|
||||||
theId = kCautionIcon ;
|
|
||||||
}
|
|
||||||
else if ( name == wxT("wxICON_WARNING") )
|
|
||||||
{
|
|
||||||
theId = kCautionIcon ;
|
|
||||||
}
|
|
||||||
else if ( name == wxT("wxICON_ERROR") )
|
|
||||||
{
|
|
||||||
theId = kStopIcon ;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Str255 theName ;
|
|
||||||
OSType theType ;
|
|
||||||
wxMacStringToPascal( name , theName ) ;
|
|
||||||
|
|
||||||
Handle resHandle = GetNamedResource( 'cicn' , theName ) ;
|
|
||||||
if ( resHandle != 0L )
|
|
||||||
{
|
|
||||||
GetResInfo( resHandle , &theId , &theType , theName ) ;
|
|
||||||
ReleaseResource( resHandle ) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( theId != -1 )
|
|
||||||
{
|
|
||||||
CIconHandle theIcon = (CIconHandle ) GetCIcon( theId ) ;
|
|
||||||
if ( theIcon )
|
|
||||||
{
|
|
||||||
M_BITMAPHANDLERDATA->m_hIcon = theIcon ;
|
|
||||||
M_BITMAPHANDLERDATA->m_width = 32 ;
|
|
||||||
M_BITMAPHANDLERDATA->m_height = 32 ;
|
|
||||||
|
|
||||||
M_BITMAPHANDLERDATA->m_depth = 8 ;
|
|
||||||
M_BITMAPHANDLERDATA->m_ok = true ;
|
|
||||||
M_BITMAPHANDLERDATA->m_numColors = 256 ;
|
|
||||||
M_BITMAPHANDLERDATA->m_bitmapType = kMacBitmapTypeIcon ;
|
|
||||||
return TRUE ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return FALSE ;
|
|
||||||
}
|
}
|
||||||
|
@@ -609,7 +609,6 @@ int wxListBox::GetCount() const
|
|||||||
void wxListBox::Refresh(bool eraseBack, const wxRect *rect)
|
void wxListBox::Refresh(bool eraseBack, const wxRect *rect)
|
||||||
{
|
{
|
||||||
wxControl::Refresh( eraseBack , rect ) ;
|
wxControl::Refresh( eraseBack , rect ) ;
|
||||||
// MacRedrawControl() ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if wxUSE_OWNER_DRAWN
|
#if wxUSE_OWNER_DRAWN
|
||||||
|
@@ -118,7 +118,11 @@ public:
|
|||||||
void FinishLoad();
|
void FinishLoad();
|
||||||
|
|
||||||
wxSize m_bestSize; //Original movie size
|
wxSize m_bestSize; //Original movie size
|
||||||
|
#ifdef __WXMAC_OSX__
|
||||||
struct MovieType** m_movie; //QT Movie handle/instance
|
struct MovieType** m_movie; //QT Movie handle/instance
|
||||||
|
#else
|
||||||
|
Movie m_movie ;
|
||||||
|
#endif
|
||||||
wxControl* m_ctrl; //Parent control
|
wxControl* m_ctrl; //Parent control
|
||||||
bool m_bVideo; //Whether or not we have video
|
bool m_bVideo; //Whether or not we have video
|
||||||
class _wxQTTimer* m_timer; //Timer for streaming the movie
|
class _wxQTTimer* m_timer; //Timer for streaming the movie
|
||||||
|
@@ -94,6 +94,7 @@ void wxMenuItem::UpdateItemBitmap()
|
|||||||
SetMenuItemIconHandle( mhandle , index ,
|
SetMenuItemIconHandle( mhandle , index ,
|
||||||
kMenuColorIconType , (Handle) info.u.cIconHandle ) ;
|
kMenuColorIconType , (Handle) info.u.cIconHandle ) ;
|
||||||
}
|
}
|
||||||
|
wxMacReleaseBitmapButton( &info ) ;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -121,9 +121,12 @@ bool wxMetaFile::Play(wxDC *dc)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
#else
|
||||||
wxMacPortSetter helper( dc ) ;
|
wxMacPortSetter helper( dc ) ;
|
||||||
PicHandle pict = (PicHandle) GetHMETAFILE() ;
|
PicHandle pict = (PicHandle) GetHMETAFILE() ;
|
||||||
DrawPicture( pict , &(**pict).picFrame ) ;
|
DrawPicture( pict , &(**pict).picFrame ) ;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -158,15 +161,17 @@ wxMetaFileDC::wxMetaFileDC(const wxString& filename ,
|
|||||||
wxASSERT_MSG( filename.IsEmpty() , _T("no file based metafile support yet")) ;
|
wxASSERT_MSG( filename.IsEmpty() , _T("no file based metafile support yet")) ;
|
||||||
|
|
||||||
m_metaFile = new wxMetaFile(filename) ;
|
m_metaFile = new wxMetaFile(filename) ;
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
#else
|
||||||
Rect r={0,0,height,width} ;
|
Rect r={0,0,height,width} ;
|
||||||
|
|
||||||
RectRgn( (RgnHandle) m_macBoundaryClipRgn , &r ) ;
|
RectRgn( (RgnHandle) m_macBoundaryClipRgn , &r ) ;
|
||||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
||||||
|
|
||||||
m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ;
|
m_metaFile->SetHMETAFILE( (WXHMETAFILE) OpenPicture( &r ) ) ;
|
||||||
::GetPort( (GrafPtr*) &m_macPort ) ;
|
::GetPort( (GrafPtr*) &m_macPort ) ;
|
||||||
m_ok = TRUE ;
|
m_ok = TRUE ;
|
||||||
|
#endif
|
||||||
SetMapMode(wxMM_TEXT);
|
SetMapMode(wxMM_TEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,7 +212,7 @@ bool wxMetafileDataObject::SetData(size_t len, const void *buf)
|
|||||||
Handle handle = NewHandle( len ) ;
|
Handle handle = NewHandle( len ) ;
|
||||||
SetHandleSize( handle , len ) ;
|
SetHandleSize( handle , len ) ;
|
||||||
memcpy( *handle , buf , len ) ;
|
memcpy( *handle , buf , len ) ;
|
||||||
m_metafile.SetHMETAFILE( handle ) ;
|
m_metafile.SetHMETAFILE( (WXHMETAFILE) handle ) ;
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -346,46 +346,21 @@ void wxNotebook::MacSetupTabs()
|
|||||||
wxMacStringToPascal( page->GetLabel() , info.name ) ;
|
wxMacStringToPascal( page->GetLabel() , info.name ) ;
|
||||||
m_peer->SetData<ControlTabInfoRec>( ii+1, kControlTabInfoTag, &info ) ;
|
m_peer->SetData<ControlTabInfoRec>( ii+1, kControlTabInfoTag, &info ) ;
|
||||||
m_peer->SetTabEnabled( ii + 1 , true ) ;
|
m_peer->SetTabEnabled( ii + 1 , true ) ;
|
||||||
#if TARGET_CARBON
|
|
||||||
if ( GetImageList() && GetPageImage(ii) >= 0 && UMAGetSystemVersion() >= 0x1020 )
|
if ( GetImageList() && GetPageImage(ii) >= 0 && UMAGetSystemVersion() >= 0x1020 )
|
||||||
{
|
{
|
||||||
// tab controls only support very specific types of images, therefore we are doing an odyssee
|
|
||||||
// accross the icon worlds (even Apple DTS did not find a shorter path)
|
|
||||||
// in order not to pollute the icon registry we put every icon into (OSType) 1 and immediately
|
|
||||||
// afterwards Unregister it (IconRef is ref counted, so it will stay on the tab even if we
|
|
||||||
// unregister it) in case this will ever lead to having the same icon everywhere add some kind
|
|
||||||
// of static counter
|
|
||||||
const wxBitmap* bmap = GetImageList()->GetBitmap( GetPageImage(ii ) ) ;
|
const wxBitmap* bmap = GetImageList()->GetBitmap( GetPageImage(ii ) ) ;
|
||||||
if ( bmap )
|
if ( bmap )
|
||||||
{
|
{
|
||||||
wxBitmap scaledBitmap ;
|
|
||||||
if ( bmap->GetWidth() != 16 || bmap->GetHeight() != 16 )
|
|
||||||
{
|
|
||||||
scaledBitmap = wxBitmap( bmap->ConvertToImage().Scale(16,16) ) ;
|
|
||||||
bmap = &scaledBitmap ;
|
|
||||||
}
|
|
||||||
ControlButtonContentInfo info ;
|
ControlButtonContentInfo info ;
|
||||||
wxMacCreateBitmapButton( &info , *bmap , kControlContentPictHandle) ;
|
|
||||||
IconFamilyHandle iconFamily = (IconFamilyHandle) NewHandle(0) ;
|
wxMacCreateBitmapButton( &info , *bmap ) ;
|
||||||
OSErr err = SetIconFamilyData( iconFamily, 'PICT' , (Handle) info.u.picture ) ;
|
OSStatus err = m_peer->SetData<ControlButtonContentInfo>( ii+1,kControlTabImageContentTag, &info );
|
||||||
wxASSERT_MSG( err == noErr , wxT("Error when adding bitmap") ) ;
|
|
||||||
IconRef iconRef ;
|
|
||||||
err = RegisterIconRefFromIconFamily( 'WXNG' , (OSType) 1, iconFamily, &iconRef ) ;
|
|
||||||
wxASSERT_MSG( err == noErr , wxT("Error when adding bitmap") ) ;
|
|
||||||
info.contentType = kControlContentIconRef ;
|
|
||||||
info.u.iconRef = iconRef ;
|
|
||||||
m_peer->SetData<ControlButtonContentInfo>( ii+1,kControlTabImageContentTag, &info );
|
|
||||||
wxASSERT_MSG( err == noErr , wxT("Error when setting icon on tab") ) ;
|
wxASSERT_MSG( err == noErr , wxT("Error when setting icon on tab") ) ;
|
||||||
if ( UMAGetSystemVersion() < 0x1030 )
|
wxMacReleaseBitmapButton( &info ) ;
|
||||||
{
|
|
||||||
UnregisterIconRef( 'WXNG' , (OSType) 1 ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReleaseIconRef( iconRef ) ;
|
|
||||||
DisposeHandle( (Handle) iconFamily ) ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
Rect bounds;
|
Rect bounds;
|
||||||
m_peer->GetRectInWindowCoords( &bounds ) ;
|
m_peer->GetRectInWindowCoords( &bounds ) ;
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
# pragma hdrstop
|
# pragma hdrstop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if wxUSE_LIBPNG
|
#if 0 // wxUSE_LIBPNG
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@@ -75,21 +75,22 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
|
|||||||
void wxRadioButton::SetValue(bool val)
|
void wxRadioButton::SetValue(bool val)
|
||||||
{
|
{
|
||||||
wxRadioButton *cycle;
|
wxRadioButton *cycle;
|
||||||
if ( m_peer->GetValue() == val )
|
if ( m_peer->GetValue() == val )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
m_peer->SetValue( val ) ;
|
m_peer->SetValue( val ) ;
|
||||||
if (val)
|
if (val)
|
||||||
{
|
{
|
||||||
cycle=this->NextInCycle();
|
cycle=this->NextInCycle();
|
||||||
if (cycle!=NULL) {
|
if (cycle!=NULL)
|
||||||
while (cycle!=this) {
|
{
|
||||||
cycle->SetValue(false);
|
while (cycle!=this)
|
||||||
cycle=cycle->NextInCycle();
|
{
|
||||||
}
|
cycle->SetValue(false);
|
||||||
}
|
cycle=cycle->NextInCycle();
|
||||||
}
|
}
|
||||||
MacRedrawControl() ;
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxRadioButton::GetValue() const
|
bool wxRadioButton::GetValue() const
|
||||||
|
@@ -399,6 +399,40 @@ wxRegionIterator::wxRegionIterator(const wxRegion& region)
|
|||||||
/*!
|
/*!
|
||||||
* Reset iterator for a new /e region.
|
* Reset iterator for a new /e region.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
OSStatus wxMacRegionToRectsCounterCallback (
|
||||||
|
UInt16 message, RgnHandle region, const Rect *rect, void *data)
|
||||||
|
{
|
||||||
|
long *m_numRects = (long*) data ;
|
||||||
|
if ( message == kQDRegionToRectsMsgInit )
|
||||||
|
{
|
||||||
|
(*m_numRects) = 0 ;
|
||||||
|
}
|
||||||
|
else if (message == kQDRegionToRectsMsgParse)
|
||||||
|
{
|
||||||
|
(*m_numRects) += 1 ;
|
||||||
|
}
|
||||||
|
return noErr;
|
||||||
|
}
|
||||||
|
|
||||||
|
class RegionToRectsCallbackData
|
||||||
|
{
|
||||||
|
public :
|
||||||
|
wxRect* m_rects ;
|
||||||
|
long m_current ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
OSStatus wxMacRegionToRectsSetterCallback (
|
||||||
|
UInt16 message, RgnHandle region, const Rect *rect, void *data)
|
||||||
|
{
|
||||||
|
if (message == kQDRegionToRectsMsgParse)
|
||||||
|
{
|
||||||
|
RegionToRectsCallbackData *cb = (RegionToRectsCallbackData*) data ;
|
||||||
|
cb->m_rects[cb->m_current] = wxRect( rect->left , rect->top , rect->right - rect->left , rect->bottom - rect->top ) ;
|
||||||
|
}
|
||||||
|
return noErr;
|
||||||
|
}
|
||||||
|
|
||||||
void wxRegionIterator::Reset(const wxRegion& region)
|
void wxRegionIterator::Reset(const wxRegion& region)
|
||||||
{
|
{
|
||||||
m_current = 0;
|
m_current = 0;
|
||||||
@@ -413,15 +447,25 @@ void wxRegionIterator::Reset(const wxRegion& region)
|
|||||||
m_numRects = 0;
|
m_numRects = 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// we cannot dissolve it into rects on mac
|
RegionToRectsUPP proc = NewRegionToRectsUPP (wxMacRegionToRectsCounterCallback);
|
||||||
m_rects = new wxRect[1];
|
|
||||||
Rect rect ;
|
OSStatus err = noErr;
|
||||||
GetRegionBounds( OTHER_M_REGION( region ) , &rect ) ;
|
err = QDRegionToRects (OTHER_M_REGION( region ) , kQDParseRegionFromTopLeft, proc, (void*)&m_numRects);
|
||||||
m_rects[0].x = rect.left;
|
if (err == noErr)
|
||||||
m_rects[0].y = rect.top;
|
{
|
||||||
m_rects[0].width = rect.right - rect.left;
|
DisposeRegionToRectsUPP (proc);
|
||||||
m_rects[0].height = rect.bottom - rect.top;
|
proc = NewRegionToRectsUPP (wxMacRegionToRectsSetterCallback);
|
||||||
m_numRects = 1;
|
m_rects = new wxRect[m_numRects];
|
||||||
|
RegionToRectsCallbackData data ;
|
||||||
|
data.m_rects = m_rects ;
|
||||||
|
data.m_current = 0 ;
|
||||||
|
QDRegionToRects (OTHER_M_REGION( region ) , kQDParseRegionFromTopLeft, proc, (void*)&data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_numRects = 0 ;
|
||||||
|
}
|
||||||
|
DisposeRegionToRectsUPP (proc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -270,6 +270,8 @@ wxRendererMac::DrawSplitterSash(wxWindow *win,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
#else
|
||||||
CGContextRef cgContext ;
|
CGContextRef cgContext ;
|
||||||
Rect bounds ;
|
Rect bounds ;
|
||||||
GetPortBounds( (CGrafPtr) dc.m_macPort , &bounds ) ;
|
GetPortBounds( (CGrafPtr) dc.m_macPort , &bounds ) ;
|
||||||
@@ -285,6 +287,7 @@ wxRendererMac::DrawSplitterSash(wxWindow *win,
|
|||||||
HIThemeDrawPaneSplitter( &splitterRect , &drawInfo , cgContext , kHIThemeOrientationNormal ) ;
|
HIThemeDrawPaneSplitter( &splitterRect , &drawInfo , cgContext , kHIThemeOrientationNormal ) ;
|
||||||
}
|
}
|
||||||
QDEndCGContext( (CGrafPtr) dc.m_macPort , &cgContext ) ;
|
QDEndCGContext( (CGrafPtr) dc.m_macPort , &cgContext ) ;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -84,9 +84,6 @@ void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageS
|
|||||||
m_peer->SetMinimum( 0 ) ;
|
m_peer->SetMinimum( 0 ) ;
|
||||||
m_peer->SetValue( position ) ;
|
m_peer->SetValue( position ) ;
|
||||||
m_peer->SetViewSize( m_viewSize ) ;
|
m_peer->SetViewSize( m_viewSize ) ;
|
||||||
|
|
||||||
if ( refresh )
|
|
||||||
MacRedrawControl() ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -176,39 +176,45 @@ wxMenu* wxTaskBarIcon::DoCreatePopupMenu()
|
|||||||
// Operations:
|
// Operations:
|
||||||
bool wxTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& tooltip)
|
bool wxTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& tooltip)
|
||||||
{
|
{
|
||||||
wxMask* mask = icon.GetMask();
|
wxBitmap bmp( icon ) ;
|
||||||
|
OSStatus err = noErr ;
|
||||||
|
|
||||||
|
CGImageRef pImage;
|
||||||
|
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
pImage = bmp.CGImageCreate() ;
|
||||||
|
#else
|
||||||
|
wxMask* mask = bmp.GetMask();
|
||||||
if (!mask)
|
if (!mask)
|
||||||
{
|
{
|
||||||
// Make a mask with no transparent pixels
|
// Make a mask with no transparent pixels
|
||||||
wxBitmap bmp(icon.GetWidth(), icon.GetHeight());
|
wxBitmap mbmp(icon.GetWidth(), icon.GetHeight());
|
||||||
wxMemoryDC dc;
|
wxMemoryDC dc;
|
||||||
dc.SelectObject(bmp);
|
dc.SelectObject(mbmp);
|
||||||
dc.SetBackground(*wxBLACK_BRUSH);
|
dc.SetBackground(*wxBLACK_BRUSH);
|
||||||
dc.Clear();
|
dc.Clear();
|
||||||
dc.SelectObject(wxNullBitmap);
|
dc.SelectObject(wxNullBitmap);
|
||||||
mask = new wxMask(bmp, *wxWHITE);
|
bmp.SetMask( new wxMask(mbmp, *wxWHITE) ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGImageRef pImage;
|
|
||||||
|
|
||||||
//create the icon from the bitmap and mask bitmap contained within
|
//create the icon from the bitmap and mask bitmap contained within
|
||||||
OSStatus err = CreateCGImageFromPixMaps(
|
WXHBITMAP iconport ;
|
||||||
GetGWorldPixMap(MAC_WXHBITMAP(icon.GetHBITMAP())),
|
WXHBITMAP maskport ;
|
||||||
GetGWorldPixMap(MAC_WXHBITMAP(mask->GetMaskBitmap())),
|
iconport = bmp.GetHBITMAP( &maskport ) ;
|
||||||
&pImage
|
err = CreateCGImageFromPixMaps(
|
||||||
);
|
GetGWorldPixMap(MAC_WXHBITMAP(iconport)),
|
||||||
|
GetGWorldPixMap(MAC_WXHBITMAP(maskport)),
|
||||||
|
&pImage
|
||||||
|
);
|
||||||
wxASSERT(err == 0);
|
wxASSERT(err == 0);
|
||||||
|
#endif
|
||||||
|
wxASSERT(pImage != NULL );
|
||||||
err = SetApplicationDockTileImage(pImage);
|
err = SetApplicationDockTileImage(pImage);
|
||||||
|
|
||||||
wxASSERT(err == 0);
|
wxASSERT(err == 0);
|
||||||
|
|
||||||
if (pImage != NULL)
|
if (pImage != NULL)
|
||||||
CGImageRelease(pImage);
|
CGImageRelease(pImage);
|
||||||
|
|
||||||
if (!icon.GetMask())
|
|
||||||
delete mask;
|
|
||||||
|
|
||||||
return m_iconAdded = err == noErr;
|
return m_iconAdded = err == noErr;
|
||||||
}
|
}
|
||||||
|
@@ -967,7 +967,7 @@ bool wxTextCtrl::MacSetupCursor( const wxPoint& pt )
|
|||||||
{
|
{
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
#if !TARGET_API_MAC_OSX
|
||||||
// user pane implementation
|
// user pane implementation
|
||||||
|
|
||||||
void wxTextCtrl::MacControlUserPaneDrawProc(wxInt16 part)
|
void wxTextCtrl::MacControlUserPaneDrawProc(wxInt16 part)
|
||||||
@@ -1005,7 +1005,7 @@ wxInt16 wxTextCtrl::MacControlUserPaneFocusProc(wxInt16 action)
|
|||||||
void wxTextCtrl::MacControlUserPaneBackgroundProc(void* info)
|
void wxTextCtrl::MacControlUserPaneBackgroundProc(void* info)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// implementation base class
|
// implementation base class
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -260,6 +260,8 @@ wxToolBarTool::wxToolBarTool(wxToolBar *tbar,
|
|||||||
CreateBevelButtonControl( window , &toolrect , CFSTR("") , kControlBevelButtonNormalBevel , behaviour , &info ,
|
CreateBevelButtonControl( window , &toolrect , CFSTR("") , kControlBevelButtonNormalBevel , behaviour , &info ,
|
||||||
0 , 0 , 0 , &m_controlHandle ) ;
|
0 , 0 , 0 , &m_controlHandle ) ;
|
||||||
|
|
||||||
|
wxMacReleaseBitmapButton( &info ) ;
|
||||||
|
|
||||||
InstallControlEventHandler( (ControlRef) m_controlHandle, GetwxMacToolBarToolEventHandlerUPP(),
|
InstallControlEventHandler( (ControlRef) m_controlHandle, GetwxMacToolBarToolEventHandlerUPP(),
|
||||||
GetEventTypeCount(eventList), eventList, this,NULL);
|
GetEventTypeCount(eventList), eventList, this,NULL);
|
||||||
|
|
||||||
@@ -555,6 +557,8 @@ bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos), wxToolBarToolBase *tool)
|
|||||||
void wxToolBar::OnPaint(wxPaintEvent& event)
|
void wxToolBar::OnPaint(wxPaintEvent& event)
|
||||||
{
|
{
|
||||||
wxPaintDC dc(this) ;
|
wxPaintDC dc(this) ;
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
#else
|
||||||
wxMacPortSetter helper(&dc) ;
|
wxMacPortSetter helper(&dc) ;
|
||||||
int w, h ;
|
int w, h ;
|
||||||
GetSize( &w , &h ) ;
|
GetSize( &w , &h ) ;
|
||||||
@@ -575,33 +579,35 @@ void wxToolBar::OnPaint(wxPaintEvent& event)
|
|||||||
{
|
{
|
||||||
#if TARGET_API_MAC_OSX
|
#if TARGET_API_MAC_OSX
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
|
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
|
||||||
if ( UMAGetSystemVersion() >= 0x1030 )
|
if ( UMAGetSystemVersion() >= 0x1030 )
|
||||||
{
|
|
||||||
HIRect hiToolbarrect = CGRectMake( dc.YLOG2DEVMAC(0) , dc.XLOG2DEVMAC(0) ,
|
|
||||||
dc.YLOG2DEVREL(h) , dc.XLOG2DEVREL(w) );
|
|
||||||
CGContextRef cgContext ;
|
|
||||||
Rect bounds ;
|
|
||||||
GetPortBounds( (CGrafPtr) dc.m_macPort , &bounds ) ;
|
|
||||||
QDBeginCGContext( (CGrafPtr) dc.m_macPort , &cgContext ) ;
|
|
||||||
CGContextTranslateCTM( cgContext , 0 , bounds.bottom - bounds.top ) ;
|
|
||||||
CGContextScaleCTM( cgContext , 1 , -1 ) ;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
HIThemeBackgroundDrawInfo drawInfo ;
|
HIRect hiToolbarrect = CGRectMake( dc.YLOG2DEVMAC(0) , dc.XLOG2DEVMAC(0) ,
|
||||||
drawInfo.version = 0 ;
|
dc.YLOG2DEVREL(h) , dc.XLOG2DEVREL(w) );
|
||||||
drawInfo.state = kThemeStateActive ;
|
CGContextRef cgContext ;
|
||||||
drawInfo.kind = kThemeBackgroundMetal ;
|
Rect bounds ;
|
||||||
HIThemeApplyBackground( &hiToolbarrect, &drawInfo , cgContext,kHIThemeOrientationNormal) ;
|
GetPortBounds( (CGrafPtr) dc.m_macPort , &bounds ) ;
|
||||||
|
QDBeginCGContext( (CGrafPtr) dc.m_macPort , &cgContext ) ;
|
||||||
|
CGContextTranslateCTM( cgContext , 0 , bounds.bottom - bounds.top ) ;
|
||||||
|
CGContextScaleCTM( cgContext , 1 , -1 ) ;
|
||||||
|
|
||||||
|
{
|
||||||
|
HIThemeBackgroundDrawInfo drawInfo ;
|
||||||
|
drawInfo.version = 0 ;
|
||||||
|
drawInfo.state = kThemeStateActive ;
|
||||||
|
drawInfo.kind = kThemeBackgroundMetal ;
|
||||||
|
HIThemeApplyBackground( &hiToolbarrect, &drawInfo , cgContext,kHIThemeOrientationNormal) ;
|
||||||
|
}
|
||||||
|
QDEndCGContext( (CGrafPtr) dc.m_macPort , &cgContext ) ;
|
||||||
}
|
}
|
||||||
QDEndCGContext( (CGrafPtr) dc.m_macPort , &cgContext ) ;
|
else
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
|
UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
event.Skip() ;
|
event.Skip() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -218,9 +218,9 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
|
|||||||
#if 0
|
#if 0
|
||||||
// in case we would need a coregraphics compliant background erase first
|
// in case we would need a coregraphics compliant background erase first
|
||||||
// now usable to track redraws
|
// now usable to track redraws
|
||||||
CGContextRef cgContext = cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef) ;
|
|
||||||
if ( thisWindow->MacIsUserPane() )
|
if ( thisWindow->MacIsUserPane() )
|
||||||
{
|
{
|
||||||
|
CGContextRef cgContext = cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef) ;
|
||||||
static float color = 0.5 ;
|
static float color = 0.5 ;
|
||||||
static channel = 0 ;
|
static channel = 0 ;
|
||||||
HIRect bounds;
|
HIRect bounds;
|
||||||
@@ -237,9 +237,16 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
|
|||||||
channel = 0 ;
|
channel = 0 ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
CGContextRef cgContext = cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef) ;
|
||||||
|
thisWindow->MacSetCGContextRef( cgContext ) ;
|
||||||
#endif
|
#endif
|
||||||
if ( thisWindow->MacDoRedraw( updateRgn , cEvent.GetTicks() ) )
|
if ( thisWindow->MacDoRedraw( updateRgn , cEvent.GetTicks() ) )
|
||||||
result = noErr ;
|
result = noErr ;
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
thisWindow->MacSetCGContextRef( NULL ) ;
|
||||||
|
#endif
|
||||||
if ( allocatedRgn )
|
if ( allocatedRgn )
|
||||||
DisposeRgn( allocatedRgn ) ;
|
DisposeRgn( allocatedRgn ) ;
|
||||||
}
|
}
|
||||||
@@ -406,6 +413,8 @@ pascal OSStatus wxMacWindowEventHandler( EventHandlerCallRef handler , EventRef
|
|||||||
|
|
||||||
DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacWindowEventHandler )
|
DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacWindowEventHandler )
|
||||||
|
|
||||||
|
#if !TARGET_API_MAC_OSX
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// UserPane events for non OSX builds
|
// UserPane events for non OSX builds
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -517,6 +526,8 @@ ControlUserPaneActivateUPP gControlUserPaneActivateUPP = NULL ;
|
|||||||
ControlUserPaneFocusUPP gControlUserPaneFocusUPP = NULL ;
|
ControlUserPaneFocusUPP gControlUserPaneFocusUPP = NULL ;
|
||||||
ControlUserPaneBackgroundUPP gControlUserPaneBackgroundUPP = NULL ;
|
ControlUserPaneBackgroundUPP gControlUserPaneBackgroundUPP = NULL ;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
// implementation
|
// implementation
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@@ -690,9 +701,12 @@ void wxWindowMac::Init()
|
|||||||
m_macBackgroundBrush = wxNullBrush ;
|
m_macBackgroundBrush = wxNullBrush ;
|
||||||
|
|
||||||
m_macIsUserPane = TRUE;
|
m_macIsUserPane = TRUE;
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
m_cgContextRef = NULL ;
|
||||||
|
#endif
|
||||||
// make sure all proc ptrs are available
|
// make sure all proc ptrs are available
|
||||||
|
|
||||||
|
#if !TARGET_API_MAC_OSX
|
||||||
if ( gControlUserPaneDrawUPP == NULL )
|
if ( gControlUserPaneDrawUPP == NULL )
|
||||||
{
|
{
|
||||||
gControlUserPaneDrawUPP = NewControlUserPaneDrawUPP( wxMacControlUserPaneDrawProc ) ;
|
gControlUserPaneDrawUPP = NewControlUserPaneDrawUPP( wxMacControlUserPaneDrawProc ) ;
|
||||||
@@ -704,6 +718,7 @@ void wxWindowMac::Init()
|
|||||||
gControlUserPaneFocusUPP = NewControlUserPaneFocusUPP( wxMacControlUserPaneFocusProc ) ;
|
gControlUserPaneFocusUPP = NewControlUserPaneFocusUPP( wxMacControlUserPaneFocusProc ) ;
|
||||||
gControlUserPaneBackgroundUPP = NewControlUserPaneBackgroundUPP( wxMacControlUserPaneBackgroundProc ) ;
|
gControlUserPaneBackgroundUPP = NewControlUserPaneBackgroundUPP( wxMacControlUserPaneBackgroundProc ) ;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if ( wxMacLiveScrollbarActionUPP == NULL )
|
if ( wxMacLiveScrollbarActionUPP == NULL )
|
||||||
{
|
{
|
||||||
wxMacLiveScrollbarActionUPP = NewControlActionUPP( wxMacLiveScrollbarActionProc );
|
wxMacLiveScrollbarActionUPP = NewControlActionUPP( wxMacLiveScrollbarActionProc );
|
||||||
@@ -2210,24 +2225,6 @@ void wxWindowMac::Thaw()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowMac::MacRedrawControl()
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
if ( *m_peer && MacGetTopLevelWindowRef() && m_peer->IsVisible())
|
|
||||||
{
|
|
||||||
#if TARGET_API_MAC_CARBON
|
|
||||||
Update() ;
|
|
||||||
#else
|
|
||||||
wxClientDC dc(this) ;
|
|
||||||
wxMacPortSetter helper(&dc) ;
|
|
||||||
wxMacWindowClipper clipper(this) ;
|
|
||||||
wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ;
|
|
||||||
UMADrawControl( *m_peer ) ;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/* TODO
|
/* TODO
|
||||||
void wxWindowMac::OnPaint(wxPaintEvent& event)
|
void wxWindowMac::OnPaint(wxPaintEvent& event)
|
||||||
{
|
{
|
||||||
@@ -2482,8 +2479,29 @@ void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect)
|
|||||||
SectRect( &scrollrect , &r , &scrollrect ) ;
|
SectRect( &scrollrect , &r , &scrollrect ) ;
|
||||||
}
|
}
|
||||||
ScrollRect( &scrollrect , dx , dy , updateRgn ) ;
|
ScrollRect( &scrollrect , dx , dy , updateRgn ) ;
|
||||||
|
|
||||||
|
// now scroll the former update region as well and add the new update region
|
||||||
|
|
||||||
|
WindowRef rootWindow = (WindowRef) MacGetTopLevelWindowRef() ;
|
||||||
|
RgnHandle formerUpdateRgn = NewRgn() ;
|
||||||
|
RgnHandle scrollRgn = NewRgn() ;
|
||||||
|
RectRgn( scrollRgn , &scrollrect ) ;
|
||||||
|
GetWindowUpdateRgn( rootWindow , formerUpdateRgn ) ;
|
||||||
|
Point pt = {0,0} ;
|
||||||
|
LocalToGlobal( &pt ) ;
|
||||||
|
OffsetRgn( formerUpdateRgn , -pt.h , -pt.v ) ;
|
||||||
|
SectRgn( formerUpdateRgn , scrollRgn , formerUpdateRgn ) ;
|
||||||
|
if ( !EmptyRgn( formerUpdateRgn ) )
|
||||||
|
{
|
||||||
|
MacOffsetRgn( formerUpdateRgn , dx , dy ) ;
|
||||||
|
SectRgn( formerUpdateRgn , scrollRgn , formerUpdateRgn ) ;
|
||||||
|
InvalWindowRgn(rootWindow , formerUpdateRgn ) ;
|
||||||
|
}
|
||||||
|
InvalWindowRgn(rootWindow , updateRgn ) ;
|
||||||
|
DisposeRgn( updateRgn ) ;
|
||||||
|
DisposeRgn( formerUpdateRgn ) ;
|
||||||
|
DisposeRgn( scrollRgn ) ;
|
||||||
}
|
}
|
||||||
// ScrollWindowRect( (WindowRef) MacGetTopLevelWindowRef() , &scrollrect , dx , dy , kScrollWindowInvalidate, updateRgn ) ;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2819,6 +2837,7 @@ bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr , long time )
|
|||||||
bool handled = false ;
|
bool handled = false ;
|
||||||
Rect updatebounds ;
|
Rect updatebounds ;
|
||||||
GetRegionBounds( updatergn , &updatebounds ) ;
|
GetRegionBounds( updatergn , &updatebounds ) ;
|
||||||
|
|
||||||
// wxLogDebug("update for %s bounds %d , %d , %d , %d",typeid(*this).name() , updatebounds.left , updatebounds.top , updatebounds.right , updatebounds.bottom ) ;
|
// wxLogDebug("update for %s bounds %d , %d , %d , %d",typeid(*this).name() , updatebounds.left , updatebounds.top , updatebounds.right , updatebounds.bottom ) ;
|
||||||
if ( !EmptyRgn(updatergn) )
|
if ( !EmptyRgn(updatergn) )
|
||||||
{
|
{
|
||||||
@@ -2886,6 +2905,8 @@ bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr , long time )
|
|||||||
{
|
{
|
||||||
if ( RectInRgn( &childRect , updatergn ) )
|
if ( RectInRgn( &childRect , updatergn ) )
|
||||||
{
|
{
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
#else
|
||||||
// paint custom borders
|
// paint custom borders
|
||||||
wxNcPaintEvent eventNc( child->GetId() );
|
wxNcPaintEvent eventNc( child->GetId() );
|
||||||
eventNc.SetEventObject( child );
|
eventNc.SetEventObject( child );
|
||||||
@@ -2896,54 +2917,26 @@ bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr , long time )
|
|||||||
wxMacPortSetter helper(&dc) ;
|
wxMacPortSetter helper(&dc) ;
|
||||||
child->MacPaintBorders( dc.m_macLocalOrigin.x + childRect.left , dc.m_macLocalOrigin.y + childRect.top) ;
|
child->MacPaintBorders( dc.m_macLocalOrigin.x + childRect.left , dc.m_macLocalOrigin.y + childRect.top) ;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( child->m_peer->NeedsFocusRect() && child->m_peer->HasFocus() )
|
if ( child->m_peer->NeedsFocusRect() && child->m_peer->HasFocus() )
|
||||||
{
|
{
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
#else
|
||||||
wxWindowDC dc(this) ;
|
wxWindowDC dc(this) ;
|
||||||
dc.SetClippingRegion(wxRegion(updatergn));
|
dc.SetClippingRegion(wxRegion(updatergn));
|
||||||
wxMacPortSetter helper(&dc) ;
|
wxMacPortSetter helper(&dc) ;
|
||||||
Rect r = childRect ;
|
Rect r = childRect ;
|
||||||
OffsetRect( &r , dc.m_macLocalOrigin.x , dc.m_macLocalOrigin.y ) ;
|
OffsetRect( &r , dc.m_macLocalOrigin.x , dc.m_macLocalOrigin.y ) ;
|
||||||
DrawThemeFocusRect( &r , true ) ;
|
DrawThemeFocusRect( &r , true ) ;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return handled ;
|
return handled ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowMac::MacRedraw( WXHRGN updatergnr , long time, bool erase)
|
|
||||||
{
|
|
||||||
RgnHandle updatergn = (RgnHandle) updatergnr ;
|
|
||||||
// updatergn is always already clipped to our boundaries
|
|
||||||
// if we are in compositing mode then it is in relative to the upper left of the control
|
|
||||||
// if we are in non-compositing, then it is relatvie to the uppder left of the content area
|
|
||||||
// of the toplevel window
|
|
||||||
// it is in window coordinates, not in client coordinates
|
|
||||||
|
|
||||||
// ownUpdateRgn is the area that this window has to repaint, it is in window coordinates
|
|
||||||
RgnHandle ownUpdateRgn = NewRgn() ;
|
|
||||||
CopyRgn( updatergn , ownUpdateRgn ) ;
|
|
||||||
|
|
||||||
if ( MacGetTopLevelWindow()->MacUsesCompositing() == false )
|
|
||||||
{
|
|
||||||
Rect bounds;
|
|
||||||
m_peer->GetRectInWindowCoords( &bounds );
|
|
||||||
RgnHandle controlRgn = NewRgn();
|
|
||||||
RectRgn( controlRgn, &bounds );
|
|
||||||
//KO: This sets the ownUpdateRgn to the area of this control that is inside
|
|
||||||
// the window update region
|
|
||||||
SectRgn( ownUpdateRgn, controlRgn, ownUpdateRgn );
|
|
||||||
DisposeRgn( controlRgn );
|
|
||||||
|
|
||||||
//KO: convert ownUpdateRgn to local coordinates
|
|
||||||
OffsetRgn( ownUpdateRgn, -bounds.left, -bounds.top );
|
|
||||||
}
|
|
||||||
|
|
||||||
MacDoRedraw( ownUpdateRgn , time ) ;
|
|
||||||
DisposeRgn( ownUpdateRgn ) ;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
WXWindow wxWindowMac::MacGetTopLevelWindowRef() const
|
WXWindow wxWindowMac::MacGetTopLevelWindowRef() const
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user