src/gui/graphicsview/qgraphicslayoutitem.h
changeset 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtGui module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef QGRAPHICSLAYOUTITEM_H
       
    43 #define QGRAPHICSLAYOUTITEM_H
       
    44 
       
    45 #include <QtCore/qscopedpointer.h>
       
    46 #include <QtGui/qsizepolicy.h>
       
    47 #include <QtGui/qevent.h>
       
    48 
       
    49 QT_BEGIN_HEADER
       
    50 
       
    51 QT_BEGIN_NAMESPACE
       
    52 
       
    53 QT_MODULE(Gui)
       
    54 
       
    55 #if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
       
    56 
       
    57 class QGraphicsLayoutItemPrivate;
       
    58 class QGraphicsItem;
       
    59 class Q_GUI_EXPORT QGraphicsLayoutItem
       
    60 {
       
    61 public:
       
    62     QGraphicsLayoutItem(QGraphicsLayoutItem *parent = 0, bool isLayout = false);
       
    63     virtual ~QGraphicsLayoutItem();
       
    64 
       
    65     void setSizePolicy(const QSizePolicy &policy);
       
    66     void setSizePolicy(QSizePolicy::Policy hPolicy, QSizePolicy::Policy vPolicy, QSizePolicy::ControlType controlType = QSizePolicy::DefaultType);
       
    67     QSizePolicy sizePolicy() const;
       
    68 
       
    69     void setMinimumSize(const QSizeF &size);
       
    70     inline void setMinimumSize(qreal w, qreal h);
       
    71     QSizeF minimumSize() const;
       
    72     void setMinimumWidth(qreal width);
       
    73     inline qreal minimumWidth() const;
       
    74     void setMinimumHeight(qreal height);
       
    75     inline qreal minimumHeight() const;
       
    76 
       
    77     void setPreferredSize(const QSizeF &size);
       
    78     inline void setPreferredSize(qreal w, qreal h);
       
    79     QSizeF preferredSize() const;
       
    80     void setPreferredWidth(qreal width);
       
    81     inline qreal preferredWidth() const;
       
    82     void setPreferredHeight(qreal height);
       
    83     inline qreal preferredHeight() const;
       
    84 
       
    85     void setMaximumSize(const QSizeF &size);
       
    86     inline void setMaximumSize(qreal w, qreal h);
       
    87     QSizeF maximumSize() const;
       
    88     void setMaximumWidth(qreal width);
       
    89     inline qreal maximumWidth() const;
       
    90     void setMaximumHeight(qreal height);
       
    91     inline qreal maximumHeight() const;
       
    92 
       
    93     virtual void setGeometry(const QRectF &rect);
       
    94     QRectF geometry() const;
       
    95     virtual void getContentsMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const;
       
    96     QRectF contentsRect() const;
       
    97 
       
    98     QSizeF effectiveSizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
       
    99 
       
   100     virtual void updateGeometry();  //### rename to sizeHintChanged()
       
   101 
       
   102     QGraphicsLayoutItem *parentLayoutItem() const;
       
   103     void setParentLayoutItem(QGraphicsLayoutItem *parent);
       
   104 
       
   105     bool isLayout() const;
       
   106     // ###Qt5: Make automatic reparenting work regardless of item/object/widget type.
       
   107     QGraphicsItem *graphicsItem() const;
       
   108     bool ownedByLayout() const;
       
   109 
       
   110 protected:
       
   111     void setGraphicsItem(QGraphicsItem *item);
       
   112     void setOwnedByLayout(bool ownedByLayout);
       
   113     QGraphicsLayoutItem(QGraphicsLayoutItemPrivate &dd);
       
   114 
       
   115     virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const = 0;
       
   116     QScopedPointer<QGraphicsLayoutItemPrivate> d_ptr;
       
   117 
       
   118 private:
       
   119     QSizeF *effectiveSizeHints(const QSizeF &constraint) const;
       
   120     Q_DECLARE_PRIVATE(QGraphicsLayoutItem)
       
   121     
       
   122     friend class QGraphicsLayout;
       
   123 };
       
   124 
       
   125 Q_DECLARE_INTERFACE(QGraphicsLayoutItem, "com.trolltech.Qt.QGraphicsLayoutItem")
       
   126 
       
   127 inline void QGraphicsLayoutItem::setMinimumSize(qreal aw, qreal ah)
       
   128 { setMinimumSize(QSizeF(aw, ah)); }
       
   129 inline void QGraphicsLayoutItem::setPreferredSize(qreal aw, qreal ah)
       
   130 { setPreferredSize(QSizeF(aw, ah)); }
       
   131 inline void QGraphicsLayoutItem::setMaximumSize(qreal aw, qreal ah)
       
   132 { setMaximumSize(QSizeF(aw, ah)); }
       
   133 
       
   134 inline qreal QGraphicsLayoutItem::minimumWidth() const
       
   135 { return effectiveSizeHint(Qt::MinimumSize).width(); }
       
   136 inline qreal QGraphicsLayoutItem::minimumHeight() const
       
   137 { return effectiveSizeHint(Qt::MinimumSize).height(); }
       
   138 
       
   139 inline qreal QGraphicsLayoutItem::preferredWidth() const
       
   140 { return effectiveSizeHint(Qt::PreferredSize).width(); }
       
   141 inline qreal QGraphicsLayoutItem::preferredHeight() const
       
   142 { return effectiveSizeHint(Qt::PreferredSize).height(); }
       
   143 
       
   144 inline qreal QGraphicsLayoutItem::maximumWidth() const
       
   145 { return effectiveSizeHint(Qt::MaximumSize).width(); }
       
   146 inline qreal QGraphicsLayoutItem::maximumHeight() const
       
   147 { return effectiveSizeHint(Qt::MaximumSize).height(); }
       
   148 
       
   149 #endif
       
   150 
       
   151 QT_END_NAMESPACE
       
   152 
       
   153 QT_END_HEADER
       
   154 
       
   155 #endif