本文整理汇总了C++中BContainerWindow类的典型用法代码示例。如果您正苦于以下问题:C++ BContainerWindow类的具体用法?C++ BContainerWindow怎么用?C++ BContainerWindow使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BContainerWindow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BSlowMenu
BNavMenu::BNavMenu(const char *title, uint32 message, const BMessenger &messenger,
BWindow *parentWindow, const BObjectList<BString> *list)
: BSlowMenu(title),
fMessage(message),
fMessenger(messenger),
fParentWindow(parentWindow),
fFlags(0),
fItemList(0),
fContainer(0),
fTypesList(list)
{
InitIconPreloader();
SetFont(be_plain_font);
// add the parent window to the invocation message so that it
// can be closed if option modifier held down during invocation
BContainerWindow *originatingWindow = dynamic_cast<BContainerWindow *>(fParentWindow);
if (originatingWindow)
fMessage.AddData("nodeRefsToClose", B_RAW_TYPE,
originatingWindow->TargetModel()->NodeRef(), sizeof (node_ref));
// too long to have triggers
SetTriggersEnabled(false);
}
示例2:
void
BTitleView::MouseMoved(BPoint where, uint32 code, const BMessage* dragMessage)
{
BContainerWindow* window = dynamic_cast<BContainerWindow*>(Window());
if (window == NULL)
return;
if (fTrackingState != NULL) {
int32 buttons = 0;
if (Looper() != NULL && Looper()->CurrentMessage() != NULL)
Looper()->CurrentMessage()->FindInt32("buttons", &buttons);
fTrackingState->MouseMoved(where, buttons);
return;
}
switch (code) {
default:
if (InColumnResizeArea(where) && window->IsActive())
SetViewCursor(&fHorizontalResizeCursor);
else
SetViewCursor(B_CURSOR_SYSTEM_DEFAULT);
break;
case B_EXITED_VIEW:
SetViewCursor(B_CURSOR_SYSTEM_DEFAULT);
break;
}
_inherited::MouseMoved(where, code, dragMessage);
}
示例3: lock
bool
TTracker::CloseParentWaitingForChild(const entry_ref *child,
const node_ref *parent)
{
AutoLock<WindowList> lock(&fWindowList);
BContainerWindow *parentWindow = FindContainerWindow(parent);
if (!parentWindow)
// parent window already closed, give up
return true;
// If child is a symbolic link, dereference it, so that
// FindContainerWindow will succeed.
BEntry entry(child, true);
entry_ref resolvedChild;
if (entry.GetRef(&resolvedChild) != B_OK)
resolvedChild = *child;
BContainerWindow *window = FindContainerWindow(&resolvedChild);
if (window) {
AutoLock<BWindow> lock(window);
if (!window->IsHidden())
return CloseParentWindowCommon(parentWindow);
}
return false;
}
示例4: ASSERT
void
TTracker::MoveRefsToTrash(const BMessage *message)
{
int32 count;
uint32 type;
message->GetInfo("refs", &type, &count);
if (count <= 0)
return;
BObjectList<entry_ref> *srcList = new BObjectList<entry_ref>(count, true);
for (int32 index = 0; index < count; index++) {
entry_ref ref;
ASSERT(message->FindRef("refs", index, &ref) == B_OK);
if (message->FindRef("refs", index, &ref) != B_OK)
continue;
AutoLock<WindowList> lock(&fWindowList);
BContainerWindow *window = FindParentContainerWindow(&ref);
if (window)
// if we have a window open for this entry, ask the pose to
// delete it, this will select the next entry
window->PoseView()->MoveEntryToTrash(&ref);
else
// add all others to a list that gets deleted separately
srcList->AddItem(new entry_ref(ref));
}
if (srcList->CountItems())
// async move to trash
FSMoveToTrash(srcList);
}
示例5: 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);
}
}
}
示例6: TextViewFilter
static filter_result
TextViewFilter(BMessage* message, BHandler**, BMessageFilter* filter)
{
uchar key;
if (message->FindInt8("byte", (int8*)&key) != B_OK)
return B_DISPATCH_MESSAGE;
ThrowOnAssert(filter != NULL);
BContainerWindow* window = dynamic_cast<BContainerWindow*>(
filter->Looper());
ThrowOnAssert(window != NULL);
BPoseView* poseView = window->PoseView();
ThrowOnAssert(poseView != NULL);
if (key == B_RETURN || key == B_ESCAPE) {
poseView->CommitActivePose(key == B_RETURN);
return B_SKIP_MESSAGE;
}
if (key == B_TAB) {
if (poseView->ActivePose()) {
if (message->FindInt32("modifiers") & B_SHIFT_KEY)
poseView->ActivePose()->EditPreviousWidget(poseView);
else
poseView->ActivePose()->EditNextWidget(poseView);
}
return B_SKIP_MESSAGE;
}
// the BTextView doesn't respect window borders when resizing itself;
// we try to work-around this "bug" here.
// find the text editing view
BView* scrollView = poseView->FindView("BorderView");
if (scrollView != NULL) {
BTextView* textView = dynamic_cast<BTextView*>(
scrollView->FindView("WidgetTextView"));
if (textView != NULL) {
BRect rect = scrollView->Frame();
if (rect.right + 3 > poseView->Bounds().right
|| rect.left - 3 < 0)
textView->MakeResizable(true, NULL);
}
}
return B_DISPATCH_MESSAGE;
}
示例7: lock
void
TTracker::SaveAllPoseLocations()
{
int32 numWindows = fWindowList.CountItems();
for (int32 windowIndex = 0; windowIndex < numWindows; windowIndex++) {
BContainerWindow* window = dynamic_cast<BContainerWindow*>(
fWindowList.ItemAt(windowIndex));
if (window != NULL) {
AutoLock<BWindow> lock(window);
BDeskWindow* deskWindow = dynamic_cast<BDeskWindow*>(window);
if (deskWindow != NULL)
deskWindow->SaveDesktopPoseLocations();
else
window->PoseView()->SavePoseLocations();
}
}
}
示例8: entry
BContainerWindow *
TTracker::FindParentContainerWindow(const entry_ref *ref) const
{
BEntry entry(ref);
BEntry parent;
if (entry.GetParent(&parent) != B_OK)
return NULL;
entry_ref parentRef;
parent.GetRef(&parentRef);
ASSERT(fWindowList.IsLocked());
int32 count = fWindowList.CountItems();
for (int32 index = 0; index < count; index++) {
BContainerWindow *window = dynamic_cast<BContainerWindow *>
(fWindowList.ItemAt(index));
if (window && window->IsShowing(&parentRef))
return window;
}
return NULL;
}
示例9: 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);
}
示例10: 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);
}
}
示例11: Window
void
BTitleView::MouseDown(BPoint where)
{
if (!Window()->IsActive()) {
// wasn't active, just activate and bail
Window()->Activate();
return;
}
// finish any pending edits
fPoseView->CommitActivePose();
BColumnTitle *title = FindColumnTitle(where);
BColumnTitle *resizedTitle = InColumnResizeArea(where);
uint32 buttons;
GetMouse(&where, &buttons);
// Check if the user clicked the secondary mouse button.
// if so, display the attribute menu:
if (buttons & B_SECONDARY_MOUSE_BUTTON) {
BContainerWindow *window = dynamic_cast<BContainerWindow *>
(Window());
BPopUpMenu *menu = new BPopUpMenu("Attributes", false, false);
menu->SetFont(be_plain_font);
window->NewAttributeMenu(menu);
window->AddMimeTypesToMenu(menu);
window->MarkAttributeMenu(menu);
menu->SetTargetForItems(window->PoseView());
menu->Go(ConvertToScreen(where), true, false);
return;
}
bigtime_t doubleClickSpeed;
get_click_speed(&doubleClickSpeed);
if (resizedTitle) {
bool force = static_cast<bool>(buttons & B_TERTIARY_MOUSE_BUTTON);
if (force || buttons & B_PRIMARY_MOUSE_BUTTON) {
if (force || fPreviouslyClickedColumnTitle != 0) {
if (force || system_time() - fPreviousLeftClickTime < doubleClickSpeed) {
if (fPoseView->ResizeColumnToWidest(resizedTitle->Column())) {
Invalidate();
return;
}
}
}
fPreviousLeftClickTime = system_time();
fPreviouslyClickedColumnTitle = resizedTitle;
}
} else if (!title)
return;
SetMouseEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY | B_LOCK_WINDOW_FOCUS);
// track the mouse
if (resizedTitle) {
fTrackingState = new ColumnResizeState(this, resizedTitle, where,
system_time() + doubleClickSpeed);
} else {
fTrackingState = new ColumnDragState(this, title, where,
system_time() + doubleClickSpeed);
}
}
示例12: BApplication
TTracker::TTracker()
:
BApplication(kTrackerSignature),
fMimeTypeList(NULL),
fClipboardRefsWatcher(NULL),
fTrashWatcher(NULL),
fTaskLoop(NULL),
fNodeMonitorCount(-1),
fWatchingInterface(new WatchingInterface),
fSettingsWindow(NULL)
{
BPathMonitor::SetWatchingInterface(fWatchingInterface);
// set the cwd to /boot/home, anything that's launched
// from Tracker will automatically inherit this
BPath homePath;
if (find_directory(B_USER_DIRECTORY, &homePath) == B_OK)
chdir(homePath.Path());
// ask for a bunch more file descriptors so that nested copying works well
struct rlimit rl;
rl.rlim_cur = 512;
rl.rlim_max = RLIM_SAVED_MAX;
setrlimit(RLIMIT_NOFILE, &rl);
fNodeMonitorCount = DEFAULT_MON_NUM;
gLocalizedNamePreferred
= BLocaleRoster::Default()->IsFilesystemTranslationPreferred();
#ifdef CHECK_OPEN_MODEL_LEAKS
InitOpenModelDumping();
#endif
InitIconPreloader();
#ifdef LEAK_CHECKING
SetNewLeakChecking(true);
SetMallocLeakChecking(true);
#endif
// This is how often it should update the free space bar on the
// volume icons
SetPulseRate(1000000);
gLaunchLooper = new LaunchLooper();
gLaunchLooper->Run();
// 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;
}
}
示例13: DEBUG_ONLY
bool
TTracker::QuitRequested()
{
// don't allow user quitting
if (CurrentMessage() && CurrentMessage()->FindBool("shortcut"))
return false;
gStatusWindow->AttemptToQuit();
// try quitting the copy/move/empty trash threads
BVolume bootVolume;
DEBUG_ONLY(status_t err =) BVolumeRoster().GetBootVolume(&bootVolume);
ASSERT(err == B_OK);
BMessage message;
AutoLock<WindowList> lock(&fWindowList);
// save open windows in a message inside an attribute of the desktop
int32 count = fWindowList.CountItems();
for (int32 i = 0; i < count; i++) {
BContainerWindow *window = dynamic_cast<BContainerWindow *>
(fWindowList.ItemAt(i));
if (window && window->TargetModel() && !window->PoseView()->IsDesktopWindow()) {
if (window->TargetModel()->IsRoot())
message.AddBool("open_disks_window", true);
else {
BEntry entry;
BPath path;
const entry_ref *ref = window->TargetModel()->EntryRef();
if (entry.SetTo(ref) == B_OK && entry.GetPath(&path) == B_OK) {
int8 flags = window->IsMinimized() ? kOpenWindowMinimized : kOpenWindowNoFlags;
uint32 deviceFlags = GetVolumeFlags(window->TargetModel());
// save state for every window which is
// a) already open on another workspace
// b) on a volume not capable of writing attributes
if (window != FindContainerWindow(ref)
|| (deviceFlags & (B_FS_HAS_ATTR | B_FS_IS_READONLY)) != B_FS_HAS_ATTR) {
BMessage stateMessage;
window->SaveState(stateMessage);
window->SetSaveStateEnabled(false);
// This is to prevent its state to be saved to the node when closed.
message.AddMessage("window state", &stateMessage);
flags |= kOpenWindowHasState;
}
const char *target;
bool pathAlreadyExists = false;
for (int32 index = 0;message.FindString("paths", index, &target) == B_OK;index++) {
if (!strcmp(target,path.Path())) {
pathAlreadyExists = true;
break;
}
}
if (!pathAlreadyExists)
message.AddString("paths", path.Path());
message.AddInt8(path.Path(), flags);
}
}
}
}
lock.Unlock();
// write windows to open on disk
BDirectory deskDir;
if (!BootedInSafeMode() && FSGetDeskDir(&deskDir, bootVolume.Device()) == B_OK) {
// if message is empty, delete the corresponding attribute
if (message.CountNames(B_ANY_TYPE)) {
size_t size = (size_t)message.FlattenedSize();
char *buffer = new char[size];
message.Flatten(buffer, (ssize_t)size);
deskDir.WriteAttr(kAttrOpenWindows, B_MESSAGE_TYPE, 0, buffer, size);
delete [] buffer;
} else
deskDir.RemoveAttr(kAttrOpenWindows);
}
for (int32 count = 0; count == 50; count++) {
// wait 5 seconds for the copiing/moving to quit
if (gStatusWindow->AttemptToQuit())
break;
snooze(100000);
}
return _inherited::QuitRequested();
}
示例14: GetFont
void
OpenWithMenu::DoneBuildingItemList()
{
// sort by app name
fSupportingAppList->SortItems(SortByRelationAndName, this);
// check if each app is unique
bool isUnique = true;
int32 count = fSupportingAppList->CountItems();
for (int32 index = 0; index < count - 1; index++) {
// the list is sorted, just compare two adjacent models
if (strcmp(fSupportingAppList->ItemAt(index)->fModel->Name(),
fSupportingAppList->ItemAt(index + 1)->fModel->Name()) == 0) {
isUnique = false;
break;
}
}
// add apps as menu items
BFont font;
GetFont(&font);
int32 lastRelation = -1;
for (int32 index = 0; index < count ; index++) {
RelationCachingModelProxy* modelProxy
= fSupportingAppList->ItemAt(index);
Model* model = modelProxy->fModel;
BMessage* message = new BMessage(fEntriesToOpen);
message->AddRef("handler", model->EntryRef());
BContainerWindow* window
= dynamic_cast<BContainerWindow*>(fParentWindow);
if (window != NULL) {
message->AddData("nodeRefsToClose", B_RAW_TYPE,
window->TargetModel()->NodeRef(), sizeof(node_ref));
}
BString result;
if (isUnique) {
// just use the app name
result = model->Name();
} else {
// get a truncated full path
BPath path;
BEntry entry(model->EntryRef());
if (entry.GetPath(&path) != B_OK) {
PRINT(("stale entry ref %s\n", model->Name()));
delete message;
continue;
}
result = path.Path();
font.TruncateString(&result, B_TRUNCATE_MIDDLE, kMaxMenuWidth);
}
#if DEBUG
BString relationDescription;
fIterator->RelationDescription(&fEntriesToOpen, model, &relationDescription);
result += " (";
result += relationDescription;
result += ")";
#endif
// divide different relations of opening with a separator
int32 relation = modelProxy->Relation(fIterator, &fEntriesToOpen);
if (lastRelation != -1 && relation != lastRelation)
AddSeparatorItem();
lastRelation = relation;
ModelMenuItem* item = new ModelMenuItem(model, result.String(),
message);
AddItem(item);
// mark item if it represents the preferred app
if (fHaveCommonPreferredApp && *(model->EntryRef()) == fPreferredRef) {
//PRINT(("marking item for % as preferred", model->Name()));
item->SetMarked(true);
}
}
// target the menu
if (target != NULL)
SetTargetForItems(target);
else
SetTargetForItems(fMessenger);
if (CountItems() == 0) {
BMenuItem* item = new BMenuItem(B_TRANSLATE("no supporting apps"), 0);
item->SetEnabled(false);
AddItem(item);
}
}
示例15: BStatusWindow
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();
}
}