本文整理汇总了C++中BMenu::RemoveItem方法的典型用法代码示例。如果您正苦于以下问题:C++ BMenu::RemoveItem方法的具体用法?C++ BMenu::RemoveItem怎么用?C++ BMenu::RemoveItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BMenu
的用法示例。
在下文中一共展示了BMenu::RemoveItem方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FileFormatMenuItem
void
MediaConverterWindow::BuildFormatMenu()
{
BMenu* menu = fFormatMenu->Menu();
BMenuItem* item;
// clear out old format menu items
while ((item = menu->RemoveItem((int32)0)) != NULL)
delete item;
// add menu items for each file format
media_file_format mfi;
int32 cookie = 0;
FileFormatMenuItem* ff_item;
while (get_next_file_format(&cookie, &mfi) == B_OK) {
if ((mfi.capabilities & media_file_format::B_WRITABLE) == 0)
continue;
ff_item = new FileFormatMenuItem(&mfi);
menu->AddItem(ff_item);
}
// mark first item
item = menu->ItemAt(0);
if (item != NULL) {
item->SetMarked(true);
((BInvoker*)item)->Invoke();
}
}
示例2: UpdateDirectoryPopup
void CFtpDialog::UpdateDirectoryPopup()
{
BMenu* menu = fDirectoryField->Menu();
BMenuItem *item;
while ((item = menu->ItemAt(menu->CountItems() - 1)) != NULL)
{
menu->RemoveItem(item);
delete item;
}
char p[PATH_MAX], *l;
strcpy(p, fPath);
l = strtok(p, "/");
menu->AddItem(new BMenuItem("/", new BMessage(msg_SelectedDirectory)));
while (l)
{
menu->AddItem(new BMenuItem(l, new BMessage(msg_SelectedDirectory)));
l = strtok(NULL, "/");
}
menu->ItemAt(menu->CountItems() - 1)->SetMarked(true);
} // CFtpDialog::UpdateDirectoryPopup
示例3: BuildProtocolMenu
void ChatWindow::BuildProtocolMenu(void) {
BMessage getStatus(IM::GET_CONTACT_STATUS);
getStatus.AddRef("contact", &fEntry);
BMessage statusMsg;
BMenu *menu = fProtocolMenu->Menu();
if (menu == NULL) {
LOG("im_emoclient", liHigh, "BuildProtocolMenu(): fProtocolMenu is NULL.");
return;
}
// You have to do this twice... buggered if I know why...
for (int32 i = 0; i < menu->CountItems(); i++) delete menu->RemoveItem(0L);
for (int32 i = 0; i < menu->CountItems(); i++) delete menu->RemoveItem(0L);
menu->AddItem(new IconMenuItem(NULL, _T("Any Protocol"), NULL,
new BMessage(PROTOCOL_SELECTED)));
if (fMan->SendMessage(&getStatus, &statusMsg) != B_OK) {
LOG("im_emoclient", liHigh, "Failed to get contact statues");
return;
};
BPath iconDir;
find_directory(B_USER_ADDONS_DIRECTORY, &iconDir, true);
iconDir.Append("im_kit/protocols");
menu->AddSeparatorItem();
for (int32 i = 0; statusMsg.FindString("connection", i); i++) {
BString status = statusMsg.FindString("status", i);
IM::Connection connection( statusMsg.FindString("connection", i) );
BString iconPath = iconDir.Path();
iconPath << "/" << connection.Protocol();
BBitmap *icon = ReadNodeIcon(iconPath.String(), kSmallIcon, true);
BString label = connection.String();
label << " (" << _T(status.String()) << ")";
menu->AddItem(
new IconMenuItem(
icon,
label.String(),
connection.String(),
new BMessage(PROTOCOL_SELECTED)
)
);
};
// TODO: Is this call needed or not?
//menu->SetFont(be_plain_font);
fStatusBar->PositionViews();
fInfoView->ResizeTo(fStatusBar->Bounds().Width() - fInfoView->Frame().left,
fInfoView->Bounds().Height());
};
示例4:
/*! \brief Removes the option at the given index.
\param index The index of the option to remove.
*/
void
BOptionPopUp::RemoveOptionAt(int32 index)
{
BMenu *menu = fMenuField->Menu();
if (menu != NULL) {
BMenuItem *item = menu->ItemAt(index);
if (item != NULL) {
menu->RemoveItem(item);
delete item;
}
}
}
示例5: if
void
PPPoEView::ReloadInterfaces()
{
// delete all items and request a new bunch from the pppoe kernel module
BMenu *menu = fInterface->Menu();
while(menu->CountItems() > 2)
delete menu->RemoveItem((int32) 0);
fOtherInterface->SetLabel(kLabelOtherInterface);
PPPManager manager;
char *interfaces = new char[8192];
// reserve enough space for approximately 512 entries
int32 count = manager.ControlModule("pppoe", PPPoE_GET_INTERFACES, interfaces,
8192);
BMenuItem *item;
char *name = interfaces;
int32 insertAt;
for(int32 index = 0; index < count; index++) {
item = new BMenuItem(name, new BMessage(kMsgSelectInterface));
insertAt = FindNextMenuInsertionIndex(menu, name);
if(insertAt > menu->CountItems() - 2)
insertAt = menu->CountItems() - 2;
item->SetTarget(this);
menu->AddItem(item, insertAt);
name += strlen(name) + 1;
}
// set interface or some default value if nothing was found
if(Addon()->InterfaceName() && strlen(Addon()->InterfaceName()) > 0)
fInterfaceName = Addon()->InterfaceName();
else if(count > 0)
fInterfaceName = interfaces;
else
fInterfaceName = "";
delete interfaces;
item = menu->FindItem(fInterfaceName.String());
if(item && menu->IndexOf(item) <= menu->CountItems() - 2)
item->SetMarked(true);
else if(Addon()->InterfaceName()) {
BString label(kLabelOtherInterface);
label << " " << fInterfaceName;
fOtherInterface->SetLabel(label.String());
fOtherInterface->SetMarked(true);
}
}
示例6: handleMouseEvent
void BWebPage::handleMouseEvent(const BMessage* message)
{
WebCore::Frame* frame = fMainFrame->Frame();
if (!frame->view() || !frame->document())
return;
PlatformMouseEvent event(message);
switch (message->what) {
case B_MOUSE_DOWN:
// Handle context menus, if necessary.
if (event.button() == RightButton) {
fPage->contextMenuController()->clearContextMenu();
WebCore::Frame* focusedFrame = fPage->focusController()->focusedOrMainFrame();
focusedFrame->eventHandler()->sendContextMenuEvent(event);
// If the web page implements it's own context menu handling, then
// the contextMenu() pointer will be zero. In this case, we should
// also swallow the event.
ContextMenu* contextMenu = fPage->contextMenuController()->contextMenu();
if (contextMenu) {
BMenu* platformMenu = contextMenu->releasePlatformDescription();
if (platformMenu) {
// Need to convert the BMenu into BPopUpMenu.
BPopUpMenu* popupMenu = new BPopUpMenu("context menu");
for (int32 i = platformMenu->CountItems() - 1; i >= 0; i--) {
BMenuItem* item = platformMenu->RemoveItem(i);
popupMenu->AddItem(item, 0);
}
BPoint screenLocation(event.globalPosition().x() + 2,
event.globalPosition().y() + 2);
popupMenu->Go(screenLocation, true, true, true);
delete platformMenu;
}
}
break;
}
// Handle regular mouse events.
frame->eventHandler()->handleMousePressEvent(event);
break;
case B_MOUSE_UP:
frame->eventHandler()->handleMouseReleaseEvent(event);
break;
case B_MOUSE_MOVED:
default:
frame->eventHandler()->mouseMoved(event);
break;
}
}
示例7: OnOpen
// Read data
void AppWindow::OnOpen(BMessage *msg) {
entry_ref ref;
BMessage archive;
msg->FindRef("refs", &ref);
BFile file(&ref, B_READ_ONLY);
archive.Unflatten(&file);
Graph *g = (Graph*)Graph::Instantiate(&archive);
if (g != NULL) {
delete view->graph; view->graph = g;
BMenu *menu = data->functions->Menu();
while (menu->RemoveItem((int32)0) != NULL);
Function1 *f;
int i;
if (program->Lock()) {
program->view->SetText(g->GetDefinitions()->GetText());
program->Unlock();
}
MarkColorMenuItem(bg_color, view->graph->bg_color);
MarkColorMenuItem(axes_color, view->graph->axes_color);
ExprList *el = g->GetGraphExprs();
for (i = 0; i < 6; i++)
data->gCtrls[i]->SetText(el->GetText(i));
for (i = 0; i < 5; i++)
data->fCtrls[i]->SetText("");
UpdateGraph();
for (i = 0; NULL != (f = g->GetFunction(i)); i++) {
CompileFunction(f, false);
}
for (i = 0; NULL != (f = g->GetFunction(i)); i++)
AddFunction(f);
OnSelect();
OnUpdate();
} else {
BAlert *a = new BAlert("Open Error", "Could not read file.", "OK");
a->Go();
}
}
示例8: windRect
void
TFilePanel::Init(const BMessage*)
{
BRect windRect(Bounds());
AddChild(fBackView = new BackgroundView(windRect));
// add poseview menu bar
fMenuBar = new BMenuBar(BRect(0, 0, windRect.Width(), 1), "MenuBar");
fMenuBar->SetBorder(B_BORDER_FRAME);
fBackView->AddChild(fMenuBar);
AddMenus();
AddContextMenus();
FavoritesMenu* favorites = new FavoritesMenu(B_TRANSLATE("Favorites"),
new BMessage(kSwitchDirectory), new BMessage(B_REFS_RECEIVED),
BMessenger(this), IsSavePanel(), fPoseView->RefFilter());
favorites->AddItem(new BMenuItem(B_TRANSLATE("Add current folder"),
new BMessage(kAddCurrentDir)));
favorites->AddItem(new BMenuItem(
B_TRANSLATE("Edit favorites" B_UTF8_ELLIPSIS),
new BMessage(kEditFavorites)));
fMenuBar->AddItem(favorites);
// configure menus
BMenuItem* item = fMenuBar->FindItem(B_TRANSLATE("Window"));
if (item) {
fMenuBar->RemoveItem(item);
delete item;
}
item = fMenuBar->FindItem(B_TRANSLATE("File"));
if (item) {
BMenu* menu = item->Submenu();
if (menu) {
item = menu->FindItem(kOpenSelection);
if (item && menu->RemoveItem(item))
delete item;
item = menu->FindItem(kDuplicateSelection);
if (item && menu->RemoveItem(item))
delete item;
// remove add-ons menu, identifier menu, separator
item = menu->FindItem(B_TRANSLATE("Add-ons"));
if (item) {
int32 index = menu->IndexOf(item);
delete menu->RemoveItem(index);
delete menu->RemoveItem(--index);
delete menu->RemoveItem(--index);
}
// remove separator
item = menu->FindItem(B_CUT);
if (item) {
item = menu->ItemAt(menu->IndexOf(item)-1);
if (item && menu->RemoveItem(item))
delete item;
}
}
}
// add directory menu and menufield
fDirMenu = new BDirMenu(0, this, kSwitchDirectory, "refs");
font_height ht;
be_plain_font->GetHeight(&ht);
float f_height = ht.ascent + ht.descent + ht.leading;
BRect rect;
rect.top = fMenuBar->Bounds().Height() + 8;
rect.left = windRect.left + 8;
rect.right = rect.left + 300;
rect.bottom = rect.top + (f_height > 22 ? f_height : 22);
fDirMenuField = new BMenuField(rect, "DirMenuField", "", fDirMenu);
fDirMenuField->MenuBar()->SetFont(be_plain_font);
fDirMenuField->SetDivider(0);
fDirMenuField->MenuBar()->SetMaxContentWidth(rect.Width() - 26.0f);
// Make room for the icon
fDirMenuField->MenuBar()->RemoveItem((int32)0);
fDirMenu->SetMenuBar(fDirMenuField->MenuBar());
// the above is a weird call from BDirMenu
// ToDo: clean up
BEntry entry(TargetModel()->EntryRef());
if (entry.InitCheck() == B_OK)
fDirMenu->Populate(&entry, 0, true, true, false, true);
else
fDirMenu->Populate(0, 0, true, true, false, true);
fBackView->AddChild(fDirMenuField);
// add file name text view
if (fIsSavePanel) {
BRect rect(windRect);
rect.top = rect.bottom - 35;
rect.left = 8;
//.........这里部分代码省略.........
示例9: BMessage
void
MediaConverterWindow::BuildAudioVideoMenus()
{
BMenu* menu = fAudioMenu->Menu();
BMenuItem* item;
// clear out old audio codec menu items
while ((item = menu->RemoveItem((int32)0)) != NULL)
delete item;
bool separator = true;
// get selected file format
FileFormatMenuItem* ffmi
= (FileFormatMenuItem*)fFormatMenu->Menu()->FindMarked();
media_file_format* mf_format = &(ffmi->fFileFormat);
media_format format, outfmt;
memset(&format, 0, sizeof(format));
media_codec_info codec_info;
int32 cookie = 0;
CodecMenuItem* cmi;
// add available audio encoders to menu
format.type = B_MEDIA_RAW_AUDIO;
format.u.raw_audio = media_raw_audio_format::wildcard;
while (get_next_encoder(&cookie, mf_format, &format, &outfmt, &codec_info)
== B_OK) {
if (separator) {
menu->AddItem(new BMenuItem(
B_TRANSLATE_CONTEXT("No audio", "Audio codecs list"),
new BMessage(AUDIO_CODEC_SELECT_MESSAGE)));
menu->AddSeparatorItem();
separator = false;
}
cmi = new CodecMenuItem(&codec_info, AUDIO_CODEC_SELECT_MESSAGE);
menu->AddItem(cmi);
// reset media format struct
/*
format.type = B_MEDIA_RAW_AUDIO;
format.u.raw_audio = media_raw_audio_format::wildcard;
*/
}
// mark first audio encoder
item = menu->ItemAt(0);
if (item != NULL) {
fAudioMenu->SetEnabled(fEnabled);
fAudioQualitySlider->SetEnabled(fEnabled);
item->SetMarked(true);
((BInvoker*)item)->Invoke();
} else {
item = new BMenuItem(
B_TRANSLATE_CONTEXT("None available", "Audio codecs"), NULL);
menu->AddItem(item);
item->SetMarked(true);
fAudioMenu->SetEnabled(false);
fAudioQualitySlider->SetEnabled(false);
}
// clear out old video codec menu items
menu = fVideoMenu->Menu();
while ((item = menu->RemoveItem((int32)0)) != NULL)
delete item;
separator = true;
// construct a generic video format. Some of these parameters
// seem silly, but are needed for R4.5.x, which is more picky
// than subsequent BeOS releases will be.
memset(&format, 0, sizeof(format));
format.type = B_MEDIA_RAW_VIDEO;
format.u.raw_video.last_active = (uint32)(240 - 1);
format.u.raw_video.orientation = B_VIDEO_TOP_LEFT_RIGHT;
format.u.raw_video.display.format = B_RGB32;
format.u.raw_video.display.line_width = (int32)320;
format.u.raw_video.display.line_count = (int32)240;
format.u.raw_video.display.bytes_per_row = 4 * 320;
// add available video encoders to menu
cookie = 0;
while (get_next_encoder(&cookie, mf_format, &format, &outfmt, &codec_info)
== B_OK) {
if (separator) {
menu->AddItem(new BMenuItem(
B_TRANSLATE_CONTEXT("No video", "Video codecs list"),
new BMessage(VIDEO_CODEC_SELECT_MESSAGE)));
menu->AddSeparatorItem();
separator = false;
}
cmi = new CodecMenuItem(&codec_info, VIDEO_CODEC_SELECT_MESSAGE);
menu->AddItem(cmi);
}
// mark first video encoder
item = menu->ItemAt(0);
if (item != NULL) {
fVideoMenu->SetEnabled(fEnabled);
//.........这里部分代码省略.........
示例10: network
void
NetworkPrefsView::MessageReceived (BMessage * msg)
{
switch (msg->what)
{
case M_NETWORK_DEFAULTS:
if (fActiveNetwork.HasString ("name"))
vision_app->SetNetwork (fActiveNetwork.FindString ("name"), &fActiveNetwork);
fActiveNetwork = vision_app->GetNetwork ("defaults");
fNetworkMenu->MenuItem ()->SetLabel ("Defaults");
SetupDefaults (fActiveNetwork);
fDupeItem->SetEnabled (false);
fRemoveItem->SetEnabled (false);
break;
case M_CHOOSE_NETWORK:
{
BMenuItem *item (NULL);
msg->FindPointer ("source", reinterpret_cast < void **>(&item));
SaveCurrentNetwork ();
fActiveNetwork = vision_app->GetNetwork (item->Label ());
fNetworkMenu->MenuItem ()->SetLabel (item->Label ());
UpdatePersonalData (fActiveNetwork);
UpdateNetworkData (fActiveNetwork);
if (BMessenger (fServerPrefs).IsValid ())
fServerPrefs->SetNetworkData (&fActiveNetwork);
fDupeItem->SetEnabled (true);
fRemoveItem->SetEnabled (true);
}
break;
case M_ADD_NEW_NETWORK:
{
if (msg->HasString ("text"))
{
fNetPrompt = NULL;
BString network (msg->FindString ("text"));
network.RemoveAll (" ");
BMenu *menu (fNetworkMenu->Menu ());
for (int32 i = 0; i < menu->CountItems (); i++)
{
BMenuItem *item (menu->ItemAt (i));
if (item && network == item->Label ())
{
dynamic_cast < BInvoker * >(item)->Invoke ();
return;
}
}
BMessage newNet (VIS_NETWORK_DATA);
newNet.AddString ("name", network.String ());
vision_app->SetNetwork (network.String (), &newNet);
BMenuItem *item (new BMenuItem (network.String (), new BMessage (M_CHOOSE_NETWORK)));
menu->AddItem (item, 0);
item->SetTarget (this);
dynamic_cast < BInvoker * >(item)->Invoke ();
}
else
{
BString promptText = B_TRANSLATE("Network Name");
promptText += ": ";
fNetPrompt = new PromptWindow (BPoint (Window ()->Frame ().left + Window ()->Frame ().Width () / 2, Window ()->Frame ().top + Window ()->Frame ().Height () / 2),
promptText.String(), B_TRANSLATE("Add Network"), NULL, this, new BMessage (M_ADD_NEW_NETWORK), NULL, false);
fNetPrompt->Show ();
}
}
break;
case M_REMOVE_CURRENT_NETWORK:
{
const char *name (fActiveNetwork.FindString ("name"));
vision_app->RemoveNetwork (name);
BMenu *menu (fNetworkMenu->Menu ());
for (int32 i = 0; i < menu->CountItems (); i++)
{
BMenuItem *item (menu->ItemAt (i));
if (!strcmp (item->Label (), name))
{
delete menu->RemoveItem (i);
fActiveNetwork.MakeEmpty ();
dynamic_cast < BInvoker * >(menu->ItemAt (0))->Invoke ();
break;
}
}
}
break;
case M_DUPE_CURRENT_NETWORK:
{
if (msg->HasString ("text"))
{
fDupePrompt = NULL;
BString network (msg->FindString ("text"));
network.RemoveAll (" ");
BMenu *menu (fNetworkMenu->Menu ());
for (int32 i = 0; i < menu->CountItems (); i++)
{
BMenuItem *item (menu->ItemAt (i));
if (item && network == item->Label ())
{
dynamic_cast < BInvoker * >(item)->Invoke ();
//.........这里部分代码省略.........