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