Geometrize  1.0
An application for geometrizing images into geometric primitives
flowlayout.h
Go to the documentation of this file.
1 // Copyright (c) 2016, The Qt Company Ltd.
2 // Contact: https://www.qt.io/licensing/
3 //
4 // Modifications Copyright (c) 2016, Sam Twidale.
5 // Contact: https://samcodes.co.uk/contact/
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions are
9 // met:
10 //
11 // * Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13 // * Redistributions in binary form must reproduce the above copyright
14 // notice, this list of conditions and the following disclaimer in
15 // the documentation and/or other materials provided with the
16 // distribution.
17 // * Neither the name of The Qt Company Ltd nor the names of its
18 // contributors may be used to endorse or promote products derived
19 // from this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
32 
33 #pragma once
34 
35 #include <QLayout>
36 #include <QList>
37 #include <QSize>
38 #include <QStyle>
39 
40 class QLayoutItem;
41 
42 namespace geometrize
43 {
44 
45 namespace layout
46 {
47 
52 class FlowLayout : public QLayout
53 {
54 public:
55  explicit FlowLayout(const int margin = -1, const int hSpacing = -1, const int vSpacing = -1);
56  virtual ~FlowLayout();
57 
58  int horizontalSpacing() const;
59  int verticalSpacing() const;
60 
61  void addItem(QLayoutItem* item) override;
62  Qt::Orientations expandingDirections() const override;
63  bool hasHeightForWidth() const override;
64  int heightForWidth(int width) const override;
65  int count() const override;
66  QLayoutItem* itemAt(int index) const override;
67  QSize minimumSize() const override;
68  void setGeometry(const QRect& rect) override;
69  QSize sizeHint() const override;
70  QLayoutItem* takeAt(int index) override;
71 
72 private:
73  int doLayout(const QRect& rect, bool testOnly) const;
74  int smartSpacing(QStyle::PixelMetric pm) const;
75 
76  QList<QLayoutItem*> m_itemList;
77  int m_hSpace;
78  int m_vSpace;
79 };
80 
81 }
82 
83 }
geometrize::layout::FlowLayout::smartSpacing
int smartSpacing(QStyle::PixelMetric pm) const
Definition: flowlayout.cpp:184
geometrize::layout::FlowLayout::itemAt
QLayoutItem * itemAt(int index) const override
Definition: flowlayout.cpp:99
geometrize::layout::FlowLayout::m_itemList
QList< QLayoutItem * > m_itemList
Definition: flowlayout.h:76
geometrize::layout::FlowLayout::setGeometry
void setGeometry(const QRect &rect) override
Definition: flowlayout.cpp:122
geometrize::layout::FlowLayout
The FlowLayout class implements a layout that arranges components in a directional flow,...
Definition: flowlayout.h:53
geometrize::layout::FlowLayout::FlowLayout
FlowLayout(const int margin=-1, const int hSpacing=-1, const int vSpacing=-1)
Definition: flowlayout.cpp:43
geometrize::layout::FlowLayout::verticalSpacing
int verticalSpacing() const
Definition: flowlayout.cpp:65
flowlayout.h
geometrize::layout::FlowLayout::minimumSize
QSize minimumSize() const override
Definition: flowlayout.cpp:104
geometrize::layout::FlowLayout::sizeHint
QSize sizeHint() const override
Definition: flowlayout.cpp:128
geometrize
Definition: commandlineparser.cpp:73
geometrize::layout::FlowLayout::m_vSpace
int m_vSpace
Definition: flowlayout.h:78
geometrize::layout::FlowLayout::hasHeightForWidth
bool hasHeightForWidth() const override
Definition: flowlayout.cpp:84
geometrize::layout::FlowLayout::expandingDirections
Qt::Orientations expandingDirections() const override
Definition: flowlayout.cpp:79
geometrize::layout::FlowLayout::count
int count() const override
Definition: flowlayout.cpp:94
geometrize::layout::FlowLayout::~FlowLayout
virtual ~FlowLayout()
Definition: flowlayout.cpp:48
geometrize::layout::FlowLayout::addItem
void addItem(QLayoutItem *item) override
Definition: flowlayout.cpp:74
geometrize::layout::FlowLayout::horizontalSpacing
int horizontalSpacing() const
Definition: flowlayout.cpp:56
geometrize::layout::FlowLayout::takeAt
QLayoutItem * takeAt(int index) override
Definition: flowlayout.cpp:133
geometrize::layout::FlowLayout::heightForWidth
int heightForWidth(int width) const override
Definition: flowlayout.cpp:89
geometrize::layout::FlowLayout::doLayout
int doLayout(const QRect &rect, bool testOnly) const
Definition: flowlayout.cpp:142
geometrize::layout::FlowLayout::m_hSpace
int m_hSpace
Definition: flowlayout.h:77