本文整理汇总了C++中BContainerWindow::PostMessage方法的典型用法代码示例。如果您正苦于以下问题:C++ BContainerWindow::PostMessage方法的具体用法?C++ BContainerWindow::PostMessage怎么用?C++ BContainerWindow::PostMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BContainerWindow
的用法示例。
在下文中一共展示了BContainerWindow::PostMessage方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: entry
void
DesktopPoseView::AdaptToVolumeChange(BMessage* message)
{
TTracker* tracker = dynamic_cast<TTracker*>(be_app);
if (!tracker)
return;
bool showDisksIcon = false;
bool mountVolumesOnDesktop = true;
bool mountSharedVolumesOntoDesktop = false;
message->FindBool("ShowDisksIcon", &showDisksIcon);
message->FindBool("MountVolumesOntoDesktop", &mountVolumesOnDesktop);
message->FindBool("MountSharedVolumesOntoDesktop",
&mountSharedVolumesOntoDesktop);
BEntry entry("/");
Model model(&entry);
if (model.InitCheck() == B_OK) {
BMessage entryMessage;
entryMessage.what = B_NODE_MONITOR;
if (showDisksIcon)
entryMessage.AddInt32("opcode", B_ENTRY_CREATED);
else {
entryMessage.AddInt32("opcode", B_ENTRY_REMOVED);
entry_ref ref;
if (entry.GetRef(&ref) == B_OK) {
BContainerWindow* disksWindow
= tracker->FindContainerWindow(&ref);
if (disksWindow) {
disksWindow->Lock();
disksWindow->Close();
}
}
}
entryMessage.AddInt32("device", model.NodeRef()->device);
entryMessage.AddInt64("node", model.NodeRef()->node);
entryMessage.AddInt64("directory", model.EntryRef()->directory);
entryMessage.AddString("name", model.EntryRef()->name);
BContainerWindow* deskWindow
= dynamic_cast<BContainerWindow*>(Window());
if (deskWindow)
deskWindow->PostMessage(&entryMessage, deskWindow->PoseView());
}
ShowVolumes(mountVolumesOnDesktop, mountSharedVolumesOntoDesktop);
}
示例2: dir
void
TTracker::CloseWindowAndChildren(const node_ref *node)
{
BDirectory dir(node);
if (dir.InitCheck() != B_OK)
return;
AutoLock<WindowList> lock(&fWindowList);
BObjectList<BContainerWindow> closeList;
// make a list of all windows to be closed
// count from end to beginning so we can remove items safely
for (int32 index = fWindowList.CountItems() - 1; index >= 0; index--) {
BContainerWindow *window = dynamic_cast<BContainerWindow *>
(fWindowList.ItemAt(index));
if (window && window->TargetModel()) {
BEntry wind_entry;
wind_entry.SetTo(window->TargetModel()->EntryRef());
if ((*window->TargetModel()->NodeRef() == *node)
|| dir.Contains(&wind_entry)) {
// ToDo:
// get rid of the Remove here, BContainerWindow::Quit does it
fWindowList.RemoveItemAt(index);
closeList.AddItem(window);
}
}
}
// now really close the windows
int32 numItems = closeList.CountItems();
for (int32 index = 0; index < numItems; index++) {
BContainerWindow *window = closeList.ItemAt(index);
window->PostMessage(B_CLOSE_REQUESTED);
}
}
示例3: restoreStateMessage
void
TTracker::OpenContainerWindow(Model *model, BMessage *originalRefsList,
OpenSelector openSelector, uint32 openFlags, bool checkAlreadyOpen,
const BMessage *stateMessage)
{
AutoLock<WindowList> lock(&fWindowList);
BContainerWindow *window = NULL;
if (checkAlreadyOpen && openSelector != kRunOpenWithWindow)
// find out if window already open
window = FindContainerWindow(model->NodeRef());
bool someWindowActivated = false;
uint32 workspace = (uint32)(1 << current_workspace());
int32 windowCount = 0;
while (window) {
// At least one window open, just pull to front
// make sure we don't jerk workspaces around
uint32 windowWorkspaces = window->Workspaces();
if (windowWorkspaces & workspace) {
window->Activate();
someWindowActivated = true;
}
window = FindContainerWindow(model->NodeRef(), ++windowCount);
}
if (someWindowActivated) {
delete model;
return;
} // If no window was actiated, (none in the current workspace
// we open a new one.
if (openSelector == kRunOpenWithWindow) {
BMessage *refList = NULL;
if (!originalRefsList) {
// when passing just a single model, stuff it's entry in a single
// element list anyway
ASSERT(model);
refList = new BMessage;
refList->AddRef("refs", model->EntryRef());
delete model;
model = NULL;
} else
// clone the message, window adopts it for it's own use
refList = new BMessage(*originalRefsList);
window = new OpenWithContainerWindow(refList, &fWindowList);
} else if (model->IsRoot()) {
// window will adopt the model
window = new BVolumeWindow(&fWindowList, openFlags);
} else if (model->IsQuery()) {
// window will adopt the model
window = new BQueryContainerWindow(&fWindowList, openFlags);
} else
// window will adopt the model
window = new BContainerWindow(&fWindowList, openFlags);
if (model)
window->CreatePoseView(model);
BMessage restoreStateMessage(kRestoreState);
if (stateMessage)
restoreStateMessage.AddMessage("state", stateMessage);
window->PostMessage(&restoreStateMessage);
}
示例4: entry
//.........这里部分代码省略.........
bool openDisksWindow = false;
// open desktop window
BContainerWindow *deskWindow = NULL;
BVolume bootVol;
BVolumeRoster().GetBootVolume(&bootVol);
BDirectory deskDir;
if (FSGetDeskDir(&deskDir, bootVol.Device()) == B_OK) {
// create desktop
BEntry entry;
deskDir.GetEntry(&entry);
Model *model = new Model(&entry);
if (model->InitCheck() == B_OK) {
AutoLock<WindowList> lock(&fWindowList);
deskWindow = new BDeskWindow(&fWindowList);
AutoLock<BWindow> windowLock(deskWindow);
deskWindow->CreatePoseView(model);
deskWindow->Init();
} else
delete model;
// open previously open windows
attr_info attrInfo;
if (!BootedInSafeMode()
&& deskDir.GetAttrInfo(kAttrOpenWindows, &attrInfo) == B_OK) {
char *buffer = (char *)malloc((size_t)attrInfo.size);
BMessage message;
if (deskDir.ReadAttr(kAttrOpenWindows, B_MESSAGE_TYPE, 0, buffer, (size_t)attrInfo.size)
== attrInfo.size
&& message.Unflatten(buffer) == B_OK) {
node_ref nodeRef;
deskDir.GetNodeRef(&nodeRef);
int32 stateMessageCounter = 0;
const char *path;
for (int32 outer = 0;message.FindString("paths", outer, &path) == B_OK;outer++) {
int8 flags = 0;
for (int32 inner = 0;message.FindInt8(path, inner, &flags) == B_OK;inner++) {
BEntry entry(path, true);
if (entry.InitCheck() == B_OK) {
Model *model = new Model(&entry);
if (model->InitCheck() == B_OK && model->IsContainer()) {
BMessage state;
bool restoreStateFromMessage = false;
if ((flags & kOpenWindowHasState) != 0
&& message.FindMessage("window state", stateMessageCounter++, &state) == B_OK)
restoreStateFromMessage = true;
if (restoreStateFromMessage)
OpenContainerWindow(model, 0, kOpen,
kRestoreWorkspace | (flags & kOpenWindowMinimized ? kIsHidden : 0U),
false, &state);
else
OpenContainerWindow(model, 0, kOpen,
kRestoreWorkspace | (flags & kOpenWindowMinimized ? kIsHidden : 0U));
} else
delete model;
}
}
}
if (message.HasBool("open_disks_window"))
openDisksWindow = true;
}
free(buffer);
}
}
// create model for root of everything
if (deskWindow) {
BEntry entry("/");
Model model(&entry);
if (model.InitCheck() == B_OK) {
if (TrackerSettings().ShowDisksIcon()) {
// add the root icon to desktop window
BMessage message;
message.what = B_NODE_MONITOR;
message.AddInt32("opcode", B_ENTRY_CREATED);
message.AddInt32("device", model.NodeRef()->device);
message.AddInt64("node", model.NodeRef()->node);
message.AddInt64("directory", model.EntryRef()->directory);
message.AddString("name", model.EntryRef()->name);
deskWindow->PostMessage(&message, deskWindow->PoseView());
}
if (openDisksWindow)
OpenContainerWindow(new Model(model), 0, kOpen, kRestoreWorkspace);
}
}
// kick off building the mime type list for find panels, etc.
fMimeTypeList = new MimeTypeList();
if (!BootedInSafeMode())
// kick of transient query killer
DeleteTransientQueriesTask::StartUpTransientQueryCleaner();
}
示例5: entry
void
TTracker::ReadyToRun()
{
gStatusWindow = new BStatusWindow();
InitMimeTypes();
InstallDefaultTemplates();
InstallIndices();
InstallTemporaryBackgroundImages();
fTrashWatcher = new BTrashWatcher();
fTrashWatcher->Run();
fClipboardRefsWatcher = new BClipboardRefsWatcher();
fClipboardRefsWatcher->Run();
fTaskLoop = new StandAloneTaskLoop(true);
// open desktop window
BContainerWindow *deskWindow = NULL;
BDirectory deskDir;
if (FSGetDeskDir(&deskDir) == B_OK) {
// create desktop
BEntry entry;
deskDir.GetEntry(&entry);
Model *model = new Model(&entry, true);
if (model->InitCheck() == B_OK) {
AutoLock<WindowList> lock(&fWindowList);
deskWindow = new BDeskWindow(&fWindowList);
AutoLock<BWindow> windowLock(deskWindow);
deskWindow->CreatePoseView(model);
deskWindow->Init();
if (TrackerSettings().ShowDisksIcon()) {
// create model for root of everything
BEntry entry("/");
Model model(&entry);
if (model.InitCheck() == B_OK) {
// add the root icon to desktop window
BMessage message;
message.what = B_NODE_MONITOR;
message.AddInt32("opcode", B_ENTRY_CREATED);
message.AddInt32("device", model.NodeRef()->device);
message.AddInt64("node", model.NodeRef()->node);
message.AddInt64("directory", model.EntryRef()->directory);
message.AddString("name", model.EntryRef()->name);
deskWindow->PostMessage(&message, deskWindow->PoseView());
}
}
} else
delete model;
}
// kick off building the mime type list for find panels, etc.
fMimeTypeList = new MimeTypeList();
if (!BootedInSafeMode()) {
// kick of transient query killer
DeleteTransientQueriesTask::StartUpTransientQueryCleaner();
// the mount_server will have mounted the previous volumes already.
_OpenPreviouslyOpenedWindows();
}
}
示例6: restoreStateMessage
void
TTracker::OpenContainerWindow(Model* model, BMessage* originalRefsList,
OpenSelector openSelector, uint32 openFlags, bool checkAlreadyOpen,
const BMessage* stateMessage)
{
AutoLock<WindowList> lock(&fWindowList);
BContainerWindow* window = NULL;
const node_ref* modelNodeRef = model->NodeRef();
if (checkAlreadyOpen && openSelector != kRunOpenWithWindow) {
// find out if window already open
window = FindContainerWindow(modelNodeRef);
}
bool someWindowActivated = false;
uint32 workspace = (uint32)(1 << current_workspace());
int32 windowCount = 0;
while (window != NULL) {
if ((window->Workspaces() & workspace) != 0
&& (dynamic_cast<BDeskWindow*>(window) == NULL
|| !TrackerSettings().SingleWindowBrowse())) {
// We found at least one window that is open and is not Desktop
// or we're in spatial mode, activate it and make sure we don't
// jerk the workspaces around.
window->Activate();
someWindowActivated = true;
}
window = FindContainerWindow(model->NodeRef(), ++windowCount);
}
if (someWindowActivated) {
delete model;
return;
}
// If no window was activated (none in the current workspace),
// we open a new one.
if (openSelector == kRunOpenWithWindow) {
BMessage* refList = NULL;
if (originalRefsList == NULL) {
// when passing just a single model, stuff it's entry in a single
// element list anyway
ASSERT(model != NULL);
refList = new BMessage;
refList->AddRef("refs", model->EntryRef());
delete model;
model = NULL;
} else {
// clone the message, window adopts it for it's own use
refList = new BMessage(*originalRefsList);
}
window = new OpenWithContainerWindow(refList, &fWindowList);
} else if (model->IsQuery()) {
// window will adopt the model
window = new BQueryContainerWindow(&fWindowList, openFlags);
} else if (model->IsVirtualDirectory()) {
// window will adopt the model
window = new VirtualDirectoryWindow(&fWindowList, openFlags);
} else {
// window will adopt the model
window = new BContainerWindow(&fWindowList, openFlags);
}
if (model != NULL)
window->CreatePoseView(model);
BMessage restoreStateMessage(kRestoreState);
if (stateMessage != NULL)
restoreStateMessage.AddMessage("state", stateMessage);
window->PostMessage(&restoreStateMessage);
}