summaryrefslogtreecommitdiffstats
path: root/kimagemapeditor/drawzone.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:54:04 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:54:04 +0000
commitdc6b8e72fed2586239e3514819238c520636c9d9 (patch)
tree88b200df0a0b7fab9d6f147596173556f1ed9a13 /kimagemapeditor/drawzone.cpp
parent6927d4436e54551917f600b706a8d6109e49de1c (diff)
downloadtdewebdev-dc6b8e72fed2586239e3514819238c520636c9d9.tar.gz
tdewebdev-dc6b8e72fed2586239e3514819238c520636c9d9.zip
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdewebdev@1157656 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kimagemapeditor/drawzone.cpp')
-rw-r--r--kimagemapeditor/drawzone.cpp192
1 files changed, 96 insertions, 96 deletions
diff --git a/kimagemapeditor/drawzone.cpp b/kimagemapeditor/drawzone.cpp
index a5bf5612..60b6fe9f 100644
--- a/kimagemapeditor/drawzone.cpp
+++ b/kimagemapeditor/drawzone.cpp
@@ -16,10 +16,10 @@
***************************************************************************/
// QT
-#include <qbitmap.h>
-#include <qpainter.h>
-#include <qdragobject.h>
-#include <qpixmap.h>
+#include <tqbitmap.h>
+#include <tqpainter.h>
+#include <tqdragobject.h>
+#include <tqpixmap.h>
// KDE
#include <kdebug.h>
@@ -37,11 +37,11 @@
#include "kimecommon.h"
-DrawZone::DrawZone(QWidget *parent,KImageMapEditor* _imageMapEditor)
- : QScrollView(parent)
+DrawZone::DrawZone(TQWidget *parent,KImageMapEditor* _imageMapEditor)
+ : TQScrollView(parent)
{
imageMapEditor=_imageMapEditor;
-// setPicture(QImage());
+// setPicture(TQImage());
currentAction=None;
currentArea=0L;
oldArea=0L;
@@ -57,9 +57,9 @@ DrawZone::DrawZone(QWidget *parent,KImageMapEditor* _imageMapEditor)
setDragAutoScroll(true);
// The cross rectangle cursor
- QBitmap b(32,32,true);
- QBitmap b2(32,32,true);
- QPainter p(&b);
+ TQBitmap b(32,32,true);
+ TQBitmap b2(32,32,true);
+ TQPainter p(&b);
// the cross
p.drawLine(0,8,6,8);
p.drawLine(10,8,16,8);
@@ -96,12 +96,12 @@ DrawZone::DrawZone(QWidget *parent,KImageMapEditor* _imageMapEditor)
p.end();
- RectangleCursor = QCursor(b,b2,8,8);
+ RectangleCursor = TQCursor(b,b2,8,8);
// The cross circle cursor
- b = QBitmap(32,32,true);
- b2 = QBitmap(32,32,true);
+ b = TQBitmap(32,32,true);
+ b2 = TQBitmap(32,32,true);
p.begin(&b);
// the cross
p.drawLine(0,8,6,8);
@@ -139,25 +139,25 @@ DrawZone::DrawZone(QWidget *parent,KImageMapEditor* _imageMapEditor)
p.end();
- CircleCursor = QCursor(b,b2,8,8);
+ CircleCursor = TQCursor(b,b2,8,8);
- QString path = KGlobal::dirs()->findResourceDir( "data", "kimagemapeditor/polygoncursor.png" ) + "kimagemapeditor/polygoncursor.png";
- PolygonCursor = QCursor(QPixmap(path),8,8);
+ TQString path = KGlobal::dirs()->findResourceDir( "data", "kimagemapeditor/polygoncursor.png" ) + "kimagemapeditor/polygoncursor.png";
+ PolygonCursor = TQCursor(TQPixmap(path),8,8);
path = KGlobal::dirs()->findResourceDir( "data", "kimagemapeditor/freehandcursor.png" ) + "kimagemapeditor/freehandcursor.png";
- FreehandCursor = QCursor(QPixmap(path),8,8);
+ FreehandCursor = TQCursor(TQPixmap(path),8,8);
path = KGlobal::dirs()->findResourceDir( "data", "kimagemapeditor/addpointcursor.png" ) + "kimagemapeditor/addpointcursor.png";
- AddPointCursor = QCursor(QPixmap(path),8,8);
+ AddPointCursor = TQCursor(TQPixmap(path),8,8);
path = KGlobal::dirs()->findResourceDir( "data", "kimagemapeditor/removepointcursor.png" ) + "kimagemapeditor/removepointcursor.png";
- RemovePointCursor = QCursor(QPixmap(path),8,8);
+ RemovePointCursor = TQCursor(TQPixmap(path),8,8);
}
DrawZone::~DrawZone(){
}
-void DrawZone::setPicture(const QImage &_image) {
+void DrawZone::setPicture(const TQImage &_image) {
image=_image;
//- zoomedImage.convertFromImage(image);
setZoom(_zoom);
@@ -168,22 +168,22 @@ void DrawZone::setZoom(double z)
_zoom=z;
imageRect.setHeight(myround(image.height()*_zoom));
imageRect.setWidth(myround(image.width()*_zoom));
- zoomedImage=QPixmap(imageRect.width(),imageRect.height());
- QPainter p(&zoomedImage);
+ zoomedImage=TQPixmap(imageRect.width(),imageRect.height());
+ TQPainter p(&zoomedImage);
p.scale(z,z);
- QPixmap pix;
+ TQPixmap pix;
pix.convertFromImage(image);
// if the picture has transparent areas,
// fill them with Gimp like background
if (pix.mask()) {
- QPixmap backPix(32,32);
- QPainter p2(&backPix);
- p2.fillRect(0,0,32,32,QColor(156,149,156));
- p2.fillRect(0,16,16,16,QColor(98,105,98));
- p2.fillRect(16,0,16,16,QColor(98,105,98));
+ TQPixmap backPix(32,32);
+ TQPainter p2(&backPix);
+ p2.fillRect(0,0,32,32,TQColor(156,149,156));
+ p2.fillRect(0,16,16,16,TQColor(98,105,98));
+ p2.fillRect(16,0,16,16,TQColor(98,105,98));
p2.flush();
- p.setPen(QPen());
- p.fillRect(imageRect.left(),imageRect.top(),imageRect.width(),imageRect.height(),QBrush(QColor("black"),backPix));
+ p.setPen(TQPen());
+ p.fillRect(imageRect.left(),imageRect.top(),imageRect.width(),imageRect.height(),TQBrush(TQColor("black"),backPix));
}
p.drawPixmap(imageRect.left(),imageRect.top(),pix);
p.flush();
@@ -192,31 +192,31 @@ void DrawZone::setZoom(double z)
repaintContents(0,0,contentsWidth(),contentsHeight(),true);
}
-QPoint DrawZone::translateFromZoom(const QPoint & p) const {
- return QPoint((int)(p.x()/_zoom),(int)(p.y()/_zoom));
+TQPoint DrawZone::translateFromZoom(const TQPoint & p) const {
+ return TQPoint((int)(p.x()/_zoom),(int)(p.y()/_zoom));
}
-QRect DrawZone::translateFromZoom(const QRect & p) const {
- return QRect((int)(p.x()/_zoom),(int) (p.y()/_zoom),
+TQRect DrawZone::translateFromZoom(const TQRect & p) const {
+ return TQRect((int)(p.x()/_zoom),(int) (p.y()/_zoom),
(int)(p.width()/_zoom),(int)(p.height()/_zoom));
}
-QPoint DrawZone::translateToZoom(const QPoint & p) const {
- return QPoint(myround(p.x()*_zoom),myround(p.y()*_zoom));
+TQPoint DrawZone::translateToZoom(const TQPoint & p) const {
+ return TQPoint(myround(p.x()*_zoom),myround(p.y()*_zoom));
}
-QRect DrawZone::translateToZoom(const QRect & r) const {
-// return QRect(round(r.x()*_zoom),round(r.y()*_zoom),
+TQRect DrawZone::translateToZoom(const TQRect & r) const {
+// return TQRect(round(r.x()*_zoom),round(r.y()*_zoom),
// round(r.width()*_zoom),round(r.height()*_zoom));
- return QRect((int)(r.x()*_zoom),(int)(r.y()*_zoom),
+ return TQRect((int)(r.x()*_zoom),(int)(r.y()*_zoom),
(int)(r.width()*_zoom+2),(int)(r.height()*_zoom+2));
}
-void DrawZone::contentsMouseDoubleClickEvent(QMouseEvent* e) {
+void DrawZone::contentsMouseDoubleClickEvent(TQMouseEvent* e) {
if ( ! imageMapEditor->isReadWrite())
return;
- QPoint point=e->pos();
+ TQPoint point=e->pos();
point-=imageRect.topLeft();
point=translateFromZoom(point);
if ( currentAction==None &&
@@ -230,7 +230,7 @@ void DrawZone::contentsMouseDoubleClickEvent(QMouseEvent* e) {
}
-void DrawZone::contentsMousePressEvent(QMouseEvent* e)
+void DrawZone::contentsMousePressEvent(TQMouseEvent* e)
{
if ( ! imageMapEditor->isReadWrite())
return;
@@ -251,7 +251,7 @@ void DrawZone::contentsMousePressEvent(QMouseEvent* e)
// Translate it to picture coordinates
drawStart-=imageRect.topLeft();
- QPoint zoomedPoint = drawStart;
+ TQPoint zoomedPoint = drawStart;
drawStart=translateFromZoom(drawStart);
delete oldArea;
oldArea=0L;
@@ -339,7 +339,7 @@ void DrawZone::contentsMousePressEvent(QMouseEvent* e)
{
currentArea=AreaCreator::create(imageMapEditor->currentToolType());
- currentArea->setRect(QRect(drawStart,drawStart));
+ currentArea->setRect(TQRect(drawStart,drawStart));
currentArea->setSelected(false);
imageMapEditor->deselectAll();
@@ -374,7 +374,7 @@ void DrawZone::contentsMousePressEvent(QMouseEvent* e)
}
- QRect r;
+ TQRect r;
if (oldArea)
r=oldArea->selectionRect();
if (currentArea) {
@@ -385,11 +385,11 @@ void DrawZone::contentsMousePressEvent(QMouseEvent* e)
}
-void DrawZone::contentsMouseReleaseEvent(QMouseEvent *e) {
+void DrawZone::contentsMouseReleaseEvent(TQMouseEvent *e) {
if ( ! imageMapEditor->isReadWrite())
return;
- QPoint drawEnd=e->pos();
+ TQPoint drawEnd=e->pos();
// Check if it's on picture if not
// move it to the picture's border
@@ -405,7 +405,7 @@ void DrawZone::contentsMouseReleaseEvent(QMouseEvent *e) {
}
// Translate it to picture coordinates
drawEnd-=imageRect.topLeft();
- QPoint zoomedPoint=drawEnd;
+ TQPoint zoomedPoint=drawEnd;
drawEnd=translateFromZoom(drawEnd);
@@ -441,8 +441,8 @@ void DrawZone::contentsMouseReleaseEvent(QMouseEvent *e) {
new CreateCommand( imageMapEditor, currentArea ), true);
} else
if (currentAction==MoveArea) {
- QPoint p1 = oldArea->rect().topLeft();
- QPoint p2 = imageMapEditor->selected()->rect().topLeft();
+ TQPoint p1 = oldArea->rect().topLeft();
+ TQPoint p2 = imageMapEditor->selected()->rect().topLeft();
if (p1 != p2)
{
@@ -484,7 +484,7 @@ void DrawZone::contentsMouseReleaseEvent(QMouseEvent *e) {
if (currentAction==DoSelect) {
currentAction=None;
- QRect r(drawStart.x(),drawStart.y(),drawCurrent.x()-drawStart.x(),drawCurrent.y()-drawStart.y());
+ TQRect r(drawStart.x(),drawStart.y(),drawCurrent.x()-drawStart.x(),drawCurrent.y()-drawStart.y());
r = r.normalize();
AreaListIterator it=imageMapEditor->areaList();
@@ -518,7 +518,7 @@ void DrawZone::contentsMouseReleaseEvent(QMouseEvent *e) {
}
-void DrawZone::contentsMouseMoveEvent(QMouseEvent *e)
+void DrawZone::contentsMouseMoveEvent(TQMouseEvent *e)
{
if ( ! imageMapEditor->isReadWrite())
return;
@@ -541,20 +541,20 @@ void DrawZone::contentsMouseMoveEvent(QMouseEvent *e)
// Translate to image coordinates
drawCurrent-=imageRect.topLeft();
- QPoint zoomedPoint=drawCurrent;
+ TQPoint zoomedPoint=drawCurrent;
drawCurrent=translateFromZoom(drawCurrent);
if (currentAction==DrawRectangle) {
// To avoid flicker, only repaint the minimum rect
- QRect oldRect=translateToZoom(currentArea->rect());
- currentArea->setRect(QRect(drawStart,drawCurrent).normalize());
- QRect newRect=translateToZoom(currentArea->selectionRect());
- QRect r=oldRect | newRect;
+ TQRect oldRect=translateToZoom(currentArea->rect());
+ currentArea->setRect(TQRect(drawStart,drawCurrent).normalize());
+ TQRect newRect=translateToZoom(currentArea->selectionRect());
+ TQRect r=oldRect | newRect;
repaintContents(r,false);
imageMapEditor->slotUpdateSelectionCoords( currentArea->rect() );
} else
if (currentAction==DrawCircle) {
- QRect oldRect=translateToZoom(currentArea->rect());
+ TQRect oldRect=translateToZoom(currentArea->rect());
// We don't want ellipses
int maxDistance=myabs(drawStart.x()-drawCurrent.x()) >
@@ -571,49 +571,49 @@ void DrawZone::contentsMouseMoveEvent(QMouseEvent *e)
if ( drawStart.y()-drawCurrent.y() > 0)
yDiff=-yDiff;
- QPoint endPoint( drawStart.x()+xDiff, drawStart.y()+yDiff);
+ TQPoint endPoint( drawStart.x()+xDiff, drawStart.y()+yDiff);
- currentArea->setRect(QRect(drawStart,endPoint).normalize());
- QRect newRect=translateToZoom(currentArea->rect());
- QRect r=oldRect | newRect;
+ currentArea->setRect(TQRect(drawStart,endPoint).normalize());
+ TQRect newRect=translateToZoom(currentArea->rect());
+ TQRect r=oldRect | newRect;
repaintContents(r,false);
imageMapEditor->slotUpdateSelectionCoords( currentArea->rect() );
} else
if ( currentAction==DrawPolygon ) {
- QRect oldRect=translateToZoom(currentArea->rect());
+ TQRect oldRect=translateToZoom(currentArea->rect());
currentArea->moveSelectionPoint(currentSelectionPoint,drawCurrent);
- QRect newRect=translateToZoom(currentArea->rect());
- QRect r=oldRect | newRect;
+ TQRect newRect=translateToZoom(currentArea->rect());
+ TQRect r=oldRect | newRect;
repaintContents(r,false);
} else
if ( currentAction==DrawFreehand) {
- QRect oldRect=translateToZoom(currentArea->rect());
+ TQRect oldRect=translateToZoom(currentArea->rect());
currentArea->insertCoord(currentArea->countSelectionPoints(), drawCurrent);
- QRect newRect=translateToZoom(currentArea->rect());
- QRect r=oldRect | newRect;
+ TQRect newRect=translateToZoom(currentArea->rect());
+ TQRect r=oldRect | newRect;
repaintContents(r,false);
} else
if ( currentAction==MoveArea ) {
- QRect oldRect=translateToZoom(currentArea->selectionRect());
+ TQRect oldRect=translateToZoom(currentArea->selectionRect());
currentArea->moveBy((drawCurrent-drawStart).x(),(drawCurrent-drawStart).y());
- QRect newRect=translateToZoom(currentArea->selectionRect());
- QRect r=oldRect | newRect;
+ TQRect newRect=translateToZoom(currentArea->selectionRect());
+ TQRect r=oldRect | newRect;
currentArea->setMoving(true);
repaintContents(r,false);
drawStart=drawCurrent;
imageMapEditor->slotUpdateSelectionCoords();
} else
if ( currentAction==MoveSelectionPoint ) {
- QRect oldRect=translateToZoom(currentArea->selectionRect());
+ TQRect oldRect=translateToZoom(currentArea->selectionRect());
currentArea->moveSelectionPoint(currentSelectionPoint,drawCurrent);
- QRect newRect=translateToZoom(currentArea->selectionRect());
- QRect r=oldRect | newRect;
+ TQRect newRect=translateToZoom(currentArea->selectionRect());
+ TQRect r=oldRect | newRect;
repaintContents(r,false);
imageMapEditor->slotUpdateSelectionCoords();
} else
if (currentAction==DoSelect) {
- QRect r(drawStart.x(),drawStart.y(),drawCurrent.x()-drawStart.x(),drawCurrent.y()-drawStart.y());
+ TQRect r(drawStart.x(),drawStart.y(),drawCurrent.x()-drawStart.x(),drawCurrent.y()-drawStart.y());
r = r.normalize();
// r = translateFromZoom(r);
/*
@@ -634,7 +634,7 @@ void DrawZone::contentsMouseMoveEvent(QMouseEvent *e)
// So we have to create 4 rectangles for every rectangle
// which represent the borders and then repaint them.
- QRect lb,rb,tb,bb;
+ TQRect lb,rb,tb,bb;
createBorderRectangles(translateToZoom(r),lb,rb,tb,bb);
repaintContents(lb,false);
repaintContents(rb,false);
@@ -653,9 +653,9 @@ void DrawZone::contentsMouseMoveEvent(QMouseEvent *e)
//+ imageMapEditor->updateSelection();
-// QRect r(drawStart.x(),drawStart.y(),drawCurrent.x()-drawStart.x(),drawCurrent.y()-drawStart.y());
+// TQRect r(drawStart.x(),drawStart.y(),drawCurrent.x()-drawStart.x(),drawCurrent.y()-drawStart.y());
// r = r.normalize();
-// QRect r2(drawStart.x(),drawStart.y(),drawOld.x()-drawStart.x(),drawOld.y()-drawStart.y());
+// TQRect r2(drawStart.x(),drawStart.y(),drawOld.x()-drawStart.x(),drawOld.y()-drawStart.y());
// r2 = r2.normalize();
// r = translateToZoom(r | r2);
// repaintContents(r,false);
@@ -679,7 +679,7 @@ void DrawZone::contentsMouseMoveEvent(QMouseEvent *e)
}
else
{
- QPoint center=imageMapEditor->selected()->rect().center();
+ TQPoint center=imageMapEditor->selected()->rect().center();
if (drawCurrent.x() < center.x()) {
if (drawCurrent.y() < center.y())
viewport()->setCursor(sizeFDiagCursor);
@@ -726,7 +726,7 @@ void DrawZone::contentsMouseMoveEvent(QMouseEvent *e)
imageMapEditor->slotChangeStatusCoords(drawCurrent.x(),drawCurrent.y());
}
-void DrawZone::createBorderRectangles(const QRect & r,QRect & rb,QRect & lb,QRect & tb,QRect & bb)
+void DrawZone::createBorderRectangles(const TQRect & r,TQRect & rb,TQRect & lb,TQRect & tb,TQRect & bb)
{
int bw;
bw = (int) (2+2*_zoom); // Border width
@@ -753,8 +753,8 @@ void DrawZone::createBorderRectangles(const QRect & r,QRect & rb,QRect & lb,QRec
}
-void DrawZone::resizeEvent(QResizeEvent* e) {
- QScrollView::resizeEvent(e);
+void DrawZone::resizeEvent(TQResizeEvent* e) {
+ TQScrollView::resizeEvent(e);
int width=(int) (image.width()*_zoom);
int height=(int) (image.height()*_zoom);
if (visibleWidth()>width)
@@ -779,7 +779,7 @@ void DrawZone::cancelDrawing()
)
{
currentAction = None;
- QRect r = translateToZoom(currentArea->selectionRect());
+ TQRect r = translateToZoom(currentArea->selectionRect());
delete currentArea;
currentArea = 0L;
repaintContents(r,false);
@@ -791,39 +791,39 @@ void DrawZone::repaintArea(const Area & a) {
repaintContents(translateToZoom(a.selectionRect()),false);
}
-void DrawZone::repaintRect(const QRect & r) {
+void DrawZone::repaintRect(const TQRect & r) {
repaintContents(translateToZoom(r),false);
}
-void DrawZone::drawContents(QPainter* p,int clipx,int clipy,int clipw,int cliph)
+void DrawZone::drawContents(TQPainter* p,int clipx,int clipy,int clipw,int cliph)
{
// Erase background without flicker
- QRect updateRect(clipx,clipy,clipw,cliph);
+ TQRect updateRect(clipx,clipy,clipw,cliph);
// Pixmap for double-buffering
- QPixmap doubleBuffer(updateRect.size());
+ TQPixmap doubleBuffer(updateRect.size());
if (doubleBuffer.isNull())
return;
- QPainter p2(&doubleBuffer);
+ TQPainter p2(&doubleBuffer);
p2.drawPixmap(0,0,zoomedImage,clipx,clipy,clipw,cliph);
p2.setBackgroundColor(p->backgroundColor());
if (zoomedImage.width() < (clipw+clipx) ) {
int eraseWidth = clipw+clipx - zoomedImage.width();
- p2.eraseRect( QRect(clipw-eraseWidth,0,eraseWidth,cliph) );
+ p2.eraseRect( TQRect(clipw-eraseWidth,0,eraseWidth,cliph) );
}
if (zoomedImage.height() < (cliph+clipy) ) {
int eraseHeight = cliph+clipy - zoomedImage.height();
- p2.eraseRect( QRect(0,cliph-eraseHeight,clipw,eraseHeight) );
+ p2.eraseRect( TQRect(0,cliph-eraseHeight,clipw,eraseHeight) );
}
p2.translate(-clipx, -clipy);
p2.scale(_zoom,_zoom);
- QRect areaUpdateRect;
+ TQRect areaUpdateRect;
areaUpdateRect.setX(myround(clipx/_zoom)-1);
areaUpdateRect.setY(myround(clipy/_zoom)-1);
areaUpdateRect.setWidth(myround(clipw/_zoom)+2);
@@ -847,12 +847,12 @@ void DrawZone::drawContents(QPainter* p,int clipx,int clipy,int clipw,int cliph)
if (currentAction == DoSelect )
{
- QPen pen = QPen(QColor("white"),1);
+ TQPen pen = TQPen(TQColor("white"),1);
p2.setRasterOp(Qt::XorROP);
pen.setStyle(Qt::DotLine);
p2.setPen(pen);
- QRect r( drawStart.x(),drawStart.y(),drawCurrent.x()-drawStart.x(),drawCurrent.y()-drawStart.y());
+ TQRect r( drawStart.x(),drawStart.y(),drawCurrent.x()-drawStart.x(),drawCurrent.y()-drawStart.y());
r = r.normalize();
p2.drawRect(r);
}
@@ -867,7 +867,7 @@ void DrawZone::drawContents(QPainter* p,int clipx,int clipy,int clipw,int cliph)
}
-void DrawZone::contentsDragEnterEvent(QDragEnterEvent*e) {
+void DrawZone::contentsDragEnterEvent(TQDragEnterEvent*e) {
if (!KURLDrag::canDecode(e))
return;
@@ -881,13 +881,13 @@ void DrawZone::contentsDragEnterEvent(QDragEnterEvent*e) {
e->accept();
}
-void DrawZone::contentsDropEvent( QDropEvent* e) {
+void DrawZone::contentsDropEvent( TQDropEvent* e) {
viewportDropEvent(e);
}
-void DrawZone::viewportDropEvent( QDropEvent* e) {
+void DrawZone::viewportDropEvent( TQDropEvent* e) {
KURL::List urlList;
// A file from konqueror was dropped
if (KURLDrag::decode(e,urlList)) {