-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathShapeFusionApp.cpp
133 lines (106 loc) · 4.18 KB
/
ShapeFusionApp.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
* This file is part of ShapeFusion (Copyright 2000 Tito Dal Canton)
*
* ShapeFusion is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* ShapeFusion is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ShapeFusion; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "ShapeFusionApp.h"
#include "ShapeFusionMenus.h"
#include "ShapesDocument.h"
#include "ShapesView.h"
#include "SoundsDocument.h"
#include "SoundsView.h"
#include "PhysicsDocument.h"
#include "PhysicsView.h"
ShapeFusionMain *frame = (ShapeFusionMain *)NULL;
IMPLEMENT_APP(ShapeFusionApp)
ShapeFusionApp::ShapeFusionApp(void)
{
m_docManager = (ShapeFusionDocManager *)NULL;
}
bool ShapeFusionApp::OnInit(void)
{
if (!wxApp::OnInit())
return false;
// so that we can import every sort of bitmap format
wxInitAllImageHandlers();
// Create a document manager
m_docManager = new ShapeFusionDocManager;
// Create a template relating drawing documents to their views
(void) new wxDocTemplate(m_docManager, _T("Shapes"), _T("*"), _T(""), _T(""), _T("Shapes"), _T("Shapes"),
CLASSINFO(ShapesDocument), CLASSINFO(ShapesView));
(void) new wxDocTemplate(m_docManager, _T("Sounds"), _T("*"), _T(""), _T(""), _T("Sounds"), _T("Sounds"),
CLASSINFO(SoundsDocument), CLASSINFO(SoundsView));
(void) new wxDocTemplate(m_docManager, _T("Physics"), _T("*"), _T(""), _T(""), _T("Physics"), _T("Physics"), CLASSINFO(PhysicsDocument), CLASSINFO(PhysicsView));
#ifdef __WXMAC__
//TODO: Put correct file extension values here
// wxFileName::MacRegisterDefaultTypeAndCreator( wxT("*") , 'WXMB' , 'WXMA' );
// wxFileName::MacRegisterDefaultTypeAndCreator( wxT("*") , 'WXMB' , 'WXMA' );
#endif
// Create the main frame window
#ifdef __WXMAC__
// a hack to make the frame invisible on MacOS, which is more Mac-like
// http://www.wxwidgets.org/wiki/index.php/WxMac_Issues#The_Mac_OS_menu_bar
frame = new ShapeFusionMain(m_docManager, (wxFrame *)NULL, wxID_ANY, _T("ShapeFusion Workspace"), wxPoint(5,5), wxSize(0,0), 0);
#else
frame = new ShapeFusionMain(m_docManager, (wxFrame *)NULL, wxID_ANY, _T("ShapeFusion Workspace"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE);
#endif
// Give it an icon (this is ignored in MDI mode: uses resources)
#ifdef __WXMSW__
frame->SetIcon(wxIcon(_T("doc_icn")));
#endif
wxMenuBar *menu_bar = new wxMenuBar;
CreateFileMenu(menu_bar);
CreateEditMenu(menu_bar);
CreateHelpMenu(menu_bar);
// Associate the menu bar with the frame
frame->SetMenuBar(menu_bar);
//FIXME: This doesn't work
//wxMenuItem *menuItem = menu_bar->FindItem(FILE_MENU_HISTORY);
//m_docManager->FileHistoryUseMenu(menuItem->GetMenu());
frame->Centre(wxBOTH);
frame->Show(true);
SetTopWindow(frame);
return true;
}
int ShapeFusionApp::OnExit(void)
{
delete m_docManager;
return 0;
}
/*
* Centralised code for creating a document frame.
* Called when a new view is created (after a New/Open event)
*/
wxFrame *ShapeFusionApp::CreateChildFrame(wxDocument *doc, wxView *view, const wxString title, wxPoint point, wxSize size, long style)
{
// Make a child frame
wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, GetMainFrame(), wxID_ANY, title,
point, size, style);
wxMenuBar *menu_bar = new wxMenuBar;
CreateFileMenu(menu_bar);
CreateEditMenu(menu_bar);
CreateHelpMenu(menu_bar);
// Associate the menu bar with the frame
subframe->SetMenuBar(menu_bar);
//FIXME: This doesn't work
//wxMenuItem *menuItem = menu_bar->FindItem(FILE_MENU_HISTORY);
//m_docManager->FileHistoryUseMenu(menuItem->GetMenu());
subframe->Centre(wxBOTH);
return subframe;
}
ShapeFusionMain *GetMainFrame(void)
{
return frame;
}