Layers.library

From Freepascal Amiga wiki
Jump to: navigation, search

Layers.library

[insert background information here]


examples

Example: layerstest

A collection of assorted layers functions is used in this test.

Original c-source [1]

Program layerstest;

{$MODE OBJFPC}{$H+}

Uses
  Exec, AmigaDos, Layers, AGraphics, Intuition, Utility,
  sysutils;


Var
  IntuitionBase : pIntuitionBase;
  GfxBase       : pGfxBase;
  LayersBase    : pLibrary;
  DosBase       : pDosLibrary;
  screen        : pScreen;
//  window        : pWindow;


  Procedure DoAll(); forward;
  Function  DoOpenScreen(): pScreen; forward;
  Procedure DoCloseScreen(screen: pScreen); forward;

//Var
//  BltBitMapPtr: Pointer;



Function Main: LongInt;
begin
  IntuitionBase := pIntuitionBase(OpenLibrary('intuition.library',0));
  if (IntuitionBase <> nil) then
  begin
    GfxBase := pGfxBase(OpenLibrary('graphics.library',0));
    if (GfxBase <> nil) then
    begin
      LayersBase := OpenLibrary('layers.library',0);
      if (LayersBase <> nil) then
      begin
        DOSBase := pDosLibrary(OpenLibrary('dos.library',0));
        if (DOSBase <> nil) then
        begin
          Screen := DoOpenScreen();
          if screen <> nil then
          begin
            DoAll;
            DoCloseScreen(Screen);
          end;
          CloseLibrary(pLibrary(DOSBase));
        end;
        CloseLibrary(LayersBase);
      end;
      CloseLibrary(pLibrary(GfxBase));
    end;
    CloseLibrary(pLibrary(IntuitionBase));
  end;
  result := 0;
end;



Function  DoOpenScreen(): pScreen;
var Screen : pScreen;
begin
  screen := OpenScreenTags(nil,
  [
    LongInt(SA_Height), 200,
    LongInt(SA_Width),  300,
    TAG_END
  ]);

  Draw(@Screen^.RastPort, 100, 100);
  result := Screen;
end;


Procedure DoCloseScreen(screen: pScreen);
begin
  CloseScreen(screen);
end;


Var
  layers: array[0..9] of pLayer;


procedure DoFreeLayers;
var i: Integer;
begin
  For i := 0 to 9 do
  begin
    if (nil <> layers[i]) then
    begin
      DeleteLayer(0, layers[i]);
      if (layers[i]^.SuperBitmap <> nil)
        then FreeBitmap(layers[i]^.SuperBitMap);
    end;
  end;
end;


Function DoUnusedLayer: integer;
var i: integer;
begin
  for i := 0 to 9 do
  begin
    if (nil = layers[i]) then exit(i);
  end;
  result := -1;
end;


procedure DoCreateupfrontlayer;
var
  x0,y0,x1,y1: integer;
  i : integer;
  c,s : char;
  flags : LongInt = 0;
  sb    : pBitmap = nil;
begin
  for i := 0 to 9 do
  begin
    if (layers[i] = nil) then break;
  end;
  if (i < 10) then
  begin
    write('Backdroplayer [y/N]: ');
    Read(c);
    write('SuperBitmap [y/N]: ');
    read(s);
    write('x0: ');
    read(x0);
    write('y0: ');
    read(y0);
    write('x1: ');
    read(x1);
    write('y1: ');
    read(y1);

    if (c='y') or (c='Y') then
    begin
      writeln('Generating a backdrop layer.');
      flags := flags or LAYERBACKDROP;
    end;

    if (s='y') or (s='Y') then
    begin
      writeln('Generating a superbitmap layer.');
      flags := flags or LAYERSUPER;
      sb := AllocBitmap(x1-x0+1,y1-y0+1,1,BMF_CLEAR, nil);
    end;

    flags := flags or LAYERSMART;

    layers[i] := CreateUpFrontLayer
    (
      @Screen^.LayerInfo,Screen^.RastPort.Bitmap, x0,y0,x1,y1,flags,sb
    );

    if (layers[i] <> nil)
    then writeln('Created layer with ID ',i)
    else Writeln('Could not create layer. No more memory (?).');
  end
  else
  writeln('No more layers possible!');
end;


procedure DoCreatebehindlayer;
var
  x0,y0,x1,y1: integer;
  i : integer;
  c,s : char;
  flags : LongInt = 0;
  sb    : pBitmap = nil;
begin
  for i := 0 to 9 do
  begin
    if (layers[i] = nil) then break;
  end;
  if (i < 10) then
  begin
    write('Backdroplayer [y/N]: ');
    Read(c);
    write('SuperBitmap [y/N]: ');
    read(s);
    write('x0: ');
    read(x0);
    write('y0: ');
    read(y0);
    write('x1: ');
    read(x1);
    write('y1: ');
    read(y1);

    if (c='y') or (c='Y') then
    begin
      writeln('Generating a backdrop layer.');
      flags := flags or LAYERBACKDROP;
    end;

    if (s='y') or (s='Y') then
    begin
      writeln('Generating a superbitmap layer.');
      flags := flags or LAYERSUPER;
      sb := AllocBitmap(x1-x0+1,y1-y0+1,1,BMF_CLEAR, nil);
    end;

    flags := flags or LAYERSMART;

    layers[i] := CreateBehindLayer
    (
      @Screen^.LayerInfo,Screen^.RastPort.Bitmap, x0,y0,x1,y1,flags,sb
    );

    if (layers[i] <> nil)
    then writeln('Created layer with ID ',i)
    else Writeln('Could not create layer. No more memory (?).');
  end
  else
  writeln('No more layers possible!');
end;


procedure DoDeletelayer;
var i: integer;
begin
  write('Delete layer with id: ');
  read(i);
  if (layers[i] <> nil) then
  begin
    DeleteLayer(0, layers[i]);
    if (layers[i]^.SuperBitmap <> nil)
      then FreeBitMap(Layers[i]^.SuperBitmap);
    writeln('Deleted layer with id ',i);
    layers[i] := nil;
  end
  else
  begin
    writeln('No layer with id ',i);
  end;
end;


procedure DoUpfrontlayer;
var i: integer;
begin
  write('Upfront layer with id: ');
  read(i);
  if (layers[i] <> nil) then
  begin
    UpfrontLayer(0, layers[i]);
    writeln('Moved layer with id ',i,' upfront');
  end
  else
  begin
    writeln('No layer with id ',i);
  end;
end;


procedure DoBehindlayer;
var i: integer;
begin
  write('Behind layer with id: ');
  read(i);
  if (layers[i] <> nil) then
  begin
    BehindLayer(0, layers[i]);
    writeln('Moved layer with id ',i,' behind');
  end
  else
  begin
    writeln('No layer with id ',i);
  end;
end;


procedure DoMovelayerinfrontof;
var i1,i2: integer;
begin
  write('Move layer with id: ');
  read(i1);
  write('in front of layer with id: ');
  read(i2);

  if (layers[i1] <> nil) and (layers[i2] <> nil) then
  begin
    MoveLayerInFrontOf(layers[i1],layers[i2]);
    writeln('Moved layer with id ',i1,' in front of layer with id ',i2);
  end
  else
  begin
    writeln('No layer with id ',i1,' or id ',i2);
  end;
end;


procedure DoMovelayer;
var i,dx,dy: integer;
begin
  write('Move layer with id: ');
  read(i);
  write('delta x: ');
  read(dx);
  write('delta y: ');
  read(dy);

  if (layers[i] <> nil) then
  begin
    MoveLayer(0, layers[i], dx, dy);
    writeln('Moved layer with id ',i,' to new position.');
  end
  else
  begin
    writeln('No layer with id ',i);
  end;
end;


procedure DoMovesizelayer;
var i,dx,dy,dw,dh: integer;
begin
  write('Move and size layer with id: ');
  read(i);
  write('delta x: ');
  read(dx);
  write('delta y: ');
  read(dy);
  write('delta width: ');
  read(dw);
  write('delta height: ');
  read(dh);

  if (layers[i] <> nil) then
  begin
    MoveSizeLayer(layers[i], dx, dy,dw,dh);
    writeln('Moved and sized layer with id ',i,'.');
  end
  else
  begin
    writeln('No layer with id ',i);
  end;
end;


procedure DoSizelayer;
var i,dw,dh: integer;
begin
  write('Resize layer with id: ');
  read(i);
  write('delta width: ');
  read(dw);
  write('delta height: ');
  read(dh);

  if (layers[i] <> nil) then
  begin
    SizeLayer(0, layers[i], dw, dh);
    writeln('Resized layer with id ',i,'.');
  end
  else
  begin
    writeln('No layer with id ',i);
  end;
end;


procedure DoScrolllayer;
var i,dx,dy: integer;
begin
  write('Scroll layer with id: ');
  read(i);

  if (layers[i] = nil) then
  begin
    writeln('No layer with id ',i);
    exit;
  end;

  write('delta x: ');
  read(dx);
  write('delta y: ');
  read(dy);

  if ((layers[i]^.Flags and LAYERSUPER) <> 0)
  then writeln('This is a non-superbitmapped layer.')
  else writeln('This is a superbitmapped layer.');

  ScrollLayer(0, layers[i], dx, dy);
  writeln('Scrolled layer with id ',i,'.');
end;


procedure DoMotion;
var i,dx,dy, iter: integer;
begin
  write('Move layer with id: ');
  read(i);
  write('delta x: ');
  read(dx);
  write('delta y: ');
  read(dy);
  write('iterations: ');
  read(iter);

  if (layers[i] <> nil) then
  begin
    while (iter > 0) and (LTrue = MoveLayer(0, layers[i], dx, dy))
    do dec(iter);
    writeln('Moved layer with id ',i,' to new position.');
  end
  else
  begin
    writeln('No layer with id ',i);
  end;
end;


// Draw a simple frame around a layer
procedure DoFrame(layer: pLayer); overload;
var c, width, i : integer;
begin
  width := layer^.bounds.MaxX - layer^.bounds.MinX;
  i := 0;
  SetAPen(layer^.rp , 1);
  Move(layer^.rp, 0,0);
  draw(layer^.rp, layer^.bounds.MaxX - layer^.bounds.MinX, 0);
  draw(layer^.rp, layer^.bounds.MaxX - layer^.bounds.MinX, layer^.bounds.MaxY - layer^.bounds.MinY);
  draw(layer^.rp,                                       0, layer^.bounds.MaxY - layer^.bounds.MinY);
  draw(layer^.rp,                                       0, 0);
  draw(layer^.rp, layer^.bounds.MaxX - layer^.bounds.MinX, layer^.bounds.MaxY - layer^.bounds.MinY);

  c := 0;
  while c <= width do
  begin
    move(layer^.rp,c, 0);
    draw(layer^.rp,c, layer^.bounds.MaxY - layer^.bounds.MinY);

    inc(i,2);
    c := c + (width and $f) + i;
  end;
end;


procedure DoFrame; overload;
var i: Integer;
begin
  writeln('Framing layer with id: ');
  read(i);
  if (layers[i] <> nil) then
  begin
    // draw a frame
    DoFrame(layers[i]);
  end
  else
  begin
    writeln('No layer with id ',i);
  end;
end;


procedure DoGenerateLayers1;
var i: integer;
begin
  i := DoUnusedLayer;
  if (i=-1) then exit;
  layers[i] := CreateUpFrontLayer(@screen^.LayerInfo, Screen^.RastPort.Bitmap,10,10,100,100,LAYERSMART,nil);
  DoFrame(layers[i]);

  i := DoUnusedLayer;
  if (i=-1) then exit;
  layers[i] := CreateUpFrontLayer(@screen^.LayerInfo, Screen^.RastPort.Bitmap,50,50,150,150,LAYERSMART,nil);
  DoFrame(layers[i]);

  i := DoUnusedLayer;
  if (i=-1) then exit;
  layers[i] := CreateUpFrontLayer(@screen^.LayerInfo, Screen^.RastPort.Bitmap,20,20,120, 70,LAYERSMART,nil);
  DoFrame(layers[i]);
end;


procedure DoGenerateLayers2;
var i: integer;
begin
  i := DoUnusedLayer;
  if (i=-1) then exit;
  layers[i] := CreateBehindLayer(@screen^.LayerInfo, Screen^.RastPort.Bitmap,10,10,100, 95,LAYERSMART,nil);
  DoFrame(layers[i]);

  i := DoUnusedLayer;
  if (i=-1) then exit;
  layers[i] := CreateBehindLayer(@screen^.LayerInfo, Screen^.RastPort.Bitmap,50,50,150,150,LAYERSMART,nil);
  DoFrame(layers[i]);

  i := DoUnusedLayer;
  if (i=-1) then exit;
  layers[i] := CreateBehindLayer(@screen^.LayerInfo, Screen^.RastPort.Bitmap,70,130,140,190,LAYERSMART,nil);
  DoFrame(layers[i]);

  i := DoUnusedLayer;
  if (i=-1) then exit;
  layers[i] := CreateBehindLayer(@screen^.LayerInfo, Screen^.RastPort.Bitmap,120,120,150,160,LAYERSMART,nil);
  DoFrame(layers[i]);
end;


procedure DoGenerateLayers3;
var i: integer;
begin
  i := DoUnusedLayer;
  if (i=-1) then exit;
  layers[i] := CreateBehindLayer(@screen^.LayerInfo, Screen^.RastPort.Bitmap,110,110,200,195,LAYERSMART,nil);
  DoFrame(layers[i]);

  i := DoUnusedLayer;
  if (i=-1) then exit;
  layers[i] := CreateBehindLayer(@screen^.LayerInfo, Screen^.RastPort.Bitmap,150,150,190,190,LAYERSMART,nil);
  DoFrame(layers[i]);

  i := DoUnusedLayer;
  if (i=-1) then exit;
  layers[i] := CreateBehindLayer(@screen^.LayerInfo, Screen^.RastPort.Bitmap,70,130,140,190,LAYERSMART,nil);
  DoFrame(layers[i]);

  i := DoUnusedLayer;
  if (i=-1) then exit;
  layers[i] := CreateBehindLayer(@screen^.LayerInfo, Screen^.RastPort.Bitmap,120,120,150,160,LAYERSMART,nil);
  DoFrame(layers[i]);
