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