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

#include <AddModuleDialog.hh>

Inheritance diagram for AddModuleDialog:
Inheritance graph
Collaboration diagram for AddModuleDialog:
Collaboration graph

Public Member Functions

 AddModuleDialog (wxWindow *parent, std::string path)
 
virtual ~AddModuleDialog ()
 
std::string name () const
 

Private Types

enum  { ID_TEXT , ID_MODULE_NAME }
 

Private Member Functions

 AddModuleDialog (const AddModuleDialog &)
 Copying not allowed.
 
AddModuleDialogoperator= (const AddModuleDialog &)
 Assignment not allowed.
 
wxSizer * createContents (wxWindow *parent, bool call_fit, bool set_sizer)
 
void onOk (wxCommandEvent &event)
 
void setTexts ()
 

Private Attributes

std::string path_
 Path in which module is added.
 
wxString name_
 Name of the module.
 

Detailed Description

Dialog for adding new modules.

Definition at line 42 of file AddModuleDialog.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

Widget ids.

Enumerator
ID_TEXT 
ID_MODULE_NAME 

Definition at line 62 of file AddModuleDialog.hh.

Constructor & Destructor Documentation

◆ AddModuleDialog() [1/2]

AddModuleDialog::AddModuleDialog ( wxWindow *  parent,
std::string  path 
)

Constructor.

@parent Parent window.

Definition at line 62 of file AddModuleDialog.cc.

