summaryrefslogtreecommitdiffstats
path: root/kgoldrunner/src/kgrcanvas.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kgoldrunner/src/kgrcanvas.cpp')
-rw-r--r--kgoldrunner/src/kgrcanvas.cpp176
1 files changed, 88 insertions, 88 deletions
diff --git a/kgoldrunner/src/kgrcanvas.cpp b/kgoldrunner/src/kgrcanvas.cpp
index 6104939e..111913a1 100644
--- a/kgoldrunner/src/kgrcanvas.cpp
+++ b/kgoldrunner/src/kgrcanvas.cpp
@@ -34,11 +34,11 @@
class KGoldrunner;
-KGrCanvas::KGrCanvas (QWidget * parent, const char *name)
- : QCanvasView (0, parent, name)
+KGrCanvas::KGrCanvas (TQWidget * parent, const char *name)
+ : TQCanvasView (0, parent, name)
{
setBackgroundMode (NoBackground);
- m = new QCursor (); // For handling the mouse.
+ m = new TQCursor (); // For handling the mouse.
scaleStep = STEP; // Initial scale is 1:1.
baseScale = scaleStep;
@@ -57,12 +57,12 @@ KGrCanvas::~KGrCanvas()
{
}
-void KGrCanvas::changeLandscape (const QString & name)
+void KGrCanvas::changeLandscape (const TQString & name)
{
for (int i = 0; strcmp (colourScheme [i], "") != 0; i++) {
if (colourScheme [i] == name) {
- // Change XPM colours and re-draw the tile-pictures used by QCanvas.
+ // Change XPM colours and re-draw the tile-pictures used by TQCanvas.
changeColours (& colourScheme [i]);
makeTiles();
@@ -85,11 +85,11 @@ void KGrCanvas::changeLandscape (const QString & name)
}
}
- borderB->setBrush (QBrush (borderColor));
- borderL->setBrush (QBrush (borderColor));
- borderR->setBrush (QBrush (borderColor));
+ borderB->setBrush (TQBrush (borderColor));
+ borderL->setBrush (TQBrush (borderColor));
+ borderR->setBrush (TQBrush (borderColor));
- QString t = title->text();
+ TQString t = title->text();
makeTitle ();
setTitle (t);
@@ -117,7 +117,7 @@ bool KGrCanvas::changeSize (int d)
return FALSE;
}
- QWMatrix wm = worldMatrix();
+ TQWMatrix wm = worldMatrix();
double wmScale = 1.0;
// Set the scale back to 1:1 and calculate the new scale factor.
@@ -132,11 +132,11 @@ bool KGrCanvas::changeSize (int d)
setWorldMatrix (wm);
// Force the title size and position to be re-calculated.
- QString t = title->text();
+ TQString t = title->text();
makeTitle ();
setTitle (t);
- // Fit the QCanvasView and its frame to the canvas.
+ // Fit the TQCanvasView and its frame to the canvas.
int frame = frameWidth()*2;
setFixedSize ((FIELDWIDTH + 4) * 4 * scaleStep + frame,
(FIELDHEIGHT + 4) * 4 * scaleStep + frame);
@@ -175,7 +175,7 @@ void KGrCanvas::paintCell (int x, int y, char type, int offset)
tileNumber = tileNumber + offset; // Offsets 1-9 are for digging sequence.
- // In KGoldrunner, the top-left visible cell is [1,1] --- in QCanvas [2,2].
+ // In KGoldrunner, the top-left visible cell is [1,1] --- in TQCanvas [2,2].
x++; y++;
field->setTile (x, y, tileNumber); // Paint cell with required pixmap.
}
@@ -184,56 +184,56 @@ void KGrCanvas::setBaseScale ()
{
// Synchronise the desktop font size with the initial canvas scale.
baseScale = scaleStep;
- QString t = title->text();
+ TQString t = title->text();
makeTitle ();
setTitle (t);
}
-void KGrCanvas::setTitle (QString newTitle)
+void KGrCanvas::setTitle (TQString newTitle)
{
title->setText (newTitle);
}
void KGrCanvas::makeTitle ()
{
- // This uses a calculated QLabel and QFont size because a QCanvasText
+ // This uses a calculated TQLabel and TQFont size because a QCanvasText
// object does not always display scaled-up fonts cleanly (in Qt 3.1.1).
if (title != 0)
title->close (TRUE); // Close and delete previous title.
- title = new QLabel ("", this);
+ title = new TQLabel ("", this);
title->setFixedWidth (((FIELDWIDTH * cw + 2 * bw) * scaleStep) / STEP);
title->setFixedHeight ((mw * scaleStep) / STEP);
title->move (0, 0);
title->setPaletteBackgroundColor (borderColor);
title->setPaletteForegroundColor (textColor);
- title->setFont (QFont (fontInfo().family(),
- (baseFontSize * scaleStep) / baseScale, QFont::Bold));
+ title->setFont (TQFont (fontInfo().family(),
+ (baseFontSize * scaleStep) / baseScale, TQFont::Bold));
title->setAlignment (Qt::AlignCenter);
title->raise();
title->show();
}
-void KGrCanvas::contentsMousePressEvent (QMouseEvent * m) {
+void KGrCanvas::contentsMousePressEvent (TQMouseEvent * m) {
emit mouseClick (m->button ());
}
-void KGrCanvas::contentsMouseReleaseEvent (QMouseEvent * m) {
+void KGrCanvas::contentsMouseReleaseEvent (TQMouseEvent * m) {
emit mouseLetGo (m->button ());
}
-QPoint KGrCanvas::getMousePos ()
+TQPoint KGrCanvas::getMousePos ()
{
int i, j;
int fw = frameWidth();
int cell = 4 * scaleStep;
- QPoint p = mapFromGlobal (m->pos());
+ TQPoint p = mapFromGlobal (m->pos());
- // In KGoldrunner, the top-left visible cell is [1,1] --- in QCanvas [2,2].
+ // In KGoldrunner, the top-left visible cell is [1,1] --- in TQCanvas [2,2].
i = ((p.x() - fw) / cell) - 1; j = ((p.y() - fw) / cell) - 1;
- return (QPoint (i, j));
+ return (TQPoint (i, j));
}
void KGrCanvas::setMousePos (int i, int j)
@@ -241,19 +241,19 @@ void KGrCanvas::setMousePos (int i, int j)
int fw = frameWidth();
int cell = 4 * scaleStep;
- // In KGoldrunner, the top-left visible cell is [1,1] --- in QCanvas [2,2].
+ // In KGoldrunner, the top-left visible cell is [1,1] --- in TQCanvas [2,2].
i++; j++;
- //m->setPos (mapToGlobal (QPoint (i * 4 * STEP + 8, j * 4 * STEP + 8)));
- //m->setPos (mapToGlobal (QPoint (i * 5 * STEP + 10, j * 5 * STEP + 10)));
+ //m->setPos (mapToGlobal (TQPoint (i * 4 * STEP + 8, j * 4 * STEP + 8)));
+ //m->setPos (mapToGlobal (TQPoint (i * 5 * STEP + 10, j * 5 * STEP + 10)));
m->setPos (mapToGlobal (
- QPoint (i * cell + fw + cell / 2, j * cell + fw + cell / 2)));
+ TQPoint (i * cell + fw + cell / 2, j * cell + fw + cell / 2)));
}
void KGrCanvas::makeHeroSprite (int i, int j, int startFrame)
{
- heroSprite = new QCanvasSprite (heroArray, field);
+ heroSprite = new TQCanvasSprite (heroArray, field);
- // In KGoldrunner, the top-left visible cell is [1,1] --- in QCanvas [2,2].
+ // In KGoldrunner, the top-left visible cell is [1,1] --- in TQCanvas [2,2].
i++; j++;
heroSprite->move (i * 4 * STEP, j * 4 * STEP, startFrame);
heroSprite->setZ (1);
@@ -267,11 +267,11 @@ void KGrCanvas::setHeroVisible (bool newState)
void KGrCanvas::makeEnemySprite (int i, int j, int startFrame)
{
- QCanvasSprite * enemySprite = new QCanvasSprite (enemyArray, field);
+ TQCanvasSprite * enemySprite = new TQCanvasSprite (enemyArray, field);
enemySprites->append (enemySprite);
- // In KGoldrunner, the top-left visible cell is [1,1] --- in QCanvas [2,2].
+ // In KGoldrunner, the top-left visible cell is [1,1] --- in TQCanvas [2,2].
i++; j++;
enemySprite->move (i * 4 * STEP, j * 4 * STEP, startFrame);
enemySprite->setZ (2);
@@ -280,7 +280,7 @@ void KGrCanvas::makeEnemySprite (int i, int j, int startFrame)
void KGrCanvas::moveHero (int x, int y, int frame)
{
- // In KGoldrunner, the top-left visible cell is [1,1] --- in QCanvas [2,2].
+ // In KGoldrunner, the top-left visible cell is [1,1] --- in TQCanvas [2,2].
heroSprite->move (x + 4 * STEP, y + 4 * STEP, frame);
updateCanvas();
}
@@ -291,7 +291,7 @@ void KGrCanvas::moveEnemy (int id, int x, int y, int frame, int nuggets)
frame = frame + goldEnemy; // show him with gold outline.
}
- // In KGoldrunner, the top-left visible cell is [1,1] --- in QCanvas [2,2].
+ // In KGoldrunner, the top-left visible cell is [1,1] --- in TQCanvas [2,2].
enemySprites->at(id)->move (x + 4 * STEP, y + 4 * STEP, frame);
updateCanvas();
}
@@ -301,10 +301,10 @@ void KGrCanvas::deleteEnemySprites()
enemySprites->clear();
}
-QPixmap KGrCanvas::getPixmap (char type)
+TQPixmap KGrCanvas::getPixmap (char type)
{
- QPixmap pic (bgw, bgh, bgd);
- QPainter p (& pic);
+ TQPixmap pic (bgw, bgh, bgd);
+ TQPainter p (& pic);
int tileNumber;
// Get a pixmap from the tile-array for use on an edit-button.
@@ -347,30 +347,30 @@ void KGrCanvas::initView()
brickbg = 8; // Solid brick - 1st pixmap.
fbrickbg = 15; // False brick - 8th pixmap (for editing).
- QPixmap pixmap;
- QImage image;
+ TQPixmap pixmap;
+ TQImage image;
- pixmap = QPixmap (hgbrick_xpm);
+ pixmap = TQPixmap (hgbrick_xpm);
bgw = pixmap.width(); // Save dimensions for "getPixmap".
bgh = pixmap.height();
bgd = pixmap.depth();
// Assemble the background and editing pixmaps into a strip (18 pixmaps).
- bgPix = QPixmap ((brickbg + 10) * bgw, bgh, bgd);
+ bgPix = TQPixmap ((brickbg + 10) * bgw, bgh, bgd);
makeTiles(); // Fill the strip with 18 tiles.
// Define the canvas as an array of tiles. Default tile is 0 (free space).
int frame = frameWidth()*2;
- field = new QCanvas ((FIELDWIDTH+border) * bgw, (FIELDHEIGHT+border) * bgh);
+ field = new TQCanvas ((FIELDWIDTH+border) * bgw, (FIELDHEIGHT+border) * bgh);
field->setTiles (bgPix, (FIELDWIDTH+border), (FIELDHEIGHT+border),
bgw, bgh);
// Embed the canvas in the view and make it occupy the whole of the view.
setCanvas (field);
- setVScrollBarMode (QScrollView::AlwaysOff);
- setHScrollBarMode (QScrollView::AlwaysOff);
+ setVScrollBarMode (TQScrollView::AlwaysOff);
+ setHScrollBarMode (TQScrollView::AlwaysOff);
setFixedSize (field->width() + frame, field->height() + frame);
//////////////////////////////////////////////////////////////////////////
@@ -379,41 +379,41 @@ void KGrCanvas::initView()
// climb up ladder (2) and fall (2) --- total 20. //
//////////////////////////////////////////////////////////////////////////
- // Convert the pixmap strip for hero animation into a QCanvasPixmapArray.
- pixmap = QPixmap (hero_xpm);
+ // Convert the pixmap strip for hero animation into a TQCanvasPixmapArray.
+ pixmap = TQPixmap (hero_xpm);
image = pixmap.convertToImage ();
#ifdef QT3
- QPixmap pm;
- QValueList<QPixmap> pmList;
+ TQPixmap pm;
+ TQValueList<TQPixmap> pmList;
for (int i = 0; i < 20; i++) {
pm.convertFromImage (image.copy (i * 16, 0, 16, 16));
pmList.append (pm);
}
- heroArray = new QCanvasPixmapArray (pmList); // Hot spots all (0,0).
+ heroArray = new TQCanvasPixmapArray (pmList); // Hot spots all (0,0).
#else
- QPixmap * pm;
- QPoint * pt;
- QList<QPixmap> pmList;
- QList<QPoint> ptList;
+ TQPixmap * pm;
+ TQPoint * pt;
+ QList<TQPixmap> pmList;
+ QList<TQPoint> ptList;
- pt = new QPoint (0, 0); // "Hot spot" not used in KGoldrunner.
+ pt = new TQPoint (0, 0); // "Hot spot" not used in KGoldrunner.
for (int i = 0; i < 20; i++) {
- pm = new QPixmap ();
+ pm = new TQPixmap ();
pm->convertFromImage (image.copy (i * 16, 0, 16, 16));
pmList.append (pm);
ptList.append (pt);
}
- heroArray = new QCanvasPixmapArray (pmList, ptList);
+ heroArray = new TQCanvasPixmapArray (pmList, ptList);
#endif
- // Convert pixmap strips for enemy animations into a QCanvasPixmapArray.
+ // Convert pixmap strips for enemy animations into a TQCanvasPixmapArray.
// First convert the pixmaps for enemies with no gold ...
- pixmap = QPixmap (enemy1_xpm);
+ pixmap = TQPixmap (enemy1_xpm);
image = pixmap.convertToImage ();
pmList.clear();
@@ -427,7 +427,7 @@ void KGrCanvas::initView()
ptList.clear();
for (int i = 0; i < 20; i++) {
- pm = new QPixmap ();
+ pm = new TQPixmap ();
pm->convertFromImage (image.copy (i * 16, 0, 16, 16));
pmList.append (pm);
ptList.append (pt);
@@ -435,7 +435,7 @@ void KGrCanvas::initView()
#endif
// ... then convert the gold-carrying enemies.
- pixmap = QPixmap (enemy2_xpm);
+ pixmap = TQPixmap (enemy2_xpm);
image = pixmap.convertToImage ();
#ifdef QT3
@@ -444,16 +444,16 @@ void KGrCanvas::initView()
pmList.append (pm);
}
- enemyArray = new QCanvasPixmapArray (pmList); // Hot spots all (0,0).
+ enemyArray = new TQCanvasPixmapArray (pmList); // Hot spots all (0,0).
#else
for (int i = 0; i < 20; i++) {
- pm = new QPixmap ();
+ pm = new TQPixmap ();
pm->convertFromImage (image.copy (i * 16, 0, 16, 16));
pmList.append (pm);
ptList.append (pt);
}
- enemyArray = new QCanvasPixmapArray (pmList, ptList);
+ enemyArray = new TQCanvasPixmapArray (pmList, ptList);
#endif
goldEnemy = 20; // Offset of gold-carrying frames.
@@ -467,29 +467,29 @@ void KGrCanvas::initView()
// Create an empty list of enemy sprites.
#ifdef QT3
- enemySprites = new QPtrList<QCanvasSprite> ();
+ enemySprites = new TQPtrList<TQCanvasSprite> ();
#else
- enemySprites = new QList<QCanvasSprite> ();
+ enemySprites = new QList<TQCanvasSprite> ();
#endif
enemySprites->setAutoDelete(TRUE);
}
void KGrCanvas::makeTiles ()
{
- QPainter p (& bgPix);
+ TQPainter p (& bgPix);
// First draw the single pixmaps (8 tiles) ...
- p.drawPixmap (freebg * bgw, 0, QPixmap (hgbrick_xpm)); // Free space.
- p.drawPixmap (nuggetbg * bgw, 0, QPixmap (nugget_xpm)); // Nugget.
- p.drawPixmap (polebg * bgw, 0, QPixmap (pole_xpm)); // Pole or bar.
- p.drawPixmap (ladderbg * bgw, 0, QPixmap (ladder_xpm)); // Ladder.
- p.drawPixmap (hladderbg * bgw, 0, QPixmap (hladder_xpm)); // Hidden laddr.
- p.drawPixmap (edherobg * bgw, 0, QPixmap (edithero_xpm)); // Static hero.
- p.drawPixmap (edenemybg * bgw, 0, QPixmap (editenemy_xpm)); // Static enemy.
- p.drawPixmap (betonbg * bgw, 0, QPixmap (beton_xpm)); // Concrete.
+ p.drawPixmap (freebg * bgw, 0, TQPixmap (hgbrick_xpm)); // Free space.
+ p.drawPixmap (nuggetbg * bgw, 0, TQPixmap (nugget_xpm)); // Nugget.
+ p.drawPixmap (polebg * bgw, 0, TQPixmap (pole_xpm)); // Pole or bar.
+ p.drawPixmap (ladderbg * bgw, 0, TQPixmap (ladder_xpm)); // Ladder.
+ p.drawPixmap (hladderbg * bgw, 0, TQPixmap (hladder_xpm)); // Hidden laddr.
+ p.drawPixmap (edherobg * bgw, 0, TQPixmap (edithero_xpm)); // Static hero.
+ p.drawPixmap (edenemybg * bgw, 0, TQPixmap (editenemy_xpm)); // Static enemy.
+ p.drawPixmap (betonbg * bgw, 0, TQPixmap (beton_xpm)); // Concrete.
// ... then add the 10 brick pixmaps.
- p.drawPixmap (brickbg * bgw, 0, QPixmap (bricks_xpm)); // Bricks.
+ p.drawPixmap (brickbg * bgw, 0, TQPixmap (bricks_xpm)); // Bricks.
p.end();
}
@@ -500,7 +500,7 @@ void KGrCanvas::makeBorder ()
// Allow some overlap to prevent slits appearing when using "changeSize".
colour = borderColor;
- // The first rectangle is actually a QLabel drawn by "makeTitle()".
+ // The first rectangle is actually a TQLabel drawn by "makeTitle()".
// borderT = drawRectangle (11, 0, 0, FIELDWIDTH*cw + 2*bw, mw);
borderB = drawRectangle (11, 0, FIELDHEIGHT*cw + bw + lw,
FIELDWIDTH*cw + 2*bw, mw);
@@ -509,19 +509,19 @@ void KGrCanvas::makeBorder ()
mw, FIELDHEIGHT*cw + 2*lw + 2);
// Draw inside edges of border, in the same way.
- colour = QColor (black);
+ colour = TQColor (black);
drawRectangle (10, bw-lw, bw-lw-1, FIELDWIDTH*cw + 2*lw, lw+1);
drawRectangle (10, bw-lw, FIELDHEIGHT*cw + bw, FIELDWIDTH*cw + 2*lw, lw+1);
drawRectangle (10, bw - lw, bw, lw, FIELDHEIGHT*cw);
drawRectangle (10, FIELDWIDTH*cw + bw, bw, lw, FIELDHEIGHT*cw);
}
-QCanvasRectangle * KGrCanvas::drawRectangle (int z, int x, int y, int w, int h)
+TQCanvasRectangle * KGrCanvas::drawRectangle (int z, int x, int y, int w, int h)
{
- QCanvasRectangle * r = new QCanvasRectangle (x, y, w, h, field);
+ TQCanvasRectangle * r = new TQCanvasRectangle (x, y, w, h, field);
- r->setBrush (QBrush (colour));
- r->setPen (QPen (NoPen));
+ r->setBrush (TQBrush (colour));
+ r->setPen (TQPen (NoPen));
r->setZ (z);
r->show();
@@ -541,13 +541,13 @@ void KGrCanvas::changeColours (const char * colours [])
recolourObject (beton_xpm, colours);
recolourObject (bricks_xpm, colours);
- borderColor = QColor (colours [1]);
- textColor = QColor (colours [2]);
+ borderColor = TQColor (colours [1]);
+ textColor = TQColor (colours [2]);
- KGrThumbNail::backgroundColor = QColor (QString(colours [3]).right(7));
- KGrThumbNail::brickColor = QColor (QString(colours [6]).right(7));
- KGrThumbNail::ladderColor = QColor (QString(colours [9]).right(7));
- KGrThumbNail::poleColor = QColor (QString(colours [11]).right(7));
+ KGrThumbNail::backgroundColor = TQColor (TQString(colours [3]).right(7));
+ KGrThumbNail::brickColor = TQColor (TQString(colours [6]).right(7));
+ KGrThumbNail::ladderColor = TQColor (TQString(colours [9]).right(7));
+ KGrThumbNail::poleColor = TQColor (TQString(colours [11]).right(7));
}
void KGrCanvas::recolourObject (const char * object [], const char * colours [])