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


C++ BMenuBar类代码示例

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


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

示例1: BWindow

BeCheckersWindow::BeCheckersWindow(BRect frame, const char *title)
					: BWindow(frame,
							  title,
							  B_TITLED_WINDOW,
							  B_NOT_RESIZABLE | B_NOT_ZOOMABLE) {
	BMenuBar *mb = new BMenuBar(BRect(0, 0, frame.right, 15), "MenuBar");
	BMenu *menu = new BMenu("File");
	menu->AddItem(new BMenuItem("New", new BMessage(BECHECKERS_NEW), 'N'));
	menu->AddItem(new BMenuItem("Open...", new BMessage(BECHECKERS_OPEN), 'O'));
	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem("Save", new BMessage(BECHECKERS_SAVE), 'S'));
	menu->AddItem(new BMenuItem("Save As", new BMessage(BECHECKERS_SAVEAS)));
	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem("About BeCheckers...", new BMessage(B_ABOUT_REQUESTED)));
	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q'));
	mb->AddItem(menu);
	AddChild(mb);

	mvIndicationLabel = new BStringView(BRect(0, 472, 450, 485), "Status", "Dark to move");
	mvIndicationLabel->SetViewColor(232, 232, 232);
	mvIndicationLabel->SetAlignment(B_ALIGN_CENTER);
	AddChild(mvIndicationLabel);

	StartGame();
}
开发者ID:noryb009,项目名称:BeCheckers,代码行数:26,代码来源:BeCheckersWindow.cpp

示例2: receive_data

/*static*/ int32
BMenuBar::_TrackTask(void* arg)
{
	menubar_data data;
	thread_id id;
	receive_data(&id, &data, sizeof(data));

	BMenuBar* menuBar = data.menuBar;
	if (data.useRect)
		menuBar->fExtraRect = &data.rect;
	menuBar->_SetStickyMode(data.sticky);

	int32 action;
	menuBar->_Track(&action, data.menuIndex, data.showMenu);

	menuBar->fTracking = false;
	menuBar->fExtraRect = NULL;

	// We aren't the BWindow thread, so don't call MenusEnded() directly
	BWindow* window = menuBar->Window();
	window->PostMessage(_MENUS_DONE_);

	_set_menu_sem_(window, B_BAD_SEM_ID);
	delete_sem(menuBar->fMenuSem);
	menuBar->fMenuSem = B_BAD_SEM_ID;

	return 0;
}
开发者ID:,项目名称:,代码行数:28,代码来源:

示例3: BMenuBar

void SeqStudioWindow::AddMainMenu(BRect f)
{
	BMenuBar*		menuBar;
	BMenu*			menu;
	BMenuItem*		item;
	menuBar = new BMenuBar(	f, NULL, B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT,
							B_ITEMS_IN_ROW, FALSE);
	/* Entry Menu
	 */
	mPortMenu = new BMenu("MIDI Port", B_ITEMS_IN_COLUMN);
	add_menu_item(mPortMenu,	DELETE_STR,		DELETE_PORT_MSG,		'T');
	item = new BMenuItem(mPortMenu);
	menuBar->AddItem(mPortMenu, ENTRY_MENU_INDEX);

	/* Attributes Menu
	 */
	menu = new BMenu("Attributes", B_ITEMS_IN_COLUMN);
	item = new BMenuItem(menu);
	menuBar->AddItem(item, ATTRIBUTES_MENU_INDEX);
	add_attribute_item(menu, MIDI_PORT_STR);
	add_attribute_item(menu, TYPE_STR);
	add_attribute_item(menu, DEVICE_STR);
	add_attribute_item(menu, LABEL_STR);

	AddChild(menuBar);
	SetKeyMenuBar(menuBar);
}
开发者ID:dtbinh,项目名称:Sequitur,代码行数:27,代码来源:SeqStudioWindow.cpp

示例4: BWindow

