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 locale.Init(wxLANGUAGE_DEFAULT);
43 locale.AddCatalogLookupPathPrefix(wxT("."));
44 locale.AddCatalogLookupPathPrefix(wxT("./locale/"));
45 locale.AddCatalog(wxT("ShapeFusion"));
47 // so that we can import every sort of bitmap format
48 wxInitAllImageHandlers();
50 // Create a document manager
51 m_docManager = new ShapeFusionDocManager;
53 // Create a template relating drawing documents to their views
54 (void) new wxDocTemplate(m_docManager, wxT("Shapes"), wxT("*"), wxT(""), wxT(""), wxT("Shapes"), wxT("Shapes"),
55 CLASSINFO(ShapesDocument), CLASSINFO(ShapesView));
56 (void) new wxDocTemplate(m_docManager, wxT("Sounds"), wxT("*"), wxT(""), wxT(""), wxT("Sounds"), wxT("Sounds"),
57 CLASSINFO(SoundsDocument), CLASSINFO(SoundsView));
59 (void) new wxDocTemplate(m_docManager, wxT("Physics"), wxT("*"), wxT(""), wxT(""), wxT("Physics"), wxT("Physics"), CLASSINFO(PhysicsDocument), CLASSINFO(PhysicsView));
62 //TODO: Put correct file extension values here
63 // wxFileName::MacRegisterDefaultTypeAndCreator( wxT("*") , 'WXMB' , 'WXMA' );
64 // wxFileName::MacRegisterDefaultTypeAndCreator( wxT("*") , 'WXMB' , 'WXMA' );
67 // Create the main frame window
69 // a hack to make the frame invisible on MacOS, which is more Mac-like
70 // http://www.wxwidgets.org/wiki/index.php/WxMac_Issues#The_Mac_OS_menu_bar
71 frame = new ShapeFusionMain(m_docManager, (wxFrame *)NULL, wxID_ANY, _("ShapeFusion Workspace"), wxPoint(5,5), wxSize(0,0), 0);
73 frame = new ShapeFusionMain(m_docManager, (wxFrame *)NULL, wxID_ANY, _("ShapeFusion Workspace"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE);
76 // Give it an icon (this is ignored in MDI mode: uses resources)
78 frame->SetIcon(wxIcon(wxT("doc_icn")));
81 wxMenuBar *menu_bar = new wxMenuBar;
83 CreateFileMenu(menu_bar);
84 CreateEditMenu(menu_bar);
85 CreateHelpMenu(menu_bar);
87 // Associate the menu bar with the frame
88 frame->SetMenuBar(menu_bar);
90 //FIXME: This doesn't work
91 //wxMenuItem *menuItem = menu_bar->FindItem(FILE_MENU_HISTORY);
92 //m_docManager->FileHistoryUseMenu(menuItem->GetMenu());
94 frame->Centre(wxBOTH);
101 int ShapeFusionApp::OnExit(void)
108 * Centralised code for creating a document frame.
109 * Called when a new view is created (after a New/Open event)
111 wxFrame *ShapeFusionApp::CreateChildFrame(wxDocument *doc, wxView *view, const wxString title, wxPoint point, wxSize size, long style)
113 // Make a child frame
114 wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, GetMainFrame(), wxID_ANY, title,
117 wxMenuBar *menu_bar = new wxMenuBar;
119 CreateFileMenu(menu_bar);
120 CreateEditMenu(menu_bar);
121 CreateHelpMenu(menu_bar);
123 // Associate the menu bar with the frame
124 subframe->SetMenuBar(menu_bar);
126 //FIXME: This doesn't work
127 //wxMenuItem *menuItem = menu_bar->FindItem(FILE_MENU_HISTORY);
128 //m_docManager->FileHistoryUseMenu(menuItem->GetMenu());
130 subframe->Centre(wxBOTH);
135 ShapeFusionMain *GetMainFrame(void)