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

#include <OSEdOptionsDialog.hh>

Inheritance diagram for OSEdOptionsDialog:
Inheritance graph
Collaboration diagram for OSEdOptionsDialog:
Collaboration graph

Public Member Functions

 OSEdOptionsDialog (wxWindow *parent)
 
virtual ~OSEdOptionsDialog ()
 

Private Types

enum  { ID_TEXT = 10000, ID_EDITOR, ID_BUTTON_SAVE, ID_BUTTON_BROWSE }
 

Private Member Functions

 OSEdOptionsDialog (const OSEdOptionsDialog &)
 Copying not allowed. More...
 
OSEdOptionsDialogoperator= (const OSEdOptionsDialog &)
 Assignment not allowed. More...
 
wxSizer * createContents (wxWindow *parent, bool call_fit, bool set_sizer)
 
void setTexts ()
 
bool TransferDataToWindow ()
 
void onSave (wxCommandEvent &event)
 
void onBrowse (wxCommandEvent &event)
 

Private Attributes

wxString editor_
 The name of the editor. More...
 

Detailed Description

Dialog for modifying OSEd options.

Definition at line 41 of file OSEdOptionsDialog.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

Widget ids.

Enumerator
ID_TEXT 
ID_EDITOR 
ID_BUTTON_SAVE 
ID_BUTTON_BROWSE 

Definition at line 61 of file OSEdOptionsDialog.hh.

61  {
62  ID_TEXT = 10000,
63  ID_EDITOR,
66  };

Constructor & Destructor Documentation

◆ OSEdOptionsDialog() [1/2]

OSEdOptionsDialog::OSEdOptionsDialog ( wxWindow *  parent)

Constructor.

Parameters
parentThe parent window.

Definition at line 67 of file OSEdOptionsDialog.cc.

67  :
68  wxDialog(parent, -1, _T(""),
70  wxSize(400, 200)) {
71 
72  createContents(this, true, true);
73 
75  SetValidator(wxTextValidator(wxFILTER_ASCII, &editor_));
76 
77  setTexts();
78 }

◆ ~OSEdOptionsDialog()

OSEdOptionsDialog::~OSEdOptionsDialog ( )
virtual

Destructor.

Definition at line 83 of file OSEdOptionsDialog.cc.

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

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

Here is the call graph for this function:

◆ OSEdOptionsDialog() [2/2]

OSEdOptionsDialog::OSEdOptionsDialog ( const OSEdOptionsDialog )
private

Copying not allowed.

Member Function Documentation

◆ createContents()

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

Creates the contents of the dialog.

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

Definition at line 173 of file OSEdOptionsDialog.cc.

176  {
177 
178  wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
179 
180  item0->Add( 20, 20, 0, wxALIGN_CENTER|wxALL, 5 );
181 
182  wxBoxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
183 
184  wxStaticText *item2 = new wxStaticText( parent, ID_TEXT, wxT("Source code editor:"), wxDefaultPosition, wxDefaultSize, 0 );
185  item1->Add( item2, 0, wxALIGN_CENTER|wxALL, 5 );
186 
187  wxTextCtrl *item3 = new wxTextCtrl( parent, ID_EDITOR, wxT(""), wxDefaultPosition, wxSize(150,-1), 0 );
188  item1->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );
189 
190  wxButton *item4 = new wxButton( parent, ID_BUTTON_BROWSE, wxT("Browse"), wxDefaultPosition, wxDefaultSize, 0 );
191  item1->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
192 
193  item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
194 
195  item0->Add( 20, 20, 0, wxALIGN_CENTER|wxALL, 5 );
196 
197  wxBoxSizer *item5 = new wxBoxSizer( wxHORIZONTAL );
198 
199  wxButton *item6 = new wxButton( parent, ID_BUTTON_SAVE, wxT("&Save"), wxDefaultPosition, wxDefaultSize, 0 );
200  item5->Add( item6, 0, wxALIGN_CENTER|wxALL, 5 );
201 
202  wxButton *item7 = new wxButton( parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
203  item5->Add( item7, 0, wxALIGN_CENTER|wxALL, 5 );
204 
205  item0->Add( item5, 0, wxALIGN_CENTER|wxALL, 5 );
206 
207  if (set_sizer)
208  {
209  parent->SetSizer( item0 );
210  if (call_fit)
211  item0->SetSizeHints( parent );
212  }
213 
214  return item0;
215 }

References ID_BUTTON_BROWSE, ID_BUTTON_SAVE, ID_EDITOR, and ID_TEXT.

◆ onBrowse()

void OSEdOptionsDialog::onBrowse ( wxCommandEvent &  event)
private

Handles the event when Browse button is pushed.

Definition at line 153 of file OSEdOptionsDialog.cc.

