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