QVFbView Class Reference

#include <qvfbview.h>

Inheritance diagram for QVFbView:

Inheritance graph
[legend]
Collaboration diagram for QVFbView:

Collaboration graph
[legend]
List of all members.

Detailed Description

Definition at line 40 of file qvfbview.h.

Public Types

enum  Rotation

Public Slots

void setTouchscreenEmulation (bool)
void setLcdScreenEmulation (bool)
void setZoom (double, double)
void startAnimation (const QString &)
void stopAnimation ()

Public Member Functions

 QVFbView (int id, int w, int h, int d, Rotation r, QWidget *parent=0)
virtual ~QVFbView ()
int displayId () const
int displayWidth () const
int displayHeight () const
int displayDepth () const
Rotation displayRotation () const
bool touchScreenEmulation () const
bool lcdScreenEmulation () const
int rate ()
bool animating () const
QImage image () const
void setGamma (double gr, double gg, double gb)
double gammaRed () const
double gammaGreen () const
double gammaBlue () const
void getGamma (int i, QRgb &rgb)
void skinKeyPressEvent (int code, const QString &text, bool autorep=FALSE)
void skinKeyReleaseEvent (int code, const QString &text, bool autorep=FALSE)
void skinMouseEvent (QMouseEvent *e)
double zoomH () const
double zoomV () const
QSize sizeHint () const
void setRate (int)

Protected Slots

void refreshDisplay (const QRect &)

Protected Member Functions

QImage getBuffer (const QRect &r, int &leading) const
void drawScreen ()
void sendMouseData (const QPoint &pos, int buttons, int wheel)
void sendKeyboardData (QString unicode, int keycode, int modifiers, bool press, bool repeat)
virtual void paintEvent (QPaintEvent *pe)
virtual void contextMenuEvent (QContextMenuEvent *e)
virtual void mousePressEvent (QMouseEvent *e)
virtual void mouseDoubleClickEvent (QMouseEvent *e)
virtual void mouseReleaseEvent (QMouseEvent *e)
virtual void mouseMoveEvent (QMouseEvent *e)
virtual void wheelEvent (QWheelEvent *e)
virtual void keyPressEvent (QKeyEvent *e)
virtual void keyReleaseEvent (QKeyEvent *e)

Private Member Functions

void setDirty (const QRect &)

Private Attributes

int viewdepth
int rsh
int gsh
int bsh
int rmax
int gmax
int bmax
int contentsWidth
int contentsHeight
double gred
double ggreen
double gblue
QRgbgammatable
int refreshRate
QAnimationWriteranimation
double hzm
double vzm
QVFbViewProtocolmView
bool emulateTouchscreen
bool emulateLcdScreen
Rotation rotation


Member Enumeration Documentation

enum QVFbView::Rotation

Definition at line 49 of file qvfbview.h.

00049 { Rot0, Rot90, Rot180, Rot270 };


Constructor & Destructor Documentation

QVFbView::QVFbView ( int  id,
int  w,
int  h,
int  d,
Rotation  r,
QWidget parent = 0 
)

Definition at line 53 of file qvfbview.cpp.

References qvfb_protocol, SIGNAL, SLOT, Qt::StrongFocus, Qt::WA_NoSystemBackground, and Qt::WA_PaintOnScreen.

00055     : QGLWidget( parent ),
00056 #else
00057     : QWidget( parent ),
00058 #endif
00059     viewdepth(d), rsh(0), gsh(0), bsh(0), rmax(15), gmax(15), bmax(15),
00060     contentsWidth(w), contentsHeight(h), gred(1.0), ggreen(1.0), gblue(1.0),
00061     gammatable(0), refreshRate(30), animation(0),
00062     hzm(1.0), vzm(1.0), mView(0),
00063     emulateTouchscreen(false), emulateLcdScreen(false), rotation(r)
00064 {
00065     int _w = ( rotation & 0x1 ) ? h : w;
00066     int _h = ( rotation & 0x1 ) ? w : h;
00067 
00068     switch(qvfb_protocol) {
00069         default:
00070         case 0:
00071             mView = new QShMemViewProtocol(id, QSize(_w, _h), d, this);
00072             break;
00073         case 1:
00074             mView = new QMMapViewProtocol(id, QSize(_w, _h), d, this);
00075             break;
00076     }
00077 
00078     connect(mView, SIGNAL(displayDataChanged(const QRect &)),
00079             SLOT(refreshDisplay(const QRect &)));
00080 
00081     setAttribute(Qt::WA_PaintOnScreen, true);
00082     setMouseTracking( true );
00083     setFocusPolicy( Qt::StrongFocus );
00084     setAttribute( Qt::WA_NoSystemBackground );
00085 
00086     resize( contentsWidth, contentsHeight );
00087 
00088     setGamma(1.0,1.0,1.0);
00089     mView->setRate( 30 );
00090 }

QVFbView::~QVFbView (  )  [virtual]

Definition at line 92 of file qvfbview.cpp.

References sendKeyboardData(), and stopAnimation().

00093 {
00094     stopAnimation();
00095     sendKeyboardData( 0, 0, 0, true, false ); // magic die key
00096 }

Here is the call graph for this function:


Member Function Documentation

int QVFbView::displayId (  )  const

Definition at line 176 of file qvfbview.cpp.

References QVFbViewProtocol::id(), and mView.

