1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "dc.h"
19 class WXDLLEXPORT wxDC
: public wxDCBase
21 DECLARE_DYNAMIC_CLASS(wxDC
)
27 // implement base class pure virtuals
28 // ----------------------------------
32 virtual bool StartDoc(const wxString
& message
);
33 virtual void EndDoc();
35 virtual void StartPage();
36 virtual void EndPage();
38 virtual void SetFont(const wxFont
& font
);
39 virtual void SetPen(const wxPen
& pen
);
40 virtual void SetBrush(const wxBrush
& brush
);
41 virtual void SetBackground(const wxBrush
& brush
);
42 virtual void SetBackgroundMode(int mode
);
43 virtual void SetPalette(const wxPalette
& palette
);
45 virtual void DestroyClippingRegion();
47 virtual long GetCharHeight() const;
48 virtual long GetCharWidth() const;
49 virtual void GetTextExtent(const wxString
& string
,
52 long *externalLeading
= NULL
,
53 wxFont
*theFont
= NULL
) const;
55 virtual bool CanDrawBitmap() const;
56 virtual bool CanGetTextExtent() const;
57 virtual int GetDepth() const;
58 virtual wxSize
GetPPI() const;
60 virtual void SetMapMode(int mode
);
61 virtual void SetUserScale(double x
, double y
);
62 virtual void SetSystemScale(double x
, double y
);
63 virtual void SetLogicalScale(double x
, double y
);
64 virtual void SetLogicalOrigin(long x
, long y
);
65 virtual void SetDeviceOrigin(long x
, long y
);
66 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
67 virtual void SetLogicalFunction(int function
);
69 // implementation from now on
70 // --------------------------
72 virtual void SetRop(WXHDC cdc
);
73 virtual void DoClipping(WXHDC cdc
);
74 virtual void SelectOldObjects(WXHDC dc
);
76 wxWindow
*GetWindow() const { return m_canvas
; }
77 void SetWindow(wxWindow
*win
) { m_canvas
= win
; }
79 WXHDC
GetHDC() const { return m_hDC
; }
80 void SetHDC(WXHDC dc
, bool bOwnsDC
= FALSE
)
87 virtual void DoFloodFill(long x
, long y
, const wxColour
& col
,
88 int style
= wxFLOOD_SURFACE
);
90 virtual bool DoGetPixel(long x
, long y
, wxColour
*col
) const;
92 virtual void DoDrawPoint(long x
, long y
);
93 virtual void DoDrawLine(long x1
, long y1
, long x2
, long y2
);
95 virtual void DoDrawArc(long x1
, long y1
,
98 virtual void DoDrawEllipticArc(long x
, long y
, long w
, long h
,
99 double sa
, double ea
);
101 virtual void DoDrawRectangle(long x
, long y
, long width
, long height
);
102 virtual void DoDrawRoundedRectangle(long x
, long y
,
103 long width
, long height
,
105 virtual void DoDrawEllipse(long x
, long y
, long width
, long height
);
107 virtual void DoCrossHair(long x
, long y
);
109 virtual void DoDrawIcon(const wxIcon
& icon
, long x
, long y
);
110 virtual void DoDrawBitmap(const wxBitmap
&bmp
, long x
, long y
,
111 bool useMask
= FALSE
);
113 virtual void DoDrawText(const wxString
& text
, long x
, long y
);
115 virtual bool DoBlit(long xdest
, long ydest
, long width
, long height
,
116 wxDC
*source
, long xsrc
, long ysrc
,
117 int rop
= wxCOPY
, bool useMask
= FALSE
);
119 // this is gnarly - we can't even call this function DoSetClippingRegion()
120 // because of virtual function hiding
121 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
);
122 virtual void DoSetClippingRegion(long x
, long y
,
123 long width
, long height
);
124 virtual void DoGetClippingRegion(long *x
, long *y
,
125 long *width
, long *height
)
127 GetClippingBox(x
, y
, width
, height
);
130 virtual void DoGetSize(int *width
, int *height
) const;
131 virtual void DoGetSizeMM(int* width
, int* height
) const;
133 virtual void DoDrawLines(int n
, wxPoint points
[],
134 long xoffset
, long yoffset
);
135 virtual void DoDrawPolygon(int n
, wxPoint points
[],
136 long xoffset
, long yoffset
,
137 int fillStyle
= wxODDEVEN_RULE
);
140 virtual void DoDrawSpline(wxList
*points
);
141 #endif // wxUSE_SPLINES
143 // MSW-specific member variables
147 // the window associated with this DC (may be NULL)
150 wxBitmap m_selectedBitmap
;
152 // TRUE => DeleteDC() in dtor, FALSE => only ReleaseDC() it
155 // our HDC and its usage count: we only free it when the usage count drops
160 // Store all old GDI objects when do a SelectObject, so we can select them
161 // back in (this unselecting user's objects) so we can safely delete the
163 WXHBITMAP m_oldBitmap
;
167 WXHPALETTE m_oldPalette
;
172 #define XLOG2DEV(x) (x)
173 #define YLOG2DEV(y) (y)
176 #define XLOG2DEVREL(x) (x)
177 #define YLOG2DEVREL(y) (y)
181 #define XDEV2LOG(x) (x)
183 #define YDEV2LOG(y) (y)
186 #define XDEV2LOGREL(x) (x)
187 #define YDEV2LOGREL(y) (y)
190 * Have the same macros as for XView but not for every operation:
191 * just for calculating window/viewport extent (a better way of scaling).
196 #define MS_XLOG2DEV(x) LogicalToDevice(x)
198 #define MS_YLOG2DEV(y) LogicalToDevice(y)
201 #define MS_XLOG2DEVREL(x) LogicalToDeviceXRel(x)
202 #define MS_YLOG2DEVREL(y) LogicalToDeviceYRel(y)
206 #define MS_XDEV2LOG(x) DeviceToLogicalX(x)
208 #define MS_YDEV2LOG(y) DeviceToLogicalY(y)
211 #define MS_XDEV2LOGREL(x) DeviceToLogicalXRel(x)
212 #define MS_YDEV2LOGREL(y) DeviceToLogicalYRel(y)
218 #define METRIC_CONVERSION_CONSTANT 0.0393700787
220 // Scaling factors for various unit conversions
221 #define mm2inches (METRIC_CONVERSION_CONSTANT)
222 #define inches2mm (1/METRIC_CONVERSION_CONSTANT)
224 #define mm2twips (METRIC_CONVERSION_CONSTANT*1440)
225 #define twips2mm (1/(METRIC_CONVERSION_CONSTANT*1440))
227 #define mm2pt (METRIC_CONVERSION_CONSTANT*72)
228 #define pt2mm (1/(METRIC_CONVERSION_CONSTANT*72))
230 #define wx_round(a) (int)((a)+.5)