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