Referenced by QVFb::configure(), QVFb::init(), and Skin::setupDefaultButtons().

00177 {
00178     return mView->id();
00179 }

Here is the call graph for this function:

int QVFbView::displayWidth (  )  const

Definition at line 181 of file qvfbview.cpp.

References QVFbViewProtocol::height(), mView, rotation, QVFbViewProtocol::width(), and x01.

Referenced by QVFb::configure(), QVFb::init(), sendMouseData(), QVFb::setZoom(), setZoom(), and QVFb::sizeHint().

00182 {
00183     return ( (int)rotation & 0x01 ) ? mView->height() : mView->width();
00184 }

Here is the call graph for this function:

int QVFbView::displayHeight (  )  const

Definition at line 186 of file qvfbview.cpp.

References QVFbViewProtocol::height(), mView, rotation, QVFbViewProtocol::width(), and x01.

Referenced by QVFb::configure(), QVFb::init(), sendMouseData(), QVFb::setZoom(), setZoom(), and QVFb::sizeHint().

00187 {
00188     return ( (int)rotation & 0x01 ) ? mView->width(): mView->height();
00189 }

Here is the call graph for this function:

int QVFbView::displayDepth (  )  const

Definition at line 191 of file qvfbview.cpp.

References viewdepth.

Referenced by QVFb::configure().

00192 {
00193     return viewdepth;
00194 }

QVFbView::Rotation QVFbView::displayRotation (  )  const

Definition at line 196 of file qvfbview.cpp.

References rotation.

Referenced by QVFb::configure().

00197 {
00198     return rotation;
00199 }

bool QVFbView::touchScreenEmulation (  )  const [inline]

Definition at line 59 of file qvfbview.h.

References emulateTouchscreen.

Referenced by QVFb::configure().

00059 { return emulateTouchscreen; }

bool QVFbView::lcdScreenEmulation (  )  const [inline]

Definition at line 60 of file qvfbview.h.

References emulateLcdScreen.

Referenced by QVFb::configure().

00060 { return emulateLcdScreen; }

int QVFbView::rate (  )  [inline]

Definition at line 61 of file qvfbview.h.

References refreshRate.

00061 { return refreshRate; }

bool QVFbView::animating (  )  const [inline]

Definition at line 62 of file qvfbview.h.

References animation.

00062 { return !!animation; }

QImage QVFbView::image (  )  const

Definition at line 587 of file qvfbview.cpp.

References QImage::copy(), getBuffer(), QVFbViewProtocol::height(), l, mView, and QVFbViewProtocol::width().

Referenced by QVFb::saveImage(), AnimationSaveWidget::timerEvent(), and AnimationSaveWidget::toggleRecord().

00588 {
00589     int l;
00590     QImage r = getBuffer( QRect(0, 0, mView->width(), mView->height()), l ).copy();
00591     return r;
00592 }

Here is the call graph for this function:

void QVFbView::setGamma ( double  gr,
double  gg,
double  gb 
)

Definition at line 108 of file qvfbview.cpp.

References b, bmax, bsh, QVFbViewProtocol::flushChanges(), g, gammatable, gblue, ggreen, gmax, gred, gsh, i, int, mView, qMax(), qRgb(), QRgb, rmax, rsh, and viewdepth.

Referenced by QVFb::configure(), QVFb::setB400(), QVFb::setG400(), QVFb::setGamma400(), and QVFb::setR400().

00109 {
00110     if ( viewdepth < 12 )
00111   return; // not implemented
00112 
00113     gred=gr; ggreen=gg; gblue=gb;
00114 
00115     switch ( viewdepth ) {
00116       case 12:
00117   rsh = 12;
00118   gsh = 7;
00119   bsh = 1;
00120   rmax = 15;
00121   gmax = 15;
00122   bmax = 15;
00123   break;
00124       case 16:
00125   rsh = 11;
00126   gsh = 5;
00127   bsh = 0;
00128   rmax = 31;
00129   gmax = 63;
00130   bmax = 31;
00131   break;
00132       case 18:
00133         rsh = 12;
00134         gsh = 6;
00135         bsh = 0;
00136         rmax = 63;
00137         gmax = 63;
00138         bmax = 63;
00139         break;
00140       case 24:
00141       case 32:
00142   rsh = 16;
00143   gsh = 8;
00144   bsh = 0;
00145   rmax = 255;
00146   gmax = 255;
00147   bmax = 255;
00148     }
00149     int mm = qMax(rmax,qMax(gmax,bmax))+1;
00150     if ( gammatable )
00151   delete [] gammatable;
00152     gammatable = new QRgb[mm];
00153     for (int i=0; i<mm; i++) {
00154   int r = int(pow(i,gr)*255/rmax);
00155   int g = int(pow(i,gg)*255/gmax);
00156   int b = int(pow(i,gb)*255/bmax);
00157   if ( r > 255 ) r = 255;
00158   if ( g > 255 ) g = 255;
00159   if ( b > 255 ) b = 255;
00160   gammatable[i] = qRgb(r,g,b);
00161 //qDebug("%d: %d,%d,%d",i,r,g,b);
00162     }
00163 
00164     mView->flushChanges();
00165 }

Here is the call graph for this function:

double QVFbView::gammaRed (  )  const [inline]

Definition at line 66 of file qvfbview.h.

References gred.

Referenced by QVFb::configure(), QVFb::setB400(), QVFb::setG400(), and QVFb::updateGammaLabels().

