CHANGED: Implemented property setting for CGroupList.

This commit is contained in:
dfighter1985 2012-08-06 20:55:33 +02:00
parent 30dfa426cf
commit ee1166fa8d
2 changed files with 143 additions and 17 deletions

View file

@ -109,6 +109,7 @@ namespace NLGUI
} }
std::string getProperty( const std::string &name ) const; std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
/** /**
* parse the element and initalize it * parse the element and initalize it
@ -253,6 +254,8 @@ namespace NLGUI
void setHSGroup (CViewBase *child, EAlign addElt, EAlign align); void setHSGroup (CViewBase *child, EAlign addElt, EAlign align);
void setHSParent(CViewBase *view, EAlign addElt, EAlign align, uint space); void setHSParent(CViewBase *view, EAlign addElt, EAlign align, uint space);
void setupSizes();
void onTextChanged();
}; };

View file

@ -271,6 +271,104 @@ namespace NLGUI
return CInterfaceGroup::getProperty( name ); 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) bool CGroupList::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup)
{ {
@ -322,23 +420,7 @@ namespace NLGUI
if (ptr) if (ptr)
fromString((const char*)ptr, _Space); fromString((const char*)ptr, _Space);
EAlign addElt = _AddElt; setupSizes();
// 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);
}
ptr = (char*) xmlGetProp( cur, (xmlChar*)"over" ); ptr = (char*) xmlGetProp( cur, (xmlChar*)"over" );
_Over = false; _Over = false;
@ -1235,5 +1317,46 @@ namespace NLGUI
return 0; 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 );
}
}
}
} }