1 /*
2  *    Copyright 2013 Kai Pastor
3  *
4  *    This file is part of OpenOrienteering.
5  *
6  *    OpenOrienteering is free software: you can redistribute it and/or modify
7  *    it under the terms of the GNU General Public License as published by
8  *    the Free Software Foundation, either version 3 of the License, or
9  *    (at your option) any later version.
10  *
11  *    OpenOrienteering is distributed in the hope that it will be useful,
12  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *    GNU General Public License for more details.
15  *
16  *    You should have received a copy of the GNU General Public License
17  *    along with OpenOrienteering.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 
21 #ifndef OPENORIENTEERING_SEGMENTED_BUTTON_LAYOUT_H
22 #define OPENORIENTEERING_SEGMENTED_BUTTON_LAYOUT_H
23 
24 #include <QtGlobal>
25 #include <QObject>
26 #include <QHBoxLayout>
27 
28 class QWidget;
29 
30 namespace OpenOrienteering {
31 
32 
33 /**
34  * SegmentedButtonLayout is a horizontal box layout with no margin and no
35  * spacing which will mark the contained widgets as being segments having a
36  * left and/or right neighbor.
37  *
38  * MapperProxyStyle uses this information to make buttons from a single
39  * SegmentedButtonLayout appear as a single segmented button.
40  */
41 class SegmentedButtonLayout : public QHBoxLayout
42 {
43 Q_OBJECT
44 public:
45 	/**
46 	 * Constructs a new SegmentedButtonLayout.
47 	 */
48 	SegmentedButtonLayout();
49 
50 	/**
51 	 * Constructs a new SegmentedButtonLayout for the given parent.
52 	 */
53 	explicit SegmentedButtonLayout(QWidget* parent);
54 
55 	/**
56 	 * Destroys the object.
57 	 */
58 	~SegmentedButtonLayout() override;
59 
60 	/**
61 	 * Resets the information about neighboring segments and any other cached
62 	 * information about the layout.
63 	 */
64 	void invalidate() override;
65 
66 	/**
67 	 * Types of segment neighborhood.
68 	 */
69 	enum Segment
70 	{
71 		NoNeighbors   = 0x00,
72 		RightNeighbor = 0x01,
73 		LeftNeighbor  = 0x02,
74 		BothNeighbors = RightNeighbor | LeftNeighbor
75 	};
76 
77 private:
78 	Q_DISABLE_COPY(SegmentedButtonLayout)
79 };
80 
81 
82 }  // namespace OpenOrienteering
83 
84 #endif // OPENORIENTEERING_SEGMENTED_BUTTON_LAYOUT_H
85