1 /////////////////////////////////////////////////////////////////////////////
4 // Author: David Elliott
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef __WX_COCOA_DC_H__
13 #define __WX_COCOA_DC_H__
15 DECLARE_WXCOCOA_OBJC_CLASS(NSAffineTransform
);
17 class WXDLLEXPORT wxDC
;
18 WX_DECLARE_LIST(wxDC
, wxCocoaDCStack
);
20 //=========================================================================
22 //=========================================================================
23 class WXDLLEXPORT wxDC
: public wxDCBase
25 DECLARE_DYNAMIC_CLASS(wxDC
)
26 DECLARE_NO_COPY_CLASS(wxDC
)
27 //-------------------------------------------------------------------------
29 //-------------------------------------------------------------------------
34 //-------------------------------------------------------------------------
36 //-------------------------------------------------------------------------
38 static void CocoaInitializeTextSystem();
39 static void CocoaShutdownTextSystem();
40 static WX_NSTextStorage sm_cocoaNSTextStorage
;
41 static WX_NSLayoutManager sm_cocoaNSLayoutManager
;
42 static WX_NSTextContainer sm_cocoaNSTextContainer
;
43 // Create a simple Wx to Bounds transform (just flip the coordinate system)
44 static WX_NSAffineTransform
CocoaGetWxToBoundsTransform(bool isFlipped
, float height
);
47 static wxCocoaDCStack sm_cocoaDCStack
;
48 virtual bool CocoaLockFocus();
49 virtual bool CocoaUnlockFocus();
50 bool CocoaUnwindStackAndTakeFocus();
51 inline bool CocoaTakeFocus()
53 wxCocoaDCStack::compatibility_iterator node
= sm_cocoaDCStack
.GetFirst();
54 if(node
&& (node
->GetData() == this))
56 return CocoaUnwindStackAndTakeFocus();
58 void CocoaUnwindStackAndLoseFocus();
59 // DC flipping/transformation
60 void CocoaApplyTransformations();
61 WX_NSAffineTransform m_cocoaWxToBoundsTransform
;
63 virtual bool CocoaDoBlitOnFocusedDC(wxCoord xdest
, wxCoord ydest
,
64 wxCoord width
, wxCoord height
, wxCoord xsrc
, wxCoord ysrc
,
65 int logicalFunc
, bool useMask
, wxCoord xsrcMask
, wxCoord ysrcMask
);
66 //-------------------------------------------------------------------------
68 //-------------------------------------------------------------------------
70 // implement base class pure virtuals
71 // ----------------------------------
75 virtual bool StartDoc( const wxString
& WXUNUSED(message
) ) { return true; }
76 virtual void EndDoc(void) {};
78 virtual void StartPage(void) {};
79 virtual void EndPage(void) {};
81 virtual void SetFont(const wxFont
& font
) {}
82 virtual void SetPen(const wxPen
& pen
);
83 virtual void SetBrush(const wxBrush
& brush
);
84 virtual void SetBackground(const wxBrush
& brush
);
85 virtual void SetBackgroundMode(int mode
) { m_backgroundMode
= mode
; }
86 virtual void SetPalette(const wxPalette
& palette
);
88 virtual void DestroyClippingRegion();
90 virtual wxCoord
GetCharHeight() const;
91 virtual wxCoord
GetCharWidth() const;
92 virtual void DoGetTextExtent(const wxString
& string
,
93 wxCoord
*x
, wxCoord
*y
,
94 wxCoord
*descent
= NULL
,
95 wxCoord
*externalLeading
= NULL
,
96 wxFont
*theFont
= NULL
) const;
98 virtual bool CanDrawBitmap() const;
99 virtual bool CanGetTextExtent() const;
100 virtual int GetDepth() const;
101 virtual wxSize
GetPPI() const;
103 virtual void SetMapMode(int mode
);
104 virtual void SetUserScale(double x
, double y
);
106 virtual void SetLogicalScale(double x
, double y
);
107 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
108 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
109 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
110 virtual void SetLogicalFunction(int function
);
112 virtual void SetTextForeground(const wxColour
& colour
) ;
113 virtual void SetTextBackground(const wxColour
& colour
) ;
115 virtual void ComputeScaleAndOrigin();
117 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
118 int style
= wxFLOOD_SURFACE
);
120 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const;
122 virtual void DoDrawPoint(wxCoord x
, wxCoord y
);
123 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
125 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
126 wxCoord x2
, wxCoord y2
,
127 wxCoord xc
, wxCoord yc
);
129 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
130 double sa
, double ea
);
132 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
133 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
134 wxCoord width
, wxCoord height
,
136 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
138 virtual void DoCrossHair(wxCoord x
, wxCoord y
);
140 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
);
141 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
142 bool useMask
= false);
144 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
145 virtual void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
,
148 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
149 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
150 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= -1, wxCoord ysrcMask
= -1);
152 // this is gnarly - we can't even call this function DoSetClippingRegion()
153 // because of virtual function hiding
154 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
);
155 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
156 wxCoord width
, wxCoord height
);
158 virtual void DoGetSize(int *width
, int *height
) const;
159 virtual void DoGetSizeMM(int* width
, int* height
) const;
161 virtual void DoDrawLines(int n
, wxPoint points
[],
162 wxCoord xoffset
, wxCoord yoffset
);
163 virtual void DoDrawPolygon(int n
, wxPoint points
[],
164 wxCoord xoffset
, wxCoord yoffset
,
165 int fillStyle
= wxODDEVEN_RULE
);
168 #endif // __WX_COCOA_DC_H__