#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winb.h>
#include <te.h>
#include <fntb.h>
#include <gui.h>
#include "sftlib.h"
#include <egb.h>

int	DB_alert = -1 ;
int	DB_alert_sub[9] = -1 ;
int	DB_alert_freemen = -1 ;
int	DB_alert_logo = -1 ;
int	DB_himituButton = -1 ;


#define   COL_LOGOFR  5 
#define   COL_LOGOBK  6 

/*	initDataALERT:DB_alert_sub[3]:MJ_DBUTTONL40の呼び出し関数	*/
int	DB_Alert_ret(kobj, messId, argc, pev, trigger)
int		kobj ;
int		messId ;
int		argc ;
EVENT	*pev ;
int		trigger ;
{
	MMI_SendMessage( DB_alert, MM_ERASE, 0);
	MMI_SendMessage( DB_alert, MM_DETACH, 0);
	MMI_SetHaltFlag(True);
	return NOERR ;
}


/*	initDataALERT:DB_himituButton:MJ_BUTTONL40の呼び出し関数	*/
int	himitu(kobj, messId, argc, pev, trigger)
int		kobj ;
int		messId ;
int		argc ;
EVENT	*pev ;
int		trigger ;
{
	AMI_PLT_call( DB_page, NULL );
	return NOERR ;
}


int DB_Alert_call()
{
	extern int DB_base;
	extern char	*guiEgbPtr ;			/*	EGB のワークアドレス	*/
	HYPER  phyp;
	char freemem[80];
	int m1, m2,mem;
	
	m1=TL_checkMemory(0); /* 純粋な空きブロック       */
	m2=TL_checkMemory(2); /* 連続したブロックの総数   */
	mem=( (m1<m2)?m1:m2 )*4;  
	sprintf( freemem, "%dK Bytes free", mem); 
	MMI_SendMessage( DB_alert_freemen, MM_SETMSG, 1, freemem );
	MMI_SendMessage( DB_alert_logo, MM_GETHYPER, 1, &phyp );
	phyp.atrm=MS_DEFAULTL40 ;
	MMI_SendMessage( DB_alert, MM_ATTACH, 1, DB_base);
	MMI_SendMessage( DB_alert, MM_SHOW, 0);

	MG_mosDisp(2);
		EGB_writeMode( guiEgbPtr, 0);
		EGB_paintMode( guiEgbPtr, 0x22 );
		EGB_color( guiEgbPtr, 0, COL_LOGOFR );
		EGB_color( guiEgbPtr, 2, COL_LOGOBK );
		tiff_prt( DB_tifflp,
			phyp.fr.lupx, phyp.fr.lupy, phyp.fr.rdwx, phyp.fr.rdwy);
	MG_mosDisp(3);

	MMI_ExecSystem();
	return 0;
}

