workbench.pas 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957
  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. {
  13. History:
  14. Added overlay functions for PAnsiChar->Strings, functions
  15. and procedures.
  16. 14 Jul 2000.
  17. Changed tWBArg.wa_Lock from a pointer to a longint.
  18. 15 Aug 2000.
  19. Fixed tDiskObject.
  20. Member tDiskObject.do_CurrentX was defined as a pointer,
  21. should be longint.
  22. 17 Aug 2000.
  23. Added functions and procedures with array of const.
  24. For use with fpc 1.0.7. Thay are in systemvartags.
  25. 05 Nov 2002.
  26. Removed amigaoverlays, use smartlink instead.
  27. 05 Nov 2002.
  28. Added the defines use_amiga_smartlink and
  29. use_auto_openlib. Implemented autoopening of
  30. the library.
  31. 14 Jan 2003.
  32. Update for AmigaOS 3.9.
  33. A lot of new const and new records.
  34. New functions
  35. FUNCTION AddAppWindowDropZoneA
  36. FUNCTION ChangeWorkbenchSelectionA
  37. FUNCTION CloseWorkbenchObjectA
  38. FUNCTION MakeWorkbenchObjectVisibleA
  39. FUNCTION OpenWorkbenchObjectA
  40. FUNCTION RemoveAppWindowDropZone
  41. FUNCTION WorkbenchControlA
  42. Varargs functions are in systemvartags.
  43. 02 Feb 2003.
  44. Changed integer > smallint,
  45. cardinal > longword.
  46. 09 Feb 2003.
  47. [email protected]
  48. }
  49. {$PACKRECORDS 2}
  50. {$IFNDEF FPC_DOTTEDUNITS}
  51. unit workbench;
  52. {$ENDIF FPC_DOTTEDUNITS}
  53. INTERFACE
  54. {$IFDEF FPC_DOTTEDUNITS}
  55. uses Amiga.Core.Exec,Amiga.Core.Amigados,Amiga.Core.Utility,Amiga.Core.Intuition,Amiga.Core.Agraphics;
  56. {$ELSE FPC_DOTTEDUNITS}
  57. uses exec,amigados,utility,intuition,agraphics;
  58. {$ENDIF FPC_DOTTEDUNITS}
  59. Type
  60. pWBArg = ^tWBArg;
  61. tWBArg = record
  62. wa_Lock : BPTR; { a lock descriptor }
  63. wa_Name : STRPTR; { a string relative to that lock }
  64. end;
  65. WBArgList = Array [1..100] of tWBArg; { Only 1..smNumArgs are valid }
  66. pWBArgList = ^WBArgList;
  67. pWBStartup = ^tWBStartup;
  68. tWBStartup = record
  69. sm_Message : tMessage; { a standard message structure }
  70. sm_Process : pMsgPort; { the process descriptor for you }
  71. sm_Segment : BPTR; { a descriptor for your code }
  72. sm_NumArgs : Longint; { the number of elements in ArgList }
  73. sm_ToolWindow : STRPTR; { description of window }
  74. sm_ArgList : pWBArgList; { the arguments themselves }
  75. end;
  76. Const
  77. WBDISK = 1;
  78. WBDRAWER = 2;
  79. WBTOOL = 3;
  80. WBPROJECT = 4;
  81. WBGARBAGE = 5;
  82. WBDEVICE = 6;
  83. WBKICK = 7;
  84. WBAPPICON = 8;
  85. Type
  86. pOldDrawerData = ^tOldDrawerData;
  87. tOldDrawerData = record
  88. dd_NewWindow : tNewWindow; { args to open window }
  89. dd_CurrentX : Longint; { current x coordinate of origin }
  90. dd_CurrentY : Longint; { current y coordinate of origin }
  91. end;
  92. Const
  93. { the amount of DrawerData actually written to disk }
  94. OLDDRAWERDATAFILESIZE = 56; { sizeof(OldDrawerData) }
  95. Type
  96. pDrawerData = ^tDrawerData;
  97. tDrawerData = record
  98. dd_NewWindow : tNewWindow; { args to open window }
  99. dd_CurrentX : Longint; { current x coordinate of origin }
  100. dd_CurrentY : Longint; { current y coordinate of origin }
  101. dd_Flags : Longint; { flags for drawer }
  102. dd_ViewModes : Word; { view mode for drawer }
  103. end;
  104. Const
  105. { the amount of DrawerData actually written to disk }
  106. DRAWERDATAFILESIZE = 62; { sizeof(DrawerData) }
  107. DDVM_BYDEFAULT = 0;
  108. { view as icons }
  109. DDVM_BYICON = 1;
  110. { view as text, sorted by name }
  111. DDVM_BYNAME = 2;
  112. { view as text, sorted by date }
  113. DDVM_BYDATE = 3;
  114. { view as text, sorted by size }
  115. DDVM_BYSIZE = 4;
  116. { view as text, sorted by type }
  117. DDVM_BYTYPE = 5;
  118. { definitions for dd_Flags }
  119. { default (show only icons) }
  120. DDFLAGS_SHOWDEFAULT = 0;
  121. { show only icons }
  122. DDFLAGS_SHOWICONS = 1;
  123. { show all files }
  124. DDFLAGS_SHOWALL = 2;
  125. Type
  126. pDiskObject = ^tDiskObject;
  127. tDiskObject = record
  128. do_Magic : Word; { a magic number at the start of the file }
  129. do_Version : Word; { a version number, so we can change it }
  130. do_Gadget : tGadget; { a copy of in core gadget }
  131. do_Type : Byte;
  132. do_DefaultTool : STRPTR;
  133. do_ToolTypes : Pointer;
  134. do_CurrentX : Longint;
  135. do_CurrentY : Longint;
  136. do_DrawerData : pDrawerData;
  137. do_ToolWindow : STRPTR; { only applies to tools }
  138. do_StackSize : Longint; { only applies to tools }
  139. end;
  140. Const
  141. WB_DISKMAGIC = $e310; { a magic number, not easily impersonated }
  142. WB_DISKVERSION = 1; { our current version number }
  143. WB_DISKREVISION = 1; { our current revision number }
  144. {I only use the lower 8 bits of Gadget.UserData for the revision # }
  145. WB_DISKREVISIONMASK = 255;
  146. Type
  147. pFreeList = ^tFreeList;
  148. tFreeList = record
  149. fl_NumFree : smallint;
  150. fl_MemList : tList;
  151. end;
  152. Const
  153. { each message that comes into the WorkBenchPort must have a type field
  154. * in the preceeding short. These are the defines for this type
  155. }
  156. MTYPE_PSTD = 1; { a "standard Potion" message }
  157. MTYPE_TOOLEXIT = 2; { exit message from our tools }
  158. MTYPE_DISKCHANGE = 3; { dos telling us of a disk change }
  159. MTYPE_TIMER = 4; { we got a timer tick }
  160. MTYPE_CLOSEDOWN = 5; { <unimplemented> }
  161. MTYPE_IOPROC = 6; { <unimplemented> }
  162. MTYPE_APPWINDOW = 7; { msg from an app window }
  163. MTYPE_APPICON = 8; { msg from an app icon }
  164. MTYPE_APPMENUITEM = 9; { msg from an app menuitem }
  165. MTYPE_COPYEXIT = 10; { exit msg from copy process }
  166. MTYPE_ICONPUT = 11; { msg from PutDiskObject in icon.library }
  167. { workbench does different complement modes for its gadgets.
  168. * It supports separate images, complement mode, and backfill mode.
  169. * The first two are identical to intuitions GADGIMAGE and GADGHCOMP.
  170. * backfill is similar to GADGHCOMP, but the region outside of the
  171. * image (which normally would be color three when complemented)
  172. * is flood-filled to color zero.
  173. }
  174. GFLG_GADGBACKFILL = $0001;
  175. GADGBACKFILL = $0001; { an old synonym }
  176. { if an icon does not really live anywhere, set its current position
  177. * to here
  178. }
  179. NO_ICON_POSITION = $80000000;
  180. { If you find am_Version >= AM_VERSION, you know this structure has
  181. * at least the fields defined in this version of the include file
  182. }
  183. AM_VERSION = 1;
  184. Type
  185. pAppMessage = ^tAppMessage;
  186. tAppMessage = record
  187. am_Message : tMessage; { standard message structure }
  188. am_Type : Word; { message type }
  189. am_UserData : ULONG; { application specific }
  190. am_ID : ULONG; { application definable ID }
  191. am_NumArgs : ULONG; { # of elements in arglist }
  192. am_ArgList : pWBArgList; { the arguements themselves }
  193. am_Version : Word; { will be AM_VERSION }
  194. am_Class : Word; { message class }
  195. am_MouseX : smallint; { mouse x position of event }
  196. am_MouseY : smallint; { mouse y position of event }
  197. am_Seconds : ULONG; { current system clock time }
  198. am_Micros : ULONG; { current system clock time }
  199. am_Reserved : Array[0..7] of ULONG; { avoid recompilation }
  200. END;
  201. {* types of app messages *}
  202. const
  203. AMTYPE_APPWINDOW = 7; {* app window message *}
  204. AMTYPE_APPICON = 8; {* app icon message *}
  205. AMTYPE_APPMENUITEM = 9; {* app menu item message *}
  206. { Classes of AppIcon messages (V44) }
  207. { The "Open" menu item was invoked,
  208. the icon got double-clicked or an
  209. icon got dropped on it.
  210. }
  211. AMCLASSICON_Open = 0;
  212. { The "Copy" menu item was invoked }
  213. AMCLASSICON_Copy = 1;
  214. { The "Rename" menu item was invoked }
  215. AMCLASSICON_Rename = 2;
  216. { The "Information" menu item was invoked }
  217. AMCLASSICON_Information = 3;
  218. { The "Snapshot" menu item was invoked }
  219. AMCLASSICON_Snapshot = 4;
  220. { The "UnSnapshot" menu item was invoked }
  221. AMCLASSICON_UnSnapshot = 5;
  222. { The "Leave Out" menu item was invoked }
  223. AMCLASSICON_LeaveOut = 6;
  224. { The "Put Away" menu item was invoked }
  225. AMCLASSICON_PutAway = 7;
  226. { The "Delete" menu item was invoked }
  227. AMCLASSICON_Delete = 8;
  228. { The "Format Disk" menu item was invoked }
  229. AMCLASSICON_FormatDisk = 9;
  230. { The "Empty Trash" menu item was invoked }
  231. AMCLASSICON_EmptyTrash = 10;
  232. { The icon is now selected }
  233. AMCLASSICON_Selected = 11;
  234. { The icon is now unselected }
  235. AMCLASSICON_Unselected = 12;
  236. {
  237. * The following structures are private. These are just stub
  238. * structures for code compatibility...
  239. }
  240. type
  241. tAppWindow = record
  242. aw_PRIVATE : Pointer;
  243. END;
  244. pAppWindow = ^tAppWindow;
  245. tAppIcon = record
  246. ai_PRIVATE : Pointer;
  247. END;
  248. pAppIcon = ^tAppIcon;
  249. tAppMenuItem = record
  250. ami_PRIVATE : Pointer;
  251. END;
  252. pAppMenuItem = ^tAppMenuItem;
  253. PAppWindowDropZone = ^tAppWindowDropZone;
  254. tAppWindowDropZone = record
  255. awdz_PRIVATE : pointer;
  256. end;
  257. PAppMenu = ^tAppMenu;
  258. tAppMenu = record
  259. am_PRIVATE : pointer;
  260. end;
  261. const
  262. WBA_Dummy = TAG_USER + $A000;
  263. { }
  264. { Tags for use with AddAppIconA() }
  265. { AppIcon responds to the "Open" menu item (BOOL). }
  266. WBAPPICONA_SupportsOpen = WBA_Dummy + 1;
  267. { AppIcon responds to the "Copy" menu item (BOOL). }
  268. WBAPPICONA_SupportsCopy = WBA_Dummy + 2;
  269. { AppIcon responds to the "Rename" menu item (BOOL). }
  270. WBAPPICONA_SupportsRename = WBA_Dummy + 3;
  271. { AppIcon responds to the "Information" menu item (BOOL). }
  272. WBAPPICONA_SupportsInformation = WBA_Dummy + 4;
  273. { AppIcon responds to the "Snapshot" menu item (BOOL). }
  274. WBAPPICONA_SupportsSnapshot = WBA_Dummy + 5;
  275. { AppIcon responds to the "UnSnapshot" menu item (BOOL). }
  276. WBAPPICONA_SupportsUnSnapshot = WBA_Dummy + 6;
  277. { AppIcon responds to the "LeaveOut" menu item (BOOL). }
  278. WBAPPICONA_SupportsLeaveOut = WBA_Dummy + 7;
  279. { AppIcon responds to the "PutAway" menu item (BOOL). }
  280. WBAPPICONA_SupportsPutAway = WBA_Dummy + 8;
  281. { AppIcon responds to the "Delete" menu item (BOOL). }
  282. WBAPPICONA_SupportsDelete = WBA_Dummy + 9;
  283. { AppIcon responds to the "FormatDisk" menu item (BOOL). }
  284. WBAPPICONA_SupportsFormatDisk = WBA_Dummy + 10;
  285. { AppIcon responds to the "EmptyTrash" menu item (BOOL). }
  286. WBAPPICONA_SupportsEmptyTrash = WBA_Dummy + 11;
  287. { AppIcon position should be propagated back to original DiskObject (BOOL). }
  288. WBAPPICONA_PropagatePosition = WBA_Dummy + 12;
  289. { Callback hook to be invoked when rendering this icon (struct Hook ). }
  290. WBAPPICONA_RenderHook = WBA_Dummy + 13;
  291. { AppIcon wants to be notified when its select state changes (BOOL). }
  292. WBAPPICONA_NotifySelectState = WBA_Dummy + 14;
  293. {**************************************************************************}
  294. { Tags for use with AddAppMenuA() }
  295. { Command key string for this AppMenu (STRPTR). }
  296. WBAPPMENUA_CommandKeyString = WBA_Dummy + 15;
  297. { Item to be added should get sub menu items attached to; make room for it,
  298. then return the key to use later for attaching the items (ULONG ).
  299. }
  300. WBAPPMENUA_GetKey = WBA_Dummy + 65;
  301. { This item should be attached to a sub menu; the key provided refers to
  302. the sub menu it should be attached to (ULONG).
  303. }
  304. WBAPPMENUA_UseKey = WBA_Dummy + 66;
  305. { Item to be added is in fact a new menu title; make room for it, then
  306. return the key to use later for attaching the items (ULONG ).
  307. }
  308. WBAPPMENUA_GetTitleKey = WBA_Dummy + 77;
  309. {**************************************************************************}
  310. { Tags for use with OpenWorkbenchObjectA() }
  311. { Corresponds to the wa_Lock member of a struct WBArg }
  312. WBOPENA_ArgLock = WBA_Dummy + 16;
  313. { Corresponds to the wa_Name member of a struct WBArg }
  314. WBOPENA_ArgName = WBA_Dummy + 17;
  315. { When opening a drawer, show all files or only icons?
  316. This must be one out of DDFLAGS_SHOWICONS,
  317. or DDFLAGS_SHOWALL; (UBYTE); (V45)
  318. }
  319. WBOPENA_Show = WBA_Dummy + 75;
  320. { When opening a drawer, view the contents by icon, name,
  321. date, size or type? This must be one out of DDVM_BYICON,
  322. DDVM_BYNAME, DDVM_BYDATE, DDVM_BYSIZE or DDVM_BYTYPE;
  323. (UBYTE); (V45)
  324. }
  325. WBOPENA_ViewBy = WBA_Dummy + 76;
  326. {**************************************************************************}
  327. { Tags for use with WorkbenchControlA() }
  328. { Check if the named drawer is currently open (LONG ). }
  329. WBCTRLA_IsOpen = WBA_Dummy + 18;
  330. { Create a duplicate of the Workbench private search path list (BPTR ). }
  331. WBCTRLA_DuplicateSearchPath = WBA_Dummy + 19;
  332. { Free the duplicated search path list (BPTR). }
  333. WBCTRLA_FreeSearchPath = WBA_Dummy + 20;
  334. { Get the default stack size for launching programs with (ULONG ). }
  335. WBCTRLA_GetDefaultStackSize = WBA_Dummy + 21;
  336. { Set the default stack size for launching programs with (ULONG). }
  337. WBCTRLA_SetDefaultStackSize = WBA_Dummy + 22;
  338. { Cause an AppIcon to be redrawn (struct AppIcon ). }
  339. WBCTRLA_RedrawAppIcon = WBA_Dummy + 23;
  340. { Get a list of currently running Workbench programs (struct List ). }
  341. WBCTRLA_GetProgramList = WBA_Dummy + 24;
  342. { Release the list of currently running Workbench programs (struct List ). }
  343. WBCTRLA_FreeProgramList = WBA_Dummy + 25;
  344. { Get a list of currently selected icons (struct List ). }
  345. WBCTRLA_GetSelectedIconList = WBA_Dummy + 36;
  346. { Release the list of currently selected icons (struct List ). }
  347. WBCTRLA_FreeSelectedIconList = WBA_Dummy + 37;
  348. { Get a list of currently open drawers (struct List ). }
  349. WBCTRLA_GetOpenDrawerList = WBA_Dummy + 38;
  350. { Release the list of currently open icons (struct List ). }
  351. WBCTRLA_FreeOpenDrawerList = WBA_Dummy + 39;
  352. { Get the list of hidden devices (struct List ). }
  353. WBCTRLA_GetHiddenDeviceList = WBA_Dummy + 42;
  354. { Release the list of hidden devices (struct List ). }
  355. WBCTRLA_FreeHiddenDeviceList = WBA_Dummy + 43;
  356. { Add the name of a device which Workbench should never try to
  357. read a disk icon from (STRPTR).
  358. }
  359. WBCTRLA_AddHiddenDeviceName = WBA_Dummy + 44;
  360. { Remove a name from list of hidden devices (STRPTR). }
  361. WBCTRLA_RemoveHiddenDeviceName = WBA_Dummy + 45;
  362. { Get the number of seconds that have to pass before typing
  363. the next character in a drawer window will restart
  364. with a new file name (ULONG ).
  365. }
  366. WBCTRLA_GetTypeRestartTime = WBA_Dummy + 47;
  367. { Set the number of seconds that have to pass before typing
  368. the next character in a drawer window will restart
  369. with a new file name (ULONG).
  370. }
  371. WBCTRLA_SetTypeRestartTime = WBA_Dummy + 48;
  372. { Obtain the hook that will be invoked when Workbench starts
  373. to copy files and data (struct Hook ); (V45)
  374. }
  375. WBCTRLA_GetCopyHook = WBA_Dummy + 69;
  376. { Install the hook that will be invoked when Workbench starts
  377. to copy files and data (struct Hook ); (V45)
  378. }
  379. WBCTRLA_SetCopyHook = WBA_Dummy + 70;
  380. { Obtain the hook that will be invoked when Workbench discards
  381. files and drawers or empties the trashcan (struct Hook );
  382. (V45).
  383. }
  384. WBCTRLA_GetDeleteHook = WBA_Dummy + 71;
  385. { Install the hook that will be invoked when Workbench discards
  386. files and drawers or empties the trashcan (struct Hook );
  387. (V45).
  388. }
  389. WBCTRLA_SetDeleteHook = WBA_Dummy + 72;
  390. { Obtain the hook that will be invoked when Workbench requests
  391. that the user enters text, such as when a file is to be renamed
  392. or a new drawer is to be created (struct Hook ); (V45)
  393. }
  394. WBCTRLA_GetTextInputHook = WBA_Dummy + 73;
  395. { Install the hook that will be invoked when Workbench requests
  396. that the user enters text, such as when a file is to be renamed
  397. or a new drawer is to be created (struct Hook ); (V45)
  398. }
  399. WBCTRLA_SetTextInputHook = WBA_Dummy + 74;
  400. { Add a hook that will be invoked when Workbench is about
  401. to shut down (cleanup), and when Workbench has returned
  402. to operational state (setup) (struct Hook ); (V45)
  403. }
  404. WBCTRLA_AddSetupCleanupHook = WBA_Dummy + 78;
  405. { Remove a hook that has been installed with the
  406. WBCTRLA_AddSetupCleanupHook tag (struct Hook ); (V45)
  407. }
  408. WBCTRLA_RemSetupCleanupHook = WBA_Dummy + 79;
  409. {**************************************************************************}
  410. { The message your setup/cleanup hook gets invoked with. }
  411. type
  412. PSetupCleanupHookMsg = ^tSetupCleanupHookMsg;
  413. tSetupCleanupHookMsg = record
  414. schm_Length : ULONG;
  415. schm_State : LONG;
  416. end;
  417. const
  418. { Workbench will attempt to shut down now. }
  419. SCHMSTATE_TryCleanup = 0;
  420. { Workbench will really shut down now. }
  421. SCHMSTATE_Cleanup = 1;
  422. { Workbench is operational again or
  423. could not be shut down.
  424. }
  425. SCHMSTATE_Setup = 2;
  426. {**************************************************************************}
  427. { Tags for use with AddAppWindowDropZoneA() }
  428. { Zone left edge (WORD) }
  429. WBDZA_Left = WBA_Dummy + 26;
  430. { Zone left edge, if relative to the right edge of the window (WORD) }
  431. WBDZA_RelRight = WBA_Dummy + 27;
  432. { Zone top edge (WORD) }
  433. WBDZA_Top = WBA_Dummy + 28;
  434. { Zone top edge, if relative to the bottom edge of the window (WORD) }
  435. WBDZA_RelBottom = WBA_Dummy + 29;
  436. { Zone width (WORD) }
  437. WBDZA_Width = WBA_Dummy + 30;
  438. { Zone width, if relative to the window width (WORD) }
  439. WBDZA_RelWidth = WBA_Dummy + 31;
  440. { Zone height (WORD) }
  441. WBDZA_Height = WBA_Dummy + 32;
  442. { Zone height, if relative to the window height (WORD) }
  443. WBDZA_RelHeight = WBA_Dummy + 33;
  444. { Zone position and size (struct IBox ). }
  445. WBDZA_Box = WBA_Dummy + 34;
  446. { Hook to invoke when the mouse enters or leave a drop zone (struct Hook ). }
  447. WBDZA_Hook = WBA_Dummy + 35;
  448. {**************************************************************************}
  449. { Reserved tags; don't use! }
  450. WBA_Reserved1 = WBA_Dummy + 40;
  451. WBA_Reserved2 = WBA_Dummy + 41;
  452. WBA_Reserved3 = WBA_Dummy + 46;
  453. WBA_Reserved4 = WBA_Dummy + 49;
  454. WBA_Reserved5 = WBA_Dummy + 50;
  455. WBA_Reserved6 = WBA_Dummy + 51;
  456. WBA_Reserved7 = WBA_Dummy + 52;
  457. WBA_Reserved8 = WBA_Dummy + 53;
  458. WBA_Reserved9 = WBA_Dummy + 54;
  459. WBA_Reserved10 = WBA_Dummy + 55;
  460. WBA_Reserved11 = WBA_Dummy + 56;
  461. WBA_Reserved12 = WBA_Dummy + 57;
  462. WBA_Reserved13 = WBA_Dummy + 58;
  463. WBA_Reserved14 = WBA_Dummy + 59;
  464. WBA_Reserved15 = WBA_Dummy + 60;
  465. WBA_Reserved16 = WBA_Dummy + 61;
  466. WBA_Reserved17 = WBA_Dummy + 62;
  467. WBA_Reserved18 = WBA_Dummy + 63;
  468. WBA_Reserved19 = WBA_Dummy + 64;
  469. WBA_Reserved20 = WBA_Dummy + 67;
  470. WBA_Reserved21 = WBA_Dummy + 68;
  471. {**************************************************************************}
  472. WBA_LAST_TAG = WBA_Dummy + 79;
  473. {**************************************************************************}
  474. { The message your AppIcon rendering hook gets invoked with. }
  475. type
  476. PAppIconRenderMsg = ^tAppIconRenderMsg;
  477. tAppIconRenderMsg = record
  478. arm_RastPort : PRastPort; { RastPort to render into }
  479. arm_Icon : PDiskObject; { The icon to be rendered }
  480. arm_Label : STRPTR; { The icon label txt }
  481. arm_Tags : PTagItem; { Further tags to be passed on
  482. * to DrawIconStateA().
  483. }
  484. arm_Left : WORD; { \ Rendering origin, not taking the }
  485. arm_Top : WORD; { / button border into account. }
  486. arm_Width : WORD; { \ Limit your rendering to }
  487. arm_Height : WORD; { / this area. }
  488. arm_State : ULONG; { IDS_SELECTED, IDS_NORMAL, etc. }
  489. end;
  490. { The message your drop zone hook gets invoked with. }
  491. PAppWindowDropZoneMsg = ^tAppWindowDropZoneMsg;
  492. tAppWindowDropZoneMsg = record
  493. adzm_RastPort : PRastPort; { RastPort to render into. }
  494. adzm_DropZoneBox : tIBox; { Limit your rendering to this area. }
  495. adzm_ID : ULONG; { \ These come from straight }
  496. adzm_UserData : ULONG; { / from AddAppWindowDropZoneA(). }
  497. adzm_Action : LONG; { See below for a list of actions. }
  498. end;
  499. const
  500. ADZMACTION_Enter = 0;
  501. ADZMACTION_Leave = 1;
  502. {**************************************************************************}
  503. { The message your icon selection change hook is invoked with. }
  504. type
  505. PIconSelectMsg = ^tIconSelectMsg;
  506. tIconSelectMsg = record
  507. { Size of this data structure (in bytes). }
  508. ism_Length : ULONG;
  509. { Lock on the drawer this object resides in,
  510. * NULL for Workbench backdrop (devices).
  511. }
  512. ism_Drawer : BPTR;
  513. { Name of the object in question. }
  514. ism_Name : STRPTR;
  515. { One of WBDISK, WBDRAWER, WBTOOL, WBPROJECT,
  516. * WBGARBAGE, WBDEVICE, WBKICK or WBAPPICON.
  517. }
  518. ism_Type : UWORD;
  519. { TRUE if currently selected, FALSE otherwise. }
  520. ism_Selected : BOOL;
  521. { Pointer to the list of tag items passed to
  522. * ChangeWorkbenchSelectionA().
  523. }
  524. ism_Tags : PTagItem;
  525. { Pointer to the window attached to this icon,
  526. * if the icon is a drawer-like object.
  527. }
  528. ism_DrawerWindow : PWindow;
  529. { Pointer to the window the icon resides in. }
  530. ism_ParentWindow : PWindow;
  531. { Position and size of the icon; note that the
  532. * icon may not entirely reside within the visible
  533. * bounds of the parent window.
  534. }
  535. ism_Left : WORD;
  536. ism_Top : WORD;
  537. ism_Width : WORD;
  538. ism_Height : WORD;
  539. end;
  540. { These are the values your hook code can return. }
  541. const
  542. { Unselect the icon }
  543. ISMACTION_Unselect = 0;
  544. { Select the icon }
  545. ISMACTION_Select = 1;
  546. { Do not change the selection state. }
  547. ISMACTION_Ignore = 2;
  548. { Do not invoke the hook code again,
  549. leave the icon as it is.
  550. }
  551. ISMACTION_Stop = 3;
  552. {**************************************************************************}
  553. { The messages your copy hook is invoked with. }
  554. type
  555. PCopyBeginMsg = ^tCopyBeginMsg;
  556. tCopyBeginMsg = record
  557. cbm_Length : ULONG; { Size of this data structure in bytes. }
  558. cbm_Action : LONG; { Will be set to CPACTION_Begin (see below). }
  559. cbm_SourceDrawer : BPTR; { A lock on the source drawer. }
  560. cbm_DestinationDrawer : BPTR; { A lock on the destination drawer. }
  561. end;
  562. PCopyDataMsg = ^tCopyDataMsg;
  563. tCopyDataMsg = record
  564. cdm_Length : ULONG; { Size of this data structure in bytes. }
  565. cdm_Action : LONG; { Will be set to CPACTION_Copy (see below). }
  566. cdm_SourceLock : BPTR; { A lock on the parent directory of the
  567. * source file/drawer.
  568. }
  569. cdm_SourceName : STRPTR; { The name of the source file or drawer. }
  570. cdm_DestinationLock : BPTR; { A lock on the parent directory of the
  571. * destination file/drawer.
  572. }
  573. cdm_DestinationName : STRPTR; { The name of the destination file/drawer.
  574. * This may or may not match the name of
  575. * the source file/drawer in case the
  576. * data is to be copied under a different
  577. * name. For example, this is the case
  578. * with the Workbench "Copy" command which
  579. * creates duplicates of file/drawers by
  580. * prefixing the duplicate's name with
  581. * "Copy_XXX_of".
  582. }
  583. cdm_DestinationX : LONG; { When the icon corresponding to the
  584. * destination is written to disk, this
  585. * is the position (put into its
  586. * DiskObject->do_CurrentX/DiskObject->do_CurrentY
  587. * fields) it should be placed at.
  588. }
  589. cdm_DestinationY : LONG;
  590. end;
  591. PCopyEndMsg = ^tCopyEndMsg;
  592. tCopyEndMsg = record
  593. cem_Length : ULONG; { Size of this data structure in bytes. }
  594. cem_Action : LONG; { Will be set to CPACTION_End (see below). }
  595. end;
  596. const
  597. CPACTION_Begin = 0;
  598. { This message arrives for each file or
  599. drawer to be copied.
  600. }
  601. CPACTION_Copy = 1;
  602. { This message arrives when all files/drawers
  603. have been copied.
  604. }
  605. CPACTION_End = 2;
  606. {**************************************************************************}
  607. { The messages your delete hook is invoked with. }
  608. type
  609. PDeleteBeginMsg = ^tDeleteBeginMsg;
  610. tDeleteBeginMsg = record
  611. dbm_Length : ULONG; { Size of this data structure in bytes. }
  612. dbm_Action : LONG; { Will be set to either DLACTION_BeginDiscard
  613. * or DLACTION_BeginEmptyTrash (see below).
  614. }
  615. end;
  616. PDeleteDataMsg = ^tDeleteDataMsg;
  617. tDeleteDataMsg = record
  618. ddm_Length : ULONG; { Size of this data structure in bytes. }
  619. ddm_Action : LONG; { Will be set to either DLACTION_DeleteContents
  620. * or DLACTION_DeleteObject (see below).
  621. }
  622. ddm_Lock : BPTR; { A Lock on the parent directory of the object
  623. * whose contents or which itself should be
  624. * deleted.
  625. }
  626. ddm_Name : STRPTR; { The name of the object whose contents or
  627. * which itself should be deleted.
  628. }
  629. end;
  630. PDeleteEndMsg = ^tDeleteEndMsg;
  631. tDeleteEndMsg = record
  632. dem_Length : ULONG; { Size of this data structure in bytes. }
  633. dem_Action : LONG; { Will be set to DLACTION_End (see below). }
  634. end;
  635. const
  636. DLACTION_BeginDiscard = 0;
  637. { This indicates that the following
  638. delete operations are intended to
  639. empty the trashcan.
  640. }
  641. DLACTION_BeginEmptyTrash = 1;
  642. { This indicates that the object
  643. described by lock and name refers
  644. to a drawer; you should empty its
  645. contents but DO NOT delete the
  646. drawer itself!
  647. }
  648. DLACTION_DeleteContents = 3;
  649. { This indicates that the object
  650. described by lock and name should
  651. be deleted; this could be a file
  652. or an empty drawer.
  653. }
  654. DLACTION_DeleteObject = 4;
  655. { This indicates that the
  656. deletion process is finished.
  657. }
  658. DLACTION_End = 5;
  659. {**************************************************************************}
  660. { The messages your text input hook is invoked with. }
  661. type
  662. PTextInputMsg = ^tTextInputMsg;
  663. tTextInputMsg = record
  664. tim_Length : ULONG; { Size of this data structure
  665. * in bytes.
  666. }
  667. tim_Action : LONG; { One of the TIACTION_...
  668. * values listed below.
  669. }
  670. tim_Prompt : STRPTR; { The Workbench suggested
  671. * result, depending on what
  672. * kind of input is requested
  673. * (as indicated by the
  674. * tim_Action member).
  675. }
  676. end;
  677. const
  678. { A file or drawer is to be
  679. * renamed.
  680. }
  681. TIACTION_Rename = 0;
  682. { A volume is to be relabeled. }
  683. TIACTION_RelabelVolume = 1;
  684. { A new drawer is to be created. }
  685. TIACTION_NewDrawer = 2;
  686. { A program or script is to be
  687. executed.
  688. }
  689. TIACTION_Execute = 3;
  690. {**************************************************************************}
  691. { Parameters for the UpdateWorkbench() function. }
  692. { Object has been deleted. }
  693. UPDATEWB_ObjectRemoved = 0;
  694. { Object is new or has changed. }
  695. UPDATEWB_ObjectAdded = 1;
  696. WORKBENCHNAME : PAnsiChar = 'workbench.library';
  697. VAR
  698. WorkbenchBase : pLibrary = nil;
  699. FUNCTION AddAppIconA(id : ULONG location 'd0'; userdata : ULONG location 'd1'; text_ : PAnsiChar location 'a0'; msgport : pMsgPort location 'a1'; lock : BPTR location 'a2'; diskobj : pDiskObject location 'a3'; const taglist : pTagItem location 'a4') : pAppIcon; syscall WorkbenchBase 060;
  700. FUNCTION AddAppMenuItemA(id : ULONG location 'd0'; userdata : ULONG location 'd1'; text_ : PAnsiChar location 'a0'; msgport : pMsgPort location 'a1'; const taglist : pTagItem location 'a2') : pAppMenuItem; syscall WorkbenchBase 072;
  701. FUNCTION AddAppWindowA(id : ULONG location 'd0'; userdata : ULONG location 'd1'; window : pWindow location 'a0'; msgport : pMsgPort location 'a1'; const taglist : pTagItem location 'a2') : pAppWindow; syscall WorkbenchBase 048;
  702. FUNCTION RemoveAppIcon(appIcon : pAppIcon location 'a0') : longbool; syscall WorkbenchBase 066;
  703. FUNCTION RemoveAppMenuItem(appMenuItem : pAppMenuItem location 'a0') : longbool; syscall WorkbenchBase 078;
  704. FUNCTION RemoveAppWindow(appWindow : pAppWindow location 'a0') : longbool; syscall WorkbenchBase 054;
  705. PROCEDURE WBInfo(lock : BPTR location 'a0'; name : PAnsiChar location 'a1'; screen : pScreen location 'a2'); syscall WorkbenchBase 090;
  706. FUNCTION AddAppWindowDropZoneA(aw : pAppWindow location 'a0'; id : longword location 'd0'; userdata : longword location 'd1'; const tags : pTagItem location 'a1') : pAppWindowDropZone; syscall WorkbenchBase 114;
  707. FUNCTION ChangeWorkbenchSelectionA(name : PAnsiChar location 'a0'; hook : pHook location 'a1'; const tags : pTagItem location 'a2') : longbool; syscall WorkbenchBase 126;
  708. FUNCTION CloseWorkbenchObjectA(name : PAnsiChar location 'a0'; const tags : pTagItem location 'a1') : longbool; syscall WorkbenchBase 102;
  709. FUNCTION MakeWorkbenchObjectVisibleA(name : PAnsiChar location 'a0'; const tags : pTagItem location 'a1') : longbool; syscall WorkbenchBase 132;
  710. FUNCTION OpenWorkbenchObjectA(name : PAnsiChar location 'a0'; const tags : pTagItem location 'a1') : longbool; syscall WorkbenchBase 096;
  711. FUNCTION RemoveAppWindowDropZone(aw : pAppWindow location 'a0'; dropZone : pAppWindowDropZone location 'a1') : longbool; syscall WorkbenchBase 120;
  712. FUNCTION WorkbenchControlA(name : PAnsiChar location 'a0'; const tags : pTagItem location 'a1') : longbool; syscall WorkbenchBase 108;
  713. function AddAppIcon(id : ULONG; userdata : ULONG; text_ : PAnsiChar; msgport : pMsgPort; lock: BPTR; diskobj : pDiskObject; const taglist : array of PtrUInt) : pAppIcon;
  714. function AddAppMenuItem(id : ULONG; userdata : ULONG; text_ : PAnsiChar; msgport : pMsgPort; Const argv : array of PtrUInt) : pAppMenuItem;
  715. function AddAppWindow(id : ULONG; userdata : ULONG; window : pWindow; msgport : pMsgPort; Const argv : array of PtrUInt) : pAppWindow;
  716. { overlays }
  717. FUNCTION AddAppIconA(id : ULONG; userdata : ULONG; const text_ : RawByteString; msgport : pMsgPort; lock : BPTR; diskobj : pDiskObject;const taglist : pTagItem) : pAppIcon;
  718. FUNCTION AddAppMenuItemA(id : ULONG; userdata : ULONG; const text_ : RawByteString; msgport : pMsgPort;const taglist : pTagItem) : pAppMenuItem;
  719. PROCEDURE WBInfo(lock : BPTR; const name : RawByteString; screen : pScreen);
  720. FUNCTION ChangeWorkbenchSelectionA(const name : RawByteString; hook : pHook; const tags : pTagItem) : BOOLEAN;
  721. FUNCTION CloseWorkbenchObjectA(const name : RawByteString; const tags : pTagItem) : BOOLEAN;
  722. FUNCTION MakeWorkbenchObjectVisibleA(const name : RawByteString;const tags : pTagItem) : BOOLEAN;
  723. FUNCTION OpenWorkbenchObjectA(const name : RawByteString;const tags : pTagItem) : BOOLEAN;
  724. FUNCTION WorkbenchControlA(const name : RawByteString;const tags : pTagItem) : BOOLEAN;
  725. IMPLEMENTATION
  726. function AddAppIcon(id : ULONG; userdata : ULONG; text_ : PAnsiChar; msgport : pMsgPort; lock: BPTR; diskobj : pDiskObject; const taglist : array of PtrUInt) : pAppIcon;
  727. begin
  728. AddAppIcon := AddAppIconA(id, userdata, text_, msgport, lock, diskobj, @taglist);
  729. end;
  730. function AddAppMenuItem(id : ULONG; userdata : ULONG; text_ : PAnsiChar; msgport : pMsgPort; Const argv : array of PtrUInt) : pAppMenuItem;
  731. begin
  732. AddAppMenuItem := AddAppMenuItemA(id,userdata,text_,msgport,@argv);
  733. end;
  734. function AddAppWindow(id : ULONG; userdata : ULONG; window : pWindow; msgport : pMsgPort; Const argv : array of PtrUInt) : pAppWindow;
  735. begin
  736. AddAppWindow := AddAppWindowA(id,userdata,window,msgport,@argv);
  737. end;
  738. FUNCTION AddAppIconA(id : ULONG; userdata : ULONG; const text_ : RawByteString; msgport : pMsgPort; lock : BPTR; diskobj : pDiskObject;const taglist : pTagItem) : pAppIcon;
  739. begin
  740. AddAppIconA := AddAppIconA(id,userdata,PAnsiChar(text_),msgport,lock,diskobj,taglist);
  741. end;
  742. FUNCTION AddAppMenuItemA(id : ULONG; userdata : ULONG; const text_ : RawByteString; msgport : pMsgPort;const taglist : pTagItem) : pAppMenuItem;
  743. begin
  744. AddAppMenuItemA := AddAppMenuItemA(id,userdata,PAnsiChar(text_),msgport,taglist);
  745. end;
  746. PROCEDURE WBInfo(lock : BPTR; const name : RawByteString; screen : pScreen);
  747. begin
  748. WBInfo(lock,PAnsiChar(name),screen);
  749. end;
  750. FUNCTION ChangeWorkbenchSelectionA(const name : RawByteString; hook : pHook;const tags : pTagItem) : BOOLEAN;
  751. begin
  752. ChangeWorkbenchSelectionA := ChangeWorkbenchSelectionA(PAnsiChar(name),hook,tags);
  753. end;
  754. FUNCTION CloseWorkbenchObjectA(const name : RawByteString;const tags : pTagItem) : BOOLEAN;
  755. begin
  756. CloseWorkbenchObjectA := CloseWorkbenchObjectA(PAnsiChar(name),tags);
  757. end;
  758. FUNCTION MakeWorkbenchObjectVisibleA(const name : RawByteString;const tags : pTagItem) : BOOLEAN;
  759. begin
  760. MakeWorkbenchObjectVisibleA := MakeWorkbenchObjectVisibleA(PAnsiChar(name),tags);
  761. end;
  762. FUNCTION OpenWorkbenchObjectA(const name : RawByteString;const tags : pTagItem) : BOOLEAN;
  763. begin
  764. OpenWorkbenchObjectA := OpenWorkbenchObjectA(PAnsiChar(name),tags);
  765. end;
  766. FUNCTION WorkbenchControlA(const name : RawByteString;const tags : pTagItem) : BOOLEAN;
  767. begin
  768. WorkbenchControlA := WorkbenchControlA(PAnsiChar(name),tags);
  769. end;
  770. const
  771. { Change VERSION and LIBVERSION to proper values }
  772. VERSION : String[2] = '0';
  773. LIBVERSION : longword = 0;
  774. initialization
  775. WorkbenchBase := OpenLibrary(WORKBENCHNAME,LIBVERSION);
  776. finalization
  777. if Assigned(WorkbenchBase) then
  778. CloseLibrary(WorkbenchBase);
  779. END. (* UNIT WB *)