]> Creatis software - crea.git/blob - lib/creaDevManagerLib/wxCDMMainFrame.cpp
add previous authors
[crea.git] / lib / creaDevManagerLib / wxCDMMainFrame.cpp
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
5 #                        pour la Santé)
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
9 #
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.
16 #
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
21 #  liability. 
22 #
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 # ------------------------------------------------------------------------ 
26 */ 
27
28
29 #include "wxCDMMainFrame.h"
30
31 #include "creaDevManagerIds.h"
32 #include "wxCDMMainDescriptionPanel.h"
33 #include "wxCDMProjectActionsPanel.h"
34 #include "wxCDMNewProjectDialog.h"
35
36
37 #include <iostream>
38
39
40
41 BEGIN_EVENT_TABLE(wxCDMMainFrame, wxFrame)
42   EVT_MENU(ID_MENU_NEW_PROJECT, wxCDMMainFrame::OnMenuNewProject)
43   EVT_MENU(ID_MENU_OPEN_PROJECT, wxCDMMainFrame::OnMenuOpenProject)
44   EVT_MENU(ID_MENU_OPEN_RECENT, wxCDMMainFrame::OnMenuOpenRecent)
45   EVT_MENU(ID_MENU_CLOSE_PROJECT, wxCDMMainFrame::OnMenuCloseProject)
46   EVT_MENU(ID_MENU_CLOSE_ALL_PROJECTS, wxCDMMainFrame::OnMenuCloseAllProjects)
47   EVT_MENU(ID_MENU_EXPORT_HIERARCHY, wxCDMMainFrame::OnMenuExportHierarchy)
48   EVT_MENU(ID_MENU_EXIT, wxCDMMainFrame::OnMenuExit)
49   EVT_MENU(ID_MENU_REFRESH_PROJECT, wxCDMMainFrame::OnMenuRefreshProject)
50   EVT_MENU(ID_MENU_CUT, wxCDMMainFrame::OnMenuMenuCut)
51   EVT_MENU(ID_MENU_COPY, wxCDMMainFrame::OnMenuMenuCopy)
52   EVT_MENU(ID_MENU_PASTE, wxCDMMainFrame::OnMenuMenuPaste)
53   EVT_MENU(ID_MENU_DELETE, wxCDMMainFrame::OnMenuMenuDelete)
54   EVT_MENU(ID_MENU_SELECT_ALL, wxCDMMainFrame::OnMenuSelectAll)
55   EVT_MENU(ID_MENU_SELECT_NONE, wxCDMMainFrame::OnMenuSelectNone)
56   EVT_MENU(ID_MENU_EVENT_LOG, wxCDMMainFrame::OnMenuEventLog)
57   EVT_MENU(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxCDMMainFrame::OnMenuBBTKGraphicalEditor)
58   EVT_MENU(ID_MENU_MINITOOLS, wxCDMMainFrame::OnMenuMiniTools)
59   EVT_MENU(ID_MENU_CODE_EDITOR, wxCDMMainFrame::OnMenuCodeEditor)
60   EVT_MENU(ID_MENU_COMMAND_LINE, wxCDMMainFrame::OnMenuCommandLine)
61   EVT_MENU(ID_MENU_HELP, wxCDMMainFrame::OnMenuHelp)
62   EVT_MENU(ID_MENU_REPORT_BUG, wxCDMMainFrame::OnMenuReportBug)
63   EVT_MENU(ID_MENU_ABOUT_CREADEVMANAGER, wxCDMMainFrame::OnMenuAboutCreaDevManager)
64   EVT_MENU(ID_MENU_ABOUT_CREATIS, wxCDMMainFrame::OnMenuAboutCreatis)
65   EVT_BUTTON(ID_BUTTON_NEWPROJECT, wxCDMMainFrame::OnMenuNewProject)
66   EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMMainFrame::OnMenuOpenProject)
67 END_EVENT_TABLE()
68
69 wxCDMMainFrame::wxCDMMainFrame(
70   wxWindow* parent,
71   wxWindowID id,
72   const wxString& caption,
73   const wxPoint& pos,
74   const wxSize& size,
75   long style
76 )
77 {
78   Create(parent, id, caption, pos, size, style);
79 }
80
81 wxCDMMainFrame::~wxCDMMainFrame()
82 {
83   auiManager.UnInit();
84 }
85
86 bool wxCDMMainFrame::Create(
87   wxWindow* parent,
88   wxWindowID id,
89   const wxString& caption,
90   const wxPoint& pos,
91   const wxSize& size,
92   long style
93 )
94 {
95   wxFrame::Create(parent, id, caption, pos, size, style);
96   this->model = new modelCDMMain();
97   CreateMenus();
98   CreateControls();
99   return TRUE;
100 }
101
102 void wxCDMMainFrame::CreateMenus()
103 {
104   wxMenuBar* menuBar = new wxMenuBar;
105
106   //FileMenu
107   menu_File = new wxMenu();
108   menu_File->Append(ID_MENU_NEW_PROJECT, wxString("&New Project..."));
109   menu_File->Append(ID_MENU_OPEN_PROJECT, wxString("&Open Project..."));
110   menu_File->Append(ID_MENU_OPEN_RECENT, wxString("Open &Recent"));
111   menu_File->AppendSeparator();
112   menu_File->Append(ID_MENU_CLOSE_PROJECT, wxString("&Close Project"));
113   menu_File->Append(ID_MENU_CLOSE_ALL_PROJECTS, wxString("C&lose All Projects"));
114   menu_File->AppendSeparator();
115   menu_File->Append(ID_MENU_EXPORT_HIERARCHY, wxString("&Export Project Hierarchy..."));
116   menu_File->AppendSeparator();
117   menu_File->Append(ID_MENU_EXIT, wxString("E&xit"));
118
119   menuBar->Append(menu_File, wxString("&File"));
120
121   //EditMenu
122   menu_Edit = new wxMenu();
123   menu_Edit->Append(ID_MENU_REFRESH_PROJECT, wxString("&Refresh Project"));
124   menu_Edit->AppendSeparator();
125   menu_Edit->Append(ID_MENU_CUT, wxString("Cu&t"));
126   menu_Edit->Append(ID_MENU_COPY, wxString("&Copy"));
127   menu_Edit->Append(ID_MENU_PASTE, wxString("&Paste"));
128   menu_Edit->AppendSeparator();
129   menu_Edit->Append(ID_MENU_DELETE, wxString("&Delete"));
130   menu_Edit->Append(ID_MENU_SELECT_ALL, wxString("Select &All"));
131   menu_Edit->Append(ID_MENU_SELECT_NONE, wxString("Ca&ncel Selection"));
132
133   menuBar->Append(menu_Edit, wxString("&Edit"));
134
135   //ToolsMenu
136   menu_Tools = new wxMenu();
137   menu_Tools->Append(ID_MENU_EVENT_LOG, wxString("Event &Log"));
138   menu_Tools->Append(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxString("BBTK &Graphical Editor"));
139   menu_Tools->Append(ID_MENU_MINITOOLS, wxString("&MiniTools"));
140   menu_Tools->Append(ID_MENU_CODE_EDITOR, wxString("&Code Editor"));
141   menu_Tools->Append(ID_MENU_COMMAND_LINE, wxString("&Command Line"));
142
143   menuBar->Append(menu_Tools, wxString("&Tools"));
144
145   //HelpMenu
146   menu_Help = new wxMenu();
147   menu_Help->Append(ID_MENU_HELP, wxString("&Help"));
148   menu_Help->Append(ID_MENU_REPORT_BUG, wxString("Report &Bug"));
149   menu_Help->Append(ID_MENU_ABOUT_CREADEVMANAGER, wxString("&About CreaDevManager"));
150   menu_Help->Append(ID_MENU_ABOUT_CREATIS, wxString("A&bout CREATIS"));
151
152   menuBar->Append(menu_Help, wxString("&Help"));
153
154   //Set Bar
155   SetMenuBar(menuBar);
156
157   wxStatusBar* statusBar = new wxStatusBar(this, ID_STATUS_BAR, wxST_SIZEGRIP);
158   statusBar->SetFieldsCount(1);
159   SetStatusBar(statusBar);
160
161 }
162
163 void wxCDMMainFrame::CreateControls()
164 {
165
166   auiManager.SetManagedWindow(this);
167
168
169   tree_Projects = new wxCDMProjectsTreeCtrl(
170     this,
171     ID_TREE_PROJECTS,
172     wxDefaultPosition,
173     wxSize(300,400),
174     wxTR_HAS_BUTTONS | wxTR_AQUA_BUTTONS
175   );
176   tree_Projects->SetMinSize(wxSize(200,200));
177
178   panel_Properties = new wxCDMMainDescriptionPanel(
179     this,
180     ID_WINDOW_PROPERTIES,
181     wxString("Description Panel"),
182     wxDefaultPosition,
183     wxSize(300, 400),
184     0
185   );
186
187
188
189   panel_ProjectActions = new wxCDMProjectActionsPanel(
190     this,
191     ID_WINDOW_PROJ_ACTIONS,
192     wxString("Project Actions Panel"),
193     wxDefaultPosition,
194     wxSize(600,200),
195     0
196   );
197   panel_ProjectActions->SetMinSize(wxSize(500, 100));
198
199   auiManager.AddPane(tree_Projects, wxLEFT, wxString("Projects Tree"));
200   auiManager.AddPane(panel_ProjectActions, wxBOTTOM, wxString("Project Actions"));
201   auiManager.AddPane(panel_Properties, wxCENTER, wxString("Properties"));
202
203   auiManager.Update();
204   auiManager.GetPane(tree_Projects).CloseButton(false).MaximizeButton(true);
205   auiManager.GetPane(panel_Properties).CloseButton(false);
206 }
207
208 //Event Handlers
209 //File menu
210 void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event)
211 {
212   wxCDMNewProjectDialog* dialog = new wxCDMNewProjectDialog(this);
213   long userResponse;
214   userResponse = dialog->ShowModal();
215
216   if(userResponse == wxID_FORWARD)
217   {
218     //TODO createProject
219     std::cerr << "should create Project here" << std::endl;
220     //tree_Projects->BuildTree(this->model->GetActiveProjects());
221   }
222
223   event.Skip();
224 }
225 void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event)
226 {
227   /*
228   long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
229   wxDirDialog* FD = new wxDirDialog(this, wxString("Select the project directory"), wxString(""), style);
230   long userResponse;
231   userResponse = FD->ShowModal();
232   if(userResponse == wxID_OK)
233   {
234     switch(this->controller->OpenProject(crea::wx2std (FD->GetPath())))
235     {
236     case 1:
237       wxMessageBox( wxT("No project selected."), wxT("Open Project - Error"), wxICON_ERROR);
238       event.Skip();
239       break;
240     case 2:
241       wxMessageBox( wxString("Sources not found."), wxString("Open Project - Error"), wxICON_ERROR);
242       event.Skip();
243       break;
244     case 0:
245       break;
246     };
247
248     ((wxCreaDevManagerTreeCtrl*)tree_Projects)->BuildTree(controller->GetActiveProjects());
249
250     auiManager.Update();
251   }
252   */
253   event.Skip();
254 }
255 void wxCDMMainFrame::OnMenuOpenRecent(wxCommandEvent& event)
256 {
257   std::cerr << "Event OnMenuOpenRecent not implemented" << std::endl;
258   event.Skip();
259 }
260 void wxCDMMainFrame::OnMenuCloseProject(wxCommandEvent& event)
261 {
262   std::cerr << "Event OnMenuCloseProject not implemented" << std::endl;
263   event.Skip();
264 }
265 void wxCDMMainFrame::OnMenuCloseAllProjects(wxCommandEvent& event)
266 {
267   std::cerr << "Event OnMenuCloseAllProjects not implemented" << std::endl;
268   event.Skip();
269 }
270 void wxCDMMainFrame::OnMenuExportHierarchy(wxCommandEvent& event)
271 {
272   std::cerr << "Event OnMenuExportHierarchy not implemented" << std::endl;
273   event.Skip();
274 }
275 void wxCDMMainFrame::OnMenuExit(wxCommandEvent& event)
276 {
277   std::cout << "Closing CreaDevManager..." << std::endl;
278   Close();
279   event.Skip();
280 }
281
282 //Edit Menu
283 void wxCDMMainFrame::OnMenuRefreshProject(wxCommandEvent& event)
284 {
285   std::cerr << "Event OnMenuRefreshProject not implemented" << std::endl;
286   event.Skip();
287 }
288 void wxCDMMainFrame::OnMenuMenuCut(wxCommandEvent& event)
289 {
290   std::cerr << "Event OnMenuMenuCut not implemented" << std::endl;
291   event.Skip();
292 }
293 void wxCDMMainFrame::OnMenuMenuCopy(wxCommandEvent& event)
294 {
295   std::cerr << "Event OnMenuMenuCopy not implemented" << std::endl;
296   event.Skip();
297 }
298 void wxCDMMainFrame::OnMenuMenuPaste(wxCommandEvent& event)
299 {
300   std::cerr << "Event OnMenuMenuPaste not implemented" << std::endl;
301   event.Skip();
302 }
303 void wxCDMMainFrame::OnMenuMenuDelete(wxCommandEvent& event)
304 {
305   std::cerr << "Event OnMenuMenuDelete not implemented" << std::endl;
306   event.Skip();
307 }
308 void wxCDMMainFrame::OnMenuSelectAll(wxCommandEvent& event)
309 {
310   std::cerr << "Event OnMenuSelectAll not implemented" << std::endl;
311   event.Skip();
312 }
313 void wxCDMMainFrame::OnMenuSelectNone(wxCommandEvent& event)
314 {
315   std::cerr << "Event OnMenuSelectNone not implemented" << std::endl;
316   event.Skip();
317 }
318
319 //Tools Menu
320 void wxCDMMainFrame::OnMenuEventLog(wxCommandEvent& event)
321 {
322   std::cerr << "Event OnMenuEventLog not implemented" << std::endl;
323   event.Skip();
324 }
325 void wxCDMMainFrame::OnMenuBBTKGraphicalEditor(wxCommandEvent& event)
326 {
327   std::cerr << "Event OnMenuBBTKGraphicalEditor not implemented" << std::endl;
328   event.Skip();
329 }
330 void wxCDMMainFrame::OnMenuMiniTools(wxCommandEvent& event)
331 {
332   std::cerr << "Event OnMenuMiniTools not implemented" << std::endl;
333   event.Skip();
334 }
335 void wxCDMMainFrame::OnMenuCodeEditor(wxCommandEvent& event)
336 {
337   std::cerr << "Event OnMenuCodeEditor not implemented" << std::endl;
338   event.Skip();
339 }
340 void wxCDMMainFrame::OnMenuCommandLine(wxCommandEvent& event)
341 {
342   std::cerr << "Event OnMenuCommandLine not implemented" << std::endl;
343   event.Skip();
344 }
345
346 //Help Menu
347 void wxCDMMainFrame::OnMenuHelp(wxCommandEvent& event)
348 {
349   std::cerr << "Event OnMenuHelp not implemented" << std::endl;
350   event.Skip();
351 }
352 void wxCDMMainFrame::OnMenuReportBug(wxCommandEvent& event)
353 {
354   std::cerr << "Event OnMenuReportBug not implemented" << std::endl;
355   event.Skip();
356 }
357 void wxCDMMainFrame::OnMenuAboutCreaDevManager(wxCommandEvent& event)
358 {
359   std::cerr << "Event OnMenuAboutCreaDevManager not implemented" << std::endl;
360   event.Skip();
361 }
362 void wxCDMMainFrame::OnMenuAboutCreatis(wxCommandEvent& event)
363 {
364   std::cerr << "Event OnMenuAboutCreatis not implemented" << std::endl;
365   event.Skip();
366 }