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 #include "wxCDMMainFrame.h"
34 #include "wx/treectrl.h"
35 #include "CDMUtilities.h"
37 #include "creaDevManagerIds.h"
38 #include "wxCDMMainDescriptionPanel.h"
39 #include "wxCDMProjectActionsPanel.h"
40 #include "wxCDMNewProjectDialog.h"
43 BEGIN_EVENT_TABLE(wxCDMMainFrame, wxFrame)
44 EVT_MENU(ID_MENU_NEW_PROJECT, wxCDMMainFrame::OnMenuNewProject)
45 EVT_MENU(ID_MENU_OPEN_PROJECT, wxCDMMainFrame::OnMenuOpenProject)
46 EVT_MENU(ID_MENU_OPEN_RECENT, wxCDMMainFrame::OnMenuOpenRecent)
47 EVT_MENU(ID_MENU_CLOSE_PROJECT, wxCDMMainFrame::OnMenuCloseProject)
48 EVT_MENU(ID_MENU_CLOSE_ALL_PROJECTS, wxCDMMainFrame::OnMenuCloseAllProjects)
49 EVT_MENU(ID_MENU_EXPORT_HIERARCHY, wxCDMMainFrame::OnMenuExportHierarchy)
50 EVT_MENU(ID_MENU_EXIT, wxCDMMainFrame::OnMenuExit)
51 EVT_MENU(ID_MENU_REFRESH_PROJECT, wxCDMMainFrame::OnMenuRefreshProject)
52 EVT_MENU(ID_MENU_CUT, wxCDMMainFrame::OnMenuMenuCut)
53 EVT_MENU(ID_MENU_COPY, wxCDMMainFrame::OnMenuMenuCopy)
54 EVT_MENU(ID_MENU_PASTE, wxCDMMainFrame::OnMenuMenuPaste)
55 EVT_MENU(ID_MENU_DELETE, wxCDMMainFrame::OnMenuMenuDelete)
56 EVT_MENU(ID_MENU_SELECT_ALL, wxCDMMainFrame::OnMenuSelectAll)
57 EVT_MENU(ID_MENU_SELECT_NONE, wxCDMMainFrame::OnMenuSelectNone)
58 EVT_MENU(ID_MENU_EVENT_LOG, wxCDMMainFrame::OnMenuEventLog)
59 EVT_MENU(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxCDMMainFrame::OnMenuBBTKGraphicalEditor)
60 EVT_MENU(ID_MENU_MINITOOLS, wxCDMMainFrame::OnMenuMiniTools)
61 EVT_MENU(ID_MENU_CODE_EDITOR, wxCDMMainFrame::OnMenuCodeEditor)
62 EVT_MENU(ID_MENU_COMMAND_LINE, wxCDMMainFrame::OnMenuCommandLine)
63 EVT_MENU(ID_MENU_HELP, wxCDMMainFrame::OnMenuHelp)
64 EVT_MENU(ID_MENU_REPORT_BUG, wxCDMMainFrame::OnMenuReportBug)
65 EVT_MENU(ID_MENU_ABOUT_CREADEVMANAGER, wxCDMMainFrame::OnMenuAboutCreaDevManager)
66 EVT_MENU(ID_MENU_ABOUT_CREATIS, wxCDMMainFrame::OnMenuAboutCreatis)
67 EVT_BUTTON(ID_BUTTON_NEWPROJECT, wxCDMMainFrame::OnMenuNewProject)
68 EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMMainFrame::OnMenuOpenProject)
69 EVT_TREE_SEL_CHANGED(ID_TREE_PROJECTS, wxCDMMainFrame::OnTreeSelectionChanged)
72 wxCDMMainFrame::wxCDMMainFrame(
75 const wxString& caption,
81 Create(parent, id, caption, pos, size, style);
84 wxCDMMainFrame::~wxCDMMainFrame()
89 bool wxCDMMainFrame::Create(
92 const wxString& caption,
98 wxFrame::Create(parent, id, caption, pos, size, style);
99 this->model = new modelCDMMain();
105 void wxCDMMainFrame::CreateMenus()
107 wxMenuBar* menuBar = new wxMenuBar;
110 menu_File = new wxMenu();
111 menu_File->Append(ID_MENU_NEW_PROJECT, wxT("&New Project..."));
112 menu_File->Append(ID_MENU_OPEN_PROJECT, wxT("&Open Project..."));
113 menu_File->Append(ID_MENU_OPEN_RECENT, wxT("Open &Recent"));
114 menu_File->AppendSeparator();
115 menu_File->Append(ID_MENU_CLOSE_PROJECT, wxT("&Close Project"));
116 menu_File->Append(ID_MENU_CLOSE_ALL_PROJECTS, wxT("C&lose All Projects"));
117 menu_File->AppendSeparator();
118 menu_File->Append(ID_MENU_EXPORT_HIERARCHY, wxT("&Export Project Hierarchy..."));
119 menu_File->AppendSeparator();
120 menu_File->Append(ID_MENU_EXIT, wxT("E&xit"));
122 menuBar->Append(menu_File, wxT("&File"));
125 menu_Edit = new wxMenu();
126 menu_Edit->Append(ID_MENU_REFRESH_PROJECT, wxT("&Refresh Project"));
127 menu_Edit->AppendSeparator();
128 menu_Edit->Append(ID_MENU_CUT, wxT("Cu&t"));
129 menu_Edit->Append(ID_MENU_COPY, wxT("&Copy"));
130 menu_Edit->Append(ID_MENU_PASTE, wxT("&Paste"));
131 menu_Edit->AppendSeparator();
132 menu_Edit->Append(ID_MENU_DELETE, wxT("&Delete"));
133 menu_Edit->Append(ID_MENU_SELECT_ALL, wxT("Select &All"));
134 menu_Edit->Append(ID_MENU_SELECT_NONE, wxT("Ca&ncel Selection"));
136 menuBar->Append(menu_Edit, wxT("&Edit"));
139 menu_Tools = new wxMenu();
140 menu_Tools->Append(ID_MENU_EVENT_LOG, wxT("Event &Log"));
141 menu_Tools->Append(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxT("BBTK &Graphical Editor"));
142 menu_Tools->Append(ID_MENU_MINITOOLS, wxT("&MiniTools"));
143 menu_Tools->Append(ID_MENU_CODE_EDITOR, wxT("&Code Editor"));
144 menu_Tools->Append(ID_MENU_COMMAND_LINE, wxT("&Command Line"));
146 menuBar->Append(menu_Tools, wxT("&Tools"));
149 menu_Help = new wxMenu();
150 menu_Help->Append(ID_MENU_HELP, wxT("&Help"));
151 menu_Help->Append(ID_MENU_REPORT_BUG, wxT("Report &Bug"));
152 menu_Help->Append(ID_MENU_ABOUT_CREADEVMANAGER, wxT("&About CreaDevManager"));
153 menu_Help->Append(ID_MENU_ABOUT_CREATIS, wxT("A&bout CREATIS"));
155 menuBar->Append(menu_Help, wxT("&Help"));
160 wxStatusBar* statusBar = new wxStatusBar(this, ID_STATUS_BAR, wxST_SIZEGRIP);
161 statusBar->SetFieldsCount(1);
162 SetStatusBar(statusBar);
166 void wxCDMMainFrame::CreateControls()
169 auiManager.SetManagedWindow(this);
172 tree_Projects = new wxCDMProjectsTreeCtrl(
177 wxTR_HAS_BUTTONS | wxTR_AQUA_BUTTONS
179 tree_Projects->SetMinSize(wxSize(200,200));
181 panel_Properties = new wxCDMMainDescriptionPanel(
183 ID_WINDOW_PROPERTIES,
184 wxT("Description Panel"),
192 panel_ProjectActions = new wxCDMProjectActionsPanel(
194 ID_WINDOW_PROJ_ACTIONS,
195 wxT("Project Actions Panel"),
200 panel_ProjectActions->SetMinSize(wxSize(500, 100));
202 auiManager.AddPane(tree_Projects, wxLEFT, wxT("Projects Tree"));
203 auiManager.AddPane(panel_ProjectActions, wxBOTTOM, wxT("Project Actions"));
204 auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
207 auiManager.GetPane(tree_Projects).CloseButton(false).MaximizeButton(true);
208 auiManager.GetPane(panel_Properties).CloseButton(false);
213 void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event)
215 wxCDMNewProjectDialog* dialog = new wxCDMNewProjectDialog(this);
217 userResponse = dialog->ShowModal();
219 if(userResponse == wxID_FORWARD)
223 if(!this->model->CreateProject(
224 crea::wx2std(dialog->GetProjectName()),
225 crea::wx2std(dialog->GetProjectLocation()),
227 crea::wx2std(dialog->GetPackageAuthor()),
228 crea::wx2std(dialog->GetPackageDescription())
231 wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR);
236 //populate tree control
237 tree_Projects->BuildTree(this->model->GetProject());
238 tree_Projects->SelectItem(this->model->GetProject()->GetId());
239 //TODO: change description panel
240 //TODO: change project's actions panel
243 wxMessageBox(_T("New Project created!"),_T("New Project - Success!"), wxOK | wxICON_INFORMATION);
248 void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event)
250 long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
251 wxDirDialog* FD = new wxDirDialog(this, wxT("Select the project directory"), wxT(""), style);
252 long userResponse = FD->ShowModal();
253 if(userResponse == wxID_OK)
255 std::string path = crea::wx2std (FD->GetPath());
259 std::cout << "Selection to open: " << path << std::endl;
264 if (!this->model->OpenProject(path, result))
266 wxMessageBox( crea::std2wx(result->c_str()), wxT("Open Project - Error"), wxICON_ERROR);
269 //populate tree control
270 tree_Projects->BuildTree(this->model->GetProject());
271 tree_Projects->SelectItem(this->model->GetProject()->GetId());
277 void wxCDMMainFrame::OnMenuOpenRecent(wxCommandEvent& event)
279 std::cerr << "Event OnMenuOpenRecent not implemented" << std::endl;
282 void wxCDMMainFrame::OnMenuCloseProject(wxCommandEvent& event)
285 if(!this->model->CloseProject(result))
287 wxMessageBox( crea::std2wx(result->c_str()), wxT("Close Project - Error"), wxICON_ERROR);
291 void wxCDMMainFrame::OnMenuCloseAllProjects(wxCommandEvent& event)
293 std::cerr << "Event OnMenuCloseAllProjects not implemented" << std::endl;
296 void wxCDMMainFrame::OnMenuExportHierarchy(wxCommandEvent& event)
298 std::cerr << "Event OnMenuExportHierarchy not implemented" << std::endl;
301 void wxCDMMainFrame::OnMenuExit(wxCommandEvent& event)
303 std::cout << "Closing CreaDevManager..." << std::endl;
309 void wxCDMMainFrame::OnMenuRefreshProject(wxCommandEvent& event)
312 if(!model->RefreshProject(result))
314 wxMessageBox( crea::std2wx(result->c_str()), wxT("Refresh Project - Error"), wxICON_ERROR);
316 //TODO: Show possible problems in CMakeLists files
319 void wxCDMMainFrame::OnMenuMenuCut(wxCommandEvent& event)
321 std::cerr << "Event OnMenuMenuCut not implemented" << std::endl;
324 void wxCDMMainFrame::OnMenuMenuCopy(wxCommandEvent& event)
326 std::cerr << "Event OnMenuMenuCopy not implemented" << std::endl;
329 void wxCDMMainFrame::OnMenuMenuPaste(wxCommandEvent& event)
331 std::cerr << "Event OnMenuMenuPaste not implemented" << std::endl;
334 void wxCDMMainFrame::OnMenuMenuDelete(wxCommandEvent& event)
336 std::cerr << "Event OnMenuMenuDelete not implemented" << std::endl;
339 void wxCDMMainFrame::OnMenuSelectAll(wxCommandEvent& event)
341 std::cerr << "Event OnMenuSelectAll not implemented" << std::endl;
344 void wxCDMMainFrame::OnMenuSelectNone(wxCommandEvent& event)
346 std::cerr << "Event OnMenuSelectNone not implemented" << std::endl;
351 void wxCDMMainFrame::OnMenuEventLog(wxCommandEvent& event)
353 std::cerr << "Event OnMenuEventLog not implemented" << std::endl;
356 void wxCDMMainFrame::OnMenuBBTKGraphicalEditor(wxCommandEvent& event)
358 std::cerr << "Event OnMenuBBTKGraphicalEditor not implemented" << std::endl;
361 void wxCDMMainFrame::OnMenuMiniTools(wxCommandEvent& event)
363 std::cerr << "Event OnMenuMiniTools not implemented" << std::endl;
366 void wxCDMMainFrame::OnMenuCodeEditor(wxCommandEvent& event)
368 std::cerr << "Event OnMenuCodeEditor not implemented" << std::endl;
371 void wxCDMMainFrame::OnMenuCommandLine(wxCommandEvent& event)
373 std::cerr << "Event OnMenuCommandLine not implemented" << std::endl;
378 void wxCDMMainFrame::OnMenuHelp(wxCommandEvent& event)
380 std::cerr << "Event OnMenuHelp not implemented" << std::endl;
383 void wxCDMMainFrame::OnMenuReportBug(wxCommandEvent& event)
385 std::cerr << "Event OnMenuReportBug not implemented" << std::endl;
388 void wxCDMMainFrame::OnMenuAboutCreaDevManager(wxCommandEvent& event)
390 std::cerr << "Event OnMenuAboutCreaDevManager not implemented" << std::endl;
393 void wxCDMMainFrame::OnMenuAboutCreatis(wxCommandEvent& event)
395 std::cerr << "Event OnMenuAboutCreatis not implemented" << std::endl;
399 void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
401 std::cerr << "Event OnTreeSelectionChange not implemented" << std::endl;