本文整理汇总了C++中BNavMenu::InitTrackingHook方法的典型用法代码示例。如果您正苦于以下问题:C++ BNavMenu::InitTrackingHook方法的具体用法?C++ BNavMenu::InitTrackingHook怎么用?C++ BNavMenu::InitTrackingHook使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BNavMenu
的用法示例。
在下文中一共展示了BNavMenu::InitTrackingHook方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: Model
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());
}
}
}
示例3: 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);
}
示例4: opener
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;
}
示例5: 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;
}
示例6: opener
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;
}