diff options
author | Sebastien Barre <sebastien.barre@kitware.com> | 2002-07-21 19:56:08 (GMT) |
---|---|---|
committer | Sebastien Barre <sebastien.barre@kitware.com> | 2002-07-21 19:56:08 (GMT) |
commit | 4a792ac1a4c751c17891197703df27f30a83bb2a (patch) | |
tree | 96ae357a6341894fb459068cb1d88e29b9f0127a /Source | |
parent | 4823f16ebb3644c4092fa74078e5b2c72d5a2c1a (diff) | |
download | CMake-4a792ac1a4c751c17891197703df27f30a83bb2a.zip CMake-4a792ac1a4c751c17891197703df27f30a83bb2a.tar.gz CMake-4a792ac1a4c751c17891197703df27f30a83bb2a.tar.bz2 |
ENH: add Drag & Drop (directory, file, or CMakeCache), support for Shortcut too
Diffstat (limited to 'Source')
-rw-r--r-- | Source/MFCDialog/CMakeCommandLineInfo.cpp | 25 | ||||
-rw-r--r-- | Source/MFCDialog/CMakeCommandLineInfo.h | 1 | ||||
-rw-r--r-- | Source/MFCDialog/CMakeSetupDialog.cpp | 94 | ||||
-rw-r--r-- | Source/MFCDialog/CMakeSetupDialog.h | 15 |
4 files changed, 110 insertions, 25 deletions
diff --git a/Source/MFCDialog/CMakeCommandLineInfo.cpp b/Source/MFCDialog/CMakeCommandLineInfo.cpp index 8ef3c43..f48de98 100644 --- a/Source/MFCDialog/CMakeCommandLineInfo.cpp +++ b/Source/MFCDialog/CMakeCommandLineInfo.cpp @@ -15,10 +15,11 @@ static char THIS_FILE[] = __FILE__; CMakeCommandLineInfo::CMakeCommandLineInfo() { - m_WhereSource = _T(""); - m_WhereBuild = _T(""); - m_AdvancedValues = FALSE; - m_GeneratorChoiceString = _T(""); + this->m_WhereSource = _T(""); + this->m_WhereBuild = _T(""); + this->m_AdvancedValues = FALSE; + this->m_GeneratorChoiceString = _T(""); + this->m_LastUnknownParameter = _T(""); } CMakeCommandLineInfo::~CMakeCommandLineInfo() @@ -50,7 +51,11 @@ int CMakeCommandLineInfo::GetBoolValue(const CString& v) { void CMakeCommandLineInfo::ParseParam(LPCTSTR lpszParam, BOOL bFlag, BOOL bLast) { - if(bFlag) + if(!bFlag) + { + this->m_LastUnknownParameter = lpszParam; + } + else { CString sParam(lpszParam); // Single letter valued flag like /B=value or /B:value @@ -70,21 +75,21 @@ void CMakeCommandLineInfo::ParseParam(LPCTSTR lpszParam, BOOL bFlag, BOOL bLast) res = CMakeCommandLineInfo::GetBoolValue(value); if (res == 1) { - m_AdvancedValues = TRUE; + this->m_AdvancedValues = TRUE; } else if (res == -1) { - m_AdvancedValues = FALSE; + this->m_AdvancedValues = FALSE; } break; case 'B': - m_WhereBuild = value; + this->m_WhereBuild = value; break; case 'G': - m_GeneratorChoiceString = value; + this->m_GeneratorChoiceString = value; break; case 'H': - m_WhereSource = value; + this->m_WhereSource = value; break; } } diff --git a/Source/MFCDialog/CMakeCommandLineInfo.h b/Source/MFCDialog/CMakeCommandLineInfo.h index e9e96b8..7fe0773 100644 --- a/Source/MFCDialog/CMakeCommandLineInfo.h +++ b/Source/MFCDialog/CMakeCommandLineInfo.h @@ -45,6 +45,7 @@ public: CString m_WhereBuild; BOOL m_AdvancedValues; CString m_GeneratorChoiceString; + CString m_LastUnknownParameter; // Operations public: diff --git a/Source/MFCDialog/CMakeSetupDialog.cpp b/Source/MFCDialog/CMakeSetupDialog.cpp index ea3611e..3b049a6 100644 --- a/Source/MFCDialog/CMakeSetupDialog.cpp +++ b/Source/MFCDialog/CMakeSetupDialog.cpp @@ -2,6 +2,7 @@ // #include "stdafx.h" +#include "shellapi.h" // a fun undef for DOT NET #undef DEBUG #include "CMakeSetup.h" @@ -82,15 +83,30 @@ CMakeSetupDialog::CMakeSetupDialog(const CMakeCommandLineInfo& cmdInfo, CWnd* pParent /*=NULL*/) : CDialog(CMakeSetupDialog::IDD, pParent) { - cmSystemTools::SetErrorCallback(MFCMessageCallback); + cmSystemTools::SetErrorCallback(MFCMessageCallback); m_RegistryKey = "Software\\Kitware\\CMakeSetup\\Settings\\StartPath"; //{{AFX_DATA_INIT(CMakeSetupDialog) - m_WhereSource = cmdInfo.m_WhereSource; - m_WhereBuild = cmdInfo.m_WhereBuild; - m_GeneratorChoiceString = cmdInfo.m_GeneratorChoiceString; - m_AdvancedValues = cmdInfo.m_AdvancedValues; + // Get the parameters from the command line info + // If an unknown parameter is found, try to interpret it too, since it + // is likely to be a file dropped on the shortcut :) + if (cmdInfo.m_LastUnknownParameter.IsEmpty()) + { + this->m_WhereSource = cmdInfo.m_WhereSource; + this->m_WhereBuild = cmdInfo.m_WhereBuild; + this->m_GeneratorChoiceString = cmdInfo.m_GeneratorChoiceString; + this->m_AdvancedValues = cmdInfo.m_AdvancedValues; + } + else + { + this->m_WhereSource = _T(""); + this->m_WhereBuild = _T(""); + this->m_AdvancedValues = FALSE; + this->m_GeneratorChoiceString = _T(""); + this->ChangeDirectoriesFromFile((LPCTSTR)cmdInfo.m_LastUnknownParameter); + } //}}AFX_DATA_INIT + // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); m_BuildPathChanged = false; @@ -101,7 +117,7 @@ CMakeSetupDialog::CMakeSetupDialog(const CMakeCommandLineInfo& cmdInfo, m_PathToExecutable = cmSystemTools::GetProgramPath(fname).c_str(); // add the cmake.exe to the path m_PathToExecutable += "/cmake.exe"; - + m_oldCX = -1; m_deltaXRemainder = 0; } @@ -133,6 +149,7 @@ BEGIN_MESSAGE_MAP(CMakeSetupDialog, CDialog) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() + ON_WM_DROPFILES() ON_BN_CLICKED(IDC_BUTTON2, OnBrowseWhereSource) ON_BN_CLICKED(IDC_BuildProjects, OnConfigure) ON_BN_CLICKED(IDC_BUTTON3, OnBrowseWhereBuild) @@ -157,6 +174,7 @@ END_MESSAGE_MAP() BOOL CMakeSetupDialog::OnInitDialog() { CDialog::OnInitDialog(); + this->DragAcceptFiles(true); // Add "Create shortcut" menu item to system menu. @@ -914,9 +932,6 @@ void CMakeSetupDialog::OnEditchangeGenerator() // Create a shortcut on the desktop with the current Source/Build dir. int CMakeSetupDialog::CreateShortcut() { - // m_WhereSource = cmdInfo.m_WhereSource; - // m_WhereBuild = cmdInfo.m_WhereBuild; - // Find the desktop folder and create the link name HKEY hKey; @@ -1152,3 +1167,64 @@ void CMakeSetupDialog::OnDoubleclickedAdvancedValues() { this->OnAdvancedValues(); } + +// Handle param or single dropped file. +// If it's a directory, use it as source and build dirs +// otherwise, if it's a CMakeCache, get source dir from cache +// otherwise use file's dir to set source and build dirs. + +void CMakeSetupDialog::ChangeDirectoriesFromFile(const char* buffer) +{ + std::string file = buffer; + if (cmSystemTools::FileIsDirectory(file.c_str())) + { + this->m_WhereSource = this->m_WhereBuild = file.c_str(); + } + else + { + std::string name = cmSystemTools::GetFilenameName(file); + std::string path = cmSystemTools::GetFilenamePath(file); + this->m_WhereBuild = path.c_str(); + + cmCacheManager *cache = cmCacheManager::GetInstance(); + if (name == "CMakeCache.txt" && + cache->LoadCache(path.c_str()) && + cache->GetCacheEntry("CMAKE_HOME_DIRECTORY")) + { + this->m_WhereSource = + cache->GetCacheEntry("CMAKE_HOME_DIRECTORY")->m_Value.c_str(); + } + else + { + this->m_WhereSource = path.c_str(); + } + } +} + +// The framework calls this member function when the user releases the +// left mouse button over a window that has registered itself as the +// recipient of dropped files. + +void CMakeSetupDialog::OnDropFiles(HDROP hDropInfo) +{ + UINT nb_files = DragQueryFile(hDropInfo, 0xFFFFFFFF, NULL, 0); + if (nb_files > 0) + { + UINT buffer_size = DragQueryFile(hDropInfo, 0, NULL, 0); + char *buffer = new char [buffer_size + 1]; + DragQueryFile(hDropInfo, 0, buffer, buffer_size + 1); + + this->ChangeDirectoriesFromFile(buffer); + delete [] buffer; + + this->m_WhereSourceControl.SetWindowText(this->m_WhereSource); + this->m_WhereBuildControl.SetWindowText(this->m_WhereBuild); + + this->UpdateData(FALSE); + + this->OnChangeWhereSource(); + this->OnChangeWhereBuild(); + } + + DragFinish(hDropInfo); +} diff --git a/Source/MFCDialog/CMakeSetupDialog.h b/Source/MFCDialog/CMakeSetupDialog.h index 7a21452..d0c5ac1 100644 --- a/Source/MFCDialog/CMakeSetupDialog.h +++ b/Source/MFCDialog/CMakeSetupDialog.h @@ -87,6 +87,8 @@ protected: void FillCacheManagerFromCacheGUI(); // Create a shortcut on the desktop with the current Source/Build dir. int CreateShortcut(); + // Handle param or single dropped file. + void ChangeDirectoriesFromFile(const char *file); HICON m_hIcon; CString m_RegistryKey; @@ -107,12 +109,13 @@ protected: afx_msg void OnSelendokWhereSource(); afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg void OnGetMinMaxInfo( MINMAXINFO FAR* lpMMI ); - afx_msg void OnOk(); - afx_msg void OnEditchangeGenerator(); - afx_msg void OnHelpButton(); - afx_msg void OnAdvancedValues(); - afx_msg void OnDoubleclickedAdvancedValues(); - //}}AFX_MSG + afx_msg void OnOk(); + afx_msg void OnEditchangeGenerator(); + afx_msg void OnHelpButton(); + afx_msg void OnAdvancedValues(); + afx_msg void OnDoubleclickedAdvancedValues(); + afx_msg void OnDropFiles(HDROP); + //}}AFX_MSG DECLARE_MESSAGE_MAP() int m_oldCX; |