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

#include <OSEdMainFrame.hh>

Inheritance diagram for OSEdMainFrame:
Inheritance graph
Collaboration diagram for OSEdMainFrame:
Collaboration graph

Public Member Functions

 OSEdMainFrame (const wxString &title, const wxPoint &pos, const wxSize &size)
 
virtual ~OSEdMainFrame ()
 
OSEdTreeViewtreeView () const
 
CommandRegistryregistry () const
 
OSEdInformerinformer () const
 
wxStatusBar * statusBar () const
 
void updateMenuBar ()
 
void onCommandEvent (wxCommandEvent &event)
 

Private Member Functions

 OSEdMainFrame (const OSEdMainFrame &)
 Copying not allowed.
 
OSEdMainFrameoperator= (const OSEdMainFrame &)
 Assignment not allowed.
 

Private Attributes

CommandRegistryregistry_
 Command registry.
 
OSEdTreeViewtreeView_
 Tree view.
 
OSEdInformerinformer_
 Informs listener classes for events that occurs.
 
wxStatusBar * statusBar_
 Status bar of the main window.
 

Detailed Description

Main window of the application.

Contains a splitted window for showing data and a menu bar for executing actions.

Definition at line 49 of file OSEdMainFrame.hh.

Constructor & Destructor Documentation

◆ OSEdMainFrame() [1/2]

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

Constructor.

Parameters
titleWindow title.
posWindow position.
sizeWindow size.

Definition at line 82 of file OSEdMainFrame.cc.

