예제 #1
0
파일: MediaJack.cpp 프로젝트: mariuz/haiku
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);
}
예제 #2
0
//! 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);
    }
}
예제 #3
0
파일: Panel.cpp 프로젝트: dakyri/qua
void
Panel::RunControlMenu(BPoint where)
{
	BPopUpMenu	*qMenu = new BPopUpMenu("env sel", true, FALSE);
	
	BPoint			orig = where;
	ConvertToScreen(&where);
	
	BMessage	*msg;
	BMenuItem	*item;
	
	if (displayMode != PANEL_DISPLAY_SMALL) {
		msg = new BMessage(SET_DISPLAY_MODE);
		msg->AddInt32("display mode", PANEL_DISPLAY_SMALL);
		item = new BMenuItem("Close", msg);
		qMenu->AddItem(item);
		item->SetTarget(this);
	}
	if (displayMode != PANEL_DISPLAY_BIG) {
		msg = new BMessage(SET_DISPLAY_MODE);
		msg->AddInt32("display mode", PANEL_DISPLAY_BIG);
		item = new BMenuItem("Open", msg);
		qMenu->AddItem(item);
		item->SetTarget(this);
	}
		
	qMenu->SetAsyncAutoDestruct(true);
	qMenu->Go(where, true, false, true);
}
예제 #4
0
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);
}
예제 #5
0
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;
	}
}
예제 #6
0
// 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);
	}
}
예제 #7
0
파일: MarkAs.cpp 프로젝트: mmanley/Antares
extern "C" void
process_refs(entry_ref dir, BMessage* message, void* /*reserved*/)
{
	BPopUpMenu* menu = new BPopUpMenu("status");
	retrieve_status_items(menu);

	BMenuItem* item = menu->Go(mouse_position() - BPoint(5, 5), false, true);
	if (item == NULL)
		return;

	BString status = item->Label();

	entry_ref ref;
	for (int i = 0; message->FindRef("refs", i, &ref) == B_OK; i++) {
		BNode node(&ref);
		BString type;

		if (node.InitCheck() == B_OK
			&& node.ReadAttrString("BEOS:TYPE", &type) == B_OK
			&& type == "text/x-email") {
			BString previousStatus;

			// Only update the attribute if there is an actual change
			if (node.ReadAttrString("MAIL:status", &previousStatus) != B_OK
				|| previousStatus != status)
				node.WriteAttrString("MAIL:status", &status);
		}
	}
}
예제 #8
0
파일: TimeView.cpp 프로젝트: ysei/haiku
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);
}
예제 #9
0
파일: GMenu.cpp 프로젝트: FEI17N/Lgi
int GSubMenu::Float(GView *Parent, int x, int y, bool Left)
{
	if (Info)
	{
		BPopUpMenu *Popup = new BPopUpMenu("PopUpMenu");
		if (Popup)
		{
			_CopyMenu(Popup, this);
		
			BPoint Pt(x, y);
			BMenuItem *Item = Popup->Go(Pt);
			if (Item)
			{
				#undef Message
				BMessage *Msg = Item->Message();
				int32 i;
				if (Msg && Msg->FindInt32("Cmd", &i) == B_OK)
				{
					return i;
				}
			}
		}
	}
	
	return 0;
}
예제 #10
0
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);
}
예제 #11
0
// 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;
}
예제 #12
0
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);
	}
}
예제 #13
0
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);
}
예제 #14
0
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);
		}
	}
}
예제 #15
0
	virtual void MessageReceived(BMessage* message)
	{
		switch (message->what) {
			case MSG_SCROLL_TABS_LEFT:
				fTabContainerView->SetFirstVisibleTabIndex(
					fTabContainerView->FirstVisibleTabIndex() - 1);
				break;
			case MSG_SCROLL_TABS_RIGHT:
				fTabContainerView->SetFirstVisibleTabIndex(
					fTabContainerView->FirstVisibleTabIndex() + 1);
				break;
			case MSG_OPEN_TAB_MENU:
			{
				BPopUpMenu* tabMenu = new BPopUpMenu("tab menu", true, false);
				int tabCount = fTabContainerView->GetLayout()->CountItems();
				for (int i = 0; i < tabCount; i++) {
					TabView* tab = fTabContainerView->TabAt(i);
					if (tab) {
						BMenuItem* item = new BMenuItem(tab->Label(), NULL);
						tabMenu->AddItem(item);
						if (tab->IsFront())
							item->SetMarked(true);
					}
				}

				// Force layout to get the final menu size. InvalidateLayout()
				// did not seem to work here.
				tabMenu->AttachedToWindow();
				BRect buttonFrame = fTabMenuButton->Frame();
				BRect menuFrame = tabMenu->Frame();
				BPoint openPoint = ConvertToScreen(buttonFrame.LeftBottom());
				// Open with the right side of the menu aligned with the right
				// side of the button and a little below.
				openPoint.x -= menuFrame.Width() - buttonFrame.Width();
				openPoint.y += 2;

				BMenuItem *selected = tabMenu->Go(openPoint, false, false,
					ConvertToScreen(buttonFrame));
				if (selected) {
					selected->SetMarked(true);
					int32 index = tabMenu->IndexOf(selected);
					if (index != B_ERROR)
						fTabContainerView->SelectTab(index);
				}
				fTabMenuButton->MenuClosed();
				delete tabMenu;
				
				break;
			}
			default:
				BGroupView::MessageReceived(message);
				break;
		}
	}
