Layers.library

From Freepascal Amiga wiki
Revision as of 20:20, 19 October 2013 by Molly (talk | contribs) (→‎the unit: Added unit source)
Jump to navigation Jump to search

Layers.library

[insert background information here]


examples

Example: Demo

Original c-source [1]

Example: test

Original c-source [2]

Example: Example1

Original c-source [3]


the unit

Unit layers;

{$MODE OBJFPC}{$H+}{$PACKRECORDS C}

Interface

Uses
  CTypes, exec, agraphics, utility;


Const
  LAYERSNAME : PChar = 'layers.library';
Var
  LayersBase : pLibrary;



  Procedure InitLayers(li: pLayer_Info);
  Function  CreateUpfrontLayer(li: pLayer_Info; bm: pBitMap; x0: LongInt; y0: LongInt; x1: LongInt; y1: LongInt; flags: LongInt; bm2: pBitMap): pLayer;
  Function  CreateBehindLayer(li: pLayer_Info; bm: pBitMap; x0: LongInt; y0: LongInt; x1: LongInt; y1: LongInt; flags: LongInt; bm2: pBitMap): pLayer;
  Function  UpfrontLayer(dummy: LongInt; l: pLayer): LongInt;
  Function  BehindLayer(dummy: LongInt; l: pLayer): LongInt;
  Function  MoveLayer(dummy: LongInt; l: pLayer; dx: LongInt; dy: LongInt): LongInt;
  Function  SizeLayer(dummy: LongInt; l: pLayer; dw: LongInt; dh: LongInt): LongInt;
  Procedure ScrollLayer(dummy: LongInt; l: pLayer; dx: LongInt; dy: LongInt);
  Function  BeginUpdate(l: pLayer): LongInt;
  Procedure EndUpdate(l: pLayer; flag: Word);
  Function  DeleteLayer(dummy: LongInt; l: pLayer): LongInt;
  Procedure LockLayer(dummy: LongInt; layer: pLayer);
  Procedure UnlockLayer(layer: pLayer);
  Procedure LockLayers(li: pLayer_Info);
  Procedure UnlockLayers(li: pLayer_Info);
  Procedure LockLayerInfo(li: pLayer_Info);
  Procedure SwapBitsRastPortClipRect(rp: pRastPort; cr: pClipRect);
  Function  WhichLayer(li: pLayer_Info; x: LongInt; y: LongInt): pLayer;
  Procedure UnlockLayerInfo(li: pLayer_Info);
  Function  NewLayerInfo(): pLayer_Info;
  Procedure DisposeLayerInfo(li: pLayer_Info);
  Function  FattenLayerInfo(li: pLayer_Info): LongInt;
  Procedure ThinLayerInfo(li: pLayer_Info);
  Function  MoveLayerInFrontOf(layer_to_move: pLayer; other_layer: pLayer): LongInt;
  Function  InstallClipRegion(l: pLayer; region: pRegion): pRegion;
  Function  MoveSizeLayer(l: pLayer; dx: LongInt; dy: LongInt; dw: LongInt; dh: LongInt): LongInt;
  Function  CreateUpfrontHookLayer(li: pLayer_Info; bm: pBitMap; x0: LongInt; y0: LongInt; x1: LongInt; y1: LongInt; flags: LongInt; hook: pHook; bm2: pBitMap): pLayer;
  Function  CreateBehindHookLayer(li: pLayer_Info; bm: pBitMap; x0: LongInt; y0: LongInt; x1: LongInt; y1: LongInt; flags: LongInt; hook: pHook; bm2: pBitMap): pLayer;
  Function  InstallLayerHook(layer: pLayer; hook: pHook): pHook;
  Function  InstallLayerInfoHook(li: pLayer_Info; hook: pHook): pHook;
  Procedure SortLayerCR(layer: pLayer; dx: LongInt; dy: LongInt);
  Procedure DoHookClipRects(hook: pHook; rport: pRastPort; rect: pRectangle);
  // aros extension
  Function  CreateLayerTagList(li: pLayer_Info; bm: pBitMap; x0: LongInt; y0: LongInt; x1: LongInt; y1: LongInt; flags: LongInt; tagList: pTagItem): pLayer;
  Function  GetFirstFamilyMember(l: pLayer): pLayer;
  Function  ChangeLayerVisibility(l: pLayer; visible: cint): LongInt;
  Function  IsLayerVisible(l: pLayer): LongInt;
  Function  ChangeLayerShape(l: pLayer; newshape: pRegion; callback: pHook): pRegion;
  Function  ScaleLayer(l: pLayer; taglist: pTagItem): LongWord;
  Function  IsFrontmostLayer(l: pLayer; check_invisible: LongBool): LongBool;
  Function  IsLayerHiddenBySibling(l: pLayer; check_invisible: LongBool): LongBool;
  Procedure CollectPixelsLayer(l: pLayer; r: pRegion; callback: pHook);
  // aros extension - varargs
  Function  CreateLayerTags(li: pLayer_Info; bm: pBitMap; x0: LongInt; y0: LongInt; x1: LongInt; y1: LongInt; flags: LongInt; const tags: Array Of Const): pLayer; inline;
  Function  ScaleLayerTags(l: pLayer; const tags: Array of Const): LongWord; inline;



