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/list.h" // we use wxList in inline functions
30 #include "wx/dynarray.h"
34 // 1 if using the reorganized DC code
35 #define wxUSE_NEW_DC 0
40 //-----------------------------------------------------------------------------
42 //-----------------------------------------------------------------------------
44 class WXDLLIMPEXP_FWD_CORE wxImplDC
;
46 class WXDLLIMPEXP_CORE wxDCFactory
50 virtual ~wxDCFactory() {}
52 virtual wxImplDC
* CreateWindowDC() = 0;
53 virtual wxImplDC
* CreateWindowDC( wxWindow
*window
) = 0;
54 virtual wxImplDC
* CreateClientDC() = 0;
55 virtual wxImplDC
* CreateClientDC( wxWindow
*window
) = 0;
56 virtual wxImplDC
* CreatePaintDC() = 0;
57 virtual wxImplDC
* CreatePaintDC( wxWindow
*window
) = 0;
58 virtual wxImplDC
* CreateMemoryDC() = 0;
59 virtual wxImplDC
* CreateMemoryDC( wxBitmap
&bitmap
) = 0;
60 virtual wxImplDC
* CreateMemoryDC( wxDC
*dc
) = 0;
62 static void SetDCFactory( wxDCFactory
*factory
);
63 static wxDCFactory
*GetFactory();
65 static wxDCFactory
*m_factory
;
68 //-----------------------------------------------------------------------------
70 //-----------------------------------------------------------------------------
72 class WXDLLIMPEXP_CORE wxDCFactory
75 wxNativeDCFactory() {}
77 virtual wxImplDC
* CreateWindowDC();
78 virtual wxImplDC
* CreateWindowDC( wxWindow
*window
);
79 virtual wxImplDC
* CreateClientDC();
80 virtual wxImplDC
* CreateClientDC( wxWindow
*window
);
81 virtual wxImplDC
* CreatePaintDC();
82 virtual wxImplDC
* CreatePaintDC( wxWindow
*window
);
83 virtual wxImplDC
* CreateMemoryDC();
84 virtual wxImplDC
* CreateMemoryDC( wxBitmap
&bitmap
);
85 virtual wxImplDC
* CreateMemoryDC( wxDC
*dc
);
88 //-----------------------------------------------------------------------------
90 //-----------------------------------------------------------------------------
92 class WXDLLIMPEXP_CORE wxWindowDC
: public wxDC
96 wxWindowDC( wxWindow
*win
);
99 DECLARE_DYNAMIC_CLASS(wxWindowDC
)
102 //-----------------------------------------------------------------------------
104 //-----------------------------------------------------------------------------
106 class WXDLLIMPEXP_CORE wxClientDC
: public wxDC
110 wxClientDC( wxWindow
*win
);
113 DECLARE_DYNAMIC_CLASS(wxClientDC
)
116 //-----------------------------------------------------------------------------
118 //-----------------------------------------------------------------------------
120 class WXDLLIMPEXP_CORE wxMemoryDC
: public wxDC
124 wxMemoryDC( wxBitmap
& bitmap
);
125 wxMemoryDC( wxDC
*dc
);
128 DECLARE_DYNAMIC_CLASS(wxMemoryDC
)
131 //-----------------------------------------------------------------------------
133 //-----------------------------------------------------------------------------
135 class WXDLLIMPEXP_CORE wxPaintDC
: public wxDC
139 wxPaintDC( wxWindow
*win
);
142 DECLARE_DYNAMIC_CLASS(wxPaintDC
)
145 //-----------------------------------------------------------------------------
147 //-----------------------------------------------------------------------------
149 class WXDLLIMPEXP_CORE wxImplDC
: public wxObject
152 wxImplDC( wxDC
*owner
);
155 wxDC
*GetOwner() { return m_owner
; }
157 virtual bool IsOk() const { return m_ok
; }
159 // query capabilities
161 virtual bool CanDrawBitmap() const = 0;
162 virtual bool CanGetTextExtent() const = 0;
164 // query dimension, colour deps, resolution
166 virtual void DoGetSize(int *width
, int *height
) const = 0;
167 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
169 virtual int GetDepth() const = 0;
170 virtual wxSize
GetPPI() const = 0;
172 // Right-To-Left (RTL) modes
174 virtual void SetLayoutDirection(wxLayoutDirection
WXUNUSED(dir
)) { }
175 virtual wxLayoutDirection
GetLayoutDirection() const { return wxLayout_Default
; }
179 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
180 virtual void EndDoc() { }
182 virtual void StartPage() { }
183 virtual void EndPage() { }
187 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
);
191 if ( x
< m_minX
) m_minX
= x
;
192 if ( y
< m_minY
) m_minY
= y
;
193 if ( x
> m_maxX
) m_maxX
= x
;
194 if ( y
> m_maxY
) m_maxY
= y
;
198 m_isBBoxValid
= true;
206 void ResetBoundingBox();
208 m_isBBoxValid
= false;
210 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
213 wxCoord
MinX() const { return m_minX
; }
214 wxCoord
MaxX() const { return m_maxX
; }
215 wxCoord
MinY() const { return m_minY
; }
216 wxCoord
MaxY() const { return m_maxY
; }
218 // setters and getters
220 virtual void SetFont(const wxFont
& font
) = 0;
221 virtual const wxFont
& GetFont() const { return m_font
; }
223 virtual void SetPen(const wxPen
& pen
) = 0;
224 virtual const wxPen
& GetPen() const { return m_pen
; }
226 virtual void SetBrush(const wxBrush
& brush
) = 0;
227 virtual const wxBrush
& GetBrush() const { return m_brush
; }
229 virtual void SetBackground(const wxBrush
& brush
) = 0;
230 virtual const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
232 virtual void SetBackgroundMode(int mode
) = 0;
233 virtual int GetBackgroundMode() const { return m_backgroundMode
; }
235 virtual void SetTextForeground(const wxColour
& colour
)
236 { m_textForegroundColour
= colour
; }
237 virtual const wxColour
& GetTextForeground() const { return m_textForegroundColour
; }
239 virtual void SetTextBackground(const wxColour
& colour
)
240 { m_textBackgroundColour
= colour
; }
241 virtual const wxColour
& GetTextBackground() const { return m_textBackgroundColour
; }
244 virtual void SetPalette(const wxPalette
& palette
) = 0;
245 #endif // wxUSE_PALETTE
249 virtual void SetLogicalFunction(int function
) = 0;
250 virtual int GetLogicalFunction() const { return m_logicalFunction
; }
254 virtual wxCoord
GetCharHeight() const = 0;
255 virtual wxCoord
GetCharWidth() const = 0;
256 virtual void DoGetTextExtent(const wxString
& string
,
257 wxCoord
*x
, wxCoord
*y
,
258 wxCoord
*descent
= NULL
,
259 wxCoord
*externalLeading
= NULL
,
260 const wxFont
*theFont
= NULL
) const = 0;
261 virtual void GetMultiLineTextExtent(const wxString
& string
,
264 wxCoord
*heightLine
= NULL
,
265 const wxFont
*font
= NULL
) const;
266 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
270 virtual void Clear() = 0;
274 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
275 wxCoord width
, wxCoord height
) = 0;
276 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
) = 0;
278 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
279 wxCoord
*w
, wxCoord
*h
) const
286 *w
= m_clipX2
- m_clipX1
;
288 *h
= m_clipY2
- m_clipY1
;
291 virtual void DestroyClippingRegion() { ResetClipping(); }
294 // coordinates conversions and transforms
296 virtual wxCoord
DeviceToLogicalX(wxCoord x
) const;
297 virtual wxCoord
DeviceToLogicalY(wxCoord y
) const;
298 virtual wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
299 virtual wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
300 virtual wxCoord
LogicalToDeviceX(wxCoord x
) const;
301 virtual wxCoord
LogicalToDeviceY(wxCoord y
) const;
302 virtual wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
303 virtual wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
305 virtual void SetMapMode(int mode
);
306 virtual int GetMapMode() const { return m_mappingMode
; }
308 virtual void SetUserScale(double x
, double y
);
309 virtual void GetUserScale(double *x
, double *y
) const
311 if ( x
) *x
= m_userScaleX
;
312 if ( y
) *y
= m_userScaleY
;
315 virtual void SetLogicalScale(double x
, double y
);
316 virtual void GetLogicalScale(double *x
, double *y
)
318 if ( x
) *x
= m_logicalScaleX
;
319 if ( y
) *y
= m_logicalScaleY
;
322 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
323 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
325 if ( x
) *x
= m_logicalOriginX
;
326 if ( y
) *y
= m_logicalOriginY
;
329 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
330 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
332 if ( x
) *x
= m_deviceOriginX
;
333 if ( y
) *y
= m_deviceOriginY
;
336 virtual void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
);
338 virtual void ComputeScaleAndOrigin();
340 // this needs to overidden if the axis is inverted
341 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
343 // ---------------------------------------------------------
344 // the actual drawing API
346 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
347 int style
= wxFLOOD_SURFACE
) = 0;
349 virtual void DoGradientFillLinear(const wxRect
& rect
,
350 const wxColour
& initialColour
,
351 const wxColour
& destColour
,
352 wxDirection nDirection
= wxEAST
);
354 virtual void DoGradientFillConcentric(const wxRect
& rect
,
355 const wxColour
& initialColour
,
356 const wxColour
& destColour
,
357 const wxPoint
& circleCenter
);
359 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
361 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
362 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
364 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
365 wxCoord x2
, wxCoord y2
,
366 wxCoord xc
, wxCoord yc
) = 0;
367 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
368 wxCoord width
, wxCoord height
);
369 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
370 double sa
, double ea
) = 0;
372 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
373 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
374 wxCoord width
, wxCoord height
,
376 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
377 wxCoord width
, wxCoord height
) = 0;
379 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
381 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
382 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
383 bool useMask
= false) = 0;
385 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
386 virtual void DoDrawRotatedText(const wxString
& text
,
387 wxCoord x
, wxCoord y
, double angle
) = 0;
389 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
390 wxCoord width
, wxCoord height
,
392 wxCoord xsrc
, wxCoord ysrc
,
394 bool useMask
= false,
395 wxCoord xsrcMask
= wxDefaultCoord
,
396 wxCoord ysrcMask
= wxDefaultCoord
) = 0;
398 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
399 wxCoord dstWidth
, wxCoord dstHeight
,
401 wxCoord xsrc
, wxCoord ysrc
,
402 wxCoord srcWidth
, wxCoord srcHeight
,
404 bool useMask
= false,
405 wxCoord xsrcMask
= wxDefaultCoord
,
406 wxCoord ysrcMask
= wxDefaultCoord
);
408 virtual wxBitmap
DoGetAsBitmap(const wxRect
*WXUNUSED(subrect
)) const
409 { return wxNullBitmap
; }
412 virtual void DoDrawLines(int n
, wxPoint points
[],
413 wxCoord xoffset
, wxCoord yoffset
) = 0;
414 virtual void DoDrawPolygon(int n
, wxPoint points
[],
415 wxCoord xoffset
, wxCoord yoffset
,
416 int fillStyle
= wxODDEVEN_RULE
) = 0;
417 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
418 wxCoord xoffset
, wxCoord yoffset
,
424 virtual void DoDrawSpline(wxList
*points
);
431 // unset clipping variables (after clipping region was destroyed)
436 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
443 bool m_isInteractive
:1;
444 bool m_isBBoxValid
:1;
446 // coordinate system variables
448 wxCoord m_logicalOriginX
, m_logicalOriginY
;
449 wxCoord m_deviceOriginX
, m_deviceOriginY
; // Usually 0,0, can be change by user
451 wxCoord m_deviceLocalOriginX
, m_deviceLocalOriginY
; // non-zero if native top-left corner
452 // is not at 0,0. This was the case under
453 // Mac's GrafPorts (coordinate system
454 // used toplevel window's origin) and
455 // e.g. for Postscript, where the native
456 // origin in the bottom left corner.
457 double m_logicalScaleX
, m_logicalScaleY
;
458 double m_userScaleX
, m_userScaleY
;
459 double m_scaleX
, m_scaleY
; // calculated from logical scale and user scale
461 int m_signX
, m_signY
; // Used by SetAxisOrientation() to invert the axes
463 // what is a mm on a screen you don't know the size of?
464 double m_mm_to_pix_x
,
467 // bounding and clipping boxes
468 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
469 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
471 int m_logicalFunction
;
472 int m_backgroundMode
;
477 wxBrush m_backgroundBrush
;
478 wxColour m_textForegroundColour
;
479 wxColour m_textBackgroundColour
;
484 bool m_hasCustomPalette
;
485 #endif // wxUSE_PALETTE
488 DECLARE_ABSTRACT_CLASS(wxImplDC
)
492 class wxDC
: public wxObject
495 wxDC() { m_pimpl
= NULL
; }
498 { return m_pimpl
&& m_pimpl
->IsOk(); }
500 // query capabilities
502 bool CanDrawBitmap() const
503 { return m_pimpl
->CanDrawBitmap(); }
504 bool CanGetTextExtent() const
505 { return m_pimpl
->CanGetTextExtent(); }
507 // query dimension, colour deps, resolution
509 void GetSize(int *width
, int *height
) const
510 { m_pimpl
->DoGetSize(width
, height
); }
512 wxSize
GetSize() const
515 m_pimpl
->DoGetSize(&w
, &h
);
519 void GetSizeMM(int* width
, int* height
) const
520 { m_pimpl
->DoGetSizeMM(width
, height
); }
521 wxSize
GetSizeMM() const
524 m_pimpl
->DoGetSizeMM(&w
, &h
);
529 { return m_pimpl
->GetDepth(); }
530 wxSize
GetPPI() const
531 { return m_pimpl
->GetPPI(); }
533 // Right-To-Left (RTL) modes
535 void SetLayoutDirection(wxLayoutDirection dir
)
536 { m_pimpl
->SetLayoutDirection( dir
); }
537 wxLayoutDirection
GetLayoutDirection() const
538 { return m_pimpl
->GetLayoutDirection(); }
542 bool StartDoc(const wxString
& message
)
543 { return m_pimpl
->StartDoc(message
); }
545 { m_pimpl
->EndDoc(); }
548 { m_pimpl
->StartPage(); }
550 { m_pimpl
->EndPage(); }
554 void CalcBoundingBox(wxCoord x
, wxCoord y
)
555 { m_pimpl
->CalcBoundingBox(x
,y
); }
556 void ResetBoundingBox()
557 { m_pimpl
->ResetBoundingBox(); }
560 { return m_pimpl
->MinX(); }
562 { return m_pimpl
->MaxX(); }
564 { return m_pimpl
->MinY(); }
566 { return m_pimpl
->MaxY(); }
568 // setters and getters
570 void SetFont(const wxFont
& font
)
571 { m_pimpl
->SetFont( font
); }
572 const wxFont
& GetFont() const
573 { return m_pimpl
->GetFont(); }
575 void SetPen(const wxPen
& pen
)
576 { m_pimpl
->SetPen( pen
); }
577 const wxPen
& GetPen() const
578 { return m_pimpl
->GetPen(); }
580 void SetBrush(const wxBrush
& brush
)
581 { m_pimpl
->SetBrush( brush
); }
582 const wxBrush
& GetBrush() const
583 { return m_pimpl
->GetBrush(); }
585 void SetBackground(const wxBrush
& brush
)
586 { m_pimpl
->SetBackground( brush
); }
587 const wxBrush
& GetBackground() const
588 { return m_pimpl
->GetBackground(); }
590 void SetBackgroundMode(int mode
)
591 { m_pimpl
->SetBackground( mode
); }
592 int GetBackgroundMode() const
593 { return m_pimpl
->GetBackground(); }
595 void SetTextForeground(const wxColour
& colour
)
596 { m_pimpl
->SetTextForeground(colour
); }
597 const wxColour
& GetTextForeground() const
598 { return m_pimpl
->GetTextForeground(); }
600 void SetTextBackground(const wxColour
& colour
)
601 { m_pimpl
->SetTextBackground(colour
); }
602 const wxColour
& GetTextBackground() const
603 { return m_pimpl
->GetTextBackground(); }
606 void SetPalette(const wxPalette
& palette
)
607 { m_pimpl
->SetPalette(palette
); }
608 #endif // wxUSE_PALETTE
612 void SetLogicalFunction(int function
)
613 { m_pimpl
->SetLogicalFunction(function
); }
614 int GetLogicalFunction() const
615 { return m_pimpl
->GetLogicalFunction(); }
619 wxCoord
GetCharHeight() const
620 { return m_pimpl
->GetCharHeight(); }
621 wxCoord
GetCharWidth() const
622 { return m_pimpl
->GetCharWidth(); }
624 void GetTextExtent(const wxString
& string
,
625 wxCoord
*x
, wxCoord
*y
,
626 wxCoord
*descent
= NULL
,
627 wxCoord
*externalLeading
= NULL
,
628 const wxFont
*theFont
= NULL
) const
629 { m_pimpl
->DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
631 wxSize
GetTextExtent(const wxString
& string
) const
634 m_pimpl
->DoGetTextExtent(string
, &w
, &h
);
638 void GetMultiLineTextExtent(const wxString
& string
,
641 wxCoord
*heightLine
= NULL
,
642 const wxFont
*font
= NULL
) const
643 { m_pimpl
->GetMultiLineTextExtent( string
, width
, height
, heightLine
, font
); }
645 wxSize
GetMultiLineTextExtent(const wxString
& string
) const
648 m_pimpl
->GetMultiLineTextExtent(string
, &w
, &h
);
652 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
653 { return m_pimpl
->DoGetPartialTextExtents(text
, widths
); }
658 { m_pimpl
->Clear(); }
662 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
663 { m_pimpl
->DoSetClippingRegion(x
, y
, width
, height
); }
664 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
665 { m_pimpl
->DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
666 void SetClippingRegion(const wxRect
& rect
)
667 { m_pimpl
->DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
668 void SetClippingRegion(const wxRegion
& region
)
669 { m_pimpl
->DoSetClippingRegionAsRegion(region
); }
671 void DestroyClippingRegion()
672 { m_pimpl
->DestroyClippingRegion(); }
674 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
675 { m_pimpl
->DoGetClippingBox(x
, y
, w
, h
); }
676 void GetClippingBox(wxRect
& rect
) const
677 { m_pimpl
->DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
); }
679 // coordinates conversions and transforms
681 wxCoord
DeviceToLogicalX(wxCoord x
) const
682 { return m_pimpl
->DeviceToLogicalX(x
); }
683 wxCoord
DeviceToLogicalY(wxCoord y
) const;
684 { return m_pimpl
->DeviceToLogicalY(y
); }
685 wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
686 { return m_pimpl
->DeviceToLogicalXRel(x
); }
687 wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
688 { return m_pimpl
->DeviceToLogicalYRel(y
); }
689 wxCoord
LogicalToDeviceX(wxCoord x
) const;
690 { return m_pimpl
->LogicalToDeviceX(x
); }
691 wxCoord
LogicalToDeviceY(wxCoord y
) const;
692 { return m_pimpl
->LogicalToDeviceY(y
); }
693 wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
694 { return m_pimpl
->LogicalToDeviceXRel(x
); }
695 wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
696 { return m_pimpl
->LogicalToDeviceYRel(y
); }
698 void SetMapMode(int mode
)
699 { m_pimpl
->SetMapMode(mode
); }
700 int GetMapMode() const
701 { return m_pimpl
->GetMapMode(); }
703 void SetUserScale(double x
, double y
)
704 { m_pimpl
->SetUserScale(x
,y
); }
705 void GetUserScale(double *x
, double *y
) const
706 { m_pimpl
->GetUserScale( x
, y
); }
708 void SetLogicalScale(double x
, double y
)
709 { m_pimpl
->SetLogicalScale( x
, y
); }
710 void GetLogicalScale(double *x
, double *y
)
711 { m_pimpl
->GetLogicalScale( x
, y
); }
713 void SetLogicalOrigin(wxCoord x
, wxCoord y
)
714 { m_pimpl
->SetLogicalOrigin(x
,y
); }
715 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
716 { m_pimpl
->DoGetLogicalOrigin(x
, y
); }
717 wxPoint
GetLogicalOrigin() const
718 { wxCoord x
, y
; m_pimpl
->DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
720 void SetDeviceOrigin(wxCoord x
, wxCoord y
)
721 { m_pimpl
->SetDeviceOrigin( x
, y
); }
722 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
723 { m_pimpl
->DoGetDeviceOrigin(x
, y
); }
724 wxPoint
GetDeviceOrigin() const
725 { wxCoord x
, y
; m_pimpl
->DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
727 void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
)
728 { m_pimpl
->SetAxisOrientation(xLeftRight
, yBottomUp
); }
731 void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
)
732 { m_pimpl
->SetDeviceLocalOrigin( x
, y
); }
735 // draw generic object
737 void DrawObject(wxDrawObject
* drawobject
)
739 drawobject
->Draw(*this);
740 CalcBoundingBox(drawobject
->MinX(),drawobject
->MinY());
741 CalcBoundingBox(drawobject
->MaxX(),drawobject
->MaxY());
744 // -----------------------------------------------
745 // the actual drawing API
747 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
748 int style
= wxFLOOD_SURFACE
)
749 { return m_pimpl
->DoFloodFill(x
, y
, col
, style
); }
750 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
751 int style
= wxFLOOD_SURFACE
)
752 { return m_pimpl
->DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
754 // fill the area specified by rect with a radial gradient, starting from
755 // initialColour in the centre of the cercle and fading to destColour.
756 void GradientFillConcentric(const wxRect
& rect
,
757 const wxColour
& initialColour
,
758 const wxColour
& destColour
)
759 { m_pimpl
->GradientFillConcentric(rect
, initialColour
, destColour
,
760 wxPoint(rect
.GetWidth() / 2,
761 rect
.GetHeight() / 2)); }
763 void GradientFillConcentric(const wxRect
& rect
,
764 const wxColour
& initialColour
,
765 const wxColour
& destColour
,
766 const wxPoint
& circleCenter
)
767 { m_pimpl
->DoGradientFillConcentric(rect
, initialColour
, destColour
, circleCenter
); }
769 // fill the area specified by rect with a linear gradient
770 void GradientFillLinear(const wxRect
& rect
,
771 const wxColour
& initialColour
,
772 const wxColour
& destColour
,
773 wxDirection nDirection
= wxEAST
)
774 { m_pimpl
->DoGradientFillLinear(rect
, initialColour
, destColour
, nDirection
); }
776 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
777 { return m_pimpl
->DoGetPixel(x
, y
, col
); }
778 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
779 { return m_pimpl
->DoGetPixel(pt
.x
, pt
.y
, col
); }
781 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
782 { m_pimpl
->DoDrawLine(x1
, y1
, x2
, y2
); }
783 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
784 { m_pimpl
->DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
786 void CrossHair(wxCoord x
, wxCoord y
)
787 { m_pimpl
->DoCrossHair(x
, y
); }
788 void CrossHair(const wxPoint
& pt
)
789 { m_pimpl
->DoCrossHair(pt
.x
, pt
.y
); }
791 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
792 wxCoord xc
, wxCoord yc
)
793 { m_pimpl
->DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
794 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
795 { m_pimpl
->DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
797 void DrawCheckMark(wxCoord x
, wxCoord y
,
798 wxCoord width
, wxCoord height
)
799 { m_pimpl
->DoDrawCheckMark(x
, y
, width
, height
); }
800 void DrawCheckMark(const wxRect
& rect
)
801 { m_pimpl
->DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
803 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
804 double sa
, double ea
)
805 { m_pimpl
->DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
806 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
807 double sa
, double ea
)
808 { m_pimpl
->DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
810 void DrawPoint(wxCoord x
, wxCoord y
)
811 { m_pimpl
->DoDrawPoint(x
, y
); }
812 void DrawPoint(const wxPoint
& pt
)
813 { m_pimpl
->DoDrawPoint(pt
.x
, pt
.y
); }
815 void DrawLines(int n
, wxPoint points
[],
816 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
817 { m_pimpl
->DoDrawLines(n
, points
, xoffset
, yoffset
); }
818 void DrawLines(const wxList
*list
,
819 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
820 { m_pimpl
->DrawLines( list
, xoffset
, yoffset
); }
822 void DrawPolygon(int n
, wxPoint points
[],
823 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
824 int fillStyle
= wxODDEVEN_RULE
)
825 { m_pimpl
->DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
827 void DrawPolygon(const wxList
*list
,
828 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
829 int fillStyle
= wxODDEVEN_RULE
)
830 { m_pimpl
->DrawPolygon( list
, xoffset
, yoffset
, fillStyle
); }
832 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
833 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
834 int fillStyle
= wxODDEVEN_RULE
)
835 { m_pimpl
->DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
837 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
838 { m_pimpl
->DoDrawRectangle(x
, y
, width
, height
); }
839 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
840 { m_pimpl
->DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
841 void DrawRectangle(const wxRect
& rect
)
842 { m_pimpl
->DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
844 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
846 { m_pimpl
->DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
847 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
849 { m_pimpl
->DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
850 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
851 { m_pimpl
->DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
853 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
854 { m_pimpl
->DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
855 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
856 { m_pimpl
->DrawCircle(pt
.x
, pt
.y
, radius
); }
858 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
859 { m_pimpl
->DoDrawEllipse(x
, y
, width
, height
); }
860 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
861 { m_pimpl
->DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
862 void DrawEllipse(const wxRect
& rect
)
863 { m_pimpl
->DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
865 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
866 { m_pimpl
->DoDrawIcon(icon
, x
, y
); }
867 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
868 { m_pimpl
->DoDrawIcon(icon
, pt
.x
, pt
.y
); }
870 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
871 bool useMask
= false)
872 { m_pimpl
->DoDrawBitmap(bmp
, x
, y
, useMask
); }
873 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
874 bool useMask
= false)
875 { m_pimpl
->DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
877 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
878 { m_pimpl
->DoDrawText(text
, x
, y
); }
879 void DrawText(const wxString
& text
, const wxPoint
& pt
)
880 { m_pimpl
->DoDrawText(text
, pt
.x
, pt
.y
); }
882 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
883 { m_pimpl
->DoDrawRotatedText(text
, x
, y
, angle
); }
884 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
885 { m_pimpl
->DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
887 // this version puts both optional bitmap and the text into the given
888 // rectangle and aligns is as specified by alignment parameter; it also
889 // will emphasize the character with the given index if it is != -1 and
890 // return the bounding rectangle if required
891 void DrawLabel(const wxString
& text
,
892 const wxBitmap
& image
,
894 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
896 wxRect
*rectBounding
= NULL
)
897 { m_pimpl
->DrawLabel( text
, image
, rect
, alignment
, indexAccel
, rectBounding
); }
899 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
900 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
902 { m_pimpl
->DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
904 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
905 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
906 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
908 return m_pimpl
->DoBlit(xdest
, ydest
, width
, height
,
909 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
911 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
912 wxDC
*source
, const wxPoint
& srcPt
,
913 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcPtMask
= wxDefaultPosition
)
915 return m_pimpl
->DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
916 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
919 bool StretchBlit(wxCoord dstX
, wxCoord dstY
,
920 wxCoord dstWidth
, wxCoord dstHeight
,
922 wxCoord srcX
, wxCoord srcY
,
923 wxCoord srcWidth
, wxCoord srcHeight
,
924 int rop
= wxCOPY
, bool useMask
= false,
925 wxCoord srcMaskX
= wxDefaultCoord
, wxCoord srcMaskY
= wxDefaultCoord
)
927 return m_pimpl
->DoStretchBlit(dstX
, dstY
, dstWidth
, dstHeight
,
928 source
, srcX
, srcY
, srcWidth
, srcHeight
, rop
, useMask
, srcMaskX
, srcMaskY
);
930 bool StretchBlit(const wxPoint
& dstPt
, const wxSize
& dstSize
,
931 wxDC
*source
, const wxPoint
& srcPt
, const wxSize
& srcSize
,
932 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcMaskPt
= wxDefaultPosition
)
934 return m_pimpl
->DoStretchBlit(dstPt
.x
, dstPt
.y
, dstSize
.x
, dstSize
.y
,
935 source
, srcPt
.x
, srcPt
.y
, srcSize
.x
, srcSize
.y
, rop
, useMask
, srcMaskPt
.x
, srcMaskPt
.y
);
938 wxBitmap
GetAsBitmap(const wxRect
*subrect
= (const wxRect
*) NULL
) const
940 return m_pimpl
->DoGetAsBitmap(subrect
);
944 // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?)
945 void DrawSpline(wxCoord x1
, wxCoord y1
,
946 wxCoord x2
, wxCoord y2
,
947 wxCoord x3
, wxCoord y3
)
948 { m_pimpl
->DrawSpline(x1
,y1
,x2
,y2
,x3
,y3
); }
949 void DrawSpline(int n
, wxPoint points
[])
950 { m_pimpl
->DrawSpline(n
,points
); }
952 void DrawSpline(wxList
*points
)
953 { m_pimpl
->DoDrawSpline(points
); }
954 #endif // wxUSE_SPLINES
957 #if WXWIN_COMPATIBILITY_2_8
958 // for compatibility with the old code when wxCoord was long everywhere
959 wxDEPRECATED( void GetTextExtent(const wxString
& string
,
961 long *descent
= NULL
,
962 long *externalLeading
= NULL
,
963 const wxFont
*theFont
= NULL
) const );
964 wxDEPRECATED( void GetLogicalOrigin(long *x
, long *y
) const );
965 wxDEPRECATED( void GetDeviceOrigin(long *x
, long *y
) const );
966 wxDEPRECATED( void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const );
967 #endif // WXWIN_COMPATIBILITY_2_8
974 DECLARE_ABSTRACT_CLASS(wxImplDC
)
978 #else // wxUSE_NEW_DC
981 class WXDLLIMPEXP_FWD_CORE wxDC
;
982 class WXDLLIMPEXP_FWD_CORE wxDCBase
;
984 class WXDLLEXPORT wxDrawObject
989 : m_isBBoxValid(false)
990 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
993 virtual ~wxDrawObject() { }
995 virtual void Draw(wxDCBase
&) const { }
997 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
1001 if ( x
< m_minX
) m_minX
= x
;
1002 if ( y
< m_minY
) m_minY
= y
;
1003 if ( x
> m_maxX
) m_maxX
= x
;
1004 if ( y
> m_maxY
) m_maxY
= y
;
1008 m_isBBoxValid
= true;
1017 void ResetBoundingBox()
1019 m_isBBoxValid
= false;
1021 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
1024 // Get the final bounding box of the PostScript or Metafile picture.
1026 wxCoord
MinX() const { return m_minX
; }
1027 wxCoord
MaxX() const { return m_maxX
; }
1028 wxCoord
MinY() const { return m_minY
; }
1029 wxCoord
MaxY() const { return m_maxY
; }
1031 //to define the type of object for derived objects
1032 virtual int GetType()=0;
1035 //for boundingbox calculation
1036 bool m_isBBoxValid
:1;
1037 //for boundingbox calculation
1038 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
1041 // ---------------------------------------------------------------------------
1043 // ---------------------------------------------------------------------------
1045 // ---------------------------------------------------------------------------
1046 // wxDC is the device context - object on which any drawing is done
1047 // ---------------------------------------------------------------------------
1049 class WXDLLEXPORT wxDCBase
: public wxObject
1053 virtual ~wxDCBase();
1055 // graphic primitives
1056 // ------------------
1058 virtual void DrawObject(wxDrawObject
* drawobject
)
1060 drawobject
->Draw(*this);
1061 CalcBoundingBox(drawobject
->MinX(),drawobject
->MinY());
1062 CalcBoundingBox(drawobject
->MaxX(),drawobject
->MaxY());
1065 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
1066 int style
= wxFLOOD_SURFACE
)
1067 { return DoFloodFill(x
, y
, col
, style
); }
1068 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
1069 int style
= wxFLOOD_SURFACE
)
1070 { return DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
1072 // fill the area specified by rect with a radial gradient, starting from
1073 // initialColour in the centre of the cercle and fading to destColour.
1074 void GradientFillConcentric(const wxRect
& rect
,
1075 const wxColour
& initialColour
,
1076 const wxColour
& destColour
)
1077 { GradientFillConcentric(rect
, initialColour
, destColour
,
1078 wxPoint(rect
.GetWidth() / 2,
1079 rect
.GetHeight() / 2)); }
1081 void GradientFillConcentric(const wxRect
& rect
,
1082 const wxColour
& initialColour
,
1083 const wxColour
& destColour
,
1084 const wxPoint
& circleCenter
)
1085 { DoGradientFillConcentric(rect
, initialColour
, destColour
, circleCenter
); }
1087 // fill the area specified by rect with a linear gradient
1088 void GradientFillLinear(const wxRect
& rect
,
1089 const wxColour
& initialColour
,
1090 const wxColour
& destColour
,
1091 wxDirection nDirection
= wxEAST
)
1092 { DoGradientFillLinear(rect
, initialColour
, destColour
, nDirection
); }
1094 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
1095 { return DoGetPixel(x
, y
, col
); }
1096 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
1097 { return DoGetPixel(pt
.x
, pt
.y
, col
); }
1099 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
1100 { DoDrawLine(x1
, y1
, x2
, y2
); }
1101 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
1102 { DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
1104 void CrossHair(wxCoord x
, wxCoord y
)
1105 { DoCrossHair(x
, y
); }
1106 void CrossHair(const wxPoint
& pt
)
1107 { DoCrossHair(pt
.x
, pt
.y
); }
1109 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
1110 wxCoord xc
, wxCoord yc
)
1111 { DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
1112 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
1113 { DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
1115 void DrawCheckMark(wxCoord x
, wxCoord y
,
1116 wxCoord width
, wxCoord height
)
1117 { DoDrawCheckMark(x
, y
, width
, height
); }
1118 void DrawCheckMark(const wxRect
& rect
)
1119 { DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1121 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
1122 double sa
, double ea
)
1123 { DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
1124 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
1125 double sa
, double ea
)
1126 { DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
1128 void DrawPoint(wxCoord x
, wxCoord y
)
1129 { DoDrawPoint(x
, y
); }
1130 void DrawPoint(const wxPoint
& pt
)
1131 { DoDrawPoint(pt
.x
, pt
.y
); }
1133 void DrawLines(int n
, wxPoint points
[],
1134 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
1135 { DoDrawLines(n
, points
, xoffset
, yoffset
); }
1136 void DrawLines(const wxList
*list
,
1137 wxCoord xoffset
= 0, wxCoord yoffset
= 0);
1139 void DrawPolygon(int n
, wxPoint points
[],
1140 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1141 int fillStyle
= wxODDEVEN_RULE
)
1142 { DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
1144 void DrawPolygon(const wxList
*list
,
1145 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1146 int fillStyle
= wxODDEVEN_RULE
);
1148 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
1149 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1150 int fillStyle
= wxODDEVEN_RULE
)
1151 { DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
1153 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1154 { DoDrawRectangle(x
, y
, width
, height
); }
1155 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
1156 { DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1157 void DrawRectangle(const wxRect
& rect
)
1158 { DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1160 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
1162 { DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
1163 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
1165 { DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
1166 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
1167 { DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
1169 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
1170 { DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
1171 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
1172 { DrawCircle(pt
.x
, pt
.y
, radius
); }
1174 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1175 { DoDrawEllipse(x
, y
, width
, height
); }
1176 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
1177 { DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1178 void DrawEllipse(const wxRect
& rect
)
1179 { DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1181 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
1182 { DoDrawIcon(icon
, x
, y
); }
1183 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
1184 { DoDrawIcon(icon
, pt
.x
, pt
.y
); }
1186 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
1187 bool useMask
= false)
1188 { DoDrawBitmap(bmp
, x
, y
, useMask
); }
1189 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
1190 bool useMask
= false)
1191 { DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
1193 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
1194 { DoDrawText(text
, x
, y
); }
1195 void DrawText(const wxString
& text
, const wxPoint
& pt
)
1196 { DoDrawText(text
, pt
.x
, pt
.y
); }
1198 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
1199 { DoDrawRotatedText(text
, x
, y
, angle
); }
1200 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
1201 { DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
1203 // this version puts both optional bitmap and the text into the given
1204 // rectangle and aligns is as specified by alignment parameter; it also
1205 // will emphasize the character with the given index if it is != -1 and
1206 // return the bounding rectangle if required
1207 virtual void DrawLabel(const wxString
& text
,
1208 const wxBitmap
& image
,
1210 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1211 int indexAccel
= -1,
1212 wxRect
*rectBounding
= NULL
);
1214 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
1215 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1216 int indexAccel
= -1)
1217 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
1219 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1220 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
1221 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
1223 return DoBlit(xdest
, ydest
, width
, height
,
1224 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
1226 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
1227 wxDC
*source
, const wxPoint
& srcPt
,
1228 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcPtMask
= wxDefaultPosition
)
1230 return DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
1231 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
1234 bool StretchBlit(wxCoord dstX
, wxCoord dstY
,
1235 wxCoord dstWidth
, wxCoord dstHeight
,
1237 wxCoord srcX
, wxCoord srcY
,
1238 wxCoord srcWidth
, wxCoord srcHeight
,
1239 int rop
= wxCOPY
, bool useMask
= false,
1240 wxCoord srcMaskX
= wxDefaultCoord
, wxCoord srcMaskY
= wxDefaultCoord
)
1242 return DoStretchBlit(dstX
, dstY
, dstWidth
, dstHeight
,
1243 source
, srcX
, srcY
, srcWidth
, srcHeight
, rop
, useMask
, srcMaskX
, srcMaskY
);
1245 bool StretchBlit(const wxPoint
& dstPt
, const wxSize
& dstSize
,
1246 wxDC
*source
, const wxPoint
& srcPt
, const wxSize
& srcSize
,
1247 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcMaskPt
= wxDefaultPosition
)
1249 return DoStretchBlit(dstPt
.x
, dstPt
.y
, dstSize
.x
, dstSize
.y
,
1250 source
, srcPt
.x
, srcPt
.y
, srcSize
.x
, srcSize
.y
, rop
, useMask
, srcMaskPt
.x
, srcMaskPt
.y
);
1253 wxBitmap
GetAsBitmap(const wxRect
*subrect
= (const wxRect
*) NULL
) const
1255 return DoGetAsBitmap(subrect
);
1259 // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?)
1260 void DrawSpline(wxCoord x1
, wxCoord y1
,
1261 wxCoord x2
, wxCoord y2
,
1262 wxCoord x3
, wxCoord y3
);
1263 void DrawSpline(int n
, wxPoint points
[]);
1265 void DrawSpline(wxList
*points
) { DoDrawSpline(points
); }
1266 #endif // wxUSE_SPLINES
1268 // Eventually we will have wxUSE_GENERIC_DRAWELLIPSE
1270 //! Generic method to draw ellipses, circles and arcs with current pen and brush.
1271 /*! \param x Upper left corner of bounding box.
1272 * \param y Upper left corner of bounding box.
1273 * \param w Width of bounding box.
1274 * \param h Height of bounding box.
1275 * \param sa Starting angle of arc
1276 * (counterclockwise, start at 3 o'clock, 360 is full circle).
1277 * \param ea Ending angle of arc.
1278 * \param angle Rotation angle, the Arc will be rotated after
1279 * calculating begin and end.
1281 void DrawEllipticArcRot( wxCoord x
, wxCoord y
,
1282 wxCoord width
, wxCoord height
,
1283 double sa
= 0, double ea
= 0, double angle
= 0 )
1284 { DoDrawEllipticArcRot( x
, y
, width
, height
, sa
, ea
, angle
); }
1286 void DrawEllipticArcRot( const wxPoint
& pt
,
1288 double sa
= 0, double ea
= 0, double angle
= 0 )
1289 { DoDrawEllipticArcRot( pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
, angle
); }
1291 void DrawEllipticArcRot( const wxRect
& rect
,
1292 double sa
= 0, double ea
= 0, double angle
= 0 )
1293 { DoDrawEllipticArcRot( rect
.x
, rect
.y
, rect
.width
, rect
.height
, sa
, ea
, angle
); }
1295 virtual void DoDrawEllipticArcRot( wxCoord x
, wxCoord y
,
1296 wxCoord w
, wxCoord h
,
1297 double sa
= 0, double ea
= 0, double angle
= 0 );
1299 //! Rotates points around center.
1300 /*! This is a quite straight method, it calculates in pixels
1301 * and so it produces rounding errors.
1302 * \param points The points inside will be rotated.
1303 * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle).
1304 * \param center Center of rotation.
1306 void Rotate( wxList
* points
, double angle
, wxPoint center
= wxPoint(0,0) );
1308 // used by DrawEllipticArcRot
1309 // Careful: wxList gets filled with points you have to delete later.
1310 void CalculateEllipticPoints( wxList
* points
,
1311 wxCoord xStart
, wxCoord yStart
,
1312 wxCoord w
, wxCoord h
,
1313 double sa
, double ea
);
1316 // global DC operations
1317 // --------------------
1319 virtual void Clear() = 0;
1321 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
1322 virtual void EndDoc() { }
1324 virtual void StartPage() { }
1325 virtual void EndPage() { }
1327 #if WXWIN_COMPATIBILITY_2_6
1328 wxDEPRECATED( void BeginDrawing() );
1329 wxDEPRECATED( void EndDrawing() );
1330 #endif // WXWIN_COMPATIBILITY_2_6
1333 // set objects to use for drawing
1334 // ------------------------------
1336 virtual void SetFont(const wxFont
& font
) = 0;
1337 virtual void SetPen(const wxPen
& pen
) = 0;
1338 virtual void SetBrush(const wxBrush
& brush
) = 0;
1339 virtual void SetBackground(const wxBrush
& brush
) = 0;
1340 virtual void SetBackgroundMode(int mode
) = 0;
1342 virtual void SetPalette(const wxPalette
& palette
) = 0;
1343 #endif // wxUSE_PALETTE
1348 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1349 { DoSetClippingRegion(x
, y
, width
, height
); }
1350 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
1351 { DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1352 void SetClippingRegion(const wxRect
& rect
)
1353 { DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1354 void SetClippingRegion(const wxRegion
& region
)
1355 { DoSetClippingRegionAsRegion(region
); }
1357 virtual void DestroyClippingRegion() { ResetClipping(); }
1359 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
1360 { DoGetClippingBox(x
, y
, w
, h
); }
1361 void GetClippingBox(wxRect
& rect
) const
1363 DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
);
1369 virtual wxCoord
GetCharHeight() const = 0;
1370 virtual wxCoord
GetCharWidth() const = 0;
1372 // only works for single line strings
1373 void GetTextExtent(const wxString
& string
,
1374 wxCoord
*x
, wxCoord
*y
,
1375 wxCoord
*descent
= NULL
,
1376 wxCoord
*externalLeading
= NULL
,
1377 const wxFont
*theFont
= NULL
) const
1378 { DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
1380 wxSize
GetTextExtent(const wxString
& string
) const
1383 DoGetTextExtent(string
, &w
, &h
);
1384 return wxSize(w
, h
);
1387 // works for single as well as multi-line strings
1388 virtual void GetMultiLineTextExtent(const wxString
& string
,
1391 wxCoord
*heightLine
= NULL
,
1392 const wxFont
*font
= NULL
) const;
1394 wxSize
GetMultiLineTextExtent(const wxString
& string
) const
1397 GetMultiLineTextExtent(string
, &w
, &h
);
1398 return wxSize(w
, h
);
1401 // Measure cumulative width of text after each character
1402 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
1403 { return DoGetPartialTextExtents(text
, widths
); }
1406 // size and resolution
1407 // -------------------
1410 void GetSize(int *width
, int *height
) const
1411 { DoGetSize(width
, height
); }
1412 wxSize
GetSize() const
1417 return wxSize(w
, h
);
1421 void GetSizeMM(int* width
, int* height
) const
1422 { DoGetSizeMM(width
, height
); }
1423 wxSize
GetSizeMM() const
1426 DoGetSizeMM(&w
, &h
);
1428 return wxSize(w
, h
);
1431 // query DC capabilities
1432 // ---------------------
1434 virtual bool CanDrawBitmap() const = 0;
1435 virtual bool CanGetTextExtent() const = 0;
1438 virtual int GetDepth() const = 0;
1440 // Resolution in Pixels per inch
1441 virtual wxSize
GetPPI() const = 0;
1443 virtual bool Ok() const { return IsOk(); }
1444 virtual bool IsOk() const { return m_ok
; }
1446 // accessors and setters
1447 // ---------------------
1449 virtual int GetBackgroundMode() const { return m_backgroundMode
; }
1450 virtual const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
1451 virtual const wxBrush
& GetBrush() const { return m_brush
; }
1452 virtual const wxFont
& GetFont() const { return m_font
; }
1453 virtual const wxPen
& GetPen() const { return m_pen
; }
1455 virtual const wxColour
& GetTextForeground() const { return m_textForegroundColour
; }
1456 virtual const wxColour
& GetTextBackground() const { return m_textBackgroundColour
; }
1457 virtual void SetTextForeground(const wxColour
& colour
)
1458 { m_textForegroundColour
= colour
; }
1459 virtual void SetTextBackground(const wxColour
& colour
)
1460 { m_textBackgroundColour
= colour
; }
1463 // coordinates conversions and transforms
1464 // --------------------------------------
1466 virtual wxCoord
DeviceToLogicalX(wxCoord x
) const;
1467 virtual wxCoord
DeviceToLogicalY(wxCoord y
) const;
1468 virtual wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
1469 virtual wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
1470 virtual wxCoord
LogicalToDeviceX(wxCoord x
) const;
1471 virtual wxCoord
LogicalToDeviceY(wxCoord y
) const;
1472 virtual wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
1473 virtual wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
1475 virtual void SetMapMode(int mode
);
1476 virtual int GetMapMode() const { return m_mappingMode
; }
1478 virtual void SetUserScale(double x
, double y
);
1479 virtual void GetUserScale(double *x
, double *y
) const
1481 if ( x
) *x
= m_userScaleX
;
1482 if ( y
) *y
= m_userScaleY
;
1485 virtual void SetLogicalScale(double x
, double y
);
1486 virtual void GetLogicalScale(double *x
, double *y
)
1488 if ( x
) *x
= m_logicalScaleX
;
1489 if ( y
) *y
= m_logicalScaleY
;
1492 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
1493 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
1494 { DoGetLogicalOrigin(x
, y
); }
1495 wxPoint
GetLogicalOrigin() const
1496 { wxCoord x
, y
; DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
1498 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
1499 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
1500 { DoGetDeviceOrigin(x
, y
); }
1501 wxPoint
GetDeviceOrigin() const
1502 { wxCoord x
, y
; DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
1504 virtual void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
);
1506 virtual void ComputeScaleAndOrigin();
1508 // this needs to overidden if the axis is inverted (such
1509 // as when using Postscript, where 0,0 is the lower left
1510 // corner, not the upper left).
1511 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
1513 // logical functions
1514 // ---------------------------
1516 virtual int GetLogicalFunction() const { return m_logicalFunction
; }
1517 virtual void SetLogicalFunction(int function
) = 0;
1522 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
1524 if ( m_isBBoxValid
)
1526 if ( x
< m_minX
) m_minX
= x
;
1527 if ( y
< m_minY
) m_minY
= y
;
1528 if ( x
> m_maxX
) m_maxX
= x
;
1529 if ( y
> m_maxY
) m_maxY
= y
;
1533 m_isBBoxValid
= true;
1542 void ResetBoundingBox()
1544 m_isBBoxValid
= false;
1546 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
1549 // Get the final bounding box of the PostScript or Metafile picture.
1550 wxCoord
MinX() const { return m_minX
; }
1551 wxCoord
MaxX() const { return m_maxX
; }
1552 wxCoord
MinY() const { return m_minY
; }
1553 wxCoord
MaxY() const { return m_maxY
; }
1555 // misc old functions
1556 // ------------------
1558 #if WXWIN_COMPATIBILITY_2_8
1559 // for compatibility with the old code when wxCoord was long everywhere
1560 wxDEPRECATED( void GetTextExtent(const wxString
& string
,
1562 long *descent
= NULL
,
1563 long *externalLeading
= NULL
,
1564 const wxFont
*theFont
= NULL
) const );
1565 wxDEPRECATED( void GetLogicalOrigin(long *x
, long *y
) const );
1566 wxDEPRECATED( void GetDeviceOrigin(long *x
, long *y
) const );
1567 wxDEPRECATED( void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const );
1568 #endif // WXWIN_COMPATIBILITY_2_8
1570 // RTL related functions
1571 // ---------------------
1573 // get or change the layout direction (LTR or RTL) for this dc,
1574 // wxLayout_Default is returned if layout direction is not supported
1575 virtual wxLayoutDirection
GetLayoutDirection() const
1576 { return wxLayout_Default
; }
1577 virtual void SetLayoutDirection(wxLayoutDirection
WXUNUSED(dir
))
1581 // the pure virtual functions which should be implemented by wxDC
1582 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
1583 int style
= wxFLOOD_SURFACE
) = 0;
1585 virtual void DoGradientFillLinear(const wxRect
& rect
,
1586 const wxColour
& initialColour
,
1587 const wxColour
& destColour
,
1588 wxDirection nDirection
= wxEAST
);
1590 virtual void DoGradientFillConcentric(const wxRect
& rect
,
1591 const wxColour
& initialColour
,
1592 const wxColour
& destColour
,
1593 const wxPoint
& circleCenter
);
1595 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
1597 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
1598 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
1600 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
1601 wxCoord x2
, wxCoord y2
,
1602 wxCoord xc
, wxCoord yc
) = 0;
1603 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
1604 wxCoord width
, wxCoord height
);
1605 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
1606 double sa
, double ea
) = 0;
1608 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
1609 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
1610 wxCoord width
, wxCoord height
,
1612 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
1613 wxCoord width
, wxCoord height
) = 0;
1615 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
1617 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
1618 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
1619 bool useMask
= false) = 0;
1621 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
1622 virtual void DoDrawRotatedText(const wxString
& text
,
1623 wxCoord x
, wxCoord y
, double angle
) = 0;
1625 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
1626 wxCoord width
, wxCoord height
,
1628 wxCoord xsrc
, wxCoord ysrc
,
1630 bool useMask
= false,
1631 wxCoord xsrcMask
= wxDefaultCoord
,
1632 wxCoord ysrcMask
= wxDefaultCoord
) = 0;
1634 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
1635 wxCoord dstWidth
, wxCoord dstHeight
,
1637 wxCoord xsrc
, wxCoord ysrc
,
1638 wxCoord srcWidth
, wxCoord srcHeight
,
1640 bool useMask
= false,
1641 wxCoord xsrcMask
= wxDefaultCoord
,
1642 wxCoord ysrcMask
= wxDefaultCoord
);
1644 virtual wxBitmap
DoGetAsBitmap(const wxRect
*WXUNUSED(subrect
)) const
1645 { return wxNullBitmap
; }
1647 virtual void DoGetSize(int *width
, int *height
) const = 0;
1648 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
1650 virtual void DoDrawLines(int n
, wxPoint points
[],
1651 wxCoord xoffset
, wxCoord yoffset
) = 0;
1652 virtual void DoDrawPolygon(int n
, wxPoint points
[],
1653 wxCoord xoffset
, wxCoord yoffset
,
1654 int fillStyle
= wxODDEVEN_RULE
) = 0;
1655 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
1656 wxCoord xoffset
, wxCoord yoffset
,
1659 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
) = 0;
1660 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
1661 wxCoord width
, wxCoord height
) = 0;
1663 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
1664 wxCoord
*w
, wxCoord
*h
) const
1671 *w
= m_clipX2
- m_clipX1
;
1673 *h
= m_clipY2
- m_clipY1
;
1676 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
1678 if ( x
) *x
= m_logicalOriginX
;
1679 if ( y
) *y
= m_logicalOriginY
;
1682 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
1684 if ( x
) *x
= m_deviceOriginX
;
1685 if ( y
) *y
= m_deviceOriginY
;
1688 virtual void DoGetTextExtent(const wxString
& string
,
1689 wxCoord
*x
, wxCoord
*y
,
1690 wxCoord
*descent
= NULL
,
1691 wxCoord
*externalLeading
= NULL
,
1692 const wxFont
*theFont
= NULL
) const = 0;
1694 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
1697 virtual void DoDrawSpline(wxList
*points
);
1701 // unset clipping variables (after clipping region was destroyed)
1702 void ResetClipping()
1706 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
1713 bool m_isInteractive
:1;
1714 bool m_isBBoxValid
:1;
1716 // coordinate system variables
1718 // TODO short descriptions of what exactly they are would be nice...
1720 wxCoord m_logicalOriginX
, m_logicalOriginY
;
1721 wxCoord m_deviceOriginX
, m_deviceOriginY
; // Usually 0,0, can be change by user
1723 wxCoord m_deviceLocalOriginX
, m_deviceLocalOriginY
; // non-zero if native top-left corner
1724 // is not at 0,0. This was the case under
1725 // Mac's GrafPorts (coordinate system
1726 // used toplevel window's origin) and
1727 // e.g. for Postscript, where the native
1728 // origin in the bottom left corner.
1729 double m_logicalScaleX
, m_logicalScaleY
;
1730 double m_userScaleX
, m_userScaleY
;
1731 double m_scaleX
, m_scaleY
; // calculated from logical scale and user scale
1733 // Used by SetAxisOrientation() to invert the axes
1734 int m_signX
, m_signY
;
1736 // what is a mm on a screen you don't know the size of?
1737 double m_mm_to_pix_x
,
1740 // bounding and clipping boxes
1741 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
1742 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
1744 int m_logicalFunction
;
1745 int m_backgroundMode
;
1751 wxBrush m_backgroundBrush
;
1752 wxColour m_textForegroundColour
;
1753 wxColour m_textBackgroundColour
;
1757 wxPalette m_palette
;
1758 bool m_hasCustomPalette
;
1759 #endif // wxUSE_PALETTE
1762 DECLARE_NO_COPY_CLASS(wxDCBase
)
1763 DECLARE_ABSTRACT_CLASS(wxDCBase
)
1766 #endif // wxUSE_NEW_DC
1768 // ----------------------------------------------------------------------------
1769 // now include the declaration of wxDC class
1770 // ----------------------------------------------------------------------------
1772 #if defined(__WXPALMOS__)
1773 #include "wx/palmos/dc.h"
1774 #elif defined(__WXMSW__)
1775 #include "wx/msw/dc.h"
1776 #elif defined(__WXMOTIF__)
1777 #include "wx/motif/dc.h"
1778 #elif defined(__WXGTK20__)
1779 #include "wx/gtk/dc.h"
1780 #elif defined(__WXGTK__)
1781 #include "wx/gtk1/dc.h"
1782 #elif defined(__WXX11__)
1783 #include "wx/x11/dc.h"
1784 #elif defined(__WXMGL__)
1785 #include "wx/mgl/dc.h"
1786 #elif defined(__WXDFB__)
1787 #include "wx/dfb/dc.h"
1788 #elif defined(__WXMAC__)
1789 #include "wx/mac/dc.h"
1790 #elif defined(__WXCOCOA__)
1791 #include "wx/cocoa/dc.h"
1792 #elif defined(__WXPM__)
1793 #include "wx/os2/dc.h"
1796 #if wxUSE_GRAPHICS_CONTEXT
1797 #include "wx/dcgraph.h"
1800 // ----------------------------------------------------------------------------
1801 // helper class: you can use it to temporarily change the DC text colour and
1802 // restore it automatically when the object goes out of scope
1803 // ----------------------------------------------------------------------------
1805 class WXDLLEXPORT wxDCTextColourChanger
1808 wxDCTextColourChanger(wxDC
& dc
) : m_dc(dc
), m_colFgOld() { }
1810 wxDCTextColourChanger(wxDC
& dc
, const wxColour
& col
) : m_dc(dc
)
1815 ~wxDCTextColourChanger()
1817 if ( m_colFgOld
.Ok() )
1818 m_dc
.SetTextForeground(m_colFgOld
);
1821 void Set(const wxColour
& col
)
1823 if ( !m_colFgOld
.Ok() )
1824 m_colFgOld
= m_dc
.GetTextForeground();
1825 m_dc
.SetTextForeground(col
);
1831 wxColour m_colFgOld
;
1833 DECLARE_NO_COPY_CLASS(wxDCTextColourChanger
)
1836 // ----------------------------------------------------------------------------
1837 // helper class: you can use it to temporarily change the DC pen and
1838 // restore it automatically when the object goes out of scope
1839 // ----------------------------------------------------------------------------
1841 class WXDLLEXPORT wxDCPenChanger
1844 wxDCPenChanger(wxDC
& dc
, const wxPen
& pen
) : m_dc(dc
), m_penOld(dc
.GetPen())
1851 if ( m_penOld
.Ok() )
1852 m_dc
.SetPen(m_penOld
);
1860 DECLARE_NO_COPY_CLASS(wxDCPenChanger
)
1863 // ----------------------------------------------------------------------------
1864 // helper class: you can use it to temporarily change the DC brush and
1865 // restore it automatically when the object goes out of scope
1866 // ----------------------------------------------------------------------------
1868 class WXDLLEXPORT wxDCBrushChanger
1871 wxDCBrushChanger(wxDC
& dc
, const wxBrush
& brush
) : m_dc(dc
), m_brushOld(dc
.GetBrush())
1873 m_dc
.SetBrush(brush
);
1878 if ( m_brushOld
.Ok() )
1879 m_dc
.SetBrush(m_brushOld
);
1887 DECLARE_NO_COPY_CLASS(wxDCBrushChanger
)
1890 // ----------------------------------------------------------------------------
1891 // another small helper class: sets the clipping region in its ctor and
1892 // destroys it in the dtor
1893 // ----------------------------------------------------------------------------
1895 class WXDLLEXPORT wxDCClipper
1898 wxDCClipper(wxDC
& dc
, const wxRegion
& r
) : m_dc(dc
)
1899 { dc
.SetClippingRegion(r
); }
1900 wxDCClipper(wxDC
& dc
, const wxRect
& r
) : m_dc(dc
)
1901 { dc
.SetClippingRegion(r
.x
, r
.y
, r
.width
, r
.height
); }
1902 wxDCClipper(wxDC
& dc
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) : m_dc(dc
)
1903 { dc
.SetClippingRegion(x
, y
, w
, h
); }
1905 ~wxDCClipper() { m_dc
.DestroyClippingRegion(); }
1910 DECLARE_NO_COPY_CLASS(wxDCClipper
)
1913 #endif // _WX_DC_H_BASE_