]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/motif/dc.h
Because someone was inconsistent about using LPSTR and char*, I missed
[wxWidgets.git] / include / wx / motif / dc.h
... / ...
CommitLineData
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
44class WXDLLEXPORT wxDC : public wxDCBase
45{
46 DECLARE_DYNAMIC_CLASS(wxDC)
47
48public:
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 SetSystemScale(double x, double y);
62 virtual void SetLogicalScale(double x, double y);
63 virtual void SetLogicalOrigin(long x, long y);
64 virtual void SetDeviceOrigin(long x, long y);
65 virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
66 virtual void SetLogicalFunction(int function);
67
68protected:
69 virtual void DoDrawIcon(const wxIcon& icon, long x, long y);
70 virtual void DoDrawBitmap(const wxBitmap &bmp, long x, long y,
71 bool useMask = FALSE);
72
73 virtual void DoSetClippingRegion(long x, long y,
74 long width, long height);
75 virtual void DoGetSize(int *width, int *height) const;
76 virtual void DoGetSizeMM(int* width, int* height) const;
77
78public:
79 void ComputeScaleAndOrigin();
80
81 long XDEV2LOG(long x) const
82 {
83 long new_x = x - m_deviceOriginX;
84 if (new_x > 0)
85 return (long)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX;
86 else
87 return (long)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX;
88 }
89 long XDEV2LOGREL(long x) const
90 {
91 if (x > 0)
92 return (long)((double)(x) / m_scaleX + 0.5);
93 else
94 return (long)((double)(x) / m_scaleX - 0.5);
95 }
96 long YDEV2LOG(long y) const
97 {
98 long new_y = y - m_deviceOriginY;
99 if (new_y > 0)
100 return (long)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY;
101 else
102 return (long)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY;
103 }
104 long YDEV2LOGREL(long y) const
105 {
106 if (y > 0)
107 return (long)((double)(y) / m_scaleY + 0.5);
108 else
109 return (long)((double)(y) / m_scaleY - 0.5);
110 }
111 long XLOG2DEV(long x) const
112 {
113 long new_x = x - m_logicalOriginX;
114 if (new_x > 0)
115 return (long)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX;
116 else
117 return (long)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX;
118 }
119 // Without device translation, for backing pixmap purposes
120 long XLOG2DEV_2(long x) const
121 {
122 long new_x = x - m_logicalOriginX;
123 if (new_x > 0)
124 return (long)((double)(new_x) * m_scaleX + 0.5) * m_signX;
125 else
126 return (long)((double)(new_x) * m_scaleX - 0.5) * m_signX;
127 }
128 long XLOG2DEVREL(long x) const
129 {
130 if (x > 0)
131 return (long)((double)(x) * m_scaleX + 0.5);
132 else
133 return (long)((double)(x) * m_scaleX - 0.5);
134 }
135 long YLOG2DEV(long y) const
136 {
137 long new_y = y - m_logicalOriginY;
138 if (new_y > 0)
139 return (long)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY;
140 else
141 return (long)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY;
142 }
143 // Without device translation, for backing pixmap purposes
144 long YLOG2DEV_2(long y) const
145 {
146 long new_y = y - m_logicalOriginY;
147 if (new_y > 0)
148 return (long)((double)(new_y) * m_scaleY + 0.5) * m_signY;
149 else
150 return (long)((double)(new_y) * m_scaleY - 0.5) * m_signY;
151 }
152 long YLOG2DEVREL(long y) const
153 {
154 if (y > 0)
155 return (long)((double)(y) * m_scaleY + 0.5);
156 else
157 return (long)((double)(y) * m_scaleY - 0.5);
158 }
159
160 void SetInternalDeviceOrigin( long x, long y );
161 void GetInternalDeviceOrigin( long *x, long *y );
162
163public:
164 // not sure what for, but what is a mm on a screen you don't know the size of?
165 double m_mm_to_pix_x,m_mm_to_pix_y;
166
167 // If un-scrolled is non-zero or d.o. changes with scrolling. Set using
168 // SetInternalDeviceOrigin().
169 long m_internalDeviceOriginX,m_internalDeviceOriginY;
170
171 // To be set by external classes such as wxScrolledWindow using
172 // SetDeviceOrigin()
173 long m_externalDeviceOriginX,m_externalDeviceOriginY;
174
175 // recompute scale?
176 bool m_needComputeScaleX, m_needComputeScaleY;
177
178 // wxPSDC wants to have this. Will disappear.
179 float m_scaleFactor;
180};
181
182#endif
183 // _WX_DC_H_