00066 { return gred; }

double QVFbView::gammaGreen (  )  const [inline]

Definition at line 67 of file qvfbview.h.

References ggreen.

Referenced by QVFb::configure(), QVFb::setB400(), QVFb::setR400(), and QVFb::updateGammaLabels().

00067 { return ggreen; }

double QVFbView::gammaBlue (  )  const [inline]

Definition at line 68 of file qvfbview.h.

References gblue.

Referenced by QVFb::configure(), QVFb::setG400(), QVFb::setR400(), and QVFb::updateGammaLabels().

00068 { return gblue; }

void QVFbView::getGamma ( int  i,
QRgb rgb 
)

Definition at line 167 of file qvfbview.cpp.

References gammatable, qBlue(), qGreen(), qRed(), qRgb(), and rmax.

00168 {
00169     if ( i > 255 ) i = 255;
00170     if ( i < 0 ) i = 0;
00171     rgb = qRgb(qRed(gammatable[i*rmax/255]),
00172                qGreen(gammatable[i*rmax/255]),
00173                qBlue(gammatable[i*rmax/255]));
00174 }

Here is the call graph for this function:

void QVFbView::skinKeyPressEvent ( int  code,
const QString text,
bool  autorep = FALSE 
)

Definition at line 610 of file qvfbview.cpp.

References QEvent::KeyPress, and keyPressEvent().

Referenced by Skin::flip(), Skin::skinKeyRepeat(), and Skin::startPress().

00611 {
00612     QKeyEvent e(QEvent::KeyPress,code,0,text,autorep);
00613     keyPressEvent(&e);
00614 }

Here is the call graph for this function:

void QVFbView::skinKeyReleaseEvent ( int  code,
const QString text,
bool  autorep = FALSE 
)

Definition at line 616 of file qvfbview.cpp.

References QEvent::KeyRelease, and keyReleaseEvent().

Referenced by Skin::endPress(), Skin::flip(), and Skin::skinKeyRepeat().

00617 {
00618     QKeyEvent e(QEvent::KeyRelease,code,0,text,autorep);
00619     keyReleaseEvent(&e);
00620 }

Here is the call graph for this function:

void QVFbView::skinMouseEvent ( QMouseEvent e  ) 

Definition at line 544 of file qvfbview.cpp.

References QMouseEvent::buttons(), hzm, sendMouseData(), vzm, QMouseEvent::x(), and QMouseEvent::y().

00545 {
00546     sendMouseData( QPoint(int(e->x()/hzm),int(e->y()/vzm)), e->buttons(), 0 );
00547 }

Here is the call graph for this function:

double QVFbView::zoomH (  )  const [inline]

Definition at line 74 of file qvfbview.h.

References hzm.

Referenced by QVFb::sizeHint().

00074 { return hzm; }

double QVFbView::zoomV (  )  const [inline]

Definition at line 75 of file qvfbview.h.

References vzm.

Referenced by QVFb::sizeHint().

00075 { return vzm; }

QSize QVFbView::sizeHint (  )  const [virtual]

Reimplemented from QWidget.

Definition at line 98 of file qvfbview.cpp.

References contentsHeight, and contentsWidth.

Referenced by QVFb::init().

00099 {
00100     return QSize(contentsWidth, contentsHeight);
00101 }

void QVFbView::setRate ( int   ) 

Definition at line 103 of file qvfbview.cpp.

References mView, and QVFbViewProtocol::setRate().

Referenced by QVFb::init(), and QVFb::setRate().

00104 {
00105     mView->setRate(i);
00106 }

Here is the call graph for this function:

void QVFbView::setTouchscreenEmulation ( bool   )  [slot]

Definition at line 562 of file qvfbview.cpp.

References emulateTouchscreen.

Referenced by QVFb::configure().

00563 {
00564     emulateTouchscreen = b;
00565 }

void QVFbView::setLcdScreenEmulation ( bool   )  [slot]

Definition at line 567 of file qvfbview.cpp.

References emulateLcdScreen.

Referenced by QVFb::configure().

00568 {
00569     emulateLcdScreen = b;
00570 }

void QVFbView::setZoom ( double  ,
double   
) [slot]

Definition at line 201 of file qvfbview.cpp.

References QWidget::adjustSize(), contentsHeight, contentsWidth, displayHeight(), displayWidth(), QVFbViewProtocol::flushChanges(), hzm, int, mView, qApp, QWidget::resize(), QWidget::topLevelWidget(), QWidget::update(), QWidget::updateGeometry(), and vzm.

Referenced by QVFb::setZoom().

00202 {
00203     if ( hzm != hz || vzm != vz ) {
00204   hzm = hz;
00205   vzm = vz;
00206         mView->flushChanges();
00207 
00208         contentsWidth = int(displayWidth()*hz);
00209         contentsHeight = int(displayHeight()*vz);
00210         resize(contentsWidth, contentsHeight);
00211 
00212   updateGeometry();
00213   qApp->sendPostedEvents();
00214   topLevelWidget()->adjustSize();
00215   update();
00216     }
00217 }

void QVFbView::startAnimation ( const QString  )  [slot]

Definition at line 594 of file qvfbview.cpp.

References animation, QAnimationWriter::appendFrame(), QVFbViewProtocol::data(), QImage::Format_RGB32, QVFbViewProtocol::height(), mView, refreshRate, QAnimationWriter::setFrameRate(), and QVFbViewProtocol::width().

