OpenASIP 2.2
Loading...
Searching...
No Matches
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.
 
OSEdOptionsDialogoperator= (const OSEdOptionsDialog &)
 Assignment not allowed.
 
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.
 

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.

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}
static wxPoint getPosition(Dialogs dialog)
@ DIALOG_OPTIONS
Options dialog.
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
wxString editor_
The name of the editor.

◆ ~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}
static void setPosition(Dialogs dialog, wxPoint point)

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}
static std::string directoryOfPath(const std::string fileName)
Definition FileSystem.cc:79
static wxString toWxString(const std::string &source)
static std::string toString(const wxString &source)

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}
static MachInfoCmdLineOptions options
Definition MachInfo.cc:46
static TCEString userConfPath(const std::string &fileName)
static const std::string CONF_FILE_NAME
Configuration file name.
virtual void writeState(const ObjectState *state)
void setDestinationFile(const std::string &fileName)
static OSEdTextGenerator & instance()
@ TXT_ERROR_CAN_NOT_SAVE
Error when options can not be saved.
virtual boost::format text(int textId)

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

Set texts to all widgets.

Definition at line 94 of file OSEdOptionsDialog.cc.

94 {
97
98 // title
100 SetTitle(WxConversion::toWxString(fmt.str()));
101
104
105 // buttons
106 WidgetTools::setLabel(&guiText, FindWindow(wxID_CANCEL),
108
111
114}
@ TXT_BUTTON_CANCEL
Label for cancel button.
static GUITextGenerator * instance()
@ TXT_BUTTON_SAVE
Save button label.
@ TXT_BUTTON_BROWSE
Browse button label.
@ TXT_OPTIONS_DIALOG_TITLE
Options dialog title.
@ TXT_LABEL_EDITOR
Editor label.
static void setLabel(Texts::TextGenerator *generator, wxWindow *widget, int textID)

References ID_BUTTON_BROWSE, ID_BUTTON_SAVE, ID_TEXT, GUITextGenerator::instance(), OSEdTextGenerator::instance(), WidgetTools::setLabel(), Texts::TextGenerator::text(), WxConversion::toWxString(), OSEdTextGenerator::TXT_BUTTON_BROWSE, GUITextGenerator::TXT_BUTTON_CANCEL, OSEdTextGenerator::TXT_BUTTON_SAVE, OSEdTextGenerator::TXT_LABEL_EDITOR, and OSEdTextGenerator::TXT_OPTIONS_DIALOG_TITLE.

Here is the call graph for this function:

◆ 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: