From cff522f98666e1bf24c36a3a0a2abe3fb2e1abe8 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Mon, 18 Feb 2013 20:37:37 -0600 Subject: Automated update from Qt3 --- src/iconview/ntqiconview.h | 1 + src/iconview/qiconview.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) (limited to 'src/iconview') diff --git a/src/iconview/ntqiconview.h b/src/iconview/ntqiconview.h index bda8273f4..e45cfca65 100644 --- a/src/iconview/ntqiconview.h +++ b/src/iconview/ntqiconview.h @@ -452,6 +452,7 @@ protected: void contentsDropEvent( TQDropEvent *e ); #endif + void bufferedPaintEvent( TQPaintEvent* ); void resizeEvent( TQResizeEvent* e ); void keyPressEvent( TQKeyEvent *e ); void focusInEvent( TQFocusEvent *e ); diff --git a/src/iconview/qiconview.cpp b/src/iconview/qiconview.cpp index ee4a0fe36..dbf764a0f 100644 --- a/src/iconview/qiconview.cpp +++ b/src/iconview/qiconview.cpp @@ -214,6 +214,7 @@ public: TQIconViewItem *currentItem, *tmpCurrentItem, *highlightedItem, *startDragItem, *pressedItem, *selectAnchor, *renamingItem; TQRect *rubber; + TQPixmap *backBuffer; TQTimer *scrollTimer, *adjustTimer, *updateTimer, *inputTimer, *fullRedrawTimer; int rastX, rastY, spacing; @@ -2800,6 +2801,7 @@ TQIconView::TQIconView( TQWidget *parent, const char *name, WFlags f ) d->currentItem = 0; d->highlightedItem = 0; d->rubber = 0; + d->backBuffer = 0; d->scrollTimer = 0; d->startDragItem = 0; d->tmpCurrentItem = 0; @@ -2953,6 +2955,8 @@ TQIconView::~TQIconView() delete item; item = tmp; } + delete d->backBuffer; + d->backBuffer = 0; delete d->fm; d->fm = 0; #ifndef QT_NO_TOOLTIP @@ -4972,6 +4976,47 @@ void TQIconView::contentsDropEvent( TQDropEvent *e ) } #endif +/*! + This function grabs all paintevents that otherwise would have been + processed by the TQScrollView::viewportPaintEvent(). Here we use a + doublebuffer to reduce 'on-paint' flickering on TQIconView + (and of course its children). + + \sa TQScrollView::viewportPaintEvent(), TQIconView::drawContents() +*/ + +void TQIconView::bufferedPaintEvent( TQPaintEvent* pe ) +{ + TQWidget* vp = viewport(); + TQRect r = pe->rect() & vp->rect(); + int ex = r.x() + contentsX(); + int ey = r.y() + contentsY(); + int ew = r.width(); + int eh = r.height(); + + if ( !d->backBuffer ) + d->backBuffer = new TQPixmap(vp->size()); + if ( d->backBuffer->size() != vp->size() ) { + // Resize function (with hysteresis). Uses a good compromise between memory + // consumption and speed (number) of resizes. + float newWidth = (float)vp->width(); + float newHeight = (float)vp->height(); + if ( newWidth > d->backBuffer->width() || newHeight > d->backBuffer->height() ) + { + newWidth *= 1.1892; + newHeight *= 1.1892; + d->backBuffer->resize( (int)newWidth, (int)newHeight ); + } else if ( 1.5*newWidth < d->backBuffer->width() || 1.5*newHeight < d->backBuffer->height() ) + d->backBuffer->resize( (int)newWidth, (int)newHeight ); + } + + TQPainter p; + p.begin(d->backBuffer, vp); + drawContentsOffset(&p, contentsX(), contentsY(), ex, ey, ew, eh); + p.end(); + bitBlt(vp, r.x(), r.y(), d->backBuffer, r.x(), r.y(), ew, eh); +} + /*! \reimp */ @@ -5756,7 +5801,7 @@ bool TQIconView::eventFilter( TQObject * o, TQEvent * e ) if ( !d->rubber ) drawDragShapes( d->oldDragPos ); } - viewportPaintEvent( (TQPaintEvent*)e ); + bufferedPaintEvent( (TQPaintEvent*)e ); if ( d->dragging ) { if ( !d->rubber ) drawDragShapes( d->oldDragPos ); -- cgit v1.2.1