home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / basic / QBSCR20.ZIP / FTEST.BAS < prev    next >
Encoding:
BASIC Source File  |  1992-07-08  |  10.8 KB  |  241 lines

  1. ' ──────────────────────────────────────────────────────────────────────────
  2. '
  3. '                             F T E S T . B A S
  4. '
  5. '                     Copyright (c) 1992 by Tony Martin
  6. '
  7. '   This simple program demonstrates some of the special characters in the
  8. '   font DEMO.VGF.  You must have a VGA card and color VGA-capable monitor
  9. '   to run this demo.  Also, make sure the file DEMO.VGF is around.
  10. '
  11. '   You will be able to see some of the interface possibilities available
  12. '   to you using the QBSCR and Font Builder combination.  The font DEMO.VGF
  13. '   was created using the Font Builder software included with QBSCR.  It
  14. '   contains the standard character set, plus some new interface-oriented
  15. '   characters.  With these new characters, you can build such common
  16. '   interface gadgets as radio buttons, check boxes, disk (or other) icons,
  17. '   and boxes that have borders on the very edge (two types are provided
  18. '   here as examples, found in the routines Box and Box2).
  19. '
  20. '   You will also see how easy it is to remap the palette in text mode with
  21. '   the new rgbRGB% function, part of QBSCR.  Feel free to change the three
  22. '   values in the rgbRGB% calls below to change the colors displayed on the
  23. '   screen.  Make sure you look at the DEMO.VGF font using Font Builder so
  24. '   you can see how some of this was done.  Some of these interface symbols
  25. '   use two character cells to make the symbol.
  26. '
  27. '   To run this program, use the following command to load QB:
  28. '
  29. '                            QB FTEST.BAS /l QBSCR20
  30. '
  31. '   making sure the QBSCR20.QLB file is in the current directory.  The
  32. '   program will then display two boxes and some interface items to look
  33. '   at.  Once this is done, hit any key to exit.  The program doesn't
  34. '   really do anything, though it would be fairly easy to add code to
  35. '   handle the mouse clicking buttons and check boxes on and off.
  36. '
  37. ' ──────────────────────────────────────────────────────────────────────────
  38.  
  39. '$INCLUDE: 'qbscr.inc'      Comes with QBSCR.
  40. '$INCLUDE: 'qb.bi'          Comes with QuickBASIC.
  41.  
  42. DECLARE SUB Box (x1%, y1%, x2%, y2%, fg%, bg%)
  43. DECLARE SUB Box2 (x1%, y1%, x2%, y2%, fg%, bg%)
  44.  
  45.  
  46. ' ──────────────────────────────────────────────────────────────────────────
  47. '  Increase the stack space available.  YOU MUST DO THIS AS THE FIRST
  48. '  EXECUTABLE LINE OF YOUR PROGRAM IF YOU USE THE FONT ROUTINES.
  49. ' ──────────────────────────────────────────────────────────────────────────
  50. CLEAR , , 8192
  51.  
  52. ' ──────────────────────────────────────────────────────────────────────────
  53. '  Load the demo font data.
  54. ' ──────────────────────────────────────────────────────────────────────────
  55. LoadVgaTextFont "DEMO.VGF"
  56.  
  57. ' ──────────────────────────────────────────────────────────────────────────
  58. '  Give ourselves 16 background colors to play with.
  59. ' ──────────────────────────────────────────────────────────────────────────
  60. BlinkOff
  61.  
  62. ' ──────────────────────────────────────────────────────────────────────────
  63. '  Adjust the palette to suit our (your) needs.
  64. ' ──────────────────────────────────────────────────────────────────────────
  65. PALETTE 1, rgbRGB%(0, 0, 1)     ' Dark blue.
  66. PALETTE 2, rgbRGB%(3, 3, 2)     ' Almost white, but slightly yellow.
  67. PALETTE 4, rgbRGB%(3, 1, 2)     ' Hot pink, with a purple tinge.
  68. PALETTE 5, rgbRGB%(1, 0, 1)     ' Dark purple.
  69. PALETTE 6, rgbRGB%(1, 2, 3)     ' Nice medium to pale blue.
  70.  
  71. ' ──────────────────────────────────────────────────────────────────────────
  72. '  Set dark blue as color for background.
  73. ' ──────────────────────────────────────────────────────────────────────────
  74. COLOR 0, 1
  75.  
  76. ' ──────────────────────────────────────────────────────────────────────────
  77. '  Clear screen with dark blue.
  78. ' ──────────────────────────────────────────────────────────────────────────
  79. CLS
  80.  
  81. ' ──────────────────────────────────────────────────────────────────────────
  82. '  Draw a box of the first type. This is a box with borders that go all the
  83. '  way to the edge, and are two pixels wide. This will be the screen border.
  84. ' ──────────────────────────────────────────────────────────────────────────
  85. Box 1, 1, 80, 25, 2, 1
  86.  
  87. ' ──────────────────────────────────────────────────────────────────────────
  88. '  This part should be fun!  See if you can figure out what it does...
  89. ' ──────────────────────────────────────────────────────────────────────────
  90. COLOR 15, 1
  91. LOCATE 3, 5, 0
  92. PRINT STRING$(64, 216);
  93. FOR i% = 207 TO 215
  94.     PRINT CHR$(i%);
  95. NEXT i%
  96.  
  97. ' ──────────────────────────────────────────────────────────────────────────
  98. '  Some credits to demonstrate the copyright symbol.
  99. ' ──────────────────────────────────────────────────────────────────────────
  100. COLOR 15, 1
  101. Box2 24, 5, 57, 7, 15, 6
  102. LOCATE 6, 25, 0
  103. COLOR 0, 6
  104. PRINT "Copyright "; CHR$(233); " 1992 by Tony Martin";
  105.  
  106.  
  107. ' ──────────────────────────────────────────────────────────────────────────
  108. '  Draw a box of the first type. This is a box with borders that go all the
  109. '  way to the edge, and are two pixels wide. This will be the first box.
  110. ' ──────────────────────────────────────────────────────────────────────────
  111. Box 21, 9, 60, 15, 15, 4
  112.  
  113. ' ──────────────────────────────────────────────────────────────────────────
  114. '  Add some interface items, in this case, three radio buttons and three
  115. '  check boxes.
  116. ' ──────────────────────────────────────────────────────────────────────────
  117. COLOR 0, 4
  118. LOCATE 10, 26, 0: PRINT CHR$(199); CHR$(225); " Button 1    "; CHR$(197); CHR$(224); " Check Box 1";
  119. LOCATE 11, 26, 0: PRINT CHR$(201); CHR$(226); " Button 2    "; CHR$(198); CHR$(227); " Check Box 2";
  120. LOCATE 12, 26, 0: PRINT CHR$(201); CHR$(226); " Button 3    "; CHR$(197); CHR$(224); " Check Box 3";
  121.  
  122. ' ──────────────────────────────────────────────────────────────────────────
  123. '  Add three disk drive icons, two floppies and three hard disks.
  124. ' ──────────────────────────────────────────────────────────────────────────
  125. LOCATE 14, 27, 0: PRINT CHR$(204); CHR$(231); " A  "; CHR$(204); CHR$(231); " B  "; CHR$(205); CHR$(232); " C  "; CHR$(205); CHR$(232); " D  "; CHR$(205); CHR$(232); " E"
  126. COLOR 15, 0
  127. LOCATE 14, 26, 0: PRINT " "; CHR$(204); CHR$(231); " A "
  128.  
  129. ' ──────────────────────────────────────────────────────────────────────────
  130. '  Draw a box of the second type. This is a box with borders that go all the
  131. '  way to the edge, and are only one pixel wide.
  132. ' ──────────────────────────────────────────────────────────────────────────
  133. COLOR 15, 1
  134. Box2 21, 17, 61, 21, 15, 5
  135.  
  136. ' ──────────────────────────────────────────────────────────────────────────
  137. '  Add some text to the second box.
  138. ' ──────────────────────────────────────────────────────────────────────────
  139. COLOR 11, 5
  140. LOCATE 18, 22, 0: PRINT "This box can be drawn in with no top";
  141. LOCATE 19, 22, 0: PRINT "or bottom margin, but requires a left";
  142. LOCATE 20, 22, 0: PRINT "margin of 1 (1-char right to balance)";
  143.  
  144. ' ──────────────────────────────────────────────────────────────────────────
  145. '  Wait for a user keypress before we clear everything and end.
  146. ' ──────────────────────────────────────────────────────────────────────────
  147. d$ = INPUT$(1)
  148.  
  149. ' ──────────────────────────────────────────────────────────────────────────
  150. '  Reset the screen font to normal.
  151. ' ──────────────────────────────────────────────────────────────────────────
  152. LoadVgaTextFont ""
  153.  
  154. ' ──────────────────────────────────────────────────────────────────────────
  155. '  Restore normal blinking attributes.
  156. ' ──────────────────────────────────────────────────────────────────────────
  157. BlinkOn
  158.  
  159. COLOR 7, 0
  160. CLS
  161. END
  162.  
  163. SUB Box (x1%, y1%, x2%, y2%, fg%, bg%)
  164.  
  165.     ' ────────────────────────────────────────────────────────────────────────
  166.     '  This routine draws a box that has a border going all the way to the
  167.     '  edges.  The border is two pixels wide, and uses characters from the
  168.     '  DEMO.VGF font to do it.
  169.     ' ────────────────────────────────────────────────────────────────────────
  170.  
  171.     COLOR fg%, bg%
  172.  
  173.     ' ────────────────────────────────────────────────────────────────────────
  174.     '  Draw the top row of the box.
  175.     ' ────────────────────────────────────────────────────────────────────────
  176.     LOCATE y1%, x1%, 0
  177.     PRINT CHR$(218); STRING$(x2% - x1% - 1, 196); CHR$(195);
  178.  
  179.     ' ────────────────────────────────────────────────────────────────────────
  180.     '  Draw the sides and interior of the box.
  181.     ' ────────────────────────────────────────────────────────────────────────
  182.     FOR i% = y1% + 1 TO y2% - 1
  183.         LOCATE i%, x1%, 0
  184.         PRINT CHR$(179); SPACE$(x2% - x1% - 1); CHR$(194);
  185.     NEXT i%
  186.  
  187.     ' ────────────────────────────────────────────────────────────────────────
  188.     '  Draw the bottom row.
  189.     ' ────────────────────────────────────────────────────────────────────────
  190.     LOCATE y2%, x1%, 0
  191.     PRINT CHR$(192); STRING$(x2% - x1% - 1, 193); CHR$(217);
  192.  
  193. END SUB
  194.  
  195. SUB Box2 (x1%, y1%, x2%, y2%, fg%, bg%)
  196.  
  197.     ' ────────────────────────────────────────────────────────────────────────
  198.     '  This routine draws a box that has a border going all the way to the
  199.     '  edges.  The border is one pixel wide, and uses characters from the
  200.     '  DEMO.VGF font to do it.
  201.     ' ────────────────────────────────────────────────────────────────────────
  202.  
  203.     ' ────────────────────────────────────────────────────────────────────────
  204.     '  Draw the top row.  It is compose of characters that look like the
  205.     '  underscore (_) character.  The last character is different.  It is a
  206.     '  single pixel, located in the lower-left corner of the character cell.
  207.     '  It fills in a space of one pixel left by characters not lining up
  208.     '  exactly.  This is required, and you can remove the "CHR$(218);" part
  209.     ' of the PRINT statement below to see the difference without it.
  210.     ' ────────────────────────────────────────────────────────────────────────
  211.     LOCATE y1%, x1%, 0
  212.     PRINT STRING$(x2% - x1%, 203); CHR$(128);
  213.  
  214.     ' ────────────────────────────────────────────────────────────────────────
  215.     '  Print the RIGHT side of the box using a special vertical character.
  216.     ' ────────────────────────────────────────────────────────────────────────
  217.     FOR i% = y1% + 1 TO y2% - 1
  218.         LOCATE i%, x2%, 0
  219.         PRINT CHR$(228);
  220.     NEXT i%
  221.  
  222.     ' ────────────────────────────────────────────────────────────────────────
  223.     '  Display the bottom row of the box.  See the comment above about the top
  224.     '  row.  Remove the "CHR$(129);" part of the PRINT statement below to see
  225.     '  the difference in the box without this one-pixel filler character.
  226.     ' ────────────────────────────────────────────────────────────────────────
  227.     LOCATE y2%, x1%, 0
  228.     PRINT STRING$(x2% - x1%, 200); CHR$(129);
  229.  
  230.     ' ────────────────────────────────────────────────────────────────────────
  231.     '  Draw the left side and interior of the box.
  232.     ' ────────────────────────────────────────────────────────────────────────
  233.     COLOR fg%, bg%
  234.     FOR i% = y1% + 1 TO y2% - 1
  235.         LOCATE i%, x1%, 0
  236.         PRINT CHR$(228); SPACE$(x2% - x1% - 1);
  237.     NEXT i%
  238.  
  239. END SUB
  240.  
  241.