Browse Source

AmigaOS4: Added library units for asl, diskfont and workbench

git-svn-id: trunk@33623 -
marcus 9 years ago
parent
commit
88a7915fb5

+ 3 - 0
.gitattributes

@@ -6324,7 +6324,9 @@ packages/os4units/Makefile.fpc.fpcmake svneol=native#text/plain
 packages/os4units/fpmake.pp svneol=native#text/pascal
 packages/os4units/src/agraphics.pas svneol=native#text/pascal
 packages/os4units/src/amigados.pas svneol=native#text/pascal
+packages/os4units/src/asl.pas svneol=native#text/pascal
 packages/os4units/src/clipboard.pas svneol=native#text/pascal
+packages/os4units/src/diskfont.pas svneol=native#text/pascal
 packages/os4units/src/exec.pas svneol=native#text/pascal
 packages/os4units/src/iffparse.pas svneol=native#text/pascal
 packages/os4units/src/inputevent.pas svneol=native#text/pascal
@@ -6334,6 +6336,7 @@ packages/os4units/src/layers.pas svneol=native#text/pascal
 packages/os4units/src/mui.pas svneol=native#text/pascal
 packages/os4units/src/timer.pas svneol=native#text/pascal
 packages/os4units/src/utility.pas svneol=native#text/pascal
+packages/os4units/src/workbench.pas svneol=native#text/pascal
 packages/palmunits/Makefile svneol=native#text/plain
 packages/palmunits/Makefile.fpc svneol=native#text/plain
 packages/palmunits/Makefile.fpc.fpcmake svneol=native#text/plain

+ 3 - 0
packages/os4units/fpmake.pp

@@ -43,6 +43,9 @@ begin
     T:=P.Targets.AddUnit('iffparse.pas');
     T:=P.Targets.AddUnit('intuition.pas');
     T:=P.Targets.AddUnit('mui.pas');
+    T:=P.Targets.AddUnit('diskfont.pas');
+    T:=P.Targets.AddUnit('workbench.pas');
+    T:=P.Targets.AddUnit('asl.pas');
 
 {$ifndef ALLPACKAGES}
     Run;

+ 553 - 0
packages/os4units/src/asl.pas

