当前位置: 首页>>代码示例>>C++>>正文


C++ BMenu::SetTargetForItems方法代码示例

本文整理汇总了C++中BMenu::SetTargetForItems方法的典型用法代码示例。如果您正苦于以下问题:C++ BMenu::SetTargetForItems方法的具体用法?C++ BMenu::SetTargetForItems怎么用?C++ BMenu::SetTargetForItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BMenu的用法示例。


在下文中一共展示了BMenu::SetTargetForItems方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: menuRect

GDWindow::GDWindow(BRect frame)
				: BWindow(frame, "GrafDemo 4.6", B_DOCUMENT_WINDOW,0)
{
	Lock();
	// Add the graph to the window
	BRect grafRect = Bounds();
	grafRect.top += mb_height + 2;
	mGraphView= new GDView(grafRect);
	AddChild(mGraphView);
	SetSizeLimits(frame.right - frame.left,9999,frame.bottom - frame.top,9999);

	// Add the main menu bar and menus
	BRect menuRect(0,0,1000,mb_height);
	BMenuBar* menuBar = new BMenuBar(menuRect,"MB");
	
	BMenu*	fileMenu = new BMenu("File");
	BMenuItem* aboutItem = new BMenuItem("About...",new BMessage(B_ABOUT_REQUESTED));
	aboutItem->SetTarget(be_app);
	fileMenu->AddItem(aboutItem);
	fileMenu->AddSeparatorItem();
	fileMenu->AddItem(new BMenuItem("Quit",new BMessage(B_QUIT_REQUESTED)));
	menuBar->AddItem(fileMenu);
	
	BMenu*	editMenu = new BMenu("Edit");
	editMenu->AddItem(new BMenuItem("Erase",new BMessage(G_erase_data)));
	editMenu->AddItem(new BMenuItem("Reset Axes",new BMessage(G_reset_axes)));
	editMenu->SetTargetForItems(mGraphView);
	menuBar->AddItem(editMenu);
	
	BMenu*	paramsMenu = new BMenu("Params");
	BMessage* cFitMesg = new BMessage(G_set_params);
	cFitMesg->AddInt16(pName,0);
	BMessage* p2Mesg = new BMessage(G_set_params);
	p2Mesg->AddInt16(pName,2);
	BMessage* p3Mesg = new BMessage(G_set_params);
	p3Mesg->AddInt16(pName,3);
	BMessage* p4Mesg = new BMessage(G_set_params);
	p4Mesg->AddInt16(pName,4);
	paramsMenu->AddItem(new BMenuItem("Cubic Spline",cFitMesg));
	paramsMenu->AddSeparatorItem();
	paramsMenu->AddItem(new BMenuItem("1st Order",p2Mesg));
	paramsMenu->AddItem(new BMenuItem("2nd Order",p3Mesg));
	paramsMenu->AddItem(new BMenuItem("3rd Order",p4Mesg));
	paramsMenu->SetRadioMode(true);
	paramsMenu->FindItem("2nd Order")->SetMarked(true);
	paramsMenu->SetTargetForItems(mGraphView);
	menuBar->AddItem(paramsMenu);

	BMenu*	axisMenu = new BMenu("Axes");
	axisMenu->AddItem(new BMenuItem("Set Axes"B_UTF8_ELLIPSIS,new BMessage(G_change_axis)));
	axisMenu->SetTargetForItems(mGraphView);
	menuBar->AddItem(axisMenu);

	AddChild(menuBar);
	
	Unlock();
}
开发者ID:HaikuArchives,项目名称:PlottingTools,代码行数:57,代码来源:GDWindow.cpp

示例2: r

S9xRefreshWindow::S9xRefreshWindow(BRect rect, BWindow *parent, uint32 closemsg)
	: BWindow(rect, "FullScreen - Refresh Rate", B_FLOATING_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
	fWindow(parent),
	fS9xMsg(closemsg)
{
	display_mode *modes;
	uint32 mode_count;
	
	if(BScreen().GetModeList(&modes, &mode_count) == B_NO_ERROR) {
		BMenu *menu = new BMenu("menu");
		for(unsigned int i = 0; i < mode_count; i++) {
		//	if((modes[i].virtual_width == 640) && (modes[i].space == B_RGB16)) {
				BMessage *msg = new BMessage(ID_REFRESH);
				msg->AddPointer("refr_rate", (void *)&modes[i]);
				BString item_name;
				item_name << (modes[i].timing.pixel_clock * 1000)
					/ (modes[i].timing.h_total * modes[i].timing.v_total) << " Hz";
				menu->AddItem(new BMenuItem(item_name.String(), msg));
		//	}
		}
		BRect r(20, 20, 200, 60);
		BMenuField *field = new BMenuField(r, "field", "Refresh Rate:", menu);
		AddChild(field);
		menu->SetLabelFromMarked(true);
		menu->ItemAt(0)->SetMarked(true);
		menu->SetTargetForItems(fWindow);
	}
	Show();
}
开发者ID:ModeenF,项目名称:snes9x_haiku,代码行数:29,代码来源:S9xRefreshWindow.cpp

示例3: BMenu

// SetMenu
void
TransformerListView::SetMenu(BMenu* menu)
{
	if (fMenu == menu)
		return;

	fMenu = menu;
	if (fMenu == NULL)
		return;

	BMenu* addMenu = new BMenu(B_TRANSLATE("Add"));
	int32 cookie = 0;
	uint32 type;
	BString name;
	while (TransformerFactory::NextType(&cookie, &type, &name)) {
		// TODO: Disable the "Transformation" and "Perspective" transformers
		// since they are not very useful or even implemented at all.
		if (name == B_TRANSLATE("Transformation") 
			|| name == B_TRANSLATE("Perspective"))
			continue;
		// End of TODO.
		BMessage* message = new BMessage(MSG_ADD_TRANSFORMER);
		message->AddInt32("type", type);
		addMenu->AddItem(new BMenuItem(name.String(), message));
	}
	addMenu->SetTargetForItems(this);
	fMenu->AddItem(addMenu);

	_UpdateMenu();
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:31,代码来源:TransformerListView.cpp

示例4:

void
AppearancePrefView::AttachedToWindow()
{
	fTabTitle->SetTarget(this);
	fWindowTitle->SetTarget(this);
	fBlinkCursor->SetTarget(this);
	fBrightInsteadOfBold->SetTarget(this);
	fWarnOnExit->SetTarget(this);

	fFontField->Menu()->SetTargetForItems(this);
	for (int32 i = 0; i < fFontField->Menu()->CountItems(); i++) {
		BMenu* fontSizeMenu = fFontField->Menu()->SubmenuAt(i);
		if (fontSizeMenu == NULL)
			continue;

		fontSizeMenu->SetTargetForItems(this);
	}

	fColorControl->SetTarget(this);
	fColorField->Menu()->SetTargetForItems(this);
	fColorSchemeField->Menu()->SetTargetForItems(this);
	fWindowSizeField->Menu()->SetTargetForItems(this);
	fEncodingField->Menu()->SetTargetForItems(this);

	_SetCurrentColorScheme();
}
开发者ID:,项目名称:,代码行数:26,代码来源:

示例5: GetFont

void
ControlView::_UpdateFontmenus(bool setInitialfont)
{
    BFont font;
    BMenu* stylemenu = NULL;

    font_family fontFamilyName, currentFamily;
    font_style fontStyleName, currentStyle;

    GetFont(&font);
    font.GetFamilyAndStyle(&currentFamily, &currentStyle);

    const int32 fontfamilies = count_font_families();

    fFontFamilyMenu->RemoveItems(0, fFontFamilyMenu->CountItems(), true);

    for (int32 i = 0; i < fontfamilies; i++) {
        if (get_font_family(i, &fontFamilyName) == B_OK) {
            stylemenu = new BMenu(fontFamilyName);
            const int32 styles = count_font_styles(fontFamilyName);

            BMessage* familyMsg = new BMessage(FONTFAMILY_CHANGED_MSG);
            familyMsg->AddString("_family", fontFamilyName);
            BMenuItem* familyItem = new BMenuItem(stylemenu, familyMsg);
            fFontFamilyMenu->AddItem(familyItem);

            for (int32 j = 0; j < styles; j++) {
                if (get_font_style(fontFamilyName, j, &fontStyleName) == B_OK) {
                    BMessage* fontMsg = new BMessage(FONTSTYLE_CHANGED_MSG);
                    fontMsg->AddString("_family", fontFamilyName);
                    fontMsg->AddString("_style", fontStyleName);

                    BMenuItem* styleItem = new BMenuItem(fontStyleName, fontMsg);
                    styleItem->SetMarked(false);

                    // setInitialfont is used when we attach the FontField
                    if (!strcmp(fontStyleName, currentStyle)
                            && !strcmp(fontFamilyName, currentFamily)
                            && setInitialfont) {
                        styleItem->SetMarked(true);
                        familyItem->SetMarked(true);

                        BString string;
                        string << currentFamily << " " << currentStyle;

                        if (fFontMenuField)
                            fFontMenuField->MenuItem()->SetLabel(string.String());
                    }
                    stylemenu->AddItem(styleItem);
                }
            }
        }
        stylemenu->SetRadioMode(true);
        stylemenu->SetTargetForItems(this);
    }

    fFontFamilyMenu->SetLabelFromMarked(true);
    fFontFamilyMenu->SetTargetForItems(this);
}
开发者ID:nielx,项目名称:haiku-serviceskit,代码行数:59,代码来源:ControlView.cpp

示例6:

/*! \brief Called to take special actions when the child views are attached.
	It's used to set correctly the divider for the BMenuField.
*/
void
BOptionPopUp::AllAttached()
{
	BMenu *menu = fMenuField->Menu();
	if (menu != NULL) {
		float labelWidth = fMenuField->StringWidth(fMenuField->Label());
		fMenuField->SetDivider(labelWidth + kLabelSpace);
		menu->SetTargetForItems(this);
	}
}
开发者ID:mmanley,项目名称:Antares,代码行数:13,代码来源:OptionPopUp.cpp

示例7: BMessage

void
MediaReplicant::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("", false, false);
		menu->SetFont(be_plain_font);

		menu->AddItem(new BMenuItem(
			B_TRANSLATE("Media preferences" B_UTF8_ELLIPSIS),
			new BMessage(kMsgOpenMediaSettings)));
		menu->AddItem(new BMenuItem(
			B_TRANSLATE("Sound preferences" B_UTF8_ELLIPSIS),
			new BMessage(kMsgOpenSoundSettings)));

		menu->AddSeparatorItem();

		menu->AddItem(new BMenuItem(B_TRANSLATE("Open MediaPlayer"),
			new BMessage(kMsgOpenMediaPlayer)));

		menu->AddSeparatorItem();

		BMenu* subMenu = new BMenu(B_TRANSLATE("Options"));
		menu->AddItem(subMenu);

		BMenuItem* item = new BMenuItem(B_TRANSLATE("Control physical output"),
			new BMessage(kMsgVolumeWhich));
		item->SetMarked(fVolumeWhich == VOLUME_USE_PHYS_OUTPUT);
		subMenu->AddItem(item);

		item = new BMenuItem(B_TRANSLATE("Beep"),
			new BMessage(kMsgToggleBeep));
		item->SetMarked(!fDontBeep);
		subMenu->AddItem(item);

		menu->SetTargetForItems(this);
		subMenu->SetTargetForItems(this);

		menu->Go(where, true, true, BRect(where - BPoint(4, 4),
			where + BPoint(4, 4)));
	} else {
		// Show VolumeWindow
		fVolumeSlider = new VolumeWindow(BRect(where.x, where.y,
			where.x + 207, where.y + 19), fDontBeep, fVolumeWhich);
		fVolumeSlider->Show();
	}
}
开发者ID:mmadia,项目名称:Haiku-services-branch,代码行数:52,代码来源:MediaReplicant.cpp

