本文整理汇总了C++中BNavMenu类的典型用法代码示例。如果您正苦于以下问题:C++ BNavMenu类的具体用法?C++ BNavMenu怎么用?C++ BNavMenu使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BNavMenu类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: model
void
BDirMenu::AddItemToDirMenu(const BEntry* entry, BWindow* originatingWindow,
bool atEnd, bool addShortcuts, bool navMenuEntries)
{
Model model(entry);
if (model.InitCheck() != B_OK)
return;
BMessage* message = new BMessage(fCommand);
message->AddRef(fEntryName.String(), model.EntryRef());
// add reference to the container windows model so that we can
// close the window if
BContainerWindow* window = originatingWindow ?
dynamic_cast<BContainerWindow*>(originatingWindow) : 0;
if (window)
message->AddData("nodeRefsToClose", B_RAW_TYPE,
window->TargetModel()->NodeRef(), sizeof (node_ref));
ModelMenuItem* item;
if (navMenuEntries) {
BNavMenu* subMenu = new BNavMenu(model.Name(), B_REFS_RECEIVED,
fTarget, window);
entry_ref ref;
entry->GetRef(&ref);
subMenu->SetNavDir(&ref);
item = new ModelMenuItem(&model, subMenu);
item->SetLabel(model.Name());
item->SetMessage(message);
} else {
item = new ModelMenuItem(&model, model.Name(), message);
}
if (addShortcuts) {
if (model.IsDesktop())
item->SetShortcut('D', B_COMMAND_KEY);
else if (FSIsHomeDir(entry))
item->SetShortcut('H', B_COMMAND_KEY);
}
if (atEnd)
AddItem(item);
else
AddItem(item, 0);
item->SetTarget(fTarget);
if (fMenuBar) {
ModelMenuItem* menu
= dynamic_cast<ModelMenuItem*>(fMenuBar->ItemAt(0));
if (menu) {
ThrowOnError(menu->SetEntry(entry));
item->SetMarked(true);
}
}
}
示例2: BNavMenu
void
BNavMenu::AddNavParentDir(const char *name,const Model *model,uint32 what,BHandler *target)
{
BNavMenu *menu = new BNavMenu(name,what,target);
menu->SetNavDir(model->EntryRef());
menu->SetShowParent(true);
menu->InitTrackingHook(fTrackingHook.fTrackingHook, &(fTrackingHook.fTarget),
fTrackingHook.fDragMessage);
BMenuItem *item = new SpecialModelMenuItem(model,menu);
BMessage *message = new BMessage(what);
message->AddRef("refs",model->EntryRef());
item->SetMessage(message);
AddItem(item);
}
示例3: while
void
BSlowContextMenu::BuildVolumeMenu()
{
BVolumeRoster roster;
BVolume volume;
roster.Rewind();
while (roster.GetNextVolume(&volume) == B_OK) {
if (!volume.IsPersistent())
continue;
BDirectory startDir;
if (volume.GetRootDirectory(&startDir) == B_OK) {
BEntry entry;
startDir.GetEntry(&entry);
Model *model = new Model(&entry);
if (model->InitCheck() != B_OK) {
delete model;
continue;
}
BNavMenu *menu = new BNavMenu(model->Name(), fMessage.what,
fMessenger, fParentWindow, fTypesList);
menu->SetNavDir(model->EntryRef());
menu->InitTrackingHook(fTrackingHook.fTrackingHook, &(fTrackingHook.fTarget),
fTrackingHook.fDragMessage);
ASSERT(menu->Name());
ModelMenuItem *item = new ModelMenuItem(model, menu);
BMessage *message = new BMessage(fMessage);
message->AddRef("refs", model->EntryRef());
item->SetMessage(message);
fItemList->AddItem(item);
ASSERT(item->Label());
}
}
}
示例4: BMessage
void
BNavMenu::AddNavDir(const Model *model, uint32 what, BHandler *target,
bool populateSubmenu)
{
BMessage *message = new BMessage((uint32)what);
message->AddRef("refs", model->EntryRef());
ModelMenuItem *item = NULL;
if (populateSubmenu) {
BNavMenu *navMenu = new BNavMenu(model->Name(), what, target);
navMenu->SetNavDir(model->EntryRef());
navMenu->InitTrackingHook(fTrackingHook.fTrackingHook, &(fTrackingHook.fTarget),
fTrackingHook.fDragMessage);
item = new ModelMenuItem(model, navMenu);
item->SetMessage(message);
} else
item = new ModelMenuItem(model, model->Name(), message);
AddItem(item);
}
示例5: Model
ModelMenuItem *
BSlowContextMenu::NewModelItem(Model *model, const BMessage *invokeMessage,
const BMessenger &target, bool suppressFolderHierarchy,
BContainerWindow *parentWindow, const BObjectList<BString> *typeslist,
TrackingHookData *hook)
{
if (model->InitCheck() != B_OK)
return NULL;
entry_ref ref;
bool container = false;
if (model->IsSymLink()) {
Model *newResolvedModel = NULL;
Model *result = model->LinkTo();
if (!result) {
newResolvedModel = new Model(model->EntryRef(), true, true);
if (newResolvedModel->InitCheck() != B_OK) {
// broken link, still can show though, bail
delete newResolvedModel;
newResolvedModel = NULL;
}
result = newResolvedModel;
}
if (result) {
BModelOpener opener(result);
// open the model, if it ain't open already
PoseInfo poseInfo;
ssize_t size = -1;
if (result->Node())
size = result->Node()->ReadAttr(kAttrPoseInfo, B_RAW_TYPE, 0,
&poseInfo, sizeof(poseInfo));
result->CloseNode();
ref = *result->EntryRef();
container = result->IsContainer();
}
model->SetLinkTo(result);
} else {
ref = *model->EntryRef();
container = model->IsContainer();
}
BMessage *message = new BMessage(*invokeMessage);
message->AddRef("refs", model->EntryRef());
// Truncate the name if necessary
BString truncatedString(model->Name());
be_plain_font->TruncateString(&truncatedString, B_TRUNCATE_END,
BNavMenu::GetMaxMenuWidth());
ModelMenuItem *item = NULL;
if (!container || suppressFolderHierarchy) {
item = new ModelMenuItem(model, truncatedString.String(), message);
if (invokeMessage->what != B_REFS_RECEIVED)
item->SetEnabled(false);
} else {
BNavMenu *menu = new BNavMenu(truncatedString.String(),
invokeMessage->what, target, parentWindow, typeslist);
menu->SetNavDir(&ref);
if (hook)
menu->InitTrackingHook(hook->fTrackingHook, &(hook->fTarget),
hook->fDragMessage);
item = new ModelMenuItem(model, menu);
item->SetMessage(message);
}
return item;
}
示例6: AddStandardDeskbarMenuItems
bool
TDeskbarMenu::AddNextItem()
{
if (fAddState == kStart)
return AddStandardDeskbarMenuItems();
TrackingHookData* data = fBarView->GetTrackingHookData();
if (fAddState == kAddingRecents) {
static const char* recentTitle[] = {
B_TRANSLATE_MARK("Recent documents"),
B_TRANSLATE_MARK("Recent folders"),
B_TRANSLATE_MARK("Recent applications")};
const int recentType[] = {kRecentDocuments, kRecentFolders,
kRecentApplications};
const int recentTypes = 3;
TRecentsMenu* recentItem[recentTypes];
bool enabled = false;
for (int i = 0; i < recentTypes; i++) {
recentItem[i]
= new TRecentsMenu(B_TRANSLATE_NOCOLLECT(recentTitle[i]),
fBarView, recentType[i]);
if (recentItem[i])
enabled |= recentItem[i]->RecentsEnabled();
}
if (enabled) {
AddSeparatorItem();
for (int i = 0; i < recentTypes; i++) {
if (!recentItem[i])
continue;
if (recentItem[i]->RecentsEnabled()) {
recentItem[i]->SetTypesList(TypesList());
recentItem[i]->SetTarget(Target());
AddItem(recentItem[i]);
}
if (data && fBarView && fBarView->Dragging()) {
recentItem[i]->InitTrackingHook(data->fTrackingHook,
&data->fTarget, data->fDragMessage);
}
}
}
AddSeparatorItem();
fAddState = kAddingDeskbarMenu;
return true;
}
if (fAddState == kAddingDeskbarMenu) {
// keep reentering and adding items
// until this returns false
bool done = BNavMenu::AddNextItem();
BMenuItem* item = ItemAt(CountItems() - 1);
if (item) {
BNavMenu* menu = dynamic_cast<BNavMenu*>(item->Menu());
if (menu) {
if (data && fBarView->Dragging()) {
menu->InitTrackingHook(data->fTrackingHook,
&data->fTarget, data->fDragMessage);
} else
menu->InitTrackingHook(0, NULL, NULL);
}
}
if (!done)
fAddState = kDone;
return done;
}
return false;
}
示例7: model
BMenuItem*
BRecentItemsList::GetNextMenuItem(const BMessage* fileOpenInvokeMessage,
const BMessage* containerOpenInvokeMessage, BHandler* target,
entry_ref* currentItemRef)
{
entry_ref ref;
if (GetNextRef(&ref) != B_OK)
return NULL;
Model model(&ref, true);
if (model.InitCheck() != B_OK)
return NULL;
bool container = false;
if (model.IsSymLink()) {
Model* newResolvedModel = NULL;
Model* result = model.LinkTo();
if (result == NULL) {
newResolvedModel = new Model(model.EntryRef(), true, true);
if (newResolvedModel->InitCheck() != B_OK) {
// broken link, still can show though, bail
delete newResolvedModel;
result = NULL;
} else
result = newResolvedModel;
} else {
BModelOpener opener(result);
// open the model, if it ain't open already
PoseInfo poseInfo;
BNode* resultNode = result->Node();
if (resultNode != NULL) {
resultNode->ReadAttr(kAttrPoseInfo, B_RAW_TYPE, 0,
&poseInfo, sizeof(poseInfo));
}
result->CloseNode();
ref = *result->EntryRef();
container = result->IsContainer();
}
model.SetLinkTo(result);
} else {
ref = *model.EntryRef();
container = model.IsContainer();
}
// if user asked for it, return the current item ref
if (currentItemRef != NULL)
*currentItemRef = ref;
BMessage* message;
if (container && containerOpenInvokeMessage)
message = new BMessage(*containerOpenInvokeMessage);
else if (!container && fileOpenInvokeMessage)
message = new BMessage(*fileOpenInvokeMessage);
else
message = new BMessage(B_REFS_RECEIVED);
message->AddRef("refs", model.EntryRef());
// Truncate the name if necessary
BString truncatedString(model.Name());
be_plain_font->TruncateString(&truncatedString, B_TRUNCATE_END,
BNavMenu::GetMaxMenuWidth());
ModelMenuItem* item = NULL;
if (!container || !fNavMenuFolders)
item = new ModelMenuItem(&model, truncatedString.String(), message);
else {
// add another nav menu item if it's a directory
BNavMenu* menu = new BNavMenu(truncatedString.String(), message->what,
target, 0);
menu->SetNavDir(&ref);
item = new ModelMenuItem(&model, menu);
item->SetMessage(message);
}
if (item != NULL && target != NULL)
item->SetTarget(target);
return item;
}
示例8: Model
ModelMenuItem *
BNavMenu::NewModelItem(Model *model, const BMessage *invokeMessage,
const BMessenger &target, bool suppressFolderHierarchy,
BContainerWindow *parentWindow, const BObjectList<BString> *typeslist,
TrackingHookData *hook)
{
if (model->InitCheck() != B_OK)
return 0;
entry_ref ref;
bool container = false;
if (model->IsSymLink()) {
Model *newResolvedModel = 0;
Model *result = model->LinkTo();
if (!result) {
newResolvedModel = new Model(model->EntryRef(), true, true);
if (newResolvedModel->InitCheck() != B_OK) {
// broken link, still can show though, bail
delete newResolvedModel;
result = 0;
} else
result = newResolvedModel;
}
if (result) {
BModelOpener opener(result);
// open the model, if it ain't open already
PoseInfo poseInfo;
ssize_t size = -1;
if (result->Node())
size = result->Node()->ReadAttr(kAttrPoseInfo, B_RAW_TYPE, 0,
&poseInfo, sizeof(poseInfo));
result->CloseNode();
if (size == sizeof(poseInfo) && !BPoseView::PoseVisible(result,
&poseInfo, false)) {
// link target sez it doesn't want to be visible,
// don't show the link
PRINT(("not showing hidden item %s\n", model->Name()));
delete newResolvedModel;
return 0;
}
ref = *result->EntryRef();
container = result->IsContainer();
}
model->SetLinkTo(result);
} else {
ref = *model->EntryRef();
container = model->IsContainer();
}
BMessage *message = new BMessage(*invokeMessage);
message->AddRef("refs", model->EntryRef());
// Truncate the name if necessary
BString truncatedString;
TruncString(be_plain_font, model->Name(), truncatedString, GetMaxMenuWidth());
ModelMenuItem *item = NULL;
if (!container || suppressFolderHierarchy) {
item = new ModelMenuItem(model, truncatedString.String(), message);
if (invokeMessage->what != B_REFS_RECEIVED)
item->SetEnabled(false);
// the above is broken for FavoritesMenu::AddNextItem, which uses a
// workaround - should fix this
} else {
BNavMenu *menu = new BNavMenu(truncatedString.String(),
invokeMessage->what, target, parentWindow, typeslist);
menu->SetNavDir(&ref);
if (hook)
menu->InitTrackingHook(hook->fTrackingHook, &(hook->fTarget),
hook->fDragMessage);
item = new ModelMenuItem(model, menu);
item->SetMessage(message);
}
return item;
}