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