Example #1
0
void KstEditViewObjectDialogI::fillPenStyleWidget(QComboBox* widget) {
  QRect rect = widget->style().querySubControlMetrics(QStyle::CC_ComboBox, 
                                                      widget, 
                                                      QStyle::SC_ComboBoxEditField);
  rect.setLeft(rect.left() + 2);
  rect.setRight(rect.right() - 2);
  rect.setTop(rect.top() + 2);
  rect.setBottom(rect.bottom() - 2);

  // fill the combo with pen styles
  QPixmap ppix(rect.width(), rect.height());
  QPainter pp(&ppix);
  QPen pen(Qt::black, 0);

  widget->clear(); 
  
  QValueList<Qt::PenStyle> styles;
  styles.append(Qt::SolidLine);
  styles.append(Qt::DashLine);
  styles.append(Qt::DotLine);
  styles.append(Qt::DashDotLine);
  styles.append(Qt::DashDotDotLine);
  
  while (!styles.isEmpty()) {
    pen.setStyle(styles.front());
    pp.setPen(pen);
    pp.fillRect( pp.window(), QColor("white"));
    pp.drawLine(1,ppix.height()/2,ppix.width()-1, ppix.height()/2);
    widget->insertItem(ppix);
    styles.pop_front();
  }
}
// The rect of a scale without the title
QRect ScalePicker::scaleRect(const QwtScaleWidget *scale) const
{
	int margin = 1; // pixels tolerance
	QRect rect = scale->rect();
	rect.setRect(rect.x() - margin, rect.y() - margin, rect.width() + 2 * margin, rect.height() +  2 * margin);

	if (scale->title().text().isEmpty())
		return rect;

	int dh = scale->title().textSize().height();
	switch(scale->alignment())
	{
		case QwtScaleDraw::LeftScale:
			{
				rect.setLeft(rect.left() + dh);
				break;
			}
		case QwtScaleDraw::RightScale:
			{
				rect.setRight(rect.right() - dh);
				break;
			}
		case QwtScaleDraw::BottomScale:
			{
				rect.setBottom(rect.bottom() - dh);
				break;
			}
		case QwtScaleDraw::TopScale:
			{
				rect.setTop(rect.top() + dh);
				break;
			}
	}
	return rect;
}
/*!
  \brief draw the scale
*/
void QwtScaleWidget::draw( QPainter *painter ) const
{
    d_data->scaleDraw->draw( painter, palette() );

    if ( d_data->colorBar.isEnabled && d_data->colorBar.width > 0 &&
        d_data->colorBar.interval.isValid() )
    {
        drawColorBar( painter, colorBarRect( contentsRect() ) );
    }

    QRect r = contentsRect();
    if ( d_data->scaleDraw->orientation() == Qt::Horizontal )
    {
        r.setLeft( r.left() + d_data->borderDist[0] );
        r.setWidth( r.width() - d_data->borderDist[1] );
    }
    else
    {
        r.setTop( r.top() + d_data->borderDist[0] );
        r.setHeight( r.height() - d_data->borderDist[1] );
    }

    if ( !d_data->title.isEmpty() )
        drawTitle( painter, d_data->scaleDraw->alignment(), r );
}
Example #4
0
// Draw a dragging separator line.
void qtractorFileListView::moveRubberBand ( QTreeWidgetItem *pDropItem, bool bOutdent )
{
	// Is there any item upon we migh drop anything?
	if (pDropItem == NULL) {
		if (m_pRubberBand)
			m_pRubberBand->hide();
		return;
	}

	// Create the rubber-band if there's none...
	if (m_pRubberBand == NULL) {
		m_pRubberBand = new qtractorRubberBand(
			QRubberBand::Line, QTreeWidget::viewport());
	#if 0
		QPalette pal(m_pRubberBand->palette());
		pal.setColor(m_pRubberBand->foregroundRole(), Qt::blue);
		m_pRubberBand->setPalette(pal);
		m_pRubberBand->setBackgroundRole(QPalette::NoRole);
	#endif
	}

	// Just move it
	QRect rect = QTreeWidget::visualItemRect(pDropItem);
	if (pDropItem->type() == GroupItem && !bOutdent)
		rect.setX(rect.x() + QTreeWidget::indentation());
	rect.setTop(rect.bottom() + 1);
	rect.setHeight(3);
	m_pRubberBand->setGeometry(rect);

	// Ah, and make it visible, of course...
	if (!m_pRubberBand->isVisible())
		m_pRubberBand->show();
}
Example #5
0
static void alignY(QWidget *a, const QWidget *b){
  QRect ar = a->geometry();
  int h = ar.height();
  ar.setTop(b->geometry().top());
  ar.setHeight(h);
  a->setGeometry(ar);
}
Example #6
0
QRectF
ComboBox::layoutRect() const
{
    QRect cr = contentsRect();
    Qt::Alignment align = QStyle::visualAlignment( Qt::LeftToRight, QFlag(_align) );
    int indent = fontMetrics().width( QLatin1Char('x') ) / 2;

    if (indent > 0) {
        if (align & Qt::AlignLeft) {
            cr.setLeft(cr.left() + indent);
        }

        if (align & Qt::AlignRight) {
            cr.setRight(cr.right() - indent);
        }

        if (align & Qt::AlignTop) {
            cr.setTop(cr.top() + indent);
        }

        if (align & Qt::AlignBottom) {
            cr.setBottom(cr.bottom() - indent);
        }
    }
    cr.adjust(0, 0, -DROP_DOWN_ICON_SIZE * 2, 0);

    return cr;
}
void BachelorThesis::adjustRoiSize( const QRect & srcRoi, QRect & dstRoi, const QPoint & maxSize )
{
	dstRoi = srcRoi;
	if( srcRoi.x() < 0 )
	{
		dstRoi.setLeft( 0 );
	}
	if( srcRoi.y() < 0 )
	{
		dstRoi.setTop( 0 );
	}
	if( srcRoi.right() >= maxSize.x() )
	{
		dstRoi.setRight( maxSize.x() - 2 );
	}

	if( srcRoi.bottom() >= maxSize.y() )
	{
		dstRoi.setBottom( maxSize.y() - 2 );
	}
	if( srcRoi.isEmpty() )
	{
		dstRoi = QRect( 0, 0, maxSize.x(), maxSize.y() );
	}
}
Example #8
0
void
PrettyPopupMenu::paintEvent( QPaintEvent* e )
{
    generateSidePixmap();

    QPainter p( this );

    QRect r = sideImageRect();
    r.setTop( r.bottom() - s_sidePixmap.height() );
    if ( r.intersects( e->rect() ) )
    {
        QRect drawRect = r.intersect( e->rect() ).intersect( sideImageRect() );
        QRect pixRect = drawRect;
        pixRect.moveBy( -r.left(), -r.top() );
        p.drawImage( drawRect.topLeft(), s_sidePixmap, pixRect );
    }

    p.setClipRegion( e->region() );


    //NOTE The order is important here. drawContents() must be called before drawPrimitive(),
    //     otherwise we get rendering glitches.

    drawContents( &p );

    style().drawPrimitive( QStyle::PE_PanelPopup, &p,
                           QRect( 0, 0, width(), height() ),
                           colorGroup(), QStyle::Style_Default,
                           QStyleOption( frameWidth(), 0 ) );
}
Example #9
0
void QVistaHelper::mouseMoveEvent(QMouseEvent *event)
{
    if (wizard->windowState() & Qt::WindowMaximized) {
        event->ignore();
        return;
    }

    QRect rect = wizard->geometry();
    if (pressed) {
        switch (change) {
        case resizeTop:
            {
                const int dy = event->pos().y() - pressedPos.y();
                if ((dy > 0 && rect.height() > wizard->minimumHeight())
                    || (dy < 0 && rect.height() < wizard->maximumHeight()))
                    rect.setTop(rect.top() + dy);
            }
            break;
        case movePosition: {
            QPoint newPos = event->pos() - pressedPos;
            rect.moveLeft(rect.left() + newPos.x());
            rect.moveTop(rect.top() + newPos.y());
            break; }
        default:
            break;
        }
        wizard->setGeometry(rect);

    } else if (vistaState() == VistaAero) {
        setMouseCursor(event->pos());
    }
    event->ignore();
}
Example #10
0
SlmUi::SlmUi(QWidget* _uiPanel)
{


    ztpm = new ZTPManager(3320,QHostAddress("224.102.228.40"));
    connect(ztpm,SIGNAL(readyRead()),this,SLOT(procNetPkg()));
    int table_w = 260;
    int table_h = 350;
    table1 = new QTableWidget(0,2,_uiPanel);

    table1->resize(table_w,table_h);
    QString headerStr("slm1,slm2");
    table1->setHorizontalHeaderLabels(headerStr.split(QChar(',')));

    QRect rect =  table1->geometry();

    rect.setLeft(_uiPanel->size().width()/2- 20 -table_w);
    rect.setTop((_uiPanel->size().height() - table_h)/3);
    rect.setWidth(table_w);
    rect.setHeight(table_h);

    table1->setGeometry(rect);
    table2 = new QTableWidget(0,2,_uiPanel);
    table2->setHorizontalHeaderLabels(headerStr.split(QChar(',')));
    rect.setLeft(_uiPanel->size().width()/2+ 20);
    rect.setWidth(table_w);
    rect.setHeight(table_h);
    table2->setGeometry(rect);

    table1->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
    table2->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
}
Example #11
0
void SxButton::paintEvent(QPaintEvent *event)
{
    QPoint mousePos = mapFromGlobal(QCursor::pos());
    bool selected = rect().contains(mousePos);

    QPainter painter(this);

    QRect drawRect = event->rect();
    if (drawRect.width() > m_width)
    {
        int margin = (drawRect.width() - m_width) / 2;
        int left = drawRect.left() + margin;
        drawRect.setLeft(left);
        drawRect.setWidth(m_width);
    }
    if (drawRect.height() > m_height)
    {
        int margin = (drawRect.height() - m_height) / 2;
        int top = drawRect.top() + margin;
        drawRect.setTop(top);
        drawRect.setHeight(m_height);
    }

    if (isEnabled()) {
    if (isDown())
        painter.drawPixmap(drawRect, m_pixmapDown);
    else if (selected)
        painter.drawPixmap(drawRect, m_pixmapSelected);
    else
        painter.drawPixmap(drawRect, m_pixmap);
    }
    else
        painter.drawPixmap(drawRect, m_pixmap);

}
QRect MultiContainerWidget::selectionRect() const
{
    if ( _isSelected ) {
        return QRect( mapToGlobal( QPoint(0,0) ), size() );
    } else {
        QRect res;
        QList<RegExpWidget *>::const_iterator it = _children.constBegin();
        ++it; // Move past the first dragAccepter
        for ( ; it != _children.constEnd() ; it +=2 ) {
            if ( (*it)->hasSelection() ) {
                QRect childSel = (*it)->selectionRect();
                if ( res.isNull() ) {
                    res = childSel;
                } else {
                    QRect newRes;
                    newRes.setLeft( qMin( res.left(), childSel.left() ) );
                    newRes.setTop( qMin( res.top(), childSel.top() ) );
                    newRes.setRight( qMax( res.right(), childSel.right() ) );
                    newRes.setBottom( qMax( res.bottom(), childSel.bottom() ) );
                    res = newRes;
                }
            }
        }
        return res;
    }
}
	void SpeechTranscriptionWidget::transcriberModel_playingSampleIndChanged(long oldPlayingSampleInd)
	{
		QRect updateRect = ui->widgetSamples->rect();

		auto playingSampleInd = transcriberModel_->playingSampleInd();
		if (oldPlayingSampleInd != PticaGovorun::NullSampleInd && playingSampleInd != PticaGovorun::NullSampleInd)
		{
			assert(oldPlayingSampleInd <= playingSampleInd && "Audio must be played forward?");

			auto minSampleInd = oldPlayingSampleInd;
			auto maxSampleInd = playingSampleInd;

			auto leftX = transcriberModel_->sampleIndToDocPosX(minSampleInd);
			auto rightX = transcriberModel_->sampleIndToDocPosX(maxSampleInd);

			// repaint optimization when caret moves inside one lane
			ViewportHitInfo hitLeft;
			ViewportHitInfo hitRight;
			if (transcriberModel_->docPosToViewport(leftX, hitLeft) &&
				transcriberModel_->docPosToViewport(rightX, hitRight) &&
				hitLeft.LaneInd == hitRight.LaneInd)
			{
				RectY laneY = transcriberModel_->laneYBounds(hitLeft.LaneInd);

				const static int VerticalMarkerWidth = 1;
				updateRect.setLeft(hitLeft.DocXInsideLane - VerticalMarkerWidth);
				updateRect.setRight(hitRight.DocXInsideLane + VerticalMarkerWidth);
				updateRect.setTop(laneY.Top);
				updateRect.setBottom(laneY.Top + laneY.Height);
			}
		}

		ui->widgetSamples->update(updateRect);
	}
