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
;
45 class WXDLLIMPEXP_FWD_CORE wxDCBase
;
48 class WXDLLEXPORT wxDrawObject
53 : m_isBBoxValid(false)
54 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
57 virtual ~wxDrawObject() { }
60 virtual void Draw(wxDC
&) const { }
62 virtual void Draw(wxDCBase
&) const { }
65 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
69 if ( x
< m_minX
) m_minX
= x
;
70 if ( y
< m_minY
) m_minY
= y
;
71 if ( x
> m_maxX
) m_maxX
= x
;
72 if ( y
> m_maxY
) m_maxY
= y
;
85 void ResetBoundingBox()
87 m_isBBoxValid
= false;
89 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
92 // Get the final bounding box of the PostScript or Metafile picture.
94 wxCoord
MinX() const { return m_minX
; }
95 wxCoord
MaxX() const { return m_maxX
; }
96 wxCoord
MinY() const { return m_minY
; }
97 wxCoord
MaxY() const { return m_maxY
; }
99 //to define the type of object for derived objects
100 virtual int GetType()=0;
103 //for boundingbox calculation
104 bool m_isBBoxValid
:1;
105 //for boundingbox calculation
106 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
112 //-----------------------------------------------------------------------------
114 //-----------------------------------------------------------------------------
116 class WXDLLIMPEXP_FWD_CORE wxImplDC
;
118 class WXDLLIMPEXP_CORE wxDCFactory
122 virtual ~wxDCFactory() {}
124 virtual wxImplDC
* CreateWindowDC( wxWindowDC
*owner
) = 0;
125 virtual wxImplDC
* CreateWindowDC( wxWindowDC
*owner
, wxWindow
*window
) = 0;
126 virtual wxImplDC
* CreateClientDC( wxClientDC
*owner
) = 0;
127 virtual wxImplDC
* CreateClientDC( wxClientDC
*owner
, wxWindow
*window
) = 0;
128 virtual wxImplDC
* CreatePaintDC( wxPaintDC
*owner
) = 0;
129 virtual wxImplDC
* CreatePaintDC( wxPaintDC
*owner
, wxWindow
*window
) = 0;
130 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
) = 0;
131 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
, wxBitmap
&bitmap
) = 0;
132 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
, wxDC
*dc
) = 0;
133 virtual wxImplDC
* CreateScreenDC( wxScreenDC
*owner
) = 0;
135 static void SetDCFactory( wxDCFactory
*factory
);
136 static wxDCFactory
*GetFactory();
138 static wxDCFactory
*m_factory
;
141 //-----------------------------------------------------------------------------
143 //-----------------------------------------------------------------------------
145 class WXDLLIMPEXP_CORE wxNativeDCFactory
: public wxDCFactory
148 wxNativeDCFactory() {}
150 virtual wxImplDC
* CreateWindowDC( wxWindowDC
*owner
);
151 virtual wxImplDC
* CreateWindowDC( wxWindowDC
*owner
, wxWindow
*window
);
152 virtual wxImplDC
* CreateClientDC( wxClientDC
*owner
);
153 virtual wxImplDC
* CreateClientDC( wxClientDC
*owner
, wxWindow
*window
);
154 virtual wxImplDC
* CreatePaintDC( wxPaintDC
*owner
);
155 virtual wxImplDC
* CreatePaintDC( wxPaintDC
*owner
, wxWindow
*window
);
156 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
);
157 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
, wxBitmap
&bitmap
);
158 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
, wxDC
*dc
);
159 virtual wxImplDC
* CreateScreenDC( wxScreenDC
*owner
);
162 //-----------------------------------------------------------------------------
164 //-----------------------------------------------------------------------------
166 class WXDLLIMPEXP_CORE wxImplDC
: public wxObject
169 wxImplDC( wxDC
*owner
);
172 wxDC
*GetOwner() const { return m_owner
; }
174 virtual bool IsOk() const { return m_ok
; }
176 // query capabilities
178 virtual bool CanDrawBitmap() const = 0;
179 virtual bool CanGetTextExtent() const = 0;
181 // query dimension, colour deps, resolution
183 virtual void DoGetSize(int *width
, int *height
) const = 0;
184 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
186 virtual int GetDepth() const = 0;
187 virtual wxSize
GetPPI() const = 0;
189 // Right-To-Left (RTL) modes
191 virtual void SetLayoutDirection(wxLayoutDirection
WXUNUSED(dir
)) { }
192 virtual wxLayoutDirection
GetLayoutDirection() const { return wxLayout_Default
; }
196 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
197 virtual void EndDoc() { }
199 virtual void StartPage() { }
200 virtual void EndPage() { }
202 // flushing the content of this dc immediately eg onto screen
203 virtual void Flush() { }
207 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
211 if ( x
< m_minX
) m_minX
= x
;
212 if ( y
< m_minY
) m_minY
= y
;
213 if ( x
> m_maxX
) m_maxX
= x
;
214 if ( y
> m_maxY
) m_maxY
= y
;
218 m_isBBoxValid
= true;
226 void ResetBoundingBox()
228 m_isBBoxValid
= false;
230 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
233 wxCoord
MinX() const { return m_minX
; }
234 wxCoord
MaxX() const { return m_maxX
; }
235 wxCoord
MinY() const { return m_minY
; }
236 wxCoord
MaxY() const { return m_maxY
; }
238 // setters and getters
240 virtual void SetFont(const wxFont
& font
) = 0;
241 virtual const wxFont
& GetFont() const { return m_font
; }
243 virtual void SetPen(const wxPen
& pen
) = 0;
244 virtual const wxPen
& GetPen() const { return m_pen
; }
246 virtual void SetBrush(const wxBrush
& brush
) = 0;
247 virtual const wxBrush
& GetBrush() const { return m_brush
; }
249 virtual void SetBackground(const wxBrush
& brush
) = 0;
250 virtual const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
252 virtual void SetBackgroundMode(int mode
) = 0;
253 virtual int GetBackgroundMode() const { return m_backgroundMode
; }
255 virtual void SetTextForeground(const wxColour
& colour
)
256 { m_textForegroundColour
= colour
; }
257 virtual const wxColour
& GetTextForeground() const { return m_textForegroundColour
; }
259 virtual void SetTextBackground(const wxColour
& colour
)
260 { m_textBackgroundColour
= colour
; }
261 virtual const wxColour
& GetTextBackground() const { return m_textBackgroundColour
; }
264 virtual void SetPalette(const wxPalette
& palette
) = 0;
265 #endif // wxUSE_PALETTE
269 virtual void SetLogicalFunction(int function
) = 0;
270 virtual int GetLogicalFunction() const { return m_logicalFunction
; }
274 virtual wxCoord
GetCharHeight() const = 0;
275 virtual wxCoord
GetCharWidth() const = 0;
276 virtual void DoGetTextExtent(const wxString
& string
,
277 wxCoord
*x
, wxCoord
*y
,
278 wxCoord
*descent
= NULL
,
279 wxCoord
*externalLeading
= NULL
,
280 const wxFont
*theFont
= NULL
) const = 0;
281 virtual void GetMultiLineTextExtent(const wxString
& string
,
284 wxCoord
*heightLine
= NULL
,
285 const wxFont
*font
= NULL
) const;
286 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
290 virtual void Clear() = 0;
294 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
295 wxCoord width
, wxCoord height
) = 0;
296 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
) = 0;
298 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
299 wxCoord
*w
, wxCoord
*h
) const
306 *w
= m_clipX2
- m_clipX1
;
308 *h
= m_clipY2
- m_clipY1
;
311 virtual void DestroyClippingRegion() { ResetClipping(); }
314 // coordinates conversions and transforms
316 virtual wxCoord
DeviceToLogicalX(wxCoord x
) const;
317 virtual wxCoord
DeviceToLogicalY(wxCoord y
) const;
318 virtual wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
319 virtual wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
320 virtual wxCoord
LogicalToDeviceX(wxCoord x
) const;
321 virtual wxCoord
LogicalToDeviceY(wxCoord y
) const;
322 virtual wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
323 virtual wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
325 virtual void SetMapMode(int mode
);
326 virtual int GetMapMode() const { return m_mappingMode
; }
328 virtual void SetUserScale(double x
, double y
);
329 virtual void GetUserScale(double *x
, double *y
) const
331 if ( x
) *x
= m_userScaleX
;
332 if ( y
) *y
= m_userScaleY
;
335 virtual void SetLogicalScale(double x
, double y
);
336 virtual void GetLogicalScale(double *x
, double *y
)
338 if ( x
) *x
= m_logicalScaleX
;
339 if ( y
) *y
= m_logicalScaleY
;
342 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
343 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
345 if ( x
) *x
= m_logicalOriginX
;
346 if ( y
) *y
= m_logicalOriginY
;
349 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
350 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
352 if ( x
) *x
= m_deviceOriginX
;
353 if ( y
) *y
= m_deviceOriginY
;
356 virtual void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
);
358 virtual void ComputeScaleAndOrigin();
360 // this needs to overidden if the axis is inverted
361 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
363 // ---------------------------------------------------------
364 // the actual drawing API
366 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
367 int style
= wxFLOOD_SURFACE
) = 0;
369 virtual void DoGradientFillLinear(const wxRect
& rect
,
370 const wxColour
& initialColour
,
371 const wxColour
& destColour
,
372 wxDirection nDirection
= wxEAST
);
374 virtual void DoGradientFillConcentric(const wxRect
& rect
,
375 const wxColour
& initialColour
,
376 const wxColour
& destColour
,
377 const wxPoint
& circleCenter
);
379 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
381 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
382 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
384 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
385 wxCoord x2
, wxCoord y2
,
386 wxCoord xc
, wxCoord yc
) = 0;
387 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
388 wxCoord width
, wxCoord height
);
389 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
390 double sa
, double ea
) = 0;
392 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
393 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
394 wxCoord width
, wxCoord height
,
396 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
397 wxCoord width
, wxCoord height
) = 0;
399 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
401 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
402 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
403 bool useMask
= false) = 0;
405 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
406 virtual void DoDrawRotatedText(const wxString
& text
,
407 wxCoord x
, wxCoord y
, double angle
) = 0;
409 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
410 wxCoord width
, wxCoord height
,
412 wxCoord xsrc
, wxCoord ysrc
,
414 bool useMask
= false,
415 wxCoord xsrcMask
= wxDefaultCoord
,
416 wxCoord ysrcMask
= wxDefaultCoord
) = 0;
418 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
419 wxCoord dstWidth
, wxCoord dstHeight
,
421 wxCoord xsrc
, wxCoord ysrc
,
422 wxCoord srcWidth
, wxCoord srcHeight
,
424 bool useMask
= false,
425 wxCoord xsrcMask
= wxDefaultCoord
,
426 wxCoord ysrcMask
= wxDefaultCoord
);
428 virtual wxBitmap
DoGetAsBitmap(const wxRect
*WXUNUSED(subrect
)) const
429 { return wxNullBitmap
; }
432 virtual void DoDrawLines(int n
, wxPoint points
[],
433 wxCoord xoffset
, wxCoord yoffset
) = 0;
434 virtual void DoDrawPolygon(int n
, wxPoint points
[],
435 wxCoord xoffset
, wxCoord yoffset
,
436 int fillStyle
= wxODDEVEN_RULE
) = 0;
437 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
438 wxCoord xoffset
, wxCoord yoffset
,
444 virtual void DoDrawSpline(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
, wxCoord x3
, wxCoord y3
);
445 virtual void DoDrawSpline(int n
, wxPoint points
[]);
446 virtual void DoDrawSpline(const wxPointList
*points
);
453 // unset clipping variables (after clipping region was destroyed)
458 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
465 bool m_isInteractive
:1;
466 bool m_isBBoxValid
:1;
468 // coordinate system variables
470 wxCoord m_logicalOriginX
, m_logicalOriginY
;
471 wxCoord m_deviceOriginX
, m_deviceOriginY
; // Usually 0,0, can be change by user
473 wxCoord m_deviceLocalOriginX
, m_deviceLocalOriginY
; // non-zero if native top-left corner
474 // is not at 0,0. This was the case under
475 // Mac's GrafPorts (coordinate system
476 // used toplevel window's origin) and
477 // e.g. for Postscript, where the native
478 // origin in the bottom left corner.
479 double m_logicalScaleX
, m_logicalScaleY
;
480 double m_userScaleX
, m_userScaleY
;
481 double m_scaleX
, m_scaleY
; // calculated from logical scale and user scale
483 int m_signX
, m_signY
; // Used by SetAxisOrientation() to invert the axes
485 // what is a mm on a screen you don't know the size of?
486 double m_mm_to_pix_x
,
489 // bounding and clipping boxes
490 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
491 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
493 int m_logicalFunction
;
494 int m_backgroundMode
;
499 wxBrush m_backgroundBrush
;
500 wxColour m_textForegroundColour
;
501 wxColour m_textBackgroundColour
;
506 bool m_hasCustomPalette
;
507 #endif // wxUSE_PALETTE
510 DECLARE_ABSTRACT_CLASS(wxImplDC
)
514 class wxDC
: public wxObject
517 wxDC() { m_pimpl
= NULL
; }
523 { return m_pimpl
&& m_pimpl
->IsOk(); }
525 // query capabilities
527 bool CanDrawBitmap() const
528 { return m_pimpl
->CanDrawBitmap(); }
529 bool CanGetTextExtent() const
530 { return m_pimpl
->CanGetTextExtent(); }
532 // query dimension, colour deps, resolution
534 void GetSize(int *width
, int *height
) const
535 { m_pimpl
->DoGetSize(width
, height
); }
537 wxSize
GetSize() const
540 m_pimpl
->DoGetSize(&w
, &h
);
544 void GetSizeMM(int* width
, int* height
) const
545 { m_pimpl
->DoGetSizeMM(width
, height
); }
546 wxSize
GetSizeMM() const
549 m_pimpl
->DoGetSizeMM(&w
, &h
);
554 { return m_pimpl
->GetDepth(); }
555 wxSize
GetPPI() const
556 { return m_pimpl
->GetPPI(); }
558 // Right-To-Left (RTL) modes
560 void SetLayoutDirection(wxLayoutDirection dir
)
561 { m_pimpl
->SetLayoutDirection( dir
); }
562 wxLayoutDirection
GetLayoutDirection() const
563 { return m_pimpl
->GetLayoutDirection(); }
567 bool StartDoc(const wxString
& message
)
568 { return m_pimpl
->StartDoc(message
); }
570 { m_pimpl
->EndDoc(); }
573 { m_pimpl
->StartPage(); }
575 { m_pimpl
->EndPage(); }
579 void CalcBoundingBox(wxCoord x
, wxCoord y
)
580 { m_pimpl
->CalcBoundingBox(x
,y
); }
581 void ResetBoundingBox()
582 { m_pimpl
->ResetBoundingBox(); }
585 { return m_pimpl
->MinX(); }
587 { return m_pimpl
->MaxX(); }
589 { return m_pimpl
->MinY(); }
591 { return m_pimpl
->MaxY(); }
593 // setters and getters
595 void SetFont(const wxFont
& font
)
596 { m_pimpl
->SetFont( font
); }
597 const wxFont
& GetFont() const
598 { return m_pimpl
->GetFont(); }
600 void SetPen(const wxPen
& pen
)
601 { m_pimpl
->SetPen( pen
); }
602 const wxPen
& GetPen() const
603 { return m_pimpl
->GetPen(); }
605 void SetBrush(const wxBrush
& brush
)
606 { m_pimpl
->SetBrush( brush
); }
607 const wxBrush
& GetBrush() const
608 { return m_pimpl
->GetBrush(); }
610 void SetBackground(const wxBrush
& brush
)
611 { m_pimpl
->SetBackground( brush
); }
612 const wxBrush
& GetBackground() const
613 { return m_pimpl
->GetBackground(); }
615 void SetBackgroundMode(int mode
)
616 { m_pimpl
->SetBackgroundMode( mode
); }
617 int GetBackgroundMode() const
618 { return m_pimpl
->GetBackgroundMode(); }
620 void SetTextForeground(const wxColour
& colour
)
621 { m_pimpl
->SetTextForeground(colour
); }
622 const wxColour
& GetTextForeground() const
623 { return m_pimpl
->GetTextForeground(); }
625 void SetTextBackground(const wxColour
& colour
)
626 { m_pimpl
->SetTextBackground(colour
); }
627 const wxColour
& GetTextBackground() const
628 { return m_pimpl
->GetTextBackground(); }
631 void SetPalette(const wxPalette
& palette
)
632 { m_pimpl
->SetPalette(palette
); }
633 #endif // wxUSE_PALETTE
637 void SetLogicalFunction(int function
)
638 { m_pimpl
->SetLogicalFunction(function
); }
639 int GetLogicalFunction() const
640 { return m_pimpl
->GetLogicalFunction(); }
644 wxCoord
GetCharHeight() const
645 { return m_pimpl
->GetCharHeight(); }
646 wxCoord
GetCharWidth() const
647 { return m_pimpl
->GetCharWidth(); }
649 void GetTextExtent(const wxString
& string
,
650 wxCoord
*x
, wxCoord
*y
,
651 wxCoord
*descent
= NULL
,
652 wxCoord
*externalLeading
= NULL
,
653 const wxFont
*theFont
= NULL
) const
654 { m_pimpl
->DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
656 wxSize
GetTextExtent(const wxString
& string
) const
659 m_pimpl
->DoGetTextExtent(string
, &w
, &h
);
663 void GetMultiLineTextExtent(const wxString
& string
,
666 wxCoord
*heightLine
= NULL
,
667 const wxFont
*font
= NULL
) const
668 { m_pimpl
->GetMultiLineTextExtent( string
, width
, height
, heightLine
, font
); }
670 wxSize
GetMultiLineTextExtent(const wxString
& string
) const
673 m_pimpl
->GetMultiLineTextExtent(string
, &w
, &h
);
677 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
678 { return m_pimpl
->DoGetPartialTextExtents(text
, widths
); }
683 { m_pimpl
->Clear(); }
687 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
688 { m_pimpl
->DoSetClippingRegion(x
, y
, width
, height
); }
689 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
690 { m_pimpl
->DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
691 void SetClippingRegion(const wxRect
& rect
)
692 { m_pimpl
->DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
693 void SetClippingRegion(const wxRegion
& region
)
694 { m_pimpl
->DoSetClippingRegionAsRegion(region
); }
696 void DestroyClippingRegion()
697 { m_pimpl
->DestroyClippingRegion(); }
699 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
700 { m_pimpl
->DoGetClippingBox(x
, y
, w
, h
); }
701 void GetClippingBox(wxRect
& rect
) const
702 { m_pimpl
->DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
); }
704 // coordinates conversions and transforms
706 wxCoord
DeviceToLogicalX(wxCoord x
) const
707 { return m_pimpl
->DeviceToLogicalX(x
); }
708 wxCoord
DeviceToLogicalY(wxCoord y
) const
709 { return m_pimpl
->DeviceToLogicalY(y
); }
710 wxCoord
DeviceToLogicalXRel(wxCoord x
) const
711 { return m_pimpl
->DeviceToLogicalXRel(x
); }
712 wxCoord
DeviceToLogicalYRel(wxCoord y
) const
713 { return m_pimpl
->DeviceToLogicalYRel(y
); }
714 wxCoord
LogicalToDeviceX(wxCoord x
) const
715 { return m_pimpl
->LogicalToDeviceX(x
); }
716 wxCoord
LogicalToDeviceY(wxCoord y
) const
717 { return m_pimpl
->LogicalToDeviceY(y
); }
718 wxCoord
LogicalToDeviceXRel(wxCoord x
) const
719 { return m_pimpl
->LogicalToDeviceXRel(x
); }
720 wxCoord
LogicalToDeviceYRel(wxCoord y
) const
721 { return m_pimpl
->LogicalToDeviceYRel(y
); }
723 void SetMapMode(int mode
)
724 { m_pimpl
->SetMapMode(mode
); }
725 int GetMapMode() const
726 { return m_pimpl
->GetMapMode(); }
728 void SetUserScale(double x
, double y
)
729 { m_pimpl
->SetUserScale(x
,y
); }
730 void GetUserScale(double *x
, double *y
) const
731 { m_pimpl
->GetUserScale( x
, y
); }
733 void SetLogicalScale(double x
, double y
)
734 { m_pimpl
->SetLogicalScale( x
, y
); }
735 void GetLogicalScale(double *x
, double *y
)
736 { m_pimpl
->GetLogicalScale( x
, y
); }
738 void SetLogicalOrigin(wxCoord x
, wxCoord y
)
739 { m_pimpl
->SetLogicalOrigin(x
,y
); }
740 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
741 { m_pimpl
->DoGetLogicalOrigin(x
, y
); }
742 wxPoint
GetLogicalOrigin() const
743 { wxCoord x
, y
; m_pimpl
->DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
745 void SetDeviceOrigin(wxCoord x
, wxCoord y
)
746 { m_pimpl
->SetDeviceOrigin( x
, y
); }
747 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
748 { m_pimpl
->DoGetDeviceOrigin(x
, y
); }
749 wxPoint
GetDeviceOrigin() const
750 { wxCoord x
, y
; m_pimpl
->DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
752 void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
)
753 { m_pimpl
->SetAxisOrientation(xLeftRight
, yBottomUp
); }
756 void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
)
757 { m_pimpl
->SetDeviceLocalOrigin( x
, y
); }
760 // draw generic object
762 void DrawObject(wxDrawObject
* drawobject
)
764 drawobject
->Draw(*this);
765 CalcBoundingBox(drawobject
->MinX(),drawobject
->MinY());
766 CalcBoundingBox(drawobject
->MaxX(),drawobject
->MaxY());
769 // -----------------------------------------------
770 // the actual drawing API
772 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
773 int style
= wxFLOOD_SURFACE
)
774 { return m_pimpl
->DoFloodFill(x
, y
, col
, style
); }
775 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
776 int style
= wxFLOOD_SURFACE
)
777 { return m_pimpl
->DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
779 // fill the area specified by rect with a radial gradient, starting from
780 // initialColour in the centre of the cercle and fading to destColour.
781 void GradientFillConcentric(const wxRect
& rect
,
782 const wxColour
& initialColour
,
783 const wxColour
& destColour
)
784 { m_pimpl
->DoGradientFillConcentric( rect
, initialColour
, destColour
,
785 wxPoint(rect
.GetWidth() / 2,
786 rect
.GetHeight() / 2)); }
788 void GradientFillConcentric(const wxRect
& rect
,
789 const wxColour
& initialColour
,
790 const wxColour
& destColour
,
791 const wxPoint
& circleCenter
)
792 { m_pimpl
->DoGradientFillConcentric(rect
, initialColour
, destColour
, circleCenter
); }
794 // fill the area specified by rect with a linear gradient
795 void GradientFillLinear(const wxRect
& rect
,
796 const wxColour
& initialColour
,
797 const wxColour
& destColour
,
798 wxDirection nDirection
= wxEAST
)
799 { m_pimpl
->DoGradientFillLinear(rect
, initialColour
, destColour
, nDirection
); }
801 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
802 { return m_pimpl
->DoGetPixel(x
, y
, col
); }
803 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
804 { return m_pimpl
->DoGetPixel(pt
.x
, pt
.y
, col
); }
806 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
807 { m_pimpl
->DoDrawLine(x1
, y1
, x2
, y2
); }
808 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
809 { m_pimpl
->DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
811 void CrossHair(wxCoord x
, wxCoord y
)
812 { m_pimpl
->DoCrossHair(x
, y
); }
813 void CrossHair(const wxPoint
& pt
)
814 { m_pimpl
->DoCrossHair(pt
.x
, pt
.y
); }
816 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
817 wxCoord xc
, wxCoord yc
)
818 { m_pimpl
->DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
819 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
820 { m_pimpl
->DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
822 void DrawCheckMark(wxCoord x
, wxCoord y
,
823 wxCoord width
, wxCoord height
)
824 { m_pimpl
->DoDrawCheckMark(x
, y
, width
, height
); }
825 void DrawCheckMark(const wxRect
& rect
)
826 { m_pimpl
->DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
828 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
829 double sa
, double ea
)
830 { m_pimpl
->DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
831 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
832 double sa
, double ea
)
833 { m_pimpl
->DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
835 void DrawPoint(wxCoord x
, wxCoord y
)
836 { m_pimpl
->DoDrawPoint(x
, y
); }
837 void DrawPoint(const wxPoint
& pt
)
838 { m_pimpl
->DoDrawPoint(pt
.x
, pt
.y
); }
840 void DrawLines(int n
, wxPoint points
[],
841 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
842 { m_pimpl
->DoDrawLines(n
, points
, xoffset
, yoffset
); }
845 // needs to be removed
846 void DrawLines(const wxPointList
*list
,
847 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
850 void DrawPolygon(int n
, wxPoint points
[],
851 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
852 int fillStyle
= wxODDEVEN_RULE
)
853 { m_pimpl
->DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
856 // needs to be removed
857 void DrawPolygon(const wxPointList
*list
,
858 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
859 int fillStyle
= wxODDEVEN_RULE
)
860 { m_pimpl
->DrawPolygon( list
, xoffset
, yoffset
, fillStyle
); }
863 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
864 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
865 int fillStyle
= wxODDEVEN_RULE
)
866 { m_pimpl
->DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
868 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
869 { m_pimpl
->DoDrawRectangle(x
, y
, width
, height
); }
870 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
871 { m_pimpl
->DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
872 void DrawRectangle(const wxRect
& rect
)
873 { m_pimpl
->DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
875 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
877 { m_pimpl
->DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
878 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
880 { m_pimpl
->DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
881 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
882 { m_pimpl
->DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
884 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
885 { m_pimpl
->DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
886 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
887 { m_pimpl
->DoDrawEllipse(pt
.x
- radius
, pt
.y
- radius
, 2*radius
, 2*radius
); }
889 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
890 { m_pimpl
->DoDrawEllipse(x
, y
, width
, height
); }
891 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
892 { m_pimpl
->DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
893 void DrawEllipse(const wxRect
& rect
)
894 { m_pimpl
->DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
896 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
897 { m_pimpl
->DoDrawIcon(icon
, x
, y
); }
898 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
899 { m_pimpl
->DoDrawIcon(icon
, pt
.x
, pt
.y
); }
901 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
902 bool useMask
= false)
903 { m_pimpl
->DoDrawBitmap(bmp
, x
, y
, useMask
); }
904 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
905 bool useMask
= false)
906 { m_pimpl
->DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
908 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
909 { m_pimpl
->DoDrawText(text
, x
, y
); }
910 void DrawText(const wxString
& text
, const wxPoint
& pt
)
911 { m_pimpl
->DoDrawText(text
, pt
.x
, pt
.y
); }
913 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
914 { m_pimpl
->DoDrawRotatedText(text
, x
, y
, angle
); }
915 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
916 { m_pimpl
->DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
918 // this version puts both optional bitmap and the text into the given
919 // rectangle and aligns is as specified by alignment parameter; it also
920 // will emphasize the character with the given index if it is != -1 and
921 // return the bounding rectangle if required
922 void DrawLabel(const wxString
& text
,
923 const wxBitmap
& image
,
925 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
927 wxRect
*rectBounding
= NULL
);
929 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
930 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
932 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
934 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
935 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
936 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
938 return m_pimpl
->DoBlit(xdest
, ydest
, width
, height
,
939 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
941 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
942 wxDC
*source
, const wxPoint
& srcPt
,
943 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcPtMask
= wxDefaultPosition
)
945 return m_pimpl
->DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
946 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
949 bool StretchBlit(wxCoord dstX
, wxCoord dstY
,
950 wxCoord dstWidth
, wxCoord dstHeight
,
952 wxCoord srcX
, wxCoord srcY
,
953 wxCoord srcWidth
, wxCoord srcHeight
,
954 int rop
= wxCOPY
, bool useMask
= false,
955 wxCoord srcMaskX
= wxDefaultCoord
, wxCoord srcMaskY
= wxDefaultCoord
)
957 return m_pimpl
->DoStretchBlit(dstX
, dstY
, dstWidth
, dstHeight
,
958 source
, srcX
, srcY
, srcWidth
, srcHeight
, rop
, useMask
, srcMaskX
, srcMaskY
);
960 bool StretchBlit(const wxPoint
& dstPt
, const wxSize
& dstSize
,
961 wxDC
*source
, const wxPoint
& srcPt
, const wxSize
& srcSize
,
962 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcMaskPt
= wxDefaultPosition
)
964 return m_pimpl
->DoStretchBlit(dstPt
.x
, dstPt
.y
, dstSize
.x
, dstSize
.y
,
965 source
, srcPt
.x
, srcPt
.y
, srcSize
.x
, srcSize
.y
, rop
, useMask
, srcMaskPt
.x
, srcMaskPt
.y
);
968 wxBitmap
GetAsBitmap(const wxRect
*subrect
= (const wxRect
*) NULL
) const
970 return m_pimpl
->DoGetAsBitmap(subrect
);
974 void DrawSpline(wxCoord x1
, wxCoord y1
,
975 wxCoord x2
, wxCoord y2
,
976 wxCoord x3
, wxCoord y3
)
977 { m_pimpl
->DoDrawSpline(x1
,y1
,x2
,y2
,x3
,y3
); }
978 void DrawSpline(int n
, wxPoint points
[])
979 { m_pimpl
->DoDrawSpline(n
,points
); }
980 void DrawSpline(const wxPointList
*points
)
981 { m_pimpl
->DoDrawSpline(points
); }
982 #endif // wxUSE_SPLINES
985 #if WXWIN_COMPATIBILITY_2_8
986 // for compatibility with the old code when wxCoord was long everywhere
987 wxDEPRECATED( void GetTextExtent(const wxString
& string
,
989 long *descent
= NULL
,
990 long *externalLeading
= NULL
,
991 const wxFont
*theFont
= NULL
) const );
992 wxDEPRECATED( void GetLogicalOrigin(long *x
, long *y
) const );
993 wxDEPRECATED( void GetDeviceOrigin(long *x
, long *y
) const );
994 wxDEPRECATED( void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const );
995 #endif // WXWIN_COMPATIBILITY_2_8
1002 DECLARE_ABSTRACT_CLASS(wxImplDC
)
1006 //-----------------------------------------------------------------------------
1008 //-----------------------------------------------------------------------------
1010 class WXDLLIMPEXP_CORE wxWindowDC
: public wxDC
1014 wxWindowDC( wxWindow
*win
);
1017 DECLARE_DYNAMIC_CLASS(wxWindowDC
)
1020 //-----------------------------------------------------------------------------
1022 //-----------------------------------------------------------------------------
1024 class WXDLLIMPEXP_CORE wxClientDC
: public wxDC
1028 wxClientDC( wxWindow
*win
);
1031 DECLARE_DYNAMIC_CLASS(wxClientDC
)
1034 //-----------------------------------------------------------------------------
1036 //-----------------------------------------------------------------------------
1038 class WXDLLIMPEXP_CORE wxPaintDC
: public wxDC
1042 wxPaintDC( wxWindow
*win
);
1045 DECLARE_DYNAMIC_CLASS(wxPaintDC
)
1048 #else // wxUSE_NEW_DC
1051 class WXDLLIMPEXP_FWD_CORE wxDC
;
1053 // ---------------------------------------------------------------------------
1055 // ---------------------------------------------------------------------------
1057 // ---------------------------------------------------------------------------
1058 // wxDC is the device context - object on which any drawing is done
1059 // ---------------------------------------------------------------------------
1061 class WXDLLEXPORT wxDCBase
: public wxObject
1065 virtual ~wxDCBase();
1067 // graphic primitives
1068 // ------------------
1070 virtual void DrawObject(wxDrawObject
* drawobject
)
1072 drawobject
->Draw(*this);
1073 CalcBoundingBox(drawobject
->MinX(),drawobject
->MinY());
1074 CalcBoundingBox(drawobject
->MaxX(),drawobject
->MaxY());
1077 wxDC
*GetOwner() const { return (wxDC
*) this; }
1079 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
1080 int style
= wxFLOOD_SURFACE
)
1081 { return DoFloodFill(x
, y
, col
, style
); }
1082 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
1083 int style
= wxFLOOD_SURFACE
)
1084 { return DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
1086 // fill the area specified by rect with a radial gradient, starting from
1087 // initialColour in the centre of the cercle and fading to destColour.
1088 void GradientFillConcentric(const wxRect
& rect
,
1089 const wxColour
& initialColour
,
1090 const wxColour
& destColour
)
1091 { GradientFillConcentric(rect
, initialColour
, destColour
,
1092 wxPoint(rect
.GetWidth() / 2,
1093 rect
.GetHeight() / 2)); }
1095 void GradientFillConcentric(const wxRect
& rect
,
1096 const wxColour
& initialColour
,
1097 const wxColour
& destColour
,
1098 const wxPoint
& circleCenter
)
1099 { DoGradientFillConcentric(rect
, initialColour
, destColour
, circleCenter
); }
1101 // fill the area specified by rect with a linear gradient
1102 void GradientFillLinear(const wxRect
& rect
,
1103 const wxColour
& initialColour
,
1104 const wxColour
& destColour
,
1105 wxDirection nDirection
= wxEAST
)
1106 { DoGradientFillLinear(rect
, initialColour
, destColour
, nDirection
); }
1108 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
1109 { return DoGetPixel(x
, y
, col
); }
1110 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
1111 { return DoGetPixel(pt
.x
, pt
.y
, col
); }
1113 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
1114 { DoDrawLine(x1
, y1
, x2
, y2
); }
1115 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
1116 { DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
1118 void CrossHair(wxCoord x
, wxCoord y
)
1119 { DoCrossHair(x
, y
); }
1120 void CrossHair(const wxPoint
& pt
)
1121 { DoCrossHair(pt
.x
, pt
.y
); }
1123 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
1124 wxCoord xc
, wxCoord yc
)
1125 { DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
1126 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
1127 { DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
1129 void DrawCheckMark(wxCoord x
, wxCoord y
,
1130 wxCoord width
, wxCoord height
)
1131 { DoDrawCheckMark(x
, y
, width
, height
); }
1132 void DrawCheckMark(const wxRect
& rect
)
1133 { DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1135 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
1136 double sa
, double ea
)
1137 { DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
1138 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
1139 double sa
, double ea
)
1140 { DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
1142 void DrawPoint(wxCoord x
, wxCoord y
)
1143 { DoDrawPoint(x
, y
); }
1144 void DrawPoint(const wxPoint
& pt
)
1145 { DoDrawPoint(pt
.x
, pt
.y
); }
1147 void DrawLines(int n
, wxPoint points
[],
1148 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
1149 { DoDrawLines(n
, points
, xoffset
, yoffset
); }
1150 void DrawLines(const wxPointList
*list
,
1151 wxCoord xoffset
= 0, wxCoord yoffset
= 0);
1153 #if WXWIN_COMPATIBILITY_2_8
1154 wxDEPRECATED( void DrawLines(const wxList
*list
,
1155 wxCoord xoffset
= 0, wxCoord yoffset
= 0) );
1156 #endif // WXWIN_COMPATIBILITY_2_8
1159 void DrawPolygon(int n
, wxPoint points
[],
1160 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1161 int fillStyle
= wxODDEVEN_RULE
)
1162 { DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
1164 void DrawPolygon(const wxPointList
*list
,
1165 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1166 int fillStyle
= wxODDEVEN_RULE
);
1168 #if WXWIN_COMPATIBILITY_2_8
1169 wxDEPRECATED( void DrawPolygon(const wxList
*list
,
1170 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1171 int fillStyle
= wxODDEVEN_RULE
) );
1172 #endif // WXWIN_COMPATIBILITY_2_8
1174 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
1175 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1176 int fillStyle
= wxODDEVEN_RULE
)
1177 { DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
1179 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1180 { DoDrawRectangle(x
, y
, width
, height
); }
1181 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
1182 { DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1183 void DrawRectangle(const wxRect
& rect
)
1184 { DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1186 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
1188 { DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
1189 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
1191 { DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
1192 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
1193 { DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
1195 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
1196 { DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
1197 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
1198 { DrawCircle(pt
.x
, pt
.y
, radius
); }
1200 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1201 { DoDrawEllipse(x
, y
, width
, height
); }
1202 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
1203 { DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1204 void DrawEllipse(const wxRect
& rect
)
1205 { DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1207 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
1208 { DoDrawIcon(icon
, x
, y
); }
1209 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
1210 { DoDrawIcon(icon
, pt
.x
, pt
.y
); }
1212 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
1213 bool useMask
= false)
1214 { DoDrawBitmap(bmp
, x
, y
, useMask
); }
1215 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
1216 bool useMask
= false)
1217 { DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
1219 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
1220 { DoDrawText(text
, x
, y
); }
1221 void DrawText(const wxString
& text
, const wxPoint
& pt
)
1222 { DoDrawText(text
, pt
.x
, pt
.y
); }
1224 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
1225 { DoDrawRotatedText(text
, x
, y
, angle
); }
1226 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
1227 { DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
1229 // this version puts both optional bitmap and the text into the given
1230 // rectangle and aligns is as specified by alignment parameter; it also
1231 // will emphasize the character with the given index if it is != -1 and
1232 // return the bounding rectangle if required
1233 virtual void DrawLabel(const wxString
& text
,
1234 const wxBitmap
& image
,
1236 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1237 int indexAccel
= -1,
1238 wxRect
*rectBounding
= NULL
);
1240 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
1241 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1242 int indexAccel
= -1)
1243 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
1245 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1246 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
1247 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
1249 return DoBlit(xdest
, ydest
, width
, height
,
1250 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
1252 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
1253 wxDC
*source
, const wxPoint
& srcPt
,
1254 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcPtMask
= wxDefaultPosition
)
1256 return DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
1257 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
1260 bool StretchBlit(wxCoord dstX
, wxCoord dstY
,
1261 wxCoord dstWidth
, wxCoord dstHeight
,
1263 wxCoord srcX
, wxCoord srcY
,
1264 wxCoord srcWidth
, wxCoord srcHeight
,
1265 int rop
= wxCOPY
, bool useMask
= false,
1266 wxCoord srcMaskX
= wxDefaultCoord
, wxCoord srcMaskY
= wxDefaultCoord
)
1268 return DoStretchBlit(dstX
, dstY
, dstWidth
, dstHeight
,
1269 source
, srcX
, srcY
, srcWidth
, srcHeight
, rop
, useMask
, srcMaskX
, srcMaskY
);
1271 bool StretchBlit(const wxPoint
& dstPt
, const wxSize
& dstSize
,
1272 wxDC
*source
, const wxPoint
& srcPt
, const wxSize
& srcSize
,
1273 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcMaskPt
= wxDefaultPosition
)
1275 return DoStretchBlit(dstPt
.x
, dstPt
.y
, dstSize
.x
, dstSize
.y
,
1276 source
, srcPt
.x
, srcPt
.y
, srcSize
.x
, srcSize
.y
, rop
, useMask
, srcMaskPt
.x
, srcMaskPt
.y
);
1279 wxBitmap
GetAsBitmap(const wxRect
*subrect
= (const wxRect
*) NULL
) const
1281 return DoGetAsBitmap(subrect
);
1285 void DrawSpline(wxCoord x1
, wxCoord y1
,
1286 wxCoord x2
, wxCoord y2
,
1287 wxCoord x3
, wxCoord y3
);
1288 void DrawSpline(int n
, wxPoint points
[]);
1290 void DrawSpline(const wxPointList
*points
) { DoDrawSpline(points
); }
1292 #if WXWIN_COMPATIBILITY_2_8
1293 wxDEPRECATED( void DrawSpline(const wxList
*points
) );
1294 #endif // WXWIN_COMPATIBILITY_2_8
1296 #endif // wxUSE_SPLINES
1298 // Eventually we will have wxUSE_GENERIC_DRAWELLIPSE
1300 //! Generic method to draw ellipses, circles and arcs with current pen and brush.
1301 /*! \param x Upper left corner of bounding box.
1302 * \param y Upper left corner of bounding box.
1303 * \param w Width of bounding box.
1304 * \param h Height of bounding box.
1305 * \param sa Starting angle of arc
1306 * (counterclockwise, start at 3 o'clock, 360 is full circle).
1307 * \param ea Ending angle of arc.
1308 * \param angle Rotation angle, the Arc will be rotated after
1309 * calculating begin and end.
1311 void DrawEllipticArcRot( wxCoord x
, wxCoord y
,
1312 wxCoord width
, wxCoord height
,
1313 double sa
= 0, double ea
= 0, double angle
= 0 )
1314 { DoDrawEllipticArcRot( x
, y
, width
, height
, sa
, ea
, angle
); }
1316 void DrawEllipticArcRot( const wxPoint
& pt
,
1318 double sa
= 0, double ea
= 0, double angle
= 0 )
1319 { DoDrawEllipticArcRot( pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
, angle
); }
1321 void DrawEllipticArcRot( const wxRect
& rect
,
1322 double sa
= 0, double ea
= 0, double angle
= 0 )
1323 { DoDrawEllipticArcRot( rect
.x
, rect
.y
, rect
.width
, rect
.height
, sa
, ea
, angle
); }
1325 virtual void DoDrawEllipticArcRot( wxCoord x
, wxCoord y
,
1326 wxCoord w
, wxCoord h
,
1327 double sa
= 0, double ea
= 0, double angle
= 0 );
1329 //! Rotates points around center.
1330 /*! This is a quite straight method, it calculates in pixels
1331 * and so it produces rounding errors.
1332 * \param points The points inside will be rotated.
1333 * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle).
1334 * \param center Center of rotation.
1336 void Rotate( wxPointList
* points
, double angle
, wxPoint center
= wxPoint(0,0) );
1338 // used by DrawEllipticArcRot
1339 // Careful: wxList gets filled with points you have to delete later.
1340 void CalculateEllipticPoints( wxPointList
* points
,
1341 wxCoord xStart
, wxCoord yStart
,
1342 wxCoord w
, wxCoord h
,
1343 double sa
, double ea
);
1346 // global DC operations
1347 // --------------------
1349 virtual void Clear() = 0;
1351 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
1352 virtual void EndDoc() { }
1354 virtual void StartPage() { }
1355 virtual void EndPage() { }
1357 #if WXWIN_COMPATIBILITY_2_6
1358 wxDEPRECATED( void BeginDrawing() );
1359 wxDEPRECATED( void EndDrawing() );
1360 #endif // WXWIN_COMPATIBILITY_2_6
1363 // set objects to use for drawing
1364 // ------------------------------
1366 virtual void SetFont(const wxFont
& font
) = 0;
1367 virtual void SetPen(const wxPen
& pen
) = 0;
1368 virtual void SetBrush(const wxBrush
& brush
) = 0;
1369 virtual void SetBackground(const wxBrush
& brush
) = 0;
1370 virtual void SetBackgroundMode(int mode
) = 0;
1372 virtual void SetPalette(const wxPalette
& palette
) = 0;
1373 #endif // wxUSE_PALETTE
1378 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1379 { DoSetClippingRegion(x
, y
, width
, height
); }
1380 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
1381 { DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1382 void SetClippingRegion(const wxRect
& rect
)
1383 { DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1384 void SetClippingRegion(const wxRegion
& region
)
1385 { DoSetClippingRegionAsRegion(region
); }
1387 virtual void DestroyClippingRegion() { ResetClipping(); }
1389 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
1390 { DoGetClippingBox(x
, y
, w
, h
); }
1391 void GetClippingBox(wxRect
& rect
) const
1393 DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
);
1399 virtual wxCoord
GetCharHeight() const = 0;
1400 virtual wxCoord
GetCharWidth() const = 0;
1402 // only works for single line strings
1403 void GetTextExtent(const wxString
& string
,
1404 wxCoord
*x
, wxCoord
*y
,
1405 wxCoord
*descent
= NULL
,
1406 wxCoord
*externalLeading
= NULL
,
1407 const wxFont
*theFont
= NULL
) const
1408 { DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
1410 wxSize
GetTextExtent(const wxString
& string
) const
1413 DoGetTextExtent(string
, &w
, &h
);
1414 return wxSize(w
, h
);
1417 // works for single as well as multi-line strings
1418 virtual void GetMultiLineTextExtent(const wxString
& string
,
1421 wxCoord
*heightLine
= NULL
,
1422 const wxFont
*font
= NULL
) const;
1424 wxSize
GetMultiLineTextExtent(const wxString
& string
) const
1427 GetMultiLineTextExtent(string
, &w
, &h
);
1428 return wxSize(w
, h
);
1431 // Measure cumulative width of text after each character
1432 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
1433 { return DoGetPartialTextExtents(text
, widths
); }
1436 // size and resolution
1437 // -------------------
1440 void GetSize(int *width
, int *height
) const
1441 { DoGetSize(width
, height
); }
1442 wxSize
GetSize() const
1447 return wxSize(w
, h
);
1451 void GetSizeMM(int* width
, int* height
) const
1452 { DoGetSizeMM(width
, height
); }
1453 wxSize
GetSizeMM() const
1456 DoGetSizeMM(&w
, &h
);
1458 return wxSize(w
, h
);
1461 // query DC capabilities
1462 // ---------------------
1464 virtual bool CanDrawBitmap() const = 0;
1465 virtual bool CanGetTextExtent() const = 0;
1468 virtual int GetDepth() const = 0;
1470 // Resolution in Pixels per inch
1471 virtual wxSize
GetPPI() const = 0;
1473 virtual bool Ok() const { return IsOk(); }
1474 virtual bool IsOk() const { return m_ok
; }
1476 // accessors and setters
1477 // ---------------------
1479 virtual int GetBackgroundMode() const { return m_backgroundMode
; }
1480 virtual const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
1481 virtual const wxBrush
& GetBrush() const { return m_brush
; }
1482 virtual const wxFont
& GetFont() const { return m_font
; }
1483 virtual const wxPen
& GetPen() const { return m_pen
; }
1485 virtual const wxColour
& GetTextForeground() const { return m_textForegroundColour
; }
1486 virtual const wxColour
& GetTextBackground() const { return m_textBackgroundColour
; }
1487 virtual void SetTextForeground(const wxColour
& colour
)
1488 { m_textForegroundColour
= colour
; }
1489 virtual void SetTextBackground(const wxColour
& colour
)
1490 { m_textBackgroundColour
= colour
; }
1493 // coordinates conversions and transforms
1494 // --------------------------------------
1496 virtual wxCoord
DeviceToLogicalX(wxCoord x
) const;
1497 virtual wxCoord
DeviceToLogicalY(wxCoord y
) const;
1498 virtual wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
1499 virtual wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
1500 virtual wxCoord
LogicalToDeviceX(wxCoord x
) const;
1501 virtual wxCoord
LogicalToDeviceY(wxCoord y
) const;
1502 virtual wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
1503 virtual wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
1505 virtual void SetMapMode(int mode
);
1506 virtual int GetMapMode() const { return m_mappingMode
; }
1508 virtual void SetUserScale(double x
, double y
);
1509 virtual void GetUserScale(double *x
, double *y
) const
1511 if ( x
) *x
= m_userScaleX
;
1512 if ( y
) *y
= m_userScaleY
;
1515 virtual void SetLogicalScale(double x
, double y
);
1516 virtual void GetLogicalScale(double *x
, double *y
)
1518 if ( x
) *x
= m_logicalScaleX
;
1519 if ( y
) *y
= m_logicalScaleY
;
1522 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
1523 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
1524 { DoGetLogicalOrigin(x
, y
); }
1525 wxPoint
GetLogicalOrigin() const
1526 { wxCoord x
, y
; DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
1528 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
1529 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
1530 { DoGetDeviceOrigin(x
, y
); }
1531 wxPoint
GetDeviceOrigin() const
1532 { wxCoord x
, y
; DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
1534 virtual void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
);
1536 virtual void ComputeScaleAndOrigin();
1538 // this needs to overidden if the axis is inverted (such
1539 // as when using Postscript, where 0,0 is the lower left
1540 // corner, not the upper left).
1541 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
1543 // logical functions
1544 // ---------------------------
1546 virtual int GetLogicalFunction() const { return m_logicalFunction
; }
1547 virtual void SetLogicalFunction(int function
) = 0;
1552 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
1554 if ( m_isBBoxValid
)
1556 if ( x
< m_minX
) m_minX
= x
;
1557 if ( y
< m_minY
) m_minY
= y
;
1558 if ( x
> m_maxX
) m_maxX
= x
;
1559 if ( y
> m_maxY
) m_maxY
= y
;
1563 m_isBBoxValid
= true;
1572 void ResetBoundingBox()
1574 m_isBBoxValid
= false;
1576 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
1579 // Get the final bounding box of the PostScript or Metafile picture.
1580 wxCoord
MinX() const { return m_minX
; }
1581 wxCoord
MaxX() const { return m_maxX
; }
1582 wxCoord
MinY() const { return m_minY
; }
1583 wxCoord
MaxY() const { return m_maxY
; }
1585 // misc old functions
1586 // ------------------
1588 #if WXWIN_COMPATIBILITY_2_8
1589 // for compatibility with the old code when wxCoord was long everywhere
1590 wxDEPRECATED( void GetTextExtent(const wxString
& string
,
1592 long *descent
= NULL
,
1593 long *externalLeading
= NULL
,
1594 const wxFont
*theFont
= NULL
) const );
1595 wxDEPRECATED( void GetLogicalOrigin(long *x
, long *y
) const );
1596 wxDEPRECATED( void GetDeviceOrigin(long *x
, long *y
) const );
1597 wxDEPRECATED( void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const );
1598 #endif // WXWIN_COMPATIBILITY_2_8
1600 // RTL related functions
1601 // ---------------------
1603 // get or change the layout direction (LTR or RTL) for this dc,
1604 // wxLayout_Default is returned if layout direction is not supported
1605 virtual wxLayoutDirection
GetLayoutDirection() const
1606 { return wxLayout_Default
; }
1607 virtual void SetLayoutDirection(wxLayoutDirection
WXUNUSED(dir
))
1611 // the pure virtual functions which should be implemented by wxDC
1612 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
1613 int style
= wxFLOOD_SURFACE
) = 0;
1615 virtual void DoGradientFillLinear(const wxRect
& rect
,
1616 const wxColour
& initialColour
,
1617 const wxColour
& destColour
,
1618 wxDirection nDirection
= wxEAST
);
1620 virtual void DoGradientFillConcentric(const wxRect
& rect
,
1621 const wxColour
& initialColour
,
1622 const wxColour
& destColour
,
1623 const wxPoint
& circleCenter
);
1625 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
1627 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
1628 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
1630 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
1631 wxCoord x2
, wxCoord y2
,
1632 wxCoord xc
, wxCoord yc
) = 0;
1633 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
1634 wxCoord width
, wxCoord height
);
1635 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
1636 double sa
, double ea
) = 0;
1638 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
1639 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
1640 wxCoord width
, wxCoord height
,
1642 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
1643 wxCoord width
, wxCoord height
) = 0;
1645 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
1647 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
1648 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
1649 bool useMask
= false) = 0;
1651 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
1652 virtual void DoDrawRotatedText(const wxString
& text
,
1653 wxCoord x
, wxCoord y
, double angle
) = 0;
1655 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
1656 wxCoord width
, wxCoord height
,
1658 wxCoord xsrc
, wxCoord ysrc
,
1660 bool useMask
= false,
1661 wxCoord xsrcMask
= wxDefaultCoord
,
1662 wxCoord ysrcMask
= wxDefaultCoord
) = 0;
1664 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
1665 wxCoord dstWidth
, wxCoord dstHeight
,
1667 wxCoord xsrc
, wxCoord ysrc
,
1668 wxCoord srcWidth
, wxCoord srcHeight
,
1670 bool useMask
= false,
1671 wxCoord xsrcMask
= wxDefaultCoord
,
1672 wxCoord ysrcMask
= wxDefaultCoord
);
1674 virtual wxBitmap
DoGetAsBitmap(const wxRect
*WXUNUSED(subrect
)) const
1675 { return wxNullBitmap
; }
1677 virtual void DoGetSize(int *width
, int *height
) const = 0;
1678 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
1680 virtual void DoDrawLines(int n
, wxPoint points
[],
1681 wxCoord xoffset
, wxCoord yoffset
) = 0;
1682 virtual void DoDrawPolygon(int n
, wxPoint points
[],
1683 wxCoord xoffset
, wxCoord yoffset
,
1684 int fillStyle
= wxODDEVEN_RULE
) = 0;
1685 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
1686 wxCoord xoffset
, wxCoord yoffset
,
1689 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
) = 0;
1690 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
1691 wxCoord width
, wxCoord height
) = 0;
1693 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
1694 wxCoord
*w
, wxCoord
*h
) const
1701 *w
= m_clipX2
- m_clipX1
;
1703 *h
= m_clipY2
- m_clipY1
;
1706 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
1708 if ( x
) *x
= m_logicalOriginX
;
1709 if ( y
) *y
= m_logicalOriginY
;
1712 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
1714 if ( x
) *x
= m_deviceOriginX
;
1715 if ( y
) *y
= m_deviceOriginY
;
1718 virtual void DoGetTextExtent(const wxString
& string
,
1719 wxCoord
*x
, wxCoord
*y
,
1720 wxCoord
*descent
= NULL
,
1721 wxCoord
*externalLeading
= NULL
,
1722 const wxFont
*theFont
= NULL
) const = 0;
1724 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
1727 virtual void DoDrawSpline(const wxPointList
*points
);
1731 // unset clipping variables (after clipping region was destroyed)
1732 void ResetClipping()
1736 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
1743 bool m_isInteractive
:1;
1744 bool m_isBBoxValid
:1;
1746 // coordinate system variables
1748 // TODO short descriptions of what exactly they are would be nice...
1750 wxCoord m_logicalOriginX
, m_logicalOriginY
;
1751 wxCoord m_deviceOriginX
, m_deviceOriginY
; // Usually 0,0, can be change by user
1753 wxCoord m_deviceLocalOriginX
, m_deviceLocalOriginY
; // non-zero if native top-left corner
1754 // is not at 0,0. This was the case under
1755 // Mac's GrafPorts (coordinate system
1756 // used toplevel window's origin) and
1757 // e.g. for Postscript, where the native
1758 // origin in the bottom left corner.
1759 double m_logicalScaleX
, m_logicalScaleY
;
1760 double m_userScaleX
, m_userScaleY
;
1761 double m_scaleX
, m_scaleY
; // calculated from logical scale and user scale
1763 // Used by SetAxisOrientation() to invert the axes
1764 int m_signX
, m_signY
;
1766 // what is a mm on a screen you don't know the size of?
1767 double m_mm_to_pix_x
,
1770 // bounding and clipping boxes
1771 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
1772 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
1774 int m_logicalFunction
;
1775 int m_backgroundMode
;
1781 wxBrush m_backgroundBrush
;
1782 wxColour m_textForegroundColour
;
1783 wxColour m_textBackgroundColour
;
1787 wxPalette m_palette
;
1788 bool m_hasCustomPalette
;
1789 #endif // wxUSE_PALETTE
1792 DECLARE_NO_COPY_CLASS(wxDCBase
)
1793 DECLARE_ABSTRACT_CLASS(wxDCBase
)
1796 #endif // wxUSE_NEW_DC
1798 // ----------------------------------------------------------------------------
1799 // now include the declaration of wxDC class
1800 // ----------------------------------------------------------------------------
1802 #if defined(__WXPALMOS__)
1803 #include "wx/palmos/dc.h"
1804 #elif defined(__WXMSW__)
1805 #include "wx/msw/dc.h"
1806 #elif defined(__WXMOTIF__)
1807 #include "wx/motif/dc.h"
1808 #elif defined(__WXGTK20__)
1809 #include "wx/gtk/dc.h"
1810 #elif defined(__WXGTK__)
1811 #include "wx/gtk1/dc.h"
1812 #elif defined(__WXX11__)
1813 #include "wx/x11/dc.h"
1814 #elif defined(__WXMGL__)
1815 #include "wx/mgl/dc.h"
1816 #elif defined(__WXDFB__)
1817 #include "wx/dfb/dc.h"
1818 #elif defined(__WXMAC__)
1819 #include "wx/mac/dc.h"
1820 #elif defined(__WXCOCOA__)
1821 #include "wx/cocoa/dc.h"
1822 #elif defined(__WXPM__)
1823 #include "wx/os2/dc.h"
1826 #if wxUSE_GRAPHICS_CONTEXT
1827 #include "wx/dcgraph.h"
1830 // ----------------------------------------------------------------------------
1831 // helper class: you can use it to temporarily change the DC text colour and
1832 // restore it automatically when the object goes out of scope
1833 // ----------------------------------------------------------------------------
1835 class WXDLLEXPORT wxDCTextColourChanger
1838 wxDCTextColourChanger(wxDC
& dc
) : m_dc(dc
), m_colFgOld() { }
1840 wxDCTextColourChanger(wxDC
& dc
, const wxColour
& col
) : m_dc(dc
)
1845 ~wxDCTextColourChanger()
1847 if ( m_colFgOld
.Ok() )
1848 m_dc
.SetTextForeground(m_colFgOld
);
1851 void Set(const wxColour
& col
)
1853 if ( !m_colFgOld
.Ok() )
1854 m_colFgOld
= m_dc
.GetTextForeground();
1855 m_dc
.SetTextForeground(col
);
1861 wxColour m_colFgOld
;
1863 DECLARE_NO_COPY_CLASS(wxDCTextColourChanger
)
1866 // ----------------------------------------------------------------------------
1867 // helper class: you can use it to temporarily change the DC pen and
1868 // restore it automatically when the object goes out of scope
1869 // ----------------------------------------------------------------------------
1871 class WXDLLEXPORT wxDCPenChanger
1874 wxDCPenChanger(wxDC
& dc
, const wxPen
& pen
) : m_dc(dc
), m_penOld(dc
.GetPen())
1881 if ( m_penOld
.Ok() )
1882 m_dc
.SetPen(m_penOld
);
1890 DECLARE_NO_COPY_CLASS(wxDCPenChanger
)
1893 // ----------------------------------------------------------------------------
1894 // helper class: you can use it to temporarily change the DC brush and
1895 // restore it automatically when the object goes out of scope
1896 // ----------------------------------------------------------------------------
1898 class WXDLLEXPORT wxDCBrushChanger
1901 wxDCBrushChanger(wxDC
& dc
, const wxBrush
& brush
) : m_dc(dc
), m_brushOld(dc
.GetBrush())
1903 m_dc
.SetBrush(brush
);
1908 if ( m_brushOld
.Ok() )
1909 m_dc
.SetBrush(m_brushOld
);
1917 DECLARE_NO_COPY_CLASS(wxDCBrushChanger
)
1920 // ----------------------------------------------------------------------------
1921 // another small helper class: sets the clipping region in its ctor and
1922 // destroys it in the dtor
1923 // ----------------------------------------------------------------------------
1925 class WXDLLEXPORT wxDCClipper
1928 wxDCClipper(wxDC
& dc
, const wxRegion
& r
) : m_dc(dc
)
1929 { dc
.SetClippingRegion(r
); }
1930 wxDCClipper(wxDC
& dc
, const wxRect
& r
) : m_dc(dc
)
1931 { dc
.SetClippingRegion(r
.x
, r
.y
, r
.width
, r
.height
); }
1932 wxDCClipper(wxDC
& dc
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) : m_dc(dc
)
1933 { dc
.SetClippingRegion(x
, y
, w
, h
); }
1935 ~wxDCClipper() { m_dc
.DestroyClippingRegion(); }
1940 DECLARE_NO_COPY_CLASS(wxDCClipper
)
1943 #endif // _WX_DC_H_BASE_