void CXTPChartRangeBarSeriesLabelView::CalculateLayout(CXTPChartDeviceContext* pDC)
{
	CXTPChartRangeBarSeriesLabel* pLabel = (CXTPChartRangeBarSeriesLabel*)m_pLabel;

	if (pLabel->GetType() == xtpChartRangeBarOneLabel)
	{
		CString strText = m_pLabel->GetPointLabel(m_pPointView->GetPoint(), 0) + _T(", ") + m_pLabel->GetPointLabel(m_pPointView->GetPoint(), 1);
		CXTPChartDiagram2DSeriesLabelView::CalculateLayout(pDC, GetAnchorPoint(0), strText);
	}
	else if (pLabel->GetType() == xtpChartRangeBarTwoLabels)
	{

		CString strText = m_pLabel->GetPointLabel(m_pPointView->GetPoint(), 0);
		CXTPChartDiagram2DSeriesLabelView::CalculateLayout(pDC, GetAnchorPoint(TRUE), GetAnchorAngle(TRUE), strText);

		strText = m_pLabel->GetPointLabel(m_pPointView->GetPoint(), 1);
		CXTPChartDiagram2DSeriesLabelView::CalculateLayout(pDC, GetAnchorPoint(FALSE), GetAnchorAngle(FALSE), strText);
	}
	else if (pLabel->GetType() == xtpChartRangeBarMinValueLabel)
	{
		CString strText = m_pLabel->GetPointLabel(m_pPointView->GetPoint(), 0);
		CXTPChartDiagram2DSeriesLabelView::CalculateLayout(pDC, GetAnchorPoint(TRUE), GetAnchorAngle(TRUE), strText);
	}
	else  if (pLabel->GetType() == xtpChartRangeBarMaxValueLabel)
	{
		CString strText = m_pLabel->GetPointLabel(m_pPointView->GetPoint(), 1);
		CXTPChartDiagram2DSeriesLabelView::CalculateLayout(pDC, GetAnchorPoint(FALSE), GetAnchorAngle(FALSE), strText);
	}
}
Пример #2
0
// calculates the area of the screen the balloon falls into
// this determins which direction the tail points
CBalloonHelp::BALLOON_QUADRANT CBalloonHelp::GetBalloonQuadrant()
{
	CRect rectDesktop;
	GetAnchorScreenBounds(rectDesktop);
	CPoint ptAnchor = GetAnchorPoint();
	
	if ( ptAnchor.y < rectDesktop.top + rectDesktop.Height()/2 )
	{
		if ( ptAnchor.x < rectDesktop.left + rectDesktop.Width()/2 )
		{
			return BQ_TOPLEFT;
		}
		else
		{
			return BQ_TOPRIGHT;
		}
	}
	else
	{
		if ( ptAnchor.x < rectDesktop.left + rectDesktop.Width()/2 )
		{
			return BQ_BOTTOMLEFT;
		}
		else
		{
			return BQ_BOTTOMRIGHT;
		}
	}
	
	// unreachable
}
Пример #3
0
 void Label::Draw()
 {
     //If this assert is hit, it means there isn't a Shader set
     assert(m_Shader != nullptr);
 
     //Is the render target null
     if(m_RenderTarget != nullptr)
     {
         //Draw the render target
         m_RenderTarget->GetTextureFrame()->Draw(m_ModelMatrix);
     }
     else
     {
         //Draw the text with out the render target
         DrawText();
     }
     
     //Draw a debug label rect
     #if DRAW_LABEL_RECT
     Rect rect(GetWorldPosition().x, GetWorldPosition().y, GetWidth(), GetHeight());
     rect.SetIsFilled(false);
     rect.SetColor(DRAW_LABEL_RECT_COLOR);
     rect.SetAnchorPoint(GetAnchorPoint());
     rect.SetLocalAngle(GetWorldAngle());
     rect.SetLocalScale(GetWorldScale());
     rect.Draw();
     #endif
     
     //Draw the GameObject, which draws all the children
     GameObject::Draw();
 }
