Container::Container(Vector p1, Object * p/*= NULL*/): Object(p1, p),
+ isTopLevelContainer(false),
dragging(false), draggingHandle1(false), draggingHandle2(false)//, needUpdate(false)
{
type = OTContainer;
*/
+// Need to add checking here for clicking on a member of a group (Container),
+// and checking for if it's a top level container (the DrawingView's document).
+/*
+One approach is to check for the parent of the container: If it's NULL, then it's
+the DrawingView's document. It might be better, though, to set a boolean like
+isTopLevelContainer so that we can do things like edit members of a group without
+having to ungroup them first (like Inkscape).
+*/
/*virtual*/ bool Container::Collided(Vector point)
{
objectWasDragged = false;
}
}
- // Do we decouple the state of the generic container from the objects inside??? Mebbe.
- state = OSInactive;
+ // We check to see if the container we're trying to access is the
+ // DrawingView's document. If so, we ignore the state of the container.
+ // Otherwise, we care about the state of the container. :-)
+ if (isTopLevelContainer)
+ state = OSInactive;
+ else
+ {
+ state = (collision ? OSSelected : OSInactive);
+
+ if (state == OSSelected)
+ DeselectAll();
+ }
+
return collision;
}
// objectWasDragged = true;
//printf("CONTAINER: PointerMoved()\n");
- for(int i=0; i<(int)objects.size(); i++)
+ for(std::vector<Object *>::iterator i=objects.begin(); i!=objects.end(); i++)
+// for(int i=0; i<(int)objects.size(); i++)
{
-// if (objects[i]->GetState() == OSSelected)
- objects[i]->PointerMoved(point);
+//// if (objects[i]->GetState() == OSSelected)
+// objects[i]->PointerMoved(point);
+ (*i)->PointerMoved(point);
}
// Generic container doesn't need this???
/*virtual*/ bool Container::NeedsUpdate(void)
{
- needUpdate = false;
-
- for(uint i=0; i<objects.size(); i++)
+ // Search through objects for one that needs an update; if one is found,
+ // return immediately.
+ for(std::vector<Object *>::iterator i=objects.begin(); i!=objects.end(); i++)
{
- if (objects[i]->NeedsUpdate())
- needUpdate = true;
+ if ((*i)->NeedsUpdate())
+ return true;
}
- return needUpdate;
+ return false;
}
}
-#if 0
-/*virtual*/ ObjectType Container::Type(void)
-{
- return OTContainer;
-}
-#endif
-
-
void Container::Delete(Object * objectToDelete)
{
std::vector<Object *>::iterator i = objects.begin();
void Container::Clear(void)
{
-#if 0
- // No memory leaks!
- while (objects.size() > 0)
- {
-printf("Container: Deleting object ($%X)...\n", objects[0]);
- delete objects[0];
- objects.erase(objects.begin());
- }
-#else
std::vector<Object *>::iterator i = objects.begin();
while (i != objects.end())
delete (*i);
objects.erase(i);
}
-#endif
}