From 0a6e0958c03e41c87b15557b6f407874f20c2f8d Mon Sep 17 00:00:00 2001 From: tpearson Date: Sat, 31 Jul 2010 19:39:55 +0000 Subject: Trinity Qt initial conversion git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeedu@1157642 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kturtle/src/canvas.cpp | 130 ++++++++++++++++++++++++------------------------- 1 file changed, 65 insertions(+), 65 deletions(-) (limited to 'kturtle/src/canvas.cpp') diff --git a/kturtle/src/canvas.cpp b/kturtle/src/canvas.cpp index 871c1614..38281956 100644 --- a/kturtle/src/canvas.cpp +++ b/kturtle/src/canvas.cpp @@ -53,7 +53,7 @@ #include -#include +#include #include #include @@ -75,10 +75,10 @@ const double DEG2RAD = 3.14159265358979323846/180; // BEGIN public methods -Canvas::Canvas(QWidget *parent, const char *name) : QCanvasView(0, parent, name) +Canvas::Canvas(TQWidget *parent, const char *name) : TQCanvasView(0, parent, name) { // Create a new canvas for this view - canvas = new QCanvas(parent); + canvas = new TQCanvas(parent); canvas->setAdvancePeriod(250); // refresh-rate in [ms] // set initial values @@ -95,10 +95,10 @@ Canvas::~Canvas() } -QPixmap* Canvas::canvas2Pixmap() +TQPixmap* Canvas::canvas2Pixmap() { - pixmap = QPixmap( canvas->width(), canvas->height() ); - QPainter painter(&pixmap); + pixmap = TQPixmap( canvas->width(), canvas->height() ); + TQPainter painter(&pixmap); canvas->drawArea(canvas->rect(), &painter); return &pixmap; } @@ -111,8 +111,8 @@ QPixmap* Canvas::canvas2Pixmap() void Canvas::slotClear() { - QCanvasItemList list = canvas->allItems(); - QCanvasItemList::Iterator it = list.begin(); + TQCanvasItemList list = canvas->allItems(); + TQCanvasItemList::Iterator it = list.begin(); for (; it != list.end(); ++it) { // kill everything but the turtle (who lives on a seperate layer) @@ -122,8 +122,8 @@ void Canvas::slotClear() void Canvas::slotClearSpriteToo() { - QCanvasItemList list = canvas->allItems(); - QCanvasItemList::Iterator it = list.begin(); + TQCanvasItemList list = canvas->allItems(); + TQCanvasItemList::Iterator it = list.begin(); for (; it != list.end(); ++it) { if (*it) delete *it; @@ -138,7 +138,7 @@ void Canvas::slotGo(double x, double y) if ( wrap && !canvas->onCanvas(intX, intY) ) { - QPoint offsetPoint = offset(intX, intY); + TQPoint offsetPoint = offset(intX, intY); posX = x - ( offsetPoint.x() * canvasWidth ); posY = y - ( offsetPoint.y() * canvasHeight ); } @@ -156,7 +156,7 @@ void Canvas::slotGoX(double x) int intPosY = ROUND2INT(posY); if ( wrap && !canvas->onCanvas(intX, intPosY) ) { - QPoint offsetPoint = offset(intX, intPosY); + TQPoint offsetPoint = offset(intX, intPosY); posX = x - ( offsetPoint.x() * canvasWidth ); } else posX = x; @@ -169,7 +169,7 @@ void Canvas::slotGoY(double y) int intPosX = ROUND2INT(posX); if ( wrap && !canvas->onCanvas(intPosX, intY) ) { - QPoint offsetPoint = offset(intPosX, intY); + TQPoint offsetPoint = offset(intPosX, intY); posY = y - ( offsetPoint.y() * canvasHeight ); } else posY = y; @@ -243,7 +243,7 @@ void Canvas::slotSetFgColor(int r, int g, int b) void Canvas::slotSetBgColor(int r, int g, int b) { - canvas->setBackgroundColor( QColor(r, g, b) ); + canvas->setBackgroundColor( TQColor(r, g, b) ); } void Canvas::slotResizeCanvas(int x, int y) @@ -285,16 +285,16 @@ void Canvas::slotSpriteChange(int x) sprite->move(ROUND2INT(posX - sprite->width()/2), ROUND2INT(posY - sprite->height()/2)); } -void Canvas::slotPrint(QString text) +void Canvas::slotPrint(TQString text) { - QCanvasText* t = new QCanvasText(text, font, canvas); + TQCanvasText* t = new TQCanvasText(text, font, canvas); // text does not do the wrapping, never... sorry - t->setColor( QColor(fgR, fgG, fgB) ); + t->setColor( TQColor(fgR, fgG, fgB) ); t->move(ROUND2INT(posX), ROUND2INT(posY)); t->show(); } -void Canvas::slotFontType(QString family, QString extra) +void Canvas::slotFontType(TQString family, TQString extra) { font.setFamily(family); font.setBold( extra.contains("bold") > 0 ); @@ -338,7 +338,7 @@ void Canvas::initValues() canvasWidth = Settings::canvasWidth(); canvasHeight = Settings::canvasHeight(); // colors - canvas->setBackgroundColor( QColor(255, 255, 255) ); // background + canvas->setBackgroundColor( TQColor(255, 255, 255) ); // background fgR = 0; // pencolor (forground) fgG = 0; fgB = 0; @@ -347,7 +347,7 @@ void Canvas::initValues() pen = true; wrap = true; direction = 0; - font = QFont("serif", 18); + font = TQFont("serif", 18); // the position posX = canvasWidth / 2; posY = canvasHeight / 2; @@ -364,26 +364,26 @@ void Canvas::lineShell(double xa, double ya, double xb, double yb) // line can fallback into this function in case of cutLoop == true cutLoop = false; // Reset the loop detection memory - prevStartPos3 = prevStartPos2 = prevStartPos1 = prevEndPos3 = prevEndPos2 = prevEndPos1 = QPoint(0, 0); + prevStartPos3 = prevStartPos2 = prevStartPos1 = prevEndPos3 = prevEndPos2 = prevEndPos1 = TQPoint(0, 0); // and go! line(xa, ya, xb, yb); } void Canvas::line(double xa, double ya, double xb, double yb) { - QCanvasLine* l = new QCanvasLine(canvas); + TQCanvasLine* l = new TQCanvasLine(canvas); int intXa = ROUND2INT(xa); int intYa = ROUND2INT(ya); int intXb = ROUND2INT(xb); int intYb = ROUND2INT(yb); l->setPoints(intXa, intYa, intXb, intYb); - l->setPen( QPen(QColor(fgR, fgG, fgB), penWidth, SolidLine) ); + l->setPen( TQPen(TQColor(fgR, fgG, fgB), penWidth, SolidLine) ); l->setZ(1); l->show(); // kdDebug(0)<<"Canvas::line(); xa:"<onCanvas( ROUND2INT(xb), ROUND2INT(yb) ) ) { - if (endlessLoop( QPoint(intXa, intYa), QPoint(intXb, intYb) ) == true) // detect for endless loop + if (endlessLoop( TQPoint(intXa, intYa), TQPoint(intXb, intYb) ) == true) // detect for endless loop { slotCenter(); kdDebug(0)<<"Canvas::line(): ENDLESS LOOP DETECTED, BROKE THE LOOP"< -0.00001 && (xb - xa) < 0.00001 ) // check for an infinite tangent (direction coefficient) { i++; - translate[i] = QPoint( 0, 1 ); - crossPoint[i] = QPoint( ROUND2INT(xa), 0 ); + translate[i] = TQPoint( 0, 1 ); + crossPoint[i] = TQPoint( ROUND2INT(xa), 0 ); i++; - translate[i] = QPoint(0,-1 ); - crossPoint[i] = QPoint( ROUND2INT(xa), canvasHeight ); + translate[i] = TQPoint(0,-1 ); + crossPoint[i] = TQPoint( ROUND2INT(xa), canvasHeight ); } else { @@ -487,32 +487,32 @@ QPoint Canvas::translationFactor(double xa, double ya, double xb, double yb) if ( 0 <= x_sT && x_sT <= canvasWidth && pointInRange(x_sT, 0, xa, ya, xb, yb) ) { i++; - translate[i] = QPoint( 0, 1 ); - crossPoint[i] = QPoint( ROUND2INT(x_sT), 0 ); + translate[i] = TQPoint( 0, 1 ); + crossPoint[i] = TQPoint( ROUND2INT(x_sT), 0 ); } if ( 0 <= x_sB && x_sB <= canvasWidth && pointInRange(x_sB, canvasHeight, xa, ya, xb, yb) ) { i++; - translate[i] = QPoint( 0,-1 ); - crossPoint[i] = QPoint( ROUND2INT(x_sB), ROUND2INT(canvasHeight) ); + translate[i] = TQPoint( 0,-1 ); + crossPoint[i] = TQPoint( ROUND2INT(x_sB), ROUND2INT(canvasHeight) ); } if ( 0 <= y_sL && y_sL <= canvasHeight && pointInRange(0, y_sL, xa, ya, xb, yb) ) { i++; - translate[i] = QPoint( 1, 0 ); - crossPoint[i] = QPoint( 0, ROUND2INT(y_sL) ); + translate[i] = TQPoint( 1, 0 ); + crossPoint[i] = TQPoint( 0, ROUND2INT(y_sL) ); } if ( 0 <= y_sR && y_sR <= canvasHeight && pointInRange(canvasWidth, y_sR, xa, ya, xb, yb) ) { i++; - translate[i] = QPoint(-1, 0 ); - crossPoint[i] = QPoint( ROUND2INT(canvasWidth), ROUND2INT(y_sR) ); + translate[i] = TQPoint(-1, 0 ); + crossPoint[i] = TQPoint( ROUND2INT(canvasWidth), ROUND2INT(y_sR) ); } if ( i == 0 ) { // kdDebug(0)<<"Canvas::translationFactor: FIRST NO BORDER CROSSINGS DETECTED"< canvasWidth) returnValue = returnValue + QPoint(-1, 0); + returnValue = TQPoint(0, 0); + if (xb < 0) returnValue = returnValue + TQPoint( 1, 0); + else if (xb > canvasWidth) returnValue = returnValue + TQPoint(-1, 0); - if (yb < 0) returnValue = returnValue + QPoint( 0, 1); - else if (yb > canvasHeight) returnValue = returnValue + QPoint( 0,-1); + if (yb < 0) returnValue = returnValue + TQPoint( 0, 1); + else if (yb > canvasHeight) returnValue = returnValue + TQPoint( 0,-1); return returnValue; } @@ -595,14 +595,14 @@ QPoint Canvas::translationFactor(double xa, double ya, double xb, double yb) // Sprite related methods: -void Canvas::loadSpriteFrames(QString name) +void Canvas::loadSpriteFrames(TQString name) { // read the pixmaps name.0001.png, name.0002.png, ..., name.0035.png: the different rotations // #0000 for 0 or 360, #0001 for 10, #0002 for 20, ..., #0018 for 180, etc. // WARNING if the dir doesnt exists the app will crash!!! // This will be fixed in qt3.3 and in the current qt-copy - QPixmap turtlePix = QPixmap(locate("data","kturtle/pics/turtle.0000.png") ); + TQPixmap turtlePix = TQPixmap(locate("data","kturtle/pics/turtle.0000.png") ); if ( turtlePix.isNull() ) { KMessageBox::sorry( this, @@ -610,10 +610,10 @@ void Canvas::loadSpriteFrames(QString name) "Please check your installation."), i18n("Error") ); return; } - QString spritePath = locate("data","kturtle/pics/"+name+".0000.png"); + TQString spritePath = locate("data","kturtle/pics/"+name+".0000.png"); spritePath.remove(".0000.png"); - spriteFrames = new QCanvasPixmapArray(spritePath+".%1.png", 36); - sprite = new QCanvasSprite(spriteFrames, canvas); + spriteFrames = new TQCanvasPixmapArray(spritePath+".%1.png", 36); + sprite = new TQCanvasSprite(spriteFrames, canvas); sprite->setZ(250); } -- cgit v1.2.1