ptc.pp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. {
  2. Free Pascal port of the OpenPTC C++ library.
  3. Copyright (C) 2001-2003 Nikolay Nikolov ([email protected])
  4. Original C++ version by Glenn Fiedler ([email protected])
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. }
  11. {$MODE objfpc}
  12. {$MACRO ON}
  13. {$DEFINE PTC_LOGGING}
  14. {$UNDEF ENABLE_C_API}
  15. {$H+}
  16. {$IFDEF UNIX}
  17. {$DEFINE HAVE_X11_EXTENSIONS_XSHM}
  18. {$DEFINE XStringListToTextProperty_notyetimplemented_in_xutil_pp}
  19. {$ENDIF UNIX}
  20. Unit ptc;
  21. Interface
  22. Uses
  23. {$IFDEF WIN32}
  24. Windows, DirectDraw,
  25. {$ENDIF WIN32}
  26. {$IFDEF UNIX}
  27. x, xlib, xutil, keysym,
  28. xf86vmode, xf86dga,
  29. {$IFDEF HAVE_X11_EXTENSIONS_XSHM}
  30. xshm, ipc,
  31. {$ENDIF HAVE_X11_EXTENSIONS_XSHM}
  32. {$ENDIF UNIX}
  33. {SysUtils,} Hermes;
  34. Const
  35. PTC_VERSION = 'OpenPTC 1.0';
  36. PTC_WIN32_VERSION = 'OpenPTC Win32 1.0.18';
  37. Type
  38. Pchar8 = ^char8;
  39. char8 = Byte;
  40. Pshort16 = ^short16;
  41. short16 = Word;
  42. Pint32 = ^int32;
  43. int32 = DWord;
  44. {$INCLUDE aread.inc}
  45. {$INCLUDE colord.inc}
  46. {$INCLUDE formatd.inc}
  47. {$INCLUDE keyd.inc}
  48. {$INCLUDE moded.inc}
  49. {$INCLUDE paletted.inc}
  50. {$INCLUDE cleard.inc}
  51. {$INCLUDE copyd.inc}
  52. {$INCLUDE clipperd.inc}
  53. {$INCLUDE basesurd.inc}
  54. {$INCLUDE surfaced.inc}
  55. {$INCLUDE basecond.inc}
  56. {$INCLUDE consoled.inc}
  57. {$INCLUDE errord.inc}
  58. {$INCLUDE timerd.inc}
  59. {$IFDEF ENABLE_C_API}
  60. {$INCLUDE c_api/index.inc}
  61. {$INCLUDE c_api/errord.inc}
  62. {$INCLUDE c_api/exceptd.inc}
  63. {$INCLUDE c_api/aread.inc}
  64. {$INCLUDE c_api/colord.inc}
  65. {$INCLUDE c_api/cleard.inc}
  66. {$INCLUDE c_api/clipperd.inc}
  67. {$INCLUDE c_api/copyd.inc}
  68. {$INCLUDE c_api/keyd.inc}
  69. {$INCLUDE c_api/formatd.inc}
  70. {$INCLUDE c_api/paletted.inc}
  71. {$INCLUDE c_api/surfaced.inc}
  72. {$INCLUDE c_api/consoled.inc}
  73. {$INCLUDE c_api/moded.inc}
  74. {$INCLUDE c_api/timerd.inc}
  75. {$ENDIF ENABLE_C_API}
  76. {$IFDEF GO32V2}
  77. {$INCLUDE dos/base/kbdd.inc}
  78. {$INCLUDE dos/vesa/consoled.inc}
  79. {$INCLUDE dos/fakemode/consoled.inc}
  80. {$INCLUDE dos/textfx2/consoled.inc}
  81. {$INCLUDE dos/cga/consoled.inc}
  82. {$WARNING should be moved in the implementation part}
  83. {$ENDIF GO32V2}
  84. {$IFDEF WIN32}
  85. {$INCLUDE win32/base/monitord.inc}
  86. {$INCLUDE win32/base/eventd.inc}
  87. {$INCLUDE win32/base/windowd.inc}
  88. {$INCLUDE win32/base/hookd.inc}
  89. {$INCLUDE win32/base/kbdd.inc}
  90. {$INCLUDE win32/directx/hookd.inc}
  91. {$INCLUDE win32/directx/libraryd.inc}
  92. {$INCLUDE win32/directx/displayd.inc}
  93. {$INCLUDE win32/directx/primaryd.inc}
  94. {$INCLUDE win32/directx/consoled.inc}
  95. {$WARNING should be moved in the implementation part}
  96. {$ENDIF WIN32}
  97. {$IFDEF UNIX}
  98. {$INCLUDE x11/imaged.inc}
  99. {$INCLUDE x11/displayd.inc}
  100. {$INCLUDE x11/windowd.inc}
  101. {$INCLUDE x11/dgadispd.inc}
  102. {$INCLUDE x11/consoled.inc}
  103. {$WARNING should be moved in the implementation part}
  104. {$ENDIF UNIX}
  105. Implementation
  106. {$IFDEF GO32V2}
  107. Uses
  108. textfx2, vesa, vga, cga, timeunit, crt, go32;
  109. {$ENDIF GO32V2}
  110. {$IFDEF WIN32}
  111. {Uses
  112. Windows, DirectDraw;}
  113. {$ENDIF WIN32}
  114. {$IFDEF UNIX}
  115. Uses
  116. BaseUnix, Unix;
  117. {$ENDIF UNIX}
  118. Procedure FreeAndNil(Var q);
  119. Var
  120. tmp : TObject;
  121. Begin
  122. tmp := TObject(q);
  123. Pointer(q) := Nil;
  124. tmp.Free;
  125. End;
  126. Procedure FreeMemAndNil(Var q);
  127. Var
  128. tmp : Pointer;
  129. Begin
  130. tmp := Pointer(q);
  131. Pointer(q) := Nil;
  132. If tmp <> Nil Then
  133. FreeMem(tmp);
  134. End;
  135. {$INCLUDE log.inc}
  136. {$IFDEF WIN32}
  137. {$INCLUDE win32/base/cursor.inc}
  138. {$ENDIF WIN32}
  139. {$INCLUDE errori.inc}
  140. {$INCLUDE areai.inc}
  141. {$INCLUDE colori.inc}
  142. {$INCLUDE formati.inc}
  143. {$INCLUDE keyi.inc}
  144. {$INCLUDE modei.inc}
  145. {$INCLUDE palettei.inc}
  146. {$INCLUDE cleari.inc}
  147. {$INCLUDE copyi.inc}
  148. {$INCLUDE clipperi.inc}
  149. {$INCLUDE basesuri.inc}
  150. {$INCLUDE baseconi.inc}
  151. {$INCLUDE surfacei.inc}
  152. {$INCLUDE timeri.inc}
  153. {$IFDEF GO32V2}
  154. {$INCLUDE dos/base/kbd.inc}
  155. {$INCLUDE dos/vesa/console.inc}
  156. {$INCLUDE dos/fakemode/console.inc}
  157. {$INCLUDE dos/textfx2/console.inc}
  158. {$INCLUDE dos/cga/console.inc}
  159. {$ENDIF GO32V2}
  160. {$IFDEF WIN32}
  161. {$INCLUDE win32/base/monitor.inc}
  162. {$INCLUDE win32/base/event.inc}
  163. {$INCLUDE win32/base/window.inc}
  164. {$INCLUDE win32/base/hook.inc}
  165. {$INCLUDE win32/base/kbd.inc}
  166. {$INCLUDE win32/directx/check.inc}
  167. {$INCLUDE win32/directx/translte.inc}
  168. {$INCLUDE win32/directx/hook.inc}
  169. {$INCLUDE win32/directx/library.inc}
  170. {$INCLUDE win32/directx/display.inc}
  171. {$INCLUDE win32/directx/primary.inc}
  172. {$INCLUDE win32/directx/console.inc}
  173. {$ENDIF WIN32}
  174. {$IFDEF UNIX}
  175. {$INCLUDE x11/check.inc}
  176. {$INCLUDE x11/image.inc}
  177. {$INCLUDE x11/display.inc}
  178. {$INCLUDE x11/window.inc}
  179. {$INCLUDE x11/dgadisp.inc}
  180. {$INCLUDE x11/console.inc}
  181. {$ENDIF UNIX}
  182. {$INCLUDE consolei.inc}
  183. {$IFDEF ENABLE_C_API}
  184. {$INCLUDE c_api/except.inc}
  185. {$INCLUDE c_api/error.inc}
  186. {$INCLUDE c_api/area.inc}
  187. {$INCLUDE c_api/color.inc}
  188. {$INCLUDE c_api/clear.inc}
  189. {$INCLUDE c_api/clipper.inc}
  190. {$INCLUDE c_api/copy.inc}
  191. {$INCLUDE c_api/key.inc}
  192. {$INCLUDE c_api/format.inc}
  193. {$INCLUDE c_api/palette.inc}
  194. {$INCLUDE c_api/surface.inc}
  195. {$INCLUDE c_api/console.inc}
  196. {$INCLUDE c_api/mode.inc}
  197. {$INCLUDE c_api/timer.inc}
  198. {$ENDIF ENABLE_C_API}
  199. Initialization
  200. Begin
  201. {$IFDEF ENABLE_C_API}
  202. ptc_error_handler_function := @ptc_error_handler_default;
  203. {$ENDIF ENABLE_C_API}
  204. {$IFDEF WIN32}
  205. TWin32Hook_m_monitor := TWin32Monitor.Create;
  206. {$ENDIF WIN32}
  207. End;
  208. Finalization
  209. Begin
  210. {$IFDEF WIN32}
  211. FreeAndNil(TWin32Hook_m_monitor);
  212. {$ENDIF WIN32}
  213. End;
  214. End.