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_
15 #if defined(__GNUG__) && !defined(__APPLE__)
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
40 : m_isBBoxValid(FALSE
)
41 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
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
106 : m_colour(wxColourDisplay())
110 , m_isBBoxValid(FALSE
)
111 , m_logicalOriginX(0), m_logicalOriginY(0)
112 , m_deviceOriginX(0), m_deviceOriginY(0)
113 , m_logicalScaleX(1.0), m_logicalScaleY(1.0)
114 , m_userScaleX(1.0), m_userScaleY(1.0)
115 , m_scaleX(1.0), m_scaleY(1.0)
116 , m_signX(1), m_signY(1)
117 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
118 , m_clipX1(0), m_clipY1(0), m_clipX2(0), m_clipY2(0)
119 , m_logicalFunction(wxCOPY
)
120 , m_backgroundMode(wxTRANSPARENT
)
121 , m_mappingMode(wxMM_TEXT
)
124 , m_backgroundBrush(*wxTRANSPARENT_BRUSH
)
125 , m_textForegroundColour(*wxBLACK
)
126 , m_textBackgroundColour(*wxWHITE
)
130 , m_hasCustomPalette(FALSE
)
131 #endif // wxUSE_PALETTE
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 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
152 int style
= wxFLOOD_SURFACE
)
153 { return DoFloodFill(x
, y
, col
, style
); }
154 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
155 int style
= wxFLOOD_SURFACE
)
156 { return 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 DrawCircle(const wxPoint
& pt
, wxCoord radius
)
231 { DrawCircle(pt
.x
, pt
.y
, radius
); }
233 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
234 { DoDrawEllipse(x
, y
, width
, height
); }
235 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
236 { DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
237 void DrawEllipse(const wxRect
& rect
)
238 { DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
240 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
241 { DoDrawIcon(icon
, x
, y
); }
242 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
243 { DoDrawIcon(icon
, pt
.x
, pt
.y
); }
245 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
246 bool useMask
= FALSE
)
247 { DoDrawBitmap(bmp
, x
, y
, useMask
); }
248 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
249 bool useMask
= FALSE
)
250 { DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
252 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
253 { DoDrawText(text
, x
, y
); }
254 void DrawText(const wxString
& text
, const wxPoint
& pt
)
255 { DoDrawText(text
, pt
.x
, pt
.y
); }
257 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
258 { DoDrawRotatedText(text
, x
, y
, angle
); }
259 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
260 { DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
262 // this version puts both optional bitmap and the text into the given
263 // rectangle and aligns is as specified by alignment parameter; it also
264 // will emphasize the character with the given index if it is != -1 and
265 // return the bounding rectangle if required
266 virtual void DrawLabel(const wxString
& text
,
267 const wxBitmap
& image
,
269 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
271 wxRect
*rectBounding
= NULL
);
273 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
274 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
276 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
278 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
279 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
280 int rop
= wxCOPY
, bool useMask
= FALSE
, wxCoord xsrcMask
= -1, wxCoord ysrcMask
= -1)
282 return DoBlit(xdest
, ydest
, width
, height
,
283 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
285 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
286 wxDC
*source
, const wxPoint
& srcPt
,
287 int rop
= wxCOPY
, bool useMask
= FALSE
, const wxPoint
& srcPtMask
= wxPoint(-1, -1))
289 return DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
290 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
294 // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?)
295 void DrawSpline(wxCoord x1
, wxCoord y1
,
296 wxCoord x2
, wxCoord y2
,
297 wxCoord x3
, wxCoord y3
);
298 void DrawSpline(int n
, wxPoint points
[]);
300 void DrawSpline(wxList
*points
) { DoDrawSpline(points
); }
301 #endif // wxUSE_SPLINES
303 // global DC operations
304 // --------------------
306 virtual void Clear() = 0;
308 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return TRUE
; }
309 virtual void EndDoc() { }
311 virtual void StartPage() { }
312 virtual void EndPage() { }
314 // set objects to use for drawing
315 // ------------------------------
317 virtual void SetFont(const wxFont
& font
) = 0;
318 virtual void SetPen(const wxPen
& pen
) = 0;
319 virtual void SetBrush(const wxBrush
& brush
) = 0;
320 virtual void SetBackground(const wxBrush
& brush
) = 0;
321 virtual void SetBackgroundMode(int mode
) = 0;
323 virtual void SetPalette(const wxPalette
& palette
) = 0;
324 #endif // wxUSE_PALETTE
329 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
330 { DoSetClippingRegion(x
, y
, width
, height
); }
331 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
332 { DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
333 void SetClippingRegion(const wxRect
& rect
)
334 { DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
335 void SetClippingRegion(const wxRegion
& region
)
336 { DoSetClippingRegionAsRegion(region
); }
338 virtual void DestroyClippingRegion() = 0;
340 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
341 { DoGetClippingBox(x
, y
, w
, h
); }
342 void GetClippingBox(wxRect
& rect
) const
344 // Necessary to use intermediate variables for 16-bit compilation
346 DoGetClippingBox(&x
, &y
, &w
, &h
);
347 rect
.x
= x
; rect
.y
= y
; rect
.width
= w
; rect
.height
= h
;
353 virtual wxCoord
GetCharHeight() const = 0;
354 virtual wxCoord
GetCharWidth() const = 0;
356 // only works for single line strings
357 void GetTextExtent(const wxString
& string
,
358 wxCoord
*x
, wxCoord
*y
,
359 wxCoord
*descent
= NULL
,
360 wxCoord
*externalLeading
= NULL
,
361 wxFont
*theFont
= NULL
) const
362 { DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
364 // works for single as well as multi-line strings
365 virtual void GetMultiLineTextExtent(const wxString
& text
,
368 wxCoord
*heightLine
= NULL
,
369 wxFont
*font
= NULL
);
371 // size and resolution
372 // -------------------
375 void GetSize(int *width
, int *height
) const
376 { DoGetSize(width
, height
); }
377 wxSize
GetSize() const
386 void GetSizeMM(int* width
, int* height
) const
387 { DoGetSizeMM(width
, height
); }
388 wxSize
GetSizeMM() const
396 // coordinates conversions
397 // -----------------------
399 // This group of functions does actual conversion of the input, as you'd
401 wxCoord
DeviceToLogicalX(wxCoord x
) const;
402 wxCoord
DeviceToLogicalY(wxCoord y
) const;
403 wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
404 wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
405 wxCoord
LogicalToDeviceX(wxCoord x
) const;
406 wxCoord
LogicalToDeviceY(wxCoord y
) const;
407 wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
408 wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
410 // query DC capabilities
411 // ---------------------
413 virtual bool CanDrawBitmap() const = 0;
414 virtual bool CanGetTextExtent() const = 0;
417 virtual int GetDepth() const = 0;
419 // Resolution in Pixels per inch
420 virtual wxSize
GetPPI() const = 0;
422 virtual bool Ok() const { return m_ok
; }
428 int GetBackgroundMode() const { return m_backgroundMode
; }
429 const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
430 const wxBrush
& GetBrush() const { return m_brush
; }
431 const wxFont
& GetFont() const { return m_font
; }
432 const wxPen
& GetPen() const { return m_pen
; }
433 const wxColour
& GetTextBackground() const { return m_textBackgroundColour
; }
434 const wxColour
& GetTextForeground() const { return m_textForegroundColour
; }
437 wxBrush
& GetBackground() { return m_backgroundBrush
; }
438 wxBrush
& GetBrush() { return m_brush
; }
439 wxFont
& GetFont() { return m_font
; }
440 wxPen
& GetPen() { return m_pen
; }
441 wxColour
& GetTextBackground() { return m_textBackgroundColour
; }
442 wxColour
& GetTextForeground() { return m_textForegroundColour
; }
444 virtual void SetTextForeground(const wxColour
& colour
)
445 { m_textForegroundColour
= colour
; }
446 virtual void SetTextBackground(const wxColour
& colour
)
447 { m_textBackgroundColour
= colour
; }
449 int GetMapMode() const { return m_mappingMode
; }
450 virtual void SetMapMode(int mode
) = 0;
452 virtual void GetUserScale(double *x
, double *y
) const
454 if ( x
) *x
= m_userScaleX
;
455 if ( y
) *y
= m_userScaleY
;
457 virtual void SetUserScale(double x
, double y
) = 0;
459 virtual void GetLogicalScale(double *x
, double *y
)
461 if ( x
) *x
= m_logicalScaleX
;
462 if ( y
) *y
= m_logicalScaleY
;
464 virtual void SetLogicalScale(double x
, double y
)
470 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
471 { DoGetLogicalOrigin(x
, y
); }
472 wxPoint
GetLogicalOrigin() const
473 { wxCoord x
, y
; DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
474 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
) = 0;
476 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
477 { DoGetDeviceOrigin(x
, y
); }
478 wxPoint
GetDeviceOrigin() const
479 { wxCoord x
, y
; DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
480 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
) = 0;
482 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
) = 0;
484 int GetLogicalFunction() const { return m_logicalFunction
; }
485 virtual void SetLogicalFunction(int function
) = 0;
487 // Sometimes we need to override optimization, e.g. if other software is
488 // drawing onto our surface and we can't be sure of who's done what.
490 // FIXME: is this (still) used?
491 virtual void SetOptimization(bool WXUNUSED(opt
)) { }
492 virtual bool GetOptimization() { return FALSE
; }
494 // Some platforms have a DC cache, which should be cleared
495 // at appropriate points such as after a series of DC operations.
496 // Put ClearCache in the wxDC implementation class, since it has to be
498 // static void ClearCache() ;
499 #if 0 // wxUSE_DC_CACHEING
500 static void EnableCache(bool cacheing
) { sm_cacheing
= cacheing
; }
501 static bool CacheEnabled() { return sm_cacheing
; }
507 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
511 if ( x
< m_minX
) m_minX
= x
;
512 if ( y
< m_minY
) m_minY
= y
;
513 if ( x
> m_maxX
) m_maxX
= x
;
514 if ( y
> m_maxY
) m_maxY
= y
;
518 m_isBBoxValid
= TRUE
;
527 void ResetBoundingBox()
529 m_isBBoxValid
= FALSE
;
531 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
534 // Get the final bounding box of the PostScript or Metafile picture.
535 wxCoord
MinX() const { return m_minX
; }
536 wxCoord
MaxX() const { return m_maxX
; }
537 wxCoord
MinY() const { return m_minY
; }
538 wxCoord
MaxY() const { return m_maxY
; }
540 // misc old functions
541 // ------------------
543 // for compatibility with the old code when wxCoord was long everywhere
545 void GetTextExtent(const wxString
& string
,
547 long *descent
= NULL
,
548 long *externalLeading
= NULL
,
549 wxFont
*theFont
= NULL
) const
551 wxCoord x2
, y2
, descent2
, externalLeading2
;
552 DoGetTextExtent(string
, &x2
, &y2
,
553 &descent2
, &externalLeading2
,
561 if ( externalLeading
)
562 *externalLeading
= externalLeading2
;
565 void GetLogicalOrigin(long *x
, long *y
) const
568 DoGetLogicalOrigin(&x2
, &y2
);
575 void GetDeviceOrigin(long *x
, long *y
) const
578 DoGetDeviceOrigin(&x2
, &y2
);
584 void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const
587 DoGetClippingBox(&xx
, &yy
, &ww
, &hh
);
595 #if WXWIN_COMPATIBILITY
598 virtual void SetColourMap(const wxPalette
& palette
) { SetPalette(palette
); }
599 #endif // wxUSE_PALETTE
601 void GetTextExtent(const wxString
& string
, float *x
, float *y
,
602 float *descent
= NULL
, float *externalLeading
= NULL
,
603 wxFont
*theFont
= NULL
, bool use16bit
= FALSE
) const ;
604 void GetSize(float* width
, float* height
) const { int w
, h
; GetSize(& w
, & h
); *width
= w
; *height
= h
; }
605 void GetSizeMM(float *width
, float *height
) const { int w
, h
; GetSizeMM(& w
, & h
); *width
= (float) w
; *height
= (float) h
; }
607 #endif // WXWIN_COMPATIBILITY
610 // the pure virtual functions which should be implemented by wxDC
611 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
612 int style
= wxFLOOD_SURFACE
) = 0;
614 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
616 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
617 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
619 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
620 wxCoord x2
, wxCoord y2
,
621 wxCoord xc
, wxCoord yc
) = 0;
622 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
623 wxCoord width
, wxCoord height
);
624 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
625 double sa
, double ea
) = 0;
627 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
628 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
629 wxCoord width
, wxCoord height
,
631 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
632 wxCoord width
, wxCoord height
) = 0;
634 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
636 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
637 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
638 bool useMask
= FALSE
) = 0;
640 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
641 virtual void DoDrawRotatedText(const wxString
& text
,
642 wxCoord x
, wxCoord y
, double angle
) = 0;
644 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
645 wxCoord width
, wxCoord height
,
646 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
647 int rop
= wxCOPY
, bool useMask
= FALSE
, wxCoord xsrcMask
= -1, wxCoord ysrcMask
= -1) = 0;
649 virtual void DoGetSize(int *width
, int *height
) const = 0;
650 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
652 virtual void DoDrawLines(int n
, wxPoint points
[],
653 wxCoord xoffset
, wxCoord yoffset
) = 0;
654 virtual void DoDrawPolygon(int n
, wxPoint points
[],
655 wxCoord xoffset
, wxCoord yoffset
,
656 int fillStyle
= wxODDEVEN_RULE
) = 0;
658 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
) = 0;
659 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
660 wxCoord width
, wxCoord height
) = 0;
662 // FIXME are these functions really different?
663 virtual void DoGetClippingRegion(wxCoord
*x
, wxCoord
*y
,
664 wxCoord
*w
, wxCoord
*h
)
665 { DoGetClippingBox(x
, y
, w
, h
); }
666 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
667 wxCoord
*w
, wxCoord
*h
) const
671 if ( x
) *x
= m_clipX1
;
672 if ( y
) *y
= m_clipY1
;
673 if ( w
) *w
= m_clipX2
- m_clipX1
;
674 if ( h
) *h
= m_clipY2
- m_clipY1
;
678 *x
= *y
= *w
= *h
= 0;
682 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
684 if ( x
) *x
= m_logicalOriginX
;
685 if ( y
) *y
= m_logicalOriginY
;
688 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
690 if ( x
) *x
= m_deviceOriginX
;
691 if ( y
) *y
= m_deviceOriginY
;
694 virtual void DoGetTextExtent(const wxString
& string
,
695 wxCoord
*x
, wxCoord
*y
,
696 wxCoord
*descent
= NULL
,
697 wxCoord
*externalLeading
= NULL
,
698 wxFont
*theFont
= NULL
) const = 0;
701 virtual void DoDrawSpline(wxList
*points
);
709 bool m_isInteractive
:1;
710 bool m_isBBoxValid
:1;
711 #if wxUSE_DC_CACHEING
712 // static bool sm_cacheing;
715 // coordinate system variables
717 // TODO short descriptions of what exactly they are would be nice...
719 wxCoord m_logicalOriginX
, m_logicalOriginY
;
720 wxCoord m_deviceOriginX
, m_deviceOriginY
;
722 double m_logicalScaleX
, m_logicalScaleY
;
723 double m_userScaleX
, m_userScaleY
;
724 double m_scaleX
, m_scaleY
;
726 // Used by SetAxisOrientation() to invert the axes
727 int m_signX
, m_signY
;
729 // bounding and clipping boxes
730 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
731 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
733 int m_logicalFunction
;
734 int m_backgroundMode
;
740 wxBrush m_backgroundBrush
;
741 wxColour m_textForegroundColour
;
742 wxColour m_textBackgroundColour
;
747 bool m_hasCustomPalette
;
748 #endif // wxUSE_PALETTE
751 DECLARE_NO_COPY_CLASS(wxDCBase
)
752 DECLARE_ABSTRACT_CLASS(wxDCBase
)
755 // ----------------------------------------------------------------------------
756 // now include the declaration of wxDC class
757 // ----------------------------------------------------------------------------
759 #if defined(__WXMSW__)
760 #include "wx/msw/dc.h"
761 #elif defined(__WXMOTIF__)
762 #include "wx/motif/dc.h"
763 #elif defined(__WXGTK__)
764 #include "wx/gtk/dc.h"
765 #elif defined(__WXX11__)
766 #include "wx/x11/dc.h"
767 #elif defined(__WXMGL__)
768 #include "wx/mgl/dc.h"
769 #elif defined(__WXMAC__)
770 #include "wx/mac/dc.h"
771 #elif defined(__WXPM__)
772 #include "wx/os2/dc.h"
775 // ----------------------------------------------------------------------------
776 // helper class: you can use it to temporarily change the DC text colour and
777 // restore it automatically when the object goes out of scope
778 // ----------------------------------------------------------------------------
780 class WXDLLEXPORT wxDCTextColourChanger
783 wxDCTextColourChanger(wxDC
& dc
) : m_dc(dc
), m_colFgOld() { }
785 ~wxDCTextColourChanger()
787 if ( m_colFgOld
.Ok() )
788 m_dc
.SetTextForeground(m_colFgOld
);
791 void Set(const wxColour
& col
)
793 if ( !m_colFgOld
.Ok() )
794 m_colFgOld
= m_dc
.GetTextForeground();
795 m_dc
.SetTextForeground(col
);
804 // ----------------------------------------------------------------------------
805 // another small helper class: sets the clipping region in its ctor and
806 // destroys it in the dtor
807 // ----------------------------------------------------------------------------
809 class WXDLLEXPORT wxDCClipper
812 wxDCClipper(wxDC
& dc
, const wxRect
& r
) : m_dc(dc
)
813 { dc
.SetClippingRegion(r
.x
, r
.y
, r
.width
, r
.height
); }
814 wxDCClipper(wxDC
& dc
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) : m_dc(dc
)
815 { dc
.SetClippingRegion(x
, y
, w
, h
); }
817 ~wxDCClipper() { m_dc
.DestroyClippingRegion(); }