28#include "KoUnitWidgets.h"
29#include "vselecttoolbar.h"
30#include "karbon_view.h"
31#include "karbon_part.h"
32#include "vselection.h"
33#include "vtransformcmd.h"
36VSelectToolBar::VSelectToolBar( KarbonView *view,
const char* name ) : TDEToolBar( view, name ), m_view( view )
38 setCaption( i18n(
"Object Properties" ) );
39 TQLabel *x_label =
new TQLabel( i18n(
"X:" ),
this,
"tde toolbar widget" );
40 insertWidget( 0, x_label->width(), x_label );
41 m_x =
new KoUnitDoubleSpinBox(
this, 0.0, 1000.0, 0.5 );
42 connect( m_x, TQ_SIGNAL( valueChanged(
double ) ),
this, TQ_SLOT( slotXChanged(
double ) ) );
43 insertWidget( 1, m_x->width(), m_x );
44 TQLabel *y_label =
new TQLabel( i18n(
"Y:" ),
this,
"tde toolbar widget" );
45 insertWidget( 2, y_label->width(), y_label );
46 m_y =
new KoUnitDoubleSpinBox(
this, 0.0, 1000.0, 0.5 );
47 connect( m_y, TQ_SIGNAL( valueChanged(
double ) ),
this, TQ_SLOT( slotYChanged(
double ) ) );
48 insertWidget( 3, m_y->width(), m_y );
51 TQLabel *w_label =
new TQLabel( i18n(
"selection width",
"Width:" ),
this,
"tde toolbar widget" );
52 insertWidget( 5, w_label->width(), w_label );
53 m_width =
new KoUnitDoubleSpinBox(
this, 0.0, 1000.0, 0.5 );
54 connect( m_width, TQ_SIGNAL( valueChanged(
double ) ),
this, TQ_SLOT( slotWidthChanged(
double ) ) );
55 insertWidget( 6, m_width->width(), m_width );
56 TQLabel *h_label =
new TQLabel( i18n(
"Height:" ),
this,
"tde toolbar widget" );
57 insertWidget( 7, h_label->width(), h_label );
58 m_height =
new KoUnitDoubleSpinBox(
this, 0.0, 1000.0, 0.5 );
59 connect( m_height, TQ_SIGNAL( valueChanged(
double ) ),
this, TQ_SLOT( slotHeightChanged(
double ) ) );
60 insertWidget( 8, m_height->width(), m_height );
62 connect( m_view, TQ_SIGNAL( selectionChange() ),
this, TQ_SLOT( slotSelectionChanged() ) );
65VSelectToolBar::~VSelectToolBar()
70VSelectToolBar::slotXChanged(
double newval )
72 double dx = newval - m_view->part()->document().selection()->boundingBox().topLeft().x();
73 m_view->part()->addCommand(
new VTranslateCmd( &m_view->part()->document(), dx, 0.0 ),
true );
77VSelectToolBar::slotYChanged(
double newval )
79 double dy = newval - m_view->part()->document().selection()->boundingBox().topLeft().y();
80 m_view->part()->addCommand(
new VTranslateCmd( &m_view->part()->document(), 0.0, dy ),
true );
84VSelectToolBar::slotWidthChanged(
double newval )
88 double sx = newval / m_view->part()->document().selection()->boundingBox().width();
89 KoPoint sp = m_view->part()->document().selection()->boundingBox().topLeft();
90 m_view->part()->addCommand(
new VScaleCmd( &m_view->part()->document(), sp, sx, 1.0 ),
true );
95VSelectToolBar::slotHeightChanged(
double newval )
99 double sy = newval / m_view->part()->document().selection()->boundingBox().height();
100 KoPoint sp = m_view->part()->document().selection()->boundingBox().bottomLeft();
101 m_view->part()->addCommand(
new VScaleCmd( &m_view->part()->document(), sp, 1.0, sy ),
true );
106VSelectToolBar::slotSelectionChanged()
108 m_x->blockSignals(
true );
109 m_y->blockSignals(
true );
110 m_width->blockSignals(
true );
111 m_height->blockSignals(
true );
112 KoRect rect = m_view->part()->document().selection()->boundingBox();
113 m_x->setValue( rect.topLeft().x() );
114 m_y->setValue( rect.topLeft().y() );
115 m_width->setValue( rect.width() );
116 m_height->setValue( rect.height() );
117 m_x->blockSignals(
false );
118 m_y->blockSignals(
false );
119 m_width->blockSignals(
false );
120 m_height->blockSignals(
false );
123#include "vselecttoolbar.moc"