kivio

kivio_stencil_geometry_panel.cpp

00001 #include "kivio_stencil_geometry_panel.h"
00002 
00003 #include <qlayout.h>
00004 #include <qlabel.h>
00005 #include <qpixmap.h>
00006 
00007 #include <knuminput.h>
00008 #include <klocale.h>
00009 #include <kdialog.h>
00010 
00011 #include <KoPageLayout.h>
00012 #include <KoUnitWidgets.h>
00013 
00014 KivioStencilGeometryPanel::KivioStencilGeometryPanel(QWidget* parent)
00015 : QWidget(parent,"KivioStencilGeometryPanel")
00016 {
00017   QGridLayout* grid = new QGridLayout(this, 4, 2, 0, 2);
00018 
00019   QLabel* lx = new QLabel(i18n("X:"), this);
00020   QLabel* ly = new QLabel(i18n("Y:"), this);
00021   QLabel* lw = new QLabel(i18n("Width:"), this);
00022   QLabel* lh = new QLabel(i18n("Height:"), this);
00023 //   QLabel *rotationLbl = new QLabel(this);
00024 
00025   m_pX = new KoUnitDoubleSpinBox(this, 0.0, 1000.0, 0.5, 0.0);
00026   m_pY = new KoUnitDoubleSpinBox(this, 0.0, 1000.0, 0.5, 0.0);
00027   m_pW = new KoUnitDoubleSpinBox(this, 0.0, 1000.0, 0.5, 0.0);
00028   m_pH = new KoUnitDoubleSpinBox(this, 0.0, 1000.0, 0.5, 0.0);
00029 //   m_rotationSBox = new KIntSpinBox(-360, 360, 1, 0, 10, this);
00030 //   m_rotationSBox->hide();
00031 
00032   connect(m_pX, SIGNAL(valueChanged(double)), SLOT(xChange(double)));
00033   connect(m_pY, SIGNAL(valueChanged(double)), SLOT(yChange(double)));
00034   connect(m_pW, SIGNAL(valueChanged(double)), SLOT(wChange(double)));
00035   connect(m_pH, SIGNAL(valueChanged(double)), SLOT(hChange(double)));
00036 //  connect(m_rotationSBox, SIGNAL(valueChanged(int)), SLOT(rotationChange(int)));
00037 
00038   grid->addWidget(lx, 0, 0);
00039   grid->addWidget(m_pX, 1, 0);
00040 
00041   grid->addWidget(ly, 0, 1);
00042   grid->addWidget(m_pY, 1, 1);
00043 
00044   grid->addWidget(lw, 2, 0);
00045   grid->addWidget(m_pW, 3, 0);
00046 
00047   grid->addWidget(lh, 2, 1);
00048   grid->addWidget(m_pH, 3, 1);
00049 
00050   grid->setRowStretch(4, 10);
00051 
00052 //   grid->addWidget(rotationLbl, 4, 0);
00053 //   grid->addWidget(m_rotationSBox, 4, 1);
00054 
00055   m_unit = KoUnit::U_PT;
00056   m_emitSignals = true;
00057 }
00058 
00059 KivioStencilGeometryPanel::~KivioStencilGeometryPanel()
00060 {
00061 }
00062 
00063 void KivioStencilGeometryPanel::setUnit( KoUnit::Unit m )
00064 {
00065   bool oldEmitSignals = m_emitSignals;
00066   m_emitSignals = false;
00067   m_pX->setUnit(m);
00068   m_pY->setUnit(m);
00069   m_pW->setUnit(m);
00070   m_pH->setUnit(m);
00071   m_unit = m;
00072   m_emitSignals = oldEmitSignals;
00073 }
00074 
00075 void KivioStencilGeometryPanel::xChange( double d )
00076 {
00077   if(m_emitSignals) {
00078     emit positionChanged( KoUnit::fromUserValue(d, m_unit), m_pY->value() );
00079   }
00080 }
00081 
00082 void KivioStencilGeometryPanel::yChange( double d )
00083 {
00084   if(m_emitSignals) {
00085     emit positionChanged( m_pX->value(), KoUnit::fromUserValue(d, m_unit) );
00086   }
00087 }
00088 
00089 void KivioStencilGeometryPanel::wChange( double d )
00090 {
00091   if(m_emitSignals) {
00092     emit sizeChanged( KoUnit::fromUserValue(d, m_unit), m_pH->value() );
00093   }
00094 }
00095 
00096 void KivioStencilGeometryPanel::hChange( double d )
00097 {
00098   if(m_emitSignals) {
00099     emit sizeChanged( m_pW->value(), KoUnit::fromUserValue(d, m_unit) );
00100   }
00101 }
00102 
00103 void KivioStencilGeometryPanel::rotationChange(int d)
00104 {
00105   if(m_emitSignals) {
00106     emit rotationChanged(d);
00107   }
00108 }
00109 
00110 void KivioStencilGeometryPanel::setPosition( double x, double y )
00111 {
00112   m_pX->changeValue(x);
00113   m_pY->changeValue(y);
00114 }
00115 
00116 void KivioStencilGeometryPanel::setSize( double w, double h )
00117 {
00118   m_pW->changeValue(w);
00119   m_pH->changeValue(h);
00120 }
00121 
00122 void KivioStencilGeometryPanel::setPageLayout(const KoPageLayout& l)
00123 {
00124   m_pX->setMaxValue(l.ptWidth);
00125   m_pY->setMaxValue(l.ptHeight);
00126 }
00127 
00128 void KivioStencilGeometryPanel::setRotation(int /*d*/)
00129 {
00130 //   m_rotationSBox->setValue(d);
00131 }
00132 
00133 void KivioStencilGeometryPanel::setEmitSignals(bool e)
00134 {
00135   m_emitSignals = e;
00136 }
00137 
00138 #include "kivio_stencil_geometry_panel.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys