diff --git a/code/nel/include/nel/gui/group_list.h b/code/nel/include/nel/gui/group_list.h index 3e08b1a07..892521992 100644 --- a/code/nel/include/nel/gui/group_list.h +++ b/code/nel/include/nel/gui/group_list.h @@ -109,6 +109,7 @@ namespace NLGUI } std::string getProperty( const std::string &name ) const; + void setProperty( const std::string &name, const std::string &value ); /** * parse the element and initalize it @@ -253,6 +254,8 @@ namespace NLGUI void setHSGroup (CViewBase *child, EAlign addElt, EAlign align); void setHSParent(CViewBase *view, EAlign addElt, EAlign align, uint space); + void setupSizes(); + void onTextChanged(); }; diff --git a/code/nel/src/gui/group_list.cpp b/code/nel/src/gui/group_list.cpp index f60cc475c..4bd96b456 100644 --- a/code/nel/src/gui/group_list.cpp +++ b/code/nel/src/gui/group_list.cpp @@ -271,6 +271,104 @@ namespace NLGUI return CInterfaceGroup::getProperty( name ); } + void CGroupList::setProperty( const std::string &name, const std::string &value ) + { + if( name == "maxelements" ) + { + sint32 i; + if( fromString( value, i ) ) + _MaxElements = i; + return; + } + else + if( name == "addelt" ) + { + if( value == "T" ) + _AddElt = Top; + else + if( value == "L" ) + _AddElt = Left; + else + if( value == "R" ) + _AddElt = Right; + else + if( value == "B" ) + _AddElt = Bottom; + + setupSizes(); + return; + } + else + if( name == "align" ) + { + if( value == "T" ) + _Align = Top; + else + if( value == "L" ) + _Align = Left; + else + if( value == "R" ) + _Align = Right; + else + if( value == "B" ) + _Align = Bottom; + + return; + } + else + if( name == "space" ) + { + sint32 i; + if( fromString( value, i ) ) + _Space = i; + return; + } + else + if( name == "over" ) + { + bool b; + if( fromString( value, b ) ) + _Over = b; + return; + } + else + if( name == "dynamic_display_size" ) + { + bool b; + if( fromString( value, b ) ) + _DynamicDisplaySize = b; + return; + } + else + if( name == "col_over" ) + { + CRGBA c; + if( fromString( value, c ) ) + _OverColor = c; + return; + } + else + if( name == "hardtext" ) + { + _HardText = value; + _TextId = 0; + onTextChanged(); + return; + } + else + if( name == "textid" ) + { + uint32 i; + if( fromString( value, i ) ) + _TextId = i; + _HardText = ""; + onTextChanged(); + return; + } + else + CInterfaceGroup::setProperty( name, value ); + } + // ---------------------------------------------------------------------------- bool CGroupList::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) { @@ -322,23 +420,7 @@ namespace NLGUI if (ptr) fromString((const char*)ptr, _Space); - EAlign addElt = _AddElt; - // EAlign align = _Align; - _GroupSizeRef = _SizeRef; - if ((addElt == Top) || (addElt == Bottom)) - { - setMaxW (_W); - setMaxH(_H); - _H = 0; - _SizeRef = _SizeRef&(~2); - } - else - { - setMaxW (_W); - setMaxH (_H); - _W = 0; - _SizeRef = _SizeRef&(~1); - } + setupSizes(); ptr = (char*) xmlGetProp( cur, (xmlChar*)"over" ); _Over = false; @@ -1235,5 +1317,46 @@ namespace NLGUI return 0; } + void CGroupList::setupSizes() + { + _GroupSizeRef = _SizeRef; + if ((_AddElt == Top) || (_AddElt == Bottom)) + { + setMaxW (_W); + setMaxH(_H); + _H = 0; + _SizeRef = _SizeRef & (~2); + } + else + { + setMaxW (_W); + setMaxH (_H); + _W = 0; + _SizeRef = _SizeRef & (~1); + } + } + + void CGroupList::onTextChanged() + { + if( _Elements.size() == 0 ) + return; + + CElementInfo &e = _Elements[ 0 ]; + + CViewText *t = dynamic_cast< CViewText* >( e.Element ); + if( t != NULL ) + { + t->setText( _HardText ); + return; + } + else + { + CViewTextID *ti = dynamic_cast< CViewTextID* >( e.Element ); + if( ti != NULL ) + { + ti->setTextId( _TextId ); + } + } + } }