ReloadedWin::ReloadedWin()
    : BWindow(BRect(80,80,847,619),"Reloaded", B_TITLED_WINDOW,
              B_NOT_ZOOMABLE|B_NOT_RESIZABLE|B_QUIT_ON_WINDOW_CLOSE)
{
    // TODO - compute the size instead of hardcoding it
    SetSizeLimits(847-80,847-80,619-61,619-61);

    BMenuBar* menu = new BMenuBar(BRect(0,0,Bounds().Width() - 16,16),
                                  "mainmenu", B_FOLLOW_LEFT | B_FOLLOW_TOP);
    BMenu* file = new BMenu("File");
    menu->AddItem(file);
    BMenuItem* insertdsk = new BMenuItem("Insert Disc",
                                         new BMessage('dins'));
    file->AddItem(insertdsk);

    BMenu* settings = new BMenu("Settings");
    menu->AddItem(settings);
    BMenuItem* keymap = new BMenuItem("Keymap",
                                      new BMessage('kymp'));
    settings->AddItem(keymap);
    AddChild(menu);

    fStatusLed = new BView(BRect(Bounds().Width() - 16, 0, Bounds().Width(), 16), "fdcLed",
                           B_FOLLOW_RIGHT | B_FOLLOW_TOP, B_WILL_DRAW);
    fStatusLed->SetViewColor(0x77,00,00);
    AddChild(fStatusLed);

    fBitmapView = new RBitmapView(this, false);
    fBitmapView->MoveTo(0, menu->Bounds().bottom + 1);

    Show();
}
开发者ID:pedgarcia,项目名称:cpcsdk,代码行数:32,代码来源:RWin.cpp

示例5: BApplication

