]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/dc.h
(blind) fixes for Motif compilation
[wxWidgets.git] / include / wx / msw / dc.h
CommitLineData
2bda0e17
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: dc.h
3// Purpose: wxDC class
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
bbcdf8bc 8// Copyright: (c) Julian Smart
a23fd0e1 9// Licence: wxWindows licence
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
bbcdf8bc
JS
12#ifndef _WX_DC_H_
13#define _WX_DC_H_
2bda0e17
KB
14
15#ifdef __GNUG__
a23fd0e1 16 #pragma interface "dc.h"
2bda0e17
KB
17#endif
18
2662e49e
RR
19#include "wx/defs.h"
20#include "wx/dc.h"
21
e6f1ad22
HH
22// ---------------------------------------------------------------------------
23// macros
24// ---------------------------------------------------------------------------
25
26// Logical to device
27// Absolute
28#define XLOG2DEV(x) (x)
29#define YLOG2DEV(y) (y)
30
31// Relative
32#define XLOG2DEVREL(x) (x)
33#define YLOG2DEVREL(y) (y)
34
35// Device to logical
36// Absolute
37#define XDEV2LOG(x) (x)
38
39#define YDEV2LOG(y) (y)
40
41// Relative
42#define XDEV2LOGREL(x) (x)
43#define YDEV2LOGREL(y) (y)
44
45/*
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).
48 */
49
50// Logical to device
51// Absolute
52#define MS_XLOG2DEV(x) LogicalToDevice(x)
53
54#define MS_YLOG2DEV(y) LogicalToDevice(y)
55
56// Relative
57#define MS_XLOG2DEVREL(x) LogicalToDeviceXRel(x)
58#define MS_YLOG2DEVREL(y) LogicalToDeviceYRel(y)
59
60// Device to logical
61// Absolute
62#define MS_XDEV2LOG(x) DeviceToLogicalX(x)
63
64#define MS_YDEV2LOG(y) DeviceToLogicalY(y)
65
66// Relative
67#define MS_XDEV2LOGREL(x) DeviceToLogicalXRel(x)
68#define MS_YDEV2LOGREL(y) DeviceToLogicalYRel(y)
69
70#define YSCALE(y) (yorigin - (y))
71
72#define wx_round(a) (int)((a)+.5)
73
a23fd0e1 74class WXDLLEXPORT wxDC : public wxDCBase
2bda0e17 75{
a23fd0e1
VZ
76 DECLARE_DYNAMIC_CLASS(wxDC)
77
2bda0e17 78public:
a23fd0e1
VZ
79 wxDC();
80 ~wxDC();
81
82 // implement base class pure virtuals
83 // ----------------------------------
84
85 virtual void Clear();
86
87 virtual bool StartDoc(const wxString& message);
88 virtual void EndDoc();
89
90 virtual void StartPage();
91 virtual void EndPage();
92
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);
99
100 virtual void DestroyClippingRegion();
101
72cdf4c9
VZ
102 virtual wxCoord GetCharHeight() const;
103 virtual wxCoord GetCharWidth() const;
104 virtual void DoGetTextExtent(const wxString& string,
105 wxCoord *x, wxCoord *y,
106 wxCoord *descent = NULL,
107 wxCoord *externalLeading = NULL,
108 wxFont *theFont = NULL) const;
a23fd0e1
VZ
109
110 virtual bool CanDrawBitmap() const;
111 virtual bool CanGetTextExtent() const;
112 virtual int GetDepth() const;
113 virtual wxSize GetPPI() const;
114
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);
72cdf4c9
VZ
119 virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
120 virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
a23fd0e1
VZ
121 virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
122 virtual void SetLogicalFunction(int function);
123
124 // implementation from now on
125 // --------------------------
126
127 virtual void SetRop(WXHDC cdc);
a23fd0e1
VZ
128 virtual void SelectOldObjects(WXHDC dc);
129
130 wxWindow *GetWindow() const { return m_canvas; }
131 void SetWindow(wxWindow *win) { m_canvas = win; }
132
133 WXHDC GetHDC() const { return m_hDC; }
134 void SetHDC(WXHDC dc, bool bOwnsDC = FALSE)
135 {
136 m_hDC = dc;
137 m_bOwnsDC = bOwnsDC;
138 }
2bda0e17 139
4b7f2165
VZ
140 const wxBitmap& GetSelectedBitmap() const { return m_selectedBitmap; }
141 wxBitmap& GetSelectedBitmap() { return m_selectedBitmap; }
142
a23fd0e1 143protected:
72cdf4c9 144 virtual void DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
a23fd0e1
VZ
145 int style = wxFLOOD_SURFACE);
146
72cdf4c9 147 virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const;
a23fd0e1 148
72cdf4c9
VZ
149 virtual void DoDrawPoint(wxCoord x, wxCoord y);
150 virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
a23fd0e1 151
72cdf4c9
VZ
152 virtual void DoDrawArc(wxCoord x1, wxCoord y1,
153 wxCoord x2, wxCoord y2,
154 wxCoord xc, wxCoord yc);
cd9da200
VZ
155 virtual void DoDrawCheckMark(wxCoord x, wxCoord y,
156 wxCoord width, wxCoord height);
72cdf4c9 157 virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
a23fd0e1
VZ
158 double sa, double ea);
159
72cdf4c9
VZ
160 virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
161 virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
162 wxCoord width, wxCoord height,
a23fd0e1 163 double radius);
72cdf4c9 164 virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
a23fd0e1 165
72cdf4c9 166 virtual void DoCrossHair(wxCoord x, wxCoord y);
a23fd0e1 167
72cdf4c9
VZ
168 virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
169 virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
a23fd0e1
VZ
170 bool useMask = FALSE);
171
72cdf4c9 172 virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y);
95724b1a
VZ
173 virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
174 double angle);
a23fd0e1 175
72cdf4c9
VZ
176 virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
177 wxDC *source, wxCoord xsrc, wxCoord ysrc,
a23fd0e1
VZ
178 int rop = wxCOPY, bool useMask = FALSE);
179
180 // this is gnarly - we can't even call this function DoSetClippingRegion()
181 // because of virtual function hiding
182 virtual void DoSetClippingRegionAsRegion(const wxRegion& region);
72cdf4c9
VZ
183 virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
184 wxCoord width, wxCoord height);
185 virtual void DoGetClippingRegion(wxCoord *x, wxCoord *y,
186 wxCoord *width, wxCoord *height)
a23fd0e1
VZ
187 {
188 GetClippingBox(x, y, width, height);
189 }
190
191 virtual void DoGetSize(int *width, int *height) const;
192 virtual void DoGetSizeMM(int* width, int* height) const;
193
194 virtual void DoDrawLines(int n, wxPoint points[],
72cdf4c9 195 wxCoord xoffset, wxCoord yoffset);
a23fd0e1 196 virtual void DoDrawPolygon(int n, wxPoint points[],
72cdf4c9 197 wxCoord xoffset, wxCoord yoffset,
a23fd0e1 198 int fillStyle = wxODDEVEN_RULE);
6a6c0a8b 199
47d67540 200#if wxUSE_SPLINES
a23fd0e1
VZ
201 virtual void DoDrawSpline(wxList *points);
202#endif // wxUSE_SPLINES
203
4314ec48
VZ
204 // common part of DoDrawText() and DoDrawRotatedText()
205 void DrawAnyText(const wxString& text, wxCoord x, wxCoord y);
206
a23fd0e1
VZ
207 // MSW-specific member variables
208 int m_windowExtX;
209 int m_windowExtY;
210
211 // the window associated with this DC (may be NULL)
212 wxWindow *m_canvas;
213
214 wxBitmap m_selectedBitmap;
215
216 // TRUE => DeleteDC() in dtor, FALSE => only ReleaseDC() it
217 bool m_bOwnsDC:1;
218
219 // our HDC and its usage count: we only free it when the usage count drops
220 // to 0
221 WXHDC m_hDC;
222 int m_hDCCount;
223
224 // Store all old GDI objects when do a SelectObject, so we can select them
225 // back in (this unselecting user's objects) so we can safely delete the
226 // DC.
227 WXHBITMAP m_oldBitmap;
228 WXHPEN m_oldPen;
229 WXHBRUSH m_oldBrush;
230 WXHFONT m_oldFont;
231 WXHPALETTE m_oldPalette;
2bda0e17
KB
232};
233
2bda0e17 234#endif
bbcdf8bc 235 // _WX_DC_H_