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 long GetCharHeight() const;
99 virtual long GetCharWidth() const;
100 virtual void GetTextExtent(const wxString
& string
,
102 long *descent
= NULL
,
103 long *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(long x
, long y
);
116 virtual void SetDeviceOrigin(long x
, long 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(long x
, long y
, const wxColour
& col
,
139 int style
= wxFLOOD_SURFACE
);
141 virtual bool DoGetPixel(long x
, long y
, wxColour
*col
) const;
143 virtual void DoDrawPoint(long x
, long y
);
144 virtual void DoDrawLine(long x1
, long y1
, long x2
, long y2
);
146 virtual void DoDrawArc(long x1
, long y1
,
149 virtual void DoDrawEllipticArc(long x
, long y
, long w
, long h
,
150 double sa
, double ea
);
152 virtual void DoDrawRectangle(long x
, long y
, long width
, long height
);
153 virtual void DoDrawRoundedRectangle(long x
, long y
,
154 long width
, long height
,
156 virtual void DoDrawEllipse(long x
, long y
, long width
, long height
);
158 virtual void DoCrossHair(long x
, long y
);
160 virtual void DoDrawIcon(const wxIcon
& icon
, long x
, long y
);
161 virtual void DoDrawBitmap(const wxBitmap
&bmp
, long x
, long y
,
162 bool useMask
= FALSE
);
164 virtual void DoDrawText(const wxString
& text
, long x
, long y
);
166 virtual bool DoBlit(long xdest
, long ydest
, long width
, long height
,
167 wxDC
*source
, long xsrc
, long ysrc
,
168 int rop
= wxCOPY
, bool useMask
= FALSE
);
170 // this is gnarly - we can't even call this function DoSetClippingRegion()
171 // because of virtual function hiding
172 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
);
173 virtual void DoSetClippingRegion(long x
, long y
,
174 long width
, long height
);
175 virtual void DoGetClippingRegion(long *x
, long *y
,
176 long *width
, long *height
)
178 GetClippingBox(x
, y
, width
, height
);
181 virtual void DoGetSize(int *width
, int *height
) const;
182 virtual void DoGetSizeMM(int* width
, int* height
) const;
184 virtual void DoDrawLines(int n
, wxPoint points
[],
185 long xoffset
, long yoffset
);
186 virtual void DoDrawPolygon(int n
, wxPoint points
[],
187 long xoffset
, long yoffset
,
188 int fillStyle
= wxODDEVEN_RULE
);
191 virtual void DoDrawSpline(wxList
*points
);
192 #endif // wxUSE_SPLINES
194 // OS2-specific member variables
198 // the window associated with this DC (may be NULL)
201 wxBitmap m_selectedBitmap
;
203 // TRUE => DeleteDC() in dtor, FALSE => only ReleaseDC() it
206 // our HDC and its usage count: we only free it when the usage count drops
211 // Store all old GDI objects when do a SelectObject, so we can select them
212 // back in (this unselecting user's objects) so we can safely delete the
214 WXHBITMAP m_oldBitmap
;
218 WXHPALETTE m_oldPalette
;