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