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

#include <MainFrame.hh>

Inheritance diagram for MainFrame:
Inheritance graph
Collaboration diagram for MainFrame:
Collaboration graph

Public Member Functions

 MainFrame (wxDocManager *manager, wxFrame *parent, const wxString &title, const wxPoint &position, const wxSize &size, long style)
 
void onKeyEvent (wxKeyEvent &event)
 
void createToolbar ()
 
void createMenubar ()
 
void onToggleToolbar ()
 
void onToggleStatusbar ()
 
void updateUI ()
 
void OnExit (wxCommandEvent &WXUNUSED(event))
 

Private Types

enum  {
  ID_ADD_SUBMENU = 12000 , ID_ADD_FROM_HDB_SUBMENU , ID_ZOOM_SUBMENU , ID_VIEW_TOOLBAR ,
  ID_VIEW_STATUSBAR
}
 GUI element IDs. More...
 

Private Member Functions

wxMenu * createOptionsMenu ()
 
wxMenu * createHelpMenu ()
 
void onCommandEvent (wxCommandEvent &event)
 
void onUpdateUI (wxUpdateUIEvent &event)
 
wxString menuAccelerator (int id)
 

Private Attributes

CommandRegistrycommandRegistry_
 Command registry.
 
wxToolBar * toolbar_
 Toolbar.
 

Detailed Description

Main window of the editor.

Contains a default menubar, toolbar, statusbar and the child frames for all open documents. Derived from the wxDocMDIParentFrame class, which handles the child frames automatically. Handles the Options and the Help menu events and the events for toggling visibility of the menubar and the toolbar.

Definition at line 50 of file MainFrame.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

GUI element IDs.

Enumerator
ID_ADD_SUBMENU 
ID_ADD_FROM_HDB_SUBMENU 
ID_ZOOM_SUBMENU 
ID_VIEW_TOOLBAR 
ID_VIEW_STATUSBAR 

Definition at line 78 of file MainFrame.hh.

Constructor & Destructor Documentation

◆ MainFrame()

MainFrame::MainFrame ( wxDocManager *  manager,
wxFrame *  parent,
const wxString &  title,
const wxPoint &  position,
const wxSize &  size,
long  style 
)

The Constructor.

Parameters
managerPointer to the editor's document manager.
parentParent frame of the MainFrame.
titleTitle of the MainFrame.
positionPosition of the MainFrame on the screen.
sizeSize of the MainFrame on the screen.
styleStyle of the MainFrame.

Definition at line 118 of file MainFrame.cc.

124 :
125 wxDocMDIParentFrame(manager, parent, -1, title,
126 position, size, style, _T("MainFrame")) {
127
128 commandRegistry_ = wxGetApp().commandRegistry();
129 assert(commandRegistry_ != NULL);
181
182 toolbar_ = NULL;
183 CreateStatusBar(2);
184 int widths[2] = {-2, -1};
185 SetStatusWidths(2, widths);
186
189}
#define assert(condition)
void addCommand(GUICommand *command)
CommandRegistry * commandRegistry_
Command registry.
Definition MainFrame.hh:72
wxToolBar * toolbar_
Toolbar.
Definition MainFrame.hh:75
void createMenubar()
Definition MainFrame.cc:414
void createToolbar()
Definition MainFrame.cc:746

References assert.

Member Function Documentation

◆ createHelpMenu()

wxMenu * MainFrame::createHelpMenu ( )
private

Creates and returns a new help menu.

Returns
Help menu.

Definition at line 260 of file MainFrame.cc.

260 {
261 wxMenu* helpMenu = new wxMenu;
262 helpMenu->Append(
265 _T("&User Manual...")));
266
267 helpMenu->Append(
270 _T("&About...")));
271
272 return helpMenu;
273}
wxString menuAccelerator(int id)
Definition MainFrame.cc:713
static const int COMMAND_ID
Command ID.

