OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ProximMainFrame Class Reference

#include <ProximMainFrame.hh>

Inheritance diagram for ProximMainFrame:
Inheritance graph
Collaboration diagram for ProximMainFrame:
Collaboration graph

Public Member Functions

 ProximMainFrame (const wxString &title, const wxPoint &pos, const wxSize &size)
 
virtual ~ProximMainFrame ()
 
void addSubWindow (ProximSimulatorWindow *window)
 
void removeSubWindow (ProximSimulatorWindow *window)
 
void createToolbar ()
 
void createMenubar ()
 
void reset ()
 

Private Member Functions

void initialize ()
 
void dockWindow (wxWindow *window)
 
void onCommandEvent (wxCommandEvent &event)
 
void onToggleWindow (wxCommandEvent &event)
 
void onSimulatorTerminated (SimulatorEvent &event)
 
void onSimulatorEvent (SimulatorEvent &event)
 
void onKeyEvent (wxKeyEvent &event)
 
void onClose (wxCloseEvent &event)
 
void onStatusTimer (wxTimerEvent &event)
 
void onReset (const SimulatorEvent &event)
 
void updateCommand (wxUpdateUIEvent &event)
 
void updateToggleItem (wxUpdateUIEvent &event)
 
void updateSimulationStatus ()
 
void updateMemoryWindowMenuItem ()
 
wxString menuAccelerator (int id)
 

Private Attributes

wxBoxSizer * sizer_
 Toplevel sizer of the window managing the basic layout.
 
wxWindow * topSplitter_
 Top level splitter window of the splitted subwindow hierarchy.
 
std::vector< ProximSimulatorWindow * > subwindows
 List of subwindows where to send the simulator events.
 
wxToolBar * toolbar_
 Mainframe toolbar.
 
bool stopDialogInstantiated_
 True, if an instance of the stop dialog is currently visible.
 
wxMutex * resetMutex_
 Mutex for the resetCondition_.
 
wxCondition * resetCondition_
 Condition which is signalled when the subwindow reset is complete.
 
bool isReset_
 True if the subwindow reset is complete.
 

Detailed Description

Main window of the Proxim application.

ProximMainFrame is the top level window of the Proxim window hierarchy. This class is responsible for managing the simulation windows. All simulator backend events are passed to all subwindows. This class is also responsible for the menubar and executing command registry commands corresponding to the menu bar item ids. All subwindows are handled as wxPanels, and the simulator events are passed as custom wxEvents (see SimulatorEvent class).

Definition at line 58 of file ProximMainFrame.hh.

Constructor & Destructor Documentation

◆ ProximMainFrame()

ProximMainFrame::ProximMainFrame ( const wxString &  title,
const wxPoint &  pos,
const wxSize &  size 
)

◆ ~ProximMainFrame()

ProximMainFrame::~ProximMainFrame ( )
virtual

The destructor.

Definition at line 176 of file ProximMainFrame.cc.

176 {
177 delete resetCondition_;
178}
wxCondition * resetCondition_
Condition which is signalled when the subwindow reset is complete.

References resetCondition_.

Member Function Documentation

◆ addSubWindow()

void ProximMainFrame::addSubWindow ( ProximSimulatorWindow window)

Adds a window to the list of subwindows to send the simulator events to.

Parameters
windowWindow to be added.

Definition at line 666 of file ProximMainFrame.cc.

666 {
668 subwindows.push_back(window);
669 }
670}
static bool containsValue(const ContainerType &aContainer, const ElementType &aKey)
std::vector< ProximSimulatorWindow * > subwindows
List of subwindows where to send the simulator events.

References ContainerTools::containsValue(), and subwindows.

Here is the call graph for this function:

◆ createMenubar()

void ProximMainFrame::createMenubar ( )

Creates the proxim main frame menubar.

Definition at line 223 of file ProximMainFrame.cc.

