

Definition at line 50 of file skin.cpp.
Public Member Functions | |
| CursorWindow (const QString &fn, QPoint hot, QWidget *sk) | |
| void | setView (QVFbView *) |
| void | setPos (QPoint) |
| bool | handleMouseEvent (QEvent *ev) |
Protected Member Functions | |
| bool | event (QEvent *) |
| bool | eventFilter (QObject *, QEvent *) |
Private Attributes | |
| QWidget * | mouseRecipient |
| QVFbView * | view |
| QWidget * | skin |
| QPoint | hotspot |
Definition at line 689 of file skin.cpp.
References QWidget::backgroundRole(), Qt::BlankCursor, QImage::createAlphaMask(), QImage::createHeuristicMask(), Qt::FramelessWindowHint, QPixmap::fromImage(), QImage::hasAlphaChannel(), mouseRecipient, p, QWidget::palette(), QPalette::setBrush(), QWidget::setCursor(), QWidget::setFixedSize(), QWidget::setMask(), QWidget::setMouseTracking(), QWidget::setPalette(), and QWidget::setWindowFlags().
00690 :QWidget(0), 00691 view(0), skin(sk), 00692 hotspot(hot) 00693 { 00694 setWindowFlags( Qt::FramelessWindowHint ); 00695 mouseRecipient = 0; 00696 setMouseTracking(true); 00697 setCursor(Qt::BlankCursor); 00698 QImage img( fn ); 00699 QPixmap p; 00700 p = QPixmap::fromImage( img ); 00701 if ( !p.mask() ) 00702 if ( img.hasAlphaChannel() ) { 00703 QBitmap bm; 00704 bm = QPixmap::fromImage(img.createAlphaMask()); 00705 p.setMask( bm ); 00706 } else { 00707 QBitmap bm; 00708 bm = QPixmap::fromImage(img.createHeuristicMask()); 00709 p.setMask( bm ); 00710 } 00711 QPalette palette; 00712 palette.setBrush(backgroundRole(), QBrush(p)); 00713 setPalette(palette); 00714 setFixedSize( p.size() ); 00715 if ( !p.mask().isNull() ) 00716 setMask( p.mask() ); 00717 }
Here is the call graph for this function:

| void CursorWindow::setView | ( | QVFbView * | ) |
Definition at line 677 of file skin.cpp.
References QObject::installEventFilter(), mouseRecipient, QObject::removeEventFilter(), and view.
Referenced by Skin::loadImages(), and Skin::setView().
00678 { 00679 if ( view ) { 00680 view->removeEventFilter(this); 00681 view->removeEventFilter(this); 00682 } 00683 view = v; 00684 view->installEventFilter(this); 00685 view->installEventFilter(this); 00686 mouseRecipient = 0; 00687 }
Here is the call graph for this function:

| void CursorWindow::setPos | ( | QPoint | ) |
Definition at line 719 of file skin.cpp.
References hotspot, QWidget::move(), p, QWidget::raise(), and QWidget::show().
Referenced by handleMouseEvent(), and Skin::mouseMoveEvent().
Here is the call graph for this function:

| bool CursorWindow::handleMouseEvent | ( | QEvent * | ev | ) |
Definition at line 638 of file skin.cpp.
References QRect::contains(), QWidget::geometry(), QWidget::hide(), QWidget::mapFromGlobal(), QEvent::MouseButtonDblClick, QEvent::MouseButtonPress, QEvent::MouseButtonRelease, QEvent::MouseMove, mouseRecipient, QWidget::parentWidget(), QWidget::rect(), QCoreApplication::sendEvent(), setPos(), skin, QEvent::type(), and view.
Referenced by event(), and eventFilter().
00639 { 00640 bool handledEvent = false; 00641 static int inhere=0; 00642 if ( !inhere ) { 00643 inhere++; 00644 if ( view ) { 00645 if ( ev->type() >= QEvent::MouseButtonPress && ev->type() <= QEvent::MouseMove ) { 00646 QMouseEvent *e = (QMouseEvent*)ev; 00647 QPoint gp = e->globalPos(); 00648 QPoint vp = view->mapFromGlobal(gp); 00649 QPoint sp = skin->mapFromGlobal(gp); 00650 if ( e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonDblClick ) { 00651 if ( view->rect().contains(vp) ) 00652 mouseRecipient = view; 00653 else if ( skin->parentWidget()->geometry().contains(gp) ) 00654 mouseRecipient = skin; 00655 else 00656 mouseRecipient = 0; 00657 } 00658 if ( mouseRecipient ) { 00659 setPos(gp); 00660 QMouseEvent me(e->type(),mouseRecipient==skin ? sp : vp,gp,e->button(),e->buttons(),e->modifiers()); 00661 QApplication::sendEvent(mouseRecipient, &me); 00662 } else if ( !skin->parentWidget()->geometry().contains(gp) ) { 00663 hide(); 00664 } else { 00665 setPos(gp); 00666 } 00667 if ( e->type() == QEvent::MouseButtonRelease ) 00668 mouseRecipient = 0; 00669 handledEvent = true; 00670 } 00671 } 00672 inhere--; 00673 } 00674 return handledEvent; 00675 }
Here is the call graph for this function:

| bool CursorWindow::event | ( | QEvent * | ev | ) | [protected, virtual] |
This is the main event handler; it handles event event. You can reimplement this function in a subclass, but we recommend using one of the specialized event handlers instead.
Key press and release events are treated differently from other events. event() checks for Tab and Shift+Tab and tries to move the focus appropriately. If there is no widget to move the focus to (or the key press is not Tab or Shift+Tab), event() calls keyPressEvent().
Mouse and tablet event handling is also slightly special: only when the widget is enabled, event() will call the specialized handlers such as mousePressEvent(); otherwise it will discard the event.
This function returns true if the event was recognized, otherwise it returns false. If the recognized event was accepted (see QEvent::accepted), any further processing such as event propagation to the parent widget stops.
Reimplemented from QWidget.
Definition at line 631 of file skin.cpp.
References QWidget::event(), and handleMouseEvent().
00632 { 00633 if (handleMouseEvent(ev)) 00634 return true; 00635 return QWidget::event(ev); 00636 }
Here is the call graph for this function:

Filters events if this object has been installed as an event filter for the watched object.
In your reimplementation of this function, if you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.
Example:
class MainWindow : public QMainWindow { public: MainWindow(); protected: bool eventFilter(QObject *obj, QEvent *ev); private: QTextEdit *textEdit; }; MainWindow::MainWindow() { textEdit = new QTextEdit; setCentralWidget(textEdit); textEdit->installEventFilter(this); } bool MainWindow::eventFilter(QObject *obj, QEvent *event) { if (obj == textEdit) { if (event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event); qDebug() << "Ate key press" << keyEvent->key(); return true; } else { return false; } } else { // pass the event on to the parent class return QMainWindow::eventFilter(obj, event); } }
Notice in the example above that unhandled events are passed to the base class's eventFilter() function, since the base class might have reimplemented eventFilter() for its own internal purposes.
Reimplemented from QObject.
Definition at line 625 of file skin.cpp.
References handleMouseEvent().
00626 { 00627 handleMouseEvent(ev); 00628 return false; 00629 }
Here is the call graph for this function:

QWidget* CursorWindow::mouseRecipient [private] |
Definition at line 64 of file skin.cpp.
Referenced by CursorWindow(), handleMouseEvent(), and setView().
QVFbView* CursorWindow::view [private] |
QWidget* CursorWindow::skin [private] |
QPoint CursorWindow::hotspot [private] |
1.5.1