#include "wxCDMMainFrame.h"
+#include "wxCDMLibHelpDialog.h"
+
#include "creaDevManagerIds.h"
#include "images/LbIcon64.xpm"
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);
-
- //Title
- sizer->Add(new wxStaticText(this, -1, _("Library Management")),0, wxALIGN_CENTER, 0);
-
- //Image
- sizer->Add(new wxStaticBitmap(this, -1, wxBitmap(LbIcon64)),0, wxALIGN_CENTER, 0);
+ //Header
+ wxBoxSizer* headerSizer = new wxBoxSizer(wxHORIZONTAL);
+ {
+ //Image
+ headerSizer->Add(new wxStaticBitmap(this, -1, wxBitmap(LbIcon64)),0, wxALIGN_CENTER, 0);
+ wxBoxSizer* textSizer = new wxBoxSizer(wxVERTICAL);
+ //Title
+ textSizer->Add(new wxStaticText(this, -1, _("Library Management")),0, wxALIGN_LEFT, 0);
+ headerSizer->Add(textSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+ }
+ sizer->Add(headerSizer, 0, wxALIGN_CENTER);
//Libraries
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 the modify them."));
+ 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::string tt = "Name: " + libraries[i]->GetName() + "\n";
tt += "Location: " + libraries[i]->GetPath();
pLibrarylk->SetToolTip(crea::std2wx(tt.c_str()));
+ 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);
}
wxPanel* actionsPanel = new wxPanel(this);
wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL);
- wxButton* createLibrarybt = new wxButton(actionsPanel, ID_BUTTON_CREATE_LIBRARY, _T("Create Library"));
+ //actionsGrid Sizer
+ wxFlexGridSizer* actionsGridSizer = new wxFlexGridSizer(2, 2, 9, 15);
+
+ wxButton* createLibrarybt = new wxButton(actionsPanel, ID_BUTTON_CREATE_LIBRARY, _T("A. Create Library"));
createLibrarybt->SetToolTip(wxT("Create a new library for this project."));
- actionsPanelSizer->Add(createLibrarybt, 0, wxALL, 5);
- 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 CMakeLists.txt file."));
- actionsPanelSizer->Add(editCMakebt, 0, wxALL, 5);
- wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Libraries Folder"));
+ actionsGridSizer->Add(createLibrarybt, 1, wxALL | wxEXPAND, 5);
+ wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("B. 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"));
openFolderbt->SetToolTip(wxT("Open the lib folder in the file explorer."));
- actionsPanelSizer->Add(openFolderbt, 0, wxALL, 5);
+ actionsGridSizer->Add(openFolderbt, 1, wxALL | wxEXPAND, 5);
+
+ actionsGridSizer->AddGrowableCol(0,1);
+ actionsGridSizer->AddGrowableCol(1,1);
+
+ actionsPanelSizer->Add(actionsGridSizer, 1, wxEXPAND, 0);
actionsPanel->SetSizer(actionsPanelSizer);
actionsPanelSizer->Fit(actionsPanel);
//Assign sizer
SetSizer(sizer);
sizer->SetSizeHints(this);
+
+ if (((wxCDMMainFrame*)this->GetParent())->isHelp())
+ {
+ wxCDMLibHelpDialog* helpDialog = new wxCDMLibHelpDialog(this->GetParent(), this->lib, wxID_ANY);
+ helpDialog->Show(true);
+ }
}
void wxCDMLibDescriptionPanel::OnBtnCreateLibrary(wxCommandEvent& event)
void wxCDMLibDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
{
- //TODO: implement method
- std::cerr << "Event OnBtnEditCMakeLists not implemented" << std::endl;
- event.Skip();
+ std::string* result;
+ 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);
+
+ if(this->lib->GetCMakeLists() != NULL)
+ {
+ int CMId = this->lib->GetCMakeLists()->GetId();
+ newEvent->SetInt(CMId);
+ newEvent->SetId(0);
+ wxPostEvent(this->GetParent(), *newEvent);
+ }
}
void wxCDMLibDescriptionPanel::OnLnkLibrarySelect(wxHyperlinkEvent& event)
newEvent->SetId(0);
wxPostEvent(this->GetParent(), *newEvent);
+ wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
+ newEvent1->SetInt(libraryId);
+ newEvent1->SetId(0);
+ wxPostEvent(this->GetParent(), *newEvent1);
+
}
void wxCDMLibDescriptionPanel::OnBtnReturn(wxCommandEvent& event)
wxPostEvent(this->GetParent(), *newEvent);
}
-void
-wxCDMLibDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
+void wxCDMLibDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
+{
+ std::string* result;
+ if(!this->lib->OpenInFileExplorer(result))
+ wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR);
+}
+
+void wxCDMLibDescriptionPanel::OnMouseEnter(wxMouseEvent& event)
{
- //TODO: implement method
- std::cerr << "Event OnBtnOpenFolder not implemented" << std::endl;
+ wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
+ std::string LibName = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL());
+ int lbId = 0;
+ std::vector<modelCDMLibrary*> libraries = this->lib->GetLibraries();
+ for (int i = 0; i < libraries.size(); i++)
+ {
+ if(libraries[i]->GetName() == LibName)
+ {
+ lbId = libraries[i]->GetId();
+ break;
+ }
+ }
+ newEvent->SetInt(lbId);
+ newEvent->SetId(0);
+ wxPostEvent(this->GetParent(), *newEvent);
+ event.Skip();
+}
+
+void wxCDMLibDescriptionPanel::OnMouseExit(wxMouseEvent& event)
+{
+ wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
+ std::string LibName = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL());
+ int lbId = 0;
+ std::vector<modelCDMLibrary*> libraries = this->lib->GetLibraries();
+ for (int i = 0; i < libraries.size(); i++)
+ {
+ if(libraries[i]->GetName() == LibName)
+ {
+ lbId = libraries[i]->GetId();
+ break;
+ }
+ }
+ newEvent->SetInt(lbId);
+ newEvent->SetId(0);
+ wxPostEvent(this->GetParent(), *newEvent);
+ event.Skip();
+}
+
+void wxCDMLibDescriptionPanel::OnCMakeMouseEnter(wxMouseEvent& event)
+{
+ wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
+
+ if(this->lib->GetCMakeLists() != NULL)
+ {
+ int CMId = this->lib->GetCMakeLists()->GetId();
+ newEvent->SetInt(CMId);
+ newEvent->SetId(0);
+ wxPostEvent(this->GetParent(), *newEvent);
+ }
+ event.Skip();
+}
+
+void wxCDMLibDescriptionPanel::OnCMakeMouseExit(wxMouseEvent& event)
+{
+ wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
+
+ if(this->lib->GetCMakeLists() != NULL)
+ {
+ int CMId = this->lib->GetCMakeLists()->GetId();
+ newEvent->SetInt(CMId);
+ newEvent->SetId(0);
+ wxPostEvent(this->GetParent(), *newEvent);
+ }
event.Skip();
}