CuteLogger
Fast and simple logging solution for Qt based applications
fixx11h.h
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 // template --->
63 // Affects: Should be without side effects.
64 #ifdef Unsorted
65 #ifndef FIXX11H_Unsorted
66 #define FIXX11H_Unsorted
67 const int XUnsorted = Unsorted;
68 #undef Unsorted
69 const int Unsorted = XUnsorted;
70 #endif
71 #undef Unsorted
72 #endif
73 // template <---
74 
75 // Affects: Should be without side effects.
76 #ifdef None
77 #ifndef FIXX11H_None
78 #define FIXX11H_None
79 const XID XNone = None;
80 #undef None
81 const XID None = XNone;
82 #endif
83 #undef None
84 #endif
85 
86 // template --->
87 // Affects: Should be without side effects.
88 #ifdef Bool
89 #ifndef FIXX11H_Bool
90 #define FIXX11H_Bool
91 #ifdef _XTYPEDEF_BOOL /* Xdefs.h has typedef'ed Bool already */
92 #undef Bool
93 #else
94 typedef Bool XBool;
95 #undef Bool
96 typedef XBool Bool;
97 #endif
98 #endif
99 #undef Bool
100 #define _XTYPEDEF_BOOL
101 #endif
102 // template <---
103 
104 // Affects: Should be without side effects.
105 #ifdef KeyPress
106 #ifndef FIXX11H_KeyPress
107 #define FIXX11H_KeyPress
108 const int XKeyPress = KeyPress;
109 #undef KeyPress
110 const int KeyPress = XKeyPress;
111 #endif
112 #undef KeyPress
113 #endif
114 
115 // Affects: Should be without side effects.
116 #ifdef KeyRelease
117 #ifndef FIXX11H_KeyRelease
118 #define FIXX11H_KeyRelease
119 const int XKeyRelease = KeyRelease;
120 #undef KeyRelease
121 const int KeyRelease = XKeyRelease;
122 #endif
123 #undef KeyRelease
124 #endif
125 
126 // Affects: Should be without side effects.
127 #ifdef Above
128 #ifndef FIXX11H_Above
129 #define FIXX11H_Above
130 const int XAbove = Above;
131 #undef Above
132 const int Above = XAbove;
133 #endif
134 #undef Above
135 #endif
136 
137 // Affects: Should be without side effects.
138 #ifdef Below
139 #ifndef FIXX11H_Below
140 #define FIXX11H_Below
141 const int XBelow = Below;
142 #undef Below
143 const int Below = XBelow;
144 #endif
145 #undef Below
146 #endif
147 
148 // Affects: Should be without side effects.
149 #ifdef FocusIn
150 #ifndef FIXX11H_FocusIn
151 #define FIXX11H_FocusIn
152 const int XFocusIn = FocusIn;
153 #undef FocusIn
154 const int FocusIn = XFocusIn;
155 #endif
156 #undef FocusIn
157 #endif
158 
159 // Affects: Should be without side effects.
160 #ifdef FocusOut
161 #ifndef FIXX11H_FocusOut
162 #define FIXX11H_FocusOut
163 const int XFocusOut = FocusOut;
164 #undef FocusOut
165 const int FocusOut = XFocusOut;
166 #endif
167 #undef FocusOut
168 #endif
169 
170 // Affects: Should be without side effects.
171 #ifdef Always
172 #ifndef FIXX11H_Always
173 #define FIXX11H_Always
174 const int XAlways = Always;
175 #undef Always
176 const int Always = XAlways;
177 #endif
178 #undef Always
179 #endif
180 
181 // Affects: Should be without side effects.
182 #ifdef Success
183 #ifndef FIXX11H_Success
184 #define FIXX11H_Success
185 const int XSuccess = Success;
186 #undef Success
187 const int Success = XSuccess;
188 #endif
189 #undef Success
190 #endif
191 
192 // Affects: Should be without side effects.
193 #ifdef GrayScale
194 #ifndef FIXX11H_GrayScale
195 #define FIXX11H_GrayScale
196 const int XGrayScale = GrayScale;
197 #undef GrayScale
198 const int GrayScale = XGrayScale;
199 #endif
200 #undef GrayScale
201 #endif
202 
203 // Affects: Should be without side effects.
204 #ifdef Status
205 #ifndef FIXX11H_Status
206 #define FIXX11H_Status
207 typedef Status XStatus;
208 #undef Status
209 typedef XStatus Status;
210 #endif
211 #undef Status
212 #endif
213 
214 // template --->
215 // Affects: Should be without side effects.
216 #ifdef CursorShape
217 #ifndef FIXX11H_CursorShape
218 #define FIXX11H_CursorShape
219 const int XCursorShape = CursorShape;
220 #undef CursorShape
221 const int CursorShape = XCursorShape;
222 #endif
223 #undef CursorShape
224 #endif
225 // template <---
226 
227 // template --->
228 // Affects: Should be without side effects.
229 #ifdef FontChange
230 #ifndef FIXX11H_FontChange
231 #define FIXX11H_FontChange
232 const int XFontChange = FontChange;
233 #undef FontChange
234 const int FontChange = XFontChange;
235 #endif
236 #undef FontChange
237 #endif
238 // template <---
239 
240 // Affects: Should be without side effects.
241 #ifdef NormalState
242 #ifndef FIXX11H_NormalState
243 #define FIXX11H_NormalState
244 const int XNormalState = NormalState;
245 #undef NormalState
246 const int NormalState = XNormalState;
247 #endif
248 #undef NormalState
249 #endif
250 
251 // template --->
252 // Affects: Should be without side effects.
253 #ifdef index
254 #ifndef FIXX11H_index
255 #define FIXX11H_index
256 inline
257 const char *Xindex( const char *s, int c )
258 {
259  return index( s, c );
260 }
261 #undef index
262 inline
263 const char *index( const char *s, int c )
264 {
265  return Xindex( s, c );
266 }
267 #endif
268 #undef index
269 #endif
270 // template <---
271 
272 #ifdef rindex
273 // Affects: Should be without side effects.
274 #ifndef FIXX11H_rindex
275 #define FIXX11H_rindex
276 inline
277 const char *Xrindex( const char *s, int c )
278 {
279  return rindex( s, c );
280 }
281 #undef rindex
282 inline
283 const char *rindex( const char *s, int c )
284 {
285  return Xrindex( s, c );
286 }
287 #endif
288 #undef rindex
289 #endif
290 }
291 
292 using namespace X;
293 
294 #endif