]> git.saurik.com Git - wxWidgets.git/blame - include/wx/dc.h
more extra semicolons removed (patch 1303724)
[wxWidgets.git] / include / wx / dc.h
CommitLineData
006162a9
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: dc.h
3// Purpose: wxDC class
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 05/25/99
7// RCS-ID: $Id$
77ffb593 8// Copyright: (c) wxWidgets team
65571936 9// Licence: wxWindows licence
006162a9
VZ
10/////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_DC_H_BASE_
13#define _WX_DC_H_BASE_
c801d85f 14
a23fd0e1
VZ
15// ----------------------------------------------------------------------------
16// headers which we must include here
17// ----------------------------------------------------------------------------
18
19#include "wx/object.h" // the base class
20
21#include "wx/cursor.h" // we have member variables of these classes
22#include "wx/font.h" // so we can't do without them
23#include "wx/colour.h"
b494e2b0 24#include "wx/bitmap.h" // for wxNullBitmap
a23fd0e1
VZ
25#include "wx/brush.h"
26#include "wx/pen.h"
27#include "wx/palette.h"
a23fd0e1 28#include "wx/list.h" // we use wxList in inline functions
0919e93e 29#include "wx/dynarray.h"
19edb09c 30#include "wx/math.h"
a23fd0e1 31
f4515f98 32class WXDLLEXPORT wxDC;
aec43716
KH
33class WXDLLEXPORT wxDCBase;
34
35class WXDLLEXPORT wxDrawObject
36{
37public:
38
39 wxDrawObject()
68379eaf 40 : m_isBBoxValid(false)
ba161d7e
GD
41 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
42 { }
aec43716
KH
43
44 virtual ~wxDrawObject() { }
45
33ac7e6f 46 virtual void Draw(wxDCBase&) const { }
aec43716
KH
47
48 virtual void CalcBoundingBox(wxCoord x, wxCoord y)
49 {
50 if ( m_isBBoxValid )
51 {
52 if ( x < m_minX ) m_minX = x;
53 if ( y < m_minY ) m_minY = y;
54 if ( x > m_maxX ) m_maxX = x;
55 if ( y > m_maxY ) m_maxY = y;
56 }
57 else
58 {
68379eaf 59 m_isBBoxValid = true;
aec43716
KH
60
61 m_minX = x;
62 m_minY = y;
63 m_maxX = x;
64 m_maxY = y;
65 }
66 }
67
68 void ResetBoundingBox()
69 {
68379eaf 70 m_isBBoxValid = false;
aec43716
KH
71
72 m_minX = m_maxX = m_minY = m_maxY = 0;
73 }
74
75 // Get the final bounding box of the PostScript or Metafile picture.
76
77 wxCoord MinX() const { return m_minX; }
78 wxCoord MaxX() const { return m_maxX; }
79 wxCoord MinY() const { return m_minY; }
80 wxCoord MaxY() const { return m_maxY; }
81
82 //to define the type of object for derived objects
83 virtual int GetType()=0;
84
85protected:
86 //for boundingbox calculation
87 bool m_isBBoxValid:1;
88 //for boundingbox calculation
89 wxCoord m_minX, m_minY, m_maxX, m_maxY;
90};
91
a23fd0e1
VZ
92// ---------------------------------------------------------------------------
93// global variables
94// ---------------------------------------------------------------------------
95
16cba29d 96extern WXDLLEXPORT_DATA(int) wxPageNumber;
a23fd0e1
VZ
97
98// ---------------------------------------------------------------------------
99// wxDC is the device context - object on which any drawing is done
100// ---------------------------------------------------------------------------
101
102class WXDLLEXPORT wxDCBase : public wxObject
103{
a23fd0e1
VZ
104public:
105 wxDCBase()
ba161d7e 106 : m_colour(wxColourDisplay())
68379eaf
WS
107 , m_ok(true)
108 , m_clipping(false)
ba161d7e 109 , m_isInteractive(0)
68379eaf 110 , m_isBBoxValid(false)
ba161d7e
GD
111 , m_logicalOriginX(0), m_logicalOriginY(0)
112 , m_deviceOriginX(0), m_deviceOriginY(0)
113 , m_logicalScaleX(1.0), m_logicalScaleY(1.0)
114 , m_userScaleX(1.0), m_userScaleY(1.0)
115 , m_scaleX(1.0), m_scaleY(1.0)
116 , m_signX(1), m_signY(1)
117 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
118 , m_clipX1(0), m_clipY1(0), m_clipX2(0), m_clipY2(0)
119 , m_logicalFunction(wxCOPY)
120 , m_backgroundMode(wxTRANSPARENT)
121 , m_mappingMode(wxMM_TEXT)
122 , m_pen()
123 , m_brush()
124 , m_backgroundBrush(*wxTRANSPARENT_BRUSH)
125 , m_textForegroundColour(*wxBLACK)
126 , m_textBackgroundColour(*wxWHITE)
127 , m_font()
128#if wxUSE_PALETTE
129 , m_palette()
68379eaf 130 , m_hasCustomPalette(false)
ba161d7e 131#endif // wxUSE_PALETTE
a23fd0e1 132 {
f6bcfd97 133 ResetBoundingBox();
d16b634f 134 ResetClipping();
a23fd0e1
VZ
135 }
136
137 ~wxDCBase() { }
138
139 virtual void BeginDrawing() { }
140 virtual void EndDrawing() { }
141
142 // graphic primitives
143 // ------------------
144
aec43716
KH
145 virtual void DrawObject(wxDrawObject* drawobject)
146 {
147 drawobject->Draw(*this);
148 CalcBoundingBox(drawobject->MinX(),drawobject->MinY());
149 CalcBoundingBox(drawobject->MaxX(),drawobject->MaxY());
150 }
151
387ebd3e 152 bool FloodFill(wxCoord x, wxCoord y, const wxColour& col,
72cdf4c9 153 int style = wxFLOOD_SURFACE)
387ebd3e
JS
154 { return DoFloodFill(x, y, col, style); }
155 bool FloodFill(const wxPoint& pt, const wxColour& col,
72cdf4c9 156 int style = wxFLOOD_SURFACE)
387ebd3e 157 { return DoFloodFill(pt.x, pt.y, col, style); }
a23fd0e1 158
72cdf4c9 159 bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const
a23fd0e1
VZ
160 { return DoGetPixel(x, y, col); }
161 bool GetPixel(const wxPoint& pt, wxColour *col) const
162 { return DoGetPixel(pt.x, pt.y, col); }
163
72cdf4c9 164 void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
a23fd0e1
VZ
165 { DoDrawLine(x1, y1, x2, y2); }
166 void DrawLine(const wxPoint& pt1, const wxPoint& pt2)
167 { DoDrawLine(pt1.x, pt1.y, pt2.x, pt2.y); }
168
72cdf4c9 169 void CrossHair(wxCoord x, wxCoord y)
a23fd0e1
VZ
170 { DoCrossHair(x, y); }
171 void CrossHair(const wxPoint& pt)
172 { DoCrossHair(pt.x, pt.y); }
173
72cdf4c9
VZ
174 void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
175 wxCoord xc, wxCoord yc)
a23fd0e1
VZ
176 { DoDrawArc(x1, y1, x2, y2, xc, yc); }
177 void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre)
178 { DoDrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y); }
179
cd9da200
VZ
180 void DrawCheckMark(wxCoord x, wxCoord y,
181 wxCoord width, wxCoord height)
182 { DoDrawCheckMark(x, y, width, height); }
183 void DrawCheckMark(const wxRect& rect)
184 { DoDrawCheckMark(rect.x, rect.y, rect.width, rect.height); }
185
72cdf4c9
VZ
186 void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
187 double sa, double ea)
7b90a8f2 188 { DoDrawEllipticArc(x, y, w, h, sa, ea); }
a23fd0e1
VZ
189 void DrawEllipticArc(const wxPoint& pt, const wxSize& sz,
190 double sa, double ea)
191 { DoDrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea); }
192
72cdf4c9 193 void DrawPoint(wxCoord x, wxCoord y)
a23fd0e1
VZ
194 { DoDrawPoint(x, y); }
195 void DrawPoint(const wxPoint& pt)
196 { DoDrawPoint(pt.x, pt.y); }
197
72cdf4c9
VZ
198 void DrawLines(int n, wxPoint points[],
199 wxCoord xoffset = 0, wxCoord yoffset = 0)
a23fd0e1 200 { DoDrawLines(n, points, xoffset, yoffset); }
72cdf4c9
VZ
201 void DrawLines(const wxList *list,
202 wxCoord xoffset = 0, wxCoord yoffset = 0);
a23fd0e1
VZ
203
204 void DrawPolygon(int n, wxPoint points[],
72cdf4c9 205 wxCoord xoffset = 0, wxCoord yoffset = 0,
a23fd0e1
VZ
206 int fillStyle = wxODDEVEN_RULE)
207 { DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); }
208
209 void DrawPolygon(const wxList *list,
72cdf4c9 210 wxCoord xoffset = 0, wxCoord yoffset = 0,
bd5dd957 211 int fillStyle = wxODDEVEN_RULE);
a23fd0e1 212
793db755 213 void DrawPolyPolygon(int n, int count[], wxPoint points[],
6e76b35d
VZ
214 wxCoord xoffset = 0, wxCoord yoffset = 0,
215 int fillStyle = wxODDEVEN_RULE)
793db755 216 { DoDrawPolyPolygon(n, count, points, xoffset, yoffset, fillStyle); }
6e76b35d 217
72cdf4c9 218 void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
a23fd0e1
VZ
219 { DoDrawRectangle(x, y, width, height); }
220 void DrawRectangle(const wxPoint& pt, const wxSize& sz)
221 { DoDrawRectangle(pt.x, pt.y, sz.x, sz.y); }
222 void DrawRectangle(const wxRect& rect)
223 { DoDrawRectangle(rect.x, rect.y, rect.width, rect.height); }
224
72cdf4c9 225 void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height,
a23fd0e1
VZ
226 double radius)
227 { DoDrawRoundedRectangle(x, y, width, height, radius); }
228 void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz,
229 double radius)
230 { DoDrawRoundedRectangle(pt.x, pt.y, sz.x, sz.y, radius); }
231 void DrawRoundedRectangle(const wxRect& r, double radius)
232 { DoDrawRoundedRectangle(r.x, r.y, r.width, r.height, radius); }
233
72cdf4c9 234 void DrawCircle(wxCoord x, wxCoord y, wxCoord radius)
220af862 235 { DoDrawEllipse(x - radius, y - radius, 2*radius, 2*radius); }
0371e9a8 236 void DrawCircle(const wxPoint& pt, wxCoord radius)
b95edd47 237 { DrawCircle(pt.x, pt.y, radius); }
0371e9a8 238
72cdf4c9 239 void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
a23fd0e1
VZ
240 { DoDrawEllipse(x, y, width, height); }
241 void DrawEllipse(const wxPoint& pt, const wxSize& sz)
242 { DoDrawEllipse(pt.x, pt.y, sz.x, sz.y); }
243 void DrawEllipse(const wxRect& rect)
244 { DoDrawEllipse(rect.x, rect.y, rect.width, rect.height); }
245
72cdf4c9 246 void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
a23fd0e1
VZ
247 { DoDrawIcon(icon, x, y); }
248 void DrawIcon(const wxIcon& icon, const wxPoint& pt)
249 { DoDrawIcon(icon, pt.x, pt.y); }
250
72cdf4c9 251 void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
68379eaf 252 bool useMask = false)
a23fd0e1
VZ
253 { DoDrawBitmap(bmp, x, y, useMask); }
254 void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt,
68379eaf 255 bool useMask = false)
a23fd0e1
VZ
256 { DoDrawBitmap(bmp, pt.x, pt.y, useMask); }
257
72cdf4c9 258 void DrawText(const wxString& text, wxCoord x, wxCoord y)
a23fd0e1
VZ
259 { DoDrawText(text, x, y); }
260 void DrawText(const wxString& text, const wxPoint& pt)
261 { DoDrawText(text, pt.x, pt.y); }
262
95724b1a
VZ
263 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle)
264 { DoDrawRotatedText(text, x, y, angle); }
265 void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle)
266 { DoDrawRotatedText(text, pt.x, pt.y, angle); }
267
1e6feb95
VZ
268 // this version puts both optional bitmap and the text into the given
269 // rectangle and aligns is as specified by alignment parameter; it also
270 // will emphasize the character with the given index if it is != -1 and
271 // return the bounding rectangle if required
272 virtual void DrawLabel(const wxString& text,
273 const wxBitmap& image,
274 const wxRect& rect,
275 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
276 int indexAccel = -1,
277 wxRect *rectBounding = NULL);
278
279 void DrawLabel(const wxString& text, const wxRect& rect,
280 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
281 int indexAccel = -1)
282 { DrawLabel(text, wxNullBitmap, rect, alignment, indexAccel); }
283
72cdf4c9
VZ
284 bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
285 wxDC *source, wxCoord xsrc, wxCoord ysrc,
68379eaf 286 int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord)
a23fd0e1
VZ
287 {
288 return DoBlit(xdest, ydest, width, height,
0cbff120 289 source, xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask);
a23fd0e1
VZ
290 }
291 bool Blit(const wxPoint& destPt, const wxSize& sz,
292 wxDC *source, const wxPoint& srcPt,
68379eaf 293 int rop = wxCOPY, bool useMask = false, const wxPoint& srcPtMask = wxDefaultPosition)
a23fd0e1
VZ
294 {
295 return DoBlit(destPt.x, destPt.y, sz.x, sz.y,
0cbff120 296 source, srcPt.x, srcPt.y, rop, useMask, srcPtMask.x, srcPtMask.y);
a23fd0e1
VZ
297 }
298
299#if wxUSE_SPLINES
72cdf4c9
VZ
300 // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?)
301 void DrawSpline(wxCoord x1, wxCoord y1,
302 wxCoord x2, wxCoord y2,
303 wxCoord x3, wxCoord y3);
bd5dd957 304 void DrawSpline(int n, wxPoint points[]);
a23fd0e1
VZ
305
306 void DrawSpline(wxList *points) { DoDrawSpline(points); }
307#endif // wxUSE_SPLINES
308
12bdd77c
JS
309 // Eventually we will have wxUSE_GENERIC_DRAWELLIPSE
310#ifdef __WXWINCE__
311 //! Generic method to draw ellipses, circles and arcs with current pen and brush.
312 /*! \param x Upper left corner of bounding box.
313 * \param y Upper left corner of bounding box.
314 * \param w Width of bounding box.
315 * \param h Height of bounding box.
d16b634f 316 * \param sa Starting angle of arc
12bdd77c
JS
317 * (counterclockwise, start at 3 o'clock, 360 is full circle).
318 * \param ea Ending angle of arc.
d16b634f 319 * \param angle Rotation angle, the Arc will be rotated after
12bdd77c
JS
320 * calculating begin and end.
321 */
d16b634f
VZ
322 void DrawEllipticArcRot( wxCoord x, wxCoord y,
323 wxCoord width, wxCoord height,
12bdd77c
JS
324 double sa = 0, double ea = 0, double angle = 0 )
325 { DoDrawEllipticArcRot( x, y, width, height, sa, ea, angle ); }
d16b634f
VZ
326
327 void DrawEllipticArcRot( const wxPoint& pt,
12bdd77c
JS
328 const wxSize& sz,
329 double sa = 0, double ea = 0, double angle = 0 )
330 { DoDrawEllipticArcRot( pt.x, pt.y, sz.x, sz.y, sa, ea, angle ); }
331
332 void DrawEllipticArcRot( const wxRect& rect,
333 double sa = 0, double ea = 0, double angle = 0 )
334 { DoDrawEllipticArcRot( rect.x, rect.y, rect.width, rect.height, sa, ea, angle ); }
335
d16b634f
VZ
336 virtual void DoDrawEllipticArcRot( wxCoord x, wxCoord y,
337 wxCoord w, wxCoord h,
12bdd77c 338 double sa = 0, double ea = 0, double angle = 0 );
d16b634f 339
12bdd77c
JS
340 //! Rotates points around center.
341 /*! This is a quite straight method, it calculates in pixels
342 * and so it produces rounding errors.
343 * \param points The points inside will be rotated.
344 * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle).
345 * \param center Center of rotation.
d16b634f 346 */
c47addef 347 void Rotate( wxList* points, double angle, wxPoint center = wxPoint(0,0) );
12bdd77c
JS
348
349 // used by DrawEllipticArcRot
350 // Careful: wxList gets filled with points you have to delete later.
d16b634f
VZ
351 void CalculateEllipticPoints( wxList* points,
352 wxCoord xStart, wxCoord yStart,
353 wxCoord w, wxCoord h,
12bdd77c
JS
354 double sa, double ea );
355#endif
d16b634f 356
a23fd0e1
VZ
357 // global DC operations
358 // --------------------
359
360 virtual void Clear() = 0;
361
68379eaf 362 virtual bool StartDoc(const wxString& WXUNUSED(message)) { return true; }
af0bb3b1 363 virtual void EndDoc() { }
a23fd0e1 364
af0bb3b1
VZ
365 virtual void StartPage() { }
366 virtual void EndPage() { }
a23fd0e1
VZ
367
368 // set objects to use for drawing
369 // ------------------------------
370
371 virtual void SetFont(const wxFont& font) = 0;
372 virtual void SetPen(const wxPen& pen) = 0;
373 virtual void SetBrush(const wxBrush& brush) = 0;
374 virtual void SetBackground(const wxBrush& brush) = 0;
375 virtual void SetBackgroundMode(int mode) = 0;
d275c7eb 376#if wxUSE_PALETTE
a23fd0e1 377 virtual void SetPalette(const wxPalette& palette) = 0;
d275c7eb 378#endif // wxUSE_PALETTE
a23fd0e1
VZ
379
380 // clipping region
381 // ---------------
382
72cdf4c9 383 void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
a23fd0e1
VZ
384 { DoSetClippingRegion(x, y, width, height); }
385 void SetClippingRegion(const wxPoint& pt, const wxSize& sz)
386 { DoSetClippingRegion(pt.x, pt.y, sz.x, sz.y); }
387 void SetClippingRegion(const wxRect& rect)
388 { DoSetClippingRegion(rect.x, rect.y, rect.width, rect.height); }
389 void SetClippingRegion(const wxRegion& region)
390 { DoSetClippingRegionAsRegion(region); }
391
d16b634f 392 virtual void DestroyClippingRegion() { ResetClipping(); }
a23fd0e1 393
72cdf4c9 394 void GetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const
a23fd0e1
VZ
395 { DoGetClippingBox(x, y, w, h); }
396 void GetClippingBox(wxRect& rect) const
8fb3a512 397 {
ae500232 398 DoGetClippingBox(&rect.x, &rect.y, &rect.width, &rect.height);
8fb3a512 399 }
a23fd0e1
VZ
400
401 // text extent
402 // -----------
403
72cdf4c9
VZ
404 virtual wxCoord GetCharHeight() const = 0;
405 virtual wxCoord GetCharWidth() const = 0;
cd9da200 406
1e6feb95 407 // only works for single line strings
72cdf4c9
VZ
408 void GetTextExtent(const wxString& string,
409 wxCoord *x, wxCoord *y,
410 wxCoord *descent = NULL,
411 wxCoord *externalLeading = NULL,
412 wxFont *theFont = NULL) const
413 { DoGetTextExtent(string, x, y, descent, externalLeading, theFont); }
a23fd0e1 414
1e6feb95
VZ
415 // works for single as well as multi-line strings
416 virtual void GetMultiLineTextExtent(const wxString& text,
417 wxCoord *width,
418 wxCoord *height,
419 wxCoord *heightLine = NULL,
420 wxFont *font = NULL);
421
0919e93e
RD
422 // Measure cumulative width of text after each character
423 bool GetPartialTextExtents(const wxString& text, wxArrayInt& widths) const
424 { return DoGetPartialTextExtents(text, widths); }
425
d16b634f 426
a23fd0e1
VZ
427 // size and resolution
428 // -------------------
429
430 // in device units
431 void GetSize(int *width, int *height) const
432 { DoGetSize(width, height); }
433 wxSize GetSize() const
434 {
435 int w, h;
436 DoGetSize(&w, &h);
437
438 return wxSize(w, h);
439 }
440
441 // in mm
442 void GetSizeMM(int* width, int* height) const
443 { DoGetSizeMM(width, height); }
444 wxSize GetSizeMM() const
445 {
446 int w, h;
447 DoGetSizeMM(&w, &h);
448
449 return wxSize(w, h);
450 }
451
452 // coordinates conversions
453 // -----------------------
454
455 // This group of functions does actual conversion of the input, as you'd
456 // expect.
72cdf4c9
VZ
457 wxCoord DeviceToLogicalX(wxCoord x) const;
458 wxCoord DeviceToLogicalY(wxCoord y) const;
459 wxCoord DeviceToLogicalXRel(wxCoord x) const;
460 wxCoord DeviceToLogicalYRel(wxCoord y) const;
461 wxCoord LogicalToDeviceX(wxCoord x) const;
462 wxCoord LogicalToDeviceY(wxCoord y) const;
463 wxCoord LogicalToDeviceXRel(wxCoord x) const;
464 wxCoord LogicalToDeviceYRel(wxCoord y) const;
a23fd0e1
VZ
465
466 // query DC capabilities
467 // ---------------------
468
469 virtual bool CanDrawBitmap() const = 0;
470 virtual bool CanGetTextExtent() const = 0;
471
472 // colour depth
473 virtual int GetDepth() const = 0;
474
475 // Resolution in Pixels per inch
476 virtual wxSize GetPPI() const = 0;
477
478 virtual bool Ok() const { return m_ok; }
479
2439f37a
VZ
480 // accessors and setters
481 // ---------------------
a23fd0e1 482
f6bcfd97 483 int GetBackgroundMode() const { return m_backgroundMode; }
a23fd0e1
VZ
484 const wxBrush& GetBackground() const { return m_backgroundBrush; }
485 const wxBrush& GetBrush() const { return m_brush; }
486 const wxFont& GetFont() const { return m_font; }
487 const wxPen& GetPen() const { return m_pen; }
a23fd0e1 488
2439f37a
VZ
489 const wxColour& GetTextForeground() const { return m_textForegroundColour; }
490 const wxColour& GetTextBackground() const { return m_textBackgroundColour; }
a23fd0e1
VZ
491 virtual void SetTextForeground(const wxColour& colour)
492 { m_textForegroundColour = colour; }
493 virtual void SetTextBackground(const wxColour& colour)
494 { m_textBackgroundColour = colour; }
495
496 int GetMapMode() const { return m_mappingMode; }
497 virtual void SetMapMode(int mode) = 0;
498
499 virtual void GetUserScale(double *x, double *y) const
500 {
501 if ( x ) *x = m_userScaleX;
502 if ( y ) *y = m_userScaleY;
503 }
504 virtual void SetUserScale(double x, double y) = 0;
505
a23fd0e1
VZ
506 virtual void GetLogicalScale(double *x, double *y)
507 {
508 if ( x ) *x = m_logicalScaleX;
509 if ( y ) *y = m_logicalScaleY;
510 }
511 virtual void SetLogicalScale(double x, double y)
512 {
513 m_logicalScaleX = x;
514 m_logicalScaleY = y;
515 }
516
72cdf4c9 517 void GetLogicalOrigin(wxCoord *x, wxCoord *y) const
a23fd0e1
VZ
518 { DoGetLogicalOrigin(x, y); }
519 wxPoint GetLogicalOrigin() const
72cdf4c9
VZ
520 { wxCoord x, y; DoGetLogicalOrigin(&x, &y); return wxPoint(x, y); }
521 virtual void SetLogicalOrigin(wxCoord x, wxCoord y) = 0;
a23fd0e1 522
72cdf4c9 523 void GetDeviceOrigin(wxCoord *x, wxCoord *y) const
a23fd0e1
VZ
524 { DoGetDeviceOrigin(x, y); }
525 wxPoint GetDeviceOrigin() const
72cdf4c9
VZ
526 { wxCoord x, y; DoGetDeviceOrigin(&x, &y); return wxPoint(x, y); }
527 virtual void SetDeviceOrigin(wxCoord x, wxCoord y) = 0;
a23fd0e1 528
b1263dcf
WS
529 virtual void ComputeScaleAndOrigin() {}
530
a23fd0e1
VZ
531 virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp) = 0;
532
533 int GetLogicalFunction() const { return m_logicalFunction; }
534 virtual void SetLogicalFunction(int function) = 0;
535
ea76a6a5 536#if WXWIN_COMPATIBILITY_2_4
a23fd0e1 537 virtual void SetOptimization(bool WXUNUSED(opt)) { }
68379eaf 538 virtual bool GetOptimization() { return false; }
ea76a6a5 539#endif
a23fd0e1
VZ
540
541 // bounding box
542 // ------------
543
72cdf4c9 544 virtual void CalcBoundingBox(wxCoord x, wxCoord y)
a23fd0e1 545 {
f6bcfd97
BP
546 if ( m_isBBoxValid )
547 {
548 if ( x < m_minX ) m_minX = x;
549 if ( y < m_minY ) m_minY = y;
550 if ( x > m_maxX ) m_maxX = x;
551 if ( y > m_maxY ) m_maxY = y;
552 }
553 else
554 {
68379eaf 555 m_isBBoxValid = true;
f6bcfd97
BP
556
557 m_minX = x;
558 m_minY = y;
559 m_maxX = x;
560 m_maxY = y;
561 }
562 }
563
564 void ResetBoundingBox()
565 {
68379eaf 566 m_isBBoxValid = false;
f6bcfd97
BP
567
568 m_minX = m_maxX = m_minY = m_maxY = 0;
a23fd0e1
VZ
569 }
570
571 // Get the final bounding box of the PostScript or Metafile picture.
72cdf4c9
VZ
572 wxCoord MinX() const { return m_minX; }
573 wxCoord MaxX() const { return m_maxX; }
574 wxCoord MinY() const { return m_minY; }
575 wxCoord MaxY() const { return m_maxY; }
a23fd0e1
VZ
576
577 // misc old functions
578 // ------------------
579
72cdf4c9 580 // for compatibility with the old code when wxCoord was long everywhere
72cdf4c9
VZ
581 void GetTextExtent(const wxString& string,
582 long *x, long *y,
583 long *descent = NULL,
584 long *externalLeading = NULL,
585 wxFont *theFont = NULL) const
586 {
587 wxCoord x2, y2, descent2, externalLeading2;
588 DoGetTextExtent(string, &x2, &y2,
589 &descent2, &externalLeading2,
590 theFont);
591 if ( x )
592 *x = x2;
593 if ( y )
594 *y = y2;
595 if ( descent )
596 *descent = descent2;
597 if ( externalLeading )
598 *externalLeading = externalLeading2;
599 }
600
601 void GetLogicalOrigin(long *x, long *y) const
602 {
603 wxCoord x2, y2;
604 DoGetLogicalOrigin(&x2, &y2);
605 if ( x )
606 *x = x2;
607 if ( y )
608 *y = y2;
609 }
610
611 void GetDeviceOrigin(long *x, long *y) const
612 {
613 wxCoord x2, y2;
614 DoGetDeviceOrigin(&x2, &y2);
615 if ( x )
616 *x = x2;
617 if ( y )
618 *y = y2;
619 }
1dd989e1 620 void GetClippingBox(long *x, long *y, long *w, long *h) const
cd9da200
VZ
621 {
622 wxCoord xx,yy,ww,hh;
623 DoGetClippingBox(&xx, &yy, &ww, &hh);
624 if (x) *x = xx;
625 if (y) *y = yy;
626 if (w) *w = ww;
627 if (h) *h = hh;
1dd989e1 628 }
72cdf4c9 629
48710795
RR
630 // Reserved for future use
631 virtual void ReservedDCFunc1() {}
632 virtual void ReservedDCFunc2() {}
633 virtual void ReservedDCFunc3() {}
634 virtual void ReservedDCFunc4() {}
635 virtual void ReservedDCFunc5() {}
636 virtual void ReservedDCFunc6() {}
637 virtual void ReservedDCFunc7() {}
638 virtual void ReservedDCFunc8() {}
639 virtual void ReservedDCFunc9() {}
640
a23fd0e1
VZ
641protected:
642 // the pure virtual functions which should be implemented by wxDC
387ebd3e 643 virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
a23fd0e1
VZ
644 int style = wxFLOOD_SURFACE) = 0;
645
72cdf4c9 646 virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const = 0;
a23fd0e1 647
72cdf4c9
VZ
648 virtual void DoDrawPoint(wxCoord x, wxCoord y) = 0;
649 virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) = 0;
a23fd0e1 650
72cdf4c9
VZ
651 virtual void DoDrawArc(wxCoord x1, wxCoord y1,
652 wxCoord x2, wxCoord y2,
653 wxCoord xc, wxCoord yc) = 0;
cd9da200
VZ
654 virtual void DoDrawCheckMark(wxCoord x, wxCoord y,
655 wxCoord width, wxCoord height);
72cdf4c9 656 virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
a23fd0e1
VZ
657 double sa, double ea) = 0;
658
72cdf4c9
VZ
659 virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) = 0;
660 virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
661 wxCoord width, wxCoord height,
a23fd0e1 662 double radius) = 0;
72cdf4c9
VZ
663 virtual void DoDrawEllipse(wxCoord x, wxCoord y,
664 wxCoord width, wxCoord height) = 0;
a23fd0e1 665
72cdf4c9 666 virtual void DoCrossHair(wxCoord x, wxCoord y) = 0;
a23fd0e1 667
72cdf4c9
VZ
668 virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) = 0;
669 virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
68379eaf 670 bool useMask = false) = 0;
a23fd0e1 671
72cdf4c9 672 virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y) = 0;
95724b1a
VZ
673 virtual void DoDrawRotatedText(const wxString& text,
674 wxCoord x, wxCoord y, double angle) = 0;
a23fd0e1 675
72cdf4c9
VZ
676 virtual bool DoBlit(wxCoord xdest, wxCoord ydest,
677 wxCoord width, wxCoord height,
678 wxDC *source, wxCoord xsrc, wxCoord ysrc,
68379eaf 679 int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord) = 0;
a23fd0e1
VZ
680
681 virtual void DoGetSize(int *width, int *height) const = 0;
682 virtual void DoGetSizeMM(int* width, int* height) const = 0;
683
684 virtual void DoDrawLines(int n, wxPoint points[],
72cdf4c9 685 wxCoord xoffset, wxCoord yoffset) = 0;
a23fd0e1 686 virtual void DoDrawPolygon(int n, wxPoint points[],
72cdf4c9 687 wxCoord xoffset, wxCoord yoffset,
a23fd0e1 688 int fillStyle = wxODDEVEN_RULE) = 0;
793db755 689 virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[],
6e76b35d
VZ
690 wxCoord xoffset, wxCoord yoffset,
691 int fillStyle);
a23fd0e1
VZ
692
693 virtual void DoSetClippingRegionAsRegion(const wxRegion& region) = 0;
72cdf4c9
VZ
694 virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
695 wxCoord width, wxCoord height) = 0;
b0e0d661 696
c5789d15
WS
697#if WXWIN_COMPATIBILITY_2_4
698 // this was only for confusing people, use DoGetClippingBox only
72cdf4c9
VZ
699 virtual void DoGetClippingRegion(wxCoord *x, wxCoord *y,
700 wxCoord *w, wxCoord *h)
b0e0d661 701 { DoGetClippingBox(x, y, w, h); }
c5789d15
WS
702#endif
703
72cdf4c9
VZ
704 virtual void DoGetClippingBox(wxCoord *x, wxCoord *y,
705 wxCoord *w, wxCoord *h) const
a23fd0e1 706 {
d16b634f
VZ
707 if ( x )
708 *x = m_clipX1;
709 if ( y )
710 *y = m_clipY1;
711 if ( w )
712 *w = m_clipX2 - m_clipX1;
713 if ( h )
714 *h = m_clipY2 - m_clipY1;
a23fd0e1
VZ
715 }
716
72cdf4c9 717 virtual void DoGetLogicalOrigin(wxCoord *x, wxCoord *y) const
a23fd0e1
VZ
718 {
719 if ( x ) *x = m_logicalOriginX;
720 if ( y ) *y = m_logicalOriginY;
721 }
722
72cdf4c9 723 virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const
a23fd0e1
VZ
724 {
725 if ( x ) *x = m_deviceOriginX;
726 if ( y ) *y = m_deviceOriginY;
727 }
728
72cdf4c9
VZ
729 virtual void DoGetTextExtent(const wxString& string,
730 wxCoord *x, wxCoord *y,
731 wxCoord *descent = NULL,
732 wxCoord *externalLeading = NULL,
733 wxFont *theFont = NULL) const = 0;
d16b634f 734
0919e93e 735 virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
d16b634f 736
64698f9a 737#if wxUSE_SPLINES
fe2e4366 738 virtual void DoDrawSpline(wxList *points);
64698f9a 739#endif
a23fd0e1
VZ
740
741protected:
d16b634f
VZ
742 // unset clipping variables (after clipping region was destroyed)
743 void ResetClipping()
744 {
745 m_clipping = false;
746
747 m_clipX1 = m_clipX2 = m_clipY1 = m_clipY2 = 0;
748 }
749
a23fd0e1
VZ
750 // flags
751 bool m_colour:1;
752 bool m_ok:1;
753 bool m_clipping:1;
754 bool m_isInteractive:1;
f6bcfd97 755 bool m_isBBoxValid:1;
a23fd0e1
VZ
756
757 // coordinate system variables
758
759 // TODO short descriptions of what exactly they are would be nice...
760
72cdf4c9
VZ
761 wxCoord m_logicalOriginX, m_logicalOriginY;
762 wxCoord m_deviceOriginX, m_deviceOriginY;
a23fd0e1
VZ
763
764 double m_logicalScaleX, m_logicalScaleY;
765 double m_userScaleX, m_userScaleY;
766 double m_scaleX, m_scaleY;
767
768 // Used by SetAxisOrientation() to invert the axes
769 int m_signX, m_signY;
770
771 // bounding and clipping boxes
72cdf4c9
VZ
772 wxCoord m_minX, m_minY, m_maxX, m_maxY;
773 wxCoord m_clipX1, m_clipY1, m_clipX2, m_clipY2;
a23fd0e1
VZ
774
775 int m_logicalFunction;
776 int m_backgroundMode;
777 int m_mappingMode;
778
779 // GDI objects
780 wxPen m_pen;
781 wxBrush m_brush;
782 wxBrush m_backgroundBrush;
783 wxColour m_textForegroundColour;
784 wxColour m_textBackgroundColour;
785 wxFont m_font;
d275c7eb
VZ
786
787#if wxUSE_PALETTE
a23fd0e1 788 wxPalette m_palette;
b95edd47 789 bool m_hasCustomPalette;
d275c7eb 790#endif // wxUSE_PALETTE
a23fd0e1
VZ
791
792private:
ac84e37d 793 DECLARE_NO_COPY_CLASS(wxDCBase)
cd9da200 794 DECLARE_ABSTRACT_CLASS(wxDCBase)
a23fd0e1
VZ
795};
796
797// ----------------------------------------------------------------------------
798// now include the declaration of wxDC class
799// ----------------------------------------------------------------------------
800
4055ed82 801#if defined(__WXPALMOS__)
ffecfa5a
JS
802 #include "wx/palmos/dc.h"
803#elif defined(__WXMSW__)
a23fd0e1 804 #include "wx/msw/dc.h"
2049ba38 805#elif defined(__WXMOTIF__)
a23fd0e1 806 #include "wx/motif/dc.h"
2049ba38 807#elif defined(__WXGTK__)
a23fd0e1 808 #include "wx/gtk/dc.h"
83df96d6
JS
809#elif defined(__WXX11__)
810 #include "wx/x11/dc.h"
1e6feb95
VZ
811#elif defined(__WXMGL__)
812 #include "wx/mgl/dc.h"
34138703 813#elif defined(__WXMAC__)
a23fd0e1 814 #include "wx/mac/dc.h"
f4515f98
DE
815#elif defined(__WXCOCOA__)
816 #include "wx/cocoa/dc.h"
1777b9bb
DW
817#elif defined(__WXPM__)
818 #include "wx/os2/dc.h"
c801d85f
KB
819#endif
820
1e6feb95
VZ
821// ----------------------------------------------------------------------------
822// helper class: you can use it to temporarily change the DC text colour and
823// restore it automatically when the object goes out of scope
824// ----------------------------------------------------------------------------
825
826class WXDLLEXPORT wxDCTextColourChanger
827{
828public:
ba161d7e 829 wxDCTextColourChanger(wxDC& dc) : m_dc(dc), m_colFgOld() { }
1e6feb95
VZ
830
831 ~wxDCTextColourChanger()
832 {
833 if ( m_colFgOld.Ok() )
834 m_dc.SetTextForeground(m_colFgOld);
835 }
836
837 void Set(const wxColour& col)
838 {
839 if ( !m_colFgOld.Ok() )
840 m_colFgOld = m_dc.GetTextForeground();
841 m_dc.SetTextForeground(col);
842 }
843
844private:
845 wxDC& m_dc;
846
847 wxColour m_colFgOld;
fc7a2a60
VZ
848
849 DECLARE_NO_COPY_CLASS(wxDCTextColourChanger)
1e6feb95
VZ
850};
851
e26be42b
VZ
852// ----------------------------------------------------------------------------
853// another small helper class: sets the clipping region in its ctor and
854// destroys it in the dtor
855// ----------------------------------------------------------------------------
856
857class WXDLLEXPORT wxDCClipper
858{
859public:
860 wxDCClipper(wxDC& dc, const wxRect& r) : m_dc(dc)
861 { dc.SetClippingRegion(r.x, r.y, r.width, r.height); }
862 wxDCClipper(wxDC& dc, wxCoord x, wxCoord y, wxCoord w, wxCoord h) : m_dc(dc)
863 { dc.SetClippingRegion(x, y, w, h); }
864
865 ~wxDCClipper() { m_dc.DestroyClippingRegion(); }
866
867private:
868 wxDC& m_dc;
fc7a2a60
VZ
869
870 DECLARE_NO_COPY_CLASS(wxDCClipper)
e26be42b
VZ
871};
872
c801d85f 873#endif
34138703 874 // _WX_DC_H_BASE_