本文整理汇总了C++中BMenuField::CreateLabelLayoutItem方法的典型用法代码示例。如果您正苦于以下问题:C++ BMenuField::CreateLabelLayoutItem方法的具体用法?C++ BMenuField::CreateLabelLayoutItem怎么用?C++ BMenuField::CreateLabelLayoutItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BMenuField
的用法示例。
在下文中一共展示了BMenuField::CreateLabelLayoutItem方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ContactFieldTextControl
virtual void Visit(BStringContactField* field)
{
int count = fOwner->fControls.CountItems();
BGridLayout* layout = fOwner->GridLayout();
if (field->FieldType() != B_CONTACT_SIMPLE_GROUP) {
ContactFieldTextControl* control = new ContactFieldTextControl(field);
layout->AddItem(control->CreateLabelLayoutItem(), 1, count);
layout->AddItem(control->CreateTextViewLayoutItem(), 2, count);
fOwner->fControls.AddItem(control);
} else {
const char* label =
BContactField::ExtendedLabel(field);
fOwner->fGroups = new BPopUpMenu(label);
fOwner->fGroups->SetRadioMode(false);
fOwner->BuildGroupMenu(field);
BMenuField* field = new BMenuField("", "", fOwner->fGroups);
BTextControl* control = new BTextControl("simpleGroup",
NULL, NULL, NULL);
field->SetEnabled(true);
layout->AddItem(field->CreateLabelLayoutItem(), 1, 0, count);
layout->AddItem(field->CreateMenuBarLayoutItem(), 1, 1, count);
layout->AddItem(control->CreateLabelLayoutItem(), 2, 0, count);
layout->AddItem(control->CreateTextViewLayoutItem(), 2, 1, count);
}
}
示例2: font
void
PackageView::_InitView()
{
SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
float fontHeight = be_plain_font->Size();
rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR);
BTextView* packageDescriptionView = new DescriptionTextView(
"package description", fontHeight * 13);
packageDescriptionView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
packageDescriptionView->SetText(fInfo.GetDescription());
packageDescriptionView->MakeEditable(false);
packageDescriptionView->MakeSelectable(false);
packageDescriptionView->SetFontAndColor(be_plain_font, B_FONT_ALL,
&textColor);
BScrollView* descriptionScrollView = new BScrollView(
"package description scroll view", packageDescriptionView,
0, false, true, B_NO_BORDER);
// Install type menu field
fInstallTypes = new BPopUpMenu(B_TRANSLATE("none"));
BMenuField* installType = new BMenuField("install_type",
B_TRANSLATE("Installation type:"), fInstallTypes);
// Install type description text view
fInstallTypeDescriptionView = new DescriptionTextView(
"install type description", fontHeight * 4);
fInstallTypeDescriptionView->MakeEditable(false);
fInstallTypeDescriptionView->MakeSelectable(false);
fInstallTypeDescriptionView->SetInsets(8, 0, 0, 0);
// Left inset needs to match BMenuField text offset
fInstallTypeDescriptionView->SetText(
B_TRANSLATE("No installation type selected"));
fInstallTypeDescriptionView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
BFont font(be_plain_font);
font.SetSize(ceilf(font.Size() * 0.85));
fInstallTypeDescriptionView->SetFontAndColor(&font, B_FONT_ALL,
&textColor);
BScrollView* installTypeScrollView = new BScrollView(
"install type description scroll view", fInstallTypeDescriptionView,
0, false, true, B_NO_BORDER);
// Destination menu field
fDestination = new BPopUpMenu(B_TRANSLATE("none"));
fDestField = new BMenuField("install_to", B_TRANSLATE("Install to:"),
fDestination);
fBeginButton = new BButton("begin_button", B_TRANSLATE("Begin"),
new BMessage(P_MSG_INSTALL));
BLayoutItem* typeLabelItem = installType->CreateLabelLayoutItem();
BLayoutItem* typeMenuItem = installType->CreateMenuBarLayoutItem();
BLayoutItem* destFieldLabelItem = fDestField->CreateLabelLayoutItem();
BLayoutItem* destFieldMenuItem = fDestField->CreateMenuBarLayoutItem();
float forcedMinWidth = be_plain_font->StringWidth("XXX") * 5;
destFieldMenuItem->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET));
typeMenuItem->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET));
BAlignment labelAlignment(B_ALIGN_RIGHT, B_ALIGN_VERTICAL_UNSET);
typeLabelItem->SetExplicitAlignment(labelAlignment);
destFieldLabelItem->SetExplicitAlignment(labelAlignment);
// Build the layout
BLayoutBuilder::Group<>(this, B_VERTICAL)
.Add(descriptionScrollView)
.AddGrid(B_USE_SMALL_SPACING, B_USE_DEFAULT_SPACING)
.Add(typeLabelItem, 0, 0)
.Add(typeMenuItem, 1, 0)
.Add(installTypeScrollView, 1, 1)
.Add(destFieldLabelItem, 0, 2)
.Add(destFieldMenuItem, 1, 2)
.End()
.AddGroup(B_HORIZONTAL)
.AddGlue()
.Add(fBeginButton)
.End()
.SetInsets(B_USE_DEFAULT_SPACING)
;
fBeginButton->MakeDefault(true);
}
示例3: BMessage
ConfigView::ConfigView(TranslatorSettings* settings)
:
BGroupView(B_TRANSLATE("WebPTranslator Settings"), B_VERTICAL),
fSettings(settings)
{
SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
BStringView* title = new BStringView("title",
B_TRANSLATE("WebP image translator"));
title->SetFont(be_bold_font);
char versionString[256];
sprintf(versionString, "v%d.%d.%d, %s",
static_cast<int>(B_TRANSLATION_MAJOR_VERSION(WEBP_TRANSLATOR_VERSION)),
static_cast<int>(B_TRANSLATION_MINOR_VERSION(WEBP_TRANSLATOR_VERSION)),
static_cast<int>(B_TRANSLATION_REVISION_VERSION(
WEBP_TRANSLATOR_VERSION)),
__DATE__);
BStringView* version = new BStringView("version", versionString);
BString copyrightsText;
BStringView *copyrightView = new BStringView("Copyright",
B_TRANSLATE(B_UTF8_COPYRIGHT "2010-2011 Haiku Inc."));
BStringView *copyright2View = new BStringView("Copyright2",
B_TRANSLATE("Based on libwebp v0.1,"));
BStringView *copyright3View = new BStringView("Copyright3",
B_TRANSLATE(B_UTF8_COPYRIGHT "2010-2011 Google Inc."));
// output parameters
fPresetsMenu = new BPopUpMenu(B_TRANSLATE("Preset"));
const struct preset_name* preset = kPresetNames;
while (preset->name != NULL) {
BMessage* msg = new BMessage(kMsgPreset);
msg->AddInt32("value", preset->id);
BMenuItem* item = new BMenuItem(preset->name, msg);
if (fSettings->SetGetInt32(WEBP_SETTING_PRESET) == preset->id)
item->SetMarked(true);
fPresetsMenu->AddItem(item);
preset++;
}
BMenuField* presetsField = new BMenuField(B_TRANSLATE("Output preset:"),
fPresetsMenu);
fQualitySlider = new BSlider("quality", B_TRANSLATE("Output quality:"),
new BMessage(kMsgQuality), 0, 100, B_HORIZONTAL, B_BLOCK_THUMB);
fQualitySlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fQualitySlider->SetHashMarkCount(10);
fQualitySlider->SetLimitLabels(B_TRANSLATE("Low"), B_TRANSLATE("High"));
fQualitySlider->SetValue(fSettings->SetGetInt32(WEBP_SETTING_QUALITY));
fMethodSlider = new BSlider("method", B_TRANSLATE("Compression method:"),
new BMessage(kMsgMethod), 0, 6, B_HORIZONTAL, B_BLOCK_THUMB);
fMethodSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fMethodSlider->SetHashMarkCount(7);
fMethodSlider->SetLimitLabels(B_TRANSLATE("Fast"),
B_TRANSLATE("Slower but better"));
fMethodSlider->SetValue(fSettings->SetGetInt32(WEBP_SETTING_METHOD));
fPreprocessingCheckBox = new BCheckBox("preprocessing",
B_TRANSLATE("Preprocessing filter"), new BMessage(kMsgPreprocessing));
if (fSettings->SetGetBool(WEBP_SETTING_PREPROCESSING))
fPreprocessingCheckBox->SetValue(B_CONTROL_ON);
// Build the layout
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
.SetInsets(B_USE_DEFAULT_SPACING)
.Add(title)
.Add(version)
.Add(copyrightView)
.AddGlue()
.AddGrid(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING)
.Add(presetsField->CreateLabelLayoutItem(), 0, 0)
.AddGroup(B_HORIZONTAL, 0.0f, 1, 0)
.Add(presetsField->CreateMenuBarLayoutItem(), 0.0f)
.AddGlue()
.End()
.End()
.Add(fQualitySlider)
.Add(fMethodSlider)
.Add(fPreprocessingCheckBox)
.AddGlue()
.Add(copyright2View)
.Add(copyright3View);
BFont font;
GetFont(&font);
SetExplicitPreferredSize(BSize((font.Size() * 250) / 12,
(font.Size() * 350) / 12));
}
示例4: name
//.........这里部分代码省略.........
fActiveWindow = new BCheckBox(B_TRANSLATE("Capture active window"),
new BMessage(kActiveWindow));
if (fGrabActiveWindow)
fActiveWindow->SetValue(B_CONTROL_ON);
fWindowBorder = new BCheckBox(B_TRANSLATE("Include window border"),
new BMessage(kIncludeBorder));
if (fIncludeBorder)
fWindowBorder->SetValue(B_CONTROL_ON);
if (!fGrabActiveWindow)
fWindowBorder->SetEnabled(false);
fShowCursor = new BCheckBox(B_TRANSLATE("Include mouse pointer"),
new BMessage(kIncludeCursor));
if (fIncludeCursor)
fShowCursor->SetValue(B_CONTROL_ON);
BString delay;
delay << fDelay / 1000000;
fDelayControl = new BTextControl("", B_TRANSLATE("Delay:"), delay.String(),
NULL);
_DisallowChar(fDelayControl->TextView());
fDelayControl->TextView()->SetAlignment(B_ALIGN_RIGHT);
BStringView* seconds = new BStringView("", B_TRANSLATE("seconds"));
seconds->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
BMenuField* menuLocation = new BMenuField(B_TRANSLATE("Save in:"),
fOutputPathMenu);
menuLocation->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
fTranslatorMenu = new BMenu(B_TRANSLATE("Please select"));
_SetupTranslatorMenu();
BMenuField* menuFormat = new BMenuField(B_TRANSLATE("Save as:"),
fTranslatorMenu);
menuFormat->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
BButton* showSettings = new BButton("",
B_TRANSLATE("Settings" B_UTF8_ELLIPSIS), new BMessage(kSettings));
showSettings->SetExplicitAlignment(
BAlignment(B_ALIGN_RIGHT, B_ALIGN_BOTTOM));
BBox* divider = new BBox(B_FANCY_BORDER, NULL);
divider->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1));
BButton* saveScreenshot = new BButton("", B_TRANSLATE("Save"),
new BMessage(kSaveScreenshot));
const float kSpacing = be_control_look->DefaultItemSpacing();
const float kLabelSpacing = be_control_look->DefaultLabelSpacing();
fPreview = new BView("preview", B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE);
BBox* previewBox = new BBox(B_FANCY_BORDER, fPreview);
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
.AddGroup(B_HORIZONTAL)
.SetInsets(B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING,
B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING)
.Add(previewBox)
.AddGroup(B_VERTICAL, 0)
.Add(fActiveWindow)
.Add(fWindowBorder)
.Add(fShowCursor)
.AddStrut(kSpacing)
.AddGrid(0.0, kSpacing / 2)
.Add(fDelayControl->CreateLabelLayoutItem(), 0, 0)
.Add(fDelayControl->CreateTextViewLayoutItem(), 1, 0)
.Add(BSpaceLayoutItem::CreateHorizontalStrut(kLabelSpacing),
2, 0)
.Add(seconds, 3, 0)
.Add(fNameControl->CreateLabelLayoutItem(), 0, 1)
.Add(fNameControl->CreateTextViewLayoutItem(), 1, 1, 3, 1)
.Add(menuLocation->CreateLabelLayoutItem(), 0, 2)
.Add(menuLocation->CreateMenuBarLayoutItem(), 1, 2, 3, 1)
.Add(menuFormat->CreateLabelLayoutItem(), 0, 3)
.Add(menuFormat->CreateMenuBarLayoutItem(), 1, 3, 3, 1)
.End()
.AddStrut(kSpacing / 2)
.Add(showSettings)
.AddGlue()
.End()
.End()
.Add(new BSeparatorView(B_HORIZONTAL))
.AddGroup(B_HORIZONTAL)
.SetInsets(B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING,
B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING)
.Add(new BButton("", B_TRANSLATE("Copy to clipboard"),
new BMessage(B_COPY)))
.Add(new BButton("", B_TRANSLATE("New screenshot"),
new BMessage(kNewScreenshot)))
.AddGlue()
.Add(saveScreenshot);
saveScreenshot->MakeDefault(true);
_UpdatePreviewPanel();
_UpdateFilenameSelection();
CenterOnScreen();
Show();
}
示例5: BMessage
ModifierKeysWindow::ModifierKeysWindow()
:
BWindow(BRect(0, 0, 360, 220), B_TRANSLATE("Modifier keys"),
B_FLOATING_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE
| B_AUTO_UPDATE_SIZE_LIMITS)
{
get_key_map(&fCurrentMap, &fCurrentBuffer);
get_key_map(&fSavedMap, &fSavedBuffer);
BStringView* keyRole = new BStringView("key role",
B_TRANSLATE_COMMENT("Role", "As in the role of a modifier key"));
keyRole->SetAlignment(B_ALIGN_RIGHT);
keyRole->SetFont(be_bold_font);
BStringView* keyLabel = new BStringView("key label",
B_TRANSLATE_COMMENT("Key", "As in a computer keyboard key"));
keyLabel->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
keyLabel->SetFont(be_bold_font);
BMenuField* shiftMenuField = _CreateShiftMenuField();
shiftMenuField->SetAlignment(B_ALIGN_RIGHT);
BMenuField* controlMenuField = _CreateControlMenuField();
controlMenuField->SetAlignment(B_ALIGN_RIGHT);
BMenuField* optionMenuField = _CreateOptionMenuField();
optionMenuField->SetAlignment(B_ALIGN_RIGHT);
BMenuField* commandMenuField = _CreateCommandMenuField();
commandMenuField->SetAlignment(B_ALIGN_RIGHT);
fShiftConflictView = new ConflictView("shift warning view");
fShiftConflictView->SetExplicitMaxSize(BSize(15, 15));
fControlConflictView = new ConflictView("control warning view");
fControlConflictView->SetExplicitMaxSize(BSize(15, 15));
fOptionConflictView = new ConflictView("option warning view");
fOptionConflictView->SetExplicitMaxSize(BSize(15, 15));
fCommandConflictView = new ConflictView("command warning view");
fCommandConflictView->SetExplicitMaxSize(BSize(15, 15));
fCancelButton = new BButton("cancelButton", B_TRANSLATE("Cancel"),
new BMessage(B_QUIT_REQUESTED));
fRevertButton = new BButton("revertButton", B_TRANSLATE("Revert"),
new BMessage(kMsgRevertModifiers));
fRevertButton->SetEnabled(false);
fOkButton = new BButton("okButton", B_TRANSLATE("Set modifier keys"),
new BMessage(kMsgApplyModifiers));
fOkButton->MakeDefault(true);
// Build the layout
SetLayout(new BGroupLayout(B_VERTICAL));
float forcedMinWidth = be_plain_font->StringWidth("XXX") * 4;
keyRole->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET));
BLayoutItem* shiftLabel = shiftMenuField->CreateLabelLayoutItem();
shiftLabel->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET));
BLayoutItem* controlLabel = controlMenuField->CreateLabelLayoutItem();
controlLabel->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET));
BLayoutItem* optionLabel = optionMenuField->CreateLabelLayoutItem();
optionLabel->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET));
BLayoutItem* commandLabel = commandMenuField->CreateLabelLayoutItem();
commandLabel->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET));
AddChild(BLayoutBuilder::Group<>(B_VERTICAL, B_USE_SMALL_SPACING)
.AddGroup(B_HORIZONTAL)
.Add(keyRole)
.Add(keyLabel)
.End()
.AddGroup(B_HORIZONTAL)
.Add(shiftLabel)
.Add(shiftMenuField->CreateMenuBarLayoutItem())
.Add(fShiftConflictView)
.End()
.AddGroup(B_HORIZONTAL)
.Add(controlLabel)
.Add(controlMenuField->CreateMenuBarLayoutItem())
.Add(fControlConflictView)
.End()
.AddGroup(B_HORIZONTAL)
.Add(optionLabel)
.Add(optionMenuField->CreateMenuBarLayoutItem())
.Add(fOptionConflictView)
.End()
.AddGroup(B_HORIZONTAL)
.Add(commandLabel)
.Add(commandMenuField->CreateMenuBarLayoutItem())
.Add(fCommandConflictView)
.End()
.AddGlue()
.AddGroup(B_HORIZONTAL)
.Add(fCancelButton)
.AddGlue()
.Add(fRevertButton)
.Add(fOkButton)
//.........这里部分代码省略.........
示例6: BMessage
void
AddPrinterDialog::_BuildGUI(int stage)
{
// add a "printer name" input field
fName = new BTextControl("printer_name", B_TRANSLATE("Printer name:"),
B_EMPTY_STRING, NULL);
fName->SetFont(be_bold_font);
fName->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
fName->SetModificationMessage(new BMessage(kNameChangedMsg));
// add a "driver" popup menu field
fPrinter = new BPopUpMenu(B_TRANSLATE("<pick one>"));
BMenuField *printerMenuField = new BMenuField("drivers_list",
B_TRANSLATE("Printer type:"), fPrinter);
printerMenuField->SetAlignment(B_ALIGN_RIGHT);
_FillMenu(fPrinter, "Print", kPrinterSelectedMsg);
// add a "connected to" (aka transports list) menu field
fTransport = new BPopUpMenu(B_TRANSLATE("<pick one>"));
BMenuField *transportMenuField = new BMenuField("transports_list",
B_TRANSLATE("Connected to:"), fTransport);
transportMenuField->SetAlignment(B_ALIGN_RIGHT);
_FillTransportMenu(fTransport);
// add a "OK" button
fOk = new BButton(NULL, B_TRANSLATE("Add"), new BMessage((uint32)B_OK),
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
// add a "Cancel button
BButton *cancel = new BButton(NULL, B_TRANSLATE("Cancel"),
new BMessage(B_CANCEL));
SetLayout(new BGridLayout());
AddChild(BGridLayoutBuilder(0, 4)
.Add(fName->CreateLabelLayoutItem(), 0, 0)
.Add(fName->CreateTextViewLayoutItem(), 1, 0)
.Add(printerMenuField->CreateLabelLayoutItem(), 0, 1)
.Add(printerMenuField->CreateMenuBarLayoutItem(), 1, 1)
.Add(transportMenuField->CreateLabelLayoutItem(), 0, 2)
.Add(transportMenuField->CreateMenuBarLayoutItem(), 1, 2)
.Add(BGroupLayoutBuilder(B_HORIZONTAL)
.AddGlue()
.Add(cancel)
.Add(fOk)
, 0, 3, 2)
.SetInsets(8, 8, 8, 8)
);
SetDefaultButton(fOk);
fOk->MakeDefault(true);
fName->MakeFocus(true);
_Update();
// Stage == 0
// init_icon 64x114 Add a Local or Network Printer
// ------------------------------
// I would like to add a...
// Local Printer
// Network Printer
// ------------------------------------------------
// Cancel Continue
// Add local printer:
// Stage == 1
// local_icon Add a Local Printer
// ------------------------------
// Printer Name: ________________
// Printer Type: pick one
// Connected to: pick one
// ------------------------------------------------
// Cancel Add
// This seems to be hard coded into the preferences dialog:
// Don't show Network transport add-on in Printer Type menu.
// If Printer Type == Preview disable Connect to popup menu.
// If Printer Type == Serial Port add a submenu to menu item
// with names in /dev/ports (if empty remove item from menu)
// If Printer Type == Parallel Port add a submenu to menu item
// with names in /dev/parallel (if empty remove item from menu)
// Printer Driver Setup
// Dialog Info
// Would you like to make X the default printer?
// No Yes
// Add network printer:
// Dialog Info
// Apple Talk networking isn't currenty enabled. If you
// wish to install a network printer you should enable
// AppleTalk in the Network preferences.
// Cancel Open Network
// Stage == 2
// network_icon Add a Network Printer
//.........这里部分代码省略.........
示例7: BMessage
//.........这里部分代码省略.........
fSpecialControl->SetModificationMessage(
new BMessage(kMsgAttributeUpdated));
fSpecialControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
fSpecialControl->SetEnabled(false);
char text[64];
snprintf(text, sizeof(text), "%ld", fAttribute.Width());
fWidthControl = new BTextControl(B_TRANSLATE_COMMENT("Width:",
"Default column width in Tracker for this attribute."),
text, NULL);
fWidthControl->SetModificationMessage(
new BMessage(kMsgAttributeUpdated));
fWidthControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
// filter out invalid characters that can't be part of a width
textView = fWidthControl->TextView();
for (int32 i = 0; i < 256; i++) {
if (!isdigit(i))
textView->DisallowChar(i);
}
textView->SetMaxBytes(4);
const struct alignment_map {
int32 alignment;
const char* name;
} kAlignmentMap[] = {
{B_ALIGN_LEFT, B_TRANSLATE_COMMENT("Left",
"Attribute column alignment in Tracker")},
{B_ALIGN_RIGHT, B_TRANSLATE_COMMENT("Right",
"Attribute column alignment in Tracker")},
{B_ALIGN_CENTER, B_TRANSLATE_COMMENT("Center",
"Attribute column alignment in Tracker")},
{0, NULL}
};
menu = new BPopUpMenu("alignment");
for (int32 i = 0; kAlignmentMap[i].name != NULL; i++) {
BMessage* message = new BMessage(kMsgAlignmentChosen);
message->AddInt32("alignment", kAlignmentMap[i].alignment);
item = new BMenuItem(kAlignmentMap[i].name, message);
menu->AddItem(item);
if (kAlignmentMap[i].alignment == fAttribute.Alignment())
item->SetMarked(true);
}
fAlignmentMenuField = new BMenuField("alignment",
B_TRANSLATE("Alignment:"), menu);
fAlignmentMenuField->SetAlignment(B_ALIGN_RIGHT);
fAcceptButton = new BButton("add",
item ? B_TRANSLATE("Done") : B_TRANSLATE("Add"),
new BMessage(kMsgAccept));
fAcceptButton->SetEnabled(false);
BButton* cancelButton = new BButton("cancel", B_TRANSLATE("Cancel"),
new BMessage(B_QUIT_REQUESTED));
BBox* visibleBox;
BLayoutBuilder::Group<>(this, B_VERTICAL, padding)
.SetInsets(padding, padding, padding, padding)
.AddGrid(padding, padding / 2)
.Add(fPublicNameControl->CreateLabelLayoutItem(), 0, 0)
.Add(fPublicNameControl->CreateTextViewLayoutItem(), 1, 0)
.Add(fAttributeControl->CreateLabelLayoutItem(), 0, 1)
.Add(fAttributeControl->CreateTextViewLayoutItem(), 1, 1)
.Add(typeMenuField->CreateLabelLayoutItem(), 0, 2)
.Add(typeMenuField->CreateMenuBarLayoutItem(), 1, 2)
.End()
.Add(visibleBox = new BBox(B_FANCY_BORDER,
BLayoutBuilder::Grid<>(padding, padding / 2)
.Add(fDisplayAsMenuField->CreateLabelLayoutItem(), 0, 0)
.Add(fDisplayAsMenuField->CreateMenuBarLayoutItem(), 1, 0)
.Add(fEditableCheckBox, 2, 0)
.Add(fSpecialControl->CreateLabelLayoutItem(), 0, 1)
.Add(fSpecialControl->CreateTextViewLayoutItem(), 1, 1, 2)
.Add(fWidthControl->CreateLabelLayoutItem(), 0, 2)
.Add(fWidthControl->CreateTextViewLayoutItem(), 1, 2, 2)
.Add(fAlignmentMenuField->CreateLabelLayoutItem(), 0, 3)
.Add(fAlignmentMenuField->CreateMenuBarLayoutItem(), 1, 3, 2)
.SetInsets(padding, padding, padding, padding)
.View())
)
.AddGroup(B_HORIZONTAL, padding)
.Add(BSpaceLayoutItem::CreateGlue())
.Add(cancelButton)
.Add(fAcceptButton);
visibleBox->SetLabel(fVisibleCheckBox);
fAcceptButton->MakeDefault(true);
fPublicNameControl->MakeFocus(true);
target->PlaceSubWindow(this);
AddToSubset(target);
_CheckDisplayAs();
_CheckAcceptable();
}
示例8: PageView
/**
* _ConstructGUI()
*
* Creates the GUI for the View. MUST be called AFTER the View is attached to
* the Window, or will crash and/or create strange behaviour
*
* @param none
* @return void
*/
void
MarginView::_ConstructGUI()
{
fPage = new PageView();
fPage->SetViewColor(ViewColor());
fPageSize = new BStringView("pageSize", "?x?");
BString str;
// Create text fields
// top
str << fMargins.top/fUnitValue;
fTop = new BTextControl("top", "Top:", str.String(), NULL);
fTop->SetModificationMessage(new BMessage(TOP_MARGIN_CHANGED));
fTop->SetTarget(this);
_AllowOnlyNumbers(fTop, kNumCount);
//left
str = "";
str << fMargins.left/fUnitValue;
fLeft = new BTextControl("left", "Left:", str.String(), NULL);
fLeft->SetModificationMessage(new BMessage(LEFT_MARGIN_CHANGED));
fLeft->SetTarget(this);
_AllowOnlyNumbers(fLeft, kNumCount);
//bottom
str = "";
str << fMargins.bottom/fUnitValue;
fBottom = new BTextControl("bottom", "Bottom:", str.String(), NULL);
fBottom->SetModificationMessage(new BMessage(BOTTOM_MARGIN_CHANGED));
fBottom->SetTarget(this);
_AllowOnlyNumbers(fBottom, kNumCount);
//right
str = "";
str << fMargins.right/fUnitValue;
fRight = new BTextControl("right", "Right:", str.String(), NULL);
fRight->SetModificationMessage(new BMessage(RIGHT_MARGIN_CHANGED));
fRight->SetTarget(this);
_AllowOnlyNumbers(fRight, kNumCount);
// Create Units popup
BPopUpMenu *menu = new BPopUpMenu("units");
BMenuField *units = new BMenuField("units", "Units:", menu);
BMenuItem *item;
// Construct menu items
for (int32 i = 0; kUnitNames[i] != NULL; i++) {
BMessage *msg = new BMessage(MARGIN_UNIT_CHANGED);
msg->AddInt32("marginUnit", kUnitMsg[i]);
menu->AddItem(item = new BMenuItem(kUnitNames[i], msg));
item->SetTarget(this);
if (fMarginUnit == kUnitMsg[i])
item->SetMarked(true);
}
BGridView* settings = new BGridView();
BGridLayout* settingsLayout = settings->GridLayout();
settingsLayout->AddItem(fTop->CreateLabelLayoutItem(), 0, 0);
settingsLayout->AddItem(fTop->CreateTextViewLayoutItem(), 1, 0);
settingsLayout->AddItem(fLeft->CreateLabelLayoutItem(), 0, 1);
settingsLayout->AddItem(fLeft->CreateTextViewLayoutItem(), 1, 1);
settingsLayout->AddItem(fBottom->CreateLabelLayoutItem(), 0, 2);
settingsLayout->AddItem(fBottom->CreateTextViewLayoutItem(), 1, 2);
settingsLayout->AddItem(fRight->CreateLabelLayoutItem(), 0, 3);
settingsLayout->AddItem(fRight->CreateTextViewLayoutItem(), 1, 3);
settingsLayout->AddItem(units->CreateLabelLayoutItem(), 0, 4);
settingsLayout->AddItem(units->CreateMenuBarLayoutItem(), 1, 4);
settingsLayout->SetSpacing(0, 0);
BGroupView* groupView = new BGroupView(B_HORIZONTAL, 10);
BGroupLayout* groupLayout = groupView->GroupLayout();
groupLayout->AddView(BGroupLayoutBuilder(B_VERTICAL, 0)
.Add(fPage)
.Add(fPageSize)
.SetInsets(0, 0, 0, 0)
.TopView()
);
groupLayout->AddView(settings);
groupLayout->SetInsets(5, 5, 5, 5);
AddChild(groupView);
UpdateView(MARGIN_CHANGED);
}