//=========================================================================
// CPADgBar.cpp : implementation file for main dialog bar
// This is a part of the CPA project.
//
// Version			1.0
// Creation date	06/06/96
// Revision date
//
// (c) Ubi Studios 1996
//
// DO NOT MODIFY THAT FILE. IF SOMETHING NEEDS TO BE CHANGE, PLEASE CONTACT 
// VINCENT GRECO OR CHRISTOPHE BEAUDET.
//=========================================================================

#include "stdafx.h"

#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "itf/CPADgBar.hpp"
#include "itf/CPAProj.hpp"
#include "itf/CPARes.h"
#include "itf/CPAPopTb.hpp"
#include "itf/camdllb.hpp"
#include "itf/stddllid.h"
#include "itf/cpainter.hpp"
#include "itf/cpaspec.hpp"
//Mircea Dunka 1 sept. 1998
#include "itf/CPAMWorl.hpp"
//#include "itf/customID.h"
//end Mircea Dunka

BEGIN_MESSAGE_MAP(CPA_DialogBar, CDialogBar)
	//{{AFX_MSG_MAP(CPA_DialogBar)
	ON_CBN_SELCHANGE(CPA_IDCB_SELECTMODE, OnSelChangeComboMode)
	ON_BN_CLICKED(CPA_IDCB_AUTOTARGET, OnAutoTarget)
	ON_BN_CLICKED(CPA_IDCB_AUTOZOOM, OnAutoZoom)
    ON_BN_CLICKED(CPA_IDCB_FULL, OnFull)
    ON_BN_CLICKED(CPA_IDCB_DELTA, OnDelta)
	ON_BN_CLICKED(CPA_IDCB_LOCK, OnLockSelection)
	ON_CBN_SELCHANGE(CPA_IDCB_CURRENTSECTOR, OnSelChangeComboSector)
	ON_COMMAND(CPA_IDB_DISPLAYWORLD, OnDisplayWorld)
	ON_COMMAND(CPA_IDB_DISPLAYVISIBLE, OnDisplayVisible)
	ON_COMMAND(CPA_IDB_DISPLAYSECTOR, OnDisplaySector)
	ON_COMMAND(CPA_IDB_DISPLAYFOG, OnDisplayFog)
	ON_COMMAND(CPA_IDB_DISPLAYNOFOG, OnDisplayNoFog)
	ON_COMMAND(CPA_IDB_TEXTURED, OnTextured)
	ON_COMMAND(CPA_IDB_NOTEX, OnNoTex)
	ON_COMMAND(CPA_IDB_GRIDED, OnGrided)
	ON_COMMAND(CPA_IDB_GRIDEDNOTEX, OnGridedNoTex)
	ON_COMMAND(CPA_IDB_WIRED, OnWired)
	ON_COMMAND(CPA_IDB_WIREDNOTEX, OnWiredNoTex)
	ON_COMMAND(CPA_IDB_NOBV, OnNoBV)
	ON_COMMAND(CPA_IDB_SECTORBV, OnSectorBV)
	ON_COMMAND(CPA_IDB_ACTORBV, OnActorBV)
	ON_COMMAND(CPA_IDB_OBJECTBV, OnObjectBV)
	ON_COMMAND(IDCB_NORMAL, OnNoCenter)
	ON_COMMAND(IDCB_MAINCENTERS, OnMainCenters)
	ON_COMMAND(IDCB_ALLCENTERS, OnAllCenters)
	ON_COMMAND(IDCB_NOCONSTRAINT, OnNoConstraint)
	ON_COMMAND(IDCB_CONSTRAINTX, OnConstraintX)
	ON_COMMAND(IDCB_CONSTRAINTY, OnConstraintY)
	ON_COMMAND(IDCB_CONSTRAINTZ, OnConstraintZ)
	ON_COMMAND(IDCB_CONSTRAINTXY, OnConstraintXY)
	ON_COMMAND(IDCB_CONSTRAINTXZ, OnConstraintXZ)
	ON_COMMAND(IDCB_CONSTRAINTYZ, OnConstraintYZ)
	ON_COMMAND(CPA_IDB_OPENDEVICE, OnOpenDevice)
	ON_COMMAND(CPA_IDB_DEVICE_TILE_HORZ, OnTileHoriz)
	ON_COMMAND(CPA_IDB_DEVICE_TILE_VERT, OnTileVert)
	ON_COMMAND(CPA_IDB_DEVICE_CASCADE, OnCascade)
	ON_COMMAND(CPA_IDB_DEVICE_SPLITVERT, OnSplitVert)
	ON_COMMAND(CPA_IDB_DEVICE_SPLITHORIZ, OnSplitHoriz)
	ON_COMMAND_RANGE(40000,40050,OnCommandRange)
	ON_NOTIFY_EX(TTN_NEEDTEXT, 0, OnToolTipNotify)
	ON_BN_CLICKED(CPA_IDCB_MOVECAMERA, OnMoveCamera) // CPA_Ed_1 FS
	ON_COMMAND(CPA_IDB_NOAXIS,OnDisplayNoAxis)
	ON_COMMAND(CPA_IDB_AXISDOWNLEFT,OnDisplayAxisDownLeft)
	ON_COMMAND(CPA_IDB_AXISDOWNRIGHT,OnDisplayAxisDownRight)
	ON_BN_CLICKED(CPA_IDCB_STATUSBARMODE, OnStatusBarMode) // Silviu Simen 13 August 1998 Button for StatusBar
	ON_BN_CLICKED(CPA_IDCB_SELECTBYSECTOR, OnSelectBySector) // Silviu Simen Select by sector
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPA_DialogBar dialog construction
//		Mircea Dunka - 30 Aug 1998
//			 - added dialog bar support for editors
CPA_DialogBar::CPA_DialogBar() : CDialogBar()
{
	m_p_oCamera = NULL;
	if(!m_oListOfEditorButtons.IsEmpty())
		m_oListOfEditorButtons.RemoveAll();
}
CPA_DialogBar::~CPA_DialogBar()
{
	CButton *p_But;
	while(!m_oListOfEditorButtons.IsEmpty())
	{
		p_But = m_oListOfEditorButtons.RemoveHead();
		p_But->ShowWindow(SW_HIDE);
		delete(p_But);
	}
}

