// EdIABtVw.cpp : implementation file
//

#include "stdafx.h"

extern __declspec(dllimport) char gcSimulateRelease;
extern __declspec(dllimport) char gcSimulateNotU64;
char gcGenerateOneRule = 0;

#include "Defines.hpp"

#ifdef D_ED_IR_ACTIVE

#include "EdIRBtVw.hpp"

#include "EdIRREd.hpp"
#include "EdIRRVw.hpp"
#include "EdIRFrm.hpp"
#include "EdIRRes.hm"
#include "EdIRIRD.hpp"
#include "EdIRBeEn.hpp"

#include "ai_intf.hpp"

#include "IncTUT.h"

//ANNECY CB
#include "EdIRBeha.hpp"
#include "EdIRBVw.hpp"
//END

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

// Sha - TempDebug
//char gcSimulateRelease;
// Sha - TempU64
//char gcSimulateNotU64;

// Shaitan => Macros to subroutines
#define C_NB_BUTTONS	22
// End Shaitan => Macros to subroutines

/////////////////////////////////////////////////////////////////////////////
// class CPA_EdIR_ButtonView
/////////////////////////////////////////////////////////////////////////////

IMPLEMENT_DYNCREATE(CPA_EdIR_ButtonView, CFormView)

BEGIN_MESSAGE_MAP(CPA_EdIR_ButtonView, CFormView)
	//{{AFX_MSG_MAP(CPA_EdIR_ButtonView)
	ON_WM_DESTROY()
	ON_WM_SIZE()
	ON_BN_CLICKED(IDC_IR_BUTTON_PROCESS,OnButtonProcess)
	ON_BN_CLICKED(IDC_IR_BUTTON_PROCESS_ALL,OnButtonProcessAll)
// Shaitan FastC (16/06/98) {
	ON_BN_CLICKED(IDC_IR_BUTTON_GENERATE_FASTC,OnButtonGenerateFastC)
//End Shaitan FastC }
// Shaitan Debug (04/08/98) {
	ON_BN_CLICKED(IDC_IR_BUTTON_DEBUG,OnButtonDebug)
//End Shaitan Debug }
// Shaitan U64 (30/09/98) {
	ON_BN_CLICKED(IDC_IR_BUTTON_U64,OnButtonU64)
//End Shaitan U64 }
// Shaitan => Macros to subroutines
	ON_BN_CLICKED(IDC_IR_BUTTON_MACROTOSUBR_ALL,OnButtonMacroToSubrAll)
	ON_BN_CLICKED(IDC_IR_BUTTON_MACROTOSUBR_ONE,OnButtonMacroToSubrOne)
// End Shaitan => Macros to subroutines
	ON_BN_CLICKED(IDC_IR_BUTTON_ONERULE,OnButtonOneRule)
	ON_BN_CLICKED(IDC_IR_BUTTON_STOP,OnButtonStop)
	ON_BN_CLICKED(IDC_IR_BUTTON_CHECK,OnButtonCheck)
	/* CHRISTOPHE QUICK SAVE MODIFICATIONS */
	ON_BN_CLICKED(IDC_IR_BUTTON_QUICKSAVE,OnButtonQuickSave)
	/* END CHRISTOPHE QUICK SAVE MODIFICATIONS */
	ON_BN_CLICKED(IDC_IR_BUTTON_SAVE_ALL,OnButtonSaveAll)
	ON_BN_CLICKED(IDC_IR_BUTTON_VIEW_MODE,OnButtonChangeViewMode)
	ON_BN_CLICKED(IDC_IR_BUTTON_NEW_BEHAVIOUR,OnButtonNewBehaviour)
	ON_BN_CLICKED(IDC_IR_BUTTON_PRINT,OnButtonPrint)
	ON_BN_CLICKED(IDC_IR_RADIO_DECL,OnRadioDecl)
	// BEGIN CPA2 Cristi Petrescu 98-03-
	ON_BN_CLICKED(IDC_IR_RADIO_MACRO, OnRadioMacro)
	// END CPA2 Cristi Petrescu 98-03-
	// BEGIN ROMTEAM CPA2 Cristi Petrescu 98-04-
	ON_BN_CLICKED(IDC_IR_RADIO_SUBR, OnRadioSubr)
	// END ROMTEAM CPA2 Cristi Petrescu 98-04-
	ON_BN_CLICKED(IDC_IR_RADIO_INTEL,OnRadioIntel)
	ON_BN_CLICKED(IDC_IR_RADIO_REFLEX,OnRadioReflex)
	ON_BN_CLICKED(IDC_IR_BUTTON_CONSTANT,OnButtonConstant)
	ON_WM_HELPINFO()
	ON_NOTIFY_EX(TTN_NEEDTEXT,0,OnToolTipNotify)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/**********************************************************************************/
CPA_EdIR_ButtonView::CPA_EdIR_ButtonView()
	: CFormView(CPA_EdIR_ButtonView::IDD)
{
	//{{AFX_DATA_INIT(CPA_EdIR_ButtonView)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	m_bAreEnable=FALSE;
	m_tdeEditState=EditIntell;
	m_tdeBehaviourModeView=ListView;
	m_bMustStopProcess=FALSE;
	m_bProcessInProgress=FALSE;
	m_pclToolTip=NULL;
}

/**********************************************************************************/
CPA_EdIR_ButtonView::~CPA_EdIR_ButtonView()
{
	//Deletes Tool Tip Control
	if(m_pclToolTip)
		delete m_pclToolTip;
}

/**********************************************************************************/
void CPA_EdIR_ButtonView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPA_EdIR_ButtonView)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

/////////////////////////////////////////////////////////////////////////////
// CPA_EdIR_ButtonView diagnostics

#ifdef _DEBUG
/**********************************************************************************/
void CPA_EdIR_ButtonView::AssertValid() const
{
	CFormView::AssertValid();
}

/**********************************************************************************/
void CPA_EdIR_ButtonView::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CPA_EdIR_ButtonView message handlers