153  {
154 
156  wxFileDialog dialog(this, _T("Choose a file"),
158  if (dialog.ShowModal() == wxID_OK) {
159  editor_ = dialog.GetPath();
160  wxWindow::TransferDataToWindow();
161  }
162 }

References FileSystem::directoryOfPath(), editor_, WxConversion::toString(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ onSave()

void OSEdOptionsDialog::onSave ( wxCommandEvent &  event)
private

Handles the event when Save button is pushed.

Definition at line 132 of file OSEdOptionsDialog.cc.

132  {
133  TransferDataFromWindow();
134  wxGetApp().options()->setEditor(WxConversion::toString(editor_));
135  OSEdOptionsSerializer serializer;
137  serializer.setDestinationFile(confFile);
138  try {
139  serializer.writeState(wxGetApp().options()->saveState());
140  } catch (const Exception& e) {
143  ErrorDialog dialog(this, WxConversion::toWxString(fmt.str()));
144  dialog.ShowModal();
145  }
146  EndModal(wxID_OK);
147 }

References OSEdConstants::CONF_FILE_NAME, editor_, OSEdTextGenerator::instance(), options, OSEdOptionsSerializer::setDestinationFile(), Texts::TextGenerator::text(), WxConversion::toString(), WxConversion::toWxString(), OSEdTextGenerator::TXT_ERROR_CAN_NOT_SAVE, Environment::userConfPath(), and OSEdOptionsSerializer::writeState().

Here is the call graph for this function:

◆ operator=()

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

Assignment not allowed.

◆ setTexts()

void OSEdOptionsDialog::setTexts ( )
private

◆ TransferDataToWindow()

bool OSEdOptionsDialog::TransferDataToWindow ( )
private

Transfers data to window.

Returns
True if all is successful.

Definition at line 122 of file OSEdOptionsDialog.cc.

122  {
123  OSEdOptions* options = wxGetApp().options();
125  return wxWindow::TransferDataToWindow();
126 }

References editor_, options, and WxConversion::toWxString().

Here is the call graph for this function:

Member Data Documentation

◆ editor_

wxString OSEdOptionsDialog::editor_
private

The name of the editor.

Definition at line 69 of file OSEdOptionsDialog.hh.

Referenced by onBrowse(), onSave(), and TransferDataToWindow().


The documentation for this class was generated from the following files:
OSEdTextGenerator::TXT_ERROR_CAN_NOT_SAVE
@ TXT_ERROR_CAN_NOT_SAVE
Error when options can not be saved.
Definition: OSEdTextGenerator.hh:142
WxConversion::toWxString
static wxString toWxString(const std::string &source)
OSEdOptionsDialog::createContents
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
Definition: OSEdOptionsDialog.cc:173
OSEdOptionsSerializer::writeState
virtual void writeState(const ObjectState *state)
Definition: OSEdOptionsSerializer.cc:55
OSEdOptionsDialog::setTexts
void setTexts()
Definition: OSEdOptionsDialog.cc:94
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
FindWindow
Definition: FindWindow.hh:49
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
OSEdOptionsDialog::ID_BUTTON_BROWSE
@ ID_BUTTON_BROWSE
Definition: OSEdOptionsDialog.hh:65
DialogPosition::setPosition
static void setPosition(Dialogs dialog, wxPoint point)
Definition: DialogPosition.cc:63
OSEdTextGenerator::TXT_OPTIONS_DIALOG_TITLE
@ TXT_OPTIONS_DIALOG_TITLE
Options dialog title.
Definition: OSEdTextGenerator.hh:114
Environment::userConfPath
static TCEString userConfPath(const std::string &fileName)
Definition: Environment.cc:303
OSEdTextGenerator::TXT_BUTTON_BROWSE
@ TXT_BUTTON_BROWSE
Browse button label.
Definition: OSEdTextGenerator.hh:79
OSEdOptionsDialog::ID_TEXT
@ ID_TEXT
Definition: OSEdOptionsDialog.hh:62
GUITextGenerator::TXT_BUTTON_CANCEL
@ TXT_BUTTON_CANCEL
Label for cancel button.
Definition: GUITextGenerator.hh:55
ErrorDialog
Definition: ErrorDialog.hh:42
FileSystem::directoryOfPath
static std::string directoryOfPath(const std::string fileName)
Definition: FileSystem.cc:79
OSEdOptionsSerializer::setDestinationFile
void setDestinationFile(const std::string &fileName)
Definition: OSEdOptionsSerializer.cc:99
OSEdOptionsSerializer
Definition: OSEdOptionsSerializer.hh:44
Exception
Definition: Exception.hh:54
DialogPosition::DIALOG_OPTIONS
@ DIALOG_OPTIONS
Options dialog.
Definition: DialogPosition.hh:53
options
static MachInfoCmdLineOptions options
Definition: MachInfo.cc:46
OSEdTextGenerator::instance
static OSEdTextGenerator & instance()
Definition: OSEdTextGenerator.cc:214
OSEdTextGenerator::TXT_LABEL_EDITOR
@ TXT_LABEL_EDITOR
Editor label.
Definition: OSEdTextGenerator.hh:58
OSEdTextGenerator
Definition: OSEdTextGenerator.hh:42
OSEdOptionsDialog::editor_
wxString editor_
The name of the editor.
Definition: OSEdOptionsDialog.hh:69
OSEdOptions
Definition: OSEdOptions.hh:46
OSEdOptionsDialog::ID_BUTTON_SAVE
@ ID_BUTTON_SAVE
Definition: OSEdOptionsDialog.hh:64
OSEdOptionsDialog::ID_EDITOR
@ ID_EDITOR
Definition: OSEdOptionsDialog.hh:63
OSEdTextGenerator::TXT_BUTTON_SAVE
@ TXT_BUTTON_SAVE
Save button label.
Definition: OSEdTextGenerator.hh:75
WxConversion::toString
static std::string toString(const wxString &source)
OSEdConstants::CONF_FILE_NAME
static const std::string CONF_FILE_NAME
Configuration file name.
Definition: OSEdConstants.hh:78