223 {
224
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();
234
235 // File menu
236 fileMenu->Append(
239 _T("Open &Machine...")));
240
241 fileMenu->Append(
244 _T("Open &Program...")));
245
246 fileMenu->Append(
249 _T("&Change Directory...")));
250
251 fileMenu->AppendSeparator();
252
253 fileMenu->Append(
256 _T("&Quit")));
257
258 wxMenuBar* menuBar = new wxMenuBar;
259 menuBar->Append(fileMenu, _T("&File"));
260
261 // View menu
262 viewMenu->AppendCheckItem(
264 _T("&Simulator Console"));
265
266 viewMenu->AppendCheckItem(
268 _T("Program &Disassembly"));
269
270 viewMenu->AppendCheckItem(
272 _T("&Memory Window"));
273
274 viewMenu->AppendCheckItem(
276 _T("Simulator &Control"));
277
278 viewMenu->AppendCheckItem(
280 _T("&Machine Window"));
281
282 viewMenu->AppendCheckItem(
284 _T("&Breakpoint Window"));
285
286 viewMenu->AppendCheckItem(
288 _T("&Debugger Window"));
289
290 viewMenu->AppendSeparator();
291 viewMenu->Append(
294 _T("New &Register Window")));
295
296 viewMenu->Append(
299 _T("New &Port Window")));
300
301 viewMenu->Check(ProximConstants::COMMAND_TOGGLE_CONSOLE_WIN, true);
302 viewMenu->Check(ProximConstants::COMMAND_TOGGLE_DISASM_WIN, true);
303 viewMenu->Enable(ProximConstants::COMMAND_TOGGLE_CONSOLE_WIN, false);
304 viewMenu->Enable(ProximConstants::COMMAND_TOGGLE_DISASM_WIN, false);
305
306 menuBar->Append(viewMenu, _T("&View"));
307
308 editMenu->Append(
311 _T("Simulator Settings...")));
312
313 editMenu->Append(
316 _T("Options...")));
317
318 // Edit menu
319 menuBar->Append(editMenu, _T("&Edit"));
320
321 // Command menu
322 commandMenu->Append(
325 _T("&Clear Console")));
326
327 commandMenu->Append(
330 _T("&Execute File...")));
331
332 commandMenu->Append(
335 _T("&Find in disassembly...")));
336
337 commandMenu->AppendSeparator();
338 commandMenu->AppendCheckItem(
340 _T("Command &History Window"));
341
342 menuBar->Append(commandMenu, _T("&Command"));
343
344 // Source menu
345 menuBar->Append(sourceMenu, _T("&Source"));
346 sourceMenu->Append(17000, _T("&Profile Data"), highlightMenu);
347
348 highlightMenu->Append(
352 _T("None")));
353
354 highlightMenu->Append(
358 _T("Highlight Top Execution Counts")));
359
360 highlightMenu->Append(
364 _T("Highlight Move Executions")));
365
366 // Program menu
367 programMenu->Append(
369 menuAccelerator(ProximConstants::COMMAND_RUN).Prepend(_T("&Run")));
370
371 programMenu->AppendSeparator();
372
373 programMenu->Append(
376 _T("&Step Instruction")));
377
378 programMenu->Append(
381 _T("&Next Instruction")));
382
383 programMenu->Append(
386 _T("R&esume")));
387
388 programMenu->AppendSeparator();
389 programMenu->Append(
391 menuAccelerator(ProximConstants::COMMAND_KILL).Prepend(_T("&Kill")));
392
393 menuBar->Append(programMenu, _T("&Program"));
394
395 // Data menu
396 menuBar->Append(dataMenu, _T("&Data"));
397
398 // Help menu
399 helpMenu->Append(
402 _T("&User Manual...")));
403
404 helpMenu->Append(
407 _T("&About...")));
408
409 menuBar->Append(helpMenu, _T("&Help"));
410
411 SetMenuBar(menuBar);
412
414}
void updateMemoryWindowMenuItem()
wxString menuAccelerator(int id)
static const int COMMAND_ID
Command ID.

References ProximConstants::COMMAND_ABOUT, ProximConstants::COMMAND_CD, ProximConstants::COMMAND_CLEAR_CONSOLE, ProximConstants::COMMAND_CLEAR_DISASSEMBLY_HIGHLIGHT, ProximConstants::COMMAND_EDIT_OPTIONS, ProximConstants::COMMAND_EXECUTE_FILE, ProximConstants::COMMAND_FIND, ProximConstants::COMMAND_HIGHLIGHT_EXEC_PERCENTAGE, ProximConstants::COMMAND_HIGHLIGHT_TOP_EXEC_COUNTS, UserManualCmd::COMMAND_ID, ProximConstants::COMMAND_KILL, ProximConstants::COMMAND_NEW_PORT_WINDOW, ProximConstants::COMMAND_NEW_REGISTER_WINDOW, ProximConstants::COMMAND_NEXTI, ProximConstants::COMMAND_OPEN_MACHINE, ProximConstants::COMMAND_OPEN_PROGRAM, ProximConstants::COMMAND_QUIT, ProximConstants::COMMAND_RESUME, ProximConstants::COMMAND_RUN, ProximConstants::COMMAND_SIMULATOR_SETTINGS, ProximConstants::COMMAND_STEPI, ProximConstants::COMMAND_TOGGLE_BREAKPOINT_WIN, ProximConstants::COMMAND_TOGGLE_CMD_HISTORY_WIN, ProximConstants::COMMAND_TOGGLE_CONSOLE_WIN, ProximConstants::COMMAND_TOGGLE_CONTROL_WIN, ProximConstants::COMMAND_TOGGLE_DEBUGGER_WIN, ProximConstants::COMMAND_TOGGLE_DISASM_WIN, ProximConstants::COMMAND_TOGGLE_MACHINE_WIN, ProximConstants::COMMAND_TOGGLE_MEMORY_WIN, menuAccelerator(), and updateMemoryWindowMenuItem().

