1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** Contact: Qt Software Information ([email protected])
|
---|
5 | **
|
---|
6 | ** This file is part of the tools applications of the Qt Toolkit.
|
---|
7 | **
|
---|
8 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
9 | ** Commercial Usage
|
---|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
11 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
12 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
13 | ** a written agreement between you and Nokia.
|
---|
14 | **
|
---|
15 | ** GNU Lesser General Public License Usage
|
---|
16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
17 | ** General Public License version 2.1 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
19 | ** packaging of this file. Please review the following information to
|
---|
20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
22 | **
|
---|
23 | ** In addition, as a special exception, Nokia gives you certain
|
---|
24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
26 | ** package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you are unsure which license is appropriate for your use, please
|
---|
37 | ** contact the sales department at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef QVFBVIEW_H
|
---|
43 | #define QVFBVIEW_H
|
---|
44 |
|
---|
45 | //#ifdef QT_NO_OPENGL
|
---|
46 | #include <QWidget>
|
---|
47 | //#else
|
---|
48 | //#define QVFB_USE_GLWIDGET
|
---|
49 | //#include <QGLWidget>
|
---|
50 | //#endif
|
---|
51 |
|
---|
52 | QT_BEGIN_NAMESPACE
|
---|
53 |
|
---|
54 | class QImage;
|
---|
55 | class QTimer;
|
---|
56 | class QAnimationWriter;
|
---|
57 | struct QVFbHeader;
|
---|
58 | class QVFbViewProtocol;
|
---|
59 | class QX11EmbedContainer;
|
---|
60 |
|
---|
61 | class QVFbAbstractView :
|
---|
62 | #ifdef QVFB_USE_GLWIDGET
|
---|
63 | public QGLWidget
|
---|
64 | #else
|
---|
65 | public QWidget
|
---|
66 | #endif
|
---|
67 | {
|
---|
68 | Q_OBJECT
|
---|
69 | public:
|
---|
70 | enum Rotation { Rot0, Rot90, Rot180, Rot270 };
|
---|
71 | enum PixelFormat { DefaultFormat, GrayscaleFormat, RGBFormat, ARGBFormat };
|
---|
72 | QVFbAbstractView( QWidget *parent = 0);
|
---|
73 | virtual ~QVFbAbstractView();
|
---|
74 |
|
---|
75 | virtual int displayId() const = 0;
|
---|
76 | virtual int displayWidth() const = 0;
|
---|
77 | virtual int displayHeight() const = 0;
|
---|
78 | virtual int displayDepth() const = 0;
|
---|
79 | virtual PixelFormat displayFormat() const { return DefaultFormat; }
|
---|
80 | virtual Rotation displayRotation() const = 0;
|
---|
81 |
|
---|
82 | virtual void setGamma(double gr, double gg, double gb) = 0;
|
---|
83 | virtual double gammaRed() const = 0;
|
---|
84 | virtual double gammaGreen() const = 0;
|
---|
85 | virtual double gammaBlue() const = 0;
|
---|
86 | virtual void getGamma(int i, QRgb& rgb) = 0;
|
---|
87 |
|
---|
88 | virtual bool touchScreenEmulation() const = 0;
|
---|
89 | virtual bool lcdScreenEmulation() const = 0;
|
---|
90 | virtual int rate() = 0;
|
---|
91 | virtual bool animating() const = 0;
|
---|
92 | virtual QImage image() const = 0;
|
---|
93 | virtual void setRate(int) = 0;
|
---|
94 |
|
---|
95 | virtual double zoomH() const = 0;
|
---|
96 | virtual double zoomV() const = 0;
|
---|
97 |
|
---|
98 | public slots:
|
---|
99 | virtual void setTouchscreenEmulation( bool ) = 0;
|
---|
100 | virtual void setLcdScreenEmulation( bool ) = 0;
|
---|
101 | virtual void setZoom( double, double ) = 0;
|
---|
102 | virtual void setRotation(Rotation) = 0;
|
---|
103 | virtual void startAnimation( const QString& ) = 0;
|
---|
104 | virtual void stopAnimation() = 0;
|
---|
105 | virtual void skinKeyPressEvent( int code, const QString& text, bool autorep=FALSE ) = 0;
|
---|
106 | virtual void skinKeyReleaseEvent( int code, const QString& text, bool autorep=FALSE ) = 0;
|
---|
107 | virtual void setViewFormat(PixelFormat) {}
|
---|
108 | virtual void embedDisplay(WId) {}
|
---|
109 | };
|
---|
110 |
|
---|
111 | class QVFbView : public QVFbAbstractView
|
---|
112 | {
|
---|
113 | Q_OBJECT
|
---|
114 | public:
|
---|
115 | QVFbView(int id, int w, int h, int d, Rotation r, QWidget *parent = 0);
|
---|
116 | virtual ~QVFbView();
|
---|
117 |
|
---|
118 | int displayId() const;
|
---|
119 | int displayWidth() const;
|
---|
120 | int displayHeight() const;
|
---|
121 | int displayDepth() const;
|
---|
122 | PixelFormat displayFormat() const;
|
---|
123 | Rotation displayRotation() const;
|
---|
124 |
|
---|
125 | bool touchScreenEmulation() const { return emulateTouchscreen; }
|
---|
126 | bool lcdScreenEmulation() const { return emulateLcdScreen; }
|
---|
127 | int rate() { return refreshRate; }
|
---|
128 | bool animating() const { return !!animation; }
|
---|
129 | QImage image() const;
|
---|
130 |
|
---|
131 | void setGamma(double gr, double gg, double gb);
|
---|
132 | double gammaRed() const { return gred; }
|
---|
133 | double gammaGreen() const { return ggreen; }
|
---|
134 | double gammaBlue() const { return gblue; }
|
---|
135 | void getGamma(int i, QRgb& rgb);
|
---|
136 | void skinMouseEvent(QMouseEvent *e);
|
---|
137 |
|
---|
138 | double zoomH() const { return hzm; }
|
---|
139 | double zoomV() const { return vzm; }
|
---|
140 |
|
---|
141 | QSize sizeHint() const;
|
---|
142 | void setRate(int);
|
---|
143 |
|
---|
144 | public slots:
|
---|
145 | void setTouchscreenEmulation(bool);
|
---|
146 | void setLcdScreenEmulation(bool);
|
---|
147 | void setZoom(double, double);
|
---|
148 | void setRotation(Rotation);
|
---|
149 | void startAnimation(const QString&);
|
---|
150 | void stopAnimation();
|
---|
151 | void skinKeyPressEvent(int code, const QString& text, bool autorep=FALSE);
|
---|
152 | void skinKeyReleaseEvent(int code, const QString& text, bool autorep=FALSE);
|
---|
153 | void setViewFormat(PixelFormat);
|
---|
154 | #ifdef Q_WS_X11
|
---|
155 | void embedDisplay(WId id);
|
---|
156 | #endif
|
---|
157 |
|
---|
158 | protected slots:
|
---|
159 | void refreshDisplay(const QRect &);
|
---|
160 |
|
---|
161 | protected:
|
---|
162 | QImage getBuffer(const QRect &r, int &leading) const;
|
---|
163 | void drawScreen(const QRect &r);
|
---|
164 | void sendMouseData(const QPoint &pos, int buttons, int wheel);
|
---|
165 | void sendKeyboardData(QString unicode, int keycode, int modifiers,
|
---|
166 | bool press, bool repeat);
|
---|
167 | //virtual bool eventFilter(QObject *obj, QEvent *e);
|
---|
168 | virtual void paintEvent(QPaintEvent *pe);
|
---|
169 | virtual void contextMenuEvent(QContextMenuEvent *e);
|
---|
170 | virtual void mousePressEvent(QMouseEvent *e);
|
---|
171 | virtual void mouseDoubleClickEvent(QMouseEvent *e);
|
---|
172 | virtual void mouseReleaseEvent(QMouseEvent *e);
|
---|
173 | virtual void mouseMoveEvent(QMouseEvent *e);
|
---|
174 | virtual void wheelEvent(QWheelEvent *e);
|
---|
175 | virtual void keyPressEvent(QKeyEvent *e);
|
---|
176 | virtual void keyReleaseEvent(QKeyEvent *e);
|
---|
177 | virtual bool event(QEvent *event);
|
---|
178 |
|
---|
179 | private:
|
---|
180 | void setDirty(const QRect&);
|
---|
181 | int viewdepth; // "faked" depth
|
---|
182 | PixelFormat viewFormat;
|
---|
183 | int rsh;
|
---|
184 | int gsh;
|
---|
185 | int bsh;
|
---|
186 | int rmax;
|
---|
187 | int gmax;
|
---|
188 | int bmax;
|
---|
189 | int contentsWidth;
|
---|
190 | int contentsHeight;
|
---|
191 | double gred, ggreen, gblue;
|
---|
192 | QRgb* gammatable;
|
---|
193 |
|
---|
194 | int refreshRate;
|
---|
195 | QAnimationWriter *animation;
|
---|
196 | double hzm,vzm;
|
---|
197 | QVFbViewProtocol *mView;
|
---|
198 | bool emulateTouchscreen;
|
---|
199 | bool emulateLcdScreen;
|
---|
200 | Rotation rotation;
|
---|
201 |
|
---|
202 | #ifdef Q_WS_X11
|
---|
203 | QX11EmbedContainer *embedContainer;
|
---|
204 | #endif
|
---|
205 | };
|
---|
206 |
|
---|
207 | QT_END_NAMESPACE
|
---|
208 |
|
---|
209 | #endif
|
---|