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


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

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


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

示例1: saveprefs

int CharismaWindow::saveprefs()
{
	FILE *f;
	BMenu *m;
	char fname[B_PATH_NAME_LENGTH];
	int r;
	BRect rect;
	
	r=find_directory(B_COMMON_SETTINGS_DIRECTORY,0,true,fname,sizeof fname);
	if(r) return r;
	strcat(fname,"/");
	strcat(fname,"Charisma_settings");
	
	f=fopen(fname,"w");
	if(!f)return -1;

	fprintf(f,"Charisma_settings\n");
	fprintf(f,"version=1\n");
	fprintf(f,"directory=%s\n",g_webdir);
	m=modemenu->Menu();
	fprintf(f,"mode=%d\n",m->IndexOf(m->FindMarked()));
	m=smartrefresh->Menu();
	fprintf(f,"smart_refresh=%d\n",m->IndexOf(m->FindMarked()));
	fprintf(f,"external_control=%s\n",extcontrol_item->IsMarked()?"yes":"no");
	fprintf(f,"netpositive_autoset=%s\n",netposautoset_item->IsMarked()?"yes":"no");
	rect=Frame();
	fprintf(f,"position=%f,%f\n",rect.left,rect.top);
	fprintf(f,"minimized=%s\n",isminim?"yes":"no");

	fclose(f);
	
	return 0;
}
开发者ID:HaikuArchives,项目名称:Stamina,代码行数:33,代码来源:main.cpp

示例2: 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

示例3: projmsg

void
TemplateWindow::MessageReceived(BMessage *msg)
{
	switch (msg->what)
	{
		case M_NAME_CHANGED:
		case M_TARGET_CHANGED:
		{
			if (fNameBox->Text() && strlen(fNameBox->Text()) > 0 &&
				fTargetBox->Text() && strlen(fTargetBox->Text()) > 0)
				fOK->SetEnabled(true);
			else
				fOK->SetEnabled(false);
			break;
		}
		case M_CREATE_PROJECT:
		{
			BMenu *menu = fTemplateField->Menu();
			BMenuItem *item = menu->FindMarked();
			if (!item)
				break;
			
			int32 selection = menu->IndexOf(item);
			ProjectTemplate *ptemp = fTempList.TemplateAt(selection);
			
			BMessage projmsg(M_CREATE_PROJECT),reply;
			projmsg.AddString("name",fNameBox->Text());
			projmsg.AddString("target",fTargetBox->Text());
			projmsg.AddInt32("type",ptemp->TargetType());
			projmsg.AddString("path",fPathBox->Path());
			projmsg.AddString("template", ptemp->GetRef().name);
			projmsg.AddString("pldfile", ptemp->ProjectFileName());
			
			BMenu *scmMenu = fSCMChooser->Menu();
			int32 scm = scmMenu->IndexOf(scmMenu->FindMarked());
			projmsg.AddInt32("scmtype",scm);
			
			if (!ptemp->ProjectFileName())
			{
				for (int32 i = 0; i < ptemp->CountFiles(); i++)
					projmsg.AddRef("refs",ptemp->FileAt(i));
				
				for (int32 i = 0; i < ptemp->CountLibs(); i++)
					projmsg.AddRef("libs",ptemp->LibAt(i));
			}
			
			projmsg.AddBool("createfolder",(fCreateFolder->Value() == B_CONTROL_ON));
			be_app_messenger.SendMessage(&projmsg,&reply);
			PostMessage(B_QUIT_REQUESTED);
			break;
		}
		default:
		{
			DWindow::MessageReceived(msg);
			break;
		}
	}
}
开发者ID:passick,项目名称:Paladin,代码行数:58,代码来源:TemplateWindow.cpp

示例4: BMessage

