]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/dc.h
refactored wxGTK scrolling: it has now fully-functioning wxScrollHelper and a lot...
[wxWidgets.git] / include / wx / gtk / 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
65571936 7// Licence: wxWindows licence
c801d85f
KB
8/////////////////////////////////////////////////////////////////////////////
9
c801d85f
KB
10#ifndef __GTKDCH__
11#define __GTKDCH__
12
c801d85f
KB
13//-----------------------------------------------------------------------------
14// classes
15//-----------------------------------------------------------------------------
16
20123d49 17class WXDLLIMPEXP_CORE wxDC;
c801d85f
KB
18
19//-----------------------------------------------------------------------------
20// constants
21//-----------------------------------------------------------------------------
22
d2b1753d 23#ifndef MM_TEXT
a23fd0e1 24#define MM_TEXT 0
8bbe427f 25#define MM_ISOTROPIC 1
a23fd0e1
VZ
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
d2b1753d 32#endif
c801d85f
KB
33
34//-----------------------------------------------------------------------------
35// wxDC
36//-----------------------------------------------------------------------------
37
20123d49 38class WXDLLIMPEXP_CORE wxDC : public wxDCBase
c801d85f 39{
463c1fa1 40public:
a23fd0e1
VZ
41 wxDC();
42 ~wxDC() { }
c801d85f 43
a23fd0e1 44 void SetColourMap( const wxPalette& palette ) { SetPalette(palette); };
8bbe427f 45
a23fd0e1
VZ
46 // Resolution in pixels per logical inch
47 virtual wxSize GetPPI() const;
c801d85f 48
b1263dcf 49 virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return true; }
a23fd0e1
VZ
50 virtual void EndDoc() { }
51 virtual void StartPage() { }
52 virtual void EndPage() { }
8bbe427f 53
a23fd0e1
VZ
54 virtual void SetMapMode( int mode );
55 virtual void SetUserScale( double x, double y );
56 virtual void SetLogicalScale( double x, double y );
72cdf4c9
VZ
57 virtual void SetLogicalOrigin( wxCoord x, wxCoord y );
58 virtual void SetDeviceOrigin( wxCoord x, wxCoord y );
8bbe427f 59
a23fd0e1 60 virtual void SetAxisOrientation( bool xLeftRight, bool yBottomUp );
c801d85f 61
a23fd0e1
VZ
62 // implementation
63 // --------------
8bbe427f 64
238d735d 65 virtual void ComputeScaleAndOrigin();
8bbe427f 66
72cdf4c9 67 wxCoord XDEV2LOG(wxCoord x) const
a23fd0e1 68 {
72cdf4c9 69 wxCoord new_x = x - m_deviceOriginX;
a23fd0e1 70 if (new_x > 0)
72cdf4c9 71 return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX;
a23fd0e1 72 else
72cdf4c9 73 return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX;
a23fd0e1 74 }
72cdf4c9 75 wxCoord XDEV2LOGREL(wxCoord x) const
a23fd0e1
VZ
76 {
77 if (x > 0)
72cdf4c9 78 return (wxCoord)((double)(x) / m_scaleX + 0.5);
a23fd0e1 79 else
72cdf4c9 80 return (wxCoord)((double)(x) / m_scaleX - 0.5);
a23fd0e1 81 }
72cdf4c9 82 wxCoord YDEV2LOG(wxCoord y) const
a23fd0e1 83 {
72cdf4c9 84 wxCoord new_y = y - m_deviceOriginY;
a23fd0e1 85 if (new_y > 0)
72cdf4c9 86 return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY;
a23fd0e1 87 else
72cdf4c9 88 return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY;
a23fd0e1 89 }
72cdf4c9 90 wxCoord YDEV2LOGREL(wxCoord y) const
a23fd0e1
VZ
91 {
92 if (y > 0)
72cdf4c9 93 return (wxCoord)((double)(y) / m_scaleY + 0.5);
a23fd0e1 94 else
72cdf4c9 95 return (wxCoord)((double)(y) / m_scaleY - 0.5);
a23fd0e1 96 }
72cdf4c9 97 wxCoord XLOG2DEV(wxCoord x) const
a23fd0e1 98 {
72cdf4c9 99 wxCoord new_x = x - m_logicalOriginX;
a23fd0e1 100 if (new_x > 0)
72cdf4c9 101 return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX;
a23fd0e1 102 else
72cdf4c9 103 return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX;
a23fd0e1 104 }
72cdf4c9 105 wxCoord XLOG2DEVREL(wxCoord x) const
a23fd0e1
VZ
106 {
107 if (x > 0)
72cdf4c9 108 return (wxCoord)((double)(x) * m_scaleX + 0.5);
a23fd0e1 109 else
72cdf4c9 110 return (wxCoord)((double)(x) * m_scaleX - 0.5);
a23fd0e1 111 }
72cdf4c9 112 wxCoord YLOG2DEV(wxCoord y) const
a23fd0e1 113 {
72cdf4c9 114 wxCoord new_y = y - m_logicalOriginY;
a23fd0e1 115 if (new_y > 0)
72cdf4c9 116 return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY;
a23fd0e1 117 else
72cdf4c9 118 return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY;
a23fd0e1 119 }
72cdf4c9 120 wxCoord YLOG2DEVREL(wxCoord y) const
a23fd0e1
VZ
121 {
122 if (y > 0)
72cdf4c9 123 return (wxCoord)((double)(y) * m_scaleY + 0.5);
a23fd0e1 124 else
72cdf4c9 125 return (wxCoord)((double)(y) * m_scaleY - 0.5);
a23fd0e1
VZ
126 }
127
128protected:
129 // base class pure virtuals implemented here
72cdf4c9 130 virtual void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
a23fd0e1 131 virtual void DoGetSizeMM(int* width, int* height) const;
8bbe427f 132
a23fd0e1
VZ
133public:
134 // GTK-specific member variables
8bbe427f 135
a23fd0e1
VZ
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;
8bbe427f 140
a23fd0e1
VZ
141 bool m_needComputeScaleX,
142 m_needComputeScaleY; // not yet used
8bbe427f 143
c3e44503 144
20e05ffb
RR
145private:
146 DECLARE_ABSTRACT_CLASS(wxDC)
c801d85f
KB
147};
148
c3e44503
VZ
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
c801d85f 156#endif // __GTKDCH__