/**********************************************************************************/
void CPA_EdIR_ButtonView::OnInitialUpdate() 
{
	HINSTANCE hOldInstance=AfxGetResourceHandle();
	AfxSetResourceHandle(g_stAIIdentity.hModule);

	CFormView::OnInitialUpdate();

	//Creates tool tips
	EnableToolTips(TRUE);
	m_pclToolTip=new CToolTipCtrl;
	m_pclToolTip->Create(this,WS_VISIBLE|TTS_ALWAYSTIP);

	//Disables Scroll Bar
	SetScrollSizes(MM_TEXT,CSize(0,0));

	HICON hIcon = AfxGetApp()->LoadIcon(IDI_ICON_IR_PROCESS);
	((CButton *)GetDlgItem(IDC_IR_BUTTON_PROCESS))->SetIcon(hIcon);

	hIcon = AfxGetApp()->LoadIcon(IDI_ICON_IR_PROCESS_ALL);
	((CButton *)GetDlgItem(IDC_IR_BUTTON_PROCESS_ALL))->SetIcon(hIcon);

// Shaitan FastC (16/06/98) {
	hIcon = AfxGetApp()->LoadIcon(IDI_ICON_IR_GENERATE_FASTC);
	((CButton *)GetDlgItem(IDC_IR_BUTTON_GENERATE_FASTC))->SetIcon(hIcon);
//End Shaitan FastC }

// Shaitan Debug (04/08/98) {
	hIcon = AfxGetApp()->LoadIcon(IDI_ICON_IR_DEBUG);
	((CButton *)GetDlgItem(IDC_IR_BUTTON_DEBUG))->SetIcon(hIcon);
	((CButton *)GetDlgItem(IDC_IR_BUTTON_DEBUG))->SetCheck(!gcSimulateRelease);
//End Shaitan Debug }

	hIcon = AfxGetApp()->LoadIcon(IDI_ICON_IR_ONERULE);
	((CButton *)GetDlgItem(IDC_IR_BUTTON_ONERULE))->SetIcon(hIcon);
	((CButton *)GetDlgItem(IDC_IR_BUTTON_ONERULE))->SetCheck(gcGenerateOneRule);
// Shaitan U64 (30/09/98) {
	hIcon = AfxGetApp()->LoadIcon(IDI_ICON_IR_U64);
	((CButton *)GetDlgItem(IDC_IR_BUTTON_U64))->SetIcon(hIcon);
	((CButton *)GetDlgItem(IDC_IR_BUTTON_U64))->SetCheck(!gcSimulateNotU64);
//End Shaitan U64 }
// Shaitan => Macros to subroutines
	hIcon = AfxGetApp()->LoadIcon(IDI_ICON_IR_MACROTOSUBR_ALL);
	((CButton *)GetDlgItem(IDC_IR_BUTTON_MACROTOSUBR_ALL))->SetIcon(hIcon);
	hIcon = AfxGetApp()->LoadIcon(IDI_ICON_IR_MACROTOSUBR_ONE);
	((CButton *)GetDlgItem(IDC_IR_BUTTON_MACROTOSUBR_ONE))->SetIcon(hIcon);
// End Shaitan => Macros to subroutines
	hIcon = AfxGetApp()->LoadIcon(IDI_ICON_IR_STOP);
	((CButton *)GetDlgItem(IDC_IR_BUTTON_STOP))->SetIcon(hIcon);

	hIcon = AfxGetApp()->LoadIcon(IDI_ICON_IR_CHECK);
	((CButton *)GetDlgItem(IDC_IR_BUTTON_CHECK))->SetIcon(hIcon);

	/* CHRISTOPHE QUICK SAVE MODIFICATIONS */
	hIcon = AfxGetApp()->LoadIcon(IDI_ICON_IR_QUICKSAVE);
	((CButton *)GetDlgItem(IDC_IR_BUTTON_QUICKSAVE))->SetIcon(hIcon);
	/* END CHRISTOPHE QUICK SAVE MODIFICATIONS */


	hIcon = AfxGetApp()->LoadIcon(IDI_ICON_IR_SAVE_ALL);
	((CButton *)GetDlgItem(IDC_IR_BUTTON_SAVE_ALL))->SetIcon(hIcon);

	hIcon = AfxGetApp()->LoadIcon(IDI_ICON_IR_PRINT);
	((CButton *)GetDlgItem(IDC_IR_BUTTON_PRINT))->SetIcon(hIcon);

	hIcon = AfxGetApp()->LoadIcon(IDI_ICON_IR_NEW);
	((CButton *)GetDlgItem(IDC_IR_BUTTON_NEW_BEHAVIOUR))->SetIcon(hIcon);

	hIcon = AfxGetApp()->LoadIcon(IDI_ICON_IR_VIEW_MODE_LIST);
	((CButton *)GetDlgItem(IDC_IR_BUTTON_VIEW_MODE))->SetIcon(hIcon);

	hIcon = AfxGetApp()->LoadIcon(IDI_ICON_IR_IDR_INTEL);
	((CButton *)GetDlgItem(IDC_IR_RADIO_INTEL))->SetIcon(hIcon);
	((CButton *)GetDlgItem(IDC_IR_RADIO_INTEL))->SetCheck(1);

	hIcon = AfxGetApp()->LoadIcon(IDI_ICON_IR_IDR_REFLEX);
	((CButton *)GetDlgItem(IDC_IR_RADIO_REFLEX))->SetIcon(hIcon);
	((CButton *)GetDlgItem(IDC_IR_RADIO_REFLEX))->SetCheck(0);

	hIcon = AfxGetApp()->LoadIcon(IDI_ICON_IR_IDR_DECL);
	((CButton *)GetDlgItem(IDC_IR_RADIO_DECL))->SetIcon(hIcon);
	((CButton *)GetDlgItem(IDC_IR_RADIO_DECL))->SetCheck(0);

	// BEGIN CPA2 Cristi Petrescu 98-03-
	hIcon = AfxGetApp()->LoadIcon(IDI_ICON_IR_IDR_MACRO);
	((CButton *)GetDlgItem(IDC_IR_RADIO_MACRO))->SetIcon(hIcon);
	((CButton *)GetDlgItem(IDC_IR_RADIO_MACRO))->SetCheck(0);
	// END CPA2 Cristi Petrescu 98-03-

	// BEGIN ROMTEAM CPA2 Cristi Petrescu 98-04-
	hIcon = AfxGetApp()->LoadIcon(IDI_ICON_IR_IDR_SUBR);
	((CButton *)GetDlgItem(IDC_IR_RADIO_SUBR))->SetIcon(hIcon);
	((CButton *)GetDlgItem(IDC_IR_RADIO_SUBR))->SetCheck(0);
	// END ROMTEAM CPA2 Cristi Petrescu 98-04-

	hIcon = AfxGetApp()->LoadIcon(IDI_ICON_IR_CONSTANT);
	((CButton *)GetDlgItem(IDC_IR_BUTTON_CONSTANT))->SetIcon(hIcon);

	//Disables Buttons
	m_fn_vEnableButtons(FALSE);

	//////////////
	//////////////
	//Registers for TUT Module
	TUT_M_vGetTutDll();
	
	TUT_M_vRegisterControlID(IDC_IR_BUTTON_PROCESS,"EdIR_BtView_Process",TUT_e_Button);
	TUT_M_vRegisterControlID(IDC_IR_BUTTON_PROCESS_ALL,"EdIR_BtView_Process_All",TUT_e_Button);
// Shaitan FastC (16/06/98) {
	TUT_M_vRegisterControlID(IDC_IR_BUTTON_GENERATE_FASTC,"EdIR_BtView_Generate_FastC",TUT_e_Button);
//End Shaitan FastC }
// Shaitan Debug (04/08/98) {
	TUT_M_vRegisterControlID(IDC_IR_BUTTON_DEBUG,"EdIR_BtView_Debug",TUT_e_Button);
//End Shaitan Debug }
// Shaitan U64 (30/09/98) {
	TUT_M_vRegisterControlID(IDC_IR_BUTTON_U64,"EdIR_BtView_U64",TUT_e_Button);
//End Shaitan U64 }
	TUT_M_vRegisterControlID(IDC_IR_BUTTON_ONERULE,"EdIR_BtView_OneRule",TUT_e_Button);
// Shaitan => Macros to subroutines
	TUT_M_vRegisterControlID(IDC_IR_BUTTON_MACROTOSUBR_ALL,"EdIR_BtView_MacroToSubr_All",TUT_e_Button);
	TUT_M_vRegisterControlID(IDC_IR_BUTTON_MACROTOSUBR_ONE,"EdIR_BtView_MacroToSubr_One",TUT_e_Button);
// End Shaitan => Macros to subroutines
	TUT_M_vRegisterControlID(IDC_IR_BUTTON_STOP,"EdIR_BtView_StopProcess",TUT_e_Button);
	TUT_M_vRegisterControlID(IDC_IR_BUTTON_CHECK,"EdIR_BtView_Check",TUT_e_Button);
	/* CHRISTOPHE QUICK SAVE MODIFICATIONS */
	TUT_M_vRegisterControlID(IDC_IR_BUTTON_QUICKSAVE,"EdIR_BtView_QuickSave",TUT_e_Button);
	/* END CHRISTOPHE QUICK SAVE MODIFICATIONS */
	TUT_M_vRegisterControlID(IDC_IR_BUTTON_SAVE_ALL,"EdIR_BtView_SaveAll",TUT_e_Button);
	TUT_M_vRegisterControlID(IDC_IR_BUTTON_PRINT,"EdIR_BtView_Print",TUT_e_Button);
	TUT_M_vRegisterControlID(IDC_IR_BUTTON_NEW_BEHAVIOUR,"EdIR_BtView_CreateBehaviour",TUT_e_Button);
	TUT_M_vRegisterControlID(IDC_IR_BUTTON_VIEW_MODE,"EdIR_BtView_ChangeMode",TUT_e_Button);
	TUT_M_vRegisterControlID(IDC_IR_RADIO_INTEL,"EdIR_BtView_ShowIntell",TUT_e_Button);
	TUT_M_vRegisterControlID(IDC_IR_RADIO_REFLEX,"EdIR_BtView_ShowReflex",TUT_e_Button);
	TUT_M_vRegisterControlID(IDC_IR_RADIO_DECL,"EdIR_BtView_ShowDeclaration",TUT_e_Button);
	// BEGIN CPA2 Cristi Petrescu 98-03-
	TUT_M_vRegisterControlID(IDC_IR_RADIO_DECL,"EdIR_BtView_ShowMacro",TUT_e_Button);
	// END CPA2 Cristi Petrescu 98-03-
	// BEGIN ROMTEAM CPA2 Cristi Petrescu 98-04-
	TUT_M_vRegisterControlID(IDC_IR_RADIO_SUBR,"EdIR_BtView_ShowSubr",TUT_e_Button);
	// END ROMTEAM CPA2 Cristi Petrescu 98-04-
	TUT_M_vRegisterControlID(IDC_IR_BUTTON_CONSTANT,"EdIR_BtView_ShowConstant",TUT_e_Button);
	//End of Register for TUT Module
	//////////////

	AfxSetResourceHandle(hOldInstance);
}

