本文整理汇总了C++中BMenuField::Bounds方法的典型用法代码示例。如果您正苦于以下问题:C++ BMenuField::Bounds方法的具体用法?C++ BMenuField::Bounds怎么用?C++ BMenuField::Bounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BMenuField
的用法示例。
在下文中一共展示了BMenuField::Bounds方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MenuTask
//------------------------------------------------------------------------------
long BMenuField::MenuTask(void *arg)
{
BMenuField *menuField = (BMenuField*)arg;
if (!menuField->LockLooper())
return 0;
menuField->fSelected = true;
menuField->fTransition = true;
menuField->Draw(menuField->Bounds());
menuField->UnlockLooper();
bool tracking;
do
{
snooze(20000);
if (!menuField->LockLooper())
return 0;
tracking = menuField->fMenuBar->fTracking;
menuField->UnlockLooper();
} while (tracking);
if (!menuField->LockLooper())
return 0;
menuField->fSelected = false;
menuField->fTransition = true;
menuField->Draw(menuField->Bounds());
menuField->UnlockLooper();
return 0;
}
示例2: BMessage
BooleanEditor::BooleanEditor(BRect rect, DataEditor &editor)
: TypeEditorView(rect, B_TRANSLATE("Boolean editor"), B_FOLLOW_NONE, 0, editor)
{
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
BPopUpMenu *menu = new BPopUpMenu("bool");
BMessage *message;
menu->AddItem(fFalseMenuItem = new BMenuItem("false",
new BMessage(kMsgValueChanged)));
menu->AddItem(fTrueMenuItem = new BMenuItem("true",
message = new BMessage(kMsgValueChanged)));
message->AddInt8("value", 1);
BMenuField *menuField = new BMenuField(rect.InsetByCopy(5, 5),
B_EMPTY_STRING, B_TRANSLATE("Boolean value:"), menu, B_FOLLOW_LEFT_RIGHT);
menuField->SetDivider(StringWidth(menuField->Label()) + 8);
menuField->ResizeToPreferred();
ResizeTo(menuField->Bounds().Width() + 10,
menuField->Bounds().Height() + 10);
_UpdateMenuField();
AddChild(menuField);
}
示例3: bounds
void
DocInfoWindow::_SetupDocInfoView(BBox* panel)
{
BRect bounds(panel->Bounds());
#if HAVE_FULLVERSION_PDF_LIB
bounds.InsetBy(10.0, 10.0);
#endif
// add list of keys
fKeyList = new BMenu("Delete Key");
BMenuField *menu = new BMenuField(bounds, "delete", "", fKeyList,
B_FOLLOW_BOTTOM);
panel->AddChild(menu);
menu->SetDivider(0);
#ifdef __HAIKU__
menu->ResizeToPreferred();
menu->MoveTo(bounds.left, bounds.bottom - menu->Bounds().Height());
#else
menu->ResizeTo(menu->StringWidth("Delete Key") + 15.0, 25.0);
menu->MoveTo(bounds.left, bounds.bottom - 25.0);
#endif
const char* title[6] = { "Title", "Author", "Subject", "Keywords", "Creator",
NULL }; // PDFlib sets these: "Producer", "CreationDate", not "ModDate"
BMenu* defaultKeys = new BMenu("Default Keys");
for (int32 i = 0; title[i] != NULL; ++i)
defaultKeys->AddItem(new BMenuItem(title[i], new BMessage(DEFAULT_KEY_MSG)));
BRect frame(menu->Frame());
menu = new BMenuField(frame, "add", "", defaultKeys, B_FOLLOW_BOTTOM);
panel->AddChild(menu);
menu->SetDivider(0);
#ifdef __HAIKU__
menu->ResizeToPreferred();
menu->MoveBy(frame.Width() + 10.0, 0.0);
#else
menu->ResizeTo(menu->StringWidth("Default Keys") + 15.0, 25.0);
menu->MoveBy(menu->Bounds().Width() + 10.0, 0.0);
#endif
frame = menu->Frame();
frame.left = frame.right + 10.0;
frame.right = bounds.right;
BTextControl *add = new BTextControl(frame, "add", "Add Key:", "",
new BMessage(ADD_KEY_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM);
panel->AddChild(add);
float width, height;
add->GetPreferredSize(&width, &height);
add->ResizeTo(bounds.right - frame.left, height);
add->SetDivider(be_plain_font->StringWidth("Add Key: "));
bounds.bottom = frame.top - 10.0;
bounds.right -= B_V_SCROLL_BAR_WIDTH;
bounds.InsetBy(2.0, 2.0);
fTable = new BView(bounds, "table", B_FOLLOW_ALL, B_WILL_DRAW);
fTable->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
fTableScrollView = new BScrollView("scroll_table", fTable, B_FOLLOW_ALL, 0,
false, true);
panel->AddChild(fTableScrollView);
BMessage docInfo;
fDocInfo->FindMessage("doc_info", &docInfo);
// fill table
_BuildTable(docInfo);
}
示例4: BMessage
AttributeWindow::AttributeWindow(FileTypesWindow* target, BMimeType& mimeType,
AttributeItem* attributeItem)
: BWindow(BRect(100, 100, 350, 200), "Attribute", B_MODAL_WINDOW_LOOK,
B_MODAL_SUBSET_WINDOW_FEEL, B_NOT_ZOOMABLE | B_NOT_V_RESIZABLE
| B_ASYNCHRONOUS_CONTROLS),
fTarget(target),
fMimeType(mimeType.Type())
{
if (attributeItem != NULL)
fAttribute = *attributeItem;
BRect rect = Bounds();
BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(topView);
rect.InsetBy(8.0f, 8.0f);
fPublicNameControl = new BTextControl(rect, "public", "Attribute name:",
fAttribute.PublicName(), NULL, B_FOLLOW_LEFT_RIGHT);
fPublicNameControl->SetModificationMessage(new BMessage(kMsgAttributeUpdated));
float labelWidth = fPublicNameControl->StringWidth(fPublicNameControl->Label()) + 2.0f;
fPublicNameControl->SetDivider(labelWidth);
fPublicNameControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
float width, height;
fPublicNameControl->GetPreferredSize(&width, &height);
fPublicNameControl->ResizeTo(rect.Width(), height);
topView->AddChild(fPublicNameControl);
rect = fPublicNameControl->Frame();
rect.OffsetBy(0.0f, rect.Height() + 5.0f);
fAttributeControl = new BTextControl(rect, "internal", "Internal name:",
fAttribute.Name(), NULL, B_FOLLOW_LEFT_RIGHT);
fAttributeControl->SetModificationMessage(new BMessage(kMsgAttributeUpdated));
fAttributeControl->SetDivider(labelWidth);
fAttributeControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
// filter out invalid characters that can't be part of an attribute
BTextView* textView = fAttributeControl->TextView();
const char* disallowedCharacters = "/";
for (int32 i = 0; disallowedCharacters[i]; i++) {
textView->DisallowChar(disallowedCharacters[i]);
}
topView->AddChild(fAttributeControl);
fTypeMenu = new BPopUpMenu("type");
BMenuItem* item = NULL;
for (int32 i = 0; kTypeMap[i].name != NULL; i++) {
BMessage* message = new BMessage(kMsgTypeChosen);
message->AddInt32("type", kTypeMap[i].type);
item = new BMenuItem(kTypeMap[i].name, message);
fTypeMenu->AddItem(item);
if (kTypeMap[i].type == fAttribute.Type())
item->SetMarked(true);
}
rect.OffsetBy(0.0f, rect.Height() + 4.0f);
BMenuField* menuField = new BMenuField(rect, "types",
"Type:", fTypeMenu);
menuField->SetDivider(labelWidth);
menuField->SetAlignment(B_ALIGN_RIGHT);
menuField->GetPreferredSize(&width, &height);
menuField->ResizeTo(rect.Width(), height);
topView->AddChild(menuField);
rect.OffsetBy(0.0f, rect.Height() + 4.0f);
rect.bottom = rect.top + fAttributeControl->Bounds().Height() * 2.0f + 18.0f;
BBox* box = new BBox(rect, "", B_FOLLOW_LEFT_RIGHT);
topView->AddChild(box);
fVisibleCheckBox = new BCheckBox(rect, "visible", "Visible",
new BMessage(kMsgVisibilityChanged));
fVisibleCheckBox->SetValue(fAttribute.Visible());
fVisibleCheckBox->ResizeToPreferred();
box->SetLabel(fVisibleCheckBox);
labelWidth -= 8.0f;
BMenu* menu = new BPopUpMenu("display as");
for (int32 i = 0; kDisplayAsMap[i].name != NULL; i++) {
BMessage* message = new BMessage(kMsgDisplayAsChosen);
if (kDisplayAsMap[i].identifier != NULL) {
message->AddString("identifier", kDisplayAsMap[i].identifier);
for (int32 j = 0; kDisplayAsMap[i].supported[j]; j++) {
message->AddInt32("supports", kDisplayAsMap[i].supported[j]);
}
}
item = new BMenuItem(kDisplayAsMap[i].name, message);
menu->AddItem(item);
if (compare_display_as(kDisplayAsMap[i].identifier, fAttribute.DisplayAs()))
item->SetMarked(true);
}
rect.OffsetTo(8.0f, fVisibleCheckBox->Bounds().Height());
//.........这里部分代码省略.........