home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / basic / tools / codeit / demow1.bas < prev    next >
BASIC Source File  |  1992-05-27  |  11KB  |  317 lines

  1. '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2. 'DEMOW1.BAS Copyright (C) 1991-1992, Clear Software. ALL RIGHTS RESERVED.
  3. '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  4.  
  5. '$INCLUDE: 'CITOOLS.BI'
  6. '$INCLUDE: 'CIWIND1.BI'
  7. '$INCLUDE: 'CIMOUSE.BI'
  8.  
  9. '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  10.  
  11. DEFINT A-Z
  12.  
  13. '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  14.  
  15. CONST TRUE = -1, FALSE = 0
  16.  
  17. '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  18.  
  19. '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  20. 'Inititalize the mouse and paint the background.
  21. '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  22.  
  23.     MouseInit
  24.  
  25.     CLS
  26.     COLOR 15, 7
  27.     ScreenPaint 2, 79, 2, 22, ""
  28.     DrawBox 1, 80, 1, 23, 2
  29.  
  30. '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  31. 'Define the window.
  32. '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  33.     
  34.     WindowDefine 1, 20, 60, 6, 16, "Button/Edit Field", 0, 2
  35.     WindowColors 7, 1, 7, 1, 15, 1, 1, 3
  36.     
  37. '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  38. 'Show the window.
  39. '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  40.                    
  41.     WindowOn 1
  42.  
  43. '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  44. 'Put the buttons and edit fields on the window.
  45. '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  46.  
  47.     ButtonDefine 1, 1, 1, 2, 3, " Who ", 3
  48.     ButtonDefine 1, 2, 0, 2, 10, " What ", 3
  49.     ButtonDefine 1, 3, 0, 2, 18, " When ", 3
  50.     ButtonDefine 1, 4, 0, 2, 26, " Exit ", 3
  51.  
  52.     ButtonDefine 1, 5, 1, 4, 6, "Button 4", 2
  53.     ButtonDefine 1, 6, 0, 4, 23, "Button 5", 2
  54.  
  55.     ButtonDefine 1, 7, 1, 7, 3, " Where       ", 5
  56.     ButtonDefine 1, 8, 0, 8, 3, " Why         ", 5
  57.     ButtonDefine 1, 9, 0, 9, 3, " How         ", 5
  58.  
  59.     EditFieldColors 7, 0
  60.  
  61.     EditFieldDefine 1, 10, "", 7, 19, 12, 20, "Fld 1:", 1
  62.     EditFieldDefine 1, 11, "", 9, 19, 12, 11, "Fld 2:", 2
  63.  
  64. '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  65. 'Define the CTRL A through CTRL D as a keypress to look for. When these keys
  66. 'are pressed the program shows the keypress at the top left of the screen.
  67. '(See 31 - 34 in the window loop below)
  68. '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  69.  
  70.     WindowCtrlKey 1, "a"
  71.     WindowCtrlKey 2, "b"
  72.     WindowCtrlKey 3, "c"
  73.     WindowCtrlKey 4, "d"
  74.                                      
  75. '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  76. 'Draw the lines and the box in the window.
  77. '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  78.  
  79.     WindowDrawLine 1, 3, "─"
  80.     WindowDrawLine 1, 5, "─"
  81.     WindowDrawBox 1, 2, 16, 6, 10, 2
  82.     
  83. '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  84. 'Place the cursor on the first item when the window is made active. Also
  85. 'set cursor for the group buttons when one of the groups is selected.
  86. '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  87.  
  88.     item = 1
  89.  
  90.     curGp1 = 1
  91.     curGp2 = 5
  92.     curGp3 = 7
  93.     
  94.  
  95. '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  96. 'Show the mouse and enter the window loop. The first select case determines
  97. 'which item is current and prints the correct description line for it.
  98. '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  99.  
  100.     WDONE = FALSE
  101.     MouseShow
  102.  
  103.     WHILE NOT WDONE
  104.  
  105.         MouseHide
  106.         COLOR 0, 7
  107.         LOCATE 23, 2: PRINT SPACE$(78)
  108.         SELECT CASE item
  109.             CASE 1, 2, 3, 4
  110.                 LOCATE 23, 2
  111.                 PRINT " <ARROW=Next Item>   <TAB=Next Button Set>   <ENTER=Accept>   <ESCAPE=Exit>"; ""
  112.                
  113.             CASE 5
  114.                 LOCATE 23, 2
  115.                 PRINT " <SPACE BAR=Toggle Button>    <TAB=Next Button>    <ESCAPE=Exit>"; ""
  116.                
  117.             CASE 6
  118.                 LOCATE 23, 2
  119.                 PRINT " <SPACE BAR=Toggle Button>    <TAB=Next Button Set>    <ESCAPE=Exit>"; ""
  120.                
  121.             CASE 7, 8, 9
  122.                 LOCATE 23, 2
  123.                 PRINT " <ARROW=Next Item>    <TAB=Go To Edit Field 1>    <ESCAPE=Exit>"; ""
  124.                
  125.             CASE 10
  126.                 LOCATE 23, 2
  127.                 PRINT " <TAB=Go To Edit Field 2>    <ESCAPE=Exit>"
  128.  
  129.             CASE 11
  130.                 LOCATE 23, 2
  131.                 PRINT " <TAB=Next Button Set>    <ESCAPE=Exit>"
  132.  
  133.         END SELECT
  134.  
  135.         MouseShow
  136. '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  137. 'Make the window active. When a key or mouse button is pressed find out which
  138. 'one.
  139. '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  140.  
  141.         WindowActive item
  142.  
  143.         SELECT CASE WindowEvent(0)              'Find out what took place.
  144.  
  145.             CASE 1                              'A mouse event took place so
  146.                 SELECT CASE WindowEvent(1)      'find out on which button or
  147.                     CASE 4                      'edit field.
  148.                         WDONE = TRUE
  149.  
  150.                     CASE 1, 2, 3
  151.                         item = WindowEvent(1)
  152.                         curGp1 = item
  153.  
  154.                     CASE 7, 8, 9
  155.                         ButtonToggle curGp3
  156.                         item = WindowEvent(1)
  157.                         curGp3 = item
  158.                         ButtonToggle curGp3
  159.  
  160.                     CASE 10, 11
  161.                         item = WindowEvent(1)
  162.                         
  163.                     CASE 5, 6
  164.                         ButtonToggle curGp2
  165.                         curGp2 = WindowEvent(1)
  166.                         ButtonToggle curGp2
  167.                         item = curGp2
  168.                         
  169.                 END SELECT
  170.  
  171.              CASE 2                             'A key was pressed so find out
  172.                 SELECT CASE WindowEvent(2)      'which key and what button or
  173.                     CASE 1                      'edit field th cursor was on.
  174.                         SELECT CASE item
  175.                             CASE 4
  176.                                 WDONE = TRUE
  177.                         END SELECT
  178.  
  179.                     CASE 2
  180.                         WDONE = TRUE
  181.  
  182.                     CASE 3
  183.                         SELECT CASE item
  184.                             CASE 1, 2, 3
  185.                                 item = 5
  186.                             
  187.                             CASE 4
  188.                                 ButtonToggle item
  189.                                 item = 5
  190.                                 ButtonToggle 1
  191.                                 curGp1 = 1
  192.  
  193.                             CASE 5
  194.                                item = item + 1
  195.  
  196.                             CASE 6
  197.                                 item = curGp3
  198.  
  199.                             CASE 7, 8, 9
  200.                                 curGp3 = item
  201.                                 item = 10
  202.                                 
  203.  
  204.                             CASE 10
  205.                                 item = item + 1
  206.  
  207.                             CASE 11
  208.                                 item = curGp1
  209.  
  210.                         END SELECT
  211.                      
  212.                      CASE 5
  213.                         SELECT CASE item
  214.                             CASE 7, 8, 9
  215.                                 ButtonToggle item
  216.                                 item = item - 1
  217.                                 IF item < 7 THEN
  218.                                     item = 9
  219.                                 END IF
  220.                                 ButtonToggle item
  221.                                 curGp3 = item
  222.                         END SELECT
  223.  
  224.                      CASE 6
  225.                         SELECT CASE item
  226.                             CASE 7, 8, 9
  227.                                 ButtonToggle item
  228.                                 item = item + 1
  229.                                 IF item > 9 THEN
  230.                                     item = 7
  231.                                 END IF
  232.                                 ButtonToggle item
  233.                                 curGp3 = item
  234.                         END SELECT
  235.  
  236.  
  237.                      CASE 7
  238.                         SELECT CASE item
  239.                             CASE 5, 6
  240.                                 ButtonToggle item
  241.                         END SELECT
  242.  
  243.  
  244.                      CASE 8
  245.  
  246.                         SELECT CASE item
  247.                             CASE 1, 2, 3, 4
  248.                                 ButtonToggle item
  249.                                 item = item - 1
  250.                                 IF item < 1 THEN
  251.                                     item = 4
  252.                                 END IF
  253.                                 ButtonToggle item
  254.                                 curGp1 = item
  255.                         END SELECT
  256.  
  257.                      CASE 9
  258.                         SELECT CASE item
  259.                             CASE 1, 2, 3, 4
  260.                                 ButtonToggle item
  261.                                 item = item + 1
  262.                                 IF item > 4 THEN
  263.                                     item = 1
  264.                                 END IF
  265.                                 ButtonToggle item
  266.                                 curGp1 = item
  267.                          END SELECT
  268.  
  269. '----Page up and Page down key actions
  270. '                      │
  271. '                      
  272.  
  273.                      CASE 23        'Page up
  274.                         item = 1
  275.                         curGp1 = item
  276.  
  277.                      CASE 24        'Page down
  278.                         item = 11
  279.                        
  280.  
  281. '----CTRL key actions ─┐
  282. '                      
  283.  
  284.                     CASE 31
  285.                         COLOR 15, 2
  286.                         LOCATE 1, 1: PRINT "CTRL A"
  287.                        
  288.                     CASE 32
  289.                         COLOR 15, 3
  290.                         LOCATE 1, 1: PRINT "CTRL B"
  291.                       
  292.                     CASE 33
  293.                         COLOR 15, 4
  294.                         LOCATE 1, 1: PRINT "CTRL C"
  295.                       
  296.                     CASE 34
  297.                         COLOR 15, 5
  298.                         LOCATE 1, 1: PRINT "CTRL D"
  299.  
  300.  
  301.                  END SELECT
  302.  
  303.        END SELECT
  304.     WEND
  305.  
  306.  
  307. '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  308. 'The user chose to exit so hide the mouse and clean up the screen.
  309. '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  310.  
  311.     MouseHide
  312.  
  313.     COLOR 7, 0
  314.     CLS
  315.     END
  316.  
  317.