2.12.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

mdidockarea.h 4.73 KB
Newer Older
1
2
3
4
5
6
7
// ================================================================================================
// 
// This file is part of the CAMPVis Software Framework.
// 
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
//      Christian Schulte zu Berge <christian.szb@in.tum.de>
//      Chair for Computer Aided Medical Procedures
8
9
//      Technische Universität München
//      Boltzmannstr. 3, 85748 Garching b. München, Germany
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
// 
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
// 
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// 
// ================================================================================================

30
31
#ifndef MDIDOCKAREA_H__
#define MDIDOCKAREA_H__
32

33
#include "mdidockedwindow.h"
34
#include "mdifloatingwindow.h"
35
36
37

#include <QMdiArea>

38
39
class QSignalMapper;

40
41
42
namespace campvis {

    /**
43
     * MDI area whose subwindows can be docked and undocked.
44
     *
45
46
47
     * MdiDockArea takes care of creating all necessary representations (docked and floating window)
     * of the widgets passed to \ref addSubWindow and seamlessly switching between them in response
     * to the user's actions (window dragging, key presses, etc).
48
     */
49
    class MdiDockArea : public QMdiArea {
50

51
        Q_OBJECT
52
53

    public:
54
55
56
57
58
59
60
        /**
         * Constructs an empty MDI area.
         *
         * \param parent the area's parent widget (passed to QMdiArea's constructor)
         */
        explicit MdiDockArea(QWidget* parent = 0);

61
        /**
62
         * Wrap \p widget in an MDI window and dock it in the MDI area.
63
         *
64
         * This method creates a MdiDockedWindow wrapping the widget, and adds it to the MDI area.
65
         *
66
67
68
         * \param widget the widget to add to the MDI area
         * \param windowFlags flags used to customize the frame of the created subwindow
         * \return the PipelineMdiSubWindow instance that was added to the MDI area
69
         */
70
        MdiDockedWindow* addSubWindow(QWidget* widget, Qt::WindowFlags windowFlags = 0);
71

72
73
        QMenu* menu();

74
75
    private slots:
        /**
76
         * Track the position of a floating MDI window and dock it if necessary.
77
         *
78
         * This slot is invoked when the position of a floating MDI window changes.
79
         */
80
        void trackFloatingWindowsPosition(MdiFloatingWindow* floatingWindow, const QPoint& newPos);
81
82

        /**
83
         * Track the position of a docked MDI window and detach it if necessary.
84
         *
85
         * This slot is invoked when the position of an MDI subwindow changes.
86
         */
87
        void trackMdiSubWindowsPosition(MdiDockedWindow* mdiSubWindow, const QPoint& newPos);
88

89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
        /**
         * Display docked windows as sub-windows with window frames.
         */
        void switchToTiledDisplay();

        /**
         * Display docked windows with tabs in a tab bar.
         */
        void switchToTabbedDisplay();

        /**
         * Depending on the state of \p actionObject, show or hide its associated sub-window.
         *
         * \param actionObject the visibility action whose corresponding sub-window should be shown or hidden
         */
        void toggleSubWindowVisibility(QObject* actionObject);

    private:
        /**
         * Add the given MdiDockedWindow to the MDI area.
         *
         * \param dockedWindow the docked window to add
         */
        void addDockedWindow(MdiDockedWindow* dockedWindow);

        QMenu* _menu;                   ///< Menu with actions for controlling the MDI area and its subwindows.
        QSignalMapper* _signalMapper;   ///< Helper used to pass extra information to toggleSubWindowVisibility.

117
118
119
    };
}

120
#endif // MDIDOCKAREA_H__