1 /************************************************************************ 2 * 3 * Copyright 2012 Jakob Leben (jakob.leben@gmail.com) 4 * 5 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 6 * All rights reserved. 7 * Contact: Nokia Corporation (qt-info@nokia.com) 8 * 9 * This file is part of SuperCollider Qt GUI. 10 * 11 * This program is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation, either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program. If not, see <http://www.gnu.org/licenses/>. 23 * 24 ************************************************************************/ 25 26 #pragma once 27 28 #include <QLayout> 29 #include <QList> 30 31 namespace QtCollider { 32 33 class StackLayout : public QLayout { 34 Q_OBJECT 35 Q_ENUMS(StackingMode) 36 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex) 37 Q_PROPERTY(StackingMode stackingMode READ stackingMode WRITE setStackingMode) 38 Q_PROPERTY(int count READ count) 39 40 public: 41 enum StackingMode { StackOne, StackAll }; 42 43 StackLayout(); 44 ~StackLayout(); 45 46 int addWidget(QWidget* w); 47 int insertWidget(int index, QWidget* w); 48 49 QWidget* currentWidget() const; 50 void setCurrentWidget(QWidget* widget); 51 int currentIndex() const; 52 void setCurrentIndex(int index); 53 widget()54 inline QWidget* widget() { return QLayout::widget(); } 55 56 QWidget* widget(int) const; 57 int count() const; 58 59 StackingMode stackingMode() const; 60 void setStackingMode(StackingMode stackingMode); 61 62 // abstract virtual functions: 63 void addItem(QLayoutItem* item); 64 QLayoutItem* itemAt(int) const; 65 QLayoutItem* takeAt(int); 66 QSize sizeHint() const; 67 QSize minimumSize() const; 68 Qt::Orientations expandingDirections() const; 69 void setGeometry(const QRect& rect); 70 71 virtual void invalidate(); 72 73 private: 74 QList<QLayoutItem*> _list; 75 int _index; 76 StackingMode _mode; 77 bool _gotParent; 78 }; 79 80 } // namespace QtCollider 81