OpenASIP  2.0
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. More...
 
AddModuleDialogoperator= (const AddModuleDialog &)
 Assignment not allowed. More...
 
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. More...
 
wxString name_
 Name of the module. More...
 

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.

62  {
63  ID_TEXT,
65  };

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 }

◆ ~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 }

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 }

References name_, and WxConversion::toString().

Referenced by OSEdAddModuleCmd::Do().

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)) {
129  format fmt = texts.text(OSEdTextGenerator::TXT_ERROR_MOD_NAME);
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 }

References OSEdTextGenerator::instance(), NullOperationModule::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

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:
AddModuleDialog::name_
wxString name_
Name of the module.
Definition: AddModuleDialog.hh:70
OSEdTextGenerator::TXT_ERROR_MODULE_EXISTS
@ TXT_ERROR_MODULE_EXISTS
Module exists error.
Definition: OSEdTextGenerator.hh:151
AddModuleDialog::ID_MODULE_NAME
@ ID_MODULE_NAME
Definition: AddModuleDialog.hh:64
WxConversion::toWxString
static wxString toWxString(const std::string &source)
AddModuleDialog::ID_TEXT
@ ID_TEXT
Definition: AddModuleDialog.hh:63
OperationContainer::module
static OperationModule & module(const std::string &path, const std::string &mod)
Definition: OperationContainer.cc:148
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
DialogPosition::setPosition
static void setPosition(Dialogs dialog, wxPoint point)
Definition: DialogPosition.cc:63
AddModuleDialog::setTexts
void setTexts()
Definition: AddModuleDialog.cc:89
GUITextGenerator::TXT_BUTTON_CANCEL
@ TXT_BUTTON_CANCEL
Label for cancel button.
Definition: GUITextGenerator.hh:55
ErrorDialog
Definition: ErrorDialog.hh:42
AddModuleDialog::createContents
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
Definition: AddModuleDialog.cc:171
DialogPosition::DIALOG_ADD_MODULE
@ DIALOG_ADD_MODULE
Add module dialog.
Definition: DialogPosition.hh:54
AddModuleDialog::path_
std::string path_
Path in which module is added.
Definition: AddModuleDialog.hh:68
OSEdTextGenerator::TXT_LABEL_MODULE_NAME
@ TXT_LABEL_MODULE_NAME
Module name label.
Definition: OSEdTextGenerator.hh:53
OSEdTextGenerator::TXT_ADD_MODULE_DIALOG_TITLE
@ TXT_ADD_MODULE_DIALOG_TITLE
Add module dialog title.
Definition: OSEdTextGenerator.hh:112
OSEdTextGenerator::TXT_ERROR_NO_NAME
@ TXT_ERROR_NO_NAME
Error when no name is given.
Definition: OSEdTextGenerator.hh:132
OSEdTextGenerator::instance
static OSEdTextGenerator & instance()
Definition: OSEdTextGenerator.cc:214
OSEdTextGenerator
Definition: OSEdTextGenerator.hh:42
OSEdTextGenerator::TXT_ERROR_MOD_NAME
@ TXT_ERROR_MOD_NAME
Module name is erronous.
Definition: OSEdTextGenerator.hh:155
NullOperationModule::instance
static NullOperationModule & instance()
WxConversion::toString
static std::string toString(const wxString &source)
GUITextGenerator::TXT_BUTTON_OK
@ TXT_BUTTON_OK
Label for OK button.
Definition: GUITextGenerator.hh:59