]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk1/dc.h
Added a bug report; C++Builder compile fixes
[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 );
72cdf4c9
VZ
65 virtual void SetLogicalOrigin( wxCoord x, wxCoord y );
66 virtual void SetDeviceOrigin( wxCoord x, wxCoord 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
72cdf4c9 75 wxCoord XDEV2LOG(wxCoord x) const
a23fd0e1 76 {
72cdf4c9 77 wxCoord new_x = x - m_deviceOriginX;
a23fd0e1 78 if (new_x > 0)
72cdf4c9 79 return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX;
a23fd0e1 80 else
72cdf4c9 81 return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX;
a23fd0e1 82 }
72cdf4c9 83 wxCoord XDEV2LOGREL(wxCoord x) const
a23fd0e1
VZ
84 {
85 if (x > 0)
72cdf4c9 86 return (wxCoord)((double)(x) / m_scaleX + 0.5);
a23fd0e1 87 else
72cdf4c9 88 return (wxCoord)((double)(x) / m_scaleX - 0.5);
a23fd0e1 89 }
72cdf4c9 90 wxCoord YDEV2LOG(wxCoord y) const
a23fd0e1 91 {
72cdf4c9 92 wxCoord new_y = y - m_deviceOriginY;
a23fd0e1 93 if (new_y > 0)
72cdf4c9 94 return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY;
a23fd0e1 95 else
72cdf4c9 96 return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY;
a23fd0e1 97 }
72cdf4c9 98 wxCoord YDEV2LOGREL(wxCoord y) const
a23fd0e1
VZ
99 {
100 if (y > 0)
72cdf4c9 101 return (wxCoord)((double)(y) / m_scaleY + 0.5);
a23fd0e1 102 else
72cdf4c9 103 return (wxCoord)((double)(y) / m_scaleY - 0.5);
a23fd0e1 104 }
72cdf4c9 105 wxCoord XLOG2DEV(wxCoord x) const
a23fd0e1 106 {
72cdf4c9 107 wxCoord new_x = x - m_logicalOriginX;
a23fd0e1 108 if (new_x > 0)
72cdf4c9 109 return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX;
a23fd0e1 110 else
72cdf4c9 111 return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX;
a23fd0e1 112 }
72cdf4c9 113 wxCoord XLOG2DEVREL(wxCoord x) const
a23fd0e1
VZ
114 {
115 if (x > 0)
72cdf4c9 116 return (wxCoord)((double)(x) * m_scaleX + 0.5);
a23fd0e1 117 else
72cdf4c9 118 return (wxCoord)((double)(x) * m_scaleX - 0.5);
a23fd0e1 119 }
72cdf4c9 120 wxCoord YLOG2DEV(wxCoord y) const
a23fd0e1 121 {
72cdf4c9 122 wxCoord new_y = y - m_logicalOriginY;
a23fd0e1 123 if (new_y > 0)
72cdf4c9 124 return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY;
a23fd0e1 125 else
72cdf4c9 126 return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY;
a23fd0e1 127 }
72cdf4c9 128 wxCoord YLOG2DEVREL(wxCoord y) const
a23fd0e1
VZ
129 {
130 if (y > 0)
72cdf4c9 131 return (wxCoord)((double)(y) * m_scaleY + 0.5);
a23fd0e1 132 else
72cdf4c9 133 return (wxCoord)((double)(y) * m_scaleY - 0.5);
a23fd0e1
VZ
134 }
135
136protected:
137 // base class pure virtuals implemented here
72cdf4c9 138 virtual void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
a23fd0e1
VZ
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__