STL-list for another Java list case.
This commit is contained in:
18
dw/image.cc
18
dw/image.cc
@ -33,41 +33,35 @@ using namespace lout;
|
||||
|
||||
ImageMapsList::ImageMap::ImageMap ()
|
||||
{
|
||||
shapesAndLinks = new container::typed::List <ShapeAndLink> (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 <ShapeAndLink> 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 <ShapeAndLink> 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;
|
||||
|
@ -33,7 +33,7 @@ private:
|
||||
~ShapeAndLink () { if (shape) delete shape; };
|
||||
};
|
||||
|
||||
lout::container::typed::List <ShapeAndLink> *shapesAndLinks;
|
||||
std::list< std::unique_ptr< ShapeAndLink > > shapesAndLinks;
|
||||
int defaultLink;
|
||||
public:
|
||||
ImageMap ();
|
||||
|
Reference in New Issue
Block a user