//! Track the mouse without blocking the window void CPUButton::MouseDown(BPoint point) { BPoint mousePosition; uint32 mouseButtons; GetMouse(&mousePosition, &mouseButtons); if ((B_PRIMARY_MOUSE_BUTTON & mouseButtons) != 0) { SetValue(!Value()); SetTracking(true); SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS); } else if ((B_SECONDARY_MOUSE_BUTTON & mouseButtons) != 0 && fReplicantInDeskbar) { BPopUpMenu *menu = new BPopUpMenu(B_TRANSLATE("Deskbar menu")); menu->AddItem(new BMenuItem(B_TRANSLATE("About Pulse" B_UTF8_ELLIPSIS), new BMessage(B_ABOUT_REQUESTED))); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("Remove replicant"), new BMessage(kDeleteReplicant))); menu->SetTargetForItems(this); ConvertToScreen(&point); menu->Go(point, true, true, true); } }
// MouseDown void OptionValueView::MouseDown(BPoint where) { if (BView* parent = Parent()) parent->MouseDown(ConvertToParent(where)); if (fProperty) { BPopUpMenu* menu = new BPopUpMenu("option popup", false, false); BString name; int32 id; for (int32 i = 0; fProperty->GetOption(i, &name, &id); i++) { BMessage* message = new BMessage(MSG_OPTION_CHANGED); message->AddInt32("id", id); BMenuItem* item = new BMenuItem(name.String(), message); menu->AddItem(item); if (id == fProperty->CurrentOptionID()) item->SetMarked(true); } menu->SetTargetForItems(this); menu->SetAsyncAutoDestruct(true); menu->SetFont(be_plain_font); menu->SetEnabled(fEnabled); where = ConvertToScreen(where); BRect mouseRect(where, where); mouseRect.InsetBy(-10.0, -10.0); where += BPoint(5.0, 5.0); menu->Go(where, true, false, mouseRect, true); } }
void PowerStatusReplicant::MouseDown(BPoint point) { BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING, false, false); menu->SetFont(be_plain_font); BMenuItem* item; menu->AddItem(item = new BMenuItem(B_TRANSLATE("Show text label"), new BMessage(kMsgToggleLabel))); if (fShowLabel) item->SetMarked(true); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Show status icon"), new BMessage(kMsgToggleStatusIcon))); if (fShowStatusIcon) item->SetMarked(true); menu->AddItem(new BMenuItem(!fShowTime ? B_TRANSLATE("Show time") : B_TRANSLATE("Show percent"), new BMessage(kMsgToggleTime))); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("Battery info" B_UTF8_ELLIPSIS), new BMessage(kMsgToggleExtInfo))); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("About" B_UTF8_ELLIPSIS), new BMessage(B_ABOUT_REQUESTED))); menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"), new BMessage(B_QUIT_REQUESTED))); menu->SetTargetForItems(this); ConvertToScreen(&point); menu->Go(point, true, false, true); }
void StatusItem::GeneratePopUp(BPoint point, BRect openrect) { BString str(value); str.Append(" "); BString url; URLCrunch crunch(str.String(), str.Length()); BPopUpMenu* menu = new BPopUpMenu("URLs"); BMessage msg(M_LOAD_URL); BMessage* allocmsg(NULL); BMenuItem* item(NULL); while (crunch.Crunch(&url) != B_ERROR) { allocmsg = new BMessage(msg); allocmsg->AddString("url", url.String()); item = new BMenuItem(url.String(), allocmsg); menu->AddItem(item); allocmsg = NULL; } if (menu->CountItems() > 0) { menu->SetTargetForItems(be_app); menu->SetAsyncAutoDestruct(true); menu->Go(point, true, true, openrect, true); } else { delete menu; } }
void MediaJack::showContextMenu( BPoint point) { D_METHOD(("MediaJack::showContextMenu()\n")); BPopUpMenu *menu = new BPopUpMenu("MediaJack PopUp", false, false, B_ITEMS_IN_COLUMN); menu->SetFont(be_plain_font); BMenuItem *item; // add the "Get Info" item if (isInput()) { media_input input; getInput(&input); BMessage *message = new BMessage(InfoWindowManager::M_INFO_WINDOW_REQUESTED); message->AddData("input", B_RAW_TYPE, reinterpret_cast<const void *>(&input), sizeof(input)); menu->AddItem(item = new BMenuItem("Get info", message)); } else if (isOutput()) { media_output output; getOutput(&output); BMessage *message = new BMessage(InfoWindowManager::M_INFO_WINDOW_REQUESTED); message->AddData("output", B_RAW_TYPE, reinterpret_cast<const void *>(&output), sizeof(output)); menu->AddItem(item = new BMenuItem("Get info", message)); } menu->SetTargetForItems(view()); view()->ConvertToScreen(&point); point -= BPoint(1.0, 1.0); menu->Go(point, true, true, true); }
void JobSetupView::AddPopUpMenu(const DriverSpecificCap* capability, BGridLayout* gridLayout, int& row) { const char* label = capability->fLabel.c_str(); BPopUpMenu* popUpMenu = new BPopUpMenu(label); popUpMenu->SetRadioMode(true); PrinterCap::CapID category = static_cast<PrinterCap::CapID>( capability->ID()); const BaseCap** categoryCapabilities = fPrinterCap->GetCaps(category); int categoryCount = fPrinterCap->CountCap(category); string value = GetDriverSpecificValue(category, capability->Key()); PrinterCap::KeyPredicate predicate(value.c_str()); FillCapabilityMenu(popUpMenu, kMsgNone, categoryCapabilities, categoryCount, predicate); BString menuLabel = label; menuLabel << ":"; BMenuField* menuField = new BMenuField(label, menuLabel.String(), popUpMenu); popUpMenu->SetTargetForItems(this); gridLayout->AddItem(menuField->CreateLabelLayoutItem(), 0, row); gridLayout->AddItem(menuField->CreateMenuBarLayoutItem(), 1, row); row ++; fDriverSpecificPopUpMenus[category] = popUpMenu; }
void TTimeView::ShowTimeOptions(BPoint point) { BPopUpMenu* menu = new BPopUpMenu("", false, false); menu->SetFont(be_plain_font); BMenuItem* item; item = new BMenuItem(B_TRANSLATE("Time preferences" B_UTF8_ELLIPSIS), new BMessage(kChangeTime)); menu->AddItem(item); item = new BMenuItem(B_TRANSLATE("Hide time"), new BMessage(kShowHideTime)); menu->AddItem(item); item = new BMenuItem(B_TRANSLATE("Show calendar" B_UTF8_ELLIPSIS), new BMessage(kShowCalendar)); menu->AddItem(item); menu->SetTargetForItems(this); // Changed to accept screen coord system point; // not constrained to this view now menu->Go(point, true, true, BRect(point.x - 4, point.y - 4, point.x + 4, point.y +4), true); }
void StatusView::MouseDown(BPoint where) { if (!fReadOnly) return; float left = fCellWidth[kPositionCell] + fCellWidth[kEncodingCell]; if (where.x < left) return; int32 clicks = 0; BMessage* message = Window()->CurrentMessage(); if (message != NULL && message->FindInt32("clicks", &clicks) == B_OK && clicks > 1) return; BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING, false, false); menu->AddItem(new BMenuItem(B_TRANSLATE("Unlock file"), new BMessage(UNLOCK_FILE))); where.x = left; where.y = Bounds().bottom; ConvertToScreen(&where); menu->SetTargetForItems(this); menu->Go(where, true, true, true); }
// ShowContextMenu bool PathManipulator::ShowContextMenu(BPoint where) { // Change the selection to the current point if it isn't currently // selected. This could will only be chosen if the user right-clicked // a path point directly. if (fCurrentPathPoint >= 0 && !fSelection->Contains(fCurrentPathPoint)) { fSelection->MakeEmpty(); _UpdateSelection(); *fOldSelection = *fSelection; _Select(fCurrentPathPoint, false); } BPopUpMenu* menu = new BPopUpMenu("context menu", false, false); BMessage* message; BMenuItem* item; bool hasSelection = fSelection->CountItems() > 0; if (fCurrentPathPoint < 0) { message = new BMessage(B_SELECT_ALL); item = new BMenuItem("Select All", message, 'A'); menu->AddItem(item); menu->AddSeparatorItem(); } message = new BMessage(MSG_TRANSFORM); item = new BMenuItem("Transform", message, 'T'); item->SetEnabled(hasSelection); menu->AddItem(item); message = new BMessage(MSG_SPLIT_POINTS); item = new BMenuItem("Split", message); item->SetEnabled(hasSelection); menu->AddItem(item); message = new BMessage(MSG_FLIP_POINTS); item = new BMenuItem("Flip", message); item->SetEnabled(hasSelection); menu->AddItem(item); message = new BMessage(MSG_REMOVE_POINTS); item = new BMenuItem("Remove", message); item->SetEnabled(hasSelection); menu->AddItem(item); // go menu->SetTargetForItems(fCanvasView); menu->SetAsyncAutoDestruct(true); menu->SetFont(be_plain_font); where = fCanvasView->ConvertToScreen(where); BRect mouseRect(where, where); mouseRect.InsetBy(-10.0, -10.0); where += BPoint(5.0, 5.0); menu->Go(where, true, false, mouseRect, true); return true; }
void IconView::MouseDown(BPoint where) { if (!IsEnabled()) return; int32 buttons = B_PRIMARY_MOUSE_BUTTON; int32 clicks = 1; if (Looper() != NULL && Looper()->CurrentMessage() != NULL) { if (Looper()->CurrentMessage()->FindInt32("buttons", &buttons) != B_OK) buttons = B_PRIMARY_MOUSE_BUTTON; if (Looper()->CurrentMessage()->FindInt32("clicks", &clicks) != B_OK) clicks = 1; } if ((buttons & B_PRIMARY_MOUSE_BUTTON) != 0 && BitmapRect().Contains(where)) { if (clicks == 2) { // double click - open Icon-O-Matic Invoke(); } else if (fIcon != NULL) { // start tracking - this icon might be dragged around fDragPoint = where; fTracking = true; SetMouseEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY); } } if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) { // show context menu ConvertToScreen(&where); BPopUpMenu* menu = new BPopUpMenu("context"); menu->SetFont(be_plain_font); bool hasIcon = fHasType ? fSource == kOwnIcon : fIcon != NULL; if (hasIcon) { menu->AddItem(new BMenuItem( B_TRANSLATE("Edit icon" B_UTF8_ELLIPSIS), new BMessage(kMsgEditIcon))); } else { menu->AddItem(new BMenuItem( B_TRANSLATE("Add icon" B_UTF8_ELLIPSIS), new BMessage(kMsgAddIcon))); } BMenuItem* item = new BMenuItem( B_TRANSLATE("Remove icon"), new BMessage(kMsgRemoveIcon)); if (!hasIcon) item->SetEnabled(false); menu->AddItem(item); menu->SetTargetForItems(fTarget); menu->Go(where, true, false, true); } }
MainWindow::MainWindow() : BWindow(BRect(0, 0, 300, 400), "Caya", B_TITLED_WINDOW, 0), fWorkspaceChanged(false) { fStatusView = new StatusView("statusView"); SearchBarTextControl* searchBox = new SearchBarTextControl(new BMessage(kSearchContact)); fListView = new RosterListView("buddyView"); fListView->SetInvocationMessage(new BMessage(CAYA_OPEN_CHAT_WINDOW)); BScrollView* scrollView = new BScrollView("scrollview", fListView, B_WILL_DRAW, false, true); // Wrench menu BPopUpMenu* wrenchMenu = new BPopUpMenu("Wrench"); (void)wrenchMenu->AddItem(new BMenuItem("About" B_UTF8_ELLIPSIS, new BMessage(B_ABOUT_REQUESTED))); (void)wrenchMenu->AddItem(new BSeparatorItem()); (void)wrenchMenu->AddItem(new BMenuItem("Preferences" B_UTF8_ELLIPSIS, new BMessage(CAYA_SHOW_SETTINGS))); (void)wrenchMenu->AddItem(new BSeparatorItem()); (void)wrenchMenu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED))); wrenchMenu->SetTargetForItems(this); // Tool icon BResources* res = CayaResources(); BBitmap* toolIcon = IconFromResources(res, kToolIcon); delete res; // Wrench tool button ToolButton* wrench = new ToolButton(NULL, NULL); wrench->SetBitmap(toolIcon); wrench->SetMenu(wrenchMenu); SetLayout(new BGridLayout(1, 2)); AddChild(BGridLayoutBuilder(1, 2) .Add(searchBox, 0, 0) .Add(wrench, 1, 0) .Add(scrollView, 0, 1, 2) .Add(fStatusView, 0, 2, 2) .SetInsets(5, 5, 5, 10) ); AddShortcut('a', B_COMMAND_KEY, new BMessage(B_ABOUT_REQUESTED)); MoveTo(BAlert::AlertPosition(Bounds().Width(), Bounds().Height() / 2)); // Filter messages using Server fServer = new Server(); AddFilter(fServer); CenterOnScreen(); //TODO check for errors here ReplicantStatusView::InstallReplicant(); }
// DisplayPopupMenu bool SplitManipulator::DisplayPopupMenu(BPoint where) { BPopUpMenu* menu = new BPopUpMenu("item popup", false, false); BMessage* message; BMenuItem* item; bool separator = false; if (fItem->HasVideo()) { message = new BMessage(MSG_SET_VIDEO_MUTED); message->AddPointer("item", fItem); item = new BMenuItem("Enabled Video", message); item->SetMarked(!fItem->IsVideoMuted()); menu->AddItem(item); separator = true; } if (fItem->HasAudio()) { message = new BMessage(MSG_SET_AUDIO_MUTED); message->AddPointer("item", fItem); item = new BMenuItem("Enabled Audio", message); item->SetMarked(!fItem->IsAudioMuted()); menu->AddItem(item); separator = true; } if (separator) menu->AddSeparatorItem(); BMenuItem* selectClipItem = NULL; if (ClipPlaylistItem* clipItem = dynamic_cast<ClipPlaylistItem*>(fItem)) { message = new BMessage(MSG_SELECT_AND_SHOW_CLIP); message->AddPointer("clip", clipItem->Clip()); selectClipItem = new BMenuItem("Select Clip", message); menu->AddItem(selectClipItem); } else separator = false; if (separator) menu->AddSeparatorItem(); message = new BMessage(MSG_REMOVE_ITEM); message->AddPointer("item", fItem); item = new BMenuItem("Remove Clip", message); menu->AddItem(item); menu->SetTargetForItems(fView); if (selectClipItem) selectClipItem->SetTarget(fView->Window()); show_popup_menu(menu, where, fView, false); return true; }
void URLInputGroup::URLTextView::MouseDown(BPoint where) { bool wasFocus = IsFocus(); if (!wasFocus) MakeFocus(true); int32 buttons; if (Window()->CurrentMessage()->FindInt32("buttons", &buttons) != B_OK) buttons = B_PRIMARY_MOUSE_BUTTON; if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) { // Display context menu int32 selectionStart; int32 selectionEnd; GetSelection(&selectionStart, &selectionEnd); bool canCutOrCopy = selectionEnd > selectionStart; bool canPaste = false; if (be_clipboard->Lock()) { if (BMessage* data = be_clipboard->Data()) canPaste = data->HasData("text/plain", B_MIME_TYPE); be_clipboard->Unlock(); } BMenuItem* cutItem = new BMenuItem(B_TRANSLATE("Cut"), new BMessage(B_CUT)); BMenuItem* copyItem = new BMenuItem(B_TRANSLATE("Copy"), new BMessage(B_COPY)); BMenuItem* pasteItem = new BMenuItem(B_TRANSLATE("Paste"), new BMessage(B_PASTE)); BMenuItem* clearItem = new BMenuItem(B_TRANSLATE("Clear"), new BMessage(MSG_CLEAR)); cutItem->SetEnabled(canCutOrCopy); copyItem->SetEnabled(canCutOrCopy); pasteItem->SetEnabled(canPaste); clearItem->SetEnabled(strlen(Text()) > 0); BPopUpMenu* menu = new BPopUpMenu("url context"); menu->AddItem(cutItem); menu->AddItem(copyItem); menu->AddItem(pasteItem); menu->AddItem(clearItem); menu->SetTargetForItems(this); menu->Go(ConvertToScreen(where), true, true, true); return; } // Only pass through to base class if we already have focus. if (!wasFocus) return; BTextView::MouseDown(where); }
void MediaReplicant::MouseDown(BPoint point) { int32 buttons = B_PRIMARY_MOUSE_BUTTON; if (Looper() != NULL && Looper()->CurrentMessage() != NULL) Looper()->CurrentMessage()->FindInt32("buttons", &buttons); BPoint where = ConvertToScreen(point); if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) { BPopUpMenu* menu = new BPopUpMenu("", false, false); menu->SetFont(be_plain_font); menu->AddItem(new BMenuItem( B_TRANSLATE("Media preferences" B_UTF8_ELLIPSIS), new BMessage(kMsgOpenMediaSettings))); menu->AddItem(new BMenuItem( B_TRANSLATE("Sound preferences" B_UTF8_ELLIPSIS), new BMessage(kMsgOpenSoundSettings))); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("Open MediaPlayer"), new BMessage(kMsgOpenMediaPlayer))); menu->AddSeparatorItem(); BMenu* subMenu = new BMenu(B_TRANSLATE("Options")); menu->AddItem(subMenu); BMenuItem* item = new BMenuItem(B_TRANSLATE("Control physical output"), new BMessage(kMsgVolumeWhich)); item->SetMarked(fVolumeWhich == VOLUME_USE_PHYS_OUTPUT); subMenu->AddItem(item); item = new BMenuItem(B_TRANSLATE("Beep"), new BMessage(kMsgToggleBeep)); item->SetMarked(!fDontBeep); subMenu->AddItem(item); menu->SetTargetForItems(this); subMenu->SetTargetForItems(this); menu->Go(where, true, true, BRect(where - BPoint(4, 4), where + BPoint(4, 4))); } else { // Show VolumeWindow fVolumeSlider = new VolumeWindow(BRect(where.x, where.y, where.x + 207, where.y + 19), fDontBeep, fVolumeWhich); fVolumeSlider->Show(); } }
void NetPulseView::MouseDown(BPoint where) { int32 buttons; int32 clicks; if (Window()->CurrentMessage()->FindInt32("buttons", &buttons) != B_OK || Window()->CurrentMessage()->FindInt32("clicks", &clicks) != B_OK) { return; } if (buttons == B_SECONDARY_MOUSE_BUTTON) { BPopUpMenu* popUpMenu = new BPopUpMenu("NetPulseMenu"); popUpMenu->AddItem(new BMenuItem("Connect", new BMessage(kMsgConnect))); popUpMenu->AddItem(new BMenuItem("Disconnect", new BMessage(kMsgDisconnect))); popUpMenu->AddSeparatorItem(); popUpMenu->AddItem(new BMenuItem("Statistics...", new BMessage(kMsgStatistics))); popUpMenu->AddSeparatorItem(); uint32 cookie = 0; BNetworkInterface interface; BNetworkRoster& roster = BNetworkRoster::Default(); while (roster.GetNextInterface(&cookie, interface) == B_OK) { const char* name = interface.Name(); if (strncmp(name, "loop", 4) != 0) { BMenuItem* menuItem = new BMenuItem(name, new BMessage(kMsgChangeInterface + cookie)); menuItem->SetMarked(cookie == fCookie); popUpMenu->AddItem(menuItem); } } popUpMenu->AddSeparatorItem(); popUpMenu->AddItem(new BMenuItem("Quit", new BMessage(kMsgQuit))); popUpMenu->SetTargetForItems(this); popUpMenu->FindItem(kMsgConnect)->SetEnabled(!fEnable && fCookie != 0); popUpMenu->FindItem(kMsgDisconnect)->SetEnabled(fEnable && fCookie != 0); popUpMenu->FindItem(kMsgStatistics)->SetEnabled(fEnable && fCookie != 0); popUpMenu->Go(ConvertToScreen(BPoint(0, 0)), true, false, false); delete popUpMenu; } else if (buttons == B_PRIMARY_MOUSE_BUTTON && clicks == 2) be_roster->Launch("application/x-vnd.Haiku-Network"); }
void DownloadProgressView::ShowContextMenu(BPoint screenWhere) { screenWhere += BPoint(2, 2); BPopUpMenu* contextMenu = new BPopUpMenu("download context"); BMenuItem* copyURL = new BMenuItem("Copy URL to clipboard", new BMessage(COPY_URL_TO_CLIPBOARD)); copyURL->SetEnabled(fURL.Length() > 0); contextMenu->AddItem(copyURL); BMenuItem* openFolder = new BMenuItem("Open containing folder", new BMessage(OPEN_CONTAINING_FOLDER)); contextMenu->AddItem(openFolder); contextMenu->SetTargetForItems(this); contextMenu->Go(screenWhere, true, true, true); }
void WatchView::MouseDown(BPoint point) { BPopUpMenu* menu = new BPopUpMenu("WatchView", false, false); menu->AddItem(new BMenuItem( B_TRANSLATE("About"), new BMessage(B_ABOUT_REQUESTED))); menu->AddItem(new BMenuItem( B_TRANSLATE("Quit"), new BMessage(B_QUIT_REQUESTED))); menu->SetTargetForItems(this); ConvertToScreen(&point); menu->Go(point, true, false, true); delete menu; }
void DeskbarControlView::MouseDown(BPoint where) { BPopUpMenu *menu = new BPopUpMenu("menu"); if (fRecording) { menu->AddItem(new BSCMenuItem(BSC_STOP, new BMessage(kMsgGUIStopCapture))); if (fPaused) menu->AddItem(new BSCMenuItem(BSC_RESUME, new BMessage(kResumeCapture))); else menu->AddItem(new BSCMenuItem(BSC_PAUSE, new BMessage(kPauseCapture))); } else menu->AddItem(new BSCMenuItem(BSC_START, new BMessage(kMsgGUIStartCapture))); menu->SetTargetForItems(this); ConvertToScreen(&where); menu->Go(where, true, false, true); }
void PeakView::MouseDown(BPoint where) { int32 buttons; if (Window()->CurrentMessage()->FindInt32("buttons", &buttons) < B_OK) buttons = B_PRIMARY_MOUSE_BUTTON; if (buttons & B_PRIMARY_MOUSE_BUTTON) { // Reset the overshot flag and set the observed max to the current // value. for (uint32 i = 0; i < fChannelCount; i++) { fChannelInfos[i].last_overshot_time = -5000000; fChannelInfos[i].last_max = fChannelInfos[i].current_max; } } else if (buttons & B_TERTIARY_MOUSE_BUTTON) { // Toggle locking of the observed max value. fPeakLocked = !fPeakLocked; } else { // Display context menu BPopUpMenu* menu = new BPopUpMenu("peak context menu"); BMenuItem* item = new BMenuItem("Lock Peaks", new BMessage(MSG_LOCK_PEAKS)); item->SetMarked(fPeakLocked); menu->AddItem(item); menu->SetTargetForItems(this); menu->SetAsyncAutoDestruct(true); menu->SetFont(be_plain_font); where = ConvertToScreen(where); bool keepOpen = false; // ? if (keepOpen) { BRect mouseRect(where, where); mouseRect.InsetBy(-3.0, -3.0); where += BPoint(3.0, 3.0); menu->Go(where, true, false, mouseRect, true); } else { where += BPoint(3.0, 3.0); menu->Go(where, true, false, true); } } }
// MouseDown void FontValueView::MouseDown(BPoint where) { if (BView* parent = Parent()) parent->MouseDown(ConvertToParent(where)); if (fProperty) { font_family family; font_style style; fProperty->Value().GetFamilyAndStyle(&family, &style); BPopUpMenu* menu = new BPopUpMenu("font popup", false, false); _PolulateMenu(menu, this, family, style); menu->SetTargetForItems(this); menu->SetEnabled(fEnabled); show_popup_menu(menu, where, this); } }
void TReplicantTray::ShowReplicantMenu(BPoint point) { BPopUpMenu *menu = new BPopUpMenu("", false, false); menu->SetFont(be_plain_font); // If the clock is visible, show the extended menu // otheriwse, show "Show Time". if (fBarView->ShowingClock()) fClock->ShowClockOptions(ConvertToScreen(point)); else { BMenuItem *item = new BMenuItem("Show Time", new BMessage('time')); menu->AddItem(item); menu->SetTargetForItems(this); BPoint where = ConvertToScreen(point); menu->Go(where, true, true, BRect(where - BPoint(4, 4), where + BPoint(4, 4)), true); } }
void VBoxGuestDeskbarView::MouseDown(BPoint point) { int32 buttons = B_PRIMARY_MOUSE_BUTTON; if (Looper() != NULL && Looper()->CurrentMessage() != NULL) Looper()->CurrentMessage()->FindInt32("buttons", &buttons); BPoint where = ConvertToScreen(point); if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) { BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING, false, false); menu->SetAsyncAutoDestruct(true); menu->SetFont(be_plain_font); menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED))); menu->SetTargetForItems(this); menu->Go(where, true, true, true); } }
void TReplicantTray::ShowReplicantMenu(BPoint point) { BPopUpMenu* menu = new BPopUpMenu("", false, false); menu->SetFont(be_plain_font); // If clock is visible show the extended menu, otherwise show "Show time" if (!fTime->IsHidden()) fTime->ShowTimeOptions(ConvertToScreen(point)); else { BMenuItem* item = new BMenuItem(B_TRANSLATE("Show time"), new BMessage(kShowHideTime)); menu->AddItem(item); menu->SetTargetForItems(this); BPoint where = ConvertToScreen(point); menu->Go(where, true, true, BRect(where - BPoint(4, 4), where + BPoint(4, 4)), true); } }
void SeqPhraseMatrixView::ShowPopUp() { BPoint point; uint32 buttons; GetMouse(&point, &buttons, false); BPopUpMenu* menu = new BPopUpMenu( "", TRUE, TRUE, B_ITEMS_IN_COLUMN ); BMenuItem* item1 = new BMenuItem("Properties", new BMessage(PROPERTIES_MSG) ); // BMenuItem* item2 = new BMenuItem("Edit Name", new BMessage(EDIT_START_MSG) ); // BMenuItem* item3 = new BMenuItem("Remove", new BMessage(REMOVE_MSG) ); // if (menu && item1 && item2 && item3) { if (menu && item1) { if (item1 && item1->Message() ) item1->Message()->AddPoint(WHERE_STR, point); menu->SetFontSize(10); menu->AddItem(item1); // menu->AddItem(item2); // menu->AddItem(item3); menu->SetTargetForItems(this); BRect r(point, point); menu->Go( ConvertToScreen(point), true, false, ConvertToScreen(r), true ); } }
void QueryView::MouseDown(BPoint point) { BPoint cursorpoint; uint32 buttonmask; GetMouse(&cursorpoint, &buttonmask); if( buttonmask & B_PRIMARY_MOUSE_BUTTON ) { //pop-up query results window BMessenger messenger(this); messenger.SendMessage(OPEN_QUERY_WIN); return; //buttons aren't mutually exclusive, so we favor the primary. } if( buttonmask & B_SECONDARY_MOUSE_BUTTON ) { //pop-up context menu BPopUpMenu* popup = new BPopUpMenu("QueryWatcher"); BMenuItem* headeritem = new BMenuItem( Name(), NULL ); headeritem->SetEnabled(false); popup->AddItem(headeritem); popup->AddSeparatorItem(); popup->AddItem(new BMenuItem("Open settings directory", new BMessage(OPEN_SETTINGS_DIR))); popup->AddSeparatorItem(); popup->AddItem( new BMenuItem("Open query results", new BMessage(OPEN_QUERY_WIN) ) ); popup->AddItem( new BMenuItem("Reset query", new BMessage(RESET_QUERY) ) ); status_t ret; ret = popup->SetTargetForItems(this); #ifdef DEBUG ASSERT(ret == B_OK); #endif ConvertToScreen(&point); popup->Go(point, true, false, true); delete popup; } }
void PowerStatusReplicant::MouseDown(BPoint point) { BMessage* msg = Window()->CurrentMessage(); int32 buttons = msg->GetInt32("buttons", 0); if ((buttons & B_TERTIARY_MOUSE_BUTTON) != 0) { BMessenger messenger(this); messenger.SendMessage(kMsgToggleExtInfo); } else { BPopUpMenu* menu = new BPopUpMenu(B_EMPTY_STRING, false, false); menu->SetFont(be_plain_font); BMenuItem* item; menu->AddItem(item = new BMenuItem(B_TRANSLATE("Show text label"), new BMessage(kMsgToggleLabel))); if (fShowLabel) item->SetMarked(true); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Show status icon"), new BMessage(kMsgToggleStatusIcon))); if (fShowStatusIcon) item->SetMarked(true); menu->AddItem(new BMenuItem(!fShowTime ? B_TRANSLATE("Show time") : B_TRANSLATE("Show percent"), new BMessage(kMsgToggleTime))); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("Battery info" B_UTF8_ELLIPSIS), new BMessage(kMsgToggleExtInfo))); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("About" B_UTF8_ELLIPSIS), new BMessage(B_ABOUT_REQUESTED))); menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"), new BMessage(B_QUIT_REQUESTED))); menu->SetTargetForItems(this); ConvertToScreen(&point); menu->Go(point, true, false, true); } }
void MediaRoutingView::showContextMenu( BPoint point) { D_METHOD(("MediaRoutingView::showContextMenu()\n")); BPopUpMenu *menu = new BPopUpMenu("MediaRoutingView PopUp", false, false, B_ITEMS_IN_COLUMN); menu->SetFont(be_plain_font); // add layout options BMenuItem *item; BMessage *message = new BMessage(M_LAYOUT_CHANGED); message->AddInt32("layout", M_ICON_VIEW); menu->AddItem(item = new BMenuItem("Icon View", message)); if (m_layout == M_ICON_VIEW) { item->SetMarked(true); } message = new BMessage(M_LAYOUT_CHANGED); message->AddInt32("layout", M_MINI_ICON_VIEW); menu->AddItem(item = new BMenuItem("Mini Icon View", message)); if (m_layout == M_MINI_ICON_VIEW) { item->SetMarked(true); } menu->AddSeparatorItem(); // add 'CleanUp' command menu->AddItem(new BMenuItem("Clean Up", new BMessage(M_CLEANUP_REQUESTED), 'K')); // add 'Select All' command menu->AddItem(new BMenuItem("Select All", new BMessage(M_SELECT_ALL), 'A')); menu->SetTargetForItems(this); ConvertToScreen(&point); point -= BPoint(1.0, 1.0); menu->Go(point, true, true, true); }
void TermWindow::TabRightClicked(SmartTabView* tabView, BPoint point, int32 index) { if (index < 0) return; TermView* termView = _TermViewAt(index); if (termView == NULL) return; BMessage* closeMessage = new BMessage(kCloseView); _SessionAt(index)->id.AddToMessage(*closeMessage, "session"); BMessage* closeOthersMessage = new BMessage(kCloseOtherViews); _SessionAt(index)->id.AddToMessage(*closeOthersMessage, "session"); BMessage* editTitleMessage = new BMessage(kEditTabTitle); _SessionAt(index)->id.AddToMessage(*editTitleMessage, "session"); BPopUpMenu* popUpMenu = new BPopUpMenu("tab menu"); BLayoutBuilder::Menu<>(popUpMenu) .AddItem(B_TRANSLATE("Close tab"), closeMessage) .AddItem(B_TRANSLATE("Close other tabs"), closeOthersMessage) .AddSeparator() .AddItem(B_TRANSLATE("Edit tab title" B_UTF8_ELLIPSIS), editTitleMessage) ; popUpMenu->SetAsyncAutoDestruct(true); popUpMenu->SetTargetForItems(BMessenger(this)); BPoint screenWhere = tabView->ConvertToScreen(point); BRect mouseRect(screenWhere, screenWhere); mouseRect.InsetBy(-4.0, -4.0); popUpMenu->Go(screenWhere, true, true, mouseRect, true); }
void TestView::ShowModeMenu(void) { BPopUpMenu *menu = new BPopUpMenu("String"); BMessage *msg, modes; if (RuleRunner::GetCompatibleModes(fTestButton->Label(),modes) != B_OK) return; BString modestr; int32 i = 0; while (modes.FindString("modes",i,&modestr) == B_OK) { i++; msg = new BMessage(M_MODE_CHOSEN); msg->AddString("mode",modestr); menu->AddItem(new BMenuItem(modestr.String(), msg)); } menu->SetTargetForItems(this); BPoint pt; uint32 buttons; GetMouse(&pt,&buttons); ConvertToScreen(&pt); pt.x -= 10.0; if (pt.x < 0.0) pt.x = 0.0; pt.y -= 10.0; if (pt.y < 0.0) pt.y = 0.0; menu->SetAsyncAutoDestruct(true); menu->Go(pt,true,true,true); }
void _AmPropertiesField::AttachedToWindow() { inherited::AttachedToWindow(); if (mMenu && mMenuTarget) mMenu->SetTargetForItems(mMenuTarget); }