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 void FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
151 int style
= wxFLOOD_SURFACE
)
152 { DoFloodFill(x
, y
, col
, style
); }
153 void FloodFill(const wxPoint
& pt
, const wxColour
& col
,
154 int style
= wxFLOOD_SURFACE
)
155 { 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 DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
230 { DoDrawEllipse(x
, y
, width
, height
); }
231 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
232 { DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
233 void DrawEllipse(const wxRect
& rect
)
234 { DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
236 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
237 { DoDrawIcon(icon
, x
, y
); }
238 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
239 { DoDrawIcon(icon
, pt
.x
, pt
.y
); }
241 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
242 bool useMask
= FALSE
)
243 { DoDrawBitmap(bmp
, x
, y
, useMask
); }
244 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
245 bool useMask
= FALSE
)
246 { DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
248 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
249 { DoDrawText(text
, x
, y
); }
250 void DrawText(const wxString
& text
, const wxPoint
& pt
)
251 { DoDrawText(text
, pt
.x
, pt
.y
); }
253 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
254 { DoDrawRotatedText(text
, x
, y
, angle
); }
255 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
256 { DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
258 // this version puts both optional bitmap and the text into the given
259 // rectangle and aligns is as specified by alignment parameter; it also
260 // will emphasize the character with the given index if it is != -1 and
261 // return the bounding rectangle if required
262 virtual void DrawLabel(const wxString
& text
,
263 const wxBitmap
& image
,
265 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
267 wxRect
*rectBounding
= NULL
);
269 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
270 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
272 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
274 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
275 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
276 int rop
= wxCOPY
, bool useMask
= FALSE
, wxCoord xsrcMask
= -1, wxCoord ysrcMask
= -1)
278 return DoBlit(xdest
, ydest
, width
, height
,
279 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
281 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
282 wxDC
*source
, const wxPoint
& srcPt
,
283 int rop
= wxCOPY
, bool useMask
= FALSE
, const wxPoint
& srcPtMask
= wxPoint(-1, -1))
285 return DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
286 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
290 // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?)
291 void DrawSpline(wxCoord x1
, wxCoord y1
,
292 wxCoord x2
, wxCoord y2
,
293 wxCoord x3
, wxCoord y3
);
294 void DrawSpline(int n
, wxPoint points
[]);
296 void DrawSpline(wxList
*points
) { DoDrawSpline(points
); }
297 #endif // wxUSE_SPLINES
299 // global DC operations
300 // --------------------
302 virtual void Clear() = 0;
304 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return TRUE
; }
305 virtual void EndDoc() { }
307 virtual void StartPage() { }
308 virtual void EndPage() { }
310 // set objects to use for drawing
311 // ------------------------------
313 virtual void SetFont(const wxFont
& font
) = 0;
314 virtual void SetPen(const wxPen
& pen
) = 0;
315 virtual void SetBrush(const wxBrush
& brush
) = 0;
316 virtual void SetBackground(const wxBrush
& brush
) = 0;
317 virtual void SetBackgroundMode(int mode
) = 0;
319 virtual void SetPalette(const wxPalette
& palette
) = 0;
320 #endif // wxUSE_PALETTE
325 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
326 { DoSetClippingRegion(x
, y
, width
, height
); }
327 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
328 { DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
329 void SetClippingRegion(const wxRect
& rect
)
330 { DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
331 void SetClippingRegion(const wxRegion
& region
)
332 { DoSetClippingRegionAsRegion(region
); }
334 virtual void DestroyClippingRegion() = 0;
336 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
337 { DoGetClippingBox(x
, y
, w
, h
); }
338 void GetClippingBox(wxRect
& rect
) const
340 // Necessary to use intermediate variables for 16-bit compilation
342 DoGetClippingBox(&x
, &y
, &w
, &h
);
343 rect
.x
= x
; rect
.y
= y
; rect
.width
= w
; rect
.height
= h
;
349 virtual wxCoord
GetCharHeight() const = 0;
350 virtual wxCoord
GetCharWidth() const = 0;
352 // only works for single line strings
353 void GetTextExtent(const wxString
& string
,
354 wxCoord
*x
, wxCoord
*y
,
355 wxCoord
*descent
= NULL
,
356 wxCoord
*externalLeading
= NULL
,
357 wxFont
*theFont
= NULL
) const
358 { DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
360 // works for single as well as multi-line strings
361 virtual void GetMultiLineTextExtent(const wxString
& text
,
364 wxCoord
*heightLine
= NULL
,
365 wxFont
*font
= NULL
);
367 // size and resolution
368 // -------------------
371 void GetSize(int *width
, int *height
) const
372 { DoGetSize(width
, height
); }
373 wxSize
GetSize() const
382 void GetSizeMM(int* width
, int* height
) const
383 { DoGetSizeMM(width
, height
); }
384 wxSize
GetSizeMM() const
392 // coordinates conversions
393 // -----------------------
395 // This group of functions does actual conversion of the input, as you'd
397 wxCoord
DeviceToLogicalX(wxCoord x
) const;
398 wxCoord
DeviceToLogicalY(wxCoord y
) const;
399 wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
400 wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
401 wxCoord
LogicalToDeviceX(wxCoord x
) const;
402 wxCoord
LogicalToDeviceY(wxCoord y
) const;
403 wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
404 wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
406 // query DC capabilities
407 // ---------------------
409 virtual bool CanDrawBitmap() const = 0;
410 virtual bool CanGetTextExtent() const = 0;
413 virtual int GetDepth() const = 0;
415 // Resolution in Pixels per inch
416 virtual wxSize
GetPPI() const = 0;
418 virtual bool Ok() const { return m_ok
; }
424 int GetBackgroundMode() const { return m_backgroundMode
; }
425 const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
426 const wxBrush
& GetBrush() const { return m_brush
; }
427 const wxFont
& GetFont() const { return m_font
; }
428 const wxPen
& GetPen() const { return m_pen
; }
429 const wxColour
& GetTextBackground() const { return m_textBackgroundColour
; }
430 const wxColour
& GetTextForeground() const { return m_textForegroundColour
; }
433 wxBrush
& GetBackground() { return m_backgroundBrush
; }
434 wxBrush
& GetBrush() { return m_brush
; }
435 wxFont
& GetFont() { return m_font
; }
436 wxPen
& GetPen() { return m_pen
; }
437 wxColour
& GetTextBackground() { return m_textBackgroundColour
; }
438 wxColour
& GetTextForeground() { return m_textForegroundColour
; }
440 virtual void SetTextForeground(const wxColour
& colour
)
441 { m_textForegroundColour
= colour
; }
442 virtual void SetTextBackground(const wxColour
& colour
)
443 { m_textBackgroundColour
= colour
; }
445 int GetMapMode() const { return m_mappingMode
; }
446 virtual void SetMapMode(int mode
) = 0;
448 virtual void GetUserScale(double *x
, double *y
) const
450 if ( x
) *x
= m_userScaleX
;
451 if ( y
) *y
= m_userScaleY
;
453 virtual void SetUserScale(double x
, double y
) = 0;
455 virtual void GetLogicalScale(double *x
, double *y
)
457 if ( x
) *x
= m_logicalScaleX
;
458 if ( y
) *y
= m_logicalScaleY
;
460 virtual void SetLogicalScale(double x
, double y
)
466 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
467 { DoGetLogicalOrigin(x
, y
); }
468 wxPoint
GetLogicalOrigin() const
469 { wxCoord x
, y
; DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
470 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
) = 0;
472 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
473 { DoGetDeviceOrigin(x
, y
); }
474 wxPoint
GetDeviceOrigin() const
475 { wxCoord x
, y
; DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
476 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
) = 0;
478 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
) = 0;
480 int GetLogicalFunction() const { return m_logicalFunction
; }
481 virtual void SetLogicalFunction(int function
) = 0;
483 // Sometimes we need to override optimization, e.g. if other software is
484 // drawing onto our surface and we can't be sure of who's done what.
486 // FIXME: is this (still) used?
487 virtual void SetOptimization(bool WXUNUSED(opt
)) { }
488 virtual bool GetOptimization() { return FALSE
; }
490 // Some platforms have a DC cache, which should be cleared
491 // at appropriate points such as after a series of DC operations.
492 // Put ClearCache in the wxDC implementation class, since it has to be
494 // static void ClearCache() ;
495 #if 0 // wxUSE_DC_CACHEING
496 static void EnableCache(bool cacheing
) { sm_cacheing
= cacheing
; }
497 static bool CacheEnabled() { return sm_cacheing
; }
503 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
507 if ( x
< m_minX
) m_minX
= x
;
508 if ( y
< m_minY
) m_minY
= y
;
509 if ( x
> m_maxX
) m_maxX
= x
;
510 if ( y
> m_maxY
) m_maxY
= y
;
514 m_isBBoxValid
= TRUE
;
523 void ResetBoundingBox()
525 m_isBBoxValid
= FALSE
;
527 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
530 // Get the final bounding box of the PostScript or Metafile picture.
531 wxCoord
MinX() const { return m_minX
; }
532 wxCoord
MaxX() const { return m_maxX
; }
533 wxCoord
MinY() const { return m_minY
; }
534 wxCoord
MaxY() const { return m_maxY
; }
536 // misc old functions
537 // ------------------
539 // for compatibility with the old code when wxCoord was long everywhere
541 void GetTextExtent(const wxString
& string
,
543 long *descent
= NULL
,
544 long *externalLeading
= NULL
,
545 wxFont
*theFont
= NULL
) const
547 wxCoord x2
, y2
, descent2
, externalLeading2
;
548 DoGetTextExtent(string
, &x2
, &y2
,
549 &descent2
, &externalLeading2
,
557 if ( externalLeading
)
558 *externalLeading
= externalLeading2
;
561 void GetLogicalOrigin(long *x
, long *y
) const
564 DoGetLogicalOrigin(&x2
, &y2
);
571 void GetDeviceOrigin(long *x
, long *y
) const
574 DoGetDeviceOrigin(&x2
, &y2
);
580 void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const
583 DoGetClippingBox(&xx
, &yy
, &ww
, &hh
);
591 #if WXWIN_COMPATIBILITY
594 virtual void SetColourMap(const wxPalette
& palette
) { SetPalette(palette
); }
595 #endif // wxUSE_PALETTE
597 void GetTextExtent(const wxString
& string
, float *x
, float *y
,
598 float *descent
= NULL
, float *externalLeading
= NULL
,
599 wxFont
*theFont
= NULL
, bool use16bit
= FALSE
) const ;
600 void GetSize(float* width
, float* height
) const { int w
, h
; GetSize(& w
, & h
); *width
= w
; *height
= h
; }
601 void GetSizeMM(float *width
, float *height
) const { long w
, h
; GetSizeMM(& w
, & h
); *width
= (float) w
; *height
= (float) h
; }
603 #endif // WXWIN_COMPATIBILITY
606 // the pure virtual functions which should be implemented by wxDC
607 virtual void DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
608 int style
= wxFLOOD_SURFACE
) = 0;
610 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
612 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
613 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
615 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
616 wxCoord x2
, wxCoord y2
,
617 wxCoord xc
, wxCoord yc
) = 0;
618 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
619 wxCoord width
, wxCoord height
);
620 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
621 double sa
, double ea
) = 0;
623 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
624 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
625 wxCoord width
, wxCoord height
,
627 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
628 wxCoord width
, wxCoord height
) = 0;
630 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
632 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
633 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
634 bool useMask
= FALSE
) = 0;
636 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
637 virtual void DoDrawRotatedText(const wxString
& text
,
638 wxCoord x
, wxCoord y
, double angle
) = 0;
640 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
641 wxCoord width
, wxCoord height
,
642 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
643 int rop
= wxCOPY
, bool useMask
= FALSE
, wxCoord xsrcMask
= -1, wxCoord ysrcMask
= -1) = 0;
645 virtual void DoGetSize(int *width
, int *height
) const = 0;
646 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
648 virtual void DoDrawLines(int n
, wxPoint points
[],
649 wxCoord xoffset
, wxCoord yoffset
) = 0;
650 virtual void DoDrawPolygon(int n
, wxPoint points
[],
651 wxCoord xoffset
, wxCoord yoffset
,
652 int fillStyle
= wxODDEVEN_RULE
) = 0;
654 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
) = 0;
655 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
656 wxCoord width
, wxCoord height
) = 0;
658 // FIXME are these functions really different?
659 virtual void DoGetClippingRegion(wxCoord
*x
, wxCoord
*y
,
660 wxCoord
*w
, wxCoord
*h
)
661 { DoGetClippingBox(x
, y
, w
, h
); }
662 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
663 wxCoord
*w
, wxCoord
*h
) const
667 if ( x
) *x
= m_clipX1
;
668 if ( y
) *y
= m_clipY1
;
669 if ( w
) *w
= m_clipX2
- m_clipX1
;
670 if ( h
) *h
= m_clipY2
- m_clipY1
;
674 *x
= *y
= *w
= *h
= 0;
678 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
680 if ( x
) *x
= m_logicalOriginX
;
681 if ( y
) *y
= m_logicalOriginY
;
684 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
686 if ( x
) *x
= m_deviceOriginX
;
687 if ( y
) *y
= m_deviceOriginY
;
690 virtual void DoGetTextExtent(const wxString
& string
,
691 wxCoord
*x
, wxCoord
*y
,
692 wxCoord
*descent
= NULL
,
693 wxCoord
*externalLeading
= NULL
,
694 wxFont
*theFont
= NULL
) const = 0;
697 virtual void DoDrawSpline(wxList
*points
);
705 bool m_isInteractive
:1;
706 bool m_isBBoxValid
:1;
707 #if wxUSE_DC_CACHEING
708 // static bool sm_cacheing;
711 // coordinate system variables
713 // TODO short descriptions of what exactly they are would be nice...
715 wxCoord m_logicalOriginX
, m_logicalOriginY
;
716 wxCoord m_deviceOriginX
, m_deviceOriginY
;
718 double m_logicalScaleX
, m_logicalScaleY
;
719 double m_userScaleX
, m_userScaleY
;
720 double m_scaleX
, m_scaleY
;
722 // Used by SetAxisOrientation() to invert the axes
723 int m_signX
, m_signY
;
725 // bounding and clipping boxes
726 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
727 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
729 int m_logicalFunction
;
730 int m_backgroundMode
;
736 wxBrush m_backgroundBrush
;
737 wxColour m_textForegroundColour
;
738 wxColour m_textBackgroundColour
;
743 bool m_custompalette
;
744 #endif // wxUSE_PALETTE
747 DECLARE_NO_COPY_CLASS(wxDCBase
)
748 DECLARE_ABSTRACT_CLASS(wxDCBase
)
751 // ----------------------------------------------------------------------------
752 // now include the declaration of wxDC class
753 // ----------------------------------------------------------------------------
755 #if defined(__WXMSW__)
756 #include "wx/msw/dc.h"
757 #elif defined(__WXMOTIF__)
758 #include "wx/motif/dc.h"
759 #elif defined(__WXGTK__)
760 #include "wx/gtk/dc.h"
761 #elif defined(__WXX11__)
762 #include "wx/x11/dc.h"
763 #elif defined(__WXMGL__)
764 #include "wx/mgl/dc.h"
765 #elif defined(__WXMAC__)
766 #include "wx/mac/dc.h"
767 #elif defined(__WXPM__)
768 #include "wx/os2/dc.h"
769 #elif defined(__WXSTUBS__)
770 #include "wx/stubs/dc.h"
773 // ----------------------------------------------------------------------------
774 // helper class: you can use it to temporarily change the DC text colour and
775 // restore it automatically when the object goes out of scope
776 // ----------------------------------------------------------------------------
778 class WXDLLEXPORT wxDCTextColourChanger
781 wxDCTextColourChanger(wxDC
& dc
) : m_dc(dc
) { }
783 ~wxDCTextColourChanger()
785 if ( m_colFgOld
.Ok() )
786 m_dc
.SetTextForeground(m_colFgOld
);
789 void Set(const wxColour
& col
)
791 if ( !m_colFgOld
.Ok() )
792 m_colFgOld
= m_dc
.GetTextForeground();
793 m_dc
.SetTextForeground(col
);
802 // ----------------------------------------------------------------------------
803 // another small helper class: sets the clipping region in its ctor and
804 // destroys it in the dtor
805 // ----------------------------------------------------------------------------
807 class WXDLLEXPORT wxDCClipper
810 wxDCClipper(wxDC
& dc
, const wxRect
& r
) : m_dc(dc
)
811 { dc
.SetClippingRegion(r
.x
, r
.y
, r
.width
, r
.height
); }
812 wxDCClipper(wxDC
& dc
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) : m_dc(dc
)
813 { dc
.SetClippingRegion(x
, y
, w
, h
); }
815 ~wxDCClipper() { m_dc
.DestroyClippingRegion(); }