added wxWindow::IsDoubleBuffered() and improve wxBufferedDC (patch 1565330)
[wxWidgets.git] / include / wx / gtk / dc.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/dc.h
3 // Purpose:
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifndef __GTKDCH__
11 #define __GTKDCH__
12
13 //-----------------------------------------------------------------------------
14 // constants
15 //-----------------------------------------------------------------------------
16
17 #ifndef MM_TEXT
18 #define MM_TEXT 0
19 #define MM_ISOTROPIC 1
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
26 #endif
27
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
65 //-----------------------------------------------------------------------------
66 // wxDC
67 //-----------------------------------------------------------------------------
68
69 class WXDLLIMPEXP_CORE wxDC : public wxDCBase
70 {
71 public:
72 wxDC();
73 virtual ~wxDC() { }
74
75 #if wxUSE_PALETTE
76 void SetColourMap( const wxPalette& palette ) { SetPalette(palette); };
77 #endif // wxUSE_PALETTE
78
79 // Resolution in pixels per logical inch
80 virtual wxSize GetPPI() const;
81
82 virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return true; }
83 virtual void EndDoc() { }
84 virtual void StartPage() { }
85 virtual void EndPage() { }
86
87 virtual void SetMapMode( int mode );
88 virtual void SetUserScale( double x, double y );
89 virtual void SetLogicalScale( double x, double y );
90 virtual void SetLogicalOrigin( wxCoord x, wxCoord y );
91 virtual void SetDeviceOrigin( wxCoord x, wxCoord y );
92
93 virtual void SetAxisOrientation( bool xLeftRight, bool yBottomUp );
94
95 virtual void ComputeScaleAndOrigin();
96
97 virtual GdkWindow* GetGDKWindow() const { return NULL; }
98
99 protected:
100 // implementation
101 // --------------
102
103 wxCoord XDEV2LOG(wxCoord x) const
104 {
105 return DeviceToLogicalX(x);
106 }
107 wxCoord XDEV2LOGREL(wxCoord x) const
108 {
109 return DeviceToLogicalXRel(x);
110 }
111 wxCoord YDEV2LOG(wxCoord y) const
112 {
113 return DeviceToLogicalY(y);
114 }
115 wxCoord YDEV2LOGREL(wxCoord y) const
116 {
117 return DeviceToLogicalYRel(y);
118 }
119 wxCoord XLOG2DEV(wxCoord x) const
120 {
121 return LogicalToDeviceX(x);
122 }
123 wxCoord XLOG2DEVREL(wxCoord x) const
124 {
125 return LogicalToDeviceXRel(x);
126 }
127 wxCoord YLOG2DEV(wxCoord y) const
128 {
129 return LogicalToDeviceY(y);
130 }
131 wxCoord YLOG2DEVREL(wxCoord y) const
132 {
133 return LogicalToDeviceYRel(y);
134 }
135
136 // base class pure virtuals implemented here
137 virtual void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
138 virtual void DoGetSizeMM(int* width, int* height) const;
139
140 public:
141 // GTK-specific member variables
142
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;
147
148 bool m_needComputeScaleX,
149 m_needComputeScaleY; // not yet used
150
151
152 private:
153 DECLARE_ABSTRACT_CLASS(wxDC)
154 };
155
156 // this must be defined when wxDC::Blit() honours the DC origian and needed to
157 // allow wxUniv code in univ/winuniv.cpp to work with versions of wxGTK
158 // 2.3.[23]
159 #ifndef wxHAS_WORKING_GTK_DC_BLIT
160 #define wxHAS_WORKING_GTK_DC_BLIT
161 #endif
162
163 #endif // __GTKDCH__