@@ -0,0 +1,553 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2014-2016 by Free Pascal development team
+
+    asl.library functions
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit asl;
+
+interface
+
+uses
+  exec, utility, workbench, agraphics;
+
+const
+  ASLNAME: PChar = 'asl.library';
+  ASL_Dummy = TAG_USER + $80000;
+
+// Types of requesters known to ASL, used as arguments to AllocAslRequest()
+  ASL_FileRequest       = 0;
+  ASL_FontRequest       = 1;
+  ASL_ScreenModeRequest = 2;
+
+
+{****************************************************************************
+
+  ASL File Requester data structures and constants
+
+  This structure must only be allocated by asl.library amd is READ-ONLY!
+  Control of the various fields is provided via tags when the requester
+  is created with AllocAslRequest() and when it is displayed via
+  AslRequest() }
+
+type
+  PFileRequester = ^TFileRequester;
+  TFileRequester = record
+    fr_Reserved0: array[0..3] of byte;
+    fr_File: STRPTR;        // User selected file
+    fr_Drawer: STRPTR;      // User selected drawer
+    fr_Reserved1: array[0..9] of byte;
+    fr_LeftEdge: SmallInt;
+    fr_TopEdge: SmallInt;   // Requester size/placement on exit
+    fr_Width: SmallInt;
+    fr_Height: SmallInt;
+    fr_Reserved2: array[0..1] of byte;
+    fr_NumArgs: LongInt;    // How many files were selected ?
+    fr_ArgList: PWBArgList; // Selected files
+    fr_UserData: APTR;
+    fr_Reserved3: array[0..7] of byte;
+    fr_Pattern: STRPTR;     // Pattern on exit
+  end;
+
+
+// File requester tag values, used by AllocAslRequest() and AslRequest()
+
+const
+// Window control
+  ASLFR_Window        = ASL_Dummy + 2;   // (PWindow) Parent window
+  ASLFR_Screen        = ASL_Dummy + 40;  // (PScreen) Screen to open on if no window
+  ASLFR_PubScreenName = ASL_Dummy + 41;  // (STRPTR) Name of public screen
+  ASLFR_PrivateIDCMP  = ASL_Dummy + 42;  // (Bool) Allocate private IDCMP?
+  ASLFR_IntuiMsgFunc  = ASL_Dummy + 70;  // (PHook) function to handle IntuiMessages
+  ASLFR_SleepWindow   = ASL_Dummy + 43;  // (Bool) Block input in ASLFR_Window?
+  ASLFR_UserData      = ASL_Dummy + 52;  // (APTR) What to put in fr_UserData
+  ASLFR_PopToFront    = ASL_Dummy + 131; // (Bool) Make the requester window visible
+  ASLFR_Activate      = ASL_Dummy + 132; // (Bool) Activate the requester window when
+
+// Text display
+  ASLFR_TextAttr     = ASL_Dummy + 51; // (PTextAttr) Text font to use for gadget text
+  ASLFR_Locale       = ASL_Dummy + 50; // (PLocale) Locale ASL should use for text
+  ASLFR_TitleText    = ASL_Dummy + 1;  // (STRPTR) Title of requester
+  ASLFR_PositiveText = ASL_Dummy + 18; // (STRPTR) Positive gadget text
+  ASLFR_NegativeText = ASL_Dummy + 19; // (STRPTR) Negative gadget text
+
+// Initial settings
+  ASLFR_InitialLeftEdge    = ASL_Dummy + 3;   // (SmallInt) Initial requester coordinates
+  ASLFR_InitialTopEdge     = ASL_Dummy + 4;
+  ASLFR_InitialWidth       = ASL_Dummy + 5;   // (SmallInt) Initial requester dimensions
+  ASLFR_InitialHeight      = ASL_Dummy + 6;
+  ASLFR_InitialFile        = ASL_Dummy + 8;   // (STRPTR) Initial contents of File gadget
+  ASLFR_InitialDrawer      = ASL_Dummy + 9;   // (STRPTR) Initial contents of Drawer gadg.
+  ASLFR_InitialPattern     = ASL_Dummy + 10;  // (STRPTR) Initial contents of Pattern gadg.
+  ASLFR_InitialShowVolumes = ASL_Dummy + 130; // (Bool) Initially, show the volume list (V44)
+
+// Options
+  ASLFR_Flags1        = ASL_Dummy + 20; // (LongWord) Option flags
+  ASLFR_Flags2        = ASL_Dummy + 22; // (LongWord) Additional option flags
+  ASLFR_DoSaveMode    = ASL_Dummy + 44; // (Bool) Being used for saving?
+  ASLFR_DoMultiSelect = ASL_Dummy + 45; // (Bool) Do multi-select?
+  ASLFR_DoPatterns    = ASL_Dummy + 46; // (Bool) Display a Pattern gadget?
+
+// Filtering
+  ASLFR_DrawersOnly   = ASL_Dummy + 47; // (Bool) Don't display files?
+  ASLFR_FilterFunc    = ASL_Dummy + 49; // deprecated
+  ASLFR_RejectIcons   = ASL_Dummy + 60; // (Bool) Display .info files?
+  ASLFR_RejectPattern = ASL_Dummy + 61; // STRPTR) Don't display files matching pat
+  ASLFR_AcceptPattern = ASL_Dummy + 62; // STRPTR) Accept only files matching pat
+  ASLFR_FilterDrawers = ASL_Dummy + 63; // (Bool) Also filter drawers with patterns
+  ASLFR_HookFunc      = ASL_Dummy + 7;  // (PHook) Combined callback function
+
+// Sorting
+  ASLFR_SetSortBy      = ASL_Dummy + 124; // (LongWord) Sort criteria (name, date, size)
+  ASLFR_GetSortBy      = ASL_Dummy + 125; // (PLongWord)
+  ASLFR_SetSortDrawers = ASL_Dummy + 126; // (LongWord) Placement of drawers in the list
+  ASLFR_GetSortDrawers = ASL_Dummy + 127; // (PLongWord)
+  ASLFR_SetSortOrder   = ASL_Dummy + 128; // (LongWord) Order (ascending or descending)
+  ASLFR_GetSortOrder   = ASL_Dummy + 129;
+
+  ASLFR_StayOnTop      = ASL_Dummy + 142; // (BOOL) Force the requester to stay on top of other windows
+
+// Flag bits for the ASLFR_Flags1 tag
+  FRB_FILTERFUNC    = 7; // deprecated
+  FRB_INTUIFUNC     = 6; // deprecated
+  FRB_DOSAVEMODE    = 5;
+  FRB_PRIVATEIDCMP  = 4;
+  FRB_DOMULTISELECT = 3;
+  FRB_DOPATTERNS    = 0;
+
+  FRF_FILTERFUNC    = 1 shl FRB_FILTERFUNC;  // deprecated
+  FRF_INTUIFUNC     = 1 shl FRB_INTUIFUNC;   // deprecated
+  FRF_DOSAVEMODE    = 1 shl FRB_DOSAVEMODE;
+  FRF_PRIVATEIDCMP  = 1 shl FRB_PRIVATEIDCMP;
+  FRF_DOMULTISELECT = 1 shl FRB_DOMULTISELECT;
+  FRF_DOPATTERNS    = 1 shl FRB_DOPATTERNS;
+
+// Flag bits for the ASLFR_Flags2 tag
+  FRB_DRAWERSONLY   = 0;
+  FRB_FILTERDRAWERS = 1;
+  FRB_REJECTICONS   = 2;
+
+  FRF_DRAWERSONLY   = 1 shl FRB_DRAWERSONLY;
+  FRF_FILTERDRAWERS = 1 shl FRB_FILTERDRAWERS;
+  FRF_REJECTICONS   = 1 shl FRB_REJECTICONS;
+
+// Sort criteria for the ASLFR_SetSortBy/ASLFR_GetSortBy tags
+  ASLFRSORTBY_Name = 0;
+  ASLFRSORTBY_Date = 1;
+  ASLFRSORTBY_Size = 2;
+
+// Drawer placement for the ASLFR_SetSortDrawers/ASLFR_GetSortDrawers tags
+  ASLFRSORTDRAWERS_First = 0;
+  ASLFRSORTDRAWERS_Mix   = 1;
+  ASLFRSORTDRAWERS_Last  = 2;
+
+// Sort order for the ASLFR_SetSortOrder/ASLFR_GetSortOrder tags
+  ASLFRSORTORDER_Ascend  = 0;
+  ASLFRSORTORDER_Descend = 1;
+
+{****************************************************************************
+
+  ASL Font Requester data structures and constants
+
+  This structure must only be allocated by asl.library amd is READ-ONLY!
+  Control of the various fields is provided via tags when the requester
+  is created with AllocAslRequest() and when it is displayed via
+  AslRequest()}
+
+Type
+  PFontRequester = ^TFontRequester;
+  TFontRequester = record
+    fo_Reserved0: array[0..7] of byte;
+    fo_Attr: TTextAttr;    // Returned TextAttr
+    fo_FrontPen: byte;     // Returned front pen
+    fo_BackPen: byte;      // Returned back pen
+    fo_DrawMode: byte;     // Returned drawing mode
+    fo_Reserved1: byte;
+    fo_UserData: Pointer;  // You can store your own data here
+    fo_LeftEdge: SmallInt; // Coordinates Of requester on Exit
+    fo_TopEdge: SmallInt;
+    fo_Width: SmallInt;
+    fo_Height: SmallInt;
+    fo_TAttr: TTTextAttr;  // Returned TTextAttr
+  end;
+
+
+// Font requester tag values, used by AllocAslRequest() AND AslRequest()
+
+const
+// Window control
+  ASLFO_Window        = ASL_Dummy + 2;   // Parent window
+  ASLFO_Screen        = ASL_Dummy + 40;  // Screen to open on if no window
+  ASLFO_PubScreenName = ASL_Dummy + 41;  // Name of public screen
+  ASLFO_PrivateIDCMP  = ASL_Dummy + 42;  // Allocate private IDCMP?
+  ASLFO_IntuiMsgFunc  = ASL_Dummy + 70;  // function to handle IntuiMessages
+  ASLFO_SleepWindow   = ASL_Dummy + 43;  // Block input in ASLFO_Window?
+  ASLFO_UserData      = ASL_Dummy + 52;  // What to put in fo_UserData
+  ASLFO_PopToFront    = ASL_Dummy + 131; // Make the requester window visible when it opens (V44)
+  ASLFO_Activate      = ASL_Dummy + 132; // Activate the requester window when it opens (V45).
+
+// Text display
+  ASLFO_TextAttr     = ASL_Dummy + 51; // Text font to use for gadget text
+  ASLFO_Locale       = ASL_Dummy + 50; // Locale ASL should use for text
+  ASLFO_TitleText    = ASL_Dummy + 1 ; // Title of requester
+  ASLFO_PositiveText = ASL_Dummy + 18; // Positive gadget text
+  ASLFO_NegativeText = ASL_Dummy + 19; // Negative gadget text
+
+// Initial settings
+  ASLFO_InitialLeftEdge = ASL_Dummy + 3;  // Initial requester coordinates
+  ASLFO_InitialTopEdge  = ASL_Dummy + 4;
+  ASLFO_InitialWidth    = ASL_Dummy + 5;  // Initial requester dimensions
+  ASLFO_InitialHeight   = ASL_Dummy + 6;
+  ASLFO_InitialName     = ASL_Dummy + 10; // Initial contents of Name gadget
+  ASLFO_InitialSize     = ASL_Dummy + 11; // Initial contents of Size gadget
+  ASLFO_InitialStyle    = ASL_Dummy + 12; // Initial font style
+  ASLFO_InitialFlags    = ASL_Dummy + 13; // Initial font flags for TextAttr
+  ASLFO_InitialFrontPen = ASL_Dummy + 14; // Initial front pen
+  ASLFO_InitialBackPen  = ASL_Dummy + 15; // Initial back pen
+  ASLFO_InitialDrawMode = ASL_Dummy + 59; // Initial draw mode
+
+// Options
+  ASLFO_Flags      = ASL_Dummy + 20;  // Option flags
+  ASLFO_DoFrontPen = ASL_Dummy + 44;  // Display Front color selector?
+  ASLFO_DoBackPen  = ASL_Dummy + 45;  // Display Back color selector?
+  ASLFO_DoStyle    = ASL_Dummy + 46;  // Display Style checkboxes?
+  ASLFO_DoDrawMode = ASL_Dummy + 47;  // Display DrawMode cycle gadget?
+  ASLFO_SampleText = ASL_Dummy + 133; // Text to display in font sample area (V45)
+
+// Filtering
+  ASLFO_FixedWidthOnly = ASL_Dummy + 48; // Only allow fixed-width fonts?
+  ASLFO_MinHeight      = ASL_Dummy + 16; // Minimum font height to display
+  ASLFO_MaxHeight      = ASL_Dummy + 17; // Maximum font height to display
+  ASLFO_FilterFunc     = ASL_Dummy + 49; // function to filter fonts
+  ASLFO_HookFunc       = ASL_Dummy + 7;  // Combined callback function
+  ASLFO_MaxFrontPen    = ASL_Dummy + 66; // Max # of colors in front palette
+  ASLFO_MaxBackPen     = ASL_Dummy + 67; // Max # of colors in back palette
+
+// Custom additions
+  ASLFO_ModeList  = ASL_Dummy + 21; // Substitute list for drawmodes
+  ASLFO_FrontPens = ASL_Dummy + 64; // Color table for front pen palette
+  ASLFO_BackPens  = ASL_Dummy + 65; // Color table for back pen palette
+
+// Flag bits for ASLFO_Flags tag
+  FOB_DOFRONTPEN     = 0;
+  FOB_DOBACKPEN      = 1;
+  FOB_DOSTYLE        = 2;
+  FOB_DODRAWMODE     = 3;
+  FOB_FIXEDWIDTHONLY = 4;
+  FOB_PRIVATEIDCMP   = 5;
+  FOB_INTUIFUNC      = 6;
+  FOB_FILTERFUNC     = 7;
+
+  FOF_DOFRONTPEN     = 1 shl FOB_DOFRONTPEN;
+  FOF_DOBACKPEN      = 1 shl FOB_DOBACKPEN;
+  FOF_DOSTYLE        = 1 shl FOB_DOSTYLE;
+  FOF_DODRAWMODE     = 1 shl FOB_DODRAWMODE;
+  FOF_FIXEDWIDTHONLY = 1 shl FOB_FIXEDWIDTHONLY;
+  FOF_PRIVATEIDCMP   = 1 shl FOB_PRIVATEIDCMP;
+  FOF_INTUIFUNC      = 1 shl FOB_INTUIFUNC;
+  FOF_FILTERFUNC     = 1 shl FOB_FILTERFUNC;
+
+{****************************************************************************
+
+  ASL Screen Mode Requester data structures and constants
+
+  This structure must only be allocated by asl.library and is READ-ONLY!
+  Control of the various fields is provided via tags when the requester
+  is created with AllocAslRequest() and when it is displayed via
+  AslRequest() }
+
+type
+  PScreenModeRequester = ^TScreenModeRequester;
+  TScreenModeRequester = record
+    sm_DisplayID: LongWord;     // Display mode ID
+    sm_DisplayWidth: LongWord;  // Width Of display IN pixels
+    sm_DisplayHeight: LongWord; // Height Of display IN pixels
+    sm_DisplayDepth: word;      // Number OF bit-planes OF display
+    sm_OverscanType: word;      // TYPE OF overscan OF display
+    sm_AutoScroll: WordBool;    // Display should auto-scroll?
+
+    sm_BitMapWidth: LongWord;    // Used TO create your own BitMap
+    sm_BitMapHeight: LongWord;
+
+    sm_LeftEdge: SmallInt;       // Coordinates OF requester on Exit
+    sm_TopEdge: SmallInt;
+    sm_Width: SmallInt;
+    sm_Height: SmallInt;
+
+    sm_InfoOpened: WordBool;     // Info window opened on exit?
+    sm_InfoLeftEdge: SmallInt;   // Last coordinates OF Info window
+    sm_InfoTopEdge: SmallInt;
+    sm_InfoWidth: SmallInt;
+    sm_InfoHeight: SmallInt;
+
+    sm_UserData: APTR;           // You can store your own data here
+  end;
+
+{ An Exec list of custom modes can be added to the list of available modes.
+  The DimensionInfo structure must be completely initialized, including the
+  Header. See <graphics/displayinfo.h>. Custom mode ID's must be in the range
+  $FFFF0000..$FFFFFFFF. Regular properties which apply to your custom modes
+  can be added in the dn_PropertyFlags field. Custom properties are not
+  allowed. }
+
+  PDisplayMode = ^TDisplayMode;
+  TDisplayMode = record
+    dm_Node: TNode;                   // see ln_Name
+    dm_DimensionInfo: TDimensionInfo; // mode description
+    dm_PropertyFlags: LongWord;       // applicable properties
+  end;
+
+// ScreenMode requester tag values, used by AllocAslRequest() and AslRequest()
+const
+// Window control
+  ASLSM_Window        = ASL_Dummy + 2;   // Parent window
+  ASLSM_Screen        = ASL_Dummy + 40;  // Screen to open on if no window
+  ASLSM_PubScreenName = ASL_Dummy + 41;  // Name of public screen
+  ASLSM_PrivateIDCMP  = ASL_Dummy + 42;  // Allocate private IDCMP?
+  ASLSM_IntuiMsgFunc  = ASL_Dummy + 70;  // function to handle IntuiMessages
+  ASLSM_SleepWindow   = ASL_Dummy + 43;  // Block input in ASLSM_Window?
+  ASLSM_UserData      = ASL_Dummy + 52;  // What to put in sm_UserData
+  ASLSM_PopToFront    = ASL_Dummy + 131; // Make the requester window visible  when it opens (V44)
+  ASLSM_Activate      = ASL_Dummy + 132; // Activate the requester window when it opens (V45).
+
+// Text display
+  ASLSM_TextAttr     = ASL_Dummy + 51; // Text font to use for gadget text
+  ASLSM_Locale       = ASL_Dummy + 50; // Locale ASL should use for text
+  ASLSM_TitleText    = ASL_Dummy + 1;  // Title of requester
+  ASLSM_PositiveText = ASL_Dummy + 18; // Positive gadget text
+  ASLSM_NegativeText = ASL_Dummy + 19; // Negative gadget text
+
+// Initial settings
+  ASLSM_InitialLeftEdge      = ASL_Dummy + 3;   // Initial requester coordinates
+  ASLSM_InitialTopEdge       = ASL_Dummy + 4;
+  ASLSM_InitialWidth         = ASL_Dummy + 5;   // Initial requester dimensions
+  ASLSM_InitialHeight        = ASL_Dummy + 6;
+  ASLSM_InitialDisplayID     = ASL_Dummy + 100; // Initial display mode id
+  ASLSM_InitialDisplayWidth  = ASL_Dummy + 101; // Initial display width
+  ASLSM_InitialDisplayHeight = ASL_Dummy + 102; // Initial display height
+  ASLSM_InitialDisplayDepth  = ASL_Dummy + 103; // Initial display depth
+  ASLSM_InitialOverscanType  = ASL_Dummy + 104; // Initial type of overscan
+  ASLSM_InitialAutoScroll    = ASL_Dummy + 105; // Initial autoscroll setting
+  ASLSM_InitialInfoOpened    = ASL_Dummy + 106; // Info wndw initially opened?
+  ASLSM_InitialInfoLeftEdge  = ASL_Dummy + 107; // Initial Info window coords.
+  ASLSM_InitialInfoTopEdge   = ASL_Dummy + 108;
+
+// Options
+  ASLSM_DoWidth        = ASL_Dummy + 109; // Display Width gadget?
+  ASLSM_DoHeight       = ASL_Dummy + 110; // Display Height gadget?
+  ASLSM_DoDepth        = ASL_Dummy + 111; // Display Depth gadget?
+  ASLSM_DoOverscanType = ASL_Dummy + 112; // Display Overscan Type gadget?
+  ASLSM_DoAutoScroll   = ASL_Dummy + 113; // Display AutoScroll gadget?
+
+// Filtering
+  ASLSM_PropertyFlags = ASL_Dummy + 114; // Must have these Property flags
+  ASLSM_PropertyMask  = ASL_Dummy + 115; // Only these should be looked at
+  ASLSM_MinWidth      = ASL_Dummy + 116; // Minimum display width to allow
+  ASLSM_MaxWidth      = ASL_Dummy + 117; // Maximum display width to allow
+  ASLSM_MinHeight     = ASL_Dummy + 118; // Minimum display height to allow
+  ASLSM_MaxHeight     = ASL_Dummy + 119; // Maximum display height to allow
+  ASLSM_MinDepth      = ASL_Dummy + 120; // Minimum display depth
+  ASLSM_MaxDepth      = ASL_Dummy + 121; // Maximum display depth
+  ASLSM_FilterFunc    = ASL_Dummy + 122; // function to filter mode id's
+
+// Custom additions
+  ASLSM_CustomSMList = ASL_Dummy + 123; // Exec list of struct DisplayMode
+
+  ASL_LAST_TAG = ASL_Dummy + 133;
+
+
+{ This defines the rendezvous data for setting and querying asl.library's
+  defaults for the window size and the file requester sort order. The name
+  of the semaphore is given below; it exists only with asl.library V45 and
+  IPrefs V45 and beyond.}
+  ASL_SEMAPHORE_NAME: PChar = 'asl.library';
+
+type
+  PASLSemaphore = ^TASLSemaphore;
+  TASLSemaphore = record
+    as_Semaphore: TSignalSemaphore;
+    as_Version: word;          // Must be >= 45
+    as_Size: LongWord;         // Size of this data structure. }
+    as_SortBy: byte;           // File requester defaults; name, date or size }
+    as_SortDrawers: byte;      // File requester defaults; first, mix or last }
+    as_SortOrder: byte;        // File requester defaults; ascending or descending }
+    as_SizePosition: byte;     // See below }
+    as_RelativeLeft: Smallint; // Window position offset }
+    as_RelativeTop: Smallint;
+    as_RelativeWidth: byte;    // Window size factor; this is a percentage of the parent window/screen width.
+    as_RelativeHeight: byte;
+   end;
+
+const
+// Default position of the ASL window.
+  ASLPOS_DefaultPosition = 0; // Position is calculated according to the builtin rules.
+  ASLPOS_CenterWindow    = 1; // Centred within the bounds of the parent window.
+  ASLPOS_CenterScreen    = 2; // Centred within the bounds of the parent screen.
+  ASLPOS_WindowPosition  = 3; // Relative to the top left corner of the parent window, using the offset values provided in the as_RelativeLeft/as_RelativeTop members.
+  ASLPOS_ScreenPosition  = 4; // Relative to the top left corner of the parent screen, using the offset values provided in the as_RelativeLeft/as_RelativeTop members.
+  ASLPOS_CenterMouse     = 5; // Directly below the mouse pointer.
+  ASLPOS_MASK            = $0F;
+
+// Default size of the ASL window.
+  ASLSIZE_DefaultSize  = 0 shl 4; // Size is calculated according to the builtin rules.
+  ASLSIZE_RelativeSize = 1 shl 4; // Size is relative to the size of the parent window or screen, using the values provided in
+                                  // the as_RelativeWidth/as_RelativeHeight members. The as_RelativeWidth/as_RelativeHeight values are
+                                  // taken as percentage, i.e. a value of "50" stands for 50% of the width/height of the parent window/screen.
+  ASLSIZE_MASK         = $30;
+
+// Other options.
+  ASLOPTION_ASLOverrides = 1 shl 6; // ASL determines placement and size of requester windows; application's choice is ignored.
+
+
+{****************************************************************************
+
+  Obsolete ASL definitions, here for source code compatibility only.
+  Please do NOT use in new code.
+
+    define ASL_V38_NAMES_ONLY to remove these older names
+ }
+{$define ASL_V38_NAMES_ONLY}
+{$ifndef ASL_V38_NAMES_ONLY}
+const
+
+  TFileRequesterV38 = record
+    rf_Reserved0: array[0..3] of byte;
+    rf_File: STRPTR;         // Filename pointer
+    rf_Dir: STRPTR;          // Directory name pointer
+    rf_Reserved1: array[0..9] of Byte;
+    rf_LeftEdge: SmallInt;
+    rf_TopEdge: SmallInt;    // Preferred window pos
+    rf_Width: SmallInt;
+    rf_Height: SmallInt;     // Preferred window size
+    rf_Reserved2: array[0..1] of Byte;
+    rf_NumArgs: LongInt;     // A-la WB Args, FOR multiselects
+    rf_ArgList: PWBArgList;
+    rf_UserData: Pointer;    // Applihandle (you may write!!)
+    rf_Reserved3: array[0..7] of Byte;
+    rf_Pat: STRPTR;          // Pattern match pointer
+  end;                       // note - more reserved fields follow
+
+  ASL_Dummy       = TAG_USER + $80000;
+  ASL_Hail        = ASL_Dummy + 1;
+  ASL_Window      = ASL_Dummy + 2;
+  ASL_LeftEdge    = ASL_Dummy + 3;
+  ASL_TopEdge     = ASL_Dummy + 4;
+  ASL_Width       = ASL_Dummy + 5;
+  ASL_Height      = ASL_Dummy + 6;
+  ASL_HookFunc    = ASL_Dummy + 7;
+  ASL_File        = ASL_Dummy + 8;
+  ASL_Dir         = ASL_Dummy + 9;
+  ASL_FontName    = ASL_Dummy + 10;
+  ASL_FontHeight  = ASL_Dummy + 11;
+  ASL_FontStyles  = ASL_Dummy + 12;
+  ASL_FontFlags   = ASL_Dummy + 13;
+  ASL_FrontPen    = ASL_Dummy + 14;
+  ASL_BackPen     = ASL_Dummy + 15;
+  ASL_MinHeight   = ASL_Dummy + 16;
+  ASL_MaxHeight   = ASL_Dummy + 17;
+  ASL_OKText      = ASL_Dummy + 18;
+  ASL_CancelText  = ASL_Dummy + 19;
+  ASL_FuncFlags   = ASL_Dummy + 20;
+  ASL_ModeList    = ASL_Dummy + 21;
+  ASL_ExtFlags1   = ASL_Dummy + 22;
+  ASL_Pattern     = ASL_FontName;
+// remember what I said up there? Do not use these anymore!
+  FILB_DOWILDFUNC  = 7;
+  FILB_DOMSGFUNC   = 6;
+  FILB_SAVE        = 5;
+  FILB_NEWIDCMP    = 4;
+  FILB_MULTISELECT = 3;
+  FILB_PATGAD      = 0;
+  FILF_DOWILDFUNC  = 128;
+  FILF_DOMSGFUNC   = 64;
+  FILF_SAVE        = 32;
+  FILF_NEWIDCMP    = 16;
+  FILF_MULTISELECT = 8;
+  FILF_PATGAD      = 1;
+  FIL1B_NOFILES    = 0;
+  FIL1B_MATCHDIRS  = 1;
+  FIL1F_NOFILES    = 1;
+  FIL1F_MATCHDIRS  = 2;
+  FONB_FRONTCOLOR  = 0;
+  FONB_BACKCOLOR   = 1;
+  FONB_STYLES      = 2;
+  FONB_DRAWMODE    = 3;
+  FONB_FIXEDWIDTH  = 4;
+  FONB_NEWIDCMP    = 5;
+  FONB_DOMSGFUNC   = 6;
+  FONB_DOWILDFUNC  = 7;
+  FONF_FRONTCOLOR  = 1;
+  FONF_BACKCOLOR   = 2;
+  FONF_STYLES      = 4;
+  FONF_DRAWMODE    = 8;
+  FONF_FIXEDWIDTH  = 16;
+  FONF_NEWIDCMP    = 32;
+  FONF_DOMSGFUNC   = 64;
+  FONF_DOWILDFUNC  = 128;
+{$endif ASL_V38_NAMES_ONLY}
+
+var
+  ASLBase: PLibrary;
+  IASL: PInterface;
+
+function ASLObtain(): LongWord; syscall IDos 60;
+function ASLRelease(): LongWord; syscall IDos 64;
+procedure ASLExpunge(); syscall IDos 68;
+function ASLClone(): PInterface; syscall IDos 72;
+function AllocFileRequest: PFileRequester; syscall IASL 76;
+procedure FreeFileRequest(FileReq: PFileRequester); syscall IASL 80;
+function RequestFile(FileReq: PFileRequester): LongBool; syscall IASL 84;
+function AllocAslRequestA(ReqType: LongWord; TagList: PTagItem): Pointer; syscall IASL 88;
+// 92 AllocAslRequestTags
+procedure FreeAslRequest(Requester: Pointer); syscall IASL 96;
+function AslRequestA(Requester: Pointer; TagList: PTagItem): LongBool; syscall IASL 100;
+// 104 AslRequestTags
+procedure AslFreeVec(Memory: APTR); syscall IASL 108;
+function AslAllocVec(ByteSize: LongWord; Attributes: LongWord): APTR; syscall IASL 112;
+procedure AbortAslRequest(Requester: APTR); syscall IASL 116;
+procedure ActivateAslRequest(Requester: APTR); syscall IASL 120;
+function AslControl(const Tags: PTagItem): LongWord; syscall IASL 124;
+// 128 AslControlTags
+
+function AllocAslRequest(ReqType: LongWord; const Tags: array of PtrUInt): Pointer;
+function AslRequest(Requester: Pointer; const Tags: array of PtrUInt): LongBool;
+function AslRequestTags(Requester: Pointer; const Tags: array of PtrUInt): LongBool;
+
+implementation
+
+function AllocAslRequest(ReqType: LongWord; const Tags: array of PtrUInt): Pointer; inline;
+begin
+  AllocAslRequest := AllocAslRequestA(reqType, @Tags);
+end;
+
+function AslRequest(Requester: Pointer; const Tags: array of PtrUInt): LongBool; inline;
+begin
+  AslRequest := AslRequestA(Requester, @Tags);
+end;
+
+function AslRequestTags(Requester: Pointer; const Tags: array of PtrUInt): LongBool; inline;
+begin
+  AslRequestTags := AslRequestA(Requester, @Tags);
+end;
+
+initialization
+  ASLBase := OpenLibrary(ASLNAME, 36);
+  if Assigned(ASLBase) then
+    IASL := GetInterface(ASLBase, 'main', 1, nil);
+finalization
+  if Assigned(IASL) then
+    DropInterface(IASL);
+  if Assigned(ASLBase) then
+    CloseLibrary(ASLBase);
+end.
+
+

