• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kdeui
 

kdeui

  • kdeui
knuminput.cpp
1 // -*- c-basic-offset: 4 -*-
2 /*
3  * knuminput.cpp
4  *
5  * Initial implementation:
6  * Copyright (c) 1997 Patrick Dowler <dowler@morgul.fsh.uvic.ca>
7  * Rewritten and maintained by:
8  * Copyright (c) 2000 Dirk A. Mueller <mueller@kde.org>
9  * KDoubleSpinBox:
10  * Copyright (c) 2002 Marc Mutz <mutz@kde.org>
11  *
12  * Requires the Qt widget libraries, available at no cost at
13  * http://www.troll.no/
14  *
15  * This library is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU Library General Public
17  * License as published by the Free Software Foundation; either
18  * version 2 of the License, or (at your option) any later version.
19  *
20  * This library is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23  * Library General Public License for more details.
24  *
25  * You should have received a copy of the GNU Library General Public License
26  * along with this library; see the file COPYING.LIB. If not, write to
27  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
28  * Boston, MA 02110-1301, USA.
29  */
30 
31 #include <config.h>
32 #ifdef HAVE_LIMITS_H
33 #include <limits.h>
34 #endif
35 #include <assert.h>
36 #include <math.h>
37 #include <algorithm>
38 
39 #include <tqapplication.h>
40 #include <tqlabel.h>
41 #include <tqlineedit.h>
42 #include <tqsize.h>
43 #include <tqslider.h>
44 #include <tqspinbox.h>
45 #include <tqstyle.h>
46 
47 #include <kglobal.h>
48 #include <klocale.h>
49 #include <kdebug.h>
50 
51 #include "kdialog.h"
52 #include "knumvalidator.h"
53 #include "knuminput.h"
54 
55 static inline int calcDiffByTen( int x, int y ) {
56  // calculate ( x - y ) / 10 without overflowing ints:
57  return ( x / 10 ) - ( y / 10 ) + ( x % 10 - y % 10 ) / 10;
58 }
59 
60 // ----------------------------------------------------------------------------
61 
62 KNumInput::KNumInput(TQWidget* parent, const char* name)
63  : TQWidget(parent, name)
64 {
65  init();
66 }
67 
68 KNumInput::KNumInput(KNumInput* below, TQWidget* parent, const char* name)
69  : TQWidget(parent, name)
70 {
71  init();
72 
73  if(below) {
74  m_next = below->m_next;
75  m_prev = below;
76  below->m_next = this;
77  if(m_next)
78  m_next->m_prev = this;
79  }
80 }
81 
82 void KNumInput::init()
83 {
84  m_prev = m_next = 0;
85  m_colw1 = m_colw2 = 0;
86 
87  m_label = 0;
88  m_slider = 0;
89  m_alignment = 0;
90 }
91 
92 KNumInput::~KNumInput()
93 {
94  if(m_prev)
95  m_prev->m_next = m_next;
96 
97  if(m_next)
98  m_next->m_prev = m_prev;
99 }
100 
101 void KNumInput::setLabel(const TQString & label, int a)
102 {
103  if(label.isEmpty()) {
104  delete m_label;
105  m_label = 0;
106  m_alignment = 0;
107  }
108  else {
109  if (m_label) m_label->setText(label);
110  else m_label = new TQLabel(label, this, "KNumInput::TQLabel");
111  m_label->setAlignment((a & (~(AlignTop|AlignBottom|AlignVCenter)))
112  | AlignVCenter);
113  // if no vertical alignment set, use Top alignment
114  if(!(a & (AlignTop|AlignBottom|AlignVCenter)))
115  a |= AlignTop;
116  m_alignment = a;
117  }
118 
119  layout(true);
120 }
121 
122 TQString KNumInput::label() const
123 {
124  if (m_label) return m_label->text();
125  return TQString::null;
126 }
127 
128 void KNumInput::layout(bool deep)
129 {
130  int w1 = m_colw1;
131  int w2 = m_colw2;
132 
133  // label sizeHint
134  m_sizeLabel = (m_label ? m_label->sizeHint() : TQSize(0,0));
135 
136  if(m_label && (m_alignment & AlignVCenter))
137  m_colw1 = m_sizeLabel.width() + 4;
138  else
139  m_colw1 = 0;
140 
141  // slider sizeHint
142  m_sizeSlider = (m_slider ? m_slider->sizeHint() : TQSize(0, 0));
143 
144  doLayout();
145 
146  if(!deep) {
147  m_colw1 = w1;
148  m_colw2 = w2;
149  return;
150  }
151 
152  KNumInput* p = this;
153  while(p) {
154  p->doLayout();
155  w1 = QMAX(w1, p->m_colw1);
156  w2 = QMAX(w2, p->m_colw2);
157  p = p->m_prev;
158  }
159 
160  p = m_next;
161  while(p) {
162  p->doLayout();
163  w1 = QMAX(w1, p->m_colw1);
164  w2 = QMAX(w2, p->m_colw2);
165  p = p->m_next;
166  }
167 
168  p = this;
169  while(p) {
170  p->m_colw1 = w1;
171  p->m_colw2 = w2;
172  p = p->m_prev;
173  }
174 
175  p = m_next;
176  while(p) {
177  p->m_colw1 = w1;
178  p->m_colw2 = w2;
179  p = p->m_next;
180  }
181 
182 // kdDebug() << "w1 " << w1 << " w2 " << w2 << endl;
183 }
184 
185 TQSizePolicy KNumInput::sizePolicy() const
186 {
187  return TQSizePolicy( TQSizePolicy::Minimum, TQSizePolicy::Fixed );
188 }
189 
190 TQSize KNumInput::sizeHint() const
191 {
192  return minimumSizeHint();
193 }
194 
195 void KNumInput::setSteps(int minor, int major)
196 {
197  if(m_slider)
198  m_slider->setSteps( minor, major );
199 }
200 
201 
202 // ----------------------------------------------------------------------------
203 
204 KIntSpinBox::KIntSpinBox(TQWidget *parent, const char *name)
205  : TQSpinBox(0, 99, 1, parent, name)
206 {
207  editor()->setAlignment(AlignRight);
208  val_base = 10;
209  setValidator(new KIntValidator(this, val_base));
210  setValue(0);
211 }
212 
213 KIntSpinBox::~KIntSpinBox()
214 {
215 }
216 
217 KIntSpinBox::KIntSpinBox(int lower, int upper, int step, int value, int base,
218  TQWidget* parent, const char* name)
219  : TQSpinBox(lower, upper, step, parent, name)
220 {
221  editor()->setAlignment(AlignRight);
222  val_base = base;
223  setValidator(new KIntValidator(this, val_base));
224  setValue(value);
225 }
226 
227 void KIntSpinBox::setBase(int base)
228 {
229  const KIntValidator* kvalidator = dynamic_cast<const KIntValidator*>(validator());
230  if (kvalidator) {
231  const_cast<KIntValidator*>(kvalidator)->setBase(base);
232  }
233  val_base = base;
234 }
235 
236 
237 int KIntSpinBox::base() const
238 {
239  return val_base;
240 }
241 
242 TQString KIntSpinBox::mapValueToText(int v)
243 {
244  return TQString::number(v, val_base);
245 }
246 
247 int KIntSpinBox::mapTextToValue(bool* ok)
248 {
249  return cleanText().toInt(ok, val_base);
250 }
251 
252 void KIntSpinBox::setEditFocus(bool mark)
253 {
254  editor()->setFocus();
255  if(mark)
256  editor()->selectAll();
257 }
258 
259 
260 // ----------------------------------------------------------------------------
261 
262 class KIntNumInput::KIntNumInputPrivate {
263 public:
264  int referencePoint;
265  short blockRelative;
266  KIntNumInputPrivate( int r )
267  : referencePoint( r ),
268  blockRelative( 0 ) {}
269 };
270 
271 
272 KIntNumInput::KIntNumInput(KNumInput* below, int val, TQWidget* parent,
273  int _base, const char* name)
274  : KNumInput(below, parent, name)
275 {
276  init(val, _base);
277 }
278 
279 KIntNumInput::KIntNumInput(TQWidget *parent, const char *name)
280  : KNumInput(parent, name)
281 {
282  init(0, 10);
283 }
284 
285 KIntNumInput::KIntNumInput(int val, TQWidget *parent, int _base, const char *name)
286  : KNumInput(parent, name)
287 {
288  init(val, _base);
289 
290 }
291 
292 void KIntNumInput::init(int val, int _base)
293 {
294  d = new KIntNumInputPrivate( val );
295  m_spin = new KIntSpinBox(INT_MIN, INT_MAX, 1, val, _base, this, "KIntNumInput::KIntSpinBox");
296  // the KIntValidator is broken beyond believe for
297  // spinboxes which have suffix or prefix texts, so
298  // better don't use it unless absolutely necessary
299  if (_base != 10)
300  m_spin->setValidator(new KIntValidator(this, _base, "KNumInput::KIntValidtr"));
301 
302  connect(m_spin, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(spinValueChanged(int)));
303  connect(this, TQT_SIGNAL(valueChanged(int)),
304  TQT_SLOT(slotEmitRelativeValueChanged(int)));
305 
306  setFocusProxy(m_spin);
307  layout(true);
308 }
309 
310 void KIntNumInput::setReferencePoint( int ref ) {
311  // clip to valid range:
312  ref = kMin( maxValue(), kMax( minValue(), ref ) );
313  d->referencePoint = ref;
314 }
315 
316 int KIntNumInput::referencePoint() const {
317  return d->referencePoint;
318 }
319 
320 void KIntNumInput::spinValueChanged(int val)
321 {
322  if(m_slider)
323  m_slider->setValue(val);
324 
325  emit valueChanged(val);
326 }
327 
328 void KIntNumInput::slotEmitRelativeValueChanged( int value ) {
329  if ( d->blockRelative || !d->referencePoint ) return;
330  emit relativeValueChanged( double( value ) / double( d->referencePoint ) );
331 }
332 
333 void KIntNumInput::setRange(int lower, int upper, int step, bool slider)
334 {
335  upper = kMax(upper, lower);
336  lower = kMin(upper, lower);
337  m_spin->setMinValue(lower);
338  m_spin->setMaxValue(upper);
339  m_spin->setLineStep(step);
340 
341  step = m_spin->lineStep(); // maybe TQRangeControl didn't like out lineStep?
342 
343  if(slider) {
344  if (m_slider)
345  m_slider->setRange(lower, upper);
346  else {
347  m_slider = new TQSlider(lower, upper, step, m_spin->value(),
348  Qt::Horizontal, this);
349  m_slider->setTickmarks(TQSlider::Below);
350  connect(m_slider, TQT_SIGNAL(valueChanged(int)),
351  m_spin, TQT_SLOT(setValue(int)));
352  }
353 
354  // calculate (upper-lower)/10 without overflowing int's:
355  int major = calcDiffByTen( upper, lower );
356  if ( major==0 ) major = step; // #### workaround Qt bug in 2.1-beta4
357 
358  m_slider->setSteps(step, major);
359  m_slider->setTickInterval(major);
360  }
361  else {
362  delete m_slider;
363  m_slider = 0;
364  }
365 
366  // check that reference point is still inside valid range:
367  setReferencePoint( referencePoint() );
368 
369  layout(true);
370 }
371 
372 void KIntNumInput::setMinValue(int min)
373 {
374  setRange(min, m_spin->maxValue(), m_spin->lineStep(), m_slider);
375 }
376 
377 int KIntNumInput::minValue() const
378 {
379  return m_spin->minValue();
380 }
381 
382 void KIntNumInput::setMaxValue(int max)
383 {
384  setRange(m_spin->minValue(), max, m_spin->lineStep(), m_slider);
385 }
386 
387 int KIntNumInput::maxValue() const
388 {
389  return m_spin->maxValue();
390 }
391 
392 void KIntNumInput::setSuffix(const TQString &suffix)
393 {
394  m_spin->setSuffix(suffix);
395 
396  layout(true);
397 }
398 
399 TQString KIntNumInput::suffix() const
400 {
401  return m_spin->suffix();
402 }
403 
404 void KIntNumInput::setPrefix(const TQString &prefix)
405 {
406  m_spin->setPrefix(prefix);
407 
408  layout(true);
409 }
410 
411 TQString KIntNumInput::prefix() const
412 {
413  return m_spin->prefix();
414 }
415 
416 void KIntNumInput::setEditFocus(bool mark)
417 {
418  m_spin->setEditFocus(mark);
419 }
420 
421 TQSize KIntNumInput::minimumSizeHint() const
422 {
423  constPolish();
424 
425  int w;
426  int h;
427 
428  h = 2 + QMAX(m_sizeSpin.height(), m_sizeSlider.height());
429 
430  // if in extra row, then count it here
431  if(m_label && (m_alignment & (AlignBottom|AlignTop)))
432  h += 4 + m_sizeLabel.height();
433  else
434  // label is in the same row as the other widgets
435  h = QMAX(h, m_sizeLabel.height() + 2);
436 
437  w = m_slider ? m_slider->sizeHint().width() + 8 : 0;
438  w += m_colw1 + m_colw2;
439 
440  if(m_alignment & (AlignTop|AlignBottom))
441  w = QMAX(w, m_sizeLabel.width() + 4);
442 
443  return TQSize(w, h);
444 }
445 
446 void KIntNumInput::doLayout()
447 {
448  m_sizeSpin = m_spin->sizeHint();
449  m_colw2 = m_sizeSpin.width();
450 
451  if (m_label)
452  m_label->setBuddy(m_spin);
453 }
454 
455 void KIntNumInput::resizeEvent(TQResizeEvent* e)
456 {
457  int w = m_colw1;
458  int h = 0;
459 
460  if(m_label && (m_alignment & AlignTop)) {
461  m_label->setGeometry(0, 0, e->size().width(), m_sizeLabel.height());
462  h += m_sizeLabel.height() + KDialog::spacingHint();
463  }
464 
465  if(m_label && (m_alignment & AlignVCenter))
466  m_label->setGeometry(0, 0, w, m_sizeSpin.height());
467 
468  if (tqApp->reverseLayout())
469  {
470  m_spin->setGeometry(w, h, m_slider ? m_colw2 : QMAX(m_colw2, e->size().width() - w), m_sizeSpin.height());
471  w += m_colw2 + 8;
472 
473  if(m_slider)
474  m_slider->setGeometry(w, h, e->size().width() - w, m_sizeSpin.height());
475  }
476  else if(m_slider) {
477  m_slider->setGeometry(w, h, e->size().width() - (w + m_colw2 + KDialog::spacingHint()), m_sizeSpin.height());
478  m_spin->setGeometry(w + m_slider->size().width() + KDialog::spacingHint(), h, m_colw2, m_sizeSpin.height());
479  }
480  else {
481  m_spin->setGeometry(w, h, QMAX(m_colw2, e->size().width() - w), m_sizeSpin.height());
482  }
483 
484  h += m_sizeSpin.height() + 2;
485 
486  if(m_label && (m_alignment & AlignBottom))
487  m_label->setGeometry(0, h, m_sizeLabel.width(), m_sizeLabel.height());
488 }
489 
490 KIntNumInput::~KIntNumInput()
491 {
492  delete d;
493 }
494 
495 void KIntNumInput::setValue(int val)
496 {
497  m_spin->setValue(val);
498  // slider value is changed by spinValueChanged
499 }
500 
501 void KIntNumInput::setRelativeValue( double r ) {
502  if ( !d->referencePoint ) return;
503  ++d->blockRelative;
504  setValue( int( d->referencePoint * r + 0.5 ) );
505  --d->blockRelative;
506 }
507 
508 double KIntNumInput::relativeValue() const {
509  if ( !d->referencePoint ) return 0;
510  return double( value() ) / double ( d->referencePoint );
511 }
512 
513 int KIntNumInput::value() const
514 {
515  return m_spin->value();
516 }
517 
518 void KIntNumInput::setSpecialValueText(const TQString& text)
519 {
520  m_spin->setSpecialValueText(text);
521  layout(true);
522 }
523 
524 TQString KIntNumInput::specialValueText() const
525 {
526  return m_spin->specialValueText();
527 }
528 
529 void KIntNumInput::setLabel(const TQString & label, int a)
530 {
531  KNumInput::setLabel(label, a);
532 
533  if(m_label)
534  m_label->setBuddy(m_spin);
535 }
536 
537 // ----------------------------------------------------------------------------
538 
539 class KDoubleNumInput::KDoubleNumInputPrivate {
540 public:
541  KDoubleNumInputPrivate( double r )
542  : spin( 0 ),
543  referencePoint( r ),
544  blockRelative ( 0 ) {}
545  KDoubleSpinBox * spin;
546  double referencePoint;
547  short blockRelative;
548 };
549 
550 KDoubleNumInput::KDoubleNumInput(TQWidget *parent, const char *name)
551  : KNumInput(parent, name)
552 {
553  init(0.0, 0.0, 9999.0, 0.01, 2);
554 }
555 
556 KDoubleNumInput::KDoubleNumInput(double lower, double upper, double value,
557  double step, int precision, TQWidget* parent,
558  const char *name)
559  : KNumInput(parent, name)
560 {
561  init(value, lower, upper, step, precision);
562 }
563 
564 KDoubleNumInput::KDoubleNumInput(KNumInput *below,
565  double lower, double upper, double value,
566  double step, int precision, TQWidget* parent,
567  const char *name)
568  : KNumInput(below, parent, name)
569 {
570  init(value, lower, upper, step, precision);
571 }
572 
573 KDoubleNumInput::KDoubleNumInput(double value, TQWidget *parent, const char *name)
574  : KNumInput(parent, name)
575 {
576  init(value, kMin(0.0, value), kMax(0.0, value), 0.01, 2 );
577 }
578 
579 KDoubleNumInput::KDoubleNumInput(KNumInput* below, double value, TQWidget* parent,
580  const char* name)
581  : KNumInput(below, parent, name)
582 {
583  init( value, kMin(0.0, value), kMax(0.0, value), 0.01, 2 );
584 }
585 
586 KDoubleNumInput::~KDoubleNumInput()
587 {
588  delete d;
589 }
590 
591 // ### remove when BIC changes are allowed again:
592 
593 bool KDoubleNumInput::eventFilter( TQObject * o, TQEvent * e ) {
594  return KNumInput::eventFilter( o, e );
595 }
596 
597 void KDoubleNumInput::resetEditBox() {
598 
599 }
600 
601 // ### end stuff to remove when BIC changes are allowed again
602 
603 
604 
605 void KDoubleNumInput::init(double value, double lower, double upper,
606  double step, int precision )
607 {
608  // ### init no longer used members:
609  edit = 0;
610  m_range = true;
611  m_value = 0.0;
612  m_precision = 2;
613  // ### end
614 
615  d = new KDoubleNumInputPrivate( value );
616 
617  d->spin = new KDoubleSpinBox( lower, upper, step, value, precision,
618  this, "KDoubleNumInput::d->spin" );
619  setFocusProxy(d->spin);
620  connect( d->spin, TQT_SIGNAL(valueChanged(double)),
621  this, TQT_SIGNAL(valueChanged(double)) );
622  connect( this, TQT_SIGNAL(valueChanged(double)),
623  this, TQT_SLOT(slotEmitRelativeValueChanged(double)) );
624 
625  updateLegacyMembers();
626 
627  layout(true);
628 }
629 
630 void KDoubleNumInput::updateLegacyMembers() {
631  // ### update legacy members that are either not private or for
632  // which an inlined getter exists:
633  m_lower = minValue();
634  m_upper = maxValue();
635  m_step = d->spin->lineStep();
636  m_specialvalue = specialValueText();
637 }
638 
639 
640 double KDoubleNumInput::mapSliderToSpin( int val ) const
641 {
642  // map [slidemin,slidemax] to [spinmin,spinmax]
643  double spinmin = d->spin->minValue();
644  double spinmax = d->spin->maxValue();
645  double slidemin = m_slider->minValue(); // cast int to double to avoid
646  double slidemax = m_slider->maxValue(); // overflow in rel denominator
647  double rel = ( double(val) - slidemin ) / ( slidemax - slidemin );
648  return spinmin + rel * ( spinmax - spinmin );
649 }
650 
651 void KDoubleNumInput::sliderMoved(int val)
652 {
653  d->spin->setValue( mapSliderToSpin( val ) );
654 }
655 
656 void KDoubleNumInput::slotEmitRelativeValueChanged( double value )
657 {
658  if ( !d->referencePoint ) return;
659  emit relativeValueChanged( value / d->referencePoint );
660 }
661 
662 TQSize KDoubleNumInput::minimumSizeHint() const
663 {
664  constPolish();
665 
666  int w;
667  int h;
668 
669  h = 2 + QMAX(m_sizeEdit.height(), m_sizeSlider.height());
670 
671  // if in extra row, then count it here
672  if(m_label && (m_alignment & (AlignBottom|AlignTop)))
673  h += 4 + m_sizeLabel.height();
674  else
675  // label is in the same row as the other widgets
676  h = QMAX(h, m_sizeLabel.height() + 2);
677 
678  w = m_slider ? m_slider->sizeHint().width() + 8 : 0;
679  w += m_colw1 + m_colw2;
680 
681  if(m_alignment & (AlignTop|AlignBottom))
682  w = QMAX(w, m_sizeLabel.width() + 4);
683 
684  return TQSize(w, h);
685 }
686 
687 void KDoubleNumInput::resizeEvent(TQResizeEvent* e)
688 {
689  int w = m_colw1;
690  int h = 0;
691 
692  if(m_label && (m_alignment & AlignTop)) {
693  m_label->setGeometry(0, 0, e->size().width(), m_sizeLabel.height());
694  h += m_sizeLabel.height() + 4;
695  }
696 
697  if(m_label && (m_alignment & AlignVCenter))
698  m_label->setGeometry(0, 0, w, m_sizeEdit.height());
699 
700  if (tqApp->reverseLayout())
701  {
702  d->spin->setGeometry(w, h, m_slider ? m_colw2
703  : e->size().width() - w, m_sizeEdit.height());
704  w += m_colw2 + KDialog::spacingHint();
705 
706  if(m_slider)
707  m_slider->setGeometry(w, h, e->size().width() - w, m_sizeEdit.height());
708  }
709  else if(m_slider) {
710  m_slider->setGeometry(w, h, e->size().width() -
711  (m_colw1 + m_colw2 + KDialog::spacingHint()),
712  m_sizeEdit.height());
713  d->spin->setGeometry(w + m_slider->width() + KDialog::spacingHint(), h,
714  m_colw2, m_sizeEdit.height());
715  }
716  else {
717  d->spin->setGeometry(w, h, e->size().width() - w, m_sizeEdit.height());
718  }
719 
720  h += m_sizeEdit.height() + 2;
721 
722  if(m_label && (m_alignment & AlignBottom))
723  m_label->setGeometry(0, h, m_sizeLabel.width(), m_sizeLabel.height());
724 }
725 
726 void KDoubleNumInput::doLayout()
727 {
728  m_sizeEdit = d->spin->sizeHint();
729  m_colw2 = m_sizeEdit.width();
730 }
731 
732 void KDoubleNumInput::setValue(double val)
733 {
734  d->spin->setValue( val );
735 }
736 
737 void KDoubleNumInput::setRelativeValue( double r )
738 {
739  if ( !d->referencePoint ) return;
740  ++d->blockRelative;
741  setValue( r * d->referencePoint );
742  --d->blockRelative;
743 }
744 
745 void KDoubleNumInput::setReferencePoint( double ref )
746 {
747  // clip to valid range:
748  ref = kMin( maxValue(), kMax( minValue(), ref ) );
749  d->referencePoint = ref;
750 }
751 
752 void KDoubleNumInput::setRange(double lower, double upper, double step,
753  bool slider)
754 {
755  if( m_slider ) {
756  // don't update the slider to avoid an endless recursion
757  TQSpinBox * spin = d->spin;
758  disconnect(spin, TQT_SIGNAL(valueChanged(int)),
759  m_slider, TQT_SLOT(setValue(int)) );
760  }
761  d->spin->setRange( lower, upper, step, d->spin->precision() );
762 
763  if(slider) {
764  // upcast to base type to get the min/maxValue in int form:
765  TQSpinBox * spin = d->spin;
766  int slmax = spin->maxValue();
767  int slmin = spin->minValue();
768  int slvalue = spin->value();
769  int slstep = spin->lineStep();
770  if (m_slider) {
771  m_slider->setRange(slmin, slmax);
772  m_slider->setValue(slvalue);
773  } else {
774  m_slider = new TQSlider(slmin, slmax, slstep, slvalue,
775  Qt::Horizontal, this);
776  m_slider->setTickmarks(TQSlider::Below);
777  // feedback line: when one moves, the other moves, too:
778  connect(m_slider, TQT_SIGNAL(valueChanged(int)),
779  TQT_SLOT(sliderMoved(int)) );
780  }
781  connect(spin, TQT_SIGNAL(valueChanged(int)),
782  m_slider, TQT_SLOT(setValue(int)) );
783  // calculate ( slmax - slmin ) / 10 without overflowing ints:
784  int major = calcDiffByTen( slmax, slmin );
785  if ( !major ) major = slstep; // ### needed?
786  m_slider->setSteps(slstep, major);
787  m_slider->setTickInterval(major);
788  } else {
789  delete m_slider;
790  m_slider = 0;
791  }
792 
793  setReferencePoint( referencePoint() );
794 
795  layout(true);
796  updateLegacyMembers();
797 }
798 
799 void KDoubleNumInput::setMinValue(double min)
800 {
801  setRange(min, maxValue(), d->spin->lineStep(), m_slider);
802 }
803 
804 double KDoubleNumInput::minValue() const
805 {
806  return d->spin->minValue();
807 }
808 
809 void KDoubleNumInput::setMaxValue(double max)
810 {
811  setRange(minValue(), max, d->spin->lineStep(), m_slider);
812 }
813 
814 double KDoubleNumInput::maxValue() const
815 {
816  return d->spin->maxValue();
817 }
818 
819 double KDoubleNumInput::value() const
820 {
821  return d->spin->value();
822 }
823 
824 double KDoubleNumInput::relativeValue() const
825 {
826  if ( !d->referencePoint ) return 0;
827  return value() / d->referencePoint;
828 }
829 
830 double KDoubleNumInput::referencePoint() const
831 {
832  return d->referencePoint;
833 }
834 
835 TQString KDoubleNumInput::suffix() const
836 {
837  return d->spin->suffix();
838 }
839 
840 TQString KDoubleNumInput::prefix() const
841 {
842  return d->spin->prefix();
843 }
844 
845 void KDoubleNumInput::setSuffix(const TQString &suffix)
846 {
847  d->spin->setSuffix( suffix );
848 
849  layout(true);
850 }
851 
852 void KDoubleNumInput::setPrefix(const TQString &prefix)
853 {
854  d->spin->setPrefix( prefix );
855 
856  layout(true);
857 }
858 
859 void KDoubleNumInput::setPrecision(int precision)
860 {
861  d->spin->setPrecision( precision );
862  if(m_slider) {
863  // upcast to base type to get the min/maxValue in int form:
864  TQSpinBox * spin = d->spin;
865  m_slider->setRange(spin->minValue(), spin->maxValue());
866  m_slider->setValue(spin->value());
867  int major = calcDiffByTen(spin->maxValue(), spin->minValue());
868  if ( !major ) major = spin->lineStep();
869  m_slider->setSteps(spin->lineStep(), major);
870  m_slider->setTickInterval(major);
871  }
872 
873  layout(true);
874 }
875 
876 int KDoubleNumInput::precision() const
877 {
878  return d->spin->precision();
879 }
880 
881 void KDoubleNumInput::setSpecialValueText(const TQString& text)
882 {
883  d->spin->setSpecialValueText( text );
884 
885  layout(true);
886  updateLegacyMembers();
887 }
888 
889 void KDoubleNumInput::setLabel(const TQString & label, int a)
890 {
891  KNumInput::setLabel(label, a);
892 
893  if(m_label)
894  m_label->setBuddy(d->spin);
895 
896 }
897 
898 // ----------------------------------------------------------------------------
899 
900 
901 class KDoubleSpinBoxValidator : public KDoubleValidator
902 {
903 public:
904  KDoubleSpinBoxValidator( double bottom, double top, int decimals, KDoubleSpinBox* sb, const char *name )
905  : KDoubleValidator( bottom, top, decimals, TQT_TQOBJECT(sb), name ), spinBox( sb ) { }
906 
907  virtual State validate( TQString& str, int& pos ) const;
908 
909 private:
910  KDoubleSpinBox *spinBox;
911 };
912 
913 TQValidator::State KDoubleSpinBoxValidator::validate( TQString& str, int& pos ) const
914 {
915  TQString pref = spinBox->prefix();
916  TQString suff = spinBox->suffix();
917  TQString suffStriped = suff.stripWhiteSpace();
918  uint overhead = pref.length() + suff.length();
919  State state = Invalid;
920 
921  if ( overhead == 0 ) {
922  state = KDoubleValidator::validate( str, pos );
923  } else {
924  bool stripedVersion = false;
925  if ( str.length() >= overhead && str.startsWith(pref)
926  && (str.endsWith(suff)
927  || (stripedVersion = str.endsWith(suffStriped))) ) {
928  if ( stripedVersion )
929  overhead = pref.length() + suffStriped.length();
930  TQString core = str.mid( pref.length(), str.length() - overhead );
931  int corePos = pos - pref.length();
932  state = KDoubleValidator::validate( core, corePos );
933  pos = corePos + pref.length();
934  str.replace( pref.length(), str.length() - overhead, core );
935  } else {
936  state = KDoubleValidator::validate( str, pos );
937  if ( state == Invalid ) {
938  // stripWhiteSpace(), cf. TQSpinBox::interpretText()
939  TQString special = spinBox->specialValueText().stripWhiteSpace();
940  TQString candidate = str.stripWhiteSpace();
941 
942  if ( special.startsWith(candidate) ) {
943  if ( candidate.length() == special.length() ) {
944  state = Acceptable;
945  } else {
946  state = Intermediate;
947  }
948  }
949  }
950  }
951  }
952  return state;
953 }
954 
955 // We use a kind of fixed-point arithmetic to represent the range of
956 // doubles [mLower,mUpper] in steps of 10^(-mPrecision). Thus, the
957 // following relations hold:
958 //
959 // 1. factor = 10^mPrecision
960 // 2. basicStep = 1/factor = 10^(-mPrecision);
961 // 3. lowerInt = lower * factor;
962 // 4. upperInt = upper * factor;
963 // 5. lower = lowerInt * basicStep;
964 // 6. upper = upperInt * basicStep;
965 class KDoubleSpinBox::Private {
966 public:
967  Private( int precision=1 )
968  : mPrecision( precision ),
969  mValidator( 0 )
970  {
971  }
972 
973  int factor() const {
974  int f = 1;
975  for ( int i = 0 ; i < mPrecision ; ++i ) f *= 10;
976  return f;
977  }
978 
979  double basicStep() const {
980  return 1.0/double(factor());
981  }
982 
983  int mapToInt( double value, bool * ok ) const {
984  assert( ok );
985  const double f = factor();
986  if ( value > double(INT_MAX) / f ) {
987  kdWarning() << "KDoubleSpinBox: can't represent value " << value
988  << "in terms of fixed-point numbers with precision "
989  << mPrecision << endl;
990  *ok = false;
991  return INT_MAX;
992  } else if ( value < double(INT_MIN) / f ) {
993  kdWarning() << "KDoubleSpinBox: can't represent value " << value
994  << "in terms of fixed-point numbers with precision "
995  << mPrecision << endl;
996  *ok = false;
997  return INT_MIN;
998  } else {
999  *ok = true;
1000  return int( value * f + ( value < 0 ? -0.5 : 0.5 ) );
1001  }
1002  }
1003 
1004  double mapToDouble( int value ) const {
1005  return double(value) * basicStep();
1006  }
1007 
1008  int mPrecision;
1009  KDoubleSpinBoxValidator * mValidator;
1010 };
1011 
1012 KDoubleSpinBox::KDoubleSpinBox( TQWidget * parent, const char * name )
1013  : TQSpinBox( parent, name )
1014 {
1015  editor()->setAlignment( Qt::AlignRight );
1016  d = new Private();
1017  updateValidator();
1018  connect( this, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(slotValueChanged(int)) );
1019 }
1020 
1021 KDoubleSpinBox::KDoubleSpinBox( double lower, double upper, double step,
1022  double value, int precision,
1023  TQWidget * parent, const char * name )
1024  : TQSpinBox( parent, name )
1025 {
1026  editor()->setAlignment( Qt::AlignRight );
1027  d = new Private();
1028  setRange( lower, upper, step, precision );
1029  setValue( value );
1030  connect( this, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(slotValueChanged(int)) );
1031 }
1032 
1033 KDoubleSpinBox::~KDoubleSpinBox() {
1034  delete d; d = 0;
1035 }
1036 
1037 bool KDoubleSpinBox::acceptLocalizedNumbers() const {
1038  if ( !d->mValidator ) return true; // we'll set one that does;
1039  // can't do it now, since we're const
1040  return d->mValidator->acceptLocalizedNumbers();
1041 }
1042 
1043 void KDoubleSpinBox::setAcceptLocalizedNumbers( bool accept ) {
1044  if ( !d->mValidator ) updateValidator();
1045  d->mValidator->setAcceptLocalizedNumbers( accept );
1046 }
1047 
1048 void KDoubleSpinBox::setRange( double lower, double upper, double step,
1049  int precision ) {
1050  lower = kMin(upper, lower);
1051  upper = kMax(upper, lower);
1052  setPrecision( precision, true ); // disable bounds checking, since
1053  setMinValue( lower ); // it's done in set{Min,Max}Value
1054  setMaxValue( upper ); // anyway and we want lower, upper
1055  setLineStep( step ); // and step to have the right precision
1056 }
1057 
1058 int KDoubleSpinBox::precision() const {
1059  return d->mPrecision;
1060 }
1061 
1062 void KDoubleSpinBox::setPrecision( int precision ) {
1063  setPrecision( precision, false );
1064 }
1065 
1066 void KDoubleSpinBox::setPrecision( int precision, bool force ) {
1067  if ( precision < 0 ) return;
1068  if ( !force ) {
1069  int maxPrec = maxPrecision();
1070  if ( precision > maxPrec )
1071  {
1072  precision = maxPrec;
1073  }
1074  }
1075  // Update minValue, maxValue, value and lineStep to match the precision change
1076  int oldPrecision = d->mPrecision;
1077  double oldValue = value();
1078  double oldMinValue = minValue();
1079  double oldMaxValue = maxValue();
1080  double oldLineStep = lineStep();
1081  d->mPrecision = precision;
1082  if (precision != oldPrecision)
1083  {
1084  setMinValue(oldMinValue);
1085  setMaxValue(oldMaxValue);
1086  setValue(oldValue);
1087  setLineStep(oldLineStep);
1088  }
1089  updateValidator();
1090 }
1091 
1092 int KDoubleSpinBox::maxPrecision() const {
1093  // INT_MAX must be > maxAbsValue * 10^precision
1094  // ==> 10^precision < INT_MAX / maxAbsValue
1095  // ==> precision < log10 ( INT_MAX / maxAbsValue )
1096  // ==> maxPrecision = floor( log10 ( INT_MAX / maxAbsValue ) );
1097  double maxAbsValue = kMax( fabs(minValue()), fabs(maxValue()) );
1098  if ( maxAbsValue == 0 ) return 6; // return arbitrary value to avoid dbz...
1099 
1100  return int( floor( log10( double(INT_MAX) / maxAbsValue ) ) );
1101 }
1102 
1103 double KDoubleSpinBox::value() const {
1104  return d->mapToDouble( base::value() );
1105 }
1106 
1107 void KDoubleSpinBox::setValue( double value ) {
1108  if ( value == this->value() ) return;
1109  if ( value < minValue() )
1110  base::setValue( base::minValue() );
1111  else if ( value > maxValue() )
1112  base::setValue( base::maxValue() );
1113  else {
1114  bool ok = false;
1115  base::setValue( d->mapToInt( value, &ok ) );
1116  assert( ok );
1117  }
1118 }
1119 
1120 double KDoubleSpinBox::minValue() const {
1121  return d->mapToDouble( base::minValue() );
1122 }
1123 
1124 void KDoubleSpinBox::setMinValue( double value ) {
1125  bool ok = false;
1126  int min = d->mapToInt( value, &ok );
1127  base::setMinValue( min );
1128  updateValidator();
1129 }
1130 
1131 
1132 double KDoubleSpinBox::maxValue() const {
1133  return d->mapToDouble( base::maxValue() );
1134 }
1135 
1136 void KDoubleSpinBox::setMaxValue( double value ) {
1137  bool ok = false;
1138  int max = d->mapToInt( value, &ok );
1139  base::setMaxValue( max );
1140  updateValidator();
1141 }
1142 
1143 double KDoubleSpinBox::lineStep() const {
1144  return d->mapToDouble( base::lineStep() );
1145 }
1146 
1147 void KDoubleSpinBox::setLineStep( double step ) {
1148  bool ok = false;
1149  if ( step > maxValue() - minValue() )
1150  base::setLineStep( 1 );
1151  else
1152  base::setLineStep( kMax( d->mapToInt( step, &ok ), 1 ) );
1153 }
1154 
1155 TQString KDoubleSpinBox::mapValueToText( int value ) {
1156  if ( acceptLocalizedNumbers() )
1157  return KGlobal::locale()
1158  ->formatNumber( d->mapToDouble( value ), d->mPrecision );
1159  else
1160  return TQString().setNum( d->mapToDouble( value ), 'f', d->mPrecision );
1161 }
1162 
1163 int KDoubleSpinBox::mapTextToValue( bool * ok ) {
1164  double value;
1165  if ( acceptLocalizedNumbers() )
1166  value = KGlobal::locale()->readNumber( cleanText(), ok );
1167  else
1168  value = cleanText().toDouble( ok );
1169  if ( !*ok ) return 0;
1170  if ( value > maxValue() )
1171  value = maxValue();
1172  else if ( value < minValue() )
1173  value = minValue();
1174  return d->mapToInt( value, ok );
1175 }
1176 
1177 void KDoubleSpinBox::setValidator( const TQValidator * ) {
1178  // silently discard the new validator. We don't want another one ;-)
1179 }
1180 
1181 void KDoubleSpinBox::slotValueChanged( int value ) {
1182  emit valueChanged( d->mapToDouble( value ) );
1183 }
1184 
1185 void KDoubleSpinBox::updateValidator() {
1186  if ( !d->mValidator ) {
1187  d->mValidator = new KDoubleSpinBoxValidator( minValue(), maxValue(), precision(),
1188  this, "d->mValidator" );
1189  base::setValidator( d->mValidator );
1190  } else
1191  d->mValidator->setRange( minValue(), maxValue(), precision() );
1192 }
1193 
1194 void KNumInput::virtual_hook( int, void* )
1195 { /*BASE::virtual_hook( id, data );*/ }
1196 
1197 void KIntNumInput::virtual_hook( int id, void* data )
1198 { KNumInput::virtual_hook( id, data ); }
1199 
1200 void KDoubleNumInput::virtual_hook( int id, void* data )
1201 { KNumInput::virtual_hook( id, data ); }
1202 
1203 void KIntSpinBox::virtual_hook( int, void* )
1204 { /*BASE::virtual_hook( id, data );*/ }
1205 
1206 void KDoubleSpinBox::virtual_hook( int, void* )
1207 { /*BASE::virtual_hook( id, data );*/ }
1208 
1209 #include "knuminput.moc"
KIntNumInput::relativeValue
double relativeValue() const
KIntNumInput::setPrefix
void setPrefix(const TQString &prefix)
Sets the prefix to prefix.
Definition: knuminput.cpp:404
KDoubleNumInput::setPrecision
void setPrecision(int precision)
Specifies the number of digits to use.
Definition: knuminput.cpp:859
KDoubleSpinBox::setPrecision
void setPrecision(int precision)
Equivalent to setPrecision( precision, false ); Needed since Qt's moc doesn't ignore trailing paramet...
Definition: knuminput.cpp:1062
KIntSpinBox::~KIntSpinBox
virtual ~KIntSpinBox()
Destructor.
Definition: knuminput.cpp:213
KGlobal::locale
static KLocale * locale()
KDoubleValidator::validate
virtual TQValidator::State validate(TQString &input, int &pos) const
Overloaded for internal reasons.
Definition: knumvalidator.cpp:326
KDoubleSpinBox::setRange
void setRange(double lower, double upper, double step=0.01, int precision=2)
Sets a new range for the spin box values.
Definition: knuminput.cpp:1048
KIntNumInput::relativeValueChanged
void relativeValueChanged(double)
Emitted whenever valueChanged is.
KNumInput::layout
void layout(bool deep)
Call this function whenever you change something in the geometry of your KNumInput child...
Definition: knuminput.cpp:128
KDoubleSpinBox::acceptLocalizedNumbers
bool acceptLocalizedNumbers() const
KIntNumInput::setLabel
virtual void setLabel(const TQString &label, int a=AlignLeft|AlignTop)
Sets the text and alignment of the main description label.
Definition: knuminput.cpp:529
KDoubleNumInput::setMinValue
void setMinValue(double min)
Sets the minimum value.
Definition: knuminput.cpp:799
KDoubleNumInput::suffix
TQString suffix() const
KDoubleNumInput::specialValueText
TQString specialValueText() const
Definition: knuminput.h:550
KDoubleNumInput::referencePoint
double referencePoint() const
KDoubleNumInput::precision
int precision() const
KDoubleSpinBox
A spin box for fractional numbers.
Definition: knuminput.h:838
KIntNumInput::KIntNumInput
KIntNumInput(TQWidget *parent=0, const char *name=0)
Constructs an input control for integer values with base 10 and initial value 0.
Definition: knuminput.cpp:279
KDoubleSpinBox::minValue
double minValue() const
Definition: knuminput.cpp:1120
KDoubleNumInput::setSpecialValueText
void setSpecialValueText(const TQString &text)
Sets the special value text.
Definition: knuminput.cpp:881
KDoubleNumInput::setSuffix
void setSuffix(const TQString &suffix)
Sets the suffix to be displayed to suffix.
Definition: knuminput.cpp:845
KIntNumInput::setRelativeValue
void setRelativeValue(double)
Sets the value in units of the referencePoint.
Definition: knuminput.cpp:501
klocale.h
KDoubleNumInput::maxValue
double maxValue() const
KDoubleSpinBox::setMinValue
void setMinValue(double value)
Sets the lower bound of the range to value, subject to the contraints that value is first rounded to ...
Definition: knuminput.cpp:1124
KDoubleSpinBox::precision
int precision() const
KNumInput
You need to inherit from this class if you want to implement K*NumInput for a different variable type...
Definition: knuminput.h:49
KDoubleNumInput::valueChanged
void valueChanged(double)
Emitted every time the value changes (by calling setValue() or by user interaction).
KDoubleNumInput::doLayout
virtual void doLayout()
You need to overwrite this method and implement your layout calculations there.
Definition: knuminput.cpp:726
KIntSpinBox::KIntSpinBox
KIntSpinBox(TQWidget *parent=0, const char *name=0)
Constructor.
Definition: knuminput.cpp:204
KIntNumInput::setMaxValue
void setMaxValue(int max)
Sets the maximum value.
Definition: knuminput.cpp:382
KIntNumInput::maxValue
int maxValue() const
KIntNumInput::value
int value() const
KIntSpinBox::base
int base() const
KDialog::spacingHint
static int spacingHint()
Return the number of pixels you shall use between widgets inside a dialog according to the KDE standa...
Definition: kdialog.cpp:109
KIntNumInput::specialValueText
TQString specialValueText() const
KDoubleSpinBox::value
double value() const
Definition: knuminput.cpp:1103
kdWarning
kdbgstream kdWarning(int area=0)
KIntNumInput::setSuffix
void setSuffix(const TQString &suffix)
Sets the suffix to suffix.
Definition: knuminput.cpp:392
KIntNumInput::minimumSizeHint
virtual TQSize minimumSizeHint() const
This method returns the minimum size necessary to display the control.
Definition: knuminput.cpp:421
KDoubleSpinBox::setValue
virtual void setValue(double value)
Sets the current value to value, subject to the constraints that value is first rounded to the curren...
Definition: knuminput.cpp:1107
KIntNumInput::referencePoint
int referencePoint() const
KIntNumInput::suffix
TQString suffix() const
KIntValidator
TQValidator for integers.
Definition: knumvalidator.h:44
KDoubleNumInput::relativeValueChanged
void relativeValueChanged(double)
This is an overloaded member function, provided for convenience.
KIntNumInput::prefix
TQString prefix() const
KDoubleValidator
A locale-aware QDoubleValidator.
Definition: knumvalidator.h:181
KDoubleNumInput::setRelativeValue
void setRelativeValue(double)
Sets the value in units of referencePoint.
Definition: knuminput.cpp:737
KIntNumInput::setRange
void setRange(int min, int max, int step=1, bool slider=true)
Definition: knuminput.cpp:333
KDoubleSpinBox::setAcceptLocalizedNumbers
virtual void setAcceptLocalizedNumbers(bool accept)
Sets whether to use and accept localized numbers as returned by KLocale::formatNumber() ...
Definition: knuminput.cpp:1043
KNumInput::label
TQString label() const
KDoubleNumInput::setReferencePoint
void setReferencePoint(double ref)
Sets the reference Point to ref.
Definition: knuminput.cpp:745
KIntSpinBox
A TQSpinBox with support for arbitrary base numbers.
Definition: knuminput.h:707
KIntSpinBox::mapTextToValue
virtual int mapTextToValue(bool *)
Overloaded the method in QSpinBox to make use of the base given in the constructor.
Definition: knuminput.cpp:247
KLocale::formatNumber
TQString formatNumber(double num, int precision=-1) const
KDoubleNumInput::KDoubleNumInput
KDoubleNumInput(TQWidget *parent=0, const char *name=0)
Constructs an input control for double values with initial value 0.00.
Definition: knuminput.cpp:550
KIntSpinBox::mapValueToText
virtual TQString mapValueToText(int)
Overloaded the method in QSpinBox to make use of the base given in the constructor.
Definition: knuminput.cpp:242
Horizontal
KDoubleNumInput::~KDoubleNumInput
virtual ~KDoubleNumInput()
destructor
Definition: knuminput.cpp:586
KNumInput::sizePolicy
TQSizePolicy sizePolicy() const
Specifies that this widget may stretch horizontally, but is fixed vertically (like TQSpinBox itself)...
Definition: knuminput.cpp:185
KDoubleNumInput::setValue
void setValue(double)
Sets the value of the control.
Definition: knuminput.cpp:732
KIntNumInput::setMinValue
void setMinValue(int min)
Sets the minimum value.
Definition: knuminput.cpp:372
KIntSpinBox::setBase
void setBase(int base)
Sets the base in which the numbers in the spin box are represented.
Definition: knuminput.cpp:227
KIntSpinBox::setEditFocus
void setEditFocus(bool mark)
sets focus and optionally marks all text
Definition: knuminput.cpp:252
KDoubleNumInput::setMaxValue
void setMaxValue(double max)
Sets the maximum value.
Definition: knuminput.cpp:809
KIntNumInput::minValue
int minValue() const
KDoubleNumInput::setPrefix
void setPrefix(const TQString &prefix)
Sets the prefix to be displayed to prefix.
Definition: knuminput.cpp:852
KDoubleSpinBox::KDoubleSpinBox
KDoubleSpinBox(TQWidget *parent=0, const char *name=0)
Constructs a KDoubleSpinBox with parent parent and default values for range and value (whatever QRang...
Definition: knuminput.cpp:1012
KIntNumInput::valueChanged
void valueChanged(int)
Emitted every time the value changes (by calling setValue() or by user interaction).
KDoubleSpinBox::maxValue
double maxValue() const
Definition: knuminput.cpp:1132
KNumInput::sizeHint
virtual TQSize sizeHint() const
Returns a size which fits the contents of the control.
Definition: knuminput.cpp:190
KIntNumInput::doLayout
virtual void doLayout()
You need to overwrite this method and implement your layout calculations there.
Definition: knuminput.cpp:446
KDoubleNumInput::relativeValue
double relativeValue() const
KDoubleNumInput::setRange
void setRange(double min, double max, double step=1, bool slider=true)
Definition: knuminput.cpp:752
KNumInput::setLabel
virtual void setLabel(const TQString &label, int a=AlignLeft|AlignTop)
Sets the text and alignment of the main description label.
Definition: knuminput.cpp:101
endl
kndbgstream & endl(kndbgstream &s)
KDoubleNumInput::value
double value() const
KDoubleSpinBox::setValidator
void setValidator(const TQValidator *)
Overridden to ignore any setValidator() calls.
Definition: knuminput.cpp:1177
KNumInput::KNumInput
KNumInput(TQWidget *parent=0, const char *name=0)
Default constructor.
Definition: knuminput.cpp:62
KNumInput::doLayout
virtual void doLayout()=0
You need to overwrite this method and implement your layout calculations there.
KIntNumInput::~KIntNumInput
virtual ~KIntNumInput()
Destructor.
Definition: knuminput.cpp:490
KDoubleNumInput::prefix
TQString prefix() const
KDoubleSpinBox::lineStep
double lineStep() const
Definition: knuminput.cpp:1143
KDoubleNumInput::minValue
double minValue() const
KIntNumInput::setEditFocus
void setEditFocus(bool mark=true)
sets focus to the edit widget and marks all text in if mark == true
Definition: knuminput.cpp:416
KNumInput::setSteps
void setSteps(int minor, int major)
Sets the spacing of tickmarks for the slider.
Definition: knuminput.cpp:195
KDoubleSpinBox::setLineStep
void setLineStep(double step)
Sets the step size for clicking the up/down buttons to step, subject to the constraints that step is ...
Definition: knuminput.cpp:1147
KIntNumInput::setReferencePoint
void setReferencePoint(int)
Sets the reference point for relativeValue.
Definition: knuminput.cpp:310
KDoubleSpinBox::valueChanged
void valueChanged(double value)
Emitted whenever TQSpinBox::valueChanged( int ) is emitted.
KDoubleNumInput::setLabel
virtual void setLabel(const TQString &label, int a=AlignLeft|AlignTop)
Sets the text and alignment of the main description label.
Definition: knuminput.cpp:889
KIntNumInput::setValue
void setValue(int)
Sets the value of the control.
Definition: knuminput.cpp:495
KDoubleSpinBox::setMaxValue
void setMaxValue(double value)
Sets the upper bound of the range to value, subject to the contraints that value is first rounded to ...
Definition: knuminput.cpp:1136
KLocale::readNumber
double readNumber(const TQString &numStr, bool *ok=0) const
KIntNumInput::setSpecialValueText
void setSpecialValueText(const TQString &text)
Sets the special value text.
Definition: knuminput.cpp:518

kdeui

Skip menu "kdeui"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdeui

Skip menu "kdeui"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kdeui by doxygen 1.8.8
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |