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