当前位置: 首页>>代码示例>>C++>>正文


C++ Window::getParent方法代码示例

本文整理汇总了C++中cegui::Window::getParent方法的典型用法代码示例。如果您正苦于以下问题:C++ Window::getParent方法的具体用法?C++ Window::getParent怎么用?C++ Window::getParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cegui::Window的用法示例。


在下文中一共展示了Window::getParent方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: moveWindow

//只改变位置不改变大小
void CUIEditorView::moveWindow(CPoint point,CPoint step,CEGUI::Window* pWin/* = NULL*/)
{
	CEGUI::Window* pWindow =  pWin ? pWin : m_pSelectedWindow;
	if (pWindow)
	{
		//方向键操作
		if ( step.x != 0 || step.y != 0 )
		{
			CEGUI::Point pos = pWindow->getAbsolutePosition();
			pos.d_x += step.x;
			pos.d_y += step.y;
			pWindow->setPosition(CEGUI::Absolute, pos);
		}
		//鼠标操作
		else
		{
			CEGUI::Window* pParent = pWindow;
			CEGUI::Point pt = CEGUI::Point(point.x, point.y);
			if (pWindow->getParent() == CEGUI::System::getSingleton().getGUISheet())
			{
				pParent = pWindow->getParent();
				CEGUI::Point pointWindow = pWindow->getPixelRect().getPosition();
				//初始化位置
				if(m_ptMouseMovePos.x == 0 && m_ptMouseMovePos.y == 0)
				{
					m_ptMouseMovePos.x = point.x -  pointWindow.d_x;
					m_ptMouseMovePos.y = point.y -  pointWindow.d_y;
				}
				pt.d_x -= m_ptMouseMovePos.x;
				pt.d_y -= m_ptMouseMovePos.y;
			}
			else
			{
				while (pParent && pParent->getParent() != CEGUI::System::getSingleton().getGUISheet())
				{
					pParent = pParent->getParent();
				}
				CEGUI::Point pointParent = pParent->getPixelRect().getPosition();
				CEGUI::Point pointWindow = pWindow->getPixelRect().getPosition();
				//初始化位置
				if(m_ptMouseMovePos.x == 0 && m_ptMouseMovePos.y == 0)
				{
					m_ptMouseMovePos.x = point.x -  pointWindow.d_x;
					m_ptMouseMovePos.y = point.y -  pointWindow.d_y;
				}
				pt = CEGUI::Point(point.x-pointParent.d_x /*+pointWindow.d_x*/ - m_ptMouseMovePos.x, 
					point.y - pointParent.d_y/* +pointWindow.d_y*/ - m_ptMouseMovePos.y);
			}
			pWindow->setClippedByParent(true);
			pWindow->setPosition(CEGUI::Absolute, pt);
		}
	}
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:54,代码来源:UIEditorView.cpp

示例2: Input_InputModeChanged

void ActiveWidgetHandler::Input_InputModeChanged(Input::InputMode mode)
{
	if (mode != Input::IM_GUI && mLastMode == Input::IM_GUI) {
		//save the current active widget
		CEGUI::Window* window = mGuiManager.getMainSheet()->getActiveChild();
		if (window) {
			mLastActiveWindow = window;
			mLastActiveWindowDestructionStartedConnection = window->subscribeEvent(CEGUI::Window::EventDestructionStarted, CEGUI::Event::Subscriber(&ActiveWidgetHandler::lastActiveWindowDestructionStarted, this));
			window->deactivate();
			//deactivate all parents
			while ((window = window->getParent())) {
				window->deactivate();
			}
		} else {
			mLastActiveWindow = nullptr;
		}
		mLastMode = mode;
	} else if (mode == Input::IM_GUI) {
		if (mLastActiveWindow) {
			//restore the previously active widget
			try {
				mLastActiveWindow->activate();
			} catch (...)
			{
				S_LOG_WARNING("Error when trying to restore previously captured window.");
			}
			mLastActiveWindow = 0;
			mLastActiveWindowDestructionStartedConnection->disconnect();
		}
		mLastMode = mode;
	}
}
开发者ID:Chimangoo,项目名称:ember,代码行数:32,代码来源:ActiveWidgetHandler.cpp

示例3: OnRButtonDown

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);
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:29,代码来源:UIEditorView.cpp

