]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: dc.h | |
3 | // Purpose: | |
4 | // Author: Robert Roebling | |
dbf858b5 RR |
5 | // Id: $Id$ |
6 | // Copyright: (c) 1998 Robert Roebling | |
8bbe427f | 7 | // Licence: wxWindows licence |
c801d85f KB |
8 | ///////////////////////////////////////////////////////////////////////////// |
9 | ||
10 | ||
11 | #ifndef __GTKDCH__ | |
12 | #define __GTKDCH__ | |
13 | ||
14 | #ifdef __GNUG__ | |
15 | #pragma interface | |
16 | #endif | |
17 | ||
c801d85f KB |
18 | //----------------------------------------------------------------------------- |
19 | // classes | |
20 | //----------------------------------------------------------------------------- | |
21 | ||
22 | class wxDC; | |
23 | ||
24 | //----------------------------------------------------------------------------- | |
25 | // constants | |
26 | //----------------------------------------------------------------------------- | |
27 | ||
a23fd0e1 | 28 | #define MM_TEXT 0 |
8bbe427f | 29 | #define MM_ISOTROPIC 1 |
a23fd0e1 VZ |
30 | #define MM_ANISOTROPIC 2 |
31 | #define MM_LOMETRIC 3 | |
32 | #define MM_HIMETRIC 4 | |
33 | #define MM_TWIPS 5 | |
34 | #define MM_POINTS 6 | |
35 | #define MM_METRIC 7 | |
c801d85f KB |
36 | |
37 | //----------------------------------------------------------------------------- | |
38 | // wxDC | |
39 | //----------------------------------------------------------------------------- | |
40 | ||
a23fd0e1 | 41 | class wxDC : public wxDCBase |
c801d85f | 42 | { |
463c1fa1 | 43 | public: |
a23fd0e1 VZ |
44 | wxDC(); |
45 | ~wxDC() { } | |
c801d85f | 46 | |
a23fd0e1 | 47 | void SetColourMap( const wxPalette& palette ) { SetPalette(palette); }; |
8bbe427f | 48 | |
c801d85f | 49 | // the first two must be overridden and called |
a23fd0e1 | 50 | virtual void DestroyClippingRegion(); |
8bbe427f | 51 | |
a23fd0e1 VZ |
52 | // Resolution in pixels per logical inch |
53 | virtual wxSize GetPPI() const; | |
c801d85f | 54 | |
a23fd0e1 VZ |
55 | virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return TRUE; } |
56 | virtual void EndDoc() { } | |
57 | virtual void StartPage() { } | |
58 | virtual void EndPage() { } | |
8bbe427f | 59 | |
a23fd0e1 VZ |
60 | virtual void SetMapMode( int mode ); |
61 | virtual void SetUserScale( double x, double y ); | |
62 | virtual void SetLogicalScale( double x, double y ); | |
72cdf4c9 VZ |
63 | virtual void SetLogicalOrigin( wxCoord x, wxCoord y ); |
64 | virtual void SetDeviceOrigin( wxCoord x, wxCoord y ); | |
8bbe427f | 65 | |
a23fd0e1 | 66 | virtual void SetAxisOrientation( bool xLeftRight, bool yBottomUp ); |
c801d85f | 67 | |
a23fd0e1 VZ |
68 | // implementation |
69 | // -------------- | |
8bbe427f | 70 | |
238d735d | 71 | virtual void ComputeScaleAndOrigin(); |
8bbe427f | 72 | |
72cdf4c9 | 73 | wxCoord XDEV2LOG(wxCoord x) const |
a23fd0e1 | 74 | { |
72cdf4c9 | 75 | wxCoord new_x = x - m_deviceOriginX; |
a23fd0e1 | 76 | if (new_x > 0) |
72cdf4c9 | 77 | return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX; |
a23fd0e1 | 78 | else |
72cdf4c9 | 79 | return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX; |
a23fd0e1 | 80 | } |
72cdf4c9 | 81 | wxCoord XDEV2LOGREL(wxCoord x) const |
a23fd0e1 VZ |
82 | { |
83 | if (x > 0) | |
72cdf4c9 | 84 | return (wxCoord)((double)(x) / m_scaleX + 0.5); |
a23fd0e1 | 85 | else |
72cdf4c9 | 86 | return (wxCoord)((double)(x) / m_scaleX - 0.5); |
a23fd0e1 | 87 | } |
72cdf4c9 | 88 | wxCoord YDEV2LOG(wxCoord y) const |
a23fd0e1 | 89 | { |
72cdf4c9 | 90 | wxCoord new_y = y - m_deviceOriginY; |
a23fd0e1 | 91 | if (new_y > 0) |
72cdf4c9 | 92 | return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY; |
a23fd0e1 | 93 | else |
72cdf4c9 | 94 | return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY; |
a23fd0e1 | 95 | } |
72cdf4c9 | 96 | wxCoord YDEV2LOGREL(wxCoord y) const |
a23fd0e1 VZ |
97 | { |
98 | if (y > 0) | |
72cdf4c9 | 99 | return (wxCoord)((double)(y) / m_scaleY + 0.5); |
a23fd0e1 | 100 | else |
72cdf4c9 | 101 | return (wxCoord)((double)(y) / m_scaleY - 0.5); |
a23fd0e1 | 102 | } |
72cdf4c9 | 103 | wxCoord XLOG2DEV(wxCoord x) const |
a23fd0e1 | 104 | { |
72cdf4c9 | 105 | wxCoord new_x = x - m_logicalOriginX; |
a23fd0e1 | 106 | if (new_x > 0) |
72cdf4c9 | 107 | return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX; |
a23fd0e1 | 108 | else |
72cdf4c9 | 109 | return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX; |
a23fd0e1 | 110 | } |
72cdf4c9 | 111 | wxCoord XLOG2DEVREL(wxCoord x) const |
a23fd0e1 VZ |
112 | { |
113 | if (x > 0) | |
72cdf4c9 | 114 | return (wxCoord)((double)(x) * m_scaleX + 0.5); |
a23fd0e1 | 115 | else |
72cdf4c9 | 116 | return (wxCoord)((double)(x) * m_scaleX - 0.5); |
a23fd0e1 | 117 | } |
72cdf4c9 | 118 | wxCoord YLOG2DEV(wxCoord y) const |
a23fd0e1 | 119 | { |
72cdf4c9 | 120 | wxCoord new_y = y - m_logicalOriginY; |
a23fd0e1 | 121 | if (new_y > 0) |
72cdf4c9 | 122 | return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY; |
a23fd0e1 | 123 | else |
72cdf4c9 | 124 | return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY; |
a23fd0e1 | 125 | } |
72cdf4c9 | 126 | wxCoord YLOG2DEVREL(wxCoord y) const |
a23fd0e1 VZ |
127 | { |
128 | if (y > 0) | |
72cdf4c9 | 129 | return (wxCoord)((double)(y) * m_scaleY + 0.5); |
a23fd0e1 | 130 | else |
72cdf4c9 | 131 | return (wxCoord)((double)(y) * m_scaleY - 0.5); |
a23fd0e1 VZ |
132 | } |
133 | ||
134 | protected: | |
135 | // base class pure virtuals implemented here | |
72cdf4c9 | 136 | virtual void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
a23fd0e1 VZ |
137 | virtual void DoGetSize(int *width, int *height) const; |
138 | virtual void DoGetSizeMM(int* width, int* height) const; | |
8bbe427f | 139 | |
a23fd0e1 VZ |
140 | public: |
141 | // GTK-specific member variables | |
8bbe427f | 142 | |
a23fd0e1 VZ |
143 | // not sure what for, but what is a mm on a screen you don't know the size |
144 | // of? | |
145 | double m_mm_to_pix_x, | |
146 | m_mm_to_pix_y; | |
8bbe427f | 147 | |
a23fd0e1 VZ |
148 | bool m_needComputeScaleX, |
149 | m_needComputeScaleY; // not yet used | |
8bbe427f | 150 | |
c801d85f | 151 | float m_scaleFactor; // wxPSDC wants to have this. Will disappear. |
20e05ffb RR |
152 | |
153 | private: | |
154 | DECLARE_ABSTRACT_CLASS(wxDC) | |
c801d85f KB |
155 | }; |
156 | ||
157 | #endif // __GTKDCH__ |