/* * TextDialog.cpp * * Created on: Jan 5, 2010 * Author: crueger */ #include #include "UIElements/TextDialog.hpp" #include "atom.hpp" #include "molecule.hpp" #include "log.hpp" #include "verbose.hpp" using namespace std; TextDialog::TextDialog() { } TextDialog::~TextDialog() { } void TextDialog::queryInt(const char* title, int* target){ registerQuery(new IntTextQuery(title,target)); } void TextDialog::queryString(const char* title, string* target){ registerQuery(new StringTextQuery(title,target)); } void TextDialog::queryMolecule(const char* title, molecule **target, MoleculeListClass *molecules) { registerQuery(new MoleculeTextQuery(title,target,molecules)); } /************************** Query Infrastructure ************************/ TextDialog::IntTextQuery::IntTextQuery(string title,int *_target) : Dialog::IntQuery(title,_target) {} TextDialog::IntTextQuery::~IntTextQuery() {} bool TextDialog::IntTextQuery::handle() { Log() << Verbose(0) << getTitle(); cin >> tmp; return true; } TextDialog::StringTextQuery::StringTextQuery(string title,string *_target) : Dialog::StringQuery(title,_target) {} TextDialog::StringTextQuery::~StringTextQuery() {} bool TextDialog::StringTextQuery::handle() { Log() << Verbose(0) << getTitle(); cin >> tmp; return true; } TextDialog::MoleculeTextQuery::MoleculeTextQuery(string title, molecule **_target, MoleculeListClass *_molecules) : Dialog::MoleculeQuery(title,_target,_molecules) {} TextDialog::MoleculeTextQuery::~MoleculeTextQuery() {} bool TextDialog::MoleculeTextQuery::handle() { int idxOfMol; Log() << Verbose(0) << getTitle(); cin >> idxOfMol; tmp = molecules->ReturnIndex(idxOfMol); while(!tmp && (idxOfMol !=-1)) { Log() << Verbose(0) << "Invalid Molecule Index" << endl; Log() << Verbose(0) << getTitle(); cin >> idxOfMol; tmp = molecules->ReturnIndex(idxOfMol); } return (idxOfMol!=-1); }