libs/flake

KoCreateShapesTool.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002  *
00003  * Copyright (C) 2006-2007 Thomas Zander <zander@kde.org>
00004  * Copyright (C) 2006 Thorsten Zachmann <zachmann@kde.org>
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Library General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Library General Public License
00017  * along with this library; see the file COPYING.LIB.  If not, write to
00018  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020  */
00021 
00022 #include "KoCreateShapesTool.h"
00023 
00024 #include <QMouseEvent>
00025 #include <QPainter>
00026 
00027 #include "KoPointerEvent.h"
00028 #include "KoInteractionStrategy.h"
00029 #include "KoCreateShapeStrategy.h"
00030 
00031 
00032 class KoCreateShapesTool::Private
00033 {
00034 public:
00035     Private() : newShapeProperties(0) {}
00036 
00037     QString shapeId;
00038     KoProperties *newShapeProperties;
00039 };
00040 
00041 KoCreateShapesTool::KoCreateShapesTool(KoCanvasBase *canvas)
00042         : KoInteractionTool(canvas),
00043         d(new Private())
00044 {
00045 }
00046 
00047 KoCreateShapesTool::~KoCreateShapesTool()
00048 {
00049     delete d;
00050 }
00051 
00052 void KoCreateShapesTool::paint(QPainter &painter, const KoViewConverter &converter)
00053 {
00054     if (m_currentStrategy)
00055         m_currentStrategy->paint(painter, converter);
00056 }
00057 
00058 void KoCreateShapesTool::mouseReleaseEvent(KoPointerEvent *event)
00059 {
00060     KoInteractionTool::mouseReleaseEvent(event);
00061     emit KoTool::done();
00062 }
00063 
00064 void KoCreateShapesTool::activate(bool)
00065 {
00066     useCursor(Qt::ArrowCursor, true);
00067 }
00068 
00069 void KoCreateShapesTool::setShapeId(const QString &id)
00070 {
00071     d->shapeId = id;
00072 }
00073 
00074 const QString &KoCreateShapesTool::shapeId() const
00075 {
00076     return d->shapeId;
00077 }
00078 
00079 void KoCreateShapesTool::setShapeProperties(KoProperties *properties)
00080 {
00081     d->newShapeProperties = properties;
00082 }
00083 
00084 KoProperties const * KoCreateShapesTool::shapeProperties()
00085 {
00086     return d->newShapeProperties;
00087 }
00088 
00089 KoInteractionStrategy *KoCreateShapesTool::createStrategy(KoPointerEvent *event)
00090 {
00091     return new KoCreateShapeStrategy(this, m_canvas, event->point);
00092 }
00093