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
|
||||
|
||||
typedef unsigned char WXCOLORREF[6];
|
||||
typedef void* WXCGIMAGEREF;
|
||||
typedef void* WXHBITMAP;
|
||||
typedef void* WXHMETAFILE;
|
||||
typedef void* WXHICON;
|
||||
//typedef void* WXHMETAFILE;
|
||||
//typedef void* WXHICON;
|
||||
typedef void* WXHCURSOR;
|
||||
typedef void* WXHRGN;
|
||||
typedef void* WXRECTPTR;
|
||||
@@ -2236,6 +2237,9 @@ typedef unsigned int WXUINT;
|
||||
typedef unsigned long WXDWORD;
|
||||
typedef unsigned short WXWORD;
|
||||
|
||||
typedef WX_OPAQUE_TYPE(CIconHandle ) * WXHICON ;
|
||||
typedef WX_OPAQUE_TYPE(PicHandle ) * WXHMETAFILE ;
|
||||
|
||||
|
||||
/* typedef void* WXWidget; */
|
||||
/* typedef void* WXWindow; */
|
||||
|
@@ -20,6 +20,7 @@
|
||||
|
||||
// Bitmap
|
||||
class WXDLLEXPORT wxBitmap;
|
||||
class wxBitmapRefData ;
|
||||
class WXDLLEXPORT wxBitmapHandler;
|
||||
class WXDLLEXPORT wxControl;
|
||||
class WXDLLEXPORT wxCursor;
|
||||
@@ -29,8 +30,11 @@ class WXDLLEXPORT wxImage;
|
||||
class WXDLLEXPORT wxPixelDataBase;
|
||||
|
||||
// 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
|
||||
// transparently.
|
||||
// Internally it is stored as a 8 bit deep memory chunk, 0 = black means the source will be drawn
|
||||
// 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
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxMask)
|
||||
@@ -43,64 +47,41 @@ public:
|
||||
// the transparent area
|
||||
wxMask(const wxBitmap& bitmap, const wxColour& colour);
|
||||
|
||||
// Construct a mask from a bitmap and a palette index indicating
|
||||
// the transparent area
|
||||
wxMask(const wxBitmap& bitmap, int paletteIndex);
|
||||
|
||||
// Construct a mask from a mono bitmap (copies the bitmap).
|
||||
// Construct a mask from a mono bitmap (black meaning show pixels, white meaning transparent)
|
||||
wxMask(const wxBitmap& bitmap);
|
||||
|
||||
// implementation helper only : construct a mask from a 8 bit memory buffer
|
||||
wxMask(const wxMemoryBuffer& buf, int width , int height , int bytesPerRow ) ;
|
||||
|
||||
~wxMask();
|
||||
|
||||
bool Create(const wxBitmap& bitmap, const wxColour& colour);
|
||||
bool Create(const wxBitmap& bitmap, int paletteIndex);
|
||||
bool Create(const wxBitmap& bitmap);
|
||||
bool Create(const wxMemoryBuffer& buf, int width , int height , int bytesPerRow ) ;
|
||||
|
||||
// Implementation
|
||||
bool PointMasked(int x, int y);
|
||||
inline WXHBITMAP GetMaskBitmap() const { return m_maskBitmap; }
|
||||
inline void SetMaskBitmap(WXHBITMAP bmp) { m_maskBitmap = bmp; }
|
||||
int GetDepth() const { return m_depth ; }
|
||||
void SetDepth( int depth ) { m_depth = depth ; }
|
||||
protected:
|
||||
WXHBITMAP m_maskBitmap;
|
||||
int m_depth ;
|
||||
};
|
||||
// Implementation below
|
||||
|
||||
enum { kMacBitmapTypeUnknownType , kMacBitmapTypeGrafWorld, kMacBitmapTypePict , kMacBitmapTypeIcon } ;
|
||||
void Init() ;
|
||||
|
||||
class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData
|
||||
{
|
||||
DECLARE_NO_COPY_CLASS(wxBitmapRefData)
|
||||
// a 8 bit depth mask
|
||||
void* GetRawAccess() const;
|
||||
int GetBytesPerRow() const { return m_bytesPerRow ; }
|
||||
// renders/updates native representation when necessary
|
||||
void RealizeNative() ;
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
WXHBITMAP GetHBITMAP() const ;
|
||||
#endif
|
||||
|
||||
friend class WXDLLEXPORT wxBitmap;
|
||||
friend class WXDLLEXPORT wxIcon;
|
||||
friend class WXDLLEXPORT wxCursor;
|
||||
public:
|
||||
wxBitmapRefData();
|
||||
~wxBitmapRefData();
|
||||
|
||||
public:
|
||||
private:
|
||||
wxMemoryBuffer m_memBuf ;
|
||||
int m_bytesPerRow ;
|
||||
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;
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
WXHBITMAP m_maskBitmap ;
|
||||
#endif
|
||||
};
|
||||
|
||||
#define M_BITMAPDATA ((wxBitmapRefData *)m_refData)
|
||||
|
||||
class WXDLLEXPORT wxBitmapHandler: public wxBitmapHandlerBase
|
||||
{
|
||||
public:
|
||||
@@ -129,7 +110,6 @@ public:
|
||||
|
||||
// Copy constructors
|
||||
wxBitmap(const wxBitmap& bitmap)
|
||||
: wxBitmapBase()
|
||||
{ Ref(bitmap); }
|
||||
|
||||
// Initialize with raw data.
|
||||
@@ -152,6 +132,9 @@ public:
|
||||
// Convert from wxImage:
|
||||
wxBitmap(const wxImage& image, int depth = -1);
|
||||
|
||||
// Convert from wxIcon
|
||||
wxBitmap(const wxIcon& icon) { CopyFromIcon(icon); }
|
||||
|
||||
~wxBitmap();
|
||||
|
||||
wxImage ConvertToImage() const;
|
||||
@@ -161,9 +144,13 @@ public:
|
||||
|
||||
virtual bool Create(int width, int height, int depth = -1);
|
||||
virtual bool Create(void *data, wxBitmapType type, int width, int height, int depth = 1);
|
||||
// virtual bool Create( WXHICON 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;
|
||||
|
||||
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);
|
||||
|
||||
@@ -171,13 +158,18 @@ public:
|
||||
int GetWidth() const;
|
||||
int GetHeight() const;
|
||||
int GetDepth() const;
|
||||
int GetQuality() const;
|
||||
void SetWidth(int w);
|
||||
void SetHeight(int h);
|
||||
void SetDepth(int d);
|
||||
void SetQuality(int q);
|
||||
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
|
||||
wxPalette* GetPalette() const;
|
||||
void SetPalette(const wxPalette& palette);
|
||||
@@ -186,8 +178,6 @@ public:
|
||||
wxMask *GetMask() const;
|
||||
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 bool operator != (const wxBitmap& bitmap) const { return m_refData != bitmap.m_refData; }
|
||||
@@ -198,18 +188,26 @@ public:
|
||||
void *GetRawData(wxPixelDataBase& data, int bpp);
|
||||
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();
|
||||
|
||||
public:
|
||||
WXHBITMAP GetHBITMAP() const;
|
||||
inline WXHICON GetHICON() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_hIcon : 0); }
|
||||
WXHMETAFILE GetPict(bool *created = NULL ) const;
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
// returns the 'native' implementation, a GWorldPtr for the content and one for the mask
|
||||
WXHBITMAP GetHBITMAP( WXHBITMAP * mask = NULL ) const;
|
||||
#endif
|
||||
|
||||
void SetHBITMAP(WXHBITMAP bmp);
|
||||
void SetHICON(WXHICON ico);
|
||||
void SetPict( WXHMETAFILE pict ) ;
|
||||
|
||||
bool FreeResource(bool force = FALSE);
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
// returns a CGImageRef which must released after usage with CGImageRelease
|
||||
WXCGIMAGEREF CGImageCreate() const ;
|
||||
#endif
|
||||
// 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
|
||||
// _WX_BITMAP_H_
|
||||
|
@@ -25,6 +25,14 @@
|
||||
#define wxUSE_DEBUG_NEW_ALWAYS 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* use OS X CoreGraphics (1) or QuickDraw (0) for rendering
|
||||
*/
|
||||
|
||||
#ifndef wxMAC_USE_CORE_GRAPHICS
|
||||
#define wxMAC_USE_CORE_GRAPHICS 0
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* _WX_MAC_CHKCONF_H_ */
|
||||
|
||||
|
@@ -18,27 +18,6 @@
|
||||
|
||||
#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
|
||||
class WXDLLEXPORT wxCursor: public wxBitmap
|
||||
{
|
||||
@@ -65,7 +44,7 @@ public:
|
||||
~wxCursor();
|
||||
|
||||
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 bool operator == (const wxCursor& cursor) const { return m_refData == cursor.m_refData; }
|
||||
@@ -74,7 +53,7 @@ public:
|
||||
void MacInstall() const ;
|
||||
|
||||
void SetHCURSOR(WXHCURSOR cursor);
|
||||
inline WXHCURSOR GetHCURSOR() const { return (M_CURSORDATA ? M_CURSORDATA->m_hCursor : 0); }
|
||||
inline WXHCURSOR GetHCURSOR() const ;
|
||||
private :
|
||||
void CreateFromImage(const wxImage & image) ;
|
||||
};
|
||||
|
@@ -44,7 +44,43 @@
|
||||
extern int wxPageNumber;
|
||||
|
||||
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
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -186,9 +222,10 @@ class WXDLLEXPORT wxDC: public wxDCBase
|
||||
else
|
||||
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 ; }
|
||||
static void MacSetupBackgroundForCurrentPort(const wxBrush& background ) ;
|
||||
#endif
|
||||
//
|
||||
|
||||
protected:
|
||||
@@ -257,37 +294,45 @@ protected:
|
||||
// Begin implementation for Mac
|
||||
public:
|
||||
|
||||
WXHDC m_macPort ;
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
WXHBITMAP m_macMask ;
|
||||
#endif
|
||||
|
||||
// in order to preserve the const inheritance of the virtual functions, we have to
|
||||
// use mutable variables starting from CWPro 5
|
||||
|
||||
void MacInstallFont() const ;
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
void MacInstallPen() 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_macPenInstalled ;
|
||||
mutable bool m_macBrushInstalled ;
|
||||
|
||||
WXHRGN m_macBoundaryClipRgn ;
|
||||
WXHRGN m_macCurrentClipRgn ;
|
||||
wxPoint m_macLocalOrigin ;
|
||||
void MacSetupPort( wxMacPortStateHelper* ph ) const ;
|
||||
void MacCleanupPort( wxMacPortStateHelper* ph ) const ;
|
||||
mutable void* m_macATSUIStyle ;
|
||||
mutable wxMacPortStateHelper* m_macCurrentPortStateHelper ;
|
||||
mutable bool m_macFormerAliasState ;
|
||||
mutable short m_macFormerAliasSize ;
|
||||
mutable bool m_macAliasWasEnabled ;
|
||||
mutable void* m_macForegroundPixMap ;
|
||||
mutable void* m_macBackgroundPixMap ;
|
||||
#endif
|
||||
|
||||
// CoreGraphics
|
||||
|
||||
wxMacCGContext * m_macGraphicContext ;
|
||||
void MacSetupGraphicContext() ;
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -37,7 +37,9 @@ class WXDLLEXPORT wxPrinterDC: public wxDC
|
||||
virtual void EndPage(void) ;
|
||||
wxPrintData& GetPrintData() { return m_printData; }
|
||||
virtual void DoGetSize( int *width, int *height ) const;
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
void MacSetCGContext( void * cg ) ;
|
||||
#endif
|
||||
protected:
|
||||
wxPrintData m_printData ;
|
||||
wxNativePrinterDC* m_nativePrinterDC ;
|
||||
|
@@ -1,8 +1,8 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: display.h
|
||||
// Purpose: wxDisplay class customization for Mac
|
||||
// Author: Brian Victor
|
||||
// Modified by: Royce Mitchell III
|
||||
// Author: Brian Victor/Royce Mitchel for non OSX / Ryan Norton for OS X
|
||||
// Modified by:
|
||||
// Created: 06/21/02
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) wxWidgets team
|
||||
|
@@ -19,14 +19,13 @@
|
||||
#include "wx/bitmap.h"
|
||||
|
||||
// Icon
|
||||
class WXDLLEXPORT wxIcon: public wxBitmap
|
||||
class WXDLLEXPORT wxIcon: public wxGDIObject
|
||||
{
|
||||
public:
|
||||
wxIcon();
|
||||
|
||||
// Copy constructors
|
||||
wxIcon(const wxIcon& icon)
|
||||
: wxBitmap()
|
||||
{ Ref(icon); }
|
||||
|
||||
wxIcon(const char **data);
|
||||
@@ -55,6 +54,17 @@ public:
|
||||
// ctors, assignment operators...), but it's ok to have such function
|
||||
void CopyFromBitmap(const wxBitmap& bmp);
|
||||
|
||||
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
|
||||
|
||||
#include "wx/dc.h"
|
||||
#include "wx/window.h"
|
||||
|
||||
class wxMacPortStateHelper
|
||||
@@ -345,19 +346,22 @@ private :
|
||||
typedef wxMacUPP<NMProcPtr,NMUPP,NewNMUPP,DisposeNMUPP> wxMacNMUPP ;
|
||||
|
||||
#if wxUSE_GUI
|
||||
|
||||
/*
|
||||
GWorldPtr wxMacCreateGWorld( int width , int height , int depth ) ;
|
||||
void wxMacDestroyGWorld( GWorldPtr gw ) ;
|
||||
PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL ) ;
|
||||
CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize ) ;
|
||||
void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) ;
|
||||
CTabHandle wxMacCreateColorTable( int numColors ) ;
|
||||
*/
|
||||
IconRef wxMacCreateIconRef(const wxBitmap& bmp) ;
|
||||
void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType = 0 ) ;
|
||||
void wxMacReleaseBitmapButton( ControlButtonContentInfo*info ) ;
|
||||
|
||||
#define MAC_WXCOLORREF(a) (*((RGBColor*)&(a)))
|
||||
#define MAC_WXHBITMAP(a) (GWorldPtr(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_WXHRGN(a) (RgnHandle(a))
|
||||
#define MAC_WXHWND(a) (WindowPtr(a))
|
||||
@@ -540,6 +544,142 @@ protected :
|
||||
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
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@@ -22,9 +22,9 @@ class WXDLLEXPORT wxStaticBitmap: public wxStaticBitmapBase
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxStaticBitmap)
|
||||
public:
|
||||
inline wxStaticBitmap() { }
|
||||
wxStaticBitmap() { }
|
||||
|
||||
inline wxStaticBitmap(wxWindow *parent, wxWindowID id,
|
||||
wxStaticBitmap(wxWindow *parent, wxWindowID id,
|
||||
const wxBitmap& label,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
|
@@ -163,7 +163,7 @@ public:
|
||||
|
||||
virtual void MacVisibilityChanged() ;
|
||||
virtual void MacEnabledStateChanged() ;
|
||||
|
||||
#ifndef __WXMAC_OSX__
|
||||
virtual void MacControlUserPaneDrawProc(wxInt16 part) ;
|
||||
virtual wxInt16 MacControlUserPaneHitTestProc(wxInt16 x, wxInt16 y) ;
|
||||
virtual wxInt16 MacControlUserPaneTrackingProc(wxInt16 x, wxInt16 y, void* actionProc) ;
|
||||
@@ -172,6 +172,7 @@ public:
|
||||
virtual void MacControlUserPaneActivateProc(bool activating) ;
|
||||
virtual wxInt16 MacControlUserPaneFocusProc(wxInt16 action) ;
|
||||
virtual void MacControlUserPaneBackgroundProc(void* info) ;
|
||||
#endif
|
||||
|
||||
wxMacTextControl* GetPeer() const { return (wxMacTextControl*) m_peer ; }
|
||||
protected:
|
||||
|
@@ -17,6 +17,7 @@
|
||||
#endif
|
||||
|
||||
#include "wx/brush.h"
|
||||
#include "wx/dc.h"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// forward declarations
|
||||
@@ -161,7 +162,6 @@ public:
|
||||
public:
|
||||
virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) ;
|
||||
virtual bool MacDoRedraw( WXHRGN updatergn , long time ) ;
|
||||
virtual void MacRedraw( WXHRGN updatergn , long time , bool erase) ;
|
||||
virtual bool MacCanFocus() const ;
|
||||
|
||||
// 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; }
|
||||
virtual void MacInstallEventHandler(WXWidget native) ;
|
||||
virtual void MacRedrawControl();
|
||||
WXEVENTHANDLERREF MacGetControlEventHandler() { return m_macControlEventHandler ; }
|
||||
void MacPostControlCreate(const wxPoint& pos, const wxSize& size) ;
|
||||
|
||||
#ifndef __WXMAC_OSX__
|
||||
virtual void MacControlUserPaneDrawProc(wxInt16 part) ;
|
||||
virtual wxInt16 MacControlUserPaneHitTestProc(wxInt16 x, wxInt16 y) ;
|
||||
virtual wxInt16 MacControlUserPaneTrackingProc(wxInt16 x, wxInt16 y, void* actionProc) ;
|
||||
@@ -224,7 +223,7 @@ public:
|
||||
virtual void MacControlUserPaneActivateProc(bool activating) ;
|
||||
virtual wxInt16 MacControlUserPaneFocusProc(wxInt16 action) ;
|
||||
virtual void MacControlUserPaneBackgroundProc(void* info) ;
|
||||
|
||||
#endif
|
||||
// translate wxWidgets coords into ones suitable to be passed to
|
||||
// the CreateControl calls
|
||||
//
|
||||
@@ -241,7 +240,10 @@ public:
|
||||
|
||||
// flash the current invalid area, useful for debugging in OSX double buffered situation
|
||||
void MacFlashInvalidAreas() ;
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
void * MacGetCGContextRef() { return m_cgContextRef ; }
|
||||
void MacSetCGContextRef(void * cg) { m_cgContextRef = cg ; }
|
||||
#endif
|
||||
protected:
|
||||
// For controls like radiobuttons which are really composite
|
||||
wxList m_subControls;
|
||||
@@ -249,6 +251,9 @@ protected:
|
||||
unsigned int m_frozenness;
|
||||
// the peer object, allowing for cleaner API support
|
||||
wxMacControl* m_peer ;
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
void * m_cgContextRef ;
|
||||
#endif
|
||||
// true if is is not a native control but a wxWindow control
|
||||
bool m_macIsUserPane ;
|
||||
wxBrush m_macBackgroundBrush ;
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -66,11 +66,6 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
|
||||
|
||||
m_bmpNormal = bitmap;
|
||||
|
||||
wxBitmapRefData * bmap = NULL ;
|
||||
|
||||
if ( m_bmpNormal.Ok() )
|
||||
bmap = (wxBitmapRefData*) ( m_bmpNormal.GetRefData()) ;
|
||||
|
||||
ControlButtonContentInfo info ;
|
||||
wxMacCreateBitmapButton( &info , m_bmpNormal ) ;
|
||||
|
||||
@@ -80,7 +75,7 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
|
||||
(( style & wxBU_AUTODRAW ) ? kControlBevelButtonSmallBevel : kControlBevelButtonNormalBevel ) ,
|
||||
kControlBehaviorOffsetContents , &info , 0 , 0 , 0 , m_peer->GetControlRefAddr() ) );
|
||||
|
||||
|
||||
wxMacReleaseBitmapButton( &info ) ;
|
||||
wxASSERT_MSG( m_peer != NULL && m_peer->Ok() , wxT("No valid mac control") ) ;
|
||||
|
||||
MacPostControlCreate(pos,size) ;
|
||||
@@ -99,6 +94,7 @@ void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
|
||||
{
|
||||
m_peer->SetData( kControlButtonPart , kControlBevelButtonContentTag , info ) ;
|
||||
}
|
||||
wxMacReleaseBitmapButton( &info ) ;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -27,6 +27,27 @@
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
|
||||
#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 kwxCursorBlank = 1 ;
|
||||
const short kwxCursorPencil = 2 ;
|
||||
@@ -181,8 +202,8 @@ CursHandle wxGetStockCursor( int number )
|
||||
|
||||
wxCursorRefData::wxCursorRefData()
|
||||
{
|
||||
m_width = 16;
|
||||
m_height = 16;
|
||||
SetWidth( 16 );
|
||||
SetHeight( 16 );
|
||||
m_hCursor = NULL ;
|
||||
m_disposeHandle = false ;
|
||||
m_releaseHandle = false ;
|
||||
@@ -242,6 +263,16 @@ bool wxCursor::CreateFromXpm(const char **bits)
|
||||
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 retval = 0 ;
|
||||
|
@@ -250,7 +250,9 @@ wxBitmapDataObject::wxBitmapDataObject(
|
||||
Init();
|
||||
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);
|
||||
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 ) ;
|
||||
memcpy( *picHandle , pBuf , nSize ) ;
|
||||
m_pictHandle = picHandle ;
|
||||
// ownership is transferred to the bitmap
|
||||
m_pictCreated = false ;
|
||||
Rect frame = (**picHandle).picFrame ;
|
||||
|
||||
m_bitmap.SetPict( picHandle ) ;
|
||||
/*
|
||||
m_bitmap.GetBitmapData()->SetPict( (WXHMETAFILE) picHandle ) ;
|
||||
m_bitmap.SetWidth( frame.right - frame.left ) ;
|
||||
m_bitmap.SetHeight( frame.bottom - frame.top ) ;
|
||||
*/
|
||||
return m_bitmap.Ok();
|
||||
}
|
||||
|
@@ -16,6 +16,8 @@
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#include "wx/dc.h"
|
||||
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
#include "wx/app.h"
|
||||
#include "wx/mac/uma.h"
|
||||
#include "wx/dcmemory.h"
|
||||
@@ -285,11 +287,6 @@ wxDC::~wxDC(void)
|
||||
DisposeRgn( (RgnHandle) m_macCurrentClipRgn ) ;
|
||||
}
|
||||
|
||||
void wxDC::MacSetupGraphicContext()
|
||||
{
|
||||
// no-op for QuickDraw
|
||||
}
|
||||
|
||||
void wxDC::MacSetupPort(wxMacPortStateHelper* help) const
|
||||
{
|
||||
#ifdef __WXDEBUG__
|
||||
@@ -360,14 +357,9 @@ void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask
|
||||
//m_logicalFunction == wxSRC_OR ? srcOr :
|
||||
//m_logicalFunction == wxSRC_AND ? SRCAND :
|
||||
srcCopy );
|
||||
if ( bmp.GetBitmapType() == kMacBitmapTypePict ) {
|
||||
Rect bitmaprect = { 0 , 0 , hh, ww };
|
||||
::OffsetRect( &bitmaprect, xx, yy ) ;
|
||||
::DrawPicture( (PicHandle) bmp.GetPict(), &bitmaprect ) ;
|
||||
}
|
||||
else if ( bmp.GetBitmapType() == kMacBitmapTypeGrafWorld )
|
||||
{
|
||||
GWorldPtr bmapworld = MAC_WXHBITMAP( bmp.GetHBITMAP() );
|
||||
|
||||
GWorldPtr maskworld = NULL ;
|
||||
GWorldPtr bmapworld = MAC_WXHBITMAP( bmp.GetHBITMAP((WXHBITMAP*)&maskworld) );
|
||||
PixMapHandle bmappixels ;
|
||||
// Set foreground and background colours (for bitmaps depth = 1)
|
||||
if(bmp.GetDepth() == 1)
|
||||
@@ -389,18 +381,18 @@ void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask
|
||||
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 ( useMask && maskworld )
|
||||
{
|
||||
if( LockPixels(GetGWorldPixMap(MAC_WXHBITMAP(bmp.GetMask()->GetMaskBitmap()))))
|
||||
if( LockPixels(GetGWorldPixMap(MAC_WXHBITMAP(maskworld))))
|
||||
{
|
||||
CopyDeepMask
|
||||
(
|
||||
GetPortBitMapForCopyBits(bmapworld),
|
||||
GetPortBitMapForCopyBits(MAC_WXHBITMAP(bmp.GetMask()->GetMaskBitmap())),
|
||||
GetPortBitMapForCopyBits(MAC_WXHBITMAP(maskworld)),
|
||||
GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ),
|
||||
&source, &source, &dest, mode, NULL
|
||||
);
|
||||
UnlockPixels(GetGWorldPixMap(MAC_WXHBITMAP(bmp.GetMask()->GetMaskBitmap())));
|
||||
UnlockPixels(GetGWorldPixMap(MAC_WXHBITMAP(maskworld)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -409,13 +401,7 @@ void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask
|
||||
&source, &dest, mode, NULL ) ;
|
||||
}
|
||||
UnlockPixels( bmappixels ) ;
|
||||
}
|
||||
else if ( bmp.GetBitmapType() == kMacBitmapTypeIcon )
|
||||
{
|
||||
Rect bitmaprect = { 0 , 0 , bmp.GetHeight(), bmp.GetWidth() } ;
|
||||
OffsetRect( &bitmaprect, xx, yy ) ;
|
||||
PlotCIconHandle( &bitmaprect , atNone , ttNone , MAC_WXHICON(bmp.GetHICON()) ) ;
|
||||
}
|
||||
|
||||
m_macPenInstalled = false ;
|
||||
m_macBrushInstalled = 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(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 )
|
||||
@@ -1942,9 +1934,9 @@ void wxDC::MacInstallBrush() const
|
||||
int height = bitmap->GetHeight() ;
|
||||
GWorldPtr gw = NULL ;
|
||||
if ( m_brush.GetStyle() == wxSTIPPLE )
|
||||
gw = MAC_WXHBITMAP(bitmap->GetHBITMAP()) ;
|
||||
gw = MAC_WXHBITMAP(bitmap->GetHBITMAP(NULL)) ;
|
||||
else
|
||||
gw = MAC_WXHBITMAP(bitmap->GetMask()->GetMaskBitmap()) ;
|
||||
gw = MAC_WXHBITMAP(bitmap->GetMask()->GetHBITMAP()) ;
|
||||
PixMapHandle gwpixmaphandle = GetGWorldPixMap( gw ) ;
|
||||
LockPixels( gwpixmaphandle ) ;
|
||||
bool isMonochrome = !IsPortColor( gw ) ;
|
||||
@@ -2098,3 +2090,5 @@ wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const
|
||||
{
|
||||
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)
|
||||
{
|
||||
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() ;
|
||||
WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ;
|
||||
|
||||
int x , y ;
|
||||
x = y = 0 ;
|
||||
window->MacWindowToRootWindow( &x , &y ) ;
|
||||
@@ -121,9 +132,10 @@ wxWindowDC::wxWindowDC(wxWindow *window)
|
||||
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
|
||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
||||
m_macPort = UMAGetWindowPort( windowref ) ;
|
||||
m_ok = TRUE ;
|
||||
MacSetupGraphicContext() ;
|
||||
SetBackground(MacGetBackgroundBrush(window));
|
||||
#endif
|
||||
m_ok = TRUE ;
|
||||
SetFont( window->GetFont() ) ;
|
||||
}
|
||||
|
||||
wxWindowDC::~wxWindowDC()
|
||||
@@ -149,6 +161,41 @@ wxClientDC::wxClientDC()
|
||||
wxClientDC::wxClientDC(wxWindow *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() ;
|
||||
if (!rootwindow)
|
||||
return;
|
||||
@@ -167,9 +214,8 @@ wxClientDC::wxClientDC(wxWindow *window)
|
||||
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
|
||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ;
|
||||
m_macPort = UMAGetWindowPort( windowref ) ;
|
||||
|
||||
m_ok = TRUE ;
|
||||
MacSetupGraphicContext() ;
|
||||
#endif
|
||||
SetBackground(MacGetBackgroundBrush(window));
|
||||
SetFont( window->GetFont() ) ;
|
||||
}
|
||||
@@ -198,6 +244,23 @@ wxPaintDC::wxPaintDC()
|
||||
wxPaintDC::wxPaintDC(wxWindow *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() ;
|
||||
WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ;
|
||||
wxPoint origin = window->GetClientAreaOrigin() ;
|
||||
@@ -215,10 +278,9 @@ wxPaintDC::wxPaintDC(wxWindow *window)
|
||||
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
|
||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
||||
m_macPort = UMAGetWindowPort( windowref ) ;
|
||||
|
||||
m_ok = TRUE ;
|
||||
MacSetupGraphicContext() ;
|
||||
SetBackground(MacGetBackgroundBrush(window));
|
||||
m_ok = TRUE ;
|
||||
#endif
|
||||
SetFont( window->GetFont() ) ;
|
||||
}
|
||||
|
||||
|
@@ -31,6 +31,7 @@ wxMemoryDC::wxMemoryDC(void)
|
||||
SetBackground(*wxWHITE_BRUSH);
|
||||
SetBrush(*wxWHITE_BRUSH);
|
||||
SetPen(*wxBLACK_PEN);
|
||||
SetFont(*wxNORMAL_FONT) ;
|
||||
m_ok = FALSE;
|
||||
};
|
||||
|
||||
@@ -41,6 +42,7 @@ wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
|
||||
SetBackground(*wxWHITE_BRUSH);
|
||||
SetBrush(*wxWHITE_BRUSH);
|
||||
SetPen(*wxBLACK_PEN);
|
||||
SetFont(*wxNORMAL_FONT) ;
|
||||
m_ok = FALSE;
|
||||
};
|
||||
|
||||
@@ -48,7 +50,15 @@ wxMemoryDC::~wxMemoryDC()
|
||||
{
|
||||
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() )
|
||||
{
|
||||
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;
|
||||
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 ) ) ;
|
||||
/*
|
||||
wxMask * mask = bitmap.GetMask() ;
|
||||
if ( mask )
|
||||
{
|
||||
m_macMask = mask->GetMaskBitmap() ;
|
||||
m_macMask = mask->GetHBITMAP() ;
|
||||
}
|
||||
*/
|
||||
SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , 0 , 0 , m_selected.GetWidth() , m_selected.GetHeight() ) ;
|
||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ;
|
||||
m_ok = TRUE ;
|
||||
@@ -78,6 +123,7 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
|
||||
{
|
||||
m_ok = FALSE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -106,6 +106,15 @@ bool wxMacCarbonPrinterDC::StartDoc( wxPrinterDC* dc , const wxString& WXUNUSED
|
||||
|
||||
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,
|
||||
native->m_macPrintSettings,
|
||||
native->m_macPageFormat);
|
||||
@@ -143,11 +152,21 @@ void wxMacCarbonPrinterDC::StartPage( wxPrinterDC* dc )
|
||||
native->m_macPageFormat,
|
||||
nil);
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
CGContextRef pageContext;
|
||||
#endif
|
||||
if ( m_err == noErr )
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
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 );
|
||||
#endif
|
||||
}
|
||||
|
||||
if ( m_err != noErr )
|
||||
@@ -162,8 +181,13 @@ void wxMacCarbonPrinterDC::StartPage( wxPrinterDC* dc )
|
||||
m_err = PMGetAdjustedPageRect(native->m_macPageFormat, &rPage);
|
||||
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.y = (int) rPage.top;
|
||||
#endif
|
||||
}
|
||||
// since this is a non-critical error, we set the flag back
|
||||
m_err = noErr ;
|
||||
@@ -313,7 +337,6 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
|
||||
if ( m_nativePrinterDC )
|
||||
{
|
||||
m_ok = m_nativePrinterDC->Ok() ;
|
||||
|
||||
if ( !m_ok )
|
||||
{
|
||||
wxString message ;
|
||||
@@ -321,6 +344,10 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
|
||||
wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ;
|
||||
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 ;
|
||||
}
|
||||
|
||||
#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 )
|
||||
{
|
||||
wxASSERT_MSG( Ok() , wxT("Called wxPrinterDC::StartDoc from an invalid object") ) ;
|
||||
@@ -384,10 +419,11 @@ void wxPrinterDC::StartPage(void)
|
||||
m_font = *wxNORMAL_FONT;
|
||||
m_brush = *wxTRANSPARENT_BRUSH;
|
||||
m_backgroundBrush = *wxWHITE_BRUSH;
|
||||
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
m_macFontInstalled = false ;
|
||||
m_macBrushInstalled = false ;
|
||||
m_macPenInstalled = false ;
|
||||
#endif
|
||||
|
||||
m_nativePrinterDC->StartPage(this) ;
|
||||
m_ok = m_nativePrinterDC->Ok() ;
|
||||
|
@@ -25,7 +25,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC)
|
||||
// Create a DC representing the whole screen
|
||||
wxScreenDC::wxScreenDC()
|
||||
{
|
||||
#if TARGET_CARBON
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
#else
|
||||
m_macPort = CreateNewPort() ;
|
||||
GrafPtr port ;
|
||||
GetPort( &port ) ;
|
||||
@@ -35,31 +36,29 @@ wxScreenDC::wxScreenDC()
|
||||
SetPort( port ) ;
|
||||
m_macLocalOrigin.x = -pt.h ;
|
||||
m_macLocalOrigin.y = -pt.v ;
|
||||
#else
|
||||
m_macPort = LMGetWMgrPort() ;
|
||||
m_macLocalOrigin.x = 0 ;
|
||||
m_macLocalOrigin.y = 0 ;
|
||||
#endif
|
||||
|
||||
m_ok = TRUE ;
|
||||
BitMap screenBits;
|
||||
GetQDGlobalsScreenBits( &screenBits );
|
||||
m_minX = screenBits.bounds.left ;
|
||||
#if TARGET_CARBON
|
||||
|
||||
SInt16 height ;
|
||||
GetThemeMenuBarHeight( &height ) ;
|
||||
m_minY = screenBits.bounds.top + height ;
|
||||
#else
|
||||
m_minY = screenBits.bounds.top + LMGetMBarHeight() ;
|
||||
#endif
|
||||
|
||||
m_maxX = screenBits.bounds.right ;
|
||||
m_maxY = screenBits.bounds.bottom ;
|
||||
MacSetRectRgn( (RgnHandle) m_macBoundaryClipRgn , m_minX , m_minY , m_maxX , m_maxY ) ;
|
||||
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
|
||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
wxScreenDC::~wxScreenDC()
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
#else
|
||||
DisposePort( (CGrafPtr) m_macPort ) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@@ -46,6 +46,176 @@
|
||||
// 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
|
||||
{
|
||||
public:
|
||||
@@ -460,4 +630,6 @@ wxDisplay::~wxDisplay()
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !OSX
|
||||
|
||||
#endif // wxUSE_DISPLAY
|
||||
|
@@ -33,20 +33,22 @@ wxIcon::wxIcon()
|
||||
{
|
||||
}
|
||||
|
||||
wxIcon::wxIcon(const char bits[], int width, int height) :
|
||||
wxBitmap(bits, width, height)
|
||||
wxIcon::wxIcon(const char bits[], int width, int height)
|
||||
{
|
||||
|
||||
wxBitmap bmp(bits,width,height) ;
|
||||
CopyFromBitmap( bmp ) ;
|
||||
}
|
||||
|
||||
wxIcon::wxIcon( const char **bits ) :
|
||||
wxBitmap(bits)
|
||||
wxIcon::wxIcon( const char **bits )
|
||||
{
|
||||
wxBitmap bmp(bits) ;
|
||||
CopyFromBitmap( bmp ) ;
|
||||
}
|
||||
|
||||
wxIcon::wxIcon( char **bits ) :
|
||||
wxBitmap(bits)
|
||||
wxIcon::wxIcon( char **bits )
|
||||
{
|
||||
wxBitmap bmp(bits) ;
|
||||
CopyFromBitmap( bmp ) ;
|
||||
}
|
||||
|
||||
wxIcon::wxIcon(const wxString& icon_file, int flags,
|
||||
@@ -59,17 +61,90 @@ 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,
|
||||
int desiredWidth, int desiredHeight)
|
||||
{
|
||||
UnRef();
|
||||
|
||||
wxBitmapHandler *handler = FindHandler(type);
|
||||
if ( type == wxBITMAP_TYPE_ICON_RESOURCE )
|
||||
{
|
||||
OSType theId = 0 ;
|
||||
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
|
||||
{
|
||||
wxBitmapHandler *handler = wxBitmap::FindHandler(type);
|
||||
|
||||
if ( handler )
|
||||
{
|
||||
m_refData = new wxBitmapRefData;
|
||||
return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight );
|
||||
wxBitmap bmp ;
|
||||
if ( handler->LoadFile(&bmp , filename, type, desiredWidth, desiredHeight ))
|
||||
{
|
||||
CopyFromBitmap( bmp ) ;
|
||||
return true ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -83,18 +158,38 @@ bool wxIcon::LoadFile(const wxString& filename, wxBitmapType type,
|
||||
if ( desiredWidth != loadimage.GetWidth() || desiredHeight != loadimage.GetHeight() )
|
||||
loadimage.Rescale( desiredWidth , desiredHeight ) ;
|
||||
wxBitmap bmp( loadimage );
|
||||
wxIcon *icon = (wxIcon*)(&bmp);
|
||||
*this = *icon;
|
||||
CopyFromBitmap( bmp ) ;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
void wxIcon::CopyFromBitmap(const wxBitmap& bmp)
|
||||
{
|
||||
wxIcon *icon = (wxIcon*)(&bmp);
|
||||
*this = *icon;
|
||||
UnRef() ;
|
||||
|
||||
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)
|
||||
@@ -102,51 +197,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxICONResourceHandler, wxBitmapHandler)
|
||||
bool wxICONResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
||||
int desiredWidth, int desiredHeight)
|
||||
{
|
||||
short theId = -1 ;
|
||||
if ( name == wxT("wxICON_INFORMATION") )
|
||||
{
|
||||
theId = kNoteIcon ;
|
||||
}
|
||||
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 ;
|
||||
wxIcon icon ;
|
||||
icon.LoadFile( name , wxBITMAP_TYPE_ICON_RESOURCE , desiredWidth , desiredHeight ) ;
|
||||
bitmap->CopyFromIcon( icon ) ;
|
||||
return bitmap->Ok() ;
|
||||
}
|
||||
|
@@ -609,7 +609,6 @@ int wxListBox::GetCount() const
|
||||
void wxListBox::Refresh(bool eraseBack, const wxRect *rect)
|
||||
{
|
||||
wxControl::Refresh( eraseBack , rect ) ;
|
||||
// MacRedrawControl() ;
|
||||
}
|
||||
|
||||
#if wxUSE_OWNER_DRAWN
|
||||
|
@@ -118,7 +118,11 @@ public:
|
||||
void FinishLoad();
|
||||
|
||||
wxSize m_bestSize; //Original movie size
|
||||
#ifdef __WXMAC_OSX__
|
||||
struct MovieType** m_movie; //QT Movie handle/instance
|
||||
#else
|
||||
Movie m_movie ;
|
||||
#endif
|
||||
wxControl* m_ctrl; //Parent control
|
||||
bool m_bVideo; //Whether or not we have video
|
||||
class _wxQTTimer* m_timer; //Timer for streaming the movie
|
||||
|
@@ -94,6 +94,7 @@ void wxMenuItem::UpdateItemBitmap()
|
||||
SetMenuItemIconHandle( mhandle , index ,
|
||||
kMenuColorIconType , (Handle) info.u.cIconHandle ) ;
|
||||
}
|
||||
wxMacReleaseBitmapButton( &info ) ;
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -121,9 +121,12 @@ bool wxMetaFile::Play(wxDC *dc)
|
||||
return FALSE;
|
||||
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
#else
|
||||
wxMacPortSetter helper( dc ) ;
|
||||
PicHandle pict = (PicHandle) GetHMETAFILE() ;
|
||||
DrawPicture( pict , &(**pict).picFrame ) ;
|
||||
#endif
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@@ -158,15 +161,17 @@ wxMetaFileDC::wxMetaFileDC(const wxString& filename ,
|
||||
wxASSERT_MSG( filename.IsEmpty() , _T("no file based metafile support yet")) ;
|
||||
|
||||
m_metaFile = new wxMetaFile(filename) ;
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
#else
|
||||
Rect r={0,0,height,width} ;
|
||||
|
||||
RectRgn( (RgnHandle) m_macBoundaryClipRgn , &r ) ;
|
||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
||||
|
||||
m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ;
|
||||
m_metaFile->SetHMETAFILE( (WXHMETAFILE) OpenPicture( &r ) ) ;
|
||||
::GetPort( (GrafPtr*) &m_macPort ) ;
|
||||
m_ok = TRUE ;
|
||||
|
||||
#endif
|
||||
SetMapMode(wxMM_TEXT);
|
||||
}
|
||||
|
||||
@@ -207,7 +212,7 @@ bool wxMetafileDataObject::SetData(size_t len, const void *buf)
|
||||
Handle handle = NewHandle( len ) ;
|
||||
SetHandleSize( handle , len ) ;
|
||||
memcpy( *handle , buf , len ) ;
|
||||
m_metafile.SetHMETAFILE( handle ) ;
|
||||
m_metafile.SetHMETAFILE( (WXHMETAFILE) handle ) ;
|
||||
return true ;
|
||||
}
|
||||
#endif
|
||||
|
@@ -346,46 +346,21 @@ void wxNotebook::MacSetupTabs()
|
||||
wxMacStringToPascal( page->GetLabel() , info.name ) ;
|
||||
m_peer->SetData<ControlTabInfoRec>( ii+1, kControlTabInfoTag, &info ) ;
|
||||
m_peer->SetTabEnabled( ii + 1 , true ) ;
|
||||
#if TARGET_CARBON
|
||||
|
||||
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 ) ) ;
|
||||
if ( bmap )
|
||||
{
|
||||
wxBitmap scaledBitmap ;
|
||||
if ( bmap->GetWidth() != 16 || bmap->GetHeight() != 16 )
|
||||
{
|
||||
scaledBitmap = wxBitmap( bmap->ConvertToImage().Scale(16,16) ) ;
|
||||
bmap = &scaledBitmap ;
|
||||
}
|
||||
ControlButtonContentInfo info ;
|
||||
wxMacCreateBitmapButton( &info , *bmap , kControlContentPictHandle) ;
|
||||
IconFamilyHandle iconFamily = (IconFamilyHandle) NewHandle(0) ;
|
||||
OSErr err = SetIconFamilyData( iconFamily, 'PICT' , (Handle) info.u.picture ) ;
|
||||
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 );
|
||||
|
||||
wxMacCreateBitmapButton( &info , *bmap ) ;
|
||||
OSStatus err = m_peer->SetData<ControlButtonContentInfo>( ii+1,kControlTabImageContentTag, &info );
|
||||
wxASSERT_MSG( err == noErr , wxT("Error when setting icon on tab") ) ;
|
||||
if ( UMAGetSystemVersion() < 0x1030 )
|
||||
{
|
||||
UnregisterIconRef( 'WXNG' , (OSType) 1 ) ;
|
||||
wxMacReleaseBitmapButton( &info ) ;
|
||||
}
|
||||
}
|
||||
|
||||
ReleaseIconRef( iconRef ) ;
|
||||
DisposeHandle( (Handle) iconFamily ) ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Rect bounds;
|
||||
m_peer->GetRectInWindowCoords( &bounds ) ;
|
||||
|
@@ -21,7 +21,7 @@
|
||||
# pragma hdrstop
|
||||
#endif
|
||||
|
||||
#if wxUSE_LIBPNG
|
||||
#if 0 // wxUSE_LIBPNG
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
@@ -82,14 +82,15 @@ void wxRadioButton::SetValue(bool val)
|
||||
if (val)
|
||||
{
|
||||
cycle=this->NextInCycle();
|
||||
if (cycle!=NULL) {
|
||||
while (cycle!=this) {
|
||||
if (cycle!=NULL)
|
||||
{
|
||||
while (cycle!=this)
|
||||
{
|
||||
cycle->SetValue(false);
|
||||
cycle=cycle->NextInCycle();
|
||||
}
|
||||
}
|
||||
}
|
||||
MacRedrawControl() ;
|
||||
}
|
||||
|
||||
bool wxRadioButton::GetValue() const
|
||||
|
@@ -399,6 +399,40 @@ wxRegionIterator::wxRegionIterator(const wxRegion& 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)
|
||||
{
|
||||
m_current = 0;
|
||||
@@ -413,15 +447,25 @@ void wxRegionIterator::Reset(const wxRegion& region)
|
||||
m_numRects = 0;
|
||||
else
|
||||
{
|
||||
// we cannot dissolve it into rects on mac
|
||||
m_rects = new wxRect[1];
|
||||
Rect rect ;
|
||||
GetRegionBounds( OTHER_M_REGION( region ) , &rect ) ;
|
||||
m_rects[0].x = rect.left;
|
||||
m_rects[0].y = rect.top;
|
||||
m_rects[0].width = rect.right - rect.left;
|
||||
m_rects[0].height = rect.bottom - rect.top;
|
||||
m_numRects = 1;
|
||||
RegionToRectsUPP proc = NewRegionToRectsUPP (wxMacRegionToRectsCounterCallback);
|
||||
|
||||
OSStatus err = noErr;
|
||||
err = QDRegionToRects (OTHER_M_REGION( region ) , kQDParseRegionFromTopLeft, proc, (void*)&m_numRects);
|
||||
if (err == noErr)
|
||||
{
|
||||
DisposeRegionToRectsUPP (proc);
|
||||
proc = NewRegionToRectsUPP (wxMacRegionToRectsSetterCallback);
|
||||
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
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
#else
|
||||
CGContextRef cgContext ;
|
||||
Rect bounds ;
|
||||
GetPortBounds( (CGrafPtr) dc.m_macPort , &bounds ) ;
|
||||
@@ -285,6 +287,7 @@ wxRendererMac::DrawSplitterSash(wxWindow *win,
|
||||
HIThemeDrawPaneSplitter( &splitterRect , &drawInfo , cgContext , kHIThemeOrientationNormal ) ;
|
||||
}
|
||||
QDEndCGContext( (CGrafPtr) dc.m_macPort , &cgContext ) ;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@@ -84,9 +84,6 @@ void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageS
|
||||
m_peer->SetMinimum( 0 ) ;
|
||||
m_peer->SetValue( position ) ;
|
||||
m_peer->SetViewSize( m_viewSize ) ;
|
||||
|
||||
if ( refresh )
|
||||
MacRedrawControl() ;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -176,30 +176,39 @@ wxMenu* wxTaskBarIcon::DoCreatePopupMenu()
|
||||
// Operations:
|
||||
bool wxTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& tooltip)
|
||||
{
|
||||
wxMask* mask = icon.GetMask();
|
||||
if (!mask)
|
||||
{
|
||||
// Make a mask with no transparent pixels
|
||||
wxBitmap bmp(icon.GetWidth(), icon.GetHeight());
|
||||
wxMemoryDC dc;
|
||||
dc.SelectObject(bmp);
|
||||
dc.SetBackground(*wxBLACK_BRUSH);
|
||||
dc.Clear();
|
||||
dc.SelectObject(wxNullBitmap);
|
||||
mask = new wxMask(bmp, *wxWHITE);
|
||||
}
|
||||
wxBitmap bmp( icon ) ;
|
||||
OSStatus err = noErr ;
|
||||
|
||||
CGImageRef pImage;
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
pImage = bmp.CGImageCreate() ;
|
||||
#else
|
||||
wxMask* mask = bmp.GetMask();
|
||||
if (!mask)
|
||||
{
|
||||
// Make a mask with no transparent pixels
|
||||
wxBitmap mbmp(icon.GetWidth(), icon.GetHeight());
|
||||
wxMemoryDC dc;
|
||||
dc.SelectObject(mbmp);
|
||||
dc.SetBackground(*wxBLACK_BRUSH);
|
||||
dc.Clear();
|
||||
dc.SelectObject(wxNullBitmap);
|
||||
bmp.SetMask( new wxMask(mbmp, *wxWHITE) ) ;
|
||||
}
|
||||
|
||||
//create the icon from the bitmap and mask bitmap contained within
|
||||
OSStatus err = CreateCGImageFromPixMaps(
|
||||
GetGWorldPixMap(MAC_WXHBITMAP(icon.GetHBITMAP())),
|
||||
GetGWorldPixMap(MAC_WXHBITMAP(mask->GetMaskBitmap())),
|
||||
WXHBITMAP iconport ;
|
||||
WXHBITMAP maskport ;
|
||||
iconport = bmp.GetHBITMAP( &maskport ) ;
|
||||
err = CreateCGImageFromPixMaps(
|
||||
GetGWorldPixMap(MAC_WXHBITMAP(iconport)),
|
||||
GetGWorldPixMap(MAC_WXHBITMAP(maskport)),
|
||||
&pImage
|
||||
);
|
||||
|
||||
wxASSERT(err == 0);
|
||||
|
||||
#endif
|
||||
wxASSERT(pImage != NULL );
|
||||
err = SetApplicationDockTileImage(pImage);
|
||||
|
||||
wxASSERT(err == 0);
|
||||
@@ -207,9 +216,6 @@ bool wxTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& tooltip)
|
||||
if (pImage != NULL)
|
||||
CGImageRelease(pImage);
|
||||
|
||||
if (!icon.GetMask())
|
||||
delete mask;
|
||||
|
||||
return m_iconAdded = err == noErr;
|
||||
}
|
||||
|
||||
|
@@ -967,7 +967,7 @@ bool wxTextCtrl::MacSetupCursor( const wxPoint& pt )
|
||||
{
|
||||
return true ;
|
||||
}
|
||||
|
||||
#if !TARGET_API_MAC_OSX
|
||||
// user pane implementation
|
||||
|
||||
void wxTextCtrl::MacControlUserPaneDrawProc(wxInt16 part)
|
||||
@@ -1005,7 +1005,7 @@ wxInt16 wxTextCtrl::MacControlUserPaneFocusProc(wxInt16 action)
|
||||
void wxTextCtrl::MacControlUserPaneBackgroundProc(void* info)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
// ----------------------------------------------------------------------------
|
||||
// implementation base class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@@ -260,6 +260,8 @@ wxToolBarTool::wxToolBarTool(wxToolBar *tbar,
|
||||
CreateBevelButtonControl( window , &toolrect , CFSTR("") , kControlBevelButtonNormalBevel , behaviour , &info ,
|
||||
0 , 0 , 0 , &m_controlHandle ) ;
|
||||
|
||||
wxMacReleaseBitmapButton( &info ) ;
|
||||
|
||||
InstallControlEventHandler( (ControlRef) m_controlHandle, GetwxMacToolBarToolEventHandlerUPP(),
|
||||
GetEventTypeCount(eventList), eventList, this,NULL);
|
||||
|
||||
@@ -555,6 +557,8 @@ bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos), wxToolBarToolBase *tool)
|
||||
void wxToolBar::OnPaint(wxPaintEvent& event)
|
||||
{
|
||||
wxPaintDC dc(this) ;
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
#else
|
||||
wxMacPortSetter helper(&dc) ;
|
||||
int w, h ;
|
||||
GetSize( &w , &h ) ;
|
||||
@@ -602,6 +606,8 @@ void wxToolBar::OnPaint(wxPaintEvent& event)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
event.Skip() ;
|
||||
}
|
||||
|
||||
|
@@ -218,9 +218,9 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
|
||||
#if 0
|
||||
// in case we would need a coregraphics compliant background erase first
|
||||
// now usable to track redraws
|
||||
CGContextRef cgContext = cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef) ;
|
||||
if ( thisWindow->MacIsUserPane() )
|
||||
{
|
||||
CGContextRef cgContext = cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef) ;
|
||||
static float color = 0.5 ;
|
||||
static channel = 0 ;
|
||||
HIRect bounds;
|
||||
@@ -237,9 +237,16 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
|
||||
channel = 0 ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
CGContextRef cgContext = cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef) ;
|
||||
thisWindow->MacSetCGContextRef( cgContext ) ;
|
||||
#endif
|
||||
if ( thisWindow->MacDoRedraw( updateRgn , cEvent.GetTicks() ) )
|
||||
result = noErr ;
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
thisWindow->MacSetCGContextRef( NULL ) ;
|
||||
#endif
|
||||
if ( allocatedRgn )
|
||||
DisposeRgn( allocatedRgn ) ;
|
||||
}
|
||||
@@ -406,6 +413,8 @@ pascal OSStatus wxMacWindowEventHandler( EventHandlerCallRef handler , EventRef
|
||||
|
||||
DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacWindowEventHandler )
|
||||
|
||||
#if !TARGET_API_MAC_OSX
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// UserPane events for non OSX builds
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -517,6 +526,8 @@ ControlUserPaneActivateUPP gControlUserPaneActivateUPP = NULL ;
|
||||
ControlUserPaneFocusUPP gControlUserPaneFocusUPP = NULL ;
|
||||
ControlUserPaneBackgroundUPP gControlUserPaneBackgroundUPP = NULL ;
|
||||
|
||||
#endif
|
||||
|
||||
// ===========================================================================
|
||||
// implementation
|
||||
// ===========================================================================
|
||||
@@ -690,9 +701,12 @@ void wxWindowMac::Init()
|
||||
m_macBackgroundBrush = wxNullBrush ;
|
||||
|
||||
m_macIsUserPane = TRUE;
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
m_cgContextRef = NULL ;
|
||||
#endif
|
||||
// make sure all proc ptrs are available
|
||||
|
||||
#if !TARGET_API_MAC_OSX
|
||||
if ( gControlUserPaneDrawUPP == NULL )
|
||||
{
|
||||
gControlUserPaneDrawUPP = NewControlUserPaneDrawUPP( wxMacControlUserPaneDrawProc ) ;
|
||||
@@ -704,6 +718,7 @@ void wxWindowMac::Init()
|
||||
gControlUserPaneFocusUPP = NewControlUserPaneFocusUPP( wxMacControlUserPaneFocusProc ) ;
|
||||
gControlUserPaneBackgroundUPP = NewControlUserPaneBackgroundUPP( wxMacControlUserPaneBackgroundProc ) ;
|
||||
}
|
||||
#endif
|
||||
if ( wxMacLiveScrollbarActionUPP == NULL )
|
||||
{
|
||||
wxMacLiveScrollbarActionUPP = NewControlActionUPP( wxMacLiveScrollbarActionProc );
|
||||
@@ -2210,24 +2225,6 @@ void wxWindowMac::Thaw()
|
||||
#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
|
||||
void wxWindowMac::OnPaint(wxPaintEvent& event)
|
||||
{
|
||||
@@ -2482,8 +2479,29 @@ void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect)
|
||||
SectRect( &scrollrect , &r , &scrollrect ) ;
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -2819,6 +2837,7 @@ bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr , long time )
|
||||
bool handled = false ;
|
||||
Rect updatebounds ;
|
||||
GetRegionBounds( updatergn , &updatebounds ) ;
|
||||
|
||||
// wxLogDebug("update for %s bounds %d , %d , %d , %d",typeid(*this).name() , updatebounds.left , updatebounds.top , updatebounds.right , updatebounds.bottom ) ;
|
||||
if ( !EmptyRgn(updatergn) )
|
||||
{
|
||||
@@ -2886,6 +2905,8 @@ bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr , long time )
|
||||
{
|
||||
if ( RectInRgn( &childRect , updatergn ) )
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
#else
|
||||
// paint custom borders
|
||||
wxNcPaintEvent eventNc( child->GetId() );
|
||||
eventNc.SetEventObject( child );
|
||||
@@ -2896,54 +2917,26 @@ bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr , long time )
|
||||
wxMacPortSetter helper(&dc) ;
|
||||
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 wxMAC_USE_CORE_GRAPHICS
|
||||
#else
|
||||
wxWindowDC dc(this) ;
|
||||
dc.SetClippingRegion(wxRegion(updatergn));
|
||||
wxMacPortSetter helper(&dc) ;
|
||||
Rect r = childRect ;
|
||||
OffsetRect( &r , dc.m_macLocalOrigin.x , dc.m_macLocalOrigin.y ) ;
|
||||
DrawThemeFocusRect( &r , true ) ;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
{
|
||||
|
Reference in New Issue
Block a user