示例4: OnPlayerShopBuyNumChange

bool OnPlayerShopBuyNumChange(const CEGUI::EventArgs& e)
{
	CEGUI::Window* wnd = WEArgs(e).window;
	if(!wnd) return false;

	CEGUI::String buyNum = wnd->getText();
	char str[32] = "";

	CEGUI::Window* goodsWnd = wnd->getParent();
	if (goodsWnd)
	{	
		CGoods* goods = static_cast<CGoods*>(goodsWnd->getUserData());
		if (!goods) return false;

		PlayerShop::tagGoodsItem* pGoodsItem = GetPlayerShop().FindtagGoods(goods);
		if (pGoodsItem!=NULL)
		{
			ulong num = atoi(buyNum.c_str());

			if (num>=pGoodsItem->groupNum)
			{
				sprintf(str,"%d",pGoodsItem->groupNum);
			}
			else if (num<=0)
			{
				sprintf(str,"%d",0);
			}
				sprintf(str,"%d",num);
			wnd->setText(ToCEGUIString(str));
			pGoodsItem->readyTradeNum = num;	
		}
	}
	return true;
}
开发者ID:xiongshaogang,项目名称:mmo-resourse,代码行数:34,代码来源:PlayerShopPage.cpp

示例5: setWindowSelected

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)
	{
		
	}
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:56,代码来源:UIEditorView.cpp

示例6: OnEventKeyDown

bool TabNavigation::OnEventKeyDown(const CEGUI::EventArgs& e)
{
	const CEGUI::KeyEventArgs& args = static_cast<const CEGUI::KeyEventArgs&>(e);
	if (args.scancode == CEGUI::Key::Tab) // Tab or Shift+Tab
	{
		WidgetList::iterator itCurrent = Containers::find(mTabOrder.begin(), mTabOrder.end(), args.window);
		OC_ASSERT(itCurrent != mTabOrder.end());
		WidgetList::iterator itFocus = itCurrent;
		CEGUI::Window* newWidget = 0;
		do
		{
			if (args.sysKeys & CEGUI::Shift)
			{
				// Set previous
				if (itFocus == mTabOrder.begin())
					itFocus = mTabOrder.end();
				--itFocus;
			}
			else
			{
				// Set next
				++itFocus;
				if (itFocus == mTabOrder.end())
					itFocus = mTabOrder.begin();
			}
			newWidget = *itFocus;
		}
		while ((!newWidget->isVisible() || newWidget->isDisabled() || newWidget->getProperty("ReadOnly") == "True" ) && itFocus != itCurrent);
		newWidget->activate();

		// Make sure active widget will be visible
		if (mScrollablePane)
		{
			CEGUI::Window* w = newWidget;
			CEGUI::Vector2 widgetOffset(0, 0);
			do
			{
				widgetOffset += w->getPosition().asAbsolute(w->getParentPixelSize());
				w = w->getParent();
			}
			while (w != mScrollablePane && w != 0);

			float32 scrollViewTop = mScrollablePane->getContentPaneArea().getSize().d_height * mScrollablePane->getVerticalScrollPosition();
			float32 scrollViewBottom = scrollViewTop + mScrollablePane->getClipRect().getHeight();
			
			if (widgetOffset.d_y < scrollViewTop || widgetOffset.d_y + newWidget->getPixelSize().d_height > scrollViewBottom)
			{
				// We need to scroll
				mScrollablePane->setVerticalScrollPosition(widgetOffset.d_y / mScrollablePane->getContentPaneArea().getSize().d_height);
			}
		}

		return true;
	}
	return false;
}
开发者ID:Ocerus,项目名称:Ocerus,代码行数:56,代码来源:TabNavigation.cpp

示例7: sizingWindow

