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