|
|
DataMuseum.dkPresents historical artifacts from the history of: Commodore CBM-900 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Commodore CBM-900 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 1866 (0x74a)
Types: TextFile
Notes: UNIX file
Names: »dalert.c«
└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code
└─⟦2d53db1df⟧ UNIX Filesystem
└─⟦this⟧ »hr/src/desk/dalert.c«
#include "desk.h"
#define XMARGIN (16)
#define YMARGIN (16)
#define ALERT (5)
struct alert
{
int a_rows; /* number of rows of text */
RECT a_rect; /* destination rectangle */
char **a_str; /* ptr to string ptr array */
};
struct alert alert[ALERT]; /* alert definitions */
int aln; /* 1st free alert entry */
int alopen = -1; /* current open entry */
AL_New(nrow, str)
int nrow;
register char **str;
{
register struct alert *alp;
register int height;
register int width;
int j;
RECT rect;
if ( aln == ALERT )
return -1;
if ( nrow <= 0 || nrow > 128 || !str )
return -1;
alp = &alert[aln];
alp->a_str = str;
alp->a_rows = nrow;
if ( (height = nrow * dskFntH + 2*YMARGIN) > DIS_HEIGHT )
return -1;
width = 0;
while ( nrow-- )
{
if ( *str && (j = D_StrW(*str, strlen(*str))) > width )
width = j;
str++;
}
width += 2*XMARGIN;
if ( width > DIS_WIDTH )
return -1;
rect.origin.x = 0;
rect.origin.y = 0;
rect.corner.x = width;
rect.corner.y = height;
alp->a_rect = R_addp(rect, XMIN + (DIS_WIDTH - rect.corner.x)/2,
YMIN + (DIS_HEIGHT - rect.corner.y)/2 );
if ( height * words_between(alp->a_rect.origin.x, alp->a_rect.corner.x)
> HEAP )
return -1;
return aln++;
}
AL_Open(n)
register int n;
{
register char **s;
register int x, y;
RECT rect;
if ( n >= aln || alopen >= 0 )
return -1;
if ( D_Open(&alert[n].a_rect) == -1 )
return -1;
dskClip = alert[n].a_rect;
D_Frame(&dskClip, 3);
rect = R_inset(dskClip, 4, 4);
D_Frame(&rect, 3);
x = alert[n].a_rect.origin.x + XMARGIN;
y = alert[n].a_rect.origin.y + YMARGIN + dskFntA;
s = alert[n].a_str;
n = alert[n].a_rows;
while ( n-- )
{
if ( *s )
{
D_Str(*s, strlen(*s), x, y);
}
s++;
y += dskFntH;
}
alopen = n;
return 0;
}
AL_Close()
{
if ( alopen == 1 )
return;
D_Close(&dskClip, 0);
alopen = -1;
}