本文整理汇总了C++中BSize类的典型用法代码示例。如果您正苦于以下问题:C++ BSize类的具体用法?C++ BSize怎么用?C++ BSize使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BSize类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OperatorType
/**
* Sets Preferred size of the area's content.
* May be different from the preferred size of the area.
* Manual changes of PreferredContentSize are ignored unless
* autoPreferredContentSize is set to false.
*/
void
Area::SetPreferredContentSize(BSize preferred)
{
if (fChildArea == NULL) {
fPreferredContentSize = preferred;
if (fPreferredContentWidth == NULL) {
fPreferredContentWidth = fLS->AddConstraint(
-1.0, fLeft, 1.0, fRight, OperatorType(EQ),
fPreferredContentSize.Width(), fShrinkPenalties.Width(),
fGrowPenalties.Width());
fConstraints->AddItem(fPreferredContentWidth);
fPreferredContentHeight = fLS->AddConstraint(
-1.0, fTop, 1.0, fBottom, OperatorType(EQ),
fPreferredContentSize.Height(), fShrinkPenalties.Height(),
fGrowPenalties.Height());
fConstraints->AddItem(fPreferredContentHeight);
} else {
fPreferredContentWidth->SetRightSide(preferred.Width());
fPreferredContentHeight->SetRightSide(preferred.Height());
}
} else
fChildArea->SetPreferredContentSize(preferred);
fLS->InvalidateLayout();
}
示例2:
// SetExplicitMaxSize
void
BSpaceLayoutItem::SetExplicitMaxSize(BSize size)
{
if (size.IsWidthSet())
fMaxSize.width = size.width;
if (size.IsHeightSet())
fMaxSize.height = size.height;
InvalidateLayout();
}
示例3:
// ComposeSize
BSize
BLayoutUtils::ComposeSize(BSize size, BSize layoutSize)
{
if (!size.IsWidthSet())
size.width = layoutSize.width;
if (!size.IsHeightSet())
size.height = layoutSize.height;
return size;
}
示例4: SetShrinkPenalties
void Area::SetShrinkPenalties(BSize shrink) {
if (fChildArea == NULL) {
fShrinkPenalties = shrink;
if (fPreferredContentWidth != NULL) {
fPreferredContentWidth->SetPenaltyNeg(shrink.Width());
fPreferredContentHeight->SetPenaltyNeg(shrink.Height());
}
} else
fChildArea->SetShrinkPenalties(shrink);
fLS->InvalidateLayout();
}
示例5: BList
/**
* Initialize variables.
*/
void
Area::Init(BALMLayout* ls, XTab* left, YTab* top, XTab* right, YTab* bottom,
BView* content, BSize minContentSize)
{
fConstraints = new BList(2);
fMaxContentSize = kMaxSize;
fMaxContentWidth = NULL;
fMaxContentHeight = NULL;
fPreferredContentSize = kUndefinedSize;
fShrinkPenalties = BSize(2, 2);
fGrowPenalties = BSize(1, 1);
fContentAspectRatio = 0;
fContentAspectRatioC = NULL;
fAutoPreferredContentSize = false;
fPreferredContentWidth = NULL;
fPreferredContentHeight = NULL;
fChildArea = NULL;
fAlignment = BAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT);
fLeftInset = 0;
fTopInset = 0;
fRightInset = 0;
fBottomInset = 0;
fLeftConstraint = NULL;
fTopConstraint = NULL;
fRightConstraint = NULL;
fBottomConstraint = NULL;
fLS = ls;
fLeft = left;
fRight = right;
fTop = top;
fBottom = bottom;
SetContent(content);
fMinContentSize = minContentSize;
// adds the two essential constraints of the area that make sure that the left x-tab is
// really to the left of the right x-tab, and the top y-tab really above the bottom y-tab
fMinContentWidth = ls->AddConstraint(-1.0, left, 1.0, right, OperatorType(GE),
minContentSize.Width());
fConstraints->AddItem(fMinContentWidth);
fMinContentHeight = ls->AddConstraint(-1.0, top, 1.0, bottom, OperatorType(GE),
minContentSize.Height());
fConstraints->AddItem(fMinContentHeight);
}
示例6: LeftInset
void
Area::_UpdateMinSizeConstraint(BSize min)
{
float width = 0.;
float height = 0.;
if (min.width > 0)
width = min.Width() + LeftInset() + RightInset();
if (min.height > 0)
height = min.Height() + TopInset() + BottomInset();
fMinContentWidth->SetRightSide(width);
fMinContentHeight->SetRightSide(height);
}
示例7:
void
Area::SetGrowPenalties(BSize grow)
{
if (fChildArea == NULL) {
fGrowPenalties = grow;
if (fPreferredContentWidth != NULL) {
fPreferredContentWidth->SetPenaltyPos(grow.Width());
fPreferredContentHeight->SetPenaltyPos(grow.Height());
}
} else
fChildArea->SetGrowPenalties(grow);
fLS->InvalidateLayout();
}
示例8: rect
status_t
DataTranslationsWindow::_ShowConfigView(int32 id)
{
// Shows the config panel for the translator with the given id
if (id < 0)
return B_BAD_VALUE;
BTranslatorRoster *roster = BTranslatorRoster::Default();
// fConfigView is NULL the first time this function
// is called, prevent a segment fault
if (fConfigView)
fRightBox->RemoveChild(fConfigView);
BMessage emptyMsg;
BRect rect(0, 0, 200, 233);
status_t ret = roster->MakeConfigurationView(id, &emptyMsg, &fConfigView, &rect);
if (ret != B_OK) {
fRightBox->RemoveChild(fConfigView);
return ret;
}
BRect configRect(fRightBox->Bounds());
configRect.InsetBy(3, 3);
configRect.bottom -= 45;
float width = 0, height = 0;
if ((fConfigView->Flags() & B_SUPPORTS_LAYOUT) != 0) {
BSize configSize = fConfigView->ExplicitPreferredSize();
width = configSize.Width();
height = configSize.Height();
} else {
fConfigView->GetPreferredSize(&width, &height);
}
float widen = max_c(0, width - configRect.Width());
float heighten = max_c(0, height - configRect.Height());
if (widen > 0 || heighten > 0) {
ResizeBy(widen, heighten);
configRect.right += widen;
configRect.bottom += heighten;
}
fConfigView->MoveTo(configRect.left, configRect.top);
fConfigView->ResizeTo(configRect.Width(), configRect.Height());
fConfigView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
// force config views to all have the same color
fRightBox->AddChild(fConfigView);
return B_OK;
}
示例9: Bounds
void
TeamsWindow::Zoom(BPoint, float, float)
{
BSize preferredSize = fTeamsListView->PreferredSize();
ResizeBy(preferredSize.Width() - Bounds().Width(),
0.0);
// if the new size would extend us past the screen border,
// move sufficiently to the left to bring us back within the bounds
// + a bit of extra margin so we're not flush against the edge.
BScreen screen;
float offset = screen.Frame().right - Frame().right;
if (offset < 0)
MoveBy(offset - 5.0, 0.0);
}
示例10: LeftInset
void
Area::_UpdateMinSizeConstraint(BSize min)
{
if (!fLayoutItem->IsVisible()) {
fMinContentHeight->SetRightSide(-1);
fMinContentWidth->SetRightSide(-1);
return;
}
float width = 0.;
float height = 0.;
if (min.width > 0)
width = min.Width() + LeftInset() + RightInset();
if (min.height > 0)
height = min.Height() + TopInset() + BottomInset();
fMinContentWidth->SetRightSide(width);
fMinContentHeight->SetRightSide(height);
}
示例11: streamNodeSource
void
TFilePanel::RestoreState()
{
BNode defaultingNode;
if (DefaultStateSourceNode(kDefaultFilePanelTemplate, &defaultingNode,
false)) {
AttributeStreamFileNode streamNodeSource(&defaultingNode);
RestoreWindowState(&streamNodeSource);
PoseView()->Init(&streamNodeSource);
} else {
RestoreWindowState(NULL);
PoseView()->Init(NULL);
}
// Finish UI creation now that the PoseView is initialized
BLayoutItem* item
= fBorderedView->GroupLayout()->AddView(0, fPoseView->TitleView());
BSize minSize = item->MinSize();
BSize maxSize = item->MaxSize();
item->SetExplicitMinSize(BSize(minSize.Width(), kTitleViewHeight));
item->SetExplicitMaxSize(BSize(maxSize.Width(), kTitleViewHeight));
BRect rect(fBorderedView->Frame());
rect.right = rect.left + kCountViewWidth;
rect.top = rect.bottom + 1;
rect.bottom = rect.top + PoseView()->HScrollBar()->Bounds().Height() - 1;
PoseView()->CountView()->MoveTo(rect.LeftTop());
PoseView()->CountView()->ResizeTo(rect.Size());
PoseView()->CountView()->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
fBackView->AddChild(PoseView()->CountView(), fBorderedView);
PoseView()->HScrollBar()->MoveBy(kCountViewWidth + 1, 0);
PoseView()->HScrollBar()->ResizeBy(-kCountViewWidth - 1, 0);
// The Be Book states that the BTitleView will have a name of "TitleView",
// and so some apps will try to grab it by that name and move it around.
// They don't need to, because resizing "PoseView" (really the BorderedView)
// will resize the BTitleView as well. So just create a dummy view here
// so that they don't get NULL when trying to find the view.
BView* dummyTitleView = new BView(BRect(), "TitleView", B_FOLLOW_NONE, 0);
fBackView->AddChild(dummyTitleView);
dummyTitleView->Hide();
}
示例12: ThreeButtonsWindow
ThreeButtonsWindow(BRect frame)
:
BWindow(frame, "ALM Three Buttons", B_TITLED_WINDOW,
B_QUIT_ON_WINDOW_CLOSE)
{
BButton* button1 = new BButton("A");
BButton* button2 = new BButton("B");
BButton* button3 = new BButton("C");
button1->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
B_ALIGN_USE_FULL_HEIGHT));
button1->SetExplicitMaxSize(BSize(500, 50));
button2->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
B_ALIGN_USE_FULL_HEIGHT));
button2->SetExplicitMaxSize(BSize(500, 500));
button3->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
B_ALIGN_USE_FULL_HEIGHT));
button3->SetExplicitMaxSize(BSize(500, 500));
// create a new BALMLayout and use it for this window
fLayout = new BALMLayout();
SetLayout(fLayout);
fLayout->AddView(button1, fLayout->Left(), fLayout->Top(),
fLayout->Right(), NULL);
fLayout->AddViewToBottom(button2);
fLayout->AddViewToBottom(button3, fLayout->Bottom());
// test size limits
BSize min = fLayout->MinSize();
BSize max = fLayout->MaxSize();
SetSizeLimits(min.Width(), max.Width(), min.Height(), max.Height());
}
示例13: ThreeButtonsWindow
ThreeButtonsWindow(BRect frame)
:
BWindow(frame, "ALM Three Buttons", B_TITLED_WINDOW,
B_QUIT_ON_WINDOW_CLOSE)
{
BButton* button1 = new BButton("A");
BButton* button2 = new BButton("B");
BButton* button3 = new BButton("C");
button1->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
B_ALIGN_USE_FULL_HEIGHT));
button1->SetExplicitMaxSize(BSize(500, 50));
button2->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
B_ALIGN_USE_FULL_HEIGHT));
button2->SetExplicitMaxSize(BSize(500, 500));
button3->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
B_ALIGN_USE_FULL_HEIGHT));
button3->SetExplicitMaxSize(BSize(500, 500));
fLayout = new BALMLayout(0, 0);
BALM::BALMLayoutBuilder(this, fLayout)
.Add(button1, fLayout->Left(), fLayout->Top(), fLayout->Right())
.StartingAt(button1)
.AddBelow(button2)
.AddBelow(button3, fLayout->Bottom());
// test size limits
BSize min = fLayout->MinSize();
BSize max = fLayout->MaxSize();
SetSizeLimits(min.Width(), max.Width(), min.Height(), max.Height());
}
示例14: TableDemoWindow
TableDemoWindow(BRect frame)
: BWindow(frame, "ALM Table Demo", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE)
{
// create a new BALMLayout and use it for this window
BALMLayout* layout = new BALMLayout();
SetLayout(layout);
Column* c1 = layout->AddColumn(layout->Left(), layout->Right());
Row* r1 = layout->AddRow(layout->Top(), NULL);
Row* r2 = layout->AddRow(r1->Bottom(), NULL);
Row* r3 = layout->AddRow(r2->Bottom(), layout->Bottom());
BButton* b1 = new BButton("A1");
layout->AddView(b1, r1, c1);
b1->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));
BButton* b2 = new BButton("A2");
layout->AddView(b2, r2, c1);
b2->SetExplicitAlignment(BAlignment(
B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER));
BButton* b3 = new BButton("A3");
layout->AddView(b3, r3, c1);
b3->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT, B_ALIGN_BOTTOM));
// test size limits
BSize min = layout->MinSize();
BSize max = layout->MaxSize();
SetSizeLimits(min.Width(), max.Width(), min.Height(), max.Height());
}
示例15: StatusWindow
StatusWindow(const char* text)
:
BWindow(BRect(0, 0, 10, 10), B_TRANSLATE("status"), B_MODAL_WINDOW_LOOK,
B_MODAL_APP_WINDOW_FEEL, B_NO_WORKSPACE_ACTIVATION | B_NOT_ZOOMABLE
| B_AVOID_FRONT | B_NOT_RESIZABLE)
{
BView* rootView = new BView(Bounds(), "root", B_FOLLOW_ALL,
B_WILL_DRAW);
AddChild(rootView);
rootView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
float spacing = be_control_look->DefaultItemSpacing();
BALMLayout* layout = new BALMLayout(spacing);
rootView->SetLayout(layout);
layout->SetInset(spacing);
BStringView* string = new BStringView("text", text);
layout->AddView(string, layout->Left(), layout->Top(), layout->Right(),
layout->Bottom());
BSize min = layout->MinSize();
ResizeTo(min.Width(), min.Height());
CenterOnScreen();
}