void hdSelectAreaTool::mouseUp(hdMouseEvent &event) { hdAbstractTool::mouseUp(event); hdGeometry g; //hack-fix for bug when selecting figures from right to left if(event.LeftUp()) { if( selectionRect.width < 0 ) { int tmp; tmp = selectionRect.width; selectionRect.x += tmp; selectionRect.width = g.ddabs(tmp); } if( selectionRect.height < 0 ) { int tmp; tmp = selectionRect.height; selectionRect.y += tmp; selectionRect.height = g.ddabs(tmp); } //end hack-fix drawSelectionRect(event.getView()); selectFiguresOnRect(event.ShiftDown(), event.getView()); event.getView()->disableSelRectDraw(); } }
void hdSelectionTool::mouseDown(hdMouseEvent &event) { hdITool::mouseDown(event); hdDrawingView *view = event.getView(); int x = event.GetPosition().x, y = event.GetPosition().y; hdIHandle *handle = view->findHandle(view->getIdx(), x, y); if(handle) { setDelegateTool(view, new hdHandleTrackerTool(view, handle)); } else { hdIFigure *figure = view->getDrawing()->findFigure(view->getIdx(), x, y); if(figure) { view->getDrawing()->bringToFront(figure); setDelegateTool(event.getView(), figure->CreateFigureTool(view, new hdDragTrackerTool(view, figure))); } else { setDelegateTool(event.getView(), new hdCanvasMenuTool(view, new hdSelectAreaTool(view)) ); } } hdITool *delegateTool = getDelegateTool(); if (delegateTool) delegateTool->mouseDown(event); }
void hdDragCreationTool::mouseDrag(hdMouseEvent &event) { if(event.LeftIsDown()) { figurePrototype->displayBox().SetPosition(event.getView()->getIdx(), event.GetPosition()); } }
void hdPolyLineHandle::invokeStep(hdMouseEvent &event, hdDrawingView *view) { int x = event.GetPosition().x, y = event.GetPosition().y; ((hdPolyLineFigure *) getOwner())->setPointAt(view->getIdx(), indx, x, y); view->notifyChanged(); }
void ddSouthTableSizeHandle::invokeStep(hdMouseEvent &event, hdDrawingView *view) { int y = event.GetPosition().y; ddTableFigure *table = (ddTableFigure *) getOwner(); wxFont font = *hdFontAttribute::defaultFont; int colOffset = table->getColDefaultHeight(font); int divBy = (table->getTotalColumns() - table->getColumnsWindow()); if(divBy <= 0) divBy = table->getColumnsWindow(); hdGeometry g; if ( g.ddabs(anchorY - y) > colOffset) { if((anchorY - y) > 0) { table->setColumnsWindow(view->getIdx(), table->getColumnsWindow() - 1); } else { table->setColumnsWindow(view->getIdx(), table->getColumnsWindow() + 1); } anchorY = y; } //hack to update relationship position when table size change table->manuallyNotifyChange(view->getIdx()); view->notifyChanged(); }
void ddAddFkButtonHandle::invokeStart(hdMouseEvent &event, hdDrawingView *view) { if(getOwner()->ms_classInfo.IsKindOf(&ddTableFigure::ms_classInfo)) { ddRelationshipFigure *fkConnection = new ddRelationshipFigure(); //Check figure available positions for diagrams, add at least needed to allow initialization of the class int i, start; start = fkConnection->displayBox().CountPositions(); for(i = start; i < (view->getIdx() + 1); i++) { fkConnection->AddPosForNewDiagram(); } fkConnection->setStartTerminal(new ddRelationshipTerminal(fkConnection, false)); fkConnection->setEndTerminal(new ddRelationshipTerminal(fkConnection, true)); hdConnectionCreationTool *conn = new hdConnectionCreationTool(view, fkConnection); view->setTool(conn); // Simulate button down to start connection of foreign key wxMouseEvent e(wxEVT_LEFT_DOWN); e.m_x = event.GetPosition().x; e.m_y = event.GetPosition().y; e.SetEventObject(view); hdMouseEvent evento(e, view); conn->mouseDown(evento); ddTableFigure *table = (ddTableFigure *) getOwner(); table->setSelectFkDestMode(true); view->notifyChanged(); } }
void hdLineConnectionHandle::invokeEnd(hdMouseEvent &event, hdDrawingView *view) { int x = event.GetPosition().x, y = event.GetPosition().y; hdPolyLineFigure *figure = (hdPolyLineFigure *) getOwner(); //eliminate all handles in the middle of a straight line if( figure->pointCount(view->getIdx()) > 2 && getIndex() != 0 && getIndex() != (figure->pointCount(view->getIdx()) - 1) ) { hdPoint p1 = figure->pointAt(view->getIdx(), getIndex() - 1); hdPoint p2 = figure->pointAt(view->getIdx(), getIndex() + 1); hdGeometry g; if(g.lineContainsPoint(p1.x, p1.y, p2.x, p2.y, x, y)) { figure->removePointAt(view->getIdx(), getIndex()); } } }
void hdPolyLineHandle::invokeStart(hdMouseEvent &event, hdDrawingView *view) { if(event.RightDown()) { ((hdPolyLineFigure *) getOwner())->removePointAt(view->getIdx(), indx); view->notifyChanged(); } }
void ddScrollBarHandle::invokeStart(hdMouseEvent &event, hdDrawingView *view) { int idx = view->getIdx(); int y = event.GetPosition().y; anchorY = y; if( (y > (getDisplayBox(idx).GetPosition().y + 2)) && (y < (getDisplayBox(idx).GetPosition().y + 2 + 6)) ) //6 image height table->columnsWindowUp(idx); if( (y > (getDisplayBox(idx).GetPosition().y + getDisplayBox(idx).height - 2 - downBitmap.GetHeight()) ) && (y < (getDisplayBox(idx).GetPosition().y + getDisplayBox(idx).height - 2) ) ) table->columnsWindowDown(idx); view->notifyChanged(); }
void hdDragTrackerTool::mouseDrag(hdMouseEvent &event) { hdAbstractTool::mouseDrag(event); if(event.LeftIsDown()) { int x = event.GetPosition().x, y = event.GetPosition().y; //Hack to avoid a weird bug that ocurrs when use double click very fast over figure and drag a same time, lastX //and lastY values becomes big negatives numbers, if this happens, then reset it to click point if(lastX < 0) lastX = x; if(lastY < 0) lastY = y; hasMovedValue = (abs (x - anchorX) > 4 || abs (y - anchorX) > 4); if (hasMoved()) { hdIFigure *tmp = NULL; hdIteratorBase *iterator = event.getView()->getDrawing()->selectionFigures(); while(iterator->HasNext()) { tmp = (hdIFigure *)iterator->Next(); tmp->moveBy(event.getView()->getIdx(), x - lastX, y - lastY); event.getView()->notifyChanged(); } delete iterator; } setLastCoords (x, y); } }
void hdCreationTool::mouseDown(hdMouseEvent &event) { hdAbstractTool::mouseDown(event); if(event.LeftDown()) { event.getView()->getDrawing()->add(figurePrototype); int x = event.GetPosition().x, y = event.GetPosition().y; figurePrototype->moveTo(event.getView()->getIdx(), x, y); event.getView()->getDrawing()->clearSelection(); event.getView()->getDrawing()->addToSelection(figurePrototype); } }
void hdCanvasMenuTool::mouseDown(hdMouseEvent &event) { //Linux hack for bug int x = event.GetPosition().x, y = event.GetPosition().y; setAnchorCoords(x, y); if(event.RightDown()) { wxMenu menu; event.getView()->setCanvasMenuTool(this); createViewMenu(event.getView(), menu); event.getView()->connectPopUpMenu(menu); hdPoint p = event.GetPosition(); event.getView()->CalcScrolledPosition(p.x, p.y, &p.x, &p.y); event.getView()->PopupMenu(&menu, p); return; } defaultTool->mouseDown(event); }
void hdSelectionTool::mouseMove(hdMouseEvent &event) { hdAbstractTool::mouseMove(event); hdDrawingView *view = event.getView(); int x = event.GetPosition().x, y = event.GetPosition().y; hdIHandle *handle = view->findHandle(view->getIdx(), x, y); if(handle) { view->SetCursor(handle->createCursor()); } else { hdIFigure *figure = view->getDrawing()->findFigure(view->getIdx(), x, y); if(figure) { view->SetCursor(wxCursor(wxCURSOR_HAND)); } else { view->SetCursor(wxCursor(wxCURSOR_ARROW)); } } }
void hdSelectAreaTool::mouseDrag(hdMouseEvent &event) { hdAbstractTool::mouseDrag(event); if(event.LeftIsDown()) { drawSelectionRect(event.getView()); int x = event.GetPosition().x, y = event.GetPosition().y; selectionRect.x = anchorX; selectionRect.y = anchorY; selectionRect.SetBottomRight(wxPoint(x, y)); drawSelectionRect(event.getView()); event.getView()->ScrollToMakeVisible(event.GetPosition()); } }
void hdMenuTool::mouseDown(hdMouseEvent &event) { //Linux hack for bug int x = event.GetPosition().x, y = event.GetPosition().y; setAnchorCoords(x, y); if(menuFigure->menuEnabled() && event.RightDown()) { wxMenu menu; event.getView()->setMenuToolFigure(menuFigure); menuFigure->createMenu(menu); event.getView()->connectPopUpMenu(menu); hdPoint p = event.GetPosition(); event.getView()->CalcScrolledPosition(p.x, p.y, &p.x, &p.y); event.getView()->PopupMenu(&menu, p); return; } getDefaultTool()->mouseDown(event); }
void hdSelectAreaTool::mouseDown(hdMouseEvent &event) { hdAbstractTool::mouseDown(event); if(!event.ShiftDown()) { event.getView()->getDrawing()->clearSelection(); } if(event.LeftDown()) { int x = event.GetPosition().x, y = event.GetPosition().y; selectionRect.x = x; selectionRect.y = y; selectionRect.width = 0; selectionRect.height = 0; drawSelectionRect(event.getView()); } }
void hdDragTrackerTool::mouseDown(hdMouseEvent &event) { hdAbstractTool::mouseDown(event); if(event.LeftDown()) { int x = event.GetPosition().x, y = event.GetPosition().y; setLastCoords(x, y); if(event.m_shiftDown) { event.getView()->getDrawing()->toggleSelection(anchorFigure); } else if(!event.getView()->getDrawing()->isFigureSelected(anchorFigure)) { event.getView()->getDrawing()->clearSelection(); event.getView()->getDrawing()->addToSelection(anchorFigure); } } }
void ddScrollBarHandle::invokeStep(hdMouseEvent &event, hdDrawingView *view) { int y = event.GetPosition().y; int divBy = (table->getTotalColumns() - table->getColumnsWindow()); if(divBy <= 0) divBy = table->getColumnsWindow(); int colOffset = barSize.GetHeight() / divBy; hdGeometry g; if ( g.ddabs(anchorY - y) > colOffset) { if((anchorY - y) > 0) { table->columnsWindowUp(view->getIdx()); } else { table->columnsWindowDown(view->getIdx()); } anchorY = y; } view->notifyChanged(); }
void hdCreationTool::mouseUp(hdMouseEvent &event) { hdAbstractTool::mouseUp(event); event.getView()->setTool(new hdSelectionTool(event.getView())); }
void ddSouthTableSizeHandle::invokeStart(hdMouseEvent &event, hdDrawingView *view) { anchorY = event.GetPosition().y; }
void hdHandleTrackerTool::mouseDrag(hdMouseEvent &event) { anchorHandle->invokeStep(event, event.getView()); }
void hdHandleTrackerTool::mouseUp(hdMouseEvent &event) { anchorHandle->invokeEnd(event, event.getView()); }
void hdHandleTrackerTool::mouseDown(hdMouseEvent &event) { hdAbstractTool::mouseDown(event); anchorHandle->invokeStart(event, event.getView()); }
void hdSimpleTextTool::mouseDown(hdMouseEvent &event) { setAnchorCoords(event.GetPosition().x, event.GetPosition().y); // Right click to get the contextual menu if(txtFigure->menuEnabled() && event.RightDown()) { wxMenu menu; event.getView()->setSimpleTextToolFigure(txtFigure, true); txtFigure->createMenu(menu); event.getView()->connectPopUpMenu(menu); hdPoint p = event.GetPosition(); event.getView()->CalcScrolledPosition(p.x, p.y, &p.x, &p.y); event.getView()->PopupMenu(&menu, p); return; } // Double click to rename an object if(event.LeftDClick()) { if(withoutDialog) { event.getView()->setSimpleTextToolFigure(txtFigure); showEdit = true; event.getView()->getSimpleTextToolEdit()->ChangeValue(txtFigure->getText()); //Same as SetValue but don't generated wxEVT_COMMAND_TEXT_UPDATED event calculateSizeEntry(event.getView()); event.getView()->getSimpleTextToolEdit()->SetFocus(); event.getView()->getSimpleTextToolEdit()->Show(); event.getView()->getOkTxt()->Show(); event.getView()->getCancelTxt()->Show(); } else { callDialog(event.getView()); } return; } getDefaultTool()->mouseDown(event); }