home *** CD-ROM | disk | FTP | other *** search
- **************************************************************************
- * Program Name: ach_win.prg *
- * Author: Jonathan Cole *
- * Copyright (c) 1989 by American Management Systems, Inc. *
- *------------------------------------------------------------------------*
- * Created: 6/30/1989 at 0:17 *
- * Revision: 1.0 Last Revised: 6/30/1989 at 0:35 *
- * Description: Original Creation. *
-
- ***************************** ALL RIGHTS RESERVED ************************
-
- FUNCTION ach_wndw( arr_ch, caption, mnutop, mnubtm, arr_avail, udf, frstch, winrow)
-
- * Purpose: create a drop shadowed window around an achoice()
- * Syntax : ach_wndw( <array of choices>, <C caption>, <N top row>, <N bottom row>, <array of available options>, <C UDF name>, <N first choice>, <N window row> )
- * Return : the return value from achoice
- * Notes : only the 1st parameter is necessary
-
- LOCAL mnuleft, mnuwidth, mnurght, oldcolor, J, oldscrn, u_choice
- LOCAL num_els
-
- num_els = LEN(arr_ch) && number of elements in the array
- oldcolor = SETCOLOR(colchc)
-
- * ---check if optional parameters were passed. If not, set defaults. --- *
- IF valtype( MNUTOP) != "N"
- mnutop = 12 && default top row
- ENDIF
-
- IF valtype( MNUBTM) != "N" && if it's not numeric either it wasn't passed or a dummy was passed (or an error)
- mnubtm = IF( (mnutop + num_els - 1) < 21, mnutop + num_els - 1, 20 )
- ELSE
- mnubtm = IF( mnubtm < 21, mnubtm, 20 )
- ENDIF
-
- IF valtype( ARR_AVAIL) == "U"
- arr_avail = .T. && make everything available
- ENDIF
-
- IF valtype( UDF) == "U"
- udf = .F. && no key handling udf
- ENDIF
-
- IF valtype( frstch) == "U"
- frstch = .F.
- ENDIF
-
- IF valtype( winrow) == "U"
- winrow = .F.
- ENDIF
- *--------------------------------------*
-
- * determine how wide the window must be
- mnuwidth = 0
- FOR J = 1 TO num_els
- IF LEN(arr_ch[j]) > mnuwidth
- mnuwidth = LEN(arr_ch[j])
- ENDIF
- NEXT j
-
- IF valtype( CAPTION) == "C"
- IF LEN(caption) > mnuwidth
- mnuwidth = LEN(caption)
- ENDIF
- ENDIF
-
- * define the achoice() coordinates - the border of the box is outside of these.
- mnuleft = Center(SPACE(mnuwidth))
- mnurght = mnuleft + mnuwidth
-
- * save the screen area (including border & shadow) on which the box will appear
- oldscrn = SAVESCREEN( mnutop - 1, mnuleft-1, mnubtm + 2, mnurght + 2 )
-
- * shadow the box
- shadow( mnutop-1, mnuleft-1, mnubtm+1, mnurght+1, maxrow() )
-
- * clear the box
- @ mnutop - 1, mnuleft-1 CLEAR TO mnubtm + 1, mnuleft + mnuwidth + 1
-
- * draw frame around box
- SETCOLOR(colchcx)
- @ mnutop - 1, mnuleft - 1 TO mnubtm + 1, mnurght + 1 DOUBLE
-
- * if the entire array doesn't fit into the window, draw arrows
- IF num_els > (mnubtm - mnutop + 1)
- msg = " " && up & down arrows
- @ mnubtm+1, Center(msg) SAY msg
- ENDIF
-
- * Put caption in top of frame if it exists
- IF valtype( CAPTION) == "C"
- @ mnutop - 1, Center(caption) SAY caption
- ENDIF
-
- * Activate achoice menu function
- SETCOLOR(colchc)
- u_choice = Achoice(mnutop, mnuleft, mnubtm, mnurght, arr_ch, arr_avail, udf, frstch, winrow)
-
- * return screen to previous state
- SETCOLOR(oldcolor)
- Restscreen( mnutop - 1, mnuleft-1, mnubtm + 2, mnurght + 2, oldscrn )
-
- RETURN u_choice
- *------------------------------------------*
- * eof - ach_win.prg
-