layers.pas 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2004 Karoly Balogh for Genesi S.a.r.l. <www.genesi.lu>
  4. layers.library interface unit for MorphOS/PowerPC
  5. Based on work of Nils Sjoholm member of the Amiga RTL
  6. development team.
  7. MorphOS port was done on a free Pegasos II/G4 machine
  8. provided by Genesi S.a.r.l. <www.genesi.lu>
  9. See the file COPYING.FPC, included in this distribution,
  10. for details about the copyright.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. **********************************************************************}
  15. {$PACKRECORDS 2}
  16. unit layers;
  17. interface
  18. uses exec, graphics, utility;
  19. const
  20. LAYERSIMPLE = 1;
  21. LAYERSMART = 2;
  22. LAYERSUPER = 4;
  23. LAYERUPDATING = $10;
  24. LAYERBACKDROP = $40;
  25. LAYERREFRESH = $80;
  26. LAYER_CLIPRECTS_LOST = $100; { during BeginUpdate }
  27. { or during layerop }
  28. { this happens if out of memory }
  29. LMN_REGION = -1;
  30. type
  31. pLayer_Info = ^tLayer_Info;
  32. tLayer_Info = packed record
  33. top_layer : pLayer;
  34. check_lp : pLayer; { !! Private !! }
  35. obs : pClipRect;
  36. FreeClipRects : pClipRect; { !! Private !! }
  37. PrivateReserve1, { !! Private !! }
  38. PrivateReserve2 : Longint; { !! Private !! }
  39. Lock : tSignalSemaphore; { !! Private !! }
  40. gs_Head : tMinList; { !! Private !! }
  41. PrivateReserve3 : smallint; { !! Private !! }
  42. PrivateReserve4 : Pointer; { !! Private !! }
  43. Flags : WORD;
  44. fatten_count : Shortint; { !! Private !! }
  45. LockLayersCount : Shortint; { !! Private !! }
  46. PrivateReserve5 : smallint; { !! Private !! }
  47. BlankHook, { !! Private !! }
  48. LayerInfo_extra : Pointer; { !! Private !! }
  49. end;
  50. const
  51. NEWLAYERINFO_CALLED = 1;
  52. {
  53. * LAYERS_NOBACKFILL is the value needed to get no backfill hook
  54. * LAYERS_BACKFILL is the value needed to get the default backfill hook
  55. }
  56. LAYERS_NOBACKFILL = 1;
  57. LAYERS_BACKFILL = 0;
  58. LAYERSNAME : PChar = 'layers.library';
  59. var
  60. LayersBase : PLibrary;
  61. procedure InitLayers(li : pLayer_Info location 'a0');
  62. SysCall LayersBase 030;
  63. function CreateUpfrontLayer(li : pLayer_Info location 'a0'; bm : pBitMap location 'a1'; x0 : LongInt location 'd0'; y0 : LongInt location 'd1'; x1 : LongInt location 'd2'; y1 : LongInt location 'd3'; flags : LongInt location 'd4'; bm2 : pBitMap location 'a2') : pLayer;
  64. SysCall LayersBase 036;
  65. function CreateBehindLayer(li : pLayer_Info location 'a0'; bm : pBitMap location 'a1'; x0 : LongInt location 'd0'; y0 : LongInt location 'd1'; x1 : LongInt location 'd2'; y1 : LongInt location 'd3'; flags : LongInt location 'd4'; bm2 : pBitMap location 'a2') : pLayer;
  66. SysCall LayersBase 042;
  67. function UpfrontLayer(dummy : LongInt location 'a0'; layer : pLayer location 'a1') : LongInt;
  68. SysCall LayersBase 048;
  69. function BehindLayer(dummy : LongInt location 'a0'; layer : pLayer location 'a1') : LongInt;
  70. SysCall LayersBase 054;
  71. function MoveLayer(dummy : LongInt location 'a0'; layer : pLayer location 'a1'; dx : LongInt location 'd0'; dy : LongInt location 'd1') : LongInt;
  72. SysCall LayersBase 060;
  73. function SizeLayer(dummy : LongInt location 'a0'; layer : pLayer location 'a1'; dx : LongInt location 'd0'; dy : LongInt location 'd1') : LongInt;
  74. SysCall LayersBase 066;
  75. procedure ScrollLayer(dummy : LongInt location 'a0'; layer : pLayer location 'a1'; dx : LongInt location 'd0'; dy : LongInt location 'd1');
  76. SysCall LayersBase 072;
  77. function BeginUpdate(l : pLayer location 'a0') : LongInt;
  78. SysCall LayersBase 078;
  79. procedure EndUpdate(layer : pLayer location 'a0'; flag : CARDINAL location 'd0');
  80. SysCall LayersBase 084;
  81. function DeleteLayer(dummy : LongInt location 'a0'; layer : pLayer location 'a1') : LongInt;
  82. SysCall LayersBase 090;
  83. procedure LockLayer(dummy : LongInt location 'a0'; layer : pLayer location 'a1');
  84. SysCall LayersBase 096;
  85. procedure UnlockLayer(layer : pLayer location 'a0');
  86. SysCall LayersBase 102;
  87. procedure LockLayers(li : pLayer_Info location 'a0');
  88. SysCall LayersBase 108;
  89. procedure UnlockLayers(li : pLayer_Info location 'a0');
  90. SysCall LayersBase 114;
  91. procedure LockLayerInfo(li : pLayer_Info location 'a0');
  92. SysCall LayersBase 120;
  93. procedure SwapBitsRastPortClipRect(rp : pRastPort location 'a0'; cr : pClipRect location 'a1');
  94. SysCall LayersBase 126;
  95. function WhichLayer(li : pLayer_Info location 'a0'; x : LongInt location 'd0'; y : LongInt location 'd1') : pLayer;
  96. SysCall LayersBase 132;
  97. procedure UnlockLayerInfo(li : pLayer_Info location 'a0');
  98. SysCall LayersBase 138;
  99. function NewLayerInfo : pLayer_Info;
  100. SysCall LayersBase 144;
  101. procedure DisposeLayerInfo(li : pLayer_Info location 'a0');
  102. SysCall LayersBase 150;
  103. function FattenLayerInfo(li : pLayer_Info location 'a0') : LongInt;
  104. SysCall LayersBase 156;
  105. procedure ThinLayerInfo(li : pLayer_Info location 'a0');
  106. SysCall LayersBase 162;
  107. function MoveLayerInFrontOf(layer_to_move : pLayer location 'a0'; other_layer : pLayer location 'a1') : LongInt;
  108. SysCall LayersBase 168;
  109. function InstallClipRegion(layer : pLayer location 'a0'; CONST region : pRegion location 'a1') : pRegion;
  110. SysCall LayersBase 174;
  111. function MoveSizeLayer(layer : pLayer location 'a0'; dx : LongInt location 'd0'; dy : LongInt location 'd1'; dw : LongInt location 'd2'; dh : LongInt location 'd3') : LongInt;
  112. SysCall LayersBase 180;
  113. function CreateUpfrontHookLayer(li : pLayer_Info location 'a0'; bm : pBitMap location 'a1'; x0 : LongInt location 'd0'; y0 : LongInt location 'd1'; x1 : LongInt location 'd2'; y1 : LongInt location 'd3'; flags : LongInt location 'd4'; hook : pHook location 'a3'; bm2 : pBitMap location 'a2') : pLayer;
  114. SysCall LayersBase 186;
  115. function CreateBehindHookLayer(li : pLayer_Info location 'a0'; bm : pBitMap location 'a1'; x0 : LongInt location 'd0'; y0 : LongInt location 'd1'; x1 : LongInt location 'd2'; y1 : LongInt location 'd3'; flags : LongInt location 'd4'; hook : pHook location 'a3'; bm2 : pBitMap location 'a2') : pLayer;
  116. SysCall LayersBase 192;
  117. function InstallLayerHook(layer : pLayer location 'a0'; hook : pHook location 'a1') : pHook;
  118. SysCall LayersBase 198;
  119. function InstallLayerInfoHook(li : pLayer_Info location 'a0'; CONST hook : pHook location 'a1') : pHook;
  120. SysCall LayersBase 204;
  121. procedure SortLayerCR(layer : pLayer location 'a0'; dx : LongInt location 'd0'; dy : LongInt location 'd1');
  122. SysCall LayersBase 210;
  123. procedure DoHookClipRects(hook : pHook location 'a0'; rport : pRastPort location 'a1'; CONST rect : pRectangle location 'a2');
  124. SysCall LayersBase 216;
  125. function InstallTransparentRegion(l : pLayer location 'a0'; r : pRegion location 'a1') : pRegion;
  126. SysCall LayersBase 222;
  127. function InstallTransparentRegionHook(l : pLayer location 'a0'; h : pHook location 'a1') : pHook;
  128. SysCall LayersBase 228;
  129. function CreateUpfrontLayerTagList(li : pLayer_Info location 'a0'; bm : pBitMap location 'a1'; x0 : LongInt location 'd0'; y0 : LongInt location 'd1'; x1 : LongInt location 'd2'; y1 : LongInt location 'd3'; flags : LongInt location 'd4'; taglist : pTagItem location 'a2') : pLayer;
  130. SysCall LayersBase 234;
  131. function CreateBehindLayerTagList(li : pLayer_Info location 'a0'; bm : pBitMap location 'a1'; x0 : LongInt location 'd0'; y0 : LongInt location 'd1'; x1 : LongInt location 'd2'; y1 : LongInt location 'd3'; flags : LongInt location 'd4'; taglist : pTagItem location 'a2') : pLayer;
  132. SysCall LayersBase 240;
  133. {
  134. Functions and procedures with array of const go here
  135. }
  136. {
  137. function CreateUpfrontLayerTags(li : pLayer_Info; bm : pBitMap; x0 : LongInt; y0 : LongInt; x1 : LongInt; y1 : LongInt; flags : LongInt; const taglist : Array Of Const) : pLayer;
  138. function CreateBehindLayerTags(li : pLayer_Info; bm : pBitMap; x0 : LongInt; y0 : LongInt; x1 : LongInt; y1 : LongInt; flags : LongInt; const taglist : Array Of Const) : pLayer;
  139. }
  140. { Helper func }
  141. function InitLayersLibrary : boolean;
  142. implementation
  143. const
  144. { Change VERSION and LIBVERSION to proper values }
  145. VERSION : string[2] = '50';
  146. LIBVERSION : longword = 50;
  147. var
  148. layers_exit : Pointer;
  149. procedure CloseLayersLibrary;
  150. begin
  151. ExitProc := layers_exit;
  152. if LayersBase <> nil then begin
  153. CloseLibrary(LayersBase);
  154. LayersBase := nil;
  155. end;
  156. end;
  157. function InitLayersLibrary : boolean;
  158. begin
  159. LayersBase := nil;
  160. LayersBase := OpenLibrary(LAYERSNAME,LIBVERSION);
  161. if LayersBase <> nil then begin
  162. layers_exit := ExitProc;
  163. ExitProc := @CloseLayersLibrary;
  164. InitLayersLibrary:=True;
  165. end else begin
  166. InitLayersLibrary:=False;
  167. end;
  168. end;
  169. end.