Referenced by ProximOptionsCmd::Do(), and initialize().

Here is the call graph for this function:

◆ createToolbar()

void ProximMainFrame::createToolbar ( )

Creates the main frame toolbar.

Definition at line 420 of file ProximMainFrame.cc.

420 {
421
422 if (toolbar_ != NULL) {
423 delete toolbar_;
424 toolbar_ = NULL;
425 }
426
427 CommandRegistry& registry = wxGetApp().commandRegistry();
428 GUIOptions& options = wxGetApp().options();
430
431 toolbar_ = options.createToolbar(this, registry, iconPath);
432
433 SetToolBar(toolbar_);
434 toolbar_->Show(options.toolbarVisibility());
435}
static MachInfoCmdLineOptions options
Definition MachInfo.cc:46
static std::string iconDirPath()
wxToolBar * toolbar_
Mainframe toolbar.
static wxString toWxString(const std::string &source)

References Environment::iconDirPath(), options, toolbar_, and WxConversion::toWxString().

Referenced by ProximOptionsCmd::Do(), and initialize().

Here is the call graph for this function:

◆ dockWindow()

void ProximMainFrame::dockWindow ( wxWindow *  window)
private

Docks a simulation subwindow to the mainframe.

Parameters
windowSub window to add.

Definition at line 514 of file ProximMainFrame.cc.

514 {
515
516 // If the frame is empty, the window is added directly to the sizer
517 // w/o a splitterwindow.
518 if (topSplitter_ == NULL) {
519 topSplitter_ = window;
520 sizer_->Add(window);
521 return;
522 }
523
524 // The frame already contained window(s). A new splitter window is created,
525 // and the old contents of the frame is set as the top half of the
526 // splitter window, and the new window as the bottom half of the
527 // splitter. Finally, the old contents of the frame is replaced with the
528 // new splitter window.
529 sizer_->Detach(topSplitter_);
530 wxSplitterWindow* newSplitter = new wxSplitterWindow(this, wxHORIZONTAL);
531 newSplitter->SetMinimumPaneSize(25);
532 window->Reparent(newSplitter);
533 topSplitter_->Reparent(newSplitter);
534 newSplitter->SplitHorizontally(topSplitter_, window);
535 topSplitter_ = newSplitter;
536 sizer_->Add(newSplitter, 1, wxGROW);
537 sizer_->Layout();
538 newSplitter->SetSashPosition(topSplitter_->GetSize().GetHeight() / 2);
539}
wxBoxSizer * sizer_
Toplevel sizer of the window managing the basic layout.
wxWindow * topSplitter_
Top level splitter window of the splitted subwindow hierarchy.

References sizer_, and topSplitter_.

Referenced by initialize().

◆ initialize()

void ProximMainFrame::initialize ( )
private

Initializes the frame instance.

Creates the sizer managing the window layout, and creates an instance of the default windows.

Definition at line 188 of file ProximMainFrame.cc.

188 {
189
191
192 wxStatusBar* statusbar = CreateStatusBar();
193 int widths[3] = {-1, 200, 200};
194 statusbar->SetFieldsCount(3, widths);
195
196 sizer_ = new wxBoxSizer(wxVERTICAL);
197
200
201 dockWindow(disasmWindow);
203 SetSizer(sizer_);
204
206
207 SetSizeHints(400, 300);
208}
void dockWindow(wxWindow *window)

References createMenubar(), createToolbar(), dockWindow(), ProximConstants::ID_CONSOLE_WINDOW, ProximConstants::ID_DISASSEMBLY_WINDOW, and sizer_.

Here is the call graph for this function:

◆ menuAccelerator()

wxString ProximMainFrame::menuAccelerator ( int  id)
private

Returns a menu accelerator string for a command.

The returned string can be appended to the menu item text to set the keyboard shortcut defined in the options for the command.

Parameters
idCommand ID.
Returns
Accelerator string.

Definition at line 448 of file ProximMainFrame.cc.

448 {
449
450 const CommandRegistry& reg = wxGetApp().commandRegistry();
451 const GUIOptions& options = wxGetApp().options();
452 std::string cmdName = reg.commandName(id);
453 const KeyboardShortcut* sc = options.keyboardShortcut(cmdName);
454
455 if (sc != NULL) {
456 wxString accel = _T("\t");
457 if (sc->ctrl()) {
458 accel.Append(_T("Ctrl-"));
459 accel.Append(WxConversion::toWxString(sc->key()));
460 return accel;
461 } else if (sc->alt()) {
462 accel.Append(_T("Alt-"));
463 accel.Append(WxConversion::toWxString(sc->key()));
464 return accel;
465 } else if (sc->fKey() > 0) {
466 accel.Append(_T("F"));
467 accel.Append(WxConversion::toWxString(sc->fKey()));
468 return accel;
469 } else {
470 // Invalid shortcut.
471 return _T("");
472 }
473 }
474
475 return _T("");
476}
std::string commandName(int id) const

