1415 lines
40 KiB
C++
1415 lines
40 KiB
C++
/*
|
|
=======================================================================================
|
|
Name : DlgFile.cpp
|
|
|
|
Author : vincent lhullier Date :24/07/97
|
|
|
|
Description : implementation file for file configuration dialog box
|
|
=======================================================================================
|
|
Modification -> Author : Date :
|
|
Description :
|
|
=======================================================================================
|
|
*/
|
|
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
#include "stdafx.h"
|
|
#include "DlgFile.h"
|
|
#include "DlgNwCfg.h"
|
|
#include "HelpId.h"
|
|
#include "Constant.h"
|
|
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
/*
|
|
=======================================================================================
|
|
Constants And Globals
|
|
=======================================================================================
|
|
*/
|
|
|
|
/*
|
|
* menu string
|
|
*/
|
|
char *g_a_szMenuItem[] =
|
|
{
|
|
"Get",
|
|
"Get recursively",
|
|
"Not gotten",
|
|
"Recursive",
|
|
"Not recursive"
|
|
};
|
|
|
|
/*
|
|
* static control
|
|
*/
|
|
#define C_cNbLegend 15
|
|
static UINT s_a_uiLegend[C_cNbLegend] =
|
|
{
|
|
IDC_TAB_LEGEND,
|
|
IDC_BUTTON_LEGEND0,
|
|
IDC_BUTTON_LEGEND4,
|
|
IDC_STATIC_LEGENDTEXT0,
|
|
IDC_BUTTON_LEGEND1,
|
|
IDC_BUTTON_LEGEND5,
|
|
IDC_STATIC_LEGENDTEXT1,
|
|
IDC_BUTTON_LEGEND2,
|
|
IDC_STATIC_LEGENDTEXT2,
|
|
IDC_BUTTON_LEGEND3,
|
|
IDC_BUTTON_LEGEND6,
|
|
IDC_STATIC_LEGENDTEXT3,
|
|
IDC_BUTTON_LEGEND7,
|
|
IDC_STATIC_LEGENDTEXT4,
|
|
IDC_STATIC_KEYS
|
|
};
|
|
|
|
/*
|
|
* button control
|
|
*/
|
|
#define C_cNbBottom 7
|
|
static UINT s_a_uiBottom[C_cNbBottom] =
|
|
{
|
|
IDC_CHECK_OBTAIN,
|
|
IDC_CHECK_RECURSE,
|
|
IDC_BUTTON_OBTAINALL,
|
|
IDC_BUTTON_OBTAINNOTHING,
|
|
IDC_STATIC_PICTURE,
|
|
IDCANCEL,
|
|
IDOK
|
|
};
|
|
|
|
|
|
/*
|
|
=======================================================================================
|
|
CDialogFileList dialog
|
|
=======================================================================================
|
|
*/
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
Description : constructor
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
CDialogFileList::CDialogFileList(CWnd* pParent /*=NULL*/) : CDialog(CDialogFileList::IDD, pParent)
|
|
{
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
int iImage;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
//{{AFX_DATA_INIT(CDialogFileList)
|
|
// NOTE: the ClassWizard will add member initialization here
|
|
//}}AFX_DATA_INIT
|
|
|
|
/* load icon */
|
|
m_a_hIcon[0] = AfxGetApp()->LoadIcon( IDI_ICON_NOTOBTAIN );
|
|
m_a_hIcon[1] = AfxGetApp()->LoadIcon( IDI_ICON_OBTAIN );
|
|
m_a_hIcon[2] = AfxGetApp()->LoadIcon( IDI_ICON_OBTAINRECURSE );
|
|
m_a_hIcon[3] = AfxGetApp()->LoadIcon( IDI_ICON_OBTAINCAUSERECURSE );
|
|
m_a_hIcon[4] = AfxGetApp()->LoadIcon( IDI_ICON_FILENOTOBTAIN );
|
|
m_a_hIcon[5] = AfxGetApp()->LoadIcon( IDI_ICON_FILEOBTAIN );
|
|
m_a_hIcon[6] = AfxGetApp()->LoadIcon( IDI_ICON_FILEOBTAINCAUSERECURSE );
|
|
m_a_hIcon[7] = AfxGetApp()->LoadIcon( IDI_ICON_FILEOBTAINCAUSEPROJOBTAINED );
|
|
|
|
/* initialize and fill image list */
|
|
m_oImageList.Create( 16, 16, TRUE, 8, 5 );
|
|
for (iImage = 0; iImage < 8; iImage ++)
|
|
m_oImageList.Add( m_a_hIcon[ iImage ] );
|
|
|
|
m_hIconKey = AfxGetApp()->LoadIcon( IDI_ICON_KEY );
|
|
|
|
m_oLegendImageList.Create( 16, 16, TRUE, 2, 5 );
|
|
m_oLegendImageList.Add( m_a_hIcon[ 0 ] );
|
|
m_oLegendImageList.Add( m_hIconKey );
|
|
|
|
m_p_stProjectTree = NULL;
|
|
m_p_stConfig = NULL;
|
|
}
|
|
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
Description : destructor
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
CDialogFileList::~CDialogFileList()
|
|
{
|
|
m_oImageList.DeleteImageList();
|
|
m_oLegendImageList.DeleteImageList();
|
|
}
|
|
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
Description : set config type
|
|
_cConfigType -> config type
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
void CDialogFileList::m_fn_vSetConfigType( char _cConfigType )
|
|
{
|
|
switch( m_cConfigType = _cConfigType )
|
|
{
|
|
case C_ConfigType_cObtain:
|
|
m_p_stProjectTree = g_p_stVssRootProject;
|
|
m_p_stConfig = &g_stIniData.stObtainConfig;
|
|
m_szRootProject = g_stIniData.szVssPath;
|
|
break;
|
|
case C_ConfigType_cUpdate:
|
|
m_p_stProjectTree = g_p_stLocalRootProject;
|
|
m_p_stConfig = &g_stIniData.stUpdateConfig;
|
|
m_szRootProject = g_stIniData.szLocalPath;
|
|
break;
|
|
default:
|
|
m_p_stProjectTree = NULL;
|
|
m_p_stConfig = NULL;
|
|
m_szRootProject = NULL;
|
|
}
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
Description : Message map
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
BEGIN_MESSAGE_MAP(CDialogFileList, CDialog)
|
|
//{{AFX_MSG_MAP(CDialogFileList)
|
|
ON_NOTIFY(TVN_SELCHANGED, IDC_TREE_VSS, OnSelchangedTreeVss)
|
|
ON_BN_CLICKED(IDC_CHECK_OBTAIN, OnCheckObtain)
|
|
ON_BN_CLICKED(IDC_CHECK_RECURSE, OnCheckRecurse)
|
|
ON_BN_CLICKED(IDC_BUTTON_OBTAINALL, OnButtonObtainall)
|
|
ON_BN_CLICKED(IDC_BUTTON_OBTAINNOTHING, OnButtonObtainnothing)
|
|
ON_BN_CLICKED(IDC_BUTTON_HELP, OnButtonHelp)
|
|
ON_WM_SIZE()
|
|
ON_WM_SIZING()
|
|
ON_WM_DESTROY()
|
|
ON_WM_MEASUREITEM()
|
|
ON_WM_DRAWITEM()
|
|
ON_BN_CLICKED(IDC_BUTTON_LEGEND0, OnButtonLegend0)
|
|
ON_BN_CLICKED(IDC_BUTTON_LEGEND1, OnButtonLegend1)
|
|
ON_BN_CLICKED(IDC_BUTTON_LEGEND2, OnButtonLegend2)
|
|
ON_BN_CLICKED(IDC_BUTTON_LEGEND3, OnButtonLegend3)
|
|
ON_BN_CLICKED(IDC_BUTTON_LEGEND4, OnButtonLegend4)
|
|
ON_BN_CLICKED(IDC_BUTTON_LEGEND5, OnButtonLegend5)
|
|
ON_BN_CLICKED(IDC_BUTTON_LEGEND6, OnButtonLegend6)
|
|
ON_BN_CLICKED(IDC_BUTTON_LEGEND7, OnButtonLegend7)
|
|
ON_WM_HELPINFO()
|
|
ON_NOTIFY(TCN_SELCHANGE, IDC_TAB_LEGEND, OnSelchangeTabLegend)
|
|
ON_BN_CLICKED(IDC_CHECK_CONFIG, OnCheckConfig)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/*
|
|
=======================================================================================
|
|
CDialogFileList specific functions
|
|
=======================================================================================
|
|
*/
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
Description : Add Recursively sub project in tree
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
void CDialogFileList::m_fn_vAddProjectContentInTree( tdstProject *_p_stProj, BOOL _bGetCauseRecurse )
|
|
{
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
int iImage;
|
|
long lSubProj = 0;
|
|
tdstProject *p_stSubProj = _p_stProj->d_stSubProject;
|
|
long lFile = 0;
|
|
tdstFile *p_stFile = _p_stProj->d_stFile;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
for ( ; lSubProj < _p_stProj->lNumberOfSubProjects; lSubProj ++, p_stSubProj ++)
|
|
{
|
|
iImage = (_bGetCauseRecurse) ? 3 : m_fn_iGetProjectImage( p_stSubProj );
|
|
p_stSubProj->hTreeItem = m_p_oTree->InsertItem( p_stSubProj->szName, iImage, iImage, _p_stProj->hTreeItem );
|
|
m_p_oTree->SetItemData( p_stSubProj->hTreeItem,(DWORD) p_stSubProj );
|
|
m_fn_vAddProjectContentInTree ( p_stSubProj, (iImage == 2) || (iImage == 3));
|
|
}
|
|
|
|
/*
|
|
* Adding files
|
|
*/
|
|
for (; lFile < _p_stProj->lNumberOfFiles; lFile ++, p_stFile ++)
|
|
{
|
|
iImage = (_bGetCauseRecurse) ? 6 : (_p_stProj->bGet ? 7 : (p_stFile->bGet ? 5 : 4));
|
|
p_stFile->hTreeItem = m_p_oTree->InsertItem( p_stFile->szName, iImage, iImage, _p_stProj->hTreeItem );
|
|
m_p_oTree->SetItemData( p_stFile->hTreeItem,(DWORD) p_stFile );
|
|
}
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
change recursively image of tree item
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
void CDialogFileList::m_fn_vChangeProjectImage( tdstProject *_p_stProj, BOOL _bGetCauseRecurse )
|
|
{
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
int iImage;
|
|
long lSubProj = 0;
|
|
tdstProject *p_stSubProj = _p_stProj->d_stSubProject;
|
|
long lFile = 0;
|
|
tdstFile *p_stFile = _p_stProj->d_stFile;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
/*
|
|
* change recursively sub project image
|
|
*/
|
|
for ( ; lSubProj < _p_stProj->lNumberOfSubProjects; lSubProj ++, p_stSubProj ++)
|
|
{
|
|
iImage = (_bGetCauseRecurse) ? 3 : m_fn_iGetProjectImage( p_stSubProj );
|
|
m_p_oTree->SetItemImage( p_stSubProj->hTreeItem, iImage, iImage );
|
|
m_fn_vChangeProjectImage ( p_stSubProj, (iImage == 2) || (iImage == 3));
|
|
}
|
|
|
|
/*
|
|
* change files image
|
|
*/
|
|
for (; lFile < _p_stProj->lNumberOfFiles; lFile++, p_stFile ++)
|
|
{
|
|
iImage = (_bGetCauseRecurse) ? 6 : ((_p_stProj->bGet) ? 7 : (p_stFile->bGet ? 5 : 4));
|
|
m_p_oTree->SetItemImage( p_stFile->hTreeItem, iImage, iImage );
|
|
}
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
change only image of file in a project
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
void CDialogFileList::m_fn_vChangeProjectFilesImage( tdstProject *_p_stProj )
|
|
{
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
int iImage;
|
|
long lFile = 0;
|
|
tdstFile *p_stFile = _p_stProj->d_stFile;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
for (; lFile < _p_stProj->lNumberOfFiles; lFile++, p_stFile ++)
|
|
{
|
|
if (_p_stProj->bGet && _p_stProj->bRecurse)
|
|
iImage = 6;
|
|
else
|
|
iImage = (_p_stProj->bGet) ? 7 : (p_stFile->bGet ? 5 : 4);
|
|
m_p_oTree->SetItemImage( p_stFile->hTreeItem, iImage, iImage );
|
|
}
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
Get image index we must used for a project
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
int CDialogFileList::m_fn_iGetProjectImage( tdstProject *_p_stProj )
|
|
{
|
|
if (!_p_stProj->bGet)
|
|
return 0;
|
|
else
|
|
if (_p_stProj->bRecurse)
|
|
return 2;
|
|
else
|
|
return 1;
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
Set button for given project
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
void CDialogFileList::m_fn_vSetButton( HTREEITEM hItem )
|
|
{
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
int iImage, iSelectedImage;
|
|
BOOL bShow;
|
|
BOOL bSubProj;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
m_p_oTree->GetItemImage( hItem, iImage, iSelectedImage );
|
|
|
|
/*
|
|
* show button only if state of item can be change
|
|
* ie item is not obtain recursively
|
|
*/
|
|
bShow = ( (iImage != 3 ) && (iImage != 6) && (iImage != 7) );
|
|
bSubProj= ( iImage <= 3 );
|
|
|
|
GetDlgItem( IDC_CHECK_OBTAIN )->ShowWindow( bShow );
|
|
GetDlgItem( IDC_CHECK_RECURSE )->ShowWindow( bShow && bSubProj );
|
|
|
|
if ( bShow )
|
|
{
|
|
((CButton *) GetDlgItem( IDC_CHECK_OBTAIN ))->SetCheck( ( (iImage == 0) || (iImage == 4) ) ? 0 : 1 );
|
|
if ( bSubProj )
|
|
{
|
|
((CButton *) GetDlgItem( IDC_CHECK_RECURSE ))->SetCheck( (iImage == 2) ? 1 : 0 );
|
|
GetDlgItem( IDC_CHECK_RECURSE )->SetWindowText( (iImage == 0) ? "Get Recursively" : "Recurse" );
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
=======================================================================================
|
|
CDialogFileList specific functions for file configuration
|
|
=======================================================================================
|
|
*/
|
|
|
|
static char BASED_CODE szFilter[] = "File configuration file(*.fcf)|*.fcf||";
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
choose (or create) a configuration
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
void CDialogFileList::m_fn_vChooseConfig( void )
|
|
{
|
|
CNewConfigDialog oNewConfigDlg ( m_cConfigType );
|
|
char cConfig;
|
|
BOOL bNewConfig = FALSE;
|
|
|
|
if (oNewConfigDlg.DoModal() == IDOK)
|
|
{
|
|
cConfig = oNewConfigDlg.m_fn_cGetConfigIndex();
|
|
if (cConfig == -1)
|
|
{
|
|
bNewConfig = TRUE;
|
|
cConfig = fn_IniD_cGetAvailableConfig();
|
|
if (cConfig == -1)
|
|
MessageBox("Two many config (100)", "Error", MB_ICONSTOP);
|
|
}
|
|
if (cConfig != -1)
|
|
{
|
|
char szName[80];
|
|
|
|
strcpy( szName, oNewConfigDlg.m_fn_szGetConfigName() );
|
|
|
|
m_cConfig = cConfig;
|
|
GetDlgItem(IDC_EDIT_CONFIGNAME)->SetWindowText( szName );
|
|
if (!bNewConfig)
|
|
{
|
|
int iImage;
|
|
if ( !fn_IniD_bGetFileList( m_p_stConfig, cConfig, g_szIniFile ) )
|
|
{
|
|
fn_IniD_vSetSingleFileList( m_p_stConfig, m_szRootProject);
|
|
}
|
|
fn_Tree_vRefreshWithFileList( m_p_stProjectTree, m_p_stConfig );
|
|
iImage = m_fn_iGetProjectImage( m_p_stProjectTree );
|
|
m_p_oTree->SetItemImage(m_p_stProjectTree->hTreeItem, iImage, iImage );
|
|
m_fn_vChangeProjectImage( m_p_stProjectTree, iImage == 2 );
|
|
}
|
|
else
|
|
{
|
|
long lNbFiles = 0;
|
|
fn_Tree_vGetNumberOfFilesOrProjectsToGet( m_p_stProjectTree, &lNbFiles );
|
|
if (lNbFiles != 0)
|
|
if (AfxMessageBox( "New config : does I clear all vss tree\nto have an empty configuration ?", MB_ICONQUESTION | MB_YESNO) == IDYES)
|
|
OnButtonObtainnothing();
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if ( (m_cConfig != -1) && (g_stIniData.a_cAvailableConfig[ m_cConfig ] == 0) )
|
|
{
|
|
m_cConfig = -1;
|
|
GetDlgItem(IDC_EDIT_CONFIGNAME)->SetWindowText( "" );
|
|
|
|
}
|
|
}
|
|
|
|
m_p_oTree->SetFocus();
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
Import a configuration
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
void CDialogFileList::m_fn_vImportConfig( void )
|
|
{
|
|
char szFileName[ MAX_PATH ];
|
|
char szText[ 512 ];
|
|
int iImage;
|
|
DWORD dwFlags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
|
|
CFileDialog oFD( TRUE, "fcf", "*.fcf", dwFlags, szFilter, this);
|
|
char cConfig;
|
|
|
|
if ( (cConfig = fn_IniD_cGetAvailableConfig()) == -1)
|
|
{
|
|
MessageBox("Can't import : Two many config (100)", "Error", MB_ICONSTOP);
|
|
return;
|
|
}
|
|
|
|
if (oFD.DoModal() != IDOK)
|
|
return;
|
|
|
|
strcpy ( szFileName, (char *) (LPCTSTR) oFD.GetPathName() );
|
|
|
|
if (!fn_IniD_bGetFileList( m_p_stConfig, 0, szFileName ) )
|
|
{
|
|
sprintf( szText, "Can't read file configuration from file\r\n%s", szFileName );
|
|
MessageBox( szText, "Error", MB_OK | MB_ICONERROR );
|
|
return;
|
|
}
|
|
|
|
m_cConfig = cConfig;
|
|
|
|
GetDlgItem(IDC_EDIT_CONFIGNAME)->SetWindowText( m_p_stConfig->szName );
|
|
|
|
fn_Tree_vRefreshWithFileList( m_p_stProjectTree, m_p_stConfig );
|
|
iImage = m_fn_iGetProjectImage( m_p_stProjectTree );
|
|
m_p_oTree->SetItemImage(m_p_stProjectTree->hTreeItem, iImage, iImage );
|
|
m_fn_vChangeProjectImage( m_p_stProjectTree, iImage == 2 );
|
|
|
|
m_p_oTree->SetFocus();
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
Export a configuration
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
void CDialogFileList::m_fn_vExportConfig( void )
|
|
{
|
|
char szFileName[ MAX_PATH ];
|
|
DWORD dwFlags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_OVERWRITEPROMPT | OFN_NOREADONLYRETURN;
|
|
tdstFileListConfig stFLC;
|
|
char szConfigName[40];
|
|
|
|
GetDlgItem( IDC_EDIT_CONFIGNAME )->GetWindowText( szConfigName, 40 );
|
|
if ( *szConfigName == 0)
|
|
{
|
|
MessageBox("You must set a config name", "Error", MB_ICONSTOP );
|
|
return;
|
|
}
|
|
|
|
sprintf( szFileName, "%s.fcf", szConfigName );
|
|
|
|
CFileDialog oFD( FALSE, "fcf", szFileName, dwFlags, szFilter, this);
|
|
if (oFD.DoModal() != IDOK)
|
|
return;
|
|
|
|
strcpy ( szFileName, (char *) (LPCTSTR) oFD.GetPathName() );
|
|
|
|
memset( &stFLC, 0, sizeof( tdstFileListConfig ) );
|
|
if ( !fn_TREE_bGetFileList( m_p_stProjectTree, &stFLC, 0, szConfigName ))
|
|
{
|
|
MessageBox("Can't export : No file to get", "Error", MB_ICONSTOP );
|
|
m_p_oTree->SetFocus();
|
|
return;
|
|
}
|
|
|
|
fn_IniD_vWriteFileList( &stFLC, szFileName );
|
|
fn_IniD_vFreeFileList( &stFLC );
|
|
|
|
m_p_oTree->SetFocus();
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
=======================================================================================
|
|
CDialogFileList message handlers
|
|
=======================================================================================
|
|
*/
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
WM_INITDIALOG
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
BOOL CDialogFileList::OnInitDialog()
|
|
{
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
int iImage;
|
|
TC_ITEM stItem;
|
|
CTabCtrl *p_oTab;
|
|
CSize oSize( 32, 0 );
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
ASSERT( m_p_stConfig != NULL );
|
|
ASSERT( m_p_stProjectTree != NULL );
|
|
|
|
CDialog::OnInitDialog();
|
|
|
|
/* init tab control */
|
|
p_oTab = (CTabCtrl *) GetDlgItem( IDC_TAB_LEGEND );
|
|
p_oTab->DeleteAllItems();
|
|
p_oTab->SetImageList( &m_oLegendImageList );
|
|
oSize = p_oTab->SetItemSize( oSize );
|
|
|
|
|
|
stItem.mask = TCIF_IMAGE;
|
|
|
|
stItem.iImage = 0;
|
|
p_oTab->InsertItem( 0 , &stItem );
|
|
stItem.iImage = 1;
|
|
p_oTab->InsertItem( 1 , &stItem );
|
|
|
|
LRESULT lResult;
|
|
p_oTab->SetCurSel( 0 );
|
|
OnSelchangeTabLegend( NULL, &lResult );
|
|
|
|
m_bExpand = FALSE;
|
|
|
|
|
|
/* get Tree ctrl and empty it */
|
|
m_p_oTree = (CTreeCtrl *) GetDlgItem( IDC_TREE_VSS );
|
|
m_p_oTree->SetImageList( &m_oImageList, TVSIL_NORMAL );
|
|
m_p_oTree->DeleteAllItems();
|
|
|
|
/* fill tree control */
|
|
iImage = m_fn_iGetProjectImage( m_p_stProjectTree );
|
|
m_p_stProjectTree->hTreeItem = m_p_oTree->InsertItem( m_p_stProjectTree->szName, iImage, iImage );
|
|
m_p_oTree->SetItemData(m_p_stProjectTree->hTreeItem, (DWORD) m_p_stProjectTree );
|
|
m_fn_vAddProjectContentInTree( m_p_stProjectTree, iImage == 2 );
|
|
|
|
GetDlgItem( IDC_EDIT_CONFIGNAME )->SetWindowText( m_p_stConfig->szName );
|
|
if ( *m_p_stConfig->szName == 0)
|
|
m_cConfig = -1;
|
|
else
|
|
m_cConfig = atoi( m_p_stConfig->szId + 15 );
|
|
|
|
MoveWindow( &g_stWinPref.stFilePos );
|
|
|
|
m_p_oTree->Select(m_p_stProjectTree->hTreeItem, TVGN_CARET);
|
|
m_p_oTree->SetFocus();
|
|
return FALSE;
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
TVN_SELCHANGED from IDC_TREE_VSS
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
void CDialogFileList::OnSelchangedTreeVss(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*) pNMHDR;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
m_fn_vSetButton( pNMTreeView->itemNew.hItem );
|
|
|
|
*pResult = 0;
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
BN_CLICKED on IDC_CHECK_OBTAIN
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
void CDialogFileList::OnCheckObtain()
|
|
{
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
HTREEITEM hItem = m_p_oTree->GetSelectedItem();
|
|
tdstProject *p_stProj;
|
|
tdstFile *p_stFile;
|
|
int iImage, iSelectedImage;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
if (hItem == NULL)
|
|
return;
|
|
|
|
m_p_oTree->GetItemImage( hItem, iImage, iSelectedImage );
|
|
|
|
if ( iImage <= 3)
|
|
{
|
|
p_stProj = (tdstProject *) m_p_oTree->GetItemData( hItem );
|
|
p_stProj->bGet = !p_stProj->bGet;
|
|
if ( !p_stProj->bGet && p_stProj->bRecurse )
|
|
{
|
|
p_stProj->bRecurse = FALSE;
|
|
m_fn_vChangeProjectImage( p_stProj, FALSE );
|
|
}
|
|
else
|
|
{
|
|
m_fn_vChangeProjectFilesImage( p_stProj );
|
|
}
|
|
iImage = m_fn_iGetProjectImage( p_stProj );
|
|
}
|
|
else
|
|
{
|
|
p_stFile = (tdstFile *) m_p_oTree->GetItemData( hItem );
|
|
p_stFile->bGet = !p_stFile->bGet;
|
|
iImage = p_stFile->bGet ? 5 : 4;
|
|
}
|
|
|
|
m_p_oTree->SetItemImage( hItem, iImage, iImage );
|
|
m_fn_vSetButton( hItem );
|
|
m_p_oTree->SetFocus();
|
|
}
|
|
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
BN_CLICKED on IDC_CHECK_OBTAIN
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
void CDialogFileList::OnCheckRecurse()
|
|
{
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
HTREEITEM hItem = m_p_oTree->GetSelectedItem();
|
|
tdstProject *p_stProj;
|
|
int iImage, iSelectedImage;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
if (hItem == NULL)
|
|
return;
|
|
|
|
m_p_oTree->GetItemImage( hItem, iImage, iSelectedImage );
|
|
p_stProj = (tdstProject *) m_p_oTree->GetItemData( hItem );
|
|
|
|
if (iImage == 0)
|
|
{
|
|
p_stProj->bGet = TRUE;
|
|
p_stProj->bRecurse = TRUE;
|
|
}
|
|
else
|
|
p_stProj->bRecurse = !p_stProj->bRecurse;
|
|
|
|
m_fn_vChangeProjectImage( p_stProj, p_stProj->bRecurse );
|
|
|
|
iImage = m_fn_iGetProjectImage( p_stProj );
|
|
m_p_oTree->SetItemImage( hItem, iImage, iImage );
|
|
m_fn_vSetButton( hItem );
|
|
m_p_oTree->SetFocus();
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
BN_CLICKED on IDOK
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
void CDialogFileList::OnOK()
|
|
{
|
|
char szConfigName[40];
|
|
GetDlgItem( IDC_EDIT_CONFIGNAME )->GetWindowText( szConfigName, 40 );
|
|
|
|
if ( *szConfigName == 0)
|
|
{
|
|
MessageBox("You must set a config name", "Error", MB_ICONSTOP );
|
|
m_fn_vChooseConfig();
|
|
return;
|
|
}
|
|
|
|
if ( !fn_TREE_bGetFileList( m_p_stProjectTree, m_p_stConfig, m_cConfig, szConfigName ))
|
|
{
|
|
MessageBox("No folder to get", "Error", MB_ICONSTOP );
|
|
m_p_oTree->SetFocus();
|
|
return;
|
|
}
|
|
|
|
CDialog::OnOK();
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
BN_CLICKED on IDC_BUTTON_OBTAINALL
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
void CDialogFileList::OnButtonObtainall()
|
|
{
|
|
int iImage;
|
|
fn_IniD_vSetSingleFileList( m_p_stConfig, m_szRootProject);
|
|
fn_Tree_vRefreshWithFileList( m_p_stProjectTree, m_p_stConfig );
|
|
iImage = m_fn_iGetProjectImage( m_p_stProjectTree );
|
|
m_p_oTree->SetItemImage( m_p_stProjectTree->hTreeItem, iImage, iImage );
|
|
m_fn_vChangeProjectImage( m_p_stProjectTree, (iImage == 2) );
|
|
m_fn_vSetButton( m_p_oTree->GetSelectedItem() );
|
|
m_p_oTree->SetFocus();
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
BN_CLICKED on IDC_BUTTON_OBTAINNOTHING
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
void CDialogFileList::OnButtonObtainnothing()
|
|
{
|
|
fn_Tree_vGetNothing( m_p_stProjectTree );
|
|
m_p_oTree->SetItemImage( m_p_stProjectTree->hTreeItem, 0, 0 );
|
|
m_fn_vChangeProjectImage( m_p_stProjectTree, FALSE );
|
|
m_fn_vSetButton( m_p_oTree->GetSelectedItem() );
|
|
m_p_oTree->SetFocus();
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
BN_CLICKED on IDC_BUTTON_HELP
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
void CDialogFileList::OnButtonHelp()
|
|
{
|
|
::WinHelp(this->GetSafeHwnd(), C_szHelpFile, HELP_CONTEXT, IDH_J_CONFIGFILELIST );
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
WM_SIZING
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
void CDialogFileList::OnSizing( UINT nSide, LPRECT lpRect )
|
|
{
|
|
long lWidth = lpRect->right - lpRect->left + 1;
|
|
long lHeight= lpRect->bottom - lpRect->top + 1;
|
|
|
|
if (lWidth < C_iFileMinWidth)
|
|
{
|
|
switch (nSide)
|
|
{
|
|
case WMSZ_BOTTOMLEFT:
|
|
case WMSZ_LEFT:
|
|
case WMSZ_TOPLEFT:
|
|
lpRect->left = lpRect->right - C_iFileMinWidth;
|
|
break;
|
|
case WMSZ_BOTTOMRIGHT:
|
|
case WMSZ_RIGHT:
|
|
case WMSZ_TOPRIGHT:
|
|
lpRect->right = lpRect->left + C_iFileMinWidth;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (lHeight < C_iFileMinHeight)
|
|
{
|
|
switch (nSide)
|
|
{
|
|
case WMSZ_BOTTOM:
|
|
case WMSZ_BOTTOMLEFT:
|
|
case WMSZ_BOTTOMRIGHT:
|
|
lpRect->bottom = lpRect->top + C_iFileMinHeight;
|
|
break;
|
|
case WMSZ_TOP:
|
|
case WMSZ_TOPLEFT:
|
|
case WMSZ_TOPRIGHT:
|
|
lpRect->top = lpRect->bottom - C_iFileMinHeight;
|
|
}
|
|
}
|
|
|
|
CDialog::OnSizing( nSide, lpRect );
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
WM_SIZE
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
/*
|
|
* macro to get a pointer on a CWnd and screen rectangle of a dialog item
|
|
*/
|
|
#define M_vGetWndAndRect( _uiItem, _p_oWnd, _p_stRect )\
|
|
{\
|
|
_p_oWnd = GetDlgItem( _uiItem );\
|
|
_p_oWnd->GetWindowRect( _p_stRect );\
|
|
ScreenToClient( _p_stRect );\
|
|
}
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
void CDialogFileList::OnSize(UINT nType, int cx, int cy)
|
|
{
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
RECT stRect;
|
|
CWnd *p_oWnd;
|
|
char cItem;
|
|
int iDiffX = (cx - m_iOldCx);
|
|
int iDiffY = (cy - m_iOldCy);
|
|
TC_ITEM stItem;
|
|
CTabCtrl *p_oTab;
|
|
char szText[10];
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
CDialog::OnSize(nType, cx, cy);
|
|
|
|
p_oWnd = GetDlgItem( IDC_EDIT_CONFIGNAME );
|
|
|
|
if ( (nType != SIZE_MINIMIZED) && (p_oWnd != NULL) )
|
|
{
|
|
/*
|
|
* resizing config name edit box
|
|
*/
|
|
M_vGetWndAndRect( IDC_EDIT_CONFIGNAME, p_oWnd, &stRect );
|
|
stRect.right += iDiffX;
|
|
p_oWnd->MoveWindow( &stRect, FALSE );
|
|
|
|
/*
|
|
* moving legend item
|
|
*/
|
|
for (cItem = 0; cItem < C_cNbLegend; cItem ++)
|
|
{
|
|
M_vGetWndAndRect( s_a_uiLegend[cItem], p_oWnd, &stRect );
|
|
stRect.left += iDiffX;
|
|
stRect.right += iDiffX;
|
|
p_oWnd->MoveWindow( &stRect, FALSE );
|
|
}
|
|
|
|
/*
|
|
* resizing tree view
|
|
*/
|
|
M_vGetWndAndRect( IDC_TREE_VSS, p_oWnd, &stRect );
|
|
stRect.right += iDiffX;
|
|
stRect.bottom += iDiffY;
|
|
p_oWnd->MoveWindow( &stRect, FALSE );
|
|
/*
|
|
* resizing and moving help button
|
|
*/
|
|
M_vGetWndAndRect( IDC_BUTTON_HELP, p_oWnd, &stRect );
|
|
stRect.bottom += iDiffY;
|
|
stRect.left += iDiffX;
|
|
stRect.right += iDiffX;
|
|
p_oWnd->MoveWindow( & stRect, FALSE );
|
|
/*
|
|
* moving bottom item
|
|
*/
|
|
for (cItem = 0; cItem < C_cNbBottom; cItem ++)
|
|
{
|
|
M_vGetWndAndRect( s_a_uiBottom[cItem], p_oWnd, &stRect );
|
|
stRect.top += iDiffY;
|
|
stRect.bottom += iDiffY;
|
|
p_oWnd->MoveWindow( &stRect, FALSE );
|
|
}
|
|
|
|
/*
|
|
* special for legend
|
|
*/
|
|
if (m_bExpand && (cy < 500) )
|
|
{
|
|
m_bExpand = FALSE;
|
|
M_vGetWndAndRect( IDC_TAB_LEGEND, p_oWnd, &stRect );
|
|
stRect.bottom -= 200;
|
|
p_oWnd->MoveWindow( &stRect, FALSE );
|
|
M_vGetWndAndRect( IDC_STATIC_KEYS, p_oWnd, &stRect );
|
|
stRect.bottom -= 240;
|
|
stRect.top -= 240;
|
|
p_oWnd->MoveWindow( &stRect, FALSE );
|
|
M_vGetWndAndRect( IDC_BUTTON_HELP, p_oWnd, &stRect );
|
|
stRect.top -= 200;
|
|
stRect.bottom = cy - 5;
|
|
p_oWnd->MoveWindow( &stRect, FALSE );
|
|
|
|
p_oTab = (CTabCtrl *) GetDlgItem( IDC_TAB_LEGEND );
|
|
stItem.mask = TCIF_IMAGE;
|
|
p_oTab->SetItemSize( CSize(32,0) );
|
|
p_oTab->DeleteAllItems();
|
|
stItem.iImage = 0;
|
|
p_oTab->InsertItem( 0 , &stItem );
|
|
stItem.iImage = 1;
|
|
p_oTab->InsertItem( 1 , &stItem );
|
|
|
|
LRESULT lResult;
|
|
p_oTab->SetCurSel( m_bLegend ? 0 : 1 );
|
|
OnSelchangeTabLegend( NULL, &lResult );
|
|
}
|
|
else if (!m_bExpand && (cy >= 500) )
|
|
{
|
|
M_vGetWndAndRect( IDC_TAB_LEGEND, p_oWnd, &stRect );
|
|
stRect.bottom += 200;
|
|
p_oWnd->MoveWindow( &stRect, FALSE );
|
|
M_vGetWndAndRect( IDC_STATIC_KEYS, p_oWnd, &stRect );
|
|
stRect.bottom += 240;
|
|
stRect.top += 240;
|
|
p_oWnd->MoveWindow( &stRect, FALSE );
|
|
M_vGetWndAndRect( IDC_BUTTON_HELP, p_oWnd, &stRect );
|
|
stRect.top += 200;
|
|
stRect.bottom = cy - 5;
|
|
p_oWnd->MoveWindow( &stRect, FALSE );
|
|
|
|
p_oTab = (CTabCtrl *) GetDlgItem( IDC_TAB_LEGEND );
|
|
p_oTab->SetItemSize( CSize(64,0) );
|
|
stItem.mask = TCIF_TEXT;
|
|
p_oTab->DeleteAllItems();
|
|
stItem.pszText = szText;
|
|
strcpy( szText, "Legend" );
|
|
p_oTab->InsertItem( 0 , &stItem );
|
|
|
|
if ( !m_bLegend )
|
|
{
|
|
LRESULT lResult;
|
|
p_oTab->SetCurSel( 0 );
|
|
OnSelchangeTabLegend( NULL, &lResult );
|
|
m_bLegend = FALSE;
|
|
}
|
|
GetDlgItem( IDC_STATIC_KEYS )->ShowWindow( TRUE );
|
|
m_bExpand = TRUE;
|
|
}
|
|
|
|
Invalidate();
|
|
}
|
|
m_iOldCx = cx;
|
|
m_iOldCy = cy;
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
WM_DESTROY
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
void CDialogFileList::OnDestroy()
|
|
{
|
|
GetWindowRect( &g_stWinPref.stFilePos );
|
|
CDialog::OnDestroy();
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
Pre translate message
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
BOOL CDialogFileList::PreTranslateMessage(MSG* pMsg)
|
|
{
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
CWnd *pWnd = GetDlgItem(IDC_TREE_VSS);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
if (pMsg->message == WM_RBUTTONDOWN)
|
|
{
|
|
if ( pMsg->hwnd == GetDlgItem(IDC_TREE_VSS)->GetSafeHwnd() )
|
|
{
|
|
HTREEITEM hItem;
|
|
UINT uiFlags;
|
|
CPoint oPoint( LOWORD( pMsg->lParam), HIWORD( pMsg->lParam ) );
|
|
CMenu oMenu;
|
|
int iImage, iSelectedImage;
|
|
char szText[40];
|
|
DWORD dwItemData1, dwItemData2;
|
|
|
|
if ( (hItem = m_p_oTree->HitTest( oPoint, &uiFlags )) != NULL)
|
|
{
|
|
m_p_oTree->SelectItem( hItem );
|
|
m_p_oTree->GetItemImage( hItem, iImage, iSelectedImage );
|
|
oMenu.CreatePopupMenu();
|
|
if ( (iImage != 3) && (iImage != 6) && (iImage != 7))
|
|
{
|
|
switch (iImage)
|
|
{
|
|
case 0:
|
|
dwItemData1 = MAKELPARAM( 1, 0 );
|
|
dwItemData2 = MAKELPARAM( 2, 1 );
|
|
break;
|
|
case 1:
|
|
dwItemData1 = MAKELPARAM( 0, 2 );
|
|
dwItemData2 = MAKELPARAM( 2, 3 );
|
|
break;
|
|
case 2:
|
|
dwItemData1 = MAKELPARAM( 0, 2 );
|
|
dwItemData2 = MAKELPARAM( 1, 4 );
|
|
break;
|
|
case 4:
|
|
dwItemData1 = MAKELPARAM( 5, 0 );
|
|
break;
|
|
case 5:
|
|
dwItemData1 = MAKELPARAM( 4, 2 );
|
|
break;
|
|
}
|
|
oMenu.AppendMenu(MF_OWNERDRAW, 1, (LPCTSTR) dwItemData1);
|
|
if (iImage < 3)
|
|
oMenu.AppendMenu(MF_OWNERDRAW, 2, (LPCTSTR) dwItemData2);
|
|
oMenu.AppendMenu( MF_SEPARATOR );
|
|
}
|
|
GetDlgItem( IDC_BUTTON_OBTAINALL ) ->GetWindowText( szText, 40 );
|
|
oMenu.AppendMenu(MF_STRING, 3, szText );
|
|
GetDlgItem( IDC_BUTTON_OBTAINNOTHING ) ->GetWindowText( szText, 40 );
|
|
oMenu.AppendMenu(MF_STRING, 4, szText );
|
|
m_p_oTree->ClientToScreen( (POINT *) &oPoint );
|
|
oMenu.TrackPopupMenu( TPM_RIGHTBUTTON, oPoint.x, oPoint.y, this );
|
|
oMenu.DestroyMenu();
|
|
}
|
|
}
|
|
}
|
|
else if (pMsg->message == WM_CHAR)
|
|
{
|
|
if (pMsg->hwnd == m_p_oTree->GetSafeHwnd() )
|
|
{
|
|
HTREEITEM hItem = NULL;
|
|
HTREEITEM hNextItem = NULL;
|
|
POINT stPoint;
|
|
char cChar = (char) pMsg->wParam;
|
|
|
|
if ( (cChar == 7) || (cChar == 14) || (cChar == 18) )
|
|
{
|
|
hItem = m_p_oTree->GetSelectedItem();
|
|
if (hItem)
|
|
if (GetKeyState( VK_SHIFT ) & 0x8000 )
|
|
hNextItem = m_p_oTree->GetNextItem( hItem, TVGN_PREVIOUSVISIBLE );
|
|
else
|
|
hNextItem = m_p_oTree->GetNextItem( hItem, TVGN_NEXTVISIBLE );
|
|
cChar = cChar - 7 + 'g';
|
|
}
|
|
else if ( strchr("grn", cChar ) )
|
|
{
|
|
hItem = m_p_oTree->GetSelectedItem();
|
|
}
|
|
else if ( strchr("GRN", cChar ) )
|
|
{
|
|
UINT uiFlags;
|
|
|
|
GetCursorPos( &stPoint );
|
|
m_p_oTree->ScreenToClient( &stPoint );
|
|
hItem = m_p_oTree->HitTest( stPoint, &uiFlags );
|
|
if (hItem)
|
|
{
|
|
m_p_oTree->SelectItem( hItem );
|
|
cChar = tolower( cChar );
|
|
}
|
|
}
|
|
|
|
if (hItem)
|
|
{
|
|
int iImage, iSelectedImage;
|
|
|
|
m_p_oTree->GetItemImage( hItem, iImage, iSelectedImage );
|
|
switch( cChar )
|
|
{
|
|
case 'g':
|
|
if ( (iImage == 0) || (iImage == 4) )
|
|
OnCheckObtain();
|
|
else if (iImage == 2)
|
|
OnCheckRecurse();
|
|
break;
|
|
case 'n' :
|
|
if ( (iImage == 1) || (iImage == 2) || (iImage == 5) )
|
|
OnCheckObtain();
|
|
break;
|
|
case 'r' :
|
|
if ((iImage == 0) || (iImage == 1))
|
|
OnCheckRecurse();
|
|
break;
|
|
}
|
|
|
|
|
|
if (hNextItem)
|
|
m_p_oTree->SelectItem( hNextItem );
|
|
return 1;
|
|
}
|
|
}
|
|
}
|
|
return CDialog::PreTranslateMessage(pMsg);
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
On command
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
BOOL CDialogFileList::OnCommand(WPARAM wParam, LPARAM lParam)
|
|
{
|
|
if ( (lParam == 0) && (HIWORD( wParam ) == 0) )
|
|
{
|
|
switch (LOWORD( wParam ) )
|
|
{
|
|
case 1:
|
|
OnCheckObtain();
|
|
return TRUE;
|
|
case 2:
|
|
OnCheckRecurse();
|
|
return TRUE;
|
|
case 3:
|
|
OnButtonObtainall();
|
|
return TRUE;
|
|
case 4:
|
|
OnButtonObtainnothing();
|
|
return TRUE;
|
|
case IDM_CONFIGCHOOSE:
|
|
m_fn_vChooseConfig();
|
|
return TRUE;
|
|
case IDM_CONFIGIMPORT:
|
|
m_fn_vImportConfig();
|
|
return TRUE;
|
|
case IDM_CONFIGEXPORT:
|
|
m_fn_vExportConfig();
|
|
return TRUE;
|
|
}
|
|
}
|
|
return CDialog::OnCommand(wParam, lParam);
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
WM_MEASUREITEM
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
void CDialogFileList::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMIS)
|
|
{
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
char *p_szItem = g_a_szMenuItem[ HIWORD(lpMIS->itemData) ];
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
lpMIS->itemHeight = 16;
|
|
lpMIS->itemWidth = 20 + GetDC()->GetOutputTextExtent( p_szItem, strlen( p_szItem ) ).cx;
|
|
|
|
//CDialog::OnMeasureItem(nIDCtl, lpMIS);
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
WM_DRAWITEM
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
void CDialogFileList::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDIS)
|
|
{
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
CDC *p_oDC = CDC::FromHandle( lpDIS->hDC );
|
|
POINT stPoint;
|
|
int iImage;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
if (nIDCtl == 0) // menu item
|
|
{
|
|
char *p_szItem = g_a_szMenuItem[ HIWORD(lpDIS->itemData) ];
|
|
|
|
iImage = LOWORD( lpDIS->itemData );
|
|
|
|
stPoint.x = lpDIS->rcItem.left;
|
|
stPoint.y = lpDIS->rcItem.top;
|
|
|
|
m_oImageList.Draw( p_oDC, iImage, stPoint, ILD_NORMAL );
|
|
lpDIS->rcItem.left += 20;
|
|
p_oDC->DrawText( p_szItem, strlen(p_szItem), &lpDIS->rcItem, DT_VCENTER | DT_SINGLELINE );
|
|
}
|
|
else // legend button
|
|
{
|
|
stPoint.x = lpDIS->rcItem.left + 2;
|
|
stPoint.y = lpDIS->rcItem.top + 2;
|
|
|
|
switch( nIDCtl )
|
|
{
|
|
case IDC_BUTTON_LEGEND0: iImage = 0; break;
|
|
case IDC_BUTTON_LEGEND1: iImage = 1; break;
|
|
case IDC_BUTTON_LEGEND2: iImage = 2; break;
|
|
case IDC_BUTTON_LEGEND3: iImage = 3; break;
|
|
case IDC_BUTTON_LEGEND4: iImage = 4; break;
|
|
case IDC_BUTTON_LEGEND5: iImage = 5; break;
|
|
case IDC_BUTTON_LEGEND6: iImage = 6; break;
|
|
case IDC_BUTTON_LEGEND7: iImage = 7; break;
|
|
}
|
|
|
|
m_oImageList.Draw( p_oDC, iImage, stPoint, ILD_NORMAL );
|
|
p_oDC->Draw3dRect( &lpDIS->rcItem, GetSysColor( COLOR_3DHILIGHT ), GetSysColor( COLOR_3DDKSHADOW ) );
|
|
}
|
|
|
|
//CDialog::OnDrawItem(nIDCtl, lpDIS);
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
BN_CLICKED on IDC_BUTTON_LEGEND0
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
void CDialogFileList::OnButtonLegend0()
|
|
{
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
HTREEITEM hItem;
|
|
int iImage, iSelectedImage;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
hItem = m_p_oTree->GetSelectedItem();
|
|
if (hItem != NULL)
|
|
{
|
|
m_p_oTree->GetItemImage( hItem, iImage, iSelectedImage );
|
|
if ( (iImage == 1) || (iImage == 2) )
|
|
OnCheckObtain();
|
|
}
|
|
m_p_oTree->SetFocus();
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
BN_CLICKED on IDC_BUTTON_LEGEND1
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
void CDialogFileList::OnButtonLegend1()
|
|
{
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
HTREEITEM hItem;
|
|
int iImage, iSelectedImage;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
hItem = m_p_oTree->GetSelectedItem();
|
|
if (hItem != NULL)
|
|
{
|
|
m_p_oTree->GetItemImage( hItem, iImage, iSelectedImage );
|
|
if (iImage == 0)
|
|
OnCheckObtain();
|
|
else if (iImage == 2)
|
|
OnCheckRecurse();
|
|
}
|
|
m_p_oTree->SetFocus();
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
BN_CLICKED on IDC_BUTTON_LEGEND2
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
void CDialogFileList::OnButtonLegend2()
|
|
{
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
HTREEITEM hItem;
|
|
int iImage, iSelectedImage;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
hItem = m_p_oTree->GetSelectedItem();
|
|
if (hItem != NULL)
|
|
{
|
|
m_p_oTree->GetItemImage( hItem, iImage, iSelectedImage );
|
|
if ((iImage == 0) || (iImage == 1))
|
|
OnCheckRecurse();
|
|
}
|
|
m_p_oTree->SetFocus();
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
BN_CLICKED on IDC_BUTTON_LEGEND3
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
void CDialogFileList::OnButtonLegend3()
|
|
{
|
|
m_p_oTree->SetFocus();
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
Description : BN_CLICKED on IDC_BUTTON_LEGEND4
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
void CDialogFileList::OnButtonLegend4()
|
|
{
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
HTREEITEM hItem;
|
|
int iImage, iSelectedImage;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
hItem = m_p_oTree->GetSelectedItem();
|
|
if (hItem != NULL)
|
|
{
|
|
m_p_oTree->GetItemImage( hItem, iImage, iSelectedImage );
|
|
if ( iImage == 5 )
|
|
OnCheckObtain();
|
|
}
|
|
m_p_oTree->SetFocus();
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
Description : BN_CLICKED on IDC_BUTTON_LEGEND5
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
void CDialogFileList::OnButtonLegend5()
|
|
{
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
HTREEITEM hItem;
|
|
int iImage, iSelectedImage;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
hItem = m_p_oTree->GetSelectedItem();
|
|
if (hItem != NULL)
|
|
{
|
|
m_p_oTree->GetItemImage( hItem, iImage, iSelectedImage );
|
|
if ( iImage == 4 )
|
|
OnCheckObtain();
|
|
}
|
|
m_p_oTree->SetFocus();
|
|
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
Description : BN_CLICKED on IDC_BUTTON_LEGEND6
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
void CDialogFileList::OnButtonLegend6()
|
|
{
|
|
m_p_oTree->SetFocus();
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
Description : BN_CLICKED on IDC_BUTTON_LEGEND6
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
void CDialogFileList::OnButtonLegend7()
|
|
{
|
|
m_p_oTree->SetFocus();
|
|
}
|
|
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
Description : WM_HELPINFO
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
BOOL CDialogFileList::OnHelpInfo(HELPINFO* pHelpInfo)
|
|
{
|
|
::WinHelp(this->GetSafeHwnd(), C_szHelpFile, HELP_CONTEXT, IDH_J_CONFIGFILELIST );
|
|
return TRUE;
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
Description : TCN_SELCHANGE on IDC_TAB_LEGEND tab control
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
void CDialogFileList::OnSelchangeTabLegend(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
char cItem;
|
|
int iTab = ((CTabCtrl *) GetDlgItem( IDC_TAB_LEGEND ))->GetCurSel();
|
|
|
|
if (!m_bExpand)
|
|
{
|
|
m_bLegend = (iTab == 0);
|
|
/*
|
|
* showing / hiding legend item
|
|
*/
|
|
for (cItem = 1; cItem < C_cNbLegend - 1; cItem ++)
|
|
{
|
|
GetDlgItem( s_a_uiLegend[cItem] )->ShowWindow( m_bLegend );
|
|
}
|
|
|
|
/*
|
|
* showing / hiding legend key item
|
|
*/
|
|
for ( ; cItem < C_cNbLegend; cItem ++)
|
|
{
|
|
GetDlgItem( s_a_uiLegend[cItem] )->ShowWindow( !m_bLegend );
|
|
}
|
|
}
|
|
|
|
|
|
*pResult = 0;
|
|
}
|
|
|
|
/*
|
|
----------------------------------------------------------------------------------------
|
|
Description : BN_CLICKED on IDC_CHECK_CONFIG
|
|
----------------------------------------------------------------------------------------
|
|
*/
|
|
void CDialogFileList::OnCheckConfig()
|
|
{
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
CButton *p_oCheck = ((CButton *) GetDlgItem (IDC_CHECK_CONFIG));
|
|
RECT stRect;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
if ( p_oCheck->GetCheck() == 1 )
|
|
{
|
|
CMenu oMenu;
|
|
oMenu.CreatePopupMenu();
|
|
|
|
oMenu.AppendMenu( MF_STRING | MF_ENABLED, IDM_CONFIGCHOOSE, "Choose / create");
|
|
oMenu.AppendMenu( MF_STRING | MF_ENABLED, IDM_CONFIGIMPORT, "Import");
|
|
oMenu.AppendMenu( MF_STRING | MF_ENABLED, IDM_CONFIGEXPORT, "Export");
|
|
|
|
p_oCheck->GetWindowRect(&stRect);
|
|
oMenu.TrackPopupMenu( TPM_LEFTBUTTON, stRect.left, stRect.bottom, this );
|
|
oMenu.DestroyMenu();
|
|
p_oCheck->SetCheck( 0 );
|
|
}
|
|
|
|
}
|