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