void TestWidget::HandleMouseDrag ( const JPoint& pt, const JXButtonStates& buttonStates, const JXKeyModifiers& modifiers ) { const JBoolean scrolled = ScrollForDrag(pt); JPainter* p = NULL; if (buttonStates.left() && pt != itsPrevPt && GetDragPainter(&p)) // no painter for multiple click { if (!scrolled) { p->Rect(JRect(itsStartPt, itsPrevPt)); } p->Rect(JRect(itsStartPt, pt)); } if (buttonStates.middle() && pt != itsPrevPt) { itsAnimButton->Place(pt.x, pt.y); } else if (buttonStates.right() && pt != itsPrevPt) { JRect r = itsAnimButton->GetFrame(); if (pt.x > r.left && pt.y > r.top) { itsAnimButton->SetSize(pt.x-r.left, pt.y-r.top); } } itsPrevPt = pt; }
void UndoWidget::HandleMouseDrag ( const JPoint& pt, const JXButtonStates& buttonStates, const JXKeyModifiers& modifiers ) { // Check to see if the window was scrolled const JBoolean scrolled = ScrollForDrag(pt); // Get the drag painter that we created in mouse down JPainter* p = NULL; const JBoolean ok = GetDragPainter(&p); assert( ok ); // Make sure that the left button is pressed, // that we have moved, // and that a drag painter exists if (buttonStates.left() && pt != itsPrevPt && p != NULL) // p is NULL for multiple click { // Draw line depending on whether or not we scrolled if (!scrolled) { p->Line(itsStartPt, itsPrevPt); } p->Line(itsStartPt, pt); } // Remember the current point itsPrevPt = pt; }
void JXCheckbox::HandleMouseDrag ( const JPoint& pt, const JXButtonStates& buttonStates, const JXKeyModifiers& modifiers ) { if (buttonStates.left()) { const JRect frame = JXContainer::GlobalToLocal(GetFrameGlobal()); const JBoolean inside = frame.Contains(pt); if (inside && !itsIsPushedFlag) { itsIsPushedFlag = kJTrue; Redraw(); } else if (!inside && itsIsPushedFlag) { itsIsPushedFlag = kJFalse; Redraw(); } } }