Feature: Auto include in corresponding CMakeLists files when creating: Libraries, Applications, Packages.
Feature: Checkboxes to include in CMakeLists files for: Libraries, Application, Packages.
#define ID_LINK_SELECT_APPLICATION 10332
#define ID_LINK_SELECT_BLACKBOX 10333
-#define ID_CHECKBOX_ENABLE_HELP 10334
-#define ID_CHECKBOX_DISABLE_HELP 10335
-#define ID_CHECKBOX_TOGGLE_HELP 10335
+#define ID_CHECK_INCLUDE_LIBRARY 10334
+#define ID_CHECK_INCLUDE_PACKAGE 10335
+#define ID_CHECK_INCLUDE_APPLICATION 10336
-#define ID_BUTTON_CHECK_PROJECT 10336
+#define ID_CHECKBOX_ENABLE_HELP 10337
+#define ID_CHECKBOX_DISABLE_HELP 10338
+#define ID_CHECKBOX_TOGGLE_HELP 10339
+
+#define ID_BUTTON_CHECK_PROJECT 10340
#endif /* CREADEVMANAGERIDS_H_ */
return NULL;
}
+ //add application to appli CMakeLists
+ std::fstream out1((this->path + CDMUtilities::SLASH + "CMakeLists.txt").c_str(), std::fstream::in | std::fstream::out | std::fstream::app);
+ if (out1.is_open())
+ {
+ out1 << "ADD_SUBDIRECTORY(" << name << ")" << std::endl;
+ out1.close();
+ }
+
//add application to model
modelCDMApplication* application = new modelCDMApplication(this, this->path + CDMUtilities::SLASH + name, name, this->level + 1);
this->applications.push_back(application);
return NULL;
}
+ //add application to appli CMakeLists
+ std::fstream out1((this->path + CDMUtilities::SLASH + "CMakeLists.txt").c_str(), std::fstream::in | std::fstream::out | std::fstream::app);
+ if (out1.is_open())
+ {
+ out1 << "ADD_SUBDIRECTORY(" << name << ")" << std::endl;
+ out1.close();
+ }
+
//add application to model
modelCDMApplication* application = new modelCDMApplication(this, this->path + CDMUtilities::SLASH + name, name, this->level + 1);
this->applications.push_back(application);
this->applications[i]->CheckStructure(properties);
}
}
+
+bool modelCDMAppli::IsApplicationIncluded(const std::string& application_name)
+{
+ if(this->HasCMakeLists())
+ {
+ std::ifstream CMFile(this->CMakeLists->GetPath().c_str());
+ if (CMFile.is_open())
+ {
+ std::string line;
+ while(!CMFile.eof())
+ {
+ std::getline(CMFile, line);
+ while(line[0]==' ')
+ line.erase(0);
+ if(line[0] != '#')
+ {
+ std::vector<std::string> lineSeg;
+ CDMUtilities::splitter::split(lineSeg,line,"()",CDMUtilities::splitter::no_empties);
+ if(lineSeg.size() > 0 && lineSeg[0] == "ADD_SUBDIRECTORY" && lineSeg[1] == application_name)
+ {
+ CMFile.close();
+ return true;
+ }
+ }
+ }
+ CMFile.close();
+ }
+ }
+ return false;
+}
+
+bool modelCDMAppli::SetApplicationInclude(const std::string& application_name, const bool& toInclude)
+{
+ if (this->HasCMakeLists())
+ {
+ std::ifstream CMFile(this->CMakeLists->GetPath().c_str());
+ if (CMFile.is_open())
+ {
+ std::stringstream outs;
+ std::string line;
+ bool found = false;
+ while(!CMFile.eof())
+ {
+ std::getline(CMFile, line);
+ if(line != "")
+ {
+ std::vector<std::string> segs;
+ CDMUtilities::splitter::split(segs, line, " ", CDMUtilities::splitter::no_empties);
+ //is comment
+ if(segs.size() > 0 && segs[0][0] == '#')
+ {
+ if(toInclude)
+ {
+ CDMUtilities::splitter::split(segs, line, " #()", CDMUtilities::splitter::no_empties);
+ if (segs.size() > 1 && segs[0] == "ADD_SUBDIRECTORY" && segs[1] == application_name)
+ {
+ found = true;
+ outs << "ADD_SUBDIRECTORY(" << application_name << ")\n";
+ }
+ else
+ outs << line << "\n";
+ }
+ else
+ {
+ outs << line << "\n";
+ }
+ }
+ //is not comment
+ else
+ {
+ if (segs.size() > 0 && !toInclude)
+ {
+ CDMUtilities::splitter::split(segs, line, " ()", CDMUtilities::splitter::no_empties);
+ if (segs.size() > 1 && segs[0] == "ADD_SUBDIRECTORY" && segs[1] == application_name)
+ {
+ outs << "#" << line << "\n";
+ }
+ else
+ {
+ outs << line << "\n";
+ }
+ }
+ else
+ {
+ CDMUtilities::splitter::split(segs, line, " ()", CDMUtilities::splitter::no_empties);
+ if (segs.size() > 1 && segs[0] == "ADD_SUBDIRECTORY" && segs[1] == application_name)
+ {
+ found = true;
+ }
+ outs << line << "\n";
+ }
+ }
+ }
+ else
+ {
+ outs << "\n";
+ }
+ }
+
+ CMFile.close();
+
+ if(!found && toInclude)
+ outs << "ADD_SUBDIRECTORY(" << application_name << ")\n";
+
+ std::ofstream CMFileOut(this->CMakeLists->GetPath().c_str());
+ if (CMFileOut.is_open())
+ {
+ CMFileOut << outs.rdbuf();
+ CMFileOut.close();
+ return true;
+ }
+ }
+ }
+ return false;
+}
const std::vector<modelCDMApplication*>& GetApplications() const;
/**
- * Creates a new application in the system and creates an application node. This node is stored in the applications attribute and returned.
+ * Creates a new application in the system and creates an application node. This node is stored in the applications attribute and returned. The created application is included in the appli's CMakeLists file.
* @param name Name of the new application.
* @param type 0=console application, 1=GUI Application (wxWidgets).
* @param result Result message of the operation.
*/
void CheckStructure(std::map<std::string, bool>& properties);
+ /**
+ * Checks if the given application is included in the CMakeLists file.
+ * @param application_name Name of the library to check.
+ * @return True if the library is included, otherwise returns False.
+ */
+ bool IsApplicationIncluded(const std::string& application_name);
+
+ /**
+ * Sets the inclusion of the application in the lib's CMakeLists file. If the application inclusion already exist in file, then the line is uncommented/commented depending on the requested action. If the application inclusion doesn't exist yet, then it is included if the request is an inclusion.
+ * @param application_name Name of the application to include/exclude.
+ * @param toInclude True if the request is an inclusion, False otherwise.
+ * @return True if the request was processed successfully.
+ */
+ bool SetApplicationInclude(const std::string& application_name, const bool& toInclude);
+
private:
/**
* application in the appli folder node.
return NULL;
}
+ //add library to lib CMakeLists
+ std::fstream out1((this->path + CDMUtilities::SLASH + "CMakeLists.txt").c_str(), std::fstream::in | std::fstream::out | std::fstream::app);
+ if (out1.is_open())
+ {
+ out1 << "ADD_SUBDIRECTORY(" << name << ")" << std::endl;
+ out1.close();
+ }
+
+
//add library to model
modelCDMLibrary* library = new modelCDMLibrary(this, this->path + CDMUtilities::SLASH + name, name, this->level + 1);
this->libraries.push_back(library);
this->libraries[i]->CheckStructure(properties);
}
}
+
+bool modelCDMLib::IsLibraryIncluded(const std::string& library_name)
+{
+ if(this->HasCMakeLists())
+ {
+ std::ifstream CMFile(this->CMakeLists->GetPath().c_str());
+ if (CMFile.is_open())
+ {
+ std::string line;
+ while(!CMFile.eof())
+ {
+ std::getline(CMFile, line);
+ while(line[0]==' ')
+ line.erase(0);
+ if(line[0] != '#')
+ {
+ std::vector<std::string> lineSeg;
+ CDMUtilities::splitter::split(lineSeg,line,"()",CDMUtilities::splitter::no_empties);
+ if(lineSeg.size() > 0 && lineSeg[0] == "ADD_SUBDIRECTORY" && lineSeg[1] == library_name)
+ {
+ CMFile.close();
+ return true;
+ }
+ }
+ }
+ CMFile.close();
+ }
+ }
+ return false;
+}
+
+bool modelCDMLib::SetLibraryInclude(const std::string& library_name, const bool& toInclude)
+{
+ if (this->HasCMakeLists())
+ {
+ std::ifstream CMFile(this->CMakeLists->GetPath().c_str());
+ if (CMFile.is_open())
+ {
+ std::stringstream outs;
+ std::string line;
+ bool found = false;
+ while(!CMFile.eof())
+ {
+ std::getline(CMFile, line);
+ if(line != "")
+ {
+ std::vector<std::string> segs;
+ CDMUtilities::splitter::split(segs, line, " ", CDMUtilities::splitter::no_empties);
+ //is comment
+ if(segs.size() > 0 && segs[0][0] == '#')
+ {
+ if(toInclude)
+ {
+ CDMUtilities::splitter::split(segs, line, " #()", CDMUtilities::splitter::no_empties);
+ if (segs.size() > 1 && segs[0] == "ADD_SUBDIRECTORY" && segs[1] == library_name)
+ {
+ found = true;
+ outs << "ADD_SUBDIRECTORY(" << library_name << ")\n";
+ }
+ else
+ outs << line << "\n";
+ }
+ else
+ {
+ outs << line << "\n";
+ }
+ }
+ //is not comment
+ else
+ {
+ if (segs.size() > 0 && !toInclude)
+ {
+ CDMUtilities::splitter::split(segs, line, " ()", CDMUtilities::splitter::no_empties);
+ if (segs.size() > 1 && segs[0] == "ADD_SUBDIRECTORY" && segs[1] == library_name)
+ {
+ outs << "#" << line << "\n";
+ }
+ else
+ {
+ outs << line << "\n";
+ }
+ }
+ else
+ {
+ CDMUtilities::splitter::split(segs, line, " ()", CDMUtilities::splitter::no_empties);
+ if (segs.size() > 1 && segs[0] == "ADD_SUBDIRECTORY" && segs[1] == library_name)
+ {
+ found = true;
+ }
+ outs << line << "\n";
+ }
+ }
+ }
+ else
+ {
+ outs << "\n";
+ }
+ }
+
+ CMFile.close();
+
+ if(!found && toInclude)
+ outs << "ADD_SUBDIRECTORY(" << library_name << ")\n";
+
+ std::ofstream CMFileOut(this->CMakeLists->GetPath().c_str());
+ if (CMFileOut.is_open())
+ {
+ CMFileOut << outs.rdbuf();
+ CMFileOut.close();
+ return true;
+ }
+ }
+ }
+ return false;
+}
const std::vector<modelCDMLibrary*>& GetLibraries() const;
/**
- * Creates a new library node for the actual project and registers it. It modifies the project model as well as the system.
+ * Creates a new library node for the actual project and registers it. It modifies the project model as well as the system. The created library is included in the lib's CMakeLists file.
* @param name Name of the new library.
* @param result Result message.
* @return New library reference.
*/
void CheckStructure(std::map<std::string, bool>& properties);
+ /**
+ * Checks if the given library is included in the CMakeLists file.
+ * @param library_name Name of the library to check.
+ * @return True if the library is included, otherwise returns False.
+ */
+ bool IsLibraryIncluded(const std::string& library_name);
+
+ /**
+ * Sets the inclusion of the library in the lib's CMakeLists file. If the library inclusion already exist in file, then the line is uncommented/commented depending on the requested action. If the library inclusion doesn't exist yet, then it is included if the request is an inclusion.
+ * @param library_name Name of the library to include/exclude.
+ * @param toInclude True if the request is an inclusion, False otherwise.
+ * @return True if the request was processed successfully.
+ */
+ bool SetLibraryInclude(const std::string& library_name, const bool& toInclude);
+
private:
/**
* Libraries references.
return NULL;
}
+ //add library to project CMakeLists
+ std::fstream out1((this->path + CDMUtilities::SLASH + "CMakeLists.txt").c_str(), std::fstream::in | std::fstream::out | std::fstream::app);
+ if (out1.is_open())
+ {
+ out1 << "ADD_SUBDIRECTORY(bbtk_" << nameFixed << "_PKG)" << std::endl;
+ out1.close();
+ }
+
//add library to model
modelCDMPackage* package = new modelCDMPackage(this, this->path + CDMUtilities::SLASH + "bbtk_" + nameFixed + "_PKG", "bbtk_" + nameFixed + "_PKG", this->level + 1);
this->packages.push_back(package);
this->packages[i]->CheckStructure(properties);
}
}
+
+bool modelCDMProject::IsPackageIncluded(const std::string& package_name)
+{
+ if(this->HasCMakeLists())
+ {
+ std::ifstream CMFile(this->CMakeLists->GetPath().c_str());
+ if (CMFile.is_open())
+ {
+ std::string line;
+ while(!CMFile.eof())
+ {
+ std::getline(CMFile, line);
+ while(line[0]==' ')
+ line.erase(0);
+ if(line[0] != '#')
+ {
+ std::vector<std::string> lineSeg;
+ CDMUtilities::splitter::split(lineSeg,line,"()",CDMUtilities::splitter::no_empties);
+ if(lineSeg.size() > 0 && lineSeg[0] == "ADD_SUBDIRECTORY" && lineSeg[1] == package_name)
+ {
+ CMFile.close();
+ return true;
+ }
+ }
+ }
+ CMFile.close();
+ }
+ }
+ return false;
+}
+
+bool modelCDMProject::SetPackageInclude(const std::string& package_name, const bool& toInclude)
+{
+ if (this->HasCMakeLists())
+ {
+ std::ifstream CMFile(this->CMakeLists->GetPath().c_str());
+ if (CMFile.is_open())
+ {
+ std::stringstream outs;
+ std::string line;
+ bool found = false;
+ while(!CMFile.eof())
+ {
+ std::getline(CMFile, line);
+ if(line != "")
+ {
+ std::vector<std::string> segs;
+ CDMUtilities::splitter::split(segs, line, " ", CDMUtilities::splitter::no_empties);
+ //is comment
+ if(segs.size() > 0 && segs[0][0] == '#')
+ {
+ if(toInclude)
+ {
+ CDMUtilities::splitter::split(segs, line, " #()", CDMUtilities::splitter::no_empties);
+ if (segs.size() > 1 && segs[0] == "ADD_SUBDIRECTORY" && segs[1] == package_name)
+ {
+ found = true;
+ outs << "ADD_SUBDIRECTORY(" << package_name << ")\n";
+ }
+ else
+ outs << line << "\n";
+ }
+ else
+ {
+ outs << line << "\n";
+ }
+ }
+ //is not comment
+ else
+ {
+ if (segs.size() > 0 && !toInclude)
+ {
+ CDMUtilities::splitter::split(segs, line, " ()", CDMUtilities::splitter::no_empties);
+ if (segs.size() > 1 && segs[0] == "ADD_SUBDIRECTORY" && segs[1] == package_name)
+ {
+ outs << "#" << line << "\n";
+ }
+ else
+ {
+ outs << line << "\n";
+ }
+ }
+ else
+ {
+ CDMUtilities::splitter::split(segs, line, " ()", CDMUtilities::splitter::no_empties);
+ if (segs.size() > 1 && segs[0] == "ADD_SUBDIRECTORY" && segs[1] == package_name)
+ {
+ found = true;
+ }
+ outs << line << "\n";
+ }
+ }
+ }
+ else
+ {
+ outs << "\n";
+ }
+ }
+
+ CMFile.close();
+
+ if(!found && toInclude)
+ outs << "ADD_SUBDIRECTORY(" << package_name << ")\n";
+
+ std::ofstream CMFileOut(this->CMakeLists->GetPath().c_str());
+ if (CMFileOut.is_open())
+ {
+ CMFileOut << outs.rdbuf();
+ CMFileOut.close();
+ return true;
+ }
+ }
+ }
+ return false;
+}
//Creations
/**
- * Creates a package and sets it as a children of the project. This method creates the package in the hard drive and also in the model.
+ * Creates a package and sets it as a children of the project. This method creates the package in the hard drive and also in the model. The created package is included in the project's CMakeLists file.
* @param name Name of the package.
* @param result Result of the operation.
* @param authors Authors of the operation. If any space is found, it will be replaced by '_'.
*/
void CheckStructure(std::map<std::string, bool>& properties);
+ /**
+ * Checks if the given package is included in the CMakeLists file.
+ * @param package_name Name of the package to check.
+ * @return True if the package is included, otherwise returns False.
+ */
+ bool IsPackageIncluded(const std::string& package_name);
+
+ /**
+ * Sets the inclusion of the package in the project's CMakeLists file. If the package inclusion already exist in file, then the line is uncommented/commented depending on the requested action. If the package inclusion doesn't exist yet, then it is included if the request is an inclusion.
+ * @param package_name Name of the package to include/exclude.
+ * @param toInclude True if the request is an inclusion, False otherwise.
+ * @return True if the request was processed successfully.
+ */
+ bool SetPackageInclude(const std::string& package_name, const bool& toInclude);
+
private:
EVT_BUTTON(ID_BUTTON_CREATE_APPLICATION, wxCDMAppliDescriptionPanel::OnBtnCreateApplication)
EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMAppliDescriptionPanel::OnBtnEditCMakeLists)
EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMAppliDescriptionPanel::OnBtnOpenFolder)
+EVT_CHECKBOX(ID_CHECK_INCLUDE_APPLICATION, wxCDMAppliDescriptionPanel::OnChBApplicationChange)
END_EVENT_TABLE()
wxCDMAppliDescriptionPanel::wxCDMAppliDescriptionPanel(
wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("A&vailable Applications"));
propertiesBox->GetStaticBox()->SetToolTip(wxT("Select any of the available applications to see its details or the modify them."));
wxPanel* propertiesPanel = new wxPanel(this);
- wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL);
std::vector<modelCDMApplication*> applications = this->appli->GetApplications();
+ wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(applications.size()+1, 3, 9, 5);
+
+ wxStaticText* ChBTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Include in\nCMake"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
+ wxStaticText* LkTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Application Name"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
+ wxStaticText* HlpTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Help"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
+
+ propertiesGridSizer -> Add(ChBTitle, 0, wxEXPAND | wxALL, 5);
+ propertiesGridSizer -> Add(LkTitle, 0, wxEXPAND | wxALL, 5);
+ propertiesGridSizer -> Add(HlpTitle, 0, wxEXPAND | wxALL, 5);
+
for (int i = 0; i < (int)(applications.size()); i++)
{
- wxHyperlinkCtrl* pApplicationlk = new wxHyperlinkCtrl(propertiesPanel,ID_LINK_SELECT_APPLICATION, crea::std2wx(applications[i]->GetName().c_str()), crea::std2wx(applications[i]->GetName().c_str()), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
+ //checkbox for cmake inclusion
+ wxCheckBox* pApplicationChB = new wxCheckBox(propertiesPanel, ID_CHECK_INCLUDE_APPLICATION, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
+ pApplicationChB->SetName(crea::std2wx(applications[i]->GetName()));
+ std::string tt = "if this box is checked the the " + applications[i]->GetName() + " application is included in the project compilation.";
+ pApplicationChB->SetToolTip(crea::std2wx(tt));
+ pApplicationChB->SetValue(this->appli->IsApplicationIncluded(applications[i]->GetName()));
+ propertiesGridSizer -> Add(pApplicationChB, 0, wxEXPAND | wxALIGN_CENTER);
+
+ //link to library with description
+ wxHyperlinkCtrl* pApplicationlk = new wxHyperlinkCtrl(propertiesPanel, ID_LINK_SELECT_APPLICATION, crea::std2wx(applications[i]->GetName().c_str()), crea::std2wx(applications[i]->GetName().c_str()), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
pApplicationlk->SetWindowStyle(wxALIGN_LEFT | wxNO_BORDER);
- std::string tt = "Name: " + applications[i]->GetName() + "\n";
+ tt = "Name: " + applications[i]->GetName() + "\n";
tt += "Location: " + applications[i]->GetPath();
- pApplicationlk->SetToolTip(crea::std2wx(tt.c_str()));
+ pApplicationlk->SetToolTip(crea::std2wx(tt));
pApplicationlk->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMAppliDescriptionPanel::OnMouseEnter,NULL,this);
pApplicationlk->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMAppliDescriptionPanel::OnMouseExit,NULL,this);
- propertiesPanelSizer -> Add(pApplicationlk, 1, wxEXPAND | wxALL, 5);
+ propertiesGridSizer -> Add(pApplicationlk, 0, wxEXPAND);
+
+ //help icon
+ wxButton* pApplicationHlp = new wxButton(propertiesPanel, wxID_ANY, wxT("?"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
+ propertiesGridSizer -> Add(pApplicationHlp, 0, wxEXPAND | wxALIGN_CENTER);
}
- propertiesPanel->SetSizer(propertiesPanelSizer);
- propertiesPanelSizer->Fit(propertiesPanel);
+ propertiesGridSizer->AddGrowableCol(1,1);
+
+ propertiesPanel->SetSizer(propertiesGridSizer);
+ propertiesGridSizer->Fit(propertiesPanel);
+
propertiesBox->Add(propertiesPanel, 1, wxEXPAND | wxALL, 5);
sizer -> Add(propertiesBox, 0, wxEXPAND | wxALL, 10);
}
}
+void wxCDMAppliDescriptionPanel::OnChBApplicationChange(wxCommandEvent& event)
+{
+ this->appli->SetApplicationInclude(
+ crea::wx2std(((wxCheckBox*)event.GetEventObject())->GetName()),
+ ((wxCheckBox*)event.GetEventObject())->GetValue()
+ );
+}
+
void wxCDMAppliDescriptionPanel::OnLnkApplicationSelect(wxHyperlinkEvent& event)
{
modelCDMApplication* applicationFound = NULL;
* Handles when the open package cmakelists file button is pressed.
*/
void OnBtnEditCMakeLists(wxCommandEvent& event);
+ /**
+ * Handles when a application checkbox is (un)checked.
+ * @param event Has the link reference to know which application was selected.
+ */
+ void OnChBApplicationChange(wxCommandEvent& event);
/**
* Handles when an application link is pressed.
* @param event Has the link reference to know which application was selected.
EVT_BUTTON(ID_BUTTON_CREATE_LIBRARY, wxCDMLibDescriptionPanel::OnBtnCreateLibrary)
EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMLibDescriptionPanel::OnBtnEditCMakeLists)
EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMLibDescriptionPanel::OnBtnOpenFolder)
+EVT_CHECKBOX(ID_CHECK_INCLUDE_LIBRARY, wxCDMLibDescriptionPanel::OnChBLibraryChange)
END_EVENT_TABLE()
wxCDMLibDescriptionPanel::wxCDMLibDescriptionPanel(
wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("A&vailable Libraries"));
propertiesBox->GetStaticBox()->SetToolTip(wxT("Select any of the available libraries to see its details or modify them."));
wxPanel* propertiesPanel = new wxPanel(this);
- wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL);
std::vector<modelCDMLibrary*> libraries = this->lib->GetLibraries();
+ wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(libraries.size()+1, 3, 9, 5);
+
+ wxStaticText* ChBTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Include in\nCMake"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
+ wxStaticText* LkTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Library Name"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
+ wxStaticText* HlpTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Help"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
+
+ propertiesGridSizer -> Add(ChBTitle, 0, wxEXPAND | wxALL, 5);
+ propertiesGridSizer -> Add(LkTitle, 0, wxEXPAND | wxALL, 5);
+ propertiesGridSizer -> Add(HlpTitle, 0, wxEXPAND | wxALL, 5);
+
for (int i = 0; i < (int)(libraries.size()); i++)
{
- wxHyperlinkCtrl* pLibrarylk = new wxHyperlinkCtrl(propertiesPanel, ID_LINK_SELECT_LIBRARY, crea::std2wx(libraries[i]->GetName().c_str()), crea::std2wx(libraries[i]->GetName().c_str()), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
+ //checkbox for cmake inclusion
+ wxCheckBox* pLibraryChB = new wxCheckBox(propertiesPanel, ID_CHECK_INCLUDE_LIBRARY, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
+ pLibraryChB->SetName(crea::std2wx(libraries[i]->GetName()));
+ std::string tt = "if this box is checked the the " + libraries[i]->GetName() + " library is included in the project compilation.";
+ pLibraryChB->SetToolTip(crea::std2wx(tt));
+ pLibraryChB->SetValue(this->lib->IsLibraryIncluded(libraries[i]->GetName()));
+ propertiesGridSizer -> Add(pLibraryChB, 0, wxEXPAND | wxALIGN_CENTER);
+
+ //link to library with description
+ wxHyperlinkCtrl* pLibrarylk = new wxHyperlinkCtrl(propertiesPanel, ID_LINK_SELECT_LIBRARY, crea::std2wx(libraries[i]->GetName().c_str()), crea::std2wx(libraries[i]->GetName().c_str()), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
pLibrarylk->SetWindowStyle(wxALIGN_LEFT | wxNO_BORDER);
- std::string tt = "Name: " + libraries[i]->GetName() + "\n";
+ tt = "Name: " + libraries[i]->GetName() + "\n";
tt += "Location: " + libraries[i]->GetPath();
- pLibrarylk->SetToolTip(crea::std2wx(tt.c_str()));
+ pLibrarylk->SetToolTip(crea::std2wx(tt));
pLibrarylk->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibDescriptionPanel::OnMouseEnter,NULL,this);
pLibrarylk->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibDescriptionPanel::OnMouseExit,NULL,this);
- propertiesPanelSizer -> Add(pLibrarylk, 0, wxEXPAND | wxALL, 5);
+ propertiesGridSizer -> Add(pLibrarylk, 0, wxEXPAND);
+
+ //help icon
+ wxButton* pLibraryHlp = new wxButton(propertiesPanel, wxID_ANY, wxT("?"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
+ propertiesGridSizer -> Add(pLibraryHlp, 0, wxEXPAND | wxALIGN_CENTER);
}
- propertiesPanel->SetSizer(propertiesPanelSizer);
- propertiesPanelSizer->Fit(propertiesPanel);
+ propertiesGridSizer->AddGrowableCol(1,1);
+
+ propertiesPanel->SetSizer(propertiesGridSizer);
+ propertiesGridSizer->Fit(propertiesPanel);
propertiesBox->Add(propertiesPanel, 1, wxALL | wxEXPAND, 5);
sizer -> Add(propertiesBox, 0, wxEXPAND | wxALL, 10);
}
}
+void wxCDMLibDescriptionPanel::OnChBLibraryChange(wxCommandEvent& event)
+{
+ this->lib->SetLibraryInclude(
+ crea::wx2std(((wxCheckBox*)event.GetEventObject())->GetName()),
+ ((wxCheckBox*)event.GetEventObject())->GetValue()
+ );
+}
+
void wxCDMLibDescriptionPanel::OnLnkLibrarySelect(wxHyperlinkEvent& event)
{
modelCDMLibrary* theLibrary = NULL;
* Handles when the open package cmakelists file button is pressed.
*/
void OnBtnEditCMakeLists(wxCommandEvent& event);
+ /**
+ * Handles when a library checkbox is (un)checked.
+ * @param event Has the link reference to know which library was selected.
+ */
+ void OnChBLibraryChange(wxCommandEvent& event);
/**
* Handles when a library link is pressed.
* @param event Has the link reference to know which library was selected.
EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_TOOL_CLICKED, wxCDMPackageManagerPanel::OnBtnCreatePackage)
EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMPackageManagerPanel::OnBtnEditCMakeLists)
EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_TOOL_ENTER, wxCDMPackageManagerPanel::OnBtnEditCMakeLists)
+EVT_CHECKBOX(ID_CHECK_INCLUDE_PACKAGE, wxCDMPackageManagerPanel::OnChBPackageChange)
END_EVENT_TABLE()
wxCDMPackageManagerPanel::wxCDMPackageManagerPanel(
wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("A&vailable Packages"));
propertiesBox->GetStaticBox()->SetToolTip(wxT("Select any of the available packages to see its details or modify them. Remember that black boxes are created inside packages, any of these packages is available."));
wxPanel* propertiesPanel = new wxPanel(this);
- wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL);
std::vector<modelCDMPackage*> packages = this->project->GetPackages();
+ wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(packages.size()+1, 3, 9, 5);
+
+ wxStaticText* ChBTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Include in\nCMake"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
+ wxStaticText* LkTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Package Name"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
+ wxStaticText* HlpTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Help"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
+
+ propertiesGridSizer -> Add(ChBTitle, 0, wxEXPAND | wxALL, 5);
+ propertiesGridSizer -> Add(LkTitle, 0, wxEXPAND | wxALL, 5);
+ propertiesGridSizer -> Add(HlpTitle, 0, wxEXPAND | wxALL, 5);
+
for (int i = 0; i < (int)(packages.size()); i++)
{
- wxHyperlinkCtrl* pPackagelk = new wxHyperlinkCtrl(propertiesPanel,ID_LINK_SELECT_PACKAGE, crea::std2wx(packages[i]->GetName().c_str()), crea::std2wx(packages[i]->GetName().c_str()), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
- pPackagelk->SetWindowStyle(wxALIGN_LEFT | wxNO_BORDER);
- std::string tt = "Author: " + packages[i]->GetAuthors() + "\nDescription: " + packages[i]->GetDescription();
+ //checkbox for cmake inclusion
+ wxCheckBox* pPackageChB = new wxCheckBox(propertiesPanel, ID_CHECK_INCLUDE_PACKAGE, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
+ pPackageChB->SetName(crea::std2wx(packages[i]->GetName()));
+ std::string tt = "if this box is checked the the " + packages[i]->GetName() + " package is included in the project compilation.";
+ pPackageChB->SetToolTip(crea::std2wx(tt));
+ pPackageChB->SetValue(this->project->IsPackageIncluded(packages[i]->GetName()));
+ propertiesGridSizer -> Add(pPackageChB, 0, wxEXPAND | wxALIGN_CENTER);
+
+ //link to package with description
+ wxHyperlinkCtrl* pPackagelk = new wxHyperlinkCtrl(propertiesPanel, ID_LINK_SELECT_PACKAGE, crea::std2wx(packages[i]->GetName().c_str()), crea::std2wx(packages[i]->GetName().c_str()), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
+ pPackagelk->SetWindowStyle(wxALIGN_LEFT | wxNO_BORDER);
+ tt = "Name: " + packages[i]->GetName() + "\n";
+ tt += "Location: " + packages[i]->GetPath();
pPackagelk->SetToolTip(crea::std2wx(tt));
- propertiesPanelSizer -> Add(pPackagelk, 0, wxEXPAND | wxALL, 5);
pPackagelk->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageManagerPanel::OnMouseEnter,NULL,this);
pPackagelk->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageManagerPanel::OnMouseExit,NULL,this);
+ propertiesGridSizer -> Add(pPackagelk, 0, wxEXPAND);
+
+ //help icon
+ wxButton* pPackageHlp = new wxButton(propertiesPanel, wxID_ANY, wxT("?"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
+ propertiesGridSizer -> Add(pPackageHlp, 0, wxEXPAND | wxALIGN_CENTER);
}
- propertiesPanel->SetSizer(propertiesPanelSizer);
- propertiesPanelSizer->Fit(propertiesPanel);
+ propertiesGridSizer->AddGrowableCol(1,1);
+
+ propertiesPanel->SetSizer(propertiesGridSizer);
+ propertiesGridSizer->Fit(propertiesPanel);
+
+
propertiesBox->Add(propertiesPanel, 1, wxALL | wxEXPAND, 5);
sizer -> Add(propertiesBox, 0, wxEXPAND | wxALL, 10);
wxPostEvent(this->GetParent(), *newEvent);
}
+void wxCDMPackageManagerPanel::OnChBPackageChange(wxCommandEvent& event)
+{
+ this->project->SetPackageInclude(
+ crea::wx2std(((wxCheckBox*)event.GetEventObject())->GetName()),
+ ((wxCheckBox*)event.GetEventObject())->GetValue()
+ );
+}
+
void wxCDMPackageManagerPanel::OnLnkPackageSelect(wxHyperlinkEvent& event)
{
modelCDMPackage* thePackage = NULL;
* @param event Has the link reference to know where to return
*/
void OnBtnReturn(wxHyperlinkEvent& event);
+ /**
+ * Handles when a package checkbox is (un)checked.
+ * @param event Has the link reference to know which package was selected.
+ */
+ void OnChBPackageChange(wxCommandEvent& event);
/**
* Handles when a packages link is pressed.
* @param event Has the link reference to know which package was selected.