References KeyboardShortcut::alt(), CommandRegistry::commandName(), KeyboardShortcut::ctrl(), KeyboardShortcut::fKey(), KeyboardShortcut::key(), options, and WxConversion::toWxString().

Referenced by createMenubar().

Here is the call graph for this function:

◆ onClose()

void ProximMainFrame::onClose ( wxCloseEvent &  event)
private

Handles system close events.

This event handler is called for example when the window is being closed using the frame close button X.

Parameters
eventClose event to handle;

Definition at line 924 of file ProximMainFrame.cc.

924 {
925 if (event.CanVeto()) {
926 // Execute quit-command.
927 GUICommand* quitCommand = wxGetApp().commandRegistry().createCommand(
929 if (quitCommand->isEnabled()) {
930 quitCommand->setParentWindow(this);
931 if (!quitCommand->Do()) {
932 event.Veto();
933 }
934 }
935 event.Veto();
936 delete quitCommand;
937 return;
938 }
939}
virtual bool Do()=0
void setParentWindow(wxWindow *view)
Definition GUICommand.cc:64
virtual bool isEnabled()=0
static const std::string COMMAND_NAME_QUIT
Name of the quit command.

References ProximConstants::COMMAND_NAME_QUIT, GUICommand::Do(), GUICommand::isEnabled(), and GUICommand::setParentWindow().

Here is the call graph for this function:

◆ onCommandEvent()

void ProximMainFrame::onCommandEvent ( wxCommandEvent &  event)
private

Handles command events from the menubar.

Commands are handled using Proxim command registry. A command is requested from the registry with the command event ID. If a command is found in the registry, the command will be executed. Otherwise an errordialog is displayed.

Parameters
eventCommand event to handle.

Definition at line 490 of file ProximMainFrame.cc.

490 {
491
492 GUICommand* command =
493 wxGetApp().commandRegistry().createCommand(event.GetId());
494
495 if (command == NULL) {
496 ErrorDialog dialog(
497 this, _T("No handler found for the command event"));
498 dialog.ShowModal();
499 return;
500 }
501
502 command->setParentWindow(this);
503 command->Do();
504 delete command;
505}

References GUICommand::Do(), and GUICommand::setParentWindow().

Here is the call graph for this function:

◆ onKeyEvent()

void ProximMainFrame::onKeyEvent ( wxKeyEvent &  event)
private

Handles key events.

Parameters
eventKey event to handle.

Definition at line 910 of file ProximMainFrame.cc.

910 {
911 event.Skip();
912}

◆ onReset()

void ProximMainFrame::onReset ( const SimulatorEvent event)
private

Event handler for the simulator reset event.

Definition at line 1002 of file ProximMainFrame.cc.

1002 {
1003 reset();
1004}

References reset().

Here is the call graph for this function:

◆ onSimulatorEvent()

void ProximMainFrame::onSimulatorEvent ( SimulatorEvent event)
private

Handles simulator events.

The events are passed to all subwindows registered as simulator listeners.

Parameters
eventSimulator event to handle.

Definition at line 551 of file ProximMainFrame.cc.

551 {
552
554
555 WXTYPE eventType = event.GetEventType();
556
557 if (eventType == SimulatorEvent::EVT_SIMULATOR_COMMAND) {
558 wxSetCursor(*wxHOURGLASS_CURSOR);
559 wxString status = _T("Executing command '");
560 status.Append(WxConversion::toWxString(event.data()));
561 status.Append(_T("'."));
562 GetStatusBar()->SetStatusText(status);
563 GetMenuBar()->Disable();
564
565 // If a toolbar button is disabled and re-enabled when a mouse cursor
566 // is over the button, the button can't be clicked until the cursor
567 // is moved away from the button and back over it. This prevents
568 // stepi button to work when clicked repeatedly. Stepi
569 // commands do not disable toolbar buttons when executed to avoid
570 // this problem.
571 std::string command = event.data();
573 GetToolBar()->Disable();
574 }
575 }
576
578 wxSetCursor(*wxSTANDARD_CURSOR);
579 GetStatusBar()->SetStatusText(_T(""));
580 GetMenuBar()->Enable();
581
582 std::string command = event.data();
583 // Kludge to make stepi button to work better. See comment
584 // in the previous if-clause.
586 GetToolBar()->Enable();
587 }
588 }
589
591 wxString message = WxConversion::toWxString(event.data());
592 ErrorDialog dialog(this, message);
593 dialog.ShowModal();
594 }
595
597 wxString message = WxConversion::toWxString(event.data());
598 WarningDialog dialog(this, message);
599 dialog.ShowModal();
600 }
601
602 // Loading program.
604 wxString message = _T("Loading program... ");
605 message.Append(WxConversion::toWxString(event.data()));
606 GetStatusBar()->SetStatusText(message);
607 }
608
609 // Program loaded
611 wxString message = _T("Program loaded.");
612 GetStatusBar()->SetStatusText(message);
614 }
615
616 // Loading machine.
618 wxString message = _T("Loading machine... ");
619 message.Append(WxConversion::toWxString(event.data()));
620 GetStatusBar()->SetStatusText(message);
621 }
622
623 // Machine loaded
625 wxString message = _T("Machine loaded.");
626 GetStatusBar()->SetStatusText(message);
627 }
628
629 // Program is being simulated.
630 if (eventType == SimulatorEvent::EVT_SIMULATOR_RUN) {
631 // If an instance of stop dialog is already visible, do not create
632 // a new one.
635 wxString message = _T("Running simulation... ");
636 message.Append(WxConversion::toWxString(event.data()));
637 GetStatusBar()->SetStatusText(message);
638 ProximStopDialog dialog(this, -1, *ProximToolbox::frontend());
639 dialog.ShowModal();
641
642 // Another workaround for a gtk-bug where button goes out of focus.
643 GetToolBar()->Show(false);
644 GetToolBar()->Show(true);
645 }
646 }
647
648 for (unsigned i = 0; i < subwindows.size(); i++) {
649 wxWindow * window = subwindows[i];
650 wxPostEvent(window, event);
651 }
652
653 // Update menus.
654 wxMenuBar* menubar = GetMenuBar();
655 for (unsigned i = 0; i < menubar->GetMenuCount(); i++) {
656 menubar->GetMenu(i)->UpdateUI();
657 }
658}
static const std::string SCL_STEP_INSTRUCTION
Command for stepping an instruction.
bool stopDialogInstantiated_
True, if an instance of the stop dialog is currently visible.
static TracedSimulatorFrontend * frontend()
static const wxEventType EVT_SIMULATOR_RUNTIME_WARNING
Runtime warning event.
static const wxEventType EVT_SIMULATOR_RUNTIME_ERROR
Runtime error event.
static const wxEventType EVT_SIMULATOR_MACHINE_LOADED
Machine loaded event.
static const wxEventType EVT_SIMULATOR_RUN
Simulation ran/resumed.
static const wxEventType EVT_SIMULATOR_PROGRAM_LOADED
Program loaded event.
static const wxEventType EVT_SIMULATOR_LOADING_MACHINE
Machine loading started.
static const wxEventType EVT_SIMULATOR_COMMAND_DONE
Command execution completed.
static const wxEventType EVT_SIMULATOR_COMMAND
Command received from the GUI.
std::string data() const
static const wxEventType EVT_SIMULATOR_LOADING_PROGRAM
Program loading started.

