]> git.saurik.com Git - wxWidgets.git/blame - include/wx/dc.h
Add a trivial virtual dtor to wxMarkupParserOutput.
[wxWidgets.git] / include / wx / dc.h
CommitLineData
006162a9 1/////////////////////////////////////////////////////////////////////////////
4660e6ac 2// Name: wx/dc.h
006162a9 3// Purpose: wxDC class
6d52ca53 4// Author: Vadim Zeitlin
006162a9
VZ
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
0d80fb31 21#include "wx/intl.h" // for wxLayoutDirection
a23fd0e1
VZ
22#include "wx/cursor.h" // we have member variables of these classes
23#include "wx/font.h" // so we can't do without them
24#include "wx/colour.h"
b494e2b0 25#include "wx/bitmap.h" // for wxNullBitmap
a23fd0e1
VZ
26#include "wx/brush.h"
27#include "wx/pen.h"
28#include "wx/palette.h"
0919e93e 29#include "wx/dynarray.h"
19edb09c 30#include "wx/math.h"
02255e07 31#include "wx/image.h"
081d8d96 32#include "wx/region.h"
a23fd0e1 33
888dde65 34#define wxUSE_NEW_DC 1
2970ae54 35
ca7db61e 36class WXDLLIMPEXP_FWD_CORE wxDC;
ab171e95
RR
37class WXDLLIMPEXP_FWD_CORE wxClientDC;
38class WXDLLIMPEXP_FWD_CORE wxPaintDC;
39class WXDLLIMPEXP_FWD_CORE wxWindowDC;
40class WXDLLIMPEXP_FWD_CORE wxScreenDC;
41class WXDLLIMPEXP_FWD_CORE wxMemoryDC;
c8ddadff 42class WXDLLIMPEXP_FWD_CORE wxPrinterDC;
477c48bf 43class WXDLLIMPEXP_FWD_CORE wxPrintData;
888dde65 44
89efaf2b
FM
45// Logical ops
46enum wxRasterOperationMode
47{
48 wxCLEAR, // 0
49 wxXOR, // src XOR dst
50 wxINVERT, // NOT dst
51 wxOR_REVERSE, // src OR (NOT dst)
52 wxAND_REVERSE, // src AND (NOT dst)
53 wxCOPY, // src
54 wxAND, // src AND dst
55 wxAND_INVERT, // (NOT src) AND dst
56 wxNO_OP, // dst
57 wxNOR, // (NOT src) AND (NOT dst)
58 wxEQUIV, // (NOT src) XOR dst
59 wxSRC_INVERT, // (NOT src)
60 wxOR_INVERT, // (NOT src) OR dst
61 wxNAND, // (NOT src) OR (NOT dst)
62 wxOR, // src OR dst
63 wxSET // 1
79bd5e98 64#if WXWIN_COMPATIBILITY_2_8
89efaf2b
FM
65 ,wxROP_BLACK = wxCLEAR,
66 wxBLIT_BLACKNESS = wxCLEAR,
67 wxROP_XORPEN = wxXOR,
68 wxBLIT_SRCINVERT = wxXOR,
69 wxROP_NOT = wxINVERT,
70 wxBLIT_DSTINVERT = wxINVERT,
71 wxROP_MERGEPENNOT = wxOR_REVERSE,
72 wxBLIT_00DD0228 = wxOR_REVERSE,
73 wxROP_MASKPENNOT = wxAND_REVERSE,
74 wxBLIT_SRCERASE = wxAND_REVERSE,
75 wxROP_COPYPEN = wxCOPY,
76 wxBLIT_SRCCOPY = wxCOPY,
77 wxROP_MASKPEN = wxAND,
78 wxBLIT_SRCAND = wxAND,
79 wxROP_MASKNOTPEN = wxAND_INVERT,
80 wxBLIT_00220326 = wxAND_INVERT,
81 wxROP_NOP = wxNO_OP,
82 wxBLIT_00AA0029 = wxNO_OP,
83 wxROP_NOTMERGEPEN = wxNOR,
84 wxBLIT_NOTSRCERASE = wxNOR,
85 wxROP_NOTXORPEN = wxEQUIV,
86 wxBLIT_00990066 = wxEQUIV,
87 wxROP_NOTCOPYPEN = wxSRC_INVERT,
88 wxBLIT_NOTSCRCOPY = wxSRC_INVERT,
89 wxROP_MERGENOTPEN = wxOR_INVERT,
90 wxBLIT_MERGEPAINT = wxOR_INVERT,
91 wxROP_NOTMASKPEN = wxNAND,
92 wxBLIT_007700E6 = wxNAND,
93 wxROP_MERGEPEN = wxOR,
94 wxBLIT_SRCPAINT = wxOR,
95 wxROP_WHITE = wxSET,
96 wxBLIT_WHITENESS = wxSET
97#endif //WXWIN_COMPATIBILITY_2_8
98};
99
100// Flood styles
101enum wxFloodFillStyle
102{
103 wxFLOOD_SURFACE = 1,
104 wxFLOOD_BORDER
105};
106
e65a6cc1 107// Mapping modes
89efaf2b
FM
108enum wxMappingMode
109{
110 wxMM_TEXT = 1,
e65a6cc1 111 wxMM_METRIC,
89efaf2b 112 wxMM_LOMETRIC,
89efaf2b 113 wxMM_TWIPS,
e65a6cc1 114 wxMM_POINTS
89efaf2b
FM
115};
116
e29bf4b0
VZ
117// Description of text characteristics.
118struct wxFontMetrics
119{
120 wxFontMetrics()
121 {
122 height =
123 ascent =
124 descent =
125 internalLeading =
126 externalLeading =
127 averageWidth = 0;
128 }
129
130 int height, // Total character height.
131 ascent, // Part of the height above the baseline.
132 descent, // Part of the height below the baseline.
133 internalLeading, // Intra-line spacing.
134 externalLeading, // Inter-line spacing.
135 averageWidth; // Average font width, a.k.a. "x-width".
136};
137
0a0e4984
VZ
138#if WXWIN_COMPATIBILITY_2_8
139
888dde65
RR
140//-----------------------------------------------------------------------------
141// wxDrawObject helper class
142//-----------------------------------------------------------------------------
ca7db61e 143
713e9290 144class WXDLLIMPEXP_CORE wxDrawObject
ca7db61e
RR
145{
146public:
713e9290 147 wxDEPRECATED_CONSTRUCTOR(wxDrawObject)()
ca7db61e
RR
148 : m_isBBoxValid(false)
149 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
150 { }
151
152 virtual ~wxDrawObject() { }
153
ca7db61e 154 virtual void Draw(wxDC&) const { }
ca7db61e
RR
155
156 virtual void CalcBoundingBox(wxCoord x, wxCoord y)
157 {
158 if ( m_isBBoxValid )
159 {
160 if ( x < m_minX ) m_minX = x;
161 if ( y < m_minY ) m_minY = y;
162 if ( x > m_maxX ) m_maxX = x;
163 if ( y > m_maxY ) m_maxY = y;
164 }
165 else
166 {
167 m_isBBoxValid = true;
168
169 m_minX = x;
170 m_minY = y;
171 m_maxX = x;
172 m_maxY = y;
173 }
174 }
175
176 void ResetBoundingBox()
177 {
178 m_isBBoxValid = false;
179
180 m_minX = m_maxX = m_minY = m_maxY = 0;
181 }
182
183 // Get the final bounding box of the PostScript or Metafile picture.
184
185 wxCoord MinX() const { return m_minX; }
186 wxCoord MaxX() const { return m_maxX; }
187 wxCoord MinY() const { return m_minY; }
188 wxCoord MaxY() const { return m_maxY; }
189
190 //to define the type of object for derived objects
191 virtual int GetType()=0;
192
193protected:
194 //for boundingbox calculation
195 bool m_isBBoxValid:1;
196 //for boundingbox calculation
197 wxCoord m_minX, m_minY, m_maxX, m_maxY;
198};
199
0a0e4984
VZ
200#endif // WXWIN_COMPATIBILITY_2_8
201
ca7db61e 202
2970ae54
RR
203//-----------------------------------------------------------------------------
204// wxDCFactory
205//-----------------------------------------------------------------------------
206
888dde65 207class WXDLLIMPEXP_FWD_CORE wxDCImpl;
2970ae54
RR
208
209class WXDLLIMPEXP_CORE wxDCFactory
210{
211public:
212 wxDCFactory() {}
213 virtual ~wxDCFactory() {}
f0875501 214
888dde65 215 virtual wxDCImpl* CreateWindowDC( wxWindowDC *owner, wxWindow *window ) = 0;
888dde65 216 virtual wxDCImpl* CreateClientDC( wxClientDC *owner, wxWindow *window ) = 0;
888dde65
RR
217 virtual wxDCImpl* CreatePaintDC( wxPaintDC *owner, wxWindow *window ) = 0;
218 virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner ) = 0;
219 virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner, wxBitmap &bitmap ) = 0;
220 virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner, wxDC *dc ) = 0;
221 virtual wxDCImpl* CreateScreenDC( wxScreenDC *owner ) = 0;
6b4f4d47 222#if wxUSE_PRINTING_ARCHITECTURE
888dde65 223 virtual wxDCImpl* CreatePrinterDC( wxPrinterDC *owner, const wxPrintData &data ) = 0;
6b4f4d47 224#endif
f0875501 225
f2498c4e 226 static void Set(wxDCFactory *factory);
f0875501
VZ
227 static wxDCFactory *Get();
228
2970ae54
RR
229private:
230 static wxDCFactory *m_factory;
231};
232
233//-----------------------------------------------------------------------------
234// wxNativeDCFactory
235//-----------------------------------------------------------------------------
236
ab171e95 237class WXDLLIMPEXP_CORE wxNativeDCFactory: public wxDCFactory
2970ae54
RR
238{
239public:
240 wxNativeDCFactory() {}
f0875501 241
888dde65 242 virtual wxDCImpl* CreateWindowDC( wxWindowDC *owner, wxWindow *window );
888dde65 243 virtual wxDCImpl* CreateClientDC( wxClientDC *owner, wxWindow *window );
888dde65
RR
244 virtual wxDCImpl* CreatePaintDC( wxPaintDC *owner, wxWindow *window );
245 virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner );
246 virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner, wxBitmap &bitmap );
247 virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner, wxDC *dc );
248 virtual wxDCImpl* CreateScreenDC( wxScreenDC *owner );
6b4f4d47 249#if wxUSE_PRINTING_ARCHITECTURE
888dde65 250 virtual wxDCImpl* CreatePrinterDC( wxPrinterDC *owner, const wxPrintData &data );
6b4f4d47 251#endif
2970ae54
RR
252};
253
2970ae54 254//-----------------------------------------------------------------------------
888dde65 255// wxDCImpl
2970ae54
RR
256//-----------------------------------------------------------------------------
257
888dde65 258class WXDLLIMPEXP_CORE wxDCImpl: public wxObject
2970ae54
RR
259{
260public:
888dde65 261 wxDCImpl( wxDC *owner );
edc51344 262 virtual ~wxDCImpl();
f0875501 263
ab171e95 264 wxDC *GetOwner() const { return m_owner; }
f0875501 265
888dde65 266 wxWindow* GetWindow() const { return m_window; }
f0875501 267
2970ae54
RR
268 virtual bool IsOk() const { return m_ok; }
269
270 // query capabilities
271
272 virtual bool CanDrawBitmap() const = 0;
273 virtual bool CanGetTextExtent() const = 0;
274
0b822969
RR
275 // get Cairo context
276 virtual void* GetCairoContext() const
2b44ffc0
RR
277 {
278 return NULL;
279 }
2b44ffc0 280
2970ae54
RR
281 // query dimension, colour deps, resolution
282
283 virtual void DoGetSize(int *width, int *height) const = 0;
4a624f6e
VZ
284 void GetSize(int *width, int *height) const
285 {
243ef54b
CE
286 DoGetSize(width, height);
287 return ;
4a624f6e
VZ
288 }
289
290 wxSize GetSize() const
291 {
292 int w, h;
293 DoGetSize(&w, &h);
294 return wxSize(w, h);
295 }
296
2970ae54 297 virtual void DoGetSizeMM(int* width, int* height) const = 0;
f0875501 298
2970ae54
RR
299 virtual int GetDepth() const = 0;
300 virtual wxSize GetPPI() const = 0;
f0875501 301
2970ae54 302 // Right-To-Left (RTL) modes
f0875501 303
2970ae54
RR
304 virtual void SetLayoutDirection(wxLayoutDirection WXUNUSED(dir)) { }
305 virtual wxLayoutDirection GetLayoutDirection() const { return wxLayout_Default; }
f0875501
VZ
306
307 // page and document
308
2970ae54
RR
309 virtual bool StartDoc(const wxString& WXUNUSED(message)) { return true; }
310 virtual void EndDoc() { }
311
312 virtual void StartPage() { }
313 virtual void EndPage() { }
314
cc18b1c7
SC
315 // flushing the content of this dc immediately eg onto screen
316 virtual void Flush() { }
317
2970ae54
RR
318 // bounding box
319
ca7db61e 320 virtual void CalcBoundingBox(wxCoord x, wxCoord y)
2970ae54
RR
321 {
322 if ( m_isBBoxValid )
323 {
324 if ( x < m_minX ) m_minX = x;
325 if ( y < m_minY ) m_minY = y;
326 if ( x > m_maxX ) m_maxX = x;
327 if ( y > m_maxY ) m_maxY = y;
328 }
329 else
330 {
331 m_isBBoxValid = true;
332
333 m_minX = x;
334 m_minY = y;
335 m_maxX = x;
336 m_maxY = y;
337 }
338 }
ca7db61e 339 void ResetBoundingBox()
2970ae54
RR
340 {
341 m_isBBoxValid = false;
342
343 m_minX = m_maxX = m_minY = m_maxY = 0;
344 }
345
346 wxCoord MinX() const { return m_minX; }
347 wxCoord MaxX() const { return m_maxX; }
348 wxCoord MinY() const { return m_minY; }
349 wxCoord MaxY() const { return m_maxY; }
f0875501 350
2970ae54
RR
351 // setters and getters
352
353 virtual void SetFont(const wxFont& font) = 0;
edc51344 354 virtual const wxFont& GetFont() const { return m_font; }
f0875501 355
2970ae54 356 virtual void SetPen(const wxPen& pen) = 0;
edc51344 357 virtual const wxPen& GetPen() const { return m_pen; }
f0875501 358
2970ae54 359 virtual void SetBrush(const wxBrush& brush) = 0;
edc51344 360 virtual const wxBrush& GetBrush() const { return m_brush; }
f0875501 361
2970ae54 362 virtual void SetBackground(const wxBrush& brush) = 0;
edc51344 363 virtual const wxBrush& GetBackground() const { return m_backgroundBrush; }
f0875501 364
2970ae54
RR
365 virtual void SetBackgroundMode(int mode) = 0;
366 virtual int GetBackgroundMode() const { return m_backgroundMode; }
367
368 virtual void SetTextForeground(const wxColour& colour)
369 { m_textForegroundColour = colour; }
edc51344
VZ
370 virtual const wxColour& GetTextForeground() const
371 { return m_textForegroundColour; }
f0875501 372
2970ae54
RR
373 virtual void SetTextBackground(const wxColour& colour)
374 { m_textBackgroundColour = colour; }
edc51344
VZ
375 virtual const wxColour& GetTextBackground() const
376 { return m_textBackgroundColour; }
2970ae54
RR
377
378#if wxUSE_PALETTE
379 virtual void SetPalette(const wxPalette& palette) = 0;
380#endif // wxUSE_PALETTE
381
edc51344
VZ
382 // inherit the DC attributes (font and colours) from the given window
383 //
384 // this is called automatically when a window, client or paint DC is
385 // created
386 virtual void InheritAttributes(wxWindow *win);
387
388
2970ae54 389 // logical functions
f0875501 390
89efaf2b 391 virtual void SetLogicalFunction(wxRasterOperationMode function) = 0;
e65a6cc1 392 virtual wxRasterOperationMode GetLogicalFunction() const
89efaf2b 393 { return m_logicalFunction; }
2970ae54
RR
394
395 // text measurement
396
397 virtual wxCoord GetCharHeight() const = 0;
398 virtual wxCoord GetCharWidth() const = 0;
e29bf4b0
VZ
399
400 // The derived classes should really override DoGetFontMetrics() to return
401 // the correct values in the future but for now provide a default
402 // implementation in terms of DoGetTextExtent() to avoid breaking the
403 // compilation of all other ports as wxMSW is the only one to implement it.
404 virtual void DoGetFontMetrics(int *height,
405 int *ascent,
406 int *descent,
407 int *internalLeading,
408 int *externalLeading,
409 int *averageWidth) const;
410
2970ae54
RR
411 virtual void DoGetTextExtent(const wxString& string,
412 wxCoord *x, wxCoord *y,
413 wxCoord *descent = NULL,
414 wxCoord *externalLeading = NULL,
415 const wxFont *theFont = NULL) const = 0;
416 virtual void GetMultiLineTextExtent(const wxString& string,
417 wxCoord *width,
418 wxCoord *height,
419 wxCoord *heightLine = NULL,
420 const wxFont *font = NULL) const;
421 virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
f0875501 422
2970ae54 423 // clearing
f0875501 424
2970ae54
RR
425 virtual void Clear() = 0;
426
427 // clipping
428
429 virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
430 wxCoord width, wxCoord height) = 0;
fdaad94e
VZ
431
432 // NB: this function works with device coordinates, not the logical ones!
433 virtual void DoSetDeviceClippingRegion(const wxRegion& region) = 0;
2970ae54
RR
434
435 virtual void DoGetClippingBox(wxCoord *x, wxCoord *y,
436 wxCoord *w, wxCoord *h) const
437 {
438 if ( x )
439 *x = m_clipX1;
440 if ( y )
441 *y = m_clipY1;
442 if ( w )
443 *w = m_clipX2 - m_clipX1;
444 if ( h )
445 *h = m_clipY2 - m_clipY1;
446 }
447
448 virtual void DestroyClippingRegion() { ResetClipping(); }
449
450
451 // coordinates conversions and transforms
452
453 virtual wxCoord DeviceToLogicalX(wxCoord x) const;
454 virtual wxCoord DeviceToLogicalY(wxCoord y) const;
455 virtual wxCoord DeviceToLogicalXRel(wxCoord x) const;
456 virtual wxCoord DeviceToLogicalYRel(wxCoord y) const;
457 virtual wxCoord LogicalToDeviceX(wxCoord x) const;
458 virtual wxCoord LogicalToDeviceY(wxCoord y) const;
459 virtual wxCoord LogicalToDeviceXRel(wxCoord x) const;
460 virtual wxCoord LogicalToDeviceYRel(wxCoord y) const;
461
89efaf2b
FM
462 virtual void SetMapMode(wxMappingMode mode);
463 virtual wxMappingMode GetMapMode() const { return m_mappingMode; }
2970ae54
RR
464
465 virtual void SetUserScale(double x, double y);
466 virtual void GetUserScale(double *x, double *y) const
467 {
468 if ( x ) *x = m_userScaleX;
469 if ( y ) *y = m_userScaleY;
470 }
471
472 virtual void SetLogicalScale(double x, double y);
473 virtual void GetLogicalScale(double *x, double *y)
474 {
475 if ( x ) *x = m_logicalScaleX;
476 if ( y ) *y = m_logicalScaleY;
477 }
478
479 virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
480 virtual void DoGetLogicalOrigin(wxCoord *x, wxCoord *y) const
481 {
482 if ( x ) *x = m_logicalOriginX;
483 if ( y ) *y = m_logicalOriginY;
484 }
485
486 virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
487 virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const
488 {
489 if ( x ) *x = m_deviceOriginX;
490 if ( y ) *y = m_deviceOriginY;
491 }
f0875501 492
2970ae54
RR
493 virtual void SetDeviceLocalOrigin( wxCoord x, wxCoord y );
494
495 virtual void ComputeScaleAndOrigin();
496
497 // this needs to overidden if the axis is inverted
498 virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
499
500 // ---------------------------------------------------------
501 // the actual drawing API
502
503 virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
89efaf2b 504 wxFloodFillStyle style = wxFLOOD_SURFACE) = 0;
2970ae54
RR
505
506 virtual void DoGradientFillLinear(const wxRect& rect,
507 const wxColour& initialColour,
508 const wxColour& destColour,
509 wxDirection nDirection = wxEAST);
510
511 virtual void DoGradientFillConcentric(const wxRect& rect,
512 const wxColour& initialColour,
513 const wxColour& destColour,
514 const wxPoint& circleCenter);
515
516 virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const = 0;
517
518 virtual void DoDrawPoint(wxCoord x, wxCoord y) = 0;
519 virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) = 0;
520
521 virtual void DoDrawArc(wxCoord x1, wxCoord y1,
522 wxCoord x2, wxCoord y2,
523 wxCoord xc, wxCoord yc) = 0;
524 virtual void DoDrawCheckMark(wxCoord x, wxCoord y,
525 wxCoord width, wxCoord height);
526 virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
527 double sa, double ea) = 0;
528
529 virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) = 0;
530 virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
531 wxCoord width, wxCoord height,
532 double radius) = 0;
533 virtual void DoDrawEllipse(wxCoord x, wxCoord y,
534 wxCoord width, wxCoord height) = 0;
535
536 virtual void DoCrossHair(wxCoord x, wxCoord y) = 0;
537
538 virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) = 0;
539 virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
540 bool useMask = false) = 0;
541
542 virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y) = 0;
543 virtual void DoDrawRotatedText(const wxString& text,
544 wxCoord x, wxCoord y, double angle) = 0;
545
546 virtual bool DoBlit(wxCoord xdest, wxCoord ydest,
547 wxCoord width, wxCoord height,
548 wxDC *source,
549 wxCoord xsrc, wxCoord ysrc,
89efaf2b 550 wxRasterOperationMode rop = wxCOPY,
2970ae54
RR
551 bool useMask = false,
552 wxCoord xsrcMask = wxDefaultCoord,
553 wxCoord ysrcMask = wxDefaultCoord) = 0;
554
555 virtual bool DoStretchBlit(wxCoord xdest, wxCoord ydest,
556 wxCoord dstWidth, wxCoord dstHeight,
557 wxDC *source,
558 wxCoord xsrc, wxCoord ysrc,
559 wxCoord srcWidth, wxCoord srcHeight,
89efaf2b 560 wxRasterOperationMode rop = wxCOPY,
2970ae54
RR
561 bool useMask = false,
562 wxCoord xsrcMask = wxDefaultCoord,
563 wxCoord ysrcMask = wxDefaultCoord);
564
565 virtual wxBitmap DoGetAsBitmap(const wxRect *WXUNUSED(subrect)) const
566 { return wxNullBitmap; }
567
568
569 virtual void DoDrawLines(int n, wxPoint points[],
4f37154e
RR
570 wxCoord xoffset, wxCoord yoffset ) = 0;
571 virtual void DrawLines(const wxPointList *list,
572 wxCoord xoffset, wxCoord yoffset );
f0875501 573
2970ae54 574 virtual void DoDrawPolygon(int n, wxPoint points[],
89efaf2b
FM
575 wxCoord xoffset, wxCoord yoffset,
576 wxPolygonFillMode fillStyle = wxODDEVEN_RULE) = 0;
2970ae54
RR
577 virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[],
578 wxCoord xoffset, wxCoord yoffset,
89efaf2b 579 wxPolygonFillMode fillStyle);
4f37154e
RR
580 void DrawPolygon(const wxPointList *list,
581 wxCoord xoffset, wxCoord yoffset,
89efaf2b 582 wxPolygonFillMode fillStyle );
2970ae54
RR
583
584
585#if wxUSE_SPLINES
7210c3a1
VZ
586 void DrawSpline(wxCoord x1, wxCoord y1,
587 wxCoord x2, wxCoord y2,
588 wxCoord x3, wxCoord y3);
589 void DrawSpline(int n, wxPoint points[]);
590 void DrawSpline(const wxPointList *points) { DoDrawSpline(points); }
591
b0d7707b 592 virtual void DoDrawSpline(const wxPointList *points);
2970ae54 593#endif
f0875501 594
4f37154e
RR
595 // ---------------------------------------------------------
596 // wxMemoryDC Impl API
597
598 virtual void DoSelect(const wxBitmap& WXUNUSED(bmp))
599 { }
f0875501 600
4f37154e
RR
601 virtual const wxBitmap& GetSelectedBitmap() const
602 { return wxNullBitmap; }
603 virtual wxBitmap& GetSelectedBitmap()
604 { return wxNullBitmap; }
f0875501 605
4f37154e
RR
606 // ---------------------------------------------------------
607 // wxPrinterDC Impl API
608
6d52ca53 609 virtual wxRect GetPaperRect() const
4f37154e 610 { int w = 0; int h = 0; DoGetSize( &w, &h ); return wxRect(0,0,w,h); }
f0875501 611
6d52ca53 612 virtual int GetResolution() const
4f37154e
RR
613 { return -1; }
614
2970ae54 615private:
888dde65 616 wxDC *m_owner;
2970ae54 617
f0875501 618protected:
2970ae54
RR
619 // unset clipping variables (after clipping region was destroyed)
620 void ResetClipping()
621 {
622 m_clipping = false;
623
624 m_clipX1 = m_clipX2 = m_clipY1 = m_clipY2 = 0;
625 }
626
2261baf7
VZ
627#ifdef __WXWINCE__
628 //! Generic method to draw ellipses, circles and arcs with current pen and brush.
629 /*! \param x Upper left corner of bounding box.
630 * \param y Upper left corner of bounding box.
631 * \param w Width of bounding box.
632 * \param h Height of bounding box.
633 * \param sa Starting angle of arc
634 * (counterclockwise, start at 3 o'clock, 360 is full circle).
635 * \param ea Ending angle of arc.
636 * \param angle Rotation angle, the Arc will be rotated after
637 * calculating begin and end.
638 */
639 void DrawEllipticArcRot( wxCoord x, wxCoord y,
640 wxCoord width, wxCoord height,
641 double sa = 0, double ea = 0, double angle = 0 )
642 { DoDrawEllipticArcRot( x, y, width, height, sa, ea, angle ); }
643
644 void DrawEllipticArcRot( const wxPoint& pt,
645 const wxSize& sz,
646 double sa = 0, double ea = 0, double angle = 0 )
647 { DoDrawEllipticArcRot( pt.x, pt.y, sz.x, sz.y, sa, ea, angle ); }
648
649 void DrawEllipticArcRot( const wxRect& rect,
650 double sa = 0, double ea = 0, double angle = 0 )
651 { DoDrawEllipticArcRot( rect.x, rect.y, rect.width, rect.height, sa, ea, angle ); }
652
653 virtual void DoDrawEllipticArcRot( wxCoord x, wxCoord y,
654 wxCoord w, wxCoord h,
655 double sa = 0, double ea = 0, double angle = 0 );
656
657 //! Rotates points around center.
658 /*! This is a quite straight method, it calculates in pixels
659 * and so it produces rounding errors.
660 * \param points The points inside will be rotated.
661 * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle).
662 * \param center Center of rotation.
663 */
664 void Rotate( wxPointList* points, double angle, wxPoint center = wxPoint(0,0) );
665
666 // used by DrawEllipticArcRot
667 // Careful: wxList gets filled with points you have to delete later.
668 void CalculateEllipticPoints( wxPointList* points,
669 wxCoord xStart, wxCoord yStart,
670 wxCoord w, wxCoord h,
671 double sa, double ea );
672#endif // __WXWINCE__
673
12ca5586
VS
674 // returns adjustment factor for converting wxFont "point size"; in wx
675 // it is point size on screen and needs to be multiplied by this value
676 // for rendering on higher-resolution DCs such as printer ones
677 static float GetFontPointSizeAdjustment(float dpi);
2261baf7 678
888dde65
RR
679 // window on which the DC draws or NULL
680 wxWindow *m_window;
f0875501 681
2970ae54
RR
682 // flags
683 bool m_colour:1;
684 bool m_ok:1;
685 bool m_clipping:1;
686 bool m_isInteractive:1;
687 bool m_isBBoxValid:1;
688
689 // coordinate system variables
690
691 wxCoord m_logicalOriginX, m_logicalOriginY;
692 wxCoord m_deviceOriginX, m_deviceOriginY; // Usually 0,0, can be change by user
f0875501 693
2970ae54
RR
694 wxCoord m_deviceLocalOriginX, m_deviceLocalOriginY; // non-zero if native top-left corner
695 // is not at 0,0. This was the case under
696 // Mac's GrafPorts (coordinate system
697 // used toplevel window's origin) and
698 // e.g. for Postscript, where the native
699 // origin in the bottom left corner.
700 double m_logicalScaleX, m_logicalScaleY;
701 double m_userScaleX, m_userScaleY;
702 double m_scaleX, m_scaleY; // calculated from logical scale and user scale
703
704 int m_signX, m_signY; // Used by SetAxisOrientation() to invert the axes
f0875501 705
2970ae54
RR
706 // what is a mm on a screen you don't know the size of?
707 double m_mm_to_pix_x,
708 m_mm_to_pix_y;
f0875501 709
2970ae54
RR
710 // bounding and clipping boxes
711 wxCoord m_minX, m_minY, m_maxX, m_maxY;
712 wxCoord m_clipX1, m_clipY1, m_clipX2, m_clipY2;
713
89efaf2b 714 wxRasterOperationMode m_logicalFunction;
2970ae54 715 int m_backgroundMode;
89efaf2b 716 wxMappingMode m_mappingMode;
2970ae54
RR
717
718 wxPen m_pen;
719 wxBrush m_brush;
720 wxBrush m_backgroundBrush;
721 wxColour m_textForegroundColour;
722 wxColour m_textBackgroundColour;
723 wxFont m_font;
724
725#if wxUSE_PALETTE
726 wxPalette m_palette;
727 bool m_hasCustomPalette;
728#endif // wxUSE_PALETTE
729
730private:
888dde65 731 DECLARE_ABSTRACT_CLASS(wxDCImpl)
ca7db61e 732};
2970ae54
RR
733
734
f0875501 735class WXDLLIMPEXP_CORE wxDC : public wxObject
2970ae54
RR
736{
737public:
4feecbb9
VZ
738 // copy attributes (font, colours and writing direction) from another DC
739 void CopyAttributes(const wxDC& dc);
740
f0875501 741 virtual ~wxDC() { delete m_pimpl; }
2970ae54 742
888dde65 743 wxDCImpl *GetImpl()
ab171e95 744 { return m_pimpl; }
888dde65 745 const wxDCImpl *GetImpl() const
32043152
RR
746 { return m_pimpl; }
747
1f991c9d 748 wxWindow *GetWindow() const
888dde65 749 { return m_pimpl->GetWindow(); }
ab171e95 750
f0875501 751 bool IsOk() const
2970ae54
RR
752 { return m_pimpl && m_pimpl->IsOk(); }
753
754 // query capabilities
755
f0875501 756 bool CanDrawBitmap() const
2970ae54
RR
757 { return m_pimpl->CanDrawBitmap(); }
758 bool CanGetTextExtent() const
759 { return m_pimpl->CanGetTextExtent(); }
f0875501 760
2970ae54
RR
761 // query dimension, colour deps, resolution
762
763 void GetSize(int *width, int *height) const
764 { m_pimpl->DoGetSize(width, height); }
2970ae54 765 wxSize GetSize() const
4a624f6e 766 { return m_pimpl->GetSize(); }
2970ae54
RR
767
768 void GetSizeMM(int* width, int* height) const
769 { m_pimpl->DoGetSizeMM(width, height); }
770 wxSize GetSizeMM() const
771 {
772 int w, h;
773 m_pimpl->DoGetSizeMM(&w, &h);
774 return wxSize(w, h);
775 }
f0875501 776
2970ae54
RR
777 int GetDepth() const
778 { return m_pimpl->GetDepth(); }
779 wxSize GetPPI() const
780 { return m_pimpl->GetPPI(); }
781
6d52ca53 782 virtual int GetResolution() const
4f37154e 783 { return m_pimpl->GetResolution(); }
f0875501 784
2970ae54 785 // Right-To-Left (RTL) modes
f0875501 786
2970ae54
RR
787 void SetLayoutDirection(wxLayoutDirection dir)
788 { m_pimpl->SetLayoutDirection( dir ); }
789 wxLayoutDirection GetLayoutDirection() const
790 { return m_pimpl->GetLayoutDirection(); }
f0875501
VZ
791
792 // page and document
793
2970ae54
RR
794 bool StartDoc(const wxString& message)
795 { return m_pimpl->StartDoc(message); }
796 void EndDoc()
797 { m_pimpl->EndDoc(); }
798
799 void StartPage()
800 { m_pimpl->StartPage(); }
801 void EndPage()
802 { m_pimpl->EndPage(); }
803
804 // bounding box
f0875501 805
2970ae54
RR
806 void CalcBoundingBox(wxCoord x, wxCoord y)
807 { m_pimpl->CalcBoundingBox(x,y); }
808 void ResetBoundingBox()
809 { m_pimpl->ResetBoundingBox(); }
f0875501 810
2970ae54
RR
811 wxCoord MinX() const
812 { return m_pimpl->MinX(); }
813 wxCoord MaxX() const
814 { return m_pimpl->MaxX(); }
815 wxCoord MinY() const
816 { return m_pimpl->MinY(); }
817 wxCoord MaxY() const
818 { return m_pimpl->MaxY(); }
f0875501 819
2970ae54
RR
820 // setters and getters
821
822 void SetFont(const wxFont& font)
823 { m_pimpl->SetFont( font ); }
f0875501 824 const wxFont& GetFont() const
2970ae54 825 { return m_pimpl->GetFont(); }
f0875501 826
2970ae54
RR
827 void SetPen(const wxPen& pen)
828 { m_pimpl->SetPen( pen ); }
f0875501 829 const wxPen& GetPen() const
2970ae54 830 { return m_pimpl->GetPen(); }
f0875501 831
2970ae54
RR
832 void SetBrush(const wxBrush& brush)
833 { m_pimpl->SetBrush( brush ); }
834 const wxBrush& GetBrush() const
835 { return m_pimpl->GetBrush(); }
f0875501 836
2970ae54
RR
837 void SetBackground(const wxBrush& brush)
838 { m_pimpl->SetBackground( brush ); }
839 const wxBrush& GetBackground() const
840 { return m_pimpl->GetBackground(); }
f0875501 841
2970ae54 842 void SetBackgroundMode(int mode)
ca7db61e 843 { m_pimpl->SetBackgroundMode( mode ); }
2970ae54 844 int GetBackgroundMode() const
ca7db61e 845 { return m_pimpl->GetBackgroundMode(); }
2970ae54
RR
846
847 void SetTextForeground(const wxColour& colour)
848 { m_pimpl->SetTextForeground(colour); }
849 const wxColour& GetTextForeground() const
850 { return m_pimpl->GetTextForeground(); }
f0875501 851
2970ae54
RR
852 void SetTextBackground(const wxColour& colour)
853 { m_pimpl->SetTextBackground(colour); }
f0875501 854 const wxColour& GetTextBackground() const
2970ae54
RR
855 { return m_pimpl->GetTextBackground(); }
856
857#if wxUSE_PALETTE
858 void SetPalette(const wxPalette& palette)
859 { m_pimpl->SetPalette(palette); }
860#endif // wxUSE_PALETTE
f0875501 861
2970ae54 862 // logical functions
f0875501 863
89efaf2b 864 void SetLogicalFunction(wxRasterOperationMode function)
2970ae54 865 { m_pimpl->SetLogicalFunction(function); }
89efaf2b 866 wxRasterOperationMode GetLogicalFunction() const
2970ae54 867 { return m_pimpl->GetLogicalFunction(); }
f0875501 868
2970ae54
RR
869 // text measurement
870
871 wxCoord GetCharHeight() const
872 { return m_pimpl->GetCharHeight(); }
873 wxCoord GetCharWidth() const
874 { return m_pimpl->GetCharWidth(); }
f0875501 875
e29bf4b0
VZ
876 wxFontMetrics GetFontMetrics() const
877 {
878 wxFontMetrics fm;
879 m_pimpl->DoGetFontMetrics(&fm.height, &fm.ascent, &fm.descent,
880 &fm.internalLeading, &fm.externalLeading,
881 &fm.averageWidth);
882 return fm;
883 }
884
2970ae54
RR
885 void GetTextExtent(const wxString& string,
886 wxCoord *x, wxCoord *y,
887 wxCoord *descent = NULL,
888 wxCoord *externalLeading = NULL,
889 const wxFont *theFont = NULL) const
890 { m_pimpl->DoGetTextExtent(string, x, y, descent, externalLeading, theFont); }
891
892 wxSize GetTextExtent(const wxString& string) const
893 {
894 wxCoord w, h;
895 m_pimpl->DoGetTextExtent(string, &w, &h);
896 return wxSize(w, h);
897 }
f0875501 898
2970ae54
RR
899 void GetMultiLineTextExtent(const wxString& string,
900 wxCoord *width,
901 wxCoord *height,
902 wxCoord *heightLine = NULL,
903 const wxFont *font = NULL) const
904 { m_pimpl->GetMultiLineTextExtent( string, width, height, heightLine, font ); }
f0875501 905
2970ae54
RR
906 wxSize GetMultiLineTextExtent(const wxString& string) const
907 {
908 wxCoord w, h;
909 m_pimpl->GetMultiLineTextExtent(string, &w, &h);
910 return wxSize(w, h);
911 }
f0875501 912
2970ae54
RR
913 bool GetPartialTextExtents(const wxString& text, wxArrayInt& widths) const
914 { return m_pimpl->DoGetPartialTextExtents(text, widths); }
f0875501 915
2970ae54 916 // clearing
f0875501 917
2970ae54
RR
918 void Clear()
919 { m_pimpl->Clear(); }
920
921 // clipping
922
923 void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
924 { m_pimpl->DoSetClippingRegion(x, y, width, height); }
925 void SetClippingRegion(const wxPoint& pt, const wxSize& sz)
926 { m_pimpl->DoSetClippingRegion(pt.x, pt.y, sz.x, sz.y); }
927 void SetClippingRegion(const wxRect& rect)
928 { m_pimpl->DoSetClippingRegion(rect.x, rect.y, rect.width, rect.height); }
fdaad94e
VZ
929
930 // unlike the functions above, the coordinates of the region used in this
931 // one are in device coordinates, not the logical ones
932 void SetDeviceClippingRegion(const wxRegion& region)
933 { m_pimpl->DoSetDeviceClippingRegion(region); }
934
935 // this function is deprecated because its name is confusing: you may
936 // expect it to work with logical coordinates but, in fact, it does exactly
937 // the same thing as SetDeviceClippingRegion()
938 //
939 // please review the code using it and either replace it with calls to
940 // SetDeviceClippingRegion() or correct it if it was [wrongly] passing
941 // logical coordinates to this function
942 wxDEPRECATED_INLINE(void SetClippingRegion(const wxRegion& region),
943 SetDeviceClippingRegion(region); )
2970ae54
RR
944
945 void DestroyClippingRegion()
946 { m_pimpl->DestroyClippingRegion(); }
947
948 void GetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const
949 { m_pimpl->DoGetClippingBox(x, y, w, h); }
950 void GetClippingBox(wxRect& rect) const
951 { m_pimpl->DoGetClippingBox(&rect.x, &rect.y, &rect.width, &rect.height); }
f0875501 952
2970ae54
RR
953 // coordinates conversions and transforms
954
955 wxCoord DeviceToLogicalX(wxCoord x) const
956 { return m_pimpl->DeviceToLogicalX(x); }
ca7db61e 957 wxCoord DeviceToLogicalY(wxCoord y) const
2970ae54 958 { return m_pimpl->DeviceToLogicalY(y); }
ca7db61e 959 wxCoord DeviceToLogicalXRel(wxCoord x) const
2970ae54 960 { return m_pimpl->DeviceToLogicalXRel(x); }
ca7db61e 961 wxCoord DeviceToLogicalYRel(wxCoord y) const
2970ae54 962 { return m_pimpl->DeviceToLogicalYRel(y); }
ca7db61e 963 wxCoord LogicalToDeviceX(wxCoord x) const
2970ae54 964 { return m_pimpl->LogicalToDeviceX(x); }
ca7db61e 965 wxCoord LogicalToDeviceY(wxCoord y) const
2970ae54 966 { return m_pimpl->LogicalToDeviceY(y); }
ca7db61e 967 wxCoord LogicalToDeviceXRel(wxCoord x) const
2970ae54 968 { return m_pimpl->LogicalToDeviceXRel(x); }
ca7db61e 969 wxCoord LogicalToDeviceYRel(wxCoord y) const
2970ae54
RR
970 { return m_pimpl->LogicalToDeviceYRel(y); }
971
89efaf2b 972 void SetMapMode(wxMappingMode mode)
2970ae54 973 { m_pimpl->SetMapMode(mode); }
89efaf2b 974 wxMappingMode GetMapMode() const
2970ae54
RR
975 { return m_pimpl->GetMapMode(); }
976
977 void SetUserScale(double x, double y)
978 { m_pimpl->SetUserScale(x,y); }
979 void GetUserScale(double *x, double *y) const
980 { m_pimpl->GetUserScale( x, y ); }
981
982 void SetLogicalScale(double x, double y)
983 { m_pimpl->SetLogicalScale( x, y ); }
984 void GetLogicalScale(double *x, double *y)
985 { m_pimpl->GetLogicalScale( x, y ); }
986
987 void SetLogicalOrigin(wxCoord x, wxCoord y)
988 { m_pimpl->SetLogicalOrigin(x,y); }
989 void GetLogicalOrigin(wxCoord *x, wxCoord *y) const
990 { m_pimpl->DoGetLogicalOrigin(x, y); }
991 wxPoint GetLogicalOrigin() const
992 { wxCoord x, y; m_pimpl->DoGetLogicalOrigin(&x, &y); return wxPoint(x, y); }
993
994 void SetDeviceOrigin(wxCoord x, wxCoord y)
995 { m_pimpl->SetDeviceOrigin( x, y); }
996 void GetDeviceOrigin(wxCoord *x, wxCoord *y) const
997 { m_pimpl->DoGetDeviceOrigin(x, y); }
998 wxPoint GetDeviceOrigin() const
999 { wxCoord x, y; m_pimpl->DoGetDeviceOrigin(&x, &y); return wxPoint(x, y); }
1000
1001 void SetAxisOrientation(bool xLeftRight, bool yBottomUp)
1002 { m_pimpl->SetAxisOrientation(xLeftRight, yBottomUp); }
f0875501
VZ
1003
1004 // mostly internal
2970ae54
RR
1005 void SetDeviceLocalOrigin( wxCoord x, wxCoord y )
1006 { m_pimpl->SetDeviceLocalOrigin( x, y ); }
1007
1008
2970ae54
RR
1009 // -----------------------------------------------
1010 // the actual drawing API
1011
1012 bool FloodFill(wxCoord x, wxCoord y, const wxColour& col,
89efaf2b 1013 wxFloodFillStyle style = wxFLOOD_SURFACE)
2970ae54
RR
1014 { return m_pimpl->DoFloodFill(x, y, col, style); }
1015 bool FloodFill(const wxPoint& pt, const wxColour& col,
89efaf2b 1016 wxFloodFillStyle style = wxFLOOD_SURFACE)
2970ae54
RR
1017 { return m_pimpl->DoFloodFill(pt.x, pt.y, col, style); }
1018
1019 // fill the area specified by rect with a radial gradient, starting from
1020 // initialColour in the centre of the cercle and fading to destColour.
1021 void GradientFillConcentric(const wxRect& rect,
1022 const wxColour& initialColour,
1023 const wxColour& destColour)
ca7db61e
RR
1024 { m_pimpl->DoGradientFillConcentric( rect, initialColour, destColour,
1025 wxPoint(rect.GetWidth() / 2,
1026 rect.GetHeight() / 2)); }
2970ae54
RR
1027
1028 void GradientFillConcentric(const wxRect& rect,
1029 const wxColour& initialColour,
1030 const wxColour& destColour,
1031 const wxPoint& circleCenter)
1032 { m_pimpl->DoGradientFillConcentric(rect, initialColour, destColour, circleCenter); }
1033
1034 // fill the area specified by rect with a linear gradient
1035 void GradientFillLinear(const wxRect& rect,
1036 const wxColour& initialColour,
1037 const wxColour& destColour,
1038 wxDirection nDirection = wxEAST)
1039 { m_pimpl->DoGradientFillLinear(rect, initialColour, destColour, nDirection); }
1040
1041 bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const
1042 { return m_pimpl->DoGetPixel(x, y, col); }
1043 bool GetPixel(const wxPoint& pt, wxColour *col) const
1044 { return m_pimpl->DoGetPixel(pt.x, pt.y, col); }
1045
1046 void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
1047 { m_pimpl->DoDrawLine(x1, y1, x2, y2); }
1048 void DrawLine(const wxPoint& pt1, const wxPoint& pt2)
1049 { m_pimpl->DoDrawLine(pt1.x, pt1.y, pt2.x, pt2.y); }
1050
1051 void CrossHair(wxCoord x, wxCoord y)
1052 { m_pimpl->DoCrossHair(x, y); }
1053 void CrossHair(const wxPoint& pt)
1054 { m_pimpl->DoCrossHair(pt.x, pt.y); }
1055
1056 void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
1057 wxCoord xc, wxCoord yc)
1058 { m_pimpl->DoDrawArc(x1, y1, x2, y2, xc, yc); }
1059 void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre)
1060 { m_pimpl->DoDrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y); }
1061
1062 void DrawCheckMark(wxCoord x, wxCoord y,
1063 wxCoord width, wxCoord height)
1064 { m_pimpl->DoDrawCheckMark(x, y, width, height); }
1065 void DrawCheckMark(const wxRect& rect)
1066 { m_pimpl->DoDrawCheckMark(rect.x, rect.y, rect.width, rect.height); }
1067
1068 void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
1069 double sa, double ea)
1070 { m_pimpl->DoDrawEllipticArc(x, y, w, h, sa, ea); }
1071 void DrawEllipticArc(const wxPoint& pt, const wxSize& sz,
1072 double sa, double ea)
1073 { m_pimpl->DoDrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea); }
1074
1075 void DrawPoint(wxCoord x, wxCoord y)
1076 { m_pimpl->DoDrawPoint(x, y); }
1077 void DrawPoint(const wxPoint& pt)
1078 { m_pimpl->DoDrawPoint(pt.x, pt.y); }
1079
1080 void DrawLines(int n, wxPoint points[],
1081 wxCoord xoffset = 0, wxCoord yoffset = 0)
1082 { m_pimpl->DoDrawLines(n, points, xoffset, yoffset); }
b0d7707b 1083 void DrawLines(const wxPointList *list,
2970ae54 1084 wxCoord xoffset = 0, wxCoord yoffset = 0)
f0875501 1085 { m_pimpl->DrawLines( list, xoffset, yoffset ); }
4f37154e
RR
1086#if WXWIN_COMPATIBILITY_2_8
1087 wxDEPRECATED( void DrawLines(const wxList *list,
1088 wxCoord xoffset = 0, wxCoord yoffset = 0) );
1089#endif // WXWIN_COMPATIBILITY_2_8
2970ae54
RR
1090
1091 void DrawPolygon(int n, wxPoint points[],
1092 wxCoord xoffset = 0, wxCoord yoffset = 0,
89efaf2b 1093 wxPolygonFillMode fillStyle = wxODDEVEN_RULE)
2970ae54 1094 { m_pimpl->DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); }
b0d7707b 1095 void DrawPolygon(const wxPointList *list,
2970ae54 1096 wxCoord xoffset = 0, wxCoord yoffset = 0,
89efaf2b 1097 wxPolygonFillMode fillStyle = wxODDEVEN_RULE)
2970ae54 1098 { m_pimpl->DrawPolygon( list, xoffset, yoffset, fillStyle ); }
2970ae54
RR
1099 void DrawPolyPolygon(int n, int count[], wxPoint points[],
1100 wxCoord xoffset = 0, wxCoord yoffset = 0,
89efaf2b 1101 wxPolygonFillMode fillStyle = wxODDEVEN_RULE)
2970ae54 1102 { m_pimpl->DoDrawPolyPolygon(n, count, points, xoffset, yoffset, fillStyle); }
4f37154e
RR
1103#if WXWIN_COMPATIBILITY_2_8
1104 wxDEPRECATED( void DrawPolygon(const wxList *list,
1105 wxCoord xoffset = 0, wxCoord yoffset = 0,
89efaf2b 1106 wxPolygonFillMode fillStyle = wxODDEVEN_RULE) );
4f37154e 1107#endif // WXWIN_COMPATIBILITY_2_8
2970ae54
RR
1108
1109 void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
1110 { m_pimpl->DoDrawRectangle(x, y, width, height); }
1111 void DrawRectangle(const wxPoint& pt, const wxSize& sz)
1112 { m_pimpl->DoDrawRectangle(pt.x, pt.y, sz.x, sz.y); }
1113 void DrawRectangle(const wxRect& rect)
1114 { m_pimpl->DoDrawRectangle(rect.x, rect.y, rect.width, rect.height); }
1115
1116 void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height,
1117 double radius)
1118 { m_pimpl->DoDrawRoundedRectangle(x, y, width, height, radius); }
1119 void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz,
1120 double radius)
1121 { m_pimpl->DoDrawRoundedRectangle(pt.x, pt.y, sz.x, sz.y, radius); }
1122 void DrawRoundedRectangle(const wxRect& r, double radius)
1123 { m_pimpl->DoDrawRoundedRectangle(r.x, r.y, r.width, r.height, radius); }
1124
1125 void DrawCircle(wxCoord x, wxCoord y, wxCoord radius)
1126 { m_pimpl->DoDrawEllipse(x - radius, y - radius, 2*radius, 2*radius); }
1127 void DrawCircle(const wxPoint& pt, wxCoord radius)
ca7db61e 1128 { m_pimpl->DoDrawEllipse(pt.x - radius, pt.y - radius, 2*radius, 2*radius); }
2970ae54
RR
1129
1130 void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
1131 { m_pimpl->DoDrawEllipse(x, y, width, height); }
1132 void DrawEllipse(const wxPoint& pt, const wxSize& sz)
1133 { m_pimpl->DoDrawEllipse(pt.x, pt.y, sz.x, sz.y); }
1134 void DrawEllipse(const wxRect& rect)
1135 { m_pimpl->DoDrawEllipse(rect.x, rect.y, rect.width, rect.height); }
1136
1137 void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
1138 { m_pimpl->DoDrawIcon(icon, x, y); }
1139 void DrawIcon(const wxIcon& icon, const wxPoint& pt)
1140 { m_pimpl->DoDrawIcon(icon, pt.x, pt.y); }
1141
1142 void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
1143 bool useMask = false)
1144 { m_pimpl->DoDrawBitmap(bmp, x, y, useMask); }
1145 void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt,
1146 bool useMask = false)
1147 { m_pimpl->DoDrawBitmap(bmp, pt.x, pt.y, useMask); }
1148
1149 void DrawText(const wxString& text, wxCoord x, wxCoord y)
1150 { m_pimpl->DoDrawText(text, x, y); }
1151 void DrawText(const wxString& text, const wxPoint& pt)
1152 { m_pimpl->DoDrawText(text, pt.x, pt.y); }
1153
1154 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle)
1155 { m_pimpl->DoDrawRotatedText(text, x, y, angle); }
1156 void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle)
1157 { m_pimpl->DoDrawRotatedText(text, pt.x, pt.y, angle); }
1158
1159 // this version puts both optional bitmap and the text into the given
1160 // rectangle and aligns is as specified by alignment parameter; it also
1161 // will emphasize the character with the given index if it is != -1 and
1162 // return the bounding rectangle if required
1163 void DrawLabel(const wxString& text,
1164 const wxBitmap& image,
1165 const wxRect& rect,
1166 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
1167 int indexAccel = -1,
ca7db61e 1168 wxRect *rectBounding = NULL);
2970ae54
RR
1169
1170 void DrawLabel(const wxString& text, const wxRect& rect,
1171 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
1172 int indexAccel = -1)
ca7db61e 1173 { DrawLabel(text, wxNullBitmap, rect, alignment, indexAccel); }
2970ae54
RR
1174
1175 bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
1176 wxDC *source, wxCoord xsrc, wxCoord ysrc,
e65a6cc1 1177 wxRasterOperationMode rop = wxCOPY, bool useMask = false,
89efaf2b 1178 wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord)
2970ae54
RR
1179 {
1180 return m_pimpl->DoBlit(xdest, ydest, width, height,
1181 source, xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask);
1182 }
1183 bool Blit(const wxPoint& destPt, const wxSize& sz,
1184 wxDC *source, const wxPoint& srcPt,
e65a6cc1 1185 wxRasterOperationMode rop = wxCOPY, bool useMask = false,
89efaf2b 1186 const wxPoint& srcPtMask = wxDefaultPosition)
2970ae54
RR
1187 {
1188 return m_pimpl->DoBlit(destPt.x, destPt.y, sz.x, sz.y,
1189 source, srcPt.x, srcPt.y, rop, useMask, srcPtMask.x, srcPtMask.y);
1190 }
1191
f0875501 1192 bool StretchBlit(wxCoord dstX, wxCoord dstY,
2970ae54 1193 wxCoord dstWidth, wxCoord dstHeight,
f0875501 1194 wxDC *source,
2970ae54
RR
1195 wxCoord srcX, wxCoord srcY,
1196 wxCoord srcWidth, wxCoord srcHeight,
89efaf2b 1197 wxRasterOperationMode rop = wxCOPY, bool useMask = false,
2970ae54
RR
1198 wxCoord srcMaskX = wxDefaultCoord, wxCoord srcMaskY = wxDefaultCoord)
1199 {
1200 return m_pimpl->DoStretchBlit(dstX, dstY, dstWidth, dstHeight,
1201 source, srcX, srcY, srcWidth, srcHeight, rop, useMask, srcMaskX, srcMaskY);
1202 }
1203 bool StretchBlit(const wxPoint& dstPt, const wxSize& dstSize,
1204 wxDC *source, const wxPoint& srcPt, const wxSize& srcSize,
e65a6cc1 1205 wxRasterOperationMode rop = wxCOPY, bool useMask = false,
89efaf2b 1206 const wxPoint& srcMaskPt = wxDefaultPosition)
2970ae54
RR
1207 {
1208 return m_pimpl->DoStretchBlit(dstPt.x, dstPt.y, dstSize.x, dstSize.y,
1209 source, srcPt.x, srcPt.y, srcSize.x, srcSize.y, rop, useMask, srcMaskPt.x, srcMaskPt.y);
1210 }
1211
1212 wxBitmap GetAsBitmap(const wxRect *subrect = (const wxRect *) NULL) const
1213 {
1214 return m_pimpl->DoGetAsBitmap(subrect);
1215 }
1216
1217#if wxUSE_SPLINES
2970ae54
RR
1218 void DrawSpline(wxCoord x1, wxCoord y1,
1219 wxCoord x2, wxCoord y2,
1220 wxCoord x3, wxCoord y3)
7210c3a1 1221 { m_pimpl->DrawSpline(x1,y1,x2,y2,x3,y3); }
2970ae54 1222 void DrawSpline(int n, wxPoint points[])
7210c3a1 1223 { m_pimpl->DrawSpline(n,points); }
f0875501 1224 void DrawSpline(const wxPointList *points)
7210c3a1 1225 { m_pimpl->DrawSpline(points); }
2970ae54
RR
1226#endif // wxUSE_SPLINES
1227
1228
1229#if WXWIN_COMPATIBILITY_2_8
1230 // for compatibility with the old code when wxCoord was long everywhere
1231 wxDEPRECATED( void GetTextExtent(const wxString& string,
1232 long *x, long *y,
1233 long *descent = NULL,
1234 long *externalLeading = NULL,
1235 const wxFont *theFont = NULL) const );
1236 wxDEPRECATED( void GetLogicalOrigin(long *x, long *y) const );
1237 wxDEPRECATED( void GetDeviceOrigin(long *x, long *y) const );
1238 wxDEPRECATED( void GetClippingBox(long *x, long *y, long *w, long *h) const );
f5725872 1239
713e9290 1240 wxDEPRECATED( void DrawObject(wxDrawObject* drawobject) );
2970ae54
RR
1241#endif // WXWIN_COMPATIBILITY_2_8
1242
f5725872 1243#ifdef __WXMSW__
942d5e2d
VZ
1244 // GetHDC() is the simplest way to retrieve an HDC From a wxDC but only
1245 // works if this wxDC is GDI-based and fails for GDI+ contexts (and
1246 // anything else without HDC, e.g. wxPostScriptDC)
f5725872 1247 WXHDC GetHDC() const;
942d5e2d
VZ
1248
1249 // don't use these methods manually, use GetTempHDC() instead
1250 virtual WXHDC AcquireHDC() { return GetHDC(); }
1251 virtual void ReleaseHDC(WXHDC WXUNUSED(hdc)) { }
1252
1253 // helper class holding the result of GetTempHDC() with std::auto_ptr<>-like
1254 // semantics, i.e. it is moved when copied
1255 class TempHDC
1256 {
1257 public:
1258 TempHDC(wxDC& dc)
1259 : m_dc(dc),
1260 m_hdc(dc.AcquireHDC())
1261 {
1262 }
1263
1264 TempHDC(const TempHDC& thdc)
1265 : m_dc(thdc.m_dc),
1266 m_hdc(thdc.m_hdc)
1267 {
1268 const_cast<TempHDC&>(thdc).m_hdc = 0;
1269 }
1270
1271 ~TempHDC()
1272 {
1273 if ( m_hdc )
1274 m_dc.ReleaseHDC(m_hdc);
1275 }
1276
1277 WXHDC GetHDC() const { return m_hdc; }
1278
1279 private:
1280 wxDC& m_dc;
1281 WXHDC m_hdc;
1282
1283 wxDECLARE_NO_ASSIGN_CLASS(TempHDC);
1284 };
1285
1286 // GetTempHDC() also works for wxGCDC (but still not for wxPostScriptDC &c)
1287 TempHDC GetTempHDC() { return TempHDC(*this); }
f5725872 1288#endif // __WXMSW__
2970ae54
RR
1289
1290protected:
f0875501
VZ
1291 // ctor takes ownership of the pointer
1292 wxDC(wxDCImpl *pimpl) : m_pimpl(pimpl) { }
1293
1294 wxDCImpl * const m_pimpl;
aec43716 1295
ca7db61e 1296private:
888dde65 1297 DECLARE_ABSTRACT_CLASS(wxDC)
c0c133e1 1298 wxDECLARE_NO_COPY_CLASS(wxDC);
ca7db61e 1299};
aec43716 1300
1e6feb95
VZ
1301// ----------------------------------------------------------------------------
1302// helper class: you can use it to temporarily change the DC text colour and
1303// restore it automatically when the object goes out of scope
1304// ----------------------------------------------------------------------------
1305
53a2db12 1306class WXDLLIMPEXP_CORE wxDCTextColourChanger
1e6feb95
VZ
1307{
1308public:
ba161d7e 1309 wxDCTextColourChanger(wxDC& dc) : m_dc(dc), m_colFgOld() { }
1e6feb95 1310
1b97b23d
VS
1311 wxDCTextColourChanger(wxDC& dc, const wxColour& col) : m_dc(dc)
1312 {
1313 Set(col);
1314 }
1315
1e6feb95
VZ
1316 ~wxDCTextColourChanger()
1317 {
1318 if ( m_colFgOld.Ok() )
1319 m_dc.SetTextForeground(m_colFgOld);
1320 }
1321
1322 void Set(const wxColour& col)
1323 {
1324 if ( !m_colFgOld.Ok() )
1325 m_colFgOld = m_dc.GetTextForeground();
1326 m_dc.SetTextForeground(col);
1327 }
1328
1329private:
1330 wxDC& m_dc;
1331
1332 wxColour m_colFgOld;
fc7a2a60 1333
c0c133e1 1334 wxDECLARE_NO_COPY_CLASS(wxDCTextColourChanger);
1e6feb95
VZ
1335};
1336
4660e6ac
WS
1337// ----------------------------------------------------------------------------
1338// helper class: you can use it to temporarily change the DC pen and
1339// restore it automatically when the object goes out of scope
1340// ----------------------------------------------------------------------------
1341
53a2db12 1342class WXDLLIMPEXP_CORE wxDCPenChanger
4660e6ac
WS
1343{
1344public:
0164f8eb
WS
1345 wxDCPenChanger(wxDC& dc, const wxPen& pen) : m_dc(dc), m_penOld(dc.GetPen())
1346 {
1347 m_dc.SetPen(pen);
1348 }
4660e6ac
WS
1349
1350 ~wxDCPenChanger()
1351 {
1352 if ( m_penOld.Ok() )
1353 m_dc.SetPen(m_penOld);
1354 }
1355
4660e6ac
WS
1356private:
1357 wxDC& m_dc;
1358
1359 wxPen m_penOld;
1360
c0c133e1 1361 wxDECLARE_NO_COPY_CLASS(wxDCPenChanger);
4660e6ac
WS
1362};
1363
1364// ----------------------------------------------------------------------------
1365// helper class: you can use it to temporarily change the DC brush and
1366// restore it automatically when the object goes out of scope
1367// ----------------------------------------------------------------------------
1368
53a2db12 1369class WXDLLIMPEXP_CORE wxDCBrushChanger
4660e6ac
WS
1370{
1371public:
0164f8eb
WS
1372 wxDCBrushChanger(wxDC& dc, const wxBrush& brush) : m_dc(dc), m_brushOld(dc.GetBrush())
1373 {
1374 m_dc.SetBrush(brush);
1375 }
4660e6ac
WS
1376
1377 ~wxDCBrushChanger()
1378 {
1379 if ( m_brushOld.Ok() )
1380 m_dc.SetBrush(m_brushOld);
1381 }
1382
4660e6ac
WS
1383private:
1384 wxDC& m_dc;
1385
1386 wxBrush m_brushOld;
1387
c0c133e1 1388 wxDECLARE_NO_COPY_CLASS(wxDCBrushChanger);
4660e6ac
WS
1389};
1390
e26be42b
VZ
1391// ----------------------------------------------------------------------------
1392// another small helper class: sets the clipping region in its ctor and
1393// destroys it in the dtor
1394// ----------------------------------------------------------------------------
1395
53a2db12 1396class WXDLLIMPEXP_CORE wxDCClipper
e26be42b
VZ
1397{
1398public:
fc298ea7 1399 wxDCClipper(wxDC& dc, const wxRegion& r) : m_dc(dc)
fdaad94e 1400 { dc.SetClippingRegion(r.GetBox()); }
e26be42b
VZ
1401 wxDCClipper(wxDC& dc, const wxRect& r) : m_dc(dc)
1402 { dc.SetClippingRegion(r.x, r.y, r.width, r.height); }
1403 wxDCClipper(wxDC& dc, wxCoord x, wxCoord y, wxCoord w, wxCoord h) : m_dc(dc)
1404 { dc.SetClippingRegion(x, y, w, h); }
1405
1406 ~wxDCClipper() { m_dc.DestroyClippingRegion(); }
1407
1408private:
1409 wxDC& m_dc;
fc7a2a60 1410
c0c133e1 1411 wxDECLARE_NO_COPY_CLASS(wxDCClipper);
e26be42b
VZ
1412};
1413
c48d6cdf
FM
1414// ----------------------------------------------------------------------------
1415// helper class: you can use it to temporarily change the DC font and
1416// restore it automatically when the object goes out of scope
1417// ----------------------------------------------------------------------------
1418
1419class WXDLLIMPEXP_CORE wxDCFontChanger
1420{
1421public:
ca4adfd0
VZ
1422 wxDCFontChanger(wxDC& dc)
1423 : m_dc(dc), m_fontOld()
c48d6cdf 1424 {
ca4adfd0
VZ
1425 }
1426
1427 wxDCFontChanger(wxDC& dc, const wxFont& font)
1428 : m_dc(dc), m_fontOld(dc.GetFont())
1429 {
1430 m_dc.SetFont(font);
1431 }
1432
1433 void Set(const wxFont& font)
1434 {
1435 if ( !m_fontOld.Ok() )
1436 m_fontOld = m_dc.GetFont();
c48d6cdf
FM
1437 m_dc.SetFont(font);
1438 }
1439
1440 ~wxDCFontChanger()
1441 {
1442 if ( m_fontOld.Ok() )
1443 m_dc.SetFont(m_fontOld);
1444 }
1445
1446private:
1447 wxDC& m_dc;
1448
1449 wxFont m_fontOld;
1450
c0c133e1 1451 wxDECLARE_NO_COPY_CLASS(wxDCFontChanger);
c48d6cdf
FM
1452};
1453
1454
8b56b16a 1455#endif // _WX_DC_H_BASE_