/**********************************************************************************/
void CPA_EdIR_ButtonView::OnDestroy()
{
	//////////////
	//////////////
	//UnRegisters for TUT Module
	TUT_M_vGetTutDll();
	
	TUT_M_vUnregisterControlID(IDC_IR_BUTTON_PROCESS);
	TUT_M_vUnregisterControlID(IDC_IR_BUTTON_PROCESS_ALL);
// Shaitan FastC (16/06/98) {
	TUT_M_vUnregisterControlID(IDC_IR_BUTTON_GENERATE_FASTC);
//End Shaitan FastC }
// Shaitan Debug (04/08/98) {
	TUT_M_vUnregisterControlID(IDC_IR_BUTTON_DEBUG);
//End Shaitan Debug }
// Shaitan U64 (30/09/98) {
	TUT_M_vUnregisterControlID(IDC_IR_BUTTON_U64);
//End Shaitan U64 }
	TUT_M_vUnregisterControlID(IDC_IR_BUTTON_ONERULE);
// Shaitan => Macros to subroutines
	TUT_M_vUnregisterControlID(IDC_IR_BUTTON_MACROTOSUBR_ALL);
	TUT_M_vUnregisterControlID(IDI_ICON_IR_MACROTOSUBR_ONE);
// End Shaitan => Macros to subroutines
	TUT_M_vUnregisterControlID(IDC_IR_BUTTON_STOP);
	TUT_M_vUnregisterControlID(IDC_IR_BUTTON_CHECK);
	/* MARC -> CHRISTOPHE QUICK SAVE MODIFICATIONS CORRECTION */
	TUT_M_vUnregisterControlID(IDC_IR_BUTTON_QUICKSAVE);
	/* END MARC -> CHRISTOPHE QUICK SAVE MODIFICATIONS CORRECTION */
	TUT_M_vUnregisterControlID(IDC_IR_BUTTON_SAVE_ALL);
	TUT_M_vUnregisterControlID(IDC_IR_BUTTON_PRINT);
	TUT_M_vUnregisterControlID(IDC_IR_BUTTON_NEW_BEHAVIOUR);
	TUT_M_vUnregisterControlID(IDC_IR_BUTTON_VIEW_MODE);
	TUT_M_vUnregisterControlID(IDC_IR_RADIO_INTEL);
	TUT_M_vUnregisterControlID(IDC_IR_RADIO_REFLEX);
	TUT_M_vUnregisterControlID(IDC_IR_RADIO_DECL);
	// BEGIN CPA2 Cristi Petrescu 98-03-
	TUT_M_vUnregisterControlID(IDC_IR_RADIO_MACRO);
	// END CPA2 Cristi Petrescu 98-03-
	// BEGIN ROMTEAM CPA2 Cristi Petrescu 98-04-
	TUT_M_vUnregisterControlID(IDC_IR_RADIO_SUBR);
	// END ROMTEAM CPA2 Cristi Petrescu 98-04-
	TUT_M_vUnregisterControlID(IDC_IR_BUTTON_CONSTANT);
	//End of UnRegister for TUT Module
	//////////////

	CFormView::OnDestroy();
}

/**********************************************************************************/
void CPA_EdIR_ButtonView::OnSize(UINT nType,int cx,int cy) 
{
	CFormView::OnSize(nType,C_NB_BUTTONS*(cx/C_NB_BUTTONS),cy);

	m_fn_vUpdateDisplay();
}

