F:/KPlato/koffice/libs/kofficeui/KoShapeGeometry.cpp

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002  * Copyright (C) 2006 Thomas Zander <zander@kde.org>
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public License
00015  * along with this library; see the file COPYING.LIB.  If not, write to
00016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018  */
00019 #include "KoShapeGeometry.h"
00020 
00021 #include <KoShape.h>
00022 #include <klocale.h>
00023 
00024 KoShapeGeometry::KoShapeGeometry()
00025     : m_shape(0)
00026 {
00027     widget.setupUi(this);
00028     setObjectName(i18n("Geometry"));
00029     widget.left->setMinimum(0.0);
00030     widget.top->setMinimum(0.0);
00031     widget.width->setMinimum(0.0);
00032     widget.height->setMinimum(0.0);
00033 }
00034 
00035 KoShapeGeometry::~KoShapeGeometry() {
00036 }
00037 
00038 void KoShapeGeometry::open(KoShape *shape) {
00039     m_shape = shape;
00040     mOriginalPosition = shape->absolutePosition();
00041     mOriginalSize = shape->size();
00042     widget.left->changeValue(mOriginalPosition.x());
00043     widget.top->changeValue(mOriginalPosition.y());
00044     widget.width->changeValue(mOriginalSize.width());
00045     widget.height->changeValue(mOriginalSize.height());
00046 
00047     connect(widget.protectSize, SIGNAL(stateChanged(int)),
00048             this, SLOT(protectSizeChanged(int)));
00049 
00050     if (shape->isLocked()) {
00051         widget.protectSize->setCheckState(Qt::Checked);
00052     }
00053 
00054     connect(widget.left, SIGNAL(valueChanged(double)),
00055             this, SLOT(updateShape()));
00056     connect(widget.top, SIGNAL(valueChanged(double)),
00057             this, SLOT(updateShape()));
00058     connect(widget.width, SIGNAL(valueChanged(double)),
00059             this, SLOT(updateShape()));
00060     connect(widget.height, SIGNAL(valueChanged(double)),
00061             this, SLOT(updateShape()));
00062 }
00063 
00064 void KoShapeGeometry::updateShape() {
00065     m_shape->repaint();
00066     QPointF pos(widget.left->value(), widget.top->value());
00067     m_shape->setAbsolutePosition(pos);
00068     QSizeF size(widget.width->value(), widget.height->value());
00069     m_shape->resize(size);
00070     m_shape->repaint();
00071 }
00072 
00073 void KoShapeGeometry::protectSizeChanged(int protectSizeState) {
00074     bool lock = (protectSizeState == Qt::Checked);
00075     widget.left->setDisabled(lock);
00076     widget.top->setDisabled(lock);
00077     widget.width->setDisabled(lock);
00078     widget.height->setDisabled(lock);
00079 }
00080 
00081 void KoShapeGeometry::save() {
00082     bool lock = (widget.protectSize->checkState() == Qt::Checked);
00083     m_shape->setLocked(lock);
00084 }
00085 
00086 void KoShapeGeometry::cancel() {
00087     m_shape->setAbsolutePosition(mOriginalPosition);
00088     m_shape->resize(mOriginalSize);
00089 }
00090 
00091 KAction *KoShapeGeometry::createAction() {
00092     return 0; // TODO
00093 }
00094 
00095 void KoShapeGeometry::setUnit(KoUnit::Unit unit) {
00096     widget.left->setUnit(unit);
00097     widget.top->setUnit(unit);
00098     widget.width->setUnit(unit);
00099     widget.height->setUnit(unit);
00100 }
00101 
00102 #include "KoShapeGeometry.moc"

Généré le Wed Nov 22 23:41:05 2006 pour KPlato par  doxygen 1.5.1-p1