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


C++ Menu::AddItem方法代码示例

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


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

示例1: new

static Menu *
add_boot_volume_menu(Directory *bootVolume)
{
    Menu *menu = new(nothrow) Menu(CHOICE_MENU, "Select Boot Volume");
    MenuItem *item;
    void *cookie;
    int32 count = 0;

    if (gRoot->Open(&cookie, O_RDONLY) == B_OK) {
        Directory *volume;
        while (gRoot->GetNextNode(cookie, (Node **)&volume) == B_OK) {
            // only list bootable volumes
            if (!is_bootable(volume))
                continue;

            char name[B_FILE_NAME_LENGTH];
            if (volume->GetName(name, sizeof(name)) == B_OK) {
                menu->AddItem(item = new(nothrow) MenuItem(name));
                item->SetTarget(user_menu_boot_volume);
                item->SetData(volume);

                if (volume == bootVolume) {
                    item->SetMarked(true);
                    item->Select(true);
                }

                count++;
            }
        }
        gRoot->Close(cookie);
    }

    if (count == 0) {
        // no boot volume found yet
        menu->AddItem(item = new(nothrow) MenuItem("<No boot volume found>"));
        item->SetType(MENU_ITEM_NO_CHOICE);
        item->SetEnabled(false);
    }

    menu->AddSeparatorItem();

    menu->AddItem(item = new(nothrow) MenuItem("Rescan volumes"));
    item->SetHelpText("Please insert a Antares CD-ROM or attach a USB disk - "
                      "depending on your system, you can then boot from them.");
    item->SetType(MENU_ITEM_NO_CHOICE);
    if (count == 0)
        item->Select(true);

    menu->AddItem(item = new(nothrow) MenuItem("Return to main menu"));
    item->SetType(MENU_ITEM_NO_CHOICE);

    if (gKernelArgs.boot_volume.GetBool(BOOT_VOLUME_BOOTED_FROM_IMAGE, false))
        menu->SetChoiceText("CD-ROM or hard drive");

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

示例2: new

static Menu*
add_safe_mode_menu()
{
	Menu* safeMenu = new(nothrow) Menu(SAFE_MODE_MENU, "Safe Mode Options");
	MenuItem* item;

	safeMenu->AddItem(item = new(nothrow) MenuItem("Safe mode"));
	item->SetData(B_SAFEMODE_SAFE_MODE);
	item->SetType(MENU_ITEM_MARKABLE);
	item->SetHelpText("Puts the system into safe mode. This can be enabled "
		"independently from the other options.");

	safeMenu->AddItem(item = new(nothrow) MenuItem("Disable user add-ons"));
	item->SetData(B_SAFEMODE_DISABLE_USER_ADD_ONS);
	item->SetType(MENU_ITEM_MARKABLE);
    item->SetHelpText("Prevents all user installed add-ons from being loaded. "
		"Only the add-ons in the system directory will be used.");

	safeMenu->AddItem(item = new(nothrow) MenuItem("Disable IDE DMA"));
	item->SetData(B_SAFEMODE_DISABLE_IDE_DMA);
	item->SetType(MENU_ITEM_MARKABLE);
    item->SetHelpText("Disables IDE DMA, increasing IDE compatibility "
		"at the expense of performance.");

#if B_HAIKU_PHYSICAL_BITS > 32
	// check whether we have memory beyond 4 GB
	bool hasMemoryBeyond4GB = false;
	for (uint32 i = 0; i < gKernelArgs.num_physical_memory_ranges; i++) {
		phys_addr_range& range = gKernelArgs.physical_memory_range[i];
		if (range.start >= (phys_addr_t)1 << 32) {
			hasMemoryBeyond4GB = true;
			break;
		}
	}

	// ... add the menu, if so
	if (hasMemoryBeyond4GB) {
		safeMenu->AddItem(
			item = new(nothrow) MenuItem("Ignore memory beyond 4 GiB"));
		item->SetData(B_SAFEMODE_4_GB_MEMORY_LIMIT);
		item->SetType(MENU_ITEM_MARKABLE);
		item->SetHelpText("Ignores all memory beyond the 4 GiB address limit, "
			"overriding the setting in the kernel settings file.");
	}
#endif

	platform_add_menus(safeMenu);

	safeMenu->AddSeparatorItem();
	safeMenu->AddItem(item = new(nothrow) MenuItem("Return to main menu"));

	return safeMenu;
}
开发者ID:mariuz,项目名称:haiku,代码行数:53,代码来源:menu.cpp

示例3: CreateWindowMenu

void CreateWindowMenu(Window w) {
    //File Menu
    mFile.AddItem(ID_FILE_NEW, "&New");
    mFile.AddItem(ID_FILE_SAVE, "&Save");
    mFile.AddBreak();
    mFile.AddItem(ID_FILE_EXIT, "E&xit");

    //Scale Menu
    mScale.AddItem(ID_SCALE_CONNECT, "&Connect");
    mScale.AddItem(ID_SCALE_ZERO, "&Zero", MF_DISABLED);

    //Add the sub menu's to the title menu
    mTitle.AddSubMenu(mFile, "&File");
    mTitle.AddSubMenu(mScale, "&Scale");

    //Set the window's menu to the title menu
    w.SetWindowMenu(mTitle);
}
开发者ID:kirkbackus,项目名称:meal-track,代码行数:18,代码来源:main.cpp

示例4: new

static void
add_boot_volume_item(Menu* menu, Directory* volume, const char* name)
{
	BReference<PackageVolumeInfo> volumeInfo;
	PackageVolumeState* selectedState = NULL;
	if (volume == sBootVolume->RootDirectory()) {
		volumeInfo.SetTo(sBootVolume->GetPackageVolumeInfo());
		selectedState = sBootVolume->GetPackageVolumeState();
	} else {
		volumeInfo.SetTo(new(std::nothrow) PackageVolumeInfo);
		if (volumeInfo->SetTo(volume, "system/packages") == B_OK)
			selectedState = volumeInfo->States().Head();
		else
			volumeInfo.Unset();
	}

	BootVolumeMenuItem* item = new(nothrow) BootVolumeMenuItem(name);
	menu->AddItem(item);

	Menu* subMenu = NULL;

	if (volumeInfo != NULL) {
		subMenu = new(std::nothrow) Menu(CHOICE_MENU, "Select Haiku version");

		for (PackageVolumeStateList::ConstIterator it
				= volumeInfo->States().GetIterator();
			PackageVolumeState* state = it.Next();) {
			PackageVolumeStateMenuItem* stateItem
				= new(nothrow) PackageVolumeStateMenuItem(state->DisplayName(),
					volumeInfo, state);
			subMenu->AddItem(stateItem);
			stateItem->SetTarget(user_menu_boot_volume_state);
			stateItem->SetData(volume);

			if (state == selectedState) {
				stateItem->SetMarked(true);
				stateItem->Select(true);
				item->UpdateStateName(stateItem->VolumeState());
			}
		}
	}

	if (subMenu != NULL && subMenu->CountItems() > 1) {
		item->SetSubmenu(subMenu);
	} else {
		delete subMenu;
		item->SetTarget(user_menu_boot_volume);
		item->SetData(volume);
	}

	if (volume == sBootVolume->RootDirectory()) {
		item->SetMarked(true);
		item->Select(true);
	}
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:55,代码来源:menu.cpp

示例5: new

Menu *
video_mode_menu()
{
	Menu *menu = new(nothrow) Menu(CHOICE_MENU, "Select Video Mode");
	MenuItem *item;

	menu->AddItem(item = new(nothrow) MenuItem("Default"));
	item->SetMarked(true);
	item->Select(true);
	item->SetHelpText("The Default video mode is the one currently configured "
		"in the system. If there is no mode configured yet, a viable mode will "
		"be chosen automatically.");


	menu->AddSeparatorItem();
	menu->AddItem(item = new(nothrow) MenuItem("Return to main menu"));
	item->SetType(MENU_ITEM_NO_CHOICE);

	return menu;
}
开发者ID:mylegacy,项目名称:haiku,代码行数:20,代码来源:video.cpp

示例6: MaintainRect

void MaintainRect()
{
    Menu MaintainMenu;
	FigureFirst();
	MaintainMenu.AddItem( 'f', "First", FigureFirst );
	MaintainMenu.AddItem( 'n', "Next", FigureNext );
	MaintainMenu.AddItem( 'p', "Previous", FigurePrevious );
	MaintainMenu.AddItem( 'd', "Delete", FigureDelete );
	MaintainMenu.AddItem( 'q', "Print current", FigurePrint );
	MaintainMenu.AddItem( ' ', "", MenuSeparator );
	MaintainMenu.AddItem( 'x', "Exit", MenuExit );
	MaintainMenu.AddItem( '?', "Help", MenuPrintHelp );

	MaintainMenu.Run();
}
开发者ID:BengtHolm,项目名称:STLexer,代码行数:15,代码来源:main.cpp

示例7: main

int main()
{
	cout << "Hello \n";

	Menu MyMenu; 

	MyMenu.AddItem( 'r', "Read from files", FileRead );
	MyMenu.AddItem( 'l', "List all", ListAll );
	MyMenu.AddItem( 's', "Show big", ShowBig );
	MyMenu.AddItem( 'a', "Add new item",AddMenu );
	MyMenu.AddItem( 'c', "Accumulate Area", AccumulateArea );
	MyMenu.AddItem( 'm', "Maintain Rects",MaintainRect );
	MyMenu.AddItem( 'w', "Write to files", FileWrite );

	MyMenu.AddItem( ' ', "", MenuSeparator );
	MyMenu.AddItem( 'x', "Exit", MenuExit );
	MyMenu.AddItem( '?', "Help", MenuPrintHelp );

	MyMenu.Run();

	return 0;
}
开发者ID:BengtHolm,项目名称:STLexer,代码行数:22,代码来源:main.cpp

示例8: AddMenu

void AddMenu()
{
    Menu AddMenu;
	AddMenu.AddItem( 'c', "Add new circle", AddCircle );
	AddMenu.AddItem( 'r', "Add new rectangle", AddRectangle );
	AddMenu.AddItem( 't', "Add new triangle", AddTriangle );
	AddMenu.AddItem( ' ', "", MenuSeparator );
	AddMenu.AddItem( 'x', "Exit", MenuExit );
	AddMenu.AddItem( '?', "Help", MenuPrintHelp );

	AddMenu.Run();
}
开发者ID:BengtHolm,项目名称:STLexer,代码行数:12,代码来源:main.cpp

示例9: Window


//.........这里部分代码省略.........
	m_pPressedTest = new Widget(GetContentWidget());
		m_pPressedTest->SetBackgroundColor(Color4::Blue);
		m_pPressedTest->SetPos(Vector2i(200, 70));
		m_pPressedTest->SetSize(Vector2i(32, 32));
		m_pPressedTest->SetVisible(true);
	m_pBitmapButton = new BitmapButton(GetContentWidget());
		m_pBitmapButton->SetImageEnabled (Image(*Gui::GetSystemGui(), "PLGui/button.png"));
		m_pBitmapButton->SetImageDisabled(Image(*Gui::GetSystemGui(), "PLGui/button-inactive.png"));
		m_pBitmapButton->SetImageSelected(Image(*Gui::GetSystemGui(), "PLGui/button-over.png"));
		m_pBitmapButton->SetImagePressed (Image(*Gui::GetSystemGui(), "PLGui/button-pressed.png"));
		m_pBitmapButton->SetPos(Vector2i(10, 230));
		m_pBitmapButton->SetSize(Vector2i(64, 64));
		m_pBitmapButton->SetVisible(true);
	m_pBitmapToggleButton = new BitmapToggleButton(GetContentWidget());
		m_pBitmapToggleButton->SetImageDisabled  (Image(*Gui::GetSystemGui(), "PLGui/button-inactive.png"));
		m_pBitmapToggleButton->SetImageUnselected(NotChecked,		Image(*Gui::GetSystemGui(), "PLGui/button-off.png"));
		m_pBitmapToggleButton->SetImageUnselected(PartiallyChecked,	Image(*Gui::GetSystemGui(), "PLGui/button-on.png"));
		m_pBitmapToggleButton->SetImageUnselected(Checked,			Image(*Gui::GetSystemGui(), "PLGui/button-on.png"));
		m_pBitmapToggleButton->SetImageSelected  (NotChecked,		Image(*Gui::GetSystemGui(), "PLGui/button-over-off.png"));
		m_pBitmapToggleButton->SetImageSelected  (PartiallyChecked,	Image(*Gui::GetSystemGui(), "PLGui/button-over-on.png"));
		m_pBitmapToggleButton->SetImageSelected  (Checked,			Image(*Gui::GetSystemGui(), "PLGui/button-over-on.png"));
		m_pBitmapToggleButton->SetPos(Vector2i(10, 300));
		m_pBitmapToggleButton->SetSize(Vector2i(64, 64));
		m_pBitmapToggleButton->SetVisible(true);

	// Connect event handlers to button
	m_pButton->SignalClicked .Connect(EventHandlerClicked);
	m_pButton->SignalPressed .Connect(EventHandlerPressed);
	m_pButton->SignalReleased.Connect(EventHandlerReleased);

	// Create menu
	Menu *pMenuFile = new Menu(*GetGui());
		pMenuFile->SetText("&File");
		pMenuFile->AddItem("&Open");
		pMenuFile->AddItem("&Close");
		pMenuFile->AddSeparator();
		pMenuFile->AddItem("&Quit");
	Menu *pMenuEdit = new Menu(*GetGui());
		pMenuEdit->SetText("&Edit");
		pMenuEdit->AddItem("&Copy");
		pMenuEdit->AddItem("Cu&t");
		pMenuEdit->AddItem("&Paste");
	Menu *pMenuView = new Menu(*GetGui());
		pMenuView->SetText("&View");
		pMenuView->AddItem("View &All");
		pMenuView->AddItem("View &None");
	Menu *pMenuWindow = new Menu(*GetGui());
		pMenuWindow->SetText("&Window");
		pMenuWindow->AddItem("&Next");
		pMenuWindow->AddItem("&Previous");
		pMenuWindow->AddItem("&Close");
		pMenuWindow->AddItem( "Close &All");
	Menu *pMenuHelp = new Menu(*GetGui());
		pMenuHelp->SetText("&Help");
		pMenuHelp->AddItem("&Help");
		pMenuHelp->AddItem("&About");
	m_cMenu.SetText("&Menu");
	m_cMenu.AddSubMenu(pMenuFile);
	m_cMenu.AddSubMenu(pMenuEdit);
	m_cMenu.AddSubMenu(pMenuView);
	m_cMenu.AddSubMenu(pMenuWindow);
	m_cMenu.AddSubMenu(pMenuHelp);
	m_cMenu.AddSeparator();
	m_cMenu.AddItem("&Restore");
	m_cMenu.AddSeparator();
开发者ID:ByeDream,项目名称:pixellight,代码行数:66,代码来源:TestWindow.cpp

示例10: CreateMenus

bool Menus::CreateMenus()
{
	// Build the menus
	Menu* menuMain = new Menu;
	ASSERT(menuMain);

	menuMain->AddItem(new MenuLabel(MenuItem::Title,L"main menu",0,true,NULL));
	menuMain->AddItem(new MenuLabel(MenuItem::Margin,NULL,0,true,NULL));
	menuMain->AddItem(new MenuLabel(MenuItem::Label,L"visualizations",1,false,NULL));
	menuMain->AddItem(new MenuLabel(MenuItem::Label,L"color presets",2,false,NULL));
	menuMain->AddItem(new MenuLabel(MenuItem::Seperator,NULL,0,true,NULL));
	menuMain->AddItem(new MenuLabel(MenuItem::Label,L"options",3,false,NULL));
	menuMain->AddItem(new MenuLabel(MenuItem::Label,L"capture source",4,false,NULL));
	menuMain->AddItem(new MenuLabel(MenuItem::Seperator,NULL,0,true,NULL));
	menuMain->AddItem(new MenuLabel(MenuItem::Label,L"info",5,false,NULL));
	menuMain->AddItem(new MenuLabel(MenuItem::Seperator,NULL,0,true,NULL));
	menuMain->AddItem(new MenuLabel(MenuItem::Label,L"close",6,false,NULL));

	menuMain->SetSelectedFirstValid();
	menuMain->SetEventHandler(MenuEventHandler);

	mMenuRoot.AddMenu(menuMain);

	Menu* menuExit = new Menu;
	ASSERT(menuExit);

	menuExit->AddItem(new MenuLabel(MenuItem::Title,L"close",0,true,NULL));
	menuExit->AddItem(new MenuLabel(MenuItem::Margin,NULL,0,true,NULL));
	menuExit->AddItem(new MenuLabel(MenuItem::Label,L"yes",1,false,NULL));
	menuExit->AddItem(new MenuLabel(MenuItem::Label,L"no",2,false,NULL));

	menuExit->SetSelected(3);	// No
	menuExit->SetEventHandler(MenuExitEventHandler);

	mMenuRoot.AddMenu(menuExit);

	Menu* menuCapture = new Menu;
	ASSERT(menuCapture);

	menuCapture->AddItem(new MenuLabel(MenuItem::Title,L"capture source menu",0,true,NULL));
	menuCapture->AddItem(new MenuLabel(MenuItem::Margin,NULL,0,true,NULL));

	// Add the capture sources
	for(unsigned long i = 0; i < GetKernel()->GetAudio()->GetSourcesCount(); ++i)
		menuCapture->AddItem(new MenuLabel(MenuItem::Label,GetKernel()->GetAudio()->GetSource(i),i+1,false,NULL));

	if(!GetKernel()->GetAudio()->GetSourcesCount())
		menuCapture->AddItem(new MenuLabel(MenuItem::Label,L"no capture sources",1,true,NULL));

	menuCapture->AddItem(new MenuLabel(MenuItem::Seperator,NULL,0,true,NULL));
	menuCapture->AddItem(new MenuLabel(MenuItem::Label,L"back",GetKernel()->GetAudio()->GetSourcesCount()+1,false,NULL));

	menuCapture->SetSelectedFirstValid();
	menuCapture->SetEventHandler(MenuCaptureEventHandler);

	mMenuRoot.AddMenu(menuCapture);

	Menu* menuOptions = new Menu;
	ASSERT(menuOptions);

	menuOptions->AddItem(new MenuLabel(MenuItem::Title,L"options menu",0,true,NULL));
	menuOptions->AddItem(new MenuLabel(MenuItem::Margin,NULL,0,true,NULL));
	menuOptions->AddItem(new MenuLabel(MenuItem::Label,NULL,1,false,MenuItemTextHandler));
	menuOptions->AddItem(new MenuLabel(MenuItem::Label,NULL,2,false,MenuItemTextHandler));
	menuOptions->AddItem(new MenuLabel(MenuItem::Label,NULL,3,false,MenuItemTextHandler));
	menuOptions->AddItem(new MenuLabel(MenuItem::Label,NULL,4,false,MenuItemTextHandler));
	menuOptions->AddItem(new MenuLabel(MenuItem::Label,NULL,5,false,MenuItemTextHandler));
	menuOptions->AddItem(new MenuLabel(MenuItem::Label,NULL,6,false,MenuItemTextHandler));
	menuOptions->AddItem(new MenuLabel(MenuItem::Label,NULL,7,false,MenuItemTextHandler));
	menuOptions->AddItem(new MenuLabel(MenuItem::Seperator,NULL,0,true,NULL));
	menuOptions->AddItem(new MenuLabel(MenuItem::Label,NULL,8,false,MenuItemTextHandler));
	menuOptions->AddItem(new MenuLabel(MenuItem::Seperator,NULL,0,true,NULL));
	menuOptions->AddItem(new MenuLabel(MenuItem::Label,NULL,9,false,MenuItemTextHandler));
	menuOptions->AddItem(new MenuLabel(MenuItem::Label,NULL,10,false,MenuItemTextHandler));
	menuOptions->AddItem(new MenuLabel(MenuItem::Label,NULL,11,false,MenuItemTextHandler));
	menuOptions->AddItem(new MenuLabel(MenuItem::Seperator,NULL,0,true,NULL));
	menuOptions->AddItem(new MenuLabel(MenuItem::Label,L"write config",12,false,NULL));
	menuOptions->AddItem(new MenuLabel(MenuItem::Label,L"read config",13,false,NULL));
	menuOptions->AddItem(new MenuLabel(MenuItem::Seperator,NULL,0,true,NULL));
	menuOptions->AddItem(new MenuLabel(MenuItem::Label,L"back",14,false,NULL));

	menuOptions->SetSelectedFirstValid();
	menuOptions->SetEventHandler(MenuOptionsEventHandler);

	mMenuRoot.AddMenu(menuOptions);

	Menu* menuInfo = new Menu;
	ASSERT(menuInfo);

	menuInfo->AddItem(new MenuLabel(MenuItem::Title,L"info menu",0,true,NULL));
	menuInfo->AddItem(new MenuLabel(MenuItem::Margin,NULL,0,true,NULL));
	menuInfo->AddItem(new MenuLabel(MenuItem::Label,NULL,1,true,MenuInfoItemTextHandler));
	menuInfo->AddItem(new MenuLabel(MenuItem::Label,NULL,2,true,MenuInfoItemTextHandler));
	menuInfo->AddItem(new MenuLabel(MenuItem::Margin,NULL,0,true,NULL));
	menuInfo->AddItem(new MenuLabel(MenuItem::Label,L"audio analyzer v\002" TOSTRINGW(ANALYZER_VERSION_MAJOR) L"." TOSTRINGW(ANALYZER_VERSION_MINOR) L"\001",0,true,NULL));
	menuInfo->AddItem(new MenuLabel(MenuItem::Label,L"marko mihovilic",0,true,NULL));
	menuInfo->AddItem(new MenuLabel(MenuItem::Margin,NULL,0,true,NULL));
	menuInfo->AddItem(new MenuLabel(MenuItem::Label,L"back",6,false,NULL));

	menuInfo->SetSelectedFirstValid();
//.........这里部分代码省略.........
开发者ID:m1h4,项目名称:AudioAnalyzer,代码行数:101,代码来源:Menus.cpp

示例11: cSelf

BrowserWindow::BrowserWindow( const Rect &cFrame ) : Window( cFrame, "webview_wnd", "Webster" )
{
	Rect cMenuFrame, cToolFrame, cStatusFrame, cTabFrame;

	m_pcChromeClient = new BrowserChromeClient( this );
	m_pcWebSettings = new WebSettings();
	m_pcWebSettings->Load();

	m_pcSettings = new Settings();
	m_pcSettings->Load();

	/* Get window layouts */
	m_pcGuiSettings = new Settings();
	m_pcGuiSettings->SetFile( "Gui" );
	m_pcGuiSettings->Load();

	m_cWindowFrame = m_pcGuiSettings->GetRect( "webster", cFrame );
	m_cSettingsFrame = m_pcGuiSettings->GetRect( "settings", Rect( 25, 25, 600, 450 ) );

	SetFrame( m_cWindowFrame );
	cMenuFrame = cToolFrame = cStatusFrame = cTabFrame = GetBounds();

	/* DANGER WILL ROBINSON! See the note in the BrowserApp constructor about this mutex! */
	g_cGlobalMutex.Lock();
	SetMutex( &g_cGlobalMutex );

	m_pcMenuBar = new Menu( cMenuFrame, "menubar", ITEMS_IN_ROW );

	Menu *pcApplicationMenu = new Menu( Rect(), "Application", ITEMS_IN_COLUMN );
	pcApplicationMenu->AddItem( "Quit", new Message( M_TERMINATE ), "Ctrl+Q" );
	pcApplicationMenu->AddItem( new MenuSeparator() );
	pcApplicationMenu->AddItem( "About Webster", new Message( ID_MENU_APP_ABOUT ) );
	m_pcMenuBar->AddItem( pcApplicationMenu );

	Menu *pcWindowMenu = new Menu( Rect(), "Window", ITEMS_IN_COLUMN );
	pcWindowMenu->AddItem( "New window", new Message( ID_CREATE_WINDOW ), "Ctrl+N" );
	pcWindowMenu->AddItem( "Close window", new Message( M_QUIT ), "Ctrl+W" );
	pcWindowMenu->AddItem( new MenuSeparator() );
	pcWindowMenu->AddItem( "New tab", new Message( ID_MENU_WIN_NEW_TAB ), "Ctrl+T" );
	pcWindowMenu->AddItem( "Close tab", new Message( ID_MENU_WIN_CLOSE_TAB ) );
	m_pcMenuBar->AddItem( pcWindowMenu );

	Menu *pcEditMenu = new Menu( Rect(), "Edit", ITEMS_IN_COLUMN );
	pcEditMenu->AddItem( "Cut", new Message( ID_MENU_EDIT_CUT ), "Ctrl+X" );
	pcEditMenu->AddItem( "Copy", new Message( ID_MENU_EDIT_COPY ), "Ctrl+C" );
	pcEditMenu->AddItem( "Paste", new Message( ID_MENU_EDIT_PASTE ), "Ctrl+V" );
	pcEditMenu->AddItem( new MenuSeparator() );
	pcEditMenu->AddItem( "Delete", new Message( ID_MENU_EDIT_DELETE ) );
	m_pcMenuBar->AddItem( pcEditMenu );

	Menu *pcSettingsMenu = new Menu( Rect(), "Settings", ITEMS_IN_COLUMN );
	pcSettingsMenu->AddItem( "Configure", new Message( ID_MENU_SETTINGS_CONFIGURE ) );
	m_pcMenuBar->AddItem( pcSettingsMenu );

	m_pcBookmarksManager = new BookmarksManager();
	BookmarksMenu *pcBookmarksMenu = m_pcBookmarksManager->CreateMenu( "Bookmarks", Path( "" ) );
	m_pcMenuBar->AddItem( pcBookmarksMenu );

	m_pcMenuBar->SetTargetForItems( this );

	cMenuFrame.bottom = m_pcMenuBar->GetPreferredSize( false ).y;
	m_pcMenuBar->SetFrame( cMenuFrame );
	AddChild( m_pcMenuBar );

	/* Setup the toolbar */
	bool bShowButtonText = m_pcSettings->GetBool( "show_button_text", true );
	m_pcToolBar = new ToolBar( Rect(), "toolbar", CF_FOLLOW_LEFT | CF_FOLLOW_RIGHT | CF_FOLLOW_TOP );

	ResStream *pcStream;
	File cSelf( open_image_file( get_image_id() ) );
	Resources cCol( &cSelf );		

	m_pcBackButton = new ImageButton( Rect(), "back", "Back", new Message(ID_BUTTON_BACK), NULL, ImageButton::IB_TEXT_BOTTOM, true, bShowButtonText, true );
	pcStream = cCol.GetResourceStream( "back.png" );
	m_pcBackButton->SetImage( pcStream );
	delete( pcStream );

	m_pcForwardButton = new ImageButton( Rect(), "foward", "Forward", new Message(ID_BUTTON_FORWARD), NULL, ImageButton::IB_TEXT_BOTTOM, true, bShowButtonText, true );
	pcStream = cCol.GetResourceStream( "forward.png" );
	m_pcForwardButton->SetImage( pcStream );
	delete( pcStream );

	m_pcReloadButton = new ImageButton( Rect(), "reload", "Reload", new Message(ID_BUTTON_RELOAD), NULL, ImageButton::IB_TEXT_BOTTOM, true, bShowButtonText, true );
	pcStream = cCol.GetResourceStream( "reload.png" );
	m_pcReloadButton->SetImage( pcStream );
	delete( pcStream );

	m_pcStopButton = new ImageButton( Rect(), "stop", "Stop", new Message(ID_BUTTON_STOP), NULL, ImageButton::IB_TEXT_BOTTOM, true, bShowButtonText, true );
	pcStream = cCol.GetResourceStream( "stop.png" );
	m_pcStopButton->SetImage( pcStream );
	delete( pcStream );

	m_pcHomeButton = new ImageButton( Rect(), "home", "Home", new Message(ID_BUTTON_HOME), NULL, ImageButton::IB_TEXT_BOTTOM, true, bShowButtonText, true );
	pcStream = cCol.GetResourceStream( "home.png" );
	m_pcHomeButton->SetImage( pcStream );
	delete( pcStream );

	m_pcBackButton->SetEnable( false );
	m_pcForwardButton->SetEnable( false );
	m_pcStopButton->SetEnable( false );
//.........这里部分代码省略.........
开发者ID:PyroOS,项目名称:Pyro,代码行数:101,代码来源:main.cpp


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