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


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

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


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

示例1: BMessage

// PopulateMenu
void
FontValueView::_PolulateMenu(BMenu* menu, BHandler* target,
							 const char* markedFamily,
							 const char* markedStyle)
{
	if (!menu)
		return;

	FontManager* manager = FontManager::Default();

	if (!manager->Lock())
		return;

	BMenu* fontMenu = NULL;

	font_family family;
	font_style style;

	int32 count = manager->CountFontFiles();
	for (int32 i = 0; i < count; i++) {
		if (!manager->GetFontAt(i, family, style))
			break;

		BMessage* message = new BMessage(MSG_FONT_CHANGED);
		message->AddString("font family", family);
		message->AddString("font style", style);

		FontMenuItem* item = new FontMenuItem(style, family, style,
											  message);
		item->SetTarget(target);

		bool markStyle = false;
		if (!fontMenu
			|| (fontMenu->Name()
				&& strcmp(fontMenu->Name(), family) != 0)) {
			// create new entry
			fontMenu = new BMenu(family);
			fontMenu->AddItem(item);
			menu->AddItem(fontMenu);
			// mark the menu if necessary
			if (markedFamily && strcmp(markedFamily, family) == 0) {
				if (BMenuItem* superItem = fontMenu->Superitem())
					superItem->SetMarked(true);
				markStyle = true;
			}
		} else {
			// reuse old entry
			fontMenu->AddItem(item);
		}
		// mark the item if necessary
		if (markStyle && markedStyle && strcmp(markedStyle, style) == 0)
			item->SetMarked(true);
	}
	
	manager->Unlock();
}
开发者ID:stippi,项目名称:Clockwerk,代码行数:57,代码来源:FontValueView.cpp

示例2: BWindow

Tearoff::Tearoff(BRect frame, const char *name, MainWindow *parent, MenuName menu_name, int idx)
	: BWindow(frame, name, B_FLOATING_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE, 0)
{
	int y = 0;
	BFont font;
	BMenu *menu;
	
	this->parent = parent;
	menu = parent->GetMenu(menu_name);
	menu->GetFont(&font);
	for(int i = 1; i < menu->CountItems(); i++) {
		BMenuItem *item = menu->ItemAt(i);
		if(item->Message()) {
			BButton *b = new BButton(BRect(0, y, frame.IntegerWidth(), y + TEAROFF_BUTTON_HEIGHT), "", item->Label(), new BMessage(item->Message()->what), B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); 
			font.SetSize(TEAROFF_FONT_SIZE);
			b->SetFont(&font);
			AddChild(b);
			y = y + TEAROFF_BUTTON_HEIGHT;
		}
	}
	this->ResizeTo(frame.IntegerWidth(), y);
	this->SetTitle(menu->Name());
	this->index = idx;
	delete menu;
}
开发者ID:brennanos,项目名称:XFile-Haiku,代码行数:25,代码来源:Tearoff.cpp

示例3: MessageReceived

void YabWindow::MessageReceived(BMessage *message)
{
	// if(message) message->PrintToStream();
	switch(message->what)
	{
		case YABBUTTON:
			{
				BString tmpMessage("");
                        	BButton *myButtonPressed;
                        	message->FindPointer("source",(void **) &myButtonPressed);
				tmpMessage += myButtonPressed->Name();
				tmpMessage += "|";
				messageString += tmpMessage;
			}
			break;
		case YABMENU:
			{
				BString tmpMessage("");
				BMenuItem *mySelectedMenu;
                        	message->FindPointer("source",(void **) &mySelectedMenu);
				BMenu *myMenu = mySelectedMenu->Menu();
				tmpMessage += ((BMenuBar*)myMenu->Supermenu())->Parent()->Name();
				tmpMessage += ":";
				tmpMessage += myMenu->Name();
				tmpMessage += ":";
                        	tmpMessage += mySelectedMenu->Label(); 
				tmpMessage += "|";
				messageString += tmpMessage;
			}
			break;
		case YABSUBMENU:
			{
				BString tmpMessage("");
				BMenuItem *mySelectedMenu;
                        	message->FindPointer("source",(void **) &mySelectedMenu);
				BMenu *myMenu = mySelectedMenu->Menu();
				tmpMessage += ((BMenuBar*)myMenu->Supermenu()->Supermenu())->Parent()->Name();
				tmpMessage += ":";
				tmpMessage += myMenu->Supermenu()->Name();
				tmpMessage += ":";
				tmpMessage += myMenu->Name();
				tmpMessage += ":";
                        	tmpMessage += mySelectedMenu->Label(); 
				tmpMessage += "|";
				messageString += tmpMessage;
			}
			break;
		case YABTEXTCONTROL:
			{
				BString tmpMessage("");
				BTextControl *myTextControl;
                        	message->FindPointer("source",(void **) &myTextControl);
				tmpMessage += myTextControl->Name();
				tmpMessage += ":";
				tmpMessage += myTextControl->Text();
				tmpMessage += "|";
				messageString += tmpMessage;
			}
			break;
		case YABCHECKBOX:
			{
				BString tmpMessage("");
				BCheckBox *myCheckBox;
                        	message->FindPointer("source",(void **) &myCheckBox);
				tmpMessage += myCheckBox->Name();
				tmpMessage += ":";
				if(myCheckBox->Value()==B_CONTROL_ON)
					tmpMessage += "ON|";
				else
					tmpMessage += "OFF|";
				messageString += tmpMessage;
			}
			break;
		case YABRADIOBUTTON:
			{
				BString tmpMessage("");
				BRadioButton *myRadioButton;
                        	message->FindPointer("source",(void **) &myRadioButton);
				tmpMessage += myRadioButton->Name();
				tmpMessage += "|";
				messageString += tmpMessage;
			}
			break;
		case YABLISTBOXINVOKE:
			{
				BListView *myList;
				message->FindPointer("source",(void **) &myList);
				int i = myList->CurrentSelection();
				if(i>=0)
				{
					BString tmpMessage("");
					tmpMessage += myList->Name();
					tmpMessage += ":_Invoke:";
					// tmpMessage += ((BStringItem*)(myList->ItemAt(i)))->Text();
					tmpMessage << i+1;
					tmpMessage += "|";
					messageString += tmpMessage;
				}
			}
			break;
//.........这里部分代码省略.........
开发者ID:HaikuArchives,项目名称:Yab,代码行数:101,代码来源:YabWindow.cpp


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