2
* Kivio - Visual Modelling and Flowcharting
3
* Copyright (C) 2000 theKompany.com
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
#include "tkfloatspinboxaction.h"
23
TKFloatSpinBoxAction::TKFloatSpinBoxAction( const QString& text, const QString& icon, int accel, QObject* parent, const char* name)
24
: TKAction(parent,name)
35
m_buttonSymbol = TKFloatSpinBox::UpDownArrows;
37
m_prefix = QString::null;
38
m_suffix = QString::null;
42
TKFloatSpinBoxAction::TKFloatSpinBoxAction( const QString& text, int accel, QObject* parent, const char* name)
43
: TKAction(parent,name)
53
m_buttonSymbol = TKFloatSpinBox::UpDownArrows;
55
m_prefix = QString::null;
56
m_suffix = QString::null;
60
TKFloatSpinBoxAction::~TKFloatSpinBoxAction()
64
int TKFloatSpinBoxAction::plug( QWidget* widget, int index )
66
int id_ = KAction::getToolButtonID();
68
TKFloatSpinBox* fsb = new TKFloatSpinBox();
69
connect(fsb,SIGNAL(valueChanged(float)),SLOT(slotActivated(float)));
71
QWidget* base = createLayout(widget,fsb);
73
if ( widget->inherits("KToolBar") ) {
74
KToolBar* bar = static_cast<KToolBar*>( widget );
75
bar->insertWidget( id_, 0, base, index );
78
addContainer( widget, id_ );
79
connect( widget, SIGNAL(destroyed()), SLOT(slotDestroyed()) );
81
fsb->setButtonSymbols(m_buttonSymbol);
82
fsb->setDecimals(m_decimal);
83
fsb->setWrapping(m_wrapping);
84
fsb->setMinValue(m_minvalue);
85
fsb->setMaxValue(m_maxvalue);
86
fsb->setLineStep(m_linestep);
87
fsb->setPrefix(m_prefix);
88
fsb->setSuffix(m_suffix);
89
fsb->setValue(m_value);
90
fsb->setMinimumStyle(m_minimum);
92
return containerCount() - 1;
95
void TKFloatSpinBoxAction::slotActivated(float value)
97
if ( m_value == value )
103
emit activated(value);
104
emit TKAction::activated();
107
#define SETVALUE(variable,method) \
109
int len = containerCount(); \
110
for( int id = 0; id < len; ++id ) { \
111
QWidget* w = container( id ); \
112
if ( w->inherits( "KToolBar" ) ) { \
113
QWidget* r = static_cast<KToolBar*>( w )->getWidget( itemId( id ) ); \
115
TKFloatSpinBox* fsb = (TKFloatSpinBox*)r->child("widget"); \
117
fsb->method(value); \
121
QWidget* r = static_cast<QWidget*>(w->child("KTToolBarLayout")); \
123
TKFloatSpinBox* fsb = (TKFloatSpinBox*)r->child("widget"); \
125
fsb->method(value); \
131
void TKFloatSpinBoxAction::setValue(float value)
133
SETVALUE(m_value,setValue)
136
void TKFloatSpinBoxAction::setButtonSymbols( TKFloatSpinBox::ButtonSymbols value )
138
SETVALUE(m_buttonSymbol,setButtonSymbols)
141
void TKFloatSpinBoxAction::setDecimals( int value )
143
SETVALUE(m_decimal,setDecimals)
144
(void) updateLayout();
147
void TKFloatSpinBoxAction::setWrapping( bool value )
149
SETVALUE(m_wrapping,setWrapping)
152
void TKFloatSpinBoxAction::setMinValue( float value )
154
SETVALUE(m_minvalue,setMinValue)
155
(void) updateLayout();
158
void TKFloatSpinBoxAction::setMaxValue( float value )
160
SETVALUE(m_maxvalue,setMaxValue)
161
(void) updateLayout();
164
void TKFloatSpinBoxAction::setLineStep( float value )
166
SETVALUE(m_linestep,setLineStep)
169
void TKFloatSpinBoxAction::setPrefix( const QString& value )
171
SETVALUE(m_prefix,setPrefix)
172
(void) updateLayout();
175
void TKFloatSpinBoxAction::setSuffix( const QString& value )
177
SETVALUE(m_suffix,setSuffix)
178
(void) updateLayout();
181
void TKFloatSpinBoxAction::setMinimumStyle(bool value )
183
SETVALUE(m_minimum,setMinimumStyle)
184
(void) updateLayout();
188
TKUFloatSpinBoxAction::TKUFloatSpinBoxAction( const QString& text, const QString& icon, int accel, QObject* parent, const char* name)
189
: TKFloatSpinBoxAction(text,icon,accel,parent,name)
191
setUnit((int)UnitPoint);
194
TKUFloatSpinBoxAction::TKUFloatSpinBoxAction( const QString& text, int accel, QObject* parent, const char* name)
195
: TKFloatSpinBoxAction(text,accel,parent,name)
197
setUnit((int)UnitPoint);
200
TKUFloatSpinBoxAction::~TKUFloatSpinBoxAction()
204
void TKUFloatSpinBoxAction::setUnit(int unit)
207
setSuffix(unitToString(unit));
208
float v = cvtPtToUnit(unit,cvtUnitToPt(m_unit,m_value));
209
setMinValue( cvtPtToUnit(unit,cvtUnitToPt(m_unit,m_minvalue)) );
210
setMaxValue( cvtPtToUnit(unit,cvtUnitToPt(m_unit,m_maxvalue)) );
211
TKFloatSpinBoxAction::setValue( v );
217
float TKUFloatSpinBoxAction::value(int unit)
219
return cvtPtToUnit(unit,cvtUnitToPt(m_unit,m_value));
222
void TKUFloatSpinBoxAction::setValue(float value,int unit)
224
TKFloatSpinBoxAction::setValue( cvtPtToUnit(m_unit,cvtUnitToPt(unit,value)) );
227
#include "tkfloatspinboxaction.moc"