]> git.saurik.com Git - wxWidgets.git/blob - include/wx/dc.h
94390e9fbfc4df4ae4ff7f35c40aa7da6e6caa56
[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
33 // 1 if using the reorganized DC code
34 #define wxUSE_NEW_DC 0
35
36
37 #if wxUSE_NEW_DC
38 class WXDLLIMPEXP_FWD_CORE wxDC;
39 class WXDLLIMPEXP_FWD_CORE wxClientDC;
40 class WXDLLIMPEXP_FWD_CORE wxPaintDC;
41 class WXDLLIMPEXP_FWD_CORE wxWindowDC;
42 class WXDLLIMPEXP_FWD_CORE wxScreenDC;
43 class WXDLLIMPEXP_FWD_CORE wxMemoryDC;
44 class WXDLLIMPEXP_FWD_CORE wxPrinterDC;
45 #include "wx/cmndata.h"
46 #else
47 class WXDLLIMPEXP_FWD_CORE wxDCBase;
48 #endif
49
50 class WXDLLEXPORT wxDrawObject
51 {
52 public:
53
54 wxDrawObject()
55 : m_isBBoxValid(false)
56 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
57 { }
58
59 virtual ~wxDrawObject() { }
60
61 #if wxUSE_NEW_DC
62 virtual void Draw(wxDC&) const { }
63 #else
64 virtual void Draw(wxDCBase&) const { }
65 #endif
66
67 virtual void CalcBoundingBox(wxCoord x, wxCoord y)
68 {
69 if ( m_isBBoxValid )
70 {
71 if ( x < m_minX ) m_minX = x;
72 if ( y < m_minY ) m_minY = y;
73 if ( x > m_maxX ) m_maxX = x;
74 if ( y > m_maxY ) m_maxY = y;
75 }
76 else
77 {
78 m_isBBoxValid = true;
79
80 m_minX = x;
81 m_minY = y;
82 m_maxX = x;
83 m_maxY = y;
84 }
85 }
86
87 void ResetBoundingBox()
88 {
89 m_isBBoxValid = false;
90
91 m_minX = m_maxX = m_minY = m_maxY = 0;
92 }
93
94 // Get the final bounding box of the PostScript or Metafile picture.
95
96 wxCoord MinX() const { return m_minX; }
97 wxCoord MaxX() const { return m_maxX; }
98 wxCoord MinY() const { return m_minY; }
99 wxCoord MaxY() const { return m_maxY; }
100
101 //to define the type of object for derived objects
102 virtual int GetType()=0;
103
104 protected:
105 //for boundingbox calculation
106 bool m_isBBoxValid:1;
107 //for boundingbox calculation
108 wxCoord m_minX, m_minY, m_maxX, m_maxY;
109 };
110
111
112 #if wxUSE_NEW_DC
113
114 //-----------------------------------------------------------------------------
115 // wxDCFactory
116 //-----------------------------------------------------------------------------
117
118 class WXDLLIMPEXP_FWD_CORE wxImplDC;
119
120 class WXDLLIMPEXP_CORE wxDCFactory
121 {
122 public:
123 wxDCFactory() {}
124 virtual ~wxDCFactory() {}
125
126 virtual wxImplDC* CreateWindowDC( wxWindowDC *owner ) = 0;
127 virtual wxImplDC* CreateWindowDC( wxWindowDC *owner, wxWindow *window ) = 0;
128 virtual wxImplDC* CreateClientDC( wxClientDC *owner ) = 0;
129 virtual wxImplDC* CreateClientDC( wxClientDC *owner, wxWindow *window ) = 0;
130 virtual wxImplDC* CreatePaintDC( wxPaintDC *owner ) = 0;
131 virtual wxImplDC* CreatePaintDC( wxPaintDC *owner, wxWindow *window ) = 0;
132 virtual wxImplDC* CreateMemoryDC( wxMemoryDC *owner ) = 0;
133 virtual wxImplDC* CreateMemoryDC( wxMemoryDC *owner, wxBitmap &bitmap ) = 0;
134 virtual wxImplDC* CreateMemoryDC( wxMemoryDC *owner, wxDC *dc ) = 0;
135 virtual wxImplDC* CreateScreenDC( wxScreenDC *owner ) = 0;
136 virtual wxImplDC* CreatePrinterDC( wxPrinterDC *owner, const wxPrintData &data ) = 0;
137
138 static void SetDCFactory( wxDCFactory *factory );
139 static wxDCFactory *GetFactory();
140 private:
141 static wxDCFactory *m_factory;
142 };
143
144 //-----------------------------------------------------------------------------
145 // wxNativeDCFactory
146 //-----------------------------------------------------------------------------
147
148 class WXDLLIMPEXP_CORE wxNativeDCFactory: public wxDCFactory
149 {
150 public:
151 wxNativeDCFactory() {}
152
153 virtual wxImplDC* CreateWindowDC( wxWindowDC *owner );
154 virtual wxImplDC* CreateWindowDC( wxWindowDC *owner, wxWindow *window );
155 virtual wxImplDC* CreateClientDC( wxClientDC *owner );
156 virtual wxImplDC* CreateClientDC( wxClientDC *owner, wxWindow *window );
157 virtual wxImplDC* CreatePaintDC( wxPaintDC *owner );
158 virtual wxImplDC* CreatePaintDC( wxPaintDC *owner, wxWindow *window );
159 virtual wxImplDC* CreateMemoryDC( wxMemoryDC *owner );
160 virtual wxImplDC* CreateMemoryDC( wxMemoryDC *owner, wxBitmap &bitmap );
161 virtual wxImplDC* CreateMemoryDC( wxMemoryDC *owner, wxDC *dc );
162 virtual wxImplDC* CreateScreenDC( wxScreenDC *owner );
163 virtual wxImplDC* CreatePrinterDC( wxPrinterDC *owner, const wxPrintData &data );
164 };
165
166 //-----------------------------------------------------------------------------
167 // wxImplDC
168 //-----------------------------------------------------------------------------
169
170 class WXDLLIMPEXP_CORE wxImplDC: public wxObject
171 {
172 public:
173 wxImplDC( wxDC *owner );
174 ~wxImplDC();
175
176 wxDC *GetOwner() const { return m_owner; }
177
178 virtual bool IsOk() const { return m_ok; }
179
180 // query capabilities
181
182 virtual bool CanDrawBitmap() const = 0;
183 virtual bool CanGetTextExtent() const = 0;
184
185 // query dimension, colour deps, resolution
186
187 virtual void DoGetSize(int *width, int *height) const = 0;
188 virtual void DoGetSizeMM(int* width, int* height) const = 0;
189
190 virtual int GetDepth() const = 0;
191 virtual wxSize GetPPI() const = 0;
192
193 // Right-To-Left (RTL) modes
194
195 virtual void SetLayoutDirection(wxLayoutDirection WXUNUSED(dir)) { }
196 virtual wxLayoutDirection GetLayoutDirection() const { return wxLayout_Default; }
197
198 // page and document
199
200 virtual bool StartDoc(const wxString& WXUNUSED(message)) { return true; }
201 virtual void EndDoc() { }
202
203 virtual void StartPage() { }
204 virtual void EndPage() { }
205
206 // flushing the content of this dc immediately eg onto screen
207 virtual void Flush() { }
208
209 // bounding box
210
211 virtual void CalcBoundingBox(wxCoord x, wxCoord y)
212 {
213 if ( m_isBBoxValid )
214 {
215 if ( x < m_minX ) m_minX = x;
216 if ( y < m_minY ) m_minY = y;
217 if ( x > m_maxX ) m_maxX = x;
218 if ( y > m_maxY ) m_maxY = y;
219 }
220 else
221 {
222 m_isBBoxValid = true;
223
224 m_minX = x;
225 m_minY = y;
226 m_maxX = x;
227 m_maxY = y;
228 }
229 }
230 void ResetBoundingBox()
231 {
232 m_isBBoxValid = false;
233
234 m_minX = m_maxX = m_minY = m_maxY = 0;
235 }
236
237 wxCoord MinX() const { return m_minX; }
238 wxCoord MaxX() const { return m_maxX; }
239 wxCoord MinY() const { return m_minY; }
240 wxCoord MaxY() const { return m_maxY; }
241
242 // setters and getters
243
244 virtual void SetFont(const wxFont& font) = 0;
245 virtual const wxFont& GetFont() const { return m_font; }
246
247 virtual void SetPen(const wxPen& pen) = 0;
248 virtual const wxPen& GetPen() const { return m_pen; }
249
250 virtual void SetBrush(const wxBrush& brush) = 0;
251 virtual const wxBrush& GetBrush() const { return m_brush; }
252
253 virtual void SetBackground(const wxBrush& brush) = 0;
254 virtual const wxBrush& GetBackground() const { return m_backgroundBrush; }
255
256 virtual void SetBackgroundMode(int mode) = 0;
257 virtual int GetBackgroundMode() const { return m_backgroundMode; }
258
259 virtual void SetTextForeground(const wxColour& colour)
260 { m_textForegroundColour = colour; }
261 virtual const wxColour& GetTextForeground() const { return m_textForegroundColour; }
262
263 virtual void SetTextBackground(const wxColour& colour)
264 { m_textBackgroundColour = colour; }
265 virtual const wxColour& GetTextBackground() const { return m_textBackgroundColour; }
266
267 #if wxUSE_PALETTE
268 virtual void SetPalette(const wxPalette& palette) = 0;
269 #endif // wxUSE_PALETTE
270
271 // logical functions
272
273 virtual void SetLogicalFunction(int function) = 0;
274 virtual int GetLogicalFunction() const { return m_logicalFunction; }
275
276 // text measurement
277
278 virtual wxCoord GetCharHeight() const = 0;
279 virtual wxCoord GetCharWidth() const = 0;
280 virtual void DoGetTextExtent(const wxString& string,
281 wxCoord *x, wxCoord *y,
282 wxCoord *descent = NULL,
283 wxCoord *externalLeading = NULL,
284 const wxFont *theFont = NULL) const = 0;
285 virtual void GetMultiLineTextExtent(const wxString& string,
286 wxCoord *width,
287 wxCoord *height,
288 wxCoord *heightLine = NULL,
289 const wxFont *font = NULL) const;
290 virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
291
292 // clearing
293
294 virtual void Clear() = 0;
295
296 // clipping
297
298 virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
299 wxCoord width, wxCoord height) = 0;
300 virtual void DoSetClippingRegionAsRegion(const wxRegion& region) = 0;
301
302 virtual void DoGetClippingBox(wxCoord *x, wxCoord *y,
303 wxCoord *w, wxCoord *h) const
304 {
305 if ( x )
306 *x = m_clipX1;
307 if ( y )
308 *y = m_clipY1;
309 if ( w )
310 *w = m_clipX2 - m_clipX1;
311 if ( h )
312 *h = m_clipY2 - m_clipY1;
313 }
314
315 virtual void DestroyClippingRegion() { ResetClipping(); }
316
317
318 // coordinates conversions and transforms
319
320 virtual wxCoord DeviceToLogicalX(wxCoord x) const;
321 virtual wxCoord DeviceToLogicalY(wxCoord y) const;
322 virtual wxCoord DeviceToLogicalXRel(wxCoord x) const;
323 virtual wxCoord DeviceToLogicalYRel(wxCoord y) const;
324 virtual wxCoord LogicalToDeviceX(wxCoord x) const;
325 virtual wxCoord LogicalToDeviceY(wxCoord y) const;
326 virtual wxCoord LogicalToDeviceXRel(wxCoord x) const;
327 virtual wxCoord LogicalToDeviceYRel(wxCoord y) const;
328
329 virtual void SetMapMode(int mode);
330 virtual int GetMapMode() const { return m_mappingMode; }
331
332 virtual void SetUserScale(double x, double y);
333 virtual void GetUserScale(double *x, double *y) const
334 {
335 if ( x ) *x = m_userScaleX;
336 if ( y ) *y = m_userScaleY;
337 }
338
339 virtual void SetLogicalScale(double x, double y);
340 virtual void GetLogicalScale(double *x, double *y)
341 {
342 if ( x ) *x = m_logicalScaleX;
343 if ( y ) *y = m_logicalScaleY;
344 }
345
346 virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
347 virtual void DoGetLogicalOrigin(wxCoord *x, wxCoord *y) const
348 {
349 if ( x ) *x = m_logicalOriginX;
350 if ( y ) *y = m_logicalOriginY;
351 }
352
353 virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
354 virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const
355 {
356 if ( x ) *x = m_deviceOriginX;
357 if ( y ) *y = m_deviceOriginY;
358 }
359
360 virtual void SetDeviceLocalOrigin( wxCoord x, wxCoord y );
361
362 virtual void ComputeScaleAndOrigin();
363
364 // this needs to overidden if the axis is inverted
365 virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
366
367 // ---------------------------------------------------------
368 // the actual drawing API
369
370 virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
371 int style = wxFLOOD_SURFACE) = 0;
372
373 virtual void DoGradientFillLinear(const wxRect& rect,
374 const wxColour& initialColour,
375 const wxColour& destColour,
376 wxDirection nDirection = wxEAST);
377
378 virtual void DoGradientFillConcentric(const wxRect& rect,
379 const wxColour& initialColour,
380 const wxColour& destColour,
381 const wxPoint& circleCenter);
382
383 virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const = 0;
384
385 virtual void DoDrawPoint(wxCoord x, wxCoord y) = 0;
386 virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) = 0;
387
388 virtual void DoDrawArc(wxCoord x1, wxCoord y1,
389 wxCoord x2, wxCoord y2,
390 wxCoord xc, wxCoord yc) = 0;
391 virtual void DoDrawCheckMark(wxCoord x, wxCoord y,
392 wxCoord width, wxCoord height);
393 virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
394 double sa, double ea) = 0;
395
396 virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) = 0;
397 virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
398 wxCoord width, wxCoord height,
399 double radius) = 0;
400 virtual void DoDrawEllipse(wxCoord x, wxCoord y,
401 wxCoord width, wxCoord height) = 0;
402
403 virtual void DoCrossHair(wxCoord x, wxCoord y) = 0;
404
405 virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) = 0;
406 virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
407 bool useMask = false) = 0;
408
409 virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y) = 0;
410 virtual void DoDrawRotatedText(const wxString& text,
411 wxCoord x, wxCoord y, double angle) = 0;
412
413 virtual bool DoBlit(wxCoord xdest, wxCoord ydest,
414 wxCoord width, wxCoord height,
415 wxDC *source,
416 wxCoord xsrc, wxCoord ysrc,
417 int rop = wxCOPY,
418 bool useMask = false,
419 wxCoord xsrcMask = wxDefaultCoord,
420 wxCoord ysrcMask = wxDefaultCoord) = 0;
421
422 virtual bool DoStretchBlit(wxCoord xdest, wxCoord ydest,
423 wxCoord dstWidth, wxCoord dstHeight,
424 wxDC *source,
425 wxCoord xsrc, wxCoord ysrc,
426 wxCoord srcWidth, wxCoord srcHeight,
427 int rop = wxCOPY,
428 bool useMask = false,
429 wxCoord xsrcMask = wxDefaultCoord,
430 wxCoord ysrcMask = wxDefaultCoord);
431
432 virtual wxBitmap DoGetAsBitmap(const wxRect *WXUNUSED(subrect)) const
433 { return wxNullBitmap; }
434
435
436 virtual void DoDrawLines(int n, wxPoint points[],
437 wxCoord xoffset, wxCoord yoffset) = 0;
438 virtual void DoDrawPolygon(int n, wxPoint points[],
439 wxCoord xoffset, wxCoord yoffset,
440 int fillStyle = wxODDEVEN_RULE) = 0;
441 virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[],
442 wxCoord xoffset, wxCoord yoffset,
443 int fillStyle);
444
445
446
447 #if wxUSE_SPLINES
448 virtual void DoDrawSpline(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord x3, wxCoord y3);
449 virtual void DoDrawSpline(int n, wxPoint points[]);
450 virtual void DoDrawSpline(const wxPointList *points);
451 #endif
452
453 private:
454 wxDC *m_owner;
455
456 protected:
457 // unset clipping variables (after clipping region was destroyed)
458 void ResetClipping()
459 {
460 m_clipping = false;
461
462 m_clipX1 = m_clipX2 = m_clipY1 = m_clipY2 = 0;
463 }
464
465 // flags
466 bool m_colour:1;
467 bool m_ok:1;
468 bool m_clipping:1;
469 bool m_isInteractive:1;
470 bool m_isBBoxValid:1;
471
472 // coordinate system variables
473
474 wxCoord m_logicalOriginX, m_logicalOriginY;
475 wxCoord m_deviceOriginX, m_deviceOriginY; // Usually 0,0, can be change by user
476
477 wxCoord m_deviceLocalOriginX, m_deviceLocalOriginY; // non-zero if native top-left corner
478 // is not at 0,0. This was the case under
479 // Mac's GrafPorts (coordinate system
480 // used toplevel window's origin) and
481 // e.g. for Postscript, where the native
482 // origin in the bottom left corner.
483 double m_logicalScaleX, m_logicalScaleY;
484 double m_userScaleX, m_userScaleY;
485 double m_scaleX, m_scaleY; // calculated from logical scale and user scale
486
487 int m_signX, m_signY; // Used by SetAxisOrientation() to invert the axes
488
489 // what is a mm on a screen you don't know the size of?
490 double m_mm_to_pix_x,
491 m_mm_to_pix_y;
492
493 // bounding and clipping boxes
494 wxCoord m_minX, m_minY, m_maxX, m_maxY;
495 wxCoord m_clipX1, m_clipY1, m_clipX2, m_clipY2;
496
497 int m_logicalFunction;
498 int m_backgroundMode;
499 int m_mappingMode;
500
501 wxPen m_pen;
502 wxBrush m_brush;
503 wxBrush m_backgroundBrush;
504 wxColour m_textForegroundColour;
505 wxColour m_textBackgroundColour;
506 wxFont m_font;
507
508 #if wxUSE_PALETTE
509 wxPalette m_palette;
510 bool m_hasCustomPalette;
511 #endif // wxUSE_PALETTE
512
513 private:
514 DECLARE_ABSTRACT_CLASS(wxImplDC)
515 };
516
517
518 class wxDC: public wxObject
519 {
520 public:
521 wxDC() { m_pimpl = NULL; }
522
523 wxImplDC *GetImpl()
524 { return m_pimpl; }
525 const wxImplDC *GetImpl() const
526 { return m_pimpl; }
527
528
529 bool IsOk() const
530 { return m_pimpl && m_pimpl->IsOk(); }
531
532 // query capabilities
533
534 bool CanDrawBitmap() const
535 { return m_pimpl->CanDrawBitmap(); }
536 bool CanGetTextExtent() const
537 { return m_pimpl->CanGetTextExtent(); }
538
539 // query dimension, colour deps, resolution
540
541 void GetSize(int *width, int *height) const
542 { m_pimpl->DoGetSize(width, height); }
543
544 wxSize GetSize() const
545 {
546 int w, h;
547 m_pimpl->DoGetSize(&w, &h);
548 return wxSize(w, h);
549 }
550
551 void GetSizeMM(int* width, int* height) const
552 { m_pimpl->DoGetSizeMM(width, height); }
553 wxSize GetSizeMM() const
554 {
555 int w, h;
556 m_pimpl->DoGetSizeMM(&w, &h);
557 return wxSize(w, h);
558 }
559
560 int GetDepth() const
561 { return m_pimpl->GetDepth(); }
562 wxSize GetPPI() const
563 { return m_pimpl->GetPPI(); }
564
565 // Right-To-Left (RTL) modes
566
567 void SetLayoutDirection(wxLayoutDirection dir)
568 { m_pimpl->SetLayoutDirection( dir ); }
569 wxLayoutDirection GetLayoutDirection() const
570 { return m_pimpl->GetLayoutDirection(); }
571
572 // page and document
573
574 bool StartDoc(const wxString& message)
575 { return m_pimpl->StartDoc(message); }
576 void EndDoc()
577 { m_pimpl->EndDoc(); }
578
579 void StartPage()
580 { m_pimpl->StartPage(); }
581 void EndPage()
582 { m_pimpl->EndPage(); }
583
584 // bounding box
585
586 void CalcBoundingBox(wxCoord x, wxCoord y)
587 { m_pimpl->CalcBoundingBox(x,y); }
588 void ResetBoundingBox()
589 { m_pimpl->ResetBoundingBox(); }
590
591 wxCoord MinX() const
592 { return m_pimpl->MinX(); }
593 wxCoord MaxX() const
594 { return m_pimpl->MaxX(); }
595 wxCoord MinY() const
596 { return m_pimpl->MinY(); }
597 wxCoord MaxY() const
598 { return m_pimpl->MaxY(); }
599
600 // setters and getters
601
602 void SetFont(const wxFont& font)
603 { m_pimpl->SetFont( font ); }
604 const wxFont& GetFont() const
605 { return m_pimpl->GetFont(); }
606
607 void SetPen(const wxPen& pen)
608 { m_pimpl->SetPen( pen ); }
609 const wxPen& GetPen() const
610 { return m_pimpl->GetPen(); }
611
612 void SetBrush(const wxBrush& brush)
613 { m_pimpl->SetBrush( brush ); }
614 const wxBrush& GetBrush() const
615 { return m_pimpl->GetBrush(); }
616
617 void SetBackground(const wxBrush& brush)
618 { m_pimpl->SetBackground( brush ); }
619 const wxBrush& GetBackground() const
620 { return m_pimpl->GetBackground(); }
621
622 void SetBackgroundMode(int mode)
623 { m_pimpl->SetBackgroundMode( mode ); }
624 int GetBackgroundMode() const
625 { return m_pimpl->GetBackgroundMode(); }
626
627 void SetTextForeground(const wxColour& colour)
628 { m_pimpl->SetTextForeground(colour); }
629 const wxColour& GetTextForeground() const
630 { return m_pimpl->GetTextForeground(); }
631
632 void SetTextBackground(const wxColour& colour)
633 { m_pimpl->SetTextBackground(colour); }
634 const wxColour& GetTextBackground() const
635 { return m_pimpl->GetTextBackground(); }
636
637 #if wxUSE_PALETTE
638 void SetPalette(const wxPalette& palette)
639 { m_pimpl->SetPalette(palette); }
640 #endif // wxUSE_PALETTE
641
642 // logical functions
643
644 void SetLogicalFunction(int function)
645 { m_pimpl->SetLogicalFunction(function); }
646 int GetLogicalFunction() const
647 { return m_pimpl->GetLogicalFunction(); }
648
649 // text measurement
650
651 wxCoord GetCharHeight() const
652 { return m_pimpl->GetCharHeight(); }
653 wxCoord GetCharWidth() const
654 { return m_pimpl->GetCharWidth(); }
655
656 void GetTextExtent(const wxString& string,
657 wxCoord *x, wxCoord *y,
658 wxCoord *descent = NULL,
659 wxCoord *externalLeading = NULL,
660 const wxFont *theFont = NULL) const
661 { m_pimpl->DoGetTextExtent(string, x, y, descent, externalLeading, theFont); }
662
663 wxSize GetTextExtent(const wxString& string) const
664 {
665 wxCoord w, h;
666 m_pimpl->DoGetTextExtent(string, &w, &h);
667 return wxSize(w, h);
668 }
669
670 void GetMultiLineTextExtent(const wxString& string,
671 wxCoord *width,
672 wxCoord *height,
673 wxCoord *heightLine = NULL,
674 const wxFont *font = NULL) const
675 { m_pimpl->GetMultiLineTextExtent( string, width, height, heightLine, font ); }
676
677 wxSize GetMultiLineTextExtent(const wxString& string) const
678 {
679 wxCoord w, h;
680 m_pimpl->GetMultiLineTextExtent(string, &w, &h);
681 return wxSize(w, h);
682 }
683
684 bool GetPartialTextExtents(const wxString& text, wxArrayInt& widths) const
685 { return m_pimpl->DoGetPartialTextExtents(text, widths); }
686
687 // clearing
688
689 void Clear()
690 { m_pimpl->Clear(); }
691
692 // clipping
693
694 void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
695 { m_pimpl->DoSetClippingRegion(x, y, width, height); }
696 void SetClippingRegion(const wxPoint& pt, const wxSize& sz)
697 { m_pimpl->DoSetClippingRegion(pt.x, pt.y, sz.x, sz.y); }
698 void SetClippingRegion(const wxRect& rect)
699 { m_pimpl->DoSetClippingRegion(rect.x, rect.y, rect.width, rect.height); }
700 void SetClippingRegion(const wxRegion& region)
701 { m_pimpl->DoSetClippingRegionAsRegion(region); }
702
703 void DestroyClippingRegion()
704 { m_pimpl->DestroyClippingRegion(); }
705
706 void GetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const
707 { m_pimpl->DoGetClippingBox(x, y, w, h); }
708 void GetClippingBox(wxRect& rect) const
709 { m_pimpl->DoGetClippingBox(&rect.x, &rect.y, &rect.width, &rect.height); }
710
711 // coordinates conversions and transforms
712
713 wxCoord DeviceToLogicalX(wxCoord x) const
714 { return m_pimpl->DeviceToLogicalX(x); }
715 wxCoord DeviceToLogicalY(wxCoord y) const
716 { return m_pimpl->DeviceToLogicalY(y); }
717 wxCoord DeviceToLogicalXRel(wxCoord x) const
718 { return m_pimpl->DeviceToLogicalXRel(x); }
719 wxCoord DeviceToLogicalYRel(wxCoord y) const
720 { return m_pimpl->DeviceToLogicalYRel(y); }
721 wxCoord LogicalToDeviceX(wxCoord x) const
722 { return m_pimpl->LogicalToDeviceX(x); }
723 wxCoord LogicalToDeviceY(wxCoord y) const
724 { return m_pimpl->LogicalToDeviceY(y); }
725 wxCoord LogicalToDeviceXRel(wxCoord x) const
726 { return m_pimpl->LogicalToDeviceXRel(x); }
727 wxCoord LogicalToDeviceYRel(wxCoord y) const
728 { return m_pimpl->LogicalToDeviceYRel(y); }
729
730 void SetMapMode(int mode)
731 { m_pimpl->SetMapMode(mode); }
732 int GetMapMode() const
733 { return m_pimpl->GetMapMode(); }
734
735 void SetUserScale(double x, double y)
736 { m_pimpl->SetUserScale(x,y); }
737 void GetUserScale(double *x, double *y) const
738 { m_pimpl->GetUserScale( x, y ); }
739
740 void SetLogicalScale(double x, double y)
741 { m_pimpl->SetLogicalScale( x, y ); }
742 void GetLogicalScale(double *x, double *y)
743 { m_pimpl->GetLogicalScale( x, y ); }
744
745 void SetLogicalOrigin(wxCoord x, wxCoord y)
746 { m_pimpl->SetLogicalOrigin(x,y); }
747 void GetLogicalOrigin(wxCoord *x, wxCoord *y) const
748 { m_pimpl->DoGetLogicalOrigin(x, y); }
749 wxPoint GetLogicalOrigin() const
750 { wxCoord x, y; m_pimpl->DoGetLogicalOrigin(&x, &y); return wxPoint(x, y); }
751
752 void SetDeviceOrigin(wxCoord x, wxCoord y)
753 { m_pimpl->SetDeviceOrigin( x, y); }
754 void GetDeviceOrigin(wxCoord *x, wxCoord *y) const
755 { m_pimpl->DoGetDeviceOrigin(x, y); }
756 wxPoint GetDeviceOrigin() const
757 { wxCoord x, y; m_pimpl->DoGetDeviceOrigin(&x, &y); return wxPoint(x, y); }
758
759 void SetAxisOrientation(bool xLeftRight, bool yBottomUp)
760 { m_pimpl->SetAxisOrientation(xLeftRight, yBottomUp); }
761
762 // mostly internal
763 void SetDeviceLocalOrigin( wxCoord x, wxCoord y )
764 { m_pimpl->SetDeviceLocalOrigin( x, y ); }
765
766
767 // draw generic object
768
769 void DrawObject(wxDrawObject* drawobject)
770 {
771 drawobject->Draw(*this);
772 CalcBoundingBox(drawobject->MinX(),drawobject->MinY());
773 CalcBoundingBox(drawobject->MaxX(),drawobject->MaxY());
774 }
775
776 // -----------------------------------------------
777 // the actual drawing API
778
779 bool FloodFill(wxCoord x, wxCoord y, const wxColour& col,
780 int style = wxFLOOD_SURFACE)
781 { return m_pimpl->DoFloodFill(x, y, col, style); }
782 bool FloodFill(const wxPoint& pt, const wxColour& col,
783 int style = wxFLOOD_SURFACE)
784 { return m_pimpl->DoFloodFill(pt.x, pt.y, col, style); }
785
786 // fill the area specified by rect with a radial gradient, starting from
787 // initialColour in the centre of the cercle and fading to destColour.
788 void GradientFillConcentric(const wxRect& rect,
789 const wxColour& initialColour,
790 const wxColour& destColour)
791 { m_pimpl->DoGradientFillConcentric( rect, initialColour, destColour,
792 wxPoint(rect.GetWidth() / 2,
793 rect.GetHeight() / 2)); }
794
795 void GradientFillConcentric(const wxRect& rect,
796 const wxColour& initialColour,
797 const wxColour& destColour,
798 const wxPoint& circleCenter)
799 { m_pimpl->DoGradientFillConcentric(rect, initialColour, destColour, circleCenter); }
800
801 // fill the area specified by rect with a linear gradient
802 void GradientFillLinear(const wxRect& rect,
803 const wxColour& initialColour,
804 const wxColour& destColour,
805 wxDirection nDirection = wxEAST)
806 { m_pimpl->DoGradientFillLinear(rect, initialColour, destColour, nDirection); }
807
808 bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const
809 { return m_pimpl->DoGetPixel(x, y, col); }
810 bool GetPixel(const wxPoint& pt, wxColour *col) const
811 { return m_pimpl->DoGetPixel(pt.x, pt.y, col); }
812
813 void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
814 { m_pimpl->DoDrawLine(x1, y1, x2, y2); }
815 void DrawLine(const wxPoint& pt1, const wxPoint& pt2)
816 { m_pimpl->DoDrawLine(pt1.x, pt1.y, pt2.x, pt2.y); }
817
818 void CrossHair(wxCoord x, wxCoord y)
819 { m_pimpl->DoCrossHair(x, y); }
820 void CrossHair(const wxPoint& pt)
821 { m_pimpl->DoCrossHair(pt.x, pt.y); }
822
823 void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
824 wxCoord xc, wxCoord yc)
825 { m_pimpl->DoDrawArc(x1, y1, x2, y2, xc, yc); }
826 void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre)
827 { m_pimpl->DoDrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y); }
828
829 void DrawCheckMark(wxCoord x, wxCoord y,
830 wxCoord width, wxCoord height)
831 { m_pimpl->DoDrawCheckMark(x, y, width, height); }
832 void DrawCheckMark(const wxRect& rect)
833 { m_pimpl->DoDrawCheckMark(rect.x, rect.y, rect.width, rect.height); }
834
835 void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
836 double sa, double ea)
837 { m_pimpl->DoDrawEllipticArc(x, y, w, h, sa, ea); }
838 void DrawEllipticArc(const wxPoint& pt, const wxSize& sz,
839 double sa, double ea)
840 { m_pimpl->DoDrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea); }
841
842 void DrawPoint(wxCoord x, wxCoord y)
843 { m_pimpl->DoDrawPoint(x, y); }
844 void DrawPoint(const wxPoint& pt)
845 { m_pimpl->DoDrawPoint(pt.x, pt.y); }
846
847 void DrawLines(int n, wxPoint points[],
848 wxCoord xoffset = 0, wxCoord yoffset = 0)
849 { m_pimpl->DoDrawLines(n, points, xoffset, yoffset); }
850
851 #if 0
852 // needs to be removed
853 void DrawLines(const wxPointList *list,
854 wxCoord xoffset = 0, wxCoord yoffset = 0)
855 #endif
856
857 void DrawPolygon(int n, wxPoint points[],
858 wxCoord xoffset = 0, wxCoord yoffset = 0,
859 int fillStyle = wxODDEVEN_RULE)
860 { m_pimpl->DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); }
861
862 #if 0
863 // needs to be removed
864 void DrawPolygon(const wxPointList *list,
865 wxCoord xoffset = 0, wxCoord yoffset = 0,
866 int fillStyle = wxODDEVEN_RULE)
867 { m_pimpl->DrawPolygon( list, xoffset, yoffset, fillStyle ); }
868 #endif
869
870 void DrawPolyPolygon(int n, int count[], wxPoint points[],
871 wxCoord xoffset = 0, wxCoord yoffset = 0,
872 int fillStyle = wxODDEVEN_RULE)
873 { m_pimpl->DoDrawPolyPolygon(n, count, points, xoffset, yoffset, fillStyle); }
874
875 void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
876 { m_pimpl->DoDrawRectangle(x, y, width, height); }
877 void DrawRectangle(const wxPoint& pt, const wxSize& sz)
878 { m_pimpl->DoDrawRectangle(pt.x, pt.y, sz.x, sz.y); }
879 void DrawRectangle(const wxRect& rect)
880 { m_pimpl->DoDrawRectangle(rect.x, rect.y, rect.width, rect.height); }
881
882 void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height,
883 double radius)
884 { m_pimpl->DoDrawRoundedRectangle(x, y, width, height, radius); }
885 void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz,
886 double radius)
887 { m_pimpl->DoDrawRoundedRectangle(pt.x, pt.y, sz.x, sz.y, radius); }
888 void DrawRoundedRectangle(const wxRect& r, double radius)
889 { m_pimpl->DoDrawRoundedRectangle(r.x, r.y, r.width, r.height, radius); }
890
891 void DrawCircle(wxCoord x, wxCoord y, wxCoord radius)
892 { m_pimpl->DoDrawEllipse(x - radius, y - radius, 2*radius, 2*radius); }
893 void DrawCircle(const wxPoint& pt, wxCoord radius)
894 { m_pimpl->DoDrawEllipse(pt.x - radius, pt.y - radius, 2*radius, 2*radius); }
895
896 void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
897 { m_pimpl->DoDrawEllipse(x, y, width, height); }
898 void DrawEllipse(const wxPoint& pt, const wxSize& sz)
899 { m_pimpl->DoDrawEllipse(pt.x, pt.y, sz.x, sz.y); }
900 void DrawEllipse(const wxRect& rect)
901 { m_pimpl->DoDrawEllipse(rect.x, rect.y, rect.width, rect.height); }
902
903 void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
904 { m_pimpl->DoDrawIcon(icon, x, y); }
905 void DrawIcon(const wxIcon& icon, const wxPoint& pt)
906 { m_pimpl->DoDrawIcon(icon, pt.x, pt.y); }
907
908 void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
909 bool useMask = false)
910 { m_pimpl->DoDrawBitmap(bmp, x, y, useMask); }
911 void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt,
912 bool useMask = false)
913 { m_pimpl->DoDrawBitmap(bmp, pt.x, pt.y, useMask); }
914
915 void DrawText(const wxString& text, wxCoord x, wxCoord y)
916 { m_pimpl->DoDrawText(text, x, y); }
917 void DrawText(const wxString& text, const wxPoint& pt)
918 { m_pimpl->DoDrawText(text, pt.x, pt.y); }
919
920 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle)
921 { m_pimpl->DoDrawRotatedText(text, x, y, angle); }
922 void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle)
923 { m_pimpl->DoDrawRotatedText(text, pt.x, pt.y, angle); }
924
925 // this version puts both optional bitmap and the text into the given
926 // rectangle and aligns is as specified by alignment parameter; it also
927 // will emphasize the character with the given index if it is != -1 and
928 // return the bounding rectangle if required
929 void DrawLabel(const wxString& text,
930 const wxBitmap& image,
931 const wxRect& rect,
932 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
933 int indexAccel = -1,
934 wxRect *rectBounding = NULL);
935
936 void DrawLabel(const wxString& text, const wxRect& rect,
937 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
938 int indexAccel = -1)
939 { DrawLabel(text, wxNullBitmap, rect, alignment, indexAccel); }
940
941 bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
942 wxDC *source, wxCoord xsrc, wxCoord ysrc,
943 int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord)
944 {
945 return m_pimpl->DoBlit(xdest, ydest, width, height,
946 source, xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask);
947 }
948 bool Blit(const wxPoint& destPt, const wxSize& sz,
949 wxDC *source, const wxPoint& srcPt,
950 int rop = wxCOPY, bool useMask = false, const wxPoint& srcPtMask = wxDefaultPosition)
951 {
952 return m_pimpl->DoBlit(destPt.x, destPt.y, sz.x, sz.y,
953 source, srcPt.x, srcPt.y, rop, useMask, srcPtMask.x, srcPtMask.y);
954 }
955
956 bool StretchBlit(wxCoord dstX, wxCoord dstY,
957 wxCoord dstWidth, wxCoord dstHeight,
958 wxDC *source,
959 wxCoord srcX, wxCoord srcY,
960 wxCoord srcWidth, wxCoord srcHeight,
961 int rop = wxCOPY, bool useMask = false,
962 wxCoord srcMaskX = wxDefaultCoord, wxCoord srcMaskY = wxDefaultCoord)
963 {
964 return m_pimpl->DoStretchBlit(dstX, dstY, dstWidth, dstHeight,
965 source, srcX, srcY, srcWidth, srcHeight, rop, useMask, srcMaskX, srcMaskY);
966 }
967 bool StretchBlit(const wxPoint& dstPt, const wxSize& dstSize,
968 wxDC *source, const wxPoint& srcPt, const wxSize& srcSize,
969 int rop = wxCOPY, bool useMask = false, const wxPoint& srcMaskPt = wxDefaultPosition)
970 {
971 return m_pimpl->DoStretchBlit(dstPt.x, dstPt.y, dstSize.x, dstSize.y,
972 source, srcPt.x, srcPt.y, srcSize.x, srcSize.y, rop, useMask, srcMaskPt.x, srcMaskPt.y);
973 }
974
975 wxBitmap GetAsBitmap(const wxRect *subrect = (const wxRect *) NULL) const
976 {
977 return m_pimpl->DoGetAsBitmap(subrect);
978 }
979
980 #if wxUSE_SPLINES
981 void DrawSpline(wxCoord x1, wxCoord y1,
982 wxCoord x2, wxCoord y2,
983 wxCoord x3, wxCoord y3)
984 { m_pimpl->DoDrawSpline(x1,y1,x2,y2,x3,y3); }
985 void DrawSpline(int n, wxPoint points[])
986 { m_pimpl->DoDrawSpline(n,points); }
987 void DrawSpline(const wxPointList *points)
988 { m_pimpl->DoDrawSpline(points); }
989 #endif // wxUSE_SPLINES
990
991
992 #if WXWIN_COMPATIBILITY_2_8
993 // for compatibility with the old code when wxCoord was long everywhere
994 wxDEPRECATED( void GetTextExtent(const wxString& string,
995 long *x, long *y,
996 long *descent = NULL,
997 long *externalLeading = NULL,
998 const wxFont *theFont = NULL) const );
999 wxDEPRECATED( void GetLogicalOrigin(long *x, long *y) const );
1000 wxDEPRECATED( void GetDeviceOrigin(long *x, long *y) const );
1001 wxDEPRECATED( void GetClippingBox(long *x, long *y, long *w, long *h) const );
1002 #endif // WXWIN_COMPATIBILITY_2_8
1003
1004
1005 protected:
1006 wxImplDC *m_pimpl;
1007
1008 private:
1009 DECLARE_ABSTRACT_CLASS(wxImplDC)
1010 };
1011
1012
1013 //-----------------------------------------------------------------------------
1014 // wxWindowDC
1015 //-----------------------------------------------------------------------------
1016
1017 class WXDLLIMPEXP_CORE wxWindowDC : public wxDC
1018 {
1019 public:
1020 wxWindowDC();
1021 wxWindowDC( wxWindow *win );
1022
1023 private:
1024 DECLARE_DYNAMIC_CLASS(wxWindowDC)
1025 };
1026
1027 //-----------------------------------------------------------------------------
1028 // wxClientDC
1029 //-----------------------------------------------------------------------------
1030
1031 class WXDLLIMPEXP_CORE wxClientDC : public wxDC
1032 {
1033 public:
1034 wxClientDC();
1035 wxClientDC( wxWindow *win );
1036
1037 private:
1038 DECLARE_DYNAMIC_CLASS(wxClientDC)
1039 };
1040
1041 //-----------------------------------------------------------------------------
1042 // wxPaintDC
1043 //-----------------------------------------------------------------------------
1044
1045 class WXDLLIMPEXP_CORE wxPaintDC : public wxDC
1046 {
1047 public:
1048 wxPaintDC();
1049 wxPaintDC( wxWindow *win );
1050
1051 private:
1052 DECLARE_DYNAMIC_CLASS(wxPaintDC)
1053 };
1054
1055 #else // wxUSE_NEW_DC
1056
1057
1058 class WXDLLIMPEXP_FWD_CORE wxDC;
1059
1060 // ---------------------------------------------------------------------------
1061 // global variables
1062 // ---------------------------------------------------------------------------
1063
1064 // ---------------------------------------------------------------------------
1065 // wxDC is the device context - object on which any drawing is done
1066 // ---------------------------------------------------------------------------
1067
1068 class WXDLLEXPORT wxDCBase : public wxObject
1069 {
1070 public:
1071 wxDCBase();
1072 virtual ~wxDCBase();
1073
1074 // graphic primitives
1075 // ------------------
1076
1077 virtual void DrawObject(wxDrawObject* drawobject)
1078 {
1079 drawobject->Draw(*this);
1080 CalcBoundingBox(drawobject->MinX(),drawobject->MinY());
1081 CalcBoundingBox(drawobject->MaxX(),drawobject->MaxY());
1082 }
1083
1084 wxDC *GetOwner() const { return (wxDC*) this; }
1085
1086 bool FloodFill(wxCoord x, wxCoord y, const wxColour& col,
1087 int style = wxFLOOD_SURFACE)
1088 { return DoFloodFill(x, y, col, style); }
1089 bool FloodFill(const wxPoint& pt, const wxColour& col,
1090 int style = wxFLOOD_SURFACE)
1091 { return DoFloodFill(pt.x, pt.y, col, style); }
1092
1093 // fill the area specified by rect with a radial gradient, starting from
1094 // initialColour in the centre of the cercle and fading to destColour.
1095 void GradientFillConcentric(const wxRect& rect,
1096 const wxColour& initialColour,
1097 const wxColour& destColour)
1098 { GradientFillConcentric(rect, initialColour, destColour,
1099 wxPoint(rect.GetWidth() / 2,
1100 rect.GetHeight() / 2)); }
1101
1102 void GradientFillConcentric(const wxRect& rect,
1103 const wxColour& initialColour,
1104 const wxColour& destColour,
1105 const wxPoint& circleCenter)
1106 { DoGradientFillConcentric(rect, initialColour, destColour, circleCenter); }
1107
1108 // fill the area specified by rect with a linear gradient
1109 void GradientFillLinear(const wxRect& rect,
1110 const wxColour& initialColour,
1111 const wxColour& destColour,
1112 wxDirection nDirection = wxEAST)
1113 { DoGradientFillLinear(rect, initialColour, destColour, nDirection); }
1114
1115 bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const
1116 { return DoGetPixel(x, y, col); }
1117 bool GetPixel(const wxPoint& pt, wxColour *col) const
1118 { return DoGetPixel(pt.x, pt.y, col); }
1119
1120 void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
1121 { DoDrawLine(x1, y1, x2, y2); }
1122 void DrawLine(const wxPoint& pt1, const wxPoint& pt2)
1123 { DoDrawLine(pt1.x, pt1.y, pt2.x, pt2.y); }
1124
1125 void CrossHair(wxCoord x, wxCoord y)
1126 { DoCrossHair(x, y); }
1127 void CrossHair(const wxPoint& pt)
1128 { DoCrossHair(pt.x, pt.y); }
1129
1130 void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
1131 wxCoord xc, wxCoord yc)
1132 { DoDrawArc(x1, y1, x2, y2, xc, yc); }
1133 void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre)
1134 { DoDrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y); }
1135
1136 void DrawCheckMark(wxCoord x, wxCoord y,
1137 wxCoord width, wxCoord height)
1138 { DoDrawCheckMark(x, y, width, height); }
1139 void DrawCheckMark(const wxRect& rect)
1140 { DoDrawCheckMark(rect.x, rect.y, rect.width, rect.height); }
1141
1142 void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
1143 double sa, double ea)
1144 { DoDrawEllipticArc(x, y, w, h, sa, ea); }
1145 void DrawEllipticArc(const wxPoint& pt, const wxSize& sz,
1146 double sa, double ea)
1147 { DoDrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea); }
1148
1149 void DrawPoint(wxCoord x, wxCoord y)
1150 { DoDrawPoint(x, y); }
1151 void DrawPoint(const wxPoint& pt)
1152 { DoDrawPoint(pt.x, pt.y); }
1153
1154 void DrawLines(int n, wxPoint points[],
1155 wxCoord xoffset = 0, wxCoord yoffset = 0)
1156 { DoDrawLines(n, points, xoffset, yoffset); }
1157 void DrawLines(const wxPointList *list,
1158 wxCoord xoffset = 0, wxCoord yoffset = 0);
1159
1160 #if WXWIN_COMPATIBILITY_2_8
1161 wxDEPRECATED( void DrawLines(const wxList *list,
1162 wxCoord xoffset = 0, wxCoord yoffset = 0) );
1163 #endif // WXWIN_COMPATIBILITY_2_8
1164
1165
1166 void DrawPolygon(int n, wxPoint points[],
1167 wxCoord xoffset = 0, wxCoord yoffset = 0,
1168 int fillStyle = wxODDEVEN_RULE)
1169 { DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); }
1170
1171 void DrawPolygon(const wxPointList *list,
1172 wxCoord xoffset = 0, wxCoord yoffset = 0,
1173 int fillStyle = wxODDEVEN_RULE);
1174
1175 #if WXWIN_COMPATIBILITY_2_8
1176 wxDEPRECATED( void DrawPolygon(const wxList *list,
1177 wxCoord xoffset = 0, wxCoord yoffset = 0,
1178 int fillStyle = wxODDEVEN_RULE) );
1179 #endif // WXWIN_COMPATIBILITY_2_8
1180
1181 void DrawPolyPolygon(int n, int count[], wxPoint points[],
1182 wxCoord xoffset = 0, wxCoord yoffset = 0,
1183 int fillStyle = wxODDEVEN_RULE)
1184 { DoDrawPolyPolygon(n, count, points, xoffset, yoffset, fillStyle); }
1185
1186 void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
1187 { DoDrawRectangle(x, y, width, height); }
1188 void DrawRectangle(const wxPoint& pt, const wxSize& sz)
1189 { DoDrawRectangle(pt.x, pt.y, sz.x, sz.y); }
1190 void DrawRectangle(const wxRect& rect)
1191 { DoDrawRectangle(rect.x, rect.y, rect.width, rect.height); }
1192
1193 void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height,
1194 double radius)
1195 { DoDrawRoundedRectangle(x, y, width, height, radius); }
1196 void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz,
1197 double radius)
1198 { DoDrawRoundedRectangle(pt.x, pt.y, sz.x, sz.y, radius); }
1199 void DrawRoundedRectangle(const wxRect& r, double radius)
1200 { DoDrawRoundedRectangle(r.x, r.y, r.width, r.height, radius); }
1201
1202 void DrawCircle(wxCoord x, wxCoord y, wxCoord radius)
1203 { DoDrawEllipse(x - radius, y - radius, 2*radius, 2*radius); }
1204 void DrawCircle(const wxPoint& pt, wxCoord radius)
1205 { DrawCircle(pt.x, pt.y, radius); }
1206
1207 void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
1208 { DoDrawEllipse(x, y, width, height); }
1209 void DrawEllipse(const wxPoint& pt, const wxSize& sz)
1210 { DoDrawEllipse(pt.x, pt.y, sz.x, sz.y); }
1211 void DrawEllipse(const wxRect& rect)
1212 { DoDrawEllipse(rect.x, rect.y, rect.width, rect.height); }
1213
1214 void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
1215 { DoDrawIcon(icon, x, y); }
1216 void DrawIcon(const wxIcon& icon, const wxPoint& pt)
1217 { DoDrawIcon(icon, pt.x, pt.y); }
1218
1219 void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
1220 bool useMask = false)
1221 { DoDrawBitmap(bmp, x, y, useMask); }
1222 void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt,
1223 bool useMask = false)
1224 { DoDrawBitmap(bmp, pt.x, pt.y, useMask); }
1225
1226 void DrawText(const wxString& text, wxCoord x, wxCoord y)
1227 { DoDrawText(text, x, y); }
1228 void DrawText(const wxString& text, const wxPoint& pt)
1229 { DoDrawText(text, pt.x, pt.y); }
1230
1231 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle)
1232 { DoDrawRotatedText(text, x, y, angle); }
1233 void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle)
1234 { DoDrawRotatedText(text, pt.x, pt.y, angle); }
1235
1236 // this version puts both optional bitmap and the text into the given
1237 // rectangle and aligns is as specified by alignment parameter; it also
1238 // will emphasize the character with the given index if it is != -1 and
1239 // return the bounding rectangle if required
1240 virtual void DrawLabel(const wxString& text,
1241 const wxBitmap& image,
1242 const wxRect& rect,
1243 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
1244 int indexAccel = -1,
1245 wxRect *rectBounding = NULL);
1246
1247 void DrawLabel(const wxString& text, const wxRect& rect,
1248 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
1249 int indexAccel = -1)
1250 { DrawLabel(text, wxNullBitmap, rect, alignment, indexAccel); }
1251
1252 bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
1253 wxDC *source, wxCoord xsrc, wxCoord ysrc,
1254 int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord)
1255 {
1256 return DoBlit(xdest, ydest, width, height,
1257 source, xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask);
1258 }
1259 bool Blit(const wxPoint& destPt, const wxSize& sz,
1260 wxDC *source, const wxPoint& srcPt,
1261 int rop = wxCOPY, bool useMask = false, const wxPoint& srcPtMask = wxDefaultPosition)
1262 {
1263 return DoBlit(destPt.x, destPt.y, sz.x, sz.y,
1264 source, srcPt.x, srcPt.y, rop, useMask, srcPtMask.x, srcPtMask.y);
1265 }
1266
1267 bool StretchBlit(wxCoord dstX, wxCoord dstY,
1268 wxCoord dstWidth, wxCoord dstHeight,
1269 wxDC *source,
1270 wxCoord srcX, wxCoord srcY,
1271 wxCoord srcWidth, wxCoord srcHeight,
1272 int rop = wxCOPY, bool useMask = false,
1273 wxCoord srcMaskX = wxDefaultCoord, wxCoord srcMaskY = wxDefaultCoord)
1274 {
1275 return DoStretchBlit(dstX, dstY, dstWidth, dstHeight,
1276 source, srcX, srcY, srcWidth, srcHeight, rop, useMask, srcMaskX, srcMaskY);
1277 }
1278 bool StretchBlit(const wxPoint& dstPt, const wxSize& dstSize,
1279 wxDC *source, const wxPoint& srcPt, const wxSize& srcSize,
1280 int rop = wxCOPY, bool useMask = false, const wxPoint& srcMaskPt = wxDefaultPosition)
1281 {
1282 return DoStretchBlit(dstPt.x, dstPt.y, dstSize.x, dstSize.y,
1283 source, srcPt.x, srcPt.y, srcSize.x, srcSize.y, rop, useMask, srcMaskPt.x, srcMaskPt.y);
1284 }
1285
1286 wxBitmap GetAsBitmap(const wxRect *subrect = (const wxRect *) NULL) const
1287 {
1288 return DoGetAsBitmap(subrect);
1289 }
1290
1291 #if wxUSE_SPLINES
1292 void DrawSpline(wxCoord x1, wxCoord y1,
1293 wxCoord x2, wxCoord y2,
1294 wxCoord x3, wxCoord y3);
1295 void DrawSpline(int n, wxPoint points[]);
1296
1297 void DrawSpline(const wxPointList *points) { DoDrawSpline(points); }
1298
1299 #if WXWIN_COMPATIBILITY_2_8
1300 wxDEPRECATED( void DrawSpline(const wxList *points) );
1301 #endif // WXWIN_COMPATIBILITY_2_8
1302
1303 #endif // wxUSE_SPLINES
1304
1305 // Eventually we will have wxUSE_GENERIC_DRAWELLIPSE
1306 #ifdef __WXWINCE__
1307 //! Generic method to draw ellipses, circles and arcs with current pen and brush.
1308 /*! \param x Upper left corner of bounding box.
1309 * \param y Upper left corner of bounding box.
1310 * \param w Width of bounding box.
1311 * \param h Height of bounding box.
1312 * \param sa Starting angle of arc
1313 * (counterclockwise, start at 3 o'clock, 360 is full circle).
1314 * \param ea Ending angle of arc.
1315 * \param angle Rotation angle, the Arc will be rotated after
1316 * calculating begin and end.
1317 */
1318 void DrawEllipticArcRot( wxCoord x, wxCoord y,
1319 wxCoord width, wxCoord height,
1320 double sa = 0, double ea = 0, double angle = 0 )
1321 { DoDrawEllipticArcRot( x, y, width, height, sa, ea, angle ); }
1322
1323 void DrawEllipticArcRot( const wxPoint& pt,
1324 const wxSize& sz,
1325 double sa = 0, double ea = 0, double angle = 0 )
1326 { DoDrawEllipticArcRot( pt.x, pt.y, sz.x, sz.y, sa, ea, angle ); }
1327
1328 void DrawEllipticArcRot( const wxRect& rect,
1329 double sa = 0, double ea = 0, double angle = 0 )
1330 { DoDrawEllipticArcRot( rect.x, rect.y, rect.width, rect.height, sa, ea, angle ); }
1331
1332 virtual void DoDrawEllipticArcRot( wxCoord x, wxCoord y,
1333 wxCoord w, wxCoord h,
1334 double sa = 0, double ea = 0, double angle = 0 );
1335
1336 //! Rotates points around center.
1337 /*! This is a quite straight method, it calculates in pixels
1338 * and so it produces rounding errors.
1339 * \param points The points inside will be rotated.
1340 * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle).
1341 * \param center Center of rotation.
1342 */
1343 void Rotate( wxPointList* points, double angle, wxPoint center = wxPoint(0,0) );
1344
1345 // used by DrawEllipticArcRot
1346 // Careful: wxList gets filled with points you have to delete later.
1347 void CalculateEllipticPoints( wxPointList* points,
1348 wxCoord xStart, wxCoord yStart,
1349 wxCoord w, wxCoord h,
1350 double sa, double ea );
1351 #endif
1352
1353 // global DC operations
1354 // --------------------
1355
1356 virtual void Clear() = 0;
1357
1358 virtual bool StartDoc(const wxString& WXUNUSED(message)) { return true; }
1359 virtual void EndDoc() { }
1360
1361 virtual void StartPage() { }
1362 virtual void EndPage() { }
1363
1364 #if WXWIN_COMPATIBILITY_2_6
1365 wxDEPRECATED( void BeginDrawing() );
1366 wxDEPRECATED( void EndDrawing() );
1367 #endif // WXWIN_COMPATIBILITY_2_6
1368
1369
1370 // set objects to use for drawing
1371 // ------------------------------
1372
1373 virtual void SetFont(const wxFont& font) = 0;
1374 virtual void SetPen(const wxPen& pen) = 0;
1375 virtual void SetBrush(const wxBrush& brush) = 0;
1376 virtual void SetBackground(const wxBrush& brush) = 0;
1377 virtual void SetBackgroundMode(int mode) = 0;
1378 #if wxUSE_PALETTE
1379 virtual void SetPalette(const wxPalette& palette) = 0;
1380 #endif // wxUSE_PALETTE
1381
1382 // clipping region
1383 // ---------------
1384
1385 void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
1386 { DoSetClippingRegion(x, y, width, height); }
1387 void SetClippingRegion(const wxPoint& pt, const wxSize& sz)
1388 { DoSetClippingRegion(pt.x, pt.y, sz.x, sz.y); }
1389 void SetClippingRegion(const wxRect& rect)
1390 { DoSetClippingRegion(rect.x, rect.y, rect.width, rect.height); }
1391 void SetClippingRegion(const wxRegion& region)
1392 { DoSetClippingRegionAsRegion(region); }
1393
1394 virtual void DestroyClippingRegion() { ResetClipping(); }
1395
1396 void GetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const
1397 { DoGetClippingBox(x, y, w, h); }
1398 void GetClippingBox(wxRect& rect) const
1399 {
1400 DoGetClippingBox(&rect.x, &rect.y, &rect.width, &rect.height);
1401 }
1402
1403 // text extent
1404 // -----------
1405
1406 virtual wxCoord GetCharHeight() const = 0;
1407 virtual wxCoord GetCharWidth() const = 0;
1408
1409 // only works for single line strings
1410 void GetTextExtent(const wxString& string,
1411 wxCoord *x, wxCoord *y,
1412 wxCoord *descent = NULL,
1413 wxCoord *externalLeading = NULL,
1414 const wxFont *theFont = NULL) const
1415 { DoGetTextExtent(string, x, y, descent, externalLeading, theFont); }
1416
1417 wxSize GetTextExtent(const wxString& string) const
1418 {
1419 wxCoord w, h;
1420 DoGetTextExtent(string, &w, &h);
1421 return wxSize(w, h);
1422 }
1423
1424 // works for single as well as multi-line strings
1425 virtual void GetMultiLineTextExtent(const wxString& string,
1426 wxCoord *width,
1427 wxCoord *height,
1428 wxCoord *heightLine = NULL,
1429 const wxFont *font = NULL) const;
1430
1431 wxSize GetMultiLineTextExtent(const wxString& string) const
1432 {
1433 wxCoord w, h;
1434 GetMultiLineTextExtent(string, &w, &h);
1435 return wxSize(w, h);
1436 }
1437
1438 // Measure cumulative width of text after each character
1439 bool GetPartialTextExtents(const wxString& text, wxArrayInt& widths) const
1440 { return DoGetPartialTextExtents(text, widths); }
1441
1442
1443 // size and resolution
1444 // -------------------
1445
1446 // in device units
1447 void GetSize(int *width, int *height) const
1448 { DoGetSize(width, height); }
1449 wxSize GetSize() const
1450 {
1451 int w, h;
1452 DoGetSize(&w, &h);
1453
1454 return wxSize(w, h);
1455 }
1456
1457 // in mm
1458 void GetSizeMM(int* width, int* height) const
1459 { DoGetSizeMM(width, height); }
1460 wxSize GetSizeMM() const
1461 {
1462 int w, h;
1463 DoGetSizeMM(&w, &h);
1464
1465 return wxSize(w, h);
1466 }
1467
1468 // query DC capabilities
1469 // ---------------------
1470
1471 virtual bool CanDrawBitmap() const = 0;
1472 virtual bool CanGetTextExtent() const = 0;
1473
1474 // colour depth
1475 virtual int GetDepth() const = 0;
1476
1477 // Resolution in Pixels per inch
1478 virtual wxSize GetPPI() const = 0;
1479
1480 virtual bool Ok() const { return IsOk(); }
1481 virtual bool IsOk() const { return m_ok; }
1482
1483 // accessors and setters
1484 // ---------------------
1485
1486 virtual int GetBackgroundMode() const { return m_backgroundMode; }
1487 virtual const wxBrush& GetBackground() const { return m_backgroundBrush; }
1488 virtual const wxBrush& GetBrush() const { return m_brush; }
1489 virtual const wxFont& GetFont() const { return m_font; }
1490 virtual const wxPen& GetPen() const { return m_pen; }
1491
1492 virtual const wxColour& GetTextForeground() const { return m_textForegroundColour; }
1493 virtual const wxColour& GetTextBackground() const { return m_textBackgroundColour; }
1494 virtual void SetTextForeground(const wxColour& colour)
1495 { m_textForegroundColour = colour; }
1496 virtual void SetTextBackground(const wxColour& colour)
1497 { m_textBackgroundColour = colour; }
1498
1499
1500 // coordinates conversions and transforms
1501 // --------------------------------------
1502
1503 virtual wxCoord DeviceToLogicalX(wxCoord x) const;
1504 virtual wxCoord DeviceToLogicalY(wxCoord y) const;
1505 virtual wxCoord DeviceToLogicalXRel(wxCoord x) const;
1506 virtual wxCoord DeviceToLogicalYRel(wxCoord y) const;
1507 virtual wxCoord LogicalToDeviceX(wxCoord x) const;
1508 virtual wxCoord LogicalToDeviceY(wxCoord y) const;
1509 virtual wxCoord LogicalToDeviceXRel(wxCoord x) const;
1510 virtual wxCoord LogicalToDeviceYRel(wxCoord y) const;
1511
1512 virtual void SetMapMode(int mode);
1513 virtual int GetMapMode() const { return m_mappingMode; }
1514
1515 virtual void SetUserScale(double x, double y);
1516 virtual void GetUserScale(double *x, double *y) const
1517 {
1518 if ( x ) *x = m_userScaleX;
1519 if ( y ) *y = m_userScaleY;
1520 }
1521
1522 virtual void SetLogicalScale(double x, double y);
1523 virtual void GetLogicalScale(double *x, double *y)
1524 {
1525 if ( x ) *x = m_logicalScaleX;
1526 if ( y ) *y = m_logicalScaleY;
1527 }
1528
1529 virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
1530 void GetLogicalOrigin(wxCoord *x, wxCoord *y) const
1531 { DoGetLogicalOrigin(x, y); }
1532 wxPoint GetLogicalOrigin() const
1533 { wxCoord x, y; DoGetLogicalOrigin(&x, &y); return wxPoint(x, y); }
1534
1535 virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
1536 void GetDeviceOrigin(wxCoord *x, wxCoord *y) const
1537 { DoGetDeviceOrigin(x, y); }
1538 wxPoint GetDeviceOrigin() const
1539 { wxCoord x, y; DoGetDeviceOrigin(&x, &y); return wxPoint(x, y); }
1540
1541 virtual void SetDeviceLocalOrigin( wxCoord x, wxCoord y );
1542
1543 virtual void ComputeScaleAndOrigin();
1544
1545 // this needs to overidden if the axis is inverted (such
1546 // as when using Postscript, where 0,0 is the lower left
1547 // corner, not the upper left).
1548 virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
1549
1550 // logical functions
1551 // ---------------------------
1552
1553 virtual int GetLogicalFunction() const { return m_logicalFunction; }
1554 virtual void SetLogicalFunction(int function) = 0;
1555
1556 // bounding box
1557 // ------------
1558
1559 virtual void CalcBoundingBox(wxCoord x, wxCoord y)
1560 {
1561 if ( m_isBBoxValid )
1562 {
1563 if ( x < m_minX ) m_minX = x;
1564 if ( y < m_minY ) m_minY = y;
1565 if ( x > m_maxX ) m_maxX = x;
1566 if ( y > m_maxY ) m_maxY = y;
1567 }
1568 else
1569 {
1570 m_isBBoxValid = true;
1571
1572 m_minX = x;
1573 m_minY = y;
1574 m_maxX = x;
1575 m_maxY = y;
1576 }
1577 }
1578
1579 void ResetBoundingBox()
1580 {
1581 m_isBBoxValid = false;
1582
1583 m_minX = m_maxX = m_minY = m_maxY = 0;
1584 }
1585
1586 // Get the final bounding box of the PostScript or Metafile picture.
1587 wxCoord MinX() const { return m_minX; }
1588 wxCoord MaxX() const { return m_maxX; }
1589 wxCoord MinY() const { return m_minY; }
1590 wxCoord MaxY() const { return m_maxY; }
1591
1592 // misc old functions
1593 // ------------------
1594
1595 #if WXWIN_COMPATIBILITY_2_8
1596 // for compatibility with the old code when wxCoord was long everywhere
1597 wxDEPRECATED( void GetTextExtent(const wxString& string,
1598 long *x, long *y,
1599 long *descent = NULL,
1600 long *externalLeading = NULL,
1601 const wxFont *theFont = NULL) const );
1602 wxDEPRECATED( void GetLogicalOrigin(long *x, long *y) const );
1603 wxDEPRECATED( void GetDeviceOrigin(long *x, long *y) const );
1604 wxDEPRECATED( void GetClippingBox(long *x, long *y, long *w, long *h) const );
1605 #endif // WXWIN_COMPATIBILITY_2_8
1606
1607 // RTL related functions
1608 // ---------------------
1609
1610 // get or change the layout direction (LTR or RTL) for this dc,
1611 // wxLayout_Default is returned if layout direction is not supported
1612 virtual wxLayoutDirection GetLayoutDirection() const
1613 { return wxLayout_Default; }
1614 virtual void SetLayoutDirection(wxLayoutDirection WXUNUSED(dir))
1615 { }
1616
1617 protected:
1618 // the pure virtual functions which should be implemented by wxDC
1619 virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
1620 int style = wxFLOOD_SURFACE) = 0;
1621
1622 virtual void DoGradientFillLinear(const wxRect& rect,
1623 const wxColour& initialColour,
1624 const wxColour& destColour,
1625 wxDirection nDirection = wxEAST);
1626
1627 virtual void DoGradientFillConcentric(const wxRect& rect,
1628 const wxColour& initialColour,
1629 const wxColour& destColour,
1630 const wxPoint& circleCenter);
1631
1632 virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const = 0;
1633
1634 virtual void DoDrawPoint(wxCoord x, wxCoord y) = 0;
1635 virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) = 0;
1636
1637 virtual void DoDrawArc(wxCoord x1, wxCoord y1,
1638 wxCoord x2, wxCoord y2,
1639 wxCoord xc, wxCoord yc) = 0;
1640 virtual void DoDrawCheckMark(wxCoord x, wxCoord y,
1641 wxCoord width, wxCoord height);
1642 virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
1643 double sa, double ea) = 0;
1644
1645 virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) = 0;
1646 virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
1647 wxCoord width, wxCoord height,
1648 double radius) = 0;
1649 virtual void DoDrawEllipse(wxCoord x, wxCoord y,
1650 wxCoord width, wxCoord height) = 0;
1651
1652 virtual void DoCrossHair(wxCoord x, wxCoord y) = 0;
1653
1654 virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) = 0;
1655 virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
1656 bool useMask = false) = 0;
1657
1658 virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y) = 0;
1659 virtual void DoDrawRotatedText(const wxString& text,
1660 wxCoord x, wxCoord y, double angle) = 0;
1661
1662 virtual bool DoBlit(wxCoord xdest, wxCoord ydest,
1663 wxCoord width, wxCoord height,
1664 wxDC *source,
1665 wxCoord xsrc, wxCoord ysrc,
1666 int rop = wxCOPY,
1667 bool useMask = false,
1668 wxCoord xsrcMask = wxDefaultCoord,
1669 wxCoord ysrcMask = wxDefaultCoord) = 0;
1670
1671 virtual bool DoStretchBlit(wxCoord xdest, wxCoord ydest,
1672 wxCoord dstWidth, wxCoord dstHeight,
1673 wxDC *source,
1674 wxCoord xsrc, wxCoord ysrc,
1675 wxCoord srcWidth, wxCoord srcHeight,
1676 int rop = wxCOPY,
1677 bool useMask = false,
1678 wxCoord xsrcMask = wxDefaultCoord,
1679 wxCoord ysrcMask = wxDefaultCoord);
1680
1681 virtual wxBitmap DoGetAsBitmap(const wxRect *WXUNUSED(subrect)) const
1682 { return wxNullBitmap; }
1683
1684 virtual void DoGetSize(int *width, int *height) const = 0;
1685 virtual void DoGetSizeMM(int* width, int* height) const = 0;
1686
1687 virtual void DoDrawLines(int n, wxPoint points[],
1688 wxCoord xoffset, wxCoord yoffset) = 0;
1689 virtual void DoDrawPolygon(int n, wxPoint points[],
1690 wxCoord xoffset, wxCoord yoffset,
1691 int fillStyle = wxODDEVEN_RULE) = 0;
1692 virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[],
1693 wxCoord xoffset, wxCoord yoffset,
1694 int fillStyle);
1695
1696 virtual void DoSetClippingRegionAsRegion(const wxRegion& region) = 0;
1697 virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
1698 wxCoord width, wxCoord height) = 0;
1699
1700 virtual void DoGetClippingBox(wxCoord *x, wxCoord *y,
1701 wxCoord *w, wxCoord *h) const
1702 {
1703 if ( x )
1704 *x = m_clipX1;
1705 if ( y )
1706 *y = m_clipY1;
1707 if ( w )
1708 *w = m_clipX2 - m_clipX1;
1709 if ( h )
1710 *h = m_clipY2 - m_clipY1;
1711 }
1712
1713 virtual void DoGetLogicalOrigin(wxCoord *x, wxCoord *y) const
1714 {
1715 if ( x ) *x = m_logicalOriginX;
1716 if ( y ) *y = m_logicalOriginY;
1717 }
1718
1719 virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const
1720 {
1721 if ( x ) *x = m_deviceOriginX;
1722 if ( y ) *y = m_deviceOriginY;
1723 }
1724
1725 virtual void DoGetTextExtent(const wxString& string,
1726 wxCoord *x, wxCoord *y,
1727 wxCoord *descent = NULL,
1728 wxCoord *externalLeading = NULL,
1729 const wxFont *theFont = NULL) const = 0;
1730
1731 virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
1732
1733 #if wxUSE_SPLINES
1734 virtual void DoDrawSpline(const wxPointList *points);
1735 #endif
1736
1737 protected:
1738 // unset clipping variables (after clipping region was destroyed)
1739 void ResetClipping()
1740 {
1741 m_clipping = false;
1742
1743 m_clipX1 = m_clipX2 = m_clipY1 = m_clipY2 = 0;
1744 }
1745
1746 // flags
1747 bool m_colour:1;
1748 bool m_ok:1;
1749 bool m_clipping:1;
1750 bool m_isInteractive:1;
1751 bool m_isBBoxValid:1;
1752
1753 // coordinate system variables
1754
1755 // TODO short descriptions of what exactly they are would be nice...
1756
1757 wxCoord m_logicalOriginX, m_logicalOriginY;
1758 wxCoord m_deviceOriginX, m_deviceOriginY; // Usually 0,0, can be change by user
1759
1760 wxCoord m_deviceLocalOriginX, m_deviceLocalOriginY; // non-zero if native top-left corner
1761 // is not at 0,0. This was the case under
1762 // Mac's GrafPorts (coordinate system
1763 // used toplevel window's origin) and
1764 // e.g. for Postscript, where the native
1765 // origin in the bottom left corner.
1766 double m_logicalScaleX, m_logicalScaleY;
1767 double m_userScaleX, m_userScaleY;
1768 double m_scaleX, m_scaleY; // calculated from logical scale and user scale
1769
1770 // Used by SetAxisOrientation() to invert the axes
1771 int m_signX, m_signY;
1772
1773 // what is a mm on a screen you don't know the size of?
1774 double m_mm_to_pix_x,
1775 m_mm_to_pix_y;
1776
1777 // bounding and clipping boxes
1778 wxCoord m_minX, m_minY, m_maxX, m_maxY;
1779 wxCoord m_clipX1, m_clipY1, m_clipX2, m_clipY2;
1780
1781 int m_logicalFunction;
1782 int m_backgroundMode;
1783 int m_mappingMode;
1784
1785 // GDI objects
1786 wxPen m_pen;
1787 wxBrush m_brush;
1788 wxBrush m_backgroundBrush;
1789 wxColour m_textForegroundColour;
1790 wxColour m_textBackgroundColour;
1791 wxFont m_font;
1792
1793 #if wxUSE_PALETTE
1794 wxPalette m_palette;
1795 bool m_hasCustomPalette;
1796 #endif // wxUSE_PALETTE
1797
1798 private:
1799 DECLARE_NO_COPY_CLASS(wxDCBase)
1800 DECLARE_ABSTRACT_CLASS(wxDCBase)
1801 };
1802
1803 #endif // wxUSE_NEW_DC
1804
1805 // ----------------------------------------------------------------------------
1806 // now include the declaration of wxDC class
1807 // ----------------------------------------------------------------------------
1808
1809 #if defined(__WXPALMOS__)
1810 #include "wx/palmos/dc.h"
1811 #elif defined(__WXMSW__)
1812 #include "wx/msw/dc.h"
1813 #elif defined(__WXMOTIF__)
1814 #include "wx/motif/dc.h"
1815 #elif defined(__WXGTK20__)
1816 #include "wx/gtk/dc.h"
1817 #elif defined(__WXGTK__)
1818 #include "wx/gtk1/dc.h"
1819 #elif defined(__WXX11__)
1820 #include "wx/x11/dc.h"
1821 #elif defined(__WXMGL__)
1822 #include "wx/mgl/dc.h"
1823 #elif defined(__WXDFB__)
1824 #include "wx/dfb/dc.h"
1825 #elif defined(__WXMAC__)
1826 #include "wx/mac/dc.h"
1827 #elif defined(__WXCOCOA__)
1828 #include "wx/cocoa/dc.h"
1829 #elif defined(__WXPM__)
1830 #include "wx/os2/dc.h"
1831 #endif
1832
1833 #if wxUSE_GRAPHICS_CONTEXT
1834 #include "wx/dcgraph.h"
1835 #endif
1836
1837 // ----------------------------------------------------------------------------
1838 // helper class: you can use it to temporarily change the DC text colour and
1839 // restore it automatically when the object goes out of scope
1840 // ----------------------------------------------------------------------------
1841
1842 class WXDLLEXPORT wxDCTextColourChanger
1843 {
1844 public:
1845 wxDCTextColourChanger(wxDC& dc) : m_dc(dc), m_colFgOld() { }
1846
1847 wxDCTextColourChanger(wxDC& dc, const wxColour& col) : m_dc(dc)
1848 {
1849 Set(col);
1850 }
1851
1852 ~wxDCTextColourChanger()
1853 {
1854 if ( m_colFgOld.Ok() )
1855 m_dc.SetTextForeground(m_colFgOld);
1856 }
1857
1858 void Set(const wxColour& col)
1859 {
1860 if ( !m_colFgOld.Ok() )
1861 m_colFgOld = m_dc.GetTextForeground();
1862 m_dc.SetTextForeground(col);
1863 }
1864
1865 private:
1866 wxDC& m_dc;
1867
1868 wxColour m_colFgOld;
1869
1870 DECLARE_NO_COPY_CLASS(wxDCTextColourChanger)
1871 };
1872
1873 // ----------------------------------------------------------------------------
1874 // helper class: you can use it to temporarily change the DC pen and
1875 // restore it automatically when the object goes out of scope
1876 // ----------------------------------------------------------------------------
1877
1878 class WXDLLEXPORT wxDCPenChanger
1879 {
1880 public:
1881 wxDCPenChanger(wxDC& dc, const wxPen& pen) : m_dc(dc), m_penOld(dc.GetPen())
1882 {
1883 m_dc.SetPen(pen);
1884 }
1885
1886 ~wxDCPenChanger()
1887 {
1888 if ( m_penOld.Ok() )
1889 m_dc.SetPen(m_penOld);
1890 }
1891
1892 private:
1893 wxDC& m_dc;
1894
1895 wxPen m_penOld;
1896
1897 DECLARE_NO_COPY_CLASS(wxDCPenChanger)
1898 };
1899
1900 // ----------------------------------------------------------------------------
1901 // helper class: you can use it to temporarily change the DC brush and
1902 // restore it automatically when the object goes out of scope
1903 // ----------------------------------------------------------------------------
1904
1905 class WXDLLEXPORT wxDCBrushChanger
1906 {
1907 public:
1908 wxDCBrushChanger(wxDC& dc, const wxBrush& brush) : m_dc(dc), m_brushOld(dc.GetBrush())
1909 {
1910 m_dc.SetBrush(brush);
1911 }
1912
1913 ~wxDCBrushChanger()
1914 {
1915 if ( m_brushOld.Ok() )
1916 m_dc.SetBrush(m_brushOld);
1917 }
1918
1919 private:
1920 wxDC& m_dc;
1921
1922 wxBrush m_brushOld;
1923
1924 DECLARE_NO_COPY_CLASS(wxDCBrushChanger)
1925 };
1926
1927 // ----------------------------------------------------------------------------
1928 // another small helper class: sets the clipping region in its ctor and
1929 // destroys it in the dtor
1930 // ----------------------------------------------------------------------------
1931
1932 class WXDLLEXPORT wxDCClipper
1933 {
1934 public:
1935 wxDCClipper(wxDC& dc, const wxRegion& r) : m_dc(dc)
1936 { dc.SetClippingRegion(r); }
1937 wxDCClipper(wxDC& dc, const wxRect& r) : m_dc(dc)
1938 { dc.SetClippingRegion(r.x, r.y, r.width, r.height); }
1939 wxDCClipper(wxDC& dc, wxCoord x, wxCoord y, wxCoord w, wxCoord h) : m_dc(dc)
1940 { dc.SetClippingRegion(x, y, w, h); }
1941
1942 ~wxDCClipper() { m_dc.DestroyClippingRegion(); }
1943
1944 private:
1945 wxDC& m_dc;
1946
1947 DECLARE_NO_COPY_CLASS(wxDCClipper)
1948 };
1949
1950 #endif // _WX_DC_H_BASE_