00595 {
00596     delete animation;
00597     animation = new QAnimationWriter(filename,"MNG");
00598     animation->setFrameRate(refreshRate);
00599     animation->appendFrame(QImage(mView->data(),
00600                 mView->width(), mView->height(), QImage::Format_RGB32));
00601 }

void QVFbView::stopAnimation (  )  [slot]

Definition at line 603 of file qvfbview.cpp.

References animation.

Referenced by ~QVFbView().

00604 {
00605     delete animation;
00606     animation = 0;
00607 }

void QVFbView::refreshDisplay ( const QRect  )  [protected, slot]

Definition at line 258 of file qvfbview.cpp.

References animation, QAnimationWriter::appendBlankFrame(), QAnimationWriter::appendFrame(), getBuffer(), QRect::isEmpty(), QRect::isNull(), l, QWidget::repaint(), QRect::x(), and QRect::y().

00259 {
00260     if ( animation ) {
00261       if ( r.isEmpty() ) {
00262     animation->appendBlankFrame();
00263       } else {
00264     int l;
00265     QImage img = getBuffer( r, l );
00266     animation->appendFrame(img,QPoint(r.x(),r.y()));
00267       }
00268     }
00269     if ( !r.isNull() )
00270   repaint();
00271 }

QImage QVFbView::getBuffer ( const QRect r,
int &  leading 
) const [protected]

Definition at line 273 of file qvfbview.cpp.

References b, bmax, bsh, buffer, QVFbViewProtocol::clut(), QVFbViewProtocol::data(), QImage::Format_Indexed8, QImage::Format_MonoLSB, QImage::Format_RGB32, gammatable, gmax, gsh, QVFbViewProtocol::height(), QRect::height(), QVFbViewProtocol::linestep(), mView, qBlue(), qGreen(), qRed(), qRgb(), QRgb, QRect::right(), rmax, row, rsh, s, viewdepth, QRect::width(), QVFbViewProtocol::width(), QRect::x(), and QRect::y().

Referenced by drawScreen(), image(), and refreshDisplay().

00274 {
00275     static QByteArray buffer;
00276 
00277     const int requiredSize = r.width() * r.height() * 4;
00278 
00279     switch ( viewdepth ) {
00280     case 12:
00281     case 16: {
00282         if (requiredSize > buffer.size())
00283             buffer.resize(requiredSize);
00284         uchar *b = reinterpret_cast<uchar*>(buffer.data());
00285   QImage img(b, r.width(), r.height(), QImage::Format_RGB32);
00286   const int rsh = viewdepth == 12 ? 12 : 11;
00287   const int gsh = viewdepth == 12 ? 7 : 5;
00288   const int bsh = viewdepth == 12 ? 1 : 0;
00289   const int rmax = viewdepth == 12 ? 15 : 31;
00290   const int gmax = viewdepth == 12 ? 15 : 63;
00291   const int bmax = viewdepth == 12 ? 15 : 31;
00292   for ( int row = 0; row < r.height(); row++ ) {
00293       QRgb *dptr = (QRgb*)img.scanLine( row );
00294       ushort *sptr = (ushort*)(mView->data() + (r.y()+row)*mView->linestep());
00295       sptr += r.x();
00296       for ( int col=0; col < r.width(); col++ ) {
00297     ushort s = *sptr++;
00298     *dptr++ = qRgb(qRed(gammatable[(s>>rsh)&rmax]),qGreen(gammatable[(s>>gsh)&gmax]),qBlue(gammatable[(s>>bsh)&bmax]));
00299     //*dptr++ = qRgb(((s>>rsh)&rmax)*255/rmax,((s>>gsh)&gmax)*255/gmax,((s>>bsh)&bmax)*255/bmax);
00300       }
00301   }
00302   leading = 0;
00303   return img;
00304     }
00305     case 4: {
00306         if (requiredSize > buffer.size())
00307             buffer.resize(requiredSize);
00308         uchar *b = reinterpret_cast<uchar*>(buffer.data());
00309   QImage img(b, r.width(), r.height(), QImage::Format_Indexed8);
00310         //img.setColorTable(mView->clut());
00311   for ( int row = 0; row < r.height(); row++ ) {
00312       unsigned char *dptr = img.scanLine( row );
00313       const unsigned char *sptr = mView->data() + (r.y()+row)*mView->linestep();
00314       sptr += r.x()/2;
00315       int col = 0;
00316       if ( r.x() & 1 ) {
00317     *dptr++ = *sptr++ >> 4;
00318     col++;
00319       }
00320       for ( ; col < r.width()-1; col+=2 ) {
00321     unsigned char s = *sptr++;
00322     *dptr++ = s & 0x0f;
00323     *dptr++ = s >> 4;
00324       }
00325       if ( !(r.right() & 1) )
00326     *dptr = *sptr & 0x0f;
00327   }
00328   leading = 0;
00329   return img;
00330     }
00331     case 18: {
00332          // packed into 24 bpp
00333         if (requiredSize > buffer.size())
00334             buffer.resize(requiredSize);
00335         uchar *b = reinterpret_cast<uchar*>(buffer.data());
00336   QImage img(b, r.width(), r.height(), QImage::Format_RGB32);
00337         const int rsh = 12;
00338         const int gsh = 6;
00339         const int bsh = 0;
00340         const int rmax = 63;
00341         const int gmax = 63;
00342         const int bmax = 63;
00343   for ( int row = 0; row < r.height(); row++ ) {
00344       QRgb *dptr = (QRgb*)img.scanLine( row );
00345             uchar *sptr = (uchar*)(mView->data() + (r.y()+row)*mView->linestep());
00346       sptr += r.x()*3;
00347       for ( int col=0; col < r.width(); col++ ) {
00348                 uint s = *(reinterpret_cast<uint*>(sptr));
00349                 s &= 0x00ffffff;
00350                 sptr += 3;
00351                 *dptr++ = qRgb(qRed(gammatable[(s>>rsh)&rmax]),qGreen(gammatable[(s>>gsh)&gmax]),qBlue(gammatable[(s>>bsh)&bmax]));
00352       }
00353   }
00354   leading = 0;
00355   return img;
00356      }
00357     case 24: {
00358         static unsigned char *imgData = 0;
00359         if (!imgData) {
00360             int bpl = mView->width() *4;
00361             imgData = new unsigned char[bpl * mView->height()];
00362         }
00363         QImage img(imgData, r.width(), r.height(), QImage::Format_RGB32);
00364         for (int row = 0; row < r.height(); ++row) {
00365             uchar *dptr = img.scanLine(row);
00366             const uchar *sptr = mView->data() + (r.y() + row) * mView->linestep();
00367             sptr += r.x() * 3;
00368             for (int col = 0; col < r.width(); ++col) {
00369                 *dptr++ = *sptr++;
00370                 *dptr++ = *sptr++;
00371                 *dptr++ = *sptr++;
00372                 dptr++;
00373             }
00374         }
00375         leading = 0;
00376         return img;
00377     }
00378     case 32: {
00379   leading = r.x();
00380   return QImage( mView->data() + r.y() * mView->linestep(),
00381                        mView->width(), r.height(), QImage::Format_RGB32 );
00382     }
00383     case 8: {
00384         leading = r.x();
00385         QImage img( mView->data() + r.y() * mView->linestep(),
00386                     mView->width(), r.height(), QImage::Format_Indexed8 );
00387         img.setColorTable(mView->clut());
00388         return img;
00389     }
00390     case 1: {
00391   leading = r.x();
00392   return QImage( mView->data() + r.y() * mView->linestep(),
00393                        mView->width(), r.height(), QImage::Format_MonoLSB );
00394     }
00395     }
00396     return QImage();
00397 }

