hydrogen 1.2.6
LCDSpinBox.h
Go to the documentation of this file.
1/*
2 * Hydrogen
3 * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4 * Copyright(c) 2008-2025 The hydrogen development team [hydrogen-devel@lists.sourceforge.net]
5 *
6 * http://www.hydrogen-music.org
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY, without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
23
24#ifndef LCDSPINBOX_H
25#define LCDSPINBOX_H
26
27#include <QtGui>
28#include <QDoubleSpinBox>
29
30#include <core/Object.h>
32
49class LCDSpinBox : public QDoubleSpinBox, public H2Core::Object<LCDSpinBox>
50{
52 Q_OBJECT
53
54public:
55
56 enum class Type {
59 };
60
72
73 LCDSpinBox( QWidget *pParent, QSize size = QSize(), Type type = Type::Int, double fMin = 0.0, double fMax = 1.0, bool bModifyOnChange = false, bool bMinusOneAsOff = false );
75
76 void setType( Type type );
77 void setKind( Kind kind );
78 void setSize( QSize size );
79 void setModifyOnChange( bool bModifyOnChange );
80
81 virtual QValidator::State validate( QString &text, int &pos ) const override;
82
83 bool getIsActive() const;
84 void setIsActive( bool bIsActive );
85
86 bool getIsHovered() const;
87
88public slots:
90 void setValue( double fValue );
91
92private slots:
93 void valueChanged( double fNewValue );
94
95signals:
97 void valueChanged( int );
98
99private:
100 double nextValueInPatternSizeDenominator( bool bUp, bool bAccelerated );
101 void updateStyleSheet();
102
103 QSize m_size;
106
109
113
117
118 virtual QString textFromValue( double fValue ) const override;
119 virtual double valueFromText( const QString& sText ) const override;
120 virtual void paintEvent( QPaintEvent *ev ) override;
121#ifdef H2CORE_HAVE_QT6
122 virtual void enterEvent( QEnterEvent *ev ) override;
123#else
124 virtual void enterEvent( QEvent *ev ) override;
125#endif
126 virtual void leaveEvent( QEvent *ev ) override;
127 virtual void wheelEvent( QWheelEvent *ev ) override;
128 virtual void keyPressEvent( QKeyEvent *ev ) override;
129 virtual void mousePressEvent(QMouseEvent *ev) override;
130 virtual void mouseReleaseEvent( QMouseEvent *ev ) override;
131 virtual void mouseMoveEvent(QMouseEvent *ev) override;
132
133 virtual bool event( QEvent* ev ) override;
134};
135
136inline void LCDSpinBox::setKind( Kind kind ) {
137 m_kind = kind;
138}
139inline void LCDSpinBox::setModifyOnChange( bool bModifyOnChange ) {
140 m_bModifyOnChange = bModifyOnChange;
141}
142inline bool LCDSpinBox::getIsActive() const {
143 return m_bIsActive;
144}
145inline bool LCDSpinBox::getIsHovered() const {
146 return m_bEntered;
147}
148#endif
#define H2_OBJECT(name)
Definition Object.h:227
Changes
Bitwise or-able options showing which part of the Preferences were altered using the PreferencesDialo...
void valueChanged(double fNewValue)
virtual void mouseMoveEvent(QMouseEvent *ev) override
double nextValueInPatternSizeDenominator(bool bUp, bool bAccelerated)
virtual void mousePressEvent(QMouseEvent *ev) override
virtual double valueFromText(const QString &sText) const override
QSize m_size
Definition LCDSpinBox.h:103
bool getIsHovered() const
Definition LCDSpinBox.h:145
void setModifyOnChange(bool bModifyOnChange)
Definition LCDSpinBox.h:139
void setValue(double fValue)
void setType(Type type)
void onPreferencesChanged(H2Core::Preferences::Changes changes)
LCDSpinBox(QWidget *pParent, QSize size=QSize(), Type type=Type::Int, double fMin=0.0, double fMax=1.0, bool bModifyOnChange=false, bool bMinusOneAsOff=false)
void valueChanged(int)
bool m_bModifyOnChange
Whether Hydrogen::setIsModified() is invoked with true as soon as the value of the widget does change...
Definition LCDSpinBox.h:116
virtual QValidator::State validate(QString &text, int &pos) const override
bool getIsActive() const
Definition LCDSpinBox.h:142
bool m_bMinusOneAsOff
In some widgets the QString "off" will be displayed instead of -1.
Definition LCDSpinBox.h:112
virtual void leaveEvent(QEvent *ev) override
virtual void wheelEvent(QWheelEvent *ev) override
virtual void keyPressEvent(QKeyEvent *ev) override
virtual void mouseReleaseEvent(QMouseEvent *ev) override
void updateStyleSheet()
void setSize(QSize size)
virtual bool event(QEvent *ev) override
@ Default
Behaves like QDoubleSpinBox.
Definition LCDSpinBox.h:63
@ PatternSizeNumerator
The minimum value - a fractional one - can only be reached by entering it using the keyboard.
Definition LCDSpinBox.h:68
@ PatternSizeDenominator
Only a limited number of values is allowed.
Definition LCDSpinBox.h:70
bool m_bIsActive
Definition LCDSpinBox.h:108
void setKind(Kind kind)
Definition LCDSpinBox.h:136
virtual QString textFromValue(double fValue) const override
virtual void paintEvent(QPaintEvent *ev) override
void setIsActive(bool bIsActive)
void slashKeyPressed()
virtual void enterEvent(QEvent *ev) override
bool m_bEntered
Definition LCDSpinBox.h:107