OpenASIP  2.0
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ResultDialog Class Reference

#include <ResultDialog.hh>

Inheritance diagram for ResultDialog:
Inheritance graph
Collaboration diagram for ResultDialog:
Collaboration graph

Public Member Functions

 ResultDialog (wxWindow *parent, std::vector< std::string > output, const std::string &title, const std::string &module="")
 
virtual ~ResultDialog ()
 

Private Types

enum  { ID_RESULT, ID_BUTTON_OPEN }
 

Private Member Functions

 ResultDialog (const ResultDialog &)
 Copying not allowed. More...
 
ResultDialog operator= (const ResultDialog &)
 Assignment not allowed. More...
 
wxSizer * createContents (wxWindow *parent, bool call_fit, bool set_sizer)
 
void setTexts ()
 
virtual bool TransferDataToWindow ()
 
void onOpen (wxCommandEvent &event)
 

Private Attributes

wxTextCtrl * result_
 Result window pointer. More...
 
std::vector< std::string > output_
 Output of compilation. More...
 
std::string module_
 Module which was compiled or empty string, if all modules were compiled. More...
 

Detailed Description

Dialog that shows operation build results.

Definition at line 44 of file ResultDialog.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

Widget ids.

Enumerator
ID_RESULT 
ID_BUTTON_OPEN 

Definition at line 67 of file ResultDialog.hh.

67  {
68  ID_RESULT,
70  };

Constructor & Destructor Documentation

◆ ResultDialog() [1/2]

ResultDialog::ResultDialog ( wxWindow *  parent,
std::vector< std::string >  output,
const std::string &  title,
const std::string &  module = "" 
)

Constructor.

Parameters
parentParent window.

Definition at line 60 of file ResultDialog.cc.

64  :
65  wxDialog(parent, -1, _T(""),
67  wxDefaultSize, wxRESIZE_BORDER),
68  output_(output), module_(module) {
69 
70  createContents(this, true, true);
71  result_ = dynamic_cast<wxTextCtrl*>(FindWindow(ID_RESULT));
72  result_->SetEditable(false);
73 
74  FindWindow(wxID_OK)->SetFocus();
75  SetTitle(WxConversion::toWxString(title));
76  if (module_ == "") {
77  FindWindow(ID_BUTTON_OPEN)->Disable();
78  }
79  setTexts();
80 }

References WxConversion::toWxString().

Here is the call graph for this function:

◆ ~ResultDialog()

ResultDialog::~ResultDialog ( )
virtual

Destructor.

Definition at line 85 of file ResultDialog.cc.

85  {
86  int x, y;
87  GetPosition(&x, &y);
88  wxPoint point(x, y);
90 }

References DialogPosition::DIALOG_RESULT, and DialogPosition::setPosition().

Here is the call graph for this function:

◆ ResultDialog() [2/2]

ResultDialog::ResultDialog ( const ResultDialog )
private

Copying not allowed.

Member Function Documentation

◆ createContents()

wxSizer * ResultDialog::createContents ( wxWindow *  parent,
bool  call_fit,
bool  set_sizer 
)
private

Creates the contents of the dialog.

NOTE! This function was generated by wxDesigner.

Parameters
parentParent window.
call_fitIf true fits the contents inside the dialog.
set_sizerIf true, sets the main sizer as contents of dialog.
Returns
The created sizer.

Definition at line 161 of file ResultDialog.cc.

164  {
165 
166  wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
167 
168  wxTextCtrl *item1 = new wxTextCtrl( parent, ID_RESULT, wxT(""), wxDefaultPosition, wxSize(400,100), wxTE_MULTILINE );
169  item0->Add( item1, 1, wxGROW|wxALL, 5 );
170 
171  wxBoxSizer *item2 = new wxBoxSizer( wxHORIZONTAL );
172 
173  wxButton *item3 = new wxButton( parent, ID_BUTTON_OPEN, wxT("Open"), wxDefaultPosition, wxDefaultSize, 0 );
174  item2->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );
175 
176  wxButton *item4 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
177  item2->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
178 
179  item0->Add( item2, 0, wxALIGN_CENTER|wxALL, 5 );
180 
181  if (set_sizer)
182  {
183  parent->SetSizer( item0 );
184  if (call_fit)
185  item0->SetSizeHints( parent );
186  }
187 
188  return item0;
189 }

References ID_BUTTON_OPEN, and ID_RESULT.

◆ onOpen()

void ResultDialog::onOpen ( wxCommandEvent &  event)
private

Handles the event when Open button is pushed.

Definition at line 126 of file ResultDialog.cc.

126  {
127 
129  OSEdOptions* options = wxGetApp().options();
130  string editor = options->editor();
131  if (editor == "") {
132  format fmt = texts.text(OSEdTextGenerator::TXT_ERROR_NO_EDITOR);
133  ErrorDialog error(this, WxConversion::toWxString(fmt.str()));
134  error.ShowModal();
135  } else {
136  if (FileSystem::fileExists(editor)) {
137  string cmd = editor + " " + module_;
138  CommandThread* thread = new CommandThread(cmd);
139  thread->Create();
140  thread->Run();
141  } else {
142  format fmt = texts.text(OSEdTextGenerator::TXT_ERROR_OPEN);
143  fmt % editor;
144  ErrorDialog dialog(this, WxConversion::toWxString(fmt.str()));
145  dialog.ShowModal();
146  }
147  }
148 }

