void DrawZone::setZoom(double z) { _zoom=z; imageRect.setHeight(myround(image.height()*_zoom)); imageRect.setWidth(myround(image.width()*_zoom)); zoomedImage=QPixmap(imageRect.width(),imageRect.height()); QPainter p(&zoomedImage); p.scale(z,z); QPixmap pix; pix.convertFromImage(image); // if the picture has transparent areas, // fill them with Gimp like background if (pix.mask()) { QPixmap backPix(32,32); QPainter p2(&backPix); p2.fillRect(0,0,32,32,QColor(156,149,156)); p2.fillRect(0,16,16,16,QColor(98,105,98)); p2.fillRect(16,0,16,16,QColor(98,105,98)); p2.flush(); p.setPen(QPen()); p.fillRect(imageRect.left(),imageRect.top(),imageRect.width(),imageRect.height(),QBrush(QColor("black"),backPix)); } p.drawPixmap(imageRect.left(),imageRect.top(),pix); p.flush(); resizeContents(visibleWidth()>imageRect.width() ? visibleWidth() : imageRect.width(), visibleHeight()>imageRect.height() ? visibleHeight() : imageRect.height()); repaintContents(0,0,contentsWidth(),contentsHeight(),true); }
void RosegardenScrollView::slotScrollVertToTop(int vpos) { QScrollBar* vbar = verticalScrollBar(); if (vpos < visibleHeight() / 3) vbar->setValue(0); else vbar->setValue(vpos - visibleHeight() / 5); }
void FitCanvasView::resizeEvent(QResizeEvent *event) { QCanvasView::resizeEvent(event); if (visibleHeight() > height_) { canvas()->resize(canvas()->width(), visibleHeight()); } }
void RosegardenScrollView::updateScrollBars() { horizontalScrollBar()->setPageStep(visibleWidth()); // horizontalScrollBar()->setLineStep(visibleWidth() / 10); horizontalScrollBar()->setMaximum( std::max(contentsWidth()-visibleWidth(),0)); verticalScrollBar()->setPageStep(visibleHeight()); // verticalScrollBar()->setLineStep(visibleHeight() / 10); verticalScrollBar()->setMaximum( std::max(contentsHeight()-visibleHeight(),0)); // RG_DEBUG << "RosegardenScrollView::updateScrollBars :" << // " pagewidth - " << visibleWidth() << // " pageheight - " << visibleHeight(); }
void ThumbnailList::notifyViewportChanged( bool /*smoothMove*/ ) { // skip notifies for the current page (already selected) int newPage = m_document->viewport().pageNumber; if ( m_selected && m_selected->pageNumber() == newPage ) return; // deselect previous thumbnail if ( m_selected ) m_selected->setSelected( false ); m_selected = 0; // select the page with viewport and ensure it's centered in the view m_vectorIndex = 0; QValueVector<ThumbnailWidget *>::iterator tIt = m_thumbnails.begin(), tEnd = m_thumbnails.end(); for ( ; tIt != tEnd; ++tIt ) { if ( (*tIt)->pageNumber() == newPage ) { m_selected = *tIt; m_selected->setSelected( true ); if ( KpdfSettings::syncThumbnailsViewport() ) { int yOffset = QMAX( visibleHeight() / 4, m_selected->height() / 2 ); ensureVisible( 0, childY( m_selected ) + m_selected->height()/2, 0, yOffset ); } break; } m_vectorIndex++; } }
bool PageView::readDown() { if( atBottom() ) return false; else { // Coordinate of the bottom of the viewport int bottom = contentsY() + visibleHeight(); DocumentWidget* widget = 0; // Find the widget(s) that intersect the bottom of the viewport // TODO: It would be better to use a binary search. for(Q_UINT16 i=0; i<widgetList->size(); i++) { widget = widgetList->at(i); if (childY(widget) < bottom && childY(widget) + widget->height() > bottom) { // Draw scrollguide widget->drawScrollGuide(bottom - childY(widget)); } } int newValue = QMIN( verticalScrollBar()->value() + (int)(height() * 0.9), verticalScrollBar()->maxValue() ); verticalScrollBar()->setValue( newValue ); return true; } }
void CardView::drawRubberBands( int pos ) { if (!d->mSpan || ((pos - d->mFirstX) / d->mSpan) - d->mColspace - d->mSepWidth < MIN_ITEM_WIDTH) return; int tmpcw = (d->mRubberBandAnchor - d->mFirstX) / d->mSpan; int x = d->mFirstX + tmpcw - d->mSepWidth - contentsX(); int h = visibleHeight(); QPainter p( viewport() ); // FIXME porting //p.setRasterOp( XorROP ); p.setPen( Qt::gray ); p.setBrush( Qt::gray ); uint n = d->mFirst; // erase if ( d->mRubberBandAnchor ) do { p.drawRect( x, 0, 2, h ); x += tmpcw; n++; } while ( x < visibleWidth() && n < d->mSeparatorList.count() ); // paint new if ( ! pos ) return; tmpcw = (pos - d->mFirstX) / d->mSpan; n = d->mFirst; x = d->mFirstX + tmpcw - d->mSepWidth - contentsX(); do { p.drawRect( x, 0, 2, h ); x += tmpcw; n++; } while ( x < visibleWidth() && n < d->mSeparatorList.count() ); d->mRubberBandAnchor = pos; }
int ScrollableArea::pageStep(ScrollbarOrientation orientation) const { int length = (orientation == HorizontalScrollbar) ? visibleWidth() : visibleHeight(); int minPageStep = static_cast<float>(length) * minFractionToStepWhenPaging(); int pageStep = std::max(minPageStep, length - maxOverlapBetweenPages()); return std::max(pageStep, 1); }
void DrawZone::resizeEvent(QResizeEvent* e) { QScrollView::resizeEvent(e); int width=(int) (image.width()*_zoom); int height=(int) (image.height()*_zoom); if (visibleWidth()>width) width=visibleWidth(); if (visibleHeight()>height) height=visibleHeight(); resizeContents(width,height); imageRect.setLeft(0); imageRect.setTop(0); imageRect.setHeight((int)(image.height()*_zoom)); imageRect.setWidth((int)(image.width()*_zoom)); }
void RosegardenScrollView::resizeContents(int w, int h) // Code lifted from Q3ScrollView { int ow = m_vwidth; int oh = m_vheight; m_vwidth = w; m_vheight = h; // d->scrollbar_timer.start(0, true); // This was necessary until I fixed the resizeEvent connection //### CJ - Don't think this is necessary - slightly confused as we're resizing the content, not the widget // if (d->children.isEmpty() && d->policy == Default) // setResizePolicy(Manual); if (ow > w) { // Swap int t=w; w=ow; ow=t; } // Refresh area ow..w if (ow < visibleWidth() && w >= 0) { if (ow < 0) ow = 0; if (w > visibleWidth()) w = visibleWidth(); this->viewport()->update(contentsX()+ow, 0, w-ow, visibleHeight()); } if (oh > h) { // Swap int t=h; h=oh; oh=t; } // Refresh area oh..h if (oh < visibleHeight() && h >= 0) { if (oh < 0) oh = 0; if (h > visibleHeight()) h = visibleHeight(); this->viewport()->update(0, contentsY()+oh, visibleWidth(), h-oh); } }
bool ScrollView::platformHandleVerticalAdjustment(const IntSize& scroll) { if (m_verticalAdjustment) { m_verticalAdjustment->page_size = visibleHeight(); m_verticalAdjustment->step_increment = visibleHeight() / 10.0; m_verticalAdjustment->page_increment = visibleHeight() * 0.9; m_verticalAdjustment->lower = 0; m_verticalAdjustment->upper = contentsHeight(); gtk_adjustment_changed(m_verticalAdjustment); if (m_scrollOffset.height() != scroll.height()) { m_verticalAdjustment->value = scroll.height(); gtk_adjustment_value_changed(m_verticalAdjustment); } return true; } return false; }
bool ScrollView::platformHandleVerticalAdjustment(const IntSize& scroll) { if (m_verticalAdjustment) { m_verticalAdjustment->page_size = visibleHeight(); m_verticalAdjustment->step_increment = cScrollbarPixelsPerLineStep; m_verticalAdjustment->page_increment = visibleHeight() - cAmountToKeepWhenPaging; m_verticalAdjustment->lower = 0; m_verticalAdjustment->upper = contentsHeight(); gtk_adjustment_changed(m_verticalAdjustment); if (m_verticalAdjustment->value != scroll.height()) { m_verticalAdjustment->value = scroll.height(); gtk_adjustment_value_changed(m_verticalAdjustment); } return true; } return false; }
void RosegardenScrollView::updateContents(int x, int y, int w, int h) // Code lifted from Q3ScrollView { if (!isVisible() || !updatesEnabled()) return; // RG_DEBUG << "RosegardenScrollView::updateContents" << endl; QWidget* vp = viewport(); // Translate x -= contentsX(); y -= contentsY(); if (x < 0) { w += x; x = 0; } if (y < 0) { h += y; y = 0; } if (w < 0 || h < 0) return; if (x > visibleWidth() || y > visibleHeight()) return; if (w > visibleWidth()) w = visibleWidth(); if (h > visibleHeight()) h = visibleHeight(); //### CJ - I don't think we used a clipped_viewport on Q3ScrollView //if (d->clipped_viewport) { //// Translate clipper() to viewport() //x -= d->clipped_viewport->x(); //y -= d->clipped_viewport->y(); //} vp->update(x, y, w, h); updateScrollBars(); }
void RosegardenScrollView::slotScrollVertSmallSteps(int vpos) { QScrollBar* vbar = verticalScrollBar(); // RG_DEBUG << "RosegardenCanvasView::slotScrollVertSmallSteps - Start: vpos is " << vpos << ", contentsY is " << contentsY() << ", visibleHeight is " << visibleHeight() << endl; // As a special case (or hack), ignore any request made before we've // actually been rendered and sized if (visibleHeight() <= 1) return ; int diff = 0; if (vpos == 0) { // returning to zero vbar->setValue(0); } else if ((diff = int(vpos - (contentsY() + visibleHeight() * 0.90))) > 0) { // moving off up int delta = diff / 6; int diff10 = std::min(diff, (int)m_minDeltaScroll); delta = std::max(delta, diff10); vbar->setValue(vbar->value() + diff); } else if ((diff = int(vpos - (contentsY() + visibleHeight() * 0.10))) < 0) { // moving off down int delta = -diff / 6; int diff10 = std::min( -diff, (int)m_minDeltaScroll); delta = std::max(delta, diff10); vbar->setValue(vbar->value() - delta); } }
void PageView::calculateCurrentPageNumber(int x, int y) { // Safety check if (widgetList == 0) return; QRect viewportRect(x, y, visibleWidth(), visibleHeight()); //kdDebug() << "viewportRect(" << viewportRect.x() << ", " << viewportRect.y() << ", " // << viewportRect.width() << ", " << viewportRect.height() << ")" << endl; int maxVisiblePixels = 0; DocumentWidget* _currentWidget = 0; for (Q_UINT16 i = 0; i < widgetList->size(); i++) { DocumentWidget* documentWidget = widgetList->at(i); // Safety check if (documentWidget == 0) continue; // Check if the Widget is visible int cx = childX(documentWidget); int cy = childY(documentWidget); QRect widgetRect(cx, cy, documentWidget->width(), documentWidget->height()); bool isVisible = widgetRect.intersects(viewportRect); if (!isVisible) continue; // Calculate the number of visible pixels of the widget QRect visibleRect = widgetRect.intersect(viewportRect); int visiblePixels = visibleRect.width() * visibleRect.height(); //kdDebug() << visiblePixels << " pixels are visible of page " << documentWidget->getPageNumber() << endl; // If a bigger part of this widget as of the previous widgets is visible make it the current widget. if (maxVisiblePixels < visiblePixels) { maxVisiblePixels = visiblePixels; _currentWidget = documentWidget; } } // No page is visible if (_currentWidget == 0) return; // Return the number of the current page emit currentPageChanged(_currentWidget->getPageNumber()); }
int Q3ScrollView::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = Q3Frame::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 23) qt_static_metacall(this, _c, _id, _a); _id -= 23; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< ResizePolicy*>(_v) = resizePolicy(); break; case 1: *reinterpret_cast< ScrollBarMode*>(_v) = vScrollBarMode(); break; case 2: *reinterpret_cast< ScrollBarMode*>(_v) = hScrollBarMode(); break; case 3: *reinterpret_cast< int*>(_v) = visibleWidth(); break; case 4: *reinterpret_cast< int*>(_v) = visibleHeight(); break; case 5: *reinterpret_cast< int*>(_v) = contentsWidth(); break; case 6: *reinterpret_cast< int*>(_v) = contentsHeight(); break; case 7: *reinterpret_cast< int*>(_v) = contentsX(); break; case 8: *reinterpret_cast< int*>(_v) = contentsY(); break; case 9: *reinterpret_cast< bool*>(_v) = dragAutoScroll(); break; } _id -= 10; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setResizePolicy(*reinterpret_cast< ResizePolicy*>(_v)); break; case 1: setVScrollBarMode(*reinterpret_cast< ScrollBarMode*>(_v)); break; case 2: setHScrollBarMode(*reinterpret_cast< ScrollBarMode*>(_v)); break; case 9: setDragAutoScroll(*reinterpret_cast< bool*>(_v)); break; } _id -= 10; } else if (_c == QMetaObject::ResetProperty) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 10; } #endif // QT_NO_PROPERTIES return _id; }
void PageView::moveViewportToWidget(QWidget* widget, int y) { int verticalPos = 0; int verticalPosTop = 0; if (y != 0) { verticalPosTop = childY(widget) + y - visibleHeight()/2; verticalPos = childY(widget) + y; } else { verticalPos = childY(widget) - distanceBetweenWidgets; verticalPosTop = verticalPos; } if (nrCols == 1) { // In single column viewmodes, we change the vertical position only, to make it // easier to work with high zoomlevels where not the whole pagewidth is visible. // TODO: Smarter algorithm also for continuous facing viewmode. int top = (int)(contentsY() + 0.1 * visibleHeight()); int bottom = (int)(contentsY() + 0.9 * visibleHeight()); // Move the viewport if the target is currently not visible, or lies at the edge // of the viewport. If y = 0 always move the top of the targetpage to the top edge // of the viewport. if (verticalPos < top || verticalPos > bottom || y == 0) { setContentsPos(contentsX(), verticalPosTop); } } else { setContentsPos(childX(widget) - distanceBetweenWidgets, verticalPosTop); } }
void LightTablePreview::setDragAndDropMessage() { if (d->dragAndDropEnabled) { QPixmap pix(visibleWidth(), visibleHeight()); pix.fill(ThemeEngine::instance()->baseColor()); QPainter p(&pix); p.setPen(QPen(ThemeEngine::instance()->textRegColor())); p.drawText(0, 0, pix.width(), pix.height(), Qt::AlignCenter|Qt::TextWordWrap, i18n("Drag and drop an image here")); p.end(); setImage(DImg(pix.toImage())); } }
void ThumbnailList::updateWidgets() { // find all widgets that intersects the viewport and update them QRect viewportRect( contentsX(), contentsY(), visibleWidth(), visibleHeight() ); QValueList<ThumbnailWidget *>::iterator vIt = m_visibleThumbnails.begin(), vEnd = m_visibleThumbnails.end(); for ( ; vIt != vEnd; ++vIt ) { ThumbnailWidget * t = *vIt; QRect widgetRect( childX( t ), childY( t ), t->width(), t->height() ); // update only the exposed area of the widget (saves pixels..) QRect relativeRect = viewportRect.intersect( widgetRect ); if ( !relativeRect.isValid() ) continue; relativeRect.moveBy( -widgetRect.left(), -widgetRect.top() ); t->update( relativeRect ); } }
IntRect ScrollableArea::visibleContentRectInternal(VisibleContentRectIncludesScrollbars scrollbarInclusion, VisibleContentRectBehavior) const { int verticalScrollbarWidth = 0; int horizontalScrollbarHeight = 0; if (scrollbarInclusion == IncludeScrollbars) { if (Scrollbar* verticalBar = verticalScrollbar()) verticalScrollbarWidth = verticalBar->occupiedWidth(); if (Scrollbar* horizontalBar = horizontalScrollbar()) horizontalScrollbarHeight = horizontalBar->occupiedHeight(); } return IntRect(scrollPosition().x(), scrollPosition().y(), std::max(0, visibleWidth() + verticalScrollbarWidth), std::max(0, visibleHeight() + horizontalScrollbarHeight)); }
IntRect ScrollableArea::visibleContentRect(bool includeScrollbars) const { int verticalScrollbarWidth = 0; int horizontalScrollbarHeight = 0; if (includeScrollbars) { if (Scrollbar* verticalBar = verticalScrollbar()) verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? verticalBar->width() : 0; if (Scrollbar* horizontalBar = horizontalScrollbar()) horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? horizontalBar->height() : 0; } return IntRect(scrollPosition().x(), scrollPosition().y(), std::max(0, visibleWidth() + verticalScrollbarWidth), std::max(0, visibleHeight() + horizontalScrollbarHeight)); }
void ThumbnailList::viewportResizeEvent( QResizeEvent * e ) { if ( m_thumbnails.count() < 1 || width() < 1 ) return; // if width changed resize all the Thumbnails, reposition them to the // right place and recalculate the contents area if ( e->size().width() != e->oldSize().width() ) { // runs the timer avoiding a thumbnail regeneration by 'contentsMoving' delayedRequestVisiblePixmaps( 2000 ); // resize and reposition items int totalHeight = 0, newWidth = e->size().width(); QValueVector<ThumbnailWidget *>::iterator tIt = m_thumbnails.begin(), tEnd = m_thumbnails.end(); for ( ; tIt != tEnd; ++tIt ) { ThumbnailWidget *t = *tIt; moveChild( t, 0, totalHeight ); t->resizeFitWidth( newWidth ); totalHeight += t->heightHint() + 4; } // update scrollview's contents size (sets scrollbars limits) resizeContents( newWidth, totalHeight ); // ensure selected item remains visible if ( m_selected ) ensureVisible( 0, childY( m_selected ) + m_selected->height()/2, 0, visibleHeight()/2 ); } else if ( e->size().height() <= e->oldSize().height() ) return; // invalidate the bookmark overlay if ( m_bookmarkOverlay ) { delete m_bookmarkOverlay; m_bookmarkOverlay = 0; } // update Thumbnails since width has changed or height has increased delayedRequestVisiblePixmaps( 500 ); }
void SchemaEditor::zoom(float factor) { _zoom+=factor; if (_zoom < 0.2f) _zoom = 0.2f; int oldcenterx = visibleWidth()/2; int oldcentery = visibleHeight()/2; int x, y; viewportToContents(oldcenterx, oldcentery, x, y); inverseWorldMatrix().map(x, y, &x, &y); QMatrix wm; wm.scale(_zoom, _zoom); setWorldMatrix(wm); //worldMatrix().map(x, y, &x, &y); //setContentsPos(x-oldcenterx, y-oldcentery); }
//BEGIN internal SLOTS void ThumbnailList::slotRequestVisiblePixmaps( int /*newContentsX*/, int newContentsY ) { // if an update is already scheduled or the widget is hidden, don't proceed if ( (m_delayTimer && m_delayTimer->isActive()) || !isShown() ) return; int vHeight = visibleHeight(), vOffset = newContentsY == -1 ? contentsY() : newContentsY; // scroll from the top to the last visible thumbnail m_visibleThumbnails.clear(); QValueList< PixmapRequest * > requestedPixmaps; QValueVector<ThumbnailWidget *>::iterator tIt = m_thumbnails.begin(), tEnd = m_thumbnails.end(); for ( ; tIt != tEnd; ++tIt ) { ThumbnailWidget * t = *tIt; int top = childY( t ) - vOffset; if ( top > vHeight ) break; if ( top + t->height() < 0 ) continue; // add ThumbnailWidget to visible list m_visibleThumbnails.push_back( t ); // if pixmap not present add it to requests if ( !t->page()->hasPixmap( THUMBNAILS_ID, t->pixmapWidth(), t->pixmapHeight() ) ) { PixmapRequest * p = new PixmapRequest( THUMBNAILS_ID, t->pageNumber(), t->pixmapWidth(), t->pixmapHeight(), THUMBNAILS_PRIO, true ); requestedPixmaps.push_back( p ); } } // actually request pixmaps if ( !requestedPixmaps.isEmpty() ) m_document->requestPixmaps( requestedPixmaps ); }
IntPoint ScrollableArea::maximumScrollPosition() const { return IntPoint(contentsSize().width() - visibleWidth(), contentsSize().height() - visibleHeight()); }
void PageView::layoutPages(bool zoomChanged) { // Paranoid safety check if (widgetList == 0) return; // If there are no widgets, e.g. because the last widget has been // removed, the matter is easy: set the contents size to 0. If there // are no widgets because previously existing widgets were removed // (we detect that by looking at the contentsWidth and -Height). if (widgetList->isEmpty()) { if ((contentsWidth() != 0) || (contentsHeight() != 0)) { QScrollView::resizeContents(0,0); } return; } // Ok, now we are in a situation where we do have some widgets that // shall be centered. int distance = distanceBetweenWidgets; if (singlePageFullScreenMode()) { // In single page fullscreen mode we don't want a margin around the pages distance = 0; } QMemArray<Q_UINT32> colWidth(nrCols); for(Q_UINT8 i=0; i<colWidth.size(); i++) colWidth[i] = 0; Q_UINT16 numRows; if(nrCols <= 2) { numRows = (widgetList->size()+2*nrCols-2) / nrCols; } else { numRows = (Q_INT16)ceil(((double)widgetList->size()) / nrCols); } QMemArray<Q_UINT32> rowHeight(numRows); for(Q_UINT16 i=0; i<rowHeight.size(); i++) rowHeight[i] = 0; // Now find the widths and heights of the columns for(Q_UINT16 i=0; i<widgetList->size(); i++) { Q_UINT8 col; Q_UINT16 row; if (nrCols == 2) { // In two-column display, start with the right column col = (i+1+nrCols) % nrCols; row = (i+1+nrCols) / nrCols - 1; } else { col = (i+nrCols) % nrCols; row = (i+nrCols) / nrCols - 1; } colWidth[col] = QMAX(colWidth[col], (Q_UINT32)widgetList->at(i)->pageSize().width()); rowHeight[row] = QMAX(rowHeight[row], (Q_UINT32)widgetList->at(i)->pageSize().height()); } // Calculate the total width and height of the display Q_UINT32 totalHeight = 0; for(Q_UINT16 i=0; i<rowHeight.size(); i++) totalHeight += rowHeight[i]; totalHeight += (numRows+1)*distance; Q_UINT32 totalWidth = 0; for(Q_UINT8 i=0; i<colWidth.size(); i++) totalWidth += colWidth[i]; totalWidth += (nrCols+1)*distance; QSize newViewportSize = viewportSize( totalWidth, totalHeight ); Q_UINT32 centeringLeft = 0; if( (Q_UINT32)newViewportSize.width() > totalWidth ) centeringLeft = ( newViewportSize.width() - totalWidth )/2; Q_UINT32 centeringTop = 0; if( (Q_UINT32)newViewportSize.height() > totalHeight ) centeringTop = ( newViewportSize.height() - totalHeight)/2; // Resize the viewport if (((Q_UINT32)contentsWidth() != totalWidth) || ((Q_UINT32)contentsHeight() != totalHeight)) { // Calculate the point in the coordinates of the contents which is currently at the center of the viewport. QPoint midPoint = QPoint(visibleWidth() / 2 + contentsX(), visibleHeight() / 2 + contentsY()); double midPointRatioX = (double)(midPoint.x()) / contentsWidth(); double midPointRatioY = (double)(midPoint.y()) / contentsHeight(); resizeContents(totalWidth,totalHeight); // If the zoom changed recenter the former midPoint if (zoomChanged) center((int)(contentsWidth() * midPointRatioX), (int)(contentsHeight() * midPointRatioY)); } // Finally, calculate the left and top coordinates of each row and // column, respectively QMemArray<Q_UINT32> colLeft(nrCols); colLeft[0] = distance; for(Q_UINT8 i=1; i<colLeft.size(); i++) colLeft[i] = colLeft[i-1]+colWidth[i-1]+distance; QMemArray<Q_UINT32> rowTop(numRows); rowTop[0] = distance; for(Q_UINT16 i=1; i<rowTop.size(); i++) rowTop[i] = rowTop[i-1]+rowHeight[i-1]+distance; for(Q_UINT16 i=0; i<widgetList->size(); i++) { Q_UINT8 col; Q_UINT16 row; if (nrCols == 2) { // In two column-mode start with the right column. col = (i+nrCols-1) % nrCols; row = (i+nrCols-1) / nrCols; } else { col = (i+nrCols) % nrCols; row = i / nrCols; } if (nrCols == 2) { // in 2-column mode right justify the first column, and leftjustify the second column int width = widgetList->at(i)->width(); int left; if (col == 0) left = centeringLeft + colLeft[col] + colWidth[col]-width + distance/2; else left = centeringLeft + colLeft[col]; moveChild( widgetList->at(i), left, centeringTop+rowTop[row]); } else { // in single column and overview mode center the widgets int widgetWidth = widgetList->at(i)->width(); int left = centeringLeft + colLeft[col] + ((int)colWidth[col]-widgetWidth)/2; moveChild(widgetList->at(i), left, centeringTop+rowTop[row]); } } calculateCurrentPageNumber(); }
IntSize maximumScrollOffsetInt() const override { return contentsSize() - IntSize(visibleWidth(), visibleHeight()); }
FloatRect ScrollView::visibleContentRect() const { return FloatRect(contentsX(),contentsY(),visibleWidth(),visibleHeight()); }
IntPoint maximumScrollPosition() const override { return IntPoint(contentsSize().width() - visibleWidth(), contentsSize().height() - visibleHeight()); }
IntSize ScrollView::maximumScroll() const { IntSize delta = (IntSize(contentsWidth(), contentsHeight()) - IntSize(visibleWidth(), visibleHeight())) - scrollOffset(); delta.clampNegativeToZero(); return delta; }