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