home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 2 / DATAFILE_PDCD2.iso / utilities / _macros / !Macros / Documents / WimpExt < prev   
Encoding:
Text File  |  1993-03-28  |  70.2 KB  |  1,958 lines

  1.                       ________________________________
  2.  
  3.                       WimpExtension 1.97 (28-Mar-1993)
  4.                       ________________________________
  5.  
  6.  
  7.                      (c) Jon Ribbens of DoggySoft, 1993
  8.  
  9.  
  10. Licence
  11. =======
  12.  
  13.  
  14. You can give copies of WimpExtension, with or without the accompanying
  15. documentation and example application, to anybody you like, as long as you
  16. don't make any money out of doing so. You can, however, include WimpExtension
  17. with other commercial products. ie: You can sell a program which uses
  18. WimpExtension, and include WimpExtension with it, but you can't sell
  19. WimpExtension on its own.
  20.  
  21. There is no warranty at all, express or implied or whatever. If anything goes
  22. wrong, don't blame me. I will, however, try to fix any problems you find.
  23.  
  24.  
  25. NB  If you find any bugs in WimpExtension, or you think I should include some
  26. --  extra feature, don't just sit there muttering to yourself, TELL me about
  27.     it.
  28.  
  29.  
  30.  
  31. Introduction
  32. ============
  33.  
  34. WimpExtension is designed to make the task of programming the Wimp easier. It
  35. also enables you to use 3D icons (like Impression). It is designed to enable
  36. you, when you are writing your programs, to think less 'It's a Desktop
  37. program' and more 'It's a program to do ...'. It has been written over a
  38. period of more than a year, reaching well over ten thousand lines of source
  39. code, hopefully carefully designed to be as easy to use as possible.
  40.  
  41. You use WimpExtension by a set of SWI (BASIC's SYS) commands. There are calls
  42. to put icons on the iconbar, to change the pointer shape, to pop icons in and
  43. out, link windows so they move about together (for toolboxes and
  44. windows-in-windows), there are facilities for options window handling, for
  45. dialogue boxes, for controlling indirected icons, for loading templates, for
  46. colour menus, for RAM templates, for dragging icons, for menu handling, for
  47. draw-files and sprites, for immediate windows, for memory management, etc.,
  48. etc.
  49.  
  50. This manual explains all the features of WimpExtension, and how to use them.
  51. For a quick overview of the SWI calls read the file 'SWIs'.
  52.  
  53. There is an accompanying example application, ExtDemo, which should be
  54. included with the WimpExtension module. This shows off some of the features
  55. of WimpExtension. It is written in BASIC so that you can see how it works.
  56.  
  57.  
  58.  
  59. General points
  60. ==============
  61.  
  62. * WimpExtension needs to know which task is calling it. It is told when you
  63.   call WimpExt_Initialise or WimpExt_Action, but calls to Wimp_Poll may
  64.   change it (as other tasks call it). If you have not called
  65.   WimpExt_Initialise or WimpExt_Action since the last Wimp_Poll therefore,
  66.   you should call WimpExt_CurrentTask to tell WimpExtension your task handle.
  67. * In general, all strings are control-terminated, ie. they may not contain
  68.   any characters less than 32, which are treated as terminators.
  69. * Some features of WimpExtension are controlled by the validation strings of
  70.   icons. To have a validation string, the icon must be indirected text (plus
  71.   sprite if you want). (If you don't want text, make it text, just don't put
  72.   any text in it.) Validation commands are separated by semicolons; you can
  73.   put as many as you want on a single icon. You shouldn't use the same
  74.   command twice, unless you are specifically told you can. (The behaviour is
  75.   undefined if you do - ie. different versions of WimpExtension may do
  76.   different things.)
  77. * Since it claims workspace for tasks it knows about, WimpExtension MUST know
  78.   when a task closes down. You should therefore, always call
  79.   WimpExt_CloseDown before your task exits. To catch any unavoidable slips
  80.   (eg. Address Exceptions in BASIC) WimpExtension initialises a module task
  81.   which will call WimpExt_CloseDown for any tasks that exit. You must not
  82.   rely on this, though.
  83. * All SWIs corrupt R0, even if they are not using it to return a result.
  84. * Because WimpExtension provides more than 64 SWIs, another module called
  85.   'WimpExtShadow' appears in the module list. This is perfectly normal and
  86.   should be ignored.
  87.  
  88.  
  89.  
  90. Essential SWIs
  91. ==============
  92.  
  93. These are SWIs you MUST call if you are going to use ANY of the features of
  94. WimpExtension.
  95.  
  96.  
  97. WimpExt_Initialise       &45780
  98. -------------------------------
  99. R0 = 14
  100. R1 = task handle
  101. R2 = features flags
  102.        bit     meaning
  103.        0       semi-automatic slabbing if set, automatic otherwise
  104.        1       automatically recreate menus if set
  105.        2       task wants to use font menus if set
  106.        3       automatically compact heap once a second if set
  107.        4       'correct' radio icons if set
  108.        5       semi-automatic help if set, automatic otherwise
  109.        6       use alternative parameters for flag-setting SWIs if set
  110.        7       use R0 of WimpExt_SetIconString[N]
  111.        8       automatically call WimpExt_MoveCaret
  112.        9       Unset other icons in ESG when setting icons
  113.        10-31   reserved; MUST BE 0
  114. Exit:
  115. R0 = WimpExt version number * 100
  116.  
  117. Must be called prior to using any other WimpExt calls. R0 must be 11 on
  118. entry. This is so that WimpExtension can work out what version the program
  119. thinks it is calling (so I can change the functionality of calls later whilst
  120. still retaining backwards-compatibility). R2 holds features flags, for
  121. specifying certain things at start-up. If bit 1 of R2 is set then if the user
  122. selects a menu option with the ADJUST button then the menu will automatically
  123. be recreated when you next call WimpExt_PrePoll (assuming you used
  124. 'WimpExt_CreateMenu' to create the menu, that is). If bit 2 of R2 is set then
  125. you are allowed to call WimpExt_GetFontMenu and WimpExt_DecodeFontMenu - you
  126. are NOT allowed to call them if you do not set bit 2. If bit 4 of R2 is set
  127. then the user won't be able to deselect all of a group of radio icons by
  128. clicking adjust on the selected icon.
  129.  
  130.  
  131. WimpExt_CloseDown        &45781
  132. -------------------------------
  133. R0 = task handle
  134.  
  135. Must be called prior to the task exiting.
  136.  
  137.  
  138. WimpExt_PrePoll          &457B4
  139. -------------------------------
  140.  
  141. To be called immediately before Wimp_Poll or Wimp_PollIdle.
  142.  
  143.  
  144. WimpExt_Action           &45784
  145. -------------------------------
  146. R0 = task handle
  147. R1 = Wimp_Poll block
  148. R2 = Wimp_Poll reason code
  149. Exit:
  150. R0 = Wimp_Poll reason code (possibly altered)
  151.  
  152. To be called immediately after Wimp_Poll. WimpExtension may alter the code
  153. returned - eg. if the user clicks in a requester window then the code will
  154. be translated before your program gets to see it.
  155.  
  156.  
  157. The general structure of your program, therefore, will be:
  158.  
  159.     SYS "Wimp_Initialise"...
  160.     SYS "WimpExt_Initialise"...
  161.     WHILE NOT quit%
  162.       SYS "WimpExt_PrePoll"
  163.       SYS "Wimp_Poll"...
  164.       SYS "WimpExt_Action"...
  165.     ENDWHILE
  166.     SYS "WimpExt_CloseDown"...
  167.     SYS "Wimp_CloseDown"...
  168.     END
  169.  
  170.  
  171.  
  172. 3D icons and window redraws
  173. ===========================
  174.  
  175. 3D borders are treated as user graphics, so the 'auto-redraw' flag in the
  176. window definition should not be set. 3D borders are controlled by the 'w'
  177. validation command:
  178.  
  179.   'w' (border type)
  180.     Syntax:
  181.       w<border number>,<slabbing mask>,<slabbing time>,<top left colour>,
  182.        <bottom right colour>,<popped in colour>,<popped out colour>,
  183.        <channel colour>
  184.  
  185. All the numbers apart from the border number are optional. The defaults are:
  186. wxx,4,15,4,0,1,14,12. You can specify only some, eg: w2,4,20 or w2,,,,3. The
  187. border numbers are:
  188.  
  189.      0  : Standard 3D border. Used for headings and buttons. Pops in if
  190.           clicked on.
  191.      1  : Ridged grouping border. Put it around things of a similar nature.
  192.      2  : Like 0, with a channel round it. Used for the default button (ie.
  193.           the one that is pressed if you press RETURN).
  194.      3  : Wide border for writeable icons - leave the normal black border on
  195.           the icon and make the background white.
  196.      4  : Popped in border - for things that are for information only.
  197.      5  : Trenched border - the opposite of border 1. Can be clicked on.
  198.           Suggested use is as an alternate border 1.
  199.      6  : Title border - similar to border 0, but with two 'dents'.
  200.           This border is designed to be used as the title of a group, with
  201.           a border 1 icon behind it as the frame - see ExtDemo for examples.
  202.  
  203. If you add 8 to the border number, it will become inert - ie. it will ignore
  204. all mouse clicks and not pop in. Bordered icons should be filled if you want
  205. them to change colour when clicked on (which is definitely recommended), and
  206. you should initially set the background colour of the icon to the out-colour.
  207.  
  208. Anti-aliased font icons are now supported. The icon MUST have an 'F'
  209. validation command, as the Wimp needs this to specify the icon's colour. Note
  210. that slabbing font icons doesn't look very good in 16-colour modes, due to
  211. anti-aliasing (this is not WimpExtension's fault, it's just a fact of life).
  212.  
  213. If you set the in-colour and out-colour the same then the icon won't ever be
  214. slabbed in or out. If you really really want an icon which doesn't change
  215. colour when slabbed in and out unset the 'Filled' flag. I don't recommend
  216. having icons which don't change colour, anyway - they look awful.
  217.  
  218.  
  219. WimpExt_SlabIcon         &45782
  220. -------------------------------
  221. R2 = window handle or 0 for slabbed icon
  222. R3 = icon handle
  223. If semi-automatic slabbing is enabled, then:
  224. R4 = 0 to pop out, any other to pop in
  225.  
  226. To be called to force an icon to be slabbed (for example to slab the default
  227. action icon if RETURN is pressed). If semi-automatic slabbing is enabled then
  228. the icon will be popped in or out depending on R4, otherwise it will be
  229. popped in and then out again. If R2 is zero then the last icon to be slabbed
  230. in (either implicity or explicity) is used. Note that in this case the SWI
  231. might return an error (eg. if the window has been deleted).
  232.  
  233.  
  234. WimpExt_Redraw           &45783
  235. -------------------------------
  236. R1 = Wimp_RedrawWindow block
  237.  
  238. To be called in the window redraw loop, to draw the 3D borders round icons.
  239.  
  240.  
  241. If you use 3D borders, you MUST call WimpExt_Redraw, or they won't appear.
  242. Your redraw loop would probably look something like:
  243.  
  244.     SYS "Wimp_RedrawWindow",,q% TO flag%
  245.     WHILE flag%
  246.       SYS "WimpExt_Redraw",,q%
  247.       ...
  248.       SYS "Wimp_GetRectangle",,q% TO flag%
  249.     ENDWHILE
  250.  
  251.  
  252. WimpExt_AutoRedraw       &45798
  253. -------------------------------
  254. R1 = Wimp_Poll reason code 1 block
  255.  
  256. This call can be used instead of the normal Wimp_RedrawWindow/GetRectangle
  257. loop if the window doesn't contain any graphics drawn by your program. It
  258. does the equivalent of:
  259.  
  260.     SYS "Wimp_RedrawWindow",,q% TO flag%
  261.     WHILE flag%
  262.       SYS "WimpExt_Redraw",,q%
  263.       SYS "Wimp_GetRectangle",,q% TO flag%
  264.     ENDWHILE
  265.  
  266.  
  267.  
  268. Iconbar sprites
  269. ===============
  270.  
  271. Two SWIs are provided for putting icons on the iconbar - one for sprites
  272. only, and one for text-plus-sprite icons. These read the size of the sprite
  273. to get the width of the icon.
  274.  
  275.  
  276. WimpExt_IconBarSprite    &45785
  277. -------------------------------
  278. R2 = -2 for left of iconbar, -1 for right
  279. R3 = pointer to sprite name
  280. R5 = icon button type (eg. 3)
  281. Exit:
  282. R0 = icon handle
  283.  
  284. Will place a sprite on the iconbar, returning the icon handle. Note that the
  285. sprite name is copied out of the memory block, which can be reused. Also note
  286. that the number in R5 is just the button type, not the flags.
  287.  
  288.  
  289. WimpExt_IconBarText      &45786
  290. -------------------------------
  291. R2 = -2 for left of iconbar, -1 for right
  292. R3 = pointer to sprite name
  293. R4 = pointer to text (max. 128 chars inc. terminator)
  294. R5 = icon button type (eg. 3)
  295. Exit:
  296. R0 = icon handle
  297.  
  298. Will place a sprite on the iconbar, with a text message underneath, returning
  299. the icon handle. Note that the sprite name is copied out of the memory block,
  300. which can be reused, but the text remains where it is; this is so you can
  301. change the text after creating the icon. Also note that the number in R5 is
  302. just the button type, not the flags.
  303.  
  304.  
  305.  
  306. Linked windows
  307. ==============
  308.  
  309. Linked windows are good for option setting and lists of things. They consist
  310. of a main window, which is normal, and a subwindow, which moves around with
  311. the main window. The subwindow normally has no titlebar and no horizontal
  312. scrollbar, just the vertical scrollbar, although this is a matter of style.
  313. To have more than one subwindow in a main window you should link the
  314. subwindows together. eg:
  315.   SYS "WimpExt_LinkWindows",,,mainw%,link1w%
  316.   SYS "WimpExt_LinkWindows",,,link1w%,link2w%
  317.   SYS "WimpExt_LinkWindows",,,link2w%,link3w%
  318.   ...
  319.  
  320. WimpExtension makes linked windows very easy - to set up a linked window,
  321. just use SWI WimpExt_LinkWindows, and use WimpExt_OpenLinked and
  322. WimpExt_CloseLinked instead of Wimp_OpenWindow and Wimp_CloseWindow.
  323.  
  324.  
  325. WimpExt_LinkWindows      &45787
  326. -------------------------------
  327. R2 = main window handle
  328. R3 = sub-window handle
  329.  
  330. Will link two windows so the sub-window moves with the main window. Currently
  331. there is a limit of 16 linked windows - this may be removed in a later
  332. version.
  333.  
  334.  
  335. WimpExt_OpenLinked       &45788
  336. -------------------------------
  337. R1 = Wimp_OpenWindow block
  338.  
  339. To be used instead of Wimp_OpenWindow. It does the same thing, but if the
  340. window is linked then it will handle the link. If the window is not linked,
  341. it has the same effect as Wimp_OpenWindow.
  342.  
  343.  
  344. WimpExt_CloseLinked      &45789
  345. -------------------------------
  346. R1 = Wimp_CloseWindow block
  347.  
  348. To be used instead of Wimp_CloseWindow. It does the same thing, but if the
  349. window is linked then it will close the linked window as well. If the window
  350. is not linked, it has the same effect as Wimp_CloseWindow.
  351.  
  352.  
  353. WimpExt_UnLinkWindows    &4578A
  354. -------------------------------
  355. R2 = main window handle
  356. R3 = sub-window handle
  357.  
  358. Will remove the link between the specified window and its subwindow. Note
  359. that this just removes the pointer in WimpExtension workspace, if the windows
  360. are on the screen they will remain there. You do not have to call
  361. UnLinkWindows before you exit - it is here so that you can unlink windows
  362. while your application is still running.
  363.  
  364.  
  365. WimpExt_HideLink         &457A8
  366. -------------------------------
  367. R0 = main window handle
  368. R2 = sub-window handle
  369.  
  370. Temporarily hides the link between the specified window and its sub-window.
  371. This is useful, for example, for removing toolboxes in such a way that they
  372. can be replaced later. Note that this call does no screen update - ie. the
  373. sub-window remains where it is.
  374.  
  375.  
  376. WimpExt_UnHideLink       &457A9
  377. -------------------------------
  378. R0 = main window handle
  379. R2 = sub-window handle
  380.  
  381. Unhides the previously hidden link. Note that this call does no screen
  382. update - ie. the sub-window remains where it is.
  383.  
  384.  
  385.  
  386. Templates
  387. =========
  388.  
  389. Using templates usually is quite tedious, as you have to open the template
  390. file and read in the definitions for each window individually, calling
  391. Wimp_CreateWindow for each one and storing the window handle. Using
  392. WimpExtension you just call WimpExt_LoadTemplates and all the windows in the
  393. named file will be loaded and created, and the handles stored in a buffer.
  394. The only time you cannot do this is if you have more than one window that you
  395. want to open multiple copies of. If you have no such windows, you're OK, if
  396. you want one such window then you simply make sure it's the last window in
  397. the templates file, and its definition will be in the buffer after the SWI
  398. call.
  399.  
  400. Note that by using this call your program is dependent on the order of the
  401. templates in the file. This shouldn't matter, as when you make the templates
  402. file you know what order you've got them in, and nobody else has any business
  403. changing your templates file.
  404.  
  405.  
  406. WimpExt_LoadTemplates    &4578C
  407. -------------------------------
  408. R0 = pointer to buffer for storing window handles
  409. R1 = pointer to user buffer for template (big enough for largest template)
  410. R2 = pointer to workspace for indirected icons
  411. R3 = pointer to end of workspace for indirected icons
  412. R4 = 256-byte font reference array (-1 for no fonts)
  413. R5 = pointer to filename of templates file
  414. R6 = pointer to sprite area control block (+1 for Wimp sprite pool)
  415.  
  416. Loads in all the templates from the file whose name is pointed to by R5, and
  417. called Wimp_CreateWindow for each one. The value in R6 is placed in the
  418. window block at offset +64. Stores the window handles sequentially in the
  419. buffer pointed to by R0, in the order they are found in the templates file.
  420. On exit the buffer pointed to by R1 will contain the template for the last
  421. window in the file. The buffer for window handles should be big enough to
  422. store all the window handles, each of which is a word. For each window, if
  423. the word on entry is zero the window will be created as usual. Bits that are
  424. set have the following meanings:
  425.  
  426.     Bit   Meaning if set
  427.     ----------------------------------------------
  428.     0     centre window horizontally
  429.     1     don't create window
  430.     2     centre window vertically
  431.  
  432. Bit 1 is useful if you have the last window in the file as one that you want
  433. repeatedly, but you don't want it created at once.
  434.  
  435.  
  436. Another SWI is provided for RAM templates. This is provided mainly for module
  437. tasks, where the templates must be part of the main code. You can use the
  438. supplied BASIC function 'FNtemplate' to include the template as part of your
  439. code, and then use WimpExt_LoadRAMTemplate to turn this into a window
  440. definition.
  441.  
  442.  
  443. WimpExt_LoadRAMTemplate  &457A5
  444. -------------------------------
  445. R1 = pointer to user buffer for window definition
  446. R2 = pointer to workspace for indirected icons
  447. R3 = pointer to end of workspace for indirected icons
  448. R4 = -1 for no fonts - fonts not supported at present
  449. R5 = pointer to template
  450. Exit:
  451. R2 = pointer to end of workspace used (ie. first free byte)
  452.  
  453. This call is similar to Wimp_LoadTemplate except that it uses templates in
  454. RAM. This is designed to be used in Module tasks, where you cannot have a
  455. separate Templates file. You would use the supplied 'FNtemplate' function to
  456. insert the template in your module, and then call WimpExt_LoadRAMTemplate to
  457. convert this to a window definition. At present fonts in templates are not
  458. supported - this shouldn't cause too much of a problem as I have never seen
  459. a program which uses this feature anyway.
  460.  
  461.  
  462.  
  463. Icon handling
  464. =============
  465.  
  466. Lots of SWIs are provided for handling icons, eg. setting the string in a
  467. text icon, shading icons, reading a number from an icon, etc...
  468.  
  469.  
  470. WimpExt_SetIconString    &4578D
  471. -------------------------------
  472. R0 = non-zero for ellipsis (only if enabled in WimpExt_Initialise)
  473. R2 = window handle
  474. R3 = icon handle
  475. R4 = pointer to string
  476.  
  477. Copies the string pointed to by R2 into the specified indirected text icon,
  478. and updates the screen if necessary. If the caret was in the icon then it is
  479. moved to the end of the new string. Only updates the screen if anything was
  480. changed - ie. if the new string is the same as the old string then nothing
  481. will happen. If R0 is non-zero and bit 7 was set in R2 in WimpExt_Initialise
  482. and the string is longer than the icon can hold then the string will be
  483. post-fixed with '...'.
  484.  
  485.  
  486. WimpExt_SetIcon          &4578F
  487. -------------------------------
  488. R2 = window handle
  489. R3 = icon handle
  490. R4 = 0 to deselect icon, non-zero to select icon
  491. If bit 6 of R2 was set in WimpExt_Initialise:
  492. R4 = 0 to deselect icon, 1 to select icon, 2 to toggle icon
  493. Exit:
  494. R0 = old state of icon (0 for unset, 1 for set)
  495.  
  496. Selects the icon if R4 is non-zero, deselects it otherwise. Updates the
  497. screen if necessary. If bit 6 of R2 was set in WimpExt_Initialise then the
  498. alternative parameters are used as shown. If bit 9 of R2 was set in
  499. WimpExt_Initialise and you are setting the icon, then other icons in the same
  500. ESG will be unset.
  501.  
  502.  
  503. WimpExt_GetIcon          &45790
  504. -------------------------------
  505. R2 = window handle
  506. R3 = icon handle
  507. Exit:
  508. R0 = 0 if icon is not selected, 1 if it is selected
  509. R3 = word at iconblock+20 (ie. pointer to indirected text for indirected text
  510.      icon)
  511.  
  512. Detects whether the icon is selected, and returns 1 in R0 if it is, 0
  513. otherwise. Also returns in R1 then value in the iconblock at offset 20. For
  514. an indirected text icon this will be a pointer to the text.
  515.  
  516.  
  517. WimpExt_SetNumberIcon    &45791
  518. -------------------------------
  519. R0 = base
  520. R2 = window handle
  521. R3 = icon handle
  522. R4 = value
  523.  
  524. Converts the signed integer in R4 into a string and places it in the icon.
  525. Updates the screen as necessary. The base to be used is specified in R0 - it
  526. must be in the range 2-36.
  527.  
  528.  
  529. WimpExt_GetNumberIcon    &45792
  530. -------------------------------
  531. R0 = default base
  532. R2 = window handle
  533. R3 = icon handle
  534. Exit:
  535. R0 = value
  536.  
  537. Converts the string in the icon to a signed integer and places it in R0. The
  538. base to be used by default is specified in R0 - it must be in the range 2-36.
  539.  
  540.  
  541. WimpExt_IncNumberIcon    &45793
  542. -------------------------------
  543. R0 = base
  544. R2 = window handle
  545. R3 = icon handle
  546. R4 = maximum value
  547. R5 = step
  548. Exit:
  549. R0 = new value
  550.  
  551. Converts the string in the icon to an signed integer, adds the step, and puts
  552. it back. Updates the screen as necessary. The value will not go beyond the
  553. value passed in R4, and the new value is returned in R0.
  554.  
  555.  
  556. WimpExt_DecNumberIcon    &45794
  557. -------------------------------
  558. R0 = base
  559. R2 = window handle
  560. R3 = icon handle
  561. R4 = minimum value
  562. R5 = step
  563. Exit:
  564. R0 = new value
  565.  
  566. Converts the string in the icon to an signed integer, subtracts the step, and
  567. puts it back. Updates the screen as necessary. The value will not go beyond
  568. the value passed in R4, and the new value is returned in R0.
  569.  
  570.  
  571. WimpExt_SetIconStringN   &457A0
  572. -------------------------------
  573. R0 = non-zero for ellipsis (only if enabled in WimpExt_Initialise)
  574. R2 = window handle
  575. R3 = icon handle
  576. R4 = pointer to string
  577.  
  578. Copies the string pointed to by R2 into the specified indirected text icon,
  579. and updates the screen if necessary. If the string is longer than the size of
  580. the buffer then the right-hand end of the string is copied (as opposed to the
  581. left-hand end, which is the case if you use WimpExt_SetIconString). If the
  582. caret was in the icon then it is moved to the end of the new string. If R0 is
  583. non-zero and bit 7 was set in R2 in WimpExt_Initialise and the string is
  584. longer than the icon can hold then the string will be pre-fixed with '...'.
  585.  
  586.  
  587. WimpExt_SetIconColour    &457B0
  588. -------------------------------
  589. R2 = window handle
  590. R3 = icon handle
  591. R4 = foreground colour (0-15 or -1 to keep the same)
  592. R5 = background colour (0-15 or -1 to keep the same)
  593. Exit:
  594. R0 = old foreground colour + old background colour * 16
  595.  
  596. Changes the specified icon's colour(s). If there is no change then the icon
  597. is not updated (ie. it doesn't flicker). This call will now work for anti-
  598. aliased fonts, but the icon MUST have an 'F' validation command, as the Wimp
  599. needs this to specify the icon's colour.
  600.  
  601.  
  602. WimpExt_ShadeIcon        &457B1
  603. -------------------------------
  604. R2 = window handle
  605. R3 = icon handle
  606. R4 = 0 to unshade icon, non-zero to shade icon
  607. If bit 6 of R2 was set in WimpExt_Initialise:
  608. R4 = 0 to unshade icon, 1 to shade icon, 2 to toggle shade flag
  609. Exit:
  610. R0 = old state of icon (0 for unshaded, 1 for shaded)
  611.  
  612. Shades the icon if R2 is non-zero, unshades it otherwise. Updates the screen
  613. if necessary. If the caret was in the icon and you are telling WimpExtension
  614. to shade it then the caret is removed (disowned). If bit 6 of R2 was set in
  615. WimpExt_Initialise then the alternative parameters are used as shown.
  616.  
  617.  
  618.  
  619. Pointer handling
  620. ================
  621.  
  622. Pointer changes over icons are controlled by the 'wp' validation command.
  623.  
  624.    'wp' (change pointer)
  625.      Syntax:
  626.        wp<pointer name>,<x hotspot>,<y hotspot>
  627.  
  628. The x and y hotspots are optional. What happens is that when the pointer is
  629. over the icon it will changed to the named sprite. The 'hotspot' is the area
  630. that is the actual 'point' of the pointer. Apart from the following supplied
  631. standard pointers, the sprite must be in the Wimp sprite pool.
  632.  
  633. Standard supplied pointers are:
  634.  
  635.        ptr_write    (4,4)
  636.         should be used over writeable icons
  637.        ptr_menu     (6,5)
  638.         should be used over icons that lead to menus when clicked with SELECT
  639.        ptr_direct   (12,6)
  640.         should be used for resizing objects
  641.        ptr_hand     (10,9)
  642.         should be used for dragging objects
  643.        ptr_cross    (8,4)
  644.         should be used for accurate pointing
  645.  
  646. All these pointers are stored (with hi-res versions as well) inside the
  647. WimpExtension module itself, so they are always available.
  648.  
  649. Pointer sprites should be designed in mode 8, maximum size 32x32 pixels. You
  650. should be wary of using logical colour 2 in pointer sprites, as it doesn't
  651. work in high-res mono modes. The pointer can have a palette if you want it
  652. to.
  653.  
  654. If you are in a hi-res mode then WimpExtension will try to use a sprite of
  655. name "<pointer>22", and then try "<pointer>" if that didn't work. Therefore
  656. you can supply hi-res pointers as well (they should be in mode 19).
  657.  
  658. The pointer changing is done entirely by the WimpExtension task, so you CAN
  659. disable null events and pointer changing will still work.
  660.  
  661. On RISC OS 3 the 'p' command is attempted by the operating system, so
  662. WimpExtension uses the 'wp' command as RISC OS gets the pointer changing
  663. wrong.
  664.  
  665. There is also a SWI provided so that your program can change the pointer
  666. directly:
  667.  
  668.  
  669. WimpExt_SetPointer       &45795
  670. -------------------------------
  671. R0 = pointer to sprite name in the Wimp sprite pool, or 0 to reset pointer
  672. If R0>0:
  673. R2 = hotspot X
  674. R3 = hotspot Y
  675.  
  676. Stores the old pointer palette, and changes the pointer palette and shape to
  677. the sprite specified in R0 (palette optional). The 'hotspot' is defined by
  678. the X and Y coordinates (pixels) in R2 and R3. If R0 is 0 then it will reset
  679. the pointer to its original state. You don't need to check if the pointer is
  680. already reset or changed as WimpExtension will do this for you. Note that the
  681. pointer will keep changed until you specifically ask for it to be reset - ie.
  682. pointer changes over icons will be suspended, and the pointer will remain
  683. changed outside your window's workarea.
  684.  
  685.  
  686. WimpExt_LimitPointer     &457A2
  687. -------------------------------
  688. R0 = window handle
  689.  
  690. Limits the mouse pointer to the visible area of the window specified. Note
  691. that if there are draggable objects within this area and these are used then
  692. the mouse rectangle is reset. It is also reset if there is a change of mode,
  693. eg. if the user presses F12 and then Return.
  694.  
  695.  
  696. WimpExt_ReleasePointer   &457A3
  697. -------------------------------
  698.  
  699. Releases the limits on the mouse pointer - ie. sets the mouse rectangle to be
  700. the entire screen. Note that this call resets the graphics origin and the
  701. graphics and text windows (ie. it does a 'VDU 26').
  702.  
  703.  
  704.  
  705. Colour menus
  706. ============
  707.  
  708. Colour menus are useful if you want the user to be able to select any WIMP
  709. colour for some reason. WimpExtension will automatically create a colour menu
  710. for you, and will work out whether each menu item should be black or white.
  711.  
  712.  
  713. WimpExt_ColoursMenu      &45797
  714. -------------------------------
  715. R0 = colour to be ticked
  716. R2 = 0 to have just colours, 1 to have extra option
  717. Exit:
  718. R0 = pointer to colour menu
  719.  
  720. Creates a colour menu (like Edit's 'Background' and 'Foreground' ones),
  721. making the text of each option black or white depending on the brightness of
  722. that colour in the current palette. If the value in R0 on entry is in the
  723. range 0-15 then that colour will be ticked in the menu. The call returns a
  724. pointer to the menu block (in RMA workspace). If the value in R2 on entry is
  725. 1 then a 17th option will be added, 'Transparent'. You can change the text of
  726. this by changing the menu block if you want (it's in RMA). The 17th option
  727. will be ticked if R0 on entry is 16.
  728.  
  729.  
  730.  
  731. Window handling
  732. ===============
  733.  
  734.  
  735. WimpExt_CentreWindow     &45799
  736. -------------------------------
  737. R1 = pointer to block:
  738.       R1 +  0   visible area minimum x coordinate
  739.       R1 +  4   visible area minimum y coordinate
  740.       R1 +  8   visible area maximum x coordinate
  741.       R1 + 12   visible area maximum y coordinate
  742.       R1 + 28   window flags
  743. Exit:
  744.       Block contains altered coordinates
  745.  
  746. This call shifts the x coordinates in the supplied block so that the window
  747. described would be centred horizontally on the screen. You can use this call
  748. before Wimp_CreateWindow - eg:
  749.        SYS "WimpExt_CentreWindow",,q%
  750.        SYS "WimpExt_CreateWindow",,q% TO handle%
  751. or you can use it before Wimp_OpenWindow - eg:
  752.        SYS "WimpExt_CentreWindow",,q%+4
  753.        SYS "WimpExt_OpenWindow",,q%
  754. If you are using WimpExt_LoadTemplates then windows can be centred
  755. automatically for you (see description above).
  756.  
  757.  
  758. WimpExt_CentreWindowV    &457BE
  759. -------------------------------
  760. R1 = Pointer to block:
  761.       R1 +  0   visible area minimum x coordinate
  762.       R1 +  4   visible area minimum y coordinate
  763.       R1 +  8   visible area maximum x coordinate
  764.       R1 + 12   visible area maximum y coordinate
  765.       R1 + 28   window flags
  766. Exit:
  767.       Block contains altered coordinates
  768.  
  769. This call shifts the y coordinates in the supplied block so that the window
  770. described would be centred vertically on the screen. You can use this call
  771. before Wimp_CreateWindow - eg:
  772.        SYS "WimpExt_CentreWindowV",,q%
  773.        SYS "WimpExt_CreateWindow",,q% TO handle%
  774. or you can use it before Wimp_OpenWindow - eg:
  775.        SYS "WimpExt_CentreWindowV",,q%+4
  776.        SYS "WimpExt_OpenWindow",,q%
  777. If you are using WimpExt_LoadTemplates then windows can be centred
  778. automatically for you (see description above).
  779.  
  780.  
  781. WimpExt_CheckWindowOpen  &4579D
  782. -------------------------------
  783. R0 = window handle (or -3 for requester window)
  784. Exit:
  785. R0 = 0 if window closed, 1 if open
  786.  
  787. Checks to see if the specified window is open.
  788.  
  789.  
  790. WimpExt_SetWindowTitle   &4579F
  791. -------------------------------
  792. R2 = window handle
  793. R3 = pointer to string
  794.  
  795. Copies the string in R3 into the window whose handle is in R2. The title must
  796. be indirected. Updates the screen if necessary.
  797.  
  798.  
  799. WimpExt_OpenFullSize     &457A4
  800. -------------------------------
  801. R2 = window handle
  802. R3 = window to open behind (-1 = top, -2 = bottom)
  803.  
  804. Opens the window to maximum size - ie. the same as clicking on the toggle
  805. icon.
  806.  
  807.  
  808. WimpExt_SetExtent        &457B5
  809. -------------------------------
  810. R0 = window handle
  811. R1 = pointer to block
  812.      R1+00 = new work area minimum x
  813.      R1+04 = new work area minimum y
  814.      R1+08 = new work area maximum x
  815.      R1+12 = new work area maximum y
  816.  
  817. Sets the work area extent of the specified window, altering the values to be
  818. whole pixels, and reopening the window (if already open) so that the change
  819. is reflected on the screen.
  820.  
  821.  
  822.  
  823. Key handling
  824. ============
  825.  
  826. As it is often needed that RETURN do the same as clicking on the default icon
  827. (the one with border type 2), and also that the up and down arrow keys move
  828. to writeable icons above and below, WimpExtension will handle these keys for
  829. you. Simply include the validation code 'wr' in the writeable icon's
  830. validation string:
  831.  
  832.   'wr'
  833.     Syntax:
  834.       wr[RETURN icon number],[up icon number],[down icon number]
  835.  
  836. The icons specified will be used when the user presses RETURN, up arrow (or
  837. shift-tab) and down arrow (or tab) respectively. If the icon specified is a
  838. writeable icon then the caret will be moved to that icon, otherwise
  839. WimpExtension will generate a fake Mouse_Click event for that icon, which
  840. will make it appear to your task as if the user clicked with button status
  841. %100 on the icon (the mouse coordinates given will be those of the caret).
  842.  
  843. You may leave out any of the numbers in the syntax, if you do so then
  844. WimpExtension will not affect the handling of that key.
  845.  
  846.  
  847. WimpExt_PutCaretIcon     &4579B
  848. -------------------------------
  849. R2 = window handle
  850. R3 = icon handle
  851.  
  852. Works out the length of the indirected text icon specified and calls
  853. 'Wimp_SetCaretPosition' to position the caret and the end of the string.
  854.  
  855.  
  856. WimpExt_MoveCaret        &457B6
  857. -------------------------------
  858. R0 = key
  859. R2 = window handle
  860. R3 = icon handle
  861. Exit:
  862. R0 preserved if no action taken, 0 otherwise
  863.  
  864. Moves the caret from its current writeable icon to the next one above or
  865. below (in number) if the key in R0 is up arrow (or shift-tab) or down arrow
  866. (or tab). If you set bit 8 of R2 on entry to WimpExt_Initialise then this SWI
  867. will be called automatically for you in WimpExt_Action, and the reason code
  868. translated to a null event if the key is processed.
  869.  
  870.  
  871.  
  872. Radio icons
  873. ===========
  874.  
  875. There are a couple of validation commands for helping with radio icons. 'ws'
  876. allows icons to select and deselect other icons when clicked on, and 'wu'
  877. allows icons to shade and unshade other icons.
  878.  
  879.   'ws'
  880.     Syntax:
  881.       ws<action>,<icon>[,<icon>][,<icon>][,<icon>]...
  882.  
  883. The action code is as follows:
  884.  
  885.   0   deselect specified icons
  886.   1   select specified icons
  887.   2   toggle specified icons
  888.  
  889. The syntax is exactly the same for 'wu' except that the icons will be shaded
  890. instead of selected. You can specify several of these commands in one
  891. validation string - eg. 'ws1,4;ws2,5;ws0,1'.
  892.  
  893.  
  894.  
  895. Menu handling
  896. =============
  897.  
  898.  
  899. WimpExtension can do a couple of helpful things with menus. If you use
  900. WimpExt_CreateMenu instead of Wimp_CreateMenu and you set bit 1 in R2 when
  901. you call WimpExt_Initialise then WimpExtension will automatically recreate
  902. menus when the user clicks Adjust.
  903.  
  904.  
  905. WimpExt_OpenDialogue     &4579C
  906. -------------------------------
  907. R2 = window handle
  908. R3 = X Offset
  909. R4 = Y Offset
  910.  
  911. Opens the specified window using Wimp_CreateMenu at the pointer position,
  912. offset by R3 and R4. The coordinates used are PointerX-R3,PointerY+R4.
  913.  
  914.  
  915. WimpExt_CreateMenu       &457AC
  916. -------------------------------
  917. R1 = pointer to menu structure, or window handle, or -1 to close menus
  918. R2 = menu X
  919. R3 = menu Y
  920.  
  921. Exactly the same as Wimp_CreateMenu, except that the parameters are stored so
  922. that, after you have processed the selection, if the user clicked ADJUST you
  923. can call WimpExt_ReCreateMenu (see below) to reopen the menu, or this can be
  924. done for you (see WimpExt_Initialise).
  925.  
  926.  
  927. WimpExt_ReCreateMenu     &457AD
  928. -------------------------------
  929.  
  930. Reopens the last menu opened with WimpExt_CreateMenu. Generates an error if
  931. the last operation was to close a menu, or if you have not called
  932. WimpExt_CreateMenu yet.
  933.  
  934.  
  935. WimpExt_ShadeEntry       &457AE
  936. -------------------------------
  937. R1 = pointer to menu structure
  938. R2 = number of option to shade/unshade (0...nn)
  939. R3 = 0 to unshade, any other to shade
  940. If bit 6 of R2 was set in WimpExt_Initialise:
  941. R3 = 0 to unshade entry, 1 to shade icon, 2 to toggle shade flag
  942. Exit:
  943. R0 = old state of menu entry (0 for unshaded, 1 for shaded)
  944.  
  945. Shades or unshades the specified menu entry. If bit 6 of R2 was set in
  946. WimpExt_Initialise then the alternative parameters are used as shown.
  947.  
  948.  
  949. WimpExt_TickEntry        &457AF
  950. -------------------------------
  951. R1 = pointer to menu structure
  952. R2 = number of option to tick/untick (0...nn)
  953. R3 = 0 to untick, any other to tick
  954. If bit 6 of R2 was set in WimpExt_Initialise:
  955. R3 = 0 to untick entry, 1 to tick entry, 2 to toggle tick flag
  956. Exit:
  957. R0 = old state of menu entry (0 for unticked, 1 for ticked)
  958.  
  959. Ticks or unticks the specified menu entry. If bit 6 of R2 was set in
  960. WimpExt_Initialise then the alternative parameters are used as shown.
  961.  
  962.  
  963. WimpExt_MenuWidth        &46382
  964. -------------------------------
  965. R1 = pointer to menu structure
  966.  
  967. This SWI scans through the specified menu, altering its width and the widths
  968. of all its submenus, so that all the menus are the minimum width possible
  969. while still displaying the text correctly (and neatly).
  970.  
  971.  
  972.  
  973. Incrementing and decrementing icons
  974. ===================================
  975.  
  976. If, as is often the case, you have a number in an indirected icon on the
  977. screen and you want the user to be able to alter it, it is nice to have
  978. bumper icons next to it as well as making it writeable. For this purpose, you
  979. can specify that an icon should decrement/increment another icon when clicked
  980. on in the validation string. The syntax of the command is:
  981.  
  982.    'wi' (increment)
  983.      Syntax:
  984.        wi<icon>,<minimum>,<maximum>,<step>
  985.  
  986. The default values are: wixx,0,&7FFFFFFF,1. All the values are optional apart
  987. from the icon number. To make it decrement the icon instead, use a negative
  988. step value. If the user clicks with Adjust instead of Select then the icon
  989. will be incremented instead of decremented, or decremented instead of
  990. incremented, in keeping with other RISC OS features.
  991.  
  992. See 'icon handling', WimpExt_IncNumberIcon and WimpExt_DecNumberIcon for more
  993. information.
  994.  
  995.  
  996.  
  997. Requester windows
  998. =================
  999.  
  1000. A requester window has a title message, a text string, and up to four
  1001. buttons. It can be used as a general-purpose way of asking the user for some
  1002. response which must be answered before anything else happens - like the
  1003. Wimp's Wimp_ReportError window, but a lot nicer and more flexible. An
  1004. advantage of the requester windows is that you can specify the text of the
  1005. buttons, what Escape and Return do, and the computer still multitasks while
  1006. the requester is open. (If you don't want a multitasking requester, see
  1007. 'Immediate windows'.)
  1008.  
  1009.  
  1010. WimpExt_OpenRequester    &457A6
  1011. -------------------------------
  1012. R2 = title (eg. 'Message from MyTask')
  1013. R3 = text (eg. 'Document not saved. Save?')
  1014. R4 = pointer to block containing button definitons
  1015.        text for default button    (eg. 'Save')
  1016.        text for button 1          (eg. 'Discard')
  1017.        text for button 2          (eg. 'Cancel')
  1018.        ...
  1019. R5 = button to be used if 'Escape' is pressed (0-3)
  1020.  
  1021. Opens a requester box with a title, a message and some buttons along the
  1022. right-hand edge. The pointer is constrained to the requester window. The
  1023. buttons may contain any text up to 8 characters. You can have up to 4
  1024. buttons. They are filled with the text specified from the bottom one (the
  1025. default) upwards. If the text for a button is a null string then that button
  1026. will not be created. If the user presses Return then the default button is
  1027. pressed. If the user presses Escape then the button specified in R5 is
  1028. pressed. Mouse_Click events to the requester window will be passed from
  1029. WimpExt_Action filtered so that only Select and Adjust are passed through,
  1030. the window handle is -3, and the icon handle will be 0-3. You can check
  1031. whether the requester window is open by using WimpExt_CheckWindowOpen.
  1032.  
  1033.  
  1034. WimpExt_CloseRequester   &457A7
  1035. -------------------------------
  1036.  
  1037. Closes the requester window and releases the mouse pointer. This is done
  1038. automatically if the user selects a button in the requester box, or presses
  1039. Escape or Return. If the window wasn't open then no error is generated.
  1040.  
  1041.  
  1042.  
  1043. Help
  1044. ====
  1045.  
  1046. WimpExtension provides a couple of SWIs and a validation command to make
  1047. providing multitasking help easier. The validation command is:
  1048.  
  1049.     'wh' (help)
  1050.       Syntax:
  1051.         wh<message>
  1052.  
  1053. When the pointer is over the icon, Acorn's Help application would display the
  1054. message specified.
  1055.  
  1056. If you set bit 5 of R2 when you called WimpExt_Initialise, specifying
  1057. 'semi-automatic' help then instead of sending the message to Help for you,
  1058. WimpExtension will instead give YOU a message, &45783, giving you the
  1059. suggested help string. This feature was suggested by Peter Greenham, so that
  1060. help strings can be converted via MsgTrans. The message format is as
  1061. follows:
  1062.     R1+0   40
  1063.     R1+16  &45783
  1064.     R1+20  mouse X
  1065.     R1+24  mouse Y
  1066.     R1+28  button state
  1067.     R1+32  window handle (-1 for background, -2 for icon bar,
  1068.            -3 for requester window)
  1069.     R1+36  icon handle
  1070.     R1+40  suggested text
  1071.  
  1072. You may notice that this is the same as message &502, with the message number
  1073. changed and the suggested text tagged on the end. To send this on unchanged,
  1074. you would use:
  1075.     SYS "WimpExt_SendHelp",q%+40,q%
  1076.  
  1077.  
  1078. WimpExt_SendHelp         &457AA
  1079. -------------------------------
  1080. R0 = message text
  1081. R1 = pointer to message block containing message of type &502 or &45783
  1082.  
  1083. Sends a reply to message type &502, with the specified text. The message will
  1084. appear in Help's Interactive Help Window, or WimpHelp's Standard Help Window.
  1085.  
  1086.  
  1087. WimpExt_SendWimpHelp     &457AB
  1088. -------------------------------
  1089. R2 = keyword
  1090. R3 = filename
  1091.  
  1092. Sends a message to WimpHelp, telling it to open a hypertext help window from
  1093. a file as specified in R3, with the keyword as specified in R2.
  1094.  
  1095.  
  1096.  
  1097. Graphics handling
  1098. =================
  1099.  
  1100.  
  1101. WimpExtension can help you with plotting sprites (including 256-colour ones)
  1102. and also with operations on Draw files (including displaying them).
  1103.  
  1104.  
  1105. WimpExt_SpriteOp         &46386
  1106. -------------------------------
  1107. R0 = reason code
  1108.      +256 for user sprite area, R2 points to sprite name
  1109.      +512 for user sprite area, R2 points to sprite
  1110. unless otherwise specified:
  1111. R1 = sprite control block pointer (or +1 for Wimp sprite pool)
  1112. R2 = sprite pointer
  1113. other registers as appropriate for reason code
  1114.  
  1115. This SWI performs various operations on sprites, including displaying them
  1116. onto the screen (or printer). Note that these calls need ColourTrans if you
  1117. are using them with 256-colour sprites. Sprites in the system sprite area are
  1118. not supported.
  1119.  
  1120. R0 = 0 : Display sprite
  1121. -----------------------
  1122. R3 = x coordinate (OS units)
  1123. R4 = y coordinate (OS units)
  1124. R5 = plot action
  1125.  
  1126. Plots the specified sprite on the screen. This call is mode-independent, so
  1127. if necessary the sprite is changed size and/or the colours are chosen
  1128. appropriately.
  1129.  
  1130. R0 = 1 : Get palette
  1131. --------------------
  1132. Exit:
  1133. R3 = pointer to sprite's palette, or 0 if it doesn't have one
  1134. R4 = number of entries in palette
  1135.  
  1136. Locates the specified sprite's palette.
  1137.  
  1138. R0 = 2 : Make pixel translation table
  1139. -------------------------------------
  1140. R3 = pointer to block to contain table (1 byte per colour)
  1141. Exit:
  1142.      block contains pixel translation data
  1143.  
  1144. Calculates a pixel translation table for displaying the specified sprite in
  1145. the current mode. If the sprite has no palette then the desktop's colours are
  1146. used.
  1147.  
  1148. R0 = 3 : Make scaling table
  1149. ---------------------------
  1150. R3 = pointer to 16-byte block to contain table
  1151. Exit:
  1152.      block contains scaling table
  1153.  
  1154. Calculates a scaling table for displaying the specified sprite at normal size
  1155. in the current mode.
  1156.  
  1157. R0 = 4 : Display sprite scaled
  1158. ------------------------------
  1159. R3 = x coordinate (OS units)
  1160. R4 = y coordinate (OS units)
  1161. R5 = plot action
  1162. R6 = pointer to sprite scaling table:
  1163.      R6 + 00  x multiplier
  1164.      R6 + 04  y multiplier
  1165.      R6 + 08  x divisor
  1166.      R6 + 12  y divisor
  1167.  
  1168. Plots the specified sprite on the screen, scaled according to the table. This
  1169. call is mode-independent, so if necessary the sprite is changed size and/or
  1170. the colours are chosen appropriately. The sprite is first scaled to be the
  1171. correct size in the current mode, then the specified scaling table is used.
  1172.  
  1173.  
  1174. WimpExt_DrawOp           &46385
  1175. -------------------------------
  1176. R0 = reason code
  1177. other registers as appropriate for reason code
  1178.  
  1179. This SWI performs various operations on Draw files, including rendering them
  1180. onto the screen (or printer).
  1181.  
  1182. R0 = 0 : Render draw file
  1183. -------------------------
  1184. R1 = pointer to scaling and position table:
  1185.        R1+00 = amount to multiply X by * 65536
  1186.        R1+04 = 0
  1187.        R1+08 = 0
  1188.        R1+12 = amount to multiply Y by * 65536
  1189.        R1+16 = X origin (OS units)
  1190.        R1+20 = Y origin (OS units)
  1191. R2 = pointer to first object (ie. beginning of Draw file+40)
  1192. R3 = pointer to end of file
  1193. R4 = pointer to graphics clip box, or 0 for no clipping:
  1194.        R4+00 = XMin
  1195.        R4+04 = YMin
  1196.        R4+08 = XMax
  1197.        R4+12 = YMax
  1198.  
  1199. This call displays a draw file. Objects will be checked one by one to see if
  1200. they are in the clipping area, and redrawn if they are. Currently the
  1201. following objects are supported:
  1202.       0 - font table
  1203.       1 - text
  1204.       2 - path
  1205.       5 - sprite
  1206.       6 - group
  1207.       7 - tag
  1208. This is all the objects specified in the RISC OS 2 PRMs, except for text AREA
  1209. objects, which are hardly ever used and are very very complicated. Magnifying
  1210. a draw file by more than about 8 times is probably not a good idea because
  1211. rounding errors in the Draw module will start to become significant. Note
  1212. that this call requires the ColourTrans module. It also requires the
  1213. FPEmulator module, if and only if the scaling is not 1:1. This call replaces
  1214. the old SWI WimpExt_RedrawDraw, which should now not be used. (This call is
  1215. much better anyway.)
  1216.  
  1217. R0 = 1 : Calculate bounding box
  1218. -------------------------------
  1219. R2 = pointer to first object
  1220. R3 = pointer to end of last object
  1221. Exit:
  1222. R4 = XMin (Draw units)
  1223. R5 = YMin (Draw units)
  1224. R6 = XMax (Draw units)
  1225. R7 = YMax (Draw units)
  1226.  
  1227. Calculates the bounding box of the specified objects. The coordinates are
  1228. returned in Draw units (which are OS Units * 256). Grouped objects are not
  1229. checked individually - the group's bounding box is used. Unknown object types
  1230. will not be checked. (This call 'knows' all the types described in the RISC
  1231. OS 2 PRMs.)
  1232.  
  1233.  
  1234.  
  1235. Font menus
  1236. ==========
  1237.  
  1238.  
  1239. Font menus have tended to be huge and impossible to use, with every single
  1240. variety of every single font listed all in one menu. WimpExtension will
  1241. automatically create a hierarchial font menu for you, with all the fonts
  1242. listed by family. Note that you must set bit 2 of R2 when you call
  1243. WimpExt_Initialise if you wish to use font menus.
  1244.  
  1245.  
  1246. WimpExt_GetFontMenu      &457B7
  1247. -------------------------------
  1248. R0 = 0 to unshade 'System font' entry, 1 to shade it
  1249. R1 = pointer to menu title (12 chars max), or 0 for default title ('Font')
  1250. Exit:
  1251. R1 = pointer to menu structure
  1252.  
  1253. Reads in the list of fonts currently available and creates a hierarchial
  1254. menu structure with all the fonts listed by family. 'System font' is also on
  1255. the root menu. This menu structure is guaranteed to remain in the same place
  1256. for as long as your task is active. The font list MAY be read in the first
  1257. time you call WimpExt_GetFontMenu, or it may have been read in earlier. This
  1258. SWI may only be called if you set bit 2 of R2 when you called
  1259. WimpExt_Initialise.
  1260.  
  1261.  
  1262. WimpExt_DecodeFontMenu   &457B8
  1263. -------------------------------
  1264. R0 = pointer to buffer for font name
  1265. R1 = pointer to Wimp_Poll block, reason code Menu_Selection
  1266.  
  1267. The font menu is decoded and the correct font name is placed in the buffer.
  1268. If the user selects, for example, 'Trinity' of 'Trinity.xxx','Trinity.yyy'
  1269. the submenus will be followed through, and the font name at the top of each
  1270. menu used. This SWI may only be called if you set bit 2 of R2 when you called
  1271. WimpExt_Initialise.
  1272.  
  1273.  
  1274.  
  1275. Immediate windows
  1276. =================
  1277.  
  1278.  
  1279. Immediate windows are nothing to do with the Wimp. They are redrawn entirely
  1280. by WimpExtension, and do not multitask. They can be for reporting the
  1281. progress of a non-multitasking operation, or for getting an immediate
  1282. response from the user. Because the redraw routine is entirely within
  1283. WimpExtension, not all features of windows and icons are supported. Windows
  1284. are fully supported apart from scrollbars and the control icons in the window
  1285. border. Icons at the moment don't include sprites, but this will be improved
  1286. upon in a later version of WimpExtension.
  1287.  
  1288.  
  1289. WimpExt_ControlImmediate &457B9
  1290. -------------------------------
  1291. R1 = 0 or -1   : close immediate window
  1292.    = 1         : check for mouse click in immediate window
  1293.    = 2         : open immediate requester and wait for mouse click
  1294.    = 3         : redraw icon - icon handle in R0
  1295.    = 4         : slab icon - icon handle in R0 (-1 to use currently slabbed
  1296.                  icon), R2 = 1 to slab in, 0 to slab out
  1297.    = 5         : limit pointer to immediate window
  1298.    = 6         : redraw icon's 3D border - icon handle in R0
  1299.    = 7         : redraw icon:
  1300.                  R0 = pointer to icon block
  1301.                  R2 = 'Work area' X origin
  1302.                  R3 = 'Work area' Y origin
  1303.   >= &8000     : open immediate window using data pointed to by R1
  1304. If R1 = 2 then rest of registers as for WimpExt_OpenRequester
  1305. Exit:
  1306. If R1 = 1 or 2 : R0 = Icon handle of icon clicked on, or -1 for none
  1307.  
  1308. This SWI is for using windows like the Wimp_ReportError window that are not
  1309. multi-tasking. You can only have one 'immediate window' open at a time, it is
  1310. always on top of the window pile, and you MUST NOT call 'Wimp_Poll' while the
  1311. immediate window is open.
  1312. If R1 is 0 or -1 on entry, the immediate window is closed. If it was not open
  1313. then no error is generated.
  1314. If R1 is 1 on entry, then the program will check for mouse clicks on icons in
  1315. the window. 3D icons will be slabbed automatically. -1 is returned if no iconwas clicked on.
  1316. If R1 is 2 on entry, the rest of the registers are as for
  1317. WimpExt_OpenRequester. It opens an 'immediate requester' and waits for a
  1318. mouse click on one of the action buttons, or ESCAPE or RETURN. The icon
  1319. clicked on is returned in R0.
  1320. If R1 is 3 on entry, the icon in the immediate window whose handle is in R0
  1321. will be redrawn (presumably because you have changed the indirected data).
  1322. The 3D border is not redrawn.
  1323. If R1 is 4 on entry, the icon whose handle is in R0 will be slabbed in or out
  1324. depending on R2 - similar to WimpExt_SlabIcon for normal icons. If the
  1325. specified icon handle is -1 and R2 is 0 then the currently slabbed icon (if
  1326. any) is used.
  1327. If R1 is 5, the mouse rectangle is redefined to be the size of the immediate
  1328. window - similar to WimpExt_LimitPointer for normal windows. Use
  1329. WimpExt_ReleasePointer to release the pointer again afterwards.
  1330. If R1 is 6, the specified icon's 3D border is redrawn.
  1331. If R1 is 7, the specified icon is drawn. You do not need to have an immediate
  1332. window open to use this reason code.
  1333. If R1 is greater than or equal to &8000 on entry, then an immediate window is
  1334. created from the Wimp_CreateWindow block pointed to by R1.
  1335. If you call WimpExt_PrePoll while an immediate window is open then it will be
  1336. closed automatically - the Wimp does not know about immediate windows and the
  1337. screen display would become corrupted if you kept an immediate window open
  1338. over a call to Wimp_Poll[Idle].
  1339. Icon types currently supported are:
  1340.   sprite-only non-indirected
  1341.   text-only, all types
  1342. Unknown icon types will be ignored.
  1343.  
  1344.  
  1345.  
  1346. Heap manager
  1347. ============
  1348.  
  1349. One of the biggest problems in writing multitasking programs (or single-
  1350. tasking ones for that matter) is memory management. For any program which has
  1351. more than one memory array which may change size during use it can get very
  1352. complicated. For this reason, WimpExtension provides a complete heap
  1353. manager. You call the initialise routine at the beginning of your program,
  1354. and from then on whenever you need some memory simply ask for it, and return
  1355. it when you don't need it any more. WimpExtension will automatically tidy the
  1356. heap, and reduce and enlarge the WimpSlot where necessary/possible.
  1357.  
  1358. The heap management system takes control of all your task's memory above the
  1359. start of the heap (specified when you call the initialise routine). You
  1360. should NOT change your task's WimpSlot when using the heap management routine
  1361. (ie. don't call Wimp_SlotSize with R0<>-1).
  1362.  
  1363. So that the memory blocks can be moved about by the tidy routine, you are not
  1364. given the address of the block, but the address of its 'anchor'. This is a
  1365. single word which points to the block. The tidy routine can then move the
  1366. block about and then update the anchor so you still know where it is. Note
  1367. that blocks will not mysteriously move on their own, they will only move on
  1368. calls to WimpExt_Heap, and then only for reason codes 5, 6, 11 and 12.
  1369. (See below.)
  1370.  
  1371. You specify the number of anchors to create when calling WimpExt_Heap's
  1372. initialise routine. More anchors can be created later using the increase
  1373. anchors routine, but this is quite slow. If you use the 'allocate with
  1374. extend' routine for allocating blocks then the increase anchors routine will
  1375. be called for you automatically when necessary. You cannot decrease the
  1376. number of anchors. If you specify 0 anchors in the initialise entry then a
  1377. default value of 256 is used - this is loads and should be more than
  1378. sufficient for most needs.
  1379.  
  1380. Note that the size of all memory blocks is a multiple of 8 plus 4 (ie.
  1381. size = 8N+4). The size will be rounded up on calls to the allocate routine.
  1382. The size of the block is stored 4 bytes before the start of the block. All
  1383. blocks are guaranteed word aligned.
  1384.  
  1385. When calling WimpExt_Heap routines, you can either refer to a block by a
  1386. pointer to it, or by a pointer to its anchor. I will refer to this as a
  1387. 'block pointer'.
  1388.  
  1389. The tidy routine can be automatically called once a second in WimpExt_PrePoll
  1390. if you set bit 3 of R2 when you call WimpExt_Initialise. Remember not to mask
  1391. out null events, though - it's probably best to use Wimp_PollIdle.
  1392.  
  1393. The routines are fairly robust, and will usually produce the error
  1394. 'Heap corrupt' or 'Bad heap operation' rather than an address exception or
  1395. corrupting memory if something goes wrong. Both of these should probably be
  1396. treated as fatal errors, but you can do with them what you like.
  1397.  
  1398. Note that when there are no blocks allocated in the heap, it takes no memory
  1399. at all - even the list of anchors is destroyed. This means that if you are a
  1400. module task with a heap at &8000 then you won't be unnecessarily using 16k
  1401. (or whatever page size the computer is using) all the time.
  1402.  
  1403.  
  1404. WimpExt_Heap             &457BA
  1405. -------------------------------
  1406. R0 = reason code
  1407. other registers as appropriate for reason code
  1408.  
  1409. R0 = 0 - Initialise heap:
  1410. -------------------------
  1411. R0 = 0
  1412. R1 = pointer to base of heap
  1413. R2 = number of anchors to allocate, or 0 for default (currently 256)
  1414.  
  1415. Initialises heap. R1 points to the base of the heap - it will grow upwards
  1416. from here. R2 specifies the numbers of anchors to allocate - this is
  1417. effectively the maximum number of blocks you may have allocated at any one
  1418. time. Each anchor takes 8 bytes. Note that R1 is rounded up to the nearest
  1419. multiple of 8 plus 4 (ie. 8N+4).
  1420.  
  1421. R0 = 1 - Decribe heap:
  1422. ----------------------
  1423. R0 = 1
  1424. Exit:
  1425. R2 = largest available block size
  1426. R3 = total free
  1427. R4 = memory used by heap
  1428. R5 = number of anchors allocated
  1429. R6 = number of anchors in use
  1430.  
  1431. Adds up all the sizes of the free blocks, and returns information about
  1432. memory used by the heap. If the heap is empty then R2-R6 will be zero.
  1433.  
  1434. R0 = 2 - Allocate block:
  1435. ------------------------
  1436. R0 = 2
  1437. R2 = size of block required
  1438. Exit:
  1439. R1 = pointer to anchor or zero if allocation failed
  1440.  
  1441. Tries to find a block of the required size. Increases the WimpSlot if
  1442. necessary. If a call to Wimp_SlotSize fails then zero will be returned. Note
  1443. that the size is rounded up to the next multiple of 8 plus 4.
  1444.  
  1445. R0 = 3 - Free block:
  1446. --------------------
  1447. R0 = 3
  1448. R1 = block pointer
  1449.  
  1450. Frees the memory used by the specified block.
  1451.  
  1452. R0 = 4 - Reallocate block:
  1453. --------------------------
  1454. R0 = 4
  1455. R1 = block pointer
  1456. R2 = new size required
  1457. Exit:
  1458. R1 = pointer to anchor (the same anchor as before) or 0 if reallocate failed
  1459.  
  1460. Tries to resize the specified block. You should check R1 on exit to see if
  1461. the resize was successful (only on increasing the size, decreasing the size
  1462. will always be successful).
  1463.  
  1464. R0 = 5 - Tidy heap:
  1465. -------------------
  1466. R0 = 5
  1467.  
  1468. Tries to tidy the heap, reducing the WimpSlot if possible. This can be
  1469. automatically performed once a second (in WimpExt_PrePoll) if you set bit 3
  1470. of R2 when you called WimpExt_Initialise. Note that this routine does not
  1471. tidy the heap fully, it just does a little bit each time it is called. This
  1472. is to keep the time cost down.
  1473.  
  1474. R0 = 6 - Compact heap:
  1475. ----------------------
  1476. R0 = 6
  1477.  
  1478. Repeatedly calls Tidy Heap, until the heap is as small as it can get.
  1479.  
  1480. R0 = 7 - Find anchor:
  1481. ---------------------
  1482. R0 = 7
  1483. R1 = block pointer
  1484. Exit:
  1485. R1 = pointer to anchor
  1486.  
  1487. Given a block pointer, returns a pointer to that block's anchor.
  1488.  
  1489. R0 = 8 - Fix blocks:
  1490. --------------------
  1491. R0 = 8
  1492.  
  1493. Fixes the heap. Subsequent calls to the Tidy or Compact routines will have no
  1494. effect. Effectively, the heap becomes a non-relocatable heap like the RMA.
  1495. This call is provided so that if you temporarily need to rely on the blocks
  1496. not moving, you can easily do so. WimpExtension keeps a counter of the number
  1497. of times you call this routine, so that if you, for example, fix the blocks
  1498. twice in a row then you need to unfix them twice in a row before they are
  1499. actually unfixed.
  1500.  
  1501. R0 = 9 - Unfix blocks regardless of counter:
  1502. --------------------------------------------
  1503. R0 = 9
  1504.  
  1505. Unfixes the heap, so that garbage disposal routines will work again. This
  1506. call zeroes the counter straight away - ie. the blocks are immediately
  1507. unfixed no matter how many times you called the fix routine.
  1508.  
  1509. R0 = 10 - Unfix blocks:
  1510. -----------------------
  1511. R0 = 10
  1512.  
  1513. Unfixes the heap, so that garbage disposal routines will work again. This
  1514. routine decrements the fix counter, and only actually unfixes the blocks if
  1515. the counter reaches zero.
  1516.  
  1517. R0 = 11 - Increase anchors:
  1518. ------------------------------------
  1519. R0 = 11
  1520. R2 = number of anchors to add
  1521. Exit:
  1522. R1 = 0 indicates failure, non-zero indicates success
  1523.  
  1524. Increases the number of anchors. This routine is quite slow as it often has
  1525. to move the entire heap up in memory so you should use this routine
  1526. sparingly, if you need to use it at all. Note that this SWI causes blocks to
  1527. be relocated.
  1528.  
  1529. R0 = 12 - Allocate with anchor extend:
  1530. --------------------------------------
  1531. R0 = 2
  1532. R2 = size of block required
  1533. Exit:
  1534. R1 = pointer to anchor or zero if allocation failed
  1535.  
  1536. Tries to find a block of the required size. Increases the WimpSlot if
  1537. necessary. If a call to Wimp_SlotSize fails then zero will be returned. Note
  1538. that the size is rounded up to the next multiple of 8 plus 4. If no free
  1539. anchors are available then the increase anchors call is used to make some
  1540. more; therefore using this SWI can cause blocks to be relocated. It is,
  1541. however, the recommended call to use for allocating blocks as it isn't
  1542. limited by the number of anchors already created.
  1543.  
  1544. R0 = 13 - Free all blocks
  1545. -------------------------
  1546. R0 = 13
  1547.  
  1548. Frees all blocks belonging to your task.
  1549.  
  1550.  
  1551.  
  1552. Data transfer
  1553. =============
  1554.  
  1555. WimpExtension can handle saving files if your file is in a contiguous area of
  1556. memory (ie. not split up in several chunks all over the place). You just call
  1557. WimpExt_DataSave when you receive the User_Drag_Box event from the user
  1558. dropping the icon in a filer window or onto another task. When the transfer
  1559. is complete (successful or otherwise) you will be sent a message, &45782,
  1560. telling you that the transfer is complete, and whether everything went OK.
  1561. The SWI supports the full data transfer protocol, including the Wimp$Scrap
  1562. method and RAM transfer. Note that if you are saving from a WimpExt_Heap
  1563. block, you should fix the blocks beforehand, and unfix them afterwards.
  1564.  
  1565. WimpExtension can now also handle loading of files. Files can either be
  1566. loaded into a WimpExt_Heap block (the preferred method) or they can be loaded
  1567. into a fixed-size area of memory. Use is similar to WimpExt_DataSave - you
  1568. just pass the DataSave or DataLoad message to WimpExt_DataLoad, and wait for
  1569. a message telling you the transfer is complete.
  1570.  
  1571.  
  1572. WimpExt_DataSave         &457BC
  1573. -------------------------------
  1574. R0 = File length
  1575. R1 = Pointer to filename (pathname or leafname)
  1576. R2 = File type
  1577. R3 = Pointer to data
  1578. R4 = Zero to allow files to be saved to your own task, non-zero otherwise
  1579. Exit:
  1580. R0 = 0 if failed due to attempt to save to own task, non-zero otherwise
  1581.  
  1582. Used to save a file from your program to a filer or to another task. When you
  1583. receive the User_Drag_Box event after the user has dragged the icon to where
  1584. they want it put, call WimpExt_DataSave to handle the data transfer. If R4 is
  1585. non-zero on entry, then if the user has dragged the file to a window or icon
  1586. belonging to your task then no action will be taken, and R0 will be zero on
  1587. exit. Otherwise, when the transfer has finished, WimpExtension will send you
  1588. a message, number &45782, with the word at R1+20 having the following
  1589. meaning:
  1590.         0 = file not saved
  1591.         1 = file saved but is 'unsafe' (eg. saved to another task)
  1592.         2 = file saved
  1593. If the code is 2, then the filename the file was saved as is at R1+24.
  1594.  
  1595.  
  1596. WimpExt_DataLoad         &46383
  1597. -------------------------------
  1598. R0 = 0 : Load into heap block
  1599.   R1 = pointer to DataSave or DataLoad message block
  1600.   R2 = block pointer of block to receive file, or 0 to create new block
  1601.   R3 = offset in block to place file
  1602. R0 = 1 : Load into fixed block
  1603.   R1 = pointer to DataSave or DataLoad message block
  1604.   R2 = pointer to block to receive file
  1605.   R3 = length of block
  1606.  
  1607. Use this SWI to load files from the filer or other applications. If R0=0 then
  1608. the file is loaded into a WimpExt_Heap block, and can be any length, memory
  1609. permitting. If R0=1 then the file is loaded into a fixed area of memory, and
  1610. will not be loaded if it exceeds the length of the area. When you receive the
  1611. DataSave or DataLoad message, pass the block onto WimpExt_DataLoad, and the
  1612. transfer will be handled automatically. As long as this SWI doesn't return an
  1613. error, when the transfer has finished, WimpExtension will send you a message,
  1614. number &45784, with the word at R1+20 having the following meaning:
  1615.         0 = file not loaded. Error block at R1+28
  1616.         1 = file transferred successfully from another task
  1617.         2 = file loaded successfully from disc
  1618. A pointer to the block's anchor is at R1+24, if it was loaded into a heap
  1619. block. Otherwise a pointer to the area is at R1+24. If R1+20<>0 then the rest
  1620. of the block contains:
  1621.     R1+28 = length of file
  1622.     R1+32 = load address of file
  1623.     R1+36 = exec address of file
  1624.     R1+40 = filename (leafname if transferred from task)
  1625. Obviously you need to have initialised a heap to use this SWI. Note that
  1626. WimpExtension won't free the block if there's an error; your error handler
  1627. must do this if appropriate. The load and exec addresses don't indicate the
  1628. date if the file was transferred from another task (the relevant bits will
  1629. all be zero).
  1630.  
  1631.  
  1632.  
  1633. Dragging icons
  1634. ==============
  1635.  
  1636.  
  1637. To make dragging icons about easier, WimpExtension provides a single SWI
  1638. 'WimpExt_DragIcon'. Normally this will produce an ordinary rotating dash-box
  1639. like normal. If you have the DragASprite module loaded, however, it can be
  1640. made to use that instead (if the user has configured the computer to use this
  1641. module by setting bit 1 of CMOS RAM location 28).
  1642.  
  1643. The DragASprite module is included with RISC OS 3 and above. However, the
  1644. module can be altered to work on RISC OS 2 by simply removing the call to
  1645. OS_ReadSysInfo in the initialise entry. I have no idea whether it is legal to
  1646. take a copy of DragASprite from a RISC OS 3 machine, alter it, and put it on
  1647. a RISC OS 2 machine, so I haven't supplied a RISC OS 2-compatible copy of
  1648. DragASprite.
  1649.  
  1650.  
  1651. WimpExt_DragIcon         &4579A
  1652. -------------------------------
  1653. R0 = flags:
  1654.       0-1 Horizontal position:
  1655.             00 = left
  1656.             01 = middle
  1657.             10 = right
  1658.             11 = undefined
  1659.       2-3 Vertical position:
  1660.             00 = bottom
  1661.             01 = middle
  1662.             10 = top
  1663.             11 = undefined
  1664.       4-5 Mouse bounding box:
  1665.             00 = whole screen
  1666.             01 = constrain to parent window
  1667.             10 = constrain to box pointed to by R5
  1668.             11 = undefined
  1669.       6   constrain sprite if set, otherwise constrain pointer
  1670.       7   shadow if set
  1671.       8   use DragASprite even if CMOS flag isn't set
  1672.      9-31 reserved; MUST BE 0
  1673. R1 = pointer to sprite block, +1 for Wimp sprite area, 0 to use dash box
  1674. R2 = Window handle
  1675. R3 = Icon handle
  1676. R4 = pointer to sprite name (if R1<>0)
  1677. R5 = pointer to mouse bounding box (only if necessary - see flags)
  1678.       +00 xmin
  1679.       +04 ymin
  1680.       +08 xmax
  1681.       +12 ymax
  1682.  
  1683. This SWI does one of two things. If the DragASprite module is loaded, and
  1684. bit 1 of byte 28 of the CMOS RAM is set, and R1<>0 then it will use the
  1685. DragASprite module as follows:
  1686.   Work out the parameters to 'DragASprite_Start' and call it. If this
  1687.   produces an error then try again with dash box as described below.
  1688. Otherwise it makes an ordinary rotating dash box as follows:
  1689.   Work out the parameters to 'Wimp_DragBox' and call it. Bits 0-3 and 7 of
  1690.   the flags are ignored.
  1691. If you are using this SWI at any time with R1<>0 then remember to call
  1692. XDragASprite_Stop at appropriate points. You MUST use the X form of the SWI,
  1693. and you must ignore errors.
  1694. This SWI has been altered since version 1.63 of WimpExtension - if you wish
  1695. to use it as before simply set R0 and R1 to zero.
  1696.  
  1697.  
  1698.  
  1699. Miscellaneous SWIs
  1700. ==================
  1701.  
  1702.  
  1703. WimpExt_CurrentTask      &4578B
  1704. -------------------------------
  1705. R0 = task handle
  1706. Exit:
  1707. R0 = previous task handle
  1708.  
  1709. Informs WimpExtension which task is currently active. Not needed if you have
  1710. called WimpExt_Initialise or WimpExt_Action since the last Wimp_Poll. The
  1711. previous user is returned in R0.
  1712.  
  1713.  
  1714. WimpExt_Divide           &45796
  1715. -------------------------------
  1716. R2 = Numerator
  1717. R3 = Denominator
  1718. Exit:
  1719. R0 = Result
  1720. R2 = Remainder
  1721.  
  1722. Returns (R2 DIV R3) in R0 and (R2 MOD R3) in R2. Useful for calculating which
  1723. area of window needs to be updated. An error is produced if R3 is zero on
  1724. entry.
  1725.  
  1726.  
  1727. WimpExt_CopyString       &4579E
  1728. -------------------------------
  1729. R2 = 'From' pointer
  1730. R3 = 'To' pointer
  1731.  
  1732. Copies the control-terminated string from R2 to R3. The string stored at R3
  1733. will be zero-terminated whatever the terminator was for the original string.
  1734.  
  1735.  
  1736. WimpExt_FindLeaf         &457A1
  1737. -------------------------------
  1738. R0 = Pointer to pathname
  1739. Exit:
  1740. R0 = Pointer to leafname
  1741.  
  1742. Finds the last occurence of '.' in the string pointed to by R0, and returns a
  1743. pointer to the next character. eg. given 'scsi::HardDisc.$.first.second.last'
  1744. it will return a pointer to 'last'. This can be useful for both extracting
  1745. the leaf name, and for determining what directory the file is in (by poking
  1746. a zero to (R0-1) - eg. MOV R2,#0  STRB R2,[R0,#-1] ).
  1747.  
  1748.  
  1749. WimpExt_MemCopy          &457BB
  1750. -------------------------------
  1751. R0 = 'From' address (word aligned)
  1752. R1 = 'To' address (word aligned)
  1753. R2 = Length (not necessarily word aligned)
  1754. Exit:
  1755. R0 preserved
  1756.  
  1757. Copies an area of memory very quickly. Can cope with overlap, R0=R1 or R2=0.
  1758.  
  1759.  
  1760. WimpExt_PlotBorder       &457BD
  1761. -------------------------------
  1762. R0 = reason code
  1763.  R0 = 0  =>  R1 = pointer to icon block
  1764.  R0 = 1  =>  R1 = pointer to block:
  1765.                R1 + 0  Minimum work area x coordinate
  1766.                R1 + 4  Minimum work area y coordinate
  1767.                R1 + 8  Maximum work area x coordinate
  1768.                R1 + 12 Maximum work area y coordinate
  1769.                R1 + 16 Border type
  1770. R2 = window handle
  1771.  
  1772. Like Wimp_PlotIcon, except it just redraws the 3D border. If R0 is 1 on entry
  1773. then an alternative block is used as specified.
  1774.  
  1775.  
  1776. WimpExt_Sort             &46380
  1777. -------------------------------
  1778. R0 = number of objects to sort
  1779. R1 = pointer to array of objects
  1780. R2 = pointer to comparison routine
  1781. R3 = workspace pointer for comparison procedure
  1782. R4 = size of object
  1783. R5 = address of temporary workspace of R4 bytes (only needed if R4>63)
  1784.  
  1785. This SWI will sort an array of objects. It is very similar to the OS_HeapSort
  1786. SWI, except that you can use it to sort an array of ANY object, rather than
  1787. just arrays of pointers. R2 points to a routine which is entered, in SVC
  1788. mode, as follows:
  1789.   R0  = address of object a
  1790.   R1  = address of object b
  1791.   R12 = value supplied to WimpExt_Sort in R3
  1792.   R13 = supervisor stack
  1793.   R14 = return address
  1794. The routine should compare the two objects and return, preserving all
  1795. registers apart from R0,R1,R12 and R14, with flags set as follows:
  1796.   a<b   Z=0, C=0
  1797.   a=b   Z=1, C=1
  1798.   a>b   Z=0, C=1
  1799. The actual method of sorting is unspecified; suffice it to say it's fast...
  1800. Although R5 doesn't have to be word-aligned, the sort will probably be faster
  1801. if it is.
  1802.  
  1803.  
  1804. WimpExt_MemMove          &46381
  1805. -------------------------------
  1806. R0 = from
  1807. R1 = to
  1808. R2 = size in bytes
  1809.  
  1810. Copies R2 bytes from R0 to R1. R0 and R1 need not be word-aligned, and R2
  1811. need not be a multiple of 4. This SWI uses the optimised memory copying
  1812. routine given in the RISC OS 2 PRMs. It does not cope with overlap (which is
  1813. why it's separate from WimpExt_MemCopy).
  1814.  
  1815.  
  1816. WimpExt_Intersect        &46387
  1817. -------------------------------
  1818. R0 = 0 : Boxes in registers:
  1819.   R2 = XMin1
  1820.   R3 = YMin1
  1821.   R4 = XMax1
  1822.   R5 = YMax1
  1823.   R6 = XMin2
  1824.   R7 = YMin2
  1825.   R8 = XMax2
  1826.   R9 = YMax2
  1827. R0 = 1 : Boxes in blocks:
  1828.   R2 = pointer to XMin1,YMin1,XMax1,YMax1
  1829.   R3 = pointer to XMin2,YMin2,XMax2,YMax2
  1830. Exit:
  1831. If boxes intersect:
  1832. R0 = 1, C flag set
  1833. If boxes don't intersect:
  1834. R0 = 0, C flag clear
  1835.  
  1836. Checks whether the specified rectangles intersect.
  1837.  
  1838.  
  1839.  
  1840. OS commands
  1841. ===========
  1842.  
  1843. WimpExtension provides the OS-command 'X'. This is used to execute other OS
  1844. commands, but any errors produced by that command will be ignored. This can
  1845. be useful in obey files. eg:
  1846.  
  1847.   X Rename <Obey$Dir>.Data <Obey$Dir>.Backup
  1848.  
  1849. or
  1850.  
  1851.   X Run <Obey$Dir>.Title
  1852.  
  1853.  
  1854.  
  1855. Things possibly to be included in a later version...
  1856. ====================================================
  1857.  
  1858.    * Resizeable RamFS and common data area (very very useful)
  1859.    * List handling (quite useful when you come to think of it)
  1860.    * Fast text displayer (very useful)
  1861.  ( * Improved immediate windows (ie. handle more icon types)   )
  1862.  
  1863. Plus anything else useful anybody comes up with...
  1864.  
  1865. Improving immediate windows is definitely Acorn's problem - the fact that
  1866. they are not provided in the Wimp is a major failing of the RISC OS desktop
  1867. (in my opinion).
  1868.  
  1869. (Basically, by 2022 WimpExtension will be slightly larger than the solar
  1870. system and will have more features than are dreamt of in your philosophy.)
  1871.  
  1872.  
  1873.  
  1874. Thanks
  1875. ======
  1876.  
  1877.  
  1878. Thanks to Aiden Corey (hope I spelt that right) for helpful suggestions.
  1879.  
  1880. Thanks to Jon Thackray for disappearing off to Canterbury and claiming he's
  1881. poor when he quite blatantly bought an A410 and an ARM3 and a huge hard
  1882. drive, and Impression, and ...
  1883.  
  1884. Thanks to James Ponder for uploading stuff to BBSes ( :-)   <- that's a
  1885. smiley, for people who haven't used bulletin boards, I mean, I didn't know
  1886. what it was at first). James is really annoying and has a 14k4 modem, which
  1887. is silly.
  1888.  
  1889. Thanks to Mr. Clare, for looking mildly amused at whatever stunning programs
  1890. I pass his way...
  1891.  
  1892. Thanks to David Cox for being able to get me the SWI chunk for this module,
  1893. and being the first person other than me to use it in one of their programs.
  1894. (But certainly not the last ;-) )
  1895.  
  1896. Thanks to Ben Dooks and Andrew Clover for having no taste whatsoever.
  1897.  
  1898. Thanks to Acorn for making sprite and draw-file displaying so incredibly
  1899. complicated, and for making RISC OS so flexible, honest.
  1900.  
  1901. Finally, thanks to Ben Curthoys for generally complaining at me to get things
  1902. finished (maybe I WILL write a game someday), and for a black plastic bag.
  1903. (Which is now nearly deceased :-( ).
  1904.  
  1905.  
  1906.  
  1907. Plugs
  1908. =====
  1909.  
  1910. Look out for other PD stuff by me... VEnd (virus-killingly nice)...
  1911. HourMake (utterly wonderful)... EliteCht (astonishingly good)...
  1912. RoughTime IV (staggeringly useful)... SWI (swimmingly jolly)...
  1913.  
  1914. Also other stuff which I haven't decided how to classify yet... Domination
  1915. (startlingly smart)... Mines (running-out-of-adjectives-aly good)...
  1916.  
  1917. Also, products from other members of DoggySoft...
  1918.  
  1919. The Hacker, only £5, the original and BEST games hacker - makes it incredibly
  1920. easy to create cheats for games. Many many wonderful features. Just press
  1921. Alt-Alt during the game, and The Hacker will pop up... (As seen in Acorn
  1922. Computing...:-) )
  1923.  
  1924. Diss, only £10, by far the best desktop disassembler available for the
  1925. Archimedes. Diss has FAR too many features to list them all here, but they
  1926. include:
  1927.   * Multiple files/multiple views
  1928.   * FAST disassembly with optional colour-coding
  1929.   * Labels - you can add labels to any address to aid disassembly.
  1930.      eg. Instead of:
  1931.       B       &381239471
  1932.      you get:
  1933.       B       mouse_click
  1934.   * Automatic un-squeezing of Squeezed files
  1935.   * Automatic labels generation for:
  1936.       Modules (eg. entry points, SWIs, OS commands, etc.)
  1937.       Shared C Library functions
  1938.       BASIC in-line-assembler programs
  1939.       LINKed programs
  1940.       ABC programs
  1941.   * Search facilities (including search for reference (incredibly useful))
  1942. etc. etc. etc... Diss is invaluable for any serious programmer.
  1943.  
  1944.  
  1945.  
  1946. Finally
  1947. =======
  1948.  
  1949. Any money, bug reports, information, demos, just about anything to:
  1950.  
  1951.                 Jon Ribbens
  1952.                 39 Nutkins Way
  1953.                 Chesham
  1954.                 Bucks.
  1955.                 HP5 2BE
  1956.  
  1957. I can also be reached on Arcade BBS, but don't hold your breath...
  1958.