/////////////////////////////////////////////////////////////////////////////
FRMBaseMenu * CPA_DialogBar::GetParentFrame()
{
	return (FRMBaseMenu *) GetParent();
}

DEV_MultiDevice * CPA_DialogBar::GetParentMultiDevice()
{
	return (DEV_MultiDevice *) GetParentFrame()->GetActiveView();
}

FRMSplitter * CPA_DialogBar::GetParentSplitter()
{
	return (FRMSplitter *) GetParentMultiDevice()->GetParent();
}

/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnOpenDevice(void)
{
	((DEV_MultiDevice *) (GetParentFrame()->m_oSplitter.GetActivePane()))->OnOpenDevice();
}
void CPA_DialogBar::OnTileHoriz(void)
{
	GetParentMultiDevice()->OnDeviceTileHorz();
}
void CPA_DialogBar::OnTileVert(void)
{
	GetParentMultiDevice()->OnDeviceTileVert();
}
void CPA_DialogBar::OnCascade(void)
{
	GetParentMultiDevice()->OnDeviceCascade();
}
void CPA_DialogBar::OnSplitHoriz(void)
{
	GetParentSplitter()->MakeSplit(1);
}
void CPA_DialogBar::OnSplitVert(void)
{
	GetParentSplitter()->MakeSplit(2);
}