StyledEditApp::StyledEditApp()
	:
	BApplication(APP_SIGNATURE),
	fOpenPanel(NULL)
{
	B_TRANSLATE_MARK_SYSTEM_NAME_VOID("StyledEdit");

	fOpenPanel = new BFilePanel();
	fOpenAsEncoding = 0;

	BMenuBar* menuBar
		= dynamic_cast<BMenuBar*>(fOpenPanel->Window()->FindView("MenuBar"));
	if (menuBar != NULL) {
		fOpenPanelEncodingMenu = new BMenu(B_TRANSLATE("Encoding"));
		fOpenPanelEncodingMenu->SetRadioMode(true);

		menuBar->AddItem(fOpenPanelEncodingMenu);

		BCharacterSetRoster roster;
		BCharacterSet charset;
		while (roster.GetNextCharacterSet(&charset) == B_NO_ERROR) {
			BString name;
			if (charset.GetFontID() == B_UNICODE_UTF8)
				name = B_TRANSLATE("Default");
			else
				name = charset.GetPrintName();

			const char* mime = charset.GetMIMEName();
			if (mime != NULL) {
				name.Append(" (");
				name.Append(mime);
				name.Append(")");
			}
			BMenuItem* item
				= new BMenuItem(name.String(), new BMessage(OPEN_AS_ENCODING));
			item->SetTarget(this);
			fOpenPanelEncodingMenu->AddItem(item);
			if (charset.GetFontID() == fOpenAsEncoding)
				item->SetMarked(true);
		}
	} else
		fOpenPanelEncodingMenu = NULL;

	fWindowCount = 0;
	fNextUntitledWindow = 1;
	fBadArguments = false;

	float factor = be_plain_font->Size() / 12.0f;
	sCascadeOffset *= factor;
	sTopLeft.x *= factor;
	sTopLeft.y *= factor;
	sWindowRect.left *= factor;
	sWindowRect.top *= factor;
	sWindowRect.right *= factor;
	sWindowRect.bottom *= factor;
	sWindowRect.PrintToStream();
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:57,代码来源:StyledEditApp.cpp

示例6: BWindow

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

示例7: BMenuBar

BMenuBar*
FaberView::BuildMainMenuBar()
{
	BMenuBar* menuBar = new BMenuBar("MainMenuBar");

	RecentsMenuBuilder builder;
	fFileMenu = MenuBuilder::BuildMenu(kFileMenu, NULL, &builder);
	menuBar->AddItem(fFileMenu);

	fEditMenu = MenuBuilder::BuildMenu(kEditMenu);
	menuBar->AddItem(fEditMenu);

	fProjectMenu = MenuBuilder::BuildMenu(kProjectMenu);
	menuBar->AddItem(fProjectMenu);

	fTracksMenu = MenuBuilder::BuildMenu(kTracksMenu);
	menuBar->AddItem(fTracksMenu);

	fEffectsMenu = BuildEffectsMenu();
	menuBar->AddItem(fEffectsMenu);

	fGenerateMenu = BuildGenerateMenu();
	menuBar->AddItem(fGenerateMenu);

	fEngineMenu = MenuBuilder::BuildMenu(kEngineMenu);
	menuBar->AddItem(fEngineMenu);

	menuBar->AddItem(MenuBuilder::BuildMenu(kHelpMenu));

	return menuBar;
}
开发者ID:Barrett17,项目名称:Faber,代码行数:31,代码来源:FaberView.cpp

示例8: BWindow

MainWindow::MainWindow(void)
	:	BWindow(BRect(5,25,250,350),"PDesigner",B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS),
		fProject(NULL)
{
	BRect r(Bounds());
	r.bottom = 20;
	BMenuBar *bar = new BMenuBar(r,"menubar");
	AddChild(bar);
	
	r = Bounds();
	r.top = 21;
	BView *top = new BView(r, "top", B_FOLLOW_ALL, B_WILL_DRAW);
	AddChild(top);
	top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	
	r = top->Bounds();
	r.right -= B_V_SCROLL_BAR_WIDTH;
	r.bottom -= B_H_SCROLL_BAR_HEIGHT;
	fListView = new BOutlineListView(r,"listview",B_SINGLE_SELECTION_LIST,B_FOLLOW_ALL);
	BScrollView *scroll = new BScrollView("listscroll",fListView,B_FOLLOW_ALL,0,true,true);
	top->AddChild(scroll);
	fListView->SetSelectionMessage(new BMessage(M_OBJECT_SELECTED));
	
	BMenu *menu = new BMenu("File");
	menu->AddItem(new BMenuItem("New Project",new BMessage(M_NEW_PROJECT),'N', B_COMMAND_KEY));
	bar->AddItem(menu);
	
	menu = new BMenu("Project");
	menu->AddItem(new BMenuItem("Add Window",new BMessage(M_ADD_WINDOW),'A'));
	
	BMessage *menumsg = new BMessage(M_ADD_CONTROL);
	menumsg->AddString("type","PView");
	menu->AddItem(new BMenuItem("Add View",menumsg,'V'));

	menumsg = new BMessage(M_ADD_CONTROL);
	menumsg->AddString("type","PButton");
	menu->AddItem(new BMenuItem("Add Button",menumsg));
	
	menumsg = new BMessage(M_ADD_CONTROL);
	menumsg->AddString("type","PCheckBox");
	menu->AddItem(new BMenuItem("Add Check Box",menumsg));
	
	menu->AddItem(new BMenuItem("Delete Item",new BMessage(M_REMOVE_SELECTED),'D'));
	bar->AddItem(menu);
	
	menu = new BMenu("Window");
	menu->AddItem(new BMenuItem("Toggle Properties",new BMessage(M_TOGGLE_PROPERTY_WIN)));
	bar->AddItem(menu);
	
	fPropertyWin = new PropertyWindow();
	fPropertyWin->Show();
	
	fObjectWin = new ObjectWindow(BMessenger(this));
	fObjectWin->Show();
}
开发者ID:HaikuArchives,项目名称:PDesigner,代码行数:55,代码来源:MainWindow.cpp

示例9: BMenuBar

BMenuBar*
KeymapWindow::_CreateMenu()
{
	BMenuBar* menuBar = new BMenuBar(Bounds(), "menubar");
	BMenuItem* item;

	// Create the File menu
	BMenu* menu = new BMenu(TR("File"));
	menu->AddItem(new BMenuItem(TR("Open" B_UTF8_ELLIPSIS),
		new BMessage(kMsgMenuFileOpen), 'O'));
	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem(TR("Save as" B_UTF8_ELLIPSIS),
		new BMessage(kMsgMenuFileSaveAs)));
	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem(TR("Quit"),
		new BMessage(B_QUIT_REQUESTED), 'Q'));
	menuBar->AddItem(menu);

	// Create keyboard layout menu
	fLayoutMenu = new BMenu(TR("Layout"));
	fLayoutMenu->SetRadioMode(true);
	fLayoutMenu->AddItem(item = new BMenuItem(
		fKeyboardLayoutView->GetKeyboardLayout()->Name(),
		new BMessage(kChangeKeyboardLayout)));
	item->SetMarked(true);

	_AddKeyboardLayouts(fLayoutMenu);
	menuBar->AddItem(fLayoutMenu);

	// Create the Font menu
	fFontMenu = new BMenu(TR("Font"));
	fFontMenu->SetRadioMode(true);
	int32 numFamilies = count_font_families();
	font_family family, currentFamily;
	font_style currentStyle;
	uint32 flags;

	be_plain_font->GetFamilyAndStyle(&currentFamily, &currentStyle);

	for (int32 i = 0; i < numFamilies; i++) {
		if (get_font_family(i, &family, &flags) == B_OK) {
			BMenuItem *item =
				new BMenuItem(family, new BMessage(kMsgMenuFontChanged));
			fFontMenu->AddItem(item);

			if (!strcmp(family, currentFamily))
				item->SetMarked(true);
		}
	}
	menuBar->AddItem(fFontMenu);

	return menuBar;
}
开发者ID:mmanley,项目名称:Antares,代码行数:53,代码来源:KeymapWindow.cpp

