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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
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"
28 #include "wx/bitmap.h" // for wxNullBitmap
31 #include "wx/palette.h"
32 #include "wx/list.h" // we use wxList in inline functions
33 #include "wx/dynarray.h"
36 class WXDLLEXPORT wxDC
;
37 class WXDLLEXPORT wxDCBase
;
39 class WXDLLEXPORT wxDrawObject
44 : m_isBBoxValid(false)
45 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
48 virtual ~wxDrawObject() { }
50 virtual void Draw(wxDCBase
&) const { }
52 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
56 if ( x
< m_minX
) m_minX
= x
;
57 if ( y
< m_minY
) m_minY
= y
;
58 if ( x
> m_maxX
) m_maxX
= x
;
59 if ( y
> m_maxY
) m_maxY
= y
;
72 void ResetBoundingBox()
74 m_isBBoxValid
= false;
76 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
79 // Get the final bounding box of the PostScript or Metafile picture.
81 wxCoord
MinX() const { return m_minX
; }
82 wxCoord
MaxX() const { return m_maxX
; }
83 wxCoord
MinY() const { return m_minY
; }
84 wxCoord
MaxY() const { return m_maxY
; }
86 //to define the type of object for derived objects
87 virtual int GetType()=0;
90 //for boundingbox calculation
92 //for boundingbox calculation
93 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
96 // ---------------------------------------------------------------------------
98 // ---------------------------------------------------------------------------
100 WXDLLEXPORT_DATA(extern int) wxPageNumber
;
102 // ---------------------------------------------------------------------------
103 // wxDC is the device context - object on which any drawing is done
104 // ---------------------------------------------------------------------------
106 class WXDLLEXPORT wxDCBase
: public wxObject
110 : m_colour(wxColourDisplay())
114 , m_isBBoxValid(false)
115 , m_logicalOriginX(0), m_logicalOriginY(0)
116 , m_deviceOriginX(0), m_deviceOriginY(0)
117 , m_logicalScaleX(1.0), m_logicalScaleY(1.0)
118 , m_userScaleX(1.0), m_userScaleY(1.0)
119 , m_scaleX(1.0), m_scaleY(1.0)
120 , m_signX(1), m_signY(1)
121 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
122 , m_clipX1(0), m_clipY1(0), m_clipX2(0), m_clipY2(0)
123 , m_logicalFunction(wxCOPY
)
124 , m_backgroundMode(wxTRANSPARENT
)
125 , m_mappingMode(wxMM_TEXT
)
128 , m_backgroundBrush(*wxTRANSPARENT_BRUSH
)
129 , m_textForegroundColour(*wxBLACK
)
130 , m_textBackgroundColour(*wxWHITE
)
134 , m_hasCustomPalette(false)
135 #endif // wxUSE_PALETTE
143 virtual void BeginDrawing() { }
144 virtual void EndDrawing() { }
146 // graphic primitives
147 // ------------------
149 virtual void DrawObject(wxDrawObject
* drawobject
)
151 drawobject
->Draw(*this);
152 CalcBoundingBox(drawobject
->MinX(),drawobject
->MinY());
153 CalcBoundingBox(drawobject
->MaxX(),drawobject
->MaxY());
156 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
157 int style
= wxFLOOD_SURFACE
)
158 { return DoFloodFill(x
, y
, col
, style
); }
159 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
160 int style
= wxFLOOD_SURFACE
)
161 { return DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
163 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
164 { return DoGetPixel(x
, y
, col
); }
165 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
166 { return DoGetPixel(pt
.x
, pt
.y
, col
); }
168 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
169 { DoDrawLine(x1
, y1
, x2
, y2
); }
170 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
171 { DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
173 void CrossHair(wxCoord x
, wxCoord y
)
174 { DoCrossHair(x
, y
); }
175 void CrossHair(const wxPoint
& pt
)
176 { DoCrossHair(pt
.x
, pt
.y
); }
178 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
179 wxCoord xc
, wxCoord yc
)
180 { DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
181 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
182 { DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
184 void DrawCheckMark(wxCoord x
, wxCoord y
,
185 wxCoord width
, wxCoord height
)
186 { DoDrawCheckMark(x
, y
, width
, height
); }
187 void DrawCheckMark(const wxRect
& rect
)
188 { DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
190 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
191 double sa
, double ea
)
192 { DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
193 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
194 double sa
, double ea
)
195 { DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
197 void DrawPoint(wxCoord x
, wxCoord y
)
198 { DoDrawPoint(x
, y
); }
199 void DrawPoint(const wxPoint
& pt
)
200 { DoDrawPoint(pt
.x
, pt
.y
); }
202 void DrawLines(int n
, wxPoint points
[],
203 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
204 { DoDrawLines(n
, points
, xoffset
, yoffset
); }
205 void DrawLines(const wxList
*list
,
206 wxCoord xoffset
= 0, wxCoord yoffset
= 0);
208 void DrawPolygon(int n
, wxPoint points
[],
209 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
210 int fillStyle
= wxODDEVEN_RULE
)
211 { DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
213 void DrawPolygon(const wxList
*list
,
214 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
215 int fillStyle
= wxODDEVEN_RULE
);
217 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
218 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
219 int fillStyle
= wxODDEVEN_RULE
)
220 { DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
222 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
223 { DoDrawRectangle(x
, y
, width
, height
); }
224 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
225 { DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
226 void DrawRectangle(const wxRect
& rect
)
227 { DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
229 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
231 { DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
232 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
234 { DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
235 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
236 { DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
238 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
239 { DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
240 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
241 { DrawCircle(pt
.x
, pt
.y
, radius
); }
243 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
244 { DoDrawEllipse(x
, y
, width
, height
); }
245 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
246 { DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
247 void DrawEllipse(const wxRect
& rect
)
248 { DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
250 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
251 { DoDrawIcon(icon
, x
, y
); }
252 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
253 { DoDrawIcon(icon
, pt
.x
, pt
.y
); }
255 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
256 bool useMask
= false)
257 { DoDrawBitmap(bmp
, x
, y
, useMask
); }
258 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
259 bool useMask
= false)
260 { DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
262 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
263 { DoDrawText(text
, x
, y
); }
264 void DrawText(const wxString
& text
, const wxPoint
& pt
)
265 { DoDrawText(text
, pt
.x
, pt
.y
); }
267 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
268 { DoDrawRotatedText(text
, x
, y
, angle
); }
269 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
270 { DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
272 // this version puts both optional bitmap and the text into the given
273 // rectangle and aligns is as specified by alignment parameter; it also
274 // will emphasize the character with the given index if it is != -1 and
275 // return the bounding rectangle if required
276 virtual void DrawLabel(const wxString
& text
,
277 const wxBitmap
& image
,
279 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
281 wxRect
*rectBounding
= NULL
);
283 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
284 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
286 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
288 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
289 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
290 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
292 return DoBlit(xdest
, ydest
, width
, height
,
293 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
295 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
296 wxDC
*source
, const wxPoint
& srcPt
,
297 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcPtMask
= wxDefaultPosition
)
299 return DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
300 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
304 // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?)
305 void DrawSpline(wxCoord x1
, wxCoord y1
,
306 wxCoord x2
, wxCoord y2
,
307 wxCoord x3
, wxCoord y3
);
308 void DrawSpline(int n
, wxPoint points
[]);
310 void DrawSpline(wxList
*points
) { DoDrawSpline(points
); }
311 #endif // wxUSE_SPLINES
313 // Eventually we will have wxUSE_GENERIC_DRAWELLIPSE
315 //! Generic method to draw ellipses, circles and arcs with current pen and brush.
316 /*! \param x Upper left corner of bounding box.
317 * \param y Upper left corner of bounding box.
318 * \param w Width of bounding box.
319 * \param h Height of bounding box.
320 * \param sa Starting angle of arc
321 * (counterclockwise, start at 3 o'clock, 360 is full circle).
322 * \param ea Ending angle of arc.
323 * \param angle Rotation angle, the Arc will be rotated after
324 * calculating begin and end.
326 void DrawEllipticArcRot( wxCoord x
, wxCoord y
,
327 wxCoord width
, wxCoord height
,
328 double sa
= 0, double ea
= 0, double angle
= 0 )
329 { DoDrawEllipticArcRot( x
, y
, width
, height
, sa
, ea
, angle
); }
331 void DrawEllipticArcRot( const wxPoint
& pt
,
333 double sa
= 0, double ea
= 0, double angle
= 0 )
334 { DoDrawEllipticArcRot( pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
, angle
); }
336 void DrawEllipticArcRot( const wxRect
& rect
,
337 double sa
= 0, double ea
= 0, double angle
= 0 )
338 { DoDrawEllipticArcRot( rect
.x
, rect
.y
, rect
.width
, rect
.height
, sa
, ea
, angle
); }
340 virtual void DoDrawEllipticArcRot( wxCoord x
, wxCoord y
,
341 wxCoord w
, wxCoord h
,
342 double sa
= 0, double ea
= 0, double angle
= 0 );
344 //! Rotates points around center.
345 /*! This is a quite straight method, it calculates in pixels
346 * and so it produces rounding errors.
347 * \param points The points inside will be rotated.
348 * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle).
349 * \param center Center of rotation.
351 void Rotate( wxList
* points
, double angle
, wxPoint center
= wxPoint() );
353 // used by DrawEllipticArcRot
354 // Careful: wxList gets filled with points you have to delete later.
355 void CalculateEllipticPoints( wxList
* points
,
356 wxCoord xStart
, wxCoord yStart
,
357 wxCoord w
, wxCoord h
,
358 double sa
, double ea
);
361 // global DC operations
362 // --------------------
364 virtual void Clear() = 0;
366 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
367 virtual void EndDoc() { }
369 virtual void StartPage() { }
370 virtual void EndPage() { }
372 // set objects to use for drawing
373 // ------------------------------
375 virtual void SetFont(const wxFont
& font
) = 0;
376 virtual void SetPen(const wxPen
& pen
) = 0;
377 virtual void SetBrush(const wxBrush
& brush
) = 0;
378 virtual void SetBackground(const wxBrush
& brush
) = 0;
379 virtual void SetBackgroundMode(int mode
) = 0;
381 virtual void SetPalette(const wxPalette
& palette
) = 0;
382 #endif // wxUSE_PALETTE
387 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
388 { DoSetClippingRegion(x
, y
, width
, height
); }
389 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
390 { DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
391 void SetClippingRegion(const wxRect
& rect
)
392 { DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
393 void SetClippingRegion(const wxRegion
& region
)
394 { DoSetClippingRegionAsRegion(region
); }
396 virtual void DestroyClippingRegion() { ResetClipping(); }
398 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
399 { DoGetClippingBox(x
, y
, w
, h
); }
400 void GetClippingBox(wxRect
& rect
) const
402 DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
);
408 virtual wxCoord
GetCharHeight() const = 0;
409 virtual wxCoord
GetCharWidth() const = 0;
411 // only works for single line strings
412 void GetTextExtent(const wxString
& string
,
413 wxCoord
*x
, wxCoord
*y
,
414 wxCoord
*descent
= NULL
,
415 wxCoord
*externalLeading
= NULL
,
416 wxFont
*theFont
= NULL
) const
417 { DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
419 // works for single as well as multi-line strings
420 virtual void GetMultiLineTextExtent(const wxString
& text
,
423 wxCoord
*heightLine
= NULL
,
424 wxFont
*font
= NULL
);
426 // Measure cumulative width of text after each character
427 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
428 { return DoGetPartialTextExtents(text
, widths
); }
431 // size and resolution
432 // -------------------
435 void GetSize(int *width
, int *height
) const
436 { DoGetSize(width
, height
); }
437 wxSize
GetSize() const
446 void GetSizeMM(int* width
, int* height
) const
447 { DoGetSizeMM(width
, height
); }
448 wxSize
GetSizeMM() const
456 // coordinates conversions
457 // -----------------------
459 // This group of functions does actual conversion of the input, as you'd
461 wxCoord
DeviceToLogicalX(wxCoord x
) const;
462 wxCoord
DeviceToLogicalY(wxCoord y
) const;
463 wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
464 wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
465 wxCoord
LogicalToDeviceX(wxCoord x
) const;
466 wxCoord
LogicalToDeviceY(wxCoord y
) const;
467 wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
468 wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
470 // query DC capabilities
471 // ---------------------
473 virtual bool CanDrawBitmap() const = 0;
474 virtual bool CanGetTextExtent() const = 0;
477 virtual int GetDepth() const = 0;
479 // Resolution in Pixels per inch
480 virtual wxSize
GetPPI() const = 0;
482 virtual bool Ok() const { return m_ok
; }
484 // accessors and setters
485 // ---------------------
487 int GetBackgroundMode() const { return m_backgroundMode
; }
488 const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
489 const wxBrush
& GetBrush() const { return m_brush
; }
490 const wxFont
& GetFont() const { return m_font
; }
491 const wxPen
& GetPen() const { return m_pen
; }
493 const wxColour
& GetTextForeground() const { return m_textForegroundColour
; }
494 const wxColour
& GetTextBackground() const { return m_textBackgroundColour
; }
495 virtual void SetTextForeground(const wxColour
& colour
)
496 { m_textForegroundColour
= colour
; }
497 virtual void SetTextBackground(const wxColour
& colour
)
498 { m_textBackgroundColour
= colour
; }
500 int GetMapMode() const { return m_mappingMode
; }
501 virtual void SetMapMode(int mode
) = 0;
503 virtual void GetUserScale(double *x
, double *y
) const
505 if ( x
) *x
= m_userScaleX
;
506 if ( y
) *y
= m_userScaleY
;
508 virtual void SetUserScale(double x
, double y
) = 0;
510 virtual void GetLogicalScale(double *x
, double *y
)
512 if ( x
) *x
= m_logicalScaleX
;
513 if ( y
) *y
= m_logicalScaleY
;
515 virtual void SetLogicalScale(double x
, double y
)
521 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
522 { DoGetLogicalOrigin(x
, y
); }
523 wxPoint
GetLogicalOrigin() const
524 { wxCoord x
, y
; DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
525 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
) = 0;
527 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
528 { DoGetDeviceOrigin(x
, y
); }
529 wxPoint
GetDeviceOrigin() const
530 { wxCoord x
, y
; DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
531 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
) = 0;
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
);
633 // the pure virtual functions which should be implemented by wxDC
634 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
635 int style
= wxFLOOD_SURFACE
) = 0;
637 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
639 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
640 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
642 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
643 wxCoord x2
, wxCoord y2
,
644 wxCoord xc
, wxCoord yc
) = 0;
645 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
646 wxCoord width
, wxCoord height
);
647 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
648 double sa
, double ea
) = 0;
650 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
651 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
652 wxCoord width
, wxCoord height
,
654 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
655 wxCoord width
, wxCoord height
) = 0;
657 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
659 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
660 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
661 bool useMask
= false) = 0;
663 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
664 virtual void DoDrawRotatedText(const wxString
& text
,
665 wxCoord x
, wxCoord y
, double angle
) = 0;
667 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
668 wxCoord width
, wxCoord height
,
669 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
670 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
) = 0;
672 virtual void DoGetSize(int *width
, int *height
) const = 0;
673 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
675 virtual void DoDrawLines(int n
, wxPoint points
[],
676 wxCoord xoffset
, wxCoord yoffset
) = 0;
677 virtual void DoDrawPolygon(int n
, wxPoint points
[],
678 wxCoord xoffset
, wxCoord yoffset
,
679 int fillStyle
= wxODDEVEN_RULE
) = 0;
680 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
681 wxCoord xoffset
, wxCoord yoffset
,
684 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
) = 0;
685 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
686 wxCoord width
, wxCoord height
) = 0;
688 #if WXWIN_COMPATIBILITY_2_4
689 // this was only for confusing people, use DoGetClippingBox only
690 virtual void DoGetClippingRegion(wxCoord
*x
, wxCoord
*y
,
691 wxCoord
*w
, wxCoord
*h
)
692 { DoGetClippingBox(x
, y
, w
, h
); }
695 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
696 wxCoord
*w
, wxCoord
*h
) const
703 *w
= m_clipX2
- m_clipX1
;
705 *h
= m_clipY2
- m_clipY1
;
708 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
710 if ( x
) *x
= m_logicalOriginX
;
711 if ( y
) *y
= m_logicalOriginY
;
714 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
716 if ( x
) *x
= m_deviceOriginX
;
717 if ( y
) *y
= m_deviceOriginY
;
720 virtual void DoGetTextExtent(const wxString
& string
,
721 wxCoord
*x
, wxCoord
*y
,
722 wxCoord
*descent
= NULL
,
723 wxCoord
*externalLeading
= NULL
,
724 wxFont
*theFont
= NULL
) const = 0;
726 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
729 virtual void DoDrawSpline(wxList
*points
);
733 // unset clipping variables (after clipping region was destroyed)
738 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
745 bool m_isInteractive
:1;
746 bool m_isBBoxValid
:1;
748 // coordinate system variables
750 // TODO short descriptions of what exactly they are would be nice...
752 wxCoord m_logicalOriginX
, m_logicalOriginY
;
753 wxCoord m_deviceOriginX
, m_deviceOriginY
;
755 double m_logicalScaleX
, m_logicalScaleY
;
756 double m_userScaleX
, m_userScaleY
;
757 double m_scaleX
, m_scaleY
;
759 // Used by SetAxisOrientation() to invert the axes
760 int m_signX
, m_signY
;
762 // bounding and clipping boxes
763 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
764 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
766 int m_logicalFunction
;
767 int m_backgroundMode
;
773 wxBrush m_backgroundBrush
;
774 wxColour m_textForegroundColour
;
775 wxColour m_textBackgroundColour
;
780 bool m_hasCustomPalette
;
781 #endif // wxUSE_PALETTE
784 DECLARE_NO_COPY_CLASS(wxDCBase
)
785 DECLARE_ABSTRACT_CLASS(wxDCBase
)
788 // ----------------------------------------------------------------------------
789 // now include the declaration of wxDC class
790 // ----------------------------------------------------------------------------
792 #if defined(__PALMOS__)
793 #include "wx/palmos/dc.h"
794 #elif defined(__WXMSW__)
795 #include "wx/msw/dc.h"
796 #elif defined(__WXMOTIF__)
797 #include "wx/motif/dc.h"
798 #elif defined(__WXGTK__)
799 #include "wx/gtk/dc.h"
800 #elif defined(__WXX11__)
801 #include "wx/x11/dc.h"
802 #elif defined(__WXMGL__)
803 #include "wx/mgl/dc.h"
804 #elif defined(__WXMAC__)
805 #include "wx/mac/dc.h"
806 #elif defined(__WXCOCOA__)
807 #include "wx/cocoa/dc.h"
808 #elif defined(__WXPM__)
809 #include "wx/os2/dc.h"
812 // ----------------------------------------------------------------------------
813 // helper class: you can use it to temporarily change the DC text colour and
814 // restore it automatically when the object goes out of scope
815 // ----------------------------------------------------------------------------
817 class WXDLLEXPORT wxDCTextColourChanger
820 wxDCTextColourChanger(wxDC
& dc
) : m_dc(dc
), m_colFgOld() { }
822 ~wxDCTextColourChanger()
824 if ( m_colFgOld
.Ok() )
825 m_dc
.SetTextForeground(m_colFgOld
);
828 void Set(const wxColour
& col
)
830 if ( !m_colFgOld
.Ok() )
831 m_colFgOld
= m_dc
.GetTextForeground();
832 m_dc
.SetTextForeground(col
);
840 DECLARE_NO_COPY_CLASS(wxDCTextColourChanger
)
843 // ----------------------------------------------------------------------------
844 // another small helper class: sets the clipping region in its ctor and
845 // destroys it in the dtor
846 // ----------------------------------------------------------------------------
848 class WXDLLEXPORT wxDCClipper
851 wxDCClipper(wxDC
& dc
, const wxRect
& r
) : m_dc(dc
)
852 { dc
.SetClippingRegion(r
.x
, r
.y
, r
.width
, r
.height
); }
853 wxDCClipper(wxDC
& dc
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) : m_dc(dc
)
854 { dc
.SetClippingRegion(x
, y
, w
, h
); }
856 ~wxDCClipper() { m_dc
.DestroyClippingRegion(); }
861 DECLARE_NO_COPY_CLASS(wxDCClipper
)