Qt 4.8
qbbwindow.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtCore module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QBBWINDOW_H
43 #define QBBWINDOW_H
44 
45 #include "qbbbuffer.h"
46 
47 #include <QImage>
48 #include <QtGui/QPlatformWindow>
49 
50 #include <screen/screen.h>
51 #include <EGL/egl.h>
52 
54 
56 class QBBGLContext;
57 class QBBScreen;
58 
59 class QBBWindow : public QPlatformWindow
60 {
61 friend class QBBScreen;
62 public:
63  QBBWindow(QWidget *window, screen_context_t context, QBBScreen *screen);
64  virtual ~QBBWindow();
65 
66  virtual void setGeometry(const QRect &rect);
67  virtual void setVisible(bool visible);
68  virtual void setOpacity(qreal level);
69 
70  virtual WId winId() const { return (WId)mWindow; }
71 
72  void setBufferSize(const QSize &size);
73  QSize bufferSize() const { return mBufferSize; }
74  bool hasBuffers() const { return !mBufferSize.isEmpty(); }
75 
78 
79  void scroll(const QRegion &region, int dx, int dy, bool flush=false);
80  void post(const QRegion &dirty);
81 
82  void setScreen(QBBScreen *platformScreen);
83 
84  virtual QPlatformGLContext *glContext() const;
85 
86  virtual void setParent(const QPlatformWindow *window);
87  virtual void raise();
88  virtual void lower();
89  virtual void requestActivateWindow();
90 
91  void gainedFocus();
92 
93  QBBScreen* screen() const { return mScreen; }
94  const QList<QBBWindow*>& children() const { return mChildren; }
95 
96  QBBWindow *findWindow(screen_window_t windowHandle);
97 
98 private:
99 
100  enum Buffer {
104  };
105 
106  QBBBuffer &buffer(QBBWindow::Buffer bufferIndex);
107 
108  screen_context_t mContext;
109  screen_window_t mWindow;
116 
121  bool mVisible;
122 
123  void removeFromParent();
124  void offset(const QPoint &offset);
125  void updateVisibility(bool parentVisible);
126  void updateZorder(int &topZorder);
127 
128  void fetchBuffers();
129 
130  void copyBack(const QRegion &region, int dx, int dy, bool flush=false);
131 
133 };
134 
136 
137 #endif // QBBWINDOW_H
bool hasBuffers() const
Definition: qbbwindow.h:74
unsigned long WId
Definition: qwindowdefs.h:119
double qreal
Definition: qglobal.h:1193
QSize mBufferSize
Definition: qbbwindow.h:110
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
void setScreen(QBBScreen *platformScreen)
Definition: qbbwindow.cpp:474
virtual void lower()
Reimplement to be able to let Qt lower windows to the bottom of the desktop.
Definition: qbbwindow.cpp:579
QBBWindow(QWidget *window, screen_context_t context, QBBScreen *screen)
Definition: qbbwindow.cpp:57
virtual void requestActivateWindow()
Reimplement to let Qt be able to request activation/focus for a window.
Definition: qbbwindow.cpp:595
virtual void setParent(const QPlatformWindow *window)
This function is called to enable native child widgets in QPA.
Definition: qbbwindow.cpp:532
void offset(const QPoint &offset)
Definition: qbbwindow.cpp:207
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QPlatformWindowFormat class specifies the display format of an OpenGL rendering context and if po...
QBBWindow * mParent
Definition: qbbwindow.h:120
void updateVisibility(bool parentVisible)
Definition: qbbwindow.cpp:254
void setBufferSize(const QSize &size)
Definition: qbbwindow.cpp:288
virtual ~QBBWindow()
Definition: qbbwindow.cpp:135
The QPlatformWindow class provides an abstraction for top-level windows.
QSize bufferSize() const
Definition: qbbwindow.h:73
bool mVisible
Definition: qbbwindow.h:121
NSWindow * window
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QList< QBBWindow * > mChildren
Definition: qbbwindow.h:119
int mPreviousBufferIndex
Definition: qbbwindow.h:113
QBBScreen * screen() const
Definition: qbbwindow.h:93
screen_window_t mWindow
Definition: qbbwindow.h:109
int mCurrentBufferIndex
Definition: qbbwindow.h:112
QBBBuffer mBuffers[MAX_BUFFER_COUNT]
Definition: qbbwindow.h:111
void post(const QRegion &dirty)
Definition: qbbwindow.cpp:417
void gainedFocus()
Definition: qbbwindow.cpp:607
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
static int platformWindowFormatToNativeFormat(const QPlatformWindowFormat &format)
Definition: qbbwindow.cpp:707
const QList< QBBWindow * > & children() const
Definition: qbbwindow.h:94
virtual void setVisible(bool visible)
Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false...
Definition: qbbwindow.cpp:232
QBBBuffer & renderBuffer()
Definition: qbbwindow.cpp:350
virtual void setGeometry(const QRect &rect)
This function is called by Qt whenever a window is moved or the window is resized.
Definition: qbbwindow.cpp:157
The QPlatformGLContext class provides an abstraction for native GL contexts.
void scroll(const QRegion &region, int dx, int dy, bool flush=false)
Definition: qbbwindow.cpp:411
void copyBack(const QRegion &region, int dx, int dy, bool flush=false)
Definition: qbbwindow.cpp:646
virtual WId winId() const
Reimplement in subclasses to return a handle to the native window.
Definition: qbbwindow.h:70
QBBBuffer & buffer(QBBWindow::Buffer bufferIndex)
Definition: qbbwindow.cpp:368
virtual QPlatformGLContext * glContext() const
Reimplement to return the glContext associated with the window.
Definition: qbbwindow.cpp:461
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
screen_context_t mContext
Definition: qbbwindow.h:108
void updateZorder(int &topZorder)
Definition: qbbwindow.cpp:631
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QBBBuffer & frontBuffer()
Definition: qbbwindow.cpp:359
QRegion mScrolled
Definition: qbbwindow.h:115
QBBScreen * mScreen
Definition: qbbwindow.h:118
Q_CORE_EXPORT QTextStream & flush(QTextStream &s)
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
virtual void setOpacity(qreal level)
Reimplement to be able to let Qt set the opacity level of a window.
Definition: qbbwindow.cpp:270
QBBWindow * findWindow(screen_window_t windowHandle)
Definition: qbbwindow.cpp:617
bool isEmpty() const
Returns true if either of the width and height is less than or equal to 0; otherwise returns false...
Definition: qsize.h:120
void fetchBuffers()
void removeFromParent()
Definition: qbbwindow.cpp:519
QRegion mPreviousDirty
Definition: qbbwindow.h:114
QBBGLContext * mPlatformGlContext
Definition: qbbwindow.h:117
The QList class is a template class that provides lists.
Definition: qdatastream.h:62