//只改变大小,不改变位置
void CUIEditorView::sizingWindow(CPoint point,INT type,CEGUI::Window* pWin/* = NULL*/)
{
	CEGUI::Window* pWindow =  pWin ? pWin : m_pSelectedWindow;
	if (pWindow)
	{
		CEGUI::Window* pParent = pWindow;
		CEGUI::Size pt(0,0);
		if (pWindow->getParent() == CEGUI::System::getSingleton().getGUISheet())
		{
			CEGUI::Point pos = pWindow->getPixelRect().getPosition();
			pt = CEGUI::Size(point.x - pos.d_x, point.y - pos.d_y);
		}
		else
		{
			while (pParent && pParent->getParent() != CEGUI::System::getSingleton().getGUISheet())
			{
				pParent = pParent->getParent();
			}
			CEGUI::Rect	 rectWindow = pWindow->getPixelRect();
			pt = CEGUI::Size(point.x -rectWindow.getPosition().d_x   ,point.y -rectWindow.getPosition().d_y);
		}
		pWindow->setClippedByParent(true);
		if(type == 0)
		{
			pWindow->setHeight(CEGUI::Absolute,pt.d_height);
		}
		else if (type == 1)
		{
			pWindow->setWidth(CEGUI::Absolute,pt.d_width);
		}
		else
		{
			pWindow->setSize(CEGUI::Absolute, pt);
		}
	}
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:37,代码来源:UIEditorView.cpp

示例8: RemoveLinkBtnFromWindow

void LinkButtonParser::RemoveLinkBtnFromWindow(CEGUI::Window *Wnd)
{
    mapLinkInfo::iterator iterInfo = LinkMap.begin();
    while(iterInfo != LinkMap.end())
    {
        CEGUI::Window *pChildWin = iterInfo->first;

        if (Wnd == pChildWin->getParent())
        {
            pChildWin->destroy();
            iterInfo = LinkMap.erase(iterInfo);
            continue;
        }
        ++iterInfo;
    }
}
开发者ID:xiongshaogang,项目名称:mmo-resourse,代码行数:16,代码来源:LinkButtonParser.cpp

示例9: OnPlayerShopSubBuyNum

bool OnPlayerShopSubBuyNum(const CEGUI::EventArgs& e)
{
	CEGUI::Window* wnd = WEArgs(e).window;
	if(!wnd) return false;

	CEGUI::Window* goodsWnd = wnd->getParent();
	if (goodsWnd)
	{	
		CGoods* goods = static_cast<CGoods*>(goodsWnd->getUserData());
		if (!goods) return false;

		PlayerShop::tagGoodsItem* pGoodsItem = GetPlayerShop().FindtagGoods(goods);
		if (pGoodsItem!=NULL)
		{
			char str[32];
			// 取得输入框控件名
			CEGUI::String name = wnd->getName();
			name.assign(name, 0, name.find_last_of("/"));
			name += "/BuyNum";

			CEGUI::Window* buyNumWnd = GetWndMgr().getWindow(name);
			int num = atoi(buyNumWnd->getText().c_str());

			if (num<=0)
			{
				sprintf(str,"%d",0);
				wnd->disable();
			}
			else
				sprintf(str,"%d",num--);
			buyNumWnd->setText(ToCEGUIString(str));
			pGoodsItem->readyTradeNum = num;	
		}
	}

	return true;
}
开发者ID:xiongshaogang,项目名称:mmo-resourse,代码行数:37,代码来源:PlayerShopPage.cpp

示例10: AlignSpaceBetween

//nikai 2010.9.3
void SelectionMover::AlignSpaceBetween(int PaddingValue, const PaddingAlign al)
{
    // Validations
    wxASSERT_MSG(m_selection != NULL, wxT("Selection member is NULL"));

    if(m_selection->Size() <= 1) 
    {
        // Should not happen because of the disabled menu/toolbar item in this case
        LogWarning(wxT("You must select more than one window to align!"));
        return;
    }
    // The first selected window is the one to match. This is for example how Visual Studio's 
    // dialog editor works as well.
    Selection::Boxes::iterator boxIt = m_selection->GetMoveableBoxes().begin();

    const CEGUI::Window *current = boxIt->GetWindow();
            
    CEGUI::Window *pParentWin = current->getParent();
    if(NULL == pParentWin)
    {
        LogWarning(wxT("You can't operate the root window!"));
        wxMessageBox(L"You can't operate the root window!");
        return;
    }
    const long ParentX = CEGUI::CoordConverter::windowToScreenX(*pParentWin,0);
    const long ParentY = CEGUI::CoordConverter::windowToScreenY(*pParentWin,0);
    const long parentWidth = pParentWin->getPixelSize().d_width;
    const long parentHeight = pParentWin->getPixelSize().d_height;

    const CEGUI::URect rect = current->getArea();
    ++boxIt;
    
    for(; boxIt != m_selection->GetMoveableBoxes().end(); ++boxIt) {
        // Deny when it is blocked
        if (boxIt->IsLocked())
        {
            wxMessageBox(L"all the select window ¡¯s can't be locked£¡");
            return;
        }
        CEGUI::Window* curWin = boxIt->GetWindow();
        if (pParentWin != curWin->getParent())
        {
            wxMessageBox(L"all the select window ¡¯s parent must be same£¡");
            return;
        }
    }
    //»Ö¸´µü´úÆ÷λÖÃ
    //boxIt = m_selection->GetMoveableBoxes().begin(); 
    //++boxIt;
    //float lWidth  = current->getPixelSize().d_width;
    //float lHeight = current->getPixelSize().d_height;
    //float RightPos = CEGUI::CoordConverter::windowToScreenX(*current,0)+lWidth;
    //float BottomPos = CEGUI::CoordConverter::windowToScreenY(*current,0)+lHeight;
    //
    //for(; boxIt != m_selection->GetMoveableBoxes().end(); ++boxIt)
    //{
    //    CEGUI::Window* curWin = boxIt->GetWindow();
    //    CEGUI::UDim xPos = curWin->getXPosition();
    //    CEGUI::UDim yPos = curWin->getYPosition();
    //    switch(al)
    //    {
    //    case HorzPadding:
    //        {
    //            float newXPixel = RightPos + PaddingValue;
    //            float xscale = (newXPixel-ParentX)/parentWidth;
    //            xPos = CEGUI::UDim(xscale,0);
    //            break;
    //        }
    //    case VertPadding:
    //        {
    //            float newYPixel = BottomPos + PaddingValue;
    //            float yscale = (newYPixel-ParentY)/parentHeight;
    //            yPos = CEGUI::UDim(yscale,0);
    //            break;
    //        }
    //    default:
    //        LogError(wxT("SelectionMover::AlignSelection - Unrecognized align option (%d)"), al);
    //        return;
    //    }
    //    curWin->setPosition(CEGUI::UVector2(xPos,yPos));
    //    lWidth  = curWin->getPixelSize().d_width;
    //    lHeight = curWin->getPixelSize().d_height;
    //    RightPos = CEGUI::CoordConverter::windowToScreenX(*curWin,0)+lWidth;
    //    BottomPos = CEGUI::CoordConverter::windowToScreenY(*curWin,0)+lHeight;
    //}
    //// Request for a repaint
    //wxGetApp().GetMainFrame()->Refresh();
    boxIt = m_selection->GetMoveableBoxes().begin(); 
    ++boxIt;
    float newPixelWidth  = current->getPixelSize().d_width;
    float newPixelHeight = current->getPixelSize().d_height;
    float RightPos = CEGUI::CoordConverter::windowToScreenX(*current,0)+newPixelWidth;
    float BottomPos = CEGUI::CoordConverter::windowToScreenY(*current,0)+newPixelHeight;

    for(; boxIt != m_selection->GetMoveableBoxes().end(); ++boxIt)
    {
        CEGUI::Window* curWin = boxIt->GetWindow();
        float fLeft = CEGUI::CoordConverter::windowToScreenX(*curWin,0);
        float fTop  = CEGUI::CoordConverter::windowToScreenY(*curWin,0);
//.........这里部分代码省略.........
开发者ID:xiongshaogang,项目名称:mmo-resourse,代码行数:101,代码来源:SelectionMover.cpp


注:本文中的cegui::Window::getParent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。