Here is the call graph for this function:

void QVFbView::drawScreen (  )  [protected]

Definition at line 410 of file qvfbview.cpp.

References Qt::black, emulateLcdScreen, findMultiple(), QImage::Format_RGB32, QPixmap::fromImage(), getBuffer(), QImage::height(), QPixmap::height(), QVFbViewProtocol::height(), hzm, Qt::IgnoreAspectRatio, int, m, mView, p, qBlue(), qGreen(), qRed(), qRgb(), QRgb, Rot0, Rot180, Rot270, Rot90, rotation, row, s, QImage::scaled(), QImage::scanLine(), Qt::SmoothTransformation, QPixmap::transformed(), vzm, Qt::white, QPixmap::width(), QVFbViewProtocol::width(), and QImage::width().

Referenced by paintEvent().

00411 {
00412     QPainter p( this );
00413 
00414     /* later just draw the update */
00415     QRect r(0, 0, mView->width(), mView->height() );
00416 
00417     if ( int(hzm) != hzm || int(vzm) != vzm ) {
00418         r.setLeft( findMultiple(r.left(),hzm,0,-1) );
00419         r.setTop( findMultiple(r.top(),vzm,0,-1) );
00420         int w = findMultiple(r.width(),hzm,mView->width(),1);
00421         int h = findMultiple(r.height(),vzm,mView->height(),1);
00422         r.setRight( r.left()+w-1 );
00423         r.setBottom( r.top()+h-1 );
00424     }
00425     int leading;
00426     QImage img( getBuffer( r, leading ) );
00427     QPixmap pm;
00428     if ( hzm == 1.0 && vzm == 1.0 ) {
00429         pm = QPixmap::fromImage( img );
00430     } else if ( emulateLcdScreen && hzm == 3.0 && vzm == 3.0 ) {
00431         QImage img2( img.width()*3, img.height(), QImage::Format_RGB32 );
00432         for ( int row = 0; row < img2.height(); row++ ) {
00433             QRgb *dptr = (QRgb*)img2.scanLine( row );
00434             QRgb *sptr = (QRgb*)img.scanLine( row );
00435             for ( int col = 0; col < img.width(); col++ ) {
00436                 QRgb s = *sptr++;
00437                 *dptr++ = qRgb(qRed(s),0,0);
00438                 *dptr++ = qRgb(0,qGreen(s),0);
00439                 *dptr++ = qRgb(0,0,qBlue(s));
00440             }
00441         }
00442         QMatrix m;
00443         m.scale(1.0, 3.0);
00444         pm = QPixmap::fromImage( img2 );
00445         pm = pm.transformed(m);
00446     } else if ( int(hzm) == hzm && int(vzm) == vzm ) {
00447         QMatrix m;
00448         m.scale(hzm,vzm);
00449         pm = QPixmap::fromImage( img );
00450         pm = pm.transformed(m);
00451     } else {
00452         pm = QPixmap::fromImage( img.scaled(int(img.width()*hzm),int(img.height()*vzm), Qt::IgnoreAspectRatio, Qt::SmoothTransformation) );
00453     }
00454 
00455     int x1 = r.x();
00456     int y1 = r.y();
00457     int leadingX = leading;
00458     int leadingY = 0;
00459 
00460     // Do the rotation thing
00461     int rotX1 = mView->width() - x1 - img.width();
00462     int rotY1 = mView->height() - y1 - img.height();
00463     int rotLeadingX = (leading) ? mView->width() - leadingX - img.width() : 0;
00464     int rotLeadingY = 0;
00465     switch ( rotation ) {
00466         case Rot0:
00467             break;
00468         case Rot90:
00469             leadingY = leadingX;
00470             leadingX = rotLeadingY;
00471             y1 = x1;
00472             x1 = rotY1;
00473             break;
00474         case Rot180:
00475             leadingX = rotLeadingX;
00476             leadingY = leadingY;
00477             x1 = rotX1;
00478             y1 = rotY1;
00479             break;
00480         case Rot270:
00481             leadingX = leadingY;
00482             leadingY = rotLeadingX;
00483             x1 = y1;
00484             y1 = rotX1;
00485             break;
00486         default:
00487             break;
00488     }
00489     x1 = int(x1*hzm);
00490     y1 = int(y1*vzm);
00491     leadingX = int(leadingX*hzm);
00492     leadingY = int(leadingY*vzm);
00493     if ( rotation != 0 ) {
00494         QMatrix m;
00495         m.rotate(rotation * 90.0);
00496         pm = pm.transformed(m);
00497     }
00498     p.setPen( Qt::black );
00499     p.setBrush( Qt::white );
00500     p.drawPixmap( x1, y1, pm, leadingX, leadingY, pm.width(), pm.height() );
00501 }

