X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ed8818893364087335327d2190e4608646a3547b..f5a1953b341d16396763bee067ccdd96108f3aad:/include/wx/cocoa/dc.h diff --git a/include/wx/cocoa/dc.h b/include/wx/cocoa/dc.h index 8d53d84c68..c9cc225042 100644 --- a/include/wx/cocoa/dc.h +++ b/include/wx/cocoa/dc.h @@ -6,12 +6,17 @@ // Created: 2003/04/01 // RCS-ID: $Id$ // Copyright: (c) 2003 David Elliott -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef __WX_COCOA_DC_H__ #define __WX_COCOA_DC_H__ +DECLARE_WXCOCOA_OBJC_CLASS(NSAffineTransform); + +class WXDLLEXPORT wxDC; +WX_DECLARE_LIST(wxDC, wxCocoaDCStack); + //========================================================================= // wxDC //========================================================================= @@ -19,25 +24,62 @@ class WXDLLEXPORT wxDC: public wxDCBase { DECLARE_DYNAMIC_CLASS(wxDC) DECLARE_NO_COPY_CLASS(wxDC) +//------------------------------------------------------------------------- +// Initialization +//------------------------------------------------------------------------- public: wxDC(); ~wxDC(); - + +//------------------------------------------------------------------------- +// wxCocoa specifics +//------------------------------------------------------------------------- +public: static void CocoaInitializeTextSystem(); static void CocoaShutdownTextSystem(); - static wxDC *sm_focusedDC; static WX_NSTextStorage sm_cocoaNSTextStorage; static WX_NSLayoutManager sm_cocoaNSLayoutManager; static WX_NSTextContainer sm_cocoaNSTextContainer; - + // Create a simple Wx to Bounds transform (just flip the coordinate system) + static WX_NSAffineTransform CocoaGetWxToBoundsTransform(bool isFlipped, float height); +protected: +// DC stack + static wxCocoaDCStack sm_cocoaDCStack; + virtual bool CocoaLockFocus(); + virtual bool CocoaUnlockFocus(); + bool CocoaUnwindStackAndTakeFocus(); + inline bool CocoaTakeFocus() + { + wxCocoaDCStack::compatibility_iterator node = sm_cocoaDCStack.GetFirst(); + if(node && (node->GetData() == this)) + return true; + return CocoaUnwindStackAndTakeFocus(); + } + void CocoaUnwindStackAndLoseFocus(); +// DC flipping/transformation + void CocoaApplyTransformations(); + void CocoaUnapplyTransformations(); + WX_NSAffineTransform m_cocoaWxToBoundsTransform; +// Get bounds rect (for Clear()) + // note: we use void * to mean NSRect * so that we can avoid + // putting NSRect in the headers. + virtual bool CocoaGetBounds(void *rectData); +// Blitting + virtual bool CocoaDoBlitOnFocusedDC(wxCoord xdest, wxCoord ydest, + wxCoord width, wxCoord height, wxCoord xsrc, wxCoord ysrc, + int logicalFunc, bool useMask, wxCoord xsrcMask, wxCoord ysrcMask); +//------------------------------------------------------------------------- +// Implementation +//------------------------------------------------------------------------- +public: // implement base class pure virtuals // ---------------------------------- virtual void Clear(); - virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return TRUE; } + virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return true; } virtual void EndDoc(void) {}; - + virtual void StartPage(void) {}; virtual void EndPage(void) {}; @@ -75,7 +117,7 @@ public: virtual void SetTextForeground(const wxColour& colour) ; virtual void SetTextBackground(const wxColour& colour) ; - void ComputeScaleAndOrigin(void); + virtual void ComputeScaleAndOrigin(); protected: virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style = wxFLOOD_SURFACE); @@ -88,7 +130,7 @@ protected: virtual void DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc); - + virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, double sa, double ea); @@ -102,7 +144,7 @@ protected: virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y); virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, - bool useMask = FALSE); + bool useMask = false); virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y); virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, @@ -110,7 +152,7 @@ protected: virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC *source, wxCoord xsrc, wxCoord ysrc, - int rop = wxCOPY, bool useMask = FALSE, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1); + int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1); // this is gnarly - we can't even call this function DoSetClippingRegion() // because of virtual function hiding @@ -126,7 +168,6 @@ protected: virtual void DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle = wxODDEVEN_RULE); - }; #endif // __WX_COCOA_DC_H__