Putting draft of wxImplDC and the wxDC using it
[wxWidgets.git] / include / wx / gtk / dc.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/dc.h
3 // Purpose:
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifndef __GTKDCH__
11 #define __GTKDCH__
12
13 #if 0
14
15 //-----------------------------------------------------------------------------
16 // wxImplDC
17 //-----------------------------------------------------------------------------
18
19 class WXDLLIMPEXP_CORE wxImplDC: public wxObject
20 {
21 public:
22 wxImplDC( wxDC *owner );
23 ~wxImplDC();
24
25 wxDC *GetOwner() { return m_owner; }
26
27 virtual bool IsOk() const { return m_ok; }
28
29 // query capabilities
30
31 virtual bool CanDrawBitmap() const = 0;
32 virtual bool CanGetTextExtent() const = 0;
33
34 // query dimension, colour deps, resolution
35
36 virtual void DoGetSize(int *width, int *height) const = 0;
37 virtual void DoGetSizeMM(int* width, int* height) const = 0;
38
39 virtual int GetDepth() const = 0;
40 virtual wxSize GetPPI() const = 0;
41
42 // Right-To-Left (RTL) modes
43
44 virtual void SetLayoutDirection(wxLayoutDirection WXUNUSED(dir)) { }
45 virtual wxLayoutDirection GetLayoutDirection() const { return wxLayout_Default; }
46
47 // page and document
48
49 virtual bool StartDoc(const wxString& WXUNUSED(message)) { return true; }
50 virtual void EndDoc() { }
51
52 virtual void StartPage() { }
53 virtual void EndPage() { }
54
55 // bounding box
56
57 virtual void CalcBoundingBox(wxCoord x, wxCoord y);
58 {
59 if ( m_isBBoxValid )
60 {
61 if ( x < m_minX ) m_minX = x;
62 if ( y < m_minY ) m_minY = y;
63 if ( x > m_maxX ) m_maxX = x;
64 if ( y > m_maxY ) m_maxY = y;
65 }
66 else
67 {
68 m_isBBoxValid = true;
69
70 m_minX = x;
71 m_minY = y;
72 m_maxX = x;
73 m_maxY = y;
74 }
75 }
76 void ResetBoundingBox();
77 {
78 m_isBBoxValid = false;
79
80 m_minX = m_maxX = m_minY = m_maxY = 0;
81 }
82
83 wxCoord MinX() const { return m_minX; }
84 wxCoord MaxX() const { return m_maxX; }
85 wxCoord MinY() const { return m_minY; }
86 wxCoord MaxY() const { return m_maxY; }
87
88 // setters and getters
89
90 virtual void SetFont(const wxFont& font) = 0;
91 virtual const wxFont& GetFont() const { return m_font; }
92
93 virtual void SetPen(const wxPen& pen) = 0;
94 virtual const wxPen& GetPen() const { return m_pen; }
95
96 virtual void SetBrush(const wxBrush& brush) = 0;
97 virtual const wxBrush& GetBrush() const { return m_brush; }
98
99 virtual void SetBackground(const wxBrush& brush) = 0;
100 virtual const wxBrush& GetBackground() const { return m_backgroundBrush; }
101
102 virtual void SetBackgroundMode(int mode) = 0;
103 virtual int GetBackgroundMode() const { return m_backgroundMode; }
104
105 virtual void SetTextForeground(const wxColour& colour)
106 { m_textForegroundColour = colour; }
107 virtual const wxColour& GetTextForeground() const { return m_textForegroundColour; }
108
109 virtual void SetTextBackground(const wxColour& colour)
110 { m_textBackgroundColour = colour; }
111 virtual const wxColour& GetTextBackground() const { return m_textBackgroundColour; }
112
113 #if wxUSE_PALETTE
114 virtual void SetPalette(const wxPalette& palette) = 0;
115 #endif // wxUSE_PALETTE
116
117 // logical functions
118
119 virtual void SetLogicalFunction(int function) = 0;
120 virtual int GetLogicalFunction() const { return m_logicalFunction; }
121
122 // text measurement
123
124 virtual wxCoord GetCharHeight() const = 0;
125 virtual wxCoord GetCharWidth() const = 0;
126 virtual void DoGetTextExtent(const wxString& string,
127 wxCoord *x, wxCoord *y,
128 wxCoord *descent = NULL,
129 wxCoord *externalLeading = NULL,
130 const wxFont *theFont = NULL) const = 0;
131 virtual void GetMultiLineTextExtent(const wxString& string,
132 wxCoord *width,
133 wxCoord *height,
134 wxCoord *heightLine = NULL,
135 const wxFont *font = NULL) const;
136 virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
137
138 // clearing
139
140 virtual void Clear() = 0;
141
142 // clipping
143
144 virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
145 wxCoord width, wxCoord height) = 0;
146 virtual void DoSetClippingRegionAsRegion(const wxRegion& region) = 0;
147
148 virtual void DoGetClippingBox(wxCoord *x, wxCoord *y,
149 wxCoord *w, wxCoord *h) const
150 {
151 if ( x )
152 *x = m_clipX1;
153 if ( y )
154 *y = m_clipY1;
155 if ( w )
156 *w = m_clipX2 - m_clipX1;
157 if ( h )
158 *h = m_clipY2 - m_clipY1;
159 }
160
161 virtual void DestroyClippingRegion() { ResetClipping(); }
162
163
164 // coordinates conversions and transforms
165
166 virtual wxCoord DeviceToLogicalX(wxCoord x) const;
167 virtual wxCoord DeviceToLogicalY(wxCoord y) const;
168 virtual wxCoord DeviceToLogicalXRel(wxCoord x) const;
169 virtual wxCoord DeviceToLogicalYRel(wxCoord y) const;
170 virtual wxCoord LogicalToDeviceX(wxCoord x) const;
171 virtual wxCoord LogicalToDeviceY(wxCoord y) const;
172 virtual wxCoord LogicalToDeviceXRel(wxCoord x) const;
173 virtual wxCoord LogicalToDeviceYRel(wxCoord y) const;
174
175 virtual void SetMapMode(int mode);
176 virtual int GetMapMode() const { return m_mappingMode; }
177
178 virtual void SetUserScale(double x, double y);
179 virtual void GetUserScale(double *x, double *y) const
180 {
181 if ( x ) *x = m_userScaleX;
182 if ( y ) *y = m_userScaleY;
183 }
184
185 virtual void SetLogicalScale(double x, double y);
186 virtual void GetLogicalScale(double *x, double *y)
187 {
188 if ( x ) *x = m_logicalScaleX;
189 if ( y ) *y = m_logicalScaleY;
190 }
191
192 virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
193 virtual void DoGetLogicalOrigin(wxCoord *x, wxCoord *y) const
194 {
195 if ( x ) *x = m_logicalOriginX;
196 if ( y ) *y = m_logicalOriginY;
197 }
198
199 virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
200 virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const
201 {
202 if ( x ) *x = m_deviceOriginX;
203 if ( y ) *y = m_deviceOriginY;
204 }
205
206 virtual void SetDeviceLocalOrigin( wxCoord x, wxCoord y );
207
208 virtual void ComputeScaleAndOrigin();
209
210 // this needs to overidden if the axis is inverted
211 virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
212
213 // ---------------------------------------------------------
214 // the actual drawing API
215
216 virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
217 int style = wxFLOOD_SURFACE) = 0;
218
219 virtual void DoGradientFillLinear(const wxRect& rect,
220 const wxColour& initialColour,
221 const wxColour& destColour,
222 wxDirection nDirection = wxEAST);
223
224 virtual void DoGradientFillConcentric(const wxRect& rect,
225 const wxColour& initialColour,
226 const wxColour& destColour,
227 const wxPoint& circleCenter);
228
229 virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const = 0;
230
231 virtual void DoDrawPoint(wxCoord x, wxCoord y) = 0;
232 virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) = 0;
233
234 virtual void DoDrawArc(wxCoord x1, wxCoord y1,
235 wxCoord x2, wxCoord y2,
236 wxCoord xc, wxCoord yc) = 0;
237 virtual void DoDrawCheckMark(wxCoord x, wxCoord y,
238 wxCoord width, wxCoord height);
239 virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
240 double sa, double ea) = 0;
241
242 virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) = 0;
243 virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
244 wxCoord width, wxCoord height,
245 double radius) = 0;
246 virtual void DoDrawEllipse(wxCoord x, wxCoord y,
247 wxCoord width, wxCoord height) = 0;
248
249 virtual void DoCrossHair(wxCoord x, wxCoord y) = 0;
250
251 virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) = 0;
252 virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
253 bool useMask = false) = 0;
254
255 virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y) = 0;
256 virtual void DoDrawRotatedText(const wxString& text,
257 wxCoord x, wxCoord y, double angle) = 0;
258
259 virtual bool DoBlit(wxCoord xdest, wxCoord ydest,
260 wxCoord width, wxCoord height,
261 wxDC *source,
262 wxCoord xsrc, wxCoord ysrc,
263 int rop = wxCOPY,
264 bool useMask = false,
265 wxCoord xsrcMask = wxDefaultCoord,
266 wxCoord ysrcMask = wxDefaultCoord) = 0;
267
268 virtual bool DoStretchBlit(wxCoord xdest, wxCoord ydest,
269 wxCoord dstWidth, wxCoord dstHeight,
270 wxDC *source,
271 wxCoord xsrc, wxCoord ysrc,
272 wxCoord srcWidth, wxCoord srcHeight,
273 int rop = wxCOPY,
274 bool useMask = false,
275 wxCoord xsrcMask = wxDefaultCoord,
276 wxCoord ysrcMask = wxDefaultCoord);
277
278 virtual wxBitmap DoGetAsBitmap(const wxRect *WXUNUSED(subrect)) const
279 { return wxNullBitmap; }
280
281
282 virtual void DoDrawLines(int n, wxPoint points[],
283 wxCoord xoffset, wxCoord yoffset) = 0;
284 virtual void DoDrawPolygon(int n, wxPoint points[],
285 wxCoord xoffset, wxCoord yoffset,
286 int fillStyle = wxODDEVEN_RULE) = 0;
287 virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[],
288 wxCoord xoffset, wxCoord yoffset,
289 int fillStyle);
290
291
292
293 #if wxUSE_SPLINES
294 virtual void DoDrawSpline(wxList *points);
295 #endif
296
297 private:
298 wxDC *m_owner;
299
300 protected:
301 // unset clipping variables (after clipping region was destroyed)
302 void ResetClipping()
303 {
304 m_clipping = false;
305
306 m_clipX1 = m_clipX2 = m_clipY1 = m_clipY2 = 0;
307 }
308
309 // flags
310 bool m_colour:1;
311 bool m_ok:1;
312 bool m_clipping:1;
313 bool m_isInteractive:1;
314 bool m_isBBoxValid:1;
315
316 // coordinate system variables
317
318 wxCoord m_logicalOriginX, m_logicalOriginY;
319 wxCoord m_deviceOriginX, m_deviceOriginY; // Usually 0,0, can be change by user
320
321 wxCoord m_deviceLocalOriginX, m_deviceLocalOriginY; // non-zero if native top-left corner
322 // is not at 0,0. This was the case under
323 // Mac's GrafPorts (coordinate system
324 // used toplevel window's origin) and
325 // e.g. for Postscript, where the native
326 // origin in the bottom left corner.
327 double m_logicalScaleX, m_logicalScaleY;
328 double m_userScaleX, m_userScaleY;
329 double m_scaleX, m_scaleY; // calculated from logical scale and user scale
330
331 int m_signX, m_signY; // Used by SetAxisOrientation() to invert the axes
332
333 // what is a mm on a screen you don't know the size of?
334 double m_mm_to_pix_x,
335 m_mm_to_pix_y;
336
337 // bounding and clipping boxes
338 wxCoord m_minX, m_minY, m_maxX, m_maxY;
339 wxCoord m_clipX1, m_clipY1, m_clipX2, m_clipY2;
340
341 int m_logicalFunction;
342 int m_backgroundMode;
343 int m_mappingMode;
344
345 wxPen m_pen;
346 wxBrush m_brush;
347 wxBrush m_backgroundBrush;
348 wxColour m_textForegroundColour;
349 wxColour m_textBackgroundColour;
350 wxFont m_font;
351
352 #if wxUSE_PALETTE
353 wxPalette m_palette;
354 bool m_hasCustomPalette;
355 #endif // wxUSE_PALETTE
356
357 private:
358 DECLARE_ABSTRACT_CLASS(wxImplDC)
359 }
360
361
362 class wxDC: public wxObject
363 {
364 public:
365 wxDC() { m_pimpl = NULL; }
366
367 bool IsOk() const
368 { return m_pimpl && m_pimpl->IsOk(); }
369
370 // query capabilities
371
372 bool CanDrawBitmap() const
373 { return m_pimpl->CanDrawBitmap(); }
374 bool CanGetTextExtent() const
375 { return m_pimpl->CanGetTextExtent(); }
376
377 // query dimension, colour deps, resolution
378
379 void GetSize(int *width, int *height) const
380 { m_pimpl->DoGetSize(width, height); }
381
382 wxSize GetSize() const
383 {
384 int w, h;
385 m_pimpl->DoGetSize(&w, &h);
386 return wxSize(w, h);
387 }
388
389 void GetSizeMM(int* width, int* height) const
390 { m_pimpl->DoGetSizeMM(width, height); }
391 wxSize GetSizeMM() const
392 {
393 int w, h;
394 m_pimpl->DoGetSizeMM(&w, &h);
395 return wxSize(w, h);
396 }
397
398 int GetDepth() const
399 { return m_pimpl->GetDepth(); }
400 wxSize GetPPI() const
401 { return m_pimpl->GetPPI(); }
402
403 // Right-To-Left (RTL) modes
404
405 void SetLayoutDirection(wxLayoutDirection dir)
406 { m_pimpl->SetLayoutDirection( dir ); }
407 wxLayoutDirection GetLayoutDirection() const
408 { return m_pimpl->GetLayoutDirection(); }
409
410 // page and document
411
412 bool StartDoc(const wxString& message)
413 { return m_pimpl->StartDoc(message); }
414 void EndDoc()
415 { m_pimpl->EndDoc(); }
416
417 void StartPage()
418 { m_pimpl->StartPage(); }
419 void EndPage()
420 { m_pimpl->EndPage(); }
421
422 // bounding box
423
424 void CalcBoundingBox(wxCoord x, wxCoord y)
425 { m_pimpl->CalcBoundingBox(x,y); }
426 void ResetBoundingBox()
427 { m_pimpl->ResetBoundingBox(); }
428
429 wxCoord MinX() const
430 { return m_pimpl->MinX(); }
431 wxCoord MaxX() const
432 { return m_pimpl->MaxX(); }
433 wxCoord MinY() const
434 { return m_pimpl->MinY(); }
435 wxCoord MaxY() const
436 { return m_pimpl->MaxY(); }
437
438 // setters and getters
439
440 void SetFont(const wxFont& font)
441 { m_pimpl->SetFont( font ); }
442 const wxFont& GetFont() const
443 { return m_pimpl->GetFont(); }
444
445 void SetPen(const wxPen& pen)
446 { m_pimpl->SetPen( pen ); }
447 const wxPen& GetPen() const
448 { return m_pimpl->GetPen(); }
449
450 void SetBrush(const wxBrush& brush)
451 { m_pimpl->SetBrush( brush ); }
452 const wxBrush& GetBrush() const
453 { return m_pimpl->GetBrush(); }
454
455 void SetBackground(const wxBrush& brush)
456 { m_pimpl->SetBackground( brush ); }
457 const wxBrush& GetBackground() const
458 { return m_pimpl->GetBackground(); }
459
460 void SetBackgroundMode(int mode)
461 { m_pimpl->SetBackground( mode ); }
462 int GetBackgroundMode() const
463 { return m_pimpl->GetBackground(); }
464
465 void SetTextForeground(const wxColour& colour)
466 { m_pimpl->SetTextForeground(colour); }
467 const wxColour& GetTextForeground() const
468 { return m_pimpl->GetTextForeground(); }
469
470 void SetTextBackground(const wxColour& colour)
471 { m_pimpl->SetTextBackground(colour); }
472 const wxColour& GetTextBackground() const
473 { return m_pimpl->GetTextBackground(); }
474
475 #if wxUSE_PALETTE
476 void SetPalette(const wxPalette& palette)
477 { m_pimpl->SetPalette(palette); }
478 #endif // wxUSE_PALETTE
479
480 // logical functions
481
482 void SetLogicalFunction(int function)
483 { m_pimpl->SetLogicalFunction(function); }
484 int GetLogicalFunction() const
485 { return m_pimpl->GetLogicalFunction(); }
486
487 // text measurement
488
489 wxCoord GetCharHeight() const
490 { return m_pimpl->GetCharHeight(); }
491 wxCoord GetCharWidth() const
492 { return m_pimpl->GetCharWidth(); }
493
494 void GetTextExtent(const wxString& string,
495 wxCoord *x, wxCoord *y,
496 wxCoord *descent = NULL,
497 wxCoord *externalLeading = NULL,
498 const wxFont *theFont = NULL) const
499 { m_pimpl->DoGetTextExtent(string, x, y, descent, externalLeading, theFont); }
500
501 wxSize GetTextExtent(const wxString& string) const
502 {
503 wxCoord w, h;
504 m_pimpl->DoGetTextExtent(string, &w, &h);
505 return wxSize(w, h);
506 }
507
508 void GetMultiLineTextExtent(const wxString& string,
509 wxCoord *width,
510 wxCoord *height,
511 wxCoord *heightLine = NULL,
512 const wxFont *font = NULL) const
513 { m_pimpl->GetMultiLineTextExtent( string, width, height, heightLine, font ); }
514
515 wxSize GetMultiLineTextExtent(const wxString& string) const
516 {
517 wxCoord w, h;
518 m_pimpl->GetMultiLineTextExtent(string, &w, &h);
519 return wxSize(w, h);
520 }
521
522 bool GetPartialTextExtents(const wxString& text, wxArrayInt& widths) const
523 { return m_pimpl->DoGetPartialTextExtents(text, widths); }
524
525 // clearing
526
527 void Clear()
528 { m_pimpl->Clear(); }
529
530 // clipping
531
532 void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
533 { m_pimpl->DoSetClippingRegion(x, y, width, height); }
534 void SetClippingRegion(const wxPoint& pt, const wxSize& sz)
535 { m_pimpl->DoSetClippingRegion(pt.x, pt.y, sz.x, sz.y); }
536 void SetClippingRegion(const wxRect& rect)
537 { m_pimpl->DoSetClippingRegion(rect.x, rect.y, rect.width, rect.height); }
538 void SetClippingRegion(const wxRegion& region)
539 { m_pimpl->DoSetClippingRegionAsRegion(region); }
540
541 void DestroyClippingRegion()
542 { m_pimpl->DestroyClippingRegion(); }
543
544 void GetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const
545 { m_pimpl->DoGetClippingBox(x, y, w, h); }
546 void GetClippingBox(wxRect& rect) const
547 { m_pimpl->DoGetClippingBox(&rect.x, &rect.y, &rect.width, &rect.height); }
548
549 // coordinates conversions and transforms
550
551 wxCoord DeviceToLogicalX(wxCoord x) const
552 { return m_pimpl->DeviceToLogicalX(x); }
553 wxCoord DeviceToLogicalY(wxCoord y) const;
554 { return m_pimpl->DeviceToLogicalY(y); }
555 wxCoord DeviceToLogicalXRel(wxCoord x) const;
556 { return m_pimpl->DeviceToLogicalXRel(x); }
557 wxCoord DeviceToLogicalYRel(wxCoord y) const;
558 { return m_pimpl->DeviceToLogicalYRel(y); }
559 wxCoord LogicalToDeviceX(wxCoord x) const;
560 { return m_pimpl->LogicalToDeviceX(x); }
561 wxCoord LogicalToDeviceY(wxCoord y) const;
562 { return m_pimpl->LogicalToDeviceY(y); }
563 wxCoord LogicalToDeviceXRel(wxCoord x) const;
564 { return m_pimpl->LogicalToDeviceXRel(x); }
565 wxCoord LogicalToDeviceYRel(wxCoord y) const;
566 { return m_pimpl->LogicalToDeviceYRel(y); }
567
568 void SetMapMode(int mode)
569 { m_pimpl->SetMapMode(mode); }
570 int GetMapMode() const
571 { return m_pimpl->GetMapMode(); }
572
573 void SetUserScale(double x, double y)
574 { m_pimpl->SetUserScale(x,y); }
575 void GetUserScale(double *x, double *y) const
576 { m_pimpl->GetUserScale( x, y ); }
577
578 void SetLogicalScale(double x, double y)
579 { m_pimpl->SetLogicalScale( x, y ); }
580 void GetLogicalScale(double *x, double *y)
581 { m_pimpl->GetLogicalScale( x, y ); }
582
583 void SetLogicalOrigin(wxCoord x, wxCoord y)
584 { m_pimpl->SetLogicalOrigin(x,y); }
585 void GetLogicalOrigin(wxCoord *x, wxCoord *y) const
586 { m_pimpl->DoGetLogicalOrigin(x, y); }
587 wxPoint GetLogicalOrigin() const
588 { wxCoord x, y; m_pimpl->DoGetLogicalOrigin(&x, &y); return wxPoint(x, y); }
589
590 void SetDeviceOrigin(wxCoord x, wxCoord y)
591 { m_pimpl->SetDeviceOrigin( x, y); }
592 void GetDeviceOrigin(wxCoord *x, wxCoord *y) const
593 { DoGetDeviceOrigin(x, y); }
594 wxPoint GetDeviceOrigin() const
595 { wxCoord x, y; DoGetDeviceOrigin(&x, &y); return wxPoint(x, y); }
596
597 void SetAxisOrientation(bool xLeftRight, bool yBottomUp)
598 { m_pimpl->SetAxisOrientation(xLeftRight, yBottomUp); }
599
600 // mostly internal
601 void SetDeviceLocalOrigin( wxCoord x, wxCoord y )
602 { m_pimpl->SetDeviceLocalOrigin( x, y ); }
603
604
605 // draw generic object
606
607 void DrawObject(wxDrawObject* drawobject)
608 {
609 drawobject->Draw(*this);
610 CalcBoundingBox(drawobject->MinX(),drawobject->MinY());
611 CalcBoundingBox(drawobject->MaxX(),drawobject->MaxY());
612 }
613
614 // -----------------------------------------------
615 // the actual drawing API
616
617 bool FloodFill(wxCoord x, wxCoord y, const wxColour& col,
618 int style = wxFLOOD_SURFACE)
619 { return m_pimpl->DoFloodFill(x, y, col, style); }
620 bool FloodFill(const wxPoint& pt, const wxColour& col,
621 int style = wxFLOOD_SURFACE)
622 { return m_pimpl->DoFloodFill(pt.x, pt.y, col, style); }
623
624 // fill the area specified by rect with a radial gradient, starting from
625 // initialColour in the centre of the cercle and fading to destColour.
626 void GradientFillConcentric(const wxRect& rect,
627 const wxColour& initialColour,
628 const wxColour& destColour)
629 { m_pimpl->GradientFillConcentric(rect, initialColour, destColour,
630 wxPoint(rect.GetWidth() / 2,
631 rect.GetHeight() / 2)); }
632
633 void GradientFillConcentric(const wxRect& rect,
634 const wxColour& initialColour,
635 const wxColour& destColour,
636 const wxPoint& circleCenter)
637 { m_pimpl->DoGradientFillConcentric(rect, initialColour, destColour, circleCenter); }
638
639 // fill the area specified by rect with a linear gradient
640 void GradientFillLinear(const wxRect& rect,
641 const wxColour& initialColour,
642 const wxColour& destColour,
643 wxDirection nDirection = wxEAST)
644 { m_pimpl->DoGradientFillLinear(rect, initialColour, destColour, nDirection); }
645
646 bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const
647 { return m_pimpl->DoGetPixel(x, y, col); }
648 bool GetPixel(const wxPoint& pt, wxColour *col) const
649 { return m_pimpl->DoGetPixel(pt.x, pt.y, col); }
650
651 void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
652 { m_pimpl->DoDrawLine(x1, y1, x2, y2); }
653 void DrawLine(const wxPoint& pt1, const wxPoint& pt2)
654 { m_pimpl->DoDrawLine(pt1.x, pt1.y, pt2.x, pt2.y); }
655
656 void CrossHair(wxCoord x, wxCoord y)
657 { m_pimpl->DoCrossHair(x, y); }
658 void CrossHair(const wxPoint& pt)
659 { m_pimpl->DoCrossHair(pt.x, pt.y); }
660
661 void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
662 wxCoord xc, wxCoord yc)
663 { m_pimpl->DoDrawArc(x1, y1, x2, y2, xc, yc); }
664 void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre)
665 { m_pimpl->DoDrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y); }
666
667 void DrawCheckMark(wxCoord x, wxCoord y,
668 wxCoord width, wxCoord height)
669 { m_pimpl->DoDrawCheckMark(x, y, width, height); }
670 void DrawCheckMark(const wxRect& rect)
671 { m_pimpl->DoDrawCheckMark(rect.x, rect.y, rect.width, rect.height); }
672
673 void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
674 double sa, double ea)
675 { m_pimpl->DoDrawEllipticArc(x, y, w, h, sa, ea); }
676 void DrawEllipticArc(const wxPoint& pt, const wxSize& sz,
677 double sa, double ea)
678 { m_pimpl->DoDrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea); }
679
680 void DrawPoint(wxCoord x, wxCoord y)
681 { m_pimpl->DoDrawPoint(x, y); }
682 void DrawPoint(const wxPoint& pt)
683 { m_pimpl->DoDrawPoint(pt.x, pt.y); }
684
685 void DrawLines(int n, wxPoint points[],
686 wxCoord xoffset = 0, wxCoord yoffset = 0)
687 { m_pimpl->DoDrawLines(n, points, xoffset, yoffset); }
688 void DrawLines(const wxList *list,
689 wxCoord xoffset = 0, wxCoord yoffset = 0)
690 { m_pimpl->DrawLines( list, xoffset, yoffset ); }
691
692 void DrawPolygon(int n, wxPoint points[],
693 wxCoord xoffset = 0, wxCoord yoffset = 0,
694 int fillStyle = wxODDEVEN_RULE)
695 { m_pimpl->DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); }
696
697 void DrawPolygon(const wxList *list,
698 wxCoord xoffset = 0, wxCoord yoffset = 0,
699 int fillStyle = wxODDEVEN_RULE)
700 { m_pimpl->DrawPolygon( list, xoffset, yoffset, fillStyle ); }
701
702 void DrawPolyPolygon(int n, int count[], wxPoint points[],
703 wxCoord xoffset = 0, wxCoord yoffset = 0,
704 int fillStyle = wxODDEVEN_RULE)
705 { m_pimpl->DoDrawPolyPolygon(n, count, points, xoffset, yoffset, fillStyle); }
706
707 void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
708 { m_pimpl->DoDrawRectangle(x, y, width, height); }
709 void DrawRectangle(const wxPoint& pt, const wxSize& sz)
710 { m_pimpl->DoDrawRectangle(pt.x, pt.y, sz.x, sz.y); }
711 void DrawRectangle(const wxRect& rect)
712 { m_pimpl->DoDrawRectangle(rect.x, rect.y, rect.width, rect.height); }
713
714 void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height,
715 double radius)
716 { m_pimpl->DoDrawRoundedRectangle(x, y, width, height, radius); }
717 void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz,
718 double radius)
719 { m_pimpl->DoDrawRoundedRectangle(pt.x, pt.y, sz.x, sz.y, radius); }
720 void DrawRoundedRectangle(const wxRect& r, double radius)
721 { m_pimpl->DoDrawRoundedRectangle(r.x, r.y, r.width, r.height, radius); }
722
723 void DrawCircle(wxCoord x, wxCoord y, wxCoord radius)
724 { m_pimpl->DoDrawEllipse(x - radius, y - radius, 2*radius, 2*radius); }
725 void DrawCircle(const wxPoint& pt, wxCoord radius)
726 { m_pimpl->DrawCircle(pt.x, pt.y, radius); }
727
728 void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
729 { m_pimpl->DoDrawEllipse(x, y, width, height); }
730 void DrawEllipse(const wxPoint& pt, const wxSize& sz)
731 { m_pimpl->DoDrawEllipse(pt.x, pt.y, sz.x, sz.y); }
732 void DrawEllipse(const wxRect& rect)
733 { m_pimpl->DoDrawEllipse(rect.x, rect.y, rect.width, rect.height); }
734
735 void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
736 { m_pimpl->DoDrawIcon(icon, x, y); }
737 void DrawIcon(const wxIcon& icon, const wxPoint& pt)
738 { m_pimpl->DoDrawIcon(icon, pt.x, pt.y); }
739
740 void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
741 bool useMask = false)
742 { m_pimpl->DoDrawBitmap(bmp, x, y, useMask); }
743 void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt,
744 bool useMask = false)
745 { m_pimpl->DoDrawBitmap(bmp, pt.x, pt.y, useMask); }
746
747 void DrawText(const wxString& text, wxCoord x, wxCoord y)
748 { m_pimpl->DoDrawText(text, x, y); }
749 void DrawText(const wxString& text, const wxPoint& pt)
750 { m_pimpl->DoDrawText(text, pt.x, pt.y); }
751
752 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle)
753 { m_pimpl->DoDrawRotatedText(text, x, y, angle); }
754 void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle)
755 { m_pimpl->DoDrawRotatedText(text, pt.x, pt.y, angle); }
756
757 // this version puts both optional bitmap and the text into the given
758 // rectangle and aligns is as specified by alignment parameter; it also
759 // will emphasize the character with the given index if it is != -1 and
760 // return the bounding rectangle if required
761 void DrawLabel(const wxString& text,
762 const wxBitmap& image,
763 const wxRect& rect,
764 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
765 int indexAccel = -1,
766 wxRect *rectBounding = NULL)
767 { m_pimpl->DrawLabel( text, image, rect, alignment, indexAccel, rectBounding ); }
768
769 void DrawLabel(const wxString& text, const wxRect& rect,
770 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
771 int indexAccel = -1)
772 { m_pimpl->DrawLabel(text, wxNullBitmap, rect, alignment, indexAccel); }
773
774 bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
775 wxDC *source, wxCoord xsrc, wxCoord ysrc,
776 int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord)
777 {
778 return m_pimpl->DoBlit(xdest, ydest, width, height,
779 source, xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask);
780 }
781 bool Blit(const wxPoint& destPt, const wxSize& sz,
782 wxDC *source, const wxPoint& srcPt,
783 int rop = wxCOPY, bool useMask = false, const wxPoint& srcPtMask = wxDefaultPosition)
784 {
785 return m_pimpl->DoBlit(destPt.x, destPt.y, sz.x, sz.y,
786 source, srcPt.x, srcPt.y, rop, useMask, srcPtMask.x, srcPtMask.y);
787 }
788
789 bool StretchBlit(wxCoord dstX, wxCoord dstY,
790 wxCoord dstWidth, wxCoord dstHeight,
791 wxDC *source,
792 wxCoord srcX, wxCoord srcY,
793 wxCoord srcWidth, wxCoord srcHeight,
794 int rop = wxCOPY, bool useMask = false,
795 wxCoord srcMaskX = wxDefaultCoord, wxCoord srcMaskY = wxDefaultCoord)
796 {
797 return m_pimpl->DoStretchBlit(dstX, dstY, dstWidth, dstHeight,
798 source, srcX, srcY, srcWidth, srcHeight, rop, useMask, srcMaskX, srcMaskY);
799 }
800 bool StretchBlit(const wxPoint& dstPt, const wxSize& dstSize,
801 wxDC *source, const wxPoint& srcPt, const wxSize& srcSize,
802 int rop = wxCOPY, bool useMask = false, const wxPoint& srcMaskPt = wxDefaultPosition)
803 {
804 return m_pimpl->DoStretchBlit(dstPt.x, dstPt.y, dstSize.x, dstSize.y,
805 source, srcPt.x, srcPt.y, srcSize.x, srcSize.y, rop, useMask, srcMaskPt.x, srcMaskPt.y);
806 }
807
808 wxBitmap GetAsBitmap(const wxRect *subrect = (const wxRect *) NULL) const
809 {
810 return m_pimpl->DoGetAsBitmap(subrect);
811 }
812
813 #if wxUSE_SPLINES
814 // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?)
815 void DrawSpline(wxCoord x1, wxCoord y1,
816 wxCoord x2, wxCoord y2,
817 wxCoord x3, wxCoord y3)
818 { m_pimpl->DrawSpline(x1,y1,x2,y2,x3,y3); }
819 void DrawSpline(int n, wxPoint points[])
820 { m_pimpl->DrawSpline(n,points); }
821
822 void DrawSpline(wxList *points)
823 { m_pimpl->DoDrawSpline(points); }
824 #endif // wxUSE_SPLINES
825
826
827 protected:
828 wxImplDC *m_pimpl;
829
830 private:
831 DECLARE_ABSTRACT_CLASS(wxImplDC)
832 }
833
834
835 #endif
836
837 //-----------------------------------------------------------------------------
838 // wxDC
839 //-----------------------------------------------------------------------------
840
841 class WXDLLIMPEXP_CORE wxDC : public wxDCBase
842 {
843 public:
844 wxDC();
845 virtual ~wxDC() { }
846
847 #if wxUSE_PALETTE
848 void SetColourMap( const wxPalette& palette ) { SetPalette(palette); };
849 #endif // wxUSE_PALETTE
850
851 // Resolution in pixels per logical inch
852 virtual wxSize GetPPI() const;
853
854 virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return true; }
855 virtual void EndDoc() { }
856 virtual void StartPage() { }
857 virtual void EndPage() { }
858
859 virtual GdkWindow* GetGDKWindow() const { return NULL; }
860
861 protected:
862 // implementation
863 wxCoord XDEV2LOG(wxCoord x) const { return DeviceToLogicalX(x); }
864 wxCoord XDEV2LOGREL(wxCoord x) const { return DeviceToLogicalXRel(x); }
865 wxCoord YDEV2LOG(wxCoord y) const { return DeviceToLogicalY(y); }
866 wxCoord YDEV2LOGREL(wxCoord y) const { return DeviceToLogicalYRel(y); }
867 wxCoord XLOG2DEV(wxCoord x) const { return LogicalToDeviceX(x); }
868 wxCoord XLOG2DEVREL(wxCoord x) const { return LogicalToDeviceXRel(x); }
869 wxCoord YLOG2DEV(wxCoord y) const { return LogicalToDeviceY(y); }
870 wxCoord YLOG2DEVREL(wxCoord y) const { return LogicalToDeviceYRel(y); }
871
872 // base class pure virtuals implemented here
873 virtual void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
874 virtual void DoGetSizeMM(int* width, int* height) const;
875
876 private:
877 DECLARE_ABSTRACT_CLASS(wxDC)
878 };
879
880 // this must be defined when wxDC::Blit() honours the DC origian and needed to
881 // allow wxUniv code in univ/winuniv.cpp to work with versions of wxGTK
882 // 2.3.[23]
883 #ifndef wxHAS_WORKING_GTK_DC_BLIT
884 #define wxHAS_WORKING_GTK_DC_BLIT
885 #endif
886
887 #endif // __GTKDCH__