home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / dirs / rexxintuition_463.lzh / RexxIntuition / RexxIntui.lzh / scripts / Gadg.rexx < prev    next >
OS/2 REXX Batch file  |  1990-06-27  |  3KB  |  66 lines

  1. /* An example of using the dissidents rx_intui.library */
  2.  
  3. wind=GetWindow('Gadgets',,,,,,,,)
  4. IF wind == '' | wind == 0 THEN SAY 'Window open error'
  5. err = SetDraw(wind,2,,0)
  6.  
  7. /* Add a Bool gadget with RELVERIFY and ID = 0. Set Flags to 128 (ISSUE_CLOSE)   */
  8. /* When the user clicks on this, WaitMsg() will return the GADGET event for this */
  9. /* gadget. Then, a second call to WaitMsg() will return CLOSEWINDOW event (with  */
  10. /* state=CANCEL because we didn't set the OK flag). */
  11. gadg1=AddGadg(wind,1,'BOOL',20,100,61,16,1,0,128)
  12. IF gadg1 == '' | gadg1 == 0 THEN Text('Gadg allocation Error',wind,5,12)
  13.  
  14. /* Add a String gadget with RELVERIFY and ID = 1. Also note MaxChars parameter. */
  15. /* Finally, note that we set the AUTOSELECT flag */
  16. maxchars=30
  17. gadg2=AddGadg(wind,4,'Type',150,100,150,12,1,1,2,maxchars)
  18. IF gadg2 == '' | gadg2 == 0 THEN Text('Gadg allocation Error',wind,5,12)
  19.  
  20. /* Initialize the string buffer to 'This is my string' */
  21. gadg=ModGadg(wind,gadg2,,,,'This is my string.',,,,,)
  22.  
  23. /* Add another String gadget with AUTOSELECT. This means that after the user   */
  24. /* hits RETURN on the other string gadget, this one is automatically selected. */
  25. gadg3=AddGadg(wind,4,'Type2',150,115,150,12,1,2,2,maxchars)
  26. IF gadg3 == '' | gadg3 == 0 THEN Text('Gadg allocation Error',wind,5,12)
  27.  
  28. /* Add a Prop gadget with RELVERIFY, IMMEDIATE, and ID = 3. Set extra (pot   */
  29. /* range) to 128. This means that I'll get values between 0 to 127. When the */
  30. /* user brings the knob all the way to the left, I get 0. All the way to the */
  31. /* right = 127. Note that I set the IDCMP to PRINTPROP. This "steals" the    */
  32. /* GADGETDOWN (IMMEDIATE) and uses it to start printing the value of the     */
  33. /* knob step. Note that I didn't ask for GIMME_MOVE or NO_COLLECT when I opened */
  34. /* the window. Note that whenever my IDCMP loop gets a GADGET class with     */
  35. /* ID = 3, this means that the user played with this prop, and as a result   */
  36. /* my PenA, PenB will be set to the same as the gadget Text, and DrawMode to */
  37. /* JAM2. */
  38. gadg4=AddGadg(wind,3,'Move me',150,85,150,12,11,3,4,128)
  39. IF gadg4 == '' | gadg4 == 0 THEN Text('Gadg allocation Error',wind,5,12)
  40.  
  41. /* Set Prop knob position to 64. Note that I don't bother passing pens and mode */
  42. gadg=ModGadg(wind,gadg4,,,,64,,)
  43.  
  44. /* Note that if we added more string gadgets with AUTOSELECT, they would select   */
  45. /* each other, but wouldn't be selected by the previous 2 strings. That's because */
  46. /* we added that PROP gadget inbetween. */
  47.  
  48. /* Change to JAM2 for printing out the IDCMPspec */
  49. err=SetDraw(wind,3,,1)
  50.  
  51. /* Loop until CLOSEWINDOW, printing out all IDCMPspecs in the upper left corner */
  52. /* Observe the printout as you select and use gadgets and click the mouse. */
  53. class = 1
  54. DO WHILE class > 0
  55. spec=WaitMsg(wind)
  56. PARSE var spec class part1 part2 part3
  57. /* Check if the user played with my prop. If so, I've got to restore my pens */
  58. IF class == 1 THEN DO
  59. IF part1 == 3 THEN err=SetDraw(wind,3,,)
  60. END
  61. err=Erase(60,wind,5,20)
  62. err=Text(spec,wind,5,20)
  63. END
  64.  
  65. err=EndWindow(wind)
  66.