Ejemplo n.º 1
0
void CUIEditorView::OnRButtonDown(UINT nFlags, CPoint point)
{
	g_CoreSystem.getCEGUISystem()->injectMousePosition(point.x, point.y);
	g_CoreSystem.getCEGUISystem()->injectMouseButtonDown(CEGUI::RightButton);

	if( getShowMode() == false ) return;

	CMenu menu;
	menu.CreatePopupMenu();
	CEGUI::Window* mouseWindow = g_CoreSystem.getCEGUISystem()->getWindowContainingMouse();
	bool showMenu = false;
	INT menuId = ID_RIGHT_WINDOW_SELECT;
	for ( ; mouseWindow ; mouseWindow = mouseWindow->getParent(),++menuId )
	{
		if (mouseWindow != CEGUI::System::getSingleton().getGUISheet() && !mouseWindow->isAutoWindow())
		{
			menu.AppendMenu(MF_STRING, menuId,mouseWindow->getName().c_str());
			showMenu = true;
		}		
	}
	if (showMenu)
	{
		POINT pos;
		GetCursorPos(&pos);
		menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON,pos.x, pos.y, this);
		g_DataPool.OnSelectWindowChanged(NULL, m_pSelectedWindow);
	}
	CView::OnRButtonDown(nFlags, point);
}
Ejemplo n.º 2
0
void CUIEditorView::setWindowSelected(const CEGUI::String& name,bool addEvent /*= true*/)
{
	try
	{
		if( name.length()> 0 && name != m_nSelectWindowName)
		{
			if(name == "___Shower_Window____") return;
			CEGUI::Window* pWindow = CEGUI::WindowManager::getSingleton().getWindow(name);
			CEGUI::Window* pOldSel = NULL;
			if (pWindow && !pWindow->isAutoWindow())
			{
				if(m_nSelectWindowName.length() > 0)
				{
					pOldSel = CEGUI::WindowManager::getSingleton().getWindow(m_nSelectWindowName);
					if (pOldSel)
					{
						for(;pOldSel && pOldSel != CEGUI::System::getSingleton().getGUISheet(); pOldSel = pOldSel->getParent())
						{
							pOldSel->unsubscribeEvent(CEGUI::Window::EventMoved, CEGUI::Event::Subscriber(&CUIEditorView::handleSelectedWindowMoved, this));
						}
					}
				}
				//pWindow->moveToFront();
				m_nSelectWindowName = pWindow->getName();
				CEGUI::Window* pSet = pWindow;
				for (; pSet&& pSet !=CEGUI::System::getSingleton().getGUISheet(); pSet = pSet->getParent() )
				{
					pSet->subscribeEvent(CEGUI::Window::EventMoved, CEGUI::Event::Subscriber(&CUIEditorView::handleSelectedWindowMoved, this));
				}
				CEGUI::Rect rect = pWindow->getPixelRect();
				setSelectWindowPos(CRect(rect.d_left, rect.d_top, rect.getWidth(), rect.getHeight()));
				m_ptMouseMovePos = CPoint(0,0);			
			}
			m_pSelectedWindow = pWindow;
			updateCurrentWindowStatusText();
			if (addEvent)
			{
				g_DataPool.OnSelectWindowChanged(pOldSel,pWindow);
			}
		}
		else if (name.length() == 0)
		{
			if (addEvent)
			{
				g_DataPool.OnSelectWindowChanged(m_pSelectedWindow,NULL);
			}
			m_nSelectWindowName = "";
			setSelectWindowPos(CRect(), true);
			m_pSelectedWindow = NULL;
		}
	}
	catch(CEGUI::UnknownObjectException& e)
	{
		
	}
}