]> git.saurik.com Git - wxWidgets.git/blame - include/wx/dc.h
Fixed context menu in wxRichTextCtrl
[wxWidgets.git] / include / wx / dc.h
CommitLineData
006162a9 1/////////////////////////////////////////////////////////////////////////////
4660e6ac 2// Name: wx/dc.h
006162a9
VZ
3// Purpose: wxDC class
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 05/25/99
7// RCS-ID: $Id$
77ffb593 8// Copyright: (c) wxWidgets team
65571936 9// Licence: wxWindows licence
006162a9
VZ
10/////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_DC_H_BASE_
13#define _WX_DC_H_BASE_
c801d85f 14
a23fd0e1
VZ
15// ----------------------------------------------------------------------------
16// headers which we must include here
17// ----------------------------------------------------------------------------
18
19#include "wx/object.h" // the base class
20
0d80fb31 21#include "wx/intl.h" // for wxLayoutDirection
a23fd0e1
VZ
22#include "wx/cursor.h" // we have member variables of these classes
23#include "wx/font.h" // so we can't do without them
24#include "wx/colour.h"
b494e2b0 25#include "wx/bitmap.h" // for wxNullBitmap
a23fd0e1
VZ
26#include "wx/brush.h"
27#include "wx/pen.h"
28#include "wx/palette.h"
0919e93e 29#include "wx/dynarray.h"
19edb09c 30#include "wx/math.h"
02255e07 31#include "wx/image.h"
a23fd0e1 32
2970ae54
RR
33 // 1 if using the reorganized DC code
34#define wxUSE_NEW_DC 0
35
36
ca7db61e
RR
37#if wxUSE_NEW_DC
38class WXDLLIMPEXP_FWD_CORE wxDC;
ab171e95
RR
39class WXDLLIMPEXP_FWD_CORE wxClientDC;
40class WXDLLIMPEXP_FWD_CORE wxPaintDC;
41class WXDLLIMPEXP_FWD_CORE wxWindowDC;
42class WXDLLIMPEXP_FWD_CORE wxScreenDC;
43class WXDLLIMPEXP_FWD_CORE wxMemoryDC;
ca7db61e
RR
44#else
45class WXDLLIMPEXP_FWD_CORE wxDCBase;
46#endif
47
48class WXDLLEXPORT wxDrawObject
49{
50public:
51
52 wxDrawObject()
53 : m_isBBoxValid(false)
54 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
55 { }
56
57 virtual ~wxDrawObject() { }
58
59#if wxUSE_NEW_DC
60 virtual void Draw(wxDC&) const { }
61#else
62 virtual void Draw(wxDCBase&) const { }
63#endif
64
65 virtual void CalcBoundingBox(wxCoord x, wxCoord y)
66 {
67 if ( m_isBBoxValid )
68 {
69 if ( x < m_minX ) m_minX = x;
70 if ( y < m_minY ) m_minY = y;
71 if ( x > m_maxX ) m_maxX = x;
72 if ( y > m_maxY ) m_maxY = y;
73 }
74 else
75 {
76 m_isBBoxValid = true;
77
78 m_minX = x;
79 m_minY = y;
80 m_maxX = x;
81 m_maxY = y;
82 }
83 }
84
85 void ResetBoundingBox()
86 {
87 m_isBBoxValid = false;
88
89 m_minX = m_maxX = m_minY = m_maxY = 0;
90 }
91
92 // Get the final bounding box of the PostScript or Metafile picture.
93
94 wxCoord MinX() const { return m_minX; }
95 wxCoord MaxX() const { return m_maxX; }
96 wxCoord MinY() const { return m_minY; }
97 wxCoord MaxY() const { return m_maxY; }
98
99 //to define the type of object for derived objects
100 virtual int GetType()=0;
101
102protected:
103 //for boundingbox calculation
104 bool m_isBBoxValid:1;
105 //for boundingbox calculation
106 wxCoord m_minX, m_minY, m_maxX, m_maxY;
107};
108
109
2970ae54
RR
110#if wxUSE_NEW_DC
111
112//-----------------------------------------------------------------------------
113// wxDCFactory
114//-----------------------------------------------------------------------------
115
b5dbe15d 116class WXDLLIMPEXP_FWD_CORE wxImplDC;
2970ae54
RR
117
118class WXDLLIMPEXP_CORE wxDCFactory
119{
120public:
121 wxDCFactory() {}
122 virtual ~wxDCFactory() {}
123
ab171e95
RR
124 virtual wxImplDC* CreateWindowDC( wxWindowDC *owner ) = 0;
125 virtual wxImplDC* CreateWindowDC( wxWindowDC *owner, wxWindow *window ) = 0;
126 virtual wxImplDC* CreateClientDC( wxClientDC *owner ) = 0;
127 virtual wxImplDC* CreateClientDC( wxClientDC *owner, wxWindow *window ) = 0;
128 virtual wxImplDC* CreatePaintDC( wxPaintDC *owner ) = 0;
129 virtual wxImplDC* CreatePaintDC( wxPaintDC *owner, wxWindow *window ) = 0;
130 virtual wxImplDC* CreateMemoryDC( wxMemoryDC *owner ) = 0;
131 virtual wxImplDC* CreateMemoryDC( wxMemoryDC *owner, wxBitmap &bitmap ) = 0;
132 virtual wxImplDC* CreateMemoryDC( wxMemoryDC *owner, wxDC *dc ) = 0;
133 virtual wxImplDC* CreateScreenDC( wxScreenDC *owner ) = 0;
2970ae54
RR
134
135 static void SetDCFactory( wxDCFactory *factory );
136 static wxDCFactory *GetFactory();
137private:
138 static wxDCFactory *m_factory;
139};
140
141//-----------------------------------------------------------------------------
142// wxNativeDCFactory
143//-----------------------------------------------------------------------------
144
ab171e95 145class WXDLLIMPEXP_CORE wxNativeDCFactory: public wxDCFactory
2970ae54
RR
146{
147public:
148 wxNativeDCFactory() {}
149
ab171e95
RR
150 virtual wxImplDC* CreateWindowDC( wxWindowDC *owner );
151 virtual wxImplDC* CreateWindowDC( wxWindowDC *owner, wxWindow *window );
152 virtual wxImplDC* CreateClientDC( wxClientDC *owner );
153 virtual wxImplDC* CreateClientDC( wxClientDC *owner, wxWindow *window );
154 virtual wxImplDC* CreatePaintDC( wxPaintDC *owner );
155 virtual wxImplDC* CreatePaintDC( wxPaintDC *owner, wxWindow *window );
156 virtual wxImplDC* CreateMemoryDC( wxMemoryDC *owner );
157 virtual wxImplDC* CreateMemoryDC( wxMemoryDC *owner, wxBitmap &bitmap );
158 virtual wxImplDC* CreateMemoryDC( wxMemoryDC *owner, wxDC *dc );
159 virtual wxImplDC* CreateScreenDC( wxScreenDC *owner );
2970ae54
RR
160};
161
2970ae54
RR
162//-----------------------------------------------------------------------------
163// wxImplDC
164//-----------------------------------------------------------------------------
165
166class WXDLLIMPEXP_CORE wxImplDC: public wxObject
167{
168public:
169 wxImplDC( wxDC *owner );
170 ~wxImplDC();
171
ab171e95 172 wxDC *GetOwner() const { return m_owner; }
2970ae54
RR
173
174 virtual bool IsOk() const { return m_ok; }
175
176 // query capabilities
177
178 virtual bool CanDrawBitmap() const = 0;
179 virtual bool CanGetTextExtent() const = 0;
180
181 // query dimension, colour deps, resolution
182
183 virtual void DoGetSize(int *width, int *height) const = 0;
184 virtual void DoGetSizeMM(int* width, int* height) const = 0;
185
186 virtual int GetDepth() const = 0;
187 virtual wxSize GetPPI() const = 0;
188
189 // Right-To-Left (RTL) modes
190
191 virtual void SetLayoutDirection(wxLayoutDirection WXUNUSED(dir)) { }
192 virtual wxLayoutDirection GetLayoutDirection() const { return wxLayout_Default; }
193
194 // page and document
195
196 virtual bool StartDoc(const wxString& WXUNUSED(message)) { return true; }
197 virtual void EndDoc() { }
198
199 virtual void StartPage() { }
200 virtual void EndPage() { }
201
202 // bounding box
203
ca7db61e 204 virtual void CalcBoundingBox(wxCoord x, wxCoord y)
2970ae54
RR
205 {
206 if ( m_isBBoxValid )
207 {
208 if ( x < m_minX ) m_minX = x;
209 if ( y < m_minY ) m_minY = y;
210 if ( x > m_maxX ) m_maxX = x;
211 if ( y > m_maxY ) m_maxY = y;
212 }
213 else
214 {
215 m_isBBoxValid = true;
216
217 m_minX = x;
218 m_minY = y;
219 m_maxX = x;
220 m_maxY = y;
221 }
222 }
ca7db61e 223 void ResetBoundingBox()
2970ae54
RR
224 {
225 m_isBBoxValid = false;
226
227 m_minX = m_maxX = m_minY = m_maxY = 0;
228 }
229
230 wxCoord MinX() const { return m_minX; }
231 wxCoord MaxX() const { return m_maxX; }
232 wxCoord MinY() const { return m_minY; }
233 wxCoord MaxY() const { return m_maxY; }
234
235 // setters and getters
236
237 virtual void SetFont(const wxFont& font) = 0;
238 virtual const wxFont& GetFont() const { return m_font; }
239
240 virtual void SetPen(const wxPen& pen) = 0;
241 virtual const wxPen& GetPen() const { return m_pen; }
242
243 virtual void SetBrush(const wxBrush& brush) = 0;
244 virtual const wxBrush& GetBrush() const { return m_brush; }
245
246 virtual void SetBackground(const wxBrush& brush) = 0;
247 virtual const wxBrush& GetBackground() const { return m_backgroundBrush; }
248
249 virtual void SetBackgroundMode(int mode) = 0;
250 virtual int GetBackgroundMode() const { return m_backgroundMode; }
251
252 virtual void SetTextForeground(const wxColour& colour)
253 { m_textForegroundColour = colour; }
254 virtual const wxColour& GetTextForeground() const { return m_textForegroundColour; }
255
256 virtual void SetTextBackground(const wxColour& colour)
257 { m_textBackgroundColour = colour; }
258 virtual const wxColour& GetTextBackground() const { return m_textBackgroundColour; }
259
260#if wxUSE_PALETTE
261 virtual void SetPalette(const wxPalette& palette) = 0;
262#endif // wxUSE_PALETTE
263
264 // logical functions
265
266 virtual void SetLogicalFunction(int function) = 0;
267 virtual int GetLogicalFunction() const { return m_logicalFunction; }
268
269 // text measurement
270
271 virtual wxCoord GetCharHeight() const = 0;
272 virtual wxCoord GetCharWidth() const = 0;
273 virtual void DoGetTextExtent(const wxString& string,
274 wxCoord *x, wxCoord *y,
275 wxCoord *descent = NULL,
276 wxCoord *externalLeading = NULL,
277 const wxFont *theFont = NULL) const = 0;
278 virtual void GetMultiLineTextExtent(const wxString& string,
279 wxCoord *width,
280 wxCoord *height,
281 wxCoord *heightLine = NULL,
282 const wxFont *font = NULL) const;
283 virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
284
285 // clearing
286
287 virtual void Clear() = 0;
288
289 // clipping
290
291 virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
292 wxCoord width, wxCoord height) = 0;
293 virtual void DoSetClippingRegionAsRegion(const wxRegion& region) = 0;
294
295 virtual void DoGetClippingBox(wxCoord *x, wxCoord *y,
296 wxCoord *w, wxCoord *h) const
297 {
298 if ( x )
299 *x = m_clipX1;
300 if ( y )
301 *y = m_clipY1;
302 if ( w )
303 *w = m_clipX2 - m_clipX1;
304 if ( h )
305 *h = m_clipY2 - m_clipY1;
306 }
307
308 virtual void DestroyClippingRegion() { ResetClipping(); }
309
310
311 // coordinates conversions and transforms
312
313 virtual wxCoord DeviceToLogicalX(wxCoord x) const;
314 virtual wxCoord DeviceToLogicalY(wxCoord y) const;
315 virtual wxCoord DeviceToLogicalXRel(wxCoord x) const;
316 virtual wxCoord DeviceToLogicalYRel(wxCoord y) const;
317 virtual wxCoord LogicalToDeviceX(wxCoord x) const;
318 virtual wxCoord LogicalToDeviceY(wxCoord y) const;
319 virtual wxCoord LogicalToDeviceXRel(wxCoord x) const;
320 virtual wxCoord LogicalToDeviceYRel(wxCoord y) const;
321
322 virtual void SetMapMode(int mode);
323 virtual int GetMapMode() const { return m_mappingMode; }
324
325 virtual void SetUserScale(double x, double y);
326 virtual void GetUserScale(double *x, double *y) const
327 {
328 if ( x ) *x = m_userScaleX;
329 if ( y ) *y = m_userScaleY;
330 }
331
332 virtual void SetLogicalScale(double x, double y);
333 virtual void GetLogicalScale(double *x, double *y)
334 {
335 if ( x ) *x = m_logicalScaleX;
336 if ( y ) *y = m_logicalScaleY;
337 }
338
339 virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
340 virtual void DoGetLogicalOrigin(wxCoord *x, wxCoord *y) const
341 {
342 if ( x ) *x = m_logicalOriginX;
343 if ( y ) *y = m_logicalOriginY;
344 }
345
346 virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
347 virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const
348 {
349 if ( x ) *x = m_deviceOriginX;
350 if ( y ) *y = m_deviceOriginY;
351 }
352
353 virtual void SetDeviceLocalOrigin( wxCoord x, wxCoord y );
354
355 virtual void ComputeScaleAndOrigin();
356
357 // this needs to overidden if the axis is inverted
358 virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
359
360 // ---------------------------------------------------------
361 // the actual drawing API
362
363 virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
364 int style = wxFLOOD_SURFACE) = 0;
365
366 virtual void DoGradientFillLinear(const wxRect& rect,
367 const wxColour& initialColour,
368 const wxColour& destColour,
369 wxDirection nDirection = wxEAST);
370
371 virtual void DoGradientFillConcentric(const wxRect& rect,
372 const wxColour& initialColour,
373 const wxColour& destColour,
374 const wxPoint& circleCenter);
375
376 virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const = 0;
377
378 virtual void DoDrawPoint(wxCoord x, wxCoord y) = 0;
379 virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) = 0;
380
381 virtual void DoDrawArc(wxCoord x1, wxCoord y1,
382 wxCoord x2, wxCoord y2,
383 wxCoord xc, wxCoord yc) = 0;
384 virtual void DoDrawCheckMark(wxCoord x, wxCoord y,
385 wxCoord width, wxCoord height);
386 virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
387 double sa, double ea) = 0;
388
389 virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) = 0;
390 virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
391 wxCoord width, wxCoord height,
392 double radius) = 0;
393 virtual void DoDrawEllipse(wxCoord x, wxCoord y,
394 wxCoord width, wxCoord height) = 0;
395
396 virtual void DoCrossHair(wxCoord x, wxCoord y) = 0;
397
398 virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) = 0;
399 virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
400 bool useMask = false) = 0;
401
402 virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y) = 0;
403 virtual void DoDrawRotatedText(const wxString& text,
404 wxCoord x, wxCoord y, double angle) = 0;
405
406 virtual bool DoBlit(wxCoord xdest, wxCoord ydest,
407 wxCoord width, wxCoord height,
408 wxDC *source,
409 wxCoord xsrc, wxCoord ysrc,
410 int rop = wxCOPY,
411 bool useMask = false,
412 wxCoord xsrcMask = wxDefaultCoord,
413 wxCoord ysrcMask = wxDefaultCoord) = 0;
414
415 virtual bool DoStretchBlit(wxCoord xdest, wxCoord ydest,
416 wxCoord dstWidth, wxCoord dstHeight,
417 wxDC *source,
418 wxCoord xsrc, wxCoord ysrc,
419 wxCoord srcWidth, wxCoord srcHeight,
420 int rop = wxCOPY,
421 bool useMask = false,
422 wxCoord xsrcMask = wxDefaultCoord,
423 wxCoord ysrcMask = wxDefaultCoord);
424
425 virtual wxBitmap DoGetAsBitmap(const wxRect *WXUNUSED(subrect)) const
426 { return wxNullBitmap; }
427
428
429 virtual void DoDrawLines(int n, wxPoint points[],
430 wxCoord xoffset, wxCoord yoffset) = 0;
431 virtual void DoDrawPolygon(int n, wxPoint points[],
432 wxCoord xoffset, wxCoord yoffset,
433 int fillStyle = wxODDEVEN_RULE) = 0;
434 virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[],
435 wxCoord xoffset, wxCoord yoffset,
436 int fillStyle);
437
438
439
440#if wxUSE_SPLINES
ca7db61e
RR
441 virtual void DoDrawSpline(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord x3, wxCoord y3);
442 virtual void DoDrawSpline(int n, wxPoint points[]);
b0d7707b 443 virtual void DoDrawSpline(const wxPointList *points);
2970ae54
RR
444#endif
445
446private:
447 wxDC *m_owner;
448
449protected:
450 // unset clipping variables (after clipping region was destroyed)
451 void ResetClipping()
452 {
453 m_clipping = false;
454
455 m_clipX1 = m_clipX2 = m_clipY1 = m_clipY2 = 0;
456 }
457
458 // flags
459 bool m_colour:1;
460 bool m_ok:1;
461 bool m_clipping:1;
462 bool m_isInteractive:1;
463 bool m_isBBoxValid:1;
464
465 // coordinate system variables
466
467 wxCoord m_logicalOriginX, m_logicalOriginY;
468 wxCoord m_deviceOriginX, m_deviceOriginY; // Usually 0,0, can be change by user
469
470 wxCoord m_deviceLocalOriginX, m_deviceLocalOriginY; // non-zero if native top-left corner
471 // is not at 0,0. This was the case under
472 // Mac's GrafPorts (coordinate system
473 // used toplevel window's origin) and
474 // e.g. for Postscript, where the native
475 // origin in the bottom left corner.
476 double m_logicalScaleX, m_logicalScaleY;
477 double m_userScaleX, m_userScaleY;
478 double m_scaleX, m_scaleY; // calculated from logical scale and user scale
479
480 int m_signX, m_signY; // Used by SetAxisOrientation() to invert the axes
481
482 // what is a mm on a screen you don't know the size of?
483 double m_mm_to_pix_x,
484 m_mm_to_pix_y;
485
486 // bounding and clipping boxes
487 wxCoord m_minX, m_minY, m_maxX, m_maxY;
488 wxCoord m_clipX1, m_clipY1, m_clipX2, m_clipY2;
489
490 int m_logicalFunction;
491 int m_backgroundMode;
492 int m_mappingMode;
493
494 wxPen m_pen;
495 wxBrush m_brush;
496 wxBrush m_backgroundBrush;
497 wxColour m_textForegroundColour;
498 wxColour m_textBackgroundColour;
499 wxFont m_font;
500
501#if wxUSE_PALETTE
502 wxPalette m_palette;
503 bool m_hasCustomPalette;
504#endif // wxUSE_PALETTE
505
506private:
507 DECLARE_ABSTRACT_CLASS(wxImplDC)
ca7db61e 508};
2970ae54
RR
509
510
511class wxDC: public wxObject
512{
513public:
514 wxDC() { m_pimpl = NULL; }
515
ab171e95
RR
516 wxImplDC *GetImpl()
517 { return m_pimpl; }
518
2970ae54
RR
519 bool IsOk() const
520 { return m_pimpl && m_pimpl->IsOk(); }
521
522 // query capabilities
523
524 bool CanDrawBitmap() const
525 { return m_pimpl->CanDrawBitmap(); }
526 bool CanGetTextExtent() const
527 { return m_pimpl->CanGetTextExtent(); }
528
529 // query dimension, colour deps, resolution
530
531 void GetSize(int *width, int *height) const
532 { m_pimpl->DoGetSize(width, height); }
533
534 wxSize GetSize() const
535 {
536 int w, h;
537 m_pimpl->DoGetSize(&w, &h);
538 return wxSize(w, h);
539 }
540
541 void GetSizeMM(int* width, int* height) const
542 { m_pimpl->DoGetSizeMM(width, height); }
543 wxSize GetSizeMM() const
544 {
545 int w, h;
546 m_pimpl->DoGetSizeMM(&w, &h);
547 return wxSize(w, h);
548 }
549
550 int GetDepth() const
551 { return m_pimpl->GetDepth(); }
552 wxSize GetPPI() const
553 { return m_pimpl->GetPPI(); }
554
555 // Right-To-Left (RTL) modes
556
557 void SetLayoutDirection(wxLayoutDirection dir)
558 { m_pimpl->SetLayoutDirection( dir ); }
559 wxLayoutDirection GetLayoutDirection() const
560 { return m_pimpl->GetLayoutDirection(); }
561
562 // page and document
563
564 bool StartDoc(const wxString& message)
565 { return m_pimpl->StartDoc(message); }
566 void EndDoc()
567 { m_pimpl->EndDoc(); }
568
569 void StartPage()
570 { m_pimpl->StartPage(); }
571 void EndPage()
572 { m_pimpl->EndPage(); }
573
574 // bounding box
575
576 void CalcBoundingBox(wxCoord x, wxCoord y)
577 { m_pimpl->CalcBoundingBox(x,y); }
578 void ResetBoundingBox()
579 { m_pimpl->ResetBoundingBox(); }
580
581 wxCoord MinX() const
582 { return m_pimpl->MinX(); }
583 wxCoord MaxX() const
584 { return m_pimpl->MaxX(); }
585 wxCoord MinY() const
586 { return m_pimpl->MinY(); }
587 wxCoord MaxY() const
588 { return m_pimpl->MaxY(); }
589
590 // setters and getters
591
592 void SetFont(const wxFont& font)
593 { m_pimpl->SetFont( font ); }
594 const wxFont& GetFont() const
595 { return m_pimpl->GetFont(); }
596
597 void SetPen(const wxPen& pen)
598 { m_pimpl->SetPen( pen ); }
599 const wxPen& GetPen() const
600 { return m_pimpl->GetPen(); }
601
602 void SetBrush(const wxBrush& brush)
603 { m_pimpl->SetBrush( brush ); }
604 const wxBrush& GetBrush() const
605 { return m_pimpl->GetBrush(); }
606
607 void SetBackground(const wxBrush& brush)
608 { m_pimpl->SetBackground( brush ); }
609 const wxBrush& GetBackground() const
610 { return m_pimpl->GetBackground(); }
611
612 void SetBackgroundMode(int mode)
ca7db61e 613 { m_pimpl->SetBackgroundMode( mode ); }
2970ae54 614 int GetBackgroundMode() const
ca7db61e 615 { return m_pimpl->GetBackgroundMode(); }
2970ae54
RR
616
617 void SetTextForeground(const wxColour& colour)
618 { m_pimpl->SetTextForeground(colour); }
619 const wxColour& GetTextForeground() const
620 { return m_pimpl->GetTextForeground(); }
621
622 void SetTextBackground(const wxColour& colour)
623 { m_pimpl->SetTextBackground(colour); }
624 const wxColour& GetTextBackground() const
625 { return m_pimpl->GetTextBackground(); }
626
627#if wxUSE_PALETTE
628 void SetPalette(const wxPalette& palette)
629 { m_pimpl->SetPalette(palette); }
630#endif // wxUSE_PALETTE
631
632 // logical functions
633
634 void SetLogicalFunction(int function)
635 { m_pimpl->SetLogicalFunction(function); }
636 int GetLogicalFunction() const
637 { return m_pimpl->GetLogicalFunction(); }
638
639 // text measurement
640
641 wxCoord GetCharHeight() const
642 { return m_pimpl->GetCharHeight(); }
643 wxCoord GetCharWidth() const
644 { return m_pimpl->GetCharWidth(); }
645
646 void GetTextExtent(const wxString& string,
647 wxCoord *x, wxCoord *y,
648 wxCoord *descent = NULL,
649 wxCoord *externalLeading = NULL,
650 const wxFont *theFont = NULL) const
651 { m_pimpl->DoGetTextExtent(string, x, y, descent, externalLeading, theFont); }
652
653 wxSize GetTextExtent(const wxString& string) const
654 {
655 wxCoord w, h;
656 m_pimpl->DoGetTextExtent(string, &w, &h);
657 return wxSize(w, h);
658 }
659
660 void GetMultiLineTextExtent(const wxString& string,
661 wxCoord *width,
662 wxCoord *height,
663 wxCoord *heightLine = NULL,
664 const wxFont *font = NULL) const
665 { m_pimpl->GetMultiLineTextExtent( string, width, height, heightLine, font ); }
666
667 wxSize GetMultiLineTextExtent(const wxString& string) const
668 {
669 wxCoord w, h;
670 m_pimpl->GetMultiLineTextExtent(string, &w, &h);
671 return wxSize(w, h);
672 }
673
674 bool GetPartialTextExtents(const wxString& text, wxArrayInt& widths) const
675 { return m_pimpl->DoGetPartialTextExtents(text, widths); }
676
677 // clearing
678
679 void Clear()
680 { m_pimpl->Clear(); }
681
682 // clipping
683
684 void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
685 { m_pimpl->DoSetClippingRegion(x, y, width, height); }
686 void SetClippingRegion(const wxPoint& pt, const wxSize& sz)
687 { m_pimpl->DoSetClippingRegion(pt.x, pt.y, sz.x, sz.y); }
688 void SetClippingRegion(const wxRect& rect)
689 { m_pimpl->DoSetClippingRegion(rect.x, rect.y, rect.width, rect.height); }
690 void SetClippingRegion(const wxRegion& region)
691 { m_pimpl->DoSetClippingRegionAsRegion(region); }
692
693 void DestroyClippingRegion()
694 { m_pimpl->DestroyClippingRegion(); }
695
696 void GetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const
697 { m_pimpl->DoGetClippingBox(x, y, w, h); }
698 void GetClippingBox(wxRect& rect) const
699 { m_pimpl->DoGetClippingBox(&rect.x, &rect.y, &rect.width, &rect.height); }
700
701 // coordinates conversions and transforms
702
703 wxCoord DeviceToLogicalX(wxCoord x) const
704 { return m_pimpl->DeviceToLogicalX(x); }
ca7db61e 705 wxCoord DeviceToLogicalY(wxCoord y) const
2970ae54 706 { return m_pimpl->DeviceToLogicalY(y); }
ca7db61e 707 wxCoord DeviceToLogicalXRel(wxCoord x) const
2970ae54 708 { return m_pimpl->DeviceToLogicalXRel(x); }
ca7db61e 709 wxCoord DeviceToLogicalYRel(wxCoord y) const
2970ae54 710 { return m_pimpl->DeviceToLogicalYRel(y); }
ca7db61e 711 wxCoord LogicalToDeviceX(wxCoord x) const
2970ae54 712 { return m_pimpl->LogicalToDeviceX(x); }
ca7db61e 713 wxCoord LogicalToDeviceY(wxCoord y) const
2970ae54 714 { return m_pimpl->LogicalToDeviceY(y); }
ca7db61e 715 wxCoord LogicalToDeviceXRel(wxCoord x) const
2970ae54 716 { return m_pimpl->LogicalToDeviceXRel(x); }
ca7db61e 717 wxCoord LogicalToDeviceYRel(wxCoord y) const
2970ae54
RR
718 { return m_pimpl->LogicalToDeviceYRel(y); }
719
720 void SetMapMode(int mode)
721 { m_pimpl->SetMapMode(mode); }
722 int GetMapMode() const
723 { return m_pimpl->GetMapMode(); }
724
725 void SetUserScale(double x, double y)
726 { m_pimpl->SetUserScale(x,y); }
727 void GetUserScale(double *x, double *y) const
728 { m_pimpl->GetUserScale( x, y ); }
729
730 void SetLogicalScale(double x, double y)
731 { m_pimpl->SetLogicalScale( x, y ); }
732 void GetLogicalScale(double *x, double *y)
733 { m_pimpl->GetLogicalScale( x, y ); }
734
735 void SetLogicalOrigin(wxCoord x, wxCoord y)
736 { m_pimpl->SetLogicalOrigin(x,y); }
737 void GetLogicalOrigin(wxCoord *x, wxCoord *y) const
738 { m_pimpl->DoGetLogicalOrigin(x, y); }
739 wxPoint GetLogicalOrigin() const
740 { wxCoord x, y; m_pimpl->DoGetLogicalOrigin(&x, &y); return wxPoint(x, y); }
741
742 void SetDeviceOrigin(wxCoord x, wxCoord y)
743 { m_pimpl->SetDeviceOrigin( x, y); }
744 void GetDeviceOrigin(wxCoord *x, wxCoord *y) const
745 { m_pimpl->DoGetDeviceOrigin(x, y); }
746 wxPoint GetDeviceOrigin() const
747 { wxCoord x, y; m_pimpl->DoGetDeviceOrigin(&x, &y); return wxPoint(x, y); }
748
749 void SetAxisOrientation(bool xLeftRight, bool yBottomUp)
750 { m_pimpl->SetAxisOrientation(xLeftRight, yBottomUp); }
751
752 // mostly internal
753 void SetDeviceLocalOrigin( wxCoord x, wxCoord y )
754 { m_pimpl->SetDeviceLocalOrigin( x, y ); }
755
756
757 // draw generic object
758
759 void DrawObject(wxDrawObject* drawobject)
760 {
761 drawobject->Draw(*this);
762 CalcBoundingBox(drawobject->MinX(),drawobject->MinY());
763 CalcBoundingBox(drawobject->MaxX(),drawobject->MaxY());
764 }
765
766 // -----------------------------------------------
767 // the actual drawing API
768
769 bool FloodFill(wxCoord x, wxCoord y, const wxColour& col,
770 int style = wxFLOOD_SURFACE)
771 { return m_pimpl->DoFloodFill(x, y, col, style); }
772 bool FloodFill(const wxPoint& pt, const wxColour& col,
773 int style = wxFLOOD_SURFACE)
774 { return m_pimpl->DoFloodFill(pt.x, pt.y, col, style); }
775
776 // fill the area specified by rect with a radial gradient, starting from
777 // initialColour in the centre of the cercle and fading to destColour.
778 void GradientFillConcentric(const wxRect& rect,
779 const wxColour& initialColour,
780 const wxColour& destColour)
ca7db61e
RR
781 { m_pimpl->DoGradientFillConcentric( rect, initialColour, destColour,
782 wxPoint(rect.GetWidth() / 2,
783 rect.GetHeight() / 2)); }
2970ae54
RR
784
785 void GradientFillConcentric(const wxRect& rect,
786 const wxColour& initialColour,
787 const wxColour& destColour,
788 const wxPoint& circleCenter)
789 { m_pimpl->DoGradientFillConcentric(rect, initialColour, destColour, circleCenter); }
790
791 // fill the area specified by rect with a linear gradient
792 void GradientFillLinear(const wxRect& rect,
793 const wxColour& initialColour,
794 const wxColour& destColour,
795 wxDirection nDirection = wxEAST)
796 { m_pimpl->DoGradientFillLinear(rect, initialColour, destColour, nDirection); }
797
798 bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const
799 { return m_pimpl->DoGetPixel(x, y, col); }
800 bool GetPixel(const wxPoint& pt, wxColour *col) const
801 { return m_pimpl->DoGetPixel(pt.x, pt.y, col); }
802
803 void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
804 { m_pimpl->DoDrawLine(x1, y1, x2, y2); }
805 void DrawLine(const wxPoint& pt1, const wxPoint& pt2)
806 { m_pimpl->DoDrawLine(pt1.x, pt1.y, pt2.x, pt2.y); }
807
808 void CrossHair(wxCoord x, wxCoord y)
809 { m_pimpl->DoCrossHair(x, y); }
810 void CrossHair(const wxPoint& pt)
811 { m_pimpl->DoCrossHair(pt.x, pt.y); }
812
813 void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
814 wxCoord xc, wxCoord yc)
815 { m_pimpl->DoDrawArc(x1, y1, x2, y2, xc, yc); }
816 void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre)
817 { m_pimpl->DoDrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y); }
818
819 void DrawCheckMark(wxCoord x, wxCoord y,
820 wxCoord width, wxCoord height)
821 { m_pimpl->DoDrawCheckMark(x, y, width, height); }
822 void DrawCheckMark(const wxRect& rect)
823 { m_pimpl->DoDrawCheckMark(rect.x, rect.y, rect.width, rect.height); }
824
825 void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
826 double sa, double ea)
827 { m_pimpl->DoDrawEllipticArc(x, y, w, h, sa, ea); }
828 void DrawEllipticArc(const wxPoint& pt, const wxSize& sz,
829 double sa, double ea)
830 { m_pimpl->DoDrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea); }
831
832 void DrawPoint(wxCoord x, wxCoord y)
833 { m_pimpl->DoDrawPoint(x, y); }
834 void DrawPoint(const wxPoint& pt)
835 { m_pimpl->DoDrawPoint(pt.x, pt.y); }
836
837 void DrawLines(int n, wxPoint points[],
838 wxCoord xoffset = 0, wxCoord yoffset = 0)
839 { m_pimpl->DoDrawLines(n, points, xoffset, yoffset); }
ca7db61e
RR
840
841#if 0
842 // needs to be removed
b0d7707b 843 void DrawLines(const wxPointList *list,
2970ae54 844 wxCoord xoffset = 0, wxCoord yoffset = 0)
ca7db61e 845#endif
2970ae54
RR
846
847 void DrawPolygon(int n, wxPoint points[],
848 wxCoord xoffset = 0, wxCoord yoffset = 0,
849 int fillStyle = wxODDEVEN_RULE)
850 { m_pimpl->DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); }
851
ca7db61e
RR
852#if 0
853 // needs to be removed
b0d7707b 854 void DrawPolygon(const wxPointList *list,
2970ae54
RR
855 wxCoord xoffset = 0, wxCoord yoffset = 0,
856 int fillStyle = wxODDEVEN_RULE)
857 { m_pimpl->DrawPolygon( list, xoffset, yoffset, fillStyle ); }
ca7db61e 858#endif
2970ae54
RR
859
860 void DrawPolyPolygon(int n, int count[], wxPoint points[],
861 wxCoord xoffset = 0, wxCoord yoffset = 0,
862 int fillStyle = wxODDEVEN_RULE)
863 { m_pimpl->DoDrawPolyPolygon(n, count, points, xoffset, yoffset, fillStyle); }
864
865 void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
866 { m_pimpl->DoDrawRectangle(x, y, width, height); }
867 void DrawRectangle(const wxPoint& pt, const wxSize& sz)
868 { m_pimpl->DoDrawRectangle(pt.x, pt.y, sz.x, sz.y); }
869 void DrawRectangle(const wxRect& rect)
870 { m_pimpl->DoDrawRectangle(rect.x, rect.y, rect.width, rect.height); }
871
872 void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height,
873 double radius)
874 { m_pimpl->DoDrawRoundedRectangle(x, y, width, height, radius); }
875 void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz,
876 double radius)
877 { m_pimpl->DoDrawRoundedRectangle(pt.x, pt.y, sz.x, sz.y, radius); }
878 void DrawRoundedRectangle(const wxRect& r, double radius)
879 { m_pimpl->DoDrawRoundedRectangle(r.x, r.y, r.width, r.height, radius); }
880
881 void DrawCircle(wxCoord x, wxCoord y, wxCoord radius)
882 { m_pimpl->DoDrawEllipse(x - radius, y - radius, 2*radius, 2*radius); }
883 void DrawCircle(const wxPoint& pt, wxCoord radius)
ca7db61e 884 { m_pimpl->DoDrawEllipse(pt.x - radius, pt.y - radius, 2*radius, 2*radius); }
2970ae54
RR
885
886 void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
887 { m_pimpl->DoDrawEllipse(x, y, width, height); }
888 void DrawEllipse(const wxPoint& pt, const wxSize& sz)
889 { m_pimpl->DoDrawEllipse(pt.x, pt.y, sz.x, sz.y); }
890 void DrawEllipse(const wxRect& rect)
891 { m_pimpl->DoDrawEllipse(rect.x, rect.y, rect.width, rect.height); }
892
893 void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
894 { m_pimpl->DoDrawIcon(icon, x, y); }
895 void DrawIcon(const wxIcon& icon, const wxPoint& pt)
896 { m_pimpl->DoDrawIcon(icon, pt.x, pt.y); }
897
898 void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
899 bool useMask = false)
900 { m_pimpl->DoDrawBitmap(bmp, x, y, useMask); }
901 void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt,
902 bool useMask = false)
903 { m_pimpl->DoDrawBitmap(bmp, pt.x, pt.y, useMask); }
904
905 void DrawText(const wxString& text, wxCoord x, wxCoord y)
906 { m_pimpl->DoDrawText(text, x, y); }
907 void DrawText(const wxString& text, const wxPoint& pt)
908 { m_pimpl->DoDrawText(text, pt.x, pt.y); }
909
910 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle)
911 { m_pimpl->DoDrawRotatedText(text, x, y, angle); }
912 void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle)
913 { m_pimpl->DoDrawRotatedText(text, pt.x, pt.y, angle); }
914
915 // this version puts both optional bitmap and the text into the given
916 // rectangle and aligns is as specified by alignment parameter; it also
917 // will emphasize the character with the given index if it is != -1 and
918 // return the bounding rectangle if required
919 void DrawLabel(const wxString& text,
920 const wxBitmap& image,
921 const wxRect& rect,
922 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
923 int indexAccel = -1,
ca7db61e 924 wxRect *rectBounding = NULL);
2970ae54
RR
925
926 void DrawLabel(const wxString& text, const wxRect& rect,
927 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
928 int indexAccel = -1)
ca7db61e 929 { DrawLabel(text, wxNullBitmap, rect, alignment, indexAccel); }
2970ae54
RR
930
931 bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
932 wxDC *source, wxCoord xsrc, wxCoord ysrc,
933 int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord)
934 {
935 return m_pimpl->DoBlit(xdest, ydest, width, height,
936 source, xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask);
937 }
938 bool Blit(const wxPoint& destPt, const wxSize& sz,
939 wxDC *source, const wxPoint& srcPt,
940 int rop = wxCOPY, bool useMask = false, const wxPoint& srcPtMask = wxDefaultPosition)
941 {
942 return m_pimpl->DoBlit(destPt.x, destPt.y, sz.x, sz.y,
943 source, srcPt.x, srcPt.y, rop, useMask, srcPtMask.x, srcPtMask.y);
944 }
945
946 bool StretchBlit(wxCoord dstX, wxCoord dstY,
947 wxCoord dstWidth, wxCoord dstHeight,
948 wxDC *source,
949 wxCoord srcX, wxCoord srcY,
950 wxCoord srcWidth, wxCoord srcHeight,
951 int rop = wxCOPY, bool useMask = false,
952 wxCoord srcMaskX = wxDefaultCoord, wxCoord srcMaskY = wxDefaultCoord)
953 {
954 return m_pimpl->DoStretchBlit(dstX, dstY, dstWidth, dstHeight,
955 source, srcX, srcY, srcWidth, srcHeight, rop, useMask, srcMaskX, srcMaskY);
956 }
957 bool StretchBlit(const wxPoint& dstPt, const wxSize& dstSize,
958 wxDC *source, const wxPoint& srcPt, const wxSize& srcSize,
959 int rop = wxCOPY, bool useMask = false, const wxPoint& srcMaskPt = wxDefaultPosition)
960 {
961 return m_pimpl->DoStretchBlit(dstPt.x, dstPt.y, dstSize.x, dstSize.y,
962 source, srcPt.x, srcPt.y, srcSize.x, srcSize.y, rop, useMask, srcMaskPt.x, srcMaskPt.y);
963 }
964
965 wxBitmap GetAsBitmap(const wxRect *subrect = (const wxRect *) NULL) const
966 {
967 return m_pimpl->DoGetAsBitmap(subrect);
968 }
969
970#if wxUSE_SPLINES
2970ae54
RR
971 void DrawSpline(wxCoord x1, wxCoord y1,
972 wxCoord x2, wxCoord y2,
973 wxCoord x3, wxCoord y3)
ca7db61e 974 { m_pimpl->DoDrawSpline(x1,y1,x2,y2,x3,y3); }
2970ae54 975 void DrawSpline(int n, wxPoint points[])
ca7db61e 976 { m_pimpl->DoDrawSpline(n,points); }
b0d7707b 977 void DrawSpline(const wxPointList *points)
2970ae54
RR
978 { m_pimpl->DoDrawSpline(points); }
979#endif // wxUSE_SPLINES
980
981
982#if WXWIN_COMPATIBILITY_2_8
983 // for compatibility with the old code when wxCoord was long everywhere
984 wxDEPRECATED( void GetTextExtent(const wxString& string,
985 long *x, long *y,
986 long *descent = NULL,
987 long *externalLeading = NULL,
988 const wxFont *theFont = NULL) const );
989 wxDEPRECATED( void GetLogicalOrigin(long *x, long *y) const );
990 wxDEPRECATED( void GetDeviceOrigin(long *x, long *y) const );
991 wxDEPRECATED( void GetClippingBox(long *x, long *y, long *w, long *h) const );
992#endif // WXWIN_COMPATIBILITY_2_8
993
994
995protected:
996 wxImplDC *m_pimpl;
997
998private:
999 DECLARE_ABSTRACT_CLASS(wxImplDC)
ca7db61e 1000};
2970ae54
RR
1001
1002
ca7db61e
RR
1003//-----------------------------------------------------------------------------
1004// wxWindowDC
1005//-----------------------------------------------------------------------------
aec43716 1006
ca7db61e 1007class WXDLLIMPEXP_CORE wxWindowDC : public wxDC
aec43716
KH
1008{
1009public:
ca7db61e
RR
1010 wxWindowDC();
1011 wxWindowDC( wxWindow *win );
aec43716 1012
ca7db61e
RR
1013private:
1014 DECLARE_DYNAMIC_CLASS(wxWindowDC)
1015};
aec43716 1016
ca7db61e
RR
1017//-----------------------------------------------------------------------------
1018// wxClientDC
1019//-----------------------------------------------------------------------------
aec43716 1020
ca7db61e
RR
1021class WXDLLIMPEXP_CORE wxClientDC : public wxDC
1022{
1023public:
1024 wxClientDC();
1025 wxClientDC( wxWindow *win );
aec43716 1026
ca7db61e
RR
1027private:
1028 DECLARE_DYNAMIC_CLASS(wxClientDC)
1029};
aec43716 1030
ca7db61e
RR
1031//-----------------------------------------------------------------------------
1032// wxPaintDC
1033//-----------------------------------------------------------------------------
aec43716 1034
ca7db61e
RR
1035class WXDLLIMPEXP_CORE wxPaintDC : public wxDC
1036{
1037public:
1038 wxPaintDC();
1039 wxPaintDC( wxWindow *win );
aec43716 1040
ca7db61e
RR
1041private:
1042 DECLARE_DYNAMIC_CLASS(wxPaintDC)
1043};
aec43716 1044
ca7db61e 1045#else // wxUSE_NEW_DC
aec43716 1046
aec43716 1047
ca7db61e 1048class WXDLLIMPEXP_FWD_CORE wxDC;
aec43716 1049
a23fd0e1
VZ
1050// ---------------------------------------------------------------------------
1051// global variables
1052// ---------------------------------------------------------------------------
1053
a23fd0e1
VZ
1054// ---------------------------------------------------------------------------
1055// wxDC is the device context - object on which any drawing is done
1056// ---------------------------------------------------------------------------
1057
1058class WXDLLEXPORT wxDCBase : public wxObject
1059{
a23fd0e1 1060public:
04ab8b6d
RR
1061 wxDCBase();
1062 virtual ~wxDCBase();
1063
a23fd0e1
VZ
1064 // graphic primitives
1065 // ------------------
1066
aec43716
KH
1067 virtual void DrawObject(wxDrawObject* drawobject)
1068 {
1069 drawobject->Draw(*this);
1070 CalcBoundingBox(drawobject->MinX(),drawobject->MinY());
1071 CalcBoundingBox(drawobject->MaxX(),drawobject->MaxY());
1072 }
1073
ab171e95
RR
1074 wxDC *GetOwner() const { return (wxDC*) this; }
1075
387ebd3e 1076 bool FloodFill(wxCoord x, wxCoord y, const wxColour& col,
72cdf4c9 1077 int style = wxFLOOD_SURFACE)
387ebd3e
JS
1078 { return DoFloodFill(x, y, col, style); }
1079 bool FloodFill(const wxPoint& pt, const wxColour& col,
72cdf4c9 1080 int style = wxFLOOD_SURFACE)
387ebd3e 1081 { return DoFloodFill(pt.x, pt.y, col, style); }
a23fd0e1 1082
213ad8e7
VZ
1083 // fill the area specified by rect with a radial gradient, starting from
1084 // initialColour in the centre of the cercle and fading to destColour.
1085 void GradientFillConcentric(const wxRect& rect,
4660e6ac 1086 const wxColour& initialColour,
213ad8e7
VZ
1087 const wxColour& destColour)
1088 { GradientFillConcentric(rect, initialColour, destColour,
1089 wxPoint(rect.GetWidth() / 2,
1090 rect.GetHeight() / 2)); }
1091
1092 void GradientFillConcentric(const wxRect& rect,
4660e6ac 1093 const wxColour& initialColour,
213ad8e7 1094 const wxColour& destColour,
fb63a242
SC
1095 const wxPoint& circleCenter)
1096 { DoGradientFillConcentric(rect, initialColour, destColour, circleCenter); }
213ad8e7
VZ
1097
1098 // fill the area specified by rect with a linear gradient
1099 void GradientFillLinear(const wxRect& rect,
4660e6ac 1100 const wxColour& initialColour,
213ad8e7
VZ
1101 const wxColour& destColour,
1102 wxDirection nDirection = wxEAST)
1103 { DoGradientFillLinear(rect, initialColour, destColour, nDirection); }
1104
72cdf4c9 1105 bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const
a23fd0e1
VZ
1106 { return DoGetPixel(x, y, col); }
1107 bool GetPixel(const wxPoint& pt, wxColour *col) const
1108 { return DoGetPixel(pt.x, pt.y, col); }
1109
72cdf4c9 1110 void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
a23fd0e1
VZ
1111 { DoDrawLine(x1, y1, x2, y2); }
1112 void DrawLine(const wxPoint& pt1, const wxPoint& pt2)
1113 { DoDrawLine(pt1.x, pt1.y, pt2.x, pt2.y); }
1114
72cdf4c9 1115 void CrossHair(wxCoord x, wxCoord y)
a23fd0e1
VZ
1116 { DoCrossHair(x, y); }
1117 void CrossHair(const wxPoint& pt)
1118 { DoCrossHair(pt.x, pt.y); }
1119
72cdf4c9
VZ
1120 void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
1121 wxCoord xc, wxCoord yc)
a23fd0e1
VZ
1122 { DoDrawArc(x1, y1, x2, y2, xc, yc); }
1123 void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre)
1124 { DoDrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y); }
1125
cd9da200
VZ
1126 void DrawCheckMark(wxCoord x, wxCoord y,
1127 wxCoord width, wxCoord height)
1128 { DoDrawCheckMark(x, y, width, height); }
1129 void DrawCheckMark(const wxRect& rect)
1130 { DoDrawCheckMark(rect.x, rect.y, rect.width, rect.height); }
1131
72cdf4c9
VZ
1132 void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
1133 double sa, double ea)
7b90a8f2 1134 { DoDrawEllipticArc(x, y, w, h, sa, ea); }
a23fd0e1
VZ
1135 void DrawEllipticArc(const wxPoint& pt, const wxSize& sz,
1136 double sa, double ea)
1137 { DoDrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea); }
1138
72cdf4c9 1139 void DrawPoint(wxCoord x, wxCoord y)
a23fd0e1
VZ
1140 { DoDrawPoint(x, y); }
1141 void DrawPoint(const wxPoint& pt)
1142 { DoDrawPoint(pt.x, pt.y); }
1143
72cdf4c9
VZ
1144 void DrawLines(int n, wxPoint points[],
1145 wxCoord xoffset = 0, wxCoord yoffset = 0)
a23fd0e1 1146 { DoDrawLines(n, points, xoffset, yoffset); }
b0d7707b 1147 void DrawLines(const wxPointList *list,
72cdf4c9 1148 wxCoord xoffset = 0, wxCoord yoffset = 0);
a23fd0e1 1149
b0d7707b
RR
1150#if WXWIN_COMPATIBILITY_2_8
1151 wxDEPRECATED( void DrawLines(const wxList *list,
1152 wxCoord xoffset = 0, wxCoord yoffset = 0) );
1153#endif // WXWIN_COMPATIBILITY_2_8
1154
1155
a23fd0e1 1156 void DrawPolygon(int n, wxPoint points[],
72cdf4c9 1157 wxCoord xoffset = 0, wxCoord yoffset = 0,
a23fd0e1
VZ
1158 int fillStyle = wxODDEVEN_RULE)
1159 { DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); }
1160
b0d7707b 1161 void DrawPolygon(const wxPointList *list,
72cdf4c9 1162 wxCoord xoffset = 0, wxCoord yoffset = 0,
bd5dd957 1163 int fillStyle = wxODDEVEN_RULE);
a23fd0e1 1164
b0d7707b
RR
1165#if WXWIN_COMPATIBILITY_2_8
1166 wxDEPRECATED( void DrawPolygon(const wxList *list,
1167 wxCoord xoffset = 0, wxCoord yoffset = 0,
1168 int fillStyle = wxODDEVEN_RULE) );
1169#endif // WXWIN_COMPATIBILITY_2_8
1170
793db755 1171 void DrawPolyPolygon(int n, int count[], wxPoint points[],
6e76b35d
VZ
1172 wxCoord xoffset = 0, wxCoord yoffset = 0,
1173 int fillStyle = wxODDEVEN_RULE)
793db755 1174 { DoDrawPolyPolygon(n, count, points, xoffset, yoffset, fillStyle); }
6e76b35d 1175
72cdf4c9 1176 void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
a23fd0e1
VZ
1177 { DoDrawRectangle(x, y, width, height); }
1178 void DrawRectangle(const wxPoint& pt, const wxSize& sz)
1179 { DoDrawRectangle(pt.x, pt.y, sz.x, sz.y); }
1180 void DrawRectangle(const wxRect& rect)
1181 { DoDrawRectangle(rect.x, rect.y, rect.width, rect.height); }
1182
72cdf4c9 1183 void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height,
a23fd0e1
VZ
1184 double radius)
1185 { DoDrawRoundedRectangle(x, y, width, height, radius); }
1186 void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz,
1187 double radius)
1188 { DoDrawRoundedRectangle(pt.x, pt.y, sz.x, sz.y, radius); }
1189 void DrawRoundedRectangle(const wxRect& r, double radius)
1190 { DoDrawRoundedRectangle(r.x, r.y, r.width, r.height, radius); }
1191
72cdf4c9 1192 void DrawCircle(wxCoord x, wxCoord y, wxCoord radius)
220af862 1193 { DoDrawEllipse(x - radius, y - radius, 2*radius, 2*radius); }
0371e9a8 1194 void DrawCircle(const wxPoint& pt, wxCoord radius)
b95edd47 1195 { DrawCircle(pt.x, pt.y, radius); }
0371e9a8 1196
72cdf4c9 1197 void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
a23fd0e1
VZ
1198 { DoDrawEllipse(x, y, width, height); }
1199 void DrawEllipse(const wxPoint& pt, const wxSize& sz)
1200 { DoDrawEllipse(pt.x, pt.y, sz.x, sz.y); }
1201 void DrawEllipse(const wxRect& rect)
1202 { DoDrawEllipse(rect.x, rect.y, rect.width, rect.height); }
1203
72cdf4c9 1204 void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
a23fd0e1
VZ
1205 { DoDrawIcon(icon, x, y); }
1206 void DrawIcon(const wxIcon& icon, const wxPoint& pt)
1207 { DoDrawIcon(icon, pt.x, pt.y); }
1208
72cdf4c9 1209 void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
68379eaf 1210 bool useMask = false)
a23fd0e1
VZ
1211 { DoDrawBitmap(bmp, x, y, useMask); }
1212 void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt,
68379eaf 1213 bool useMask = false)
a23fd0e1
VZ
1214 { DoDrawBitmap(bmp, pt.x, pt.y, useMask); }
1215
72cdf4c9 1216 void DrawText(const wxString& text, wxCoord x, wxCoord y)
a23fd0e1
VZ
1217 { DoDrawText(text, x, y); }
1218 void DrawText(const wxString& text, const wxPoint& pt)
1219 { DoDrawText(text, pt.x, pt.y); }
1220
95724b1a
VZ
1221 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle)
1222 { DoDrawRotatedText(text, x, y, angle); }
1223 void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle)
1224 { DoDrawRotatedText(text, pt.x, pt.y, angle); }
1225
1e6feb95
VZ
1226 // this version puts both optional bitmap and the text into the given
1227 // rectangle and aligns is as specified by alignment parameter; it also
1228 // will emphasize the character with the given index if it is != -1 and
1229 // return the bounding rectangle if required
1230 virtual void DrawLabel(const wxString& text,
1231 const wxBitmap& image,
1232 const wxRect& rect,
1233 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
1234 int indexAccel = -1,
1235 wxRect *rectBounding = NULL);
1236
1237 void DrawLabel(const wxString& text, const wxRect& rect,
1238 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
1239 int indexAccel = -1)
1240 { DrawLabel(text, wxNullBitmap, rect, alignment, indexAccel); }
1241
72cdf4c9
VZ
1242 bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
1243 wxDC *source, wxCoord xsrc, wxCoord ysrc,
68379eaf 1244 int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord)
a23fd0e1
VZ
1245 {
1246 return DoBlit(xdest, ydest, width, height,
0cbff120 1247 source, xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask);
a23fd0e1
VZ
1248 }
1249 bool Blit(const wxPoint& destPt, const wxSize& sz,
1250 wxDC *source, const wxPoint& srcPt,
68379eaf 1251 int rop = wxCOPY, bool useMask = false, const wxPoint& srcPtMask = wxDefaultPosition)
a23fd0e1
VZ
1252 {
1253 return DoBlit(destPt.x, destPt.y, sz.x, sz.y,
0cbff120 1254 source, srcPt.x, srcPt.y, rop, useMask, srcPtMask.x, srcPtMask.y);
a23fd0e1 1255 }
e3b81044
VZ
1256
1257 bool StretchBlit(wxCoord dstX, wxCoord dstY,
1258 wxCoord dstWidth, wxCoord dstHeight,
1259 wxDC *source,
1260 wxCoord srcX, wxCoord srcY,
1261 wxCoord srcWidth, wxCoord srcHeight,
1262 int rop = wxCOPY, bool useMask = false,
1263 wxCoord srcMaskX = wxDefaultCoord, wxCoord srcMaskY = wxDefaultCoord)
1264 {
1265 return DoStretchBlit(dstX, dstY, dstWidth, dstHeight,
1266 source, srcX, srcY, srcWidth, srcHeight, rop, useMask, srcMaskX, srcMaskY);
1267 }
1268 bool StretchBlit(const wxPoint& dstPt, const wxSize& dstSize,
1269 wxDC *source, const wxPoint& srcPt, const wxSize& srcSize,
1270 int rop = wxCOPY, bool useMask = false, const wxPoint& srcMaskPt = wxDefaultPosition)
1271 {
1272 return DoStretchBlit(dstPt.x, dstPt.y, dstSize.x, dstSize.y,
1273 source, srcPt.x, srcPt.y, srcSize.x, srcSize.y, rop, useMask, srcMaskPt.x, srcMaskPt.y);
1274 }
1275
c59abe03 1276 wxBitmap GetAsBitmap(const wxRect *subrect = (const wxRect *) NULL) const
c64c9cd3 1277 {
c59abe03 1278 return DoGetAsBitmap(subrect);
c64c9cd3 1279 }
a23fd0e1
VZ
1280
1281#if wxUSE_SPLINES
72cdf4c9
VZ
1282 void DrawSpline(wxCoord x1, wxCoord y1,
1283 wxCoord x2, wxCoord y2,
1284 wxCoord x3, wxCoord y3);
bd5dd957 1285 void DrawSpline(int n, wxPoint points[]);
a23fd0e1 1286
b0d7707b
RR
1287 void DrawSpline(const wxPointList *points) { DoDrawSpline(points); }
1288
1289#if WXWIN_COMPATIBILITY_2_8
1290 wxDEPRECATED( void DrawSpline(const wxList *points) );
1291#endif // WXWIN_COMPATIBILITY_2_8
1292
a23fd0e1
VZ
1293#endif // wxUSE_SPLINES
1294
12bdd77c
JS
1295 // Eventually we will have wxUSE_GENERIC_DRAWELLIPSE
1296#ifdef __WXWINCE__
1297 //! Generic method to draw ellipses, circles and arcs with current pen and brush.
1298 /*! \param x Upper left corner of bounding box.
1299 * \param y Upper left corner of bounding box.
1300 * \param w Width of bounding box.
1301 * \param h Height of bounding box.
d16b634f 1302 * \param sa Starting angle of arc
12bdd77c
JS
1303 * (counterclockwise, start at 3 o'clock, 360 is full circle).
1304 * \param ea Ending angle of arc.
d16b634f 1305 * \param angle Rotation angle, the Arc will be rotated after
12bdd77c
JS
1306 * calculating begin and end.
1307 */
d16b634f
VZ
1308 void DrawEllipticArcRot( wxCoord x, wxCoord y,
1309 wxCoord width, wxCoord height,
12bdd77c
JS
1310 double sa = 0, double ea = 0, double angle = 0 )
1311 { DoDrawEllipticArcRot( x, y, width, height, sa, ea, angle ); }
d16b634f
VZ
1312
1313 void DrawEllipticArcRot( const wxPoint& pt,
12bdd77c
JS
1314 const wxSize& sz,
1315 double sa = 0, double ea = 0, double angle = 0 )
1316 { DoDrawEllipticArcRot( pt.x, pt.y, sz.x, sz.y, sa, ea, angle ); }
1317
1318 void DrawEllipticArcRot( const wxRect& rect,
1319 double sa = 0, double ea = 0, double angle = 0 )
1320 { DoDrawEllipticArcRot( rect.x, rect.y, rect.width, rect.height, sa, ea, angle ); }
1321
d16b634f
VZ
1322 virtual void DoDrawEllipticArcRot( wxCoord x, wxCoord y,
1323 wxCoord w, wxCoord h,
12bdd77c 1324 double sa = 0, double ea = 0, double angle = 0 );
d16b634f 1325
12bdd77c
JS
1326 //! Rotates points around center.
1327 /*! This is a quite straight method, it calculates in pixels
1328 * and so it produces rounding errors.
1329 * \param points The points inside will be rotated.
1330 * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle).
1331 * \param center Center of rotation.
d16b634f 1332 */
b0d7707b 1333 void Rotate( wxPointList* points, double angle, wxPoint center = wxPoint(0,0) );
12bdd77c
JS
1334
1335 // used by DrawEllipticArcRot
1336 // Careful: wxList gets filled with points you have to delete later.
b0d7707b 1337 void CalculateEllipticPoints( wxPointList* points,
d16b634f
VZ
1338 wxCoord xStart, wxCoord yStart,
1339 wxCoord w, wxCoord h,
12bdd77c
JS
1340 double sa, double ea );
1341#endif
d16b634f 1342
a23fd0e1
VZ
1343 // global DC operations
1344 // --------------------
1345
1346 virtual void Clear() = 0;
1347
68379eaf 1348 virtual bool StartDoc(const wxString& WXUNUSED(message)) { return true; }
af0bb3b1 1349 virtual void EndDoc() { }
a23fd0e1 1350
af0bb3b1
VZ
1351 virtual void StartPage() { }
1352 virtual void EndPage() { }
a23fd0e1 1353
2e992e06
VZ
1354#if WXWIN_COMPATIBILITY_2_6
1355 wxDEPRECATED( void BeginDrawing() );
1356 wxDEPRECATED( void EndDrawing() );
1357#endif // WXWIN_COMPATIBILITY_2_6
1358
1359
a23fd0e1
VZ
1360 // set objects to use for drawing
1361 // ------------------------------
1362
1363 virtual void SetFont(const wxFont& font) = 0;
1364 virtual void SetPen(const wxPen& pen) = 0;
1365 virtual void SetBrush(const wxBrush& brush) = 0;
1366 virtual void SetBackground(const wxBrush& brush) = 0;
1367 virtual void SetBackgroundMode(int mode) = 0;
d275c7eb 1368#if wxUSE_PALETTE
a23fd0e1 1369 virtual void SetPalette(const wxPalette& palette) = 0;
d275c7eb 1370#endif // wxUSE_PALETTE
a23fd0e1
VZ
1371
1372 // clipping region
1373 // ---------------
1374
72cdf4c9 1375 void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
a23fd0e1
VZ
1376 { DoSetClippingRegion(x, y, width, height); }
1377 void SetClippingRegion(const wxPoint& pt, const wxSize& sz)
1378 { DoSetClippingRegion(pt.x, pt.y, sz.x, sz.y); }
1379 void SetClippingRegion(const wxRect& rect)
1380 { DoSetClippingRegion(rect.x, rect.y, rect.width, rect.height); }
1381 void SetClippingRegion(const wxRegion& region)
1382 { DoSetClippingRegionAsRegion(region); }
1383
d16b634f 1384 virtual void DestroyClippingRegion() { ResetClipping(); }
a23fd0e1 1385
72cdf4c9 1386 void GetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const
a23fd0e1
VZ
1387 { DoGetClippingBox(x, y, w, h); }
1388 void GetClippingBox(wxRect& rect) const
8fb3a512 1389 {
ae500232 1390 DoGetClippingBox(&rect.x, &rect.y, &rect.width, &rect.height);
8fb3a512 1391 }
a23fd0e1
VZ
1392
1393 // text extent
1394 // -----------
1395
72cdf4c9
VZ
1396 virtual wxCoord GetCharHeight() const = 0;
1397 virtual wxCoord GetCharWidth() const = 0;
cd9da200 1398
1e6feb95 1399 // only works for single line strings
72cdf4c9
VZ
1400 void GetTextExtent(const wxString& string,
1401 wxCoord *x, wxCoord *y,
1402 wxCoord *descent = NULL,
1403 wxCoord *externalLeading = NULL,
c94f845b 1404 const wxFont *theFont = NULL) const
72cdf4c9 1405 { DoGetTextExtent(string, x, y, descent, externalLeading, theFont); }
a23fd0e1 1406
cc4f194e
VZ
1407 wxSize GetTextExtent(const wxString& string) const
1408 {
1409 wxCoord w, h;
1410 DoGetTextExtent(string, &w, &h);
1411 return wxSize(w, h);
1412 }
1413
1e6feb95 1414 // works for single as well as multi-line strings
cc4f194e 1415 virtual void GetMultiLineTextExtent(const wxString& string,
1e6feb95
VZ
1416 wxCoord *width,
1417 wxCoord *height,
1418 wxCoord *heightLine = NULL,
c94f845b 1419 const wxFont *font = NULL) const;
1e6feb95 1420
cc4f194e
VZ
1421 wxSize GetMultiLineTextExtent(const wxString& string) const
1422 {
1423 wxCoord w, h;
1424 GetMultiLineTextExtent(string, &w, &h);
1425 return wxSize(w, h);
1426 }
1427
0919e93e
RD
1428 // Measure cumulative width of text after each character
1429 bool GetPartialTextExtents(const wxString& text, wxArrayInt& widths) const
1430 { return DoGetPartialTextExtents(text, widths); }
1431
d16b634f 1432
a23fd0e1
VZ
1433 // size and resolution
1434 // -------------------
1435
1436 // in device units
1437 void GetSize(int *width, int *height) const
1438 { DoGetSize(width, height); }
1439 wxSize GetSize() const
1440 {
1441 int w, h;
1442 DoGetSize(&w, &h);
1443
1444 return wxSize(w, h);
1445 }
1446
1447 // in mm
1448 void GetSizeMM(int* width, int* height) const
1449 { DoGetSizeMM(width, height); }
1450 wxSize GetSizeMM() const
1451 {
1452 int w, h;
1453 DoGetSizeMM(&w, &h);
1454
1455 return wxSize(w, h);
1456 }
1457
a23fd0e1
VZ
1458 // query DC capabilities
1459 // ---------------------
1460
1461 virtual bool CanDrawBitmap() const = 0;
1462 virtual bool CanGetTextExtent() const = 0;
1463
1464 // colour depth
1465 virtual int GetDepth() const = 0;
1466
1467 // Resolution in Pixels per inch
1468 virtual wxSize GetPPI() const = 0;
1469
b7cacb43
VZ
1470 virtual bool Ok() const { return IsOk(); }
1471 virtual bool IsOk() const { return m_ok; }
a23fd0e1 1472
2439f37a
VZ
1473 // accessors and setters
1474 // ---------------------
a23fd0e1 1475
2e992e06
VZ
1476 virtual int GetBackgroundMode() const { return m_backgroundMode; }
1477 virtual const wxBrush& GetBackground() const { return m_backgroundBrush; }
1478 virtual const wxBrush& GetBrush() const { return m_brush; }
1479 virtual const wxFont& GetFont() const { return m_font; }
1480 virtual const wxPen& GetPen() const { return m_pen; }
a23fd0e1 1481
2e992e06
VZ
1482 virtual const wxColour& GetTextForeground() const { return m_textForegroundColour; }
1483 virtual const wxColour& GetTextBackground() const { return m_textBackgroundColour; }
a23fd0e1
VZ
1484 virtual void SetTextForeground(const wxColour& colour)
1485 { m_textForegroundColour = colour; }
1486 virtual void SetTextBackground(const wxColour& colour)
1487 { m_textBackgroundColour = colour; }
1488
04ab8b6d
RR
1489
1490 // coordinates conversions and transforms
1491 // --------------------------------------
1492
1493 virtual wxCoord DeviceToLogicalX(wxCoord x) const;
1494 virtual wxCoord DeviceToLogicalY(wxCoord y) const;
1495 virtual wxCoord DeviceToLogicalXRel(wxCoord x) const;
1496 virtual wxCoord DeviceToLogicalYRel(wxCoord y) const;
1497 virtual wxCoord LogicalToDeviceX(wxCoord x) const;
1498 virtual wxCoord LogicalToDeviceY(wxCoord y) const;
1499 virtual wxCoord LogicalToDeviceXRel(wxCoord x) const;
1500 virtual wxCoord LogicalToDeviceYRel(wxCoord y) const;
1501
1502 virtual void SetMapMode(int mode);
2e992e06 1503 virtual int GetMapMode() const { return m_mappingMode; }
a23fd0e1 1504
04ab8b6d 1505 virtual void SetUserScale(double x, double y);
a23fd0e1
VZ
1506 virtual void GetUserScale(double *x, double *y) const
1507 {
1508 if ( x ) *x = m_userScaleX;
1509 if ( y ) *y = m_userScaleY;
1510 }
a23fd0e1 1511
04ab8b6d 1512 virtual void SetLogicalScale(double x, double y);
a23fd0e1
VZ
1513 virtual void GetLogicalScale(double *x, double *y)
1514 {
1515 if ( x ) *x = m_logicalScaleX;
1516 if ( y ) *y = m_logicalScaleY;
1517 }
a23fd0e1 1518
04ab8b6d 1519 virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
72cdf4c9 1520 void GetLogicalOrigin(wxCoord *x, wxCoord *y) const
a23fd0e1
VZ
1521 { DoGetLogicalOrigin(x, y); }
1522 wxPoint GetLogicalOrigin() const
72cdf4c9 1523 { wxCoord x, y; DoGetLogicalOrigin(&x, &y); return wxPoint(x, y); }
a23fd0e1 1524
04ab8b6d 1525 virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
72cdf4c9 1526 void GetDeviceOrigin(wxCoord *x, wxCoord *y) const
a23fd0e1
VZ
1527 { DoGetDeviceOrigin(x, y); }
1528 wxPoint GetDeviceOrigin() const
72cdf4c9 1529 { wxCoord x, y; DoGetDeviceOrigin(&x, &y); return wxPoint(x, y); }
04ab8b6d
RR
1530
1531 virtual void SetDeviceLocalOrigin( wxCoord x, wxCoord y );
a23fd0e1 1532
04ab8b6d 1533 virtual void ComputeScaleAndOrigin();
b1263dcf 1534
04ab8b6d
RR
1535 // this needs to overidden if the axis is inverted (such
1536 // as when using Postscript, where 0,0 is the lower left
1537 // corner, not the upper left).
1538 virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
a23fd0e1 1539
04ab8b6d
RR
1540 // logical functions
1541 // ---------------------------
1542
2e992e06 1543 virtual int GetLogicalFunction() const { return m_logicalFunction; }
a23fd0e1
VZ
1544 virtual void SetLogicalFunction(int function) = 0;
1545
a23fd0e1
VZ
1546 // bounding box
1547 // ------------
1548
72cdf4c9 1549 virtual void CalcBoundingBox(wxCoord x, wxCoord y)
a23fd0e1 1550 {
f6bcfd97
BP
1551 if ( m_isBBoxValid )
1552 {
1553 if ( x < m_minX ) m_minX = x;
1554 if ( y < m_minY ) m_minY = y;
1555 if ( x > m_maxX ) m_maxX = x;
1556 if ( y > m_maxY ) m_maxY = y;
1557 }
1558 else
1559 {
68379eaf 1560 m_isBBoxValid = true;
f6bcfd97
BP
1561
1562 m_minX = x;
1563 m_minY = y;
1564 m_maxX = x;
1565 m_maxY = y;
1566 }
1567 }
1568
1569 void ResetBoundingBox()
1570 {
68379eaf 1571 m_isBBoxValid = false;
f6bcfd97
BP
1572
1573 m_minX = m_maxX = m_minY = m_maxY = 0;
a23fd0e1
VZ
1574 }
1575
1576 // Get the final bounding box of the PostScript or Metafile picture.
72cdf4c9
VZ
1577 wxCoord MinX() const { return m_minX; }
1578 wxCoord MaxX() const { return m_maxX; }
1579 wxCoord MinY() const { return m_minY; }
1580 wxCoord MaxY() const { return m_maxY; }
a23fd0e1
VZ
1581
1582 // misc old functions
1583 // ------------------
1584
ad973712 1585#if WXWIN_COMPATIBILITY_2_8
72cdf4c9 1586 // for compatibility with the old code when wxCoord was long everywhere
1f540d96 1587 wxDEPRECATED( void GetTextExtent(const wxString& string,
72cdf4c9
VZ
1588 long *x, long *y,
1589 long *descent = NULL,
1590 long *externalLeading = NULL,
cfa87e81
RR
1591 const wxFont *theFont = NULL) const );
1592 wxDEPRECATED( void GetLogicalOrigin(long *x, long *y) const );
1593 wxDEPRECATED( void GetDeviceOrigin(long *x, long *y) const );
1594 wxDEPRECATED( void GetClippingBox(long *x, long *y, long *w, long *h) const );
ad973712 1595#endif // WXWIN_COMPATIBILITY_2_8
72cdf4c9 1596
6ae7410f
VZ
1597 // RTL related functions
1598 // ---------------------
1599
1600 // get or change the layout direction (LTR or RTL) for this dc,
1601 // wxLayout_Default is returned if layout direction is not supported
1602 virtual wxLayoutDirection GetLayoutDirection() const
1603 { return wxLayout_Default; }
1604 virtual void SetLayoutDirection(wxLayoutDirection WXUNUSED(dir))
1605 { }
1606
a23fd0e1
VZ
1607protected:
1608 // the pure virtual functions which should be implemented by wxDC
387ebd3e 1609 virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
a23fd0e1
VZ
1610 int style = wxFLOOD_SURFACE) = 0;
1611
213ad8e7
VZ
1612 virtual void DoGradientFillLinear(const wxRect& rect,
1613 const wxColour& initialColour,
1614 const wxColour& destColour,
1615 wxDirection nDirection = wxEAST);
4660e6ac 1616
fb63a242
SC
1617 virtual void DoGradientFillConcentric(const wxRect& rect,
1618 const wxColour& initialColour,
1619 const wxColour& destColour,
1620 const wxPoint& circleCenter);
1621
72cdf4c9 1622 virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const = 0;
a23fd0e1 1623
72cdf4c9
VZ
1624 virtual void DoDrawPoint(wxCoord x, wxCoord y) = 0;
1625 virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) = 0;
a23fd0e1 1626
72cdf4c9
VZ
1627 virtual void DoDrawArc(wxCoord x1, wxCoord y1,
1628 wxCoord x2, wxCoord y2,
1629 wxCoord xc, wxCoord yc) = 0;
cd9da200
VZ
1630 virtual void DoDrawCheckMark(wxCoord x, wxCoord y,
1631 wxCoord width, wxCoord height);
72cdf4c9 1632 virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
a23fd0e1
VZ
1633 double sa, double ea) = 0;
1634
72cdf4c9
VZ
1635 virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) = 0;
1636 virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
1637 wxCoord width, wxCoord height,
a23fd0e1 1638 double radius) = 0;
72cdf4c9
VZ
1639 virtual void DoDrawEllipse(wxCoord x, wxCoord y,
1640 wxCoord width, wxCoord height) = 0;
a23fd0e1 1641
72cdf4c9 1642 virtual void DoCrossHair(wxCoord x, wxCoord y) = 0;
a23fd0e1 1643
72cdf4c9
VZ
1644 virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) = 0;
1645 virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
68379eaf 1646 bool useMask = false) = 0;
a23fd0e1 1647
72cdf4c9 1648 virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y) = 0;
95724b1a
VZ
1649 virtual void DoDrawRotatedText(const wxString& text,
1650 wxCoord x, wxCoord y, double angle) = 0;
a23fd0e1 1651
72cdf4c9
VZ
1652 virtual bool DoBlit(wxCoord xdest, wxCoord ydest,
1653 wxCoord width, wxCoord height,
e3b81044
VZ
1654 wxDC *source,
1655 wxCoord xsrc, wxCoord ysrc,
1656 int rop = wxCOPY,
1657 bool useMask = false,
1658 wxCoord xsrcMask = wxDefaultCoord,
1659 wxCoord ysrcMask = wxDefaultCoord) = 0;
1660
1661 virtual bool DoStretchBlit(wxCoord xdest, wxCoord ydest,
1662 wxCoord dstWidth, wxCoord dstHeight,
1663 wxDC *source,
1664 wxCoord xsrc, wxCoord ysrc,
1665 wxCoord srcWidth, wxCoord srcHeight,
1666 int rop = wxCOPY,
1667 bool useMask = false,
1668 wxCoord xsrcMask = wxDefaultCoord,
1669 wxCoord ysrcMask = wxDefaultCoord);
1670
1671 virtual wxBitmap DoGetAsBitmap(const wxRect *WXUNUSED(subrect)) const
1672 { return wxNullBitmap; }
c64c9cd3 1673
a23fd0e1
VZ
1674 virtual void DoGetSize(int *width, int *height) const = 0;
1675 virtual void DoGetSizeMM(int* width, int* height) const = 0;
1676
1677 virtual void DoDrawLines(int n, wxPoint points[],
72cdf4c9 1678 wxCoord xoffset, wxCoord yoffset) = 0;
a23fd0e1 1679 virtual void DoDrawPolygon(int n, wxPoint points[],
72cdf4c9 1680 wxCoord xoffset, wxCoord yoffset,
a23fd0e1 1681 int fillStyle = wxODDEVEN_RULE) = 0;
793db755 1682 virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[],
6e76b35d
VZ
1683 wxCoord xoffset, wxCoord yoffset,
1684 int fillStyle);
a23fd0e1
VZ
1685
1686 virtual void DoSetClippingRegionAsRegion(const wxRegion& region) = 0;
72cdf4c9
VZ
1687 virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
1688 wxCoord width, wxCoord height) = 0;
b0e0d661 1689
72cdf4c9
VZ
1690 virtual void DoGetClippingBox(wxCoord *x, wxCoord *y,
1691 wxCoord *w, wxCoord *h) const
a23fd0e1 1692 {
d16b634f
VZ
1693 if ( x )
1694 *x = m_clipX1;
1695 if ( y )
1696 *y = m_clipY1;
1697 if ( w )
1698 *w = m_clipX2 - m_clipX1;
1699 if ( h )
1700 *h = m_clipY2 - m_clipY1;
a23fd0e1
VZ
1701 }
1702
72cdf4c9 1703 virtual void DoGetLogicalOrigin(wxCoord *x, wxCoord *y) const
a23fd0e1
VZ
1704 {
1705 if ( x ) *x = m_logicalOriginX;
1706 if ( y ) *y = m_logicalOriginY;
1707 }
1708
72cdf4c9 1709 virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const
a23fd0e1
VZ
1710 {
1711 if ( x ) *x = m_deviceOriginX;
1712 if ( y ) *y = m_deviceOriginY;
1713 }
1714
72cdf4c9
VZ
1715 virtual void DoGetTextExtent(const wxString& string,
1716 wxCoord *x, wxCoord *y,
1717 wxCoord *descent = NULL,
1718 wxCoord *externalLeading = NULL,
c94f845b 1719 const wxFont *theFont = NULL) const = 0;
d16b634f 1720
0919e93e 1721 virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
d16b634f 1722
64698f9a 1723#if wxUSE_SPLINES
b0d7707b 1724 virtual void DoDrawSpline(const wxPointList *points);
64698f9a 1725#endif
a23fd0e1
VZ
1726
1727protected:
d16b634f
VZ
1728 // unset clipping variables (after clipping region was destroyed)
1729 void ResetClipping()
1730 {
1731 m_clipping = false;
1732
1733 m_clipX1 = m_clipX2 = m_clipY1 = m_clipY2 = 0;
1734 }
1735
a23fd0e1
VZ
1736 // flags
1737 bool m_colour:1;
1738 bool m_ok:1;
1739 bool m_clipping:1;
1740 bool m_isInteractive:1;
f6bcfd97 1741 bool m_isBBoxValid:1;
a23fd0e1
VZ
1742
1743 // coordinate system variables
1744
1745 // TODO short descriptions of what exactly they are would be nice...
1746
72cdf4c9 1747 wxCoord m_logicalOriginX, m_logicalOriginY;
04ab8b6d
RR
1748 wxCoord m_deviceOriginX, m_deviceOriginY; // Usually 0,0, can be change by user
1749
1750 wxCoord m_deviceLocalOriginX, m_deviceLocalOriginY; // non-zero if native top-left corner
1751 // is not at 0,0. This was the case under
1752 // Mac's GrafPorts (coordinate system
1753 // used toplevel window's origin) and
1754 // e.g. for Postscript, where the native
1755 // origin in the bottom left corner.
a23fd0e1
VZ
1756 double m_logicalScaleX, m_logicalScaleY;
1757 double m_userScaleX, m_userScaleY;
04ab8b6d 1758 double m_scaleX, m_scaleY; // calculated from logical scale and user scale
a23fd0e1
VZ
1759
1760 // Used by SetAxisOrientation() to invert the axes
1761 int m_signX, m_signY;
1762
04ab8b6d
RR
1763 // what is a mm on a screen you don't know the size of?
1764 double m_mm_to_pix_x,
1765 m_mm_to_pix_y;
1766
a23fd0e1 1767 // bounding and clipping boxes
72cdf4c9
VZ
1768 wxCoord m_minX, m_minY, m_maxX, m_maxY;
1769 wxCoord m_clipX1, m_clipY1, m_clipX2, m_clipY2;
a23fd0e1
VZ
1770
1771 int m_logicalFunction;
1772 int m_backgroundMode;
1773 int m_mappingMode;
1774
1775 // GDI objects
1776 wxPen m_pen;
1777 wxBrush m_brush;
1778 wxBrush m_backgroundBrush;
1779 wxColour m_textForegroundColour;
1780 wxColour m_textBackgroundColour;
1781 wxFont m_font;
d275c7eb
VZ
1782
1783#if wxUSE_PALETTE
a23fd0e1 1784 wxPalette m_palette;
b95edd47 1785 bool m_hasCustomPalette;
d275c7eb 1786#endif // wxUSE_PALETTE
a23fd0e1
VZ
1787
1788private:
ac84e37d 1789 DECLARE_NO_COPY_CLASS(wxDCBase)
cd9da200 1790 DECLARE_ABSTRACT_CLASS(wxDCBase)
a23fd0e1
VZ
1791};
1792
2970ae54
RR
1793#endif // wxUSE_NEW_DC
1794
a23fd0e1
VZ
1795// ----------------------------------------------------------------------------
1796// now include the declaration of wxDC class
1797// ----------------------------------------------------------------------------
1798
4055ed82 1799#if defined(__WXPALMOS__)
ffecfa5a
JS
1800 #include "wx/palmos/dc.h"
1801#elif defined(__WXMSW__)
a23fd0e1 1802 #include "wx/msw/dc.h"
2049ba38 1803#elif defined(__WXMOTIF__)
a23fd0e1 1804 #include "wx/motif/dc.h"
1be7a35c 1805#elif defined(__WXGTK20__)
a23fd0e1 1806 #include "wx/gtk/dc.h"
1be7a35c
MR
1807#elif defined(__WXGTK__)
1808 #include "wx/gtk1/dc.h"
83df96d6
JS
1809#elif defined(__WXX11__)
1810 #include "wx/x11/dc.h"
1e6feb95
VZ
1811#elif defined(__WXMGL__)
1812 #include "wx/mgl/dc.h"
b3c86150
VS
1813#elif defined(__WXDFB__)
1814 #include "wx/dfb/dc.h"
34138703 1815#elif defined(__WXMAC__)
a23fd0e1 1816 #include "wx/mac/dc.h"
f4515f98
DE
1817#elif defined(__WXCOCOA__)
1818 #include "wx/cocoa/dc.h"
1777b9bb
DW
1819#elif defined(__WXPM__)
1820 #include "wx/os2/dc.h"
c801d85f
KB
1821#endif
1822
8acd14d1
SC
1823#if wxUSE_GRAPHICS_CONTEXT
1824 #include "wx/dcgraph.h"
1825#endif
1826
1e6feb95
VZ
1827// ----------------------------------------------------------------------------
1828// helper class: you can use it to temporarily change the DC text colour and
1829// restore it automatically when the object goes out of scope
1830// ----------------------------------------------------------------------------
1831
1832class WXDLLEXPORT wxDCTextColourChanger
1833{
1834public:
ba161d7e 1835 wxDCTextColourChanger(wxDC& dc) : m_dc(dc), m_colFgOld() { }
1e6feb95 1836
1b97b23d
VS
1837 wxDCTextColourChanger(wxDC& dc, const wxColour& col) : m_dc(dc)
1838 {
1839 Set(col);
1840 }
1841
1e6feb95
VZ
1842 ~wxDCTextColourChanger()
1843 {
1844 if ( m_colFgOld.Ok() )
1845 m_dc.SetTextForeground(m_colFgOld);
1846 }
1847
1848 void Set(const wxColour& col)
1849 {
1850 if ( !m_colFgOld.Ok() )
1851 m_colFgOld = m_dc.GetTextForeground();
1852 m_dc.SetTextForeground(col);
1853 }
1854
1855private:
1856 wxDC& m_dc;
1857
1858 wxColour m_colFgOld;
fc7a2a60
VZ
1859
1860 DECLARE_NO_COPY_CLASS(wxDCTextColourChanger)
1e6feb95
VZ
1861};
1862
4660e6ac
WS
1863// ----------------------------------------------------------------------------
1864// helper class: you can use it to temporarily change the DC pen and
1865// restore it automatically when the object goes out of scope
1866// ----------------------------------------------------------------------------
1867
1868class WXDLLEXPORT wxDCPenChanger
1869{
1870public:
0164f8eb
WS
1871 wxDCPenChanger(wxDC& dc, const wxPen& pen) : m_dc(dc), m_penOld(dc.GetPen())
1872 {
1873 m_dc.SetPen(pen);
1874 }
4660e6ac
WS
1875
1876 ~wxDCPenChanger()
1877 {
1878 if ( m_penOld.Ok() )
1879 m_dc.SetPen(m_penOld);
1880 }
1881
4660e6ac
WS
1882private:
1883 wxDC& m_dc;
1884
1885 wxPen m_penOld;
1886
1887 DECLARE_NO_COPY_CLASS(wxDCPenChanger)
1888};
1889
1890// ----------------------------------------------------------------------------
1891// helper class: you can use it to temporarily change the DC brush and
1892// restore it automatically when the object goes out of scope
1893// ----------------------------------------------------------------------------
1894
1895class WXDLLEXPORT wxDCBrushChanger
1896{
1897public:
0164f8eb
WS
1898 wxDCBrushChanger(wxDC& dc, const wxBrush& brush) : m_dc(dc), m_brushOld(dc.GetBrush())
1899 {
1900 m_dc.SetBrush(brush);
1901 }
4660e6ac
WS
1902
1903 ~wxDCBrushChanger()
1904 {
1905 if ( m_brushOld.Ok() )
1906 m_dc.SetBrush(m_brushOld);
1907 }
1908
4660e6ac
WS
1909private:
1910 wxDC& m_dc;
1911
1912 wxBrush m_brushOld;
1913
1914 DECLARE_NO_COPY_CLASS(wxDCBrushChanger)
1915};
1916
e26be42b
VZ
1917// ----------------------------------------------------------------------------
1918// another small helper class: sets the clipping region in its ctor and
1919// destroys it in the dtor
1920// ----------------------------------------------------------------------------
1921
1922class WXDLLEXPORT wxDCClipper
1923{
1924public:
fc298ea7
VZ
1925 wxDCClipper(wxDC& dc, const wxRegion& r) : m_dc(dc)
1926 { dc.SetClippingRegion(r); }
e26be42b
VZ
1927 wxDCClipper(wxDC& dc, const wxRect& r) : m_dc(dc)
1928 { dc.SetClippingRegion(r.x, r.y, r.width, r.height); }
1929 wxDCClipper(wxDC& dc, wxCoord x, wxCoord y, wxCoord w, wxCoord h) : m_dc(dc)
1930 { dc.SetClippingRegion(x, y, w, h); }
1931
1932 ~wxDCClipper() { m_dc.DestroyClippingRegion(); }
1933
1934private:
1935 wxDC& m_dc;
fc7a2a60
VZ
1936
1937 DECLARE_NO_COPY_CLASS(wxDCClipper)
e26be42b
VZ
1938};
1939
8b56b16a 1940#endif // _WX_DC_H_BASE_