summaryrefslogtreecommitdiff
path: root/src/msimplewindowframe.h
blob: a44c086f02c4f6e7032e9dbeafcaf28cbf662eee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (directui@nokia.com)
**
** This file is part of mcompositor.
**
** If you have questions regarding the use of this file, please contact
** Nokia at directui@nokia.com.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/

#include <QWidget>

class SystemButton;

/*!
 * MSimpleWindow is responsible for drawing window frames for windows
 * which do not manage itself. It draws a simple toolbar which contains
 * a close button and a minimize button.
 *
 */
class MSimpleWindowFrame: public QWidget
{
    Q_OBJECT
public:

    /*!
     * Initializes the MSimpleWindowFrame
     *
     * \param managedWindow the window that will be drawn with a frame
     */
    MSimpleWindowFrame(Qt::HANDLE managedWindow);

    /*!
     * Frees the resources
     */
    virtual ~MSimpleWindowFrame();

    /*!
     * Returns the suggested size of the contents of the window that
     * is supposed to be managed by this frame.
     */
    const QSize &suggestedWindowSize() const;

    /*!
     * Returns the window id of the area where the managed window is
     * going to be re-parented
     */
    Qt::HANDLE windowArea();

    /*!
     * Returns the window id of the managed window contained by this frame
     */
    Qt::HANDLE managedWindow();

    /*!
    * Sets parent window of this frame if any
    *
    * \param frame the parent window this this frame
    */
    void setParentFrame(Qt::HANDLE frame);

    /*!
    * Sets the decoration of the frame to dialog mode by hiding the minimize button
    *
    * \param dialogDecor true if dialog mode false otherwise.
    */
    void setDialogDecoration(bool dialogDecor);

public slots:

    /*!
     * Slot to minimize the managed window
     */
    void minimizeWindow();

    /*!
     * Slot to send a close event to the managed window
     */
    void closeWindow();

private:
    QSize window_size;
    QWidget *window_area;
    SystemButton *homesb;

    QPixmap *homepixmap;
    QPixmap *closepixmap;

    Qt::HANDLE parent_frame;
    // the actual window that is being managed
    Qt::HANDLE managed_window;

    static QPixmap *homepix;
    static QPixmap *closepix;

#ifdef UNIT_TEST
    friend class Ut_MSimpleWindowFrame;
#endif
};