void TeamsWindow::_Init() { BMessage settings; _LoadSettings(settings); BRect frame; if (settings.FindRect("teams window frame", &frame) == B_OK) { MoveTo(frame.LeftTop()); ResizeTo(frame.Width(), frame.Height()); } BMenu* connectionMenu = new BMenu("Connection"); ObjectDeleter<BMenu> menuDeleter(connectionMenu); connectionMenu->SetLabelFromMarked(true); TargetHostInterfaceRoster* roster = TargetHostInterfaceRoster::Default(); for (int32 i = 0; i < roster->CountActiveInterfaces(); i++) { TargetHostInterface* interface = roster->ActiveInterfaceAt(i); BMenuItem* item = new BMenuItem(interface->GetTargetHost()->Name(), new BMessage(MSG_SWITCH_TARGET_CONNECTION)); if (item->Message()->AddPointer("interface", interface) != B_OK) { delete item; throw std::bad_alloc(); } if (interface->IsLocal()) { item->SetMarked(true); fTargetHostInterface = interface; } connectionMenu->AddItem(item); } BGroupLayout* connectionLayout = NULL; BLayoutBuilder::Group<>(this, B_VERTICAL) .AddGroup(B_HORIZONTAL) .SetInsets(B_USE_DEFAULT_SPACING) .GetLayout(&connectionLayout) .Add(fConnectionField = new BMenuField("Connected to:", connectionMenu)) .AddGlue() .Add(fCreateConnectionButton = new BButton("Create new connection" B_UTF8_ELLIPSIS, new BMessage( MSG_SHOW_CONNECTION_CONFIG_WINDOW))) .End() .Add(fTeamsListView = new TeamsListView("TeamsList")) .SetInsets(1.0f, 1.0f, 1.0f, 5.0f) .AddGroup(B_HORIZONTAL) .SetInsets(B_USE_DEFAULT_SPACING) .Add(fAttachTeamButton = new BButton("Attach", new BMessage( MSG_DEBUG_THIS_TEAM))) .AddGlue() .Add(fCreateTeamButton = new BButton("Start new team" B_UTF8_ELLIPSIS, new BMessage(MSG_SHOW_START_TEAM_WINDOW))) .Add(fLoadCoreButton = new BButton("Load core" B_UTF8_ELLIPSIS, new BMessage(MSG_LOAD_CORE_TEAM))) .End() .End(); connectionLayout->SetVisible(false); menuDeleter.Detach(); AddListener(fTeamsListView); connectionMenu->SetTargetForItems(this); fTeamsListView->SetInvocationMessage(new BMessage(MSG_DEBUG_THIS_TEAM)); fTeamsListView->SetSelectionMessage(new BMessage( MSG_TEAM_SELECTION_CHANGED)); fAttachTeamButton->SetEnabled(false); fCreateTeamButton->SetTarget(this); fLoadCoreButton->SetTarget(this); fCreateConnectionButton->SetTarget(be_app); _NotifySelectedInterfaceChanged(fTargetHostInterface); }
void MemoryView::_HandleContextMenu(BPoint point) { int32 offset = _GetOffsetAt(point); if (offset < fSelectionStart || offset > fSelectionEnd) return; BPopUpMenu* menu = new(std::nothrow) BPopUpMenu("Options"); if (menu == NULL) return; ObjectDeleter<BPopUpMenu> menuDeleter(menu); ObjectDeleter<BMenuItem> itemDeleter; ObjectDeleter<BMessage> messageDeleter; BMessage* message = NULL; BMenuItem* item = NULL; if (fSelectionEnd - fSelectionStart == fTargetAddressSize / 2) { BMessage* message = new(std::nothrow) BMessage(MSG_INSPECT_ADDRESS); if (message == NULL) return; target_addr_t address; if (fTargetAddressSize == 8) address = *((uint32*)(fTargetBlock->Data() + fSelectionStart)); else address = *((uint64*)(fTargetBlock->Data() + fSelectionStart)); if (fCurrentEndianMode == EndianModeBigEndian) address = B_HOST_TO_BENDIAN_INT64(address); else address = B_HOST_TO_LENDIAN_INT64(address); messageDeleter.SetTo(message); message->AddUInt64("address", address); BMenuItem* item = new(std::nothrow) BMenuItem("Inspect", message); if (item == NULL) return; messageDeleter.Detach(); itemDeleter.SetTo(item); if (!menu->AddItem(item)) return; item->SetTarget(Looper()); itemDeleter.Detach(); } message = new(std::nothrow) BMessage(B_COPY); if (message == NULL) return; messageDeleter.SetTo(message); item = new(std::nothrow) BMenuItem("Copy", message); if (item == NULL) return; messageDeleter.Detach(); itemDeleter.SetTo(item); if (!menu->AddItem(item)) return; item->SetTarget(this); itemDeleter.Detach(); menuDeleter.Detach(); BPoint screenWhere(point); ConvertToScreen(&screenWhere); BRect mouseRect(screenWhere, screenWhere); mouseRect.InsetBy(-4.0, -4.0); menu->Go(screenWhere, true, false, mouseRect, true); }
void TeamWindow::_HandleLocateSourceRequest(BStringList* entries) { if (fActiveFunction == NULL) return; else if (fActiveFunction->GetFunctionDebugInfo()->SourceFile() == NULL) return; else if (fActiveSourceCode == NULL) return; else if (fActiveSourceCode->GetSourceFile() != NULL) return; else if (fActiveFunction->GetFunction()->SourceCodeState() == FUNCTION_SOURCE_NOT_LOADED) { return; } if (entries == NULL) { if (fActiveSourceWorker < 0) { fActiveSourceWorker = spawn_thread(&_RetrieveMatchingSourceWorker, "source file query worker", B_NORMAL_PRIORITY, this); if (fActiveSourceWorker > 0) resume_thread(fActiveSourceWorker); } return; } int32 count = entries->CountStrings(); if (count > 0) { BPopUpMenu* menu = new(std::nothrow) BPopUpMenu(""); if (menu == NULL) return; BPrivate::ObjectDeleter<BPopUpMenu> menuDeleter(menu); BMenuItem* item = NULL; for (int32 i = 0; i < count; i++) { item = new(std::nothrow) BMenuItem(entries->StringAt(i).String(), NULL); if (item == NULL || !menu->AddItem(item)) { delete item; return; } } menu->AddSeparatorItem(); BMenuItem* manualItem = new(std::nothrow) BMenuItem( "Locate manually" B_UTF8_ELLIPSIS, NULL); if (manualItem == NULL || !menu->AddItem(manualItem)) { delete manualItem; return; } BPoint point; fSourcePathView->GetMouse(&point, NULL, false); fSourcePathView->ConvertToScreen(&point); item = menu->Go(point, false, true); if (item == NULL) return; else if (item != manualItem) { // if the user picks to locate the entry manually, // then fall through to the usual file panel logic // as if we'd found no matches at all. entry_ref ref; if (get_ref_for_path(item->Label(), &ref) == B_OK) { _HandleResolveMissingSourceFile(ref); return; } } } try { if (fFilePanel == NULL) { fFilePanel = new BFilePanel(B_OPEN_PANEL, new BMessenger(this)); } fFilePanel->Show(); } catch (...) { delete fFilePanel; fFilePanel = NULL; } }