void GUITextBox::Draw() { if(IsVisible()) { COLOR4 color = GetColor(); Box(GetX(), GetY(), GetWidth(), GetHeight(), color.r, color.g, color.b, color.a); if(GetCaption() && GetCaptionFont()) { COLOR4 c_color = GetCaptionColor(); glColor4ub(c_color.r, c_color.g, c_color.b, c_color.a); PrintText(GetCaption(), GetCaptionFont(), GetX() + GetCaptionX(), GetY() + GetCaptionY()); } if(GetTextFont()) { COLOR4 t_color = GetTextColor(); glColor4ub(t_color.r, t_color.g, t_color.b, t_color.a); PrintText(GetText(), GetTextFont(), GetX() + GetTextX(), GetY() + GetTextY()); } } }
void CUICustomEdit::Draw() { VERIFY( m_pLines ); Fvector2 pos, out; GetAbsolutePos( pos ); CGameFont* font = m_pLines->m_pFont; if ( ec().need_update() || m_force_update ) { float ui_width = GetWidth(); LPCSTR cursor_str = ec().str_before_cursor(); u32 cursor_str_size = xr_strlen( cursor_str ); LPCSTR istr = cursor_str; float str_length = font->SizeOf_( istr ); UI()->ClientToScreenScaledWidth( str_length ); u32 ix = 0; while ( (str_length > ui_width) && (ix < cursor_str_size) ) { istr = cursor_str + ix; str_length = font->SizeOf_( istr ); UI()->ClientToScreenScaledWidth( str_length ); ++ix; } istr = cursor_str + ix; LPCSTR astr = ec().str_edit() + ix; u32 str_size = xr_strlen( ec().str_edit() ); u32 jx = 1; strncpy_s( m_out_str, sizeof(m_out_str), astr, jx ); str_length = font->SizeOf_( m_out_str ); UI()->ClientToScreenScaledWidth( str_length ); while ( (str_length < ui_width) && (jx < str_size-ix) ) { strncpy_s( m_out_str, sizeof(m_out_str), astr, jx ); str_length = font->SizeOf_( m_out_str ); UI()->ClientToScreenScaledWidth( str_length ); ++jx; } strncpy_s( m_out_str, sizeof(m_out_str), astr, jx ); inherited::SetText( m_out_str ); m_dx_cur = font->SizeOf_( istr ); // cursor_str m_force_update = false; } inherited::Draw(); if ( m_bInputFocus ) //draw cursor here { out.x = pos.x + 0.0f + GetTextX() + m_pLines->GetIndentByAlign(); out.y = pos.y + 2.0f + GetTextY() + m_pLines->GetVIndentByAlign(); UI()->ClientToScreenScaled( out ); out.x += m_dx_cur; // cursor_str font->Out( out.x, out.y, "_" ); } font->OnRender(); }