Qt 4.8
Public Functions | Static Public Functions | Protected Variables | Friends | List of all members
QScreenCursor Class Reference

The QScreenCursor class is a base class for screen cursors in Qt for Embedded Linux. More...

#include <qscreen_qws.h>

Inheritance diagram for QScreenCursor:
QAhiScreenCursor QDirectFBScreenCursor QMultiScreenCursor QProxyScreenCursor QVNCClientCursor QVNCCursor

Public Functions

QRect boundingRect () const
 Returns the cursor's bounding rectangle. More...
 
virtual void hide ()
 Hides the cursor from the screen. More...
 
QImage image () const
 Returns the cursor's image. More...
 
bool isAccelerated () const
 Returns true if the cursor is accelerated; otherwise false. More...
 
bool isVisible () const
 Returns true if the cursor is visible; otherwise false. More...
 
virtual void move (int x, int y)
 Moves the mouse cursor to the given position, i.e., (x, y). More...
 
 QScreenCursor ()
 Constructs a screen cursor. More...
 
virtual void set (const QImage &image, int hotx, int hoty)
 Sets the cursor's image to be the given image. More...
 
virtual void show ()
 Shows the mouse cursor. More...
 
bool supportsAlphaCursor () const
 
virtual ~QScreenCursor ()
 Destroys the screen cursor. More...
 

Static Public Functions

static bool enabled ()
 
static void initSoftwareCursor ()
 Initializes the screen cursor. More...
 
static QScreenCursorinstance ()
 

Protected Variables

QImage cursor
 
uint enable: 1
 
QPoint hotspot
 
uint hwaccel: 1
 
QPoint pos
 
QSize size
 
uint supportsAlpha: 1
 

Friends

class QProxyScreenCursor
 

Detailed Description

The QScreenCursor class is a base class for screen cursors in Qt for Embedded Linux.

Note that this class is non-portable, and that it is only available in Qt for Embedded Linux.

QScreenCursor implements a software cursor, but can be subclassed to support hardware cursors as well. When deriving from the QScreenCursor class it is important to maintain the cursor's image, position, hot spot (the point within the cursor's image that will be the position of the associated mouse events) and visibility as well as informing whether it is hardware accelerated or not.

Note that there may only be one screen cursor at a time. Use the static instance() function to retrieve a pointer to the current screen cursor. Typically, the cursor is constructed by the QScreen class or one of its descendants when it is initializing the device; the QScreenCursor class should never be instantiated explicitly.

Use the move() function to change the position of the cursor, and the set() function to alter its image or its hot spot. In addition, you can find out whether the cursor is accelerated or not, using the isAccelerated() function, and the boundingRect() function returns the cursor's bounding rectangle.

The cursor's appearance can be controlled using the isVisible(), hide() and show() functions; alternatively the QWSServer class provides some means of controlling the cursor's appearance using the QWSServer::isCursorVisible() and QWSServer::setCursorVisible() functions.

See also
QScreen, QWSServer

Definition at line 135 of file qscreen_qws.h.

Constructors and Destructors

◆ QScreenCursor()

QScreenCursor::QScreenCursor ( )

Constructs a screen cursor.

Definition at line 127 of file qscreen_qws.cpp.

Referenced by initSoftwareCursor().

128 {
130  size = QSize(0,0);
131  enable = true;
132  hwaccel = false;
133  supportsAlpha = true;
134 }
Q_GUI_EXPORT QScreen * qt_screen
Definition: qscreen_qws.cpp:69
int deviceWidth() const
Returns the physical width of the framebuffer device in pixels.
Definition: qscreen_qws.h:233
int deviceHeight() const
Returns the full height of the framebuffer device in pixels.
Definition: qscreen_qws.h:234
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
uint supportsAlpha
Definition: qscreen_qws.h:166
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ ~QScreenCursor()

QScreenCursor::~QScreenCursor ( )
virtual

Destroys the screen cursor.

Definition at line 139 of file qscreen_qws.cpp.

140 {
141 }

Functions

◆ boundingRect()

QRect QScreenCursor::boundingRect ( ) const
inline

Returns the cursor's bounding rectangle.

Definition at line 150 of file qscreen_qws.h.

Referenced by blendCursor(), buttonChange(), QScreen::exposeRegion(), QVNCCursor::hide(), hide(), QVNCCursor::move(), move(), QVNCDirtyMap::QVNCDirtyMap(), QVNCCursor::set(), set(), QVNCCursor::show(), show(), QRfbRawEncoder::write(), and QRfbHextileEncoder< SRC >::write().