예제 #16
0
파일: SymObject.cpp 프로젝트: dakyri/qua
void
QuaSymbolBridge::MouseDown(BPoint where)
{
	long		channel, quant;
	BRect		area = Bounds();

	ulong		mods = modifiers(); // Key mods???
	ulong		buts;
	BMessage	*msg;
	BPoint		pt;
	drawing_mode	cur_mode = DrawingMode();
	long		clicks;
	
	GetMouse(&pt, &buts);
	msg = Window()->CurrentMessage();
	
	if ((clicks=msg->FindInt32("clicks")) == 1) {
		if (buts & B_SECONDARY_MOUSE_BUTTON) {
			BPopUpMenu	*qMenu = new BPopUpMenu("env sel", true, FALSE);
			
			BPoint			orig = where;
			ConvertToScreen(&where);
			
			BMessage	*msg = new BMessage(SET_DISPLAY_MODE);
			msg->AddInt32("display mode", OBJECT_DISPLAY_SMALL);
			BMenuItem	*item = new BMenuItem("Small", msg);
			qMenu->AddItem(item);
			item->SetTarget(this);
		
			msg = new BMessage(SET_DISPLAY_MODE);
			msg->AddInt32("display mode", OBJECT_DISPLAY_BIG);
			item = new BMenuItem("Large", msg);
			qMenu->AddItem(item);
			item->SetTarget(this);
		
			qMenu->SetAsyncAutoDestruct(true);
			qMenu->Go(where, true, false, true);
		} else {
			msg = new BMessage(MOVE_OBJECT);
		 	msg->AddPointer("sym_object", this);
		 	
			if (mods & B_SHIFT_KEY) {
				((ObjectViewContainer *)Parent())->AddSelection(this);
			} else {
				((ObjectViewContainer *)Parent())->Select(this);
			}
		
			DragMessage(msg, area);
		}
	} else if (clicks > 1) {	// edit object
		Edit();
	} else {
	}
}
예제 #17
0
파일: URLView.cpp 프로젝트: bbjimmy/YAB
void URLView::MouseUp( BPoint point ) {
	// If the link isn't enabled, don't do anything.
	if( !IsEnabled() )
		return;

	// Do we want to show the right-click menu?
	if( inPopup  &&  GetTextRect().Contains( point ) ) {
		BPopUpMenu *popup = CreatePopupMenu();
			// Work around a current bug in Be's popup menus.
			point.y = point.y - 6;
			
			// Display the popup menu.
			BMenuItem *selected = popup->Go( ConvertToScreen( point ) , false, true );
			
			// Did the user select an item?
			if( selected ) {
				BString label( selected->Label() );
				// Did the user select the first item?  If so, launch the URL.
				if( label.FindFirst( "Open" ) != B_ERROR  ||
					label.FindFirst( "Send" ) != B_ERROR  ||
					label.FindFirst( "Connect" ) != B_ERROR ) {
					LaunchURL();
				}
				// Did the user select the second item?
				else if( label.FindFirst( "Copy" ) != B_ERROR ) {
					CopyToClipboard();
				}
			}
			// If not, restore the normal link color.
			else {
				SetHighColor( color );
				Redraw();
			}
		}

	// If the link was clicked on (and not dragged), run the program
	// that should handle the URL.
	if( selected  &&  GetTextRect().Contains( point )  &&
		!draggedOut  &&  !inPopup ) {
		LaunchURL();
	}
	selected = false;
	draggedOut = false;
	inPopup = false;
	
	// Should we restore the hovering-highlighted color or the original
	// link color?
	if( GetTextRect().Contains( point )  &&  !draggedOut  &&
		!inPopup  &&  hoverEnabled ) {
		SetHighColor( hoverColor );
	}
	else if( !hovering ) SetHighColor( color );
	Redraw();
}
예제 #18
0
void _AmPropertiesField::MouseDown(BPoint where)
{
	if (mMenu) {
		BRect	b = Bounds();
		DrawDepressedBackground(b);
		BPoint	pt(b.left, b.bottom);
		BRect	r(pt, pt);
		if (mMenuTarget) mMenuTarget->ControlActivated(0);
		mMenu->Go(ConvertToScreen(pt), true, false, ConvertToScreen(r));
		Invalidate();
	}
}
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();
	}
}
예제 #20
0
void
DeskbarView::MouseDown(BPoint pos)
{
	Looper()->CurrentMessage()->FindInt32("buttons", &fLastButtons);

	if ((fLastButtons & B_SECONDARY_MOUSE_BUTTON) != 0) {
		ConvertToScreen(&pos);

		BPopUpMenu* menu = _BuildMenu();
		menu->Go(pos, true, true, BRect(pos.x - 2, pos.y - 2,
			pos.x + 2, pos.y + 2), true);
	}
}
예제 #21
0
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");
}
예제 #22
0
void BWebPage::handleMouseEvent(const BMessage* message)
{
    WebCore::Frame* frame = fMainFrame->Frame();
    if (!frame->view() || !frame->document())
        return;

    PlatformMouseEvent event(message);
    switch (message->what) {
    case B_MOUSE_DOWN:
        // Handle context menus, if necessary.
        if (event.button() == RightButton) {
            fPage->contextMenuController()->clearContextMenu();

            WebCore::Frame* focusedFrame = fPage->focusController()->focusedOrMainFrame();
            focusedFrame->eventHandler()->sendContextMenuEvent(event);
            // If the web page implements it's own context menu handling, then
            // the contextMenu() pointer will be zero. In this case, we should
            // also swallow the event.
            ContextMenu* contextMenu = fPage->contextMenuController()->contextMenu();
            if (contextMenu) {
            	BMenu* platformMenu = contextMenu->releasePlatformDescription();
            	if (platformMenu) {
            		// Need to convert the BMenu into BPopUpMenu.
	            	BPopUpMenu* popupMenu = new BPopUpMenu("context menu");
					for (int32 i = platformMenu->CountItems() - 1; i >= 0; i--) {
					    BMenuItem* item = platformMenu->RemoveItem(i);
					    popupMenu->AddItem(item, 0);
					}
					BPoint screenLocation(event.globalPosition().x() + 2,
					    event.globalPosition().y() + 2);
            	    popupMenu->Go(screenLocation, true, true, true);
            	    delete platformMenu;
            	}
            }
            break;
    	}
    	// Handle regular mouse events.
        frame->eventHandler()->handleMousePressEvent(event);
        break;
    case B_MOUSE_UP:
        frame->eventHandler()->handleMouseReleaseEvent(event);
        break;
    case B_MOUSE_MOVED:
    default:
        frame->eventHandler()->mouseMoved(event);
        break;
    }
}
예제 #23
0
void
GLObject::MenuInvoked(BPoint point)
{
	BPopUpMenu* m = new BPopUpMenu("Object",false,false);
	BMenuItem* i;

	int c = 1;
	m->AddItem(i = new BMenuItem("White",NULL));
	if (color == c++)
		i->SetMarked(true);
	m->AddItem(i = new BMenuItem("Yellow",NULL));
	if (color == c++)
		i->SetMarked(true);
	m->AddItem(i = new BMenuItem("Blue",NULL));
	if (color == c++)
		i->SetMarked(true);
	m->AddItem(i = new BMenuItem("Red",NULL));
	if (color == c++)
		i->SetMarked(true);
	m->AddItem(i = new BMenuItem("Green",NULL));
	if (color == c++)
		i->SetMarked(true);
	m->AddSeparatorItem();

	c = 0;
	m->AddItem(i = new BMenuItem("Solid",NULL));
	if (solidity == c++)
		i->SetMarked(true);
	m->AddItem(i = new BMenuItem("Translucent",NULL));
	if (solidity == c++)
		i->SetMarked(true);
	m->AddItem(i = new BMenuItem("Transparent",NULL));
	if (solidity == c++)
		i->SetMarked(true);

	i = m->Go(point);
	int32 index = m->IndexOf(i);
	delete m;
	
	if (index < 5) {
		color = index+1;
	} else if (index > 5) {
		solidity = index-6;
	}
	changed = true;
	setEvent(fObjView->drawEvent);
}
예제 #24
0
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);
}
예제 #25
0
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);
}
예제 #26
0
파일: WatchView.cpp 프로젝트: DonCN/haiku
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;
}
예제 #27
0
void SeqToolBarView::ShowPropertyMenu(const AmTool* tool, BPoint where)
{
	BPopUpMenu*			menu = new BPopUpMenu("properties menu");
	if (!menu) return;
	BMessage*			msg = new BMessage(PROPERTIES_MSG);
	if (msg) {
		msg->AddString("tool_key", tool->Key() );
		BMenuItem*		item = new BMenuItem("Properties", msg);
		if (item) {
			item->SetTarget(this);
			menu->AddItem(item);
		}
	}
	msg = new BMessage(EDIT_MSG);
	if (msg) {
		msg->AddString("tool_key", tool->Key() );
		msg->AddString("path", tool->LocalFilePath() );
		BMenuItem*		item = new BMenuItem("Edit", msg);
		if (item) {
			item->SetTarget(this);
			if (tool->IsReadOnly() ) item->SetEnabled(false);
			menu->AddItem(item);
		}
	}

	menu->AddSeparatorItem();

	msg = new BMessage(REMOVE_FROM_TOOL_BAR_MSG);
	if (msg) {
		msg->AddString("tool_key", tool->Key() );
		msg->AddPointer("tool_id", tool->Id() );
		BMenuItem*		item = new BMenuItem("Remove From Tool Bar", msg);
		if (item) {
			item->SetTarget(this);
			menu->AddItem(item);
		}
	}

	menu->SetAsyncAutoDestruct(true);
	where = ConvertToScreen(where);
	BRect	sticky(where.x-5, where.y-5, where.x+5, where.y+5);
	menu->Go(where, true, false, sticky, true);
}
예제 #28
0
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);
    }
}
예제 #29
0
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);
	}
}
예제 #30
0
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);
	}
}