2 * This file is part of ShapeFusion (Copyright 2000 Tito Dal Canton)
4 * ShapeFusion is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * ShapeFusion is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with ShapeFusion; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include "ShapeFusionApp.h"
20 #include "ShapeFusionMenus.h"
21 #include "ShapesDocument.h"
22 #include "ShapesView.h"
23 #include "SoundsDocument.h"
24 #include "SoundsView.h"
25 #include "PhysicsDocument.h"
26 #include "PhysicsView.h"
28 ShapeFusionMain *frame = (ShapeFusionMain *)NULL;
30 IMPLEMENT_APP(ShapeFusionApp)
32 ShapeFusionApp::ShapeFusionApp(void)
34 m_docManager = (ShapeFusionDocManager *)NULL;
37 bool ShapeFusionApp::OnInit(void)
42 // so that we can import every sort of bitmap format
43 wxInitAllImageHandlers();
45 // Create a document manager
46 m_docManager = new ShapeFusionDocManager;
48 // Create a template relating drawing documents to their views
49 (void) new wxDocTemplate(m_docManager, _T("Shapes"), _T("*"), _T(""), _T(""), _T("Shapes"), _T("Shapes"),
50 CLASSINFO(ShapesDocument), CLASSINFO(ShapesView));
51 (void) new wxDocTemplate(m_docManager, _T("Sounds"), _T("*"), _T(""), _T(""), _T("Sounds"), _T("Sounds"),
52 CLASSINFO(SoundsDocument), CLASSINFO(SoundsView));
54 (void) new wxDocTemplate(m_docManager, _T("Physics"), _T("*"), _T(""), _T(""), _T("Physics"), _T("Physics"), CLASSINFO(PhysicsDocument), CLASSINFO(PhysicsView));
57 //TODO: Put correct file extension values here
58 // wxFileName::MacRegisterDefaultTypeAndCreator( wxT("*") , 'WXMB' , 'WXMA' );
59 // wxFileName::MacRegisterDefaultTypeAndCreator( wxT("*") , 'WXMB' , 'WXMA' );
62 // Create the main frame window
64 // a hack to make the frame invisible on MacOS, which is more Mac-like
65 // http://www.wxwidgets.org/wiki/index.php/WxMac_Issues#The_Mac_OS_menu_bar
66 frame = new ShapeFusionMain(m_docManager, (wxFrame *)NULL, wxID_ANY, _T("ShapeFusion Workspace"), wxPoint(5,5), wxSize(0,0), 0);
68 frame = new ShapeFusionMain(m_docManager, (wxFrame *)NULL, wxID_ANY, _T("ShapeFusion Workspace"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE);
71 // Give it an icon (this is ignored in MDI mode: uses resources)
73 frame->SetIcon(wxIcon(_T("doc_icn")));
76 wxMenuBar *menu_bar = new wxMenuBar;
78 CreateFileMenu(menu_bar);
79 CreateEditMenu(menu_bar);
80 CreateHelpMenu(menu_bar);
82 // Associate the menu bar with the frame
83 frame->SetMenuBar(menu_bar);
85 //FIXME: This doesn't work
86 //wxMenuItem *menuItem = menu_bar->FindItem(FILE_MENU_HISTORY);
87 //m_docManager->FileHistoryUseMenu(menuItem->GetMenu());
89 frame->Centre(wxBOTH);
96 int ShapeFusionApp::OnExit(void)
103 * Centralised code for creating a document frame.
104 * Called when a new view is created (after a New/Open event)
106 wxFrame *ShapeFusionApp::CreateChildFrame(wxDocument *doc, wxView *view, const wxString title, wxPoint point, wxSize size, long style)
108 // Make a child frame
109 wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, GetMainFrame(), wxID_ANY, title,
112 wxMenuBar *menu_bar = new wxMenuBar;
114 CreateFileMenu(menu_bar);
115 CreateEditMenu(menu_bar);
116 CreateHelpMenu(menu_bar);
118 // Associate the menu bar with the frame
119 subframe->SetMenuBar(menu_bar);
121 //FIXME: This doesn't work
122 //wxMenuItem *menuItem = menu_bar->FindItem(FILE_MENU_HISTORY);
123 //m_docManager->FileHistoryUseMenu(menuItem->GetMenu());
125 subframe->Centre(wxBOTH);
130 ShapeFusionMain *GetMainFrame(void)