本文整理汇总了C++中BRect::Size方法的典型用法代码示例。如果您正苦于以下问题:C++ BRect::Size方法的具体用法?C++ BRect::Size怎么用?C++ BRect::Size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BRect
的用法示例。
在下文中一共展示了BRect::Size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AlignInFrame
// AlignInFrame
void
BLayoutUtils::AlignInFrame(BView* view, BRect frame)
{
BSize maxSize = view->MaxSize();
BAlignment alignment = view->LayoutAlignment();
if (view->HasHeightForWidth()) {
// The view has height for width, so we do the horizontal alignment
// ourselves and restrict the height max constraint respectively.
if (maxSize.width < frame.Width()
&& alignment.horizontal != B_ALIGN_USE_FULL_WIDTH) {
frame.OffsetBy(floor((frame.Width() - maxSize.width)
* alignment.RelativeHorizontal()), 0);
frame.right = frame.left + maxSize.width;
}
alignment.horizontal = B_ALIGN_USE_FULL_WIDTH;
float minHeight;
float maxHeight;
float preferredHeight;
view->GetHeightForWidth(frame.Width(), &minHeight, &maxHeight,
&preferredHeight);
frame.bottom = frame.top + max_c(frame.Height(), minHeight);
maxSize.height = minHeight;
}
frame = AlignInFrame(frame, maxSize, alignment);
view->MoveTo(frame.LeftTop());
view->ResizeTo(frame.Size());
}
示例2: Bounds
void
PictureView::Draw(BRect updateRect)
{
BRect rect = Bounds();
// Draw the outer frame
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
if (IsFocus() && Window() && Window()->IsActive())
SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
else
SetHighColor(tint_color(base, B_DARKEN_3_TINT));
StrokeRect(rect);
if (fFocusChanging) {
// focus frame is already redraw, stop here
return;
}
BBitmap* picture = fPicture ? fPicture : fDefaultPicture;
if (picture != NULL) {
// scale to fit and center picture in frame
BRect frame = rect.InsetByCopy(kPictureMargin, kPictureMargin);
BRect srcRect = picture->Bounds();
BSize size = frame.Size();
if (srcRect.Width() > srcRect.Height())
size.height = srcRect.Height() * size.width / srcRect.Width();
else
size.width = srcRect.Width() * size.height / srcRect.Height();
fPictureRect = BLayoutUtils::AlignInFrame(frame, size,
BAlignment(B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER));
SetDrawingMode(B_OP_ALPHA);
if (picture == fDefaultPicture) {
SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
SetHighColor(0, 0, 0, 24);
}
DrawBitmapAsync(picture, srcRect, fPictureRect,
B_FILTER_BITMAP_BILINEAR);
SetDrawingMode(B_OP_OVER);
}
}
示例3: entry
//.........这里部分代码省略.........
break;
}
case MSG_ADD_SLOT: {
LaunchButton* button;
if (message->FindPointer("be:source", (void**)&button) >= B_OK) {
fPadView->AddButton(new LaunchButton("launch button",
NULL, new BMessage(MSG_LAUNCH)), button);
}
break;
}
case MSG_CLEAR_SLOT: {
LaunchButton* button;
if (message->FindPointer("be:source", (void**)&button) >= B_OK)
button->SetTo((entry_ref*)NULL);
break;
}
case MSG_REMOVE_SLOT: {
LaunchButton* button;
if (message->FindPointer("be:source", (void**)&button) >= B_OK) {
if (fPadView->RemoveButton(button))
delete button;
}
break;
}
case MSG_SET_DESCRIPTION: {
LaunchButton* button;
if (message->FindPointer("be:source", (void**)&button) >= B_OK) {
const char* name;
if (message->FindString("name", &name) >= B_OK) {
// message comes from a previous name panel
button->SetDescription(name);
BRect namePanelFrame;
if (message->FindRect("frame", &namePanelFrame) == B_OK) {
((App*)be_app)->SetNamePanelSize(
namePanelFrame.Size());
}
} else {
// message comes from pad view
entry_ref* ref = button->Ref();
if (ref) {
BString helper(B_TRANSLATE("Description for '%3'"));
helper.ReplaceFirst("%3", ref->name);
// Place the name panel besides the pad, but give it
// the user configured size.
BPoint origin = B_ORIGIN;
BSize size = ((App*)be_app)->NamePanelSize();
NamePanel* panel = new NamePanel(helper.String(),
button->Description(), this, this,
new BMessage(*message), size);
panel->Layout(true);
size = panel->Frame().Size();
BScreen screen(this);
BPoint mousePos;
uint32 buttons;
fPadView->GetMouse(&mousePos, &buttons, false);
fPadView->ConvertToScreen(&mousePos);
if (fPadView->Orientation() == B_HORIZONTAL) {
// Place above or below the pad
origin.x = mousePos.x - size.width / 2;
if (screen.Frame().bottom - Frame().bottom
> size.height + 20) {
origin.y = Frame().bottom + 10;
} else {
origin.y = Frame().top - 10 - size.height;
}
} else {
示例4: windRect
void
TFilePanel::Init(const BMessage*)
{
BRect windRect(Bounds());
fBackView = new BView(Bounds(), "View", B_FOLLOW_ALL, 0);
fBackView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
AddChild(fBackView);
// add poseview menu bar
fMenuBar = new BMenuBar(BRect(0, 0, windRect.Width(), 1), "MenuBar");
fMenuBar->SetBorder(B_BORDER_FRAME);
fBackView->AddChild(fMenuBar);
// add directory menu and menufield
fDirMenu = new BDirMenu(0, this, kSwitchDirectory, "refs");
font_height ht;
be_plain_font->GetHeight(&ht);
float f_height = ht.ascent + ht.descent + ht.leading;
BRect rect;
rect.top = fMenuBar->Bounds().Height() + 8;
rect.left = windRect.left + 8;
rect.right = rect.left + 300;
rect.bottom = rect.top + (f_height > 22 ? f_height : 22);
fDirMenuField = new BMenuField(rect, "DirMenuField", "", fDirMenu);
fDirMenuField->MenuBar()->SetFont(be_plain_font);
fDirMenuField->SetDivider(0);
fDirMenuField->MenuBar()->SetMaxContentWidth(rect.Width() - 26.0f);
// Make room for the icon
fDirMenuField->MenuBar()->RemoveItem((int32)0);
fDirMenu->SetMenuBar(fDirMenuField->MenuBar());
// the above is a weird call from BDirMenu
// ToDo: clean up
BEntry entry(TargetModel()->EntryRef());
if (entry.InitCheck() == B_OK)
fDirMenu->Populate(&entry, 0, true, true, false, true);
else
fDirMenu->Populate(0, 0, true, true, false, true);
fBackView->AddChild(fDirMenuField);
// add file name text view
if (fIsSavePanel) {
BRect rect(windRect);
rect.top = rect.bottom - 35;
rect.left = 8;
rect.right = rect.left + 170;
rect.bottom = rect.top + 13;
fTextControl = new BTextControl(rect, "text view",
B_TRANSLATE("save text"), "", NULL,
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
DisallowMetaKeys(fTextControl->TextView());
DisallowFilenameKeys(fTextControl->TextView());
fBackView->AddChild(fTextControl);
fTextControl->SetDivider(0.0f);
fTextControl->TextView()->SetMaxBytes(B_FILE_NAME_LENGTH - 1);
fButtonText.SetTo(B_TRANSLATE("Save"));
} else
fButtonText.SetTo(B_TRANSLATE("Open"));
// Add PoseView
fBorderedView->SetName("PoseView");
fBorderedView->SetResizingMode(B_FOLLOW_ALL);
fBorderedView->EnableBorderHighlight(true);
rect = windRect;
rect.OffsetTo(10, fDirMenuField->Frame().bottom + 10);
rect.bottom = windRect.bottom - 60;
rect.right -= B_V_SCROLL_BAR_WIDTH + 20;
fBorderedView->MoveTo(rect.LeftTop());
fBorderedView->ResizeTo(rect.Width(), rect.Height());
PoseView()->AddScrollBars();
PoseView()->SetDragEnabled(false);
PoseView()->SetDropEnabled(false);
PoseView()->SetSelectionHandler(this);
PoseView()->SetSelectionChangedHook(true);
PoseView()->DisableSaveLocation();
// horizontal
rect = fBorderedView->Frame();
rect.top = rect.bottom;
rect.bottom = rect.top + (float)B_H_SCROLL_BAR_HEIGHT;
PoseView()->HScrollBar()->MoveTo(rect.LeftTop());
PoseView()->HScrollBar()->ResizeTo(rect.Size());
PoseView()->HScrollBar()->SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM);
fBackView->AddChild(PoseView()->HScrollBar());
// vertical
rect = fBorderedView->Frame();
rect.left = rect.right;
rect.right = rect.left + (float)B_V_SCROLL_BAR_WIDTH;
PoseView()->VScrollBar()->MoveTo(rect.LeftTop());
PoseView()->VScrollBar()->ResizeTo(rect.Size());
//.........这里部分代码省略.........