示例8: ChildAt

void
AccountView::AttachedToWindow()
{
	// Once we are attached to window, the GUI is already created
	// so we can set our window as target for messages
	for (int32 i = 0; i < CountChildren(); i++) {
		BView* child = ChildAt(i);

		BMenu* menu = dynamic_cast<BMenu*>(child);
		BMenuField* menuField
			= dynamic_cast<BMenuField*>(child);
		BTextControl* textControl
			= dynamic_cast<BTextControl*>(child);
		NotifyingTextView* textView
			= dynamic_cast<NotifyingTextView*>(child);
		BCheckBox* checkBox = dynamic_cast<BCheckBox*>(child);

		if (menuField)
			menu = menuField->Menu();

		if (menu) {
			for (int32 j = 0; j < menu->CountItems(); j++) {
				BMenuItem* item = menu->ItemAt(j);
				item->SetMessage(new BMessage(kChanged));
				item->SetTarget(Window());
			}

			menu->SetTargetForItems(Window());
		}

		if (textControl) {
			textControl->SetMessage(new BMessage(kChanged));
			textControl->SetTarget(Window());
		}

		if (checkBox) {
			checkBox->SetMessage(new BMessage(kChanged));
			checkBox->SetTarget(Window());
		}

		if (textView) {
			textView->SetMessage(new BMessage(kChanged));
			textView->SetTarget(Window());
		}
	}
}
开发者ID:Barrett17,项目名称:Caya,代码行数:46,代码来源:AccountView.cpp

示例9: PopupMenu

