1 | /**************************************************************************** |
2 | |
3 | Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org> |
4 | |
5 | Permission is hereby granted, free of charge, to any person obtaining a |
6 | copy of this software and associated documentation files (the "Software"), |
7 | to deal in the Software without restriction, including without limitation |
8 | the rights to use, copy, modify, merge, publish, distribute, sublicense, |
9 | and/or sell copies of the Software, and to permit persons to whom the |
10 | Software is furnished to do so, subject to the following conditions: |
11 | |
12 | The above copyright notice and this permission notice shall be included in |
13 | all copies or substantial portions of the Software. |
14 | |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
18 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
20 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
21 | DEALINGS IN THE SOFTWARE. |
22 | |
23 | ****************************************************************************/ |
24 | |
25 | |
26 | //#ifdef don't do this, this file is supposed to be included |
27 | //#define multiple times |
28 | |
29 | #include <QtCore/QtGlobal> |
30 | |
31 | #ifdef Q_WS_X11 |
32 | |
33 | /* Usage: |
34 | |
35 | If you get compile errors caused by X11 includes (the line |
36 | where first error appears contains word like None, Unsorted, |
37 | Below, etc.), put #include <fixx11h.h> in the .cpp file |
38 | (not .h file!) between the place where X11 headers are |
39 | included and the place where the file with compile |
40 | error is included (or the place where the compile error |
41 | in the .cpp file occurs). |
42 | |
43 | This file remaps X11 #defines to const variables or |
44 | inline functions. The side effect may be that these |
45 | symbols may now refer to different variables |
46 | (e.g. if X11 #defined NoButton, after this file |
47 | is included NoButton would no longer be X11's |
48 | NoButton, but Qt::NoButton instead). At this time, |
49 | there's no conflict known that could cause problems. |
50 | |
51 | The original X11 symbols are still accessible |
52 | (e.g. for None) as X::None, XNone, and also still |
53 | None, unless name lookup finds different None |
54 | first (in the current class, etc.) |
55 | |
56 | Use 'Unsorted', 'Bool' and 'index' as templates. |
57 | |
58 | */ |
59 | |
60 | namespace X |
61 | { |
62 | |
63 | // template ---> |
64 | // Affects: Should be without side effects. |
65 | #ifdef Unsorted |
66 | #ifndef FIXX11H_Unsorted |
67 | #define FIXX11H_Unsorted |
68 | const int XUnsorted = Unsorted; |
69 | #undef Unsorted |
70 | const int Unsorted = XUnsorted; |
71 | #endif |
72 | #undef Unsorted |
73 | #endif |
74 | // template <--- |
75 | |
76 | // Affects: Should be without side effects. |
77 | #ifdef None |
78 | #ifndef FIXX11H_None |
79 | #define FIXX11H_None |
80 | const XID XNone = None; |
81 | #undef None |
82 | const XID None = XNone; |
83 | #endif |
84 | #undef None |
85 | #endif |
86 | |
87 | // template ---> |
88 | // Affects: Should be without side effects. |
89 | #ifdef Bool |
90 | #ifndef FIXX11H_Bool |
91 | #define FIXX11H_Bool |
92 | #ifdef _XTYPEDEF_BOOL /* Xdefs.h has typedef'ed Bool already */ |
93 | #undef Bool |
94 | #else |
95 | typedef Bool XBool; |
96 | #undef Bool |
97 | typedef XBool Bool; |
98 | #endif |
99 | #endif |
100 | #undef Bool |
101 | #define _XTYPEDEF_BOOL |
102 | #endif |
103 | // template <--- |
104 | |
105 | // Affects: Should be without side effects. |
106 | #ifdef KeyPress |
107 | #ifndef FIXX11H_KeyPress |
108 | #define FIXX11H_KeyPress |
109 | const int XKeyPress = KeyPress; |
110 | #undef KeyPress |
111 | const int KeyPress = XKeyPress; |
112 | #endif |
113 | #undef KeyPress |
114 | #endif |
115 | |
116 | // Affects: Should be without side effects. |
117 | #ifdef KeyRelease |
118 | #ifndef FIXX11H_KeyRelease |
119 | #define FIXX11H_KeyRelease |
120 | const int XKeyRelease = KeyRelease; |
121 | #undef KeyRelease |
122 | const int KeyRelease = XKeyRelease; |
123 | #endif |
124 | #undef KeyRelease |
125 | #endif |
126 | |
127 | // Affects: Should be without side effects. |
128 | #ifdef Above |
129 | #ifndef FIXX11H_Above |
130 | #define FIXX11H_Above |
131 | const int XAbove = Above; |
132 | #undef Above |
133 | const int Above = XAbove; |
134 | #endif |
135 | #undef Above |
136 | #endif |
137 | |
138 | // Affects: Should be without side effects. |
139 | #ifdef Below |
140 | #ifndef FIXX11H_Below |
141 | #define FIXX11H_Below |
142 | const int XBelow = Below; |
143 | #undef Below |
144 | const int Below = XBelow; |
145 | #endif |
146 | #undef Below |
147 | #endif |
148 | |
149 | // Affects: Should be without side effects. |
150 | #ifdef FocusIn |
151 | #ifndef FIXX11H_FocusIn |
152 | #define FIXX11H_FocusIn |
153 | const int XFocusIn = FocusIn; |
154 | #undef FocusIn |
155 | const int FocusIn = XFocusIn; |
156 | #endif |
157 | #undef FocusIn |
158 | #endif |
159 | |
160 | // Affects: Should be without side effects. |
161 | #ifdef FocusOut |
162 | #ifndef FIXX11H_FocusOut |
163 | #define FIXX11H_FocusOut |
164 | const int XFocusOut = FocusOut; |
165 | #undef FocusOut |
166 | const int FocusOut = XFocusOut; |
167 | #endif |
168 | #undef FocusOut |
169 | #endif |
170 | |
171 | // Affects: Should be without side effects. |
172 | #ifdef Always |
173 | #ifndef FIXX11H_Always |
174 | #define FIXX11H_Always |
175 | const int XAlways = Always; |
176 | #undef Always |
177 | const int Always = XAlways; |
178 | #endif |
179 | #undef Always |
180 | #endif |
181 | |
182 | // Affects: Should be without side effects. |
183 | #ifdef Success |
184 | #ifndef FIXX11H_Success |
185 | #define FIXX11H_Success |
186 | const int XSuccess = Success; |
187 | #undef Success |
188 | const int Success = XSuccess; |
189 | #endif |
190 | #undef Success |
191 | #endif |
192 | |
193 | // Affects: Should be without side effects. |
194 | #ifdef GrayScale |
195 | #ifndef FIXX11H_GrayScale |
196 | #define FIXX11H_GrayScale |
197 | const int XGrayScale = GrayScale; |
198 | #undef GrayScale |
199 | const int GrayScale = XGrayScale; |
200 | #endif |
201 | #undef GrayScale |
202 | #endif |
203 | |
204 | // Affects: Should be without side effects. |
205 | #ifdef Status |
206 | #ifndef FIXX11H_Status |
207 | #define FIXX11H_Status |
208 | typedef Status XStatus; |
209 | #undef Status |
210 | typedef XStatus Status; |
211 | #endif |
212 | #undef Status |
213 | #endif |
214 | |
215 | // template ---> |
216 | // Affects: Should be without side effects. |
217 | #ifdef CursorShape |
218 | #ifndef FIXX11H_CursorShape |
219 | #define FIXX11H_CursorShape |
220 | const int XCursorShape = CursorShape; |
221 | #undef CursorShape |
222 | const int CursorShape = XCursorShape; |
223 | #endif |
224 | #undef CursorShape |
225 | #endif |
226 | // template <--- |
227 | |
228 | // template ---> |
229 | // Affects: Should be without side effects. |
230 | #ifdef FontChange |
231 | #ifndef FIXX11H_FontChange |
232 | #define FIXX11H_FontChange |
233 | const int XFontChange = FontChange; |
234 | #undef FontChange |
235 | const int FontChange = XFontChange; |
236 | #endif |
237 | #undef FontChange |
238 | #endif |
239 | // template <--- |
240 | |
241 | // Affects: Should be without side effects. |
242 | #ifdef NormalState |
243 | #ifndef FIXX11H_NormalState |
244 | #define FIXX11H_NormalState |
245 | const int XNormalState = NormalState; |
246 | #undef NormalState |
247 | const int NormalState = XNormalState; |
248 | #endif |
249 | #undef NormalState |
250 | #endif |
251 | |
252 | // template ---> |
253 | // Affects: Should be without side effects. |
254 | #ifdef index |
255 | #ifndef FIXX11H_index |
256 | #define FIXX11H_index |
257 | inline |
258 | const char* Xindex( const char* s, int c ) |
259 | { |
260 | return index( s, c ); |
261 | } |
262 | #undef index |
263 | inline |
264 | const char* index( const char* s, int c ) |
265 | { |
266 | return Xindex( s, c ); |
267 | } |
268 | #endif |
269 | #undef index |
270 | #endif |
271 | // template <--- |
272 | |
273 | #ifdef rindex |
274 | // Affects: Should be without side effects. |
275 | #ifndef FIXX11H_rindex |
276 | #define FIXX11H_rindex |
277 | inline |
278 | const char* Xrindex( const char* s, int c ) |
279 | { |
280 | return rindex( s, c ); |
281 | } |
282 | #undef rindex |
283 | inline |
284 | const char* rindex( const char* s, int c ) |
285 | { |
286 | return Xrindex( s, c ); |
287 | } |
288 | #endif |
289 | #undef rindex |
290 | #endif |
291 | } |
292 | |
293 | using namespace X; |
294 | |
295 | #endif |
296 | |