1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
13 #define wxUSE_NEW_DC 0
17 //-----------------------------------------------------------------------------
19 //-----------------------------------------------------------------------------
21 class WXDLLIMPEXP_CORE wxImplDC
;
23 class WXDLLIMPEXP_CORE wxDCFactory
27 virtual ~wxDCFactory() {}
29 virtual wxImplDC
* CreateWindowDC( wxWindow
*window
) = 0;
30 virtual wxImplDC
* CreateClientDC( wxWindow
*window
) = 0;
31 virtual wxImplDC
* CreatePaintDC( wxWindow
*window
) = 0;
32 virtual wxImplDC
* CreateMemoryDC() = 0;
33 virtual wxImplDC
* CreateMemoryDC( wxBitmap
&bitmap
) = 0;
34 virtual wxImplDC
* CreateMemoryDC( wxDC
*dc
) = 0;
36 static void SetDCFactory( wxDCFactory
*factory
);
37 static wxDCFactory
*GetFactory();
39 static wxDCFactory
*m_factory
;
42 //-----------------------------------------------------------------------------
44 //-----------------------------------------------------------------------------
46 class WXDLLIMPEXP_CORE wxDCFactory
49 wxNativeDCFactory() {}
51 virtual wxImplDC
* CreateWindowDC( wxWindow
*window
);
52 virtual wxImplDC
* CreateClientDC( wxWindow
*window
);
53 virtual wxImplDC
* CreatePaintDC( wxWindow
*window
);
54 virtual wxImplDC
* CreateMemoryDC();
55 virtual wxImplDC
* CreateMemoryDC( wxBitmap
&bitmap
);
56 virtual wxImplDC
* CreateMemoryDC( wxDC
*dc
);
59 //-----------------------------------------------------------------------------
61 //-----------------------------------------------------------------------------
63 class WXDLLIMPEXP_CORE wxImplDC
: public wxObject
66 wxImplDC( wxDC
*owner
);
69 wxDC
*GetOwner() { return m_owner
; }
71 virtual bool IsOk() const { return m_ok
; }
75 virtual bool CanDrawBitmap() const = 0;
76 virtual bool CanGetTextExtent() const = 0;
78 // query dimension, colour deps, resolution
80 virtual void DoGetSize(int *width
, int *height
) const = 0;
81 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
83 virtual int GetDepth() const = 0;
84 virtual wxSize
GetPPI() const = 0;
86 // Right-To-Left (RTL) modes
88 virtual void SetLayoutDirection(wxLayoutDirection
WXUNUSED(dir
)) { }
89 virtual wxLayoutDirection
GetLayoutDirection() const { return wxLayout_Default
; }
93 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
94 virtual void EndDoc() { }
96 virtual void StartPage() { }
97 virtual void EndPage() { }
101 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
);
105 if ( x
< m_minX
) m_minX
= x
;
106 if ( y
< m_minY
) m_minY
= y
;
107 if ( x
> m_maxX
) m_maxX
= x
;
108 if ( y
> m_maxY
) m_maxY
= y
;
112 m_isBBoxValid
= true;
120 void ResetBoundingBox();
122 m_isBBoxValid
= false;
124 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
127 wxCoord
MinX() const { return m_minX
; }
128 wxCoord
MaxX() const { return m_maxX
; }
129 wxCoord
MinY() const { return m_minY
; }
130 wxCoord
MaxY() const { return m_maxY
; }
132 // setters and getters
134 virtual void SetFont(const wxFont
& font
) = 0;
135 virtual const wxFont
& GetFont() const { return m_font
; }
137 virtual void SetPen(const wxPen
& pen
) = 0;
138 virtual const wxPen
& GetPen() const { return m_pen
; }
140 virtual void SetBrush(const wxBrush
& brush
) = 0;
141 virtual const wxBrush
& GetBrush() const { return m_brush
; }
143 virtual void SetBackground(const wxBrush
& brush
) = 0;
144 virtual const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
146 virtual void SetBackgroundMode(int mode
) = 0;
147 virtual int GetBackgroundMode() const { return m_backgroundMode
; }
149 virtual void SetTextForeground(const wxColour
& colour
)
150 { m_textForegroundColour
= colour
; }
151 virtual const wxColour
& GetTextForeground() const { return m_textForegroundColour
; }
153 virtual void SetTextBackground(const wxColour
& colour
)
154 { m_textBackgroundColour
= colour
; }
155 virtual const wxColour
& GetTextBackground() const { return m_textBackgroundColour
; }
158 virtual void SetPalette(const wxPalette
& palette
) = 0;
159 #endif // wxUSE_PALETTE
163 virtual void SetLogicalFunction(int function
) = 0;
164 virtual int GetLogicalFunction() const { return m_logicalFunction
; }
168 virtual wxCoord
GetCharHeight() const = 0;
169 virtual wxCoord
GetCharWidth() const = 0;
170 virtual void DoGetTextExtent(const wxString
& string
,
171 wxCoord
*x
, wxCoord
*y
,
172 wxCoord
*descent
= NULL
,
173 wxCoord
*externalLeading
= NULL
,
174 const wxFont
*theFont
= NULL
) const = 0;
175 virtual void GetMultiLineTextExtent(const wxString
& string
,
178 wxCoord
*heightLine
= NULL
,
179 const wxFont
*font
= NULL
) const;
180 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
184 virtual void Clear() = 0;
188 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
189 wxCoord width
, wxCoord height
) = 0;
190 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
) = 0;
192 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
193 wxCoord
*w
, wxCoord
*h
) const
200 *w
= m_clipX2
- m_clipX1
;
202 *h
= m_clipY2
- m_clipY1
;
205 virtual void DestroyClippingRegion() { ResetClipping(); }
208 // coordinates conversions and transforms
210 virtual wxCoord
DeviceToLogicalX(wxCoord x
) const;
211 virtual wxCoord
DeviceToLogicalY(wxCoord y
) const;
212 virtual wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
213 virtual wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
214 virtual wxCoord
LogicalToDeviceX(wxCoord x
) const;
215 virtual wxCoord
LogicalToDeviceY(wxCoord y
) const;
216 virtual wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
217 virtual wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
219 virtual void SetMapMode(int mode
);
220 virtual int GetMapMode() const { return m_mappingMode
; }
222 virtual void SetUserScale(double x
, double y
);
223 virtual void GetUserScale(double *x
, double *y
) const
225 if ( x
) *x
= m_userScaleX
;
226 if ( y
) *y
= m_userScaleY
;
229 virtual void SetLogicalScale(double x
, double y
);
230 virtual void GetLogicalScale(double *x
, double *y
)
232 if ( x
) *x
= m_logicalScaleX
;
233 if ( y
) *y
= m_logicalScaleY
;
236 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
237 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
239 if ( x
) *x
= m_logicalOriginX
;
240 if ( y
) *y
= m_logicalOriginY
;
243 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
244 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
246 if ( x
) *x
= m_deviceOriginX
;
247 if ( y
) *y
= m_deviceOriginY
;
250 virtual void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
);
252 virtual void ComputeScaleAndOrigin();
254 // this needs to overidden if the axis is inverted
255 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
257 // ---------------------------------------------------------
258 // the actual drawing API
260 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
261 int style
= wxFLOOD_SURFACE
) = 0;
263 virtual void DoGradientFillLinear(const wxRect
& rect
,
264 const wxColour
& initialColour
,
265 const wxColour
& destColour
,
266 wxDirection nDirection
= wxEAST
);
268 virtual void DoGradientFillConcentric(const wxRect
& rect
,
269 const wxColour
& initialColour
,
270 const wxColour
& destColour
,
271 const wxPoint
& circleCenter
);
273 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
275 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
276 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
278 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
279 wxCoord x2
, wxCoord y2
,
280 wxCoord xc
, wxCoord yc
) = 0;
281 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
282 wxCoord width
, wxCoord height
);
283 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
284 double sa
, double ea
) = 0;
286 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
287 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
288 wxCoord width
, wxCoord height
,
290 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
291 wxCoord width
, wxCoord height
) = 0;
293 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
295 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
296 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
297 bool useMask
= false) = 0;
299 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
300 virtual void DoDrawRotatedText(const wxString
& text
,
301 wxCoord x
, wxCoord y
, double angle
) = 0;
303 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
304 wxCoord width
, wxCoord height
,
306 wxCoord xsrc
, wxCoord ysrc
,
308 bool useMask
= false,
309 wxCoord xsrcMask
= wxDefaultCoord
,
310 wxCoord ysrcMask
= wxDefaultCoord
) = 0;
312 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
313 wxCoord dstWidth
, wxCoord dstHeight
,
315 wxCoord xsrc
, wxCoord ysrc
,
316 wxCoord srcWidth
, wxCoord srcHeight
,
318 bool useMask
= false,
319 wxCoord xsrcMask
= wxDefaultCoord
,
320 wxCoord ysrcMask
= wxDefaultCoord
);
322 virtual wxBitmap
DoGetAsBitmap(const wxRect
*WXUNUSED(subrect
)) const
323 { return wxNullBitmap
; }
326 virtual void DoDrawLines(int n
, wxPoint points
[],
327 wxCoord xoffset
, wxCoord yoffset
) = 0;
328 virtual void DoDrawPolygon(int n
, wxPoint points
[],
329 wxCoord xoffset
, wxCoord yoffset
,
330 int fillStyle
= wxODDEVEN_RULE
) = 0;
331 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
332 wxCoord xoffset
, wxCoord yoffset
,
338 virtual void DoDrawSpline(wxList
*points
);
345 // unset clipping variables (after clipping region was destroyed)
350 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
357 bool m_isInteractive
:1;
358 bool m_isBBoxValid
:1;
360 // coordinate system variables
362 wxCoord m_logicalOriginX
, m_logicalOriginY
;
363 wxCoord m_deviceOriginX
, m_deviceOriginY
; // Usually 0,0, can be change by user
365 wxCoord m_deviceLocalOriginX
, m_deviceLocalOriginY
; // non-zero if native top-left corner
366 // is not at 0,0. This was the case under
367 // Mac's GrafPorts (coordinate system
368 // used toplevel window's origin) and
369 // e.g. for Postscript, where the native
370 // origin in the bottom left corner.
371 double m_logicalScaleX
, m_logicalScaleY
;
372 double m_userScaleX
, m_userScaleY
;
373 double m_scaleX
, m_scaleY
; // calculated from logical scale and user scale
375 int m_signX
, m_signY
; // Used by SetAxisOrientation() to invert the axes
377 // what is a mm on a screen you don't know the size of?
378 double m_mm_to_pix_x
,
381 // bounding and clipping boxes
382 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
383 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
385 int m_logicalFunction
;
386 int m_backgroundMode
;
391 wxBrush m_backgroundBrush
;
392 wxColour m_textForegroundColour
;
393 wxColour m_textBackgroundColour
;
398 bool m_hasCustomPalette
;
399 #endif // wxUSE_PALETTE
402 DECLARE_ABSTRACT_CLASS(wxImplDC
)
406 class wxDC
: public wxObject
409 wxDC() { m_pimpl
= NULL
; }
412 { return m_pimpl
&& m_pimpl
->IsOk(); }
414 // query capabilities
416 bool CanDrawBitmap() const
417 { return m_pimpl
->CanDrawBitmap(); }
418 bool CanGetTextExtent() const
419 { return m_pimpl
->CanGetTextExtent(); }
421 // query dimension, colour deps, resolution
423 void GetSize(int *width
, int *height
) const
424 { m_pimpl
->DoGetSize(width
, height
); }
426 wxSize
GetSize() const
429 m_pimpl
->DoGetSize(&w
, &h
);
433 void GetSizeMM(int* width
, int* height
) const
434 { m_pimpl
->DoGetSizeMM(width
, height
); }
435 wxSize
GetSizeMM() const
438 m_pimpl
->DoGetSizeMM(&w
, &h
);
443 { return m_pimpl
->GetDepth(); }
444 wxSize
GetPPI() const
445 { return m_pimpl
->GetPPI(); }
447 // Right-To-Left (RTL) modes
449 void SetLayoutDirection(wxLayoutDirection dir
)
450 { m_pimpl
->SetLayoutDirection( dir
); }
451 wxLayoutDirection
GetLayoutDirection() const
452 { return m_pimpl
->GetLayoutDirection(); }
456 bool StartDoc(const wxString
& message
)
457 { return m_pimpl
->StartDoc(message
); }
459 { m_pimpl
->EndDoc(); }
462 { m_pimpl
->StartPage(); }
464 { m_pimpl
->EndPage(); }
468 void CalcBoundingBox(wxCoord x
, wxCoord y
)
469 { m_pimpl
->CalcBoundingBox(x
,y
); }
470 void ResetBoundingBox()
471 { m_pimpl
->ResetBoundingBox(); }
474 { return m_pimpl
->MinX(); }
476 { return m_pimpl
->MaxX(); }
478 { return m_pimpl
->MinY(); }
480 { return m_pimpl
->MaxY(); }
482 // setters and getters
484 void SetFont(const wxFont
& font
)
485 { m_pimpl
->SetFont( font
); }
486 const wxFont
& GetFont() const
487 { return m_pimpl
->GetFont(); }
489 void SetPen(const wxPen
& pen
)
490 { m_pimpl
->SetPen( pen
); }
491 const wxPen
& GetPen() const
492 { return m_pimpl
->GetPen(); }
494 void SetBrush(const wxBrush
& brush
)
495 { m_pimpl
->SetBrush( brush
); }
496 const wxBrush
& GetBrush() const
497 { return m_pimpl
->GetBrush(); }
499 void SetBackground(const wxBrush
& brush
)
500 { m_pimpl
->SetBackground( brush
); }
501 const wxBrush
& GetBackground() const
502 { return m_pimpl
->GetBackground(); }
504 void SetBackgroundMode(int mode
)
505 { m_pimpl
->SetBackground( mode
); }
506 int GetBackgroundMode() const
507 { return m_pimpl
->GetBackground(); }
509 void SetTextForeground(const wxColour
& colour
)
510 { m_pimpl
->SetTextForeground(colour
); }
511 const wxColour
& GetTextForeground() const
512 { return m_pimpl
->GetTextForeground(); }
514 void SetTextBackground(const wxColour
& colour
)
515 { m_pimpl
->SetTextBackground(colour
); }
516 const wxColour
& GetTextBackground() const
517 { return m_pimpl
->GetTextBackground(); }
520 void SetPalette(const wxPalette
& palette
)
521 { m_pimpl
->SetPalette(palette
); }
522 #endif // wxUSE_PALETTE
526 void SetLogicalFunction(int function
)
527 { m_pimpl
->SetLogicalFunction(function
); }
528 int GetLogicalFunction() const
529 { return m_pimpl
->GetLogicalFunction(); }
533 wxCoord
GetCharHeight() const
534 { return m_pimpl
->GetCharHeight(); }
535 wxCoord
GetCharWidth() const
536 { return m_pimpl
->GetCharWidth(); }
538 void GetTextExtent(const wxString
& string
,
539 wxCoord
*x
, wxCoord
*y
,
540 wxCoord
*descent
= NULL
,
541 wxCoord
*externalLeading
= NULL
,
542 const wxFont
*theFont
= NULL
) const
543 { m_pimpl
->DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
545 wxSize
GetTextExtent(const wxString
& string
) const
548 m_pimpl
->DoGetTextExtent(string
, &w
, &h
);
552 void GetMultiLineTextExtent(const wxString
& string
,
555 wxCoord
*heightLine
= NULL
,
556 const wxFont
*font
= NULL
) const
557 { m_pimpl
->GetMultiLineTextExtent( string
, width
, height
, heightLine
, font
); }
559 wxSize
GetMultiLineTextExtent(const wxString
& string
) const
562 m_pimpl
->GetMultiLineTextExtent(string
, &w
, &h
);
566 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
567 { return m_pimpl
->DoGetPartialTextExtents(text
, widths
); }
572 { m_pimpl
->Clear(); }
576 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
577 { m_pimpl
->DoSetClippingRegion(x
, y
, width
, height
); }
578 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
579 { m_pimpl
->DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
580 void SetClippingRegion(const wxRect
& rect
)
581 { m_pimpl
->DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
582 void SetClippingRegion(const wxRegion
& region
)
583 { m_pimpl
->DoSetClippingRegionAsRegion(region
); }
585 void DestroyClippingRegion()
586 { m_pimpl
->DestroyClippingRegion(); }
588 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
589 { m_pimpl
->DoGetClippingBox(x
, y
, w
, h
); }
590 void GetClippingBox(wxRect
& rect
) const
591 { m_pimpl
->DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
); }
593 // coordinates conversions and transforms
595 wxCoord
DeviceToLogicalX(wxCoord x
) const
596 { return m_pimpl
->DeviceToLogicalX(x
); }
597 wxCoord
DeviceToLogicalY(wxCoord y
) const;
598 { return m_pimpl
->DeviceToLogicalY(y
); }
599 wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
600 { return m_pimpl
->DeviceToLogicalXRel(x
); }
601 wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
602 { return m_pimpl
->DeviceToLogicalYRel(y
); }
603 wxCoord
LogicalToDeviceX(wxCoord x
) const;
604 { return m_pimpl
->LogicalToDeviceX(x
); }
605 wxCoord
LogicalToDeviceY(wxCoord y
) const;
606 { return m_pimpl
->LogicalToDeviceY(y
); }
607 wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
608 { return m_pimpl
->LogicalToDeviceXRel(x
); }
609 wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
610 { return m_pimpl
->LogicalToDeviceYRel(y
); }
612 void SetMapMode(int mode
)
613 { m_pimpl
->SetMapMode(mode
); }
614 int GetMapMode() const
615 { return m_pimpl
->GetMapMode(); }
617 void SetUserScale(double x
, double y
)
618 { m_pimpl
->SetUserScale(x
,y
); }
619 void GetUserScale(double *x
, double *y
) const
620 { m_pimpl
->GetUserScale( x
, y
); }
622 void SetLogicalScale(double x
, double y
)
623 { m_pimpl
->SetLogicalScale( x
, y
); }
624 void GetLogicalScale(double *x
, double *y
)
625 { m_pimpl
->GetLogicalScale( x
, y
); }
627 void SetLogicalOrigin(wxCoord x
, wxCoord y
)
628 { m_pimpl
->SetLogicalOrigin(x
,y
); }
629 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
630 { m_pimpl
->DoGetLogicalOrigin(x
, y
); }
631 wxPoint
GetLogicalOrigin() const
632 { wxCoord x
, y
; m_pimpl
->DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
634 void SetDeviceOrigin(wxCoord x
, wxCoord y
)
635 { m_pimpl
->SetDeviceOrigin( x
, y
); }
636 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
637 { m_pimpl
->DoGetDeviceOrigin(x
, y
); }
638 wxPoint
GetDeviceOrigin() const
639 { wxCoord x
, y
; m_pimpl
->DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
641 void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
)
642 { m_pimpl
->SetAxisOrientation(xLeftRight
, yBottomUp
); }
645 void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
)
646 { m_pimpl
->SetDeviceLocalOrigin( x
, y
); }
649 // draw generic object
651 void DrawObject(wxDrawObject
* drawobject
)
653 drawobject
->Draw(*this);
654 CalcBoundingBox(drawobject
->MinX(),drawobject
->MinY());
655 CalcBoundingBox(drawobject
->MaxX(),drawobject
->MaxY());
658 // -----------------------------------------------
659 // the actual drawing API
661 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
662 int style
= wxFLOOD_SURFACE
)
663 { return m_pimpl
->DoFloodFill(x
, y
, col
, style
); }
664 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
665 int style
= wxFLOOD_SURFACE
)
666 { return m_pimpl
->DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
668 // fill the area specified by rect with a radial gradient, starting from
669 // initialColour in the centre of the cercle and fading to destColour.
670 void GradientFillConcentric(const wxRect
& rect
,
671 const wxColour
& initialColour
,
672 const wxColour
& destColour
)
673 { m_pimpl
->GradientFillConcentric(rect
, initialColour
, destColour
,
674 wxPoint(rect
.GetWidth() / 2,
675 rect
.GetHeight() / 2)); }
677 void GradientFillConcentric(const wxRect
& rect
,
678 const wxColour
& initialColour
,
679 const wxColour
& destColour
,
680 const wxPoint
& circleCenter
)
681 { m_pimpl
->DoGradientFillConcentric(rect
, initialColour
, destColour
, circleCenter
); }
683 // fill the area specified by rect with a linear gradient
684 void GradientFillLinear(const wxRect
& rect
,
685 const wxColour
& initialColour
,
686 const wxColour
& destColour
,
687 wxDirection nDirection
= wxEAST
)
688 { m_pimpl
->DoGradientFillLinear(rect
, initialColour
, destColour
, nDirection
); }
690 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
691 { return m_pimpl
->DoGetPixel(x
, y
, col
); }
692 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
693 { return m_pimpl
->DoGetPixel(pt
.x
, pt
.y
, col
); }
695 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
696 { m_pimpl
->DoDrawLine(x1
, y1
, x2
, y2
); }
697 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
698 { m_pimpl
->DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
700 void CrossHair(wxCoord x
, wxCoord y
)
701 { m_pimpl
->DoCrossHair(x
, y
); }
702 void CrossHair(const wxPoint
& pt
)
703 { m_pimpl
->DoCrossHair(pt
.x
, pt
.y
); }
705 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
706 wxCoord xc
, wxCoord yc
)
707 { m_pimpl
->DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
708 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
709 { m_pimpl
->DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
711 void DrawCheckMark(wxCoord x
, wxCoord y
,
712 wxCoord width
, wxCoord height
)
713 { m_pimpl
->DoDrawCheckMark(x
, y
, width
, height
); }
714 void DrawCheckMark(const wxRect
& rect
)
715 { m_pimpl
->DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
717 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
718 double sa
, double ea
)
719 { m_pimpl
->DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
720 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
721 double sa
, double ea
)
722 { m_pimpl
->DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
724 void DrawPoint(wxCoord x
, wxCoord y
)
725 { m_pimpl
->DoDrawPoint(x
, y
); }
726 void DrawPoint(const wxPoint
& pt
)
727 { m_pimpl
->DoDrawPoint(pt
.x
, pt
.y
); }
729 void DrawLines(int n
, wxPoint points
[],
730 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
731 { m_pimpl
->DoDrawLines(n
, points
, xoffset
, yoffset
); }
732 void DrawLines(const wxList
*list
,
733 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
734 { m_pimpl
->DrawLines( list
, xoffset
, yoffset
); }
736 void DrawPolygon(int n
, wxPoint points
[],
737 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
738 int fillStyle
= wxODDEVEN_RULE
)
739 { m_pimpl
->DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
741 void DrawPolygon(const wxList
*list
,
742 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
743 int fillStyle
= wxODDEVEN_RULE
)
744 { m_pimpl
->DrawPolygon( list
, xoffset
, yoffset
, fillStyle
); }
746 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
747 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
748 int fillStyle
= wxODDEVEN_RULE
)
749 { m_pimpl
->DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
751 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
752 { m_pimpl
->DoDrawRectangle(x
, y
, width
, height
); }
753 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
754 { m_pimpl
->DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
755 void DrawRectangle(const wxRect
& rect
)
756 { m_pimpl
->DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
758 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
760 { m_pimpl
->DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
761 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
763 { m_pimpl
->DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
764 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
765 { m_pimpl
->DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
767 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
768 { m_pimpl
->DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
769 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
770 { m_pimpl
->DrawCircle(pt
.x
, pt
.y
, radius
); }
772 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
773 { m_pimpl
->DoDrawEllipse(x
, y
, width
, height
); }
774 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
775 { m_pimpl
->DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
776 void DrawEllipse(const wxRect
& rect
)
777 { m_pimpl
->DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
779 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
780 { m_pimpl
->DoDrawIcon(icon
, x
, y
); }
781 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
782 { m_pimpl
->DoDrawIcon(icon
, pt
.x
, pt
.y
); }
784 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
785 bool useMask
= false)
786 { m_pimpl
->DoDrawBitmap(bmp
, x
, y
, useMask
); }
787 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
788 bool useMask
= false)
789 { m_pimpl
->DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
791 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
792 { m_pimpl
->DoDrawText(text
, x
, y
); }
793 void DrawText(const wxString
& text
, const wxPoint
& pt
)
794 { m_pimpl
->DoDrawText(text
, pt
.x
, pt
.y
); }
796 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
797 { m_pimpl
->DoDrawRotatedText(text
, x
, y
, angle
); }
798 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
799 { m_pimpl
->DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
801 // this version puts both optional bitmap and the text into the given
802 // rectangle and aligns is as specified by alignment parameter; it also
803 // will emphasize the character with the given index if it is != -1 and
804 // return the bounding rectangle if required
805 void DrawLabel(const wxString
& text
,
806 const wxBitmap
& image
,
808 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
810 wxRect
*rectBounding
= NULL
)
811 { m_pimpl
->DrawLabel( text
, image
, rect
, alignment
, indexAccel
, rectBounding
); }
813 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
814 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
816 { m_pimpl
->DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
818 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
819 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
820 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
822 return m_pimpl
->DoBlit(xdest
, ydest
, width
, height
,
823 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
825 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
826 wxDC
*source
, const wxPoint
& srcPt
,
827 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcPtMask
= wxDefaultPosition
)
829 return m_pimpl
->DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
830 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
833 bool StretchBlit(wxCoord dstX
, wxCoord dstY
,
834 wxCoord dstWidth
, wxCoord dstHeight
,
836 wxCoord srcX
, wxCoord srcY
,
837 wxCoord srcWidth
, wxCoord srcHeight
,
838 int rop
= wxCOPY
, bool useMask
= false,
839 wxCoord srcMaskX
= wxDefaultCoord
, wxCoord srcMaskY
= wxDefaultCoord
)
841 return m_pimpl
->DoStretchBlit(dstX
, dstY
, dstWidth
, dstHeight
,
842 source
, srcX
, srcY
, srcWidth
, srcHeight
, rop
, useMask
, srcMaskX
, srcMaskY
);
844 bool StretchBlit(const wxPoint
& dstPt
, const wxSize
& dstSize
,
845 wxDC
*source
, const wxPoint
& srcPt
, const wxSize
& srcSize
,
846 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcMaskPt
= wxDefaultPosition
)
848 return m_pimpl
->DoStretchBlit(dstPt
.x
, dstPt
.y
, dstSize
.x
, dstSize
.y
,
849 source
, srcPt
.x
, srcPt
.y
, srcSize
.x
, srcSize
.y
, rop
, useMask
, srcMaskPt
.x
, srcMaskPt
.y
);
852 wxBitmap
GetAsBitmap(const wxRect
*subrect
= (const wxRect
*) NULL
) const
854 return m_pimpl
->DoGetAsBitmap(subrect
);
858 // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?)
859 void DrawSpline(wxCoord x1
, wxCoord y1
,
860 wxCoord x2
, wxCoord y2
,
861 wxCoord x3
, wxCoord y3
)
862 { m_pimpl
->DrawSpline(x1
,y1
,x2
,y2
,x3
,y3
); }
863 void DrawSpline(int n
, wxPoint points
[])
864 { m_pimpl
->DrawSpline(n
,points
); }
866 void DrawSpline(wxList
*points
)
867 { m_pimpl
->DoDrawSpline(points
); }
868 #endif // wxUSE_SPLINES
871 #if WXWIN_COMPATIBILITY_2_8
872 // for compatibility with the old code when wxCoord was long everywhere
873 wxDEPRECATED( void GetTextExtent(const wxString
& string
,
875 long *descent
= NULL
,
876 long *externalLeading
= NULL
,
877 const wxFont
*theFont
= NULL
) const );
878 wxDEPRECATED( void GetLogicalOrigin(long *x
, long *y
) const );
879 wxDEPRECATED( void GetDeviceOrigin(long *x
, long *y
) const );
880 wxDEPRECATED( void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const );
881 #endif // WXWIN_COMPATIBILITY_2_8
888 DECLARE_ABSTRACT_CLASS(wxImplDC
)
894 //-----------------------------------------------------------------------------
896 //-----------------------------------------------------------------------------
898 class WXDLLIMPEXP_CORE wxDC
: public wxDCBase
905 void SetColourMap( const wxPalette
& palette
) { SetPalette(palette
); };
906 #endif // wxUSE_PALETTE
908 // Resolution in pixels per logical inch
909 virtual wxSize
GetPPI() const;
911 virtual bool StartDoc( const wxString
& WXUNUSED(message
) ) { return true; }
912 virtual void EndDoc() { }
913 virtual void StartPage() { }
914 virtual void EndPage() { }
916 virtual GdkWindow
* GetGDKWindow() const { return NULL
; }
920 wxCoord
XDEV2LOG(wxCoord x
) const { return DeviceToLogicalX(x
); }
921 wxCoord
XDEV2LOGREL(wxCoord x
) const { return DeviceToLogicalXRel(x
); }
922 wxCoord
YDEV2LOG(wxCoord y
) const { return DeviceToLogicalY(y
); }
923 wxCoord
YDEV2LOGREL(wxCoord y
) const { return DeviceToLogicalYRel(y
); }
924 wxCoord
XLOG2DEV(wxCoord x
) const { return LogicalToDeviceX(x
); }
925 wxCoord
XLOG2DEVREL(wxCoord x
) const { return LogicalToDeviceXRel(x
); }
926 wxCoord
YLOG2DEV(wxCoord y
) const { return LogicalToDeviceY(y
); }
927 wxCoord
YLOG2DEVREL(wxCoord y
) const { return LogicalToDeviceYRel(y
); }
929 // base class pure virtuals implemented here
930 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
931 virtual void DoGetSizeMM(int* width
, int* height
) const;
934 DECLARE_ABSTRACT_CLASS(wxDC
)
937 // this must be defined when wxDC::Blit() honours the DC origian and needed to
938 // allow wxUniv code in univ/winuniv.cpp to work with versions of wxGTK
940 #ifndef wxHAS_WORKING_GTK_DC_BLIT
941 #define wxHAS_WORKING_GTK_DC_BLIT