示例#1
0
void
JXWidget::SetBorderWidth
	(
	const JSize width
	)
{
	if (width != itsBorderWidth)
		{
		const JRect origApG = GetApertureGlobal();
		itsBorderWidth = width;
		const JRect newApG = GetApertureGlobal();

		ApertureMoved(newApG.left - origApG.left, newApG.top - origApG.top);
		ApertureResized(newApG.width()  - origApG.width(),
						newApG.height() - origApG.height());
		}
}
void
JXExprEditor::EIPBoundsChanged()
{
	const JRect newBounds = (GetRectList())->GetBoundsRect();
	const JRect apG       = GetApertureGlobal();
	const JCoordinate w   = JMax(newBounds.width(),  apG.width());
	const JCoordinate h   = JMax(newBounds.height(), apG.height());
	SetBounds(w,h);
}
示例#3
0
void
JXWidget::ShouldAllowUnboundedScrolling
	(
	const JBoolean allow
	)
{
	itsAllowUnboundedScrollingFlag = allow;
	if (!allow)
		{
		const JRect apG = GetApertureGlobal();
		const JRect bG  = GetBoundsGlobal();
		if (apG.top < bG.top || apG.left < bG.left)
			{
			ScrollTo(JMax(0L, apG.left - bG.left),
					 JMax(0L, apG.top - bG.top));
			}
		}
}
示例#4
0
JBoolean
JXWidget::ScrollToRect
	(
	const JRect& r
	)
{
	JRect rG = JXContainer::LocalToGlobal(r);
	if (!JIntersection(rG, itsBoundsG, &rG))
		{
		return kJFalse;
		}

	const JRect ap = GetApertureGlobal();

	JCoordinate dx=0;
	if (rG.left < ap.left)
		{
		dx = ap.left - rG.left;
		}
	else if (rG.right > ap.right)
		{
		dx = ap.right - rG.right;
		if (rG.left + dx < ap.left)
			{
			dx = ap.left - rG.left;
			}
		}

	JCoordinate dy=0;
	if (rG.top < ap.top)
		{
		dy = ap.top - rG.top;
		}
	else if (rG.bottom > ap.bottom)
		{
		dy = ap.bottom - rG.bottom;
		if (rG.top + dy < ap.top)
			{
			dy = ap.top - rG.top;
			}
		}

	return Scroll(dx,dy);
}
void
JXRowHeaderWidget::HandleMouseDown
	(
	const JPoint&			pt,
	const JXMouseButton		button,
	const JSize				clickCount,
	const JXButtonStates&	buttonStates,
	const JXKeyModifiers&	modifiers
	)
{
	itsDragType = kInvalidDrag;
	if (!itsAllowRowResizingFlag)
		{
		return;
		}

	const JBoolean inDragRegion = InDragRegion(pt, &itsDragCell);

	if (inDragRegion && button == kJXLeftButton)
		{
		itsDragCellRect = GetCellRect(itsDragCell);
		if (modifiers.meta())
			{
			itsDragType = kDragAllRows;
			}
		else
			{
			itsDragType = kDragOneRow;
			}

		JPainter* p = CreateDragOutsidePainter();
		JRect defClipRect = p->GetDefaultClipRect();
		JRect apG = GetApertureGlobal();
		defClipRect.top    = apG.top;
		defClipRect.bottom = apG.bottom;
		p->SetDefaultClipRect(defClipRect);

		const JRect enclAp = JXContainer::GlobalToLocal((GetEnclosure())->GetApertureGlobal());
		p->Line(enclAp.left, pt.y, enclAp.right, pt.y);
		itsPrevPt = pt;
		}
}
示例#6
0
JBoolean
JXWidget::KeepApertureInsideBounds
	(
	JCoordinate* dx,
	JCoordinate* dy
	)
	const
{
	*dx=0;
	*dy=0;

	const JRect ap = GetApertureGlobal();

	if (itsBoundsG.left > ap.left)
		{
		*dx = ap.left - itsBoundsG.left;
		}
	else if (itsBoundsG.right < ap.right)
		{
		*dx = ap.right - itsBoundsG.right;
		if (itsBoundsG.left + *dx > ap.left)
			{
			*dx = ap.left - itsBoundsG.left;
			}
		}

	if (itsBoundsG.top > ap.top)
		{
		*dy = ap.top - itsBoundsG.top;
		}
	else if (itsBoundsG.bottom < ap.bottom)
		{
		*dy = ap.bottom - itsBoundsG.bottom;
		if (itsBoundsG.top + *dy > ap.top)
			{
			*dy = ap.top - itsBoundsG.top;
			}
		}

	return JConvertToBoolean(*dx != 0 || *dy != 0);
}
示例#7
0
JXWidget::JXWidget
	(
	JXContainer*		enclosure,
	const HSizingOption	hSizing,
	const VSizingOption	vSizing,
	const JCoordinate	x,
	const JCoordinate	y,
	const JCoordinate	w,
	const JCoordinate	h
	)
	:
	JXContainer(enclosure->GetWindow(), enclosure)
{
	assert( enclosure != NULL );
	assert( w > 0 && h > 0 );

	itsHSizing     = hSizing;
	itsVSizing     = vSizing;
	itsBorderWidth = 0;
	itsBackColor   = (GetColormap())->GetDefaultBackColor();
	itsFocusColor  = (GetColormap())->GetDefaultFocusColor();
	itsDragPainter = NULL;

	itsAllowUnboundedScrollingFlag = kJFalse;

	itsWantInputFlag  = kJFalse;
	itsWantTabFlag    = kJFalse;
	itsWantModTabFlag = kJFalse;

	const JPoint pt = enclosure->LocalToGlobal(x,y);
	itsFrameG       = JRect(pt.y, pt.x, pt.y+h, pt.x+w);

	itsApertureBoundedFlag = kJTrue;
	itsBoundsG             = GetApertureGlobal();

	Refresh();
}
示例#8
0
JBoolean
JXWidget::Scroll
	(
	const JCoordinate userdx,
	const JCoordinate userdy
	)
{
	assert( !itsApertureBoundedFlag );

	if (userdx != 0 || userdy != 0)
		{
		const JRect apG = GetApertureGlobal();

		JCoordinate dx = userdx;
		if (itsBoundsG.width() <= apG.width())
			{
			dx = 0;
			}
		else if (dx > 0 && itsBoundsG.left + dx > apG.left)
			{
			dx = apG.left - itsBoundsG.left;
			}
		else if (dx < 0 && itsBoundsG.right + dx < apG.right)
			{
			dx = apG.right - itsBoundsG.right;
			}

		JCoordinate dy = userdy;
		if (itsBoundsG.height() <= apG.height())
			{
			dy = 0;
			}
		else if (dy > 0 && itsBoundsG.top + dy > apG.top)
			{
			dy = apG.top - itsBoundsG.top;
			}
		else if (dy < 0 && itsBoundsG.bottom + dy < apG.bottom)
			{
			dy = apG.bottom - itsBoundsG.bottom;
			}

		if (dx != 0 || dy != 0)
			{
//			const JRect origAp = GetAperture();

			itsBoundsG.Shift(dx,dy);
			NotifyBoundsMoved(dx,dy);

//			const JRect newAp = GetAperture();
//			JRect dest;
//			if (JIntersection(origAp, newAp, &dest))
//				{
//				dest      = JXContainer::LocalToGlobal(dest);
//				JRect src = dest;
//				src.Shift(-dx, -dy);
//				(GetWindow())->UpdateForScroll(JXContainer::LocalToGlobal(newAp), src, dest);
//				}
//			else
//				{
				Refresh();
//				}

			return kJTrue;
			}
		}

	return kJFalse;
}
示例#9
0
JBoolean
JXDockWidget::Dock
	(
	JXWindow*		w,
	const JBoolean	reportError
	)
{
	if (itsChildPartition != NULL)
		{
		return kJFalse;
		}

	const JRect geom = GetApertureGlobal();
	JPoint minSize;
	if (w->Dock(this, (GetWindow())->GetXWindow(), geom, &minSize))
		{
		if (itsWindowList == NULL)
			{
			itsWindowList = new JPtrArray<JXWindow>(JPtrArrayT::kForgetAll);
			assert( itsWindowList != NULL );
			}

		const JSize count = itsWindowList->GetElementCount();
		assert( count == itsTabGroup->GetTabCount() );

		const JCharacter* title =
			JXFileDocument::SkipNeedsSavePrefix(w->GetTitle());

		JIndex index = count+1;
		for (JIndex i=1; i<=count; i++)
			{
			const JCharacter* t =
				JXFileDocument::SkipNeedsSavePrefix((itsWindowList->NthElement(i))->GetTitle());
			if (JStringCompare(title, t, kJFalse) < 0)
				{
				index = i;
				break;
				}
			}

		itsWindowList->InsertAtIndex(index, w);
		ListenTo(w);
		UpdateMinSize();

		itsTabGroup->InsertTab(index, w->GetTitle());

		// Can't call ShowTab() because window might be partially constructed,
		// so Activate() could blow up.

		JXSelectTabTask* task = new JXSelectTabTask(itsTabGroup, index);
		assert( task != NULL );
		(JXGetApplication())->InstallUrgentTask(task);

		return kJTrue;
		}
	else
		{
		if (reportError)
			{
			(JGetUserNotification())->ReportError(JGetString(kWindowWillNotFitID));
			}
		return kJFalse;
		}
}