home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 3
/
AACD03.BIN
/
AACD
/
Programming
/
ImageLib
/
Image_lib
/
lib_source
/
Draw3DBox.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-05-27
|
3KB
|
126 lines
/* Draw3DBox.c © Paweî Marciniak <pmarciniak@lodz.home.pl>*/
#include <string.h>
#include <exec/types.h>
#include <graphics/text.h>
#include <utility/tagitem.h>
#include <proto/graphics.h>
#include <proto/dos.h>
#include <proto/exec.h>
#include <proto/utility.h>
#include "/include/libraries/image.h"
#define DrawLine(x,y,x2,y2) Move( rp, x , y); \
Draw( rp, x2, y2 )
/**Draw3DBox************************************************************/
/* Draw3DBox() (c) 1997 Paweî Marciniak
Modify date | Version | Comment
---------------+-----------+------------------------------
15-03-97 15:23 | 1.0 |
18-08-97 9:25 | 2.0 |
12-09-97 20:45 | 2.1 |
25-10-98 21:31 | 2.2 | little bug in drawing bright edges when align is center
11-02-99 17:14 | 2.3 | little bug in drawing bright edges
*/
void __saveds __asm Draw3DBoxA(
register __a0 struct RastPort *rp_reg,
register __a1 struct TextFont *TxFont_reg,
register __a2 struct TagItem *Tags)
{
struct RastPort *rp = rp_reg;
struct TextFont *TxFont = TxFont_reg;
UWORD xpos, ypos, xsize, ysize, txtlen;
UWORD dark_pen=1;
UWORD bright_pen=2;
UWORD align=ALIGN_LEFT;
STRPTR text;
struct TagItem *ti, *TagsTmp = Tags;
/* Tags */
while ( ti = NextTagItem( &TagsTmp ) )
{
switch ( ti->ti_Tag )
{
case DBA_PosX:
xpos = ( UWORD )ti->ti_Data;
break;
case DBA_PosY:
ypos = ( UWORD )ti->ti_Data;
break;
case DBA_Width:
xsize = ( UWORD )ti->ti_Data - 1;
break;
case DBA_Height:
ysize = ( UWORD )ti->ti_Data - 1;
break;
case DBA_BrightEdge:
bright_pen = ( UWORD )ti->ti_Data;
break;
case DBA_DarkEdge:
dark_pen = ( UWORD )ti->ti_Data;
break;
case DBA_Align:
align = ( UWORD )ti->ti_Data;
break;
case DBA_Text:
text = ( STRPTR )ti->ti_Data;
break;
default:
break;
}
}
SetFont( rp, TxFont );
SetAPen( rp, 1);
SetBPen( rp, 0);
SetDrMd( rp, JAM1 );
txtlen=TextLength( rp, text, strlen(text)); //dîugoôê tekstu
if(align==ALIGN_CENTER)
Move( rp, xpos+(xsize/2)-(txtlen/2), ypos+(TxFont->tf_YSize/2)-(TxFont->tf_YSize-TxFont->tf_Baseline)); //rp -RastPort , pozycja x, pozycja y
else
Move( rp, xpos+10, ypos+(TxFont->tf_YSize/2)-(TxFont->tf_YSize-TxFont->tf_Baseline));
Text( rp, text, (ULONG)strlen(text) );
SetAPen( rp, dark_pen );
if(align==ALIGN_CENTER)
{
DrawLine( xpos, ypos, xpos+(xsize/2)-(txtlen/2), ypos );
DrawLine( xpos+(xsize/2)+(txtlen/2), ypos, xpos+xsize, ypos );
}
else
{
DrawLine( xpos, ypos, xpos+10, ypos );
DrawLine( xpos+10+txtlen, ypos, xpos+xsize, ypos );
}
DrawLine( xpos+xsize, ypos, xpos+xsize, ypos+ysize );
DrawLine( xpos+xsize, ypos+ysize, xpos, ypos+ysize );
DrawLine( xpos, ypos+ysize, xpos, ypos );
SetAPen( rp, bright_pen );
if(align==ALIGN_CENTER)
{
DrawLine( xpos+1, ypos+1, xpos+(xsize/2)-(txtlen/2)-1, ypos+1 );
DrawLine( xpos+(xsize/2)+(txtlen/2), ypos+1, xpos+xsize+1, ypos+1 );
}
else
{
DrawLine( xpos+1, ypos+1, xpos+9, ypos+1 );
DrawLine( xpos+10+txtlen, ypos+1, xpos+xsize+1, ypos+1 );
}
DrawLine( xpos+xsize+1, ypos+1, xpos+xsize+1, ypos+ysize+1 );
DrawLine( xpos+xsize+1, ypos+ysize+1, xpos+1, ypos+ysize+1 );
DrawLine( xpos+1, ypos+ysize+1, xpos+1, ypos+1 );
SetAPen( rp, 0 );
}