QtPdWidgets  2.3.1
PushButton.h
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * Copyright (C) 2009 Florian Pose <fp@igh-essen.com>
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_PUSHBUTTON_H
24 #define PD_PUSHBUTTON_H
25 
26 #include <QPushButton>
27 
28 #include "Export.h"
29 #include <QtPdCom1/ScalarSubscriber.h>
30 
31 namespace Pd {
32 
33 /****************************************************************************/
34 
40  public QPushButton, public QtPdCom::ScalarSubscriber
41 {
42  Q_OBJECT
44  Q_PROPERTY(ButtonMode buttonMode
45  READ getButtonMode WRITE setButtonMode RESET resetButtonMode)
46  Q_PROPERTY(EventCondition eventCondition
47  READ getEventCondition WRITE setEventCondition
48  RESET resetEventCondition)
49  Q_PROPERTY(EventAction eventAction
50  READ getEventAction WRITE setEventAction RESET resetEventAction)
51  Q_PROPERTY(int onValue
52  READ getOnValue WRITE setOnValue RESET resetOnValue)
53  Q_PROPERTY(int offValue
54  READ getOffValue WRITE setOffValue RESET resetOffValue)
55 
56  public:
57  PushButton(QWidget *parent = 0);
58  virtual ~PushButton();
59 
60  void clearData(); // pure-virtual from ScalarSubscriber
61 
64  enum ButtonMode {
65  PressRelease,
68  Event
70  };
71  ButtonMode getButtonMode() const;
72  void setButtonMode(ButtonMode);
73  void resetButtonMode();
74 
78  OnClicked,
81  OnPressed,
83  OnReleased
86  };
87  EventCondition getEventCondition() const;
88  void setEventCondition(EventCondition);
89  void resetEventCondition();
90 
93  enum EventAction {
94  IncrementValue,
96  SetOnValue,
98  ToggleValue,
101  };
102  EventAction getEventAction() const;
103  void setEventAction(EventAction);
104  void resetEventAction();
105 
106  int getOnValue() const;
107  void setOnValue(int);
108  void resetOnValue();
109 
110  int getOffValue() const;
111  void setOffValue(int);
112  void resetOffValue();
113 
114  private slots:
115  PD_PRIVATE void on_clicked();
116  PD_PRIVATE void on_pressed();
117  PD_PRIVATE void on_released();
118 
119  private:
120  struct PD_PRIVATE Impl;
121  std::unique_ptr<Impl> impl;
122 
123  PD_PRIVATE void changeEvent(QEvent *) override;
124  PD_PRIVATE void newValues(std::chrono::nanoseconds) override;
125 };
126 
127 /****************************************************************************/
128 
129 } // namespace
130 
131 #endif
ButtonMode
Push button behaviour.
Definition: PushButton.h:64
Definition: Bar.h:36
#define PD_PRIVATE
Definition: Export.h:28
EventAction
Event action, determines what happens, when an event is generated.
Definition: PushButton.h:93
std::unique_ptr< Impl > impl
Definition: PushButton.h:121
#define PD_PUBLIC
Definition: Export.h:33
Definition: PushButton.cpp:39
Push Button.
Definition: PushButton.h:39
EventCondition
Event condition, determines when an event is generated.
Definition: PushButton.h:77