]> git.saurik.com Git - wxWidgets.git/blob - include/wx/dc.h
Don't set a normal cursor for the frame, set the NULL cursor, else
[wxWidgets.git] / include / wx / dc.h
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
12 #ifndef _WX_DC_H_BASE_
13 #define _WX_DC_H_BASE_
14
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 #include "wx/list.h" // we use wxList in inline functions
32
33 class WXDLLEXPORT wxDCBase;
34
35 class WXDLLEXPORT wxDrawObject
36 {
37 public:
38
39 wxDrawObject()
40 {
41 ResetBoundingBox();
42 }
43
44 virtual ~wxDrawObject() { }
45
46 virtual void Draw(wxDCBase&) const { }
47
48 virtual void CalcBoundingBox(wxCoord x, wxCoord y)
49 {
50 if ( m_isBBoxValid )
51 {
52 if ( x < m_minX ) m_minX = x;
53 if ( y < m_minY ) m_minY = y;
54 if ( x > m_maxX ) m_maxX = x;
55 if ( y > m_maxY ) m_maxY = y;
56 }
57 else
58 {
59 m_isBBoxValid = TRUE;
60
61 m_minX = x;
62 m_minY = y;
63 m_maxX = x;
64 m_maxY = y;
65 }
66 }
67
68 void ResetBoundingBox()
69 {
70 m_isBBoxValid = FALSE;
71
72 m_minX = m_maxX = m_minY = m_maxY = 0;
73 }
74
75 // Get the final bounding box of the PostScript or Metafile picture.
76
77 wxCoord MinX() const { return m_minX; }
78 wxCoord MaxX() const { return m_maxX; }
79 wxCoord MinY() const { return m_minY; }
80 wxCoord MaxY() const { return m_maxY; }
81
82 //to define the type of object for derived objects
83 virtual int GetType()=0;
84
85 protected:
86 //for boundingbox calculation
87 bool m_isBBoxValid:1;
88 //for boundingbox calculation
89 wxCoord m_minX, m_minY, m_maxX, m_maxY;
90 };
91
92 // ---------------------------------------------------------------------------
93 // global variables
94 // ---------------------------------------------------------------------------
95
96 WXDLLEXPORT_DATA(extern int) wxPageNumber;
97
98 // ---------------------------------------------------------------------------
99 // wxDC is the device context - object on which any drawing is done
100 // ---------------------------------------------------------------------------
101
102 class WXDLLEXPORT wxDCBase : public wxObject
103 {
104 public:
105 wxDCBase()
106 {
107 m_clipping = FALSE;
108 m_ok = TRUE;
109
110 ResetBoundingBox();
111
112 m_signX = m_signY = 1;
113
114 m_logicalOriginX = m_logicalOriginY =
115 m_deviceOriginX = m_deviceOriginY = 0;
116
117 m_logicalScaleX = m_logicalScaleY =
118 m_userScaleX = m_userScaleY =
119 m_scaleX = m_scaleY = 1.0;
120
121 m_logicalFunction = wxCOPY;
122
123 m_backgroundMode = wxTRANSPARENT;
124
125 m_mappingMode = wxMM_TEXT;
126
127 m_backgroundBrush = *wxTRANSPARENT_BRUSH;
128
129 m_textForegroundColour = *wxBLACK;
130 m_textBackgroundColour = *wxWHITE;
131
132 m_colour = wxColourDisplay();
133 }
134
135 ~wxDCBase() { }
136
137 virtual void BeginDrawing() { }
138 virtual void EndDrawing() { }
139
140 // graphic primitives
141 // ------------------
142
143 virtual void DrawObject(wxDrawObject* drawobject)
144 {
145 drawobject->Draw(*this);
146 CalcBoundingBox(drawobject->MinX(),drawobject->MinY());
147 CalcBoundingBox(drawobject->MaxX(),drawobject->MaxY());
148 }
149
150 void FloodFill(wxCoord x, wxCoord y, const wxColour& col,
151 int style = wxFLOOD_SURFACE)
152 { DoFloodFill(x, y, col, style); }
153 void FloodFill(const wxPoint& pt, const wxColour& col,
154 int style = wxFLOOD_SURFACE)
155 { DoFloodFill(pt.x, pt.y, col, style); }
156
157 bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const
158 { return DoGetPixel(x, y, col); }
159 bool GetPixel(const wxPoint& pt, wxColour *col) const
160 { return DoGetPixel(pt.x, pt.y, col); }
161
162 void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
163 { DoDrawLine(x1, y1, x2, y2); }
164 void DrawLine(const wxPoint& pt1, const wxPoint& pt2)
165 { DoDrawLine(pt1.x, pt1.y, pt2.x, pt2.y); }
166
167 void CrossHair(wxCoord x, wxCoord y)
168 { DoCrossHair(x, y); }
169 void CrossHair(const wxPoint& pt)
170 { DoCrossHair(pt.x, pt.y); }
171
172 void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
173 wxCoord xc, wxCoord yc)
174 { DoDrawArc(x1, y1, x2, y2, xc, yc); }
175 void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre)
176 { DoDrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y); }
177
178 void DrawCheckMark(wxCoord x, wxCoord y,
179 wxCoord width, wxCoord height)
180 { DoDrawCheckMark(x, y, width, height); }
181 void DrawCheckMark(const wxRect& rect)
182 { DoDrawCheckMark(rect.x, rect.y, rect.width, rect.height); }
183
184 void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
185 double sa, double ea)
186 { DoDrawEllipticArc(x, y, w, h, sa, ea); }
187 void DrawEllipticArc(const wxPoint& pt, const wxSize& sz,
188 double sa, double ea)
189 { DoDrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea); }
190
191 void DrawPoint(wxCoord x, wxCoord y)
192 { DoDrawPoint(x, y); }
193 void DrawPoint(const wxPoint& pt)
194 { DoDrawPoint(pt.x, pt.y); }
195
196 void DrawLines(int n, wxPoint points[],
197 wxCoord xoffset = 0, wxCoord yoffset = 0)
198 { DoDrawLines(n, points, xoffset, yoffset); }
199 void DrawLines(const wxList *list,
200 wxCoord xoffset = 0, wxCoord yoffset = 0);
201
202 void DrawPolygon(int n, wxPoint points[],
203 wxCoord xoffset = 0, wxCoord yoffset = 0,
204 int fillStyle = wxODDEVEN_RULE)
205 { DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); }
206
207 void DrawPolygon(const wxList *list,
208 wxCoord xoffset = 0, wxCoord yoffset = 0,
209 int fillStyle = wxODDEVEN_RULE);
210
211 void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
212 { DoDrawRectangle(x, y, width, height); }
213 void DrawRectangle(const wxPoint& pt, const wxSize& sz)
214 { DoDrawRectangle(pt.x, pt.y, sz.x, sz.y); }
215 void DrawRectangle(const wxRect& rect)
216 { DoDrawRectangle(rect.x, rect.y, rect.width, rect.height); }
217
218 void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height,
219 double radius)
220 { DoDrawRoundedRectangle(x, y, width, height, radius); }
221 void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz,
222 double radius)
223 { DoDrawRoundedRectangle(pt.x, pt.y, sz.x, sz.y, radius); }
224 void DrawRoundedRectangle(const wxRect& r, double radius)
225 { DoDrawRoundedRectangle(r.x, r.y, r.width, r.height, radius); }
226
227 void DrawCircle(wxCoord x, wxCoord y, wxCoord radius)
228 { DoDrawEllipse(x - radius, y - radius, 2*radius, 2*radius); }
229 void DrawCircle(const wxPoint& pt, wxCoord radius)
230 { DrawCircle(pt.x, pt.y, radius); }
231
232 void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
233 { DoDrawEllipse(x, y, width, height); }
234 void DrawEllipse(const wxPoint& pt, const wxSize& sz)
235 { DoDrawEllipse(pt.x, pt.y, sz.x, sz.y); }
236 void DrawEllipse(const wxRect& rect)
237 { DoDrawEllipse(rect.x, rect.y, rect.width, rect.height); }
238
239 void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
240 { DoDrawIcon(icon, x, y); }
241 void DrawIcon(const wxIcon& icon, const wxPoint& pt)
242 { DoDrawIcon(icon, pt.x, pt.y); }
243
244 void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
245 bool useMask = FALSE)
246 { DoDrawBitmap(bmp, x, y, useMask); }
247 void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt,
248 bool useMask = FALSE)
249 { DoDrawBitmap(bmp, pt.x, pt.y, useMask); }
250
251 void DrawText(const wxString& text, wxCoord x, wxCoord y)
252 { DoDrawText(text, x, y); }
253 void DrawText(const wxString& text, const wxPoint& pt)
254 { DoDrawText(text, pt.x, pt.y); }
255
256 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle)
257 { DoDrawRotatedText(text, x, y, angle); }
258 void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle)
259 { DoDrawRotatedText(text, pt.x, pt.y, angle); }
260
261 // this version puts both optional bitmap and the text into the given
262 // rectangle and aligns is as specified by alignment parameter; it also
263 // will emphasize the character with the given index if it is != -1 and
264 // return the bounding rectangle if required
265 virtual void DrawLabel(const wxString& text,
266 const wxBitmap& image,
267 const wxRect& rect,
268 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
269 int indexAccel = -1,
270 wxRect *rectBounding = NULL);
271
272 void DrawLabel(const wxString& text, const wxRect& rect,
273 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
274 int indexAccel = -1)
275 { DrawLabel(text, wxNullBitmap, rect, alignment, indexAccel); }
276
277 bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
278 wxDC *source, wxCoord xsrc, wxCoord ysrc,
279 int rop = wxCOPY, bool useMask = FALSE, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1)
280 {
281 return DoBlit(xdest, ydest, width, height,
282 source, xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask);
283 }
284 bool Blit(const wxPoint& destPt, const wxSize& sz,
285 wxDC *source, const wxPoint& srcPt,
286 int rop = wxCOPY, bool useMask = FALSE, const wxPoint& srcPtMask = wxPoint(-1, -1))
287 {
288 return DoBlit(destPt.x, destPt.y, sz.x, sz.y,
289 source, srcPt.x, srcPt.y, rop, useMask, srcPtMask.x, srcPtMask.y);
290 }
291
292 #if wxUSE_SPLINES
293 // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?)
294 void DrawSpline(wxCoord x1, wxCoord y1,
295 wxCoord x2, wxCoord y2,
296 wxCoord x3, wxCoord y3);
297 void DrawSpline(int n, wxPoint points[]);
298
299 void DrawSpline(wxList *points) { DoDrawSpline(points); }
300 #endif // wxUSE_SPLINES
301
302 // global DC operations
303 // --------------------
304
305 virtual void Clear() = 0;
306
307 virtual bool StartDoc(const wxString& WXUNUSED(message)) { return TRUE; }
308 virtual void EndDoc() { }
309
310 virtual void StartPage() { }
311 virtual void EndPage() { }
312
313 // set objects to use for drawing
314 // ------------------------------
315
316 virtual void SetFont(const wxFont& font) = 0;
317 virtual void SetPen(const wxPen& pen) = 0;
318 virtual void SetBrush(const wxBrush& brush) = 0;
319 virtual void SetBackground(const wxBrush& brush) = 0;
320 virtual void SetBackgroundMode(int mode) = 0;
321 #if wxUSE_PALETTE
322 virtual void SetPalette(const wxPalette& palette) = 0;
323 #endif // wxUSE_PALETTE
324
325 // clipping region
326 // ---------------
327
328 void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
329 { DoSetClippingRegion(x, y, width, height); }
330 void SetClippingRegion(const wxPoint& pt, const wxSize& sz)
331 { DoSetClippingRegion(pt.x, pt.y, sz.x, sz.y); }
332 void SetClippingRegion(const wxRect& rect)
333 { DoSetClippingRegion(rect.x, rect.y, rect.width, rect.height); }
334 void SetClippingRegion(const wxRegion& region)
335 { DoSetClippingRegionAsRegion(region); }
336
337 virtual void DestroyClippingRegion() = 0;
338
339 void GetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const
340 { DoGetClippingBox(x, y, w, h); }
341 void GetClippingBox(wxRect& rect) const
342 {
343 // Necessary to use intermediate variables for 16-bit compilation
344 wxCoord x, y, w, h;
345 DoGetClippingBox(&x, &y, &w, &h);
346 rect.x = x; rect.y = y; rect.width = w; rect.height = h;
347 }
348
349 // text extent
350 // -----------
351
352 virtual wxCoord GetCharHeight() const = 0;
353 virtual wxCoord GetCharWidth() const = 0;
354
355 // only works for single line strings
356 void GetTextExtent(const wxString& string,
357 wxCoord *x, wxCoord *y,
358 wxCoord *descent = NULL,
359 wxCoord *externalLeading = NULL,
360 wxFont *theFont = NULL) const
361 { DoGetTextExtent(string, x, y, descent, externalLeading, theFont); }
362
363 // works for single as well as multi-line strings
364 virtual void GetMultiLineTextExtent(const wxString& text,
365 wxCoord *width,
366 wxCoord *height,
367 wxCoord *heightLine = NULL,
368 wxFont *font = NULL);
369
370 // size and resolution
371 // -------------------
372
373 // in device units
374 void GetSize(int *width, int *height) const
375 { DoGetSize(width, height); }
376 wxSize GetSize() const
377 {
378 int w, h;
379 DoGetSize(&w, &h);
380
381 return wxSize(w, h);
382 }
383
384 // in mm
385 void GetSizeMM(int* width, int* height) const
386 { DoGetSizeMM(width, height); }
387 wxSize GetSizeMM() const
388 {
389 int w, h;
390 DoGetSizeMM(&w, &h);
391
392 return wxSize(w, h);
393 }
394
395 // coordinates conversions
396 // -----------------------
397
398 // This group of functions does actual conversion of the input, as you'd
399 // expect.
400 wxCoord DeviceToLogicalX(wxCoord x) const;
401 wxCoord DeviceToLogicalY(wxCoord y) const;
402 wxCoord DeviceToLogicalXRel(wxCoord x) const;
403 wxCoord DeviceToLogicalYRel(wxCoord y) const;
404 wxCoord LogicalToDeviceX(wxCoord x) const;
405 wxCoord LogicalToDeviceY(wxCoord y) const;
406 wxCoord LogicalToDeviceXRel(wxCoord x) const;
407 wxCoord LogicalToDeviceYRel(wxCoord y) const;
408
409 // query DC capabilities
410 // ---------------------
411
412 virtual bool CanDrawBitmap() const = 0;
413 virtual bool CanGetTextExtent() const = 0;
414
415 // colour depth
416 virtual int GetDepth() const = 0;
417
418 // Resolution in Pixels per inch
419 virtual wxSize GetPPI() const = 0;
420
421 virtual bool Ok() const { return m_ok; }
422
423 // accessors
424 // ---------
425
426 // const...
427 int GetBackgroundMode() const { return m_backgroundMode; }
428 const wxBrush& GetBackground() const { return m_backgroundBrush; }
429 const wxBrush& GetBrush() const { return m_brush; }
430 const wxFont& GetFont() const { return m_font; }
431 const wxPen& GetPen() const { return m_pen; }
432 const wxColour& GetTextBackground() const { return m_textBackgroundColour; }
433 const wxColour& GetTextForeground() const { return m_textForegroundColour; }
434
435 // ... and non const
436 wxBrush& GetBackground() { return m_backgroundBrush; }
437 wxBrush& GetBrush() { return m_brush; }
438 wxFont& GetFont() { return m_font; }
439 wxPen& GetPen() { return m_pen; }
440 wxColour& GetTextBackground() { return m_textBackgroundColour; }
441 wxColour& GetTextForeground() { return m_textForegroundColour; }
442
443 virtual void SetTextForeground(const wxColour& colour)
444 { m_textForegroundColour = colour; }
445 virtual void SetTextBackground(const wxColour& colour)
446 { m_textBackgroundColour = colour; }
447
448 int GetMapMode() const { return m_mappingMode; }
449 virtual void SetMapMode(int mode) = 0;
450
451 virtual void GetUserScale(double *x, double *y) const
452 {
453 if ( x ) *x = m_userScaleX;
454 if ( y ) *y = m_userScaleY;
455 }
456 virtual void SetUserScale(double x, double y) = 0;
457
458 virtual void GetLogicalScale(double *x, double *y)
459 {
460 if ( x ) *x = m_logicalScaleX;
461 if ( y ) *y = m_logicalScaleY;
462 }
463 virtual void SetLogicalScale(double x, double y)
464 {
465 m_logicalScaleX = x;
466 m_logicalScaleY = y;
467 }
468
469 void GetLogicalOrigin(wxCoord *x, wxCoord *y) const
470 { DoGetLogicalOrigin(x, y); }
471 wxPoint GetLogicalOrigin() const
472 { wxCoord x, y; DoGetLogicalOrigin(&x, &y); return wxPoint(x, y); }
473 virtual void SetLogicalOrigin(wxCoord x, wxCoord y) = 0;
474
475 void GetDeviceOrigin(wxCoord *x, wxCoord *y) const
476 { DoGetDeviceOrigin(x, y); }
477 wxPoint GetDeviceOrigin() const
478 { wxCoord x, y; DoGetDeviceOrigin(&x, &y); return wxPoint(x, y); }
479 virtual void SetDeviceOrigin(wxCoord x, wxCoord y) = 0;
480
481 virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp) = 0;
482
483 int GetLogicalFunction() const { return m_logicalFunction; }
484 virtual void SetLogicalFunction(int function) = 0;
485
486 // Sometimes we need to override optimization, e.g. if other software is
487 // drawing onto our surface and we can't be sure of who's done what.
488 //
489 // FIXME: is this (still) used?
490 virtual void SetOptimization(bool WXUNUSED(opt)) { }
491 virtual bool GetOptimization() { return FALSE; }
492
493 // Some platforms have a DC cache, which should be cleared
494 // at appropriate points such as after a series of DC operations.
495 // Put ClearCache in the wxDC implementation class, since it has to be
496 // static.
497 // static void ClearCache() ;
498 #if 0 // wxUSE_DC_CACHEING
499 static void EnableCache(bool cacheing) { sm_cacheing = cacheing; }
500 static bool CacheEnabled() { return sm_cacheing ; }
501 #endif
502
503 // bounding box
504 // ------------
505
506 virtual void CalcBoundingBox(wxCoord x, wxCoord y)
507 {
508 if ( m_isBBoxValid )
509 {
510 if ( x < m_minX ) m_minX = x;
511 if ( y < m_minY ) m_minY = y;
512 if ( x > m_maxX ) m_maxX = x;
513 if ( y > m_maxY ) m_maxY = y;
514 }
515 else
516 {
517 m_isBBoxValid = TRUE;
518
519 m_minX = x;
520 m_minY = y;
521 m_maxX = x;
522 m_maxY = y;
523 }
524 }
525
526 void ResetBoundingBox()
527 {
528 m_isBBoxValid = FALSE;
529
530 m_minX = m_maxX = m_minY = m_maxY = 0;
531 }
532
533 // Get the final bounding box of the PostScript or Metafile picture.
534 wxCoord MinX() const { return m_minX; }
535 wxCoord MaxX() const { return m_maxX; }
536 wxCoord MinY() const { return m_minY; }
537 wxCoord MaxY() const { return m_maxY; }
538
539 // misc old functions
540 // ------------------
541
542 // for compatibility with the old code when wxCoord was long everywhere
543 #ifndef __WIN16__
544 void GetTextExtent(const wxString& string,
545 long *x, long *y,
546 long *descent = NULL,
547 long *externalLeading = NULL,
548 wxFont *theFont = NULL) const
549 {
550 wxCoord x2, y2, descent2, externalLeading2;
551 DoGetTextExtent(string, &x2, &y2,
552 &descent2, &externalLeading2,
553 theFont);
554 if ( x )
555 *x = x2;
556 if ( y )
557 *y = y2;
558 if ( descent )
559 *descent = descent2;
560 if ( externalLeading )
561 *externalLeading = externalLeading2;
562 }
563
564 void GetLogicalOrigin(long *x, long *y) const
565 {
566 wxCoord x2, y2;
567 DoGetLogicalOrigin(&x2, &y2);
568 if ( x )
569 *x = x2;
570 if ( y )
571 *y = y2;
572 }
573
574 void GetDeviceOrigin(long *x, long *y) const
575 {
576 wxCoord x2, y2;
577 DoGetDeviceOrigin(&x2, &y2);
578 if ( x )
579 *x = x2;
580 if ( y )
581 *y = y2;
582 }
583 void GetClippingBox(long *x, long *y, long *w, long *h) const
584 {
585 wxCoord xx,yy,ww,hh;
586 DoGetClippingBox(&xx, &yy, &ww, &hh);
587 if (x) *x = xx;
588 if (y) *y = yy;
589 if (w) *w = ww;
590 if (h) *h = hh;
591 }
592 #endif // !Win16
593
594 #if WXWIN_COMPATIBILITY
595
596 #if wxUSE_PALETTE
597 virtual void SetColourMap(const wxPalette& palette) { SetPalette(palette); }
598 #endif // wxUSE_PALETTE
599
600 void GetTextExtent(const wxString& string, float *x, float *y,
601 float *descent = NULL, float *externalLeading = NULL,
602 wxFont *theFont = NULL, bool use16bit = FALSE) const ;
603 void GetSize(float* width, float* height) const { int w, h; GetSize(& w, & h); *width = w; *height = h; }
604 void GetSizeMM(float *width, float *height) const { long w, h; GetSizeMM(& w, & h); *width = (float) w; *height = (float) h; }
605
606 #endif // WXWIN_COMPATIBILITY
607
608 protected:
609 // the pure virtual functions which should be implemented by wxDC
610 virtual void DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
611 int style = wxFLOOD_SURFACE) = 0;
612
613 virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const = 0;
614
615 virtual void DoDrawPoint(wxCoord x, wxCoord y) = 0;
616 virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) = 0;
617
618 virtual void DoDrawArc(wxCoord x1, wxCoord y1,
619 wxCoord x2, wxCoord y2,
620 wxCoord xc, wxCoord yc) = 0;
621 virtual void DoDrawCheckMark(wxCoord x, wxCoord y,
622 wxCoord width, wxCoord height);
623 virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
624 double sa, double ea) = 0;
625
626 virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) = 0;
627 virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
628 wxCoord width, wxCoord height,
629 double radius) = 0;
630 virtual void DoDrawEllipse(wxCoord x, wxCoord y,
631 wxCoord width, wxCoord height) = 0;
632
633 virtual void DoCrossHair(wxCoord x, wxCoord y) = 0;
634
635 virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) = 0;
636 virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
637 bool useMask = FALSE) = 0;
638
639 virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y) = 0;
640 virtual void DoDrawRotatedText(const wxString& text,
641 wxCoord x, wxCoord y, double angle) = 0;
642
643 virtual bool DoBlit(wxCoord xdest, wxCoord ydest,
644 wxCoord width, wxCoord height,
645 wxDC *source, wxCoord xsrc, wxCoord ysrc,
646 int rop = wxCOPY, bool useMask = FALSE, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1) = 0;
647
648 virtual void DoGetSize(int *width, int *height) const = 0;
649 virtual void DoGetSizeMM(int* width, int* height) const = 0;
650
651 virtual void DoDrawLines(int n, wxPoint points[],
652 wxCoord xoffset, wxCoord yoffset) = 0;
653 virtual void DoDrawPolygon(int n, wxPoint points[],
654 wxCoord xoffset, wxCoord yoffset,
655 int fillStyle = wxODDEVEN_RULE) = 0;
656
657 virtual void DoSetClippingRegionAsRegion(const wxRegion& region) = 0;
658 virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
659 wxCoord width, wxCoord height) = 0;
660
661 // FIXME are these functions really different?
662 virtual void DoGetClippingRegion(wxCoord *x, wxCoord *y,
663 wxCoord *w, wxCoord *h)
664 { DoGetClippingBox(x, y, w, h); }
665 virtual void DoGetClippingBox(wxCoord *x, wxCoord *y,
666 wxCoord *w, wxCoord *h) const
667 {
668 if ( m_clipping )
669 {
670 if ( x ) *x = m_clipX1;
671 if ( y ) *y = m_clipY1;
672 if ( w ) *w = m_clipX2 - m_clipX1;
673 if ( h ) *h = m_clipY2 - m_clipY1;
674 }
675 else
676 {
677 *x = *y = *w = *h = 0;
678 }
679 }
680
681 virtual void DoGetLogicalOrigin(wxCoord *x, wxCoord *y) const
682 {
683 if ( x ) *x = m_logicalOriginX;
684 if ( y ) *y = m_logicalOriginY;
685 }
686
687 virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const
688 {
689 if ( x ) *x = m_deviceOriginX;
690 if ( y ) *y = m_deviceOriginY;
691 }
692
693 virtual void DoGetTextExtent(const wxString& string,
694 wxCoord *x, wxCoord *y,
695 wxCoord *descent = NULL,
696 wxCoord *externalLeading = NULL,
697 wxFont *theFont = NULL) const = 0;
698
699 #if wxUSE_SPLINES
700 virtual void DoDrawSpline(wxList *points);
701 #endif
702
703 protected:
704 // flags
705 bool m_colour:1;
706 bool m_ok:1;
707 bool m_clipping:1;
708 bool m_isInteractive:1;
709 bool m_isBBoxValid:1;
710 #if wxUSE_DC_CACHEING
711 // static bool sm_cacheing;
712 #endif
713
714 // coordinate system variables
715
716 // TODO short descriptions of what exactly they are would be nice...
717
718 wxCoord m_logicalOriginX, m_logicalOriginY;
719 wxCoord m_deviceOriginX, m_deviceOriginY;
720
721 double m_logicalScaleX, m_logicalScaleY;
722 double m_userScaleX, m_userScaleY;
723 double m_scaleX, m_scaleY;
724
725 // Used by SetAxisOrientation() to invert the axes
726 int m_signX, m_signY;
727
728 // bounding and clipping boxes
729 wxCoord m_minX, m_minY, m_maxX, m_maxY;
730 wxCoord m_clipX1, m_clipY1, m_clipX2, m_clipY2;
731
732 int m_logicalFunction;
733 int m_backgroundMode;
734 int m_mappingMode;
735
736 // GDI objects
737 wxPen m_pen;
738 wxBrush m_brush;
739 wxBrush m_backgroundBrush;
740 wxColour m_textForegroundColour;
741 wxColour m_textBackgroundColour;
742 wxFont m_font;
743
744 #if wxUSE_PALETTE
745 wxPalette m_palette;
746 bool m_hasCustomPalette;
747 #endif // wxUSE_PALETTE
748
749 private:
750 DECLARE_NO_COPY_CLASS(wxDCBase)
751 DECLARE_ABSTRACT_CLASS(wxDCBase)
752 };
753
754 // ----------------------------------------------------------------------------
755 // now include the declaration of wxDC class
756 // ----------------------------------------------------------------------------
757
758 #if defined(__WXMSW__)
759 #include "wx/msw/dc.h"
760 #elif defined(__WXMOTIF__)
761 #include "wx/motif/dc.h"
762 #elif defined(__WXGTK__)
763 #include "wx/gtk/dc.h"
764 #elif defined(__WXX11__)
765 #include "wx/x11/dc.h"
766 #elif defined(__WXMGL__)
767 #include "wx/mgl/dc.h"
768 #elif defined(__WXMAC__)
769 #include "wx/mac/dc.h"
770 #elif defined(__WXPM__)
771 #include "wx/os2/dc.h"
772 #elif defined(__WXSTUBS__)
773 #include "wx/stubs/dc.h"
774 #endif
775
776 // ----------------------------------------------------------------------------
777 // helper class: you can use it to temporarily change the DC text colour and
778 // restore it automatically when the object goes out of scope
779 // ----------------------------------------------------------------------------
780
781 class WXDLLEXPORT wxDCTextColourChanger
782 {
783 public:
784 wxDCTextColourChanger(wxDC& dc) : m_dc(dc) { }
785
786 ~wxDCTextColourChanger()
787 {
788 if ( m_colFgOld.Ok() )
789 m_dc.SetTextForeground(m_colFgOld);
790 }
791
792 void Set(const wxColour& col)
793 {
794 if ( !m_colFgOld.Ok() )
795 m_colFgOld = m_dc.GetTextForeground();
796 m_dc.SetTextForeground(col);
797 }
798
799 private:
800 wxDC& m_dc;
801
802 wxColour m_colFgOld;
803 };
804
805 // ----------------------------------------------------------------------------
806 // another small helper class: sets the clipping region in its ctor and
807 // destroys it in the dtor
808 // ----------------------------------------------------------------------------
809
810 class WXDLLEXPORT wxDCClipper
811 {
812 public:
813 wxDCClipper(wxDC& dc, const wxRect& r) : m_dc(dc)
814 { dc.SetClippingRegion(r.x, r.y, r.width, r.height); }
815 wxDCClipper(wxDC& dc, wxCoord x, wxCoord y, wxCoord w, wxCoord h) : m_dc(dc)
816 { dc.SetClippingRegion(x, y, w, h); }
817
818 ~wxDCClipper() { m_dc.DestroyClippingRegion(); }
819
820 private:
821 wxDC& m_dc;
822 };
823
824 #endif
825 // _WX_DC_H_BASE_