コード例 #1
0
bool HyperLinkManager::doHyperLinkByMouseRight(const Window* pOwnerWindow,const Point& position)
{

	HyperLinkNameRegistry::const_iterator itCur, itEnd;
	HyperLink nHyperLink;

	itCur		= d_HyperLinkNameMap.begin();
	itEnd		= d_HyperLinkNameMap.end();

	while ( itCur != itEnd )
	{
		nHyperLink = itCur->second;

		if(nHyperLink.isInRange(pOwnerWindow,position))
		{
			HyperLinkEventArgs e(pOwnerWindow->getName(), nHyperLink.d_name);

			fireEvent(EventHyperLinkRightActive, e, EventNamespace);
			return true;
		}

		itCur++;
	}
	return false;

}
コード例 #2
0
	bool HyperLinkManager::isHyperLinkRange(const Window* pOwnerWindow, const Point& position)
	{
		HyperLinkNameRegistry::const_iterator itCur, itEnd;
		HyperLink nHyperLink;

		itCur		= d_HyperLinkNameMap.begin();
		itEnd		= d_HyperLinkNameMap.end();
		Rect rectRange;
		while ( itCur != itEnd )
		{
			nHyperLink = itCur->second;

			if(nHyperLink.isInRange(pOwnerWindow,position, &rectRange))
			{
				d_lastMouseInLinkName = nHyperLink.d_name;
				d_lastMouseInLinkWindow = (Window*)pOwnerWindow;

				HyperLinkEventArgs e(pOwnerWindow->getName(), nHyperLink.d_name);

				fireEvent(EventHyperLinkInactive, e, EventNamespace);		
				return true;
			}

			if( d_lastMouseInLinkWindow == pOwnerWindow && d_lastMouseInLinkName == nHyperLink.d_name)
			{
				d_lastMouseInLinkWindow = NULL;
				d_lastMouseInLinkName = "";
			}

			itCur++;
		}
		return false;
	}
コード例 #3
0
	void HyperLinkManager::addHyperLink(const Window* OwnerWindow,const String32 name, const Rect hyper_rect , utf32& ocolor)
	{
		// first ensure name uniqueness

		HyperLinkNameRegistry::iterator pos = d_HyperLinkNameMap.find(name);

		if (pos != d_HyperLinkNameMap.end())
		{
			pos->second.addNewRect(OwnerWindow,hyper_rect);
		}
		else
		{
			HyperLink newHyperLink;
			newHyperLink.CleanUp();
			newHyperLink.d_name = name;
			newHyperLink.addNewRect(OwnerWindow,hyper_rect);

			d_HyperLinkNameMap[name] = newHyperLink;
		}
		//如果鼠标在某个超级链接上,那么修改颜色
		if (name == d_lastMouseInLinkName && d_lastMouseInLinkWindow  ==  OwnerWindow)
		{
			ocolor = 0xFF0000FF;
		}
		return;
	}
コード例 #4
0
ファイル: TermViewStates.cpp プロジェクト: AmirAbrams/haiku
void
TermView::HyperLinkMenuState::Prepare(BPoint point, const HyperLink& link)
{
	fLink = link;

	// open context menu
	PopUpMenu* menu = new PopUpMenu(fView);
	BLayoutBuilder::Menu<> menuBuilder(menu);
	switch (link.GetType()) {
		case HyperLink::TYPE_URL:
			menuBuilder
				.AddItem(B_TRANSLATE("Open link"), kMessageOpenLink)
				.AddItem(B_TRANSLATE("Copy link location"), kMessageCopyLink);
			break;

		case HyperLink::TYPE_PATH:
		case HyperLink::TYPE_PATH_WITH_LINE:
		case HyperLink::TYPE_PATH_WITH_LINE_AND_COLUMN:
			menuBuilder.AddItem(B_TRANSLATE("Open path"), kMessageOpenLink);
			menuBuilder.AddItem(B_TRANSLATE("Copy path"), kMessageCopyLink);
			if (fLink.Text() != fLink.Address()) {
				menuBuilder.AddItem(B_TRANSLATE("Copy absolute path"),
					kMessageCopyAbsolutePath);
			}
			break;
	}
	menu->SetTargetForItems(fView);
	menu->Go(fView->ConvertToScreen(point), true, true, true);
}
コード例 #5
0
ファイル: TermViewStates.cpp プロジェクト: AmirAbrams/haiku
void
TermView::HyperLinkState::MouseDown(BPoint where, int32 buttons,
	int32 modifiers)
{
	TermPos start;
	TermPos end;
	HyperLink link;

	bool pathPrefixOnly = (modifiers & B_SHIFT_KEY) != 0;
	if (!_GetHyperLinkAt(where, pathPrefixOnly, link, start, end))
		return;

	if ((buttons & B_PRIMARY_MOUSE_BUTTON) != 0) {
		link.Open();
	} else if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) {
		fView->fHyperLinkMenuState->Prepare(where, link);
		fView->_NextState(fView->fHyperLinkMenuState);
	}
}
コード例 #6
0
void HyperLinkManager::addHyperLink(const Window* OwnerWindow,const String name, const Rect hyper_rect )
{
	// first ensure name uniqueness

	HyperLinkNameRegistry::iterator pos = d_HyperLinkNameMap.find(name);

	if (pos != d_HyperLinkNameMap.end())
	{
		pos->second.addNewRect(OwnerWindow,hyper_rect);
	}
	else
	{
		HyperLink newHyperLink;
		newHyperLink.CleanUp();
		newHyperLink.d_name = name;
		newHyperLink.addNewRect(OwnerWindow,hyper_rect);

		d_HyperLinkNameMap[name] = newHyperLink;
	}
		return;
}
コード例 #7
0
String HyperLinkManager::getHyperLinkContex(const Window* pOwnerWindow, const Point& position)
{
	HyperLinkNameRegistry::const_iterator itCur, itEnd;
	HyperLink nHyperLink;

	itCur		= d_HyperLinkNameMap.begin();
	itEnd		= d_HyperLinkNameMap.end();

	while ( itCur != itEnd )
	{
		nHyperLink = itCur->second;

		if(nHyperLink.isInRange(pOwnerWindow,position))
		{
			HyperLinkEventArgs e(pOwnerWindow->getName(), nHyperLink.d_name);
			return nHyperLink.d_name;
		}

		itCur++;
	}
	return "";
}