References SimulatorEvent::data(), SimulatorEvent::EVT_SIMULATOR_COMMAND, SimulatorEvent::EVT_SIMULATOR_COMMAND_DONE, SimulatorEvent::EVT_SIMULATOR_LOADING_MACHINE, SimulatorEvent::EVT_SIMULATOR_LOADING_PROGRAM, SimulatorEvent::EVT_SIMULATOR_MACHINE_LOADED, SimulatorEvent::EVT_SIMULATOR_PROGRAM_LOADED, SimulatorEvent::EVT_SIMULATOR_RUN, SimulatorEvent::EVT_SIMULATOR_RUNTIME_ERROR, SimulatorEvent::EVT_SIMULATOR_RUNTIME_WARNING, ProximToolbox::frontend(), ProximConstants::SCL_STEP_INSTRUCTION, stopDialogInstantiated_, subwindows, WxConversion::toWxString(), updateMemoryWindowMenuItem(), and updateSimulationStatus().

Here is the call graph for this function:

◆ onSimulatorTerminated()

void ProximMainFrame::onSimulatorTerminated ( SimulatorEvent event)
private

Closes the GUI when the simulator engine is terminated.

Definition at line 214 of file ProximMainFrame.cc.

214 {
215 Destroy();
216}

◆ onStatusTimer()

void ProximMainFrame::onStatusTimer ( wxTimerEvent &  event)
private

◆ onToggleWindow()

void ProximMainFrame::onToggleWindow ( wxCommandEvent &  event)
private

Event handler for View menu check items.

Parameters
eventView menu event to handle.

Definition at line 691 of file ProximMainFrame.cc.

