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"
32 #include "wx/list.h" // we use wxList in inline functions
34 class WXDLLEXPORT wxDCBase
;
36 class WXDLLEXPORT wxDrawObject
45 virtual ~wxDrawObject() { }
47 virtual void Draw(wxDCBase
&) const { }
49 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
53 if ( x
< m_minX
) m_minX
= x
;
54 if ( y
< m_minY
) m_minY
= y
;
55 if ( x
> m_maxX
) m_maxX
= x
;
56 if ( y
> m_maxY
) m_maxY
= y
;
69 void ResetBoundingBox()
71 m_isBBoxValid
= FALSE
;
73 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
76 // Get the final bounding box of the PostScript or Metafile picture.
78 wxCoord
MinX() const { return m_minX
; }
79 wxCoord
MaxX() const { return m_maxX
; }
80 wxCoord
MinY() const { return m_minY
; }
81 wxCoord
MaxY() const { return m_maxY
; }
83 //to define the type of object for derived objects
84 virtual int GetType()=0;
87 //for boundingbox calculation
89 //for boundingbox calculation
90 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
93 // ---------------------------------------------------------------------------
95 // ---------------------------------------------------------------------------
97 WXDLLEXPORT_DATA(extern int) wxPageNumber
;
99 // ---------------------------------------------------------------------------
100 // wxDC is the device context - object on which any drawing is done
101 // ---------------------------------------------------------------------------
103 class WXDLLEXPORT wxDCBase
: public wxObject
113 m_signX
= m_signY
= 1;
115 m_logicalOriginX
= m_logicalOriginY
=
116 m_deviceOriginX
= m_deviceOriginY
= 0;
118 m_logicalScaleX
= m_logicalScaleY
=
119 m_userScaleX
= m_userScaleY
=
120 m_scaleX
= m_scaleY
= 1.0;
122 m_logicalFunction
= wxCOPY
;
124 m_backgroundMode
= wxTRANSPARENT
;
126 m_mappingMode
= wxMM_TEXT
;
128 m_backgroundBrush
= *wxTRANSPARENT_BRUSH
;
130 m_textForegroundColour
= *wxBLACK
;
131 m_textBackgroundColour
= *wxWHITE
;
133 m_colour
= wxColourDisplay();
138 virtual void BeginDrawing() { }
139 virtual void EndDrawing() { }
141 // graphic primitives
142 // ------------------
144 virtual void DrawObject(wxDrawObject
* drawobject
)
146 drawobject
->Draw(*this);
147 CalcBoundingBox(drawobject
->MinX(),drawobject
->MinY());
148 CalcBoundingBox(drawobject
->MaxX(),drawobject
->MaxY());
151 void FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
152 int style
= wxFLOOD_SURFACE
)
153 { DoFloodFill(x
, y
, col
, style
); }
154 void FloodFill(const wxPoint
& pt
, const wxColour
& col
,
155 int style
= wxFLOOD_SURFACE
)
156 { DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
158 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
159 { return DoGetPixel(x
, y
, col
); }
160 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
161 { return DoGetPixel(pt
.x
, pt
.y
, col
); }
163 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
164 { DoDrawLine(x1
, y1
, x2
, y2
); }
165 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
166 { DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
168 void CrossHair(wxCoord x
, wxCoord y
)
169 { DoCrossHair(x
, y
); }
170 void CrossHair(const wxPoint
& pt
)
171 { DoCrossHair(pt
.x
, pt
.y
); }
173 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
174 wxCoord xc
, wxCoord yc
)
175 { DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
176 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
177 { DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
179 void DrawCheckMark(wxCoord x
, wxCoord y
,
180 wxCoord width
, wxCoord height
)
181 { DoDrawCheckMark(x
, y
, width
, height
); }
182 void DrawCheckMark(const wxRect
& rect
)
183 { DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
185 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
186 double sa
, double ea
)
187 { DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
188 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
189 double sa
, double ea
)
190 { DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
192 void DrawPoint(wxCoord x
, wxCoord y
)
193 { DoDrawPoint(x
, y
); }
194 void DrawPoint(const wxPoint
& pt
)
195 { DoDrawPoint(pt
.x
, pt
.y
); }
197 void DrawLines(int n
, wxPoint points
[],
198 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
199 { DoDrawLines(n
, points
, xoffset
, yoffset
); }
200 void DrawLines(const wxList
*list
,
201 wxCoord xoffset
= 0, wxCoord yoffset
= 0);
203 void DrawPolygon(int n
, wxPoint points
[],
204 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
205 int fillStyle
= wxODDEVEN_RULE
)
206 { DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
208 void DrawPolygon(const wxList
*list
,
209 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
210 int fillStyle
= wxODDEVEN_RULE
);
212 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
213 { DoDrawRectangle(x
, y
, width
, height
); }
214 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
215 { DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
216 void DrawRectangle(const wxRect
& rect
)
217 { DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
219 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
221 { DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
222 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
224 { DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
225 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
226 { DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
228 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
229 { DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
230 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
231 { DoDrawEllipse(x
, y
, width
, height
); }
232 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
233 { DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
234 void DrawEllipse(const wxRect
& rect
)
235 { DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
237 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
238 { DoDrawIcon(icon
, x
, y
); }
239 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
240 { DoDrawIcon(icon
, pt
.x
, pt
.y
); }
242 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
243 bool useMask
= FALSE
)
244 { DoDrawBitmap(bmp
, x
, y
, useMask
); }
245 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
246 bool useMask
= FALSE
)
247 { DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
249 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
250 { DoDrawText(text
, x
, y
); }
251 void DrawText(const wxString
& text
, const wxPoint
& pt
)
252 { DoDrawText(text
, pt
.x
, pt
.y
); }
254 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
255 { DoDrawRotatedText(text
, x
, y
, angle
); }
256 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
257 { DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
259 // this version puts both optional bitmap and the text into the given
260 // rectangle and aligns is as specified by alignment parameter; it also
261 // will emphasize the character with the given index if it is != -1 and
262 // return the bounding rectangle if required
263 virtual void DrawLabel(const wxString
& text
,
264 const wxBitmap
& image
,
266 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
268 wxRect
*rectBounding
= NULL
);
270 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
271 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
273 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
275 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
276 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
277 int rop
= wxCOPY
, bool useMask
= FALSE
, wxCoord xsrcMask
= -1, wxCoord ysrcMask
= -1)
279 return DoBlit(xdest
, ydest
, width
, height
,
280 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
282 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
283 wxDC
*source
, const wxPoint
& srcPt
,
284 int rop
= wxCOPY
, bool useMask
= FALSE
, const wxPoint
& srcPtMask
= wxPoint(-1, -1))
286 return DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
287 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
291 // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?)
292 void DrawSpline(wxCoord x1
, wxCoord y1
,
293 wxCoord x2
, wxCoord y2
,
294 wxCoord x3
, wxCoord y3
);
295 void DrawSpline(int n
, wxPoint points
[]);
297 void DrawSpline(wxList
*points
) { DoDrawSpline(points
); }
298 #endif // wxUSE_SPLINES
300 // global DC operations
301 // --------------------
303 virtual void Clear() = 0;
305 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return TRUE
; }
306 virtual void EndDoc() { }
308 virtual void StartPage() { }
309 virtual void EndPage() { }
311 // set objects to use for drawing
312 // ------------------------------
314 virtual void SetFont(const wxFont
& font
) = 0;
315 virtual void SetPen(const wxPen
& pen
) = 0;
316 virtual void SetBrush(const wxBrush
& brush
) = 0;
317 virtual void SetBackground(const wxBrush
& brush
) = 0;
318 virtual void SetBackgroundMode(int mode
) = 0;
319 virtual void SetPalette(const wxPalette
& palette
) = 0;
324 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
325 { DoSetClippingRegion(x
, y
, width
, height
); }
326 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
327 { DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
328 void SetClippingRegion(const wxRect
& rect
)
329 { DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
330 void SetClippingRegion(const wxRegion
& region
)
331 { DoSetClippingRegionAsRegion(region
); }
333 virtual void DestroyClippingRegion() = 0;
335 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
336 { DoGetClippingBox(x
, y
, w
, h
); }
337 void GetClippingBox(wxRect
& rect
) const
339 // Necessary to use intermediate variables for 16-bit compilation
341 DoGetClippingBox(&x
, &y
, &w
, &h
);
342 rect
.x
= x
; rect
.y
= y
; rect
.width
= w
; rect
.height
= h
;
348 virtual wxCoord
GetCharHeight() const = 0;
349 virtual wxCoord
GetCharWidth() const = 0;
351 // only works for single line strings
352 void GetTextExtent(const wxString
& string
,
353 wxCoord
*x
, wxCoord
*y
,
354 wxCoord
*descent
= NULL
,
355 wxCoord
*externalLeading
= NULL
,
356 wxFont
*theFont
= NULL
) const
357 { DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
359 // works for single as well as multi-line strings
360 virtual void GetMultiLineTextExtent(const wxString
& text
,
363 wxCoord
*heightLine
= NULL
,
364 wxFont
*font
= NULL
);
366 // size and resolution
367 // -------------------
370 void GetSize(int *width
, int *height
) const
371 { DoGetSize(width
, height
); }
372 wxSize
GetSize() const
381 void GetSizeMM(int* width
, int* height
) const
382 { DoGetSizeMM(width
, height
); }
383 wxSize
GetSizeMM() const
391 // coordinates conversions
392 // -----------------------
394 // This group of functions does actual conversion of the input, as you'd
396 wxCoord
DeviceToLogicalX(wxCoord x
) const;
397 wxCoord
DeviceToLogicalY(wxCoord y
) const;
398 wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
399 wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
400 wxCoord
LogicalToDeviceX(wxCoord x
) const;
401 wxCoord
LogicalToDeviceY(wxCoord y
) const;
402 wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
403 wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
405 // query DC capabilities
406 // ---------------------
408 virtual bool CanDrawBitmap() const = 0;
409 virtual bool CanGetTextExtent() const = 0;
412 virtual int GetDepth() const = 0;
414 // Resolution in Pixels per inch
415 virtual wxSize
GetPPI() const = 0;
417 virtual bool Ok() const { return m_ok
; }
423 int GetBackgroundMode() const { return m_backgroundMode
; }
424 const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
425 const wxBrush
& GetBrush() const { return m_brush
; }
426 const wxFont
& GetFont() const { return m_font
; }
427 const wxPen
& GetPen() const { return m_pen
; }
428 const wxColour
& GetTextBackground() const { return m_textBackgroundColour
; }
429 const wxColour
& GetTextForeground() const { return m_textForegroundColour
; }
432 wxBrush
& GetBackground() { return m_backgroundBrush
; }
433 wxBrush
& GetBrush() { return m_brush
; }
434 wxFont
& GetFont() { return m_font
; }
435 wxPen
& GetPen() { return m_pen
; }
436 wxColour
& GetTextBackground() { return m_textBackgroundColour
; }
437 wxColour
& GetTextForeground() { return m_textForegroundColour
; }
439 virtual void SetTextForeground(const wxColour
& colour
)
440 { m_textForegroundColour
= colour
; }
441 virtual void SetTextBackground(const wxColour
& colour
)
442 { m_textBackgroundColour
= colour
; }
444 int GetMapMode() const { return m_mappingMode
; }
445 virtual void SetMapMode(int mode
) = 0;
447 virtual void GetUserScale(double *x
, double *y
) const
449 if ( x
) *x
= m_userScaleX
;
450 if ( y
) *y
= m_userScaleY
;
452 virtual void SetUserScale(double x
, double y
) = 0;
454 virtual void GetLogicalScale(double *x
, double *y
)
456 if ( x
) *x
= m_logicalScaleX
;
457 if ( y
) *y
= m_logicalScaleY
;
459 virtual void SetLogicalScale(double x
, double y
)
465 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
466 { DoGetLogicalOrigin(x
, y
); }
467 wxPoint
GetLogicalOrigin() const
468 { wxCoord x
, y
; DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
469 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
) = 0;
471 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
472 { DoGetDeviceOrigin(x
, y
); }
473 wxPoint
GetDeviceOrigin() const
474 { wxCoord x
, y
; DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
475 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
) = 0;
477 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
) = 0;
479 int GetLogicalFunction() const { return m_logicalFunction
; }
480 virtual void SetLogicalFunction(int function
) = 0;
482 // Sometimes we need to override optimization, e.g. if other software is
483 // drawing onto our surface and we can't be sure of who's done what.
485 // FIXME: is this (still) used?
486 virtual void SetOptimization(bool WXUNUSED(opt
)) { }
487 virtual bool GetOptimization() { return FALSE
; }
489 // Some platforms have a DC cache, which should be cleared
490 // at appropriate points such as after a series of DC operations.
491 // Put ClearCache in the wxDC implementation class, since it has to be
493 // static void ClearCache() ;
494 #if 0 // wxUSE_DC_CACHEING
495 static void EnableCache(bool cacheing
) { sm_cacheing
= cacheing
; }
496 static bool CacheEnabled() { return sm_cacheing
; }
502 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
506 if ( x
< m_minX
) m_minX
= x
;
507 if ( y
< m_minY
) m_minY
= y
;
508 if ( x
> m_maxX
) m_maxX
= x
;
509 if ( y
> m_maxY
) m_maxY
= y
;
513 m_isBBoxValid
= TRUE
;
522 void ResetBoundingBox()
524 m_isBBoxValid
= FALSE
;
526 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
529 // Get the final bounding box of the PostScript or Metafile picture.
530 wxCoord
MinX() const { return m_minX
; }
531 wxCoord
MaxX() const { return m_maxX
; }
532 wxCoord
MinY() const { return m_minY
; }
533 wxCoord
MaxY() const { return m_maxY
; }
535 // misc old functions
536 // ------------------
538 // for compatibility with the old code when wxCoord was long everywhere
540 void GetTextExtent(const wxString
& string
,
542 long *descent
= NULL
,
543 long *externalLeading
= NULL
,
544 wxFont
*theFont
= NULL
) const
546 wxCoord x2
, y2
, descent2
, externalLeading2
;
547 DoGetTextExtent(string
, &x2
, &y2
,
548 &descent2
, &externalLeading2
,
556 if ( externalLeading
)
557 *externalLeading
= externalLeading2
;
560 void GetLogicalOrigin(long *x
, long *y
) const
563 DoGetLogicalOrigin(&x2
, &y2
);
570 void GetDeviceOrigin(long *x
, long *y
) const
573 DoGetDeviceOrigin(&x2
, &y2
);
579 void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const
582 DoGetClippingBox(&xx
, &yy
, &ww
, &hh
);
590 #if WXWIN_COMPATIBILITY
591 virtual void SetColourMap(const wxPalette
& palette
) { SetPalette(palette
); }
592 void GetTextExtent(const wxString
& string
, float *x
, float *y
,
593 float *descent
= NULL
, float *externalLeading
= NULL
,
594 wxFont
*theFont
= NULL
, bool use16bit
= FALSE
) const ;
595 void GetSize(float* width
, float* height
) const { int w
, h
; GetSize(& w
, & h
); *width
= w
; *height
= h
; }
596 void GetSizeMM(float *width
, float *height
) const { long w
, h
; GetSizeMM(& w
, & h
); *width
= (float) w
; *height
= (float) h
; }
597 #endif // WXWIN_COMPATIBILITY
600 // the pure virtual functions which should be implemented by wxDC
601 virtual void DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
602 int style
= wxFLOOD_SURFACE
) = 0;
604 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
606 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
607 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
609 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
610 wxCoord x2
, wxCoord y2
,
611 wxCoord xc
, wxCoord yc
) = 0;
612 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
613 wxCoord width
, wxCoord height
);
614 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
615 double sa
, double ea
) = 0;
617 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
618 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
619 wxCoord width
, wxCoord height
,
621 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
622 wxCoord width
, wxCoord height
) = 0;
624 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
626 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
627 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
628 bool useMask
= FALSE
) = 0;
630 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
631 virtual void DoDrawRotatedText(const wxString
& text
,
632 wxCoord x
, wxCoord y
, double angle
) = 0;
634 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
635 wxCoord width
, wxCoord height
,
636 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
637 int rop
= wxCOPY
, bool useMask
= FALSE
, wxCoord xsrcMask
= -1, wxCoord ysrcMask
= -1) = 0;
639 virtual void DoGetSize(int *width
, int *height
) const = 0;
640 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
642 virtual void DoDrawLines(int n
, wxPoint points
[],
643 wxCoord xoffset
, wxCoord yoffset
) = 0;
644 virtual void DoDrawPolygon(int n
, wxPoint points
[],
645 wxCoord xoffset
, wxCoord yoffset
,
646 int fillStyle
= wxODDEVEN_RULE
) = 0;
648 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
) = 0;
649 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
650 wxCoord width
, wxCoord height
) = 0;
652 // FIXME are these functions really different?
653 virtual void DoGetClippingRegion(wxCoord
*x
, wxCoord
*y
,
654 wxCoord
*w
, wxCoord
*h
)
655 { DoGetClippingBox(x
, y
, w
, h
); }
656 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
657 wxCoord
*w
, wxCoord
*h
) const
661 if ( x
) *x
= m_clipX1
;
662 if ( y
) *y
= m_clipY1
;
663 if ( w
) *w
= m_clipX2
- m_clipX1
;
664 if ( h
) *h
= m_clipY2
- m_clipY1
;
668 *x
= *y
= *w
= *h
= 0;
672 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
674 if ( x
) *x
= m_logicalOriginX
;
675 if ( y
) *y
= m_logicalOriginY
;
678 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
680 if ( x
) *x
= m_deviceOriginX
;
681 if ( y
) *y
= m_deviceOriginY
;
684 virtual void DoGetTextExtent(const wxString
& string
,
685 wxCoord
*x
, wxCoord
*y
,
686 wxCoord
*descent
= NULL
,
687 wxCoord
*externalLeading
= NULL
,
688 wxFont
*theFont
= NULL
) const = 0;
691 virtual void DoDrawSpline(wxList
*points
);
699 bool m_isInteractive
:1;
700 bool m_isBBoxValid
:1;
701 #if wxUSE_DC_CACHEING
702 // static bool sm_cacheing;
705 // coordinate system variables
707 // TODO short descriptions of what exactly they are would be nice...
709 wxCoord m_logicalOriginX
, m_logicalOriginY
;
710 wxCoord m_deviceOriginX
, m_deviceOriginY
;
712 double m_logicalScaleX
, m_logicalScaleY
;
713 double m_userScaleX
, m_userScaleY
;
714 double m_scaleX
, m_scaleY
;
716 // Used by SetAxisOrientation() to invert the axes
717 int m_signX
, m_signY
;
719 // bounding and clipping boxes
720 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
721 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
723 int m_logicalFunction
;
724 int m_backgroundMode
;
730 wxBrush m_backgroundBrush
;
731 wxColour m_textForegroundColour
;
732 wxColour m_textBackgroundColour
;
737 DECLARE_NO_COPY_CLASS(wxDCBase
)
738 DECLARE_ABSTRACT_CLASS(wxDCBase
)
741 // ----------------------------------------------------------------------------
742 // now include the declaration of wxDC class
743 // ----------------------------------------------------------------------------
745 #if defined(__WXMSW__)
746 #include "wx/msw/dc.h"
747 #elif defined(__WXMOTIF__)
748 #include "wx/motif/dc.h"
749 #elif defined(__WXGTK__)
750 #include "wx/gtk/dc.h"
751 #elif defined(__WXMGL__)
752 #include "wx/mgl/dc.h"
753 #elif defined(__WXMAC__)
754 #include "wx/mac/dc.h"
755 #elif defined(__WXPM__)
756 #include "wx/os2/dc.h"
757 #elif defined(__WXSTUBS__)
758 #include "wx/stubs/dc.h"
761 // ----------------------------------------------------------------------------
762 // helper class: you can use it to temporarily change the DC text colour and
763 // restore it automatically when the object goes out of scope
764 // ----------------------------------------------------------------------------
766 class WXDLLEXPORT wxDCTextColourChanger
769 wxDCTextColourChanger(wxDC
& dc
) : m_dc(dc
) { }
771 ~wxDCTextColourChanger()
773 if ( m_colFgOld
.Ok() )
774 m_dc
.SetTextForeground(m_colFgOld
);
777 void Set(const wxColour
& col
)
779 if ( !m_colFgOld
.Ok() )
780 m_colFgOld
= m_dc
.GetTextForeground();
781 m_dc
.SetTextForeground(col
);
790 // ----------------------------------------------------------------------------
791 // another small helper class: sets the clipping region in its ctor and
792 // destroys it in the dtor
793 // ----------------------------------------------------------------------------
795 class WXDLLEXPORT wxDCClipper
798 wxDCClipper(wxDC
& dc
, const wxRect
& r
) : m_dc(dc
)
799 { dc
.SetClippingRegion(r
.x
, r
.y
, r
.width
, r
.height
); }
800 wxDCClipper(wxDC
& dc
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) : m_dc(dc
)
801 { dc
.SetClippingRegion(x
, y
, w
, h
); }
803 ~wxDCClipper() { m_dc
.DestroyClippingRegion(); }