]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: dc.h | |
3 | // Purpose: wxDC class | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 17/09/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_DC_H_ | |
13 | #define _WX_DC_H_ | |
14 | ||
15 | #ifdef __GNUG__ | |
16 | #pragma interface "dc.h" | |
17 | #endif | |
18 | ||
19 | #include "wx/pen.h" | |
20 | #include "wx/brush.h" | |
21 | #include "wx/icon.h" | |
22 | #include "wx/font.h" | |
23 | #include "wx/gdicmn.h" | |
24 | ||
25 | //----------------------------------------------------------------------------- | |
26 | // constants | |
27 | //----------------------------------------------------------------------------- | |
28 | ||
29 | #ifndef MM_TEXT | |
30 | #define MM_TEXT 0 | |
31 | #define MM_ISOTROPIC 1 | |
32 | #define MM_ANISOTROPIC 2 | |
33 | #define MM_LOMETRIC 3 | |
34 | #define MM_HIMETRIC 4 | |
35 | #define MM_TWIPS 5 | |
36 | #define MM_POINTS 6 | |
37 | #define MM_METRIC 7 | |
38 | #endif | |
39 | ||
40 | //----------------------------------------------------------------------------- | |
41 | // wxDC | |
42 | //----------------------------------------------------------------------------- | |
43 | ||
44 | class WXDLLEXPORT wxDC : public wxDCBase | |
45 | { | |
46 | DECLARE_DYNAMIC_CLASS(wxDC) | |
47 | ||
48 | public: | |
49 | wxDC(); | |
50 | ~wxDC() { } | |
51 | ||
52 | // implement base class pure virtuals | |
53 | // ---------------------------------- | |
54 | ||
55 | virtual void DestroyClippingRegion(); | |
56 | ||
57 | virtual wxSize GetPPI() const; | |
58 | ||
59 | virtual void SetMapMode(int mode); | |
60 | virtual void SetUserScale(double x, double y); | |
61 | virtual void SetLogicalScale(double x, double y); | |
62 | virtual void SetLogicalOrigin(long x, long y); | |
63 | virtual void SetDeviceOrigin(long x, long y); | |
64 | virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp); | |
65 | ||
66 | protected: | |
67 | virtual void DoDrawIcon(const wxIcon& icon, long x, long y); | |
68 | virtual void DoDrawBitmap(const wxBitmap &bmp, long x, long y, | |
69 | bool useMask = FALSE); | |
70 | ||
71 | virtual void DoSetClippingRegion(long x, long y, | |
72 | long width, long height); | |
73 | virtual void DoGetSize(int *width, int *height) const; | |
74 | virtual void DoGetSizeMM(int* width, int* height) const; | |
75 | ||
76 | public: | |
77 | void ComputeScaleAndOrigin(); | |
78 | ||
79 | long XDEV2LOG(long x) const | |
80 | { | |
81 | long new_x = x - m_deviceOriginX; | |
82 | if (new_x > 0) | |
83 | return (long)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX; | |
84 | else | |
85 | return (long)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX; | |
86 | } | |
87 | long XDEV2LOGREL(long x) const | |
88 | { | |
89 | if (x > 0) | |
90 | return (long)((double)(x) / m_scaleX + 0.5); | |
91 | else | |
92 | return (long)((double)(x) / m_scaleX - 0.5); | |
93 | } | |
94 | long YDEV2LOG(long y) const | |
95 | { | |
96 | long new_y = y - m_deviceOriginY; | |
97 | if (new_y > 0) | |
98 | return (long)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY; | |
99 | else | |
100 | return (long)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY; | |
101 | } | |
102 | long YDEV2LOGREL(long y) const | |
103 | { | |
104 | if (y > 0) | |
105 | return (long)((double)(y) / m_scaleY + 0.5); | |
106 | else | |
107 | return (long)((double)(y) / m_scaleY - 0.5); | |
108 | } | |
109 | long XLOG2DEV(long x) const | |
110 | { | |
111 | long new_x = x - m_logicalOriginX; | |
112 | if (new_x > 0) | |
113 | return (long)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX; | |
114 | else | |
115 | return (long)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX; | |
116 | } | |
117 | // Without device translation, for backing pixmap purposes | |
118 | long XLOG2DEV_2(long x) const | |
119 | { | |
120 | long new_x = x - m_logicalOriginX; | |
121 | if (new_x > 0) | |
122 | return (long)((double)(new_x) * m_scaleX + 0.5) * m_signX; | |
123 | else | |
124 | return (long)((double)(new_x) * m_scaleX - 0.5) * m_signX; | |
125 | } | |
126 | long XLOG2DEVREL(long x) const | |
127 | { | |
128 | if (x > 0) | |
129 | return (long)((double)(x) * m_scaleX + 0.5); | |
130 | else | |
131 | return (long)((double)(x) * m_scaleX - 0.5); | |
132 | } | |
133 | long YLOG2DEV(long y) const | |
134 | { | |
135 | long new_y = y - m_logicalOriginY; | |
136 | if (new_y > 0) | |
137 | return (long)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY; | |
138 | else | |
139 | return (long)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY; | |
140 | } | |
141 | // Without device translation, for backing pixmap purposes | |
142 | long YLOG2DEV_2(long y) const | |
143 | { | |
144 | long new_y = y - m_logicalOriginY; | |
145 | if (new_y > 0) | |
146 | return (long)((double)(new_y) * m_scaleY + 0.5) * m_signY; | |
147 | else | |
148 | return (long)((double)(new_y) * m_scaleY - 0.5) * m_signY; | |
149 | } | |
150 | long YLOG2DEVREL(long y) const | |
151 | { | |
152 | if (y > 0) | |
153 | return (long)((double)(y) * m_scaleY + 0.5); | |
154 | else | |
155 | return (long)((double)(y) * m_scaleY - 0.5); | |
156 | } | |
157 | ||
158 | void SetInternalDeviceOrigin( long x, long y ); | |
159 | void GetInternalDeviceOrigin( long *x, long *y ); | |
160 | ||
161 | public: | |
162 | // not sure what for, but what is a mm on a screen you don't know the size of? | |
163 | double m_mm_to_pix_x,m_mm_to_pix_y; | |
164 | ||
165 | // If un-scrolled is non-zero or d.o. changes with scrolling. Set using | |
166 | // SetInternalDeviceOrigin(). | |
167 | long m_internalDeviceOriginX,m_internalDeviceOriginY; | |
168 | ||
169 | // To be set by external classes such as wxScrolledWindow using | |
170 | // SetDeviceOrigin() | |
171 | long m_externalDeviceOriginX,m_externalDeviceOriginY; | |
172 | ||
173 | // recompute scale? | |
174 | bool m_needComputeScaleX, m_needComputeScaleY; | |
175 | ||
176 | // wxPSDC wants to have this. Will disappear. | |
177 | float m_scaleFactor; | |
178 | }; | |
179 | ||
180 | #endif | |
181 | // _WX_DC_H_ |