本文整理汇总了C++中BPopUpMenu::AddItem方法的典型用法代码示例。如果您正苦于以下问题:C++ BPopUpMenu::AddItem方法的具体用法?C++ BPopUpMenu::AddItem怎么用?C++ BPopUpMenu::AddItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BPopUpMenu
的用法示例。
在下文中一共展示了BPopUpMenu::AddItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showContextMenu
void MediaJack::showContextMenu(
BPoint point)
{
D_METHOD(("MediaJack::showContextMenu()\n"));
BPopUpMenu *menu = new BPopUpMenu("MediaJack PopUp", false, false, B_ITEMS_IN_COLUMN);
menu->SetFont(be_plain_font);
BMenuItem *item;
// add the "Get Info" item
if (isInput())
{
media_input input;
getInput(&input);
BMessage *message = new BMessage(InfoWindowManager::M_INFO_WINDOW_REQUESTED);
message->AddData("input", B_RAW_TYPE,
reinterpret_cast<const void *>(&input), sizeof(input));
menu->AddItem(item = new BMenuItem("Get info", message));
}
else if (isOutput())
{
media_output output;
getOutput(&output);
BMessage *message = new BMessage(InfoWindowManager::M_INFO_WINDOW_REQUESTED);
message->AddData("output", B_RAW_TYPE,
reinterpret_cast<const void *>(&output), sizeof(output));
menu->AddItem(item = new BMenuItem("Get info", message));
}
menu->SetTargetForItems(view());
view()->ConvertToScreen(&point);
point -= BPoint(1.0, 1.0);
menu->Go(point, true, true, true);
}
示例2: BMessage
//! Track the mouse without blocking the window
void
CPUButton::MouseDown(BPoint point)
{
BPoint mousePosition;
uint32 mouseButtons;
GetMouse(&mousePosition, &mouseButtons);
if ((B_PRIMARY_MOUSE_BUTTON & mouseButtons) != 0) {
SetValue(!Value());
SetTracking(true);
SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
} else if ((B_SECONDARY_MOUSE_BUTTON & mouseButtons) != 0
&& fReplicantInDeskbar) {
BPopUpMenu *menu = new BPopUpMenu(B_TRANSLATE("Deskbar menu"));
menu->AddItem(new BMenuItem(B_TRANSLATE("About Pulse" B_UTF8_ELLIPSIS),
new BMessage(B_ABOUT_REQUESTED)));
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem(B_TRANSLATE("Remove replicant"),
new BMessage(kDeleteReplicant)));
menu->SetTargetForItems(this);
ConvertToScreen(&point);
menu->Go(point, true, true, true);
}
}
示例3: 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;
}
示例4: 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;
}
示例5: BMessage
void
TTimeView::ShowTimeOptions(BPoint point)
{
BPopUpMenu* menu = new BPopUpMenu("", false, false);
menu->SetFont(be_plain_font);
BMenuItem* item;
item = new BMenuItem(B_TRANSLATE("Time preferences" B_UTF8_ELLIPSIS),
new BMessage(kChangeTime));
menu->AddItem(item);
item = new BMenuItem(B_TRANSLATE("Hide time"),
new BMessage(kShowHideTime));
menu->AddItem(item);
item = new BMenuItem(B_TRANSLATE("Show calendar" B_UTF8_ELLIPSIS),
new BMessage(kShowCalendar));
menu->AddItem(item);
menu->SetTargetForItems(this);
// Changed to accept screen coord system point;
// not constrained to this view now
menu->Go(point, true, true, BRect(point.x - 4, point.y - 4,
point.x + 4, point.y +4), true);
}
示例6: 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);
}
示例7: 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;
}
示例8: 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);
}
示例9: BPopUpMenu
void
MidiPlayerWindow::CreateReverbMenu()
{
BPopUpMenu* reverbPopUp = new BPopUpMenu("reverbPopUp");
reverbNone = new BMenuItem(
B_TRANSLATE("None"), new BMessage(MSG_REVERB_NONE));
reverbCloset = new BMenuItem(
B_TRANSLATE("Closet"), new BMessage(MSG_REVERB_CLOSET));
reverbGarage = new BMenuItem(
B_TRANSLATE("Garage"), new BMessage(MSG_REVERB_GARAGE));
reverbIgor = new BMenuItem(
B_TRANSLATE("Igor's lab"), new BMessage(MSG_REVERB_IGOR));
reverbCavern = new BMenuItem(
B_TRANSLATE("Cavern"), new BMessage(MSG_REVERB_CAVERN));
reverbDungeon = new BMenuItem(
B_TRANSLATE("Dungeon"), new BMessage(MSG_REVERB_DUNGEON));
reverbPopUp->AddItem(reverbNone);
reverbPopUp->AddItem(reverbCloset);
reverbPopUp->AddItem(reverbGarage);
reverbPopUp->AddItem(reverbIgor);
reverbPopUp->AddItem(reverbCavern);
reverbPopUp->AddItem(reverbDungeon);
reverbMenu = new BMenuField(B_TRANSLATE("Reverb:"), reverbPopUp);
}
示例10: mouseRect
// ShowContextMenu
bool
PathManipulator::ShowContextMenu(BPoint where)
{
// Change the selection to the current point if it isn't currently
// selected. This could will only be chosen if the user right-clicked
// a path point directly.
if (fCurrentPathPoint >= 0 && !fSelection->Contains(fCurrentPathPoint)) {
fSelection->MakeEmpty();
_UpdateSelection();
*fOldSelection = *fSelection;
_Select(fCurrentPathPoint, false);
}
BPopUpMenu* menu = new BPopUpMenu("context menu", false, false);
BMessage* message;
BMenuItem* item;
bool hasSelection = fSelection->CountItems() > 0;
if (fCurrentPathPoint < 0) {
message = new BMessage(B_SELECT_ALL);
item = new BMenuItem("Select All", message, 'A');
menu->AddItem(item);
menu->AddSeparatorItem();
}
message = new BMessage(MSG_TRANSFORM);
item = new BMenuItem("Transform", message, 'T');
item->SetEnabled(hasSelection);
menu->AddItem(item);
message = new BMessage(MSG_SPLIT_POINTS);
item = new BMenuItem("Split", message);
item->SetEnabled(hasSelection);
menu->AddItem(item);
message = new BMessage(MSG_FLIP_POINTS);
item = new BMenuItem("Flip", message);
item->SetEnabled(hasSelection);
menu->AddItem(item);
message = new BMessage(MSG_REMOVE_POINTS);
item = new BMenuItem("Remove", message);
item->SetEnabled(hasSelection);
menu->AddItem(item);
// go
menu->SetTargetForItems(fCanvasView);
menu->SetAsyncAutoDestruct(true);
menu->SetFont(be_plain_font);
where = fCanvasView->ConvertToScreen(where);
BRect mouseRect(where, where);
mouseRect.InsetBy(-10.0, -10.0);
where += BPoint(5.0, 5.0);
menu->Go(where, true, false, mouseRect, true);
return true;
}
示例11: 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));
}
示例12: BMessage
void
IconView::MouseDown(BPoint where)
{
if (!IsEnabled())
return;
int32 buttons = B_PRIMARY_MOUSE_BUTTON;
int32 clicks = 1;
if (Looper() != NULL && Looper()->CurrentMessage() != NULL) {
if (Looper()->CurrentMessage()->FindInt32("buttons", &buttons) != B_OK)
buttons = B_PRIMARY_MOUSE_BUTTON;
if (Looper()->CurrentMessage()->FindInt32("clicks", &clicks) != B_OK)
clicks = 1;
}
if ((buttons & B_PRIMARY_MOUSE_BUTTON) != 0
&& BitmapRect().Contains(where)) {
if (clicks == 2) {
// double click - open Icon-O-Matic
Invoke();
} else if (fIcon != NULL) {
// start tracking - this icon might be dragged around
fDragPoint = where;
fTracking = true;
SetMouseEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY);
}
}
if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) {
// show context menu
ConvertToScreen(&where);
BPopUpMenu* menu = new BPopUpMenu("context");
menu->SetFont(be_plain_font);
bool hasIcon = fHasType ? fSource == kOwnIcon : fIcon != NULL;
if (hasIcon) {
menu->AddItem(new BMenuItem(
B_TRANSLATE("Edit icon" B_UTF8_ELLIPSIS),
new BMessage(kMsgEditIcon)));
} else {
menu->AddItem(new BMenuItem(
B_TRANSLATE("Add icon" B_UTF8_ELLIPSIS),
new BMessage(kMsgAddIcon)));
}
BMenuItem* item = new BMenuItem(
B_TRANSLATE("Remove icon"), new BMessage(kMsgRemoveIcon));
if (!hasIcon)
item->SetEnabled(false);
menu->AddItem(item);
menu->SetTargetForItems(fTarget);
menu->Go(where, true, false, true);
}
}
示例13: SearchBarTextControl
MainWindow::MainWindow()
:
BWindow(BRect(0, 0, 300, 400), "Caya", B_TITLED_WINDOW, 0),
fWorkspaceChanged(false)
{
fStatusView = new StatusView("statusView");
SearchBarTextControl* searchBox =
new SearchBarTextControl(new BMessage(kSearchContact));
fListView = new RosterListView("buddyView");
fListView->SetInvocationMessage(new BMessage(CAYA_OPEN_CHAT_WINDOW));
BScrollView* scrollView = new BScrollView("scrollview", fListView,
B_WILL_DRAW, false, true);
// Wrench menu
BPopUpMenu* wrenchMenu = new BPopUpMenu("Wrench");
(void)wrenchMenu->AddItem(new BMenuItem("About" B_UTF8_ELLIPSIS,
new BMessage(B_ABOUT_REQUESTED)));
(void)wrenchMenu->AddItem(new BSeparatorItem());
(void)wrenchMenu->AddItem(new BMenuItem("Preferences" B_UTF8_ELLIPSIS,
new BMessage(CAYA_SHOW_SETTINGS)));
(void)wrenchMenu->AddItem(new BSeparatorItem());
(void)wrenchMenu->AddItem(new BMenuItem("Quit",
new BMessage(B_QUIT_REQUESTED)));
wrenchMenu->SetTargetForItems(this);
// Tool icon
BResources* res = CayaResources();
BBitmap* toolIcon = IconFromResources(res, kToolIcon);
delete res;
// Wrench tool button
ToolButton* wrench = new ToolButton(NULL, NULL);
wrench->SetBitmap(toolIcon);
wrench->SetMenu(wrenchMenu);
SetLayout(new BGridLayout(1, 2));
AddChild(BGridLayoutBuilder(1, 2)
.Add(searchBox, 0, 0)
.Add(wrench, 1, 0)
.Add(scrollView, 0, 1, 2)
.Add(fStatusView, 0, 2, 2)
.SetInsets(5, 5, 5, 10)
);
AddShortcut('a', B_COMMAND_KEY, new BMessage(B_ABOUT_REQUESTED));
MoveTo(BAlert::AlertPosition(Bounds().Width(), Bounds().Height() / 2));
// Filter messages using Server
fServer = new Server();
AddFilter(fServer);
CenterOnScreen();
//TODO check for errors here
ReplicantStatusView::InstallReplicant();
}
示例14: BPopUpMenu
// DisplayPopupMenu
bool
SplitManipulator::DisplayPopupMenu(BPoint where)
{
BPopUpMenu* menu = new BPopUpMenu("item popup", false, false);
BMessage* message;
BMenuItem* item;
bool separator = false;
if (fItem->HasVideo()) {
message = new BMessage(MSG_SET_VIDEO_MUTED);
message->AddPointer("item", fItem);
item = new BMenuItem("Enabled Video", message);
item->SetMarked(!fItem->IsVideoMuted());
menu->AddItem(item);
separator = true;
}
if (fItem->HasAudio()) {
message = new BMessage(MSG_SET_AUDIO_MUTED);
message->AddPointer("item", fItem);
item = new BMenuItem("Enabled Audio", message);
item->SetMarked(!fItem->IsAudioMuted());
menu->AddItem(item);
separator = true;
}
if (separator)
menu->AddSeparatorItem();
BMenuItem* selectClipItem = NULL;
if (ClipPlaylistItem* clipItem = dynamic_cast<ClipPlaylistItem*>(fItem)) {
message = new BMessage(MSG_SELECT_AND_SHOW_CLIP);
message->AddPointer("clip", clipItem->Clip());
selectClipItem = new BMenuItem("Select Clip", message);
menu->AddItem(selectClipItem);
} else
separator = false;
if (separator)
menu->AddSeparatorItem();
message = new BMessage(MSG_REMOVE_ITEM);
message->AddPointer("item", fItem);
item = new BMenuItem("Remove Clip", message);
menu->AddItem(item);
menu->SetTargetForItems(fView);
if (selectClipItem)
selectClipItem->SetTarget(fView->Window());
show_popup_menu(menu, where, fView, false);
return true;
}
示例15: BMessage
void
URLInputGroup::URLTextView::MouseDown(BPoint where)
{
bool wasFocus = IsFocus();
if (!wasFocus)
MakeFocus(true);
int32 buttons;
if (Window()->CurrentMessage()->FindInt32("buttons", &buttons) != B_OK)
buttons = B_PRIMARY_MOUSE_BUTTON;
if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) {
// Display context menu
int32 selectionStart;
int32 selectionEnd;
GetSelection(&selectionStart, &selectionEnd);
bool canCutOrCopy = selectionEnd > selectionStart;
bool canPaste = false;
if (be_clipboard->Lock()) {
if (BMessage* data = be_clipboard->Data())
canPaste = data->HasData("text/plain", B_MIME_TYPE);
be_clipboard->Unlock();
}
BMenuItem* cutItem = new BMenuItem(B_TRANSLATE("Cut"),
new BMessage(B_CUT));
BMenuItem* copyItem = new BMenuItem(B_TRANSLATE("Copy"),
new BMessage(B_COPY));
BMenuItem* pasteItem = new BMenuItem(B_TRANSLATE("Paste"),
new BMessage(B_PASTE));
BMenuItem* clearItem = new BMenuItem(B_TRANSLATE("Clear"),
new BMessage(MSG_CLEAR));
cutItem->SetEnabled(canCutOrCopy);
copyItem->SetEnabled(canCutOrCopy);
pasteItem->SetEnabled(canPaste);
clearItem->SetEnabled(strlen(Text()) > 0);
BPopUpMenu* menu = new BPopUpMenu("url context");
menu->AddItem(cutItem);
menu->AddItem(copyItem);
menu->AddItem(pasteItem);
menu->AddItem(clearItem);
menu->SetTargetForItems(this);
menu->Go(ConvertToScreen(where), true, true, true);
return;
}
// Only pass through to base class if we already have focus.
if (!wasFocus)
return;
BTextView::MouseDown(where);
}