src/widgets.h

changeset 675
450827da2376
parent 674
3d8ab0f89102
parent 629
b75c6cce02e2
child 676
f7f965742fd5
equal deleted inserted replaced
674:3d8ab0f89102 675:450827da2376
1 /*
2 * LDForge: LDraw parts authoring CAD
3 * Copyright (C) 2013, 2014 Santeri Piippo
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #ifndef WIDGETS_H
20 #define WIDGETS_H
21
22 #include <QGroupBox>
23 #include <QSpinBox>
24 #include <map>
25 #include "main.h"
26 #include "types.h"
27
28 class QIcon;
29 class QCheckBox;
30 class QButtonGroup;
31 class QBoxLayout;
32 class QRadioButton;
33
34 // =============================================================================
35 // RadioGroup
36 //
37 // Convenience widget - is a groupbox of radio buttons.
38 // =============================================================================
39 class RadioGroup : public QGroupBox
40 {
41 Q_OBJECT
42
43 public:
44 typedef QList<QRadioButton*>::Iterator Iterator;
45
46 explicit RadioGroup()
47 {
48 init (Qt::Vertical);
49 }
50
51 explicit RadioGroup (QWidget* parent = null) : QGroupBox (parent)
52 {
53 init (Qt::Vertical);
54 }
55
56 explicit RadioGroup (const QString& title, QWidget* parent = null);
57 explicit RadioGroup (const QString& title, initlist<char const*> entries, int const defaultId,
58 const Qt::Orientation orient = Qt::Vertical, QWidget* parent = null);
59
60 void addButton (const char* entry);
61 void addButton (QRadioButton* button);
62 Iterator begin();
63 Iterator end();
64 void init (Qt::Orientation orient);
65 bool isChecked (int n) const;
66 void rowBreak();
67 void setCurrentRow (int row);
68 void setValue (int val);
69 int value() const;
70
71 QRadioButton* operator[] (int n) const;
72 RadioGroup& operator<< (QRadioButton* button);
73 RadioGroup& operator<< (const char* entry);
74
75 signals:
76 void buttonPressed (int btn);
77 void buttonReleased (int btn);
78 void valueChanged (int val);
79
80 private:
81 QList<QRadioButton*> m_objects;
82 QList<QBoxLayout*> m_layouts;
83 QBoxLayout* m_coreLayout;
84 QBoxLayout* m_currentLayout;
85 bool m_vert;
86 int m_curId, m_defId, m_oldId;
87 QButtonGroup* m_buttonGroup;
88
89 Q_DISABLE_COPY (RadioGroup)
90
91 private slots:
92 void slot_buttonPressed (int btn);
93 void slot_buttonReleased (int btn);
94 };
95
96 #endif // WIDGETS_H

mercurial