diff options
author | Luis Ibanez <luis.ibanez@kitware.com> | 2001-06-12 12:34:29 (GMT) |
---|---|---|
committer | Luis Ibanez <luis.ibanez@kitware.com> | 2001-06-12 12:34:29 (GMT) |
commit | d0614d75ea2fa259bed8e48226f85b0f5553cfb5 (patch) | |
tree | 55b6f78b2428f0640c82695476cf21266e6d17b6 /Source/FLTKDialog | |
parent | 522ff0204a48774d42f9a1de4d2ab9530f0f6994 (diff) | |
download | CMake-d0614d75ea2fa259bed8e48226f85b0f5553cfb5.zip CMake-d0614d75ea2fa259bed8e48226f85b0f5553cfb5.tar.gz CMake-d0614d75ea2fa259bed8e48226f85b0f5553cfb5.tar.bz2 |
ENH: Paths are now expanded for environment variables and made absolute.
The binary directory is created if it doesn't exist.
Diffstat (limited to 'Source/FLTKDialog')
-rw-r--r-- | Source/FLTKDialog/CMakeSetupGUI.cxx | 4 | ||||
-rw-r--r-- | Source/FLTKDialog/CMakeSetupGUI.fl | 8 | ||||
-rw-r--r-- | Source/FLTKDialog/CMakeSetupGUI.h | 4 | ||||
-rw-r--r-- | Source/FLTKDialog/CMakeSetupGUIImplementation.cxx | 131 | ||||
-rw-r--r-- | Source/FLTKDialog/CMakeSetupGUIImplementation.h | 11 | ||||
-rw-r--r-- | Source/FLTKDialog/FLTKPropertyItemRow.cxx | 3 |
6 files changed, 109 insertions, 52 deletions
diff --git a/Source/FLTKDialog/CMakeSetupGUI.cxx b/Source/FLTKDialog/CMakeSetupGUI.cxx index 91bb932..7855d36 100644 --- a/Source/FLTKDialog/CMakeSetupGUI.cxx +++ b/Source/FLTKDialog/CMakeSetupGUI.cxx @@ -126,8 +126,8 @@ void CMakeSetupGUI::BrowseForBinaryPath(void) { void CMakeSetupGUI::Show(void) { } -void CMakeSetupGUI::SetBinaryPath(const char *) { +bool CMakeSetupGUI::SetBinaryPath(const char *) { } -void CMakeSetupGUI::SetSourcePath(const char *) { +bool CMakeSetupGUI::SetSourcePath(const char *) { } diff --git a/Source/FLTKDialog/CMakeSetupGUI.fl b/Source/FLTKDialog/CMakeSetupGUI.fl index 07b0d37..a62adbc 100644 --- a/Source/FLTKDialog/CMakeSetupGUI.fl +++ b/Source/FLTKDialog/CMakeSetupGUI.fl @@ -25,7 +25,7 @@ class CMakeSetupGUI {open } Fl_Input binaryPathTextInput { label {Where do you want to build the binaries: } - callback {SetBinaryPath( binaryPathTextInput->value() );} + callback {SetBinaryPath( binaryPathTextInput->value() );} selected xywh {219 50 200 20} labelsize 11 when 8 textsize 11 } Fl_Button {} { @@ -50,7 +50,7 @@ class CMakeSetupGUI {open label {Cache Values} open xywh {40 98 485 190} type BOTH_ALWAYS box DOWN_FRAME labelsize 11 align 5 when 1 resizable } { - Fl_Pack propertyListPack {selected + Fl_Pack propertyListPack { xywh {40 99 485 185} resizable } {} } @@ -72,8 +72,8 @@ class CMakeSetupGUI {open } {} Function {Show(void)} {return_type {virtual void} } {} - Function {SetBinaryPath(const char *)} {return_type {virtual void} + Function {SetBinaryPath(const char *)} {return_type {virtual bool} } {} - Function {SetSourcePath(const char *)} {return_type {virtual void} + Function {SetSourcePath(const char *)} {return_type {virtual bool} } {} } diff --git a/Source/FLTKDialog/CMakeSetupGUI.h b/Source/FLTKDialog/CMakeSetupGUI.h index c3dc3eb..1a35110 100644 --- a/Source/FLTKDialog/CMakeSetupGUI.h +++ b/Source/FLTKDialog/CMakeSetupGUI.h @@ -41,7 +41,7 @@ public: virtual void BrowseForSourcePath(void); virtual void BrowseForBinaryPath(void); virtual void Show(void); - virtual void SetBinaryPath(const char *); - virtual void SetSourcePath(const char *); + virtual bool SetBinaryPath(const char *); + virtual bool SetSourcePath(const char *); }; #endif diff --git a/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx b/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx index 4f5d0b4..2ade1eb 100644 --- a/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx +++ b/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx @@ -21,10 +21,9 @@ CMakeSetupGUIImplementation { m_BuildPathChanged = false; char fname[1024]; - //::GetModuleFileName(NULL,fname,1023); + //::GetModuleFileName(NULL,fname,1023); // Didn't found this method. (?) m_PathToExecutable = cmSystemTools::GetProgramPath(fname).c_str(); m_PathToExecutable += "/cmake.exe"; - std::cout << "Path to executable = " << m_PathToExecutable << std::endl; } @@ -122,89 +121,142 @@ CMakeSetupGUIImplementation /** * Set the source path */ -void +bool CMakeSetupGUIImplementation ::SetSourcePath( const char * path ) { - if( VerifySourcePath( path ) ) + + if( !path || strlen(path)==0 ) + { + fl_alert("Please select the path to the sources"); + return false; + } + + string expandedAbsolutePath = ExpandPathAndMakeItAbsolute( path ); + + sourcePathTextInput->value( expandedAbsolutePath.c_str() ); + + if( VerifySourcePath( expandedAbsolutePath ) ) { - m_WhereSource = path; - sourcePathTextInput->value( path ); + m_WhereSource = expandedAbsolutePath; + return true; } + return false; + } /** - * Set the binary path + * Expand environment variables in the path and make it absolute */ -void +string CMakeSetupGUIImplementation -::SetBinaryPath( const char * path ) +::ExpandPathAndMakeItAbsolute( const string & inputPath ) const { - if( VerifyBinaryPath( path ) ) - { - if( m_WhereBuild != path ) - { - m_BuildPathChanged = true; - m_WhereBuild = path; - } - binaryPathTextInput->value( path ); - } + char expandedPath[3000]; + filename_expand( expandedPath, inputPath.c_str() ); - LoadCacheFromDiskToGUI(); + char absolutePath[3000]; + filename_absolute( absolutePath, expandedPath ); + + string expandedAbsolutePath = absolutePath; + return expandedAbsolutePath; + } - /** - * Verify the path to binaries + * Set the binary path */ bool CMakeSetupGUIImplementation -::VerifyBinaryPath( const char * path ) +::SetBinaryPath( const char * path ) { if( !path || strlen(path)==0 ) { fl_alert("Please select the path to the binaries"); - return false; + return false; } + string expandedAbsolutePath = ExpandPathAndMakeItAbsolute( path ); + + binaryPathTextInput->value( expandedAbsolutePath.c_str() ); + + if( !VerifyBinaryPath( expandedAbsolutePath.c_str() ) ) + { + return false; + } - if( !filename_isdir( path ) ) + if( m_WhereBuild != expandedAbsolutePath ) { - fl_alert("%s \n Doesn't exist or is not a directory",path); - return false; + m_BuildPathChanged = true; + m_WhereBuild = expandedAbsolutePath; } + + LoadCacheFromDiskToGUI(); return true; + } /** - * Verify the path to sources + * Verify the path to binaries */ bool CMakeSetupGUIImplementation -::VerifySourcePath( const char * path ) +::VerifyBinaryPath( const string & path ) const { - if( !path || strlen(path)==0 ) + bool pathIsOK = false; + + if( filename_isdir( path.c_str() ) ) { - fl_alert("Please select the path to the sources"); - return false; + pathIsOK = true; + } + else + { + int userWantsToCreateDirectory = + fl_ask("The directory \n %s \n Doesn't exist. Do you want to create it ?", + path.c_str() ); + + if( userWantsToCreateDirectory ) + { + string command = "mkdir "; + command += path; + system( command.c_str() ); + pathIsOK = true; + } + else + { + pathIsOK = false; + } } + return pathIsOK; - if( !filename_isdir( path ) ) +} + + + +/** + * Verify the path to sources + */ +bool +CMakeSetupGUIImplementation +::VerifySourcePath( const string & path ) const +{ + + if( !filename_isdir( path.c_str() ) ) { - fl_alert("%s \n Doesn't exist or is not a directory",path); + fl_alert("The Source directory \n %s \n Doesn't exist or is not a directory", path.c_str() ); return false; } @@ -222,17 +274,18 @@ CMakeSetupGUIImplementation ::BuildProjectFiles( void ) { - // Verify that source path is a valid directory - if( !VerifySourcePath( sourcePathTextInput->value() ) ) + // Take and verify the source path from the GUI + if( !SetSourcePath( sourcePathTextInput->value() ) ) { return; } - - // Verify that binary path is a valid directory - if( !VerifyBinaryPath( binaryPathTextInput->value() ) ) - { + + // Take and verify the binary path from the GUI + if( !SetBinaryPath( binaryPathTextInput->value() ) ) + { return; } + SaveCacheFromGUI(); diff --git a/Source/FLTKDialog/CMakeSetupGUIImplementation.h b/Source/FLTKDialog/CMakeSetupGUIImplementation.h index d0f8021..a7275b9 100644 --- a/Source/FLTKDialog/CMakeSetupGUIImplementation.h +++ b/Source/FLTKDialog/CMakeSetupGUIImplementation.h @@ -26,15 +26,18 @@ public: virtual void BuildProjectFiles( void ); virtual void BrowseForBinaryPath( void ); virtual void BrowseForSourcePath( void ); - virtual void SetBinaryPath( const char * path ); - virtual void SetSourcePath( const char * path ); - virtual bool VerifyBinaryPath( const char * path ); - virtual bool VerifySourcePath( const char * path ); + virtual bool SetBinaryPath( const char * path ); + virtual bool SetSourcePath( const char * path ); virtual void SaveCacheFromGUI( void ); virtual void LoadCacheFromDiskToGUI( void ); virtual void FillCacheGUIFromCacheManager( void ); virtual void FillCacheManagerFromCacheGUI( void ); +private: + virtual bool VerifyBinaryPath( const string & path ) const; + virtual bool VerifySourcePath( const string & path ) const; + virtual string ExpandPathAndMakeItAbsolute( const string & inputPath ) const; + private: fltk::PropertyList m_CacheEntriesList; std::string m_WhereBuild; diff --git a/Source/FLTKDialog/FLTKPropertyItemRow.cxx b/Source/FLTKDialog/FLTKPropertyItemRow.cxx index c55cd8b..e5607a4 100644 --- a/Source/FLTKDialog/FLTKPropertyItemRow.cxx +++ b/Source/FLTKDialog/FLTKPropertyItemRow.cxx @@ -26,7 +26,8 @@ PropertyItemRow::PropertyItemRow( PropertyItem * pItem ) Fl_Tile * group = new Fl_Tile(0,0,nameWidth+textWidth,rowHeight,""); - group->parent()->size( nameWidth + textWidth , 100 ); + // Make the parent Fl_Pack widget at least a row wide. + group->parent()->size( nameWidth + textWidth , rowHeight ); Fl_Button * name = new Fl_Button( firstColumn, 0, nameWidth, rowHeight, |