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

#include <ProDe.hh>

Inheritance diagram for ProDe:
Inheritance graph
Collaboration diagram for ProDe:
Collaboration graph

Public Member Functions

 ProDe ()
 
bool OnInit ()
 
int OnExit ()
 
MainFramemainFrame () const
 
ProDeOptionsoptions () const
 
void setOptions (ProDeOptions *options)
 
CommandRegistrycommandRegistry () const
 
wxDocManager * docManager () const
 

Static Public Member Functions

static std::string bitmapsDirPath ()
 

Private Member Functions

void createDefaultOptions ()
 

Private Attributes

wxDocManager * docManager_
 Manages multiple documents.
 
MainFramemainFrame_
 Main frame of the application.
 
ProDeOptionsoptions_
 editor options
 
CommandRegistrycommandRegistry_
 editor command registry
 

Detailed Description

Represents the ProDe application.

This class is responsible for parsing the command line and initializing the editor accordingly. If the editor is executed in interactive mode, a graphical user interface will be initialized. The class is derived from wxApp class, which does the low level initialization of wxWindows automatically.

Definition at line 54 of file ProDe.hh.

Constructor & Destructor Documentation

◆ ProDe()

ProDe::ProDe ( )

The constructor.

Definition at line 72 of file ProDe.cc.

72 : docManager_((wxDocManager*)NULL), options_(NULL) {
73}
ProDeOptions * options_
editor options
Definition ProDe.hh:74
wxDocManager * docManager_
Manages multiple documents.
Definition ProDe.hh:70

Member Function Documentation

◆ bitmapsDirPath()

string ProDe::bitmapsDirPath ( )
static

Returns path of toolbar icon files.

Returns
ProDe icon files path.

Definition at line 427 of file ProDe.cc.

427 {
428 string path = Environment::bitmapsDirPath("ProDe") +
430 return path;
431}
static std::string bitmapsDirPath(const std::string &prog)
static const std::string DIRECTORY_SEPARATOR

References Environment::bitmapsDirPath(), and FileSystem::DIRECTORY_SEPARATOR.

Referenced by AboutDialog::createContents().

Here is the call graph for this function:

◆ commandRegistry()

CommandRegistry * ProDe::commandRegistry ( ) const

Returns command registry of the editor.

Definition at line 406 of file ProDe.cc.

406 {
407 return commandRegistry_;
408}
CommandRegistry * commandRegistry_
editor command registry
Definition ProDe.hh:76

References commandRegistry_.

◆ createDefaultOptions()

void ProDe::createDefaultOptions ( )
private

Creates default options.

Definition at line 277 of file ProDe.cc.

