home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / extspsht.zip / EXTSPSHT / extspsht.ipf < prev    next >
Text File  |  1997-09-26  |  10KB  |  255 lines

  1. :userdoc.
  2.  
  3. :title.Extended Spreadsheet
  4.  
  5.  
  6. .*********************************************************
  7. :h1 res=99. Disclaimer
  8. :i1. Disclaimer
  9. :p.THIS SOFTWARE IS PROVIDED BY THOMAS KORFHAGE "AS IS'' AND ANY EXPRESSED
  10. OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  11. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  12. ARE DISCLAIMED. IN NO EVENT SHALL THOMAS KORFHAGE BE LIABLE FOR ANY
  13. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  14. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  15. GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  16. INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  17. IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  18. OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  19. IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  20.  
  21. .*********************************************************
  22. :h1 res=100 . Extension of VisPro Rexx Spreadsheet Object
  23. :i1. General
  24.  
  25. :p.The VisPro Rexx Spreadsheet Object is limited in the way you can start editing
  26. a field. You have to ALT+LeftClick on the field to get it into the edit state.
  27.  
  28. :p.I didn't like that to be the only way, so i searched for a way to enhance the spreadsheet control.
  29. :p.I did this first for the VisProC object. I subclassified the VPSpreadsheetClass.
  30. First i thought i had to create a complete new object with the VPTOOL kit to do the same for Rexx.
  31. Then i got the idea to try the subclassing in an external rexx-dll. I found that i seems so work.
  32. :p.But i could not use class subclassing, because there is no way in VisProRexx to make the call at the 
  33. wright time (between registration of the standard VisProSpreadSheetObject and the
  34. first creation of an instance of it, if the spreadsheet is on the first (Main) window form).
  35. :p.So i decided to use window subclassing. That's what is done if you call SbcSpsht(window, id).
  36. :p.The Spreadsheet Object (Control id on form window) will be subclassed. You can then set the desired edit style and/or let the spreadsheet perform a display optimization.
  37.  
  38. :p.This sample was build with screen resolution 1280x1024. May be it looks bad on VGA.
  39.  
  40. :p.:link reftype=hd res=999.Thomas Korfhage:elink. Sep. 1997
  41. :warning.
  42. This is the first time i tried the window subclassing in an external rexx-dll. During my test cycle (German Warp4 no FP)  i could not watch any side effects and problems. This does not mean, that i would not expect them to arise in the future.
  43. So read the :link reftype=hd res=99.Disclaimer:elink.!:ewarning.
  44.  
  45. .*********************************************************
  46. :h1 res=110. How to enable the extensions
  47. :i1. Enable the extensions
  48. :p.To get access to the extensions, you first have to register the rexx function SbcSpsht
  49. :xmp.
  50. /* Event Form events, Opened */
  51. /* Register the extension and subclass the spreadsheet */
  52. call RxFuncAdd 'SbcSpsht', 'SBCSPSHT', 'SbcSpsht'
  53. SbcSpshtRV = SbcSpsht(window, 1000);
  54. :exmp.
  55. :p.SbcSpsht must be called for every spreadsheet object after its creation. Successfully subclassing is shown by a return value of "1", "0" means subclassing could not be done.
  56.  
  57. .*********************************************************
  58. :h1 res=120. How to configure the edit style
  59. :i1. Configure the edit style
  60. :p.To set the desired edit style, a message has to be send to the control. Use the Create link "Send message 2 longs" from the spreadsheet control.
  61. :xmp.
  62. /* Set the edit style */
  63. Style = :link reftype=hd res=112.SPRS.ENTER_EDITS:elink. + :link reftype=hd res=112.SPRS.CHAR_EDITS:elink.
  64. value=VpItem(window,1000,'SENDMSG', :link reftype=hd res=112.SPRM.SET_EDTSTYLE:elink., Style, :link reftype=hd res=113.EditKey:elink.);
  65. :exmp.
  66. :p.The edit styles are non exclusive flags, so they can be added.
  67.  
  68. .*********************************************************
  69. :h1 res=130. Optimize the Display
  70. :i1. Optimize the Display
  71. :p.The extension also includes the optimizing of the Spreadsheet widths  and heights according to font in use.
  72. :p.To optimize the spreadsheet, a message has to be send to the control. Use the Create link "Send message 4 shorts" from the spreadsheet control.
  73. :parml compact break=none.
  74. :pt.Short 1
  75. :pd.Column to optimize, -1 for all, 0 for the row label column
  76. :pt.Short 2
  77. :pd.Column and/or Header, 1 for column width optimization, 2 for header height optimization, 3 for both
  78. :pt.Short 3
  79. :pd.Additional horizontal space 
  80. :pt.Short 4
  81. :pd.Additional vertical space
  82. (space for rows) * 256 + space for header
  83. :eparml.
  84. :xmp.
  85. /* Set the edit style */
  86. value=VpItem(window,1000,'SENDMSG', :link reftype=hd res=112.SPRM.OPTIMZE:elink., :link reftype=hd res=112.SPRS.OPTIMZE_ALLCOLS:elink., :link reftype=hd res=112.SPRS.OPTIMZE_BOTH:elink., '10', '10');
  87. :exmp.
  88. :p.Be sure to set the max number of cells before this call, because the text of up to all fields must be checked to find the longest.
  89. :p.If You have set the max number of cells and performed the optimization, You my size the spreadsheet to the size that displays all fields. Be sure the control will fit into your window!
  90. :xmp.
  91. /* Get item position 1000 Spreadsheet */
  92. xy=VpItem(window,1000,'ITEMPOS')
  93. PARSE VAR xy x y
  94. /* Set item position/size 1000 Spreadsheet */
  95. CALL VpItem window,1000,'SETITEMPOS',x,y,20000,20000
  96. /* Repaint item 1000 Spreadsheet */
  97. rc=VpItem(window,1000,'PAINT')
  98. :exmp.
  99.  
  100. :p.This uses the functionality build into the original Vispro Spreadsheet to reduce it's size to the maximal needed area.
  101.  
  102.  
  103. .*********************************************************
  104. :h1 res=140. Readonly Fields/Columns/Rows
  105. :i1. Readonly 
  106. :p.Any Field can be set readonly.
  107. :p.To set fields readonly, a message has to be send to the control. Use the Create link "Send message 4 shorts" from the spreadsheet control.
  108. :parml compact break=none.
  109. :pt.Short 1
  110. :pd.Column 1-n, -1 for all columns of a row
  111. :pt.Short 2
  112. :pd.Row 1-n, -1 for all of rows of a column
  113. :pt.Short 3
  114. :pd.Readonly Flag, 1 set Readonly, 0 reset Readonly
  115. :pt.Short 4
  116. :pd.Not used, should be 0
  117. :eparml.
  118. :p.Set field 1,2 readonly.
  119. :xmp.
  120. value=VpItem(window,1000,'SENDMSG', SPRM.SET_READONLY, 1, 2, 1, 0);
  121. :exmp.
  122. :p.Set row 2 readonly.
  123. :xmp.
  124. value=VpItem(window,1000,'SENDMSG', SPRM.SET_READONLY, -1, 2, 1, 0);
  125. :exmp.
  126. :p.Set coulumn 3 readonly.
  127. :xmp.
  128. value=VpItem(window,1000,'SENDMSG', SPRM.SET_READONLY, 3, -1, 1, 0);
  129. :exmp.
  130. :p.Set every field readonly.
  131. :xmp.
  132. value=VpItem(window,1000,'SENDMSG', SPRM.SET_READONLY, -1, -1, 1, 0);
  133. :exmp.
  134. :p.Reset readonly for every field.
  135. :xmp.
  136. value=VpItem(window,1000,'SENDMSG', SPRM.SET_READONLY, -1, -1, 0, 0);
  137. :exmp.
  138. :p.This functionality is limited to 1000 rows and/or 1000 columns!
  139.  
  140. .*********************************************************
  141. :h1 res=150. Change color for cell in edit mode
  142. :i1. Color in edit mode
  143. :p.The extension also includes the posibility to change the color for a cell that is in edit mode.
  144. :p.To optimize the spreadsheet, a message has to be send to the control. Use the Create link "Send message 4 longs" from the spreadsheet control.
  145. :parml compact break=none.
  146. :pt.Long 1
  147. :pd.Fore ground color, use a RGB - value
  148. :pt.Long 2
  149. :pd.Back ground color, use a RGB - value
  150. :eparml.
  151. :xmp.
  152. /* Set the edit Color to black on red */
  153. Bcolor = ((255 * 256) + 0)*256+0
  154. Fcolor = 0
  155. value=VpItem(window,1000,'SENDMSG', :link reftype=hd res=112.SPRM.SET_EF_COLORS:elink., Fcolor, Bcolor);
  156. :exmp.
  157.  
  158. .*********************************************************
  159. :h1 res=160. Enter edit mode for a cell
  160. :i1. Enter edit mode
  161. :p.The extension also includes the posibility directly start the edit mode for one cell.
  162. :p.To optimize the spreadsheet, a message has to be send to the control. Use the Create link "Send message 4 longs" from the spreadsheet control.
  163. :parml compact break=none.
  164. :pt.Long 1
  165. :pd.Column of Cell
  166. :pt.Long 2
  167. :pd.Row of CellEnter edit mode
  168. :eparml.
  169. :xmp.
  170. /* Start edit mode for cell 3,3 */
  171. value=VpItem(window,1000,'SENDMSG', :link reftype=hd res=112.SPRM.EDIT_CELL:elink., 3, 3);
  172. :exmp.
  173.  
  174. .*********************************************************
  175. :h1 res=112. Constant definitions
  176. :i1. Constant definitions
  177. :p.To make code more readable following definitions are used:
  178. :xmp.
  179. SPRM.SET_EDTSTYLE = '0x101b'
  180. SPRM.GET_EDTSTYLE = '0x101c'
  181. SPRS.ENTER_EDITS  = 256
  182. SPRS.CHAR_EDITS   = 512
  183. SPRS.EDITFULLSEL  = 1024
  184. SPRS.EDITFIXLEN   = 2048
  185. SPRS.ALLOWDELETE  = 4096
  186. SPRS.GO_LEFT      = 8192
  187. SPRS.GO_DOWN      = 16384
  188.  
  189. SPRS.VIRTUALKEY   = 65536
  190. SPRS.KEY_SHIFT    = 16777216
  191. SPRS.KEY_CTRL     = 33554432
  192. SPRS.KEY_ALT      = 67108864
  193.  
  194. SPRM.OPTIMZE      = '0x101a'
  195. SPRS.OPTIMZE_ALLCOLS   =-1
  196. SPRS.OPTIMZE_COLS      =1
  197. SPRS.OPTIMZE_HEADER    =2
  198. SPRS.OPTIMZE_ROW_HEIGHT =4
  199.  
  200. SPRM.SET_READONLY  = '0x101e'
  201. SPRM.SET_EF_COLORS = '0x101f'
  202. SPRM.EDIT_CELL     = '0x1020'
  203. :exmp.
  204.  
  205. .*********************************************************
  206. :h1 res=113. Additional Edit Key
  207. :i1. Edit Key
  208. :p.Beneath the Enterkey one other user defined key can be set to act in the same way.
  209. :p.The Key must be given as a special constant when setting the edit style.
  210.  
  211. :xmp.
  212. value = SPRS.VIRTUALKEY
  213. if shft then value = value + SPRS.KEY_SHIFT;
  214. if ctrl then value = value + SPRS.KEY_CTRL;
  215. if alt then value = value + SPRS.KEY_ALT;
  216. value = value + 33;        /* key 33 is F2 */
  217. value=VpItem(window,1000,'SENDMSG', SPRM.SET_EDTSTYLE, Style, value);
  218. :exmp.
  219.  
  220. .*********************************************************
  221. :h1 res=333. RXWAITUNTIL
  222. :i1. Funtion RXWAITUNTIL
  223.  
  224. :p.Included within the spcspsht.dll is the function RXWAITUNTIL.
  225. :p.It can be used, to suspend a the REXX programm until a specified time is reached.
  226. :p.ActualDateString = RXWAITUNTIL(h,m,s)
  227. :parml.
  228. :pt.h
  229. :pd.hour to wait for (0-23). If h is greater 23 it matches any hour.
  230. :pt.m
  231. :pd.minute to wait for (0-23). If m is greater 59 it matches any minute.
  232. :pt.s
  233. :pd.second to wait for.
  234. :eparml.
  235. :p.If RXWAITUNTIL is called w/o any parameter it will be the same than RXWAITUNTIL(99,99,0). It waits until the next minute start.
  236. .*********************************************************
  237. :h1 res=999. Contact Thomas Korfhage
  238. :i1. Contact Thomas Korfhage
  239.  
  240. :p.100271.16@compuserve.com
  241. :p.  or
  242. :p.korfhage@t-online.de
  243.  
  244. :euserdoc.
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.