end;


procedure DoGenerateLayers4;
var i, c: integer;
begin
  c := 0;
  while c < 5 do
  begin
    i := DoUnusedLayer;
    if (i=-1) then exit;
    layers[i] := CreateBehindLayer(@screen^.LayerInfo, Screen^.RastPort.Bitmap,10+c*10,10+c*10,100+c*10,100+c*10,LAYERSMART,nil);
    DoFrame(layers[i]);
    inc(c);
  end;
end;


procedure DoDemoA;
Const DELAYTIME = 50;
var i:integer;
begin
  writeln('Deleting all previously generated layers...');
  for i := 0 to 9 do
  begin
    if (layers[i] <> nil) then
    begin
      DeleteLayer(0, layers[i]);
      layers[i] := nil;
    end;
  end;

  writeln('After each step there will be a short delay.');
  writeln('Activate other X-window (Amiga Screen) and always press a key');
  writeln('to see what is going on');

  i := 0;
  writeln('Creating layer ',i,'.');
  DOSDelay(DELAYTIME);
  layers[i] := CreateUpFrontLayer(@screen^.LayerInfo, Screen^.RastPort.Bitmap,10,10,100,100,LAYERSMART,nil);
  DoFrame(layers[i]);

  inc(i);
  writeln('Creating layer ',i,'.');
  DOSDelay(DELAYTIME);
  layers[i] := CreateUpFrontLayer(@screen^.LayerInfo, Screen^.RastPort.Bitmap,20, 5, 30,150,LAYERSMART,nil);
  DoFrame(layers[i]);

  inc(i);
  writeln('Creating layer ',i,'.');
  DOSDelay(DELAYTIME);
  layers[i] := CreateUpFrontLayer(@screen^.LayerInfo, Screen^.RastPort.Bitmap, 5,50,150, 70,LAYERSMART,nil);
  DoFrame(layers[i]);

  inc(i);
  writeln('Creating layer ',i,'.');
  DOSDelay(DELAYTIME);
  layers[i] := CreateUpFrontLayer(@screen^.LayerInfo, Screen^.RastPort.Bitmap,80, 5,180,200,LAYERSMART,nil);
  DoFrame(layers[i]);

  i := 0;
  writeln('Moving layer ',i,' in front of all other layers.');
  DOSDelay(DELAYTIME);
  UpFrontLayer(0, Layers[i]);

  i := 1;
  writeln('Moving layer ',i,' in front of all other layers.');
  DOSDelay(DELAYTIME);
  UpFrontLayer(0, Layers[i]);

  i := 2;
  writeln('Moving layer ',i,' in front of all other layers.');
  DOSDelay(DELAYTIME);
  UpFrontLayer(0, Layers[i]);

  i := 3;
  writeln('Moving layer ',i,' in front of all other layers.');
  DOSDelay(DELAYTIME);
  UpFrontLayer(0, Layers[i]);


  i := 0;
  writeln('Moving layer ',i,' in front of all other layers.');
  DOSDelay(DELAYTIME);
  UpFrontLayer(0, Layers[i]);

  i := 2;
  writeln('Moving layer ',i,' in front of all other layers.');
  DOSDelay(DELAYTIME);
  UpFrontLayer(0, Layers[i]);

  i := 2;
  writeln('Moving layer ',i,' in front of all other layers.');
  DOSDelay(DELAYTIME);
  UpFrontLayer(0, Layers[i]);

  i := 1;
  writeln('Moving layer ',i,' in front of all other layers.');
  DOSDelay(DELAYTIME);
  UpFrontLayer(0, Layers[i]);

  i := 2;
  writeln('Moving layer ',i,' in front of all other layers.');
  DOSDelay(DELAYTIME);
  UpFrontLayer(0, Layers[i]);

  for i := 0 to 9 do
    if (layers[i] <> nil) then
    begin
      writeln('Destroying layer ',i,'.');
      DOSDelay(DELAYTIME);
      DeleteLayer(0, layers[i]);
      Layers[i] := nil;
    end;
  writeln('End of demo .');
end;


procedure DoDemoB;
Const DELAYTIME = 100;
var i:integer;
begin
  writeln('Deleting all previously generated layers...');
  for i := 0 to 9 do
  begin
    if (layers[i] <> nil) then
    begin
      DeleteLayer(0, layers[i]);
      layers[i] := nil;
    end;
  end;

  writeln('After each step there will be a short delay.');
  writeln('Activate other X-window (Amiga Screen) and always press a key');
  writeln('to see what is going on');

  i := 0;
  writeln('Creating behind-layer ',i,'.');
  DOSDelay(DELAYTIME);
  layers[i] := CreateBehindLayer(@screen^.LayerInfo, Screen^.RastPort.Bitmap,10,10,100,100,LAYERSMART,nil);
  DoFrame(layers[i]);

  inc(i);
  writeln('Creating behind-layer ',i,'.');
  DOSDelay(DELAYTIME);
  layers[i] := CreateBehindLayer(@screen^.LayerInfo, Screen^.RastPort.Bitmap,50,50,120,120,LAYERSMART,nil);
  DoFrame(layers[i]);

  inc(i);
  writeln('Creating behind-layer ',i,'.');
  DOSDelay(DELAYTIME);
  layers[i] := CreateBehindLayer(@screen^.LayerInfo, Screen^.RastPort.Bitmap,70,30,140,90,LAYERSMART,nil);
  DoFrame(layers[i]);

  inc(i);
  writeln('Creating behind-layer ',i,'.');
  DOSDelay(DELAYTIME);
  layers[i] := CreateBehindLayer(@screen^.LayerInfo, Screen^.RastPort.Bitmap,20,20,150,60,LAYERSMART,nil);
  DoFrame(layers[i]);


  i := 2;
  writeln('Moving layer ',i,' in front of all other layers.');
  DOSDelay(DELAYTIME);
  UpFrontLayer(0, Layers[i]);

  writeln('Moving layer ',3,' in front of layer ',0);
  DOSDelay(DELAYTIME);
  MoveLayerInFrontOf(Layers[3], layers[0]);

  writeln('Moving layer ',0,' in front of layer ',3);
  DOSDelay(DELAYTIME);
  MoveLayerInFrontOf(Layers[0], layers[3]);

  i := 1;
  writeln('Moving layer ',i,' in front of all other layers.');
  DOSDelay(DELAYTIME);
  UpFrontLayer(0, Layers[i]);

  i := 0;
  writeln('Moving layer ',i,' in front of all other layers.');
  DOSDelay(DELAYTIME);
  UpFrontLayer(0, Layers[i]);

  i := 1;
  writeln('Moving layer ',i,' behind all other layers.');
  DOSDelay(DELAYTIME);
  BehindLayer(0, Layers[i]);

  for i := 0 to 9 do
    if (layers[i] <> nil) then
    begin
      writeln('Destroying layer ',i,'.');
      DOSDelay(DELAYTIME);
      DeleteLayer(0, layers[i]);
      Layers[i] := nil;
    end;
  writeln('End of demo .');
end;


procedure DoDemoC;
var i: integer;
begin
  writeln('generating a few layers');
  DoGenerateLayers2;

  if (layers[1] <> nil) then
  begin
    writeln('Moving layer 1...');
    DOSDelay(30);
    i := 50;
    while (i>0) and (LTrue = MoveLayer(0, layers[1], 1, 1))
      do dec(i);
  end;

  if (layers[2] <> nil) then
  begin
    writeln('Moving layer 2...');
    DOSDelay(30);
    i := 50;
    while (i>0) and (LTrue = MoveLayer(0, layers[1], 2, -1))
      do dec(i);
  end;

  if (layers[3] <> nil) then
  begin
    writeln('Moving layer 3...');
    DOSDelay(30);
    i := 50;
    while (i>0) and (LTrue = MoveLayer(0, layers[1], 1, 3))
      do dec(i);
  end;

  if (layers[0] <> nil) then
  begin
    writeln('Moving layer 0...');
    DOSDelay(30);
    i := 150;
    while (i>0) and (LTrue = MoveLayer(0, layers[1], 0, 1))
      do dec(i);
  end;

  writeln('Deleting all visible layers!');
  i := 0;
  while i < 10 do
  begin
    if layers[i] <> nil then deletelayer(0,layers[i]);
    layers[i] := nil;
    inc(i);
  end;
end;


procedure DoDemoD;
var i: integer; c: integer; sb: pBitMap;
begin
  writeln('Deleting all previously generated layers...');
  for i := 0 to 9 do
  begin
    if (layers[i] <> nil) then
    begin
      DeleteLayer(0, layers[i]);
      layers[i] := nil;
    end;
  end;

  i := 0;

  writeln('Creating 4 superbitmap layers');

  sb := AllocBitmap(91,91,1,BMF_CLEAR, nil);
  layers[0] := CreateUpFrontLayer(@screen^.LayerInfo, Screen^.RastPort.Bitmap, 10, 10,100,100,LAYERSMART or LAYERSUPER, sb);
  DoFrame(layers[0]);

  sb := AllocBitmap(71,71,1,BMF_CLEAR, nil);
  layers[1] := CreateUpFrontLayer(@screen^.LayerInfo, Screen^.RastPort.Bitmap, 50, 50,120,120,LAYERSMART or LAYERSUPER, sb);
  DoFrame(layers[1]);

  sb := AllocBitmap(71,61,1,BMF_CLEAR, nil);
  layers[2] := CreateUpFrontLayer(@screen^.LayerInfo, Screen^.RastPort.Bitmap, 70, 30,140, 90,LAYERSMART or LAYERSUPER, sb);
  DoFrame(layers[2]);

  sb := AllocBitmap(131,41,1,BMF_CLEAR, nil);
  layers[3] := CreateUpFrontLayer(@screen^.LayerInfo, Screen^.RastPort.Bitmap, 20, 20,150, 60,LAYERSMART or LAYERSUPER, sb);
  DoFrame(layers[3]);

  writeln('Resizing layer 4');
  DOSDelay(30);
  SizeLayer(0, layers[3], -80, -10);
  // This leaves width = 51, height 31 //
  writeln('Scrolling layer 4');
  DOSDelay(30);
  c := 0;
  while (c < 80) do
  begin
    inc(c);
    DOSDelay(5);
    ScrollLayer(0, layers[3], 1, 0);
  end;

  c := 0;
  while (c < 10) do
  begin
    inc(c);
    DOSDelay(5);
    ScrollLayer(0, layers[3], 0, 1);
  end;

  c := 0;
  while (c < 10) do
  begin
    inc(c);
    DOSDelay(5);
    ScrollLayer(0, layers[3], -8, -1);
  end;

  writeln('Resizing layer 4 to its full size');
  DOSDelay(30);
  SizeLayer(0, layers[3], 80, 10);

  writeln('Resizing layer 1');
  SizeLayer(0, layers[0], -50, -50);
  // This leaves width = 41, height 41 //
  writeln('Scrolling layer 1');
  DOSDelay(30);

  c := 0;
  while (c < 41) do
  begin
    inc(c);
    DOSDelay(5);
    ScrollLayer(0, layers[0], 1, 0);
  end;

  c := 0;
  while (c < 41) do
  begin
    inc(c);
    DOSDelay(5);
    ScrollLayer(0, layers[0], 0, 1);
  end;

  c := 0;
  while (c < 41) do
  begin
    inc(c);
    DOSDelay(5);
    ScrollLayer(0, layers[0], -1, -1);
  end;

  writeln('Resizing layer 1 to its full size');
  DOSDelay(30);
  SizeLayer(0, layers[0], 50, 50);

  writeln('Shuffling layers...');
  UpFrontLayer(0, Layers[0]);
  DOSDelay(20);
  UpFrontLayer(0, Layers[1]);
  DOSDelay(20);
  UpFrontLayer(0, Layers[2]);
  DOSDelay(20);
  UpFrontLayer(0, Layers[3]);
  DOSDelay(20);

  BehindLayer(0, Layers[2]);
  DOSDelay(20);
  BehindLayer(0, Layers[1]);
  DOSDelay(20);
  BehindLayer(0, Layers[0]);

  writeln('Inviting a few smart friends...');
  DoGenerateLayers3;
  writeln('Moving the layers...');
  c := 0;
  while (c < 40) do
  begin
    MoveLayer(0, layers[4], -1, -1);
    MoveLayer(0, layers[0],  1,  2);
    MoveLayer(0, layers[2],  2,  1);
    MoveLayer(0, layers[5], -2,  0);
    inc(c);
  end;

  c := 0;
  while (c < 30) do
  begin
    MoveLayer(0, layers[4], -1, -1);
    MoveLayer(0, layers[5], -1,  0);
    MoveLayer(0, layers[3],  3,  2);
    MoveSizeLayer(layers[2], 2,  -1, -1, -1);
    inc(c);
  end;

  c := 0;
  while (c < 30) do
  begin
    MoveSizeLayer(layers[2], -2,  1,  1,  1);
    MoveSizeLayer(layers[1],  2,  0, -1, -1);
    MoveLayer(0, layers[5],  2,  1);
    inc(c);
  end;

  c := 0;
  while (c < 30) do
  begin
    MoveSizeLayer(layers[1], -1, -1,  1,  1);
    inc(c);
  end;

  writeln('Deleting the layers...');
  i := 0;
  while (i < 8) do
  begin
    while ((layers[i]^.bounds.MaxX - layers[i]^.bounds.MinX) >= 1) and
          ((layers[i]^.bounds.MaxY - layers[i]^.bounds.MinY) >= 1) do
    begin
      MoveSizeLayer(layers[i], 2, 0, -1, -1);
    end;
    DeleteLayer(0, Layers[i]);
    layers[i] := nil;
    inc(i);
  end;
end;


procedure DoDumpCliprects;
var
  i  : integer;
  CR : pClipRect;
  c  : Integer;
begin
  write('Dump ClipRects of which layer? ');
