summaryrefslogtreecommitdiffabout
path: root/microkde/kdeui/knuminput.h
Unidiff
Diffstat (limited to 'microkde/kdeui/knuminput.h') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdeui/knuminput.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/microkde/kdeui/knuminput.h b/microkde/kdeui/knuminput.h
index 123fefa..9f9e200 100644
--- a/microkde/kdeui/knuminput.h
+++ b/microkde/kdeui/knuminput.h
@@ -1,132 +1,137 @@
1/* 1/*
2 * knuminput.h 2 * knuminput.h
3 * 3 *
4 * Copyright (c) 1997 Patrick Dowler <dowler@morgul.fsh.uvic.ca> 4 * Copyright (c) 1997 Patrick Dowler <dowler@morgul.fsh.uvic.ca>
5 * Copyright (c) 2000 Dirk A. Mueller <mueller@kde.org> 5 * Copyright (c) 2000 Dirk A. Mueller <mueller@kde.org>
6 * Copyright (c) 2002 Marc Mutz <mutz@kde.org> 6 * Copyright (c) 2002 Marc Mutz <mutz@kde.org>
7 * 7 *
8 * Requires the Qt widget libraries, available at no cost at 8 * Requires the Qt widget libraries, available at no cost at
9 * http://www.troll.no/ 9 * http://www.troll.no/
10 * 10 *
11 * This library is free software; you can redistribute it and/or 11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public 12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either 13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version. 14 * version 2 of the License, or (at your option) any later version.
15 * 15 *
16 * This library is distributed in the hope that it will be useful, 16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details. 19 * Library General Public License for more details.
20 * 20 *
21 * You should have received a copy of the GNU Library General Public License 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 22 * along with this library; see the file COPYING.LIB. If not, write to
23 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 23 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 * Boston, MA 02111-1307, USA. 24 * Boston, MA 02111-1307, USA.
25 */ 25 */
26 26
27#ifndef K_NUMINPUT_H 27#ifndef K_NUMINPUT_H
28#define K_NUMINPUT_H 28#define K_NUMINPUT_H
29 29
30#include <qwidget.h> 30#include <qwidget.h>
31#include <qspinbox.h> 31#include <qspinbox.h>
32#include <QLineEdit>
33//Added by qt3to4:
34#include <QResizeEvent>
35#include <QLabel>
36#include <QEvent>
32 37
33class QLabel; 38class QLabel;
34class QSlider; 39class QSlider;
35class QLineEdit; 40class QLineEdit;
36class QLayout; 41class QLayout;
37class QValidator; 42class QValidator;
38 43
39class KIntSpinBox; 44class KIntSpinBox;
40 45
41/* ------------------------------------------------------------------------ */ 46/* ------------------------------------------------------------------------ */
42 47
43/** 48/**
44 * You need to inherit from this class if you want to implement K*NumInput 49 * You need to inherit from this class if you want to implement K*NumInput
45 * for a different variable type 50 * for a different variable type
46 * 51 *
47 */ 52 */
48class KNumInput : public QWidget 53class KNumInput : public QWidget
49{ 54{
50 Q_OBJECT 55 Q_OBJECT
51 Q_PROPERTY( QString label READ label WRITE setLabel ) 56 Q_PROPERTY( QString label READ label WRITE setLabel )
52public: 57public:
53 /** 58 /**
54 * Default constructor 59 * Default constructor
55 * 60 *
56 */ 61 */
57 KNumInput(QWidget* parent=0, const char* name=0); 62 KNumInput(QWidget* parent=0, const char* name=0);
58 63
59 /** 64 /**
60 * @param below A pointer to another KNumInput. 65 * @param below A pointer to another KNumInput.
61 * 66 *
62 */ 67 */
63 KNumInput(KNumInput* below, QWidget* parent=0, const char* name=0); 68 KNumInput(KNumInput* below, QWidget* parent=0, const char* name=0);
64 ~KNumInput(); 69 ~KNumInput();
65 70
66 /** 71 /**
67 * Sets the text and alignment of the main description label. 72 * Sets the text and alignment of the main description label.
68 * 73 *
69 * @param label The text of the label. 74 * @param label The text of the label.
70 * Use QString::null to remove an existing one. 75 * Use QString::null to remove an existing one.
71 * 76 *
72 * @param a one of @p AlignLeft, @p AlignHCenter, YAlignRight and 77 * @param a one of @p AlignLeft, @p AlignHCenter, YAlignRight and
73 * @p AlignTop, @p AlignVCenter, @p AlignBottom. 78 * @p AlignTop, @p AlignVCenter, @p AlignBottom.
74 * default is @p AlignLeft | @p AlignTop. 79 * default is @p AlignLeft | @p AlignTop.
75 * 80 *
76 * The vertical alignment flags have special meaning with this 81 * The vertical alignment flags have special meaning with this
77 * widget: 82 * widget:
78 * 83 *
79 * @li @p AlignTop The label is placed above the edit/slider 84 * @li @p AlignTop The label is placed above the edit/slider
80 * @li @p AlignVCenter The label is placed left beside the edit 85 * @li @p AlignVCenter The label is placed left beside the edit
81 * @li @p AlignBottom The label is placed below the edit/slider 86 * @li @p AlignBottom The label is placed below the edit/slider
82 * 87 *
83 */ 88 */
84 virtual void setLabel(const QString & label, int a = AlignLeft | AlignTop); 89 virtual void setLabel(const QString & label, int a = Qt::AlignLeft | Qt::AlignTop);
85 90
86 /** 91 /**
87 * @return the text of the label. 92 * @return the text of the label.
88 */ 93 */
89 QString label() const; 94 QString label() const;
90 95
91 /** 96 /**
92 * @return if the num input has a slider. 97 * @return if the num input has a slider.
93 * @since 3.1 98 * @since 3.1
94 */ 99 */
95 bool showSlider() const { return m_slider; } 100 bool showSlider() const { return m_slider; }
96 101
97 /** 102 /**
98 * Sets the spacing of tickmarks for the slider. 103 * Sets the spacing of tickmarks for the slider.
99 * 104 *
100 * @param minor Minor tickmark separation. 105 * @param minor Minor tickmark separation.
101 * @param major Major tickmark separation. 106 * @param major Major tickmark separation.
102 */ 107 */
103 void setSteps(int minor, int major); 108 void setSteps(int minor, int major);
104 109
105 /** 110 /**
106 * Specifies that this widget may stretch horizontally, but is 111 * Specifies that this widget may stretch horizontally, but is
107 * fixed vertically (like @ref QSpinBox itself). 112 * fixed vertically (like @ref QSpinBox itself).
108 */ 113 */
109 QSizePolicy sizePolicy() const; 114 QSizePolicy sizePolicy() const;
110 115
111 /** 116 /**
112 * Returns a size which fits the contents of the control. 117 * Returns a size which fits the contents of the control.
113 * 118 *
114 * @return the preferred size necessary to show the control 119 * @return the preferred size necessary to show the control
115 */ 120 */
116 virtual QSize sizeHint() const; 121 virtual QSize sizeHint() const;
117 122
118protected: 123protected:
119 /** 124 /**
120 * Call this function whenever you change something in the geometry 125 * Call this function whenever you change something in the geometry
121 * of your KNumInput child. 126 * of your KNumInput child.
122 * 127 *
123 */ 128 */
124 void layout(bool deep); 129 void layout(bool deep);
125 130
126 /** 131 /**
127 * You need to overwrite this method and implement your layout 132 * You need to overwrite this method and implement your layout
128 * calculations there. 133 * calculations there.
129 * 134 *
130 * See KIntNumInput::doLayout and KDoubleNumInput::doLayout implementation 135 * See KIntNumInput::doLayout and KDoubleNumInput::doLayout implementation
131 * for details. 136 * for details.
132 * 137 *
@@ -257,97 +262,97 @@ public:
257 * @see #setSuffix() 262 * @see #setSuffix()
258 */ 263 */
259 QString suffix() const; 264 QString suffix() const;
260 /** 265 /**
261 * @return the prefix displayed in front of the value. 266 * @return the prefix displayed in front of the value.
262 * @see #setPrefix() 267 * @see #setPrefix()
263 */ 268 */
264 QString prefix() const; 269 QString prefix() const;
265 /** 270 /**
266 * @return the string displayed for a special value. 271 * @return the string displayed for a special value.
267 * @see #setSpecialValueText() 272 * @see #setSpecialValueText()
268 */ 273 */
269 QString specialValueText() const; 274 QString specialValueText() const;
270 275
271 /** 276 /**
272 * @param min minimum value 277 * @param min minimum value
273 * @param max maximum value 278 * @param max maximum value
274 * @param step step size for the QSlider 279 * @param step step size for the QSlider
275 */ 280 */
276 void setRange(int min, int max, int step=1, bool slider=true); 281 void setRange(int min, int max, int step=1, bool slider=true);
277 /** 282 /**
278 * Sets the minimum value. 283 * Sets the minimum value.
279 */ 284 */
280 void setMinValue(int min); 285 void setMinValue(int min);
281 /** 286 /**
282 * @return the minimum value. 287 * @return the minimum value.
283 */ 288 */
284 int minValue() const; 289 int minValue() const;
285 /** 290 /**
286 * Sets the maximum value. 291 * Sets the maximum value.
287 */ 292 */
288 void setMaxValue(int max); 293 void setMaxValue(int max);
289 /** 294 /**
290 * @return the maximum value. 295 * @return the maximum value.
291 */ 296 */
292 int maxValue() const; 297 int maxValue() const;
293 298
294 /** 299 /**
295 * Sets the special value text. If set, the SpinBox will display 300 * Sets the special value text. If set, the SpinBox will display
296 * this text instead of the numeric value whenever the current 301 * this text instead of the numeric value whenever the current
297 * value is equal to minVal(). Typically this is used for indicating 302 * value is equal to minVal(). Typically this is used for indicating
298 * that the choice has a special (default) meaning. 303 * that the choice has a special (default) meaning.
299 */ 304 */
300 void setSpecialValueText(const QString& text); 305 void setSpecialValueText(const QString& text);
301 306
302 /** 307 /**
303 * @reimplemented 308 * @reimplemented
304 */ 309 */
305 virtual void setLabel(const QString & label, int a = AlignLeft | AlignTop); 310 virtual void setLabel(const QString & label, int a = Qt::AlignLeft | Qt::AlignTop);
306 311
307 /** 312 /**
308 * This method returns the minimum size necessary to display the 313 * This method returns the minimum size necessary to display the
309 * control. The minimum size is enough to show all the labels 314 * control. The minimum size is enough to show all the labels
310 * in the current font (font change may invalidate the return value). 315 * in the current font (font change may invalidate the return value).
311 * 316 *
312 * @return the minimum size necessary to show the control 317 * @return the minimum size necessary to show the control
313 */ 318 */
314 virtual QSize minimumSizeHint() const; 319 virtual QSize minimumSizeHint() const;
315 320
316public slots: 321public slots:
317 /** 322 /**
318 * Sets the value of the control. 323 * Sets the value of the control.
319 */ 324 */
320 void setValue(int); 325 void setValue(int);
321 326
322 /** 327 /**
323 * Sets the value in units of the @ref referencePoint 328 * Sets the value in units of the @ref referencePoint
324 * @since 3.1 329 * @since 3.1
325 */ 330 */
326 void setRelativeValue(double); 331 void setRelativeValue(double);
327 332
328 /** 333 /**
329 * Sets the reference point for @ref relativeValue. 334 * Sets the reference point for @ref relativeValue.
330 * @since 3.1 335 * @since 3.1
331 */ 336 */
332 void setReferencePoint(int); 337 void setReferencePoint(int);
333 338
334 /** 339 /**
335 * Sets the suffix to @p suffix. 340 * Sets the suffix to @p suffix.
336 * Use QString::null to disable this feature. 341 * Use QString::null to disable this feature.
337 * Formatting has to be provided (e.g. a space separator between the 342 * Formatting has to be provided (e.g. a space separator between the
338 * prepended @p value and the suffix's text has to be provided 343 * prepended @p value and the suffix's text has to be provided
339 * as the first character in the suffix). 344 * as the first character in the suffix).
340 * 345 *
341 * @see QSpinBox::setSuffix(), #setPrefix() 346 * @see QSpinBox::setSuffix(), #setPrefix()
342 */ 347 */
343 void setSuffix(const QString &suffix); 348 void setSuffix(const QString &suffix);
344 349
345 /** 350 /**
346 * Sets the prefix to @p prefix. 351 * Sets the prefix to @p prefix.
347 * Use QString::null to disable this feature. 352 * Use QString::null to disable this feature.
348 * Formatting has to be provided (see above). 353 * Formatting has to be provided (see above).
349 * 354 *
350 * @see QSpinBox::setPrefix(), #setSuffix() 355 * @see QSpinBox::setPrefix(), #setSuffix()
351 */ 356 */
352 void setPrefix(const QString &prefix); 357 void setPrefix(const QString &prefix);
353 358
@@ -543,97 +548,97 @@ public:
543 * @param step step size for the QSlider 548 * @param step step size for the QSlider
544 */ 549 */
545 void setRange(double min, double max, double step=1, bool slider=true); 550 void setRange(double min, double max, double step=1, bool slider=true);
546 /** 551 /**
547 * Sets the minimum value. 552 * Sets the minimum value.
548 */ 553 */
549 void setMinValue(double min); 554 void setMinValue(double min);
550 /** 555 /**
551 * @return the minimum value. 556 * @return the minimum value.
552 */ 557 */
553 double minValue() const; 558 double minValue() const;
554 /** 559 /**
555 * Sets the maximum value. 560 * Sets the maximum value.
556 */ 561 */
557 void setMaxValue(double max); 562 void setMaxValue(double max);
558 /** 563 /**
559 * @return the maximum value. 564 * @return the maximum value.
560 */ 565 */
561 double maxValue() const; 566 double maxValue() const;
562 567
563 /** 568 /**
564 * Specifies the number of digits to use. 569 * Specifies the number of digits to use.
565 */ 570 */
566 void setPrecision(int precision); 571 void setPrecision(int precision);
567 572
568 /** 573 /**
569 * @return the reference point for @ref #relativeValue calculation 574 * @return the reference point for @ref #relativeValue calculation
570 * @since 3.1 575 * @since 3.1
571 */ 576 */
572 double referencePoint() const; 577 double referencePoint() const;
573 578
574 /** 579 /**
575 * @return the current value in units of @ref #referencePoint. 580 * @return the current value in units of @ref #referencePoint.
576 * @since 3.1 581 * @since 3.1
577 */ 582 */
578 double relativeValue() const; 583 double relativeValue() const;
579 584
580 /** 585 /**
581 * Sets the special value text. If set, the spin box will display 586 * Sets the special value text. If set, the spin box will display
582 * this text instead of the numeric value whenever the current 587 * this text instead of the numeric value whenever the current
583 * value is equal to @ref #minVal(). Typically this is used for indicating 588 * value is equal to @ref #minVal(). Typically this is used for indicating
584 * that the choice has a special (default) meaning. 589 * that the choice has a special (default) meaning.
585 */ 590 */
586 void setSpecialValueText(const QString& text); 591 void setSpecialValueText(const QString& text);
587 592
588 /** 593 /**
589 * @reimplemented 594 * @reimplemented
590 */ 595 */
591 virtual void setLabel(const QString & label, int a = AlignLeft | AlignTop); 596 virtual void setLabel(const QString & label, int a = Qt::AlignLeft | Qt::AlignTop);
592 /** 597 /**
593 * @reimplemented 598 * @reimplemented
594 */ 599 */
595 virtual QSize minimumSizeHint() const; 600 virtual QSize minimumSizeHint() const;
596 /** 601 /**
597 * @reimplemented 602 * @reimplemented
598 */ 603 */
599 virtual bool eventFilter(QObject*, QEvent*); 604 virtual bool eventFilter(QObject*, QEvent*);
600 605
601public slots: 606public slots:
602 /** 607 /**
603 * Sets the value of the control. 608 * Sets the value of the control.
604 */ 609 */
605 void setValue(double); 610 void setValue(double);
606 611
607 /** 612 /**
608 * Sets the value in units of @ref #referencePoint. 613 * Sets the value in units of @ref #referencePoint.
609 * @since 3.1 614 * @since 3.1
610 */ 615 */
611 void setRelativeValue(double); 616 void setRelativeValue(double);
612 617
613 /** 618 /**
614 * Sets the reference Point to @p ref. It @p ref == 0, emitting of 619 * Sets the reference Point to @p ref. It @p ref == 0, emitting of
615 * @ref #relativeValueChanged is blocked and @ref #relativeValue 620 * @ref #relativeValueChanged is blocked and @ref #relativeValue
616 * just returns 0. 621 * just returns 0.
617 * @since 3.1 622 * @since 3.1
618 */ 623 */
619 void setReferencePoint(double ref); 624 void setReferencePoint(double ref);
620 625
621 /** 626 /**
622 * Sets the suffix to be displayed to @p suffix. Use QString::null to disable 627 * Sets the suffix to be displayed to @p suffix. Use QString::null to disable
623 * this feature. Note that the suffix is attached to the value without any 628 * this feature. Note that the suffix is attached to the value without any
624 * spacing. So if you prefer to display a space separator, set suffix 629 * spacing. So if you prefer to display a space separator, set suffix
625 * to something like " cm". 630 * to something like " cm".
626 * @see #setSuffix() 631 * @see #setSuffix()
627 */ 632 */
628 void setSuffix(const QString &suffix); 633 void setSuffix(const QString &suffix);
629 634
630 /** 635 /**
631 * Sets the prefix to be displayed to @p prefix. Use QString::null to disable 636 * Sets the prefix to be displayed to @p prefix. Use QString::null to disable
632 * this feature. Note that the prefix is attached to the value without any 637 * this feature. Note that the prefix is attached to the value without any
633 * spacing. 638 * spacing.
634 * @see #setPrefix() 639 * @see #setPrefix()
635 */ 640 */
636 void setPrefix(const QString &prefix); 641 void setPrefix(const QString &prefix);
637 642
638signals: 643signals:
639 /** 644 /**
@@ -713,96 +718,100 @@ class KIntSpinBox : public QSpinBox
713 718
714public: 719public:
715 720
716 /** 721 /**
717 * Constructor. 722 * Constructor.
718 * 723 *
719 * Constructs a widget with an integer inputline with a little scrollbar 724 * Constructs a widget with an integer inputline with a little scrollbar
720 * and a slider, with minimal value 0, maximal value 99, step 1, base 10 725 * and a slider, with minimal value 0, maximal value 99, step 1, base 10
721 * and initial value 0. 726 * and initial value 0.
722 */ 727 */
723 KIntSpinBox( QWidget *parent=0, const char *name=0); 728 KIntSpinBox( QWidget *parent=0, const char *name=0);
724 729
725 /** 730 /**
726 * Constructor. 731 * Constructor.
727 * 732 *
728 * Constructs a widget with an integer inputline with a little scrollbar 733 * Constructs a widget with an integer inputline with a little scrollbar
729 * and a slider. 734 * and a slider.
730 * 735 *
731 * @param lower The lowest valid value. 736 * @param lower The lowest valid value.
732 * @param upper The greatest valid value. 737 * @param upper The greatest valid value.
733 * @param step The step size of the scrollbar. 738 * @param step The step size of the scrollbar.
734 * @param value The actual value. 739 * @param value The actual value.
735 * @param base The base of the used number system. 740 * @param base The base of the used number system.
736 * @param parent The parent of the widget. 741 * @param parent The parent of the widget.
737 * @param name The Name of the widget. 742 * @param name The Name of the widget.
738 */ 743 */
739 KIntSpinBox(int lower, int upper, int step, int value, int base = 10, 744 KIntSpinBox(int lower, int upper, int step, int value, int base = 10,
740 QWidget* parent = 0, const char* name = 0); 745 QWidget* parent = 0, const char* name = 0);
741 746
742 /** 747 /**
743 * Destructor. 748 * Destructor.
744 */ 749 */
745 virtual ~KIntSpinBox(); 750 virtual ~KIntSpinBox();
746 751
747 /** 752 /**
748 * Sets the base in which the numbers in the spin box are represented. 753 * Sets the base in which the numbers in the spin box are represented.
749 */ 754 */
750 void setBase(int base); 755 void setBase(int base);
751 /** 756 /**
752 * @return the base in which numbers in the spin box are represented. 757 * @return the base in which numbers in the spin box are represented.
753 */ 758 */
754 int base() const; 759 int base() const;
755 /** 760 /**
756 * sets focus and optionally marks all text 761 * sets focus and optionally marks all text
757 * 762 *
758 */ 763 */
759 void setEditFocus(bool mark); 764 void setEditFocus(bool mark);
760 765
766 void setValidator(const QValidator *v) {
767 lineEdit()->setValidator(v);
768 }
769
761protected: 770protected:
762 771
763 /** 772 /**
764 * Overloaded the method in QSpinBox 773 * Overloaded the method in QSpinBox
765 * to make use of the base given in the constructor. 774 * to make use of the base given in the constructor.
766 */ 775 */
767 virtual QString mapValueToText(int); 776 virtual QString mapValueToText(int);
768 777
769 /** 778 /**
770 * Overloaded the method in QSpinBox 779 * Overloaded the method in QSpinBox
771 * to make use of the base given in the constructor. 780 * to make use of the base given in the constructor.
772 */ 781 */
773 virtual int mapTextToValue(bool*); 782 virtual int mapTextToValue(bool*);
774 783
775private: 784private:
776 int val_base; 785 int val_base;
777protected: 786protected:
778 virtual void virtual_hook( int id, void* data ); 787 virtual void virtual_hook( int id, void* data );
779private: 788private:
780 class KIntSpinBoxPrivate; 789 class KIntSpinBoxPrivate;
781 KIntSpinBoxPrivate *d; 790 KIntSpinBoxPrivate *d;
782}; 791};
783 792
784 793
785/* --------------------------------------------------------------------------- */ 794/* --------------------------------------------------------------------------- */
786 795
787/** 796/**
788 This class provides a spin box for fractional numbers. 797 This class provides a spin box for fractional numbers.
789 798
790 @sect Parameters 799 @sect Parameters
791 800
792 There are a number of interdependent parameters whose relation to 801 There are a number of interdependent parameters whose relation to
793 each other you need to understand in order to make successful use 802 each other you need to understand in order to make successful use
794 of the spin box. 803 of the spin box.
795 804
796 @li precision: The number of decimals after the decimal point. 805 @li precision: The number of decimals after the decimal point.
797 @li maxValue/minValue: upper and lower bound of the valid range 806 @li maxValue/minValue: upper and lower bound of the valid range
798 @li lineStep: the size of the step that is taken when the user hits 807 @li lineStep: the size of the step that is taken when the user hits
799 the up or down buttons 808 the up or down buttons
800 809
801 Since we work with fixed-point numbers internally, the maximum 810 Since we work with fixed-point numbers internally, the maximum
802 precision is a function of the valid range and vice versa. More 811 precision is a function of the valid range and vice versa. More
803 precisely, the following relations hold: 812 precisely, the following relations hold:
804 <pre> 813 <pre>
805 max( abs(minValue()), abs(maxValue() ) <= INT_MAX/10^precision 814 max( abs(minValue()), abs(maxValue() ) <= INT_MAX/10^precision
806 maxPrecision = floor( log10( INT_MAX/max(abs(minValue()),abs(maxValue())) ) ) 815 maxPrecision = floor( log10( INT_MAX/max(abs(minValue()),abs(maxValue())) ) )
807 </pre> 816 </pre>
808 817