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"
35 class WXDLLEXPORT wxDC
;
36 class WXDLLEXPORT wxDCBase
;
38 class WXDLLEXPORT wxDrawObject
43 : m_isBBoxValid(false)
44 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
47 virtual ~wxDrawObject() { }
49 virtual void Draw(wxDCBase
&) const { }
51 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
55 if ( x
< m_minX
) m_minX
= x
;
56 if ( y
< m_minY
) m_minY
= y
;
57 if ( x
> m_maxX
) m_maxX
= x
;
58 if ( y
> m_maxY
) m_maxY
= y
;
71 void ResetBoundingBox()
73 m_isBBoxValid
= false;
75 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
78 // Get the final bounding box of the PostScript or Metafile picture.
80 wxCoord
MinX() const { return m_minX
; }
81 wxCoord
MaxX() const { return m_maxX
; }
82 wxCoord
MinY() const { return m_minY
; }
83 wxCoord
MaxY() const { return m_maxY
; }
85 //to define the type of object for derived objects
86 virtual int GetType()=0;
89 //for boundingbox calculation
91 //for boundingbox calculation
92 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
95 // ---------------------------------------------------------------------------
97 // ---------------------------------------------------------------------------
99 WXDLLEXPORT_DATA(extern int) wxPageNumber
;
101 // ---------------------------------------------------------------------------
102 // wxDC is the device context - object on which any drawing is done
103 // ---------------------------------------------------------------------------
105 class WXDLLEXPORT wxDCBase
: public wxObject
109 : m_colour(wxColourDisplay())
113 , m_isBBoxValid(false)
114 , m_logicalOriginX(0), m_logicalOriginY(0)
115 , m_deviceOriginX(0), m_deviceOriginY(0)
116 , m_logicalScaleX(1.0), m_logicalScaleY(1.0)
117 , m_userScaleX(1.0), m_userScaleY(1.0)
118 , m_scaleX(1.0), m_scaleY(1.0)
119 , m_signX(1), m_signY(1)
120 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
121 , m_clipX1(0), m_clipY1(0), m_clipX2(0), m_clipY2(0)
122 , m_logicalFunction(wxCOPY
)
123 , m_backgroundMode(wxTRANSPARENT
)
124 , m_mappingMode(wxMM_TEXT
)
127 , m_backgroundBrush(*wxTRANSPARENT_BRUSH
)
128 , m_textForegroundColour(*wxBLACK
)
129 , m_textBackgroundColour(*wxWHITE
)
133 , m_hasCustomPalette(false)
134 #endif // wxUSE_PALETTE
142 virtual void BeginDrawing() { }
143 virtual void EndDrawing() { }
145 // graphic primitives
146 // ------------------
148 virtual void DrawObject(wxDrawObject
* drawobject
)
150 drawobject
->Draw(*this);
151 CalcBoundingBox(drawobject
->MinX(),drawobject
->MinY());
152 CalcBoundingBox(drawobject
->MaxX(),drawobject
->MaxY());
155 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
156 int style
= wxFLOOD_SURFACE
)
157 { return DoFloodFill(x
, y
, col
, style
); }
158 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
159 int style
= wxFLOOD_SURFACE
)
160 { return DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
162 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
163 { return DoGetPixel(x
, y
, col
); }
164 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
165 { return DoGetPixel(pt
.x
, pt
.y
, col
); }
167 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
168 { DoDrawLine(x1
, y1
, x2
, y2
); }
169 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
170 { DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
172 void CrossHair(wxCoord x
, wxCoord y
)
173 { DoCrossHair(x
, y
); }
174 void CrossHair(const wxPoint
& pt
)
175 { DoCrossHair(pt
.x
, pt
.y
); }
177 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
178 wxCoord xc
, wxCoord yc
)
179 { DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
180 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
181 { DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
183 void DrawCheckMark(wxCoord x
, wxCoord y
,
184 wxCoord width
, wxCoord height
)
185 { DoDrawCheckMark(x
, y
, width
, height
); }
186 void DrawCheckMark(const wxRect
& rect
)
187 { DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
189 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
190 double sa
, double ea
)
191 { DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
192 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
193 double sa
, double ea
)
194 { DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
196 void DrawPoint(wxCoord x
, wxCoord y
)
197 { DoDrawPoint(x
, y
); }
198 void DrawPoint(const wxPoint
& pt
)
199 { DoDrawPoint(pt
.x
, pt
.y
); }
201 void DrawLines(int n
, wxPoint points
[],
202 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
203 { DoDrawLines(n
, points
, xoffset
, yoffset
); }
204 void DrawLines(const wxList
*list
,
205 wxCoord xoffset
= 0, wxCoord yoffset
= 0);
207 void DrawPolygon(int n
, wxPoint points
[],
208 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
209 int fillStyle
= wxODDEVEN_RULE
)
210 { DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
212 void DrawPolygon(const wxList
*list
,
213 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
214 int fillStyle
= wxODDEVEN_RULE
);
216 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
217 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
218 int fillStyle
= wxODDEVEN_RULE
)
219 { DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
221 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
222 { DoDrawRectangle(x
, y
, width
, height
); }
223 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
224 { DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
225 void DrawRectangle(const wxRect
& rect
)
226 { DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
228 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
230 { DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
231 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
233 { DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
234 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
235 { DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
237 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
238 { DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
239 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
240 { DrawCircle(pt
.x
, pt
.y
, radius
); }
242 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
243 { DoDrawEllipse(x
, y
, width
, height
); }
244 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
245 { DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
246 void DrawEllipse(const wxRect
& rect
)
247 { DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
249 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
250 { DoDrawIcon(icon
, x
, y
); }
251 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
252 { DoDrawIcon(icon
, pt
.x
, pt
.y
); }
254 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
255 bool useMask
= false)
256 { DoDrawBitmap(bmp
, x
, y
, useMask
); }
257 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
258 bool useMask
= false)
259 { DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
261 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
262 { DoDrawText(text
, x
, y
); }
263 void DrawText(const wxString
& text
, const wxPoint
& pt
)
264 { DoDrawText(text
, pt
.x
, pt
.y
); }
266 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
267 { DoDrawRotatedText(text
, x
, y
, angle
); }
268 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
269 { DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
271 // this version puts both optional bitmap and the text into the given
272 // rectangle and aligns is as specified by alignment parameter; it also
273 // will emphasize the character with the given index if it is != -1 and
274 // return the bounding rectangle if required
275 virtual void DrawLabel(const wxString
& text
,
276 const wxBitmap
& image
,
278 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
280 wxRect
*rectBounding
= NULL
);
282 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
283 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
285 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
287 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
288 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
289 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
291 return DoBlit(xdest
, ydest
, width
, height
,
292 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
294 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
295 wxDC
*source
, const wxPoint
& srcPt
,
296 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcPtMask
= wxDefaultPosition
)
298 return DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
299 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
303 // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?)
304 void DrawSpline(wxCoord x1
, wxCoord y1
,
305 wxCoord x2
, wxCoord y2
,
306 wxCoord x3
, wxCoord y3
);
307 void DrawSpline(int n
, wxPoint points
[]);
309 void DrawSpline(wxList
*points
) { DoDrawSpline(points
); }
310 #endif // wxUSE_SPLINES
312 // Eventually we will have wxUSE_GENERIC_DRAWELLIPSE
314 //! Generic method to draw ellipses, circles and arcs with current pen and brush.
315 /*! \param x Upper left corner of bounding box.
316 * \param y Upper left corner of bounding box.
317 * \param w Width of bounding box.
318 * \param h Height of bounding box.
319 * \param sa Starting angle of arc
320 * (counterclockwise, start at 3 o'clock, 360 is full circle).
321 * \param ea Ending angle of arc.
322 * \param angle Rotation angle, the Arc will be rotated after
323 * calculating begin and end.
325 void DrawEllipticArcRot( wxCoord x
, wxCoord y
,
326 wxCoord width
, wxCoord height
,
327 double sa
= 0, double ea
= 0, double angle
= 0 )
328 { DoDrawEllipticArcRot( x
, y
, width
, height
, sa
, ea
, angle
); }
330 void DrawEllipticArcRot( const wxPoint
& pt
,
332 double sa
= 0, double ea
= 0, double angle
= 0 )
333 { DoDrawEllipticArcRot( pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
, angle
); }
335 void DrawEllipticArcRot( const wxRect
& rect
,
336 double sa
= 0, double ea
= 0, double angle
= 0 )
337 { DoDrawEllipticArcRot( rect
.x
, rect
.y
, rect
.width
, rect
.height
, sa
, ea
, angle
); }
339 virtual void DoDrawEllipticArcRot( wxCoord x
, wxCoord y
,
340 wxCoord w
, wxCoord h
,
341 double sa
= 0, double ea
= 0, double angle
= 0 );
343 //! Rotates points around center.
344 /*! This is a quite straight method, it calculates in pixels
345 * and so it produces rounding errors.
346 * \param points The points inside will be rotated.
347 * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle).
348 * \param center Center of rotation.
350 void Rotate( wxList
* points
, double angle
, wxPoint center
= wxPoint() );
352 // used by DrawEllipticArcRot
353 // Careful: wxList gets filled with points you have to delete later.
354 void CalculateEllipticPoints( wxList
* points
,
355 wxCoord xStart
, wxCoord yStart
,
356 wxCoord w
, wxCoord h
,
357 double sa
, double ea
);
360 // global DC operations
361 // --------------------
363 virtual void Clear() = 0;
365 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
366 virtual void EndDoc() { }
368 virtual void StartPage() { }
369 virtual void EndPage() { }
371 // set objects to use for drawing
372 // ------------------------------
374 virtual void SetFont(const wxFont
& font
) = 0;
375 virtual void SetPen(const wxPen
& pen
) = 0;
376 virtual void SetBrush(const wxBrush
& brush
) = 0;
377 virtual void SetBackground(const wxBrush
& brush
) = 0;
378 virtual void SetBackgroundMode(int mode
) = 0;
380 virtual void SetPalette(const wxPalette
& palette
) = 0;
381 #endif // wxUSE_PALETTE
386 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
387 { DoSetClippingRegion(x
, y
, width
, height
); }
388 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
389 { DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
390 void SetClippingRegion(const wxRect
& rect
)
391 { DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
392 void SetClippingRegion(const wxRegion
& region
)
393 { DoSetClippingRegionAsRegion(region
); }
395 virtual void DestroyClippingRegion() { ResetClipping(); }
397 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
398 { DoGetClippingBox(x
, y
, w
, h
); }
399 void GetClippingBox(wxRect
& rect
) const
401 DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
);
407 virtual wxCoord
GetCharHeight() const = 0;
408 virtual wxCoord
GetCharWidth() const = 0;
410 // only works for single line strings
411 void GetTextExtent(const wxString
& string
,
412 wxCoord
*x
, wxCoord
*y
,
413 wxCoord
*descent
= NULL
,
414 wxCoord
*externalLeading
= NULL
,
415 wxFont
*theFont
= NULL
) const
416 { DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
418 // works for single as well as multi-line strings
419 virtual void GetMultiLineTextExtent(const wxString
& text
,
422 wxCoord
*heightLine
= NULL
,
423 wxFont
*font
= NULL
);
425 // Measure cumulative width of text after each character
426 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
427 { return DoGetPartialTextExtents(text
, widths
); }
430 // size and resolution
431 // -------------------
434 void GetSize(int *width
, int *height
) const
435 { DoGetSize(width
, height
); }
436 wxSize
GetSize() const
445 void GetSizeMM(int* width
, int* height
) const
446 { DoGetSizeMM(width
, height
); }
447 wxSize
GetSizeMM() const
455 // coordinates conversions
456 // -----------------------
458 // This group of functions does actual conversion of the input, as you'd
460 wxCoord
DeviceToLogicalX(wxCoord x
) const;
461 wxCoord
DeviceToLogicalY(wxCoord y
) const;
462 wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
463 wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
464 wxCoord
LogicalToDeviceX(wxCoord x
) const;
465 wxCoord
LogicalToDeviceY(wxCoord y
) const;
466 wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
467 wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
469 // query DC capabilities
470 // ---------------------
472 virtual bool CanDrawBitmap() const = 0;
473 virtual bool CanGetTextExtent() const = 0;
476 virtual int GetDepth() const = 0;
478 // Resolution in Pixels per inch
479 virtual wxSize
GetPPI() const = 0;
481 virtual bool Ok() const { return m_ok
; }
483 // accessors and setters
484 // ---------------------
486 int GetBackgroundMode() const { return m_backgroundMode
; }
487 const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
488 const wxBrush
& GetBrush() const { return m_brush
; }
489 const wxFont
& GetFont() const { return m_font
; }
490 const wxPen
& GetPen() const { return m_pen
; }
492 const wxColour
& GetTextForeground() const { return m_textForegroundColour
; }
493 const wxColour
& GetTextBackground() const { return m_textBackgroundColour
; }
494 virtual void SetTextForeground(const wxColour
& colour
)
495 { m_textForegroundColour
= colour
; }
496 virtual void SetTextBackground(const wxColour
& colour
)
497 { m_textBackgroundColour
= colour
; }
499 int GetMapMode() const { return m_mappingMode
; }
500 virtual void SetMapMode(int mode
) = 0;
502 virtual void GetUserScale(double *x
, double *y
) const
504 if ( x
) *x
= m_userScaleX
;
505 if ( y
) *y
= m_userScaleY
;
507 virtual void SetUserScale(double x
, double y
) = 0;
509 virtual void GetLogicalScale(double *x
, double *y
)
511 if ( x
) *x
= m_logicalScaleX
;
512 if ( y
) *y
= m_logicalScaleY
;
514 virtual void SetLogicalScale(double x
, double y
)
520 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
521 { DoGetLogicalOrigin(x
, y
); }
522 wxPoint
GetLogicalOrigin() const
523 { wxCoord x
, y
; DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
524 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
) = 0;
526 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
527 { DoGetDeviceOrigin(x
, y
); }
528 wxPoint
GetDeviceOrigin() const
529 { wxCoord x
, y
; DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
530 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
) = 0;
532 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
) = 0;
534 int GetLogicalFunction() const { return m_logicalFunction
; }
535 virtual void SetLogicalFunction(int function
) = 0;
537 // Sometimes we need to override optimization, e.g. if other software is
538 // drawing onto our surface and we can't be sure of who's done what.
540 // FIXME: is this (still) used?
541 virtual void SetOptimization(bool WXUNUSED(opt
)) { }
542 virtual bool GetOptimization() { return false; }
547 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
551 if ( x
< m_minX
) m_minX
= x
;
552 if ( y
< m_minY
) m_minY
= y
;
553 if ( x
> m_maxX
) m_maxX
= x
;
554 if ( y
> m_maxY
) m_maxY
= y
;
558 m_isBBoxValid
= true;
567 void ResetBoundingBox()
569 m_isBBoxValid
= false;
571 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
574 // Get the final bounding box of the PostScript or Metafile picture.
575 wxCoord
MinX() const { return m_minX
; }
576 wxCoord
MaxX() const { return m_maxX
; }
577 wxCoord
MinY() const { return m_minY
; }
578 wxCoord
MaxY() const { return m_maxY
; }
580 // misc old functions
581 // ------------------
583 // for compatibility with the old code when wxCoord was long everywhere
584 void GetTextExtent(const wxString
& string
,
586 long *descent
= NULL
,
587 long *externalLeading
= NULL
,
588 wxFont
*theFont
= NULL
) const
590 wxCoord x2
, y2
, descent2
, externalLeading2
;
591 DoGetTextExtent(string
, &x2
, &y2
,
592 &descent2
, &externalLeading2
,
600 if ( externalLeading
)
601 *externalLeading
= externalLeading2
;
604 void GetLogicalOrigin(long *x
, long *y
) const
607 DoGetLogicalOrigin(&x2
, &y2
);
614 void GetDeviceOrigin(long *x
, long *y
) const
617 DoGetDeviceOrigin(&x2
, &y2
);
623 void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const
626 DoGetClippingBox(&xx
, &yy
, &ww
, &hh
);
634 // the pure virtual functions which should be implemented by wxDC
635 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
636 int style
= wxFLOOD_SURFACE
) = 0;
638 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
640 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
641 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
643 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
644 wxCoord x2
, wxCoord y2
,
645 wxCoord xc
, wxCoord yc
) = 0;
646 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
647 wxCoord width
, wxCoord height
);
648 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
649 double sa
, double ea
) = 0;
651 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
652 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
653 wxCoord width
, wxCoord height
,
655 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
656 wxCoord width
, wxCoord height
) = 0;
658 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
660 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
661 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
662 bool useMask
= false) = 0;
664 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
665 virtual void DoDrawRotatedText(const wxString
& text
,
666 wxCoord x
, wxCoord y
, double angle
) = 0;
668 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
669 wxCoord width
, wxCoord height
,
670 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
671 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
) = 0;
673 virtual void DoGetSize(int *width
, int *height
) const = 0;
674 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
676 virtual void DoDrawLines(int n
, wxPoint points
[],
677 wxCoord xoffset
, wxCoord yoffset
) = 0;
678 virtual void DoDrawPolygon(int n
, wxPoint points
[],
679 wxCoord xoffset
, wxCoord yoffset
,
680 int fillStyle
= wxODDEVEN_RULE
) = 0;
681 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
682 wxCoord xoffset
, wxCoord yoffset
,
685 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
) = 0;
686 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
687 wxCoord width
, wxCoord height
) = 0;
689 // FIXME are these functions really different?
690 virtual void DoGetClippingRegion(wxCoord
*x
, wxCoord
*y
,
691 wxCoord
*w
, wxCoord
*h
)
692 { DoGetClippingBox(x
, y
, w
, h
); }
693 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
694 wxCoord
*w
, wxCoord
*h
) const
701 *w
= m_clipX2
- m_clipX1
;
703 *h
= m_clipY2
- m_clipY1
;
706 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
708 if ( x
) *x
= m_logicalOriginX
;
709 if ( y
) *y
= m_logicalOriginY
;
712 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
714 if ( x
) *x
= m_deviceOriginX
;
715 if ( y
) *y
= m_deviceOriginY
;
718 virtual void DoGetTextExtent(const wxString
& string
,
719 wxCoord
*x
, wxCoord
*y
,
720 wxCoord
*descent
= NULL
,
721 wxCoord
*externalLeading
= NULL
,
722 wxFont
*theFont
= NULL
) const = 0;
724 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
727 virtual void DoDrawSpline(wxList
*points
);
731 // unset clipping variables (after clipping region was destroyed)
736 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
743 bool m_isInteractive
:1;
744 bool m_isBBoxValid
:1;
746 // coordinate system variables
748 // TODO short descriptions of what exactly they are would be nice...
750 wxCoord m_logicalOriginX
, m_logicalOriginY
;
751 wxCoord m_deviceOriginX
, m_deviceOriginY
;
753 double m_logicalScaleX
, m_logicalScaleY
;
754 double m_userScaleX
, m_userScaleY
;
755 double m_scaleX
, m_scaleY
;
757 // Used by SetAxisOrientation() to invert the axes
758 int m_signX
, m_signY
;
760 // bounding and clipping boxes
761 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
762 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
764 int m_logicalFunction
;
765 int m_backgroundMode
;
771 wxBrush m_backgroundBrush
;
772 wxColour m_textForegroundColour
;
773 wxColour m_textBackgroundColour
;
778 bool m_hasCustomPalette
;
779 #endif // wxUSE_PALETTE
782 DECLARE_NO_COPY_CLASS(wxDCBase
)
783 DECLARE_ABSTRACT_CLASS(wxDCBase
)
786 // ----------------------------------------------------------------------------
787 // now include the declaration of wxDC class
788 // ----------------------------------------------------------------------------
790 #if defined(__PALMOS__)
791 #include "wx/palmos/dc.h"
792 #elif defined(__WXMSW__)
793 #include "wx/msw/dc.h"
794 #elif defined(__WXMOTIF__)
795 #include "wx/motif/dc.h"
796 #elif defined(__WXGTK__)
797 #include "wx/gtk/dc.h"
798 #elif defined(__WXX11__)
799 #include "wx/x11/dc.h"
800 #elif defined(__WXMGL__)
801 #include "wx/mgl/dc.h"
802 #elif defined(__WXMAC__)
803 #include "wx/mac/dc.h"
804 #elif defined(__WXCOCOA__)
805 #include "wx/cocoa/dc.h"
806 #elif defined(__WXPM__)
807 #include "wx/os2/dc.h"
810 // ----------------------------------------------------------------------------
811 // helper class: you can use it to temporarily change the DC text colour and
812 // restore it automatically when the object goes out of scope
813 // ----------------------------------------------------------------------------
815 class WXDLLEXPORT wxDCTextColourChanger
818 wxDCTextColourChanger(wxDC
& dc
) : m_dc(dc
), m_colFgOld() { }
820 ~wxDCTextColourChanger()
822 if ( m_colFgOld
.Ok() )
823 m_dc
.SetTextForeground(m_colFgOld
);
826 void Set(const wxColour
& col
)
828 if ( !m_colFgOld
.Ok() )
829 m_colFgOld
= m_dc
.GetTextForeground();
830 m_dc
.SetTextForeground(col
);
838 DECLARE_NO_COPY_CLASS(wxDCTextColourChanger
)
841 // ----------------------------------------------------------------------------
842 // another small helper class: sets the clipping region in its ctor and
843 // destroys it in the dtor
844 // ----------------------------------------------------------------------------
846 class WXDLLEXPORT wxDCClipper
849 wxDCClipper(wxDC
& dc
, const wxRect
& r
) : m_dc(dc
)
850 { dc
.SetClippingRegion(r
.x
, r
.y
, r
.width
, r
.height
); }
851 wxDCClipper(wxDC
& dc
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) : m_dc(dc
)
852 { dc
.SetClippingRegion(x
, y
, w
, h
); }
854 ~wxDCClipper() { m_dc
.DestroyClippingRegion(); }
859 DECLARE_NO_COPY_CLASS(wxDCClipper
)