home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
SOURCE
/
CSSRC
/
SDSCRLAD.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-03-28
|
3KB
|
114 lines
/*
sdscrlad.c
% sd_scroll_adjust
C-scape 3.2
Copyright (c) 1986, 1987, by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Revision History:
-----------------
2/14/86 jmd replaced scroll.
3/11/87 jmd replaced scroll for horizontal scrolling.
3/11/87 jmd added horizontal adjusting.
3/22/87 jmd added search for first char of a field.
11/18/87 jmd changed names of some low-level funcs
7/08/88 jmd converted to menu coords
8/23/88 jmd added check for dependent screens
9/12/88 jmd Added in and out data to objects
11/25/88 jmd Added check for sizeless fields
12/07/88 jmd fixed sideways adjust bug
3/24/89 jmd added sed_ macros
4/13/89 jmd added sed_GetField macro
8/08/89 jmd converted bob calls to window calls
3/28/90 jmd ansi-fied
*/
#include "sed.h"
void sd_scroll_adjust(sed_type sed, int fieldno)
/*
requires: a field number within range.
effects: if the field indicated is off the screen, scroll until
it's on the screen.
Always tries to make first position in a field visible.
Note: Does not do anything if the field (and its bob)
has no size.
*/
{
int vt_adj = 0; /* adjustment components */
int hz_adj = 0;
int frow, lrow, fcol, lcol, edge, xoff, yoff;
bob_type bob;
boolean isabob = FALSE;
field_type field;
cs_Assert(sed_Ok(sed), CS_SD_SCRA_SED, 0);
xoff = sed_GetXoffset(sed);
yoff = sed_GetYoffset(sed);
/* if the field has a dependent screen, adjust to it */
if ((bob = sed_GetFieldBob(sed, fieldno)) != NULL) {
if (bob_IsDepend(bob)) {
isabob = TRUE;
}
}
/* get adjust parameters (from field or bob object) */
if (isabob) {
/* bob object */
frow = bord_GetTopRow(bob) - win_GetTopRow(sed) + yoff;
fcol = bord_GetLeftCol(bob) - win_GetLeftCol(sed) + xoff;
lrow = frow + bord_GetHeight(bob) - 1;
lcol = fcol + bord_GetWidth(bob) - 1;
}
else {
/* field */
field = sed_GetField(sed, fieldno);
frow = field_GetRow(field); /* first row */
lrow = frow; /* last row */
fcol = field_GetCol(field); /* first pos */
lcol = fcol + field_GetWidth(field) - 1; /* last pos */
}
/* Skip "sizeless" fields */
if (lcol < fcol || lrow < frow) {
return;
}
/* compute vertical component */
edge = yoff + sed_GetHeight(sed) - 1;
if (frow < yoff) {
/* This case is first because the start of the field is more important */
vt_adj = frow - yoff;
}
else if (lrow > edge) {
/* scroll so that end is visible, but not so that start is hidden */
vt_adj = int_min(lrow - edge, frow - yoff);
}
/* compute horizontal component */
edge = xoff + sed_GetWidth(sed) - 1;
if (fcol < xoff) {
/* This case is first because the start of the field is more important */
hz_adj = fcol - xoff;
}
else if (lcol > edge) {
/* scroll so that end is visible, but not so that start is hidden */
hz_adj = int_min(lcol - edge, fcol - xoff);
}
/* do it */
if (vt_adj != 0 || hz_adj != 0) {
sd_scroll(sed, vt_adj, hz_adj, TRUE);
}
}