diff options
Diffstat (limited to 'ktuberling/playground.cpp')
-rw-r--r-- | ktuberling/playground.cpp | 134 |
1 files changed, 67 insertions, 67 deletions
diff --git a/ktuberling/playground.cpp b/ktuberling/playground.cpp index 367c407c..4488fe8d 100644 --- a/ktuberling/playground.cpp +++ b/ktuberling/playground.cpp @@ -11,11 +11,11 @@ #include <kstandarddirs.h> #include <kprinter.h> -#include <qfile.h> -#include <qpainter.h> -#include <qimage.h> -#include <qcursor.h> -#include <qdom.h> +#include <tqfile.h> +#include <tqpainter.h> +#include <tqimage.h> +#include <tqcursor.h> +#include <tqdom.h> #include "playground.moc" #include "toplevel.h" @@ -25,7 +25,7 @@ // Constructor PlayGround::PlayGround(TopLevel *parent, const char *name, uint selectedGameboard) - : QWidget(parent, name) + : TQWidget(parent, name) { topLevel = parent; @@ -38,7 +38,7 @@ PlayGround::PlayGround(TopLevel *parent, const char *name, uint selectedGameboar setBackgroundColor(white); - QDomDocument layoutsDocument; + TQDomDocument layoutsDocument; bool ok = topLevel->loadLayout(layoutsDocument); if (ok) ok = registerPlayGrounds(layoutsDocument); if (ok) ok = loadPlayGround(layoutsDocument, selectedGameboard); @@ -71,7 +71,7 @@ void PlayGround::reset() // Change the gameboard void PlayGround::change(uint selectedGameboard) { - QDomDocument layoutsDocument; + TQDomDocument layoutsDocument; bool ok = topLevel->loadLayout(layoutsDocument); if (ok) ok = loadPlayGround(layoutsDocument, selectedGameboard); if (!ok) loadFailure(); @@ -88,7 +88,7 @@ void PlayGround::change(uint selectedGameboard) // Repaint all the editable area void PlayGround::repaintAll() { - QRect dirtyArea + TQRect dirtyArea (editableArea.left() - 10, editableArea.top() - 10, editableArea.width() + 20, @@ -158,12 +158,12 @@ bool PlayGround::redo() } // Save objects laid down on the editable area -bool PlayGround::saveAs(const QString & name) +bool PlayGround::saveAs(const TQString & name) { FILE *fp; const ToDraw *currentObject; - if (!(fp = fopen((const char *) QFile::encodeName(name), "w"))) return false; + if (!(fp = fopen((const char *) TQFile::encodeName(name), "w"))) return false; fprintf(fp, "%d\n", topLevel->getSelectedGameboard()); for (currentObject = toDraw.first(); currentObject; currentObject = toDraw.next()) @@ -175,21 +175,21 @@ bool PlayGround::saveAs(const QString & name) // Print gameboard's picture bool PlayGround::printPicture(KPrinter &printer) const { - QPainter artist; - QPixmap picture(getPicture()); + TQPainter artist; + TQPixmap picture(getPicture()); if (!artist.begin(&printer)) return false; - artist.drawPixmap(QPoint(32, 32), picture); + artist.drawPixmap(TQPoint(32, 32), picture); if (!artist.end()) return false; return true; } // Get a pixmap containing the current picture -QPixmap PlayGround::getPicture() const +TQPixmap PlayGround::getPicture() const { - QPixmap result(editableArea.size()); - QPainter artist(&result); - QRect transEditableArea(editableArea); + TQPixmap result(editableArea.size()); + TQPainter artist(&result); + TQRect transEditableArea(editableArea); transEditableArea.moveBy(-XMARGIN, -YMARGIN); artist.translate(XMARGIN - editableArea.left(), @@ -199,9 +199,9 @@ QPixmap PlayGround::getPicture() const } // Draw some text -void PlayGround::drawText(QPainter &artist, QRect &area, QString &textId) const +void PlayGround::drawText(TQPainter &artist, TQRect &area, TQString &textId) const { - QString label; + TQString label; label=i18n(textId.latin1()); @@ -209,7 +209,7 @@ void PlayGround::drawText(QPainter &artist, QRect &area, QString &textId) const } // Paint the current picture to the given device -void PlayGround::drawGameboard( QPainter &artist, const QRect &area ) const +void PlayGround::drawGameboard( TQPainter &artist, const TQRect &area ) const { artist.drawPixmap(area.topLeft(), gameboard, area); @@ -218,25 +218,25 @@ void PlayGround::drawGameboard( QPainter &artist, const QRect &area ) const drawText(artist, textsLayout[text], textsList[text]); artist.setPen(black); - for (QPtrListIterator<ToDraw> currentObject(toDraw); + for (TQPtrListIterator<ToDraw> currentObject(toDraw); currentObject.current(); ++currentObject) currentObject.current()->draw(artist, area, objectsLayout, &gameboard, &masks); } // Painting event -void PlayGround::paintEvent( QPaintEvent *event ) +void PlayGround::paintEvent( TQPaintEvent *event ) { - QPoint destination(event->rect().topLeft()), + TQPoint destination(event->rect().topLeft()), position(destination.x() - XMARGIN, destination.y() - YMARGIN); - QRect area(position, QSize(event->rect().size())); - QPixmap cache(gameboard.size()); - QPainter artist(&cache); + TQRect area(position, TQSize(event->rect().size())); + TQPixmap cache(gameboard.size()); + TQPainter artist(&cache); if (destination.x() < XMARGIN) destination.setX(XMARGIN); if (destination.y() < YMARGIN) destination.setY(YMARGIN); - area = QRect(0, 0, gameboard.width(), gameboard.height()).intersect(area); + area = TQRect(0, 0, gameboard.width(), gameboard.height()).intersect(area); if (area.isEmpty()) return; drawGameboard(artist, area); @@ -245,41 +245,41 @@ void PlayGround::paintEvent( QPaintEvent *event ) } // Mouse pressed event -void PlayGround::mousePressEvent( QMouseEvent *event ) +void PlayGround::mousePressEvent( TQMouseEvent *event ) { if (draggedCursor) return; - QPoint position(event->x() - XMARGIN, + TQPoint position(event->x() - XMARGIN, event->y() - YMARGIN); if (!zone(position)) return; int draggedNumber = draggedObject.getNumber(); - QPixmap object(objectsLayout[draggedNumber].size()); - QBitmap shape(objectsLayout[draggedNumber].size()); - bitBlt(&object, QPoint(0, 0), &gameboard, objectsLayout[draggedNumber], Qt::CopyROP); - bitBlt(&shape, QPoint(0, 0), &masks, objectsLayout[draggedNumber], Qt::CopyROP); + TQPixmap object(objectsLayout[draggedNumber].size()); + TQBitmap shape(objectsLayout[draggedNumber].size()); + bitBlt(&object, TQPoint(0, 0), &gameboard, objectsLayout[draggedNumber], Qt::CopyROP); + bitBlt(&shape, TQPoint(0, 0), &masks, objectsLayout[draggedNumber], Qt::CopyROP); object.setMask(shape); - draggedCursor = new QCursor(object, position.x(), position.y()); + draggedCursor = new TQCursor(object, position.x(), position.y()); setCursor(*draggedCursor); topLevel->playSound(soundsList[draggedNumber]); } // Mouse released event -void PlayGround::mouseReleaseEvent( QMouseEvent *event ) +void PlayGround::mouseReleaseEvent( TQMouseEvent *event ) { // If we are not dragging an object, ignore the event if (!draggedCursor) return; - QCursor arrow; + TQCursor arrow; int draggedNumber = draggedObject.getNumber(); - QRect position( + TQRect position( event->x() - XMARGIN - draggedCursor->hotSpot().x(), event->y() - YMARGIN - draggedCursor->hotSpot().y(), objectsLayout[draggedNumber].width(), objectsLayout[draggedNumber].height()); - QRect dirtyArea + TQRect dirtyArea (editableArea.left() - 10, editableArea.top() - 10, editableArea.width() + 20, @@ -325,11 +325,11 @@ void PlayGround::mouseReleaseEvent( QMouseEvent *event ) } // Register the various playgrounds -bool PlayGround::registerPlayGrounds(QDomDocument &layoutDocument) +bool PlayGround::registerPlayGrounds(TQDomDocument &layoutDocument) { - QDomNodeList playGroundsList, menuItemsList, labelsList; - QDomElement playGroundElement, menuItemElement, labelElement; - QDomAttr actionAttribute; + TQDomNodeList playGroundsList, menuItemsList, labelsList; + TQDomElement playGroundElement, menuItemElement, labelElement; + TQDomAttr actionAttribute; playGroundsList = layoutDocument.elementsByTagName("playground"); if (playGroundsList.count() < 1) @@ -337,19 +337,19 @@ bool PlayGround::registerPlayGrounds(QDomDocument &layoutDocument) for (uint i = 0; i < playGroundsList.count(); i++) { - playGroundElement = (const QDomElement &) playGroundsList.item(i).toElement(); + playGroundElement = (const TQDomElement &) playGroundsList.item(i).toElement(); menuItemsList = playGroundElement.elementsByTagName("menuitem"); if (menuItemsList.count() != 1) return false; - menuItemElement = (const QDomElement &) menuItemsList.item(0).toElement(); + menuItemElement = (const TQDomElement &) menuItemsList.item(0).toElement(); labelsList = menuItemElement.elementsByTagName("label"); if (labelsList.count() != 1) return false; - labelElement = (const QDomElement &) labelsList.item(0).toElement(); + labelElement = (const TQDomElement &) labelsList.item(0).toElement(); actionAttribute = menuItemElement.attributeNode("action"); topLevel->registerGameboard(labelElement.text(), actionAttribute.value().latin1()); } @@ -358,15 +358,15 @@ bool PlayGround::registerPlayGrounds(QDomDocument &layoutDocument) } // Load background and draggable objects masks -bool PlayGround::loadPlayGround(QDomDocument &layoutDocument, uint toLoad) +bool PlayGround::loadPlayGround(TQDomDocument &layoutDocument, uint toLoad) { - QDomNodeList playGroundsList, + TQDomNodeList playGroundsList, editableAreasList, categoriesList, objectsList, gameAreasList, maskAreasList, soundNamesList, labelsList; - QDomElement playGroundElement, + TQDomElement playGroundElement, editableAreaElement, categoryElement, objectElement, gameAreaElement, maskAreaElement, soundNameElement, labelElement; - QDomAttr gameboardAttribute, masksAttribute, + TQDomAttr gameboardAttribute, masksAttribute, leftAttribute, topAttribute, rightAttribute, bottomAttribute, refAttribute; @@ -374,7 +374,7 @@ bool PlayGround::loadPlayGround(QDomDocument &layoutDocument, uint toLoad) if (toLoad >= playGroundsList.count()) return false; - playGroundElement = (const QDomElement &) playGroundsList.item(toLoad).toElement(); + playGroundElement = (const TQDomElement &) playGroundsList.item(toLoad).toElement(); gameboardAttribute = playGroundElement.attributeNode("gameboard"); if (!gameboard.load(locate("data", "ktuberling/pics/" + gameboardAttribute.value()))) @@ -388,13 +388,13 @@ bool PlayGround::loadPlayGround(QDomDocument &layoutDocument, uint toLoad) if (editableAreasList.count() != 1) return false; - editableAreaElement = (const QDomElement &) editableAreasList.item(0).toElement(); + editableAreaElement = (const TQDomElement &) editableAreasList.item(0).toElement(); gameAreasList = editableAreaElement.elementsByTagName("position"); if (gameAreasList.count() != 1) return false; - gameAreaElement = (const QDomElement &) gameAreasList.item(0).toElement(); + gameAreaElement = (const TQDomElement &) gameAreasList.item(0).toElement(); leftAttribute = gameAreaElement.attributeNode("left"); topAttribute = gameAreaElement.attributeNode("top"); rightAttribute = gameAreaElement.attributeNode("right"); @@ -410,7 +410,7 @@ bool PlayGround::loadPlayGround(QDomDocument &layoutDocument, uint toLoad) if (soundNamesList.count() != 1) return false; - soundNameElement = (const QDomElement &) soundNamesList.item(0).toElement(); + soundNameElement = (const TQDomElement &) soundNamesList.item(0).toElement(); refAttribute = soundNameElement.attributeNode("ref"); editableSound = refAttribute.value(); @@ -427,13 +427,13 @@ bool PlayGround::loadPlayGround(QDomDocument &layoutDocument, uint toLoad) for (int text = 0; text < texts; text++) { - categoryElement = (const QDomElement &) categoriesList.item(text).toElement(); + categoryElement = (const TQDomElement &) categoriesList.item(text).toElement(); gameAreasList = categoryElement.elementsByTagName("position"); if (gameAreasList.count() != 1) return false; - gameAreaElement = (const QDomElement &) gameAreasList.item(0).toElement(); + gameAreaElement = (const TQDomElement &) gameAreasList.item(0).toElement(); leftAttribute = gameAreaElement.attributeNode("left"); topAttribute = gameAreaElement.attributeNode("top"); rightAttribute = gameAreaElement.attributeNode("right"); @@ -449,7 +449,7 @@ bool PlayGround::loadPlayGround(QDomDocument &layoutDocument, uint toLoad) if (labelsList.count() != 1) return false; - labelElement = (const QDomElement &) labelsList.item(0).toElement(); + labelElement = (const TQDomElement &) labelsList.item(0).toElement(); textsList[text] = labelElement.text(); } @@ -466,13 +466,13 @@ bool PlayGround::loadPlayGround(QDomDocument &layoutDocument, uint toLoad) for (int decoration = 0; decoration < decorations; decoration++) { - objectElement = (const QDomElement &) objectsList.item(decoration).toElement(); + objectElement = (const TQDomElement &) objectsList.item(decoration).toElement(); gameAreasList = objectElement.elementsByTagName("position"); if (gameAreasList.count() != 1) return false; - gameAreaElement = (const QDomElement &) gameAreasList.item(0).toElement(); + gameAreaElement = (const TQDomElement &) gameAreasList.item(0).toElement(); leftAttribute = gameAreaElement.attributeNode("left"); topAttribute = gameAreaElement.attributeNode("top"); rightAttribute = gameAreaElement.attributeNode("right"); @@ -488,7 +488,7 @@ bool PlayGround::loadPlayGround(QDomDocument &layoutDocument, uint toLoad) if (soundNamesList.count() != 1) return false; - soundNameElement = (const QDomElement &) soundNamesList.item(0).toElement(); + soundNameElement = (const TQDomElement &) soundNamesList.item(0).toElement(); refAttribute = soundNameElement.attributeNode("ref"); @@ -518,7 +518,7 @@ void PlayGround::setupGeometry() // In which decorative object are we? // On return, the position is the location of the cursor's hot spot // Returns false if we aren't in any zone -bool PlayGround::zone(QPoint &position) +bool PlayGround::zone(TQPoint &position) { // Scan all available decorative objects on right side because we may be adding one int draggedNumber; @@ -543,14 +543,14 @@ bool PlayGround::zone(QPoint &position) currentObject = toDraw.at(draggedZOrder); if (!currentObject->getPosition().contains(position)) continue; - QRect toUpdate(currentObject->getPosition()); + TQRect toUpdate(currentObject->getPosition()); draggedObject = *currentObject; draggedNumber = draggedObject.getNumber(); - QBitmap shape(objectsLayout[draggedNumber].size()); - QPoint relative(position.x() - toUpdate.x(), + TQBitmap shape(objectsLayout[draggedNumber].size()); + TQPoint relative(position.x() - toUpdate.x(), position.y() - toUpdate.y()); - bitBlt(&shape, QPoint(0, 0), &masks, objectsLayout[draggedNumber], Qt::CopyROP); + bitBlt(&shape, TQPoint(0, 0), &masks, objectsLayout[draggedNumber], Qt::CopyROP); if (!shape.convertToImage().pixelIndex(relative.x(), relative.y())) continue; toDraw.remove(draggedZOrder); @@ -570,14 +570,14 @@ bool PlayGround::zone(QPoint &position) } // Load objects and lay them down on the editable area -bool PlayGround::loadFrom(const QString &name) +bool PlayGround::loadFrom(const TQString &name) { FILE *fp; bool eof = false; ToDraw readObject, *newObject; Action *newAction; - if (!(fp = fopen(QFile::encodeName(name), "r"))) return false; + if (!(fp = fopen(TQFile::encodeName(name), "r"))) return false; uint newGameboard; int nitems = fscanf(fp, "%u\n", &newGameboard); |