CXTPChartDeviceCommand* CXTPChartRadarPointSeriesLabelView::CreateDeviceCommand(CXTPChartDeviceContext* pDC)
{
    CXTPChartString text(m_pLabel->GetPointLabel(m_pPointView->GetPoint()));
    CXTPChartPointF ptAnchorPoint = GetAnchorPoint();

    return CreateDeviceCommand(pDC, ptAnchorPoint, GetAnchorAngle(), text);
}
void CXTPChartRadarPointSeriesLabelView::CalculateLayout(CXTPChartDeviceContext* pDC)
{
    CXTPChartString text(m_pLabel->GetPointLabel(m_pPointView->GetPoint()));
    CXTPChartPointF ptAnchorPoint = GetAnchorPoint();

    CalculateLayout(pDC, ptAnchorPoint, GetAnchorAngle(), text);
}
Пример #6
0
	//------------------------------------------------------------------------------
	void CTDWgtTower::SetGameWorld( CTDGameWorld* pGameWorld )
	{
		m_pGameWorld = pGameWorld;

		if( m_pGameTower )
		{
			delete m_pGameTower;
			m_pGameTower = NULL;
		}
		if( m_pGameWorld )
		{
			m_pGameTower = new CTDGameTower( this, m_pGameWorld, GetAnchorPoint() );
		}
	}
CXTPChartDeviceCommand* CXTPChartRangeBarSeriesLabelView::CreateDeviceCommand(CXTPChartDeviceContext* pDC)
{
	CXTPChartRangeBarSeriesLabel* pLabel = (CXTPChartRangeBarSeriesLabel*)m_pLabel;

	if (pLabel->GetType() == xtpChartRangeBarOneLabel)
	{
		CString strText = m_pLabel->GetPointLabel(m_pPointView->GetPoint(), 0) + _T(", ") + m_pLabel->GetPointLabel(m_pPointView->GetPoint(), 1);
		return CXTPChartDiagram2DSeriesLabelView::CreateDeviceCommand(pDC, GetAnchorPoint(0), strText);
	}

	if (pLabel->GetType() == xtpChartRangeBarTwoLabels)
	{
		CXTPChartDeviceCommand* pCommand = new CXTPChartDeviceCommand();

		CString strText = m_pLabel->GetPointLabel(m_pPointView->GetPoint(), 0);
		pCommand->AddChildCommand(CXTPChartDiagram2DSeriesLabelView::CreateDeviceCommand(pDC, GetAnchorPoint(TRUE), GetAnchorAngle(TRUE), strText));

		strText = m_pLabel->GetPointLabel(m_pPointView->GetPoint(), 1);
		pCommand->AddChildCommand(CXTPChartDiagram2DSeriesLabelView::CreateDeviceCommand(pDC, GetAnchorPoint(FALSE), GetAnchorAngle(FALSE), strText));

		return pCommand;
	}

	if (pLabel->GetType() == xtpChartRangeBarMinValueLabel)
	{
		CString strText = m_pLabel->GetPointLabel(m_pPointView->GetPoint(), 0);
		return CXTPChartDiagram2DSeriesLabelView::CreateDeviceCommand(pDC, GetAnchorPoint(TRUE), GetAnchorAngle(TRUE), strText);
	}

	if (pLabel->GetType() == xtpChartRangeBarMaxValueLabel)
	{
		CString strText = m_pLabel->GetPointLabel(m_pPointView->GetPoint(), 1);
		return CXTPChartDiagram2DSeriesLabelView::CreateDeviceCommand(pDC, GetAnchorPoint(FALSE), GetAnchorAngle(FALSE), strText);
	}

	return 0;
}
Пример #8
0
// determine bounds of screen anchor is on (Multi-Monitor compatibility)
void CBalloonHelp::GetAnchorScreenBounds(CRect& rect)
{
	if ( m_screenRect.IsRectEmpty() )
	{     
		// get the nearest monitor to the anchor
		HMONITOR hMonitor = MonitorFromPoint(GetAnchorPoint(), MONITOR_DEFAULTTONEAREST);
		
		// get the monitor bounds
		MONITORINFO mi;
		mi.cbSize = sizeof(mi);
		GetMonitorInfo(hMonitor, &mi);
		
		// work area (area not obscured by task bar, etc.)
		m_screenRect = mi.rcWork;
	}
	rect = m_screenRect;
}
Пример #9
0
    void Label::ResetModelMatrix()
    {
        //Translate the anchor, then translate the position
        mat4 anchor = translate(mat4(1.0f), vec3(-GetWidth() * GetWorldScale().x * GetAnchorPoint().x, -GetHeight() * GetWorldScale().y * GetAnchorPoint().y, 0.0f));
        mat4 viewTranslate = translate(anchor, vec3(GetWorldPosition().x, GetWorldPosition().y, 0.0f));

        //Calculate the rotation based on the anchor point
        mat4 halfTranslate1 = translate(viewTranslate, vec3(GetWidth() * GetWorldScale().x * GetAnchorPoint().x, GetHeight() * GetWorldScale().y * GetAnchorPoint().y, 0.0f));
        mat4 viewRotation = rotate(halfTranslate1, GetWorldAngle(), vec3(0.0f, 0.0f, 1.0f));
        mat4 halfTranslate2 = translate(viewRotation, vec3(-GetWidth() * GetWorldScale().x * GetAnchorPoint().x, -GetHeight() * GetWorldScale().y * GetAnchorPoint().y, 0.0f));
        
        //Lastly the scale
        m_ModelMatrix = scale(halfTranslate2, vec3(GetWorldScale().x, GetWorldScale().y, 0.0f));
        
        //Reset the model matrix
        GameObject::ResetModelMatrix();
    }
