27#include "tool_select.h"
29#include "kivio_view.h"
31#include "kivio_canvas.h"
32#include "kivio_page.h"
34#include "kivio_custom_drag_data.h"
35#include "kivio_layer.h"
36#include "kivio_stencil.h"
38#include <tdeactionclasses.h>
39#include <tdepopupmenu.h>
41#include <KoZoomHandler.h>
45#include "kivio_command.h"
49#include "kivio_pluginmanager.h"
51SelectTool::SelectTool( KivioView* parent ) : Kivio::
MouseTool(parent,
"Selection Mouse Tool")
53 view()->pluginManager()->setDefaultTool(
this);
55 TDEShortcut selectShortCut(Key_Space);
56 selectShortCut.setSeq(1, TQKeySequence(Key_Escape));
57 m_selectAction =
new TDERadioAction(i18n(
"&Select"),
"select", selectShortCut, actionCollection(),
"select");
58 connect(m_selectAction, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(setActivated(
bool)));
60 m_textEditAction =
new TDEAction(i18n(
"&Edit Text..."),
"text", Key_F2,
61 this, TQ_SLOT(editStencilText()), actionCollection(),
"editText");
62 (void)
new TDEAction(i18n(
"Format &Stencils && Connectors..."), 0, 0, view(), TQ_SLOT(stencilFormat()),
63 actionCollection(),
"formatStencil");
64 m_arrowHeadAction =
new TDEAction(i18n(
"Format &Arrowheads..."), 0, 0, view(), TQ_SLOT(arrowHeadFormat()),
65 actionCollection(),
"formatConnector");
68 m_pResizingStencil = NULL;
69 m_pCustomDraggingStencil = NULL;
71 m_lstOldGeometry.setAutoDelete(
true);
76SelectTool::~SelectTool()
87bool SelectTool::processEvent(TQEvent* e)
89 KivioCanvas* canvas = view()->canvasWidget();
94 case TQEvent::MouseButtonDblClick:
95 m = (TQMouseEvent *)e;
97 if( m->button() == TQt::LeftButton ) {
98 leftDoubleClick(m->pos());
105 case TQEvent::MouseButtonPress:
106 m = (TQMouseEvent *)e;
108 if( m->button() == TQt::RightButton ) {
109 showPopupMenu(m->globalPos());
110 }
else if( m->button() == TQt::LeftButton ) {
111 if(m->state() & ControlButton) {
114 m_controlKey =
false;
117 mousePress( m->pos() );
124 case TQEvent::MouseButtonRelease:
125 mouseRelease( ((TQMouseEvent *)e)->pos() );
130 case TQEvent::MouseMove:
131 mouseMove(
static_cast<TQMouseEvent*
>(e));
135 case TQEvent::KeyPress:
136 if((
static_cast<TQKeyEvent*
>(e)->key() >= Key_Left) && (
static_cast<TQKeyEvent*
>(e)->key() <= Key_Down)) {
137 keyPress(
static_cast<TQKeyEvent*
>(e));
149void SelectTool::setActivated(
bool a)
152 m_selectAction->setChecked(
true);
153 view()->canvasWidget()->unsetCursor();
156 }
else if(m_selectAction->isChecked()) {
157 m_selectAction->setChecked(
false);
158 view()->canvasWidget()->activePage()->setPaintSelected(
true);
165void SelectTool::select(
const TQRect &r)
168 KoPoint startPoint = view()->canvasWidget()->mapFromScreen( TQPoint( r.x(), r.y() ) );
169 KoPoint releasePoint = view()->canvasWidget()->mapFromScreen( TQPoint( r.x() + r.width(), r.y() + r.height() ) );
175 x = startPoint.x() < releasePoint.x() ? startPoint.x() : releasePoint.x();
176 y = startPoint.y() < releasePoint.y() ? startPoint.y() : releasePoint.y();
179 w = releasePoint.x() - startPoint.x();
185 h = releasePoint.y() - startPoint.y();
192 view()->activePage()->selectStencils( x, y, w, h );
195void SelectTool::mousePress(
const TQPoint &pos)
198 m_lastPoint = view()->canvasWidget()->mapFromScreen(pos);
199 m_origPoint = m_lastPoint;
202 if( startCustomDragging(pos,
true) )
204 m_mode = stmCustomDragging;
209 if( startResizing(pos) )
211 m_mode = stmResizing;
217 if( startCustomDragging(pos,
false) )
219 m_mode = stmCustomDragging;
224 if( startDragging(pos,
false) )
226 m_mode = stmDragging;
231 if( startRubberBanding(pos) )
233 m_mode = stmDrawRubber;
242bool SelectTool::startRubberBanding(
const TQPoint &pos)
244 KivioCanvas* canvas = view()->canvasWidget();
247 canvas->activePage()->unselectAllStencils();
249 canvas->startRectDraw( pos, KivioCanvas::Rubber );
259bool SelectTool::startDragging(
const TQPoint &pos,
bool onlySelected)
261 KivioCanvas* canvas = view()->canvasWidget();
262 KivioPage *pPage = canvas->activePage();
263 KivioStencil *pStencil;
267 double threshold = view()->zoomHandler()->unzoomItY(4);
269 KoPoint pagePoint = canvas->mapFromScreen( pos );
271 pStencil = pPage->checkForStencil( &pagePoint, &colType, threshold, onlySelected );
276 canvas->setEnabled(
false);
278 if( pStencil->isSelected() )
282 if( m_controlKey==
true ) {
283 pPage->unselectStencil( pStencil );
292 pPage->unselectAllStencils();
294 pPage->selectStencil( pStencil );
296 view()->canvasWidget()->updateAutoGuideLines();
300 canvas->beginUnclippedSpawnerPainter();
303 KivioSelectDragData *pData;
304 m_lstOldGeometry.clear();
305 pStencil = canvas->activePage()->selectedStencils()->first();
309 pData =
new KivioSelectDragData;
310 pData->rect = pStencil->rect();
311 m_lstOldGeometry.append(pData);
313 pStencil = canvas->activePage()->selectedStencils()->next();
316 m_selectedRect = view()->activePage()->getRectForAllSelectedStencils();
317 changeMouseCursor(pos);
319 m_mode = stmDragging;
321 canvas->setEnabled(
true);
325bool SelectTool::startCustomDragging(
const TQPoint &pos,
bool selectedOnly )
327 KivioCanvas* canvas = view()->canvasWidget();
328 KivioPage *pPage = canvas->activePage();
329 KivioStencil *pStencil;
332 KoPoint pagePoint = canvas->mapFromScreen( pos );
335 double threshold = view()->zoomHandler()->unzoomItY(4);
337 pStencil = pPage->checkForStencil( &pagePoint, &colType, threshold, selectedOnly );
339 if( !pStencil || colType < kctCustom ) {
344 if(pStencil->isSelected()) {
348 pPage->unselectStencil(pStencil);
353 pPage->unselectAllStencils();
356 pPage->selectStencil( pStencil );
359 m_pCustomDraggingStencil = pStencil;
362 m_mode = stmCustomDragging;
364 m_customDragID = colType;
365 m_customDragOrigPoint = pStencil->customIDPoint(m_customDragID);
367 view()->canvasWidget()->setShowConnectorTargets(
true);
368 view()->canvasWidget()->repaint();
371 canvas->beginUnclippedSpawnerPainter();
380bool SelectTool::startResizing(
const TQPoint &pos)
382 KivioCanvas* canvas = view()->canvasWidget();
383 KoPoint pagePoint = canvas->mapFromScreen(pos);
384 KivioSelectDragData *pData;
386 double x = pagePoint.x();
387 double y = pagePoint.y();
390 KivioStencil *pStencil = canvas->activePage()->selectedStencils()->first();
393 m_resizeHandle = isOverResizeHandle(pStencil, x, y);
394 if( m_resizeHandle > 0 )
396 switch( m_resizeHandle )
399 m_origPoint.setCoords(pStencil->x(), pStencil->y());
403 m_origPoint.setCoords((pStencil->x() + pStencil->w()) / 2.0, pStencil->y());
407 m_origPoint.setCoords(pStencil->x() + pStencil->w(), pStencil->y());
411 m_origPoint.setCoords(pStencil->x() + pStencil->w(), (pStencil->y() + pStencil->h()) / 2.0);
415 m_origPoint.setCoords(pStencil->x() + pStencil->w(), pStencil->y() + pStencil->h());
419 m_origPoint.setCoords((pStencil->x() + pStencil->w()) / 2.0, pStencil->y() + pStencil->h());
423 m_origPoint.setCoords(pStencil->x(), pStencil->y() + pStencil->h());
427 m_origPoint.setCoords(pStencil->x(), (pStencil->y() + pStencil->h()) / 2.0);
431 m_lstOldGeometry.clear();
432 pData =
new KivioSelectDragData;
433 pData->rect = pStencil->rect();
434 m_lstOldGeometry.append(pData);
436 m_pResizingStencil = pStencil;
439 canvas->beginUnclippedSpawnerPainter();
445 pStencil = canvas->activePage()->selectedStencils()->next();
453void SelectTool::mouseMove(TQMouseEvent* e)
455 TQPoint pos = e->pos();
456 bool ignoreGridGuides = e->state() & ShiftButton;
461 continueRubberBanding(pos);
465 continueDragging(pos, ignoreGridGuides);
468 case stmCustomDragging:
469 continueCustomDragging(pos);
473 continueResizing(pos, ignoreGridGuides);
477 changeMouseCursor(pos);
481 m_lastPoint = view()->canvasWidget()->mapFromScreen(pos);
484void SelectTool::continueRubberBanding(
const TQPoint &pos)
486 view()->canvasWidget()->continueRectDraw( pos, KivioCanvas::Rubber );
497void SelectTool::continueDragging(
const TQPoint &pos,
bool ignoreGridGuides)
499 KivioCanvas* canvas = view()->canvasWidget();
500 KoPoint pagePoint = canvas->mapFromScreen( pos );
502 double dx = pagePoint.x() - m_origPoint.x();
503 double dy = pagePoint.y() - m_origPoint.y();
512 canvas->drawSelectedStencilsXOR();
514 canvas->activePage()->setPaintSelected(
false);
522 newX = m_selectedRect.x() + dx;
523 newY = m_selectedRect.y() + dy;
525 if(!ignoreGridGuides) {
527 p.setCoords(newX, newY);
529 p = canvas->snapToGrid(p);
536 p.setCoords(m_selectedRect.x() + dx + m_selectedRect.width(), m_selectedRect.y() + dy + m_selectedRect.height());
537 p = canvas->snapToGuides(p, snappedX, snappedY);
540 newX = p.x() - m_selectedRect.width();
544 newY = p.y() - m_selectedRect.height();
548 p.setCoords(m_selectedRect.x() + dx + (m_selectedRect.width() / 2.0),
549 m_selectedRect.y() + dy + (m_selectedRect.height() / 2.0));
550 p = canvas->snapToGuides(p, snappedX, snappedY);
553 newX = p.x() - (m_selectedRect.width() / 2.0);
557 newY = p.y() - (m_selectedRect.height() / 2.0);
561 p.setCoords(m_selectedRect.x() + dx, m_selectedRect.y() + dy);
562 p = canvas->snapToGuides(p, snappedX, snappedY);
573 dx = newX - m_selectedRect.x();
574 dy = newY - m_selectedRect.y();
576 KivioSelectDragData *pData;
577 KivioStencil *pStencil = canvas->activePage()->selectedStencils()->first();
578 pData = m_lstOldGeometry.first();
580 while( pStencil && pData )
582 newX = pData->rect.x() + dx;
583 newY = pData->rect.y() + dy;
585 if( pStencil->protection()->at( kpX ) ==
false ) {
586 pStencil->setX(newX);
588 if( pStencil->protection()->at( kpY ) ==
false ) {
589 pStencil->setY(newY);
592 pData = m_lstOldGeometry.next();
593 pStencil = canvas->activePage()->selectedStencils()->next();
597 canvas->drawSelectedStencilsXOR();
598 view()->updateToolBars();
601void SelectTool::continueCustomDragging(
const TQPoint &pos)
603 KivioCanvas* canvas = view()->canvasWidget();
604 KoPoint pagePoint = canvas->mapFromScreen(pos);
607 if(m_pCustomDraggingStencil->type() == kstConnector){
608 pagePoint = canvas->activePage()->snapToTarget(pagePoint, 8.0, hit);
612 pagePoint = canvas->snapToGridAndGuides( pagePoint );
615 KivioCustomDragData data;
616 data.page = canvas->activePage();
617 data.dx = pagePoint.x() - m_lastPoint.x();
618 data.dy = pagePoint.y() - m_lastPoint.y();
619 data.x = pagePoint.x();
620 data.y = pagePoint.y();
621 data.id = m_customDragID;
622 data.scale = view()->zoomHandler()->zoomedResolutionY();
625 if(m_pCustomDraggingStencil->type() != kstConnector){
628 canvas->drawStencilXOR(m_pCustomDraggingStencil);
630 m_pCustomDraggingStencil->setHidden(
true);
637 if( m_pCustomDraggingStencil )
638 m_pCustomDraggingStencil->customDrag( &data );
641 if(m_pCustomDraggingStencil->type() != kstConnector){
642 canvas->drawStencilXOR(m_pCustomDraggingStencil);
644 view()->canvasWidget()->repaint();
647 view()->updateToolBars();
651void SelectTool::continueResizing(
const TQPoint &pos,
bool ignoreGridGuides)
653 KivioCanvas* canvas = view()->canvasWidget();
654 KoPoint pagePoint = canvas->mapFromScreen(pos);
656 if(!ignoreGridGuides) {
657 pagePoint = canvas->snapToGridAndGuides( pagePoint );
660 KivioSelectDragData *pData = m_lstOldGeometry.first();
677 kdDebug(43000) <<
"SelectTool::continueResizing() - Original geometry not found" << endl;
681 double dx = pagePoint.x() - m_origPoint.x();
682 double dy = pagePoint.y() - m_origPoint.y();
684 if((dx > 0) || (dy > 0) || (dx < 0) || (dy < 0)) {
687 canvas->drawStencilXOR( m_pResizingStencil );
689 m_pResizingStencil->setHidden(
true);
694 double sx = pData->rect.x();
695 double sy = pData->rect.y();
696 double sw = pData->rect.width();
697 double sh = pData->rect.height();
698 double ratio = sw / sh;
700 switch( m_resizeHandle )
703 if( m_pResizingStencil->protection()->testBit( kpWidth )==
false &&
704 m_pResizingStencil->protection()->testBit( kpHeight )==
false )
706 if((dx > dy) && (dx != 0)) {
712 m_pResizingStencil->setX( sx + dx );
713 m_pResizingStencil->setW( sw - dx );
715 m_pResizingStencil->setY( sy + dy );
716 m_pResizingStencil->setH( sh - dy );
721 if( m_pResizingStencil->protection()->testBit( kpHeight )==
false )
723 m_pResizingStencil->setY( sy + dy );
724 m_pResizingStencil->setH( sh - dy );
729 if( m_pResizingStencil->protection()->testBit( kpHeight )==
false &&
730 m_pResizingStencil->protection()->testBit( kpWidth )==
false )
732 if((dx > dy) && (dx != 0)) {
738 m_pResizingStencil->setY( sy + dy );
739 m_pResizingStencil->setH( sh - dy );
741 m_pResizingStencil->setW( sw + dx );
746 if( m_pResizingStencil->protection()->testBit( kpWidth )==
false )
750 m_pResizingStencil->setW( sw + dx );
755 if( m_pResizingStencil->protection()->testBit( kpWidth )==
false &&
756 m_pResizingStencil->protection()->testBit( kpHeight )==
false )
758 if((dx > dy) && (dx != 0)) {
764 m_pResizingStencil->setW( sw + dx );
765 m_pResizingStencil->setH( sh + dy );
770 if( m_pResizingStencil->protection()->testBit( kpHeight )==
false )
772 m_pResizingStencil->setH( sh + dy );
777 if( m_pResizingStencil->protection()->testBit( kpWidth )==
false &&
778 m_pResizingStencil->protection()->testBit( kpHeight )==
false )
780 if((dx > dy) && (dx != 0)) {
786 m_pResizingStencil->setX( sx + dx );
787 m_pResizingStencil->setW( sw - dx );
789 m_pResizingStencil->setH( sh + dy );
794 if( m_pResizingStencil->protection()->testBit( kpWidth )==
false )
796 KoPoint pinPoint = m_pResizingStencil->pinPoint();
797 m_pResizingStencil->setPinPoint(KoPoint(pinPoint.x() - (dx / 2.0), pinPoint.y()));
798 m_pResizingStencil->setX( sx + dx );
799 m_pResizingStencil->setW( sw - dx );
804 kdDebug(43000) <<
"SelectTool::continueResizing() - unknown resize handle: " << m_resizeHandle << endl;
808 canvas->drawStencilXOR( m_pResizingStencil );
809 view()->updateToolBars();
817void SelectTool::changeMouseCursor(
const TQPoint &pos)
819 KivioCanvas* canvas = view()->canvasWidget();
820 KoPoint pagePoint = canvas->mapFromScreen(pos);
821 KivioStencil *pStencil;
822 double threshold = view()->zoomHandler()->unzoomItY(4);
826 pStencil = canvas->activePage()->selectedStencils()->first();
829 cursorType = isOverResizeHandle(pStencil, pagePoint.x(), pagePoint.y());
833 canvas->setCursor( sizeFDiagCursor );
837 canvas->setCursor( sizeVerCursor );
841 canvas->setCursor( sizeBDiagCursor );
845 canvas->setCursor( sizeHorCursor );
849 canvas->setCursor( sizeFDiagCursor );
853 canvas->setCursor( sizeVerCursor );
857 canvas->setCursor( sizeBDiagCursor );
861 canvas->setCursor( sizeHorCursor );
865 if( pStencil->checkForCollision( &pagePoint, threshold )!= kctNone )
867 canvas->setCursor( sizeAllCursor );
875 pStencil = canvas->activePage()->selectedStencils()->next();
878 canvas->unsetCursor();
885#define RESIZE_BOX_TEST( x, y, bx, by ) \
886x >= bx-three_pixels && \
887x <= bx+three_pixels && \
888y >= by-three_pixels && \
894int SelectTool::isOverResizeHandle( KivioStencil *pStencil,
const double x,
const double y )
896 double three_pixels = 4.0;
901 double w = pStencil->w();
902 double h = pStencil->h();
903 double w2 = pStencil->w() / 2.0;
904 double h2 = pStencil->h() / 2.0;
905 m.translate(pStencil->x(), pStencil->y());
907 m.rotate(pStencil->rotation());
908 m.translate(-w2, -h2);
911 KoPoint tl(0 * m.m11() + 0 * m.m21() + m.dx(), 0 * m.m12() + 0 * m.m22() + m.dy());
912 KoPoint t(w2 * m.m11() + 0 * m.m21() + m.dx(), w2 * m.m12() + 0 * m.m22() + m.dy());
913 KoPoint tr(w * m.m11() + 0 * m.m21() + m.dx(), w * m.m12() + 0 * m.m22() + m.dy());
914 KoPoint r(w * m.m11() + h2 * m.m21() + m.dx(), w * m.m12() + h2 * m.m22() + m.dy());
915 KoPoint br(w * m.m11() + h * m.m21() + m.dx(), w * m.m12() + h * m.m22() + m.dy());
916 KoPoint b(w2 * m.m11() + h * m.m21() + m.dx(), w2 * m.m12() + h * m.m22() + m.dy());
917 KoPoint bl(0 * m.m11() + h * m.m21() + m.dx(), 0 * m.m12() + h * m.m22() + m.dy());
918 KoPoint l(0 * m.m11() + h2 * m.m21() + m.dx(), 0 * m.m12() + h2 * m.m22() + m.dy());
920 available = pStencil->resizeHandlePositions();
928 if( available & krhpNW &&
929 RESIZE_BOX_TEST( x, y, tl.x(), tl.y() ) )
933 if( available & krhpN &&
934 RESIZE_BOX_TEST( x, y, t.x(), t.y() ) )
938 if( available & krhpNE &&
939 RESIZE_BOX_TEST( x, y, tr.x(), tr.y() ) )
943 if( available & krhpE &&
944 RESIZE_BOX_TEST( x, y, r.x(), r.y() ) )
948 if( available & krhpSE &&
949 RESIZE_BOX_TEST( x, y, br.x(), br.y() ) )
953 if( available & krhpS &&
954 RESIZE_BOX_TEST( x, y, b.x(), b.y() ) )
958 if( available & krhpSW &&
959 RESIZE_BOX_TEST( x, y, bl.x(), bl.y() ) )
963 if( available & krhpW &&
964 RESIZE_BOX_TEST( x, y, l.x(), l.y() ) )
972void SelectTool::mouseRelease(
const TQPoint &pos)
974 m_releasePoint = pos;
979 endRubberBanding(pos);
982 case stmCustomDragging:
983 endCustomDragging(pos);
997 view()->canvasWidget()->guideLines().repaintAfterSnapping();
998 view()->doc()->updateView(view()->activePage());
1001void SelectTool::endRubberBanding(
const TQPoint &pos)
1003 KivioCanvas* canvas = view()->canvasWidget();
1005 canvas->endRectDraw();
1007 KoPoint p = canvas->mapFromScreen(pos);
1010 if( m_origPoint.x() != p.x() && m_origPoint.y() != p.y() )
1012 select(canvas->rect());
1015 view()->updateToolBars();
1018void SelectTool::endDragging(
const TQPoint&)
1020 KivioCanvas* canvas = view()->canvasWidget();
1021 canvas->activePage()->setPaintSelected(
true);
1022 KMacroCommand *macro=
new KMacroCommand( i18n(
"Move Stencil"));
1023 KivioStencil *pStencil = canvas->activePage()->selectedStencils()->first();
1024 KivioSelectDragData *pData = m_lstOldGeometry.first();
1027 while( pStencil && pData )
1029 if((pData->rect.x() != pStencil->rect().x()) || (pData->rect.y() != pStencil->rect().y())) {
1030 KivioMoveStencilCommand * cmd =
new KivioMoveStencilCommand( i18n(
"Move Stencil"),
1031 pStencil, pData->rect, pStencil->rect(), canvas->activePage());
1032 macro->addCommand( cmd);
1034 if(pStencil->type() == kstConnector) {
1035 pStencil->searchForConnections(view()->activePage(), view()->zoomHandler()->unzoomItY(4));
1041 pData = m_lstOldGeometry.next();
1042 pStencil = canvas->activePage()->selectedStencils()->next();
1046 canvas->doc()->addCommand( macro );
1051 canvas->drawSelectedStencilsXOR();
1052 canvas->endUnclippedSpawnerPainter();
1054 m_lstOldGeometry.clear();
1057void SelectTool::endCustomDragging(
const TQPoint&)
1059 KivioCanvas* canvas = view()->canvasWidget();
1060 m_pCustomDraggingStencil->setHidden(
false);
1061 KivioCustomDragCommand* cmd =
new KivioCustomDragCommand(i18n(
"Move Connector Point"), view()->activePage(),
1062 m_pCustomDraggingStencil, m_customDragID, m_customDragOrigPoint,
1063 m_pCustomDraggingStencil->customIDPoint(m_customDragID));
1064 view()->doc()->addCommand(cmd);
1066 KivioStencil *pStencil = canvas->activePage()->selectedStencils()->first();
1070 if(pStencil->type() == kstConnector) {
1071 pStencil->searchForConnections(view()->activePage(), view()->zoomHandler()->unzoomItY(4));
1074 pStencil = canvas->activePage()->selectedStencils()->next();
1077 canvas->endUnclippedSpawnerPainter();
1079 canvas->setShowConnectorTargets(
false);
1083void SelectTool::endResizing(
const TQPoint&)
1085 KivioCanvas* canvas = view()->canvasWidget();
1086 m_pResizingStencil->setHidden(
false);
1087 KivioResizeStencilCommand * cmd =
new KivioResizeStencilCommand( i18n(
"Resize Stencil"),
1088 m_pResizingStencil, m_lstOldGeometry.first()->rect, m_pResizingStencil->rect(), view()->activePage());
1089 canvas->doc()->addCommand( cmd );
1091 canvas->drawStencilXOR( m_pResizingStencil );
1093 if(m_pResizingStencil->type() == kstConnector) {
1094 m_pResizingStencil->searchForConnections(view()->activePage(), view()->zoomHandler()->unzoomItY(4));
1098 canvas->endUnclippedSpawnerPainter();
1101 m_pResizingStencil = NULL;
1108void SelectTool::showPopupMenu(
const TQPoint &pos )
1110 TDEPopupMenu* menu = 0;
1112 if(view()->activePage()->selectedStencils()->count() < 1) {
1113 menu =
static_cast<TDEPopupMenu*
>(view()->factory()->container(
"PagePopup", view()));
1115 menu =
static_cast<TDEPopupMenu*
>(view()->factory()->container(
"StencilPopup", view()));
1116 m_arrowHeadAction->setEnabled(view()->activePage()->checkForStencilTypeInSelection(kstConnector));
1118 if(view()->activePage()->checkForTextBoxesInSelection()) {
1119 m_textEditAction->setEnabled(
true);
1121 m_textEditAction->setEnabled(
false);
1126 m_lastPoint = view()->canvasWidget()->mapFromScreen(pos);
1129 kdDebug(43000) <<
"What no popup! *ARGH*!" << endl;
1141void SelectTool::leftDoubleClick(
const TQPoint& pos)
1143 if( view()->activePage()->selectedStencils()->count() <= 0 )
1146 KoPoint pagePoint = view()->canvasWidget()->mapFromScreen(pos);
1148 double threshold = view()->zoomHandler()->unzoomItY(4);
1150 KivioPage *page = view()->activePage();
1151 KivioStencil* stencil = page->checkForStencil( &pagePoint, &colType, threshold,
false);
1155 Kivio::Plugin *p = view()->pluginManager()->findPlugin(
"Text Mouse Tool");
1159 kdDebug(43000) <<
"SelectTool::leftDoubleClick() - unable to locate Text Tool" << endl;
1163 static_cast<Kivio::MouseTool*
>(p)->
applyToolAction(stencil, pagePoint);
1167void SelectTool::editText(TQPtrList<KivioStencil>* stencils)
1170 Kivio::Plugin *p = view()->pluginManager()->findPlugin(
"Text Mouse Tool");
1173 kdDebug(43000) <<
"SelectTool::leftDoubleClick() - unable to locate Text Tool" << endl;
1181void SelectTool::showProperties()
1184 if(view()->activePage()->selectedStencils()->count() == 0) {
1185 view()->paperLayoutDlg();
1189void SelectTool::editStencilText()
1191 editText(view()->activePage()->selectedStencils());
1194void SelectTool::keyPress(TQKeyEvent* e)
1196 KivioCanvas* canvas = view()->canvasWidget();
1198 canvas->setEnabled(
false);
1201 canvas->beginUnclippedSpawnerPainter();
1204 KivioSelectDragData *pData;
1205 m_lstOldGeometry.clear();
1206 KivioStencil* pStencil = canvas->activePage()->selectedStencils()->first();
1210 pData =
new KivioSelectDragData;
1211 pData->rect = pStencil->rect();
1212 m_lstOldGeometry.append(pData);
1215 pStencil = canvas->activePage()->selectedStencils()->next();
1218 m_selectedRect = view()->activePage()->getRectForAllSelectedStencils();
1220 m_mode = stmDragging;
1221 canvas->setEnabled(
true);
1222 m_origPoint = m_selectedRect.topLeft();
1223 KivioGridData gd = view()->doc()->grid();
1224 bool ignoreGridGuides = e->state() & ShiftButton;
1225 double distX, distY;
1227 if(ignoreGridGuides || !view()->doc()->grid().isSnap) {
1228 distX = view()->zoomHandler()->unzoomItX(1);
1229 distY = view()->zoomHandler()->unzoomItY(1);
1231 distX = gd.freq.width();
1232 distY = gd.freq.height();
1237 continueDragging(canvas->mapToScreen(KoPoint(m_selectedRect.x() - distX,
1238 m_selectedRect.y())), ignoreGridGuides);
1241 continueDragging(canvas->mapToScreen(KoPoint(m_selectedRect.x(),
1242 m_selectedRect.y() - distY)), ignoreGridGuides);
1245 continueDragging(canvas->mapToScreen(KoPoint(m_selectedRect.x() + distX,
1246 m_selectedRect.y())), ignoreGridGuides);
1249 continueDragging(canvas->mapToScreen(KoPoint(m_selectedRect.x(),
1250 m_selectedRect.y() + distY)), ignoreGridGuides);
1256 endDragging(TQPoint());
1257 canvas->guideLines().repaintAfterSnapping();
1261#include "tool_select.moc"