]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk1/dc.h
82f2ae49e788599b5eb045e3980f542187e03460
[wxWidgets.git] / include / wx / gtk1 / dc.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk1/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 // classes
15 //-----------------------------------------------------------------------------
16
17 class WXDLLIMPEXP_CORE wxDC;
18
19 //-----------------------------------------------------------------------------
20 // constants
21 //-----------------------------------------------------------------------------
22
23 #ifndef MM_TEXT
24 #define MM_TEXT 0
25 #define MM_ISOTROPIC 1
26 #define MM_ANISOTROPIC 2
27 #define MM_LOMETRIC 3
28 #define MM_HIMETRIC 4
29 #define MM_TWIPS 5
30 #define MM_POINTS 6
31 #define MM_METRIC 7
32 #endif
33
34 //-----------------------------------------------------------------------------
35 // wxDC
36 //-----------------------------------------------------------------------------
37
38 class WXDLLIMPEXP_CORE wxDC : public wxDCBase
39 {
40 public:
41 wxDC();
42 virtual ~wxDC() { }
43
44 #if wxUSE_PALETTE
45 void SetColourMap( const wxPalette& palette ) { SetPalette(palette); };
46 #endif // wxUSE_PALETTE
47
48 // Resolution in pixels per logical inch
49 virtual wxSize GetPPI() const;
50
51 virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return true; }
52 virtual void EndDoc() { }
53 virtual void StartPage() { }
54 virtual void EndPage() { }
55
56 virtual void SetMapMode( int mode );
57 virtual void SetUserScale( double x, double y );
58 virtual void SetLogicalScale( double x, double y );
59 virtual void SetLogicalOrigin( wxCoord x, wxCoord y );
60 virtual void SetDeviceOrigin( wxCoord x, wxCoord y );
61
62 virtual void SetAxisOrientation( bool xLeftRight, bool yBottomUp );
63
64 // implementation
65 // --------------
66
67 virtual void ComputeScaleAndOrigin();
68
69 virtual GdkWindow* GetGDKWindow() const { return NULL; }
70
71 wxCoord XDEV2LOG(wxCoord x) const
72 {
73 wxCoord new_x = x - m_deviceOriginX;
74 if (new_x > 0)
75 return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX;
76 else
77 return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX;
78 }
79 wxCoord XDEV2LOGREL(wxCoord x) const
80 {
81 if (x > 0)
82 return (wxCoord)((double)(x) / m_scaleX + 0.5);
83 else
84 return (wxCoord)((double)(x) / m_scaleX - 0.5);
85 }
86 wxCoord YDEV2LOG(wxCoord y) const
87 {
88 wxCoord new_y = y - m_deviceOriginY;
89 if (new_y > 0)
90 return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY;
91 else
92 return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY;
93 }
94 wxCoord YDEV2LOGREL(wxCoord y) const
95 {
96 if (y > 0)
97 return (wxCoord)((double)(y) / m_scaleY + 0.5);
98 else
99 return (wxCoord)((double)(y) / m_scaleY - 0.5);
100 }
101 wxCoord XLOG2DEV(wxCoord x) const
102 {
103 wxCoord new_x = x - m_logicalOriginX;
104 if (new_x > 0)
105 return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX;
106 else
107 return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX;
108 }
109 wxCoord XLOG2DEVREL(wxCoord x) const
110 {
111 if (x > 0)
112 return (wxCoord)((double)(x) * m_scaleX + 0.5);
113 else
114 return (wxCoord)((double)(x) * m_scaleX - 0.5);
115 }
116 wxCoord YLOG2DEV(wxCoord y) const
117 {
118 wxCoord new_y = y - m_logicalOriginY;
119 if (new_y > 0)
120 return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY;
121 else
122 return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY;
123 }
124 wxCoord YLOG2DEVREL(wxCoord y) const
125 {
126 if (y > 0)
127 return (wxCoord)((double)(y) * m_scaleY + 0.5);
128 else
129 return (wxCoord)((double)(y) * m_scaleY - 0.5);
130 }
131
132 protected:
133 // base class pure virtuals implemented here
134 virtual void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
135 virtual void DoGetSizeMM(int* width, int* height) const;
136
137 public:
138 // GTK-specific member variables
139
140 // not sure what for, but what is a mm on a screen you don't know the size
141 // of?
142 double m_mm_to_pix_x,
143 m_mm_to_pix_y;
144
145 bool m_needComputeScaleX,
146 m_needComputeScaleY; // not yet used
147
148
149 private:
150 DECLARE_ABSTRACT_CLASS(wxDC)
151 };
152
153 // this must be defined when wxDC::Blit() honours the DC origian and needed to
154 // allow wxUniv code in univ/winuniv.cpp to work with versions of wxGTK
155 // 2.3.[23]
156 #ifndef wxHAS_WORKING_GTK_DC_BLIT
157 #define wxHAS_WORKING_GTK_DC_BLIT
158 #endif
159
160 #endif // __GTKDCH__