Implementation

Uses
  mytagsarray;


Procedure InitLayers(li: pLayer_Info);
Type
  TLocalCall = Procedure(li: pLayer_Info; LibBase: Pointer); cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 5));
  Call(li, LayersBase);
End;


Function  CreateUpfrontLayer(li: pLayer_Info; bm: pBitMap; x0: LongInt; y0: LongInt; x1: LongInt; y1: LongInt; flags: LongInt; bm2: pBitMap): pLayer;
Type
  TLocalCall = Function(li: pLayer_Info; bm: pBitMap; x0: LongInt; y0: LongInt; x1: LongInt; y1: LongInt; flags: LongInt; bm2: pBitMap; LibBase: Pointer): pLayer; cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 6));
  CreateUpfrontLayer := Call(li, bm, x0, y0, x1, y1, flags, bm2, LayersBase);
End;


Function  CreateBehindLayer(li: pLayer_Info; bm: pBitMap; x0: LongInt; y0: LongInt; x1: LongInt; y1: LongInt; flags: LongInt; bm2: pBitMap): pLayer;
Type
  TLocalCall = Function(li: pLayer_Info; bm: pBitMap; x0: LongInt; y0: LongInt; x1: LongInt; y1: LongInt; flags: LongInt; bm2: pBitMap; LibBase: Pointer): pLayer; cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 7));
  CreateBehindLayer := Call(li, bm, x0, y0, x1, y1, flags, bm2, LayersBase);
End;


Function  UpfrontLayer(dummy: LongInt; l: pLayer): LongInt;
Type
  TLocalCall = Function(dummy: LongInt; l: pLayer; LibBase: Pointer): LongInt; cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 8));
  UpfrontLayer := Call(dummy, l, LayersBase);
End;


Function  BehindLayer(dummy: LongInt; l: pLayer): LongInt;
Type
  TLocalCall = Function(dummy: LongInt; l: pLayer; LibBase: Pointer): LongInt; cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 9));
  BehindLayer := Call(dummy, l, LayersBase);
End;


Function  MoveLayer(dummy: LongInt; l: pLayer; dx: LongInt; dy: LongInt): LongInt;
Type
  TLocalCall = Function(dummy: LongInt; l: pLayer; dx: LongInt; dy: LongInt; LibBase: Pointer): LongInt; cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 10));
  MoveLayer := Call(dummy, l, dx, dy, LayersBase);
End;


Function  SizeLayer(dummy: LongInt; l: pLayer; dw: LongInt; dh: LongInt): LongInt;
Type
  TLocalCall = Function(dummy: LongInt; l: pLayer; dw: LongInt; dh: LongInt; LibBase: Pointer): LongInt; cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 11));
  SizeLayer := Call(dummy, l, dw, dh, LayersBase);
End;


Procedure ScrollLayer(dummy: LongInt; l: pLayer; dx: LongInt; dy: LongInt);
Type
  TLocalCall = Procedure(dummy: LongInt; l: pLayer; dx: LongInt; dy: LongInt; LibBase: Pointer); cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 12));
  Call(dummy, l, dx, dy, LayersBase);
End;


Function  BeginUpdate(l: pLayer): LongInt;
Type
  TLocalCall = Function(l: pLayer; LibBase: Pointer): LongInt; cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 13));
  BeginUpdate := Call(l, LayersBase);
End;


Procedure EndUpdate(l: pLayer; flag: Word);
Type
  TLocalCall = Procedure(l: pLayer; flag: Word; LibBase: Pointer); cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 14));
  Call(l, flag, LayersBase);
End;


Function  DeleteLayer(dummy: LongInt; l: pLayer): LongInt;
Type
  TLocalCall = Function(dummy: LongInt; l: pLayer; LibBase: Pointer): LongInt; cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 15));
  DeleteLayer := Call(dummy, l, LayersBase);
End;


Procedure LockLayer(dummy: LongInt; layer: pLayer);
Type
  TLocalCall = Procedure(dummy: LongInt; layer: pLayer; LibBase: Pointer); cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 16));
  Call(dummy, layer, LayersBase);
End;


Procedure UnlockLayer(layer: pLayer);
Type
  TLocalCall = Procedure(layer: pLayer; LibBase: Pointer); cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 17));
  Call(layer, LayersBase);
End;


