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 class WXDLLEXPORT wxDC
;
16 WX_DECLARE_LIST(wxDC
, wxCocoaDCStack
);
18 //=========================================================================
20 //=========================================================================
21 class WXDLLEXPORT wxDC
: public wxDCBase
23 DECLARE_DYNAMIC_CLASS(wxDC
)
24 DECLARE_NO_COPY_CLASS(wxDC
)
25 //-------------------------------------------------------------------------
27 //-------------------------------------------------------------------------
32 //-------------------------------------------------------------------------
34 //-------------------------------------------------------------------------
36 static void CocoaInitializeTextSystem();
37 static void CocoaShutdownTextSystem();
38 static WX_NSTextStorage sm_cocoaNSTextStorage
;
39 static WX_NSLayoutManager sm_cocoaNSLayoutManager
;
40 static WX_NSTextContainer sm_cocoaNSTextContainer
;
43 static wxCocoaDCStack sm_cocoaDCStack
;
44 virtual bool CocoaLockFocus();
45 virtual bool CocoaUnlockFocus();
46 bool CocoaUnwindStackAndTakeFocus();
47 inline bool CocoaTakeFocus()
49 wxCocoaDCStack::compatibility_iterator node
= sm_cocoaDCStack
.GetFirst();
50 if(node
&& (node
->GetData() == this))
52 return CocoaUnwindStackAndTakeFocus();
54 void CocoaUnwindStackAndLoseFocus();
55 // DC flipping/transformation
56 void CocoaApplyTransformations();
60 virtual bool CocoaDoBlitOnFocusedDC(wxCoord xdest
, wxCoord ydest
,
61 wxCoord width
, wxCoord height
, wxCoord xsrc
, wxCoord ysrc
,
62 int logicalFunc
, bool useMask
, wxCoord xsrcMask
, wxCoord ysrcMask
);
63 //-------------------------------------------------------------------------
65 //-------------------------------------------------------------------------
67 // implement base class pure virtuals
68 // ----------------------------------
72 virtual bool StartDoc( const wxString
& WXUNUSED(message
) ) { return TRUE
; }
73 virtual void EndDoc(void) {};
75 virtual void StartPage(void) {};
76 virtual void EndPage(void) {};
78 virtual void SetFont(const wxFont
& font
) {}
79 virtual void SetPen(const wxPen
& pen
);
80 virtual void SetBrush(const wxBrush
& brush
);
81 virtual void SetBackground(const wxBrush
& brush
);
82 virtual void SetBackgroundMode(int mode
) { m_backgroundMode
= mode
; }
83 virtual void SetPalette(const wxPalette
& palette
);
85 virtual void DestroyClippingRegion();
87 virtual wxCoord
GetCharHeight() const;
88 virtual wxCoord
GetCharWidth() const;
89 virtual void DoGetTextExtent(const wxString
& string
,
90 wxCoord
*x
, wxCoord
*y
,
91 wxCoord
*descent
= NULL
,
92 wxCoord
*externalLeading
= NULL
,
93 wxFont
*theFont
= NULL
) const;
95 virtual bool CanDrawBitmap() const;
96 virtual bool CanGetTextExtent() const;
97 virtual int GetDepth() const;
98 virtual wxSize
GetPPI() const;
100 virtual void SetMapMode(int mode
);
101 virtual void SetUserScale(double x
, double y
);
103 virtual void SetLogicalScale(double x
, double y
);
104 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
105 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
106 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
107 virtual void SetLogicalFunction(int function
);
109 virtual void SetTextForeground(const wxColour
& colour
) ;
110 virtual void SetTextBackground(const wxColour
& colour
) ;
112 void ComputeScaleAndOrigin(void);
114 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
115 int style
= wxFLOOD_SURFACE
);
117 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const;
119 virtual void DoDrawPoint(wxCoord x
, wxCoord y
);
120 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
122 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
123 wxCoord x2
, wxCoord y2
,
124 wxCoord xc
, wxCoord yc
);
126 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
127 double sa
, double ea
);
129 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
130 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
131 wxCoord width
, wxCoord height
,
133 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
135 virtual void DoCrossHair(wxCoord x
, wxCoord y
);
137 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
);
138 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
139 bool useMask
= FALSE
);
141 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
142 virtual void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
,
145 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
146 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
147 int rop
= wxCOPY
, bool useMask
= FALSE
, wxCoord xsrcMask
= -1, wxCoord ysrcMask
= -1);
149 // this is gnarly - we can't even call this function DoSetClippingRegion()
150 // because of virtual function hiding
151 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
);
152 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
153 wxCoord width
, wxCoord height
);
155 virtual void DoGetSize(int *width
, int *height
) const;
156 virtual void DoGetSizeMM(int* width
, int* height
) const;
158 virtual void DoDrawLines(int n
, wxPoint points
[],
159 wxCoord xoffset
, wxCoord yoffset
);
160 virtual void DoDrawPolygon(int n
, wxPoint points
[],
161 wxCoord xoffset
, wxCoord yoffset
,
162 int fillStyle
= wxODDEVEN_RULE
);
165 #endif // __WX_COCOA_DC_H__