home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
SOURCE
/
FUNCS
/
FNFRAMER.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-12-08
|
10KB
|
376 lines
/*
fnframer.c
jmd 6/23/89 new(er) framer funcs
% framer_funcs
C-scape 3.2
Copyright (c) 1988-1989, by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Revision History:
-----------------
5/24/89 jdc added sed_DoSpecial and special_key
5/26/89 jdc added fix for help
6/23/89 jmd completely rewrote
6/26/89 jmd added FRAME_LEFT, FRAME_RIGHT
7/21/89 jdc readded special_key and added immediate selection from
sed_SearchMerge
changed return value condition
8/12/89 jmd removed call to sed_GetBob
12/09/89 ted Completely rewrote.
3/10/90 pmcm Changed so _bobgo ret'ing 0 to pulldown keeps pulldown down
3/14/90 jmd changed fexit, fenter to std_fexit, std_fenter
3/28/90 jmd ansi-fied
4/08/90 ted Fixed pulldown bug pmcm and I made on 3/3/90 when we fixed the ufunc rtn case.
4/23/90 jmd fixed expression for Zortech compiler
8/13/90 ted Changed references from sed_SetMouseCode to kb_Stuff.
8/13/90 ted Modified framer bit test to allow sub-pulldowns.
8/29/90 ted Reconstructed to have more SAA-like mouse behavior.
9/23/90 ted Got rid of FRAME_QUIT code, made use of MOU_THERE code.
9/23/90 ted Turned BD_MOUSETHRU on before painting a dropdown sed.
10/04/90 pmcm removed isprint from search
10/16/90 ted fixed framer test loop so embedded framers will work.
10/22/90 pmcm added reset of border prompt when ret'ing from bob
10/25/90 ted moved border prompt resetting into msys_bobgo.
10/25/90 ted added case to check for SED_ABORT after msys_bobgo for LNF.
10/31/90 ted changed 'letter' from char to int to avoid int/char compiler warning.
12/08/90 pmcm changed std_fenter to stdNoCur_fenter
*/
#include <stdio.h>
#include <ctype.h>
#include "cscape.h"
#include "scancode.h"
#include "oaktag.h" /* For ID in bob_IsUfunc */
#include "msys.h"
#include "helpdecl.h"
#include "menupriv.h"
OSTATIC void framer_fkey(sed_type sed);
OSTATIC void common_fkey(sed_type sed, int scancode);
OSTATIC void gotofirst(sed_type sed, int scancode);
OGLOBAL field_funcs_struct framer_funcs = {
stdNoCur_fenter,
std_fexit,
framer_fkey,
FNULL,
FNULL,
0
};
/* -------------------------------------------------------------------------- */
static void framer_fkey(sed_type sed)
/*
*/
{
int scancode;
int ret;
win_type parent;
bob_type bob;
/* If we're the first here, we're the top framer, so we set a bit so our
kids won't think they're it. */
if (!msys_IsFramer(sed)) {
parent = sed;
for (;;) {
if ((parent = bob_GetParent(parent)) == NULL) {
msys_SetFramer(sed, TRUE);
break;
}
if (msys_IsFramer(parent)) {
break;
}
}
}
scancode = kb_Read();
/* Clear the framer return flag for this sed in case we set it last time through */
msys_SetFrameRtn(sed, FALSE);
if (sed_DoSpecial(sed, scancode)) {
gotofirst(sed, scancode);
return;
}
if (scancode == FN1 && msys_IsFramer(sed)) {
framerbar_help(sed);
return;
}
if (special_key(sed, scancode)) {
gotofirst(sed, scancode);
return;
}
if (msys_IsFramer(sed)) {
/* Features specific for top menu */
switch (scancode) {
case ESC:
sed_SetBaton(sed, 0);
sed_ToggleExit(sed);
break;
case MOU_CLICK: /* Display dropdown menu */
case MOU_NOFIELD: /* Remove dropdown menu */
{
int i;
menu_type menu;
bob_type abob;
unsigned bfeature;
/* Remove all dropdowns, except the one that should be up */
bob = sed_GetFieldBob(sed, sed_GetFieldNo(sed));
menu = sed_GetMenu(sed);
for (i = 0; i < menu_GetBobCount(menu); i++) {
abob = menu_GetBob(menu, i);
if (abob != NULL && !bob_IsUfunc(abob)) {
if (abob == bob && scancode == MOU_CLICK) {
if (!win_IsEmployed(abob)) {
bfeature = bord_GetFeature(bob);
bord_SetFeature(bob, bfeature | BD_MOUSETHRU);
bob_Repaint(bob);
}
}
else if (win_IsEmployed(abob)) {
bob_Pop(abob); /* Unemploy bob */
}
}
}
break;
}
case MOU_RELEASE:
bob = sed_GetFieldBob(sed, sed_GetFieldNo(sed));
if (bob != NULL && !bob_IsUfunc(bob)) {
/* Pop menu if it's already been up */
if (win_IsEmployed(bob) && bob == disp_GetFromWin()) {
bob_Pop(bob); /* Unemploy bob */
}
/* Don't go into bob if it's not ready
(we're not on its field or it's been popped) */
if (!win_IsEmployed(bob)) {
sed_SetBaton(sed, 0); /* Get out of here */
sed_ToggleExit(sed);
scancode = MOU_THERE; /* For the benefit of 'gotofirst()' */
break;
}
}
/* no break; fall thru */
case ENTER: /* Go in dropdown menu */
case DOWN: /* Display and go in dropdown menu */
/* Set FrameRtn flag TRUE so mouse events in next kb_read will
know we just entered a framer dropdown.
(We'll clear it later - see below).
*/
msys_SetFrameRtn(sed, TRUE);
/* Employ and go in the dropdown, or call the user function */
ret = msys_bobgo(sed, scancode);
switch (ret) {
case 0:
case SED_ABORT: /* LNF special func may return this */
/* Leave FrameRtn flag TRUE so mouse events in next kb_read will
know we just returned from a framer dropdown menu.
(We know we will be re-entering this field right away, so
we can clear the flag again after the kb_read up above).
*/
break;
default:
msys_SetFrameRtn(sed, FALSE);
sed_SetBaton(sed, ret);
sed_ToggleExit(sed);
break;
}
break;
case UP:
break;
case LEFT:
if (sed_LeftField(sed) == SED_STUCK) {
sed_GotoLastField(sed);
}
break;
case RIGHT:
if (sed_RightField(sed) == SED_STUCK) {
sed_GotoFirstField(sed);
}
break;
default:
common_fkey(sed, scancode);
break;
}
gotofirst(sed, scancode);
}
else {
/* Features specific for dropdown menus */
if (!kb_WasMouse()) {
sed_SetActive(sed, TRUE); /* In case mouhandler deactivated it */
}
switch (scancode) {
case ESC:
sed_SetBaton(sed, 0);
sed_ToggleExit(sed);
break;
case ENTER:
case MOU_CLICK:
/* Do the next menu or call the ufunc */
/* Set FrameRtn flag TRUE so mouse events in next kb_read will
know we just entered a dropdown sub-menu or ufunc.
(We'll clear it later - see below).
*/
msys_SetFrameRtn(sed, TRUE);
if ((ret = msys_bobgo(sed, scancode)) != 0) {
msys_SetFrameRtn(sed, FALSE);
sed_SetBaton(sed, ret);
sed_ToggleExit(sed);
}
/* else (if ret == 0) leave FrameRtn flag TRUE so mouse events
in next kb_read'll know we just came from a dropdown
sub-menu or ufunc.
(We know we will be re-entering this field right away, so
we can clear the flag again after the kb_read up above).
*/
/* reset border prompt in case pulldown shares prompt msgwin of
parent field
*/
sed_BorderPrompt(sed, (char *) sed_GetCurrFieldData(sed, 0));
break;
case DOWN:
if (sed_DownField(sed) == SED_STUCK) {
sed_GotoFirstField(sed);
}
break;
case UP:
if (sed_UpField(sed) == SED_STUCK) {
sed_GotoLastField(sed);
}
break;
case LEFT:
case RIGHT:
{
sed_type topmenu;
/* Move to the next dropdown */
topmenu = bob_GetParent(sed);
if (scancode == LEFT) {
if (sed_LeftField(topmenu) == SED_STUCK) {
sed_GotoLastField(topmenu);
}
}
else {
if (sed_RightField(topmenu) == SED_STUCK) {
sed_GotoFirstField(topmenu);
}
}
/* Pass a DOWN arrow to the new field's fkey */
kb_Stuff(DOWN);
sed_SetBaton(sed, 0);
sed_ToggleExit(sed);
break;
}
default:
common_fkey(sed, scancode);
break;
}
}
}
/* -------------------------------------------------------------------------- */
static void common_fkey(sed_type sed, int scancode)
/*
Features shared by top menu and dropdown menus
*/
{
switch (scancode) {
/* Note: FN1 & MOU_HERE & MOU_THERE are normally handled in special_key() */
case HOME:
sed_GotoFirstField(sed);
break;
case END:
sed_GotoLastField(sed);
break;
default:
{
int choice, letter;
/* Do first letter search */
letter = ascii(scancode);
if ((choice = sed_SearchMerge(sed, (char) letter)) != -1) {
sed_GotoField(sed, choice);
kb_Stuff(ENTER); /* select choice immediately */
}
break;
}
}
}
/* -------------------------------------------------------------------------- */
static void gotofirst(sed_type sed, int scancode)
/* Call GotoFirstField and then restore baton */
{
int baton;
if (sed_GetExit(sed) && msys_IsFramer(sed)) {
baton = sed_GetBaton(sed);
sed_GotoFirstField(sed);
/* Set the baton to MOU_THERE instead of 0 so outside world can tell
the diff between a user-generated quit code and normal mouse stuff */
if (scancode == MOU_THERE && baton == 0) {
baton = MOU_THERE;
}
sed_SetBaton(sed, baton);
}
}
/* -------------------------------------------------------------------------- */
void framerbar_help(sed_type sed)
/*
A Special help function for a framer menu bar.
*/
{
bob_type bob;
ufuncopen_struct ufuncopen;
int label = 0;
/* help for topbar, chapter = bob label, paragraph = 0 */
bob = sed_GetFieldBob(sed, sed_GetFieldNo(sed));
if (bob_IsUfunc(bob)) {
bob_Do(bob, UFUNCBM_GETUFUNC, NULL, &ufuncopen);
label = ufuncopen.idata;
}
else if (bob_IsSed(bob)) {
label = sed_GetLabel(bob);
}
help_Show(label, 0);
}
/* -------------------------------------------------------------------------- */