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

tdeui

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