ENH: allow cancel and display of progress during cpu intensive configure steps

This commit is contained in:
Bill Hoffman 2003-07-08 13:12:10 -04:00
parent 6566ba20ac
commit b274069b93
2 changed files with 75 additions and 22 deletions

View File

@ -117,13 +117,41 @@ void updateProgress(const char *msg, float prog, void *cd)
sprintf(tmp,"%s",msg); sprintf(tmp,"%s",msg);
} }
CMakeSetupDialog *self = (CMakeSetupDialog *)cd; CMakeSetupDialog *self = (CMakeSetupDialog *)cd;
self->SetDlgItemText(IDC_PROGRESS, tmp); self->SetDlgItemText(IDC_PROGRESS, tmp);
CWnd* cancel = self->GetDlgItem(IDCANCEL);
//
// Retrieve and dispatch any waiting messages.
//
MSG wmsg;
while (::PeekMessage (&wmsg, NULL, 0, 0, PM_REMOVE))
{
switch(wmsg.message)
{
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_LBUTTONDBLCLK:
{
if(wmsg.hwnd == cancel->m_hWnd)
{
::DispatchMessage(&wmsg);
}
}
break;
case WM_COMMAND:
case WM_SETCURSOR:
case WM_PAINT:
::DispatchMessage(&wmsg);
break;
}
}
} }
CMakeSetupDialog::CMakeSetupDialog(const CMakeCommandLineInfo& cmdInfo, CMakeSetupDialog::CMakeSetupDialog(const CMakeCommandLineInfo& cmdInfo,
CWnd* pParent /*=NULL*/) CWnd* pParent /*=NULL*/)
: CDialog(CMakeSetupDialog::IDD, pParent) : CDialog(CMakeSetupDialog::IDD, pParent)
{ {
m_Cursor = LoadCursor(NULL, IDC_ARROW);
m_RunningConfigure = false;
cmSystemTools::SetRunCommandHideConsole(true); cmSystemTools::SetRunCommandHideConsole(true);
cmSystemTools::SetErrorCallback(MFCMessageCallback); cmSystemTools::SetErrorCallback(MFCMessageCallback);
m_RegistryKey = "Software\\Kitware\\CMakeSetup\\Settings\\StartPath"; m_RegistryKey = "Software\\Kitware\\CMakeSetup\\Settings\\StartPath";
@ -208,7 +236,6 @@ BEGIN_MESSAGE_MAP(CMakeSetupDialog, CDialog)
ON_WM_SYSCOMMAND() ON_WM_SYSCOMMAND()
ON_WM_PAINT() ON_WM_PAINT()
ON_WM_QUERYDRAGICON() ON_WM_QUERYDRAGICON()
ON_WM_DROPFILES()
ON_BN_CLICKED(IDC_BUTTON2, OnBrowseWhereSource) ON_BN_CLICKED(IDC_BUTTON2, OnBrowseWhereSource)
ON_BN_CLICKED(IDC_BuildProjects, OnConfigure) ON_BN_CLICKED(IDC_BuildProjects, OnConfigure)
ON_BN_CLICKED(IDC_BUTTON3, OnBrowseWhereBuild) ON_BN_CLICKED(IDC_BUTTON3, OnBrowseWhereBuild)
@ -221,10 +248,12 @@ BEGIN_MESSAGE_MAP(CMakeSetupDialog, CDialog)
ON_BN_CLICKED(IDC_OK, OnOk) ON_BN_CLICKED(IDC_OK, OnOk)
ON_CBN_EDITCHANGE(IDC_Generator, OnEditchangeGenerator) ON_CBN_EDITCHANGE(IDC_Generator, OnEditchangeGenerator)
ON_BN_CLICKED(IDC_HELP_BUTTON, OnHelpButton) ON_BN_CLICKED(IDC_HELP_BUTTON, OnHelpButton)
ON_BN_CLICKED(IDCANCEL, OnCancel)
ON_BN_CLICKED(IDC_AdvancedValues, OnAdvancedValues) ON_BN_CLICKED(IDC_AdvancedValues, OnAdvancedValues)
ON_BN_DOUBLECLICKED(IDC_AdvancedValues, OnDoubleclickedAdvancedValues) ON_BN_DOUBLECLICKED(IDC_AdvancedValues, OnDoubleclickedAdvancedValues)
//}}AFX_MSG_MAP ON_WM_DROPFILES()
ON_BN_CLICKED(IDCANCEL, OnCancel)
ON_WM_SETCURSOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP() END_MESSAGE_MAP()
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -606,8 +635,10 @@ void CMakeSetupDialog::RunCMake(bool generateProjectFiles)
} }
} }
// set the wait cursor // set the wait cursor
::SetCursor(LoadCursor(NULL, IDC_WAIT)); m_Cursor = LoadCursor(NULL, IDC_WAIT);
::SetCursor(m_Cursor);
m_RunningConfigure = true;
// get all the info from the dialog // get all the info from the dialog
this->UpdateData(); this->UpdateData();
// always save the current gui values to disk // always save the current gui values to disk
@ -649,8 +680,10 @@ void CMakeSetupDialog::RunCMake(bool generateProjectFiles)
this->SaveToRegistry(); this->SaveToRegistry();
// path is up-to-date now // path is up-to-date now
m_BuildPathChanged = false; m_BuildPathChanged = false;
// put the cursor back // put the cursor back
::SetCursor(LoadCursor(NULL, IDC_ARROW)); m_Cursor = LoadCursor(NULL, IDC_ARROW);
::SetCursor(m_Cursor);
m_RunningConfigure = false;
cmSystemTools::ResetErrorOccuredFlag(); cmSystemTools::ResetErrorOccuredFlag();
} }
@ -1054,6 +1087,17 @@ void CMakeSetupDialog::OnGetMinMaxInfo( MINMAXINFO FAR* lpMMI )
void CMakeSetupDialog::OnCancel() void CMakeSetupDialog::OnCancel()
{ {
if(m_RunningConfigure)
{
if(MessageBox("You are in the middle of a Configure.\n"
"If you Cancel now the configure information will be lost.\n"
"Are you sure you want to Cancel?", "Confirm Exit",
MB_YESNO) == IDYES)
{
cmSystemTools::SetFatalErrorOccured();
}
return;
}
if(m_CacheEntriesList.IsDirty()) if(m_CacheEntriesList.IsDirty())
{ {
if(MessageBox("You have changed options but not rebuilt, " if(MessageBox("You have changed options but not rebuilt, "
@ -1395,3 +1439,9 @@ void CMakeSetupDialog::OnDropFiles(HDROP hDropInfo)
DragFinish(hDropInfo); DragFinish(hDropInfo);
} }
BOOL CMakeSetupDialog::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
::SetCursor(m_Cursor);
return true;
}

View File

@ -1,17 +1,17 @@
/*========================================================================= /*=========================================================================
Program: CMake - Cross-Platform Makefile Generator Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$ Module: $RCSfile$
Language: C++ Language: C++
Date: $Date$ Date: $Date$
Version: $Revision$ Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
// CMakeSetupDialogDlg.h : header file // CMakeSetupDialogDlg.h : header file
@ -59,7 +59,7 @@ protected:
void RemoveAdvancedValues(); void RemoveAdvancedValues();
// Dialog Data // Dialog Data
//{{AFX_DATA(CMakeSetupDialog) //{{AFX_DATA(CMakeSetupDialog)
enum { IDD = IDD_CMakeSetupDialog_DIALOG }; enum { IDD = IDD_CMakeSetupDialog_DIALOG };
CButton m_AdvancedValuesControl; CButton m_AdvancedValuesControl;
CStatic m_BuildForLabel; CStatic m_BuildForLabel;
CButton m_BrowseSource; CButton m_BrowseSource;
@ -80,7 +80,7 @@ protected:
CButton m_Configure; CButton m_Configure;
CString m_GeneratorChoiceString; CString m_GeneratorChoiceString;
BOOL m_AdvancedValues; BOOL m_AdvancedValues;
//}}AFX_DATA //}}AFX_DATA
// ClassWizard generated virtual function overrides // ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMakeSetupDialog) //{{AFX_VIRTUAL(CMakeSetupDialog)
@ -125,13 +125,16 @@ protected:
afx_msg void OnAdvancedValues(); afx_msg void OnAdvancedValues();
afx_msg void OnDoubleclickedAdvancedValues(); afx_msg void OnDoubleclickedAdvancedValues();
afx_msg void OnDropFiles(HDROP); afx_msg void OnDropFiles(HDROP);
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
//}}AFX_MSG //}}AFX_MSG
DECLARE_MESSAGE_MAP() DECLARE_MESSAGE_MAP()
int m_oldCX; int m_oldCX;
int m_oldCY; int m_oldCY;
float m_deltaXRemainder; float m_deltaXRemainder;
cmake *m_CMakeInstance; cmake *m_CMakeInstance;
HCURSOR m_Cursor;
bool m_RunningConfigure;
}; };
//{{AFX_INSERT_LOCATION}} //{{AFX_INSERT_LOCATION}}