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:
@@ -20,6 +20,7 @@
|
||||
|
||||
// Bitmap
|
||||
class WXDLLEXPORT wxBitmap;
|
||||
class wxBitmapRefData ;
|
||||
class WXDLLEXPORT wxBitmapHandler;
|
||||
class WXDLLEXPORT wxControl;
|
||||
class WXDLLEXPORT wxCursor;
|
||||
@@ -29,78 +30,58 @@ 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)
|
||||
DECLARE_NO_COPY_CLASS(wxMask)
|
||||
|
||||
public:
|
||||
wxMask();
|
||||
wxMask();
|
||||
|
||||
// Construct a mask from a bitmap and a colour indicating
|
||||
// the transparent area
|
||||
wxMask(const wxBitmap& bitmap, const wxColour& colour);
|
||||
// Construct a mask from a bitmap and a colour indicating
|
||||
// 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 (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 ) ;
|
||||
|
||||
// Construct a mask from a mono bitmap (copies the bitmap).
|
||||
wxMask(const wxBitmap& bitmap);
|
||||
~wxMask();
|
||||
|
||||
~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);
|
||||
bool Create(const wxBitmap& bitmap, int paletteIndex);
|
||||
bool Create(const wxBitmap& bitmap);
|
||||
// Implementation below
|
||||
|
||||
// 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 ;
|
||||
void Init() ;
|
||||
|
||||
// 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
|
||||
|
||||
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
|
||||
{
|
||||
public:
|
||||
@@ -120,96 +101,113 @@ private:
|
||||
|
||||
class WXDLLEXPORT wxBitmap: public wxBitmapBase
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxBitmap)
|
||||
DECLARE_DYNAMIC_CLASS(wxBitmap)
|
||||
|
||||
friend class WXDLLEXPORT wxBitmapHandler;
|
||||
friend class WXDLLEXPORT wxBitmapHandler;
|
||||
|
||||
public:
|
||||
wxBitmap(); // Platform-specific
|
||||
wxBitmap(); // Platform-specific
|
||||
|
||||
// Copy constructors
|
||||
wxBitmap(const wxBitmap& bitmap)
|
||||
: wxBitmapBase()
|
||||
{ Ref(bitmap); }
|
||||
// Copy constructors
|
||||
wxBitmap(const wxBitmap& bitmap)
|
||||
{ Ref(bitmap); }
|
||||
|
||||
// Initialize with raw data.
|
||||
wxBitmap(const char bits[], int width, int height, int depth = 1);
|
||||
// Initialize with raw data.
|
||||
wxBitmap(const char bits[], int width, int height, int depth = 1);
|
||||
|
||||
// Initialize with XPM data
|
||||
bool CreateFromXpm(const char **bits);
|
||||
wxBitmap(const char **bits);
|
||||
wxBitmap(char **bits);
|
||||
// Initialize with XPM data
|
||||
bool CreateFromXpm(const char **bits);
|
||||
wxBitmap(const char **bits);
|
||||
wxBitmap(char **bits);
|
||||
|
||||
// Load a file or resource
|
||||
wxBitmap(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_PICT_RESOURCE);
|
||||
// Load a file or resource
|
||||
wxBitmap(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_PICT_RESOURCE);
|
||||
|
||||
// Constructor for generalised creation from data
|
||||
wxBitmap(void *data, wxBitmapType type, int width, int height, int depth = 1);
|
||||
// Constructor for generalised creation from data
|
||||
wxBitmap(void *data, wxBitmapType type, int width, int height, int depth = 1);
|
||||
|
||||
// If depth is omitted, will create a bitmap compatible with the display
|
||||
wxBitmap(int width, int height, int depth = -1);
|
||||
|
||||
// Convert from wxImage:
|
||||
wxBitmap(const wxImage& image, int depth = -1);
|
||||
|
||||
~wxBitmap();
|
||||
|
||||
wxImage ConvertToImage() const;
|
||||
// If depth is omitted, will create a bitmap compatible with the display
|
||||
wxBitmap(int width, int height, int depth = -1);
|
||||
|
||||
// get the given part of bitmap
|
||||
wxBitmap GetSubBitmap( const wxRect& rect ) const;
|
||||
// Convert from wxImage:
|
||||
wxBitmap(const wxImage& image, int depth = -1);
|
||||
|
||||
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 LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_BMP_RESOURCE);
|
||||
virtual bool SaveFile(const wxString& name, wxBitmapType type, const wxPalette *cmap = NULL) const;
|
||||
// Convert from wxIcon
|
||||
wxBitmap(const wxIcon& icon) { CopyFromIcon(icon); }
|
||||
|
||||
// copies the contents and mask of the given (colour) icon to the bitmap
|
||||
virtual bool CopyFromIcon(const wxIcon& icon);
|
||||
~wxBitmap();
|
||||
|
||||
bool Ok() const;
|
||||
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);
|
||||
wxImage ConvertToImage() const;
|
||||
|
||||
// get the given part of bitmap
|
||||
wxBitmap GetSubBitmap( const wxRect& rect ) const;
|
||||
|
||||
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);
|
||||
|
||||
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
|
||||
wxPalette* GetPalette() const;
|
||||
void SetPalette(const wxPalette& palette);
|
||||
wxPalette* GetPalette() const;
|
||||
void SetPalette(const wxPalette& palette);
|
||||
#endif // wxUSE_PALETTE
|
||||
|
||||
wxMask *GetMask() const;
|
||||
void SetMask(wxMask *mask) ;
|
||||
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; }
|
||||
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; }
|
||||
|
||||
static void InitStandardHandlers();
|
||||
static void InitStandardHandlers();
|
||||
|
||||
// raw bitmap access support functions, for internal use only
|
||||
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,43 +19,53 @@
|
||||
#include "wx/bitmap.h"
|
||||
|
||||
// Icon
|
||||
class WXDLLEXPORT wxIcon: public wxBitmap
|
||||
class WXDLLEXPORT wxIcon: public wxGDIObject
|
||||
{
|
||||
public:
|
||||
wxIcon();
|
||||
wxIcon();
|
||||
|
||||
// Copy constructors
|
||||
wxIcon(const wxIcon& icon)
|
||||
: wxBitmap()
|
||||
// Copy constructors
|
||||
wxIcon(const wxIcon& icon)
|
||||
{ Ref(icon); }
|
||||
|
||||
wxIcon(const char **data);
|
||||
wxIcon(char **data);
|
||||
wxIcon(const char bits[], int width , int height );
|
||||
wxIcon(const wxString& name, int flags = wxBITMAP_TYPE_ICON_RESOURCE,
|
||||
wxIcon(const char **data);
|
||||
wxIcon(char **data);
|
||||
wxIcon(const char bits[], int width , int height );
|
||||
wxIcon(const wxString& name, int flags = wxBITMAP_TYPE_ICON_RESOURCE,
|
||||
int desiredWidth = -1, int desiredHeight = -1);
|
||||
wxIcon(const wxIconLocation& loc)
|
||||
{
|
||||
wxIcon(const wxIconLocation& loc)
|
||||
{
|
||||
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);
|
||||
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 ) ; }
|
||||
|
||||
wxIcon& operator=(const wxIcon& icon)
|
||||
wxIcon& operator=(const wxIcon& icon)
|
||||
{ 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 !(*this == icon); }
|
||||
bool operator==(const wxIcon& icon) const { return m_refData == icon.m_refData; }
|
||||
bool operator!=(const wxIcon& icon) const { return !(*this == icon); }
|
||||
|
||||
// create from bitmap (which should have a mask unless it's monochrome):
|
||||
// there shouldn't be any implicit bitmap -> icon conversion (i.e. no
|
||||
// ctors, assignment operators...), but it's ok to have such function
|
||||
void CopyFromBitmap(const wxBitmap& bmp);
|
||||
// create from bitmap (which should have a mask unless it's monochrome):
|
||||
// there shouldn't be any implicit bitmap -> icon conversion (i.e. no
|
||||
// ctors, assignment operators...), but it's ok to have such function
|
||||
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
|
||||
|
||||
#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,
|
||||
@@ -60,7 +60,7 @@ class WXDLLEXPORT wxStaticBitmap: public wxStaticBitmapBase
|
||||
virtual wxSize DoGetBestSize() const ;
|
||||
|
||||
protected:
|
||||
wxBitmap m_bitmap;
|
||||
wxBitmap m_bitmap;
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
@@ -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 ;
|
||||
|
Reference in New Issue
Block a user