/** * Shortcut for calling m_pFText->setLink() followed by * this->setTextPosition(). */ void MessageWidget::setLinkAndTextPos() { if (m_pFText) { m_pFText->setLink(this); setTextPosition(); } }
void TextShape::setTextPositionByBaseline(int x, int b, bool from_cider) { int ty = 0, tb = 0; //QT getTextDimensions(NULL, &ty, NULL, NULL, &tb); setTextPosition(x, b - (tb - ty), from_cider); }
void FlatButton::init() { setUsesTextLabel(true); setUsesBigPixmap(true); setAutoRaise(true); setTextPosition( TQToolButton::Under ); setFocusPolicy(TQ_StrongFocus); }
/** * Overrides operation from LinkWidget. * Required by FloatingTextWidget. * * @param ft The text widget which to update. */ void MessageWidget::setMessageText(FloatingTextWidget *ft) { if (ft == NULL) return; ft->setSequenceNumber(m_SequenceNumber); ft->setText(operationText(m_scene)); setTextPosition(); }
WordContainer::WordContainer(Word *myWord) { //constructor used in GSSection, steps to define WordContainer in GSSection; size undefined, depends on lenght of text setText(myWord); setSizeOfRect(); setColor(apperiance->brushDarkGray); setTextPosition(); setTimersAndConnections(); }
WordContainer::WordContainer(int width, int height, Word *myWord, bool isItTranslation) { //constructor used in FCSection, steps to define WordContainer in FCSection; size defined; setIfIsTranslation(isItTranslation); setText(myWord); setFixedSizeOfRect(width, height); setColor(apperiance->brushDarkGray); setTextPosition(); setTimersAndConnections(); }
TeamMenu::TeamMenu() { for (int i = 0; i < TEAMMATE_COUNT; i++) { auto h = addChild<Head>(i % 2 * 250, i / 2 * 100); h->setHaveBox(false); //h->setOnlyHead(true); heads_.push_back(h); //selected_.push_back(0); } button_all_.setText("全選"); button_ok_.setText("確定"); addChild(&button_all_, 0, 300); addChild(&button_ok_, 100, 300); setPosition(200, 150); setTextPosition(20, -30); }
/** * Sets the y-coordinate. * Reimplemented from UMLWidget. * * @param y The y-coordinate to be set. */ void MessageWidget::setY(qreal y) { if (y < getMinY()) { DEBUG(DBG_SRC) << "got out of bounds y position, check the reason" << this->y() << getMinY(); return; } UMLWidget::setY(y); if (m_sequenceMessageType == Uml::SequenceMessage::Creation) { const qreal objWidgetHalfHeight = m_pOw[Uml::RoleType::B]->height() / 2; m_pOw[Uml::RoleType::B]->setY(y - objWidgetHalfHeight); } if (m_pFText && !UMLApp::app()->document()->loading()) { setTextPosition(); emit sigMessageMoved(); } }
//assume the text and all things related to text have already been set void CustomButton::setPosition(int x, int y) { setBackgroundRectanglePosition(x, y); auto textHeight = text.getLocalBounds().height; auto textWidth = text.getLocalBounds().width; auto buttonRectangleWidth = textWidth / 4 + textWidth + textWidth / 4; auto buttonRectangleHeight = textHeight /4 + textHeight + textHeight / 4; //set the rectangle to be large enough to contain padding setBackgroundRectangleSize(buttonRectangleWidth, buttonRectangleHeight); //centering the text is more complicated, we consider the text's x and y offsets auto yOffset = (buttonRectangleHeight - textHeight) / 2; auto xOffset = (buttonRectangleWidth - textWidth) / 2; setTextPosition(x + xOffset, y - yOffset); }
void MessageWidget::slotWidgetMoved(Uml::ID::Type id) { const Uml::ID::Type idA = m_pOw[Uml::RoleType::A]->localID(); const Uml::ID::Type idB = m_pOw[Uml::RoleType::B]->localID(); if (idA != id && idB != id) { DEBUG(DBG_SRC) << "id=" << Uml::ID::toString(id) << ": ignoring for idA=" << Uml::ID::toString(idA) << ", idB=" << Uml::ID::toString(idB); return; } qreal y = this->y(); if (y < getMinY()) y = getMinY(); if (y > getMaxY()) y = getMaxY(); setPos(x(), y); calculateWidget(); if(!m_pFText) return; if (m_scene->selectedCount(true) > 1) return; setTextPosition(); }
void k9CanvasSprite::setText(const QString &text) { m_txtValue=text; setTextPosition(m_textPosition); }
void k9CanvasSprite::setTextColor(const QColor &color) { m_txtColor=color; setTextPosition(m_textPosition); }
void k9CanvasSprite::scalePixmap(int width,int height) { m_pixmap->setPixmap(m_bPixmap.scaled(width,height)); setTextPosition(m_textPosition); }
void k9CanvasSprite::setPixmap(const QPixmap &pixmap) { m_bPixmap=pixmap; m_pixmap->setPixmap(pixmap); setTextPosition(m_textPosition); }
void k9CanvasSprite::mouseMoveEvent ( QGraphicsSceneMouseEvent * event ) { QRectF oldRect=sceneBoundingRect(); //oldRect.adjust(pos().x(),pos().y(),pos().x(),pos().y()); QPointF offset; QSizeF s(m_pixmap->pixmap().size()); switch(m_resize) { case STL: offset= event->scenePos() - event->lastScenePos(); setPos(pos()+offset); s-=QSize(offset.x(),offset.y()); if (s.width()>0 && s.height()>0) { m_pixmap->setPixmap(m_bPixmap.scaled(s.toSize())); } break; case SBL: offset= event->scenePos() - event->lastScenePos(); setPos(pos().x()+offset.x(),pos().y()); s-=QSize(offset.x(),-offset.y()); if (s.width()>0 && s.height()>0) { m_pixmap->setPixmap(m_bPixmap.scaled(s.toSize())); } break; case STR: offset= event->scenePos() - event->lastScenePos(); setPos(pos().x(),pos().y()+offset.y()); s+=QSize(offset.x(),-offset.y()); if (s.width()>0 && s.height()>0) { m_pixmap->setPixmap(m_bPixmap.scaled(s.toSize())); } break; case SBR: offset= event->scenePos() - event->lastScenePos(); s+=QSize(offset.x(),offset.y()); if (s.width()>0 && s.height()>0) { m_pixmap->setPixmap(m_bPixmap.scaled(s.toSize())); } break; case STC: offset=QPointF(0,event->scenePos().y()-event->lastScenePos().y()); setPos(pos().x(),pos().y()+offset.y()); s-=QSize(offset.x(),offset.y()); if (s.width()>0 && s.height()>0) { m_pixmap->setPixmap(m_bPixmap.scaled(s.toSize())); } break; case SBC: offset=QPointF(0,event->scenePos().y()-event->lastScenePos().y()); s+=QSize(offset.x(),offset.y()); if (s.width()>0 && s.height()>0) { m_pixmap->setPixmap(m_bPixmap.scaled(s.toSize())); } break; case SML: offset=QPointF(event->scenePos().x()-event->lastScenePos().x(),0); setPos(pos().x()+offset.x(),pos().y()); s-=QSize(offset.x(),offset.y()); if (s.width()>0 && s.height()>0) { m_pixmap->setPixmap(m_bPixmap.scaled(s.toSize())); } break; case SMR: offset=QPointF(event->scenePos().x()-event->lastScenePos().x(),0); s+=QSize(offset.x(),offset.y()); m_pixmap->setPixmap(m_bPixmap.scaled(s.toSize())); break; default: break; } if (m_resize != SNONE) { setTextPosition(m_textPosition); update(boundingRect()); scene()->update(oldRect); }else QGraphicsItemGroup::mouseMoveEvent(event); }
/** * Activates a MessageWidget. Connects its m_pOw[] pointers * to UMLObjects and also send signals about its FloatingTextWidget. */ bool MessageWidget::activate(IDChangeLog * /*Log = 0*/) { m_scene->resetPastePoint(); // UMLWidget::activate(Log); CHECK: I don't think we need this ? if (m_pOw[Uml::RoleType::A] == NULL) { UMLWidget *pWA = m_scene->findWidget(m_widgetAId); if (pWA == NULL) { DEBUG(DBG_SRC) << "role A object " << Uml::ID::toString(m_widgetAId) << " not found"; return false; } m_pOw[Uml::RoleType::A] = dynamic_cast<ObjectWidget*>(pWA); if (m_pOw[Uml::RoleType::A] == NULL) { DEBUG(DBG_SRC) << "role A widget " << Uml::ID::toString(m_widgetAId) << " is not an ObjectWidget"; return false; } } if (m_pOw[Uml::RoleType::B] == NULL) { UMLWidget *pWB = m_scene->findWidget(m_widgetBId); if (pWB == NULL) { DEBUG(DBG_SRC) << "role B object " << Uml::ID::toString(m_widgetBId) << " not found"; return false; } m_pOw[Uml::RoleType::B] = dynamic_cast<ObjectWidget*>(pWB); if (m_pOw[Uml::RoleType::B] == NULL) { DEBUG(DBG_SRC) << "role B widget " << Uml::ID::toString(m_widgetBId) << " is not an ObjectWidget"; return false; } } updateResizability(); UMLClassifier *c = dynamic_cast<UMLClassifier*>(m_pOw[Uml::RoleType::B]->umlObject()); UMLOperation *op = NULL; if (c && !m_CustomOp.isEmpty()) { Uml::ID::Type opId = Uml::ID::fromString(m_CustomOp); op = dynamic_cast<UMLOperation*>(c->findChildObjectById(opId, true)); if (op) { // If the UMLOperation is set, m_CustomOp isn't used anyway. // Just setting it empty for the sake of sanity. m_CustomOp.clear(); } } if(!m_pFText) { Uml::TextRole::Enum tr = Uml::TextRole::Seq_Message; if (isSelf()) tr = Uml::TextRole::Seq_Message_Self; m_pFText = new FloatingTextWidget(m_scene, tr, operationText(m_scene)); m_scene->addFloatingTextWidget(m_pFText); m_pFText->setFontCmd(UMLWidget::font()); } if (op) setOperation(op); // This requires a valid m_pFText. setLinkAndTextPos(); m_pFText->setText(QString()); m_pFText->setActivated(); QString messageText = m_pFText->text(); m_pFText->setVisible(messageText.length() > 1); connect(m_pOw[Uml::RoleType::A], SIGNAL(sigWidgetMoved(Uml::ID::Type)), this, SLOT(slotWidgetMoved(Uml::ID::Type))); connect(m_pOw[Uml::RoleType::B], SIGNAL(sigWidgetMoved(Uml::ID::Type)), this, SLOT(slotWidgetMoved(Uml::ID::Type))); connect(this, SIGNAL(sigMessageMoved()), m_pOw[Uml::RoleType::A], SLOT(slotMessageMoved())); connect(this, SIGNAL(sigMessageMoved()), m_pOw[Uml::RoleType::B], SLOT(slotMessageMoved())); m_pOw[Uml::RoleType::A]->messageAdded(this); if (!isSelf()) m_pOw[Uml::RoleType::B]->messageAdded(this); // Calculate the size and position of the message widget calculateDimensions(); // Position the floating text accordingly setTextPosition(); emit sigMessageMoved(); return true; }