129 lines
3.6 KiB
C++
129 lines
3.6 KiB
C++
/***************************************************************************
|
|
* Copyright (C) 2008 by Oliver Groß *
|
|
* z.o.gross@gmx.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 CCROSSFIELDWIDGET_H
|
|
#define CCROSSFIELDWIDGET_H
|
|
|
|
#include <QWidget>
|
|
#include <QQueue>
|
|
|
|
#include <libqnono/nonogrammarker.h>
|
|
|
|
class QLCDNumber;
|
|
class QFrame;
|
|
class QLabel;
|
|
|
|
namespace libqnono {
|
|
class CNonogram;
|
|
class CNonogramSolver;
|
|
}
|
|
|
|
namespace qcross {
|
|
class CCrossFieldWidget : public QWidget {
|
|
Q_OBJECT
|
|
public:
|
|
enum MessageType {Information = 1, Warning = 2, Critical = 3, Invalid = 0};
|
|
|
|
CCrossFieldWidget(QWidget * parent = 0);
|
|
~CCrossFieldWidget();
|
|
|
|
libqnono::CNonogram * nonogram() { return m_Nonogram; }
|
|
|
|
void showMessage(const QString message = QString(), int timeout = 0, MessageType type = Information);
|
|
|
|
public slots:
|
|
void setNumbersMarkable(bool value);
|
|
|
|
protected slots:
|
|
/* signals from nonogram */
|
|
void loaded();
|
|
|
|
void won(int score);
|
|
void timeup();
|
|
|
|
void wrongMark(int x, int y, int penaltyTime);
|
|
void changedMark(int x, int y);
|
|
|
|
void restarted();
|
|
void paused(int time);
|
|
void resumed(int time);
|
|
void tick(int time);
|
|
|
|
protected:
|
|
struct Message {
|
|
MessageType type;
|
|
QString text;
|
|
int timeout;
|
|
|
|
Message() : type(Invalid), timeout(0) {}
|
|
};
|
|
|
|
QQueue<Message> m_Messages;
|
|
int m_MessageTimeoutId;
|
|
Message m_Message;
|
|
|
|
libqnono::CNonogram * m_Nonogram;
|
|
|
|
int m_BoxSize;
|
|
qreal m_MarkerSize;
|
|
qreal m_MarkerOffset;
|
|
int m_OffsetX;
|
|
int m_OffsetY;
|
|
int m_HeaderWidth;
|
|
int m_HeaderHeight;
|
|
int m_RasterWidth;
|
|
int m_RasterHeight;
|
|
|
|
libqnono::NonogramMarker::Mark m_MouseMark;
|
|
bool m_MouseDown;
|
|
int m_MouseLastX, m_MouseLastY;
|
|
|
|
bool m_NumbersMarkable;
|
|
|
|
QLCDNumber * m_Clock;
|
|
|
|
// QFrame * m_Notifier;
|
|
// QLabel * m_NotifierIcon;
|
|
// QLabel * m_NotifierText;
|
|
|
|
QPoint m_LastErrorMark;
|
|
|
|
void nextMessage();
|
|
|
|
void initialize(); /** update metrics for new problem */
|
|
|
|
void timerEvent(QTimerEvent * event);
|
|
void updateTimeDisplay();
|
|
|
|
void paintEvent(QPaintEvent * event);
|
|
|
|
/* void updateCell(int x, int y);
|
|
*/
|
|
void resizeEvent(QResizeEvent * event);
|
|
|
|
void updateMetrics(); /** update metrics after resize */
|
|
|
|
void mousePressEvent(QMouseEvent * event);
|
|
void mouseMoveEvent(QMouseEvent * event);
|
|
void mouseReleaseEvent(QMouseEvent * event);
|
|
};
|
|
}
|
|
|
|
#endif
|