//  readln(
  read(i);
  if (i < 0) or (i > 9) or (layers[i] = nil) then
  begin
    writeln('No such layer!');
    exit;
  end;

  write('Layer at ',IntToHex(QWord(layers[i]),8),' is a ');
       if (0 <> (layers[i]^.Flags and LAYERSIMPLE)) then writeln('simple layer')
  else if (0 <> (layers[i]^.Flags and LAYERSUPER))  then writeln('superbitmap layer')
  else                                                   writeln('smart layer');

  c := 1;
  CR := layers[i]^.ClipRect;
  while CR <> nil do
  begin
    writeln('CR #',c);

    writeln('Bounds: (',CR^.bounds.MinX,',',CR^.bounds.MinY,')-(',CR^.bounds.MaxX,',',CR^.bounds.MaxY,')');
    if (nil <> CR^.lobs)
    then writeln('This cliprect is hidden by layer ',IntToHex(QWord(CR^.lobs),8),' !')
    else writeln('This cliprect is visible!');
    inc(c);
    CR := CR^.Next;
  end;
  writeln('----------------------------------------------');
end;


procedure DoAll;
var
  buf: string;
  i : integer;
begin
  for i := 0 to 9 do layers[i] := nil;

  while true do
  begin
    write('> ');
    readln(buf);

    if (0 = comparetext(buf, 'quit')) then
    begin
      DoFreelayers;
      break;
    end
    else if (0 = comparetext(buf, 'help')) then
    begin
      writeln('quit help createupfrontlayer [cul] createbehindlayer [cbl] deletelayer [dl]');
      writeln('behindlayerupfrontlayer [ul] movelayerinfrontof [mlio]');
      writeln('movelayer [ml] movesizelayer [msl] sizelayer [sl] scrollayer [scl]');
      writeln('motion [mot] DumpCliprects [dc] ');
      writeln('Frame [F]  DemoA DemoB DemoC DemoD');
      writeln('Generate a few layers: [gl1,gl2,gl3,gl4]');
    end
    else if (0 = comparetext(buf, 'createupfrontlayer')) or (0= Comparetext(buf, 'cul')) then
    begin
      DoCreateupfrontlayer();
    end
    else if (0 = comparetext(buf, 'createbehindlayer')) or (0= Comparetext(buf, 'cbl')) then
    begin
      DoCreatebehindlayer;
    end
    else if (0 = comparetext(buf, 'deletelayer')) or (0= Comparetext(buf, 'dl')) then
    begin
      DoDeletelayer;
    end
    else if (0 = comparetext(buf, 'behindlayer')) or (0= Comparetext(buf, 'bl')) then
    begin
      DoBehindlayer;
    end
    else if (0 = comparetext(buf, 'upfrontlayer')) or (0= Comparetext(buf, 'ul')) then
    begin
      DoUpfrontlayer;
    end
    else if (0 = comparetext(buf, 'movelayerinfrontof')) or (0= Comparetext(buf, 'mlio')) then
    begin
      DoMovelayerinfrontof;
    end
    else if (0 = comparetext(buf, 'movelayer')) or (0= Comparetext(buf, 'ml')) then
    begin
      DoMovelayer;
    end
    else if (0 = comparetext(buf, 'movesizelayer')) or (0= Comparetext(buf, 'msl')) then
    begin
      DoMovesizelayer;
    end
    else if (0 = comparetext(buf, 'sizelayer')) or (0= Comparetext(buf, 'sl1')) then
    begin
      DoSizelayer;
    end
    else if (0 = comparetext(buf, 'scrolllayer')) or (0= Comparetext(buf, 'scl')) then
    begin
      DoScrolllayer;
    end
    else if (0 = comparetext(buf, 'motion')) or (0= Comparetext(buf, 'mot')) then
    begin
      DoMotion;
    end
    else if (0 = comparetext(buf, 'Frame')) or (0= Comparetext(buf, 'F')) then
    begin
      DoFrame;
    end
    else if (0 = comparetext(buf, 'DemoA')) then
    begin
      DoDemoA;
    end
    else if (0 = comparetext(buf, 'DemoB')) then
    begin
      DoDemoB;
    end
    else if (0 = comparetext(buf, 'DemoC')) then
    begin
      DoDemoC;
    end
    else if (0 = comparetext(buf, 'DemoD')) then
    begin
      DoDemoD;
    end
    else if (0 = comparetext(buf, 'gl1')) then
    begin
      DoGenerateLayers1;
    end
    else if (0 = comparetext(buf, 'gl2')) then
    begin
      DoGenerateLayers2;
    end
    else if (0 = comparetext(buf, 'gl3')) then
    begin
      DoGenerateLayers3;
    end
    else if (0 = comparetext(buf, 'gl4')) then
    begin
      DoGenerateLayers4;
    end
    else if (0 = comparetext(buf, 'dc')) then
    begin
      DoDumpCliprects;
    end
    else
      writeln('Unknown command. Try "help".');
  end;

end;



Begin
  ExitCode := Main;
End.

Example: clippingtest

A collection of layers functions that focuses on clipping.

Original c-source [2]

Program ClippingTest;

{$MODE OBJFPC}{$H+}

Uses
  exec, AGraphics, Intuition, AmigaDos, Layers, Utility;


const
  ARG_TEMPLATE      = 'SIMPLE/S';

  ARG_SIMPLE        = 0;
  NUM_ARGS          = 1;


var
  IntuitionBase     : pIntuitionBase;
  GfxBase	    : pGfxBase;
  LayersBase	    : pLibrary;

  win 	            : pWIndow;
  rp  	            : pRastPort;
  lay 	            : pLayer;

  myargs            : pRDArgs;
  args              : array[0..NUM_ARGS-1] of UIntPtr;
  s                 : array[0..255] of char;



procedure Cleanup(msg: pChar);
begin
  if (msg           <> nil) then
  begin
    Writeln('Clippingtest: ',msg);
  end;

  if (win           <> nil) then CloseWindow(Win);

  if (myArgs        <> nil) then FreeArgs(myargs);

  if (LayersBase    <> nil) then CloseLibrary(LayersBase);
  if (gfxBase       <> nil) then CloseLibrary(pLibrary(GfxBase));
  if (IntuitionBase <> nil) then CloseLibrary(pLibrary(IntuitionBase));

  halt(0);
end;


procedure DosError;
begin
  Fault(IoErr, nil, s, 255);
  Cleanup(s);
end;


Procedure OpenLibs;
begin
  IntuitionBase := pIntuitionBase(OpenLibrary('intuition.library', 39));
  If not(intuitionbase <> nil) then
  begin
    Cleanup('Can''t open intuition.library v39!');
  end;

  GfxBase := pGfxBase(OpenLibrary('graphics.library', 39));
  If not(intuitionbase <> nil) then
  begin
    Cleanup('Can''t open graphics.library v39!');
  end;

  LayersBase := OpenLibrary('layers.library', 39);
  If not(LayersBase <> nil) then
  begin
    Cleanup('Can''t open layers.library v39!');
  end;
end;


procedure GetArguments;
begin
  myargs := ReadArgs(ARG_TEMPLATE, args, nil);
  if not (myargs <> nil) then
  begin
    DosERROR;
  end;
end;


procedure MakeWin;
Var OptionalTag : LongWord;
begin
  If (args[ARG_SIMPLE] <> 0) then OptionalTag := WA_SimpleRefresh else Optionaltag := TAG_IGNORE;

  win := OpenWindowTags(nil,
  [
    LongInt(WA_LEFT)         ,  10,
    LongInt(WA_Top)          ,  20,
    LongInt(WA_Width)        , 200,
    LongInt(WA_Height)       , 200,
    LongInt(WA_Title)        , pChar('Press key to flip color!'),
    LongInt(WA_CloseGadget)  , LTrue,
    LongInt(WA_DepthGadget)  , LTrue,
    LongInt(WA_DragBar)      , LTrue,
    LongInt(WA_Activate)     , LTrue,
    LongInt(OptionalTag)     , LTrue,
    LongInt(WA_IDCMP)        , (IDCMP_CLOSEWINDOW or IDCMP_VANILLAKEY or IDCMP_REFRESHWINDOW),
    TAG_DONE
  ]);

  if not(win <> nil) then Cleanup('Can''t open window');

  rp  := win^.RPort;
  lay := win^.WLayer;
end;



Function AssignVar(Var Variable1: Pointer; Variable2: Pointer): Pointer; overload;
begin
  Variable1 := Variable2;
  Result := Variable1;
end;

Function AssignVar(Var Variable1: LongInt; Variable2: LongInt): LongInt; overload;
begin
  Variable1 := Variable2;
  Result := Variable1;
end;



procedure Action;
var
  clip, oldclip: pRegion;
  rect1, rect2 : TRectangle;
  msg : pIntuiMessage;
  col : SmallInt = 1;
  installed : LongBool = True;
  quitme    : LongBool = False;
begin
  rect1.MinX :=  20; rect1.MinY :=  80;
  rect1.MaxX := 180; rect1.MaxY := 120;
  rect2.MinX :=  80; rect2.MinY :=  20;
  rect2.MaxX := 120; rect2.MaxY := 180;

  Move(rp, 20, 20);
  Draw(rp, 180, 180);

  clip := NewRegion;
  if not(clip <> NewRegion) then Cleanup('Can''t create clip regio!');

  OrRectRegion(clip, @rect1);
  OrRectRegion(clip, @rect2);

  oldclip := InstallClipRegion(lay, clip);

  SetAPen(rp, col);

  while not (quitme) do
  begin
    WaitPort(win^.UserPort);

    while (AssignVar(msg, GetMsg(win^.UserPort)) <> nil) do
    begin
      Case msg^.IClass of
        IDCMP_CLOSEWINDOW : quitme := true;
        IDCMP_VANILLAKEY  :
        case char(msg^.Code) of
          'c','C' :
            If (installed) then
            begin
              InstallClipRegion(lay, oldClip);
              installed := false;
            end
            else
            begin
              oldclip := InstallClipRegion(lay, clip);
              installed := true;
            end;
          else
          begin
            col := 3 - col;
            SetAPen(rp, col);
            rectFill(rp, 0, 0, 1000, 1000);
          end;
        end; // case vanillakey
        IDCMP_REFRESHWINDOW :
        begin
          BeginRefresh(win);
          SetAPen(rp, col);
          RectFill(rp, 0, 0, 1000, 1000);
          EndRefresh(win, LTrue);
        end;

      end; // case msg^.class
      ReplyMsg(pMessage(msg));
    end;
  end;

  if (installed)
  then InstallClipRegion(lay, oldclip);
  DisposeRegion(clip);
end;


Function Main: Integer;
begin
  OpenLibs;
  GetArguments;
  MakeWin;
  Action;
  cleanup(nil);
  exit(0);
end;


Begin
  exitcode := Main;
End.

Example: CRList

ClipRects and their usage.

Original c-source [3]

Program CRList;

{$MODE OBJFPC}{$H+}

uses
  exec, AGraphics, Intuition, AmigaDos, Layers, Utility, Sysutils, StrUtils, Math;



Type
  pBackFillMessage = ^TBackFillMessage;
  TBackFillMessage = record
    Layer : pLayer;
    Bounds : TRectangle;
    OffSetX : LongInt;
    OffsetY : LongInt;
  end;

const
  ARG_TEMPLATE = 'FAST=F/S,NUMBERS=N/S,EXTRA/S,HOOK/S';

  ARG_FAST     = 0;
  ARG_NUMBERS  = 1;
  ARG_EXTRA    = 2;
  ARG_HOOK     = 3;
  NUM_ARGS     = 4;

var
  scr               : pScreen;
  win 	            : pWIndow;
  lay 	            : pLayer;

  MyArgs            : pRDArgs;
  Args              : Array[0..NUM_ARGS-1] of UIntPtr;
  s                 : array[0..255] of char;
  exit_buf          : jmp_buf;



Function CloneRastPort(rp: pRastPort): pRastPort;
var newRP : pRastPort;
begin
  newRP := AllocMem(sizeof(TRastPort), MEMF_ANY);

  if (newRP <> nil) then CopyMem(rp, newRP, sizeof(TRastPort));
  result := newRP;
end;


procedure Cleanup(msg: pChar);
var rc : SmallInt;
begin
  if (msg <> nil) then
  begin
    Writeln('crlist: ',msg);
    rc := RETURN_WARN;
  end
  else
  begin
    rc := RETURN_OK;
  end;

  if (myArgs <> nil) then FreeArgs(myargs);

  if (RC <> RETURN_OK) then longjmp(exit_buf, rc);//longjump(exit_buf, rc);
end;


procedure GetArguments;
begin
  myargs := ReadArgs(ARG_TEMPLATE, args, nil);
  if not (myargs <> nil) then
  begin
    Fault(IoErr,nil,s,255);
    Cleanup(s);
  end;
end;


procedure Show(rp: pRastPort; cr: pClipRect);
var
  x,y,i, count: SmallInt;
  s1, s2 : string;
  w,   h : LongWord;
  q      : longint;