150 { return QRect(pos - hotspot, size); }
QPoint hotspot
Definition: qscreen_qws.h:163
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ enabled()

bool QScreenCursor::enabled ( )
inlinestatic
Warning
This function is not part of the public interface.

Definition at line 148 of file qscreen_qws.h.

148 { return qws_sw_cursor; }
bool qws_sw_cursor

◆ hide()

void QScreenCursor::hide ( )
virtual

Hides the cursor from the screen.

See also
show()

Reimplemented in QDirectFBScreenCursor, QAhiScreenCursor, QVNCCursor, QProxyScreenCursor, and QMultiScreenCursor.

Definition at line 148 of file qscreen_qws.cpp.

Referenced by QWSServer::beginDisplayReconfigure(), QMultiScreenCursor::hide(), QProxyScreenCursor::hide(), QAhiScreenCursor::hide(), QWSServerPrivate::hideCursor(), QWSServerPrivate::resetEngine(), and QScreen::shutdownDevice().

149 {
150  if (enable) {
151  enable = false;
152  if (!hwaccel)
154  }
155 }
Q_GUI_EXPORT QScreen * qt_screen
Definition: qscreen_qws.cpp:69
QRect boundingRect() const
Returns the cursor&#39;s bounding rectangle.
Definition: qscreen_qws.h:150
virtual void exposeRegion(QRegion r, int changing)
This function is called by the Qt for Embedded Linux server whenever a screen update is required...

◆ image()

QImage QScreenCursor::image ( ) const
inline

◆ initSoftwareCursor()

void QScreenCursor::initSoftwareCursor ( )
static

Initializes the screen cursor.

This function is typically called from the screen driver when initializing the device. Alternatively, the cursor can be set directly using the pointer returned by the static instance() function.

See also
QScreen::initDevice()

Definition at line 247 of file qscreen_qws.cpp.

Referenced by QIntfbScreen::initDevice(), QVFbScreen::initDevice(), QQnxScreen::initDevice(), QAhiScreen::initDevice(), QLinuxFbScreen::initDevice(), QLinuxFbIntegration::initDevice(), and QDirectFBScreen::initDevice().

248 {
250 }
QScreenCursor()
Constructs a screen cursor.
Q_GUI_EXPORT QScreenCursor * qt_screencursor
Definition: qscreen_qws.cpp:67

◆ instance()

static QScreenCursor * QScreenCursor::instance ( )
inlinestatic
Since
4.2

Returns a pointer to the application's unique screen cursor.

Definition at line 156 of file qscreen_qws.h.

Referenced by QDirectFBScreen::exposeRegion().

156 { return qt_screencursor; }
QScreenCursor * qt_screencursor
Definition: qscreen_qws.cpp:67

◆ isAccelerated()

bool QScreenCursor::isAccelerated ( ) const
inline

Returns true if the cursor is accelerated; otherwise false.

Definition at line 153 of file qscreen_qws.h.

Referenced by QScreen::exposeRegion(), QVNCDirtyMap::QVNCDirtyMap(), QVNCServer::setEncodings(), QRfbRawEncoder::write(), and QRfbHextileEncoder< SRC >::write().

153 { return hwaccel; }

◆ isVisible()

bool QScreenCursor::isVisible ( ) const
inline

Returns true if the cursor is visible; otherwise false.

Definition at line 152 of file qscreen_qws.h.

152 { return enable; }

◆ move()

void QScreenCursor::move ( int  x,
int  y 
)
virtual

Moves the mouse cursor to the given position, i.e., (x, y).

Note that the given position defines the top-left corner of the cursor's image, i.e., not the cursor's hot spot (the position of the associated mouse events).

See also
set()

Reimplemented in QDirectFBScreenCursor, QAhiScreenCursor, QVNCCursor, QProxyScreenCursor, and QMultiScreenCursor.

Definition at line 221 of file qscreen_qws.cpp.

Referenced by QMultiScreenCursor::move(), QProxyScreenCursor::move(), QAhiScreenCursor::move(), and QWSServerPrivate::sendMouseEventUnfiltered().