References ProDeConstants::COMMAND_ABOUT, UserManualCmd::COMMAND_ID, and menuAccelerator().

Referenced by createMenubar().

Here is the call graph for this function:

◆ createMenubar()

void MainFrame::createMenubar ( )

Creates the default menubar.

Definition at line 414 of file MainFrame.cc.

414 {
415 // File menu
416 wxMenu* fileMenu = new wxMenu;
417
418 fileMenu->Append(
421
422 fileMenu->Append(
425 ProDeConstants::COMMAND_OPEN_DOC).Prepend(_T("Open...")));
426
427 fileMenu->Append(
430 ProDeConstants::COMMAND_SAVE_DOC).Prepend(_T("&Save")));
431
432 fileMenu->Append(
435 ProDeConstants::COMMAND_SAVEAS_DOC).Prepend(_T("Save &As...")));
436
437 fileMenu->Append(
440 ProDeConstants::COMMAND_CLOSE_DOC).Prepend(_T("&Close")));
441
442 fileMenu->AppendSeparator();
443
444 fileMenu->Append(
447 ProDeConstants::COMMAND_PRINT).Prepend(_T("&Print...")));
448
449 fileMenu->Append(
452 _T("Print Pre&view...")));
453
454 fileMenu->Append(
457 _T("Export...")));
458
459 fileMenu->AppendSeparator();
460
461 fileMenu->Append(
463 menuAccelerator(ProDeConstants::COMMAND_QUIT).Prepend(_T("&Quit")));
464
465 // Edit menu
466 wxMenu* editMenu = new wxMenu;
467 wxMenu* addSubMenu = new wxMenu;
468 wxMenu* addFromHDBSubMenu = new wxMenu;
469
470 editMenu->Append(
473 _T("&Undo")));
474
475 editMenu->Append(
478 _T("&Redo")));
479
480 editMenu->AppendSeparator();
481 editMenu->Append(
484 _T("Cu&t")));
485
486 editMenu->Append(
489 _T("&Copy")));
490
491 editMenu->Append(
494 _T("&Paste")));
495
496 editMenu->AppendSeparator();
497
498 addSubMenu->Append(
501 _T("&Function Unit...")));
502
503 addSubMenu->Append(
506 _T("&Register File...")));
507
508 addSubMenu->Append(
511 _T("&Transport Bus...")));
512
513 addSubMenu->Append(
516 _T("&Socket...")));
517
518 addSubMenu->Append(
521 _T("&Bridge...")));
522
523 addSubMenu->Append(
526 _T("&Immediate Unit...")));
527
528 addSubMenu->Append(
531 _T("&Global Control Unit...")));
532
533 addSubMenu->Append(
536 _T("&Address Space...")));
537
538 editMenu->Append(ID_ADD_SUBMENU, _T("&Add"), addSubMenu);
539
540 addFromHDBSubMenu->Append(
543 _T("&Function Unit...")));
544
545 addFromHDBSubMenu->Append(
548 _T("&Immediate Unit...")));
549
550 addFromHDBSubMenu->Append(
553 _T("&Register File...")));
554
555 editMenu->Append(
557 _T("Add From &HDB"), addFromHDBSubMenu);
558
559 editMenu->Append(
562 _T("&Delete")));
563
564 editMenu->Append(
567 _T("&Modify...")));
568
569 editMenu->AppendSeparator();
570 editMenu->Append(
573 _T("Address &Spaces...")));
574
575 editMenu->Append(
578 _T("Instruction &Templates...")));
579
580 editMenu->Append(
583 .Prepend(_T("OTA Formats...")));
584
585 editMenu->Append(
588 _T("&Immediate Slots...")));
589
590 editMenu->Append(
593 _T("Transport Bus &Order...")));
594
595 editMenu->Append(
598 _T("Architecture Features...")));
599
600 // View menu
601 wxMenu* viewMenu = new wxMenu;
602 wxMenu* zoomSubMenu = new wxMenu;
603 zoomSubMenu->Append(
606 _T("Zoom &In")));
607
608 zoomSubMenu->Append(
611 _T("Zoom &Out")));
612
613 zoomSubMenu->AppendSeparator();
614 zoomSubMenu->Append(
617 _T("&Fit Window")));
618
619 zoomSubMenu->Append(
622 _T("Fit &Height")));
623
624 zoomSubMenu->Append(
627 _T("Fit &Width")));
628
629 viewMenu->Append(ID_ZOOM_SUBMENU, _T("&Zoom"), zoomSubMenu);
630 viewMenu->AppendSeparator();
631 viewMenu->AppendCheckItem(
634 _T("Unit &Details")));
635
636 viewMenu->AppendSeparator();
637 viewMenu->AppendCheckItem(ID_VIEW_TOOLBAR, _T("&Toolbar"));
638 viewMenu->AppendCheckItem(ID_VIEW_STATUSBAR, _T("&Statusbar"));
639 viewMenu->Check(ID_VIEW_STATUSBAR, true);
640 viewMenu->Check(ID_VIEW_TOOLBAR, true);
641
642 // Tool menu
643 wxMenu* toolMenu = new wxMenu;
644 toolMenu->Append(
647 _T("&Select")));
648
649 toolMenu->Append(
652 _T("&Edit Connections")));
653
654 toolMenu->AppendSeparator();
655 toolMenu->Append(
658 _T("&Fully Connect IC")));
659
660 toolMenu->Append(
663 _T("&VLIW Connect IC")));
664
665 toolMenu->Append(
668 .Prepend(_T("&Blocks Connect IC")));
669
670 toolMenu->Append(
673 _T("&Verify...")));
674
675 toolMenu->Append(
678 _T("&Processor Implementation...")));
679
680 toolMenu->Append(
683 _T("&Call Explorer Plugin...")));
684
685 // Options menu
686 wxMenu* optionsMenu = createOptionsMenu();
687
688 // Help menu
689 wxMenu* helpMenu = createHelpMenu();
690
691 // add menus to the menubar
692 wxMenuBar* menuBar = new wxMenuBar;
693 menuBar->Append(fileMenu, _T("&File"));
694 menuBar->Append(editMenu, _T("&Edit"));
695 menuBar->Append(viewMenu, _T("&View"));
696 menuBar->Append(toolMenu, _T("&Tools"));
697 menuBar->Append(optionsMenu, _T("&Options"));
698 menuBar->Append(helpMenu, _T("&Help"));
699
700 SetMenuBar(menuBar);
701}
wxMenu * createOptionsMenu()
Definition MainFrame.cc:237
wxMenu * createHelpMenu()
Definition MainFrame.cc:260