//===========================================================================
//	Description:	Creation of main dialog bar.
//					=> Load icons for buttons
//					=> Init combo box with all current editors
//	Creation date:	18 Jun 96
//	Author:			CB
//---------------------------------------------------------------------------
//	BOOL			Not used
//	Return void
//---------------------------------------------------------------------------
//	Revision date:												Author:		
//===========================================================================
BOOL CPA_DialogBar::Create(CWnd* pParentWnd, UINT nIDTemplate, UINT nStyle, UINT nID)
{
	BOOL	bRes;

	bRes = CDialogBar::Create(pParentWnd, nIDTemplate, nStyle, nID);
	if(bRes)
	{
		m_ToolTip.Create (this);
		m_ToolTip.Activate (TRUE);

		CWnd*    pWnd = GetWindow (GW_CHILD);
		while (pWnd)
		{
			int nID = pWnd->GetDlgCtrlID ();
			if (nID != -1)
			{
				m_ToolTip.AddTool (pWnd, pWnd->GetDlgCtrlID ());
			}
			pWnd = pWnd->GetWindow (GW_HWNDNEXT);
		}
		//
		//	ICON FOR BUTTONS
		//
		CButton* p_But;
		// To swap beetween edit and engine mode
		p_But = (CButton *) GetDlgItem(CPA_IDCB_SWAPTOEDITORS);
		p_But->SetIcon(M_GetMainApp()->LoadIcon(CPA_IDI_SWAPTOEDITORS));
		p_But->SetWindowPos(NULL, 0, 0, 26, 26, SWP_NOMOVE);
		// To pause engine
		p_But = (CButton *) GetDlgItem(CPA_IDCB_PAUSEENGINE);
		p_But->SetIcon(M_GetMainApp()->LoadIcon(CPA_IDI_PAUSEENGINE));
		p_But->SetWindowPos(NULL, 0, 0, 26, 26, SWP_NOMOVE);
		// One step engine
		p_But = (CButton *) GetDlgItem(CPA_IDCB_ONESTEPENGINE);
		p_But->SetIcon(M_GetMainApp()->LoadIcon(CPA_IDI_ONESTEPENGINE));
		p_But->SetWindowPos(NULL, 0, 0, 26, 26, SWP_NOMOVE);
		// Full screen
		p_But = (CButton *) GetDlgItem(CPA_IDCB_FULLSCREEN);
		p_But->SetIcon(M_GetMainApp()->LoadIcon(CPA_IDI_FULLSCREEN));
		p_But->SetWindowPos(NULL, 0, 0, 26, 26, SWP_NOMOVE);
		// Undo & Redo
		p_But = (CButton *) GetDlgItem(CPA_IDCB_UNDO);
		p_But->SetIcon(M_GetMainApp()->LoadIcon(CPA_IDI_UNDO));
		p_But->SetWindowPos(NULL, 0, 0, 26, 26, SWP_NOMOVE);

		p_But = (CButton *) GetDlgItem(CPA_IDCB_REDO);
		p_But->SetIcon(M_GetMainApp()->LoadIcon(CPA_IDI_REDO));
		p_But->SetWindowPos(NULL, 0, 0, 26, 26, SWP_NOMOVE);

		// Save
		p_But = (CButton *) GetDlgItem(CPA_IDCB_SAVEALL);
		p_But->SetIcon(M_GetMainApp()->LoadIcon(CPA_IDI_SAVE));
		p_But->SetWindowPos(NULL, 0, 0, 26, 26, SWP_NOMOVE);
		// Options
		p_But = (CButton *) GetDlgItem(CPA_IDCB_OPTIONS);
		p_But->SetIcon(M_GetMainApp()->LoadIcon(CPA_IDI_OPTION));
		p_But->SetWindowPos(NULL, 0, 0, 26, 26, SWP_NOMOVE);

		// Full Select
		m_hFullSelIcon = M_GetMainApp()->LoadIcon(CPA_IDI_FULLSELECT);
		m_hNoFullIcon = M_GetMainApp()->LoadIcon(CPA_IDI_NOFULLSELECT);

		p_But = (CButton *) GetDlgItem(CPA_IDCB_FULL);
		p_But->SetIcon(m_hNoFullIcon);
		p_But->SetWindowPos(NULL, 0, 0, 26, 26, SWP_NOMOVE);

		// Delta Select
		m_hDeltaSelIcon = M_GetMainApp()->LoadIcon(CPA_IDI_DELTASELECT);
		m_hNoDeltaIcon = M_GetMainApp()->LoadIcon(CPA_IDI_NODELTASELECT);

		p_But = (CButton *) GetDlgItem(CPA_IDCB_DELTA);
		p_But->SetIcon(m_hNoDeltaIcon);
		p_But->SetWindowPos(NULL, 0, 0, 26, 26, SWP_NOMOVE);

		// Lock Selection
		m_hLockSelIcon = M_GetMainApp()->LoadIcon(CPA_IDI_LOCKSEL);
		m_hNoLockIcon = M_GetMainApp()->LoadIcon(CPA_IDI_NOLOCK);

		p_But = (CButton *) GetDlgItem(CPA_IDCB_LOCK);
		p_But->SetIcon(m_hNoLockIcon);
		p_But->SetWindowPos(NULL, 0, 0, 26, 26, SWP_NOMOVE);

		// Auto target
		m_hTargetIcon = M_GetMainApp()->LoadIcon(CPA_IDI_TARGET);
		m_hNoTargetIcon = M_GetMainApp()->LoadIcon(CPA_IDI_NOTARGET);

		p_But = (CButton *) GetDlgItem(CPA_IDCB_AUTOTARGET);
		p_But->SetIcon(m_hNoTargetIcon);
		p_But->SetWindowPos(NULL, 0, 0, 26, 26, SWP_NOMOVE);

		// Auto zoom
		m_hZoomIcon = M_GetMainApp()->LoadIcon(CPA_IDI_ZOOM);
		m_hNoZoomIcon = M_GetMainApp()->LoadIcon(CPA_IDI_NOZOOM);

		p_But = (CButton *) GetDlgItem(CPA_IDCB_AUTOZOOM);
		p_But->SetIcon(m_hNoZoomIcon);
		p_But->SetWindowPos(NULL, 0, 0, 26, 26, SWP_NOMOVE);

		// Move camera
		m_hMoveIcon = M_GetMainApp()->LoadIcon(CPA_IDI_MOVE);
		m_hNoMoveIcon = M_GetMainApp()->LoadIcon(CPA_IDI_NOMOVE);

		p_But = (CButton *) GetDlgItem(CPA_IDCB_MOVECAMERA);
		p_But->SetIcon(m_hNoMoveIcon);
		p_But->SetWindowPos(NULL, 0, 0, 26, 26, SWP_NOMOVE);

		
// Begin Silviu Simen 13 August 1998 Button for StatusBar
	// To swap beetween StatusBar modes
		m_hInsInfIcon = M_GetMainApp()->LoadIcon(CPA_IDI_INSTANCEINFO);
		m_hInsCamIcon = M_GetMainApp()->LoadIcon(CPA_IDI_INSTANCECAM);
		m_hCamInfIcon = M_GetMainApp()->LoadIcon(CPA_IDI_CAMERAINFO);

		p_But = (CButton *) GetDlgItem(CPA_IDCB_STATUSBARMODE);
		p_But->SetIcon(m_hInsInfIcon);
		p_But->SetWindowPos(NULL, 0, 0, 26, 26, SWP_NOMOVE|SWP_NOZORDER);
// End Silviu Simen 13 August 1998 Button for StatusBar
// Begin Silviu Simen Select by sector
		m_hSelectBySector = M_GetMainApp()->LoadIcon(CPA_IDI_SELECTBYSECTOR);
		p_But = (CButton *) GetDlgItem(CPA_IDCB_SELECTBYSECTOR);
		p_But->SetIcon(m_hSelectBySector);
		p_But->SetWindowPos(NULL, 0, 0, 26, 26, SWP_NOMOVE|SWP_NOZORDER);
// End Silviu Simen Select by sector

		// Toolbar for display mode
		tdstButtonDef a_stModeButtonDef[] =
		{
			// display
			{CPA_IDB_DISPLAYWORLD, TRUE, "Display : World"},
			{CPA_IDB_DISPLAYVISIBLE, TRUE, "Display : Visible Sectors"},
			{CPA_IDB_DISPLAYSECTOR, TRUE, "Display : Current Sector"},
			{CPA_IDB_DENDFAMILY, TRUE, ""},
			// fog
			{CPA_IDB_DISPLAYFOG, TRUE, "Fog : display"},
			{CPA_IDB_DISPLAYNOFOG, TRUE, "Fog : none"},
			{CPA_IDB_DENDFAMILY, TRUE, ""},
			// appearance
			{CPA_IDB_TEXTURED, TRUE, "Render : Textured"},
			{CPA_IDB_NOTEX, TRUE, "Render : Not Textured"},
			{CPA_IDB_GRIDED, TRUE, "Render : Grided"},
			{CPA_IDB_GRIDEDNOTEX, TRUE, "Render : Grided without Texture"},
			{CPA_IDB_WIRED, TRUE, "Render : Wired"},
			{CPA_IDB_WIREDNOTEX, TRUE, "Render : Wired without Texture"},
			{CPA_IDB_DENDFAMILY, TRUE, ""},
			// bounding volumes
			{CPA_IDB_NOBV, TRUE, "Display Bounding Volumes : None"},
			{CPA_IDB_SECTORBV, TRUE, "Display Bounding Volumes : Sectors"},
			{CPA_IDB_ACTORBV, TRUE, "Display Bounding Volumes : Actors"},
			{CPA_IDB_OBJECTBV, TRUE, "Display Bounding Volumes : Objects"},
			{CPA_IDB_DENDFAMILY, TRUE, ""},
			// Axis display
			{CPA_IDB_NOAXIS, TRUE, "Display Axis : None"},
			{CPA_IDB_AXISDOWNLEFT, TRUE, "Display Axis : Left Corner"},
			{CPA_IDB_AXISDOWNRIGHT, TRUE, "Display Axis : Right Corner"},
			{CPA_IDB_DENDFAMILY, TRUE, ""},
			// centers
			{IDCB_NORMAL, TRUE, "Display Centers : None"},
			{IDCB_MAINCENTERS, TRUE, "Display Centers : Instances"},
			{IDCB_ALLCENTERS, TRUE, "Display Centers : Objects"},
			{CPA_IDB_DENDFAMILY, TRUE, ""},
		};

		m_oDisplayToolbar.Define(a_stModeButtonDef, 27, CPA_IDTB_DISPLAY, CPA_IDB_DENDFAMILY, 18, 18);
		m_oDisplayToolbar.CreateToolBarCtrl(this, CPoint(228, -1));

		// Toolbar for constraint move
		tdstButtonDef a_stDevButtonDef[] =
		{
			{IDCB_NOCONSTRAINT, TRUE, "No Constraint"},
			{IDCB_CONSTRAINTX, TRUE, " Move on X Axis Only"},
			{IDCB_CONSTRAINTY, TRUE, " Move on Y Axis Only"},
			{IDCB_CONSTRAINTZ, TRUE, " Move on Z Axis Only"},
			{IDCB_CONSTRAINTXY, TRUE, " Move on XoY Plane Only"},
			{IDCB_CONSTRAINTXZ, TRUE, " Move on XoZ Plane Only"},
			{IDCB_CONSTRAINTYZ, TRUE, " Move on YoZ Plane Only"},
			{CPA_IDB_ENDFAMILY, TRUE, ""},
		};

		m_oDeviceToolbar.Define(a_stDevButtonDef, 8, CPA_IDTB_DEVICE, CPA_IDB_ENDFAMILY, 18, 18);
		m_oDeviceToolbar.CreateToolBarCtrl(this, CPoint(567, -1));

	}
	ShowWindow(FALSE);
	return bRes;
}

