workbench.pas 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2014 by Free Pascal development team
  4. workbnech.library functions
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {$IFNDEF FPC_DOTTEDUNITS}
  12. unit Workbench;
  13. {$ENDIF FPC_DOTTEDUNITS}
  14. {$PACKRECORDS 2}
  15. Interface
  16. {$IFDEF FPC_DOTTEDUNITS}
  17. Uses
  18. Amiga.Core.Exec, Amiga.Core.Amigados, Amiga.Core.Utility, Amiga.Core.Intuition, Amiga.Core.Agraphics;
  19. {$ELSE FPC_DOTTEDUNITS}
  20. Uses
  21. exec, AmigaDos, Utility, Intuition, AGraphics;
  22. {$ENDIF FPC_DOTTEDUNITS}
  23. // ###### workbench/startup.h ###############################################
  24. type
  25. PWBArg = ^TWBArg;
  26. TWBArg = record
  27. wa_Lock: BPTR; // A lock descriptor.
  28. wa_Name: PAnsiChar; // A string relative to that lock.
  29. end;
  30. // ###### <freepascal> ######################################################
  31. PWBArgList = ^TWBArgList;
  32. TWBArgList = array[1..100] of TWBArg; // Only 1..smNumArgs are valid
  33. // ###### </freepascal> #####################################################
  34. PWBStartup = ^TWBStartup;
  35. TWBStartup = record
  36. sm_Message: TMessage; // A standard message structure.
  37. sm_Process: PMsgPort; // The process descriptor for you.
  38. sm_Segment: BPTR; // A descriptor for your code.
  39. sm_NumArgs: LongInt; // The number of elements in ArgList.
  40. sm_ToolWindow: PAnsiChar; // Description of window.
  41. sm_ArgList: PWBArgList; // The arguments themselves
  42. end;
  43. // ###### workbench/workbench.h #############################################
  44. const
  45. WORKBENCHNAME: PAnsiChar = 'workbench.library'; // Workbench library name.
  46. type
  47. POldDrawerData = ^TOldDrawerData;
  48. TOldDrawerData = record
  49. dd_NewWindow: TNewWindow; // Args to open window.
  50. dd_CurrentX: LongInt; // Current x coordinate of origin.
  51. dd_CurrentY: LongInt; // Current y coordinate of origin.
  52. end;
  53. const
  54. OLDDRAWERDATAFILESIZE = SizeOf(TOldDrawerData); // Amount of DrawerData actually written to disk.
  55. type
  56. PDrawerData = ^TDrawerData;
  57. TDrawerData = record
  58. dd_NewWindow: TNewWindow; // Args to open window.
  59. dd_CurrentX: LongInt; // Current x coordinate of origin.
  60. dd_CurrentY: LongInt; // Current y coordinate of origin.
  61. dd_Flags: LongWord; // Flags for drawer.
  62. dd_ViewModes: Word; // View mode for drawer.
  63. end;
  64. const
  65. DRAWERDATAFILESIZE = SizeOf(TDrawerData); // Amount of DrawerData actually written to disk.
  66. // Definitions for dd_ViewModes
  67. DDVM_BYDEFAULT = 0; // Default (inherit parent's view mode).
  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; // Fefault (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: PPAnsiChar;
  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. WBDISK = 1;
  94. WBDRAWER = 2;
  95. WBTOOL = 3;
  96. WBPROJECT = 4;
  97. WBGARBAGE = 5;
  98. WBDEVICE = 6;
  99. WBKICK = 7;
  100. WBAPPICON = 8;
  101. WB_DISKVERSION = 1; // Current version number.
  102. WB_DISKREVISION = 1; // Current revision number.
  103. WB_DISKREVISIONMASK = $FF; // Only use the lower 8 bits of Gadget.UserData for the revision #.
  104. WB_DISKMAGIC = $E310; // A magic number, not easily impersonated.
  105. type
  106. PFreeList = ^TFreeList;
  107. TFreeList = record
  108. fl_NumFree: SmallInt;
  109. fl_MemList: TList;
  110. end;
  111. const
  112. //
  113. // workbench does different complement modes for its gadgets.
  114. // It supports separate images, complement mode, and backfill mode.
  115. // The first two are identical to intuitions GADGIMAGE and GADGHCOMP.
  116. // backfill is similar to GADGHCOMP, but the region outside of the
  117. // image (which normally would be color three when complemented)
  118. // is flood-filled to color zero.
  119. //
  120. GFLG_GADGBACKFILL = $0001;
  121. // GADGBACKFILL = $0001; // an old synonym
  122. NO_ICON_POSITION = $80000000; // If an icon does not really live anywhere, set its current position to here.
  123. type
  124. PAppMessage = ^TAppMessage;
  125. TAppMessage = record
  126. am_Message: TMessage; // Standard message structure.
  127. am_type: Word; // Message type.
  128. am_UserData: LongWord; // Application specific.
  129. am_ID: LongWord; // Application definable ID.
  130. am_NumArgs: LongInt; // # of elements in arglist.
  131. am_ArgList: PWBArgList; // The arguements themselves.
  132. am_Version: Word; // Will be AM_VERSION.
  133. am_Class: Word; // Message class.
  134. am_MouseX: SmallInt; // Mouse x position of event.
  135. am_MouseY: SmallInt; // Mouse y position of event.
  136. am_Seconds: LongWord; // Current system clock time.
  137. am_Micros: LongWord; // Current system clock time.
  138. am_Reserved: array[0..7] of LongWord; // Avoid recompilation.
  139. end;
  140. const
  141. //
  142. // If you find am_Version >= AM_VERSION, you know this structure has
  143. // at least the fields defined in this version of the include file
  144. //
  145. AM_VERSION = 1; // Definition for am_Version.
  146. // Definitions for member am_type of structure TAppMessage.
  147. AMTYPE_APPWINDOW = 7; // App window message.
  148. AMTYPE_APPICON = 8; // App icon message.
  149. AMTYPE_APPMENUITEM = 9; // App menu item message.
  150. AMTYPE_APPWINDOWZONE = 10; // App window drop zone message.
  151. // Definitions for member am_Class of structure TAppMessage for AppIcon messages (V44)
  152. AMCLASSICON_Open = 0; // The "Open" menu item was invoked, the icon got double-clicked or an icon got dropped on it.
  153. AMCLASSICON_Copy = 1; // The "Copy" menu item was invoked.
  154. AMCLASSICON_Rename = 2; // The "Rename" menu item was invoked.
  155. AMCLASSICON_Information = 3; // The "Information" menu item was invoked.
  156. AMCLASSICON_Snapshot = 4; // The "Snapshot" menu item was invoked.
  157. AMCLASSICON_UnSnapshot = 5; // The "UnSnapshot" menu item was invoked.
  158. AMCLASSICON_LeaveOut = 6; // The "Leave Out" menu item was invoked.
  159. AMCLASSICON_PutAway = 7; // The "Put Away" menu item was invoked.
  160. AMCLASSICON_Delete = 8; // The "Delete" menu item was invoked.
  161. AMCLASSICON_FormatDisk = 9; // The "Format Disk" menu item was invoked.
  162. AMCLASSICON_EmptyTrash = 10; // The "Empty Trash" menu item was invoked.
  163. AMCLASSICON_Selected = 11; // The icon is now selected.
  164. AMCLASSICON_Unselected = 12; // The icon is now unselected.
  165. type
  166. // The message your AppIcon rendering hook gets invoked with.
  167. PAppIconRenderMsg = ^TAppIconRenderMsg;
  168. TAppIconRenderMsg = record
  169. arm_RastPort: PRastPort; // RastPort to render into.
  170. arm_Icon: PDiskObject; // The icon to be rendered.
  171. arm_Label: STRPTR; // The icon label txt.
  172. arm_Tags: PTagItem; // Further tags to be passed on to DrawIconStateA().
  173. arm_Left: SmallInt; // \ Rendering origin, not taking the
  174. arm_Top: SmallInt; // / button border into account.
  175. arm_Width: SmallInt; // \ Limit your rendering to
  176. arm_Height: SmallInt; // / this area.
  177. arm_State: LongWord; // IDS_SELECTED, IDS_NORMAL, etc.
  178. end;
  179. // The message your drop zone hook gets invoked with. }
  180. PAppWindowDropZoneMsg = ^TAppWindowDropZoneMsg;
  181. TAppWindowDropZoneMsg = record
  182. adzm_RastPort: PRastPort; // RastPort to render into.
  183. adzm_DropZoneBox: TIBox; // Limit your rendering to this area.
  184. adzm_ID: LongWord; // \ These come from straight
  185. adzm_UserData: LongWord; // / from AddAppWindowDropZoneA().
  186. adzm_Action: LongInt; // See below for a list of actions.
  187. end;
  188. const
  189. // definitions for adzm_Action
  190. ADZMACTION_Enter = 0;
  191. ADZMACTION_Leave = 1;
  192. type
  193. // The message your icon selection change hook is invoked with. }
  194. PIconSelectMsg = ^TIconSelectMsg;
  195. TIconSelectMsg = record
  196. ism_Length: LongWord; // Size of this data structure (in bytes).
  197. ism_Drawer: BPTR; // Lock on the drawer this object resides in, NULL for Workbench backdrop (devices).
  198. ism_Name: STRPTR; // Name of the object in question.
  199. ism_type: Word; // One of WBDISK, WBDRAWER, WBTOOL, WBPROJECT, WBGARBAGE, WBDEVICE, WBKICK or WBAPPICON.
  200. ism_Selected: LongBool; // TRUE if currently selected, FALSE otherwise.
  201. ism_Tags: PTagItem; // Pointer to the list of tag items passed to ChangeWorkbenchSelectionA().
  202. ism_DrawerWindow: PWindow; // Pointer to the window attached to this icon, if the icon is a drawer-like object.
  203. ism_ParentWindow: PWindow; // Pointer to the window the icon resides in.
  204. 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.
  205. ism_Top: SmallInt;
  206. ism_Width: SmallInt;
  207. ism_Height: SmallInt;
  208. end;
  209. const
  210. // These are the values your hook code can return.
  211. ISMACTION_Unselect = 0; // Unselect the icon.
  212. ISMACTION_Select = 1; // Select the icon.
  213. ISMACTION_Ignore = 2; // Do not change the selection state.
  214. ISMACTION_Stop = 3; // Do not invoke the hook code again, leave the icon as it is.
  215. type
  216. // The messages your copy hook is invoked with.
  217. PCopyBeginMsg = ^TCopyBeginMsg;
  218. TCopyBeginMsg = record
  219. cbm_Length: LongWord; // Size of this data structure in bytes.
  220. cbm_Action: LongInt; // Will be set to CPACTION_Begin (see below).
  221. cbm_SourceDrawer: BPTR; // A lock on the source drawer.
  222. cbm_DestinationDrawer: BPTR; // A lock on the destination drawer.
  223. end;
  224. PCopyDataMsg = ^TCopyDataMsg;
  225. TCopyDataMsg = record
  226. cdm_Length: LongWord; // Size of this data structure in bytes.
  227. cdm_Action: LongInt; // Will be set to CPACTION_Copy (see below).
  228. cdm_SourceLock: BPTR; // A lock on the parent directory of the source file/drawer.
  229. cdm_SourceName: STRPTR; // The name of the source file or drawer.
  230. cdm_DestinationLock: BPTR; // A lock on the parent directory of the destination file/drawer.
  231. cdm_DestinationName: STRPTR; // The name of the destination file/drawer.
  232. // This may or may not match the name of the source file/drawer in case the
  233. // data is to be copied under a different name. For example, this is the case
  234. // with the Workbench "Copy" command which creates duplicates of file/drawers by
  235. // prefixing the duplicate's name with "Copy_XXX_of".
  236. cdm_DestinationX: LongInt; // When the icon corresponding to the destination is written to disk, this
  237. cdm_DestinationY: LongInt; // is the position (put into its DiskObject->do_CurrentX/DiskObject->do_CurrentY.
  238. end; // fields) it should be placed at.
  239. PCopyEndMsg = ^TCopyEndMsg;
  240. TCopyEndMsg = record
  241. cem_Length: LongWord; // Size of this data structure in bytes.
  242. cem_Action: LongInt; // Will be set to CPACTION_End (see below).
  243. end;
  244. const
  245. CPACTION_Begin = 0;
  246. CPACTION_Copy = 1; // This message arrives for each file or drawer to be copied.
  247. CPACTION_End = 2; // This message arrives when all files/drawers have been copied.
  248. type
  249. // The messages your delete hook is invoked with.
  250. PDeleteBeginMsg = ^TDeleteBeginMsg;
  251. TDeleteBeginMsg = record
  252. dbm_Length: LongWord; // Size of this data structure in bytes.
  253. dbm_Action: LongInt; // Will be set to either DLACTION_BeginDiscard or DLACTION_BeginEmptyTrash (see below).
  254. end;
  255. PDeleteDataMsg = ^TDeleteDataMsg;
  256. TDeleteDataMsg = record
  257. ddm_Length: LongWord; // Size of this data structure in bytes.
  258. ddm_Action: LongInt; // Will be set to either DLACTION_DeleteContents or DLACTION_DeleteObject (see below).
  259. ddm_Lock: BPTR; // A Lock on the parent directory of the object whose contents or which itself should be deleted.
  260. ddm_Name: STRPTR; // The name of the object whose contents or which itself should be deleted.
  261. end;
  262. PDeleteEndMsg = ^TDeleteEndMsg;
  263. TDeleteEndMsg = record
  264. dem_Length: LongWord; // Size of this data structure in bytes.
  265. dem_Action: LongInt; // Will be set to DLACTION_End (see below).
  266. end;
  267. const
  268. DLACTION_BeginDiscard = 0;
  269. DLACTION_BeginEmptyTrash = 1; // This indicates that the following delete operations are intended to empty the trashcan.
  270. 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!
  271. 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.
  272. DLACTION_End = 5; // This indicates that the deletion process is finished.
  273. type
  274. // The message your setup/cleanup hook gets invoked with.
  275. PSetupCleanupHookMsg = ^TSetupCleanupHookMsg;
  276. TSetupCleanupHookMsg = record
  277. schm_Length: LongWord;
  278. schm_State: LongInt;
  279. end;
  280. const
  281. SCHMSTATE_TryCleanup = 0; // Workbench will attempt to shut down now.
  282. SCHMSTATE_Cleanup = 1; // Workbench will really shut down now.
  283. SCHMSTATE_Setup = 2; // Workbench is operational again or could not be shut down.
  284. type
  285. // The messages your text input hook is invoked with.
  286. PTextInputMsg = ^TTextInputMsg;
  287. TTextInputMsg = record
  288. tim_Length: LongWord; // Size of this data structure in bytes.
  289. tim_Action: LongInt; // One of the TIACTION_... values listed below.
  290. tim_Prompt: STRPTR; // The Workbench suggested result, depending on what kind of input is requested (as indicated by the tim_Action member).
  291. end;
  292. const
  293. TIACTION_Rename = 0; // A file or drawer is to be renamed.
  294. TIACTION_RelabelVolume = 1; // A volume is to be relabeled.
  295. TIACTION_NewDrawer = 2; // A new drawer is to be created.
  296. TIACTION_Execute = 3; // A program or script is to be executed.
  297. type
  298. //
  299. // The following structures are private. These are just stub
  300. // structures for code compatibility...
  301. //
  302. PAppWindow = ^TAppWindow;
  303. TAppWindow = record
  304. aw_PRIVATE: pointer;
  305. end;
  306. PAppMenu = ^TAppMenu;
  307. TAppMenu = record
  308. am_PRIVATE: pointer;
  309. end;
  310. PAppWindowDropZone = ^TAppWindowDropZone;
  311. TAppWindowDropZone = record
  312. awdz_PRIVATE: pointer;
  313. end;
  314. PAppIcon = ^TAppIcon;
  315. TAppIcon = record
  316. ai_PRIVATE: Pointer;
  317. end;
  318. PAppMenuItem = ^TAppMenuItem;
  319. TAppMenuItem = record
  320. ami_PRIVATE: Pointer;
  321. end;
  322. const
  323. WBA_Dummy = TAG_USER + $A000;
  324. // Tags for use with AddAppIconA()
  325. // The different menu items the AppIcon responds to (BOOL).
  326. WBAPPICONA_SupportsOpen = WBA_Dummy + 1; // AppIcon responds to the "Open" menu item (LongBool).
  327. WBAPPICONA_SupportsCopy = WBA_Dummy + 2; // AppIcon responds to the "Copy" menu item (LongBool).
  328. WBAPPICONA_SupportsRename = WBA_Dummy + 3; // AppIcon responds to the "Rename" menu item (LongBool).
  329. WBAPPICONA_SupportsInformation = WBA_Dummy + 4; // AppIcon responds to the "Information" menu item (LongBool).
  330. WBAPPICONA_SupportsSnapshot = WBA_Dummy + 5; // AppIcon responds to the "Snapshot" menu item (LongBool).
  331. WBAPPICONA_SupportsUnSnapshot = WBA_Dummy + 6; // AppIcon responds to the "UnSnapshot" menu item (LongBool).
  332. WBAPPICONA_SupportsLeaveOut = WBA_Dummy + 7; // AppIcon responds to the "LeaveOut" menu item (LongBool).
  333. WBAPPICONA_SupportsPutAway = WBA_Dummy + 8; // AppIcon responds to the "PutAway" menu item (LongBool).
  334. WBAPPICONA_SupportsDelete = WBA_Dummy + 9; // AppIcon responds to the "Delete" menu item (LongBool).
  335. WBAPPICONA_SupportsFormatDisk = WBA_Dummy + 10; // AppIcon responds to the "FormatDisk" menu item (LongBool).
  336. WBAPPICONA_SupportsEmptyTrash = WBA_Dummy + 11; // AppIcon responds to the "EmptyTrash" menu item (LongBool).
  337. WBAPPICONA_PropagatePosition = WBA_Dummy + 12; // AppIcon position should be propagated back to original DiskObject (LongBool).
  338. WBAPPICONA_RenderHook = WBA_Dummy + 13; // Callback hook to be invoked when rendering this icon (pHook).
  339. WBAPPICONA_NotifySelectState = WBA_Dummy + 14; // AppIcon wants to be notified when its select state changes (LongBool).
  340. // Tags for use with AddAppMenuA()
  341. WBAPPMENUA_CommandKeyString = WBA_Dummy + 15; // Command key string for this AppMenu (STRPTR).
  342. 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
  343. 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).
  344. 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 ???).
  345. // Tags for use with OpenWorkbenchObjectA()
  346. WBOPENA_ArgLock = WBA_Dummy + 16; // Corresponds to the wa_Lock member of a struct WBArg.
  347. WBOPENA_ArgName = WBA_Dummy + 17; // Corresponds to the wa_Name member of a struct WBArg.
  348. 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)
  349. 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)
  350. // Tags for use with WorkbenchControlA()
  351. WBCTRLA_IsOpen = WBA_Dummy + 18; // Check if the named drawer is currently open (PLongInt).
  352. WBCTRLA_DuplicateSearchPath = WBA_Dummy + 19; // Create a duplicate of the Workbench private search path list (PBPTR).
  353. WBCTRLA_FreeSearchPath = WBA_Dummy + 20; // Free the duplicated search path list (BPTR).
  354. WBCTRLA_GetDefaultStackSize = WBA_Dummy + 21; // Get the default stack size for launching programs with (PLongWord).
  355. WBCTRLA_SetDefaultStackSize = WBA_Dummy + 22; // Set the default stack size for launching programs with (LongWord).
  356. WBCTRLA_RedrawAppIcon = WBA_Dummy + 23; // Cause an AppIcon to be redrawn (pAppIcon).
  357. WBCTRLA_GetProgramList = WBA_Dummy + 24; // Get a list of currently running Workbench programs (pList).
  358. WBCTRLA_FreeProgramList = WBA_Dummy + 25; // Release the list of currently running Workbench programs (pList).
  359. WBCTRLA_GetSelectedIconList = WBA_Dummy + 36; // Get a list of currently selected icons (pList).
  360. WBCTRLA_FreeSelectedIconList = WBA_Dummy + 37; // Release the list of currently selected icons (pList).
  361. WBCTRLA_GetOpenDrawerList = WBA_Dummy + 38; // Get a list of currently open drawers (pList).
  362. WBCTRLA_FreeOpenDrawerList = WBA_Dummy + 39; // Release the list of currently open icons (pList).
  363. WBCTRLA_GetHiddenDeviceList = WBA_Dummy + 42; // Get the list of hidden devices (pList).
  364. WBCTRLA_FreeHiddenDeviceList = WBA_Dummy + 43; // Release the list of hidden devices (pList).
  365. WBCTRLA_AddHiddenDeviceName = WBA_Dummy + 44; // Add the name of a device which Workbench should never try to read a disk icon from (STRPTR).
  366. WBCTRLA_RemoveHiddenDeviceName = WBA_Dummy + 45; // Remove a name from list of hidden devices (STRPTR).
  367. 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).
  368. 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).
  369. WBCTRLA_GetCopyHook = WBA_Dummy + 69; // Obtain the hook that will be invoked when Workbench starts to copy files and data (pHook); (V45)
  370. WBCTRLA_SetCopyHook = WBA_Dummy + 70; // Install the hook that will be invoked when Workbench starts to copy files and data (pHook); (V45)
  371. WBCTRLA_GetDeleteHook = WBA_Dummy + 71; // Obtain the hook that will be invoked when Workbench discards files and drawers or empties the trashcan (pHook); (V45).
  372. WBCTRLA_SetDeleteHook = WBA_Dummy + 72; // Install the hook that will be invoked when Workbench discards files and drawers or empties the trashcan (pHook); (V45).
  373. 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)
  374. 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)
  375. 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)
  376. WBCTRLA_RemSetupCleanupHook = WBA_Dummy + 79; // Remove a hook that has been installed with the WBCTRLA_AddSetupCleanupHook tag (pHook); (V45)
  377. // Tags for use with AddAppWindowDropZoneA()
  378. WBDZA_Left = WBA_Dummy + 26; // Zone left edge (SmallInt)
  379. WBDZA_RelRight = WBA_Dummy + 27; // Zone left edge, if relative to the right edge of the window (SmallInt)
  380. WBDZA_Top = WBA_Dummy + 28; // Zone top edge (SmallInt)
  381. WBDZA_RelBottom = WBA_Dummy + 29; // Zone top edge, if relative to the bottom edge of the window (SmallInt)
  382. WBDZA_Width = WBA_Dummy + 30; // Zone width (SmallInt)
  383. WBDZA_RelWidth = WBA_Dummy + 31; // Zone width, if relative to the window width (SmallInt)
  384. WBDZA_Height = WBA_Dummy + 32; // Zone height (SmallInt)
  385. WBDZA_RelHeight = WBA_Dummy + 33; // Zone height, if relative to the window height (SmallInt)
  386. WBDZA_Box = WBA_Dummy + 34; // Zone position and size (pIBox).
  387. WBDZA_Hook = WBA_Dummy + 35; // Hook to invoke when the mouse enters or leave a drop zone (pHook).
  388. // Reserved tags; don't use! }
  389. WBA_Reserved1 = WBA_Dummy + 40;
  390. WBA_Reserved2 = WBA_Dummy + 41;
  391. WBA_Reserved3 = WBA_Dummy + 46;
  392. WBA_Reserved4 = WBA_Dummy + 49;
  393. WBA_Reserved5 = WBA_Dummy + 50;
  394. WBA_Reserved6 = WBA_Dummy + 51;
  395. WBA_Reserved7 = WBA_Dummy + 52;
  396. WBA_Reserved8 = WBA_Dummy + 53;
  397. WBA_Reserved9 = WBA_Dummy + 54;
  398. WBA_Reserved10 = WBA_Dummy + 55;
  399. WBA_Reserved11 = WBA_Dummy + 56;
  400. WBA_Reserved12 = WBA_Dummy + 57;
  401. WBA_Reserved13 = WBA_Dummy + 58;
  402. WBA_Reserved14 = WBA_Dummy + 59;
  403. WBA_Reserved15 = WBA_Dummy + 60;
  404. WBA_Reserved16 = WBA_Dummy + 61;
  405. WBA_Reserved17 = WBA_Dummy + 62;
  406. WBA_Reserved18 = WBA_Dummy + 63;
  407. WBA_Reserved19 = WBA_Dummy + 64;
  408. // Last Tag
  409. WBA_LAST_TAG = WBA_Dummy + 64;
  410. // Parameters for the UpdateWorkbench() function.
  411. UPDATEWB_ObjectRemoved = 0; // Object has been deleted.
  412. UPDATEWB_ObjectAdded = 1; // Object is new or has changed.
  413. const
  414. // each message that comes into the WorkBenchPort must have a type field in the preceeding short. These are the defines for this type
  415. MTYPE_PSTD = 1; { a "standard Potion" message }
  416. MTYPE_TOOLEXIT = 2; { exit message from our tools }
  417. MTYPE_DISKCHANGE = 3; { dos telling us of a disk change }
  418. MTYPE_TIMER = 4; { we got a timer tick }
  419. MTYPE_CLOSEDOWN = 5; { <unimplemented> }
  420. MTYPE_IOPROC = 6; { <unimplemented> }
  421. MTYPE_APPWINDOW = 7; { msg from an app window }
  422. MTYPE_APPICON = 8; { msg from an app icon }
  423. MTYPE_APPMENUITEM = 9; { msg from an app menuitem }
  424. MTYPE_COPYEXIT = 10; { exit msg from copy process }
  425. MTYPE_ICONPUT = 11; { msg from PutDiskObject in icon.library }
  426. // ###### workbench/handler.h ###############################################
  427. type
  428. TWBHM_type =
  429. (
  430. WBHM_TYPE_SHOW, // Open all windows.
  431. WBHM_TYPE_HIDE, // Close all windows.
  432. WBHM_TYPE_OPEN, // Open a drawer.
  433. WBHM_TYPE_UPDATE // Update an object.
  434. );
  435. PWBHandlerMessage = ^TWBHandlerMessage;
  436. TWBHandlerMessage = record
  437. wbhm_Message: TMessage; // Standard message structure.
  438. wbhm_type: TWBHM_type; // type of message.
  439. case integer of
  440. 0 :
  441. (
  442. Open: record
  443. OpenName: STRPTR; // Name of the drawer.
  444. end;
  445. );
  446. 1 :
  447. (
  448. Update: record
  449. UpdateName: STRPTR; // Mame of the object.
  450. Updatetype: LongInt; // type of object (WBDRAWER, WBPROJECT, ...).
  451. end;
  452. );
  453. end;
  454. var
  455. WorkbenchBase: PLibrary;
  456. IWorkbench: PInterface;
  457. function WBObtain(): LongWord; syscall IWorkbench 60;
  458. function WBRelease(): LongWord; syscall IWorkbench 64;
  459. procedure WBExpunge(); syscall IWorkbench 68;
  460. function WBClone(): PInterface; syscall IWorkbench 72;
  461. procedure UpdateWorkbench(const Name: STRPTR; Lock: BPTR; Action: LongInt); syscall IWorkbench 76;
  462. // 80 private
  463. // 84 private
  464. function AddAppWindowA(ID: LongWord; UserData: LongWord; Window: PWindow; MsgPort: PMsgPort; TagList: PTagItem): PAppWindow; syscall IWorkbench 88;
  465. // 92 AddAppWindow
  466. function RemoveAppWindow(AppWindow: PAppWindow): LongBool; syscall IWorkbench 96;
  467. function AddAppIconA(ID: LongWord; UserData: LongWord; Text_: PAnsiChar; MsgPort: PMsgPort; Lock: BPTR; DiskObj: PDiskObject; TagList: PTagItem): PAppIcon; syscall IWorkbench 100;
  468. // 104 AddAppIcon
  469. function RemoveAppIcon(AppIcon: PAppIcon): LongBool; syscall IWorkbench 108;
  470. function AddAppMenuItemA(ID: LongWord; UserData: LongWord; Text_: APTR; MsgPort: PMsgPort; TagList: PTagItem): PAppMenuItem; syscall IWorkbench 112;
  471. // 116
  472. function RemoveAppMenuItem(AppMenuItem: PAppMenuItem): LongBool; syscall IWorkbench 120;
  473. // 124 private
  474. function WBInfo(Lock: BPTR; const Name: STRPTR; Screen: PScreen): LongBool; syscall IWorkbench 128;
  475. function OpenWorkbenchObjectA(Name: STRPTR; Tags: PTagItem): LongBool; syscall IWorkbench 132;
  476. // 136 OpenWorkbenchObject
  477. function CloseWorkbenchObjectA(Name: STRPTR; Tags: PTagItem): LongBool; syscall IWorkbench 140;
  478. // 144 CloseWorkbenchObject
  479. function WorkbenchControlA(Name: STRPTR; Tags: PTagItem): LongBool; syscall IWorkbench 148;
  480. // 152 WorkbenchControl
  481. function AddAppWindowDropZoneA(Aw: PAppWindow; ID: LongWord; UserData: LongWord; Tags: PTagItem): PAppWindowDropZone; syscall IWorkbench 156;
  482. // 160 AddAppWindowDropZone
  483. function RemoveAppWindowDropZone(Aw: PAppWindow; DropZone: PAppWindowDropZone): LongBool; syscall IWorkbench 164;
  484. function ChangeWorkbenchSelectionA(Name: STRPTR; Hook: PHook; Tags: PTagItem): LongBool; syscall IWorkbench 168;
  485. // 172 ChangeWorkbenchSelection
  486. function MakeWorkbenchObjectVisibleA(Name: STRPTR; Tags: PTagItem): LongBool; syscall IWorkbench 176;
  487. // 180 MakeWorkbenchObjectVisible
  488. function WhichWorkbenchObjectA(Window: PWindow; X, Y: LongInt; Tags: PTagItem): LongBool; syscall IWorkbench 184;
  489. // 188 WhichWorkbenchObject
  490. // 192 private
  491. // varargs versions:
  492. function AddAppIcon(ID: LongWord; UserData: LongWord; Text_: PAnsiChar; MsgPort: PMsgPort; Lock: BPTR; DiskObj: PDiskObject; const Tags: array of PtrUInt): PAppIcon;
  493. function AddAppMenuItem(ID: LongWord; UserData: LongWord; Text_: APTR; MsgPort: PMsgPort; const Tags: array of PtrUInt): PAppMenuItem;
  494. function AddAppWindow(ID: LongWord; UserData: LongWord; Window: PWindow; MsgPort: PMsgPort; const Tags: array of PtrUInt): PAppWindow;
  495. function AddAppWindowDropZone(Aw: PAppWindow; ID: LongWord; UserData: LongWord; const Tags: array of PtrUInt): PAppWindowDropZone;
  496. function CloseWorkbenchObject(Name: STRPTR; const Tags: array of PtrUInt): LongBool; unimplemented;
  497. function MakeWorkbenchObjectVisible(Name: STRPTR; const Tags: array of PtrUInt): LongBool; unimplemented;
  498. function OpenWorkbenchObject(Name: STRPTR; const Tags: array of PtrUInt): LongBool;
  499. function WorkbenchControl(Name: STRPTR; const Tags: array of PtrUInt): LongBool;
  500. implementation
  501. // varargs versions:
  502. function AddAppIcon(ID: LongWord; UserData: LongWord; Text_: PAnsiChar; MsgPort: PMsgPort; Lock: BPTR; DiskObj: PDiskObject; const Tags: array of PtrUInt): PAppIcon; inline;
  503. begin
  504. AddAppIcon := AddAppIconA(ID, UserData, Text_, MsgPort, Lock, DiskObj, @Tags);
  505. end;
  506. function AddAppMenuItem(ID: LongWord; UserData: LongWord; Text_: APTR; MsgPort: PMsgPort; const Tags: array of PtrUInt): PAppMenuItem; inline;
  507. begin
  508. AddAppMenuItem := AddAppMenuItemA(ID, UserData, Text_, MsgPort, @Tags);
  509. end;
  510. function AddAppWindow(ID: LongWord; UserData: LongWord; Window: PWindow; MsgPort: PMsgPort; const Tags: array of PtrUInt): PAppWindow; inline;
  511. begin
  512. AddAppWindow := AddAppWindowA(ID, UserData, Window, MsgPort, @Tags);
  513. end;
  514. function AddAppWindowDropZone(Aw: PAppWindow; ID: LongWord; UserData: LongWord; const Tags: array of PtrUInt): PAppWindowDropZone; inline;
  515. begin
  516. AddAppWindowDropZone := AddAppWindowDropZoneA(Aw, ID, UserData, @Tags);
  517. end;
  518. function CloseWorkbenchObject(Name: STRPTR; const Tags: array of PtrUInt): LongBool; inline;
  519. begin
  520. CloseWorkbenchObject := CloseWorkbenchObjectA(Name, @Tags);
  521. end;
  522. function MakeWorkbenchObjectVisible(Name: STRPTR; const Tags: array of PtrUInt): LongBool; inline;
  523. begin
  524. MakeWorkbenchObjectVisible := MakeWorkbenchObjectVisibleA(Name, @Tags);
  525. end;
  526. function OpenWorkbenchObject(Name: STRPTR; const Tags: array of PtrUInt): LongBool; inline;
  527. begin
  528. OpenWorkbenchObject := OpenWorkbenchObjectA(Name, @Tags);
  529. end;
  530. function WorkbenchControl(Name: STRPTR; const Tags: array of PtrUInt): LongBool; inline;
  531. begin
  532. WorkbenchControl := WorkbenchControlA(Name, @Tags);
  533. end;
  534. Initialization
  535. WorkbenchBase := OpenLibrary(WORKBENCHNAME,0);
  536. if Assigned(WorkbenchBase) then
  537. IWorkbench := GetInterface(WorkbenchBase, 'main', 1, nil);
  538. finalization
  539. if Assigned(IWorkbench) then
  540. DropInterface(IWorkbench);
  541. if Assigned(WorkbenchBase) then
  542. CloseLibrary(WorkbenchBase);
  543. end.