home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / sphigs / sph_dos.lha / dos / srgpdemo / testrubb.c < prev   
Encoding:
C/C++ Source or Header  |  1991-11-26  |  1.5 KB  |  53 lines

  1. #include "srgp.h"
  2. #include <stdio.h>
  3.  
  4. /* TEST OF LOCATOR DEVICE RUBBER LINE ECHO MODE */
  5.  
  6. /* Also tests the keyboard in raw mode. */
  7.  
  8. /* A left button press adds the new point to the polyline.
  9.    A right button press sets a new anchor point.
  10.    A middle button press is never seen (masked out).
  11.    Hitting 'Q' at any time should cause the application to exit.
  12.    */
  13.  
  14. main()
  15. {
  16.    locator_measure locmeasure, pastlocmeasure;
  17.    char keymeasure[81];
  18.    int whichdev;
  19.  
  20.  
  21.    SRGP_begin ("Test of rubber echo", SCREEN_WIDTH, SCREEN_HEIGHT, 1, FALSE);
  22.  
  23.    SRGP_setLocatorEchoType(CURSOR);
  24.    SRGP_setLocatorButtonMask(LEFT_BUTTON_MASK | RIGHT_BUTTON_MASK);
  25.    pastlocmeasure.position = SRGP_defPoint(5,5);
  26.    SRGP_setLocatorMeasure(pastlocmeasure.position);
  27.    SRGP_setKeyboardProcessingMode (RAW);
  28.    SRGP_setInputMode(LOCATOR, EVENT);   
  29.    SRGP_setInputMode(KEYBOARD, EVENT);
  30.    SRGP_setLocatorEchoRubberAnchor(pastlocmeasure.position);
  31.    SRGP_setLocatorEchoType (RUBBER_LINE);
  32.    SRGP_setLineStyle(DASHED);
  33.  
  34.    while (1) {
  35.       whichdev = SRGP_waitEvent(INDEFINITE);
  36.       if (whichdev == KEYBOARD) {
  37.         SRGP_getKeyboard(keymeasure,80);
  38.         if (keymeasure[0] == 'Q') break;
  39.       }
  40.       else {
  41.          SRGP_getLocator(&locmeasure);
  42.          SRGP_setLocatorEchoRubberAnchor(locmeasure.position);
  43.          if (locmeasure.button_of_last_transition == LEFT_BUTTON)
  44.             SRGP_line(pastlocmeasure.position, locmeasure.position);
  45.          SRGP_beep();
  46.          pastlocmeasure = locmeasure;
  47.          /* Swallow the UP event. */
  48.          while(LOCATOR!=SRGP_waitEvent(INDEFINITE));
  49.       }
  50.    }
  51.    SRGP_end();
  52. }
  53.