本文整理汇总了C++中BAlignment函数的典型用法代码示例。如果您正苦于以下问题:C++ BAlignment函数的具体用法?C++ BAlignment怎么用?C++ BAlignment使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BAlignment函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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());
}
示例2: 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());
}
示例3: BView
LookAndFeelSettingsView::LookAndFeelSettingsView(const char* name)
:
BView(name, 0),
fDecorInfoButton(NULL),
fDecorMenuField(NULL),
fDecorMenu(NULL)
{
// Decorator menu
_BuildDecorMenu();
fDecorMenuField = new BMenuField("decorator",
B_TRANSLATE("Decorator:"), fDecorMenu);
fDecorInfoButton = new BButton(B_TRANSLATE("About"),
new BMessage(kMsgDecorInfo));
// scroll bar arrow style
BBox* arrowStyleBox = new BBox("arrow style");
arrowStyleBox->SetLabel(B_TRANSLATE("Arrow style"));
fSavedDoubleArrowsValue = _DoubleScrollBarArrows();
fArrowStyleSingle = new FakeScrollBar(true, false,
new BMessage(kMsgArrowStyleSingle));
fArrowStyleDouble = new FakeScrollBar(true, true,
new BMessage(kMsgArrowStyleDouble));
BView* arrowStyleView;
arrowStyleView = BLayoutBuilder::Group<>()
.AddGroup(B_VERTICAL, 1)
.Add(new BStringView("single", B_TRANSLATE("Single:")))
.Add(fArrowStyleSingle)
.AddStrut(B_USE_DEFAULT_SPACING)
.Add(new BStringView("double", B_TRANSLATE("Double:")))
.Add(fArrowStyleDouble)
.SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
.End()
.View();
arrowStyleBox->AddChild(arrowStyleView);
arrowStyleBox->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
B_ALIGN_VERTICAL_CENTER));
arrowStyleBox->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
BStringView* scrollBarLabel
= new BStringView("scroll bar", B_TRANSLATE("Scroll bar:"));
scrollBarLabel->SetExplicitAlignment(
BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));
// control layout
BLayoutBuilder::Grid<>(this, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
.Add(fDecorMenuField->CreateLabelLayoutItem(), 0, 0)
.Add(fDecorMenuField->CreateMenuBarLayoutItem(), 1, 0)
.Add(fDecorInfoButton, 2, 0)
.Add(scrollBarLabel, 0, 1)
.Add(arrowStyleBox, 1, 1)
.AddGlue(0, 2)
.SetInsets(B_USE_WINDOW_SPACING);
// TODO : Decorator Preview Image?
}
示例4: 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());
}
示例5: BView
CamStatusView::CamStatusView(Controller* controller)
:
BView("CamStatusView", B_WILL_DRAW|B_PULSE_NEEDED),
fController(controller),
fStringView(NULL),
fBitmapView(NULL),
fEncodingStringView(NULL),
fStatusBar(NULL),
fNumFrames(0),
fRecording(false),
fPaused(false),
fRecordingBitmap(NULL),
fPauseBitmap(NULL)
{
BCardLayout* cardLayout = new BCardLayout();
SetLayout(cardLayout);
BRect bitmapRect(0, 0, kBitmapSize, kBitmapSize);
fRecordingBitmap = new BBitmap(bitmapRect, B_RGBA32);
fPauseBitmap = new BBitmap(bitmapRect, B_RGBA32);
BView* statusView = BLayoutBuilder::Group<>()
.SetInsets(0)
.Add(fEncodingStringView = new BStringView("stringview", kEncodingString))
.Add(fStatusBar = new BStatusBar("", ""))
.View();
fStatusBar->SetExplicitMinSize(BSize(100, 20));
BView* layoutView = BLayoutBuilder::Group<>()
.SetInsets(0)
.Add(fBitmapView = new SquareBitmapView("bitmap view"))
.Add(fStringView = new BStringView("cam string view", ""))
.View();
cardLayout->AddView(layoutView);
cardLayout->AddView(statusView);
fBitmapView->SetBitmap(NULL);
BFont font;
GetFont(&font);
float scaledSize = kBitmapSize * (capped_size(font.Size()) / 12);
fBitmapView->SetExplicitMinSize(BSize(scaledSize, scaledSize));
fBitmapView->SetExplicitMaxSize(BSize(scaledSize, scaledSize));
fBitmapView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));
fStringView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
cardLayout->SetVisibleItem(int32(0));
}
示例6: rect
void
BButton::Draw(BRect updateRect)
{
BRect rect(Bounds());
rgb_color background = LowColor();
rgb_color base = background;
uint32 flags = be_control_look->Flags(this);
if (_Flag(FLAG_DEFAULT))
flags |= BControlLook::B_DEFAULT_BUTTON;
if (_Flag(FLAG_FLAT) && !IsTracking())
flags |= BControlLook::B_FLAT;
if (_Flag(FLAG_INSIDE))
flags |= BControlLook::B_HOVER;
be_control_look->DrawButtonFrame(this, rect, updateRect,
base, background, flags);
if (fBehavior == B_POP_UP_BEHAVIOR) {
be_control_look->DrawButtonWithPopUpBackground(this, rect, updateRect,
base, flags);
} else {
be_control_look->DrawButtonBackground(this, rect, updateRect,
base, flags);
}
// always leave some room around the label
rect.InsetBy(kLabelMargin, kLabelMargin);
const BBitmap* icon = IconBitmap(
(Value() == B_CONTROL_OFF
? B_INACTIVE_ICON_BITMAP : B_ACTIVE_ICON_BITMAP)
| (IsEnabled() ? 0 : B_DISABLED_ICON_BITMAP));
be_control_look->DrawLabel(this, Label(), icon, rect, updateRect,
base, flags, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE));
}
示例7: SetPulseRate
void
TTimeWindow::_InitWindow()
{
SetPulseRate(500000);
fDateTimeView = new DateTimeView(B_TRANSLATE("Date and time"));
fTimeZoneView = new TimeZoneView(B_TRANSLATE("Time zone"));
fNetworkTimeView = new NetworkTimeView(B_TRANSLATE("Network time"));
fClockView = new ClockView(B_TRANSLATE("Clock"));
fBaseView = new TTimeBaseView("baseView");
fBaseView->StartWatchingAll(fDateTimeView);
fBaseView->StartWatchingAll(fTimeZoneView);
fTabView = new BTabView("tabView", B_WIDTH_FROM_WIDEST);
fTabView->AddTab(fDateTimeView);
fTabView->AddTab(fTimeZoneView);
fTabView->AddTab(fNetworkTimeView);
fTabView->AddTab(fClockView);
fBaseView->AddChild(fTabView);
fRevertButton = new BButton("revert", B_TRANSLATE("Revert"),
new BMessage(kMsgRevert));
fRevertButton->SetEnabled(false);
fRevertButton->SetTarget(this);
fRevertButton->SetExplicitAlignment(
BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
BLayoutBuilder::Group<>(this, B_VERTICAL)
.SetInsets(B_USE_DEFAULT_SPACING)
.Add(fBaseView)
.Add(fRevertButton);
}
示例8: PictureView
void
PersonView::UpdatePicture(BBitmap* bitmap)
{
if (fPictureView == NULL) {
fPictureView = new PictureView(70, 90, bitmap);
GridLayout()->AddView(fPictureView, 0, 0, 1, 5);
GridLayout()->ItemAt(0, 0)->SetExplicitAlignment(
BAlignment(B_ALIGN_CENTER, B_ALIGN_TOP));
return;
}
if (fSaving)
return;
/*
time_t modificationTime = 0;
BEntry entry(ref);
entry.GetModificationTime(&modificationTime);
if (entry.InitCheck() == B_OK
&& modificationTime <= fLastModificationTime) {
return;
}*/
fPictureView->Update(bitmap);
}
示例9: BGridView
PersonView::PersonView(const char* name, const char* categoryAttribute,
const entry_ref *ref)
:
BGridView(),
fLastModificationTime(0),
fGroups(NULL),
fControls(20, false),
fCategoryAttribute(categoryAttribute),
fPictureView(NULL),
fSaving(false)
{
SetName(name);
SetFlags(Flags() | B_WILL_DRAW);
fRef = ref;
BFile* file = NULL;
if (fRef != NULL)
file = new BFile(fRef, B_READ_ONLY);
// Add picture "field", using ID photo 35mm x 45mm ratio
fPictureView = new PictureView(70, 90, ref);
BGridLayout* layout = GridLayout();
float spacing = be_control_look->DefaultItemSpacing();
layout->SetInsets(spacing, spacing, spacing, spacing);
layout->AddView(fPictureView, 0, 0, 1, 5);
layout->ItemAt(0, 0)->SetExplicitAlignment(
BAlignment(B_ALIGN_CENTER, B_ALIGN_TOP));
if (file != NULL)
file->GetModificationTime(&fLastModificationTime);
delete file;
}
示例10: _ValidateLayoutData
BAlignment
BAbstractSpinner::LayoutAlignment()
{
_ValidateLayoutData();
return BLayoutUtils::ComposeAlignment(ExplicitAlignment(),
BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_CENTER));
}
示例11: BPoint
void
BToolTip::_InitData()
{
fIsSticky = false;
fRelativeLocation = BPoint(20, 20);
fAlignment = BAlignment(B_ALIGN_RIGHT, B_ALIGN_BOTTOM);
}
示例12: BPopUpMenu
BMenuField*
ModifierKeysWindow::_CreateCommandMenuField()
{
fCommandMenu = new BPopUpMenu(
B_TRANSLATE_NOCOLLECT(_KeyToString(MENU_ITEM_COMMAND)), true, true);
for (int32 key = MENU_ITEM_SHIFT; key <= MENU_ITEM_DISABLED; key++) {
if (key == MENU_ITEM_SEPERATOR) {
// add separator item
BSeparatorItem* separator = new BSeparatorItem;
fCommandMenu->AddItem(separator, MENU_ITEM_SEPERATOR);
continue;
}
BMessage* message = new BMessage(kMsgUpdateModifier);
message->AddInt32(_KeyToString(MENU_ITEM_COMMAND), key);
BMenuItem* item = new BMenuItem(
B_TRANSLATE_NOCOLLECT(_KeyToString(key)), message);
fCommandMenu->AddItem(item, key);
}
fCommandMenu->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
B_ALIGN_VERTICAL_UNSET));
return new BMenuField(B_TRANSLATE_COMMENT("Command:",
"Command key role name"), fCommandMenu);
}
示例13: BView
PreviewView::PreviewView()
:
BView("Rect View", B_WILL_DRAW),
fBitmapView(NULL),
fTop(NULL),
fLeft(NULL),
fRight(NULL),
fBottom(NULL)
{
fCoordRect = BRect(10, 10, 20, 20);
fChanged = true;
SetLayout(new BGroupLayout(B_HORIZONTAL));
SetExplicitAlignment(BAlignment(B_ALIGN_HORIZONTAL_CENTER,
B_ALIGN_VERTICAL_CENTER));
AddChild(BGroupLayoutBuilder(B_VERTICAL)
.AddGroup(B_HORIZONTAL)
.Add(new BStringView("spacer", ""))
.Add(fTop = new BStringView("top", "top"))
.Add(new BStringView("spacer", ""))
.End()
.AddGroup(B_HORIZONTAL)
.Add(fLeft = new BStringView("left", "left"))
.Add(fBitmapView = new BitmapView())
.Add(fRight = new BStringView("right", "right"))
.End()
.AddGroup(B_HORIZONTAL)
.Add(new BStringView("spacer", ""))
.Add(fBottom = new BStringView("bottom", "bottom"))
.Add(new BStringView("spacer", ""))
.End()
);
}
示例14: BWindow
ScreenSaverWindow::ScreenSaverWindow()
:
BWindow(BRect(50.0f, 50.0f, 50.0f + kWindowWidth, 50.0f + kWindowHeight),
B_TRANSLATE_SYSTEM_NAME("ScreenSaver"), B_TITLED_WINDOW,
B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS)
{
fSettings.Load();
fMinWidth = floorf(be_control_look->DefaultItemSpacing()
* (kWindowWidth / kDefaultItemSpacingAt12pt));
font_height fontHeight;
be_plain_font->GetHeight(&fontHeight);
float textHeight = ceilf(fontHeight.ascent + fontHeight.descent);
fMinHeight = ceilf(std::max(kWindowHeight, textHeight * 28));
// Create the password editing window
fPasswordWindow = new PasswordWindow(fSettings);
fPasswordWindow->Run();
// Create the tab view
fTabView = new TabView();
fTabView->SetBorder(B_NO_BORDER);
// Create the controls inside the tabs
fFadeView = new FadeView(B_TRANSLATE("General"), fSettings);
fModulesView = new ModulesView(B_TRANSLATE("Screensavers"), fSettings);
fTabView->AddTab(fFadeView);
fTabView->AddTab(fModulesView);
// Create the topmost background view
BView* topView = new BView("topView", B_WILL_DRAW);
topView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
topView->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
B_ALIGN_USE_FULL_HEIGHT));
topView->SetExplicitMinSize(BSize(fMinWidth, fMinHeight));
BLayoutBuilder::Group<>(topView, B_VERTICAL)
.SetInsets(0, B_USE_DEFAULT_SPACING, 0, B_USE_WINDOW_SPACING)
.Add(fTabView)
.End();
SetLayout(new BGroupLayout(B_VERTICAL));
GetLayout()->AddView(topView);
fTabView->Select(fSettings.WindowTab());
if (fSettings.WindowFrame().left > 0 && fSettings.WindowFrame().top > 0)
MoveTo(fSettings.WindowFrame().left, fSettings.WindowFrame().top);
if (fSettings.WindowFrame().Width() > 0
&& fSettings.WindowFrame().Height() > 0) {
ResizeTo(fSettings.WindowFrame().Width(),
fSettings.WindowFrame().Height());
}
CenterOnScreen();
}
示例15: fMessage
Settings::Settings()
:
fMessage(kMsgDiskProbeSettings),
fUpdated(false)
{
float fontSize = be_plain_font->Size();
int32 windowWidth = DataView::WidthForFontSize(fontSize) + 20;
// TODO: make scrollbar width variable
BScreen screen;
fMessage.AddRect("window_frame", BLayoutUtils::AlignInFrame(screen.Frame(),
BSize(windowWidth, windowWidth),
BAlignment(B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER)));
fMessage.AddInt32("base_type", kHexBase);
fMessage.AddFloat("font_size", fontSize);
fMessage.AddBool("case_sensitive", true);
fMessage.AddInt8("find_mode", kAsciiMode);
BFile file;
if (Open(&file, B_READ_ONLY) != B_OK)
return;
// TODO: load/save settings as flattened BMessage - but not yet,
// since that will break compatibility with R5's DiskProbe
disk_probe_settings settings;
if (file.Read(&settings, sizeof(settings)) == sizeof(settings)) {
#if B_HOST_IS_BENDIAN
// settings are saved in little endian
settings.window_frame.left = B_LENDIAN_TO_HOST_FLOAT(
settings.window_frame.left);
settings.window_frame.top = B_LENDIAN_TO_HOST_FLOAT(
settings.window_frame.top);
settings.window_frame.right = B_LENDIAN_TO_HOST_FLOAT(
settings.window_frame.right);
settings.window_frame.bottom = B_LENDIAN_TO_HOST_FLOAT(
settings.window_frame.bottom);
#endif
// check if the window frame is on screen at all
BScreen screen;
if (screen.Frame().Contains(settings.window_frame.LeftTop())
&& settings.window_frame.Width() < screen.Frame().Width()
&& settings.window_frame.Height() < screen.Frame().Height())
fMessage.ReplaceRect("window_frame", settings.window_frame);
if (settings.base_type == kHexBase
|| settings.base_type == kDecimalBase)
fMessage.ReplaceInt32("base_type",
B_LENDIAN_TO_HOST_INT32(settings.base_type));
if (settings.font_size >= 0 && settings.font_size <= 72)
fMessage.ReplaceFloat("font_size",
float(B_LENDIAN_TO_HOST_INT32(settings.font_size)));
fMessage.ReplaceBool("case_sensitive",
settings.flags & kCaseSensitive);
fMessage.ReplaceInt8("find_mode",
settings.flags & kHexFindMode ? kHexMode : kAsciiMode);
}
}