begin
  count := 0;

  while (cr <> nil) do
  begin
    s1 := ifthen(cr^.lobs <> nil, 'HIDDEN ', '');
    s2 := ifthen(cr^.BitMap <> nil, 'BITMAP', '');
    Writeln(Format('#%d (%4d, %4d) - (%4d, %4d)  size: %4d x %4d  %s%s',
    [
      count,
      cr^.bounds.MinX,
      cr^.bounds.MinY,
      cr^.bounds.MaxX,
      cr^.bounds.MaxY,

      cr^.bounds.MaxX - cr^.bounds.MinX + 1,
      cr^.bounds.MaxY - cr^.bounds.MinY + 1,
      s1,
      s2
    ]));


    if (cr^.BitMap <> nil) and (Args[ARG_EXTRA] <> 0) then
    begin
      w := GetBitMapAttr(cr^.BitMap, BMA_WIDTH);
      h := GetBitMapAttr(cr^.BitMap, BMA_HEIGHT);

      writeln(Format('  -> BitMap %p, size %d x %d',[ cr^.Bitmap, w, h]));
    end;

    q := ifthen(args[ARG_FAST] <> 0, 1, 8);
    for i := 0 to q-1 do
    begin
      SetAPen(rp, 1 + (i and 1));
      RectFill(rp, cr^.bounds.MinX, cr^.bounds.MinY, cr^.bounds.MaxX, cr^.bounds.MinY);
      RectFill(rp, cr^.bounds.MaxX, cr^.bounds.MinY, cr^.bounds.MaxX, cr^.bounds.MaxY);
      RectFill(rp, cr^.bounds.MinX, cr^.bounds.MaxY, cr^.bounds.MaxX, cr^.bounds.MaxY);
      RectFill(rp, cr^.bounds.MinX, cr^.bounds.MinY, cr^.bounds.MinX, cr^.bounds.MaxY);

      if not (Args[ARG_FAST] <> 0) then DOSDelay(10);
    end;


    if (Args[ARG_NUMBERS] <> 0) then
    begin
      s1 := '';
      WriteStr(s1, count);
      s := s1;
      i := TextLength(rp, s, strlen(s));

      x := (cr^.bounds.MinX + cr^.bounds.MaxX - i) div 2;
      y := (cr^.bounds.MinY + cr^.bounds.MaxY - rp^.TxHeight) div 2;


      if (x < 0) then
      begin
        x := 0;
      end
      else if (x >= scr^.Width - 1) then
      begin
        x := scr^.Width - i - 1;
      end;

      if (y < 0) then
      begin
        y := 0;
      end
      else if (y >= scr^.Height - rp^.TxHeight) then
      begin
        y := scr^.Height - rp^.TxHeight - 1;
      end;

      i := length(s);

      SetAPen(rp, 1);
      Move(rp, x + 1, y + 1 + rp^.TxBaseLine);
      GText(rp, s, i);

      SetAPen(rp, 2);
      Move(rp, x, y + rp^.TxBaseLine);
      GText(rp, s, i);
    end;
    cr := cr^.Next;
  end;
end;


Procedure ClipRectHook( h : pHook; rp: pRastPort; msg: pBackFillMessage); cdecl;
begin
  writeln(Format('# Rastport 0x%p, BitMap 0x%p, Layer 0x%p',[rp, rp^.BitMap, msg^.Layer]));
  writeln(Format('  -> (%4d, %4d) - (%4d, %4d), offset (%4d, %4d)',
  [
    msg^.Bounds.MinX,
    msg^.Bounds.MinY,
    msg^.Bounds.MaxX,
    msg^.Bounds.MaxY,
    msg^.OffsetX,
    msg^.OffsetY
  ]));
end;

var
  crHook : THook = (
    h_minNode   :
    (
      mln_Succ  : nil;
      mln_Pred  : nil
    );
    h_Entry     : 0;
    h_SubEntry  : 0; 
    h_Data     : nil;
  );


procedure Action;
var
//  intuitionBase : pIntuitionBase;
  rp            : pRastPort;
  rect : TRectangle;