62 :
63 wxDialog(parent, -1, _T(""),
65 path_(path), name_(_T("")){
66
67 createContents(this, true, true);
69 SetValidator(wxTextValidator(wxFILTER_ASCII, &name_));
70
71 FindWindow(wxID_OK)->SetFocus();
72 setTexts();
73}
wxString name_
Name of the module.
std::string path_
Path in which module is added.
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
static wxPoint getPosition(Dialogs dialog)
@ DIALOG_ADD_MODULE
Add module dialog.

◆ ~AddModuleDialog()

AddModuleDialog::~AddModuleDialog ( )
virtual

Destructor.

Definition at line 78 of file AddModuleDialog.cc.

78 {
79 int x, y;
80 GetPosition(&x, &y);
81 wxPoint point(x, y);
83}
static void setPosition(Dialogs dialog, wxPoint point)

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

Here is the call graph for this function:

◆ AddModuleDialog() [2/2]

AddModuleDialog::AddModuleDialog ( const AddModuleDialog )
private

Copying not allowed.

Member Function Documentation

◆ createContents()

wxSizer * AddModuleDialog::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 the contents of the dialog.
Returns
The created sizer.

Definition at line 171 of file AddModuleDialog.cc.

174 {
175
176 wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
177
178 wxBoxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
179
180 wxStaticText *item2 = new wxStaticText( parent, ID_TEXT, wxT("Name of the module:"), wxDefaultPosition, wxDefaultSize, 0 );
181 item1->Add( item2, 0, wxALIGN_CENTER|wxALL, 5 );
182
183 wxTextCtrl *item3 = new wxTextCtrl( parent, ID_MODULE_NAME, wxT(""), wxDefaultPosition, wxSize(80,-1), wxTE_PROCESS_ENTER );
184 item1->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );
185
186 item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
187
188 wxBoxSizer *item4 = new wxBoxSizer( wxHORIZONTAL );
189
190 wxButton *item5 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
191 item4->Add( item5, 0, wxALIGN_CENTER|wxALL, 5 );
192
193 wxButton *item6 = new wxButton( parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
194 item4->Add( item6, 0, wxALIGN_CENTER|wxALL, 5 );
195
196 item0->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
197
198 if (set_sizer)
199 {
200 parent->SetSizer( item0 );
201 if (call_fit)
202 item0->SetSizeHints( parent );
203 }
204
205 return item0;
206}

References ID_MODULE_NAME, and ID_TEXT.

◆ name()

string AddModuleDialog::name ( ) const

Returns the name of the added module.

Returns
The name of the added module.

Definition at line 158 of file AddModuleDialog.cc.

158 {
160}
static std::string toString(const wxString &source)

References name_, and WxConversion::toString().

Here is the call graph for this function:

◆ onOk()

void AddModuleDialog::onOk ( wxCommandEvent &  event)
private

Handles the event when OK button is pushed.

Definition at line 113 of file AddModuleDialog.cc.

113 {
114 TransferDataFromWindow();
116 if (name_ == _T("")) {
117 format fmt = texts.text(OSEdTextGenerator::TXT_ERROR_NO_NAME);
118 fmt % "operation module";
119 ErrorDialog dialog(this, WxConversion::toWxString(fmt.str()));
120 dialog.ShowModal();
121 return;
122 } else {
123 string modName = WxConversion::toString(name_);
124 // let's check that module name is legal
125 const char* regExp = "\\w+";
126 boost::regex expression(regExp);
127 boost::match_results<string::const_iterator> what;
128 if (!boost::regex_match(modName, what, expression)) {
130 fmt % modName;
131 ErrorDialog dialog(this, WxConversion::toWxString(fmt.str()));
132 dialog.ShowModal();
133 return;
134 }
135
136 // let's check there is not already a module by that name
137 if (&OperationContainer::module(path_, modName) !=
139
140 format fmt =
142 fmt % modName;
143 string msg = fmt.str();
144 ErrorDialog error(this, WxConversion::toWxString(msg));
145 error.ShowModal();
146 } else {
147 EndModal(wxID_OK);
148 }
149 }
150}
static NullOperationModule & instance()
static OSEdTextGenerator & instance()
@ TXT_ERROR_MODULE_EXISTS
Module exists error.
@ TXT_ERROR_NO_NAME
Error when no name is given.
@ TXT_ERROR_MOD_NAME
Module name is erronous.
static OperationModule & module(const std::string &path, const std::string &mod)
virtual boost::format text(int textId)
static wxString toWxString(const std::string &source)

References NullOperationModule::instance(), OSEdTextGenerator::instance(), OperationContainer::module(), name_, path_, Texts::TextGenerator::text(), WxConversion::toString(), WxConversion::toWxString(), OSEdTextGenerator::TXT_ERROR_MOD_NAME, OSEdTextGenerator::TXT_ERROR_MODULE_EXISTS, and OSEdTextGenerator::TXT_ERROR_NO_NAME.

Here is the call graph for this function:

◆ operator=()

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

Assignment not allowed.

◆ setTexts()

void AddModuleDialog::setTexts ( )
private

Set texts to widgets.

Definition at line 89 of file AddModuleDialog.cc.

89 {
90
93
94 //title
96 SetTitle(WxConversion::toWxString(fmt.str()));
97
100
101 // buttons
102 WidgetTools::setLabel(&guiText, FindWindow(wxID_OK),
104
105 WidgetTools::setLabel(&guiText, FindWindow(wxID_CANCEL),
107}
@ TXT_BUTTON_CANCEL
Label for cancel button.
@ TXT_BUTTON_OK
Label for OK button.
static GUITextGenerator * instance()
@ TXT_LABEL_MODULE_NAME
Module name label.
@ TXT_ADD_MODULE_DIALOG_TITLE
Add module dialog title.
static void setLabel(Texts::TextGenerator *generator, wxWindow *widget, int textID)

References ID_TEXT, GUITextGenerator::instance(), OSEdTextGenerator::instance(), WidgetTools::setLabel(), Texts::TextGenerator::text(), WxConversion::toWxString(), OSEdTextGenerator::TXT_ADD_MODULE_DIALOG_TITLE, GUITextGenerator::TXT_BUTTON_CANCEL, GUITextGenerator::TXT_BUTTON_OK, and OSEdTextGenerator::TXT_LABEL_MODULE_NAME.

Here is the call graph for this function:

Member Data Documentation

◆ name_

wxString AddModuleDialog::name_
private

Name of the module.

Definition at line 70 of file AddModuleDialog.hh.

Referenced by name(), and onOk().

◆ path_

std::string AddModuleDialog::path_
private

Path in which module is added.

Definition at line 68 of file AddModuleDialog.hh.

Referenced by onOk().


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