Пример #10
0
    void Polygon::ResetModelMatrix()
    {
        //Local variables used below
        float left = 0.0f;
        float right = 0.0f;
        float bottom = 0.0f;
        float top = 0.0f;
    
        //Cycle through and set the left, right, bottom and top vars
        for(unsigned int i = 0; i < m_Vertices.size(); i++)
        {
            left = fminf(left, m_Vertices.at(i).x);
            right = fmaxf(right, m_Vertices.at(i).x);
            bottom = fminf(bottom, m_Vertices.at(i).y);
            top = fmaxf(top, m_Vertices.at(i).y);
        }
    
        //Set the width and height
        float width = right - left;
        float height = top - bottom;

        //Translate the anchor, then translate the position
        mat4 anchor = translate(mat4(1.0f), vec3(-width * GetWorldScale().x * GetAnchorPoint().x, -height * GetWorldScale().y * GetAnchorPoint().y, 0.0f));
        mat4 viewTranslate = translate(anchor, vec3(GetWorldPosition().x, GetWorldPosition().y, 0.0f));

        //Calculate the rotation based on the anchor point
        mat4 halfTranslate1 = translate(viewTranslate, vec3(width * GetWorldScale().x * GetAnchorPoint().x, height * GetWorldScale().y * GetAnchorPoint().y, 0.0f));
        
    #if DRAW_POLYGON_ANCHOR_POINT
        vec4 transformedVector = halfTranslate1 * vec4(0.0f, 0.0f, 0.0f, 1.0);
        m_AnchorLocation = vec2(transformedVector.x, transformedVector.y);
    #endif
        
        mat4 viewRotation = rotate(halfTranslate1, GetWorldAngle(), vec3(0.0f, 0.0f, 1.0f));
        mat4 halfTranslate2 = translate(viewRotation, vec3(-width * GetWorldScale().x * GetAnchorPoint().x, -height * GetWorldScale().y * GetAnchorPoint().y, 0.0f));
        
        //Lastly the scale
        m_ModelMatrix = scale(halfTranslate2, vec3(GetWorldScale().x, GetWorldScale().y, 0.0f));
        
        //Reset the model matrix
        GameObject::ResetModelMatrix();
    }
