]> git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/dc.h
BC++ and Watcom C++ makefile and source fixes
[wxWidgets.git] / include / wx / os2 / dc.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: dc.h
3 // Purpose: wxDC class
4 // Author: David Webster
5 // Modified by:
6 // Created: 08/26/99
7 // RCS-ID: $Id$
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_DC_H_
13 #define _WX_DC_H_
14
15 #include "wx/defs.h"
16 #include "wx/dc.h"
17
18 // ---------------------------------------------------------------------------
19 // macros
20 // ---------------------------------------------------------------------------
21
22 // Logical to device
23 // Absolute
24 #define XLOG2DEV(x) (x)
25 #define YLOG2DEV(y) (y)
26
27 // Relative
28 #define XLOG2DEVREL(x) (x)
29 #define YLOG2DEVREL(y) (y)
30
31 // Device to logical
32 // Absolute
33 #define XDEV2LOG(x) (x)
34
35 #define YDEV2LOG(y) (y)
36
37 // Relative
38 #define XDEV2LOGREL(x) (x)
39 #define YDEV2LOGREL(y) (y)
40
41 /*
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).
44 */
45
46 // Logical to device
47 // Absolute
48 #define MS_XLOG2DEV(x) LogicalToDevice(x)
49
50 #define MS_YLOG2DEV(y) LogicalToDevice(y)
51
52 // Relative
53 #define MS_XLOG2DEVREL(x) LogicalToDeviceXRel(x)
54 #define MS_YLOG2DEVREL(y) LogicalToDeviceYRel(y)
55
56 // Device to logical
57 // Absolute
58 #define MS_XDEV2LOG(x) DeviceToLogicalX(x)
59
60 #define MS_YDEV2LOG(y) DeviceToLogicalY(y)
61
62 // Relative
63 #define MS_XDEV2LOGREL(x) DeviceToLogicalXRel(x)
64 #define MS_YDEV2LOGREL(y) DeviceToLogicalYRel(y)
65
66 #define YSCALE(y) (yorigin - (y))
67
68 #define wx_round(a) (int)((a)+.5)
69
70 class WXDLLEXPORT wxDC : public wxDCBase
71 {
72 DECLARE_DYNAMIC_CLASS(wxDC)
73
74 public:
75 wxDC();
76 ~wxDC();
77
78 // implement base class pure virtuals
79 // ----------------------------------
80
81 virtual void Clear();
82
83 virtual bool StartDoc(const wxString& message);
84 virtual void EndDoc();
85
86 virtual void StartPage();
87 virtual void EndPage();
88
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);
95
96 virtual void DestroyClippingRegion();
97
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;
105
106 virtual bool CanDrawBitmap() const;
107 virtual bool CanGetTextExtent() const;
108 virtual int GetDepth() const;
109 virtual wxSize GetPPI() const;
110
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);
119
120 // implementation from now on
121 // --------------------------
122
123 virtual void SetRop(WXHDC cdc);
124 virtual void DoClipping(WXHDC cdc);
125 virtual void SelectOldObjects(WXHDC dc);
126
127 wxWindow *GetWindow() const { return m_canvas; }
128 void SetWindow(wxWindow *win) { m_canvas = win; }
129
130 WXHDC GetHDC() const { return m_hDC; }
131 void SetHDC(WXHDC dc, bool bOwnsDC = FALSE)
132 {
133 m_hDC = dc;
134 m_bOwnsDC = bOwnsDC;
135 }
136
137 protected:
138 virtual void DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
139 int style = wxFLOOD_SURFACE);
140
141 virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const;
142
143 virtual void DoDrawPoint(wxCoord x, wxCoord y);
144 virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
145
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);
151
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,
155 double radius);
156 virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
157
158 virtual void DoCrossHair(wxCoord x, wxCoord y);
159
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);
163
164 virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y);
165
166 virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
167 wxDC *source, wxCoord xsrc, wxCoord ysrc,
168 int rop = wxCOPY, bool useMask = FALSE);
169
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(wxCoord x, wxCoord y,
174 wxCoord width, wxCoord height);
175 virtual void DoGetClippingRegion(wxCoord *x, wxCoord *y,
176 wxCoord *width, wxCoord *height)
177 {
178 GetClippingBox(x, y, width, height);
179 }
180
181 virtual void DoGetSize(int *width, int *height) const;
182 virtual void DoGetSizeMM(int* width, int* height) const;
183
184 virtual void DoDrawLines(int n, wxPoint points[],
185 wxCoord xoffset, wxCoord yoffset);
186 virtual void DoDrawPolygon(int n, wxPoint points[],
187 wxCoord xoffset, wxCoord yoffset,
188 int fillStyle = wxODDEVEN_RULE);
189
190 #if wxUSE_SPLINES
191 virtual void DoDrawSpline(wxList *points);
192 #endif // wxUSE_SPLINES
193
194 // OS2-specific member variables
195 int m_windowExtX;
196 int m_windowExtY;
197
198 // the window associated with this DC (may be NULL)
199 wxWindow *m_canvas;
200
201 wxBitmap m_selectedBitmap;
202
203 // TRUE => DeleteDC() in dtor, FALSE => only ReleaseDC() it
204 bool m_bOwnsDC:1;
205
206 // our HDC and its usage count: we only free it when the usage count drops
207 // to 0
208 WXHDC m_hDC;
209 int m_hDCCount;
210
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
213 // DC.
214 WXHBITMAP m_oldBitmap;
215 WXHPEN m_oldPen;
216 WXHBRUSH m_oldBrush;
217 WXHFONT m_oldFont;
218 WXHPALETTE m_oldPalette;
219 };
220 #endif
221 // _WX_DC_H_