示例10: D_INTERNAL

void ParameterWindow::_updateParameterView(
    BMediaTheme *theme) {
    D_INTERNAL(("ParameterWindow::_updateParameterView()\n"));

    // clear the old version
    if (m_parameters) {
        ParameterContainerView *view = dynamic_cast<ParameterContainerView *>(FindView("ParameterContainerView"));
        RemoveChild(view);
        delete m_parameters;
        m_parameters = 0;
        delete view;
    }

    // fetch ParameterWeb from the MediaRoster
    BMediaRoster *roster = BMediaRoster::CurrentRoster();
    if (roster) {
        BParameterWeb *web;
        status_t error = roster->GetParameterWebFor(m_node, &web);
        if (!error && (web->CountParameters() || web->CountGroups())) {
            // if no theme was specified, use the preferred theme
            if (!theme) {
                theme = BMediaTheme::PreferredTheme();
            }
            // acquire the view
            m_parameters = BMediaTheme::ViewFor(web, 0, theme);
            if (m_parameters) {
                BMenuBar *menuBar = KeyMenuBar();
                m_idealSize = m_parameters->Bounds();
                m_idealSize.right += B_V_SCROLL_BAR_WIDTH;
                m_idealSize.bottom += B_H_SCROLL_BAR_HEIGHT;
                if (menuBar) {
                    m_parameters->MoveTo(0.0, menuBar->Bounds().bottom + 1.0);
                    m_idealSize.bottom += menuBar->Bounds().bottom + 1.0;
                }
            }
        }
    }

    // limit min size to avoid funny-looking scrollbars
    float hMin = B_V_SCROLL_BAR_WIDTH*6, vMin = B_H_SCROLL_BAR_HEIGHT*3;
    // limit max size to full extents of the parameter view
    float hMax = m_idealSize.Width(), vMax = m_idealSize.Height();
    SetSizeLimits(hMin, hMax, vMin, vMax);

    // adapt the window to the new dimensions
    ResizeTo(m_idealSize.Width(), m_idealSize.Height());
    m_zoomed = true;

    if (m_parameters) {
        BRect paramRect = m_parameters->Bounds();
        AddChild(new ParameterContainerView(paramRect, m_parameters));
    }
}
开发者ID:nielx,项目名称:haiku-serviceskit,代码行数:53,代码来源:ParameterWindow.cpp

示例11: BWindow

ApplicationWindow::ApplicationWindow(BRect frame, bool visible)
	:
	BWindow(frame, B_TRANSLATE_SYSTEM_NAME("PackageManager"),
		B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
		B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE),
	fMinimizeOnClose(false)
{
	SetPulseRate(1000000);

	SetLayout(new BGroupLayout(B_VERTICAL, 0.0));

	ApplicationsContainerView* downloadsGroupView = new ApplicationsContainerView();
	fApplicationViewsLayout = downloadsGroupView->GroupLayout();

	BMenuBar* menuBar = new BMenuBar("Menu bar");
	BMenu* menu = new BMenu("Actions");
	menu->AddItem(new BMenuItem("Apply changes",
		new BMessage('NADA')));
	menu->AddItem(new BMenuItem("Exit", new BMessage(B_QUIT_REQUESTED)));
	menuBar->AddItem(menu);

	fApplicationsScrollView = new ApplicationContainerScrollView(downloadsGroupView);

	fDiscardButton = new BButton("Revert",
		new BMessage('NADA'));
	fDiscardButton->SetEnabled(false);

	fApplyChangesButton = new BButton("Apply",
		new BMessage('NADA'));
	fApplyChangesButton->SetEnabled(false);

	const float spacing = be_control_look->DefaultItemSpacing();

	AddChild(BGroupLayoutBuilder(B_VERTICAL, 0.0)
		.Add(menuBar)
		.Add(fApplicationsScrollView)
		.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
		.Add(BGroupLayoutBuilder(B_HORIZONTAL, spacing)
			.AddGlue()
			.Add(fApplyChangesButton)
			.Add(fDiscardButton)
			.SetInsets(12, 5, 12, 5)
		)
	);

	PostMessage(INIT);

	if (!visible)
		Hide();
	Show();
}
开发者ID:mmadia,项目名称:Haiku-services-branch,代码行数:51,代码来源:ApplicationWindow.cpp

