QtPdWidgets  2.3.1
Digital.h
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * Copyright (C) 2009 - 2019 Florian Pose <fp@igh.de>
4  *
5  * This file is part of the QtPdWidgets library.
6  *
7  * The QtPdWidgets library is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation, either version 3 of the License,
10  * or (at your option) any later version.
11  *
12  * The QtPdWidgets library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with the QtPdWidgets Library. If not, see
19  * <http://www.gnu.org/licenses/>.
20  *
21  ****************************************************************************/
22 
23 #ifndef PD_DIGITAL_H
24 #define PD_DIGITAL_H
25 
26 #include <QFrame>
27 
28 #include <QtPdCom1/ScalarSubscriber.h>
29 #include "Export.h"
30 
31 #include <memory>
32 
33 namespace Pd {
34 
35 /****************************************************************************/
36 
40  public QFrame, public QtPdCom::ScalarSubscriber
41 {
42  Q_OBJECT
43 
44  Q_ENUMS(TimeDisplay)
45 
46  Q_PROPERTY(Qt::Alignment alignment
47  READ getAlignment WRITE setAlignment RESET resetAlignment)
48  Q_PROPERTY(quint32 decimals
49  READ getDecimals WRITE setDecimals RESET resetDecimals)
50  Q_PROPERTY(QString suffix
51  READ getSuffix WRITE setSuffix RESET resetSuffix)
52  Q_PROPERTY(TimeDisplay timeDisplay
53  READ getTimeDisplay WRITE setTimeDisplay RESET resetTimeDisplay)
54  Q_PROPERTY(int base
55  READ getBase WRITE setBase RESET resetBase)
56 
57  public:
58  Digital(QWidget *parent = 0);
59  virtual ~Digital();
60 
61  void clearData(); // pure-virtual from ScalarSubscriber
62 
63  double getValue() const;
64 
65  Qt::Alignment getAlignment() const;
66  void setAlignment(Qt::Alignment);
67  void resetAlignment();
68 
69  quint32 getDecimals() const;
70  void setDecimals(quint32);
71  void resetDecimals();
72 
73  QString getSuffix() const;
74  void setSuffix(const QString &);
75  void resetSuffix();
76 
77  enum TimeDisplay {
81  Hours
82  };
83  TimeDisplay getTimeDisplay() const;
84  void setTimeDisplay(TimeDisplay);
85  void resetTimeDisplay();
86 
87  int getBase() const;
88  void setBase(int);
89  void resetBase();
90 
91  QString getValueString() const;
92 
93  QSize sizeHint() const override;
94 
95  protected:
96  bool event(QEvent *) override;
97  void paintEvent(QPaintEvent *) override;
98 
99  private:
100  struct PD_PRIVATE Impl;
101  std::unique_ptr<Impl> impl;
102 
103  PD_PRIVATE void newValues(std::chrono::nanoseconds) override;
104 
105  private slots:
106  PD_PRIVATE void redrawEvent();
107 };
108 
109 /****************************************************************************/
110 
111 } // namespace
112 
113 #endif
Definition: Bar.h:36
Definition: Digital.h:80
#define PD_PRIVATE
Definition: Export.h:28
Definition: Digital.cpp:45
TimeDisplay
Definition: Digital.h:77
#define PD_PUBLIC
Definition: Export.h:33
std::unique_ptr< Impl > impl
Definition: Digital.h:101
Definition: Digital.h:78
Base functionality for digital displays.
Definition: Digital.h:39
Definition: Digital.h:79