References ProDeConstants::COMMAND_ADD_AS, ProDeConstants::COMMAND_ADD_BRIDGE, ProDeConstants::COMMAND_ADD_BUS, ProDeConstants::COMMAND_ADD_FU, ProDeConstants::COMMAND_ADD_FU_FROM_HDB, ProDeConstants::COMMAND_ADD_GCU, ProDeConstants::COMMAND_ADD_IU, ProDeConstants::COMMAND_ADD_IU_FROM_HDB, ProDeConstants::COMMAND_ADD_RF, ProDeConstants::COMMAND_ADD_RF_FROM_HDB, ProDeConstants::COMMAND_ADD_SOCKET, ProDeConstants::COMMAND_BLOCKS_CONNECT_IC, ProDeConstants::COMMAND_CALL_EXPLORER_PLUGIN, ProDeConstants::COMMAND_CLOSE_DOC, ProDeConstants::COMMAND_COPY, ProDeConstants::COMMAND_CUT, ProDeConstants::COMMAND_DELETE_COMP, ProDeConstants::COMMAND_EDIT_ADDRESS_SPACES, ProDeConstants::COMMAND_EDIT_BUS_ORDER, ProDeConstants::COMMAND_EDIT_CONNECTIONS, ProDeConstants::COMMAND_EDIT_IMMEDIATE_SLOTS, ProDeConstants::COMMAND_EDIT_MACHINE, ProDeConstants::COMMAND_EDIT_OTA_FORMATS, ProDeConstants::COMMAND_EDIT_TEMPLATES, ProDeConstants::COMMAND_EXPORT, ProDeConstants::COMMAND_FULLY_CONNECT_BUSSES, ProDeConstants::COMMAND_IMPLEMENTATION, ProDeConstants::COMMAND_MODIFY_COMP, ProDeConstants::COMMAND_NEW_DOC, ProDeConstants::COMMAND_OPEN_DOC, ProDeConstants::COMMAND_PASTE, ProDeConstants::COMMAND_PRINT, ProDeConstants::COMMAND_PRINT_PREVIEW, ProDeConstants::COMMAND_QUIT, ProDeConstants::COMMAND_REDO, ProDeConstants::COMMAND_SAVE_DOC, ProDeConstants::COMMAND_SAVEAS_DOC, ProDeConstants::COMMAND_SELECT, ProDeConstants::COMMAND_TOGGLE_UNIT_DETAILS, ProDeConstants::COMMAND_UNDO, ProDeConstants::COMMAND_VERIFY_MACHINE, ProDeConstants::COMMAND_VLIW_CONNECT_IC, ProDeConstants::COMMAND_ZOOM_FIT_HEI, ProDeConstants::COMMAND_ZOOM_FIT_WID, ProDeConstants::COMMAND_ZOOM_FIT_WIN, ProDeConstants::COMMAND_ZOOM_IN, ProDeConstants::COMMAND_ZOOM_OUT, createHelpMenu(), createOptionsMenu(), ID_ADD_FROM_HDB_SUBMENU, ID_ADD_SUBMENU, ID_VIEW_STATUSBAR, ID_VIEW_TOOLBAR, ID_ZOOM_SUBMENU, and menuAccelerator().

