AbstractScrollArea::AbstractScrollArea(QGraphicsWidget *parent) : GvbWidget(parent) , m_viewport(0) , m_horizontalScrollBar(0) , m_verticalScrollBar(0) , m_prevHorizontalValue(0.0) , m_prevVerticalValue(0.0) { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); setContentsMargins(0, 0, 0, 0); m_horizontalScrollBar = new ScrollBar(Qt::Horizontal, this); m_horizontalScrollBar->hide(); m_horizontalScrollBar->setContentsMargins(0, 0, 0, 0); m_horizontalScrollBarPolicy = Qt::ScrollBarAsNeeded; m_horizontalScrollBar->setZValue(zValue()+1); // Raise scroll bar to top m_horizontalScrollBar->setVisible(false); connect(m_horizontalScrollBar, SIGNAL(sliderPositionChange(qreal)), this, SLOT(horizontalScroll(qreal))); connect(m_horizontalScrollBar, SIGNAL(sliderPressed()), this, SLOT(horizontalScrollStart())); m_verticalScrollBar = new ScrollBar(Qt::Vertical, this); m_verticalScrollBar->hide(); m_verticalScrollBar->setContentsMargins(0, 0, 0, 0); m_verticalScrollBarPolicy = Qt::ScrollBarAsNeeded; m_verticalScrollBar->setZValue(zValue()+1); // Raise scroll bar to top m_verticalScrollBar->setVisible(false); connect(m_verticalScrollBar, SIGNAL(sliderPositionChange(qreal)), this, SLOT(verticalScroll(qreal))); connect(m_verticalScrollBar, SIGNAL(sliderPressed()), this, SLOT(verticalScrollStart())); QGraphicsWidget *viewport = new QGraphicsWidget; setViewport(viewport); }
void CreatorItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* , QWidget* ) { QPen pen; if (zValue() < depth_) pen.setStyle(Qt::DotLine); painter->setPen(pen); QBrush brush(color_); if (zValue() < depth_) brush.setStyle(Qt::Dense4Pattern); painter->setBrush(brush); painter->drawRect(0, 0, 9, 9); }
void KoReportDesignerItemChart::buildXML(QDomDocument & doc, QDomElement & parent) { QDomElement entity = doc.createElement("report:chart"); // properties addPropertyAsAttribute(&entity, m_name); addPropertyAsAttribute(&entity, m_dataSource); addPropertyAsAttribute(&entity, m_chartType); addPropertyAsAttribute(&entity, m_chartSubType); addPropertyAsAttribute(&entity, m_threeD); addPropertyAsAttribute(&entity, m_colorScheme); addPropertyAsAttribute(&entity, m_aa); addPropertyAsAttribute(&entity, m_xTitle); addPropertyAsAttribute(&entity, m_yTitle); addPropertyAsAttribute(&entity, m_backgroundColor); addPropertyAsAttribute(&entity, m_displayLegend); addPropertyAsAttribute(&entity, m_legendPosition); addPropertyAsAttribute(&entity, m_legendOrientation); addPropertyAsAttribute(&entity, m_linkChild); addPropertyAsAttribute(&entity, m_linkMaster); entity.setAttribute("report:z-index", zValue()); // bounding rect buildXMLRect(doc, entity, &m_pos, &m_size); parent.appendChild(entity); }
void InputTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if(pos() != position_change) { //d->getNoticeWindow()->write("Pos change"); updatePosition(d, Vec3D(pos().x(), pos().y(), zValue())); } QGraphicsTextItem::mouseReleaseEvent(event); }
void ActivityContainerCanvas::force_inside(DiagramItem * di, QGraphicsItem * ci, BooL & need_sub_upper) { QRect r = rect(); QRect sr = di->rect(); int dx = 0; int dy = 0; if (sr.left() < r.left()) { if (sr.right() <= r.right()) dx = r.left() - sr.left(); } else if (sr.right() > r.right()) dx = r.right() - sr.right(); if (sr.top() < r.top()) { if (sr.bottom() <= r.bottom()) dy = r.top() - sr.top(); } else if (sr.bottom() > r.bottom()) dy = r.bottom() - sr.bottom(); if ((dx != 0) || (dy != 0)) ci->moveBy(dx, dy); need_sub_upper |= (ci->zValue() <= zValue()); }
void GraphicsContinuousControlItem::mousePressEvent(QGraphicsSceneMouseEvent * event) { if (minValue != maxValue) { GraphicsLabelItem::mousePressEvent(event); if (event->isAccepted()) { valueEditingStarted(); positionBeforeEdit = pos(); rectBeforeEdit = rect(); waitingForMouseReleaseEvent = true; valueBeforeEdit = currentValue; // create label items marking the minimum and maximum value: setZValue(zValue() + 2); double absolutePositionBeforeEdit = (orientation == HORIZONTAL ? positionBeforeEdit.x() : -positionBeforeEdit.y()); double relativePositionBeforeEdit = size * (valueBeforeEdit - minValue) / (maxValue - minValue); double minPos = absolutePositionBeforeEdit - relativePositionBeforeEdit; double maxPos = minPos + size; backgroundRect->setVisible(true); minLabel->setVisible(true); maxLabel->setVisible(true); if (orientation == HORIZONTAL) { minLabel->setPos(QPointF(minPos, positionBeforeEdit.y())); maxLabel->setPos(QPointF(maxPos, positionBeforeEdit.y())); } else { minLabel->setPos(QPointF(alignX(minLabel->rect(), rectBeforeEdit.translated(positionBeforeEdit)), -minPos)); maxLabel->setPos(QPointF(alignX(maxLabel->rect(), rectBeforeEdit.translated(positionBeforeEdit)), -maxPos)); } backgroundRect->setRect((minLabel->rect().translated(minLabel->pos()) | maxLabel->rect().translated(maxLabel->pos())));//.adjusted(-1, -1, 1, 1)); setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); } } }
Context::AppletToolbarConfigItem::AppletToolbarConfigItem( QGraphicsItem* parent ) : AppletToolbarBase( parent ) , m_iconPadding( 2 ) , m_icon( 0 ) { QAction* listAdd = new QAction( i18n( "Configure Applets..." ), this ); listAdd->setIcon( KIcon( "configure" ) ); listAdd->setVisible( true ); listAdd->setEnabled( true ); connect( listAdd, SIGNAL(triggered()), this, SIGNAL(triggered()) ); m_icon = new Plasma::IconWidget( this ); m_icon->setAction( listAdd ); m_icon->setText( QString() ); m_icon->setToolTip( listAdd->text() ); m_icon->setDrawBackground( false ); m_icon->setOrientation( Qt::Horizontal ); QSizeF iconSize = m_icon->sizeFromIconSize( 22 ); m_icon->setMinimumSize( iconSize ); m_icon->setMaximumSize( iconSize ); m_icon->resize( iconSize ); m_icon->setZValue( zValue() + 1 ); setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred ); }
Character* Character::clone() { Character* p=new Character; p->setName(name); p->setViewReceiver(receiver); p->setStateTotal(stateTotal); p->setDragable(dragable); p->setShowRect(showRect); for(int i=0;i<stateTotal;i++) { State* state=new State(stateBox[i]); state->setSprite(p); p->getStateBox().push_back(state); } p->init(); p->setZValue(zValue()); p->setWeight(weight); p->setHP(HP); p->setMP(MP); p->setHPMax(HPMax); p->setMPMax(MPMax); p->setType(type); return p; }
void CodDirsCanvas::save(QTextStream & st, bool ref, QString & warning) const { if (ref) st << "dirscanvas_ref " << get_ident(); else { nl_indent(st); st << "dirscanvas " << get_ident() << " z " << zValue() << " "; link->save(st, TRUE, warning); indent(+1); settings.save_msg(st); if (label != 0) { nl_indent(st); st << "forward_label "; save_string(label->get_name().toLatin1().constData(), st); save_xyz(st, label, " xyz"); } if (backward_label != 0) { nl_indent(st); st << "backward_label "; save_string(backward_label->get_name().toLatin1().constData(), st); save_xyz(st, backward_label, " xyz"); } indent(-1); } }
void TextButton::setupScanItem() { if (Colors::useButtonBalls){ ScanItem *scanItem = new ScanItem(0, this); scanItem->setZValue(zValue() + 1); this->scanAnim = new DemoItemAnimation(scanItem); this->scanAnim->timeline->setLoopCount(1); float x = 1; float y = 1.5f; float stop = BUTTON_WIDTH - scanItem->boundingRect().width() - x; if (this->alignment == LEFT){ this->scanAnim->setDuration(2500); this->scanAnim->setPosAt(0.0, QPointF(x, y)); this->scanAnim->setPosAt(0.5, QPointF(x, y)); this->scanAnim->setPosAt(0.7, QPointF(stop, y)); this->scanAnim->setPosAt(1.0, QPointF(x, y)); scanItem->setPos(QPointF(x, y)); } else { this->scanAnim->setPosAt(0.0, QPointF(stop, y)); this->scanAnim->setPosAt(0.5, QPointF(x, y)); this->scanAnim->setPosAt(1.0, QPointF(stop, y)); scanItem->setPos(QPointF(stop, y)); } } }
void OperatorItem::addOutputConnection(unsigned int id, ConnectionItem* connection) { m_outputs[id]->addConnection(connection); // move the output connection slightly in front of the operator connection->setZValue(zValue() + m_outputs.count() * CONNECTION_Z_OFFSET); }
ArrowPointCanvas * CodLinkCanvas::brk(const QPoint & p) { ArrowPointCanvas * ap = new ArrowPointCanvas(the_canvas(), p.x(), p.y()); ap->setZValue(zValue() + 1); CodLinkCanvas * other = new CodLinkCanvas(the_canvas(), ap, end, 0, decenter_begin, decenter_end); ap->add_line(this); end->remove_line(this, TRUE); end = ap; //update_pos(); ap->show(); other->show(); if (dirs && ((p - beginp).manhattanLength() < (p - endp).manhattanLength())) { other->dirs = dirs; dirs = 0; other->dirs->set_link(other); other->dirs->update_pos(other->beginp, other->endp); } modified(); other->modified(); return ap; }
Quasi::Ordering Entity::order() const { #if QT_VERSION >= 0x050000 return (Quasi::Ordering)z(); #else return (Quasi::Ordering)zValue(); #endif }
void LabelCanvas::history_save(QBuffer & b) const { ::save(this, b); ::save(center_x_scale100, b); ::save(center_y_scale100, b); ::save(x(), b); ::save(y(), b); ::save(zValue(), b); }
void TextButton::setupHoverText() { if (this->buttonLabel.isEmpty()) return; DemoTextItem *textItem = new DemoTextItem(this->buttonLabel, Colors::buttonFont(), Colors::buttonText, -1, this->scene(), this); textItem->setZValue(zValue() + 2); textItem->setPos(16, 0); }
QVariant AbstractFigure::itemChange(GraphicsItemChange change, const QVariant &value) { if (change == ItemSelectedChange && value.toBool()) { if (zValue() < maxZOrder) { maxZOrder += 0.1; setZValue(maxZOrder); } } return QGraphicsItem::itemChange(change, value); }
void Entity::setOrder(Quasi::Ordering order) { #if QT_VERSION >= 0x050000 if (z() != order) setZ(order); #else if (zValue() != order) setZValue(order); #endif }
foreach (QGraphicsItem *item, collidingItems()){ if (item->zValue() == zValue() - 1){ QString kind = item->data(0).toString(); if ((kind == "Object") || (kind == "Robot")){ hide(); m_bulletTime->stop(); emit bulletCollision(item); } } }
void ReportEntityLabel::buildXML(QDomDocument & doc, QDomElement & parent) { kDebug(); //kdDebug() << "ReportEntityLabel::buildXML()"); QDomElement entity = doc.createElement("label"); // bounding rect buildXMLRect(doc, entity, pointRect()); // name QDomElement n = doc.createElement("name"); n.appendChild(doc.createTextNode(entityName())); entity.appendChild(n); // z QDomElement z = doc.createElement("zvalue"); z.appendChild(doc.createTextNode(QString::number(zValue()))); entity.appendChild(z); // font info //buildXMLFont ( doc,entity,font() ); //text style info buildXMLTextStyle(doc, entity, textStyle()); //Line Style buildXMLLineStyle(doc, entity, lineStyle()); // text alignment int align = textFlags(); // horizontal if ((align & Qt::AlignRight) == Qt::AlignRight) entity.appendChild(doc.createElement("right")); else if ((align & Qt::AlignHCenter) == Qt::AlignHCenter) entity.appendChild(doc.createElement("hcenter")); else // Qt::AlignLeft entity.appendChild(doc.createElement("left")); // vertical if ((align & Qt::AlignBottom) == Qt::AlignBottom) entity.appendChild(doc.createElement("bottom")); else if ((align & Qt::AlignVCenter) == Qt::AlignVCenter) entity.appendChild(doc.createElement("vcenter")); else // Qt::AlignTop entity.appendChild(doc.createElement("top")); // the text string QDomElement string = doc.createElement("string"); string.appendChild(doc.createTextNode(text())); entity.appendChild(string); parent.appendChild(entity); }
QVariant AbstractContent::itemChange(GraphicsItemChange change, const QVariant & value) { // keep the AbstractContent's center inside the scene rect.. if (change == ItemPositionChange && scene()) { QPointF newPos = value.toPointF(); QRectF sceneRect = scene()->sceneRect(); if (!sceneRect.contains(newPos) && sceneRect.width() > 100 && sceneRect.height() > 100) { newPos.setX(qBound(sceneRect.left(), newPos.x(), sceneRect.right())); newPos.setY(qBound(sceneRect.top(), newPos.y(), sceneRect.bottom())); return newPos; } } // tell subclasses about selection changes if (change == ItemSelectedHasChanged) selectionChanged(value.toBool()); // changes that affect the mirror item if (m_mirrorItem) { switch (change) { // notify about setPos case ItemPositionHasChanged: m_mirrorItem->sourceMoved(); break; // notify about graphics changes //case ItemMatrixChange: //case ItemTransformChange: case ItemTransformHasChanged: case ItemEnabledHasChanged: case ItemSelectedHasChanged: case ItemParentHasChanged: case ItemOpacityHasChanged: GFX_CHANGED(); break; case ItemZValueHasChanged: m_mirrorItem->setZValue(zValue()); break; case ItemVisibleHasChanged: m_mirrorItem->setVisible(isVisible()); break; default: break; } } // ..or just apply the value return QGraphicsItem::itemChange(change, value); }
void dmz::QtCanvasLink::set_arrow_state (const Boolean State) { if (State) { if (!_arrow1) { _arrow1 = new QGraphicsPolygonItem (this); } if (!_arrow2) { _arrow2 = new QGraphicsPolygonItem (this); } QPolygon poly (4); poly.putPoints (0, 4, 0, -9 * _arrowSizeMultiplier, 9 * _arrowSizeMultiplier, 5 * _arrowSizeMultiplier, 0, 0, -9 * _arrowSizeMultiplier, 5 * _arrowSizeMultiplier); if (_arrow1) { _arrow1->setPolygon (poly); _arrow1->setZValue (zValue () - 1.0f); _arrow1->setBrush (QBrush (Qt::SolidPattern)); } if (_arrow2) { _arrow2->setPolygon (poly); _arrow2->setZValue (zValue () - 1.0f); _arrow2->setBrush (QBrush (Qt::SolidPattern)); } setColorAll (pen ()); _set_arrow_transform (); } else { if (_arrow1) { delete _arrow1; _arrow1 = 0; } if (_arrow2) { delete _arrow2; _arrow2 = 0; } } }
QRectF UBGraphicsProtractor::resizeButtonRect () const { qreal antiSc = antiScale(); if (buttonSizeReference().width() * antiSc <= buttonSizeReference().width() * 15) return QRectF(buttonSizeReference().width() * 8, -buttonSizeReference().height() * antiSc / 2, buttonSizeReference().width() * antiSc, buttonSizeReference().height() * antiSc); else { mResizeSvgItem->setZValue(zValue()+10); return QRectF(-buttonSizeReference().width() * antiSc / 2, -buttonSizeReference().height() * antiSc / 2, buttonSizeReference().width() * antiSc, buttonSizeReference().height() * antiSc); } }
void QDeclarativeGeoMapObject::setMapObject(QGeoMapObject *object) { if (!object) return; object_ = object; object_->setVisible(visible_); connect(this, SIGNAL(zChanged()), this, SLOT(parentZChanged())); object_->setZValue(zValue()); }
QVariant AbstractContent::itemChange(GraphicsItemChange change, const QVariant & value) { // keep the AbstractContent's center inside the scene rect.. if (change == ItemPositionChange && scene()) { QPointF newPos = value.toPointF(); QRectF rect = scene()->sceneRect(); if (!rect.contains(newPos)) { newPos.setX(qBound(rect.left(), newPos.x(), rect.right())); newPos.setY(qBound(rect.top(), newPos.y(), rect.bottom())); return newPos; } } // changes that affect the mirror item if (m_mirrorItem) { switch (change) { // notify about setPos case ItemPositionHasChanged: m_mirrorItem->sourceMoved(); break; // notify about graphics changes case ItemTransformHasChanged: case ItemEnabledHasChanged: case ItemSelectedHasChanged: case ItemParentHasChanged: #if QT_VERSION >= 0x040500 case ItemOpacityHasChanged: #endif GFX_CHANGED(); break; case ItemZValueHasChanged: m_mirrorItem->setZValue(zValue()); break; case ItemVisibleHasChanged: m_mirrorItem->setVisible(isVisible()); break; default: break; } } // ..or just apply the value return QGraphicsItem::itemChange(change, value); }
void KoReportDesignerItemLine::buildXML(QDomDocument & doc, QDomElement & parent) { QDomElement entity = doc.createElement("report:line"); // properties addPropertyAsAttribute(&entity, m_name); entity.setAttribute("report:z-index", zValue()); KRUtils::setAttribute(entity, "svg:x1", m_start.toPoint().x()); KRUtils::setAttribute(entity, "svg:y1", m_start.toPoint().y()); KRUtils::setAttribute(entity, "svg:x2", m_end.toPoint().x()); KRUtils::setAttribute(entity, "svg:y2", m_end.toPoint().y()); buildXMLLineStyle(doc, entity, lineStyle()); parent.appendChild(entity); }
void KReportDesignerItemLine::buildXML(QDomDocument *doc, QDomElement *parent) { QDomElement entity = doc->createElement(QLatin1String("report:") + typeName()); // properties addPropertyAsAttribute(&entity, nameProperty()); entity.setAttribute(QLatin1String("report:z-index"), zValue()); KReportUtils::setAttribute(&entity, QLatin1String("svg:x1"), m_start->value().toPointF().x()); KReportUtils::setAttribute(&entity, QLatin1String("svg:y1"), m_start->value().toPointF().y()); KReportUtils::setAttribute(&entity, QLatin1String("svg:x2"), m_end->value().toPointF().x()); KReportUtils::setAttribute(&entity, QLatin1String("svg:y2"), m_end->value().toPointF().y()); buildXMLLineStyle(doc, &entity, lineStyle()); parent->appendChild(entity); }
void GraphicsContinuousControlItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * event) { GraphicsLabelItem::mouseReleaseEvent(event); if (waitingForMouseReleaseEvent) { waitingForMouseReleaseEvent = false; setFlag(QGraphicsItem::ItemSendsGeometryChanges, false); setSelected(false); // remove the minimum/maximum labels: setZValue(zValue() - 2); backgroundRect->setVisible(false); minLabel->setVisible(false); maxLabel->setVisible(false); // change our position back to the original position: setPos(alignX(rect(), rectBeforeEdit.translated(positionBeforeEdit)), positionBeforeEdit.y()); valueEditingStopped(currentValue); } }
// update sub nodes to be upper this, recursively void ActivityContainerCanvas::force_sub_upper(QList<QGraphicsItem*> & all) { QList<QGraphicsItem*>::Iterator cit; BrowserNode * browser_node = get_bn(); for (cit = all.begin(); cit != all.end(); ++cit) { if ((*cit)->isVisible()) { DiagramItem * di = QCanvasItemToDiagramItem(*cit); if ((di != 0) && (di->get_bn() != 0) && (((BrowserNode *) di->get_bn())->parent() == browser_node)) { // must look at the type because some canvas items have browser_node // attr equals to the diagram and the parent of the diagram is the activity switch (di->typeUmlCode()) { case UmlActivityObject: case UmlActivityAction: case UmlActivityPartition: case UmlExpansionRegion: case UmlInterruptibleActivityRegion: case InitialAN: case FlowFinalAN: case ActivityFinalAN: case DecisionAN: case MergeAN: case ForkAN: case JoinAN: if ((*cit)->zValue() <= zValue()) ((DiagramCanvas *) di)->upper(); { ActivityContainerCanvas * cntr = dynamic_cast<ActivityContainerCanvas *>(di); if (cntr != 0) cntr->force_sub_upper(all); } break; default: break; } } } } }
Context::AppletToolbarAddItem::AppletToolbarAddItem( QGraphicsItem* parent, Context::Containment* cont, bool fixedAdd ) : AppletToolbarBase( parent ) , m_iconPadding( 0 ) , m_fixedAdd( fixedAdd ) , m_showingAppletExplorer( false ) , m_cont( cont ) , m_icon( 0 ) , m_label( 0 ) { QAction* listAdd = new QAction( i18n( "Add Applets..." ), this ); listAdd->setIcon( KIcon( "list-add" ) ); listAdd->setVisible( true ); listAdd->setEnabled( true ); connect( listAdd, SIGNAL( triggered() ), this, SLOT( iconClicked() ) ); m_icon = new Plasma::IconWidget( this ); m_icon->setAction( listAdd ); m_icon->setText( QString() ); m_icon->setToolTip( listAdd->text() ); m_icon->setDrawBackground( false ); m_icon->setOrientation( Qt::Horizontal ); QSizeF iconSize; if( m_fixedAdd ) iconSize = m_icon->sizeFromIconSize( 22 ); else iconSize = m_icon->sizeFromIconSize( 11 ); m_icon->setMinimumSize( iconSize ); m_icon->setMaximumSize( iconSize ); m_icon->resize( iconSize ); m_icon->setZValue( zValue() + 1 ); m_label = new QGraphicsSimpleTextItem( i18n( "Add Applet..." ), this ); m_label->hide(); if( m_cont ) connect( m_cont->view(), SIGNAL( appletExplorerHid() ), this, SLOT( appletExplorerHid() ) ); if( m_fixedAdd ) setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); else setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred ); // resize( QSizeF( 18, 24 ) ); }
void SceneWidgetContainer::setProxy(QGraphicsProxyWidget *child) { childproxy = child; child->setFlag(ItemIsSelectable, false); QWidget *childwidget = child->widget(); child->setParentItem(this); closepos = QPoint(childwidget->width(), -30); close.setParent(this); close.setPos((QPointF)closepos); setZValue(zValue()+0.5); setFlag(ItemIsMovable, true); QGraphicsDropShadowEffect drop; drop.setBlurRadius(10); drop.setOffset(5); drop.setColor(QColor(10, 10, 10, 200)); setGraphicsEffect(&drop); }