/**********************************************************************************/
void CPA_EdIR_ButtonView::m_fn_vUpdateDisplay()
{
	HINSTANCE hOldInstance=AfxGetResourceHandle();
	AfxSetResourceHandle(g_stAIIdentity.hModule);

	CRect	cr;
	GetClientRect(cr);

	long	lWidth=cr.Width();
	long	lHeigth=cr.Height();
// CPA2 ASilvescu 98-04-29
	lHeigth /= 2;
	int nb = (C_NB_BUTTONS + 1)>> 1;
// CPA2 ASilvescu 98-04-29
	long	lButtonNumber=0;

	CButton	*p_clBtProcess=(CButton *)GetDlgItem(IDC_IR_BUTTON_PROCESS);
	if(p_clBtProcess)
		p_clBtProcess->MoveWindow(lButtonNumber*lWidth/nb,0,lWidth/nb,lHeigth);	// CPA2 ASilvescu 98-04-29
	lButtonNumber++;

	CButton	*p_clBtProcessAll=(CButton *)GetDlgItem(IDC_IR_BUTTON_PROCESS_ALL);
	if(p_clBtProcessAll)
		p_clBtProcessAll->MoveWindow(lButtonNumber*lWidth/nb,0,lWidth/nb,lHeigth);	// CPA2 ASilvescu 98-04-29
	lButtonNumber++;

	CButton	*p_clBtStop=(CButton *)GetDlgItem(IDC_IR_BUTTON_STOP);
	if(p_clBtStop)
		p_clBtStop->MoveWindow(lButtonNumber*lWidth/nb,0,lWidth/nb,lHeigth); // CPA2 ASilvescu 98-04-29
	lButtonNumber++;

	CButton	*p_clBtCheck=(CButton *)GetDlgItem(IDC_IR_BUTTON_CHECK);
	if(p_clBtCheck)
	{
		p_clBtCheck->MoveWindow(lButtonNumber*lWidth/nb,0,lWidth/nb,lHeigth);	// CPA2 ASilvescu 98-04-29
		// BEGIN CPA2 Cristi Petrescu 98-03-
		/*
		if(m_bAreEnable)
			p_clBtCheck->EnableWindow(m_fn_tdeGetEditState()!=EditMacro);
		*/
		// END CPA2 Cristi Petrescu 98-03-
	}
	lButtonNumber++;

	/* CHRISTOPHE QUICK SAVE MODIFICATIONS { */
	CButton	*p_clBtQuickSave=(CButton *)GetDlgItem(IDC_IR_BUTTON_QUICKSAVE);
	if(p_clBtQuickSave)
		p_clBtQuickSave->MoveWindow(lButtonNumber*lWidth/nb,0,lWidth/nb,lHeigth);	 // CPA2 ASilvescu 98-04-29
	lButtonNumber++;
	/* } END CHRISTOPHE QUICK SAVE MODIFICATIONS */

	CButton	*p_clBtSaveAll=(CButton *)GetDlgItem(IDC_IR_BUTTON_SAVE_ALL);
	if(p_clBtSaveAll)
		p_clBtSaveAll->MoveWindow(lButtonNumber*lWidth/nb,0,lWidth/nb,lHeigth);	 // CPA2 ASilvescu 98-04-29
	lButtonNumber++;

	CButton	*p_clBtPrint=(CButton *)GetDlgItem(IDC_IR_BUTTON_PRINT);
	if(p_clBtPrint)
		p_clBtPrint->MoveWindow(lButtonNumber*lWidth/nb,0,lWidth/nb,lHeigth);		// CPA2 ASilvescu 98-04-29
	lButtonNumber++;

	CButton	*p_clBtNewBehaviour=(CButton *)GetDlgItem(IDC_IR_BUTTON_NEW_BEHAVIOUR);
	if(p_clBtNewBehaviour)
	{
		p_clBtNewBehaviour->MoveWindow(lButtonNumber*lWidth/nb,0,lWidth/nb,lHeigth);	// CPA2 ASilvescu 98-04-29
		if(m_bAreEnable)
			p_clBtNewBehaviour->EnableWindow(m_fn_tdeGetEditState()!=EditDecl);
	}
	lButtonNumber++;

// Shaitan Debug (04/08/98) {
	CButton	*p_clBtDebug=(CButton *)GetDlgItem(IDC_IR_BUTTON_DEBUG);
	if(p_clBtDebug)
		p_clBtDebug->MoveWindow(lButtonNumber*lWidth/nb,0,lWidth/nb,lHeigth);	
	lButtonNumber++;
//End Shaitan Debug }

// Shaitan U64 (30/09/98) {
	CButton	*p_clBtU64=(CButton *)GetDlgItem(IDC_IR_BUTTON_U64);
	if(p_clBtU64)
		p_clBtU64->MoveWindow(lButtonNumber*lWidth/nb,0,lWidth/nb,lHeigth);	
	lButtonNumber++;
//End Shaitan U64 }

// CPA2 ASilvescu 98-04-29
	lButtonNumber = 0;
	nb = C_NB_BUTTONS - nb;
// CPA2 ASilvescu 98-04-29

// Shaitan FastC (16/06/98) {
	CButton	*p_clBtGenerateFastC=(CButton *)GetDlgItem(IDC_IR_BUTTON_GENERATE_FASTC);
	if(p_clBtGenerateFastC)
		p_clBtGenerateFastC->MoveWindow(lButtonNumber*lWidth/nb,lHeigth+1,lWidth/nb,lHeigth);	
	lButtonNumber++;
//End Shaitan FastC }


	CButton	*p_clBtViewMode=(CButton *)GetDlgItem(IDC_IR_BUTTON_VIEW_MODE);
	if(p_clBtViewMode)
	{
		p_clBtViewMode->MoveWindow(lButtonNumber*lWidth/nb,lHeigth+1,lWidth/nb,lHeigth); // CPA2 ASilvescu 98-04-29

		HICON hIcon;
		if(m_fn_tdeGetViewMode()==ListView)
			hIcon = AfxGetApp()->LoadIcon(IDI_ICON_IR_VIEW_MODE_LIST);
		else
			hIcon = AfxGetApp()->LoadIcon(IDI_ICON_IR_VIEW_MODE_DIAG);

		((CButton *)GetDlgItem(IDC_IR_BUTTON_VIEW_MODE))->SetIcon(hIcon);
	}
	lButtonNumber++;

	CButton	*p_clBtIntel=(CButton *)GetDlgItem(IDC_IR_RADIO_INTEL);
	if(p_clBtIntel)
		p_clBtIntel->MoveWindow(lButtonNumber*lWidth/nb,lHeigth+1,lWidth/nb,lHeigth); // CPA2 ASilvescu 98-04-29
	lButtonNumber++;

	CButton	*p_clBtReflex=(CButton *)GetDlgItem(IDC_IR_RADIO_REFLEX);
	if(p_clBtReflex)
		p_clBtReflex->MoveWindow(lButtonNumber*lWidth/nb,lHeigth+1,lWidth/nb,lHeigth);	// CPA2 ASilvescu 98-04-29
	lButtonNumber++;
	
	CButton	*p_clBtDecl=(CButton *)GetDlgItem(IDC_IR_RADIO_DECL);	
	if(p_clBtDecl)
		p_clBtDecl->MoveWindow(lButtonNumber*lWidth/nb,lHeigth+1,lWidth/nb,lHeigth);	// CPA2 ASilvescu 98-04-29
	lButtonNumber++;

	// BEGIN CPA2 Cristi Petrescu 98-03-
	CButton	*p_clBtMacro=(CButton *)GetDlgItem(IDC_IR_RADIO_MACRO);
	if(p_clBtMacro)
		p_clBtMacro->MoveWindow(lButtonNumber*lWidth/nb,lHeigth+1,lWidth/nb,lHeigth);	// CPA2 ASilvescu 98-04-29
	lButtonNumber++;
	// END CPA2 Cristi Petrescu 98-03-

	// BEGIN ROMTEAM CPA2 Cristi Petrescu 98-04-
	CButton	*p_clBtSubr=(CButton *)GetDlgItem(IDC_IR_RADIO_SUBR);
	if(p_clBtSubr)
		p_clBtSubr->MoveWindow(lButtonNumber*lWidth/nb,lHeigth+1,lWidth/nb,lHeigth);	// CPA2 ASilvescu 98-04-29
	lButtonNumber++;
	// END ROMTEAM CPA2 Cristi Petrescu 98-04-

	CButton	*p_clBtConstant=(CButton *)GetDlgItem(IDC_IR_BUTTON_CONSTANT);
	if(p_clBtConstant)
		p_clBtConstant->MoveWindow(lButtonNumber*lWidth/nb,lHeigth+1,lWidth/nb,lHeigth);	// CPA2 ASilvescu 98-04-29
	lButtonNumber++;

// Shaitan => Macros to subroutines
	CButton	*p_clBtMtoSAll=(CButton *)GetDlgItem(IDC_IR_BUTTON_MACROTOSUBR_ALL);
	if(p_clBtMtoSAll)
		p_clBtMtoSAll->MoveWindow(lButtonNumber*lWidth/nb,lHeigth+1,lWidth/nb,lHeigth);	
	lButtonNumber++;

	CButton	*p_clBtMtoSOne=(CButton *)GetDlgItem(IDC_IR_BUTTON_MACROTOSUBR_ONE);
	if(p_clBtMtoSOne)
	{
		p_clBtMtoSOne->MoveWindow(lButtonNumber*lWidth/nb,lHeigth+1,lWidth/nb,lHeigth);	
		tdeEditState eState = m_fn_tdeGetEditState();
		if (eState == EditDecl)
			p_clBtMtoSOne->EnableWindow(TRUE);
		else if (eState == EditMacro)
			p_clBtMtoSOne->EnableWindow(((CPA_EdIR_Frame *)GetParentFrame())->m_fn_pclGetDiagrammeView()->m_fn_pclGetActiveBehaviour() != NULL);
		else
			p_clBtMtoSOne->EnableWindow(FALSE);
	}
	lButtonNumber++;
// End Shaitan => Macros to subroutines

	CButton	*p_clBtOneRule=(CButton *)GetDlgItem(IDC_IR_BUTTON_ONERULE);
	if(p_clBtOneRule)
		p_clBtOneRule->MoveWindow(lButtonNumber*lWidth/nb,0,lWidth/nb,lHeigth+lHeigth);	

	AfxSetResourceHandle(hOldInstance);
}

