本文整理汇总了C++中CControl::CalcSizeFromMouse方法的典型用法代码示例。如果您正苦于以下问题:C++ CControl::CalcSizeFromMouse方法的具体用法?C++ CControl::CalcSizeFromMouse怎么用?C++ CControl::CalcSizeFromMouse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CControl
的用法示例。
在下文中一共展示了CControl::CalcSizeFromMouse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessMouseEvent
void CUIViewAgent::ProcessMouseEvent( wxMouseEvent& event )
{
__super::ProcessMouseEvent(event);
wxPoint MousePos = event.GetPosition();
CRenderTarget* pRenderWnd = CRenderManager::GetInstance()->GetCurrentRenderTarget();
wxGLRenderWindow* pSceneRenderWnd = down_cast<wxGLRenderWindow*>(pRenderWnd);
BEATS_ASSERT(pSceneRenderWnd != NULL);
float fScale = pSceneRenderWnd->IsFBOInUse() ? (float)pSceneRenderWnd->GetFBOViewPortWidth() / pSceneRenderWnd->GetWidth() : pSceneRenderWnd->GetScaleFactor();
MousePos.x /= fScale;
MousePos.y /= fScale;
if(event.ButtonDown(wxMOUSE_BTN_LEFT))
{
if (m_pMainFrame->m_nCursorIconID == wxCURSOR_ARROW)
{
CComponentBase* pSelectedComponent = CWindowManager::GetInstance()->GetControl(MousePos.x, MousePos.y);
CComponentProxy* pProxy = NULL;
if (pSelectedComponent)
{
pProxy = (CComponentProxy*)CComponentProxyManager::GetInstance()->GetComponentInstance(pSelectedComponent->GetId(), pSelectedComponent->GetGuid());
}
if (m_pMainFrame->m_pSelectedComponentProxy != pProxy)
{
m_pMainFrame->SelectComponent(pProxy);
}
}
if (m_pMainFrame->m_pSelectedComponentProxy != NULL)
{
kmVec2 kmVec2Pos;
kmVec2Fill(&kmVec2Pos, 0, 0);
((CControl*)m_pMainFrame->m_pSelectedComponentProxy->GetHostComponent())->LocalToWorld(kmVec2Pos.x, kmVec2Pos.y);
m_pMainFrame->m_activeGUIPosOffset = wxPoint(kmVec2Pos.x - MousePos.x, kmVec2Pos.y - MousePos.y);
}
UpdateCursorIcon(MousePos);
((wxWindow*)m_pMainFrame->m_pViewScreen)->SetCursor(m_pMainFrame->m_nCursorIconID);
}
else if(event.ButtonDown(wxMOUSE_BTN_RIGHT))
{
m_pMainFrame->SelectComponent(NULL);
UpdateCursorIcon(MousePos);
((wxWindow*)m_pMainFrame->m_pViewScreen)->SetCursor(m_pMainFrame->m_nCursorIconID);
}
else if(event.Dragging())
{
if (m_pMainFrame->m_pSelectedComponentProxy)
{
wxString propertyName;
int nHitTestRet = m_pMainFrame->m_nHitTestRet;
if (nHitTestRet == CControl::eHTR_HIT_CONTENT || nHitTestRet == CControl::eHTR_HIT_EDGE)
{
propertyName = _T("m_pos");
}
else if (nHitTestRet > CControl::eHTR_HIT_CONTENT && nHitTestRet < CControl::eHTR_HIT_ANCHOR)
{
propertyName = _T("m_vecSize");
}
else
{
propertyName = _T("");
}
if (!propertyName.IsEmpty())
{
CWxwidgetsPropertyBase* pPropertyDescription = static_cast<CWxwidgetsPropertyBase*>(m_pMainFrame->m_pSelectedComponentProxy->GetPropertyDescription(propertyName));
BEATS_ASSERT(pPropertyDescription != NULL);
CControl* pWindow = dynamic_cast<CControl*>(m_pMainFrame->m_pSelectedComponentProxy->GetHostComponent());
BEATS_ASSERT(pWindow != NULL);
if (nHitTestRet == CControl::eHTR_HIT_CONTENT || nHitTestRet == CControl::eHTR_HIT_EDGE)
{
kmScalar posX = MousePos.x + m_pMainFrame->m_activeGUIPosOffset.x;
kmScalar posY = MousePos.y + m_pMainFrame->m_activeGUIPosOffset.y;
kmVec2 pos = pWindow->CalcPosFromMouse(posX, posY);
SetkmVec2PropertyValue(pPropertyDescription, pos);
}
else if (nHitTestRet > CControl::eHTR_HIT_CONTENT && nHitTestRet < CControl::eHTR_HIT_ANCHOR)
{
kmVec2 size = pWindow->CalcSizeFromMouse(MousePos.x, MousePos.y, (CControl::EHitTestResult)nHitTestRet);
SetkmVec2PropertyValue(pPropertyDescription, size);
}
}
}
}
else if(event.Moving())
{
UpdateCursorIcon(MousePos);
}
}