Commit | Line | Data |
---|---|---|
9b6dbb09 JS |
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 | |
af0bb3b1 | 9 | // Licence: wxWindows licence |
9b6dbb09 JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_DC_H_ | |
13 | #define _WX_DC_H_ | |
14 | ||
15 | #ifdef __GNUG__ | |
af0bb3b1 | 16 | #pragma interface "dc.h" |
9b6dbb09 JS |
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 | |
af0bb3b1 VZ |
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 | |
9b6dbb09 JS |
38 | #endif |
39 | ||
9b6dbb09 JS |
40 | //----------------------------------------------------------------------------- |
41 | // wxDC | |
42 | //----------------------------------------------------------------------------- | |
43 | ||
af0bb3b1 | 44 | class WXDLLEXPORT wxDC : public wxDCBase |
9b6dbb09 | 45 | { |
af0bb3b1 | 46 | DECLARE_DYNAMIC_CLASS(wxDC) |
9b6dbb09 | 47 | |
af0bb3b1 VZ |
48 | public: |
49 | wxDC(); | |
50 | ~wxDC() { } | |
9b6dbb09 | 51 | |
af0bb3b1 VZ |
52 | // implement base class pure virtuals |
53 | // ---------------------------------- | |
9b6dbb09 | 54 | |
af0bb3b1 | 55 | virtual void DestroyClippingRegion(); |
9b6dbb09 | 56 | |
af0bb3b1 | 57 | virtual wxSize GetPPI() const; |
9b6dbb09 | 58 | |
af0bb3b1 VZ |
59 | virtual void SetMapMode(int mode); |
60 | virtual void SetUserScale(double x, double y); | |
af0bb3b1 VZ |
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); | |
9b6dbb09 | 65 | |
af0bb3b1 VZ |
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); | |
9b6dbb09 | 70 | |
af0bb3b1 VZ |
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; | |
9b6dbb09 | 75 | |
af0bb3b1 VZ |
76 | public: |
77 | void ComputeScaleAndOrigin(); | |
78 | ||
79 | long XDEV2LOG(long x) const | |
9b6dbb09 | 80 | { |
af0bb3b1 VZ |
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; | |
9b6dbb09 | 86 | } |
af0bb3b1 | 87 | long XDEV2LOGREL(long x) const |
9b6dbb09 | 88 | { |
af0bb3b1 VZ |
89 | if (x > 0) |
90 | return (long)((double)(x) / m_scaleX + 0.5); | |
91 | else | |
92 | return (long)((double)(x) / m_scaleX - 0.5); | |
9b6dbb09 | 93 | } |
af0bb3b1 | 94 | long YDEV2LOG(long y) const |
9b6dbb09 | 95 | { |
af0bb3b1 VZ |
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; | |
9b6dbb09 | 101 | } |
af0bb3b1 | 102 | long YDEV2LOGREL(long y) const |
9b6dbb09 | 103 | { |
af0bb3b1 VZ |
104 | if (y > 0) |
105 | return (long)((double)(y) / m_scaleY + 0.5); | |
106 | else | |
107 | return (long)((double)(y) / m_scaleY - 0.5); | |
9b6dbb09 | 108 | } |
af0bb3b1 | 109 | long XLOG2DEV(long x) const |
9b6dbb09 | 110 | { |
af0bb3b1 VZ |
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; | |
9b6dbb09 | 116 | } |
af0bb3b1 VZ |
117 | // Without device translation, for backing pixmap purposes |
118 | long XLOG2DEV_2(long x) const | |
9b6dbb09 | 119 | { |
af0bb3b1 VZ |
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; | |
9b6dbb09 | 125 | } |
af0bb3b1 | 126 | long XLOG2DEVREL(long x) const |
9b6dbb09 | 127 | { |
af0bb3b1 VZ |
128 | if (x > 0) |
129 | return (long)((double)(x) * m_scaleX + 0.5); | |
130 | else | |
131 | return (long)((double)(x) * m_scaleX - 0.5); | |
9b6dbb09 | 132 | } |
af0bb3b1 | 133 | long YLOG2DEV(long y) const |
9b6dbb09 | 134 | { |
af0bb3b1 VZ |
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; | |
9b6dbb09 | 140 | } |
af0bb3b1 VZ |
141 | // Without device translation, for backing pixmap purposes |
142 | long YLOG2DEV_2(long y) const | |
9b6dbb09 | 143 | { |
af0bb3b1 VZ |
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; | |
9b6dbb09 | 149 | } |
af0bb3b1 | 150 | long YLOG2DEVREL(long y) const |
9b6dbb09 | 151 | { |
af0bb3b1 VZ |
152 | if (y > 0) |
153 | return (long)((double)(y) * m_scaleY + 0.5); | |
154 | else | |
155 | return (long)((double)(y) * m_scaleY - 0.5); | |
9b6dbb09 JS |
156 | } |
157 | ||
af0bb3b1 VZ |
158 | void SetInternalDeviceOrigin( long x, long y ); |
159 | void GetInternalDeviceOrigin( long *x, long *y ); | |
9b6dbb09 | 160 | |
af0bb3b1 VZ |
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; | |
9b6dbb09 | 164 | |
af0bb3b1 VZ |
165 | // If un-scrolled is non-zero or d.o. changes with scrolling. Set using |
166 | // SetInternalDeviceOrigin(). | |
167 | long m_internalDeviceOriginX,m_internalDeviceOriginY; | |
9b6dbb09 | 168 | |
af0bb3b1 VZ |
169 | // To be set by external classes such as wxScrolledWindow using |
170 | // SetDeviceOrigin() | |
171 | long m_externalDeviceOriginX,m_externalDeviceOriginY; | |
7bcb11d3 | 172 | |
af0bb3b1 VZ |
173 | // recompute scale? |
174 | bool m_needComputeScaleX, m_needComputeScaleY; | |
9b6dbb09 | 175 | |
af0bb3b1 VZ |
176 | // wxPSDC wants to have this. Will disappear. |
177 | float m_scaleFactor; | |
9b6dbb09 JS |
178 | }; |
179 | ||
180 | #endif | |
181 | // _WX_DC_H_ |