Procedure LockLayers(li: pLayer_Info);
Type
  TLocalCall = Procedure(li: pLayer_Info; LibBase: Pointer); cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 18));
  Call(li, LayersBase);
End;


Procedure UnlockLayers(li: pLayer_Info);
Type
  TLocalCall = Procedure(li: pLayer_Info; LibBase: Pointer); cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 19));
  Call(li, LayersBase);
End;


Procedure LockLayerInfo(li: pLayer_Info);
Type
  TLocalCall = Procedure(li: pLayer_Info; LibBase: Pointer); cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 20));
  Call(li, LayersBase);
End;


Procedure SwapBitsRastPortClipRect(rp: pRastPort; cr: pClipRect);
Type
  TLocalCall = Procedure(rp: pRastPort; cr: pClipRect; LibBase: Pointer); cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 21));
  Call(rp, cr, LayersBase);
End;


Function  WhichLayer(li: pLayer_Info; x: LongInt; y: LongInt): pLayer;
Type
  TLocalCall = Function(li: pLayer_Info; x: LongInt; y: LongInt; LibBase: Pointer): pLayer; cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 22));
  WhichLayer := Call(li, x, y, LayersBase);
End;


Procedure UnlockLayerInfo(li: pLayer_Info);
Type
  TLocalCall = Procedure(li: pLayer_Info; LibBase: Pointer); cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 23));
  Call(li, LayersBase);
End;


Function  NewLayerInfo(): pLayer_Info;
Type
  TLocalCall = Function(LibBase: Pointer): pLayer_Info; cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 24));
  NewLayerInfo := Call(LayersBase);
End;


Procedure DisposeLayerInfo(li: pLayer_Info);
Type
  TLocalCall = Procedure(li: pLayer_Info; LibBase: Pointer); cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 25));
  Call(li, LayersBase);
End;


Function  FattenLayerInfo(li: pLayer_Info): LongInt;
Type
  TLocalCall = Function(li: pLayer_Info; LibBase: Pointer): LongInt; cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 26));
  FattenLayerInfo := Call(li, LayersBase);
End;


Procedure ThinLayerInfo(li: pLayer_Info);
Type
  TLocalCall = Procedure(li: pLayer_Info; LibBase: Pointer); cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 27));
  Call(li, LayersBase);
End;


Function  MoveLayerInFrontOf(layer_to_move: pLayer; other_layer: pLayer): LongInt;
Type
  TLocalCall = Function(layer_to_move: pLayer; other_layer: pLayer; LibBase: Pointer): LongInt; cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 28));
  MoveLayerInFrontOf := Call(layer_to_move, other_layer, LayersBase);
End;


Function  InstallClipRegion(l: pLayer; region: pRegion): pRegion;
Type
  TLocalCall = Function(l: pLayer; region: pRegion; LibBase: Pointer): pRegion; cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 29));
  InstallClipRegion := Call(l, region, LayersBase);
End;


Function  MoveSizeLayer(l: pLayer; dx: LongInt; dy: LongInt; dw: LongInt; dh: LongInt): LongInt;
Type
  TLocalCall = Function(l: pLayer; dx: LongInt; dy: LongInt; dw: LongInt; dh: LongInt; LibBase: Pointer): LongInt; cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 30));
  MoveSizeLayer := Call(l, dx, dy, dw, dh, LayersBase);
End;


Function  CreateUpfrontHookLayer(li: pLayer_Info; bm: pBitMap; x0: LongInt; y0: LongInt; x1: LongInt; y1: LongInt; flags: LongInt; hook: pHook; bm2: pBitMap): pLayer;
Type
  TLocalCall = Function(li: pLayer_Info; bm: pBitMap; x0: LongInt; y0: LongInt; x1: LongInt; y1: LongInt; flags: LongInt; hook: pHook; bm2: pBitMap; LibBase: Pointer): pLayer; cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 31));
  CreateUpfrontHookLayer := Call(li, bm, x0, y0, x1, y1, flags, hook, bm2, LayersBase);
End;


Function  CreateBehindHookLayer(li: pLayer_Info; bm: pBitMap; x0: LongInt; y0: LongInt; x1: LongInt; y1: LongInt; flags: LongInt; hook: pHook; bm2: pBitMap): pLayer;
Type
  TLocalCall = Function(li: pLayer_Info; bm: pBitMap; x0: LongInt; y0: LongInt; x1: LongInt; y1: LongInt; flags: LongInt; hook: pHook; bm2: pBitMap; LibBase: Pointer): pLayer; cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 32));
  CreateBehindHookLayer := Call(li, bm, x0, y0, x1, y1, flags, hook, bm2, LayersBase);
End;


Function  InstallLayerHook(layer: pLayer; hook: pHook): pHook;
Type
  TLocalCall = Function(layer: pLayer; hook: pHook; LibBase: Pointer): pHook; cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 33));
  InstallLayerHook := Call(layer, hook, LayersBase);
