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


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

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


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

示例1: node


//.........这里部分代码省略.........
	query.SetVolume(&volume);
	query.SetPredicate("((META:email=*)&&(BEOS:TYPE=application/x-person))");

	if(!fReadOnly && query.Fetch() == B_OK)
	{
		BString addr[4],name,group,nick;
		entry_ref ref;
		BList peopleList;
	
	
		while(query.GetNextRef(&ref) == B_OK)
		{
			BNode node(&ref);
			if(node.InitCheck() != B_OK)
				continue;
			
			ReadNodeAttrString(&node,"META:name",&name);		
			ReadNodeAttrString(&node,"META:email",&addr[0]);
			ReadNodeAttrString(&node,"META:email2",&addr[1]);
			ReadNodeAttrString(&node,"META:email3",&addr[2]);
			ReadNodeAttrString(&node,"META:email4",&addr[3]);
			ReadNodeAttrString(&node,"META:group",&group);
			ReadNodeAttrString(&node,"META:nickname",&nick);
			
			for(int32 i = 0;i < 4;i++)
			{
				if(addr[i].Length() > 0)
				{
					if(nick.Length() > 0)
					{
						nick += " <";
						nick += addr[i];
						nick += ">";
						fAddrList.AddItem(strdup(nick.String()));
					}
					fAddrList.AddItem(strdup(addr[i].String()));
					
					BString title = name;
					title << " <" << addr[i] << ">";
				
					AddPersonToList(peopleList,title.String(),group.String());
				}
			}
		}
		
		// Sort people data
		peopleList.SortItems(HAddressView::SortPeople);
		// Build menus
		BTextControl *control[3] = {fTo,fCc,fBcc};
		BMenu *menus[3] = {toMenu,ccMenu,bccMenu};
		int32 count = peopleList.CountItems();
		PersonData *data;
		bool needSeparator = false;
		bool hasSeparator = false;
		for(int32 k = 0;k < 3;k++)
		{
			for(int32 i = 0;i < count;i++)
			{
				BMessage *msg = new BMessage(M_ADDR_MSG);
				msg->AddPointer("pointer",control[k]);
				data =  (PersonData*)peopleList.ItemAt(i);
				msg->AddString("email",data->email);
				if(needSeparator && !hasSeparator && strlen(data->group) == 0)
				{
					menus[k]->AddSeparatorItem();
					hasSeparator = true;
开发者ID:HaikuArchives,项目名称:Scooby,代码行数:67,代码来源:HAddressView.cpp

示例2: BWindow

// ------------------------------------------------------------- RHTML_Preferences_Win - RHTMLPreferencesWin -
RHTMLPreferencesWin::RHTMLPreferencesWin(BRect fRect,BWindow *parent): BWindow(fRect,fOptions->GetLocaleString("Preferences_Window","Preferences"),B_FLOATING_WINDOW,B_UNTYPED_WINDOW)
{
 fParent=parent;
 IsQuit=false;
 fList = new BOutlineListView(BRect(0,0,150,Bounds().bottom),"List",B_SINGLE_SELECTION_LIST,B_FOLLOW_TOP_BOTTOM,B_WILL_DRAW);
 BView *view1= new BView(BRect(151,0,151,Bounds().bottom),"view",B_FOLLOW_TOP_BOTTOM,B_WILL_DRAW);
 fView=new BView(BRect(152,0,Bounds().right,Bounds().bottom),"view",B_FOLLOW_ALL,B_WILL_DRAW);
 AddChild(fList);
 AddChild(view1);
 AddChild(fView);
 fView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
 view1->SetViewColor(184,184,184,0);
 fList->SetSelectionMessage(new BMessage('LIST'));

 JViewDb=5;
 fJView = (BView**) calloc(JViewDb,sizeof(BView));

// - Create Languages
 fList->AddItem(new BStringItem(fOptions->GetLocaleString("Preferences_Window_List","Languages")));

 fJView[0] = new BView(fView->Bounds(),"LangView",B_FOLLOW_TOP_BOTTOM,B_WILL_DRAW);
 fJView[0]->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
 fView->AddChild(fJView[0]);
 fLangMenu = new BMenu(fOptions->Locale[fOptions->CurrentLocale]->Lang.String());
 fLangMenu->SetLabelFromMarked(true);
 fLangMenu->SetRadioMode(true);
 for (int32 i=0;i<(int32)fOptions->LocaleDb;i++)
 {
  BMessage* msg = new BMessage('LANG');
  msg->AddInt32("Lang",i);
  BMenuItem *item;
  fLangMenu->AddItem(item=new BMenuItem(fOptions->Locale[i]->Lang.String(),msg));
  item->SetTarget(this);
 }
 fLanguages= new BMenuField(BRect(10,10,250,30),"LanguagesMenu",fOptions->GetLocaleString("Preferences_Window_Languages","Languages"),fLangMenu);
 fJView[0]->AddChild(fLanguages);
 
 fView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

 fStrView1 = new BStringView(BRect(10,50,250,100),"strview1","Language:");
 fJView[0]->AddChild(fStrView1);

 fStrView2 = new BStringView(BRect(10,50,250,120),"strview1","");
 fJView[0]->AddChild(fStrView2);

 fStrView3 = new BStringView(BRect(10,50,250,150),"strview1","Author:");
 fJView[0]->AddChild(fStrView3);

 author = new URLView( BRect(0,50,250,170),"author","","");
 fJView[0]->AddChild(author);

 fStrView4 = new BStringView(BRect(10,50,250,200),"strview4","Language version:");
 fJView[0]->AddChild(fStrView4);
 
 fStrView5 = new BStringView(BRect(10,50,300,220),"strview5","");
 fJView[0]->AddChild(fStrView5);

 fStrView6 = new BStringView(BRect(10,50,300,250),"strview6","Language create to:");
 fJView[0]->AddChild(fStrView6);
 
 fStrView7 = new BStringView(BRect(10,50,300,270),"strview7","");
 fJView[0]->AddChild(fStrView7);

 LSetAuthor();

// - Create FileTypes

 fJView[1] = new BView(fView->Bounds(),"FTView",B_FOLLOW_TOP_BOTTOM,B_WILL_DRAW);
 fJView[1]->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
 fView->AddChild(fJView[1]);

// - Create FileTypes/Fonts

 fFTFontsBox= new BBox(BRect(10,10,200,120));
 fFTFontsBox->SetLabel(fOptions->GetLocaleString("Preferences_Window_FileTypes","Default font"));
 fFTFontsBox->SetFont(new BFont(be_plain_font));
 fJView[1]->AddChild(fFTFontsBox);


 BString stmp;
 stmp << (int32) fOptions->DefaultFont->Size();
 BMenu *fSizeMenu = new BMenu(stmp.String());
 fSizeMenu->SetRadioMode(false);
 fSizeMenu->SetLabelFromMarked(true);
 
 for (int32 o=8;o<15;o++)
 {
  BMessage *msg2;
  msg2 = new BMessage('FTSZ');
  msg2->AddInt32("font_size",o);
  BString tmp;
  tmp << o;
  fSizeMenu->AddItem(new BMenuItem(tmp.String(),msg2));
 }
 fFTDFSize= new BMenuField(BRect(10,75,180,105),"Font Size",fOptions->GetLocaleString("Preferences_Window_FileTypes","Size"),fSizeMenu);
 fFTDFSize->SetDivider(60);
 fFTFontsBox->AddChild(fFTDFSize);

 font_family fFamily;
//.........这里部分代码省略.........
开发者ID:puckipedia,项目名称:Globe,代码行数:101,代码来源:RHTML_prefwin.cpp

示例3: b

// constructor
ObjectWindow::ObjectWindow(BRect frame, const char* name)
	: BWindow(frame, name, B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
			  B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE)
{
	BRect b(Bounds());

	b.bottom = b.top + 8;
	BMenuBar* menuBar = new BMenuBar(b, "menu bar");
	AddChild(menuBar);

	BMenu* menu = new BMenu("File");
	menuBar->AddItem(menu);

	menu->AddItem(new BMenu("Submenu"));

	BMenuItem* menuItem = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED),
										'Q');
	menu->AddItem(menuItem);

	b = Bounds();
	b.top = menuBar->Bounds().bottom + 1;
	b.right = ceilf((b.left + b.right) / 2.0);
	BBox* bg = new BBox(b, "bg box", B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW,
		B_PLAIN_BORDER);

	AddChild(bg);
	bg->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	// object view occupies the right side of the window
	b.left = b.right + 1.0;
	b.right = Bounds().right - B_V_SCROLL_BAR_WIDTH;
	b.bottom -= B_H_SCROLL_BAR_HEIGHT;
	fObjectView = new ObjectView(b, "object view", B_FOLLOW_ALL,
								 B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE);
	// wrap a scroll view around the object view
	BScrollView* scrollView = new BScrollView("object scroller", fObjectView,
		B_FOLLOW_ALL, 0, true, true, B_NO_BORDER);

	if (BScrollBar* scrollBar = fObjectView->ScrollBar(B_VERTICAL)) {
		scrollBar->SetRange(0.0, fObjectView->Bounds().Height());
		scrollBar->SetProportion(0.5);
	}
	if (BScrollBar* scrollBar = fObjectView->ScrollBar(B_HORIZONTAL)) {
		scrollBar->SetRange(0.0, fObjectView->Bounds().Width());
		scrollBar->SetProportion(0.5);
	}
	AddChild(scrollView);

	b = bg->Bounds();
	// controls occupy the left side of the window
	b.InsetBy(5.0, 5.0);
	BBox* controlGroup = new BBox(b, "controls box",
		B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW, B_FANCY_BORDER);

	controlGroup->SetLabel("Controls");
	bg->AddChild(controlGroup);

	b = controlGroup->Bounds();
	b.top += controlGroup->InnerFrame().top;
	b.bottom = b.top + 25.0;
	b.InsetBy(10.0, 10.0);
	b.right = b.left + b.Width() / 2.0 - 5.0;

	// new button
	fNewB = new BButton(b, "new button", "New Object",
		new BMessage(MSG_NEW_OBJECT));
	controlGroup->AddChild(fNewB);
	SetDefaultButton(fNewB);

	// clear button
	b.OffsetBy(0, fNewB->Bounds().Height() + 5.0);
	fClearB = new BButton(b, "clear button", "Clear", new BMessage(MSG_CLEAR));
	controlGroup->AddChild(fClearB);

	// object type radio buttons
	BMessage* message;
	BRadioButton* radioButton;

	b.OffsetBy(0, fClearB->Bounds().Height() + 5.0);
	message = new BMessage(MSG_SET_OBJECT_TYPE);
	message->AddInt32("type", OBJECT_LINE);
	radioButton = new BRadioButton(b, "radio 1", "Line", message);
	controlGroup->AddChild(radioButton);

	radioButton->SetValue(B_CONTROL_ON);

	b.OffsetBy(0, radioButton->Bounds().Height() + 5.0);
	message = new BMessage(MSG_SET_OBJECT_TYPE);
	message->AddInt32("type", OBJECT_RECT);
	radioButton = new BRadioButton(b, "radio 2", "Rect", message);
	controlGroup->AddChild(radioButton);

	b.OffsetBy(0, radioButton->Bounds().Height() + 5.0);
	message = new BMessage(MSG_SET_OBJECT_TYPE);
	message->AddInt32("type", OBJECT_ROUND_RECT);
	radioButton = new BRadioButton(b, "radio 3", "Round Rect", message);
	controlGroup->AddChild(radioButton);

	b.OffsetBy(0, radioButton->Bounds().Height() + 5.0);
//.........这里部分代码省略.........
开发者ID:mariuz,项目名称:haiku,代码行数:101,代码来源:ObjectWindow.cpp

示例4: mbRect

ActivityWindow::ActivityWindow()
	:
	BWindow(BRect(100, 100, 500, 350), B_TRANSLATE_SYSTEM_NAME("ActivityMonitor"),
	B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE)
{
	BMessage settings;
	_LoadSettings(settings);

	BRect frame;
	if (settings.FindRect("window frame", &frame) == B_OK) {
		MoveTo(frame.LeftTop());
		ResizeTo(frame.Width(), frame.Height());
	}

#ifdef __HAIKU__
	BGroupLayout* layout = new BGroupLayout(B_VERTICAL, 0);
	SetLayout(layout);

	// create GUI

	BMenuBar* menuBar = new BMenuBar("menu");
	layout->AddView(menuBar);

	fLayout = new BGroupLayout(B_VERTICAL);
	float inset = ceilf(be_plain_font->Size() * 0.7);
	fLayout->SetInsets(inset, inset, inset, inset);
	fLayout->SetSpacing(inset);

	BView* top = new BView("top", 0, fLayout);
	top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	layout->AddView(top);

	BMessage viewState;
	int32 count = 0;
	for (int32 i = 0; settings.FindMessage("activity view", i, &viewState)
			== B_OK; i++) {
		ActivityView* view = new ActivityView("ActivityMonitor", &viewState);
		fLayout->AddItem(view->CreateHistoryLayoutItem());
		fLayout->AddItem(view->CreateLegendLayoutItem());
		count++;
	}
	if (count == 0) {
		// Add default views (memory & CPU usage)
		_AddDefaultView();
		_AddDefaultView();
	}
#else	// !__HAIKU__
	BView *layout = new BView(Bounds(), "topmost", B_FOLLOW_NONE, 0);
	AddChild(layout);

	// create GUI
	BRect mbRect(Bounds());
	mbRect.bottom = 10;
	BMenuBar* menuBar = new BMenuBar(mbRect, "menu");
	layout->AddChild(menuBar);

	BRect topRect(Bounds());
	topRect.top = menuBar->Bounds().bottom + 1;

	BView* top = new BView(topRect, "top", B_FOLLOW_ALL, 0);
	top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	layout->AddChild(top);

	BMessage viewState;
	int32 count = 0;
	ActivityView *aview;
	BRect rect;
	for (int32 i = 0; settings.FindMessage("activity view", i, &viewState)
			== B_OK; i++) {
		aview = new ActivityView("ActivityMonitor", &viewState);
		if (!rect.IsValid())
			rect = aview->Bounds();
		else
			rect.OffsetBySelf(0.0, aview->Bounds().Height());
		top->AddChild(aview);
		count++;
	}
	if (count == 0)
		top->AddChild(new ActivityView("ActivityMonitor", NULL));

#endif
	// add menu

	// "File" menu
	BMenu* menu = new BMenu(B_TRANSLATE("File"));
	menu->AddItem(new BMenuItem(B_TRANSLATE("Add graph"),
		new BMessage(kMsgAddView)));
	menu->AddSeparatorItem();

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

	// "Settings" menu
	menu = new BMenu(B_TRANSLATE("Settings"));
	menu->AddItem(new BMenuItem(B_TRANSLATE("Settings" B_UTF8_ELLIPSIS),
		new BMessage(kMsgShowSettings)));
	menu->SetTargetForItems(this);
	menuBar->AddItem(menu);
//.........这里部分代码省略.........
开发者ID:veer77,项目名称:Haiku-services-branch,代码行数:101,代码来源:ActivityWindow.cpp

示例5: BMessage

void
PadView::DisplayMenu(BPoint where, LaunchButton* button) const
{
	MainWindow* window = dynamic_cast<MainWindow*>(Window());
	if (window == NULL)
		return;

	LaunchButton* nearestButton = button;
	if (!nearestButton) {
		// find the nearest button
		for (int32 i = 0; (nearestButton = ButtonAt(i)); i++) {
			if (nearestButton->Frame().top > where.y)
				break;
		}
	}
	BPopUpMenu* menu = new BPopUpMenu(B_TRANSLATE("launch popup"), false, false);
	// add button
	BMessage* message = new BMessage(MSG_ADD_SLOT);
	message->AddPointer("be:source", (void*)nearestButton);
	BMenuItem* item = new BMenuItem(B_TRANSLATE("Add button here"), message);
	item->SetTarget(window);
	menu->AddItem(item);
	// button options
	if (button) {
		// clear button
		message = new BMessage(MSG_CLEAR_SLOT);
		message->AddPointer("be:source", (void*)button);
		item = new BMenuItem(B_TRANSLATE("Clear button"), message);
		item->SetTarget(window);
		menu->AddItem(item);
		// remove button
		message = new BMessage(MSG_REMOVE_SLOT);
		message->AddPointer("be:source", (void*)button);
		item = new BMenuItem(B_TRANSLATE("Remove button"), message);
		item->SetTarget(window);
		menu->AddItem(item);
		// Open containing folder button
		if (button->Ref() != NULL) {	
			message = new BMessage(MSG_OPEN_CONTAINING_FOLDER);
			message->AddPointer("be:source", (void*)button);
			item = new BMenuItem(B_TRANSLATE("Open containing folder"), message);
			item->SetTarget(window);
			menu->AddItem(item);
		}
		// set button description
		if (button->Ref()) {
			message = new BMessage(MSG_SET_DESCRIPTION);
			message->AddPointer("be:source", (void*)button);
			item = new BMenuItem(B_TRANSLATE("Set description"B_UTF8_ELLIPSIS),
				message);
			item->SetTarget(window);
			menu->AddItem(item);
		}
	}
	menu->AddSeparatorItem();
	// window settings
	BMenu* settingsM = new BMenu(B_TRANSLATE("Settings"));
	settingsM->SetFont(be_plain_font);

	const char* toggleLayoutLabel;
	if (fButtonLayout->Orientation() == B_HORIZONTAL)
		toggleLayoutLabel = B_TRANSLATE("Vertical layout");
	else
		toggleLayoutLabel = B_TRANSLATE("Horizontal layout");
	item = new BMenuItem(toggleLayoutLabel, new BMessage(MSG_TOGGLE_LAYOUT));
	item->SetTarget(this);
	settingsM->AddItem(item);

	BMenu* iconSizeM = new BMenu(B_TRANSLATE("Icon size"));
	for (uint32 i = 0; i < sizeof(kIconSizes) / sizeof(uint32); i++) {
		uint32 iconSize = kIconSizes[i];
		message = new BMessage(MSG_SET_ICON_SIZE);
		message->AddInt32("size", iconSize);
		BString label;
		label << iconSize << " x " << iconSize;
		item = new BMenuItem(label.String(), message);
		item->SetTarget(this);
		item->SetMarked(IconSize() == iconSize);
		iconSizeM->AddItem(item);
	}
	settingsM->AddItem(iconSizeM);

	item = new BMenuItem(B_TRANSLATE("Ignore double-click"),
		new BMessage(MSG_SET_IGNORE_DOUBLECLICK));
	item->SetTarget(this);
	item->SetMarked(IgnoreDoubleClick());
	settingsM->AddItem(item);

	uint32 what = window->Look() == B_BORDERED_WINDOW_LOOK ? MSG_SHOW_BORDER : MSG_HIDE_BORDER;
	item = new BMenuItem(B_TRANSLATE("Show window border"), new BMessage(what));
	item->SetTarget(window);
	item->SetMarked(what == MSG_HIDE_BORDER);
	settingsM->AddItem(item);

	item = new BMenuItem(B_TRANSLATE("Auto-raise"), new BMessage(MSG_TOGGLE_AUTORAISE));
	item->SetTarget(window);
	item->SetMarked(window->AutoRaise());
	settingsM->AddItem(item);

	item = new BMenuItem(B_TRANSLATE("Show on all workspaces"), new BMessage(MSG_SHOW_ON_ALL_WORKSPACES));
//.........这里部分代码省略.........
开发者ID:Barrett17,项目名称:haiku-contacts-kit-old,代码行数:101,代码来源:PadView.cpp

示例6: msg

TeapotWindow::TeapotWindow(BRect rect, const char* name, window_type wt,
	ulong something)
	:
	BDirectWindow(rect, name, wt, something)
{
	GLenum type = BGL_RGB | BGL_DEPTH | BGL_DOUBLE;

	Lock();
	BRect bounds = Bounds();
	bounds.bottom = bounds.top + 14;
	BMenuBar* menuBar = new BMenuBar(bounds, "main menu");

	BMenu* menu;
	BMessage msg(kMsgAddModel);

	menuBar->AddItem(menu = new BMenu(B_TRANSLATE("File")));
	AddChild(menuBar);

	menuBar->ResizeToPreferred();

	bounds = Bounds();
	bounds.top = menuBar->Bounds().bottom + 1;
	BView *subView = new BView(bounds, "subview", B_FOLLOW_ALL, 0);
	AddChild(subView);

	bounds = subView->Bounds();
	fObjectView = new(std::nothrow) ObjectView(bounds, "objectView",
		B_FOLLOW_ALL_SIDES, type);
	subView->AddChild(fObjectView);

	BMenuItem*	item;
	msg.AddInt32("num", 256);
	menu->AddItem(item = new BMenuItem(B_TRANSLATE("Add a teapot"),
		new BMessage(msg), 'N'));
	item->SetTarget(fObjectView);
	menu->AddSeparatorItem();
	menu->AddItem(item = new BMenuItem(B_TRANSLATE("Quit"),
		new BMessage(B_QUIT_REQUESTED), 'Q'));
	item->SetTarget(be_app);
	msg.RemoveName("num");
	menuBar->AddItem(menu = new BMenu(B_TRANSLATE("Options")));
	menu->AddItem(item = new BMenuItem(B_TRANSLATE("Perspective"),
		new BMessage(kMsgPerspective)));
	item->SetTarget(fObjectView);
	item->SetMarked(false);
	menu->AddItem(item = new BMenuItem(B_TRANSLATE("FPS display"),
		new BMessage(kMsgFPS)));
	item->SetTarget(fObjectView);
	item->SetMarked(true);
	menu->AddItem(item = new BMenuItem(B_TRANSLATE("Filled polygons"),
		new BMessage(kMsgFilled)));
	item->SetTarget(fObjectView);
	item->SetMarked(true);
	menu->AddItem(item = new BMenuItem(B_TRANSLATE("Lighting"),
		new BMessage(kMsgLighting)));
	item->SetTarget(fObjectView);
	item->SetMarked(true);
	menu->AddItem(item = new BMenuItem(B_TRANSLATE("Backface culling"),
		new BMessage(kMsgCulling)));
	item->SetTarget(fObjectView);
	item->SetMarked(true);
	menu->AddItem(item = new BMenuItem(B_TRANSLATE("Z-buffered"),
		new BMessage(kMsgZBuffer)));
	item->SetTarget(fObjectView);
	item->SetMarked(true);
	menu->AddItem(item = new BMenuItem(B_TRANSLATE("Gouraud shading"),
		new BMessage(kMsgGouraud)));
	item->SetTarget(fObjectView);
	item->SetMarked(true);
//	menu->AddItem(item = new BMenuItem("Texture mapped", new BMessage(kMsgTextured)));
//	item->SetTarget(fObjectView);
	menu->AddItem(item = new BMenuItem(B_TRANSLATE("Fog"),
		new BMessage(kMsgFog)));
	item->SetTarget(fObjectView);

	BMenu *subMenu;
	menuBar->AddItem(menu = new BMenu(B_TRANSLATE("Lights")));
	msg.what = kMsgLights;

	msg.AddInt32("num", 1);
	menu->AddItem(item = new BMenuItem(subMenu =
		new BMenu(B_TRANSLATE("Upper center")), NULL));
	item->SetTarget(fObjectView);
	msg.AddInt32("color", lightNone);
	subMenu->AddItem(item = new BMenuItem(B_TRANSLATE("Off"),
		new BMessage(msg)));
	item->SetTarget(fObjectView);
	subMenu->AddSeparatorItem();
	msg.ReplaceInt32("color", lightWhite);
	subMenu->AddItem(item = new BMenuItem(B_TRANSLATE("White"),
		new BMessage(msg)));
	item->SetTarget(fObjectView);
	item->SetMarked(true);
	msg.ReplaceInt32("color", lightYellow);
	subMenu->AddItem(item = new BMenuItem(B_TRANSLATE("Yellow"),
		new BMessage(msg)));
	item->SetTarget(fObjectView);
	msg.ReplaceInt32("color", lightBlue);
	subMenu->AddItem(item = new BMenuItem(B_TRANSLATE("Blue"),
		new BMessage(msg)));
//.........这里部分代码省略.........
开发者ID:veer77,项目名称:Haiku-services-branch,代码行数:101,代码来源:TeapotWindow.cpp

示例7: fullAlignment

FileTypesWindow::FileTypesWindow(const BMessage& settings)
	:
	BWindow(_Frame(settings), B_TRANSLATE_SYSTEM_NAME("FileTypes"),
		B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS
		| B_AUTO_UPDATE_SIZE_LIMITS),
	fNewTypeWindow(NULL)
{
	bool showIcons;
	bool showRule;
	if (settings.FindBool("show_icons", &showIcons) != B_OK)
		showIcons = true;
	if (settings.FindBool("show_rule", &showRule) != B_OK)
		showRule = false;

	float padding = be_control_look->DefaultItemSpacing();
	BAlignment labelAlignment = be_control_look->DefaultLabelAlignment();
	BAlignment fullAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT);

	// add the menu
	BMenuBar* menuBar = new BMenuBar("");

	BMenu* menu = new BMenu(B_TRANSLATE("File"));
	BMenuItem* item = new BMenuItem(
		B_TRANSLATE("New resource file" B_UTF8_ELLIPSIS), NULL, 'N',
		B_COMMAND_KEY);
	item->SetEnabled(false);
	menu->AddItem(item);

	BMenu* recentsMenu = BRecentFilesList::NewFileListMenu(
		B_TRANSLATE("Open" B_UTF8_ELLIPSIS), NULL, NULL,
		be_app, 10, false, NULL, kSignature);
	item = new BMenuItem(recentsMenu, new BMessage(kMsgOpenFilePanel));
	item->SetShortcut('O', B_COMMAND_KEY);
	menu->AddItem(item);

	menu->AddItem(new BMenuItem(
		B_TRANSLATE("Application types" B_UTF8_ELLIPSIS),
		new BMessage(kMsgOpenApplicationTypesWindow)));
	menu->AddSeparatorItem();

	menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"),
		new BMessage(B_QUIT_REQUESTED), 'Q', B_COMMAND_KEY));
	menu->SetTargetForItems(be_app);
	menuBar->AddItem(menu);

	menu = new BMenu(B_TRANSLATE("Settings"));
	item = new BMenuItem(B_TRANSLATE("Show icons in list"),
		new BMessage(kMsgToggleIcons));
	item->SetMarked(showIcons);
	item->SetTarget(this);
	menu->AddItem(item);

	item = new BMenuItem(B_TRANSLATE("Show recognition rule"),
		new BMessage(kMsgToggleRule));
	item->SetMarked(showRule);
	item->SetTarget(this);
	menu->AddItem(item);
	menuBar->AddItem(menu);
	menuBar->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));

	// MIME Types list
	BButton* addTypeButton = new BButton("add",
		B_TRANSLATE("Add" B_UTF8_ELLIPSIS), new BMessage(kMsgAddType));

	fRemoveTypeButton = new BButton("remove", B_TRANSLATE("Remove"),
		new BMessage(kMsgRemoveType) );

	fTypeListView = new MimeTypeListView("typeview", NULL, showIcons, false);
	fTypeListView->SetSelectionMessage(new BMessage(kMsgTypeSelected));
	fTypeListView->SetExplicitMinSize(BSize(200, B_SIZE_UNSET));

	BScrollView* typeListScrollView = new BScrollView("scrollview",
		fTypeListView, B_FRAME_EVENTS | B_WILL_DRAW, false, true);

	// "Icon" group

	fIconView = new TypeIconView("icon");
	fIconBox = new BBox("Icon BBox");
	fIconBox->SetLabel(B_TRANSLATE("Icon"));
	BLayoutBuilder::Group<>(fIconBox, B_VERTICAL, padding)
		.SetInsets(padding)
		.AddGlue(1)
		.Add(fIconView, 3)
		.AddGlue(1);

	// "File Recognition" group

	fRecognitionBox = new BBox("Recognition Box");
	fRecognitionBox->SetLabel(B_TRANSLATE("File recognition"));
	fRecognitionBox->SetExplicitAlignment(fullAlignment);

	fExtensionLabel = new StringView(B_TRANSLATE("Extensions:"), NULL);
	fExtensionLabel->LabelView()->SetExplicitAlignment(labelAlignment);

	fAddExtensionButton = new BButton("add ext",
		B_TRANSLATE("Add" B_UTF8_ELLIPSIS), new BMessage(kMsgAddExtension));
	fAddExtensionButton->SetExplicitMaxSize(
		BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));

	fRemoveExtensionButton = new BButton("remove ext", B_TRANSLATE("Remove"),
//.........这里部分代码省略.........
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:101,代码来源:FileTypesWindow.cpp

示例8: path

void
HWindow::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case M_OTHER_MESSAGE:
		{
			BMenuField* menufield
				= dynamic_cast<BMenuField*>(FindView("filemenu"));
			if (menufield == NULL)
				return;
			BMenu* menu = menufield->Menu();

			HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
			if (row != NULL) {
				BPath path(row->Path());
				if (path.InitCheck() != B_OK) {
					BMenuItem* item = menu->FindItem(B_TRANSLATE("<none>"));
					if (item != NULL)
						item->SetMarked(true);
				} else {
					BMenuItem* item = menu->FindItem(path.Leaf());
					if (item != NULL)
						item->SetMarked(true);
				}
			}
			fFilePanel->Show();
			break;
		}

		case B_SIMPLE_DATA:
		case B_REFS_RECEIVED:
		{
			entry_ref ref;
			HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
			if (message->FindRef("refs", &ref) == B_OK && row != NULL) {
				BMenuField* menufield
					= dynamic_cast<BMenuField*>(FindView("filemenu"));
				if (menufield == NULL)
					return;
				BMenu* menu = menufield->Menu();

				// check audio file
				BNode node(&ref);
				BNodeInfo ninfo(&node);
				char type[B_MIME_TYPE_LENGTH + 1];
				ninfo.GetType(type);
				BMimeType mtype(type);
				BMimeType superType;
				mtype.GetSupertype(&superType);
				if (superType.Type() == NULL
					|| strcmp(superType.Type(), "audio") != 0) {
					beep();
					BAlert* alert = new BAlert("",
						B_TRANSLATE("This is not an audio file."),
						B_TRANSLATE("OK"), NULL, NULL,
						B_WIDTH_AS_USUAL, B_STOP_ALERT);
					alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
					alert->Go();
					break;
				}

				// add file item
				BMessage* msg = new BMessage(M_ITEM_MESSAGE);
				BPath path(&ref);
				msg->AddRef("refs", &ref);
				BMenuItem* menuitem = menu->FindItem(path.Leaf());
				if (menuitem == NULL)
					menu->AddItem(menuitem = new BMenuItem(path.Leaf(), msg), 0);
				// refresh item
				fEventList->SetPath(BPath(&ref).Path());
				// check file menu
				if (menuitem != NULL)
					menuitem->SetMarked(true);
			}
			break;
		}

		case M_PLAY_MESSAGE:
		{
			HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
			if (row != NULL) {
				const char* path = row->Path();
				if (path != NULL) {
					entry_ref ref;
					::get_ref_for_path(path, &ref);
					delete fPlayer;
					fPlayer = new BFileGameSound(&ref, false);
					fPlayer->StartPlaying();
				}
			}
			break;
		}

		case M_STOP_MESSAGE:
		{
			if (fPlayer == NULL)
				break;
			if (fPlayer->IsPlaying()) {
				fPlayer->StopPlaying();
				delete fPlayer;
//.........这里部分代码省略.........
开发者ID:AmirAbrams,项目名称:haiku,代码行数:101,代码来源:HWindow.cpp

示例9: BMessage

SerialWindow::SerialWindow()
	: BWindow(BRect(100, 100, 400, 400), SerialWindow::kWindowTitle,
		B_DOCUMENT_WINDOW, B_QUIT_ON_WINDOW_CLOSE | B_AUTO_UPDATE_SIZE_LIMITS)
	, fLogFilePanel(NULL)
{
	BMenuBar* menuBar = new BMenuBar(Bounds(), "menuBar");
	menuBar->ResizeToPreferred();

	BRect r = Bounds();
	r.top = menuBar->Bounds().bottom + 1;
	r.right -= B_V_SCROLL_BAR_WIDTH;
	fTermView = new TermView(r);
	fTermView->ResizeToPreferred();

	r = fTermView->Frame();
	r.left = r.right + 1;
	r.right = r.left + B_V_SCROLL_BAR_WIDTH;
	r.top -= 1;
	r.bottom -= B_H_SCROLL_BAR_HEIGHT - 1;
	BScrollBar* scrollBar = new BScrollBar(r, "scrollbar", NULL, 0, 0,
		B_VERTICAL);

	scrollBar->SetTarget(fTermView);

	ResizeTo(r.right - 1, r.bottom + B_H_SCROLL_BAR_HEIGHT - 1);

	AddChild(menuBar);
	AddChild(fTermView);
	AddChild(scrollBar);

	fConnectionMenu = new BMenu("Connection");
	BMenu* fileMenu = new BMenu("File");
	BMenu* settingsMenu = new BMenu("Settings");

	fConnectionMenu->SetRadioMode(true);

	menuBar->AddItem(fConnectionMenu);
	menuBar->AddItem(fileMenu);
	menuBar->AddItem(settingsMenu);

	// TODO edit menu - what's in it ?
	//BMenu* editMenu = new BMenu("Edit");
	//menuBar->AddItem(editMenu);

	BMenuItem* logFile = new BMenuItem("Log to file" B_UTF8_ELLIPSIS,
		new BMessage(kMsgLogfile));
	fileMenu->AddItem(logFile);
#if 0
	// TODO implement these
	BMenuItem* xmodemSend = new BMenuItem("X/Y/ZModem send" B_UTF8_ELLIPSIS,
		NULL);
	fileMenu->AddItem(xmodemSend);
	BMenuItem* xmodemReceive = new BMenuItem(
		"X/Y/Zmodem receive" B_UTF8_ELLIPSIS, NULL);
	fileMenu->AddItem(xmodemReceive);
#endif

	// Configuring all this by menus may be a bit unhandy. Make a setting
	// window instead ?
	fBaudrateMenu = new BMenu("Baud rate");
	fBaudrateMenu->SetRadioMode(true);
	settingsMenu->AddItem(fBaudrateMenu);

	fParityMenu = new BMenu("Parity");
	fParityMenu->SetRadioMode(true);
	settingsMenu->AddItem(fParityMenu);

	fStopbitsMenu = new BMenu("Stop bits");
	fStopbitsMenu->SetRadioMode(true);
	settingsMenu->AddItem(fStopbitsMenu);

	fFlowcontrolMenu = new BMenu("Flow control");
	fFlowcontrolMenu->SetRadioMode(true);
	settingsMenu->AddItem(fFlowcontrolMenu);

	fDatabitsMenu = new BMenu("Data bits");
	fDatabitsMenu->SetRadioMode(true);
	settingsMenu->AddItem(fDatabitsMenu);


	BMessage* message = new BMessage(kMsgSettings);
	message->AddInt32("parity", B_NO_PARITY);
	BMenuItem* parityNone = new BMenuItem("None", message);

	message = new BMessage(kMsgSettings);
	message->AddInt32("parity", B_ODD_PARITY);
	BMenuItem* parityOdd = new BMenuItem("Odd", message);

	message = new BMessage(kMsgSettings);
	message->AddInt32("parity", B_EVEN_PARITY);
	BMenuItem* parityEven = new BMenuItem("Even", message);

	fParityMenu->AddItem(parityNone);
	fParityMenu->AddItem(parityOdd);
	fParityMenu->AddItem(parityEven);
	fParityMenu->SetTargetForItems(be_app);

	message = new BMessage(kMsgSettings);
	message->AddInt32("databits", B_DATA_BITS_7);
	BMenuItem* data7 = new BMenuItem("7", message);
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例10: BMessage

BMenuBar*
MainWindow::_CreateMenuBar()
{
	BMenuBar* menuBar = new BMenuBar("main menu");


	#undef B_TRANSLATE_CONTEXT
	#define B_TRANSLATE_CONTEXT "Icon-O-Matic-Menus"
	
	
	BMenu* fileMenu = new BMenu(B_TRANSLATE("File"));
	BMenu* editMenu = new BMenu(B_TRANSLATE("Edit"));
	BMenu* settingsMenu = new BMenu(B_TRANSLATE("Options"));
	fPathMenu = new BMenu(B_TRANSLATE("Path"));
	fStyleMenu = new BMenu(B_TRANSLATE("Style"));
	fShapeMenu = new BMenu(B_TRANSLATE("Shape"));
	fTransformerMenu = new BMenu(B_TRANSLATE("Transformer"));
	fPropertyMenu = new BMenu(B_TRANSLATE("Properties"));
	fSwatchMenu = new BMenu(B_TRANSLATE("Swatches"));

	menuBar->AddItem(fileMenu);
	menuBar->AddItem(editMenu);
	menuBar->AddItem(settingsMenu);


	// File
	#undef B_TRANSLATE_CONTEXT
	#define B_TRANSLATE_CONTEXT "Icon-O-Matic-Menu-File"
	

	BMenuItem* item = new BMenuItem(B_TRANSLATE("New"),
		new BMessage(MSG_NEW), 'N');
	fileMenu->AddItem(item);
	item->SetTarget(be_app);
	item = new BMenuItem(B_TRANSLATE("Open"B_UTF8_ELLIPSIS),
		new BMessage(MSG_OPEN), 'O');
	fileMenu->AddItem(item);
	BMessage* appendMessage = new BMessage(MSG_APPEND);
	appendMessage->AddPointer("window", this);
	item = new BMenuItem(B_TRANSLATE("Append"B_UTF8_ELLIPSIS),
		appendMessage, 'O', B_SHIFT_KEY);
	fileMenu->AddItem(item);
	item->SetTarget(be_app);
	fileMenu->AddSeparatorItem();
	fileMenu->AddItem(new BMenuItem(B_TRANSLATE("Save"),
		new BMessage(MSG_SAVE), 'S'));
	fileMenu->AddItem(new BMenuItem(B_TRANSLATE("Save as"B_UTF8_ELLIPSIS),
		new BMessage(MSG_SAVE_AS), 'S', B_SHIFT_KEY));
	fileMenu->AddSeparatorItem();
	fileMenu->AddItem(new BMenuItem(B_TRANSLATE("Export"),
		new BMessage(MSG_EXPORT), 'P'));
	fileMenu->AddItem(new BMenuItem(B_TRANSLATE("Export as"B_UTF8_ELLIPSIS),
		new BMessage(MSG_EXPORT_AS), 'P', B_SHIFT_KEY));
	fileMenu->AddSeparatorItem();
	fileMenu->AddItem(new BMenuItem(B_TRANSLATE("Close"),
		new BMessage(B_QUIT_REQUESTED), 'W'));
	item = new BMenuItem(B_TRANSLATE("Quit"),
		new BMessage(B_QUIT_REQUESTED), 'Q');
	fileMenu->AddItem(item);
	item->SetTarget(be_app);

	// Edit
	#undef B_TRANSLATE_CONTEXT
	#define B_TRANSLATE_CONTEXT "Icon-O-Matic-Menu-Edit"
	
	
	fUndoMI = new BMenuItem(B_TRANSLATE("<nothing to undo>"),
		new BMessage(MSG_UNDO), 'Z');
	fRedoMI = new BMenuItem(B_TRANSLATE("<nothing to redo>"),
		new BMessage(MSG_REDO), 'Z', B_SHIFT_KEY);

	fUndoMI->SetEnabled(false);
	fRedoMI->SetEnabled(false);

	editMenu->AddItem(fUndoMI);
	editMenu->AddItem(fRedoMI);


	// Settings
	#undef B_TRANSLATE_CONTEXT
	#define B_TRANSLATE_CONTEXT "Icon-O-Matic-Menu-Settings"
	
	
	BMenu* filterModeMenu = new BMenu(B_TRANSLATE("Snap to grid"));
	BMessage* message = new BMessage(MSG_MOUSE_FILTER_MODE);
	message->AddInt32("mode", SNAPPING_OFF);
	fMouseFilterOffMI = new BMenuItem(B_TRANSLATE("Off"), message, '4');
	filterModeMenu->AddItem(fMouseFilterOffMI);

	message = new BMessage(MSG_MOUSE_FILTER_MODE);
	message->AddInt32("mode", SNAPPING_64);
	fMouseFilter64MI = new BMenuItem("64 x 64", message, '3');
	filterModeMenu->AddItem(fMouseFilter64MI);

	message = new BMessage(MSG_MOUSE_FILTER_MODE);
	message->AddInt32("mode", SNAPPING_32);
	fMouseFilter32MI = new BMenuItem("32 x 32", message, '2');
	filterModeMenu->AddItem(fMouseFilter32MI);

	message = new BMessage(MSG_MOUSE_FILTER_MODE);
//.........这里部分代码省略.........
开发者ID:michael-manley,项目名称:haiku,代码行数:101,代码来源:MainWindow.cpp

示例11: BMenu

void
ShowImageWindow::_AddMenus(BMenuBar* bar)
{
	BMenu* menu = new BMenu(B_TRANSLATE("File"));

	// Add recent files to "Open File" entry as sub-menu.
	BMenuItem* item = new BMenuItem(BRecentFilesList::NewFileListMenu(
		B_TRANSLATE("Open" B_UTF8_ELLIPSIS), NULL, NULL, be_app, 10, true,
		NULL, kApplicationSignature), new BMessage(MSG_FILE_OPEN));
	item->SetShortcut('O', 0);
	item->SetTarget(be_app);
	menu->AddItem(item);
	menu->AddSeparatorItem();

	BMenu* menuSaveAs = new BMenu(B_TRANSLATE("Save as" B_UTF8_ELLIPSIS),
		B_ITEMS_IN_COLUMN);
	BTranslationUtils::AddTranslationItems(menuSaveAs, B_TRANSLATOR_BITMAP);
		// Fill Save As submenu with all types that can be converted
		// to from the Be bitmap image format
	menu->AddItem(menuSaveAs);
	_AddItemMenu(menu, B_TRANSLATE("Close"), B_QUIT_REQUESTED, 'W', 0, this);
	_AddItemMenu(menu, B_TRANSLATE("Move to Trash"), kMsgDeleteCurrentFile, 'T', 0, this);
	menu->AddSeparatorItem();
	_AddItemMenu(menu, B_TRANSLATE("Page setup" B_UTF8_ELLIPSIS),
		MSG_PAGE_SETUP, 0, 0, this);
	_AddItemMenu(menu, B_TRANSLATE("Print" B_UTF8_ELLIPSIS),
		MSG_PREPARE_PRINT, 'P', 0, this);
	menu->AddSeparatorItem();
	_AddItemMenu(menu, B_TRANSLATE("Quit"), B_QUIT_REQUESTED, 'Q', 0, be_app);
	bar->AddItem(menu);

	menu = new BMenu(B_TRANSLATE("Edit"));
	_AddItemMenu(menu, B_TRANSLATE("Copy"), B_COPY, 'C', 0, this, false);
	menu->AddSeparatorItem();
	_AddItemMenu(menu, B_TRANSLATE("Selection mode"), MSG_SELECTION_MODE, 0, 0,
		this);
	_AddItemMenu(menu, B_TRANSLATE("Clear selection"),
		MSG_CLEAR_SELECT, 0, 0, this, false);
	_AddItemMenu(menu, B_TRANSLATE("Select all"),
		MSG_SELECT_ALL, 'A', 0, this);
	bar->AddItem(menu);

	menu = fBrowseMenu = new BMenu(B_TRANSLATE("Browse"));
	_AddItemMenu(menu, B_TRANSLATE("First page"),
		MSG_PAGE_FIRST, B_LEFT_ARROW, B_SHIFT_KEY, this);
	_AddItemMenu(menu, B_TRANSLATE("Last page"),
		MSG_PAGE_LAST, B_RIGHT_ARROW, B_SHIFT_KEY, this);
	_AddItemMenu(menu, B_TRANSLATE("Previous page"),
		MSG_PAGE_PREV, B_LEFT_ARROW, 0, this);
	_AddItemMenu(menu, B_TRANSLATE("Next page"),
		MSG_PAGE_NEXT, B_RIGHT_ARROW, 0, this);
	fGoToPageMenu = new BMenu(B_TRANSLATE("Go to page"));
	fGoToPageMenu->SetRadioMode(true);
	menu->AddItem(fGoToPageMenu);
	menu->AddSeparatorItem();
	_AddItemMenu(menu, B_TRANSLATE("Previous file"),
		MSG_FILE_PREV, B_UP_ARROW, 0, this);
	_AddItemMenu(menu, B_TRANSLATE("Next file"),
		MSG_FILE_NEXT, B_DOWN_ARROW, 0, this);
	bar->AddItem(menu);

	menu = new BMenu(B_TRANSLATE("Image"));
	_AddItemMenu(menu, B_TRANSLATE("Rotate clockwise"),
		MSG_ROTATE_90, 'R', 0, this);
	_AddItemMenu(menu, B_TRANSLATE("Rotate counterclockwise"),
		MSG_ROTATE_270, 'R', B_SHIFT_KEY, this);
	menu->AddSeparatorItem();
	_AddItemMenu(menu, B_TRANSLATE("Flip left to right"),
		MSG_FLIP_LEFT_TO_RIGHT, 0, 0, this);
	_AddItemMenu(menu, B_TRANSLATE("Flip top to bottom"),
		MSG_FLIP_TOP_TO_BOTTOM, 0, 0, this);
	menu->AddSeparatorItem();
	_AddItemMenu(menu, B_TRANSLATE("Use as background" B_UTF8_ELLIPSIS),
		MSG_DESKTOP_BACKGROUND, 0, 0, this);

	bar->AddItem(menu);
}
开发者ID:yunxiaoxiao110,项目名称:haiku,代码行数:77,代码来源:ShowImageWindow.cpp

示例12: Filter

SelectionWindow::SelectionWindow(BContainerWindow* window)
	:
	BWindow(BRect(0, 0, 270, 0), B_TRANSLATE("Select"),	B_TITLED_WINDOW,
		B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_NOT_V_RESIZABLE
			| B_NO_WORKSPACE_ACTIVATION | B_ASYNCHRONOUS_CONTROLS
			| B_NOT_ANCHORED_ON_ACTIVATE),
	fParentWindow(window)
{
	if (window->Feel() & kDesktopWindowFeel) {
		// The window will not show up if we have
		// B_FLOATING_SUBSET_WINDOW_FEEL and use it with the desktop window
		// since it's never in front.
		SetFeel(B_NORMAL_WINDOW_FEEL);
	}

	AddToSubset(fParentWindow);

	BView* backgroundView = new BView(Bounds(), "bgView", B_FOLLOW_ALL,
		B_WILL_DRAW);
	backgroundView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
	AddChild(backgroundView);

	BMenu* menu = new BPopUpMenu("");
	menu->AddItem(new BMenuItem(B_TRANSLATE("starts with"),	NULL));
	menu->AddItem(new BMenuItem(B_TRANSLATE("ends with"), NULL));
	menu->AddItem(new BMenuItem(B_TRANSLATE("contains"), NULL));
	menu->AddItem(new BMenuItem(B_TRANSLATE("matches wildcard expression"),
		NULL));
	menu->AddItem(new BMenuItem(B_TRANSLATE("matches regular expression"),
		NULL));

	menu->SetLabelFromMarked(true);
	menu->ItemAt(3)->SetMarked(true);
		// Set wildcard matching to default.

	// Set up the menu field
	fMatchingTypeMenuField = new BMenuField(BRect(7, 6,
		Bounds().right - 5, 0), NULL, B_TRANSLATE("Name"), menu);
	backgroundView->AddChild(fMatchingTypeMenuField);
	fMatchingTypeMenuField->SetDivider(fMatchingTypeMenuField->StringWidth(
		B_TRANSLATE("Name")) + 8);
	fMatchingTypeMenuField->ResizeToPreferred();

	// Set up the expression text control
	fExpressionTextControl = new BTextControl(BRect(7,
			fMatchingTypeMenuField->Bounds().bottom + 11,
			Bounds().right - 6, 0),
		NULL, NULL, NULL, NULL, B_FOLLOW_LEFT_RIGHT);
	backgroundView->AddChild(fExpressionTextControl);
	fExpressionTextControl->ResizeToPreferred();
	fExpressionTextControl->MakeFocus(true);

	// Set up the Invert checkbox
	fInverseCheckBox = new BCheckBox(
		BRect(7, fExpressionTextControl->Frame().bottom + 6, 6, 6), NULL,
		B_TRANSLATE("Invert"), NULL);
	backgroundView->AddChild(fInverseCheckBox);
	fInverseCheckBox->ResizeToPreferred();

	// Set up the Ignore Case checkbox
	fIgnoreCaseCheckBox = new BCheckBox(
		BRect(fInverseCheckBox->Frame().right + 10,
			fInverseCheckBox->Frame().top, 6, 6),
		NULL, B_TRANSLATE("Ignore case"), NULL);
	fIgnoreCaseCheckBox->SetValue(1);
	backgroundView->AddChild(fIgnoreCaseCheckBox);
	fIgnoreCaseCheckBox->ResizeToPreferred();

	// Set up the Select button
	fSelectButton = new BButton(BRect(0, 0, 5, 5), NULL,
		B_TRANSLATE("Select"), new BMessage(kSelectButtonPressed),
		B_FOLLOW_RIGHT);

	backgroundView->AddChild(fSelectButton);
	fSelectButton->ResizeToPreferred();
	fSelectButton->MoveTo(Bounds().right - 10 - fSelectButton->Bounds().right,
		fExpressionTextControl->Frame().bottom + 9);
	fSelectButton->MakeDefault(true);
#if !B_BEOS_VERSION_DANO
	fSelectButton->SetLowColor(backgroundView->ViewColor());
	fSelectButton->SetViewColor(B_TRANSPARENT_COLOR);
#endif

	font_height fh;
	be_plain_font->GetHeight(&fh);
	// Center the checkboxes vertically to the button
	float topMiddleButton =
		(fSelectButton->Bounds().Height() / 2 -
		(fh.ascent + fh.descent + fh.leading + 4) / 2)
		+ fSelectButton->Frame().top;
	fInverseCheckBox->MoveTo(fInverseCheckBox->Frame().left, topMiddleButton);
	fIgnoreCaseCheckBox->MoveTo(fIgnoreCaseCheckBox->Frame().left,
		topMiddleButton);

	float bottomMinWidth = 32 + fSelectButton->Bounds().Width()
		+ fInverseCheckBox->Bounds().Width()
		+ fIgnoreCaseCheckBox->Bounds().Width();
	float topMinWidth = be_plain_font->StringWidth(
		B_TRANSLATE("Name matches wildcard expression:###"));
	float minWidth = bottomMinWidth > topMinWidth
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例13: nullrect

CharismaWindow::CharismaWindow(BPoint origin):
	BWindow(BRect(origin.x,origin.y,origin.x+200,origin.y+80),
		"Charisma", B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, 
		B_NOT_RESIZABLE|B_NOT_ZOOMABLE|B_WILL_ACCEPT_FIRST_CLICK)
{
	BRect nullrect(0,0,0,0),r;
	BMenu *m;
	BWindow *w;
	char buf[100];
	
	isminim=0;
	
	// le menu
	menubar=new BMenuBar(BRect(0,0,0,0),"menu bar");
	m=new BMenu("File");
	m->AddItem(new BMenuItem("About…",new BMessage(kMsg_About)));
	m->AddSeparatorItem();
	m->AddItem(new BMenuItem("Quit",new BMessage(B_QUIT_REQUESTED),'Q'));
	menubar->AddItem(m);
	m=new BMenu("Settings");
	m->AddItem(new BMenuItem("Select Web Directory…",new BMessage(kMsg_SelectDirectory)));
	m->AddSeparatorItem();
	m->AddItem(extcontrol_item=new BMenuItem("External Control",new BMessage(kMsg_ExternalControl)));
	m->AddItem(netposautoset_item=new BMenuItem("Net+ Autosettings",new BMessage(kMsg_NetposAutosettings)));
	m->AddSeparatorItem();
	m->AddItem(new BMenuItem("Clear Hits",new BMessage(kMsg_ClearHits)));
	menubar->AddItem(m);
	AddChild(menubar);

	// le fond gris
	r=Frame();
	setupview=new BView(
		BRect(0,menubar->Frame().bottom,r.Width(),r.Height()),
		"background",B_FOLLOW_NONE,B_WILL_DRAW);
	setupview->SetViewColor(0xDD,0xDD,0xDD);
	AddChild(setupview);
	
	// "Mode"
	m=new BPopUpMenu("");
	m->AddItem(new BMenuItem("Disabled",MSG));
	m->AddItem(new BMenuItem("Offline",MSG));
	m->AddItem(new BMenuItem("Online",MSG));
	modemenu=new BMenuField(
		BRect(10.0f,10.0f,20.0f,20.0f),"mode",
		"Mode:",
		m);
	BMenuField_resize(modemenu);
	setupview->AddChild(modemenu);

	// "Refresh"
	m=new BPopUpMenu("");
	m->AddItem(new BMenuItem("Dumb",MSG));
	m->AddSeparatorItem();
	m->AddItem(new BMenuItem("Always",MSG));
	m->AddItem(new BMenuItem("Once per session",MSG));
	m->AddSeparatorItem();
	m->AddItem(new BMenuItem("After 1 hour",MSG));
	m->AddItem(new BMenuItem("After 6 hours",MSG));
	m->AddItem(new BMenuItem("After 12 hours",MSG));
	m->AddSeparatorItem();
	m->AddItem(new BMenuItem("After 1 day",MSG));
	m->AddItem(new BMenuItem("After 2 days",MSG));
	m->AddItem(new BMenuItem("After 3 days",MSG));
	m->AddSeparatorItem();
	m->AddItem(new BMenuItem("After 1 week",MSG));
	m->AddItem(new BMenuItem("After 2 weeks",MSG));
	m->AddSeparatorItem();
	m->AddItem(new BMenuItem("After 1 month",MSG));
	m->AddItem(new BMenuItem("After 2 month",MSG));
	m->AddItem(new BMenuItem("After 6 month",MSG));
	m->AddSeparatorItem();
	m->AddItem(new BMenuItem("After 1 year",MSG));
	m->AddItem(new BMenuItem("After 2 years",MSG));
	m->AddSeparatorItem();
	m->AddItem(new BMenuItem("never",MSG));
	smartrefresh=new BMenuField(
		rectunder(modemenu),"refresh",
		"Refresh:",
		m);
	BMenuField_resize(smartrefresh);
	setupview->AddChild(smartrefresh);
	
	// "Hits"
	r.left=10.0f;
	r.top=smartrefresh->Frame().bottom+10.0f;
	r.right=r.left+setupview->StringWidth("hits: 99999");
	r.bottom=r.top+BView_textheight(setupview);
	hits=new BStringView(r,"hits","");
	setupview->AddChild(hits);

	if(!gregistered){
		sprintf(buf,"This copy is not registered");
		r.left=10.0f;
		r.top=hits->Frame().bottom+10.0f;
		r.right=r.left+setupview->StringWidth(buf);
		r.bottom=r.top+BView_textheight(setupview);
		setupview->AddChild(new BStringView(r,NULL,buf));
	}

	r=BView_childrenframe(setupview);
//.........这里部分代码省略.........
开发者ID:HaikuArchives,项目名称:Stamina,代码行数:101,代码来源:main.cpp

示例14: BMessage

ApplicationTypeWindow::ApplicationTypeWindow(BPoint position,
	const BEntry& entry)
	:
	BWindow(BRect(0.0f, 0.0f, 250.0f, 340.0f).OffsetBySelf(position),
		B_TRANSLATE("Application type"), B_TITLED_WINDOW,
		B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS |
			B_FRAME_EVENTS | B_AUTO_UPDATE_SIZE_LIMITS),
	fChangedProperties(0)
{
	float padding = be_control_look->DefaultItemSpacing();
	BAlignment labelAlignment = be_control_look->DefaultLabelAlignment();

	BMenuBar* menuBar = new BMenuBar((char*)NULL);
	menuBar->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));

	BMenu* menu = new BMenu(B_TRANSLATE("File"));
	fSaveMenuItem = new BMenuItem(B_TRANSLATE("Save"),
		new BMessage(kMsgSave), 'S');
	fSaveMenuItem->SetEnabled(false);
	menu->AddItem(fSaveMenuItem);
	BMenuItem* item;
	menu->AddItem(item = new BMenuItem(
		B_TRANSLATE("Save into resource file" B_UTF8_ELLIPSIS), NULL));
	item->SetEnabled(false);

	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem(B_TRANSLATE("Close"),
		new BMessage(B_QUIT_REQUESTED), 'W', B_COMMAND_KEY));
	menuBar->AddItem(menu);

	// Signature

	fSignatureControl = new BTextControl(B_TRANSLATE("Signature:"), NULL,
		new BMessage(kMsgSignatureChanged));
	fSignatureControl->SetModificationMessage(
		new BMessage(kMsgSignatureChanged));

	// filter out invalid characters that can't be part of a MIME type name
	BTextView* textView = fSignatureControl->TextView();
	textView->SetMaxBytes(B_MIME_TYPE_LENGTH);
	const char* disallowedCharacters = "<>@,;:\"()[]?= ";
	for (int32 i = 0; disallowedCharacters[i]; i++) {
		textView->DisallowChar(disallowedCharacters[i]);
	}

	// "Application Flags" group

	BBox* flagsBox = new BBox("flagsBox");

	fFlagsCheckBox = new BCheckBox("flags", B_TRANSLATE("Application flags"),
		new BMessage(kMsgToggleAppFlags));
	fFlagsCheckBox->SetValue(B_CONTROL_ON);

	fSingleLaunchButton = new BRadioButton("single",
		B_TRANSLATE("Single launch"), new BMessage(kMsgAppFlagsChanged));

	fMultipleLaunchButton = new BRadioButton("multiple",
		B_TRANSLATE("Multiple launch"), new BMessage(kMsgAppFlagsChanged));

	fExclusiveLaunchButton = new BRadioButton("exclusive",
		B_TRANSLATE("Exclusive launch"), new BMessage(kMsgAppFlagsChanged));

	fArgsOnlyCheckBox = new BCheckBox("args only", B_TRANSLATE("Args only"),
		new BMessage(kMsgAppFlagsChanged));

	fBackgroundAppCheckBox = new BCheckBox("background",
		B_TRANSLATE("Background app"), new BMessage(kMsgAppFlagsChanged));

	BLayoutBuilder::Grid<>(flagsBox, 0, 0)
		.SetInsets(padding, padding * 2, padding, padding)
		.Add(fSingleLaunchButton, 0, 0).Add(fArgsOnlyCheckBox, 1, 0)
		.Add(fMultipleLaunchButton, 0, 1).Add(fBackgroundAppCheckBox, 1, 1)
		.Add(fExclusiveLaunchButton, 0, 2);
	flagsBox->SetLabel(fFlagsCheckBox);

	// "Icon" group

	BBox* iconBox = new BBox("IconBox");
	iconBox->SetLabel(B_TRANSLATE("Icon"));
	fIconView = new IconView("icon");
	fIconView->SetModificationMessage(new BMessage(kMsgIconChanged));
	BLayoutBuilder::Group<>(iconBox, B_HORIZONTAL)
		.SetInsets(padding, padding * 2, padding, padding)
		.Add(fIconView);

	// "Supported Types" group

	BBox* typeBox = new BBox("typesBox");
	typeBox->SetLabel(B_TRANSLATE("Supported types"));

	fTypeListView = new SupportedTypeListView("Suppported Types",
		B_SINGLE_SELECTION_LIST);
	fTypeListView->SetSelectionMessage(new BMessage(kMsgTypeSelected));

	BScrollView* scrollView = new BScrollView("type scrollview", fTypeListView,
		B_FRAME_EVENTS | B_WILL_DRAW, false, true);

	fAddTypeButton = new BButton("add type",
		B_TRANSLATE("Add" B_UTF8_ELLIPSIS), new BMessage(kMsgAddType));

//.........这里部分代码省略.........
开发者ID:Barrett17,项目名称:haiku-contacts-kit-old,代码行数:101,代码来源:ApplicationTypeWindow.cpp

示例15: BMessage

BMenuBar*
BoardWindow::_CreateMenuBar(void)
{
	BMenuBar* menuBar = new BMenuBar("BoardWindowMenuBar");
	BMenuItem*	menuItem;

	BMenu*	applicationMenu = new BMenu("Application");
	menuBar->AddItem(applicationMenu);
	BMenu*  newSubMenu = new BMenu("New");
	applicationMenu->AddItem(newSubMenu);
        menuItem = new BMenuItem("Blitz Game" B_UTF8_ELLIPSIS, NULL, 'B');
		newSubMenu->AddItem(menuItem);
		menuItem->SetEnabled(false);
        menuItem = new BMenuItem("Long Game" B_UTF8_ELLIPSIS, NULL, 'L');
		newSubMenu->AddItem(menuItem);
		menuItem->SetEnabled(false);
		newSubMenu->AddSeparatorItem();
        menuItem = new BMenuItem("Position Setup" B_UTF8_ELLIPSIS, NULL, 'P');
		newSubMenu->AddItem(menuItem);
		menuItem->SetEnabled(false);
        menuItem = new BMenuItem("Engine Match" B_UTF8_ELLIPSIS, NULL, 'E');
		newSubMenu->AddItem(menuItem);
		menuItem->SetEnabled(false);
		BMenu*  openSubMenu = new BMenu("Open");
		applicationMenu->AddItem(openSubMenu);
        menuItem = new BMenuItem("PGN File" B_UTF8_ELLIPSIS, NULL, 'O');
		openSubMenu->AddItem(menuItem);
		menuItem->SetEnabled(false);
        menuItem = new BMenuItem("Database" B_UTF8_ELLIPSIS, NULL, 'D');
		openSubMenu->AddItem(menuItem);
		menuItem->SetEnabled(false);

	applicationMenu->AddSeparatorItem();
	menuItem = new BMenuItem("Save" B_UTF8_ELLIPSIS, NULL, 'S');
    applicationMenu->AddItem(menuItem);
	menuItem->SetEnabled(false);
	applicationMenu->AddSeparatorItem();
    menuItem = new BMenuItem("Quit", new BMessage(MENU_APP_QUIT), 'Q');
	applicationMenu->AddItem(menuItem);

	BMenu*	editMenu = new BMenu("Edit");
	menuBar->AddItem(editMenu);

    menuItem = new BMenuItem("Copy Position", NULL, 'C');
	editMenu->AddItem(menuItem);
	menuItem->SetEnabled(false);
    menuItem = new BMenuItem("Paste Position", NULL, 'V');
	editMenu->AddItem(menuItem);
	menuItem->SetEnabled(false);

    editMenu->AddSeparatorItem();
    menuItem = new BMenuItem("Edit Game Data" B_UTF8_ELLIPSIS, NULL, 'E');
	editMenu->AddItem(menuItem);
	menuItem->SetEnabled(false);

	BMenu*	viewMenu = new BMenu("View");
	menuBar->AddItem(viewMenu);
    fFlipBoardMI = new BMenuItem("Flip Board", new BMessage(MENU_VIEW_FLIPBOARD));
    viewMenu->AddItem(fFlipBoardMI);
    fFlipBoardMI->SetShortcut('R', B_COMMAND_KEY);
    fFlipBoardMI->SetMarked(false);

	viewMenu->AddSeparatorItem();
    fMinIfMenuItem = new BMenuItem("Minimal Interface",
        new BMessage(MENU_VIEW_MININTERFACE), '1');
	f3DMI = new BMenuItem("3D", new BMessage(MENU_VIEW_3D));
    viewMenu->AddItem(f3DMI);
    f3DMI->SetShortcut('3', B_COMMAND_KEY);
    f3DMI->SetMarked(false);

    fFullScrMI = new BMenuItem("Fullscreen",
        new BMessage(MENU_VIEW_FULLSCREEN), 'F');
    viewMenu->AddItem(fFullScrMI);
    fFullScrMI->SetMarked(false);
    fFullScrMI->SetEnabled(true);
	viewMenu->AddSeparatorItem();
    fShowClockMenuItem = new BMenuItem("Show Clock",
        new BMessage(MENU_VIEW_SHOWCLOCK));
    viewMenu->AddItem(fShowClockMenuItem);
    fShowClockMenuItem->SetShortcut('T', B_COMMAND_KEY);
    fShowClockMenuItem->SetMarked(true);
    fShowMBarMenuItem = new BMenuItem("Show Menubar",
        new BMessage(MENU_VIEW_SHOWMENU));
	viewMenu->AddItem(fShowMBarMenuItem);
    fShowMBarMenuItem->SetShortcut('M', B_COMMAND_KEY);
    fShowMBarMenuItem->SetMarked(true);
    fSidebarMenuItem = new BMenuItem("Show Sidebar",
        new BMessage(MENU_VIEW_SIDEBAR));
    viewMenu->AddItem(fSidebarMenuItem);
    fSidebarMenuItem->SetShortcut('4', B_COMMAND_KEY);
    fSidebarMenuItem->SetMarked(true);
    fShowborderMenuItem = new BMenuItem("Show Window Frame",
        new BMessage(MENU_VIEW_SHOWBORDER));
    viewMenu->AddItem(fShowborderMenuItem);
    fShowborderMenuItem->SetShortcut('Y', B_COMMAND_KEY);
    fShowborderMenuItem->SetMarked(true);
    fAutohidingMenuItem = new BMenuItem("Autohiding",
        new BMessage(MENU_VIEW_AUTOHIDING));
    viewMenu->AddItem(fAutohidingMenuItem);
    fAutohidingMenuItem->SetShortcut('X', B_COMMAND_KEY);
//.........这里部分代码省略.........
开发者ID:HaikuArchives,项目名称:Puri,代码行数:101,代码来源:BoardWindow.cpp


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