home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l196 / 3.ddi / WINDOW.BA$ / WINDOW.bin
Encoding:
Text File  |  1990-06-24  |  108.9 KB  |  2,919 lines

  1. '============================================================================
  2. '
  3. '    WINDOW.BAS - Window Routines for the User Interface Toolbox in
  4. '           Microsoft BASIC 7.1, Professional Development System
  5. '              Copyright (C) 1987-1990, Microsoft Corporation
  6. '
  7. '  NOTE:
  8. '           This sample source code toolbox is intended to demonstrate some
  9. '           of the extended capabilities of Microsoft BASIC 7.1 Professional
  10. '           Development system that can help to leverage the professional
  11. '           developer's time more effectively.  While you are free to use,
  12. '           modify, or distribute the routines in this module in any way you
  13. '           find useful, it should be noted that these are examples only and
  14. '           should not be relied upon as a fully-tested "add-on" library.
  15. '
  16. '  PURPOSE: These routines provide dialog box and window support to the
  17. '           user interface toolbox.
  18. '
  19. '  For information on creating a library and QuickLib from the routines
  20. '  contained in this file, read the comment header of GENERAL.BAS.
  21. '
  22. '==========================================================================
  23.  
  24. DEFINT A-Z
  25.  
  26. '$INCLUDE: 'general.bi'
  27. '$INCLUDE: 'mouse.bi'
  28. '$INCLUDE: 'menu.bi'
  29. '$INCLUDE: 'window.bi'
  30.  
  31.  
  32. COMMON SHARED /uitools/ GloMenu           AS MenuMiscType
  33. COMMON SHARED /uitools/ GloTitle()        AS MenuTitleType
  34. COMMON SHARED /uitools/ GloItem()         AS MenuItemType
  35. COMMON SHARED /uitools/ GloWindow()       AS windowType
  36. COMMON SHARED /uitools/ GloButton()       AS buttonType
  37. COMMON SHARED /uitools/ GloEdit()         AS EditFieldType
  38. COMMON SHARED /uitools/ GloStorage        AS WindowStorageType
  39. COMMON SHARED /uitools/ GloWindowStack()  AS INTEGER
  40. COMMON SHARED /uitools/ GloBuffer$()
  41.  
  42. FUNCTION Alert (style, text$, row1, col1, row2, col2, b1$, b2$, b3$)
  43.  
  44.     ' =======================================================================
  45.     ' Open an alert window, then return the button that was pushed
  46.     ' =======================================================================
  47.  
  48.     Alert = 0
  49.  
  50.     ' =======================================================================
  51.     ' Make sure coordinates and butttons are valid
  52.     ' =======================================================================
  53.  
  54.     IF row1 >= MINROW AND row2 <= MAXROW AND col1 >= MINCOL AND col2 <= MAXCOL THEN
  55.  
  56.         IF b1$ = "" THEN
  57.             b1$ = "OK"
  58.             b2$ = ""
  59.             b3$ = ""
  60.         END IF
  61.  
  62.         IF b2$ = "" THEN
  63.             b3$ = ""
  64.         END IF
  65.  
  66.         ' ===================================================================
  67.         ' If a window is available, compute button locations
  68.         ' ===================================================================
  69.  
  70.         alertWindow = WindowNext
  71.  
  72.         IF alertWindow <> 0 THEN
  73.  
  74.             minWidth = 3
  75.             buttonTotal = 0
  76.           
  77.             IF b1$ <> "" THEN
  78.                 minWidth = minWidth + 7 + LEN(b1$):
  79.                 buttonTotal = buttonTotal + 1
  80.             END IF
  81.  
  82.             IF b2$ <> "" THEN
  83.                 minWidth = minWidth + 7 + LEN(b2$)
  84.                 buttonTotal = buttonTotal + 1
  85.             END IF
  86.  
  87.             IF b3$ <> "" THEN
  88.                 minWidth = minWidth + 7 + LEN(b3$)
  89.                 buttonTotal = buttonTotal + 1
  90.             END IF
  91.  
  92.             actualWidth = col2 - col1 + 1
  93.             actualHeight = row2 - row1 + 1
  94.  
  95.             ' ===============================================================
  96.             ' If size is valid, open window, print text, open buttons
  97.             ' ===============================================================
  98.  
  99.             IF actualWidth >= minWidth AND actualHeight >= 3 THEN
  100.  
  101.                 WindowOpen alertWindow, row1, col1, row2, col2, 0, 7, 0, 7, 15, 0, 0, 0, 1, 1, ""
  102.                 WindowLine actualHeight - 1
  103.  
  104.                 text$ = text$ + "|"
  105.                 WHILE text$ <> ""
  106.                     x$ = LEFT$(text$, INSTR(text$, "|") - 1)
  107.                     text$ = RIGHT$(text$, LEN(text$) - LEN(x$) - 1)
  108.                     WindowPrint style, x$
  109.                 WEND
  110.  
  111.                 charTotal = LEN(b1$) + LEN(b2$) + LEN(b3$) + 4 * buttonTotal
  112.                 avgSpace = INT((actualWidth - charTotal) / (buttonTotal + 1))
  113.  
  114.                 IF LEN(b1$) > 0 THEN
  115.                     ButtonOpen 1, 2, b1$, actualHeight, avgSpace + 1, 0, 0, 1
  116.                 END IF
  117.  
  118.                 IF LEN(b2$) > 0 THEN
  119.                     ButtonOpen 2, 1, b2$, actualHeight, avgSpace * 2 + LEN(b1$) + 5, 0, 0, 1
  120.                 END IF
  121.  
  122.                 IF LEN(b3$) > 0 THEN
  123.                     ButtonOpen 3, 1, b3$, actualHeight, avgSpace * 3 + LEN(b1$) + LEN(b2$) + 9, 0, 0, 1
  124.                 END IF
  125.  
  126.                 ' ===========================================================
  127.                 ' Main window processing loop
  128.                 ' ===========================================================
  129.  
  130.                 currButton = 1
  131.  
  132.                 ExitFlag = FALSE
  133.                 WHILE NOT ExitFlag
  134.                     WindowDo currButton, 0
  135.                     SELECT CASE Dialog(0)
  136.                         CASE 1                      'Button Pressed
  137.                             Alert = Dialog(1)
  138.                             ExitFlag = TRUE
  139.                         CASE 6, 14                  'Enter or Space
  140.                             Alert = currButton
  141.                             ExitFlag = TRUE
  142.                         CASE 7                      'Tab
  143.                             ButtonSetState currButton, 1
  144.                             currButton = (currButton) MOD buttonTotal + 1
  145.                             ButtonSetState currButton, 2
  146.                         CASE 8                      'BackTab
  147.                             ButtonSetState currButton, 1
  148.                             currButton = (currButton + buttonTotal - 2) MOD buttonTotal + 1
  149.                             ButtonSetState currButton, 2
  150.                         CASE 9
  151.                             IF UCASE$(b1$) = "CANCEL" THEN
  152.                                 Alert = 1
  153.                             END IF
  154.                             IF UCASE$(b2$) = "CANCEL" THEN
  155.                                 Alert = 2
  156.                             END IF
  157.                             IF UCASE$(b3$) = "CANCEL" THEN
  158.                                 Alert = 3
  159.                             END IF
  160.                             ExitFlag = TRUE
  161.                         CASE ELSE
  162.                     END SELECT
  163.                 WEND
  164.  
  165.                 WindowClose alertWindow
  166.                
  167.             END IF
  168.         END IF
  169.     END IF
  170.  
  171. END FUNCTION
  172.  
  173. SUB BackgroundRefresh (handle)
  174.  
  175.     ' =======================================================================
  176.     ' Refresh the background behind a window
  177.     ' =======================================================================
  178.  
  179.     IF GloWindow(handle).handle > 0 THEN
  180.         MouseHide
  181.         PutBackground GloWindow(handle).row1 - 1, GloWindow(handle).col1 - 1, GloBuffer$(handle, 1)
  182.         MouseShow
  183.     END IF
  184. END SUB
  185.  
  186. SUB BackgroundSave (handle)
  187.  
  188.     ' =======================================================================
  189.     ' Save the background before a window opens, or is moved... etc
  190.     ' =======================================================================
  191.  
  192.     IF GloWindow(handle).handle > 0 THEN
  193.         MouseHide
  194.         GetBackground GloWindow(handle).row1 - 1, GloWindow(handle).col1 - 1, GloWindow(handle).row2 + 1, GloWindow(handle).col2 + 1, GloBuffer$(handle, 1)
  195.         MouseShow
  196.     END IF
  197. END SUB
  198.  
  199. SUB ButtonClose (handle)
  200.  
  201.     ' =======================================================================
  202.     ' Make sure a window is actually opened
  203.     ' =======================================================================
  204.  
  205.     windo = WindowCurrent
  206.  
  207.     IF windo > 0 THEN
  208.  
  209.         ' ===================================================================
  210.         ' If handle=0, recursively close all buttons in the CURRENT WINDOW only
  211.         ' ===================================================================
  212.  
  213.         IF handle = 0 THEN
  214.             IF GloStorage.numButtonsOpen > 0 THEN
  215.                 FOR A = GloStorage.numButtonsOpen TO 1 STEP -1
  216.                     IF GloButton(A).windowHandle = windo THEN
  217.                         ButtonClose GloButton(A).handle
  218.                     END IF
  219.                 NEXT A
  220.             END IF
  221.         ELSE
  222.             ' ===============================================================
  223.             ' Get the index into the global array based on handle, and
  224.             ' currWindow
  225.             ' ===============================================================
  226.  
  227.             button = FindButton(handle)
  228.  
  229.             ' ===============================================================
  230.             ' If valid, hide button, then squeeze array, decrement totals
  231.             ' ===============================================================
  232.  
  233.             IF button > 0 THEN
  234.                             
  235.                 COLOR GloWindow(windo).fore, GloWindow(windo).back
  236.                 SELECT CASE GloButton(button).buttonType
  237.                     CASE 1, 2, 3
  238.                         LOCATE GloWindow(windo).row1 + GloButton(button).row1 - 1, GloWindow(windo).col1 + GloButton(button).col1 - 1
  239.                         MouseHide
  240.                         PRINT SPACE$(4 + LEN(RTRIM$(GloButton(button).text$)));
  241.                         MouseShow
  242.                     CASE 6
  243.                         MouseHide
  244.                         FOR A = 1 TO GloButton(button).row2 - GloButton(button).row1 + 1
  245.                             LOCATE GloWindow(windo).row1 + GloButton(button).row1 + A - 2, GloWindow(windo).col1 + GloButton(button).col1 - 1
  246.                             PRINT " ";
  247.                         NEXT A
  248.                         MouseShow
  249.                     CASE 7
  250.                         LOCATE GloWindow(windo).row1 + GloButton(button).row1 - 1, GloWindow(windo).col1 + GloButton(button).col1 - 1
  251.                         MouseHide
  252.                         PRINT SPACE$(GloButton(button).col2 - GloButton(button).col1 + 1);
  253.                         MouseShow
  254.                     CASE ELSE
  255.                 END SELECT
  256.  
  257.  
  258.                 GloStorage.numButtonsOpen = GloStorage.numButtonsOpen - 1
  259.                 WHILE button <= GloStorage.numButtonsOpen
  260.                     GloButton(button).row1 = GloButton(button + 1).row1
  261.                     GloButton(button).col1 = GloButton(button + 1).col1
  262.                     GloButton(button).row2 = GloButton(button + 1).row2
  263.                     GloButton(button).col2 = GloButton(button + 1).col2
  264.                     GloButton(button).text = GloButton(button + 1).text
  265.                     GloButton(button).handle = GloButton(button + 1).handle
  266.                     GloButton(button).state = GloButton(button + 1).state
  267.                     GloButton(button).buttonType = GloButton(button + 1).buttonType
  268.                     GloButton(button).windowHandle = GloButton(button + 1).windowHandle
  269.                     button = button + 1
  270.                 WEND
  271.             END IF
  272.         END IF
  273.     END IF
  274.  
  275. END SUB
  276.  
  277. FUNCTION ButtonInquire (handle)
  278.  
  279.     ' =======================================================================
  280.     ' If valid, return then state of the button
  281.     ' =======================================================================
  282.  
  283.     button = FindButton(handle)
  284.  
  285.     IF button > 0 THEN
  286.         ButtonInquire = GloButton(button).state
  287.     ELSE
  288.         ButtonInquire = 0
  289.     END IF
  290.  
  291. END FUNCTION
  292.  
  293. SUB ButtonOpen (handle, state, title$, row1, col1, row2, col2, buttonType)
  294.  
  295.     ' =======================================================================
  296.     ' Open a button - first check if window can be resized - If so, do not
  297.     ' open!
  298.     ' =======================================================================
  299.  
  300.     IF MID$(WindowBorder$(GloWindow(WindowCurrent).windowType), 9, 1) = "+" THEN
  301.         resize = TRUE
  302.     END IF
  303.  
  304.     IF (resize AND buttonType >= 6) OR NOT resize THEN
  305.  
  306.         ' ===================================================================
  307.         ' If scroll bar, then make sure "state" is valid, given bar length
  308.         ' ===================================================================
  309.  
  310.         IF buttonType = 6 THEN
  311.             length = (row2 - row1) - 1
  312.             IF state < 1 THEN state = 1
  313.             IF state > length THEN state = length
  314.         END IF
  315.  
  316.         IF buttonType = 7 THEN
  317.             length = (col2 - col1) - 1
  318.             IF state < 1 THEN state = 1
  319.             IF state > length THEN state = length
  320.         END IF
  321.  
  322.  
  323.         ' ===================================================================
  324.         ' If valid state and type, increment totals, and store button info
  325.         ' ===================================================================
  326.  
  327.         IF (buttonType = 1 AND state >= 1 AND state <= 3) OR (buttonType >= 2 AND buttonType <= 3 AND state >= 1 AND state <= 2) OR (buttonType >= 4 AND buttonType <= 7) THEN
  328.             ButtonClose handle
  329.  
  330.             GloStorage.numButtonsOpen = GloStorage.numButtonsOpen + 1
  331.             GloButton(GloStorage.numButtonsOpen).row1 = row1
  332.             GloButton(GloStorage.numButtonsOpen).col1 = col1
  333.             GloButton(GloStorage.numButtonsOpen).row2 = row2
  334.             GloButton(GloStorage.numButtonsOpen).col2 = col2
  335.             GloButton(GloStorage.numButtonsOpen).text = title$
  336.             GloButton(GloStorage.numButtonsOpen).state = state
  337.             GloButton(GloStorage.numButtonsOpen).handle = handle
  338.             GloButton(GloStorage.numButtonsOpen).buttonType = buttonType
  339.             GloButton(GloStorage.numButtonsOpen).windowHandle = WindowCurrent
  340.             ButtonShow handle
  341.         ELSE
  342.             PRINT "Cannot open button on window that can be re-sized!"
  343.             END
  344.         END IF
  345.     END IF
  346. END SUB
  347.  
  348. SUB ButtonSetState (handle, state)
  349.  
  350.     button = FindButton(handle)
  351.     windo = WindowCurrent
  352.  
  353.     ' =======================================================================
  354.     ' If valid state for the type of button, assign the new state, and re-show
  355.     ' =======================================================================
  356.  
  357.     IF button > 0 AND windo > 0 THEN
  358.         SELECT CASE GloButton(button).buttonType
  359.             CASE 1
  360.                 IF state >= 1 AND state <= 3 THEN
  361.                     GloButton(button).state = state
  362.                 END IF
  363.             CASE 2, 3
  364.                 IF state = 1 OR state = 2 THEN
  365.                     GloButton(button).state = state
  366.                 END IF
  367.             CASE 4, 5
  368.             CASE 6
  369.                 IF state <> GloButton(button).state THEN
  370.                     MouseHide
  371.                     COLOR 0, 7
  372.                     LOCATE GloWindow(windo).row1 + GloButton(button).row1 - 1 + GloButton(button).state, GloWindow(windo).col1 + GloButton(button).col1 - 1
  373.                     PRINT CHR$(176);
  374.                     GloButton(button).state = state
  375.                     LOCATE GloWindow(windo).row1 + GloButton(button).row1 - 1 + GloButton(button).state, GloWindow(windo).col1 + GloButton(button).col1 - 1
  376.                     PRINT CHR$(219);
  377.                     MouseShow
  378.                 END IF
  379.             CASE 7
  380.                 IF state <> GloButton(button).state THEN
  381.                     MouseHide
  382.                     COLOR 0, 7
  383.                     LOCATE GloWindow(windo).row1 + GloButton(button).row1 - 1, GloWindow(windo).col1 + GloButton(button).col1 - 1 + GloButton(button).state
  384.                     PRINT CHR$(176);
  385.                     GloButton(button).state = state
  386.                     LOCATE GloWindow(windo).row1 + GloButton(button).row1 - 1, GloWindow(windo).col1 + GloButton(button).col1 - 1 + GloButton(button).state
  387.                     PRINT CHR$(219);
  388.                     MouseShow
  389.                 END IF
  390.             CASE ELSE
  391.         END SELECT
  392.     END IF
  393.  
  394.     ButtonShow handle
  395. END SUB
  396.  
  397. SUB ButtonShow (handle)
  398.  
  399.     button = FindButton(handle)
  400.     windo = WindowCurrent
  401.  
  402.     ' =======================================================================
  403.     ' If valid, show the button based on button type and button state
  404.     ' =======================================================================
  405.  
  406.     IF button > 0 THEN
  407.         LOCATE GloWindow(windo).row1 + GloButton(button).row1 - 1, GloWindow(windo).col1 + GloButton(button).col1 - 1
  408.  
  409.         MouseHide
  410.         SELECT CASE GloButton(button).buttonType
  411.             CASE 1
  412.                 SELECT CASE GloButton(button).state
  413.                     CASE 1
  414.                         COLOR GloWindow(windo).textFore, GloWindow(windo).textBack
  415.                         PRINT "< " + RTRIM$(GloButton(button).text$) + " >";
  416.                     CASE 2
  417.                         COLOR GloWindow(windo).highlight, GloWindow(windo).textBack
  418.                         PRINT "<";
  419.                         COLOR GloWindow(windo).textFore, GloWindow(windo).textBack
  420.                         PRINT " "; RTRIM$(GloButton(button).text$); " ";
  421.                         COLOR GloWindow(windo).highlight, GloWindow(windo).textBack
  422.                         PRINT ">";
  423.                     CASE 3
  424.                         COLOR GloWindow(windo).textBack, GloWindow(windo).textFore
  425.                         PRINT "< " + RTRIM$(GloButton(button).text$) + " >";
  426.                 END SELECT
  427.             CASE 2
  428.                 SELECT CASE GloButton(button).state
  429.                     CASE 1
  430.                         COLOR GloWindow(windo).textFore, GloWindow(windo).textBack
  431.                         PRINT "[ ] " + RTRIM$(GloButton(button).text$);
  432.                     CASE 2
  433.                         COLOR GloWindow(windo).textFore, GloWindow(windo).textBack
  434.                         PRINT "[X] " + RTRIM$(GloButton(button).text$);
  435.                 END SELECT
  436.             CASE 3
  437.                 SELECT CASE GloButton(button).state
  438.                     CASE 1
  439.                         COLOR GloWindow(windo).textFore, GloWindow(windo).textBack
  440.                         PRINT "( ) " + RTRIM$(GloButton(button).text$);
  441.                     CASE 2
  442.                         COLOR GloWindow(windo).textFore, GloWindow(windo).textBack
  443.                         PRINT "() " + RTRIM$(GloButton(button).text$);
  444.                 END SELECT
  445.             CASE 4, 5
  446.             CASE 6
  447.                 COLOR 0, 7
  448.                 PRINT CHR$(24);
  449.                 FOR A = 1 TO GloButton(button).row2 - GloButton(button).row1 - 1
  450.                     LOCATE GloWindow(windo).row1 + GloButton(button).row1 - 1 + A, GloWindow(windo).col1 + GloButton(button).col1 - 1
  451.                     IF A = GloButton(button).state THEN
  452.                         PRINT CHR$(219);
  453.                     ELSE
  454.                         PRINT CHR$(176);
  455.                     END IF
  456.                 NEXT A
  457.                 LOCATE GloWindow(windo).row1 + GloButton(button).row1 - 1 + A, GloWindow(windo).col1 + GloButton(button).col1 - 1
  458.                 PRINT CHR$(25);
  459.             CASE 7
  460.                 COLOR 0, 7
  461.                 PRINT CHR$(27); STRING$(GloButton(button).col2 - GloButton(button).col1 - 1, 176); CHR$(26);
  462.                 LOCATE GloWindow(windo).row1 + GloButton(button).row1 - 1, GloWindow(windo).col1 + GloButton(button).col1 - 1 + GloButton(button).state
  463.                 PRINT CHR$(219);
  464.             CASE ELSE
  465.                 PRINT "Error in Button Parameter";
  466.         END SELECT
  467.         MouseShow
  468.     END IF
  469. END SUB
  470.  
  471. SUB ButtonToggle (handle)
  472.  
  473.     button = FindButton(handle)
  474.     windo = WindowCurrent
  475.  
  476.     ' =======================================================================
  477.     ' If valid button, and state is 1 or 2, toggle button
  478.     ' =======================================================================
  479.  
  480.     IF button > 0 THEN
  481.         IF GloButton(button).state = 1 OR GloButton(button).state = 2 THEN
  482.            GloButton(button).state = 3 - GloButton(button).state
  483.         END IF
  484.     END IF
  485.  
  486.     ButtonShow handle
  487.  
  488. END SUB
  489.  
  490. FUNCTION Dialog (op)
  491.  
  492.     ' =======================================================================
  493.     ' Based on global variables set in WindowDo, return proper event ID/Info
  494.     ' =======================================================================
  495.  
  496.     SELECT CASE op
  497.  
  498.         ' ===================================================================
  499.         ' Return event ID, and reset all variables.
  500.         ' ===================================================================
  501.  
  502.         CASE 0
  503.             GloStorage.DialogButton = GloStorage.oldDialogButton
  504.             GloStorage.DialogEdit = GloStorage.oldDialogEdit
  505.             GloStorage.DialogWindow = GloStorage.oldDialogWindow
  506.             GloStorage.DialogClose = GloStorage.oldDialogClose
  507.             GloStorage.DialogScroll = GloStorage.oldDialogScroll
  508.             GloStorage.DialogRow = GloStorage.oldDialogRow
  509.             GloStorage.DialogCol = GloStorage.oldDialogCol
  510.             Dialog = GloStorage.oldDialogEvent
  511.  
  512.             GloStorage.oldDialogButton = 0
  513.             GloStorage.oldDialogEdit = 0
  514.             GloStorage.oldDialogWindow = 0
  515.             GloStorage.oldDialogClose = 0
  516.             GloStorage.oldDialogScroll = 0
  517.             GloStorage.oldDialogRow = 0
  518.             GloStorage.oldDialogCol = 0
  519.  
  520.         ' ===================================================================
  521.         ' If button is pressed, dialog(0) is 1, and dialog(1) is the button
  522.         ' number
  523.         ' ===================================================================
  524.  
  525.         CASE 1
  526.             Dialog = GloStorage.DialogButton
  527.  
  528.  
  529.         ' ===================================================================
  530.         ' If edit field is clicked, dialog(0) is 2, and dialog(2) is the edit
  531.         ' field number
  532.         ' ===================================================================
  533.  
  534.         CASE 2
  535.             Dialog = GloStorage.DialogEdit
  536.  
  537.         ' ===================================================================
  538.         ' If another window is clicked, dialog(0)=3, and dialog(3)=window
  539.         ' number
  540.         ' ===================================================================
  541.  
  542.         CASE 3
  543.             Dialog = GloStorage.DialogWindow
  544.  
  545.         ' ===================================================================
  546.         ' If a field button was pressed This returns the row (relative to
  547.         ' window position) of the click
  548.         ' ===================================================================
  549.  
  550.         CASE 17
  551.             Dialog = GloStorage.DialogRow
  552.  
  553.         ' ===================================================================
  554.         ' If a field button was pressed This returns the column (relative to
  555.         ' window position) of the click
  556.         ' ===================================================================
  557.  
  558.         CASE 18
  559.             Dialog = GloStorage.DialogCol
  560.  
  561.         ' ===================================================================
  562.         ' If a scroll bar was clicked, return new position of marker
  563.         ' ===================================================================
  564.  
  565.         CASE 19
  566.             Dialog = GloStorage.DialogScroll
  567.  
  568.         ' ===================================================================
  569.         ' Bad call, so return 0
  570.         ' ===================================================================
  571.  
  572.         CASE ELSE
  573.             Dialog = 0
  574.     END SELECT
  575.  
  576.  
  577. END FUNCTION
  578.  
  579. SUB EditFieldClose (handle)
  580.  
  581.     ' =======================================================================
  582.     ' Close an edit field
  583.     ' =======================================================================
  584.  
  585.     windo = WindowCurrent
  586.  
  587.     IF windo > 0 THEN
  588.         IF handle = 0 THEN
  589.  
  590.             ' ===============================================================
  591.             ' If handle = 0, then recursivily close all edit fields
  592.             ' ===============================================================
  593.  
  594.             IF GloStorage.numEditFieldsOpen > 0 THEN
  595.                 FOR A = GloStorage.numEditFieldsOpen TO 1 STEP -1
  596.                     IF GloEdit(A).windowHandle = windo THEN
  597.                         EditFieldClose GloEdit(A).handle
  598.                     END IF
  599.                 NEXT A
  600.             END IF
  601.         ELSE
  602.  
  603.             ' ===============================================================
  604.             ' else, erase edit field, then squeeze array, decrement total
  605.             ' variables
  606.             ' ===============================================================
  607.  
  608.             editField = FindEditField(handle)
  609.  
  610.             IF editField > 0 THEN
  611.                 LOCATE GloWindow(windo).row1 + GloEdit(editField).row - 1, GloWindow(windo).col1 + GloEdit(editField).col - 1
  612.                 COLOR GloWindow(windo).fore, GloWindow(windo).back
  613.                 MouseHide
  614.                 PRINT SPACE$(GloEdit(editField).visLength);
  615.                 MouseShow
  616.  
  617.                 GloStorage.numEditFieldsOpen = GloStorage.numEditFieldsOpen - 1
  618.                 WHILE editField <= GloStorage.numEditFieldsOpen
  619.                     GloEdit(editField).row = GloEdit(editField + 1).row
  620.                     GloEdit(editField).col = GloEdit(editField + 1).col
  621.                     GloEdit(editField).text = GloEdit(editField + 1).text
  622.                     GloEdit(editField).handle = GloEdit(editField + 1).handle
  623.                     GloEdit(editField).visLength = GloEdit(editField + 1).visLength
  624.                     GloEdit(editField).maxLength = GloEdit(editField + 1).maxLength
  625.                     GloEdit(editField).windowHandle = GloEdit(editField + 1).windowHandle
  626.                     editField = editField + 1
  627.                 WEND
  628.             END IF
  629.         END IF
  630.     END IF
  631. END SUB
  632.  
  633. FUNCTION EditFieldInquire$ (handle)
  634.  
  635.     ' =======================================================================
  636.     ' If valid edit field, return the value.  Note edit$ is terminated
  637.     ' by a CHR$(0), or maxLength, or 255 chars.
  638.     ' =======================================================================
  639.  
  640.     editField = FindEditField(handle)
  641.     windo = WindowCurrent
  642.     EditFieldInquire$ = ""
  643.  
  644.     IF editField > 0 THEN
  645.         x$ = GloEdit(editField).text$
  646.         x = INSTR(x$, CHR$(0)) - 1
  647.         IF x >= 0 THEN
  648.             EditFieldInquire$ = LEFT$(x$, x)
  649.         ELSE
  650.             EditFieldInquire$ = x$
  651.         END IF
  652.     END IF
  653.  
  654. END FUNCTION
  655.  
  656. SUB EditFieldOpen (handle, text$, row, col, fore, back, visLength, maxLength)
  657.  
  658.     ' =======================================================================
  659.     ' If window can be re-sized, do not open edit field
  660.     ' =======================================================================
  661.  
  662.     IF MID$(WindowBorder$(GloWindow(WindowCurrent).windowType), 9, 1) <> "+" THEN
  663.  
  664.         ' ===================================================================
  665.         ' Close edit field by the same handle if it exists
  666.         ' ===================================================================
  667.  
  668.         EditFieldClose handle
  669.  
  670.         windo = WindowCurrent
  671.  
  672.         ' ===================================================================
  673.         ' If no colors given, use default window colors
  674.         ' ===================================================================
  675.  
  676.         IF fore = 0 AND back = 0 THEN
  677.             fore = GloWindow(windo).fore
  678.             back = GloWindow(windo).back
  679.         END IF
  680.       
  681.         ' ===================================================================
  682.         ' Increment totals, and store edit field info
  683.         ' ===================================================================
  684.  
  685.         GloStorage.numEditFieldsOpen = GloStorage.numEditFieldsOpen + 1
  686.         GloEdit(GloStorage.numEditFieldsOpen).row = row
  687.         GloEdit(GloStorage.numEditFieldsOpen).col = col
  688.         GloEdit(GloStorage.numEditFieldsOpen).fore = fore
  689.         GloEdit(GloStorage.numEditFieldsOpen).back = back
  690.         GloEdit(GloStorage.numEditFieldsOpen).text = text$ + CHR$(0)
  691.         GloEdit(GloStorage.numEditFieldsOpen).visLength = visLength
  692.         GloEdit(GloStorage.numEditFieldsOpen).maxLength = maxLength
  693.         GloEdit(GloStorage.numEditFieldsOpen).windowHandle = windo
  694.         GloEdit(GloStorage.numEditFieldsOpen).handle = handle
  695.  
  696.         LOCATE GloWindow(windo).row1 + row - 1, GloWindow(windo).col1 + col - 1
  697.         COLOR fore, back
  698.  
  699.         'Create temp$ so that padding with spaces doesn't alter the original text$
  700.         IF LEN(text$) < visLength THEN
  701.             temp$ = text$ + SPACE$(visLength - LEN(text$))
  702.         ELSE
  703.             temp$ = LEFT$(text$, visLength)
  704.         END IF
  705.         PRINT temp$;
  706.        
  707.     ELSE
  708.         PRINT "EditField cannot be opened on a window that can be re-sized!"
  709.     END IF
  710. END SUB
  711.  
  712. FUNCTION FindButton (handle)
  713.  
  714.     ' =======================================================================
  715.     ' Given a handle, return the index into the global array that stores
  716.     ' buttons.  Each button is uniquely described by a handle, and a window#
  717.     ' This SUB program assumes that you want the current window.
  718.     ' =======================================================================
  719.  
  720.     FindButton = 0
  721.  
  722.     IF GloStorage.numButtonsOpen > 0 THEN
  723.         A = 0
  724.         curr = WindowCurrent
  725.         DO
  726.             A = A + 1
  727.         LOOP UNTIL (GloButton(A).handle = handle AND GloButton(A).windowHandle = curr) OR A = GloStorage.numButtonsOpen
  728.  
  729.         IF GloButton(A).handle = handle AND GloButton(A).windowHandle = curr THEN
  730.             FindButton = A
  731.         END IF
  732.     END IF
  733.  
  734. END FUNCTION
  735.  
  736. FUNCTION FindEditField (handle)
  737.  
  738.     ' =======================================================================
  739.     ' Given a handle, return the index into the global array that stores
  740.     ' edit fields.  Each button is uniquely described by a handle, and a
  741.     ' window number. This SUB program assumes the you want the current window.
  742.     ' =======================================================================
  743.  
  744.     FindEditField = 0
  745.  
  746.     IF GloStorage.numEditFieldsOpen > 0 THEN
  747.         A = 0
  748.         curr = WindowCurrent
  749.         DO
  750.             A = A + 1
  751.         LOOP UNTIL (GloEdit(A).handle = handle AND GloEdit(A).windowHandle = curr) OR A = GloStorage.numEditFieldsOpen
  752.  
  753.         IF GloEdit(A).handle = handle AND GloEdit(A).windowHandle = curr THEN
  754.             FindEditField = A
  755.         END IF
  756.     END IF
  757.  
  758. END FUNCTION
  759.  
  760. ' ==========================================================================
  761. ' The ListBox FUNCTION can be modified to accept a box width parameter. This
  762. ' will enable you to specify the width of a listbox when you call the ListBox
  763. ' FUNCTION. Below you will find two FUNCTION statements. The first is the
  764. ' default ListBox FUNCTION that takes only two arguments.  The second allows
  765. ' you to specify a box width parameter. As configured, the listbox width is
  766. ' assumed to be 14. This default is idal for listboxes that contain file
  767. ' names. To use the second form of the ListBox FUNCTION, that
  768. ' lets you specify the listbox width, comment out the first FUNCTION
  769. ' statement and remove the ' from the beginning of the second FUNCTION
  770. ' statement. Change the WINDOW.BI file so that the DECLARE statement matches
  771. ' the actual FUNCTION as follows:
  772. '
  773. ' DECLARE FUNCTION ListBox (Text$(), MaxRec%, BoxWidth%)
  774. '
  775. ' You also need to comment out the "BoxWidth = 14" statement that occurs just the
  776. ' after second FUNCTION statement.
  777. '
  778. ' When you use the ListBox FUNCTION be sure to include a box width parameter
  779. ' as the third argument.  All calculations will be automatically performed
  780. ' to properly display the listbox.
  781. '
  782. ' ===========================================================================
  783. '
  784. FUNCTION ListBox (text$(), MaxRec)
  785. 'FUNCTION ListBox (text$(), MaxRec, BoxWidth)
  786.  
  787.     ' Comment out the following line if you modify this function to allow
  788.     ' specification of a ListBox width parameter in the function call.
  789.  
  790.     BoxWidth = 14
  791.  
  792.     GOSUB ListBoxWidthCalc
  793.  
  794.     ' =======================================================================
  795.     ' Open up a modal window and put the right buttons in it
  796.     ' =======================================================================
  797.     
  798.     WindowOpen 1, 4, StartRowPos, 20, StopRowPos, 0, 7, 0, 7, 15, 0, 0, 0, 1, 1, ""
  799.                                                           
  800.     WindowBox 1, 6, 14, BoxEndPos
  801.     ButtonOpen 1, 1, "", 2, BoxEndPos, 13, BoxEndPos, 6     'Scroll Bar
  802.     ButtonOpen 2, 2, "OK", 16, 6, 0, 0, 1                   'OK button
  803.     ButtonOpen 3, 1, "Cancel", 16, BoxEndPos - 9, 0, 0, 1   'Cancel button
  804.     ButtonOpen 4, 1, "", 1, 8, 1, AreaEndPos, 4             'Area above box
  805.     ButtonOpen 5, 1, "", 2, 7, 13, AreaEndPos + 1, 4        'Area of box
  806.     ButtonOpen 6, 1, "", 14, 8, 14, AreaEndPos, 4           'Area below box
  807.  
  808.     currTop = 1
  809.     currPos = 1
  810.     currButton = 2
  811.    
  812.     GOSUB ListBoxDrawText
  813.  
  814.     ExitFlag = FALSE
  815.  
  816.     ' =======================================================================
  817.     ' Process window events...
  818.     '  IMPORTANT:  Window moving, and re-sizing is handled automatically
  819.     '  The window type dictates when this is allowed to happen.
  820.     ' =======================================================================
  821.  
  822.     WHILE NOT ExitFlag
  823.         WindowDo currButton, 0
  824.         x = Dialog(0)
  825.  
  826.         SELECT CASE x
  827.             CASE 1
  828.                 button = Dialog(1)
  829.                 SELECT CASE button
  830.                     CASE 1
  831.                         scrollCode = Dialog(19)
  832.                         SELECT CASE scrollCode
  833.                             CASE -1:   GOSUB ListBoxUp
  834.                             CASE -2:   GOSUB ListBoxDown
  835.                             CASE ELSE: GOSUB ListBoxMove
  836.                         END SELECT
  837.                     CASE 2
  838.                         ListBox = currTop + currPos - 1
  839.                         ExitFlag = TRUE
  840.                     CASE 3
  841.                         ListBox = 0
  842.                         ExitFlag = TRUE
  843.                     CASE 4
  844.                         GOSUB ListBoxUp
  845.                     CASE 5
  846.                         GOSUB ListBoxAssign
  847.                     CASE 6
  848.                         GOSUB ListBoxDown
  849.                 END SELECT
  850.             CASE 6, 14
  851.                 SELECT CASE currButton
  852.                     CASE 0, 2
  853.                         ListBox = currTop + currPos - 1
  854.                         ExitFlag = TRUE
  855.                     CASE 3
  856.                         ListBox = 0
  857.                         ExitFlag = TRUE
  858.                     CASE ELSE
  859.                 END SELECT
  860.             CASE 7
  861.                 SELECT CASE currButton
  862.                     CASE 0
  863.                         currButton = 2
  864.                     CASE 2
  865.                         ButtonToggle 2
  866.                         ButtonToggle 3
  867.                         currButton = 3
  868.                     CASE 3
  869.                         ButtonToggle 2
  870.                         ButtonToggle 3
  871.                         currButton = 0
  872.                 END SELECT
  873.             CASE 8
  874.                 SELECT CASE currButton
  875.                     CASE 0
  876.                         ButtonToggle 2
  877.                         ButtonToggle 3
  878.                         currButton = 3
  879.                     CASE 2
  880.                         currButton = 0
  881.                     CASE 3
  882.                         ButtonToggle 2
  883.                         ButtonToggle 3
  884.                         currButton = 2
  885.                 END SELECT
  886.             CASE 9
  887.                 ListBox = 0
  888.                 ExitFlag = TRUE
  889.             CASE 10, 12
  890.                 IF currButton = 0 THEN
  891.                     GOSUB ListBoxUp
  892.                 END IF
  893.             CASE 11, 13
  894.                 IF currButton = 0 THEN
  895.                     GOSUB ListBoxDown
  896.                 END IF
  897.             CASE 16
  898.                 scrollCode = 1
  899.                 GOSUB ListBoxMove
  900.             CASE 17
  901.                 scrollCode = 10
  902.                 GOSUB ListBoxMove
  903.             CASE 18
  904.                 GOSUB ListBoxPgUp
  905.             CASE 19
  906.                 GOSUB ListBoxPgDn
  907.             CASE ELSE
  908.         END SELECT
  909.     WEND
  910.  
  911.     WindowClose 0
  912.     EXIT FUNCTION
  913.  
  914. ListBoxUp:
  915.     oldRec = currTop + currPos - 1
  916.     currPos = currPos - 1
  917.     IF currPos < 1 THEN
  918.         currPos = 1
  919.         currTop = currTop - 1
  920.         IF currTop < 1 THEN
  921.             currTop = 1
  922.         END IF
  923.     END IF
  924.     newRec = currTop + currPos - 1
  925.     IF oldRec <> newRec THEN
  926.         GOSUB ListBoxDrawText
  927.         GOSUB ListBoxNewBarPos
  928.     END IF
  929. RETURN
  930.  
  931. ListBoxDown:
  932.     oldRec = currTop + currPos - 1
  933.     IF MaxRec > 12 THEN
  934.         currPos = currPos + 1
  935.         IF currPos > 12 THEN
  936.             currPos = 12
  937.             currTop = currTop + 1
  938.             IF currTop + currPos - 1 > MaxRec THEN
  939.                 currTop = currTop - 1
  940.             END IF
  941.         END IF
  942.     ELSE
  943.         IF currPos + 1 <= MaxRec THEN
  944.             currPos = currPos + 1
  945.         END IF
  946.     END IF
  947.  
  948.     newRec = currTop + currPos - 1
  949.     IF oldRec <> newRec THEN
  950.         GOSUB ListBoxDrawText
  951.         GOSUB ListBoxNewBarPos
  952.     END IF
  953. RETURN
  954.  
  955. ListBoxPgUp:
  956.     oldRec = currTop + currPos - 1
  957.     currTop = currTop - 12
  958.     IF currTop < 1 THEN
  959.         currTop = 1
  960.         currPos = 1
  961.     END IF
  962.     newRec = currTop + currPos - 1
  963.     IF oldRec <> newRec THEN
  964.         GOSUB ListBoxDrawText
  965.         GOSUB ListBoxNewBarPos
  966.     END IF
  967. RETURN
  968.  
  969. ListBoxPgDn:
  970.     oldRec = currTop + currPos - 1
  971.     IF MaxRec > 12 THEN
  972.         currTop = currTop + 12
  973.             IF currTop + 12 > MaxRec THEN
  974.                 currTop = MaxRec - 11
  975.                 currPos = 12
  976.             END IF
  977.     ELSE
  978.         currPos = MaxRec
  979.     END IF
  980.  
  981.     newRec = currTop + currPos - 1
  982.     IF oldRec <> newRec THEN
  983.         GOSUB ListBoxDrawText
  984.         GOSUB ListBoxNewBarPos
  985.     END IF
  986. RETURN
  987.  
  988. ListBoxAssign:
  989.     currPos = Dialog(17)
  990.     IF currPos > MaxRec THEN currPos = MaxRec
  991.     GOSUB ListBoxDrawText
  992.     GOSUB ListBoxNewBarPos
  993.  
  994. RETURN
  995.  
  996. ListBoxMove:
  997.     SELECT CASE scrollCode
  998.         CASE 1:      newPos = 1
  999.         CASE 2 TO 9: newPos = scrollCode * MaxRec / 10
  1000.         CASE 10:     newPos = MaxRec
  1001.     END SELECT
  1002.     
  1003.     IF newPos < 1 THEN newPos = 1
  1004.     IF newPos > MaxRec THEN newPos = MaxRec
  1005.  
  1006.     currPos = newPos - currTop + 1
  1007.     IF currPos <= 0 THEN
  1008.         currTop = newPos
  1009.         currPos = 1
  1010.     ELSEIF currPos > 12 THEN
  1011.         currPos = 12
  1012.         currTop = newPos - 11
  1013.     END IF
  1014.     GOSUB ListBoxDrawText
  1015.     GOSUB ListBoxNewBarPos
  1016. RETURN
  1017.  
  1018. ListBoxDrawText:
  1019.     FOR A = currTop TO currTop + 11
  1020.         IF A <= MaxRec THEN
  1021.             IF currTop + currPos - 1 = A THEN
  1022.                 WindowColor 7, 0
  1023.             ELSE
  1024.                 WindowColor 0, 7
  1025.             END IF
  1026.  
  1027.             WindowLocate A - currTop + 2, 8
  1028.             WindowPrint -1, LEFT$(text$(A) + STRING$(BoxWidth + 1, " "), BoxWidth + 1)
  1029.         END IF
  1030.     NEXT A
  1031.     WindowColor 0, 7
  1032.     RETURN
  1033.  
  1034. ListBoxNewBarPos:
  1035.     IF currPos = 1 AND currTop = 1 THEN
  1036.         newState = 1
  1037.     ELSE
  1038.         newState = (currTop + currPos - 1) * 10 / MaxRec
  1039.         IF newState < 1 THEN newState = 1
  1040.         IF newState > 10 THEN newState = 10
  1041.     END IF
  1042.     ButtonSetState 1, newState
  1043. RETURN
  1044.  
  1045. ListBoxWidthCalc:
  1046.     IF BoxWidth < 14 THEN BoxWidth = 14
  1047.     IF BoxWidth > 55 THEN BoxWidth = 55
  1048.     StartRowPos = 40 - ((BoxWidth + 14) / 2)
  1049.     StopRowPos = StartRowPos + BoxWidth + 14
  1050.     BoxEndPos = BoxWidth + 10
  1051.     AreaEndPos = BoxWidth + 8
  1052. RETURN
  1053.  
  1054. END FUNCTION
  1055.  
  1056. FUNCTION MaxScrollLength (handle)
  1057.  
  1058.     ' =======================================================================
  1059.     ' If valid, return then maximum length of scroll bar
  1060.     ' =======================================================================
  1061.  
  1062.     button = FindButton(handle)
  1063.  
  1064.     IF button > 0 THEN
  1065.         SELECT CASE GloButton(button).buttonType
  1066.             CASE 6
  1067.                 MaxScrollLength = GloButton(button).row2 - GloButton(button).row1 - 1
  1068.             CASE 7
  1069.                 MaxScrollLength = GloButton(button).col2 - GloButton(button).col1 - 1
  1070.             CASE ELSE
  1071.                 MaxScrollLength = 0
  1072.         END SELECT
  1073.     ELSE
  1074.         MaxScrollLength = 0
  1075.     END IF
  1076.  
  1077. END FUNCTION
  1078.  
  1079. FUNCTION WhichWindow (row, col)
  1080.  
  1081.     ' =======================================================================
  1082.     ' Returns the window number where the row,col points to.  Takes into
  1083.     ' account which windows overlap which other windows by going down
  1084.     ' the GloWindowStack from the top.
  1085.     ' =======================================================================
  1086.  
  1087.     x = GloStorage.numWindowsOpen
  1088.     Found = FALSE
  1089.     WhichWindow = 0
  1090.  
  1091.     WHILE x > 0 AND NOT Found
  1092.         handle = GloWindowStack(x)
  1093.         row1 = GloWindow(handle).row1 - 1
  1094.         col1 = GloWindow(handle).col1 - 1
  1095.         row2 = GloWindow(handle).row2 + 1
  1096.         col2 = GloWindow(handle).col2 + 1
  1097.  
  1098.         IF row >= row1 AND row <= row2 AND col >= col1 AND col <= col2 THEN
  1099.             WhichWindow = handle
  1100.             Found = TRUE
  1101.         ELSE
  1102.             x = x - 1
  1103.         END IF
  1104.     WEND
  1105.  
  1106. END FUNCTION
  1107.  
  1108. FUNCTION WindowBorder$ (windowType)
  1109.  
  1110.     ' =======================================================================
  1111.     ' Returns a window border for the given window type.
  1112.     ' You may customize this to create custom windows.  See external
  1113.     ' documentation for a discussion of window borders
  1114.     ' =======================================================================
  1115.  
  1116.     SELECT CASE ABS(windowType)
  1117.         CASE 1
  1118.             WindowBorder$ = " ░          ST"
  1119.         CASE 2
  1120.             WindowBorder$ = "=           ST"
  1121.         CASE 3
  1122.             WindowBorder$ = "=░          ST"
  1123.         CASE 4
  1124.             WindowBorder$ = "        +   ST"
  1125.         CASE 5
  1126.             WindowBorder$ = " ░      +   ST"
  1127.         CASE 6
  1128.             WindowBorder$ = "=       +   ST"
  1129.         CASE 7
  1130.             WindowBorder$ = "=░      +   ST"
  1131.         CASE 8
  1132.             WindowBorder$ = "┌─┐│ │└─┘├─┤ST"
  1133.         CASE 9
  1134.             WindowBorder$ = "┌░┐│ │└─┘├─┤ST"
  1135.         CASE 10
  1136.             WindowBorder$ = "=─┐│ │└─┘├─┤ST"
  1137.         CASE 11
  1138.             WindowBorder$ = "=░┐│ │└─┘├─┤ST"
  1139.         CASE 12
  1140.             WindowBorder$ = "┌─┐│ │└─+├─┤ST"
  1141.         CASE 13
  1142.             WindowBorder$ = "┌░┐│ │└─+├─┤ST"
  1143.         CASE 14
  1144.             WindowBorder$ = "=─┐│ │└─+├─┤ST"
  1145.         CASE 15
  1146.             WindowBorder$ = "=░┐│ │└─+├─┤ST"
  1147.         CASE 16
  1148.             WindowBorder$ = "╔═╗║ ║╚═╝╠═╣ST"
  1149.         CASE 17
  1150.             WindowBorder$ = "╔░╗║ ║╚═╝╠═╣ST"
  1151.         CASE 18
  1152.             WindowBorder$ = "=═╗║ ║╚═╝╠═╣ST"
  1153.         CASE 19
  1154.             WindowBorder$ = "=░╗║ ║╚═╝╠═╣ST"
  1155.         CASE 20
  1156.             WindowBorder$ = "╔═╗║ ║╚═+╠═╣ST"
  1157.         CASE 21
  1158.             WindowBorder$ = "╔░╗║ ║╚═+╠═╣ST"
  1159.         CASE 22
  1160.             WindowBorder$ = "=═╗║ ║╚═+╠═╣ST"
  1161.         CASE 23
  1162.             WindowBorder$ = "=░╗║ ║╚═+╠═╣ST"
  1163.  
  1164.         ' ===================================================================
  1165.         ' Put any custom-designed border styles after this point and before
  1166.         ' the CASE ELSE statement.
  1167.         ' ===================================================================
  1168.  
  1169.         CASE ELSE
  1170.             WindowBorder$ = "            ST"
  1171.    
  1172.     END SELECT
  1173.  
  1174. END FUNCTION
  1175.  
  1176. SUB WindowBox (boxRow1, boxCol1, boxRow2, boxCol2)
  1177.  
  1178.     ' =======================================================================
  1179.     ' Draw a box, given coordinates based on the current window
  1180.     ' =======================================================================
  1181.  
  1182.     windo = WindowCurrent
  1183.     IF windo > 0 THEN
  1184.         row1 = GloWindow(windo).row1 + boxRow1 - 1
  1185.         row2 = GloWindow(windo).row1 + boxRow2 - 1
  1186.         col1 = GloWindow(windo).col1 + boxCol1 - 1
  1187.         col2 = GloWindow(windo).col1 + boxCol2 - 1
  1188.         fore = GloWindow(windo).fore
  1189.         back = GloWindow(windo).back
  1190.         border$ = "┌─┐│ │└─┘"
  1191.  
  1192.         Box row1, col1, row2, col2, fore, back, border$, 0
  1193.     END IF
  1194.  
  1195. END SUB
  1196.  
  1197. SUB WindowClose (handle)
  1198.  
  1199.     ' =======================================================================
  1200.     ' Close window # handle.  If handle is 0, recursively close all windows
  1201.     ' =======================================================================
  1202.  
  1203.     IF handle = 0 THEN
  1204.         IF GloStorage.numWindowsOpen > 0 THEN
  1205.             FOR x = GloStorage.numWindowsOpen TO 1 STEP -1
  1206.                 WindowClose GloWindowStack(x)
  1207.             NEXT x
  1208.         END IF
  1209.     ELSE
  1210.  
  1211.         ' ===================================================================
  1212.         ' If valid window,
  1213.         ' ===================================================================
  1214.  
  1215.         IF GloWindow(handle).handle <> -1 THEN
  1216.  
  1217.             ' ===============================================================
  1218.             ' Make the window you want to close the top window
  1219.             ' ===============================================================
  1220.  
  1221.             WindowSetCurrent handle
  1222.  
  1223.             ' ===============================================================
  1224.             ' If top window has shadow, hide shadow
  1225.             ' ===============================================================
  1226.  
  1227.             IF INSTR(WindowBorder$(GloWindow(GloStorage.currWindow).windowType), "S") THEN
  1228.                 WindowShadowRefresh
  1229.             END IF
  1230.  
  1231.             ' ===============================================================
  1232.             ' Close all edit fields, and button on top window
  1233.             ' ===============================================================
  1234.  
  1235.             EditFieldClose 0
  1236.             ButtonClose 0
  1237.             MouseHide
  1238.  
  1239.             ' ===============================================================
  1240.             ' Restore the background of the window + clear data
  1241.             ' ===============================================================
  1242.  
  1243.             BackgroundRefresh handle
  1244.  
  1245.             GloBuffer$(handle, 1) = ""
  1246.             GloBuffer$(handle, 2) = ""
  1247.  
  1248.             GloWindow(handle).handle = -1
  1249.  
  1250.             ' ===============================================================
  1251.             ' Decrement total number of windows
  1252.             ' ===============================================================
  1253.  
  1254.             GloStorage.numWindowsOpen = GloStorage.numWindowsOpen - 1
  1255.  
  1256.             ' ===============================================================
  1257.             ' If some windows still open, assign curr Window to top window,
  1258.             ' show shadow is the currWindow has a shadow
  1259.             ' ===============================================================
  1260.  
  1261.             IF GloStorage.numWindowsOpen > 0 THEN
  1262.                 GloStorage.currWindow = GloWindowStack(GloStorage.numWindowsOpen)
  1263.  
  1264.                 IF INSTR(WindowBorder$(GloWindow(GloStorage.currWindow).windowType), "S") THEN
  1265.                     WindowShadowSave
  1266.                 END IF
  1267.             ELSE
  1268.  
  1269.                 ' ===========================================================
  1270.                 ' If no more windows open, assign 0 to the currWindow variable
  1271.                 ' ===========================================================
  1272.  
  1273.                 GloStorage.currWindow = 0
  1274.             END IF
  1275.             MouseShow
  1276.         END IF
  1277.     END IF
  1278.  
  1279. END SUB
  1280.  
  1281. SUB WindowCls
  1282.  
  1283.     ' =======================================================================
  1284.     ' If curr window is valid, clear the window
  1285.     ' =======================================================================
  1286.  
  1287.     windo = WindowCurrent
  1288.     IF windo > 0 THEN
  1289.         WindowScroll 0
  1290.     END IF
  1291.  
  1292. END SUB
  1293.  
  1294. SUB WindowColor (fore, back)
  1295.  
  1296.     ' =======================================================================
  1297.     ' If curr window is valid, assign the colors to the variables
  1298.     ' =======================================================================
  1299.  
  1300.     windo = WindowCurrent
  1301.     IF windo > 0 THEN
  1302.         GloWindow(windo).textFore = fore
  1303.         GloWindow(windo).textBack = back
  1304.     END IF
  1305.  
  1306. END SUB
  1307.  
  1308. FUNCTION WindowCols (handle)
  1309.  
  1310.     ' =======================================================================
  1311.     ' If window Handle is valid, return number of columns in that window
  1312.     ' =======================================================================
  1313.  
  1314.     IF GloWindow(handle).handle > 0 THEN
  1315.         WindowCols = GloWindow(handle).col2 - GloWindow(handle).col1 + 1
  1316.     END IF
  1317.  
  1318. END FUNCTION
  1319.  
  1320. FUNCTION WindowCurrent
  1321.  
  1322.     ' =======================================================================
  1323.     ' Simply return the current window, as stored in the global array
  1324.     ' =======================================================================
  1325.  
  1326.     WindowCurrent = GloStorage.currWindow
  1327.  
  1328. END FUNCTION
  1329.  
  1330. SUB WindowDo (startButton, startEdit)
  1331.  
  1332.   DIM RB$(1 TO 4)
  1333.  
  1334.     ' =======================================================================
  1335.     ' Main Processing loop.  Init, go to proper mode, exit
  1336.     ' =======================================================================
  1337.  
  1338.     GOSUB WindowDoInit
  1339.     GOSUB WindowDoComputeHotSpots
  1340.  
  1341.     IF WindowDoMode = 1 THEN
  1342.         GOSUB WindowDoEditMode
  1343.     ELSE
  1344.         GOSUB WindowDoButtonMode
  1345.     END IF
  1346.     LOCATE , , 0
  1347.     EXIT SUB
  1348.  
  1349. ' ===========================================================================
  1350. ' If startEdit is=0 then do button mode.  In button mode, we wait
  1351. ' for any keyboard event or mouse event that flips the ExitFlag.
  1352. ' Then we exit.  It's very simple really, don't try to make it complicated.
  1353. ' ===========================================================================
  1354.  
  1355. WindowDoButtonMode:
  1356.     GOSUB WindowDoShowTextCursor
  1357.     WHILE NOT ExitFlag
  1358.         GOSUB WindowDoMouse
  1359.         GOSUB WindowDoButtonKbd
  1360.     WEND
  1361.     GOSUB WindowDoHideTextCursor
  1362. RETURN
  1363.  
  1364. ' ===========================================================================
  1365. ' If startEdit>0 then go to edit mode.  Here we also wait for a mouse event
  1366. ' or kbd event to flip the ExitFlag, but in the mean time, we trap the
  1367. ' alphanumberic keys, and arrow keys, and use them to edit the current
  1368. ' edit field.  (StartEdit is the current edit field.)  Again, there's no magic.
  1369. ' (well maybe just a little...)
  1370. ' ===========================================================================
  1371.  
  1372. WindowDoEditMode:
  1373.     GOSUB WindowDoEditInit
  1374.     WHILE NOT ExitFlag
  1375.         GOSUB WindowDoMouse
  1376.         GOSUB WindowDoEditKbd
  1377.     WEND
  1378.     GOSUB WindowDoEditExit
  1379. RETURN
  1380.  
  1381. ' ===========================================================================
  1382. ' Set initial flags, determine where cursor should be located, and figure
  1383. ' out which mode we should be in (edit mode or button mode)
  1384. ' ===========================================================================
  1385.  
  1386. WindowDoInit:
  1387.  
  1388.     ' =======================================================================
  1389.     ' Simply abort if there is no window open.
  1390.     ' =======================================================================
  1391.  
  1392.     windo = WindowCurrent
  1393.     IF windo = 0 THEN EXIT SUB
  1394.  
  1395.     REDIM HSClick(MAXHOTSPOT) AS hotSpotType
  1396.     REDIM HSRel(MAXHOTSPOT) AS hotSpotType
  1397.  
  1398.     ExitFlag = FALSE
  1399.     ButtonHighLight = FALSE
  1400.  
  1401.     border$ = WindowBorder$(GloWindow(windo).windowType)
  1402.     WindowDoMode = 2
  1403.  
  1404.     ' =======================================================================
  1405.     ' If startEdit>0, assign the index value to currEditField, and set
  1406.     ' WindowDoMode to 1
  1407.     ' =======================================================================
  1408.  
  1409.     IF startEdit > 0 THEN
  1410.         index = FindEditField(startEdit)
  1411.         IF index > 0 THEN
  1412.             currEditField = index
  1413.             WindowDoMode = 1
  1414.             origCursorRow = GloWindow(windo).row1 + GloEdit(index).row - 1
  1415.             origCursorCol = GloWindow(windo).col1 + GloEdit(index).col - 1
  1416.         END IF
  1417.     END IF
  1418.  
  1419.     ' =======================================================================
  1420.     ' If start button>0, then set current cursor location properly
  1421.     ' =======================================================================
  1422.  
  1423.     IF startButton > 0 THEN
  1424.         index = FindButton(startButton)
  1425.         IF index > 0 THEN
  1426.             currButton = index
  1427.             origCursorRow = GloWindow(windo).row1 + GloButton(index).row1 - 1
  1428.             origCursorCol = GloWindow(windo).col1 + GloButton(index).col1
  1429.  
  1430.             ' ===============================================================
  1431.             ' For area buttons decrement the cursor position
  1432.             ' ===============================================================
  1433.  
  1434.             SELECT CASE GloButton(index).buttonType
  1435.                 CASE 4
  1436.                     origCursorCol = origCursorCol - 1
  1437.                 CASE ELSE
  1438.             END SELECT
  1439.  
  1440.         END IF
  1441.     END IF
  1442.  
  1443.     currCursorRow = origCursorRow
  1444.     currCursorCol = origCursorCol
  1445. RETURN
  1446.  
  1447. ' ===========================================================================
  1448. ' Checks buttons, editfields, etc. and stores where the hot spots are
  1449. ' ===========================================================================
  1450.  
  1451. WindowDoComputeHotSpots:
  1452.     numHSClick = 0
  1453.     numHSRel = 0
  1454.  
  1455.     ' =======================================================================
  1456.     ' If upper left corder of border is "=", then that's a close box
  1457.     ' Furthermore, a close box is a release type event so store in HSRel
  1458.     ' =======================================================================
  1459.  
  1460.     IF MID$(border$, 1, 1) = "=" THEN
  1461.         numHSRel = numHSRel + 1
  1462.         HSRel(numHSRel).row1 = GloWindow(windo).row1 - 1
  1463.         HSRel(numHSRel).row2 = GloWindow(windo).row1 - 1
  1464.         HSRel(numHSRel).col1 = GloWindow(windo).col1 - 1
  1465.         HSRel(numHSRel).col2 = GloWindow(windo).col1 - 1
  1466.         HSRel(numHSRel).action = 4
  1467.         HSRel(numHSRel).misc = windo
  1468.     END IF
  1469.  
  1470.     ' =======================================================================
  1471.     ' If lower right corner is "+", then that's a re-size box
  1472.     ' Further more, a re-size box is a click event, so store in HSClick
  1473.     ' =======================================================================
  1474.  
  1475.     IF MID$(border$, 9, 1) = "+" THEN
  1476.         numHSClick = numHSClick + 1
  1477.         HSClick(numHSClick).row1 = GloWindow(windo).row2 + 1
  1478.         HSClick(numHSClick).row2 = GloWindow(windo).row2 + 1
  1479.         HSClick(numHSClick).col1 = GloWindow(windo).col2 + 1
  1480.         HSClick(numHSClick).col2 = GloWindow(windo).col2 + 1
  1481.         HSClick(numHSClick).action = 5
  1482.         HSClick(numHSClick).misc = 0
  1483.     END IF
  1484.  
  1485.     ' =======================================================================
  1486.     ' Likewise, a "░" chr$(176) is a move bar.  That's also a click event
  1487.     ' =======================================================================
  1488.  
  1489.     IF MID$(border$, 2, 1) = "░" THEN
  1490.         numHSClick = numHSClick + 1
  1491.         HSClick(numHSClick).row1 = GloWindow(windo).row1 - 1
  1492.         HSClick(numHSClick).row2 = GloWindow(windo).row1 - 1
  1493.         HSClick(numHSClick).col1 = GloWindow(windo).col1
  1494.         HSClick(numHSClick).col2 = GloWindow(windo).col2
  1495.         HSClick(numHSClick).action = 15
  1496.         HSClick(numHSClick).misc = 0
  1497.     END IF
  1498.  
  1499.     ' =======================================================================
  1500.     ' Buttons are click, and release events.
  1501.     ' Click, and the cursor goes there, and the button is highlighted.
  1502.     ' Release, and the selection is made
  1503.     ' =======================================================================
  1504.  
  1505.     IF GloStorage.numButtonsOpen > 0 THEN
  1506.         button = 0
  1507.         WHILE button < GloStorage.numButtonsOpen
  1508.             button = button + 1
  1509.             IF GloButton(button).windowHandle = windo THEN
  1510.                 numHSClick = numHSClick + 1
  1511.                 HSClick(numHSClick).row1 = GloWindow(windo).row1 + GloButton(button).row1 - 1
  1512.                 HSClick(numHSClick).row2 = GloWindow(windo).row1 + GloButton(button).row1 - 1
  1513.                 HSClick(numHSClick).col1 = GloWindow(windo).col1 + GloButton(button).col1 - 1
  1514.                 HSClick(numHSClick).col2 = GloWindow(windo).col1 + GloButton(button).col1 + 2 + LEN(RTRIM$(GloButton(button).text$))
  1515.                 HSClick(numHSClick).action = 1
  1516.                 HSClick(numHSClick).misc = GloButton(button).handle
  1517.                 HSClick(numHSClick).misc2 = GloButton(button).buttonType
  1518.  
  1519.                 numHSRel = numHSRel + 1
  1520.                 HSRel(numHSRel).row1 = GloWindow(windo).row1 + GloButton(button).row1 - 1
  1521.                 HSRel(numHSRel).row2 = GloWindow(windo).row1 + GloButton(button).row1 - 1
  1522.                 HSRel(numHSRel).col1 = GloWindow(windo).col1 + GloButton(button).col1 - 1
  1523.                 HSRel(numHSRel).col2 = GloWindow(windo).col1 + GloButton(button).col1 + 2 + LEN(RTRIM$(GloButton(button).text$))
  1524.                 HSRel(numHSRel).action = 1
  1525.                 HSRel(numHSRel).misc = GloButton(button).handle
  1526.                 HSRel(numHSRel).misc2 = GloButton(button).buttonType
  1527.  
  1528.                 ' ===========================================================
  1529.                 ' Adjust previous info to handle special cases for
  1530.                 ' "field" buttons, and "scroll bar" buttons.
  1531.                 ' ===========================================================
  1532.  
  1533.                 SELECT CASE GloButton(button).buttonType
  1534.                     CASE 4
  1535.                         numHSRel = numHSRel - 1
  1536.                         HSClick(numHSClick).row2 = GloWindow(windo).row1 + GloButton(button).row2 - 1
  1537.                         HSClick(numHSClick).col2 = GloWindow(windo).col1 + GloButton(button).col2 - 1
  1538.                     CASE 5
  1539.                         numHSClick = numHSClick - 1
  1540.                         HSRel(numHSRel).row2 = GloWindow(windo).row1 + GloButton(button).row2 - 1
  1541.                         HSRel(numHSRel).col2 = GloWindow(windo).col1 + GloButton(button).col2 - 1
  1542.                     CASE 6
  1543.                         numHSRel = numHSRel - 1
  1544.                         HSClick(numHSClick).row2 = GloWindow(windo).row1 + GloButton(button).row2 - 1
  1545.                         HSClick(numHSClick).col2 = GloWindow(windo).col1 + GloButton(button).col1 - 1
  1546.                     CASE 7
  1547.                         numHSRel = numHSRel - 1
  1548.                         HSClick(numHSClick).row2 = GloWindow(windo).row1 + GloButton(button).row1 - 1
  1549.                         HSClick(numHSClick).col2 = GloWindow(windo).col1 + GloButton(button).col2 - 1
  1550.                     CASE ELSE
  1551.                 END SELECT
  1552.             END IF
  1553.         WEND
  1554.     END IF
  1555.  
  1556.     ' =======================================================================
  1557.     ' EditFields are Click events
  1558.     ' =======================================================================
  1559.  
  1560.     IF GloStorage.numEditFieldsOpen > 0 THEN
  1561.         editField = 0
  1562.         WHILE editField < GloStorage.numEditFieldsOpen
  1563.             editField = editField + 1
  1564.             IF GloEdit(editField).windowHandle = windo THEN
  1565.                 numHSClick = numHSClick + 1
  1566.                 HSClick(numHSClick).row1 = GloWindow(windo).row1 + GloEdit(editField).row - 1
  1567.                 HSClick(numHSClick).row2 = GloWindow(windo).row1 + GloEdit(editField).row - 1
  1568.                 HSClick(numHSClick).col1 = GloWindow(windo).col1 + GloEdit(editField).col - 1
  1569.                 HSClick(numHSClick).col2 = GloWindow(windo).col1 + GloEdit(editField).col + GloEdit(editField).visLength - 1
  1570.                 HSClick(numHSClick).action = 2
  1571.                 HSClick(numHSClick).misc = GloEdit(editField).handle
  1572.             END IF
  1573.         WEND
  1574.     END IF
  1575.  
  1576.     ' =======================================================================
  1577.     ' Feel free to add your own hot spots!  One good idea is if the
  1578.     ' right hand side of the border is ▓, make that a scroll bar!  Adding
  1579.     ' that would be good practice -- and fun too!
  1580.     ' =======================================================================
  1581.  
  1582. RETURN
  1583.  
  1584. ' ===========================================================================
  1585. ' Polls the mouse
  1586. ' ===========================================================================
  1587.  
  1588. WindowDoMouse:
  1589.  
  1590.     MousePoll MouseRow, MouseCol, lButton, rButton
  1591.    
  1592.     ' =======================================================================
  1593.     ' If lButton is down, then keep checking for click events until it's released
  1594.     ' =======================================================================
  1595.  
  1596.     IF lButton THEN
  1597.         WHILE lButton AND MouseRow <> 1 AND NOT ExitFlag
  1598.             GOSUB WindowDoCheckClickEvent
  1599.             IF Found THEN
  1600.                 GOSUB WindowDoClickEvent
  1601.             END IF
  1602.  
  1603.             MousePoll MouseRow, MouseCol, lButton, rButton
  1604.         WEND
  1605.  
  1606.         ' ===================================================================
  1607.         ' If the button was released (and no click event occured) then check
  1608.         ' for a release event!
  1609.         ' ===================================================================
  1610.  
  1611.         IF NOT lButton AND MouseRow <> 1 AND NOT ExitFlag THEN
  1612.             GOSUB WindowDoCheckReleaseEvent
  1613.             IF Found THEN
  1614.                 GOSUB WindowDoReleaseEvent
  1615.             ELSE
  1616.  
  1617.                 ' ===========================================================
  1618.                 ' If no release event, then see if mouse was released in another
  1619.                 ' window.  This is a special case release event
  1620.                 ' ===========================================================
  1621.  
  1622.                 GOSUB WindowDoCheckOtherWindow
  1623.             END IF
  1624.  
  1625.             ' ===============================================================
  1626.             ' Un highlight the button if the mouse was released for any reason
  1627.             ' ===============================================================
  1628.  
  1629.             GOSUB WindowDoUnHighlightButton
  1630.  
  1631.         END IF
  1632.      
  1633.  
  1634.     END IF
  1635.  
  1636.     ' =======================================================================
  1637.     ' If in button mode, return cursor to original spot.
  1638.     ' =======================================================================
  1639.  
  1640.     IF WindowDoMode = 2 THEN
  1641.         currCursorRow = origCursorRow
  1642.         currCursorCol = origCursorCol
  1643.         GOSUB WindowDoShowTextCursor
  1644.     END IF
  1645.     
  1646. RETURN
  1647.  
  1648. ' ===========================================================================
  1649. ' Used only in Button mode.  Checks for menu event with MenuInkey$,
  1650. ' then checks for all the misc events.  See below
  1651. ' If an event is found, the proper event ID is stored, and ExifFlag is set
  1652. ' ===========================================================================
  1653.  
  1654. WindowDoButtonKbd:
  1655.  
  1656.     ' =======================================================================
  1657.     ' Only check menu if window type > 0.
  1658.     ' =======================================================================
  1659.  
  1660.     IF GloWindow(windo).windowType < 0 THEN
  1661.         kbd$ = INKEY$
  1662.     ELSE
  1663.         kbd$ = MenuInkey$
  1664.     END IF
  1665.  
  1666.     ' =======================================================================
  1667.     ' The following is a list of key strokes that can be detected. You can
  1668.     ' add more as needed, but you will need to change any programs that use
  1669.     ' the existing configuration.  The numbers associated with each key are
  1670.     ' the numbers that are returned by Dialog(0).
  1671.     ' =======================================================================
  1672.  
  1673.     SELECT CASE kbd$
  1674.         CASE CHR$(13)
  1675.             GloStorage.oldDialogEvent = 6          'Return
  1676.             ExitFlag = TRUE
  1677.         CASE CHR$(9)
  1678.             GloStorage.oldDialogEvent = 7          'Tab
  1679.             ExitFlag = TRUE
  1680.         CASE CHR$(0) + CHR$(15)
  1681.             GloStorage.oldDialogEvent = 8          'Back Tab
  1682.             ExitFlag = TRUE
  1683.         CASE CHR$(27)
  1684.             GloStorage.oldDialogEvent = 9          'Escape
  1685.             ExitFlag = TRUE
  1686.         CASE CHR$(0) + "H"
  1687.             GloStorage.oldDialogEvent = 10         'Up
  1688.             ExitFlag = TRUE
  1689.         CASE CHR$(0) + "P"
  1690.             GloStorage.oldDialogEvent = 11         'Down
  1691.             ExitFlag = TRUE
  1692.         CASE CHR$(0) + "K"
  1693.             GloStorage.oldDialogEvent = 12         'Left
  1694.             ExitFlag = TRUE
  1695.         CASE CHR$(0) + "M"
  1696.             GloStorage.oldDialogEvent = 13         'Right
  1697.             ExitFlag = TRUE
  1698.         CASE " "
  1699.             GloStorage.oldDialogEvent = 14         'Space
  1700.             ExitFlag = TRUE
  1701.         CASE CHR$(0) + "G"
  1702.             GloStorage.oldDialogEvent = 16         'Home
  1703.             ExitFlag = TRUE
  1704.         CASE CHR$(0) + "O"
  1705.             GloStorage.oldDialogEvent = 17         'End
  1706.             ExitFlag = TRUE
  1707.         CASE CHR$(0) + "I"
  1708.             GloStorage.oldDialogEvent = 18         'PgUp
  1709.             ExitFlag = TRUE
  1710.         CASE CHR$(0) + "Q"
  1711.             GloStorage.oldDialogEvent = 19         'PgDn
  1712.             ExitFlag = TRUE
  1713.         CASE "menu"
  1714.             GloStorage.oldDialogEvent = 20         'Menu
  1715.             ExitFlag = TRUE
  1716.         CASE ELSE
  1717.     END SELECT
  1718. RETURN
  1719.  
  1720. ' ===========================================================================
  1721. ' Checks mouseRow, mouseCol against all the click events stored in HSClick
  1722. ' ===========================================================================
  1723.  
  1724. WindowDoCheckClickEvent:
  1725.     currEvent = 1
  1726.     Found = FALSE
  1727.  
  1728.     WHILE NOT Found AND currEvent <= numHSClick
  1729.         IF MouseRow >= HSClick(currEvent).row1 AND MouseRow <= HSClick(currEvent).row2 AND MouseCol >= HSClick(currEvent).col1 AND MouseCol <= HSClick(currEvent).col2 THEN
  1730.             Found = TRUE
  1731.         ELSE
  1732.             currEvent = currEvent + 1
  1733.         END IF
  1734.     WEND
  1735.  
  1736.     IF NOT Found THEN
  1737.         GOSUB WindowDoUnHighlightButton
  1738.     END IF
  1739.  
  1740. RETURN
  1741.  
  1742. ' ===========================================================================
  1743. ' Checks mouseRow,mouseCol against all the release events in HSRel
  1744. ' ===========================================================================
  1745.  
  1746. WindowDoCheckReleaseEvent:
  1747.     currEvent = 1
  1748.     Found = FALSE
  1749.  
  1750.     WHILE NOT Found AND currEvent <= numHSRel
  1751.         IF MouseRow >= HSRel(currEvent).row1 AND MouseRow <= HSRel(currEvent).row2 AND MouseCol >= HSRel(currEvent).col1 AND MouseCol <= HSRel(currEvent).col2 THEN
  1752.             Found = TRUE
  1753.         ELSE
  1754.             currEvent = currEvent + 1
  1755.         END IF
  1756.     WEND
  1757. RETURN
  1758.  
  1759. ' ===========================================================================
  1760. ' Calls WhichWindow to see if mouseRow, mouseCol is in another window
  1761. ' If it is, that's event ID #3, so set it, and set ExitFlag to TRUE
  1762. ' ===========================================================================
  1763.  
  1764. WindowDoCheckOtherWindow:
  1765.     IF GloWindow(windo).windowType > 0 THEN
  1766.         otherWindow = WhichWindow(MouseRow, MouseCol)
  1767.         IF otherWindow AND (otherWindow <> windo) THEN
  1768.             GloStorage.oldDialogEvent = 3
  1769.             GloStorage.oldDialogWindow = otherWindow
  1770.             ExitFlag = TRUE
  1771.         END IF
  1772.     END IF
  1773. RETURN
  1774.      
  1775. ' ===========================================================================
  1776. ' If there was a release event, this routine handles it
  1777. ' ===========================================================================
  1778.  
  1779. WindowDoReleaseEvent:
  1780.  
  1781.     SELECT CASE HSRel(currEvent).action
  1782.         CASE 1                                      'Released on Button
  1783.             GloStorage.oldDialogEvent = 1
  1784.             GloStorage.oldDialogButton = HSRel(currEvent).misc
  1785.             ExitFlag = TRUE
  1786.         CASE 4                                      'Released on Close Box
  1787.             GloStorage.oldDialogEvent = 4
  1788.             GloStorage.oldDialogClose = HSRel(currEvent).misc
  1789.             ExitFlag = TRUE
  1790.         CASE ELSE
  1791.     END SELECT
  1792. RETURN
  1793.  
  1794. ' ===========================================================================
  1795. ' If there was a click event, this routine handles it
  1796. ' ===========================================================================
  1797.  
  1798. WindowDoClickEvent:
  1799.  
  1800.     SELECT CASE HSClick(currEvent).action
  1801.         CASE 1                                          'ButtonClick
  1802.             SELECT CASE HSClick(currEvent).misc2
  1803.                 CASE 1
  1804.                     IF ButtonHighLight THEN
  1805.                         IF currButton <> HSClick(currEvent).misc THEN
  1806.                             ButtonSetState currButton, origState
  1807.                             currButton = HSClick(currEvent).misc
  1808.                             ButtonSetState currButton, 3
  1809.                         END IF
  1810.                     ELSE
  1811.                         currButton = HSClick(currEvent).misc
  1812.                         origState = ButtonInquire(currButton)
  1813.                         ButtonHighLight = TRUE
  1814.                         ButtonSetState currButton, 3
  1815.                     END IF
  1816.               
  1817.                     currCursorRow = HSClick(currEvent).row1
  1818.                     currCursorCol = HSClick(currEvent).col1 + 1
  1819.                     GOSUB WindowDoShowTextCursor
  1820.                 CASE 2, 3
  1821.                     currCursorRow = HSClick(currEvent).row1
  1822.                     currCursorCol = HSClick(currEvent).col1 + 1
  1823.                     GOSUB WindowDoShowTextCursor
  1824.                 CASE 4
  1825.                     IF ButtonHighLight THEN
  1826.                         ButtonSetState currButton, origState
  1827.                     END IF
  1828.  
  1829.                     GloStorage.oldDialogEvent = 1
  1830.                     GloStorage.oldDialogButton = HSClick(currEvent).misc
  1831.                     GloStorage.oldDialogRow = MouseRow - HSClick(currEvent).row1 + 1
  1832.                     GloStorage.oldDialogCol = MouseCol - HSClick(currEvent).col1 + 1
  1833.                     ExitFlag = TRUE
  1834.                 CASE 6
  1835.                     GloStorage.oldDialogEvent = 1
  1836.                     GloStorage.oldDialogButton = HSClick(currEvent).misc
  1837.  
  1838.                     IF MouseRow = HSClick(currEvent).row1 THEN
  1839.                         GloStorage.oldDialogScroll = -1
  1840.                     ELSEIF MouseRow = HSClick(currEvent).row2 THEN
  1841.                         GloStorage.oldDialogScroll = -2
  1842.                     ELSE
  1843.                         GloStorage.oldDialogScroll = MouseRow - HSClick(currEvent).row1
  1844.                     END IF
  1845.  
  1846.                     ExitFlag = TRUE
  1847.                 CASE 7
  1848.                     GloStorage.oldDialogEvent = 1
  1849.                     GloStorage.oldDialogButton = HSClick(currEvent).misc
  1850.  
  1851.                     IF MouseCol = HSClick(currEvent).col1 THEN
  1852.                         GloStorage.oldDialogScroll = -1
  1853.                     ELSEIF MouseCol = HSClick(currEvent).col2 THEN
  1854.                         GloStorage.oldDialogScroll = -2
  1855.                     ELSE
  1856.                         GloStorage.oldDialogScroll = MouseCol - HSClick(currEvent).col1
  1857.                     END IF
  1858.  
  1859.                     ExitFlag = TRUE
  1860.                 CASE ELSE
  1861.             END SELECT
  1862.         CASE 2                                      'Edit Field Click
  1863.             GloStorage.oldDialogEvent = 2           'Event ID #2
  1864.             GloStorage.oldDialogEdit = HSClick(currEvent).misc
  1865.             ExitFlag = TRUE
  1866.         CASE 5
  1867.             GOSUB WindowDoSize                      'Internally handle Re-Size
  1868.             ExitFlag = TRUE
  1869.             GloStorage.oldDialogEvent = 5
  1870.         CASE 15
  1871.             GOSUB WindowDoHideTextCursor
  1872.             GOSUB WindowDoMove                      'Internally handle Move
  1873.             ExitFlag = TRUE
  1874.             GloStorage.oldDialogEvent = 15
  1875.         CASE ELSE
  1876.             
  1877.     END SELECT
  1878.  
  1879.     IF HSClick(currEvent).action <> 1 THEN
  1880.         GOSUB WindowDoUnHighlightButton
  1881.     END IF
  1882.  
  1883. RETURN
  1884.  
  1885. ' ===========================================================================
  1886. ' Un-highlight a button
  1887. ' ===========================================================================
  1888.  
  1889. WindowDoUnHighlightButton:
  1890.     IF ButtonHighLight THEN
  1891.         ButtonSetState currButton, origState
  1892.         ButtonHighLight = FALSE
  1893.         GOSUB WindowDoShowTextCursor
  1894.     END IF
  1895. RETURN
  1896.    
  1897. ' ===========================================================================
  1898. ' Handle the move window click -- drag the window around until button released
  1899. ' ===========================================================================
  1900.  
  1901. WindowDoMove:
  1902.     MouseHide
  1903.     WindowSave windo
  1904.     BackgroundRefresh windo
  1905.     IF INSTR(WindowBorder$(GloWindow(windo).windowType), "S") THEN
  1906.       WindowShadowRefresh
  1907.     END IF
  1908.  
  1909.     oldWinrow1 = GloWindow(windo).row1
  1910.     oldWincol1 = GloWindow(windo).col1
  1911.     oldWinrow2 = GloWindow(windo).row2
  1912.     oldWincol2 = GloWindow(windo).col2
  1913.  
  1914.     GOSUB DrawRubberBand
  1915.  
  1916.     WindowPrintTitle
  1917.     MouseShow
  1918.  
  1919.     MouseBorder MINROW, (MouseCol - GloWindow(windo).col1 + 1 + MINCOL), (MAXROW - WindowRows(windo) - 1), (MAXCOL - (GloWindow(windo).col2 - MouseCol) - 1)
  1920.     
  1921.     oldMouseRow = MouseRow
  1922.     oldMouseCol = MouseCol
  1923.  
  1924.     DO
  1925.         MousePoll MouseRow, MouseCol, lButton, rButton
  1926.         IF MouseRow <> oldMouseRow OR MouseCol <> oldMouseCol THEN
  1927.             MouseHide
  1928.  
  1929.             GOSUB EraseRubberBand
  1930.  
  1931.             oldWinrow1 = oldWinrow1 - oldMouseRow + MouseRow
  1932.             oldWinrow2 = oldWinrow2 - oldMouseRow + MouseRow
  1933.             oldWincol1 = oldWincol1 - oldMouseCol + MouseCol
  1934.             oldWincol2 = oldWincol2 - oldMouseCol + MouseCol
  1935.           
  1936.             oldMouseRow = MouseRow
  1937.             oldMouseCol = MouseCol
  1938.            
  1939.             GOSUB DrawRubberBand
  1940.             MouseShow
  1941.         END IF
  1942.  
  1943.     LOOP UNTIL NOT lButton
  1944.  
  1945.     MouseHide
  1946.     GOSUB EraseRubberBand
  1947.     GloWindow(windo).row1 = oldWinrow1
  1948.     GloWindow(windo).row2 = oldWinrow2
  1949.     GloWindow(windo).col1 = oldWincol1
  1950.     GloWindow(windo).col2 = oldWincol2
  1951.     BackgroundSave windo
  1952.     WindowRefresh windo
  1953.     IF INSTR(WindowBorder$(GloWindow(windo).windowType), "S") THEN
  1954.         WindowShadowSave
  1955.     END IF
  1956.     GloBuffer$(windo, 2) = ""
  1957.     MouseShow
  1958.     MouseBorder 1, 1, MAXROW, MAXCOL
  1959.     GOSUB WindowDoComputeHotSpots
  1960. RETURN
  1961.  
  1962. ' ===========================================================================
  1963. ' Re-Size window -- Drag box around until button released, then exit
  1964. ' with eventID #5  -- Window need refreshing
  1965. ' ===========================================================================
  1966.  
  1967. WindowDoSize:
  1968.     ButtonClose 0
  1969.     MouseHide
  1970.     WindowSave windo
  1971.  
  1972.     ' ======================================================================
  1973.     ' Comment out the next line if you want to retain the window contents
  1974.     ' while resizing the window.
  1975.     ' ======================================================================
  1976.  
  1977.     BackgroundRefresh windo
  1978.  
  1979.     IF INSTR(WindowBorder$(GloWindow(windo).windowType), "S") THEN
  1980.       WindowShadowRefresh
  1981.     END IF
  1982.     
  1983.     oldWinrow1 = GloWindow(windo).row1
  1984.     oldWincol1 = GloWindow(windo).col1
  1985.     oldWinrow2 = GloWindow(windo).row2
  1986.     oldWincol2 = GloWindow(windo).col2
  1987.  
  1988.     GOSUB DrawRubberBand
  1989.  
  1990.     MouseShow
  1991.     MouseBorder GloWindow(windo).row1 + 3, GloWindow(windo).col1 + 6, MAXROW, MAXCOL
  1992.  
  1993.     oldMouseRow = MouseRow
  1994.     oldMouseCol = MouseCol
  1995.  
  1996.     DO
  1997.         MousePoll MouseRow, MouseCol, lButton, rButton
  1998.         IF MouseRow <> oldMouseRow OR MouseCol <> oldMouseCol THEN
  1999.             MouseHide
  2000.  
  2001.             GOSUB EraseRubberBand
  2002.  
  2003.             oldWinrow2 = oldWinrow2 - oldMouseRow + MouseRow
  2004.             oldWincol2 = oldWincol2 - oldMouseCol + MouseCol
  2005.           
  2006.             oldMouseRow = MouseRow
  2007.             oldMouseCol = MouseCol
  2008.            
  2009.             GOSUB DrawRubberBand
  2010.             MouseShow
  2011.         END IF
  2012.     LOOP UNTIL NOT lButton
  2013.  
  2014.     MouseHide
  2015.     GOSUB EraseRubberBand
  2016.     WindowShadowRefresh
  2017.     BackgroundRefresh windo
  2018.     GloWindow(windo).row2 = oldWinrow2
  2019.     GloWindow(windo).col2 = oldWincol2
  2020.     BackgroundSave windo
  2021.     Box GloWindow(windo).row1 - 1, GloWindow(windo).col1 - 1, GloWindow(windo).row2 + 1, GloWindow(windo).col2 + 1, GloWindow(windo).fore, GloWindow(windo).back, WindowBorder$(GloWindow(windo).windowType), 0
  2022.     GloBuffer$(windo, 2) = ""
  2023.     WindowPrintTitle
  2024.  
  2025.     IF INSTR(WindowBorder$(GloWindow(windo).windowType), "S") THEN
  2026.         WindowShadowSave
  2027.     END IF
  2028.     MouseShow
  2029.  
  2030.     MouseBorder 1, 1, MAXROW, MAXCOL
  2031. RETURN
  2032.  
  2033. ' ===========================================================================
  2034. ' Draw rubber band of current window
  2035. ' ===========================================================================
  2036.  
  2037. DrawRubberBand:
  2038.   GetBackground oldWinrow1 - 1, oldWincol1 - 1, oldWinrow1 - 1, oldWincol2 + 1, RB$(1)
  2039.   GetBackground oldWinrow2 + 1, oldWincol1 - 1, oldWinrow2 + 1, oldWincol2 + 1, RB$(2)
  2040.   GetBackground oldWinrow1 - 1, oldWincol1 - 1, oldWinrow2 + 1, oldWincol1 - 1, RB$(3)
  2041.   GetBackground oldWinrow1 - 1, oldWincol2 + 1, oldWinrow2 + 1, oldWincol2 + 1, RB$(4)
  2042.   Box oldWinrow1 - 1, oldWincol1 - 1, oldWinrow2 + 1, oldWincol2 + 1, GloWindow(windo).highlight, GloWindow(windo).back, WindowBorder$(GloWindow(windo).windowType), 0
  2043. RETURN
  2044.  
  2045. ' ===========================================================================
  2046. ' Erase rubber band of current window
  2047. ' ===========================================================================
  2048.  
  2049. EraseRubberBand:
  2050.   PutBackground oldWinrow1 - 1, oldWincol1 - 1, RB$(1)
  2051.   PutBackground oldWinrow2 + 1, oldWincol1 - 1, RB$(2)
  2052.   PutBackground oldWinrow1 - 1, oldWincol1 - 1, RB$(3)
  2053.   PutBackground oldWinrow1 - 1, oldWincol2 + 1, RB$(4)
  2054.   RETURN
  2055.  
  2056. WindowDoHideTextCursor:
  2057.     LOCATE , , 0
  2058. RETURN
  2059.  
  2060.  
  2061. WindowDoShowTextCursor:
  2062.     IF currCursorRow <> 0 AND currCursorCol <> 0 THEN
  2063.         LOCATE currCursorRow, currCursorCol, 1
  2064.     ELSE
  2065.         LOCATE , , 0
  2066.     END IF
  2067. RETURN
  2068.  
  2069. ' ===========================================================================
  2070. ' If in edit mode, this routine gets info from the global arrays
  2071. ' ===========================================================================
  2072.  
  2073. WindowDoEditInit:
  2074.     row = GloWindow(windo).row1 + GloEdit(currEditField).row - 1
  2075.     col = GloWindow(windo).col1 + GloEdit(currEditField).col - 1
  2076.     fore = GloEdit(currEditField).fore
  2077.     back = GloEdit(currEditField).back
  2078.     visLength = GloEdit(currEditField).visLength
  2079.     maxLength = GloEdit(currEditField).maxLength
  2080.     editField$ = LEFT$(GloEdit(currEditField).text$, maxLength)
  2081.     insertMode = TRUE
  2082.     InsertKey = GetShiftState(7)
  2083.     
  2084.     ' =======================================================================
  2085.     ' Make sure everything's the right length
  2086.     ' =======================================================================
  2087.  
  2088.     x = INSTR(editField$, CHR$(0)) - 1
  2089.     IF x >= 0 THEN
  2090.         editField$ = LEFT$(editField$, x)
  2091.     END IF
  2092.  
  2093.     IF LEN(editField$) >= visLength THEN
  2094.         firstchar = LEN(editField$) - visLength + 2
  2095.         cursor = visLength - 1
  2096.     ELSE
  2097.         firstchar = 1
  2098.         cursor = LEN(editField$)
  2099.     END IF
  2100.  
  2101.     GOSUB WindowDoEditPrint
  2102.  
  2103. RETURN
  2104.  
  2105. ' ===========================================================================
  2106. ' Handles the edit kbd event trapping.  Some keys trigger events
  2107. ' (e.g. TAB is event ID #7)  Others affect the current edit field string (DEL)
  2108. ' ===========================================================================
  2109.  
  2110. WindowDoEditKbd:
  2111.     IF GetShiftState(7) = InsertKey THEN
  2112.         insertMode = TRUE
  2113.         LOCATE , , , 6, 7
  2114.     ELSE
  2115.         insertMode = FALSE
  2116.         LOCATE , , , 0, 7
  2117.     END IF
  2118.  
  2119.     LOCATE row, col + cursor, 1
  2120.  
  2121.     GOSUB WindowDoMouse
  2122.  
  2123.     ' =======================================================================
  2124.     ' Only call MenuInkey$ if menuType > 0
  2125.     ' =======================================================================
  2126.  
  2127.     IF GloWindow(windo).windowType < 0 THEN
  2128.         kbd$ = INKEY$
  2129.     ELSE
  2130.         kbd$ = MenuInkey$
  2131.     END IF
  2132.  
  2133.     ' =======================================================================
  2134.     ' Either key is an event, and the exitFlag is set, or something happens
  2135.     ' to the current edit string.
  2136.     ' =======================================================================
  2137.  
  2138.     SELECT CASE kbd$
  2139.         CASE CHR$(13)
  2140.             GloStorage.oldDialogEvent = 6          'Return
  2141.             ExitFlag = TRUE
  2142.         CASE CHR$(9)
  2143.             GloStorage.oldDialogEvent = 7          'Tab
  2144.             ExitFlag = TRUE
  2145.         CASE CHR$(0) + CHR$(15)
  2146.             GloStorage.oldDialogEvent = 8          'Back Tab
  2147.             ExitFlag = TRUE
  2148.         CASE CHR$(27)
  2149.             GloStorage.oldDialogEvent = 9          'Escape
  2150.             ExitFlag = TRUE
  2151.         CASE CHR$(0) + "H"
  2152.             GloStorage.oldDialogEvent = 10         'Up
  2153.             ExitFlag = TRUE
  2154.         CASE CHR$(0) + "P"
  2155.             GloStorage.oldDialogEvent = 11         'Down
  2156.             ExitFlag = TRUE
  2157.         CASE CHR$(0) + "M"                         'Right
  2158.             GOSUB WindowDoEditRight
  2159.         CASE CHR$(0) + "K"
  2160.             cursor = cursor - 1
  2161.             IF cursor < 0 THEN
  2162.                 cursor = cursor + 1
  2163.                 IF firstchar > 1 THEN
  2164.                     firstchar = firstchar - 1
  2165.                     GOSUB WindowDoEditPrint
  2166.                 END IF
  2167.             END IF
  2168.  
  2169.         CASE CHR$(0) + "S"
  2170.             IF cursor + firstchar <= LEN(editField$) THEN
  2171.                 editField$ = LEFT$(editField$, cursor + firstchar - 1) + RIGHT$(editField$, LEN(editField$) - (cursor + firstchar))
  2172.                 GOSUB WindowDoEditPrint
  2173.             END IF
  2174.         CASE CHR$(8)
  2175.             IF firstchar + cursor > 1 THEN
  2176.                 editField$ = LEFT$(editField$, cursor + firstchar - 2) + RIGHT$(editField$, LEN(editField$) - (cursor + firstchar) + 1)
  2177.                 GOSUB WindowDoEditPrint
  2178.                 SELECT CASE cursor
  2179.                     CASE 0
  2180.                         firstchar = firstchar - 1
  2181.                         GOSUB WindowDoEditPrint
  2182.                     CASE 1
  2183.                         IF firstchar > 1 THEN
  2184.                             firstchar = firstchar - 1
  2185.                             GOSUB WindowDoEditPrint
  2186.                         ELSE
  2187.                             cursor = cursor - 1
  2188.                         END IF
  2189.                     CASE ELSE
  2190.                         cursor = cursor - 1
  2191.                 END SELECT
  2192.             END IF
  2193.         CASE CHR$(0) + "G"                         'Home
  2194.             firstchar = 1
  2195.             cursor = 0
  2196.             GOSUB WindowDoEditPrint
  2197.         CASE CHR$(0) + "O"                         'End
  2198.             IF LEN(editField$) >= visLength THEN
  2199.                 cursor = visLength - 1
  2200.                 firstchar = LEN(editField$) - visLength + 2
  2201.                 GOSUB WindowDoEditPrint
  2202.             ELSE
  2203.                 firstchar = 1
  2204.                 cursor = LEN(editField$)
  2205.             END IF
  2206.         CASE CHR$(0) + "u"                         'Ctrl+end
  2207.             editField$ = LEFT$(editField$, firstchar + cursor - 1)
  2208.             GOSUB WindowDoEditPrint
  2209.         CASE "menu"
  2210.             GloStorage.oldDialogEvent = 20         'Menu
  2211.             ExitFlag = TRUE
  2212.  
  2213.         CASE CHR$(32) TO CHR$(255)                 'Alphanumeric
  2214.             IF insertMode THEN
  2215.                 IF LEN(editField$) < maxLength THEN
  2216.                     editField$ = LEFT$(editField$, cursor + firstchar - 1) + kbd$ + RIGHT$(editField$, LEN(editField$) - (cursor + firstchar) + 1)
  2217.                     GOSUB WindowDoEditPrint
  2218.                     GOSUB WindowDoEditRight
  2219.                 ELSE
  2220.                     BEEP
  2221.                 END IF
  2222.             ELSE
  2223.                 IF cursor + firstchar > LEN(editField$) THEN
  2224.                     IF LEN(editField$) < maxLength THEN
  2225.                         editField$ = editField$ + kbd$
  2226.                         MouseHide
  2227.                         PRINT kbd$;
  2228.                         MouseShow
  2229.                     END IF
  2230.                 ELSE
  2231.                     MID$(editField$, cursor + firstchar, 1) = kbd$
  2232.                     MouseHide
  2233.                     PRINT kbd$;
  2234.                     MouseShow
  2235.                 END IF
  2236.                        
  2237.                 GOSUB WindowDoEditRight
  2238.             END IF
  2239.  
  2240.     END SELECT
  2241. RETURN
  2242.  
  2243. ' ===========================================================================
  2244. ' Moves the cursor right 1 space.  This is used twice, so it is its own
  2245. ' routine
  2246. ' ===========================================================================
  2247.  
  2248. WindowDoEditRight:
  2249.     cursor = cursor + 1
  2250.     IF cursor + firstchar - 1 > LEN(editField$) THEN
  2251.         cursor = cursor - 1
  2252.     ELSEIF cursor + firstchar - 1 > maxLength THEN
  2253.         cursor = cursor - 1
  2254.     ELSEIF cursor = visLength THEN
  2255.         firstchar = firstchar + 1
  2256.         cursor = cursor - 1
  2257.         GOSUB WindowDoEditPrint
  2258.     END IF
  2259. RETURN
  2260.  
  2261. ' ===========================================================================
  2262. ' Upon exit, store the current edit field string back into the global array
  2263. ' ===========================================================================
  2264.  
  2265. WindowDoEditExit:
  2266.     GloEdit(currEditField).text$ = editField$ + CHR$(0)
  2267.     LOCATE , , 0, 6, 7
  2268. RETURN
  2269.  
  2270. ' ===========================================================================
  2271. ' Prints the edit field in the proper color, at the proper location
  2272. ' ===========================================================================
  2273.  
  2274. WindowDoEditPrint:
  2275.     MouseHide
  2276.     COLOR fore, back
  2277.     LOCATE row, col
  2278.     PRINT MID$(editField$ + SPACE$(visLength), firstchar, visLength);
  2279.     MouseShow
  2280. RETURN
  2281.  
  2282. END SUB
  2283.  
  2284. SUB WindowInit
  2285.  
  2286.     ' =======================================================================
  2287.     ' Initialize totals
  2288.     ' =======================================================================
  2289.  
  2290.     GloStorage.currWindow = -1
  2291.     GloStorage.numWindowsOpen = 0
  2292.     GloStorage.numButtonsOpen = 0
  2293.     GloStorage.numEditFieldsOpen = 0
  2294.  
  2295.     ' =======================================================================
  2296.     ' Clear all windows
  2297.     ' =======================================================================
  2298.  
  2299.     FOR A = 1 TO MAXWINDOW
  2300.         GloWindow(A).handle = -1
  2301.         GloWindow(A).row1 = 0
  2302.         GloWindow(A).col1 = 0
  2303.         GloWindow(A).row2 = 0
  2304.         GloWindow(A).col2 = 0
  2305.         GloWindow(A).fore = 0
  2306.         GloWindow(A).back = 0
  2307.         GloWindow(A).windowType = 0
  2308.         GloWindow(A).title = ""
  2309.         GloWindowStack(A) = -1
  2310.     NEXT A
  2311.  
  2312.     ' =======================================================================
  2313.     ' Clear all buttons
  2314.     ' =======================================================================
  2315.  
  2316.     FOR A = 1 TO MAXBUTTON
  2317.         GloButton(A).handle = -1
  2318.         GloButton(A).windowHandle = -1
  2319.         GloButton(A).text = ""
  2320.         GloButton(A).state = 0
  2321.         GloButton(A).buttonOn = FALSE
  2322.         GloButton(A).row1 = 0
  2323.         GloButton(A).col1 = 0
  2324.         GloButton(A).row2 = 0
  2325.         GloButton(A).col2 = 0
  2326.         GloButton(A).buttonType = 0
  2327.     NEXT A
  2328.  
  2329.     ' =======================================================================
  2330.     ' Clear all edit fields
  2331.     ' =======================================================================
  2332.  
  2333.     FOR A = 1 TO MAXEDITFIELD
  2334.         GloEdit(A).handle = 0
  2335.         GloEdit(A).windowHandle = 0
  2336.         GloEdit(A).text = ""
  2337.         GloEdit(A).row = 0
  2338.         GloEdit(A).col = 0
  2339.         GloEdit(A).visLength = 0
  2340.         GloEdit(A).maxLength = 0
  2341.         GloEdit(A).fore = 0
  2342.         GloEdit(A).back = 0
  2343.     NEXT A
  2344.  
  2345. END SUB
  2346.  
  2347. SUB WindowLine (row)
  2348.  
  2349.     ' =======================================================================
  2350.     ' If window is valid, draw a horizontal line at the row which is passed
  2351.     ' =======================================================================
  2352.  
  2353.     windo = WindowCurrent
  2354.     
  2355.     IF windo > 0 THEN
  2356.         IF row >= 1 OR row <= WindowRows(windo) THEN
  2357.  
  2358.             topRow = GloWindow(windo).row1
  2359.             leftCol = GloWindow(windo).col1 - 1
  2360.             rightCol = GloWindow(windo).col2 + 1
  2361.             border$ = WindowBorder$(GloWindow(windo).windowType)
  2362.  
  2363.             LOCATE topRow + row - 1, leftCol
  2364.             MouseHide
  2365.             COLOR GloWindow(windo).fore, GloWindow(windo).back
  2366.  
  2367.             IF MID$(border$, 11, 1) = " " THEN
  2368.                 PRINT STRING$(rightCol - leftCol + 1, CHR$(196))
  2369.             ELSE
  2370.                 PRINT MID$(border$, 10, 1); STRING$(rightCol - leftCol - 1, MID$(border$, 11, 1)); MID$(border$, 12, 1)
  2371.             END IF
  2372.            
  2373.             MouseShow
  2374.         END IF
  2375.     END IF
  2376.  
  2377. END SUB
  2378.  
  2379. SUB WindowLocate (row, col)
  2380.  
  2381.     ' =======================================================================
  2382.     ' If window is valid, assign the passed row and col to the global variables
  2383.     ' =======================================================================
  2384.  
  2385.     windo = WindowCurrent
  2386.     IF windo > 0 THEN
  2387.         GloWindow(windo).cursorRow = row
  2388.         GloWindow(windo).cursorCol = col
  2389.     END IF
  2390.  
  2391. END SUB
  2392.  
  2393. FUNCTION WindowNext
  2394.         
  2395.     ' =======================================================================
  2396.     ' Loop through window array, and find first unused window, return handle
  2397.     ' If no window found, return 0
  2398.     ' =======================================================================
  2399.  
  2400.     Found = FALSE
  2401.     A = 1
  2402.     WHILE A <= MAXWINDOW AND NOT Found
  2403.         IF GloWindow(A).handle = -1 THEN
  2404.             Found = TRUE
  2405.         ELSE
  2406.             A = A + 1
  2407.         END IF
  2408.     WEND
  2409.  
  2410.     IF Found THEN
  2411.         WindowNext = A
  2412.     ELSE
  2413.         WindowNext = 0
  2414.     END IF
  2415.  
  2416. END FUNCTION
  2417.  
  2418. SUB WindowOpen (handle, row1, col1, row2, col2, textFore, textBack, fore, back, highlight, movewin, closewin, sizewin, modalwin, borderchar, title$)
  2419.  
  2420.     ' =======================================================================
  2421.     ' Open Window!   First make sure coordinates are valid
  2422.     ' =======================================================================
  2423.     IF row1 > row2 THEN SWAP row1, row2
  2424.     IF col1 > col2 THEN SWAP col1, col2
  2425.  
  2426.     IF col1 >= MINCOL + 1 AND row1 >= MINROW + 1 AND col2 <= MAXCOL - 1 AND row2 <= MAXROW - 1 THEN
  2427.  
  2428.         ' ===================================================================
  2429.         ' Close window by save number if it already exists
  2430.         ' ===================================================================
  2431.  
  2432.         WindowClose handle
  2433.  
  2434.         ' ===================================================================
  2435.         ' Evaluate argument list to determine windowType
  2436.         ' ===================================================================
  2437.  
  2438.         IF movewin THEN windowType = 1
  2439.         IF closewin THEN windowType = windowType + 2
  2440.         IF sizewin THEN windowType = windowType + 4
  2441.         IF borderchar = 1 THEN windowType = windowType + 8
  2442.         IF borderchar = 2 THEN windowType = windowType + 16
  2443.         IF windowType = 0 THEN windowType = 99
  2444.         IF modalwin THEN windowType = -windowType
  2445.  
  2446.         border$ = WindowBorder(windowType)
  2447.  
  2448.         ' ===================================================================
  2449.         ' hide current window's shadow if it has one
  2450.         ' ===================================================================
  2451.  
  2452.         MouseHide
  2453.         IF GloStorage.numWindowsOpen > 0 THEN
  2454.             IF INSTR(WindowBorder$(GloWindow(GloWindowStack(GloStorage.numWindowsOpen)).windowType), "S") THEN
  2455.                 WindowShadowRefresh
  2456.             END IF
  2457.         END IF
  2458.  
  2459.         ' ===================================================================
  2460.         ' Assign new values to window array
  2461.         ' ===================================================================
  2462.  
  2463.         GloWindow(handle).handle = handle
  2464.         GloWindow(handle).row1 = row1
  2465.         GloWindow(handle).col1 = col1
  2466.         GloWindow(handle).row2 = row2
  2467.         GloWindow(handle).col2 = col2
  2468.         GloWindow(handle).cursorRow = 1
  2469.         GloWindow(handle).cursorCol = 1
  2470.         GloWindow(handle).fore = fore
  2471.         GloWindow(handle).back = back
  2472.         GloWindow(handle).textFore = textFore
  2473.         GloWindow(handle).textBack = textBack
  2474.         GloWindow(handle).highlight = highlight
  2475.         GloWindow(handle).windowType = windowType
  2476.         GloWindow(handle).title = title$
  2477.  
  2478.         ' ===================================================================
  2479.         ' Save background, then draw window
  2480.         ' ===================================================================
  2481.  
  2482.         BackgroundSave handle
  2483.         Box row1 - 1, col1 - 1, row2 + 1, col2 + 1, fore, back, border$, 1
  2484.         MouseShow
  2485.  
  2486.         ' ===================================================================
  2487.         ' Assign handle to currWindow, incr total windows, push handle on stack
  2488.         ' ===================================================================
  2489.  
  2490.         GloStorage.currWindow = handle
  2491.         GloStorage.numWindowsOpen = GloStorage.numWindowsOpen + 1
  2492.         GloWindowStack(GloStorage.numWindowsOpen) = handle
  2493.  
  2494.         ' ===================================================================
  2495.         ' Print window title, and shadow
  2496.         ' ===================================================================
  2497.  
  2498.         WindowPrintTitle
  2499.         IF INSTR(border$, "S") THEN
  2500.             WindowShadowSave
  2501.         END IF
  2502.     END IF
  2503.  
  2504. END SUB
  2505.  
  2506. SUB WindowPrint (printMode, text$)
  2507.  
  2508.     ' =======================================================================
  2509.     ' If window is valid, print text$ using mode printMode%.  See
  2510.     ' External documentation for details on printMode%
  2511.     ' =======================================================================
  2512.  
  2513.     windo = WindowCurrent
  2514.  
  2515.     IF windo > 0 THEN
  2516.         SELECT CASE printMode
  2517.  
  2518.             ' ===============================================================
  2519.             ' Truncate printing
  2520.             ' ===============================================================
  2521.  
  2522.             CASE 1, -1
  2523.                 length = WindowCols(windo) - GloWindow(windo).cursorCol + 1
  2524.                 LOCATE GloWindow(windo).row1 + GloWindow(windo).cursorRow - 1, GloWindow(windo).col1 + GloWindow(windo).cursorCol - 1
  2525.                 COLOR GloWindow(windo).textFore, GloWindow(windo).textBack
  2526.                 MouseHide
  2527.                 PRINT LEFT$(text$, length);
  2528.                 MouseShow
  2529.                 IF printMode < 0 THEN
  2530.                     GloWindow(windo).cursorCol = GloWindow(windo).cursorCol + LEN(text$)
  2531.                     IF GloWindow(windo).cursorCol > WindowCols(windo) THEN
  2532.                         GloWindow(windo).cursorCol = WindowCols(windo) + 1
  2533.                     END IF
  2534.                 ELSE
  2535.                     GloWindow(windo).cursorRow = GloWindow(windo).cursorRow + 1
  2536.                     GloWindow(windo).cursorCol = 1
  2537.                     IF GloWindow(windo).cursorRow > WindowRows(windo) THEN
  2538.                         WindowScroll 1
  2539.                         GloWindow(windo).cursorRow = WindowRows(windo)
  2540.                     END IF
  2541.                 END IF
  2542.             ' ===============================================================
  2543.             ' Character wrapping
  2544.             ' ===============================================================
  2545.  
  2546.             CASE 2, -2
  2547.                 COLOR GloWindow(windo).textFore, GloWindow(windo).textBack
  2548.                 A$ = text$
  2549.                 WHILE LEN(A$) > 0
  2550.                     length = WindowCols(windo) - GloWindow(windo).cursorCol + 1
  2551.                     LOCATE GloWindow(windo).row1 + GloWindow(windo).cursorRow - 1, GloWindow(windo).col1 + GloWindow(windo).cursorCol - 1
  2552.  
  2553.                     MouseHide
  2554.                     PRINT LEFT$(A$, length);
  2555.                     MouseShow
  2556.  
  2557.                     IF length < LEN(A$) THEN
  2558.                         A$ = RIGHT$(A$, LEN(A$) - length)
  2559.                         GloWindow(windo).cursorRow = GloWindow(windo).cursorRow + 1
  2560.                         GloWindow(windo).cursorCol = 1
  2561.                         IF GloWindow(windo).cursorRow > WindowRows(windo) THEN
  2562.                             WindowScroll 1
  2563.                             GloWindow(windo).cursorRow = WindowRows(windo)
  2564.                         END IF
  2565.                     ELSE
  2566.                         IF printMode < 0 THEN
  2567.                             GloWindow(windo).cursorCol = GloWindow(windo).cursorCol + LEN(A$)
  2568.                             IF GloWindow(windo).cursorCol > WindowCols(windo) THEN
  2569.                                 GloWindow(windo).cursorCol = WindowCols(windo) + 1
  2570.                             END IF
  2571.                         ELSE
  2572.                             GloWindow(windo).cursorRow = GloWindow(windo).cursorRow + 1
  2573.                             GloWindow(windo).cursorCol = GloWindow(windo).cursorCol
  2574.                             IF GloWindow(windo).cursorRow > WindowRows(windo) THEN
  2575.                                 WindowScroll 1
  2576.                                 GloWindow(windo).cursorRow = WindowRows(windo)
  2577.                             END IF
  2578.                         END IF
  2579.                         A$ = ""
  2580.                     END IF
  2581.                 WEND
  2582.  
  2583.             ' ===============================================================
  2584.             ' Word wrapping
  2585.             ' ===============================================================
  2586.  
  2587.             CASE 3, -3
  2588.                 COLOR GloWindow(windo).textFore, GloWindow(windo).textBack
  2589.                 A$ = text$
  2590.                 WHILE LEN(A$) > 0
  2591.                     length = WindowCols(windo) - GloWindow(windo).cursorCol + 1
  2592.                     LOCATE GloWindow(windo).row1 + GloWindow(windo).cursorRow - 1, GloWindow(windo).col1 + GloWindow(windo).cursorCol - 1
  2593.  
  2594.                     IF length < LEN(A$) THEN
  2595.                         x = length + 1
  2596.                         b$ = " " + A$
  2597.                         WHILE MID$(b$, x, 1) <> " "
  2598.                             x = x - 1
  2599.                         WEND
  2600.                         x = x - 1
  2601.  
  2602.                         MouseHide
  2603.                         IF x = 0 THEN
  2604.                             PRINT LEFT$(A$, length);
  2605.                             A$ = RIGHT$(A$, LEN(A$) - length)
  2606.                         ELSE
  2607.                             PRINT LEFT$(A$, x);
  2608.                             A$ = RIGHT$(A$, LEN(A$) - x)
  2609.                         END IF
  2610.                         MouseShow
  2611.  
  2612.                         x = 1
  2613.                         b$ = A$ + " "
  2614.                         WHILE MID$(b$, x, 1) = " "
  2615.                             x = x + 1
  2616.                         WEND
  2617.  
  2618.                         IF x = LEN(b$) THEN
  2619.                             A$ = ""
  2620.                         ELSEIF x > 1 THEN
  2621.                             A$ = RIGHT$(A$, LEN(A$) - x + 1)
  2622.                         END IF
  2623.                            
  2624.                         GloWindow(windo).cursorRow = GloWindow(windo).cursorRow + 1
  2625.                         GloWindow(windo).cursorCol = 1
  2626.                         IF GloWindow(windo).cursorRow > WindowRows(windo) THEN
  2627.                             WindowScroll 1
  2628.                             GloWindow(windo).cursorRow = WindowRows(windo)
  2629.                         END IF
  2630.                     ELSE
  2631.  
  2632.                     MouseHide
  2633.                     PRINT LEFT$(A$, length);
  2634.                     MouseShow
  2635.                         IF printMode < 0 THEN
  2636.                             GloWindow(windo).cursorCol = GloWindow(windo).cursorCol + LEN(A$)
  2637.                             IF GloWindow(windo).cursorCol > WindowCols(windo) THEN
  2638.                                 GloWindow(windo).cursorCol = WindowCols(windo) + 1
  2639.                             END IF
  2640.                         ELSE
  2641.                             GloWindow(windo).cursorRow = GloWindow(windo).cursorRow + 1
  2642.                             GloWindow(windo).cursorCol = GloWindow(windo).cursorCol
  2643.                             IF GloWindow(windo).cursorRow > WindowRows(windo) THEN
  2644.                                 WindowScroll 1
  2645.                                 GloWindow(windo).cursorRow = WindowRows(windo)
  2646.                             END IF
  2647.                         END IF
  2648.                         A$ = ""
  2649.                     END IF
  2650.                 WEND
  2651.  
  2652.             ' ===============================================================
  2653.             ' Centered text printing
  2654.             ' ===============================================================
  2655.  
  2656.             CASE 4
  2657.                 COLOR GloWindow(windo).textFore, GloWindow(windo).textBack
  2658.                 IF LEN(text$) >= WindowCols(windo) THEN
  2659.                     LOCATE GloWindow(windo).row1 + GloWindow(windo).cursorRow - 1, GloWindow(windo).col1
  2660.                     MouseHide
  2661.                     PRINT LEFT$(text$, length);
  2662.                     MouseShow
  2663.                 ELSE
  2664.                     LOCATE GloWindow(windo).row1 + GloWindow(windo).cursorRow - 1, GloWindow(windo).col1 - 1 + INT((WindowCols(windo) / 2) + .9) - LEN(text$) / 2
  2665.                     MouseHide
  2666.                     PRINT text$
  2667.                     MouseShow
  2668.                 END IF
  2669.  
  2670.                 GloWindow(windo).cursorRow = GloWindow(windo).cursorRow + 1
  2671.                 GloWindow(windo).cursorCol = 1
  2672.                 IF GloWindow(windo).cursorRow > WindowRows(windo) THEN
  2673.                     WindowScroll 1
  2674.                     GloWindow(windo).cursorRow = WindowRows(windo)
  2675.                 END IF
  2676.         END SELECT
  2677.     END IF
  2678.  
  2679. END SUB
  2680.  
  2681. SUB WindowPrintTitle
  2682.  
  2683.     ' =======================================================================
  2684.     ' Print title of current window if the border$ says it's valid
  2685.     ' =======================================================================
  2686.  
  2687.     windo = WindowCurrent
  2688.     IF windo > 0 THEN
  2689.  
  2690.         title$ = GloWindow(windo).title
  2691.         border$ = WindowBorder$(GloWindow(windo).windowType)
  2692.  
  2693.         
  2694.         IF INSTR(border$, "T") THEN
  2695.             tx$ = RTRIM$(title$)
  2696.             IF LEN(tx$) > 0 THEN
  2697.                 COLOR GloWindow(windo).highlight, GloWindow(windo).back
  2698.                 MouseHide
  2699.                 length = WindowCols(windo)
  2700.                 IF (LEN(tx$) + 2) < length THEN
  2701.                     LOCATE GloWindow(windo).row1 - 1, GloWindow(windo).col1 + INT(length / 2 - LEN(tx$) / 2) - 1
  2702.                     PRINT " "; tx$; " ";
  2703.                 ELSE
  2704.                     LOCATE GloWindow(windo).row1 - 1, GloWindow(windo).col1
  2705.                     PRINT LEFT$(" " + tx$ + " ", (GloWindow(windo).col2 - GloWindow(windo).col1 + 1))
  2706.                 END IF
  2707.                 MouseShow
  2708.             END IF
  2709.         END IF
  2710.     END IF
  2711.     
  2712. END SUB
  2713.  
  2714. SUB WindowRefresh (handle)
  2715.  
  2716.     ' =======================================================================
  2717.     ' Refresh the window -- used for window move, window resize, and
  2718.     ' WindowSetCurrent
  2719.     ' =======================================================================
  2720.  
  2721.     IF GloWindow(handle).handle > 0 THEN
  2722.         MouseHide
  2723.         PutBackground GloWindow(handle).row1 - 1, GloWindow(handle).col1 - 1, GloBuffer$(handle, 2)
  2724.         MouseShow
  2725.     END IF
  2726.  
  2727. END SUB
  2728.  
  2729. FUNCTION WindowRows (handle)
  2730.  
  2731.     ' =======================================================================
  2732.     ' Returns number of rows if handle is a valid window
  2733.     ' =======================================================================
  2734.  
  2735.     IF GloWindow(handle).handle > 0 THEN
  2736.         WindowRows = GloWindow(handle).row2 - GloWindow(handle).row1 + 1
  2737.     END IF
  2738.  
  2739. END FUNCTION
  2740.  
  2741. SUB WindowSave (handle)
  2742.  
  2743.     ' =======================================================================
  2744.     ' Saves the window handle%
  2745.     ' =======================================================================
  2746.  
  2747.     IF GloWindow(handle).handle > 0 THEN
  2748.         MouseHide
  2749.         GetBackground GloWindow(handle).row1 - 1, GloWindow(handle).col1 - 1, GloWindow(handle).row2 + 1, GloWindow(handle).col2 + 1, GloBuffer$(handle, 2)
  2750.         MouseShow
  2751.     END IF
  2752.  
  2753. END SUB
  2754.  
  2755. SUB WindowScroll (lines)
  2756.  
  2757.     ' =======================================================================
  2758.     ' Scroll just the window area.
  2759.     ' =======================================================================
  2760.     
  2761.     windo = WindowCurrent
  2762.     IF windo > 0 THEN
  2763.         MouseHide
  2764.         CALL Scroll(GloWindow(windo).row1, GloWindow(windo).col1, GloWindow(windo).row2, GloWindow(windo).col2, lines, GloWindow(windo).back)
  2765.         MouseShow
  2766.     END IF
  2767.  
  2768. END SUB
  2769.  
  2770. SUB WindowSetCurrent (handle)
  2771.  
  2772.     ' =======================================================================
  2773.     ' If window is valid, and not already the current window
  2774.     ' =======================================================================
  2775.  
  2776.     IF GloWindow(handle).handle <> -1 AND handle <> WindowCurrent THEN
  2777.  
  2778.         ' ===================================================================
  2779.         ' If current window has a shadow, hide the shadow
  2780.         ' ===================================================================
  2781.  
  2782.         MouseHide
  2783.         IF INSTR(WindowBorder$(GloWindow(GloStorage.currWindow).windowType), "S") THEN
  2784.             WindowShadowRefresh
  2785.         END IF
  2786.  
  2787.         ' ===================================================================
  2788.         ' Save all windows on top of the one to be current, and refresh the
  2789.         ' background of each
  2790.         ' ===================================================================
  2791.  
  2792.         x = GloStorage.numWindowsOpen
  2793.         WHILE GloWindowStack(x) <> handle
  2794.             WindowSave GloWindowStack(x)
  2795.             BackgroundRefresh GloWindowStack(x)
  2796.             x = x - 1
  2797.         WEND
  2798.  
  2799.         ' ===================================================================
  2800.         ' Save the window to be made the current window
  2801.         ' ===================================================================
  2802.  
  2803.         WindowSave handle
  2804.         BackgroundRefresh handle
  2805.  
  2806.         ' ===================================================================
  2807.         ' Replace each window that was on top of handle, and squeeze stack
  2808.         ' ===================================================================
  2809.  
  2810.         IF handle <> GloWindowStack(GloStorage.numWindowsOpen) THEN
  2811.             FOR A = x + 1 TO GloStorage.numWindowsOpen
  2812.                 BackgroundSave GloWindowStack(A)
  2813.                 WindowRefresh GloWindowStack(A)
  2814.                 GloBuffer$(GloWindowStack(A), 2) = ""
  2815.                 GloWindowStack(A - 1) = GloWindowStack(A)
  2816.             NEXT A
  2817.         END IF
  2818.  
  2819.         ' ===================================================================
  2820.         ' Save new background of new current window.
  2821.         ' ===================================================================
  2822.  
  2823.         BackgroundSave handle
  2824.         WindowRefresh handle
  2825.         GloBuffer$(handle, 2) = ""
  2826.         MouseShow
  2827.  
  2828.         GloStorage.currWindow = handle
  2829.         GloWindowStack(GloStorage.numWindowsOpen) = handle
  2830.  
  2831.         ' ===================================================================
  2832.         ' Show shadow if current window has one
  2833.         ' ===================================================================
  2834.  
  2835.         IF INSTR(WindowBorder$(GloWindow(handle).windowType), "S") THEN
  2836.             WindowShadowSave
  2837.         END IF
  2838.  
  2839.     END IF
  2840.  
  2841. END SUB
  2842.  
  2843. SUB WindowShadowRefresh
  2844.  
  2845.     ' =======================================================================
  2846.     ' If window is current, replace what was under the shadow
  2847.     ' =======================================================================
  2848.  
  2849.     windo = WindowCurrent
  2850.     IF windo > 0 THEN
  2851.         row1 = GloWindow(windo).row1
  2852.         row2 = GloWindow(windo).row2
  2853.         col1 = GloWindow(windo).col1
  2854.         col2 = GloWindow(windo).col2
  2855.  
  2856.         ' ===================================================================
  2857.         ' If shadow partially (or fully) off screen, adjust coordinates
  2858.         ' ===================================================================
  2859.  
  2860.         MouseHide
  2861.         IF col1 <= MAXCOL - 2 THEN
  2862.             PutBackground row1, col2 + 2, GloBuffer$(MAXWINDOW + 1, 1)
  2863.         END IF
  2864.         IF row2 <= MAXROW - 2 THEN
  2865.             PutBackground row2 + 2, col1 + 1, GloBuffer$(MAXWINDOW + 1, 2)
  2866.         END IF
  2867.         MouseShow
  2868.     END IF
  2869.  
  2870. END SUB
  2871.  
  2872. SUB WindowShadowSave
  2873.  
  2874.     ' =======================================================================
  2875.     ' If current window valid, draw the shadow, storing what is underneath
  2876.     ' it first.
  2877.     ' =======================================================================
  2878.  
  2879.     windo = WindowCurrent
  2880.  
  2881.     IF windo > 0 THEN
  2882.         row1 = GloWindow(windo).row1
  2883.         row2 = GloWindow(windo).row2
  2884.         col1 = GloWindow(windo).col1
  2885.         col2 = GloWindow(windo).col2
  2886.  
  2887.         ' ===================================================================
  2888.         ' If shadow is partially, or fully off screen, adjust coordinates
  2889.         ' ===================================================================
  2890.  
  2891.         IF col2 > MAXCOL - 2 THEN
  2892.             shadowWidth = -1
  2893.         ELSEIF col2 = MAXCOL - 2 THEN
  2894.             shadowWidth = 0
  2895.         ELSE
  2896.             shadowWidth = 1
  2897.         END IF
  2898.  
  2899.         MouseHide
  2900.  
  2901.         ' ===================================================================
  2902.         ' Save background, the draw shadow
  2903.         ' ===================================================================
  2904.  
  2905.         IF col2 <= MAXCOL - 2 THEN
  2906.             GetBackground row1, col2 + 2, row2 + 1, col2 + 2 + shadowWidth, GloBuffer$(MAXWINDOW + 1, 1)
  2907.             AttrBox row1, col2 + 2, row2 + 1, col2 + 2 + shadowWidth, 8
  2908.         END IF
  2909.  
  2910.         IF row2 <= MAXROW - 2 THEN
  2911.             GetBackground row2 + 2, col1 + 1, row2 + 2, col2 + 2 + shadowWidth, GloBuffer$(MAXWINDOW + 1, 2)
  2912.             AttrBox row2 + 2, col1 + 1, row2 + 2, col2 + 2 + shadowWidth, 8
  2913.         END IF
  2914.         MouseShow
  2915.     END IF
  2916.  
  2917. END SUB
  2918.  
  2919.