EffectEditor::EffectEditor(wxWindow* parent, StimResponse& response, const unsigned int effectIndex, StimTypes& stimTypes, ui::ResponseEditor& editor) : DialogBase(_(WINDOW_TITLE), parent), _argTable(NULL), _response(response), _effectIndex(effectIndex), _backup(_response.getResponseEffect(_effectIndex)), _editor(editor), _stimTypes(stimTypes) { SetSizer(new wxBoxSizer(wxVERTICAL)); // Create the widgets populateWindow(); // Search the scenegraph for entities populateEntityListStore(); // Initialise the widgets with the current data ResponseEffect& effect = _response.getResponseEffect(_effectIndex); // Setup the selectionfinder to search for the name string wxutil::ChoiceHelper::SelectItemByStoredString(_effectTypeCombo, effect.getName()); _stateToggle->SetValue(effect.isActive()); // Parse the argument types from the effect and create the widgets createArgumentWidgets(effect); Layout(); Fit(); }
void EffectEditor::effectTypeChanged() { std::string newEffectName(""); // Get the currently selected effect name from the combo box if (_effectTypeCombo->GetSelection() != wxNOT_FOUND) { wxStringClientData* data = dynamic_cast<wxStringClientData*>( _effectTypeCombo->GetClientObject(_effectTypeCombo->GetSelection())); assert(data != NULL); newEffectName = data->GetData().ToStdString(); } // Get the effect ResponseEffect& effect = _response.getResponseEffect(_effectIndex); // Set the name of the effect and trigger an argument list update effect.setName(newEffectName); effect.clearArgumentList(); effect.buildArgumentList(); // Rebuild the argument list basing on this new effect createArgumentWidgets(effect); }
void CommandEditor::commandTypeChanged() { int newCommandTypeID = -1; wxChoice* cmdDropDown = findNamedObject<wxChoice>(this, "ConvCmdEditorCommandChoice"); int selectedItem = cmdDropDown->GetSelection(); wxStringClientData* cmdIdStr = static_cast<wxStringClientData*>(cmdDropDown->GetClientObject(selectedItem)); newCommandTypeID = string::convert<int>(cmdIdStr->GetData().ToStdString(), -1); // Create the argument widgets for this new command type createArgumentWidgets(newCommandTypeID); // Update the sensitivity of the correct flag upateWaitUntilFinished(newCommandTypeID); }
void EffectEditor::effectTypeChanged() { std::string newEffectName(""); // Get the currently selected effect name from the combo box Gtk::TreeModel::iterator iter = _effectTypeCombo->get_active(); if (iter) { newEffectName = Glib::ustring((*iter)[_effectColumns.name]); } // Get the effect ResponseEffect& effect = _response.getResponseEffect(_effectIndex); // Set the name of the effect and trigger an argument list update effect.setName(newEffectName); effect.clearArgumentList(); effect.buildArgumentList(); // Rebuild the argument list basing on this new effect createArgumentWidgets(effect); }
void CommandEditor::updateWidgets() { // Select the actor passed from the command wxutil::ChoiceHelper::SelectItemByStoredId( findNamedObject<wxChoice>(this, "ConvCmdEditorActorChoice"), _command.actor); // Select the command type wxutil::ChoiceHelper::SelectItemByStoredId( findNamedObject<wxChoice>(this, "ConvCmdEditorCommandChoice"), _command.type); // Populate the correct command argument widgets createArgumentWidgets(_command.type); // Pre-fill the values for (conversation::ConversationCommand::ArgumentMap::const_iterator i = _command.arguments.begin(); i != _command.arguments.end(); ++i) { int argIndex = i->first; if (argIndex > static_cast<int>(_argumentItems.size()) || argIndex < 0) { // Invalid command argument index rError() << "Invalid command argument index " << argIndex << std::endl; continue; } // Load the value into the argument item _argumentItems[argIndex - 1]->setValueFromString(i->second); } // Update the "wait until finished" flag findNamedObject<wxCheckBox>(this, "ConvCmdEditorWaitUntilFinished")->SetValue(_command.waitUntilFinished); // Update the sensitivity of the correct flag upateWaitUntilFinished(_command.type); }
EffectEditor::EffectEditor(const Glib::RefPtr<Gtk::Window>& parent, StimResponse& response, const unsigned int effectIndex, StimTypes& stimTypes, ui::ResponseEditor& editor) : gtkutil::BlockingTransientWindow(_(WINDOW_TITLE), parent), _argTable(NULL), _effectStore(Gtk::ListStore::create(_effectColumns)), _entityStore(Gtk::ListStore::create(_entityColumns)), _response(response), _effectIndex(effectIndex), _backup(_response.getResponseEffect(_effectIndex)), _editor(editor), _stimTypes(stimTypes) { set_border_width(12); set_type_hint(Gdk::WINDOW_TYPE_HINT_DIALOG); // Retrieve the map from the ResponseEffectTypes object ResponseEffectTypeMap& effectTypes = ResponseEffectTypes::Instance().getMap(); // Now populate the list store with all the possible effect types for (ResponseEffectTypeMap::iterator i = effectTypes.begin(); i != effectTypes.end(); ++i) { Gtk::TreeModel::Row row = *_effectStore->append(); row[_effectColumns.name] = i->first; row[_effectColumns.caption] = i->second->getAttribute("editor_caption").getValue(); } // Create the widgets populateWindow(); // Search the scenegraph for entities populateEntityListStore(); // Initialise the widgets with the current data ResponseEffect& effect = _response.getResponseEffect(_effectIndex); // Setup the selectionfinder to search for the name string gtkutil::TreeModel::SelectionFinder finder(effect.getName(), _effectColumns.name.index()); _effectStore->foreach_iter( sigc::mem_fun(finder, >kutil::TreeModel::SelectionFinder::forEach)); // Set the active row of the combo box to the current response effect type _effectTypeCombo->set_active(finder.getIter()); _stateToggle->set_active(effect.isActive()); // Create the alignment container that hold the (exchangable) widget table _argAlignment = Gtk::manage(new Gtk::Alignment(0.0f, 0.5f, 1.0f, 1.0f)); _argAlignment->set_padding(0, 0, 18, 0); _dialogVBox->pack_start(*_argAlignment, false, false, 3); // Parse the argument types from the effect and create the widgets createArgumentWidgets(effect); // Connect the signal to get notified of further changes _effectTypeCombo->signal_changed().connect(sigc::mem_fun(*this, &EffectEditor::onEffectTypeChange)); show(); }