types.pp 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2002 by Florian Klaempfl,
  5. member of the Free Pascal development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {$MODE OBJFPC}
  13. unit types;
  14. interface
  15. {$ifndef ver1_0}
  16. const
  17. RT_RCDATA = PChar(10);
  18. type
  19. DWORD = LongWord;
  20. PLongint = System.PLongint;
  21. PInteger = System.PInteger;
  22. PSmallInt = System.PSmallInt;
  23. PDouble = System.PDouble;
  24. PByte = System.PByte;
  25. TPoint = packed record
  26. X : Longint;
  27. Y : Longint;
  28. end;
  29. PPoint = ^TPoint;
  30. tagPOINT = TPoint;
  31. TRect = packed record
  32. case Integer of
  33. 0: (Left,Top,Right,Bottom : Longint);
  34. 1: (TopLeft,BottomRight : TPoint);
  35. end;
  36. PRect = ^TRect;
  37. TSize = packed record
  38. cx : Longint;
  39. cy : Longint;
  40. end;
  41. PSize = ^TSize;
  42. tagSIZE = TSize;
  43. SIZE = TSize;
  44. TSmallPoint = packed record
  45. x : SmallInt;
  46. y : SmallInt;
  47. end;
  48. PSmallPoint = ^TSmallPoint;
  49. {$ifndef win32}
  50. const
  51. STGTY_STORAGE = 1;
  52. STGTY_STREAM = 2;
  53. STGTY_LOCKBYTES = 3;
  54. STGTY_PROPERTY = 4;
  55. STREAM_SEEK_SET = 0;
  56. STREAM_SEEK_CUR = 1;
  57. STREAM_SEEK_END = 2;
  58. LOCK_WRITE = 1;
  59. LOCK_EXCLUSIVE = 2;
  60. LOCK_ONLYONCE = 4;
  61. E_FAIL = HRESULT($80004005);
  62. STG_E_INVALIDFUNCTION = HRESULT($80030001);
  63. STG_E_FILENOTFOUND = HRESULT($80030002);
  64. STG_E_PATHNOTFOUND = HRESULT($80030003);
  65. STG_E_TOOMANYOPENFILES = HRESULT($80030004);
  66. STG_E_ACCESSDENIED = HRESULT($80030005);
  67. STG_E_INVALIDHANDLE = HRESULT($80030006);
  68. STG_E_INSUFFICIENTMEMORY = HRESULT($80030008);
  69. STG_E_INVALIDPOINTER = HRESULT($80030009);
  70. STG_E_NOMOREFILES = HRESULT($80030012);
  71. STG_E_DISKISWRITEPROTECTED = HRESULT($80030013);
  72. STG_E_SEEKERROR = HRESULT($80030019);
  73. STG_E_WRITEFAULT = HRESULT($8003001D);
  74. STG_E_READFAULT = HRESULT($8003001E);
  75. STG_E_SHAREVIOLATION = HRESULT($80030020);
  76. STG_E_LOCKVIOLATION = HRESULT($80030021);
  77. STG_E_FILEALREADYEXISTS = HRESULT($80030050);
  78. STG_E_INVALIDPARAMETER = HRESULT($80030057);
  79. STG_E_MEDIUMFULL = HRESULT($80030070);
  80. STG_E_PROPSETMISMATCHED = HRESULT($800300F0);
  81. STG_E_ABNORMALAPIEXIT = HRESULT($800300FA);
  82. STG_E_INVALIDHEADER = HRESULT($800300FB);
  83. STG_E_INVALIDNAME = HRESULT($800300FC);
  84. STG_E_UNKNOWN = HRESULT($800300FD);
  85. STG_E_UNIMPLEMENTEDFUNCTION = HRESULT($800300FE);
  86. STG_E_INVALIDFLAG = HRESULT($800300FF);
  87. STG_E_INUSE = HRESULT($80030100);
  88. STG_E_NOTCURRENT = HRESULT($80030101);
  89. STG_E_REVERTED = HRESULT($80030102);
  90. STG_E_CANTSAVE = HRESULT($80030103);
  91. STG_E_OLDFORMAT = HRESULT($80030104);
  92. STG_E_OLDDLL = HRESULT($80030105);
  93. STG_E_SHAREREQUIRED = HRESULT($80030106);
  94. STG_E_EXTANTMARSHALLINGS = HRESULT($80030108);
  95. STG_E_DOCFILECORRUPT = HRESULT($80030109);
  96. STG_E_BADBASEADDRESS = HRESULT($80030110);
  97. STG_E_INCOMPLETE = HRESULT($80030201);
  98. STG_E_TERMINATED = HRESULT($80030202);
  99. STG_S_CONVERTED = $00030200;
  100. STG_S_BLOCK = $00030201;
  101. STG_S_RETRYNOW = $00030202;
  102. STG_S_MONITORING = $00030203;
  103. GUID_NULL: TGUID = '{00000000-0000-0000-0000-000000000000}';
  104. type
  105. TOleChar = WideChar;
  106. POleStr = PWideChar;
  107. PPOleStr = ^POleStr;
  108. PCLSID = PGUID;
  109. TCLSID = TGUID;
  110. LARGE_INT = Int64;
  111. Largeint = LARGE_INT;
  112. PDWord = ^DWord;
  113. PDisplay = Pointer;
  114. PEvent = Pointer;
  115. TXrmOptionDescRec = record
  116. end;
  117. XrmOptionDescRec = TXrmOptionDescRec;
  118. PXrmOptionDescRec = ^TXrmOptionDescRec;
  119. Widget = Pointer;
  120. WidgetClass = Pointer;
  121. ArgList = Pointer;
  122. Region = Pointer;
  123. _FILETIME = packed record
  124. dwLowDateTime : DWORD;
  125. dwHighDateTime : DWORD;
  126. end;
  127. TFileTime = _FILETIME;
  128. FILETIME = _FILETIME;
  129. PFileTime = ^TFileTime;
  130. tagSTATSTG = packed record
  131. pwcsName : POleStr;
  132. dwType : Longint;
  133. cbSize : Largeint;
  134. mtime : TFileTime;
  135. ctime : TFileTime;
  136. atime : TFileTime;
  137. grfMode : Longint;
  138. grfLocksSupported : Longint;
  139. clsid : TCLSID;
  140. grfStateBits : Longint;
  141. reserved : Longint;
  142. end;
  143. TStatStg = tagSTATSTG;
  144. STATSTG = TStatStg;
  145. PStatStg = ^TStatStg;
  146. IClassFactory = Interface(IUnknown) ['{00000001-0000-0000-C000-000000000046}']
  147. Function CreateInstance(Const unkOuter : IUnknown;Const riid : TGUID;Out vObject) : HResult;StdCall;
  148. Function LockServer(fLock : LongBool) : HResult;StdCall;
  149. End;
  150. ISequentialStream = interface(IUnknown) ['{0c733a30-2a1c-11ce-ade5-00aa0044773d}']
  151. function Read(pv : Pointer;cb : DWord;pcbRead : PDWord) : HRESULT;stdcall;
  152. function Write(pv : Pointer;cb : DWord;pcbWritten : PDWord) : HRESULT;stdcall;
  153. end;
  154. IStream = interface(ISequentialStream) ['{0000000C-0000-0000-C000-000000000046}']
  155. function Seek(dlibMove : LargeInt; dwOrigin : Longint;
  156. out libNewPosition : LargeInt) : HResult;stdcall;
  157. function SetSize(libNewSize : LargeInt) : HRESULT;stdcall;
  158. function CopyTo(stm: IStream;cb : LargeInt;out cbRead : LargeInt;
  159. out cbWritten : LargeInt) : HRESULT;stdcall;
  160. function Commit(grfCommitFlags : Longint) : HRESULT;stdcall;
  161. function Revert : HRESULT;stdcall;
  162. function LockRegion(libOffset : LargeInt;cb : LargeInt;
  163. dwLockType : Longint) : HRESULT;stdcall;
  164. function UnlockRegion(libOffset : LargeInt;cb : LargeInt;
  165. dwLockType : Longint) : HRESULT;stdcall;
  166. Function Stat(out statstg : TStatStg;grfStatFlag : Longint) : HRESULT;stdcall;
  167. function Clone(out stm : IStream) : HRESULT;stdcall;
  168. end;
  169. {$endif win32}
  170. function EqualRect(const r1,r2 : TRect) : Boolean;
  171. function Rect(Left,Top,Right,Bottom : Integer) : TRect;
  172. function Bounds(ALeft,ATop,AWidth,AHeight : Integer) : TRect;
  173. function Point(x,y : Integer) : TPoint;
  174. function PtInRect(const Rect : TRect; const p : TPoint) : Boolean;
  175. function IntersectRect(var Rect : TRect; const R1,R2 : TRect) : Boolean;
  176. function UnionRect(var Rect : TRect; const R1,R2 : TRect) : Boolean;
  177. function IsRectEmpty(const Rect : TRect) : Boolean;
  178. function OffsetRect(var Rect : TRect;DX : Integer;DY : Integer) : Boolean;
  179. {$endif ver1_0}
  180. implementation
  181. {$ifndef ver1_0}
  182. function EqualRect(const r1,r2 : TRect) : Boolean;
  183. begin
  184. EqualRect:=(r1.left=r2.left) and (r1.right=r2.right) and (r1.top=r2.top) and (r1.bottom=r2.bottom);
  185. end;
  186. function Rect(Left,Top,Right,Bottom : Integer) : TRect;
  187. begin
  188. Rect.Left:=Left;
  189. Rect.Top:=Top;
  190. Rect.Right:=Right;
  191. Rect.Bottom:=Bottom;
  192. end;
  193. function Bounds(ALeft,ATop,AWidth,AHeight : Integer) : TRect;
  194. begin
  195. Bounds.Left:=ALeft;
  196. Bounds.Top:=ATop;
  197. Bounds.Right:=ALeft+AWidth;
  198. Bounds.Bottom:=ATop+AHeight;
  199. end;
  200. function Point(x,y : Integer) : TPoint;
  201. begin
  202. Point.x:=x;
  203. Point.y:=y;
  204. end;
  205. function PtInRect(const Rect : TRect;const p : TPoint) : Boolean;
  206. begin
  207. PtInRect:=(p.y>=Rect.Top) and (p.y<Rect.Bottom) and (p.x>=Rect.Left) and (p.x<Rect.Right);
  208. end;
  209. function IntersectRect(var Rect : TRect;const R1,R2 : TRect) : Boolean;
  210. begin
  211. Rect:=R1;
  212. with R2 do
  213. begin
  214. if Left>R1.Left then
  215. Rect.Left:=Left;
  216. if Top>R1.Top then
  217. Rect.Top:=Top;
  218. if Right<R1.Right then
  219. Rect.Right:=Right;
  220. if Bottom<R1.Bottom then
  221. Rect.Bottom:=Bottom;
  222. end;
  223. if IsRectEmpty(Rect) then
  224. begin
  225. FillChar(Rect,SizeOf(Rect),0);
  226. IntersectRect:=false;
  227. end
  228. else
  229. IntersectRect:=true;
  230. end;
  231. function UnionRect(var Rect : TRect;const R1,R2 : TRect) : Boolean;
  232. begin
  233. Rect:=R1;
  234. with R2 do
  235. begin
  236. if Left<R1.Left then
  237. Rect.Left:=Left;
  238. if Top<R1.Top then
  239. Rect.Top:=Top;
  240. if Right>R1.Right then
  241. Rect.Right:=Right;
  242. if Bottom>R1.Bottom then
  243. Rect.Bottom:=Bottom;
  244. end;
  245. if IsRectEmpty(Rect) then
  246. begin
  247. FillChar(Rect,SizeOf(Rect),0);
  248. UnionRect:=false;
  249. end
  250. else
  251. UnionRect:=true;
  252. end;
  253. function IsRectEmpty(const Rect : TRect) : Boolean;
  254. begin
  255. IsRectEmpty:=(Rect.Right<=Rect.Left) or (Rect.Bottom<=Rect.Top);
  256. end;
  257. function OffsetRect(var Rect : TRect;DX : Integer;DY : Integer) : Boolean;
  258. begin
  259. if assigned(@Rect) then
  260. begin
  261. with Rect do
  262. begin
  263. inc(Left,dx);
  264. inc(Top,dy);
  265. inc(Right,dx);
  266. inc(Bottom,dy);
  267. end;
  268. OffsetRect:=true;
  269. end
  270. else
  271. OffsetRect:=false;
  272. end;
  273. {$endif ver1_0}
  274. end.
  275. {
  276. $Log$
  277. Revision 1.2 2002-07-27 07:28:10 florian
  278. * fixed errror on non win32 targets with 1.0.x when doing a make cycle
  279. Revision 1.1 2002/07/23 20:39:54 florian
  280. + types unit added
  281. }