#include "images/LbIcon64.xpm"
BEGIN_EVENT_TABLE(wxCDMLibDescriptionPanel, wxPanel)
-EVT_BUTTON(ID_BUTTON_PREV, wxCDMLibDescriptionPanel::OnBtnReturn)
+EVT_HYPERLINK(ID_BUTTON_PREV, wxCDMLibDescriptionPanel::OnBtnReturn)
EVT_HYPERLINK(ID_LINK_SELECT_LIBRARY, wxCDMLibDescriptionPanel::OnLnkLibrarySelect)
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(
wxPanel::Create(parent, id, pos, size, style);
this->lib = lib;
CreateControls();
+ // this part makes the scrollbars show up
+ this->FitInside(); // ask the sizer about the needed size
+ this->SetScrollRate(5, 5);
return TRUE;
}
{
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
- //Link to return
- wxButton* returnbt = new wxButton(this, ID_BUTTON_PREV, wxT("Return to project"));
- returnbt->SetToolTip(wxT("Return to the active project description."));
- sizer->Add(returnbt, 0, wxALIGN_CENTER | wxALL, 5);
+ //Links to return
+ wxBoxSizer *linksSizer = new wxBoxSizer(wxHORIZONTAL);
+ std::vector<modelCDMIProjectTreeNode*> parents = this->lib->GetParents();
+ for (int i = 0; i < (int)(parents.size()); i++)
+ {
+ wxHyperlinkCtrl* returnLnk = new wxHyperlinkCtrl(this, ID_BUTTON_PREV, crea::std2wx(parents[parents.size()-1-i]->GetName()), crea::std2wx(parents[parents.size()-1-i]->GetPath()), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
+ returnLnk->SetWindowStyle(wxNO_BORDER);
+ returnLnk->SetToolTip(crea::std2wx("Return to " + parents[parents.size()-1-i]->GetName() + "."));
+ linksSizer->Add(returnLnk, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 5);
+ linksSizer->Add(new wxStaticText(this,wxID_ANY, wxT("/")), 0, wxALIGN_CENTER, 0);
+ }
+
+ linksSizer->Add(new wxStaticText(this, wxID_ANY, crea::std2wx(this->lib->GetName())), 0, wxALIGN_CENTER, 0);
+
+ sizer->Add(linksSizer, 0, wxALIGN_CENTER | wxALL, 5);
+
//Header
wxBoxSizer* headerSizer = new wxBoxSizer(wxHORIZONTAL);
{
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();
- for (int i = 0; i < libraries.size(); i++)
+ 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()));
- std::string tt = "Name: " + libraries[i]->GetName() + "\n";
+ //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);
+ 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, wxALIGN_LEFT | wxALL, 5);
+ propertiesGridSizer -> Add(pLibrarylk, 0, wxEXPAND);
+
+ //help icon
+ wxButton* pLibraryHlp = new wxButton(propertiesPanel, wxID_ANY, wxT("?"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
+ pLibraryHlp->Enable(false);
+ tt = "When this library is included in the CMakeLists file, the\nfollowing line is included in the CMakeList.txt file in the lib\nfolder:\n"
+ "ADD_SUBDIRECTORY(" + libraries[i]->GetName() + ")";
+ pLibraryHlp->SetToolTip(crea::std2wx(tt));
+
+ propertiesGridSizer -> Add(pLibraryHlp, 0, wxEXPAND | wxALIGN_CENTER);
}
- propertiesPanel->SetSizer(propertiesPanelSizer);
- propertiesPanelSizer->Fit(propertiesPanel);
- propertiesBox->Add(propertiesPanel, 0, wxALL, 5);
+ propertiesGridSizer->AddGrowableCol(1,1);
+
+ propertiesPanel->SetSizer(propertiesGridSizer);
+ propertiesGridSizer->Fit(propertiesPanel);
+ propertiesBox->Add(propertiesPanel, 1, wxALL | wxEXPAND, 5);
sizer -> Add(propertiesBox, 0, wxEXPAND | wxALL, 10);
//Actions
wxButton* createLibrarybt = new wxButton(actionsPanel, ID_BUTTON_CREATE_LIBRARY, _T("A. Create Library"));
createLibrarybt->SetToolTip(wxT("Create a new library for this project."));
actionsGridSizer->Add(createLibrarybt, 1, wxALL | wxEXPAND, 5);
- wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("B. Edit CMakeLists File"));
+ wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File"));
editCMakebt->SetToolTip(wxT("Open the system default text editor to edit the Lib's CMakeLists.txt file."));
editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibDescriptionPanel::OnCMakeMouseEnter,NULL,this);
editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibDescriptionPanel::OnCMakeMouseExit,NULL,this);
actionsGridSizer->Add(editCMakebt, 1, wxALL | wxEXPAND, 5);
- wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("C. Open Libraries Folder"));
+ wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Libraries Folder"));
openFolderbt->SetToolTip(wxT("Open the lib folder in the file explorer."));
actionsGridSizer->Add(openFolderbt, 1, wxALL | wxEXPAND, 5);
((wxCDMMainFrame*)this->GetParent())->RefreshProject();
wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
- newEvent->SetInt(library->GetId());
+ newEvent->SetClientData(library);
wxPostEvent(this->GetParent(), *newEvent);
}
}
if(!this->lib->OpenCMakeListsFile(result))
wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
- wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
+ wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
if(this->lib->GetCMakeLists() != NULL)
{
- int CMId = this->lib->GetCMakeLists()->GetId();
- newEvent->SetInt(CMId);
+ newEvent->SetClientData(this->lib->GetCMakeLists());
newEvent->SetId(0);
wxPostEvent(this->GetParent(), *newEvent);
}
}
+void wxCDMLibDescriptionPanel::OnChBLibraryChange(wxCommandEvent& event)
+{
+ this->lib->SetLibraryInclude(
+ crea::wx2std(((wxCheckBox*)event.GetEventObject())->GetName()),
+ ((wxCheckBox*)event.GetEventObject())->GetValue()
+ );
+}
+
void wxCDMLibDescriptionPanel::OnLnkLibrarySelect(wxHyperlinkEvent& event)
{
- int libraryId = 0;
+ modelCDMLibrary* theLibrary = NULL;
std::vector<modelCDMLibrary*> libraries = this->lib->GetLibraries();
- for (int i = 0; i < libraries.size(); i++)
+ for (int i = 0; i < (int)(libraries.size()); i++)
{
if(libraries[i]->GetName() == crea::wx2std(event.GetURL()))
{
- libraryId = libraries[i]->GetId();
+ theLibrary = libraries[i];
break;
}
}
wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
- newEvent->SetInt(libraryId);
+ newEvent->SetClientData(theLibrary);
newEvent->SetId(0);
wxPostEvent(this->GetParent(), *newEvent);
- wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
- newEvent1->SetInt(libraryId);
+ wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
+ newEvent1->SetClientData(theLibrary);
newEvent1->SetId(0);
wxPostEvent(this->GetParent(), *newEvent1);
}
-void wxCDMLibDescriptionPanel::OnBtnReturn(wxCommandEvent& event)
+void wxCDMLibDescriptionPanel::OnBtnReturn(wxHyperlinkEvent& event)
{
- wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
- newEvent->SetInt(((wxCDMMainFrame*)this->GetParent())->GetModel()->GetProject()->GetId());
- newEvent->SetId(0);
- wxPostEvent(this->GetParent(), *newEvent);
+ std::vector<modelCDMIProjectTreeNode*> parents = this->lib->GetParents();
+ std::string parentURL = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL());
+ //std::cout << parentURL << std::endl;
+ for (int i = 0; i < (int)(parents.size()); i++)
+ {
+ if (parents[i]->GetPath() == parentURL)
+ {
+ wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
+ newEvent->SetClientData(parents[i]);
+ newEvent->SetId(0);
+ wxPostEvent(this->GetParent(), *newEvent);
+ }
+ }
}
void wxCDMLibDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
void wxCDMLibDescriptionPanel::OnMouseEnter(wxMouseEvent& event)
{
- wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
+ wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
std::string LibName = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL());
- int lbId = 0;
+ modelCDMLibrary* theLibrary = NULL;
std::vector<modelCDMLibrary*> libraries = this->lib->GetLibraries();
- for (int i = 0; i < libraries.size(); i++)
+ for (int i = 0; i < (int)(libraries.size()); i++)
{
if(libraries[i]->GetName() == LibName)
{
- lbId = libraries[i]->GetId();
+ theLibrary = libraries[i];
break;
}
}
- newEvent->SetInt(lbId);
+ newEvent->SetClientData(theLibrary);
newEvent->SetId(0);
wxPostEvent(this->GetParent(), *newEvent);
event.Skip();
void wxCDMLibDescriptionPanel::OnMouseExit(wxMouseEvent& event)
{
- wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
+ wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
std::string LibName = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL());
- int lbId = 0;
+ modelCDMLibrary* theLibrary = NULL;
std::vector<modelCDMLibrary*> libraries = this->lib->GetLibraries();
- for (int i = 0; i < libraries.size(); i++)
+ for (int i = 0; i < (int)(libraries.size()); i++)
{
if(libraries[i]->GetName() == LibName)
{
- lbId = libraries[i]->GetId();
+ theLibrary = libraries[i];
break;
}
}
- newEvent->SetInt(lbId);
+ newEvent->SetClientData(theLibrary);
newEvent->SetId(0);
wxPostEvent(this->GetParent(), *newEvent);
event.Skip();
void wxCDMLibDescriptionPanel::OnCMakeMouseEnter(wxMouseEvent& event)
{
- wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
+ wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
if(this->lib->GetCMakeLists() != NULL)
{
- int CMId = this->lib->GetCMakeLists()->GetId();
- newEvent->SetInt(CMId);
+ newEvent->SetClientData(this->lib->GetCMakeLists());
newEvent->SetId(0);
wxPostEvent(this->GetParent(), *newEvent);
}
void wxCDMLibDescriptionPanel::OnCMakeMouseExit(wxMouseEvent& event)
{
- wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
+ wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
if(this->lib->GetCMakeLists() != NULL)
{
- int CMId = this->lib->GetCMakeLists()->GetId();
- newEvent->SetInt(CMId);
+ newEvent->SetClientData(this->lib->GetCMakeLists());
newEvent->SetId(0);
wxPostEvent(this->GetParent(), *newEvent);
}