/**********************************************************************************/
void CPA_EdIR_ButtonView::OnButtonProcess() 
{
	m_bProcessInProgress=TRUE;
	CButton	*p_clBtStop=(CButton *)GetDlgItem(IDC_IR_BUTTON_STOP);
	if(p_clBtStop)
		p_clBtStop->EnableWindow(TRUE);
//ROMTEAM Force total compilation 09.06.98 Ionut Grozea
	if(((CPA_EdIR_Frame *)GetParentFrame())->m_pclBrain->m_fn_MacrosHasBeenModified())
	{
		((CPA_EdIR_Frame *)GetParentFrame())->m_fn_bProcessIA(TRUE);
	}
	else
	{
		((CPA_EdIR_Frame *)GetParentFrame())->m_fn_bProcessIA(FALSE);
	}
//ENDROMTEAM Force total compilation 09.06.98 Ionut Grozea
	m_bProcessInProgress=FALSE;
	if(p_clBtStop)
		p_clBtStop->EnableWindow(FALSE);

	m_bMustStopProcess=FALSE;

//Stefan Dumitrean 8-07-98 ( macro color )
	m_fn_vRefreshColorInAllBehaviours();
//End Stefan Dumitrean 8-07-98 ( macro color )
}

/**********************************************************************************/
void CPA_EdIR_ButtonView::OnButtonProcessAll() 
{
	m_bProcessInProgress=TRUE;
	CButton	*p_clBtStop=(CButton *)GetDlgItem(IDC_IR_BUTTON_STOP);
	if(p_clBtStop)
		p_clBtStop->EnableWindow(TRUE);

	((CPA_EdIR_Frame *)GetParentFrame())->m_fn_bProcessIA(TRUE);

	m_bProcessInProgress=FALSE;
	if(p_clBtStop)
		p_clBtStop->EnableWindow(FALSE);

	m_bMustStopProcess=FALSE;
//Stefan Dumitrean 8-07-98 ( macro color )
	m_fn_vRefreshColorInAllBehaviours();
//End Stefan Dumitrean 8-07-98 ( macro color )
}

// Shaitan FastC (16/06/98) {
/**********************************************************************************/
void CPA_EdIR_ButtonView::OnButtonGenerateFastC() 
{
	((CPA_EdIR_Frame *)GetParentFrame())->m_fn_bGenerateFastC(TRUE);
}
//End Shaitan FastC }

// Shaitan Debug (04/08/98) {
/**********************************************************************************/
void CPA_EdIR_ButtonView::OnButtonDebug() 
{
	gcSimulateRelease = !((CButton *)GetDlgItem(IDC_IR_BUTTON_DEBUG))->GetCheck();
}
//End Shaitan Debug }

// Shaitan U64 (30/09/98) {
/**********************************************************************************/
void CPA_EdIR_ButtonView::OnButtonU64() 
{
	gcSimulateNotU64 = !((CButton *)GetDlgItem(IDC_IR_BUTTON_U64))->GetCheck();
}
//End Shaitan U64 }

// Shaitan => Macros to subroutines
/**********************************************************************************/
void CPA_EdIR_ButtonView::OnButtonMacroToSubrAll()
{
	((CPA_EdIR_Frame *)GetParentFrame())->m_pclBrain->m_fn_vChangeAllEditorMacrosToSubroutines();
}

/**********************************************************************************/
void CPA_EdIR_ButtonView::OnButtonMacroToSubrOne()
{
	CPA_EdIR_Frame *pMainFrame = (CPA_EdIR_Frame *)GetParentFrame();
	
	if (m_fn_tdeGetEditState() == EditMacro)
	{
		CPA_EdIR_Behaviour *pBehaviour = pMainFrame->m_fn_pclGetDiagrammeView()->m_fn_pclGetActiveBehaviour();
		if (pBehaviour)
			pMainFrame->m_pclBrain->m_fn_vChangeOneEditorMacroToSubroutines(pBehaviour->m_fn_pclGetMainBehaviour());
	}
	else if (m_fn_tdeGetEditState() == EditDecl)
	{
		pMainFrame->m_pclBrain->m_fn_vChangeOneEditorMacroToSubroutines(pMainFrame->m_pclBrain->m_clListOfDeclarations.GetTail());
	}
}
// End Shaitan => Macros to subroutines

void CPA_EdIR_ButtonView::OnButtonOneRule()
{
	gcGenerateOneRule = ((CButton *)GetDlgItem(IDC_IR_BUTTON_ONERULE))->GetCheck();
}

/**********************************************************************************/
void CPA_EdIR_ButtonView::OnButtonStop() 
{
	m_bMustStopProcess=TRUE;
}

/**********************************************************************************/
void CPA_EdIR_ButtonView::OnButtonCheck()
{
	((CPA_EdIR_Frame *)GetParentFrame())->m_fn_vCheckBehaviour();
}

/**********************************************************************************/
void CPA_EdIR_ButtonView::OnButtonSaveAll() 
{
	((CPA_EdIR_Frame *)GetParentFrame())->m_fn_vSaveAll();
}
/* CHRISTOPHE QUICK SAVE MODIFICATIONS { */
/**********************************************************************************/
void CPA_EdIR_ButtonView::OnButtonQuickSave() 
{
	((CPA_EdIR_Frame *)GetParentFrame())->m_fn_vQuickSave();
}
/* } END CHRISTOPHE QUICK SAVE MODIFICATIONS */

/**********************************************************************************/
void CPA_EdIR_ButtonView::OnButtonPrint() 
{
	((CPA_EdIR_Frame *)GetParentFrame())->m_fn_vPrint();
}

