Qt 4.8
fb_base.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the plugins 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 QLIGHTHOUSEGRAPHICSSCREEN_H
43 #define QLIGHTHOUSEGRAPHICSSCREEN_H
44 
45 #include <qrect.h>
46 #include <qimage.h>
47 #include <qtimer.h>
48 #include <qpainter.h>
49 #include <QPlatformCursor>
50 #include <QPlatformScreen>
51 #include <QPlatformWindow>
52 #include <QtGui/private/qwindowsurface_p.h>
53 
54 class QMouseEvent;
55 class QSize;
56 class QPainter;
57 
58 class QFbScreen;
59 
61 {
62 public:
64 
65  // output methods
66  QRect dirtyRect();
67  virtual QRect drawCursor(QPainter & painter);
68 
69  // input methods
70  virtual void pointerEvent(const QMouseEvent & event);
71  virtual void changeCursor(QCursor * widgetCursor, QWidget * widget);
72 
73  virtual void setDirty() { dirty = true; screen->setDirty(QRect()); }
74  virtual bool isDirty() { return dirty; }
75  virtual bool isOnScreen() { return onScreen; }
76  virtual QRect lastPainted() { return prevRect; }
77 
78 protected:
80 
81 private:
82  void setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY);
83  void setCursor(Qt::CursorShape shape);
84  void setCursor(const QImage &image, int hotx, int hoty);
85  QRect currentRect; // next place to draw the cursor
86  QRect prevRect; // last place the cursor was drawn
88  bool dirty;
89  bool onScreen;
90 };
91 
92 class QFbWindow;
93 
95 {
96 public:
99 
100  virtual QPaintDevice *paintDevice() { return &mImage; }
101  virtual void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
102  virtual bool scroll(const QRegion &area, int dx, int dy);
103 
104  virtual void beginPaint(const QRegion &region);
105  virtual void endPaint(const QRegion &region);
106 
107 
108  const QImage image() { return mImage; }
109  void resize(const QSize &size);
110 
111 protected:
112  friend class QFbWindow;
114 
117 };
118 
119 
121 {
122 public:
123 
125  ~QFbWindow();
126 
127 
128  virtual void setVisible(bool visible);
129  virtual bool visible() { return visibleFlag; }
130 
131  virtual void raise();
132  virtual void lower();
133 
134  void setGeometry(const QRect &rect);
135 
136  virtual Qt::WindowFlags setWindowFlags(Qt::WindowFlags type);
137  virtual Qt::WindowFlags windowFlags() const;
138 
139  WId winId() const { return windowId; }
140 
141  virtual void repaint(const QRegion&);
142 
143 protected:
144  friend class QFbWindowSurface;
145  friend class QFbScreen;
150  Qt::WindowFlags flags;
151 
153 };
154 
156 {
157  Q_OBJECT
158 public:
159  QFbScreen();
160  ~QFbScreen();
161 
162  virtual QRect geometry() const { return mGeometry; }
163  virtual int depth() const { return mDepth; }
164  virtual QImage::Format format() const { return mFormat; }
165  virtual QSize physicalSize() const { return mPhysicalSize; }
166 
167  virtual void setGeometry(QRect rect);
168  virtual void setDepth(int depth);
169  virtual void setFormat(QImage::Format format);
170  virtual void setPhysicalSize(QSize size);
171 
172  virtual void setDirty(const QRect &rect);
173 
174  virtual void removeWindow(QFbWindow * surface);
175  virtual void addWindow(QFbWindow * surface);
176  virtual void raise(QPlatformWindow * surface);
177  virtual void lower(QPlatformWindow * surface);
178  virtual QWidget * topLevelAt(const QPoint & p) const;
179 
180  QImage * image() const { return mScreenImage; }
181  QPaintDevice * paintDevice() const { return mScreenImage; }
182 
183 protected:
188 
189 protected slots:
190  virtual QRegion doRedraw();
191 
192 protected:
194  int mDepth;
198 
199 private:
201  void generateRects();
203 
204  void invalidateRectCache() { isUpToDate = false; }
205  friend class QFbWindowSurface;
206  friend class QFbWindow;
208 };
209 
210 #endif // QLIGHTHOUSEGRAPHICSSCREEN_H
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
QImage * mScreenImage
Definition: fb_base.h:197
virtual void pointerEvent(const QMouseEvent &event)
This method is called by Qt whenever a QMouseEvent is generated by the underlying pointer input...
Definition: fb_base.cpp:67
Format
The following image formats are available in Qt.
Definition: qimage.h:91
virtual bool isDirty()
Definition: fb_base.h:74
unsigned long WId
Definition: qwindowdefs.h:119
int type
Definition: qmetatype.cpp:239
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition: qcursor.h:89
QPointer< QWidget > widget
QTimer redrawTimer
Definition: fb_base.h:187
QFbScreen * mScreen
Definition: fb_base.h:115
The QPlatformScreen class provides an abstraction for visual displays.
bool isUpToDate
Definition: fb_base.h:207
Qt::WindowFlags flags
Definition: fb_base.h:150
QImage::Format mFormat
Definition: fb_base.h:195
The QPlatformCursor class provides information about pointer device events (movement, buttons), and requests to change the currently displayed cursor.
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
virtual QRect lastPainted()
Definition: fb_base.h:76
QPlatformSoftwareCursor(QPlatformScreen *scr)
Definition: fb_base.cpp:49
virtual QRect drawCursor(QPainter &painter)
Definition: fb_base.cpp:78
QPainter * compositePainter
Definition: fb_base.h:200
The QPlatformWindow class provides an abstraction for top-level windows.
virtual bool isOnScreen()
Definition: fb_base.h:75
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
void setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY)
Definition: fb_base.cpp:115
virtual QSize physicalSize() const
Reimplement this function in subclass to return the physical size of the screen.
Definition: fb_base.h:165
unsigned char uchar
Definition: qglobal.h:994
NSWindow * window
bool visibleFlag
Definition: fb_base.h:149
virtual int depth() const
Reimplement in subclass to return current depth of the screen.
Definition: fb_base.h:163
WId winId() const
Reimplement in subclasses to return a handle to the native window.
Definition: fb_base.h:139
QList< QPair< QRect, int > > cachedRects
Definition: fb_base.h:202
QImage mImage
Definition: fb_base.h:116
virtual void changeCursor(QCursor *widgetCursor, QWidget *widget)
This method is called by Qt whenever the cursor graphic should be changed.
Definition: fb_base.cpp:120
void invalidateRectCache()
Definition: fb_base.h:204
virtual void setDirty(const QRect &)
QFbWindow * platformWindow
Definition: fb_base.h:113
virtual QPaintDevice * paintDevice()
Implement this function to return the appropriate paint device.
Definition: fb_base.h:100
QRect oldGeometry
Definition: fb_base.h:148
const QImage image()
Definition: fb_base.h:108
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
static const char * data(const QByteArray &arr)
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
QPaintDevice * paintDevice() const
Definition: fb_base.h:181
QRect mGeometry
Definition: fb_base.h:193
#define Q_OBJECT
Definition: qobjectdefs.h:157
int mDepth
Definition: fb_base.h:194
The QWindowSurface class provides the drawing area for top-level windows.
WId windowId
Definition: fb_base.h:152
QPlatformSoftwareCursor * cursor
Definition: fb_base.h:186
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
QImage * image() const
Definition: fb_base.h:180
The QPlatformCursorImage class provides a set of graphics intended to be used as cursors.
virtual QImage::Format format() const
Reimplement in subclass to return the image format which corresponds to the screen format...
Definition: fb_base.h:164
CursorShape
Definition: qnamespace.h:1262
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QFbWindowSurface * surface
Definition: fb_base.h:146
QSize mPhysicalSize
Definition: fb_base.h:196
QPlatformScreen * screen
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
virtual bool visible()
Definition: fb_base.h:129
QList< QFbScreen * > mScreens
Definition: fb_base.h:147
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 QRect geometry() const
Reimplement in subclass to return the pixel geometry of the screen.
Definition: fb_base.h:162
The QTimer class provides repetitive and single-shot timers.
Definition: qtimer.h:56
QList< QFbWindow * > windowStack
Definition: fb_base.h:184
QRegion repaintRegion
Definition: fb_base.h:185
#define slots
Definition: qobjectdefs.h:68
QPlatformCursorImage * graphic
Definition: fb_base.h:79
virtual void setDirty()
Definition: fb_base.h:73
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
static int area(const QSize &s)
Definition: qicon.cpp:155