libyui-qt  2.46.13
YQSlider.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: YQSlider.h
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 
26 #ifndef YQSlider_h
27 #define YQSlider_h
28 
29 #include <QFrame>
30 #include <yui/YSlider.h>
31 
32 class YQWidgetCaption;
33 class QSlider;
34 class QSpinBox;
35 
36 class YQSlider : public QFrame, public YSlider
37 {
38  Q_OBJECT
39 
40 public:
41 
42  /**
43  * Constructor.
44  *
45  * 'reverseLayout' creates the QSpinBox to the left and the QSlider to the right.
46  **/
47  YQSlider( YWidget * parent,
48  const std::string & label,
49  int minValue,
50  int maxValue,
51  int initialValue,
52  bool reverseLayout = false );
53 
54  /**
55  * Destructor.
56  **/
57  virtual ~YQSlider();
58 
59  /**
60  * Get the current value (the number entered by the user or set from the
61  * outside) of this slider.
62  *
63  * Implemented from YSlider / 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 slider. 'val' is guaranteed to be between minValue
72  * and maxValue; no further checks are required.
73  *
74  * Implemented from YSlider/ 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 YSlider / YIntField.
84  **/
85  virtual void setLabel( const std::string & label );
86 
87  /**
88  * Set enabled/disabled state.
89  *
90  * Reimplemented 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  virtual bool setKeyboardFocus();
119 
120 
121 public slots:
122  /**
123  * Slot for "value changed". This will send a ValueChanged event if
124  * 'notify' is set.
125  **/
126  void valueChangedSlot( int newValue );
127 
128 signals:
129 
130  /**
131  * Emitted when the value changes (regardless of the notify flag).
132  **/
133  void valueChanged( int newValue );
134 
135 
136 protected:
137 
138  YQWidgetCaption * _caption;
139  QSlider * _qt_slider;
140  QSpinBox * _qt_spinBox;
141  QFrame * _hbox;
142 };
143 
144 
145 #endif // YQSlider_h
virtual ~YQSlider()
Destructor.
Definition: YQSlider.cc:120
virtual void setSize(int newWidth, int newHeight)
Set the new size of the widget.
Definition: YQSlider.cc:181
void valueChangedSlot(int newValue)
Slot for "value changed".
Definition: YQSlider.cc:144
virtual int preferredWidth()
Preferred width of the widget.
Definition: YQSlider.cc:164
virtual int preferredHeight()
Preferred height of the widget.
Definition: YQSlider.cc:174
YQSlider(YWidget *parent, const std::string &label, int minValue, int maxValue, int initialValue, bool reverseLayout=false)
Constructor.
Definition: YQSlider.cc:41
virtual int value()
Get the current value (the number entered by the user or set from the outside) of this slider...
Definition: YQSlider.cc:127
void valueChanged(int newValue)
Emitted when the value changes (regardless of the notify flag).
virtual bool setKeyboardFocus()
Accept the keyboard focus.
Definition: YQSlider.cc:196
virtual void setLabel(const std::string &label)
Set the label (the caption above the input field).
Definition: YQSlider.cc:188
virtual void setValueInternal(int val)
Set the current value (the number entered by the user or set from the outside) of this slider...
Definition: YQSlider.cc:134
Helper class for captions (labels) above a widget: Takes care of hiding itself when its text is empty...
virtual void setEnabled(bool enabled)
Set enabled/disabled state.
Definition: YQSlider.cc:154