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 JXRowHeaderWidget::HandleMouseDrag ( const JPoint& origPt, const JXButtonStates& buttonStates, const JXKeyModifiers& modifiers ) { if (itsDragType != kInvalidDrag) { JPoint pt = origPt; // keep col width larger than minimum if (pt.y < itsDragCellRect.top + itsMinRowHeight) { pt.y = itsDragCellRect.top + itsMinRowHeight; } // check if we have moved if (pt.y != itsPrevPt.y) { JPainter* p = NULL; const JBoolean ok = GetDragPainter(&p); assert( ok ); const JRect enclApG = (GetEnclosure())->GetApertureGlobal(); JRect enclAp = JXContainer::GlobalToLocal(enclApG); // scroll, if necessary const JPoint ptG = JXContainer::LocalToGlobal(pt); const JPoint ptT = JPinInRect(itsTable->JXContainer::GlobalToLocal(ptG), itsTable->GetBounds()); const JRect tableAp = itsTable->GetAperture(); const JCoordinate x = tableAp.xcenter(); const JRect tableRect(ptT.y-1, x-1, ptT.y+1, x+1); if (itsTable->ScrollToRect(tableRect)) { (GetWindow())->Update(); enclAp = JXContainer::GlobalToLocal(enclApG); // local coords changed } else { // erase the old line p->Line(enclAp.left, itsPrevPt.y, enclAp.right, itsPrevPt.y); } // draw the new line p->Line(enclAp.left, pt.y, enclAp.right, pt.y); // ready for next call itsPrevPt = pt; } } }
void UndoWidget::HandleMouseUp ( const JPoint& pt, const JXMouseButton button, const JXButtonStates& buttonStates, const JXKeyModifiers& modifiers ) { JPainter* p = NULL; // Make sure that the left button is pressed, // and that a drag painter exists if (button == kJXLeftButton && GetDragPainter(&p)) { // Erase the last line that was drawn p->Line(itsStartPt, itsPrevPt); // Delete the drag painter DeleteDragPainter(); // Add this set of points to our JArray itsPoints->AppendElement(itsStartPt); itsPoints->AppendElement(itsPrevPt); // Create the undo object to undo the addition of this line UndoLine* undo = new UndoLine(this); assert(undo != NULL); NewUndo(undo); // Tell the widget to redraw itself Refresh(); } }
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 TestWidget::HandleMouseUp ( const JPoint& pt, const JXMouseButton button, const JXButtonStates& buttonStates, const JXKeyModifiers& modifiers ) { JPainter* p = NULL; if (button == kJXLeftButton && GetDragPainter(&p)) // no painter for multiple click { p->Rect(JRect(itsStartPt, itsPrevPt)); DeleteDragPainter(); } }
void JXHorizPartition::HandleMouseDrag ( const JPoint& origPt, const JXButtonStates& buttonStates, const JXKeyModifiers& modifiers ) { if (itsDragType != kInvalidDrag) { JPoint pt = origPt; // keep compartment width larger than minimum if (pt.x < itsMinDragX) { pt.x = itsMinDragX; } else if (pt.x > itsMaxDragX) { pt.x = itsMaxDragX; } // check if we have moved if (pt.x != itsPrevPt.x) { JPainter* p = NULL; const JBoolean ok = GetDragPainter(&p); assert( ok ); JRect ap = GetAperture(); p->Line(itsPrevPt.x, ap.top, itsPrevPt.x, ap.bottom); p->Line(pt.x, ap.top, pt.x, ap.bottom); itsPrevPt = pt; } } }
void JXVertPartition::HandleMouseDrag ( const JPoint& origPt, const JXButtonStates& buttonStates, const JXKeyModifiers& modifiers ) { if (itsDragType != kInvalidDrag) { JPoint pt = origPt; // keep compartment width larger than minimum if (pt.y < itsMinDragY) { pt.y = itsMinDragY; } else if (pt.y > itsMaxDragY) { pt.y = itsMaxDragY; } // check if we have moved if (pt.y != itsPrevPt.y) { JPainter* p = NULL; const JBoolean ok = GetDragPainter(&p); assert( ok ); JRect ap = GetAperture(); p->Line(ap.left, itsPrevPt.y, ap.right, itsPrevPt.y); p->Line(ap.left, pt.y, ap.right, pt.y); itsPrevPt = pt; } } }
void JXRowHeaderWidget::HandleMouseUp ( const JPoint& pt, const JXMouseButton button, const JXButtonStates& buttonStates, const JXKeyModifiers& modifiers ) { if (itsDragType != kInvalidDrag) { // erase the line JPainter* p = NULL; const JBoolean ok = GetDragPainter(&p); assert( ok ); const JRect enclAp = JXContainer::GlobalToLocal((GetEnclosure())->GetApertureGlobal()); p->Line(enclAp.left, itsPrevPt.y, enclAp.right, itsPrevPt.y); DeleteDragPainter(); // set the row height(s) const JCoordinate rowHeight = itsPrevPt.y - itsDragCellRect.top; if (itsDragType == kDragOneRow) { itsTable->SetRowHeight(itsDragCell.y, rowHeight); } else { assert( itsDragType == kDragAllRows ); itsTable->SetDefaultRowHeight(rowHeight); itsTable->SetAllRowHeights(rowHeight); } } itsDragType = kInvalidDrag; }
void JXColHeaderWidget::HandleMouseUp ( const JPoint& pt, const JXMouseButton button, const JXButtonStates& buttonStates, const JXKeyModifiers& modifiers ) { if (itsDragType != kInvalidDrag) { // erase the line JPainter* p = NULL; const JBoolean ok = GetDragPainter(&p); assert( ok ); const JRect enclAp = JXContainer::GlobalToLocal((GetEnclosure())->GetApertureGlobal()); p->Line(itsPrevPt.x, enclAp.top, itsPrevPt.x, enclAp.bottom); DeleteDragPainter(); // set the column width(s) const JCoordinate colWidth = itsPrevPt.x - itsDragCellRect.left; if (itsDragType == kDragOneCol) { itsTable->SetColWidth(itsDragCell.x, colWidth); } else { assert( itsDragType == kDragAllCols ); itsTable->SetDefaultColWidth(colWidth); itsTable->SetAllColWidths(colWidth); } } itsDragType = kInvalidDrag; }
void JXHorizPartition::HandleMouseUp ( const JPoint& pt, const JXMouseButton button, const JXButtonStates& buttonStates, const JXKeyModifiers& modifiers ) { if (itsDragType != kInvalidDrag) { // erase the line JPainter* p = NULL; const JBoolean ok = GetDragPainter(&p); assert( ok ); JRect ap = GetAperture(); p->Line(itsPrevPt.x, ap.top, itsPrevPt.x, ap.bottom); DeleteDragPainter(); // set the compartment widths if (itsDragType == kDragAll) { AdjustCompartmentsAfterDragAll(itsPrevPt.x); } else { assert( itsDragType == kDragOne ); AdjustCompartmentsAfterDrag(itsPrevPt.x); } } itsDragType = kInvalidDrag; }