From 6e4ce5315a420ad8330ac92010f349d7f2e67c21 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 6 Aug 2012 22:04:18 +0200 Subject: [PATCH] CHANGED: Implemented property setting for CGroupParagraph. --HG-- branch : gsoc2012-gui-editor --- code/nel/include/nel/gui/group_paragraph.h | 4 + code/nel/src/gui/group_paragraph.cpp | 149 ++++++++++++++++++--- 2 files changed, 135 insertions(+), 18 deletions(-) diff --git a/code/nel/include/nel/gui/group_paragraph.h b/code/nel/include/nel/gui/group_paragraph.h index 2cac42bd2..bc86a824e 100644 --- a/code/nel/include/nel/gui/group_paragraph.h +++ b/code/nel/include/nel/gui/group_paragraph.h @@ -126,6 +126,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 @@ -294,6 +295,9 @@ namespace NLGUI std::string _HardText; uint32 _TextId; + void setupSizes(); + void onTextChanged(); + // void setHSGroup (CViewBase *child, EAlign addElt, EAlign align); // void setHSParent(CViewBase *view, EAlign addElt, EAlign align, uint space); diff --git a/code/nel/src/gui/group_paragraph.cpp b/code/nel/src/gui/group_paragraph.cpp index b5896cf18..ece1183e9 100644 --- a/code/nel/src/gui/group_paragraph.cpp +++ b/code/nel/src/gui/group_paragraph.cpp @@ -258,6 +258,90 @@ namespace NLGUI return CInterfaceGroup::getProperty( name ); } + void CGroupParagraph::setProperty( const std::string &name, const std::string &value ) + { + 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 == "col_over" ) + { + CRGBA c; + if( fromString( value, c ) ) + _OverColor = c; + return; + } + 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 CGroupParagraph::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) { @@ -294,29 +378,13 @@ namespace NLGUI _Align = Right; } + setupSizes(); + ptr = (char*) xmlGetProp( cur, (xmlChar*)"space" ); _Space = 0; 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); - } - ptr = (char*) xmlGetProp( cur, (xmlChar*)"over" ); _Over = false; if (ptr) _Over = convertBool(ptr); @@ -1296,5 +1364,50 @@ namespace NLGUI return minWidth; } + + void CGroupParagraph::setupSizes() + { + EAlign addElt = _AddElt; + _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 CGroupParagraph::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 ); + } + } + } + }