691 {
692
693 int id = event.GetId();
694
695 switch (id) {
696
698 // Toggle memory window.
699 wxWindow* memoryWindow = FindWindowById(ProximConstants::ID_MEMORY_WINDOW);
700 if (memoryWindow == NULL) {
701 memoryWindow = new ProximMemoryWindow(
704 memoryWindow, _T("Memory"), false, wxSize(620, 400));
705 } else {
706 memoryWindow->GetParent()->Destroy();
707 memoryWindow = NULL;
708 }
709 return;
710
711 }
712
714 // Toggle control window.
715 wxWindow* controlWindow =
717 if (controlWindow == NULL) {
718 controlWindow = new ProximControlWindow(
721 controlWindow, _T("Simulator control"), false);
722 } else {
723 controlWindow->GetParent()->Destroy();
724 controlWindow = NULL;
725 }
726 return;
727
728 }
729
731 // Toggle machine window.
732 wxWindow* machineWindow = FindWindowById(
734 if (machineWindow == NULL) {
735 machineWindow = new ProximMachineStateWindow(
738 machineWindow, _T("Simulated Machine"), false, wxSize(600,400));
739 } else {
740 machineWindow->GetParent()->Destroy();
741 machineWindow = NULL;
742 }
743 return;
744
745 }
746
748 // Toggle breakpoitn window.
749 wxWindow* breakpointWindow = FindWindowById(
751 if (breakpointWindow == NULL) {
752 breakpointWindow = new ProximBreakpointWindow(
755 breakpointWindow, _T("Breakpoints"), false);
756 } else {
757 breakpointWindow->GetParent()->Close();
758 breakpointWindow = NULL;
759 }
760 return;
761
762 }
763
765 // Toggle command history window.
766 wxWindow* historyWindow = FindWindowById(
768 if (historyWindow == NULL) {
769 historyWindow = new ProximCmdHistoryWindow(
773 historyWindow, _T("Command History"), false);
774 } else {
775 historyWindow->GetParent()->Close();
776 historyWindow = NULL;
777 }
778 return;
779
780 }
781
783 // Toggle command history window.
784 wxWindow* debuggerWindow = FindWindowById(
786 if (debuggerWindow == NULL) {
787 debuggerWindow = new ProximDebuggerWindow(
790 debuggerWindow, _T("Source code debugger"), false);
791 } else {
792 debuggerWindow->GetParent()->Close();
793 debuggerWindow = NULL;
794 }
795 return;
796
797 }
798 }
799 event.Skip();
800}
static void addFramedWindow(wxWindow *window, const wxString &title, bool stayOnTop=false, const wxSize &minSize=wxSize(100, 100))
static ProximLineReader & lineReader()

References ProximToolbox::addFramedWindow(), ProximConstants::COMMAND_TOGGLE_BREAKPOINT_WIN, ProximConstants::COMMAND_TOGGLE_CMD_HISTORY_WIN, ProximConstants::COMMAND_TOGGLE_CONTROL_WIN, ProximConstants::COMMAND_TOGGLE_DEBUGGER_WIN, ProximConstants::COMMAND_TOGGLE_MACHINE_WIN, ProximConstants::COMMAND_TOGGLE_MEMORY_WIN, ProximConstants::ID_BREAKPOINT_WINDOW, ProximConstants::ID_CMD_HISTORY_WINDOW, ProximConstants::ID_CONTROL_WINDOW, ProximConstants::ID_DEBUGGER_WINDOW, ProximConstants::ID_MACHINE_STATE_WINDOW, ProximConstants::ID_MEMORY_WINDOW, and ProximToolbox::lineReader().

Here is the call graph for this function:

◆ removeSubWindow()

void ProximMainFrame::removeSubWindow ( ProximSimulatorWindow window)

Removes window from the list of subwindows to send the simulator events to.

Parameters
windowWindow to be removed.

Definition at line 678 of file ProximMainFrame.cc.

678 {
680 std::string procName = "ProximMainFrame::removeSubWindow";
681 throw InstanceNotFound(__FILE__, __LINE__, procName);
682 }
683}
static bool removeValueIfExists(ContainerType &aContainer, const ElementType &aKey)

References ContainerTools::removeValueIfExists(), and subwindows.

Referenced by ProximSimulatorWindow::~ProximSimulatorWindow().

Here is the call graph for this function:

◆ reset()

void ProximMainFrame::reset ( )

Resets all subwidnows, which acess simulator data directly.

If this fucntion is from another thread than the GUI thread, a reset event is passed to the GUI thread, which will reset the windows in the GUI thread. The caller thread is blocked and wont return from this function until the reset is complete.

Definition at line 1016 of file ProximMainFrame.cc.

