1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_DC_H_BASE_
13 #define _WX_DC_H_BASE_
15 // ----------------------------------------------------------------------------
16 // headers which we must include here
17 // ----------------------------------------------------------------------------
19 #include "wx/object.h" // the base class
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
28 #include "wx/palette.h"
29 #include "wx/dynarray.h"
33 // 1 if using the reorganized DC code
34 #define wxUSE_NEW_DC 0
38 class WXDLLIMPEXP_FWD_CORE wxDC
;
39 class WXDLLIMPEXP_FWD_CORE wxClientDC
;
40 class WXDLLIMPEXP_FWD_CORE wxPaintDC
;
41 class WXDLLIMPEXP_FWD_CORE wxWindowDC
;
42 class WXDLLIMPEXP_FWD_CORE wxScreenDC
;
43 class WXDLLIMPEXP_FWD_CORE wxMemoryDC
;
44 class WXDLLIMPEXP_FWD_CORE wxPrinterDC
;
45 #include "wx/cmndata.h"
47 class WXDLLIMPEXP_FWD_CORE wxDCBase
;
50 class WXDLLEXPORT wxDrawObject
55 : m_isBBoxValid(false)
56 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
59 virtual ~wxDrawObject() { }
62 virtual void Draw(wxDC
&) const { }
64 virtual void Draw(wxDCBase
&) const { }
67 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
71 if ( x
< m_minX
) m_minX
= x
;
72 if ( y
< m_minY
) m_minY
= y
;
73 if ( x
> m_maxX
) m_maxX
= x
;
74 if ( y
> m_maxY
) m_maxY
= y
;
87 void ResetBoundingBox()
89 m_isBBoxValid
= false;
91 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
94 // Get the final bounding box of the PostScript or Metafile picture.
96 wxCoord
MinX() const { return m_minX
; }
97 wxCoord
MaxX() const { return m_maxX
; }
98 wxCoord
MinY() const { return m_minY
; }
99 wxCoord
MaxY() const { return m_maxY
; }
101 //to define the type of object for derived objects
102 virtual int GetType()=0;
105 //for boundingbox calculation
106 bool m_isBBoxValid
:1;
107 //for boundingbox calculation
108 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
114 //-----------------------------------------------------------------------------
116 //-----------------------------------------------------------------------------
118 class WXDLLIMPEXP_FWD_CORE wxImplDC
;
120 class WXDLLIMPEXP_CORE wxDCFactory
124 virtual ~wxDCFactory() {}
126 virtual wxImplDC
* CreateWindowDC( wxWindowDC
*owner
) = 0;
127 virtual wxImplDC
* CreateWindowDC( wxWindowDC
*owner
, wxWindow
*window
) = 0;
128 virtual wxImplDC
* CreateClientDC( wxClientDC
*owner
) = 0;
129 virtual wxImplDC
* CreateClientDC( wxClientDC
*owner
, wxWindow
*window
) = 0;
130 virtual wxImplDC
* CreatePaintDC( wxPaintDC
*owner
) = 0;
131 virtual wxImplDC
* CreatePaintDC( wxPaintDC
*owner
, wxWindow
*window
) = 0;
132 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
) = 0;
133 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
, wxBitmap
&bitmap
) = 0;
134 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
, wxDC
*dc
) = 0;
135 virtual wxImplDC
* CreateScreenDC( wxScreenDC
*owner
) = 0;
136 virtual wxImplDC
* CreatePrinterDC( wxPrinterDC
*owner
, const wxPrintData
&data
) = 0;
138 static void SetDCFactory( wxDCFactory
*factory
);
139 static wxDCFactory
*GetFactory();
141 static wxDCFactory
*m_factory
;
144 //-----------------------------------------------------------------------------
146 //-----------------------------------------------------------------------------
148 class WXDLLIMPEXP_CORE wxNativeDCFactory
: public wxDCFactory
151 wxNativeDCFactory() {}
153 virtual wxImplDC
* CreateWindowDC( wxWindowDC
*owner
);
154 virtual wxImplDC
* CreateWindowDC( wxWindowDC
*owner
, wxWindow
*window
);
155 virtual wxImplDC
* CreateClientDC( wxClientDC
*owner
);
156 virtual wxImplDC
* CreateClientDC( wxClientDC
*owner
, wxWindow
*window
);
157 virtual wxImplDC
* CreatePaintDC( wxPaintDC
*owner
);
158 virtual wxImplDC
* CreatePaintDC( wxPaintDC
*owner
, wxWindow
*window
);
159 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
);
160 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
, wxBitmap
&bitmap
);
161 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
, wxDC
*dc
);
162 virtual wxImplDC
* CreateScreenDC( wxScreenDC
*owner
);
163 virtual wxImplDC
* CreatePrinterDC( wxPrinterDC
*owner
, const wxPrintData
&data
);
166 //-----------------------------------------------------------------------------
168 //-----------------------------------------------------------------------------
170 class WXDLLIMPEXP_CORE wxImplDC
: public wxObject
173 wxImplDC( wxDC
*owner
);
176 wxDC
*GetOwner() const { return m_owner
; }
178 virtual bool IsOk() const { return m_ok
; }
180 // query capabilities
182 virtual bool CanDrawBitmap() const = 0;
183 virtual bool CanGetTextExtent() const = 0;
185 // query dimension, colour deps, resolution
187 virtual void DoGetSize(int *width
, int *height
) const = 0;
188 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
190 virtual int GetDepth() const = 0;
191 virtual wxSize
GetPPI() const = 0;
193 // Right-To-Left (RTL) modes
195 virtual void SetLayoutDirection(wxLayoutDirection
WXUNUSED(dir
)) { }
196 virtual wxLayoutDirection
GetLayoutDirection() const { return wxLayout_Default
; }
200 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
201 virtual void EndDoc() { }
203 virtual void StartPage() { }
204 virtual void EndPage() { }
206 // flushing the content of this dc immediately eg onto screen
207 virtual void Flush() { }
211 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
215 if ( x
< m_minX
) m_minX
= x
;
216 if ( y
< m_minY
) m_minY
= y
;
217 if ( x
> m_maxX
) m_maxX
= x
;
218 if ( y
> m_maxY
) m_maxY
= y
;
222 m_isBBoxValid
= true;
230 void ResetBoundingBox()
232 m_isBBoxValid
= false;
234 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
237 wxCoord
MinX() const { return m_minX
; }
238 wxCoord
MaxX() const { return m_maxX
; }
239 wxCoord
MinY() const { return m_minY
; }
240 wxCoord
MaxY() const { return m_maxY
; }
242 // setters and getters
244 virtual void SetFont(const wxFont
& font
) = 0;
245 virtual const wxFont
& GetFont() const { return m_font
; }
247 virtual void SetPen(const wxPen
& pen
) = 0;
248 virtual const wxPen
& GetPen() const { return m_pen
; }
250 virtual void SetBrush(const wxBrush
& brush
) = 0;
251 virtual const wxBrush
& GetBrush() const { return m_brush
; }
253 virtual void SetBackground(const wxBrush
& brush
) = 0;
254 virtual const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
256 virtual void SetBackgroundMode(int mode
) = 0;
257 virtual int GetBackgroundMode() const { return m_backgroundMode
; }
259 virtual void SetTextForeground(const wxColour
& colour
)
260 { m_textForegroundColour
= colour
; }
261 virtual const wxColour
& GetTextForeground() const { return m_textForegroundColour
; }
263 virtual void SetTextBackground(const wxColour
& colour
)
264 { m_textBackgroundColour
= colour
; }
265 virtual const wxColour
& GetTextBackground() const { return m_textBackgroundColour
; }
268 virtual void SetPalette(const wxPalette
& palette
) = 0;
269 #endif // wxUSE_PALETTE
273 virtual void SetLogicalFunction(int function
) = 0;
274 virtual int GetLogicalFunction() const { return m_logicalFunction
; }
278 virtual wxCoord
GetCharHeight() const = 0;
279 virtual wxCoord
GetCharWidth() const = 0;
280 virtual void DoGetTextExtent(const wxString
& string
,
281 wxCoord
*x
, wxCoord
*y
,
282 wxCoord
*descent
= NULL
,
283 wxCoord
*externalLeading
= NULL
,
284 const wxFont
*theFont
= NULL
) const = 0;
285 virtual void GetMultiLineTextExtent(const wxString
& string
,
288 wxCoord
*heightLine
= NULL
,
289 const wxFont
*font
= NULL
) const;
290 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
294 virtual void Clear() = 0;
298 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
299 wxCoord width
, wxCoord height
) = 0;
300 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
) = 0;
302 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
303 wxCoord
*w
, wxCoord
*h
) const
310 *w
= m_clipX2
- m_clipX1
;
312 *h
= m_clipY2
- m_clipY1
;
315 virtual void DestroyClippingRegion() { ResetClipping(); }
318 // coordinates conversions and transforms
320 virtual wxCoord
DeviceToLogicalX(wxCoord x
) const;
321 virtual wxCoord
DeviceToLogicalY(wxCoord y
) const;
322 virtual wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
323 virtual wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
324 virtual wxCoord
LogicalToDeviceX(wxCoord x
) const;
325 virtual wxCoord
LogicalToDeviceY(wxCoord y
) const;
326 virtual wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
327 virtual wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
329 virtual void SetMapMode(int mode
);
330 virtual int GetMapMode() const { return m_mappingMode
; }
332 virtual void SetUserScale(double x
, double y
);
333 virtual void GetUserScale(double *x
, double *y
) const
335 if ( x
) *x
= m_userScaleX
;
336 if ( y
) *y
= m_userScaleY
;
339 virtual void SetLogicalScale(double x
, double y
);
340 virtual void GetLogicalScale(double *x
, double *y
)
342 if ( x
) *x
= m_logicalScaleX
;
343 if ( y
) *y
= m_logicalScaleY
;
346 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
347 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
349 if ( x
) *x
= m_logicalOriginX
;
350 if ( y
) *y
= m_logicalOriginY
;
353 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
354 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
356 if ( x
) *x
= m_deviceOriginX
;
357 if ( y
) *y
= m_deviceOriginY
;
360 virtual void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
);
362 virtual void ComputeScaleAndOrigin();
364 // this needs to overidden if the axis is inverted
365 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
367 // ---------------------------------------------------------
368 // the actual drawing API
370 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
371 int style
= wxFLOOD_SURFACE
) = 0;
373 virtual void DoGradientFillLinear(const wxRect
& rect
,
374 const wxColour
& initialColour
,
375 const wxColour
& destColour
,
376 wxDirection nDirection
= wxEAST
);
378 virtual void DoGradientFillConcentric(const wxRect
& rect
,
379 const wxColour
& initialColour
,
380 const wxColour
& destColour
,
381 const wxPoint
& circleCenter
);
383 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
385 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
386 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
388 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
389 wxCoord x2
, wxCoord y2
,
390 wxCoord xc
, wxCoord yc
) = 0;
391 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
392 wxCoord width
, wxCoord height
);
393 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
394 double sa
, double ea
) = 0;
396 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
397 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
398 wxCoord width
, wxCoord height
,
400 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
401 wxCoord width
, wxCoord height
) = 0;
403 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
405 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
406 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
407 bool useMask
= false) = 0;
409 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
410 virtual void DoDrawRotatedText(const wxString
& text
,
411 wxCoord x
, wxCoord y
, double angle
) = 0;
413 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
414 wxCoord width
, wxCoord height
,
416 wxCoord xsrc
, wxCoord ysrc
,
418 bool useMask
= false,
419 wxCoord xsrcMask
= wxDefaultCoord
,
420 wxCoord ysrcMask
= wxDefaultCoord
) = 0;
422 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
423 wxCoord dstWidth
, wxCoord dstHeight
,
425 wxCoord xsrc
, wxCoord ysrc
,
426 wxCoord srcWidth
, wxCoord srcHeight
,
428 bool useMask
= false,
429 wxCoord xsrcMask
= wxDefaultCoord
,
430 wxCoord ysrcMask
= wxDefaultCoord
);
432 virtual wxBitmap
DoGetAsBitmap(const wxRect
*WXUNUSED(subrect
)) const
433 { return wxNullBitmap
; }
436 virtual void DoDrawLines(int n
, wxPoint points
[],
437 wxCoord xoffset
, wxCoord yoffset
) = 0;
438 virtual void DoDrawPolygon(int n
, wxPoint points
[],
439 wxCoord xoffset
, wxCoord yoffset
,
440 int fillStyle
= wxODDEVEN_RULE
) = 0;
441 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
442 wxCoord xoffset
, wxCoord yoffset
,
448 virtual void DoDrawSpline(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
, wxCoord x3
, wxCoord y3
);
449 virtual void DoDrawSpline(int n
, wxPoint points
[]);
450 virtual void DoDrawSpline(const wxPointList
*points
);
457 // unset clipping variables (after clipping region was destroyed)
462 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
469 bool m_isInteractive
:1;
470 bool m_isBBoxValid
:1;
472 // coordinate system variables
474 wxCoord m_logicalOriginX
, m_logicalOriginY
;
475 wxCoord m_deviceOriginX
, m_deviceOriginY
; // Usually 0,0, can be change by user
477 wxCoord m_deviceLocalOriginX
, m_deviceLocalOriginY
; // non-zero if native top-left corner
478 // is not at 0,0. This was the case under
479 // Mac's GrafPorts (coordinate system
480 // used toplevel window's origin) and
481 // e.g. for Postscript, where the native
482 // origin in the bottom left corner.
483 double m_logicalScaleX
, m_logicalScaleY
;
484 double m_userScaleX
, m_userScaleY
;
485 double m_scaleX
, m_scaleY
; // calculated from logical scale and user scale
487 int m_signX
, m_signY
; // Used by SetAxisOrientation() to invert the axes
489 // what is a mm on a screen you don't know the size of?
490 double m_mm_to_pix_x
,
493 // bounding and clipping boxes
494 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
495 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
497 int m_logicalFunction
;
498 int m_backgroundMode
;
503 wxBrush m_backgroundBrush
;
504 wxColour m_textForegroundColour
;
505 wxColour m_textBackgroundColour
;
510 bool m_hasCustomPalette
;
511 #endif // wxUSE_PALETTE
514 DECLARE_ABSTRACT_CLASS(wxImplDC
)
518 class wxDC
: public wxObject
521 wxDC() { m_pimpl
= NULL
; }
525 const wxImplDC
*GetImpl() const
530 { return m_pimpl
&& m_pimpl
->IsOk(); }
532 // query capabilities
534 bool CanDrawBitmap() const
535 { return m_pimpl
->CanDrawBitmap(); }
536 bool CanGetTextExtent() const
537 { return m_pimpl
->CanGetTextExtent(); }
539 // query dimension, colour deps, resolution
541 void GetSize(int *width
, int *height
) const
542 { m_pimpl
->DoGetSize(width
, height
); }
544 wxSize
GetSize() const
547 m_pimpl
->DoGetSize(&w
, &h
);
551 void GetSizeMM(int* width
, int* height
) const
552 { m_pimpl
->DoGetSizeMM(width
, height
); }
553 wxSize
GetSizeMM() const
556 m_pimpl
->DoGetSizeMM(&w
, &h
);
561 { return m_pimpl
->GetDepth(); }
562 wxSize
GetPPI() const
563 { return m_pimpl
->GetPPI(); }
565 // Right-To-Left (RTL) modes
567 void SetLayoutDirection(wxLayoutDirection dir
)
568 { m_pimpl
->SetLayoutDirection( dir
); }
569 wxLayoutDirection
GetLayoutDirection() const
570 { return m_pimpl
->GetLayoutDirection(); }
574 bool StartDoc(const wxString
& message
)
575 { return m_pimpl
->StartDoc(message
); }
577 { m_pimpl
->EndDoc(); }
580 { m_pimpl
->StartPage(); }
582 { m_pimpl
->EndPage(); }
586 void CalcBoundingBox(wxCoord x
, wxCoord y
)
587 { m_pimpl
->CalcBoundingBox(x
,y
); }
588 void ResetBoundingBox()
589 { m_pimpl
->ResetBoundingBox(); }
592 { return m_pimpl
->MinX(); }
594 { return m_pimpl
->MaxX(); }
596 { return m_pimpl
->MinY(); }
598 { return m_pimpl
->MaxY(); }
600 // setters and getters
602 void SetFont(const wxFont
& font
)
603 { m_pimpl
->SetFont( font
); }
604 const wxFont
& GetFont() const
605 { return m_pimpl
->GetFont(); }
607 void SetPen(const wxPen
& pen
)
608 { m_pimpl
->SetPen( pen
); }
609 const wxPen
& GetPen() const
610 { return m_pimpl
->GetPen(); }
612 void SetBrush(const wxBrush
& brush
)
613 { m_pimpl
->SetBrush( brush
); }
614 const wxBrush
& GetBrush() const
615 { return m_pimpl
->GetBrush(); }
617 void SetBackground(const wxBrush
& brush
)
618 { m_pimpl
->SetBackground( brush
); }
619 const wxBrush
& GetBackground() const
620 { return m_pimpl
->GetBackground(); }
622 void SetBackgroundMode(int mode
)
623 { m_pimpl
->SetBackgroundMode( mode
); }
624 int GetBackgroundMode() const
625 { return m_pimpl
->GetBackgroundMode(); }
627 void SetTextForeground(const wxColour
& colour
)
628 { m_pimpl
->SetTextForeground(colour
); }
629 const wxColour
& GetTextForeground() const
630 { return m_pimpl
->GetTextForeground(); }
632 void SetTextBackground(const wxColour
& colour
)
633 { m_pimpl
->SetTextBackground(colour
); }
634 const wxColour
& GetTextBackground() const
635 { return m_pimpl
->GetTextBackground(); }
638 void SetPalette(const wxPalette
& palette
)
639 { m_pimpl
->SetPalette(palette
); }
640 #endif // wxUSE_PALETTE
644 void SetLogicalFunction(int function
)
645 { m_pimpl
->SetLogicalFunction(function
); }
646 int GetLogicalFunction() const
647 { return m_pimpl
->GetLogicalFunction(); }
651 wxCoord
GetCharHeight() const
652 { return m_pimpl
->GetCharHeight(); }
653 wxCoord
GetCharWidth() const
654 { return m_pimpl
->GetCharWidth(); }
656 void GetTextExtent(const wxString
& string
,
657 wxCoord
*x
, wxCoord
*y
,
658 wxCoord
*descent
= NULL
,
659 wxCoord
*externalLeading
= NULL
,
660 const wxFont
*theFont
= NULL
) const
661 { m_pimpl
->DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
663 wxSize
GetTextExtent(const wxString
& string
) const
666 m_pimpl
->DoGetTextExtent(string
, &w
, &h
);
670 void GetMultiLineTextExtent(const wxString
& string
,
673 wxCoord
*heightLine
= NULL
,
674 const wxFont
*font
= NULL
) const
675 { m_pimpl
->GetMultiLineTextExtent( string
, width
, height
, heightLine
, font
); }
677 wxSize
GetMultiLineTextExtent(const wxString
& string
) const
680 m_pimpl
->GetMultiLineTextExtent(string
, &w
, &h
);
684 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
685 { return m_pimpl
->DoGetPartialTextExtents(text
, widths
); }
690 { m_pimpl
->Clear(); }
694 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
695 { m_pimpl
->DoSetClippingRegion(x
, y
, width
, height
); }
696 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
697 { m_pimpl
->DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
698 void SetClippingRegion(const wxRect
& rect
)
699 { m_pimpl
->DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
700 void SetClippingRegion(const wxRegion
& region
)
701 { m_pimpl
->DoSetClippingRegionAsRegion(region
); }
703 void DestroyClippingRegion()
704 { m_pimpl
->DestroyClippingRegion(); }
706 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
707 { m_pimpl
->DoGetClippingBox(x
, y
, w
, h
); }
708 void GetClippingBox(wxRect
& rect
) const
709 { m_pimpl
->DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
); }
711 // coordinates conversions and transforms
713 wxCoord
DeviceToLogicalX(wxCoord x
) const
714 { return m_pimpl
->DeviceToLogicalX(x
); }
715 wxCoord
DeviceToLogicalY(wxCoord y
) const
716 { return m_pimpl
->DeviceToLogicalY(y
); }
717 wxCoord
DeviceToLogicalXRel(wxCoord x
) const
718 { return m_pimpl
->DeviceToLogicalXRel(x
); }
719 wxCoord
DeviceToLogicalYRel(wxCoord y
) const
720 { return m_pimpl
->DeviceToLogicalYRel(y
); }
721 wxCoord
LogicalToDeviceX(wxCoord x
) const
722 { return m_pimpl
->LogicalToDeviceX(x
); }
723 wxCoord
LogicalToDeviceY(wxCoord y
) const
724 { return m_pimpl
->LogicalToDeviceY(y
); }
725 wxCoord
LogicalToDeviceXRel(wxCoord x
) const
726 { return m_pimpl
->LogicalToDeviceXRel(x
); }
727 wxCoord
LogicalToDeviceYRel(wxCoord y
) const
728 { return m_pimpl
->LogicalToDeviceYRel(y
); }
730 void SetMapMode(int mode
)
731 { m_pimpl
->SetMapMode(mode
); }
732 int GetMapMode() const
733 { return m_pimpl
->GetMapMode(); }
735 void SetUserScale(double x
, double y
)
736 { m_pimpl
->SetUserScale(x
,y
); }
737 void GetUserScale(double *x
, double *y
) const
738 { m_pimpl
->GetUserScale( x
, y
); }
740 void SetLogicalScale(double x
, double y
)
741 { m_pimpl
->SetLogicalScale( x
, y
); }
742 void GetLogicalScale(double *x
, double *y
)
743 { m_pimpl
->GetLogicalScale( x
, y
); }
745 void SetLogicalOrigin(wxCoord x
, wxCoord y
)
746 { m_pimpl
->SetLogicalOrigin(x
,y
); }
747 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
748 { m_pimpl
->DoGetLogicalOrigin(x
, y
); }
749 wxPoint
GetLogicalOrigin() const
750 { wxCoord x
, y
; m_pimpl
->DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
752 void SetDeviceOrigin(wxCoord x
, wxCoord y
)
753 { m_pimpl
->SetDeviceOrigin( x
, y
); }
754 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
755 { m_pimpl
->DoGetDeviceOrigin(x
, y
); }
756 wxPoint
GetDeviceOrigin() const
757 { wxCoord x
, y
; m_pimpl
->DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
759 void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
)
760 { m_pimpl
->SetAxisOrientation(xLeftRight
, yBottomUp
); }
763 void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
)
764 { m_pimpl
->SetDeviceLocalOrigin( x
, y
); }
767 // draw generic object
769 void DrawObject(wxDrawObject
* drawobject
)
771 drawobject
->Draw(*this);
772 CalcBoundingBox(drawobject
->MinX(),drawobject
->MinY());
773 CalcBoundingBox(drawobject
->MaxX(),drawobject
->MaxY());
776 // -----------------------------------------------
777 // the actual drawing API
779 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
780 int style
= wxFLOOD_SURFACE
)
781 { return m_pimpl
->DoFloodFill(x
, y
, col
, style
); }
782 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
783 int style
= wxFLOOD_SURFACE
)
784 { return m_pimpl
->DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
786 // fill the area specified by rect with a radial gradient, starting from
787 // initialColour in the centre of the cercle and fading to destColour.
788 void GradientFillConcentric(const wxRect
& rect
,
789 const wxColour
& initialColour
,
790 const wxColour
& destColour
)
791 { m_pimpl
->DoGradientFillConcentric( rect
, initialColour
, destColour
,
792 wxPoint(rect
.GetWidth() / 2,
793 rect
.GetHeight() / 2)); }
795 void GradientFillConcentric(const wxRect
& rect
,
796 const wxColour
& initialColour
,
797 const wxColour
& destColour
,
798 const wxPoint
& circleCenter
)
799 { m_pimpl
->DoGradientFillConcentric(rect
, initialColour
, destColour
, circleCenter
); }
801 // fill the area specified by rect with a linear gradient
802 void GradientFillLinear(const wxRect
& rect
,
803 const wxColour
& initialColour
,
804 const wxColour
& destColour
,
805 wxDirection nDirection
= wxEAST
)
806 { m_pimpl
->DoGradientFillLinear(rect
, initialColour
, destColour
, nDirection
); }
808 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
809 { return m_pimpl
->DoGetPixel(x
, y
, col
); }
810 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
811 { return m_pimpl
->DoGetPixel(pt
.x
, pt
.y
, col
); }
813 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
814 { m_pimpl
->DoDrawLine(x1
, y1
, x2
, y2
); }
815 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
816 { m_pimpl
->DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
818 void CrossHair(wxCoord x
, wxCoord y
)
819 { m_pimpl
->DoCrossHair(x
, y
); }
820 void CrossHair(const wxPoint
& pt
)
821 { m_pimpl
->DoCrossHair(pt
.x
, pt
.y
); }
823 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
824 wxCoord xc
, wxCoord yc
)
825 { m_pimpl
->DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
826 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
827 { m_pimpl
->DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
829 void DrawCheckMark(wxCoord x
, wxCoord y
,
830 wxCoord width
, wxCoord height
)
831 { m_pimpl
->DoDrawCheckMark(x
, y
, width
, height
); }
832 void DrawCheckMark(const wxRect
& rect
)
833 { m_pimpl
->DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
835 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
836 double sa
, double ea
)
837 { m_pimpl
->DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
838 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
839 double sa
, double ea
)
840 { m_pimpl
->DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
842 void DrawPoint(wxCoord x
, wxCoord y
)
843 { m_pimpl
->DoDrawPoint(x
, y
); }
844 void DrawPoint(const wxPoint
& pt
)
845 { m_pimpl
->DoDrawPoint(pt
.x
, pt
.y
); }
847 void DrawLines(int n
, wxPoint points
[],
848 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
849 { m_pimpl
->DoDrawLines(n
, points
, xoffset
, yoffset
); }
852 // needs to be removed
853 void DrawLines(const wxPointList
*list
,
854 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
857 void DrawPolygon(int n
, wxPoint points
[],
858 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
859 int fillStyle
= wxODDEVEN_RULE
)
860 { m_pimpl
->DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
863 // needs to be removed
864 void DrawPolygon(const wxPointList
*list
,
865 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
866 int fillStyle
= wxODDEVEN_RULE
)
867 { m_pimpl
->DrawPolygon( list
, xoffset
, yoffset
, fillStyle
); }
870 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
871 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
872 int fillStyle
= wxODDEVEN_RULE
)
873 { m_pimpl
->DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
875 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
876 { m_pimpl
->DoDrawRectangle(x
, y
, width
, height
); }
877 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
878 { m_pimpl
->DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
879 void DrawRectangle(const wxRect
& rect
)
880 { m_pimpl
->DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
882 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
884 { m_pimpl
->DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
885 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
887 { m_pimpl
->DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
888 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
889 { m_pimpl
->DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
891 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
892 { m_pimpl
->DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
893 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
894 { m_pimpl
->DoDrawEllipse(pt
.x
- radius
, pt
.y
- radius
, 2*radius
, 2*radius
); }
896 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
897 { m_pimpl
->DoDrawEllipse(x
, y
, width
, height
); }
898 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
899 { m_pimpl
->DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
900 void DrawEllipse(const wxRect
& rect
)
901 { m_pimpl
->DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
903 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
904 { m_pimpl
->DoDrawIcon(icon
, x
, y
); }
905 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
906 { m_pimpl
->DoDrawIcon(icon
, pt
.x
, pt
.y
); }
908 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
909 bool useMask
= false)
910 { m_pimpl
->DoDrawBitmap(bmp
, x
, y
, useMask
); }
911 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
912 bool useMask
= false)
913 { m_pimpl
->DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
915 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
916 { m_pimpl
->DoDrawText(text
, x
, y
); }
917 void DrawText(const wxString
& text
, const wxPoint
& pt
)
918 { m_pimpl
->DoDrawText(text
, pt
.x
, pt
.y
); }
920 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
921 { m_pimpl
->DoDrawRotatedText(text
, x
, y
, angle
); }
922 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
923 { m_pimpl
->DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
925 // this version puts both optional bitmap and the text into the given
926 // rectangle and aligns is as specified by alignment parameter; it also
927 // will emphasize the character with the given index if it is != -1 and
928 // return the bounding rectangle if required
929 void DrawLabel(const wxString
& text
,
930 const wxBitmap
& image
,
932 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
934 wxRect
*rectBounding
= NULL
);
936 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
937 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
939 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
941 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
942 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
943 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
945 return m_pimpl
->DoBlit(xdest
, ydest
, width
, height
,
946 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
948 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
949 wxDC
*source
, const wxPoint
& srcPt
,
950 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcPtMask
= wxDefaultPosition
)
952 return m_pimpl
->DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
953 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
956 bool StretchBlit(wxCoord dstX
, wxCoord dstY
,
957 wxCoord dstWidth
, wxCoord dstHeight
,
959 wxCoord srcX
, wxCoord srcY
,
960 wxCoord srcWidth
, wxCoord srcHeight
,
961 int rop
= wxCOPY
, bool useMask
= false,
962 wxCoord srcMaskX
= wxDefaultCoord
, wxCoord srcMaskY
= wxDefaultCoord
)
964 return m_pimpl
->DoStretchBlit(dstX
, dstY
, dstWidth
, dstHeight
,
965 source
, srcX
, srcY
, srcWidth
, srcHeight
, rop
, useMask
, srcMaskX
, srcMaskY
);
967 bool StretchBlit(const wxPoint
& dstPt
, const wxSize
& dstSize
,
968 wxDC
*source
, const wxPoint
& srcPt
, const wxSize
& srcSize
,
969 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcMaskPt
= wxDefaultPosition
)
971 return m_pimpl
->DoStretchBlit(dstPt
.x
, dstPt
.y
, dstSize
.x
, dstSize
.y
,
972 source
, srcPt
.x
, srcPt
.y
, srcSize
.x
, srcSize
.y
, rop
, useMask
, srcMaskPt
.x
, srcMaskPt
.y
);
975 wxBitmap
GetAsBitmap(const wxRect
*subrect
= (const wxRect
*) NULL
) const
977 return m_pimpl
->DoGetAsBitmap(subrect
);
981 void DrawSpline(wxCoord x1
, wxCoord y1
,
982 wxCoord x2
, wxCoord y2
,
983 wxCoord x3
, wxCoord y3
)
984 { m_pimpl
->DoDrawSpline(x1
,y1
,x2
,y2
,x3
,y3
); }
985 void DrawSpline(int n
, wxPoint points
[])
986 { m_pimpl
->DoDrawSpline(n
,points
); }
987 void DrawSpline(const wxPointList
*points
)
988 { m_pimpl
->DoDrawSpline(points
); }
989 #endif // wxUSE_SPLINES
992 #if WXWIN_COMPATIBILITY_2_8
993 // for compatibility with the old code when wxCoord was long everywhere
994 wxDEPRECATED( void GetTextExtent(const wxString
& string
,
996 long *descent
= NULL
,
997 long *externalLeading
= NULL
,
998 const wxFont
*theFont
= NULL
) const );
999 wxDEPRECATED( void GetLogicalOrigin(long *x
, long *y
) const );
1000 wxDEPRECATED( void GetDeviceOrigin(long *x
, long *y
) const );
1001 wxDEPRECATED( void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const );
1002 #endif // WXWIN_COMPATIBILITY_2_8
1009 DECLARE_ABSTRACT_CLASS(wxImplDC
)
1013 //-----------------------------------------------------------------------------
1015 //-----------------------------------------------------------------------------
1017 class WXDLLIMPEXP_CORE wxWindowDC
: public wxDC
1021 wxWindowDC( wxWindow
*win
);
1024 DECLARE_DYNAMIC_CLASS(wxWindowDC
)
1027 //-----------------------------------------------------------------------------
1029 //-----------------------------------------------------------------------------
1031 class WXDLLIMPEXP_CORE wxClientDC
: public wxDC
1035 wxClientDC( wxWindow
*win
);
1038 DECLARE_DYNAMIC_CLASS(wxClientDC
)
1041 //-----------------------------------------------------------------------------
1043 //-----------------------------------------------------------------------------
1045 class WXDLLIMPEXP_CORE wxPaintDC
: public wxDC
1049 wxPaintDC( wxWindow
*win
);
1052 DECLARE_DYNAMIC_CLASS(wxPaintDC
)
1055 #else // wxUSE_NEW_DC
1058 class WXDLLIMPEXP_FWD_CORE wxDC
;
1060 // ---------------------------------------------------------------------------
1062 // ---------------------------------------------------------------------------
1064 // ---------------------------------------------------------------------------
1065 // wxDC is the device context - object on which any drawing is done
1066 // ---------------------------------------------------------------------------
1068 class WXDLLEXPORT wxDCBase
: public wxObject
1072 virtual ~wxDCBase();
1074 // graphic primitives
1075 // ------------------
1077 virtual void DrawObject(wxDrawObject
* drawobject
)
1079 drawobject
->Draw(*this);
1080 CalcBoundingBox(drawobject
->MinX(),drawobject
->MinY());
1081 CalcBoundingBox(drawobject
->MaxX(),drawobject
->MaxY());
1084 wxDC
*GetOwner() const { return (wxDC
*) this; }
1086 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
1087 int style
= wxFLOOD_SURFACE
)
1088 { return DoFloodFill(x
, y
, col
, style
); }
1089 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
1090 int style
= wxFLOOD_SURFACE
)
1091 { return DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
1093 // fill the area specified by rect with a radial gradient, starting from
1094 // initialColour in the centre of the cercle and fading to destColour.
1095 void GradientFillConcentric(const wxRect
& rect
,
1096 const wxColour
& initialColour
,
1097 const wxColour
& destColour
)
1098 { GradientFillConcentric(rect
, initialColour
, destColour
,
1099 wxPoint(rect
.GetWidth() / 2,
1100 rect
.GetHeight() / 2)); }
1102 void GradientFillConcentric(const wxRect
& rect
,
1103 const wxColour
& initialColour
,
1104 const wxColour
& destColour
,
1105 const wxPoint
& circleCenter
)
1106 { DoGradientFillConcentric(rect
, initialColour
, destColour
, circleCenter
); }
1108 // fill the area specified by rect with a linear gradient
1109 void GradientFillLinear(const wxRect
& rect
,
1110 const wxColour
& initialColour
,
1111 const wxColour
& destColour
,
1112 wxDirection nDirection
= wxEAST
)
1113 { DoGradientFillLinear(rect
, initialColour
, destColour
, nDirection
); }
1115 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
1116 { return DoGetPixel(x
, y
, col
); }
1117 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
1118 { return DoGetPixel(pt
.x
, pt
.y
, col
); }
1120 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
1121 { DoDrawLine(x1
, y1
, x2
, y2
); }
1122 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
1123 { DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
1125 void CrossHair(wxCoord x
, wxCoord y
)
1126 { DoCrossHair(x
, y
); }
1127 void CrossHair(const wxPoint
& pt
)
1128 { DoCrossHair(pt
.x
, pt
.y
); }
1130 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
1131 wxCoord xc
, wxCoord yc
)
1132 { DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
1133 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
1134 { DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
1136 void DrawCheckMark(wxCoord x
, wxCoord y
,
1137 wxCoord width
, wxCoord height
)
1138 { DoDrawCheckMark(x
, y
, width
, height
); }
1139 void DrawCheckMark(const wxRect
& rect
)
1140 { DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1142 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
1143 double sa
, double ea
)
1144 { DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
1145 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
1146 double sa
, double ea
)
1147 { DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
1149 void DrawPoint(wxCoord x
, wxCoord y
)
1150 { DoDrawPoint(x
, y
); }
1151 void DrawPoint(const wxPoint
& pt
)
1152 { DoDrawPoint(pt
.x
, pt
.y
); }
1154 void DrawLines(int n
, wxPoint points
[],
1155 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
1156 { DoDrawLines(n
, points
, xoffset
, yoffset
); }
1157 void DrawLines(const wxPointList
*list
,
1158 wxCoord xoffset
= 0, wxCoord yoffset
= 0);
1160 #if WXWIN_COMPATIBILITY_2_8
1161 wxDEPRECATED( void DrawLines(const wxList
*list
,
1162 wxCoord xoffset
= 0, wxCoord yoffset
= 0) );
1163 #endif // WXWIN_COMPATIBILITY_2_8
1166 void DrawPolygon(int n
, wxPoint points
[],
1167 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1168 int fillStyle
= wxODDEVEN_RULE
)
1169 { DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
1171 void DrawPolygon(const wxPointList
*list
,
1172 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1173 int fillStyle
= wxODDEVEN_RULE
);
1175 #if WXWIN_COMPATIBILITY_2_8
1176 wxDEPRECATED( void DrawPolygon(const wxList
*list
,
1177 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1178 int fillStyle
= wxODDEVEN_RULE
) );
1179 #endif // WXWIN_COMPATIBILITY_2_8
1181 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
1182 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1183 int fillStyle
= wxODDEVEN_RULE
)
1184 { DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
1186 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1187 { DoDrawRectangle(x
, y
, width
, height
); }
1188 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
1189 { DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1190 void DrawRectangle(const wxRect
& rect
)
1191 { DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1193 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
1195 { DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
1196 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
1198 { DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
1199 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
1200 { DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
1202 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
1203 { DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
1204 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
1205 { DrawCircle(pt
.x
, pt
.y
, radius
); }
1207 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1208 { DoDrawEllipse(x
, y
, width
, height
); }
1209 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
1210 { DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1211 void DrawEllipse(const wxRect
& rect
)
1212 { DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1214 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
1215 { DoDrawIcon(icon
, x
, y
); }
1216 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
1217 { DoDrawIcon(icon
, pt
.x
, pt
.y
); }
1219 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
1220 bool useMask
= false)
1221 { DoDrawBitmap(bmp
, x
, y
, useMask
); }
1222 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
1223 bool useMask
= false)
1224 { DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
1226 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
1227 { DoDrawText(text
, x
, y
); }
1228 void DrawText(const wxString
& text
, const wxPoint
& pt
)
1229 { DoDrawText(text
, pt
.x
, pt
.y
); }
1231 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
1232 { DoDrawRotatedText(text
, x
, y
, angle
); }
1233 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
1234 { DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
1236 // this version puts both optional bitmap and the text into the given
1237 // rectangle and aligns is as specified by alignment parameter; it also
1238 // will emphasize the character with the given index if it is != -1 and
1239 // return the bounding rectangle if required
1240 virtual void DrawLabel(const wxString
& text
,
1241 const wxBitmap
& image
,
1243 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1244 int indexAccel
= -1,
1245 wxRect
*rectBounding
= NULL
);
1247 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
1248 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1249 int indexAccel
= -1)
1250 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
1252 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1253 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
1254 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
1256 return DoBlit(xdest
, ydest
, width
, height
,
1257 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
1259 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
1260 wxDC
*source
, const wxPoint
& srcPt
,
1261 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcPtMask
= wxDefaultPosition
)
1263 return DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
1264 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
1267 bool StretchBlit(wxCoord dstX
, wxCoord dstY
,
1268 wxCoord dstWidth
, wxCoord dstHeight
,
1270 wxCoord srcX
, wxCoord srcY
,
1271 wxCoord srcWidth
, wxCoord srcHeight
,
1272 int rop
= wxCOPY
, bool useMask
= false,
1273 wxCoord srcMaskX
= wxDefaultCoord
, wxCoord srcMaskY
= wxDefaultCoord
)
1275 return DoStretchBlit(dstX
, dstY
, dstWidth
, dstHeight
,
1276 source
, srcX
, srcY
, srcWidth
, srcHeight
, rop
, useMask
, srcMaskX
, srcMaskY
);
1278 bool StretchBlit(const wxPoint
& dstPt
, const wxSize
& dstSize
,
1279 wxDC
*source
, const wxPoint
& srcPt
, const wxSize
& srcSize
,
1280 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcMaskPt
= wxDefaultPosition
)
1282 return DoStretchBlit(dstPt
.x
, dstPt
.y
, dstSize
.x
, dstSize
.y
,
1283 source
, srcPt
.x
, srcPt
.y
, srcSize
.x
, srcSize
.y
, rop
, useMask
, srcMaskPt
.x
, srcMaskPt
.y
);
1286 wxBitmap
GetAsBitmap(const wxRect
*subrect
= (const wxRect
*) NULL
) const
1288 return DoGetAsBitmap(subrect
);
1292 void DrawSpline(wxCoord x1
, wxCoord y1
,
1293 wxCoord x2
, wxCoord y2
,
1294 wxCoord x3
, wxCoord y3
);
1295 void DrawSpline(int n
, wxPoint points
[]);
1297 void DrawSpline(const wxPointList
*points
) { DoDrawSpline(points
); }
1299 #if WXWIN_COMPATIBILITY_2_8
1300 wxDEPRECATED( void DrawSpline(const wxList
*points
) );
1301 #endif // WXWIN_COMPATIBILITY_2_8
1303 #endif // wxUSE_SPLINES
1305 // Eventually we will have wxUSE_GENERIC_DRAWELLIPSE
1307 //! Generic method to draw ellipses, circles and arcs with current pen and brush.
1308 /*! \param x Upper left corner of bounding box.
1309 * \param y Upper left corner of bounding box.
1310 * \param w Width of bounding box.
1311 * \param h Height of bounding box.
1312 * \param sa Starting angle of arc
1313 * (counterclockwise, start at 3 o'clock, 360 is full circle).
1314 * \param ea Ending angle of arc.
1315 * \param angle Rotation angle, the Arc will be rotated after
1316 * calculating begin and end.
1318 void DrawEllipticArcRot( wxCoord x
, wxCoord y
,
1319 wxCoord width
, wxCoord height
,
1320 double sa
= 0, double ea
= 0, double angle
= 0 )
1321 { DoDrawEllipticArcRot( x
, y
, width
, height
, sa
, ea
, angle
); }
1323 void DrawEllipticArcRot( const wxPoint
& pt
,
1325 double sa
= 0, double ea
= 0, double angle
= 0 )
1326 { DoDrawEllipticArcRot( pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
, angle
); }
1328 void DrawEllipticArcRot( const wxRect
& rect
,
1329 double sa
= 0, double ea
= 0, double angle
= 0 )
1330 { DoDrawEllipticArcRot( rect
.x
, rect
.y
, rect
.width
, rect
.height
, sa
, ea
, angle
); }
1332 virtual void DoDrawEllipticArcRot( wxCoord x
, wxCoord y
,
1333 wxCoord w
, wxCoord h
,
1334 double sa
= 0, double ea
= 0, double angle
= 0 );
1336 //! Rotates points around center.
1337 /*! This is a quite straight method, it calculates in pixels
1338 * and so it produces rounding errors.
1339 * \param points The points inside will be rotated.
1340 * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle).
1341 * \param center Center of rotation.
1343 void Rotate( wxPointList
* points
, double angle
, wxPoint center
= wxPoint(0,0) );
1345 // used by DrawEllipticArcRot
1346 // Careful: wxList gets filled with points you have to delete later.
1347 void CalculateEllipticPoints( wxPointList
* points
,
1348 wxCoord xStart
, wxCoord yStart
,
1349 wxCoord w
, wxCoord h
,
1350 double sa
, double ea
);
1353 // global DC operations
1354 // --------------------
1356 virtual void Clear() = 0;
1358 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
1359 virtual void EndDoc() { }
1361 virtual void StartPage() { }
1362 virtual void EndPage() { }
1364 #if WXWIN_COMPATIBILITY_2_6
1365 wxDEPRECATED( void BeginDrawing() );
1366 wxDEPRECATED( void EndDrawing() );
1367 #endif // WXWIN_COMPATIBILITY_2_6
1370 // set objects to use for drawing
1371 // ------------------------------
1373 virtual void SetFont(const wxFont
& font
) = 0;
1374 virtual void SetPen(const wxPen
& pen
) = 0;
1375 virtual void SetBrush(const wxBrush
& brush
) = 0;
1376 virtual void SetBackground(const wxBrush
& brush
) = 0;
1377 virtual void SetBackgroundMode(int mode
) = 0;
1379 virtual void SetPalette(const wxPalette
& palette
) = 0;
1380 #endif // wxUSE_PALETTE
1385 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1386 { DoSetClippingRegion(x
, y
, width
, height
); }
1387 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
1388 { DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1389 void SetClippingRegion(const wxRect
& rect
)
1390 { DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1391 void SetClippingRegion(const wxRegion
& region
)
1392 { DoSetClippingRegionAsRegion(region
); }
1394 virtual void DestroyClippingRegion() { ResetClipping(); }
1396 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
1397 { DoGetClippingBox(x
, y
, w
, h
); }
1398 void GetClippingBox(wxRect
& rect
) const
1400 DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
);
1406 virtual wxCoord
GetCharHeight() const = 0;
1407 virtual wxCoord
GetCharWidth() const = 0;
1409 // only works for single line strings
1410 void GetTextExtent(const wxString
& string
,
1411 wxCoord
*x
, wxCoord
*y
,
1412 wxCoord
*descent
= NULL
,
1413 wxCoord
*externalLeading
= NULL
,
1414 const wxFont
*theFont
= NULL
) const
1415 { DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
1417 wxSize
GetTextExtent(const wxString
& string
) const
1420 DoGetTextExtent(string
, &w
, &h
);
1421 return wxSize(w
, h
);
1424 // works for single as well as multi-line strings
1425 virtual void GetMultiLineTextExtent(const wxString
& string
,
1428 wxCoord
*heightLine
= NULL
,
1429 const wxFont
*font
= NULL
) const;
1431 wxSize
GetMultiLineTextExtent(const wxString
& string
) const
1434 GetMultiLineTextExtent(string
, &w
, &h
);
1435 return wxSize(w
, h
);
1438 // Measure cumulative width of text after each character
1439 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
1440 { return DoGetPartialTextExtents(text
, widths
); }
1443 // size and resolution
1444 // -------------------
1447 void GetSize(int *width
, int *height
) const
1448 { DoGetSize(width
, height
); }
1449 wxSize
GetSize() const
1454 return wxSize(w
, h
);
1458 void GetSizeMM(int* width
, int* height
) const
1459 { DoGetSizeMM(width
, height
); }
1460 wxSize
GetSizeMM() const
1463 DoGetSizeMM(&w
, &h
);
1465 return wxSize(w
, h
);
1468 // query DC capabilities
1469 // ---------------------
1471 virtual bool CanDrawBitmap() const = 0;
1472 virtual bool CanGetTextExtent() const = 0;
1475 virtual int GetDepth() const = 0;
1477 // Resolution in Pixels per inch
1478 virtual wxSize
GetPPI() const = 0;
1480 virtual bool Ok() const { return IsOk(); }
1481 virtual bool IsOk() const { return m_ok
; }
1483 // accessors and setters
1484 // ---------------------
1486 virtual int GetBackgroundMode() const { return m_backgroundMode
; }
1487 virtual const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
1488 virtual const wxBrush
& GetBrush() const { return m_brush
; }
1489 virtual const wxFont
& GetFont() const { return m_font
; }
1490 virtual const wxPen
& GetPen() const { return m_pen
; }
1492 virtual const wxColour
& GetTextForeground() const { return m_textForegroundColour
; }
1493 virtual const wxColour
& GetTextBackground() const { return m_textBackgroundColour
; }
1494 virtual void SetTextForeground(const wxColour
& colour
)
1495 { m_textForegroundColour
= colour
; }
1496 virtual void SetTextBackground(const wxColour
& colour
)
1497 { m_textBackgroundColour
= colour
; }
1500 // coordinates conversions and transforms
1501 // --------------------------------------
1503 virtual wxCoord
DeviceToLogicalX(wxCoord x
) const;
1504 virtual wxCoord
DeviceToLogicalY(wxCoord y
) const;
1505 virtual wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
1506 virtual wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
1507 virtual wxCoord
LogicalToDeviceX(wxCoord x
) const;
1508 virtual wxCoord
LogicalToDeviceY(wxCoord y
) const;
1509 virtual wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
1510 virtual wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
1512 virtual void SetMapMode(int mode
);
1513 virtual int GetMapMode() const { return m_mappingMode
; }
1515 virtual void SetUserScale(double x
, double y
);
1516 virtual void GetUserScale(double *x
, double *y
) const
1518 if ( x
) *x
= m_userScaleX
;
1519 if ( y
) *y
= m_userScaleY
;
1522 virtual void SetLogicalScale(double x
, double y
);
1523 virtual void GetLogicalScale(double *x
, double *y
)
1525 if ( x
) *x
= m_logicalScaleX
;
1526 if ( y
) *y
= m_logicalScaleY
;
1529 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
1530 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
1531 { DoGetLogicalOrigin(x
, y
); }
1532 wxPoint
GetLogicalOrigin() const
1533 { wxCoord x
, y
; DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
1535 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
1536 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
1537 { DoGetDeviceOrigin(x
, y
); }
1538 wxPoint
GetDeviceOrigin() const
1539 { wxCoord x
, y
; DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
1541 virtual void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
);
1543 virtual void ComputeScaleAndOrigin();
1545 // this needs to overidden if the axis is inverted (such
1546 // as when using Postscript, where 0,0 is the lower left
1547 // corner, not the upper left).
1548 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
1550 // logical functions
1551 // ---------------------------
1553 virtual int GetLogicalFunction() const { return m_logicalFunction
; }
1554 virtual void SetLogicalFunction(int function
) = 0;
1559 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
1561 if ( m_isBBoxValid
)
1563 if ( x
< m_minX
) m_minX
= x
;
1564 if ( y
< m_minY
) m_minY
= y
;
1565 if ( x
> m_maxX
) m_maxX
= x
;
1566 if ( y
> m_maxY
) m_maxY
= y
;
1570 m_isBBoxValid
= true;
1579 void ResetBoundingBox()
1581 m_isBBoxValid
= false;
1583 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
1586 // Get the final bounding box of the PostScript or Metafile picture.
1587 wxCoord
MinX() const { return m_minX
; }
1588 wxCoord
MaxX() const { return m_maxX
; }
1589 wxCoord
MinY() const { return m_minY
; }
1590 wxCoord
MaxY() const { return m_maxY
; }
1592 // misc old functions
1593 // ------------------
1595 #if WXWIN_COMPATIBILITY_2_8
1596 // for compatibility with the old code when wxCoord was long everywhere
1597 wxDEPRECATED( void GetTextExtent(const wxString
& string
,
1599 long *descent
= NULL
,
1600 long *externalLeading
= NULL
,
1601 const wxFont
*theFont
= NULL
) const );
1602 wxDEPRECATED( void GetLogicalOrigin(long *x
, long *y
) const );
1603 wxDEPRECATED( void GetDeviceOrigin(long *x
, long *y
) const );
1604 wxDEPRECATED( void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const );
1605 #endif // WXWIN_COMPATIBILITY_2_8
1607 // RTL related functions
1608 // ---------------------
1610 // get or change the layout direction (LTR or RTL) for this dc,
1611 // wxLayout_Default is returned if layout direction is not supported
1612 virtual wxLayoutDirection
GetLayoutDirection() const
1613 { return wxLayout_Default
; }
1614 virtual void SetLayoutDirection(wxLayoutDirection
WXUNUSED(dir
))
1618 // the pure virtual functions which should be implemented by wxDC
1619 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
1620 int style
= wxFLOOD_SURFACE
) = 0;
1622 virtual void DoGradientFillLinear(const wxRect
& rect
,
1623 const wxColour
& initialColour
,
1624 const wxColour
& destColour
,
1625 wxDirection nDirection
= wxEAST
);
1627 virtual void DoGradientFillConcentric(const wxRect
& rect
,
1628 const wxColour
& initialColour
,
1629 const wxColour
& destColour
,
1630 const wxPoint
& circleCenter
);
1632 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
1634 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
1635 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
1637 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
1638 wxCoord x2
, wxCoord y2
,
1639 wxCoord xc
, wxCoord yc
) = 0;
1640 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
1641 wxCoord width
, wxCoord height
);
1642 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
1643 double sa
, double ea
) = 0;
1645 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
1646 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
1647 wxCoord width
, wxCoord height
,
1649 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
1650 wxCoord width
, wxCoord height
) = 0;
1652 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
1654 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
1655 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
1656 bool useMask
= false) = 0;
1658 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
1659 virtual void DoDrawRotatedText(const wxString
& text
,
1660 wxCoord x
, wxCoord y
, double angle
) = 0;
1662 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
1663 wxCoord width
, wxCoord height
,
1665 wxCoord xsrc
, wxCoord ysrc
,
1667 bool useMask
= false,
1668 wxCoord xsrcMask
= wxDefaultCoord
,
1669 wxCoord ysrcMask
= wxDefaultCoord
) = 0;
1671 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
1672 wxCoord dstWidth
, wxCoord dstHeight
,
1674 wxCoord xsrc
, wxCoord ysrc
,
1675 wxCoord srcWidth
, wxCoord srcHeight
,
1677 bool useMask
= false,
1678 wxCoord xsrcMask
= wxDefaultCoord
,
1679 wxCoord ysrcMask
= wxDefaultCoord
);
1681 virtual wxBitmap
DoGetAsBitmap(const wxRect
*WXUNUSED(subrect
)) const
1682 { return wxNullBitmap
; }
1684 virtual void DoGetSize(int *width
, int *height
) const = 0;
1685 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
1687 virtual void DoDrawLines(int n
, wxPoint points
[],
1688 wxCoord xoffset
, wxCoord yoffset
) = 0;
1689 virtual void DoDrawPolygon(int n
, wxPoint points
[],
1690 wxCoord xoffset
, wxCoord yoffset
,
1691 int fillStyle
= wxODDEVEN_RULE
) = 0;
1692 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
1693 wxCoord xoffset
, wxCoord yoffset
,
1696 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
) = 0;
1697 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
1698 wxCoord width
, wxCoord height
) = 0;
1700 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
1701 wxCoord
*w
, wxCoord
*h
) const
1708 *w
= m_clipX2
- m_clipX1
;
1710 *h
= m_clipY2
- m_clipY1
;
1713 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
1715 if ( x
) *x
= m_logicalOriginX
;
1716 if ( y
) *y
= m_logicalOriginY
;
1719 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
1721 if ( x
) *x
= m_deviceOriginX
;
1722 if ( y
) *y
= m_deviceOriginY
;
1725 virtual void DoGetTextExtent(const wxString
& string
,
1726 wxCoord
*x
, wxCoord
*y
,
1727 wxCoord
*descent
= NULL
,
1728 wxCoord
*externalLeading
= NULL
,
1729 const wxFont
*theFont
= NULL
) const = 0;
1731 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
1734 virtual void DoDrawSpline(const wxPointList
*points
);
1738 // unset clipping variables (after clipping region was destroyed)
1739 void ResetClipping()
1743 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
1750 bool m_isInteractive
:1;
1751 bool m_isBBoxValid
:1;
1753 // coordinate system variables
1755 // TODO short descriptions of what exactly they are would be nice...
1757 wxCoord m_logicalOriginX
, m_logicalOriginY
;
1758 wxCoord m_deviceOriginX
, m_deviceOriginY
; // Usually 0,0, can be change by user
1760 wxCoord m_deviceLocalOriginX
, m_deviceLocalOriginY
; // non-zero if native top-left corner
1761 // is not at 0,0. This was the case under
1762 // Mac's GrafPorts (coordinate system
1763 // used toplevel window's origin) and
1764 // e.g. for Postscript, where the native
1765 // origin in the bottom left corner.
1766 double m_logicalScaleX
, m_logicalScaleY
;
1767 double m_userScaleX
, m_userScaleY
;
1768 double m_scaleX
, m_scaleY
; // calculated from logical scale and user scale
1770 // Used by SetAxisOrientation() to invert the axes
1771 int m_signX
, m_signY
;
1773 // what is a mm on a screen you don't know the size of?
1774 double m_mm_to_pix_x
,
1777 // bounding and clipping boxes
1778 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
1779 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
1781 int m_logicalFunction
;
1782 int m_backgroundMode
;
1788 wxBrush m_backgroundBrush
;
1789 wxColour m_textForegroundColour
;
1790 wxColour m_textBackgroundColour
;
1794 wxPalette m_palette
;
1795 bool m_hasCustomPalette
;
1796 #endif // wxUSE_PALETTE
1799 DECLARE_NO_COPY_CLASS(wxDCBase
)
1800 DECLARE_ABSTRACT_CLASS(wxDCBase
)
1803 #endif // wxUSE_NEW_DC
1805 // ----------------------------------------------------------------------------
1806 // now include the declaration of wxDC class
1807 // ----------------------------------------------------------------------------
1809 #if defined(__WXPALMOS__)
1810 #include "wx/palmos/dc.h"
1811 #elif defined(__WXMSW__)
1812 #include "wx/msw/dc.h"
1813 #elif defined(__WXMOTIF__)
1814 #include "wx/motif/dc.h"
1815 #elif defined(__WXGTK20__)
1816 #include "wx/gtk/dc.h"
1817 #elif defined(__WXGTK__)
1818 #include "wx/gtk1/dc.h"
1819 #elif defined(__WXX11__)
1820 #include "wx/x11/dc.h"
1821 #elif defined(__WXMGL__)
1822 #include "wx/mgl/dc.h"
1823 #elif defined(__WXDFB__)
1824 #include "wx/dfb/dc.h"
1825 #elif defined(__WXMAC__)
1826 #include "wx/mac/dc.h"
1827 #elif defined(__WXCOCOA__)
1828 #include "wx/cocoa/dc.h"
1829 #elif defined(__WXPM__)
1830 #include "wx/os2/dc.h"
1833 #if wxUSE_GRAPHICS_CONTEXT
1834 #include "wx/dcgraph.h"
1837 // ----------------------------------------------------------------------------
1838 // helper class: you can use it to temporarily change the DC text colour and
1839 // restore it automatically when the object goes out of scope
1840 // ----------------------------------------------------------------------------
1842 class WXDLLEXPORT wxDCTextColourChanger
1845 wxDCTextColourChanger(wxDC
& dc
) : m_dc(dc
), m_colFgOld() { }
1847 wxDCTextColourChanger(wxDC
& dc
, const wxColour
& col
) : m_dc(dc
)
1852 ~wxDCTextColourChanger()
1854 if ( m_colFgOld
.Ok() )
1855 m_dc
.SetTextForeground(m_colFgOld
);
1858 void Set(const wxColour
& col
)
1860 if ( !m_colFgOld
.Ok() )
1861 m_colFgOld
= m_dc
.GetTextForeground();
1862 m_dc
.SetTextForeground(col
);
1868 wxColour m_colFgOld
;
1870 DECLARE_NO_COPY_CLASS(wxDCTextColourChanger
)
1873 // ----------------------------------------------------------------------------
1874 // helper class: you can use it to temporarily change the DC pen and
1875 // restore it automatically when the object goes out of scope
1876 // ----------------------------------------------------------------------------
1878 class WXDLLEXPORT wxDCPenChanger
1881 wxDCPenChanger(wxDC
& dc
, const wxPen
& pen
) : m_dc(dc
), m_penOld(dc
.GetPen())
1888 if ( m_penOld
.Ok() )
1889 m_dc
.SetPen(m_penOld
);
1897 DECLARE_NO_COPY_CLASS(wxDCPenChanger
)
1900 // ----------------------------------------------------------------------------
1901 // helper class: you can use it to temporarily change the DC brush and
1902 // restore it automatically when the object goes out of scope
1903 // ----------------------------------------------------------------------------
1905 class WXDLLEXPORT wxDCBrushChanger
1908 wxDCBrushChanger(wxDC
& dc
, const wxBrush
& brush
) : m_dc(dc
), m_brushOld(dc
.GetBrush())
1910 m_dc
.SetBrush(brush
);
1915 if ( m_brushOld
.Ok() )
1916 m_dc
.SetBrush(m_brushOld
);
1924 DECLARE_NO_COPY_CLASS(wxDCBrushChanger
)
1927 // ----------------------------------------------------------------------------
1928 // another small helper class: sets the clipping region in its ctor and
1929 // destroys it in the dtor
1930 // ----------------------------------------------------------------------------
1932 class WXDLLEXPORT wxDCClipper
1935 wxDCClipper(wxDC
& dc
, const wxRegion
& r
) : m_dc(dc
)
1936 { dc
.SetClippingRegion(r
); }
1937 wxDCClipper(wxDC
& dc
, const wxRect
& r
) : m_dc(dc
)
1938 { dc
.SetClippingRegion(r
.x
, r
.y
, r
.width
, r
.height
); }
1939 wxDCClipper(wxDC
& dc
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) : m_dc(dc
)
1940 { dc
.SetClippingRegion(x
, y
, w
, h
); }
1942 ~wxDCClipper() { m_dc
.DestroyClippingRegion(); }
1947 DECLARE_NO_COPY_CLASS(wxDCClipper
)
1950 #endif // _WX_DC_H_BASE_