+ 488 - 0
packages/os4units/src/diskfont.pas

@@ -0,0 +1,488 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2014-2016 by Free Pascal development team
+
+    diskfont.library functions
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+unit diskfont;
+
+interface
+
+uses
+  exec, agraphics,utility;
+
+const
+  MAXFONTPATH = 256; // including null terminator
+
+type
+  PFontContents = ^TFontContents;
+  TFontContents = record
+    fc_FileName: array[0..MAXFONTPATH - 1] of Char;
+    fc_YSize: Word;
+    fc_Style: Byte;
+    fc_Flags: Byte;
+  end;
+
+  PTFontContents = ^TTFontContents;
+  TTFontContents = record
+    tfc_FileName: array[0..MAXFONTPATH - 3] of Char;
+    tfc_TagCount: Word;  // including the TAG_DONE tag
+    // if tfc_TagCount is non-zero, tfc_FileName is overlayed with Text Tags starting at:
+    //     PTagItem(@tfc_FileName[MAXFONTPATH - (tfc_TagCount * sizeof(TTagItem))])
+    tfc_YSize: Word;
+    tfc_Style: Byte;
+    tfc_Flags: Byte;
+   end;
+
+const
+  FCH_ID   = $0f00; // FontContentsHeader, then FontContents
+  TFCH_ID  = $0f02; // FontContentsHeader, then TFontContents
+  OFCH_ID  = $0f03; // FontContentsHeader, then TFontContents, associated with outline font
+
+type
+  PFontContentsHeader = ^TFontContentsHeader;
+  TFontContentsHeader = record
+    fch_FileID: Word;     // FCH_ID
+    fch_NumEntries: Word; // the number of FontContents elements
+  end;
+
+const
+  DFH_ID = $0f80;
+  MAXFONTNAME = 32; // font name including '.font'#0
+
+type
+  PDiskFontHeader = ^TDiskFontHeader;
+  TDiskFontHeader = record
+    // the following 8 bytes are not actually considered a part of the  DiskFontHeader, but immediately preceed it.
+    // The NextSegment is supplied by the linker/loader, and the ReturnCode is the code at the beginning of the font in case someone runs it...
+    // Warning: you can find those bytes on disk but not in memory.
+    //   uint32 dfh_NextSegment; \* actually a BPTR
+    //   uint32 dfh_ReturnCode;  \* MOVEQ #0,D0 : RTS
+    // here then is the official start of the DiskFontHeader...
+    dfh_DF: TNode;        // node to link disk fonts
+    dfh_FileID: Word;     // DFH_ID
+    dfh_Revision: Word;   // the font revision
+    dfh_Segment: Longint; // the segment address when loaded
+    dfh_Name: array [0..MAXFONTNAME-1] of Char; // stripped font name (null terminated)
+    dfh_TF: TTextFont;    // loaded TextFont structure, dfh_TF.tf_Message.mn_Node.ln_Name points to the full font name
+  end;
+
+// unfortunately, this needs to be explicitly typed used only if dfh_TF.tf_Style FSB_TAGGED bit is set moved to dfh_TF.tf_Extension->tfe_Tags during loading
+const
+  AFB_MEMORY  = 0;     // dont filter out memory fonts
+  AFF_MEMORY  = $0001;
+  AFB_DISK    = 1;     // dont filter out disk fonts
+  AFF_DISK    = $0002;
+  AFB_SCALED  = 2;     // dont filter out scaled fonts
+  AFF_SCALED  = $0004;
+  AFB_BITMAP  = 3;     // filter out .otag files
+  AFF_BITMAP  = $0008;
+  AFB_OTAG    = 4;     // show .otag files only,
+  AFF_OTAG    = $0010; // implemented since V50
+  AFB_CHARSET = 5;     // show fonts in all charsets,
+  AFF_CHARSET = $0020; // implemented since V50
+  AFB_TYPE    = 6;     // return diskfont type in [t]af_Type: AFF_DISK|AFF_BITMAP for bitmap fonts, AFF_DISK|AFF_OTAG for .otag fonts, AFF_DISK|AFF_OTAG|AFF_SCALED for scalable .otag fonts.
+  AFF_TYPE    = $0040; // implemented since V50
+
+  AFB_TAGGED  = 16;
+  AFF_TAGGED  = $10000;
+
+type
+  PAvailFonts = ^TAvailFonts;
+  TAvailFonts = record
+    af_Type: Word;      // AFF_MEMORY, AFF_DISK or AFF_SCALED
+    af_Attr: TTextAttr; // text attributes for font
+  end;
+
+  PTAvailFonts = ^TTAvailFonts;
+  TTAvailFonts = record
+    taf_Type: Word;       // AFF_MEMORY, AFF_DISK or AFF_SCALED
+    taf_Attr: TTTextAttr; // text attributes for font
+  end;
+
+  PAvailFontsHeader = ^TAvailFontsHeader;
+  TAvailFontsHeader = record
+    afh_NumEntries: Word; // number of AvailFonts elements
+     // PAvailFonts afh_AF, or PTAvailFonts afh_TAF;
+  end;
+
+  type
+// A GlyphEngine must be acquired via OpenEngine and is read-only
+  PGlyphEngine = ^TGlyphEngine;
+  TGlyphEngine = record
+    gle_Library: PLibrary; // engine library
+    gle_Name: PChar;       // library basename: e.g. 'bullet'
+    // private library data follows...
+  end;
+
+// FIXED = 32 bit signed w/ 16 bits of fraction */
+
+  PGlyphMap = ^TGlyphMap;
+  TGlyphMap = record
+    glm_BMModulo: Word;    // # of bytes in row: always multiple of 4
+    glm_BMRows: Word;      // # of rows in bitmap
+    glm_BlackLeft: Word;   // # of blank pixel columns at left
+    glm_BlackTop: Word;    // # of blank rows at top
+    glm_BlackWidth: Word;  // span of contiguous non-blank columns
+    glm_BlackHeight: Word; // span of contiguous non-blank rows
+    glm_XOrigin: LongInt;  // FIXED, distance from upper left corner of bitmap
+    glm_YOrigin: LongInt;  // FIXED  to initial CP, in fractional pixels
+    glm_X0: SmallInt;      // approximation of XOrigin in whole pixels
+    glm_Y0: SmallInt;      // approximation of YOrigin in whole pixels
+    glm_X1: SmallInt;      // approximation of XOrigin + Width
+    glm_Y1: SmallInt;      // approximation of YOrigin + Width
+    glm_Width: LongInt;    // FIXED, character advance, as fraction of em width
+    glm_BitMap: PByte;     // actual glyph bitmap
+  end;
+
+  PGlyphWidthEntry = ^TGlyphWidthEntry;
+  TGlyphWidthEntry = record
+    gwe_Node: TMinNode; // on list returned by OT_WidthList inquiry
+    gwe_Code: Word;     // entry's character code value
+    gwe_Width: LongInt; // FIXED character advance, as fraction of em width
+  end;
+
+// Structure returned when asking for OT_WidthList32, the original GlyphWidthEntry structure is limited to 16 bit glyph code (gwe_Code: Word).
+  PGlyphWidthEntry32 = ^TGlyphWidthEntry32;
+  TGlyphWidthEntry32 = record
+    gwe32_Node: TNode;    // on list returned by OT_WidthList32 inquiry
+    gwe32_reserved: Word; // for alignment and backwards compatibility
+    gwe32_Width: LongInt; // FIXED character advance, as fraction of em width
+    gwe32_Code: LongWord; // entry's character code value
+  end;
+
+// structure used by EOpenEngine() ESetInfo() etc (V50)
+  PEGlyphEngine = ^TEGlyphEngine;
+  TEGlyphEngine = record
+    ege_IBullet: PInterface;    // NULL for 68K font engines
+    ege_BulletBase: PLibrary;
+    ege_GlyphEngine: PGlyphEngine;
+  end;
+
+const
+// flags for OpenOutlineFont() (V50)
+  OFB_OPEN = 0;
+  OFF_OPEN = $00000001;
+
+type
+// structure returned by OpenOutlineFont() (V50)
+  POutlineFont = ^TOutlineFont;
+  TOutlineFont = record
+    olf_OTagPath: STRPTR;       // full path & name of the .otag file
+    olf_OTagList: PTagItem;     // relocated .otag file in memory
+    olf_EngineName: STRPTR;     // OT_Engine name
+    olf_LibraryName: STRPTR;    // OT_Engine name + ".library"
+    olf_EEngine: PEGlyphEngine; // All NULL if OFF_OPEN not specified
+    olf_Reserved: APTR;         // for future expansion
+    olf_UserData: APTR;         // for private use
+  end;
+
+const
+  OT_Level0   = TAG_USER;          // Level 0 entries never appear in the .otag tag list, but appear in font specifications
+  OT_Level1   = TAG_USER or $1000; // Level 1 entries are required to exist in the .otag tag list
+  OT_Level2   = TAG_USER or $2000; // Level 2 entries are optional typeface metric tags
+  OT_Level3   = TAG_USER or $3000; // Level 3 entries are required for some OT_Engines
+  OT_Indirect = $8000; // Indirect entries are at (tag address + data offset)
+
+// font specification and inquiry tags
+  OT_DeviceDPI        = OT_Level0 or $01;   // = TA_DeviceDPI
+  OT_DotSize          = OT_Level0 or $02;
+  OT_PointHeight      = OT_Level0 or $08;
+  OT_SetFactor        = OT_Level0 or $09;
+  OT_ShearSin         = OT_Level0 or $0a;
+  OT_ShearCos         = OT_Level0 or $0b;
+  OT_RotateSin        = OT_Level0 or $0c;
+  OT_RotateCos        = OT_Level0 or $0d;
+  OT_EmboldenX        = OT_Level0 or $0e;
+  OT_EmboldenY        = OT_Level0 or $0f;
+  OT_PointSize        = OT_Level0 or $10;
+  OT_GlyphCode        = OT_Level0 or $11;
+  OT_GlyphCode2       = OT_Level0 or $12;
+  OT_GlyphCode_32     = OT_Level0 or $18;
+  OT_GlyphCode2_32    = OT_Level0 or $19;
+  OT_GlyphWidth       = OT_Level0 or $13;
+  OT_OTagPath         = OT_Level0 or OT_Indirect or $14;
+  OT_OTagList         = OT_Level0 or OT_Indirect or $15;
+  OT_MemPtr           = OT_Level0 or OT_Indirect or $16;
+  OT_MemSize          = OT_Level0 or $17;
+  OT_GlyphMap         = OT_Level0 or OT_Indirect or $20;
+  OT_GlyphMap8Bit     = OT_Level0 or OT_Indirect or $1a;
+  OT_GlyphMap8BitLCD  = OT_Level0 or OT_Indirect or $27;
+  OT_GlyphMap8BitLCDV = OT_Level0 or OT_Indirect or $28;
+  OT_WidthList        = OT_Level0 or OT_Indirect or $21;
+  OT_WidthList32      = OT_Level0 or OT_Indirect or $1b;
+  OT_TextKernPair     = OT_Level0 or OT_Indirect or $22;
+  OT_DesignKernPair   = OT_Level0 or OT_Indirect or $23;
+  OT_UnderLined       = OT_Level0 or $24;
+
+  OTUL_None         = 0;
+  OTUL_Solid        = 1;
+  OTUL_Broken       = 2;
+  OTUL_DoubleSolid  = 3;
+  OTUL_DoubleBroken = 4;
+// old versions had a typo here
+  OUTL_DoubleBroken = OTUL_DoubleBroken;
+  OT_StrikeThrough  = OT_Level0 or $25;
+  OT_BaseLine       = OT_Level0 or OT_Indirect or $1c;
+  OT_NumGlyphs      = OT_Level0 or OT_Indirect or $1d;
+  OT_NumKernPairs   = OT_Level0 or OT_Indirect or $1e;
+  OT_HasGlyphs      = OT_Level0 or OT_Indirect or $1f;
+  OT_GlyphName      = OT_Level0 or OT_Indirect or $26;
+
+// .otag tags
+// suffix for files in FONTS: that contain these tags
+  OTSUFFIX       = '.otag';
+  OT_FileIdent   = OT_Level1 or $01;
+  OT_Engine      = OT_Level1 or OT_Indirect or $02;
+  OTE_Bullet     = 'bullet';
+  OT_Family      = OT_Level1 or OT_Indirect or $03;
+  OT_FontFile    = OT_Level2 or OT_Indirect or $24;
+  OT_MetricsFile = OT_Level2 or OT_Indirect or $25;
+  OT_AFMFile     = OT_MetricsFile; // backwards compatibility
+  OT_FontFormat  = OT_Level2 or OT_Indirect or $26;
+
+  OTF_BDF         = 'bdf';         // Adobe Bitmap Distribution Format
+  OTF_CFF         = 'cff';         // Adobe Compact Font Format
+  OTF_Intellifont = 'intellifont'; // Agfa MonoType CompuGraphic
+  OTF_PCF         = 'pcf';         // X Portable Compiled Format
+  OTF_PFR         = 'pfr';         // Bitstream Portable Font Resource
+  OTF_TrueType    = 'truetype';    // AppleorMicroSoft TrueTypeorOpenType
+  OTF_Type1       = 'type1';       // Adobe PostScript Type1
+  OTF_Type1CID    = 't1cid';       // Adobe CID-keyed PostScript Type1
+  OTF_Type42      = 'type42';      // Adobe PostScript Type42
+  OTF_WinFonts    = 'winfonts';    // MicroSoft .fntor.fon
+
+  OT_BName  = OT_Level2 or OT_Indirect or $05;
+  OT_IName  = OT_Level2 or OT_Indirect or $06;
+  OT_BIName = OT_Level2 or OT_Indirect or $07;
+  OT_RName  = OT_Level2 or OT_Indirect or $09;
+  OT_YSizeFactor  = OT_Level1 or $11;
+  OT_SpaceWidth   = OT_Level2 or $12;
+  OT_IsFixed      = OT_Level2 or $13;
+  OT_IsUnderlined = OT_Level2 or $23;
+  OT_SerifFlag    = OT_Level1 or $14;
+  OT_StemWeight   = OT_Level1 or $15;
+
+  OTS_UltraThin  = 8;   //   0- 15
+  OTS_ExtraThin  = 24;  //  16- 31
+  OTS_Thin       = 40;  //  32- 47
+  OTS_ExtraLight = 56;  //  48- 63
+  OTS_Light      = 72;  //  64- 79
+  OTS_DemiLight  = 88;  //  80- 95
+  OTS_SemiLight  = 104; //  96-111
+  OTS_Book       = 120; // 112-127
+  OTS_Medium     = 136; // 128-143
+  OTS_SemiBold   = 152; // 144-159
+  OTS_DemiBold   = 168; // 160-175
+  OTS_Bold       = 184; // 176-191
+  OTS_ExtraBold  = 200; // 192-207
+  OTS_Black      = 216; // 208-223
+  OTS_ExtraBlack = 232; // 224-239
+  OTS_UltraBlack = 248; // 240-255
+
+  OT_SlantStyle  = OT_Level1 or $16;
+  OTS_Upright    = 0;
+  OTS_Italic     = 1; // Oblique, Slanted, etc.
+  OTS_LeftItalic = 2; // Reverse Slant
+  OT_HorizStyle  = OT_Level1 or $17;
+
+  OTH_UltraCompressed = 16;  //   0- 31
+  OTH_ExtraCompressed = 48;  //  32- 63
+  OTH_Compressed      = 80;  //  64- 95
+  OTH_Condensed       = 112; //  96-127
+  OTH_Normal          = 144; // 128-159
+  OTH_SemiExpanded    = 176; // 160-191
+  OTH_Expanded        = 208; // 192-223
+  OTH_ExtraExpanded   = 240; // 224-255
+
+  OT_SpaceFactor      = OT_Level2 or $18;
+  OT_InhibitAlgoStyle = OT_Level2 or $19;
+  OT_AvailSizes       = OT_Level1 or OT_Indirect or $20;
+  OT_MAXAVAILSIZES    = 20; // no more than 20 sizes allowed
+
+  OT_BMSize = OT_Level2 or $21;
+  OT_UnicodeRanges = OT_Level2 or OT_Indirect or $22;
+
+  UCR_BASIC_LATIN                   = 1 shl  0;
+  UCR_LATIN1_SUPPLEMENT             = 1 shl  1;
+  UCR_LATIN_EXTENDED_A              = 1 shl  2;
+  UCR_LATIN_EXTENDED_B              = 1 shl  3;
+  UCR_IPA_EXTENSIONS                = 1 shl  4;
+  UCR_SPACING_MODIFIER              = 1 shl  5;
+  UCR_COMBINING_DIACRITICS          = 1 shl  6;
+  UCR_GREEK                         = 1 shl  7;
+  UCR_CYRILLIC                      = 1 shl  9;
+  UCR_ARMENIAN                      = 1 shl 10;
+  UCR_HEBREW                        = 1 shl 11;
+  UCR_ARABIC                        = 1 shl 13;
+  UCR_DEVANAGARI                    = 1 shl 15;
+  UCR_BENGALI                       = 1 shl 16;
+  UCR_GURMUKHI                      = 1 shl 17;
+  UCR_GUJARATI                      = 1 shl 18;
+  UCR_ORIYA                         = 1 shl 19;
+  UCR_TAMIL                         = 1 shl 20;
+  UCR_TELUGU                        = 1 shl 21;
+  UCR_KANNADA                       = 1 shl 22;
+  UCR_MALAYALAM                     = 1 shl 23;
+  UCR_THAI                          = 1 shl 24;
+  UCR_LAO                           = 1 shl 25;
+  UCR_GEORGIAN                      = 1 shl 26;
+  UCR_HANGUL_JAMO                   = 1 shl 28;
+  UCR_LATIN_EXTENDED_ADDITIONAL     = 1 shl 29;
+  UCR_GREEK_EXTENDED                = 1 shl 30;
+  UCR_GENERAL_PUNCTUATION           = 1 shl 31;
+  UCR_SUPERSCRIPTS_SUBSCRIPTS       = 1 shl  0;
+  UCR_CURRENCY_SYMBOLS              = 1 shl  1;
+  UCR_COMBINING_DIACRITICS_SYMB     = 1 shl  2;
+  UCR_LETTERLIKE_SYMBOLS            = 1 shl  3;
+  UCR_NUMBER_FORMS                  = 1 shl  4;
+  UCR_ARROWS                        = 1 shl  5;
+  UCR_MATHEMATICAL_OPERATORS        = 1 shl  6;
+  UCR_MISCELLANEOUS_TECHNICAL       = 1 shl  7;
+  UCR_CONTROL_PICTURES              = 1 shl  8;
+  UCR_OCR                           = 1 shl  9;
+  UCR_ENCLOSED_ALPHANUMERICS        = 1 shl 10;
+  UCR_BOX_DRAWING                   = 1 shl 11;
+  UCR_BLOCK_ELEMENTS                = 1 shl 12;
+  UCR_GEOMETRIC_SHAPES              = 1 shl 13;
+  UCR_MISCELLANEOUS_SYMBOLS         = 1 shl 14;
+  UCR_DINGBATS                      = 1 shl 15;
+  UCR_CJK_SYMBOLS                   = 1 shl 16;
+  UCR_HIRAGANA                      = 1 shl 17;
+  UCR_KATAKANA                      = 1 shl 18;
+  UCR_BOPOMOFO                      = 1 shl 19;
+  UCR_HANGUL_COMPATIBILITY_JAMO     = 1 shl 20;
+  UCR_CJK_MISC                      = 1 shl 21;
+  UCR_KANBUN                        = UCR_CJK_MISC;
+  UCR_ENCLOSED_CJK_LETTERS_MONTHS   = 1 shl 22;
+  UCR_CJK_COMPATIBILITY             = 1 shl 23;
+  UCR_HANGUL                        = 1 shl 24;
+  UCR_SURROGATES                    = 1 shl 25;
+  UCR_CJK_UNIFIED_IDEOGRAPHS        = 1 shl 27;
+  UCR_PRIVATE_USE                   = 1 shl 28;
+  UCR_CJK_COMPATIBILITY_IDEOGRAPHS  = 1 shl 29;
+  UCR_ALPHABETIC_PRESENTATION_FORMS = 1 shl 30;
+  UCR_ARABIC_PRESENTATIONS_A        = 1 shl 31;
+  UCR_COMBINING_HALF_MARKS          = 1 shl  0;
+  UCR_CJK_COMPATIBILITY_FORMS       = 1 shl  1;
+  UCR_SMALL_FORM_VARIANTS           = 1 shl  2;
+  UCR_ARABIC_PRESENTATIONS_B        = 1 shl  3;
+  UCR_HALFWIDTH_FULLWIDTH_FORMS     = 1 shl  4;
+  UCR_SPECIALS                      = 1 shl  5;
+  UCR_TIBETAN                       = 1 shl  6;
+  UCR_SYRIAC                        = 1 shl  7;
+  UCR_THAANA                        = 1 shl  8;
+  UCR_SINHALA                       = 1 shl  9;
+  UCR_MYANMAR                       = 1 shl 10;
+  UCR_ETHIOPIC                      = 1 shl 11;
+  UCR_CHEROKEE                      = 1 shl 12;
+  UCR_CANADIAN_ABORIGINAL_SYLLABICS = 1 shl 13;
+  UCR_OGHAM                         = 1 shl 14;
+  UCR_RUNIC                         = 1 shl 15;
+  UCR_KHMER                         = 1 shl 16;
+  UCR_MONGOLIAN                     = 1 shl 17;
+  UCR_BRAILLE                       = 1 shl 18;
+  UCR_YI                            = 1 shl 19;
+
+  OT_SpecCount = OT_Level1 or $100;
+  OT_Spec      = OT_Level1 or $100;
+  OT_Spec1     = OT_Level1 or $101;
+
+// GetDiskFontCtrl and SetDiskFontCtrl tags
+  DFCTRL_BASE         = TAG_USER + $0B000000;
+
+  DFCTRL_XDPI         = DFCTRL_BASE + 1;  // X and Y DPI device default settings for the bullet library font generator. Default is 72 dpi.
+  DFCTRL_YDPI         = DFCTRL_BASE + 2;
+  DFCTRL_XDOTP        = DFCTRL_BASE + 3;  // X and Y DPI dot size settings for the font generator. Default is 100dpi.
+  DFCTRL_YDOTP        = DFCTRL_BASE + 4;
+  DFCTRL_CACHE        = DFCTRL_BASE + 5;  // AvailFonts cache enable flag. Either TRUE or FALSE.
+  DFCTRL_SORTMODE     = DFCTRL_BASE + 6;  // Availfonts font sorting flag. See below for available values.
+
+  DFCTRL_SORT_OFF     = 0;   // No sorting: Default.
+
+  DFCTRL_SORT_ASC     = 1;     // Ascending sort order, localized with default locale.
+  DFCTRL_SORT_DES     = not 0; // Descending sort order, localized with default locale.
+  DFCTRL_CACHEFLUSH   = DFCTRL_BASE + 7; // Flush the cache? = BOOL; If TRUE, a cache flush is initiated.
+  DFCTRL_CHARSET      = DFCTRL_BASE + 8; // Default character set identifier = LongWord;.
+  DFCTRL_ANTIALIASING = DFCTRL_BASE + 9;
+  DFCS_NUMBER         = DFCTRL_BASE + 0;
+  DFCS_NEXTNUMBER     = DFCTRL_BASE + 1; // Next IANA CharSet number = ULONG; for browsing charsets. The lowest possible number to start from is 3.
+  DFCS_NAME           = DFCTRL_BASE + 2; // IANA CharSet name = STRPTR;
+  DFCS_MIMENAME       = DFCTRL_BASE + 3; // IANA CharSet name for MIME = STRPTR;
+  DFCS_MAPTABLE       = DFCTRL_BASE + 4; // { Pointer to mapping table of 256 ULONGs from CharSet to Unicode = PLongWord;
+
+// PRELIMINARY
+  OTERR_Failure      = -1; // catch-all for error
+  OTERR_Success      =  0; // no error
+  OTERR_BadTag       =  1; // inappropriate tag for function
+  OTERR_UnknownTag   =  2; // unknown tag for function
+  OTERR_BadData      =  3; // catch-all for bad tag data
+  OTERR_NoMemory     =  4; // insufficient memory for operation
+  OTERR_NoFace       =  5; // no typeface currently specified
+  OTERR_BadFace      =  6; // typeface specification problem
+  OTERR_NoGlyph      =  7; // no glyph specified
+  OTERR_BadGlyph     =  8; // bad glyph code or glyph range
+  OTERR_NoShear      =  9; // shear only partially specified
+  OTERR_NoRotate     = 10; // rotate only partially specified
+  OTERR_TooSmall     = 11; // typeface metrics yield tiny glyphs
+  OTERR_UnknownGlyph = 12; // glyph not known by engine
+
+const
+  DISKFONTNAME: PChar = 'diskfont.library';
+
+var
+  DiskfontBase: PLibrary;
+  IDiskfont: PInterface;
+
+function DiskfontObtain(): LongWord; syscall IDiskfont 60;
+function DiskfontRelease(): LongWord; syscall IDiskfont 64;
+procedure DiskfontExpunge(); syscall IDiskfont 68;
+function DiskfontClone(): PInterface; syscall IDiskfont 72;
+function OpenDiskFont(TextAttr: PTextAttr): PTextFont; syscall IDiskfont 76;
+function AvailFonts(Buffer: STRPTR; BufBytes: LongInt; Flags: LongWord): LongInt; syscall IDiskfont 80;
+function NewFontContents(FontsLock: BPTR; const FontName: STRPTR): PFontContentsHeader; syscall IDiskfont 84;
+procedure DisposeFontContents(FontContentsHeader: PFontContentsHeader); syscall IDiskfont 88;
+function NewScaledDiskFont(SourceFont: PTextFont; DestTextAttr: PTextAttr): PDiskFontHeader; syscall IDiskfont 92;
+function GetDiskFontCtrl(TagId: LongInt): LongInt; syscall IDiskfont 96;
+procedure SetDiskFontCtrlA(TagList: PTagItem); syscall IDiskfont 100;
+// 104 SetDiskFontCtrl
+function EOpenEngine(EEngine: PEGlyphEngine): LongInt;  syscall IDiskfont 108;
+procedure ECloseEngine(EEngine: PEGlyphEngine);  syscall IDiskfont 112;
+function ESetInfoA(EEngine: PEGlyphEngine; TagList: PTagItem): LongWord;  syscall IDiskfont 116;
+// 120 ESetInfo
+function EObtainInfoA(EEngine: PEGlyphEngine; TagList: PTagItem): LongWord;  syscall IDiskfont 124;
+// 128 EObtainInfo
+function EReleaseInfoA(EEngine: PEGlyphEngine; TagList: PTagItem): LongWord;  syscall IDiskfont 132;
+// 136 EReleaseInfo
+function OpenOutlineFont(const Name: STRPTR; List: PList; Flags: LongWord): POutlineFont;  syscall IDiskfont 140;
+procedure CloseOutlineFont(Olf: POutlineFont; List: PList);  syscall IDiskfont 144;
+function WriteFontContents(FontsLock: BPTR; const FontName: STRPTR; FontContentsHeader: PFontContentsHeader): LongInt;  syscall IDiskfont 148;
+function WriteDiskFontHeaderA(Font: PTextFont; const FileName: STRPTR; const TagList: PTagItem): LongInt;  syscall IDiskfont 152;
+// 156 WriteDiskFontHeader
+function ObtainCharsetInfo(KnownTag, KnowValue, WantedTag: LongWord): LongWord;  syscall IDiskfont 160;
+function ObtainTTextAttr(Font: PTextFont): PTextFont;  syscall IDiskfont 164;
+procedure FreeTTextAttr(Tta: PTextFont);  syscall IDiskfont 168;
+
+implementation
+
+initialization
+  DiskfontBase := OpenLibrary(DISKFONTNAME, 36);
+  if Assigned(DiskfontBase) then
+    IDiskfont := GetInterface(DiskfontBase, 'main', 1, nil);
+finalization
+  if Assigned(IDiskfont) then
+    DropInterface(IDiskfont);
+  if Assigned(DiskfontBase) then
+    CloseLibrary(DiskfontBase);
+end.
+
+
+

