void TLFrameSequenceLayout::updateContentSize()
{
    if ( contentsHeight() < number_of_frame_sequences * 24 )
    {
    	resizeContents( contentsWidth(), number_of_frame_sequences * 24 );
    }
    else if ( contentsHeight() > number_of_frame_sequences * 24 && contentsHeight() > 90 )
    {
        resizeContents( contentsWidth(), contentsHeight() - 24 );
    }
    updateContents();
    updateScrollBars();
    parent_widget -> update();
}
// this is called from the clicked PatternWidget when in signal mode //
void 
PolicyViewClass::endAddTransition(PatternWidgetClass* patternWidget)
{
  // if addTransition mode is on, finish it and add the signal //
  if (isAddTransitionMode()) {
    viewport()->setMouseTracking(false);
    addTransitionMode = false;

    bool ok = false;
    QString message = QInputDialog::getText(tr( "Add Transition" ),
					    tr( "Transition name:" ),
					    QLineEdit::Normal, QString::null, &ok, this );
    if ( ok && !message.isEmpty() ) {
      QString target  = patternWidget->getPatternName();
      if (document.addTransition(pickedPattern, message, target))
	updateContents(contentsX(), contentsY(),
		       contentsWidth(), contentsHeight());
      else
	QMessageBox::warning(this, 
			     "Add Transition", 
			     "Transition " + message + " allready exists.\n" + 
			     "No transition added.");

    }
  }
}
Beispiel #3
0
/******************************************************************************
*  Sets the last column in the list view to extend at least to the right hand
*  edge of the list view.
*/
void EventListViewBase::resizeLastColumn()
{
    int lastColumnWidth = mLastColumnHeaderWidth;
    for (EventListViewItemBase* item = firstChild();  item;  item = item->nextSibling())
    {
        int mw = item->lastColumnWidth();
        if (mw > lastColumnWidth)
            lastColumnWidth = mw;
    }
    QHeader* head = header();
    int x = head->sectionPos(mLastColumn);
    int availableWidth = visibleWidth() - x;
    int rightColWidth = 0;
    int index = head->mapToIndex(mLastColumn);
    if (index < mLastColumn)
    {
        // The last column has been dragged by the user to a different position.
        // Ensure that the columns now to the right of it are still shown.
        for (int i = index + 1;  i <= mLastColumn;  ++i)
            rightColWidth += columnWidth(head->mapToSection(i));
        availableWidth -= rightColWidth;
    }
    if (availableWidth < lastColumnWidth)
        availableWidth = lastColumnWidth;
    setColumnWidth(mLastColumn, availableWidth);
    if (contentsWidth() > x + availableWidth + rightColWidth)
        resizeContents(x + availableWidth + rightColWidth, contentsHeight());
}
Beispiel #4
0
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 KexiSimplePrintPreviewScrollView::setFullWidth()
{
    viewport()->setUpdatesEnabled(false);
    double widthMM = KoPageFormat::width(
                         m_window->settings().pageLayout.format,
                         m_window->settings().pageLayout.orientation);
    double heightMM = KoPageFormat::height(
                          m_window->settings().pageLayout.format, m_window->settings().pageLayout.orientation);
// int constantWidth = m_window->width()- KexiSimplePrintPreviewScrollView_MARGIN*6;
    double constantWidth = width() - KexiSimplePrintPreviewScrollView_MARGIN * 6;
    double heightForWidth = constantWidth * heightMM / widthMM;
// heightForWidth = qMin(kapp->desktop()->height()*4/5, heightForWidth);
    kDebug() << "1: " << heightForWidth;
#if 0 //todo we can use this if we want to fix the height to width of the page
    heightForWidth = qMin(height(), heightForWidth);
    kDebug() << "2: " << heightForWidth;
#endif
    constantWidth = heightForWidth * widthMM / heightMM;
    widget->resize((int)constantWidth, (int)heightForWidth); //keep aspect
    resizeContents(int(widget->width() + 2*KexiSimplePrintPreviewScrollView_MARGIN),
                   int(widget->height() + 2*KexiSimplePrintPreviewScrollView_MARGIN));
    moveChild(widget, (contentsWidth() - widget->width()) / 2,
              (contentsHeight() - widget->height()) / 2);
    viewport()->setUpdatesEnabled(true);
    resize(size() + QSize(1, 1)); //to update pos.
    widget->enablePainting = true;
    widget->repaint();
}
Beispiel #6
0
void STStatusPane::relayoutContents(){
    if(size().isEmpty())
        return;

    m_nameView->setWidth(size().width());
    m_iconView->setPos(4,4);

    m_contentsView->setPos(0,m_nameView->boxHeight());
    m_contentsView->setSize(QSize(contentsWidth(),
                            size().height()-m_nameView->boxHeight()));
}
void ThumbnailList::slotDelayTimeout()
{
    // resize the bookmark overlay
    delete m_bookmarkOverlay;
    int expectedWidth = contentsWidth() / 4;
    if ( expectedWidth > 10 )
        m_bookmarkOverlay = new QPixmap( DesktopIcon( "attach", expectedWidth ) );
    else
        m_bookmarkOverlay = 0;

    // request pixmaps
    slotRequestVisiblePixmaps();
}
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 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 QGridView::paintEmptyArea( QPainter *p, int cx ,int cy, int cw, int ch)
{
    if ( gridSize().width() >= contentsWidth() && gridSize().height() >= contentsHeight() )
	return;
    // Region of the rect we should draw
    contentsToViewport( cx, cy, cx, cy );
    QRegion reg( QRect( cx, cy, cw, ch ) );
    // Subtract the table from it
    reg = reg.subtract( QRect( contentsToViewport( QPoint( 0, 0 ) ), gridSize() ) );

    // And draw the rectangles (transformed as needed)
    QMemArray<QRect> r = reg.rects();
    const QBrush &brush = backgroundBrush();
    for ( int i = 0; i < (int)r.count(); ++i)
	p->fillRect( r[ i ], brush );
}
bool ScrollView::platformHandleHorizontalAdjustment(const IntSize& scroll)
{
    if (m_horizontalAdjustment) {
        m_horizontalAdjustment->page_size = visibleWidth();
        m_horizontalAdjustment->step_increment = visibleWidth() / 10.0;
        m_horizontalAdjustment->page_increment = visibleWidth() * 0.9;
        m_horizontalAdjustment->lower = 0;
        m_horizontalAdjustment->upper = contentsWidth();
        gtk_adjustment_changed(m_horizontalAdjustment);

        if (m_scrollOffset.width() != scroll.width()) {
            m_horizontalAdjustment->value = scroll.width();
            gtk_adjustment_value_changed(m_horizontalAdjustment);
        }
        return true;
    }
    return false;
}
Beispiel #12
0
bool ScrollView::platformHandleHorizontalAdjustment(const IntSize& scroll)
{
    if (m_horizontalAdjustment) {
        m_horizontalAdjustment->page_size = visibleWidth();
        m_horizontalAdjustment->step_increment = cScrollbarPixelsPerLineStep;
        m_horizontalAdjustment->page_increment = visibleWidth() - cAmountToKeepWhenPaging;
        m_horizontalAdjustment->lower = 0;
        m_horizontalAdjustment->upper = contentsWidth();
        gtk_adjustment_changed(m_horizontalAdjustment);

        if (m_horizontalAdjustment->value != scroll.width()) {
            m_horizontalAdjustment->value = scroll.width();
            gtk_adjustment_value_changed(m_horizontalAdjustment);
        }
        return true;
    }
    return false;
}
void QtFileIconView::newDirectory()
{
    setAutoArrange( FALSE );
    selectAll( FALSE );
    if ( viewDir.mkdir( QString( "New Folder %1" ).arg( ++newFolderNum ) ) ) {
        QFileInfo *fi = new QFileInfo( viewDir, QString( "New Folder %1" ).arg( newFolderNum ) );
        QtFileIconViewItem *item = new QtFileIconViewItem( this, new QFileInfo( *fi ) );
        item->setKey( QString( "000000%1" ).arg( fi->fileName() ) );
        delete fi;
        repaintContents( contentsX(), contentsY(), contentsWidth(), contentsHeight(), FALSE );
        ensureItemVisible( item );
        item->setSelected( TRUE, TRUE );
        setCurrentItem( item );
        repaintItem( item );
        qApp->processEvents();
        item->rename();
    }
    setAutoArrange( TRUE );
}
void KImportIconView::drawContents ( QPainter *p, int cx, int cy, int cw, int ch )
{
    if ( !m_bDropped)
    {
        QIconView::drawContents ( p, cx, cy, cw, ch );

        p->save();
        QFont font ( p->font() );
        font.setBold ( true );
        font.setFamily ( "Helvetica [Adobe]" );
        font.setPointSize ( 10 );
        p->setFont ( font );
        p->setPen ( QPen ( KGlobalSettings::highlightColor() ) );

        QRect rect = frameRect();
        QFontMetrics fm ( p->font() );
        rect.setLeft ( rect.left() + 30 );
        rect.setRight ( rect.right() - 30 );

        resizeContents ( contentsWidth(), contentsHeight() );

        // word-wrap the string
        KWordWrap* wordWrap1 = KWordWrap::formatText( fm, rect, AlignHCenter | WordBreak, m_strIntro );
        KWordWrap* wordWrap2 = KWordWrap::formatText( fm, rect, AlignHCenter | WordBreak, i18n("Or just use the buttons.") );

        QRect introRect1 = wordWrap1->boundingRect();
		QRect introRect2 = wordWrap2->boundingRect();

        wordWrap1->drawText ( p, ( ( frameRect().right() - introRect1.right() ) / 2 ), ( ( frameRect().bottom() - introRect1.bottom() ) / 2 ) - 20, AlignHCenter | AlignVCenter );
        wordWrap2->drawText ( p, ( ( frameRect().right() - introRect2.right() ) / 2 ), ( ( frameRect().bottom() - introRect2.bottom() ) / 2 ) + introRect1.bottom(), AlignHCenter | AlignVCenter );

        p->restore();
    }
    else
    {
        QIconView::drawContents ( p, cx, cy, cw, ch );
    }
}
Beispiel #15
0
IntSize ScrollView::maximumScroll() const
{
    IntSize delta = (IntSize(contentsWidth(), contentsHeight()) - IntSize(visibleWidth(), visibleHeight())) - scrollOffset();
    delta.clampNegativeToZero();
    return delta;
}
void StringListEditor::adjustCols()
{
	int w=width()-leftMargin();
	TableEditor::adjustCols();
	setColumnWidth(2,w-contentsWidth());
}
Beispiel #17
0
void CardView::keyPressEvent( QKeyEvent *e )
{
  if ( !(childCount() && d->mCurrentItem) ) {
    e->ignore();
    return;
  }

  uint pos = d->mItemList.findRef( d->mCurrentItem );
  CardViewItem *aItem = 0;
  CardViewItem *old = d->mCurrentItem;

  switch ( e->key() ) {
    case Qt::Key_Up:
      if ( pos > 0 ) {
        aItem = d->mItemList.at( pos - 1 );
        setCurrentItem( aItem );
      }
      break;
    case Qt::Key_Down:
      if ( pos < d->mItemList.count() - 1 ) {
        aItem = d->mItemList.at( pos + 1 );
        setCurrentItem( aItem );
      }
      break;
    case Qt::Key_Left:
    {
      // look for an item in the previous/next column, starting from
      // the vertical middle of the current item.
      // FIXME use nice calculatd measures!!!
      QPoint aPoint( d->mCurrentItem->d->x, d->mCurrentItem->d->y );
      aPoint -= QPoint( 30, -(d->mCurrentItem->height() / 2) );
      aItem = itemAt( aPoint );
      // maybe we hit some space below an item
      while ( !aItem && aPoint.y() > 27 ) {
        aPoint -= QPoint( 0, 16 );
        aItem = itemAt( aPoint );
      }
      if ( aItem )
        setCurrentItem( aItem );

      break;
    }
    case Qt::Key_Right:
    {
      // FIXME use nice calculated measures!!!
      QPoint aPoint( d->mCurrentItem->d->x + d->mItemWidth, d->mCurrentItem->d->y );
      aPoint += QPoint( 30, (d->mCurrentItem->height() / 2) );
      aItem = itemAt( aPoint );
      while ( !aItem && aPoint.y() > 27 ) {
        aPoint -= QPoint( 0, 16 );
        aItem = itemAt( aPoint );
      }
      if ( aItem )
        setCurrentItem( aItem );

      break;
    }
    case Qt::Key_Home:
      aItem = d->mItemList.first();
      setCurrentItem( aItem );
      break;
    case Qt::Key_End:
      aItem = d->mItemList.last();
      setCurrentItem( aItem );
      break;
    case Qt::Key_PageUp: // PageUp
    {
      // QListView: "Make the item above the top visible and current"
      // TODO if contentsY(), pick the top item of the leftmost visible column
      if ( contentsX() <= 0 )
        return;
      int cw = columnWidth();
      int theCol = ( qMax( 0, ( contentsX() / cw) * cw ) ) + d->mItemSpacing;
      aItem = itemAt( QPoint( theCol + 1, d->mItemSpacing + 1 ) );
      if ( aItem )
        setCurrentItem( aItem );

      break;
    }
    case Qt::Key_PageDown:  // PageDown
    {
      // QListView: "Make the item below the bottom visible and current"
      // find the first not fully visible column.
      // TODO: consider if a partly visible (or even hidden) item at the
      //       bottom of the rightmost column exists
      int cw = columnWidth();
      int theCol = ( (( contentsX() + visibleWidth() ) / cw) * cw ) + d->mItemSpacing + 1;
      // if separators are on, we may need to we may be one column further right if only the spacing/sep is hidden
      if ( d->mDrawSeparators && cw - (( contentsX() + visibleWidth() ) % cw) <= int( d->mItemSpacing + d->mSepWidth ) )
        theCol += cw;

      // make sure this is not too far right
      while ( theCol > contentsWidth() )
        theCol -= columnWidth();

      aItem = itemAt( QPoint( theCol, d->mItemSpacing + 1 ) );

      if ( aItem )
        setCurrentItem( aItem );

      break;
    }
    case Qt::Key_Space:
      setSelected( d->mCurrentItem, !d->mCurrentItem->isSelected() );
      emit selectionChanged();
      break;
    case Qt::Key_Return:
    case Qt::Key_Enter:
      emit returnPressed( d->mCurrentItem );
      emit executed( d->mCurrentItem );
      break;
    case Qt::Key_Menu:
      emit contextMenuRequested( d->mCurrentItem, viewport()->mapToGlobal(
                                 itemRect(d->mCurrentItem).center() ) );
      break;
    default:
      if ( (e->modifiers() & Qt::ControlModifier) && e->key() == Qt::Key_A ) {
        // select all
        selectAll( true );
        break;
      } else if ( !e->text().isEmpty() && e->text()[ 0 ].isPrint() ) {
        // if we have a string, do autosearch
      }
      break;
  }

  // handle selection
  if ( aItem ) {
    if ( d->mSelectionMode == CardView::Extended ) {
      if ( e->modifiers() & Qt::ShiftModifier ) {
        // shift button: toggle range
        // if control button is pressed, leave all items
        // and toggle selection current->old current
        // otherwise, ??????
        bool s = ! aItem->isSelected();
        int from, to, a, b;
        a = d->mItemList.findRef( aItem );
        b = d->mItemList.findRef( old );
        from = a < b ? a : b;
        to = a > b ? a : b;

        if ( to - from > 1 ) {
          bool b = signalsBlocked();
          blockSignals( true );
          selectAll( false );
          blockSignals( b );
        }

        CardViewItem *item;
        for ( ; from <= to; ++from ) {
          item = d->mItemList.at( from );
          item->setSelected( s );
          repaintItem( item );
        }

        emit selectionChanged();
      } else if ( e->modifiers() & Qt::ControlModifier ) {
        // control button: do nothing
      } else {
        // no button: move selection to this item
        bool b = signalsBlocked();
        blockSignals( true );
        selectAll( false );
        blockSignals( b );

        setSelected( aItem, true );
        emit selectionChanged();
      }
    }
  }
}
void PictureListEditor::adjustCols()
{
	int w=width();
	TableEditor::adjustCols();
	setColumnWidth(2,w-contentsWidth());
}
Beispiel #19
0
void ScrollView::updateScrollbars(const IntSize& desiredOffset)
{
    // Don't allow re-entrancy into this function.
    if (m_data->m_inUpdateScrollbars)
        return;

    // FIXME: This code is here so we don't have to fork FrameView.h/.cpp.
    // In the end, FrameView should just merge with ScrollView.
    if (static_cast<const FrameView*>(this)->frame()->prohibitsScrolling())
        return;

    m_data->m_inUpdateScrollbars = true;

    bool hasVerticalScrollbar = m_data->m_vBar;
    bool hasHorizontalScrollbar = m_data->m_hBar;
    bool oldHasVertical = hasVerticalScrollbar;
    bool oldHasHorizontal = hasHorizontalScrollbar;
    ScrollbarMode hScroll = m_data->m_hScrollbarMode;
    ScrollbarMode vScroll = m_data->m_vScrollbarMode;
    
    const int cVerticalWidth = PlatformScrollbar::verticalScrollbarWidth();
    const int cHorizontalHeight = PlatformScrollbar::horizontalScrollbarHeight();

    for (int pass = 0; pass < 2; pass++) {
        bool scrollsVertically;
        bool scrollsHorizontally;

        if (!m_data->m_scrollbarsSuppressed && (hScroll == ScrollbarAuto || vScroll == ScrollbarAuto)) {
            // Do a layout if pending before checking if scrollbars are needed.
            if (hasVerticalScrollbar != oldHasVertical || hasHorizontalScrollbar != oldHasHorizontal)
                static_cast<FrameView*>(this)->layout();

            scrollsVertically = (vScroll == ScrollbarAlwaysOn) || (vScroll == ScrollbarAuto && contentsHeight() > height());
            if (scrollsVertically)
                scrollsHorizontally = (hScroll == ScrollbarAlwaysOn) || (hScroll == ScrollbarAuto && contentsWidth() + cVerticalWidth > width());
            else {
                scrollsHorizontally = (hScroll == ScrollbarAlwaysOn) || (hScroll == ScrollbarAuto && contentsWidth() > width());
                if (scrollsHorizontally)
                    scrollsVertically = (vScroll == ScrollbarAlwaysOn) || (vScroll == ScrollbarAuto && contentsHeight() + cHorizontalHeight > height());
            }
        }
        else {
            scrollsHorizontally = (hScroll == ScrollbarAuto) ? hasHorizontalScrollbar : (hScroll == ScrollbarAlwaysOn);
            scrollsVertically = (vScroll == ScrollbarAuto) ? hasVerticalScrollbar : (vScroll == ScrollbarAlwaysOn);
        }
        
        if (hasVerticalScrollbar != scrollsVertically) {
            m_data->setHasVerticalScrollbar(scrollsVertically);
            hasVerticalScrollbar = scrollsVertically;
        }

        if (hasHorizontalScrollbar != scrollsHorizontally) {
            m_data->setHasHorizontalScrollbar(scrollsHorizontally);
            hasHorizontalScrollbar = scrollsHorizontally;
        }
    }
    
    // Set up the range (and page step/line step).
    IntSize maxScrollPosition(contentsWidth() - visibleWidth(), contentsHeight() - visibleHeight());
    IntSize scroll = desiredOffset.shrunkTo(maxScrollPosition);
    scroll.clampNegativeToZero();
 
    if (m_data->m_hBar) {
        int clientWidth = visibleWidth();
        m_data->m_hBar->setEnabled(contentsWidth() > clientWidth);
        int pageStep = (clientWidth - PAGE_KEEP);
        if (pageStep < 0) pageStep = clientWidth;
        IntRect oldRect(m_data->m_hBar->frameGeometry());
        IntRect hBarRect = IntRect(0,
                                   height() - m_data->m_hBar->height(),
                                   width() - (m_data->m_vBar ? m_data->m_vBar->width() : 0),
                                   m_data->m_hBar->height());
        m_data->m_hBar->setRect(hBarRect);
        if (!m_data->m_scrollbarsSuppressed && oldRect != m_data->m_hBar->frameGeometry())
            m_data->m_hBar->invalidate();

        if (m_data->m_scrollbarsSuppressed)
            m_data->m_hBar->setSuppressInvalidation(true);
        m_data->m_hBar->setSteps(LINE_STEP, pageStep);
        m_data->m_hBar->setProportion(clientWidth, contentsWidth());
        m_data->m_hBar->setValue(scroll.width());
        if (m_data->m_scrollbarsSuppressed)
            m_data->m_hBar->setSuppressInvalidation(false); 
    } 

    if (m_data->m_vBar) {
        int clientHeight = visibleHeight();
        m_data->m_vBar->setEnabled(contentsHeight() > clientHeight);
        int pageStep = (clientHeight - PAGE_KEEP);
        if (pageStep < 0) pageStep = clientHeight;
        IntRect oldRect(m_data->m_vBar->frameGeometry());
        IntRect vBarRect = IntRect(width() - m_data->m_vBar->width(), 
                                   0,
                                   m_data->m_vBar->width(),
                                   height() - (m_data->m_hBar ? m_data->m_hBar->height() : 0));
        m_data->m_vBar->setRect(vBarRect);
        if (!m_data->m_scrollbarsSuppressed && oldRect != m_data->m_vBar->frameGeometry())
            m_data->m_vBar->invalidate();

        if (m_data->m_scrollbarsSuppressed)
            m_data->m_vBar->setSuppressInvalidation(true);
        m_data->m_vBar->setSteps(LINE_STEP, pageStep);
        m_data->m_vBar->setProportion(clientHeight, contentsHeight());
        m_data->m_vBar->setValue(scroll.height());
        if (m_data->m_scrollbarsSuppressed)
            m_data->m_vBar->setSuppressInvalidation(false);
    }

    if (oldHasVertical != (m_data->m_vBar != 0) || oldHasHorizontal != (m_data->m_hBar != 0))
        geometryChanged();

    // See if our offset has changed in a situation where we might not have scrollbars.
    // This can happen when editing a body with overflow:hidden and scrolling to reveal selection.
    // It can also happen when maximizing a window that has scrollbars (but the new maximized result
    // does not).
    IntSize scrollDelta = scroll - m_data->m_scrollOffset;
    if (scrollDelta != IntSize()) {
       m_data->m_scrollOffset = scroll;
       m_data->scrollBackingStore(scrollDelta);
    }

    m_data->m_inUpdateScrollbars = false;
}
Beispiel #20
0
void STUserProfileView::relayoutContents(){

    if(size().isEmpty())
        return;

    bool loaded=false;
    if(m_lastWidth!=contentsWidth() && m_user){
        m_lastWidth=contentsWidth();
        loaded=true;
    }

    int right=(int)contentsWidth()-10;
    int zero=10;
    int width=right-zero;
    int oneThird=width/3+zero;
    int twoThird=(width*2)/3+zero;
    int half=width/2+zero;

    m_followersView->setPos(zero, 10);
    m_followersView->setSize(QSize(half-zero, 43));
    m_friendsView->setPos(half-1, 10);
    m_friendsView->setSize(QSize(right-(half-1), 43));

    m_tweetsView->setPos(zero, 58);
    m_tweetsView->setSize(QSize(oneThird-zero, 43));
    m_favoritesView->setPos(oneThird-1, 58);
    m_favoritesView->setSize(QSize(twoThird-(oneThird-1), 43));
    m_listedView->setPos(twoThird-1, 58);
    m_listedView->setSize(QSize(right-(twoThird-1), 43));

    int cy=58+43+10;
    int labelPos=10;
    int textPos=0;
    textPos=qMax(textPos, (int)m_bioLabel->boundingRect().right());
    textPos=qMax(textPos, (int)m_urlLabel->boundingRect().right());
    textPos=qMax(textPos, (int)m_locLabel->boundingRect().right());
    textPos=qMax(textPos, (int)m_sinceLabel->boundingRect().right());
    textPos+=10+labelPos;

    float textWidth=(float)(right-textPos);

    m_bioLabel->setPos(labelPos, cy+3);
    if(loaded){
        QMutexLocker locker(&(m_user->mutex));
        m_bioText->setContents(STFont::defaultFont(),
                               m_user->displayDescription,
                               m_user->descriptionEntityRanges,
                               textWidth, false, 3.f);
    }
    m_bioText->setPos(textPos, (float)cy-m_bioText->boundingRect().top());

    cy+=(int)qMax(m_bioText->boundingRect().height(),m_bioLabel->boundingRect().bottom());
    cy+=10;


    m_urlLabel->setPos(labelPos, cy+3);
    if(loaded){
        QMutexLocker locker(&(m_user->mutex));
        m_urlText->setContents(STFont::defaultFont(),
                               m_user->displayUrl,
                               m_user->urlEntityRanges,
                               textWidth, false, 3.f);
    }
    m_urlText->setPos(textPos, (float)cy-m_urlText->boundingRect().top());

    cy+=(int)qMax(m_urlText->boundingRect().height(),m_urlLabel->boundingRect().bottom());
    cy+=10;


    m_locLabel->setPos(labelPos, cy+3);
    if(loaded){
        QString text;
        {
            QMutexLocker locker(&(m_user->mutex));
            text=m_user->data["location"].toString();
        }
        m_locText->setContents(STFont::defaultFont(),
                               text,
                               textWidth, false, 3.f);
    }
    m_locText->setPos(textPos, (float)cy-m_locText->boundingRect().top());

    cy+=(int)qMax(m_locText->boundingRect().height(),m_locLabel->boundingRect().bottom());
    cy+=10;


    m_sinceLabel->setPos(labelPos, cy+3);
    if(loaded){
        QString text;
        {
            QMutexLocker locker(&(m_user->mutex));
            text=m_user->data["created_at"].toString();
        }
        QDateTime dat=STParseDateTimeRFC2822(text);
        text=STDateFormatter::toLongDateTimeString(dat); //QLocale::system().toString(dat, QLocale::ShortFormat);
        m_sinceText->setContents(STFont::defaultFont(),
                               text,
                                 textWidth, false, 3.f);
    }
    m_sinceText->setPos(textPos, (float)cy-m_sinceText->boundingRect().top());

    cy+=(int)qMax(m_sinceText->boundingRect().height(),m_sinceLabel->boundingRect().bottom());
    cy+=10;


    setContentsHeight(cy);
}
void CommandListEditor::adjustCols()
{
	int w=width();
	TableEditor::adjustCols();
	setColumnWidth(1,max(columnWidth(1),w-contentsWidth()));
}
Beispiel #22
0
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();
}
Beispiel #23
0
QSize QVFbView::sizeHint() const
{
    int f = 2 * frameWidth();
    return QSize( contentsWidth() + f, contentsHeight() + f );
}