summaryrefslogtreecommitdiffstats
path: root/kexi/formeditor/spring.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
commit8362bf63dea22bbf6736609b0f49c152f975eb63 (patch)
tree0eea3928e39e50fae91d4e68b21b1e6cbae25604 /kexi/formeditor/spring.cpp
downloadkoffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz
koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kexi/formeditor/spring.cpp')
-rw-r--r--kexi/formeditor/spring.cpp158
1 files changed, 158 insertions, 0 deletions
diff --git a/kexi/formeditor/spring.cpp b/kexi/formeditor/spring.cpp
new file mode 100644
index 00000000..e09cc2d7
--- /dev/null
+++ b/kexi/formeditor/spring.cpp
@@ -0,0 +1,158 @@
+/* This file is part of the KDE project
+ Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
+ Copyright (C) 2005 Jaroslaw Staniek <js@iidea.pl>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include <qsizepolicy.h>
+#include <qpainter.h>
+#include <qdom.h>
+#include <qvariant.h>
+
+#include <kdebug.h>
+
+#include "objecttree.h"
+#include "container.h"
+#include "form.h"
+#include "formIO.h"
+#include "widgetlibrary.h"
+
+#include "spring.h"
+
+Spring::Spring(QWidget *parent, const char *name)
+ : QWidget(parent, name)
+{
+ m_edit = true;
+ m_orient = Horizontal;
+ setSizeType((SizeType)QSizePolicy::Expanding);
+}
+
+void
+Spring::setOrientation(Orientation orient)
+{
+ SizeType type = sizeType();
+ m_orient = orient;
+ setSizeType(type);
+ repaint();
+}
+
+Spring::SizeType
+Spring::sizeType() const
+{
+ if(m_orient == Vertical)
+ return (SizeType)sizePolicy().verData();
+ else
+ return (SizeType)sizePolicy().horData();
+}
+
+void
+Spring::setSizeType(SizeType size)
+{
+ if(m_orient == Vertical)
+ setSizePolicy(QSizePolicy::Minimum, (QSizePolicy::SizeType)size);
+ else
+ setSizePolicy( (QSizePolicy::SizeType)size, QSizePolicy::Minimum);
+}
+
+void
+Spring::paintEvent(QPaintEvent *ev)
+{
+ if(!m_edit)
+ return;
+
+ QPainter p(this);
+ if(!ev->erased())
+ p.eraseRect(0,0,width(), height());
+ p.setPen(QPen(Qt::white, 1));
+ p.setRasterOp(Qt::XorROP);
+ QPointArray pa(4);
+ if(m_orient == Vertical) {
+ uint part = (height()+16) / 16;
+ if (part<3)
+ part=3;
+ uint w = width()-1;
+ uint offset = 0;
+ for (uint i=0; i<4; i++, offset+=(part*4)) {
+ pa.putPoints(0, 4,
+ w/2,offset, w,offset+part, w,offset+part, w/2,offset+part*2);
+ p.drawCubicBezier(pa, 0);
+ pa.putPoints(0, 4,
+ w/2,offset+part*2, 0,offset+part*3, 0,offset+part*3, w/2,offset+part*4);
+ p.drawCubicBezier(pa, 0);
+ }
+ }
+ else {
+ uint part = (width()+16) / 16;
+ if (part<3)
+ part=3;
+ uint h = height()-1;
+ uint offset = 0;
+ for (uint i=0; i<4; i++, offset+=(part*4)) {
+ pa.putPoints(0, 4,
+ offset,h/2, offset+part,0, offset+part,0, offset+part*2,h/2);
+ p.drawCubicBezier(pa, 0);
+ pa.putPoints(0, 4,
+ offset+part*2,h/2, offset+part*3,h, offset+part*3,h, offset+part*4,h/2);
+ p.drawCubicBezier(pa, 0);
+ }
+ }
+}
+
+bool
+Spring::isPropertyVisible(const QCString &name)
+{
+ if((name == "name") || (name == "sizeType") || (name == "orientation") || (name == "geometry"))
+ return true;
+
+ return false;
+}
+
+
+void
+Spring::saveSpring(KFormDesigner::ObjectTreeItem *item, QDomElement &parentNode, QDomDocument &domDoc, bool insideGridLayout)
+{
+ QDomElement tclass = domDoc.createElement("spacer");
+ parentNode.appendChild(tclass);
+
+ if(insideGridLayout)
+ {
+ tclass.setAttribute("row", item->gridRow());
+ tclass.setAttribute("column", item->gridCol());
+ if(item->spanMultipleCells())
+ {
+ tclass.setAttribute("rowspan", item->gridRowSpan());
+ tclass.setAttribute("colspan", item->gridColSpan());
+ }
+ }
+
+ KFormDesigner::FormIO::savePropertyValue(tclass, domDoc, "name", item->widget()->property("name"), item->widget());
+
+ if(parentNode.tagName() == "widget")
+ KFormDesigner::FormIO::savePropertyValue(tclass, domDoc, "geometry", item->widget()->property("geometry"), item->widget());
+
+ if(!item->widget()->sizeHint().isValid())
+ KFormDesigner::FormIO::savePropertyValue(tclass, domDoc, "sizeHint", item->widget()->property("size"), item->widget());
+ else
+ KFormDesigner::FormIO::savePropertyValue(tclass, domDoc, "sizeHint", item->widget()->property("sizeHint"), item->widget());
+
+ KFormDesigner::FormIO::savePropertyValue(tclass, domDoc, "orientation", item->widget()->property("orientation"), item->widget());
+ KFormDesigner::FormIO::savePropertyValue(tclass, domDoc, "sizeType", item->widget()->property("sizeType"), item->widget());
+}
+
+
+#include "spring.moc"
+