linuxfb: fix style in QFbCursor
Fix coding style, constness, m-prefix for member variables. Change-Id: I9d75b410b398e5c3084b086b41884f2a0ddd6e5e Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>bb10
parent
22c7a1fd9b
commit
08345c5dac
|
|
@ -40,24 +40,25 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "qfbcursor_p.h"
|
||||
#include "qfbscreen_p.h"
|
||||
#include <QtGui/QPainter>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QFbCursor::QFbCursor(QPlatformScreen *scr)
|
||||
: screen(scr), currentRect(QRect()), prevRect(QRect())
|
||||
QFbCursor::QFbCursor(QFbScreen *screen)
|
||||
: mScreen(screen), mCurrentRect(QRect()), mPrevRect(QRect())
|
||||
{
|
||||
graphic = new QPlatformCursorImage(0, 0, 0, 0, 0, 0);
|
||||
mGraphic = new QPlatformCursorImage(0, 0, 0, 0, 0, 0);
|
||||
setCursor(Qt::ArrowCursor);
|
||||
}
|
||||
|
||||
QRect QFbCursor::getCurrentRect()
|
||||
{
|
||||
QRect rect = graphic->image()->rect().translated(-graphic->hotspot().x(),
|
||||
-graphic->hotspot().y());
|
||||
QRect rect = mGraphic->image()->rect().translated(-mGraphic->hotspot().x(),
|
||||
-mGraphic->hotspot().y());
|
||||
rect.translate(QCursor::pos());
|
||||
QPoint screenOffset = screen->geometry().topLeft();
|
||||
rect.translate(-screenOffset); // global to local translation
|
||||
QPoint mScreenOffset = mScreen->geometry().topLeft();
|
||||
rect.translate(-mScreenOffset); // global to local translation
|
||||
return rect;
|
||||
}
|
||||
|
||||
|
|
@ -65,54 +66,54 @@ QRect QFbCursor::getCurrentRect()
|
|||
void QFbCursor::pointerEvent(const QMouseEvent & e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
QPoint screenOffset = screen->geometry().topLeft();
|
||||
currentRect = getCurrentRect();
|
||||
QPoint mScreenOffset = mScreen->geometry().topLeft();
|
||||
mCurrentRect = getCurrentRect();
|
||||
// global to local translation
|
||||
if (onScreen || screen->geometry().intersects(currentRect.translated(screenOffset))) {
|
||||
if (mOnScreen || mScreen->geometry().intersects(mCurrentRect.translated(mScreenOffset))) {
|
||||
setDirty();
|
||||
}
|
||||
}
|
||||
|
||||
QRect QFbCursor::drawCursor(QPainter & painter)
|
||||
{
|
||||
dirty = false;
|
||||
if (currentRect.isNull())
|
||||
mDirty = false;
|
||||
if (mCurrentRect.isNull())
|
||||
return QRect();
|
||||
|
||||
// We need this because the cursor might be dirty due to moving off screen
|
||||
QPoint screenOffset = screen->geometry().topLeft();
|
||||
// We need this because the cursor might be mDirty due to moving off mScreen
|
||||
QPoint mScreenOffset = mScreen->geometry().topLeft();
|
||||
// global to local translation
|
||||
if (!currentRect.translated(screenOffset).intersects(screen->geometry()))
|
||||
if (!mCurrentRect.translated(mScreenOffset).intersects(mScreen->geometry()))
|
||||
return QRect();
|
||||
|
||||
prevRect = currentRect;
|
||||
painter.drawImage(prevRect, *graphic->image());
|
||||
onScreen = true;
|
||||
return prevRect;
|
||||
mPrevRect = mCurrentRect;
|
||||
painter.drawImage(mPrevRect, *mGraphic->image());
|
||||
mOnScreen = true;
|
||||
return mPrevRect;
|
||||
}
|
||||
|
||||
QRect QFbCursor::dirtyRect()
|
||||
{
|
||||
if (onScreen) {
|
||||
onScreen = false;
|
||||
return prevRect;
|
||||
if (mOnScreen) {
|
||||
mOnScreen = false;
|
||||
return mPrevRect;
|
||||
}
|
||||
return QRect();
|
||||
}
|
||||
|
||||
void QFbCursor::setCursor(Qt::CursorShape shape)
|
||||
{
|
||||
graphic->set(shape);
|
||||
mGraphic->set(shape);
|
||||
}
|
||||
|
||||
void QFbCursor::setCursor(const QImage &image, int hotx, int hoty)
|
||||
{
|
||||
graphic->set(image, hotx, hoty);
|
||||
mGraphic->set(image, hotx, hoty);
|
||||
}
|
||||
|
||||
void QFbCursor::setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY)
|
||||
{
|
||||
graphic->set(data, mask, width, height, hotX, hotY);
|
||||
mGraphic->set(data, mask, width, height, hotX, hotY);
|
||||
}
|
||||
|
||||
void QFbCursor::changeCursor(QCursor * widgetCursor, QWindow *window)
|
||||
|
|
@ -128,9 +129,9 @@ void QFbCursor::changeCursor(QCursor * widgetCursor, QWindow *window)
|
|||
// system cursor
|
||||
setCursor(shape);
|
||||
}
|
||||
currentRect = getCurrentRect();
|
||||
QPoint screenOffset = screen->geometry().topLeft(); // global to local translation
|
||||
if (onScreen || screen->geometry().intersects(currentRect.translated(screenOffset)))
|
||||
mCurrentRect = getCurrentRect();
|
||||
QPoint mScreenOffset = mScreen->geometry().topLeft(); // global to local translation
|
||||
if (mOnScreen || mScreen->geometry().intersects(mCurrentRect.translated(mScreenOffset)))
|
||||
setDirty();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,38 +46,38 @@
|
|||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QFbScreen;
|
||||
|
||||
class QFbCursor : public QPlatformCursor
|
||||
{
|
||||
public:
|
||||
QFbCursor(QPlatformScreen * scr);
|
||||
QFbCursor(QFbScreen *screen);
|
||||
|
||||
// output methods
|
||||
QRect dirtyRect();
|
||||
virtual QRect drawCursor(QPainter & painter);
|
||||
virtual QRect drawCursor(QPainter &painter);
|
||||
|
||||
// input methods
|
||||
virtual void pointerEvent(const QMouseEvent & event);
|
||||
virtual void changeCursor(QCursor * widgetCursor, QWindow *window);
|
||||
virtual void pointerEvent(const QMouseEvent &event);
|
||||
virtual void changeCursor(QCursor *widgetCursor, QWindow *window);
|
||||
|
||||
virtual void setDirty() { dirty = true; /* screen->setDirty(QRect()); */ }
|
||||
virtual bool isDirty() { return dirty; }
|
||||
virtual bool isOnScreen() { return onScreen; }
|
||||
virtual QRect lastPainted() { return prevRect; }
|
||||
|
||||
protected:
|
||||
QPlatformCursorImage *graphic;
|
||||
virtual void setDirty() { mDirty = true; /* screen->setDirty(QRect()); */ }
|
||||
virtual bool isDirty() const { return mDirty; }
|
||||
virtual bool isOnScreen() const { return mOnScreen; }
|
||||
virtual QRect lastPainted() const { return mPrevRect; }
|
||||
|
||||
private:
|
||||
void setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY);
|
||||
void setCursor(Qt::CursorShape shape);
|
||||
void setCursor(const QImage &image, int hotx, int hoty);
|
||||
|
||||
QPlatformScreen *screen;
|
||||
QRect currentRect; // next place to draw the cursor
|
||||
QRect prevRect; // last place the cursor was drawn
|
||||
QRect getCurrentRect();
|
||||
bool dirty;
|
||||
bool onScreen;
|
||||
|
||||
QFbScreen *mScreen;
|
||||
QRect mCurrentRect; // next place to draw the cursor
|
||||
QRect mPrevRect; // last place the cursor was drawn
|
||||
bool mDirty;
|
||||
bool mOnScreen;
|
||||
QPlatformCursorImage *mGraphic;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
Loading…
Reference in New Issue