本文整理汇总了C++中BMenu::Superitem方法的典型用法代码示例。如果您正苦于以下问题:C++ BMenu::Superitem方法的具体用法?C++ BMenu::Superitem怎么用?C++ BMenu::Superitem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BMenu
的用法示例。
在下文中一共展示了BMenu::Superitem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BMessage
// PopulateMenu
void
FontValueView::_PolulateMenu(BMenu* menu, BHandler* target,
const char* markedFamily,
const char* markedStyle)
{
if (!menu)
return;
FontManager* manager = FontManager::Default();
if (!manager->Lock())
return;
BMenu* fontMenu = NULL;
font_family family;
font_style style;
int32 count = manager->CountFontFiles();
for (int32 i = 0; i < count; i++) {
if (!manager->GetFontAt(i, family, style))
break;
BMessage* message = new BMessage(MSG_FONT_CHANGED);
message->AddString("font family", family);
message->AddString("font style", style);
FontMenuItem* item = new FontMenuItem(style, family, style,
message);
item->SetTarget(target);
bool markStyle = false;
if (!fontMenu
|| (fontMenu->Name()
&& strcmp(fontMenu->Name(), family) != 0)) {
// create new entry
fontMenu = new BMenu(family);
fontMenu->AddItem(item);
menu->AddItem(fontMenu);
// mark the menu if necessary
if (markedFamily && strcmp(markedFamily, family) == 0) {
if (BMenuItem* superItem = fontMenu->Superitem())
superItem->SetMarked(true);
markStyle = true;
}
} else {
// reuse old entry
fontMenu->AddItem(item);
}
// mark the item if necessary
if (markStyle && markedStyle && strcmp(markedStyle, style) == 0)
item->SetMarked(true);
}
manager->Unlock();
}
示例2: CountItems
void
QPopupMenu::EntryCreated(const entry_ref &ref, ino_t node)
{
BNode file;
if (file.SetTo(&ref) < B_OK)
return;
// Make sure the pop-up menu is ready for additions. Need a bunch of
// groups at the top, a divider line, and miscellaneous people added below
// the line.
int32 items = CountItems();
if (!items)
AddSeparatorItem();
// Does the file have a group attribute? OK to have none.
BString groups;
const char *kNoGroup = "NoGroup!";
file.ReadAttrString("META:group", &groups);
if (groups.Length() <= 0)
groups = kNoGroup;
// Add the e-mail address to the all people group. Then add it to all the
// group menus that it exists in (based on the comma separated list of
// groups from the People file), optionally making the group menu if it
// doesn't exist. If it's in the special NoGroup! list, then add it below
// the groups.
bool allPeopleGroupDone = false;
BMenu *groupMenu;
do {
BString group;
if (!allPeopleGroupDone) {
// Create the default group for all people, if it doesn't exist yet.
group = "All People";
allPeopleGroupDone = true;
} else {
// Break out the next group from the comma separated string.
int32 comma;
if ((comma = groups.FindFirst(',')) > 0) {
groups.MoveInto(group, 0, comma);
groups.Remove(0, 1);
} else
group.Adopt(groups);
}
// trim white spaces
int32 i = 0;
for (i = 0; isspace(group.ByteAt(i)); i++) {}
if (i)
group.Remove(0, i);
for (i = group.Length() - 1; isspace(group.ByteAt(i)); i--) {}
group.Truncate(i + 1);
groupMenu = NULL;
BMenuItem *superItem = NULL; // Corresponding item for group menu.
if (group.Length() > 0 && group != kNoGroup) {
BMenu *sub;
// Look for submenu with label == group name
for (int32 i = 0; i < items; i++) {
if ((sub = SubmenuAt(i)) != NULL) {
superItem = sub->Superitem();
if (!strcmp(superItem->Label(), group.String())) {
groupMenu = sub;
i++;
break;
}
}
}
// If no submenu, create one
if (!groupMenu) {
// Find where it should go (alphabetical)
int32 mindex = 0;
for (; mindex < fGroups; mindex++) {
if (strcmp(ItemAt(mindex)->Label(), group.String()) > 0)
break;
}
groupMenu = new BMenu(group.String());
groupMenu->SetFont(be_plain_font);
AddItem(groupMenu, mindex);
superItem = groupMenu->Superitem();
superItem->SetMessage(new BMessage(B_SIMPLE_DATA));
if (fTargetHandler)
superItem->SetTarget(fTargetHandler);
fGroups++;
}
}
BString name;
file.ReadAttrString("META:name", &name);
BString email;
file.ReadAttrString("META:email", &email);
//.........这里部分代码省略.........
示例3: MessageReceived
//.........这里部分代码省略.........
case MENU_DISTANCE:
ConfigDistance();
break;
/* case MENU_SQL:
ConfigSQLTables();
break; */
case MENU_ABOUT: {
BString about;
about = "\n\n" APP_NAME " " APP_VERSION "\n";
about += "English-Polish, Polish-English dictionary\n";
about += "\n\nBeOS version:\n";
about += "Maciej Witkowiak <[email protected]>";
about += "\n\nSAP engine based on sap v0.2b\n";
about += "(c) 1998 Bohdan R. Rau,\n(c) 2001 Daniel Mealha Cabrita";
about += "\nYDP and SQL engines by Maciej Witkowiak\n";
about += "\n\nSoftware released under GNU/GPL license";
about += "\n\nvisit:\n";
about += "http://home.elysium.pl/ytm/html/beos.html\n";
about += "\nDevelopment has been encouraged by:\n";
about += "http://www.haiku-os.pl";
outputView->SetText(about.String()); }
break;
case FONT_SIZE:
{
float fontSize;
Message->FindFloat("size",&fontSize);
SetFontSize(fontSize);
}
break;
case FONT_FAMILY:
{
const char * fontFamily = 0, * fontStyle = 0;
void * ptr;
if (Message->FindPointer("source",&ptr) == B_OK) {
currentFontItem = static_cast<BMenuItem*>(ptr);
fontFamily = currentFontItem->Label();
}
SetFontStyle(fontFamily, fontStyle);
}
case FONT_STYLE:
{
const char * fontFamily = 0, * fontStyle = 0;
void * ptr;
if (Message->FindPointer("source",&ptr) == B_OK) {
BMenuItem * item = static_cast<BMenuItem*>(ptr);
fontStyle = item->Label();
BMenu * menu = item->Menu();
if (menu != 0) {
currentFontItem = menu->Superitem();
if (currentFontItem != 0) {
fontFamily = currentFontItem->Label();
}
}
}
SetFontStyle(fontFamily, fontStyle);
}
case MSG_SCROLL:
// printf("scroll value changed\n");
if (scrollBar->Value() != dictList->topIndex) {
dictList->ListScrolled(scrollBar->Value());
myDict->GetDefinition(myDict->wordPairs[dictList->topIndex+dictList->CurrentSelection(0)]);
}
break;
case MSG_COLOURUPDATE:
// printf("colour update\n");
myDict->ReGetDefinition();
break;
case MSG_FUZZYUPDATE:
// printf("fuzzy update\n");
if (config->searchmode == SEARCH_FUZZY)
HandleModifiedInput(true);
break;
/* case MSG_SQLTABLESUPDATE:
// printf("sql tables updated\n");
myDict->FlushCache();
SwitchEngine(config->dictionarymode);
break; */
case B_CLIPBOARD_CHANGED:
NewClipData();
break;
case B_REFS_RECEIVED:
RefsReceived(Message);
break;
case B_CANCEL:
// printf("canceled\n");
if (firstStart) {
config->dictionarymode = DICTIONARY_SAP; // will be saved in QuitRequested below
BAlert *alert = new BAlert(APP_NAME, "Couldn't open dictionary. Dictionary engine has been reset to SAP.", "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
alert->Go();
QuitRequested();
}
else
delete myPanel;
// break;
default:
BWindow::MessageReceived(Message);
break;
}
this->EnableUpdates();
}