Пример #11
0
		//----------------------------------------------------
		//----------------------------------------------------
		const Core::Sphere& SpriteComponent::GetBoundingSphere()
		{
            if(IsTextureSizeCacheValid() == false)
            {
                OnTransformChanged();
                SetTextureSizeCacheValid();
            }
            
			if(GetEntity() && m_isBSValid == false)
			{
                m_isBSValid = true;
                
                Core::Vector2 transformedSize = GetSize();
                
                // Realign the origin
                Core::Vector2 anchorPoint = GetAnchorPoint(m_originAlignment, transformedSize * 0.5f);
                
				mBoundingSphere.vOrigin = GetEntity()->GetTransform().GetWorldPosition() - Core::Vector3(anchorPoint, 0.0f);
				mBoundingSphere.fRadius = std::sqrt((transformedSize.x * transformedSize.x) + (transformedSize.y * transformedSize.y)) * 0.5f;
			}
			return mBoundingSphere;
		}
Пример #12
0
        //-----------------------------------------------------------
        /// The image from the texture atlas will have potentially
        /// been cropped by the tool. This will affect the sprites
        /// position within the uncropped image and we need to
        /// account for that when positioning the corners
        //-----------------------------------------------------------
		void SpriteComponent::UpdateVertexPositions()
        {
            Core::Vector2 frameCenter;
            Core::Vector2 frameSize;
            if(m_textureAtlas != nullptr && m_hashedTextureAtlasId > 0)
            {
                CalcFrameCentreAndSize(frameCenter, frameSize);
            }
            else if(mpMaterial != nullptr && mpMaterial->GetTexture() != nullptr)
            {
                auto texture = mpMaterial->GetTexture().get();
                frameSize = m_sizePolicyDelegate(m_originalSize, Core::Vector2((f32)texture->GetWidth(), (f32)texture->GetHeight()));
            }
            
            const Core::Matrix4& worldTransform = GetEntity()->GetTransform().GetWorldTransform();
			Core::Vector2 halfFrameSize(frameSize.x * 0.5f, frameSize.y * 0.5f);
			Core::Vector2 alignedPosition = -GetAnchorPoint(m_originAlignment, halfFrameSize);
            Core::Vector4 vertexCentre(alignedPosition.x + frameCenter.x, alignedPosition.y + frameCenter.y, 0.0f, 1.0f);
            
            //TL
            Core::Vector4 vertexOffset(-halfFrameSize.x, halfFrameSize.y, 0.0f, 0.0f);
			m_spriteData.sVerts[(u32)SpriteBatch::Verts::k_topLeft].vPos = (vertexCentre + vertexOffset) * worldTransform;
            
            //TR
            vertexOffset.x = halfFrameSize.x;
            vertexOffset.y = halfFrameSize.y;
			m_spriteData.sVerts[(u32)SpriteBatch::Verts::k_topRight].vPos = (vertexCentre + vertexOffset) * worldTransform;
            
            //BL
            vertexOffset.x = -halfFrameSize.x;
            vertexOffset.y = -halfFrameSize.y;
			m_spriteData.sVerts[(u32)SpriteBatch::Verts::k_bottomLeft].vPos = (vertexCentre + vertexOffset) * worldTransform;
            
            //BR
            vertexOffset.x = halfFrameSize.x;
            vertexOffset.y = -halfFrameSize.y;
			m_spriteData.sVerts[(u32)SpriteBatch::Verts::k_bottomRight].vPos = (vertexCentre + vertexOffset) * worldTransform;
		}
