summaryrefslogtreecommitdiffstats
path: root/ksokoban/PlayField.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:42:31 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:42:31 +0000
commit576eb4299a00bc053db35414406f46372a0f70f2 (patch)
tree4c030922d533821db464af566188e7d40cc8848c /ksokoban/PlayField.cpp
parent0718336b6017d1a4fc1d626544180a5a2a29ddec (diff)
downloadtdegames-576eb4299a00bc053db35414406f46372a0f70f2.tar.gz
tdegames-576eb4299a00bc053db35414406f46372a0f70f2.zip
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1157643 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'ksokoban/PlayField.cpp')
-rw-r--r--ksokoban/PlayField.cpp114
1 files changed, 57 insertions, 57 deletions
diff --git a/ksokoban/PlayField.cpp b/ksokoban/PlayField.cpp
index 4d98d309..f277192e 100644
--- a/ksokoban/PlayField.cpp
+++ b/ksokoban/PlayField.cpp
@@ -20,13 +20,13 @@
#include <stdio.h>
#include <assert.h>
-#include <qwidget.h>
-#include <qpixmap.h>
-#include <qkeycode.h>
+#include <tqwidget.h>
+#include <tqpixmap.h>
+#include <tqkeycode.h>
#include <kconfig.h>
#include <kapplication.h>
#include <klocale.h>
-#include <qpainter.h>
+#include <tqpainter.h>
#include <kmessagebox.h>
#include <kglobalsettings.h>
@@ -45,16 +45,16 @@
#include "PlayField.moc"
-PlayField::PlayField(QWidget *parent, const char *name, WFlags f)
- : QWidget(parent, name, f|WResizeNoErase), imageData_(0), lastLevel_(-1),
+PlayField::PlayField(TQWidget *parent, const char *name, WFlags f)
+ : TQWidget(parent, name, f|WResizeNoErase), imageData_(0), lastLevel_(-1),
moveSequence_(0), moveInProgress_(false), dragInProgress_(false),
xOffs_(0), yOffs_(0),
wheelDelta_(0),
levelText_(i18n("Level:")), stepsText_(i18n("Steps:")),
pushesText_(i18n("Pushes:")),
- statusFont_(KGlobalSettings::generalFont().family(), 18, QFont::Bold), statusMetrics_(statusFont_) {
+ statusFont_(KGlobalSettings::generalFont().family(), 18, TQFont::Bold), statusMetrics_(statusFont_) {
- setFocusPolicy(QWidget::StrongFocus);
+ setFocusPolicy(TQWidget::StrongFocus);
setFocus();
setBackgroundMode(Qt::NoBackground);
setMouseTracking(true);
@@ -72,7 +72,7 @@ PlayField::PlayField(QWidget *parent, const char *name, WFlags f)
history_ = new History;
background_.setPixmap(imageData_->background());
- floor_ = QColor(0x66,0x66,0x66);
+ floor_ = TQColor(0x66,0x66,0x66);
levelMap_ = new LevelMap;
mapDelta_ = new MapDelta(levelMap_);
@@ -93,7 +93,7 @@ PlayField::~PlayField() {
}
void
-PlayField::changeCursor(const QCursor* c) {
+PlayField::changeCursor(const TQCursor* c) {
if (cursor_ == c) return;
cursor_ = c;
@@ -107,9 +107,9 @@ PlayField::level() const {
return levelMap_->level();
}
-const QString &
+const TQString &
PlayField::collectionName() {
- static QString error = "????";
+ static TQString error = "????";
if (levelMap_ == 0) return error;
return levelMap_->collectionName();
}
@@ -140,7 +140,7 @@ PlayField::levelChange() {
}
void
-PlayField::paintSquare(int x, int y, QPainter &paint) {
+PlayField::paintSquare(int x, int y, TQPainter &paint) {
if (levelMap_->xpos() == x && levelMap_->ypos() == y) {
if (levelMap_->goal(x, y))
imageData_->saveman(paint, x2pixel(x), y2pixel(y));
@@ -185,7 +185,7 @@ PlayField::paintSquare(int x, int y, QPainter &paint) {
void
PlayField::paintDelta() {
- QPainter paint(this);
+ TQPainter paint(this);
// the following line is a workaround for a bug in Qt 2.0.1
// (and possibly earlier versions)
@@ -201,8 +201,8 @@ PlayField::paintDelta() {
void
-PlayField::paintEvent(QPaintEvent *e) {
- QPainter paint(this);
+PlayField::paintEvent(TQPaintEvent *e) {
+ TQPainter paint(this);
// the following line is a workaround for a bug in Qt 2.0.1
// (and possibly earlier versions)
@@ -215,8 +215,8 @@ PlayField::paintEvent(QPaintEvent *e) {
}
void
-PlayField::paintPainterClip(QPainter &paint, int x, int y, int w, int h) {
- QRect rect(x, y, w, h);
+PlayField::paintPainterClip(TQPainter &paint, int x, int y, int w, int h) {
+ TQRect rect(x, y, w, h);
paint.setClipRect(rect);
paint.setClipping(true);
@@ -224,7 +224,7 @@ PlayField::paintPainterClip(QPainter &paint, int x, int y, int w, int h) {
}
void
-PlayField::paintPainter(QPainter &paint, const QRect &rect) {
+PlayField::paintPainter(TQPainter &paint, const TQRect &rect) {
if (size_ <= 0) return;
int minx = pixel2x(rect.x());
int miny = pixel2y(rect.y());
@@ -272,12 +272,12 @@ PlayField::paintPainter(QPainter &paint, const QRect &rect) {
}
void
-PlayField::resizeEvent(QResizeEvent *e) {
+PlayField::resizeEvent(TQResizeEvent *e) {
setSize(e->size().width(), e->size().height());
}
void
-PlayField::mouseMoveEvent(QMouseEvent *e) {
+PlayField::mouseMoveEvent(TQMouseEvent *e) {
lastMouseXPos_ = e->x();
lastMouseYPos_ = e->y();
@@ -309,11 +309,11 @@ PlayField::mouseMoveEvent(QMouseEvent *e) {
if (dragX_ == old_x && dragY_ == old_y) return;
- QRect rect(dragX_, dragY_, size_, size_);
+ TQRect rect(dragX_, dragY_, size_, size_);
dragXpm_.resize(size_, size_);
- QPainter paint;
+ TQPainter paint;
paint.begin(&dragXpm_);
paint.setBackgroundColor(backgroundColor());
paint.setBrushOrigin(- dragX_, - dragY_);
@@ -358,19 +358,19 @@ PlayField::mouseMoveEvent(QMouseEvent *e) {
int y2 = old_y;
if (dy > 0) {
paintPainterClip(paint, old_x, old_y, size_, dy);
- // NOTE: clipping is now activated in the QPainter paint
+ // NOTE: clipping is now activated in the TQPainter paint
y2 += dy;
} else if (dy < 0) {
paintPainterClip(paint, old_x, old_y+size_+dy, size_, -dy);
- // NOTE: clipping is now activated in the QPainter paint
+ // NOTE: clipping is now activated in the TQPainter paint
dy = -dy;
}
if (dx > 0) {
paintPainterClip(paint, old_x, y2, dx, size_-dy);
- // NOTE: clipping is now activated in the QPainter paint
+ // NOTE: clipping is now activated in the TQPainter paint
} else if (dx < 0) {
paintPainterClip(paint, old_x+size_+dx, y2, -dx, size_-dy);
- // NOTE: clipping is now activated in the QPainter paint
+ // NOTE: clipping is now activated in the TQPainter paint
}
}
paint.end();
@@ -390,7 +390,7 @@ PlayField::highlight() {
if (x == highlightX_ && y == highlightY_) return;
if (pathFinder_.canDrag(x, y)) {
- QPainter paint(this);
+ TQPainter paint(this);
if (highlightX_ >= 0) {
int x = highlightX_, y = highlightY_;
@@ -409,7 +409,7 @@ PlayField::highlight() {
if (pathFinder_.canWalkTo(x, y)) changeCursor(&crossCursor);
else changeCursor(0);
if (highlightX_ >= 0) {
- QPainter paint(this);
+ TQPainter paint(this);
int x = highlightX_, y = highlightY_;
highlightX_ = -1;
@@ -428,7 +428,7 @@ PlayField::stopMoving() {
updateStepsXpm();
updatePushesXpm();
- QPainter paint(this);
+ TQPainter paint(this);
paint.drawPixmap(snumRect_.x(), snumRect_.y(), snumXpm_);
paint.drawPixmap(pnumRect_.x(), pnumRect_.y(), pnumXpm_);
@@ -453,7 +453,7 @@ PlayField::startMoving(MoveSequence *ms) {
}
void
-PlayField::timerEvent(QTimerEvent *) {
+PlayField::timerEvent(TQTimerEvent *) {
assert(moveInProgress_);
if (moveSequence_ == 0) {
killTimers();
@@ -559,7 +559,7 @@ PlayField::push(int _x, int _y) {
}
void
-PlayField::keyPressEvent(QKeyEvent * e) {
+PlayField::keyPressEvent(TQKeyEvent * e) {
int x=levelMap_->xpos();
int y=levelMap_->ypos();
@@ -626,7 +626,7 @@ PlayField::keyPressEvent(QKeyEvent * e) {
case Key_S:
{
- QString buf;
+ TQString buf;
history_->save(buf);
printf("%s\n", (char *) buf);
}
@@ -667,7 +667,7 @@ PlayField::stopDrag() {
changeCursor(0);
- QPainter paint(this);
+ TQPainter paint(this);
// the following line is a workaround for a bug in Qt 2.0.1
// (and possibly earlier versions)
@@ -677,7 +677,7 @@ PlayField::stopDrag() {
paintSquare(x, y, paint);
paintPainterClip(paint, dragX_, dragY_, size_, size_);
- // NOTE: clipping is now activated in the QPainter paint
+ // NOTE: clipping is now activated in the TQPainter paint
dragInProgress_ = false;
}
@@ -696,7 +696,7 @@ PlayField::dragObject(int xpixel, int ypixel) {
void
-PlayField::mousePressEvent(QMouseEvent *e) {
+PlayField::mousePressEvent(TQMouseEvent *e) {
if (!canMoveNow()) return;
if (dragInProgress_) {
@@ -712,7 +712,7 @@ PlayField::mousePressEvent(QMouseEvent *e) {
return;
if (e->button() == LeftButton && pathFinder_.canDrag(x, y)) {
- QPainter paint(this);
+ TQPainter paint(this);
changeCursor(&sizeAllCursor);
if (levelMap_->goal(x, y))
@@ -754,7 +754,7 @@ PlayField::mousePressEvent(QMouseEvent *e) {
}
void
-PlayField::wheelEvent(QWheelEvent *e) {
+PlayField::wheelEvent(TQWheelEvent *e) {
wheelDelta_ += e->delta();
if (wheelDelta_ >= 120) {
@@ -767,23 +767,23 @@ PlayField::wheelEvent(QWheelEvent *e) {
}
void
-PlayField::mouseReleaseEvent(QMouseEvent *e) {
+PlayField::mouseReleaseEvent(TQMouseEvent *e) {
if (dragInProgress_) dragObject(e->x(), e->y());
}
void
-PlayField::focusInEvent(QFocusEvent *) {
+PlayField::focusInEvent(TQFocusEvent *) {
//printf("PlayField::focusInEvent\n");
}
void
-PlayField::focusOutEvent(QFocusEvent *) {
+PlayField::focusOutEvent(TQFocusEvent *) {
//printf("PlayField::focusOutEvent\n");
}
void
-PlayField::leaveEvent(QEvent *) {
+PlayField::leaveEvent(TQEvent *) {
stopDrag();
}
@@ -908,12 +908,12 @@ void
PlayField::updateCollectionXpm() {
if (collXpm_.isNull()) return;
- QPainter paint(&collXpm_);
+ TQPainter paint(&collXpm_);
paint.setBrushOrigin(- collRect_.x(), - collRect_.y());
paint.fillRect(0, 0, collRect_.width(), collRect_.height(), background_);
paint.setFont(statusFont_);
- paint.setPen(QColor(0,255,0));
+ paint.setPen(TQColor(0,255,0));
paint.drawText(0, 0, collRect_.width(), collRect_.height(),
AlignLeft, collectionName());
}
@@ -922,13 +922,13 @@ void
PlayField::updateTextXpm() {
if (ltxtXpm_.isNull()) return;
- QPainter paint;
+ TQPainter paint;
paint.begin(&ltxtXpm_);
paint.setBrushOrigin(- ltxtRect_.x(), - ltxtRect_.y());
paint.fillRect(0, 0, ltxtRect_.width(), ltxtRect_.height(), background_);
paint.setFont(statusFont_);
- paint.setPen(QColor(128,128,128));
+ paint.setPen(TQColor(128,128,128));
paint.drawText(0, 0, ltxtRect_.width(), ltxtRect_.height(), AlignLeft, levelText_);
paint.end();
@@ -936,7 +936,7 @@ PlayField::updateTextXpm() {
paint.setBrushOrigin(- stxtRect_.x(), - stxtRect_.y());
paint.fillRect(0, 0, stxtRect_.width(), stxtRect_.height(), background_);
paint.setFont(statusFont_);
- paint.setPen(QColor(128,128,128));
+ paint.setPen(TQColor(128,128,128));
paint.drawText(0, 0, stxtRect_.width(), stxtRect_.height(), AlignLeft, stepsText_);
paint.end();
@@ -944,7 +944,7 @@ PlayField::updateTextXpm() {
paint.setBrushOrigin(- ptxtRect_.x(), - ptxtRect_.y());
paint.fillRect(0, 0, ptxtRect_.width(), ptxtRect_.height(), background_);
paint.setFont(statusFont_);
- paint.setPen(QColor(128,128,128));
+ paint.setPen(TQColor(128,128,128));
paint.drawText(0, 0, ptxtRect_.width(), ptxtRect_.height(), AlignLeft, pushesText_);
paint.end();
}
@@ -953,13 +953,13 @@ void
PlayField::updateLevelXpm() {
if (lnumXpm_.isNull()) return;
- QPainter paint(&lnumXpm_);
+ TQPainter paint(&lnumXpm_);
paint.setBrushOrigin(- lnumRect_.x(), - lnumRect_.y());
paint.fillRect(0, 0, lnumRect_.width(), lnumRect_.height(), background_);
- QString str;
+ TQString str;
paint.setFont(statusFont_);
- paint.setPen(QColor(255,0,0));
+ paint.setPen(TQColor(255,0,0));
paint.drawText(0, 0, lnumRect_.width(), lnumRect_.height(),
AlignLeft, str.sprintf("%05d", level()+1));
}
@@ -968,13 +968,13 @@ void
PlayField::updateStepsXpm() {
if (snumXpm_.isNull()) return;
- QPainter paint(&snumXpm_);
+ TQPainter paint(&snumXpm_);
paint.setBrushOrigin(- snumRect_.x(), - snumRect_.y());
paint.fillRect(0, 0, snumRect_.width(), snumRect_.height(), background_);
- QString str;
+ TQString str;
paint.setFont(statusFont_);
- paint.setPen(QColor(255,0,0));
+ paint.setPen(TQColor(255,0,0));
paint.drawText(0, 0, snumRect_.width(), snumRect_.height(),
AlignLeft, str.sprintf("%05d", totalMoves()));
}
@@ -983,13 +983,13 @@ void
PlayField::updatePushesXpm() {
if (pnumXpm_.isNull()) return;
- QPainter paint(&pnumXpm_);
+ TQPainter paint(&pnumXpm_);
paint.setBrushOrigin(- pnumRect_.x(), - pnumRect_.y());
paint.fillRect(0, 0, pnumRect_.width(), pnumRect_.height(), background_);
- QString str;
+ TQString str;
paint.setFont(statusFont_);
- paint.setPen(QColor(255,0,0));
+ paint.setPen(TQColor(255,0,0));
paint.drawText(0, 0, pnumRect_.width(), pnumRect_.height(),
AlignLeft, str.sprintf("%05d", totalPushes()));
}