]> git.saurik.com Git - wxWidgets.git/blame - include/wx/cocoa/dc.h
Somehow, setting a tint color makes gauge work :/.
[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
6c342f3f 7// Copyright: (c) 2003 David Elliott
b1263dcf 8// Licence: wxWindows licence
a24aff65
DE
9/////////////////////////////////////////////////////////////////////////////
10
6c342f3f
DE
11#ifndef __WX_COCOA_DC_H__
12#define __WX_COCOA_DC_H__
a24aff65 13
4db3c8ac
DE
14DECLARE_WXCOCOA_OBJC_CLASS(NSAffineTransform);
15
938156b2
DE
16#include "wx/dc.h"
17
18class WXDLLIMPEXP_FWD_CORE wxCocoaDCImpl;
19WX_DECLARE_LIST(wxCocoaDCImpl, wxCocoaDCStack);
fe8f7943 20
6c342f3f
DE
21//=========================================================================
22// wxDC
23//=========================================================================
938156b2 24class WXDLLIMPEXP_CORE wxCocoaDCImpl: public wxDCImpl
a24aff65 25{
938156b2 26 DECLARE_ABSTRACT_CLASS(wxCocoaDCImpl)
c0c133e1 27 wxDECLARE_NO_COPY_CLASS(wxCocoaDCImpl);
fe8f7943
DE
28//-------------------------------------------------------------------------
29// Initialization
30//-------------------------------------------------------------------------
6c342f3f 31public:
938156b2
DE
32 wxCocoaDCImpl(wxDC *owner);
33 virtual ~wxCocoaDCImpl();
b1263dcf 34
fe8f7943
DE
35//-------------------------------------------------------------------------
36// wxCocoa specifics
37//-------------------------------------------------------------------------
38public:
6c342f3f
DE
39 static void CocoaInitializeTextSystem();
40 static void CocoaShutdownTextSystem();
6c342f3f
DE
41 static WX_NSTextStorage sm_cocoaNSTextStorage;
42 static WX_NSLayoutManager sm_cocoaNSLayoutManager;
43 static WX_NSTextContainer sm_cocoaNSTextContainer;
4db3c8ac
DE
44 // Create a simple Wx to Bounds transform (just flip the coordinate system)
45 static WX_NSAffineTransform CocoaGetWxToBoundsTransform(bool isFlipped, float height);
fe8f7943
DE
46protected:
47// DC stack
48 static wxCocoaDCStack sm_cocoaDCStack;
49 virtual bool CocoaLockFocus();
50 virtual bool CocoaUnlockFocus();
51 bool CocoaUnwindStackAndTakeFocus();
52 inline bool CocoaTakeFocus()
53 {
7ce8248b 54 wxCocoaDCStack::compatibility_iterator node = sm_cocoaDCStack.GetFirst();
fe8f7943
DE
55 if(node && (node->GetData() == this))
56 return true;
57 return CocoaUnwindStackAndTakeFocus();
58 }
59 void CocoaUnwindStackAndLoseFocus();
60// DC flipping/transformation
61 void CocoaApplyTransformations();
3e21fc05 62 void CocoaUnapplyTransformations();
4db3c8ac 63 WX_NSAffineTransform m_cocoaWxToBoundsTransform;
3e21fc05
DE
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);
2c23fe91
DE
68// Blitting
69 virtual bool CocoaDoBlitOnFocusedDC(wxCoord xdest, wxCoord ydest,
70 wxCoord width, wxCoord height, wxCoord xsrc, wxCoord ysrc,
89efaf2b 71 wxRasterOperationMode logicalFunc, bool useMask, wxCoord xsrcMask, wxCoord ysrcMask);
fe8f7943
DE
72//-------------------------------------------------------------------------
73// Implementation
74//-------------------------------------------------------------------------
75public:
a24aff65
DE
76 // implement base class pure virtuals
77 // ----------------------------------
78
79 virtual void Clear();
80
b1263dcf 81 virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return true; }
6dd0883d 82 virtual void EndDoc(void) {}
b1263dcf 83
6dd0883d
SN
84 virtual void StartPage(void) {}
85 virtual void EndPage(void) {}
a24aff65 86
e7e97a59 87 virtual void SetFont(const wxFont& font);
a24aff65
DE
88 virtual void SetPen(const wxPen& pen);
89 virtual void SetBrush(const wxBrush& brush);
90 virtual void SetBackground(const wxBrush& brush);
ed881889 91 virtual void SetBackgroundMode(int mode) { m_backgroundMode = mode; }
a24aff65
DE
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,
c94f845b 102 const wxFont *theFont = NULL) const;
a24aff65
DE
103
104 virtual bool CanDrawBitmap() const;
105 virtual bool CanGetTextExtent() const;
106 virtual int GetDepth() const;
107 virtual wxSize GetPPI() const;
108
89efaf2b 109 virtual void SetMapMode(wxMappingMode mode);
a24aff65
DE
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);
89efaf2b 116 virtual void SetLogicalFunction(wxRasterOperationMode function);
a24aff65
DE
117
118 virtual void SetTextForeground(const wxColour& colour) ;
119 virtual void SetTextBackground(const wxColour& colour) ;
120
b1263dcf 121 virtual void ComputeScaleAndOrigin();
a24aff65
DE
122protected:
123 virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
89efaf2b 124 wxFloodFillStyle style = wxFLOOD_SURFACE);
a24aff65
DE
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);
b1263dcf 134
a24aff65
DE
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,
b1263dcf 148 bool useMask = false);
a24aff65
DE
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,
b1263dcf 156 int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
a24aff65
DE
157
158 // this is gnarly - we can't even call this function DoSetClippingRegion()
159 // because of virtual function hiding
fdaad94e 160 virtual void DoSetDeviceClippingRegion(const wxRegion& region);
a24aff65
DE
161 virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
162 wxCoord width, wxCoord height);
a24aff65
DE
163
164 virtual void DoGetSize(int *width, int *height) const;
165 virtual void DoGetSizeMM(int* width, int* height) const;
166
4787c92d 167 virtual void DoDrawLines(int n, const wxPoint points[],
a24aff65 168 wxCoord xoffset, wxCoord yoffset);
4787c92d 169 virtual void DoDrawPolygon(int n, const wxPoint points[],
a24aff65 170 wxCoord xoffset, wxCoord yoffset,
89efaf2b 171 wxPolygonFillMode fillStyle = wxODDEVEN_RULE);
a24aff65
DE
172};
173
6c342f3f 174#endif // __WX_COCOA_DC_H__