/////////////////////////////////////////////////////////////////////////////
// Ctrl_key.c
//  
/////////////////////////////////////////////////////////////////////////////

//	Set up gauge header
char Ctrl_key_gauge_name[]	= GAUGE_NAME;
extern PELEMENT_HEADER	Ctrl_key_list;
extern MOUSERECT      	Ctrl_key_mouse_rect[];

GAUGE_HEADER_FS700(GAUGE_W, Ctrl_key_gauge_name, &Ctrl_key_list, \
						Ctrl_key_mouse_rect, 0, 0, 0, 0);

/*---------------------------------------------------------------------------
---- Functions that ilustrate status of Keys --------------------------------
---------------------------------------------------------------------------*/
FLOAT64 FSAPI	Ctrl_key_icon_cb( PELEMENT_ICON pelement )
{
	return Ctrl_key;
}

/*---------------------------------------------------------------------------
------------ Make ICONS macroses     ----------------------------------------
---------------------------------------------------------------------------*/

MAKE_ICON
(		
	Ctrl_key_icon,
	BMP_Pusk_key_off,
	NULL,
	NULL,
	IMAGE_USE_ERASE | IMAGE_USE_BRIGHT | IMAGE_USE_TRANSPARENCY,
	0,
	0,0,

	MODULE_VAR_NONE, Ctrl_key_icon_cb,

	ICON_SWITCH_TYPE_SET_CUR_ICON,
	1,
	0,
	0
)

PELEMENT_HEADER		Ctrl_key_icon_list[] =
{
	&Ctrl_key_icon.header,
	NULL
};

/////////////////////////////////////////////////////////////////////////////
MAKE_STATIC
(
	Ctrl_key_background,
	BMP_Ctrl_key,
	&Ctrl_key_icon_list,
	NULL,
	IMAGE_USE_TRANSPARENCY,
	0,
	0,0
)

PELEMENT_HEADER		Ctrl_key_list= &Ctrl_key_background.header;

/*---------------------------------------------------------------------------
---------------- Call back mouse functions ----------------------------------
---------------------------------------------------------------------------*/

BOOL FSAPI Ctrl_key_on_mouse_cb( PPIXPOINT relative_point, FLAGS32 mouse_flags )
{	
    // Flags that indicate what is already on
	//if (Ctrl_key == -1) {
	if ( mouse_flags & MOUSE_LEFTSINGLE){
			Ctrl_key = 0; // Blank bmp
			old_status[0] = Rezhim_ind ; // Save old status
			old_status[1] = P_topliva_ind;
			old_status[2] = Zapusk_ind ;
			old_status[3] = Stvorki_ind ;
			old_status[4] = Struzhka_v_masle_ind ;
			old_status[5] = Filter_zasoren_ind ;
			old_status[6] = Zaslonka_ind ;
			old_status[7] = Maslo_malo_ind ;
			Rezhim_ind = 0;
			P_topliva_ind = 0;
			Zapusk_ind = 0;
			Stvorki_ind = 0;
			Struzhka_v_masle_ind = 0;
			Filter_zasoren_ind = 0;
			Zaslonka_ind = 0;
			Maslo_malo_ind = 0;			
	}
	else {
			Ctrl_key = -1;  // Lighted bmp
			Rezhim_ind = old_status[0]; // Bring back to old status
			P_topliva_ind = old_status[1];
			Zapusk_ind  = old_status[2];
			Stvorki_ind = old_status[3];
			Struzhka_v_masle_ind = old_status[4];
			Filter_zasoren_ind = old_status[5];
			Zaslonka_ind = old_status[6];
			Maslo_malo_ind = old_status[7];;
	}
	return TRUE;
}
/////////////////////////////////////////////////////////////////////////////

MOUSE_BEGIN( Ctrl_key_mouse_rect, HELP_NONE, 0, 0 )
	MOUSE_CHILD_FUNCT( 0,0,50,50, CURSOR_HAND, MOUSE_LEFTSINGLE | MOUSE_LEFTRELEASE, Ctrl_key_on_mouse_cb )
MOUSE_END

/////////////////////////////////////////////////////////////////////////////
#undef GAUGE_NAME
#undef GAUGEHDR_VAR_NAME
#undef GAUGE_W