Here is the call graph for this function:

◆ createOptionsMenu()

wxMenu * MainFrame::createOptionsMenu ( )
private

Creates and returns a new options menu.

Returns
Options menu.

Definition at line 237 of file MainFrame.cc.

237 {
238 wxMenu* optionsMenu = new wxMenu;
239 optionsMenu->Append(
242 _T("&Edit...")));
243
244 optionsMenu->AppendSeparator();
245 optionsMenu->Append(
248 _T("&Save")));
249
250 return optionsMenu;
251}

References ProDeConstants::COMMAND_EDIT_OPTIONS, ProDeConstants::COMMAND_SAVE_OPTIONS, and menuAccelerator().

Referenced by createMenubar().

Here is the call graph for this function:

◆ createToolbar()

void MainFrame::createToolbar ( )

Creates the toolbar.

Definition at line 746 of file MainFrame.cc.

746 {
747
748 // delete old toolbar
749 if (toolbar_ != NULL) {
750 delete toolbar_;
751 toolbar_ = NULL;
752 }
753
754 CommandRegistry* registry = wxGetApp().commandRegistry();
755 ProDeOptions* options = wxGetApp().options();
757
758 toolbar_ = options->createToolbar(this, *registry, iconPath);
759
760 // set new toolbar as the MainFrame toolbar
761 SetToolBar(toolbar_);
762 toolbar_->Show(true);
763}
static MachInfoCmdLineOptions options
Definition MachInfo.cc:46
static std::string iconDirPath()
static wxString toWxString(const std::string &source)

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

Referenced by onToggleToolbar(), and ProDe::setOptions().

Here is the call graph for this function:

◆ menuAccelerator()

wxString MainFrame::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 713 of file MainFrame.cc.

