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


C++ BMenuField类代码示例

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


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

示例1: address

/***********************************************************
 * SetFrom
 ***********************************************************/
void
HAddressView::SetFrom(const char* in_address)
{
	if( ::strlen(in_address) == 0)
		return;
	BString address(in_address);
	
	// Compare existing accounts	
	char name[B_FILE_NAME_LENGTH];
	BPath path;
	::find_directory(B_USER_SETTINGS_DIRECTORY,&path);
	path.Append(APP_NAME);
	path.Append("Accounts");
	BDirectory dir(path.Path());
	status_t err = B_OK;
	BEntry entry;
	bool changed = false;
	
	while(err == B_OK)
	{
		if( (err = dir.GetNextEntry(&entry)) != B_OK  )
			break;
		BFile file(&entry,B_READ_ONLY);
		if(file.InitCheck() == B_OK && entry.IsFile())
		{
			BMessage msg;
			msg.Unflatten(&file);
			BString myAddress;
			PRINT(("%s\n",in_address));
			if(msg.FindString("address",&myAddress) != B_OK)
				myAddress = "";
			// Change account
			if(address.FindFirst(myAddress) != B_ERROR)
			{
				entry.GetName(name);	
				ChangeAccount(name);
				// Set From menu
				BMenuField *field = cast_as(FindView("FromMenu"),BMenuField);
				BMenu *menu = field->Menu();
				BMenuItem *item = menu->FindItem(name);
				if(item)
					item->SetMarked(true);
				changed=true;
				break;
			}
		}
	}
	
	if(!changed && cast_as(Window()->FindView("HMailView"),BTextView))
	{
		BMenuField *field = cast_as(FindView("FromMenu"),BMenuField);
		BMenuItem *item(NULL);
		item = field->Menu()->FindMarked();
		if(item)
		{
			ChangeAccount(item->Label());
			item->SetMarked(true);	
		}
	}
}
开发者ID:HaikuArchives,项目名称:Scooby,代码行数:63,代码来源:HAddressView.cpp

示例2: BStringView

quadruplet<BTextControl*, BPopUpMenu*, BMenuField*, BStringView*> CheckView::MakeField(uint16 width,
	string name, uint16* xpos, uint16* ypos)
{
	BStringView* sv = new BStringView(BRect((*xpos), (*ypos), 
		(*xpos) + width, (*ypos) + 10),
		(name + "Text").c_str(), name.c_str());
	BFont font;
	sv->GetFont(&font);
	font.SetSize(10);
	sv->SetFont(&font);
	AddChild(sv);
	BTextControl* tc = new BTextControl(BRect((*xpos) - 5, (*ypos) + 10, 
		(*xpos) + width, (*ypos) + 10), (name + "Field").c_str(), 
		"", "", 0);
	(*xpos) += width;
	tc->SetDivider(0);
	AddChild(tc);
	BPopUpMenu* pu = new BPopUpMenu("", true, false);
	BMenuField* mf = new BMenuField(BRect((*xpos) + 2, (*ypos) + 9, 
		(*xpos) + 2, (*ypos) + 9), (name + "Menu").c_str(), "", pu);
	mf->SetDivider(0);
	AddChild(mf);
	(*xpos) += 30;
	
	return quadruplet<BTextControl*, BPopUpMenu*, BMenuField*, BStringView*>(tc, pu, mf, sv);
}
开发者ID:puckipedia,项目名称:Finance,代码行数:26,代码来源:CheckView_M-R.cpp

示例3:

void
HWindow::Pulse()
{
	HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
	BMenuField* menufield = dynamic_cast<BMenuField*>(FindView("filemenu"));
	BButton* button = dynamic_cast<BButton*>(FindView("play"));
	BButton* stop = dynamic_cast<BButton*>(FindView("stop"));

	if (menufield == NULL || button == NULL || stop == NULL)
		return;

	if (row != NULL) {
		menufield->SetEnabled(true);

		const char* path = row->Path();
		if (path != NULL && strcmp(path, ""))
			button->SetEnabled(true);
		else
			button->SetEnabled(false);
	} else {
		menufield->SetEnabled(false);
		button->SetEnabled(false);
	}

	if (fPlayer != NULL) {
		if (fPlayer->IsPlaying())
			stop->SetEnabled(true);
		else
			stop->SetEnabled(false);
	} else
		stop->SetEnabled(false);
}
开发者ID:royalharsh,项目名称:haiku,代码行数:32,代码来源:HWindow.cpp

示例4: Visit

	virtual void 	Visit(BStringContactField* field)
	{
		int count = fOwner->fControls.CountItems();
		BGridLayout* layout = fOwner->GridLayout();
		if (field->FieldType() != B_CONTACT_SIMPLE_GROUP) {
			ContactFieldTextControl* control = new ContactFieldTextControl(field);

			layout->AddItem(control->CreateLabelLayoutItem(), 1, count);
			layout->AddItem(control->CreateTextViewLayoutItem(), 2, count);
			fOwner->fControls.AddItem(control);
		} else {
			const char* label = 
				BContactField::ExtendedLabel(field);

			fOwner->fGroups = new BPopUpMenu(label);
			fOwner->fGroups->SetRadioMode(false);
			fOwner->BuildGroupMenu(field);

			BMenuField* field = new BMenuField("", "", fOwner->fGroups);
			BTextControl* control = new BTextControl("simpleGroup",
				NULL, NULL, NULL);

			field->SetEnabled(true);
			layout->AddItem(field->CreateLabelLayoutItem(), 1, 0, count);
			layout->AddItem(field->CreateMenuBarLayoutItem(), 1, 1, count);
			layout->AddItem(control->CreateLabelLayoutItem(), 2, 0, count);
			layout->AddItem(control->CreateTextViewLayoutItem(), 2, 1, count);
		}
	}
开发者ID:Barrett17,项目名称:haiku-contacts-kit-old,代码行数:29,代码来源:PersonView.cpp

示例5: FindView

void HDialog::SetValue(const char *id, int value)
{
	BView *v = FindView(id);
	if (v == NULL) THROW(("View '%s' not found", id));

	if (typeid(*v) == typeid(BMenuField))
	{
		BMenuField *mf = static_cast<BMenuField*>(v);
		BMenuItem *item = mf->Menu()->ItemAt(value - 1);
		if (item)
			item->SetMarked(true);
		return;
	}
	else if (typeid(*v) == typeid(BTextControl))
	{
		char b[32];
		sprintf(b, "%d", value);
		SetText(id, b);
		return;
	}
	else if (typeid(*v) == typeid(BSlider))
	{
		static_cast<BSlider*>(v)->SetValue(value);
		return;
	}

	THROW(("view '%s' not found", id));
} // HDialog::SetValue
开发者ID:HaikuArchives,项目名称:Pe,代码行数:28,代码来源:HDialog.cpp

示例6: ResizeBy

void SplitWindow::AddCat()
{
	ResizeBy(0, 25);
	uint16 xpos = 20;
	uint16 width = 150;
	BTextControl* tc = new BTextControl(BRect(xpos - 5, ypos + 10, 
		xpos + width, ypos + 10), "CatField", "", "", 0);
	xpos += width;
	tc->SetDivider(0);
	catTexts.push_back(tc);
	v->AddChild(tc);
	BPopUpMenu* pu = new BPopUpMenu("", true, false);
	BMenuField* mf = new BMenuField(BRect(xpos + 2, ypos + 9, 
		xpos + 2, ypos + 9), "CatMenu", "", pu);
	mf->SetDivider(0);
	v->AddChild(mf);
	xpos += 30;
	tc = new BTextControl(BRect(xpos - 5, ypos + 10, 
		xpos + 75, ypos + 10), "AmountField", "", "", 0);
	tc->SetDivider(0);
	tc->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT);
	tc->SetModificationMessage(new BMessage(AmountModifiedMSG));
	amtTexts.push_back(tc);
	v->AddChild(tc);
	ypos += 25;

	for (cas::iterator ci = catS->begin(); ci != catS->end(); ci++)
	{
		if ((*ci)->IsRoot())
		{
			pu->AddItem(MakeCatMenu(*ci));
		}
	}
	catnum++;
}
开发者ID:HaikuArchives,项目名称:Finance,代码行数:35,代码来源:SplitWindow.cpp

示例7: lock

void CPasteFunctionDialog::PostInit()
{
	fCellView = fOwner->GetCellView();
	
	BAutolock lock(this);
	if (!lock.IsLocked())
		THROW((errLockWindow));

	fList = (BListView *)FindView("list");
	fList->SetInvocationMessage(new BMessage(msg_OK));
	fList->SetSelectionMessage(new BMessage(msg_FuncChanged));
//	fList->SetFont(be_plain_font);

	fFuncDescription = (BTextView *)FindView("desc");

	BMenuField *mf = dynamic_cast<BMenuField *>(FindView("group"));
	fMenu = mf->Menu();
	fMenu->AddItem(new BMenuItem("All", new BMessage(msg_MenuChanged)));
	fMenu->AddSeparatorItem();
	fMenu->AddItem(new BMenuItem("Cell", new BMessage(msg_MenuChanged)));
	fMenu->AddItem(new BMenuItem("Date-Time", new BMessage(msg_MenuChanged)));
	fMenu->AddItem(new BMenuItem("Financial", new BMessage(msg_MenuChanged)));
	fMenu->AddItem(new BMenuItem("Math", new BMessage(msg_MenuChanged)));
	fMenu->AddItem(new BMenuItem("Statistical", new BMessage(msg_MenuChanged)));
	fMenu->AddItem(new BMenuItem("Text", new BMessage(msg_MenuChanged)));
	fMenu->AddItem(new BMenuItem("Logical", new BMessage(msg_MenuChanged)));
	fMenu->AddItem(new BMenuItem("Engineering", new BMessage(msg_MenuChanged)));
	fMenu->AddItem(new BMenuItem("Plugins", new BMessage(msg_MenuChanged)));

	fMenu->FindItem("All")->SetMarked(true);

	FillList();
	
	Show();
} /* CPasteFunctionDialog::CPasteFunctionDialog */
开发者ID:ModeenF,项目名称:OpenSumIt,代码行数:35,代码来源:PasteFunctionDialog.cpp

示例8: NoRenamer

void PecoApp::NoRenamer() {
	if (fRenameMode == MODE_NONE) return;

	fWindow->Lock();
	BMenuField	*myField = (BMenuField *)fWindow->FindView("selectMode");
	BMenu		*myMenu = myField->Menu();
	
	myMenu->FindMarked()->SetMarked(false);

	myField->MenuItem()->SetLabel(STR_PLEASE_SELECT);
	
	BView	*bottomView = fWindow->FindView("bottomView");
	bottomView->RemoveChild((BView *)((PecoApp *)be_app)->fRenamers[fRenameMode]);

	fRenameMode = MODE_NONE;

	float deltaHeight = - be_plain_font->Size()*2 - 40;

	float min_h, max_h, min_v, max_v;
	fWindow->GetSizeLimits( &min_h, &max_h, &min_v, &max_v );
	fWindow->SetSizeLimits( min_h, max_h, min_v + deltaHeight, max_v );

	fWindow->FindView("topView")->SetResizingMode(0);
	fWindow->FindView("bottomView")->SetResizingMode(B_FOLLOW_TOP_BOTTOM);	
	fWindow->ResizeBy(0, deltaHeight);
	fWindow->FindView("topView")->SetResizingMode(B_FOLLOW_TOP_BOTTOM);
	fWindow->FindView("bottomView")->SetResizingMode(B_FOLLOW_BOTTOM);	

	fWindow->Unlock();

}
开发者ID:diversys,项目名称:PecoRename,代码行数:31,代码来源:PecoApp.cpp

示例9: ChangeRenamer

void PecoApp::ChangeRenamer() {
	BMenuField	*myField = (BMenuField *)fWindow->FindView("selectMode");
	BMenu		*myMenu = myField->Menu();
	if (fRenameMode != myMenu->IndexOf(myField->Menu()->FindMarked())) {
		BView	*bottomView = fWindow->FindView("bottomView");
		fWindow->Lock();
		if (fRenameMode != -1) 
			bottomView->RemoveChild((BView *)((PecoApp *)be_app)->fRenamers[fRenameMode]);
		else {
			float deltaHeight = be_plain_font->Size()*2 + 40;
			fWindow->FindView("topView")->SetResizingMode(0);
			fWindow->FindView("bottomView")->SetResizingMode(B_FOLLOW_TOP_BOTTOM);	
			fWindow->ResizeBy(0, deltaHeight);
			fWindow->FindView("topView")->SetResizingMode(B_FOLLOW_TOP_BOTTOM);
			fWindow->FindView("bottomView")->SetResizingMode(B_FOLLOW_BOTTOM);	
			float min_h, max_h, min_v, max_v;
			fWindow->GetSizeLimits( &min_h, &max_h, &min_v, &max_v );
			fWindow->SetSizeLimits( min_h, max_h, min_v + deltaHeight, max_v );
		}
		fRenameMode = myMenu->IndexOf(myField->Menu()->FindMarked());
		bottomView->AddChild(((PecoApp *)be_app)->fRenamers[fRenameMode]);
		if (((PecoApp *)be_app)->fRenamers[fRenameMode]->ChildAt(0) != NULL) 
			((PecoApp *)be_app)->fRenamers[fRenameMode]->ChildAt(0)->MakeFocus();
		else
			fWindow->FindView("DoIt")->MakeFocus();
		fWindow->Unlock();
		MakeList();
	}
}
开发者ID:diversys,项目名称:PecoRename,代码行数:29,代码来源:PecoApp.cpp

