33 #include <wx/progdlg.h>
34 #include <boost/format.hpp>
100 wxEVT_COMMAND_BUTTON_CLICKED,
135 const wxString& title,
138 wxFrame((wxFrame*)NULL, -1, title, pos, size),
139 topSplitter_(NULL), toolbar_(NULL), stopDialogInstantiated_(
false),
165 resetMutex_ =
new wxMutex();
166 resetCondition_ =
new wxCondition(*resetMutex_);
192 wxStatusBar* statusbar = CreateStatusBar();
193 int widths[3] = {-1, 200, 200};
194 statusbar->SetFieldsCount(3, widths);
196 sizer_ =
new wxBoxSizer(wxVERTICAL);
207 SetSizeHints(400, 300);
225 wxMenu* fileMenu =
new wxMenu();
226 wxMenu* viewMenu =
new wxMenu();
227 wxMenu* editMenu =
new wxMenu();
228 wxMenu* commandMenu =
new wxMenu();
229 wxMenu* sourceMenu =
new wxMenu();
230 wxMenu* programMenu =
new wxMenu();
231 wxMenu* dataMenu =
new wxMenu();
232 wxMenu* helpMenu =
new wxMenu();
233 wxMenu* highlightMenu =
new wxMenu();
239 _T(
"Open &Machine...")));
244 _T(
"Open &Program...")));
249 _T(
"&Change Directory...")));
251 fileMenu->AppendSeparator();
258 wxMenuBar* menuBar =
new wxMenuBar;
259 menuBar->Append(fileMenu, _T(
"&File"));
262 viewMenu->AppendCheckItem(
264 _T(
"&Simulator Console"));
266 viewMenu->AppendCheckItem(
268 _T(
"Program &Disassembly"));
270 viewMenu->AppendCheckItem(
272 _T(
"&Memory Window"));
274 viewMenu->AppendCheckItem(
276 _T(
"Simulator &Control"));
278 viewMenu->AppendCheckItem(
280 _T(
"&Machine Window"));
282 viewMenu->AppendCheckItem(
284 _T(
"&Breakpoint Window"));
286 viewMenu->AppendCheckItem(
288 _T(
"&Debugger Window"));
290 viewMenu->AppendSeparator();
294 _T(
"New &Register Window")));
299 _T(
"New &Port Window")));
306 menuBar->Append(viewMenu, _T(
"&View"));
311 _T(
"Simulator Settings...")));
319 menuBar->Append(editMenu, _T(
"&Edit"));
325 _T(
"&Clear Console")));
330 _T(
"&Execute File...")));
335 _T(
"&Find in disassembly...")));
337 commandMenu->AppendSeparator();
338 commandMenu->AppendCheckItem(
340 _T(
"Command &History Window"));
342 menuBar->Append(commandMenu, _T(
"&Command"));
345 menuBar->Append(sourceMenu, _T(
"&Source"));
346 sourceMenu->Append(17000, _T(
"&Profile Data"), highlightMenu);
348 highlightMenu->Append(
354 highlightMenu->Append(
358 _T(
"Highlight Top Execution Counts")));
360 highlightMenu->Append(
364 _T(
"Highlight Move Executions")));
371 programMenu->AppendSeparator();
376 _T(
"&Step Instruction")));
381 _T(
"&Next Instruction")));
388 programMenu->AppendSeparator();
393 menuBar->Append(programMenu, _T(
"&Program"));
396 menuBar->Append(dataMenu, _T(
"&Data"));
402 _T(
"&User Manual...")));
409 menuBar->Append(helpMenu, _T(
"&Help"));
456 wxString accel = _T(
"\t");
458 accel.Append(_T(
"Ctrl-"));
461 }
else if (sc->
alt()) {
462 accel.Append(_T(
"Alt-"));
465 }
else if (sc->
fKey() > 0) {
466 accel.Append(_T(
"F"));
493 wxGetApp().commandRegistry().createCommand(event.GetId());
495 if (command == NULL) {
497 this, _T(
"No handler found for the command event"));
530 wxSplitterWindow* newSplitter =
new wxSplitterWindow(
this, wxHORIZONTAL);
531 newSplitter->SetMinimumPaneSize(25);
532 window->Reparent(newSplitter);
536 sizer_->Add(newSplitter, 1, wxGROW);
538 newSplitter->SetSashPosition(
topSplitter_->GetSize().GetHeight() / 2);
555 WXTYPE eventType =
event.GetEventType();
558 wxSetCursor(*wxHOURGLASS_CURSOR);
559 wxString status = _T(
"Executing command '");
561 status.Append(_T(
"'."));
562 GetStatusBar()->SetStatusText(status);
563 GetMenuBar()->Disable();
571 std::string command =
event.data();
573 GetToolBar()->Disable();
578 wxSetCursor(*wxSTANDARD_CURSOR);
579 GetStatusBar()->SetStatusText(_T(
""));
580 GetMenuBar()->Enable();
582 std::string command =
event.data();
586 GetToolBar()->Enable();
604 wxString message = _T(
"Loading program... ");
606 GetStatusBar()->SetStatusText(message);
611 wxString message = _T(
"Program loaded.");
612 GetStatusBar()->SetStatusText(message);
618 wxString message = _T(
"Loading machine... ");
620 GetStatusBar()->SetStatusText(message);
625 wxString message = _T(
"Machine loaded.");
626 GetStatusBar()->SetStatusText(message);
635 wxString message = _T(
"Running simulation... ");
637 GetStatusBar()->SetStatusText(message);
643 GetToolBar()->Show(
false);
644 GetToolBar()->Show(
true);
648 for (
unsigned i = 0; i <
subwindows.size(); i++) {
650 wxPostEvent(window, event);
654 wxMenuBar* menubar = GetMenuBar();
655 for (
unsigned i = 0; i < menubar->GetMenuCount(); i++) {
656 menubar->GetMenu(i)->UpdateUI();
680 std::string procName =
"ProximMainFrame::removeSubWindow";
693 int id =
event.GetId();
700 if (memoryWindow == NULL) {
704 memoryWindow, _T(
"Memory"),
false, wxSize(620, 400));
706 memoryWindow->GetParent()->Destroy();
715 wxWindow* controlWindow =
717 if (controlWindow == NULL) {
721 controlWindow, _T(
"Simulator control"),
false);
723 controlWindow->GetParent()->Destroy();
724 controlWindow = NULL;
732 wxWindow* machineWindow = FindWindowById(
734 if (machineWindow == NULL) {
738 machineWindow, _T(
"Simulated Machine"),
false, wxSize(600,400));
740 machineWindow->GetParent()->Destroy();
741 machineWindow = NULL;
749 wxWindow* breakpointWindow = FindWindowById(
751 if (breakpointWindow == NULL) {
755 breakpointWindow, _T(
"Breakpoints"),
false);
757 breakpointWindow->GetParent()->Close();
758 breakpointWindow = NULL;
766 wxWindow* historyWindow = FindWindowById(
768 if (historyWindow == NULL) {
773 historyWindow, _T(
"Command History"),
false);
775 historyWindow->GetParent()->Close();
776 historyWindow = NULL;
784 wxWindow* debuggerWindow = FindWindowById(
786 if (debuggerWindow == NULL) {
790 debuggerWindow, _T(
"Source code debugger"),
false);
792 debuggerWindow->GetParent()->Close();
793 debuggerWindow = NULL;
817 if (wxGetApp().simulation() == NULL) {
822 wxGetApp().commandRegistry().createCommand(event.GetId());
824 if (command != NULL) {
925 if (event.CanVeto()) {
927 GUICommand* quitCommand = wxGetApp().commandRegistry().createCommand(
931 if (!quitCommand->
Do()) {
950 if (simulation == NULL) {
951 status = _T(
"Not initialzed");
954 status = _T(
"Initialized");
957 status = _T(
"Running");
960 status = _T(
"Stopped");
963 status = _T(
"Finished");
966 wxStatusBar* statusBar = GetStatusBar();
967 statusBar->SetStatusText(status, 1);
971 cyclesStr.Prepend(_T(
"Cycles: "));
972 statusBar->SetStatusText(cyclesStr, 2);
981 if (!wxGetApp().simulation() ||
982 !wxGetApp().simulation()->frontend() ||
983 !wxGetApp().simulation()->frontend()->isSimulationInitialized() ||
984 wxGetApp().simulation()->frontend()->memorySystem().
985 memoryCount() == 0) {
988 if (memoryWindow != NULL) {
989 memoryWindow->Destroy();
1017 if (wxThread::IsMain()) {
1018 for (
int i =
subwindows.size() - 1; i >= 0; i--) {
1025 wxPostEvent(
this, event);