예제 #1
0
ClippingWindow::ClippingWindow(BRect frame)
	:	BWindow(frame, "Window", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE)
{
	fView = new ClippingView(frame.OffsetToSelf(0, 0));
	AddChild(fView);
	fView->MakeFocus();
}
예제 #2
0
/*!	Offsets a rectangle's location so that it lies fully in a given rectangular
	frame.

	If the rectangle is too wide/high to fully fit in the frame, its left/top
	edge is offset to 0. The rect's size always remains unchanged.

	\param rect The rectangle to be moved.
	\param frameSize The size of the frame the rect shall be moved into. The
		frame's left-top is (0, 0).
	\return The modified rect.
*/
/*static*/ BRect
BLayoutUtils::MoveIntoFrame(BRect rect, BSize frameSize)
{
	BPoint leftTop(rect.LeftTop());

	// enforce horizontal limits; favor left edge
	if (rect.right > frameSize.width)
		leftTop.x -= rect.right - frameSize.width;
	if (leftTop.x < 0)
		leftTop.x = 0;

	// enforce vertical limits; favor top edge
	if (rect.bottom > frameSize.height)
		leftTop.y -= rect.bottom - frameSize.height;
	if (leftTop.y < 0)
		leftTop.y = 0;

	return rect.OffsetToSelf(leftTop);
}