lib
pointedit.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "pointedit.h"
00022 #include "editoritem.h"
00023
00024 #include <qlabel.h>
00025 #include <qlayout.h>
00026 #include <qpainter.h>
00027 #include <qtooltip.h>
00028
00029 #include <kactivelabel.h>
00030 #include <klocale.h>
00031
00032
00033 #define POINTEDIT_MASK "%1,%2"
00034
00035 using namespace KoProperty;
00036
00037 PointEdit::PointEdit(Property *property, QWidget *parent, const char *name)
00038 : Widget(property, parent, name)
00039 {
00040 setHasBorders(false);
00041 m_edit = new KActiveLabel(this);
00042 m_edit->setFocusPolicy(NoFocus);
00043
00044 m_edit->setPaletteBackgroundColor(palette().active().base());
00045 m_edit->setWordWrap( QTextEdit::NoWrap );
00046
00047
00048 m_edit->setMinimumHeight(5);
00049 setEditor(m_edit);
00050
00051 }
00052
00053 PointEdit::~PointEdit()
00054 {}
00055
00056 QVariant
00057 PointEdit::value() const
00058 {
00059 return m_value;
00060 }
00061
00062 void
00063 PointEdit::setValue(const QVariant &value, bool emitChange)
00064 {
00065 m_value = value;
00066 m_edit->selectAll(false);
00067 m_edit->setText(QString(POINTEDIT_MASK).arg(value.toPoint().x()).arg(value.toPoint().y()));
00068 QToolTip::add(this, QString("%1, %2").arg(value.toPoint().x()).arg(value.toPoint().y()));
00069
00070 if (emitChange)
00071 emit valueChanged(this);
00072 }
00073
00074 void
00075 PointEdit::drawViewer(QPainter *p, const QColorGroup &cg, const QRect &r, const QVariant &value)
00076 {
00077 QRect rect(r);
00078 rect.setBottom(r.bottom()+1);
00079 Widget::drawViewer(p, cg, rect, QString(POINTEDIT_MASK).arg(value.toPoint().x()).arg(value.toPoint().y()));
00080
00081
00082
00083 }
00084
00085 void
00086 PointEdit::setReadOnlyInternal(bool readOnly)
00087 {
00088 Q_UNUSED(readOnly);
00089 }
00090
00091 #include "pointedit.moc"
|