home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / fixx11h.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-09-10  |  4.7 KB  |  234 lines

  1. //#ifdef    don't do this, this file is supposed to be included
  2. //#define   multiple times
  3.  
  4. /* Usage:
  5.  
  6.  If you get compile errors caused by X11 includes (the line
  7.  where first error appears contains word like None, Unsorted,
  8.  Below, etc.), put #include <fixx11h.h> in the .cpp file 
  9.  (not .h file!) between the place where X11 headers are
  10.  included and the place where the file with compile
  11.  error is included (or the place where the compile error
  12.  in the .cpp file occurs).
  13.  
  14.  This file remaps X11 #defines to const variables or
  15.  inline functions. The side effect may be that these
  16.  symbols may now refer to different variables
  17.  (e.g. if X11 #defined NoButton, after this file
  18.  is included NoButton would no longer be X11's
  19.  NoButton, but Qt::NoButton instead). At this time,
  20.  there's no conflict known that could cause problems.
  21.  
  22.  The original X11 symbols are still accessible
  23.  (e.g. for None) as X::None, XNone, and also still
  24.  None, unless name lookup finds different None
  25.  first (in the current class, etc.)
  26.  
  27.  Use 'Unsorted', 'Bool' and 'index' as templates.
  28.  
  29. */
  30.  
  31. namespace X
  32. {
  33.  
  34. // template --->
  35. // Affects: Should be without side effects.
  36. #ifdef Unsorted
  37. #ifndef FIXX11H_Unsorted
  38. #define FIXX11H_Unsorted
  39. const int XUnsorted = Unsorted;
  40. #undef Unsorted
  41. const int Unsorted = XUnsorted;
  42. #endif
  43. #undef Unsorted
  44. #endif
  45. // template <---
  46.  
  47. // Affects: Should be without side effects.
  48. #ifdef None
  49. #ifndef FIXX11H_None
  50. #define FIXX11H_None
  51. const XID XNone = None;
  52. #undef None
  53. const XID None = XNone;
  54. #endif
  55. #undef None
  56. #endif
  57.  
  58. // template --->
  59. // Affects: Should be without side effects.
  60. #ifdef Bool
  61. #ifndef FIXX11H_Bool
  62. #define FIXX11H_Bool
  63. typedef Bool XBool;
  64. #undef Bool
  65. typedef XBool Bool;
  66. #endif
  67. #undef Bool
  68. #endif
  69. // template <---
  70.  
  71. // Affects: Should be without side effects.
  72. #ifdef KeyPress
  73. #ifndef FIXX11H_KeyPress
  74. #define FIXX11H_KeyPress
  75. const int XKeyPress = KeyPress;
  76. #undef KeyPress
  77. const int KeyPress = XKeyPress;
  78. #endif
  79. #undef KeyPress
  80. #endif
  81.  
  82. // Affects: Should be without side effects.
  83. #ifdef KeyRelease
  84. #ifndef FIXX11H_KeyRelease
  85. #define FIXX11H_KeyRelease
  86. const int XKeyRelease = KeyRelease;
  87. #undef KeyRelease
  88. const int KeyRelease = XKeyRelease;
  89. #endif
  90. #undef KeyRelease
  91. #endif
  92.  
  93. // Affects: Should be without side effects.
  94. #ifdef Above
  95. #ifndef FIXX11H_Above
  96. #define FIXX11H_Above
  97. const int XAbove = Above;
  98. #undef Above
  99. const int Above = XAbove;
  100. #endif
  101. #undef Above
  102. #endif
  103.  
  104. // Affects: Should be without side effects.
  105. #ifdef Below
  106. #ifndef FIXX11H_Below
  107. #define FIXX11H_Below
  108. const int XBelow = Below;
  109. #undef Below
  110. const int Below = XBelow;
  111. #endif
  112. #undef Below
  113. #endif
  114.  
  115. // Affects: Should be without side effects.
  116. #ifdef FocusIn
  117. #ifndef FIXX11H_FocusIn
  118. #define FIXX11H_FocusIn
  119. const int XFocusIn = FocusIn;
  120. #undef FocusIn
  121. const int FocusIn = XFocusIn;
  122. #endif
  123. #undef FocusIn
  124. #endif
  125.  
  126. // Affects: Should be without side effects.
  127. #ifdef FocusOut
  128. #ifndef FIXX11H_FocusOut
  129. #define FIXX11H_FocusOut
  130. const int XFocusOut = FocusOut;
  131. #undef FocusOut
  132. const int FocusOut = XFocusOut;
  133. #endif
  134. #undef FocusOut
  135. #endif
  136.  
  137. // Affects: Should be without side effects.
  138. #ifdef Always
  139. #ifndef FIXX11H_Always
  140. #define FIXX11H_Always
  141. const int XAlways = Always;
  142. #undef Always
  143. const int Always = XAlways;
  144. #endif
  145. #undef Always
  146. #endif
  147.  
  148. // Affects: Should be without side effects.
  149. #ifdef Success
  150. #ifndef FIXX11H_Success
  151. #define FIXX11H_Success
  152. const int XSuccess = Success;
  153. #undef Success
  154. const int Success = XSuccess;
  155. #endif
  156. #undef Success
  157. #endif
  158.  
  159. // Affects: Should be without side effects.
  160. #ifdef GrayScale
  161. #ifndef FIXX11H_GrayScale
  162. #define FIXX11H_GrayScale
  163. const int XGrayScale = GrayScale;
  164. #undef GrayScale
  165. const int GrayScale = XGrayScale;
  166. #endif
  167. #undef GrayScale
  168. #endif
  169.  
  170. // Affects: Should be without side effects.
  171. #ifdef Status
  172. #ifndef FIXX11H_Status
  173. #define FIXX11H_Status
  174. typedef Status XStatus;
  175. #undef Status
  176. typedef XStatus Status;
  177. #endif
  178. #undef Status
  179. #endif
  180.  
  181. // Affects: Should be without side effects.
  182. #ifdef CursorShape
  183. #ifndef FIXX11H_CursorShape
  184. #define FIXX11H_CursorShape
  185. const int XCursorShape = CursorShape;
  186. #undef CursorShape
  187. const int CursorShape = CursorShape;
  188. #endif
  189. #undef CursorShape
  190. #endif
  191.  
  192. // template --->
  193. // Affects: Should be without side effects.
  194. #ifdef index
  195. #ifndef FIXX11H_index
  196. #define FIXX11H_index
  197. inline
  198. char* Xindex( const char* s, int c )
  199.     {
  200.     return index( s, c );
  201.     }
  202. #undef index
  203. inline
  204. char* index( const char* s, int c )
  205.     {
  206.     return Xindex( s, c );
  207.     }
  208. #endif
  209. #undef index
  210. #endif
  211. // template <---
  212.  
  213. #ifdef rindex
  214. // Affects: Should be without side effects.
  215. #ifndef FIXX11H_rindex
  216. #define FIXX11H_rindex
  217. inline
  218. char* Xrindex( const char* s, int c )
  219.     {
  220.     return rindex( s, c );
  221.     }
  222. #undef rindex
  223. inline
  224. char* rindex( const char* s, int c )
  225.     {
  226.     return Xrindex( s, c );
  227.     }
  228. #endif
  229. #undef rindex
  230. #endif
  231. }
  232.  
  233. using namespace X;
  234.