aboutsummaryrefslogtreecommitdiff
path: root/plainqt/style/qtmaemo6windowdecoration.h
blob: e19ed8a639a51b720da060a77463cf0275c710d0 (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
/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (directui@nokia.com)
**
** This file is part of libmeegotouch.
**
** 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.
**
****************************************************************************/

#ifndef QTMAEMO6WINDOWDECORATION_H
#define QTMAEMO6WINDOWDECORATION_H

#include <QGraphicsView>
#include <QWidget>
#include <QScrollArea>
#include <QPointer>

#include "qtmaemo6window.h"

class QLabel;
class QStatusBar;
class QtMaemo6TitleBar;
class QVBoxLayout;
class QMenuBar;

/*!
 * this class emulates the m windowdecoration
 * it adds a titlebar and places an statusbar on the bottom of the screen,
 * if available
 */
class QtMaemo6WindowDecoration : public QtMaemo6Window
{
    Q_OBJECT
public:
    explicit QtMaemo6WindowDecoration(QWidget *mw, QWidget *parent = NULL);
    ~QtMaemo6WindowDecoration();

    /*!
     * sets the given statusbar as the applications status bar
     * this one stays on the bottom of the screen
     * it takes the ownership of the menuBar
     */
    void setStatusBar(QStatusBar *statusBar);

    /*!
     * sets the menuBar for this windowDecoration
     * it takes the ownership of the menuBar
     */
    void setMenuBar(QMenuBar *menuBar);

    void showNavigationBar( bool visible );

    void showDeviceStatusBar( bool visible );

    void ensureWidgetVisible(QWidget* widget, QRect visibleArea);
protected Q_SLOTS:
    virtual void setOrientation(M::OrientationAngle);
    void showMenuBar();
protected:
    QtMaemo6WindowDecoration() {}

    /*! \reimp */
    virtual bool eventFilter(QObject *obj, QEvent *event);
    virtual void resizeEvent(QResizeEvent *);
    virtual void timerEvent(QTimerEvent *);
    /*! \reimp_end */

#ifdef Q_WS_X11
protected Q_SLOTS:
    void updateStatusBarSharedPixmap(M::OrientationAngle angle = M::Angle0);
protected:
    bool fetchStatusBarSharedPixmapHandle(Qt::HANDLE *handle);
#endif
private:
    QLabel* m_deviceStatusBar;
    static const int layoutOffset;

    QtMaemo6TitleBar *m_titleBar;
    QMenuBar *m_menuBar;
    QStatusBar *m_statusBar;
    QWidget *m_statusBarParent;

    int m_deviceStatusBarTimerId;

    struct WidgetPos {
        WidgetPos() : widget(NULL) {};
        WidgetPos(QWidget* w, QPoint p) : widget(w), position(p) {};
        WidgetPos(const WidgetPos& other) { widget = other.widget; position = other.position; }
        QWidget* widget;
        QPoint position;
    };
    WidgetPos m_originalWidgetPos;
};

#endif