/*
Copyright (c) 2007 Matt Williams matt@milliams.com

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License or (at
your option) version 3 or, at the discretion of KDE e.V. (which shall
act as a proxy as in section 14 of the GPLv3), any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include <QGraphicsWidget>

/*TODO
Use setContentsMargins() to set the bounds for the child layouted widgets
*/

/**
 * \class Block
 * Like a QGroupBox but with an extendable box at the bottom for item attributes.
 */
class Block : public QGraphicsWidget
{
    public:
        Block();
        
        void setTitle(const QString& title) {mTitle = title;}
        QString title() const {return mTitle;}
        
        void addBlock(Block* newBlock) {} //TODO
        
        void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
        QRectF geometry() const;
        void getContentsMargins(qreal* left, qreal* top, qreal* right, qreal* bottom) const;
        void setGeometry(const QRectF& rect);
        void updateGeometry();
        
        void addItem(QGraphicsLayoutItem* item);
        void addStretch(int stretch = 1);
        
    protected:
        QSizeF sizeHint(Qt::SizeHint which, const QSizeF& constraint = QSizeF()) const;
        
        QString mTitle; ///The label to be displayed at the left
        
    private:
        qreal mTextHeight; //Text height plus padded box
        qreal mTextWidth; //Text width plus padded box
};