Пример #13
0
		//----------------------------------------------------
		//----------------------------------------------------
		const Core::AABB& SpriteComponent::GetAABB()
		{
            if(IsTextureSizeCacheValid() == false)
            {
                OnTransformChanged();
                SetTextureSizeCacheValid();
            }
            
			if(GetEntity() && m_isAABBValid == false)
			{
                m_isAABBValid = true;
                
                Core::Vector2 transformedSize = GetSize();
                
                // Realign the origin
                Core::Vector2 anchorPoint = GetAnchorPoint(m_originAlignment, transformedSize * 0.5f);
                
				// Rebuild the box
				mBoundingBox.SetSize(Core::Vector3(transformedSize, 0.0f));
				mBoundingBox.SetOrigin(GetEntity()->GetTransform().GetWorldPosition() - Core::Vector3(anchorPoint, 0.0f));
			}
			return mBoundingBox;
		}
Пример #14
0
 //----------------------------------------------------
 //----------------------------------------------------
 const OOBB& SpriteComponent::GetOOBB()
 {
     if(IsTextureSizeCacheValid() == false)
     {
         OnTransformChanged();
         SetTextureSizeCacheValid();
     }
     
     if(GetEntity() && m_isOOBBValid == false)
     {
         m_isOOBBValid = true;
         
         Vector2 transformedSize = GetSize();
         
         // Realign the origin
         Vector2 anchorPoint = GetAnchorPoint(m_originAlignment, transformedSize * 0.5f);
         
         // Rebuild the box
         mOBBoundingBox.SetOrigin(Vector3(-anchorPoint, 0.0f));
         mOBBoundingBox.SetSize(Vector3(transformedSize, 0.0f));
         mOBBoundingBox.SetTransform(GetEntity()->GetTransform().GetWorldTransform());
     }
     return mOBBoundingBox;
 }