277 {
278
279 // kb shortcut: ctrl-N = New Document
281 ProDeConstants::CMD_NAME_NEW_DOC, 0, true, false, int('N'));
282
283 // kb shortcut: ctrl-O = Open Document
285 ProDeConstants::CMD_NAME_OPEN_DOC, 0, true, false, int('O'));
286
287 // kb shortcut: ctrl-S = Save Document
289 ProDeConstants::CMD_NAME_SAVE_DOC, 0, true, false, int('S'));
290
291 // kb shortcut: ctrl-W = close document
292 KeyboardShortcut* scClose = new KeyboardShortcut(
293 ProDeConstants::CMD_NAME_CLOSE_DOC, 0, true, false, int('W'));
294
295 // kb shortcut: ctrl-P = print document
296 KeyboardShortcut* scPrint = new KeyboardShortcut(
297 ProDeConstants::CMD_NAME_PRINT, 0, true, false, int('P'));
298
299 // kb shortcut: ctrl-Q = quit
301 ProDeConstants::CMD_NAME_QUIT, 0, true, false, int('Q'));
302
303
304 // kb shortcut: ctrl-C = copy
306 ProDeConstants::CMD_NAME_COPY, 0, true, false, int('C'));
307
308 // kb shortcut: ctrl-X = cut
310 ProDeConstants::CMD_NAME_CUT, 0, true, false, int('X'));
311
312 // kb shortcut: ctrl-V = paste
313 KeyboardShortcut* scPaste = new KeyboardShortcut(
314 ProDeConstants::CMD_NAME_PASTE, 0, true, false, int('V'));
315
316 // kb shortcut: ctrl-Z = undo
318 ProDeConstants::CMD_NAME_UNDO, 0, true, false, int('Z'));
319
320 // kb shortcut: ctrl-Y = redo
322 ProDeConstants::CMD_NAME_REDO, 0, true, false, int('Y'));
323
324 // kb shortcut: F1 = Help
325 KeyboardShortcut* scUserManual = new KeyboardShortcut(
326 UserManualCmd::COMMAND_NAME, 1, false, false, 0);
327
328 // toolbar buttons
329 ToolbarButton* buttonNew = new ToolbarButton(
331
332 ToolbarButton* buttonOpen = new ToolbarButton(
334
335 ToolbarButton* buttonSave = new ToolbarButton(
337
338 ToolbarButton* buttonDelete = new ToolbarButton(
340
341 ToolbarButton* buttonModify = new ToolbarButton(
343
344 ToolbarButton* buttonZoomIn = new ToolbarButton(
346
347 ToolbarButton* buttonZoomOut = new ToolbarButton(
349
350 ToolbarButton* buttonZoomFit = new ToolbarButton(
352
353 ToolbarButton* buttonOptions = new ToolbarButton(
355
356 ToolbarButton* buttonHelp = new ToolbarButton(
358
359 options_ = new ProDeOptions();
360
372 options_->addKeyboardShortcut(scUserManual);
373
374 options_->addToolbarButton(buttonNew);
375 options_->addToolbarButton(buttonOpen);
376 options_->addToolbarButton(buttonSave);
377 options_->addToolbarButton(buttonDelete);
378 options_->addToolbarButton(buttonModify);
379 options_->addToolbarButton(buttonZoomIn);
380 options_->addToolbarButton(buttonZoomOut);
381 options_->addToolbarButton(buttonZoomFit);
382 options_->addToolbarButton(buttonOptions);
383 options_->addToolbarButton(buttonHelp);
387
388 // default toolbar layout and visibility
391
392 // default undo levels
394
395 // set MainFrame size and position
396 options_->setFullScreen(false);
397 options_->setWindowSize(600, 500);
398 options_->setWindowPosition(100, 50);
399}
void addKeyboardShortcut(KeyboardShortcut *shortcut)
void setToolbarVisibility(bool visible)
void addToolbarButton(ToolbarButton *button)
void setFullScreen(bool fullScreen)
void setWindowPosition(int x, int y)
void addSeparator(int position)
@ BOTH
Buttons contains text and icon.
Definition GUIOptions.hh:67
void setToolbarLayout(ToolbarLayout layout)
void setWindowSize(int width, int height)
static const std::string CMD_NAME_REDO
Command name for the "Redo" command.
static const std::string CMD_NAME_EDIT_OPTIONS
Command name for the "Edit Options" command.
static const std::string CMD_NAME_OPEN_DOC
Command name for the "Open Document" command.
static const std::string CMD_NAME_NEW_DOC
Command name for the "New Document" command.
static const std::string CMD_NAME_SAVE_DOC
Command name for the "Save Document" command.
static const std::string CMD_NAME_UNDO
Command name for the "Undo" command.
static const std::string CMD_NAME_ZOOM_FIT_WIN
Command name for the "Fit Window" command.
static const std::string CMD_NAME_COPY
Command name for the "Copy" command.
static const std::string CMD_NAME_ZOOM_OUT
Command name for the "Zoom Out" command.
static const std::string CMD_NAME_PASTE
Command name for the "Paste" command.
static const std::string CMD_NAME_ZOOM_IN
Command name for the "Zoom In" command.
static const std::string CMD_NAME_QUIT
Command name for the "Quit" command.
static const std::string CMD_NAME_CUT
Command name for the "Cut" command.
static const std::string CMD_NAME_CLOSE_DOC
Command name for the "Close Document" command.
static const std::string CMD_NAME_MODIFY_COMP
Command name for the "Modify Component" command.
static const std::string CMD_NAME_PRINT
Command name for the "Print" command.
static const std::string CMD_NAME_DELETE_COMP
Command name for the "Delete Component" command.
void setUndoStackSize(int size)
static const std::string COMMAND_NAME
Command name string.

References GUIOptions::addKeyboardShortcut(), GUIOptions::addSeparator(), GUIOptions::addToolbarButton(), GUIOptions::BOTH, ProDeConstants::CMD_NAME_CLOSE_DOC, ProDeConstants::CMD_NAME_COPY, ProDeConstants::CMD_NAME_CUT, ProDeConstants::CMD_NAME_DELETE_COMP, ProDeConstants::CMD_NAME_EDIT_OPTIONS, ProDeConstants::CMD_NAME_MODIFY_COMP, ProDeConstants::CMD_NAME_NEW_DOC, ProDeConstants::CMD_NAME_OPEN_DOC, ProDeConstants::CMD_NAME_PASTE, ProDeConstants::CMD_NAME_PRINT, ProDeConstants::CMD_NAME_QUIT, ProDeConstants::CMD_NAME_REDO, ProDeConstants::CMD_NAME_SAVE_DOC, ProDeConstants::CMD_NAME_UNDO, ProDeConstants::CMD_NAME_ZOOM_FIT_WIN, ProDeConstants::CMD_NAME_ZOOM_IN, ProDeConstants::CMD_NAME_ZOOM_OUT, UserManualCmd::COMMAND_NAME, options_, GUIOptions::setFullScreen(), GUIOptions::setToolbarLayout(), GUIOptions::setToolbarVisibility(), ProDeOptions::setUndoStackSize(), GUIOptions::setWindowPosition(), and GUIOptions::setWindowSize().

Referenced by OnInit().

Here is the call graph for this function:

◆ docManager()

wxDocManager * ProDe::docManager ( ) const

Returns document manager of the editor.

Definition at line 416 of file ProDe.cc.

416 {
417 return docManager_;
418}

References docManager_.

◆ mainFrame()

MainFrame * ProDe::mainFrame ( ) const

Returns pointer to the main frame of the editor.

Returns
Pointer to the main frame of the editor.

Definition at line 242 of file ProDe.cc.

242 {
243 return mainFrame_;
244}
MainFrame * mainFrame_
Main frame of the application.
Definition ProDe.hh:72

References mainFrame_.

◆ OnExit()

int ProDe::OnExit ( )

Deletes the application level dynamic objects not handled by wxWindows.

Called when the editor is about to exit, and all application windows are already destroyed.

Definition at line 227 of file ProDe.cc.

227 {
230 delete docManager_;
231 delete options_;
232 return 0;
233}
static void destroy()

References ProDeClipboard::destroy(), ProDeTextGenerator::destroy(), docManager_, and options_.

Here is the call graph for this function:

◆ OnInit()

bool ProDe::OnInit ( )

Parses the command line and initializes the editor accordingly.

Called only once by wxWindows when the program is executed. Command line is parsed using wxCmdLineParser class. If no script is provided with a "-s" option, main frame is created and set as the main window. An instance of the wxDocManager will be created to handle document templates, if the editor is ran in interactive mode.

Returns
true if application was succesfully initialized, false otherwise.

Definition at line 89 of file ProDe.cc.

89 {
90
92
93 // parse command line
94 static const wxCmdLineEntryDesc cmdLineDesc[] = {
95
96#if wxCHECK_VERSION(3, 0, 0)
97 { wxCMD_LINE_PARAM, "", "", "file", wxCMD_LINE_VAL_STRING,
98 wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE },
99
100 { wxCMD_LINE_NONE, "", "", "", wxCMD_LINE_VAL_STRING, 0}
101#else
102 { wxCMD_LINE_PARAM, _T(""), _T(""), _T("file"), wxCMD_LINE_VAL_STRING,
103 wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE },
104
105 { wxCMD_LINE_NONE, _T(""), _T(""), _T(""), wxCMD_LINE_VAL_STRING, 0}
106#endif
107
108 };
109
110 wxCmdLineParser parser(cmdLineDesc, argc, argv);
111 int parserStatus = parser.Parse();
112 if (parserStatus != 0) {
113 return false;
114 }
115
116 // create a document template for ADF files.
117 docManager_ = new wxDocManager;
118 (void) new wxDocTemplate((wxDocManager*) docManager_,
119 _T("Architecture Definition"),
120 _T("*.adf;*.xml;*.cfg"), _T(""),
121 _T("adf"), _T("Architecture Definition File"),
122 _T("ADF View"), CLASSINFO(MDFDocument),
123 CLASSINFO(MDFView));
124
125 // Dummy doc template for cfgs.
126 // Older versions of wxWidgets don't handle the *.adf;*.cfg file filter
127 // correctly and .cfgs don't get associated to the correct document class
128 // without this invisble template.
129 (void) new wxDocTemplate((wxDocManager*) docManager_,
130 _T("Processor Configuration"),
131 _T("*.cfg"), _T(""),
132 _T("cfg"), _T("Architecture Definition File"),
133 _T("ADF View"), CLASSINFO(MDFDocument),
134 CLASSINFO(MDFView), wxTEMPLATE_INVISIBLE);
135
136 // Dummy doc template for xmls.
137 (void) new wxDocTemplate((wxDocManager*) docManager_,
138 _T("Architecture Definition File"),
139 _T("*.xml"), _T(""),
140 _T("xml"), _T("Architecture Definition File"),
141 _T("ADF View"), CLASSINFO(MDFDocument),
142 CLASSINFO(MDFView), wxTEMPLATE_INVISIBLE);
143
144 // create a registry of commands
146
147 // load image handler for pngs
148 wxImage::AddHandler(new wxPNGHandler);
149
150 // set configurations
151 string configFile = Environment::confPath("ProDe.conf");
152
153 // Name of the XML Schema for options file.
154 string schemaFile =
156 FileSystem::DIRECTORY_SEPARATOR + "confschema.xsd";
157
159 reader.setSourceFile(configFile);
160 reader.setSchemaFile(schemaFile);
161 reader.setUseSchema(true);
162 bool erroneousOptions = false;
163 try {
164 ObjectState* optionsState = reader.readState();
165 options_ = new ProDeOptions(optionsState);
166 delete optionsState;
168 options_->setFileName(configFile);
169 } catch (Exception& e) {
170 cerr << e.errorMessage() << endl
171 << "Default options will be used." << endl;
172 erroneousOptions = true;
173 }
174
175 if (erroneousOptions) {
177 } else {
179 }
180
181 // create the main frame window
182 mainFrame_ =
183 new MainFrame((wxDocManager*) docManager_, (wxFrame*) NULL,
185 wxPoint(options_->xPosition(), options_->yPosition()),
186 wxSize(options_->windowWidth(),
188 wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE);
189
190 mainFrame_->Show(TRUE);
191 SetTopWindow(mainFrame_);
192
193 // open documents given in command line
194 for (unsigned int i = 0; i < parser.GetParamCount(); i++) {
195 wxString file = parser.GetParam(i);
196 wxDocument* doc = docManager_->CreateDocument(file, wxDOC_SILENT);
197 if (doc == NULL) {
198 string fileName = WxConversion::toString(file);
199 if (FileSystem::fileExists(fileName)) {
200 std::cerr << "Improper file '"
201 << fileName
202 << "' couldn't be opened."
203 << std::endl;
204 } else {
205 std::cerr << "Cannot open file '"
206 << fileName
207 << "'."
208 << std::endl;
209 }
210 }
211 }
212
213 //mainFrame_->updateMenubar();
214 //mainFrame_->updateToolbar();
215
216 return true;
217}
const string TRUE
Value used for true in attribute and element values.
static void initialize()
static std::string dataDirPath(const std::string &prog)
static TCEString confPath(const std::string &fileName)
std::string errorMessage() const
Definition Exception.cc:123
static bool fileExists(const std::string fileName)
int windowWidth() const
int yPosition() const
int xPosition() const
virtual void validate() const
int windowHeight() const
void clearModified()
void setFileName(const std::string &fileName)
static const wxString EDITOR_NAME
Full name of the Editor.
void createDefaultOptions()
Definition ProDe.cc:277
static char ** toCStringArray(size_t elements, wxChar **source)
static std::string toString(const wxString &source)
void setUseSchema(bool useSchema)
void setSchemaFile(const std::string &fileName)
void setSourceFile(const std::string &fileName)

References GUIOptions::clearModified(), commandRegistry_, Environment::confPath(), createDefaultOptions(), Environment::dataDirPath(), FileSystem::DIRECTORY_SEPARATOR, docManager_, ProDeConstants::EDITOR_NAME, Exception::errorMessage(), FileSystem::fileExists(), Application::initialize(), mainFrame_, options_, GUIOptionsSerializer::readState(), GUIOptions::setFileName(), XMLSerializer::setSchemaFile(), XMLSerializer::setSourceFile(), XMLSerializer::setUseSchema(), WxConversion::toCStringArray(), WxConversion::toString(), TRUE, GUIOptions::validate(), GUIOptions::windowHeight(), GUIOptions::windowWidth(), GUIOptions::xPosition(), and GUIOptions::yPosition().

Here is the call graph for this function:

◆ options()

ProDeOptions * ProDe::options ( ) const

Returns editor options.

Returns
Current editor options.

Definition at line 253 of file ProDe.cc.

253 {
254 return options_;
255}

References options_.

Referenced by setOptions().

◆ setOptions()

void ProDe::setOptions ( ProDeOptions options)

Sets the editor options, and deletes old options.

Parameters
optionsProDeOptions to set as new options.

Definition at line 264 of file ProDe.cc.

264 {
265 if (options_ != NULL) {
266 delete options_;
267 }
270}
void createToolbar()
Definition MainFrame.cc:746
ProDeOptions * options() const
Definition ProDe.cc:253

References MainFrame::createToolbar(), mainFrame_, options(), and options_.

Here is the call graph for this function:

Member Data Documentation

◆ commandRegistry_

CommandRegistry* ProDe::commandRegistry_
private

editor command registry

Definition at line 76 of file ProDe.hh.

Referenced by commandRegistry(), and OnInit().

◆ docManager_

wxDocManager* ProDe::docManager_
private

Manages multiple documents.

Definition at line 70 of file ProDe.hh.

Referenced by docManager(), OnExit(), and OnInit().

◆ mainFrame_

MainFrame* ProDe::mainFrame_
private

Main frame of the application.

Definition at line 72 of file ProDe.hh.

Referenced by mainFrame(), OnInit(), and setOptions().

◆ options_

ProDeOptions* ProDe::options_
private

editor options

Definition at line 74 of file ProDe.hh.

Referenced by createDefaultOptions(), OnExit(), OnInit(), options(), and setOptions().


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