本文整理汇总了C++中BView::Archive方法的典型用法代码示例。如果您正苦于以下问题:C++ BView::Archive方法的具体用法?C++ BView::Archive怎么用?C++ BView::Archive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BView
的用法示例。
在下文中一共展示了BView::Archive方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MessageReceived
void MessageReceived(BMessage* message)
{
switch (message->what) {
case 'BOOM':
if (!fBoom) {
fBoom = _MakeButton("BOOM");
fLayout2->AddView(fBoom, fLeft, fTop,
fRight, fBottom);
} else {
if (fBoom->IsHidden(fBoom))
fBoom->Show();
else
fBoom->Hide();
}
break;
case 'arcv': {
BView* view = GetLayout()->View();
BMessage archive;
status_t err = view->Archive(&archive, true);
BWindow* window = new BWindow(BRect(30, 30, 400, 400),
"ALM Friend Test Clone", B_TITLED_WINDOW,
B_QUIT_ON_WINDOW_CLOSE | B_AUTO_UPDATE_SIZE_LIMITS);
window->SetLayout(new BGroupLayout(B_VERTICAL));
BView* clone;
if (err == B_OK)
err = BUnarchiver::InstantiateObject(&archive, clone);
if (err != B_OK)
window->AddChild(new BStringView("", "An error occurred!"));
else {
window->AddChild(clone);
}
window->Show();
break;
}
default:
BWindow::MessageReceived(message);
}
}
示例2: node
/*! The add-ons must support the exported C function API
if they do, they will be loaded and added to deskbar
primary function is the Instantiate function
*/
status_t
TReplicantTray::LoadAddOn(BEntry* entry, int32* id, bool addToSettings)
{
if (!entry)
return B_ERROR;
node_ref nodeRef;
entry->GetNodeRef(&nodeRef);
// no duplicates
if (NodeExists(nodeRef))
return B_ERROR;
BNode node(entry);
BPath path;
status_t status = entry->GetPath(&path);
if (status < B_OK)
return status;
// load the add-on
image_id image = load_add_on(path.Path());
if (image < B_OK)
return image;
// get the view loading function symbol
// we first look for a symbol that takes an image_id
// and entry_ref pointer, if not found, go with normal
// instantiate function
BView* (*entryFunction)(image_id, const entry_ref*);
BView* (*itemFunction)(void);
BView* view = NULL;
entry_ref ref;
entry->GetRef(&ref);
if (get_image_symbol(image, kInstantiateEntryCFunctionName,
B_SYMBOL_TYPE_TEXT, (void**)&entryFunction) >= B_OK) {
view = (*entryFunction)(image, &ref);
} else if (get_image_symbol(image, kInstantiateItemCFunctionName,
B_SYMBOL_TYPE_TEXT, (void**)&itemFunction) >= B_OK) {
view = (*itemFunction)();
} else {
unload_add_on(image);
return B_ERROR;
}
if (view == NULL || IconExists(view->Name())) {
delete view;
unload_add_on(image);
return B_ERROR;
}
BMessage* data = new BMessage;
view->Archive(data);
delete view;
AddIcon(data, id, &ref);
// add the rep; adds info to list
if (addToSettings) {
fAddOnSettings.AddString(kReplicantPathField, path.Path());
_SaveSettings();
}
return B_OK;
}