本文整理汇总了C++中BButton::MoveBy方法的典型用法代码示例。如果您正苦于以下问题:C++ BButton::MoveBy方法的具体用法?C++ BButton::MoveBy怎么用?C++ BButton::MoveBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BButton
的用法示例。
在下文中一共展示了BButton::MoveBy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BMessage
BButton*
BAlert::_CreateButton(int32 which, const char* label)
{
BMessage* message = new BMessage(kAlertButtonMsg);
if (message == NULL)
return NULL;
message->AddInt32("which", which);
BRect rect;
rect.top = Bounds().bottom - kBottomOffset;
rect.bottom = rect.top;
char name[32];
snprintf(name, sizeof(name), "_b%ld_", which);
BButton* button = new(std::nothrow) BButton(rect, name, label, message,
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
if (button == NULL)
return NULL;
float width, height;
button->GetPreferredSize(&width, &height);
if (fButtonWidth == B_WIDTH_AS_USUAL) {
float fontFactor = be_plain_font->Size() / 11.0f;
width = max_c(width, kButtonUsualWidth * fontFactor);
}
button->ResizeTo(width, height);
button->MoveBy(0.0f, -height);
return button;
}
示例2:
void
TFilePanel::SetButtonLabel(file_panel_button selector, const char* text)
{
switch (selector) {
case B_CANCEL_BUTTON:
{
BButton* button
= dynamic_cast<BButton*>(FindView("cancel button"));
if (button == NULL)
break;
float old_width = button->StringWidth(button->Label());
button->SetLabel(text);
float delta = old_width - button->StringWidth(text);
if (delta) {
button->MoveBy(delta, 0);
button->ResizeBy(-delta, 0);
}
}
break;
case B_DEFAULT_BUTTON:
{
fButtonText = text;
float delta = 0;
BButton* button
= dynamic_cast<BButton*>(FindView("default button"));
if (button != NULL) {
float old_width = button->StringWidth(button->Label());
button->SetLabel(text);
delta = old_width - button->StringWidth(text);
if (delta) {
button->MoveBy(delta, 0);
button->ResizeBy(-delta, 0);
}
}
// now must move cancel button
button = dynamic_cast<BButton*>(FindView("cancel button"));
if (button != NULL)
button->MoveBy(delta, 0);
}
break;
}
}
示例3: windowRect
OpenWithContainerWindow::OpenWithContainerWindow(BMessage* entriesToOpen,
LockingList<BWindow>* windowList, window_look look, window_feel feel,
uint32 flags, uint32 workspace)
:
BContainerWindow(windowList, 0, look, feel, flags, workspace),
fEntriesToOpen(entriesToOpen)
{
AutoLock<BWindow> lock(this);
BRect windowRect(85, 50, 718, 296);
MoveTo(windowRect.LeftTop());
ResizeTo(windowRect.Width(), windowRect.Height());
// add a background view; use the standard BackgroundView here, the same
// as the file panel is using
BRect rect(Bounds());
BackgroundView* backgroundView = new BackgroundView(rect);
AddChild(backgroundView);
rect = Bounds();
// add buttons
fLaunchButton = new BButton(rect, "ok", B_TRANSLATE("Open"),
new BMessage(kDefaultButton), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
fLaunchButton->ResizeToPreferred();
fLaunchButton->MoveTo(rect.right - 10 - kDocumentKnobWidth
- fLaunchButton->Bounds().Width(),
rect.bottom - 10.0f - fLaunchButton->Bounds().Height());
backgroundView->AddChild(fLaunchButton);
BRect buttonRect = fLaunchButton->Frame();
fLaunchAndMakeDefaultButton = new BButton(buttonRect, "make default",
B_TRANSLATE("Open and make preferred"),
new BMessage(kOpenAndMakeDefault), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
// wide button, have to resize to fit text
fLaunchAndMakeDefaultButton->ResizeToPreferred();
fLaunchAndMakeDefaultButton->MoveBy(-10.0f
- fLaunchAndMakeDefaultButton->Bounds().Width(), 0.0f);
backgroundView->AddChild(fLaunchAndMakeDefaultButton);
fLaunchAndMakeDefaultButton->SetEnabled(false);
buttonRect = fLaunchAndMakeDefaultButton->Frame();
BButton* button = new BButton(buttonRect, "cancel", B_TRANSLATE("Cancel"),
new BMessage(kCancelButton), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
button->ResizeToPreferred();
button->MoveBy(-10.0f - button->Bounds().Width(), 0.0f);
backgroundView->AddChild(button);
fMinimalWidth = button->Bounds().Width() + fLaunchButton->Bounds().Width()
+ fLaunchAndMakeDefaultButton->Bounds().Width() + kDocumentKnobWidth
+ 40.0f;
fLaunchButton->MakeDefault(true);
// add pose view
rect.OffsetTo(10.0f, 10.0f);
rect.bottom = buttonRect.top - 15.0f;
rect.right -= B_V_SCROLL_BAR_WIDTH + 20.0f;
rect.bottom -= B_H_SCROLL_BAR_HEIGHT;
// make room for scrollbars and a margin
fPoseView = NewPoseView(0, rect, kListMode);
backgroundView->AddChild(fPoseView);
fPoseView->SetFlags(fPoseView->Flags() | B_NAVIGABLE);
fPoseView->SetPoseEditing(false);
// set the window title
if (CountRefs(fEntriesToOpen) == 1) {
// if opening just one file, use it in the title
entry_ref ref;
fEntriesToOpen->FindRef("refs", &ref);
BString buffer(B_TRANSLATE("Open %name with:"));
buffer.ReplaceFirst("%name", ref.name);
SetTitle(buffer.String());
} else {
// use generic title
SetTitle(B_TRANSLATE("Open selection with:"));
}
AddCommonFilter(new BMessageFilter(B_KEY_DOWN,
&OpenWithContainerWindow::KeyDownFilter));
}
示例4: BMessage
void
PasswordWindow::_Setup()
{
BRect bounds = Bounds();
BView* topView = new BView(bounds, "topView", B_FOLLOW_ALL, B_WILL_DRAW);
topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(topView);
bounds.InsetBy(10.0, 10.0);
fUseNetwork = new BRadioButton(bounds, "useNetwork", "Use network password",
new BMessage(kMsgPasswordTypeChanged), B_FOLLOW_NONE);
topView->AddChild(fUseNetwork);
fUseNetwork->ResizeToPreferred();
fUseNetwork->MoveBy(10.0, 0.0);
bounds.OffsetBy(0.0, fUseNetwork->Bounds().Height());
BBox *customBox = new BBox(bounds, "customBox", B_FOLLOW_NONE);
topView->AddChild(customBox);
fUseCustom = new BRadioButton(BRect(), "useCustom", "Use custom password",
new BMessage(kMsgPasswordTypeChanged), B_FOLLOW_NONE);
customBox->SetLabel(fUseCustom);
fUseCustom->ResizeToPreferred();
fPasswordControl = new BTextControl(bounds, "passwordControl", "Password:",
NULL, B_FOLLOW_NONE);
customBox->AddChild(fPasswordControl);
fPasswordControl->ResizeToPreferred();
fPasswordControl->TextView()->HideTyping(true);
fPasswordControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
bounds.OffsetBy(0.0, fPasswordControl->Bounds().Height() + 5.0);
fConfirmControl = new BTextControl(bounds, "confirmControl",
"Confirm password:", "VeryLongPasswordPossible", B_FOLLOW_NONE);
customBox->AddChild(fConfirmControl);
fConfirmControl->TextView()->HideTyping(true);
fConfirmControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
float width, height;
fConfirmControl->GetPreferredSize(&width, &height);
fPasswordControl->ResizeTo(width, height);
fConfirmControl->ResizeTo(width, height);
float divider = be_plain_font->StringWidth("Confirm password:") + 5.0;
fConfirmControl->SetDivider(divider);
fPasswordControl->SetDivider(divider);
customBox->ResizeTo(fConfirmControl->Frame().right + 10.0,
fConfirmControl->Frame().bottom + 10.0);
BButton* button = new BButton(BRect(), "done", "Done", new BMessage(kMsgDone));
topView->AddChild(button);
button->ResizeToPreferred();
BRect frame = customBox->Frame();
button->MoveTo(frame.right - button->Bounds().Width(), frame.bottom + 10.0);
frame = button->Frame();
button->MakeDefault(true);
button = new BButton(frame, "cancel", "Cancel", new BMessage(B_CANCEL));
topView->AddChild(button);
button->ResizeToPreferred();
button->MoveBy(-(button->Bounds().Width() + 10.0), 0.0);
ResizeTo(customBox->Frame().right + 10.0, frame.bottom + 10.0);
}