本文整理汇总了C++中BMenuBar::SetExplicitAlignment方法的典型用法代码示例。如果您正苦于以下问题:C++ BMenuBar::SetExplicitAlignment方法的具体用法?C++ BMenuBar::SetExplicitAlignment怎么用?C++ BMenuBar::SetExplicitAlignment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BMenuBar
的用法示例。
在下文中一共展示了BMenuBar::SetExplicitAlignment方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BMessage
ApplicationTypeWindow::ApplicationTypeWindow(BPoint position,
const BEntry& entry)
:
BWindow(BRect(0.0f, 0.0f, 250.0f, 340.0f).OffsetBySelf(position),
B_TRANSLATE("Application type"), B_TITLED_WINDOW,
B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS |
B_FRAME_EVENTS | B_AUTO_UPDATE_SIZE_LIMITS),
fChangedProperties(0)
{
float padding = be_control_look->DefaultItemSpacing();
BAlignment labelAlignment = be_control_look->DefaultLabelAlignment();
BMenuBar* menuBar = new BMenuBar((char*)NULL);
menuBar->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));
BMenu* menu = new BMenu(B_TRANSLATE("File"));
fSaveMenuItem = new BMenuItem(B_TRANSLATE("Save"),
new BMessage(kMsgSave), 'S');
fSaveMenuItem->SetEnabled(false);
menu->AddItem(fSaveMenuItem);
BMenuItem* item;
menu->AddItem(item = new BMenuItem(
B_TRANSLATE("Save into resource file" B_UTF8_ELLIPSIS), NULL));
item->SetEnabled(false);
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem(B_TRANSLATE("Close"),
new BMessage(B_QUIT_REQUESTED), 'W', B_COMMAND_KEY));
menuBar->AddItem(menu);
// Signature
fSignatureControl = new BTextControl(B_TRANSLATE("Signature:"), NULL,
new BMessage(kMsgSignatureChanged));
fSignatureControl->SetModificationMessage(
new BMessage(kMsgSignatureChanged));
// filter out invalid characters that can't be part of a MIME type name
BTextView* textView = fSignatureControl->TextView();
textView->SetMaxBytes(B_MIME_TYPE_LENGTH);
const char* disallowedCharacters = "<>@,;:\"()[]?=";
for (int32 i = 0; disallowedCharacters[i]; i++) {
textView->DisallowChar(disallowedCharacters[i]);
}
// "Application Flags" group
BBox* flagsBox = new BBox("flagsBox");
fFlagsCheckBox = new BCheckBox("flags", B_TRANSLATE("Application flags"),
new BMessage(kMsgToggleAppFlags));
fFlagsCheckBox->SetValue(B_CONTROL_ON);
fSingleLaunchButton = new BRadioButton("single",
B_TRANSLATE("Single launch"), new BMessage(kMsgAppFlagsChanged));
fMultipleLaunchButton = new BRadioButton("multiple",
B_TRANSLATE("Multiple launch"), new BMessage(kMsgAppFlagsChanged));
fExclusiveLaunchButton = new BRadioButton("exclusive",
B_TRANSLATE("Exclusive launch"), new BMessage(kMsgAppFlagsChanged));
fArgsOnlyCheckBox = new BCheckBox("args only", B_TRANSLATE("Args only"),
new BMessage(kMsgAppFlagsChanged));
fBackgroundAppCheckBox = new BCheckBox("background",
B_TRANSLATE("Background app"), new BMessage(kMsgAppFlagsChanged));
flagsBox->AddChild(BGridLayoutBuilder()
.Add(fSingleLaunchButton, 0, 0).Add(fArgsOnlyCheckBox, 1, 0)
.Add(fMultipleLaunchButton, 0, 1).Add(fBackgroundAppCheckBox, 1, 1)
.Add(fExclusiveLaunchButton, 0, 2)
.SetInsets(padding, padding, padding, padding));
flagsBox->SetLabel(fFlagsCheckBox);
// "Icon" group
BBox* iconBox = new BBox("IconBox");
iconBox->SetLabel(B_TRANSLATE("Icon"));
fIconView = new IconView("icon");
fIconView->SetModificationMessage(new BMessage(kMsgIconChanged));
iconBox->AddChild(BGroupLayoutBuilder(B_HORIZONTAL)
.Add(fIconView)
.SetInsets(padding, padding, padding, padding));
// "Supported Types" group
BBox* typeBox = new BBox("typesBox");
typeBox->SetLabel(B_TRANSLATE("Supported types"));
fTypeListView = new SupportedTypeListView("Suppported Types",
B_SINGLE_SELECTION_LIST);
fTypeListView->SetSelectionMessage(new BMessage(kMsgTypeSelected));
BScrollView* scrollView = new BScrollView("type scrollview", fTypeListView,
B_FRAME_EVENTS | B_WILL_DRAW, false, true);
fAddTypeButton = new BButton("add type",
B_TRANSLATE("Add" B_UTF8_ELLIPSIS), new BMessage(kMsgAddType));
//.........这里部分代码省略.........
示例2: fullAlignment
FileTypesWindow::FileTypesWindow(const BMessage& settings)
:
BWindow(_Frame(settings), B_TRANSLATE_SYSTEM_NAME("FileTypes"),
B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS
| B_AUTO_UPDATE_SIZE_LIMITS),
fNewTypeWindow(NULL)
{
bool showIcons;
bool showRule;
if (settings.FindBool("show_icons", &showIcons) != B_OK)
showIcons = true;
if (settings.FindBool("show_rule", &showRule) != B_OK)
showRule = false;
float padding = be_control_look->DefaultItemSpacing();
BAlignment labelAlignment = be_control_look->DefaultLabelAlignment();
BAlignment fullAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT);
// add the menu
BMenuBar* menuBar = new BMenuBar("");
BMenu* menu = new BMenu(B_TRANSLATE("File"));
BMenuItem* item = new BMenuItem(
B_TRANSLATE("New resource file" B_UTF8_ELLIPSIS), NULL, 'N',
B_COMMAND_KEY);
item->SetEnabled(false);
menu->AddItem(item);
BMenu* recentsMenu = BRecentFilesList::NewFileListMenu(
B_TRANSLATE("Open" B_UTF8_ELLIPSIS), NULL, NULL,
be_app, 10, false, NULL, kSignature);
item = new BMenuItem(recentsMenu, new BMessage(kMsgOpenFilePanel));
item->SetShortcut('O', B_COMMAND_KEY);
menu->AddItem(item);
menu->AddItem(new BMenuItem(
B_TRANSLATE("Application types" B_UTF8_ELLIPSIS),
new BMessage(kMsgOpenApplicationTypesWindow)));
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"),
new BMessage(B_QUIT_REQUESTED), 'Q', B_COMMAND_KEY));
menu->SetTargetForItems(be_app);
menuBar->AddItem(menu);
menu = new BMenu(B_TRANSLATE("Settings"));
item = new BMenuItem(B_TRANSLATE("Show icons in list"),
new BMessage(kMsgToggleIcons));
item->SetMarked(showIcons);
item->SetTarget(this);
menu->AddItem(item);
item = new BMenuItem(B_TRANSLATE("Show recognition rule"),
new BMessage(kMsgToggleRule));
item->SetMarked(showRule);
item->SetTarget(this);
menu->AddItem(item);
menuBar->AddItem(menu);
menuBar->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));
// MIME Types list
BButton* addTypeButton = new BButton("add",
B_TRANSLATE("Add" B_UTF8_ELLIPSIS), new BMessage(kMsgAddType));
fRemoveTypeButton = new BButton("remove", B_TRANSLATE("Remove"),
new BMessage(kMsgRemoveType) );
fTypeListView = new MimeTypeListView("typeview", NULL, showIcons, false);
fTypeListView->SetSelectionMessage(new BMessage(kMsgTypeSelected));
fTypeListView->SetExplicitMinSize(BSize(200, B_SIZE_UNSET));
BScrollView* typeListScrollView = new BScrollView("scrollview",
fTypeListView, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
// "Icon" group
fIconView = new TypeIconView("icon");
fIconBox = new BBox("Icon BBox");
fIconBox->SetLabel(B_TRANSLATE("Icon"));
BLayoutBuilder::Group<>(fIconBox, B_VERTICAL, padding)
.SetInsets(padding)
.AddGlue(1)
.Add(fIconView, 3)
.AddGlue(1);
// "File Recognition" group
fRecognitionBox = new BBox("Recognition Box");
fRecognitionBox->SetLabel(B_TRANSLATE("File recognition"));
fRecognitionBox->SetExplicitAlignment(fullAlignment);
fExtensionLabel = new StringView(B_TRANSLATE("Extensions:"), NULL);
fExtensionLabel->LabelView()->SetExplicitAlignment(labelAlignment);
fAddExtensionButton = new BButton("add ext",
B_TRANSLATE("Add" B_UTF8_ELLIPSIS), new BMessage(kMsgAddExtension));
fAddExtensionButton->SetExplicitMaxSize(
BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
fRemoveExtensionButton = new BButton("remove ext", B_TRANSLATE("Remove"),
//.........这里部分代码省略.........