222 {
223  QRegion r = boundingRect();
224  pos = QPoint(x,y);
225  if (enable && !hwaccel) {
226  r |= boundingRect();
227  qt_screen->exposeRegion(r, 0);
228  }
229 }
Q_GUI_EXPORT QScreen * qt_screen
Definition: qscreen_qws.cpp:69
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
QRect boundingRect() const
Returns the cursor&#39;s bounding rectangle.
Definition: qscreen_qws.h:150
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
virtual void exposeRegion(QRegion r, int changing)
This function is called by the Qt for Embedded Linux server whenever a screen update is required...

◆ set()

void QScreenCursor::set ( const QImage image,
int  hotx,
int  hoty 
)
virtual

Sets the cursor's image to be the given image.

The hotx and hoty parameters define the cursor's hot spot, i.e., the point within the cursor's image that will be the position of the associated mouse events.

See also
move()

Reimplemented in QDirectFBScreenCursor, QAhiScreenCursor, QVNCClientCursor, QVNCCursor, QProxyScreenCursor, and QMultiScreenCursor.

Definition at line 180 of file qscreen_qws.cpp.

Referenced by QMultiScreenCursor::move(), QMultiScreenCursor::set(), QProxyScreenCursor::set(), QVNCClientCursor::set(), QAhiScreenCursor::set(), and QWSServerPrivate::setCursor().

181 {
182  const QRect r = boundingRect();
183 
184  hotspot = QPoint(hotx, hoty);
185  // These are in almost all cases the fastest formats to blend
186  QImage::Format f;
187  switch (qt_screen->depth()) {
188  case 12:
190  break;
191  case 15:
193  break;
194  case 16:
196  break;
197  case 18:
199  break;
200  default:
202  }
203 
204  cursor = image.convertToFormat(f);
205 
206  size = image.size();
207 
208  if (enable && !hwaccel)
210 }
Q_GUI_EXPORT QScreen * qt_screen
Definition: qscreen_qws.cpp:69
Format
The following image formats are available in Qt.
Definition: qimage.h:91
QPoint hotspot
Definition: qscreen_qws.h:163
QSize size() const
Returns the size of the image, i.
Definition: qimage.cpp:1587
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const Q_REQUIRED_RESULT
Returns a copy of the image in the given format.
Definition: qimage.cpp:3966
QRect boundingRect() const
Returns the cursor&#39;s bounding rectangle.
Definition: qscreen_qws.h:150
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
virtual void exposeRegion(QRegion r, int changing)
This function is called by the Qt for Embedded Linux server whenever a screen update is required...
int depth() const
Returns the depth of the framebuffer, in bits per pixel.
Definition: qscreen_qws.h:229

◆ show()

void QScreenCursor::show ( )
virtual

Shows the mouse cursor.

See also
hide()

Reimplemented in QDirectFBScreenCursor, QAhiScreenCursor, QVNCCursor, QProxyScreenCursor, and QMultiScreenCursor.

Definition at line 162 of file qscreen_qws.cpp.

Referenced by QWSServer::endDisplayReconfigure(), QMultiScreenCursor::move(), QWSServerPrivate::resetEngine(), QMultiScreenCursor::show(), QProxyScreenCursor::show(), QAhiScreenCursor::show(), and QWSServerPrivate::showCursor().

163 {
164  if (!enable) {
165  enable = true;
166  if (!hwaccel)
168  }
169 }
Q_GUI_EXPORT QScreen * qt_screen
Definition: qscreen_qws.cpp:69
QRect boundingRect() const
Returns the cursor&#39;s bounding rectangle.
Definition: qscreen_qws.h:150
virtual void exposeRegion(QRegion r, int changing)
This function is called by the Qt for Embedded Linux server whenever a screen update is required...

◆ supportsAlphaCursor()

bool QScreenCursor::supportsAlphaCursor ( ) const
inline
Warning
This function is not part of the public interface.

Definition at line 146 of file qscreen_qws.h.

Referenced by QWSCursor::set().

146 { return supportsAlpha; }
uint supportsAlpha
Definition: qscreen_qws.h:166

Friends and Related Functions

◆ QProxyScreenCursor

friend class QProxyScreenCursor
friend

Definition at line 169 of file qscreen_qws.h.

Properties

◆ cursor

QImage QScreenCursor::cursor
protected

◆ enable

uint QScreenCursor::enable
protected

◆ hotspot

QPoint QScreenCursor::hotspot
protected

◆ hwaccel

uint QScreenCursor::hwaccel
protected

◆ pos

QPoint QScreenCursor::pos
protected

◆ size

QSize QScreenCursor::size
protected

◆ supportsAlpha

uint QScreenCursor::supportsAlpha
protected

The documentation for this class was generated from the following files: