Qt 4.8
Public Functions | Properties | List of all members
QAhiScreenCursor Class Reference
Inheritance diagram for QAhiScreenCursor:
QScreenCursor

Public Functions

void hide ()
 Hides the cursor from the screen. More...
 
void move (int x, int y)
 Moves the mouse cursor to the given position, i.e., (x, y). More...
 
 QAhiScreenCursor (QScreen *screen, AhiDevCtx_t context)
 
void set (const QImage &image, int hotx, int hoty)
 Sets the cursor's image to be the given image. More...
 
void show ()
 Shows the mouse cursor. More...
 
- Public Functions inherited from QScreenCursor
QRect boundingRect () const
 Returns the cursor's bounding rectangle. 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...
 
 QScreenCursor ()
 Constructs a screen cursor. More...
 
bool supportsAlphaCursor () const
 
virtual ~QScreenCursor ()
 Destroys the screen cursor. More...
 

Properties

AhiDevCtx_t context
 
QScreenscreen
 

Additional Inherited Members

- Static Public Functions inherited from QScreenCursor
static bool enabled ()
 
static void initSoftwareCursor ()
 Initializes the screen cursor. More...
 
static QScreenCursorinstance ()
 
- Protected Variables inherited from QScreenCursor
QImage cursor
 
uint enable: 1
 
QPoint hotspot
 
uint hwaccel: 1
 
QPoint pos
 
QSize size
 
uint supportsAlpha: 1
 

Detailed Description

Definition at line 106 of file qscreenahi_qws.cpp.

Constructors and Destructors

◆ QAhiScreenCursor()

QAhiScreenCursor::QAhiScreenCursor ( QScreen screen,
AhiDevCtx_t  context 
)

Definition at line 121 of file qscreenahi_qws.cpp.

122  : QScreenCursor(), screen(s), context(c)
123 {
124  hwaccel = true;
125  supportsAlpha = true;
126 
127  if (enable)
128  show();
129  else
130  hide();
131 }
unsigned char c[8]
Definition: qnumeric_p.h:62
void hide()
Hides the cursor from the screen.
QScreenCursor()
Constructs a screen cursor.
void show()
Shows the mouse cursor.
uint supportsAlpha
Definition: qscreen_qws.h:166

Functions

◆ hide()

void QAhiScreenCursor::hide ( )
virtual

Hides the cursor from the screen.

See also
show()

Reimplemented from QScreenCursor.

Definition at line 189 of file qscreenahi_qws.cpp.

Referenced by QAhiScreenCursor().

190 {
191  AhiDispCursorState(context, AhiCursor1, AhiCursorStateOff, 0);
193 }
virtual void hide()
Hides the cursor from the screen.

◆ move()

void QAhiScreenCursor::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 from QScreenCursor.

Definition at line 170 of file qscreenahi_qws.cpp.

171 {
172  AhiPoint_t pos = { x, y };
173  AhiSts_t status = AhiDispCursorPos(context, AhiCursor1, &pos, 0);
174  if (status != AhiStsOk)
175  qWarning("QAhiScreenCursor::move(): error setting mouse position: %x",
176  status);
177  QScreenCursor::move(x, y);
178 }
virtual void move(int x, int y)
Moves the mouse cursor to the given position, i.e., (x, y).
static LibLoadStatus status
Definition: qlocale_icu.cpp:69
Q_CORE_EXPORT void qWarning(const char *,...)

◆ set()

void QAhiScreenCursor::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 from QScreenCursor.

Definition at line 133 of file qscreenahi_qws.cpp.

134 {
135  if (image.isNull()) {
136  QScreenCursor::set(image, hotx, hoty);
137  return;
138  }
139 
140  if (image.format() != QImage::Format_MonoLSB) {
141  set(image.convertToFormat(QImage::Format_MonoLSB), hotx, hoty);
142  return;
143  }
144 
145  AhiPixelFormat_t pixFmt = pixelFormatForImageFormat(image.format());
146 
147  if (pixFmt >= AhiPixelFormatMax) { // generic fallback
148  QImage::Format toFormat = screen->pixelFormat();
149  if (toFormat == QImage::Format_Invalid)
150  toFormat = QImage::Format_ARGB32;
151  set(image.convertToFormat(toFormat), hotx, hoty);
152  return;
153  }
154 
155  AhiPoint_t hotSpot = { hotx, hoty };
156  AhiSize_t bitmapSize = { image.width(), image.height() };
157  AhiBitmap_t bitmap = { bitmapSize, (void*)(image.bits()),
158  image.bytesPerLine(), pixFmt };
159 
160  AhiSts_t status;
161  status = AhiDispCursorSet(context, AhiCursor1, &bitmap, &hotSpot,
162  image.serialNumber(), 0);
163  if (status != AhiStsOk)
164  qWarning("QAhiScreenCursor::set(): AhiDispCursorSet failed: %x",
165  status);
166 
167  QScreenCursor::set(image, hotx, hoty);
168 }
Format
The following image formats are available in Qt.
Definition: qimage.h:91
bool isNull() const
Returns true if it is a null image, otherwise returns false.
Definition: qimage.cpp:1542
static LibLoadStatus status
Definition: qlocale_icu.cpp:69
int bytesPerLine() const
Returns the number of bytes per image scanline.
Definition: qimage.cpp:1812
Format format() const
Returns the format of the image.
Definition: qimage.cpp:2305
static AhiPixelFormat_t pixelFormatForImageFormat(const QImage::Format format)
Q_CORE_EXPORT void qWarning(const char *,...)
uchar * bits()
Returns a pointer to the first pixel data.
Definition: qimage.cpp:1946
int serialNumber() const
Returns a number that identifies the contents of this QImage object.
Definition: qimage.cpp:6267
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
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
QImage::Format pixelFormat() const
Returns the pixel format of the screen, or QImage::Format_Invalid if the pixel format is not a suppor...
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
virtual void set(const QImage &image, int hotx, int hoty)
Sets the cursor's image to be the given image.

◆ show()

void QAhiScreenCursor::show ( )
virtual

Shows the mouse cursor.

See also
hide()

Reimplemented from QScreenCursor.

Definition at line 180 of file qscreenahi_qws.cpp.

Referenced by QAhiScreenCursor().

181 {
182  AhiSts_t status;
183  status = AhiDispCursorState(context, AhiCursor1, AhiCursorStateOn, 0);
184  if (status != AhiStsOk)
185  qWarning("QAhiScreenCursor::show(): error setting state: %x", status);
187 }
static LibLoadStatus status
Definition: qlocale_icu.cpp:69
Q_CORE_EXPORT void qWarning(const char *,...)
virtual void show()
Shows the mouse cursor.

Properties

◆ context

AhiDevCtx_t QAhiScreenCursor::context
private

Definition at line 118 of file qscreenahi_qws.cpp.

Referenced by hide(), move(), set(), and show().

◆ screen

QScreen* QAhiScreenCursor::screen
private

Definition at line 117 of file qscreenahi_qws.cpp.

Referenced by set().


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