void
PPPoEView::MessageReceived(BMessage *message)
{
	switch(message->what) {
		case kMsgSelectInterface: {
			BMenuItem *item = fInterface->Menu()->FindMarked();
			if(item)
				fInterfaceName = item->Label();
		} break;
		
		case kMsgSelectOther:
			(new TextRequestDialog("InterfaceName", NULL, kRequestInterfaceName,
				fInterfaceName.String()))->Go(new BInvoker(
				new BMessage(kMsgFinishSelectOther), this));
		break;
		
		case kMsgFinishSelectOther: {
			int32 which;
			message->FindInt32("which", &which);
			
			const char *name = message->FindString("text");
			BMenu *menu = fInterface->Menu();
			BMenuItem *item;
			if(which != 1 || !name || strlen(name) == 0) {
				item = menu->FindItem(fInterfaceName.String());
				if(item && menu->IndexOf(item) <= menu->CountItems() - 2)
					item->SetMarked(true);
				else
					fOtherInterface->SetMarked(true);
				
				return;
			}
			
			fInterfaceName = name;
			
			item = menu->FindItem(fInterfaceName.String());
			if(item && menu->IndexOf(item) <= menu->CountItems() - 2) {
				item->SetMarked(true);
				return;
			}
			
			BString label(kLabelOtherInterface);
			label << " " << name;
			fOtherInterface->SetLabel(label.String());
			fOtherInterface->SetMarked(true);
				// XXX: this is needed to tell the owning menu to update its label
		} break;
		
		default:
			BView::MessageReceived(message);
	}
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:52,代码来源:PPPoEAddon.cpp

示例5: bool

void
Renamer_Remove::DetachedFromWindow()
{
	BMessage msg;
	msg.AddInt32("pos1", fPosition1->Value());
	msg.AddInt32("pos2", fPosition2->Value());

	BMenu* menu = fDirection1->Menu();
	msg.AddBool("direction1", bool(menu->IndexOf(menu->FindMarked())));
	menu = fDirection2->Menu();
	msg.AddBool("direction2", bool(menu->IndexOf(menu->FindMarked())));

	UpdatePreferences("ren_remove", msg);
}
开发者ID:HaikuArchives,项目名称:PecoRename,代码行数:14,代码来源:Renamer_Remove.cpp

示例6: BMessage

// -------------------------------------------------------------------
void
DRRegrView::MessageReceived(BMessage* theMesg)
{
	BMessage* dispMesg;
	int16 itemChecked;
	BMenu* theMenu;
	
	switch (theMesg->what) {
	
		case apply_change :
			dispMesg = new BMessage(set_display);
			dispMesg->AddInt64(disp_set_name,mKey);
			dispMesg->AddInt16(disp_mark_name,mPlotMark->PlotMark());
			dispMesg->AddInt32(mark_col_name,mColorCtrl->Value());
			theMenu = mLineSelect->Menu();
			itemChecked = theMenu->IndexOf(theMenu->FindMarked());
			dispMesg->AddInt16(disp_line_name,itemChecked);
			be_app->PostMessage(dispMesg);
			delete dispMesg;
			break;
			
		default :
			BView::MessageReceived(theMesg);
	}
}		
开发者ID:HaikuArchives,项目名称:DataPlus,代码行数:26,代码来源:DRRegrView.cpp

示例7:

/***********************************************************
 * Operator2
 ***********************************************************/
int32
HCriteriaView::Operator2() const
{
	BMenu *menu = fOp2Menu->Menu();
	BMenuItem *item = menu->FindMarked();
	if(item)
		return menu->IndexOf(item);
	return 0;	
}
开发者ID:HaikuArchives,项目名称:Scooby,代码行数:12,代码来源:HCriteriaView.cpp

示例8: if

void
PPPoEView::ReloadInterfaces()
{
	// delete all items and request a new bunch from the pppoe kernel module
	BMenu *menu = fInterface->Menu();
	while(menu->CountItems() > 2)
		delete menu->RemoveItem((int32) 0);
	fOtherInterface->SetLabel(kLabelOtherInterface);
	
	PPPManager manager;
	char *interfaces = new char[8192];
		// reserve enough space for approximately 512 entries
	int32 count = manager.ControlModule("pppoe", PPPoE_GET_INTERFACES, interfaces,
		8192);
	
	BMenuItem *item;
	char *name = interfaces;
	int32 insertAt;
	for(int32 index = 0; index < count; index++) {
		item = new BMenuItem(name, new BMessage(kMsgSelectInterface));
		insertAt = FindNextMenuInsertionIndex(menu, name);
		if(insertAt > menu->CountItems() - 2)
			insertAt = menu->CountItems() - 2;
		
		item->SetTarget(this);
		menu->AddItem(item, insertAt);
		name += strlen(name) + 1;
	}
	
	// set interface or some default value if nothing was found
	if(Addon()->InterfaceName() && strlen(Addon()->InterfaceName()) > 0)
		fInterfaceName = Addon()->InterfaceName();
	else if(count > 0)
		fInterfaceName = interfaces;
	else
		fInterfaceName = "";
	
	delete interfaces;
	
	item = menu->FindItem(fInterfaceName.String());
	if(item && menu->IndexOf(item) <= menu->CountItems() - 2)
		item->SetMarked(true);
	else if(Addon()->InterfaceName()) {
		BString label(kLabelOtherInterface);
		label << " " << fInterfaceName;
		fOtherInterface->SetLabel(label.String());
		fOtherInterface->SetMarked(true);
	}
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:49,代码来源:PPPoEAddon.cpp

示例9:

/*! \brief Gets the currently selected option.
	\param outName A pointer to a string which will held the option's name.
	\param outValue A pointer to an integer which will held the option's value.
	\return The index of the selected option.
*/
int32
BOptionPopUp::SelectedOption(const char **outName, int32 *outValue) const
{
	BMenu *menu = fMenuField->Menu();
	if (menu != NULL) {
		BMenuItem *marked = menu->FindMarked();
		if (marked != NULL) {
			if (outName != NULL)
				*outName = marked->Label();
			if (outValue != NULL)
				marked->Message()->FindInt32("be:value", outValue);
			
			return menu->IndexOf(marked);
		}
	}
	
	return B_ERROR;
}
开发者ID:mmanley,项目名称:Antares,代码行数:23,代码来源:OptionPopUp.cpp

示例10: GetValue

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

		// according to stroustrup I shouldn't do this:

	if (typeid(*v) == typeid(BMenuField))
	{
		BMenu *menu = static_cast<BMenuField*>(v)->Menu();
		return std::max(menu->IndexOf(menu->FindMarked()) + 1, (int32)1);
	}
	else if (typeid(*v) == typeid(BTextControl))
		return atoi(GetText(id));
	else if (typeid(*v) == typeid(BSlider))
		return static_cast<BSlider*>(v)->Value();

	THROW(("view '%s' not of valid type", id));
	return 0;
} // HDialog::GetValue
开发者ID:HaikuArchives,项目名称:Pe,代码行数:20,代码来源:HDialog.cpp

示例11: SetTrackRef

void AmProgramChangeView::SetTrackRef(AmTrackRef trackRef)
{
	mTrackRef = trackRef;
	BMenu*	menu = Menu();
	if (!menu) return;
	int32			oldIndex = -1;
	BMenuItem*		item = menu->FindMarked();
	if (item) oldIndex = menu->IndexOf(item);
	menu->RemoveItems(0, menu->CountItems(), true);
	if (!mTrackRef.IsValid() ) return;

	// READ TRACK BLOCK
	#ifdef AM_TRACE_LOCKS
	printf("AmProgramChangeView::SetTrackRef() read lock\n");
	#endif
	const AmSong*	song = ReadLock();
	const AmTrack*	track = song ? song->Track( mTrackRef ) : 0;
	if (track) BuildMenu(track, menu, oldIndex);
	ReadUnlock(song);
	// END READ TRACK BLOCK
}
开发者ID:HaikuArchives,项目名称:Sequitur,代码行数:21,代码来源:AmEventControls.cpp

示例12:

/***********************************************************
 * Destructor
 ***********************************************************/
HAddressView::~HAddressView()
{
	// Save send account
	int32 smtp_account;
	BMenuField *field = cast_as(FindView("FromMenu"),BMenuField);
	BMenu *menu = field->Menu();
	smtp_account = menu->IndexOf(menu->FindMarked());
	((HApp*)be_app)->Prefs()->SetData("smtp_account",smtp_account);
	
	// free memories
	int32 count = fAddrList.CountItems();
	while(count>0)
	{
		char *p = (char*)fAddrList.RemoveItem(--count);
		if(p)
			free(p);
	}
	fTo->SetModificationMessage(NULL);
	fCc->SetModificationMessage(NULL);
	fBcc->SetModificationMessage(NULL);
	fSubject->SetModificationMessage(NULL);
}
开发者ID:HaikuArchives,项目名称:Scooby,代码行数:25,代码来源:HAddressView.cpp

示例13: windRect

void
TFilePanel::Init(const BMessage*)
{
	BRect windRect(Bounds());
	AddChild(fBackView = new BackgroundView(windRect));

	// add poseview menu bar
	fMenuBar = new BMenuBar(BRect(0, 0, windRect.Width(), 1), "MenuBar");
	fMenuBar->SetBorder(B_BORDER_FRAME);
	fBackView->AddChild(fMenuBar);

	AddMenus();
	AddContextMenus();

	FavoritesMenu* favorites = new FavoritesMenu(B_TRANSLATE("Favorites"),
		new BMessage(kSwitchDirectory), new BMessage(B_REFS_RECEIVED),
		BMessenger(this), IsSavePanel(), fPoseView->RefFilter());
	favorites->AddItem(new BMenuItem(B_TRANSLATE("Add current folder"),
		new BMessage(kAddCurrentDir)));
	favorites->AddItem(new BMenuItem(
		B_TRANSLATE("Edit favorites" B_UTF8_ELLIPSIS),
		new BMessage(kEditFavorites)));

	fMenuBar->AddItem(favorites);

	// configure menus
	BMenuItem* item = fMenuBar->FindItem(B_TRANSLATE("Window"));
	if (item) {
		fMenuBar->RemoveItem(item);
		delete item;
	}

	item = fMenuBar->FindItem(B_TRANSLATE("File"));
	if (item) {
		BMenu* menu = item->Submenu();
		if (menu) {
			item = menu->FindItem(kOpenSelection);
			if (item && menu->RemoveItem(item))
				delete item;

			item = menu->FindItem(kDuplicateSelection);
			if (item && menu->RemoveItem(item))
				delete item;

			// remove add-ons menu, identifier menu, separator
			item = menu->FindItem(B_TRANSLATE("Add-ons"));
			if (item) {
				int32 index = menu->IndexOf(item);
				delete menu->RemoveItem(index);
				delete menu->RemoveItem(--index);
				delete menu->RemoveItem(--index);
			}

			// remove separator
			item = menu->FindItem(B_CUT);
			if (item) {
				item = menu->ItemAt(menu->IndexOf(item)-1);
				if (item && menu->RemoveItem(item))
					delete item;
			}
		}
	}

	// add directory menu and menufield
	fDirMenu = new BDirMenu(0, this, kSwitchDirectory, "refs");

	font_height ht;
	be_plain_font->GetHeight(&ht);
	float f_height = ht.ascent + ht.descent + ht.leading;

	BRect rect;
	rect.top = fMenuBar->Bounds().Height() + 8;
	rect.left = windRect.left + 8;
	rect.right = rect.left + 300;
	rect.bottom = rect.top + (f_height > 22 ? f_height : 22);

	fDirMenuField = new BMenuField(rect, "DirMenuField", "", fDirMenu);
	fDirMenuField->MenuBar()->SetFont(be_plain_font);
	fDirMenuField->SetDivider(0);
	fDirMenuField->MenuBar()->SetMaxContentWidth(rect.Width() - 26.0f);
		// Make room for the icon

	fDirMenuField->MenuBar()->RemoveItem((int32)0);
	fDirMenu->SetMenuBar(fDirMenuField->MenuBar());
		// the above is a weird call from BDirMenu
		// ToDo: clean up

	BEntry entry(TargetModel()->EntryRef());
	if (entry.InitCheck() == B_OK)
		fDirMenu->Populate(&entry, 0, true, true, false, true);
	else
		fDirMenu->Populate(0, 0, true, true, false, true);

	fBackView->AddChild(fDirMenuField);

	// add file name text view
	if (fIsSavePanel) {
		BRect rect(windRect);
		rect.top = rect.bottom - 35;
		rect.left = 8;
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例14: TriangleObject

void
ObjectView::MessageReceived(BMessage* msg)
{
	BMenuItem* item = NULL;
	bool toggleItem = false;

	switch (msg->what) {
		case kMsgFPS:
			fFps = (fFps) ? false : true;
			msg->FindPointer("source", reinterpret_cast<void**>(&item));
			item->SetMarked(fFps);
			fForceRedraw = true;
			setEvent(drawEvent);
			break;
		case kMsgAddModel: 
		{
			TriangleObject *Tri = new TriangleObject(this);
			if (Tri->InitCheck() == B_OK) {
				fObjListLock.Lock();
				fObjects.AddItem(Tri);
				fObjListLock.Unlock();
			} else {
				BAlert *NoResourceAlert	= new BAlert(B_TRANSLATE("Error"),
						kNoResourceError, B_TRANSLATE("OK"), NULL, NULL,
						B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_STOP_ALERT);
				NoResourceAlert->SetFlags(NoResourceAlert->Flags() | B_CLOSE_ON_ESCAPE);
				NoResourceAlert->Go();
				delete Tri;
			}
			setEvent(drawEvent);
			break;
		}
		case kMsgLights:
		{
			msg->FindPointer("source", reinterpret_cast<void**>(&item));
			long lightNum = msg->FindInt32("num");
			long color = msg->FindInt32("color");
			BMenu *menu = item->Menu();
			long index = menu->IndexOf(item);
			menu->ItemAt(index)->SetMarked(true);
			for (int i = 0; i < menu->CountItems(); i++) {
				if (i != index)
					menu->ItemAt(i)->SetMarked(false);
			}

			LockGL();
			if (color != lightNone) {
				glEnable(GL_LIGHT0 + lightNum - 1);
				glLightfv(GL_LIGHT0 + lightNum - 1, GL_SPECULAR,
					lights[color].specular);
				glLightfv(GL_LIGHT0 + lightNum - 1, GL_DIFFUSE,
					lights[color].diffuse);
				glLightfv(GL_LIGHT0 + lightNum - 1, GL_AMBIENT,
					lights[color].ambient);
			} else {
				glDisable(GL_LIGHT0 + lightNum - 1);
			}
			UnlockGL();
			fForceRedraw = true;
			setEvent(drawEvent);
			break;
		}
		case kMsgGouraud:
			fGouraud = !fGouraud;
			toggleItem = true;
			break;
		case kMsgZBuffer:
			fZbuf = !fZbuf;
			toggleItem = true;
			break;
		case kMsgCulling:
			fCulling = !fCulling;
			toggleItem = true;
			break;
		case kMsgLighting:
			fLighting = !fLighting;
			toggleItem = true;
			break;
		case kMsgFilled:
			fFilled = !fFilled;
			toggleItem = true;
			break;
		case kMsgPerspective:
			fPersp = !fPersp;
			toggleItem = true;
			break;
		case kMsgFog:
			fFog = !fFog;
			toggleItem = true;
			break;
	}

	if (toggleItem && msg->FindPointer("source", reinterpret_cast<void**>(&item)) == B_OK){
		item->SetMarked(!item->IsMarked());
		setEvent(drawEvent);
	}

	BGLView::MessageReceived(msg);
}
开发者ID:DonCN,项目名称:haiku,代码行数:99,代码来源:ObjectView.cpp

示例15: fontMsg


//.........这里部分代码省略.........

    case BOUNDING_BOX_MSG:
    {
        BMessage msg(BOUNDING_BOX_MSG);
        msg.AddBool("_boundingbox", static_cast<bool>(fBoundingboxesCheckBox->Value()));
        fMessenger->SendMessage(&msg);
        if (static_cast<bool>(fBoundingboxesCheckBox->Value()))
            printf("Bounding: true\n");
        else
            printf("Bounding: false\n");
        break;
    }

    case OUTLINE_MSG:
    {
        int8 outlineVal = (int8)fOutlineSlider->Value();

        char buff[256];
        sprintf(buff, B_TRANSLATE("Outline: %d"), outlineVal);
        fOutlineSlider->SetLabel(buff);

        fAliasingCheckBox->SetEnabled(outlineVal < 1);
        fBoundingboxesCheckBox->SetEnabled(outlineVal < 1);

        BMessage msg(OUTLINE_MSG);
        msg.AddInt8("_outline", outlineVal);
        fMessenger->SendMessage(&msg);
        break;
    }

    case CYCLING_FONTS_MSG:
    {
        fCyclingFontButton->SetLabel(fCycleFonts ? \
                                     B_TRANSLATE("Cycle fonts") : B_TRANSLATE("Stop cycling"));
        fCycleFonts = !fCycleFonts;

        if (fCycleFonts) {
            delete fMessageRunner;
            fMessageRunner = new BMessageRunner(this,
                                                new BMessage(CYCLING_FONTS_UPDATE_MSG), 360000*2, -1);
            printf("Cycle fonts enabled\n");
        } else {
            // Delete our MessageRunner and reset the style index
            delete fMessageRunner;
            fMessageRunner = NULL;
            fFontStyleindex	= 0;
            printf("Cycle fonts disabled\n");
        }
        break;
    }

    case CYCLING_FONTS_UPDATE_MSG:
    {
        int32 familyindex = -1;
        BMenuItem* currentFamilyItem = fFontFamilyMenu->FindMarked();

        if (currentFamilyItem) {
            familyindex = fFontFamilyMenu->IndexOf(currentFamilyItem);
            const int32 installedStyles = count_font_styles(
                                              const_cast<char*>(currentFamilyItem->Label()));

            BMenu* submenu = currentFamilyItem->Submenu();
            if (submenu) {
                BMenuItem* markedStyle = submenu->FindMarked();
                fFontStyleindex = submenu->IndexOf(markedStyle);
            }

            if (fFontStyleindex < installedStyles - 1)
                fFontStyleindex++;
            else {
                fFontStyleindex = 0;

                if (familyindex < count_font_families() - 1)
                    familyindex++;
                else
                    familyindex = 0;
            }

            BMenuItem* newFontFamilyItem = fFontFamilyMenu->ItemAt(familyindex);
            BMenuItem* newstyleitem = submenu->ItemAt(fFontStyleindex);

            if (newFontFamilyItem && newstyleitem) {
                if (msg->AddString("_style", newstyleitem->Label()) != B_OK
                        || msg->AddString("_family", newFontFamilyItem->Label()) != B_OK) {
                    printf("Failed to add style or family to the message\n");
                    return;
                }
                printf("InstalledStyles(%ld), Font(%s), Style(%s)\n",
                       installedStyles, newFontFamilyItem->Label(),
                       newstyleitem->Label());
                _UpdateAndSendStyle(msg);
            }
        }
        break;
    }

    default:
        BView::MessageReceived(msg);
    }
}
开发者ID:nielx,项目名称:haiku-serviceskit,代码行数:101,代码来源:ControlView.cpp


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