]> git.saurik.com Git - wxWidgets.git/blame - include/wx/dc.h
Digital Mars compilation warnings and Unicode fixes (patch 884587)
[wxWidgets.git] / include / wx / dc.h
CommitLineData
006162a9
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: dc.h
3// Purpose: wxDC class
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 05/25/99
7// RCS-ID: $Id$
8// Copyright: (c) wxWindows team
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_DC_H_BASE_
13#define _WX_DC_H_BASE_
c801d85f 14
12028905 15#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
a23fd0e1
VZ
16 #pragma interface "dcbase.h"
17#endif
18
19// ----------------------------------------------------------------------------
20// headers which we must include here
21// ----------------------------------------------------------------------------
22
23#include "wx/object.h" // the base class
24
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/brush.h"
29#include "wx/pen.h"
30#include "wx/palette.h"
a23fd0e1
VZ
31#include "wx/list.h" // we use wxList in inline functions
32
f4515f98 33class WXDLLEXPORT wxDC;
aec43716
KH
34class WXDLLEXPORT wxDCBase;
35
36class WXDLLEXPORT wxDrawObject
37{
38public:
39
40 wxDrawObject()
ba161d7e
GD
41 : m_isBBoxValid(FALSE)
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 {
60 m_isBBoxValid = TRUE;
61
62 m_minX = x;
63 m_minY = y;
64 m_maxX = x;
65 m_maxY = y;
66 }
67 }
68
69 void ResetBoundingBox()
70 {
71 m_isBBoxValid = FALSE;
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
97WXDLLEXPORT_DATA(extern int) wxPageNumber;
98
99// ---------------------------------------------------------------------------
100// wxDC is the device context - object on which any drawing is done
101// ---------------------------------------------------------------------------
102
103class WXDLLEXPORT wxDCBase : public wxObject
104{
a23fd0e1
VZ
105public:
106 wxDCBase()
ba161d7e
GD
107 : m_colour(wxColourDisplay())
108 , m_ok(TRUE)
109 , m_clipping(FALSE)
110 , m_isInteractive(0)
111 , m_isBBoxValid(FALSE)
112 , m_logicalOriginX(0), m_logicalOriginY(0)
113 , m_deviceOriginX(0), m_deviceOriginY(0)
114 , m_logicalScaleX(1.0), m_logicalScaleY(1.0)
115 , m_userScaleX(1.0), m_userScaleY(1.0)
116 , m_scaleX(1.0), m_scaleY(1.0)
117 , m_signX(1), m_signY(1)
118 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
119 , m_clipX1(0), m_clipY1(0), m_clipX2(0), m_clipY2(0)
120 , m_logicalFunction(wxCOPY)
121 , m_backgroundMode(wxTRANSPARENT)
122 , m_mappingMode(wxMM_TEXT)
123 , m_pen()
124 , m_brush()
125 , m_backgroundBrush(*wxTRANSPARENT_BRUSH)
126 , m_textForegroundColour(*wxBLACK)
127 , m_textBackgroundColour(*wxWHITE)
128 , m_font()
129#if wxUSE_PALETTE
130 , m_palette()
131 , m_hasCustomPalette(FALSE)
132#endif // wxUSE_PALETTE
a23fd0e1 133 {
f6bcfd97 134 ResetBoundingBox();
a23fd0e1
VZ
135 }
136
137 ~wxDCBase() { }
138
139 virtual void BeginDrawing() { }
140 virtual void EndDrawing() { }
141
142 // graphic primitives
143 // ------------------
144
aec43716
KH
145 virtual void DrawObject(wxDrawObject* drawobject)
146 {
147 drawobject->Draw(*this);
148 CalcBoundingBox(drawobject->MinX(),drawobject->MinY());
149 CalcBoundingBox(drawobject->MaxX(),drawobject->MaxY());
150 }
151
387ebd3e 152 bool FloodFill(wxCoord x, wxCoord y, const wxColour& col,
72cdf4c9 153 int style = wxFLOOD_SURFACE)
387ebd3e
JS
154 { return DoFloodFill(x, y, col, style); }
155 bool FloodFill(const wxPoint& pt, const wxColour& col,
72cdf4c9 156 int style = wxFLOOD_SURFACE)
387ebd3e 157 { return DoFloodFill(pt.x, pt.y, col, style); }
a23fd0e1 158
72cdf4c9 159 bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const
a23fd0e1
VZ
160 { return DoGetPixel(x, y, col); }
161 bool GetPixel(const wxPoint& pt, wxColour *col) const
162 { return DoGetPixel(pt.x, pt.y, col); }
163
72cdf4c9 164 void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
a23fd0e1
VZ
165 { DoDrawLine(x1, y1, x2, y2); }
166 void DrawLine(const wxPoint& pt1, const wxPoint& pt2)
167 { DoDrawLine(pt1.x, pt1.y, pt2.x, pt2.y); }
168
72cdf4c9 169 void CrossHair(wxCoord x, wxCoord y)
a23fd0e1
VZ
170 { DoCrossHair(x, y); }
171 void CrossHair(const wxPoint& pt)
172 { DoCrossHair(pt.x, pt.y); }
173
72cdf4c9
VZ
174 void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
175 wxCoord xc, wxCoord yc)
a23fd0e1
VZ
176 { DoDrawArc(x1, y1, x2, y2, xc, yc); }
177 void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre)
178 { DoDrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y); }
179
cd9da200
VZ
180 void DrawCheckMark(wxCoord x, wxCoord y,
181 wxCoord width, wxCoord height)
182 { DoDrawCheckMark(x, y, width, height); }
183 void DrawCheckMark(const wxRect& rect)
184 { DoDrawCheckMark(rect.x, rect.y, rect.width, rect.height); }
185
72cdf4c9
VZ
186 void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
187 double sa, double ea)
7b90a8f2 188 { DoDrawEllipticArc(x, y, w, h, sa, ea); }
a23fd0e1
VZ
189 void DrawEllipticArc(const wxPoint& pt, const wxSize& sz,
190 double sa, double ea)
191 { DoDrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea); }
192
72cdf4c9 193 void DrawPoint(wxCoord x, wxCoord y)
a23fd0e1
VZ
194 { DoDrawPoint(x, y); }
195 void DrawPoint(const wxPoint& pt)
196 { DoDrawPoint(pt.x, pt.y); }
197
72cdf4c9
VZ
198 void DrawLines(int n, wxPoint points[],
199 wxCoord xoffset = 0, wxCoord yoffset = 0)
a23fd0e1 200 { DoDrawLines(n, points, xoffset, yoffset); }
72cdf4c9
VZ
201 void DrawLines(const wxList *list,
202 wxCoord xoffset = 0, wxCoord yoffset = 0);
a23fd0e1
VZ
203
204 void DrawPolygon(int n, wxPoint points[],
72cdf4c9 205 wxCoord xoffset = 0, wxCoord yoffset = 0,
a23fd0e1
VZ
206 int fillStyle = wxODDEVEN_RULE)
207 { DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); }
208
209 void DrawPolygon(const wxList *list,
72cdf4c9 210 wxCoord xoffset = 0, wxCoord yoffset = 0,
bd5dd957 211 int fillStyle = wxODDEVEN_RULE);
a23fd0e1 212
6e76b35d
VZ
213 void DrawPolyPolygon(int n, int start[], wxPoint points[],
214 wxCoord xoffset = 0, wxCoord yoffset = 0,
215 int fillStyle = wxODDEVEN_RULE)
216 { DoDrawPolyPolygon(n, start, points, xoffset, yoffset, fillStyle); }
217
72cdf4c9 218 void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
a23fd0e1
VZ
219 { DoDrawRectangle(x, y, width, height); }
220 void DrawRectangle(const wxPoint& pt, const wxSize& sz)
221 { DoDrawRectangle(pt.x, pt.y, sz.x, sz.y); }
222 void DrawRectangle(const wxRect& rect)
223 { DoDrawRectangle(rect.x, rect.y, rect.width, rect.height); }
224
72cdf4c9 225 void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height,
a23fd0e1
VZ
226 double radius)
227 { DoDrawRoundedRectangle(x, y, width, height, radius); }
228 void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz,
229 double radius)
230 { DoDrawRoundedRectangle(pt.x, pt.y, sz.x, sz.y, radius); }
231 void DrawRoundedRectangle(const wxRect& r, double radius)
232 { DoDrawRoundedRectangle(r.x, r.y, r.width, r.height, radius); }
233
72cdf4c9 234 void DrawCircle(wxCoord x, wxCoord y, wxCoord radius)
220af862 235 { DoDrawEllipse(x - radius, y - radius, 2*radius, 2*radius); }
0371e9a8 236 void DrawCircle(const wxPoint& pt, wxCoord radius)
b95edd47 237 { DrawCircle(pt.x, pt.y, radius); }
0371e9a8 238
72cdf4c9 239 void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
a23fd0e1
VZ
240 { DoDrawEllipse(x, y, width, height); }
241 void DrawEllipse(const wxPoint& pt, const wxSize& sz)
242 { DoDrawEllipse(pt.x, pt.y, sz.x, sz.y); }
243 void DrawEllipse(const wxRect& rect)
244 { DoDrawEllipse(rect.x, rect.y, rect.width, rect.height); }
245
72cdf4c9 246 void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
a23fd0e1
VZ
247 { DoDrawIcon(icon, x, y); }
248 void DrawIcon(const wxIcon& icon, const wxPoint& pt)
249 { DoDrawIcon(icon, pt.x, pt.y); }
250
72cdf4c9
VZ
251 void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
252 bool useMask = FALSE)
a23fd0e1
VZ
253 { DoDrawBitmap(bmp, x, y, useMask); }
254 void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt,
255 bool useMask = FALSE)
256 { DoDrawBitmap(bmp, pt.x, pt.y, useMask); }
257
72cdf4c9 258 void DrawText(const wxString& text, wxCoord x, wxCoord y)
a23fd0e1
VZ
259 { DoDrawText(text, x, y); }
260 void DrawText(const wxString& text, const wxPoint& pt)
261 { DoDrawText(text, pt.x, pt.y); }
262
95724b1a
VZ
263 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle)
264 { DoDrawRotatedText(text, x, y, angle); }
265 void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle)
266 { DoDrawRotatedText(text, pt.x, pt.y, angle); }
267
1e6feb95
VZ
268 // this version puts both optional bitmap and the text into the given
269 // rectangle and aligns is as specified by alignment parameter; it also
270 // will emphasize the character with the given index if it is != -1 and
271 // return the bounding rectangle if required
272 virtual void DrawLabel(const wxString& text,
273 const wxBitmap& image,
274 const wxRect& rect,
275 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
276 int indexAccel = -1,
277 wxRect *rectBounding = NULL);
278
279 void DrawLabel(const wxString& text, const wxRect& rect,
280 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
281 int indexAccel = -1)
282 { DrawLabel(text, wxNullBitmap, rect, alignment, indexAccel); }
283
72cdf4c9
VZ
284 bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
285 wxDC *source, wxCoord xsrc, wxCoord ysrc,
0cbff120 286 int rop = wxCOPY, bool useMask = FALSE, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1)
a23fd0e1
VZ
287 {
288 return DoBlit(xdest, ydest, width, height,
0cbff120 289 source, xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask);
a23fd0e1
VZ
290 }
291 bool Blit(const wxPoint& destPt, const wxSize& sz,
292 wxDC *source, const wxPoint& srcPt,
0cbff120 293 int rop = wxCOPY, bool useMask = FALSE, const wxPoint& srcPtMask = wxPoint(-1, -1))
a23fd0e1
VZ
294 {
295 return DoBlit(destPt.x, destPt.y, sz.x, sz.y,
0cbff120 296 source, srcPt.x, srcPt.y, rop, useMask, srcPtMask.x, srcPtMask.y);
a23fd0e1
VZ
297 }
298
299#if wxUSE_SPLINES
72cdf4c9
VZ
300 // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?)
301 void DrawSpline(wxCoord x1, wxCoord y1,
302 wxCoord x2, wxCoord y2,
303 wxCoord x3, wxCoord y3);
bd5dd957 304 void DrawSpline(int n, wxPoint points[]);
a23fd0e1
VZ
305
306 void DrawSpline(wxList *points) { DoDrawSpline(points); }
307#endif // wxUSE_SPLINES
308
12bdd77c
JS
309 // Eventually we will have wxUSE_GENERIC_DRAWELLIPSE
310#ifdef __WXWINCE__
311 //! Generic method to draw ellipses, circles and arcs with current pen and brush.
312 /*! \param x Upper left corner of bounding box.
313 * \param y Upper left corner of bounding box.
314 * \param w Width of bounding box.
315 * \param h Height of bounding box.
316 * \param sa Starting angle of arc
317 * (counterclockwise, start at 3 o'clock, 360 is full circle).
318 * \param ea Ending angle of arc.
319 * \param angle Rotation angle, the Arc will be rotated after
320 * calculating begin and end.
321 */
322 void DrawEllipticArcRot( wxCoord x, wxCoord y,
323 wxCoord width, wxCoord height,
324 double sa = 0, double ea = 0, double angle = 0 )
325 { DoDrawEllipticArcRot( x, y, width, height, sa, ea, angle ); }
326
327 void DrawEllipticArcRot( const wxPoint& pt,
328 const wxSize& sz,
329 double sa = 0, double ea = 0, double angle = 0 )
330 { DoDrawEllipticArcRot( pt.x, pt.y, sz.x, sz.y, sa, ea, angle ); }
331
332 void DrawEllipticArcRot( const wxRect& rect,
333 double sa = 0, double ea = 0, double angle = 0 )
334 { DoDrawEllipticArcRot( rect.x, rect.y, rect.width, rect.height, sa, ea, angle ); }
335
336 virtual void DoDrawEllipticArcRot( wxCoord x, wxCoord y,
337 wxCoord w, wxCoord h,
338 double sa = 0, double ea = 0, double angle = 0 );
339
340 //! Rotates points around center.
341 /*! This is a quite straight method, it calculates in pixels
342 * and so it produces rounding errors.
343 * \param points The points inside will be rotated.
344 * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle).
345 * \param center Center of rotation.
346 */
347 void Rotate( wxList* points, double angle, wxPoint center = wxPoint() );
348
349 // used by DrawEllipticArcRot
350 // Careful: wxList gets filled with points you have to delete later.
351 void CalculateEllipticPoints( wxList* points,
352 wxCoord xStart, wxCoord yStart,
353 wxCoord w, wxCoord h,
354 double sa, double ea );
355#endif
356
a23fd0e1
VZ
357 // global DC operations
358 // --------------------
359
360 virtual void Clear() = 0;
361
af0bb3b1
VZ
362 virtual bool StartDoc(const wxString& WXUNUSED(message)) { return TRUE; }
363 virtual void EndDoc() { }
a23fd0e1 364
af0bb3b1
VZ
365 virtual void StartPage() { }
366 virtual void EndPage() { }
a23fd0e1
VZ
367
368 // set objects to use for drawing
369 // ------------------------------
370
371 virtual void SetFont(const wxFont& font) = 0;
372 virtual void SetPen(const wxPen& pen) = 0;
373 virtual void SetBrush(const wxBrush& brush) = 0;
374 virtual void SetBackground(const wxBrush& brush) = 0;
375 virtual void SetBackgroundMode(int mode) = 0;
d275c7eb 376#if wxUSE_PALETTE
a23fd0e1 377 virtual void SetPalette(const wxPalette& palette) = 0;
d275c7eb 378#endif // wxUSE_PALETTE
a23fd0e1
VZ
379
380 // clipping region
381 // ---------------
382
72cdf4c9 383 void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
a23fd0e1
VZ
384 { DoSetClippingRegion(x, y, width, height); }
385 void SetClippingRegion(const wxPoint& pt, const wxSize& sz)
386 { DoSetClippingRegion(pt.x, pt.y, sz.x, sz.y); }
387 void SetClippingRegion(const wxRect& rect)
388 { DoSetClippingRegion(rect.x, rect.y, rect.width, rect.height); }
389 void SetClippingRegion(const wxRegion& region)
390 { DoSetClippingRegionAsRegion(region); }
391
392 virtual void DestroyClippingRegion() = 0;
393
72cdf4c9 394 void GetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const
a23fd0e1
VZ
395 { DoGetClippingBox(x, y, w, h); }
396 void GetClippingBox(wxRect& rect) const
8fb3a512 397 {
ae500232
JS
398#if 1
399 DoGetClippingBox(&rect.x, &rect.y, &rect.width, &rect.height);
400#else
8fb3a512 401 // Necessary to use intermediate variables for 16-bit compilation
ae500232 402 // REMOVE ME if the above is OK for all current platforms
8fb3a512
JS
403 wxCoord x, y, w, h;
404 DoGetClippingBox(&x, &y, &w, &h);
405 rect.x = x; rect.y = y; rect.width = w; rect.height = h;
ae500232 406#endif
8fb3a512 407 }
a23fd0e1
VZ
408
409 // text extent
410 // -----------
411
72cdf4c9
VZ
412 virtual wxCoord GetCharHeight() const = 0;
413 virtual wxCoord GetCharWidth() const = 0;
cd9da200 414
1e6feb95 415 // only works for single line strings
72cdf4c9
VZ
416 void GetTextExtent(const wxString& string,
417 wxCoord *x, wxCoord *y,
418 wxCoord *descent = NULL,
419 wxCoord *externalLeading = NULL,
420 wxFont *theFont = NULL) const
421 { DoGetTextExtent(string, x, y, descent, externalLeading, theFont); }
a23fd0e1 422
1e6feb95
VZ
423 // works for single as well as multi-line strings
424 virtual void GetMultiLineTextExtent(const wxString& text,
425 wxCoord *width,
426 wxCoord *height,
427 wxCoord *heightLine = NULL,
428 wxFont *font = NULL);
429
a23fd0e1
VZ
430 // size and resolution
431 // -------------------
432
433 // in device units
434 void GetSize(int *width, int *height) const
435 { DoGetSize(width, height); }
436 wxSize GetSize() const
437 {
438 int w, h;
439 DoGetSize(&w, &h);
440
441 return wxSize(w, h);
442 }
443
444 // in mm
445 void GetSizeMM(int* width, int* height) const
446 { DoGetSizeMM(width, height); }
447 wxSize GetSizeMM() const
448 {
449 int w, h;
450 DoGetSizeMM(&w, &h);
451
452 return wxSize(w, h);
453 }
454
455 // coordinates conversions
456 // -----------------------
457
458 // This group of functions does actual conversion of the input, as you'd
459 // expect.
72cdf4c9
VZ
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;
a23fd0e1
VZ
468
469 // query DC capabilities
470 // ---------------------
471
472 virtual bool CanDrawBitmap() const = 0;
473 virtual bool CanGetTextExtent() const = 0;
474
475 // colour depth
476 virtual int GetDepth() const = 0;
477
478 // Resolution in Pixels per inch
479 virtual wxSize GetPPI() const = 0;
480
481 virtual bool Ok() const { return m_ok; }
482
483 // accessors
484 // ---------
485
486 // const...
f6bcfd97 487 int GetBackgroundMode() const { return m_backgroundMode; }
a23fd0e1
VZ
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; }
492 const wxColour& GetTextBackground() const { return m_textBackgroundColour; }
493 const wxColour& GetTextForeground() const { return m_textForegroundColour; }
494
495 // ... and non const
496 wxBrush& GetBackground() { return m_backgroundBrush; }
497 wxBrush& GetBrush() { return m_brush; }
498 wxFont& GetFont() { return m_font; }
499 wxPen& GetPen() { return m_pen; }
500 wxColour& GetTextBackground() { return m_textBackgroundColour; }
501 wxColour& GetTextForeground() { return m_textForegroundColour; }
502
503 virtual void SetTextForeground(const wxColour& colour)
504 { m_textForegroundColour = colour; }
505 virtual void SetTextBackground(const wxColour& colour)
506 { m_textBackgroundColour = colour; }
507
508 int GetMapMode() const { return m_mappingMode; }
509 virtual void SetMapMode(int mode) = 0;
510
511 virtual void GetUserScale(double *x, double *y) const
512 {
513 if ( x ) *x = m_userScaleX;
514 if ( y ) *y = m_userScaleY;
515 }
516 virtual void SetUserScale(double x, double y) = 0;
517
a23fd0e1
VZ
518 virtual void GetLogicalScale(double *x, double *y)
519 {
520 if ( x ) *x = m_logicalScaleX;
521 if ( y ) *y = m_logicalScaleY;
522 }
523 virtual void SetLogicalScale(double x, double y)
524 {
525 m_logicalScaleX = x;
526 m_logicalScaleY = y;
527 }
528
72cdf4c9 529 void GetLogicalOrigin(wxCoord *x, wxCoord *y) const
a23fd0e1
VZ
530 { DoGetLogicalOrigin(x, y); }
531 wxPoint GetLogicalOrigin() const
72cdf4c9
VZ
532 { wxCoord x, y; DoGetLogicalOrigin(&x, &y); return wxPoint(x, y); }
533 virtual void SetLogicalOrigin(wxCoord x, wxCoord y) = 0;
a23fd0e1 534
72cdf4c9 535 void GetDeviceOrigin(wxCoord *x, wxCoord *y) const
a23fd0e1
VZ
536 { DoGetDeviceOrigin(x, y); }
537 wxPoint GetDeviceOrigin() const
72cdf4c9
VZ
538 { wxCoord x, y; DoGetDeviceOrigin(&x, &y); return wxPoint(x, y); }
539 virtual void SetDeviceOrigin(wxCoord x, wxCoord y) = 0;
a23fd0e1
VZ
540
541 virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp) = 0;
542
543 int GetLogicalFunction() const { return m_logicalFunction; }
544 virtual void SetLogicalFunction(int function) = 0;
545
546 // Sometimes we need to override optimization, e.g. if other software is
547 // drawing onto our surface and we can't be sure of who's done what.
548 //
549 // FIXME: is this (still) used?
550 virtual void SetOptimization(bool WXUNUSED(opt)) { }
551 virtual bool GetOptimization() { return FALSE; }
552
553 // bounding box
554 // ------------
555
72cdf4c9 556 virtual void CalcBoundingBox(wxCoord x, wxCoord y)
a23fd0e1 557 {
f6bcfd97
BP
558 if ( m_isBBoxValid )
559 {
560 if ( x < m_minX ) m_minX = x;
561 if ( y < m_minY ) m_minY = y;
562 if ( x > m_maxX ) m_maxX = x;
563 if ( y > m_maxY ) m_maxY = y;
564 }
565 else
566 {
567 m_isBBoxValid = TRUE;
568
569 m_minX = x;
570 m_minY = y;
571 m_maxX = x;
572 m_maxY = y;
573 }
574 }
575
576 void ResetBoundingBox()
577 {
578 m_isBBoxValid = FALSE;
579
580 m_minX = m_maxX = m_minY = m_maxY = 0;
a23fd0e1
VZ
581 }
582
583 // Get the final bounding box of the PostScript or Metafile picture.
72cdf4c9
VZ
584 wxCoord MinX() const { return m_minX; }
585 wxCoord MaxX() const { return m_maxX; }
586 wxCoord MinY() const { return m_minY; }
587 wxCoord MaxY() const { return m_maxY; }
a23fd0e1
VZ
588
589 // misc old functions
590 // ------------------
591
72cdf4c9
VZ
592 // for compatibility with the old code when wxCoord was long everywhere
593#ifndef __WIN16__
594 void GetTextExtent(const wxString& string,
595 long *x, long *y,
596 long *descent = NULL,
597 long *externalLeading = NULL,
598 wxFont *theFont = NULL) const
599 {
600 wxCoord x2, y2, descent2, externalLeading2;
601 DoGetTextExtent(string, &x2, &y2,
602 &descent2, &externalLeading2,
603 theFont);
604 if ( x )
605 *x = x2;
606 if ( y )
607 *y = y2;
608 if ( descent )
609 *descent = descent2;
610 if ( externalLeading )
611 *externalLeading = externalLeading2;
612 }
613
614 void GetLogicalOrigin(long *x, long *y) const
615 {
616 wxCoord x2, y2;
617 DoGetLogicalOrigin(&x2, &y2);
618 if ( x )
619 *x = x2;
620 if ( y )
621 *y = y2;
622 }
623
624 void GetDeviceOrigin(long *x, long *y) const
625 {
626 wxCoord x2, y2;
627 DoGetDeviceOrigin(&x2, &y2);
628 if ( x )
629 *x = x2;
630 if ( y )
631 *y = y2;
632 }
1dd989e1 633 void GetClippingBox(long *x, long *y, long *w, long *h) const
cd9da200
VZ
634 {
635 wxCoord xx,yy,ww,hh;
636 DoGetClippingBox(&xx, &yy, &ww, &hh);
637 if (x) *x = xx;
638 if (y) *y = yy;
639 if (w) *w = ww;
640 if (h) *h = hh;
1dd989e1 641 }
72cdf4c9
VZ
642#endif // !Win16
643
a23fd0e1
VZ
644protected:
645 // the pure virtual functions which should be implemented by wxDC
387ebd3e 646 virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
a23fd0e1
VZ
647 int style = wxFLOOD_SURFACE) = 0;
648
72cdf4c9 649 virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const = 0;
a23fd0e1 650
72cdf4c9
VZ
651 virtual void DoDrawPoint(wxCoord x, wxCoord y) = 0;
652 virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) = 0;
a23fd0e1 653
72cdf4c9
VZ
654 virtual void DoDrawArc(wxCoord x1, wxCoord y1,
655 wxCoord x2, wxCoord y2,
656 wxCoord xc, wxCoord yc) = 0;
cd9da200
VZ
657 virtual void DoDrawCheckMark(wxCoord x, wxCoord y,
658 wxCoord width, wxCoord height);
72cdf4c9 659 virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
a23fd0e1
VZ
660 double sa, double ea) = 0;
661
72cdf4c9
VZ
662 virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) = 0;
663 virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
664 wxCoord width, wxCoord height,
a23fd0e1 665 double radius) = 0;
72cdf4c9
VZ
666 virtual void DoDrawEllipse(wxCoord x, wxCoord y,
667 wxCoord width, wxCoord height) = 0;
a23fd0e1 668
72cdf4c9 669 virtual void DoCrossHair(wxCoord x, wxCoord y) = 0;
a23fd0e1 670
72cdf4c9
VZ
671 virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) = 0;
672 virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
a23fd0e1
VZ
673 bool useMask = FALSE) = 0;
674
72cdf4c9 675 virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y) = 0;
95724b1a
VZ
676 virtual void DoDrawRotatedText(const wxString& text,
677 wxCoord x, wxCoord y, double angle) = 0;
a23fd0e1 678
72cdf4c9
VZ
679 virtual bool DoBlit(wxCoord xdest, wxCoord ydest,
680 wxCoord width, wxCoord height,
681 wxDC *source, wxCoord xsrc, wxCoord ysrc,
0cbff120 682 int rop = wxCOPY, bool useMask = FALSE, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1) = 0;
a23fd0e1
VZ
683
684 virtual void DoGetSize(int *width, int *height) const = 0;
685 virtual void DoGetSizeMM(int* width, int* height) const = 0;
686
687 virtual void DoDrawLines(int n, wxPoint points[],
72cdf4c9 688 wxCoord xoffset, wxCoord yoffset) = 0;
a23fd0e1 689 virtual void DoDrawPolygon(int n, wxPoint points[],
72cdf4c9 690 wxCoord xoffset, wxCoord yoffset,
a23fd0e1 691 int fillStyle = wxODDEVEN_RULE) = 0;
6e76b35d
VZ
692 virtual void DoDrawPolyPolygon(int n, int start[], wxPoint points[],
693 wxCoord xoffset, wxCoord yoffset,
694 int fillStyle);
a23fd0e1
VZ
695
696 virtual void DoSetClippingRegionAsRegion(const wxRegion& region) = 0;
72cdf4c9
VZ
697 virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
698 wxCoord width, wxCoord height) = 0;
b0e0d661
VZ
699
700 // FIXME are these functions really different?
72cdf4c9
VZ
701 virtual void DoGetClippingRegion(wxCoord *x, wxCoord *y,
702 wxCoord *w, wxCoord *h)
b0e0d661 703 { DoGetClippingBox(x, y, w, h); }
72cdf4c9
VZ
704 virtual void DoGetClippingBox(wxCoord *x, wxCoord *y,
705 wxCoord *w, wxCoord *h) const
a23fd0e1
VZ
706 {
707 if ( m_clipping )
708 {
709 if ( x ) *x = m_clipX1;
710 if ( y ) *y = m_clipY1;
711 if ( w ) *w = m_clipX2 - m_clipX1;
712 if ( h ) *h = m_clipY2 - m_clipY1;
713 }
714 else
715 {
716 *x = *y = *w = *h = 0;
717 }
718 }
719
72cdf4c9 720 virtual void DoGetLogicalOrigin(wxCoord *x, wxCoord *y) const
a23fd0e1
VZ
721 {
722 if ( x ) *x = m_logicalOriginX;
723 if ( y ) *y = m_logicalOriginY;
724 }
725
72cdf4c9 726 virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const
a23fd0e1
VZ
727 {
728 if ( x ) *x = m_deviceOriginX;
729 if ( y ) *y = m_deviceOriginY;
730 }
731
72cdf4c9
VZ
732 virtual void DoGetTextExtent(const wxString& string,
733 wxCoord *x, wxCoord *y,
734 wxCoord *descent = NULL,
735 wxCoord *externalLeading = NULL,
736 wxFont *theFont = NULL) const = 0;
737
64698f9a 738#if wxUSE_SPLINES
fe2e4366 739 virtual void DoDrawSpline(wxList *points);
64698f9a 740#endif
a23fd0e1
VZ
741
742protected:
743 // flags
744 bool m_colour:1;
745 bool m_ok:1;
746 bool m_clipping:1;
747 bool m_isInteractive:1;
f6bcfd97 748 bool m_isBBoxValid:1;
a23fd0e1
VZ
749
750 // coordinate system variables
751
752 // TODO short descriptions of what exactly they are would be nice...
753
72cdf4c9
VZ
754 wxCoord m_logicalOriginX, m_logicalOriginY;
755 wxCoord m_deviceOriginX, m_deviceOriginY;
a23fd0e1
VZ
756
757 double m_logicalScaleX, m_logicalScaleY;
758 double m_userScaleX, m_userScaleY;
759 double m_scaleX, m_scaleY;
760
761 // Used by SetAxisOrientation() to invert the axes
762 int m_signX, m_signY;
763
764 // bounding and clipping boxes
72cdf4c9
VZ
765 wxCoord m_minX, m_minY, m_maxX, m_maxY;
766 wxCoord m_clipX1, m_clipY1, m_clipX2, m_clipY2;
a23fd0e1
VZ
767
768 int m_logicalFunction;
769 int m_backgroundMode;
770 int m_mappingMode;
771
772 // GDI objects
773 wxPen m_pen;
774 wxBrush m_brush;
775 wxBrush m_backgroundBrush;
776 wxColour m_textForegroundColour;
777 wxColour m_textBackgroundColour;
778 wxFont m_font;
d275c7eb
VZ
779
780#if wxUSE_PALETTE
a23fd0e1 781 wxPalette m_palette;
b95edd47 782 bool m_hasCustomPalette;
d275c7eb 783#endif // wxUSE_PALETTE
a23fd0e1
VZ
784
785private:
ac84e37d 786 DECLARE_NO_COPY_CLASS(wxDCBase)
cd9da200 787 DECLARE_ABSTRACT_CLASS(wxDCBase)
a23fd0e1
VZ
788};
789
790// ----------------------------------------------------------------------------
791// now include the declaration of wxDC class
792// ----------------------------------------------------------------------------
793
2049ba38 794#if defined(__WXMSW__)
a23fd0e1 795 #include "wx/msw/dc.h"
2049ba38 796#elif defined(__WXMOTIF__)
a23fd0e1 797 #include "wx/motif/dc.h"
2049ba38 798#elif defined(__WXGTK__)
a23fd0e1 799 #include "wx/gtk/dc.h"
83df96d6
JS
800#elif defined(__WXX11__)
801 #include "wx/x11/dc.h"
1e6feb95
VZ
802#elif defined(__WXMGL__)
803 #include "wx/mgl/dc.h"
34138703 804#elif defined(__WXMAC__)
a23fd0e1 805 #include "wx/mac/dc.h"
f4515f98
DE
806#elif defined(__WXCOCOA__)
807 #include "wx/cocoa/dc.h"
1777b9bb
DW
808#elif defined(__WXPM__)
809 #include "wx/os2/dc.h"
c801d85f
KB
810#endif
811
1e6feb95
VZ
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// ----------------------------------------------------------------------------
816
817class WXDLLEXPORT wxDCTextColourChanger
818{
819public:
ba161d7e 820 wxDCTextColourChanger(wxDC& dc) : m_dc(dc), m_colFgOld() { }
1e6feb95
VZ
821
822 ~wxDCTextColourChanger()
823 {
824 if ( m_colFgOld.Ok() )
825 m_dc.SetTextForeground(m_colFgOld);
826 }
827
828 void Set(const wxColour& col)
829 {
830 if ( !m_colFgOld.Ok() )
831 m_colFgOld = m_dc.GetTextForeground();
832 m_dc.SetTextForeground(col);
833 }
834
835private:
836 wxDC& m_dc;
837
838 wxColour m_colFgOld;
fc7a2a60
VZ
839
840 DECLARE_NO_COPY_CLASS(wxDCTextColourChanger)
1e6feb95
VZ
841};
842
e26be42b
VZ
843// ----------------------------------------------------------------------------
844// another small helper class: sets the clipping region in its ctor and
845// destroys it in the dtor
846// ----------------------------------------------------------------------------
847
848class WXDLLEXPORT wxDCClipper
849{
850public:
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); }
855
856 ~wxDCClipper() { m_dc.DestroyClippingRegion(); }
857
858private:
859 wxDC& m_dc;
fc7a2a60
VZ
860
861 DECLARE_NO_COPY_CLASS(wxDCClipper)
e26be42b
VZ
862};
863
c801d85f 864#endif
34138703 865 // _WX_DC_H_BASE_