home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
INCLUDE
/
FLDDECL.H
< prev
next >
Wrap
C/C++ Source or Header
|
1990-05-08
|
6KB
|
187 lines
/*
flddecl.h
% public header for field objects
C-scape 3.2
Copyright (c) 1986, 1987, by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Revision History:
-----------------
11/16/86 sng Modified to handle variable-length fields.
9/01/87 jmd added NO_PROTO option
9/23/87 jmd added field_funcs definition
3/07/88 jmd Added mergeless fields.
4/10/88 jmd Added some new macros.
4/11/88 jmd added scrollable fields
5/11/88 jmd added push/pull funcs
6/01/88 jmd removed anachronisms
6/23/88 jmd converted generic pointers to VOID*
8/20/88 jmd add bob object support
8/23/88 jmd added field_funcs_struct definition
9/19/88 jmd added field name support
10/14/88 jdc added varsize to field_funcs_struct
10/23/88 jmd changed name of varsize defines
11/28/88 jmd reorganized headers
4/11/89 jmd renamed protect to avoid Zortech conflict
prototyped fieldfunc struct
7/15/89 ted Converted '_func' prototypes from typedef to macro.
9/06/89 jmd/gam added user bit to field struct
12/01/89 jmd added bhits for highlighted char (not used yet)
3/28/90 jmd ansi-fied
5/08/90 jmd added underscores to func macros for vms compiler
*/
#define AT_END (-1)
#define MAX_FIELD_LEN 1000
/* field functions */
#define fenter_func(fname) void fname(obj_type _sed)
typedef fenter_func ((*fenter_fptr));
#define fexit_func(fname) boolean fname(obj_type _sed)
typedef fexit_func ((*fexit_fptr));
#define fkey_func(fname) void fname(obj_type _sed)
typedef fkey_func ((*fkey_fptr));
#define senter_func(fname) void fname(obj_type _sed, int _fldno)
typedef senter_func ((*senter_fptr));
#define sexit_func(fname) void fname(obj_type _sed, int _fldno)
typedef sexit_func ((*sexit_fptr));
/* field function structure */
typedef struct field_funcs {
fenter_fptr fentry; /* field entry function */
fexit_fptr fexit; /* field exit function */
fkey_fptr fkey; /* field key function */
senter_fptr sentry; /* sed entry function */
sexit_fptr sexit; /* sed exit function */
SIZE_T varsize;
} field_funcs_struct, *field_funcs_ptr;
#define VAR_INVALID (SIZE_T) 0xfff0
#define VAR_STRING (SIZE_T) 0xfff1
#define VAR_TED (SIZE_T) 0xfff2
/* rules for varsize:
menu_GetVarSize() traps the following values:
VAR_INVALID: gives a cscape error
VAR_STRING : returns the field's length
VAR_TED : returns ted_GetMaxSize if possible, or tb_GetSize
otherwise varsize is returned directly
*/
/* The field type. */
typedef struct field_struct {
/** innards **/
int *r2m; /* record to merge map */
int mergelen; /* length of merge */
int reclen; /* length of record */
char *record; /* record */
char *merge; /* merge */
/** outards (sic) **/
field_funcs_ptr funcs; /* field functions */
VOID *var; /* field variable */
bob_type bob; /* field's attached bob object */
int nameno; /* handle to field name */
int dcount; /* number of data pointers */
VOID **data; /* generic data pointer array */
int row; /* location of field */
int col;
byte reg; /* marked colors */
byte sel;
int left; /* neighboring fieldnos */
int right;
int gcol; /* grid column number */
int width; /* displayed width of the field */
int xoffset; /* xoffset of the displayed field */
/** flags **/
unsigned prot:1; /* protection flag */
unsigned marked:1; /* marked flag */
unsigned ubit:1; /* user bit (for those special times) */
unsigned hicharon:1; /* highlighted character enabled flag */
unsigned hicharno:4; /* highlighted character selector */
} *field_type;
/**** Functions *****/
/* FIELD.C */
extern void field_SetString(field_type f, char *string);
extern void field_SetChar(field_type f, int recpos, char c);
extern boolean field_SetData(field_type field, int datano, VOID *data);
extern VOID *field_GetData(field_type field, int datano);
extern int field_FirstChar(field_type field);
extern int field_LastChar(field_type field);
extern int field_NextChar(field_type field, int fieldpos);
extern int field_PrevChar(field_type field, int fieldpos);
extern void field_SetHiChar(field_type f, int mergepos);
/* FLDGETB.C */
extern boolean field_GetBox(field_type field, ocbox *boxp);
/**** Macros *****/
#define field_SetVar(field, vari) ((field)->var = (vari))
#define field_SetFuncs(field, funks) ((field)->funcs = (funks))
#define field_SetProtected(field, flag) ((field)->prot = (flag))
#define field_SetMarked(field, flag) ((field)->marked = (flag))
#define field_SetUbit(field, b) ((field)->ubit = (b))
#define field_SetXoffset(field, x) ((field)->xoffset = (x))
#define field_GetRecord(f) ((f)->record)
#define field_GetMerge(f) (((f)->merge == NULL) ? (f)->record : (f)->merge)
#define field_GetR2M(f, m) (((f)->merge == NULL) ? (m) : (f)->r2m[m])
#define field_GetProtected(field) ((field)->prot)
#define field_GetMarked(field) ((field)->marked)
#define field_GetUbit(field) ((field)->ubit)
#define field_GetCol(field) ((field)->col)
#define field_GetLastCol(field) ((field)->col + (field)->width - 1)
#define field_GetDataCount(field) ((field)->dcount)
#define field_GetRecordLen(field) ((field)->reclen)
#define field_GetMergeLen(field) ((field)->mergelen)
#define field_GetFuncs(field) ((field)->funcs)
#define field_GetVar(field) ((field)->var)
#define field_GetVarSize(field) ((field)->funcs->varsize)
#define field_GetRow(field) ((field)->row)
#define field_GetRegAttr(field) ((field)->reg)
#define field_GetSelAttr(field) ((field)->sel)
#define field_GetGCol(field) ((field)->gcol)
#define field_GetRight(field) ((field)->right)
#define field_GetLeft(field) ((field)->left)
#define field_GetWidth(field) ((field)->width)
#define field_GetXoffset(field) ((field)->xoffset)
#define field_GetBob(field) ((field)->bob)
#define field_SetBob(field, b) ((field)->bob = (b))
#define field_GetNameNo(field) ((field)->nameno)
#define field_SetNameNo(field, n) ((field)->nameno = (n))
#define field_IsHiCharOn(field) ((field)->hicharon)
#define field_GetHiChar(field) ((field)->hicharno)