]> git.saurik.com Git - wxWidgets.git/blob - include/wx/motif/dc.h
Ditribution script mods;
[wxWidgets.git] / include / wx / motif / 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 #ifdef __GNUG__
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 DECLARE_DYNAMIC_CLASS(wxDC)
47
48 public:
49 wxDC();
50 ~wxDC() { }
51
52 // implement base class pure virtuals
53 // ----------------------------------
54
55 virtual void DestroyClippingRegion();
56
57 virtual wxSize GetPPI() const;
58
59 virtual void SetMapMode(int mode);
60 virtual void SetUserScale(double x, double y);
61 virtual void SetLogicalScale(double x, double y);
62 virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
63 virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
64 virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
65
66 protected:
67 virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
68 virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
69 bool useMask = FALSE);
70
71 virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
72 wxCoord width, wxCoord height);
73 virtual void DoGetSize(int *width, int *height) const;
74 virtual void DoGetSizeMM(int* width, int* height) const;
75
76 public:
77 void ComputeScaleAndOrigin();
78
79 wxCoord XDEV2LOG(wxCoord x) const
80 {
81 wxCoord new_x = x - m_deviceOriginX;
82 if (new_x > 0)
83 return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX;
84 else
85 return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX;
86 }
87 wxCoord XDEV2LOGREL(wxCoord x) const
88 {
89 if (x > 0)
90 return (wxCoord)((double)(x) / m_scaleX + 0.5);
91 else
92 return (wxCoord)((double)(x) / m_scaleX - 0.5);
93 }
94 wxCoord YDEV2LOG(wxCoord y) const
95 {
96 wxCoord new_y = y - m_deviceOriginY;
97 if (new_y > 0)
98 return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY;
99 else
100 return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY;
101 }
102 wxCoord YDEV2LOGREL(wxCoord y) const
103 {
104 if (y > 0)
105 return (wxCoord)((double)(y) / m_scaleY + 0.5);
106 else
107 return (wxCoord)((double)(y) / m_scaleY - 0.5);
108 }
109 wxCoord XLOG2DEV(wxCoord x) const
110 {
111 wxCoord new_x = x - m_logicalOriginX;
112 if (new_x > 0)
113 return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX;
114 else
115 return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX;
116 }
117 // Without device translation, for backing pixmap purposes
118 wxCoord XLOG2DEV_2(wxCoord x) const
119 {
120 wxCoord new_x = x - m_logicalOriginX;
121 if (new_x > 0)
122 return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX;
123 else
124 return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX;
125 }
126 wxCoord XLOG2DEVREL(wxCoord x) const
127 {
128 if (x > 0)
129 return (wxCoord)((double)(x) * m_scaleX + 0.5);
130 else
131 return (wxCoord)((double)(x) * m_scaleX - 0.5);
132 }
133 wxCoord YLOG2DEV(wxCoord y) const
134 {
135 wxCoord new_y = y - m_logicalOriginY;
136 if (new_y > 0)
137 return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY;
138 else
139 return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY;
140 }
141 // Without device translation, for backing pixmap purposes
142 wxCoord YLOG2DEV_2(wxCoord y) const
143 {
144 wxCoord new_y = y - m_logicalOriginY;
145 if (new_y > 0)
146 return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY;
147 else
148 return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY;
149 }
150 wxCoord YLOG2DEVREL(wxCoord y) const
151 {
152 if (y > 0)
153 return (wxCoord)((double)(y) * m_scaleY + 0.5);
154 else
155 return (wxCoord)((double)(y) * m_scaleY - 0.5);
156 }
157
158 public:
159 // not sure what for, but what is a mm on a screen you don't know the size of?
160 double m_mm_to_pix_x,m_mm_to_pix_y;
161
162 // recompute scale?
163 bool m_needComputeScaleX, m_needComputeScaleY;
164
165 };
166
167 #endif
168 // _WX_DC_H_