713 {
714
715 const CommandRegistry* reg = wxGetApp().commandRegistry();
716 const GUIOptions* options = wxGetApp().options();
717 std::string cmdName = reg->commandName(id);
718 const KeyboardShortcut* sc = options->keyboardShortcut(cmdName);
719
720 if (sc != NULL) {
721 wxString accel = _T("\t");
722 if (sc->ctrl()) {
723 accel.Append(_T("Ctrl-"));
724 accel.Append(WxConversion::toWxString(sc->key()));
725 return accel;
726 } else if (sc->alt()) {
727 accel.Append(_T("Alt-"));
728 accel.Append(WxConversion::toWxString(sc->key()));
729 return accel;
730 } else if (sc->fKey() > 0) {
731 accel.Append(_T("F"));
732 accel.Append(WxConversion::toWxString(sc->fKey()));
733 return accel;
734 } else {
735 // Invalid shortcut.
736 return _T("");
737 }
738 }
739 return _T("");
740}
std::string commandName(int id) const

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

Referenced by createHelpMenu(), createMenubar(), and createOptionsMenu().

Here is the call graph for this function:

◆ onCommandEvent()

void MainFrame::onCommandEvent ( wxCommandEvent &  event)
private

Handles menu and toolbar events.

Parameters
eventEvent to handle.

Definition at line 283 of file MainFrame.cc.

283 {
284
285 if (event.GetId() == ID_VIEW_TOOLBAR) {
287 return;
288 }
289
290 if (event.GetId() == ID_VIEW_STATUSBAR) {
292 return;
293 }
294
295 GUICommand* command = wxGetApp().commandRegistry()
296 ->createCommand(event.GetId());
297
298 if (command == NULL) {
299 ErrorDialog dialog(this,
300 _T("No handler found for the command event!"));
301 dialog.ShowModal();
302 return;
303 }
304
305 if (!command->isEnabled()) {
306 delete command;
307 return;
308 }
309
310 wxView* view = wxGetApp().docManager()->GetCurrentView();
311 if (view != NULL) {
312 command->setParentWindow(this);
313 EditorCommand* editorCmd = dynamic_cast<EditorCommand*>(command);
314 if (editorCmd != NULL) {
315 editorCmd->setView(view);
316 }
317 command->Do();
318 updateUI();
319 delete command;
320 return;
321 }
322
323 // set command parent window and view
324 command->setParentWindow(this);
325 // execute the command
326 command->Do();
327 updateUI();
328 delete command;
329}
void setView(wxView *view)
virtual bool Do()=0
void setParentWindow(wxWindow *view)
Definition GUICommand.cc:64
virtual bool isEnabled()=0
void onToggleStatusbar()
Definition MainFrame.cc:215
void updateUI()
Definition MainFrame.cc:373
void onToggleToolbar()
Definition MainFrame.cc:196

References GUICommand::Do(), ID_VIEW_STATUSBAR, ID_VIEW_TOOLBAR, GUICommand::isEnabled(), onToggleStatusbar(), onToggleToolbar(), GUICommand::setParentWindow(), EditorCommand::setView(), and updateUI().

Here is the call graph for this function:

◆ OnExit()

void MainFrame::OnExit ( wxCommandEvent &  WXUNUSEDevent)

Performs routines before exiting a program

Parameters
eventCommand event to handle.

Definition at line 771 of file MainFrame.cc.

771 {
772 Close();
773}

Referenced by QuitCmd::Do().

◆ onKeyEvent()

void MainFrame::onKeyEvent ( wxKeyEvent &  event)

Handles key events on the canvas.

Parameters
eventKey event to handle.

Definition at line 406 of file MainFrame.cc.

406 {
407}

◆ onToggleStatusbar()

void MainFrame::onToggleStatusbar ( )

Toggles visibility of the statusbar.

Definition at line 215 of file MainFrame.cc.

