戻る
/////////////////////////////////////////////////////////
// "bmpwaku.cpp" 1996/07/05
//
// int bmpwakuInitLoad()をadv1.cppからコールすることにした。1997/01/14
//
/////////////////////////////////////////////////////////

#include 
#include "saver.h"
#include "savdef.h"
#include "mstring.h"
#include "mystream.h"
#include "mylist.h"

#include "mydirectory.h"

#include "bmpwaku.h"

BOOL		InitOK = FALSE;

mylist bmpparts;
mylist bmpparts2;
mylist bmpparts3;
mylist bmpparts4;
mylist bmpparts5;

//MyString	flDirectory(256);

enum {
	LEFTTOP,
	RIGHTTOP,
	RIGHTBOTTOM,
	LEFTBOTTOM,
	TOP,
	RIGHT,
	BOTTOM,
	LEFT,
};

extern int wwww_bmpwaku_cpp_count;				// "newc.cpp"

/////////////////////////////////////////////////////////
//
//	class bmpwakuBlock::
//
//
/////////////////////////////////////////////////////////

bmpwakuBlock::bmpwakuBlock()
{
	bmp = NULL;
	bmpBG = new BmpLoad03();						wwww_bmpwaku_cpp_count++;
	locate.x = 0;
	locate.y = 0;
}

bmpwakuBlock::~bmpwakuBlock()
{
	delete bmpBG;									wwww_bmpwaku_cpp_count--;
}

void bmpwakuBlock::AssignBMP( BmpLoad03 *b )
{
	bmp = b;
}

void bmpwakuBlock::LocateAndSize( int x, int y, int cx, int cy )
{
	locate.x = x;
	locate.y = y;
	size.x = cx;
	size.y = cy;
	bmpBG->Create( size );
}

void bmpwakuBlock::ImageDelete()
{
	bmpBG->ImageDelete();
}

void bmpwakuBlock::ImageCopy( char huge *work65 )
{
	bmp->GetImage( work65 );
	bmpBG->FillImage( work65, bmp->Size().x, bmp->Size().y );
}

RECT bmpwakuBlock::DrawArea( POINT loc )
{
	POINT p;

	p.x = loc.x + locate.x;
	p.y = loc.y + locate.y;

	RECT rc;

	rc.left   = p.x;
	rc.top    = p.y;
	rc.right  = p.x + bmpBG->Size().x;
	rc.bottom = p.y + bmpBG->Size().y;

	return rc;
}

void bmpwakuBlock::Draw( HDC DC, POINT loc )
{
	POINT p;
	p.x = loc.x + locate.x;
	p.y = loc.y + locate.y;
	bmpBG->Draw( DC, p );
}

/////////////////////////////////////////////////////////
//	area redraw.
/////////////////////////////////////////////////////////

int bmpwakuBlock::AreaRedraw( HDC DC, POINT loc, RECT rc )
{
	MyRECT	BmpRect;
	RECT	ViewRect;
	POINT	p;

	p.x = loc.x + locate.x;
	p.y = loc.y + locate.y;

	BmpRect.Set( p.x, p.y, p.x + bmpBG->Size().x - 1, p.y + bmpBG->Size().y - 1 );

	ViewRect = BmpRect.CommonArea( rc );

	if ( BmpRect.flag )
	{
		int		oldStretchModeNumber = bmpBG->StretchModeNumber;
		POINT	pt, sz;

		pt.x = ViewRect.left - p.x;
		pt.y = ViewRect.top  - p.y;
		sz.x = ViewRect.right  - p.x - pt.x + 1;
		sz.y = ViewRect.bottom - p.y - pt.y + 1;

		bmpBG->StretchMode( BmpLoad03::StretchMODE_RECTVIEW );
		bmpBG->SetBmpView( pt, sz );

		bmpBG->Draw( DC, ViewRect.left, ViewRect.top );

		bmpBG->StretchMode( (BmpLoad03::STRETCHMODE)oldStretchModeNumber );
	}
	return 0;
}

/////////////////////////////////////////////////////////
//	system initalize.
// int bmpwakuInitLoad()をadv1.cppからコールすることにした。1997/01/14
/////////////////////////////////////////////////////////

int bmpwakuInitLoad()
{
	if( InitOK )
		return 0;

	InitOK = TRUE;

	MyString	fl( "waku1" );

	for(int i=0;i<8;i++)
	{
		bmpparts.append( new BmpLoad03() );
		bmpparts2.append( new BmpLoad03() );
		bmpparts3.append( new BmpLoad03() );
		bmpparts4.append( new BmpLoad03() );
		bmpparts5.append( new BmpLoad03() );

		fl.DecStr( i + 1, 4, 1 );

		*(fl.String+3) = 'u';
		if( bmpparts[i]->Load( MyString( DISKDEVICE->DirectoryGRP(), fl.String ).String ) ) return 1;

		*(fl.String+3) = '2';
		if( bmpparts2[i]->Load( MyString( DISKDEVICE->DirectoryGRP(), fl.String ).String ) ) return 1;

		*(fl.String+3) = '3';
		if( bmpparts3[i]->Load( MyString( DISKDEVICE->DirectoryGRP(), fl.String ).String ) ) return 1;

		*(fl.String+3) = '4';
		if( bmpparts4[i]->Load( MyString( DISKDEVICE->DirectoryGRP(), fl.String ).String ) ) return 1;

		*(fl.String+3) = '5';
		if( bmpparts5[i]->Load( MyString( DISKDEVICE->DirectoryGRP(), fl.String ).String ) ) return 1;
	}
	return 0;
}

/////////////////////////////////////////////////////////
//
//	class bmpwaku::
//
//
/////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////
//	init.
/////////////////////////////////////////////////////////

