Developer Documentation

QtFlapBox.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41
42
43
44
45
46 //=============================================================================
47 //
48 // CLASS QtFlapBox
49 //
50 //=============================================================================
51
52 #ifndef ACG_QT_FLAPBOX_HH
53 #define ACG_QT_FLAPBOX_HH
54
55 //== INCLUDES =================================================================
56
57 #include <iostream>
58
59 #include <QPushButton>
60 #include <QBoxLayout>
61 #include <QResizeEvent>
62 #include <QFrame>
63 #include <QScrollArea>
64 #include "../Config/ACGDefines.hh"
65
66 //== NAMESPACES ===============================================================
67
68 namespace ACG {
69 namespace QtWidgets {
70
71 //== CLASS DEFINITION =========================================================
72
73 class ACGDLLEXPORT QtFlapBox : public QScrollArea
74 {
75 Q_OBJECT
76
77 public:
78
79 QtFlapBox( QWidget * _parent = 0, Qt::WindowFlags _f = 0 );
80 ~QtFlapBox ();
81
82 int addItem( QWidget * _widget, const QIcon & _icon, const QString & _text );
83 int addItem( QWidget * _widget, const QString & _text );
84
85 int count () const;
86
87 int indexOf( QWidget * _widget ) const;
88 int insertItem( int _index, QWidget * _widget,
89 const QIcon & _icon, const QString & _text );
90 int insertItem( int _index, QWidget * _widget, const QString & _text );
91
92 bool isItemEnabled( int _index ) const;
93 QIcon itemIcon( int _index ) const;
94
95 QString itemText( int _index ) const;
96 QString itemToolTip( int _index ) const;
97 void removeItem( int _index );
98 void setItemEnabled( int _index, bool _enabled );
99 void setItemIcon( int _index, const QIcon & _icon );
100 void setItemText( int _index, const QString & _text );
101 void setItemToolTip( int _index, const QString & _toolTip );
102 QWidget * widget( int _index ) const;
103
104 // the following methods are specific for QtFlapBox
105
106 bool isItemHidden( int _index ) const;
107 void setItemHidden( int _index, bool _hidden );
108
109 virtual QSize sizeHint() const;
110
111
112 virtual void resizeEvent ( QResizeEvent * _event );
113
114 signals:
115
116 void sizeHintChanged();
117
118
119 // void toggled( int index, bool state );
120
121
122 // public slots:
123
124 // void toggle( int index );
125
126
127 // private slots:
128
129 // void flapToggled( bool );
130
131 // virtual QSize sizeHint () const;
132
133 private:
134
135
136 struct Flap
137 {
138 QPushButton * button;
139 QWidget * widget;
140
141 void setText( const QString & _text )
142 {
143 button->setText( _text );
144 }
145
146 void setIcon( const QIcon & _icon )
147 {
148 button->setIcon( _icon );
149 }
150
151 void setToolTip( const QString & _tip )
152 {
153 button->setToolTip( _tip );
154 }
155
156 QString text() const
157 {
158 return button->text();
159 }
160
161 QIcon icon() const
162 {
163 return button->icon();
164 }
165
166 QString toolTip() const
167 {
168 return button->toolTip();
169 }
170
171 bool operator==( const Flap & _other ) const
172 {
173 return widget == _other.widget;
174 }
175 };
176
177
178
179 private slots:
180
181 void buttonClicked();
182 void widgetDestroyed(QObject*);
183
184 private:
185
186 typedef QList< Flap > FlapList;
187
188 Flap * flap( QWidget * _widget ) const;
189 const Flap * flap( int _index ) const;
190 Flap * flap( int _index );
191
192 void updateFlaps();
193 void relayout();
194
195 FlapList flapList;
196 QVBoxLayout * boxlayout;
197 QWidget * container;
198
199 };
200
201 //=============================================================================
202 } // namespace QtWidgets
203 } // namespace ACG
204 //=============================================================================
205 #endif // ACG_QT_FLAPBOX_HH defined
206 //=============================================================================
ACG
Namespace providing different geometric functions concerning angles.
Definition: BaseObjectData.hh:68
ACG::QtWidgets::QtFlapBox::Flap
Definition: QtFlapBox.hh:136
ACG::QtWidgets::QtFlapBox
Definition: QtFlapBox.hh:73