~ubuntu-branches/ubuntu/breezy/koffice/breezy

« back to all changes in this revision

Viewing changes to kivio/kiviopart/tklib/tkfloatspinboxaction.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Ben Burton
  • Date: 2004-05-09 11:33:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040509113300-vfrdadqsvjfuhn3b
Tags: 1:1.3.1-1
* New upstream bugfix release.
* Built against newer imagemagick (closes: #246623).
* Made koffice-libs/kformula recommend/depend on latex-xft-fonts, which
  provides mathematical fonts that the formula editor can use.  Also
  patched the kformula part to make these fonts the default.
* Changed kword menu hint from "WordProcessors" to "Word processors"
  (closes: #246209).
* Spellchecker configuration is now fixed (closes: #221256, #227568).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Kivio - Visual Modelling and Flowcharting
3
 
 * Copyright (C) 2000 theKompany.com
4
 
 *
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.
9
 
 *
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.
14
 
 *
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.
18
 
 */
19
 
#include "tkfloatspinboxaction.h"
20
 
 
21
 
#include <ktoolbar.h>
22
 
 
23
 
TKFloatSpinBoxAction::TKFloatSpinBoxAction( const QString& text, const QString& icon, int accel, QObject* parent, const char* name)
24
 
: TKAction(parent,name)
25
 
{
26
 
  setText(text);
27
 
  setIcon(icon);
28
 
  setAccel(accel);
29
 
 
30
 
  m_decimal = 3;
31
 
  m_value = 0.0;
32
 
  m_minvalue = 0.0;
33
 
  m_maxvalue = 100.0;
34
 
  m_linestep = 0.1;
35
 
  m_buttonSymbol = TKFloatSpinBox::UpDownArrows;
36
 
  m_wrapping = false;
37
 
  m_prefix = QString::null;
38
 
  m_suffix = QString::null;
39
 
  m_minimum = false;
40
 
}
41
 
 
42
 
TKFloatSpinBoxAction::TKFloatSpinBoxAction( const QString& text, int accel, QObject* parent, const char* name)
43
 
: TKAction(parent,name)
44
 
{
45
 
  setText(text);
46
 
  setAccel(accel);
47
 
 
48
 
  m_decimal = 3;
49
 
  m_value = 0.0;
50
 
  m_minvalue = 0.0;
51
 
  m_maxvalue = 100.0;
52
 
  m_linestep = 0.1;
53
 
  m_buttonSymbol = TKFloatSpinBox::UpDownArrows;
54
 
  m_wrapping = false;
55
 
  m_prefix = QString::null;
56
 
  m_suffix = QString::null;
57
 
  m_minimum = false;
58
 
}
59
 
 
60
 
TKFloatSpinBoxAction::~TKFloatSpinBoxAction()
61
 
{
62
 
}
63
 
 
64
 
int TKFloatSpinBoxAction::plug( QWidget* widget, int index )
65
 
{
66
 
  int id_ = KAction::getToolButtonID();
67
 
 
68
 
  TKFloatSpinBox* fsb = new TKFloatSpinBox();
69
 
  connect(fsb,SIGNAL(valueChanged(float)),SLOT(slotActivated(float)));
70
 
 
71
 
  QWidget* base = createLayout(widget,fsb);
72
 
 
73
 
  if ( widget->inherits("KToolBar") ) {
74
 
    KToolBar* bar = static_cast<KToolBar*>( widget );
75
 
    bar->insertWidget( id_, 0, base, index );
76
 
  }
77
 
 
78
 
  addContainer( widget, id_ );
79
 
  connect( widget, SIGNAL(destroyed()), SLOT(slotDestroyed()) );
80
 
 
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);
91
 
 
92
 
  return containerCount() - 1;
93
 
}
94
 
 
95
 
void TKFloatSpinBoxAction::slotActivated(float value)
96
 
{
97
 
  if ( m_value == value )
98
 
    return;
99
 
 
100
 
  m_value = value;
101
 
  setValue(value);
102
 
 
103
 
  emit activated(value);
104
 
  emit TKAction::activated();
105
 
}
106
 
 
107
 
#define SETVALUE(variable,method) \
108
 
  variable = value;                                                             \
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 ) );      \
114
 
      if (r) {                                                                  \
115
 
        TKFloatSpinBox* fsb = (TKFloatSpinBox*)r->child("widget");                  \
116
 
        if (fsb) {                                                              \
117
 
          fsb->method(value);                                                 \
118
 
        }                                                                       \
119
 
      }                                                                         \
