/////////////////////////////////////////////////////////////////////////////
// Auto_fuel_balance.c
// 
/////////////////////////////////////////////////////////////////////////////
//
signed int Auto_fuel_balance = -1;
MODULE_VAR SELECTED_FUEL_TRANSFER_MODE_var = {SELECTED_FUEL_TRANSFER_MODE};

//	Set up gauge header
char Auto_fuel_balance_gauge_name[]	= GAUGE_NAME;
extern PELEMENT_HEADER	Auto_fuel_balance_list;
extern MOUSERECT      	Auto_fuel_balance_mouse_rect[];

GAUGE_HEADER_FS700(GAUGE_W, Auto_fuel_balance_gauge_name, &Auto_fuel_balance_list, \
						Auto_fuel_balance_mouse_rect, 0, 0, 0, 0);

/*---------------------------------------------------------------------------
---- Functions that ilustrate status of Keys --------------------------------
---------------------------------------------------------------------------*/
FLOAT64 FSAPI	Auto_fuel_balance_icon_cb( PELEMENT_ICON pelement )
{
	lookup_var (&SELECTED_FUEL_TRANSFER_MODE_var);
	if (SELECTED_FUEL_TRANSFER_MODE_var.var_value.n == -1 ) Auto_fuel_balance = 0;   // Auto balanse off
	//else if (SELECTED_FUEL_TRANSFER_MODE_var.var_value.n == 0 ) Auto_fuel_balance = 0; // Auto balanse on
	else Auto_fuel_balance = -1;
	return Auto_fuel_balance;
}

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

MAKE_ICON
(		
	Auto_fuel_balance_icon,
	BMP_Auto_on_Key,
	NULL,
	NULL,
	IMAGE_USE_ERASE | IMAGE_USE_BRIGHT | IMAGE_USE_TRANSPARENCY,
	0,
	0,0,

	MODULE_VAR_NONE, Auto_fuel_balance_icon_cb,

	ICON_SWITCH_TYPE_SET_CUR_ICON,
	1,
	0,
	0
)

PELEMENT_HEADER		Auto_fuel_balance_icon_list[] =
{
	&Auto_fuel_balance_icon.header,
	NULL
};
/////////////////////////////////////////////////////////////////////////////
MAKE_STATIC
(
	Auto_fuel_balance_background,
	BMP_Auto_off_Key,
	&Auto_fuel_balance_icon_list,
	NULL,
	IMAGE_USE_TRANSPARENCY,
	0,
	0,0
)

PELEMENT_HEADER		Auto_fuel_balance_list= &Auto_fuel_balance_background.header;

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

BOOL FSAPI Auto_fuel_balance_mouse_cb( PPIXPOINT relative_point, FLAGS32 mouse_flags )
{	
	
	if (Auto_fuel_balance == -1){
		Auto_fuel_balance = 0; 
		//trigger_key_event( KEY_SET_FUEL_TRANSFER_AUTO, 0 );	// Auto transfer on, work only with Concord
	}
	else {
		Auto_fuel_balance = -1;
		trigger_key_event( KEY_SET_FUEL_TRANSFER_OFF, 0 );  // 
		
	}
	return TRUE;
}
/////////////////////////////////////////////////////////////////////////////

MOUSE_BEGIN( Auto_fuel_balance_mouse_rect, HELP_NONE, 0, 0 )
	MOUSE_CHILD_FUNCT( 0,0,50,50, CURSOR_HAND, MOUSE_LEFTSINGLE, Auto_fuel_balance_mouse_cb )
MOUSE_END

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