workbench.pas 41 KB

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