]> git.saurik.com Git - wxWidgets.git/blame - include/wx/cocoa/dc.h
remove warnings of intentionally unreachable code
[wxWidgets.git] / include / wx / cocoa / dc.h
CommitLineData
a24aff65 1/////////////////////////////////////////////////////////////////////////////
6c342f3f
DE
2// Name: wx/cocoa/dc.h
3// Purpose: wxDC
4// Author: David Elliott
a24aff65 5// Modified by:
6c342f3f 6// Created: 2003/04/01
a24aff65 7// RCS-ID: $Id$
6c342f3f 8// Copyright: (c) 2003 David Elliott
b1263dcf 9// Licence: wxWindows licence
a24aff65
DE
10/////////////////////////////////////////////////////////////////////////////
11
6c342f3f
DE
12#ifndef __WX_COCOA_DC_H__
13#define __WX_COCOA_DC_H__
a24aff65 14
4db3c8ac
DE
15DECLARE_WXCOCOA_OBJC_CLASS(NSAffineTransform);
16
fe8f7943
DE
17class WXDLLEXPORT wxDC;
18WX_DECLARE_LIST(wxDC, wxCocoaDCStack);
19
6c342f3f
DE
20//=========================================================================
21// wxDC
22//=========================================================================
a24aff65
DE
23class WXDLLEXPORT wxDC: public wxDCBase
24{
25 DECLARE_DYNAMIC_CLASS(wxDC)
26 DECLARE_NO_COPY_CLASS(wxDC)
fe8f7943
DE
27//-------------------------------------------------------------------------
28// Initialization
29//-------------------------------------------------------------------------
6c342f3f 30public:
a24aff65 31 wxDC();
d3c7fc99 32 virtual ~wxDC();
b1263dcf 33
fe8f7943
DE
34//-------------------------------------------------------------------------
35// wxCocoa specifics
36//-------------------------------------------------------------------------
37public:
6c342f3f
DE
38 static void CocoaInitializeTextSystem();
39 static void CocoaShutdownTextSystem();
6c342f3f
DE
40 static WX_NSTextStorage sm_cocoaNSTextStorage;
41 static WX_NSLayoutManager sm_cocoaNSLayoutManager;
42 static WX_NSTextContainer sm_cocoaNSTextContainer;
4db3c8ac
DE
43 // Create a simple Wx to Bounds transform (just flip the coordinate system)
44 static WX_NSAffineTransform CocoaGetWxToBoundsTransform(bool isFlipped, float height);
fe8f7943
DE
45protected:
46// DC stack
47 static wxCocoaDCStack sm_cocoaDCStack;
48 virtual bool CocoaLockFocus();
49 virtual bool CocoaUnlockFocus();
50 bool CocoaUnwindStackAndTakeFocus();
51 inline bool CocoaTakeFocus()
52 {
7ce8248b 53 wxCocoaDCStack::compatibility_iterator node = sm_cocoaDCStack.GetFirst();
fe8f7943
DE
54 if(node && (node->GetData() == this))
55 return true;
56 return CocoaUnwindStackAndTakeFocus();
57 }
58 void CocoaUnwindStackAndLoseFocus();
59// DC flipping/transformation
60 void CocoaApplyTransformations();
3e21fc05 61 void CocoaUnapplyTransformations();
4db3c8ac 62 WX_NSAffineTransform m_cocoaWxToBoundsTransform;
3e21fc05
DE
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);
2c23fe91
DE
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);
fe8f7943
DE
71//-------------------------------------------------------------------------
72// Implementation
73//-------------------------------------------------------------------------
74public:
a24aff65
DE
75 // implement base class pure virtuals
76 // ----------------------------------
77
78 virtual void Clear();
79
b1263dcf 80 virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return true; }
a24aff65 81 virtual void EndDoc(void) {};
b1263dcf 82
a24aff65
DE
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);
ed881889 90 virtual void SetBackgroundMode(int mode) { m_backgroundMode = mode; }
a24aff65
DE
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,
c94f845b 101 const wxFont *theFont = NULL) const;
a24aff65
DE
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
b1263dcf 120 virtual void ComputeScaleAndOrigin();
a24aff65
DE
121protected:
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);
b1263dcf 133
a24aff65
DE
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,
b1263dcf 147 bool useMask = false);
a24aff65
DE
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,
b1263dcf 155 int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
a24aff65
DE
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);
a24aff65
DE
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);
a24aff65
DE
171};
172
6c342f3f 173#endif // __WX_COCOA_DC_H__