src/qt3support/widgets/q3dockwindow.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 Qt3Support 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 Q3DOCKWINDOW_H
       
    43 #define Q3DOCKWINDOW_H
       
    44 
       
    45 #include <Qt3Support/q3frame.h>
       
    46 
       
    47 QT_BEGIN_HEADER
       
    48 
       
    49 QT_BEGIN_NAMESPACE
       
    50 
       
    51 QT_MODULE(Qt3SupportLight)
       
    52 
       
    53 #ifndef QT_NO_MAINWINDOW
       
    54 
       
    55 class Q3DockWindowHandle;
       
    56 class Q3DockWindowTitleBar;
       
    57 class QPainter;
       
    58 class Q3DockWindowResizeHandle;
       
    59 class QBoxLayout;
       
    60 class QHBoxLayout;
       
    61 class QVBoxLayout;
       
    62 class Q3DockArea;
       
    63 class QWidgetResizeHandler;
       
    64 class Q3MainWindow;
       
    65 class Q3DockAreaLayout;
       
    66 class Q3DockWindowPrivate;
       
    67 class Q3ToolBar;
       
    68 class QWindowsXPStyle;
       
    69 class QRubberBand;
       
    70 
       
    71 class Q_COMPAT_EXPORT Q3DockWindow : public Q3Frame
       
    72 {
       
    73     Q_OBJECT
       
    74     Q_ENUMS(CloseMode Place)
       
    75     Q_PROPERTY(int closeMode READ closeMode  WRITE setCloseMode)
       
    76     Q_PROPERTY(bool resizeEnabled READ isResizeEnabled  WRITE setResizeEnabled)
       
    77     Q_PROPERTY(bool movingEnabled READ isMovingEnabled  WRITE setMovingEnabled)
       
    78     Q_PROPERTY(bool horizontallyStretchable READ isHorizontallyStretchable  WRITE setHorizontallyStretchable)
       
    79     Q_PROPERTY(bool verticallyStretchable READ isVerticallyStretchable  WRITE setVerticallyStretchable)
       
    80     Q_PROPERTY(bool stretchable READ isStretchable)
       
    81     Q_PROPERTY(bool newLine READ newLine  WRITE setNewLine)
       
    82     Q_PROPERTY(bool opaqueMoving READ opaqueMoving  WRITE setOpaqueMoving)
       
    83     Q_PROPERTY(int offset READ offset  WRITE setOffset)
       
    84     Q_PROPERTY(Place place READ place)
       
    85 
       
    86     friend class Q3DockWindowHandle;
       
    87     friend class Q3DockWindowTitleBar;
       
    88     friend class Q3DockArea;
       
    89     friend class Q3DockAreaLayout;
       
    90     friend class Q3MainWindow;
       
    91     friend class QCEMainWindow;
       
    92     friend class Q3ToolBar;
       
    93     friend class QWindowsXPStyle;
       
    94 
       
    95 public:
       
    96     enum Place { InDock, OutsideDock };
       
    97     enum CloseMode { Never = 0, Docked = 1, Undocked = 2, Always = Docked | Undocked };
       
    98 
       
    99     Q3DockWindow(Place p = InDock, QWidget* parent=0, const char* name=0, Qt::WindowFlags f = 0);
       
   100     Q3DockWindow(QWidget* parent, const char* name=0, Qt::WindowFlags f = 0);
       
   101     ~Q3DockWindow();
       
   102 
       
   103     virtual void setWidget(QWidget *w);
       
   104     QWidget *widget() const;
       
   105 
       
   106     Place place() const { return curPlace; }
       
   107 
       
   108     Q3DockArea *area() const;
       
   109 
       
   110     virtual void setCloseMode(int m);
       
   111     bool isCloseEnabled() const;
       
   112     int closeMode() const;
       
   113 
       
   114     virtual void setResizeEnabled(bool b);
       
   115     virtual void setMovingEnabled(bool b);
       
   116     bool isResizeEnabled() const;
       
   117     bool isMovingEnabled() const;
       
   118 
       
   119     virtual void setHorizontallyStretchable(bool b);
       
   120     virtual void setVerticallyStretchable(bool b);
       
   121     bool isHorizontallyStretchable() const;
       
   122     bool isVerticallyStretchable() const;
       
   123     void setHorizontalStretchable(bool b) { setHorizontallyStretchable(b); }
       
   124     void setVerticalStretchable(bool b) { setVerticallyStretchable(b); }
       
   125     bool isHorizontalStretchable() const { return isHorizontallyStretchable(); }
       
   126     bool isVerticalStretchable() const { return isVerticallyStretchable(); }
       
   127     bool isStretchable() const;
       
   128 
       
   129     virtual void setOffset(int o);
       
   130     int offset() const;
       
   131 
       
   132     virtual void setFixedExtentWidth(int w);
       
   133     virtual void setFixedExtentHeight(int h);
       
   134     QSize fixedExtent() const;
       
   135 
       
   136     virtual void setNewLine(bool b);
       
   137     bool newLine() const;
       
   138 
       
   139     Qt::Orientation orientation() const;
       
   140 
       
   141     QSize sizeHint() const;
       
   142     QSize minimumSize() const;
       
   143     QSize minimumSizeHint() const;
       
   144 
       
   145     QBoxLayout *boxLayout();
       
   146 
       
   147     virtual void setOpaqueMoving(bool b);
       
   148     bool opaqueMoving() const;
       
   149 
       
   150     bool eventFilter(QObject *o, QEvent *e);
       
   151 
       
   152     QString windowTitle() const;
       
   153 
       
   154 Q_SIGNALS:
       
   155     void orientationChanged(Qt::Orientation o);
       
   156     void placeChanged(Q3DockWindow::Place p);
       
   157     void visibilityChanged(bool);
       
   158 
       
   159 public Q_SLOTS:
       
   160     virtual void undock(QWidget *w);
       
   161     virtual void undock() { undock(0); }
       
   162     virtual void dock();
       
   163     virtual void setOrientation(Qt::Orientation o);
       
   164 
       
   165 protected:
       
   166     void resizeEvent(QResizeEvent *e);
       
   167     void showEvent(QShowEvent *e);
       
   168     void hideEvent(QHideEvent *e);
       
   169     void contextMenuEvent(QContextMenuEvent *e);
       
   170 
       
   171     void drawFrame(QPainter *);
       
   172     void drawContents(QPainter *);
       
   173 
       
   174     bool event(QEvent *e);
       
   175 
       
   176 private Q_SLOTS:
       
   177     void toggleVisible() { setVisible(!isVisible()); }
       
   178 
       
   179 private:
       
   180     Q3DockWindow(Place p, QWidget* parent, const char* name, Qt::WindowFlags f, bool toolbar);
       
   181 
       
   182     void handleMove(const QPoint &pos, const QPoint &gp, bool drawRect);
       
   183     void updateGui();
       
   184     void updateSplitterVisibility(bool visible);
       
   185 
       
   186     void startRectDraw(const QPoint &so, bool drawRect);
       
   187     void endRectDraw(bool drawRect);
       
   188     void updatePosition(const QPoint &globalPos );
       
   189     QWidget *areaAt(const QPoint &gp);
       
   190     void removeFromDock(bool fixNewLines = true);
       
   191     void swapRect(QRect &r, Qt::Orientation o, const QPoint &offset, Q3DockArea *area);
       
   192     void init();
       
   193 
       
   194 private:
       
   195     Q3DockWindowHandle *horHandle, *verHandle;
       
   196     Q3DockWindowTitleBar *titleBar;
       
   197     QWidget *wid;
       
   198     QRubberBand *rubberBand;
       
   199     Q3DockArea *dockArea, *tmpDockArea;
       
   200     QRect currRect;
       
   201     Place curPlace;
       
   202     Place state;
       
   203     bool resizeEnabled : 1;
       
   204     bool moveEnabled : 1;
       
   205     bool nl : 1;
       
   206     bool opaque : 1;
       
   207     bool isToolbar : 1;
       
   208     bool stretchable[3];
       
   209     Qt::Orientation startOrientation;
       
   210     int cMode;
       
   211     QPoint startOffset;
       
   212     int offs;
       
   213     QSize fExtent;
       
   214     Q3DockWindowResizeHandle *hHandleTop, *hHandleBottom, *vHandleLeft, *vHandleRight;
       
   215     QVBoxLayout *hbox;
       
   216     QHBoxLayout *vbox;
       
   217     QBoxLayout *childBox;
       
   218     void *dockWindowData;
       
   219     QPoint lastPos;
       
   220     QSize lastSize;
       
   221     QWidgetResizeHandler *widgetResizeHandler;
       
   222     Q3DockWindowPrivate *d;
       
   223 
       
   224 private:
       
   225     Q_DISABLE_COPY(Q3DockWindow)
       
   226 };
       
   227 
       
   228 inline Q3DockArea *Q3DockWindow::area() const
       
   229 {
       
   230     return dockArea;
       
   231 }
       
   232 
       
   233 #endif // QT_NO_MAINWINDOW
       
   234 
       
   235 QT_END_NAMESPACE
       
   236 
       
   237 QT_END_HEADER
       
   238 
       
   239 #endif // Q3DOCKWINDOW_H