/*****************************************************************************/

/*
 *      resetdefaultCB.c -- REALmagic calibration application 
 *
 *      Copyright (C) 2000 Sigma Designs
 *                    written by Nicolas Vignal <nicolas_vignal@sdesigns.com>
 *                    modified by Emmanuel Michon <emmanuel_michon@sdesigns.com>
 *
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "define.h"

#include "resetdefaultCB.h"

gboolean ColorCalibrationFlag=FALSE;
gboolean BorderAdjustFlag=FALSE;

void RD_Ok_clicked( GtkWidget *widget,gpointer   data ){
	
	DWORD FMPreturn;

	GtkWidget *window;

	G_MESSAGE("Ok clicked\n");

	if (ColorCalibrationFlag){
		G_MESSAGE("Reset Color Calibration\n");
		
		// set the red upper to 14
		FMPreturn=FMPAnalogOverlay(FMP_ANALOG_OVERLAY_SET,FMP_ANALOG_OVERLAY_ATTRIBUTE_VGARUPPER,14,UNUSED_ARG,UNUSED_ARG,UNUSED_ARG);
		G_MESSAGE("set red upper to 14 return: %ld",FMPreturn);	

		// set the red lower to 0
		FMPreturn=FMPAnalogOverlay(FMP_ANALOG_OVERLAY_SET,FMP_ANALOG_OVERLAY_ATTRIBUTE_VGARLOWER,0,UNUSED_ARG,UNUSED_ARG,UNUSED_ARG);
		G_MESSAGE("set red lower to 0 return: %ld",FMPreturn);	

		// set the green upper to 56
		FMPreturn=FMPAnalogOverlay(FMP_ANALOG_OVERLAY_SET,FMP_ANALOG_OVERLAY_ATTRIBUTE_VGAGUPPER,56,UNUSED_ARG,UNUSED_ARG,UNUSED_ARG);
		G_MESSAGE("set green upper to 56 return: %ld",FMPreturn);	

		// set the green lower to 29
		FMPreturn=FMPAnalogOverlay(FMP_ANALOG_OVERLAY_SET,FMP_ANALOG_OVERLAY_ATTRIBUTE_VGAGLOWER,29,UNUSED_ARG,UNUSED_ARG,UNUSED_ARG);
		G_MESSAGE("set green lower to 29 return: %ld",FMPreturn);	
				
		// set the bleu upper to 14
		FMPreturn=FMPAnalogOverlay(FMP_ANALOG_OVERLAY_SET,FMP_ANALOG_OVERLAY_ATTRIBUTE_VGABUPPER,14,UNUSED_ARG,UNUSED_ARG,UNUSED_ARG);
		G_MESSAGE("set bleu upper to 14 return: %ld",FMPreturn);	

		// set the bleu lower to 0
		FMPreturn=FMPAnalogOverlay(FMP_ANALOG_OVERLAY_SET,FMP_ANALOG_OVERLAY_ATTRIBUTE_VGABLOWER,0,UNUSED_ARG,UNUSED_ARG,UNUSED_ARG);
		G_MESSAGE("set bleu lower to 0 return: %ld",FMPreturn);	
	}
	
  if (BorderAdjustFlag){
		G_MESSAGE("Reset Border Adjust\n");
		
		// set stability to 0
		FMPreturn=FMPAnalogOverlay(FMP_ANALOG_OVERLAY_SET,FMP_ANALOG_OVERLAY_ATTRIBUTE_JITTERADJUSTMENT,0,UNUSED_ARG,UNUSED_ARG,UNUSED_ARG);
		G_MESSAGE("set stability to 0 return: %ld",FMPreturn);	

		// set vgacorrection to 1000
		FMPreturn=FMPAnalogOverlay(FMP_ANALOG_OVERLAY_SET,FMP_ANALOG_OVERLAY_ATTRIBUTE_VGACORRECTION,1000,UNUSED_ARG,UNUSED_ARG,UNUSED_ARG);
		G_MESSAGE("set vga correction to 1000 return: %ld",FMPreturn);	
	
		// set YOFFSET to 0
		FMPreturn=FMPAnalogOverlay(FMP_ANALOG_OVERLAY_SET,FMP_ANALOG_OVERLAY_ATTRIBUTE_YOFFSET,0,UNUSED_ARG,UNUSED_ARG,UNUSED_ARG);
		G_MESSAGE("set YOFFSET to 0 return: %ld",FMPreturn);	
		
		// set XOFFSET to 0
		FMPreturn=FMPAnalogOverlay(FMP_ANALOG_OVERLAY_SET,FMP_ANALOG_OVERLAY_ATTRIBUTE_XOFFSET,0,UNUSED_ARG,UNUSED_ARG,UNUSED_ARG);
		G_MESSAGE("set XOFFSET to 0 return: %ld",FMPreturn);	
  }	

  		
	ColorCalibrationFlag=FALSE;
	BorderAdjustFlag=FALSE;

	window=gtk_widget_get_toplevel(widget);
  gtk_widget_destroy(window);
}



/* close the window */
void RD_Cancel_clicked( GtkWidget *widget,gpointer   data ){

	GtkWidget *window;

	ColorCalibrationFlag=FALSE;
	BorderAdjustFlag=FALSE;
	
	window=gtk_widget_get_toplevel(widget);
  gtk_widget_destroy(window);
}



void RD_ColorCalibration_toggled( GtkWidget *widget,gpointer   data ){

	ColorCalibrationFlag=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));

}



void RD_BorderAdjust_toggled( GtkWidget *widget,gpointer   data ){

	BorderAdjustFlag=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));

}
