Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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  * $Revision$ *
45  * $Author$ *
46  * $Date$ *
47  * *
48 \*===========================================================================*/
49 
50 
51 
52 //=============================================================================
53 //
54 // CLASS QtFlapBox
55 //
56 //=============================================================================
57 
58 #ifndef ACG_QT_FLAPBOX_HH
59 #define ACG_QT_FLAPBOX_HH
60 
61 //== INCLUDES =================================================================
62 
63 #include <iostream>
64 
65 #include <QPushButton>
66 #include <QBoxLayout>
67 #include <QResizeEvent>
68 #include <QFrame>
69 #include <QScrollArea>
70 #include "../Config/ACGDefines.hh"
71 
72 //== NAMESPACES ===============================================================
73 
74 namespace ACG {
75 namespace QtWidgets {
76 
77 //== CLASS DEFINITION =========================================================
78 
79 class ACGDLLEXPORT QtFlapBox : public QScrollArea
80 {
81  Q_OBJECT
82 
83 public:
84 
85  QtFlapBox( QWidget * _parent = 0, Qt::WindowFlags _f = 0 );
86  ~QtFlapBox ();
87 
88  int addItem( QWidget * _widget, const QIcon & _icon, const QString & _text );
89  int addItem( QWidget * _widget, const QString & _text );
90 
91  int count () const;
92 
93  int indexOf( QWidget * _widget ) const;
94  int insertItem( int _index, QWidget * _widget,
95  const QIcon & _icon, const QString & _text );
96  int insertItem( int _index, QWidget * _widget, const QString & _text );
97 
98  bool isItemEnabled( int _index ) const;
99  QIcon itemIcon( int _index ) const;
100 
101  QString itemText( int _index ) const;
102  QString itemToolTip( int _index ) const;
103  void removeItem( int _index );
104  void setItemEnabled( int _index, bool _enabled );
105  void setItemIcon( int _index, const QIcon & _icon );
106  void setItemText( int _index, const QString & _text );
107  void setItemToolTip( int _index, const QString & _toolTip );
108  QWidget * widget( int _index ) const;
109 
110  // the following methods are specific for QtFlapBox
111 
112  bool isItemHidden( int _index ) const;
113  void setItemHidden( int _index, bool _hidden );
114 
115  virtual QSize sizeHint() const;
116 
117 
118  virtual void resizeEvent ( QResizeEvent * _event );
119 
120 signals:
121 
122  void sizeHintChanged();
123 
124 
125 // void toggled( int index, bool state );
126 
127 
128 // public slots:
129 
130 // void toggle( int index );
131 
132 
133 // private slots:
134 
135 // void flapToggled( bool );
136 
137  // virtual QSize sizeHint () const;
138 
139 private:
140 
141 
142  struct Flap
143  {
144  QPushButton * button;
145  QWidget * widget;
146 
147  void setText( const QString & _text )
148  {
149  button->setText( _text );
150  }
151 
152  void setIcon( const QIcon & _icon )
153  {
154  button->setIcon( _icon );
155  }
156 
157  void setToolTip( const QString & _tip )
158  {
159  button->setToolTip( _tip );
160  }
161 
162  QString text() const
163  {
164  return button->text();
165  }
166 
167  QIcon icon() const
168  {
169  return button->icon();
170  }
171 
172  QString toolTip() const
173  {
174  return button->toolTip();
175  }
176 
177  bool operator==( const Flap & _other ) const
178  {
179  return widget == _other.widget;
180  }
181  };
182 
183 
184 
185 private slots:
186 
187  void buttonClicked();
188  void widgetDestroyed(QObject*);
189 
190 private:
191 
192  typedef QList< Flap > FlapList;
193 
194  Flap * flap( QWidget * _widget ) const;
195  const Flap * flap( int _index ) const;
196  Flap * flap( int _index );
197 
198  void updateFlaps();
199  void relayout();
200 
201  FlapList flapList;
202  QVBoxLayout * boxlayout;
203  QWidget * container;
204 
205 };
206 
207 //=============================================================================
208 } // namespace QtWidgets
209 } // namespace ACG
210 //=============================================================================
211 #endif // ACG_QT_FLAPBOX_HH defined
212 //=============================================================================
Namespace providing different geometric functions concerning angles.
Definition: DBSCANT.cc:51