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 ComputeScaleAndOrigin() {}
535 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
) = 0;
537 int GetLogicalFunction() const { return m_logicalFunction
; }
538 virtual void SetLogicalFunction(int function
) = 0;
540 #if WXWIN_COMPATIBILITY_2_4
541 virtual void SetOptimization(bool WXUNUSED(opt
)) { }
542 virtual bool GetOptimization() { return false; }
548 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
552 if ( x
< m_minX
) m_minX
= x
;
553 if ( y
< m_minY
) m_minY
= y
;
554 if ( x
> m_maxX
) m_maxX
= x
;
555 if ( y
> m_maxY
) m_maxY
= y
;
559 m_isBBoxValid
= true;
568 void ResetBoundingBox()
570 m_isBBoxValid
= false;
572 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
575 // Get the final bounding box of the PostScript or Metafile picture.
576 wxCoord
MinX() const { return m_minX
; }
577 wxCoord
MaxX() const { return m_maxX
; }
578 wxCoord
MinY() const { return m_minY
; }
579 wxCoord
MaxY() const { return m_maxY
; }
581 // misc old functions
582 // ------------------
584 // for compatibility with the old code when wxCoord was long everywhere
585 void GetTextExtent(const wxString
& string
,
587 long *descent
= NULL
,
588 long *externalLeading
= NULL
,
589 wxFont
*theFont
= NULL
) const
591 wxCoord x2
, y2
, descent2
, externalLeading2
;
592 DoGetTextExtent(string
, &x2
, &y2
,
593 &descent2
, &externalLeading2
,
601 if ( externalLeading
)
602 *externalLeading
= externalLeading2
;
605 void GetLogicalOrigin(long *x
, long *y
) const
608 DoGetLogicalOrigin(&x2
, &y2
);
615 void GetDeviceOrigin(long *x
, long *y
) const
618 DoGetDeviceOrigin(&x2
, &y2
);
624 void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const
627 DoGetClippingBox(&xx
, &yy
, &ww
, &hh
);
635 // the pure virtual functions which should be implemented by wxDC
636 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
637 int style
= wxFLOOD_SURFACE
) = 0;
639 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
641 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
642 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
644 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
645 wxCoord x2
, wxCoord y2
,
646 wxCoord xc
, wxCoord yc
) = 0;
647 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
648 wxCoord width
, wxCoord height
);
649 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
650 double sa
, double ea
) = 0;
652 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
653 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
654 wxCoord width
, wxCoord height
,
656 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
657 wxCoord width
, wxCoord height
) = 0;
659 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
661 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
662 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
663 bool useMask
= false) = 0;
665 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
666 virtual void DoDrawRotatedText(const wxString
& text
,
667 wxCoord x
, wxCoord y
, double angle
) = 0;
669 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
670 wxCoord width
, wxCoord height
,
671 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
672 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
) = 0;
674 virtual void DoGetSize(int *width
, int *height
) const = 0;
675 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
677 virtual void DoDrawLines(int n
, wxPoint points
[],
678 wxCoord xoffset
, wxCoord yoffset
) = 0;
679 virtual void DoDrawPolygon(int n
, wxPoint points
[],
680 wxCoord xoffset
, wxCoord yoffset
,
681 int fillStyle
= wxODDEVEN_RULE
) = 0;
682 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
683 wxCoord xoffset
, wxCoord yoffset
,
686 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
) = 0;
687 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
688 wxCoord width
, wxCoord height
) = 0;
690 #if WXWIN_COMPATIBILITY_2_4
691 // this was only for confusing people, use DoGetClippingBox only
692 virtual void DoGetClippingRegion(wxCoord
*x
, wxCoord
*y
,
693 wxCoord
*w
, wxCoord
*h
)
694 { DoGetClippingBox(x
, y
, w
, h
); }
697 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
698 wxCoord
*w
, wxCoord
*h
) const
705 *w
= m_clipX2
- m_clipX1
;
707 *h
= m_clipY2
- m_clipY1
;
710 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
712 if ( x
) *x
= m_logicalOriginX
;
713 if ( y
) *y
= m_logicalOriginY
;
716 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
718 if ( x
) *x
= m_deviceOriginX
;
719 if ( y
) *y
= m_deviceOriginY
;
722 virtual void DoGetTextExtent(const wxString
& string
,
723 wxCoord
*x
, wxCoord
*y
,
724 wxCoord
*descent
= NULL
,
725 wxCoord
*externalLeading
= NULL
,
726 wxFont
*theFont
= NULL
) const = 0;
728 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
731 virtual void DoDrawSpline(wxList
*points
);
735 // unset clipping variables (after clipping region was destroyed)
740 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
747 bool m_isInteractive
:1;
748 bool m_isBBoxValid
:1;
750 // coordinate system variables
752 // TODO short descriptions of what exactly they are would be nice...
754 wxCoord m_logicalOriginX
, m_logicalOriginY
;
755 wxCoord m_deviceOriginX
, m_deviceOriginY
;
757 double m_logicalScaleX
, m_logicalScaleY
;
758 double m_userScaleX
, m_userScaleY
;
759 double m_scaleX
, m_scaleY
;
761 // Used by SetAxisOrientation() to invert the axes
762 int m_signX
, m_signY
;
764 // bounding and clipping boxes
765 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
766 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
768 int m_logicalFunction
;
769 int m_backgroundMode
;
775 wxBrush m_backgroundBrush
;
776 wxColour m_textForegroundColour
;
777 wxColour m_textBackgroundColour
;
782 bool m_hasCustomPalette
;
783 #endif // wxUSE_PALETTE
786 DECLARE_NO_COPY_CLASS(wxDCBase
)
787 DECLARE_ABSTRACT_CLASS(wxDCBase
)
790 // ----------------------------------------------------------------------------
791 // now include the declaration of wxDC class
792 // ----------------------------------------------------------------------------
794 #if defined(__WXPALMOS__)
795 #include "wx/palmos/dc.h"
796 #elif defined(__WXMSW__)
797 #include "wx/msw/dc.h"
798 #elif defined(__WXMOTIF__)
799 #include "wx/motif/dc.h"
800 #elif defined(__WXGTK__)
801 #include "wx/gtk/dc.h"
802 #elif defined(__WXX11__)
803 #include "wx/x11/dc.h"
804 #elif defined(__WXMGL__)
805 #include "wx/mgl/dc.h"
806 #elif defined(__WXMAC__)
807 #include "wx/mac/dc.h"
808 #elif defined(__WXCOCOA__)
809 #include "wx/cocoa/dc.h"
810 #elif defined(__WXPM__)
811 #include "wx/os2/dc.h"
814 // ----------------------------------------------------------------------------
815 // helper class: you can use it to temporarily change the DC text colour and
816 // restore it automatically when the object goes out of scope
817 // ----------------------------------------------------------------------------
819 class WXDLLEXPORT wxDCTextColourChanger
822 wxDCTextColourChanger(wxDC
& dc
) : m_dc(dc
), m_colFgOld() { }
824 ~wxDCTextColourChanger()
826 if ( m_colFgOld
.Ok() )
827 m_dc
.SetTextForeground(m_colFgOld
);
830 void Set(const wxColour
& col
)
832 if ( !m_colFgOld
.Ok() )
833 m_colFgOld
= m_dc
.GetTextForeground();
834 m_dc
.SetTextForeground(col
);
842 DECLARE_NO_COPY_CLASS(wxDCTextColourChanger
)
845 // ----------------------------------------------------------------------------
846 // another small helper class: sets the clipping region in its ctor and
847 // destroys it in the dtor
848 // ----------------------------------------------------------------------------
850 class WXDLLEXPORT wxDCClipper
853 wxDCClipper(wxDC
& dc
, const wxRect
& r
) : m_dc(dc
)
854 { dc
.SetClippingRegion(r
.x
, r
.y
, r
.width
, r
.height
); }
855 wxDCClipper(wxDC
& dc
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) : m_dc(dc
)
856 { dc
.SetClippingRegion(x
, y
, w
, h
); }
858 ~wxDCClipper() { m_dc
.DestroyClippingRegion(); }
863 DECLARE_NO_COPY_CLASS(wxDCClipper
)