1016 {
1017 if (wxThread::IsMain()) {
1018 for (int i = subwindows.size() - 1; i >= 0; i--) {
1019 subwindows[i]->reset();
1020 }
1021 isReset_ = true;
1022 resetCondition_->Signal();
1023 } else {
1025 wxPostEvent(this, event);
1026 while (!isReset_) {
1027 resetCondition_->WaitTimeout(100);
1028 }
1029 isReset_ = false;
1030 }
1031}
bool isReset_
True if the subwindow reset is complete.
static const wxEventType EVT_SIMULATOR_RESET
Sent before program,machine or memory model is destroyed.

References SimulatorEvent::EVT_SIMULATOR_RESET, isReset_, resetCondition_, and subwindows.

Referenced by ProximSimulationThread::handleEvent(), and onReset().

◆ updateCommand()

void ProximMainFrame::updateCommand ( wxUpdateUIEvent &  event)
private

Event handler for wxUpdateUIEvents.

Proxim updates buttons and menu items for command registry commands using wxUpdateUIEvents. When a wxUpdateUIEvent is received, command registry is searched for corresponding command ID. If a command is found, the UI element enabled or disabled according to the command's isEnabled() return value.

Parameters
eventUpadate event to handle.

Definition at line 815 of file ProximMainFrame.cc.

815 {
816
817 if (wxGetApp().simulation() == NULL) {
818 return;
819 }
820
821 GUICommand* command =
822 wxGetApp().commandRegistry().createCommand(event.GetId());
823
824 if (command != NULL) {
825 event.Enable(command->isEnabled());
826 delete command;
827 } else {
828 event.Enable(false);
829 }
830}

References GUICommand::isEnabled().

Here is the call graph for this function:

◆ updateMemoryWindowMenuItem()

void ProximMainFrame::updateMemoryWindowMenuItem ( )
private

Updates "Memory Window" menu item depending on if memory is available

Definition at line 980 of file ProximMainFrame.cc.

980 {
981 if (!wxGetApp().simulation() ||
982 !wxGetApp().simulation()->frontend() ||
983 !wxGetApp().simulation()->frontend()->isSimulationInitialized() ||
984 wxGetApp().simulation()->frontend()->memorySystem().
985 memoryCount() == 0) {
986 GetMenuBar()->Enable(ProximConstants::COMMAND_TOGGLE_MEMORY_WIN, false);
987 wxWindow* memoryWindow = FindWindowById(ProximConstants::ID_MEMORY_WINDOW);
988 if (memoryWindow != NULL) {
989 memoryWindow->Destroy();
990 memoryWindow = NULL;
991 }
992 } else {
993 GetMenuBar()->Enable(ProximConstants::COMMAND_TOGGLE_MEMORY_WIN, true);
994 }
995}

References ProximConstants::COMMAND_TOGGLE_MEMORY_WIN, and ProximConstants::ID_MEMORY_WINDOW.

Referenced by createMenubar(), and onSimulatorEvent().

◆ updateSimulationStatus()

void ProximMainFrame::updateSimulationStatus ( )
private

Updates simulation status and cycle count in the statusbar.

Definition at line 946 of file ProximMainFrame.cc.

946 {
947 const SimulatorFrontend* simulation = ProximToolbox::frontend();
948 wxString status;
949 ClockCycleCount cycles = 0;
950 if (simulation == NULL) {
951 status = _T("Not initialzed");
952 } else if (simulation->isSimulationInitialized()) {
953 cycles = simulation->cycleCount();
954 status = _T("Initialized");
955 } else if (simulation->isSimulationRunning()) {
956 cycles = simulation->cycleCount();
957 status = _T("Running");
958 } else if (simulation->isSimulationStopped()) {
959 cycles = simulation->cycleCount();
960 status = _T("Stopped");
961 } else if (simulation->hasSimulationEnded()) {
962 cycles = simulation->cycleCount();
963 status = _T("Finished");
964 }
965
966 wxStatusBar* statusBar = GetStatusBar();
967 statusBar->SetStatusText(status, 1);
968
969 wxString cyclesStr = WxConversion::toWxString((boost::format("%.0f") %
970 cycles).str());
971 cyclesStr.Prepend(_T("Cycles: "));
972 statusBar->SetStatusText(cyclesStr, 2);
973}
CycleCount ClockCycleCount
Alias for ClockCycleCount.
bool hasSimulationEnded() const
ClockCycleCount cycleCount() const
bool isSimulationInitialized() const
bool isSimulationStopped() const
bool isSimulationRunning() const

References SimulatorFrontend::cycleCount(), ProximToolbox::frontend(), SimulatorFrontend::hasSimulationEnded(), SimulatorFrontend::isSimulationInitialized(), SimulatorFrontend::isSimulationRunning(), SimulatorFrontend::isSimulationStopped(), and WxConversion::toWxString().

Referenced by onSimulatorEvent().

Here is the call graph for this function:

◆ updateToggleItem()

