/** * Called when the release event happened on a widget. * If the button pressed isn't left button or the widget isn't an object * widget, the message is cleaned. * If the release event didn't happen on the line of an object and the first * object wasn't selected, nothing is done. If the first object was already * selected, a creation message is made. * If the event happened on the line of an object, the first object or the * second are set, depending on whether the first object was already set or * not. */ void ToolBarStateMessages::mouseReleaseWidget() { //TODO When an association between UMLObjects of invalid types is made, an error message //is shown. Shouldn't also a message be used here? if (m_pMouseEvent->button() != Qt::LeftButton || getCurrentWidget()->baseType() != WidgetBase::wt_Object) { cleanMessage(); return; } if (!m_isObjectWidgetLine && !m_firstObject) { return; } if (!m_isObjectWidgetLine) { setSecondWidget(static_cast<ObjectWidget*>(getCurrentWidget()), CreationMessage); return; } if (!m_firstObject) { setFirstWidget(static_cast<ObjectWidget*>(getCurrentWidget())); } else { setSecondWidget(static_cast<ObjectWidget*>(getCurrentWidget()), NormalMessage); } }
void TabbedArea::widgetResized(const gcn::Event &event) { int width = getWidth() - 2 * getFrameSize() - 2 * mWidgetContainer->getFrameSize(); int height = getHeight() - 2 * getFrameSize() - mWidgetContainer->getY() - 2 * mWidgetContainer->getFrameSize(); mWidgetContainer->setSize(width, height); gcn::Widget *w = getCurrentWidget(); if (w) w->setSize(width, height); // Check whether there is room to show more tabs now. int innerWidth = getWidth() - 4 - mArrowButton[0]->getWidth() - mArrowButton[1]->getWidth(); int newWidth = mVisibleTabsWidth; while (mTabScrollIndex && newWidth < innerWidth) { newWidth += mTabs[mTabScrollIndex - 1].first->getWidth(); if (newWidth < innerWidth) --mTabScrollIndex; } // Move the right arrow to fit the windows content. mArrowButton[1]->setPosition(width - mArrowButton[1]->getWidth(), 0); updateArrowEnableState(); adjustTabPositions(); }
/** * Handler for mouse press events. * Mouse tracking is enabled, any pop up menu removed, the position of the * cursor set and paste state disabled. * Then, the current association or widget are set (if any), and events are * delivered to the specific methods, depending on where the cursor was * pressed. * * @param ome The received event. * @see setCurrentElement() */ void ToolBarState::mousePress(UMLSceneMouseEvent* ome) { setMouseEvent(ome, QEvent::MouseButtonPress); m_pUMLScene->viewport()->setMouseTracking(true); //TODO Doesn't another way of emiting the signal exist? A method only for //that seems a bit dirty. m_pUMLScene->emitRemovePopupMenu(); // TODO: Check who needs this. m_pUMLScene->setPos(m_pMouseEvent->pos()); //TODO check why m_pUMLScene->setPaste(false); setCurrentElement(); if (getCurrentWidget()) { mousePressWidget(); } else if (getCurrentAssociation()) { mousePressAssociation(); } else { mousePressEmpty(); } }
/** * Handler for mouse double click events. * Events are delivered to the specific methods, depending on where the cursor * was pressed. It uses the current widget or association set in press event, * if any. * Then, the scene is scrolled if needed (if the cursor is moved in any of the * 30 pixels width area from left, top, right or bottom sides, and there is * more diagram currently not being shown in that direction). * This method is only called when mouse tracking is enabled and the mouse * is moved. * * @param ome The received event. */ void ToolBarState::mouseMove(UMLSceneMouseEvent* ome) { setMouseEvent(ome, QEvent::MouseMove); if (getCurrentWidget()) { mouseMoveWidget(); } else if (getCurrentAssociation()) { mouseMoveAssociation(); } else { mouseMoveEmpty(); } //Scrolls the view int vx = ome->x(); int vy = ome->y(); int contsX = m_pUMLScene->contentsX(); int contsY = m_pUMLScene->contentsY(); int visw = m_pUMLScene->visibleWidth(); int vish = m_pUMLScene->visibleHeight(); int dtr = visw - (vx-contsX); int dtb = vish - (vy-contsY); int dtt = (vy-contsY); int dtl = (vx-contsX); if (dtr < 30) m_pUMLScene->scrollBy(30-dtr,0); if (dtb < 30) m_pUMLScene->scrollBy(0,30-dtb); if (dtl < 30) m_pUMLScene->scrollBy(-(30-dtl),0); if (dtt < 30) m_pUMLScene->scrollBy(0,-(30-dtt)); }
/** * Handler for mouse release events. * Mouse tracking is disabled and the position of the cursor set. * The events are delivered to the specific methods, depending on where the * cursor was released, and the current association or widget cleaned. * Finally, the current tool is changed if needed. * * @param ome The received event. */ void ToolBarState::mouseRelease(UMLSceneMouseEvent* ome) { setMouseEvent(ome, QEvent::MouseButtonRelease); // Set the position of the mouse // TODO, should only be available in this state? m_pUMLScene->setPos(m_pMouseEvent->pos()); m_pUMLScene->viewport()->setMouseTracking(false); if (getCurrentWidget()) { mouseReleaseWidget(); setCurrentWidget(0); } else if (getCurrentAssociation()) { mouseReleaseAssociation(); setCurrentAssociation(0); } else { mouseReleaseEmpty(); } // Default, rightbutton changes the tool. // The arrow tool overrides the changeTool() function. changeTool(); }
/** * A widget was removed from the UMLScene. * If the widget removed was the current widget, the current widget is set * to 0. * It can be extended in subclasses if needed. */ void ToolBarState::slotWidgetRemoved(UMLWidget* widget) { if (widget == getCurrentWidget()) { setCurrentWidget(0); } }