home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
SOURCE
/
CSSRC
/
MSYS.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-12-08
|
6KB
|
215 lines
/*
msys.c
% msys menu system routines
C-scape 3.1
Copyright (c) 1988, by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Revision History:
-----------------
8/30/88 jdc created
11/05/88 jmd removed menu_Close
11/30/88 jmd Modified UFUNCBOB case in msys_GoBob
12/11/88 jmd moved idata to ufunc _od
6/23/89 jmd added GotoFirstField in msys_GoBob
8/21/89 jmd added bob_IsWin to msys_RepaintBob
9/10/89 jmd re-wrote msys_dir
9/11/89 jmd added win_Top to msys_RepaintBob
12/12/89 ted overhauled.
1/24/90 ted Added msys_SetPixShadow stuff.
3/28/90 jmd ansi-fied
8/29/90 ted Removed mouse-waiting before bob entry because new framer
mouse handlers don't need it
9/09/90 jmd added msys_SetHiColors
10/25/90 ted added border prompt resetting in msys_bobgo.
12/08/90 pmcm changed std_fenter to stdNoCur_fenter
*/
#include <stdio.h>
#include <ctype.h>
#include "cscape.h"
#include "scancode.h" /* for scancodes in msys_bobgo */
#include "oaktag.h" /* For IDs in msys.h */
#include "msys.h"
/* -------------------------------------------------------------------------- */
void msys_SetSpecial(sed_type sed, spc_fptr spcfunc)
{
msys_doall(sed, MSYSALL_SETSPCFUNC, (VOID *) &spcfunc);
}
/* -------------------------------------------------------------------------- */
void msys_SetMouse(sed_type sed, mouhandler_fptr mfunc)
{
msys_doall(sed, MSYSALL_SETMFUNC, (VOID *) &mfunc);
}
/* -------------------------------------------------------------------------- */
void msys_SetParentMove(sed_type sed, boolean move)
{
msys_doall(sed, MSYSALL_SETPARMOVE, (VOID *) &move);
}
/* -------------------------------------------------------------------------- */
void msys_SetPixShadow(sed_type sed, opcoord xshad, opcoord yshad)
{
opoint pt;
pt.x = xshad;
pt.y = yshad;
msys_doall(sed, MSYSALL_SETSHADOW, (VOID *) &pt);
}
/* -------------------------------------------------------------------------- */
void msys_SetHiColors(sed_type sed, byte hreg, byte hsel)
{
struct msys_hicolor hicol;
hicol.hireg = hreg;
hicol.hisel = hsel;
msys_doall(sed, MSYSALL_SETHICOLOR, (VOID *) &hicol);
}
/* -------------------------------------------------------------------------- */
int msys_bobgo(sed_type sed, unsigned scancode)
/*
Pass control to the bob attached to the current field of the sed.
If the bob is a window, employ it, call go on it, and unemploy it.
If the bob is a user function, call it and return its value (unless
'scancode' == DOWN, in which case 0 is returned instead of calling the
ufunc).
return value > 0 : quit w/ return value
return value == 0 : escape back to top; don't quit
return value == FRAME_QUIT : quit w/ 0 ret. value
*/
{
bob_type bob;
int fldno;
int ret;
unsigned bfeature;
/* Employ the dropdown and go in it, or call the user function */
/* Remember current fieldno, it could be changed on us. */
fldno = sed_GetFieldNo(sed);
bob = sed_GetFieldBob(sed, fldno);
/* Go in the pulldown or call the function if there ain't no pull down */
if (bob != NULL) {
if (bob_IsUfunc(bob)) {
if (scancode == DOWN) {
return(0);
}
/* call the user function */
bob_Do(bob, WINM_GOREQ, sed_GetData(sed), &ret);
}
else { /* Bob is not a ufunc; must be a win */
/* Top the bob, just in case, or else employ it */
if (win_IsEmployed(bob)) {
win_Top(bob);
}
else {
bob_Repaint(bob);
}
if (bob_IsSed(bob) == TRUE) {
sed_SetData(bob, sed_GetData(sed));
sed_GotoFirstField(bob);
}
/* make border events pass on through to mouse handler */
bfeature = bord_GetFeature(bob);
bord_SetFeature(bob, bfeature | BD_MOUSETHRU);
ret = bob_Go(bob);
bob_Pop(bob);
}
}
/* Reset border prompt in case bob shared prompt msgwin of parent field */
sed_BorderPrompt(sed, (char *) sed_GetCurrFieldData(sed, 0));
return(ret);
}
/* -------------------------------------------------------------------------- */
void msys_doall(sed_type sed, int msg, VOID *data)
/*
This function recursively traces the tree of all children of the given sed,
including sed itself, and performs a function on them specified by 'msg'.
*/
{
int i;
bob_type bob;
if (sed == NULL || !bob_IsWin(sed)) {
return;
}
/* Call ourselves again for each child */
for (i = sed_GetFieldCount(sed) - 1; i >= 0; i--) {
bob = sed_GetFieldBob(sed, i);
if (bob_IsWin(bob)) {
msys_doall(bob, msg, data);
}
}
/* Do the function on ourselves */
switch (msg) {
case MSYSALL_SETPARMOVE:
bob_SetParentMove(sed, *((boolean *) data));
break;
case MSYSALL_SETSHADOW:
win_SetPixShadow(sed, ((opoint *) data)->x, ((opoint *) data)->y);
break;
default:
/* Special cases for sed bobs only */
if (bob_IsSed(sed)) {
switch (msg) {
case MSYSALL_SETFFUNCS:
for (i = sed_GetFieldCount(sed) - 1; i >= 0; i--) {
sed_SetFuncs(sed, i, (field_funcs_struct *) data);
}
break;
case MSYSALL_SETMFUNC:
sed_SetMouse(sed, *((mouhandler_fptr *) data));
break;
case MSYSALL_SETSPCFUNC:
sed_SetSpecial(sed, *((spc_fptr *) data));
break;
case MSYSALL_SETHICOLOR:
sed_SetHiColors(sed,
((struct msys_hicolor *) data)->hisel,
((struct msys_hicolor *) data)->hireg);
break;
}
}
}
}
/* -------------------------------------------------------------------------- */
int msys_dir(sed_type sed)
/*
Determines the orientation of a sed
returns either MENU_HORIZONTAL or MENU_VERTICAL
*/
{
if (sed_GetFieldCount(sed) <= 1 || sed_GetGridField(sed, 0, 1) > 0) {
return(MENU_HORIZONTAL);
}
else {
return(MENU_VERTICAL);
}
}
/* -------------------------------------------------------------------------- */