]> git.saurik.com Git - wxWidgets.git/blob - include/wx/x11/dc.h
removed #pragma interface because it results in link problems when building wxBase...
[wxWidgets.git] / include / wx / x11 / dc.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: dc.h
3 // Purpose: wxDC class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 17/09/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_DC_H_
13 #define _WX_DC_H_
14
15 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "dc.h"
17 #endif
18
19 #include "wx/pen.h"
20 #include "wx/brush.h"
21 #include "wx/icon.h"
22 #include "wx/font.h"
23 #include "wx/gdicmn.h"
24
25 //-----------------------------------------------------------------------------
26 // constants
27 //-----------------------------------------------------------------------------
28
29 #ifndef MM_TEXT
30 #define MM_TEXT 0
31 #define MM_ISOTROPIC 1
32 #define MM_ANISOTROPIC 2
33 #define MM_LOMETRIC 3
34 #define MM_HIMETRIC 4
35 #define MM_TWIPS 5
36 #define MM_POINTS 6
37 #define MM_METRIC 7
38 #endif
39
40 //-----------------------------------------------------------------------------
41 // wxDC
42 //-----------------------------------------------------------------------------
43
44 class WXDLLEXPORT wxDC : public wxDCBase
45 {
46 public:
47 wxDC();
48 ~wxDC() { }
49
50 // implement base class pure virtuals
51 // ----------------------------------
52
53 virtual void DestroyClippingRegion();
54
55 virtual wxSize GetPPI() const;
56
57 virtual void SetMapMode(int mode);
58 virtual void SetUserScale(double x, double y);
59 virtual void SetLogicalScale(double x, double y);
60 virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
61 virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
62 virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
63
64 protected:
65 virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
66 wxCoord width, wxCoord height);
67 virtual void DoGetSizeMM(int* width, int* height) const;
68
69 public:
70 void ComputeScaleAndOrigin();
71
72 wxCoord XDEV2LOG(wxCoord x) const
73 {
74 wxCoord new_x = x - m_deviceOriginX;
75 if (new_x > 0)
76 return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX;
77 else
78 return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX;
79 }
80 wxCoord XDEV2LOGREL(wxCoord x) const
81 {
82 if (x > 0)
83 return (wxCoord)((double)(x) / m_scaleX + 0.5);
84 else
85 return (wxCoord)((double)(x) / m_scaleX - 0.5);
86 }
87 wxCoord YDEV2LOG(wxCoord y) const
88 {
89 wxCoord new_y = y - m_deviceOriginY;
90 if (new_y > 0)
91 return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY;
92 else
93 return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY;
94 }
95 wxCoord YDEV2LOGREL(wxCoord y) const
96 {
97 if (y > 0)
98 return (wxCoord)((double)(y) / m_scaleY + 0.5);
99 else
100 return (wxCoord)((double)(y) / m_scaleY - 0.5);
101 }
102 wxCoord XLOG2DEV(wxCoord x) const
103 {
104 wxCoord new_x = x - m_logicalOriginX;
105 if (new_x > 0)
106 return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX;
107 else
108 return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX;
109 }
110 wxCoord XLOG2DEVREL(wxCoord x) const
111 {
112 if (x > 0)
113 return (wxCoord)((double)(x) * m_scaleX + 0.5);
114 else
115 return (wxCoord)((double)(x) * m_scaleX - 0.5);
116 }
117 wxCoord YLOG2DEV(wxCoord y) const
118 {
119 wxCoord new_y = y - m_logicalOriginY;
120 if (new_y > 0)
121 return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY;
122 else
123 return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY;
124 }
125 wxCoord YLOG2DEVREL(wxCoord y) const
126 {
127 if (y > 0)
128 return (wxCoord)((double)(y) * m_scaleY + 0.5);
129 else
130 return (wxCoord)((double)(y) * m_scaleY - 0.5);
131 }
132
133 public:
134 // not sure what for, but what is a mm on a screen you don't know the size of?
135 double m_mm_to_pix_x,m_mm_to_pix_y;
136
137 // recompute scale?
138 bool m_needComputeScaleX, m_needComputeScaleY;
139
140
141 private:
142 DECLARE_ABSTRACT_CLASS(wxDC)
143 };
144
145 #endif
146 // _WX_DC_H_