Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
616 | bw | 1 | {$mode objfpc} |
2 | |||
3 | unit Types; |
||
4 | |||
5 | interface |
||
6 | |||
7 | type |
||
8 | PLongint = System.PLongint; |
||
9 | PSmallInt = System.PSmallInt; |
||
10 | PDouble = System.PDouble; |
||
11 | PByte = System.PByte; |
||
12 | |||
13 | TIntegerDynArray = array of Integer; |
||
14 | TCardinalDynArray = array of Cardinal; |
||
15 | TWordDynArray = array of Word; |
||
16 | TSmallIntDynArray = array of SmallInt; |
||
17 | TByteDynArray = array of Byte; |
||
18 | TShortIntDynArray = array of ShortInt; |
||
19 | TInt64DynArray = array of Int64; |
||
20 | TQWordDynArray = array of QWord; |
||
21 | TLongWordDynArray = array of LongWord; |
||
22 | TSingleDynArray = array of Single; |
||
23 | TDoubleDynArray = array of Double; |
||
24 | TBooleanDynArray = array of Boolean; |
||
25 | TStringDynArray = array of AnsiString; |
||
26 | TWideStringDynArray = array of WideString; |
||
27 | TPointerDynArray = array of Pointer; |
||
28 | |||
29 | TPoint = |
||
30 | {$ifndef FPC_REQUIRES_PROPER_ALIGNMENT} |
||
31 | packed |
||
32 | {$endif FPC_REQUIRES_PROPER_ALIGNMENT} |
||
33 | record |
||
34 | X : Longint; |
||
35 | Y : Longint; |
||
36 | end; |
||
37 | PPoint = ^TPoint; |
||
38 | tagPOINT = TPoint; |
||
39 | |||
40 | TRect = |
||
41 | {$ifndef FPC_REQUIRES_PROPER_ALIGNMENT} |
||
42 | packed |
||
43 | {$endif FPC_REQUIRES_PROPER_ALIGNMENT} |
||
44 | record |
||
45 | case Integer of |
||
46 | 0: (Left,Top,Right,Bottom : Longint); |
||
47 | 1: (TopLeft,BottomRight : TPoint); |
||
48 | end; |
||
49 | PRect = ^TRect; |
||
50 | |||
51 | TSize = |
||
52 | {$ifndef FPC_REQUIRES_PROPER_ALIGNMENT} |
||
53 | packed |
||
54 | {$endif FPC_REQUIRES_PROPER_ALIGNMENT} |
||
55 | record |
||
56 | cx : Longint; |
||
57 | cy : Longint; |
||
58 | end; |
||
59 | PSize = ^TSize; |
||
60 | tagSIZE = TSize; |
||
61 | // SIZE = TSize; |
||
62 | |||
63 | |||
64 | TSmallPoint = |
||
65 | {$ifndef FPC_REQUIRES_PROPER_ALIGNMENT} |
||
66 | packed |
||
67 | {$endif FPC_REQUIRES_PROPER_ALIGNMENT} |
||
68 | record |
||
69 | x : SmallInt; |
||
70 | y : SmallInt; |
||
71 | end; |
||
72 | PSmallPoint = ^TSmallPoint; |
||
73 | |||
74 | TDuplicates = (dupIgnore, dupAccept, dupError); |
||
75 | |||
76 | type |
||
77 | TOleChar = WideChar; |
||
78 | POleStr = PWideChar; |
||
79 | PPOleStr = ^POleStr; |
||
80 | |||
81 | TListCallback = procedure(data,arg:pointer) of object; |
||
82 | TListStaticCallback = procedure(data,arg:pointer); |
||
83 | |||
84 | const |
||
85 | GUID_NULL: TGUID = '{00000000-0000-0000-0000-000000000000}'; |
||
86 | |||
87 | STGTY_STORAGE = 1; |
||
88 | STGTY_STREAM = 2; |
||
89 | STGTY_LOCKBYTES = 3; |
||
90 | STGTY_PROPERTY = 4; |
||
91 | |||
92 | STREAM_SEEK_SET = 0; |
||
93 | STREAM_SEEK_CUR = 1; |
||
94 | STREAM_SEEK_END = 2; |
||
95 | |||
96 | LOCK_WRITE = 1; |
||
97 | LOCK_EXCLUSIVE = 2; |
||
98 | LOCK_ONLYONCE = 4; |
||
99 | |||
100 | E_FAIL = HRESULT($80004005); |
||
101 | |||
102 | STG_E_INVALIDFUNCTION = HRESULT($80030001); |
||
103 | STG_E_FILENOTFOUND = HRESULT($80030002); |
||
104 | STG_E_PATHNOTFOUND = HRESULT($80030003); |
||
105 | STG_E_TOOMANYOPENFILES = HRESULT($80030004); |
||
106 | STG_E_ACCESSDENIED = HRESULT($80030005); |
||
107 | STG_E_INVALIDHANDLE = HRESULT($80030006); |
||
108 | STG_E_INSUFFICIENTMEMORY = HRESULT($80030008); |
||
109 | STG_E_INVALIDPOINTER = HRESULT($80030009); |
||
110 | STG_E_NOMOREFILES = HRESULT($80030012); |
||
111 | STG_E_DISKISWRITEPROTECTED = HRESULT($80030013); |
||
112 | STG_E_SEEKERROR = HRESULT($80030019); |
||
113 | STG_E_WRITEFAULT = HRESULT($8003001D); |
||
114 | STG_E_READFAULT = HRESULT($8003001E); |
||
115 | STG_E_SHAREVIOLATION = HRESULT($80030020); |
||
116 | STG_E_LOCKVIOLATION = HRESULT($80030021); |
||
117 | STG_E_FILEALREADYEXISTS = HRESULT($80030050); |
||
118 | STG_E_INVALIDPARAMETER = HRESULT($80030057); |
||
119 | STG_E_MEDIUMFULL = HRESULT($80030070); |
||
120 | STG_E_PROPSETMISMATCHED = HRESULT($800300F0); |
||
121 | STG_E_ABNORMALAPIEXIT = HRESULT($800300FA); |
||
122 | STG_E_INVALIDHEADER = HRESULT($800300FB); |
||
123 | STG_E_INVALIDNAME = HRESULT($800300FC); |
||
124 | STG_E_UNKNOWN = HRESULT($800300FD); |
||
125 | STG_E_UNIMPLEMENTEDFUNCTION = HRESULT($800300FE); |
||
126 | STG_E_INVALIDFLAG = HRESULT($800300FF); |
||
127 | STG_E_INUSE = HRESULT($80030100); |
||
128 | STG_E_NOTCURRENT = HRESULT($80030101); |
||
129 | STG_E_REVERTED = HRESULT($80030102); |
||
130 | STG_E_CANTSAVE = HRESULT($80030103); |
||
131 | STG_E_OLDFORMAT = HRESULT($80030104); |
||
132 | STG_E_OLDDLL = HRESULT($80030105); |
||
133 | STG_E_SHAREREQUIRED = HRESULT($80030106); |
||
134 | STG_E_EXTANTMARSHALLINGS = HRESULT($80030108); |
||
135 | STG_E_DOCFILECORRUPT = HRESULT($80030109); |
||
136 | STG_E_BADBASEADDRESS = HRESULT($80030110); |
||
137 | STG_E_INCOMPLETE = HRESULT($80030201); |
||
138 | STG_E_TERMINATED = HRESULT($80030202); |
||
139 | |||
140 | STG_S_CONVERTED = $00030200; |
||
141 | STG_S_BLOCK = $00030201; |
||
142 | STG_S_RETRYNOW = $00030202; |
||
143 | STG_S_MONITORING = $00030203; |
||
144 | |||
145 | type |
||
146 | PCLSID = PGUID; |
||
147 | TCLSID = TGUID; |
||
148 | |||
149 | LARGE_INT = Int64; |
||
150 | Largeint = LARGE_INT; |
||
151 | PDWord = ^DWord; |
||
152 | |||
153 | PDisplay = Pointer; |
||
154 | PEvent = Pointer; |
||
155 | |||
156 | TXrmOptionDescRec = record |
||
157 | end; |
||
158 | XrmOptionDescRec = TXrmOptionDescRec; |
||
159 | PXrmOptionDescRec = ^TXrmOptionDescRec; |
||
160 | |||
161 | Widget = Pointer; |
||
162 | WidgetClass = Pointer; |
||
163 | ArgList = Pointer; |
||
164 | Region = Pointer; |
||
165 | |||
166 | _FILETIME = |
||
167 | {$ifndef FPC_REQUIRES_PROPER_ALIGNMENT} |
||
168 | packed |
||
169 | {$endif FPC_REQUIRES_PROPER_ALIGNMENT} |
||
170 | record |
||
171 | dwLowDateTime : DWORD; |
||
172 | dwHighDateTime : DWORD; |
||
173 | end; |
||
174 | TFileTime = _FILETIME; |
||
175 | FILETIME = _FILETIME; |
||
176 | PFileTime = ^TFileTime; |
||
177 | |||
178 | tagSTATSTG = |
||
179 | {$ifndef FPC_REQUIRES_PROPER_ALIGNMENT} |
||
180 | packed |
||
181 | {$endif FPC_REQUIRES_PROPER_ALIGNMENT} |
||
182 | record |
||
183 | pwcsName : POleStr; |
||
184 | dwType : Longint; |
||
185 | cbSize : Largeint; |
||
186 | mtime : TFileTime; |
||
187 | ctime : TFileTime; |
||
188 | atime : TFileTime; |
||
189 | grfMode : Longint; |
||
190 | grfLocksSupported : Longint; |
||
191 | clsid : TCLSID; |
||
192 | grfStateBits : Longint; |
||
193 | reserved : Longint; |
||
194 | end; |
||
195 | TStatStg = tagSTATSTG; |
||
196 | STATSTG = TStatStg; |
||
197 | PStatStg = ^TStatStg; |
||
198 | |||
199 | IClassFactory = Interface(IUnknown) ['{00000001-0000-0000-C000-000000000046}'] |
||
200 | Function CreateInstance(Const unkOuter : IUnknown;Const riid : TGUID;Out vObject) : HResult;StdCall; |
||
201 | Function LockServer(fLock : LongBool) : HResult;StdCall; |
||
202 | End; |
||
203 | |||
204 | ISequentialStream = interface(IUnknown) ['{0c733a30-2a1c-11ce-ade5-00aa0044773d}'] |
||
205 | function Read(pv : Pointer;cb : DWord;pcbRead : PDWord) : HRESULT;stdcall; |
||
206 | function Write(pv : Pointer;cb : DWord;pcbWritten : PDWord) : HRESULT;stdcall; |
||
207 | end; |
||
208 | |||
209 | IStream = interface(ISequentialStream) ['{0000000C-0000-0000-C000-000000000046}'] |
||
210 | function Seek(dlibMove : LargeInt; dwOrigin : Longint; |
||
211 | out libNewPosition : LargeInt) : HResult;stdcall; |
||
212 | function SetSize(libNewSize : LargeInt) : HRESULT;stdcall; |
||
213 | function CopyTo(stm: IStream;cb : LargeInt;out cbRead : LargeInt; |
||
214 | out cbWritten : LargeInt) : HRESULT;stdcall; |
||
215 | function Commit(grfCommitFlags : Longint) : HRESULT;stdcall; |
||
216 | function Revert : HRESULT;stdcall; |
||
217 | function LockRegion(libOffset : LargeInt;cb : LargeInt; |
||
218 | dwLockType : Longint) : HRESULT;stdcall; |
||
219 | function UnlockRegion(libOffset : LargeInt;cb : LargeInt; |
||
220 | dwLockType : Longint) : HRESULT;stdcall; |
||
221 | Function Stat(out statstg : TStatStg;grfStatFlag : Longint) : HRESULT;stdcall; |
||
222 | function Clone(out stm : IStream) : HRESULT;stdcall; |
||
223 | end; |
||
224 | |||
225 | function EqualRect(const r1,r2 : TRect) : Boolean; |
||
226 | function Rect(Left,Top,Right,Bottom : Integer) : TRect; |
||
227 | function Bounds(ALeft,ATop,AWidth,AHeight : Integer) : TRect; |
||
228 | function Point(x,y : Integer) : TPoint; |
||
229 | function PtInRect(const Rect : TRect; const p : TPoint) : Boolean; |
||
230 | function IntersectRect(var Rect : TRect; const R1,R2 : TRect) : Boolean; |
||
231 | function UnionRect(var Rect : TRect; const R1,R2 : TRect) : Boolean; |
||
232 | function IsRectEmpty(const Rect : TRect) : Boolean; |
||
233 | function OffsetRect(var Rect : TRect;DX : Integer;DY : Integer) : Boolean; |
||
234 | function CenterPoint(const Rect: TRect): TPoint; |
||
235 | function InflateRect(var Rect: TRect; dx: Integer; dy: Integer): Boolean; |
||
236 | function Size(AWidth, AHeight: Integer): TSize; |
||
237 | function Size(ARect: TRect): TSize; |
||
238 | |||
239 | implementation |
||
240 | |||
241 | |||
242 | function EqualRect(const r1,r2 : TRect) : Boolean; |
||
243 | |||
244 | begin |
||
245 | EqualRect:=(r1.left=r2.left) and (r1.right=r2.right) and (r1.top=r2.top) and (r1.bottom=r2.bottom); |
||
246 | end; |
||
247 | |||
248 | |||
249 | function Rect(Left,Top,Right,Bottom : Integer) : TRect; |
||
250 | |||
251 | begin |
||
252 | Rect.Left:=Left; |
||
253 | Rect.Top:=Top; |
||
254 | Rect.Right:=Right; |
||
255 | Rect.Bottom:=Bottom; |
||
256 | end; |
||
257 | |||
258 | |||
259 | function Bounds(ALeft,ATop,AWidth,AHeight : Integer) : TRect; |
||
260 | |||
261 | begin |
||
262 | Bounds.Left:=ALeft; |
||
263 | Bounds.Top:=ATop; |
||
264 | Bounds.Right:=ALeft+AWidth; |
||
265 | Bounds.Bottom:=ATop+AHeight; |
||
266 | end; |
||
267 | |||
268 | |||
269 | function Point(x,y : Integer) : TPoint; |
||
270 | |||
271 | begin |
||
272 | Point.x:=x; |
||
273 | Point.y:=y; |
||
274 | end; |
||
275 | |||
276 | function PtInRect(const Rect : TRect;const p : TPoint) : Boolean; |
||
277 | |||
278 | begin |
||
279 | PtInRect:=(p.y>=Rect.Top) and |
||
280 | (p.y |
||
281 | (p.x>=Rect.Left) and |
||
282 | (p.x |
||
283 | end; |
||
284 | |||
285 | |||
286 | function IntersectRect(var Rect : TRect;const R1,R2 : TRect) : Boolean; |
||
287 | |||
288 | begin |
||
289 | Rect:=R1; |
||
290 | with R2 do |
||
291 | begin |
||
292 | if Left>R1.Left then |
||
293 | Rect.Left:=Left; |
||
294 | if Top>R1.Top then |
||
295 | Rect.Top:=Top; |
||
296 | if Right |
||
297 | Rect.Right:=Right; |
||
298 | if Bottom |
||
299 | Rect.Bottom:=Bottom; |
||
300 | end; |
||
301 | if IsRectEmpty(Rect) then |
||
302 | begin |
||
303 | FillChar(Rect,SizeOf(Rect),0); |
||
304 | IntersectRect:=false; |
||
305 | end |
||
306 | else |
||
307 | IntersectRect:=true; |
||
308 | end; |
||
309 | |||
310 | function UnionRect(var Rect : TRect;const R1,R2 : TRect) : Boolean; |
||
311 | begin |
||
312 | Rect:=R1; |
||
313 | with R2 do |
||
314 | begin |
||
315 | if Left |
||
316 | Rect.Left:=Left; |
||
317 | if Top |
||
318 | Rect.Top:=Top; |
||
319 | if Right>R1.Right then |
||
320 | Rect.Right:=Right; |
||
321 | if Bottom>R1.Bottom then |
||
322 | Rect.Bottom:=Bottom; |
||
323 | end; |
||
324 | if IsRectEmpty(Rect) then |
||
325 | begin |
||
326 | FillChar(Rect,SizeOf(Rect),0); |
||
327 | UnionRect:=false; |
||
328 | end |
||
329 | else |
||
330 | UnionRect:=true; |
||
331 | end; |
||
332 | |||
333 | function IsRectEmpty(const Rect : TRect) : Boolean; |
||
334 | begin |
||
335 | IsRectEmpty:=(Rect.Right<=Rect.Left) or (Rect.Bottom<=Rect.Top); |
||
336 | end; |
||
337 | |||
338 | function OffsetRect(var Rect : TRect;DX : Integer;DY : Integer) : Boolean; |
||
339 | begin |
||
340 | if assigned(@Rect) then |
||
341 | begin |
||
342 | with Rect do |
||
343 | begin |
||
344 | inc(Left,dx); |
||
345 | inc(Top,dy); |
||
346 | inc(Right,dx); |
||
347 | inc(Bottom,dy); |
||
348 | end; |
||
349 | OffsetRect:=true; |
||
350 | end |
||
351 | else |
||
352 | OffsetRect:=false; |
||
353 | end; |
||
354 | |||
355 | function CenterPoint(const Rect: TRect): TPoint; |
||
356 | |||
357 | begin |
||
358 | With Rect do |
||
359 | begin |
||
360 | Result.X:=(Left+Right) div 2; |
||
361 | Result.Y:=(Top+Bottom) div 2; |
||
362 | end; |
||
363 | end; |
||
364 | |||
365 | function InflateRect(var Rect: TRect; dx: Integer; dy: Integer): Boolean; |
||
366 | begin |
||
367 | if Assigned(@Rect) then |
||
368 | begin |
||
369 | with Rect do |
||
370 | begin |
||
371 | dec(Left, dx); |
||
372 | dec(Top, dy); |
||
373 | inc(Right, dx); |
||
374 | inc(Bottom, dy); |
||
375 | end; |
||
376 | Result := True; |
||
377 | end |
||
378 | else |
||
379 | Result := False; |
||
380 | end; |
||
381 | |||
382 | function Size(AWidth, AHeight: Integer): TSize; |
||
383 | begin |
||
384 | Result.cx := AWidth; |
||
385 | Result.cy := AHeight; |
||
386 | end; |
||
387 | |||
388 | function Size(ARect: TRect): TSize; |
||
389 | begin |
||
390 | Result.cx := ARect.Right - ARect.Left; |
||
391 | Result.cy := ARect.Bottom - ARect.Top; |
||
392 | end; |
||
393 | |||
394 | |||
395 | |||
396 | end.=Rect.Top); |