//Begin Mircea Dunka 2 Sept 1998
void CPA_DialogBar::ShowWindow( BOOL bShow )
{
	//
	//	EDITOR BUTTONS - MIRCEA DUNKA 31 aug 1998
	//	
	if(bShow)
	{
		CButton *p_But;

		//the buttons list
		while(!m_oListOfEditorButtons.IsEmpty())
		{
			p_But = m_oListOfEditorButtons.RemoveHead();
			p_But->ShowWindow(SW_HIDE);
//			p_But->DestroyWindow();
//			delete(p_But);
		}
		
		//I have to initialize the "editors" menu in order to use the buttons :)
		FRMBaseMenu *pFrmBaseMenu = GetParentFrame();
		pFrmBaseMenu->m_p_oEditorSubMenu->Clear();
		// call Hierarchy Editor
		pFrmBaseMenu->M_GetEditor()->fn_bDefineSubMenu(pFrmBaseMenu->m_p_oEditorSubMenu);
		// call Objects DLLs
		pFrmBaseMenu->AddItemToPopupMenu(pFrmBaseMenu->m_p_oEditorSubMenu,(CPA_List<CPA_DLLBase>*)M_GetObjectDLLList());
		// call Tool DLLs
		pFrmBaseMenu->AddItemToPopupMenu(pFrmBaseMenu->m_p_oEditorSubMenu,(CPA_List<CPA_DLLBase>*)M_GetToolDLLList());
		

		CPA_List<CPA_DLLBase>* _p_oListOfDLL;
		POSITION stPos;
		CRect rcButton(0,27,26,26);
		UINT uID = C_EditorButtonIDStart;
		tds_DlgBarBtn sDlgBarBtn={NULL,0,""};

		
		//call hierarchy editor
		M_GetEditor()->fn_vDefineDlgBarBtnIcon (C_DlgBarCategoryEditor, &sDlgBarBtn);
		if(sDlgBarBtn.hIcon != NULL)
		{
			p_But = new CButton();
			p_But->Create("", BS_AUTORADIOBUTTON | BS_PUSHLIKE  | BS_ICON
				| WS_EX_STATICEDGE | WS_VISIBLE
				| WS_GROUP /**************!!!!!!!!!!!!!!!!!!************/
				, rcButton, this, uID++);

			SetWindowLong(p_But->m_hWnd, GWL_USERDATA, sDlgBarBtn.uID);
			p_But->SetIcon(sDlgBarBtn.hIcon);
			sDlgBarBtn.hIcon = NULL;
			p_But->SetWindowPos(NULL, 0, 0, 26, 26, SWP_NOMOVE);
			m_ToolTip.AddTool ((CWnd*)p_But, sDlgBarBtn.szToolTip);
			m_oListOfEditorButtons.AddTail(p_But);
			rcButton.left += 27;
			rcButton.right += 27;
		}
		// call Objects DLLs
		_p_oListOfDLL = (CPA_List<CPA_DLLBase>*)M_GetObjectDLLList();
		//add objects DLL button to dialog bar
	    stPos = _p_oListOfDLL->GetHeadPosition();
		while(stPos)
		{
			CPA_DLLBase *p_oDLL = _p_oListOfDLL->GetNext(stPos);
			p_oDLL->fn_vDefineDlgBarBtnIcon (C_DlgBarCategoryEditor, &sDlgBarBtn);
			if(sDlgBarBtn.hIcon != NULL)
			{
				p_But = new CButton();
				p_But->Create("", BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_ICON 
					| WS_EX_STATICEDGE | WS_VISIBLE, rcButton, this, uID++);
				long lStyle = ::GetWindowLong(p_But->m_hWnd, GWL_STYLE);
				SetWindowLong(p_But->m_hWnd, GWL_USERDATA, sDlgBarBtn.uID);
				p_But->SetIcon(sDlgBarBtn.hIcon);
				sDlgBarBtn.hIcon = NULL;
				p_But->SetWindowPos(NULL, 0, 0, 26, 26, SWP_NOMOVE);
				m_ToolTip.AddTool ((CWnd*)p_But, sDlgBarBtn.szToolTip);
				m_oListOfEditorButtons.AddTail(p_But);
				rcButton.left += 27;
				rcButton.right += 27;
			}
	    }

		// call Tool DLLs
        _p_oListOfDLL = (CPA_List<CPA_DLLBase>*)M_GetToolDLLList();
		// add tool DLL button to dialog bar
	    stPos = _p_oListOfDLL->GetHeadPosition();
		while(stPos)
		{
			CPA_DLLBase *p_oDLL = _p_oListOfDLL->GetNext(stPos);
			p_oDLL->fn_vDefineDlgBarBtnIcon (C_DlgBarCategoryEditor, &sDlgBarBtn);
			if(sDlgBarBtn.hIcon != NULL)
			{
				p_But = new CButton();
				p_But->Create("", BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_ICON
					| WS_EX_STATICEDGE | WS_VISIBLE, rcButton, this, uID++);
				SetWindowLong(p_But->m_hWnd, GWL_USERDATA, sDlgBarBtn.uID);
				p_But->SetIcon(sDlgBarBtn.hIcon);
				sDlgBarBtn.hIcon = NULL;
				p_But->SetWindowPos(NULL, 0, 0, 26, 26, SWP_NOMOVE);
				m_ToolTip.AddTool ((CWnd*)p_But, sDlgBarBtn.szToolTip);
				m_oListOfEditorButtons.AddTail(p_But);
				rcButton.left += 27;
				rcButton.right += 27;
			}
		}
//comment
//		the first editor is the hierarchy editor
//		((CButton*)GetDlgItem(C_EditorButtonIDStart))->SetCheck(1);
	}
	CDialogBar::ShowWindow( bShow );
	
	// update activation
	if (bShow)
		GetParentFrame()->fn_vUpdateCurrentEditor(M_GetCurrentEditor());

}
//End Mircea Dunka 1998