Example #14
0
void PanelKMenu::paintEvent(QPaintEvent * e)
{
    if (sidePixmap.isNull()) {
        PanelServiceMenu::paintEvent(e);
        return;
    }

    QPainter p(this);
    p.setClipRegion(e->region());

    style().drawPrimitive( QStyle::PE_PanelPopup, &p,
                           QRect( 0, 0, width(), height() ),
                           colorGroup(), QStyle::Style_Default,
                           QStyleOption( frameWidth(), 0 ) );

    QRect r = sideImageRect();
    r.setBottom( r.bottom() - sidePixmap.height() );
    if ( r.intersects( e->rect() ) )
    {
        p.drawTiledPixmap( r, sideTilePixmap );
    }

    r = sideImageRect();
    r.setTop( r.bottom() - sidePixmap.height() );
    if ( r.intersects( e->rect() ) )
    {
        QRect drawRect = r.intersect( e->rect() );
        QRect pixRect = drawRect;
        pixRect.moveBy( -r.left(), -r.top() );
        p.drawPixmap( drawRect.topLeft(), sidePixmap, pixRect );
    }

    drawContents( &p );
}
Example #15
0
//设置鼠标拖动的窗口位置信息
void MainFrame::SetDrayMove(int nXGlobal,int nYGlobal,enum_Direction direction)
{
    //计算偏差
    int ndX = nXGlobal - m_ptPressGlobal.x();
    int ndY = nYGlobal - m_ptPressGlobal.y();
    //获得主窗口位置信息
    QRect rectWindow = geometry();
    //判别方向
    if(direction & eTop)
    {
        rectWindow.setTop(rectWindow.top()+ndY);
    }
    if(direction & eRight)
    {
        rectWindow.setRight(rectWindow.right()+ndX);
    }
    if(direction & eBottom)
    {
        rectWindow.setBottom(rectWindow.bottom()+ndY);
    }
    if(direction & eLeft)
    {
        rectWindow.setLeft(rectWindow.left()+ndX);
    }
    if(rectWindow.width()< minimumWidth() || rectWindow.height()<minimumHeight())
    {
        return;
    }
    //重新设置窗口位置为新位置信息
    setGeometry(rectWindow);
}
QRect MyGraphicsView::getViewableRect() const
{
    if (mScene->items().size() == 0)
        return QRect();

    QRect r =
            mapToScene( viewport()->geometry() ).boundingRect().toRect();

    //qDebug() << "Rect " << r;

    if ( r.top() < 0 )
        r.setTop(0);

    if ( r.left() < 0 )
        r.setLeft(0);

    // get only intersection between pixmap and region
    #ifdef QT4
    r = r.intersect( mScene->sceneRect().toRect() );
    #else
    r = r.intersected( mScene->sceneRect().toRect() );
    #endif

    //qDebug() << "Rect2 " << r;

    return r;
}
Example #17
0
bool WizAttachmentListView::itemExtraImage(const QModelIndex& index, const QRect& itemBound, QRect& rcImage, QPixmap& extraPix) const
{
    if (const WizAttachmentListViewItem* item = attachmentItemFromIndex(index))
    {
        QString strIconPath;
        WizDatabase& db = m_dbMgr.db(item->attachment().strKbGUID);
        WizMainWindow* mainWindow = WizGlobal::mainWindow();
        bool isRetina = WizIsHighPixel();
        strIconPath = ::WizGetSkinResourcePath(mainWindow->userSettings().skin());
        if (!db.isAttachmentDownloaded(item->attachment().strGUID))
        {
            strIconPath += isRetina ? "*****@*****.**" : "document_needDownload.png";
        }
        else if (db.isAttachmentModified(item->attachment().strGUID))
        {
            strIconPath += isRetina ? "*****@*****.**" : "document_needUpload.png";
        }
        else
            return false;

        extraPix = QPixmap(strIconPath);
        QSize szImage = extraPix.size();
        WizScaleIconSizeForRetina(szImage);
        int nMargin = -1;
        rcImage.setLeft(itemBound.right() - szImage.width() - nMargin);
        rcImage.setTop(itemBound.bottom() - szImage.height() - nMargin);
        rcImage.setSize(szImage);

        return true;
    }

    return false;
}
Example #18
0
/** Redefined to display an editable area. */
void TabBar::mouseDoubleClickEvent(QMouseEvent *event)
{
	int tabIndex = tabAt(event->pos());
	int c = currentIndex();
	if (-1 < tabIndex && tabIndex < count() && c == tabIndex) {
		QRect visualRect = tabRect(tabIndex);
		SettingsPrivate *settings = SettingsPrivate::instance();
		if (settings->isRectTabs()) {
			visualRect.setLeft(visualRect.left() + 1);
			visualRect.setRight(visualRect.right() - 1);
		} else {
			visualRect.setLeft(visualRect.left() + 3 + settings->tabsOverlappingLength() * 1.25 + height() / 2);
			visualRect.setRight(visualRect.right() - settings->tabsOverlappingLength());
		}
		visualRect.setTop(visualRect.top() + 1);

		// Disable close buttons in case of unfortunate click
		for (int t = 0; t < count(); t++) {
			QWidget *button = tabButton(t, QTabBar::RightSide);
			if (button && t != tabIndex) {
				button->setEnabled(false);
			}
		}

		// Feed the QLineEdit with current tab text
		lineEdit->setText(tabText(tabIndex));
		lineEdit->selectAll();
		lineEdit->setFocus();
		lineEdit->setGeometry(visualRect);
		lineEdit->setVisible(true);
		lineEdit->grabMouse();
	}
	QTabBar::mouseDoubleClickEvent(event);
}
Example #19
0
void ItemDocument::resizeCanvasToItems() {
	QRect bound = canvasBoundingRect();

	m_viewList.remove((View*)0);
	const ViewList::iterator end = m_viewList.end();

	for (ViewList::iterator it = m_viewList.begin(); it != end; ++it) {
		ItemView * iv = static_cast<ItemView*>((View*) * it);
		CVBEditor * cvbEditor = iv->cvbEditor();

		QPoint topLeft = iv->mousePosToCanvasPos(QPoint(0, 0));
		int width = int(cvbEditor->visibleWidth() / iv->zoomLevel());
		int height = int(cvbEditor->visibleHeight() / iv->zoomLevel());
		QRect r(topLeft, QSize(width, height));

		bound |= r;

// 		kdDebug() << "r="<<r<<endl;
// 		kdDebug() << "bound="<<bound<<endl;
	}

	// Make it so that the rectangular offset is a multiple of 8
	bound.setLeft(bound.left() - (bound.left() % 8));
	bound.setTop(bound.top() - (bound.top() % 8));
	m_pUpdateItemViewScrollbarsTimer->start(10, true);

	bool changedSize = canvas()->rect() != bound;
	if (changedSize) {
		canvas()->resize(bound);
		requestEvent(ItemDocumentEvent::ResizeCanvasToItems);
	} else if (ICNDocument * icnd = dynamic_cast<ICNDocument*>(this)) {
		icnd->createCellMap();
	}
}
Example #20
0
STDMETHODIMP UIFrameBuffer::SetVisibleRegion(BYTE *pRectangles, ULONG uCount)
{
    PRTRECT rects = (PRTRECT)pRectangles;

    if (!rects)
        return E_POINTER;

    QRegion reg;
    for (ULONG ind = 0; ind < uCount; ++ ind)
    {
        QRect rect;
        rect.setLeft(rects->xLeft);
        rect.setTop(rects->yTop);
        /* QRect are inclusive */
        rect.setRight(rects->xRight - 1);
        rect.setBottom(rects->yBottom - 1);
        reg += rect;
        ++ rects;
    }
    lock();  /* See comment in setView(). */
    if (m_pMachineView)
        QApplication::postEvent(m_pMachineView, new UISetRegionEvent(reg));
    unlock();

    return S_OK;
}
    //____________________________________________________________________________________
    void FlatFrameShadow::updateGeometry()
    {

        QWidget *widget = parentWidget();
        if( !widget ) return;

        QRect cr = widget->contentsRect();
        switch (shadowArea())
        {

            case Top:
            cr.setHeight( SHADOW_SIZE_TOP-3 );
            break;

            case Bottom:
            cr.setTop(cr.bottom() - SHADOW_SIZE_BOTTOM + 4);
            break;

            case Unknown:
            default:
            return;
        }

        setGeometry(cr);
    }
bool CWizAttachmentListView::itemExtraImage(const QModelIndex& index, const QRect& itemBound, QRect& rcImage, QPixmap& extraPix) const
{
    if (const CWizAttachmentListViewItem* item = attachmentItemFromIndex(index))
    {
        QString strIcoPath;
        CWizDatabase& db = m_dbMgr.db(item->attachment().strKbGUID);
        MainWindow* mainWindow = qobject_cast<MainWindow *>(Core::ICore::mainWindow());
        if (!db.IsAttachmentDownloaded(item->attachment().strGUID))
        {
            strIcoPath = ::WizGetSkinResourcePath(mainWindow->userSettings().skin()) + "downloading.bmp";
        }
        else if (db.IsAttachmentModified(item->attachment().strGUID))
        {
            strIcoPath = ::WizGetSkinResourcePath(mainWindow->userSettings().skin()) + "uploading.bmp";
        }
        else
            return false;

        QPixmap fullPix(strIcoPath);
        extraPix = fullPix.copy(0, 0, fullPix.height(), fullPix.height());
        extraPix.setMask(extraPix.createMaskFromColor(Qt::black, Qt::MaskInColor));
        int nMargin = -1;
        rcImage.setLeft(itemBound.right() - extraPix.width() - nMargin);
        rcImage.setTop(itemBound.bottom() - extraPix.height() - nMargin);
        rcImage.setSize(extraPix.size());

        return true;
    }

    return false;
}
Example #23
0
// -----------------------------------------------------
// Override QWidget
// -----------------------------------------------------
void ReImagePanel::paintEvent( QPaintEvent* _event )
{
	QPainter painter( this );

	TItemListCItor itor = m_itemList.begin();
	TItemListCItor itorEnd = m_itemList.end();
		
	for( ; itor != itorEnd; ++itor )
	{
		const ReImageItem* item = *itor;
		if( NULL != item )
		{
			if( IsItemVisible( item ) )
			{
				QRect rect;
				rect.setLeft( m_contentOrigin.x() + item->m_pos.x() );
				rect.setRight( rect.left() + m_currentItemSize );
				rect.setTop( m_contentOrigin.y() + item->m_pos.y() );
				rect.setBottom( rect.top() + m_currentItemSize );
				painter.drawImage( rect, *item->m_image );
			}
		}
	}

	// Debug.
	//painter.setPen( QColor( 255, 255, 255 ) );
	//QSize bv = GetBv();
	//painter.drawRect( m_contentOrigin.x(), m_contentOrigin.y(), bv.width(), bv.height() );
}
Example #24
0
void SdfIconEngineV2::paint(QPainter *painter, QRect const &rect, QIcon::Mode mode, QIcon::State state)
{
	Q_UNUSED(mode)
	Q_UNUSED(state)
	painter->eraseRect(rect);
	int rh = rect.height();
	int rw = rect.width();

	int ph = mRenderer.pictureHeight();
	int pw = mRenderer.pictureWidth();
	if (pw == 0 || ph == 0) { // SUDDENLY!!11
		return;
	}
	// Take picture aspect into account
	QRect resRect = rect;
	if (rh * pw < ph * rw) {
		resRect.setLeft(rect.left() + (rw - rh * pw / ph) / 2);
		resRect.setRight(rect.right() - (rw - rh * pw / ph) / 2);
	}
	if (rh * pw > ph * rw) {
		resRect.setTop(rect.top() + (rh - rw * ph / pw) / 2);
		resRect.setBottom(rect.bottom() - (rh - rw * ph / pw) / 2);
	}
	painter->setRenderHint(QPainter::Antialiasing, true);
	mRenderer.render(painter, resRect, true);
}
Example #25
0
static void alignYAfter(QWidget *a, const QWidget *b){
  QRect ar = a->geometry();
  int h = ar.height();
  ar.setTop(b->geometry().bottom()+10);
  ar.setHeight(h);
  a->setGeometry(ar);
}
Example #26
0
void QBspTree::init(const QRect &area, int depth, NodeType type, int index)
{
    Node::Type t = Node::None; // t should never have this value
    if (type == Node::Both) // if both planes are specified, use 2d bsp
        t = (depth & 1) ? Node::HorizontalPlane : Node::VerticalPlane;
    else
        t = type;
    QPoint center = area.center();
    nodes[index].pos = (t == Node::VerticalPlane ? center.x() : center.y());
    nodes[index].type = t;

    QRect front = area;
    QRect back = area;

    if (t == Node::VerticalPlane) {
        front.setLeft(center.x());
        back.setRight(center.x() - 1); // front includes the center
    } else { // t == Node::HorizontalPlane
        front.setTop(center.y());
        back.setBottom(center.y() - 1);
    }

    int idx = firstChildIndex(index);
    if (--depth) {
        init(back, depth, type, idx);
        init(front, depth, type, idx + 1);
    }
}
Example #27
0
QRect ScalePicker::titleRect(const QwtScaleWidget *scale) const
{
	if (scale->title().text().isEmpty())
		return QRect();

	QRect rect = scale->rect();
	int margin = scale->margin();
	rect = rect.adjusted (margin, margin, -margin, -margin);

	int dh = scale->title().textSize().height();
	switch(scale->alignment())
	{
		case QwtScaleDraw::LeftScale:
			{
				rect.setRight(rect.left() + dh);
				break;
			}
		case QwtScaleDraw::RightScale:
			{
				rect.setLeft(rect.right() - dh);
				break;
			}
		case QwtScaleDraw::BottomScale:
			{
				rect.setTop(rect.bottom() - dh);
				break;
			}
		case QwtScaleDraw::TopScale:
			{
				rect.setBottom(rect.top() + dh);
				break;
			}
	}
	return rect;
}
Example #28
0
void RenderThread::UpdateLayout()
{
	QMutexLocker locker(&m_MutexLayout);

	// Find frames without layout info and delete them
	QMutableListIterator<FramePtr> i(m_RenderFrames);
	while (i.hasNext()) 
	{
		FramePtr renderFrame = i.next();
		if (!renderFrame)
		{
			i.remove();
			continue;
		}

		int j = m_ViewIDs.indexOf(renderFrame->Info(VIEW_ID).toUInt());
		if (j == -1)
		{
			m_Renderer->Deallocate(renderFrame);
			i.remove();
		}else
		{
			QRect srcRect = m_SrcRects.at(j);
			float scaleX = renderFrame->Info(RENDER_SRC_SCALE_X).toFloat();
			float scaleY = renderFrame->Info(RENDER_SRC_SCALE_Y).toFloat();
			srcRect.setLeft((int)(srcRect.left()*scaleX));
			srcRect.setRight((int)(srcRect.right()*scaleX));
			srcRect.setTop((int)(srcRect.top()*scaleY));
			srcRect.setBottom((int)(srcRect.bottom()*scaleY));

			renderFrame->SetInfo(SRC_RECT, srcRect);
			renderFrame->SetInfo(DST_RECT, m_DstRects.at(j));
		}
	}
}
Example #29
0
    virtual void draw(QPainter *painter,
                      const QwtScaleMap &, const QwtScaleMap &yMap,
                      const QRect &rect) const
    {
        RideItem *rideItem = parent->rideItem;

        if (! rideItem)
            return;

        const Zones *zones       = rideItem->zones;
        int zone_range     = rideItem->zoneRange();
        if (parent->shadeZones() && (zone_range >= 0)) {
            QList <int> zone_lows = zones->getZoneLows(zone_range);
            int num_zones = zone_lows.size();
            if (num_zones > 0) {
                for (int z = 0; z < num_zones; z ++) {
                    QRect r = rect;

                    QColor shading_color = zoneColor(z, num_zones);
                    shading_color.setHsv(
                        shading_color.hue(),
                        shading_color.saturation() / 4,
                        shading_color.value()
                        );
                    r.setBottom(yMap.transform(zone_lows[z]));
                    if (z + 1 < num_zones)
                        r.setTop(yMap.transform(zone_lows[z + 1]));
                    if (r.top() <= r.bottom())
                        painter->fillRect(r, shading_color);
                }
            }
        } else {
        }
    }
