]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk1/dc.h
Explicit casting/instantiation to resolve ambiguous overload.
[wxWidgets.git] / include / wx / gtk1 / dc.h
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: dc.h
3// Purpose:
4// Author: Robert Roebling
dbf858b5
RR
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
8bbe427f 7// Licence: wxWindows licence
c801d85f
KB
8/////////////////////////////////////////////////////////////////////////////
9
10
11#ifndef __GTKDCH__
12#define __GTKDCH__
13
14#ifdef __GNUG__
15#pragma interface
16#endif
17
c801d85f
KB
18//-----------------------------------------------------------------------------
19// classes
20//-----------------------------------------------------------------------------
21
22class wxDC;
23
24//-----------------------------------------------------------------------------
25// constants
26//-----------------------------------------------------------------------------
27
a23fd0e1 28#define MM_TEXT 0
8bbe427f 29#define MM_ISOTROPIC 1
a23fd0e1
VZ
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
c801d85f
KB
36
37//-----------------------------------------------------------------------------
38// wxDC
39//-----------------------------------------------------------------------------
40
a23fd0e1 41class wxDC : public wxDCBase
c801d85f 42{
a23fd0e1 43 DECLARE_ABSTRACT_CLASS(wxDC)
c801d85f 44
463c1fa1 45public:
a23fd0e1
VZ
46 wxDC();
47 ~wxDC() { }
c801d85f 48
a23fd0e1 49 void SetColourMap( const wxPalette& palette ) { SetPalette(palette); };
8bbe427f 50
c801d85f 51 // the first two must be overridden and called
a23fd0e1 52 virtual void DestroyClippingRegion();
8bbe427f 53
a23fd0e1
VZ
54 // Resolution in pixels per logical inch
55 virtual wxSize GetPPI() const;
c801d85f 56
a23fd0e1
VZ
57 virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return TRUE; }
58 virtual void EndDoc() { }
59 virtual void StartPage() { }
60 virtual void EndPage() { }
8bbe427f 61
a23fd0e1
VZ
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 );
8bbe427f 67
a23fd0e1 68 virtual void SetAxisOrientation( bool xLeftRight, bool yBottomUp );
c801d85f 69
a23fd0e1
VZ
70 // implementation
71 // --------------
8bbe427f 72
238d735d 73 virtual void ComputeScaleAndOrigin();
8bbe427f 74
c801d85f 75 long XDEV2LOG(long x) const
a23fd0e1
VZ
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 }
c801d85f 83 long XDEV2LOGREL(long x) const
a23fd0e1
VZ
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 }
c801d85f 90 long YDEV2LOG(long y) const
a23fd0e1
VZ
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 }
c801d85f 98 long YDEV2LOGREL(long y) const
a23fd0e1
VZ
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 }
c801d85f 105 long XLOG2DEV(long x) const
a23fd0e1
VZ
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 }
c801d85f 113 long XLOG2DEVREL(long x) const
a23fd0e1
VZ
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 }
c801d85f 120 long YLOG2DEV(long y) const
a23fd0e1
VZ
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 }
c801d85f 128 long YLOG2DEVREL(long y) const
a23fd0e1
VZ
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
136protected:
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;
8bbe427f 141
a23fd0e1
VZ
142public:
143 // GTK-specific member variables
8bbe427f 144
a23fd0e1
VZ
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;
8bbe427f 149
a23fd0e1
VZ
150 bool m_needComputeScaleX,
151 m_needComputeScaleY; // not yet used
8bbe427f 152
c801d85f 153 float m_scaleFactor; // wxPSDC wants to have this. Will disappear.
c801d85f
KB
154};
155
156#endif // __GTKDCH__