casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QtLayeredLayout.h
Go to the documentation of this file.
1 //# QtLayeredLayout.h: Subclass of QLayout to have layered widgets.
2 //# Copyright (C) 2009
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id: $
27 #ifndef QTLAYEREDLAYOUT_H_
28 #define QTLAYEREDLAYOUT_H_
29 
30 #include <casa/BasicSL/String.h>
31 
32 #include <QEvent>
33 #include <QLayout>
34 
35 namespace casa {
36 
37 // Subclass of QLayout to have multiple widgets layered on top of each other.
38 // Since the top widget will be the only one who receives certain types of Qt
39 // events, the layout can also propagate events to lower children if desired.
40 // NOTE: EVENT PROPAGATION IS NOT CURRENTLY WORKING.
41 class QtLayeredLayout : public QLayout {
42 public:
43  // Static //
44 
45  // Returns true if the given event type is propagate-able, false otherwise.
46  static bool propagateEventType(QEvent::Type type);
47 
48 
49  // Non-Static //
50 
51  // Constructor which takes no parent.
53 
54  // Constructor which takes a parent (cannot be null).
55  QtLayeredLayout(QWidget* parent);
56 
57  // Destructor.
59 
60 
61  // QLayoutItem Methods //
62 
63  // Implements QLayoutItem::geometry(). Returns the last geometry set using
64  // setGeometry().
65  QRect geometry() const;
66 
67  // Implements QLayoutItem::isEmpty().
68  bool isEmpty() const;
69 
70  // Implements QLayoutItem::setGeometry(). Sets the geometry of all
71  // children to the given.
72  void setGeometry(const QRect& r);
73 
74  // Implements QLayoutItem::sizeHint(). Returns minimumSizeHint().
75  QSize sizeHint() const;
76 
77 
78  // QObject Methods //
79 
80  // Overrides QObject::eventFilter() to propagate events as needed.
81  virtual bool eventFilter(QObject* watched, QEvent* event);
82 
83 
84  // QLayout Methods //
85 
86  // Implements QLayout::addItem(). Does not add duplicates.
87  void addItem(QLayoutItem* item);
88 
89  // Implements QLayout::count().
90  int count() const;
91 
92  // Overrides QLayout::expandingDirections().
93  Qt::Orientations expandingDirections() const;
94 
95  // Overrides QLayout::indexOf().
96  int indexOf(QWidget* widget) const;
97 
98  // Implements QLayout::itemAt().
99  QLayoutItem* itemAt(int index) const;
100 
101  // Overrides QLayout::maximumSize(). Returns the smallest valid maximum
102  // size for its items.
103  QSize maximumSize() const;
104 
105  // Overrides QLayout::minimumSize(). Returns the largest valid minimum
106  // size for its items.
107  QSize minimumSize() const;
108 
109  // Implements QLayout::takeAt().
110  QLayoutItem* takeAt(int index);
111 
112 
113  // QtLayeredLayout Methods //
114 
115  // Inserts the given item at the given index. If index is outside the
116  // bounds of the item list, the item is inserted at the end. Null or
117  // duplicate items are not inserted.
118  // <group>
119  void insertItem(int index, QLayoutItem* item);
120  void insertWidget(int index, QWidget* widget);
121  // </group>
122 
123 private:
124  // Items.
125  QList<QLayoutItem*> itsItems_;
126 
127  // Last set geometry.
129 
130  // Flag to propagate events or not.
132 
133 
134  // Installs or removes this layout as an event filter on the given item.
135  void installOrRemoveSelf(QLayoutItem* item, bool install);
136 
137  // Redoes the sibling widget stack in the parent, if applicable.
138  void redoParentStack();
139 
140  // Returns the layered index of the given widget, using recursive
141  // parameters.
142  // <group>
143  int layeredIndexOf(QWidget* widget) const;
144  static int layeredIndexOf(QWidget* widget, QLayoutItem* item);
145  // </group>
146 };
147 
148 }
149 
150 #endif /* QTLAYEREDLAYOUT_H_ */
int layeredIndexOf(QWidget *widget) const
Returns the layered index of the given widget, using recursive parameters.
void installOrRemoveSelf(QLayoutItem *item, bool install)
Installs or removes this layout as an event filter on the given item.
bool itsPropagateEvents_
Flag to propagate events or not.
void redoParentStack()
Redoes the sibling widget stack in the parent, if applicable.
virtual bool eventFilter(QObject *watched, QEvent *event)
QObject Methods //.
QRect geometry() const
QLayoutItem Methods //.
int count() const
Implements QLayout::count().
QSize maximumSize() const
Overrides QLayout::maximumSize().
virtual Type type()
Return the type enum.
bool isEmpty() const
Implements QLayoutItem::isEmpty().
static bool propagateEventType(QEvent::Type type)
Static //.
QLayoutItem * itemAt(int index) const
Implements QLayout::itemAt().
void addItem(QLayoutItem *item)
QLayout Methods //.
void insertItem(int index, QLayoutItem *item)
QtLayeredLayout Methods //.
Subclass of QLayout to have multiple widgets layered on top of each other.
int indexOf(QWidget *widget) const
Overrides QLayout::indexOf().
Qt::Orientations expandingDirections() const
Overrides QLayout::expandingDirections().
QLayoutItem * takeAt(int index)
Implements QLayout::takeAt().
QRect itsGeometry_
Last set geometry.
QSize minimumSize() const
Overrides QLayout::minimumSize().
~QtLayeredLayout()
Destructor.
QtLayeredLayout()
Non-Static //.
QSize sizeHint() const
Implements QLayoutItem::sizeHint().
void insertWidget(int index, QWidget *widget)
void setGeometry(const QRect &r)
Implements QLayoutItem::setGeometry().
QList< QLayoutItem * > itsItems_
Items.