

Definition at line 57 of file qeffects.cpp.
Public Member Functions | |
| QAlphaWidget (QWidget *w, Qt::WindowFlags f=0) | |
| void | run (int time) |
Protected Slots | |
| void | render () |
Protected Member Functions | |
| void | paintEvent (QPaintEvent *e) |
| void | closeEvent (QCloseEvent *) |
| void | alphaBlend () |
Private Attributes | |
| QPixmap | pm |
| double | alpha |
| QImage | back |
| QImage | front |
| QImage | mixed |
| QPointer< QAccessWidget > | widget |
| int | duration |
| int | elapsed |
| bool | showWidget |
| QTimer | anim |
| QTime | checkTime |
| QAlphaWidget::QAlphaWidget | ( | QWidget * | w, | |
| Qt::WindowFlags | f = 0 | |||
| ) |
Definition at line 92 of file qeffects.cpp.
References alpha, QWidget::setAttribute(), QWidget::setEnabled(), w, Qt::WA_NoSystemBackground, and widget.
00093 : QWidget(QApplication::desktop()->screen(QApplication::desktop()->screenNumber(w)), f) 00094 { 00095 #ifndef Q_WS_WIN 00096 setEnabled(false); 00097 #endif 00098 00099 setAttribute(Qt::WA_NoSystemBackground, true); 00100 widget = (QAccessWidget*)w; 00101 alpha = 0; 00102 }
Here is the call graph for this function:

| void QAlphaWidget::run | ( | int | time | ) |
Definition at line 117 of file qeffects.cpp.
References anim, back, checkTime, QObject::connect(), QImage::copy(), QApplication::desktop(), duration, elapsed, QTime::elapsed(), QPixmap::fromImage(), front, QPixmap::grabWidget(), QPixmap::grabWindow(), QImage::isNull(), mixed, QWidget::move(), pm, qApp, render(), QWidget::resize(), QWidget::setEnabled(), QWidget::show(), showWidget, SIGNAL, SLOT, QTime::start(), QTimer::start(), QPixmap::toImage(), widget, and QWidget::winId().
Referenced by qFadeEffect().
00118 { 00119 duration = time; 00120 00121 if (duration < 0) 00122 duration = 150; 00123 00124 if (!widget) 00125 return; 00126 00127 elapsed = 0; 00128 checkTime.start(); 00129 00130 showWidget = true; 00131 qApp->installEventFilter(this); 00132 00133 move(widget->geometry().x(),widget->geometry().y()); 00134 resize(widget->size().width(), widget->size().height()); 00135 00136 front = QPixmap::grabWidget(widget).toImage(); 00137 back = QPixmap::grabWindow(QApplication::desktop()->winId(), 00138 widget->geometry().x(), widget->geometry().y(), 00139 widget->geometry().width(), widget->geometry().height()).toImage(); 00140 00141 if (!back.isNull() && checkTime.elapsed() < duration / 2) { 00142 mixed = back.copy(); 00143 pm = QPixmap::fromImage(mixed); 00144 show(); 00145 setEnabled(false); 00146 00147 connect(&anim, SIGNAL(timeout()), this, SLOT(render())); 00148 anim.start(1); 00149 } else { 00150 duration = 0; 00151 render(); 00152 } 00153 }
Here is the call graph for this function:

| void QAlphaWidget::paintEvent | ( | QPaintEvent * | e | ) | [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:
...
extern void qt_x11_set_global_double_buffer(bool);
qt_x11_set_global_double_buffer(false);
...
Reimplemented from QWidget.
Definition at line 107 of file qeffects.cpp.
| void QAlphaWidget::closeEvent | ( | QCloseEvent * | e | ) | [protected, virtual] |
This event handler, for event event, can be reimplemented in a subclass to receive widget close events.
Reimplemented from QWidget.
Definition at line 159 of file qeffects.cpp.
References QEvent::accept(), QWidget::closeEvent(), q_blend, render(), and showWidget.
00160 { 00161 e->accept(); 00162 if (!q_blend) 00163 return; 00164 00165 showWidget = false; 00166 render(); 00167 00168 QWidget::closeEvent(e); 00169 }
Here is the call graph for this function:

| void QAlphaWidget::alphaBlend | ( | ) | [protected] |
Definition at line 217 of file qeffects.cpp.
References a, alpha, back, QImage::bits(), QImage::bytesPerLine(), QImage::depth(), fp, front, QImage::height(), mixed, qBlue(), qGreen(), qRed(), qRgb(), qRound(), and QImage::width().
Referenced by render().
00218 { 00219 const int a = qRound(alpha*256); 00220 const int ia = 256 - a; 00221 00222 const int sw = front.width(); 00223 const int sh = front.height(); 00224 const int bpl = front.bytesPerLine(); 00225 switch(front.depth()) { 00226 case 32: 00227 { 00228 uchar *mixed_data = mixed.bits(); 00229 const uchar *back_data = back.bits(); 00230 const uchar *front_data = front.bits(); 00231 00232 for (int sy = 0; sy < sh; sy++) { 00233 quint32* mixed = (quint32*)mixed_data; 00234 const quint32* back = (const quint32*)back_data; 00235 const quint32* front = (const quint32*)front_data; 00236 for (int sx = 0; sx < sw; sx++) { 00237 quint32 bp = back[sx]; 00238 quint32 fp = front[sx]; 00239 00240 mixed[sx] = qRgb((qRed(bp)*ia + qRed(fp)*a)>>8, 00241 (qGreen(bp)*ia + qGreen(fp)*a)>>8, 00242 (qBlue(bp)*ia + qBlue(fp)*a)>>8); 00243 } 00244 mixed_data += bpl; 00245 back_data += bpl; 00246 front_data += bpl; 00247 } 00248 } 00249 default: 00250 break; 00251 } 00252 }
Here is the call graph for this function:

| void QAlphaWidget::render | ( | ) | [protected, slot] |
Definition at line 177 of file qeffects.cpp.
References alpha, alphaBlend(), anim, checkTime, QObject::deleteLater(), duration, elapsed, QTime::elapsed(), QPixmap::fromImage(), QWidget::lower(), mixed, pm, q_blend, qApp, QWidget::repaint(), QWidget::setEnabled(), QWidget::setFocus(), showWidget, QTimer::stop(), and widget.
Referenced by closeEvent(), and run().
00178 { 00179 int tempel = checkTime.elapsed(); 00180 if (elapsed >= tempel) 00181 elapsed++; 00182 else 00183 elapsed = tempel; 00184 00185 if (duration != 0) 00186 alpha = tempel / double(duration); 00187 else 00188 alpha = 1; 00189 if (alpha >= 1 || !showWidget) { 00190 anim.stop(); 00191 qApp->removeEventFilter(this); 00192 00193 if (widget) { 00194 if (!showWidget) { 00195 #ifdef Q_WS_WIN 00196 setEnabled(true); 00197 setFocus(); 00198 #endif 00199 widget->hide(); 00200 } else { 00201 widget->show(); 00202 lower(); 00203 } 00204 } 00205 q_blend = 0; 00206 deleteLater(); 00207 } else { 00208 alphaBlend(); 00209 pm = QPixmap::fromImage(mixed); 00210 repaint(); 00211 } 00212 }
QPixmap QAlphaWidget::pm [private] |
double QAlphaWidget::alpha [private] |
Definition at line 75 of file qeffects.cpp.
Referenced by alphaBlend(), QAlphaWidget(), and render().
QImage QAlphaWidget::back [private] |
QImage QAlphaWidget::front [private] |
QImage QAlphaWidget::mixed [private] |
QPointer<QAccessWidget> QAlphaWidget::widget [private] |
int QAlphaWidget::duration [private] |
int QAlphaWidget::elapsed [private] |
bool QAlphaWidget::showWidget [private] |
QTimer QAlphaWidget::anim [private] |
QTime QAlphaWidget::checkTime [private] |
1.5.1