コード例 #1
0
ファイル: ltguieditctrl.cpp プロジェクト: emoose/lithtech
// Render the control
void CLTGUIEditCtrl::Render ()
{
	if ( !m_pText || !IsVisible())
		return;

    uint32 color = GetCurrentColor();

	// Render the text

	if (m_pText)
	{
		m_pText->SetColor(color);
		m_pText->Render();

		// draw the caret
		g_pDrawPrim->SetTransformType(DRAWPRIM_TRANSFORM_SCREEN);
		g_pDrawPrim->SetZBufferMode(DRAWPRIM_NOZ); 
		g_pDrawPrim->SetClipMode(DRAWPRIM_NOCLIP);
		g_pDrawPrim->SetFillMode(DRAWPRIM_FILL);
		g_pDrawPrim->SetColorOp(DRAWPRIM_NOCOLOROP);
		g_pDrawPrim->SetAlphaTestMode(DRAWPRIM_NOALPHATEST);
		g_pDrawPrim->SetAlphaBlendMode(DRAWPRIM_NOBLEND);

		if (IsCaretOn() && IsEnabled())
		{
			LT_POLYGT4*	pPolys = m_pText->GetPolys();
			
			float x = (float)m_pos.x;
			float y = (float)m_pos.y;
			float w = 2.0f;
			float h = m_pText->GetHeight();
			if (m_nCaretPos > 0 && m_nCaretPos <= m_pText->GetLength())
			{
				x = pPolys[m_nCaretPos-1].verts[1].x;
			}
			g_pDrawPrim->SetXYWH(&m_Caret,x,y,w,h);



			g_pDrawPrim->DrawPrim(&m_Caret);

		}

		// draw our frame
		if (m_bUseFrame)
			g_pDrawPrim->DrawPrim(m_Frame,4);

	}
}
コード例 #2
0
ファイル: ltguieditctrl.cpp プロジェクト: Arc0re/lithtech
// Render the control
void CLTGUIEditCtrl::Render ()
{
	if ( !IsVisible())
		return;


	// Render the text
	m_Text.SetColor(GetCurrentColor());
	m_Text.SetGlow(IsSelected());
	m_Text.Render( );

	g_pDrawPrim->SetRenderMode(eLTDrawPrimRenderMode_Modulate_NoBlend);

	// draw the caret
	if (IsCaretOn() && IsEnabled())
	{
		LTRect2n rRect;

		uint32 len = LTStrLen(GetText());
		if (m_nCaretPos > len)
			m_nCaretPos = len;
		
		float x = m_rfRect.Left();
		float y = m_rfRect.Top();
		float w = 2.0f;
		float h = GetHeight();
		if (m_nCaretPos > 0)
		{

			LTRect2n rRect;
			if (m_Text.GetCharRect(m_nCaretPos-1,rRect) == LT_OK)
			{
				x = (float)rRect.Right();
			}
		}
		DrawPrimSetXYWH(m_Caret,x,y,w,h);
		g_pDrawPrim->DrawPrim(&m_Caret);
	}

	g_pDrawPrim->SetRenderMode(eLTDrawPrimRenderMode_Modulate_Translucent);


	// draw our frame
	if (m_bUseFrame)
		g_pDrawPrim->DrawPrim(m_Frame,4);

}