pqHierarchicalGridLayout.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: pqHierarchicalGridLayout.h
5 
6  Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
7  All rights reserved.
8 
9  ParaView is a free software; you can redistribute it and/or modify it
10  under the terms of the ParaView license version 1.2.
11 
12  See License_v1.2.txt for the full ParaView license.
13  A copy of this license can be obtained by contacting
14  Kitware Inc.
15  28 Corporate Drive
16  Clifton Park, NY 12065
17  USA
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
23 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 ========================================================================*/
32 #ifndef pqHierarchicalGridLayout_h
33 #define pqHierarchicalGridLayout_h
34 
35 #include <QLayout>
36 #include <QScopedPointer> // for ivar
37 
38 #include "pqWidgetsModule.h" // for export macros
39 
67 {
68  Q_OBJECT
69  typedef QLayout Superclass;
70 
71 public:
72  pqHierarchicalGridLayout(QWidget* parent = 0);
73  ~pqHierarchicalGridLayout() override;
74 
76 
79  void addItem(QLayoutItem* item) override;
80  QLayoutItem* itemAt(int index) const override;
81  QLayoutItem* takeAt(int index) override;
82  int count() const override;
84 
86 
89  QSize minimumSize() const override;
90  void setGeometry(const QRect& rect) override;
91  QSize sizeHint() const override;
93 
95 
98  bool isLocationValid(int location) const;
100 
102 
105  void split(int location, Qt::Orientation direction, double splitFraction);
106  void splitAny(int location, double splitFraction);
107  void splitVertical(int location, double splitFraction)
108  {
109  this->split(location, Qt::Vertical, splitFraction);
110  }
111  void splitHorizontal(int location, double splitFraction)
112  {
113  this->split(location, Qt::Horizontal, splitFraction);
114  }
116 
121  void setSplitFraction(int location, double splitFraction);
123 
125 
130  void maximize(int location);
132 
133  class Item
134  {
135  public:
136  Item(Qt::Orientation direction, double fraction)
137  : Direction(direction)
138  , Fraction(fraction)
139  {
140  }
141  Item(QWidget* widget = nullptr)
142  : Widget(widget)
143  {
144  }
145 
146  private:
147  QWidget* Widget = nullptr;
148  Qt::Orientation Direction = Qt::Horizontal;
149  double Fraction = -1.0;
151  };
152 
164  QVector<QWidget*> rearrange(const QVector<Item>& layout);
165 
166 private:
167  Q_DISABLE_COPY(pqHierarchicalGridLayout);
168 
169  class pqInternals;
170  QScopedPointer<pqInternals> Internals;
171 };
172 
173 #endif
void splitVertical(int location, double splitFraction)
Adds a splitter item.
direction
location
Item(Qt::Orientation direction, double fraction)
QLayout specialization that supports a hierarchical layout.
void split(const std::string &s, const char &delim, std::vector< std::string > &elems)
#define PQWIDGETS_EXPORT
void splitHorizontal(int location, double splitFraction)
Adds a splitter item.
QVector< QWidget * > rearrange(const QVector< Item > &layout)
API to rearrange the widgets in this layout.
index