本文整理汇总了C++中BPopUpMenu::Go方法的典型用法代码示例。如果您正苦于以下问题:C++ BPopUpMenu::Go方法的具体用法?C++ BPopUpMenu::Go怎么用?C++ BPopUpMenu::Go使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BPopUpMenu
的用法示例。
在下文中一共展示了BPopUpMenu::Go方法的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
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: BMessage
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);
}
示例5: GeneratePopUp
void StatusItem::GeneratePopUp(BPoint point, BRect openrect)
{
BString str(value);
str.Append(" ");
BString url;
URLCrunch crunch(str.String(), str.Length());
BPopUpMenu* menu = new BPopUpMenu("URLs");
BMessage msg(M_LOAD_URL);
BMessage* allocmsg(NULL);
BMenuItem* item(NULL);
while (crunch.Crunch(&url) != B_ERROR) {
allocmsg = new BMessage(msg);
allocmsg->AddString("url", url.String());
item = new BMenuItem(url.String(), allocmsg);
menu->AddItem(item);
allocmsg = NULL;
}
if (menu->CountItems() > 0) {
menu->SetTargetForItems(be_app);
menu->SetAsyncAutoDestruct(true);
menu->Go(point, true, true, openrect, true);
} else {
delete menu;
}
}
示例6: mouseRect
// MouseDown
void
OptionValueView::MouseDown(BPoint where)
{
if (BView* parent = Parent())
parent->MouseDown(ConvertToParent(where));
if (fProperty) {
BPopUpMenu* menu = new BPopUpMenu("option popup", false, false);
BString name;
int32 id;
for (int32 i = 0; fProperty->GetOption(i, &name, &id); i++) {
BMessage* message = new BMessage(MSG_OPTION_CHANGED);
message->AddInt32("id", id);
BMenuItem* item = new BMenuItem(name.String(), message);
menu->AddItem(item);
if (id == fProperty->CurrentOptionID())
item->SetMarked(true);
}
menu->SetTargetForItems(this);
menu->SetAsyncAutoDestruct(true);
menu->SetFont(be_plain_font);
menu->SetEnabled(fEnabled);
where = 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);
}
}
示例7: node
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);
}
}
}
示例8: 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);
}
示例9: Float
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;
}
示例10: BMessage
void
PowerStatusReplicant::MouseDown(BPoint point)
{
BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING, false, false);
menu->SetFont(be_plain_font);
BMenuItem* item;
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Show text label"),
new BMessage(kMsgToggleLabel)));
if (fShowLabel)
item->SetMarked(true);
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Show status icon"),
new BMessage(kMsgToggleStatusIcon)));
if (fShowStatusIcon)
item->SetMarked(true);
menu->AddItem(new BMenuItem(!fShowTime ? B_TRANSLATE("Show time") :
B_TRANSLATE("Show percent"),
new BMessage(kMsgToggleTime)));
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem(B_TRANSLATE("Battery info" B_UTF8_ELLIPSIS),
new BMessage(kMsgToggleExtInfo)));
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem(B_TRANSLATE("About" B_UTF8_ELLIPSIS),
new BMessage(B_ABOUT_REQUESTED)));
menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"),
new BMessage(B_QUIT_REQUESTED)));
menu->SetTargetForItems(this);
ConvertToScreen(&point);
menu->Go(point, true, false, true);
}
示例11: 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;
}
示例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: 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);
}
示例14: BMessage
void
PeakView::MouseDown(BPoint where)
{
int32 buttons;
if (Window()->CurrentMessage()->FindInt32("buttons", &buttons) < B_OK)
buttons = B_PRIMARY_MOUSE_BUTTON;
if (buttons & B_PRIMARY_MOUSE_BUTTON) {
// Reset the overshot flag and set the observed max to the current
// value.
for (uint32 i = 0; i < fChannelCount; i++) {
fChannelInfos[i].last_overshot_time = -5000000;
fChannelInfos[i].last_max = fChannelInfos[i].current_max;
}
} else if (buttons & B_TERTIARY_MOUSE_BUTTON) {
// Toggle locking of the observed max value.
fPeakLocked = !fPeakLocked;
} else {
// Display context menu
BPopUpMenu* menu = new BPopUpMenu("peak context menu");
BMenuItem* item = new BMenuItem("Lock Peaks",
new BMessage(MSG_LOCK_PEAKS));
item->SetMarked(fPeakLocked);
menu->AddItem(item);
menu->SetTargetForItems(this);
menu->SetAsyncAutoDestruct(true);
menu->SetFont(be_plain_font);
where = ConvertToScreen(where);
bool keepOpen = false; // ?
if (keepOpen) {
BRect mouseRect(where, where);
mouseRect.InsetBy(-3.0, -3.0);
where += BPoint(3.0, 3.0);
menu->Go(where, true, false, mouseRect, true);
} else {
where += BPoint(3.0, 3.0);
menu->Go(where, true, false, true);
}
}
}
示例15: MessageReceived
virtual void MessageReceived(BMessage* message)
{
switch (message->what) {
case MSG_SCROLL_TABS_LEFT:
fTabContainerView->SetFirstVisibleTabIndex(
fTabContainerView->FirstVisibleTabIndex() - 1);
break;
case MSG_SCROLL_TABS_RIGHT:
fTabContainerView->SetFirstVisibleTabIndex(
fTabContainerView->FirstVisibleTabIndex() + 1);
break;
case MSG_OPEN_TAB_MENU:
{
BPopUpMenu* tabMenu = new BPopUpMenu("tab menu", true, false);
int tabCount = fTabContainerView->GetLayout()->CountItems();
for (int i = 0; i < tabCount; i++) {
TabView* tab = fTabContainerView->TabAt(i);
if (tab) {
BMenuItem* item = new BMenuItem(tab->Label(), NULL);
tabMenu->AddItem(item);
if (tab->IsFront())
item->SetMarked(true);
}
}
// Force layout to get the final menu size. InvalidateLayout()
// did not seem to work here.
tabMenu->AttachedToWindow();
BRect buttonFrame = fTabMenuButton->Frame();
BRect menuFrame = tabMenu->Frame();
BPoint openPoint = ConvertToScreen(buttonFrame.LeftBottom());
// Open with the right side of the menu aligned with the right
// side of the button and a little below.
openPoint.x -= menuFrame.Width() - buttonFrame.Width();
openPoint.y += 2;
BMenuItem *selected = tabMenu->Go(openPoint, false, false,
ConvertToScreen(buttonFrame));
if (selected) {
selected->SetMarked(true);
int32 index = tabMenu->IndexOf(selected);
if (index != B_ERROR)
fTabContainerView->SelectTab(index);
}
fTabMenuButton->MenuClosed();
delete tabMenu;
break;
}
default:
BGroupView::MessageReceived(message);
break;
}
}