]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/dc.h
Minor improvement.
[wxWidgets.git] / include / wx / gtk / 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
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( long x, long y );
66 virtual void SetDeviceOrigin( long x, long y );
67
68 virtual void SetAxisOrientation( bool xLeftRight, bool yBottomUp );
69
70 // implementation
71 // --------------
72
73 virtual void ComputeScaleAndOrigin();
74
75 long XDEV2LOG(long x) const
76 {
77 long new_x = x - m_deviceOriginX;
78 if (new_x > 0)
79 return (long)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX;
80 else
81 return (long)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX;
82 }
83 long XDEV2LOGREL(long x) const
84 {
85 if (x > 0)
86 return (long)((double)(x) / m_scaleX + 0.5);
87 else
88 return (long)((double)(x) / m_scaleX - 0.5);
89 }
90 long YDEV2LOG(long y) const
91 {
92 long new_y = y - m_deviceOriginY;
93 if (new_y > 0)
94 return (long)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY;
95 else
96 return (long)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY;
97 }
98 long YDEV2LOGREL(long y) const
99 {
100 if (y > 0)
101 return (long)((double)(y) / m_scaleY + 0.5);
102 else
103 return (long)((double)(y) / m_scaleY - 0.5);
104 }
105 long XLOG2DEV(long x) const
106 {
107 long new_x = x - m_logicalOriginX;
108 if (new_x > 0)
109 return (long)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX;
110 else
111 return (long)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX;
112 }
113 long XLOG2DEVREL(long x) const
114 {
115 if (x > 0)
116 return (long)((double)(x) * m_scaleX + 0.5);
117 else
118 return (long)((double)(x) * m_scaleX - 0.5);
119 }
120 long YLOG2DEV(long y) const
121 {
122 long new_y = y - m_logicalOriginY;
123 if (new_y > 0)
124 return (long)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY;
125 else
126 return (long)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY;
127 }
128 long YLOG2DEVREL(long y) const
129 {
130 if (y > 0)
131 return (long)((double)(y) * m_scaleY + 0.5);
132 else
133 return (long)((double)(y) * m_scaleY - 0.5);
134 }
135
136 protected:
137 // base class pure virtuals implemented here
138 virtual void DoSetClippingRegion(long x, long y, long width, long 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__