void CPA_DialogBar::OnCommandRange(UINT nID)
{
	if (m_p_oCamera)
		((CPA_CameraDLLBase*) m_p_oCamera->GetEditor())->SendDialogBarCommandToCamera(m_p_oCamera,nID);
}





/////////////////////////////////////////////////////////////////////////////
// Select Mode

CPA_Interface * CPA_DialogBar::GetInterface (void)
{
	return GetParentMultiDevice()->GetInterface();
}

/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnSelChangeComboMode (void)
{
	GetInterface()->fn_vOnChangeSelectMode();
}

/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnAutoTarget (void)
{
	CButton *pBut;
	
	pBut = (CButton *) GetDlgItem(CPA_IDCB_AUTOTARGET);
	GetInterface()->SetAutoTarget(pBut->GetCheck());
}

/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::fn_vUpdateAutoTarget (BOOL bAutoTarget)
{
	CButton *pBut;
	
	pBut = (CButton *) GetDlgItem(CPA_IDCB_AUTOTARGET);
	pBut->SetCheck(bAutoTarget);
	pBut->SetIcon(bAutoTarget ? m_hTargetIcon : m_hNoTargetIcon);
}

/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnAutoZoom (void)
{
	CButton *pBut;
	
	pBut = (CButton *) GetDlgItem(CPA_IDCB_AUTOZOOM);
	GetInterface()->SetAutoZoom(pBut->GetCheck());
}

/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::fn_vUpdateAutoZoom (BOOL bAutoZoom)
{
	CButton *pBut;
	
	pBut = (CButton *) GetDlgItem(CPA_IDCB_AUTOZOOM);
	pBut->SetCheck(bAutoZoom);
	pBut->SetIcon(bAutoZoom ? m_hZoomIcon : m_hNoZoomIcon);
}

/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnFull (void)
{
	CButton *pBut = (CButton *) GetDlgItem(CPA_IDCB_FULL);
	GetInterface()->SetFullSelect(pBut->GetCheck());
	GetInterface()->fn_vUpdateAll(E_mc_UpdateDialog);
	pBut->SetIcon(pBut->GetCheck() ? m_hFullSelIcon : m_hNoFullIcon);
}
/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnDelta (void)
{
	CButton *pBut = (CButton *) GetDlgItem(CPA_IDCB_DELTA);
	GetInterface()->SetDeltaSelect(pBut->GetCheck());
	pBut->SetIcon(pBut->GetCheck() ? m_hDeltaSelIcon : m_hNoDeltaIcon);
}

/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::fn_vUpdateFullSelect (BOOL bSelect)
{
	CButton *pBut = (CButton *) GetDlgItem(CPA_IDCB_FULL);
	pBut->SetCheck(bSelect);
	pBut->SetIcon(bSelect ? m_hFullSelIcon : m_hNoFullIcon);
}

/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::fn_vUpdateDeltaSelect (BOOL bSelect)
{
	CButton *pBut = (CButton *) GetDlgItem(CPA_IDCB_DELTA);
	pBut->SetCheck(bSelect);
	pBut->SetIcon(bSelect ? m_hDeltaSelIcon : m_hNoDeltaIcon);
}

