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