// virtual void kpToolColorPicker::draw (const QPoint &thisPoint, const QPoint &, const QRect &) { const kpColor color = colorAtPixel (thisPoint); if (color.isValid ()) { mainWindow ()->colorToolBar ()->setColor (m_mouseButton, color); setUserShapePoints (thisPoint); } else { mainWindow ()->colorToolBar ()->setColor (m_mouseButton, m_oldColor); setUserShapePoints (); } }
void kpTool::endInternal () { if (m_began) { // before we can stop using the tool, we must stop the current drawing operation (if any) if (hasBegunShape ()) endShapeInternal (m_currentPoint, QRect (m_startPoint, m_currentPoint).normalize ()); // call user virtual func end (); // clear leftover statusbar messages setUserMessage (); setUserShapePoints (currentPoint ()); // we've stopped using the tool... m_began = false; // and so we can't be drawing with it m_beganDraw = false; if (m_mainWindow) { kpToolToolBar *tb = m_mainWindow->toolToolBar (); if (tb) { tb->hideAllToolWidgets (); } } } }
// virtual void kpTool::hover (const QPoint &point) { #if DEBUG_KP_TOOL kdDebug () << "kpTool::hover" << point << " base implementation" << endl; #endif setUserShapePoints (point); }
// private slot void kpAbstractSelectionTool::slotRMBMoveUpdateGUI () { // (just in case not called from single shot) d->RMBMoveUpdateGUITimer->stop (); /*virtual*/setSelectionBorderForBeginDrawMove (); kpAbstractSelection * const sel = document ()->selection (); if (sel) setUserShapePoints (sel->topLeft ()); }
void kpTool::beginInternal () { #if DEBUG_KP_TOOL kdDebug () << "kpTool::beginInternal()" << endl; #endif if (!m_began) { // clear leftover statusbar messages setUserMessage (); m_currentPoint = currentPoint (); m_currentViewPoint = currentPoint (false/*view point*/); setUserShapePoints (m_currentPoint); // TODO: Audit all the code in this file - states like "m_began" & // "m_beganDraw" should be set before calling user func. // Also, m_currentPoint should be more frequently initialised. // call user virtual func begin (); // we've starting using the tool... m_began = true; // but we haven't started drawing with it m_beganDraw = false; uint keyState = KApplication::keyboardModifiers (); m_shiftPressed = (keyState & KApplication::ShiftModifier); m_controlPressed = (keyState & KApplication::ControlModifier); // TODO: Can't do much about ALT - unless it's always KApplication::Modifier1? // Ditto for everywhere else where I set SHIFT & CTRL but not alt. m_altPressed = false; } }
// private void kpAbstractSelectionTool::drawMove (const QPoint &thisPoint, const QRect &/*normalizedRect*/) { #if DEBUG_KP_TOOL_SELECTION && 1 qCDebug(kpLogTools) << "\tmoving selection"; #endif kpAbstractSelection *sel = document ()->selection (); QRect targetSelRect (thisPoint.x () - d->startMoveDragFromSelectionTopLeft.x (), thisPoint.y () - d->startMoveDragFromSelectionTopLeft.y (), sel->width (), sel->height ()); #if DEBUG_KP_TOOL_SELECTION && 1 qCDebug(kpLogTools) << "\t\tstartPoint=" << startPoint () << " thisPoint=" << thisPoint << " startDragFromSel=" << d->startMoveDragFromSelectionTopLeft << " targetSelRect=" << targetSelRect << endl; #endif // Try to make sure selection still intersects document so that it's // reachable. if (targetSelRect.right () < 0) targetSelRect.translate (-targetSelRect.right (), 0); else if (targetSelRect.left () >= document ()->width ()) targetSelRect.translate (document ()->width () - targetSelRect.left () - 1, 0); if (targetSelRect.bottom () < 0) targetSelRect.translate (0, -targetSelRect.bottom ()); else if (targetSelRect.top () >= document ()->height ()) targetSelRect.translate (0, document ()->height () - targetSelRect.top () - 1); #if DEBUG_KP_TOOL_SELECTION && 1 qCDebug(kpLogTools) << "\t\t\tafter ensure sel rect clickable=" << targetSelRect; #endif if (!d->dragAccepted && targetSelRect.topLeft () + d->startMoveDragFromSelectionTopLeft == startPoint ()) { #if DEBUG_KP_TOOL_SELECTION && 1 qCDebug(kpLogTools) << "\t\t\t\tnop"; #endif if (!d->RMBMoveUpdateGUITimer->isActive ()) { // (slotRMBMoveUpdateGUI() calls similar line) setUserShapePoints (sel->topLeft ()); } // Prevent both NOP drag-moves return; } if (d->RMBMoveUpdateGUITimer->isActive ()) { d->RMBMoveUpdateGUITimer->stop (); slotRMBMoveUpdateGUI (); } giveContentIfNeeded (); if (!d->currentMoveCommand) { d->currentMoveCommand = new kpToolSelectionMoveCommand ( QString()/*uninteresting child of macro cmd*/, environ ()->commandEnvironment ()); d->currentMoveCommandIsSmear = false; } //viewManager ()->setQueueUpdates (); //viewManager ()->setFastUpdates (); if (shiftPressed ()) d->currentMoveCommandIsSmear = true; if (!d->dragAccepted && (controlPressed () || shiftPressed ())) d->currentMoveCommand->copyOntoDocument (); d->currentMoveCommand->moveTo (targetSelRect.topLeft ()); if (shiftPressed ()) d->currentMoveCommand->copyOntoDocument (); //viewManager ()->restoreFastUpdates (); //viewManager ()->restoreQueueUpdates (); // REFACTOR: yuck, yuck kpAbstractSelection *orgSel = d->currentMoveCommand->originalSelectionClone (); QPoint start = orgSel->topLeft (); delete orgSel; QPoint end = targetSelRect.topLeft (); setUserShapePoints (start, end, false/*don't set size*/); setUserShapeSize (end.x () - start.x (), end.y () - start.y ()); d->dragAccepted = true; }