kivio

kivio_stencil_geometry_panel.cpp
1#include "kivio_stencil_geometry_panel.h"
2
3#include <tqlayout.h>
4#include <tqlabel.h>
5#include <tqpixmap.h>
6
7#include <knuminput.h>
8#include <tdelocale.h>
9#include <kdialog.h>
10
11#include <KoPageLayout.h>
12#include <KoUnitWidgets.h>
13
14KivioStencilGeometryPanel::KivioStencilGeometryPanel(TQWidget* parent)
15: TQWidget(parent,"KivioStencilGeometryPanel")
16{
17 TQGridLayout* grid = new TQGridLayout(this, 4, 2, 0, 2);
18
19 TQLabel* lx = new TQLabel(i18n("X:"), this);
20 TQLabel* ly = new TQLabel(i18n("Y:"), this);
21 TQLabel* lw = new TQLabel(i18n("Width:"), this);
22 TQLabel* lh = new TQLabel(i18n("Height:"), this);
23// TQLabel *rotationLbl = new TQLabel(this);
24
25 m_pX = new KoUnitDoubleSpinBox(this, 0.0, 1000.0, 0.5, 0.0);
26 m_pY = new KoUnitDoubleSpinBox(this, 0.0, 1000.0, 0.5, 0.0);
27 m_pW = new KoUnitDoubleSpinBox(this, 0.0, 1000.0, 0.5, 0.0);
28 m_pH = new KoUnitDoubleSpinBox(this, 0.0, 1000.0, 0.5, 0.0);
29// m_rotationSBox = new KIntSpinBox(-360, 360, 1, 0, 10, this);
30// m_rotationSBox->hide();
31
32 connect(m_pX, TQ_SIGNAL(valueChanged(double)), TQ_SLOT(xChange(double)));
33 connect(m_pY, TQ_SIGNAL(valueChanged(double)), TQ_SLOT(yChange(double)));
34 connect(m_pW, TQ_SIGNAL(valueChanged(double)), TQ_SLOT(wChange(double)));
35 connect(m_pH, TQ_SIGNAL(valueChanged(double)), TQ_SLOT(hChange(double)));
36// connect(m_rotationSBox, TQ_SIGNAL(valueChanged(int)), TQ_SLOT(rotationChange(int)));
37
38 grid->addWidget(lx, 0, 0);
39 grid->addWidget(m_pX, 1, 0);
40
41 grid->addWidget(ly, 0, 1);
42 grid->addWidget(m_pY, 1, 1);
43
44 grid->addWidget(lw, 2, 0);
45 grid->addWidget(m_pW, 3, 0);
46
47 grid->addWidget(lh, 2, 1);
48 grid->addWidget(m_pH, 3, 1);
49
50 grid->setRowStretch(4, 10);
51
52// grid->addWidget(rotationLbl, 4, 0);
53// grid->addWidget(m_rotationSBox, 4, 1);
54
55 m_unit = KoUnit::U_PT;
56 m_emitSignals = true;
57}
58
59KivioStencilGeometryPanel::~KivioStencilGeometryPanel()
60{
61}
62
63void KivioStencilGeometryPanel::setUnit( KoUnit::Unit m )
64{
65 bool oldEmitSignals = m_emitSignals;
66 m_emitSignals = false;
67 m_pX->setUnit(m);
68 m_pY->setUnit(m);
69 m_pW->setUnit(m);
70 m_pH->setUnit(m);
71 m_unit = m;
72 m_emitSignals = oldEmitSignals;
73}
74
75void KivioStencilGeometryPanel::xChange( double d )
76{
77 if(m_emitSignals) {
78 emit positionChanged( KoUnit::fromUserValue(d, m_unit), m_pY->value() );
79 }
80}
81
82void KivioStencilGeometryPanel::yChange( double d )
83{
84 if(m_emitSignals) {
85 emit positionChanged( m_pX->value(), KoUnit::fromUserValue(d, m_unit) );
86 }
87}
88
89void KivioStencilGeometryPanel::wChange( double d )
90{
91 if(m_emitSignals) {
92 emit sizeChanged( KoUnit::fromUserValue(d, m_unit), m_pH->value() );
93 }
94}
95
96void KivioStencilGeometryPanel::hChange( double d )
97{
98 if(m_emitSignals) {
99 emit sizeChanged( m_pW->value(), KoUnit::fromUserValue(d, m_unit) );
100 }
101}
102
103void KivioStencilGeometryPanel::rotationChange(int d)
104{
105 if(m_emitSignals) {
106 emit rotationChanged(d);
107 }
108}
109
110void KivioStencilGeometryPanel::setPosition( double x, double y )
111{
112 m_pX->changeValue(x);
113 m_pY->changeValue(y);
114}
115
116void KivioStencilGeometryPanel::setSize( double w, double h )
117{
118 m_pW->changeValue(w);
119 m_pH->changeValue(h);
120}
121
122void KivioStencilGeometryPanel::setPageLayout(const KoPageLayout& l)
123{
124 m_pX->setMaxValue(l.ptWidth);
125 m_pY->setMaxValue(l.ptHeight);
126}
127
128void KivioStencilGeometryPanel::setRotation(int /*d*/)
129{
130// m_rotationSBox->setValue(d);
131}
132
133void KivioStencilGeometryPanel::setEmitSignals(bool e)
134{
135 m_emitSignals = e;
136}
137
138#include "kivio_stencil_geometry_panel.moc"