void BrowserWindow::PopupMenu( KParts::BrowserExtension* /*pcSource*/, const std::string& cURL )
{
#if 0
	m_pcPopupMenu	 = new os::Menu( Rect( 0, 0, 10, 10 ), "popup", ITEMS_IN_COLUMN );
//	Menu* pcSpeedMenu = new os::Menu( Rect( 0, 0, 10, 10 ), "Speed", ITEMS_IN_COLUMN );
  
//	m_pcPopupMenu->AddItem( pcSpeedMenu );

	os::Message* pcMsg;
	m_pcPopupMenu->AddItem( new os::MenuItem( "New window", new os::Message( ID_NEW_WINDOW ) ) );
	m_pcPopupMenu->AddItem( new os::MenuItem( "Reload", new os::Message( ID_RELOAD ) ) );
	
	if ( cURL.empty() == false ) {
	m_pcPopupMenu->AddItem( new os::MenuSeparator() );
	pcMsg = new os::Message( ID_OPEN_LINK );
	pcMsg->AddString( "url", cURL );
	m_pcPopupMenu->AddItem( new os::MenuItem( "Open link in new window", pcMsg ) );

	
	pcMsg = new os::Message( ID_SAVE_LINK );
	pcMsg->AddString( "url", cURL );
	m_pcPopupMenu->AddItem( new os::MenuItem( "Save link as...", pcMsg ) );
	
	pcMsg = new os::Message( ID_COPY_LINK_LOCATION );
	pcMsg->AddString( "url", cURL );
	m_pcPopupMenu->AddItem( new os::MenuItem( "Copy link location", pcMsg ) );
	}
//	m_pcPopupMenu->AddItem( new os::MenuItem( "View document source", new os::Message( ID_VIEW_DOC_SRC ) ) );
//	pcMsg = new os::Message( ID_VIEW_FRAME_SRC );
//	pcMsg->AddPointer( "browser", pcSource );
//	m_pcPopupMenu->AddItem( new os::MenuItem( "View frame source",	new os::Message( ID_VIEW_FRAME_SRC ) ) );
	m_pcPopupMenu->AddItem( new os::MenuSeparator() );
	m_pcPopupMenu->AddItem( new os::MenuItem( "Quit", new os::Message( M_QUIT ) ) );

	m_pcPopupMenu->SetTargetForItems( this );

	os::Point cMousePos;
	m_pcStatusBar->GetMouse( &cMousePos, NULL );
	m_pcPopupMenu->Open( m_pcStatusBar->ConvertToScreen( cMousePos ) );	
#endif

}
开发者ID:BackupTheBerlios,项目名称:nirvana-svn,代码行数:42,代码来源:main.cpp

示例10: BuildGUI

