本文整理汇总了C++中BRect::OffsetToSelf方法的典型用法代码示例。如果您正苦于以下问题:C++ BRect::OffsetToSelf方法的具体用法?C++ BRect::OffsetToSelf怎么用?C++ BRect::OffsetToSelf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BRect
的用法示例。
在下文中一共展示了BRect::OffsetToSelf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ClippingView
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: leftTop
/*! 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);
}