/* An example of using the dissidents rx_intui.library */

wind=GetWindow('Gadgets',,,,,,,,)
IF wind == '' | wind == 0 THEN SAY 'Window open error'
err = SetDraw(wind,2,,0)

/* Add a Bool gadget with RELVERIFY and ID = 0. Set Flags to 128 (ISSUE_CLOSE)   */
/* When the user clicks on this, WaitMsg() will return the GADGET event for this */
/* gadget. Then, a second call to WaitMsg() will return CLOSEWINDOW event (with  */
/* state=CANCEL because we didn't set the OK flag). */
gadg1=AddGadg(wind,1,'BOOL',20,100,61,16,1,0,128)
IF gadg1 == '' | gadg1 == 0 THEN Text('Gadg allocation Error',wind,5,12)

/* Add a String gadget with RELVERIFY and ID = 1. Also note MaxChars parameter. */
/* Finally, note that we set the AUTOSELECT flag */
maxchars=30
gadg2=AddGadg(wind,4,'Type',150,100,150,12,1,1,2,maxchars)
IF gadg2 == '' | gadg2 == 0 THEN Text('Gadg allocation Error',wind,5,12)

/* Initialize the string buffer to 'This is my string' */
gadg=ModGadg(wind,gadg2,,,,'This is my string.',,,,,)

/* Add another String gadget with AUTOSELECT. This means that after the user   */
/* hits RETURN on the other string gadget, this one is automatically selected. */
gadg3=AddGadg(wind,4,'Type2',150,115,150,12,1,2,2,maxchars)
IF gadg3 == '' | gadg3 == 0 THEN Text('Gadg allocation Error',wind,5,12)

/* Add a Prop gadget with RELVERIFY, IMMEDIATE, and ID = 3. Set extra (pot   */
/* range) to 128. This means that I'll get values between 0 to 127. When the */
/* user brings the knob all the way to the left, I get 0. All the way to the */
/* right = 127. Note that I set the IDCMP to PRINTPROP. This "steals" the    */
/* GADGETDOWN (IMMEDIATE) and uses it to start printing the value of the     */
/* knob step. Note that I didn't ask for GIMME_MOVE or NO_COLLECT when I opened */
/* the window. Note that whenever my IDCMP loop gets a GADGET class with     */
/* ID = 3, this means that the user played with this prop, and as a result   */
/* my PenA, PenB will be set to the same as the gadget Text, and DrawMode to */
/* JAM2. */
gadg4=AddGadg(wind,3,'Move me',150,85,150,12,11,3,4,128)
IF gadg4 == '' | gadg4 == 0 THEN Text('Gadg allocation Error',wind,5,12)

/* Set Prop knob position to 64. Note that I don't bother passing pens and mode */
gadg=ModGadg(wind,gadg4,,,,64,,)

/* Note that if we added more string gadgets with AUTOSELECT, they would select   */
/* each other, but wouldn't be selected by the previous 2 strings. That's because */
/* we added that PROP gadget inbetween. */

/* Change to JAM2 for printing out the IDCMPspec */
err=SetDraw(wind,3,,1)

/* Loop until CLOSEWINDOW, printing out all IDCMPspecs in the upper left corner */
/* Observe the printout as you select and use gadgets and click the mouse. */
class = 1
DO WHILE class > 0
spec=WaitMsg(wind)
PARSE var spec class part1 part2 part3
/* Check if the user played with my prop. If so, I've got to restore my pens */
IF class == 1 THEN DO
IF part1 == 3 THEN err=SetDraw(wind,3,,)
END
err=Erase(60,wind,5,20)
err=Text(spec,wind,5,20)
END

err=EndWindow(wind)
