summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qdesktopwidget_s60.cpp
blob: 029892e87da3821f6b5dff9d3072f1a388ff24da (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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/****************************************************************************
**
** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
**
****************************************************************************/

#include "qdesktopwidget.h"
#include "qapplication_p.h"
#include "qwidget_p.h"
#include "qt_s60_p.h"
#include <w32std.h>

#include "hal.h"
#include "hal_data.h"

QT_BEGIN_NAMESPACE

class QDesktopWidgetPrivate : public QWidgetPrivate
{

public:
    QDesktopWidgetPrivate();
    ~QDesktopWidgetPrivate();

    static void init(QDesktopWidget *that);
    static void cleanup();

    static int screenCount;
    static int primaryScreen;
};

int QDesktopWidgetPrivate::screenCount = 1;
int QDesktopWidgetPrivate::primaryScreen = 0;

QDesktopWidgetPrivate::QDesktopWidgetPrivate()
{
}

QDesktopWidgetPrivate::~QDesktopWidgetPrivate()
{
}

void QDesktopWidgetPrivate::init(QDesktopWidget *that)
{
    TInt screenCount=0;
    TInt result=0;

    result = HAL::Get(0, HALData::EDisplayNumberOfScreens, screenCount);
    QDesktopWidgetPrivate::screenCount = screenCount;
    if( result != KErrNone)
        {
        // ### What to do if no screens found?
        }
}

void QDesktopWidgetPrivate::cleanup()
{
}


QDesktopWidget::QDesktopWidget()
    : QWidget(*new QDesktopWidgetPrivate, 0, Qt::Desktop)
{
    setObjectName(QLatin1String("desktop"));
    QDesktopWidgetPrivate::init(this);
}

QDesktopWidget::~QDesktopWidget()
{
    QDesktopWidgetPrivate::cleanup();
}

bool QDesktopWidget::isVirtualDesktop() const
{
    return true;
}

int QDesktopWidget::primaryScreen() const
{
    return QDesktopWidgetPrivate::primaryScreen;
}

int QDesktopWidget::numScreens() const
{
    Q_D(const QDesktopWidget);
    return QDesktopWidgetPrivate::screenCount;
}

QWidget *QDesktopWidget::screen(int /* screen */)
{
    return this;
}

const QRect QDesktopWidget::availableGeometry(int /* screen */) const
{
    TRect clientRect = static_cast<CEikAppUi*>(S60->appUi())->ClientRect();
    return qt_TRect2QRect(clientRect);
}

const QRect QDesktopWidget::screenGeometry(int /* screen */) const
{
    Q_D(const QDesktopWidget);
    return QRect(0, 0, S60->screenWidthInPixels, S60->screenHeightInPixels);
    }

int QDesktopWidget::screenNumber(const QWidget *widget) const
{
    return QDesktopWidgetPrivate::primaryScreen;
}

int QDesktopWidget::screenNumber(const QPoint &point) const
{
    return QDesktopWidgetPrivate::primaryScreen;
}

void QDesktopWidget::resizeEvent(QResizeEvent *)
{
}

QT_END_NAMESPACE