diff --git a/dw/image.cc b/dw/image.cc index d365ded..1fcdbb3 100644 --- a/dw/image.cc +++ b/dw/image.cc @@ -33,41 +33,35 @@ using namespace lout; ImageMapsList::ImageMap::ImageMap () { - shapesAndLinks = new container::typed::List (true); defaultLink = -1; } ImageMapsList::ImageMap::~ImageMap () { - delete shapesAndLinks; } void ImageMapsList::ImageMap::draw (core::View *view,core::style::Style *style, int x, int y) { - container::typed::Iterator it; - - for (it = shapesAndLinks->iterator (); it.hasNext (); ) { - ShapeAndLink *shapeAndLink = it.getNext (); - + for( auto &shapeAndLink: shapesAndLinks ) + { shapeAndLink->shape->draw(view, style, x, y); } } void ImageMapsList::ImageMap::add (core::Shape *shape, int link) { - ShapeAndLink *shapeAndLink = new ShapeAndLink (); + auto shapeAndLink = std::make_unique< ShapeAndLink >(); shapeAndLink->shape = shape; shapeAndLink->link = link; - shapesAndLinks->append (shapeAndLink); + shapesAndLinks.push_back( std::move( shapeAndLink ) ); } int ImageMapsList::ImageMap::link (int x, int y) { container::typed::Iterator it; int link = defaultLink; - for (it = shapesAndLinks->iterator (); it.hasNext (); ) { - ShapeAndLink *shapeAndLink = it.getNext (); - + for ( auto &shapeAndLink: shapesAndLinks ) + { if (shapeAndLink->shape->isPointWithin (x, y)) { link = shapeAndLink->link; break; diff --git a/dw/image.hh b/dw/image.hh index 2d4868f..d85918d 100644 --- a/dw/image.hh +++ b/dw/image.hh @@ -33,7 +33,7 @@ private: ~ShapeAndLink () { if (shape) delete shape; }; }; - lout::container::typed::List *shapesAndLinks; + std::list< std::unique_ptr< ShapeAndLink > > shapesAndLinks; int defaultLink; public: ImageMap ();