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

tdeui

  • tdeui
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 <tdeglobal.h>
48 #include <tdelocale.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 = TQMAX(w1, p->m_colw1);
156  w2 = TQMAX(w2, p->m_colw2);
157  p = p->m_prev;
158  }
159 
160  p = m_next;
161  while(p) {
162  p->doLayout();
163  w1 = TQMAX(w1, p->m_colw1);
164  w2 = TQMAX(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 + TQMAX(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 = TQMAX(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 = TQMAX(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 : TQMAX(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, TQMAX(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 + TQMAX(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 = TQMAX(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 = TQMAX(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->setLineStep(slstep);
773  m_slider->setValue(slvalue);
774  } else {
775  m_slider = new TQSlider(slmin, slmax, slstep, slvalue,
776  Qt::Horizontal, this);
777  m_slider->setTickmarks(TQSlider::Below);
778  // feedback line: when one moves, the other moves, too:
779  connect(m_slider, TQT_SIGNAL(valueChanged(int)),
780  TQT_SLOT(sliderMoved(int)) );
781  }
782  connect(spin, TQT_SIGNAL(valueChanged(int)),
783  m_slider, TQT_SLOT(setValue(int)) );
784  // calculate ( slmax - slmin ) / 10 without overflowing ints:
785  int major = calcDiffByTen( slmax, slmin );
786  if ( !major ) major = slstep; // ### needed?
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 
863  layout(true);
864 }
865 
866 int KDoubleNumInput::precision() const
867 {
868  return d->spin->precision();
869 }
870 
871 void KDoubleNumInput::setSpecialValueText(const TQString& text)
872 {
873  d->spin->setSpecialValueText( text );
874 
875  layout(true);
876  updateLegacyMembers();
877 }
878 
879 void KDoubleNumInput::setLabel(const TQString & label, int a)
880 {
881  KNumInput::setLabel(label, a);
882 
883  if(m_label)
884  m_label->setBuddy(d->spin);
885 
886 }
887 
888 // ----------------------------------------------------------------------------
889 
890 
891 class KDoubleSpinBoxValidator : public KDoubleValidator
892 {
893 public:
894  KDoubleSpinBoxValidator( double bottom, double top, int decimals, KDoubleSpinBox* sb, const char *name )
895  : KDoubleValidator( bottom, top, decimals, TQT_TQOBJECT(sb), name ), spinBox( sb ) { }
896 
897  virtual State validate( TQString& str, int& pos ) const;
898 
899 private:
900  KDoubleSpinBox *spinBox;
901 };
902 
903 TQValidator::State KDoubleSpinBoxValidator::validate( TQString& str, int& pos ) const
904 {
905  TQString pref = spinBox->prefix();
906  TQString suff = spinBox->suffix();
907  TQString suffStriped = suff.stripWhiteSpace();
908  uint overhead = pref.length() + suff.length();
909  State state = Invalid;
910 
911  if ( overhead == 0 ) {
912  state = KDoubleValidator::validate( str, pos );
913  } else {
914  bool stripedVersion = false;
915  if ( str.length() >= overhead && str.startsWith(pref)
916  && (str.endsWith(suff)
917  || (stripedVersion = str.endsWith(suffStriped))) ) {
918  if ( stripedVersion )
919  overhead = pref.length() + suffStriped.length();
920  TQString core = str.mid( pref.length(), str.length() - overhead );
921  int corePos = pos - pref.length();
922  state = KDoubleValidator::validate( core, corePos );
923  pos = corePos + pref.length();
924  str.replace( pref.length(), str.length() - overhead, core );
925  } else {
926  state = KDoubleValidator::validate( str, pos );
927  if ( state == Invalid ) {
928  // stripWhiteSpace(), cf. TQSpinBox::interpretText()
929  TQString special = spinBox->specialValueText().stripWhiteSpace();
930  TQString candidate = str.stripWhiteSpace();
931 
932  if ( special.startsWith(candidate) ) {
933  if ( candidate.length() == special.length() ) {
934  state = Acceptable;
935  } else {
936  state = Intermediate;
937  }
938  }
939  }
940  }
941  }
942  return state;
943 }
944 
945 // We use a kind of fixed-point arithmetic to represent the range of
946 // doubles [mLower,mUpper] in steps of 10^(-mPrecision). Thus, the
947 // following relations hold:
948 //
949 // 1. factor = 10^mPrecision
950 // 2. basicStep = 1/factor = 10^(-mPrecision);
951 // 3. lowerInt = lower * factor;
952 // 4. upperInt = upper * factor;
953 // 5. lower = lowerInt * basicStep;
954 // 6. upper = upperInt * basicStep;
955 class KDoubleSpinBox::Private {
956 public:
957  Private( int precision=1 )
958  : mPrecision( precision ),
959  mValidator( 0 )
960  {
961  }
962 
963  int factor() const {
964  int f = 1;
965  for ( int i = 0 ; i < mPrecision ; ++i ) f *= 10;
966  return f;
967  }
968 
969  double basicStep() const {
970  return 1.0/double(factor());
971  }
972 
973  int mapToInt( double value, bool * ok ) const {
974  assert( ok );
975  const double f = factor();
976  if ( value > double(INT_MAX) / f ) {
977  kdWarning() << "KDoubleSpinBox: can't represent value " << value
978  << "in terms of fixed-point numbers with precision "
979  << mPrecision << endl;
980  *ok = false;
981  return INT_MAX;
982  } else if ( value < double(INT_MIN) / f ) {
983  kdWarning() << "KDoubleSpinBox: can't represent value " << value
984  << "in terms of fixed-point numbers with precision "
985  << mPrecision << endl;
986  *ok = false;
987  return INT_MIN;
988  } else {
989  *ok = true;
990  return int( value * f + ( value < 0 ? -0.5 : 0.5 ) );
991  }
992  }
993 
994  double mapToDouble( int value ) const {
995  return double(value) * basicStep();
996  }
997 
998  int mPrecision;
999  KDoubleSpinBoxValidator * mValidator;
1000 };
1001 
1002 KDoubleSpinBox::KDoubleSpinBox( TQWidget * parent, const char * name )
1003  : TQSpinBox( parent, name )
1004 {
1005  editor()->setAlignment( Qt::AlignRight );
1006  d = new Private();
1007  updateValidator();
1008  connect( this, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(slotValueChanged(int)) );
1009 }
1010 
1011 KDoubleSpinBox::KDoubleSpinBox( double lower, double upper, double step,
1012  double value, int precision,
1013  TQWidget * parent, const char * name )
1014  : TQSpinBox( parent, name )
1015 {
1016  editor()->setAlignment( Qt::AlignRight );
1017  d = new Private();
1018  setRange( lower, upper, step, precision );
1019  setValue( value );
1020  connect( this, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(slotValueChanged(int)) );
1021 }
1022 
1023 KDoubleSpinBox::~KDoubleSpinBox() {
1024  delete d; d = 0;
1025 }
1026 
1027 bool KDoubleSpinBox::acceptLocalizedNumbers() const {
1028  if ( !d->mValidator ) return true; // we'll set one that does;
1029  // can't do it now, since we're const
1030  return d->mValidator->acceptLocalizedNumbers();
1031 }
1032 
1033 void KDoubleSpinBox::setAcceptLocalizedNumbers( bool accept ) {
1034  if ( !d->mValidator ) updateValidator();
1035  d->mValidator->setAcceptLocalizedNumbers( accept );
1036 }
1037 
1038 void KDoubleSpinBox::setRange( double lower, double upper, double step,
1039  int precision ) {
1040  lower = kMin(upper, lower);
1041  upper = kMax(upper, lower);
1042  setPrecision( precision, true ); // disable bounds checking, since
1043  setMinValue( lower ); // it's done in set{Min,Max}Value
1044  setMaxValue( upper ); // anyway and we want lower, upper
1045  setLineStep( step ); // and step to have the right precision
1046 }
1047 
1048 int KDoubleSpinBox::precision() const {
1049  return d->mPrecision;
1050 }
1051 
1052 void KDoubleSpinBox::setPrecision( int precision ) {
1053  setPrecision( precision, false );
1054 }
1055 
1056 void KDoubleSpinBox::setPrecision( int precision, bool force ) {
1057  if ( precision < 1 ) return;
1058  if ( !force ) {
1059  int maxPrec = maxPrecision();
1060  if ( precision > maxPrec )
1061  precision = maxPrec;
1062  }
1063  d->mPrecision = precision;
1064  updateValidator();
1065 }
1066 
1067 int KDoubleSpinBox::maxPrecision() const {
1068  // INT_MAX must be > maxAbsValue * 10^precision
1069  // ==> 10^precision < INT_MAX / maxAbsValue
1070  // ==> precision < log10 ( INT_MAX / maxAbsValue )
1071  // ==> maxPrecision = floor( log10 ( INT_MAX / maxAbsValue ) );
1072  double maxAbsValue = kMax( fabs(minValue()), fabs(maxValue()) );
1073  if ( maxAbsValue == 0 ) return 6; // return arbitrary value to avoid dbz...
1074 
1075  return int( floor( log10( double(INT_MAX) / maxAbsValue ) ) );
1076 }
1077 
1078 double KDoubleSpinBox::value() const {
1079  return d->mapToDouble( base::value() );
1080 }
1081 
1082 void KDoubleSpinBox::setValue( double value ) {
1083  if ( value == this->value() ) return;
1084  if ( value < minValue() )
1085  base::setValue( base::minValue() );
1086  else if ( value > maxValue() )
1087  base::setValue( base::maxValue() );
1088  else {
1089  bool ok = false;
1090  base::setValue( d->mapToInt( value, &ok ) );
1091  assert( ok );
1092  }
1093 }
1094 
1095 double KDoubleSpinBox::minValue() const {
1096  return d->mapToDouble( base::minValue() );
1097 }
1098 
1099 void KDoubleSpinBox::setMinValue( double value ) {
1100  bool ok = false;
1101  int min = d->mapToInt( value, &ok );
1102  base::setMinValue( min );
1103  updateValidator();
1104 }
1105 
1106 
1107 double KDoubleSpinBox::maxValue() const {
1108  return d->mapToDouble( base::maxValue() );
1109 }
1110 
1111 void KDoubleSpinBox::setMaxValue( double value ) {
1112  bool ok = false;
1113  int max = d->mapToInt( value, &ok );
1114  base::setMaxValue( max );
1115  updateValidator();
1116 }
1117 
1118 double KDoubleSpinBox::lineStep() const {
1119  return d->mapToDouble( base::lineStep() );
1120 }
1121 
1122 void KDoubleSpinBox::setLineStep( double step ) {
1123  bool ok = false;
1124  if ( step > maxValue() - minValue() )
1125  base::setLineStep( 1 );
1126  else
1127  base::setLineStep( kMax( d->mapToInt( step, &ok ), 1 ) );
1128 }
1129 
1130 TQString KDoubleSpinBox::mapValueToText( int value ) {
1131  if ( acceptLocalizedNumbers() )
1132  return TDEGlobal::locale()
1133  ->formatNumber( d->mapToDouble( value ), d->mPrecision );
1134  else
1135  return TQString().setNum( d->mapToDouble( value ), 'f', d->mPrecision );
1136 }
1137 
1138 int KDoubleSpinBox::mapTextToValue( bool * ok ) {
1139  double value;
1140  if ( acceptLocalizedNumbers() )
1141  value = TDEGlobal::locale()->readNumber( cleanText(), ok );
1142  else
1143  value = cleanText().toDouble( ok );
1144  if ( !*ok ) return 0;
1145  if ( value > maxValue() )
1146  value = maxValue();
1147  else if ( value < minValue() )
1148  value = minValue();
1149  return d->mapToInt( value, ok );
1150 }
1151 
1152 void KDoubleSpinBox::setValidator( const TQValidator * ) {
1153  // silently discard the new validator. We don't want another one ;-)
1154 }
1155 
1156 void KDoubleSpinBox::slotValueChanged( int value ) {
1157  emit valueChanged( d->mapToDouble( value ) );
1158 }
1159 
1160 void KDoubleSpinBox::updateValidator() {
1161  if ( !d->mValidator ) {
1162  d->mValidator = new KDoubleSpinBoxValidator( minValue(), maxValue(), precision(),
1163  this, "d->mValidator" );
1164  base::setValidator( d->mValidator );
1165  } else
1166  d->mValidator->setRange( minValue(), maxValue(), precision() );
1167 }
1168 
1169 void KNumInput::virtual_hook( int, void* )
1170 { /*BASE::virtual_hook( id, data );*/ }
1171 
1172 void KIntNumInput::virtual_hook( int id, void* data )
1173 { KNumInput::virtual_hook( id, data ); }
1174 
1175 void KDoubleNumInput::virtual_hook( int id, void* data )
1176 { KNumInput::virtual_hook( id, data ); }
1177 
1178 void KIntSpinBox::virtual_hook( int, void* )
1179 { /*BASE::virtual_hook( id, data );*/ }
1180 
1181 void KDoubleSpinBox::virtual_hook( int, void* )
1182 { /*BASE::virtual_hook( id, data );*/ }
1183 
1184 #include "knuminput.moc"
KIntNumInput::relativeValue
double relativeValue() const
Definition: knuminput.cpp:508
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&#39;s moc doesn&#39;t ignore trailing paramet...
Definition: knuminput.cpp:1052
KIntSpinBox::~KIntSpinBox
virtual ~KIntSpinBox()
Destructor.
Definition: knuminput.cpp:213
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:1038
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
Definition: knuminput.cpp:1027
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
Definition: knuminput.cpp:835
KDoubleNumInput::specialValueText
TQString specialValueText() const
Definition: knuminput.h:550
KDoubleNumInput::referencePoint
double referencePoint() const
Definition: knuminput.cpp:830
KDoubleNumInput::precision
int precision() const
Definition: knuminput.cpp:866
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:1095
KDoubleNumInput::setSpecialValueText
void setSpecialValueText(const TQString &text)
Sets the special value text.
Definition: knuminput.cpp:871
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
KDoubleNumInput::maxValue
double maxValue() const
Definition: knuminput.cpp:814
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:1099
KDoubleSpinBox::precision
int precision() const
Definition: knuminput.cpp:1048
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
Definition: knuminput.cpp:387
KIntNumInput::value
int value() const
Definition: knuminput.cpp:513
tdelocale.h
KIntSpinBox::base
int base() const
Definition: knuminput.cpp:237
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:110
KIntNumInput::specialValueText
TQString specialValueText() const
Definition: knuminput.cpp:524
KDoubleSpinBox::value
double value() const
Definition: knuminput.cpp:1078
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:1082
KIntNumInput::referencePoint
int referencePoint() const
Definition: knuminput.cpp:316
KIntNumInput::suffix
TQString suffix() const
Definition: knuminput.cpp:399
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
Definition: knuminput.cpp:411
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
TDELocale::readNumber
double readNumber(const TQString &numStr, bool *ok=0) const
KDoubleSpinBox::setAcceptLocalizedNumbers
virtual void setAcceptLocalizedNumbers(bool accept)
Sets whether to use and accept localized numbers as returned by TDELocale::formatNumber() ...
Definition: knuminput.cpp:1033
KNumInput::label
TQString label() const
Definition: knuminput.cpp:122
KDoubleNumInput::setReferencePoint
void setReferencePoint(double ref)
Sets the reference Point to ref.
Definition: knuminput.cpp:745
TDEGlobal::locale
static TDELocale * locale()
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
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
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
Definition: knuminput.cpp:377
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:1002
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:1107
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
Definition: knuminput.cpp:824
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
Definition: knuminput.cpp:819
KDoubleSpinBox::setValidator
void setValidator(const TQValidator *)
Overridden to ignore any setValidator() calls.
Definition: knuminput.cpp:1152
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
Definition: knuminput.cpp:840
KDoubleSpinBox::lineStep
double lineStep() const
Definition: knuminput.cpp:1118
KDoubleNumInput::minValue
double minValue() const
Definition: knuminput.cpp:804
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:1122
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:879
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:1111
KIntNumInput::setSpecialValueText
void setSpecialValueText(const TQString &text)
Sets the special value text.
Definition: knuminput.cpp:518
TDELocale::formatNumber
TQString formatNumber(double num, int precision=-1) const

tdeui

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

tdeui

Skip menu "tdeui"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeui by doxygen 1.8.11
This website is maintained by Timothy Pearson.