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