|##########|
|#MAGIC   #|CLABLKJB
|#PROJECT #|""
|#PATHS   #|"StdProject"
|#FLAGS   #|xx---x--x---xxx--x--------------
|#USERSW  #|--------------------------------
|#USERMASK#|--------------------------------
|#SWITCHES#|x-xx-x----------
|##########|
DEFINITION MODULE Workbench;
(* $A- *)
FROM Dos       IMPORT FileLockPtr;
FROM Intuition IMPORT Gadget,GadgetFlags,GadgetFlagSet,NewWindow,WindowPtr;
FROM Exec      IMPORT Message,MsgPortPtr,List,LibraryPtr;
FROM System    IMPORT BPTR,SysStringPtr,Regs;

CONST
  diskMagic       = $E310;
  diskVersion     = 1;
  gadgetBackFill  = GadgetFlagSet:{gadgHBox};
  noIconPosition  = -1;

TYPE
  WBObjectType        = (wb0,disk,drawer,tool,project,garbage,device,kick);

  DiskObjectPtr       = POINTER TO DiskObject;
  DrawerDataPtr       = POINTER TO DrawerData;
  FreeListPtr         = POINTER TO FreeList;
  WBArgPtr            = POINTER TO WBArg;
  WBStartupPtr        = POINTER TO WBStartup;
  ToolTypeArrayPtr    = POINTER TO ARRAY OF SysStringPtr;

  WBArg          = RECORD
                     lock : FileLockPtr;
                     name : SysStringPtr;
                   END;

  WBArgumentsPtr = POINTER TO ARRAY OF WBArg;

  WBStartup      = RECORD OF Message
                     process   : MsgPortPtr;
                     segment   : BPTR;
                     numArgs   : LONGINT;
                     toolWindow: ANYPTR;
                     argList   : WBArgumentsPtr;
                   END;

  FreeList       = RECORD
                     numFree : INTEGER;
                     memList : List;
                   END;

  DiskObject     = RECORD
                     magic      : CARDINAL;
                     version    : CARDINAL;
                     gadget     : Gadget;
                     type       : WBObjectType;
                     defaultTool: SysStringPtr;
                     toolTypes  : ToolTypeArrayPtr;
                     currentX   : LONGINT;
                     currentY   : LONGINT;
                     drawerData : DrawerDataPtr;
                     toolWindow : ANYPTR;
                     stackSize  : LONGINT;
                   END;

  DrawerData     = RECORD
                     newWindow : NewWindow;
                     currentX  : LONGINT;
                     currentY  : LONGINT;
                     flags     : LONGINT;
                     modes     : CARDINAL;
                   END;

CONST
  drawerDataFileSize = DrawerData'SIZE;

TYPE
  AppMsgTypes    = (pstd,toolexit,diskchange,timer,closedown,ioproc,
                    appwindow,appicon,appmenuitem,copyexit,iconput,
                    makeword=$1000);

  | pstd        : standard message
  | toolexit    : exit message from tools
  | diskchange  : dos telling of a disk change
  | timer       : we got a time tick
  | appwindow   : msg from an app window
  | appicon     : msg from an app icon
  | appmenuitem : msg from an app menuitem
  | copyexit    : exit msg from copy process
  | iconput     : msg from PutDiskObject in icon.library

TYPE
  AppMessagePtr  = POINTER TO AppMessage;
  AppMessage     = RECORD OF Message;
                     type     : AppMsgTypes;
                     userData : ANYPTR;
                     id       : LONGINT;
                     numArgs  : LONGINT;
                     wbArgs   : WBArgumentsPtr;
                     version  : CARDINAL;
                     class    : CARDINAL;
                     mouseX,
                     mouseY   : INTEGER;
                     seconds,
                     micros   : LONGINT;
                     reserved : ARRAY [8] OF LONGINT;
                   END;

TYPE
  AppWindowPtr   = HIDDEN;
  AppIconPtr     = HIDDEN;
  AppMenuItemPtr = HIDDEN;

VAR
  StartupMsg     : WBStartupPtr;
  WorkbenchBase  : LibraryPtr;

LIBRARY WorkbenchBase BY -48
  PROCEDURE AddAppWindow(    id       IN D0 : LONGINT;
                             userData IN D1 : ANYPTR;
                             window   IN A0 : WindowPtr;
                             msgPort  IN A1 : MsgPortPtr;
                             taglist  IN A2 : ANYPTR):AppWindowPtr;

LIBRARY WorkbenchBase BY -54
  PROCEDURE RemoveAppWindow(window IN A0 : AppWindowPtr);

|LIBRARY WorkbenchBase BY -60  | geht so nicht wegen A4

  PROCEDURE AddAppIcon(    id       IN D0 : LONGINT;
                           userData IN D1 : ANYPTR;
                       REF text     IN A0 : STRING;
                           msgport  IN A1 : MsgPortPtr;
                           lock     IN A2 : FileLockPtr;
                           diskobj  IN A3 : DiskObjectPtr):AppIconPtr;

LIBRARY WorkbenchBase BY -66
  PROCEDURE RemoveAppIcon(appIcon IN A0 : AppIconPtr);

LIBRARY WorkbenchBase BY -72
  PROCEDURE AddAppMenuItem(    id       IN D0 : LONGINT;
                               userData IN D1 : ANYPTR;
                           REF text     IN A0 : STRING;
                               msgport  IN A1 : MsgPortPtr;
                               tags     IN A2 : ANYPTR):AppMenuItemPtr;
                               | ^= NIL for now


LIBRARY WorkbenchBase BY -78
  PROCEDURE RemoveAppMenuItem(appMenu IN A0 : AppMenuItemPtr);

GROUP
  All   = diskMagic,diskVersion,gadgetBackFill,noIconPosition,
          WBObjectType,DiskObjectPtr,DrawerDataPtr,
          FreeListPtr,WBArgPtr,WBStartupPtr,WBArg,WBArgumentsPtr,
          FreeList,DiskObject,DrawerData,WBStartup,drawerDataFileSize,
          StartupMsg;

END Workbench.
