home *** CD-ROM | disk | FTP | other *** search
- '
- '
- '******************************************************************************
- ' Function : POPLIST *
- ' *
- ' Purpose: *
- ' *
- ' *
- ' Results: *
- ' *
- ' Usage : *
- ' *
- ' *
- ' Date Written : 09/01/90 - Date Tested: 09/01/90 - Author: James P Morgan *
- ' Date Modified: - : - : *
- '-----------------------------------------------------------------------------*
- ' NOTE: *
- '******************************************************************************
- ' *
- ' SUB PROGRAM NAME (PARAMETERS) STATIC/RECURSIVE *
- '-----------------------------------------------------------------------------*
- ' *
- SUB POPLIST(HEADER$,SHOWITEMS%,MAXITEMS%,ITEM$(1),FORE%,BACK%,HFORE%,HBACK%,QUADRANT$,SHADOW%,SELECT.%,RETURN.CODE%) STATIC
-
- DEFINT A-Z 'make all short intergers by default
-
- RETURN.CODE%=0
- MAKEWIND.RETURN.CODE%=0
- SETQUAD.RETURN.CODE%=0
- VIDEO.RETURN.CODE%=0
-
- ITEM.MIN=LBOUND(ITEM$) 'adjust for callers OPTION BASE
- ITEM.MAX=UBOUND(ITEM$) 'save array upper limits
-
- SELECT.BASE=1-ITEM.MIN 'normalize to a base of 1
-
- '
- ' add code to check that MAXITEMS dosnt go outside array bounds (+ or -)
- '
- IF SHOWITEMS%> MAXITEMS% THEN 'we cant show more than whats avail
- SHOWITEMS%=MAXITEMS%
- END IF
-
- TEMP.ITEM$=STRING$(255," ")
-
- BEGVAL=1
-
- MENU.TOP.ROW=0
- MENU.TOP.LEFT.COL=0
- MENU.BOTTOM.ROW=0
- MENU.BOTTOM.RIGHT.COL=0
-
- BUTTONS%=0 'assume no mouse support avail
-
- CALL MMCHECK(BUTTONS%) 'see if mouse support avail
-
- GOSUB POPLIST.MMCURSORON
-
- MOUSECOL=0 'locate the mouse cursor in upper
- MOUSEROW=0 'left top corner of screen
-
- CALL MMSETLOC(MOUSECOL,MOUSEROW) 'move the mouse cursor
-
- FIRST.TIME=-1
-
- GOSUB POPLIST.MMCURSOROFF
-
- '
- WINDLEN=LEN(HEADER$) 'assume window length is header length
-
- 'Determine width of window from length of longest item
- FOR J=ITEM.MIN TO ITEM.MIN+MAXITEMS%
- ASCIIZ=INSTR(ITEM$(J),CHR$(0)) 'a string may have imbedded
- LEN.ITEM=ASCIIZ-1 'null x'00', to allow only part
- 'of string to be displayed
- IF LEN.ITEM<1 THEN
- LEN.ITEM=LEN(ITEM$(J))
- END IF
-
- IF LEN.ITEM > WINDLEN THEN
- WINDLEN=LEN.ITEM
- END IF
-
- NEXT
-
- LENGTH.MENU.ITEM=WINDLEN 'this is the length of the longest item
-
- 'If Quadrant is in ROW:COL format, extract Row and Column
-
- IF INSTR(QUADRANT$,":")<>0 THEN 'was an absolute row:column specified
- GOSUB POPLIST.GETORD
- GOTO POPLIST.GO1
- END IF
-
- 'Determine Position based on Quadrant Parameter and size of menu
-
- QUADRANT=VAL(QUADRANT$) 'The window is to be in 1 of the 5 quadrants
-
- IF QUADRANT <0 OR QUADRANT >4 THEN 'make sure the quadrant is valid
- QUADRANT=0 'if invalid, default to center of screen
- END IF
-
- CALL SETQUAD(QUADRANT,CROW,CCOL,WINDLEN,SHOWITEMS%,SETQUAD.RETURN.CODE)
-
- ULR%=CROW-(((SHOWITEMS%+2)/2)-.5) 'the upper left row:column window co-ordinates
- ULC%=CCOL-((WINDLEN/2)-.5)
- LRR%=ULR%+SHOWITEMS%+1 'the lower right window co-ordinates
- LRC%=ULC%+WINDLEN-1
-
- '
- 'Create Window for List
- POPLIST.GO1:
- MENU.TOP.ROW=ULR%+2 'allow for the menu name box above the window
- MENU.TOP.LEFT.COL=ULC%
- MENU.BOTTOM.ROW=LRR%
- MENU.BOTTOM.RIGHT.COL=LRC%
-
- FRAME%=4
-
- CALL MAKEWIND(ULR%,ULC%,LRR%,LRC%,FRAME,FORE%,BACK%,GROW,SHADOW%,LABEL$,MAKEWIND.RETURN.CODE)
-
- TEMPHDR$=SPACE$(WINDLEN) 'make menu header as big as biggest item
-
- IF LEN(HEADER$)<>WINDLEN THEN 'does the menu header need centering?
- GOSUB POPLIST.PUTHDR 'YES
- END IF
-
- ATTR=(HBACK% AND 7)*16+HFORE% 'display the menu header
- ROW=ULR%
- COL=ULC%
- CALL FASTPRT(HEADER$,ROW,COL,ATTR,VIDEO.RETURN.CODE)
-
- ATTR=(BACK% AND 7)*16+FORE% 'bracket the menu header in the window
- ROW=ULR%+1
- COL=ULC%
- DAT$=STRING$(WINDLEN,205)
- CALL FASTPRT(DAT$,ROW,COL,ATTR,VIDEO.RETURN.CODE)
-
- 'Set current choice to List Item #1, Set Beginning and Ending values,
- 'Display 'More...' message and enter Loop
-
-
- IF (SELECT.%<1) OR (SELECT.%>MAXITEMS%) THEN 'is first item to be displayed valid range?
- SELECT.%=1 'NO, so display first one by default
- END IF
-
- FIRST.SELECT=SELECT.% 'remember the first item to display
-
- SELECT.%=1 'display the first group of items
- OLD=SELECT.%
-
- BEGVAL=SELECT.% 'starting with the first item
- ENDVAL=SHOWITEMS% 'and ending with the max we can display at once
-
- GOSUB POPLIST.FILL
-
- IF FIRST.SELECT<>1 THEN 'do we really want to display another item first?
- TEMP.SELECT=FIRST.SELECT 'yes, make it so
- GOSUB POPLIST.FOUND.IT
- END IF
-
- FIRST.TIME=0
-
- '
- POPLIST.LOOP:
- GOSUB POPLIST.PRESS 'Get KeyPress
-
- IF KP$=CHR$(13) OR KP$=CHR$(27) THEN 'was Enter or ESC key pressed?
- GOTO POPLIST.DONE 'yes, were are thru
- END IF
-
- GOTO POPLIST.LOOP 'keep waiting for user to press a key
-
- '
- 'Check for KeyPress and sound error if not UP ARROW, DOWN ARROW, HOME, END, PAGE UP, PAGE DOWN, or RETURN
- POPLIST.PRESS:
- CLICK=-1 'flush any mouse clicks
- DO WHILE CLICK
- LFT%=0
- RGT%=0
- CALL MMCLICK(LFT%,RGT%)
- CLICK=LFT%+RGT%
- LOOP
-
- GOSUB POPLIST.GET.PRESS
-
- IF KP$="" THEN 'wait for a key or mouse click
- GOTO POPLIST.PRESS
- END IF
-
- IF LEN(KP$)=2 THEN 'was an extended function key pressed?
- GOTO POPLIST.DOWN 'yes
- END IF
-
- POPLIST.PRESS.ON:
- IF KP$=CHR$(13) THEN 'Enter key pressed?
- RETURN
- END IF
-
- IF KP$=CHR$(27) THEN 'ESC key pressed
- SELECT.%=0 'nothing noted as being selected
- RETURN
- END IF
-
- GOSUB POPLIST.FIND.OPTION 'find the first char of an item that matches key pressed
-
- IF SELECT.%<>SAVE.SELECT THEN 'was a new item found?
- RETURN 'YES
- END IF
-
- GOSUB POPLIST.SOUNDOFF 'NO, a new item not found!
- GOTO POPLIST.PRESS
-
- '
- 'Process DOWN ARROW KeyPress
- POPLIST.DOWN:
- IF ASC(RIGHT$(KP$,1))=80 THEN 'was cursor down key pressed?
- SELECT.%=SELECT.%+1 'this is the new item we want highlighted
- ELSE
- GOTO POPLIST.UP 'NO, see if cursor up
- END IF
-
- IF SELECT.% > MAXITEMS% THEN 'are we at the end of the items?
- IF SHOWITEMS%=MAXITEMS% THEN 'is this a POPMENU
- BEGVAL=1 'loop back to top of menu items
- OLD=MAXITEMS% 'point to current item highlighted
- SELECT.%=1 'point to next item to highlight
- ENDVAL=MAXITEMS% 'point to last menu item to display
- GOSUB POPLIST.FILL
- RETURN
- ELSE
- SELECT.% = MAXITEMS% 'cant go past the end!
- GOSUB POPLIST.SOUNDOFF
- RETURN
- END IF
- END IF
-
- IF (SELECT.% > ENDVAL) AND (SELECT.% = MAXITEMS%) THEN
- BEGVAL=BEGVAL+1
- ENDVAL=ENDVAL+1
- OLD=0
- GOSUB POPLIST.FILL
- RETURN
- END IF
-
- '
- ' have we requested an item on the next screen of items
- '
- IF (SELECT.% > ENDVAL) AND (SELECT.% <> MAXITEMS%) THEN
- BEGVAL=BEGVAL+1
- ENDVAL=ENDVAL+1
- OLD=0
- GOSUB POPLIST.FILL
- RETURN
- END IF
-
- '
- ' highlight the next item
- '
- GOSUB POPLIST.FILL
- RETURN
-
- '
- 'Process UP ARROW KeyPress
- POPLIST.UP:
- IF ASC(RIGHT$(KP$,1))=72 THEN 'was cursor up key pressed?
- SELECT.%=SELECT.%-1 'this is the new item we want highlighted
- ELSE
- GOTO POPLIST.PG.UP 'NO, see if page up
- END IF
-
- IF SELECT.% < 1 THEN 'are we at the top of the items?
- IF SHOWITEMS%=MAXITEMS% THEN 'is this a POPMENU
- BEGVAL=1 'loop back to bottom of menu items
- OLD=BEGVAL 'point to current highlighted item
- SELECT.%=MAXITEMS% 'point to next item to highlight
- ENDVAL=MAXITEMS% 'point to last item to display
- GOSUB POPLIST.FILL
- RETURN
- ELSE
- SELECT.% = 1 'cant go past the top!
- GOSUB POPLIST.SOUNDOFF
- RETURN
- END IF
- END IF
-
- IF (SELECT.% < BEGVAL) AND (SELECT.% = 1) THEN
- BEGVAL=BEGVAL-1
- ENDVAL=ENDVAL-1
- OLD=0
- GOSUB POPLIST.FILL
- RETURN
- END IF
-
- '
- ' have we requested an item on the next screen of items
- '
- IF (SELECT.% < BEGVAL) AND (SELECT.% <> 1) THEN
- BEGVAL=BEGVAL-1
- ENDVAL=ENDVAL-1
- OLD=0
- GOSUB POPLIST.FILL
- RETURN
- END IF
-
- '
- ' highlight the next item
- '
- GOSUB POPLIST.FILL
- RETURN
-
- '
- 'Process PAGE UP KeyPress
- POPLIST.PG.UP:
- IF ASC(RIGHT$(KP$,1))=73 THEN 'was page up key pressed?
- OLD=SELECT.% 'this is the current item highlighted
- SELECT.%=SELECT.%-SHOWITEMS% 'this is the new item we want highlighted
- ELSE
- GOTO POPLIST.PG.DN 'NO, see if cursor down
- END IF
-
- IF SELECT.% < 1 THEN 'are we at the first screen of items?
- KP$=CHR$(0)+CHR$(79) 'simulate a END key press
- SELECT.%=OLD
- GOTO POPLIST.ENDK
- END IF
-
- BEGVAL=BEGVAL-SHOWITEMS% 'calculate the first and last items in next screen
- ENDVAL=ENDVAL-SHOWITEMS%
-
- IF BEGVAL < 1 THEN 'we cant go past first item
- BEGVAL=1 'point to first item
- ENDVAL=SHOWITEMS%
- END IF
-
- GOSUB POPLIST.FILL 'highlight the item
- RETURN
-
- '
- 'Process PAGE DOWN KeyPress
- POPLIST.PG.DN:
- IF ASC(RIGHT$(KP$,1))=81 THEN 'was page down key pressed?
- OLD=SELECT.% 'this is the current item highlighted
- SELECT.%=SELECT.%+SHOWITEMS% 'this is the new item we want highlighted
- ELSE
- GOTO POPLIST.HOME 'NO, see if home pressed
- END IF
-
- IF SELECT.% > MAXITEMS% THEN 'are we at the last screen of items?
- IF ENDVAL>=MAXITEMS% THEN
- KP$=CHR$(0)+CHR$(71) 'simulate a HOME key press
- SELECT.%=OLD
- GOTO POPLIST.HOME
- END IF
- END IF
-
- BEGVAL=BEGVAL+SHOWITEMS% 'calculate the first and last items in next screen
- ENDVAL=ENDVAL+SHOWITEMS%
-
- IF ENDVAL > MAXITEMS% THEN 'we cant go past the last item
- ENDVAL=MAXITEMS% 'point to last item
- BEGVAL=(ENDVAL-SHOWITEMS%)+1
- OLD=ENDVAL
- SELECT.%=OLD
-
- END IF
-
- GOSUB POPLIST.FILL 'highlight the item
- RETURN
-
- '
- 'Process HOME KeyPress
- POPLIST.HOME:
- IF ASC(RIGHT$(KP$,1))=71 THEN 'was home key pressed?
- OLD=SELECT.% 'this is the current item highlighted
- ELSE
- GOTO POPLIST.ENDK 'NO, see if end key pressed
- END IF
-
- IF SELECT.%=1 THEN
- GOSUB POPLIST.SOUNDOFF
- RETURN
- END IF
-
- SELECT.%=1 'display the first group of items
- OLD=SELECT.% 'force new screen re-display
- BEGVAL=1 'point to the first item
- ENDVAL=BEGVAL+SHOWITEMS%-1 'and display the first screen of this many items
- GOSUB POPLIST.FILL
- RETURN
-
- '
- 'Process END KeyPress
- POPLIST.ENDK:
- IF ASC(RIGHT$(KP$,1))=79 THEN 'was end key pressed?
- OLD=SELECT.% 'this is the current item highlighted
- ELSE
- GOTO POPLIST.ERRCHK 'NO, let user know invalid key pressed
- END IF
-
- IF SELECT.%=MAXITEMS% THEN
- GOSUB POPLIST.SOUNDOFF
- RETURN
- END IF
-
- SELECT.%=MAXITEMS% 'display the last group of items
- OLD=SELECT.% 'force new screen re-display
- ENDVAL=MAXITEMS% 'point to the last item
- BEGVAL=ENDVAL-SHOWITEMS%+1 'display screen of last group of items
-
- GOSUB POPLIST.FILL
- RETURN
-
- '
- 'Process ERROR
- POPLIST.ERRCHK:
- GOSUB POPLIST.SOUNDOFF 'let user know problem/error
- GOTO POPLIST.PRESS
-
- '
- 'Fill Contents of window
- POPLIST.FILL:
- IF BEGVAL < 1 THEN 'make sure we dont go out of bounds
- BEGVAL=1
- END IF
-
- IF ENDVAL > MAXITEMS% THEN 'make sure we dont go past the end of the items
- ENDVAL=MAXITEMS%
- END IF
-
- OFFSET=ENDVAL-SELECT.%
-
- IF OFFSET < 0 THEN
- OFFSET = 0
- ELSEIF OFFSET > SHOWITEMS%-1 THEN
- OFFSET = SHOWITEMS%-1
- END IF
-
- GOSUB POPLIST.MMCURSOROFF
-
- '
- ' If next item to be hi-lited is on same screen already display, dont re-
- ' display all options, BUT turn off current hi-lited option and just turn
- ' on next item to be hi-lited (on this screen of options).
- '
- IF OLD<>SELECT.% THEN
- IF (OLD>=BEGVAL) AND (OLD<=ENDVAL) THEN
- ATTR=(BACK% AND 7)*16+FORE%
-
- ROW=ROW
- COL=ULC%
-
- DAT$=ITEM$(OLD-SELECT.BASE)
-
- ASCIIZ=INSTR(DAT$,CHR$(0)) 'display ONLY the string upto
- IF ASCIIZ>1 THEN 'a null x'00' if one is imbedded
- DAT$=LEFT$(DAT$,ASCIIZ-1)
- END IF
-
- DAT$=DAT$+SPACE$(WINDLEN) 'make all items the same length
- DAT$=LEFT$(DAT$,WINDLEN) 'when they are displayed
-
- CALL FASTPRT(DAT$,ROW,COL,ATTR,VIDEO.RETURN.CODE)
- GOTO POPLIST.HILITE
- END IF
- END IF
-
-
- '
- K=1
-
- '
- ' display the group of items we need
- '
-
- FOR J=BEGVAL TO ENDVAL
- ATTR=(BACK% AND 7)*16+FORE%
- ROW=(ULR%+1+K)
- COL=ULC%
- DAT$=ITEM$(J-SELECT.BASE)
-
- ASCIIZ=INSTR(DAT$,CHR$(0)) 'display ONLY the string upto
- IF ASCIIZ>1 THEN 'a null x'00' if one is imbedded
- DAT$=LEFT$(DAT$,ASCIIZ-1)
- END IF
-
- DAT$=DAT$+SPACE$(WINDLEN) 'make all items the same length
- DAT$=LEFT$(DAT$,WINDLEN) 'when they are displayed
-
- CALL FASTPRT(DAT$,ROW,COL,ATTR,VIDEO.RETURN.CODE)
-
- K=K+1
- NEXT
-
-
- '
- 'highlight the next item displayed
- POPLIST.HILITE:
- ATTR=(FORE% AND 7)*16+BACK%
-
- IF BEGVAL=1 AND SELECT.%=1 THEN
- ROW=ULR%+2
- ELSEIF (SELECT.% >= BEGVAL) AND (SELECT.% <= ENDVAL) THEN
- ROW=ULR%+2+SELECT.%
- END IF
-
- IF (ENDVAL=MAXITEMS%) AND (SELECT.%>=MAXITEMS%) THEN
- SELECT.%=MAXITEMS%
- ROW=LRR%
- ELSE
- ROW=LRR%-OFFSET
- END IF
-
- COL=ULC%
- DAT$=ITEM$(SELECT.%-SELECT.BASE)
-
- ASCIIZ=INSTR(DAT$,CHR$(0)) 'display ONLY the string upto
- IF ASCIIZ>1 THEN 'a null x'00' if one is imbedded
- DAT$=LEFT$(DAT$,ASCIIZ-1)
- END IF
-
- DAT$=DAT$+SPACE$(WINDLEN) 'make all items the same length
- DAT$=LEFT$(DAT$,WINDLEN) 'when they are displayed
-
- '
- ' display this selected item, and highlight it
- CALL FASTPRT(DAT$,ROW,COL,ATTR,VIDEO.RETURN.CODE)
-
- IF FIRST.TIME THEN
- MOUSEROW=(ROW-1)*8 'if so, put the mouse cursor on the new selection
- MOUSECOL=(COL+(LEN(DAT$)\2)-1)*8
- CALL MMSETLOC(MOUSECOL,MOUSEROW)
- END IF
-
- OLD=SELECT.% 'fixes problem with item being highlighed twice
-
- GOSUB POPLIST.MORE 'put arrows on top and bottom of window
-
- CLICK=-1
- DO WHILE CLICK 'flush mouse click , if holding down button
- LFT%=0
- RGT%=0
- CALL MMCLICK(LFT%,RGT%)
- CLICK=LFT%+RGT%
- LOOP
-
- GOSUB POPLIST.MMCURSORON
- RETURN
-
- '
- 'Display arrowhead on top or bottom of window as necessary
- POPLIST.MORE:
- IF SHOWITEMS%=MAXITEMS% THEN 'are we doing POPMENU
- RETURN 'yes, all items displayed at once
- END IF
-
- MCOL=ULC%+((LRC%-ULC%)/2)-3 'calculate the windows upper frame location
-
- DAT$=" "+CHR$(30)+" "+CHR$(205)+" "+CHR$(31)+" "
-
- MROW=ULR%+1
- GOSUB POPLIST.DISP
-
- MROW=LRR%+1
- GOSUB POPLIST.DISP
-
- RETURN
-
- '
- POPLIST.DISP:
- ATTR=(BACK% AND 7)*16+FORE%
- CALL FASTPRT(DAT$,MROW,MCOL,ATTR,VIDEO.RETURN.CODE)
- RETURN
-
- '
- '
- ' Scan the list of items item looking for an item whose fitst character
- 'matches the keyboard character the user just typed.
- '
- POPLIST.FIND.OPTION:
- SAVE.SELECT=SELECT.% 'save the current item highlighted
- TEMP.SELECT=SELECT.%
- FIRST.CHAR$=KP$ 'this is the character to look for
-
- 'make comparison test case in-sensative
- '
- FIRST.CHAR$=UCASE$(FIRST.CHAR$)
-
- COUNT=0 'how many items have looked at
- POPLIST.FIND.LOOP:
- TEMP.SELECT=TEMP.SELECT+1 'look at the item after the current one
- IF TEMP.SELECT>MAXITEMS% THEN 'are we at the end of the list
- TEMP.SELECT=1 'Yes start back at the first item in the list
- END IF
-
- COUNT=COUNT+1 'we have looked at this many items so far
- IF COUNT>MAXITEMS% THEN 'have we looked at all the items in the list
- RETURN 'YES
- END IF
-
- MID$(TEMP.ITEM$,1)=ITEM$(TEMP.SELECT-SELECT.BASE)
- LEN.TEMP.ITEM=LEN(ITEM$(TEMP.SELECT-SELECT.BASE))
-
- '
- 'scan over leading spaces for this item, up to first character
- '
- FOR I=1 TO LEN.TEMP.ITEM
- IF MID$(TEMP.ITEM$,I,1)<>" " THEN
- '
- 'make comparison test case in-sensative
- '
- IF UCASE$(MID$(TEMP.ITEM$,I,1))=FIRST.CHAR$ THEN
- GOTO POPLIST.FOUND.IT 'this one was a match
- ELSE
- GOTO POPLIST.FIND.LOOP 'not this one, keep looking
- END IF
- END IF
-
- NEXT
-
- GOTO POPLIST.FIND.LOOP 'not this one, keep looking
-
- '
- POPLIST.FOUND.IT:
- SELECT.%=TEMP.SELECT 'this is the item to select now
-
- IF (SELECT.%>=BEGVAL) AND (SELECT.%<=ENDVAL) THEN 'new item on diff. screen
- GOTO POPLIST.FOUND.IT.CONT 'no
- ENDIF
-
- OLD=SELECT.% 'yes, force new screen re-display
- BEGVAL=SELECT.% 'start the display window with this item
- ENDVAL=(BEGVAL+SHOWITEMS%)-1 'and end with this item
-
- IF ENDVAL > MAXITEMS% THEN 'are there enought items to fill this window
- ENDVAL=MAXITEMS% 'NO, so display the last group of items
- BEGVAL=(ENDVAL-SHOWITEMS%)+1 'and highlight the one found
- END IF
-
- POPLIST.FOUND.IT.CONT:
- GOSUB POPLIST.FILL 'display the group of items and highlight one found
-
- OLD=SELECT.%
- RETURN
-
- '
- '
- ' Look for a keyboard key press or a mouse action and return a 'keystroke'
- '
- POPLIST.GET.PRESS:
- IF BUTTONS%=0 THEN 'is a mouse supported?
- GOTO POPLIST.GET.INKEY 'no, just look at the keyboard
- END IF
-
- CALL MMGETLOC(MOUSECOL,MOUSEROW) 'get the current mouse cursor scrren location
-
- MOUSEROW=(MOUSEROW\8)+1 'convert row to 80x25 co-ordinates
- MOUSECOL=(MOUSECOL\8)+1 'convert columnto 80x25 co-ordinates
-
- '
- ' Check if the mouse is still in the window box
- '
- POPLIST.CHECK.IF.INBOX:
- '
- ' Is the mouse outside the window frame
- '
- IF (MOUSEROW<MENU.TOP.ROW) OR (MOUSEROW>MENU.BOTTOM.ROW) THEN
- GOTO POPLIST.OUTSIDE.BOX
- END IF
-
- '
- ' Is the mouse in the box or on the window frame
- '
- IF (MOUSECOL>=MENU.TOP.LEFT.COL) AND (MOUSECOL<=MENU.BOTTOM.RIGHT.COL) THEN
- GOTO POPLIST.FOUNDIT
- END IF
-
-
- '
- ' Mouse cursor is outside the window, did user click any buttons
- '
- POPLIST.OUTSIDE.BOX:
- LFT%=0
- RGT%=0
- CALL MMCLICK(LFT%,RGT%) 'see if left or right button clicked?
- CLICK=LFT%+RGT%
- IF CLICK=0 THEN 'any button clicked?
- GOTO POPLIST.OUTSIDE.BOX.CONT 'NO
- END IF
-
- '
- 'If any button clicked outside window then simualte an ESC key press
- '
- IF (MOUSECOL<MENU.TOP.LEFT.COL-1) OR (MOUSECOL>MENU.BOTTOM.RIGHT.COL+1) THEN
- KP$=CHR$(27) 'simulate ESC key press
- RETURN
- END IF
-
- '
- ' Mouse was clicked on the top or bottom window frame, get the character under
- 'the mouse cursor (on the screen)
- '
- SCREEN.CHR=SCREEN(MOUSEROW,MOUSECOL)
-
- KP$=CHR$(0)+CHR$(73) 'assume 'page up' to be simulated
-
- IF MOUSEROW=MENU.TOP.ROW-1 THEN 'mouse on upper window frame?
- IF SHOWITEMS%<>MAXITEMS% THEN 'are we doing POPMENU
- IF SCREEN.CHR=31 THEN 'NO, user click on 'down' arrow
- KP$=CHR$(0)+CHR$(81) 'YES, simulate 'page down' keystroke
- RETURN
- ELSEIF SCREEN.CHR=30 THEN 'was mouse cursor on 'up' character
- RETURN
- ELSE
- RETURN
- END IF
- END IF
- END IF
-
- KP$=CHR$(0)+CHR$(81) 'assume 'page down' to be simulated
-
- IF MOUSEROW=MENU.BOTTOM.ROW+1 THEN 'mouse on bottom window frame?
- IF SHOWITEMS%<>MAXITEMS% THEN 'are we doing POPMENU
- IF SCREEN.CHR=30 THEN 'NO, user click on 'up' arrow
- KP$=CHR$(0)+CHR$(73) 'YES, simulate 'page up' keystroke
- RETURN
- ELSEIF SCREEN.CHR=31 THEN 'was mouse on 'down' character
- RETURN
- ELSE
- RETURN
- END IF
- END IF
- END IF
-
- KP$=CHR$(27) 'Simualate an ESC keypress
- RETURN
-
- '
- POPLIST.OUTSIDE.BOX.CONT:
- GOTO POPLIST.GET.INKEY 'see if a keyboard key pressed
-
- '
- POPLIST.FOUNDIT:
- SELECT.%=BEGVAL+(MOUSEROW-MENU.TOP.ROW) 'this is the one we want to highlight now
-
- IF SELECT.%<>OLD THEN 'are we on the same one as is currently highlighted
- LFT%=0
- RGT%=0
- CALL MMCLICK(LFT%,RGT%) 'see if mouse clicked on the current highlighted item
- CLICK=LFT%+RGT% 'was right or left button clicked?
- IF CLICK THEN 'a button clicked?
- GOSUB POPLIST.FILL 'NO, so highlight the newone just selected with the mouse
- OLD=SELECT.%
- ELSE
-
- SELECT.%=OLD
- GOTO POPLIST.GET.INKEY
- END IF
- END IF
-
- SELECT.%=OLD
-
- LFT%=0
- RGT%=0
- CALL MMCLICK(LFT%,RGT%) 'see if mouse clicked on the current highlighted item
- CLICK=LFT%+RGT% 'was right or left button clicked?
-
- IF CLICK THEN 'a button clicked?
- CLICK=0
- KP$=CHR$(13) 'YES, simulate a ENTER key press
- RETURN
- END IF
-
- '
- POPLIST.GET.INKEY:
- KP$=INKEY$ 'get a keyboard keypress character, if one avail.
-
- IF LEN(KP$)=0 THEN 'keep looking for a mouse or keyboard action
- GOTO POPLIST.GET.PRESS
- END IF
-
- RETURN
-
- '
- '
- ' The Window upper left frame co-ordinates were defined
- '
- POPLIST.GETORD:
- QUADRANT$=LTRIM$(QUADRANT$) 'strip off any leading and trailing spaces
- QUADRANT$=RTRIM$(QUADRANT$)
-
- COLON.LOC=INSTR(QUADRANT$,":") 'find where the row/column separator char is loacted
-
- IF COLON.LOC=1 THEN 'was a row defined
- QUADRANT$="02"+QUADRANT$ 'NO, so default to row 02
- COLON.LOC=3
- END IF
-
- ULR%=VAL(LEFT$(QUADRANT$,COLON.LOC-1)) 'convert row to a interger. to work with
-
- IF (ULR%<1) OR (ULR%>24) THEN 'is row in valid range of screen co-ordinates
- ULR%=2 'no, so default to row 02
- END IF
-
- IF COLON.LOC=LEN(QUADRANT$) THEN 'was a column co-ordinate defined
- QUADRANT$=QUADRANT$+"00" 'NO, so default to 00
- END IF
-
- ULC%=VAL(MID$(QUADRANT$,COLON.LOC+1)) 'convert column to interger, to work with
-
- IF (ULC%<1) OR (ULC%>80) THEN 'is the column in a valid range
- GOSUB POPLIST.CENTER.ON.THE.LINE 'NO, so center the window on the row
- END IF
-
- QUADRANT.ROW$=STR$(ULR%) 'return the string of the row and column we are working with
- QUADRANT$="0"+RIGHT$(QUADRANT.ROW$,LEN(QUADRANT.ROW$)-1)+":"
- QUADRANT.COL$=STR$(ULC%)
- QUADRANT$=QUADRANT$+"0"+RIGHT$(QUADRANT.COL$,LEN(QUADRANT.COL$)-1)
-
- ULR%=ULR%+1 'allow for window header frame description
-
- LRR%=ULR%+SHOWITEMS%+1 'calculate the windows lower right row and column co-ord.
- LRC%=ULC%+WINDLEN-1
- RETURN
-
- '
- POPLIST.CENTER.ON.THE.LINE:
- TEMP.ULC%=40-(LENGTH.MENU.ITEM/2) 'calculate the center point on the row
- IF (ULC%<2) THEN 'would window be outside screen?
- TEMP.ULC%=2 'put it back in scrren and allow for frame (but not shadow)
- END IF
-
- ULC%=TEMP.ULC% 'this is the upper left column needed to center this window
-
- RETURN
- '
- '
- ' Center the window frame header, within the window.
- '
- POPLIST.PUTHDR:
- PAD=(WINDLEN/2)-(LEN(HEADER$)/2)-.5
- MID$(TEMPHDR$,PAD+1,LEN(HEADER$))=HEADER$
- HEADER$=TEMPHDR$
- RETURN
-
- '
- POPLIST.MMCURSORON:
- IF BUTTONS%=0 THEN 'is a mouse supported?
- RETURN 'NO
- END IF
-
- IF MOUSE.CURSOR=0 THEN 'is the mouse off at present?
- CALL MMCURSORON 'YES, turn it on
- MOUSE.CURSOR=-1
- END IF
-
- RETURN
-
- POPLIST.MMCURSOROFF:
- IF BUTTONS%=0 THEN 'is a mouse supported?
- RETURN 'NO
- END IF
-
- IF MOUSE.CURSOR=-1 THEN 'is the mouse on at present?
- CALL MMCURSOROFF 'YES, turn it off
- MOUSE.CURSOR=0
- END IF
-
- RETURN
- '
- POPLIST.SOUNDOFF:
- SOUND 1000,1
- SOUND 1500,2
- SOUND 500,1
- RETURN
-
- '
- POPLIST.DONE:
- GOSUB POPLIST.MMCURSOROFF 'turn the mouse off as we leave
-
- TEMP.ITEM$="" 'free string space
- HEADER$=""
- TEMPHDR$=""
- DAT$=""
- END SUB