]>
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 | |
65571936 | 9 | // Licence: wxWindows licence |
9b6dbb09 JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_DC_H_ | |
13 | #define _WX_DC_H_ | |
14 | ||
9b6dbb09 JS |
15 | #include "wx/pen.h" |
16 | #include "wx/brush.h" | |
17 | #include "wx/icon.h" | |
18 | #include "wx/font.h" | |
19 | #include "wx/gdicmn.h" | |
20 | ||
21 | //----------------------------------------------------------------------------- | |
22 | // constants | |
23 | //----------------------------------------------------------------------------- | |
24 | ||
25 | #ifndef MM_TEXT | |
83df96d6 JS |
26 | #define MM_TEXT 0 |
27 | #define MM_ISOTROPIC 1 | |
28 | #define MM_ANISOTROPIC 2 | |
29 | #define MM_LOMETRIC 3 | |
30 | #define MM_HIMETRIC 4 | |
31 | #define MM_TWIPS 5 | |
32 | #define MM_POINTS 6 | |
33 | #define MM_METRIC 7 | |
9b6dbb09 JS |
34 | #endif |
35 | ||
9b6dbb09 JS |
36 | //----------------------------------------------------------------------------- |
37 | // wxDC | |
38 | //----------------------------------------------------------------------------- | |
39 | ||
af0bb3b1 | 40 | class WXDLLEXPORT wxDC : public wxDCBase |
9b6dbb09 | 41 | { |
af0bb3b1 | 42 | DECLARE_DYNAMIC_CLASS(wxDC) |
d16b634f | 43 | |
af0bb3b1 VZ |
44 | public: |
45 | wxDC(); | |
46 | ~wxDC() { } | |
d16b634f | 47 | |
af0bb3b1 VZ |
48 | // implement base class pure virtuals |
49 | // ---------------------------------- | |
d16b634f | 50 | |
af0bb3b1 | 51 | virtual wxSize GetPPI() const; |
d16b634f | 52 | |
af0bb3b1 VZ |
53 | virtual void SetMapMode(int mode); |
54 | virtual void SetUserScale(double x, double y); | |
af0bb3b1 | 55 | virtual void SetLogicalScale(double x, double y); |
7b65ea1a MB |
56 | virtual void SetLogicalOrigin(wxCoord x, wxCoord y); |
57 | virtual void SetDeviceOrigin(wxCoord x, wxCoord y); | |
af0bb3b1 | 58 | virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp); |
d16b634f | 59 | |
af0bb3b1 | 60 | protected: |
7b65ea1a MB |
61 | virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y); |
62 | virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, | |
b1263dcf | 63 | bool useMask = false); |
d16b634f | 64 | |
7b65ea1a | 65 | virtual void DoSetClippingRegion(wxCoord x, wxCoord y, |
83df96d6 | 66 | wxCoord width, wxCoord height); |
af0bb3b1 VZ |
67 | virtual void DoGetSize(int *width, int *height) const; |
68 | virtual void DoGetSizeMM(int* width, int* height) const; | |
d16b634f | 69 | |
af0bb3b1 | 70 | public: |
b1263dcf | 71 | virtual void ComputeScaleAndOrigin(); |
d16b634f | 72 | |
7b65ea1a | 73 | wxCoord XDEV2LOG(wxCoord x) const |
9b6dbb09 | 74 | { |
7b65ea1a | 75 | wxCoord new_x = x - m_deviceOriginX; |
af0bb3b1 | 76 | if (new_x > 0) |
7b65ea1a | 77 | return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX; |
af0bb3b1 | 78 | else |
7b65ea1a | 79 | return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX; |
9b6dbb09 | 80 | } |
7b65ea1a | 81 | wxCoord XDEV2LOGREL(wxCoord x) const |
9b6dbb09 | 82 | { |
af0bb3b1 | 83 | if (x > 0) |
7b65ea1a | 84 | return (wxCoord)((double)(x) / m_scaleX + 0.5); |
af0bb3b1 | 85 | else |
7b65ea1a | 86 | return (wxCoord)((double)(x) / m_scaleX - 0.5); |
9b6dbb09 | 87 | } |
7b65ea1a | 88 | wxCoord YDEV2LOG(wxCoord y) const |
9b6dbb09 | 89 | { |
7b65ea1a | 90 | wxCoord new_y = y - m_deviceOriginY; |
af0bb3b1 | 91 | if (new_y > 0) |
7b65ea1a | 92 | return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY; |
af0bb3b1 | 93 | else |
7b65ea1a | 94 | return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY; |
9b6dbb09 | 95 | } |
7b65ea1a | 96 | wxCoord YDEV2LOGREL(wxCoord y) const |
9b6dbb09 | 97 | { |
af0bb3b1 | 98 | if (y > 0) |
7b65ea1a | 99 | return (wxCoord)((double)(y) / m_scaleY + 0.5); |
af0bb3b1 | 100 | else |
7b65ea1a | 101 | return (wxCoord)((double)(y) / m_scaleY - 0.5); |
9b6dbb09 | 102 | } |
7b65ea1a | 103 | wxCoord XLOG2DEV(wxCoord x) const |
9b6dbb09 | 104 | { |
7b65ea1a | 105 | wxCoord new_x = x - m_logicalOriginX; |
af0bb3b1 | 106 | if (new_x > 0) |
7b65ea1a | 107 | return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX; |
af0bb3b1 | 108 | else |
7b65ea1a | 109 | return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX; |
9b6dbb09 | 110 | } |
af0bb3b1 | 111 | // Without device translation, for backing pixmap purposes |
7b65ea1a | 112 | wxCoord XLOG2DEV_2(wxCoord x) const |
9b6dbb09 | 113 | { |
7b65ea1a | 114 | wxCoord new_x = x - m_logicalOriginX; |
af0bb3b1 | 115 | if (new_x > 0) |
7b65ea1a | 116 | return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX; |
af0bb3b1 | 117 | else |
7b65ea1a | 118 | return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX; |
9b6dbb09 | 119 | } |
7b65ea1a | 120 | wxCoord XLOG2DEVREL(wxCoord x) const |
9b6dbb09 | 121 | { |
af0bb3b1 | 122 | if (x > 0) |
7b65ea1a | 123 | return (wxCoord)((double)(x) * m_scaleX + 0.5); |
af0bb3b1 | 124 | else |
7b65ea1a | 125 | return (wxCoord)((double)(x) * m_scaleX - 0.5); |
9b6dbb09 | 126 | } |
7b65ea1a | 127 | wxCoord YLOG2DEV(wxCoord y) const |
9b6dbb09 | 128 | { |
7b65ea1a | 129 | wxCoord new_y = y - m_logicalOriginY; |
af0bb3b1 | 130 | if (new_y > 0) |
7b65ea1a | 131 | return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY; |
af0bb3b1 | 132 | else |
7b65ea1a | 133 | return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY; |
9b6dbb09 | 134 | } |
af0bb3b1 | 135 | // Without device translation, for backing pixmap purposes |
7b65ea1a | 136 | wxCoord YLOG2DEV_2(wxCoord y) const |
9b6dbb09 | 137 | { |
7b65ea1a | 138 | wxCoord new_y = y - m_logicalOriginY; |
af0bb3b1 | 139 | if (new_y > 0) |
7b65ea1a | 140 | return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY; |
af0bb3b1 | 141 | else |
7b65ea1a | 142 | return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY; |
9b6dbb09 | 143 | } |
7b65ea1a | 144 | wxCoord YLOG2DEVREL(wxCoord y) const |
9b6dbb09 | 145 | { |
af0bb3b1 | 146 | if (y > 0) |
7b65ea1a | 147 | return (wxCoord)((double)(y) * m_scaleY + 0.5); |
af0bb3b1 | 148 | else |
7b65ea1a | 149 | return (wxCoord)((double)(y) * m_scaleY - 0.5); |
9b6dbb09 | 150 | } |
d16b634f | 151 | |
af0bb3b1 VZ |
152 | public: |
153 | // not sure what for, but what is a mm on a screen you don't know the size of? | |
154 | double m_mm_to_pix_x,m_mm_to_pix_y; | |
d16b634f | 155 | |
af0bb3b1 VZ |
156 | // recompute scale? |
157 | bool m_needComputeScaleX, m_needComputeScaleY; | |
d16b634f | 158 | |
9b6dbb09 JS |
159 | }; |
160 | ||
161 | #endif | |
83df96d6 | 162 | // _WX_DC_H_ |