home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / QBAS / QBNWS204.ZIP / WINDOWS.ZIP / WINDEM.BAS < prev    next >
BASIC Source File  |  1991-07-15  |  12KB  |  264 lines

  1. ' WINDEM.BAS    popup window demonstration program
  2. '
  3. '   Author:     Christy Gemmell
  4. '   For:        QuickBASIC Newsletter
  5. '   Date:       15/7/1991
  6. '
  7. '   $DYNAMIC
  8. '
  9. '   External functions and procedures in ASSEMBLY.LIB/QLB.
  10. '
  11.     DECLARE FUNCTION Attribute% (BYVAL Fore%, BYVAL Back%)
  12.     DECLARE SUB Explode (BYVAL Y1%, BYVAL X1%, BYVAL Y2%, BYVAL X2%,_
  13.                          BYVAL Attr%, BYVAL Speed%)
  14.     DECLARE SUB FastPrint (BYVAL Row%, BYVAL Col%, Message$, BYVAL Attr%)
  15.     DECLARE SUB PopUp (BYVAL Row%, BYVAL Col%, BYVAL Hght%, BYVAL Wdth%,_
  16.                        BYVAL Attr%, BYVAL Brdr%, BYVAL Shdw%, BYVAL Zoom%)
  17.     DECLARE SUB ShutUp (BYVAL Speed%)
  18.  
  19. '   Local functions and procedures included in this module.
  20. '
  21.     DECLARE FUNCTION Randy% (Lowest%, Highest%)
  22.     DECLARE SUB FlushKey ()
  23.  
  24.     RANDOMIZE TIMER
  25.  
  26. '   Draw title and screen background.
  27. '
  28.     CLS : LOCATE , , 0: FastPrint 1, 1, SPACE$(80), 31
  29.     FastPrint 1, 27, "POPUP WINDOW DEMONSTRATION", 31
  30.     FastPrint 2, 1, STRING$(80, "─"), 31
  31.     A$ = STRING$(1760, "░"): FastPrint 3, 1, A$, 30
  32.     FastPrint 25, 1, SPACE$(80), 48: A$ = ""
  33.  
  34. '   Overture - pop up and close three batches of windows.
  35. '
  36.     FOR M% = 1 TO 3
  37.         Area% = 0: O% = 0: B% = 1
  38.         DO
  39.             H% = Randy%(5, 10): W% = Randy%(14, 40)
  40.             Area% = Area% + (H% + 1) * (W% + 1)
  41.             IF Area% > 7200 THEN EXIT DO
  42.             K% = Randy%(4, 24 - H%): J% = Randy%(1, 79 - W%)
  43.             R% = Randy%(1, 4): S% = Randy%(1, 4)
  44.             Attrib% = Attribute%(15, B%)
  45.             PopUp K%, J%, H%, W%, Attrib%, R%, S%, -1
  46.             FastPrint K%, J% + ((W% \ 2) - 5), "[ WINDOW ]", Attrib%
  47.             O% = O% + 1: B% = B% + 1: IF B% > 6 THEN B% = 1
  48.          LOOP UNTIL O% = 30
  49.          IF (M% = 3) THEN SLEEP 3 ELSE SLEEP 1
  50.          FOR I% = O% TO 1 STEP -1
  51.              ShutUp -1
  52.          NEXT I%
  53.     NEXT M%
  54.  
  55. '   Introduction - tell 'em what it's all about.
  56. '
  57.     PopUp 4, 15, 10, 30, 52, 4, 1, -1: PopUp 3, 36, 13, 40, 47, 3, 1, -1
  58.     PopUp 9, 10, 13, 40, 31, 2, 1, -1: PopUp 12, 42, 11, 36, 67, 1, 1, -1
  59.     PopUp 2, 31, 5, 20, 78, 2, 1, -1: FastPrint 4, 34, "Presenting ...", 78
  60.     SLEEP 3: FlushKey: Attrib% = Attribute%(0, 7)
  61.     PopUp 8, 20, 7, 40, Attrib%, 2, 1, -1
  62.     FastPrint 8, 31, "[ QUICK  WINDOWS ]", Attrib%
  63.     FastPrint 10, 29, "Windowing Routines for", Attrib%
  64.     FastPrint 11, 30, "Microsoft QuickBASIC", Attrib%
  65.     SLEEP 3: FlushKey: Attrib% = Attribute%(0, 3)
  66.     PopUp 17, 55, 7, 24, Attrib%, 1, 3, -1
  67.     FastPrint 19, 66, "By", Attrib%
  68.     FastPrint 20, 59, "Christy  Gemmell", Attrib%
  69.     SLEEP 3: FlushKey: Attrib% = Attribute%(14, 1)
  70.     PopUp 13, 2, 10, 23, Attrib%, 2, 4, 0
  71.     FastPrint 15, 4, "A Library of screen", Attrib%
  72.     FastPrint 16, 4, "handling procedures", Attrib%
  73.     FastPrint 17, 4, "and functions which", Attrib%
  74.     FastPrint 18, 4, "can be incorporated", Attrib%
  75.     FastPrint 19, 4, "in your QuickBASIC", Attrib%
  76.     FastPrint 20, 9, "programs.", Attrib%
  77.     SLEEP 4: FlushKey: Attrib% = Attribute%(15, 1)
  78.     PopUp 16, 27, 5, 26, Attrib%, 2, 1, 0
  79.     FastPrint 18, 30, "HOLD ONTO YOUR HATS", Attrib%
  80.     SLEEP 2: FlushKey: FOR I% = 1 TO 9: ShutUp -1: NEXT
  81.  
  82. '   Start simple - show a plain unadorned window.
  83. '
  84.     Attrib% = 112: PopUp 9, 16, 8, 50, Attrib%, 2, 2, 0: RESTORE
  85.     FOR I% = 10 TO 15: READ Me$: FastPrint I%, 19, Me$, Attrib%: NEXT
  86.     SLEEP 6: FlushKey: Explode 10, 17, 15, 64, Attrib%, 0
  87.     FOR I% = 12 TO 13: READ Me$: FastPrint I%, 19, Me$, Attrib%: NEXT
  88.     SLEEP 5: FlushKey: PopUp 5, 5, 6, 35, Attribute%(1, 2), 0, 1, -1
  89.     SLEEP 3: FlushKey: ShutUp -1: Explode 10, 17, 15, 64, 112, 0
  90.     FOR I% = 12 TO 13: READ Me$: FastPrint I%, 19, Me$, 112: NEXT
  91.  
  92. '   Demonstrate the full set of border styles.
  93. '
  94.     SLEEP 6: FlushKey: Attrib% = Attribute%(15, 6)
  95.     PopUp 6, 5, 8, 35, Attrib%, 0, 2, -1
  96.     FastPrint 6, 15, "[  No  Frame  ]", Attrib%
  97.     SLEEP 1: FlushKey: Attrib% = Attribute%(11, 1)
  98.     PopUp 7, 8, 8, 35, Attrib%, 1, 2, -1
  99.     FastPrint 7, 17, "[ Frame Style 1 ]", Attrib%
  100.     SLEEP 1: FlushKey: Attrib% = Attribute%(0, 2)
  101.     PopUp 8, 11, 8, 35, Attrib%, 2, 2, -1
  102.     FastPrint 8, 20, "[ Frame Style 2 ]", Attrib%
  103.     SLEEP 1: FlushKey: Attrib% = Attribute%(0, 3)
  104.     PopUp 9, 14, 8, 35, Attrib%, 3, 2, -1
  105.     FastPrint 9, 23, "[ Frame Style 3 ]", Attrib%
  106.     SLEEP 1: FlushKey: Attrib% = Attribute%(14, 4)
  107.     PopUp 10, 17, 8, 35, Attrib%, 4, 2, -1
  108.     FastPrint 10, 26, "[ Frame Style 4 ]", Attrib%
  109.     SLEEP 1: FlushKey: Attrib% = Attribute%(12, 5)
  110.     PopUp 11, 20, 8, 35, Attrib%, 5, 2, -1
  111.     FastPrint 11, 29, "[ Frame Style 5 ]", Attrib%
  112.     SLEEP 1: FlushKey: Attrib% = Attribute%(13, 6)
  113.     PopUp 12, 23, 8, 35, Attrib%, 6, 2, -1
  114.     FastPrint 12, 32, "[ Frame Style 6 ]", Attrib%
  115.     SLEEP 1: FlushKey: Attrib% = Attribute%(15, 2)
  116.     PopUp 13, 26, 8, 35, Attrib%, 7, 2, -1
  117.     FastPrint 13, 35, "[ Frame Style 7 ]", Attrib%
  118.     SLEEP 1: FlushKey: Attrib% = Attribute%(1, 3)
  119.     PopUp 14, 29, 8, 35, Attrib%, 8, 2, -1
  120.     FastPrint 14, 39, "[ Frame Style 8 ]", Attrib%
  121.     SLEEP 4: FlushKey: FOR I% = 1 TO 9: ShutUp -1: NEXT
  122.  
  123. '   Display the range of foreground colours
  124.     Explode 10, 17, 15, 64, 112, 0
  125.     FOR I% = 11 TO 13: READ Me$: FastPrint I%, 20, Me$, 112: NEXT
  126.     SLEEP 6: FlushKey
  127.     FOR I% = 1 TO 15
  128.         Label$ = "[ Colour:" + STR$(I%) + " ]"
  129.         J% = Randy%(1, 51): K% = Randy%(1, 13)
  130.         Attrib% = Attribute%(I%, 0)
  131.         PopUp K% + 1, J% + 1, 7, 24, Attrib%, 4, 0, 0
  132.         FastPrint K% + 1, J% + 6, Label$, Attrib%
  133.         SLEEP 1: FlushKey
  134.     NEXT I%
  135.     Attrib% = Attribute%(31, 1)
  136.     PopUp 7, 20, 7, 24, Attrib%, 4, 2, 0
  137.     FastPrint 7, 25, "[ Colour: 31 ]", Attrib%
  138.     SLEEP 4: FlushKey: FOR I% = 1 TO 16: ShutUp 0: NEXT
  139.  
  140. '   Demonstrate left and right shadow.
  141. '
  142.     Explode 10, 17, 15, 64, 112, 0
  143.     FOR I% = 12 TO 13: READ Me$: FastPrint I%, 19, Me$, 112: NEXT
  144.     SLEEP 6: FlushKey: PopUp 2, 2, 11, 30, Attribute%(15, 1), 7, 0, 0
  145.     SLEEP 3: FlushKey: ShutUp 0: Explode 10, 17, 15, 64, 112, 0
  146.     FOR I% = 12 TO 13: READ Me$: FastPrint I%, 19, Me$, 112: NEXT
  147.     SLEEP 6: FlushKey: Attrib% = Attribute%(14, 5)
  148.     PopUp 5, 5, 10, 30, Attrib%, 2, 1, 0
  149.     FastPrint 9, 14, "Left Shadow", Attrib%
  150.     SLEEP 2: FlushKey: Attrib% = Attribute%(0, 2)
  151.     PopUp 5, 45, 10, 30, Attrib%, 2, 2, 0
  152.     FastPrint 9, 54, "Right Shadow", Attrib%
  153.     SLEEP 2: FlushKey: ShutUp 0: ShutUp 0
  154.  
  155. '   Demonstrate zooming and imploding windows.
  156. '
  157.     Explode 10, 17, 15, 64, 112, 0
  158.     FastPrint 12, 31, "Windows can be zoomed", 112
  159.     FastPrint 13, 33, "onto the screen.", 112
  160.     SLEEP 3: FlushKey: PopUp 2, 2, 15, 60, Attribute%(0, 2), 2, 0, -1
  161.     SLEEP 2: FlushKey: PopUp 13, 10, 10, 60, Attribute%(0, 3), 3, 0, -1
  162.     SLEEP 2: FlushKey: PopUp 7, 33, 10, 45, Attribute%(14, 5), 1, 0, -1
  163.     SLEEP 2: FlushKey: Attrib% = Attribute%(15, 4)
  164.     PopUp 9, 10, 12, 63, Attrib%, 2, 1, -1
  165.     FastPrint 14, 32, "<<< W O W >>>", Attrib%
  166.     SLEEP 3: FlushKey: FOR I% = 1 TO 4: ShutUp -1: NEXT
  167.  
  168. '   Demonstrate overlapping windows.
  169. '
  170.     Explode 10, 17, 15, 64, 112, 0
  171.     FOR I% = 10 TO 14: READ Me$: FastPrint I%, 19, Me$, 112: NEXT
  172.     SLEEP 6: FlushKey: Explode 10, 17, 15, 64, 112, 0
  173.     FOR I% = 10 TO 15: READ Me$: FastPrint I%, 19, Me$, 112: NEXT
  174.     SLEEP 6: FlushKey: Explode 10, 17, 15, 64, 112, 0
  175.     FOR I% = 10 TO 15: READ Me$: FastPrint I%, 19, Me$, 112: NEXT
  176.     SLEEP 6: FlushKey: Attrib% = Attribute%(0, 2)
  177.     PopUp 3, 5, 15, 45, Attrib%, 4, 1, -1
  178.     FastPrint 9, 14, "This is the first level ...", Attrib%
  179.     SLEEP 2: FlushKey: Attrib% = Attribute%(15, 4)
  180.     PopUp 6, 29, 17, 50, Attrib%, 4, 1, -1
  181.     FastPrint 12, 40, "This is the second level ...", Attrib%
  182.     SLEEP 2: FlushKey: Attrib% = Attribute%(0, 3)
  183.     PopUp 9, 22, 15, 35, Attrib%, 4, 1, -1
  184.     FastPrint 16, 26, "This is the third level ...", Attrib%
  185.     SLEEP 2: FlushKey: FastPrint 16, 26, "Now to go back ...         ", Attrib%
  186.     SLEEP 1: ShutUp -1: SLEEP 1: ShutUp -1: SLEEP 1: ShutUp -1: SLEEP 2
  187.     ShutUp -1: PopUp 4, 15, 10, 30, 52, 4, 1, -1
  188.  
  189. '   A word from our sponsor.
  190. '
  191.     PopUp 3, 36, 13, 40, 47, 3, 1, -1: PopUp 9, 10, 13, 40, 78, 2, 1, -1
  192.     PopUp 12, 42, 11, 36, 67, 1, 1, -1: PopUp 9, 16, 8, 52, 112, 2, 1, -1
  193.     FastPrint 11, 20, "The video routines in ASSEMBLY Library", 112
  194.     FastPrint 12, 20, "give you all you need to create powerful", 112
  195.     FastPrint 13, 20, "and professional screen displays in your", 112
  196.     FastPrint 14, 20, "QuickBASIC programs.", 112: SLEEP 9: FlushKey
  197.     FOR I% = 1 TO 5: ShutUp -1: SLEEP 1: FlushKey: NEXT
  198. END
  199.  
  200. '┌────────────────────────────────────────────────────────────────────────┐
  201. '│  Local procedures and functions.                                       │
  202. '└────────────────────────────────────────────────────────────────────────┘
  203. '
  204. '   Returns a random integer between the limits specified.
  205. '
  206. FUNCTION Randy% (Lowest%, Highest%) STATIC
  207.     Randy% = INT(RND * ((Highest% - Lowest%) + 1)) + Lowest%
  208. END FUNCTION    
  209.  
  210. '   Flush all keystrokes from the keyboard typeahead buffer
  211. '
  212. '   Note:   this is used in conjunction with the SLEEP function since,
  213. '           if the user terminates a SLEEP delay by pressing a key, the
  214. '           keystroke is not automatically removed from the buffer.
  215. '
  216. SUB FlushKey () STATIC
  217.     DO: LOOP UNTIL INKEY$ = ""
  218. END SUB
  219.  
  220. '┌────────────────────────────────────────────────────────────────────────┐
  221. '│  Data Division.                                                        │
  222. '└────────────────────────────────────────────────────────────────────────┘
  223. '
  224. DATA "These QBNews ASSEMBLY libraries provide you"
  225. DATA "with all the facilities necessary for you to"
  226. DATA "implement a full range of window features in"
  227. DATA "your programs.  With just one statement, for"
  228. DATA "instance, you can 'Pop-up' a window onto the"
  229. DATA "screen."
  230. DATA "The window can be a simple rectangle, in any"
  231. DATA "the QuickBASIC background colors, such as .."
  232. DATA "Alternatively it may have a border in one of"
  233. DATA "eight styles ...."
  234. DATA "The border itself may be in any one of the"
  235. DATA "QuickBASIC foreground colors. It can blink"
  236. DATA "if you want it to ..."
  237. DATA "The window, too, can be presented in several"
  238. DATA "different ways. It can be flat..."
  239. DATA "or it can have a black shadow underneath, to"
  240. DATA "give a three-dimensional effect..."
  241. DATA "Once you have a window on the screen, simply"
  242. DATA "use FASTPRINT, also in the ASSEMBLY Library,"
  243. DATA "to put text into it, in any colour you like."
  244. DATA "You can also use EXPLODE from the same place"
  245. DATA "to clear the window's contents."
  246. DATA "All the functions in the Library are written"
  247. DATA "in fast assembly language, but this does not"
  248. DATA "prevent them from being very easy to use."
  249. DATA "This for instance, is the call to create the"
  250. DATA "present window ....."
  251. DATA "   PopUp 8, 14, 8, 52, 112, 2, 0, -1"
  252. DATA "Before opening a window, the function stores"
  253. DATA "the screen beneath it in an internal buffer."
  254. DATA "When you close a window, the screen contents"
  255. DATA "are restored to their original location. Use"
  256. DATA "the statement 'ShutUp -1' to close the last"
  257. DATA "window opened.  For example ...."
  258.  
  259. '┌────────────────────────────────────────────────────────────────────────┐
  260. '│      (c) 1991 By Christy Gemmell and Singular Software.                │
  261. '└────────────────────────────────────────────────────────────────────────┘
  262.  
  263.