/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnLockSelection()
{
	CButton *pBut = (CButton *) GetDlgItem(CPA_IDCB_LOCK);
	GetInterface()->SetLockSelection(pBut->GetCheck());
	pBut->SetIcon(pBut->GetCheck() ? m_hLockSelIcon : m_hNoLockIcon);
	GetInterface()->fn_vUpdateAll(E_mc_UpdateDialog);
}

/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::fn_vUpdateLockButton()
{
	CButton *pBut = (CButton *) GetDlgItem(CPA_IDCB_LOCK);
	pBut->SetCheck(GetInterface()->GetLockSelection());
	pBut->SetIcon(pBut->GetCheck() ? m_hLockSelIcon : m_hNoLockIcon);
}


/////////////////////////////////////////////////////////////////////////////
// Move Camera
void CPA_DialogBar::OnMoveCamera (void) 
{
	CButton *pBut;
	
	pBut = (CButton *) GetDlgItem(CPA_IDCB_MOVECAMERA);
	GetInterface()->SetMoveCamera(pBut->GetCheck());
	pBut->SetIcon(pBut->GetCheck() ? m_hMoveIcon : m_hNoMoveIcon);

}

/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::SetMoveCamera (int state) 
{
	CButton *pBut;
	
	pBut = (CButton *) GetDlgItem(CPA_IDCB_MOVECAMERA);
	pBut->SetCheck( state );
	GetInterface()->SetMoveCamera(pBut->GetCheck());
	pBut->SetIcon(pBut->GetCheck() ? m_hMoveIcon : m_hNoMoveIcon);
}


/////////////////////////////////////////////////////////////////////////////
// Current Sector

void CPA_DialogBar::OnSelChangeComboSector (void)
{
	GetInterface()->GetSpecificInterface()->fn_vOnChangeCurrentSector();
}

/////////////////////////////////////////////////////////////////////////////
// DisplayMode

void CPA_DialogBar::OnDisplayWorld (void)
{
	GetInterface()->GetSpecificInterface()->fn_vOnChangeDisplayMode(E_dm_DrawWorld);
	m_oDisplayToolbar.SetButton(CPA_IDB_DISPLAYWORLD);
}
/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnDisplayVisible (void)
{
	GetInterface()->GetSpecificInterface()->fn_vOnChangeDisplayMode(E_dm_DrawVisibleSectors);
	m_oDisplayToolbar.SetButton(CPA_IDB_DISPLAYVISIBLE);
}
/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnDisplaySector (void)
{
	GetInterface()->GetSpecificInterface()->fn_vOnChangeDisplayMode(E_dm_DrawOnlyCurrentSector);
	m_oDisplayToolbar.SetButton(CPA_IDB_DISPLAYSECTOR);
}

/////////////////////////////////////////////////////////////////////////////
// Fog
void CPA_DialogBar::OnDisplayFog (void)
{
	GetInterface()->GetSpecificInterface()->fn_vChangeDisplayFog(TRUE);
	m_oDisplayToolbar.SetButton(CPA_IDB_DISPLAYFOG);
}
/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnDisplayNoFog (void)
{
	GetInterface()->GetSpecificInterface()->fn_vChangeDisplayFog(FALSE);
	m_oDisplayToolbar.SetButton(CPA_IDB_DISPLAYNOFOG);
}

/////////////////////////////////////////////////////////////////////////////
// DisplayCenter

void CPA_DialogBar::OnNoCenter (void)
{
	GetInterface()->SetShowcenter(0);
	GetInterface()->fn_vUpdateAll(E_mc_UpdateDialog);
}
/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnMainCenters (void)
{
	GetInterface()->SetShowcenter(2);
	GetInterface()->fn_vUpdateAll(E_mc_UpdateDialog);
}
/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnAllCenters (void)
{
	GetInterface()->SetShowcenter(1);
	GetInterface()->fn_vUpdateAll(E_mc_UpdateDialog);
}

/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::fn_vUpdateCenterMode  (int iNewMode)
{
	switch (iNewMode)
	{
		case 0:
			m_oDisplayToolbar.SetButton(IDCB_NORMAL);
			break;
		case 1:
			m_oDisplayToolbar.SetButton(IDCB_ALLCENTERS);
			break;
		case 2:
			m_oDisplayToolbar.SetButton(IDCB_MAINCENTERS);
			break;
	}
}

/////////////////////////////////////////////////////////////////////////////
// ConstraintMove

void CPA_DialogBar::OnNoConstraint (void)
{
	GetInterface()->SetConsX(0);
	GetInterface()->SetConsY(0);
	GetInterface()->SetConsZ(0);
	m_oDeviceToolbar.SetButton(IDCB_NOCONSTRAINT);
}
/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnConstraintX (void)
{
	GetInterface()->SetConsX(1);
	GetInterface()->SetConsY(0);
	GetInterface()->SetConsZ(0);
	m_oDeviceToolbar.SetButton(IDCB_CONSTRAINTX);
}
/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnConstraintY (void)
{
	GetInterface()->SetConsX(0);
	GetInterface()->SetConsY(1);
	GetInterface()->SetConsZ(0);
	m_oDeviceToolbar.SetButton(IDCB_CONSTRAINTY);
}
/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnConstraintZ (void)
{
	GetInterface()->SetConsX(0);
	GetInterface()->SetConsY(0);
	GetInterface()->SetConsZ(1);
	m_oDeviceToolbar.SetButton(IDCB_CONSTRAINTZ);
}
/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnConstraintXY (void)
{
	GetInterface()->SetConsX(1);
	GetInterface()->SetConsY(1);
	GetInterface()->SetConsZ(0);
	m_oDeviceToolbar.SetButton(IDCB_CONSTRAINTXY);
}
/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnConstraintXZ (void)
{
	GetInterface()->SetConsX(1);
	GetInterface()->SetConsY(0);
	GetInterface()->SetConsZ(1);
	m_oDeviceToolbar.SetButton(IDCB_CONSTRAINTXZ);
}
/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnConstraintYZ (void)
{
	GetInterface()->SetConsX(0);
	GetInterface()->SetConsY(1);
	GetInterface()->SetConsZ(1);
	m_oDeviceToolbar.SetButton(IDCB_CONSTRAINTYZ);
}

