Choreonoid  1.8
Buttons.h
Go to the documentation of this file.
1 
5 #ifndef CNOID_BASE_BUTTONS_H
6 #define CNOID_BASE_BUTTONS_H
7 
8 #include <cnoid/Signal>
9 #include <QPushButton>
10 #include <QRadioButton>
11 #include <QButtonGroup>
12 #include <QToolButton>
13 #include <memory>
14 #include "exportdecl.h"
15 
16 namespace cnoid {
17 
18 class CNOID_EXPORT PushButton : public QPushButton
19 {
20  Q_OBJECT
21 
22 public:
23  PushButton(QWidget* parent = 0);
24  PushButton(const QString& text, QWidget* parent = 0);
25  PushButton(const QIcon& icon, const QString& text, QWidget* parent = 0);
26 
27  SignalProxy<void()> sigClicked() {
28  return sigClicked_;
29  }
30  SignalProxy<void(bool)> sigToggled() {
31  return sigToggled_;
32  }
33 
34 private Q_SLOTS:
35  void onClicked(bool checked);
36  void onToggled(bool checked);
37 
38 private:
39  Signal<void()> sigClicked_;
40  Signal<void(bool)> sigToggled_;
41 
42  void initialize();
43 };
44 
45 class CNOID_EXPORT ToggleButton : public PushButton
46 {
47 public:
48  ToggleButton(QWidget* parent = 0);
49  ToggleButton(const QString& text, QWidget* parent = 0);
50  ToggleButton(const QIcon& icon, const QString& text, QWidget* parent = 0);
51 };
52 
53 class CNOID_EXPORT RadioButton : public QRadioButton
54 {
55  Q_OBJECT
56 
57 public:
58  RadioButton(QWidget* parent = 0);
59  RadioButton(const QString & text, QWidget* parent = 0);
60 
61  SignalProxy<void(bool)> sigToggled() {
62  return sigToggled_;
63  }
64 
65 private Q_SLOTS:
66  void onToggled(bool checked);
67 
68 private:
69  Signal<void(bool)> sigToggled_;
70 
71  void initialize();
72 };
73 
74 class CNOID_EXPORT ToolButton : public QToolButton
75 {
76  Q_OBJECT
77 
78 public:
79  ToolButton(QWidget* parent = 0);
80  ToolButton(const QString& text, QWidget* parent = 0);
81 
82  SignalProxy<void()> sigClicked() {
83  return sigClicked_;
84  }
85  SignalProxy<void(bool)> sigToggled() {
86  return sigToggled_;
87  }
88 
89  SignalProxy<void()> sigPressed();
90  SignalProxy<void()> sigReleased();
91 
92 private Q_SLOTS:
93  void onClicked(bool checked);
94  void onToggled(bool checked);
95  void onPressed();
96  void onReleased();
97 
98 private:
99  Signal<void()> sigClicked_;
100  Signal<void(bool)> sigToggled_;
101  std::unique_ptr<Signal<void()>> sigPressed_;
102  std::unique_ptr<Signal<void()>> sigReleased_;
103 };
104 
105 
106 class CNOID_EXPORT ToggleToolButton : public ToolButton
107 {
108 public:
109  ToggleToolButton(QWidget* parent = 0);
110  //ToggleButton(const QString& text, QWidget* parent = 0);
111  //ToggleButton(const QIcon& icon, const QString& text, QWidget* parent = 0);
112 };
113 
114 }
115 
116 #endif
cnoid::PushButton
Definition: Buttons.h:18
cnoid::PushButton::sigClicked
SignalProxy< void()> sigClicked()
Definition: Buttons.h:27
cnoid::ToolButton::sigToggled
SignalProxy< void(bool)> sigToggled()
Definition: Buttons.h:85
cnoid::RadioButton
Definition: Buttons.h:53
cnoid::RadioButton::sigToggled
SignalProxy< void(bool)> sigToggled()
Definition: Buttons.h:61
cnoid::ToolButton::sigClicked
SignalProxy< void()> sigClicked()
Definition: Buttons.h:82
cnoid::ToggleButton
Definition: Buttons.h:45
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::ToggleToolButton
Definition: Buttons.h:106
cnoid::ToolButton
Definition: Buttons.h:74
cnoid::Signal
Definition: Signal.h:165
cnoid::SignalProxy
Definition: Signal.h:470
cnoid::PushButton::sigToggled
SignalProxy< void(bool)> sigToggled()
Definition: Buttons.h:30