2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------
29 * wxCDMCMakeListsDescriptionPanel.cpp
31 * Created on: Nov 27, 2012
32 * Author: Daniel Felipe Gonzalez Obando
35 #include "wxCDMCMakeListsDescriptionPanel.h"
37 #include "wxCDMMainFrame.h"
39 #include "creaDevManagerIds.h"
40 #include "images/CMIcon64.xpm"
42 BEGIN_EVENT_TABLE(wxCDMCMakeListsDescriptionPanel, wxPanel)
43 EVT_HYPERLINK(ID_BUTTON_PREV, wxCDMCMakeListsDescriptionPanel::OnBtnReturn)
44 EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMCMakeListsDescriptionPanel::OnBtnOpenInEditor)
45 EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMCMakeListsDescriptionPanel::OnBtnOpenFolder)
48 wxCDMCMakeListsDescriptionPanel::wxCDMCMakeListsDescriptionPanel(
50 modelCDMCMakeListsFile* makefile,
52 const wxString& caption,
58 wxCDMCMakeListsDescriptionPanel::Create(parent, makefile, id, caption, pos, size, style);
61 wxCDMCMakeListsDescriptionPanel::~wxCDMCMakeListsDescriptionPanel()
65 bool wxCDMCMakeListsDescriptionPanel::Create(
67 modelCDMCMakeListsFile* makefile,
69 const wxString& caption,
75 wxPanel::Create(parent, id, pos, size, style);
76 this->cMakeLists = makefile;
78 // this part makes the scrollbars show up
79 this->FitInside(); // ask the sizer about the needed size
80 this->SetScrollRate(5, 5);
84 void wxCDMCMakeListsDescriptionPanel::CreateControls()
86 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
89 wxBoxSizer *linksSizer = new wxBoxSizer(wxHORIZONTAL);
90 std::vector<modelCDMIProjectTreeNode*> parents = this->cMakeLists->GetParents();
91 for (int i = 0; i < (int)(parents.size()); i++)
93 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);
94 returnLnk->SetWindowStyle(wxNO_BORDER);
95 returnLnk->SetToolTip(crea::std2wx("Return to " + parents[parents.size()-1-i]->GetName() + "."));
96 linksSizer->Add(returnLnk, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 5);
97 linksSizer->Add(new wxStaticText(this,wxID_ANY, wxT("/")), 0, wxALIGN_CENTER, 0);
100 linksSizer->Add(new wxStaticText(this, wxID_ANY, crea::std2wx(this->cMakeLists->GetName())), 0, wxALIGN_CENTER, 0);
102 sizer->Add(linksSizer, 0, wxALIGN_CENTER | wxALL, 5);
105 wxBoxSizer* headerSizer = new wxBoxSizer(wxHORIZONTAL);
108 headerSizer->Add(new wxStaticBitmap(this, -1, wxBitmap(CMIcon64)),0, wxALIGN_CENTER, 0);
109 wxBoxSizer* textSizer = new wxBoxSizer(wxVERTICAL);
111 textSizer->Add(new wxStaticText(this, -1, _("CMake Configuration File")),0, wxALIGN_LEFT, 0);
113 textSizer->Add(new wxStaticText(this, -1, crea::std2wx("CMakeLists.txt")),0, wxALIGN_LEFT, 0);
114 headerSizer->Add(textSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
116 sizer->Add(headerSizer, 0, wxALIGN_CENTER);
119 wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxHORIZONTAL, this, wxT("&Actions"));
120 wxPanel* actionsPanel = new wxPanel(this);
121 wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL);
123 wxFlexGridSizer* actionsGridSizer = new wxFlexGridSizer(1, 2, 9, 15);
125 wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Open File"));
126 editCMakebt->SetToolTip(wxT("Open the CMakeLists file in the default text editor."));
127 actionsGridSizer->Add(editCMakebt, 1, wxALL | wxEXPAND, 5);
128 wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Containing Folder"));
129 openFolderbt->SetToolTip(wxT("Open the folder where the CMakeLists file is located in the file explorer."));
130 actionsGridSizer->Add(openFolderbt, 1, wxALL | wxEXPAND, 5);
132 actionsGridSizer->AddGrowableCol(0,1);
133 actionsGridSizer->AddGrowableCol(1,1);
135 actionsPanelSizer->Add(actionsGridSizer, 1, wxEXPAND, 0);
136 actionsPanel->SetSizer(actionsPanelSizer);
137 actionsPanelSizer->Fit(actionsPanel);
138 actionsBox->Add(actionsPanel, 1, wxEXPAND);
139 sizer -> Add(actionsBox, 0, wxEXPAND | wxALL, 10);
143 sizer->SetSizeHints(this);
146 void wxCDMCMakeListsDescriptionPanel::OnBtnReturn(wxHyperlinkEvent& event)
148 std::vector<modelCDMIProjectTreeNode*> parents = this->cMakeLists->GetParents();
149 std::string parentURL = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL());
150 //std::cout << parentURL << std::endl;
151 for (int i = 0; i < (int)(parents.size()); i++)
153 if (parents[i]->GetPath() == parentURL)
155 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
156 newEvent->SetClientData(parents[i]);
158 wxPostEvent(this->GetParent(), *newEvent);
163 void wxCDMCMakeListsDescriptionPanel::OnBtnOpenInEditor(wxCommandEvent& event)
166 if(!this->cMakeLists->OpenFile(result))
167 wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
170 void wxCDMCMakeListsDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
173 if(!this->cMakeLists->OpenInFileExplorer(result))
174 wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR);