Example #1
0
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
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
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;
}