reman3/Rayman_X/cpa/Appli/MngData5/Src/DlgModif.cpp

401 lines
11 KiB
C++

/*
=======================================================================================
Name :DlgModif.cpp
Author :vincent lhullier Date :24/07/97
Description :implementation file for dialog box that will contain list of modification
=======================================================================================
Modification -> Author : Date :
Description :
=======================================================================================
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "stdafx.h"
#include "DlgModif.h"
#include "HelpId.h"
#include "constant.h"
#include "majdata.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
=======================================================================================
CModifListDialog dialog
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
constructor
----------------------------------------------------------------------------------------
*/
CModifListDialog::CModifListDialog(CWnd* pParent /*=NULL*/) : CDialog(CModifListDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CModifListDialog)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
/*
----------------------------------------------------------------------------------------
message map
----------------------------------------------------------------------------------------
*/
BEGIN_MESSAGE_MAP(CModifListDialog, CDialog)
//{{AFX_MSG_MAP(CModifListDialog)
ON_BN_CLICKED(IDC_BUTTON_HELP, OnButtonHelp)
ON_WM_SIZE()
ON_WM_SIZING()
ON_WM_DESTROY()
ON_BN_CLICKED(IDC_CHECK_ALL, OnCheckAll)
ON_WM_HELPINFO()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/*
=======================================================================================
CModifListDialog specific functions
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : display modif in list box
_bAll -> if true display all modif (i.e. modif of first level + child modif)
----------------------------------------------------------------------------------------
*/
void CModifListDialog::m_fn_vFillModifList(BOOL _bAll)
{
CListBox *p_oLB = (CListBox *) GetDlgItem( IDC_LIST_MODIF );
tdstModif *p_stModif = g_p_stFirstModif;
char szString[SCR_CV_ui_Cfg_MaxLenLine];
p_oLB->ResetContent();
while( p_stModif != NULL )
{
if ( _bAll || (p_stModif->p_stFather == NULL) )
{
sprintf
(
szString,
"%s%s (%s)",
p_stModif->p_stFather == NULL ? "" : " ",
p_stModif->szName,
g_a_szModifName[ p_stModif->cType ]
);
p_oLB->AddString( szString );
}
p_stModif = p_stModif->p_stNext;
}
}
/*
=======================================================================================
CModifListDialog message handlers
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
WM_INITDIALOG
----------------------------------------------------------------------------------------
*/
BOOL CModifListDialog::OnInitDialog()
{
CDialog::OnInitDialog();
((CButton *) GetDlgItem( IDC_CHECK_ALL))->SetCheck( 0 );
m_fn_vFillModifList( FALSE );
MoveWindow( &g_stWinPref.stModifPos );
return TRUE;
}
/*
----------------------------------------------------------------------------------------
BN_CLICKED on IDC_BUTTON_HELP
----------------------------------------------------------------------------------------
*/
void CModifListDialog::OnButtonHelp()
{
::WinHelp(this->GetSafeHwnd(), C_szHelpFile, HELP_CONTEXT, IDH_J_VIEWMODIF );
}
/*
----------------------------------------------------------------------------------------
WM_SIZING
----------------------------------------------------------------------------------------
*/
void CModifListDialog::OnSizing( UINT nSide, LPRECT lpRect )
{
long lWidth = lpRect->right - lpRect->left + 1;
long lHeight= lpRect->bottom - lpRect->top + 1;
if (lWidth < C_iModifMinWidth)
{
switch (nSide)
{
case WMSZ_BOTTOMLEFT:
case WMSZ_LEFT:
case WMSZ_TOPLEFT:
lpRect->left = lpRect->right - C_iModifMinWidth;
break;
case WMSZ_BOTTOMRIGHT:
case WMSZ_RIGHT:
case WMSZ_TOPRIGHT:
lpRect->right = lpRect->left + C_iModifMinWidth;
break;
}
}
if (lHeight < C_iModifMinHeight)
{
switch (nSide)
{
case WMSZ_BOTTOM:
case WMSZ_BOTTOMLEFT:
case WMSZ_BOTTOMRIGHT:
lpRect->bottom = lpRect->top + C_iModifMinHeight;
break;
case WMSZ_TOP:
case WMSZ_TOPLEFT:
case WMSZ_TOPRIGHT:
lpRect->top = lpRect->bottom - C_iModifMinHeight;
}
}
CDialog::OnSizing( nSide, lpRect );
}
/*
----------------------------------------------------------------------------------------
WM_SIZE
----------------------------------------------------------------------------------------
*/
void CModifListDialog::OnSize(UINT nType, int cx, int cy)
{
RECT stRect;
CDialog::OnSize(nType, cx, cy);
if ( (nType != SIZE_MINIMIZED) && (GetDlgItem( IDC_LIST_MODIF ) != NULL) )
{
/*
* resizing List box
*/
stRect.top = 5;
stRect.bottom = cy - 30;
stRect.left = 5;
stRect.right = cx - 10;
GetDlgItem( IDC_LIST_MODIF )->MoveWindow( &stRect, FALSE );
/*
* moving Close button
*/
stRect.bottom = cy - 5;
stRect.top = stRect.bottom - 20;
stRect.left = cx / 2 - 45;
stRect.right = stRect.left + 40;
GetDlgItem( IDCANCEL )->MoveWindow( &stRect, FALSE );
/*
* moving help button
*/
stRect.left += 50;
stRect.right += 50;
GetDlgItem( IDC_BUTTON_HELP )->MoveWindow( &stRect, FALSE );
/*
* moving all check button
*/
stRect.left = 5;
stRect.right = 50;
GetDlgItem( IDC_CHECK_ALL )->MoveWindow( &stRect, FALSE );
Invalidate();
}
}
/*
----------------------------------------------------------------------------------------
Description : WM_DESTROY
----------------------------------------------------------------------------------------
*/
void CModifListDialog::OnDestroy()
{
CDialog::OnDestroy();
GetWindowRect( &g_stWinPref.stModifPos );
}
/*
----------------------------------------------------------------------------------------
Description : BN_CLICKED on IDC_CHECK_ALL
----------------------------------------------------------------------------------------
*/
void CModifListDialog::OnCheckAll()
{
BOOL bAll;
bAll = ((CButton *) GetDlgItem( IDC_CHECK_ALL ))->GetCheck() == 1;
m_fn_vFillModifList( bAll );
}
/*
----------------------------------------------------------------------------------------
Description : WM_HELPINFO
----------------------------------------------------------------------------------------
*/
BOOL CModifListDialog::OnHelpInfo(HELPINFO* pHelpInfo)
{
::WinHelp(this->GetSafeHwnd(), C_szHelpFile, HELP_CONTEXT, IDH_J_VIEWMODIF );
return TRUE;
}
/*
=======================================================================================
CModifListErrorDlg dialog
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
constructor
----------------------------------------------------------------------------------------
*/
CModifListErrorDlg::CModifListErrorDlg(long _lNbErrors, char **_d_szError, CWnd* pParent ) : CDialog(CModifListErrorDlg::IDD, pParent)
{
m_lNumberOfErrors = _lNbErrors;
m_pp_szError = _d_szError;
//{{AFX_DATA_INIT(CModifListErrorDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
/*
----------------------------------------------------------------------------------------
Message map
----------------------------------------------------------------------------------------
*/
BEGIN_MESSAGE_MAP(CModifListErrorDlg, CDialog)
//{{AFX_MSG_MAP(CModifListErrorDlg)
ON_WM_SIZE()
ON_WM_SIZING()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/*
=======================================================================================
CModifListErrorDlg message handlers
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
WM_INITDIALOG
----------------------------------------------------------------------------------------
*/
BOOL CModifListErrorDlg::OnInitDialog()
{
CListBox *p_oLB = ((CListBox *) GetDlgItem( IDC_LIST_ERRORS ));
long lError;
char szTitle[100];
CDialog::OnInitDialog();
p_oLB->ResetContent();
for (lError = 0; lError < m_lNumberOfErrors; lError++)
{
p_oLB->AddString( m_pp_szError[ lError ] );
}
sprintf( szTitle, "I detect %d errors in list of modifications", m_lNumberOfErrors );
GetDlgItem( IDC_STATIC_TITLE )->SetWindowText( szTitle );
RECT stRect;
GetWindowRect( &stRect );
stRect.left += 1;
MoveWindow( &stRect );
SetWindowPos( &wndTopMost, 0,0,0,0, SWP_NOSIZE | SWP_NOMOVE );
return TRUE;
}
/*
----------------------------------------------------------------------------------------
WM_SIZE
----------------------------------------------------------------------------------------
*/
void CModifListErrorDlg::OnSize(UINT nType, int cx, int cy)
{
if (GetDlgItem( IDC_STATIC_TITLE) != NULL)
{
GetDlgItem( IDC_STATIC_TITLE )->SetWindowPos( NULL, 5, 5, cx - 10, 16, SWP_NOZORDER );
GetDlgItem( IDC_LIST_ERRORS )->SetWindowPos( NULL, 5, 25, cx - 10, cy - 55, SWP_NOZORDER );
GetDlgItem( IDOK )->SetWindowPos( NULL, cx - 80, cy - 25, 0, 0, SWP_NOZORDER | SWP_NOSIZE );
}
CDialog::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
}
/*
----------------------------------------------------------------------------------------
WM_SIZING
----------------------------------------------------------------------------------------
*/
void CModifListErrorDlg::OnSizing(UINT nSide, LPRECT lpRect)
{
long lWidth = lpRect->right - lpRect->left + 1;
long lHeight= lpRect->bottom - lpRect->top + 1;
if (lWidth < 200)
{
switch (nSide)
{
case WMSZ_BOTTOMLEFT:
case WMSZ_LEFT:
case WMSZ_TOPLEFT:
lpRect->left = lpRect->right - 200;
break;
case WMSZ_BOTTOMRIGHT:
case WMSZ_RIGHT:
case WMSZ_TOPRIGHT:
lpRect->right = lpRect->left + 200;
break;
}
}
if (lHeight < 200)
{
switch (nSide)
{
case WMSZ_BOTTOM:
case WMSZ_BOTTOMLEFT:
case WMSZ_BOTTOMRIGHT:
lpRect->bottom = lpRect->top + 200;
break;
case WMSZ_TOP:
case WMSZ_TOPLEFT:
case WMSZ_TOPRIGHT:
lpRect->top = lpRect->bottom - 200;
}
}
CDialog::OnSizing(nSide, lpRect);
}