Category : C Source Code
Archive   : C_ROTATE.ZIP
Filename : GPRINT.I

 
Output of file : GPRINT.I contained in archive : C_ROTATE.ZIP
/* Listing for GPRINT.I (include file)
Graphics programming in Turbo C++ p 91
*/
void erasestr( int xloc, int yloc, char *str )
{
struct textsettingstype textinfo;
int xdim, ydim;
void *textimage;
gettextsettings( &textinfo );
switch( textinfo.direction )
{
case HORIZ_DIR: xdim = textwidth( str );
ydim = textheight( str );
xloc--;
break;
case VERT_DIR : ydim = textwidth( str );
xdim = textheight( str );
yloc++;
}
switch( textinfo.horiz )
{
case LEFT_TEXT : break;
case CENTER_TEXT: xloc -= xdim / 2;
break;
case RIGHT_TEXT : xloc -= xdim;
}
switch( textinfo.vert )
{
case BOTTOM_TEXT: yloc -= ydim;
break;
case CENTER_TEXT: yloc -= ydim / 2;
break;
case TOP_TEXT : ;
}
while( xloc<0 ) { xloc++; xdim--; }
while( yloc<0 ) { yloc++; ydim--; }
textimage = malloc( imagesize( xloc, yloc, xdim, ydim ) );
getimage( xloc, yloc, xloc+xdim, yloc+ydim, textimage );
putimage( xloc, yloc, textimage, XOR_PUT );
free( textimage );
}

/* GPRINTF is like printf but printed in graphics mode based on pixel loc */
void gprintf( int *xloc, int *yloc, char *fmt, ... )
{
va_list argptr;
char str[140];
struct textsettingstype textinfo;
int pos_adj = *xloc;
va_start( argptr, fmt);
vsprintf( str, fmt, argptr );
gettextsettings( &textinfo );
outtextxy( pos_adj, *yloc, str);
switch( textinfo.direction )
{
case HORIZ_DIR: *yloc += textheight( str ) + 2;
break;
case VERT_DIR: *xloc += textheight( str ) + 2;
};
va_end( argptr );
}

/* GPRINTC like above but resets background color first */
void gprintc( int *xloc, int *yloc, char *fmt, ... )
{
va_list argptr;
char str[140];
struct textsettingstype textinfo;
int pos_adj = *xloc;
va_start( argptr, fmt);
vsprintf( str, fmt, argptr );
gettextsettings( &textinfo );
erasestr( *xloc, *yloc, str );
outtextxy( pos_adj, *yloc, str);
switch( textinfo.direction )
{
case HORIZ_DIR: *yloc += textheight( str ) + 2;
break;
case VERT_DIR: *xloc += textheight( str ) + 2;
};
va_end( argptr );
}

/* GPRINTXY- like gprintc except passed by value rather than address */
void gprintxy( int xloc, int yloc, char *fmt, ... )
{
va_list argptr;
char str[140];
struct textsettingstype textinfo;
va_start( argptr, fmt );
vsprintf( str, fmt, argptr );
gettextsettings( &textinfo );
erasestr( xloc, yloc, str );
outtextxy( xloc, yloc, str );
va_end( argptr );
}



  3 Responses to “Category : C Source Code
Archive   : C_ROTATE.ZIP
Filename : GPRINT.I

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/