示例10: SetTextControl

void
BMailProtocolConfigView::SetTo(MailAddonSettings& settings)
{
 	const BMessage* archive = &settings.Settings();

	BString host = archive->FindString("server");
	if (archive->HasInt32("port"))
		host << ':' << archive->FindInt32("port");

	SetTextControl(this,"host", host.String());
	SetTextControl(this,"user", archive->FindString("username"));

	char *password = get_passwd(archive, "cpasswd");
	if (password) {
		SetTextControl(this,"pass", password);
		delete[] password;
	} else
		SetTextControl(this,"pass", archive->FindString("password"));

	if (archive->HasInt32("flavor")) {
		BMenuField *menu = (BMenuField *)(FindView("flavor"));
		if (menu != NULL) {
			if (BMenuItem *item = menu->Menu()->ItemAt(archive->FindInt32("flavor")))
				item->SetMarked(true);
		}
	}

	if (archive->HasInt32("auth_method")) {
		BMenuField *menu = (BMenuField *)(FindView("auth_method"));
		if (menu != NULL) {
			if (BMenuItem *item = menu->Menu()->ItemAt(archive->FindInt32("auth_method"))) {
				item->SetMarked(true);
				if (item->Command() != 'none') {
					enable_control("user");
					enable_control("pass");
				}
			}
		}
	}


	BCheckBox *box = (BCheckBox *)(FindView("leave_mail_on_server"));
	if (box != NULL)
		box->SetValue(archive->FindBool("leave_mail_on_server") ? B_CONTROL_ON : B_CONTROL_OFF);

	box = (BCheckBox *)(FindView("delete_remote_when_local"));
	if (box != NULL) {
		box->SetValue(archive->FindBool("delete_remote_when_local") ? B_CONTROL_ON : B_CONTROL_OFF);

		if (archive->FindBool("leave_mail_on_server"))
			box->SetEnabled(true);
		else
			box->SetEnabled(false);
	}

	if (fBodyDownloadConfig)
		fBodyDownloadConfig->SetTo(settings);
}
开发者ID:mylegacy,项目名称:haiku,代码行数:58,代码来源:ProtocolConfigView.cpp

示例11: BMailProtocolConfigView

SMTPConfigView::SMTPConfigView(MailAddonSettings& settings,
	BMailAccountSettings& accountSettings)
	:
	BMailProtocolConfigView(B_MAIL_PROTOCOL_HAS_AUTH_METHODS
		| B_MAIL_PROTOCOL_HAS_USERNAME | B_MAIL_PROTOCOL_HAS_PASSWORD
		| B_MAIL_PROTOCOL_HAS_HOSTNAME
#ifdef USE_SSL
		| B_MAIL_PROTOCOL_HAS_FLAVORS
#endif
		)
{
#if defined(USE_SSL) || defined(B_COLLECTING_CATKEYS)
	static const char* kUnencryptedStr = B_TRANSLATE_MARK("Unencrypted");
	static const char* kSSLStr = B_TRANSLATE_MARK("SSL");
	static const char* kSTARTTLSStr = B_TRANSLATE_MARK("STARTTLS");
#endif

#ifdef USE_SSL
	AddFlavor(B_TRANSLATE_NOCOLLECT(kUnencryptedStr));
	AddFlavor(B_TRANSLATE(kSSLStr));
	AddFlavor(B_TRANSLATE(kSTARTTLSStr));
#endif

	AddAuthMethod(B_TRANSLATE("None"), false);
	AddAuthMethod(B_TRANSLATE("ESMTP"));
	AddAuthMethod(B_TRANSLATE("POP3 before SMTP"), false);

	BTextControl *control = (BTextControl *)(FindView("host"));
	control->SetLabel(B_TRANSLATE("SMTP server:"));

	// Reset the dividers after changing one
	float widestLabel = 0;
	for (int32 i = CountChildren(); i-- > 0;) {
		if (BTextControl *text = dynamic_cast<BTextControl *>(ChildAt(i)))
			widestLabel = MAX(widestLabel,text->StringWidth(text->Label()) + 5);
	}
	for (int32 i = CountChildren(); i-- > 0;) {
		if (BTextControl *text = dynamic_cast<BTextControl *>(ChildAt(i)))
			text->SetDivider(widestLabel);
	}

	BMenuField *field = (BMenuField *)(FindView("auth_method"));
	field->SetDivider(widestLabel);

	SetTo(settings);

	fFileView = new BMailFileConfigView(B_TRANSLATE("Destination:"), "path",
		false, BPrivate::default_mail_out_directory().Path());
	fFileView->SetTo(&settings.Settings(), NULL);
	AddChild(fFileView);
	float w, h;
	BMailProtocolConfigView::GetPreferredSize(&w, &h);
	fFileView->MoveBy(0, h - 10);
	GetPreferredSize(&w, &h);
	ResizeTo(w, h);
}
开发者ID:veer77,项目名称:Haiku-services-branch,代码行数:56,代码来源:ConfigView.cpp

