home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / i / iclear / ReadMe < prev   
Text File  |  1996-10-13  |  8KB  |  148 lines

  1.                                IClear Module
  2.                                ====== ======
  3.  
  4.                                by Martyn Fox
  5.  
  6. This software is Public Domain. It may be freely copied and distributed,
  7. including distribution by magazine discs, PD libraries, bulletin boards
  8. etc., provided the following conditions are adhered to:
  9.  
  10. 1. No charge is made other than to cover the reasonable cost of duplication
  11. and distribution.
  12.  
  13. 2. No alteration is made to either the software or this text file.
  14.  
  15. 3. This text file accompanies all copies of the software.
  16.  
  17. Please note that this module will only work with RISC OS 3 or later. This
  18. copy has been modified for compatibility with the StrongARM 110 processor.
  19.  
  20. IClear is a module which makes it easier to delete text from a writable
  21. icon. Under RISC OS, to replace the text in such an icon with new text, you
  22. first have to either delete all the characters of the old text or press
  23. Ctrl-U to clear it. This can be a nuisance, especially if you have just
  24. selected the icon with the mouse, as you first have to transfer to the
  25. keyboard, then press Ctrl-U before you can type in your new text.
  26.  
  27. With IClear running, simply double-click on the writable icon, using either
  28. Select or Adjust. The icon will be inverted, which usually means that it
  29. will turn black with white text. As soon as you press a key, the text in the
  30. icon will vanish, to be replaced with the character that you typed. If you
  31. change your mind after inverting the icon and decide you want to keep your
  32. existing text, a further click with any mouse button anywhere on the screen
  33. will de-invert the icon and put things back to normal.
  34.  
  35. This software will work with writable icons (button type 15) and also
  36. draggable writable icons (button type 14) but not with writable menu items.
  37.  
  38.                              Programming Notes
  39.                              =========== =====
  40.  
  41. The module intercepts the MouseV and InsV vectors to detect calls to
  42. OS_Mouse and keypresses. OS_Mouse calls are first passed onto the SWI
  43. routine and processed on exit.
  44.  
  45. Because RISC OS will not automatically detect a double-click over a writable
  46. icon, the module has to do the job itself. This involves checking the time
  47. interval since the previous click, selecting the 'double-arrow' pointer
  48. sprite, checking which button was pressed and monitoring the mouse position.
  49.  
  50. Rather than put too much code into a vector intercept routine, the software
  51. just sets one of two callbacks, depending on the time interval since the
  52. previous click. The callback routine is called by RISC OS as soon as it is
  53. not busy. The first of these callbacks handles a single click. It first
  54. checks to see if the module has a record of an inverted icon and, if so,
  55. takes steps to clear it. It then stores a record of which button was pressed
  56. and checks the icon type. If the click was over a writable icon, it stores
  57. the mouse position and redefines mouse pointer 1 sprite as ptr_double.
  58.  
  59. N.B. There appears to be no way of reading which sprite is used by a
  60. particular pointer number. Versions of this module up to v1.01 always
  61. replaced the double pointer with the ptr_default sprite after the
  62. double-click time-out. Subsequent versions checks the icon’s validation
  63. string, if any, looking for the ‘P’ instruction, which sets an alternative
  64. pointer sprite when over the icon, and restore the pointer to this sprite
  65. after first checking its presence in the Wimp sprite pool.
  66.  
  67. The module then sets a call-after, which is an instruction to RISC OS to
  68. call a routine after a certain length of time. It also calls OS_CallEvery to
  69. arrange for a call every 10 centiseconds to a routine which checks the mouse
  70. position and cancels the double-click monitoring if the mouse is moved more
  71. than a certain amount.
  72.  
  73. N.B. Although the normal double-click time limit and permitted mouse
  74. movement can be configured, there appears to be no way of reading their
  75. values, other than the unreliable method of checking CMOS RAM locations,
  76. which could change between different versions of RISC OS. This module uses
  77. the default configuration values of 1 second maximum between clicks and a
  78. maximum mouse movement of 10 OS units (it checks for either 10 horizontal or
  79. 10 vertical units of movement). These values are fixed in this version of
  80. the module. If there is a demand for the ability to alter these values, I
  81. will endeavour to include a couple of SWIs and/or star commands in a later
  82. version.
  83.  
  84. If either a second button is pressed or the mouse is moved before the
  85. call-after has timed out, the call-after and call-every are cancelled and a
  86. second callback is used. This routine checks that the same button has been
  87. pressed as previously, sets a flag and takes steps to invert the icon.
  88.  
  89. Although any icon can be inverted or de-inverted by means of a call to
  90. Wimp_SetIconState, the procedure is not that simple. This SWI may only be
  91. called while the application which owns the icon is the currently active
  92. task. If we simply call it when the mouse is clicked, this may not be the
  93. case, especially if several multi-tasking applications are running at the
  94. same time. We have to send a message to the task but we cannot, of course,
  95. rewrite its software.
  96.  
  97. The solution is to use a filter. We could use a pre-filter, which is called
  98. just before Wimp_Poll is executed, or a post-filter which is called on
  99. return from Wimp_Poll. In this case, we use the latter. The technique is to
  100. send a unique message to the task which our filter will intercept and
  101. recognise, telling it to invert or de-invert the required icon. Version
  102. v1.10 also uses the filter to check the icon’s validation string to get the
  103. pointer sprite name.
  104.  
  105. We could send a message, using reason code 17 or 18, but we would have to
  106. find a message action code that is not used for anything else, which would
  107. present problems. It is also permissible for a task to mask out these reason
  108. codes, which would prevent our message getting through. So that this cannot
  109. happen, the module sends a message with reason code 2, which usually means
  110. 'open window request'. This reason code is not supposed to be masked out
  111. when calling Wimp_Poll. Our message sends R1+0 as zero and R1+4 as
  112. &726C4349, which is the ASCII code for 'IClr'. This corresponds to a request
  113. to open the window whose handle is zero, with a minimum x coordinate of
  114. &726C4349 - a most unlikely state of affairs in any other situation! The
  115. third word in the block contains the action code for the call. Bit 1 set
  116. denotes that the call is to invert or clear the icon - bit 0 is cleared to
  117. clear, set to invert. Bit 2 is set to call the routine to read the
  118. validation string.
  119.  
  120. If a key is pressed while the inverted icon flag is set, the routine (again
  121. by means of a callback) sends a message to clear the icon, then sends the
  122. keypress character, preceded by a Ctrl-U to delete the text.
  123.  
  124. The module incorporates a self-checking routine to detect corruption by
  125. viruses.
  126.  
  127. StrongARM compatibility
  128.  
  129. The Engineering Support Application Note distributed by Acorn with the
  130. StrongARM processor states that storing the program counter to memory stores
  131. PC+8 instead of PC+12, as in the case of the ARM, and points out that the
  132. example code on page 1-107 of the PRM will not work for this reason.
  133. Unfortunately, this code had been used by versions of IClear up to v1.10,
  134. with the result that loading the module caused the machine to crash. A
  135. simple modification to a few lines of code has restored compatibility while
  136. maintaining backward compatibility with earlier ARM processors.
  137.  
  138. Incidentally, use of this module revealed that the configuration dialogue
  139. box of software PC Emulator v1.70 contained a writable icon which was
  140. created in its inverted state. Its response to a double-click is to remain
  141. black-on-white. A subsequent single click clears it to white-on-black!
  142.  
  143. Please send all comments and suggestions to:
  144.  
  145. M.P. Fox,
  146. 31 Pierson Road,
  147. Windsor,
  148. Berks. SL4 5RE