1 /****************************************************************************
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the tools applications of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
48 //#define QVFB_USE_GLWIDGET
49 //#include <QGLWidget>
56 class QAnimationWriter
;
58 class QVFbViewProtocol
;
59 class QX11EmbedContainer
;
61 class QVFbAbstractView
:
62 #ifdef QVFB_USE_GLWIDGET
70 enum Rotation
{ Rot0
, Rot90
, Rot180
, Rot270
};
71 enum PixelFormat
{ DefaultFormat
, GrayscaleFormat
, RGBFormat
, ARGBFormat
};
72 QVFbAbstractView( QWidget
*parent
= 0);
73 virtual ~QVFbAbstractView();
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 bool rgbSwapped() const { return false; }
81 virtual Rotation
displayRotation() const = 0;
83 virtual void setGamma(double gr
, double gg
, double gb
) = 0;
84 virtual double gammaRed() const = 0;
85 virtual double gammaGreen() const = 0;
86 virtual double gammaBlue() const = 0;
87 virtual void getGamma(int i
, QRgb
& rgb
) = 0;
89 virtual bool touchScreenEmulation() const = 0;
90 virtual bool lcdScreenEmulation() const = 0;
91 virtual int rate() = 0;
92 virtual bool animating() const = 0;
93 virtual QImage
image() const = 0;
94 virtual void setRate(int) = 0;
96 virtual double zoomH() const = 0;
97 virtual double zoomV() const = 0;
100 virtual void setTouchscreenEmulation( bool ) = 0;
101 virtual void setLcdScreenEmulation( bool ) = 0;
102 virtual void setZoom( double, double ) = 0;
103 virtual void setRotation(Rotation
) = 0;
104 virtual void startAnimation( const QString
& ) = 0;
105 virtual void stopAnimation() = 0;
106 virtual void skinKeyPressEvent( int code
, const QString
& text
, bool autorep
=FALSE
) = 0;
107 virtual void skinKeyReleaseEvent( int code
, const QString
& text
, bool autorep
=FALSE
) = 0;
108 virtual void setViewFormat(PixelFormat
) {}
109 virtual void setRgbSwapped( bool ) {};
110 virtual void embedDisplay(WId
) {}
113 class QVFbView
: public QVFbAbstractView
117 QVFbView(int id
, int w
, int h
, int d
, Rotation r
, QWidget
*parent
= 0);
120 int displayId() const;
121 int displayWidth() const;
122 int displayHeight() const;
123 int displayDepth() const;
124 PixelFormat
displayFormat() const;
125 bool rgbSwapped() const { return rgb_swapped
; }
126 Rotation
displayRotation() const;
128 bool touchScreenEmulation() const { return emulateTouchscreen
; }
129 bool lcdScreenEmulation() const { return emulateLcdScreen
; }
130 int rate() { return refreshRate
; }
131 bool animating() const { return !!animation
; }
132 QImage
image() const;
134 void setGamma(double gr
, double gg
, double gb
);
135 double gammaRed() const { return gred
; }
136 double gammaGreen() const { return ggreen
; }
137 double gammaBlue() const { return gblue
; }
138 void getGamma(int i
, QRgb
& rgb
);
139 void skinMouseEvent(QMouseEvent
*e
);
141 double zoomH() const { return hzm
; }
142 double zoomV() const { return vzm
; }
144 QSize
sizeHint() const;
148 void setTouchscreenEmulation(bool);
149 void setLcdScreenEmulation(bool);
150 void setZoom(double, double);
151 void setRotation(Rotation
);
152 void startAnimation(const QString
&);
153 void stopAnimation();
154 void skinKeyPressEvent(int code
, const QString
& text
, bool autorep
=FALSE
);
155 void skinKeyReleaseEvent(int code
, const QString
& text
, bool autorep
=FALSE
);
156 void setViewFormat(PixelFormat
);
157 void setRgbSwapped(bool b
) { rgb_swapped
= b
; }
159 void embedDisplay(WId id
);
163 void refreshDisplay(const QRect
&);
166 QImage
getBuffer(const QRect
&r
, int &leading
) const;
167 void drawScreen(const QRect
&r
);
168 void sendMouseData(const QPoint
&pos
, int buttons
, int wheel
);
169 void sendKeyboardData(QString unicode
, int keycode
, int modifiers
,
170 bool press
, bool repeat
);
171 //virtual bool eventFilter(QObject *obj, QEvent *e);
172 virtual void paintEvent(QPaintEvent
*pe
);
173 virtual void contextMenuEvent(QContextMenuEvent
*e
);
174 virtual void mousePressEvent(QMouseEvent
*e
);
175 virtual void mouseDoubleClickEvent(QMouseEvent
*e
);
176 virtual void mouseReleaseEvent(QMouseEvent
*e
);
177 virtual void mouseMoveEvent(QMouseEvent
*e
);
178 virtual void wheelEvent(QWheelEvent
*e
);
179 virtual void keyPressEvent(QKeyEvent
*e
);
180 virtual void keyReleaseEvent(QKeyEvent
*e
);
181 virtual bool event(QEvent
*event
);
184 void setDirty(const QRect
&);
185 int viewdepth
; // "faked" depth
186 PixelFormat viewFormat
;
196 double gred
, ggreen
, gblue
;
200 QAnimationWriter
*animation
;
202 QVFbViewProtocol
*mView
;
203 bool emulateTouchscreen
;
204 bool emulateLcdScreen
;
208 QX11EmbedContainer
*embedContainer
;