/* * Implementation of plainscene.h. */ #include "plainscene.h" #include void PlainScene::Draw () { register PlainSceneElement* e; for (e = head; e != nil; e = e->next) { e->child->Draw(); } } void PlainScene::GetComponents (Interactor** c, int nc, Interactor**& a, int& n) { register PlainSceneElement* e; register Interactor** ap; n = nelements; a = (n <= nc) ? c : new Interactor*[n]; ap = a; for (e = head; e != nil; e = e->next) { *ap++ = e->child; } } void PlainScene::Resize() { PlainSceneElement* e; Shape* s; for (e = head; e != nil; e = e->next) { s = e->child->GetShape(); Place(e->child, e->x, e->y, e->x + s->width, e->y + s->height); } } void PlainScene::Reconfig() { PlainSceneElement* e; Shape* s; shape->height = 0; shape->width = 0; for (e = head; e != nil; e = e->next) { s = e->child->GetShape(); shape->height = max(shape->height, e->y + s->height); shape->width = max(shape->width, e->x + s->width); } } void PlainScene::DoInsert (Interactor* i, boolean, Coord &x, Coord &y) { PlainSceneElement* e = new PlainSceneElement; ++nelements; e->child = i; e->next = nil; if (head == nil) { head = e; tail = e; } else { tail->next = e; tail = e; } e->x = x; e->y = y; } void PlainScene::DoChange(Interactor* i) { Reconfig(); } void PlainScene::DoMove(Interactor* i, Coord& x, Coord& y) { PlainSceneElement* e; for (e = head; e != nil; e = e->next) { if (e->child == i) { e->x = x; e->y = y; Reconfig(); Change(); break; } } } void PlainScene::DoRemove(Interactor *i) { PlainSceneElement* e, * prev; prev = nil; for (e = head; e != nil; e = e->next) { if (e->child == i) { --nelements; if (prev == nil) { head = e->next; } else { prev->next = e->next; } if (e == tail) { tail = prev; } delete e; Reconfig(); Change(); break; } prev = e; } } void PlainScene::DoRaise(Interactor* i) { PlainSceneElement* e, * prev; prev = nil; for (e = head; e != nil; e = e->next) { if (e->child == i) { if (prev == nil) { head = e->next; } else { prev->next = e->next; } e->next = nil; tail->next = e; tail = e; break; } prev = e; } /* * Note: owing to the intricacies of InterViews, calls to Reconfig and * Change are not necessary here. This is due to the fact that * Scene::Raise has already physically raised the X window for the given * interactor. See X11-scene.c:Raise(). */ } void PlainScene::DoLower(Interactor* i) { PlainSceneElement* e, * prev; prev = nil; for (e = head; e != nil; e = e->next) { if (e->child == i) { if (prev == nil) { head = e->next; } else { prev->next = e->next; } e->next = head; head = e; break; } prev = e; } /* * Ditto note at end of DoRaise. */ }