begin
  PutStr('Activate the window whose cliprects you want to see.'#13#10);
  PutStr('You have 3 seconds of time!'#13#10#13#10);

  DOSDelay(3*50);

  win := pIntuitionBase(IntuitionBase)^.ActiveWindow;

  if not(win <> nil) then Cleanup('No active window');

  scr := win^.WScreen;

  rp := CloneRastPort(@scr^.RastPort);
  if not(rp <> nil) then
  begin
    Cleanup('Can''t clone screen rastport');
  end;
  SetDrMd(rp, JAM1);

  lay := win^.WLayer;

  show(rp, lay^.ClipRect);
  if (lay^._cliprects <> nil) then
  begin
    PutStr('This window has ClipRegion installed. Listing hidden cliprects...'#13#10);
    Show(rp, lay^._cliprects);
  end;

  if (Args[ARG_HOOK] <> 0) then
  begin
    rect.MinX := 20;
    rect.MinY := 20;
    rect.MaxX := win^.Width  - 40 + 1;
    rect.MaxY := win^.Height - 40 + 1;

    writeln(Format('Running ClipRectHook on window''s Rastport 0x%p, BitMap 0x%p, layer 0x%p',
    [
      win^.RPort,
      pRastPort(win^.RPort)^.BitMap,
      lay
    ]));
    crHook.h_entry := LongWord(@ClipRectHook);
    DoHookClipRects(@CRHook, win^.RPort, @Rect);
  end;

  freeRastPort(rp);
end;


Function Main: Integer;
var rc: Integer;
begin
  rc := SetJmp(exit_buf) ;// SetJump(exit_buf) ;
  if rc <> 0 then halt(rc);

  GetArguments;
  Action;
  CleanUp(nil);

  result := 0;
end;


Begin
  exitcode := Main;
end.

Example: DamageList

Original c-source [4]

Program DamageList;

{$MODE OBJFPC}{$H+}

uses
  exec, AGraphics, Intuition, AmigaDos, Layers, sysutils, math;

const
  ARG_TEMPLATE = 'FAST=F/S,NUMBERS=N/S,RECTFILL=RF/S';

  ARG_FAST     = 0;
  ARG_NUMBERS  = 1;
  ARG_RECTFILL = 2;
  NUM_ARGS     = 3;


var
//  IntuitionBase     : pIntuitionBase;

  scr               : pScreen;
  win 	            : pWIndow;
  lay 	            : pLayer;
  MyArgs            : pRDArgs;
  Args              : Array[0..NUM_ARGS-1] of UIntPtr;
  s                 : array[0..255] of char;
  exit_buf          : jmp_buf;



Function CloneRastPort(rp: pRastPort): pRastPort;
var newRP : pRastPort;
begin
  newRP := AllocMem(sizeof(TRastPort), MEMF_ANY);

  if (newRP <> nil) then CopyMem(rp, newRP, sizeof(TRastPort));
  result := newRP;
end;



procedure Cleanup(msg: pChar);
var rc : SmallInt;
begin
  if (msg <> nil) then
  begin
    Writeln('damagelist: ',msg);
    rc := RETURN_WARN;
  end
  else
  begin
    rc := RETURN_OK;
  end;

  if (MyArgs <> nil) then FreeArgs(MyArgs);

  if (rc <> RETURN_OK) then longjmp(exit_buf, rc);
end;



procedure GetArguments;
begin
  myargs := ReadArgs(ARG_TEMPLATE, Args, nil);
  if not (MyArgs <> nil) then
  begin
    Fault(IoErr,nil,s,255);
    Cleanup(s);
  end;
end;



procedure Action;
var
  rp   : pRastPort;
  dr   : pRegion;
  rr   : pRegionRectangle;
  x,y,x1,y1,x2,y2,i, count: SmallInt; // = 0;
  q : integer;
  s1 : String;
//  rect : TRectangle;
begin
  count := 0;

  PutStr('Activate the window whose damagelist you want to see.'#13#10);
  PutStr('You have 3 seconds of time!'#13#10#13#10);

  DOSDelay(3*50);

  win := pIntuitionBase(IntuitionBase)^.ActiveWindow;
  if not(win <> nil) then Cleanup('No active window');

  scr := win^.WScreen;

  lay := win^.WLayer;

  dr := lay^.DamageList;
  if not(dr <> nil) then Cleanup('Layer does not have a damagelist!');
  rr := dr^.RegionRectangle;
  if not(rr <> nil) then Cleanup('Damagelist is empty!');

  rp := CloneRastPort(@pScreen(win^.WScreen)^.RastPort);
  if not(rp <> nil) then
  begin
    Cleanup('Can''t clone screen rastport');
  end;
  SetDrMd(rp, JAM1);


  while (rr <> nil) do
  begin
    x1 := lay^.bounds.MinX + dr^.bounds.MinX + rr^.bounds.MinX;
    y1 := lay^.bounds.MinY + dr^.bounds.MinY + rr^.bounds.MinY;
    x2 := lay^.bounds.MinX + dr^.bounds.MinX + rr^.bounds.MaxX;
    y2 := lay^.bounds.MinY + dr^.bounds.MinY + rr^.bounds.MaxY;


    writeln
    (
      Format
      ('#%4d (%4d,%4d) - (%4d,%4d) size: %4d x %4d',
      [
      count,
      x1,
      y1,
      x2,
      y2,
      x2 - x1 + 1,
      y2 - y1 + 1
      ]
      )

    );

    inc(count);

    q := ifthen(ARGS[ARG_FAST] <> 0, 1, 8);

    for i := 0 to q-1 do
    begin
      SetAPen(rp,1 + (i and 1));
      if (Args[ARG_RECTFILL] <> 0) then
      begin
        RectFill(rp,x1,y1,x2,y2);
      end
      else
      begin
        RectFill(rp,x1,y1,x2,y1);
        RectFill(rp,x2,y1,x2,y2);
        RectFill(rp,x1,y2,x2,y2);
        RectFill(rp,x1,y1,x1,y2);
      end;

      if not(Args[ARG_FAST] <> 0) then DOSDelay(10);
    end;

    if (Args[ARG_NUMBERS] <> 0) then
    begin
      s1 := '';

      WriteStr(s1, count);
      s := s1;
      i := TextLength(rp, s, strlen(s));

      x := (x1 + x2 - i) div 2;
      y := (y1 + y2 - rp^.TxHeight) div 2;

      if (x < 0) then
      begin
        x := 0;
      end
      else if (x >= scr^.Width - i) then
      begin
        x := scr^.Width - i - 1;
      end;

      if (y < 0) then
      begin
        y := 0;
      end
      else if (y >= scr^.Height - rp^.TxHeight) then
      begin
        y := scr^.Height - rp^.TxHeight - 1;
      end;

      i := length(s);

      SetAPen(rp, 1);
      Move(rp, x + 1, y + 1 + rp^.TxBaseLine);
      GText(rp, s, i);

      SetAPen(rp, 2);
      Move(rp, x, y + rp^.TxBaseLine);
      GText(rp, s, i);
    end;

    rr := rr^.Next;
  end;

  freeRastPort(rp);
end;



Function Main: Integer;
var rc: Integer;
begin
  rc := setjmp(exit_buf);

  if (rc <> 0)
    then exit(rc);
  GetArguments;
  Action;
  Cleanup(nil);

  result := 0;
end;



begin
  writeln('enter');
  exitcode := Main;
  writeln('leave');
end.

Example: Lens

Shows how to use a ScaleLayer() callback hook.

Original c-source [5]

Program Lens;

{$MODE OBJFPC}{$H+}

uses
  exec, agraphics, layers, intuition, amigados, utility, chelpers;


Var
  IntuitionBase : pIntuitionBase;
  GfxBase       : pGfxBase;
  LayersBase    : pLibrary;

  scr           : pScreen;
  win           : pWindow;
  dri           : pDrawInfo;
  ScaleBitmap   : pBitmap;

  follow        : Boolean = False;
  do_Lens       : Boolean = False;


Type
  pLensParam  = ^TLensParam;
  TLensParam  = record
    win : pWindow;
    dx  : LongInt;
    dy  : LongInt;
  end;


procedure Cleanup(msg: pChar);
var
  rc : SmallInt;
begin
  if (msg <> nil) then
  begin
    Writeln('lens: ',msg);
    rc := RETURN_WARN;
  end
  else
  begin
    rc := RETURN_OK;
  end;

  if (scalebitmap <> nil) then FreeBitmap(scalebitmap);

  if (win <> nil) then CloseWindow(win);

  if (dri <> nil) then  FreeScreenDrawInfo(scr, dri);
  UnlockPubScreen(nil, scr);

  if (LayersBase    <> nil) then CloseLibrary(LayersBase);
  if (GfxBase       <> nil) Then CloseLibrary(pLibrary(GfxBase));
  if (IntuitionBase <> nil) then CloseLibrary(pLibrary(IntuitionBase));

  halt(rc);
end;


Procedure OpenLibs;
begin
  IntuitionBase := pIntuitionBase(OpenLibrary('intuition.library', 39));
  If not(IntuitionBase <> nil) then
  begin
    Cleanup('Can''t open intuition.library v39!');
  end;

  GfxBase := pGfxBase(OpenLibrary('graphics.library', 39));
  If not(GfxBase <> nil) then
  begin
    Cleanup('Can''t open graphics.library v39!');
  end;

  LayersBase := OpenLibrary('layers.library', 39);
  If not(LayersBase <> nil) then
  begin
    Cleanup('Can''t open layers.library v39!');
  end;
end;


procedure GetVisual;
begin
  scr := LockPubScreen(nil);
  if not(scr <> nil) then
  begin
    Cleanup('Can''t lock pub screen!');
  end;

  dri := GetScreenDrawInfo(scr);
  if not (dri <> nil) then
  begin
    Cleanup('Can''t get drawinfo');
  end;
end;


//
//  The ScaleLayer callback is doing the actual work of
//  scaling the layer
//
Procedure LensCallback(hook: pHook; l: pLayer; cplm: pCollectPixelsLayerMsg); cdecl;
var
  lp  : pLensParam;
  bsa : TBitScaleArgs;
begin
  lp := pLensParam(hook^.h_Data);

  if (nil <> cplm^.bm) then
  begin
    if (false = do_lens) then
    begin
      // *
      // *  Does a 1:1 copying
      // *
      BltBitMapRastPort
      (
        cplm^.bm,
        cplm^.xSrc,
        cplm^.ySrc,
        win^.RPort,
        cplm^.xDest - win^.LeftEdge - lp^.dx + win^.Width  div 2,
        cplm^.yDest - win^.TopEdge  - lp^.dy + win^.Height div 2,
        cplm^.width,
        cplm^.height,
        cplm^.minterm
      );
    end
    else
    begin
      // *
      // * This is just a hack for now...
      // * Need to adjust the destination x/y coordinates
      // * in accordance to the source x/y coordinates taken
      // * from the absolute coordinates of the source.
      // *
      bsa.bsa_SrcX        := cplm^.xSrc;
      bsa.bsa_SrcY        := cplm^.ySrc;
      bsa.bsa_SrcWidth    := cplm^.width;
      bsa.bsa_SrcHeight   := cplm^.height;
      bsa.bsa_DestX       := 0;
      bsa.bsa_DestY       := 0;
      bsa.bsa_DestWidth   := cplm^.width*2;
      bsa.bsa_DestHeight  := cplm^.height*2;
      bsa.bsa_XSrcFactor  := cplm^.width;
      bsa.bsa_XDestFactor := cplm^.width*2;
      bsa.bsa_YSrcFactor  := cplm^.height;
      bsa.bsa_YDestFactor := cplm^.height*2;
      bsa.bsa_SrcBitMap   := cplm^.bm;
      bsa.bsa_DestBitMap  := scalebitmap;
      BitMapScale(@bsa);

      // *
      // * Display the scaled content.
      // *
      BltBitMapRastPort(
        scalebitmap,
        bsa.bsa_DestX,
        bsa.bsa_DestY,
        win^.RPort,
        bsa.bsa_DestX,
        bsa.bsa_DestY,
        cplm^.width*2,  //bsa.bsa_DestWidth,
        cplm^.height*2, //bsa.bsa_DestHeight,
        cplm^.minterm
      );

    end;
  end;
end;


procedure DoLens(win : pWindow; dx: LongInt; dy: LongInt);
var
  r       : pRegion;
  rect    : TRectangle;
  l       : pLayer;
  h       : THook;
  lp      : TLensParam;
  QWidth,
  QHeight,
  HWidth,
  HHeight : LongWord;
begin
  r := NewRegion;
  l := pRastPort(win^.RPort)^.Layer;
  lp.win := win;
  lp.dx  := dx;
  lp.dy  := dy;

  QWidth  := win^.Width  div 4;
  QHeight := win^.Height div 4;
  HWidth  := win^.Width  div 2;
  HHeight := win^.Height div 2;

  h.h_Entry := UIntPtr(@LensCallBack); // (IPTR (*)())LensCallback;
  h.h_Data  := @lp; //(void *)&lp;

  rect.MinX := dx + win^.LeftEdge + QWidth  - HWidth;
  rect.MinY := dy + win^.TopEdge  + QHeight - HHeight;
  rect.MaxX := dx + win^.LeftEdge + win^.Width  - 1 - QWidth - HWidth;
  rect.MaxY := dy + win^.TopEdge  + win^.Height - 1 - QHeight- HHeight;

  if (rect.MinX < 0)
    then rect.MinX := 0;

  if (rect.MinY < 0)
    then rect.MinY := 0;

  OrRectRegion(r, @rect);

  CollectPixelsLayer(l^.back, r, @h);

  DisposeRegion(r);
end;


procedure MakeWin;
begin

  win := OpenWindowTags(nil,
  [
    LongInt(WA_PubScreen)    , scr,
    LongInt(WA_LEFT)         ,  10,
    LongInt(WA_Top)          ,  10,
    LongInt(WA_Width)        , 200,
    LongInt(WA_Height)       , 100,
    LongInt(WA_AutoAdjust)   , LTrue,
    LongInt(WA_SmartRefresh) , LTrue,
    LongInt(WA_CloseGadget)  , LTrue,
    LongInt(WA_DepthGadget)  , LFalse,
    LongInt(WA_DragBar)      , LFalse,
    LongInt(WA_IDCMP)        , (IDCMP_REFRESHWINDOW or IDCMP_MOUSEMOVE or IDCMP_DELTAMOVE or IDCMP_CLOSEWINDOW),
    LongInt(WA_ReportMouse)  , LTrue,
    TAG_DONE
  ]);

  if not(win <> nil) then
  begin
    Cleanup('Can''t open window');
  end;

  ScaleBitmap := AllocBitMap
  (
    win^.width,
    win^.height,
    GetBitMapAttr(pRastPort(win^.rport)^.Bitmap, BMA_DEPTH), BMF_CLEAR,
    scr^.RastPort.BitMap
  );

  DoLens(win, 0, 0);

  ScreenToFront(win^.WScreen);
end;


procedure HandleAll;
var
  msg    : pIntuiMessage;
  quitme : boolean        = false;
begin
  while not(quitme) do
  begin
    WaitPort(win^.UserPort);

    while AssignedVar(msg, pIntuiMessage(GetMsg(win^.UserPort))) do
    begin
      Case msg^.IClass of
        IDCMP_CLOSEWINDOW   : quitme := true;
        IDCMP_REFRESHWINDOW :
        begin
          BeginRefresh(win);
          EndRefresh(win, True);  //           EndRefresh(win, 1);
        end;
        IDCMP_MOUSEMOVE :
        begin
          if win = msg^.IDCMPWINDOW then
          begin
            writeln('mouse move ', msg^.MouseX, '/', msg^.MouseY, '!');
            if follow then
            begin
              MoveWindow(win,
                 win^.MouseX,  // - win^.LeftEdge,
                 win^.MouseY   // - win^.TopEdge
              );
              DoLens(win, 0, 0);
            end
            else
            begin
              //
              // keep window still;
              // this works, but center is a bit off.
              //
              DoLens(win, win^.MouseX, win^.MouseY);
            end;
          end;
        end;
        IDCMP_DELTAMOVE : writeln('delta move!');
      end; // msg.class

      ReplyMsg(pMessage(msg));
    end;
  end;
end;


procedure ParseArgs;
var
  args : array[0..1] of PChar;
  rda  : pRDArgs;
begin
  args[0] := PChar(0);
  args[1] := PChar(0);

  rda := ReadArgs('FOLLOW/S,LENS/S', PUIntPtr(@args), nil);

  if 1 = UIntPtr(args[0]) then
  begin
    follow := true;
  end;

  if 1 = UIntPtr(args[1]) then
  begin
    do_lens := true;
  end;

  if (rda <> nil) then
  begin
    FreeArgs(rda);
  end;
end;


Function Main: Integer;
begin
  ParseArgs;
  OpenLibs;
  GetVisual;
  MakeWin;
  HandleAll;
  Cleanup(nil);
  result := 0;
end;


begin
  exitcode := Main;
end.

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
  tagsarray;


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.).

<?xml version="1.0"?>
<fpdoc-descriptions>
  <package name="arosrtl">
    <module name="layers">
      <element name="LAYERSNAME">
        <short>The disk/memory name of the layers.library.</short>
      </element>
      <element name="LayersBase">
        <short>Placeholder for a pointer to an opened layers.library.</short>
      </element>
      <element name="InitLayers">
        <short>
          <b>OBSOLETE</b> Initialize Layer_Info structure.</short>
        <descr>
          <p>Initializes the supplied Layer_Info, so it's ready for use. Leaves the Layer_Info in an unlocked state.</p>
          <p>
            <b>Notes:</b>
          </p>
          <p>This function is obsolete. Use <link id="NewLayerInfo"/> instead.</p>
        </descr>
        <errors>
          <p>This function is obsolete. Use <link id="NewLayerInfo"/> instead.</p>
        </errors>
        <seealso>
          <link id="NewLayerInfo"/>
        </seealso>
      </element>
      <element name="InitLayers.li">
        <short>Pointer to Layer_Info structure.</short>
      </element>
      <element name="CreateUpfrontLayer">
        <short>Create a new layer on top of existing layers.</short>
      </element>
      <element name="CreateUpfrontLayer.Result">
        <short>Pointer to layer if successful, Nil otherwise.</short>
      </element>
      <element name="CreateUpfrontLayer.li">
        <short>Pointer to LayerInfo structure.</short>
      </element>
      <element name="CreateUpfrontLayer.bm">
        <short>Pointer to common bitmap.</short>
      </element>
      <element name="CreateUpfrontLayer.x0">
        <short>Upper left corner of the layer.</short>
      </element>
      <element name="CreateUpfrontLayer.y0">
        <short>Upper left corner of the layer.</short>
      </element>
      <element name="CreateUpfrontLayer.x1">
        <short>Lower right corner of the layer.</short>
      </element>
      <element name="CreateUpfrontLayer.y1">
        <short>Lower right corner of the layer.</short>
      </element>
      <element name="CreateUpfrontLayer.flags">
        <short>Choose the type of layer by setting some flags.</short>
      </element>
      <element name="CreateUpfrontLayer.bm2">
        <short>Pointer to optional super bitmap.</short>
      </element>
      <element name="CreateBehindLayer">
        <short>Create a new layer behind all existing layers.</short>
        <descr>
          <p>Create a new layer at the given position and with the given size. The new layer will be in front of all other layers. If it is a backdrop layer it will be created in front of all other backdrop layers and behind all non backdrop layers.</p>
        </descr>
      </element>
      <element name="CreateBehindLayer.Result">
        <short>Pointer to the newly created layer. Nil if layer could not be created (Probably out of memory).</short>
      </element>
      <element name="CreateBehindLayer.li">
        <short>Pointer to LayerInfo structure.</short>
      </element>
      <element name="CreateBehindLayer.bm">
        <short>Pointer to common bitmap.</short>
      </element>
      <element name="CreateBehindLayer.x0">
        <short>Upper left corner of the layer.</short>
      </element>
      <element name="CreateBehindLayer.y0">
        <short>Upper left corner of the layer.</short>
      </element>
      <element name="CreateBehindLayer.x1">
        <short>Lower right corner of the layer.</short>
      </element>
      <element name="CreateBehindLayer.y1">
        <short>Lower right corner of the layer.</short>
      </element>
      <element name="CreateBehindLayer.flags">
        <short>Choose the type of layer by setting some flags.</short>
      </element>
      <element name="CreateBehindLayer.bm2">
        <short>Pointer to optional super bitmap.</short>
      </element>
      <element name="UpfrontLayer">
        <short>Put layer in front of all other layers.</short>
        <descr>
          <p>Brings a layer to the front. If this layer is a backdrop layer it is brought in front of all backdrop layers and behind the last non-backdrop layer. By clearing the BACKDROP flag of a layer a backdrop layer can be brought in front of all other layers.</p>
          <p>Parts of a simple layer that become visible are added to the damage list and the REFRESH flag is set.</p>
        </descr>
      </element>
      <element name="UpfrontLayer.Result">
        <short>Returns how function succeeded.</short>
        <descr>
          <p>Returns a boolean state which establishes whether the layer has moved upfront.
</p>
          <p>
            <link id="Exec.LTrue">LTrue</link> - layer was moved.
  
  
            <br/>
            <link id="Exec.LFalse">LFalse</link> - layer could not be moved (probably out of memory).
</p>
        </descr>
      </element>
      <element name="UpfrontLayer.dummy">
        <short>Unused.</short>
      </element>
      <element name="UpfrontLayer.l">
        <short>Pointer to layer.</short>
      </element>
      <element name="BehindLayer">
        <short>Put layer behind other layers.</short>
        <descr>
          <p>If the layer is a backdrop layer it will be moved to the most behind position. If it is a non-backdrop layer it will be moved in front of the first backdrop layer.</p>
          <p>The areas of simple layers, that become visible by moving this layer, are added to the damagelist and the LAYERREFRESH flag is set.</p>
        </descr>
      </element>
      <element name="BehindLayer.Result">
        <descr>
          <p>Returns a boolean state which establishes whether the function was Successful.
</p>
          <p>
            <link id="Exec.LTrue">LTrue</link> - layer was successfully moved
            <br/>
            <link id="Exec.LFalse">LFalse</link> - layer could not be moved (probably out of memory).
</p>
        </descr>
      </element>
      <element name="BehindLayer.dummy">
        <short>Unused.</short>
      </element>
      <element name="BehindLayer.l">
        <short>Pointer to layer.</short>
      </element>
      <element name="MoveLayer">
        <short>Move layer to new position in BitMap.</short>
        <descr>
          <p>Moves the layer to a specified position in the bitmap.</p>
          <p>Parts of simple layers that become visible are added to the damage list and a refresh is triggered.</p>
        </descr>
        <seealso>
          <link id="AGraphics.TLayer"/>
          <link id="AGraphics.TClipRect"/>
        </seealso>
      </element>
      <element name="MoveLayer.Result">
        <descr>
          <p>Returns a boolean state which establishes whether the layer has moved.
</p>
          <p>
            <link id="Exec.LTrue">LTrue</link> - everything went alright.
            <br/>
            <link id="Exec.LFalse">LFalse</link> - an error occured (out of memory).
</p>
        </descr>
      </element>
      <element name="MoveLayer.dummy">
        <short>Unused.</short>
      </element>
      <element name="MoveLayer.l">
        <short>Pointer to layer to be moved.</short>
      </element>
      <element name="MoveLayer.dx">
        <short>Delta to add to current x position.</short>
      </element>
      <element name="MoveLayer.dy">
        <short>Delta to add to current y position</short>
      </element>
      <element name="SizeLayer">
        <short>Change the size of this nonbackdrop layer.</short>
        <descr>
          <p>Resizes the given layer by adding dw to its width and dh to its height.</p>
          <p>If parts of simple layers become visible those parts are added to the damage list and a refresh is triggered for those layers.</p>
          <p>If the new layer is bigger than before the additional parts are added to a damage list if the layer is a non-superbitmap layer. Refresh is also triggered for this layer.</p>
        </descr>
      </element>
      <element name="SizeLayer.Result">
        <descr>
          <p>Returns a boolean state which establishes whether the layer has been resized.
</p>
          <p>
            <link id="Exec.LTrue">LTrue</link> - layer could be resized.
  
            <br/>
            <link id="Exec.LFalse">LFalse</link> - an error occured (out of memory).
</p>
        </descr>
      </element>
      <element name="SizeLayer.dummy">
        <short>Unused.</short>
      </element>
      <element name="SizeLayer.l">
        <short>Pointer to layer to be resized.</short>
      </element>
      <element name="SizeLayer.dw">
        <short>Delta to be added to the width.</short>
      </element>
      <element name="SizeLayer.dh">
        <short>Delta to be added to the height.</short>
      </element>
      <element name="ScrollLayer">
        <short>Scroll around in a superbitmap, translate coordinates in non-superbitmap layer.</short>
        <descr>
          <p>For superbitmapped layers this function work like this: It updates the contents of the superbitmap with what is visible on the display, repositions the superbitmap and redraws the display.</p>
          <p>For non-superbitmapped layers, all subsequent (x,y) pairs are adjusted by the scroll(x,y) value in the layer. If ScrollLayer(-10,-3) was called and (0,0) is drawn it will finally end up at coordinates (10, 3) in the superbitmap.</p>
        </descr>
        <errors>
          <p>May not handle (dx,dy) which attempts to move the layer outside the layer's SuperBitMap bounds.</p>
        </errors>
      </element>
      <element name="ScrollLayer.dummy">
        <short>Unused.</short>
      </element>
      <element name="ScrollLayer.l">
        <short>Pointer to layer.</short>
      </element>
      <element name="ScrollLayer.dx">
        <short>Delta x to add to current x scroll value.</short>
      </element>
      <element name="ScrollLayer.dy">
        <short>Delta y to add to current y scroll value.</short>
      </element>
      <element name="BeginUpdate">
        <short>Prepare to repair damaged layer.</short>
        <descr>
          <p>Converts the damage list to ClipRects and exchanges the two lists for faster redrawing. This routine allows a faster update of the display as it will only be rendered in the damaged areas.</p>
          <p>This routine will automatically lock the layer to prevent changes.</p>
        </descr>
        <errors>
          <p>If BeginUpdate returns 
<link id="Exec.LFalse">LFalse</link>, programmer must abort the attempt to refresh this layer and instead call EndUpdate( l, 
<link id="Exec.LFalse">LFalse</link>) to restore original 
<link id="AGraphics.TClipRect">ClipRect</link> and damage list.
</p>
        </errors>
        <seealso>
          <link id="EndUpdate"/>
        </seealso>
      </element>
      <element name="BeginUpdate.Result">
        <descr>
          <p>Returns a boolean state which establishes whether the function was Successful.
</p>
          <p>
            <link id="Exec.LTrue">LTrue</link> if damage list conversion was successful
            <br/>
            <link id="Exec.LFalse">LFalse</link> if list could not be converted.
</p>
        </descr>
      </element>
      <element name="BeginUpdate.l">
        <short>Pointer to layer.</short>
      </element>
      <element name="EndUpdate">
        <short>Remove damage list and restore state of layer to normal.</short>
        <descr>
          <p>After the damaged areas are update this routine should be called so the regular cliprects of the layer can be installed.</p>
        </descr>
        <seealso>
          <link id="BeginUpdate"/>
        </seealso>
      </element>
      <element name="EndUpdate.l">
        <short>Pointer to layer.</short>
      </element>
      <element name="EndUpdate.flag">
        <short>Determines wheter the update was complete or partial. LTrue if the update was complete. The damage list is disposed. LFalse it the update was partial. The damage list is kept.</short>
      </element>
      <element name="DeleteLayer">
        <short>Delete a layer from layer list.</short>
        <descr>
          <p>Deletes the layer. Other layers that were hidden (partially) will become visible. If parts of a simple layer become visible those parts are added to the damagelist of the layer and the LAYERREFRESH flags is set.</p>
        </descr>
      </element>
      <element name="DeleteLayer.Result">
        <descr>
          <p>Returns a boolean state which establishes whether the function was Successful.
</p>
          <p>
            <link id="Exec.LTrue">LTrue</link> - layer was successfuly deleted
  
            <br/>
            <link id="Exec.LFalse">LFalse</link> - layer could not be deleted (put of memory).
</p>
        </descr>
      </element>
      <element name="DeleteLayer.dummy">
        <short>Unused.</short>
      </element>
      <element name="DeleteLayer.l">
        <short>Layer to be deleted.</short>
      </element>
      <element name="LockLayer">
        <short>Lock layer to make changes to ClipRects.</short>
        <descr>
          <p>Locks a layer for exclusive access by this task. A layer can be locked multiple times but has to be unlocked as many times as it has been locked so that other tasks can access it.</p>
        </descr>
        <seealso>
          <link id="UnlockLayer"/>
          <link id="LockLayerInfo"/>
          <link id="UnlockLayerInfo"/>
          <link id="AGraphics.LockLayerRom"/>
          <link id="AGraphics.pLayer"/>
          <link id="AGraphics.pClipRect"/>
        </seealso>
      </element>
      <element name="LockLayer.dummy">
        <short>Unused.</short>
      </element>
      <element name="LockLayer.layer">
        <short>Pointer to a layer to be locked.</short>
      </element>
      <element name="UnlockLayer">
        <short>Unlock layer and allow graphics routines to use it.</short>
        <descr>
          <p>Unlocks a layer for access by other tasks. A layer has to be unlocked as many times as it has been locked until another task can access it.</p>
        </descr>
      </element>
      <element name="UnlockLayer.layer">
        <short>Pointer to layer to be unlocked.</short>
      </element>
      <element name="LockLayers">
        <short>Lock all layers from graphics output.</short>
        <descr>
          <p>First locks the Layer_Info then all the layers that are found in the list of layers.</p>
        </descr>
        <seealso>
          <link id="LockLayer"/>
          <link id="LockLayerInfo"/>
          <link id="AGraphics.TLayer_Info"/>
        </seealso>
      </element>
      <element name="LockLayers.li">
        <short>Pointer to a Layer_Info structure.</short>
      </element>
      <element name="UnlockLayers">
        <short>Unlock all layers from graphics output. Restart graphics output to layers that have been waiting.</short>
        <descr>
          <p>First unlocks all layers found in the list, then unlocks the Layer_Info itself.</p>
        </descr>
        <seealso>
          <link id="LockLayers"/>
          <link id="UnlockLayer"/>
        </seealso>
      </element>
      <element name="UnlockLayers.li">
        <short>Unlock the LayerInfo structure.</short>
      </element>
      <element name="LockLayerInfo">
        <short>Lock the LayerInfo structure.</short>
        <descr>
          <p>Before doing an operation that requires the LayerInfo structure, make sure that no other task is also using the LayerInfo structure. LockLayerInfo returns when the LayerInfo belongs to this task. There should be an UnLockLayerInfo for every LockLayerInfo.</p>
          <p>
            <b>Notes:</b>
          </p>
          <p>All layer routines presently LockLayerInfo() when they start up and UnlockLayerInfo as they exit. Programmers will need to use these Lock/Unlock routines if they wish to do something with the LayerStructure that is not supported by the layers library.</p>
        </descr>
        <seealso>
          <link id="UnlockLayerInfo"/>
          <link id="AGraphics.TLayer_Info"/>
        </seealso>
      </element>
      <element name="LockLayerInfo.li">
        <short>Pointer to Layer_Info structure.</short>
      </element>
      <element name="SwapBitsRastPortClipRect">
        <short>Swap bits between common bitmap and obscured ClipRect.</short>
        <descr>
          <p>Support routine for those that need to do some operations not done by the layer library. Allows programmer to swap the contents of a small BitMap with a subsection of the display. This is accomplished without using extr memory.</p>
          <p>The bits in the display RastPort are exchanged with the bits in the ClipRect's Bitmap.</p>
          <p>
            <b>Notes:</b>
          </p>
          <p>The ClipRect structures which the layer library allocates are actually a little bigger than those described in the graphics/clip.h include file. So be warned that it is not a good idea to have instances of cliprects in you code.</p>
        </descr>
      </element>
      <element name="SwapBitsRastPortClipRect.rp">
        <short>Pointer to rastport.</short>
      </element>
      <element name="SwapBitsRastPortClipRect.cr">
        <short>Pointer to cliprect to swap bits with.</short>
      </element>
      <element name="WhichLayer">
        <short>Which layer is this point in ?</short>
        <descr>
          <p>Determines in which layer the point (x,y) is to be found. Starts with the frontmost layer.</p>
        </descr>
      </element>
      <element name="WhichLayer.Result">
        <short>Pointer to the topmost layer that this point is in or nil if this point is not in a layer.</short>
      </element>
      <element name="WhichLayer.li">
        <short>Pointer to Layers_Info structure.</short>
      </element>
      <element name="WhichLayer.x">
        <short>X-coordinate.</short>
      </element>
      <element name="WhichLayer.y">
        <short>Y-coordinate.</short>
      </element>
      <element name="UnlockLayerInfo">
        <short>Unlock the LayerInfo structure.</short>
        <descr>
          <p>After the operation is complete that required a LockLayerInfo, unlock the LayerInfo structure so that other tasks may affect the layers.</p>
        </descr>
        <seealso>
          <link id="LockLayerInfo"/>
        </seealso>
      </element>
      <element name="UnlockLayerInfo.li">
        <short>Pointer to the Layer_Info structure.</short>
      </element>
      <element name="NewLayerInfo">
        <short>Allocate and Initialize full Layer_Info structure.</short>
        <descr>
          <p>Allocate memory required for full Layer_Info structure.</p>
          <p>Initialize Layer_Info structure in preparation to use other layer operations on this list of layers.</p>
          <p>Make the Layer_Info unlocked (open).</p>
        </descr>
        <seealso>
          <link id="AGraphics.TLayerInfo"/>
        </seealso>
      </element>
      <element name="NewLayerInfo.Result">
        <descr>Returns a pointer to Layer_Info structure if successful or Nil is not enough memory.</descr>
      </element>
      <element name="DisposeLayerInfo">
        <short>Return all memory for LayerInfo to memory pool.</short>
        <descr>
          <p>return LayerInfo and any other memory attached to this LayerInfo to memory allocator.</p>
          <p>
            <b>Notes:</b>
          </p>
          <p>If you wish to delete the layers associated with this Layer_Info structure, remember to call DeleteLayer for each of the layers before calling DisposeLayerInfo.</p>
        </descr>
      </element>
      <element name="DisposeLayerInfo.li">
        <short>Pointer to LayerInfo structure.</short>
      </element>
      <element name="FattenLayerInfo">
        <short>
          <b>OBSOLETE</b> Convert 1.0 LayerInfo to 1.1 LayerInfo</short>
        <descr>
          <p>This function is <b>OBSOLETE</b>
          </p>
          <p>V1.1 software and any later releases need to have more info in the Layer_Info structure. To do this in a 1.0 supportable manner requires allocation and deallocation of the memory whenever most layer library functions are called. To prevent unnecessary allocation/deallocation FattenLayerInfo will preallocate the necessary data structures and fake out the layer library into thinking it has a LayerInfo gotten from NewLayerInfo.</p>
          <p>NewLayerInfo is the approved method for getting this structure.</p>
          <p>When a program needs to give up the LayerInfo structure it must call ThinLayerInfo before freeing the memory. ThinLayerInfo is not necessary if NewLayerInfo/DisposeLayerInfo are used however.</p>
        </descr>
        <errors>
          <p>This function is OBSOLETE</p>
        </errors>
        <seealso>
          <link id="NewLayerInfo"/>
          <link id="ThinLayerInfo"/>
          <link id="DisposeLayerInfo"/>
          <link id="AGraphics.pLayerInfo"/>
        </seealso>
      </element>
      <element name="FattenLayerInfo.Result">
        <short/>
      </element>
      <element name="FattenLayerInfo.li">
        <short>Pointer to LayerInfo structure.</short>
      </element>
      <element name="ThinLayerInfo">
        <short>
          <b>OBSOLETE</b> Convert 1.1 LayerInfo to 1.0 LayerInfo</short>
        <descr>
          <p>This function is <b>OBSOLETE</b>
          </p>
          <p>return the extra memory needed that was allocated with FatteLayerInfo. This is must be done prior to freeing the Layer_Info structure itself. V1.1 software should be using DisposeLayerInfo.</p>
        </descr>
        <errors>
          <p>This function is OBSOLETE</p>
        </errors>
      </element>
      <element name="ThinLayerInfo.li">
        <short>Pointer to LayerInfo structure.</short>
      </element>
      <element name="MoveLayerInFrontOf">
        <short>Put layer in front of another layer.</short>
        <descr>
          <p>Moves layer directly in front of another layer. Other layers might become visible. You cannot move a backdrop layer in front of a non-backdrop layer. You can also not move a layer in front of a layer with different relationship to the root layer. Boot have to be children of grandchildren or grandgrandchildren etc. of the root layer. The root layer is not visible to you and should never be accessed.</p>
          <p>If parts of a simple layer become visible these areas are added to the damage list.</p>
        </descr>
        <seealso>
          <link id="AGraphics.TLayer_Info"/>
        </seealso>
      </element>
      <element name="MoveLayerInFrontOf.Result">
        <descr>
          <p>Returns a boolean state which establishes whether the layer has moved.
</p>
          <p>
            <link id="Exec.LTrue">LTrue</link> - layer was moved.
  
            <br/>
            <link id="Exec.LFalse">LFalse</link> - layer could not be moved (probably out of memory).
</p>
        </descr>
      </element>
      <element name="MoveLayerInFrontOf.layer_to_move">
        <short>Pointer to layer that is to be moved.</short>
      </element>
      <element name="MoveLayerInFrontOf.other_layer">
        <short>Pointer to other layer that will be behind the layer_to_move.</short>
      </element>
      <element name="InstallClipRegion">
        <short>Install clip region in layer.</short>
        <descr>
          <p>Install a transparent Clip region in the layer. All subsequent graphics calls to the rastport of the layer will be clipped to that region.</p>
          <p>None of the system functions will free the ClipRegion for you, so you will have to call InstallClipRegion(l, Nil) before closing a window or deleting a layer.</p>
        </descr>
        <seealso>
          <link id="BeginUpdate"/>
          <link id="EndUpdate"/>
          <link id="AGraphics.pLayer_Info"/>
          <link id="AGraphics.pClipRect"/>
          <link id="AGraphics.pClipRegion"/>
        </seealso>
      </element>
      <element name="InstallClipRegion.Result">
        <short>Pointer to old clip region.</short>
        <descr>
          <p>Returns the pointer to the previous ClipRegion that was installed. Return Nil if no previous ClipRegion installed.</p>
          <p>
            <b>Notes:</b>
          </p>
          <p>If the system runs out of memory while computing the resulting ClipRects the LAYERS_CLIPRECTS_LOST bit will be set in l^.Flags.</p>
        </descr>
        <errors>
          <p>If the system runs out of memory during normal operations, the <link id="AGraphics/TClipRect ">ClipRect</link> list may get swept away and not restored.</p>
          <p>As soon as there is enough memory and the layer library gets called again the <link id="AGraphics/TClipRect ">ClipRect</link>list will be rebuilt.</p>
        </errors>
      </element>
      <element name="InstallClipRegion.l">
        <short>Pointer to a layer.</short>
      </element>
      <element name="InstallClipRegion.region">
        <short>Pointer to region to be clipped against.</short>
      </element>
      <element name="MoveSizeLayer">
        <short>Position/Size layer.</short>
        <descr>
          <p>Moves and resizes the layer in one step. Collects damage lists for those layers that become visible and are simple layers.</p>
          <p>If the layer to be moved is becoming larger the additional areas are added to a damagelist if it is a non-superbitmap layer. Refresh is also triggered for this layer.</p>
        </descr>
        <seealso>
          <link id="AGraphics.TLayerInfo"/>
          <link id="AGraphics.TClipRect"/>
        </seealso>
      </element>
      <element name="MoveSizeLayer.Result">
        <descr>
          <p>Returns a boolean state which establishes whether the layer has moved and resized.
</p>
          <p>
            <link id="Exec.LTrue">LTrue</link> - everything went alright.
  
  
            <br/>
            <link id="Exec.LFalse">LFalse</link> - an error occured (out of memory).
</p>
        </descr>
      </element>
      <element name="MoveSizeLayer.l">
        <short>Pointer to layer to be moved.</short>
      </element>
      <element name="MoveSizeLayer.dx">
        <short>Delta to add to current x position.</short>
      </element>
      <element name="MoveSizeLayer.dy">
        <short>Delta to add to current y position.</short>
      </element>
      <element name="MoveSizeLayer.dw">
        <short>Delta to add to current width.</short>
      </element>
      <element name="MoveSizeLayer.dh">
        <short>Delta to add to current height.</short>
      </element>
      <element name="CreateUpfrontHookLayer">
        <short>Create a new layer on top of existing layers, using supplied callback BackFill hook.</short>
        <descr>
          <p>Create a new layer at the given position and with the given size. The new layer will be in front of all other layers. If it is a backdrop layer it will be created in front of all other backdrop layers and behind all non backdrop layers.</p>
          <p>Install the given hook as a backfill hook. This hook will be called whenever a part of the layer is supposed to be filled with a certain pattern. The backfill hook has to do that.</p>
          <p>If a super bitmap layer is wanted the flags LAYERSUPER and the flag LAYERSMART have to be set and a pointer to a bitmap must also be passed to this function.</p>
          <p>
            <b>Notes:</b>
          </p>
          <p>Does not allow to create layers that are partially outside the given bitmap (, yet).</p>
        </descr>
      </element>
      <element name="CreateUpfrontHookLayer.Result">
        <short>Pointer to layer if successful, Nil otherwise.</short>
      </element>
      <element name="CreateUpfrontHookLayer.li">
        <short>Pointer to LayerInfo structure.</short>
      </element>
      <element name="CreateUpfrontHookLayer.bm">
        <short>Pointer to common bitmap.</short>
      </element>
      <element name="CreateUpfrontHookLayer.x0">
        <short>Upper left corner of the layer.</short>
      </element>
      <element name="CreateUpfrontHookLayer.y0">
        <short>Upper left corner of the layer.</short>
      </element>
      <element name="CreateUpfrontHookLayer.x1">
        <short>Lower right corner of the layer.</short>
      </element>
      <element name="CreateUpfrontHookLayer.y1">
        <short>Lower right corner of the layer.</short>
      </element>
      <element name="CreateUpfrontHookLayer.flags">
        <short>Choose the type of layer by setting some flags.</short>
      </element>
      <element name="CreateUpfrontHookLayer.hook">
        <short>Pointer to the backfill hook of this layer.</short>
        <descr>
          <p>The backfill hook will be called with<br/>
object = pRastPort(result^.RastPort<br/>) 
and message = [ pLayer(layer), tRectangle(bounds), WORD(offsetx), WORD(offsety) ]
</p>
        </descr>
      </element>
      <element name="CreateUpfrontHookLayer.bm2">
        <short>Pointer to optional super bitmap.</short>
      </element>
      <element name="CreateBehindHookLayer">
        <short>Create a new layer behind all existing layers, using supplied callback BackFill hook.</short>
        <descr>
          <p>Create a new layer at the given position and with the given size. The new layer will be in front of all other layers. If it is a backdrop layer it will be created in front of all other backdrop layers and behind all non backdrop layers.</p>
          <p>Install the given hook as a backfill hook. This hook will be called whenever a part of the layer is supposed to be filled with a certain pattern. The backfill hook has to do that.</p>
          <p>If a super bitmap layer is wanted the flags LAYERSUPER and the flag LAYERSMART have to be set and a pointer to a bitmap must also be passed to this function.</p>
          <p>
            <b>Notes:</b>
          </p>
          <p>Does not allow to create layers that are partially outside the given bitmap (, yet).</p>
        </descr>
      </element>
      <element name="CreateBehindHookLayer.Result">
        <short>Pointer to the newly created layer. Nil if layer could not be created (Probably out of memory).</short>
      </element>
      <element name="CreateBehindHookLayer.li">
        <short>Pointer to LayerInfo structure.</short>
      </element>
      <element name="CreateBehindHookLayer.bm">
        <short>Pointer to common bitmap.</short>
      </element>
      <element name="CreateBehindHookLayer.x0">
        <short>Upper left corner of the layer.</short>
      </element>
      <element name="CreateBehindHookLayer.y0">
        <short>Upper left corner of the layer.</short>
      </element>
      <element name="CreateBehindHookLayer.x1">
        <short>Lower right corner of the layer.</short>
      </element>
      <element name="CreateBehindHookLayer.y1">
        <short>Lower right corner of the layer.</short>
      </element>
      <element name="CreateBehindHookLayer.flags">
        <short>Choose the type of layer by setting some flags.</short>
      </element>
      <element name="CreateBehindHookLayer.hook">
        <short>Pointer to the backfill hook of this layer.</short>
        <descr>
          <p>The backfill hook will be called with<br/>
object = pRastPort(result^.RastPort<br/>) 
and message = [ pLayer(layer), tRectangle(bounds), WORD(offsetx), WORD(offsety) ]
</p>
        </descr>
      </element>
      <element name="CreateBehindHookLayer.bm2">
        <short>Pointer to optional super bitmap.</short>
      </element>
      <element name="InstallLayerHook">
        <short>Safely install a new backfill hook.</short>
        <descr>
          <p>Safely install a new backfill hook. Return the old hook.</p>
          <p>If hook is Nil, then the default backfill hook will be installed.</p>
        </descr>
      </element>
      <element name="InstallLayerHook.Result">
        <short>Pointer to a (previous installed) hook.</short>
        <descr>
          <p>Pointer to the Layer^.BackFill Hook that was previously active. Returns Nil if it was the default hook.</p>
          <p>In V39, it could return 1 if there was no hook.</p>
        </descr>
      </element>
      <element name="InstallLayerHook.layer">
        <short>Layer that will get the new backfill hook.</short>
      </element>
      <element name="InstallLayerHook.hook">
        <short>Pointer to backfill hook to be installed.</short>
      </element>
      <element name="InstallLayerInfoHook">
        <short>Install a backfill hook for non-layer.</short>
        <descr>
          <p>Install a backfill hook into the LayerInfo structure. This backfill hook will be called to clear the areas where there is no layer. It will be used for every layer.</p>
          <p>
            <b>Notes:</b>
          </p>
          <p>The hook is not called immediately. It will be called for those areas that have to be cleared when layers move away from those areas.</p>
        </descr>
        <seealso>
          <link id="InstallLayerHook"/>
        </seealso>
      </element>
      <element name="InstallLayerInfoHook.Result">
        <short>Pointer to a (previous installed) hook.</short>
        <descr>
          <p>If there was a backfill hook installed before it will be returned. LAYERS_BACKFILL will be returned if the default backfill hook was installed, LAYERS_NOBACKFILL if there was nothing to be called for clearing an area.</p>
        </descr>
      </element>
      <element name="InstallLayerInfoHook.li">
        <short>Pointer to LayerInfo.</short>
      </element>
      <element name="InstallLayerInfoHook.hook">
        <short>Pointer to a callback Hook which will be called.</short>
        <descr>
          <p>The Hook will be called with object = pRastPort(result^.RastPort) and message = [ LongWord(undefined), TRectangle(bounds) ].</p>
          <p>This hook should fill the Rectangle in the RastPort with the BackFill pattern appropiate for rectangle given.</p>
          <p>If hook is LAYERS_BACKFILL, the default backfill is used. (Same as pre-2.0).</p>
          <p>If hook is LAYERS_NOBACkFILL, there will be no backfill. (<b>No-op</b>)</p>
        </descr>
      </element>
      <element name="SortLayerCR">
        <short>Sort ClipRects in layer.</short>
        <descr>
          <p>Sorts the list of ClipRects associated with the given layer.</p>
          <p>The direction of the sort is indicated by dx and dy.</p>
          <p>
            <b>Result:</b>
          </p>
          <p>The layer^.ClipRect pointer now points to a sorted list of ClipRects.</p>
          <p>
            <b>Internals:</b>
          </p>
          <p>Implemented as an InsertSort on a singly linked list.</p>
          <remark>? This function is introduced in AROS.?</remark>
        </descr>
      </element>
      <element name="SortLayerCR.layer">
        <short>The layer with the ClipRect list to sort</short>
      </element>
      <element name="SortLayerCR.dx">
        <short>The left/right ordering.</short>
      </element>
      <element name="SortLayerCR.dy">
        <short>The up/down ordering.</short>
      </element>
      <element name="DoHookClipRects">
        <short>Do the given hook for each of the ClipRects.</short>
        <descr>
          <p>This function will call the given hook for each ClipRect in the layer that can be rendered into. This is how the backfill hook in Layers is implemented. This means that hidden simple-refresh cliprects will be ignored. It will call the SuperBitmap cliprects, smart refresh off-screen cliprects, and all on screen cliprects.</p>
          <p>If the rect parameter is not Nil, the cliprects are bounded to the rectangle given.</p>
          <remark>? This function is introduced in AROS.?</remark>
        </descr>
      </element>
      <element name="DoHookClipRects.hook">
        <short>Pointer to the hook to be called for the cliprects of the given layer.</short>
      </element>
      <element name="DoHookClipRects.rport">
        <short>No operation is allowed outside this rectangle. If a layer is bigger than this rectangle only operations in the common area are allowed.</short>
      </element>
      <element name="DoHookClipRects.rect">
        <short>Pointer to the rastport where the layers upon which the hook is to be called.</short>
      </element>
      <element name="CreateLayerTagList">
        <short>Create a new layer according to the given taglist.</short>
        <descr>
          <remark>? This function is introduced in AROS.?</remark>
          <p/>
          <table border="1">
            <th>
              <td>TagItem</td>
              <td/>
              <td>Description</td>
            </th>
            <tr>
              <td valign="top">LA_PRIORITY</td>
              <td valign="top">:</td>
              <td valign="top">
                <p>priority class of the layer.</p>
                <p>The higher the number the further the layer will be in front of everything else.</p>
                <p>Default value is UPFRONTPRIORITY.</p>
              </td>
            </tr>
            <tr>
              <td>LA_HOOK</td>
              <td>:</td>
              <td>Backfill hook</td>
            </tr>
            <tr>
              <td>LA_SUPERBITMAP</td>
              <td>:</td>
              <td>
                <p>pointer to a superbitmap.</p>
                <p>The flags must also represent that this layer is supposed to be a superbitmap layer.</p>
              </td>
            </tr>
            <tr>
              <td>LA_CHILDOF</td>
              <td>:</td>
              <td>
                <p>pointer to parent layer. </p>
                <p>If Nil then this layer will be created as a old-style layer.</p>
              </td>
            </tr>
            <tr>
              <td>LA_INFRONTOF</td>
              <td>:</td>
              <td>pointer to a layer in front of which this layer is to be created.</td>
            </tr>
            <tr>
              <td>LA_BEHIND</td>
              <td>:</td>
              <td>
                <p>pointer to a layer behind which this layer is to be created.</p>
                <p>Must not give both LA_INFRONTOF and LA_BEHIND.</p>
              </td>
            </tr>
            <tr>
              <td>LA_VISIBLE</td>
              <td>:</td>
              <td>
                <p>LFalse if this layer is to be invisible.</p>
                <p>Default value is LTrue</p>
              </td>
            </tr>
            <tr>
              <td>LA_SHAPE</td>
              <td>:</td>
              <td>
                <p>The region of the layer that comprises its shape.</p>
                <p>This value is optional.</p>
                <p>The region must be relative to the layer.</p>
              </td>
            </tr>
          </table>
        </descr>
      </element>
      <element name="CreateLayerTagList.Result">
        <descr>
          <p>Pointer to the newly created layer. Nil if layer could not be created (Probably out of memory).</p>
          <p>If the layer is created successful you must not free its shape. The shape is automatically freed when the layer is deleted.</p>
        </descr>
      </element>
      <element name="CreateLayerTagList.li">
        <short>Pointer to LayerInfo structure.</short>
      </element>
      <element name="CreateLayerTagList.bm">
        <short>Pointer to common bitmap.</short>
      </element>
      <element name="CreateLayerTagList.x0">
        <short>Upper left corner of the layer (in parent layer coords).</short>
      </element>
      <element name="CreateLayerTagList.y0">
        <short>Upper left corner of the layer (in parent layer coords).</short>
      </element>
      <element name="CreateLayerTagList.x1">
        <short>Lower right corner of the layer (in parent layer coords).</short>
      </element>
      <element name="CreateLayerTagList.y1">
        <short>Lower right corner of the layer (in parent layer coords).</short>
      </element>
      <element name="CreateLayerTagList.flags">
        <short>Choose the type of layer by setting some flags.   If it is to be a super bitmap layer then the tag LA_SUPERBITMAP must be provided along with a pointer to a valid super bitmap.</short>
      </element>
      <element name="CreateLayerTagList.tagList">
        <short>A list of tags that specify the properties of the layer.</short>
      </element>
      <element name="GetFirstFamilyMember">
        <short>Gets the first member of a layer family.</short>
        <descr>
          <p>Gets the first member of a layer family. If the layer has no children at all this function returns the pointer to the same layer as given. If the layer has children which again have children etc. this function returns the frontmost child.</p>
          <remark>? This function is introduced in AROS.?</remark>
        </descr>
      </element>
      <element name="GetFirstFamilyMember.Result">
        <short>Pointer to layer structure.</short>
        <descr>
          <p>Pointer to a layer structure that represents the frontmost child of the given layer or the layer itself if it has no children.</p>
        </descr>
      </element>
      <element name="GetFirstFamilyMember.l">
        <short>Pointer to a layer structure.</short>
      </element>
      <element name="ChangeLayerVisibility">
        <short>Changes the visibility of a layer.</short>
        <descr>
          <p>Makes the given layer visible or invisible.</p>
          <p>If it is a simple refresh layer it will loose all its cliprects and therefore rendering will go into the void.</p>
          <remark>? This function is introduced in AROS.?</remark>
        </descr>
      </element>
      <element name="ChangeLayerVisibility.Result">
        <descr>
          <p>Returns a boolean state which establishes whether the function was Successful.
</p>
          <p>
            <link id="Exec.LTrue">LTrue</link> - layer was changed to new state
  
            <br/>
            <link id="Exec.LFalse">LFalse</link> - layer could not be changed to new state.
</p>
        </descr>
      </element>
      <element name="ChangeLayerVisibility.l">
        <short>Pointer to layer.</short>
      </element>
      <element name="ChangeLayerVisibility.visible">
        <short>LTrue or LFalse.</short>
      </element>
      <element name="IsLayerVisible">
        <short>Determines whether the layer is visible or not.</short>
        <descr>
          <remark>? This function is introduced in AROS.?</remark>
        </descr>
      </element>
      <element name="IsLayerVisible.Result">
        <descr>
          <p>Returns a boolean state which establishes whether the layer is visible.
</p>
          <p>
            <link id="Exec.LTrue">LTrue</link> - layer is visible.
            <br/>
            <link id="Exec.LFalse">LFalse</link> - layer is invisible.
</p>
        </descr>
      </element>
      <element name="IsLayerVisible.l">
        <short>Pointer to a layer.</short>
      </element>
      <element name="ChangeLayerShape">
        <short>Changes shape of layer.</short>
        <descr>
          <p>Changes the shape of the layer on the fly.</p>
          <p>When the shape of a layer is changed the current pixel content is copied into its ClipRects so no information is lost.</p>
          <p>The user can provide a callback hook that will be called when the current layer's information is all backed up in ClipRects. The signature of the callback should look as follows:</p>
          <code>Function CallBack(hook: pHook; l: pLayer; arg: pScaleLayerParam): pRegion; cdecl;</code>
          <remark>? This function is introduced in AROS.?</remark>
        </descr>
      </element>
      <element name="ChangeLayerShape.Result">
        <short>Pointer to the previously installed region.</short>
      </element>
      <element name="ChangeLayerShape.l">
        <short>Pointer to layer.</short>
      </element>
      <element name="ChangeLayerShape.newshape">
        <short>Pointer to a region that comprises the new shape of the layer. May be Nil if callback is provided.</short>
      </element>
      <element name="ChangeLayerShape.callback">
        <short>Pointer to a callback hook. May be Nil if newshape is given.</short>
      </element>
      <element name="ScaleLayer">
        <short>Scale a layer.</short>
        <descr>
          <p>Scale the given layer. This function will use the current shape of the layer and resize it according to the given newwidth/newheight.</p>
          <remark>? This function is introduced in AROS.?</remark>
          <table border="1">
            <th>
              <td>TagItem</td>
              <td/>
              <td>Description</td>
            </th>
            <tr>
              <td>LA_DESTWIDTH</td>
              <td>:</td>
              <td>Destination width of layer to scale</td>
            </tr>
            <tr>
              <td>LA_DESTHEIGHT</td>
              <td>:</td>
              <td>Destination height of layer to scale</td>
            </tr>
          </table>
        </descr>
      </element>
      <element name="ScaleLayer.Result">
        <descr>
          <p>Returns a boolean state which establishes whether the layer was scaled.
</p>
          <p>
            <link id="Exec.LTrue">LTrue</link> - everything went alright.
  
  
            <br/>
            <link id="Exec.LFalse">LFalse</link> - otherwise.
</p>
        </descr>
      </element>
      <element name="ScaleLayer.l">
        <short>Pointer to layer.</short>
      </element>
      <element name="ScaleLayer.taglist">
        <short>Pointer to a list of tags.</short>
        <descr>
          <p>Possible tagitems are:<br/>
newwidth    - new width of the layer<br/>
newheight   - new height of the layer<br/>
          </p>
        </descr>
      </element>
      <element name="IsFrontmostLayer">
        <short>Determines if layer is the frontmost layer.</short>
        <descr>
          <p>Checks whether this layer is the frontmost layer within its priority.</p>
          <p>If this layer has children then all of its children will be disregarded. Comparisons are only done with layers that have the same 'depth' of relationship (=nesting counter) to the root layer.</p>
          <p>It can be specified whether invisible siblings are to be considered in the comparison.</p>
          <remark>? This function is introduced in AROS.?</remark>
        </descr>
      </element>
      <element name="IsFrontmostLayer.Result">
        <descr>
          <p>Returns a boolean which establishes whether the layer is frontmost.
</p>
          <p>
            <link id="Exec.LTrue">LTrue</link> - layer is frontmost layer within its priority.

  
            <br/>
            <link id="Exec.LFalse">LFalse</link> - layer is not frontmost layer within its priority.
</p>
        </descr>
      </element>
      <element name="IsFrontmostLayer.l">
        <short>Pointer to a layer.</short>
      </element>
      <element name="IsFrontmostLayer.check_invisible">
        <short>Whether invisible siblings are to be considered.</short>
      </element>
      <element name="IsLayerHiddenBySibling">
        <short>Determines if layer is hidden by sibling.</short>
        <descr>
          <p>Checks whether this layer is hidden by any siblings that are in front of it. All these siblings must have the same priority as that layer.</p>
          <p>It can be specified whether invisible siblings are to be considered in the comparison.</p>
          <remark>? This function is introduced in AROS.?</remark>
        </descr>
      </element>
      <element name="IsLayerHiddenBySibling.Result">
        <descr>
          <p>Returns a boolean which establishes whether the layer is hidden by a sibbling.
</p>
          <p>
            <link id="Exec.LTrue">LTrue</link> - layer is hidden by one or more sibblings.
            <br/>
            <link id="Exec.LFalse">LFalse</link> - layer is fully visible.
</p>
        </descr>
      </element>
      <element name="IsLayerHiddenBySibling.l">
        <short>Pointer to a layer.</short>
      </element>
      <element name="IsLayerHiddenBySibling.check_invisible">
        <short>Whether invisible siblings are to be considered.</short>
      </element>
      <element name="CollectPixelsLayer">
        <short>Collect pixels of a layer.</short>
        <descr>
          <p>This function collects all the pixel within region r and calls the provided callback hook for all areas that were found. You can do with the pixels whatever you want...</p>
          <remark>? This function is introduced in AROS.?</remark>
        </descr>
      </element>
      <element name="CollectPixelsLayer.l">
        <short>Pointer to layer where to start out.</short>
      </element>
      <element name="CollectPixelsLayer.r">
        <short>Region where to look for hidden or visible pixels.</short>
      </element>
      <element name="CollectPixelsLayer.callback">
        <short>Callback function.</short>
        <descr>
          <p>Callback function.</p>
          <p>The callback will be invoked for the found pixels along with information about the size of the area that may be copied.
</p>
        </descr>
      </element>
      <element name="CreateLayerTags">
        <short>Create a new layer according to the tags given.</short>
        <descr>
          <remark>? This function is introduced in AROS.?</remark>
          <p/>
          <table border="1">
            <th>
              <td>TagItem</td>
              <td/>
              <td>Description</td>
            </th>
            <tr>
              <td valign="top">LA_PRIORITY</td>
              <td valign="top">:</td>
              <td valign="top">
                <p>priority class of the layer.</p>
                <p>The higher the number the further the layer will be in front of everything else.</p>
                <p>Default value is UPFRONTPRIORITY.</p>
              </td>
            </tr>
            <tr>
              <td>LA_HOOK</td>
              <td>:</td>
              <td>Backfill hook</td>
            </tr>
            <tr>
              <td>LA_SUPERBITMAP</td>
              <td>:</td>
              <td>
                <p>pointer to a superbitmap.</p>
                <p>The flags must also represent that this layer is supposed to be a superbitmap layer.</p>
              </td>
            </tr>
            <tr>
              <td>LA_CHILDOF</td>
              <td>:</td>
              <td>
                <p>pointer to parent layer. </p>
                <p>If Nil then this layer will be created as a old-style layer.</p>
              </td>
            </tr>
            <tr>
              <td>LA_INFRONTOF</td>
              <td>:</td>
              <td>pointer to a layer in front of which this layer is to be created.</td>
            </tr>
            <tr>
              <td>LA_BEHIND</td>
              <td>:</td>
              <td>
                <p>pointer to a layer behind which this layer is to be created.</p>
                <p>Must not give both LA_INFRONTOF and LA_BEHIND.</p>
              </td>
            </tr>
            <tr>
              <td>LA_VISIBLE</td>
              <td>:</td>
              <td>
                <p>LFalse if this layer is to be invisible.</p>
                <p>Default value is LTrue</p>
              </td>
            </tr>
            <tr>
              <td>LA_SHAPE</td>
              <td>:</td>
              <td>
                <p>The region of the layer that comprises its shape.</p>
                <p>This value is optional.</p>
                <p>The region must be relative to the layer.</p>
              </td>
            </tr>
          </table>
        </descr>
      </element>
      <element name="CreateLayerTags.Result">
        <descr>
          <p>Pointer to the newly created layer. Nil if layer could not be created (Probably out of memory).</p>
          <p>If the layer is created successful you must not free its shape. The shape is automatically freed when the layer is deleted.</p>
        </descr>
      </element>
      <element name="CreateLayerTags.li">
        <short>Pointer to LayerInfo structure.</short>
      </element>
      <element name="CreateLayerTags.bm">
        <short>Pointer to common bitmap.</short>
      </element>
      <element name="CreateLayerTags.x0">
        <short>Upper left corner of the layer (in parent layer coords).</short>
      </element>
      <element name="CreateLayerTags.y0">
        <short>Upper left corner of the layer (in parent layer coords).</short>
      </element>
      <element name="CreateLayerTags.x1">
        <short>Lower right corner of the layer (in parent layer coords).</short>
      </element>
      <element name="CreateLayerTags.y1">
        <short>Lower right corner of the layer (in parent layer coords).</short>
      </element>
      <element name="CreateLayerTags.flags">
        <short>Choose the type of layer by setting some flags.     If it is to be a super bitmap layer then the tag LA_SUPERBITMAP must be provided along with a pointer to a valid super bitmap.</short>
      </element>
      <element name="CreateLayerTags.tags">
        <short>A list of tags that specify the properties of the layer.</short>
      </element>
      <element name="ScaleLayerTags">
        <short>Scale a layer.</short>
        <descr>
          <p>Scale the given layer. This function will use the current shape of the layer and resize it according to the given newwidth/newheight.</p>
          <remark>? This function is introduced in AROS.?</remark>
          <table border="1">
            <th>
              <td>TagItem</td>
              <td/>
              <td>Description</td>
            </th>
            <tr>
              <td>LA_DESTWIDTH</td>
              <td>:</td>
              <td>Destination width of layer to scale</td>
            </tr>
            <tr>
              <td>LA_DESTHEIGHT</td>
              <td>:</td>
              <td>Destination height of layer to scale</td>
            </tr>
          </table>
        </descr>
      </element>
      <element name="ScaleLayerTags.Result">
        <descr>
          <p>Returns a boolean state which establishes whether the layer was scaled.
</p>
          <p>
            <link id="Exec.LTrue">LTrue</link> - everything went alright.
            <br/>
            <link id="Exec.LFalse">LFalse</link> - otherwise.
</p>
        </descr>
      </element>
      <element name="ScaleLayerTags.l">
        <short>Pointer to layer.</short>
      </element>
      <element name="ScaleLayerTags.tags">
        <short>A list of tags.</short>
        <descr>
          <p>Possible tagitems are:<br/>
newwidth    - new width of the layer<br/>
newheight   - new height of the layer<br/>
          </p>
        </descr>
      </element>
      <short>AROS' implementation of the hyperlayers library.</short>
      <descr>
        <p>The layers library takes care of housekeeping: the low level, repetitive tasks which are required to keep track of where to place bits. The layers library also provides a locking mechanism which coordinates display updating when multiple tasks are drawing graphics to layers. The windowing environment provided by the Intuition library is largely based on layers.</p>
        <p>ToDo:</p>
        <ul>
          <li>fix: parent layer should get/use layer info hook-handling of errors: out of memory error.</li>
          <li>optimization: if a layer is already completely hidden there is no need to call _BackupPartsOfLayer() again.</li>
          <li>optimization: do not copy a bitmap that has the same size and offset as the target bitmap but rather move only the pointer (if possible).</li>
        </ul>
      </descr>
      <notes>
        <note>Please remove Editorial Note:</note>
        <note>A Struct ScaleLayerParam is present in scalelayer.h, as well as a defined hook for ScaleLayerCallback. Both seems unused.</note>
        <note>Specific tags for using taglist does not seem to be documented.</note>
      </notes>
    </module>
    <short>Surprisingly this is the RTL of AROS</short>
  </package>
</fpdoc-descriptions>