home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
FOXPRO
/
VLIST110
/
VLIST2.DOC
< prev
next >
Wrap
Text File
|
1992-03-20
|
23KB
|
505 lines
VList Library V1.1 -- (c) 1992, Jayson R. Minard
P.O. Box 1306
Westminster, CO 80030-1306 (USA)
===============================================================================
META-Functions <CONTINUED>
-------------------------------------------------------------------------------
VList_SmallView()
VList_FullView()
-------------------------------------------------------------------------------
These two functions have almost the same functionality of viewing a text
file with the exception of VLIST_FULLVIEW() provides mouse support and
VLIST_SMALLVIEW() does not. Mouse support can be turned on and off
for VLIST_FULLVIEW().
Internally VLIST_FULLVIEW() calls VLIST_PICK() to handle the displaying of
the text file while VLIST_SMALLVIEW() calls VLIST_SIMPLE(). Therefore if you
are already using VLIST_PICK() or any of the META-functions that calls it
then you should continue to use it here since you do not want to include
extra code that isn't needed. The menu functions all use VLIST_PICK() and
the only time VLIST_SIMPLE() is used is if it is called by you.
===============================================================================
VList_1_FPick()
VList_FPick()
-------------------------------------------------------------------------------
These two functions are used to display a list of files from a specific
directory and then have the user select either 1 file (VLIST_1_FPICK)
or many (VLIST_FPICK). A parameter can be passed to allow the user
to change directories and also one to have VLIST_FPICK() retain ALL marked
files even if the directory IS changed.
===============================================================================
VList_Simple()
VList_Pick()
-------------------------------------------------------------------------------
To display a list and have an element selected, these are the two choices.
VLIST_PICK() allows for multiple columns and full mouse support. On the
other hand VLIST_SIMPLE() is similar to the old FORCE pick_list routine.
It is short with little code and just does the job. VLIST_PICK() handles
hidden, skipped, normal, and hit elements with different elements having
different colors along with multiple columns. VLIST_SIMPLE() supports
only single columns, but does allow elements of different colors. With
VLIST_PICK() you can also have embedded characters within an element
so that characters are highlighted with.
For VLIST_PICK() you can provide (actually MUST) a user-defined keystroke
handler. If you just want to use the standard defaul, you can pass
VLIST_DEFAULT_KEY_HANDLER() as the parameter. The keyboard handlers
are covered in the next section. They provide redefinition of what
keys have what activity and also how the mouse reacts with the list.
On <ESC> the selected element number is set to the last item the
cursor was on. Check LASTKEY() to determine how the list was exitted.
This allows for re-entry into the list so that the user cannot tell
you ever left.
===============================================================================
===============================================================================
MENU SYSTEMS
-------------------------------------------------------------------------------
Now we get to be complex. We will cover the three different VLIST menu systems
and how the VList must be built in order to use a system.
Basically a VLIST can contain multiple menu 'systems'. Each is assigned a
number and that is used to reference the individual system from all of the
others. A list containing more than one menu system must have an unique
number for each system and a system must be continuous within the list.
-------------------------------------------------------------------------------
Prompt Menus -- VLIST_PROMPT()
-------------------------------------------------------------------------------
These menus can either be selections scattered across the screen or they can
be push-button type selections. VLIST_PROMPT() is used to display and
execute a prompted menu.
A menu list must be build as follows for a PROMPT menu. This can be
a seperate list or a segment of an existing list.
<SYSTEM>.<ITEM> @<ROW>,<COL> |<TEXT>
{...}
Where:
<SYSTEM> - The menu system number
<ITEM> - The item number. This is the number returned upon
selecting the item.
<ROW>,<COL> - The screen coordinates to display this item.
<TEXT> - The text to display.
NOTE!!! The '|' within each element of a PROMPT system MUST be aligned so
that they are in the same character position within each element. This
helps the PROMPT system know where to find the text to display AND find
it very quickly. The text starts immediately after the '|' so any
spaces before or after WILL be displayed within the highlighted area.
A PROMPT system can have hidden, skipped, hit, and normal elements. At
least ONE should be normal. You can also edit an element within the
keyboard handler so that it acts like a push-button. The keyboard
handler used for PROMPT systems is VLIST_DEFAULT_PROMPT_HANDLER().
Example list:
VList_Add( handle, "1.1 @23,2 | Add " )
VList_Add( handle, "1.2 @23,7 | Delete " )
VList_Add( handle, "1.3 @23,15 | Rename " )
VList_Add( handle, "1.4 @23,23 | Exit " )
VList_Add( handle, "2.1 @23,2 | Next " )
VList_Add( handle, "2.2 @23,8 | Previous " )
VList_Embed_Caps( handle, 1, VList_Max( handle ) )
selection = 1 && starting guy
selection = VList_Prompt( handle, 1, selection,;
VList_Default_Prompt_Handler,;
is_mouse_on, .T. )
A few notes about the above example:
1. We created a list with 2 menu systems in it.
2. Even on <ESC> the prompt routine will return the element number
that the cursor was on, therefore allowing you to re-enter where
you left off later.
3. The 'is_mouse_on' variable is just an example saying whether or
not I have the mouse initialized.
4. VLIST_EMBEDD_CAPS() will add the __EMBED_CHAR before the first
capital letter in each of the the elements 'text'. If this letter
is pressed, the cursor will jump to that element and select it.
Therefore, each should be unique.
5. The final .T. signifies to highlight the embedded characters.
-------------------------------------------------------------------------------
PopUp Menus -- VLIST_POPUP()
-------------------------------------------------------------------------------
Another menu system commonly used is the pop-up menu. This is a window
that appears magically on the screen with a few selections in it. This
sometimes has a title.
As implemeneted in the VLIST system, you create a list or segment of
a list similar to the PROMPT system except with the following
structure. Keep in mind that the structure is designed to make
the code scan it quicker therefore there may seem to be some
unneccessary aligning and so on, but it is neccessary!
<SYSTEM>.0 |<TITLE>
<SYSTEM>.<ITEM> |<TEXT>
{...}
Note that the first line is the TITLE line and has an item number of 0. This
must always be included, yet the '|' can be immediately followed by the
terminating quote so that it is blank and therefore not displayed.
Ex.
VList_Add( handle, "1.0 | Select " )
VList_Add( handle, "1.1 | Option 1 " )
VList_Add( handle, "1.2 | Choice 2 " )
VList_Append( handle, &jl_skip, &jl_default,;
"1.? |─..." )
VList_Add( handle, "1.3 | Selection 3 " )
VList_Embed_Caps( handle, 2, 4 )
Also note that the '|' must line up again! This helps with processing
speed.
The call to the VLIST_POPUP() function has many important parameters.
They are all described in the reference section. Some notes generally
about a few...
1. The default keyboard handler is VLIST_DEFAULT_MENU_HANDLER()
2. The screen can be saved to a variable that you either restore
or allow the function to restore for you. This means that
you can keep the menu on the screen after a selection is made,
do an activity, and then clear the menu. This is where
VLIST_FREE_SCREEN() comes in handy if you want to clear the
saved screen but not restore it.
3. If you select 'allow_embedded' then the character following
the __embed_char will be highlighted. Also if you use
embedded characters, and a key is pressed, the cursor moves
to the corresponding element and selects it.
4. Notice the element "1.?" line. This line has a character followed
by '...' in the <TEXT> area. This character will be repeated across
the width of the menu window. This means that you do not have to
calculate the width yourself. Also it is marked as skipped so it
will be jumped when the cursor moves to it. The '?' is just a place
holder so that no <ITEM> number is used.
-------------------------------------------------------------------------------
PullDown Menus -- VLIST_PullDown()
-------------------------------------------------------------------------------
Pulldown menus are basically a group of horizontal pop-up menus. Therefore
most of the same internal routines are used. This means that some information
you must place in the list probably will never be used but it allows for
smaller and quicker coding of the menu routines.
The menu structure has three parts...
<SYSTEM>.<SUBMENU> @<COL> |<HEADER>
<SYSTEM>.<SUBMENU>.0 |<BOX TITLE>
<SYSTEM>.<SUBMENU>.<ITEM> |<TEXT>
{...}
The first part is the sub-menu column position and the header. The header
is displayed on the menu line, sent as a parameter, and the sub-menu is
placed according to a different parameter. This means you can have a line
or a blank space between the header and menu.
The second part is the box title. This is the same as for pop-up menus
but most pull-down menus do NOT have a title on the actual menu box. This
is there only to allow for use of identical internal code. You MUST have
this line, yet the title should be left blank after the '|' if you do
not want a title.
The last (third) part is a group of items to display as the sub-menu lines.
NOTE that you must align the '|' for all of the menus within a pull-down
system.
Ex.
__EMBED_CHAR = "^"
VList_Add( handle, "1.1 @2 | ^File " )
VList_Add( handle, "1.1.0 |" )
VList_Add( handle, "1.1.1 | ^Save " )
VList_Add( handle, "1.1.2 | ^Open " )
VList_Add( handle, "1.1.3 | ^Close " )
VList_Append( handle, &jl_skip, &jl_default,;
"1.1.? |─..." )
VList_Add( handle, "1.1.4 | C^apture " )
VList_Add( handle, "1.1.5 | ^Quit " )
VList_Add( handle, "1.2 @8 | ^Utilities " )
VList_Add( handle, "1.2.0 |" )
VList_Add( handle, "1.2.1 | ^Pack " )
VList_Add( handle, "1.2.2 | ^ReIndex " )
Now you can call VLIST_PULLDOWN() and have it display the menu. This
example contains one skipped line that will be jumped when the cursor
gets to it. This line is displayed using the color __COLOR_SKIP.
This example does not use VLIST_EMBED_CAPS() since there would be
duplicate embedded characters across different elements, 'Close' and
'Capture' would both have the 'C' highlighted. Instead I set the
__EMBED_CHAR variable to something easy to work with and directly
placed it into the element myself. The embedded code in the header
line is independent from the elements within the sub-menu. The headers,
when the menus are pulled up, can be moved to by pressing their letter.
When the menu is down, then you can press the highlighted selection
letter.
Some notes about certain parameters:
1. The 'menu_processing_proc' is called when ever an element is
selected. Therefore you process from within the menu rather
than outside of it as in the PROMPT and POPUP menus. This
UDF function should be created as follows:
FUNCTION UINT pulldown_selector && or whatever name
PARAMETERS VALUE LONG handle,;
VALUE UINT system,;
VALUE UINT over,;
VALUE UINT down
VARDEF
UINT ret_val
ENDDEF
ret_val = 0 && continue processing
DO CASE
CASE system = 1
DO CASE
CASE over = 1
DO CASE
CASE down = 1
CASE down = 2
CASE down = 3
ENDCASE
CASE over = 2
DO CASE
CASE down = 1
CASE down = 2
ENDCASE
CASE over = 3
DO CASE
CASE down = 1
CASE down = 2
ENDCASE
ENDCASE
CASE system = 2
{...}
ENDCASE
RETURN ret_val && a ret_val of 1 will stop the pulldown menu!
ENDPRO
Therefore all of your pulldown menus can call the same routine OR
you can have one for each system... NOTE that the return value
can stop the pulldown menu and exit back to whatever called
VLIST_PULLDOWN if it is 1. A 0 signifies that the menu should
be continued.
2. The keyboard handler should be VLIST_DEFAULT_MENU_HANDLER().
3. The 'column_offset' parameter adjusts the horizontal position
of the sub-menu in relation to the header.
4. The 'always_down' parameter can be used so that the menu is
always pulled down and the <ESC> key will not pull it up to
show ONLY the headers. If this is .F. then the menus can
be pulled up to have the cursor move only among the headers.
-------------------------------------------------------------------------------
Combining list systems to form a limitted 'dialog' box
-------------------------------------------------------------------------------
The example programs show the combining of the different VLIST functions
to form a dialog system. Basically a loop is run that circulates and
enters a case statement. The case statement checks a variable which is
the current 'state' of the system. This state determines which menu
system we are wanting to look at. That particular system is activated
and if the cursor leaves the system and hits another, then in the keyboard
handler we detect this, set the 'state' (a global variable), and exit
our system. The loop then goes back throught the case statement and
enters the new 'state'.
===============================================================================
===============================================================================
KEYBOARD HANDLERS
-------------------------------------------------------------------------------
The following functions are the defualt keyboard handlers for differnt VLIST
functions:
VList_Default_Key_Handler()
- for VList_Pick()
VList_Default_Menu_Handler()
- for VList_Popup()
- for VList_Pulldown()
VList_Default_Prompt_Handler()
- for VList_Prompt()
These can be replaced by your own by changing the source and placing it
into the VLIST library or linking it before the library. OR you can
create your own version and send the its' name to the function instead
of the default name. This is the preferred method.
The keyboard handler receives information on the state of the mouse
or the key that was pressed. If the mouse state is non-zero then the
mouse is what activated the handler, else it was a key-stroke.
If you have the mouse return a key value, then you should use the 'set_key'
variable in the keyboard handler so that the LASTKEY() value will be equal
to the key value. This way the mouse can return LASTKEY() = 27 when
the right button is hit and so on.
The source code for the keyboard handlers is as follows:
VLIST35.PRG -- VLIST_DEFAULT_KEY_HANDLER()
VLIST70.PRG -- VLIST_DEFAULT_MENU_HANDLER()
VLIST79.PRG -- VLIST_DEFAULT_PROMPT_HANDLER()
You can copy this file, rename the function name, and then change the
contents so that it acts the way you wish. This includes how the mouse
scrolls the window, and also how it uses the scroll-bar. You can remap
keys so that they become something altogether differnt.
The keyboard handler will receive the following codes which are defined
as macros in VLIST.HDR along with the current key value in the variable
'pick_key'.
&JL_MOUSE_IGNORE - no mouse activity, check the value of PICK_KEY
&JL_MOUSE_RIGHT - the right mouse button was pressed
&JL_MOUSE_XRIGHT - the right mouse button was released. This usually
sets PICK_KEY to 27 using the 'set_key' variable.
&JL_MOUSE_LEFT - the left mouse button was pressed
&JL_MOUSE_XLEFT - the left mouse button was released
&JL_MOUSE_BOTH - both buttons pressed together
&JL_MOUSE_UP - the left mouse button was pressed while the
mouse cursor was on the UP-tab on the scroll-bar.
This usually sets PICK_KEY to some cursor up
value.
&JL_MOUSE_XUP - the left mouse button was released while the
mouse cursor was on the UP-tab on the scroll-bar.
&JL_MOUSE_DOWN - the left mouse button was pressed while the
mouse cursor was on the DOWN-tab on the scroll-bar.
This usually sets PICK_KEY to some cursor down
value.
&JL_MOUSE_XDOWN - the left mouse button was released while the
mouse cursor was on the DOWN-tab on the scroll-bar.
&JL_MOUSE_SCROLL - the left mouse button was pressed while the
mouse cursor was somewhere on the scroll-bar.
The value of PICK_KEY is set depending on where
the cursor is according to the relative marker
on the scroll-bar.
Mouse cursor at top line of scroll-bar
PICK_KEY = &K_C_PG_UP
Mouse cursor at bottom line of scroll-bar
PICK_KEY = &K_C_PG_DOWN
Mouse cursor above relative position
PICK_KEY = &K_PG_DOWN
Mouse cursor below relative position
PICK_KEY = &K_PG_UP
Therefore you should check this case AND the
value of PICK_KEY, then you can alter PICK_KEY
to what you wish it to be.
&JL_MOUSE_XSCROLL - Mouse released on scroll-bar (usually ignored)
&JL_MOUSE_NEW - the left mouse button was pressed while the
cursor was on a new element. This usually sets
the return value to &JL_GOTO_MOUSE which will
cause the cursor to move to this element. A
new element is defined as one that the highlight
bar is not currently on.
&JL_MOUSE_XNEW - the left button was released on a new element.
&JL_MOUSE_SELECT - the left mouse button was pressed on the
current element. This is usually ignored.
&JL_MOUSE_XSELECT - the left mouse button was released on the
current element. This usually returns the
value of &JL_SELECT. You should also set
the PICK_KEY to 13 and use 'set_key' to do
this so that LASTKEY() will be correct.
The keyboard handler can return the following codes which are defined
as macros in VLIST.HDR and can also return information in the variable
'pick_key'.
&JL_CONTINUE - continue and check the value of PICK_KEY and
respond as normal for that key-stroke.
&JL_IGNORE - ignore PICK_KEY and wait for another action.
&JL_REPAINT - ignore PICK_KEY and repaint the pick area.
&JL_SELECT - select the current element and exit
&JL_ABORT - exit
&JL_PAINT_KEY - continue and check PICK_KEY, then repaint the
pick area.
&JL_BAD_ELEMENT - the current element is now either set as SKIP,
or HIDDEN so please move to another valid element
and repaint the erea. In case you either delete,
or change the status of an element in the key
handler.
&JL_REPAINT_ELEMENT - redraw the current element and then evaluate
PICK_KEY. This is in case you do a VLIST_EDIT
within the key handler.
&JL_REPAINT_IGNORE - redraw the current element but ignore PICK_KEY.
&JL_GOTO_MOUSE - goto the element that the mouse cursor is on.
** this is for PULL-DOWN menus ONLY!
&JL_RESCAN_MENU - the mouse cursor is somewhere on the header line,
please find out which header it is pointing to
and pull that menu down.
Using these values and the source for the default keyboard handlers you can
alter the library to suite your needs easily.
Another technique instead of replacing the complete handler, is to have
yours called, filter what you don't want, then call the default, then return
its return value as your own.
==============================================================================
<<<CONTINUED IN VLIST3.DOC>>>
==============================================================================