Here is the call graph for this function:

void QVFbView::sendMouseData ( const QPoint pos,
int  buttons,
int  wheel 
) [protected]

Definition at line 246 of file qvfbview.cpp.

References displayHeight(), displayWidth(), mapToDevice(), mView, p, QWidget::pos(), rotation, QVFbViewProtocol::sendMouseData(), and QRect::topLeft().

Referenced by mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), skinMouseEvent(), and wheelEvent().

00247 {
00248     QPoint p = mapToDevice( QRect(pos,QSize(1,1)), QSize(displayWidth(), displayHeight()), rotation ).topLeft();
00249     mView->sendMouseData(p, buttons, wheel);
00250 }

Here is the call graph for this function:

void QVFbView::sendKeyboardData ( QString  unicode,
int  keycode,
int  modifiers,
bool  press,
bool  repeat 
) [protected]

Definition at line 252 of file qvfbview.cpp.

References mView, and QVFbViewProtocol::sendKeyboardData().

Referenced by keyPressEvent(), keyReleaseEvent(), and ~QVFbView().

00254 {
00255     mView->sendKeyboardData(unicode, keycode, modifiers, press, repeat);
00256 }

Here is the call graph for this function:

void QVFbView::paintEvent ( QPaintEvent pe  )  [protected, virtual]

This event handler can be reimplemented in a subclass to receive paint events which are passed in the event parameter.

A paint event is a request to repaint all or part of the widget. It can happen as a result of repaint() or update(), or because the widget was obscured and has now been uncovered, or for many other reasons.

Many widgets can simply repaint their entire surface when asked to, but some slow widgets need to optimize by painting only the requested region: QPaintEvent::region(). This speed optimization does not change the result, as painting is clipped to that region during event processing. QListView and QTableView do this, for example.

Qt also tries to speed up painting by merging multiple paint events into one. When update() is called several times or the window system sends several paint events, Qt merges these events into one event with a larger region (see QRegion::united()). repaint() does not permit this optimization, so we suggest using update() whenever possible.

When the paint event occurs, the update region has normally been erased, so that you're painting on the widget's background.

The background can be set using setBackgroundRole() and setPalette().

From Qt 4.0, QWidget automatically double-buffers its painting, so there's no need to write double-buffering code in paintEvent() to avoid flicker.

Note: Under X11 it is possible to toggle the global double buffering by calling qt_x11_set_global_double_buffer(). Example usage:

See also:
event(), repaint(), update(), QPainter, QPixmap, QPaintEvent, {Analog Clock Example}

Reimplemented from QWidget.

Definition at line 512 of file qvfbview.cpp.

References drawScreen().

00513 {
00514     /*
00515     QRect r( pe->rect() );
00516     r = QRect(int(r.x()/hzm),int(r.y()/vzm),
00517       int(r.width()/hzm)+1,int(r.height()/vzm)+1);
00518 
00519     mView->flushChanges();
00520     */
00521     drawScreen();
00522 }

Here is the call graph for this function:

void QVFbView::contextMenuEvent ( QContextMenuEvent e  )  [protected, virtual]

This event handler, for event event, can be reimplemented in a subclass to receive widget context menu events.

The handler is called when the widget's contextMenuPolicy is Qt::DefaultContextMenu.

The default implementation ignores the context event. See the QContextMenuEvent documentation for more details.

See also:
event(), QContextMenuEvent customContextMenuRequested()

Reimplemented from QWidget.

Definition at line 529 of file qvfbview.cpp.

00530 {
00531 
00532 }