References FileSystem::fileExists(), OSEdTextGenerator::instance(), module_, options, Texts::TextGenerator::text(), WxConversion::toWxString(), OSEdTextGenerator::TXT_ERROR_NO_EDITOR, and OSEdTextGenerator::TXT_ERROR_OPEN.

Here is the call graph for this function:

◆ operator=()

ResultDialog ResultDialog::operator= ( const ResultDialog )
private

Assignment not allowed.

◆ setTexts()

void ResultDialog::setTexts ( )
private

Set texts to widgets.

Definition at line 96 of file ResultDialog.cc.

96  {
97 
100 
101  // buttons
102  WidgetTools::setLabel(&guiText, FindWindow(wxID_OK),
104 
107 }

References ID_BUTTON_OPEN, OSEdTextGenerator::instance(), GUITextGenerator::instance(), WidgetTools::setLabel(), GUITextGenerator::TXT_BUTTON_OK, and OSEdTextGenerator::TXT_BUTTON_OPEN.

Here is the call graph for this function:

◆ TransferDataToWindow()

bool ResultDialog::TransferDataToWindow ( )
privatevirtual

Transfer data to window.

Returns
True if transfer is successful.

Definition at line 115 of file ResultDialog.cc.

115  {
116  for (size_t i = 0; i < output_.size(); i++) {
117  result_->AppendText(WxConversion::toWxString(output_[i]));
118  }
119  return wxWindow::TransferDataToWindow();
120 }

References output_, result_, and WxConversion::toWxString().

Here is the call graph for this function:

Member Data Documentation

◆ module_

std::string ResultDialog::module_
private

Module which was compiled or empty string, if all modules were compiled.

Definition at line 78 of file ResultDialog.hh.

Referenced by onOpen().

◆ output_

std::vector<std::string> ResultDialog::output_
private

Output of compilation.

Definition at line 75 of file ResultDialog.hh.

Referenced by TransferDataToWindow().

◆ result_

wxTextCtrl* ResultDialog::result_
private

Result window pointer.

Definition at line 73 of file ResultDialog.hh.

Referenced by TransferDataToWindow().


The documentation for this class was generated from the following files:
WxConversion::toWxString
static wxString toWxString(const std::string &source)
WidgetTools::setLabel
static void setLabel(Texts::TextGenerator *generator, wxWindow *widget, int textID)
Definition: WidgetTools.cc:92
GUITextGenerator::instance
static GUITextGenerator * instance()
Definition: GUITextGenerator.cc:67
DialogPosition::getPosition
static wxPoint getPosition(Dialogs dialog)
Definition: DialogPosition.cc:49
GUITextGenerator
Definition: GUITextGenerator.hh:46
ResultDialog::output_
std::vector< std::string > output_
Output of compilation.
Definition: ResultDialog.hh:75
FindWindow
Definition: FindWindow.hh:49
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
DialogPosition::setPosition
static void setPosition(Dialogs dialog, wxPoint point)
Definition: DialogPosition.cc:63
ErrorDialog
Definition: ErrorDialog.hh:42
OSEdTextGenerator::TXT_BUTTON_OPEN
@ TXT_BUTTON_OPEN
Open button label.
Definition: OSEdTextGenerator.hh:71
ResultDialog::createContents
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
Definition: ResultDialog.cc:161
ResultDialog::module_
std::string module_
Module which was compiled or empty string, if all modules were compiled.
Definition: ResultDialog.hh:78
OSEdTextGenerator::TXT_ERROR_NO_EDITOR
@ TXT_ERROR_NO_EDITOR
Error when no editor is given.
Definition: OSEdTextGenerator.hh:140
ResultDialog::result_
wxTextCtrl * result_
Result window pointer.
Definition: ResultDialog.hh:73
OSEdTextGenerator::TXT_ERROR_OPEN
@ TXT_ERROR_OPEN
Error when opening fails.
Definition: OSEdTextGenerator.hh:141
ResultDialog::setTexts
void setTexts()
Definition: ResultDialog.cc:96
CommandThread
Definition: CommandThread.hh:43
options
static MachInfoCmdLineOptions options
Definition: MachInfo.cc:46
ResultDialog::ID_BUTTON_OPEN
@ ID_BUTTON_OPEN
Definition: ResultDialog.hh:69
DialogPosition::DIALOG_RESULT
@ DIALOG_RESULT
Result dialog.
Definition: DialogPosition.hh:52
FileSystem::fileExists
static bool fileExists(const std::string fileName)
OSEdTextGenerator::instance
static OSEdTextGenerator & instance()
Definition: OSEdTextGenerator.cc:214
OSEdTextGenerator
Definition: OSEdTextGenerator.hh:42
OSEdOptions
Definition: OSEdOptions.hh:46
ResultDialog::ID_RESULT
@ ID_RESULT
Definition: ResultDialog.hh:68
GUITextGenerator::TXT_BUTTON_OK
@ TXT_BUTTON_OK
Label for OK button.
Definition: GUITextGenerator.hh:59