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