]> git.saurik.com Git - wxWidgets.git/blame - include/wx/dc.h
Make wxGTK1.2 compile again.
[wxWidgets.git] / include / wx / dc.h
CommitLineData
006162a9 1/////////////////////////////////////////////////////////////////////////////
4660e6ac 2// Name: wx/dc.h
006162a9
VZ
3// Purpose: wxDC class
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 05/25/99
7// RCS-ID: $Id$
77ffb593 8// Copyright: (c) wxWidgets team
65571936 9// Licence: wxWindows licence
006162a9
VZ
10/////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_DC_H_BASE_
13#define _WX_DC_H_BASE_
c801d85f 14
a23fd0e1
VZ
15// ----------------------------------------------------------------------------
16// headers which we must include here
17// ----------------------------------------------------------------------------
18
19#include "wx/object.h" // the base class
20
0d80fb31 21#include "wx/intl.h" // for wxLayoutDirection
a23fd0e1
VZ
22#include "wx/cursor.h" // we have member variables of these classes
23#include "wx/font.h" // so we can't do without them
24#include "wx/colour.h"
b494e2b0 25#include "wx/bitmap.h" // for wxNullBitmap
a23fd0e1
VZ
26#include "wx/brush.h"
27#include "wx/pen.h"
28#include "wx/palette.h"
a23fd0e1 29#include "wx/list.h" // we use wxList in inline functions
0919e93e 30#include "wx/dynarray.h"
19edb09c 31#include "wx/math.h"
a23fd0e1 32
f4515f98 33class WXDLLEXPORT wxDC;
aec43716
KH
34class WXDLLEXPORT wxDCBase;
35
36class WXDLLEXPORT wxDrawObject
37{
38public:
39
40 wxDrawObject()
68379eaf 41 : m_isBBoxValid(false)
ba161d7e
GD
42 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
43 { }
aec43716
KH
44
45 virtual ~wxDrawObject() { }
46
33ac7e6f 47 virtual void Draw(wxDCBase&) const { }
aec43716
KH
48
49 virtual void CalcBoundingBox(wxCoord x, wxCoord y)
50 {
51 if ( m_isBBoxValid )
52 {
53 if ( x < m_minX ) m_minX = x;
54 if ( y < m_minY ) m_minY = y;
55 if ( x > m_maxX ) m_maxX = x;
56 if ( y > m_maxY ) m_maxY = y;
57 }
58 else
59 {
68379eaf 60 m_isBBoxValid = true;
aec43716
KH
61
62 m_minX = x;
63 m_minY = y;
64 m_maxX = x;
65 m_maxY = y;
66 }
67 }
68
69 void ResetBoundingBox()
70 {
68379eaf 71 m_isBBoxValid = false;
aec43716
KH
72
73 m_minX = m_maxX = m_minY = m_maxY = 0;
74 }
75
76 // Get the final bounding box of the PostScript or Metafile picture.
77
78 wxCoord MinX() const { return m_minX; }
79 wxCoord MaxX() const { return m_maxX; }
80 wxCoord MinY() const { return m_minY; }
81 wxCoord MaxY() const { return m_maxY; }
82
83 //to define the type of object for derived objects
84 virtual int GetType()=0;
85
86protected:
87 //for boundingbox calculation
88 bool m_isBBoxValid:1;
89 //for boundingbox calculation
90 wxCoord m_minX, m_minY, m_maxX, m_maxY;
91};
92
a23fd0e1
VZ
93// ---------------------------------------------------------------------------
94// global variables
95// ---------------------------------------------------------------------------
96
a23fd0e1
VZ
97// ---------------------------------------------------------------------------
98// wxDC is the device context - object on which any drawing is done
99// ---------------------------------------------------------------------------
100
101class WXDLLEXPORT wxDCBase : public wxObject
102{
a23fd0e1 103public:
04ab8b6d
RR
104 wxDCBase();
105 virtual ~wxDCBase();
106
a23fd0e1
VZ
107 // graphic primitives
108 // ------------------
109
aec43716
KH
110 virtual void DrawObject(wxDrawObject* drawobject)
111 {
112 drawobject->Draw(*this);
113 CalcBoundingBox(drawobject->MinX(),drawobject->MinY());
114 CalcBoundingBox(drawobject->MaxX(),drawobject->MaxY());
115 }
116
387ebd3e 117 bool FloodFill(wxCoord x, wxCoord y, const wxColour& col,
72cdf4c9 118 int style = wxFLOOD_SURFACE)
387ebd3e
JS
119 { return DoFloodFill(x, y, col, style); }
120 bool FloodFill(const wxPoint& pt, const wxColour& col,
72cdf4c9 121 int style = wxFLOOD_SURFACE)
387ebd3e 122 { return DoFloodFill(pt.x, pt.y, col, style); }
a23fd0e1 123
213ad8e7
VZ
124 // fill the area specified by rect with a radial gradient, starting from
125 // initialColour in the centre of the cercle and fading to destColour.
126 void GradientFillConcentric(const wxRect& rect,
4660e6ac 127 const wxColour& initialColour,
213ad8e7
VZ
128 const wxColour& destColour)
129 { GradientFillConcentric(rect, initialColour, destColour,
130 wxPoint(rect.GetWidth() / 2,
131 rect.GetHeight() / 2)); }
132
133 void GradientFillConcentric(const wxRect& rect,
4660e6ac 134 const wxColour& initialColour,
213ad8e7 135 const wxColour& destColour,
fb63a242
SC
136 const wxPoint& circleCenter)
137 { DoGradientFillConcentric(rect, initialColour, destColour, circleCenter); }
213ad8e7
VZ
138
139 // fill the area specified by rect with a linear gradient
140 void GradientFillLinear(const wxRect& rect,
4660e6ac 141 const wxColour& initialColour,
213ad8e7
VZ
142 const wxColour& destColour,
143 wxDirection nDirection = wxEAST)
144 { DoGradientFillLinear(rect, initialColour, destColour, nDirection); }
145
72cdf4c9 146 bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const
a23fd0e1
VZ
147 { return DoGetPixel(x, y, col); }
148 bool GetPixel(const wxPoint& pt, wxColour *col) const
149 { return DoGetPixel(pt.x, pt.y, col); }
150
72cdf4c9 151 void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
a23fd0e1
VZ
152 { DoDrawLine(x1, y1, x2, y2); }
153 void DrawLine(const wxPoint& pt1, const wxPoint& pt2)
154 { DoDrawLine(pt1.x, pt1.y, pt2.x, pt2.y); }
155
72cdf4c9 156 void CrossHair(wxCoord x, wxCoord y)
a23fd0e1
VZ
157 { DoCrossHair(x, y); }
158 void CrossHair(const wxPoint& pt)
159 { DoCrossHair(pt.x, pt.y); }
160
72cdf4c9
VZ
161 void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
162 wxCoord xc, wxCoord yc)
a23fd0e1
VZ
163 { DoDrawArc(x1, y1, x2, y2, xc, yc); }
164 void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre)
165 { DoDrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y); }
166
cd9da200
VZ
167 void DrawCheckMark(wxCoord x, wxCoord y,
168 wxCoord width, wxCoord height)
169 { DoDrawCheckMark(x, y, width, height); }
170 void DrawCheckMark(const wxRect& rect)
171 { DoDrawCheckMark(rect.x, rect.y, rect.width, rect.height); }
172
72cdf4c9
VZ
173 void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
174 double sa, double ea)
7b90a8f2 175 { DoDrawEllipticArc(x, y, w, h, sa, ea); }
a23fd0e1
VZ
176 void DrawEllipticArc(const wxPoint& pt, const wxSize& sz,
177 double sa, double ea)
178 { DoDrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea); }
179
72cdf4c9 180 void DrawPoint(wxCoord x, wxCoord y)
a23fd0e1
VZ
181 { DoDrawPoint(x, y); }
182 void DrawPoint(const wxPoint& pt)
183 { DoDrawPoint(pt.x, pt.y); }
184
72cdf4c9
VZ
185 void DrawLines(int n, wxPoint points[],
186 wxCoord xoffset = 0, wxCoord yoffset = 0)
a23fd0e1 187 { DoDrawLines(n, points, xoffset, yoffset); }
72cdf4c9
VZ
188 void DrawLines(const wxList *list,
189 wxCoord xoffset = 0, wxCoord yoffset = 0);
a23fd0e1
VZ
190
191 void DrawPolygon(int n, wxPoint points[],
72cdf4c9 192 wxCoord xoffset = 0, wxCoord yoffset = 0,
a23fd0e1
VZ
193 int fillStyle = wxODDEVEN_RULE)
194 { DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); }
195
196 void DrawPolygon(const wxList *list,
72cdf4c9 197 wxCoord xoffset = 0, wxCoord yoffset = 0,
bd5dd957 198 int fillStyle = wxODDEVEN_RULE);
a23fd0e1 199
793db755 200 void DrawPolyPolygon(int n, int count[], wxPoint points[],
6e76b35d
VZ
201 wxCoord xoffset = 0, wxCoord yoffset = 0,
202 int fillStyle = wxODDEVEN_RULE)
793db755 203 { DoDrawPolyPolygon(n, count, points, xoffset, yoffset, fillStyle); }
6e76b35d 204
72cdf4c9 205 void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
a23fd0e1
VZ
206 { DoDrawRectangle(x, y, width, height); }
207 void DrawRectangle(const wxPoint& pt, const wxSize& sz)
208 { DoDrawRectangle(pt.x, pt.y, sz.x, sz.y); }
209 void DrawRectangle(const wxRect& rect)
210 { DoDrawRectangle(rect.x, rect.y, rect.width, rect.height); }
211
72cdf4c9 212 void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height,
a23fd0e1
VZ
213 double radius)
214 { DoDrawRoundedRectangle(x, y, width, height, radius); }
215 void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz,
216 double radius)
217 { DoDrawRoundedRectangle(pt.x, pt.y, sz.x, sz.y, radius); }
218 void DrawRoundedRectangle(const wxRect& r, double radius)
219 { DoDrawRoundedRectangle(r.x, r.y, r.width, r.height, radius); }
220
72cdf4c9 221 void DrawCircle(wxCoord x, wxCoord y, wxCoord radius)
220af862 222 { DoDrawEllipse(x - radius, y - radius, 2*radius, 2*radius); }
0371e9a8 223 void DrawCircle(const wxPoint& pt, wxCoord radius)
b95edd47 224 { DrawCircle(pt.x, pt.y, radius); }
0371e9a8 225
72cdf4c9 226 void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
a23fd0e1
VZ
227 { DoDrawEllipse(x, y, width, height); }
228 void DrawEllipse(const wxPoint& pt, const wxSize& sz)
229 { DoDrawEllipse(pt.x, pt.y, sz.x, sz.y); }
230 void DrawEllipse(const wxRect& rect)
231 { DoDrawEllipse(rect.x, rect.y, rect.width, rect.height); }
232
72cdf4c9 233 void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
a23fd0e1
VZ
234 { DoDrawIcon(icon, x, y); }
235 void DrawIcon(const wxIcon& icon, const wxPoint& pt)
236 { DoDrawIcon(icon, pt.x, pt.y); }
237
72cdf4c9 238 void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
68379eaf 239 bool useMask = false)
a23fd0e1
VZ
240 { DoDrawBitmap(bmp, x, y, useMask); }
241 void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt,
68379eaf 242 bool useMask = false)
a23fd0e1
VZ
243 { DoDrawBitmap(bmp, pt.x, pt.y, useMask); }
244
72cdf4c9 245 void DrawText(const wxString& text, wxCoord x, wxCoord y)
a23fd0e1
VZ
246 { DoDrawText(text, x, y); }
247 void DrawText(const wxString& text, const wxPoint& pt)
248 { DoDrawText(text, pt.x, pt.y); }
249
95724b1a
VZ
250 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle)
251 { DoDrawRotatedText(text, x, y, angle); }
252 void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle)
253 { DoDrawRotatedText(text, pt.x, pt.y, angle); }
254
1e6feb95
VZ
255 // this version puts both optional bitmap and the text into the given
256 // rectangle and aligns is as specified by alignment parameter; it also
257 // will emphasize the character with the given index if it is != -1 and
258 // return the bounding rectangle if required
259 virtual void DrawLabel(const wxString& text,
260 const wxBitmap& image,
261 const wxRect& rect,
262 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
263 int indexAccel = -1,
264 wxRect *rectBounding = NULL);
265
266 void DrawLabel(const wxString& text, const wxRect& rect,
267 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
268 int indexAccel = -1)
269 { DrawLabel(text, wxNullBitmap, rect, alignment, indexAccel); }
270
72cdf4c9
VZ
271 bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
272 wxDC *source, wxCoord xsrc, wxCoord ysrc,
68379eaf 273 int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord)
a23fd0e1
VZ
274 {
275 return DoBlit(xdest, ydest, width, height,
0cbff120 276 source, xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask);
a23fd0e1
VZ
277 }
278 bool Blit(const wxPoint& destPt, const wxSize& sz,
279 wxDC *source, const wxPoint& srcPt,
68379eaf 280 int rop = wxCOPY, bool useMask = false, const wxPoint& srcPtMask = wxDefaultPosition)
a23fd0e1
VZ
281 {
282 return DoBlit(destPt.x, destPt.y, sz.x, sz.y,
0cbff120 283 source, srcPt.x, srcPt.y, rop, useMask, srcPtMask.x, srcPtMask.y);
a23fd0e1 284 }
e3b81044
VZ
285
286 bool StretchBlit(wxCoord dstX, wxCoord dstY,
287 wxCoord dstWidth, wxCoord dstHeight,
288 wxDC *source,
289 wxCoord srcX, wxCoord srcY,
290 wxCoord srcWidth, wxCoord srcHeight,
291 int rop = wxCOPY, bool useMask = false,
292 wxCoord srcMaskX = wxDefaultCoord, wxCoord srcMaskY = wxDefaultCoord)
293 {
294 return DoStretchBlit(dstX, dstY, dstWidth, dstHeight,
295 source, srcX, srcY, srcWidth, srcHeight, rop, useMask, srcMaskX, srcMaskY);
296 }
297 bool StretchBlit(const wxPoint& dstPt, const wxSize& dstSize,
298 wxDC *source, const wxPoint& srcPt, const wxSize& srcSize,
299 int rop = wxCOPY, bool useMask = false, const wxPoint& srcMaskPt = wxDefaultPosition)
300 {
301 return DoStretchBlit(dstPt.x, dstPt.y, dstSize.x, dstSize.y,
302 source, srcPt.x, srcPt.y, srcSize.x, srcSize.y, rop, useMask, srcMaskPt.x, srcMaskPt.y);
303 }
304
c59abe03 305 wxBitmap GetAsBitmap(const wxRect *subrect = (const wxRect *) NULL) const
c64c9cd3 306 {
c59abe03 307 return DoGetAsBitmap(subrect);
c64c9cd3 308 }
a23fd0e1
VZ
309
310#if wxUSE_SPLINES
72cdf4c9
VZ
311 // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?)
312 void DrawSpline(wxCoord x1, wxCoord y1,
313 wxCoord x2, wxCoord y2,
314 wxCoord x3, wxCoord y3);
bd5dd957 315 void DrawSpline(int n, wxPoint points[]);
a23fd0e1
VZ
316
317 void DrawSpline(wxList *points) { DoDrawSpline(points); }
318#endif // wxUSE_SPLINES
319
12bdd77c
JS
320 // Eventually we will have wxUSE_GENERIC_DRAWELLIPSE
321#ifdef __WXWINCE__
322 //! Generic method to draw ellipses, circles and arcs with current pen and brush.
323 /*! \param x Upper left corner of bounding box.
324 * \param y Upper left corner of bounding box.
325 * \param w Width of bounding box.
326 * \param h Height of bounding box.
d16b634f 327 * \param sa Starting angle of arc
12bdd77c
JS
328 * (counterclockwise, start at 3 o'clock, 360 is full circle).
329 * \param ea Ending angle of arc.
d16b634f 330 * \param angle Rotation angle, the Arc will be rotated after
12bdd77c
JS
331 * calculating begin and end.
332 */
d16b634f
VZ
333 void DrawEllipticArcRot( wxCoord x, wxCoord y,
334 wxCoord width, wxCoord height,
12bdd77c
JS
335 double sa = 0, double ea = 0, double angle = 0 )
336 { DoDrawEllipticArcRot( x, y, width, height, sa, ea, angle ); }
d16b634f
VZ
337
338 void DrawEllipticArcRot( const wxPoint& pt,
12bdd77c
JS
339 const wxSize& sz,
340 double sa = 0, double ea = 0, double angle = 0 )
341 { DoDrawEllipticArcRot( pt.x, pt.y, sz.x, sz.y, sa, ea, angle ); }
342
343 void DrawEllipticArcRot( const wxRect& rect,
344 double sa = 0, double ea = 0, double angle = 0 )
345 { DoDrawEllipticArcRot( rect.x, rect.y, rect.width, rect.height, sa, ea, angle ); }
346
d16b634f
VZ
347 virtual void DoDrawEllipticArcRot( wxCoord x, wxCoord y,
348 wxCoord w, wxCoord h,
12bdd77c 349 double sa = 0, double ea = 0, double angle = 0 );
d16b634f 350
12bdd77c
JS
351 //! Rotates points around center.
352 /*! This is a quite straight method, it calculates in pixels
353 * and so it produces rounding errors.
354 * \param points The points inside will be rotated.
355 * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle).
356 * \param center Center of rotation.
d16b634f 357 */
c47addef 358 void Rotate( wxList* points, double angle, wxPoint center = wxPoint(0,0) );
12bdd77c
JS
359
360 // used by DrawEllipticArcRot
361 // Careful: wxList gets filled with points you have to delete later.
d16b634f
VZ
362 void CalculateEllipticPoints( wxList* points,
363 wxCoord xStart, wxCoord yStart,
364 wxCoord w, wxCoord h,
12bdd77c
JS
365 double sa, double ea );
366#endif
d16b634f 367
a23fd0e1
VZ
368 // global DC operations
369 // --------------------
370
371 virtual void Clear() = 0;
372
68379eaf 373 virtual bool StartDoc(const wxString& WXUNUSED(message)) { return true; }
af0bb3b1 374 virtual void EndDoc() { }
a23fd0e1 375
af0bb3b1
VZ
376 virtual void StartPage() { }
377 virtual void EndPage() { }
a23fd0e1 378
2e992e06
VZ
379#if WXWIN_COMPATIBILITY_2_6
380 wxDEPRECATED( void BeginDrawing() );
381 wxDEPRECATED( void EndDrawing() );
382#endif // WXWIN_COMPATIBILITY_2_6
383
384
a23fd0e1
VZ
385 // set objects to use for drawing
386 // ------------------------------
387
388 virtual void SetFont(const wxFont& font) = 0;
389 virtual void SetPen(const wxPen& pen) = 0;
390 virtual void SetBrush(const wxBrush& brush) = 0;
391 virtual void SetBackground(const wxBrush& brush) = 0;
392 virtual void SetBackgroundMode(int mode) = 0;
d275c7eb 393#if wxUSE_PALETTE
a23fd0e1 394 virtual void SetPalette(const wxPalette& palette) = 0;
d275c7eb 395#endif // wxUSE_PALETTE
a23fd0e1
VZ
396
397 // clipping region
398 // ---------------
399
72cdf4c9 400 void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
a23fd0e1
VZ
401 { DoSetClippingRegion(x, y, width, height); }
402 void SetClippingRegion(const wxPoint& pt, const wxSize& sz)
403 { DoSetClippingRegion(pt.x, pt.y, sz.x, sz.y); }
404 void SetClippingRegion(const wxRect& rect)
405 { DoSetClippingRegion(rect.x, rect.y, rect.width, rect.height); }
406 void SetClippingRegion(const wxRegion& region)
407 { DoSetClippingRegionAsRegion(region); }
408
d16b634f 409 virtual void DestroyClippingRegion() { ResetClipping(); }
a23fd0e1 410
72cdf4c9 411 void GetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const
a23fd0e1
VZ
412 { DoGetClippingBox(x, y, w, h); }
413 void GetClippingBox(wxRect& rect) const
8fb3a512 414 {
ae500232 415 DoGetClippingBox(&rect.x, &rect.y, &rect.width, &rect.height);
8fb3a512 416 }
a23fd0e1
VZ
417
418 // text extent
419 // -----------
420
72cdf4c9
VZ
421 virtual wxCoord GetCharHeight() const = 0;
422 virtual wxCoord GetCharWidth() const = 0;
cd9da200 423
1e6feb95 424 // only works for single line strings
72cdf4c9
VZ
425 void GetTextExtent(const wxString& string,
426 wxCoord *x, wxCoord *y,
427 wxCoord *descent = NULL,
428 wxCoord *externalLeading = NULL,
c94f845b 429 const wxFont *theFont = NULL) const
72cdf4c9 430 { DoGetTextExtent(string, x, y, descent, externalLeading, theFont); }
a23fd0e1 431
cc4f194e
VZ
432 wxSize GetTextExtent(const wxString& string) const
433 {
434 wxCoord w, h;
435 DoGetTextExtent(string, &w, &h);
436 return wxSize(w, h);
437 }
438
1e6feb95 439 // works for single as well as multi-line strings
cc4f194e 440 virtual void GetMultiLineTextExtent(const wxString& string,
1e6feb95
VZ
441 wxCoord *width,
442 wxCoord *height,
443 wxCoord *heightLine = NULL,
c94f845b 444 const wxFont *font = NULL) const;
1e6feb95 445
cc4f194e
VZ
446 wxSize GetMultiLineTextExtent(const wxString& string) const
447 {
448 wxCoord w, h;
449 GetMultiLineTextExtent(string, &w, &h);
450 return wxSize(w, h);
451 }
452
0919e93e
RD
453 // Measure cumulative width of text after each character
454 bool GetPartialTextExtents(const wxString& text, wxArrayInt& widths) const
455 { return DoGetPartialTextExtents(text, widths); }
456
d16b634f 457
a23fd0e1
VZ
458 // size and resolution
459 // -------------------
460
461 // in device units
462 void GetSize(int *width, int *height) const
463 { DoGetSize(width, height); }
464 wxSize GetSize() const
465 {
466 int w, h;
467 DoGetSize(&w, &h);
468
469 return wxSize(w, h);
470 }
471
472 // in mm
473 void GetSizeMM(int* width, int* height) const
474 { DoGetSizeMM(width, height); }
475 wxSize GetSizeMM() const
476 {
477 int w, h;
478 DoGetSizeMM(&w, &h);
479
480 return wxSize(w, h);
481 }
482
a23fd0e1
VZ
483 // query DC capabilities
484 // ---------------------
485
486 virtual bool CanDrawBitmap() const = 0;
487 virtual bool CanGetTextExtent() const = 0;
488
489 // colour depth
490 virtual int GetDepth() const = 0;
491
492 // Resolution in Pixels per inch
493 virtual wxSize GetPPI() const = 0;
494
b7cacb43
VZ
495 virtual bool Ok() const { return IsOk(); }
496 virtual bool IsOk() const { return m_ok; }
a23fd0e1 497
2439f37a
VZ
498 // accessors and setters
499 // ---------------------
a23fd0e1 500
2e992e06
VZ
501 virtual int GetBackgroundMode() const { return m_backgroundMode; }
502 virtual const wxBrush& GetBackground() const { return m_backgroundBrush; }
503 virtual const wxBrush& GetBrush() const { return m_brush; }
504 virtual const wxFont& GetFont() const { return m_font; }
505 virtual const wxPen& GetPen() const { return m_pen; }
a23fd0e1 506
2e992e06
VZ
507 virtual const wxColour& GetTextForeground() const { return m_textForegroundColour; }
508 virtual const wxColour& GetTextBackground() const { return m_textBackgroundColour; }
a23fd0e1
VZ
509 virtual void SetTextForeground(const wxColour& colour)
510 { m_textForegroundColour = colour; }
511 virtual void SetTextBackground(const wxColour& colour)
512 { m_textBackgroundColour = colour; }
513
04ab8b6d
RR
514
515 // coordinates conversions and transforms
516 // --------------------------------------
517
518 virtual wxCoord DeviceToLogicalX(wxCoord x) const;
519 virtual wxCoord DeviceToLogicalY(wxCoord y) const;
520 virtual wxCoord DeviceToLogicalXRel(wxCoord x) const;
521 virtual wxCoord DeviceToLogicalYRel(wxCoord y) const;
522 virtual wxCoord LogicalToDeviceX(wxCoord x) const;
523 virtual wxCoord LogicalToDeviceY(wxCoord y) const;
524 virtual wxCoord LogicalToDeviceXRel(wxCoord x) const;
525 virtual wxCoord LogicalToDeviceYRel(wxCoord y) const;
526
527 virtual void SetMapMode(int mode);
2e992e06 528 virtual int GetMapMode() const { return m_mappingMode; }
a23fd0e1 529
04ab8b6d 530 virtual void SetUserScale(double x, double y);
a23fd0e1
VZ
531 virtual void GetUserScale(double *x, double *y) const
532 {
533 if ( x ) *x = m_userScaleX;
534 if ( y ) *y = m_userScaleY;
535 }
a23fd0e1 536
04ab8b6d 537 virtual void SetLogicalScale(double x, double y);
a23fd0e1
VZ
538 virtual void GetLogicalScale(double *x, double *y)
539 {
540 if ( x ) *x = m_logicalScaleX;
541 if ( y ) *y = m_logicalScaleY;
542 }
a23fd0e1 543
04ab8b6d 544 virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
72cdf4c9 545 void GetLogicalOrigin(wxCoord *x, wxCoord *y) const
a23fd0e1
VZ
546 { DoGetLogicalOrigin(x, y); }
547 wxPoint GetLogicalOrigin() const
72cdf4c9 548 { wxCoord x, y; DoGetLogicalOrigin(&x, &y); return wxPoint(x, y); }
a23fd0e1 549
04ab8b6d 550 virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
72cdf4c9 551 void GetDeviceOrigin(wxCoord *x, wxCoord *y) const
a23fd0e1
VZ
552 { DoGetDeviceOrigin(x, y); }
553 wxPoint GetDeviceOrigin() const
72cdf4c9 554 { wxCoord x, y; DoGetDeviceOrigin(&x, &y); return wxPoint(x, y); }
04ab8b6d
RR
555
556 virtual void SetDeviceLocalOrigin( wxCoord x, wxCoord y );
a23fd0e1 557
04ab8b6d 558 virtual void ComputeScaleAndOrigin();
b1263dcf 559
04ab8b6d
RR
560 // this needs to overidden if the axis is inverted (such
561 // as when using Postscript, where 0,0 is the lower left
562 // corner, not the upper left).
563 virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
a23fd0e1 564
04ab8b6d
RR
565 // logical functions
566 // ---------------------------
567
2e992e06 568 virtual int GetLogicalFunction() const { return m_logicalFunction; }
a23fd0e1
VZ
569 virtual void SetLogicalFunction(int function) = 0;
570
a23fd0e1
VZ
571 // bounding box
572 // ------------
573
72cdf4c9 574 virtual void CalcBoundingBox(wxCoord x, wxCoord y)
a23fd0e1 575 {
f6bcfd97
BP
576 if ( m_isBBoxValid )
577 {
578 if ( x < m_minX ) m_minX = x;
579 if ( y < m_minY ) m_minY = y;
580 if ( x > m_maxX ) m_maxX = x;
581 if ( y > m_maxY ) m_maxY = y;
582 }
583 else
584 {
68379eaf 585 m_isBBoxValid = true;
f6bcfd97
BP
586
587 m_minX = x;
588 m_minY = y;
589 m_maxX = x;
590 m_maxY = y;
591 }
592 }
593
594 void ResetBoundingBox()
595 {
68379eaf 596 m_isBBoxValid = false;
f6bcfd97
BP
597
598 m_minX = m_maxX = m_minY = m_maxY = 0;
a23fd0e1
VZ
599 }
600
601 // Get the final bounding box of the PostScript or Metafile picture.
72cdf4c9
VZ
602 wxCoord MinX() const { return m_minX; }
603 wxCoord MaxX() const { return m_maxX; }
604 wxCoord MinY() const { return m_minY; }
605 wxCoord MaxY() const { return m_maxY; }
a23fd0e1
VZ
606
607 // misc old functions
608 // ------------------
609
ad973712 610#if WXWIN_COMPATIBILITY_2_8
72cdf4c9 611 // for compatibility with the old code when wxCoord was long everywhere
1f540d96 612 wxDEPRECATED( void GetTextExtent(const wxString& string,
72cdf4c9
VZ
613 long *x, long *y,
614 long *descent = NULL,
615 long *externalLeading = NULL,
cfa87e81
RR
616 const wxFont *theFont = NULL) const );
617 wxDEPRECATED( void GetLogicalOrigin(long *x, long *y) const );
618 wxDEPRECATED( void GetDeviceOrigin(long *x, long *y) const );
619 wxDEPRECATED( void GetClippingBox(long *x, long *y, long *w, long *h) const );
ad973712 620#endif // WXWIN_COMPATIBILITY_2_8
72cdf4c9 621
6ae7410f
VZ
622 // RTL related functions
623 // ---------------------
624
625 // get or change the layout direction (LTR or RTL) for this dc,
626 // wxLayout_Default is returned if layout direction is not supported
627 virtual wxLayoutDirection GetLayoutDirection() const
628 { return wxLayout_Default; }
629 virtual void SetLayoutDirection(wxLayoutDirection WXUNUSED(dir))
630 { }
631
a23fd0e1
VZ
632protected:
633 // the pure virtual functions which should be implemented by wxDC
387ebd3e 634 virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
a23fd0e1
VZ
635 int style = wxFLOOD_SURFACE) = 0;
636
213ad8e7
VZ
637 virtual void DoGradientFillLinear(const wxRect& rect,
638 const wxColour& initialColour,
639 const wxColour& destColour,
640 wxDirection nDirection = wxEAST);
4660e6ac 641
fb63a242
SC
642 virtual void DoGradientFillConcentric(const wxRect& rect,
643 const wxColour& initialColour,
644 const wxColour& destColour,
645 const wxPoint& circleCenter);
646
72cdf4c9 647 virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const = 0;
a23fd0e1 648
72cdf4c9
VZ
649 virtual void DoDrawPoint(wxCoord x, wxCoord y) = 0;
650 virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) = 0;
a23fd0e1 651
72cdf4c9
VZ
652 virtual void DoDrawArc(wxCoord x1, wxCoord y1,
653 wxCoord x2, wxCoord y2,
654 wxCoord xc, wxCoord yc) = 0;
cd9da200
VZ
655 virtual void DoDrawCheckMark(wxCoord x, wxCoord y,
656 wxCoord width, wxCoord height);
72cdf4c9 657 virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
a23fd0e1
VZ
658 double sa, double ea) = 0;
659
72cdf4c9
VZ
660 virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) = 0;
661 virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
662 wxCoord width, wxCoord height,
a23fd0e1 663 double radius) = 0;
72cdf4c9
VZ
664 virtual void DoDrawEllipse(wxCoord x, wxCoord y,
665 wxCoord width, wxCoord height) = 0;
a23fd0e1 666
72cdf4c9 667 virtual void DoCrossHair(wxCoord x, wxCoord y) = 0;
a23fd0e1 668
72cdf4c9
VZ
669 virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) = 0;
670 virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
68379eaf 671 bool useMask = false) = 0;
a23fd0e1 672
72cdf4c9 673 virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y) = 0;
95724b1a
VZ
674 virtual void DoDrawRotatedText(const wxString& text,
675 wxCoord x, wxCoord y, double angle) = 0;
a23fd0e1 676
72cdf4c9
VZ
677 virtual bool DoBlit(wxCoord xdest, wxCoord ydest,
678 wxCoord width, wxCoord height,
e3b81044
VZ
679 wxDC *source,
680 wxCoord xsrc, wxCoord ysrc,
681 int rop = wxCOPY,
682 bool useMask = false,
683 wxCoord xsrcMask = wxDefaultCoord,
684 wxCoord ysrcMask = wxDefaultCoord) = 0;
685
686 virtual bool DoStretchBlit(wxCoord xdest, wxCoord ydest,
687 wxCoord dstWidth, wxCoord dstHeight,
688 wxDC *source,
689 wxCoord xsrc, wxCoord ysrc,
690 wxCoord srcWidth, wxCoord srcHeight,
691 int rop = wxCOPY,
692 bool useMask = false,
693 wxCoord xsrcMask = wxDefaultCoord,
694 wxCoord ysrcMask = wxDefaultCoord);
695
696 virtual wxBitmap DoGetAsBitmap(const wxRect *WXUNUSED(subrect)) const
697 { return wxNullBitmap; }
c64c9cd3 698
a23fd0e1
VZ
699 virtual void DoGetSize(int *width, int *height) const = 0;
700 virtual void DoGetSizeMM(int* width, int* height) const = 0;
701
702 virtual void DoDrawLines(int n, wxPoint points[],
72cdf4c9 703 wxCoord xoffset, wxCoord yoffset) = 0;
a23fd0e1 704 virtual void DoDrawPolygon(int n, wxPoint points[],
72cdf4c9 705 wxCoord xoffset, wxCoord yoffset,
a23fd0e1 706 int fillStyle = wxODDEVEN_RULE) = 0;
793db755 707 virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[],
6e76b35d
VZ
708 wxCoord xoffset, wxCoord yoffset,
709 int fillStyle);
a23fd0e1
VZ
710
711 virtual void DoSetClippingRegionAsRegion(const wxRegion& region) = 0;
72cdf4c9
VZ
712 virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
713 wxCoord width, wxCoord height) = 0;
b0e0d661 714
72cdf4c9
VZ
715 virtual void DoGetClippingBox(wxCoord *x, wxCoord *y,
716 wxCoord *w, wxCoord *h) const
a23fd0e1 717 {
d16b634f
VZ
718 if ( x )
719 *x = m_clipX1;
720 if ( y )
721 *y = m_clipY1;
722 if ( w )
723 *w = m_clipX2 - m_clipX1;
724 if ( h )
725 *h = m_clipY2 - m_clipY1;
a23fd0e1
VZ
726 }
727
72cdf4c9 728 virtual void DoGetLogicalOrigin(wxCoord *x, wxCoord *y) const
a23fd0e1
VZ
729 {
730 if ( x ) *x = m_logicalOriginX;
731 if ( y ) *y = m_logicalOriginY;
732 }
733
72cdf4c9 734 virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const
a23fd0e1
VZ
735 {
736 if ( x ) *x = m_deviceOriginX;
737 if ( y ) *y = m_deviceOriginY;
738 }
739
72cdf4c9
VZ
740 virtual void DoGetTextExtent(const wxString& string,
741 wxCoord *x, wxCoord *y,
742 wxCoord *descent = NULL,
743 wxCoord *externalLeading = NULL,
c94f845b 744 const wxFont *theFont = NULL) const = 0;
d16b634f 745
0919e93e 746 virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
d16b634f 747
64698f9a 748#if wxUSE_SPLINES
fe2e4366 749 virtual void DoDrawSpline(wxList *points);
64698f9a 750#endif
a23fd0e1
VZ
751
752protected:
d16b634f
VZ
753 // unset clipping variables (after clipping region was destroyed)
754 void ResetClipping()
755 {
756 m_clipping = false;
757
758 m_clipX1 = m_clipX2 = m_clipY1 = m_clipY2 = 0;
759 }
760
a23fd0e1
VZ
761 // flags
762 bool m_colour:1;
763 bool m_ok:1;
764 bool m_clipping:1;
765 bool m_isInteractive:1;
f6bcfd97 766 bool m_isBBoxValid:1;
a23fd0e1
VZ
767
768 // coordinate system variables
769
770 // TODO short descriptions of what exactly they are would be nice...
771
72cdf4c9 772 wxCoord m_logicalOriginX, m_logicalOriginY;
04ab8b6d
RR
773 wxCoord m_deviceOriginX, m_deviceOriginY; // Usually 0,0, can be change by user
774
775 wxCoord m_deviceLocalOriginX, m_deviceLocalOriginY; // non-zero if native top-left corner
776 // is not at 0,0. This was the case under
777 // Mac's GrafPorts (coordinate system
778 // used toplevel window's origin) and
779 // e.g. for Postscript, where the native
780 // origin in the bottom left corner.
a23fd0e1
VZ
781 double m_logicalScaleX, m_logicalScaleY;
782 double m_userScaleX, m_userScaleY;
04ab8b6d 783 double m_scaleX, m_scaleY; // calculated from logical scale and user scale
a23fd0e1
VZ
784
785 // Used by SetAxisOrientation() to invert the axes
786 int m_signX, m_signY;
787
04ab8b6d
RR
788 // what is a mm on a screen you don't know the size of?
789 double m_mm_to_pix_x,
790 m_mm_to_pix_y;
791
a23fd0e1 792 // bounding and clipping boxes
72cdf4c9
VZ
793 wxCoord m_minX, m_minY, m_maxX, m_maxY;
794 wxCoord m_clipX1, m_clipY1, m_clipX2, m_clipY2;
a23fd0e1
VZ
795
796 int m_logicalFunction;
797 int m_backgroundMode;
798 int m_mappingMode;
799
800 // GDI objects
801 wxPen m_pen;
802 wxBrush m_brush;
803 wxBrush m_backgroundBrush;
804 wxColour m_textForegroundColour;
805 wxColour m_textBackgroundColour;
806 wxFont m_font;
d275c7eb
VZ
807
808#if wxUSE_PALETTE
a23fd0e1 809 wxPalette m_palette;
b95edd47 810 bool m_hasCustomPalette;
d275c7eb 811#endif // wxUSE_PALETTE
a23fd0e1
VZ
812
813private:
ac84e37d 814 DECLARE_NO_COPY_CLASS(wxDCBase)
cd9da200 815 DECLARE_ABSTRACT_CLASS(wxDCBase)
a23fd0e1
VZ
816};
817
818// ----------------------------------------------------------------------------
819// now include the declaration of wxDC class
820// ----------------------------------------------------------------------------
821
4055ed82 822#if defined(__WXPALMOS__)
ffecfa5a
JS
823 #include "wx/palmos/dc.h"
824#elif defined(__WXMSW__)
a23fd0e1 825 #include "wx/msw/dc.h"
2049ba38 826#elif defined(__WXMOTIF__)
a23fd0e1 827 #include "wx/motif/dc.h"
1be7a35c 828#elif defined(__WXGTK20__)
a23fd0e1 829 #include "wx/gtk/dc.h"
1be7a35c
MR
830#elif defined(__WXGTK__)
831 #include "wx/gtk1/dc.h"
83df96d6
JS
832#elif defined(__WXX11__)
833 #include "wx/x11/dc.h"
1e6feb95
VZ
834#elif defined(__WXMGL__)
835 #include "wx/mgl/dc.h"
b3c86150
VS
836#elif defined(__WXDFB__)
837 #include "wx/dfb/dc.h"
34138703 838#elif defined(__WXMAC__)
a23fd0e1 839 #include "wx/mac/dc.h"
f4515f98
DE
840#elif defined(__WXCOCOA__)
841 #include "wx/cocoa/dc.h"
1777b9bb
DW
842#elif defined(__WXPM__)
843 #include "wx/os2/dc.h"
c801d85f
KB
844#endif
845
8acd14d1
SC
846#if wxUSE_GRAPHICS_CONTEXT
847 #include "wx/dcgraph.h"
848#endif
849
1e6feb95
VZ
850// ----------------------------------------------------------------------------
851// helper class: you can use it to temporarily change the DC text colour and
852// restore it automatically when the object goes out of scope
853// ----------------------------------------------------------------------------
854
855class WXDLLEXPORT wxDCTextColourChanger
856{
857public:
ba161d7e 858 wxDCTextColourChanger(wxDC& dc) : m_dc(dc), m_colFgOld() { }
1e6feb95 859
1b97b23d
VS
860 wxDCTextColourChanger(wxDC& dc, const wxColour& col) : m_dc(dc)
861 {
862 Set(col);
863 }
864
1e6feb95
VZ
865 ~wxDCTextColourChanger()
866 {
867 if ( m_colFgOld.Ok() )
868 m_dc.SetTextForeground(m_colFgOld);
869 }
870
871 void Set(const wxColour& col)
872 {
873 if ( !m_colFgOld.Ok() )
874 m_colFgOld = m_dc.GetTextForeground();
875 m_dc.SetTextForeground(col);
876 }
877
878private:
879 wxDC& m_dc;
880
881 wxColour m_colFgOld;
fc7a2a60
VZ
882
883 DECLARE_NO_COPY_CLASS(wxDCTextColourChanger)
1e6feb95
VZ
884};
885
4660e6ac
WS
886// ----------------------------------------------------------------------------
887// helper class: you can use it to temporarily change the DC pen and
888// restore it automatically when the object goes out of scope
889// ----------------------------------------------------------------------------
890
891class WXDLLEXPORT wxDCPenChanger
892{
893public:
0164f8eb
WS
894 wxDCPenChanger(wxDC& dc, const wxPen& pen) : m_dc(dc), m_penOld(dc.GetPen())
895 {
896 m_dc.SetPen(pen);
897 }
4660e6ac
WS
898
899 ~wxDCPenChanger()
900 {
901 if ( m_penOld.Ok() )
902 m_dc.SetPen(m_penOld);
903 }
904
4660e6ac
WS
905private:
906 wxDC& m_dc;
907
908 wxPen m_penOld;
909
910 DECLARE_NO_COPY_CLASS(wxDCPenChanger)
911};
912
913// ----------------------------------------------------------------------------
914// helper class: you can use it to temporarily change the DC brush and
915// restore it automatically when the object goes out of scope
916// ----------------------------------------------------------------------------
917
918class WXDLLEXPORT wxDCBrushChanger
919{
920public:
0164f8eb
WS
921 wxDCBrushChanger(wxDC& dc, const wxBrush& brush) : m_dc(dc), m_brushOld(dc.GetBrush())
922 {
923 m_dc.SetBrush(brush);
924 }
4660e6ac
WS
925
926 ~wxDCBrushChanger()
927 {
928 if ( m_brushOld.Ok() )
929 m_dc.SetBrush(m_brushOld);
930 }
931
4660e6ac
WS
932private:
933 wxDC& m_dc;
934
935 wxBrush m_brushOld;
936
937 DECLARE_NO_COPY_CLASS(wxDCBrushChanger)
938};
939
e26be42b
VZ
940// ----------------------------------------------------------------------------
941// another small helper class: sets the clipping region in its ctor and
942// destroys it in the dtor
943// ----------------------------------------------------------------------------
944
945class WXDLLEXPORT wxDCClipper
946{
947public:
fc298ea7
VZ
948 wxDCClipper(wxDC& dc, const wxRegion& r) : m_dc(dc)
949 { dc.SetClippingRegion(r); }
e26be42b
VZ
950 wxDCClipper(wxDC& dc, const wxRect& r) : m_dc(dc)
951 { dc.SetClippingRegion(r.x, r.y, r.width, r.height); }
952 wxDCClipper(wxDC& dc, wxCoord x, wxCoord y, wxCoord w, wxCoord h) : m_dc(dc)
953 { dc.SetClippingRegion(x, y, w, h); }
954
955 ~wxDCClipper() { m_dc.DestroyClippingRegion(); }
956
957private:
958 wxDC& m_dc;
fc7a2a60
VZ
959
960 DECLARE_NO_COPY_CLASS(wxDCClipper)
e26be42b
VZ
961};
962
8b56b16a 963#endif // _WX_DC_H_BASE_