]> git.saurik.com Git - wxWidgets.git/blame - include/wx/dc.h
fix for assert failure when deleting tree ctrl in-place edit window (sometimes)
[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
a23fd0e1
VZ
15#ifdef __GNUG__
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"
31
32#include "wx/list.h" // we use wxList in inline functions
33
aec43716
KH
34class WXDLLEXPORT wxDCBase;
35
36class WXDLLEXPORT wxDrawObject
37{
38public:
39
40 wxDrawObject()
41 {
42 ResetBoundingBox();
43 }
44
45 virtual ~wxDrawObject() { }
46
fc4e7a03 47 virtual void Draw(wxDCBase& dc) 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()
107 {
108 m_clipping = FALSE;
109 m_ok = TRUE;
110
f6bcfd97 111 ResetBoundingBox();
a23fd0e1
VZ
112
113 m_signX = m_signY = 1;
114
115 m_logicalOriginX = m_logicalOriginY =
116 m_deviceOriginX = m_deviceOriginY = 0;
117
118 m_logicalScaleX = m_logicalScaleY =
220af862 119 m_userScaleX = m_userScaleY =
a23fd0e1
VZ
120 m_scaleX = m_scaleY = 1.0;
121
78066fbf 122 m_logicalFunction = wxCOPY;
a23fd0e1
VZ
123
124 m_backgroundMode = wxTRANSPARENT;
125
126 m_mappingMode = wxMM_TEXT;
127
af0bb3b1 128 m_backgroundBrush = *wxTRANSPARENT_BRUSH;
a23fd0e1
VZ
129
130 m_textForegroundColour = *wxBLACK;
131 m_textBackgroundColour = *wxWHITE;
132
133 m_colour = wxColourDisplay();
134 }
135
136 ~wxDCBase() { }
137
138 virtual void BeginDrawing() { }
139 virtual void EndDrawing() { }
140
141 // graphic primitives
142 // ------------------
143
aec43716
KH
144 virtual void DrawObject(wxDrawObject* drawobject)
145 {
146 drawobject->Draw(*this);
147 CalcBoundingBox(drawobject->MinX(),drawobject->MinY());
148 CalcBoundingBox(drawobject->MaxX(),drawobject->MaxY());
149 }
150
72cdf4c9
VZ
151 void FloodFill(wxCoord x, wxCoord y, const wxColour& col,
152 int style = wxFLOOD_SURFACE)
a23fd0e1
VZ
153 { DoFloodFill(x, y, col, style); }
154 void FloodFill(const wxPoint& pt, const wxColour& col,
72cdf4c9 155 int style = wxFLOOD_SURFACE)
a23fd0e1
VZ
156 { DoFloodFill(pt.x, pt.y, col, style); }
157
72cdf4c9 158 bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const
a23fd0e1
VZ
159 { return DoGetPixel(x, y, col); }
160 bool GetPixel(const wxPoint& pt, wxColour *col) const
161 { return DoGetPixel(pt.x, pt.y, col); }
162
72cdf4c9 163 void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
a23fd0e1
VZ
164 { DoDrawLine(x1, y1, x2, y2); }
165 void DrawLine(const wxPoint& pt1, const wxPoint& pt2)
166 { DoDrawLine(pt1.x, pt1.y, pt2.x, pt2.y); }
167
72cdf4c9 168 void CrossHair(wxCoord x, wxCoord y)
a23fd0e1
VZ
169 { DoCrossHair(x, y); }
170 void CrossHair(const wxPoint& pt)
171 { DoCrossHair(pt.x, pt.y); }
172
72cdf4c9
VZ
173 void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
174 wxCoord xc, wxCoord yc)
a23fd0e1
VZ
175 { DoDrawArc(x1, y1, x2, y2, xc, yc); }
176 void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre)
177 { DoDrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y); }
178
cd9da200
VZ
179 void DrawCheckMark(wxCoord x, wxCoord y,
180 wxCoord width, wxCoord height)
181 { DoDrawCheckMark(x, y, width, height); }
182 void DrawCheckMark(const wxRect& rect)
183 { DoDrawCheckMark(rect.x, rect.y, rect.width, rect.height); }
184
72cdf4c9
VZ
185 void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
186 double sa, double ea)
7b90a8f2 187 { DoDrawEllipticArc(x, y, w, h, sa, ea); }
a23fd0e1
VZ
188 void DrawEllipticArc(const wxPoint& pt, const wxSize& sz,
189 double sa, double ea)
190 { DoDrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea); }
191
72cdf4c9 192 void DrawPoint(wxCoord x, wxCoord y)
a23fd0e1
VZ
193 { DoDrawPoint(x, y); }
194 void DrawPoint(const wxPoint& pt)
195 { DoDrawPoint(pt.x, pt.y); }
196
72cdf4c9
VZ
197 void DrawLines(int n, wxPoint points[],
198 wxCoord xoffset = 0, wxCoord yoffset = 0)
a23fd0e1 199 { DoDrawLines(n, points, xoffset, yoffset); }
72cdf4c9
VZ
200 void DrawLines(const wxList *list,
201 wxCoord xoffset = 0, wxCoord yoffset = 0);
a23fd0e1
VZ
202
203 void DrawPolygon(int n, wxPoint points[],
72cdf4c9 204 wxCoord xoffset = 0, wxCoord yoffset = 0,
a23fd0e1
VZ
205 int fillStyle = wxODDEVEN_RULE)
206 { DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); }
207
208 void DrawPolygon(const wxList *list,
72cdf4c9 209 wxCoord xoffset = 0, wxCoord yoffset = 0,
bd5dd957 210 int fillStyle = wxODDEVEN_RULE);
a23fd0e1 211
72cdf4c9 212 void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
a23fd0e1
VZ
213 { DoDrawRectangle(x, y, width, height); }
214 void DrawRectangle(const wxPoint& pt, const wxSize& sz)
215 { DoDrawRectangle(pt.x, pt.y, sz.x, sz.y); }
216 void DrawRectangle(const wxRect& rect)
217 { DoDrawRectangle(rect.x, rect.y, rect.width, rect.height); }
218
72cdf4c9 219 void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height,
a23fd0e1
VZ
220 double radius)
221 { DoDrawRoundedRectangle(x, y, width, height, radius); }
222 void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz,
223 double radius)
224 { DoDrawRoundedRectangle(pt.x, pt.y, sz.x, sz.y, radius); }
225 void DrawRoundedRectangle(const wxRect& r, double radius)
226 { DoDrawRoundedRectangle(r.x, r.y, r.width, r.height, radius); }
227
72cdf4c9 228 void DrawCircle(wxCoord x, wxCoord y, wxCoord radius)
220af862 229 { DoDrawEllipse(x - radius, y - radius, 2*radius, 2*radius); }
72cdf4c9 230 void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
a23fd0e1
VZ
231 { DoDrawEllipse(x, y, width, height); }
232 void DrawEllipse(const wxPoint& pt, const wxSize& sz)
233 { DoDrawEllipse(pt.x, pt.y, sz.x, sz.y); }
234 void DrawEllipse(const wxRect& rect)
235 { DoDrawEllipse(rect.x, rect.y, rect.width, rect.height); }
236
72cdf4c9 237 void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
a23fd0e1
VZ
238 { DoDrawIcon(icon, x, y); }
239 void DrawIcon(const wxIcon& icon, const wxPoint& pt)
240 { DoDrawIcon(icon, pt.x, pt.y); }
241
72cdf4c9
VZ
242 void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
243 bool useMask = FALSE)
a23fd0e1
VZ
244 { DoDrawBitmap(bmp, x, y, useMask); }
245 void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt,
246 bool useMask = FALSE)
247 { DoDrawBitmap(bmp, pt.x, pt.y, useMask); }
248
72cdf4c9 249 void DrawText(const wxString& text, wxCoord x, wxCoord y)
a23fd0e1
VZ
250 { DoDrawText(text, x, y); }
251 void DrawText(const wxString& text, const wxPoint& pt)
252 { DoDrawText(text, pt.x, pt.y); }
253
95724b1a
VZ
254 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle)
255 { DoDrawRotatedText(text, x, y, angle); }
256 void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle)
257 { DoDrawRotatedText(text, pt.x, pt.y, angle); }
258
72cdf4c9
VZ
259 bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
260 wxDC *source, wxCoord xsrc, wxCoord ysrc,
a23fd0e1
VZ
261 int rop = wxCOPY, bool useMask = FALSE)
262 {
263 return DoBlit(xdest, ydest, width, height,
264 source, xsrc, ysrc, rop, useMask);
265 }
266 bool Blit(const wxPoint& destPt, const wxSize& sz,
267 wxDC *source, const wxPoint& srcPt,
268 int rop = wxCOPY, bool useMask = FALSE)
269 {
270 return DoBlit(destPt.x, destPt.y, sz.x, sz.y,
271 source, srcPt.x, srcPt.y, rop, useMask);
272 }
273
274#if wxUSE_SPLINES
72cdf4c9
VZ
275 // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?)
276 void DrawSpline(wxCoord x1, wxCoord y1,
277 wxCoord x2, wxCoord y2,
278 wxCoord x3, wxCoord y3);
bd5dd957 279 void DrawSpline(int n, wxPoint points[]);
a23fd0e1
VZ
280
281 void DrawSpline(wxList *points) { DoDrawSpline(points); }
282#endif // wxUSE_SPLINES
283
284 // global DC operations
285 // --------------------
286
287 virtual void Clear() = 0;
288
af0bb3b1
VZ
289 virtual bool StartDoc(const wxString& WXUNUSED(message)) { return TRUE; }
290 virtual void EndDoc() { }
a23fd0e1 291
af0bb3b1
VZ
292 virtual void StartPage() { }
293 virtual void EndPage() { }
a23fd0e1
VZ
294
295 // set objects to use for drawing
296 // ------------------------------
297
298 virtual void SetFont(const wxFont& font) = 0;
299 virtual void SetPen(const wxPen& pen) = 0;
300 virtual void SetBrush(const wxBrush& brush) = 0;
301 virtual void SetBackground(const wxBrush& brush) = 0;
302 virtual void SetBackgroundMode(int mode) = 0;
303 virtual void SetPalette(const wxPalette& palette) = 0;
304
305 // clipping region
306 // ---------------
307
72cdf4c9 308 void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
a23fd0e1
VZ
309 { DoSetClippingRegion(x, y, width, height); }
310 void SetClippingRegion(const wxPoint& pt, const wxSize& sz)
311 { DoSetClippingRegion(pt.x, pt.y, sz.x, sz.y); }
312 void SetClippingRegion(const wxRect& rect)
313 { DoSetClippingRegion(rect.x, rect.y, rect.width, rect.height); }
314 void SetClippingRegion(const wxRegion& region)
315 { DoSetClippingRegionAsRegion(region); }
316
317 virtual void DestroyClippingRegion() = 0;
318
72cdf4c9 319 void GetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const
a23fd0e1
VZ
320 { DoGetClippingBox(x, y, w, h); }
321 void GetClippingBox(wxRect& rect) const
8fb3a512
JS
322 {
323 // Necessary to use intermediate variables for 16-bit compilation
324 wxCoord x, y, w, h;
325 DoGetClippingBox(&x, &y, &w, &h);
326 rect.x = x; rect.y = y; rect.width = w; rect.height = h;
327 }
a23fd0e1
VZ
328
329 // text extent
330 // -----------
331
72cdf4c9
VZ
332 virtual wxCoord GetCharHeight() const = 0;
333 virtual wxCoord GetCharWidth() const = 0;
cd9da200 334
72cdf4c9
VZ
335 void GetTextExtent(const wxString& string,
336 wxCoord *x, wxCoord *y,
337 wxCoord *descent = NULL,
338 wxCoord *externalLeading = NULL,
339 wxFont *theFont = NULL) const
340 { DoGetTextExtent(string, x, y, descent, externalLeading, theFont); }
a23fd0e1
VZ
341
342 // size and resolution
343 // -------------------
344
345 // in device units
346 void GetSize(int *width, int *height) const
347 { DoGetSize(width, height); }
348 wxSize GetSize() const
349 {
350 int w, h;
351 DoGetSize(&w, &h);
352
353 return wxSize(w, h);
354 }
355
356 // in mm
357 void GetSizeMM(int* width, int* height) const
358 { DoGetSizeMM(width, height); }
359 wxSize GetSizeMM() const
360 {
361 int w, h;
362 DoGetSizeMM(&w, &h);
363
364 return wxSize(w, h);
365 }
366
367 // coordinates conversions
368 // -----------------------
369
370 // This group of functions does actual conversion of the input, as you'd
371 // expect.
72cdf4c9
VZ
372 wxCoord DeviceToLogicalX(wxCoord x) const;
373 wxCoord DeviceToLogicalY(wxCoord y) const;
374 wxCoord DeviceToLogicalXRel(wxCoord x) const;
375 wxCoord DeviceToLogicalYRel(wxCoord y) const;
376 wxCoord LogicalToDeviceX(wxCoord x) const;
377 wxCoord LogicalToDeviceY(wxCoord y) const;
378 wxCoord LogicalToDeviceXRel(wxCoord x) const;
379 wxCoord LogicalToDeviceYRel(wxCoord y) const;
a23fd0e1
VZ
380
381 // query DC capabilities
382 // ---------------------
383
384 virtual bool CanDrawBitmap() const = 0;
385 virtual bool CanGetTextExtent() const = 0;
386
387 // colour depth
388 virtual int GetDepth() const = 0;
389
390 // Resolution in Pixels per inch
391 virtual wxSize GetPPI() const = 0;
392
393 virtual bool Ok() const { return m_ok; }
394
395 // accessors
396 // ---------
397
398 // const...
f6bcfd97 399 int GetBackgroundMode() const { return m_backgroundMode; }
a23fd0e1
VZ
400 const wxBrush& GetBackground() const { return m_backgroundBrush; }
401 const wxBrush& GetBrush() const { return m_brush; }
402 const wxFont& GetFont() const { return m_font; }
403 const wxPen& GetPen() const { return m_pen; }
404 const wxColour& GetTextBackground() const { return m_textBackgroundColour; }
405 const wxColour& GetTextForeground() const { return m_textForegroundColour; }
406
407 // ... and non const
408 wxBrush& GetBackground() { return m_backgroundBrush; }
409 wxBrush& GetBrush() { return m_brush; }
410 wxFont& GetFont() { return m_font; }
411 wxPen& GetPen() { return m_pen; }
412 wxColour& GetTextBackground() { return m_textBackgroundColour; }
413 wxColour& GetTextForeground() { return m_textForegroundColour; }
414
415 virtual void SetTextForeground(const wxColour& colour)
416 { m_textForegroundColour = colour; }
417 virtual void SetTextBackground(const wxColour& colour)
418 { m_textBackgroundColour = colour; }
419
420 int GetMapMode() const { return m_mappingMode; }
421 virtual void SetMapMode(int mode) = 0;
422
423 virtual void GetUserScale(double *x, double *y) const
424 {
425 if ( x ) *x = m_userScaleX;
426 if ( y ) *y = m_userScaleY;
427 }
428 virtual void SetUserScale(double x, double y) = 0;
429
a23fd0e1
VZ
430 virtual void GetLogicalScale(double *x, double *y)
431 {
432 if ( x ) *x = m_logicalScaleX;
433 if ( y ) *y = m_logicalScaleY;
434 }
435 virtual void SetLogicalScale(double x, double y)
436 {
437 m_logicalScaleX = x;
438 m_logicalScaleY = y;
439 }
440
72cdf4c9 441 void GetLogicalOrigin(wxCoord *x, wxCoord *y) const
a23fd0e1
VZ
442 { DoGetLogicalOrigin(x, y); }
443 wxPoint GetLogicalOrigin() const
72cdf4c9
VZ
444 { wxCoord x, y; DoGetLogicalOrigin(&x, &y); return wxPoint(x, y); }
445 virtual void SetLogicalOrigin(wxCoord x, wxCoord y) = 0;
a23fd0e1 446
72cdf4c9 447 void GetDeviceOrigin(wxCoord *x, wxCoord *y) const
a23fd0e1
VZ
448 { DoGetDeviceOrigin(x, y); }
449 wxPoint GetDeviceOrigin() const
72cdf4c9
VZ
450 { wxCoord x, y; DoGetDeviceOrigin(&x, &y); return wxPoint(x, y); }
451 virtual void SetDeviceOrigin(wxCoord x, wxCoord y) = 0;
a23fd0e1
VZ
452
453 virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp) = 0;
454
455 int GetLogicalFunction() const { return m_logicalFunction; }
456 virtual void SetLogicalFunction(int function) = 0;
457
458 // Sometimes we need to override optimization, e.g. if other software is
459 // drawing onto our surface and we can't be sure of who's done what.
460 //
461 // FIXME: is this (still) used?
462 virtual void SetOptimization(bool WXUNUSED(opt)) { }
463 virtual bool GetOptimization() { return FALSE; }
464
465 // bounding box
466 // ------------
467
72cdf4c9 468 virtual void CalcBoundingBox(wxCoord x, wxCoord y)
a23fd0e1 469 {
f6bcfd97
BP
470 if ( m_isBBoxValid )
471 {
472 if ( x < m_minX ) m_minX = x;
473 if ( y < m_minY ) m_minY = y;
474 if ( x > m_maxX ) m_maxX = x;
475 if ( y > m_maxY ) m_maxY = y;
476 }
477 else
478 {
479 m_isBBoxValid = TRUE;
480
481 m_minX = x;
482 m_minY = y;
483 m_maxX = x;
484 m_maxY = y;
485 }
486 }
487
488 void ResetBoundingBox()
489 {
490 m_isBBoxValid = FALSE;
491
492 m_minX = m_maxX = m_minY = m_maxY = 0;
a23fd0e1
VZ
493 }
494
495 // Get the final bounding box of the PostScript or Metafile picture.
72cdf4c9
VZ
496 wxCoord MinX() const { return m_minX; }
497 wxCoord MaxX() const { return m_maxX; }
498 wxCoord MinY() const { return m_minY; }
499 wxCoord MaxY() const { return m_maxY; }
a23fd0e1
VZ
500
501 // misc old functions
502 // ------------------
503
72cdf4c9
VZ
504 // for compatibility with the old code when wxCoord was long everywhere
505#ifndef __WIN16__
506 void GetTextExtent(const wxString& string,
507 long *x, long *y,
508 long *descent = NULL,
509 long *externalLeading = NULL,
510 wxFont *theFont = NULL) const
511 {
512 wxCoord x2, y2, descent2, externalLeading2;
513 DoGetTextExtent(string, &x2, &y2,
514 &descent2, &externalLeading2,
515 theFont);
516 if ( x )
517 *x = x2;
518 if ( y )
519 *y = y2;
520 if ( descent )
521 *descent = descent2;
522 if ( externalLeading )
523 *externalLeading = externalLeading2;
524 }
525
526 void GetLogicalOrigin(long *x, long *y) const
527 {
528 wxCoord x2, y2;
529 DoGetLogicalOrigin(&x2, &y2);
530 if ( x )
531 *x = x2;
532 if ( y )
533 *y = y2;
534 }
535
536 void GetDeviceOrigin(long *x, long *y) const
537 {
538 wxCoord x2, y2;
539 DoGetDeviceOrigin(&x2, &y2);
540 if ( x )
541 *x = x2;
542 if ( y )
543 *y = y2;
544 }
1dd989e1 545 void GetClippingBox(long *x, long *y, long *w, long *h) const
cd9da200
VZ
546 {
547 wxCoord xx,yy,ww,hh;
548 DoGetClippingBox(&xx, &yy, &ww, &hh);
549 if (x) *x = xx;
550 if (y) *y = yy;
551 if (w) *w = ww;
552 if (h) *h = hh;
1dd989e1 553 }
72cdf4c9
VZ
554#endif // !Win16
555
a23fd0e1
VZ
556#if WXWIN_COMPATIBILITY
557 virtual void SetColourMap(const wxPalette& palette) { SetPalette(palette); }
558 void GetTextExtent(const wxString& string, float *x, float *y,
559 float *descent = NULL, float *externalLeading = NULL,
560 wxFont *theFont = NULL, bool use16bit = FALSE) const ;
561 void GetSize(float* width, float* height) const { int w, h; GetSize(& w, & h); *width = w; *height = h; }
562 void GetSizeMM(float *width, float *height) const { long w, h; GetSizeMM(& w, & h); *width = (float) w; *height = (float) h; }
563#endif // WXWIN_COMPATIBILITY
564
565protected:
566 // the pure virtual functions which should be implemented by wxDC
72cdf4c9 567 virtual void DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
a23fd0e1
VZ
568 int style = wxFLOOD_SURFACE) = 0;
569
72cdf4c9 570 virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const = 0;
a23fd0e1 571
72cdf4c9
VZ
572 virtual void DoDrawPoint(wxCoord x, wxCoord y) = 0;
573 virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) = 0;
a23fd0e1 574
72cdf4c9
VZ
575 virtual void DoDrawArc(wxCoord x1, wxCoord y1,
576 wxCoord x2, wxCoord y2,
577 wxCoord xc, wxCoord yc) = 0;
cd9da200
VZ
578 virtual void DoDrawCheckMark(wxCoord x, wxCoord y,
579 wxCoord width, wxCoord height);
72cdf4c9 580 virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
a23fd0e1
VZ
581 double sa, double ea) = 0;
582
72cdf4c9
VZ
583 virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) = 0;
584 virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
585 wxCoord width, wxCoord height,
a23fd0e1 586 double radius) = 0;
72cdf4c9
VZ
587 virtual void DoDrawEllipse(wxCoord x, wxCoord y,
588 wxCoord width, wxCoord height) = 0;
a23fd0e1 589
72cdf4c9 590 virtual void DoCrossHair(wxCoord x, wxCoord y) = 0;
a23fd0e1 591
72cdf4c9
VZ
592 virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) = 0;
593 virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
a23fd0e1
VZ
594 bool useMask = FALSE) = 0;
595
72cdf4c9 596 virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y) = 0;
95724b1a
VZ
597 virtual void DoDrawRotatedText(const wxString& text,
598 wxCoord x, wxCoord y, double angle) = 0;
a23fd0e1 599
72cdf4c9
VZ
600 virtual bool DoBlit(wxCoord xdest, wxCoord ydest,
601 wxCoord width, wxCoord height,
602 wxDC *source, wxCoord xsrc, wxCoord ysrc,
a23fd0e1
VZ
603 int rop = wxCOPY, bool useMask = FALSE) = 0;
604
605 virtual void DoGetSize(int *width, int *height) const = 0;
606 virtual void DoGetSizeMM(int* width, int* height) const = 0;
607
608 virtual void DoDrawLines(int n, wxPoint points[],
72cdf4c9 609 wxCoord xoffset, wxCoord yoffset) = 0;
a23fd0e1 610 virtual void DoDrawPolygon(int n, wxPoint points[],
72cdf4c9 611 wxCoord xoffset, wxCoord yoffset,
a23fd0e1
VZ
612 int fillStyle = wxODDEVEN_RULE) = 0;
613
614 virtual void DoSetClippingRegionAsRegion(const wxRegion& region) = 0;
72cdf4c9
VZ
615 virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
616 wxCoord width, wxCoord height) = 0;
b0e0d661
VZ
617
618 // FIXME are these functions really different?
72cdf4c9
VZ
619 virtual void DoGetClippingRegion(wxCoord *x, wxCoord *y,
620 wxCoord *w, wxCoord *h)
b0e0d661 621 { DoGetClippingBox(x, y, w, h); }
72cdf4c9
VZ
622 virtual void DoGetClippingBox(wxCoord *x, wxCoord *y,
623 wxCoord *w, wxCoord *h) const
a23fd0e1
VZ
624 {
625 if ( m_clipping )
626 {
627 if ( x ) *x = m_clipX1;
628 if ( y ) *y = m_clipY1;
629 if ( w ) *w = m_clipX2 - m_clipX1;
630 if ( h ) *h = m_clipY2 - m_clipY1;
631 }
632 else
633 {
634 *x = *y = *w = *h = 0;
635 }
636 }
637
72cdf4c9 638 virtual void DoGetLogicalOrigin(wxCoord *x, wxCoord *y) const
a23fd0e1
VZ
639 {
640 if ( x ) *x = m_logicalOriginX;
641 if ( y ) *y = m_logicalOriginY;
642 }
643
72cdf4c9 644 virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const
a23fd0e1
VZ
645 {
646 if ( x ) *x = m_deviceOriginX;
647 if ( y ) *y = m_deviceOriginY;
648 }
649
72cdf4c9
VZ
650 virtual void DoGetTextExtent(const wxString& string,
651 wxCoord *x, wxCoord *y,
652 wxCoord *descent = NULL,
653 wxCoord *externalLeading = NULL,
654 wxFont *theFont = NULL) const = 0;
655
64698f9a 656#if wxUSE_SPLINES
a23fd0e1 657 virtual void DoDrawSpline(wxList *points) = 0;
64698f9a 658#endif
a23fd0e1
VZ
659
660protected:
661 // flags
662 bool m_colour:1;
663 bool m_ok:1;
664 bool m_clipping:1;
665 bool m_isInteractive:1;
f6bcfd97 666 bool m_isBBoxValid:1;
a23fd0e1
VZ
667
668 // coordinate system variables
669
670 // TODO short descriptions of what exactly they are would be nice...
671
72cdf4c9
VZ
672 wxCoord m_logicalOriginX, m_logicalOriginY;
673 wxCoord m_deviceOriginX, m_deviceOriginY;
a23fd0e1
VZ
674
675 double m_logicalScaleX, m_logicalScaleY;
676 double m_userScaleX, m_userScaleY;
677 double m_scaleX, m_scaleY;
678
679 // Used by SetAxisOrientation() to invert the axes
680 int m_signX, m_signY;
681
682 // bounding and clipping boxes
72cdf4c9
VZ
683 wxCoord m_minX, m_minY, m_maxX, m_maxY;
684 wxCoord m_clipX1, m_clipY1, m_clipX2, m_clipY2;
a23fd0e1
VZ
685
686 int m_logicalFunction;
687 int m_backgroundMode;
688 int m_mappingMode;
689
690 // GDI objects
691 wxPen m_pen;
692 wxBrush m_brush;
693 wxBrush m_backgroundBrush;
694 wxColour m_textForegroundColour;
695 wxColour m_textBackgroundColour;
696 wxFont m_font;
697 wxPalette m_palette;
698
699private:
700 DECLARE_NO_COPY_CLASS(wxDCBase);
cd9da200 701 DECLARE_ABSTRACT_CLASS(wxDCBase)
a23fd0e1
VZ
702};
703
704// ----------------------------------------------------------------------------
705// now include the declaration of wxDC class
706// ----------------------------------------------------------------------------
707
2049ba38 708#if defined(__WXMSW__)
a23fd0e1 709 #include "wx/msw/dc.h"
2049ba38 710#elif defined(__WXMOTIF__)
a23fd0e1 711 #include "wx/motif/dc.h"
2049ba38 712#elif defined(__WXGTK__)
a23fd0e1 713 #include "wx/gtk/dc.h"
b4e76e0d 714#elif defined(__WXQT__)
a23fd0e1 715 #include "wx/qt/dc.h"
34138703 716#elif defined(__WXMAC__)
a23fd0e1 717 #include "wx/mac/dc.h"
1777b9bb
DW
718#elif defined(__WXPM__)
719 #include "wx/os2/dc.h"
34138703 720#elif defined(__WXSTUBS__)
a23fd0e1 721 #include "wx/stubs/dc.h"
c801d85f
KB
722#endif
723
724#endif
34138703 725 // _WX_DC_H_BASE_