本文整理汇总了C++中BPopUpMenu::SetAsyncAutoDestruct方法的典型用法代码示例。如果您正苦于以下问题:C++ BPopUpMenu::SetAsyncAutoDestruct方法的具体用法?C++ BPopUpMenu::SetAsyncAutoDestruct怎么用?C++ BPopUpMenu::SetAsyncAutoDestruct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BPopUpMenu
的用法示例。
在下文中一共展示了BPopUpMenu::SetAsyncAutoDestruct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
示例2: 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);
}
示例3: 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);
}
}
示例4: 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;
}
示例5: Bounds
void
QuaSymbolBridge::MouseDown(BPoint where)
{
long channel, quant;
BRect area = Bounds();
ulong mods = modifiers(); // Key mods???
ulong buts;
BMessage *msg;
BPoint pt;
drawing_mode cur_mode = DrawingMode();
long clicks;
GetMouse(&pt, &buts);
msg = Window()->CurrentMessage();
if ((clicks=msg->FindInt32("clicks")) == 1) {
if (buts & B_SECONDARY_MOUSE_BUTTON) {
BPopUpMenu *qMenu = new BPopUpMenu("env sel", true, FALSE);
BPoint orig = where;
ConvertToScreen(&where);
BMessage *msg = new BMessage(SET_DISPLAY_MODE);
msg->AddInt32("display mode", OBJECT_DISPLAY_SMALL);
BMenuItem *item = new BMenuItem("Small", msg);
qMenu->AddItem(item);
item->SetTarget(this);
msg = new BMessage(SET_DISPLAY_MODE);
msg->AddInt32("display mode", OBJECT_DISPLAY_BIG);
item = new BMenuItem("Large", msg);
qMenu->AddItem(item);
item->SetTarget(this);
qMenu->SetAsyncAutoDestruct(true);
qMenu->Go(where, true, false, true);
} else {
msg = new BMessage(MOVE_OBJECT);
msg->AddPointer("sym_object", this);
if (mods & B_SHIFT_KEY) {
((ObjectViewContainer *)Parent())->AddSelection(this);
} else {
((ObjectViewContainer *)Parent())->Select(this);
}
DragMessage(msg, area);
}
} else if (clicks > 1) { // edit object
Edit();
} else {
}
}
示例6: entry
BPopUpMenu * URLView::CreatePopupMenu() {
// Create the right-click popup menu.
BPopUpMenu *returnMe = new BPopUpMenu( "URLView Popup", false, false );
returnMe->SetAsyncAutoDestruct( true );
entry_ref app;
// Set the text of the first item according to the link type.
if( IsEmailLink() ) {
// Find the name of the default e-mail client.
if( be_roster->FindApp( "text/x-email", &app ) == B_OK ) {
BEntry entry( &app );
BString openLabel( _T("Send e-mail to this address using ") );
char name[B_FILE_NAME_LENGTH];
entry.GetName( name );
openLabel.Append( name );
returnMe->AddItem( new BMenuItem( openLabel.String(), NULL ) );
}
}
else if( IsFTPLink() ) {
// Find the name of the default FTP client.
if( be_roster->FindApp( "application/x-vnd.Be.URL.ftp", &app ) == B_OK ) {
BEntry entry( &app );
BString openLabel( _T("Connect to this server using ") );
char name[B_FILE_NAME_LENGTH];
entry.GetName( name );
openLabel.Append( name );
returnMe->AddItem( new BMenuItem( openLabel.String(), NULL ) );
}
}
else {
// Find the name of the default HTML handler (browser).
if( be_roster->FindApp( "text/html", &app ) == B_OK ) {
BEntry entry( &app );
BString openLabel( _T("Open this link using ") );
char name[B_FILE_NAME_LENGTH];
entry.GetName( name );
openLabel.Append( name );
returnMe->AddItem( new BMenuItem( openLabel.String(), NULL ) );
}
}
returnMe->AddItem( new BMenuItem( _T("Copy this link to the clipboard"), NULL ) );
return returnMe;
}
示例7: ShowPropertyMenu
void SeqToolBarView::ShowPropertyMenu(const AmTool* tool, BPoint where)
{
BPopUpMenu* menu = new BPopUpMenu("properties menu");
if (!menu) return;
BMessage* msg = new BMessage(PROPERTIES_MSG);
if (msg) {
msg->AddString("tool_key", tool->Key() );
BMenuItem* item = new BMenuItem("Properties", msg);
if (item) {
item->SetTarget(this);
menu->AddItem(item);
}
}
msg = new BMessage(EDIT_MSG);
if (msg) {
msg->AddString("tool_key", tool->Key() );
msg->AddString("path", tool->LocalFilePath() );
BMenuItem* item = new BMenuItem("Edit", msg);
if (item) {
item->SetTarget(this);
if (tool->IsReadOnly() ) item->SetEnabled(false);
menu->AddItem(item);
}
}
menu->AddSeparatorItem();
msg = new BMessage(REMOVE_FROM_TOOL_BAR_MSG);
if (msg) {
msg->AddString("tool_key", tool->Key() );
msg->AddPointer("tool_id", tool->Id() );
BMenuItem* item = new BMenuItem("Remove From Tool Bar", msg);
if (item) {
item->SetTarget(this);
menu->AddItem(item);
}
}
menu->SetAsyncAutoDestruct(true);
where = ConvertToScreen(where);
BRect sticky(where.x-5, where.y-5, where.x+5, where.y+5);
menu->Go(where, true, false, sticky, true);
}
示例8: 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);
}
}
}
示例9: MouseDown
void VBoxGuestDeskbarView::MouseDown(BPoint point)
{
int32 buttons = B_PRIMARY_MOUSE_BUTTON;
if (Looper() != NULL && Looper()->CurrentMessage() != NULL)
Looper()->CurrentMessage()->FindInt32("buttons", &buttons);
BPoint where = ConvertToScreen(point);
if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0)
{
BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING, false, false);
menu->SetAsyncAutoDestruct(true);
menu->SetFont(be_plain_font);
menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED)));
menu->SetTargetForItems(this);
menu->Go(where, true, true, true);
}
}
示例10: mouseRect
void
TermWindow::TabRightClicked(SmartTabView* tabView, BPoint point, int32 index)
{
if (index < 0)
return;
TermView* termView = _TermViewAt(index);
if (termView == NULL)
return;
BMessage* closeMessage = new BMessage(kCloseView);
_SessionAt(index)->id.AddToMessage(*closeMessage, "session");
BMessage* closeOthersMessage = new BMessage(kCloseOtherViews);
_SessionAt(index)->id.AddToMessage(*closeOthersMessage, "session");
BMessage* editTitleMessage = new BMessage(kEditTabTitle);
_SessionAt(index)->id.AddToMessage(*editTitleMessage, "session");
BPopUpMenu* popUpMenu = new BPopUpMenu("tab menu");
BLayoutBuilder::Menu<>(popUpMenu)
.AddItem(B_TRANSLATE("Close tab"), closeMessage)
.AddItem(B_TRANSLATE("Close other tabs"), closeOthersMessage)
.AddSeparator()
.AddItem(B_TRANSLATE("Edit tab title" B_UTF8_ELLIPSIS),
editTitleMessage)
;
popUpMenu->SetAsyncAutoDestruct(true);
popUpMenu->SetTargetForItems(BMessenger(this));
BPoint screenWhere = tabView->ConvertToScreen(point);
BRect mouseRect(screenWhere, screenWhere);
mouseRect.InsetBy(-4.0, -4.0);
popUpMenu->Go(screenWhere, true, true, mouseRect, true);
}
示例11: BPopUpMenu
void
TestView::ShowModeMenu(void)
{
BPopUpMenu *menu = new BPopUpMenu("String");
BMessage *msg, modes;
if (RuleRunner::GetCompatibleModes(fTestButton->Label(),modes) != B_OK)
return;
BString modestr;
int32 i = 0;
while (modes.FindString("modes",i,&modestr) == B_OK)
{
i++;
msg = new BMessage(M_MODE_CHOSEN);
msg->AddString("mode",modestr);
menu->AddItem(new BMenuItem(modestr.String(), msg));
}
menu->SetTargetForItems(this);
BPoint pt;
uint32 buttons;
GetMouse(&pt,&buttons);
ConvertToScreen(&pt);
pt.x -= 10.0;
if (pt.x < 0.0)
pt.x = 0.0;
pt.y -= 10.0;
if (pt.y < 0.0)
pt.y = 0.0;
menu->SetAsyncAutoDestruct(true);
menu->Go(pt,true,true,true);
}
示例12: ShowTimeSignatureMenu
void SeqMeasureControl::ShowTimeSignatureMenu(BPoint pt) const
{
AmSignature sig;
if (SignatureForPt(pt, sig) != B_OK) return;
BPopUpMenu* menu = new BPopUpMenu("menu");
if (!menu) return;
menu->SetFontSize(10);
menu->SetAsyncAutoDestruct(true);
BMessage signatureChoices;
if (seq_get_message_preference(SIGNATURE_CHOICES_PREF, &signatureChoices) == B_OK) {
int32 beats;
for(int32 k = 0; signatureChoices.FindInt32("beats", k, &beats) == B_OK; k++) {
int32 beatvalue;
if (signatureChoices.FindInt32("beat value", k, &beatvalue) == B_OK) {
BString label;
label << beats << " / " << beatvalue;
BMessage* msg = new BMessage(CHANGE_SIGNATURE_MSG);
BMenuItem* item;
if (msg && (item = new BMenuItem(label.String(), msg)) ) {
msg->AddInt32("measure", sig.Measure() );
msg->AddInt32("beats", beats);
msg->AddInt32("beat value", beatvalue);
menu->AddItem(item);
item->SetTarget(this);
}
}
}
}
BMessage* msg = new BMessage(CHANGE_SIGNATURE_MSG);
BMenuItem* item;
if ( msg && (item = new BMenuItem("Other...", msg)) ) {
msg->AddInt32("measure", sig.Measure() );
msg->AddInt32("beats", sig.Beats() );
msg->AddInt32("beat value", sig.BeatValue() );
menu->AddItem(item);
item->SetTarget( Window() );
}
/* If I'm a track measure control, add in my motion list.
*/
BMenu* motionMenu = NULL;
if (mTrackWinProps && (motionMenu = new BMenu("Motion")) ) {
BMessage* msg = new BMessage(CHANGE_MOTION_MSG);
BMenuItem* item;
if (msg && (item = new BMenuItem(NONE_STR, msg)) ) {
msg->AddInt32("code", MOTION_NONE);
msg->AddInt32("measure", sig.Measure() );
motionMenu->AddItem(item);
item->SetTarget(this);
}
msg = new BMessage(CHANGE_MOTION_MSG);
if (msg && (item = new BMenuItem(CLEAR_STR, msg)) ) {
msg->AddInt32("code", MOTION_CLEAR);
msg->AddInt32("measure", sig.Measure() );
motionMenu->AddItem(item);
item->SetTarget(this);
}
BString label, key;
for (uint32 k = 0; AmGlobals().GetMotionInfo(k, label, key) == B_OK; k++) {
msg = new BMessage(CHANGE_MOTION_MSG);
if (msg && (item = new BMenuItem(label.String(), msg)) ) {
if (k == 0) motionMenu->AddSeparatorItem();
msg->AddString(MOTION_KEY_STR, key);
msg->AddInt32("measure", sig.Measure() );
motionMenu->AddItem(item);
item->SetTarget(this);
}
}
if (motionMenu) {
menu->AddSeparatorItem();
BMenuItem* i = new BMenuItem(motionMenu);
if (i) menu->AddItem(i);
}
}
BRect frame(pt, pt);
menu->Go( ConvertToScreen(pt), true, false, ConvertToScreen(frame), true);
}
示例13: BMessage
void
NetworkStatusView::MouseDown(BPoint point)
{
BPopUpMenu* menu = new BPopUpMenu(B_EMPTY_STRING, false, false);
menu->SetAsyncAutoDestruct(true);
menu->SetFont(be_plain_font);
BString wifiInterface;
BNetworkDevice wifiDevice;
// Add interfaces
for (std::map<BString, int32>::const_iterator it
= fInterfaceStatuses.begin(); it != fInterfaceStatuses.end(); ++it) {
const BString& name = it->first;
BString label = name;
label += ": ";
label += kStatusDescriptions[
_DetermineInterfaceStatus(name.String())];
BMessage* info = new BMessage(kMsgShowConfiguration);
info->AddString("interface", name.String());
menu->AddItem(new BMenuItem(label.String(), info));
// We only show the networks of the first wireless device we find.
if (wifiInterface.IsEmpty()) {
wifiDevice.SetTo(name);
if (wifiDevice.IsWireless())
wifiInterface = name;
}
}
if (!fInterfaceStatuses.empty())
menu->AddSeparatorItem();
// Add wireless networks, if any
if (!wifiInterface.IsEmpty()) {
std::set<BNetworkAddress> associated;
BNetworkAddress address;
uint32 cookie = 0;
while (wifiDevice.GetNextAssociatedNetwork(cookie, address) == B_OK)
associated.insert(address);
cookie = 0;
wireless_network network;
typedef std::vector<wireless_network> WirelessNetworkVector;
WirelessNetworkVector wirelessNetworks;
while (wifiDevice.GetNextNetwork(cookie, network) == B_OK)
wirelessNetworks.push_back(network);
std::sort(wirelessNetworks.begin(), wirelessNetworks.end(),
signal_strength_compare);
int32 count = 0;
for (WirelessNetworkVector::iterator it = wirelessNetworks.begin();
it != wirelessNetworks.end(); it++) {
wireless_network &network = *it;
BMessage* message = new BMessage(kMsgJoinNetwork);
message->AddString("device", wifiInterface);
message->AddString("name", network.name);
message->AddFlat("address", &network.address);
BMenuItem* item = new WirelessNetworkMenuItem(network.name,
network.signal_strength, network.authentication_mode, message);
menu->AddItem(item);
if (associated.find(network.address) != associated.end())
item->SetMarked(true);
count++;
}
if (count == 0) {
BMenuItem* item = new BMenuItem(
B_TRANSLATE("<no wireless networks found>"), NULL);
item->SetEnabled(false);
menu->AddItem(item);
}
menu->AddSeparatorItem();
}
menu->AddItem(new BMenuItem(B_TRANSLATE(
"Open network preferences" B_UTF8_ELLIPSIS),
new BMessage(kMsgOpenNetworkPreferences)));
if (fInDeskbar) {
menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"),
new BMessage(B_QUIT_REQUESTED)));
}
menu->SetTargetForItems(this);
ConvertToScreen(&point);
menu->Go(point, true, true, true);
}
示例14: BMessage
//.........这里部分代码省略.........
item->SetTarget(window);
menu->AddItem(item);
}
// set button description
if (button->Ref()) {
message = new BMessage(MSG_SET_DESCRIPTION);
message->AddPointer("be:source", (void*)button);
item = new BMenuItem(B_TRANSLATE("Set description"B_UTF8_ELLIPSIS),
message);
item->SetTarget(window);
menu->AddItem(item);
}
}
menu->AddSeparatorItem();
// window settings
BMenu* settingsM = new BMenu(B_TRANSLATE("Settings"));
settingsM->SetFont(be_plain_font);
const char* toggleLayoutLabel;
if (fButtonLayout->Orientation() == B_HORIZONTAL)
toggleLayoutLabel = B_TRANSLATE("Vertical layout");
else
toggleLayoutLabel = B_TRANSLATE("Horizontal layout");
item = new BMenuItem(toggleLayoutLabel, new BMessage(MSG_TOGGLE_LAYOUT));
item->SetTarget(this);
settingsM->AddItem(item);
BMenu* iconSizeM = new BMenu(B_TRANSLATE("Icon size"));
for (uint32 i = 0; i < sizeof(kIconSizes) / sizeof(uint32); i++) {
uint32 iconSize = kIconSizes[i];
message = new BMessage(MSG_SET_ICON_SIZE);
message->AddInt32("size", iconSize);
BString label;
label << iconSize << " x " << iconSize;
item = new BMenuItem(label.String(), message);
item->SetTarget(this);
item->SetMarked(IconSize() == iconSize);
iconSizeM->AddItem(item);
}
settingsM->AddItem(iconSizeM);
item = new BMenuItem(B_TRANSLATE("Ignore double-click"),
new BMessage(MSG_SET_IGNORE_DOUBLECLICK));
item->SetTarget(this);
item->SetMarked(IgnoreDoubleClick());
settingsM->AddItem(item);
uint32 what = window->Look() == B_BORDERED_WINDOW_LOOK ? MSG_SHOW_BORDER : MSG_HIDE_BORDER;
item = new BMenuItem(B_TRANSLATE("Show window border"), new BMessage(what));
item->SetTarget(window);
item->SetMarked(what == MSG_HIDE_BORDER);
settingsM->AddItem(item);
item = new BMenuItem(B_TRANSLATE("Auto-raise"), new BMessage(MSG_TOGGLE_AUTORAISE));
item->SetTarget(window);
item->SetMarked(window->AutoRaise());
settingsM->AddItem(item);
item = new BMenuItem(B_TRANSLATE("Show on all workspaces"), new BMessage(MSG_SHOW_ON_ALL_WORKSPACES));
item->SetTarget(window);
item->SetMarked(window->ShowOnAllWorkspaces());
settingsM->AddItem(item);
menu->AddItem(settingsM);
menu->AddSeparatorItem();
// pad commands
BMenu* padM = new BMenu(B_TRANSLATE("Pad"));
padM->SetFont(be_plain_font);
// new pad
item = new BMenuItem(B_TRANSLATE("New"), new BMessage(MSG_ADD_WINDOW));
item->SetTarget(be_app);
padM->AddItem(item);
// new pad
item = new BMenuItem(B_TRANSLATE("Clone"), new BMessage(MSG_ADD_WINDOW));
item->SetTarget(window);
padM->AddItem(item);
padM->AddSeparatorItem();
// close
item = new BMenuItem(B_TRANSLATE("Close"), new BMessage(B_QUIT_REQUESTED));
item->SetTarget(window);
padM->AddItem(item);
menu->AddItem(padM);
// app commands
BMenu* appM = new BMenu(B_TRANSLATE_SYSTEM_NAME("LaunchBox"));
appM->SetFont(be_plain_font);
// quit
item = new BMenuItem(B_TRANSLATE("Quit"), new BMessage(B_QUIT_REQUESTED));
item->SetTarget(be_app);
appM->AddItem(item);
menu->AddItem(appM);
// finish popup
menu->SetAsyncAutoDestruct(true);
menu->SetFont(be_plain_font);
where = ConvertToScreen(where);
BRect mouseRect(where, where);
mouseRect.InsetBy(-4.0, -4.0);
menu->Go(where, true, false, mouseRect, true);
}
示例15:
void
TestView::MessageReceived(BMessage *msg)
{
switch (msg->what)
{
case M_TEST_CHOSEN:
{
SetTest(msg);
break;
}
case M_MODE_CHOSEN:
{
BString mode;
if (msg->FindString("mode",&mode) != B_OK)
break;
SetMode(mode.String());
break;
}
case M_VALUE_CHANGED:
{
BString str;
if (fTest->FindString("value",&str) == B_OK)
fTest->ReplaceString("value",fValueBox->Text());
else
fTest->AddString("value",fValueBox->Text());
break;
}
case M_SHOW_TEST_MENU:
{
BPopUpMenu *menu = (BPopUpMenu*)BPopUpMenu::Instantiate(&fArchivedTestMenu);
menu->SetTargetForItems(this);
for (int32 i = 0; i < menu->CountItems(); i++)
{
BMenuItem *item = menu->ItemAt(i);
if (item->Submenu())
item->Submenu()->SetTargetForItems(this);
}
BPoint pt;
uint32 buttons;
GetMouse(&pt,&buttons);
ConvertToScreen(&pt);
pt.x -= 10.0;
if (pt.x < 0.0)
pt.x = 0.0;
pt.y -= 10.0;
if (pt.y < 0.0)
pt.y = 0.0;
menu->SetAsyncAutoDestruct(true);
menu->Go(pt,true,true,true);
break;
}
case M_SHOW_TYPE_MENU:
{
BPopUpMenu *menu = (BPopUpMenu*)BPopUpMenu::Instantiate(&gArchivedTypeMenu);
menu->SetTargetForItems(this);
for (int32 i = 0; i < menu->CountItems(); i++)
{
BMenuItem *item = menu->ItemAt(i);
if (item->Submenu())
item->Submenu()->SetTargetForItems(this);
}
BPoint pt;
uint32 buttons;
GetMouse(&pt,&buttons);
ConvertToScreen(&pt);
pt.x -= 10.0;
if (pt.x < 0.0)
pt.x = 0.0;
pt.y -= 10.0;
if (pt.y < 0.0)
pt.y = 0.0;
menu->SetAsyncAutoDestruct(true);
menu->Go(pt,true,true,true);
break;
}
case M_SHOW_MODE_MENU:
{
ShowModeMenu();
break;
}
default:
{
BView::MessageReceived(msg);
break;
}
}
}