1:/* 2: * Programmins graphical user interfaces 3: * Example: Diagram.cpp 4: * Jarkko Leponiemi 2003 5: */ 6: 7:#include "Diagram.h" 8: 9:Node::Node(string title, int x, int y) 10:{ 11: this->title = title; 12: this->x = x; 13: this->y = y; 14:} 15: 16:Node::Node(const Node ©) 17:{ 18: this->title = copy.title; 19: this->x = copy.x; 20: this->y = copy.y; 21:} 22: 23:const Node& Node::operator=(const Node ©) 24:{ 25: this->title = copy.title; 26: this->x = copy.x; 27: this->y = copy.y; 28: return copy; 29:} 30: 31:void Node::Move(int x, int y) 32:{ 33: this->x = x; 34: this->y = y; 35:} 36: 37:Connector::Connector(Node *n1, Node *n2) 38:{ 39: this->n1 = n1; 40: this->n2 = n2; 41:} 42: 43:Connector::Connector(const Connector ©) 44:{ 45: this->n1 = copy.n1; 46: this->n2 = copy.n2; 47:} 48: 49:const Connector& Connector::operator=(const Connector ©) 50:{ 51: this->n1 = copy.n1; 52: this->n2 = copy.n2; 53: return copy; 54:} 55: 56:Node* Diagram::CreateNode(string title, int x, int y) 57:{ 58: Node *n = new Node(title, x, y); 59: nodes.insert(nodes.begin(), n); 60: this->NotifyObservers(NODETYPE, n); 61: return n; 62:} 63: 64:Connector* Diagram::CreateConnector(Node *n1, Node *n2) 65:{ 66: Connector *conn = new Connector(n1, n2); 67: connectors.insert(connectors.end(), conn); 68: this->NotifyObservers(CONNECTORTYPE, conn); 69: return conn; 70:} 71: 72:void Diagram::MoveNode(Node *n, int x, int y) 73:{ 74: n->Move(x, y); 75: this->NotifyObservers(NODETYPE, n); 76:}