示例12: BMenuBar

BMenuBar* HResources::GetMenuBar(BRect r, int id)
{
	BMenuBar *mbar = new BMenuBar(r, "mbar");
	FailNil(mbar);

	size_t size;
	const int16 *lst = (int16 *)GetResource(rtyp_Mbar, id, size);
	FailNilRes(lst);

	for (uint32 i = 0; i < (size / 2); i++)
		mbar->AddItem(GetMenu(lst[i]));

	return mbar;
} /* GetMenuBar */
开发者ID:HaikuArchives,项目名称:Pe,代码行数:14,代码来源:HAppResFile.cpp

示例13: BWindow

TestWindow::TestWindow(BApplication* myApp)
	: BWindow(BRect(20,20,100,100),
	  "Code Profile", B_TITLED_WINDOW, 0)
{
	BRect frm = Bounds();

	BView* myview = new BView(BRect(),"testView",0,0);
	
	BOutlineListView* olist =
		new BOutlineListView(BRect(),"MyList",
							B_SINGLE_SELECTION_LIST,B_FOLLOW_NONE);
	if( myview && olist ) {
		myview->AddChild(olist);
		BView* vw = olist;
		vw->SetViewColor(0xc0,0xc0,0xc0);
		vw->Invalidate();
		vw->SetLowColor(0xc0,0xc0,0xc0);
		vw->Invalidate();
		vw->SetHighColor(0x00,0x00,0x00);
		vw->Invalidate();
		vw->SetFont(be_bold_font);
		this->AddChild(myview);
		BRect frm = vw->Frame();
		vw->ResizeTo(1,1);
		vw->Draw(vw->Bounds());
		vw->ResizeToPreferred();
		float w=0,h=0;
		vw->GetPreferredSize(&w,&h);
		printf("Preferred size = %f x %f\n",w,h);
	}
	
	string = new BStringView(BRect(0,0,100,20),"String",
								"Ready to profile...");	
	
	if( string ) {
		string->SetViewColor(0xc0,0xc0,0xc0);
		this->AddChild(string);
		float w=0, h=0;
		string->GetPreferredSize(&w,&h);
		MoveTo(30,30);
		ResizeTo(w,h);
	}
	
	BMenuBar* menu = new BMenuBar(BRect(),"MainMenu",B_FOLLOW_NONE);
	if( menu ) {
		this->AddChild(menu);
		float w=0, h=0;
		menu->GetPreferredSize(&w,&h);
		printf("Preferred Size = (%f,%f)\n",w,h);
		menu->SetFont(be_plain_font);
		menu->GetPreferredSize(&w,&h);
		printf("Preferred Size = (%f,%f)\n",w,h);
		menu->SetFont(be_bold_font);
		menu->GetPreferredSize(&w,&h);
		printf("Preferred Size = (%f,%f)\n",w,h);
		menu->SetFont(be_fixed_font);
		menu->GetPreferredSize(&w,&h);
		printf("Preferred Size = (%f,%f)\n",w,h);
	}
}
开发者ID:HaikuArchives,项目名称:Sequitur,代码行数:60,代码来源:Profile.cpp

示例14: BApplication