215 {
216 wxStatusBar* statusbar = GetStatusBar();
217 if (statusbar != NULL) {
218 SetStatusBar(NULL);
219 delete statusbar;
220 statusbar = NULL;
221 } else {
222 CreateStatusBar(2);
223 int widths[2] = {-4, -1};
224 SetStatusWidths(2, widths);
225 }
226 Layout();
227 Fit();
228}

Referenced by onCommandEvent().

◆ onToggleToolbar()

void MainFrame::onToggleToolbar ( )

Toggles visibility of the toolbar.

Definition at line 196 of file MainFrame.cc.

196 {
197 ProDeOptions* options = wxGetApp().options();
198 if (toolbar_ != NULL) {
199 options->setToolbarVisibility(false);
200 SetToolBar(NULL);
201 delete toolbar_;
202 toolbar_ = NULL;
203 } else {
204 options->setToolbarVisibility(true);
206 }
207 Layout();
208}

References createToolbar(), options, and toolbar_.

Referenced by onCommandEvent().

Here is the call graph for this function:

◆ onUpdateUI()

void MainFrame::onUpdateUI ( wxUpdateUIEvent &  event)
private

Updates toolbar and menubar item enabled/disabled states.

Parameters
eventUpdate event for the menu or toolbar item to be updated.

Definition at line 338 of file MainFrame.cc.

338 {
339
340 CommandRegistry* registry = wxGetApp().commandRegistry();
341 GUICommand* command = registry->createCommand(event.GetId());
342
343 if (command == NULL) {
344 event.Skip();
345 return;
346 }
347
348 wxView* view = wxGetApp().docManager()->GetCurrentView();
349 if (view != NULL) {
350 EditorCommand* editorCmd = dynamic_cast<EditorCommand*>(command);
351 if (editorCmd != NULL) {
352 editorCmd->setView(view);
353 }
354 }
355
356 if (command->isEnabled()) {
357 event.Enable(true);
358 } else {
359 event.Enable(false);
360 }
361
362 if (command->isChecked()) {
363 event.Check(command->isChecked());
364 }
365
366 delete command;
367}
GUICommand * createCommand(const int id)
virtual bool isChecked() const

References CommandRegistry::createCommand(), GUICommand::isChecked(), GUICommand::isEnabled(), and EditorCommand::setView().

Here is the call graph for this function:

◆ updateUI()

void MainFrame::updateUI ( )

Updates enabled/disabled states of toolbar buttons and menu items.

Definition at line 373 of file MainFrame.cc.

373 {
374
375 wxMenuBar* menubar = GetMenuBar();
376 for (unsigned i = 0; i < menubar->GetMenuCount(); i++) {
377 menubar->GetMenu(i)->UpdateUI();
378 }
379
380 if (toolbar_ == NULL) {
381 return;
382 }
383
384 CommandRegistry* registry = wxGetApp().commandRegistry();
385 ProDeOptions* options = wxGetApp().options();
386 ToolbarButton* tool = options->firstToolbarButton();
387
388 while (tool != NULL) {
389 int id = registry->commandId(tool->action());
390 if (!registry->isEnabled(tool->action())) {
391 toolbar_->EnableTool(id, false);
392 } else {
393 toolbar_->EnableTool(id, true);
394 }
395 tool = options->nextToolbarButton();
396 }
397
398}
bool isEnabled(const std::string command)
int commandId(const std::string name) const
std::string action() const

References ToolbarButton::action(), CommandRegistry::commandId(), CommandRegistry::isEnabled(), options, and toolbar_.

Referenced by onCommandEvent().

Here is the call graph for this function:

Member Data Documentation

◆ commandRegistry_

CommandRegistry* MainFrame::commandRegistry_
private

Command registry.

Definition at line 72 of file MainFrame.hh.

◆ toolbar_

wxToolBar* MainFrame::toolbar_
private

Toolbar.

Definition at line 75 of file MainFrame.hh.

Referenced by createToolbar(), onToggleToolbar(), and updateUI().


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