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