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