120
 
    } else {                                                                    \
121
 
      QWidget* r = static_cast<QWidget*>(w->child("KTToolBarLayout"));          \
122
 
      if (r) {                                                                  \
123
 
        TKFloatSpinBox* fsb = (TKFloatSpinBox*)r->child("widget");                  \
124
 
        if (fsb) {                                                              \
125
 
          fsb->method(value);                                                 \
126
 
        }                                                                       \
127
 
      }                                                                         \
128
 
    }                                                                           \
129
 
  }
130
 
 
131
 
void TKFloatSpinBoxAction::setValue(float value)
132
 
{
133
 
  SETVALUE(m_value,setValue)
134
 
}
135
 
 
136
 
void TKFloatSpinBoxAction::setButtonSymbols( TKFloatSpinBox::ButtonSymbols value )
137
 
{
138
 
  SETVALUE(m_buttonSymbol,setButtonSymbols)
139
 
}
140
 
 
141
 
void TKFloatSpinBoxAction::setDecimals( int value )
142
 
{
143
 
  SETVALUE(m_decimal,setDecimals)
144
 
  (void) updateLayout();
145
 
}
146
 
 
147
 
void TKFloatSpinBoxAction::setWrapping( bool value )
148
 
{
149
 
  SETVALUE(m_wrapping,setWrapping)
150
 
}
151
 
 
152
 
void TKFloatSpinBoxAction::setMinValue( float value )
153
 
{
154
 
  SETVALUE(m_minvalue,setMinValue)
155
 
  (void) updateLayout();
156
 
}
157
 
 
158
 
void TKFloatSpinBoxAction::setMaxValue( float value )
159
 
{
160
 
  SETVALUE(m_maxvalue,setMaxValue)
161
 
  (void) updateLayout();
162
 
}
163
 
 
164
 
void TKFloatSpinBoxAction::setLineStep( float value )
165
 
{
166
 
  SETVALUE(m_linestep,setLineStep)
167
 
}
168
 
 
169
 
void TKFloatSpinBoxAction::setPrefix( const QString& value )
170
 
{
171
 
  SETVALUE(m_prefix,setPrefix)
172
 
  (void) updateLayout();
173
 
}
174
 
 
175
 
void TKFloatSpinBoxAction::setSuffix( const QString& value )
176
 
{
177
 
  SETVALUE(m_suffix,setSuffix)
178
 
  (void) updateLayout();
179
 
}
180
 
 
181
 
void TKFloatSpinBoxAction::setMinimumStyle(bool value )
182
 
{
183
 
  SETVALUE(m_minimum,setMinimumStyle)
184
 
  (void) updateLayout();
185
 
}
186
 
 
187
 
 
188
 
TKUFloatSpinBoxAction::TKUFloatSpinBoxAction( const QString& text, const QString& icon, int accel, QObject* parent, const char* name)
189
 
: TKFloatSpinBoxAction(text,icon,accel,parent,name)
190
 
{
191
 
  setUnit((int)UnitPoint);
192
 
}
193
 
 
194
 
TKUFloatSpinBoxAction::TKUFloatSpinBoxAction( const QString& text, int accel, QObject* parent, const char* name)
195
 
: TKFloatSpinBoxAction(text,accel,parent,name)
196
 
{
197
 
  setUnit((int)UnitPoint);
198
 
}
199
 
 
200
 
TKUFloatSpinBoxAction::~TKUFloatSpinBoxAction()
201
 
{
202
 
}
203
 
 
204
 
void TKUFloatSpinBoxAction::setUnit(int unit)
205
 
{
206
 
  blockSignals(true);
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 );
212
 
 
213
 
  m_unit = unit;
214
 
  blockSignals(false);
215
 
}
216
 
 
217
 
float TKUFloatSpinBoxAction::value(int unit)
218
 
{
219
 
  return cvtPtToUnit(unit,cvtUnitToPt(m_unit,m_value));
220
 
}
221
 
 
222
 
void TKUFloatSpinBoxAction::setValue(float value,int unit)
223
 
{
224
 
  TKFloatSpinBoxAction::setValue( cvtPtToUnit(m_unit,cvtUnitToPt(unit,value)) );
225
 
}
226
 
 
227
 
#include "tkfloatspinboxaction.moc"