本文整理汇总了C++中BMenuItem::SetLabel方法的典型用法代码示例。如果您正苦于以下问题:C++ BMenuItem::SetLabel方法的具体用法?C++ BMenuItem::SetLabel怎么用?C++ BMenuItem::SetLabel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BMenuItem
的用法示例。
在下文中一共展示了BMenuItem::SetLabel方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
FrequencyMenu::UpdateMenu()
{
freq_preferences* pref = fStorage->GetPreferences();
switch (pref->mode) {
case DYNAMIC:
_SetL1MenuLabelFrom(fDynamicPerformance);
break;
case PERFORMANCE:
_SetL1MenuLabelFrom(fHighPerformance);
break;
case LOW_ENERGIE:
_SetL1MenuLabelFrom(fLowEnergie);
break;
case CUSTOM:
{
BMenuItem* markedItem = fCustomStateMenu->FindMarked();
if (markedItem)
markedItem->SetMarked(false);
BMenuItem* customItem
= fCustomStateMenu->ItemAt(pref->custom_stepping);
if (customItem)
customItem->SetMarked(true);
BMenuItem* superItem = fCustomStateMenu->Supermenu()->Superitem();
if (superItem && customItem)
superItem->SetLabel(customItem->Label());
break;
}
}
}
示例2: ResizeLocalized
void HMenuField::ResizeLocalized(const char* label, const char* itemLabel)
{
SetLabel(label);
BMenuItem* item = MenuItem();
if (item && itemLabel)
item->SetLabel(itemLabel);
SetDivider(label == NULL ? 0 : StringWidth(label)+StringWidth("n"));
ResizeToPreferred();
} /* HMenuField::ResizeLocalized */
示例3: BMessage
TeamListView::TeamListView(BRect frame, const char *name, CLVContainerView **s)
: ColumnListView(frame, s, name, B_FOLLOW_ALL_SIDES, B_WILL_DRAW|B_NAVIGABLE|B_FRAME_EVENTS,
B_MULTIPLE_SELECTION_LIST, true, true, true, false, B_FANCY_BORDER)
{
// add Columns...
AddColumn(new CLVColumn(NULL, 20.0, CLV_EXPANDER|CLV_LOCK_AT_BEGINNING|CLV_NOT_MOVABLE));
AddColumn(new CLVColumn(NULL, 20.0, CLV_LOCK_AT_BEGINNING|CLV_NOT_RESIZABLE|
CLV_NOT_MOVABLE|CLV_MERGE_WITH_RIGHT));
AddColumn(new CLVColumn("Name", 100.0, CLV_LOCK_AT_BEGINNING|CLV_NOT_MOVABLE));
AddColumn(new CLVColumn("Id", 40.0));
AddColumn(new CLVColumn("Priority", 50.0));
AddColumn(new CLVColumn("State", 60.0));
AddColumn(new CLVColumn("Memory", 60.0));
AddColumn(new CLVColumn("CPU", 60.0));
SetInvocationMessage(new BMessage(TEAM_INV));
// create the PopUpMenu
BMenuItem *inv;
operationMenu = new BPopUpMenu("operationMenu", false, false);
operationMenu->AddItem((inv = new BMenuItem("Kill",
new BMessage(IE_MAINWINDOW_MAINKILL))));
inv->SetTarget(slayer->mainWindow);
operationMenu->AddItem((inv = new BMenuItem("Suspend",
new BMessage(IE_MAINWINDOW_MAINSUSPEND))));
inv->SetTarget(slayer->mainWindow);
operationMenu->AddItem((inv = new BMenuItem("Resume",
new BMessage(IE_MAINWINDOW_MAINRESUME))));
inv->SetTarget(slayer->mainWindow);
operationMenu->AddSeparatorItem();
priorityMenu = new BMenu("PriorityMenu");
BMenuItem *pr = new BMenuItem(priorityMenu); //, new BMessage('tmpj'));
pr->SetLabel("Set priority");
operationMenu->AddItem(pr);
ItemsToPopUpPriorityMenu();
// MakeFocus(true);
// = new BMenu("Set priority");
// operationMenu->AddItem(setPriorityMenu);
// operationMenu->AddSeparator
}
示例4: entry
bool
FavoritesMenu::AddNextItem()
{
// run the next chunk of code for a given item adding state
if (fState == kStart) {
fState = kAddingFavorites;
fSectionItemCount = 0;
fAddedSeparatorForSection = false;
// set up adding the GoTo menu items
try {
BPath path;
ThrowOnError(find_directory(B_USER_SETTINGS_DIRECTORY,
&path, true));
path.Append(kGoDirectory);
mkdir(path.Path(), 0777);
BEntry entry(path.Path());
Model startModel(&entry, true);
ThrowOnInitCheckError(&startModel);
if (!startModel.IsContainer())
throw B_ERROR;
if (startModel.IsQuery())
fContainer = new QueryEntryListCollection(&startModel);
else
fContainer = new DirectoryEntryList(*dynamic_cast<BDirectory*>
(startModel.Node()));
ThrowOnInitCheckError(fContainer);
ThrowOnError( fContainer->Rewind() );
} catch (...) {
delete fContainer;
fContainer = NULL;
}
}
if (fState == kAddingFavorites) {
entry_ref ref;
if (fContainer
&& fContainer->GetNextRef(&ref) == B_OK) {
Model model(&ref, true);
if (model.InitCheck() != B_OK)
return true;
if (!ShouldShowModel(&model))
return true;
BMenuItem* item = BNavMenu::NewModelItem(&model,
model.IsDirectory() ? fOpenFolderMessage : fOpenFileMessage,
fTarget);
if (item == NULL)
return true;
item->SetLabel(ref.name);
// this is the name of the link in the Go dir
if (!fAddedSeparatorForSection) {
fAddedSeparatorForSection = true;
AddItem(new TitledSeparatorItem(B_TRANSLATE("Favorites")));
}
fUniqueRefCheck.push_back(*model.EntryRef());
AddItem(item);
fSectionItemCount++;
return true;
}
// done with favorites, set up for adding recent files
fState = kAddingFiles;
fAddedSeparatorForSection = false;
app_info info;
be_app->GetAppInfo(&info);
fItems.MakeEmpty();
int32 apps, docs, folders;
TrackerSettings().RecentCounts(&apps, &docs, &folders);
BRoster().GetRecentDocuments(&fItems, docs, NULL, info.signature);
fIndex = 0;
fSectionItemCount = 0;
}
if (fState == kAddingFiles) {
// if this is a Save panel, not an Open panel
// then don't add the recent documents
if (!fIsSavePanel) {
for (;;) {
entry_ref ref;
if (fItems.FindRef("refs", fIndex++, &ref) != B_OK)
break;
Model model(&ref, true);
if (model.InitCheck() != B_OK)
//.........这里部分代码省略.........
示例5: Save
void TCueSheetWindow::Save(BMessage* message)
{
status_t myErr;
entry_ref theRef;
char* theString = NULL;
// Get directory to save data to
message->FindRef("directory", &theRef);
// Get name of file to be saved as
message->FindString("name", (const char**)&theString);
// Set window title to new filename
SetTitle(theString);
// Create a BDirectory object
BDirectory saveDir(&theRef);
// Now create the file. Create new file if fFile is unitialized.
if (fFile)
delete fFile;
fFile = new BFile();
myErr = saveDir.CreateFile(theString, fFile, false);
if (myErr != B_OK)
return;
// Write out file header
//WriteHeader(fFile);
BMessage archive;
// Archive CueSheetWindow and write to file
BMessage cueSheetArchive;
Archive(&cueSheetArchive, true);
// Flatten and write out to file
ssize_t numBytes;
cueSheetArchive.Flatten(fFile, &numBytes);
// Set file type
BNodeInfo info(fFile);
if ( info.InitCheck() )
return;
myErr = info.SetType("application/x-mediapede-cuesheet");
// Set icons
BBitmap* smallIcon = GetMICNFromResource("application/x-mediapede-cuesheet");
info.SetIcon( smallIcon, B_MINI_ICON);
BBitmap* largeIcon = GetICONFromResource("application/x-mediapede-cuesheet");
info.SetIcon( largeIcon, B_LARGE_ICON);
delete smallIcon;
delete largeIcon;
// Update our entry in the Windows menu to reflect possible new filename
BMenuItem* theItem = fAppMenu->GetWindowsMenu()->FindItem( Title());
if (theItem)
theItem->SetLabel(theString);
// We aren't dirty now
fCueSheetView->SetDirty(false);
}
示例6: AdjustWindowsMenu
void TCueSheetWindow::AdjustWindowsMenu()
{
// Set up string buffers
bool retVal;
char* menuStr = (char*)malloc( sizeof(char) * 256);
// Get application
MuseumApp* theApp = static_cast<MuseumApp*>(be_app);
BMenu* theMenu = fAppMenu->GetWindowsMenu();
if (theMenu) {
// Stage Item
BMenuItem* stageItem = theMenu->FindItem(WINDOWS_STAGE_MSG);
if (stageItem) {
TStageWindow* stage = fStageWindow;
if (stage) {
stage->Lock();
if (stage->IsHidden())
retVal = GetString("WindowsMenuStrings", kWindowsShowStageItem, menuStr);
else
retVal = GetString("WindowsMenuStrings", kWindowsHideStageItem, menuStr);
stage->Unlock();
stageItem->SetLabel(menuStr);
} else {
retVal = GetString("WindowsMenuStrings", kWindowsShowStageItem, menuStr);
stageItem->SetLabel(menuStr);
}
}
// Browser Item
BMenuItem* browserItem = theMenu->FindItem(WINDOWS_BROWSER_MSG);
if (stageItem) {
TBrowserWindow* browser = theApp->GetBrowser();
if (browser) {
browser->Lock();
if (browser->IsHidden())
retVal = GetString("WindowsMenuStrings", kWindowsShowBrowserItem, menuStr);
else
retVal = GetString("WindowsMenuStrings", kWindowsHideBrowserItem, menuStr);
browser->Unlock();
browserItem->SetLabel(menuStr);
} else {
retVal = GetString("WindowsMenuStrings", kWindowsShowBrowserItem, menuStr);
browserItem->SetLabel(menuStr);
}
}
// Transport Item
BMenuItem* transportItem = theMenu->FindItem(WINDOWS_TRANSPORT_MSG);
if (transportItem) {
TTransportPalette* transport = theApp->GetTransport();
if (transport) {
transport->Lock();
if (transport->IsHidden())
retVal = GetString("WindowsMenuStrings", kWindowsShowTransportItem, menuStr);
else
retVal = GetString("WindowsMenuStrings", kWindowsHideTransportItem, menuStr);
transport->Unlock();
transportItem->SetLabel(menuStr);
} else {
retVal = GetString("WindowsMenuStrings", kWindowsShowTransportItem, menuStr);
transportItem->SetLabel(menuStr);
}
}
// Locator Item
BMenuItem* counterItem = theMenu->FindItem(WINDOWS_COUNTER_MSG);
if (counterItem) {
TTimePalette* time = theApp->GetTimePalette();
if (time) {
time->Lock();
if (time->IsHidden())
retVal = GetString("WindowsMenuStrings", kWindowsShowLocatorItem, menuStr);
else
retVal = GetString("WindowsMenuStrings", kWindowsHideLocatorItem, menuStr);
time->Unlock();
counterItem->SetLabel(menuStr);
} else {
retVal = GetString("WindowsMenuStrings", kWindowsShowLocatorItem, menuStr);
counterItem->SetLabel(menuStr);
}
}
// Media Cue Item
BMenuItem* mediaItem = theMenu->FindItem(WINDOWS_MEDIA_MSG);
if (mediaItem) {
TMediaCuePalette* mediaPalette = theApp->GetMediaPalette();
if (mediaPalette) {
mediaPalette->Lock();
if (mediaPalette->IsHidden())
retVal = GetString("WindowsMenuStrings", kWindowsShowMediaItem, menuStr);
else
retVal = GetString("WindowsMenuStrings", kWindowsHideMediaItem, menuStr);
mediaPalette->Unlock();
//.........这里部分代码省略.........
示例7: path
//.........这里部分代码省略.........
BAlert* notify = new BAlert("installation_failed",
B_TRANSLATE("The requested package failed to install on your "
"system. This might be a problem with the target package "
"file. Please consult this issue with the package "
"distributor."),
B_TRANSLATE("OK"),
NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
fprintf(stderr,
B_TRANSLATE("Error while installing the package\n"));
notify->SetFlags(notify->Flags() | B_CLOSE_ON_ESCAPE);
notify->Go();
fStatusWindow->Hide();
fBeginButton->SetEnabled(true);
fInstallTypes->SetEnabled(true);
fDestination->SetEnabled(true);
fInstallProcess.Stop();
break;
}
case P_MSG_STOP:
{
// This message is sent to us by the PackageStatus window, informing
// user interruptions.
// We actually use this message only when a post installation script
// is running and we want to kill it while it's still running
fStatusWindow->Hide();
fBeginButton->SetEnabled(true);
fInstallTypes->SetEnabled(true);
fDestination->SetEnabled(true);
fInstallProcess.Stop();
break;
}
case B_REFS_RECEIVED:
{
if (!_ValidateFilePanelMessage(message))
break;
entry_ref ref;
if (message->FindRef("refs", &ref) == B_OK) {
BPath path(&ref);
if (path.InitCheck() != B_OK)
break;
dev_t device = dev_for_path(path.Path());
BVolume volume(device);
if (volume.InitCheck() != B_OK)
break;
BMenuItem* item = fDestField->MenuItem();
BString name = _NamePlusSizeString(path.Path(),
volume.FreeBytes(), B_TRANSLATE("%name% (%size% free)"));
item->SetLabel(name.String());
fCurrentPath.SetTo(path.Path());
}
break;
}
case B_CANCEL:
{
if (!_ValidateFilePanelMessage(message))
break;
// file panel aborted, select first suitable item
for (int32 i = 0; i < fDestination->CountItems(); i++) {
BMenuItem* item = fDestination->ItemAt(i);
BMessage* message = item->Message();
if (message == NULL)
continue;
BString path;
if (message->FindString("path", &path) == B_OK) {
fCurrentPath.SetTo(path.String());
item->SetMarked(true);
break;
}
}
break;
}
case B_SIMPLE_DATA:
if (message->WasDropped()) {
uint32 type;
int32 count;
status_t ret = message->GetInfo("refs", &type, &count);
// check whether the message means someone dropped a file
// to our view
if (ret == B_OK && type == B_REF_TYPE) {
// if it is, send it along with the refs to the application
message->what = B_REFS_RECEIVED;
be_app->PostMessage(message);
}
}
// fall-through
default:
BView::MessageReceived(message);
break;
}
}
示例8: str
status_t
PMenuItem::SetProperty(const char *name, PValue *value, const int32 &index)
{
if (!name || !value)
return B_ERROR;
BString str(name);
PProperty *prop = FindProperty(name,index);
if (!prop)
return B_NAME_NOT_FOUND;
if (FlagsForProperty(prop) & PROPERTY_READ_ONLY)
return B_READ_ONLY;
BMenuItem *backend = (BMenuItem*)fBackend;
BoolValue boolval;
CharValue charval;
ColorValue colorval;
FloatValue floatval;
IntValue intval;
PointValue pointval;
RectValue rectval;
StringValue stringval;
status_t status = prop->SetValue(value);
if (status != B_OK)
return status;
if (str.ICompare("Message") == 0)
{
prop->GetValue(&intval);
backend->SetMessage(new BMessage(*intval.value));
}
else if (str.ICompare("Trigger") == 0)
{
prop->GetValue(&charval);
backend->SetTrigger(*charval.value);
}
else if (str.ICompare("Label") == 0)
{
prop->GetValue(&stringval);
backend->SetLabel(*stringval.value);
}
else if (str.ICompare("Marked") == 0)
{
prop->GetValue(&boolval);
backend->SetMarked(*boolval.value);
}
else if (str.ICompare("Enabled") == 0)
{
prop->GetValue(&boolval);
backend->SetEnabled(*boolval.value);
}
else
{
return PObject::SetProperty(name, value, index);
}
return prop->GetValue(value);
}
示例9: MessageReceived
/**
* @brief Message handler.
*/
void BePreferencesDlg::MessageReceived(
BMessage *message //!< received message.
)
{
try
{
switch (message->what)
{
case ID_PREF_KEYMAP_SELECTED:
HandleUICEvent(CID_KeyMapListBox, UICE_SelectionChanged, 0, NULL);
break;
case ID_PREF_EDIT_KEYMAP:
HandleUICEvent(CID_EditKeyMapButton, UICE_ButtonClicked, 0, NULL);
break;
case ID_PREF_DUPLICATE_KEYMAP:
HandleUICEvent(CID_DuplicateKeyMapButton, UICE_ButtonClicked, 0, NULL);
break;
case ID_PREF_DELETE_KEYMAP:
HandleUICEvent(CID_DeleteKeyMapButton, UICE_ButtonClicked, 0, NULL);
break;
case ID_DIALOG_OK:
HandleUICEvent(CID_OKButton, UICE_ButtonClicked, 0, NULL);
break;
case ID_DIALOG_CANCEL:
HandleUICEvent(CID_CancelButton, UICE_ButtonClicked, 0, NULL);
break;
#if defined (ZETA)
case B_LANGUAGE_CHANGED:
// always use locake kit to show "Use LocakeKit" item label.
// note that languageChanged() is called only when current setting
// is "Use LocaleKit". so do here.
if (NULL != langMenu && langMenu->CountItems() > 0)
{
BMenuItem* menuItem = langMenu->ItemAt(0);
menuItem->SetLabel(_T(LangSelectHelper::LANGMENU_LOCALEKIT));
if (menuItem->IsMarked())
{
menuItem->SetMarked(false);
menuItem->SetMarked(true);
}
}
baseWindow::MessageReceived(message);
break;
#endif
default:
baseWindow::MessageReceived(message);
break;
}
}
catch (Exception* ex)
{
ExceptionMessageUtils::DoExceptionMessageBox(CoveredCalcApp::GetInstance(), ex);
ex->Delete();
}
}