/////////////////////////////////////////////////////////////////////////////
// Contraint Toolbar
void CPA_DialogBar::fn_vUpdateConstraints( int iConstraintsMask )
{
	//compose the current mask
	int iFinalMask = 0;
	if ( GetInterface()->fn_bConsX() )
		iFinalMask = iFinalMask | CPA_MASK_CONSTRAINTX;
	if ( GetInterface()->fn_bConsY() )
		iFinalMask = iFinalMask | CPA_MASK_CONSTRAINTY;
	if ( GetInterface()->fn_bConsZ() )
		iFinalMask = iFinalMask | CPA_MASK_CONSTRAINTZ;
	//set the flags
	iFinalMask = iConstraintsMask ^ iFinalMask;
	GetInterface()->SetConsX(iFinalMask & CPA_MASK_CONSTRAINTX);
	GetInterface()->SetConsY(iFinalMask & CPA_MASK_CONSTRAINTY);
	GetInterface()->SetConsZ(iFinalMask & CPA_MASK_CONSTRAINTZ);
	//set the bitmap
	switch (iFinalMask )
	{
		case 1:
			m_oDeviceToolbar.SetButton(IDCB_CONSTRAINTX);
			break;
		case 2:
			m_oDeviceToolbar.SetButton(IDCB_CONSTRAINTY);
			break;
		case 3:
			m_oDeviceToolbar.SetButton(IDCB_CONSTRAINTXY);
			break;
		case 4:
			m_oDeviceToolbar.SetButton(IDCB_CONSTRAINTZ);
			break;
		case 5:
			m_oDeviceToolbar.SetButton(IDCB_CONSTRAINTXZ);
			break;
		case 6:
			m_oDeviceToolbar.SetButton(IDCB_CONSTRAINTYZ);
			break;
		case 0:
		case 7:
			//all flags are set ; this is senseless so reset them all
			GetInterface()->SetConsX(0);
			GetInterface()->SetConsY(0);
			GetInterface()->SetConsZ(0);
			m_oDeviceToolbar.SetButton(IDCB_NOCONSTRAINT);
	}
}

/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnTextured (void)
{
	GetInterface()->fn_vChangeWorldMask(GLI_C_lIsTextured, TRUE);
	GetInterface()->fn_vChangeWorldMask(GLI_C_lIsNotGrided, TRUE);
	GetInterface()->fn_vChangeWorldMask(GLI_C_lIsNotWired, TRUE);
}

/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnNoTex (void)
{
	GetInterface()->fn_vChangeWorldMask(GLI_C_lIsTextured, FALSE);
	GetInterface()->fn_vChangeWorldMask(GLI_C_lIsNotGrided, TRUE);
	GetInterface()->fn_vChangeWorldMask(GLI_C_lIsNotWired, TRUE);
}

/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnWired (void)
{
	GetInterface()->fn_vChangeWorldMask(GLI_C_lIsTextured, TRUE);
	GetInterface()->fn_vChangeWorldMask(GLI_C_lIsNotGrided, TRUE);
	GetInterface()->fn_vChangeWorldMask(GLI_C_lIsNotWired, FALSE);
}

/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnWiredNoTex (void)
{
	GetInterface()->fn_vChangeWorldMask(GLI_C_lIsTextured, FALSE);
	GetInterface()->fn_vChangeWorldMask(GLI_C_lIsNotGrided, TRUE);
	GetInterface()->fn_vChangeWorldMask(GLI_C_lIsNotWired, FALSE);
}

/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnGrided (void)
{
	GetInterface()->fn_vChangeWorldMask(GLI_C_lIsTextured, TRUE);
	GetInterface()->fn_vChangeWorldMask(GLI_C_lIsNotGrided, FALSE);
	GetInterface()->fn_vChangeWorldMask(GLI_C_lIsNotWired, TRUE);
}

/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnGridedNoTex (void)
{
	GetInterface()->fn_vChangeWorldMask(GLI_C_lIsTextured, FALSE);
	GetInterface()->fn_vChangeWorldMask(GLI_C_lIsNotGrided, FALSE);
	GetInterface()->fn_vChangeWorldMask(GLI_C_lIsNotWired, TRUE);
}
/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::fn_vUpdateAppearance (long lFlag)
{
	if (!(lFlag & GLI_C_lIsNotWired))
		m_oDisplayToolbar.SetButton((lFlag & GLI_C_lIsTextured) ? CPA_IDB_WIRED : CPA_IDB_WIREDNOTEX);

	else if (!(lFlag & GLI_C_lIsNotGrided))
		m_oDisplayToolbar.SetButton((lFlag & GLI_C_lIsTextured) ? CPA_IDB_GRIDED : CPA_IDB_GRIDEDNOTEX);
	else
		m_oDisplayToolbar.SetButton((lFlag & GLI_C_lIsTextured) ? CPA_IDB_TEXTURED : CPA_IDB_NOTEX);
}

/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnNoBV (void)
{
	GetInterface()->fn_vSetBVMode(E_bv_None);
}

/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnSectorBV (void)
{
	GetInterface()->fn_vSetBVMode(E_bv_Sectors);
}

/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnActorBV (void)
{
	GetInterface()->fn_vSetBVMode(E_bv_Actors);
}

