本文整理汇总了C++中BPopUpMenu类的典型用法代码示例。如果您正苦于以下问题:C++ BPopUpMenu类的具体用法?C++ BPopUpMenu怎么用?C++ BPopUpMenu使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BPopUpMenu类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BPopUpMenu
BPopUpMenu* AmTrackInfoView::NewPropertiesMenu() const
{
BPopUpMenu* menu = new BPopUpMenu( "properties menu" );
if( !menu ) return 0;
BMenuItem* item;
/* The Duplicate menu item.
*/
BMessage* msg = new BMessage( DUPLICATE_INFO_MSG );
if( msg && (item = new BMenuItem( "Duplicate", msg )) ) {
msg->AddPointer( SZ_VIEW_ID, this );
msg->AddString( SZ_FACTORY_SIGNATURE, mFactorySignature.String() );
msg->AddString( SZ_FACTORY_VIEW_NAME, mViewName.String() );
menu->AddItem( item );
}
/* The Change View menu item.
*/
if( (item = NewChangeViewItem()) ) menu->AddItem( item );
/* The Remove menu item.
*/
msg = new BMessage( REMOVE_INFO_MSG );
if( msg && (item = new BMenuItem( "Remove", msg )) ) {
msg->AddPointer( SZ_VIEW_ID, this );
menu->AddItem( item );
}
return menu;
}
示例2: NewPropertiesMenu
BPopUpMenu* AmControlChangeInfoView::NewPropertiesMenu() const
{
BPopUpMenu* menu = inherited::NewPropertiesMenu();
if (!menu) return menu;
mCachedControlMenu = NewControlMenu();
if (!mCachedControlMenu) return menu;
BMenuItem* item;
if (mCachedControlMenu->CountItems() < 1 ) {
item = new _AmActiveControlItem( "<track has no output filter>", new BMessage('null') );
if (item) {
item->SetEnabled( false );
mCachedControlMenu->AddItem(item);
}
}
item = new BMenuItem(mCachedControlMenu);
if (!item) {
delete mCachedControlMenu;
mCachedControlMenu = NULL;
return menu;
}
menu->AddSeparatorItem();
menu->AddItem(item);
return menu;
}
示例3: BPopUpMenu
void
Panel::RunControlMenu(BPoint where)
{
BPopUpMenu *qMenu = new BPopUpMenu("env sel", true, FALSE);
BPoint orig = where;
ConvertToScreen(&where);
BMessage *msg;
BMenuItem *item;
if (displayMode != PANEL_DISPLAY_SMALL) {
msg = new BMessage(SET_DISPLAY_MODE);
msg->AddInt32("display mode", PANEL_DISPLAY_SMALL);
item = new BMenuItem("Close", msg);
qMenu->AddItem(item);
item->SetTarget(this);
}
if (displayMode != PANEL_DISPLAY_BIG) {
msg = new BMessage(SET_DISPLAY_MODE);
msg->AddInt32("display mode", PANEL_DISPLAY_BIG);
item = new BMenuItem("Open", msg);
qMenu->AddItem(item);
item->SetTarget(this);
}
qMenu->SetAsyncAutoDestruct(true);
qMenu->Go(where, true, false, true);
}
示例4: BPopUpMenu
BPopUpMenu *TPrefsWindow::BuildFontMenu(BFont *font)
{
char label[512];
int32 family_count;
int32 family_loop;
int32 style_count;
int32 style_loop;
BMenuItem *item;
BMessage *msg;
BPopUpMenu *menu;
font_family def_family;
font_family f_family;
font_style def_style;
font_style f_style;
menu = new BPopUpMenu("");
font->GetFamilyAndStyle(&def_family, &def_style);
family_count = count_font_families();
for (family_loop = 0; family_loop < family_count; family_loop++) {
get_font_family(family_loop, &f_family);
style_count = count_font_styles(f_family);
for (style_loop = 0; style_loop < style_count; style_loop++) {
get_font_style(f_family, style_loop, &f_style);
msg = new BMessage(P_FONT);
msg->AddString("font", f_family);
msg->AddString("style", f_style);
sprintf(label, "%s %s", f_family, f_style);
menu->AddItem(item = new BMenuItem(label, msg));
if ((!strcmp(def_family, f_family)) && (!strcmp(def_style, f_style)))
item->SetMarked(true);
item->SetTarget(this);
}
}
return menu;
}
示例5: BView
ConfigView::ConfigView()
: BView(BRect(0,0,10,10),"notifier_config",B_FOLLOW_LEFT | B_FOLLOW_TOP,0)
{
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
// determine font height
font_height fontHeight;
GetFontHeight(&fontHeight);
float itemHeight = (int32)(fontHeight.ascent + fontHeight.descent + fontHeight.leading) + 6;
BRect frame(5,2,250,itemHeight + 2);
BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING,false,false);
const char *notifyMethods[] = {
MDR_DIALECT_CHOICE ("Beep","音"),
MDR_DIALECT_CHOICE ("Alert","窓(メール毎)"),
MDR_DIALECT_CHOICE ("Keyboard LEDs","キーボードLED"),
MDR_DIALECT_CHOICE ("Central alert","窓(一括)"),
"Central beep","Log window"};
for (int32 i = 0,j = 1;i < 6;i++,j *= 2)
menu->AddItem(new BMenuItem(notifyMethods[i],new BMessage(kMsgNotifyMethod)));
BMenuField *field = new BMenuField(frame,"notify",
MDR_DIALECT_CHOICE ("Method:","方法:"),menu);
field->ResizeToPreferred();
field->SetDivider(field->StringWidth(
MDR_DIALECT_CHOICE ("Method:","方法:")) + 6);
AddChild(field);
ResizeToPreferred();
}
示例6: BPopUpMenu
BPopUpMenu*
TPrefsWindow::_BuildButtonBarMenu(uint8 show)
{
BMenuItem* item;
BMessage* msg;
BPopUpMenu* menu = new BPopUpMenu("");
msg = new BMessage(P_BUTTON_BAR);
msg->AddInt8("bar", kShowToolBar);
menu->AddItem(item = new BMenuItem(
B_TRANSLATE("Show icons & labels"), msg));
if (show & 1)
item->SetMarked(true);
msg = new BMessage(P_BUTTON_BAR);
msg->AddInt8("bar", kShowToolBarIconsOnly);
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Show icons only"), msg));
if (show & 2)
item->SetMarked(true);
msg = new BMessage(P_BUTTON_BAR);
msg->AddInt8("bar", kHideToolBar);
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Hide"), msg));
if (!show)
item->SetMarked(true);
return menu;
}
示例7: ResizeBy
void SplitWindow::AddCat()
{
ResizeBy(0, 25);
uint16 xpos = 20;
uint16 width = 150;
BTextControl* tc = new BTextControl(BRect(xpos - 5, ypos + 10,
xpos + width, ypos + 10), "CatField", "", "", 0);
xpos += width;
tc->SetDivider(0);
catTexts.push_back(tc);
v->AddChild(tc);
BPopUpMenu* pu = new BPopUpMenu("", true, false);
BMenuField* mf = new BMenuField(BRect(xpos + 2, ypos + 9,
xpos + 2, ypos + 9), "CatMenu", "", pu);
mf->SetDivider(0);
v->AddChild(mf);
xpos += 30;
tc = new BTextControl(BRect(xpos - 5, ypos + 10,
xpos + 75, ypos + 10), "AmountField", "", "", 0);
tc->SetDivider(0);
tc->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT);
tc->SetModificationMessage(new BMessage(AmountModifiedMSG));
amtTexts.push_back(tc);
v->AddChild(tc);
ypos += 25;
for (cas::iterator ci = catS->begin(); ci != catS->end(); ci++)
{
if ((*ci)->IsRoot())
{
pu->AddItem(MakeCatMenu(*ci));
}
}
catnum++;
}
示例8: BPopUpMenu
BPopUpMenu*
DefaultPartitionPage::_CreatePopUpMenu()
{
int32 defaultPartitionIndex;
fSettings->FindInt32("defaultPartition", &defaultPartitionIndex);
BMenuItem* selectedItem = NULL;
int32 selectedItemIndex = 0;
BPopUpMenu* menu = new BPopUpMenu(B_TRANSLATE_COMMENT("Partitions",
"Pop up menu title"));
BMessage message;
for (int32 i = 0; fSettings->FindMessage("partition", i, &message) == B_OK;
i++) {
bool show;
if (message.FindBool("show", &show) != B_OK || !show)
continue;
BString name;
message.FindString("name", &name);
BMessage* msg = new BMessage(kMsgPartition);
msg->AddInt32("index", i);
BMenuItem* item = new BMenuItem(name.String(), msg);
menu->AddItem(item);
if (defaultPartitionIndex == i || selectedItem == NULL) {
selectedItem = item;
selectedItemIndex = i;
}
}
fSettings->ReplaceInt32("defaultPartition", selectedItemIndex);
selectedItem->SetMarked(true);
return menu;
}
示例9: BPopUpMenu
/*static*/ BPopUpMenu*
AppearancePrefView::_MakeMenu(uint32 msg, const char** items,
const char* defaultItemName)
{
BPopUpMenu* menu = new BPopUpMenu("");
int32 i = 0;
while (*items) {
if (!strcmp((*items), ""))
menu->AddSeparatorItem();
else {
BMessage* message = new BMessage(msg);
menu->AddItem(new BMenuItem((*items), message));
}
items++;
i++;
}
BMenuItem* defaultItem = menu->FindItem(defaultItemName);
if (defaultItem)
defaultItem->SetMarked(true);
return menu;
}
示例10: process_refs
extern "C" void
process_refs(entry_ref dir, BMessage* message, void* /*reserved*/)
{
BPopUpMenu* menu = new BPopUpMenu("status");
retrieve_status_items(menu);
BMenuItem* item = menu->Go(mouse_position() - BPoint(5, 5), false, true);
if (item == NULL)
return;
BString status = item->Label();
entry_ref ref;
for (int i = 0; message->FindRef("refs", i, &ref) == B_OK; i++) {
BNode node(&ref);
BString type;
if (node.InitCheck() == B_OK
&& node.ReadAttrString("BEOS:TYPE", &type) == B_OK
&& type == "text/x-email") {
BString previousStatus;
// Only update the attribute if there is an actual change
if (node.ReadAttrString("MAIL:status", &previousStatus) != B_OK
|| previousStatus != status)
node.WriteAttrString("MAIL:status", &status);
}
}
}
示例11: BPopUpMenu
int GSubMenu::Float(GView *Parent, int x, int y, bool Left)
{
if (Info)
{
BPopUpMenu *Popup = new BPopUpMenu("PopUpMenu");
if (Popup)
{
_CopyMenu(Popup, this);
BPoint Pt(x, y);
BMenuItem *Item = Popup->Go(Pt);
if (Item)
{
#undef Message
BMessage *Msg = Item->Message();
int32 i;
if (Msg && Msg->FindInt32("Cmd", &i) == B_OK)
{
return i;
}
}
}
}
return 0;
}
示例12: BPopUpMenu
BPopUpMenu*
TPrefsWindow::_BuildAccountMenu(uint32 account)
{
BPopUpMenu* menu = new BPopUpMenu("");
BMenuItem* item;
//menu->SetRadioMode(true);
BList chains;
if (GetOutboundMailChains(&chains) < B_OK) {
menu->AddItem(item = new BMenuItem("<no account found>", NULL));
item->SetEnabled(false);
return menu;
}
BMessage* msg;
for (int32 i = 0; i < chains.CountItems(); i++) {
BMailChain* chain = (BMailChain*)chains.ItemAt(i);
item = new BMenuItem(chain->Name(), msg = new BMessage(P_ACCOUNT));
msg->AddInt32("id",chain->ID());
if (account == chain->ID())
item->SetMarked(true);
menu->AddItem(item);
delete chain;
}
return menu;
}
示例13: BPopUpMenu
BPopUpMenu*
MenuBuilder::_BuildPopUpMenu(KeyBind* bind, BView* target)
{
if (bind == NULL)
return NULL;
// The first item describe the menu
BPopUpMenu* menu = new BPopUpMenu(bind[0].label);
BObjectList<BPopUpMenu> menuList(false);
menuList.AddItem(menu);
for (int i = 1; bind[i].message != FABER_EOF; i++) {
menu = menuList.ItemAt(menuList.CountItems()-1);
if (bind[i].message == FABER_ITEM_START) {
BPopUpMenu* subMenu = new BPopUpMenu(bind[i].label);
menu->AddItem(subMenu);
menuList.AddItem(subMenu);
} else if (bind[i].message == FABER_ITEM_END) {
if (menuList.CountItems() > 1)
menuList.RemoveItemAt(menuList.CountItems()-1);
} else {
BMenuItem* item = _BuildMenuItem(bind[i].message, bind[i].label);
if (target != NULL)
item->SetTarget(target);
menu->AddItem(item);
}
}
return menuList.ItemAt(0);
}
示例14: Window
void
StatusView::MouseDown(BPoint where)
{
if (!fReadOnly)
return;
float left = fCellWidth[kPositionCell] + fCellWidth[kEncodingCell];
if (where.x < left)
return;
int32 clicks = 0;
BMessage* message = Window()->CurrentMessage();
if (message != NULL
&& message->FindInt32("clicks", &clicks) == B_OK && clicks > 1)
return;
BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING, false, false);
menu->AddItem(new BMenuItem(B_TRANSLATE("Unlock file"),
new BMessage(UNLOCK_FILE)));
where.x = left;
where.y = Bounds().bottom;
ConvertToScreen(&where);
menu->SetTargetForItems(this);
menu->Go(where, true, true, true);
}
示例15: BView
ExpMixerUI::ExpMixerUI(BRect frame, const char *name, ExpMix *mix)
: BView(frame, name, B_FOLLOW_ALL, B_WILL_DRAW)
{
BMessage *msg;
BRect rect;
// build a BStringView
rect.Set(5.0,5.0, frame.Width()/2.0, 20.0);
AddChild(new BStringView(rect, "string", "Background:"));
// build our radio buttons
// source 1
rect.Set(rect.left, rect.bottom + 5.0, rect.right, rect.bottom + 20.0);
msg = new BMessage(EM_SET_BACKGROUND);
msg->AddInt32("which", 0);
AddChild(radio1 = new BRadioButton(rect, "radio1", "Source 1", msg));
// source 2
rect.Set(rect.left, rect.bottom + 5.0, rect.right, rect.bottom + 20.0);
msg = new BMessage(EM_SET_BACKGROUND);
msg->AddInt32("which", 1);
AddChild(radio2 = new BRadioButton(rect, "radio2", "Source 2", msg));
// turn radio1 on
radio1->SetValue(1);
// build our op menu
BPopUpMenu *menu = new BPopUpMenu("op menu");
// add op
msg = new BMessage(EM_SET_OP);
msg->AddInt32("which", 0);
menu->AddItem(new BMenuItem("add", msg));
// sub op
msg = new BMessage(EM_SET_OP);
msg->AddInt32("which", 1);
menu->AddItem(new BMenuItem("sub", msg));
// max op
msg = new BMessage(EM_SET_OP);
msg->AddInt32("which", 2);
menu->AddItem(new BMenuItem("max", msg));
// min op
msg = new BMessage(EM_SET_OP);
msg->AddInt32("which", 3);
menu->AddItem(new BMenuItem("min", msg));
// now add it to a menu field
rect.Set(frame.Width()/2. + 20., 25., frame.Width() - 10., 50.);
AddChild(opMenu = new BMenuField(rect, "menu", "Op: ", menu));
// cache our initial width and height
width = frame.Width();
height = frame.Height();
// background defaults to 0 (source 1)
backWhich = 0;
// know thy mixer
theMixer = mix;
// set the view color
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
}