1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "dc.h"
22 // ---------------------------------------------------------------------------
24 // ---------------------------------------------------------------------------
28 #define XLOG2DEV(x) (x)
29 #define YLOG2DEV(y) (y)
32 #define XLOG2DEVREL(x) (x)
33 #define YLOG2DEVREL(y) (y)
37 #define XDEV2LOG(x) (x)
39 #define YDEV2LOG(y) (y)
42 #define XDEV2LOGREL(x) (x)
43 #define YDEV2LOGREL(y) (y)
46 * Have the same macros as for XView but not for every operation:
47 * just for calculating window/viewport extent (a better way of scaling).
52 #define MS_XLOG2DEV(x) LogicalToDevice(x)
54 #define MS_YLOG2DEV(y) LogicalToDevice(y)
57 #define MS_XLOG2DEVREL(x) LogicalToDeviceXRel(x)
58 #define MS_YLOG2DEVREL(y) LogicalToDeviceYRel(y)
62 #define MS_XDEV2LOG(x) DeviceToLogicalX(x)
64 #define MS_YDEV2LOG(y) DeviceToLogicalY(y)
67 #define MS_XDEV2LOGREL(x) DeviceToLogicalXRel(x)
68 #define MS_YDEV2LOGREL(y) DeviceToLogicalYRel(y)
70 #define YSCALE(y) (yorigin - (y))
72 #define wx_round(a) (int)((a)+.5)
74 class WXDLLEXPORT wxDC
: public wxDCBase
76 DECLARE_DYNAMIC_CLASS(wxDC
)
82 // implement base class pure virtuals
83 // ----------------------------------
87 virtual bool StartDoc(const wxString
& message
);
88 virtual void EndDoc();
90 virtual void StartPage();
91 virtual void EndPage();
93 virtual void SetFont(const wxFont
& font
);
94 virtual void SetPen(const wxPen
& pen
);
95 virtual void SetBrush(const wxBrush
& brush
);
96 virtual void SetBackground(const wxBrush
& brush
);
97 virtual void SetBackgroundMode(int mode
);
98 virtual void SetPalette(const wxPalette
& palette
);
100 virtual void DestroyClippingRegion();
102 virtual long GetCharHeight() const;
103 virtual long GetCharWidth() const;
104 virtual void GetTextExtent(const wxString
& string
,
106 long *descent
= NULL
,
107 long *externalLeading
= NULL
,
108 wxFont
*theFont
= NULL
) const;
110 virtual bool CanDrawBitmap() const;
111 virtual bool CanGetTextExtent() const;
112 virtual int GetDepth() const;
113 virtual wxSize
GetPPI() const;
115 virtual void SetMapMode(int mode
);
116 virtual void SetUserScale(double x
, double y
);
117 virtual void SetSystemScale(double x
, double y
);
118 virtual void SetLogicalScale(double x
, double y
);
119 virtual void SetLogicalOrigin(long x
, long y
);
120 virtual void SetDeviceOrigin(long x
, long y
);
121 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
122 virtual void SetLogicalFunction(int function
);
124 // implementation from now on
125 // --------------------------
127 virtual void SetRop(WXHDC cdc
);
128 virtual void DoClipping(WXHDC cdc
);
129 virtual void SelectOldObjects(WXHDC dc
);
131 wxWindow
*GetWindow() const { return m_canvas
; }
132 void SetWindow(wxWindow
*win
) { m_canvas
= win
; }
134 WXHDC
GetHDC() const { return m_hDC
; }
135 void SetHDC(WXHDC dc
, bool bOwnsDC
= FALSE
)
142 virtual void DoFloodFill(long x
, long y
, const wxColour
& col
,
143 int style
= wxFLOOD_SURFACE
);
145 virtual bool DoGetPixel(long x
, long y
, wxColour
*col
) const;
147 virtual void DoDrawPoint(long x
, long y
);
148 virtual void DoDrawLine(long x1
, long y1
, long x2
, long y2
);
150 virtual void DoDrawArc(long x1
, long y1
,
153 virtual void DoDrawEllipticArc(long x
, long y
, long w
, long h
,
154 double sa
, double ea
);
156 virtual void DoDrawRectangle(long x
, long y
, long width
, long height
);
157 virtual void DoDrawRoundedRectangle(long x
, long y
,
158 long width
, long height
,
160 virtual void DoDrawEllipse(long x
, long y
, long width
, long height
);
162 virtual void DoCrossHair(long x
, long y
);
164 virtual void DoDrawIcon(const wxIcon
& icon
, long x
, long y
);
165 virtual void DoDrawBitmap(const wxBitmap
&bmp
, long x
, long y
,
166 bool useMask
= FALSE
);
168 virtual void DoDrawText(const wxString
& text
, long x
, long y
);
170 virtual bool DoBlit(long xdest
, long ydest
, long width
, long height
,
171 wxDC
*source
, long xsrc
, long ysrc
,
172 int rop
= wxCOPY
, bool useMask
= FALSE
);
174 // this is gnarly - we can't even call this function DoSetClippingRegion()
175 // because of virtual function hiding
176 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
);
177 virtual void DoSetClippingRegion(long x
, long y
,
178 long width
, long height
);
179 virtual void DoGetClippingRegion(long *x
, long *y
,
180 long *width
, long *height
)
182 GetClippingBox(x
, y
, width
, height
);
185 virtual void DoGetSize(int *width
, int *height
) const;
186 virtual void DoGetSizeMM(int* width
, int* height
) const;
188 virtual void DoDrawLines(int n
, wxPoint points
[],
189 long xoffset
, long yoffset
);
190 virtual void DoDrawPolygon(int n
, wxPoint points
[],
191 long xoffset
, long yoffset
,
192 int fillStyle
= wxODDEVEN_RULE
);
195 virtual void DoDrawSpline(wxList
*points
);
196 #endif // wxUSE_SPLINES
198 // MSW-specific member variables
202 // the window associated with this DC (may be NULL)
205 wxBitmap m_selectedBitmap
;
207 // TRUE => DeleteDC() in dtor, FALSE => only ReleaseDC() it
210 // our HDC and its usage count: we only free it when the usage count drops
215 // Store all old GDI objects when do a SelectObject, so we can select them
216 // back in (this unselecting user's objects) so we can safely delete the
218 WXHBITMAP m_oldBitmap
;
222 WXHPALETTE m_oldPalette
;