/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnObjectBV (void)
{
	GetInterface()->fn_vSetBVMode(E_bv_Objects);
}

/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::fn_vUpdateBVMode (int iMode)
{
	switch ((tdeBVMode) iMode)
	{
		case E_bv_None:
			m_oDisplayToolbar.SetButton(CPA_IDB_NOBV);
			break;
		case E_bv_Sectors:
			m_oDisplayToolbar.SetButton(CPA_IDB_SECTORBV);
			break;
		case E_bv_Actors:
			m_oDisplayToolbar.SetButton(CPA_IDB_ACTORBV);
			break;
		case E_bv_Objects:
			m_oDisplayToolbar.SetButton(CPA_IDB_OBJECTBV);
			break;
	}
}


/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::fn_vUpdateAxisMode (int iDisplayMode)
{
	tdeDisplayReferential eDisplayMode = (tdeDisplayReferential)iDisplayMode;
	switch( eDisplayMode )
	{
	case DisplayNone:
		m_oDisplayToolbar.SetButton(CPA_IDB_NOAXIS);
		break;
	case DisplayDownLeft:
		m_oDisplayToolbar.SetButton(CPA_IDB_AXISDOWNLEFT);
		break;
	case DisplayDownRight:
		m_oDisplayToolbar.SetButton(CPA_IDB_AXISDOWNRIGHT);
		break;
	}
}

/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnDisplayNoAxis(void)
{
	CPA_CameraDLLBase *p_oCameraInterface = ((DEV_ViewPort3D *) GetParentMultiDevice()->GetFocusDevice()->GetViewPort())->GetCameraInterface();

	p_oCameraInterface -> SetReferentialDisplayMode( DisplayNone );
}

/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnDisplayAxisDownLeft(void)
{
	CPA_CameraDLLBase *p_oCameraInterface = ((DEV_ViewPort3D *) GetParentMultiDevice()->GetFocusDevice()->GetViewPort())->GetCameraInterface();

	p_oCameraInterface -> SetReferentialDisplayMode( DisplayDownLeft );
}

/////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnDisplayAxisDownRight(void)
{
	CPA_CameraDLLBase *p_oCameraInterface = ((DEV_ViewPort3D *) GetParentMultiDevice()->GetFocusDevice()->GetViewPort())->GetCameraInterface();

	p_oCameraInterface -> SetReferentialDisplayMode( DisplayDownRight );
}

///////////////////////////////////////////////////////////////////////////////
// Begin Silviu Simen 13 August 1998 Button for StatusBar
void CPA_DialogBar::OnStatusBarMode (void)
{
	CButton *pBut = (CButton *) GetDlgItem(CPA_IDCB_STATUSBARMODE);
	tdeStatusBar iStatusMode;
	iStatusMode = GetInterface()->GetStatusBarMode();
	switch (iStatusMode )
	{
		case E_sb_CameraInfo:
			pBut->SetIcon(m_hInsInfIcon);
			GetInterface()->SetStatusBarMode(E_sb_InstanceInfo);
			break;
		case E_sb_InstanceInfo:
			pBut->SetIcon(m_hInsCamIcon);
			GetInterface()->SetStatusBarMode(E_sb_InstanceToCamera);
			break;
		case E_sb_InstanceToCamera:
			pBut->SetIcon(m_hCamInfIcon);
			GetInterface()->SetStatusBarMode(E_sb_CameraInfo);
			break;
	}
	((DEV_ViewPort3D *)GetInterface()->GetMultiDevice()->
		GetFocusDevice()->GetViewPort())->fn_vUpdateStatusBarMessage();
}

///////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::fn_vUpdateStatusBarMode (int iStatusMode) {
	CButton *pBut = (CButton *) GetDlgItem(CPA_IDCB_STATUSBARMODE);
	switch (iStatusMode )
	{
		case E_sb_CameraInfo:
			pBut->SetIcon(m_hCamInfIcon);
			break;
		case E_sb_InstanceInfo:
			pBut->SetIcon(m_hInsInfIcon);
			break;
		case E_sb_InstanceToCamera:
			pBut->SetIcon(m_hInsCamIcon);
			break;
	}
}
// End Silviu Simen 13 August 1998 Button for StatusBar
///////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////
// CPA_DialogBar message handlers

BOOL CPA_DialogBar::OnToolTipNotify(UINT id, NMHDR *pNMHDR, LRESULT *pResult)
{
    TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
    UINT nID =pNMHDR->idFrom;

	// if it is an ID from the camera toolbar
	if (nID >= 40000 && nID <= 40050)
		return (((CPA_CameraDLLBase*) m_p_oCamera->GetEditor())->OnToolTipNotify(m_p_oCamera,pTTT,nID));
	else
	{
		if (m_oDisplayToolbar.GetToolTipText(pTTT,nID))
			return TRUE;
		if (m_oDeviceToolbar.GetToolTipText(pTTT,nID))
			return TRUE;
	}
	return FALSE;
}

/////////////////////////////////////////////////////////////////////////////
BOOL CPA_DialogBar::PreTranslateMessage(MSG* pMsg) 
{
    if (m_hWnd)
    {
        m_ToolTip.RelayEvent (pMsg);
        return CDialogBar::PreTranslateMessage(pMsg);
    }
    return (FALSE);
}



///////////////////////////////////////////////////////////////////////////////
// Begin Silviu Simen Select by sector
///////////////////////////////////////////////////////////////////////////////
void CPA_DialogBar::OnSelectBySector (void)
{
	GetInterface()->SelectBySector();
}
///////////////////////////////////////////////////////////////////////////////
// End Silviu Simen Select by sector
/////////////////////////////////////////////////////////////////////////////

#endif // ACTIVE_EDITOR
