home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
SOURCE
/
CSSRC
/
FRAMER.C
< prev
next >
Wrap
Text File
|
1990-09-24
|
5KB
|
210 lines
/*
framer.c
% framer menu functions
rules for user functions:
they get passed two arguments (a VOID * and an int).
The VOID * is passed through msys_Go().
The int is the value parameter from the frame_def struct.
they return a positive value if processing is finished
This value is passed up and returned from msys_Go
0 acts like an ESCape was pressed.
int user_func(VOID *, int);
C-scape 3.2
Copyright (c) 1988, by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Revision History:
-----------------
8/30/88 jdc re-created
12/11/88 jmd moved idata to ufunc _od
12/18/88 jdc fixed field NAME_MAXLEN bug
03/08/89 jdc remove field name stuff
4/22/89 jmd changed border to bord
7/26/89 jmd made frame_Lock a function
8/11/89 jmd added call to ufunc_Open
12/12/89 ted overhauled.
12/12/89 ted Removed dir, row, col args from frame_create.
1/05/89 jmd added hilite support to the def structure
3/28/90 jmd ansi-fied
9/23/90 ted Put loop in frame_Go to support demofram-style framer usage.
*/
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include "cscape.h"
#include "oaktag.h" /* For IDs in msys.h */
#include "msys.h"
#include "scancode.h" /* For MOU_THERE baton/scancode */
#define MAXCHOICE 80
/* -------------------------------------------------------------------------- */
sed_type frame_create(struct frame_def frame_list[], bd_fptr bord, byte bkg, byte sel, byte bdr, field_funcs_ptr ffuncs, mouhandler_fptr fmfunc)
/*
Create a menuing system object from a frame_list.
The object is a top menu sed with sed bobs and ufunc bobs attached to the
fields in the top menu. The sed bobs are 'independent' and are employed
only when they are activated.
*/
{
menu_type topmenu, popmenu;
sed_type topsed;
bob_type bob;
int i, top;
int r1, c1, row, col;
char string[MAXCHOICE + 1];
int hichar;
if (frame_list[0].choice == NULL ||
(topmenu = menu_Open()) == NULL) {
return(NULL);
}
for (i = 1, top = 0, popmenu = NULL;; i++) {
bob = NULL;
if ( frame_list[i].choice == NULL ) {
/* process field in top sed */
if (popmenu != NULL) {
menu_Flush(popmenu);
if ((bob = sed_Open(popmenu)) == NULL) {
return(NULL);
}
sed_SetColors(bob, bkg, bkg, sel);
sed_SetBorder(bob, bord);
sed_SetBorderColor(bob, bdr);
sed_SetLabel(bob, frame_list[top].value);
sed_SetMouse(bob, fmfunc);
win_SetParentClip(bob, BOB_INDEPENDENT);
}
else if ( (bob = ufunc_Open(frame_list[top].frame_func,
frame_list[top].value)) == NULL ) {
return(NULL);
}
/* check for hilighted characters */
if ((hichar = msys_ParseChoice(frame_list[top].choice, string, MAXCHOICE)) >= 0) {
hichar++;
}
menu_Printf(topmenu, "@fbh%d[ %s ]", NULL, ffuncs, bob, hichar, string);
if (frame_list[i+1].choice == NULL) {
/* done parsing frame_list */
break;
}
else {
i++;
top = i;
}
popmenu = NULL;
}
else {
/* process field in pop sed */
if ( popmenu == NULL ) {
if ( (popmenu = menu_Open()) == NULL ) {
return(NULL);
}
}
else {
menu_Printf(popmenu, "\n");
}
if ((bob = ufunc_Open(frame_list[i].frame_func,
frame_list[i].value)) == NULL ) {
return(NULL);
}
/* check for hilighted characters */
if ((hichar = msys_ParseChoice(frame_list[i].choice, string, MAXCHOICE)) >= 0) {
hichar++;
}
menu_Printf(popmenu, "@fbh%d[ %s ]", NULL, ffuncs, bob, hichar, string);
}
}
menu_Flush(topmenu);
if ((topsed = sed_Open(topmenu)) == NULL) {
return(NULL);
}
sed_SetColors(topsed, bkg, bkg, sel);
sed_SetWidth(topsed, disp_GetWidth());
sed_SetLabel(topsed, frame_list[0].value);
sed_SetMouse(topsed, fmfunc);
/* Set the positions of all dropdowns in framer */
sed_GetBordCorners(topsed, &r1, &c1, &row, &col);
row++;
for (i = sed_GetFieldCount(topsed) - 1; i >= 0; i--) {
bob = sed_GetFieldBob(topsed, i);
if (bob_IsWin(bob)) {
col = sed_GetFieldCol(topsed, i);
bob_SetPosition(bob, row, col);
}
}
return(topsed);
}
/* -------------------------------------------------------------------------- */
boolean frame_Lock(sed_type sed, int family, int member, byte attr)
/*
"lock" a menu choice in a framer menu.
*/
{
return(frame_do(sed, MSYS_LOCK, family, member, (VOID *) &attr));
}
/* -------------------------------------------------------------------------- */
boolean frame_do(sed_type sed, int msg, int family, int member, VOID *indata)
/*
*/
{
int code[3];
code[0] = family;
code[1] = member;
code[2] = -1;
return(msys_do(sed, code, msg, indata));
}
/* -------------------------------------------------------------------------- */
int frame_Go(sed_type sed, int chr, VOID *data)
{
int choice, ret;
if (chr != ' ') {
if ((choice = sed_SearchMerge(sed, (char)chr)) == -1) {
return(0);
}
else {
sed_GotoField(sed, choice);
}
}
sed_SetData(sed, data);
/* Put sed_Go in a loop so normal mouse operation won't make us return */
for (;;) {
if ((ret = sed_Go(sed)) != MOU_THERE) {
break;
}
}
return(ret);
}
/* -------------------------------------------------------------------------- */