libyui-qt  2.49.2
YQIntField.h
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YQIntField.h
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 
26 #ifndef YQIntField_h
27 #define YQIntField_h
28 
29 #include <qlabel.h>
30 #include <QFrame>
31 
32 #include <yui/YIntField.h>
33 
34 
35 class YQWidgetCaption;
36 class QSpinBox;
37 
38 
39 class YQIntField : public QFrame, public YIntField
40 {
41  Q_OBJECT
42 
43 public:
44 
45  /**
46  * Constructor.
47  **/
48  YQIntField( YWidget * parent,
49  const std::string & label,
50  int minValue,
51  int maxValue,
52  int initialValue );
53 
54  /**
55  * Destructor.
56  **/
57  virtual ~YQIntField();
58 
59  /**
60  * Get the current value (the number entered by the user or set from the
61  * outside) of this IntField.
62  *
63  * Implemented from YIntField.
64  **/
65  virtual int value();
66 
67 protected:
68 
69  /**
70  * Set the current value (the number entered by the user or set from the
71  * outside) of this IntField. 'val' is guaranteed to be between minValue
72  * and maxValue; no further checks are required.
73  *
74  * Implemented from YIntField.
75  **/
76  virtual void setValueInternal( int val );
77 
78 public:
79 
80  /**
81  * Set the label (the caption above the input field).
82  *
83  * Reimplemented from YIntField.
84  **/
85  virtual void setLabel( const std::string & label );
86 
87  /**
88  * Sets the widget's enabled state.
89  *
90  * Inherited from YWidget.
91  **/
92  virtual void setEnabled( bool enabled );
93 
94  /**
95  * Preferred width of the widget.
96  *
97  * Reimplemented from YWidget.
98  **/
99  virtual int preferredWidth();
100 
101  /**
102  * Preferred height of the widget.
103  *
104  * Reimplemented from YWidget.
105  **/
106  virtual int preferredHeight();
107 
108  /**
109  * Set the new size of the widget.
110  *
111  * Reimplemented from YWidget.
112  **/
113  virtual void setSize( int newWidth, int newHeight );
114 
115  /**
116  * Accept the keyboard focus.
117  *
118  * Reimplemented from YWidget.
119  **/
120  virtual bool setKeyboardFocus();
121 
122 
123 signals:
124 
125  /**
126  * Emitted when the value changes (regardless of the notify flag).
127  **/
128  void valueChanged( int newValue );
129 
130 
131 protected slots:
132 
133  /**
134  * Slot for "value changed". This will send a ValueChanged event if
135  * 'notify' is set.
136  **/
137  void valueChangedSlot( int newValue );
138 
139 
140 protected:
141 
142  YQWidgetCaption * _caption;
143  QSpinBox * _qt_spinBox;
144 };
145 
146 
147 #endif // YQIntField_h
virtual bool setKeyboardFocus()
Accept the keyboard focus.
Definition: YQIntField.cc:147
virtual void setValueInternal(int val)
Set the current value (the number entered by the user or set from the outside) of this IntField...
Definition: YQIntField.cc:92
virtual int value()
Get the current value (the number entered by the user or set from the outside) of this IntField...
Definition: YQIntField.cc:85
virtual void setEnabled(bool enabled)
Sets the widget&#39;s enabled state.
Definition: YQIntField.cc:117
void valueChanged(int newValue)
Emitted when the value changes (regardless of the notify flag).
void valueChangedSlot(int newValue)
Slot for "value changed".
Definition: YQIntField.cc:100
virtual ~YQIntField()
Destructor.
Definition: YQIntField.cc:78
Helper class for captions (labels) above a widget: Takes care of hiding itself when its text is empty...
virtual void setLabel(const std::string &label)
Set the label (the caption above the input field).
Definition: YQIntField.cc:109
virtual int preferredHeight()
Preferred height of the widget.
Definition: YQIntField.cc:133
YQIntField(YWidget *parent, const std::string &label, int minValue, int maxValue, int initialValue)
Constructor.
Definition: YQIntField.cc:39
virtual int preferredWidth()
Preferred width of the widget.
Definition: YQIntField.cc:126
virtual void setSize(int newWidth, int newHeight)
Set the new size of the widget.
Definition: YQIntField.cc:140