void PictureTestWindow::BuildGUI()
{
	BView* backdrop = new BView(Bounds(), "backdrop", B_FOLLOW_ALL, B_WILL_DRAW);
	backdrop->SetViewColor(::ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(backdrop);
	
	BMenuBar* mb = new BMenuBar(Bounds(), "menubar");
	BMenu* m = new BMenu("File");
		m->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q'));
		m->SetTargetForItems(be_app_messenger);
	mb->AddItem(m);

	m = new BMenu("Tests");
		m->AddItem(new BMenuItem("Run", new BMessage(kMsgRunTests), 'R'));
		m->AddItem(new BMenuItem("Run Color Space B_RGB32", new BMessage(kMsgRunTests1), 'S'));
	mb->AddItem(m);

	backdrop->AddChild(mb);

	BRect b = Bounds();
	b.top = mb->Bounds().bottom + 1;
	
	fHeader = new BStringView(b, "header", 
		"X", B_FOLLOW_LEFT | B_FOLLOW_RIGHT | B_FOLLOW_TOP);
	float width, height;
	fHeader->GetPreferredSize(&width, &height);
	fHeader->ResizeTo(b.Width(), height);
	backdrop->AddChild(fHeader);
	b.top = fHeader->Frame().bottom + 1;
	
	b.right -= B_V_SCROLL_BAR_WIDTH;
	b.bottom -= B_H_SCROLL_BAR_HEIGHT;
	fListView = new BListView(b, "Results", B_SINGLE_SELECTION_LIST, 
		B_FOLLOW_ALL_SIDES, 
		B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE);
	backdrop->AddChild(new BScrollView("scroll_results", fListView, B_FOLLOW_ALL_SIDES, 0, true, true));	

	UpdateHeader();
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:39,代码来源:PictureTestWindow.cpp

示例11: showContextMenu

void MediaNodePanel::showContextMenu(
	BPoint point)
{
	D_METHOD(("MediaNodePanel::showContextMenu()\n"));

	BPopUpMenu *menu = new BPopUpMenu("MediaNodePanel PopUp", false, false, B_ITEMS_IN_COLUMN);
	menu->SetFont(be_plain_font);

	BMenuItem *item;
	BMessage *message;

	// add the "Tweak Parameters" item
	message = new BMessage(MediaRoutingView::M_NODE_TWEAK_PARAMETERS);
	menu->AddItem(item = new BMenuItem("Tweak parameters", message, 'P'));
	if (!(ref->kind() & B_CONTROLLABLE))
	{
		item->SetEnabled(false);
	}

	message = new BMessage(InfoWindowManager::M_INFO_WINDOW_REQUESTED);
	message->AddInt32("nodeID", ref->id());
	menu->AddItem(new BMenuItem("Get info", message, 'I'));
	menu->AddSeparatorItem();

	menu->AddItem(item = new BMenuItem("Release", new BMessage(MediaRoutingView::M_DELETE_SELECTION), 'T'));
	if (!ref->isInternal())
	{
		item->SetEnabled(false);
	}
	menu->AddSeparatorItem();

	// add the "Cycle" item
	message = new BMessage(MediaRoutingView::M_NODE_CHANGE_CYCLING);
	message->AddBool("cycle", !ref->isCycling());
	menu->AddItem(item = new BMenuItem("Cycle", message));
	item->SetMarked(ref->isCycling());
	if (ref->flags() & NodeRef::NO_SEEK)
	{
		item->SetEnabled(false);
	}

	// add the "Run Mode" sub menu
	BMenu *subMenu = new BMenu("Run mode");
	subMenu->SetFont(be_plain_font);
	for (uint32 runMode = 1; runMode <= BMediaNode::B_RECORDING; runMode++)
	{
		BString itemName = MediaString::getStringFor(static_cast<BMediaNode::run_mode>
													 (runMode));
		message = new BMessage(MediaRoutingView::M_NODE_CHANGE_RUN_MODE);
		message->AddInt32("run_mode", runMode);
		subMenu->AddItem(item = new BMenuItem(itemName.String(), message));
		if (ref->runMode() == runMode)
		{
			item->SetMarked(true);
		}
		else if ((ref->runMode() == 0)
			  && (ref->group()) && (ref->group()->runMode() == BMediaNode::run_mode(runMode)))
		{
			item->SetMarked(true);
		}
	}
	subMenu->AddSeparatorItem();
	message = new BMessage(MediaRoutingView::M_NODE_CHANGE_RUN_MODE);
	message->AddInt32("run_mode", 0);
	subMenu->AddItem(item = new BMenuItem("(same as group)", message));
	if (ref->group() == 0)
	{
		item->SetEnabled(false);
	}
	else if ((ref->runMode() < 1) && (ref->group()->runMode() > 0))
	{
		item->SetMarked(true);
	}
	menu->AddItem(subMenu);
	subMenu->SetTargetForItems(view());
	
	// [c.lenz 24dec99] hide rarely used commands in a 'Advanced' submenu
	subMenu = new BMenu("Advanced");
	subMenu->SetFont(be_plain_font);
	// [e.moon 5dec99] ad-hoc timesource support
	if(ref->kind() & B_TIME_SOURCE) {
		message = new BMessage(MediaRoutingView::M_NODE_START_TIME_SOURCE);
		message->AddInt32("nodeID", ref->id());
		subMenu->AddItem(new BMenuItem(
			"Start time source",
			message));
		message = new BMessage(MediaRoutingView::M_NODE_START_TIME_SOURCE);
		message->AddInt32("nodeID", ref->id());
		subMenu->AddItem(new BMenuItem(
			"Stop time source",
			message));
	}
	// [c.lenz 24dec99] support for BControllable::StartControlPanel()
	if(ref->kind() & B_CONTROLLABLE) {
		if (subMenu->CountItems() > 0)
			subMenu->AddSeparatorItem();
		message = new BMessage(MediaRoutingView::M_NODE_START_CONTROL_PANEL);
		subMenu->AddItem(new BMenuItem("Start Control Panel", message,
									   'P', B_COMMAND_KEY | B_SHIFT_KEY));
	}
//.........这里部分代码省略.........
开发者ID:AmirAbrams,项目名称:haiku,代码行数:101,代码来源:MediaNodePanel.cpp

示例12: BMessage

bool
TDeskbarMenu::AddStandardDeskbarMenuItems()
{
	bool dragging = false;
	if (fBarView)
		dragging = fBarView->Dragging();

	BMenuItem* item;

// One of them is used if HAIKU_DISTRO_COMPATIBILITY_OFFICIAL, and the other if
// not. However, we want both of them to end up in the catalog, so we have to
// make them visible to collectcatkeys in either case.
B_TRANSLATE_MARK_VOID("About Haiku")
B_TRANSLATE_MARK_VOID("About this system")

	item = new BMenuItem(
#ifdef HAIKU_DISTRO_COMPATIBILITY_OFFICIAL
	B_TRANSLATE_NOCOLLECT("About Haiku")
#else
	B_TRANSLATE_NOCOLLECT("About this system")
#endif
		, new BMessage(kShowSplash));
	item->SetEnabled(!dragging);
	AddItem(item);

	static const char* kFindMenuItemStr
		= B_TRANSLATE_MARK("Find" B_UTF8_ELLIPSIS);

#ifdef SHOW_RECENT_FIND_ITEMS
	item = new BMenuItem(
		TrackerBuildRecentFindItemsMenu(kFindMenuItemStr),
		new BMessage(kFindButton));
#else
	item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kFindMenuItemStr),
		new BMessage(kFindButton));
#endif
	item->SetEnabled(!dragging);
	AddItem(item);

	item = new BMenuItem(B_TRANSLATE("Show replicants"),
		new BMessage(kToggleDraggers));
	item->SetEnabled(!dragging);
	item->SetMarked(BDragger::AreDraggersDrawn());
	AddItem(item);

	static const char* kMountMenuStr = B_TRANSLATE_MARK("Mount");

#ifdef MOUNT_MENU_IN_DESKBAR
	DeskbarMountMenu* mountMenu = new DeskbarMountMenu(
		B_TRANSLATE_NOCOLLECT(kMountMenuStr));
	mountMenu->SetEnabled(!dragging);
	AddItem(mountMenu);
#endif

	item = new BMenuItem(B_TRANSLATE("Deskbar preferences" B_UTF8_ELLIPSIS),
		new BMessage(kConfigShow));
	item->SetTarget(be_app);
	AddItem(item);

	AddSeparatorItem();

	BMenu* shutdownMenu = new BMenu(B_TRANSLATE("Shutdown" B_UTF8_ELLIPSIS));

	item = new BMenuItem(B_TRANSLATE("Restart system"),
		new BMessage(kRebootSystem));
	item->SetEnabled(!dragging);
	shutdownMenu->AddItem(item);

	B_TRANSLATE_MARK_VOID("Suspend");

#ifdef APM_SUPPORT
	if (_kapm_control_(APM_CHECK_ENABLED) == B_OK) {
		item = new BMenuItem(B_TRANSLATE_NOCOLLECT("Suspend"),
			new BMessage(kSuspendSystem));
		item->SetEnabled(!dragging);
		shutdownMenu->AddItem(item);
	}
#endif

	item = new BMenuItem(B_TRANSLATE("Power off"),
		new BMessage(kShutdownSystem));
	item->SetEnabled(!dragging);
	shutdownMenu->AddItem(item);
	shutdownMenu->SetFont(be_plain_font);

	shutdownMenu->SetTargetForItems(be_app);
	BMessage* message = new BMessage(kShutdownSystem);
	message->AddBool("confirm", true);
	AddItem(new BMenuItem(shutdownMenu, message));

	fAddState = kAddingRecents;

	return true;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:94,代码来源:DeskbarMenu.cpp

示例13: BMessage


//.........这里部分代码省略.........
	message->AddInt32("mode", EndianModeLittleEndian);
	item = new BMenuItem("Little Endian", message, 'L');
	endianMenu->AddItem(item);
	message = new BMessage(*message);
	message->ReplaceInt32("mode", EndianModeBigEndian);
	item = new BMenuItem("Big Endian", message, 'B');
	endianMenu->AddItem(item);

	BMenu* textMenu = new BMenu("Text Mode");
	message = new BMessage(MSG_SET_TEXT_MODE);
	message->AddInt32("mode", TextModeNone);
	item = new BMenuItem("<None>", message, 'N');
	textMenu->AddItem(item);
	message = new BMessage(*message);
	message->ReplaceInt32("mode", TextModeASCII);
	item = new BMenuItem("ASCII", message, 'A');
	textMenu->AddItem(item);

	BLayoutBuilder::Group<>(this, B_VERTICAL)
		.SetInsets(B_USE_DEFAULT_SPACING)
		.AddGroup(B_HORIZONTAL)
			.Add(fAddressInput = new BTextControl("addrInput",
			"Target Address:", "",
			new BMessage(MSG_INSPECT_ADDRESS)))
			.Add(fPreviousBlockButton = new BButton("navPrevious", "<",
				new BMessage(MSG_NAVIGATE_PREVIOUS_BLOCK)))
			.Add(fNextBlockButton = new BButton("navNext", ">",
				new BMessage(MSG_NAVIGATE_NEXT_BLOCK)))
		.End()
		.AddGroup(B_HORIZONTAL)
			.Add(fHexMode = new BMenuField("hexMode", "Hex Mode:",
				hexMenu))
			.AddGlue()
			.Add(fEndianMode = new BMenuField("endianMode", "Endian Mode:",
				endianMenu))
			.AddGlue()
			.Add(fTextMode = new BMenuField("viewMode",  "Text Mode:",
				textMenu))
		.End()
		.Add(scrollView = new BScrollView("memory scroll",
			NULL, 0, false, true), 3.0f)
		.AddGroup(B_HORIZONTAL)
			.Add(fWritableBlockIndicator = new BStringView("writableIndicator",
				_GetCurrentWritableIndicator()))
			.AddGlue()
			.Add(fEditBlockButton = new BButton("editBlock", "Edit",
				new BMessage(MSG_EDIT_CURRENT_BLOCK)))
			.Add(fCommitBlockButton = new BButton("commitBlock", "Commit",
				new BMessage(MSG_COMMIT_MODIFIED_BLOCK)))
			.Add(fRevertBlockButton = new BButton("revertBlock", "Revert",
				new BMessage(MSG_REVERT_MODIFIED_BLOCK)))
		.End()
	.End();

	fHexMode->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
	fEndianMode->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
	fTextMode->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);

	int32 targetEndian = fTeam->GetArchitecture()->IsBigEndian()
		? EndianModeBigEndian : EndianModeLittleEndian;

	scrollView->SetTarget(fMemoryView = MemoryView::Create(fTeam, this));

	fAddressInput->SetTarget(this);
	fPreviousBlockButton->SetTarget(this);
	fNextBlockButton->SetTarget(this);
	fPreviousBlockButton->SetEnabled(false);
	fNextBlockButton->SetEnabled(false);

	fEditBlockButton->SetTarget(this);
	fCommitBlockButton->SetTarget(this);
	fRevertBlockButton->SetTarget(this);

	fEditBlockButton->SetEnabled(false);
	fCommitBlockButton->Hide();
	fRevertBlockButton->Hide();

	hexMenu->SetLabelFromMarked(true);
	hexMenu->SetTargetForItems(fMemoryView);
	endianMenu->SetLabelFromMarked(true);
	endianMenu->SetTargetForItems(fMemoryView);
	textMenu->SetLabelFromMarked(true);
	textMenu->SetTargetForItems(fMemoryView);

	// default to 8-bit format w/ text display
	hexMenu->ItemAt(1)->SetMarked(true);
	textMenu->ItemAt(1)->SetMarked(true);

	if (targetEndian == EndianModeBigEndian)
		endianMenu->ItemAt(1)->SetMarked(true);
	else
		endianMenu->ItemAt(0)->SetMarked(true);

	fAddressInput->TextView()->MakeFocus(true);

	AddShortcut(B_LEFT_ARROW, B_COMMAND_KEY, new BMessage(
			MSG_NAVIGATE_PREVIOUS_BLOCK));
	AddShortcut(B_RIGHT_ARROW, B_COMMAND_KEY, new BMessage(
			MSG_NAVIGATE_NEXT_BLOCK));
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:101,代码来源:InspectorWindow.cpp

示例14: BMessage

bool
TBeMenu::AddStandardBeMenuItems()
{
	bool dragging = false;
	if (fBarView)
		dragging = fBarView->Dragging();

	BMenuItem* item = new BMenuItem(
#ifdef ANTARES_DISTRO_COMPATIBILITY_OFFICIAL
	"About Antares"
#else
	"About this system"
#endif
		B_UTF8_ELLIPSIS, new BMessage(kShowSplash));
	item->SetEnabled(!dragging);
	AddItem(item);

#ifdef SHOW_RECENT_FIND_ITEMS
	item = new BMenuItem(TrackerBuildRecentFindItemsMenu("Find"B_UTF8_ELLIPSIS),
		new BMessage(kFindButton));
#else
 	item = new BMenuItem("Find"B_UTF8_ELLIPSIS, new BMessage(kFindButton));
#endif
	item->SetEnabled(!dragging);
	AddItem(item);

	item = new BMenuItem("Show replicants", new BMessage(kToggleDraggers));
	item->SetEnabled(!dragging);
	item->SetMarked(BDragger::AreDraggersDrawn());
	AddItem(item);

#ifdef MOUNT_MENU_IN_DESKBAR
	DeskbarMountMenu* mountMenu = new DeskbarMountMenu("Mount");
	mountMenu->SetEnabled(!dragging);
	AddItem(mountMenu);
#endif

	item = new BMenuItem("Deskbar preferences" B_UTF8_ELLIPSIS,
		new BMessage(kConfigShow));
 	item->SetTarget(be_app);
	AddItem(item);

	AddSeparatorItem();

	BMenu* shutdownMenu = new BMenu("Shutdown" B_UTF8_ELLIPSIS);

	item = new BMenuItem("Restart system", new BMessage(kRebootSystem));
	item->SetEnabled(!dragging);
	shutdownMenu->AddItem(item);

#ifdef APM_SUPPORT
	if (_kapm_control_(APM_CHECK_ENABLED) == B_OK) {
		item = new BMenuItem("Suspend", new BMessage(kSuspendSystem));
		item->SetEnabled(!dragging);
		shutdownMenu->AddItem(item);
	}
#endif

	item = new BMenuItem("Power off", new BMessage(kShutdownSystem));
	item->SetEnabled(!dragging);
	shutdownMenu->AddItem(item);
	shutdownMenu->SetFont(be_plain_font);

	shutdownMenu->SetTargetForItems(be_app);
	BMessage* message = new BMessage(kShutdownSystem);
	message->AddBool("confirm", true);
	AddItem(new BMenuItem(shutdownMenu, message));

	fAddState = kAddingRecents;

	return true;
}
开发者ID:mmanley,项目名称:Antares,代码行数:72,代码来源:BeMenu.cpp

示例15: BMessage


//.........这里部分代码省略.........
	BScrollView* unicodeScroller = new BScrollView("unicodeScroller",
		fUnicodeBlockView, 0, false, true);

	fCharacterView = new CharacterView("characters");
	fCharacterView->SetTarget(this, kMsgCharacterChanged);

	// TODO: have a context object shared by CharacterView/UnicodeBlockView
	bool show;
	if (settings.FindBool("show private blocks", &show) == B_OK) {
		fCharacterView->ShowPrivateBlocks(show);
		fUnicodeBlockView->ShowPrivateBlocks(show);
	}
	if (settings.FindBool("show contained blocks only", &show) == B_OK) {
		fCharacterView->ShowContainedBlocksOnly(show);
		fUnicodeBlockView->ShowPrivateBlocks(show);
	}

	const char* family;
	const char* style;
	if (settings.FindString("font family", &family) == B_OK
		&& settings.FindString("font style", &style) == B_OK) {
		_SetFont(family, style);
	}

	int32 fontSize;
	if (settings.FindInt32("font size", &fontSize) == B_OK) {
		BFont font = fCharacterView->CharacterFont();
		if (fontSize < kMinFontSize)
			fontSize = kMinFontSize;
		else if (fontSize > kMaxFontSize)
			fontSize = kMaxFontSize;
		font.SetSize(fontSize);

		fCharacterView->SetCharacterFont(font);
	} else
		fontSize = (int32)fCharacterView->CharacterFont().Size();

	BScrollView* characterScroller = new BScrollView("characterScroller",
		fCharacterView, 0, false, true);

	fFontSizeSlider = new FontSizeSlider("fontSizeSlider", "Font size:",
		new BMessage(kMsgFontSizeChanged), kMinFontSize, kMaxFontSize);
	fFontSizeSlider->SetValue(fontSize);

	fCodeView = new BStringView("code", "-");
	fCodeView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED,
		fCodeView->PreferredSize().Height()));

	AddChild(BGroupLayoutBuilder(B_VERTICAL)
		.Add(menuBar)
		.Add(BGroupLayoutBuilder(B_HORIZONTAL, 10)//BSplitLayoutBuilder()
			.Add(BGroupLayoutBuilder(B_VERTICAL, 10)
				.Add(BGroupLayoutBuilder(B_HORIZONTAL, 10)
					.Add(fFilterControl)
					.Add(clearButton))
				.Add(unicodeScroller))
			.Add(BGroupLayoutBuilder(B_VERTICAL, 10)
				.Add(characterScroller)
				.Add(fFontSizeSlider)
				.Add(fCodeView))
			.SetInsets(10, 10, 10, 10)));

	// Add menu

	// "File" menu
	BMenu* menu = new BMenu("File");
	BMenuItem* item;

	menu->AddItem(item = new BMenuItem("About CharacterMap" B_UTF8_ELLIPSIS,
		new BMessage(B_ABOUT_REQUESTED)));

	menu->AddSeparatorItem();

	menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q'));
	menu->SetTargetForItems(this);
	item->SetTarget(be_app);
	menuBar->AddItem(menu);

	menu = new BMenu("View");
	menu->AddItem(item = new BMenuItem("Show private blocks",
		new BMessage(kMsgPrivateBlocks)));
	item->SetMarked(fCharacterView->IsShowingPrivateBlocks());
// TODO: this feature is not yet supported by Haiku!
#if 0
	menu->AddItem(item = new BMenuItem("Only show blocks contained in font",
		new BMessage(kMsgContainedBlocks)));
	item->SetMarked(fCharacterView->IsShowingContainedBlocksOnly());
#endif
	menuBar->AddItem(menu);

	menuBar->AddItem(_CreateFontMenu());

	AddCommonFilter(new EscapeMessageFilter(kMsgClearFilter));
	AddCommonFilter(new RedirectUpAndDownFilter(fUnicodeBlockView));

	// TODO: why is this needed?
	fUnicodeBlockView->SetTarget(this);

	fFilterControl->MakeFocus();
}
开发者ID:mariuz,项目名称:haiku,代码行数:101,代码来源:CharacterWindow.cpp


注:本文中的BMenu::SetTargetForItems方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。