]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk1/dc.h
Made device to logical and vv conversion methods
[wxWidgets.git] / include / wx / gtk1 / dc.h
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
8ef94bfc 2// Name: wx/gtk1/dc.h
c801d85f
KB
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 41 wxDC();
d3c7fc99 42 virtual ~wxDC() { }
c801d85f 43
0b04c4e0 44#if wxUSE_PALETTE
a23fd0e1 45 void SetColourMap( const wxPalette& palette ) { SetPalette(palette); };
0b04c4e0 46#endif // wxUSE_PALETTE
8bbe427f 47
a23fd0e1
VZ
48 // Resolution in pixels per logical inch
49 virtual wxSize GetPPI() const;
c801d85f 50
b1263dcf 51 virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return true; }
a23fd0e1
VZ
52 virtual void EndDoc() { }
53 virtual void StartPage() { }
54 virtual void EndPage() { }
8bbe427f 55
621b83d9
RR
56 virtual wxCoord DeviceToLogicalX(wxCoord x) const;
57 virtual wxCoord DeviceToLogicalY(wxCoord y) const;
58 virtual wxCoord DeviceToLogicalXRel(wxCoord x) const;
59 virtual wxCoord DeviceToLogicalYRel(wxCoord y) const;
60 virtual wxCoord LogicalToDeviceX(wxCoord x) const;
61 virtual wxCoord LogicalToDeviceY(wxCoord y) const;
62 virtual wxCoord LogicalToDeviceXRel(wxCoord x) const;
63 virtual wxCoord LogicalToDeviceYRel(wxCoord y) const ;
64
a23fd0e1
VZ
65 virtual void SetMapMode( int mode );
66 virtual void SetUserScale( double x, double y );
67 virtual void SetLogicalScale( double x, double y );
72cdf4c9
VZ
68 virtual void SetLogicalOrigin( wxCoord x, wxCoord y );
69 virtual void SetDeviceOrigin( wxCoord x, wxCoord y );
8bbe427f 70
a23fd0e1 71 virtual void SetAxisOrientation( bool xLeftRight, bool yBottomUp );
c801d85f 72
a23fd0e1
VZ
73 // implementation
74 // --------------
8bbe427f 75
238d735d 76 virtual void ComputeScaleAndOrigin();
8bbe427f 77
2e992e06
VZ
78 virtual GdkWindow* GetGDKWindow() const { return NULL; }
79
72cdf4c9 80 wxCoord XDEV2LOG(wxCoord x) const
a23fd0e1 81 {
5a70d3f5 82 return wxRound((double)(x - m_deviceOriginX) / m_scaleX) * m_signX + m_logicalOriginX;
a23fd0e1 83 }
72cdf4c9 84 wxCoord XDEV2LOGREL(wxCoord x) const
a23fd0e1 85 {
5a70d3f5 86 return wxRound((double)(x) / m_scaleX);
a23fd0e1 87 }
72cdf4c9 88 wxCoord YDEV2LOG(wxCoord y) const
a23fd0e1 89 {
5a70d3f5 90 return wxRound((double)(y - m_deviceOriginY) / m_scaleY) * m_signY + m_logicalOriginY;
a23fd0e1 91 }
72cdf4c9 92 wxCoord YDEV2LOGREL(wxCoord y) const
a23fd0e1 93 {
5a70d3f5 94 return wxRound((double)(y) / m_scaleY);
a23fd0e1 95 }
72cdf4c9 96 wxCoord XLOG2DEV(wxCoord x) const
a23fd0e1 97 {
5a70d3f5 98 return wxRound((double)(x - m_logicalOriginX) * m_scaleX) * m_signX + m_deviceOriginX;
a23fd0e1 99 }
72cdf4c9 100 wxCoord XLOG2DEVREL(wxCoord x) const
a23fd0e1 101 {
5a70d3f5 102 return wxRound((double)(x) * m_scaleX);
a23fd0e1 103 }
72cdf4c9 104 wxCoord YLOG2DEV(wxCoord y) const
a23fd0e1 105 {
5a70d3f5 106 return wxRound((double)(y - m_logicalOriginY) * m_scaleY) * m_signY + m_deviceOriginY;
a23fd0e1 107 }
72cdf4c9 108 wxCoord YLOG2DEVREL(wxCoord y) const
a23fd0e1 109 {
5a70d3f5 110 return wxRound((double)(y) * m_scaleY);
a23fd0e1
VZ
111 }
112
113protected:
114 // base class pure virtuals implemented here
72cdf4c9 115 virtual void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
a23fd0e1 116 virtual void DoGetSizeMM(int* width, int* height) const;
8bbe427f 117
a23fd0e1
VZ
118public:
119 // GTK-specific member variables
8bbe427f 120
a23fd0e1
VZ
121 // not sure what for, but what is a mm on a screen you don't know the size
122 // of?
123 double m_mm_to_pix_x,
124 m_mm_to_pix_y;
8bbe427f 125
a23fd0e1
VZ
126 bool m_needComputeScaleX,
127 m_needComputeScaleY; // not yet used
8bbe427f 128
c3e44503 129
20e05ffb
RR
130private:
131 DECLARE_ABSTRACT_CLASS(wxDC)
c801d85f
KB
132};
133
c3e44503
VZ
134// this must be defined when wxDC::Blit() honours the DC origian and needed to
135// allow wxUniv code in univ/winuniv.cpp to work with versions of wxGTK
136// 2.3.[23]
137#ifndef wxHAS_WORKING_GTK_DC_BLIT
138 #define wxHAS_WORKING_GTK_DC_BLIT
139#endif
140
c801d85f 141#endif // __GTKDCH__