home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
SOURCE
/
CSSRC
/
FNBOB.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-12-08
|
4KB
|
180 lines
/*
fnbob.c 8/30/88
% bob_funcs
Object control passing functions.
C-scape 3.2
Copyright (c) 1986-1989 by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Revision History:
-----------------
9/15/88 jmd removed vid_Cursor calls
9/17/88 jmd added std_ funcs
10/14/88 jdc added var_size element to field_funcs_struct
12/05/88 jmd added mouse checking
12/06/88 jmd added special func, nesting support
5/23/89 jdc made default case pass value back instead of sed_IncField
1/29/90 jmd added support for independent bobs
3/28/90 jmd ansi-fied
4/12/90 pmcm switched on ret value of independent bob
5/17/90 pmcm BOB_QUIT changed to 0 in relay when baton reaches parent
8/07/90 pmcm added BOB_INC
12/08/90 pmcm changed std_fenter to stdNoCur_fenter
*/
#include <stdio.h>
#include <ctype.h>
#include "cscape.h"
#include "fnfunc.h"
#include "scancode.h"
OGLOBAL field_funcs_struct bob_funcs = {
stdNoCur_fenter,
std_fexit,
bob_fkey,
FNULL,
FNULL,
0
};
void bob_fkey(sed_type sed)
/*
Calls bob_Go for the bob attached to the field.
Moves to the next field in the direction indicated
by bob_Go's return value.
If the bob is independent, waits for ENTER/MOU_CLICK
and then calls go on it.
*/
{
bob_type bob;
int scancode, ret, fieldno;
fieldno = sed_GetFieldNo(sed);
if ((bob = sed_GetFieldBob(sed, fieldno)) == NULL) {
/* Error: no bob attached to the field */
sed_SetBaton(sed, BOB_QUIT);
sed_ToggleExit(sed);
return;
}
if (bob_IsDepend(bob)) {
/* Dependent bob: call go directly */
ret = bob_Go(bob);
/* return 0 instead of BOB_QUIT from ultimate ancestor */
if (ret == BOB_QUIT) {
ret = (bob_GetParent(sed) == NULL) ? 0 : ret;
}
/* See if special function is interested in BOB_ code */
if (sed_DoSpecial(sed, ret)) {
return;
}
switch (ret) {
case BOB_INC:
if (sed_IncField(sed) == SED_STUCK) {
sed_SetBaton(sed, sed_GetFieldNo(sed) + 1);
sed_ToggleExit(sed);
}
break;
case BOB_UP:
sed_UpField(sed);
break;
case BOB_DOWN:
sed_DownField(sed);
break;
case BOB_LEFT:
sed_LeftField(sed);
break;
case BOB_RIGHT:
sed_RightField(sed);
break;
case BOB_QUIT:
default:
sed_SetBaton(sed, ret);
sed_ToggleExit(sed);
break;
}
}
else {
/* Independent bob: get a keystroke (a la menu_funcs) */
scancode = kb_Read();
if (sed_DoSpecial(sed, scancode))
return;
if (special_key(sed, scancode))
return;
/* intercept key (and mouse) before inter_field... */
if (scancode == ENTER || scancode == MOU_CLICK) {
/* Only pressing ENTER or clicking with the mouse activates an
indie bob.
Paint and go, then remove bob from display.
*/
bob_Repaint(bob);
ret = bob_Go(bob);
bob_Pop(bob);
/* return 0 instead of BOB_QUIT from ultimate ancestor */
if (ret == BOB_QUIT) {
ret = (bob_GetParent(sed) == NULL) ? 0 : ret;
}
/* See if special function is interested in return code
code from the indie bob
*/
if (sed_DoSpecial(sed, ret)) {
return;
}
switch (ret) {
case 0:
break;
case BOB_INC:
sed_IncField(sed);
break;
case BOB_UP:
sed_UpField(sed);
break;
case BOB_DOWN:
sed_DownField(sed);
break;
case BOB_LEFT:
sed_LeftField(sed);
break;
case BOB_RIGHT:
sed_RightField(sed);
break;
case BOB_QUIT:
default:
sed_SetBaton(sed, ret);
sed_ToggleExit(sed);
break;
}
return;
}
/* If we did not activate the indie bob, pass the keystroke or
mouse event onto inter_field_grid and inter_page.
*/
if (inter_field_grid(sed, scancode))
return;
if (inter_page(sed, scancode))
return;
}
}