Пример #15
0
// this routine calculates the size and position of the window relative
// to it's anchor point, and moves the window accordingly.  The region is also
// created and set here.
void CBalloonHelp::PositionWindow()
{
	CSize sizeWnd = CalcWindowSize();
	
	CPoint ptTail[3];
	CPoint ptTopLeft(0,0);
	CPoint ptBottomRight(sizeWnd.cx, sizeWnd.cy);
	
	// force recalculation of desktop
	m_screenRect.SetRectEmpty();
	
	switch (GetBalloonQuadrant())
	{
	case BQ_TOPLEFT:
		ptTopLeft.y = nTIP_TAIL;
		ptTail[0].x = (sizeWnd.cx-nTIP_TAIL)/4 + nTIP_TAIL;
		ptTail[0].y = nTIP_TAIL+1;
		ptTail[2].x = (sizeWnd.cx-nTIP_TAIL)/4;
		ptTail[2].y = ptTail[0].y;
		ptTail[1].x = ptTail[2].x;
		ptTail[1].y = 1;
		break;
	case BQ_TOPRIGHT:
		ptTopLeft.y = nTIP_TAIL;
		ptTail[0].x = (sizeWnd.cx-nTIP_TAIL)/4*3;
		ptTail[0].y = nTIP_TAIL+1;
		ptTail[2].x = (sizeWnd.cx-nTIP_TAIL)/4*3 + nTIP_TAIL;
		ptTail[2].y = ptTail[0].y;
		ptTail[1].x = ptTail[2].x;
		ptTail[1].y = 1;
		break;
	case BQ_BOTTOMLEFT:
		ptBottomRight.y = sizeWnd.cy-nTIP_TAIL;
		ptTail[0].x = (sizeWnd.cx-nTIP_TAIL)/4 + nTIP_TAIL;
		ptTail[0].y = sizeWnd.cy-nTIP_TAIL-2;
		ptTail[2].x = (sizeWnd.cx-nTIP_TAIL)/4;
		ptTail[2].y = ptTail[0].y;
		ptTail[1].x = ptTail[2].x;
		ptTail[1].y = sizeWnd.cy-2;
		break;
	case BQ_BOTTOMRIGHT:
		ptBottomRight.y = sizeWnd.cy-nTIP_TAIL;
		ptTail[0].x = (sizeWnd.cx-nTIP_TAIL)/4*3;
		ptTail[0].y = sizeWnd.cy-nTIP_TAIL-2;
		ptTail[2].x = (sizeWnd.cx-nTIP_TAIL)/4*3 + nTIP_TAIL;
		ptTail[2].y = ptTail[0].y;
		ptTail[1].x = ptTail[2].x;
		ptTail[1].y = sizeWnd.cy-2;
		break;
				default:
					ASSERT(FALSE);
	}
	
	// adjust for very narrow balloons
	if ( ptTail[0].x < nTIP_MARGIN )
		ptTail[0].x = nTIP_MARGIN;
	if ( ptTail[0].x > sizeWnd.cx - nTIP_MARGIN )
		ptTail[0].x = sizeWnd.cx - nTIP_MARGIN;
	if ( ptTail[1].x < nTIP_MARGIN )
		ptTail[1].x = nTIP_MARGIN;
	if ( ptTail[1].x > sizeWnd.cx - nTIP_MARGIN )
		ptTail[1].x = sizeWnd.cx - nTIP_MARGIN;
	if ( ptTail[2].x < nTIP_MARGIN )
		ptTail[2].x = nTIP_MARGIN;
	if ( ptTail[2].x > sizeWnd.cx - nTIP_MARGIN )
		ptTail[2].x = sizeWnd.cx - nTIP_MARGIN;
	
	// get window position
	CPoint ptAnchor = GetAnchorPoint();
	CPoint ptOffs(ptAnchor.x - ptTail[1].x, ptAnchor.y - ptTail[1].y);
	
	// adjust position so all is visible
	CRect rectScreen;
	GetAnchorScreenBounds(rectScreen);
	int nAdjustX = 0;
	int nAdjustY = 0;
	if ( ptOffs.x < rectScreen.left )
		nAdjustX = rectScreen.left-ptOffs.x;
	else if ( ptOffs.x + sizeWnd.cx >= rectScreen.right )
		nAdjustX = rectScreen.right - (ptOffs.x + sizeWnd.cx);
	if ( ptOffs.y + nTIP_TAIL < rectScreen.top )
		nAdjustY = rectScreen.top - (ptOffs.y + nTIP_TAIL);
	else if ( ptOffs.y + sizeWnd.cy - nTIP_TAIL >= rectScreen.bottom )
		nAdjustY = rectScreen.bottom - (ptOffs.y + sizeWnd.cy - nTIP_TAIL);
	
	// reposition tail
	// uncomment two commented lines below to move entire tail 
	// instead of just anchor point
	
	//ptTail[0].x -= nAdjustX;
	ptTail[1].x -= nAdjustX;
	//ptTail[2].x -= nAdjustX;
	ptOffs.x    += nAdjustX;
	ptOffs.y    += nAdjustY;
	
	// place window
	MoveWindow(ptOffs.x, ptOffs.y, sizeWnd.cx, sizeWnd.cy, TRUE);
	
	// apply region
	CRgn region;
	CRgn regionRound;
	CRgn regionComplete;
	region.CreatePolygonRgn(&ptTail[0], 3, ALTERNATE);
	regionRound.CreateRoundRectRgn(ptTopLeft.x,ptTopLeft.y,ptBottomRight.x,ptBottomRight.y,nTIP_MARGIN*3,nTIP_MARGIN*3);
	regionComplete.CreateRectRgn(0,0,1,1);
	regionComplete.CombineRgn(&region, &regionRound, RGN_OR);
	
	if ( NULL == m_rgnComplete.m_hObject )
		m_rgnComplete.CreateRectRgn(0,0,1,1);
	
	if ( !m_rgnComplete.EqualRgn(&regionComplete) )
	{
		m_rgnComplete.CopyRgn(&regionComplete);
		SetWindowRgn((HRGN)regionComplete.Detach(), TRUE);
		
		// There is a bug with layered windows and NC changes in Win2k
		// As a workaround, redraw the entire window if the NC area changed.
		// Changing the anchor point is the ONLY thing that will change the
		// position of the client area relative to the window during normal
		// operation.
		RedrawWindow(NULL, NULL, RDW_UPDATENOW| RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
	}
}