home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 15 / CD_ASCQ_15_070894.iso / vrac / dnalib7a.zip / DIALOG.BAS < prev    next >
BASIC Source File  |  1994-05-16  |  3KB  |  120 lines

  1. DECLARE SUB PopWind(Title$,TopRow%,LeftColumn%,BottomRow%,RightColumn%,Attr%,Shadow%,Border%)
  2. DECLARE SUB SaveScreen(ScreenID$,TopRow%,LeftColumn%,BottomRow%,RightColumn%,Shadow%)
  3. DECLARE SUB RestoreScreen(ScreenID$,TopRow%,LeftColumn%)
  4. DECLARE SUB CalcByte(Attr%,LowByte%,HiByte%)
  5. DECLARE SUB Clicked(Rgt%,Lft%,Row%,Col%)
  6. DECLARE SUB HideCursor()
  7. DECLARE SUB ShowCursor()
  8. DECLARE FUNCTION LeftButtonReleased%()
  9.  
  10. SUB Dialog(Choices$(),Title$,Seconds%,Mouse%,Cntr%,TopRow%,LeftColumn%,TxtColor%,Attr%,Shadow%,Border%) PUBLIC
  11.  
  12. $CODE SEG "DNASEG1"
  13.  
  14. CalcByte Attr%,FGround%,BGround%
  15.  
  16. IF Mouse% THEN HideCursor
  17. i% = 0: j% = 0: Maxlength% = 0: AddedRow% = 0
  18.  
  19. DO
  20.  
  21. INCR i%
  22. INCR j%                                 'first find out how many
  23.                                                                                         'strings there are and the
  24. IF LEN (Choices$(i%)) = 0 THEN          'length of the longest one
  25.   DECR i%
  26. ELSEIF LEN (Choices$(i%)) > Maxlength% THEN
  27.   Maxlength% = LEN (Choices$(i%))
  28. END IF
  29.  
  30. LOOP WHILE i% = j%
  31.  
  32. Count% = i%
  33.  
  34. INCR Maxlength%                     'add a space
  35.  
  36. SELECT CASE Cntr%
  37.     CASE 1                      'centre the window
  38.       Centre% = 1
  39.     CASE 2                      'centre the text
  40.       CentreText% = 1
  41.     CASE 3                      'centre both text and window
  42.       Centre% = 1
  43.       CentreText% = 1
  44. END SELECT
  45.  
  46. IF Centre% = 1 THEN                            'do they want it centred
  47.   LeftColumn% = 40 - ((Maxlength% + 2) / 2)
  48.   RightColumn% = LeftColumn% + (Maxlength% + 2)
  49.   TopRow% = (25 - Count%) \ 2
  50.   BottomRow% = TopRow% + (Count% + 1)
  51. ELSE
  52.   RightColumn% = LeftColumn% + (Maxlength% + 2)
  53.   BottomRow% = TopRow% + (Count% + 1)
  54. END IF
  55.  
  56. SaveScreen DLog$,TopRow%,LeftColumn%,BottomRow%,RightColumn%,Shadow%
  57.  
  58. PopWind Title$,TopRow%,LeftColumn%,BottomRow%,RightColumn%,Attr%,Shadow%,Border%
  59.  
  60. IF Mouse% AND ISFALSE Seconds% THEN
  61.   Test% = LEN(Title$)
  62.   COLOR FGround%,BGround%
  63.   IF Test% THEN
  64.     IF Test% + 16 <= RightColumn% - LeftColumn% THEN
  65.       LOCATE TopRow%,LeftColumn% + 1,0
  66.       PRINT CHR$(91,254,93);
  67.     ELSE
  68.       LOCATE BottomRow%,LeftColumn% + 1,0
  69.       PRINT CHR$(91,254,93);
  70.     END IF
  71.   ELSE
  72.     LOCATE TopRow%,LeftColumn% + 1,0
  73.     PRINT CHR$(91,254,93);
  74.   END IF
  75. END IF
  76.  
  77. Row% = TopRow% + 1
  78. Col% = LeftColumn% + 1
  79.  
  80. FOR a% = 1 TO Count%
  81.   COLOR TxtColor%,BGround%
  82.   LOCATE Row%,Col%,0
  83.   IF CentreText% = 1 THEN
  84.     b% = (Maxlength% + 1) - LEN(Choices$(a%))
  85.     c% = b% \ 2
  86.     d% = b% - c%
  87.     PRINT SPACE$(c%) + Choices$(a%) + SPACE$(d%)
  88.   ELSE
  89.     PRINT SPACE$(1) + Choices$(a%) + SPACE$(Maxlength% - LEN(Choices$(a%)))
  90.   END IF
  91.   INCR Row%
  92. NEXT a%
  93.  
  94. IF Seconds% THEN DELAY Seconds%: GOTO Wayout
  95.  
  96. WHILE NOT INSTAT
  97.   IF Mouse% THEN
  98.     ShowCursor
  99.     Clicked Rgt%,Lft%,MRow%,MCol%
  100.     IF LeftButtonReleased% THEN
  101.       IF MCol% = LeftColumn% + 2 THEN
  102.         IF MRow% = TopRow% OR MRow% = BottomRow% THEN
  103.           EXIT LOOP
  104.         END IF
  105.       ELSEIF MRow% < TopRow% OR MRow% > BottomRow% OR_
  106.         MCol% < LeftColumn% OR MCol% > RightColumn% THEN
  107.         EXIT LOOP
  108.       END IF
  109.     END IF
  110.   END IF
  111. WEND
  112. Ky$ = INKEY$
  113.  
  114. Wayout:
  115.  
  116. IF Mouse% THEN HideCursor
  117.  
  118. RestoreScreen Dlog$,TopRow%,LeftColumn%
  119.  
  120. END SUB