Create the viewtext of the decorated edit box when the box is created, also adjust it so the text is drawn to the right of the left texture.

This commit is contained in:
dfighter1985 2014-10-17 21:18:26 +02:00
parent 25b5750239
commit 68fa126867
3 changed files with 43 additions and 28 deletions

View file

@ -283,6 +283,10 @@ namespace NLGUI
sint32 _ViewTextDeltaX;
CViewText* getVT() const{ return _ViewText; }
void createViewText();
private:
void setupDisplayText();
void makeTopWindow();

View file

@ -1536,40 +1536,43 @@ namespace NLGUI
CInterfaceGroup::clearViews();
}
// ----------------------------------------------------------------------------
void CGroupEditBox::createViewText()
{
nlwarning("Interface: CGroupEditBox: text 'edit_text' missing or bad type");
nlwarning( "Trying to create a new 'edit_text' for %s", getId().c_str() );
_ViewText = dynamic_cast< CViewText* >( CInterfaceFactory::createClass( "text" ) );
if( _ViewText == NULL )
{
nlwarning( "Failed to create new 'edit_text' for %s", getId().c_str() );
return;
}
_ViewText->setParent( this );
_ViewText->setIdRecurse( "edit_text" );
_ViewText->setHardText( "" );
_ViewText->setPosRef( Hotspot_ML );
_ViewText->setParentPosRef( Hotspot_ML );
addView( _ViewText );
sint32 w,h;
w = std::max( sint32( _ViewText->getFontWidth() * _ViewText->getText().size() ), getW() );
h = std::max( sint32( _ViewText->getFontHeight() ), getH() );
setH( h );
setW( w );
}
// ----------------------------------------------------------------------------
void CGroupEditBox::setup()
{
// bind to the controls
_ViewText = dynamic_cast<CViewText *>(CInterfaceGroup::getView("edit_text"));
if( _ViewText == NULL )
_ViewText = dynamic_cast<CViewText *>(CInterfaceGroup::getView("edit_text"));
if(_ViewText == NULL)
{
nlwarning("Interface: CGroupEditBox: text 'edit_text' missing or bad type");
if( editorMode )
{
nlwarning( "Trying to create a new 'edit_text' for %s", getId().c_str() );
_ViewText = dynamic_cast< CViewText* >( CInterfaceFactory::createClass( "text" ) );
if( _ViewText != NULL )
{
_ViewText->setParent( this );
_ViewText->setIdRecurse( "edit_text" );
_ViewText->setHardText( "" );
_ViewText->setPosRef( Hotspot_TL );
_ViewText->setParentPosRef( Hotspot_TL );
addView( _ViewText );
sint32 w,h;
w = std::max( sint32( _ViewText->getFontWidth() * _ViewText->getText().size() ), getW() );
h = std::max( sint32( _ViewText->getFontHeight() ), getH() );
setH( h );
setW( w );
}
else
nlwarning( "Failed to create new 'edit_text' for %s", getId().c_str() );
}
}
createViewText();
_ViewText->setEditorSelectable( false );

View file

@ -18,6 +18,7 @@
#include "stdpch.h"
#include "nel/gui/group_editbox_decor.h"
#include "nel/gui/view_bitmap.h"
#include "nel/gui/view_text.h"
namespace NLGUI
{
@ -162,6 +163,10 @@ namespace NLGUI
{
_Pvt = new EBDPrivate();
_Pvt->setup( this );
createViewText();
getVT()->setSerializable( false );
getVT()->setEditorSelectable( false );
}
CGroupEditBoxDecor::~CGroupEditBoxDecor()
@ -352,6 +357,9 @@ namespace NLGUI
void CGroupEditBoxDecor::updateCoords()
{
sint32 tw = _Pvt->_Textures[ EBDPrivate::L ]->getWReal();
getVT()->setX( tw + 1 );
CGroupEditBox::updateCoords();
_Pvt->updateCoords();
}