virtual void actionPerformed(const ActionEventUnrecPtr e) { std::vector<std::string> inputValues; inputValues.push_back("0"); DialogWindowRefPtr TheDialog; TheDialog = DialogWindow::createInputDialog("Move selected index to", "Please enter the index to move to", DialogWindow::INPUT_TEXT,true,inputValues); TheDialog->setAllwaysOnTop(true); TheDialog->addDialogWindowListener(this); Pnt2f CenteredPosition = calculateAlignment(dynamic_cast<Component*>(e->getSource())->getParentWindow()->getPosition(), dynamic_cast<Component*>(e->getSource())->getParentWindow()->getSize(), TheDialog->getPreferredSize(), 0.5f, 0.5f); TheDialog->setPosition(CenteredPosition); dynamic_cast<Component*>(e->getSource())->getParentWindow()->getDrawingSurface()->openWindow(TheDialog); }
void FCPtrFieldEditor::openCreateHandler(void) { const FieldContainerType* ThePtrType(getFieldContainerTypeFromPtrType(getEditingFC()->getFieldDescription(getEditingFieldId())->getFieldType().getContentType())); if(ThePtrType == NULL) { return; } //If the type is a node, then create a NodeCore instead //and then insert it as the core of a newly created node if(*ThePtrType == Node::getClassType()) { ThePtrType = &NodeCore::getClassType(); } std::vector<std::string> inputValues; UInt32 NumFieldContainersFound(0); const FieldContainerType* FoundType(NULL); for(UInt32 j(0) ; NumFieldContainersFound<FieldContainerFactory::the()->getNumTypes(); ++j) { FoundType = FieldContainerFactory::the()->findType(j); if(FoundType != NULL) { if(FoundType->isDerivedFrom(*ThePtrType) && !FoundType->isAbstract()) { inputValues.push_back(FoundType->getName()); } ++NumFieldContainersFound; } } DialogWindowRefPtr TheDialog = DialogWindow::createInputDialog("Create Field Container", "Choose the type of object to create", DialogWindow::INPUT_COMBO, true, inputValues); _CreateContainerDialogClosedConnection = TheDialog->connectDialogWindowClosed(boost::bind(&FCPtrFieldEditor::handleCreateContainerDialogClosed, this, _1)); Pnt2f CenteredPosition = calculateAlignment(Pnt2f(0.0f,0.0f), getParentWindow()->getParentDrawingSurface()->getSize(), TheDialog->getPreferredSize(), 0.5f, 0.5f); TheDialog->setPosition(CenteredPosition); TheDialog->setAllwaysOnTop(true); TheDialog->setModal(true); TheDialog->setResizable(true); getParentWindow()->getParentDrawingSurface()->openWindow(TheDialog); }
void FCPtrFieldEditor::openFindContainerHandler(void) { const FieldContainerType* ThePtrType(getFieldContainerTypeFromPtrType(getEditingFC()->getFieldDescription(getEditingFieldId())->getFieldType().getContentType())); if(ThePtrType == NULL) { return; } std::vector<std::string> inputValues; _FindFCStore->setTypeToStore(ThePtrType); FCPtrEditorStore::FieldContianerVector fcStore(_FindFCStore->getList()); std::string value; for(UInt32 i(0) ; i<fcStore.size(); ++i) { value.clear(); if(fcStore[i]->getType().isDerivedFrom(AttachmentContainer::getClassType()) && getName(dynamic_pointer_cast<AttachmentContainer>(fcStore[i]))) { value += std::string(getName(dynamic_pointer_cast<AttachmentContainer>(fcStore[i]))) + " "; } value += "[" + fcStore[i]->getType().getName() + "] " + boost::lexical_cast<std::string>(fcStore[i]->getId()); inputValues.push_back(value); } DialogWindowRefPtr TheDialog = DialogWindow::createInputDialog("Find Field Container", "Choose the container to use", DialogWindow::INPUT_LIST, true, inputValues); _FindContainerDialogClosedConnection = TheDialog->connectDialogWindowClosed(boost::bind(&FCPtrFieldEditor::handleFindContainerDialogClosed, this, _1)); Pnt2f CenteredPosition = calculateAlignment(Pnt2f(0.0f,0.0f), getParentWindow()->getParentDrawingSurface()->getSize(), TheDialog->getPreferredSize(), 0.5f, 0.5f); TheDialog->setPosition(CenteredPosition); TheDialog->setAllwaysOnTop(true); TheDialog->setResizable(true); getParentWindow()->getParentDrawingSurface()->openWindow(TheDialog); }
void GenericMultiFieldEditor::insertAtIndex(FieldContainer* const fc, UInt32 fieldID, UInt32 index, UIDrawingSurface* const drawingSurface, CommandManager* cmdMgr) { //Is this a pointer field GetFieldHandlePtr TheFieldHandle(fc->getField(fieldID)); if(TheFieldHandle->isPointerField()) { //Create const FieldContainerType* ThePtrType(getFieldContainerTypeFromPtrType(fc->getFieldDescription(fieldID)->getFieldType().getContentType())); if(ThePtrType == NULL) { return; } //If the type is a node, then create a NodeCore instead //and then insert it as the core of a newly created node if(*ThePtrType == Node::getClassType()) { ThePtrType = &NodeCore::getClassType(); } std::vector<std::string> inputValues; UInt32 NumFieldContainersFound(0); const FieldContainerType* FoundType(NULL); for(UInt32 j(0) ; NumFieldContainersFound<FieldContainerFactory::the()->getNumTypes(); ++j) { FoundType = FieldContainerFactory::the()->findType(j); if(FoundType != NULL) { if(FoundType->isDerivedFrom(*ThePtrType) && !FoundType->isAbstract()) { inputValues.push_back(FoundType->getName()); } ++NumFieldContainersFound; } } if(inputValues.size() == 1) { insertAtIndex(fc,fieldID,index,FieldContainerFactory::the()->findType(inputValues[0].c_str()),cmdMgr); } else { DialogWindowRefPtr TheDialog = DialogWindow::createInputDialog("Create " + fc->getFieldDescription(fieldID)->getFieldType().getContentType().getName(), "Choose the type of object to create", DialogWindow::INPUT_COMBO, true, inputValues); TheDialog->connectDialogWindowClosed(boost::bind(&GenericMultiFieldEditor::handleInsertFCPtrDialogClosed, _1, fc, fieldID, index, cmdMgr)); Pnt2f CenteredPosition = calculateAlignment(Pnt2f(0.0f,0.0f), drawingSurface->getSize(), TheDialog->getPreferredSize(), 0.5f, 0.5f); TheDialog->setPosition(CenteredPosition); TheDialog->setAllwaysOnTop(true); TheDialog->setModal(true); TheDialog->setResizable(true); drawingSurface->openWindow(TheDialog); } } else { //Insert the default InsertFieldElementCommandPtr InsertIndexCommand = InsertFieldElementCommand::create(fc, fieldID, "", index); cmdMgr->executeCommand(InsertIndexCommand); } }