1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_DC_H_BASE_
13 #define _WX_DC_H_BASE_
16 #pragma interface "dcbase.h"
19 // ----------------------------------------------------------------------------
20 // headers which we must include here
21 // ----------------------------------------------------------------------------
23 #include "wx/object.h" // the base class
25 #include "wx/cursor.h" // we have member variables of these classes
26 #include "wx/font.h" // so we can't do without them
27 #include "wx/colour.h"
30 #include "wx/palette.h"
31 #include "wx/list.h" // we use wxList in inline functions
33 class WXDLLEXPORT wxDCBase
;
35 class WXDLLEXPORT wxDrawObject
44 virtual ~wxDrawObject() { }
46 virtual void Draw(wxDCBase
&) const { }
48 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
52 if ( x
< m_minX
) m_minX
= x
;
53 if ( y
< m_minY
) m_minY
= y
;
54 if ( x
> m_maxX
) m_maxX
= x
;
55 if ( y
> m_maxY
) m_maxY
= y
;
68 void ResetBoundingBox()
70 m_isBBoxValid
= FALSE
;
72 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
75 // Get the final bounding box of the PostScript or Metafile picture.
77 wxCoord
MinX() const { return m_minX
; }
78 wxCoord
MaxX() const { return m_maxX
; }
79 wxCoord
MinY() const { return m_minY
; }
80 wxCoord
MaxY() const { return m_maxY
; }
82 //to define the type of object for derived objects
83 virtual int GetType()=0;
86 //for boundingbox calculation
88 //for boundingbox calculation
89 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
92 // ---------------------------------------------------------------------------
94 // ---------------------------------------------------------------------------
96 WXDLLEXPORT_DATA(extern int) wxPageNumber
;
98 // ---------------------------------------------------------------------------
99 // wxDC is the device context - object on which any drawing is done
100 // ---------------------------------------------------------------------------
102 class WXDLLEXPORT wxDCBase
: public wxObject
112 m_signX
= m_signY
= 1;
114 m_logicalOriginX
= m_logicalOriginY
=
115 m_deviceOriginX
= m_deviceOriginY
= 0;
117 m_logicalScaleX
= m_logicalScaleY
=
118 m_userScaleX
= m_userScaleY
=
119 m_scaleX
= m_scaleY
= 1.0;
121 m_logicalFunction
= wxCOPY
;
123 m_backgroundMode
= wxTRANSPARENT
;
125 m_mappingMode
= wxMM_TEXT
;
127 m_backgroundBrush
= *wxTRANSPARENT_BRUSH
;
129 m_textForegroundColour
= *wxBLACK
;
130 m_textBackgroundColour
= *wxWHITE
;
132 m_colour
= wxColourDisplay();
137 virtual void BeginDrawing() { }
138 virtual void EndDrawing() { }
140 // graphic primitives
141 // ------------------
143 virtual void DrawObject(wxDrawObject
* drawobject
)
145 drawobject
->Draw(*this);
146 CalcBoundingBox(drawobject
->MinX(),drawobject
->MinY());
147 CalcBoundingBox(drawobject
->MaxX(),drawobject
->MaxY());
150 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
151 int style
= wxFLOOD_SURFACE
)
152 { return DoFloodFill(x
, y
, col
, style
); }
153 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
154 int style
= wxFLOOD_SURFACE
)
155 { return DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
157 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
158 { return DoGetPixel(x
, y
, col
); }
159 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
160 { return DoGetPixel(pt
.x
, pt
.y
, col
); }
162 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
163 { DoDrawLine(x1
, y1
, x2
, y2
); }
164 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
165 { DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
167 void CrossHair(wxCoord x
, wxCoord y
)
168 { DoCrossHair(x
, y
); }
169 void CrossHair(const wxPoint
& pt
)
170 { DoCrossHair(pt
.x
, pt
.y
); }
172 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
173 wxCoord xc
, wxCoord yc
)
174 { DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
175 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
176 { DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
178 void DrawCheckMark(wxCoord x
, wxCoord y
,
179 wxCoord width
, wxCoord height
)
180 { DoDrawCheckMark(x
, y
, width
, height
); }
181 void DrawCheckMark(const wxRect
& rect
)
182 { DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
184 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
185 double sa
, double ea
)
186 { DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
187 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
188 double sa
, double ea
)
189 { DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
191 void DrawPoint(wxCoord x
, wxCoord y
)
192 { DoDrawPoint(x
, y
); }
193 void DrawPoint(const wxPoint
& pt
)
194 { DoDrawPoint(pt
.x
, pt
.y
); }
196 void DrawLines(int n
, wxPoint points
[],
197 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
198 { DoDrawLines(n
, points
, xoffset
, yoffset
); }
199 void DrawLines(const wxList
*list
,
200 wxCoord xoffset
= 0, wxCoord yoffset
= 0);
202 void DrawPolygon(int n
, wxPoint points
[],
203 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
204 int fillStyle
= wxODDEVEN_RULE
)
205 { DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
207 void DrawPolygon(const wxList
*list
,
208 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
209 int fillStyle
= wxODDEVEN_RULE
);
211 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
212 { DoDrawRectangle(x
, y
, width
, height
); }
213 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
214 { DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
215 void DrawRectangle(const wxRect
& rect
)
216 { DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
218 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
220 { DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
221 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
223 { DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
224 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
225 { DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
227 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
228 { DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
229 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
230 { DrawCircle(pt
.x
, pt
.y
, radius
); }
232 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
233 { DoDrawEllipse(x
, y
, width
, height
); }
234 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
235 { DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
236 void DrawEllipse(const wxRect
& rect
)
237 { DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
239 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
240 { DoDrawIcon(icon
, x
, y
); }
241 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
242 { DoDrawIcon(icon
, pt
.x
, pt
.y
); }
244 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
245 bool useMask
= FALSE
)
246 { DoDrawBitmap(bmp
, x
, y
, useMask
); }
247 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
248 bool useMask
= FALSE
)
249 { DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
251 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
252 { DoDrawText(text
, x
, y
); }
253 void DrawText(const wxString
& text
, const wxPoint
& pt
)
254 { DoDrawText(text
, pt
.x
, pt
.y
); }
256 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
257 { DoDrawRotatedText(text
, x
, y
, angle
); }
258 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
259 { DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
261 // this version puts both optional bitmap and the text into the given
262 // rectangle and aligns is as specified by alignment parameter; it also
263 // will emphasize the character with the given index if it is != -1 and
264 // return the bounding rectangle if required
265 virtual void DrawLabel(const wxString
& text
,
266 const wxBitmap
& image
,
268 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
270 wxRect
*rectBounding
= NULL
);
272 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
273 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
275 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
277 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
278 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
279 int rop
= wxCOPY
, bool useMask
= FALSE
, wxCoord xsrcMask
= -1, wxCoord ysrcMask
= -1)
281 return DoBlit(xdest
, ydest
, width
, height
,
282 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
284 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
285 wxDC
*source
, const wxPoint
& srcPt
,
286 int rop
= wxCOPY
, bool useMask
= FALSE
, const wxPoint
& srcPtMask
= wxPoint(-1, -1))
288 return DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
289 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
293 // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?)
294 void DrawSpline(wxCoord x1
, wxCoord y1
,
295 wxCoord x2
, wxCoord y2
,
296 wxCoord x3
, wxCoord y3
);
297 void DrawSpline(int n
, wxPoint points
[]);
299 void DrawSpline(wxList
*points
) { DoDrawSpline(points
); }
300 #endif // wxUSE_SPLINES
302 // global DC operations
303 // --------------------
305 virtual void Clear() = 0;
307 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return TRUE
; }
308 virtual void EndDoc() { }
310 virtual void StartPage() { }
311 virtual void EndPage() { }
313 // set objects to use for drawing
314 // ------------------------------
316 virtual void SetFont(const wxFont
& font
) = 0;
317 virtual void SetPen(const wxPen
& pen
) = 0;
318 virtual void SetBrush(const wxBrush
& brush
) = 0;
319 virtual void SetBackground(const wxBrush
& brush
) = 0;
320 virtual void SetBackgroundMode(int mode
) = 0;
322 virtual void SetPalette(const wxPalette
& palette
) = 0;
323 #endif // wxUSE_PALETTE
328 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
329 { DoSetClippingRegion(x
, y
, width
, height
); }
330 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
331 { DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
332 void SetClippingRegion(const wxRect
& rect
)
333 { DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
334 void SetClippingRegion(const wxRegion
& region
)
335 { DoSetClippingRegionAsRegion(region
); }
337 virtual void DestroyClippingRegion() = 0;
339 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
340 { DoGetClippingBox(x
, y
, w
, h
); }
341 void GetClippingBox(wxRect
& rect
) const
343 // Necessary to use intermediate variables for 16-bit compilation
345 DoGetClippingBox(&x
, &y
, &w
, &h
);
346 rect
.x
= x
; rect
.y
= y
; rect
.width
= w
; rect
.height
= h
;
352 virtual wxCoord
GetCharHeight() const = 0;
353 virtual wxCoord
GetCharWidth() const = 0;
355 // only works for single line strings
356 void GetTextExtent(const wxString
& string
,
357 wxCoord
*x
, wxCoord
*y
,
358 wxCoord
*descent
= NULL
,
359 wxCoord
*externalLeading
= NULL
,
360 wxFont
*theFont
= NULL
) const
361 { DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
363 // works for single as well as multi-line strings
364 virtual void GetMultiLineTextExtent(const wxString
& text
,
367 wxCoord
*heightLine
= NULL
,
368 wxFont
*font
= NULL
);
370 // size and resolution
371 // -------------------
374 void GetSize(int *width
, int *height
) const
375 { DoGetSize(width
, height
); }
376 wxSize
GetSize() const
385 void GetSizeMM(int* width
, int* height
) const
386 { DoGetSizeMM(width
, height
); }
387 wxSize
GetSizeMM() const
395 // coordinates conversions
396 // -----------------------
398 // This group of functions does actual conversion of the input, as you'd
400 wxCoord
DeviceToLogicalX(wxCoord x
) const;
401 wxCoord
DeviceToLogicalY(wxCoord y
) const;
402 wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
403 wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
404 wxCoord
LogicalToDeviceX(wxCoord x
) const;
405 wxCoord
LogicalToDeviceY(wxCoord y
) const;
406 wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
407 wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
409 // query DC capabilities
410 // ---------------------
412 virtual bool CanDrawBitmap() const = 0;
413 virtual bool CanGetTextExtent() const = 0;
416 virtual int GetDepth() const = 0;
418 // Resolution in Pixels per inch
419 virtual wxSize
GetPPI() const = 0;
421 virtual bool Ok() const { return m_ok
; }
427 int GetBackgroundMode() const { return m_backgroundMode
; }
428 const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
429 const wxBrush
& GetBrush() const { return m_brush
; }
430 const wxFont
& GetFont() const { return m_font
; }
431 const wxPen
& GetPen() const { return m_pen
; }
432 const wxColour
& GetTextBackground() const { return m_textBackgroundColour
; }
433 const wxColour
& GetTextForeground() const { return m_textForegroundColour
; }
436 wxBrush
& GetBackground() { return m_backgroundBrush
; }
437 wxBrush
& GetBrush() { return m_brush
; }
438 wxFont
& GetFont() { return m_font
; }
439 wxPen
& GetPen() { return m_pen
; }
440 wxColour
& GetTextBackground() { return m_textBackgroundColour
; }
441 wxColour
& GetTextForeground() { return m_textForegroundColour
; }
443 virtual void SetTextForeground(const wxColour
& colour
)
444 { m_textForegroundColour
= colour
; }
445 virtual void SetTextBackground(const wxColour
& colour
)
446 { m_textBackgroundColour
= colour
; }
448 int GetMapMode() const { return m_mappingMode
; }
449 virtual void SetMapMode(int mode
) = 0;
451 virtual void GetUserScale(double *x
, double *y
) const
453 if ( x
) *x
= m_userScaleX
;
454 if ( y
) *y
= m_userScaleY
;
456 virtual void SetUserScale(double x
, double y
) = 0;
458 virtual void GetLogicalScale(double *x
, double *y
)
460 if ( x
) *x
= m_logicalScaleX
;
461 if ( y
) *y
= m_logicalScaleY
;
463 virtual void SetLogicalScale(double x
, double y
)
469 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
470 { DoGetLogicalOrigin(x
, y
); }
471 wxPoint
GetLogicalOrigin() const
472 { wxCoord x
, y
; DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
473 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
) = 0;
475 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
476 { DoGetDeviceOrigin(x
, y
); }
477 wxPoint
GetDeviceOrigin() const
478 { wxCoord x
, y
; DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
479 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
) = 0;
481 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
) = 0;
483 int GetLogicalFunction() const { return m_logicalFunction
; }
484 virtual void SetLogicalFunction(int function
) = 0;
486 // Sometimes we need to override optimization, e.g. if other software is
487 // drawing onto our surface and we can't be sure of who's done what.
489 // FIXME: is this (still) used?
490 virtual void SetOptimization(bool WXUNUSED(opt
)) { }
491 virtual bool GetOptimization() { return FALSE
; }
493 // Some platforms have a DC cache, which should be cleared
494 // at appropriate points such as after a series of DC operations.
495 // Put ClearCache in the wxDC implementation class, since it has to be
497 // static void ClearCache() ;
498 #if 0 // wxUSE_DC_CACHEING
499 static void EnableCache(bool cacheing
) { sm_cacheing
= cacheing
; }
500 static bool CacheEnabled() { return sm_cacheing
; }
506 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
510 if ( x
< m_minX
) m_minX
= x
;
511 if ( y
< m_minY
) m_minY
= y
;
512 if ( x
> m_maxX
) m_maxX
= x
;
513 if ( y
> m_maxY
) m_maxY
= y
;
517 m_isBBoxValid
= TRUE
;
526 void ResetBoundingBox()
528 m_isBBoxValid
= FALSE
;
530 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
533 // Get the final bounding box of the PostScript or Metafile picture.
534 wxCoord
MinX() const { return m_minX
; }
535 wxCoord
MaxX() const { return m_maxX
; }
536 wxCoord
MinY() const { return m_minY
; }
537 wxCoord
MaxY() const { return m_maxY
; }
539 // misc old functions
540 // ------------------
542 // for compatibility with the old code when wxCoord was long everywhere
544 void GetTextExtent(const wxString
& string
,
546 long *descent
= NULL
,
547 long *externalLeading
= NULL
,
548 wxFont
*theFont
= NULL
) const
550 wxCoord x2
, y2
, descent2
, externalLeading2
;
551 DoGetTextExtent(string
, &x2
, &y2
,
552 &descent2
, &externalLeading2
,
560 if ( externalLeading
)
561 *externalLeading
= externalLeading2
;
564 void GetLogicalOrigin(long *x
, long *y
) const
567 DoGetLogicalOrigin(&x2
, &y2
);
574 void GetDeviceOrigin(long *x
, long *y
) const
577 DoGetDeviceOrigin(&x2
, &y2
);
583 void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const
586 DoGetClippingBox(&xx
, &yy
, &ww
, &hh
);
594 #if WXWIN_COMPATIBILITY
597 virtual void SetColourMap(const wxPalette
& palette
) { SetPalette(palette
); }
598 #endif // wxUSE_PALETTE
600 void GetTextExtent(const wxString
& string
, float *x
, float *y
,
601 float *descent
= NULL
, float *externalLeading
= NULL
,
602 wxFont
*theFont
= NULL
, bool use16bit
= FALSE
) const ;
603 void GetSize(float* width
, float* height
) const { int w
, h
; GetSize(& w
, & h
); *width
= w
; *height
= h
; }
604 void GetSizeMM(float *width
, float *height
) const { long w
, h
; GetSizeMM(& w
, & h
); *width
= (float) w
; *height
= (float) h
; }
606 #endif // WXWIN_COMPATIBILITY
609 // the pure virtual functions which should be implemented by wxDC
610 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
611 int style
= wxFLOOD_SURFACE
) = 0;
613 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
615 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
616 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
618 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
619 wxCoord x2
, wxCoord y2
,
620 wxCoord xc
, wxCoord yc
) = 0;
621 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
622 wxCoord width
, wxCoord height
);
623 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
624 double sa
, double ea
) = 0;
626 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
627 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
628 wxCoord width
, wxCoord height
,
630 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
631 wxCoord width
, wxCoord height
) = 0;
633 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
635 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
636 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
637 bool useMask
= FALSE
) = 0;
639 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
640 virtual void DoDrawRotatedText(const wxString
& text
,
641 wxCoord x
, wxCoord y
, double angle
) = 0;
643 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
644 wxCoord width
, wxCoord height
,
645 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
646 int rop
= wxCOPY
, bool useMask
= FALSE
, wxCoord xsrcMask
= -1, wxCoord ysrcMask
= -1) = 0;
648 virtual void DoGetSize(int *width
, int *height
) const = 0;
649 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
651 virtual void DoDrawLines(int n
, wxPoint points
[],
652 wxCoord xoffset
, wxCoord yoffset
) = 0;
653 virtual void DoDrawPolygon(int n
, wxPoint points
[],
654 wxCoord xoffset
, wxCoord yoffset
,
655 int fillStyle
= wxODDEVEN_RULE
) = 0;
657 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
) = 0;
658 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
659 wxCoord width
, wxCoord height
) = 0;
661 // FIXME are these functions really different?
662 virtual void DoGetClippingRegion(wxCoord
*x
, wxCoord
*y
,
663 wxCoord
*w
, wxCoord
*h
)
664 { DoGetClippingBox(x
, y
, w
, h
); }
665 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
666 wxCoord
*w
, wxCoord
*h
) const
670 if ( x
) *x
= m_clipX1
;
671 if ( y
) *y
= m_clipY1
;
672 if ( w
) *w
= m_clipX2
- m_clipX1
;
673 if ( h
) *h
= m_clipY2
- m_clipY1
;
677 *x
= *y
= *w
= *h
= 0;
681 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
683 if ( x
) *x
= m_logicalOriginX
;
684 if ( y
) *y
= m_logicalOriginY
;
687 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
689 if ( x
) *x
= m_deviceOriginX
;
690 if ( y
) *y
= m_deviceOriginY
;
693 virtual void DoGetTextExtent(const wxString
& string
,
694 wxCoord
*x
, wxCoord
*y
,
695 wxCoord
*descent
= NULL
,
696 wxCoord
*externalLeading
= NULL
,
697 wxFont
*theFont
= NULL
) const = 0;
700 virtual void DoDrawSpline(wxList
*points
);
708 bool m_isInteractive
:1;
709 bool m_isBBoxValid
:1;
710 #if wxUSE_DC_CACHEING
711 // static bool sm_cacheing;
714 // coordinate system variables
716 // TODO short descriptions of what exactly they are would be nice...
718 wxCoord m_logicalOriginX
, m_logicalOriginY
;
719 wxCoord m_deviceOriginX
, m_deviceOriginY
;
721 double m_logicalScaleX
, m_logicalScaleY
;
722 double m_userScaleX
, m_userScaleY
;
723 double m_scaleX
, m_scaleY
;
725 // Used by SetAxisOrientation() to invert the axes
726 int m_signX
, m_signY
;
728 // bounding and clipping boxes
729 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
730 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
732 int m_logicalFunction
;
733 int m_backgroundMode
;
739 wxBrush m_backgroundBrush
;
740 wxColour m_textForegroundColour
;
741 wxColour m_textBackgroundColour
;
746 bool m_hasCustomPalette
;
747 #endif // wxUSE_PALETTE
750 DECLARE_NO_COPY_CLASS(wxDCBase
)
751 DECLARE_ABSTRACT_CLASS(wxDCBase
)
754 // ----------------------------------------------------------------------------
755 // now include the declaration of wxDC class
756 // ----------------------------------------------------------------------------
758 #if defined(__WXMSW__)
759 #include "wx/msw/dc.h"
760 #elif defined(__WXMOTIF__)
761 #include "wx/motif/dc.h"
762 #elif defined(__WXGTK__)
763 #include "wx/gtk/dc.h"
764 #elif defined(__WXX11__)
765 #include "wx/x11/dc.h"
766 #elif defined(__WXMGL__)
767 #include "wx/mgl/dc.h"
768 #elif defined(__WXMAC__)
769 #include "wx/mac/dc.h"
770 #elif defined(__WXPM__)
771 #include "wx/os2/dc.h"
772 #elif defined(__WXSTUBS__)
773 #include "wx/stubs/dc.h"
776 // ----------------------------------------------------------------------------
777 // helper class: you can use it to temporarily change the DC text colour and
778 // restore it automatically when the object goes out of scope
779 // ----------------------------------------------------------------------------
781 class WXDLLEXPORT wxDCTextColourChanger
784 wxDCTextColourChanger(wxDC
& dc
) : m_dc(dc
) { }
786 ~wxDCTextColourChanger()
788 if ( m_colFgOld
.Ok() )
789 m_dc
.SetTextForeground(m_colFgOld
);
792 void Set(const wxColour
& col
)
794 if ( !m_colFgOld
.Ok() )
795 m_colFgOld
= m_dc
.GetTextForeground();
796 m_dc
.SetTextForeground(col
);
805 // ----------------------------------------------------------------------------
806 // another small helper class: sets the clipping region in its ctor and
807 // destroys it in the dtor
808 // ----------------------------------------------------------------------------
810 class WXDLLEXPORT wxDCClipper
813 wxDCClipper(wxDC
& dc
, const wxRect
& r
) : m_dc(dc
)
814 { dc
.SetClippingRegion(r
.x
, r
.y
, r
.width
, r
.height
); }
815 wxDCClipper(wxDC
& dc
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) : m_dc(dc
)
816 { dc
.SetClippingRegion(x
, y
, w
, h
); }
818 ~wxDCClipper() { m_dc
.DestroyClippingRegion(); }