End;


Function  InstallLayerInfoHook(li: pLayer_Info; hook: pHook): pHook;
Type
  TLocalCall = Function(li: pLayer_Info; hook: pHook; LibBase: Pointer): pHook; cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 34));
  InstallLayerInfoHook := Call(li, hook, LayersBase);
End;


Procedure SortLayerCR(layer: pLayer; dx: LongInt; dy: LongInt);
Type
  TLocalCall = Procedure(layer: pLayer; dx: LongInt; dy: LongInt; LibBase: Pointer); cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 35));
  Call(layer, dx, dy, LayersBase);
End;


Procedure DoHookClipRects(hook: pHook; rport: pRastPort; rect: pRectangle);
Type
  TLocalCall = Procedure(hook: pHook; rport: pRastPort; rect: pRectangle; LibBase: Pointer); cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 36));
  Call(hook, rport, rect, LayersBase);
End;


Function  CreateLayerTagList(li: pLayer_Info; bm: pBitMap; x0: LongInt; y0: LongInt; x1: LongInt; y1: LongInt; flags: LongInt; tagList: pTagItem): pLayer;
Type
  TLocalCall = Function(li: pLayer_Info; bm: pBitMap; x0: LongInt; y0: LongInt; x1: LongInt; y1: LongInt; flags: LongInt; tagList: pTagItem; LibBase: Pointer): pLayer; cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 37));
  CreateLayerTagList := Call(li, bm, x0, y0, x1, y1, flags, tagList, LayersBase);
End;


Function  GetFirstFamilyMember(l: pLayer): pLayer;
Type
  TLocalCall = Function(l: pLayer; LibBase: Pointer): pLayer; cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 38));
  GetFirstFamilyMember := Call(l, LayersBase);
End;


Function  ChangeLayerVisibility(l: pLayer; visible: cint): LongInt;
Type
  TLocalCall = Function(l: pLayer; visible: cint; LibBase: Pointer): LongInt; cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 39));
  ChangeLayerVisibility := Call(l, visible, LayersBase);
End;


Function  IsLayerVisible(l: pLayer): LongInt;
Type
  TLocalCall = Function(l: pLayer; LibBase: Pointer): LongInt; cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 40));
  IsLayerVisible := Call(l, LayersBase);
End;


Function  ChangeLayerShape(l: pLayer; newshape: pRegion; callback: pHook): pRegion;
Type
  TLocalCall = Function(l: pLayer; newshape: pRegion; callback: pHook; LibBase: Pointer): pRegion; cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 41));
  ChangeLayerShape := Call(l, newshape, callback, LayersBase);
End;


Function  ScaleLayer(l: pLayer; taglist: pTagItem): LongWord;
Type
  TLocalCall = Function(l: pLayer; taglist: pTagItem; LibBase: Pointer): LongWord; cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 42));
  ScaleLayer := Call(l, taglist, LayersBase);
End;


Function  IsFrontmostLayer(l: pLayer; check_invisible: LongBool): LongBool;
Type
  TLocalCall = Function(l: pLayer; check_invisible: LongBool; LibBase: Pointer): LongBool; cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 43));
  IsFrontmostLayer := Call(l, check_invisible, LayersBase);
End;


Function  IsLayerHiddenBySibling(l: pLayer; check_invisible: LongBool): LongBool;
Type
  TLocalCall = Function(l: pLayer; check_invisible: LongBool; LibBase: Pointer): LongBool; cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 44));
  IsLayerHiddenBySibling := Call(l, check_invisible, LayersBase);
End;


Procedure CollectPixelsLayer(l: pLayer; r: pRegion; callback: pHook);
Type
  TLocalCall = Procedure(l: pLayer; r: pRegion; callback: pHook; LibBase: Pointer); cdecl;
Var
  Call : TLocalCall;
Begin
  Call := TLocalCall(GetLibAdress(LayersBase, 45));
  Call(l, r, callback, LayersBase);
End;





Function  CreateLayerTags(li: pLayer_Info; bm: pBitMap; x0: LongInt; y0: LongInt; x1: LongInt; y1: LongInt; flags: LongInt; const tags: Array Of Const): pLayer;
begin
  CreateLayerTags := CreateLayerTagList(li, bm, x0, y0, x1, y1, flags, readintags(tags));
end;

Function  ScaleLayerTags(l: pLayer; const tags: Array of Const): LongWord;
begin
  ScaleLayerTags := ScaleLayer(l, readintags(tags));
end;




Initialization
  LayersBase := OpenLibrary(LayersName, 0);


Finalization
  CloseLibrary(LayersBase);

End.

unit documentation

A bit rough around the edges. No var /var was done, and only some basic links to other units (types etc.).