/**********************************************************************************/
void CPA_EdIR_ButtonView::OnRadioDecl() 
{
	m_fn_vSetEditState(EditDecl);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : CPA_EdIR_ButtonView::OnIrRadioMacro
// Date   : 98.03
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description :
// Author      : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date         :
// By           :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void CPA_EdIR_ButtonView::OnRadioMacro() 
{
	m_fn_vSetEditState (EditMacro);
}

// BEGIN ROMTEAM CPA2 Cristi Petrescu 98-04-
/**********************************************************************************/
void CPA_EdIR_ButtonView::OnRadioSubr() 
{
	m_fn_vSetEditState(EditSubr);
}
// END ROMTEAM CPA2 Cristi Petrescu 98-04-

/**********************************************************************************/
void CPA_EdIR_ButtonView::OnRadioIntel() 
{
	m_fn_vSetEditState(EditIntell);
}

/**********************************************************************************/
void CPA_EdIR_ButtonView::OnRadioReflex() 
{
	m_fn_vSetEditState(EditReflex);
}

/**********************************************************************************/
void CPA_EdIR_ButtonView::OnButtonConstant() 
{
	((CPA_EdIR_Frame *)GetParentFrame())->m_fn_vShowConstant();
}

/**********************************************************************************/
void CPA_EdIR_ButtonView::OnButtonChangeViewMode() 
{
	tdeBehaviourModeView	tdeMode=m_fn_tdeGetViewMode();
	switch(tdeMode)
	{
		case ListView:
			tdeMode=DiagView;
			break;

		case DiagView:
			tdeMode=ListView;
			break;

		default:
			break;
	}

	m_fn_vSetViewMode(tdeMode);
}

/**********************************************************************************/
void CPA_EdIR_ButtonView::OnButtonNewBehaviour()
{
	((CPA_EdIR_Frame *)GetParentFrame())->m_fn_vCreateNewBehaviour();
}

/**********************************************************************************/
BOOL CPA_EdIR_ButtonView::OnToolTipNotify(UINT id,NMHDR *pNMHDR,LRESULT *pResult)
{
	TOOLTIPTEXT	*pTTT=(TOOLTIPTEXT *)pNMHDR;
	UINT				nID=pNMHDR->idFrom;
	nID=::GetDlgCtrlID((HWND)nID);
    
	switch(nID)
	{
		case IDC_IR_BUTTON_PROCESS:
 			strcpy(pTTT->szText,"Process modified IA");
			break;

		case IDC_IR_BUTTON_PROCESS_ALL:
 			strcpy(pTTT->szText,"Process all IA");
			break;

// Shaitan FastC (16/06/98) {
		case IDC_IR_BUTTON_GENERATE_FASTC:
 			strcpy(pTTT->szText,"Generate Fast C");
			break;
//End Shaitan FastC }

// Shaitan Debug (04/08/98) {
		case IDC_IR_BUTTON_DEBUG:
 			strcpy(pTTT->szText,"Debug Mode");
			break;
//End Shaitan Debug }
// Shaitan U64 (30/09/98) {
		case IDC_IR_BUTTON_U64:
 			strcpy(pTTT->szText,"U64 Mode");
			break;
//End Shaitan U64 }
// Shaitan => Macros to subroutines
		case IDC_IR_BUTTON_MACROTOSUBR_ALL:
 			strcpy(pTTT->szText,"Convert all macros to subroutines");
			break;

		case IDC_IR_BUTTON_MACROTOSUBR_ONE:
 			strcpy(pTTT->szText,"Convert selected macro to subroutine");
			break;
// End Shaitan => Macros to subroutines
		case IDC_IR_BUTTON_ONERULE:
 			strcpy(pTTT->szText,"Generate one rule per comport");
			break;

		case IDC_IR_BUTTON_STOP:
 			strcpy(pTTT->szText,"Stop processing");
			break;

		case IDC_IR_BUTTON_CHECK:
 			strcpy(pTTT->szText,"Check selected behaviour(s)");
			break;

		case IDC_IR_BUTTON_QUICKSAVE:
 			strcpy(pTTT->szText,"Quick save (only editor files)");
			break;

		case IDC_IR_BUTTON_SAVE_ALL:
 			strcpy(pTTT->szText,"Save all");
			break;

		case IDC_IR_BUTTON_VIEW_MODE:
			if(m_fn_tdeGetViewMode()==ListView)
 				strcpy(pTTT->szText,"List view mode");
			else
 				strcpy(pTTT->szText,"Graph view mode");
			break;

		case IDC_IR_BUTTON_NEW_BEHAVIOUR:
 			strcpy(pTTT->szText,"Create new behaviour");
			break;

		case IDC_IR_BUTTON_PRINT:
 			strcpy(pTTT->szText,"Print");
			break;

		case IDC_IR_RADIO_DECL:
 			strcpy(pTTT->szText,"Show declaration");
			break;

		// BEGIN CPA2 Cristi Petrescu 98-03-
		case IDC_IR_RADIO_MACRO:
 			strcpy(pTTT->szText,"Show macro");
			break;
		// END CPA2 Cristi Petrescu 98-03-

		// BEGIN ROMTEAM CPA2 Cristi Petrescu 98-04-
		case IDC_IR_RADIO_SUBR:
 			strcpy(pTTT->szText,"Show subr");
		break;
			// END ROMTEAM CPA2 Cristi Petrescu 98-04-

		case IDC_IR_RADIO_INTEL:
 			strcpy(pTTT->szText,"Show intelligence");
			break;

		case IDC_IR_RADIO_REFLEX:
 			strcpy(pTTT->szText,"Show reflex");
			break;

		case IDC_IR_BUTTON_CONSTANT:
 			strcpy(pTTT->szText,"Show constant");
			break;

		default:
 			strcpy(pTTT->szText,"");
			break;
	};

	return (TRUE);
}

/**********************************************************************************/
tdeEditState CPA_EdIR_ButtonView::m_fn_tdeGetEditState()
{
	return m_tdeEditState;
}

/**********************************************************************************/
//ANNECY CB
//void CPA_EdIR_ButtonView::m_fn_vSetEditState(tdeEditState tdeState)
void CPA_EdIR_ButtonView::m_fn_vSetEditState(tdeEditState tdeState, BOOL State)
//END
{
	HINSTANCE hOldInstance=AfxGetResourceHandle();
	AfxSetResourceHandle(g_stAIIdentity.hModule);

	m_tdeEditState=tdeState;

if(State)
{
	switch(m_tdeEditState)
	{
		case EditIntell:
			((CButton *)GetDlgItem(IDC_IR_RADIO_INTEL))->SetCheck(1);
			((CButton *)GetDlgItem(IDC_IR_RADIO_REFLEX))->SetCheck(0);
			((CButton *)GetDlgItem(IDC_IR_RADIO_DECL))->SetCheck(0);
			// BEGIN CPA2 Cristi Petrescu 98-03-
			((CButton *)GetDlgItem(IDC_IR_RADIO_MACRO))->SetCheck(0);
			// END CPA2 Cristi Petrescu 98-03-
			// BEGIN ROMTEAM CPA2 Cristi Petrescu 98-04-
			((CButton *)GetDlgItem(IDC_IR_RADIO_SUBR))->SetCheck(0);
			// END ROMTEAM CPA2 Cristi Petrescu 98-04-
			break;

		case EditReflex:
			((CButton *)GetDlgItem(IDC_IR_RADIO_INTEL))->SetCheck(0);
			((CButton *)GetDlgItem(IDC_IR_RADIO_REFLEX))->SetCheck(1);
			((CButton *)GetDlgItem(IDC_IR_RADIO_DECL))->SetCheck(0);
			// BEGIN CPA2 Cristi Petrescu 98-03-
			((CButton *)GetDlgItem(IDC_IR_RADIO_MACRO))->SetCheck(0);
			// END CPA2 Cristi Petrescu 98-03-
			// BEGIN ROMTEAM CPA2 Cristi Petrescu 98-04-
			((CButton *)GetDlgItem(IDC_IR_RADIO_SUBR))->SetCheck(0);
			// END ROMTEAM CPA2 Cristi Petrescu 98-04-
			break;

		case EditDecl:
			((CButton *)GetDlgItem(IDC_IR_RADIO_INTEL))->SetCheck(0);
			((CButton *)GetDlgItem(IDC_IR_RADIO_REFLEX))->SetCheck(0);
			((CButton *)GetDlgItem(IDC_IR_RADIO_DECL))->SetCheck(1);
			// BEGIN CPA2 Cristi Petrescu 98-03-
			((CButton *)GetDlgItem(IDC_IR_RADIO_MACRO))->SetCheck(0);
			// END CPA2 Cristi Petrescu 98-03-
			// BEGIN ROMTEAM CPA2 Cristi Petrescu 98-04-
			((CButton *)GetDlgItem(IDC_IR_RADIO_SUBR))->SetCheck(0);
			// END ROMTEAM CPA2 Cristi Petrescu 98-04-
			break;

		case EditMacro:
			((CButton *)GetDlgItem(IDC_IR_RADIO_INTEL))->SetCheck(0);
			((CButton *)GetDlgItem(IDC_IR_RADIO_REFLEX))->SetCheck(0);
			((CButton *)GetDlgItem(IDC_IR_RADIO_DECL))->SetCheck(0);
			// BEGIN CPA2 Cristi Petrescu 98-03-
			((CButton *)GetDlgItem(IDC_IR_RADIO_MACRO))->SetCheck(1);
			// END CPA2 Cristi Petrescu 98-03-
			// BEGIN ROMTEAM CPA2 Cristi Petrescu 98-04-
			((CButton *)GetDlgItem(IDC_IR_RADIO_SUBR))->SetCheck(0);
			// END ROMTEAM CPA2 Cristi Petrescu 98-04-
			break;

		case EditSubr:
			((CButton *)GetDlgItem(IDC_IR_RADIO_INTEL))->SetCheck(0);
			((CButton *)GetDlgItem(IDC_IR_RADIO_REFLEX))->SetCheck(0);
			((CButton *)GetDlgItem(IDC_IR_RADIO_DECL))->SetCheck(0);
			// BEGIN CPA2 Cristi Petrescu 98-03-
			((CButton *)GetDlgItem(IDC_IR_RADIO_MACRO))->SetCheck(0);
			// END CPA2 Cristi Petrescu 98-03-
			// BEGIN ROMTEAM CPA2 Cristi Petrescu 98-04-
			((CButton *)GetDlgItem(IDC_IR_RADIO_SUBR))->SetCheck(1);
			// END ROMTEAM CPA2 Cristi Petrescu 98-04-
			break;
	}
	m_fn_vUpdateDisplay();
	((CPA_EdIR_Frame *)GetParentFrame())->m_fn_vUpdateBehaviours();
}
else
{
	((CPA_EdIR_Frame *)GetParentFrame())->m_pclBrain->m_fn_vUpdateBehavioursList(((CPA_EdIR_Frame *)GetParentFrame())->m_fn_pclGetDiagrammeView(),tdeState);
	((CPA_EdIR_Frame *)GetParentFrame())->m_fn_pclGetDiagrammeView()->m_fn_vUpdateListOfBehaviour(&(((CPA_EdIR_Frame *)GetParentFrame())->m_pclBrain->m_clListOfDeclarations), FALSE);
}

	AfxSetResourceHandle(hOldInstance);
}

/**********************************************************************************/
tdeBehaviourModeView CPA_EdIR_ButtonView::m_fn_tdeGetViewMode()
{
	return m_tdeBehaviourModeView;
}

/**********************************************************************************/
void CPA_EdIR_ButtonView::m_fn_vSetViewMode(tdeBehaviourModeView tdeMode)
{
	m_tdeBehaviourModeView=tdeMode;

	m_fn_vUpdateDisplay();

	((CPA_EdIR_Frame *)GetParentFrame())->m_fn_vChangeViewModeOfBehaviours();
}

/**********************************************************************************/
BOOL CPA_EdIR_ButtonView::OnHelpInfo(HELPINFO* pHelpInfo) 
{
	::WinHelp(m_hWnd,g_pclAIInterface->m_csBrainHelpFileNameAndPath,HELP_CONTEXTPOPUP,pHelpInfo->dwContextId);
	
	return CFormView::OnHelpInfo(pHelpInfo);
}

/**********************************************************************************/
void CPA_EdIR_ButtonView::m_fn_vEnableButtons(BOOL bEnable)
{
	HINSTANCE hOldInstance=AfxGetResourceHandle();
	AfxSetResourceHandle(g_stAIIdentity.hModule);

	m_bAreEnable=bEnable;

	CButton	*p_clBtProcess=(CButton *)GetDlgItem(IDC_IR_BUTTON_PROCESS);
	if(p_clBtProcess)
		p_clBtProcess->EnableWindow(bEnable);

	CButton	*p_clBtProcessAll=(CButton *)GetDlgItem(IDC_IR_BUTTON_PROCESS_ALL);
	if(p_clBtProcessAll)
		p_clBtProcessAll->EnableWindow(bEnable);

	CButton	*p_clBtFastC=(CButton *)GetDlgItem(IDC_IR_BUTTON_GENERATE_FASTC);
	if(p_clBtFastC)
		p_clBtFastC->EnableWindow(bEnable);

	CButton	*p_clBtDebug=(CButton *)GetDlgItem(IDC_IR_BUTTON_DEBUG);
	if(p_clBtDebug)
		p_clBtDebug->EnableWindow(bEnable);

	CButton	*p_clBtU64=(CButton *)GetDlgItem(IDC_IR_BUTTON_U64);
	if(p_clBtU64)
		p_clBtU64->EnableWindow(bEnable);

	CButton	*p_clBtOneRule=(CButton *)GetDlgItem(IDC_IR_BUTTON_ONERULE);
	if(p_clBtOneRule)
		p_clBtOneRule->EnableWindow(bEnable);

	CButton	*p_clBtStop=(CButton *)GetDlgItem(IDC_IR_BUTTON_STOP);
	if(p_clBtStop)
		p_clBtStop->EnableWindow(m_bProcessInProgress);

	CButton	*p_clBtCheck=(CButton *)GetDlgItem(IDC_IR_BUTTON_CHECK);
	if(p_clBtCheck)
		p_clBtCheck->EnableWindow(bEnable);

//ANNECY CB
	CButton	*p_clBtQuickSave=(CButton *)GetDlgItem(IDC_IR_BUTTON_QUICKSAVE);
	if(p_clBtQuickSave)
		p_clBtQuickSave->EnableWindow(bEnable);
//END

	CButton	*p_clBtSaveAll=(CButton *)GetDlgItem(IDC_IR_BUTTON_SAVE_ALL);
	if(p_clBtSaveAll)
		p_clBtSaveAll->EnableWindow(bEnable);

	CButton	*p_clBtPrint=(CButton *)GetDlgItem(IDC_IR_BUTTON_PRINT);
	if(p_clBtPrint)
		p_clBtPrint->EnableWindow(bEnable);

	CButton	*p_clBtNewBehaviour=(CButton *)GetDlgItem(IDC_IR_BUTTON_NEW_BEHAVIOUR);
	if(p_clBtNewBehaviour)
		p_clBtNewBehaviour->EnableWindow(m_fn_tdeGetEditState()!=EditDecl && bEnable);

	CButton	*p_clBtViewMode=(CButton *)GetDlgItem(IDC_IR_BUTTON_VIEW_MODE);
	if(p_clBtViewMode)
		p_clBtViewMode->EnableWindow(bEnable);

	CButton	*p_clBtIntel=(CButton *)GetDlgItem(IDC_IR_RADIO_INTEL);
	if(p_clBtIntel)
		p_clBtIntel->EnableWindow(bEnable);

	CButton	*p_clBtReflex=(CButton *)GetDlgItem(IDC_IR_RADIO_REFLEX);
	if(p_clBtReflex)
		p_clBtReflex->EnableWindow(bEnable);
	
	CButton	*p_clBtDecl=(CButton *)GetDlgItem(IDC_IR_RADIO_DECL);
	if(p_clBtDecl)
		p_clBtDecl->EnableWindow(bEnable);

	// BEGIN CPA2 Cristi Petrescu 98-03-
	CButton	*p_clBtMacro=(CButton *)GetDlgItem(IDC_IR_RADIO_MACRO);
	if(p_clBtMacro)
		p_clBtMacro->EnableWindow(bEnable);
	// END CPA2 Cristi Petrescu 98-03-

	// BEGIN ROMTEAM CPA2 Cristi Petrescu 98-04-
	CButton	*p_clBtSubr=(CButton *)GetDlgItem(IDC_IR_RADIO_SUBR);
	if(p_clBtSubr)
		p_clBtSubr->EnableWindow(bEnable);
	// END ROMTEAM CPA2 Cristi Petrescu 98-04-

	CButton	*p_clBtConstant=(CButton *)GetDlgItem(IDC_IR_BUTTON_CONSTANT);
	if(p_clBtConstant)
		p_clBtConstant->EnableWindow(bEnable);

// Shaitan => Macros to subroutines
	CButton	*p_clBtMtoSAll=(CButton *)GetDlgItem(IDC_IR_BUTTON_MACROTOSUBR_ALL);
	if(p_clBtMtoSAll)
		p_clBtMtoSAll->EnableWindow(bEnable);

	CButton	*p_clBtMtoSOne=(CButton *)GetDlgItem(IDC_IR_BUTTON_MACROTOSUBR_ONE);
	if(p_clBtMtoSOne)
	{
		tdeEditState eState = m_fn_tdeGetEditState();
		if (eState == EditDecl)
			p_clBtMtoSOne->EnableWindow(bEnable);
		else if (eState == EditMacro)
			p_clBtMtoSOne->EnableWindow(bEnable && (((CPA_EdIR_Frame *)GetParentFrame())->m_fn_pclGetDiagrammeView()->m_fn_pclGetActiveBehaviour() != NULL));
		else
			p_clBtMtoSOne->EnableWindow(FALSE);
	}
// End Shaitan => Macros to subroutines

	AfxSetResourceHandle(hOldInstance);
}

/**********************************************************************************/
BOOL CPA_EdIR_ButtonView::m_fn_bGetButtonsSate()
{
	return m_bAreEnable;
}

/**********************************************************************************/
BOOL CPA_EdIR_ButtonView::m_fn_bMustStopProcess()
{
	return m_bMustStopProcess;
}


//Stefan Dumitrean 30-06-98
//need to call this from CPA_EdIR_EditCtrl
void CPA_EdIR_ButtonView::m_fn_vProcessIA()
{
	m_bProcessInProgress=TRUE;
	CButton	*p_clBtStop=(CButton *)GetDlgItem(IDC_IR_BUTTON_STOP);
	if(p_clBtStop)
		p_clBtStop->EnableWindow(TRUE);
//ROMTEAM Force total compilation 09.06.98 Ionut Grozea
	if(((CPA_EdIR_Frame *)GetParentFrame())->m_pclBrain->m_fn_MacrosHasBeenModified())
	{
		((CPA_EdIR_Frame *)GetParentFrame())->m_fn_bProcessIA(TRUE);
	}
	else
	{
		((CPA_EdIR_Frame *)GetParentFrame())->m_fn_bProcessIA(FALSE);
	}
//ENDROMTEAM Force total compilation 09.06.98 Ionut Grozea
	m_bProcessInProgress=FALSE;
	if(p_clBtStop)
		p_clBtStop->EnableWindow(FALSE);

	m_bMustStopProcess=FALSE;

//Stefan Dumitrean 8-07-98 ( macro color )
	m_fn_vRefreshColorInAllBehaviours();
//End Stefan Dumitrean 8-07-98 ( macro color )
}
//End Stefan Dumitrean 30-06-98

//Stefan Dumitrean 8-07-98 ( macro color )
void CPA_EdIR_ButtonView::m_fn_vRefreshColorInListBehaviour( CPA_EdIR_MainBehaviourList * p_clMBList)
{
	CPA_EdIR_Behaviour * p_clBehaviour;
	if( !p_clMBList )
		return;
	POSITION pos = p_clMBList->GetHeadPosition();
	while( pos )
	{
		p_clBehaviour = p_clMBList->GetNext( pos )->m_pclBehaviour;
		if( p_clBehaviour )
		{
			p_clBehaviour->m_bFirstActivate = TRUE;;
			//the next time this behaviour will be displayed its colours will be
			//updated. 
			if( p_clBehaviour->m_fn_bIsActive() )
				p_clBehaviour->m_clEditCtrl.m_fn_vColorText(0,p_clBehaviour->m_clEditCtrl.GetTextLength());
				//update colors for the current displayed behaviour
		}
	}
}


void CPA_EdIR_ButtonView::m_fn_vRefreshColorInAllBehaviours()
{
	if( !((CPA_EdIR_Frame *)GetParentFrame())->m_pclBrain )
		return;
	m_fn_vRefreshColorInListBehaviour( &((CPA_EdIR_Frame *)GetParentFrame())->m_pclBrain->m_clListOfDeclarations );
	m_fn_vRefreshColorInListBehaviour( &((CPA_EdIR_Frame *)GetParentFrame())->m_pclBrain->m_clListOfIntelligenceBehaviours );
	m_fn_vRefreshColorInListBehaviour( &((CPA_EdIR_Frame *)GetParentFrame())->m_pclBrain->m_clListOfMacros );
	m_fn_vRefreshColorInListBehaviour( &((CPA_EdIR_Frame *)GetParentFrame())->m_pclBrain->m_clListOfReflexBehaviours );
	m_fn_vRefreshColorInListBehaviour( &((CPA_EdIR_Frame *)GetParentFrame())->m_pclBrain->m_clListOfSubrs );
}
//End Stefan Dumitrean 8-07-98 ( macro color )

// BEGIN ROMTEAM Cristi Petrescu 99-01- debug
void CPA_EdIR_ButtonView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView) 
{
	tdeEditState tdeState = m_fn_tdeGetEditState ();
	
	CFormView::OnActivateView(bActivate, pActivateView, pDeactiveView);

	m_fn_vSetEditState (tdeState, TRUE);
}
// END ROMTEAM Cristi Petrescu 99-01- debug

#endif //D_ED_IR_ACTIVE
