]> git.saurik.com Git - wxWidgets.git/blob - include/wx/motif/dc.h
Further wxAUI commits
[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 #include "wx/pen.h"
16 #include "wx/brush.h"
17 #include "wx/icon.h"
18 #include "wx/font.h"
19 #include "wx/gdicmn.h"
20
21 //-----------------------------------------------------------------------------
22 // constants
23 //-----------------------------------------------------------------------------
24
25 #ifndef MM_TEXT
26 #define MM_TEXT 0
27 #define MM_ISOTROPIC 1
28 #define MM_ANISOTROPIC 2
29 #define MM_LOMETRIC 3
30 #define MM_HIMETRIC 4
31 #define MM_TWIPS 5
32 #define MM_POINTS 6
33 #define MM_METRIC 7
34 #endif
35
36 //-----------------------------------------------------------------------------
37 // wxDC
38 //-----------------------------------------------------------------------------
39
40 class WXDLLEXPORT wxDC : public wxDCBase
41 {
42 DECLARE_DYNAMIC_CLASS(wxDC)
43
44 public:
45 wxDC();
46 ~wxDC() { }
47
48 // implement base class pure virtuals
49 // ----------------------------------
50
51 virtual wxSize GetPPI() const;
52
53 virtual void SetMapMode(int mode);
54 virtual void SetUserScale(double x, double y);
55 virtual void SetLogicalScale(double x, double y);
56 virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
57 virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
58 virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
59
60 protected:
61 virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
62 virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
63 bool useMask = false);
64
65 virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
66 wxCoord width, wxCoord height);
67 virtual void DoGetSize(int *width, int *height) const;
68 virtual void DoGetSizeMM(int* width, int* height) const;
69
70 public:
71 virtual void ComputeScaleAndOrigin();
72
73 wxCoord XDEV2LOG(wxCoord x) const
74 {
75 wxCoord new_x = x - m_deviceOriginX;
76 if (new_x > 0)
77 return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX;
78 else
79 return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX;
80 }
81 wxCoord XDEV2LOGREL(wxCoord x) const
82 {
83 if (x > 0)
84 return (wxCoord)((double)(x) / m_scaleX + 0.5);
85 else
86 return (wxCoord)((double)(x) / m_scaleX - 0.5);
87 }
88 wxCoord YDEV2LOG(wxCoord y) const
89 {
90 wxCoord new_y = y - m_deviceOriginY;
91 if (new_y > 0)
92 return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY;
93 else
94 return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY;
95 }
96 wxCoord YDEV2LOGREL(wxCoord y) const
97 {
98 if (y > 0)
99 return (wxCoord)((double)(y) / m_scaleY + 0.5);
100 else
101 return (wxCoord)((double)(y) / m_scaleY - 0.5);
102 }
103 wxCoord XLOG2DEV(wxCoord x) const
104 {
105 wxCoord new_x = x - m_logicalOriginX;
106 if (new_x > 0)
107 return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX;
108 else
109 return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX;
110 }
111 // Without device translation, for backing pixmap purposes
112 wxCoord XLOG2DEV_2(wxCoord x) const
113 {
114 wxCoord new_x = x - m_logicalOriginX;
115 if (new_x > 0)
116 return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX;
117 else
118 return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX;
119 }
120 wxCoord XLOG2DEVREL(wxCoord x) const
121 {
122 if (x > 0)
123 return (wxCoord)((double)(x) * m_scaleX + 0.5);
124 else
125 return (wxCoord)((double)(x) * m_scaleX - 0.5);
126 }
127 wxCoord YLOG2DEV(wxCoord y) const
128 {
129 wxCoord new_y = y - m_logicalOriginY;
130 if (new_y > 0)
131 return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY;
132 else
133 return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY;
134 }
135 // Without device translation, for backing pixmap purposes
136 wxCoord YLOG2DEV_2(wxCoord y) const
137 {
138 wxCoord new_y = y - m_logicalOriginY;
139 if (new_y > 0)
140 return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY;
141 else
142 return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY;
143 }
144 wxCoord YLOG2DEVREL(wxCoord y) const
145 {
146 if (y > 0)
147 return (wxCoord)((double)(y) * m_scaleY + 0.5);
148 else
149 return (wxCoord)((double)(y) * m_scaleY - 0.5);
150 }
151
152 public:
153 // not sure what for, but what is a mm on a screen you don't know the size of?
154 double m_mm_to_pix_x,m_mm_to_pix_y;
155
156 // recompute scale?
157 bool m_needComputeScaleX, m_needComputeScaleY;
158
159 };
160
161 #endif
162 // _WX_DC_H_