diff options
author | Luis Ibanez <luis.ibanez@kitware.com> | 2001-06-10 22:21:55 (GMT) |
---|---|---|
committer | Luis Ibanez <luis.ibanez@kitware.com> | 2001-06-10 22:21:55 (GMT) |
commit | b0befbde1ae69c8625af763b0bb757557345c15b (patch) | |
tree | df28cced72496b83329488e3bb3cb84dea32fa31 | |
parent | ad0019a740413ad270df38232ddcb31120c1b540 (diff) | |
download | CMake-b0befbde1ae69c8625af763b0bb757557345c15b.zip CMake-b0befbde1ae69c8625af763b0bb757557345c15b.tar.gz CMake-b0befbde1ae69c8625af763b0bb757557345c15b.tar.bz2 |
ENH: cpp renamed cxx. Copy of data to and from the GUI is working
-rw-r--r-- | Source/FLTKDialog/CMakeSetupGUI.cxx | 133 | ||||
-rw-r--r-- | Source/FLTKDialog/CMakeSetupGUIImplementation.cxx | 343 | ||||
-rw-r--r-- | Source/FLTKDialog/FLTKDialog.cxx | 23 | ||||
-rw-r--r-- | Source/FLTKDialog/FLTKPropertyItemRow.cxx | 209 | ||||
-rw-r--r-- | Source/FLTKDialog/FLTKPropertyList.cxx | 201 |
5 files changed, 909 insertions, 0 deletions
diff --git a/Source/FLTKDialog/CMakeSetupGUI.cxx b/Source/FLTKDialog/CMakeSetupGUI.cxx new file mode 100644 index 0000000..91bb932 --- /dev/null +++ b/Source/FLTKDialog/CMakeSetupGUI.cxx @@ -0,0 +1,133 @@ +// generated by Fast Light User Interface Designer (fluid) version 1.0009 + +#include "CMakeSetupGUI.h" + +inline void CMakeSetupGUI::cb_sourcePathTextInput_i(Fl_Input*, void*) { + SetSourcePath( sourcePathTextInput->value() ); +} +void CMakeSetupGUI::cb_sourcePathTextInput(Fl_Input* o, void* v) { + ((CMakeSetupGUI*)(o->parent()->user_data()))->cb_sourcePathTextInput_i(o,v); +} + +inline void CMakeSetupGUI::cb_Browse_i(Fl_Button*, void*) { + BrowseForSourcePath(); +} +void CMakeSetupGUI::cb_Browse(Fl_Button* o, void* v) { + ((CMakeSetupGUI*)(o->parent()->user_data()))->cb_Browse_i(o,v); +} + +inline void CMakeSetupGUI::cb_binaryPathTextInput_i(Fl_Input*, void*) { + SetBinaryPath( binaryPathTextInput->value() ); +} +void CMakeSetupGUI::cb_binaryPathTextInput(Fl_Input* o, void* v) { + ((CMakeSetupGUI*)(o->parent()->user_data()))->cb_binaryPathTextInput_i(o,v); +} + +inline void CMakeSetupGUI::cb_Browse1_i(Fl_Button*, void*) { + BrowseForBinaryPath(); +} +void CMakeSetupGUI::cb_Browse1(Fl_Button* o, void* v) { + ((CMakeSetupGUI*)(o->parent()->user_data()))->cb_Browse1_i(o,v); +} + +inline void CMakeSetupGUI::cb_Close_i(Fl_Button*, void*) { + Close(); +} +void CMakeSetupGUI::cb_Close(Fl_Button* o, void* v) { + ((CMakeSetupGUI*)(o->parent()->user_data()))->cb_Close_i(o,v); +} + +inline void CMakeSetupGUI::cb_Build_i(Fl_Button*, void*) { + BuildProjectFiles(); +} +void CMakeSetupGUI::cb_Build(Fl_Button* o, void* v) { + ((CMakeSetupGUI*)(o->parent()->user_data()))->cb_Build_i(o,v); +} + +CMakeSetupGUI::CMakeSetupGUI() { + Fl_Window* w; + { Fl_Window* o = dialogWindow = new Fl_Window(563, 363, "CMakeSetupDialog"); + w = o; + o->user_data((void*)(this)); + { Fl_Input* o = sourcePathTextInput = new Fl_Input(219, 15, 200, 20, "Where is the source code: "); + o->labelsize(11); + o->textsize(11); + o->callback((Fl_Callback*)cb_sourcePathTextInput); + o->when(FL_WHEN_ENTER_KEY); + } + { Fl_Button* o = new Fl_Button(426, 14, 65, 22, "Browse..."); + o->shortcut(0x80073); + o->labelsize(11); + o->callback((Fl_Callback*)cb_Browse); + } + { Fl_Input* o = binaryPathTextInput = new Fl_Input(219, 50, 200, 20, "Where do you want to build the binaries: "); + o->labelsize(11); + o->textsize(11); + o->callback((Fl_Callback*)cb_binaryPathTextInput); + o->when(FL_WHEN_ENTER_KEY); + } + { Fl_Button* o = new Fl_Button(426, 50, 65, 22, "Browse..."); + o->shortcut(0x80062); + o->labelsize(11); + o->callback((Fl_Callback*)cb_Browse1); + } + { Fl_Button* o = new Fl_Button(345, 331, 77, 23, "Close"); + o->shortcut(0x80071); + o->labelsize(11); + o->callback((Fl_Callback*)cb_Close); + } + { Fl_Button* o = new Fl_Button(123, 332, 101, 23, "Build Project Files"); + o->shortcut(0x8006d); + o->labelsize(11); + o->callback((Fl_Callback*)cb_Build); + } + { Fl_Group* o = new Fl_Group(25, 80, 515, 222); + o->box(FL_ENGRAVED_BOX); + o->labelsize(11); + o->align(FL_ALIGN_CENTER); + { Fl_Scroll* o = cacheValuesScroll = new Fl_Scroll(40, 98, 485, 190, "Cache Values"); + o->type(7); + o->box(FL_DOWN_FRAME); + o->labelsize(11); + o->align(FL_ALIGN_TOP_LEFT); + o->when(FL_WHEN_CHANGED); + { Fl_Pack* o = propertyListPack = new Fl_Pack(40, 99, 485, 185); + o->end(); + Fl_Group::current()->resizable(o); + } + o->end(); + Fl_Group::current()->resizable(o); + } + o->end(); + Fl_Group::current()->resizable(o); + } + { Fl_Box* o = new Fl_Box(141, 305, 275, 25, "Right click on cache entries for additional options"); + o->labelsize(11); + } + o->end(); + } +} + +CMakeSetupGUI::~CMakeSetupGUI() { +} + +void CMakeSetupGUI::Close(void) { +} + +void CMakeSetupGUI::BuildProjectFiles(void) { +} + +void CMakeSetupGUI::BrowseForSourcePath(void) { +} + +void CMakeSetupGUI::BrowseForBinaryPath(void) { +} + +void CMakeSetupGUI::Show(void) { +} + +void CMakeSetupGUI::SetBinaryPath(const char *) { +} + +void CMakeSetupGUI::SetSourcePath(const char *) { +} diff --git a/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx b/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx new file mode 100644 index 0000000..330e1ac --- /dev/null +++ b/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx @@ -0,0 +1,343 @@ + +#include "CMakeSetupGUIImplementation.h" +#include "Fl/fl_file_chooser.H" +#include "Fl/filename.H" +#include "Fl/fl_ask.H" +#include "cstring" +#include "../cmCacheManager.h" +#include "../cmMakefile.h" +#include <iostream> + + + +/** + * Constructor + */ +CMakeSetupGUIImplementation +::CMakeSetupGUIImplementation() +{ +} + + + +/** + * Destructor + */ +CMakeSetupGUIImplementation +::~CMakeSetupGUIImplementation() +{ +} + + + + +/** + * Show the graphic interface + */ +void +CMakeSetupGUIImplementation +::Show( void ) +{ + dialogWindow->show(); +} + + + + + +/** + * Hide the graphic interface + */ +void +CMakeSetupGUIImplementation +::Close( void ) +{ + dialogWindow->hide(); +} + + + + + +/** + * Browse for the path to the sources + */ +void +CMakeSetupGUIImplementation +::BrowseForSourcePath( void ) +{ + const char * path = + fl_file_chooser( + "Path to Sources", + "", + sourcePathTextInput->value() ); + + if( !path ) + { + return; + } + + SetSourcePath( path ); + +} + + + + +/** + * Browse for the path to the binaries + */ +void +CMakeSetupGUIImplementation +::BrowseForBinaryPath( void ) +{ + const char * path = + fl_file_chooser( + "Path to Binaries", + "", + binaryPathTextInput->value() ); + + if( !path ) + { + return; + } + + SetBinaryPath( path ); + +} + + + + + +/** + * Set the source path + */ +void +CMakeSetupGUIImplementation +::SetSourcePath( const char * path ) +{ + if( VerifySourcePath( path ) ) + { + m_WhereSource = path; + sourcePathTextInput->value( path ); + } + +} + + + + +/** + * Set the binary path + */ +void +CMakeSetupGUIImplementation +::SetBinaryPath( const char * path ) +{ + + if( VerifyBinaryPath( path ) ) + { + m_WhereBuild = path; + binaryPathTextInput->value( path ); + } + + LoadCacheFromDiskToGUI(); + +} + + + +/** + * Verify the path to binaries + */ +bool +CMakeSetupGUIImplementation +::VerifyBinaryPath( const char * path ) +{ + + if( !path || strlen(path)==0 ) + { + fl_alert("Please select the path to the binaries"); + return false; + } + + + if( !filename_isdir( path ) ) + { + fl_alert("%s \n Doesn't exist or is not a directory",path); + return false; + } + + return true; +} + + + +/** + * Verify the path to sources + */ +bool +CMakeSetupGUIImplementation +::VerifySourcePath( const char * path ) +{ + + if( !path || strlen(path)==0 ) + { + fl_alert("Please select the path to the sources"); + return false; + } + + + if( !filename_isdir( path ) ) + { + fl_alert("%s \n Doesn't exist or is not a directory",path); + return false; + } + + return true; +} + + + + +/** + * Build the project files + */ +void +CMakeSetupGUIImplementation +::BuildProjectFiles( void ) +{ + + // Verify that source path is a valid directory + if( !VerifySourcePath( sourcePathTextInput->value() ) ) + { + return; + } + + // Verify that binary path is a valid directory + if( !VerifyBinaryPath( binaryPathTextInput->value() ) ) + { + return; + } + + SaveCacheFromGUI(); + + fl_message("Building project files ... please wait"); + +} + + + + +/** + * Load Cache from disk to GUI + */ +void +CMakeSetupGUIImplementation +::LoadCacheFromDiskToGUI( void ) +{ + + + if( m_WhereBuild != "" ) + { + cmCacheManager::GetInstance()->LoadCache( m_WhereBuild.c_str() ); + this->FillCacheGUIFromCacheManager(); + } +} + + +/** + * Save Cache from disk to GUI + */ +void +CMakeSetupGUIImplementation +::SaveCacheFromGUI( void ) +{ +} + + +/** + * Fill Cache GUI from cache manager + */ +void +CMakeSetupGUIImplementation +::FillCacheGUIFromCacheManager( void ) +{ + + // Prepare to add rows to the scroll + propertyListPack->begin(); + + const cmCacheManager::CacheEntryMap &cache = + cmCacheManager::GetInstance()->GetCacheMap(); + for(cmCacheManager::CacheEntryMap::const_iterator i = cache.begin(); + i != cache.end(); ++i) + { + const char* key = i->first.c_str(); + const cmCacheManager::CacheEntry& value = i->second; + + + switch(value.m_Type ) + { + case cmCacheManager::BOOL: + if(cmCacheManager::GetInstance()->IsOn(key)) + { + m_CacheEntriesList.AddProperty(key, + "ON", + value.m_HelpString.c_str(), + fltk::PropertyList::CHECKBOX,""); + } + else + { + m_CacheEntriesList.AddProperty(key, + "OFF", + value.m_HelpString.c_str(), + fltk::PropertyList::CHECKBOX,""); + } + break; + case cmCacheManager::PATH: + m_CacheEntriesList.AddProperty(key, + value.m_Value.c_str(), + value.m_HelpString.c_str(), + fltk::PropertyList::PATH,""); + break; + case cmCacheManager::FILEPATH: + m_CacheEntriesList.AddProperty(key, + value.m_Value.c_str(), + value.m_HelpString.c_str(), + fltk::PropertyList::FILE,""); + break; + case cmCacheManager::STRING: + m_CacheEntriesList.AddProperty(key, + value.m_Value.c_str(), + value.m_HelpString.c_str(), + fltk::PropertyList::EDIT,""); + break; + case cmCacheManager::INTERNAL: + break; + } + + } + + propertyListPack->end(); + propertyListPack->init_sizes(); + cacheValuesScroll->position( 0, 0 ); + + this->UpdateData(false); + +} + + +/** + * UpdateData + */ +void +CMakeSetupGUIImplementation +::UpdateData( bool option ) +{ + dialogWindow->redraw(); + Fl::check(); +} + + + diff --git a/Source/FLTKDialog/FLTKDialog.cxx b/Source/FLTKDialog/FLTKDialog.cxx new file mode 100644 index 0000000..5933ef5 --- /dev/null +++ b/Source/FLTKDialog/FLTKDialog.cxx @@ -0,0 +1,23 @@ + +#include "CMakeSetupGUIImplementation.h" +#include "FL/Fl.h" +#include "FL/fl_ask.H" + +int main() +{ + + fl_message_font(FL_HELVETICA,11); + + CMakeSetupGUIImplementation * gui + = new CMakeSetupGUIImplementation; + + gui->Show(); + gui->LoadCacheFromDiskToGUI(); + + Fl::run(); + + delete gui; + + return 0; + +} diff --git a/Source/FLTKDialog/FLTKPropertyItemRow.cxx b/Source/FLTKDialog/FLTKPropertyItemRow.cxx new file mode 100644 index 0000000..c55cd8b --- /dev/null +++ b/Source/FLTKDialog/FLTKPropertyItemRow.cxx @@ -0,0 +1,209 @@ +#include "FLTKPropertyItemRow.h" +#include <Fl/Fl_Button.H> +#include <Fl/Fl_Input.H> +#include <Fl/Fl_Tile.H> +#include <Fl/fl_ask.H> +#include <Fl/fl_file_chooser.H> + +namespace fltk { + +PropertyItemRow::PropertyItemRow( PropertyItem * pItem ) +{ + + m_PropertyItem = pItem; + m_ItemValue = new ItemValue; + + const unsigned int nameWidth = 200; + const unsigned int textWidth = 1400; + const unsigned int checkWidth = textWidth; + const unsigned int browseWidth = 20; + const unsigned int firstColumn = 0; + + const unsigned int secondColumn = nameWidth; + + const unsigned int rowHeight = 20; + const unsigned int rowSpacing = 20; + + Fl_Tile * group = new Fl_Tile(0,0,nameWidth+textWidth,rowHeight,""); + + group->parent()->size( nameWidth + textWidth , 100 ); + + Fl_Button * name = new + Fl_Button( firstColumn, 0, nameWidth, rowHeight, + pItem->m_propName.c_str() ); + name->align( FL_ALIGN_CLIP | FL_ALIGN_LEFT | FL_ALIGN_INSIDE ); + name->labelsize(11); + name->box( FL_DOWN_BOX ); + name->callback( NameClickCallback, (void *)pItem ); + + switch( pItem->m_nItemType ) + { + case 1: + { + + name->size( secondColumn, rowHeight ); + + Fl_Input * input = new + Fl_Input( secondColumn, 0, textWidth ,rowHeight ,""); + input->value( pItem->m_curValue.c_str() ); + input->textsize(11); + input->callback( InputTextCallback, (void *)pItem ); + input->when( FL_WHEN_CHANGED ); + + break; + } + case 2: + { + break; + } + case 3: + { + break; + } + case 4: + { + + name->size( secondColumn, rowHeight ); + Fl_Button * browseButton = new + Fl_Button( secondColumn, 0, browseWidth ,rowHeight ,"..."); + browseButton->labelsize(11); + + Fl_Input * input = new + Fl_Input( secondColumn+browseWidth, 0, textWidth ,rowHeight ,""); + input->value( pItem->m_curValue.c_str() ); + input->textsize(11); + + m_ItemValue->m_InputText = input; + m_ItemValue->m_PropertyItem = pItem; + + browseButton->callback( BrowsePathCallback, (void *)m_ItemValue ); + input->callback( InputTextCallback, pItem ); + input->when( FL_WHEN_CHANGED ); + + break; + } + case 5: + { + Fl_Button * button = new + Fl_Button( secondColumn, 0, checkWidth ,rowHeight ,""); + button->align( FL_ALIGN_INSIDE | FL_ALIGN_LEFT ); + button->callback( CheckButtonCallback, (void *)pItem ); + + if( pItem->m_curValue == "ON" ) + { + button->label(" ON "); + button->value(1); + } + else if( pItem->m_curValue == "OFF" ) + { + button->label(" OFF "); + button->value(0); + } + button->type( FL_TOGGLE_BUTTON ); + button->labelsize(11); + break; + } + case 6: + { + + name->size( secondColumn, rowHeight ); + Fl_Button * browseButton = new + Fl_Button( secondColumn, 0, browseWidth ,rowHeight ,"..."); + browseButton->labelsize(11); + + Fl_Input * input = new + Fl_Input( secondColumn+browseWidth, 0, textWidth ,rowHeight ,""); + input->value( pItem->m_curValue.c_str() ); + input->textsize(11); + + m_ItemValue->m_InputText = input; + m_ItemValue->m_PropertyItem = pItem; + + browseButton->callback( BrowsePathCallback, (void *)m_ItemValue ); + input->callback( InputTextCallback, pItem ); + input->when( FL_WHEN_CHANGED ); + + break; + } + break; + default: + fl_alert("Unkown item type %d",pItem->m_nItemType); + break; + } + + + group->end(); + +} + + +PropertyItemRow::~PropertyItemRow( ) +{ + delete m_ItemValue; +} + + +void +PropertyItemRow:: +CheckButtonCallback( Fl_Widget * widget, void * data) +{ + Fl_Button * button = (Fl_Button *)widget; + PropertyItem * pItem = (PropertyItem *)data; + + int value = button->value(); + + if( value ) + { + button->label(" ON "); + pItem->m_curValue = "ON"; + } + else + { + button->label(" OFF "); + pItem->m_curValue = "OFF"; + } + button->redraw(); +} + + +void +PropertyItemRow:: +NameClickCallback( Fl_Widget * widget, void * data) +{ + PropertyItem * pItem = (PropertyItem *)data; + fl_message( pItem->m_HelpString.c_str() ); +} + +void +PropertyItemRow:: +InputTextCallback( Fl_Widget * widget, void * data) +{ + Fl_Input * input = (Fl_Input *)widget; + PropertyItem * item = (PropertyItem *)data; + + item->m_curValue = input->value(); + +} + +void +PropertyItemRow:: +BrowsePathCallback( Fl_Widget * widget, void * data) +{ + ItemValue * itemValue = (ItemValue *)data; + Fl_Input * inputText = itemValue->m_InputText; + PropertyItem * propertyItem = itemValue->m_PropertyItem; + + const char * newpath = + fl_file_chooser("Select a path","*", inputText->value() ); + + if( newpath ) + { + propertyItem->m_curValue = newpath; + inputText->value( newpath ); + } + +} + + + +} // end namespace fltk diff --git a/Source/FLTKDialog/FLTKPropertyList.cxx b/Source/FLTKDialog/FLTKPropertyList.cxx new file mode 100644 index 0000000..7efbf24 --- /dev/null +++ b/Source/FLTKDialog/FLTKPropertyList.cxx @@ -0,0 +1,201 @@ +// FLTKPropertyList.cxx : implementation file +// + +#include "FLTKPropertyList.h" +#include "../cmCacheManager.h" +#include "FLTKPropertyItemRow.h" +#include "Fl/filename.H" +#include "Fl/fl_file_chooser.H" +#include "Fl/Fl_Color_Chooser.H" +#include "Fl/fl_ask.H" +#include "Fl/Fl_Button.H" +#include <cstdio> + +namespace fltk { + +///////////////////////////////////////////////////////////////////////////// +// PropertyList + +PropertyList::PropertyList() +{ + m_Dirty = false; + m_curSel = -1; +} + +PropertyList::~PropertyList() +{ + for(std::set<PropertyItem*>::iterator i = m_PropertyItems.begin(); + i != m_PropertyItems.end(); ++i) + { + delete *i; + } +} + + + + +int PropertyList::AddItem(string txt) +{ + int nIndex =0;// = AddString(txt); + return nIndex; +} + +int PropertyList::AddPropItem(PropertyItem* pItem) +{ + + int nIndex =0; //= AddString(_T("")); + // SetItemDataPtr(nIndex,pItem); + + new PropertyItemRow( pItem ); // GUI of the property row + + m_PropertyItems.insert(pItem); + + return nIndex; +} + +int PropertyList::AddProperty(const char* name, + const char* value, + const char* helpString, + int type, + const char* comboItems) +{ + + PropertyItem* pItem = 0; + for(int i =0; i < this->GetCount(); ++i) + { + PropertyItem* item = this->GetItem(i); + if(item->m_propName == name) + { + pItem = item; + if(pItem->m_curValue != value) + { + pItem->m_curValue = value; + pItem->m_HelpString = helpString; + m_Dirty = true; + Invalidate(); + } + return i; + } + } + // if it is not found, then create a new one + if(!pItem) + { + pItem = new PropertyItem(name, value, helpString, type, comboItems); + } + return this->AddPropItem(pItem); +} + + + + +void PropertyList::OnButton() +{ + PropertyItem* pItem = (PropertyItem*) GetItemDataPtr(m_curSel); + + //display the appropriate common dialog depending on what type + //of chooser is associated with the property + if (pItem->m_nItemType == PropertyList::COLOR) + { + unsigned char red = 0; + unsigned char blue = 0; + unsigned char green = 0; + fl_color_chooser("Please pick a color",red,green,blue); + char buffer[300]; + sprintf(buffer,"RGB(%d,%d,%d)",red,green,blue); + pItem->m_curValue = buffer; + m_Dirty = true; + Invalidate(); + } + else if (pItem->m_nItemType == PropertyList::FILE) + { + string currPath = pItem->m_curValue; + + const char * SelectedFile + = fl_file_chooser("Choose a file", + "*",currPath.c_str() ); + + if( SelectedFile ) + { + pItem->m_curValue = SelectedFile; + m_Dirty = true; + Invalidate(); + } + } + else if (pItem->m_nItemType == PropertyList::PATH) + { + string currPath = pItem->m_curValue; + string initialDir = currPath; + + const char * SelectedFile + = fl_file_chooser("Choose a directory", + "*/",initialDir.c_str() ); + + if( SelectedFile && filename_isdir( SelectedFile ) ) + { + pItem->m_curValue = SelectedFile; + m_Dirty = true; + Invalidate(); + } + } + else if (pItem->m_nItemType == PropertyList::FONT) + { + } +} + + + + +void PropertyList::OnHelp() +{ + if(m_curSel == -1 || this->GetCount() <= 0) + { + return; + } + PropertyItem* pItem = (PropertyItem*) GetItemDataPtr(m_curSel); + fl_message(pItem->m_HelpString.c_str()); +} + + +void PropertyList::RemoveAll() +{ + int c = this->GetCount(); + for(int i =0; i < c; ++i) + { + PropertyItem* pItem = (PropertyItem*) GetItemDataPtr(0); + cmCacheManager::GetInstance()->RemoveCacheEntry(pItem->m_propName.c_str()); + m_PropertyItems.erase(pItem); + delete pItem; + // this->DeleteString(0); + } + Invalidate(); +} + + + +PropertyItem * PropertyList::GetItemDataPtr(int index) +{ + std::set<PropertyItem*>::iterator it = m_PropertyItems.begin(); + for(int i=0; it != m_PropertyItems.end() && i<index; i++) + { + ++it; + } + return *it; +} + + +PropertyItem * PropertyList::GetItem(int index) +{ + std::set<PropertyItem*>::iterator it = m_PropertyItems.begin(); + for(int i=0; it != m_PropertyItems.end() && i<index; i++) + { + ++it; + } + return *it; +} + + + +} // end fltk namespace + + + |