ptc.pp 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. {
  2. Free Pascal port of the OpenPTC C++ library.
  3. Copyright (C) 2001-2006 Nikolay Nikolov ([email protected])
  4. Original C++ version by Glenn Fiedler ([email protected])
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. }
  17. {$MODE objfpc}
  18. {$MACRO ON}
  19. {$UNDEF ENABLE_C_API}
  20. {$H+}
  21. {$IFDEF UNIX}
  22. { X11 extensions we want to enable at compile time }
  23. {$INCLUDE x11/extensions.inc}
  24. {$IFDEF ENABLE_X11_EXTENSION_XF86DGA1}
  25. {$DEFINE ENABLE_X11_EXTENSION_XF86DGA}
  26. {$ENDIF ENABLE_X11_EXTENSION_XF86DGA1}
  27. {$IFDEF ENABLE_X11_EXTENSION_XF86DGA2}
  28. {$DEFINE ENABLE_X11_EXTENSION_XF86DGA}
  29. {$ENDIF ENABLE_X11_EXTENSION_XF86DGA2}
  30. {$ENDIF UNIX}
  31. Unit ptc;
  32. Interface
  33. {$IFNDEF FPDOC}
  34. Uses
  35. Hermes;
  36. {$ENDIF FPDOC}
  37. Const
  38. PTCPAS_VERSION = 'PTCPas 0.99.7';
  39. Type
  40. PUint8 = ^Uint8;
  41. PUint16 = ^Uint16;
  42. PUint32 = ^Uint32;
  43. PUint64 = ^Uint64;
  44. PSint8 = ^Sint8;
  45. PSint16 = ^Sint16;
  46. PSint32 = ^Sint32;
  47. PSint64 = ^Sint64;
  48. Uint8 = Byte;
  49. Uint16 = Word;
  50. Uint32 = DWord;
  51. Uint64 = QWord;
  52. Sint8 = ShortInt;
  53. Sint16 = SmallInt;
  54. Sint32 = LongInt;
  55. Sint64 = Int64;
  56. {$INCLUDE coreinterface.inc}
  57. {$IFNDEF FPDOC}
  58. {$IFDEF ENABLE_C_API}
  59. {$INCLUDE c_api/index.pp}
  60. {$INCLUDE c_api/errord.pp}
  61. {$INCLUDE c_api/exceptd.pp}
  62. {$INCLUDE c_api/aread.pp}
  63. {$INCLUDE c_api/colord.pp}
  64. {$INCLUDE c_api/cleard.pp}
  65. {$INCLUDE c_api/clipperd.pp}
  66. {$INCLUDE c_api/copyd.pp}
  67. {$INCLUDE c_api/keyd.pp}
  68. {$INCLUDE c_api/formatd.pp}
  69. {$INCLUDE c_api/paletted.pp}
  70. {$INCLUDE c_api/surfaced.pp}
  71. {$INCLUDE c_api/consoled.pp}
  72. {$INCLUDE c_api/moded.pp}
  73. {$INCLUDE c_api/timerd.pp}
  74. {$ENDIF ENABLE_C_API}
  75. {$ENDIF FPDOC}
  76. Implementation
  77. {$IFDEF GO32V2}
  78. Uses
  79. textfx2, vesa, vga, cga, timeunit, crt, go32, mouse33h;
  80. {$ENDIF GO32V2}
  81. {$IFDEF Win32}
  82. Uses
  83. Windows, p_ddraw;
  84. {$ENDIF Win32}
  85. {$IFDEF WinCE}
  86. Uses
  87. Windows, p_gx;
  88. {$ENDIF WinCE}
  89. {$IFDEF UNIX}
  90. Uses
  91. BaseUnix, Unix, ctypes, x, xlib, xutil, xatom, keysym
  92. {$IFDEF ENABLE_X11_EXTENSION_XRANDR}
  93. , xrandr
  94. {$ENDIF ENABLE_X11_EXTENSION_XRANDR}
  95. {$IFDEF ENABLE_X11_EXTENSION_XF86VIDMODE}
  96. , xf86vmode
  97. {$ENDIF ENABLE_X11_EXTENSION_XF86VIDMODE}
  98. {$IFDEF ENABLE_X11_EXTENSION_XF86DGA}
  99. , xf86dga
  100. {$ENDIF ENABLE_X11_EXTENSION_XF86DGA}
  101. {$IFDEF ENABLE_X11_EXTENSION_XSHM}
  102. , xshm, ipc
  103. {$ENDIF ENABLE_X11_EXTENSION_XSHM}
  104. ;
  105. {$ENDIF UNIX}
  106. { this little procedure is not a good reason to include the whole sysutils
  107. unit :) }
  108. Procedure FreeAndNil(Var q);
  109. Var
  110. tmp : TObject;
  111. Begin
  112. tmp := TObject(q);
  113. Pointer(q) := Nil;
  114. tmp.Free;
  115. End;
  116. Procedure FreeMemAndNil(Var q);
  117. Var
  118. tmp : Pointer;
  119. Begin
  120. tmp := Pointer(q);
  121. Pointer(q) := Nil;
  122. If tmp <> Nil Then
  123. FreeMem(tmp);
  124. End;
  125. Function IntToStr(Value : Integer) : String;
  126. Begin
  127. System.Str(Value, Result);
  128. End;
  129. Function IntToStr(Value : Int64) : String;
  130. Begin
  131. System.Str(Value, Result);
  132. End;
  133. Function IntToStr(Value : QWord) : String;
  134. Begin
  135. System.Str(Value, Result);
  136. End;
  137. {$INCLUDE log.inc}
  138. {$IFDEF WIN32}
  139. {$INCLUDE win32/base/cursor.inc}
  140. {$ENDIF WIN32}
  141. {$INCLUDE coreimplementation.inc}
  142. {$IFDEF GO32V2}
  143. {$INCLUDE dos/includes.inc}
  144. {$ENDIF GO32V2}
  145. {$IFDEF Win32}
  146. {$INCLUDE win32/base/monitord.inc}
  147. {$INCLUDE win32/base/eventd.inc}
  148. {$INCLUDE win32/base/windowd.inc}
  149. {$INCLUDE win32/base/hookd.inc}
  150. {$INCLUDE win32/base/kbdd.inc}
  151. {$INCLUDE win32/base/moused.inc}
  152. {$INCLUDE win32/directx/hookd.inc}
  153. {$INCLUDE win32/directx/libraryd.inc}
  154. {$INCLUDE win32/directx/displayd.inc}
  155. {$INCLUDE win32/directx/primaryd.inc}
  156. {$INCLUDE win32/directx/directxconsoled.inc}
  157. {$INCLUDE win32/gdi/win32dibd.inc}
  158. {$INCLUDE win32/gdi/gdiconsoled.inc}
  159. {$INCLUDE win32/base/monitor.inc}
  160. {$INCLUDE win32/base/event.inc}
  161. {$INCLUDE win32/base/window.inc}
  162. {$INCLUDE win32/base/hook.inc}
  163. {$INCLUDE win32/base/kbd.inc}
  164. {$INCLUDE win32/base/mousei.inc}
  165. {$INCLUDE win32/directx/check.inc}
  166. {$INCLUDE win32/directx/translate.inc}
  167. {$INCLUDE win32/directx/hook.inc}
  168. {$INCLUDE win32/directx/library.inc}
  169. {$INCLUDE win32/directx/display.inc}
  170. {$INCLUDE win32/directx/primary.inc}
  171. {$INCLUDE win32/directx/directxconsolei.inc}
  172. {$INCLUDE win32/gdi/win32dibi.inc}
  173. {$INCLUDE win32/gdi/gdiconsolei.inc}
  174. {$ENDIF Win32}
  175. {$IFDEF WinCE}
  176. {$INCLUDE wince/includes.inc}
  177. {$ENDIF WinCE}
  178. {$IFDEF UNIX}
  179. {$INCLUDE x11/includes.inc}
  180. {$ENDIF UNIX}
  181. {$INCLUDE consolei.inc}
  182. {$IFDEF ENABLE_C_API}
  183. {$INCLUDE c_api/except.pp}
  184. {$INCLUDE c_api/error.pp}
  185. {$INCLUDE c_api/area.pp}
  186. {$INCLUDE c_api/color.pp}
  187. {$INCLUDE c_api/clear.pp}
  188. {$INCLUDE c_api/clipper.pp}
  189. {$INCLUDE c_api/copy.pp}
  190. {$INCLUDE c_api/key.pp}
  191. {$INCLUDE c_api/format.pp}
  192. {$INCLUDE c_api/palette.pp}
  193. {$INCLUDE c_api/surface.pp}
  194. {$INCLUDE c_api/console.pp}
  195. {$INCLUDE c_api/mode.pp}
  196. {$INCLUDE c_api/timer.pp}
  197. {$ENDIF ENABLE_C_API}
  198. Initialization
  199. Begin
  200. {$IFDEF ENABLE_C_API}
  201. ptc_error_handler_function := @ptc_error_handler_default;
  202. {$ENDIF ENABLE_C_API}
  203. {$IFDEF WIN32}
  204. TWin32Hook_m_monitor := TWin32Monitor.Create;
  205. {$ENDIF WIN32}
  206. End;
  207. Finalization
  208. Begin
  209. {$IFDEF WIN32}
  210. FreeAndNil(TWin32Hook_m_monitor);
  211. {$ENDIF WIN32}
  212. End;
  213. End.