SketchApp::SketchApp()
		  		  : BApplication("application/x-vnd.Prok-Sketch")
{
	// most of this function was ripped out of Be's old HelloWorld Example
	SketchWindow	*mainWindow = NULL;
	SketchView		*aView = NULL;
	BMenuBar		*myMenubar = NULL;
	BMenu			*firstMenu = NULL, *secondMenu = NULL;
	BRect			aRect;
	menu_info		m_info;
	int32			menubarheight=0;
	
	// the price we pay to be font sensitive...
	get_menu_info(&m_info);
	menubarheight = (int32)m_info.font_size + 8;
	aRect.Set(100, 100, 449, 349 + menubarheight);
	mainWindow = new SketchWindow(aRect);
	
	// a pretty standard set of menus
	aRect.Set(0,0, mainWindow->Bounds().Width(), menubarheight);
	myMenubar = new BMenuBar(aRect, "menubar");
	// main menu
	firstMenu = new BMenu("Sketch");
	firstMenu->AddItem(new BMenuItem("About Sketch", new BMessage(B_ABOUT_REQUESTED), 'A', B_COMMAND_KEY));
	firstMenu->AddItem(new BMenuItem("Save", new BMessage(SAVE_BITMAP), 'S', B_COMMAND_KEY));
	firstMenu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q', B_COMMAND_KEY));
	((BMenuItem *)firstMenu->ItemAt(0))->SetTarget(be_app);
	((BMenuItem *)firstMenu->ItemAt(1))->SetTarget(be_app);
	
#if __INTEL__ // only cuz the translation kit is busted in R3, will undo in R3.1
	//((BMenuItem *)firstMenu->ItemAt(1))->SetEnabled(false);
#endif
	// edit menu
	secondMenu = new BMenu("Edit");
	secondMenu->AddItem(new BMenuItem("Erase", new BMessage(ANIMATED_ERASE), 'E', B_COMMAND_KEY));
	myMenubar->AddItem(firstMenu);
	myMenubar->AddItem(secondMenu);
	
	// SketchView
	aRect.Set(0,menubarheight -1, mainWindow->Bounds().Width(), mainWindow->Bounds().Height());
	aView = new SketchView(aRect, "SketchView");
	
	// add views to window
	mainWindow->AddChild(aView);
	mainWindow->AddChild(myMenubar);
	
	// make window visible
	mainWindow->Show();
}
开发者ID:jwiggins,项目名称:BeOS-Projects,代码行数:49,代码来源:Sketch.cpp

示例15: BMenuBar

void
CAssemblyWindow::AddMenuBar()
{
	BMenu *menu, *subMenu;
	BMenuItem *item;

	BMenuBar *menuBar = new BMenuBar(Bounds(), "General");

	// Create the 'File' menu
	CreateFileMenu(menuBar);

	// Create the edit menu
	menu = new BMenu("Edit");
	menu->AddItem(new BMenuItem("Undo", new BMessage(MENU_UNDO), 'Z'));
	menu->AddItem(new BMenuItem("Redo", new BMessage(MENU_REDO), 'Z', B_SHIFT_KEY));
	menu->AddSeparatorItem();
	menu->AddItem(item = new BMenuItem("Cut", new BMessage(B_CUT), 'X'));
	item->SetEnabled(false);
	menu->AddItem(item = new BMenuItem("Copy", new BMessage(B_COPY), 'C'));
	item->SetEnabled(false);
	menu->AddItem(item = new BMenuItem("Paste", new BMessage(B_PASTE), 'V'));
	item->SetEnabled(false);
	menu->AddItem(new CQuickKeyMenuItem("Clear", new BMessage(MENU_CLEAR), B_DELETE, "Del"));
	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem("Select All", new BMessage(B_SELECT_ALL), 'A'));
	menuBar->AddItem(menu);

	// Create the 'Play' menu
	menu = new BMenu("Play");
	menu->AddItem(new CQuickKeyMenuItem("Pause", new BMessage(MENU_PAUSE), B_SPACE, "Space"));
	menu->AddSeparatorItem();
	menu->AddItem(new CQuickKeyMenuItem("Start", new BMessage(MENU_PLAY), B_ENTER, "Enter"));
	menu->AddItem(new CQuickKeyMenuItem("Play Section", new BMessage(MENU_PLAY_SECTION ), 'p', "p"));
	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem("Set Section", new BMessage(MENU_SET_SECTION), 'S', B_SHIFT_KEY));
	menuBar->AddItem(menu);
	
	// Create the 'View' menu
	menu = new BMenu("View");
	subMenu = new BMenu("Add Strip");
	menu->AddItem(subMenu);
	menuBar->AddItem(menu);

	// Create the 'Window' menu
	CreateWindowMenu(menuBar);

	// Add the menus
	AddChild(menuBar);
}
开发者ID:HaikuArchives,项目名称:MeV,代码行数:49,代码来源:AssemblyWindow.cpp


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