1 /////////////////////////////////////////////////////////////////////////////
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
18 // ---------------------------------------------------------------------------
20 // ---------------------------------------------------------------------------
24 #define XLOG2DEV(x) (x)
25 #define YLOG2DEV(y) (y)
28 #define XLOG2DEVREL(x) (x)
29 #define YLOG2DEVREL(y) (y)
33 #define XDEV2LOG(x) (x)
35 #define YDEV2LOG(y) (y)
38 #define XDEV2LOGREL(x) (x)
39 #define YDEV2LOGREL(y) (y)
42 * Have the same macros as for XView but not for every operation:
43 * just for calculating window/viewport extent (a better way of scaling).
48 #define MS_XLOG2DEV(x) LogicalToDevice(x)
50 #define MS_YLOG2DEV(y) LogicalToDevice(y)
53 #define MS_XLOG2DEVREL(x) LogicalToDeviceXRel(x)
54 #define MS_YLOG2DEVREL(y) LogicalToDeviceYRel(y)
58 #define MS_XDEV2LOG(x) DeviceToLogicalX(x)
60 #define MS_YDEV2LOG(y) DeviceToLogicalY(y)
63 #define MS_XDEV2LOGREL(x) DeviceToLogicalXRel(x)
64 #define MS_YDEV2LOGREL(y) DeviceToLogicalYRel(y)
66 #define YSCALE(y) (yorigin - (y))
68 #define wx_round(a) (int)((a)+.5)
70 class WXDLLEXPORT wxDC
: public wxDCBase
72 DECLARE_DYNAMIC_CLASS(wxDC
)
78 // implement base class pure virtuals
79 // ----------------------------------
83 virtual bool StartDoc(const wxString
& message
);
84 virtual void EndDoc();
86 virtual void StartPage();
87 virtual void EndPage();
89 virtual void SetFont(const wxFont
& font
);
90 virtual void SetPen(const wxPen
& pen
);
91 virtual void SetBrush(const wxBrush
& brush
);
92 virtual void SetBackground(const wxBrush
& brush
);
93 virtual void SetBackgroundMode(int mode
);
94 virtual void SetPalette(const wxPalette
& palette
);
96 virtual void DestroyClippingRegion();
98 virtual wxCoord
GetCharHeight() const;
99 virtual wxCoord
GetCharWidth() const;
100 virtual void DoGetTextExtent(const wxString
& string
,
101 wxCoord
*x
, wxCoord
*y
,
102 wxCoord
*descent
= NULL
,
103 wxCoord
*externalLeading
= NULL
,
104 wxFont
*theFont
= NULL
) const;
106 virtual bool CanDrawBitmap() const;
107 virtual bool CanGetTextExtent() const;
108 virtual int GetDepth() const;
109 virtual wxSize
GetPPI() const;
111 virtual void SetMapMode(int mode
);
112 virtual void SetUserScale(double x
, double y
);
113 virtual void SetSystemScale(double x
, double y
);
114 virtual void SetLogicalScale(double x
, double y
);
115 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
116 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
117 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
118 virtual void SetLogicalFunction(int function
);
120 // implementation from now on
121 // --------------------------
123 virtual void SetRop(WXHDC cdc
);
124 virtual void DoClipping(WXHDC cdc
);
125 virtual void SelectOldObjects(WXHDC dc
);
127 wxWindow
*GetWindow() const { return m_canvas
; }
128 void SetWindow(wxWindow
*win
) { m_canvas
= win
; }
130 WXHDC
GetHDC() const { return m_hDC
; }
131 void SetHDC(WXHDC dc
, bool bOwnsDC
= FALSE
)
138 virtual void DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
139 int style
= wxFLOOD_SURFACE
);
141 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const;
143 virtual void DoDrawPoint(wxCoord x
, wxCoord y
);
144 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
146 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
147 wxCoord x2
, wxCoord y2
,
148 wxCoord xc
, wxCoord yc
);
149 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
150 double sa
, double ea
);
152 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
153 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
154 wxCoord width
, wxCoord height
,
156 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
158 virtual void DoCrossHair(wxCoord x
, wxCoord y
);
160 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
);
161 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
162 bool useMask
= FALSE
);
164 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
165 virtual void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
,
168 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
169 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
170 int rop
= wxCOPY
, bool useMask
= FALSE
);
172 // this is gnarly - we can't even call this function DoSetClippingRegion()
173 // because of virtual function hiding
174 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
);
175 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
176 wxCoord width
, wxCoord height
);
177 virtual void DoGetClippingRegion(wxCoord
*x
, wxCoord
*y
,
178 wxCoord
*width
, wxCoord
*height
)
180 GetClippingBox(x
, y
, width
, height
);
183 virtual void DoGetSize(int *width
, int *height
) const;
184 virtual void DoGetSizeMM(int* width
, int* height
) const;
186 virtual void DoDrawLines(int n
, wxPoint points
[],
187 wxCoord xoffset
, wxCoord yoffset
);
188 virtual void DoDrawPolygon(int n
, wxPoint points
[],
189 wxCoord xoffset
, wxCoord yoffset
,
190 int fillStyle
= wxODDEVEN_RULE
);
193 virtual void DoDrawSpline(wxList
*points
);
194 #endif // wxUSE_SPLINES
196 // OS2-specific member variables
200 // the window associated with this DC (may be NULL)
203 wxBitmap m_selectedBitmap
;
205 // TRUE => DeleteDC() in dtor, FALSE => only ReleaseDC() it
208 // our HDC and its usage count: we only free it when the usage count drops
213 // Store all old GDI objects when do a SelectObject, so we can select them
214 // back in (this unselecting user's objects) so we can safely delete the
216 WXHBITMAP m_oldBitmap
;
220 WXHPALETTE m_oldPalette
;
222 float m_scaleFactor
; // wxPSDC wants to have this. Will disappear.