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

tdeui

  • tdeui
knuminput.h
1 /*
2  * knuminput.h
3  *
4  * Copyright (c) 1997 Patrick Dowler <dowler@morgul.fsh.uvic.ca>
5  * Copyright (c) 2000 Dirk A. Mueller <mueller@kde.org>
6  * Copyright (c) 2002 Marc Mutz <mutz@kde.org>
7  *
8  * Requires the Qt widget libraries, available at no cost at
9  * http://www.troll.no/
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Library General Public
13  * License as published by the Free Software Foundation; either
14  * version 2 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Library General Public License for more details.
20  *
21  * You should have received a copy of the GNU Library General Public License
22  * along with this library; see the file COPYING.LIB. If not, write to
23  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24  * Boston, MA 02110-1301, USA.
25  */
26 
27 #ifndef K_NUMINPUT_H
28 #define K_NUMINPUT_H
29 
30 #include <tqwidget.h>
31 #include <tqspinbox.h>
32 #include <tdelibs_export.h>
33 
34 class TQLabel;
35 class TQSlider;
36 class TQLineEdit;
37 class TQLayout;
38 class TQValidator;
39 
40 class KIntSpinBox;
41 
42 /* ------------------------------------------------------------------------ */
43 
49 class TDEUI_EXPORT KNumInput : public TQWidget
50 {
51  Q_OBJECT
52 
53  TQ_PROPERTY( TQString label READ label WRITE setLabel )
54 public:
60  KNumInput(TQWidget* parent=0, const char* name=0);
61 
67  KNumInput(KNumInput* below, TQWidget* parent=0, const char* name=0);
68  ~KNumInput();
69 
88  virtual void setLabel(const TQString & label, int a = AlignLeft | AlignTop);
89 
93  TQString label() const;
94 
99  bool showSlider() const { return m_slider; }
100 
107  void setSteps(int minor, int major);
108 
113  TQSizePolicy sizePolicy() const;
114 
120  virtual TQSize sizeHint() const;
121 
122 protected:
128  void layout(bool deep);
129 
138  virtual void doLayout() = 0;
139 
140  KNumInput* m_prev, *m_next;
141  int m_colw1, m_colw2;
142 
143  TQLabel* m_label;
144  TQSlider* m_slider;
145  TQSize m_sizeSlider, m_sizeLabel;
146 
147  int m_alignment;
148 
149 private:
150  void init();
151 
152 protected:
153  virtual void virtual_hook( int id, void* data );
154 private:
155  class KNumInputPrivate;
156  KNumInputPrivate *d;
157 };
158 
159 /* ------------------------------------------------------------------------ */
160 
188 class TDEUI_EXPORT KIntNumInput : public KNumInput
189 {
190  Q_OBJECT
191 
192  TQ_PROPERTY( int value READ value WRITE setValue )
193  TQ_PROPERTY( int minValue READ minValue WRITE setMinValue )
194  TQ_PROPERTY( int maxValue READ maxValue WRITE setMaxValue )
195  TQ_PROPERTY( int referencePoint READ referencePoint WRITE setReferencePoint )
196  TQ_PROPERTY( double relativeValue READ relativeValue WRITE setRelativeValue )
197  TQ_PROPERTY( TQString suffix READ suffix WRITE setSuffix )
198  TQ_PROPERTY( TQString prefix READ prefix WRITE setPrefix )
199  TQ_PROPERTY( TQString specialValueText READ specialValueText WRITE setSpecialValueText )
200 
201 public:
206  KIntNumInput(TQWidget *parent=0, const char *name=0);
219  KIntNumInput(int value, TQWidget* parent=0, int base = 10, const char *name=0);
220 
238  KIntNumInput(KNumInput* below, int value, TQWidget* parent=0, int base = 10, const char *name=0);
239 
245  virtual ~KIntNumInput();
246 
250  int value() const;
251 
256  double relativeValue() const;
257 
262  int referencePoint() const;
263 
268  TQString suffix() const;
273  TQString prefix() const;
278  TQString specialValueText() const;
279 
286  void setRange(int min, int max, int step=1, bool slider=true);
290  void setMinValue(int min);
294  int minValue() const;
298  void setMaxValue(int max);
302  int maxValue() const;
303 
310  void setSpecialValueText(const TQString& text);
311 
312  virtual void setLabel(const TQString & label, int a = AlignLeft | AlignTop);
313 
321  virtual TQSize minimumSizeHint() const;
322 
323 public slots:
327  void setValue(int);
328 
333  void setRelativeValue(double);
334 
339  void setReferencePoint(int);
340 
350  void setSuffix(const TQString &suffix);
351 
359  void setPrefix(const TQString &prefix);
360 
365  void setEditFocus( bool mark = true );
366 
367 signals:
372  void valueChanged(int);
373 
379  void relativeValueChanged(double);
380 
381 private slots:
382  void spinValueChanged(int);
383  void slotEmitRelativeValueChanged(int);
384 
385 protected:
386  virtual void doLayout();
387  void resizeEvent ( TQResizeEvent * );
388 
389  KIntSpinBox* m_spin;
390  TQSize m_sizeSpin;
391 
392 private:
393  void init(int value, int _base);
394 
395 protected:
396  virtual void virtual_hook( int id, void* data );
397 private:
398  class KIntNumInputPrivate;
399  KIntNumInputPrivate *d;
400 };
401 
402 
403 /* ------------------------------------------------------------------------ */
404 
405 class KDoubleLine;
406 
434 class TDEUI_EXPORT KDoubleNumInput : public KNumInput
435 {
436  Q_OBJECT
437 
438  TQ_PROPERTY( double value READ value WRITE setValue )
439  TQ_PROPERTY( double minValue READ minValue WRITE setMinValue )
440  TQ_PROPERTY( double maxValue READ maxValue WRITE setMaxValue )
441  TQ_PROPERTY( TQString suffix READ suffix WRITE setSuffix )
442  TQ_PROPERTY( TQString prefix READ prefix WRITE setPrefix )
443  TQ_PROPERTY( TQString specialValueText READ specialValueText WRITE setSpecialValueText )
444  TQ_PROPERTY( int precision READ precision WRITE setPrecision )
445  TQ_PROPERTY( double referencePoint READ referencePoint WRITE setReferencePoint )
446  TQ_PROPERTY( double relativeValue READ relativeValue WRITE setRelativeValue )
447 
448 public:
453  KDoubleNumInput(TQWidget *parent=0, const char *name=0);
454 
463  KDoubleNumInput(double value, TQWidget *parent=0, const char *name=0) KDE_DEPRECATED;
464 
477  KDoubleNumInput(double lower, double upper, double value, double step=0.01,
478  int precision=2, TQWidget *parent=0, const char *name=0);
479 
483  virtual ~KDoubleNumInput();
484 
496  KDoubleNumInput(KNumInput* below, double value, TQWidget* parent=0, const char* name=0) KDE_DEPRECATED;
497 
519  KDoubleNumInput(KNumInput* below,
520  double lower, double upper, double value, double step=0.02,
521  int precision=2, TQWidget *parent=0, const char *name=0);
522 
526  double value() const;
527 
532  TQString suffix() const;
533 
538  TQString prefix() const;
539 
544  int precision() const;
545 
550  TQString specialValueText() const { return m_specialvalue; }
551 
558  void setRange(double min, double max, double step=1, bool slider=true);
562  void setMinValue(double min);
566  double minValue() const;
570  void setMaxValue(double max);
574  double maxValue() const;
575 
579  void setPrecision(int precision);
580 
585  double referencePoint() const;
586 
591  double relativeValue() const;
592 
599  void setSpecialValueText(const TQString& text);
600 
601  virtual void setLabel(const TQString & label, int a = AlignLeft | AlignTop);
602  virtual TQSize minimumSizeHint() const;
603  virtual bool eventFilter(TQObject*, TQEvent*);
604 
605 public slots:
609  void setValue(double);
610 
615  void setRelativeValue(double);
616 
623  void setReferencePoint(double ref);
624 
632  void setSuffix(const TQString &suffix);
633 
640  void setPrefix(const TQString &prefix);
641 
642 signals:
647  void valueChanged(double);
655  void relativeValueChanged(double);
656 
657 private slots:
658  void sliderMoved(int);
659  void slotEmitRelativeValueChanged(double);
660 
661 protected:
662  virtual void doLayout();
663  void resizeEvent ( TQResizeEvent * );
664 
665  virtual void resetEditBox();
666 
667  // ### no longer used, remove when BIC allowed
668  KDoubleLine* edit;
669 
670  bool m_range;
671  double m_lower, m_upper, m_step;
672  // ### end no longer used
673 
674  TQSize m_sizeEdit;
675 
676  friend class KDoubleLine;
677 private:
678  void init(double value, double lower, double upper,
679  double step, int precision);
680  double mapSliderToSpin(int) const;
681  void updateLegacyMembers();
682  // ### no longer used, remove when BIC allowed:
683  TQString m_specialvalue, m_prefix, m_suffix;
684  double m_value;
685  short m_precision;
686  // ### end remove when BIC allowed
687 
688 protected:
689  virtual void virtual_hook( int id, void* data );
690 private:
691  class KDoubleNumInputPrivate;
692  KDoubleNumInputPrivate *d;
693 };
694 
695 
696 /* ------------------------------------------------------------------------ */
697 
707 class TDEUI_EXPORT KIntSpinBox : public TQSpinBox
708 {
709  Q_OBJECT
710 
711  TQ_PROPERTY( int base READ base WRITE setBase )
712 
713 public:
714 
722  KIntSpinBox( TQWidget *parent=0, const char *name=0);
723 
738  KIntSpinBox(int lower, int upper, int step, int value, int base = 10,
739  TQWidget* parent = 0, const char* name = 0);
740 
744  virtual ~KIntSpinBox();
745 
749  void setBase(int base);
753  int base() const;
758  void setEditFocus(bool mark);
759 
760 protected:
761 
766  virtual TQString mapValueToText(int);
767 
772  virtual int mapTextToValue(bool*);
773 
774 private:
775  int val_base;
776 protected:
777  virtual void virtual_hook( int id, void* data );
778 private:
779  class KIntSpinBoxPrivate;
780  KIntSpinBoxPrivate *d;
781 };
782 
783 
784 /* --------------------------------------------------------------------------- */
785 
838 class TDEUI_EXPORT KDoubleSpinBox : public TQSpinBox {
839  Q_OBJECT
840 
841  TQ_PROPERTY( bool acceptLocalizedNumbers READ acceptLocalizedNumbers WRITE setAcceptLocalizedNumbers )
842  TQ_OVERRIDE( double maxValue READ maxValue WRITE setMaxValue )
843  TQ_OVERRIDE( double minValue READ minValue WRITE setMinValue )
844  TQ_OVERRIDE( double lineStep READ lineStep WRITE setLineStep )
845  TQ_OVERRIDE( double value READ value WRITE setValue )
846  TQ_PROPERTY( int precision READ precision WRITE setPrecision )
847 
848 public:
852  KDoubleSpinBox( TQWidget * parent=0, const char * name=0 );
853 
857  KDoubleSpinBox( double lower, double upper, double step, double value,
858  int precision=2, TQWidget * parent=0, const char * name=0 );
859 
860  virtual ~KDoubleSpinBox();
861 
863  bool acceptLocalizedNumbers() const;
864 
867  virtual void setAcceptLocalizedNumbers( bool accept );
868 
872  void setRange( double lower, double upper, double step=0.01, int precision=2 );
873 
876  int precision() const;
877 
881  void setPrecision( int precision );
882 
895  virtual void setPrecision( int precision, bool force );
896 
898  double value() const;
899 
901  double minValue() const;
902 
909  void setMinValue( double value );
910 
912  double maxValue() const;
913 
920  void setMaxValue( double value );
921 
923  double lineStep() const;
924 
929  void setLineStep( double step );
930 
932  void setValidator( const TQValidator * );
933 
934 signals:
936  void valueChanged( double value );
937 
938 public slots:
942  virtual void setValue( double value );
943 
944 protected:
945  virtual TQString mapValueToText(int);
946  virtual int mapTextToValue(bool*);
947 
948 protected slots:
949  void slotValueChanged( int value );
950 
951 protected:
952  virtual void virtual_hook( int id, void* data );
953 private:
954  typedef TQSpinBox base;
955  void updateValidator();
956  int maxPrecision() const;
957 
958  class Private;
959  Private * d;
960 };
961 
962 #endif // K_NUMINPUT_H
KNumInput::showSlider
bool showSlider() const
Definition: knuminput.h:99
KDoubleNumInput::specialValueText
TQString specialValueText() const
Definition: knuminput.h:550
KDoubleSpinBox
A spin box for fractional numbers.
Definition: knuminput.h:838
KNumInput
You need to inherit from this class if you want to implement K*NumInput for a different variable type...
Definition: knuminput.h:49
KIntSpinBox
A TQSpinBox with support for arbitrary base numbers.
Definition: knuminput.h:707
KDoubleNumInput
An input control for real numbers, consisting of a spinbox and a slider.
Definition: knuminput.h:434
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
KNumInput::doLayout
virtual void doLayout()=0
You need to overwrite this method and implement your layout calculations there.
KIntNumInput
An input widget for integer numbers, consisting of a spinbox and a slider.
Definition: knuminput.h:188

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.