1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_DC_H_BASE_
13 #define _WX_DC_H_BASE_
15 // ----------------------------------------------------------------------------
16 // headers which we must include here
17 // ----------------------------------------------------------------------------
19 #include "wx/object.h" // the base class
21 #include "wx/cursor.h" // we have member variables of these classes
22 #include "wx/font.h" // so we can't do without them
23 #include "wx/colour.h"
24 #include "wx/bitmap.h" // for wxNullBitmap
27 #include "wx/palette.h"
28 #include "wx/list.h" // we use wxList in inline functions
29 #include "wx/dynarray.h"
32 class WXDLLEXPORT wxDC
;
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 extern WXDLLEXPORT_DATA(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
139 #if WXWIN_COMPATIBILITY_2_6
140 wxDEPRECATED( virtual void BeginDrawing() );
141 wxDEPRECATED( virtual void EndDrawing() );
142 #endif // WXWIN_COMPATIBILITY_2_6
144 // graphic primitives
145 // ------------------
147 virtual void DrawObject(wxDrawObject
* drawobject
)
149 drawobject
->Draw(*this);
150 CalcBoundingBox(drawobject
->MinX(),drawobject
->MinY());
151 CalcBoundingBox(drawobject
->MaxX(),drawobject
->MaxY());
154 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
155 int style
= wxFLOOD_SURFACE
)
156 { return DoFloodFill(x
, y
, col
, style
); }
157 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
158 int style
= wxFLOOD_SURFACE
)
159 { return DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
161 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
162 { return DoGetPixel(x
, y
, col
); }
163 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
164 { return DoGetPixel(pt
.x
, pt
.y
, col
); }
166 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
167 { DoDrawLine(x1
, y1
, x2
, y2
); }
168 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
169 { DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
171 void CrossHair(wxCoord x
, wxCoord y
)
172 { DoCrossHair(x
, y
); }
173 void CrossHair(const wxPoint
& pt
)
174 { DoCrossHair(pt
.x
, pt
.y
); }
176 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
177 wxCoord xc
, wxCoord yc
)
178 { DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
179 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
180 { DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
182 void DrawCheckMark(wxCoord x
, wxCoord y
,
183 wxCoord width
, wxCoord height
)
184 { DoDrawCheckMark(x
, y
, width
, height
); }
185 void DrawCheckMark(const wxRect
& rect
)
186 { DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
188 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
189 double sa
, double ea
)
190 { DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
191 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
192 double sa
, double ea
)
193 { DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
195 void DrawPoint(wxCoord x
, wxCoord y
)
196 { DoDrawPoint(x
, y
); }
197 void DrawPoint(const wxPoint
& pt
)
198 { DoDrawPoint(pt
.x
, pt
.y
); }
200 void DrawLines(int n
, wxPoint points
[],
201 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
202 { DoDrawLines(n
, points
, xoffset
, yoffset
); }
203 void DrawLines(const wxList
*list
,
204 wxCoord xoffset
= 0, wxCoord yoffset
= 0);
206 void DrawPolygon(int n
, wxPoint points
[],
207 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
208 int fillStyle
= wxODDEVEN_RULE
)
209 { DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
211 void DrawPolygon(const wxList
*list
,
212 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
213 int fillStyle
= wxODDEVEN_RULE
);
215 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
216 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
217 int fillStyle
= wxODDEVEN_RULE
)
218 { DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
220 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
221 { DoDrawRectangle(x
, y
, width
, height
); }
222 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
223 { DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
224 void DrawRectangle(const wxRect
& rect
)
225 { DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
227 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
229 { DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
230 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
232 { DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
233 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
234 { DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
236 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
237 { DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
238 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
239 { DrawCircle(pt
.x
, pt
.y
, radius
); }
241 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
242 { DoDrawEllipse(x
, y
, width
, height
); }
243 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
244 { DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
245 void DrawEllipse(const wxRect
& rect
)
246 { DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
248 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
249 { DoDrawIcon(icon
, x
, y
); }
250 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
251 { DoDrawIcon(icon
, pt
.x
, pt
.y
); }
253 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
254 bool useMask
= false)
255 { DoDrawBitmap(bmp
, x
, y
, useMask
); }
256 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
257 bool useMask
= false)
258 { DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
260 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
261 { DoDrawText(text
, x
, y
); }
262 void DrawText(const wxString
& text
, const wxPoint
& pt
)
263 { DoDrawText(text
, pt
.x
, pt
.y
); }
265 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
266 { DoDrawRotatedText(text
, x
, y
, angle
); }
267 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
268 { DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
270 // this version puts both optional bitmap and the text into the given
271 // rectangle and aligns is as specified by alignment parameter; it also
272 // will emphasize the character with the given index if it is != -1 and
273 // return the bounding rectangle if required
274 virtual void DrawLabel(const wxString
& text
,
275 const wxBitmap
& image
,
277 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
279 wxRect
*rectBounding
= NULL
);
281 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
282 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
284 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
286 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
287 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
288 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
290 return DoBlit(xdest
, ydest
, width
, height
,
291 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
293 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
294 wxDC
*source
, const wxPoint
& srcPt
,
295 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcPtMask
= wxDefaultPosition
)
297 return DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
298 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
302 // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?)
303 void DrawSpline(wxCoord x1
, wxCoord y1
,
304 wxCoord x2
, wxCoord y2
,
305 wxCoord x3
, wxCoord y3
);
306 void DrawSpline(int n
, wxPoint points
[]);
308 void DrawSpline(wxList
*points
) { DoDrawSpline(points
); }
309 #endif // wxUSE_SPLINES
311 // Eventually we will have wxUSE_GENERIC_DRAWELLIPSE
313 //! Generic method to draw ellipses, circles and arcs with current pen and brush.
314 /*! \param x Upper left corner of bounding box.
315 * \param y Upper left corner of bounding box.
316 * \param w Width of bounding box.
317 * \param h Height of bounding box.
318 * \param sa Starting angle of arc
319 * (counterclockwise, start at 3 o'clock, 360 is full circle).
320 * \param ea Ending angle of arc.
321 * \param angle Rotation angle, the Arc will be rotated after
322 * calculating begin and end.
324 void DrawEllipticArcRot( wxCoord x
, wxCoord y
,
325 wxCoord width
, wxCoord height
,
326 double sa
= 0, double ea
= 0, double angle
= 0 )
327 { DoDrawEllipticArcRot( x
, y
, width
, height
, sa
, ea
, angle
); }
329 void DrawEllipticArcRot( const wxPoint
& pt
,
331 double sa
= 0, double ea
= 0, double angle
= 0 )
332 { DoDrawEllipticArcRot( pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
, angle
); }
334 void DrawEllipticArcRot( const wxRect
& rect
,
335 double sa
= 0, double ea
= 0, double angle
= 0 )
336 { DoDrawEllipticArcRot( rect
.x
, rect
.y
, rect
.width
, rect
.height
, sa
, ea
, angle
); }
338 virtual void DoDrawEllipticArcRot( wxCoord x
, wxCoord y
,
339 wxCoord w
, wxCoord h
,
340 double sa
= 0, double ea
= 0, double angle
= 0 );
342 //! Rotates points around center.
343 /*! This is a quite straight method, it calculates in pixels
344 * and so it produces rounding errors.
345 * \param points The points inside will be rotated.
346 * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle).
347 * \param center Center of rotation.
349 void Rotate( wxList
* points
, double angle
, wxPoint center
= wxPoint(0,0) );
351 // used by DrawEllipticArcRot
352 // Careful: wxList gets filled with points you have to delete later.
353 void CalculateEllipticPoints( wxList
* points
,
354 wxCoord xStart
, wxCoord yStart
,
355 wxCoord w
, wxCoord h
,
356 double sa
, double ea
);
359 // global DC operations
360 // --------------------
362 virtual void Clear() = 0;
364 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
365 virtual void EndDoc() { }
367 virtual void StartPage() { }
368 virtual void EndPage() { }
370 // set objects to use for drawing
371 // ------------------------------
373 virtual void SetFont(const wxFont
& font
) = 0;
374 virtual void SetPen(const wxPen
& pen
) = 0;
375 virtual void SetBrush(const wxBrush
& brush
) = 0;
376 virtual void SetBackground(const wxBrush
& brush
) = 0;
377 virtual void SetBackgroundMode(int mode
) = 0;
379 virtual void SetPalette(const wxPalette
& palette
) = 0;
380 #endif // wxUSE_PALETTE
385 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
386 { DoSetClippingRegion(x
, y
, width
, height
); }
387 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
388 { DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
389 void SetClippingRegion(const wxRect
& rect
)
390 { DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
391 void SetClippingRegion(const wxRegion
& region
)
392 { DoSetClippingRegionAsRegion(region
); }
394 virtual void DestroyClippingRegion() { ResetClipping(); }
396 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
397 { DoGetClippingBox(x
, y
, w
, h
); }
398 void GetClippingBox(wxRect
& rect
) const
400 DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
);
406 virtual wxCoord
GetCharHeight() const = 0;
407 virtual wxCoord
GetCharWidth() const = 0;
409 // only works for single line strings
410 void GetTextExtent(const wxString
& string
,
411 wxCoord
*x
, wxCoord
*y
,
412 wxCoord
*descent
= NULL
,
413 wxCoord
*externalLeading
= NULL
,
414 wxFont
*theFont
= NULL
) const
415 { DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
417 // works for single as well as multi-line strings
418 virtual void GetMultiLineTextExtent(const wxString
& text
,
421 wxCoord
*heightLine
= NULL
,
422 wxFont
*font
= NULL
);
424 // Measure cumulative width of text after each character
425 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
426 { return DoGetPartialTextExtents(text
, widths
); }
429 // size and resolution
430 // -------------------
433 void GetSize(int *width
, int *height
) const
434 { DoGetSize(width
, height
); }
435 wxSize
GetSize() const
444 void GetSizeMM(int* width
, int* height
) const
445 { DoGetSizeMM(width
, height
); }
446 wxSize
GetSizeMM() const
454 // coordinates conversions
455 // -----------------------
457 // This group of functions does actual conversion of the input, as you'd
459 wxCoord
DeviceToLogicalX(wxCoord x
) const;
460 wxCoord
DeviceToLogicalY(wxCoord y
) const;
461 wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
462 wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
463 wxCoord
LogicalToDeviceX(wxCoord x
) const;
464 wxCoord
LogicalToDeviceY(wxCoord y
) const;
465 wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
466 wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
468 // query DC capabilities
469 // ---------------------
471 virtual bool CanDrawBitmap() const = 0;
472 virtual bool CanGetTextExtent() const = 0;
475 virtual int GetDepth() const = 0;
477 // Resolution in Pixels per inch
478 virtual wxSize
GetPPI() const = 0;
480 virtual bool Ok() const { return m_ok
; }
482 // accessors and setters
483 // ---------------------
485 int GetBackgroundMode() const { return m_backgroundMode
; }
486 const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
487 const wxBrush
& GetBrush() const { return m_brush
; }
488 const wxFont
& GetFont() const { return m_font
; }
489 const wxPen
& GetPen() const { return m_pen
; }
491 const wxColour
& GetTextForeground() const { return m_textForegroundColour
; }
492 const wxColour
& GetTextBackground() const { return m_textBackgroundColour
; }
493 virtual void SetTextForeground(const wxColour
& colour
)
494 { m_textForegroundColour
= colour
; }
495 virtual void SetTextBackground(const wxColour
& colour
)
496 { m_textBackgroundColour
= colour
; }
498 int GetMapMode() const { return m_mappingMode
; }
499 virtual void SetMapMode(int mode
) = 0;
501 virtual void GetUserScale(double *x
, double *y
) const
503 if ( x
) *x
= m_userScaleX
;
504 if ( y
) *y
= m_userScaleY
;
506 virtual void SetUserScale(double x
, double y
) = 0;
508 virtual void GetLogicalScale(double *x
, double *y
)
510 if ( x
) *x
= m_logicalScaleX
;
511 if ( y
) *y
= m_logicalScaleY
;
513 virtual void SetLogicalScale(double x
, double y
)
519 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
520 { DoGetLogicalOrigin(x
, y
); }
521 wxPoint
GetLogicalOrigin() const
522 { wxCoord x
, y
; DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
523 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
) = 0;
525 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
526 { DoGetDeviceOrigin(x
, y
); }
527 wxPoint
GetDeviceOrigin() const
528 { wxCoord x
, y
; DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
529 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
) = 0;
531 virtual void ComputeScaleAndOrigin() {}
533 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
) = 0;
535 int GetLogicalFunction() const { return m_logicalFunction
; }
536 virtual void SetLogicalFunction(int function
) = 0;
538 #if WXWIN_COMPATIBILITY_2_4
539 virtual void SetOptimization(bool WXUNUSED(opt
)) { }
540 virtual bool GetOptimization() { return false; }
546 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
550 if ( x
< m_minX
) m_minX
= x
;
551 if ( y
< m_minY
) m_minY
= y
;
552 if ( x
> m_maxX
) m_maxX
= x
;
553 if ( y
> m_maxY
) m_maxY
= y
;
557 m_isBBoxValid
= true;
566 void ResetBoundingBox()
568 m_isBBoxValid
= false;
570 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
573 // Get the final bounding box of the PostScript or Metafile picture.
574 wxCoord
MinX() const { return m_minX
; }
575 wxCoord
MaxX() const { return m_maxX
; }
576 wxCoord
MinY() const { return m_minY
; }
577 wxCoord
MaxY() const { return m_maxY
; }
579 // misc old functions
580 // ------------------
582 // for compatibility with the old code when wxCoord was long everywhere
583 void GetTextExtent(const wxString
& string
,
585 long *descent
= NULL
,
586 long *externalLeading
= NULL
,
587 wxFont
*theFont
= NULL
) const
589 wxCoord x2
, y2
, descent2
, externalLeading2
;
590 DoGetTextExtent(string
, &x2
, &y2
,
591 &descent2
, &externalLeading2
,
599 if ( externalLeading
)
600 *externalLeading
= externalLeading2
;
603 void GetLogicalOrigin(long *x
, long *y
) const
606 DoGetLogicalOrigin(&x2
, &y2
);
613 void GetDeviceOrigin(long *x
, long *y
) const
616 DoGetDeviceOrigin(&x2
, &y2
);
622 void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const
625 DoGetClippingBox(&xx
, &yy
, &ww
, &hh
);
632 // Reserved for future use
633 virtual void ReservedDCFunc1() {}
634 virtual void ReservedDCFunc2() {}
635 virtual void ReservedDCFunc3() {}
636 virtual void ReservedDCFunc4() {}
637 virtual void ReservedDCFunc5() {}
638 virtual void ReservedDCFunc6() {}
639 virtual void ReservedDCFunc7() {}
640 virtual void ReservedDCFunc8() {}
641 virtual void ReservedDCFunc9() {}
644 // the pure virtual functions which should be implemented by wxDC
645 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
646 int style
= wxFLOOD_SURFACE
) = 0;
648 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
650 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
651 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
653 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
654 wxCoord x2
, wxCoord y2
,
655 wxCoord xc
, wxCoord yc
) = 0;
656 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
657 wxCoord width
, wxCoord height
);
658 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
659 double sa
, double ea
) = 0;
661 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
662 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
663 wxCoord width
, wxCoord height
,
665 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
666 wxCoord width
, wxCoord height
) = 0;
668 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
670 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
671 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
672 bool useMask
= false) = 0;
674 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
675 virtual void DoDrawRotatedText(const wxString
& text
,
676 wxCoord x
, wxCoord y
, double angle
) = 0;
678 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
679 wxCoord width
, wxCoord height
,
680 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
681 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
) = 0;
683 virtual void DoGetSize(int *width
, int *height
) const = 0;
684 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
686 virtual void DoDrawLines(int n
, wxPoint points
[],
687 wxCoord xoffset
, wxCoord yoffset
) = 0;
688 virtual void DoDrawPolygon(int n
, wxPoint points
[],
689 wxCoord xoffset
, wxCoord yoffset
,
690 int fillStyle
= wxODDEVEN_RULE
) = 0;
691 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
692 wxCoord xoffset
, wxCoord yoffset
,
695 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
) = 0;
696 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
697 wxCoord width
, wxCoord height
) = 0;
699 #if WXWIN_COMPATIBILITY_2_4
700 // this was only for confusing people, use DoGetClippingBox only
701 virtual void DoGetClippingRegion(wxCoord
*x
, wxCoord
*y
,
702 wxCoord
*w
, wxCoord
*h
)
703 { DoGetClippingBox(x
, y
, w
, h
); }
706 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
707 wxCoord
*w
, wxCoord
*h
) const
714 *w
= m_clipX2
- m_clipX1
;
716 *h
= m_clipY2
- m_clipY1
;
719 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
721 if ( x
) *x
= m_logicalOriginX
;
722 if ( y
) *y
= m_logicalOriginY
;
725 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
727 if ( x
) *x
= m_deviceOriginX
;
728 if ( y
) *y
= m_deviceOriginY
;
731 virtual void DoGetTextExtent(const wxString
& string
,
732 wxCoord
*x
, wxCoord
*y
,
733 wxCoord
*descent
= NULL
,
734 wxCoord
*externalLeading
= NULL
,
735 wxFont
*theFont
= NULL
) const = 0;
737 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
740 virtual void DoDrawSpline(wxList
*points
);
744 // unset clipping variables (after clipping region was destroyed)
749 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
756 bool m_isInteractive
:1;
757 bool m_isBBoxValid
:1;
759 // coordinate system variables
761 // TODO short descriptions of what exactly they are would be nice...
763 wxCoord m_logicalOriginX
, m_logicalOriginY
;
764 wxCoord m_deviceOriginX
, m_deviceOriginY
;
766 double m_logicalScaleX
, m_logicalScaleY
;
767 double m_userScaleX
, m_userScaleY
;
768 double m_scaleX
, m_scaleY
;
770 // Used by SetAxisOrientation() to invert the axes
771 int m_signX
, m_signY
;
773 // bounding and clipping boxes
774 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
775 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
777 int m_logicalFunction
;
778 int m_backgroundMode
;
784 wxBrush m_backgroundBrush
;
785 wxColour m_textForegroundColour
;
786 wxColour m_textBackgroundColour
;
791 bool m_hasCustomPalette
;
792 #endif // wxUSE_PALETTE
795 DECLARE_NO_COPY_CLASS(wxDCBase
)
796 DECLARE_ABSTRACT_CLASS(wxDCBase
)
799 // ----------------------------------------------------------------------------
800 // now include the declaration of wxDC class
801 // ----------------------------------------------------------------------------
803 #if defined(__WXPALMOS__)
804 #include "wx/palmos/dc.h"
805 #elif defined(__WXMSW__)
806 #include "wx/msw/dc.h"
807 #elif defined(__WXMOTIF__)
808 #include "wx/motif/dc.h"
809 #elif defined(__WXGTK20__)
810 #include "wx/gtk/dc.h"
811 #elif defined(__WXGTK__)
812 #include "wx/gtk1/dc.h"
813 #elif defined(__WXX11__)
814 #include "wx/x11/dc.h"
815 #elif defined(__WXMGL__)
816 #include "wx/mgl/dc.h"
817 #elif defined(__WXMAC__)
818 #include "wx/mac/dc.h"
819 #elif defined(__WXCOCOA__)
820 #include "wx/cocoa/dc.h"
821 #elif defined(__WXPM__)
822 #include "wx/os2/dc.h"
825 // ----------------------------------------------------------------------------
826 // helper class: you can use it to temporarily change the DC text colour and
827 // restore it automatically when the object goes out of scope
828 // ----------------------------------------------------------------------------
830 class WXDLLEXPORT wxDCTextColourChanger
833 wxDCTextColourChanger(wxDC
& dc
) : m_dc(dc
), m_colFgOld() { }
835 ~wxDCTextColourChanger()
837 if ( m_colFgOld
.Ok() )
838 m_dc
.SetTextForeground(m_colFgOld
);
841 void Set(const wxColour
& col
)
843 if ( !m_colFgOld
.Ok() )
844 m_colFgOld
= m_dc
.GetTextForeground();
845 m_dc
.SetTextForeground(col
);
853 DECLARE_NO_COPY_CLASS(wxDCTextColourChanger
)
856 // ----------------------------------------------------------------------------
857 // another small helper class: sets the clipping region in its ctor and
858 // destroys it in the dtor
859 // ----------------------------------------------------------------------------
861 class WXDLLEXPORT wxDCClipper
864 wxDCClipper(wxDC
& dc
, const wxRect
& r
) : m_dc(dc
)
865 { dc
.SetClippingRegion(r
.x
, r
.y
, r
.width
, r
.height
); }
866 wxDCClipper(wxDC
& dc
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) : m_dc(dc
)
867 { dc
.SetClippingRegion(x
, y
, w
, h
); }
869 ~wxDCClipper() { m_dc
.DestroyClippingRegion(); }
874 DECLARE_NO_COPY_CLASS(wxDCClipper
)