void TStageMovieCue::OpenStageCueMenu(BPoint menuPt) { BMenuItem *selected; // Create the menu and mark the current transition TStageCueMenu *theMenu = new TStageCueMenu(this->m_ChannelCue); if (theMenu) { // Set menu location point ConvertToScreen(&menuPt); selected = theMenu->Go(menuPt); // Check and see if we have a menu message int32 drawingMode; if (selected) { if ( selected->Message()->FindInt32("DrawingMode", &drawingMode) == B_OK) { // Lock offscreen m_OffscreenView->Looper()->Lock(); // Save drawing mode m_ChannelCue->SetDrawingMode( (drawing_mode)drawingMode ); // Only redraw if mode has changed if ( m_OffscreenView->DrawingMode() != m_ChannelCue->GetDrawingMode() ) { // Draw the bitmap into the offscreen using the new mode. m_OffscreenView->SetDrawingMode(m_ChannelCue->GetDrawingMode()); m_OffscreenView->DrawBitmap(m_Bitmap); m_OffscreenView->Sync(); Invalidate(); } m_OffscreenView->Looper()->Unlock(); } } // Clean up delete theMenu; } }
void CCrossHairDragView::MouseMoved(BPoint point, uint32 transit, const BMessage *message) { if(isDragged) { BPoint screenPoint = ConvertToScreen(point); team_id team = FindTeam(screenPoint); if(team != -1) { // The mouse is hoovering over a window. // Select the team which this window belongs to // in the process list. BMessage selectMessage(MSG_SELECT_TEAM); selectMessage.AddInt32(MESSAGE_DATA_ID_TEAM_ID, team); target.SendMessage(&selectMessage, this); } } }
void WorkspacesView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage) { WorkspacesWindow* window = dynamic_cast<WorkspacesWindow*>(Window()); if (window == NULL || !window->IsAutoRaising()) return; // Auto-Raise where = ConvertToScreen(where); BScreen screen(window); BRect frame = screen.Frame(); if (where.x == frame.left || where.x == frame.right || where.y == frame.top || where.y == frame.bottom) { // cursor is on screen edge if (window->Frame().Contains(where)) window->Activate(); } }
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 FrissWindow::MessageReceived(BMessage* message) { switch(message->what) { case msg_SelFeed: myf->Load(feedList->CurrentSelection()); break; case msg_EditFeed: { int item = feedList->CurrentSelection(); if (item < 0) break; BPoint p(30,30); p = ConvertToScreen(p); (new FPrefEditWindow(this, Xfeeds->ItemAt(item), p, true))->Show(); break; } default: BWindow::MessageReceived(message); } }
void TListView::MouseDown(BPoint point) { int32 buttons; Looper()->CurrentMessage()->FindInt32("buttons",&buttons); if (buttons & B_SECONDARY_MOUSE_BUTTON) { BFont font = *be_plain_font; font.SetSize(10); BPopUpMenu menu("enclosure", false, false); menu.SetFont(&font); menu.AddItem(new BMenuItem(TR("Open attachment"), new BMessage(LIST_INVOKED))); menu.AddItem(new BMenuItem(TR("Remove attachment"), new BMessage(M_REMOVE))); BPoint menuStart = ConvertToScreen(point); BMenuItem *item; if ((item = menu.Go(menuStart)) != NULL) { if (item->Command() == LIST_INVOKED) { BMessage msg(LIST_INVOKED); msg.AddPointer("source",this); msg.AddInt32("index",IndexOf(point)); Window()->PostMessage(&msg,fParent); } else { Select(IndexOf(point)); Window()->PostMessage(item->Command(),fParent); } } } else BListView::MouseDown(point); }
void TMagnify::MouseDown(BPoint where) { BMessage *currentMsg = Window()->CurrentMessage(); if (currentMsg->what == B_MOUSE_DOWN) { uint32 buttons = 0; currentMsg->FindInt32("buttons", (int32 *)&buttons); uint32 modifiers = 0; currentMsg->FindInt32("modifiers", (int32 *)&modifiers); if ((buttons & B_SECONDARY_MOUSE_BUTTON) || (modifiers & B_CONTROL_KEY)) { // secondary button was clicked or control key was down, show menu and return BPopUpMenu *menu = new BPopUpMenu(B_TRANSLATE("Info")); menu->SetFont(be_plain_font); BuildInfoMenu(menu); BMenuItem *selected = menu->Go(ConvertToScreen(where)); if (selected) Window()->PostMessage(selected->Message()->what); delete menu; return; } // add a mousedown looper here int32 pixelSize = PixelSize(); float x = where.x / pixelSize; float y = where.y / pixelSize; MoveSelectionTo(x, y); // draw the frozen image // update the info region fNeedToUpdate = true; Invalidate(); } }
void PieView::MouseDown(BPoint where) { uint32 buttons; BMessage* current = Window()->CurrentMessage(); if (current->FindInt32("buttons", (int32*)&buttons) != B_OK) buttons = B_PRIMARY_MOUSE_BUTTON; FileInfo* info = _FileAt(where); if (info == NULL || info->pseudo) return; if (buttons & B_PRIMARY_MOUSE_BUTTON) { fClicked = true; fDragStart = where; fClickedFile = info; SetMouseEventMask(B_POINTER_EVENTS); } else if (buttons & B_SECONDARY_MOUSE_BUTTON) { where = ConvertToScreen(where); _ShowContextMenu(info, where); } }
void SelectionWindow::MoveCloseToMouse() { uint32 buttons; BPoint mousePosition; ChildAt((int32)0)->GetMouse(&mousePosition, &buttons); ConvertToScreen(&mousePosition); // Position the window centered around the mouse... BPoint windowPosition = BPoint(mousePosition.x - Frame().Width() / 2, mousePosition.y - Frame().Height() / 2); // ... unless that's outside of the current screen size: BScreen screen; windowPosition.x = MAX(0, MIN(screen.Frame().right - Frame().Width(), windowPosition.x)); windowPosition.y = MAX(0, MIN(screen.Frame().bottom - Frame().Height(), windowPosition.y)); MoveTo(windowPosition); }
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 CCrossHairDragView::MouseUp(BPoint where) { if(isDragged) { // The crosshair was dropped. // The point where it was dropped. BPoint screenPoint = ConvertToScreen(where); team_id team = FindTeam(screenPoint); if(team != -1) { BMessage killMessage(MSG_TEAM_ACTION), reply; killMessage.AddInt32(MESSAGE_DATA_ID_ACTION, TEAM_ACTION_KILL); killMessage.AddInt32(MESSAGE_DATA_ID_TEAM_ID, team); target.SendMessage(&killMessage, &reply); } isDragged = false; } }
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 StartWindowList::MouseDown(BPoint pt) { uint32 buttons; BPoint point; GetMouse(&point,&buttons); if (buttons & B_SECONDARY_MOUSE_BUTTON) { BMessage *msg = Window()->CurrentMessage(); int32 clicks; msg->FindInt32("clicks",&clicks); if (clicks > 1) { clicks = 1; msg->ReplaceInt32("clicks",clicks); } } BListView::MouseDown(pt); if (buttons & B_SECONDARY_MOUSE_BUTTON) { BPoint screenpt(pt); ConvertToScreen(&screenpt); screenpt.x -= 5; screenpt.y -= 5; BStringItem *stringItem = (BStringItem*)ItemAt(IndexOf(pt)); if (!stringItem) return; BPopUpMenu menu("context"); menu.AddItem(new BMenuItem(TR("Remove from Recent List"), new BMessage(M_REMOVE_FROM_LIST))); menu.SetTargetForItems(Window()); menu.Go(screenpt,true,false); } }
void TMagnify::Update(bool force) { BPoint loc; uint32 button; static long counter = 0; if (!fStickCoordinates) { GetMouse(&loc, &button); ConvertToScreen(&loc); } else loc = fLastLoc; if (force || fLastLoc != loc || counter++ % 35 == 0) { if (fImageView->CreateImage(loc, force)) Invalidate(); counter = 0; if (force) SetUpdate(false); } fLastLoc = loc; }
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 TTimeView::ShowCalendar(BPoint where) { if (fCalendarWindow.IsValid()) { // If the calendar is already shown, just activate it BMessage activate(B_SET_PROPERTY); activate.AddSpecifier("Active"); activate.AddBool("data", true); if (fCalendarWindow.SendMessage(&activate) == B_OK) return; } where.y = Bounds().bottom + 4.0; ConvertToScreen(&where); if (where.y >= BScreen().Frame().bottom) where.y -= (Bounds().Height() + 4.0); CalendarMenuWindow* window = new CalendarMenuWindow(where); fCalendarWindow = BMessenger(window); window->Show(); }
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 DTipWatcherView::Pulse(void) { // Check to see if there has been any activity. If so, just reset. BPoint pt; uint32 buttons; GetMouse(&pt,&buttons); ConvertToScreen(&pt); if (pt != fLastPoint || buttons) { fDelayCounter = 0; fLastPoint = pt; HideTip(); return; } fLastPoint = pt; if (!Window()->IsHidden()) return; fDelayCounter += Window()->PulseRate(); if (fDelayCounter < fDelayMax) return; // We got this far, so it's time to show a tip BView *view = ViewForPoint(pt); if (!view) return; BString text = GetTip(view); if (text.CountChars() < 1) return; ShowTip(pt, text.String()); }
status_t TBarView::DragStart() { // always set the click to open state // to false during a drag // so that a release on a menu/menubar will not // leave the menu open (ExpandoMenuBar, BarMenuBar) // will get reset to actual initial system // state on DragStop _menu_info_ptr_->click_to_open = false; if (!Dragging()) return B_OK; BPoint loc; uint32 buttons; GetMouse(&loc, &buttons); if (fExpando && fExpando->Frame().Contains(loc)) { ConvertToScreen(&loc); BPoint expandoloc = fExpando->ConvertFromScreen(loc); TTeamMenuItem *item = fExpando->ItemAtPoint(expandoloc); if (fLastDragItem) init_tracking_hook(fLastDragItem, NULL, NULL); if (item) { if (item == fLastDragItem) return B_OK; fLastDragItem = item; } } return B_OK; }
void WorkspacesView::MouseDown(BPoint where) { // With enabled auto-raise feature, we'll get mouse messages we don't // want to handle here. if (!Bounds().Contains(where)) return; int32 buttons = 0; if (Window() != NULL && Window()->CurrentMessage() != NULL) Window()->CurrentMessage()->FindInt32("buttons", &buttons); if ((buttons & B_SECONDARY_MOUSE_BUTTON) == 0) return; // open context menu BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING, false, false); menu->SetFont(be_plain_font); // TODO: alternatively change the count here directly? BMenuItem* changeItem = new BMenuItem("Change workspace count" B_UTF8_ELLIPSIS, new BMessage(kMsgChangeCount)); menu->AddItem(changeItem); WorkspacesWindow* window = dynamic_cast<WorkspacesWindow*>(Window()); if (window != NULL) { BMenuItem* item; menu->AddSeparatorItem(); menu->AddItem(item = new BMenuItem("Show window title", new BMessage(kMsgToggleTitle))); if (window->Look() == B_TITLED_WINDOW_LOOK) item->SetMarked(true); menu->AddItem(item = new BMenuItem("Show window border", new BMessage(kMsgToggleBorder))); if (window->Look() == B_TITLED_WINDOW_LOOK || window->Look() == B_MODAL_WINDOW_LOOK) item->SetMarked(true); menu->AddSeparatorItem(); menu->AddItem(item = new BMenuItem("Always on top", new BMessage(kMsgToggleAlwaysOnTop))); if (window->Feel() == B_FLOATING_ALL_WINDOW_FEEL) item->SetMarked(true); menu->AddItem(item = new BMenuItem("Auto-raise", new BMessage(kMsgToggleAutoRaise))); if (window->IsAutoRaising()) item->SetMarked(true); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem("About Workspaces" B_UTF8_ELLIPSIS, new BMessage(B_ABOUT_REQUESTED))); menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED))); menu->SetTargetForItems(window); } changeItem->SetTarget(this); ConvertToScreen(&where); menu->Go(where, true, true, true); }
void MiniMenuField::MouseDown(BPoint) { fMenu->Go(ConvertToScreen(BPoint(4, 4)), true); }
void SeqMeasureControl::ShowTimeSignatureMenu(BPoint pt) const { AmSignature sig; if (SignatureForPt(pt, sig) != B_OK) return; BPopUpMenu* menu = new BPopUpMenu("menu"); if (!menu) return; menu->SetFontSize(10); menu->SetAsyncAutoDestruct(true); BMessage signatureChoices; if (seq_get_message_preference(SIGNATURE_CHOICES_PREF, &signatureChoices) == B_OK) { int32 beats; for(int32 k = 0; signatureChoices.FindInt32("beats", k, &beats) == B_OK; k++) { int32 beatvalue; if (signatureChoices.FindInt32("beat value", k, &beatvalue) == B_OK) { BString label; label << beats << " / " << beatvalue; BMessage* msg = new BMessage(CHANGE_SIGNATURE_MSG); BMenuItem* item; if (msg && (item = new BMenuItem(label.String(), msg)) ) { msg->AddInt32("measure", sig.Measure() ); msg->AddInt32("beats", beats); msg->AddInt32("beat value", beatvalue); menu->AddItem(item); item->SetTarget(this); } } } } BMessage* msg = new BMessage(CHANGE_SIGNATURE_MSG); BMenuItem* item; if ( msg && (item = new BMenuItem("Other...", msg)) ) { msg->AddInt32("measure", sig.Measure() ); msg->AddInt32("beats", sig.Beats() ); msg->AddInt32("beat value", sig.BeatValue() ); menu->AddItem(item); item->SetTarget( Window() ); } /* If I'm a track measure control, add in my motion list. */ BMenu* motionMenu = NULL; if (mTrackWinProps && (motionMenu = new BMenu("Motion")) ) { BMessage* msg = new BMessage(CHANGE_MOTION_MSG); BMenuItem* item; if (msg && (item = new BMenuItem(NONE_STR, msg)) ) { msg->AddInt32("code", MOTION_NONE); msg->AddInt32("measure", sig.Measure() ); motionMenu->AddItem(item); item->SetTarget(this); } msg = new BMessage(CHANGE_MOTION_MSG); if (msg && (item = new BMenuItem(CLEAR_STR, msg)) ) { msg->AddInt32("code", MOTION_CLEAR); msg->AddInt32("measure", sig.Measure() ); motionMenu->AddItem(item); item->SetTarget(this); } BString label, key; for (uint32 k = 0; AmGlobals().GetMotionInfo(k, label, key) == B_OK; k++) { msg = new BMessage(CHANGE_MOTION_MSG); if (msg && (item = new BMenuItem(label.String(), msg)) ) { if (k == 0) motionMenu->AddSeparatorItem(); msg->AddString(MOTION_KEY_STR, key); msg->AddInt32("measure", sig.Measure() ); motionMenu->AddItem(item); item->SetTarget(this); } } if (motionMenu) { menu->AddSeparatorItem(); BMenuItem* i = new BMenuItem(motionMenu); if (i) menu->AddItem(i); } } BRect frame(pt, pt); menu->Go( ConvertToScreen(pt), true, false, ConvertToScreen(frame), true); }
void TPanelWindowView::MessageReceived( BMessage *message ) { if ( fDebugLevel >= 20 ) message->PrintToStream(); if ( message->what == B_GET_PROPERTY || message->what == B_SET_PROPERTY || message->what == B_COUNT_PROPERTIES || message->what == B_CREATE_PROPERTY || message->what == B_DELETE_PROPERTY || message->what == B_EXECUTE_PROPERTY ) { int32 index, what; BMessage specifier; const char *property; if ( message->GetCurrentSpecifier( &index, &specifier, &what, &property ) == B_OK ) { BMessage reply( B_REPLY ); if ( message->what == B_GET_PROPERTY || message->what == B_COUNT_PROPERTIES || message->what == B_EXECUTE_PROPERTY ) { if ( GetOptions( property, &reply ) ) reply.AddInt32( "error", 0 ); else reply.AddInt32( "error", -1 ); } else if ( message->what == B_SET_PROPERTY ) { if ( SetOptions( property, message ) ) reply.AddInt32( "error", 0 ); else reply.AddInt32( "error", -1 ); } else if ( message->what == B_CREATE_PROPERTY ) { if ( !strcasecmp( property, "tab" ) ) { int32 index; if ( message->FindInt32( "index", &index ) != B_OK ) index = -1; TShortcutPanel *panel = new TShortcutPanel( this ); fPanels.Lock(); if ( index >= 0 ) { TInnerPanel *rightpanel = fPanels.ItemAt(index); AddPanel( panel, rightpanel ); } else { AddPanel( panel ); } fPanels.Unlock(); ChangedSize(0); reply.AddInt32( "error", 0 ); } else reply.AddInt32( "error", -1 ); } else if ( message->what == B_DELETE_PROPERTY ) { int32 index; if ( specifier.FindInt32( "index", &index ) != B_OK ) reply.AddInt32( "error", -1 ); else { fPanels.Lock(); TInnerPanel *panel = fPanels.ItemAt(index); if ( !panel ) reply.AddInt32( "error", -1 ); else { if ( panel != fRunningAppPanel ) { RemovePanel( panel ); reply.AddInt32( "error", 0 ); } else reply.AddInt32( "error", -1 ); } fPanels.Unlock(); } } message->SendReply( &reply ); } return; } if ( message->WasDropped() ) { BPoint point = message->DropPoint(); ConvertFromScreen( &point ); TInnerPanel *panel = PanelAt( point ); if ( message->what == 'IDRG' ) { TPanelIcon *item; if ( message->FindPointer( "source", (void**)&item ) == B_OK ) { TRaisingIconPanel *previous_parent = item->fParent; TRaisingIconPanel *rpanel; if ( modifiers() & B_CONTROL_KEY ) { rpanel = new TShortcutPanel(this); bool left = false; if ( point.x < (panel->Frame().left+(panel->Frame().Width()/2) ) ) { left = true; } rpanel = new TShortcutPanel(this); AddPanel( rpanel, left ? panel : 0 ); } else rpanel = dynamic_cast<TRaisingIconPanel*>(panel); if ( rpanel && rpanel != fRunningAppPanel ) { TPanelIcon *icon = rpanel->IconAt( point, true ); if ( previous_parent == fRunningAppPanel && dynamic_cast<TShortcutPanel*>(rpanel) ) { int32 index = rpanel->IndexOf(icon); AddShortcut( dynamic_cast<TShortcutPanel*>(rpanel), dynamic_cast<TAppPanelIcon*>(item)->Ref(), index ); } else if ( !dynamic_cast<TTrashIcon*>(icon) || (modifiers() & B_SHIFT_KEY) ) { previous_parent->RemoveItem( item, false ); int32 index = rpanel->IndexOf(icon); rpanel->AddItem( item, index ); } else { if ( item->Removable() ) RemoveShortcut(item); } if ( previous_parent->CountItems() == 0 && previous_parent != fRunningAppPanel ) RemovePanel( previous_parent ); } } } else { if ( panel && panel->HitsFrame( point ) ) { panel->HandleDroppedMessage( message, point ); } else { HandleDroppedMessage( message, point ); } } return; } switch ( message->what ) { case kPanelWindowViewTimer: { if ( DoIconSmallerWithTime() == 0 ) { fTimer->SetInterval( 999999999 ); } break; } case T_MENU_CLOSED: { DebugCall( 8, "Got T_MENU_CLOSED" ); TAwarePopupMenu *source; if ( message->FindPointer( "source", (void**)&source ) == B_OK ) { if ( source == fOpenMenu ) { DebugCall( 9, "fOpenMenu is now 0" ); fOpenMenu = 0; BPoint point; uint32 buttons; GetMouse( &point, &buttons ); if ( !Bounds().Contains( point ) ) Window()->PostMessage(B_EXITED_VIEW); } } break; } case B_SOME_APP_LAUNCHED: { team_id tid; if ( message->FindInt32( "be:team", &tid ) != B_OK ) break; const char *sig; if ( message->FindString( "be:signature", &sig ) != B_OK ) break; entry_ref ref; if ( message->FindRef( "be:ref", &ref ) != B_OK ) break; int32 flags; if ( message->FindInt32( "be:flags", &flags ) != B_OK ) break; if ( sig && strlen(sig) && ( ( flags & B_BACKGROUND_APP ) == 0 ) ) AddTeam( tid, sig, ref ); break; } case B_SOME_APP_QUIT: { team_id tid; if ( message->FindInt32( "be:team", &tid ) != B_OK ) break; RemoveTeam( tid ); break; } case B_SOME_APP_ACTIVATED: { team_id tid; if ( message->FindInt32( "be:team", &tid ) == B_OK ) { TAppPanelIcon *icon = ItemWith( tid ); if ( icon != fLastActiveAppIcon ) { DebugCall( 10, "B_SOME_APP_ACTIVATED %p[..]->%p[%i]", fLastActiveAppIcon, icon, tid ); if ( fLastActiveAppIcon ) fLastActiveAppIcon->SetActive( false ); if ( icon ) icon->SetActive( true ); fLastActiveAppIcon = icon; } } BString temp; message->FindString( "be:signature", &temp ); if ( temp != "application/x-vnd.Be-TSKB" ) fLastActivatedAppSig = temp; break; } case kDoBubbleHelp: { BPoint point; uint32 buttons; GetMouse(&point, &buttons); if ( fPreviousMousePosition != point ) { if ( fBubbleCounter > 0 ) { if ( fBubbleCounter >= 6 ) { fBubbleHelp->HideBubble(); } fBubbleCounter = 0; } fPreviousMousePosition = point; } else { BRegion region; GetClippingRegion(®ion); if ( region.Contains( point ) ) { fBubbleCounter ++; if ( fBubbleCounter == 6 ) { ConvertToScreen(&point); TBubbleTarget *target = fBubbleHelp->TargetAt( point ); if (dynamic_cast<TTrackerIcon*>(target)) { TTrackerIcon *trackerIcon = dynamic_cast<TTrackerIcon*>(target); point.x = Window()->Frame().left + trackerIcon->ContentLocation().x + trackerIcon->Frame().Width() + 4; point.y = Window()->Frame().top; float height = TBubbleHelp::BubbleHeight(target); point.y += height; point.y += (Window()->Frame().Height() - height)/2 -4; } fBubbleHelp->ShowBubble( point, target ); } // else if ( fBubbleCounter == 12 ) // { // fBubbleHelp->HideBubble(); // } } } break; } case 'flsh': { BMessenger target; if ( message->FindMessenger("source", &target ) == B_OK && target.IsValid() ) { TAppPanelIcon *teamicon = ItemWith( target.Team() ); if ( teamicon ) { // todo: flashing teamicon->Flash(); } } break; } case 'mctx': { // todo: context menus break; } default: BView::MessageReceived(message); } }
void NetworkStatusView::MouseDown(BPoint point) { BPopUpMenu* menu = new BPopUpMenu(B_EMPTY_STRING, false, false); menu->SetAsyncAutoDestruct(true); menu->SetFont(be_plain_font); BString wifiInterface; BNetworkDevice wifiDevice; // Add interfaces for (std::map<BString, int32>::const_iterator it = fInterfaceStatuses.begin(); it != fInterfaceStatuses.end(); ++it) { const BString& name = it->first; BString label = name; label += ": "; label += kStatusDescriptions[ _DetermineInterfaceStatus(name.String())]; BMessage* info = new BMessage(kMsgShowConfiguration); info->AddString("interface", name.String()); menu->AddItem(new BMenuItem(label.String(), info)); // We only show the networks of the first wireless device we find. if (wifiInterface.IsEmpty()) { wifiDevice.SetTo(name); if (wifiDevice.IsWireless()) wifiInterface = name; } } if (!fInterfaceStatuses.empty()) menu->AddSeparatorItem(); // Add wireless networks, if any if (!wifiInterface.IsEmpty()) { std::set<BNetworkAddress> associated; BNetworkAddress address; uint32 cookie = 0; while (wifiDevice.GetNextAssociatedNetwork(cookie, address) == B_OK) associated.insert(address); cookie = 0; wireless_network network; typedef std::vector<wireless_network> WirelessNetworkVector; WirelessNetworkVector wirelessNetworks; while (wifiDevice.GetNextNetwork(cookie, network) == B_OK) wirelessNetworks.push_back(network); std::sort(wirelessNetworks.begin(), wirelessNetworks.end(), signal_strength_compare); int32 count = 0; for (WirelessNetworkVector::iterator it = wirelessNetworks.begin(); it != wirelessNetworks.end(); it++) { wireless_network &network = *it; BMessage* message = new BMessage(kMsgJoinNetwork); message->AddString("device", wifiInterface); message->AddString("name", network.name); message->AddFlat("address", &network.address); BMenuItem* item = new WirelessNetworkMenuItem(network.name, network.signal_strength, network.authentication_mode, message); menu->AddItem(item); if (associated.find(network.address) != associated.end()) item->SetMarked(true); count++; } if (count == 0) { BMenuItem* item = new BMenuItem( B_TRANSLATE("<no wireless networks found>"), NULL); item->SetEnabled(false); menu->AddItem(item); } menu->AddSeparatorItem(); } menu->AddItem(new BMenuItem(B_TRANSLATE( "Open network preferences" B_UTF8_ELLIPSIS), new BMessage(kMsgOpenNetworkPreferences))); if (fInDeskbar) { menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"), new BMessage(B_QUIT_REQUESTED))); } menu->SetTargetForItems(this); ConvertToScreen(&point); menu->Go(point, true, true, true); }
void ActivityView::MouseDown(BPoint where) { int32 buttons = B_SECONDARY_MOUSE_BUTTON; if (Looper() != NULL && Looper()->CurrentMessage() != NULL) Looper()->CurrentMessage()->FindInt32("buttons", &buttons); if (buttons == B_PRIMARY_MOUSE_BUTTON) { fZoomPoint = where; fOriginalResolution = fDrawResolution; fZooming = true; SetMouseEventMask(B_POINTER_EVENTS); return; } BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING, false, false); menu->SetFont(be_plain_font); BMenu* additionalMenu = new BMenu(B_TRANSLATE("Additional items")); additionalMenu->SetFont(be_plain_font); SystemInfo info; BMenuItem* item; for (int32 i = 0; i < DataSource::CountSources(); i++) { const DataSource* source = DataSource::SourceAt(i); if (source->MultiCPUOnly() && info.CPUCount() == 1) continue; BMessage* message = new BMessage(kMsgToggleDataSource); message->AddInt32("index", i); item = new BMenuItem(source->Name(), message); if (FindDataSource(source)) item->SetMarked(true); if (source->Primary()) menu->AddItem(item); else additionalMenu->AddItem(item); } menu->AddItem(new BMenuItem(additionalMenu)); menu->AddSeparatorItem(); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Show legend"), new BMessage(kMsgToggleLegend))); item->SetMarked(fShowLegend); menu->SetTargetForItems(this); additionalMenu->SetTargetForItems(this); ActivityWindow* window = dynamic_cast<ActivityWindow*>(Window()); if (window != NULL && window->ActivityViewCount() > 1) { menu->AddSeparatorItem(); BMessage* message = new BMessage(kMsgRemoveView); message->AddPointer("view", this); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Remove graph"), message)); item->SetTarget(window); } ConvertToScreen(&where); menu->Go(where, true, false, true); }
void WorkspacesView::MouseDown(BPoint where) { // With enabled auto-raise feature, we'll get mouse messages we don't // want to handle here. if (!Bounds().Contains(where)) return; int32 buttons = 0; if (Window() != NULL && Window()->CurrentMessage() != NULL) Window()->CurrentMessage()->FindInt32("buttons", &buttons); if ((buttons & B_SECONDARY_MOUSE_BUTTON) == 0) return; // open context menu BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING, false, false); menu->SetFont(be_plain_font); // TODO: alternatively change the count here directly? BMenuItem* changeItem = new BMenuItem(B_TRANSLATE("Change workspace count" B_UTF8_ELLIPSIS), new BMessage(kMsgChangeCount)); menu->AddItem(changeItem); WorkspacesWindow* window = dynamic_cast<WorkspacesWindow*>(Window()); if (window != NULL) { // inside Workspaces app BMenuItem* item; menu->AddSeparatorItem(); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Show window tab"), new BMessage(kMsgToggleTitle))); if (window->Look() == B_TITLED_WINDOW_LOOK) item->SetMarked(true); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Show window border"), new BMessage(kMsgToggleBorder))); if (window->Look() == B_TITLED_WINDOW_LOOK || window->Look() == B_MODAL_WINDOW_LOOK) item->SetMarked(true); menu->AddSeparatorItem(); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Always on top"), new BMessage(kMsgToggleAlwaysOnTop))); if (window->Feel() == B_FLOATING_ALL_WINDOW_FEEL) item->SetMarked(true); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Auto-raise"), new BMessage(kMsgToggleAutoRaise))); if (window->IsAutoRaising()) item->SetMarked(true); if (be_roster->IsRunning(kDeskbarSignature)) { menu->AddItem(item = new BMenuItem(B_TRANSLATE("Live in the Deskbar"), new BMessage(kMsgToggleLiveInDeskbar))); BDeskbar deskbar; item->SetMarked(deskbar.HasItem(kDeskbarItemName)); } menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("About Workspaces" B_UTF8_ELLIPSIS), new BMessage(B_ABOUT_REQUESTED))); menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"), new BMessage(B_QUIT_REQUESTED))); menu->SetTargetForItems(window); } else { // we're replicated in some way... BMenuItem* item; menu->AddSeparatorItem(); // check which way BDragger *dragger = dynamic_cast<BDragger*>(ChildAt(0)); if (dragger) { // replicant menu->AddItem(item = new BMenuItem(B_TRANSLATE("Remove replicant"), new BMessage(B_TRASH_TARGET))); item->SetTarget(dragger); } else { // Deskbar item menu->AddItem(item = new BMenuItem(B_TRANSLATE("Remove replicant"), new BMessage(kMsgToggleLiveInDeskbar))); item->SetTarget(this); } } changeItem->SetTarget(this); ConvertToScreen(&where); menu->Go(where, true, true, true); }
void InterfacesListView::MouseDown(BPoint where) { int32 buttons = 0; Window()->CurrentMessage()->FindInt32("buttons", &buttons); if ((B_SECONDARY_MOUSE_BUTTON & buttons) == 0) { // If not secondary mouse button do the default BListView::MouseDown(where); return; } InterfaceListItem* item = FindItem(where); if (item == NULL) return; // Remove all items from the menu for (int32 i = fContextMenu->CountItems(); i >= 0; --i) { BMenuItem* menuItem = fContextMenu->RemoveItem(i); delete menuItem; } // Now add the ones we want if (item->GetSettings()->IsDisabled()) { fContextMenu->AddItem(new BMenuItem(B_TRANSLATE("Enable"), new BMessage(kMsgInterfaceToggle))); } else { fContextMenu->AddItem(new BMenuItem( B_TRANSLATE("Configure" B_UTF8_ELLIPSIS), new BMessage(kMsgInterfaceConfigure))); if (item->GetSettings()->AutoConfigure(AF_INET) || item->GetSettings()->AutoConfigure(AF_INET6)) { fContextMenu->AddItem(new BMenuItem( B_TRANSLATE("Renegotiate Address"), new BMessage(kMsgInterfaceRenegotiate))); } fContextMenu->AddItem(new BSeparatorItem()); fContextMenu->AddItem(new BMenuItem(B_TRANSLATE("Disable"), new BMessage(kMsgInterfaceToggle))); } fContextMenu->ResizeToPreferred(); BMenuItem* selected = fContextMenu->Go(ConvertToScreen(where)); if (selected == NULL) return; switch (selected->Message()->what) { case kMsgInterfaceConfigure: { InterfaceWindow* win = new InterfaceWindow(item->GetSettings()); win->MoveTo(ConvertToScreen(where)); win->Show(); break; } case kMsgInterfaceToggle: item->SetDisabled(!item->IsDisabled()); Invalidate(); break; case kMsgInterfaceRenegotiate: item->GetSettings()->RenegotiateAddresses(); break; } }
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); } }
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 CSelectionView::MouseDown(BPoint where) { ulong btns; BPoint cur; GetMouse(&cur, &btns); if (IsOptionalClick(Window()->CurrentMessage())) { BPopUpMenu popUp("gotomenu"); popUp.SetFont(be_plain_font); CNameTable& names = *fCellView->GetNameTable(); if (names.size() == 0) popUp.AddItem(new BMenuItem(GetMessage(msgNoNames), 0)); else { namemap::iterator i; for (i = names.begin(); i != names.end(); i++) popUp.AddItem(new BMenuItem((*i).first, 0)); } BMenuItem *item = popUp.Go(ConvertToScreen(where)); if (item) { BMessage msg(msg_GoTo); msg.AddString("name", item->Label()); Window()->PostMessage(&msg, fCellView); } } else { bool isIn = true; BRect frame(Bounds()); frame.InsetBy(1.0, 1.0); FillRect3D(this, frame, true, true, fText); while (btns) { if (frame.Contains(cur)) { if (!isIn) { isIn = true; FillRect3D(this, frame, true, true, fText); } } else { if (isIn) { isIn = false; FillRect3D(this, frame, false, true, fText); } } GetMouse(&cur, &btns); } FillRect3D(this, frame, false, true, fText); if (isIn) Window()->PostMessage(msg_GoToCmd, fCellView); } } /* CSelectionView::MouseDown */