bmpwaku::bmpwaku( char huge *work65530 )
{
	work65 = work65530;

	waku.append( new bmpwakuBlock() );
	waku.append( new bmpwakuBlock() );
	waku.append( new bmpwakuBlock() );
	waku.append( new bmpwakuBlock() );
	waku.append( new bmpwakuBlock() );
	waku.append( new bmpwakuBlock() );
	waku.append( new bmpwakuBlock() );
	waku.append( new bmpwakuBlock() );
}

bmpwaku::~bmpwaku()
{
}

int bmpwaku::Init()
{
	bmpwakuInitLoad();

	for(int i=0;i<8;i++)
	{
		waku[i]->AssignBMP( bmpparts[i] );
	}

	return 0;
}

int bmpwaku::Init( int n )
{
	bmpwakuInitLoad();

	for(int i=0;i<8;i++)
	{
		switch( n )
		{
		case 1:
			waku[i]->AssignBMP( bmpparts[i] );
			break;
		case 2:
			waku[i]->AssignBMP( bmpparts2[i] );
			break;
		case 3:
			waku[i]->AssignBMP( bmpparts3[i] );
			break;
		case 4:
			waku[i]->AssignBMP( bmpparts4[i] );
			break;
		case 5:
			waku[i]->AssignBMP( bmpparts5[i] );
			break;
		default:
			waku[i]->AssignBMP( bmpparts[i] );
			break;
		}
	}

	return 0;
}

/////////////////////////////////////////////////////////
//	create.
/////////////////////////////////////////////////////////

void bmpwaku::Create( POINT size )
{
	InterViewSize = size;

	wakuLocate();

	int i;
	for(i=0;i<8;i++)
	{
		waku[i]->ImageCopy( work65 );
	}
}

/////////////////////////////////////////////////////////
//	delete.
/////////////////////////////////////////////////////////

void bmpwaku::Delete()
{
	for(int i=0;i<8;i++)
	{
		waku[i]->ImageDelete();
	}
}

/////////////////////////////////////////////////////////
//	proc.
/////////////////////////////////////////////////////////

int bmpwaku::wakuLocate()
{
	waku.RecRead( LEFTTOP );
	InterPictuerLocate = waku.Obj()->Size();

	WakuSize.x = InterViewSize.x + InterPictuerLocate.x+8 * 2;
	WakuSize.y = InterViewSize.y + InterPictuerLocate.y+8 * 2;

	POINT pnt;
	pnt.x = 0;
	pnt.y = 0;

//	waku.RecRead( LEFTTOP );
	waku.Obj()->LocateAndSize(
			pnt.x - waku.Obj()->Size().x,
			pnt.y - waku.Obj()->Size().y,
			waku.Obj()->Size().x,
			waku.Obj()->Size().y
			);

	waku.RecRead( RIGHTTOP );
	waku.Obj()->LocateAndSize(
			pnt.x + InterViewSize.x,
			pnt.y - waku.Obj()->Size().y,
			waku.Obj()->Size().x,
			waku.Obj()->Size().y
			);

	waku.RecRead( RIGHTBOTTOM );
	waku.Obj()->LocateAndSize(
			pnt.x + InterViewSize.x,
			pnt.y + InterViewSize.y,
			waku.Obj()->Size().x,
			waku.Obj()->Size().y
			);

	waku.RecRead( LEFTBOTTOM );
	waku.Obj()->LocateAndSize(
			pnt.x - waku.Obj()->Size().x,
			pnt.y + InterViewSize.y,
			waku.Obj()->Size().x,
			waku.Obj()->Size().y
			);

	waku.RecRead( TOP );
	waku.Obj()->LocateAndSize(
			pnt.x,
			pnt.y - waku.Obj()->Size().y,
			InterViewSize.x,
			waku.Obj()->Size().y
			);

	waku.RecRead( RIGHT );
	waku.Obj()->LocateAndSize(
			pnt.x + InterViewSize.x,
			pnt.y,
			waku.Obj()->Size().x,
			InterViewSize.y
			);

	waku.RecRead( BOTTOM );
	waku.Obj()->LocateAndSize(
			pnt.x,
			pnt.y + InterViewSize.y,
			InterViewSize.x,
			waku.Obj()->Size().y
			);

	waku.RecRead( LEFT );
	waku.Obj()->LocateAndSize(
			pnt.x - waku.Obj()->Size().x,
			pnt.y,
			waku.Obj()->Size().x,
			InterViewSize.y
			);

	return 0;
}

/////////////////////////////////////////////////////////
//	calc draw area.
/////////////////////////////////////////////////////////

RECT bmpwaku::DrawArea( POINT locate )
{
	MyRECT rc;

	rc.Set( locate );

	for(int i=0;i<8;i++ )
	{
		rc.AddArea( waku[i]->DrawArea( locate ) );
	}
	return rc.obj;
}

/////////////////////////////////////////////////////////
//	area redraw.
/////////////////////////////////////////////////////////

int bmpwaku::AreaRedraw( HDC DC, POINT locate, RECT rc )
{
	for(int i=0;i<8;i++ )
	{
		waku[i]->AreaRedraw( DC, locate, rc );
	}
	return 0;
}

/////////////////////////////////////////////////////////
//	draw.
/////////////////////////////////////////////////////////

int bmpwaku::Draw( HDC DC, POINT locate )
{
	for(int i=0;i<8;i++ )
	{
		waku[i]->Draw( DC, locate );
	}
	return 0;
}

/////////////////////////////////////////////////////////
// end of "bmpwaku.cpp"
/////////////////////////////////////////////////////////