void ProximMainFrame::updateToggleItem ( wxUpdateUIEvent &  event)
private

Event handler which updates view-menu check item check-marks.

When a wxUpdateUIEvent is received for view-menu check item, the main frame checks if corresponding subwindow exists and updates the menu item.

Definition at line 841 of file ProximMainFrame.cc.

841 {
842
843 // memory window check-item
844 if (event.GetId() == ProximConstants::COMMAND_TOGGLE_MEMORY_WIN) {
845 bool exists = FindWindowById(ProximConstants::ID_MEMORY_WINDOW);
846 if (exists) {
847 event.Check(true);
848 } else {
849 event.Check(false);
850 }
851 }
852
853 // simulator control window check-item
854 if (event.GetId() == ProximConstants::COMMAND_TOGGLE_CONTROL_WIN) {
855 bool exists = FindWindowById(ProximConstants::ID_CONTROL_WINDOW);
856 if (exists) {
857 event.Check(true);
858 } else {
859 event.Check(false);
860 }
861 }
862
863 // machine window check-item
864 if (event.GetId() == ProximConstants::COMMAND_TOGGLE_MACHINE_WIN) {
865 bool exists = FindWindowById(ProximConstants::ID_MACHINE_STATE_WINDOW);
866 if (exists) {
867 event.Check(true);
868 } else {
869 event.Check(false);
870 }
871 }
872
873 // breakpoint window check-item
875 bool exists = FindWindowById(ProximConstants::ID_BREAKPOINT_WINDOW);
876 if (exists) {
877 event.Check(true);
878 } else {
879 event.Check(false);
880 }
881 }
882
883 // command history window check-item
885 bool exists = FindWindowById(ProximConstants::ID_CMD_HISTORY_WINDOW);
886 if (exists) {
887 event.Check(true);
888 } else {
889 event.Check(false);
890 }
891 }
892
893 // debugger window check-item
895 bool exists = FindWindowById(ProximConstants::ID_DEBUGGER_WINDOW);
896 if (exists) {
897 event.Check(true);
898 } else {
899 event.Check(false);
900 }
901 }
902}

References ProximConstants::COMMAND_TOGGLE_BREAKPOINT_WIN, ProximConstants::COMMAND_TOGGLE_CMD_HISTORY_WIN, ProximConstants::COMMAND_TOGGLE_CONTROL_WIN, ProximConstants::COMMAND_TOGGLE_DEBUGGER_WIN, ProximConstants::COMMAND_TOGGLE_MACHINE_WIN, ProximConstants::COMMAND_TOGGLE_MEMORY_WIN, ProximConstants::ID_BREAKPOINT_WINDOW, ProximConstants::ID_CMD_HISTORY_WINDOW, ProximConstants::ID_CONTROL_WINDOW, ProximConstants::ID_DEBUGGER_WINDOW, ProximConstants::ID_MACHINE_STATE_WINDOW, and ProximConstants::ID_MEMORY_WINDOW.

Member Data Documentation

◆ isReset_

bool ProximMainFrame::isReset_
private

True if the subwindow reset is complete.

Definition at line 106 of file ProximMainFrame.hh.

Referenced by reset().

◆ resetCondition_

wxCondition* ProximMainFrame::resetCondition_
private

Condition which is signalled when the subwindow reset is complete.

Definition at line 103 of file ProximMainFrame.hh.

Referenced by reset(), and ~ProximMainFrame().

◆ resetMutex_

wxMutex* ProximMainFrame::resetMutex_
private

Mutex for the resetCondition_.

Definition at line 101 of file ProximMainFrame.hh.

◆ sizer_

wxBoxSizer* ProximMainFrame::sizer_
private

Toplevel sizer of the window managing the basic layout.

Definition at line 89 of file ProximMainFrame.hh.

Referenced by dockWindow(), and initialize().

◆ stopDialogInstantiated_

bool ProximMainFrame::stopDialogInstantiated_
private

True, if an instance of the stop dialog is currently visible.

Definition at line 98 of file ProximMainFrame.hh.

Referenced by onSimulatorEvent().

◆ subwindows

std::vector<ProximSimulatorWindow*> ProximMainFrame::subwindows
private

List of subwindows where to send the simulator events.

Definition at line 93 of file ProximMainFrame.hh.

Referenced by addSubWindow(), onSimulatorEvent(), removeSubWindow(), and reset().

◆ toolbar_

wxToolBar* ProximMainFrame::toolbar_
private

Mainframe toolbar.

Definition at line 96 of file ProximMainFrame.hh.

Referenced by createToolbar().

◆ topSplitter_

wxWindow* ProximMainFrame::topSplitter_
private

Top level splitter window of the splitted subwindow hierarchy.

Definition at line 91 of file ProximMainFrame.hh.

Referenced by dockWindow().


The documentation for this class was generated from the following files: