int
KexiRelationsTableFieldList::globalY(const QString &item)
{
    Q3ListViewItem *i = findItem(item, 0);
    if (!i)
        return -1;
    int y = itemRect(i).y() + (itemRect(i).height() / 2);
    if (contentsY() > itemPos(i))
        y = 0;
    else if (y == 0)
        y = height();
    return mapToGlobal(QPoint(0, y)).y();
}
QRect KexiRelationsTableFieldList::drawItemHighlighter(QPainter *painter, Q3ListViewItem *item)
{
#ifdef __GNUC__
#warning TODO KexiRelationsTableFieldList::drawItemHighlighter() OK?
#endif
    if (painter) {
        QStyleOptionFocusRect option;
        option.initFrom(this);
        option.rect = itemRect(item);
        option.state |= QStyle::State_FocusAtBorder;
        style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, painter, this);
    }
    return itemRect(item);
}
void SearchInputHighlight::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    painter.setPen(SearchInputHighlightLineColor);
    painter.setBrush(SearchInputHighlightNormalBgColor);
    painter.drawRect(0, 0, width()-1, height()-1);

    for (int i = 0; i < m_instruments.count(); i++)
    {
        QRect itemRect(1, SearchInputHighlightItemMargin + i*SearchInputHighlightItemHeight, width()-2, SearchInputHighlightItemHeight);
        if (i == currentIndex())
        {
            painter.fillRect(itemRect, SearchInputHighlightActiveBgColor);
            painter.setPen(SearchInputHighlightActiveTextColor);
        }
        else
        {
            painter.setPen(SearchInputHighlightNormalTextColor);
        }
        QRect textRect = itemRect;
        textRect.setLeft(SearchInputHighlightItemMargin);
        textRect.setRight(width()-SearchInputHighlightItemMargin);
        painter.drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, m_instruments[i].name);
    }
}
Exemplo n.º 4
0
QRegion PieView::itemRegion(const QModelIndex &index) const
{
        if (!index.isValid())
                return QRegion();

        if (index.column() != 1)
                return itemRect(index);

        if (model()->data(index).toDouble() <= 0.0)
                return QRegion();

        double startAngle = 0.0;
        for (int row = 0; row < model()->rowCount(rootIndex()); ++row) {

                QModelIndex sliceIndex = model()->index(row, 1, rootIndex());
                double value = model()->data(sliceIndex).toDouble();

                if (value > 0.0) {
                        double angle = 360*value/totalValue;

                        if (sliceIndex == index) {
                                QPainterPath slicePath;
                                slicePath.moveTo(totalSize/2, totalSize/2);
                                slicePath.arcTo(margin, margin, margin+pieSize, margin+pieSize,
                                                startAngle, angle);
                                slicePath.closeSubpath();

                                return QRegion(slicePath.toFillPolygon().toPolygon());
                        }
                        startAngle += angle;
                }
        }

        return QRegion();
}
Exemplo n.º 5
0
void LineItem::updateChildGeometry(const QRectF &oldParentRect, const QRectF &newParentRect) {
  // parent has been resized: update the line's dimensions:

  // we would like to have lines in terms of relative endpoint locations,
  // but instead they are in terms of length (relative to parent width)
  // and angle, relative to the parent.
  qreal theta = rotationAngle()*M_PI/180.0;
  qreal oldL = relativeWidth()*oldParentRect.width();

  // we want to keep the endpoints fixed relative to the parent, so
  // we need to calculate new lengths and angles.
  qreal newDx = cos(theta)*oldL*newParentRect.width()/oldParentRect.width();
  qreal newDy = sin(theta)*oldL*newParentRect.height()/oldParentRect.height();
  qreal newWidth = sqrt(newDx*newDx + newDy*newDy);
  QTransform transform;
  transform.rotate(atan2(newDy, newDx)*180.0/M_PI);

  // my brain hurts less for rotations when we center the object at 0,0
  QRectF itemRect(-newWidth*0.5, -rect().height()*0.5,
                  newWidth, rect().height());

  // we don't now what the parents's origin is, so, add .x() and .y()
  setPos(relativeCenter().x() * newParentRect.width() + newParentRect.x(),
         relativeCenter().y() * newParentRect.height()+ newParentRect.y());
  setViewRect(itemRect, true);

  setTransform(transform);
  setRelativeWidth(newWidth / newParentRect.width());
}
Exemplo n.º 6
0
void WindowTree::onRenderItem( RenderContext & context, const RectInt & window, PointInt & pos, Item * pItem )
{
	WindowStyle * pStyle = windowStyle();
	ASSERT( pStyle );
	Font * pFont = windowStyle()->font();
	ASSERT( pFont );

	// get the depth of this item
	int depth = itemDepth( pItem );
	// determine the X position based on it's depth
	pos.x = window.left + (depth * m_Indent);
	// get the size of the label text
	SizeInt labelSize( pFont->size( pItem->sLabel ) );
	// determine the height of this item
	int height = (int)(labelSize.height + TREE_ITEM_BUFFER);
	RectInt itemRect( window.left, pos.y, window.right, pos.y + height );

	// check if this item is highlighted or not
	if ( m_CursorInWindow && itemRect.inRect( m_LastCursorPosition ) )
		onHighlight( pItem );

	PrimitiveMaterial::push( context.display(), WHITE, PrimitiveMaterial::ALPHA );

	if ( pItem->dwFlags & BUTTON )
	{
		bool expanded = (pItem->dwFlags & EXPANDED) != 0;
		Color backColor( expanded ? pStyle->backColor() * TREE_SHADE_COLOR : pStyle->backColor() );
		Color shadeColor( expanded ? pStyle->borderColor() * TREE_LIGHT_COLOR : pStyle->borderColor() * TREE_SHADE_COLOR );
		Color lightColor( expanded ? pStyle->borderColor() * TREE_SHADE_COLOR : pStyle->borderColor() * TREE_LIGHT_COLOR );

		// render the button
		pushBackground( context, itemRect, backColor, TREE_BUTTON_STYLE, TREE_BUTTON_BORDER );
		pushBorder( context, itemRect, lightColor, shadeColor, TREE_BUTTON_STYLE, TREE_BUTTON_BORDER );

		// draw glow around this object if the mouse is currently over this button
		if ( m_pCursorOver == pItem )
			pushGlow( context, itemRect, TREE_GLOW_SIZE, TREE_GLOW_INNER, TREE_GLOW_OUTER, TREE_BUTTON_STYLE, TREE_BUTTON_BORDER );

		// place the label in the center of the button
		PointInt labelPos( itemRect.center() - PointInt( labelSize.width / 2, labelSize.height / 2 ) );
		// draw the label
		Font::push( context.display(), pFont, labelPos, pItem->sLabel, pItem->cColor );
	}
	else
	{
		if ( m_pSelected == pItem )
			pushBackground( context, itemRect, pStyle->highColor(), 0, 0 );
		if ( m_pCursorOver == pItem )
			pushGlow( context, itemRect, TREE_GLOW_SIZE, TREE_GLOW_INNER, TREE_GLOW_OUTER, 0, 0 );

		PointInt labelPos( pos.x, (int)(pos.y + (TREE_ITEM_BUFFER / 2)) );
		// render the label text`
		Font::push( context.display(), pFont, labelPos, pItem->sLabel, pItem->cColor );

	}


	// move y down
	pos.y += (int)(height + WINDOW_TREE_SPACING);
}
Exemplo n.º 7
0
///
/// PAINTING FUNCTIONS
///
void XProcessTablePrivate::drawBackground(QPainter *painter)
{
    painter->save();
    painter->setPen(XPT::Color::PenColor);

    int initY = 0;
    int counter = 0;

    while(initY < height())
    {
        if(counter++ % 2 == 0)
        {
            painter->setBrush(XPT::Color::LightColor);
        }
        else
        {
            painter->setBrush(XPT::Color::DarkColor);
        }

        QRect itemRect(QPoint(0,initY),QPoint(width(),initY + XPT::Constant::RowHeight));
        painter->drawRect(itemRect);

        // increment initY
        initY += XPT::Constant::RowHeight;

    }

    painter->restore();
}
Exemplo n.º 8
0
void WaterfallImageRenderer::layout()
{
    if (!m_image || m_image->size().isEmpty()) {
        return;
    }

    const QSize &itemSize = GlobalConfig::instance()->galleryItemSize();
    const QSize &imageSize = m_image->size();
    qreal imageWidth = itemSize.width() - 2 * WaterfallImageRenderer::PADDING;
    qreal factor = imageWidth / imageSize.width();
    qreal imageHeight = imageSize.height() * factor;
    m_imageRect.setSize(QSize(imageWidth, imageHeight));

    m_imageRect.moveTo(
        WaterfallImageRenderer::PADDING,
        WaterfallImageRenderer::PADDING
    );

    m_borderRect.setSize(m_imageRect.size() +
        QSize(2 * WaterfallImageRenderer::BORDER,
              2 * WaterfallImageRenderer::BORDER));
    m_borderRect.moveTo(m_imageRect.topLeft() -
        QPoint(WaterfallImageRenderer::BORDER, WaterfallImageRenderer::BORDER));

    QRect itemRect(0, 0,
        m_imageRect.width() + 2 * WaterfallImageRenderer::PADDING,
        m_imageRect.height() + 2 * WaterfallImageRenderer::PADDING
    );
    m_boundingRect = itemRect;
}
Exemplo n.º 9
0
QList<quint32> MainView2D::selectFixturesRect(QRectF rect)
{   
    QList<quint32>fxList;

    if (rect.width() == 0 || rect.height() == 0)
        return fxList;

    QMap<quint32, QQuickItem *>::const_iterator i = m_itemsMap.constBegin();
    while (i != m_itemsMap.constEnd())
    {
        QQuickItem *fxItem = i.value();
        qreal itemXPos = fxItem->property("x").toReal();
        qreal itemYPos = fxItem->property("y").toReal();
        qreal itemWidth = fxItem->property("width").toReal();
        qreal itemHeight = fxItem->property("height").toReal();

        QRectF itemRect(itemXPos, itemYPos, itemWidth, itemHeight);

        qDebug() << "Rect:" << rect << "itemRect:" << itemRect;

        if (rect.contains(itemRect))
        {
            if (fxItem->property("isSelected").toBool() == false)
            {
                fxItem->setProperty("isSelected", true);
                fxList.append(i.key());
            }
        }
        ++i;
    }
    return fxList;
}
Exemplo n.º 10
0
void DirContent::new_dir()
{
  cout << "DirContentView new_dir" << endl;
  char *fn="new_dir";

  if(fn)
  {
    DirContentViewItem *i=new DirContentViewItem(this,fn);
    //ensureItemVisible(item);
    //FOListView::rename_item(item);
    le_ = new RenameLineEdit(this);

  int header_height = header()->height();
  header_height =0;
  QRect r = itemRect(i);
  r.setTop( r.top() + frameWidth() + 1 + header_height + 20);
  r.setBottom( r.bottom() + frameWidth() + header_height + 20);
  r.setLeft( r.left() + cal_step_size(i));

  le_->setGeometry( r );
    le_->setText("abc");
    le_->setFocus();
    le_->show();

  }
}
Exemplo n.º 11
0
QModelIndex ImageView::indexAt(const QPoint &point) const
{
    if (!model())
        return QModelIndex();
    // Transform the view coordinates into contents widget coordinates.
    int wx = point.x() + horizontalScrollBar()->value();
    int wy = point.y() + verticalScrollBar()->value();

    int rows = model()->rowCount();

    QRect rect = itemRect(model()->index(0,0));
    int itemWidth = rect.width();
    int itemHeight = rect.height();

    int nx = wx / itemWidth;
    int ny = wy / itemHeight;

    if (nx>m_columns)
        return QModelIndex();

    int c = ny*m_columns+nx;
    if (c>rows)
        return QModelIndex();

    return model()->index(c,0);
}
Exemplo n.º 12
0
void ListBox::addItem(string text, glm::vec2 textureSize, glm::vec3 color, GLuint texID)
{
    int index = m_items.size();

    int offset_x = m_rect.x + m_curColNum * m_itemWidth;
    int offset_y = m_rect.y + m_curRowNum * m_itemHeight;

    Rect itemRect(offset_x, offset_y, m_itemWidth, m_itemHeight);

    Rect modelRect;
    modelRect.x = itemRect.x + (itemRect.w - textureSize.x) * 0.5;
    modelRect.y = itemRect.y + (itemRect.h - textureSize.y) * 0.33;
    modelRect.w = textureSize.x;
    modelRect.h = textureSize.y;


    ListBoxItem item(text, textureSize, itemRect, modelRect, color, texID);
    m_items.push_back(item);


    if(m_curColNum == m_colNum-1)
    {
        m_curRowNum++;
        m_curColNum = 0;
    }
    else
        m_curColNum++;
}
Exemplo n.º 13
0
void CFeedIcoItemListCtrl::OnLvnHotTrack(NMHDR *pNMHDR, LRESULT *pResult)
{
	// vista+ 系统的经典主题和vista-系统的 必须要加此消息
	if (thePrefs.GetWindowsVersion() >= _WINVER_VISTA_ && IsThemeEnabled())
		return;

	LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
	// TODO: Add your control notification handler code here
	*pResult = 0;

	int nCurrentHotItemIndex = GetHotItem();

	if (nCurrentHotItemIndex == m_nLastHotItemIndex)
		return;

	if (-1 != nCurrentHotItemIndex)
	{// move into the hot item
		m_nLastHotItemIndex = nCurrentHotItemIndex;
	}
	else
	{// move out of the hot item
		nCurrentHotItemIndex = m_nLastHotItemIndex;
		m_nLastHotItemIndex = -1;
	}

	CRect itemRect(0,0,0,0);
	GetItemRect(nCurrentHotItemIndex, &itemRect, LVIR_BOUNDS);

	InvalidateRect(&itemRect);
}
Exemplo n.º 14
0
void FOListView::rename_item(QListViewItem *i)
{
  if (le_==0)
  {
    le_ = new RenameLineEdit(this);
    connect(le_, SIGNAL(lost_focus()), this, SLOT(rename()));
  }

  rename_item_=(FOListViewItem *)i;

  qDebug("in rename_item(QListViewItem *i)");
  int header_height = header()->height();
  QRect r = itemRect(i);
  r.setTop( r.top() + frameWidth() + 1 + header_height);
  r.setBottom( r.bottom() + frameWidth() + header_height);
  r.setLeft( r.left() + cal_step_size(i));
  //r.setWidth( current( 0 ) );
  ensureItemVisible(i);
  horizontalScrollBar()->setValue(0);
  horizontalScrollBar()->setEnabled(false);
  verticalScrollBar()->setEnabled(false);
  le_->setGeometry( r );
  QString fn=i->text(0);
  if (fn[fn.length()-1]=='/')
    fn.remove(fn.length()-1,1);
  le_->setText(fn);
  le_->selectAll();
  le_->show();
  le_->setFocus();
}
Exemplo n.º 15
0
void MapBG::Render(Draw* w)
{
	if (_currLevel < 0 || _currLevel >= _levels.GetCount() || !GetTopRender())
		return;

	MipMapLevel& level = _levels[_currLevel];

	Point offset = GetTopRender()->GetPageOffset();
	Rect  page   = GetTopRender()->GetPageRect();
	Point lt     = GetTopRender()->GetPagePos();

	for (int i = 0; i < level.GetMipMaps().GetCount(); ++i)
	{
		Rect itemRect(level.GetMipMaps().GetKey(i), level.GetBlockSize());

		if (page.Intersects(itemRect))
			if (level.GetMipMaps()[i])
			{
				level.GetMipMaps()[i]
					->Render(w,
				         itemRect
							.Offseted(-lt)
							.Offseted(offset));
			}
	}

	IMapRender::Render(w);
}
Exemplo n.º 16
0
void SelectProjectScreen::openProjectGui()
{
  Gui::label(Rect(centerPanel.x + PADDING,
                  centerPanel.y + PADDING, 300, 30),
                  "Select project to open:");

  if(Gui::button(Rect(centerPanel.x + centerPanel.width - 100 - PADDING,
                      centerPanel.y + centerPanel.height - 25 - PADDING,
                      100, 25), "Open") == true)
  {
    openButtonClicked();
  }

  int yPad = 50;
  Rect selectRect(centerPanel.x + PADDING, centerPanel.y + yPad, centerPanel.width - (PADDING * 2), centerPanel.height - (yPad * 2));
  Gui::box(selectRect, "");

  for(int i = 0; i < projects.size(); i++)
  {
    Rect itemRect(selectRect.x, selectRect.y + (20 * i), selectRect.width, 20);
    if(projects.at(i) == selectedProject)
    {
      Gui::box(itemRect, projects.at(i));
    }
    else
    {
      Gui::label(itemRect, projects.at(i));
    }

    if(Input::getMouseButtonDown(0) == true && itemRect.contains(Input::getMousePosition()) == true)
    {
      selectedProject = projects.at(i);
    }
  }
}
Exemplo n.º 17
0
void tst_QGraphicsEffect::boundingRect()
{
    // No source; empty bounding rect.
    CustomEffect *effect = new CustomEffect;
    QCOMPARE(effect->boundingRect(), QRectF());

    // Install effect on QGraphicsItem.
    QRectF itemRect(0, 0, 100, 100);
    QGraphicsRectItem *item = new QGraphicsRectItem;
    item->setRect(itemRect);
    item->setGraphicsEffect(effect);
    int margin = effect->margin();
    QCOMPARE(effect->boundingRect(), itemRect.adjusted(-margin, -margin, margin, margin));
    QCOMPARE(effect->boundingRect(), effect->boundingRectFor(itemRect));

    // Make sure disabling/enabling the effect doesn't change the bounding rect.
    effect->setEnabled(false);
    QCOMPARE(effect->boundingRect(), itemRect.adjusted(-margin, -margin, margin, margin));
    QCOMPARE(effect->boundingRect(), effect->boundingRectFor(itemRect));
    effect->setEnabled(true);
    QCOMPARE(effect->boundingRect(), itemRect.adjusted(-margin, -margin, margin, margin));
    QCOMPARE(effect->boundingRect(), effect->boundingRectFor(itemRect));

    // Change effect margins.
    effect->setMargin(margin = 20);
    QCOMPARE(effect->boundingRect(), itemRect.adjusted(-margin, -margin, margin, margin));
    QCOMPARE(effect->boundingRect(), effect->boundingRectFor(itemRect));

    // Uninstall effect on QGraphicsItem.
    QPointer<CustomEffect> ptr = effect;
    item->setGraphicsEffect(0);
    QVERIFY(!ptr);

    delete item;
}
Exemplo n.º 18
0
void PropertyEditor::showDefaultsButton(bool show) {
    int y = viewportToContents(QPoint(0, itemRect(m_editItem).y())).y();
    QRect geometry(columnWidth(0), y, columnWidth(1), m_editItem->height());
    m_defaults->resize(m_baseRowHeight, m_baseRowHeight);

    if (!show) {
        if (m_currentEditor) {
            if (m_currentEditor->leavesTheSpaceForRevertButton()) {
                geometry.setWidth(geometry.width() - m_defaults->width());
            }

            m_currentEditor->resize(geometry.width(), geometry.height());
        }

        m_defaults->hide();

        return;
    }

    QPoint p = contentsToViewport(QPoint(0, geometry.y()));
    m_defaults->move(geometry.x() + geometry.width() - m_defaults->width(), p.y());

    if (m_currentEditor) {
        m_currentEditor->move(m_currentEditor->x(), p.y());
        m_currentEditor->resize(geometry.width() - m_defaults->width(), geometry.height());
    }

    m_defaults->show();
}
Exemplo n.º 19
0
void CFeedIcoItemListCtrl::DrawItems(CDC & dcMem, const CRect & rectClip, const CRect & rectClient)
{
	//CImageList* pImgList = GetImageList(LVSIL_NORMAL);

	CFont * pListFont = GetFont();
	dcMem.SelectObject(pListFont);
	dcMem.SetTextColor(RGB(0,0,0));

	CRect itemRect(0,0,0,0);

	CString strTaskName;

	int nItemCount  = GetItemCount() - 1;
	int nHoverIndex = GetHotItem();//Hover
	for ( ; nItemCount >= 0; nItemCount-- )
	{
		int nItemIndex = nItemCount;
		GetItemRect(nItemIndex, &itemRect, LVIR_BOUNDS);

		CRect rtIntersect;
		rtIntersect.IntersectRect(rectClip,itemRect);
		if (rtIntersect.IsRectEmpty())//判断此ITEM是否在重绘区域内,不在的话则直接continue
			continue;

		CRect rectPoster;//封面RECT
		GetItemRect(nItemIndex, &rectPoster, LVIR_ICON);

		//绘制海报
		if( nHoverIndex == nItemIndex || GetItemState(nItemIndex, ODA_SELECT) == ODA_SELECT )
		{//Hover
			if (m_imageRss_PosterSelBg)
				m_imageRss_PosterSelBg->Draw(dcMem.m_hDC, rectPoster.left + 11, rectPoster.top - 8);
		}
		else
		{//Normal
			if (m_imageRss_PosterBg)
				m_imageRss_PosterBg->Draw(dcMem.m_hDC, rectPoster.left + 15, rectPoster.top - 4);
		}

		CRssFeed* pFeed = (CRssFeed*)GetItemData(nItemIndex);

		if (pFeed->m_pPosterImage)//绘制海报
			pFeed->m_pPosterImage->Draw(dcMem.m_hDC, rectPoster.left + 20, rectPoster.top + 1);
		else if (m_imageRss_PosterDefault)//绘制默认海报
				m_imageRss_PosterDefault->Draw(dcMem.m_hDC, rectPoster.left + 20, rectPoster.top + 1);

		//strTaskName = pFeed->m_strTitle;
		strTaskName = GetItemText(nItemCount, 0);

		CRect rectNameStr;//宽度146
		GetItemRect(nItemIndex, &rectNameStr, LVIR_LABEL);
		rectNameStr.OffsetRect(0,5);//拉开标题和Poster的距离 

		dcMem.DrawText(strTaskName, -1, &rectNameStr, DT_CENTER | DT_WORDBREAK );

		//if (pImgList)
		//	pImgList->Draw(&MemDC,nItem,CPoint(itemRect.left+5,itemRect.top+5),ILD_TRANSPARENT);
	}
}
Exemplo n.º 20
0
void ImageView::paintEvent(QPaintEvent *event)
{
    //QItemSelectionModel *selections = selectionModel();
    QStyleOptionViewItem option = viewOptions();
    //QStyle::State state = option.state;
    //QBrush background = option.palette.base();
    QPen foreground(option.palette.color(QPalette::WindowText));
    //QBrush highlight(option.palette.color(QPalette::Highlight));

    //p.fillRect(event->rect(),background);

    if (!model())
        return;

    QPainter p(viewport());

    int n = model()->rowCount();

    p.translate(-horizontalOffset(),-verticalOffset());

    for (int i=0;i<n;i++)
    {
        QModelIndex index = model()->index(i,0);

        QRect rect = itemRect(index);
        p.setPen(foreground);
        //p.drawRect(rect);

        QVariant decoration = model()->data(index,Qt::DecorationRole);
        if (decoration.type() == QVariant::Pixmap)
        {
            QPixmap pixmap = qvariant_cast<QPixmap>(decoration);
            if (!pixmap.isNull())
            {
                QSize pixmapSize = pixmap.size();
                QSize itemSize = rect.size();
                pixmapSize.scale(itemSize,Qt::KeepAspectRatio);
                QSize rest = (itemSize - pixmapSize)/2;
                QRect pixmapRect(QPoint(rest.width(),rest.height()),pixmapSize);
                pixmapRect.translate(rect.topLeft());
                p.drawPixmap(pixmapRect,pixmap);
            }

        }

        if (index == currentIndex())
        {
            QColor color(option.palette.color(QPalette::Highlight));
            color.setAlpha(100);
            p.fillRect(rect,color);
        }

        //qDebug() << rect << foreground.color() << background.color();
        //p.drawText(rect,Qt::AlignCenter,QString::number(i));
    }

    event->accept();
}
Exemplo n.º 21
0
void PropertyEditor::createEditor(PropertyEditorItem * i) {
    int y = viewportToContents(QPoint(0, itemRect(i).y())).y();
    QRect geometry(columnWidth(0), y, columnWidth(1), i->height());

    delete m_currentEditor;

    m_editItem = i;
    PropertySubEditor *editor = 0;

    switch (i->type()) {
    case Variant::Type::String:
        editor = new PropertyEditorInput(viewport(), i->property());
        break;
    case Variant::Type::Port:
    case Variant::Type::Pin:
    case Variant::Type::Combo:
    case Variant::Type::VarName:
    case Variant::Type::Select:
    case Variant::Type::PenStyle:
    case Variant::Type::PenCapStyle:
    case Variant::Type::SevenSegment:
    case Variant::Type::KeyPad:
        editor = new PropertyEditorList(viewport(), i->property());
        break;
    case Variant::Type::FileName:
        editor = new PropertyEditorFile(viewport(), i->property());
        break;
    case Variant::Type::Int:
        editor = new PropertyEditorSpin(viewport(), i->property());
        break;
    case Variant::Type::Double:
        editor = new PropertyEditorDblSpin(viewport(), i->property());
        break;
    case Variant::Type::Color:
        editor = new PropertyEditorColor(viewport(), i->property());
        break;
    case Variant::Type::Bool:
        editor = new PropertyEditorBool(viewport(), i->property());
        break;
    case Variant::Type::Raw:
    case Variant::Type::Multiline:
    case Variant::Type::RichText:
    case Variant::Type::None:
        break;
    }

    if (editor) {
        addChild(editor);
        moveChild(editor, geometry.x(), geometry.y());
        editor->show();

        editor->setFocus();
    }

    m_currentEditor = editor;

    showDefaultsButton(i->property()->changed());
}
Exemplo n.º 22
0
Arquivo: view.cpp Projeto: Fale/qtmoko
QRect LinearView::itemViewportRect(const QModelIndex &index) const
{
    QRect rect = itemRect(index);
    QRect result(rect.left() - horizontalScrollBar()->value(),
                 rect.top() - verticalScrollBar()->value(),
                 rect.width(), viewport()->height());

    return result;
}
Exemplo n.º 23
0
QRect PieView::visualRect(const QModelIndex &index) const
{
    QRect rect = itemRect(index);
    if (rect.isValid())
        return QRect(rect.left() - horizontalScrollBar()->value(),
                     rect.top() - verticalScrollBar()->value(),
                     rect.width(), rect.height());
    else
        return rect;
}
Exemplo n.º 24
0
void VariableTree::maybeTip(const QPoint &p)
{
    VarItem * item = dynamic_cast<VarItem*>( itemAt(p) );
    if (item != 0) {
        QRect r = itemRect(item);
        if (r.isValid()) {
            tip(r, item->tipText());
		}
    }
}
Exemplo n.º 25
0
void LogListView::slotQueryToolTip(const QPoint& viewportPos,
                                   QRect&        viewportRect,
                                   QString&      text)
{
    if (const LogListViewItem* item = static_cast<LogListViewItem*>(itemAt(viewportPos)))
    {
        viewportRect = itemRect(item);
        text = item->m_logInfo.createToolTipText();
    }
}
int
KexiRelationsTableFieldList::globalY(const QString &item)
{
    QAbstractItemModel *themodel = model();
    QModelIndex idx;

    for (int i = 0; i < themodel->rowCount(); ++i) {
        idx = themodel->index(i, 0);
        QVariant data = themodel->data(idx);
        if (data.toString() == item) {
            break;
        }
    }

    if (idx.isValid()) {
        QRect r = this->rectForIndex(idx);
        int y = r.y() + r.height()/2;

        //Not sure what this line is supposed to do...is it to check if the item is visible?
        if (visualRect(idx).y() > viewport()->height()) {
            y = 0;
        } else if (y == 0) {
            y = height();
        }
        return mapToGlobal(QPoint(0, y)).y();
    }
    return -1;

#if 0
    QModelIndexList list = themodel->match()
                           Q3ListViewItem *i = findItem(item, 0);
    if (!i)
        return -1;
    int y = itemRect(i).y() + (itemRect(i).height() / 2);
    if (contentsY() > itemPos(i))
        y = 0;
    else if (y == 0)
        y = height();
    return mapToGlobal(QPoint(0, y)).y();

#endif
}
Exemplo n.º 27
0
void CardView::tryShowFullText()
{
  d->mTimer->stop();
  // if we have an item
  QPoint cpos = viewportToContents( viewport()->mapFromGlobal( QCursor::pos() ) );
  CardViewItem *item = itemAt( cpos );
  if ( item ) {
    // query it for a value to display
    QPoint ipos = cpos - itemRect( item ).topLeft();
    item->showFullString( ipos, d->mTip );
  }
}
Exemplo n.º 28
0
void TEnhancedListBox :: DrawItem  ( DRAWITEMSTRUCT far & drawInfo )
	{
	char 	table [100] ;			/* buffer de travail      */
	TDC	drawDC(drawInfo.hDC);		/* zones de dessin        */
	TRect	itemRect(drawInfo.rcItem.left,drawInfo.rcItem.top,drawInfo.rcItem.right,drawInfo.rcItem.bottom);
	TRect   BaseRect = itemRect ;
	char *	pchar ;
	bool	useinvert = ( drawInfo. itemState & ODS_SELECTED ) ;

	if  ( drawInfo. itemID >= Nb_display )
		return ;

	if  ( ! boolpopup )			/* redimensionnement ?    */
		{
		TRect	deplace ;

		boolpopup = TRUE ;

		Parent -> GetWindowRect ( deplace ) ;	/* basee sur le parent */
		deplace. right -= deplace. left ;
		deplace. left = -1 ;
		deplace. bottom -= deplace. top ;
		deplace. top = -1 ;
		deplace. right += GetSystemMetrics ( SM_CXVSCROLL ) ; /* cache scroller */
		MoveWindow ( deplace, TRUE ) ;
		 }

	TListBox :: GetString ( table, drawInfo. itemID  ) ;

	drawDC. FillRect ( itemRect, TBrush ( TColor ( ::GetSysColor ( useinvert ? COLOR_HIGHLIGHT : COLOR_WINDOW ) ) ) ) ;

	if  ( useinvert )
		{
		SetTextColor ( drawDC, GetSysColor ( COLOR_HIGHLIGHTTEXT ) ) ;
		SetBkColor   ( drawDC, GetSysColor ( COLOR_HIGHLIGHT ) ) ;
		 }
	else
		{
		SetTextColor ( drawDC, GetSysColor ( COLOR_WINDOWTEXT ) ) ;
		SetBkColor   ( drawDC, GetSysColor ( COLOR_WINDOW ) ) ;
		 }

	itemRect. left += 3 ;		       	/* écriture formatée      */
	drawDC. DrawText ( table , -1, itemRect, DT_VCENTER ) ;
	itemRect. left += x1 ;
	pchar = memo [ base_display + drawInfo. itemID ] ;
	while  ( * pchar  &&  * pchar  !=  ' '  &&  * pchar  !=  '\t' )
		pchar ++ ;
	while  ( * pchar  ==  ' '  ||  * pchar  ==  '\t' )
		pchar ++ ;
	if  ( * pchar )
		drawDC. DrawText( pchar , -1, itemRect, DT_VCENTER ) ;
	 }
Exemplo n.º 29
0
void CurrentFrameGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem*  /*option*/, QWidget* /*widget*/) {
    QRectF itemRect(boundingRect().x()+1, boundingRect().y()+1, boundingRect().width()-1, boundingRect().height()-1);
    QLinearGradient gradient(0,0,0, itemRect.height() );
    gradient.setSpread(QGradient::ReflectSpread);
    gradient.setColorAt(0.0, Qt::green);
    gradient.setColorAt(1.0, Qt::green);

    QBrush brush(gradient);
    painter->setBrush(gradient);
    painter->setOpacity(0.5);
    painter->drawRect(itemRect);
    setVisible(true);
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
//
TBool CMmGridContainer::ItemIsVisible( TInt aItemIndex ) const
    {
    CListBoxView* v = iGrid->View();
    TRect itemRect( v->ItemPos( aItemIndex ), v->ItemSize( aItemIndex ) );
    TRect viewRect = v->ViewRect();
    TBool isVisible = EFalse;
    if ( itemRect.Intersects( viewRect ) )
        {
        TRect intersection = itemRect;
        intersection.Intersection( viewRect );
        isVisible = intersection.Height() > 1 && intersection.Width() > 1;
        }
    return isVisible;
    }