diff options
author | Ken Martin <ken.martin@kitware.com> | 2004-05-20 19:08:18 (GMT) |
---|---|---|
committer | Ken Martin <ken.martin@kitware.com> | 2004-05-20 19:08:18 (GMT) |
commit | d7c6f51d00510175ecc61709fd22ae98889e145c (patch) | |
tree | 6ac7e6d6a6524e08a501265ed3cca34b6b33020f | |
parent | 6665adc3ff406f97ca126b8700d0da6ca7cc6e5a (diff) | |
download | CMake-d7c6f51d00510175ecc61709fd22ae98889e145c.zip CMake-d7c6f51d00510175ecc61709fd22ae98889e145c.tar.gz CMake-d7c6f51d00510175ecc61709fd22ae98889e145c.tar.bz2 |
updates to gui to delete cache
-rw-r--r-- | Source/MFCDialog/CMakeSetup.rc | 52 | ||||
-rw-r--r-- | Source/MFCDialog/CMakeSetupDialog.cpp | 109 | ||||
-rw-r--r-- | Source/MFCDialog/CMakeSetupDialog.h | 2 | ||||
-rw-r--r-- | Source/MFCDialog/resource.h | 4 | ||||
-rw-r--r-- | Source/cmCacheManager.cxx | 8 | ||||
-rw-r--r-- | Source/cmCacheManager.h | 3 |
6 files changed, 111 insertions, 67 deletions
diff --git a/Source/MFCDialog/CMakeSetup.rc b/Source/MFCDialog/CMakeSetup.rc index c5fb36d..6c0eb20 100644 --- a/Source/MFCDialog/CMakeSetup.rc +++ b/Source/MFCDialog/CMakeSetup.rc @@ -1,4 +1,4 @@ -//Microsoft Developer Studio generated resource script. +// Microsoft Visual C++ generated resource script. // #include "resource.h" @@ -27,18 +27,18 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // TEXTINCLUDE // -1 TEXTINCLUDE MOVEABLE PURE +1 TEXTINCLUDE BEGIN "resource.h\0" END -2 TEXTINCLUDE MOVEABLE PURE +2 TEXTINCLUDE BEGIN "#include ""afxres.h""\r\n" "\0" END -3 TEXTINCLUDE MOVEABLE PURE +3 TEXTINCLUDE BEGIN "#define _AFX_NO_SPLITTER_RESOURCES\r\n" "#define _AFX_NO_OLE_RESOURCES\r\n" @@ -66,7 +66,7 @@ END // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. -IDR_MAINFRAME ICON DISCARDABLE "res\\CMakeSetupDialog.ico" +IDR_MAINFRAME ICON "res\\CMakeSetupDialog.ico" ///////////////////////////////////////////////////////////////////////////// // @@ -74,7 +74,7 @@ IDR_MAINFRAME ICON DISCARDABLE "res\\CMakeSetupDialog.ico" // IDD_ABOUTBOX DIALOGEX 0, 0, 235, 55 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "About CMakeSetup" FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN @@ -84,11 +84,11 @@ BEGIN END IDD_CMakeSetupDialog_DIALOG DIALOGEX 0, 0, 447, 255 -STYLE WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | - WS_SYSMENU | WS_THICKFRAME +STYLE DS_SETFONT | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE | + WS_CAPTION | WS_SYSMENU | WS_THICKFRAME EXSTYLE WS_EX_APPWINDOW CAPTION "CMakeSetupDialog" -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN RTEXT "Where is the source code:",IDC_STATIC,6,7,86,9 COMBOBOX IDC_WhereSource,96,6,169,12,CBS_SIMPLE | CBS_AUTOHSCROLL | @@ -104,10 +104,10 @@ BEGIN WS_VSCROLL | WS_TABSTOP CONTROL "Show Advanced Values",IDC_AdvancedValues,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,305,28,98,9 - DEFPUSHBUTTON "Configure",IDC_BuildProjects,110,219,51,15 - PUSHBUTTON "OK",IDC_OK,166,219,51,15 - PUSHBUTTON "Cancel",IDCANCEL,222,219,51,15 - PUSHBUTTON "Help",IDC_HELP_BUTTON,278,219,51,15 + DEFPUSHBUTTON "Configure",IDC_BuildProjects,84,221,51,15 + PUSHBUTTON "OK",IDC_OK,141,221,51,15 + PUSHBUTTON "Cancel",IDCANCEL,198,221,51,15 + PUSHBUTTON "Help",IDC_HELP_BUTTON,312,221,51,15 LISTBOX IDC_LIST2,15,53,419,126,LBS_SORT | LBS_OWNERDRAWVARIABLE | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL @@ -116,10 +116,11 @@ BEGIN IDC_MouseHelpCaption,0,191,442,27 LTEXT "Static",IDC_PROGRESS,2,240,442,12,SS_CENTERIMAGE | SS_SUNKEN + PUSHBUTTON "Delete Cache",IDC_DELETE_BUTTON,255,221,51,15 END -IDD_CMAKE_HELP_DIALOG DIALOG DISCARDABLE 0, 0, 365, 183 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +IDD_CMAKE_HELP_DIALOG DIALOG 0, 0, 365, 183 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "CMake Help" FONT 8, "MS Sans Serif" BEGIN @@ -129,7 +130,6 @@ BEGIN END -#ifndef _MAC ///////////////////////////////////////////////////////////////////////////// // // Version @@ -152,13 +152,13 @@ BEGIN BEGIN BLOCK "040904B0" BEGIN - VALUE "FileDescription", "CMakeSetup MFC Application\0" - VALUE "FileVersion", "1, 0, 0, 1\0" - VALUE "InternalName", "CMakeSetup\0" - VALUE "LegalCopyright", "Copyright (C) 2000\0" - VALUE "OriginalFilename", "CMakeSetup.EXE\0" - VALUE "ProductName", "CMakeSetup Application\0" - VALUE "ProductVersion", "1, 0, 0, 1\0" + VALUE "FileDescription", "CMakeSetup MFC Application" + VALUE "FileVersion", "1, 0, 0, 1" + VALUE "InternalName", "CMakeSetup" + VALUE "LegalCopyright", "Copyright (C) 2000" + VALUE "OriginalFilename", "CMakeSetup.EXE" + VALUE "ProductName", "CMakeSetup Application" + VALUE "ProductVersion", "1, 0, 0, 1" END END BLOCK "VarFileInfo" @@ -167,8 +167,6 @@ BEGIN END END -#endif // !_MAC - ///////////////////////////////////////////////////////////////////////////// // @@ -176,7 +174,7 @@ END // #ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO MOVEABLE PURE +GUIDELINES DESIGNINFO BEGIN IDD_ABOUTBOX, DIALOG BEGIN @@ -208,7 +206,7 @@ END // String Table // -STRINGTABLE DISCARDABLE +STRINGTABLE BEGIN IDS_ABOUTBOX "&About CMakeSetup..." IDS_CREATESHORTCUT "&Create shortcut" diff --git a/Source/MFCDialog/CMakeSetupDialog.cpp b/Source/MFCDialog/CMakeSetupDialog.cpp index 9b6c145..8298144 100644 --- a/Source/MFCDialog/CMakeSetupDialog.cpp +++ b/Source/MFCDialog/CMakeSetupDialog.cpp @@ -164,7 +164,7 @@ CMakeSetupDialog::CMakeSetupDialog(const CMakeCommandLineInfo& cmdInfo, m_CMakeInstance->SetProgressCallback(updateProgress, (void *)this); //{{AFX_DATA_INIT(CMakeSetupDialog) - //}}AFX_DATA_INIT + //}}AFX_DATA_INIT // Get the parameters from the command line info // If an unknown parameter is found, try to interpret it too, since it @@ -212,26 +212,27 @@ void CMakeSetupDialog::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CMakeSetupDialog) - DDX_Control(pDX, IDC_AdvancedValues, m_AdvancedValuesControl); - DDX_Control(pDX, IDC_BuildForLabel, m_BuildForLabel); - DDX_Control(pDX, IDC_BROWSE_SOURCE, m_BrowseSource); - DDX_Control(pDX, IDC_BROWSE_BUILD, m_BrowseBuild); - DDX_Control(pDX, IDC_HELP_BUTTON, m_HelpButton); - DDX_Control(pDX, IDC_Generator, m_GeneratorChoice); - DDX_Control(pDX, IDC_OK, m_OKButton); - DDX_Control(pDX, IDCANCEL, m_CancelButton); - DDX_CBStringExact(pDX, IDC_WhereSource, m_WhereSource); - DDX_CBStringExact(pDX, IDC_WhereBuild, m_WhereBuild); - DDX_Control(pDX, IDC_FRAME, m_ListFrame); - DDX_Control(pDX, IDC_WhereSource, m_WhereSourceControl); - DDX_Control(pDX, IDC_WhereBuild, m_WhereBuildControl); - DDX_Control(pDX, IDC_LIST2, m_CacheEntriesList); - DDX_Control(pDX, IDC_MouseHelpCaption, m_MouseHelp); - DDX_Control(pDX, IDC_PROGRESS, m_StatusDisplay); - DDX_Control(pDX, IDC_BuildProjects, m_Configure); - DDX_CBStringExact(pDX, IDC_Generator, m_GeneratorChoiceString); - DDX_Check(pDX, IDC_AdvancedValues, m_AdvancedValues); - //}}AFX_DATA_MAP + DDX_Control(pDX, IDC_AdvancedValues, m_AdvancedValuesControl); + DDX_Control(pDX, IDC_BuildForLabel, m_BuildForLabel); + DDX_Control(pDX, IDC_BROWSE_SOURCE, m_BrowseSource); + DDX_Control(pDX, IDC_BROWSE_BUILD, m_BrowseBuild); + DDX_Control(pDX, IDC_DELETE_BUTTON, m_DeleteButton); + DDX_Control(pDX, IDC_HELP_BUTTON, m_HelpButton); + DDX_Control(pDX, IDC_Generator, m_GeneratorChoice); + DDX_Control(pDX, IDC_OK, m_OKButton); + DDX_Control(pDX, IDCANCEL, m_CancelButton); + DDX_CBStringExact(pDX, IDC_WhereSource, m_WhereSource); + DDX_CBStringExact(pDX, IDC_WhereBuild, m_WhereBuild); + DDX_Control(pDX, IDC_FRAME, m_ListFrame); + DDX_Control(pDX, IDC_WhereSource, m_WhereSourceControl); + DDX_Control(pDX, IDC_WhereBuild, m_WhereBuildControl); + DDX_Control(pDX, IDC_LIST2, m_CacheEntriesList); + DDX_Control(pDX, IDC_MouseHelpCaption, m_MouseHelp); + DDX_Control(pDX, IDC_PROGRESS, m_StatusDisplay); + DDX_Control(pDX, IDC_BuildProjects, m_Configure); + DDX_CBStringExact(pDX, IDC_Generator, m_GeneratorChoiceString); + DDX_Check(pDX, IDC_AdvancedValues, m_AdvancedValues); + //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CMakeSetupDialog, CDialog) @@ -250,13 +251,14 @@ BEGIN_MESSAGE_MAP(CMakeSetupDialog, CDialog) ON_WM_GETMINMAXINFO() ON_BN_CLICKED(IDC_OK, OnOk) ON_CBN_EDITCHANGE(IDC_Generator, OnEditchangeGenerator) + ON_BN_CLICKED(IDC_DELETE_BUTTON, OnDeleteButton) ON_BN_CLICKED(IDC_HELP_BUTTON, OnHelpButton) ON_BN_CLICKED(IDC_AdvancedValues, OnAdvancedValues) ON_BN_DOUBLECLICKED(IDC_AdvancedValues, OnDoubleclickedAdvancedValues) ON_WM_DROPFILES() ON_BN_CLICKED(IDCANCEL, OnCancel) - ON_WM_SETCURSOR() - //}}AFX_MSG_MAP + ON_WM_SETCURSOR() + //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// @@ -305,8 +307,8 @@ BOOL CMakeSetupDialog::OnInitDialog() // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog - SetIcon(m_hIcon, TRUE); // Set big icon - SetIcon(m_hIcon, FALSE); // Set small icon + SetIcon(m_hIcon, TRUE); // Set big icon + SetIcon(m_hIcon, FALSE); // Set small icon // Load source and build dirs from registry this->LoadFromRegistry(); std::vector<std::string> names; @@ -438,9 +440,9 @@ void CMakeSetupDialog::SaveToRegistry() DWORD dwDummy; if(RegCreateKeyEx(HKEY_CURRENT_USER, - m_RegistryKey, - 0, "", REG_OPTION_NON_VOLATILE, KEY_READ|KEY_WRITE, - NULL, &hKey, &dwDummy) != ERROR_SUCCESS) + m_RegistryKey, + 0, "", REG_OPTION_NON_VOLATILE, KEY_READ|KEY_WRITE, + NULL, &hKey, &dwDummy) != ERROR_SUCCESS) { return; } @@ -540,7 +542,7 @@ void CMakeSetupDialog::ReadRegistryValue(HKEY hKey, pb = val->GetBuffer(MAX_PATH); dwSize = MAX_PATH; if(RegQueryValueEx(hKey,_T(key), NULL, &dwType, - (BYTE *)pb, &dwSize) != ERROR_SUCCESS) + (BYTE *)pb, &dwSize) != ERROR_SUCCESS) { val->ReleaseBuffer(); *val = _T(adefault); @@ -556,8 +558,8 @@ void CMakeSetupDialog::LoadFromRegistry() { HKEY hKey; if(RegOpenKeyEx(HKEY_CURRENT_USER, - m_RegistryKey, - 0, KEY_READ, &hKey) != ERROR_SUCCESS) + m_RegistryKey, + 0, KEY_READ, &hKey) != ERROR_SUCCESS) { return; } @@ -767,6 +769,7 @@ void CMakeSetupDialog::OnChangeWhereBuild() void CMakeSetupDialog::FillCacheGUIFromCacheManager() { cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager(); + cmCacheManager::CacheIterator it = cachem->NewIterator(); size_t size = m_CacheEntriesList.GetItems().size(); // if there are already entries in the cache, then // put the new ones in the top, so they show up first @@ -776,8 +779,17 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager() for(std::set<CPropertyItem*>::iterator i = items.begin(); i != items.end(); ++i) { + // first check to see if it is still in the cache CPropertyItem* item = *i; - item->m_NewValue = false; + if ( !it.Find((const char*)item->m_propName) ) + { + m_CacheEntriesList.RemoveProperty((const char*)item->m_propName); + } + else + { + // if it is still in the cache then it is no longer new + item->m_NewValue = false; + } } for(cmCacheManager::CacheIterator i = cachem->NewIterator(); !i.IsAtEnd(); i.Next()) @@ -842,7 +854,7 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager() ); break; case cmCacheManager::INTERNAL: - m_CacheEntriesList.RemoveProperty(key); + m_CacheEntriesList.RemoveProperty(key); break; } } @@ -913,7 +925,7 @@ void CMakeSetupDialog::FillCacheManagerFromCacheGUI() item->m_curValue[item->m_curValue.GetLength() - 1] == '\'') { it.SetValue(item->m_curValue.Mid( - 1, item->m_curValue.GetLength() - 2)); + 1, item->m_curValue.GetLength() - 2)); } else { @@ -1079,6 +1091,12 @@ void CMakeSetupDialog::OnSize(UINT nType, int cx, int cy) cRect.top + deltay, 0, 0, SWP_NOCOPYBITS | SWP_NOSIZE); + m_DeleteButton.GetWindowRect(&cRect); + this->ScreenToClient(&cRect); + m_DeleteButton.SetWindowPos(&wndTop, cRect.left + deltax/2, + cRect.top + deltay, + 0, 0, + SWP_NOCOPYBITS | SWP_NOSIZE); m_HelpButton.GetWindowRect(&cRect); this->ScreenToClient(&cRect); m_HelpButton.SetWindowPos(&wndTop, cRect.left + deltax/2, @@ -1112,8 +1130,8 @@ void CMakeSetupDialog::OnCancel() if(m_CacheEntriesList.IsDirty()) { if(MessageBox("You have changed options but not rebuilt, " - "are you sure you want to exit?", "Confirm Exit", - MB_YESNO) == IDYES) + "are you sure you want to exit?", "Confirm Exit", + MB_YESNO) == IDYES) { CDialog::OnOK(); } @@ -1138,8 +1156,8 @@ void CMakeSetupDialog::OnOk() void CMakeSetupDialog::OnEditchangeGenerator() { - // TODO: Add your control notification handler code here - + // TODO: Add your control notification handler code here + } @@ -1151,7 +1169,7 @@ int CMakeSetupDialog::CreateShortcut() HKEY hKey; if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", - 0, KEY_READ, &hKey) != ERROR_SUCCESS) + 0, KEY_READ, &hKey) != ERROR_SUCCESS) { AfxMessageBox ("Create shortcut: unable to find 'Shell Folders' key in registry!"); return 1; @@ -1280,6 +1298,19 @@ void CMakeSetupDialog::OnHelpButton() dialog.DoModal(); } +void CMakeSetupDialog::OnDeleteButton() +{ + if(m_WhereBuild != "" && this->m_CMakeInstance) + { + this->m_CMakeInstance->GetCacheManager()->DeleteCache(m_WhereBuild); + } + + // Make sure we are working from the cache on disk + this->LoadCacheFromDiskToGUI(); + + m_OKButton.EnableWindow(false); +} + void CMakeSetupDialog::ShowAdvancedValues() { m_CacheEntriesList.ShowAdvanced(); diff --git a/Source/MFCDialog/CMakeSetupDialog.h b/Source/MFCDialog/CMakeSetupDialog.h index a4a6983..3294b37 100644 --- a/Source/MFCDialog/CMakeSetupDialog.h +++ b/Source/MFCDialog/CMakeSetupDialog.h @@ -65,6 +65,7 @@ protected: CButton m_BrowseSource; CButton m_BrowseBuild; CButton m_HelpButton; + CButton m_DeleteButton; CComboBox m_GeneratorChoice; CButton m_OKButton; CButton m_CancelButton; @@ -123,6 +124,7 @@ protected: afx_msg void OnOk(); afx_msg void OnEditchangeGenerator(); afx_msg void OnHelpButton(); + afx_msg void OnDeleteButton(); afx_msg void OnAdvancedValues(); afx_msg void OnDoubleclickedAdvancedValues(); afx_msg void OnDropFiles(HDROP); diff --git a/Source/MFCDialog/resource.h b/Source/MFCDialog/resource.h index 2d35e8a..790102d 100644 --- a/Source/MFCDialog/resource.h +++ b/Source/MFCDialog/resource.h @@ -1,5 +1,5 @@ //{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. +// Microsoft Visual C++ generated include file. // Used by CMakeSetup.rc // #define IDM_ABOUTBOX 0x0010 @@ -26,6 +26,8 @@ #define IDC_Generator 1019 #define IDC_GeneratorLabel 1020 #define IDC_HELP_BUTTON 1021 +#define IDC_HELP_BUTTON2 1022 +#define IDC_DELETE_BUTTON 1022 #define IDC_EDIT1 1025 #define IDC_AdvancedValues 1027 #define IDC_PROGRESS 1028 diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index f77964f..01a3411 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -520,6 +520,14 @@ bool cmCacheManager::SaveCache(const char* path) return true; } +bool cmCacheManager::DeleteCache(const char* path) +{ + std::string cacheFile = path; + cacheFile += "/CMakeCache.txt"; + cmSystemTools::RemoveFile(cacheFile.c_str()); + return true; +} + void cmCacheManager::OutputHelpString(std::ofstream& fout, const std::string& helpString) { diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index 700c16e..3096ac2 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -111,6 +111,9 @@ public: ///! Save cache for given makefile. Saves to ouput path/CMakeCache.txt bool SaveCache(const char* path) ; + ///! Delete the cache given + bool DeleteCache(const char* path); + ///! Print the cache to a stream void PrintCache(std::ostream&) const; |