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 ()
|
ImageMapsList::ImageMap::ImageMap ()
|
||||||
{
|
{
|
||||||
shapesAndLinks = new container::typed::List <ShapeAndLink> (true);
|
|
||||||
defaultLink = -1;
|
defaultLink = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageMapsList::ImageMap::~ImageMap ()
|
ImageMapsList::ImageMap::~ImageMap ()
|
||||||
{
|
{
|
||||||
delete shapesAndLinks;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageMapsList::ImageMap::draw (core::View *view,core::style::Style *style,
|
void ImageMapsList::ImageMap::draw (core::View *view,core::style::Style *style,
|
||||||
int x, int y)
|
int x, int y)
|
||||||
{
|
{
|
||||||
container::typed::Iterator <ShapeAndLink> it;
|
for( auto &shapeAndLink: shapesAndLinks )
|
||||||
|
{
|
||||||
for (it = shapesAndLinks->iterator (); it.hasNext (); ) {
|
|
||||||
ShapeAndLink *shapeAndLink = it.getNext ();
|
|
||||||
|
|
||||||
shapeAndLink->shape->draw(view, style, x, y);
|
shapeAndLink->shape->draw(view, style, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageMapsList::ImageMap::add (core::Shape *shape, int link) {
|
void ImageMapsList::ImageMap::add (core::Shape *shape, int link) {
|
||||||
ShapeAndLink *shapeAndLink = new ShapeAndLink ();
|
auto shapeAndLink = std::make_unique< ShapeAndLink >();
|
||||||
shapeAndLink->shape = shape;
|
shapeAndLink->shape = shape;
|
||||||
shapeAndLink->link = link;
|
shapeAndLink->link = link;
|
||||||
shapesAndLinks->append (shapeAndLink);
|
shapesAndLinks.push_back( std::move( shapeAndLink ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
int ImageMapsList::ImageMap::link (int x, int y) {
|
int ImageMapsList::ImageMap::link (int x, int y) {
|
||||||
container::typed::Iterator <ShapeAndLink> it;
|
container::typed::Iterator <ShapeAndLink> it;
|
||||||
int link = defaultLink;
|
int link = defaultLink;
|
||||||
|
|
||||||
for (it = shapesAndLinks->iterator (); it.hasNext (); ) {
|
for ( auto &shapeAndLink: shapesAndLinks )
|
||||||
ShapeAndLink *shapeAndLink = it.getNext ();
|
{
|
||||||
|
|
||||||
if (shapeAndLink->shape->isPointWithin (x, y)) {
|
if (shapeAndLink->shape->isPointWithin (x, y)) {
|
||||||
link = shapeAndLink->link;
|
link = shapeAndLink->link;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -33,7 +33,7 @@ private:
|
|||||||
~ShapeAndLink () { if (shape) delete shape; };
|
~ShapeAndLink () { if (shape) delete shape; };
|
||||||
};
|
};
|
||||||
|
|
||||||
lout::container::typed::List <ShapeAndLink> *shapesAndLinks;
|
std::list< std::unique_ptr< ShapeAndLink > > shapesAndLinks;
|
||||||
int defaultLink;
|
int defaultLink;
|
||||||
public:
|
public:
|
||||||
ImageMap ();
|
ImageMap ();
|
||||||
|
|||||||
Reference in New Issue
Block a user