]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/dc.h
renamed GlobalPtr to GlobalPtrLock
[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
10
11#ifndef __GTKDCH__
12#define __GTKDCH__
13
12028905 14#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
c801d85f
KB
15#pragma interface
16#endif
17
c801d85f
KB
18//-----------------------------------------------------------------------------
19// classes
20//-----------------------------------------------------------------------------
21
22class wxDC;
23
24//-----------------------------------------------------------------------------
25// constants
26//-----------------------------------------------------------------------------
27
d2b1753d 28#ifndef MM_TEXT
a23fd0e1 29#define MM_TEXT 0
8bbe427f 30#define MM_ISOTROPIC 1
a23fd0e1
VZ
31#define MM_ANISOTROPIC 2
32#define MM_LOMETRIC 3
33#define MM_HIMETRIC 4
34#define MM_TWIPS 5
35#define MM_POINTS 6
36#define MM_METRIC 7
d2b1753d 37#endif
c801d85f
KB
38
39//-----------------------------------------------------------------------------
40// wxDC
41//-----------------------------------------------------------------------------
42
a23fd0e1 43class wxDC : public wxDCBase
c801d85f 44{
463c1fa1 45public:
a23fd0e1
VZ
46 wxDC();
47 ~wxDC() { }
c801d85f 48
a23fd0e1 49 void SetColourMap( const wxPalette& palette ) { SetPalette(palette); };
8bbe427f 50
a23fd0e1
VZ
51 // Resolution in pixels per logical inch
52 virtual wxSize GetPPI() const;
c801d85f 53
b1263dcf 54 virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return true; }
a23fd0e1
VZ
55 virtual void EndDoc() { }
56 virtual void StartPage() { }
57 virtual void EndPage() { }
8bbe427f 58
a23fd0e1
VZ
59 virtual void SetMapMode( int mode );
60 virtual void SetUserScale( double x, double y );
61 virtual void SetLogicalScale( double x, double y );
72cdf4c9
VZ
62 virtual void SetLogicalOrigin( wxCoord x, wxCoord y );
63 virtual void SetDeviceOrigin( wxCoord x, wxCoord y );
8bbe427f 64
a23fd0e1 65 virtual void SetAxisOrientation( bool xLeftRight, bool yBottomUp );
c801d85f 66
a23fd0e1
VZ
67 // implementation
68 // --------------
8bbe427f 69
238d735d 70 virtual void ComputeScaleAndOrigin();
8bbe427f 71
72cdf4c9 72 wxCoord XDEV2LOG(wxCoord x) const
a23fd0e1 73 {
72cdf4c9 74 wxCoord new_x = x - m_deviceOriginX;
a23fd0e1 75 if (new_x > 0)
72cdf4c9 76 return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX;
a23fd0e1 77 else
72cdf4c9 78 return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX;
a23fd0e1 79 }
72cdf4c9 80 wxCoord XDEV2LOGREL(wxCoord x) const
a23fd0e1
VZ
81 {
82 if (x > 0)
72cdf4c9 83 return (wxCoord)((double)(x) / m_scaleX + 0.5);
a23fd0e1 84 else
72cdf4c9 85 return (wxCoord)((double)(x) / m_scaleX - 0.5);
a23fd0e1 86 }
72cdf4c9 87 wxCoord YDEV2LOG(wxCoord y) const
a23fd0e1 88 {
72cdf4c9 89 wxCoord new_y = y - m_deviceOriginY;
a23fd0e1 90 if (new_y > 0)
72cdf4c9 91 return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY;
a23fd0e1 92 else
72cdf4c9 93 return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY;
a23fd0e1 94 }
72cdf4c9 95 wxCoord YDEV2LOGREL(wxCoord y) const
a23fd0e1
VZ
96 {
97 if (y > 0)
72cdf4c9 98 return (wxCoord)((double)(y) / m_scaleY + 0.5);
a23fd0e1 99 else
72cdf4c9 100 return (wxCoord)((double)(y) / m_scaleY - 0.5);
a23fd0e1 101 }
72cdf4c9 102 wxCoord XLOG2DEV(wxCoord x) const
a23fd0e1 103 {
72cdf4c9 104 wxCoord new_x = x - m_logicalOriginX;
a23fd0e1 105 if (new_x > 0)
72cdf4c9 106 return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX;
a23fd0e1 107 else
72cdf4c9 108 return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX;
a23fd0e1 109 }
72cdf4c9 110 wxCoord XLOG2DEVREL(wxCoord x) const
a23fd0e1
VZ
111 {
112 if (x > 0)
72cdf4c9 113 return (wxCoord)((double)(x) * m_scaleX + 0.5);
a23fd0e1 114 else
72cdf4c9 115 return (wxCoord)((double)(x) * m_scaleX - 0.5);
a23fd0e1 116 }
72cdf4c9 117 wxCoord YLOG2DEV(wxCoord y) const
a23fd0e1 118 {
72cdf4c9 119 wxCoord new_y = y - m_logicalOriginY;
a23fd0e1 120 if (new_y > 0)
72cdf4c9 121 return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY;
a23fd0e1 122 else
72cdf4c9 123 return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY;
a23fd0e1 124 }
72cdf4c9 125 wxCoord YLOG2DEVREL(wxCoord y) const
a23fd0e1
VZ
126 {
127 if (y > 0)
72cdf4c9 128 return (wxCoord)((double)(y) * m_scaleY + 0.5);
a23fd0e1 129 else
72cdf4c9 130 return (wxCoord)((double)(y) * m_scaleY - 0.5);
a23fd0e1
VZ
131 }
132
133protected:
134 // base class pure virtuals implemented here
72cdf4c9 135 virtual void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
a23fd0e1 136 virtual void DoGetSizeMM(int* width, int* height) const;
8bbe427f 137
a23fd0e1
VZ
138public:
139 // GTK-specific member variables
8bbe427f 140
a23fd0e1
VZ
141 // not sure what for, but what is a mm on a screen you don't know the size
142 // of?
143 double m_mm_to_pix_x,
144 m_mm_to_pix_y;
8bbe427f 145
a23fd0e1
VZ
146 bool m_needComputeScaleX,
147 m_needComputeScaleY; // not yet used
8bbe427f 148
c3e44503 149
20e05ffb
RR
150private:
151 DECLARE_ABSTRACT_CLASS(wxDC)
c801d85f
KB
152};
153
c3e44503
VZ
154// this must be defined when wxDC::Blit() honours the DC origian and needed to
155// allow wxUniv code in univ/winuniv.cpp to work with versions of wxGTK
156// 2.3.[23]
157#ifndef wxHAS_WORKING_GTK_DC_BLIT
158 #define wxHAS_WORKING_GTK_DC_BLIT
159#endif
160
c801d85f 161#endif // __GTKDCH__