reman3/Rayman_X/cpa/tempgrp/OSC/Src/SECdSrfs.cpp

504 lines
14 KiB
C++

/*=========================================================================
*
* SEClEnvs.cpp : Environment List Sector Dialog - Implementation file
*
*
* Version 1.0
* Creation date
* Revision date
*
* Shaitan
*=======================================================================*/
/*
#include "stdafx.h"
#include "acp_base.h"
#include "SECTint.hpp"
#include "SECdSrfs.hpp"
#include "SECmodif.hpp"
#include "SECdEnv.hpp"
#include "SEClEnvs.hpp"
#include "..\Main\Inc\_EditID.h"
#include "TUT.h"
SECT_Surface *g_pClickedSrf;
*/
//#################################################################################
// SECT_DialogEnvElem dialog
//#################################################################################
/*----------------------------------------
----------------------------------------*/
/*
SECT_DialogSrf::SECT_DialogSrf(CWnd* pParent)
: CFormView(SECT_DialogSrf::IDD)
{
//{{AFX_DATA_INIT(SECT_DialogEnvElem)
//}}AFX_DATA_INIT
}
*/
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogSrf::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(SECT_DialogSrf)
// surf elem
DDX_Control(pDX, SECT_IDC_SURFLISTBOX, m_cSurfListBox);
DDX_Control(pDX, SECT_IDC_VIEWSURF, m_cViewSurf);
DDX_Control(pDX, SECT_IDC_SURFHEIGHT, m_cSurfHeight);
// control
DDX_Control(pDX, SECT_IDC_SRFDEFAULT, m_cDefault);
//}}AFX_DATA_MAP
}
*/
/*----------------------------------------
----------------------------------------*/
/*
BEGIN_MESSAGE_MAP(SECT_DialogSrf, CFormView)
//{{AFX_MSG_MAP(SECT_DialogSrf)
ON_WM_SIZE()
ON_WM_DESTROY()
// surf elem
ON_NOTIFY(LVN_ITEMCHANGED, SECT_IDC_SURFLISTBOX, OnSelChangeSurfListBox)
ON_NOTIFY(NM_DBLCLK, SECT_IDC_SURFLISTBOX, OnDblClkSurfListBox)
ON_EN_KILLFOCUS(SECT_IDC_SURFHEIGHT, OnChangeHeight)
ON_BN_CLICKED(SECT_IDC_VIEWSURF, OnViewSurf)
// default
ON_BN_CLICKED(SECT_IDC_SRFDEFAULT, OnDefault)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
*/
//#################################################################################
// SECT_DialogSrf Inits
//#################################################################################
/*===========================================================================
* Description: Init dialog
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
/*
void SECT_DialogSrf::fn_vInitDialog (Sector_Interface *p_oDLL, CWnd *pParent)
{
// create the dialog
m_bInitialised = FALSE;
m_pSectorInterface = p_oDLL;
CFormView::Create(NULL, "", AFX_WS_DEFAULT_VIEW, CRect(0,0,120,180), pParent, AFX_IDW_PANE_FIRST, NULL);
// init data for dialog
CFormView::UpdateData(FALSE);
// FOR TUTORIAL
TUT_M_vGetTutDll();
TUT_M_vRegisterControl(m_cSurfListBox.m_hWnd, "OSC_DSRF_LIST_SURFACES", TUT_e_ListBox);
TUT_M_vRegisterControl(m_cViewSurf.m_hWnd, "OSC_DSRF_BUTTON_VIEW", TUT_e_Button);
TUT_M_vRegisterControl(m_cSurfHeight.m_hWnd, "OSC_DSRF_EDIT_HEIGHT", TUT_e_TextEdit);
TUT_M_vRegisterControl(m_cDefault.m_hWnd, "OSC_DSRF_BUTTON_DEFAULT", TUT_e_Button);
// END TUTORIAL
// init all controls
m_bViewSurface = FALSE;
m_cViewSurf.SetCheck(0);
fn_vInitEnvElem(-1);
m_bInitialised = TRUE;
// init listbox
m_cSurfListBox.fn_vInitParameters(this, m_pSectorInterface, E_te_Surface);
}
*/
/*===========================================================================
* Description: Reinit dialog
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
/*
void SECT_DialogSrf::fn_vReinitDialog (void)
{
fn_vInitSurfListBox();
}
*/
/*===========================================================================
* Description: Init controls state
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
/*
void SECT_DialogSrf::fn_vInitControls (BOOL bEnable)
{
m_cSurfListBox.EnableWindow(bEnable);
m_cViewSurf.EnableWindow(bEnable);
m_cSurfHeight.EnableWindow((m_pSurface != NULL)&&bEnable);
}
*/
/*===========================================================================
* Description: reinit environment list
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
/*
void SECT_DialogSrf::fn_vInitEnvElem (long lEnvElem)
{
Sector_Object *pSector;
// find corresponding element
if (lEnvElem != -1)
pSector = (Sector_Object *) m_pSectorInterface->GetEditedSector()->GetObject();
else
pSector = NULL;
// update edited element
m_lEnvElem = lEnvElem;
m_pSurfElem = (pSector) ? pSector->GetSurface(m_lEnvElem) : NULL;
// update infos
fn_vSelectSurf((m_pSurfElem) ? m_pSurfElem->GetSurface() : m_pSectorInterface->GetSurfaceToDraw());
m_cSurfListBox.fn_vReinitListObjects();
}
*/
/*===========================================================================
* Description: Init combo with all available surfaces
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
/*
void SECT_DialogSrf::fn_vInitSurfListBox (void)
{
// set list style
m_cSurfListBox.SetOrder(E_lo_Edited, FALSE, FALSE);
m_cSurfListBox.SetDragDropRight(FALSE);
// reinit list
m_cSurfListBox.SetSortedList(m_pSectorInterface->GetBaseObjectList(C_szSurfaceTypeName));
// current selection => none
m_cSurfListBox.SetSelectedItem(-1);
}
*/
/*===========================================================================
* Description: update dialog when selection changes
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
/*
void SECT_DialogSrf::fn_vSelectSurf (SECT_Surface *pSurface, BOOL bUpdateSurfElem)
{
SECT_Surface *pOldSelect, *pOldCurrent;
SECT_ModifSurfElem *pModif;
CString csText;
int iInd;
// update current environment
pOldSelect = m_pSurface;
m_pSurface = pSurface;
// update selection
iInd = m_cSurfListBox.GetCorrespondingIndex((DWORD) m_pSurface);
m_cSurfListBox.RedrawItems(iInd, iInd);
// update env list
if ((bUpdateSurfElem)&&(m_pSurfElem))
{
pOldCurrent = m_pSurfElem->GetSurface();
if ((m_pSurface)&&(!m_cSurfListBox.fn_bIsAlreadyUsed(m_pSurface)))
{
// update sector lists
pModif = new SECT_ModifSurfElem(m_pSectorInterface, E_mt_ChangeSrf,
m_pSurfElem, m_pSurface, m_lEnvElem);
m_pSectorInterface->M_GetEditManager()->AskFor(pModif);
}
}
// update height control
m_cSurfHeight.EnableWindow((m_pSurface != NULL));
if (m_pSurface)
csText.Format("%5.2f", m_pSurface->GetHeight());
else
csText = "";
m_cSurfHeight.SetWindowText(csText);
// redraw previous element
if (pOldSelect != m_pSurface)
{
iInd = m_cSurfListBox.GetCorrespondingIndex((DWORD) pOldSelect);
m_cSurfListBox.RedrawItems(iInd, iInd);
}
// redraw previous element
if ((pOldCurrent)&&(pOldCurrent != pOldSelect))
{
iInd = m_cSurfListBox.GetCorrespondingIndex((DWORD) pOldCurrent);
m_cSurfListBox.RedrawItems(iInd, iInd);
}
// update selection
iInd = m_cSurfListBox.GetCorrespondingIndex((DWORD) m_pSurface);
m_cSurfListBox.RedrawItems(iInd, iInd);
m_cSurfListBox.EnsureVisible(iInd, TRUE);
m_cSurfListBox.UpdateWindow();
// update drawing
if (m_bViewSurface)
m_pSectorInterface->SetSurfaceToDraw(m_pSurface);
}
*/
//#################################################################################
// SECT_DialogEdit Messages
//#################################################################################
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogSrf::OnSize (UINT nFlags, int cx, int cy)
{
RECT WindowPosition;
int ecx, ecy;
if (!m_bInitialised)
return;
// calculate name position
GetWindowRect(&WindowPosition);
ecx = WindowPosition.right - WindowPosition.left - 10;
ecx = (ecx < 50) ? 50 : ecx;
ecy = WindowPosition.bottom - WindowPosition.top - 10;
ecy = (ecy < 100) ? 100 : ecy;
// mechanic
GetDlgItem(SECT_IDC_TEXTSURFELEM)->MoveWindow(5, 5, ecx, ecy);
m_cSurfListBox.MoveWindow(10, 25, ecx-10, ecy-50);
m_cViewSurf.MoveWindow(ecx-35, ecy-20, 30, 18);
m_cSurfHeight.MoveWindow(15, ecy-20, ecx-50, 18);
}
*/
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogSrf::OnDestroy (void)
{
// FOR TUTORIAL
TUT_M_vGetTutDll();
TUT_M_vUnregisterControl(m_cSurfListBox.m_hWnd);
TUT_M_vUnregisterControl(m_cViewSurf.m_hWnd);
TUT_M_vUnregisterControl(m_cSurfHeight.m_hWnd);
TUT_M_vUnregisterControl(m_cDefault.m_hWnd);
// END TUTORIAL
CFormView::OnDestroy();
}
*/
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogSrf::OnSelChangeSurfListBox(NMHDR* pNMHDR, LRESULT* pResult)
{
SECT_Surface *pSurf = NULL;
LPNM_LISTVIEW pNMListView = (LPNM_LISTVIEW)pNMHDR;
BOOL bOldSelect, bNewSelect;
int iIndex;
// update param
*pResult = 0;
if ((pNMListView->uChanged != LVIF_STATE)||(m_cSurfListBox.fn_bIsSelecting()))
return;
bOldSelect = (pNMListView->uOldState & LVIS_SELECTED);
bNewSelect = (pNMListView->uNewState & LVIS_SELECTED);
// get corresponding sector
iIndex = pNMListView->iItem;
pSurf = (SECT_Surface *) m_cSurfListBox.GetItemData(iIndex);
g_pClickedSrf = pSurf;
m_cSurfListBox.SetSelectedItem(-1);
if (bOldSelect != bNewSelect)
{
// select corresponding environment
if ((!pSurf)||(!pSurf->fn_bIsAvailable()))
fn_vSelectSurf((m_pSurfElem) ? m_pSurfElem->GetSurface() : NULL, FALSE);
else
fn_vSelectSurf((pSurf != m_pSurface) ? pSurf : NULL, FALSE);
}
}
*/
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogSrf::OnDblClkSurfListBox(NMHDR* pNMHDR, LRESULT* pResult)
{
SECT_Surface *pSurf = NULL;
// update param
*pResult = 0;
// get corresponding sector
pSurf = g_pClickedSrf;
g_pClickedSrf = NULL;
// select corresponding environment
if ((!pSurf)||(!pSurf->fn_bIsAvailable()))
fn_vSelectSurf((m_pSurfElem) ? m_pSurfElem->GetSurface() : NULL);
else
fn_vSelectSurf(pSurf);
}
*/
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogSrf::OnViewSurf()
{
// update draw flag
m_bViewSurface = m_cViewSurf.GetCheck();
// update drawing
m_pSectorInterface->SetSurfaceToDraw((m_bViewSurface) ? m_pSurface : NULL);
}
*/
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogSrf::OnChangeHeight()
{
SECT_ModifSrfParams *pModif;
MTH_tdxReal xHeight;
char szVal[15];
// no surface => no modif
if ((!m_pSurface)||(!m_cSurfHeight.GetModify()))
return;
// get new height
m_cSurfHeight.GetWindowText(szVal, 15);
xHeight = (float) atof(szVal);
// if necessary, update height
if (m_pSurface->GetHeight() != xHeight)
{
// update surface
pModif = new SECT_ModifSrfParams(m_pSectorInterface, E_mt_ChangeSrfHeight, m_pSurface, xHeight);
m_pSectorInterface->M_GetEditManager()->AskFor(pModif);
// update drawing
m_cSurfListBox.fn_vReinitListObjects();
if (m_bViewSurface)
m_pSectorInterface->GetInterface()->fn_vUpdateAll(E_mc_JustDraw);
}
// update flag
m_cSurfHeight.SetModify(FALSE);
}
*/
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogSrf::OnDefault()
{
if (m_cSurfHeight.GetModify())
{
OnChangeHeight();
m_cSurfHeight.SetFocus();
}
}
*/
//#################################################################################
// SECT_SrfElemListBox
//#################################################################################
/*----------------------------------------
----------------------------------------*/
/*
SECT_SrfElemListBox::SECT_SrfElemListBox (void)
{
}
*/
/*----------------------------------------
----------------------------------------*/
/*
SECT_SrfElemListBox::~SECT_SrfElemListBox (void)
{
}
*/
/*----------------------------------------
----------------------------------------*/
/*
BOOL SECT_SrfElemListBox::fn_bIsCurrentElement (CPA_BaseObject *pElem)
{
SECT_SurfElem *pSurfElem;
// no dialog => no current element
if (!m_pDialog)
return FALSE;
// init parameters
pSurfElem = ((SECT_DialogSrf *) m_pDialog)->GetCurrentSurfElem();
return ((pSurfElem)&&(pElem == pSurfElem->GetSurface()));
}
*/
/*----------------------------------------
----------------------------------------*/
/*
BOOL SECT_SrfElemListBox::fn_bIsSelectedElement (CPA_BaseObject *pElem)
{
// no dialog => no selected element
if (!m_pDialog)
return FALSE;
return (pElem == ((SECT_DialogSrf *) m_pDialog)->GetSelectedSurface());
}
*/
/*----------------------------------------
----------------------------------------*/
/*
BOOL SECT_SrfElemListBox::fn_bIsAlreadyUsed (CPA_BaseObject *pElem)
{
Sector_Object *pSector;
// no edited sector => no used element
if (!m_pSectorInterface->GetEditedSector())
return FALSE;
pSector = (Sector_Object *) m_pSectorInterface->GetEditedSector()->GetObject();
return (pSector->GetSurfaceList()->GetElementWithSurface((SECT_Surface *)pElem) != NULL);
}
*/