Example #30
0
QRect SheetPrint::cellRange(int page) const
{
    if (d->m_lnewPageListX.isEmpty() || d->m_lnewPageListY.isEmpty()) {
        return QRect();
    }
    if (page - 1 > pageCount()) {
        return QRect();
    }
    kDebug() << "page:" << page << "of" << pageCount();

    int horizontalIndex = 0;
    int verticalIndex = 0;
    if (d->m_settings->pageOrder() == PrintSettings::LeftToRight) {
        horizontalIndex = (page - 1) % d->m_lnewPageListX.count();
        verticalIndex = (page - 1) / d->m_lnewPageListX.count();
    } else {
        horizontalIndex = (page - 1) / d->m_lnewPageListY.count();
        verticalIndex = (page - 1) % d->m_lnewPageListY.count();
    }
    kDebug() << "horizontal:" << horizontalIndex + 1 << "of" << d->m_lnewPageListX.count();
    kDebug() << "vertical:" << verticalIndex + 1 << "of" << d->m_lnewPageListY.count();

    const PrintNewPageEntry horizontalParameters = d->m_lnewPageListX[horizontalIndex];
    const PrintNewPageEntry verticalParameters = d->m_lnewPageListY[verticalIndex];

    QRect cellRange;
    cellRange.setLeft(horizontalParameters.startItem());
    cellRange.setRight(horizontalParameters.endItem());
    cellRange.setTop(verticalParameters.startItem());
    cellRange.setBottom(verticalParameters.endItem());
    return cellRange;
}