void QVFbView::mousePressEvent ( QMouseEvent e  )  [protected, virtual]

This event handler, for event event, can be reimplemented in a subclass to receive mouse press events for the widget.

If you create new widgets in the mousePressEvent() the mouseReleaseEvent() may not end up where you expect, depending on the underlying window system (or X11 window manager), the widgets' location and maybe more.

The default implementation implements the closing of popup widgets when you click outside the window. For other widget types it does nothing.

See also:
mouseReleaseEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), event(), QMouseEvent, {Scribble Example}

Reimplemented from QWidget.

Definition at line 524 of file qvfbview.cpp.

References QMouseEvent::buttons(), hzm, sendMouseData(), vzm, QMouseEvent::x(), and QMouseEvent::y().

00525 {
00526     sendMouseData( QPoint(int(e->x()/hzm),int(e->y()/vzm)), e->buttons(), 0 );
00527 }

Here is the call graph for this function:

void QVFbView::mouseDoubleClickEvent ( QMouseEvent e  )  [protected, virtual]

This event handler, for event event, can be reimplemented in a subclass to receive mouse double click events for the widget.

The default implementation generates a normal mouse press event.

Note that the widgets gets a mousePressEvent() and a mouseReleaseEvent() before the mouseDoubleClickEvent().

See also:
mousePressEvent(), mouseReleaseEvent() mouseMoveEvent(), event(), QMouseEvent

Reimplemented from QWidget.

Definition at line 534 of file qvfbview.cpp.

References QMouseEvent::buttons(), hzm, sendMouseData(), vzm, QMouseEvent::x(), and QMouseEvent::y().

00535 {
00536     sendMouseData( QPoint(int(e->x()/hzm),int(e->y()/vzm)), e->buttons(), 0 );
00537 }

Here is the call graph for this function:

void QVFbView::mouseReleaseEvent ( QMouseEvent e  )  [protected, virtual]

This event handler, for event event, can be reimplemented in a subclass to receive mouse release events for the widget.

See also:
mousePressEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), event(), QMouseEvent, {Scribble Example}

Reimplemented from QWidget.

Definition at line 539 of file qvfbview.cpp.

References QMouseEvent::buttons(), hzm, sendMouseData(), vzm, QMouseEvent::x(), and QMouseEvent::y().

00540 {
00541     sendMouseData( QPoint(int(e->x()/hzm),int(e->y()/vzm)), e->buttons(), 0 );
00542 }

Here is the call graph for this function:

void QVFbView::mouseMoveEvent ( QMouseEvent e  )  [protected, virtual]

This event handler, for event event, can be reimplemented in a subclass to receive mouse move events for the widget.

If mouse tracking is switched off, mouse move events only occur if a mouse button is pressed while the mouse is being moved. If mouse tracking is switched on, mouse move events occur even if no mouse button is pressed.

QMouseEvent::pos() reports the position of the mouse cursor, relative to this widget. For press and release events, the position is usually the same as the position of the last mouse move event, but it might be different if the user's hand shakes. This is a feature of the underlying window system, not Qt.

See also:
setMouseTracking(), mousePressEvent(), mouseReleaseEvent(), mouseDoubleClickEvent(), event(), QMouseEvent, {Scribble Example}

Reimplemented from QWidget.

Definition at line 549 of file qvfbview.cpp.

References QMouseEvent::buttons(), emulateTouchscreen, hzm, Qt::MouseButtonMask, sendMouseData(), vzm, QMouseEvent::x(), and QMouseEvent::y().

00550 {
00551     if ( !emulateTouchscreen || (e->buttons() & Qt::MouseButtonMask ) )
00552   sendMouseData( QPoint(int(e->x()/hzm),int(e->y()/vzm)), e->buttons(), 0 );
00553 }

Here is the call graph for this function:

void QVFbView::wheelEvent ( QWheelEvent e  )  [protected, virtual]

This event handler, for event event, can be reimplemented in a subclass to receive wheel events for the widget.

If you reimplement this handler, it is very important that you ignore() the event if you do not handle it, so that the widget's parent can interpret it.

The default implementation ignores the event.

See also:
QWheelEvent::ignore(), QWheelEvent::accept(), event(), QWheelEvent

Reimplemented from QWidget.

Definition at line 555 of file qvfbview.cpp.

References QWheelEvent::buttons(), QWheelEvent::delta(), hzm, sendMouseData(), vzm, QWheelEvent::x(), and QWheelEvent::y().

00556 {
00557     if (!e)
00558         return;
00559     sendMouseData( QPoint(int(e->x()/hzm),int(e->y()/vzm)), e->buttons(), e->delta());
00560 }

Here is the call graph for this function:

void QVFbView::keyPressEvent ( QKeyEvent e  )  [protected, virtual]

This event handler, for event event, can be reimplemented in a subclass to receive key press events for the widget.

A widget must call setFocusPolicy() to accept focus initially and have focus in order to receive a key press event.

If you reimplement this handler, it is very important that you ignore() the event if you do not understand it, so that the widget's parent can interpret it.

The default implementation closes popup widgets if the user presses Esc. Otherwise the event is ignored.

See also:
keyReleaseEvent(), QKeyEvent::ignore(), setFocusPolicy(), focusInEvent(), focusOutEvent(), event(), QKeyEvent, {Tetrix Example}

Reimplemented from QWidget.

