home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
SOURCE
/
CSSRC
/
SDDISP.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-03-28
|
7KB
|
261 lines
/*
sddisp.c
% sed display routines
The former mdisplay.
This file contains the routines used to display seds.
C-scape 3.2
Copyright (c) 1986, 1987, by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Revision History:
-----------------
1/22/87 jmd moved senter funcs from sed_Go()
1/22/87 jmd added new borders.
1/24/87 jmd added edge clipping.
2/19/87 jmd added draw_ functions
3/11/87 jmd added horizontal scrolling
3/28/87 jmd sed_Repaint now ignores the cursor.
8/15/87 jmd added calls to vid_Cache and vid_Flush
9/04/87 jmd Removed clear_window before hz scroll
9/09/87 jmd added NO_PROTO option
10/07/87 jmd Sped up Horizontal scrolling
11/18/87 jmd changed names of some low-level funcs
2/25/88 jmd split up GetR2M macro for UNIX compilers
4/05/88 jmd Moved senter calls in sed_Draw
4/05/88 jmd Added check for virtual fields in draw_field
4/08/88 jmd changed sed->fieldcount to sed_GetFieldCount()
4/11/88 jmd added scrollable fields (changed draw_field and goto_char)
5/31/88 jmd added sed_DrawText
6/29/88 jmd added windows
7/07/88 jmd moved in adjust_cursor
8/22/88 jmd changed plot fields loop
added bob support
9/12/88 jmd added Caching to sd_refreshfield
9/19/88 jmd added sed_GetCursorType
10/02/88 jmd added win_ShowCursor
10/08/88 jmd added Flags for sed_Draw
10/11/88 jdc added dependent chech for children in sed_Draw
11/14/88 jmd added newest border scheme
12/02/88 jmd removed assert from draw_field
12/13/88 jmd added blank to PlotFields
12/14/88 jmd hand optimized
2/07/89 jmd Removed bordobj.h
3/24/89 jmd added sed_ macros
3/29/89 jmd Removed unused draw code
4/11/89 jmd added single field paint optimization
moved Plot code to sdwin
4/13/89 jmd added sed_GetField
4/26/89 jmd added Aux support
5/24/89 jmd added clipping to refresh_field
5/29/89 jmd simplified paint flags
8/08/89 jdc added LNF senter suppression
8/24/89 jdc Fixed call to opbox_clip
3/17/90 jmd added Cache/Flush
3/28/90 jmd ansi-fied
*/
#include "sed.h"
#include "tbpriv.h" /* For tb_FindLine() */
/**** Operations *****/
void sed_Draw(sed_type sed, unsigned int mode)
/*
mode is a bit masked flag...
effects: if WPD_SENTER calls the senter funcs.
if WPD_BORDER repaints the border.
if WPD_TEXT repaints the textbuffer.
if WPD_FIELDS repaints the fields.
*/
{
cs_Assert(sed_Ok(sed), CS_MD_DRAW_SED, 0);
win_Do(sed, WINM_PAINTREQ, &mode, NULL);
}
void sd_refresh_field(sed_type sed, int fieldno)
/*
effects: refreshes the field specified, then resets the cursor.
requires: that the sed have at least one field in it, and that
the field number is within the proper range.
*/
{
field_type field;
cs_Assert(menu_GetFieldCount(sed_GetMenu(sed)) != 0, CS_MD_RF_NOF, 0);
cs_Assert(fieldno >= 0 && fieldno < menu_GetFieldCount(sed_GetMenu(sed)), CS_MD_RF_FNO, 0);
field = sed_GetField(sed, fieldno);
sd_paintbox(sed, field_GetRow(field), field_GetCol(field),
1, field_GetWidth(field), fieldno);
}
void sd_paintbox(sed_type sed, int row, int col, int hgt, int wid, int mode)
/*
Paints a rectangular region of a sed
row and column are in menu coordinates
the region is clipped against the sed.
mode is the paint flag:
values >= 0 indicate a single field to be painted.
values < 0 paint everything
*/
{
opbox box, sedbox;
win_GetPixBox(sed, &sedbox);
/* Convert coords to sed, pix coords */
box.xmin = win_GetFontWidth(sed) * (col - sed_GetXoffset(sed));
box.xmax = box.xmin + (win_GetFontWidth(sed) * wid);
box.ymin = win_GetFontHeight(sed) * (row - sed_GetYoffset(sed));
box.ymax = box.ymin + (win_GetFontHeight(sed) * hgt);
if (opbox_clipbox(&sedbox, &box) != 0) {
sed_SetPaintFlag(sed, (mode < 0) ? SDPF_ALL : mode);
win_PaintPixBox(sed, &box);
/* reset paint flags */
sed_SetPaintFlag(sed, SDPF_ALL);
}
}
void sd_adjust_cur(sed_type sed)
/*
adjusts the sed's window cursor position
to correctly reflect the current state.
If the sed is not active or if it has no fields
or if the the current field has no writeable positions
then the window cursor is hidden.
*/
{
int fp, row, col;
field_type field;
if (sed_IsActive(sed) &&
sed_GetFieldCount(sed) > 0 &&
sed_GetRecordPos(sed) != NO_WRITEABLES ) {
field = sed_GetCurrField(sed);
/* calculate correct cursor location */
row = field_GetRow(field) - sed_GetYoffset(sed);
col = field_GetCol(field) - sed_GetXoffset(sed);
fp = (sed_GetRecordPos(sed) > 0) ? (sed_GetRecordPos(sed)) : 0;
col += field_GetR2M(field, fp);
col -= field_GetXoffset(field);
disp_Cache();
win_SetCursorPos(sed, row, col);
win_ShowCursor(sed);
disp_Flush();
}
else {
/* hide the cursor */
win_HideCursor(sed);
}
}
boolean sd_goto_char(sed_type sed, int fieldpos)
/*
modifies: sed.
effects: moves to the field position given.
adjusts field's xoffset if it has to.
returns: TRUE if the field needs to be scrolled.
*/
{
field_type field;
int pos, offset, width;
boolean scroll = FALSE;
cs_Assert(sed_Ok(sed), CS_MD_GC_SED, 0);
cs_Assert(fieldpos >= -1, CS_MD_GC_NFP, 0);
cs_Assert(menu_GetFieldCount(sed_GetMenu(sed)) > 0, CS_MD_GC_SED, 0);
sed_SetRecordPos(sed, fieldpos);
field = sed_GetCurrField(sed);
/* if the fieldpos is not visible, adjust the xoffset until it is */
offset = field_GetXoffset(field);
width = field_GetWidth(field);
pos = field_GetR2M(field, fieldpos);
if (pos < offset) {
offset -= (offset - pos);
field_SetXoffset(field, offset);
scroll = TRUE;
}
else if (pos >= offset + width) {
offset += (pos - (offset + width) + 1);
field_SetXoffset(field, offset);
scroll = TRUE;
}
/* adjust the cursor position */
sd_adjust_cur(sed);
return(scroll);
}
void sd_scroll(sed_type sed, int deltarow, int deltacol, boolean preset)
/*
modifies: the sed.
effects: scroll the text vertically by deltarow rows
and scroll the text horizontally by deltacol columns.
e.g., if deltarow is 1, move the text up one row.
If deltarow is -1 scroll down one row.
e.g., if deltacol is 1, move the text left one row.
If deltacol is -1 scroll right one row.
it is an error to call this routine if
scrolling is not possible.
if preset is TRUE then tb hints are preset.
*/
{
register int i;
int oldrow, oldcol;
obj_type bob;
cs_Assert(sed_Ok(sed), CS_MD_SCR_SED, 0);
disp_Cache();
if (deltarow != 0 || deltacol != 0 ) {
sed_SetYoffset(sed, sed_GetYoffset(sed) + deltarow);
sed_SetXoffset(sed, sed_GetXoffset(sed) + deltacol);
if (preset) {
tb_FindLine(sed_GetTextbuf(sed), sed_GetYoffset(sed));
}
win_Scroll(sed, deltarow, deltacol);
/* reposition the sed's dependent bobs */
for (i = 0; i < menu_GetBobCount(sed_GetMenu(sed)); i++) {
if ((bob = menu_GetBob(sed_GetMenu(sed), i)) != NULL) {
if (bob_IsDepend(bob)) {
oldrow = win_GetTopRow(bob);
oldcol = win_GetLeftCol(bob);
win_SetPosition(bob, oldrow - deltarow, oldcol - deltacol);
}
}
}
}
/* Send Scroll message to the border */
sed_SendBorderMsg(sed, BDM_SCROLL, NULL, NULL);
disp_Flush();
}