DEFINITION MODULE Windows; (*J. Gutknecht, 9.9.83*)

  CONST Background = 0; FirstWindow = 1; LastWindow = 8;

  TYPE Window = [Background..LastWindow];
    (*Background serves as a possible return value for the
      UpWindow procedure and is not accessible to the user*)
    
    RestoreProc = PROCEDURE(Window);

  PROCEDURE OpenWindow(VAR u: Window; x,y,w,h: CARDINAL;
    Repaint: RestoreProc; VAR done: BOOLEAN);
  (*Open a new window u and initialize its rectangle
    by clearing it and drawing a frame of width 1;
    procedure Repaint will be called when restoration
    becomes necessary*)

  PROCEDURE DrawTitle(u: Window; title: ARRAY OF CHAR);
  (*Draw title bar; width = lineHeight of default font*)

  PROCEDURE RedefineWindow(u: Window; x,y,w,h: CARDINAL;
    VAR done: BOOLEAN);
  (*Change and reinitialize rectangle of window u*)

  PROCEDURE CloseWindow(u: Window);

  PROCEDURE OnTop(u: Window): BOOLEAN;

  PROCEDURE PlaceOnTop(u: Window);

  PROCEDURE PlaceOnBottom(u: Window);

  PROCEDURE UpWindow(x,y: CARDINAL): Window;
  (*Return the uppermost opened window containing (x,y),
    if there is any, and take the value Background otherwise*)

END Windows.