workbench.pas 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. {
  2. This file is part of the Free Pascal run time library.
  3. A file in Amiga system run time library.
  4. Copyright (c) 1998-2003 by Nils Sjoholm
  5. member of the Amiga RTL development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {$PACKRECORDS 2}
  13. unit workbench;
  14. interface
  15. uses
  16. exec, amigados, utility, intuition, agraphics;
  17. // wb startup defines
  18. type
  19. PWBArg = ^TWBArg;
  20. TWBArg = record
  21. wa_Lock: BPTR; // a lock descriptor
  22. wa_Name: STRPTR; // a string relative to that lock
  23. end;
  24. WBArgList = array[1..100] of TWBArg; // Only 1..smNumArgs are valid
  25. PWBArgList = ^WBArgList;
  26. PWBStartup = ^TWBStartup;
  27. TWBStartup = record
  28. sm_Message: TMessage; // a standard message structure
  29. sm_Process: PMsgPort; // the process descriptor for you
  30. sm_Segment: BPTR; // a descriptor for your code
  31. sm_NumArgs: Longint; // the number of elements in ArgList
  32. sm_ToolWindow: STRPTR; // description of window
  33. sm_ArgList: PWBArgList; // the arguments themselves
  34. end;
  35. const
  36. WBDISK = 1;
  37. WBDRAWER = 2;
  38. WBTOOL = 3;
  39. WBPROJECT = 4;
  40. WBGARBAGE = 5;
  41. WBDEVICE = 6;
  42. WBKICK = 7;
  43. WBAPPICON = 8;
  44. type
  45. POldDrawerData = ^TOldDrawerData;
  46. TOldDrawerData = record
  47. dd_NewWindow: TNewWindow; // args to open window
  48. dd_CurrentX: Longint; // current x coordinate of origin
  49. dd_CurrentY: Longint; // current y coordinate of origin
  50. end;
  51. const
  52. // the amount of DrawerData actually written to disk
  53. OLDDRAWERDATAFILESIZE = SizeOf(TOldDrawerData);
  54. type
  55. PDrawerData = ^TDrawerData;
  56. TDrawerData = record
  57. dd_NewWindow: TNewWindow; // args to open window
  58. dd_CurrentX: Longint; // current x coordinate of origin
  59. dd_CurrentY: Longint; // current y coordinate of origin
  60. dd_Flags: Longint; // flags for drawer DDFLAGS_*
  61. dd_ViewModes: Word; // view mode for drawer DDVM_*
  62. end;
  63. const
  64. // the amount of DrawerData actually written to disk
  65. DRAWERDATAFILESIZE = SizeOf(TDrawerData);
  66. // dd_ViewModes
  67. DDVM_BYDEFAULT = 0;
  68. DDVM_BYICON = 1; // view as icons
  69. DDVM_BYNAME = 2; // view as text, sorted by name
  70. DDVM_BYDATE = 3; // view as text, sorted by date
  71. DDVM_BYSIZE = 4; // view as text, sorted by size
  72. DDVM_BYTYPE = 5; // view as text, sorted by type
  73. // definitions for dd_Flags
  74. DDFLAGS_SHOWDEFAULT = 0; // default (show only icons)
  75. DDFLAGS_SHOWICONS = 1; // show only icons
  76. DDFLAGS_SHOWALL = 2; // show all files
  77. type
  78. PDiskObject = ^TDiskObject;
  79. TDiskObject = record
  80. do_Magic: Word; // a magic number at the start of the file
  81. do_Version: Word; // a version number, so we can change it
  82. do_Gadget: TGadget; // a copy of in core gadget
  83. do_Type: Byte;
  84. do_DefaultTool: STRPTR;
  85. do_ToolTypes: PPChar;
  86. do_CurrentX: LongInt;
  87. do_CurrentY: LongInt;
  88. do_DrawerData: PDrawerData;
  89. do_ToolWindow: STRPTR; // only applies to tools
  90. do_StackSize: Longint; // only applies to tools
  91. end;
  92. const
  93. WB_DISKMAGIC = $e310; // a magic number, not easily impersonated
  94. WB_DISKVERSION = 1; // our current version number
  95. WB_DISKREVISION = 1; // our current revision number
  96. WB_DISKREVISIONMASK = 255; // I only use the lower 8 bits of Gadget.UserData for the revision #
  97. type
  98. PFreeList = ^TFreeList;
  99. TFreeList = record
  100. fl_NumFree: SmallInt;
  101. fl_MemList: TList;
  102. end;
  103. const
  104. { workbench does different complement modes for its gadgets. It supports separate images, complement mode, and backfill mode.
  105. The first two are identical to intuitions GADGIMAGE and GADGHCOMP. backfill is similar to GADGHCOMP, but the region outside of the
  106. image (which normally would be color three when complemented) is flood-filled to color zero. }
  107. GFLG_GADGBACKFILL = $0001;
  108. GADGBACKFILL = GFLG_GADGBACKFILL; // an old synonym
  109. NO_ICON_POSITION = $80000000; // if an icon does not really live anywhere, set its current position to here
  110. AM_VERSION = 1; // If you find am_Version >= AM_VERSION, you know this structure has at least the fields defined in this version of the include file
  111. type
  112. PAppMessage = ^TAppMessage;
  113. TAppMessage = record
  114. am_Message: TMessage; // standard message structure
  115. am_Type: Word; // message type AMTYPE_*
  116. am_UserData: LongWord; // application specific
  117. am_ID: LongWord; // application definable ID
  118. am_NumArgs: LongInt; // # of elements in arglist
  119. am_ArgList: PWBArgList; // the arguements themselves
  120. am_Version: Word; // will be AM_VERSION
  121. am_Class: Word; // message class AMCLASSICON_*
  122. am_MouseX: SmallInt; // mouse x position of event
  123. am_MouseY: SmallInt; // mouse y position of event
  124. am_Seconds: LongWord; // current system clock time
  125. am_Micros: LongWord; // current system clock time
  126. am_Reserved: array[0..7] of LongWord; // avoid recompilation
  127. end;
  128. // types of app messages
  129. const
  130. // am_Type
  131. AMTYPE_APPWINDOW = 7; // app window message
  132. AMTYPE_APPICON = 8; // app icon message
  133. AMTYPE_APPMENUITEM = 9; // app menu item message
  134. AMTYPE_APPWINDOWZONE = 10; // app menu item message
  135. //am_Class Classes of AppIcon messages (V44)
  136. AMCLASSICON_Open = 0; // The "Open" menu item was invoked, the icon got double-clicked or an icon got dropped on it.
  137. AMCLASSICON_Copy = 1; // The "Copy" menu item was invoked
  138. AMCLASSICON_Rename = 2; // The "Rename" menu item was invoked
  139. AMCLASSICON_Information = 3; // The "Information" menu item was invoked
  140. AMCLASSICON_Snapshot = 4; // The "Snapshot" menu item was invoked
  141. AMCLASSICON_UnSnapshot = 5; // The "UnSnapshot" menu item was invoked
  142. AMCLASSICON_LeaveOut = 6; // The "Leave Out" menu item was invoked
  143. AMCLASSICON_PutAway = 7; // The "Put Away" menu item was invoked
  144. AMCLASSICON_Delete = 8; // The "Delete" menu item was invoked
  145. AMCLASSICON_FormatDisk = 9; // The "Format Disk" menu item was invoked
  146. AMCLASSICON_EmptyTrash = 10; // The "Empty Trash" menu item was invoked
  147. AMCLASSICON_Selected = 11; // The icon is now selected
  148. AMCLASSICON_Unselected = 12; // The icon is now unselected
  149. // The following structures are private. These are just stub structures for code compatibility...
  150. type
  151. PAppWindow = ^TAppWindow;
  152. TAppWindow = record
  153. aw_PRIVATE: APTR;
  154. end;
  155. PAppWindowDropZone = ^TAppWindowDropZone;
  156. TAppWindowDropZone = record
  157. awdz_PRIVATE: APTR;
  158. end;
  159. PAppIcon = ^TAppIcon;
  160. TAppIcon = record
  161. ai_PRIVATE: APTR;
  162. end;
  163. PAppMenuItem = ^TAppMenuItem;
  164. TAppMenuItem = record
  165. ami_PRIVATE: APTR;
  166. end;
  167. PAppMenu = ^TAppMenu;
  168. TAppMenu = record
  169. am_PRIVATE: APTR;
  170. end;
  171. const
  172. // Tags for use with AddAppIconA()
  173. WBA_Dummy = TAG_USER + $A000;
  174. WBAPPICONA_SupportsOpen = WBA_Dummy + 1; // (Boolean) AppIcon responds to the "Open" menu item
  175. WBAPPICONA_SupportsCopy = WBA_Dummy + 2; // (Boolean) AppIcon responds to the "Copy" menu item
  176. WBAPPICONA_SupportsRename = WBA_Dummy + 3; // (Boolean) AppIcon responds to the "Rename" menu item
  177. WBAPPICONA_SupportsInformation = WBA_Dummy + 4; // (Boolean) AppIcon responds to the "Information" menu item
  178. WBAPPICONA_SupportsSnapshot = WBA_Dummy + 5; // (Boolean) AppIcon responds to the "Snapshot" menu item
  179. WBAPPICONA_SupportsUnSnapshot = WBA_Dummy + 6; // (Boolean) AppIcon responds to the "UnSnapshot" menu item
  180. WBAPPICONA_SupportsLeaveOut = WBA_Dummy + 7; // (Boolean) AppIcon responds to the "LeaveOut" menu item
  181. WBAPPICONA_SupportsPutAway = WBA_Dummy + 8; // (Boolean) AppIcon responds to the "PutAway" menu item
  182. WBAPPICONA_SupportsDelete = WBA_Dummy + 9; // (Boolean) AppIcon responds to the "Delete" menu item
  183. WBAPPICONA_SupportsFormatDisk = WBA_Dummy + 10; // (Boolean) AppIcon responds to the "FormatDisk" menu item
  184. WBAPPICONA_SupportsEmptyTrash = WBA_Dummy + 11; // (Boolean) AppIcon responds to the "EmptyTrash" menu item
  185. WBAPPICONA_PropagatePosition = WBA_Dummy + 12; // (Boolean) AppIcon position should be propagated back to original DiskObject
  186. WBAPPICONA_RenderHook = WBA_Dummy + 13; // (PHook) Callback hook to be invoked when rendering this icon
  187. WBAPPICONA_NotifySelectState = WBA_Dummy + 14; // (Boolean) AppIcon wants to be notified when its select state changes
  188. // Tags for use with AddAppMenuA()
  189. WBAPPMENUA_CommandKeyString = WBA_Dummy + 15; // (STRPTR) Command key string for this AppMenu
  190. // Tags for use with OpenWorkbenchObjectA()
  191. WBOPENA_ArgLock = WBA_Dummy + 16; // Corresponds to the wa_Lock member of a TWBArg
  192. WBOPENA_ArgName = WBA_Dummy + 17; // Corresponds to the wa_Name member of a TWBArg
  193. // Tags for use with WorkbenchControlA()
  194. WBCTRLA_IsOpen = WBA_Dummy + 18; // (PLongWord) Check if the named drawer is currently open
  195. WBCTRLA_DuplicateSearchPath = WBA_Dummy + 19; // (^BPTR) Create a duplicate of the Workbench private search path list
  196. WBCTRLA_FreeSearchPath = WBA_Dummy + 20; // (BPTR) Free the duplicated search path list
  197. WBCTRLA_GetDefaultStackSize = WBA_Dummy + 21; // (PLongWord) Get the default stack size for launching programs with
  198. WBCTRLA_SetDefaultStackSize = WBA_Dummy + 22; // (LongWord) Set the default stack size for launching programs with
  199. WBCTRLA_RedrawAppIcon = WBA_Dummy + 23; // (PAppIcon) Cause an AppIcon to be redrawn
  200. WBCTRLA_GetProgramList = WBA_Dummy + 24; // (PList) Get a list of currently running Workbench programs
  201. WBCTRLA_FreeProgramList = WBA_Dummy + 25; // (PList) Release the list of currently running Workbench programs
  202. // Tags for use with AddAppWindowDropZoneA()
  203. WBDZA_Left = WBA_Dummy + 26; // (SmallInt) Zone left edge
  204. WBDZA_RelRight = WBA_Dummy + 27; // (SmallInt) Zone left edge, if relative to the right edge of the window
  205. WBDZA_Top = WBA_Dummy + 28; // (SmallInt) Zone top edge
  206. WBDZA_RelBottom = WBA_Dummy + 29; // (SmallInt) Zone top edge, if relative to the bottom edge of the window
  207. WBDZA_Width = WBA_Dummy + 30; // (SmallInt) Zone width
  208. WBDZA_RelWidth = WBA_Dummy + 31; // (SmallInt) Zone width, if relative to the window width
  209. WBDZA_Height = WBA_Dummy + 32; // (SmallInt) Zone height
  210. WBDZA_RelHeight = WBA_Dummy + 33; // (SmallInt) Zone height, if relative to the window height
  211. WBDZA_Box = WBA_Dummy + 34; // (PIBox) Zone position and size
  212. WBDZA_Hook = WBA_Dummy + 35; // (PHook) Hook to invoke when the mouse enters or leave a drop zone
  213. // Tags for use with WorkbenchControlA()
  214. WBCTRLA_GetSelectedIconList = WBA_Dummy + 36; // (PList) Get a list of currently selected icons
  215. WBCTRLA_FreeSelectedIconList = WBA_Dummy + 37; // (PList) Release the list of currently selected icons
  216. WBCTRLA_GetOpenDrawerList = WBA_Dummy + 38; // (PList) Get a list of currently open drawers
  217. WBCTRLA_FreeOpenDrawerList = WBA_Dummy + 39; // (PList) Release the list of currently open icons
  218. WBA_Reserved1 = WBA_Dummy + 40;
  219. WBA_Reserved2 = WBA_Dummy + 41;
  220. WBCTRLA_GetHiddenDeviceList = WBA_Dummy + 42; // (PList) Get the list of hidden devices
  221. WBCTRLA_FreeHiddenDeviceList = WBA_Dummy + 43; // (PList) Release the list of hidden devices
  222. WBCTRLA_AddHiddenDeviceName = WBA_Dummy + 44; // (STRPTR) Add the name of a device which Workbench should never try to read a disk icon from
  223. WBCTRLA_RemoveHiddenDeviceName = WBA_Dummy + 45; // (STRPTR) Remove a name from list of hidden devices
  224. WBA_Reserved3 = WBA_Dummy + 46;
  225. WBCTRLA_GetTypeRestartTime = WBA_Dummy + 47; // (PLongWord) 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
  226. WBCTRLA_SetTypeRestartTime = WBA_Dummy + 48; // (LongWord) 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
  227. WBA_Reserved4 = WBA_Dummy + 49;
  228. WBA_Reserved5 = WBA_Dummy + 50;
  229. WBA_Reserved6 = WBA_Dummy + 51;
  230. WBA_Reserved7 = WBA_Dummy + 52;
  231. WBA_Reserved8 = WBA_Dummy + 53;
  232. WBA_Reserved9 = WBA_Dummy + 54;
  233. WBA_Reserved10 = WBA_Dummy + 55;
  234. WBA_Reserved11 = WBA_Dummy + 56;
  235. WBA_Reserved12 = WBA_Dummy + 57;
  236. WBA_Reserved13 = WBA_Dummy + 58;
  237. WBA_Reserved14 = WBA_Dummy + 59;
  238. WBA_Reserved15 = WBA_Dummy + 60;
  239. WBA_Reserved16 = WBA_Dummy + 61;
  240. WBA_Reserved17 = WBA_Dummy + 62;
  241. WBA_Reserved18 = WBA_Dummy + 63;
  242. WBA_Reserved19 = WBA_Dummy + 64;
  243. WBAPPMENUA_GetKey = WBA_Dummy + 65; // (PLongWord) 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
  244. WBAPPMENUA_UseKey = WBA_Dummy + 66; // (LongWord) This item should be attached to a sub menu; the key provided refers to the sub menu it should be attached to
  245. // V45
  246. WBCTRLA_GetCopyHook = WBA_Dummy + 69; // (PPHook) Obtain the hook that will be invoked when Workbench starts to copy files and data
  247. WBCTRLA_SetCopyHook = WBA_Dummy + 70; // (PHook) Install the hook that will be invoked when Workbench starts to copy files and data
  248. WBCTRLA_GetDeleteHook = WBA_Dummy + 71; // (PPHook) Obtain the hook that will be invoked when Workbench discards files and drawers or empties the trashcan
  249. WBCTRLA_SetDeleteHook = WBA_Dummy + 72; // (PHook) Install the hook that will be invoked when Workbench discards files and drawers or empties the trashcan
  250. WBCTRLA_GetTextInputHook = WBA_Dummy + 73; // (PPHook) 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
  251. WBCTRLA_SetTextInputHook = WBA_Dummy + 74; // (PHook) 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
  252. WBOPENA_Show = WBA_Dummy + 75; // (Byte) When opening a drawer, show all files or only icons? This must be one out of DDFLAGS_SHOWICONS, or DDFLAGS_SHOWALL
  253. WBOPENA_ViewBy = WBA_Dummy + 76; // (Byte) 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;
  254. WBAPPMENUA_GetTitleKey = WBA_Dummy + 77; // (PLongWord) 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
  255. WBCTRLA_AddSetupCleanupHook = WBA_Dummy + 78; // (PHook) Add a hook that will be invoked when Workbench is about to shut down (cleanup), and when Workbench has returned to operational state (setup)
  256. WBCTRLA_RemSetupCleanupHook = WBA_Dummy + 79; // (PHook) Remove a hook that has been installed with the WBCTRLA_AddSetupCleanupHook tag
  257. // V50
  258. WBAPPICONA_Clone = WBA_Dummy + 80; // (Boolean) Clone appicon default: False
  259. WBA_LAST_TAG = WBAPPICONA_Clone;
  260. // The message your setup/cleanup hook gets invoked with.
  261. type
  262. PSetupCleanupHookMsg = ^TSetupCleanupHookMsg;
  263. TSetupCleanupHookMsg = record
  264. schm_Length: LongWord;
  265. schm_State: LongInt; // SCHMSTATE_*
  266. end;
  267. const
  268. // schm_State
  269. SCHMSTATE_TryCleanup = 0; // Workbench will attempt to shut down now.
  270. SCHMSTATE_Cleanup = 1; // Workbench will really shut down now.
  271. SCHMSTATE_Setup = 2; // Workbench is operational again or could not be shut down.
  272. type
  273. // The message your AppIcon rendering hook gets invoked with.
  274. PAppIconRenderMsg = ^TAppIconRenderMsg;
  275. TAppIconRenderMsg = record
  276. arm_RastPort: PRastPort; // RastPort to render into
  277. arm_Icon: PDiskObject; // The icon to be rendered
  278. arm_Label: STRPTR; // The icon label txt
  279. arm_Tags: PTagItem; // Further tags to be passed on to DrawIconStateA().
  280. arm_Left: SmallInt; // \ Rendering origin, not taking the
  281. arm_Top: SmallInt; // / button border into account.
  282. arm_Width: SmallInt; // \ Limit your rendering to
  283. arm_Height: SmallInt; // / this area.
  284. arm_State: LongWord; // IDS_SELECTED, IDS_NORMAL, etc.
  285. end;
  286. // The message your drop zone hook gets invoked with. }
  287. PAppWindowDropZoneMsg = ^TAppWindowDropZoneMsg;
  288. TAppWindowDropZoneMsg = record
  289. adzm_RastPort: PRastPort; // RastPort to render into.
  290. adzm_DropZoneBox: TIBox; // Limit your rendering to this area.
  291. adzm_ID: LongWord; // \ These come from straight
  292. adzm_UserData: LongWord; // / from AddAppWindowDropZoneA().
  293. adzm_Action: LongInt; // See below for a list of actions. ADZMACTION_*
  294. end;
  295. const
  296. // adzm_Action
  297. ADZMACTION_Enter = 0;
  298. ADZMACTION_Leave = 1;
  299. type
  300. // The message your icon selection change hook is invoked with.
  301. PIconSelectMsg = ^TIconSelectMsg;
  302. TIconSelectMsg = record
  303. ism_Length: LongWord; // Size of this data structure (in bytes)
  304. ism_Drawer: BPTR; // Lock on the drawer this object resides in, NULL for Workbench backdrop (devices)
  305. ism_Name: STRPTR; // Name of the object in question
  306. ism_Type: Word; // One of WBDISK, WBDRAWER, WBTOOL, WBPROJECT, WBGARBAGE, WBDEVICE, WBKICK or WBAPPICON
  307. ism_Selected: WordBool; // True if currently selected, False otherwise.
  308. ism_Tags: PTagItem; // Pointer to the list of tag items passed to ChangeWorkbenchSelectionA()
  309. ism_DrawerWindow: PWindow; // Pointer to the window attached to this icon,if the icon is a drawer-like object.}
  310. ism_ParentWindow : PWindow;{ Pointer to the window the icon resides in. }
  311. ism_Left: SmallInt; // Position and size of the icon;
  312. ism_Top: SmallInt; // note that the icon may not entirely
  313. ism_Width: SmallInt; // reside within the visible bounds of
  314. ism_Height: SmallInt; // the parent window
  315. end;
  316. const
  317. // These are the values your hook code can return.
  318. ISMACTION_Unselect = 0; // Unselect the icon
  319. ISMACTION_Select = 1; // Select the icon
  320. ISMACTION_Ignore = 2; // Do not change the selection state.
  321. ISMACTION_Stop = 3; // Do not invoke the hook code again, leave the icon as it is.
  322. type
  323. // The messages your copy hook is invoked with.
  324. PCopyBeginMsg = ^TCopyBeginMsg;
  325. TCopyBeginMsg = record
  326. cbm_Length: LongWord; // Size of this data structure in bytes
  327. cbm_Action: LongInt; // Will be set to CPACTION_Begin (see below)
  328. cbm_SourceDrawer: BPTR; // A lock on the source drawer
  329. cbm_DestinationDrawer: BPTR; // A lock on the destination drawer
  330. end;
  331. PCopyDataMsg = ^TCopyDataMsg;
  332. TCopyDataMsg = record
  333. cdm_Length: LongWord; // Size of this data structure in bytes.
  334. cdm_Action: LongInt; // Will be set to CPACTION_Copy (see below).
  335. cdm_SourceLock: BPTR; // A lock on the parent directory of the source file/drawer.
  336. cdm_SourceName: STRPTR; // The name of the source file or drawer.
  337. cdm_DestinationLock: BPTR; // A lock on the parent directory of the destination file/drawer.
  338. 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
  339. // data is to be copied under a different name. For example, this is the case with the Workbench "Copy" command which
  340. // creates duplicates of file/drawers by prefixing the duplicate's name with "Copy_XXX_of".
  341. cdm_DestinationX: LongInt; // When the icon corresponding to the destination is written to disk, this is the position (put into its
  342. cdm_DestinationY: LongInt; // DiskObject^.do_CurrentX/DiskObject^.do_CurrentY fields) it should be placed at
  343. end;
  344. PCopyEndMsg = ^TCopyEndMsg;
  345. TCopyEndMsg = record
  346. cem_Length: LongWord; // Size of this data structure in bytes
  347. cem_Action: LongInt; // Will be set to CPACTION_End (see below)
  348. end;
  349. const
  350. CPACTION_Begin = 0; // This message arrives for each file or drawer to be copied.
  351. CPACTION_Copy = 1; // This message arrives when all files/drawers have been copied.
  352. CPACTION_End = 2;
  353. type
  354. // The messages your delete hook is invoked with.
  355. PDeleteBeginMsg = ^TDeleteBeginMsg;
  356. TDeleteBeginMsg = record
  357. dbm_Length: LongWord; // Size of this data structure in bytes.
  358. dbm_Action: LongInt; // Will be set to either DLACTION_BeginDiscard or DLACTION_BeginEmptyTrash (see below).
  359. end;
  360. PDeleteDataMsg = ^TDeleteDataMsg;
  361. TDeleteDataMsg = record
  362. ddm_Length: LongWord; // Size of this data structure in bytes.
  363. ddm_Action: LongInt; // Will be set to either DLACTION_DeleteContents or DLACTION_DeleteObject (see below).
  364. ddm_Lock: BPTR; // A Lock on the parent directory of the object whose contents or which itself should be deleted.
  365. ddm_Name: STRPTR; // The name of the object whose contents or which itself should be deleted.
  366. end;
  367. PDeleteEndMsg = ^TDeleteEndMsg;
  368. TDeleteEndMsg = record
  369. dem_Length: LongWord; // Size of this data structure in bytes
  370. dem_Action: LongInt; // Will be set to DLACTION_End (see below)
  371. end;
  372. const
  373. DLACTION_BeginDiscard = 0; // This indicates that the following delete operations are intended to empty the trashcan.
  374. DLACTION_BeginEmptyTrash = 1; // 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!
  375. DLACTION_DeleteContents = 3; // This indicates that the object described by lock and name should be deleted; this could be a file or an empty drawer.
  376. DLACTION_DeleteObject = 4; // This indicates that the deletion process is finished.
  377. DLACTION_End = 5;
  378. type
  379. // The messages your text input hook is invoked with.
  380. PTextInputMsg = ^TTextInputMsg;
  381. TTextInputMsg = record
  382. tim_Length: LongWord; // Size of this data structure in bytes.
  383. tim_Action: LongInt; // One of the TIACTION_* values listed below.
  384. tim_Prompt: STRPTR; // The Workbench suggested result, depending on what kind of input is requested (as indicated by the tim_Action member).
  385. end;
  386. const
  387. TIACTION_Rename = 0; // A file or drawer is to be renamed.
  388. TIACTION_RelabelVolume = 1; // A volume is to be relabeled.
  389. TIACTION_NewDrawer = 2; // A new drawer is to be created.
  390. TIACTION_Execute = 3; // A program or script is to be executed.
  391. // Parameters for the UpdateWorkbench() function.
  392. UPDATEWB_ObjectRemoved = 0; // Object has been deleted.
  393. UPDATEWB_ObjectAdded = 1; // Object is new or has changed.
  394. WORKBENCHNAME : PChar = 'workbench.library';
  395. var
  396. WorkbenchBase: PLibrary = nil;
  397. function AddAppIconA(Id: LongWord location 'd0'; UserData: LongWord location 'd1'; Text_: PChar location 'a0'; MsgPort: PMsgPort location 'a1'; Lock: BPTR location 'a2'; DiskObj: PDiskObject location 'a3'; const TagList: PTagItem location 'a4'): PAppIcon; syscall WorkbenchBase 060;
  398. function AddAppMenuItemA(Id: LongWord location 'd0'; UserData: LongWord location 'd1'; Text_: PChar location 'a0'; MsgPort: PMsgPort location 'a1'; const TagList: PTagItem location 'a2'): PAppMenuItem; syscall WorkbenchBase 072;
  399. function AddAppWindowA(Id: LongWord location 'd0'; UserData: LongWord location 'd1'; Window: PWindow location 'a0'; MsgPort: PMsgPort location 'a1'; const TagList: PTagItem location 'a2'): PAppWindow; syscall WorkbenchBase 048;
  400. function RemoveAppIcon(AppIcon: PAppIcon location 'a0'): LongBool; syscall WorkbenchBase 066;
  401. function RemoveAppMenuItem(AppMenuItem: PAppMenuItem location 'a0'): LongBool; syscall WorkbenchBase 078;
  402. function RemoveAppWindow(AppWindow: PAppWindow location 'a0'): LongBool; syscall WorkbenchBase 054;
  403. procedure WBInfo(Lock: BPTR location 'a0'; Name: STRPTR location 'a1'; Screen: PScreen location 'a2'); syscall WorkbenchBase 090;
  404. function AddAppWindowDropZoneA(Aw: PAppWindow location 'a0'; Id: LongWord location 'd0'; UserData: LongWord location 'd1'; const Tags: PTagItem location 'a1'): PAppWindowDropZone; syscall WorkbenchBase 114;
  405. function ChangeWorkbenchSelectionA(Name: STRPTR location 'a0'; Hook: PHook location 'a1'; const Tags: PTagItem location 'a2'): LongBool; syscall WorkbenchBase 126;
  406. function CloseWorkbenchObjectA(Name: STRPTR location 'a0'; const Tags: PTagItem location 'a1'): LongBool; syscall WorkbenchBase 102;
  407. function MakeWorkbenchObjectVisibleA(Name: STRPTR location 'a0'; const Tags: PTagItem location 'a1'): LongBool; syscall WorkbenchBase 132;
  408. function OpenWorkbenchObjectA(Name: STRPTR location 'a0'; const Tags: PTagItem location 'a1'): LongBool; syscall WorkbenchBase 096;
  409. function RemoveAppWindowDropZone(Aw: PAppWindow location 'a0'; DropZone: PAppWindowDropZone location 'a1'): LongBool; syscall WorkbenchBase 120;
  410. function WorkbenchControlA(Name: STRPTR location 'a0'; const Tags: PTagItem location 'a1'): LongBool; syscall WorkbenchBase 108;
  411. // V51
  412. function ManageDesktopObjectA(Name: PChar; Action: LongInt; Tags: PTagItem): Boolean; syscall BaseSysV WorkbenchBase 148;
  413. function CreateDrawerA(Drawer: PChar; Tags: PTagItem): Boolean; syscall BaseSysV WorkbenchBase 154;
  414. function CreateIconA(Name: PChar; Tags: PTagItem): Boolean; syscall BaseSysV WorkbenchBase 160;
  415. function AddAppIcon(Id: LongWord; UserData: LongWord; Text_: PChar; MsgPort: PMsgPort; Lock: BPTR; DiskObj: PDiskObject; const TagList: array of PtrUInt): PAppIcon; inline;
  416. function AddAppMenuItem(Id: LongWord; UserData: LongWord; Text_: PChar; MsgPort: PMsgPort; const Tags: array of PtrUInt): PAppMenuItem; inline;
  417. function AddAppWindow(Id: LongWord; UserData: LongWord; Window: PWindow; MsgPort: PMsgPort; const Tags: array of PtrUInt): PAppWindow; inline;
  418. function OpenWorkbenchObject(Name: PChar; const Tags: array of PtrUInt): LongBool; inline;
  419. function CloseWorkbenchObject(Name: PChar; const Tags: array of PtrUInt): LongBool; inline;
  420. function WorkbenchControl(Name: PChar; const Tags: array of PtrUInt): LongBool; inline;
  421. function AddAppWindowDropZone(Aw: PAppWindow; Id: LongWord; UserData: LongWord; const Tags: array of PtrUInt): PAppWindowDropZone; inline;
  422. function ChangeWorkbenchSelection(Name: STRPTR; Hook: PHook; const Tags: array of PtrUInt): LongBool; inline;
  423. function MakeWorkbenchObjectVisible(Name: STRPTR; const Tags: array of PtrUInt): LongBool; inline;
  424. // V51
  425. function ManageDesktopObjectTags(Name: PChar; Action: LongInt; const Tags: array of PtrUInt): Boolean; inline;
  426. function CreateDrawerTags(Drawer: PChar; const Tags: array of PtrUInt): Boolean; inline;
  427. function CreateIconTags(Name: PChar; const Tags: array of PtrUInt): Boolean; inline;
  428. implementation
  429. function AddAppIcon(Id: LongWord; UserData: LongWord; Text_: PChar; MsgPort: PMsgPort; Lock: BPTR; DiskObj: PDiskObject; const TagList: array of PtrUInt): PAppIcon;
  430. begin
  431. AddAppIcon := AddAppIconA(Id, UserData, Text_, MsgPort, Lock, Diskobj, @TagList);
  432. end;
  433. function AddAppMenuItem(Id: LongWord; UserData: LongWord; Text_: PChar; MsgPort: PMsgPort; const Tags: array of PtrUInt): PAppMenuItem;
  434. begin
  435. AddAppMenuItem := AddAppMenuItemA(Id, UserData, Text_, MsgPort, @Tags);
  436. end;
  437. function AddAppWindow(Id: LongWord; UserData: LongWord; Window: PWindow; MsgPort: PMsgPort; const Tags: array of PtrUInt): PAppWindow;
  438. begin
  439. AddAppWindow := AddAppWindowA(Id, UserData, Window, MsgPort, @Tags);
  440. end;
  441. function OpenWorkbenchObject(Name: PChar; const Tags: array of PtrUInt): LongBool;
  442. begin
  443. OpenWorkbenchObject := OpenWorkbenchObjectA(Name, @Tags);
  444. end;
  445. function CloseWorkbenchObject(Name: PChar; const Tags: array of PtrUInt): LongBool;
  446. begin
  447. CloseWorkbenchObject := CloseWorkbenchObjectA(Name, @Tags);
  448. end;
  449. function WorkbenchControl(Name: PChar; const Tags: array of PtrUInt): LongBool;
  450. begin
  451. WorkbenchControl := WorkbenchControlA(Name, @Tags);
  452. end;
  453. function AddAppWindowDropZone(Aw: PAppWindow; Id: LongWord; UserData: LongWord; const Tags: array of PtrUInt): PAppWindowDropZone;
  454. begin
  455. AddAppWindowDropZone := AddAppWindowDropZoneA(Aw, Id, UserData, @Tags);
  456. end;
  457. function ChangeWorkbenchSelection(Name: STRPTR; Hook: PHook; const Tags: array of PtrUInt): LongBool;
  458. begin
  459. ChangeWorkbenchSelection := ChangeWorkbenchSelectionA(Name, Hook, @Tags);
  460. end;
  461. function MakeWorkbenchObjectVisible(Name: STRPTR; const Tags: array of PtrUInt): LongBool;
  462. begin
  463. MakeWorkbenchObjectVisible := MakeWorkbenchObjectVisibleA(Name, @Tags);
  464. end;
  465. function ManageDesktopObjectTags(Name: PChar; Action: LongInt; const Tags: array of PtrUInt): Boolean;
  466. begin
  467. ManageDesktopObjectTags := ManageDesktopObjectA(Name, Action, @Tags);
  468. end;
  469. function CreateDrawerTags(Drawer: PChar; const Tags: array of PtrUInt): Boolean;
  470. begin
  471. CreateDrawerTags := CreateDrawerA(Drawer, @Tags);
  472. end;
  473. function CreateIconTags(Name: PChar; const Tags: array of PtrUInt): Boolean;
  474. begin
  475. CreateIconTags := CreateIconA(Name, @Tags);
  476. end;
  477. const
  478. LIBVERSION: LongWord = 0;
  479. initialization
  480. WorkbenchBase := OpenLibrary(WORKBENCHNAME, LIBVERSION);
  481. finalization
  482. if Assigned(WorkbenchBase) then
  483. CloseLibrary(WorkbenchBase);
  484. end.