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