]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mgl/dc.h
respect wxUSE_WIZARDDLG setting
[wxWidgets.git] / include / wx / mgl / dc.h
CommitLineData
32b8ec41
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: dc.h
3// Purpose: wxDC class
4// Author: Vaclav Slavik
5// Created: 2001/03/09
6// RCS-ID: $Id$
8f7b34a8 7// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
32b8ec41
VZ
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_DC_H_
12#define _WX_DC_H_
13
14#ifdef __GNUG__
15 #pragma interface "dc.h"
16#endif
17
18#include "wx/defs.h"
19#include "wx/dc.h"
20#include "wx/region.h"
21
22//-----------------------------------------------------------------------------
23// classes
24//-----------------------------------------------------------------------------
25
26class WXDLLEXPORT wxDC;
27
28//-----------------------------------------------------------------------------
29// constants
30//-----------------------------------------------------------------------------
31
32#define MM_TEXT 0
33#define MM_ISOTROPIC 1
34#define MM_ANISOTROPIC 2
35#define MM_LOMETRIC 3
36#define MM_HIMETRIC 4
37#define MM_TWIPS 5
38#define MM_POINTS 6
39#define MM_METRIC 7
40
41//-----------------------------------------------------------------------------
42// wxDC
43//-----------------------------------------------------------------------------
44
45
46// MGL fwd declarations:
47class MGLDevCtx;
48struct font_t;
49
50class WXDLLEXPORT wxDC : public wxDCBase
51{
52 DECLARE_DYNAMIC_CLASS(wxDC)
53
54public:
55 wxDC();
56 ~wxDC();
57
58 // implement base class pure virtuals
59 // ----------------------------------
60
61 virtual void Clear();
62
63 virtual bool StartDoc(const wxString& message);
64 virtual void EndDoc();
65
66 virtual void StartPage();
67 virtual void EndPage();
68
69 virtual void SetFont(const wxFont& font);
70 virtual void SetPen(const wxPen& pen);
71 virtual void SetBrush(const wxBrush& brush);
72 virtual void SetBackground(const wxBrush& brush);
73 virtual void SetBackgroundMode(int mode);
74 virtual void SetPalette(const wxPalette& palette);
75
76 virtual void DestroyClippingRegion();
77
78 virtual wxCoord GetCharHeight() const;
79 virtual wxCoord GetCharWidth() const;
80 virtual void DoGetTextExtent(const wxString& string,
81 wxCoord *x, wxCoord *y,
82 wxCoord *descent = NULL,
83 wxCoord *externalLeading = NULL,
84 wxFont *theFont = NULL) const;
85
86 virtual bool CanDrawBitmap() const;
87 virtual bool CanGetTextExtent() const;
88 virtual int GetDepth() const;
89 virtual wxSize GetPPI() const;
90
91 virtual void SetMapMode(int mode);
92 virtual void SetUserScale(double x, double y);
93 virtual void SetLogicalScale(double x, double y);
94 virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
95 virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
96 virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
97 virtual void SetLogicalFunction(int function);
98
99 // implementation from now on
100 // --------------------------
101
102 virtual void ComputeScaleAndOrigin();
103
104 wxCoord XDEV2LOG(wxCoord x) const
105 {
106 wxCoord new_x = x - m_deviceOriginX;
107 if (new_x > 0)
108 return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX;
109 else
110 return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX;
111 }
112 wxCoord XDEV2LOGREL(wxCoord x) const
113 {
114 if (x > 0)
115 return (wxCoord)((double)(x) / m_scaleX + 0.5);
116 else
117 return (wxCoord)((double)(x) / m_scaleX - 0.5);
118 }
119 wxCoord YDEV2LOG(wxCoord y) const
120 {
121 wxCoord new_y = y - m_deviceOriginY;
122 if (new_y > 0)
123 return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY;
124 else
125 return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY;
126 }
127 wxCoord YDEV2LOGREL(wxCoord y) const
128 {
129 if (y > 0)
130 return (wxCoord)((double)(y) / m_scaleY + 0.5);
131 else
132 return (wxCoord)((double)(y) / m_scaleY - 0.5);
133 }
134 wxCoord XLOG2DEV(wxCoord x) const
135 {
136 wxCoord new_x = x - m_logicalOriginX;
137 if (new_x > 0)
138 return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX;
139 else
140 return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX;
141 }
142 wxCoord XLOG2DEVREL(wxCoord x) const
143 {
144 if (x > 0)
145 return (wxCoord)((double)(x) * m_scaleX + 0.5);
146 else
147 return (wxCoord)((double)(x) * m_scaleX - 0.5);
148 }
149 wxCoord YLOG2DEV(wxCoord y) const
150 {
151 wxCoord new_y = y - m_logicalOriginY;
152 if (new_y > 0)
153 return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY;
154 else
155 return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY;
156 }
157 wxCoord YLOG2DEVREL(wxCoord y) const
158 {
159 if (y > 0)
160 return (wxCoord)((double)(y) * m_scaleY + 0.5);
161 else
162 return (wxCoord)((double)(y) * m_scaleY - 0.5);
163 }
164
165 MGLDevCtx *GetMGLDC() const { return m_MGLDC; }
166 void SetMGLDC(MGLDevCtx *mgldc, bool OwnsMGLDC = FALSE);
167
168protected:
169 virtual void DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
170 int style = wxFLOOD_SURFACE);
171
172 virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const;
173
174 virtual void DoDrawPoint(wxCoord x, wxCoord y);
175 virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
176
177 virtual void DoDrawArc(wxCoord x1, wxCoord y1,
178 wxCoord x2, wxCoord y2,
179 wxCoord xc, wxCoord yc);
180 virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
181 double sa, double ea);
182
183 virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
184 virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
185 wxCoord width, wxCoord height,
186 double radius);
187 virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
188
189 virtual void DoCrossHair(wxCoord x, wxCoord y);
190
191 virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
192 virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
193 bool useMask = FALSE);
194
195 virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y);
196 virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
197 double angle);
198
199 virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
200 wxDC *source, wxCoord xsrc, wxCoord ysrc,
201 int rop = wxCOPY, bool useMask = FALSE);
202
203 // this is gnarly - we can't even call this function DoSetClippingRegion()
204 // because of virtual function hiding
205 virtual void DoSetClippingRegionAsRegion(const wxRegion& region);
206 virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
207 wxCoord width, wxCoord height);
208 virtual void DoGetClippingRegion(wxCoord *x, wxCoord *y,
209 wxCoord *width, wxCoord *height)
210 {
211 GetClippingBox(x, y, width, height);
212 }
213
214 virtual void DoGetSize(int *width, int *height) const;
215 virtual void DoGetSizeMM(int* width, int* height) const;
216
217 virtual void DoDrawLines(int n, wxPoint points[],
218 wxCoord xoffset, wxCoord yoffset);
219 virtual void DoDrawPolygon(int n, wxPoint points[],
220 wxCoord xoffset, wxCoord yoffset,
221 int fillStyle = wxODDEVEN_RULE);
222
223 // implementation from now on:
224
225protected:
226 // setup newly attached MGLDevCtx for wxDC's use
227 // (does things like setting RGB blending mode for antialiased texts):
228 void InitializeMGLDC();
229
230 // common part of DoDrawText() and DoDrawRotatedText()
231 void DrawAnyText(const wxString& text, wxCoord x, wxCoord y);
232
233 // MGL uses pens as both wxPens and wxBrushes, so we have to
234 // switch them as needed:
235 void SelectPen();
236 void SelectBrush();
237 void SelectMGLStipplePen(int style);
238 void SelectMGLFatPen(int style, int flag);
239
240 // Select m_font into m_MGLDC:
241 bool SelectMGLFont();
242
243 // Convert wxWin logical function to MGL rop:
244 int LogicalFunctionToMGLRop(int logFunc) const;
245
246 // Unified implementation of DrawIcon, DrawBitmap and Blit:
247 void DoDrawSubBitmap(const wxBitmap &bmp,
248 wxCoord x, wxCoord y, wxCoord w, wxCoord h,
249 wxCoord destx, wxCoord desty, int rop, bool useMask);
250
251 // MGL DC class we use:
252 MGLDevCtx *m_MGLDC;
253 bool m_OwnsMGLDC:1;
254
255 // helper variables for SelectXXXX():
256 bool m_penSelected;
257 bool m_brushSelected;
258 bool m_downloadedPatterns[2];
259
260 // MGL does not render lines with width>1 with endings centered
261 // at given coords but with top left corner of the pen at them,
262 // these offsets are used to correct it. They are computed by
263 // SelectPen.
264 int m_penOfsX, m_penOfsY;
265
266 double m_mm_to_pix_x, m_mm_to_pix_y;
267
268 wxPalette m_oldPalette;
269
270 wxRegion m_currentClippingRegion;
271
272 // wxDC::Blit handles memoryDCs as special cases :(
273 bool m_isMemDC;
274
275 font_t *m_mglFont;
276};
277
278#endif
279 // _WX_DC_H_