Definition at line 572 of file qvfbview.cpp.

References Qt::AltModifier, Qt::ControlModifier, QKeyEvent::isAutoRepeat(), QKeyEvent::key(), QKeyEvent::modifiers(), sendKeyboardData(), Qt::ShiftModifier, and QKeyEvent::text().

Referenced by skinKeyPressEvent().

00573 {
00574     sendKeyboardData(e->text(), e->key(),
00575          e->modifiers()&(Qt::ShiftModifier|Qt::ControlModifier|Qt::AltModifier),
00576          true, e->isAutoRepeat());
00577 }

Here is the call graph for this function:

void QVFbView::keyReleaseEvent ( QKeyEvent e  )  [protected, virtual]

This event handler, for event event, can be reimplemented in a subclass to receive key release events for the widget.

A widget must accept focus initially and have focus in order to receive a key release event.

If you reimplement this handler, it is very important that you ignore() the release if you do not understand it, so that the widget's parent can interpret it.

The default implementation ignores the event.

See also:
keyPressEvent(), QKeyEvent::ignore(), setFocusPolicy(), focusInEvent(), focusOutEvent(), event(), QKeyEvent

Reimplemented from QWidget.

Definition at line 579 of file qvfbview.cpp.

References Qt::AltModifier, Qt::ControlModifier, QKeyEvent::isAutoRepeat(), QKeyEvent::key(), QKeyEvent::modifiers(), sendKeyboardData(), Qt::ShiftModifier, and QKeyEvent::text().

Referenced by skinKeyReleaseEvent().

00580 {
00581     sendKeyboardData(e->text(), e->key(),
00582          e->modifiers()&(Qt::ShiftModifier|Qt::ControlModifier|Qt::AltModifier),
00583          false, e->isAutoRepeat());
00584 }

Here is the call graph for this function:

void QVFbView::setDirty ( const QRect  )  [private]


Member Data Documentation

int QVFbView::viewdepth [private]

Definition at line 109 of file qvfbview.h.

Referenced by displayDepth(), getBuffer(), and setGamma().

int QVFbView::rsh [private]

Definition at line 110 of file qvfbview.h.

Referenced by getBuffer(), and setGamma().

int QVFbView::gsh [private]

Definition at line 111 of file qvfbview.h.

Referenced by getBuffer(), and setGamma().

int QVFbView::bsh [private]

Definition at line 112 of file qvfbview.h.

Referenced by getBuffer(), and setGamma().

int QVFbView::rmax [private]

Definition at line 113 of file qvfbview.h.

Referenced by getBuffer(), getGamma(), and setGamma().

int QVFbView::gmax [private]

Definition at line 114 of file qvfbview.h.

Referenced by getBuffer(), and setGamma().

int QVFbView::bmax [private]

Definition at line 115 of file qvfbview.h.

Referenced by getBuffer(), and setGamma().

int QVFbView::contentsWidth [private]

Definition at line 116 of file qvfbview.h.

Referenced by setZoom(), and sizeHint().

int QVFbView::contentsHeight [private]

Definition at line 117 of file qvfbview.h.

Referenced by setZoom(), and sizeHint().

double QVFbView::gred [private]

Definition at line 118 of file qvfbview.h.

Referenced by gammaRed(), and setGamma().

double QVFbView::ggreen [private]

Definition at line 118 of file qvfbview.h.

Referenced by gammaGreen(), and setGamma().

double QVFbView::gblue [private]

Definition at line 118 of file qvfbview.h.

Referenced by gammaBlue(), and setGamma().

QRgb* QVFbView::gammatable [private]

Definition at line 119 of file qvfbview.h.

Referenced by getBuffer(), getGamma(), and setGamma().

int QVFbView::refreshRate [private]

Definition at line 121 of file qvfbview.h.

Referenced by rate(), and startAnimation().

QAnimationWriter* QVFbView::animation [private]

Definition at line 122 of file qvfbview.h.

Referenced by animating(), refreshDisplay(), startAnimation(), and stopAnimation().

double QVFbView::hzm [private]

Definition at line 123 of file qvfbview.h.

Referenced by drawScreen(), mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), setZoom(), skinMouseEvent(), wheelEvent(), and zoomH().

double QVFbView::vzm [private]

Definition at line 123 of file qvfbview.h.

Referenced by drawScreen(), mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), setZoom(), skinMouseEvent(), wheelEvent(), and zoomV().

QVFbViewProtocol* QVFbView::mView [private]

Definition at line 124 of file qvfbview.h.

Referenced by displayHeight(), displayId(), displayWidth(), drawScreen(), getBuffer(), image(), sendKeyboardData(), sendMouseData(), setGamma(), setRate(), setZoom(), and startAnimation().

bool QVFbView::emulateTouchscreen [private]

Definition at line 125 of file qvfbview.h.

Referenced by mouseMoveEvent(), setTouchscreenEmulation(), and touchScreenEmulation().

bool QVFbView::emulateLcdScreen [private]

Definition at line 126 of file qvfbview.h.

Referenced by drawScreen(), lcdScreenEmulation(), and setLcdScreenEmulation().

Rotation QVFbView::rotation [private]

Definition at line 127 of file qvfbview.h.

Referenced by displayHeight(), displayRotation(), displayWidth(), drawScreen(), and sendMouseData().


The documentation for this class was generated from the following files:
Generated on Thu Mar 15 19:46:23 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1