qcross/libqnono/nonogrammarker.h

61 lines
2.5 KiB
C
Raw Normal View History

/***************************************************************************
* Copyright (C) 2012 Stefan Bühler <stbuehler@web.de> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef LIBQNONO_NONOGRAMMARKER_H
#define LIBQNONO_NONOGRAMMARKER_H
#include <QSize>
namespace libqnono {
2012-04-20 13:00:02 +00:00
class NonogramImage;
class NonogramMarker {
public:
enum Mark { NONE = 0, MARKED = 1, CROSSED = 2 };
NonogramMarker();
NonogramMarker(QSize size);
NonogramMarker(const NonogramMarker& other);
~NonogramMarker();
NonogramMarker& operator=(const NonogramMarker& other);
bool operator==(const NonogramMarker& other) const;
Mark pixel(int x, int y) const { return m_data[y*m_size.width()+x]; }
Mark & pixel(int x, int y) { return m_data[y*m_size.width()+x]; }
void setPixel(int x, int y, Mark value) { m_data[y*m_size.width()+x] = value; }
QSize size() const { return m_size; }
2012-04-20 13:00:02 +00:00
int width() const { return m_size.width(); }
int height() const { return m_size.height(); }
bool readFromStream(QDataStream & stream);
void writeToStream(QDataStream & stream) const;
private:
2012-04-20 13:00:02 +00:00
friend class NonogramImage;
QSize m_size;
Mark *m_data;
};
QDataStream & operator<<(QDataStream & stream, const NonogramMarker & marker);
QDataStream & operator>>(QDataStream & stream, NonogramMarker & marker);
}
#endif // LIBQNONO_NONOGRAMMARKER_H