+ 629 - 0
packages/os4units/src/workbench.pas

@@ -0,0 +1,629 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2014 by Free Pascal development team
+
+    workbnech.library functions
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+unit Workbench;
+{$PACKRECORDS C}
+
+Interface
+
+Uses
+   exec, AmigaDos, Utility, Intuition, AGraphics;
+
+// ###### workbench/startup.h ###############################################
+
+
+type
+  PWBArg = ^TWBArg;
+  TWBArg = record
+    wa_Lock: BPTR;       // A lock descriptor.
+    wa_Name: PChar;      // A string relative to that lock.
+  end;
+
+// ###### <freepascal> ######################################################
+
+  PWBArgList = ^TWBArgList;
+  TWBArgList = array[1..100] of TWBArg; // Only 1..smNumArgs are valid
+
+// ###### </freepascal> #####################################################
+
+  PWBStartup = ^TWBStartup;
+  TWBStartup = record
+    sm_Message: TMessage;    // A standard message structure.
+    sm_Process: PMsgPort;    // The process descriptor for you.
+    sm_Segment: BPTR;        // A descriptor for your code.
+    sm_NumArgs: LongInt;     // The number of elements in ArgList.
+    sm_ToolWindow: PChar;    // Description of window.
+    sm_ArgList: PWBArgList;  // The arguments themselves
+  end;
+
+// ###### workbench/workbench.h #############################################
+
+const
+  WORKBENCHNAME: PChar = 'workbench.library';  // Workbench library name.
+
+type
+  POldDrawerData = ^TOldDrawerData;
+  TOldDrawerData = record
+    dd_NewWindow: TNewWindow;  // Args to open window.
+    dd_CurrentX: LongInt;      // Current x coordinate of origin.
+    dd_CurrentY: LongInt;      // Current y coordinate of origin.
+  end;
+
+const
+  OLDDRAWERDATAFILESIZE = SizeOf(TOldDrawerData);  // Amount of DrawerData actually written to disk.
+
+type
+  PDrawerData = ^TDrawerData;
+  TDrawerData = record
+     dd_NewWindow: TNewWindow; // Args to open window.
+     dd_CurrentX: LongInt;     // Current x coordinate of origin.
+     dd_CurrentY: LongInt;     // Current y coordinate of origin.
+     dd_Flags: LongWord;       // Flags for drawer.
+     dd_ViewModes: Word;       // View mode for drawer.
+  end;
+
+const
+  DRAWERDATAFILESIZE = SizeOf(TDrawerData);  // Amount of DrawerData actually written to disk.
+
+  // Definitions for dd_ViewModes
+  DDVM_BYDEFAULT = 0;   // Default (inherit parent's view mode).
+  DDVM_BYICON    = 1;   // View as icons.
+  DDVM_BYNAME    = 2;   // View as text, sorted by name.
+  DDVM_BYDATE    = 3;   // View as text, sorted by date.
+  DDVM_BYSIZE    = 4;   // View as text, sorted by size.
+  DDVM_BYTYPE    = 5;   // View as text, sorted by type.
+
+  // Definitions for dd_Flags
+  DDFLAGS_SHOWDEFAULT = 0;  // Fefault (show only icons).
+  DDFLAGS_SHOWICONS   = 1;  // Show only icons.
+  DDFLAGS_SHOWALL     = 2;  // Show all files.
+
+type
+  PDiskObject = ^TDiskObject;
+  TDiskObject = record
+    do_Magic: Word;              // A magic number at the start of the file.
+    do_Version: Word;            // A version number, so we can change it.
+    do_Gadget: TGadget;          // A copy of in core gadget.
+    do_type: Byte;
+    do_DefaultTool: STRPTR;
+    do_Tooltypes: PPChar;
+    do_CurrentX: LongInt;
+    do_CurrentY: LongInt;
+    do_DrawerData: PDrawerData;
+    do_ToolWindow: STRPTR;       // Only applies to tools.
+    do_StackSize: LongInt;       // Only applies to tools.
+  end;
+
+const
+  WBDISK    = 1;
+  WBDRAWER  = 2;
+  WBTOOL    = 3;
+  WBPROJECT = 4;
+  WBGARBAGE = 5;
+  WBDEVICE  = 6;
+  WBKICK    = 7;
+  WBAPPICON = 8;
+
+  WB_DISKVERSION      = 1;                  // Current version number.
+  WB_DISKREVISION     = 1;                  // Current revision number.
+  WB_DISKREVISIONMASK = $FF;                // Only use the lower 8 bits of Gadget.UserData for the revision #.
+
+  WB_DISKMAGIC = $E310;              // A magic number, not easily impersonated.
+
+type
+  PFreeList = ^TFreeList;
+  TFreeList = record
+    fl_NumFree: SmallInt;
+    fl_MemList: TList;
+  end;
+
+const
+  //
+  // workbench does different complement modes for its gadgets.
+  // It supports separate images, complement mode, and backfill mode.
+  // The first two are identical to intuitions GADGIMAGE and GADGHCOMP.
+  // backfill is similar to GADGHCOMP, but the region outside of the
+  // image (which normally would be color three when complemented)
+  // is flood-filled to color zero.
+  //
+  GFLG_GADGBACKFILL = $0001;
+  // GADGBACKFILL = $0001;   // an old synonym
+  NO_ICON_POSITION  = $80000000;  // If an icon does not really live anywhere, set its current position to here.
+
+type
+  PAppMessage = ^TAppMessage;
+  TAppMessage = record
+    am_Message: TMessage;       // Standard message structure.
+    am_type: Word;              // Message type.
+    am_UserData: LongWord;      // Application specific.
+    am_ID: LongWord;            // Application definable ID.
+    am_NumArgs: LongInt;        // # of elements in arglist.
+    am_ArgList: PWBArgList;     // The arguements themselves.
+    am_Version: Word;           // Will be AM_VERSION.
+    am_Class: Word;             // Message class.
+    am_MouseX: SmallInt;        // Mouse x position of event.
+    am_MouseY: SmallInt;        // Mouse y position of event.
+    am_Seconds: LongWord;       // Current system clock time.
+    am_Micros: LongWord;        // Current system clock time.
+    am_Reserved: array[0..7] of LongWord;  // Avoid recompilation.
+  end;
+
+const
+  //
+  // If you find am_Version >= AM_VERSION, you know this structure has
+  // at least the fields defined in this version of the include file
+  //
+  AM_VERSION =  1;  // Definition for am_Version.
+
+  // Definitions for member am_type of structure TAppMessage.
+  AMTYPE_APPWINDOW     =  7;  // App window message.
+  AMTYPE_APPICON       =  8;  // App icon message.
+  AMTYPE_APPMENUITEM   =  9;  // App menu item message.
+  AMTYPE_APPWINDOWZONE = 10;  // App window drop zone message.
+
+  // Definitions for member am_Class of structure TAppMessage for AppIcon messages (V44)
+  AMCLASSICON_Open        =  0;  // The "Open" menu item was invoked, the icon got double-clicked or an icon got dropped on it.
+  AMCLASSICON_Copy        =  1;  // The "Copy" menu item was invoked.
+  AMCLASSICON_Rename      =  2;  // The "Rename" menu item was invoked.
+  AMCLASSICON_Information =  3;  // The "Information" menu item was invoked.
+  AMCLASSICON_Snapshot    =  4;  // The "Snapshot" menu item was invoked.
+  AMCLASSICON_UnSnapshot  =  5;  // The "UnSnapshot" menu item was invoked.
+  AMCLASSICON_LeaveOut    =  6;  // The "Leave Out" menu item was invoked.
+  AMCLASSICON_PutAway     =  7;  // The "Put Away" menu item was invoked.
+  AMCLASSICON_Delete      =  8;  // The "Delete" menu item was invoked.
+  AMCLASSICON_FormatDisk  =  9;  // The "Format Disk" menu item was invoked.
+  AMCLASSICON_EmptyTrash  = 10;  // The "Empty Trash" menu item was invoked.
+  AMCLASSICON_Selected    = 11;  // The icon is now selected.
+  AMCLASSICON_Unselected  = 12;  // The icon is now unselected.
+
+type
+  // The message your AppIcon rendering hook gets invoked with.
+  PAppIconRenderMsg = ^TAppIconRenderMsg;
+  TAppIconRenderMsg = record
+    arm_RastPort: PRastPort; // RastPort to render into.
+    arm_Icon: PDiskObject;   // The icon to be rendered.
+    arm_Label: STRPTR;       // The icon label txt.
+    arm_Tags: PTagItem;      // Further tags to be passed on to DrawIconStateA().
+    arm_Left: SmallInt;      // \ Rendering origin, not taking the
+    arm_Top: SmallInt;       // / button border into account.
+    arm_Width: SmallInt;     // \ Limit your rendering to
+    arm_Height: SmallInt;    // / this area.
+    arm_State: LongWord;     // IDS_SELECTED, IDS_NORMAL, etc.
+  end;
+
+  // The message your drop zone hook gets invoked with. }
+  PAppWindowDropZoneMsg = ^TAppWindowDropZoneMsg;
+  TAppWindowDropZoneMsg = record
+    adzm_RastPort: PRastPort; // RastPort to render into.
+    adzm_DropZoneBox: TIBox;  // Limit your rendering to this area.
+    adzm_ID: LongWord;        // \ These come from straight
+    adzm_UserData: LongWord;  // / from AddAppWindowDropZoneA().
+    adzm_Action: LongInt;     // See below for a list of actions.
+  end;
+
+const
+  // definitions for adzm_Action
+  ADZMACTION_Enter = 0;
+  ADZMACTION_Leave = 1;
+
+type
+  // The message your icon selection change hook is invoked with. }
+  PIconSelectMsg = ^TIconSelectMsg;
+  TIconSelectMsg = record
+    ism_Length: LongWord;      // Size of this data structure (in bytes).
+    ism_Drawer: BPTR;          // Lock on the drawer this object resides in, NULL for Workbench backdrop (devices).
+    ism_Name: STRPTR;          // Name of the object in question.
+    ism_type: Word;            // One of WBDISK, WBDRAWER, WBTOOL, WBPROJECT, WBGARBAGE, WBDEVICE, WBKICK or WBAPPICON.
+    ism_Selected: LongBool;    // TRUE if currently selected, FALSE otherwise.
+    ism_Tags: PTagItem;        // Pointer to the list of tag items passed to ChangeWorkbenchSelectionA().
+    ism_DrawerWindow: PWindow; // Pointer to the window attached to this icon, if the icon is a drawer-like object.
+    ism_ParentWindow: PWindow; // Pointer to the window the icon resides in.
+    ism_Left: SmallInt;        // Position and size of the icon; note that the icon may not entirely reside within the visible bounds of the parent window.
+    ism_Top: SmallInt;
+    ism_Width: SmallInt;
+    ism_Height: SmallInt;
+  end;
+
+const
+  // These are the values your hook code can return.
+  ISMACTION_Unselect = 0; // Unselect the icon.
+  ISMACTION_Select   = 1; // Select the icon.
+  ISMACTION_Ignore   = 2; // Do not change the selection state.
+  ISMACTION_Stop     = 3; // Do not invoke the hook code again, leave the icon as it is.
+
+type
+  // The messages your copy hook is invoked with.
+  PCopyBeginMsg = ^TCopyBeginMsg;
+  TCopyBeginMsg = record
+    cbm_Length: LongWord;        // Size of this data structure in bytes.
+    cbm_Action: LongInt;         // Will be set to CPACTION_Begin (see below).
+    cbm_SourceDrawer: BPTR;      // A lock on the source drawer.
+    cbm_DestinationDrawer: BPTR; // A lock on the destination drawer.
+  end;
+
+  PCopyDataMsg = ^TCopyDataMsg;
+  TCopyDataMsg = record
+    cdm_Length: LongWord;        // Size of this data structure in bytes.
+    cdm_Action: LongInt;         // Will be set to CPACTION_Copy (see below).
+    cdm_SourceLock: BPTR;        // A lock on the parent directory of the source file/drawer.
+    cdm_SourceName: STRPTR;      // The name of the source file or drawer.
+    cdm_DestinationLock: BPTR;   // A lock on the parent directory of the destination file/drawer.
+    cdm_DestinationName: STRPTR; // The name of the destination file/drawer.
+                                 // This may or may not match the name of the source file/drawer in case the
+                                 // data is to be copied under a different name. For example, this is the case
+                                 // with the Workbench "Copy" command which creates duplicates of file/drawers by
+                                 // prefixing the duplicate's name with "Copy_XXX_of".
+    cdm_DestinationX: LongInt;   // When the icon corresponding to the destination is written to disk, this
+    cdm_DestinationY: LongInt;   // is the position (put into its DiskObject->do_CurrentX/DiskObject->do_CurrentY.
+  end;                           // fields) it should be placed at.
+
+  PCopyEndMsg = ^TCopyEndMsg;
+  TCopyEndMsg = record
+    cem_Length: LongWord; // Size of this data structure in bytes.
+    cem_Action: LongInt;  // Will be set to CPACTION_End (see below).
+  end;
+
+const
+  CPACTION_Begin = 0;
+  CPACTION_Copy  = 1; // This message arrives for each file or drawer to be copied.
+  CPACTION_End   = 2; // This message arrives when all files/drawers have been copied.
+
+type
+  // The messages your delete hook is invoked with.
+  PDeleteBeginMsg = ^TDeleteBeginMsg;
+  TDeleteBeginMsg = record
+    dbm_Length: LongWord; // Size of this data structure in bytes.
+    dbm_Action: LongInt;  // Will be set to either DLACTION_BeginDiscard or DLACTION_BeginEmptyTrash (see below).
+  end;
+
+  PDeleteDataMsg = ^TDeleteDataMsg;
+  TDeleteDataMsg = record
+    ddm_Length: LongWord; // Size of this data structure in bytes.
+    ddm_Action: LongInt;  // Will be set to either DLACTION_DeleteContents or DLACTION_DeleteObject (see below).
+    ddm_Lock: BPTR;       // A Lock on the parent directory of the object whose contents or which itself should be deleted.
+    ddm_Name: STRPTR;     // The name of the object whose contents or which itself should be deleted.
+  end;
+
+  PDeleteEndMsg = ^TDeleteEndMsg;
+  TDeleteEndMsg = record
+    dem_Length: LongWord; // Size of this data structure in bytes.
+    dem_Action: LongInt;  // Will be set to DLACTION_End (see below).
+  end;
+
+
+const
+  DLACTION_BeginDiscard    = 0;
+  DLACTION_BeginEmptyTrash = 1; // This indicates that the following delete operations are intended to empty the trashcan.
+  DLACTION_DeleteContents  = 3; // This indicates that the object described by lock and name refers to a drawer; you should empty its contents but  DO NOT  delete the drawer itself!
+  DLACTION_DeleteObject    = 4; // This indicates that the object described by lock and name should be deleted; this could be a file or an empty drawer.
+  DLACTION_End             = 5; // This indicates that the deletion process is finished.
+
+type
+  // The message your setup/cleanup hook gets invoked with.
+  PSetupCleanupHookMsg = ^TSetupCleanupHookMsg;
+  TSetupCleanupHookMsg = record
+    schm_Length: LongWord;
+    schm_State: LongInt;
+  end;
+
+const
+  SCHMSTATE_TryCleanup = 0; // Workbench will attempt to shut down now.
+  SCHMSTATE_Cleanup    = 1; // Workbench will really shut down now.
+  SCHMSTATE_Setup      = 2; // Workbench is operational again or could not be shut down.
+
+type
+  // The messages your text input hook is invoked with.
+  PTextInputMsg = ^TTextInputMsg;
+  TTextInputMsg = record
+    tim_Length: LongWord; // Size of this data structure in bytes.
+    tim_Action: LongInt;  // One of the TIACTION_... values listed below.
+    tim_Prompt: STRPTR;   // The Workbench suggested result, depending on what kind of input is requested (as indicated by the tim_Action member).
+  end;
+
+const
+  TIACTION_Rename        = 0; // A file or drawer is to be renamed.
+  TIACTION_RelabelVolume = 1; // A volume is to be relabeled.
+  TIACTION_NewDrawer     = 2; // A new drawer is to be created.
+  TIACTION_Execute       = 3; // A program or script is to be executed.
+
+type
+  //
+  // The following structures are private.  These are just stub
+  // structures for code compatibility...
+  //
+  PAppWindow = ^TAppWindow;
+  TAppWindow = record
+    aw_PRIVATE: pointer;
+  end;
+
+  PAppMenu = ^TAppMenu;
+  TAppMenu = record
+    am_PRIVATE: pointer;
+  end;
+
+  PAppWindowDropZone = ^TAppWindowDropZone;
+  TAppWindowDropZone = record
+    awdz_PRIVATE: pointer;
+  end;
+
+  PAppIcon = ^TAppIcon;
+  TAppIcon = record
+    ai_PRIVATE: Pointer;
+  end;
+
+  PAppMenuItem = ^TAppMenuItem;
+  TAppMenuItem = record
+    ami_PRIVATE: Pointer;
+  end;
+
+
+const
+  WBA_Dummy = TAG_USER + $A000;
+  // Tags for use with AddAppIconA()
+  // The different menu items the AppIcon responds to (BOOL).
+  WBAPPICONA_SupportsOpen        = WBA_Dummy +  1; // AppIcon responds to the "Open" menu item (LongBool).
+  WBAPPICONA_SupportsCopy        = WBA_Dummy +  2; // AppIcon responds to the "Copy" menu item (LongBool).
+  WBAPPICONA_SupportsRename      = WBA_Dummy +  3; // AppIcon responds to the "Rename" menu item (LongBool).
+  WBAPPICONA_SupportsInformation = WBA_Dummy +  4; // AppIcon responds to the "Information" menu item (LongBool).
+  WBAPPICONA_SupportsSnapshot    = WBA_Dummy +  5; // AppIcon responds to the "Snapshot" menu item (LongBool).
+  WBAPPICONA_SupportsUnSnapshot  = WBA_Dummy +  6; // AppIcon responds to the "UnSnapshot" menu item (LongBool).
+  WBAPPICONA_SupportsLeaveOut    = WBA_Dummy +  7; // AppIcon responds to the "LeaveOut" menu item (LongBool).
+  WBAPPICONA_SupportsPutAway     = WBA_Dummy +  8; // AppIcon responds to the "PutAway" menu item (LongBool).
+  WBAPPICONA_SupportsDelete      = WBA_Dummy +  9; // AppIcon responds to the "Delete" menu item (LongBool).
+  WBAPPICONA_SupportsFormatDisk  = WBA_Dummy + 10; // AppIcon responds to the "FormatDisk" menu item (LongBool).
+  WBAPPICONA_SupportsEmptyTrash  = WBA_Dummy + 11; // AppIcon responds to the "EmptyTrash" menu item (LongBool).
+
+  WBAPPICONA_PropagatePosition   = WBA_Dummy + 12; // AppIcon position should be propagated back to original DiskObject (LongBool).
+  WBAPPICONA_RenderHook          = WBA_Dummy + 13; // Callback hook to be invoked when rendering this icon (pHook).
+  WBAPPICONA_NotifySelectState   = WBA_Dummy + 14; // AppIcon wants to be notified when its select state changes (LongBool).
+
+  // Tags for use with AddAppMenuA()
+  WBAPPMENUA_CommandKeyString    = WBA_Dummy + 15; // Command key string for this AppMenu (STRPTR).
+  WBAPPMENUA_GetKey              = WBA_Dummy + 65; // Item to be added should get sub menu items attached to; make room for it, then return the key to use later for attaching the items (A_PUL
+  WBAPPMENUA_UseKey              = WBA_Dummy + 66; // This item should be attached to a sub menu; the key provided refers to the sub menu it should be attached to (LongWord).
+  WBAPPMENUA_GetTitleKey         = WBA_Dummy + 77; // Item to be added is in fact a new menu title; make room for it, then return the key to use later for attaching the items (??? ULONG ???).
+
+  // Tags for use with OpenWorkbenchObjectA()
+  WBOPENA_ArgLock                = WBA_Dummy + 16; // Corresponds to the wa_Lock member of a struct WBArg.
+  WBOPENA_ArgName                = WBA_Dummy + 17; // Corresponds to the wa_Name member of a struct WBArg.
+  WBOPENA_Show                   = WBA_Dummy + 75; // When opening a drawer, show all files or only icons? This must be one out of DDFLAGS_SHOWICONS, or DDFLAGS_SHOWALL; (Byte); (V45)
+  WBOPENA_ViewBy                 = WBA_Dummy + 76; // When opening a drawer, view the contents by icon, name, date, size or type? This must be one out of DDVM_BYICON, DDVM_BYNAME, DDVM_BYDATE, DDVM_BYSIZE or DDVM_BYTYPE; (UBYTE); (V45)
+
+  // Tags for use with WorkbenchControlA()
+  WBCTRLA_IsOpen                 = WBA_Dummy + 18; // Check if the named drawer is currently open (PLongInt).
+  WBCTRLA_DuplicateSearchPath    = WBA_Dummy + 19; // Create a duplicate of the Workbench private search path list (PBPTR).
+  WBCTRLA_FreeSearchPath         = WBA_Dummy + 20; // Free the duplicated search path list (BPTR).
+  WBCTRLA_GetDefaultStackSize    = WBA_Dummy + 21; // Get the default stack size for launching programs with (PLongWord).
+  WBCTRLA_SetDefaultStackSize    = WBA_Dummy + 22; // Set the default stack size for launching programs with (LongWord).
+  WBCTRLA_RedrawAppIcon          = WBA_Dummy + 23; // Cause an AppIcon to be redrawn (pAppIcon).
+  WBCTRLA_GetProgramList         = WBA_Dummy + 24; // Get a list of currently running Workbench programs (pList).
+  WBCTRLA_FreeProgramList        = WBA_Dummy + 25; // Release the list of currently running Workbench programs (pList).
+  WBCTRLA_GetSelectedIconList    = WBA_Dummy + 36; // Get a list of currently selected icons (pList).
+  WBCTRLA_FreeSelectedIconList   = WBA_Dummy + 37; // Release the list of currently selected icons (pList).
+  WBCTRLA_GetOpenDrawerList      = WBA_Dummy + 38; // Get a list of currently open drawers (pList).
+  WBCTRLA_FreeOpenDrawerList     = WBA_Dummy + 39; // Release the list of currently open icons (pList).
+  WBCTRLA_GetHiddenDeviceList    = WBA_Dummy + 42; // Get the list of hidden devices (pList).
+
+  WBCTRLA_FreeHiddenDeviceList   = WBA_Dummy + 43; // Release the list of hidden devices (pList).
+  WBCTRLA_AddHiddenDeviceName    = WBA_Dummy + 44; // Add the name of a device which Workbench should never try to read a disk icon from (STRPTR).
+  WBCTRLA_RemoveHiddenDeviceName = WBA_Dummy + 45; // Remove a name from list of hidden devices (STRPTR).
+  WBCTRLA_GettypeRestartTime     = WBA_Dummy + 47; // Get the number of seconds that have to pass before typing the next character in a drawer window will restart with a new file name (PLongWord).
+  WBCTRLA_SettypeRestartTime     = WBA_Dummy + 48; // Set the number of seconds that have to pass before typing the next character in a drawer window will restart with a new file name (LongWord).
+  WBCTRLA_GetCopyHook            = WBA_Dummy + 69; // Obtain the hook that will be invoked when Workbench starts to copy files and data (pHook); (V45)
+  WBCTRLA_SetCopyHook            = WBA_Dummy + 70; // Install the hook that will be invoked when Workbench starts to copy files and data (pHook); (V45)
+  WBCTRLA_GetDeleteHook          = WBA_Dummy + 71; // Obtain the hook that will be invoked when Workbench discards files and drawers or empties the trashcan (pHook);  (V45).
+  WBCTRLA_SetDeleteHook          = WBA_Dummy + 72; // Install the hook that will be invoked when Workbench discards  files and drawers or empties the trashcan (pHook); (V45).
+  WBCTRLA_GetTextInputHook       = WBA_Dummy + 73; // Obtain the hook that will be invoked when Workbench requests that the user enters text, such as when a file is to be renamed  or a new drawer is to be created (pHook); (V45)
+  WBCTRLA_SetTextInputHook       = WBA_Dummy + 74; // Install the hook that will be invoked when Workbench requests that the user enters text, such as when a file is to be renamed or a new drawer is to be created (pHook); (V45)
+  WBCTRLA_AddSetupCleanupHook    = WBA_Dummy + 78; // Add a hook that will be invoked when Workbench is about to shut down (cleanup), and when Workbench has returned to operational state (setup) (pHook); (V45)
+  WBCTRLA_RemSetupCleanupHook    = WBA_Dummy + 79; // Remove a hook that has been installed with the WBCTRLA_AddSetupCleanupHook tag (pHook); (V45)
+
+  // Tags for use with AddAppWindowDropZoneA()
+  WBDZA_Left      = WBA_Dummy + 26; // Zone left edge (SmallInt)
+  WBDZA_RelRight  = WBA_Dummy + 27; // Zone left edge, if relative to the right edge of the window (SmallInt)
+  WBDZA_Top       = WBA_Dummy + 28; // Zone top edge (SmallInt)
+  WBDZA_RelBottom = WBA_Dummy + 29; // Zone top edge, if relative to the bottom edge of the window (SmallInt)
+  WBDZA_Width     = WBA_Dummy + 30; // Zone width (SmallInt)
+  WBDZA_RelWidth  = WBA_Dummy + 31; // Zone width, if relative to the window width (SmallInt)
+  WBDZA_Height    = WBA_Dummy + 32; // Zone height (SmallInt)
+  WBDZA_RelHeight = WBA_Dummy + 33; // Zone height, if relative to the window height (SmallInt)
+  WBDZA_Box       = WBA_Dummy + 34; // Zone position and size (pIBox).
+  WBDZA_Hook      = WBA_Dummy + 35; // Hook to invoke when the mouse enters or leave a drop zone (pHook).
+
+  // Reserved tags; don't use!  }
+  WBA_Reserved1  = WBA_Dummy + 40;
+  WBA_Reserved2  = WBA_Dummy + 41;
+  WBA_Reserved3  = WBA_Dummy + 46;
+  WBA_Reserved4  = WBA_Dummy + 49;
+  WBA_Reserved5  = WBA_Dummy + 50;
+  WBA_Reserved6  = WBA_Dummy + 51;
+  WBA_Reserved7  = WBA_Dummy + 52;
+  WBA_Reserved8  = WBA_Dummy + 53;
+  WBA_Reserved9  = WBA_Dummy + 54;
+  WBA_Reserved10 = WBA_Dummy + 55;
+  WBA_Reserved11 = WBA_Dummy + 56;
+  WBA_Reserved12 = WBA_Dummy + 57;
+  WBA_Reserved13 = WBA_Dummy + 58;
+  WBA_Reserved14 = WBA_Dummy + 59;
+  WBA_Reserved15 = WBA_Dummy + 60;
+  WBA_Reserved16 = WBA_Dummy + 61;
+  WBA_Reserved17 = WBA_Dummy + 62;
+  WBA_Reserved18 = WBA_Dummy + 63;
+  WBA_Reserved19 = WBA_Dummy + 64;
+
+  // Last Tag
+  WBA_LAST_TAG = WBA_Dummy + 64;
+
+  // Parameters for the UpdateWorkbench() function.
+  UPDATEWB_ObjectRemoved = 0; // Object has been deleted.
+  UPDATEWB_ObjectAdded   = 1; // Object is new or has changed.
+
+const
+
+// each message that comes into the WorkBenchPort must have a type field in the preceeding short.  These are the defines for this type
+
+  MTYPE_PSTD        = 1;    { a "standard Potion" message }
+  MTYPE_TOOLEXIT    = 2;    { exit message from our tools }
+  MTYPE_DISKCHANGE  = 3;    { dos telling us of a disk change }
+  MTYPE_TIMER       = 4;    { we got a timer tick }
+  MTYPE_CLOSEDOWN   = 5;    { <unimplemented> }
+  MTYPE_IOPROC      = 6;    { <unimplemented> }
+  MTYPE_APPWINDOW   = 7;    {     msg from an app window }
+  MTYPE_APPICON     = 8;    {     msg from an app icon }
+  MTYPE_APPMENUITEM = 9;    {     msg from an app menuitem }
+  MTYPE_COPYEXIT    = 10;   {     exit msg from copy process }
+  MTYPE_ICONPUT     = 11;   {     msg from PutDiskObject in icon.library }
+
+// ###### workbench/handler.h ###############################################
+type
+  TWBHM_type =
+  (
+    WBHM_TYPE_SHOW,  // Open all windows.
+    WBHM_TYPE_HIDE,  // Close all windows.
+    WBHM_TYPE_OPEN,  // Open a drawer.
+    WBHM_TYPE_UPDATE // Update an object.
+  );
+
+  PWBHandlerMessage = ^TWBHandlerMessage;
+  TWBHandlerMessage = record
+    wbhm_Message: TMessage; // Standard message structure.
+    wbhm_type: TWBHM_type;  // type of message.
+    case integer of
+    0 :
+    (
+      Open: record
+        OpenName: STRPTR;   // Name of the drawer.
+      end;
+    );
+    1 :
+    (
+      Update: record
+        UpdateName: STRPTR;  // Mame of the object.
+        Updatetype: LongInt; // type of object (WBDRAWER, WBPROJECT, ...).
+      end;
+    );
+  end;
+
+
+var
+  WorkbenchBase: PLibrary;
+  IWorkbench: PInterface;
+
+function WBObtain(): LongWord; syscall IWorkbench 60;
+function WBRelease(): LongWord; syscall IWorkbench 64;
+procedure WBExpunge(); syscall IWorkbench 68;
+function WBClone(): PInterface; syscall IWorkbench 72;
+procedure UpdateWorkbench(const Name: STRPTR; Lock: BPTR; Action: LongInt); syscall IWorkbench 76;
+// 80 private
+// 84 private
+function AddAppWindowA(ID: LongWord; UserData: LongWord; Window: PWindow; MsgPort: PMsgPort; TagList: PTagItem): PAppWindow;  syscall IWorkbench 88;
+// 92 AddAppWindow
+function RemoveAppWindow(AppWindow: PAppWindow): LongBool;  syscall IWorkbench 96;
+function AddAppIconA(ID: LongWord; UserData: LongWord; Text_: PChar; MsgPort: PMsgPort; Lock: BPTR; DiskObj: PDiskObject; TagList: PTagItem): PAppIcon; syscall IWorkbench 100;
+// 104 AddAppIcon
+function RemoveAppIcon(AppIcon: PAppIcon): LongBool; syscall IWorkbench 108;
+function AddAppMenuItemA(ID: LongWord; UserData: LongWord; Text_: APTR; MsgPort: PMsgPort; TagList: PTagItem): PAppMenuItem; syscall IWorkbench 112;
+// 116
+function RemoveAppMenuItem(AppMenuItem: PAppMenuItem): LongBool; syscall IWorkbench 120;
+// 124 private
+function WBInfo(Lock: BPTR; const Name: STRPTR; Screen: PScreen): LongBool; syscall IWorkbench 128;
+function OpenWorkbenchObjectA(Name: STRPTR; Tags: PTagItem): LongBool; syscall IWorkbench 132;
+// 136 OpenWorkbenchObject
+function CloseWorkbenchObjectA(Name: STRPTR; Tags: PTagItem): LongBool; syscall IWorkbench 140;
+// 144 CloseWorkbenchObject
+function WorkbenchControlA(Name: STRPTR; Tags: PTagItem): LongBool; syscall IWorkbench 148;
+// 152 WorkbenchControl
+function AddAppWindowDropZoneA(Aw: PAppWindow; ID: LongWord; UserData: LongWord; Tags: PTagItem): PAppWindowDropZone; syscall IWorkbench 156;
+// 160 AddAppWindowDropZone
+function RemoveAppWindowDropZone(Aw: PAppWindow; DropZone: PAppWindowDropZone): LongBool; syscall IWorkbench 164;
+function ChangeWorkbenchSelectionA(Name: STRPTR; Hook: PHook; Tags: PTagItem): LongBool; syscall IWorkbench 168;
+// 172 ChangeWorkbenchSelection
+function MakeWorkbenchObjectVisibleA(Name: STRPTR; Tags: PTagItem): LongBool; syscall IWorkbench 176;
+// 180 MakeWorkbenchObjectVisible
+function WhichWorkbenchObjectA(Window: PWindow; X, Y: LongInt; Tags: PTagItem): LongBool; syscall IWorkbench 184;
+// 188 WhichWorkbenchObject
+// 192 private
+
+// varargs versions:
+function AddAppIcon(ID: LongWord; UserData: LongWord; Text_: PChar; MsgPort: PMsgPort; Lock: BPTR; DiskObj: PDiskObject; const Tags: array of PtrUInt): PAppIcon;
+function AddAppMenuItem(ID: LongWord; UserData: LongWord; Text_: APTR; MsgPort: PMsgPort; const Tags: array of PtrUInt): PAppMenuItem;
+function AddAppWindow(ID: LongWord; UserData: LongWord; Window: PWindow; MsgPort: PMsgPort; const Tags: array of PtrUInt): PAppWindow;
+function AddAppWindowDropZone(Aw: PAppWindow; ID: LongWord; UserData: LongWord; const Tags: array of PtrUInt): PAppWindowDropZone;
+function CloseWorkbenchObject(Name: STRPTR; const Tags: array of PtrUInt): LongBool; unimplemented;
+function MakeWorkbenchObjectVisible(Name: STRPTR; const Tags: array of PtrUInt): LongBool; unimplemented;
+function OpenWorkbenchObject(Name: STRPTR; const Tags: array of PtrUInt): LongBool;
+function WorkbenchControl(Name: STRPTR; const Tags: array of PtrUInt): LongBool;
+
+implementation
+
+
+// varargs versions:
+function AddAppIcon(ID: LongWord; UserData: LongWord; Text_: PChar; MsgPort: PMsgPort; Lock: BPTR; DiskObj: PDiskObject; const Tags: array of PtrUInt): PAppIcon; inline;
+begin
+  AddAppIcon := AddAppIconA(ID, UserData, Text_, MsgPort, Lock, DiskObj, @Tags);
+end;
+
+
+function AddAppMenuItem(ID: LongWord; UserData: LongWord; Text_: APTR; MsgPort: PMsgPort;  const Tags: array of PtrUInt): PAppMenuItem; inline;
+begin
+  AddAppMenuItem := AddAppMenuItemA(ID, UserData, Text_, MsgPort, @Tags);
+end;
+
+
+function AddAppWindow(ID: LongWord; UserData: LongWord; Window: PWindow; MsgPort: PMsgPort;  const Tags: array of PtrUInt): PAppWindow; inline;
+begin
+  AddAppWindow := AddAppWindowA(ID, UserData, Window, MsgPort, @Tags);
+end;
+
+
+function AddAppWindowDropZone(Aw: PAppWindow; ID: LongWord; UserData: LongWord;  const Tags: array of PtrUInt): PAppWindowDropZone; inline;
+begin
+  AddAppWindowDropZone := AddAppWindowDropZoneA(Aw, ID, UserData, @Tags);
+end;
+
+
+function CloseWorkbenchObject(Name: STRPTR;  const Tags: array of PtrUInt): LongBool; inline;
+begin
+  CloseWorkbenchObject := CloseWorkbenchObjectA(Name, @Tags);
+end;
+
+
+function MakeWorkbenchObjectVisible(Name: STRPTR;  const Tags: array of PtrUInt): LongBool; inline;
+begin
+  MakeWorkbenchObjectVisible := MakeWorkbenchObjectVisibleA(Name, @Tags);
+end;
+
+
+function OpenWorkbenchObject(Name: STRPTR;  const Tags: array of PtrUInt): LongBool; inline;
+begin
+  OpenWorkbenchObject := OpenWorkbenchObjectA(Name, @Tags);
+end;
+
+
+function WorkbenchControl(Name: STRPTR;  const Tags: array of PtrUInt): LongBool; inline;
+begin
+  WorkbenchControl := WorkbenchControlA(Name, @Tags);
+end;
+
+
+Initialization
+  WorkbenchBase := OpenLibrary(WORKBENCHNAME,0);
+  if Assigned(WorkbenchBase) then
+    IWorkbench := GetInterface(WorkbenchBase, 'main', 1, nil);
+finalization
+  if Assigned(IWorkbench) then
+    DropInterface(IWorkbench);
+  if Assigned(WorkbenchBase) then
+    CloseLibrary(WorkbenchBase);
+end.