]> git.saurik.com Git - wxWidgets.git/blob - include/wx/cocoa/dc.h
applying patch 1345435
[wxWidgets.git] / include / wx / cocoa / dc.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/cocoa/dc.h
3 // Purpose: wxDC
4 // Author: David Elliott
5 // Modified by:
6 // Created: 2003/04/01
7 // RCS-ID: $Id$
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef __WX_COCOA_DC_H__
13 #define __WX_COCOA_DC_H__
14
15 DECLARE_WXCOCOA_OBJC_CLASS(NSAffineTransform);
16
17 class WXDLLEXPORT wxDC;
18 WX_DECLARE_LIST(wxDC, wxCocoaDCStack);
19
20 //=========================================================================
21 // wxDC
22 //=========================================================================
23 class WXDLLEXPORT wxDC: public wxDCBase
24 {
25 DECLARE_DYNAMIC_CLASS(wxDC)
26 DECLARE_NO_COPY_CLASS(wxDC)
27 //-------------------------------------------------------------------------
28 // Initialization
29 //-------------------------------------------------------------------------
30 public:
31 wxDC();
32 ~wxDC();
33
34 //-------------------------------------------------------------------------
35 // wxCocoa specifics
36 //-------------------------------------------------------------------------
37 public:
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);
45 protected:
46 // DC stack
47 static wxCocoaDCStack sm_cocoaDCStack;
48 virtual bool CocoaLockFocus();
49 virtual bool CocoaUnlockFocus();
50 bool CocoaUnwindStackAndTakeFocus();
51 inline bool CocoaTakeFocus()
52 {
53 wxCocoaDCStack::compatibility_iterator node = sm_cocoaDCStack.GetFirst();
54 if(node && (node->GetData() == this))
55 return true;
56 return CocoaUnwindStackAndTakeFocus();
57 }
58 void CocoaUnwindStackAndLoseFocus();
59 // DC flipping/transformation
60 void CocoaApplyTransformations();
61 void CocoaUnapplyTransformations();
62 WX_NSAffineTransform m_cocoaWxToBoundsTransform;
63 // Get bounds rect (for Clear())
64 // note: we use void * to mean NSRect * so that we can avoid
65 // putting NSRect in the headers.
66 virtual bool CocoaGetBounds(void *rectData);
67 // Blitting
68 virtual bool CocoaDoBlitOnFocusedDC(wxCoord xdest, wxCoord ydest,
69 wxCoord width, wxCoord height, wxCoord xsrc, wxCoord ysrc,
70 int logicalFunc, bool useMask, wxCoord xsrcMask, wxCoord ysrcMask);
71 //-------------------------------------------------------------------------
72 // Implementation
73 //-------------------------------------------------------------------------
74 public:
75 // implement base class pure virtuals
76 // ----------------------------------
77
78 virtual void Clear();
79
80 virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return true; }
81 virtual void EndDoc(void) {};
82
83 virtual void StartPage(void) {};
84 virtual void EndPage(void) {};
85
86 virtual void SetFont(const wxFont& font) {}
87 virtual void SetPen(const wxPen& pen);
88 virtual void SetBrush(const wxBrush& brush);
89 virtual void SetBackground(const wxBrush& brush);
90 virtual void SetBackgroundMode(int mode) { m_backgroundMode = mode; }
91 virtual void SetPalette(const wxPalette& palette);
92
93 virtual void DestroyClippingRegion();
94
95 virtual wxCoord GetCharHeight() const;
96 virtual wxCoord GetCharWidth() const;
97 virtual void DoGetTextExtent(const wxString& string,
98 wxCoord *x, wxCoord *y,
99 wxCoord *descent = NULL,
100 wxCoord *externalLeading = NULL,
101 wxFont *theFont = NULL) const;
102
103 virtual bool CanDrawBitmap() const;
104 virtual bool CanGetTextExtent() const;
105 virtual int GetDepth() const;
106 virtual wxSize GetPPI() const;
107
108 virtual void SetMapMode(int mode);
109 virtual void SetUserScale(double x, double y);
110
111 virtual void SetLogicalScale(double x, double y);
112 virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
113 virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
114 virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
115 virtual void SetLogicalFunction(int function);
116
117 virtual void SetTextForeground(const wxColour& colour) ;
118 virtual void SetTextBackground(const wxColour& colour) ;
119
120 virtual void ComputeScaleAndOrigin();
121 protected:
122 virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
123 int style = wxFLOOD_SURFACE);
124
125 virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const;
126
127 virtual void DoDrawPoint(wxCoord x, wxCoord y);
128 virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
129
130 virtual void DoDrawArc(wxCoord x1, wxCoord y1,
131 wxCoord x2, wxCoord y2,
132 wxCoord xc, wxCoord yc);
133
134 virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
135 double sa, double ea);
136
137 virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
138 virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
139 wxCoord width, wxCoord height,
140 double radius);
141 virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
142
143 virtual void DoCrossHair(wxCoord x, wxCoord y);
144
145 virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
146 virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
147 bool useMask = false);
148
149 virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y);
150 virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
151 double angle);
152
153 virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
154 wxDC *source, wxCoord xsrc, wxCoord ysrc,
155 int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
156
157 // this is gnarly - we can't even call this function DoSetClippingRegion()
158 // because of virtual function hiding
159 virtual void DoSetClippingRegionAsRegion(const wxRegion& region);
160 virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
161 wxCoord width, wxCoord height);
162
163 virtual void DoGetSize(int *width, int *height) const;
164 virtual void DoGetSizeMM(int* width, int* height) const;
165
166 virtual void DoDrawLines(int n, wxPoint points[],
167 wxCoord xoffset, wxCoord yoffset);
168 virtual void DoDrawPolygon(int n, wxPoint points[],
169 wxCoord xoffset, wxCoord yoffset,
170 int fillStyle = wxODDEVEN_RULE);
171 };
172
173 #endif // __WX_COCOA_DC_H__