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; sint32 _ViewTextDeltaX;
CViewText* getVT() const{ return _ViewText; }
void createViewText();
private: private:
void setupDisplayText(); void setupDisplayText();
void makeTopWindow(); void makeTopWindow();

View file

@ -1537,25 +1537,23 @@ namespace NLGUI
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void CGroupEditBox::setup()
{
// bind to the controls
_ViewText = dynamic_cast<CViewText *>(CInterfaceGroup::getView("edit_text"));
if(_ViewText == NULL) void CGroupEditBox::createViewText()
{ {
nlwarning("Interface: CGroupEditBox: text 'edit_text' missing or bad type"); 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() ); nlwarning( "Trying to create a new 'edit_text' for %s", getId().c_str() );
_ViewText = dynamic_cast< CViewText* >( CInterfaceFactory::createClass( "text" ) ); _ViewText = dynamic_cast< CViewText* >( CInterfaceFactory::createClass( "text" ) );
if( _ViewText != NULL ) if( _ViewText == NULL )
{ {
nlwarning( "Failed to create new 'edit_text' for %s", getId().c_str() );
return;
}
_ViewText->setParent( this ); _ViewText->setParent( this );
_ViewText->setIdRecurse( "edit_text" ); _ViewText->setIdRecurse( "edit_text" );
_ViewText->setHardText( "" ); _ViewText->setHardText( "" );
_ViewText->setPosRef( Hotspot_TL ); _ViewText->setPosRef( Hotspot_ML );
_ViewText->setParentPosRef( Hotspot_TL ); _ViewText->setParentPosRef( Hotspot_ML );
addView( _ViewText ); addView( _ViewText );
sint32 w,h; sint32 w,h;
@ -1564,12 +1562,17 @@ namespace NLGUI
setH( h ); setH( h );
setW( w ); setW( w );
}
} // ----------------------------------------------------------------------------
else void CGroupEditBox::setup()
nlwarning( "Failed to create new 'edit_text' for %s", getId().c_str() ); {
} // bind to the controls
} if( _ViewText == NULL )
_ViewText = dynamic_cast<CViewText *>(CInterfaceGroup::getView("edit_text"));
if(_ViewText == NULL)
createViewText();
_ViewText->setEditorSelectable( false ); _ViewText->setEditorSelectable( false );

View file

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