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