home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 4
/
FreshFish_May-June1994.bin
/
tools
/
pufferfish
/
source
/
images.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-03-30
|
8KB
|
324 lines
/*
* images.c
*
* Image routines
*
*/
#include <exec/types.h>
#include <intuition/intuition.h>
#include <intuition/imageclass.h>
#include <clib/exec_protos.h>
#include <clib/graphics_protos.h>
#include <clib/intuition_protos.h>
#include "PufferFish.h"
struct IntuiText start_text =
{
1, 0, JAM2, 0, 0, NULL, " Start ", NULL
};
struct IntuiText end_text =
{
1, 0, JAM2, 0, 0, NULL, " End ", NULL
};
struct IntuiText drives_text =
{
1, 0, JAM2, 0, 0, NULL, " Drives ", NULL
};
struct IntuiText drivenames_text2[5] =
{
1, 0, JAM2, 0, 0, NULL, "DF_", NULL,
1, 0, JAM2, 0, 0, NULL, "DF_", NULL,
1, 0, JAM2, 0, 0, NULL, "DF_", NULL,
1, 0, JAM2, 0, 0, NULL, "DF_", NULL,
1, 0, JAM2, 0, 0, NULL, "", NULL
};
struct IntuiText drivenames_text[5] =
{
1, 0, JAM2, 0, 0, NULL, "DF0: ", &drivenames_text2[0],
1, 0, JAM2, 0, 0, NULL, "DF1: ", &drivenames_text2[1],
1, 0, JAM2, 0, 0, NULL, "DF2: ", &drivenames_text2[2],
1, 0, JAM2, 0, 0, NULL, "DF3: ", &drivenames_text2[3],
1, 0, JAM2, 0, 0, NULL, "", &drivenames_text2[4]
};
/*
* make_systemimages()
*
* Creates system-type images
*
* Returns TRUE on success, FALSE otherwise
*
*/
BOOL make_systemimages( void )
{
BOOL ret = FALSE;
if( upimage = (struct Image *)NewObject( NULL, "sysiclass",
SYSIA_DrawInfo, drawinfo,
SYSIA_Which, UPIMAGE,
TAG_END ))
{
if( downimage = (struct Image *)NewObject( NULL, "sysiclass",
SYSIA_DrawInfo, drawinfo,
SYSIA_Which, DOWNIMAGE,
TAG_END ))
{
if( checkimage = (struct Image *)NewObject( NULL, "sysiclass",
SYSIA_DrawInfo, drawinfo,
SYSIA_Which, CHECKIMAGE,
TAG_END ))
{
ret = TRUE;
}
}
}
if( ret == FALSE )
{
free_systemimages();
}
return( ret );
}
/*
* free_systemimages()
*
* Frees images created by make_systemimages()
*
*/
void free_systemimages( void )
{
if( checkimage )
{
DisposeObject( checkimage );
}
if( downimage )
{
DisposeObject( downimage );
}
if( upimage )
{
DisposeObject( upimage );
}
}
int frame_height;
/*
* make_images()
*
* Makes all non-system-type images
*
* Returns TRUE on success, FALSE otherwise
*
*/
BOOL make_images( void )
{
BOOL ret = FALSE;
ULONG arrowwidth, arrowheight, checkwidth, checkheight;
int i;
start_text.ITextFont = screen->Font;
end_text.ITextFont = screen->Font;
drives_text.ITextFont = screen->Font;
for( i = 0; i < 5; i += 1 )
{
drivenames_text[i].ITextFont = screen->Font;
drivenames_text2[i].ITextFont = screen->Font;
}
drivenames_text[4].IText = additional_device;
GetAttr( IA_Width, upimage, &arrowwidth );
GetAttr( IA_Height, upimage, &arrowheight );
GetAttr( IA_Width, checkimage, &checkwidth );
GetAttr( IA_Height, checkimage, &checkheight );
if( frameimage = (struct Image *)NewObject( NULL, "frameiclass",
TAG_END ))
{
frame_height = (arrowheight + 2) + (drawinfo->dri_Font->tf_YSize + 2 + 4) + (arrowheight + 2) + (drawinfo->dri_Font->tf_YSize) + GF_TOPBORDER * 3 / 2;
if( frame = (struct Image *)NewObject( NULL, "frameiclass",
IA_Top, (win->BorderTop) + GF_TOPBORDER,
IA_Left, (win->BorderLeft) + GF_LEFTBORDER,
IA_Width, (arrowwidth * 11 / 2) + drawinfo->dri_Font->tf_XSize * 5 + 8,
IA_Height, frame_height,
IA_Recessed, TRUE,
TAG_END ))
{
if( start = (struct Image *)NewObject( NULL, "itexticlass",
IA_FGPen, drawinfo->dri_Pens[TEXTPEN],
IA_BGPen, drawinfo->dri_Pens[BACKGROUNDPEN],
IA_Data, &start_text,
TAG_END ))
{
if( end = (struct Image *)NewObject( NULL, "itexticlass",
IA_FGPen, drawinfo->dri_Pens[TEXTPEN],
IA_BGPen, drawinfo->dri_Pens[BACKGROUNDPEN],
IA_Data, &end_text,
TAG_END ))
{
for( i = 0; i < 5; i += 1 )
{
drivename[i] = (struct Image *)NewObject( NULL, "itexticlass",
IA_FGPen, drawinfo->dri_Pens[TEXTPEN],
IA_BGPen, drawinfo->dri_Pens[BACKGROUNDPEN],
IA_Data, &drivenames_text[i],
TAG_END );
if( !drivename[i] )
{
break;
}
}
if( i == 5 )
{
if( checkheight < drawinfo->dri_Font->tf_YSize )
{
checkheight = drawinfo->dri_Font->tf_YSize;
}
if( drive_frame = (struct Image *)NewObject( NULL, "frameiclass",
IA_Top, (win->BorderTop) + GF_TOPBORDER,
IA_Left, (win->BorderLeft) + GF_LEFTBORDER + arrowwidth * 6 + drawinfo->dri_Font->tf_XSize * 5 + 8,
IA_Height, 5 * (checkheight + 5) + GF_TOPBORDER,
IA_Width, checkwidth + 4 + 2 * drawinfo->dri_Font->tf_XSize + IntuiTextLength( &drivenames_text[0] ),
IA_Recessed, TRUE,
TAG_END ))
{
if( drive = (struct Image *)NewObject( NULL, "itexticlass",
IA_FGPen, drawinfo->dri_Pens[TEXTPEN],
IA_BGPen, drawinfo->dri_Pens[BACKGROUNDPEN],
IA_Data, &drives_text,
TAG_END ))
{
ret = TRUE;
}
}
}
}
}
}
}
if( ret == FALSE )
{
free_images();
}
return( ret );
}
/*
* free_images()
*
* Frees all non-system-type images
*
*/
void free_images( void )
{
int i;
for( i = 0; i < 5; i += 1 )
{
if( drivename[i] )
{
DisposeObject( drivename[i] );
}
}
if( drive )
{
DisposeObject( drive );
}
if( drive_frame )
{
DisposeObject( drive_frame );
}
if( end )
{
DisposeObject( end );
}
if( start )
{
DisposeObject( start );
}
if( frame )
{
DisposeObject( frame );
}
if( frameimage )
{
DisposeObject( frameimage );
}
}
/*
* draw_images()
*
* Draws all images into the window in their correct positions
*
*/
void draw_images( void )
{
ULONG newtop, i, width, height;
GetAttr( IA_Width, upimage, &width );
// Draw top digits frame
DrawImageState( win->RPort, frame, 0, 0, IDS_NORMAL, drawinfo );
// Draw bottom digits frame
DrawImageState( win->RPort, frame, 0, frame_height + GF_TOPBORDER, IDS_NORMAL, drawinfo );
// Draw drive frame
DrawImageState( win->RPort, drive_frame, 0, 0, IDS_NORMAL, drawinfo );
// Clear space for titles
SetAPen( win->RPort, drawinfo->dri_Pens[BACKGROUNDPEN] );
// Clear top digits title
RectFill( win->RPort,
win->BorderLeft + GF_LEFTBORDER * 2,
win->BorderTop + (GF_TOPBORDER / 2) + 1,
win->BorderLeft + GF_LEFTBORDER * 2 + IntuiTextLength( &start_text ),
win->BorderTop + (GF_TOPBORDER / 2) + 1 + drawinfo->dri_Font->tf_YSize);
// Clear bottom digits title
RectFill( win->RPort,
win->BorderLeft + GF_LEFTBORDER * 2,
win->BorderTop + frame_height + (GF_TOPBORDER / 2) + 1 + drawinfo->dri_Font->tf_YSize,
win->BorderLeft + GF_LEFTBORDER * 2 + IntuiTextLength( &end_text ),
win->BorderTop + frame_height + (GF_TOPBORDER / 2) + 1 + 2 * drawinfo->dri_Font->tf_YSize);
// Clear drive list title
RectFill( win->RPort,
win->BorderLeft + GF_LEFTBORDER * 2 + width * 6 + drawinfo->dri_Font->tf_XSize * 5 + 8,
win->BorderTop + (GF_TOPBORDER / 2) + 1,
win->BorderLeft + GF_LEFTBORDER * 2 + width * 6 + drawinfo->dri_Font->tf_XSize * 5 + 8 + IntuiTextLength( &drives_text ),
win->BorderTop + (GF_TOPBORDER / 2) + 1 + drawinfo->dri_Font->tf_YSize);
// Draw top digits title
DrawImageState( win->RPort, start,
win->BorderLeft + GF_LEFTBORDER * 2,
win->BorderTop + (GF_TOPBORDER / 2) + 1,
IDS_NORMAL, drawinfo );
// Draw bottom digits title
DrawImageState( win->RPort, end,
win->BorderLeft + GF_LEFTBORDER * 2,
win->BorderTop + frame_height + (GF_TOPBORDER / 2) + 1 + drawinfo->dri_Font->tf_YSize,
IDS_NORMAL, drawinfo );
// Draw drive list title
DrawImageState( win->RPort, drive,
win->BorderLeft + GF_LEFTBORDER * 2 + width * 6 + drawinfo->dri_Font->tf_XSize * 5 + 8,
win->BorderTop + (GF_TOPBORDER / 2) + 1,
IDS_NORMAL, drawinfo );
// Draw drive names
GetAttr( IA_Height, checkimage, &height );
if( height < drawinfo->dri_Font->tf_YSize )
{
height = drawinfo->dri_Font->tf_YSize;
}
for( i = 0; i < 5; i += 1 )
{
newtop = win->BorderTop + GF_TOPBORDER * 2 - 2 + i * (height + 5) + (height - drawinfo->dri_Font->tf_YSize) / 2;
DrawImageState( win->RPort, drivename[i],
win->BorderLeft + GF_LEFTBORDER * 2 + width * 6 + drawinfo->dri_Font->tf_XSize * 5 + 8,
newtop,
IDS_NORMAL, drawinfo );
}
}