]> git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/dc.h
Some Motif fixes; makefile fixes; added wxTransferStreamToFile/FileToStream for wxWin
[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 virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
166 double angle);
167
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);
171
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)
179 {
180 GetClippingBox(x, y, width, height);
181 }
182
183 virtual void DoGetSize(int *width, int *height) const;
184 virtual void DoGetSizeMM(int* width, int* height) const;
185
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);
191
192 #if wxUSE_SPLINES
193 virtual void DoDrawSpline(wxList *points);
194 #endif // wxUSE_SPLINES
195
196 // OS2-specific member variables
197 int m_windowExtX;
198 int m_windowExtY;
199
200 // the window associated with this DC (may be NULL)
201 wxWindow *m_canvas;
202
203 wxBitmap m_selectedBitmap;
204
205 // TRUE => DeleteDC() in dtor, FALSE => only ReleaseDC() it
206 bool m_bOwnsDC:1;
207
208 // our HDC and its usage count: we only free it when the usage count drops
209 // to 0
210 WXHDC m_hDC;
211 int m_hDCCount;
212
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
215 // DC.
216 WXHBITMAP m_oldBitmap;
217 WXHPEN m_oldPen;
218 WXHBRUSH m_oldBrush;
219 WXHFONT m_oldFont;
220 WXHPALETTE m_oldPalette;
221
222 float m_scaleFactor; // wxPSDC wants to have this. Will disappear.
223 };
224 #endif
225 // _WX_DC_H_