home *** CD-ROM | disk | FTP | other *** search
- *****************************************************************
- FUNCTION AEDBAR (aed_item)
- *****************************************************************
-
- * Single line -- Quit, Add, Edit, Find, Delete -- bar menu
-
- * Copyright(c) 1991 - James Occhiogrosso
-
- #include "inkey.ch"
- #include "set.ch"
- #include "setcurs.ch"
-
- LOCAL aed_col :=1, init_col := 1, keypress := 0, prev_item :=1,;
- old_col :=1, old_color := '', old_cursor := '', ;
- spacing := 9, txtnorm := '', txthigh := ''
-
- * Menubar prompt messages
- PRIVATE prompt1 := ' Quit ', prompt2 := ' Add ' , ;
- prompt3 := ' Edit ', prompt4 := ' Find ', ;
- prompt5 := ' Delete '
-
- old_cursor = SET(_SET_CURSOR,SC_NONE)
- old_color = SETCOLOR(colbarlo)
-
- * If AEDBAR variable is undefined, define it.
- IF TYPE('aedbar') = 'U'
- * Set aedbar public for use by AEDMSG
- PUBLIC aedbar
- aedbar = .T.
- ENDIF
-
- * If starting row is not defined, default to bottom screen row
- IF TYPE('aed_row') != 'N'
- * Set aed_row public for use by AEDMSG
- PUBLIC aed_row
- aed_row = MAXROW()
- ENDIF
-
- * If starting item is not defined, default to item 1
- aed_item = IF(aed_item = NIL, 1, aed_item)
-
- * Display the menubar.
- SETCOLOR(colbarlo)
- @ aed_row, init_col SAY prompt1
- @ aed_row, init_col + (spacing) SAY prompt2
- @ aed_row, init_col + (spacing*2) SAY prompt3
- @ aed_row, init_col + (spacing*3) SAY prompt4
- @ aed_row, init_col + (spacing*4) SAY prompt5
-
- * If the message window update variable is undefined, define it.
- IF TYPE('mw_update') = 'U'
- PUBLIC mw_update
- mw_update = .T.
- ENDIF
-
- * Update the message window unless mw_update is false.
- * BOF or EOF set it .F. so that messages remain on view.
- IF mw_update
- AEDMSG('mw_init')
- ENDIF
-
- * Set the loop exit for first letter of each prompt,
- * or the Return or Esc keys.
-
- DO WHILE .NOT. CHR(keypress) $ 'QAEFDqaefd' .AND. ;
- keypress != K_RETURN .AND. keypress != K_ESC
-
- * Highlight the current menubar option
- SETCOLOR(colbarhi)
- aed_col = init_col + (spacing * (aed_item - 1))
- txthigh = "prompt" + STR(aed_item,1)
- @ aed_row , aed_col SAY &txthigh
-
- * Position a normal size cursor at end of current prompt
- SETCURSOR(SC_NORMAL)
- IF aed_item = 5
- @ aed_row, aed_col + 7 say ''
- ELSEIF aed_item = 2
- @ aed_row, aed_col + 4 say ''
- ELSE
- @ aed_row, aed_col + 5 say ''
- ENDIF
-
- * Save the current settings
- prev_item = aed_item
- old_col = aed_col
-
- * Wait for the operator to press a key.
- keypress = INKEY(0)
- SETCURSOR(SC_NONE)
-
- IF keypress = K_RIGHT
-
- * Move prompt 1 position to right
- aed_item++
- old_col = aed_col
- aed_col = aed_col + spacing
-
- IF aed_item > 5
- * Wrap around back to item 1
- aed_item = 1
- aed_col = init_col
- ENDIF
-
- ELSEIF keypress = K_LEFT
-
- * Move prompt 1 position to left
- aed_item--
- old_col = aed_col
- aed_col = aed_col - spacing
- IF aed_item < 1
- aed_item = 5
- aed_col = init_col +(spacing * 4)
- ENDIF
-
- ELSEIF keypress = K_UP
-
- * Move data base pointer up 1 and exit
- SKIP -1
- IF .NOT. BOF()
- mw_update = .T.
- ELSE
- * Display "Top of file" message
- mw_update = .F.
- GO TOP
- AEDMSG('mw_bof', colblink)
- ENDIF
- browsing = .T.
- EXIT
-
- ELSEIF keypress = K_DOWN
-
- * Move data base pointer down 1 and exit
- SKIP
- IF .NOT. EOF()
- mw_update = .T.
- ELSE
- * Display "Bottom of file" message
- mw_update = .F.
- GO BOTTOM
- AEDMSG('mw_eof', colblink)
- ENDIF
- browsing = .T.
- EXIT
-
- * Reset menubar position if an option letter key was pressed.
-
- ELSEIF CHR(keypress) $ 'Aa' // Add mode
- aed_item = 2
- ELSEIF CHR(keypress) $ 'Ee' // Edit mode
- aed_item = 3
- ELSEIF CHR(keypress) $ 'Ff' // Find mode
- aed_item = 4
- ELSEIF CHR(keypress) $ 'Dd' // Delete mode
- aed_item = 5
- ELSEIF CHR(keypress) $ 'Qq' .OR. keypress = K_ESC // Quit
- aed_item = 1
-
- ELSEIF (keypress <= K_F2 .OR. keypress > 256 ;
- .OR. keypress = K_F1) .AND. TYPE('fkeyset') != 'U'
-
- * Call special keys procedure if any function key or
- * alternate key combination is pressed. The variable,
- * "fkeyset" must contain the procedure name.
-
- IF .NOT. EMPTY(fkeyset)
- SETCOLOR(old_color)
- DO &fkeyset WITH 'AEDBAR', 0, '', keypress
- ENDIF
-
- ELSE
- LOOP
-
- ENDIF
-
- * Key is a left or right arrow. Reposition menu bar.
-
- txtnorm = "prompt" + STR(prev_item,1)
- txthigh = "prompt" + STR(aed_item,1)
- SETCOLOR(colbarlo)
- @ aed_row, old_col SAY &txtnorm
- SETCOLOR(colbarhi)
- aed_col = init_col + (spacing * (aed_item-1))
- @ aed_row , aed_col SAY &txthigh
- old_col = aed_col
-
- ENDDO
-
- * Reset entry conditions and return the key pressed
-
- SETCURSOR(old_cursor)
- SETCOLOR(old_color)
- RETURN(keypress)
-
-
-