85 : wxFrame((wxFrame *)NULL, -1, title, pos, size),
86 registry_(NULL), treeView_(NULL), informer_(NULL) {
87
88 wxImage::AddHandler(new wxPNGHandler);
89 // set logo
90 string logoPath =
95 wxBitmap bmp;
96 bmp.LoadFile(WxConversion::toWxString(logoPath), wxBITMAP_TYPE_PNG);
97 wxIcon logo;
98 logo.CopyFromBitmap(bmp);
99 SetIcon(logo);
100
102
103 // create default menu bar
104 wxMenu* menu = new wxMenu;
105 format fmt = texts.text(OSEdTextGenerator::TXT_MENU_OPTIONS);
106 menu->Append(
109 menu->Append(OSEdConstants::CMD_QUIT, WxConversion::toWxString(fmt.str()));
110
111 wxMenuBar* menuBar = new wxMenuBar;
113 menuBar->Append(menu, WxConversion::toWxString(fmt.str()));
114
115 menu = new wxMenu;
117 menu->Append(
119
121 menu->Append(
123 WxConversion::toWxString(fmt.str()));
124
126 menu->Append(
128
130 menu->Append(
132
134 menu->Append(
136
138 menu->Append(
140 WxConversion::toWxString(fmt.str()));
141
143 menu->Append(
145
147 menu->Append(
149
151 menu->Append(
153
155 menu->Append(
157
159 menuBar->Append(menu, WxConversion::toWxString(fmt.str()));
160
161 menu = new wxMenu;
163 menu->Append(
165
167 menu->Append(
169
171 menuBar->Append(menu, WxConversion::toWxString(fmt.str()));
172
173 SetMenuBar(menuBar);
174 statusBar_ = CreateStatusBar();
175
176 // add all custom commands to command registry
192
193 // create splitted window
194 wxSplitterWindow* splitter = new wxSplitterWindow(
195 this, -1, wxPoint(0, 0), wxSize(900, 500), wxSP_3D);
196
197 OSEdInfoView* infoView = new OSEdInfoView(splitter);
198 treeView_ = new OSEdTreeView(splitter, infoView);
199
200 splitter->SplitVertically(treeView_, infoView);
201
202 informer_ = new OSEdInformer();
203}
void addCommand(GUICommand *command)
static std::string bitmapsDirPath(const std::string &prog)
static const std::string DIRECTORY_SEPARATOR
static const std::string LOGO_NAME
Name of the logo.
static const wxString APPLICATION_NAME
The name of the application.
@ CMD_MODIFY_BEHAVIOR
Modify operation behavior command id.
@ CMD_REMOVE_MODULE
Remove module command id.
@ CMD_OPTIONS
Option command id.
@ CMD_PROPERTIES
Operation properties command id.
@ CMD_ADD_OPERATION
Add operation command id.
@ CMD_ABOUT
About command id.
@ CMD_BUILD_ALL
Build all command id.
@ CMD_MEMORY
Memory command id.
@ CMD_BUILD
Build command id.
@ CMD_SIMULATE
Simulate command id.
@ CMD_ADD_MODULE
Add module command id.
@ CMD_REMOVE_OPERATION
Remove operation command id.
@ CMD_QUIT
Quit command id.
OSEdTreeView * treeView_
Tree view.
CommandRegistry * registry_
Command registry.
wxStatusBar * statusBar_
Status bar of the main window.
OSEdInformer * informer_
Informs listener classes for events that occurs.
static OSEdTextGenerator & instance()
@ TXT_MENU_HELP
Help menu label.
@ TXT_MENU_SIMULATE
Simulate menu label.
@ TXT_MENU_OPTIONS
Option menu label.
@ TXT_MENU_TOOLS
Tools menu label.
@ TXT_MENU_USER_MANUAL
User manual menu label.
@ TXT_MENU_REMOVE_OPERATION
Remove operation menu label.
@ TXT_MENU_BUILD
Build menu label.
@ TXT_MENU_MEMORY
Memory menu label.
@ TXT_MENU_ADD_OPERATION
Add operation menu label.
@ TXT_MENU_ADD_MODULE
Add module menu label.
@ TXT_MENU_BUILD_ALL
Build all menu label.
@ TXT_MENU_MODIFY_PROPERTIES
Modify properties menu label.
@ TXT_MENU_REMOVE_MODULE
Remove module menu label.
@ TXT_MENU_MODIFY_BEHAVIOR
Modify behavior menu label.
@ TXT_MENU_ABOUT
About menu label.
@ TXT_MENU_QUIT
Quit menu label.
@ TXT_MENU_FILE
File menu label.
virtual boost::format text(int textId)
static const int COMMAND_ID
Command ID.
static wxString toWxString(const std::string &source)
static std::string toString(const wxString &source)

References OSEdConstants::APPLICATION_NAME, Environment::bitmapsDirPath(), OSEdConstants::CMD_ABOUT, OSEdConstants::CMD_ADD_MODULE, OSEdConstants::CMD_ADD_OPERATION, OSEdConstants::CMD_BUILD, OSEdConstants::CMD_BUILD_ALL, OSEdConstants::CMD_MEMORY, OSEdConstants::CMD_MODIFY_BEHAVIOR, OSEdConstants::CMD_OPTIONS, OSEdConstants::CMD_PROPERTIES, OSEdConstants::CMD_QUIT, OSEdConstants::CMD_REMOVE_MODULE, OSEdConstants::CMD_REMOVE_OPERATION, OSEdConstants::CMD_SIMULATE, UserManualCmd::COMMAND_ID, FileSystem::DIRECTORY_SEPARATOR, OSEdTextGenerator::instance(), OSEdConstants::LOGO_NAME, Texts::TextGenerator::text(), WxConversion::toString(), WxConversion::toWxString(), OSEdTextGenerator::TXT_MENU_ABOUT, OSEdTextGenerator::TXT_MENU_ADD_MODULE, OSEdTextGenerator::TXT_MENU_ADD_OPERATION, OSEdTextGenerator::TXT_MENU_BUILD, OSEdTextGenerator::TXT_MENU_BUILD_ALL, OSEdTextGenerator::TXT_MENU_FILE, OSEdTextGenerator::TXT_MENU_HELP, OSEdTextGenerator::TXT_MENU_MEMORY, OSEdTextGenerator::TXT_MENU_MODIFY_BEHAVIOR, OSEdTextGenerator::TXT_MENU_MODIFY_PROPERTIES, OSEdTextGenerator::TXT_MENU_OPTIONS, OSEdTextGenerator::TXT_MENU_QUIT, OSEdTextGenerator::TXT_MENU_REMOVE_MODULE, OSEdTextGenerator::TXT_MENU_REMOVE_OPERATION, OSEdTextGenerator::TXT_MENU_SIMULATE, OSEdTextGenerator::TXT_MENU_TOOLS, and OSEdTextGenerator::TXT_MENU_USER_MANUAL.

Here is the call graph for this function:

◆ ~OSEdMainFrame()

OSEdMainFrame::~OSEdMainFrame ( )
virtual

Destructor.

Definition at line 208 of file OSEdMainFrame.cc.

208 {
209 delete registry_;
210 registry_ = NULL;
211 delete informer_;
212 informer_ = NULL;
213}

References informer_, and registry_.

◆ OSEdMainFrame() [2/2]

OSEdMainFrame::OSEdMainFrame ( const OSEdMainFrame )
private

Copying not allowed.

Member Function Documentation

◆ informer()

OSEdInformer * OSEdMainFrame::informer ( ) const

Returns informer instance.

Returns
The informer instance.

Definition at line 261 of file OSEdMainFrame.cc.

261 {
262 return informer_;
263}

References informer_.

◆ onCommandEvent()

void OSEdMainFrame::onCommandEvent ( wxCommandEvent &  event)

Handles menu events.

Parameters
eventEvent to be handled.

Definition at line 221 of file OSEdMainFrame.cc.

221 {
222 GUICommand* command = registry_->createCommand(event.GetId());
223 if (command == NULL) {
226 ErrorDialog dialog(this, WxConversion::toWxString(fmt.str()));
227 dialog.ShowModal();
228 return;
229 }
230 command->setParentWindow(this);
231 command->Do();
232 delete command;
233}
GUICommand * createCommand(const int id)
virtual bool Do()=0
void setParentWindow(wxWindow *view)
Definition GUICommand.cc:64
@ TXT_ERROR_NO_HANDLER
Error when custom command handler is not found.

References CommandRegistry::createCommand(), GUICommand::Do(), OSEdTextGenerator::instance(), registry_, GUICommand::setParentWindow(), Texts::TextGenerator::text(), WxConversion::toWxString(), and OSEdTextGenerator::TXT_ERROR_NO_HANDLER.

Here is the call graph for this function:

◆ operator=()

OSEdMainFrame & OSEdMainFrame::operator= ( const OSEdMainFrame )
private

Assignment not allowed.

◆ registry()

CommandRegistry * OSEdMainFrame::registry ( ) const

Returns the command registry.

Returns
the command registry.

Definition at line 251 of file OSEdMainFrame.cc.

251 {
252 return registry_;
253}

References registry_.

Referenced by OSEdTreeView::onItemClicked().

◆ statusBar()

wxStatusBar * OSEdMainFrame::statusBar ( ) const

Returns status bar of the frame.

Returns
Status bar.

Definition at line 271 of file OSEdMainFrame.cc.

271 {
272 return statusBar_;
273}

References statusBar_.

Referenced by OSEdInfoView::onDropDownMenu(), OSEdTreeView::onDropDownMenu(), OSEdTreeView::onItemSelected(), and OSEdInfoView::onSelection().

◆ treeView()

OSEdTreeView * OSEdMainFrame::treeView ( ) const

Returns pointer to the tree view.

Returns
Pointer to the tree view.

Definition at line 241 of file OSEdMainFrame.cc.

241 {
242 return treeView_;
243}

References treeView_.

Referenced by OSEdAddModuleCmd::Do(), OSEdAddOperationCmd::Do(), OSEdPropertiesCmd::Do(), OSEdSimulateCmd::Do(), OSEdBuildCmd::isEnabled(), and OSEd::OnInit().

◆ updateMenuBar()

void OSEdMainFrame::updateMenuBar ( )

Updates the menu bar disabled/enabled states.

Definition at line 279 of file OSEdMainFrame.cc.

279 {
280 wxMenuBar* menubar = GetMenuBar();
281 GUICommand* command = registry_->firstCommand();
282 while (command != NULL) {
283 if (menubar->FindItem(command->id()) != NULL) {
284 if (command->isEnabled()) {
285 menubar->Enable(command->id(), true);
286 } else {
287 menubar->Enable(command->id(), false);
288 }
289 }
290 command = registry_->nextCommand();
291 }
292}
GUICommand * firstCommand()
GUICommand * nextCommand()
virtual int id() const =0
virtual bool isEnabled()=0

References CommandRegistry::firstCommand(), GUICommand::id(), GUICommand::isEnabled(), CommandRegistry::nextCommand(), and registry_.

Referenced by OSEd::OnInit(), and OSEdInfoView::onSelection().

Here is the call graph for this function:

Member Data Documentation

◆ informer_

OSEdInformer* OSEdMainFrame::informer_
private

Informs listener classes for events that occurs.

Definition at line 77 of file OSEdMainFrame.hh.

Referenced by informer(), and ~OSEdMainFrame().

◆ registry_

CommandRegistry* OSEdMainFrame::registry_
private

Command registry.

Definition at line 73 of file OSEdMainFrame.hh.

Referenced by onCommandEvent(), registry(), updateMenuBar(), and ~OSEdMainFrame().

◆ statusBar_

wxStatusBar* OSEdMainFrame::statusBar_
private

Status bar of the main window.

Definition at line 79 of file OSEdMainFrame.hh.

Referenced by statusBar().

◆ treeView_

OSEdTreeView* OSEdMainFrame::treeView_
private

Tree view.

Definition at line 75 of file OSEdMainFrame.hh.

Referenced by treeView().


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