示例12: BMenuItem

void
BMailProtocolConfigView::AddFlavor(const char *label)
{
	BMenuField *menu = (BMenuField *)(FindView("flavor"));
	if (menu != NULL) {
		menu->Menu()->AddItem(new BMenuItem(label,NULL));
		if (menu->Menu()->FindMarked() == NULL)
			menu->Menu()->ItemAt(0)->SetMarked(true);
	}
}
开发者ID:mylegacy,项目名称:haiku,代码行数:10,代码来源:ProtocolConfigView.cpp

示例13: cast_as

/***********************************************************
 * AccountName
 ***********************************************************/
const char*
HAddressView::AccountName()
{
	BMenuField *field = cast_as(FindView("FromMenu"),BMenuField);
	BMenu *menu = field->Menu();
	BMenuItem *item = menu->FindMarked();
	if(!item)
		return NULL;
	return item->Label();
}
开发者ID:HaikuArchives,项目名称:Scooby,代码行数:13,代码来源:HAddressView.cpp

示例14: HEventList

void
HWindow::_InitGUI()
{
	fEventList = new HEventList();
	fEventList->SetType(BMediaFiles::B_SOUNDS);
	fEventList->SetSelectionMode(B_SINGLE_SELECTION_LIST);

	BMenu* menu = new BMenu("file");
	menu->SetRadioMode(true);
	menu->SetLabelFromMarked(true);
	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem(B_TRANSLATE("<none>"),
		new BMessage(M_NONE_MESSAGE)));
	menu->AddItem(new BMenuItem(B_TRANSLATE("Other" B_UTF8_ELLIPSIS),
		new BMessage(M_OTHER_MESSAGE)));

	BString label(B_TRANSLATE("Sound file:"));
	BMenuField* menuField = new BMenuField("filemenu", label, menu);
	menuField->SetDivider(menuField->StringWidth(label) + 10);

	BSize buttonsSize(be_plain_font->Size() * 2.5, be_plain_font->Size() * 2.5);

	BButton* stopbutton = new BButton("stop", "\xE2\x96\xA0",
		new BMessage(M_STOP_MESSAGE));
	stopbutton->SetEnabled(false);
	stopbutton->SetExplicitSize(buttonsSize);

	// We need at least one view to trigger B_PULSE_NEEDED events which we will
	// intercept in DispatchMessage to trigger the buttons enabling or disabling.
	stopbutton->SetFlags(stopbutton->Flags() | B_PULSE_NEEDED);

	BButton* playbutton = new BButton("play", "\xE2\x96\xB6",
		new BMessage(M_PLAY_MESSAGE));
	playbutton->SetEnabled(false);
	playbutton->SetExplicitSize(buttonsSize);

	BLayoutBuilder::Group<>(this, B_VERTICAL)
		.SetInsets(B_USE_WINDOW_SPACING)
		.Add(fEventList)
		.AddGroup(B_HORIZONTAL)
			.Add(menuField)
			.AddGroup(B_HORIZONTAL, 0)
				.Add(playbutton)
				.Add(stopbutton)
			.End()
		.End();

	// setup file menu
	_SetupMenuField();
	BMenuItem* noneItem = menu->FindItem(B_TRANSLATE("<none>"));
	if (noneItem != NULL)
		noneItem->SetMarked(true);

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

示例15: UpdatePopUpPriorityMenu

void TeamListView::UpdatePopUpPriorityMenu()
{
	BMenuField *Priority = (BMenuField *)slayer->mainWindow->FindView("MainPriorityField");
	BMenu *menu = Priority->Menu();
	BMenuItem *item;
	int32 i;
	for (i = 2; (item = menu->ItemAt(i)); i++) {
		priorityMenu->ItemAt(i-2)->SetMarked(item->IsMarked());
		priorityMenu->ItemAt(i-2)->SetEnabled(item->IsEnabled());
	}
}
开发者ID:diversys,项目名称:Slayer,代码行数:11,代码来源:TeamListView.cpp


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