]> git.saurik.com Git - wxWidgets.git/blob - include/wx/cocoa/dc.h
Don't infinitely recurse when setting the child focus. Without
[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 license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef __WX_COCOA_DC_H__
13 #define __WX_COCOA_DC_H__
14
15 class WXDLLEXPORT wxDC;
16 WX_DECLARE_LIST(wxDC, wxCocoaDCStack);
17
18 //=========================================================================
19 // wxDC
20 //=========================================================================
21 class WXDLLEXPORT wxDC: public wxDCBase
22 {
23 DECLARE_DYNAMIC_CLASS(wxDC)
24 DECLARE_NO_COPY_CLASS(wxDC)
25 //-------------------------------------------------------------------------
26 // Initialization
27 //-------------------------------------------------------------------------
28 public:
29 wxDC();
30 ~wxDC();
31
32 //-------------------------------------------------------------------------
33 // wxCocoa specifics
34 //-------------------------------------------------------------------------
35 public:
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;
41 protected:
42 // DC stack
43 static wxCocoaDCStack sm_cocoaDCStack;
44 virtual bool CocoaLockFocus();
45 virtual bool CocoaUnlockFocus();
46 bool CocoaUnwindStackAndTakeFocus();
47 inline bool CocoaTakeFocus()
48 {
49 wxCocoaDCStack::compatibility_iterator node = sm_cocoaDCStack.GetFirst();
50 if(node && (node->GetData() == this))
51 return true;
52 return CocoaUnwindStackAndTakeFocus();
53 }
54 void CocoaUnwindStackAndLoseFocus();
55 // DC flipping/transformation
56 void CocoaApplyTransformations();
57 float m_cocoaHeight;
58 bool m_cocoaFlipped;
59 // Blitting
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 //-------------------------------------------------------------------------
64 // Implementation
65 //-------------------------------------------------------------------------
66 public:
67 // implement base class pure virtuals
68 // ----------------------------------
69
70 virtual void Clear();
71
72 virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return TRUE; }
73 virtual void EndDoc(void) {};
74
75 virtual void StartPage(void) {};
76 virtual void EndPage(void) {};
77
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);
84
85 virtual void DestroyClippingRegion();
86
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;
94
95 virtual bool CanDrawBitmap() const;
96 virtual bool CanGetTextExtent() const;
97 virtual int GetDepth() const;
98 virtual wxSize GetPPI() const;
99
100 virtual void SetMapMode(int mode);
101 virtual void SetUserScale(double x, double y);
102
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);
108
109 virtual void SetTextForeground(const wxColour& colour) ;
110 virtual void SetTextBackground(const wxColour& colour) ;
111
112 void ComputeScaleAndOrigin(void);
113 protected:
114 virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
115 int style = wxFLOOD_SURFACE);
116
117 virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const;
118
119 virtual void DoDrawPoint(wxCoord x, wxCoord y);
120 virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
121
122 virtual void DoDrawArc(wxCoord x1, wxCoord y1,
123 wxCoord x2, wxCoord y2,
124 wxCoord xc, wxCoord yc);
125
126 virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
127 double sa, double ea);
128
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,
132 double radius);
133 virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
134
135 virtual void DoCrossHair(wxCoord x, wxCoord y);
136
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);
140
141 virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y);
142 virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
143 double angle);
144
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);
148
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);
154
155 virtual void DoGetSize(int *width, int *height) const;
156 virtual void DoGetSizeMM(int* width, int* height) const;
157
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);
163 };
164
165 #endif // __WX_COCOA_DC_H__