From 13b195c0d5ff40fe397acf8befeb039a920c04ce Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 3 Aug 2012 21:10:57 +0200 Subject: [PATCH] CHANGED: #1471 Implemented property setting for CCtrlBaseButton. --HG-- branch : gsoc2012-gui-editor --- code/nel/include/nel/gui/ctrl_base_button.h | 2 + code/nel/src/gui/ctrl_base_button.cpp | 236 ++++++++++++++++++-- 2 files changed, 219 insertions(+), 19 deletions(-) diff --git a/code/nel/include/nel/gui/ctrl_base_button.h b/code/nel/include/nel/gui/ctrl_base_button.h index 9025ab796..ebbef218e 100644 --- a/code/nel/include/nel/gui/ctrl_base_button.h +++ b/code/nel/include/nel/gui/ctrl_base_button.h @@ -42,6 +42,7 @@ namespace NLGUI CCtrlBaseButton(const TCtorParam ¶m); std::string getProperty( const std::string &name ) const; + void setProperty( const std::string &name, const std::string &value ); virtual bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup); virtual bool handleEvent (const NLGUI::CEventDescriptor& event); @@ -51,6 +52,7 @@ namespace NLGUI void setType (EType t) { _Type = t; } EType getType() { return _Type; } std::string getTypeString() const; + void setTypeFromString( const std::string &type ); void setClickWhenPushed(bool click) { _ClickWhenPushed = click; } bool getClickWhenPushed() const { return _ClickWhenPushed; } diff --git a/code/nel/src/gui/ctrl_base_button.cpp b/code/nel/src/gui/ctrl_base_button.cpp index dd81f205f..a31fc4317 100644 --- a/code/nel/src/gui/ctrl_base_button.cpp +++ b/code/nel/src/gui/ctrl_base_button.cpp @@ -205,6 +205,190 @@ namespace NLGUI return CCtrlBase::getProperty( name ); } + void CCtrlBaseButton::setProperty( const std::string &name, const std::string &value ) + { + if( name == "button_type" ) + { + setTypeFromString( value ); + return; + } + else + if( name == "pushed" ) + { + bool b; + if( fromString( value, b ) ) + _Pushed = b; + return; + } + else + if( name == "over_when_pushed" ) + { + bool b; + if( fromString( value, b ) ) + _OverWhenPushed = b; + return; + } + else + if( name == "clicked_when_pushed" ) + { + bool b; + if( fromString( value, b ) ) + _ClickWhenPushed = b; + return; + } + else + if( name == "color" ) + { + setColorAsString( value ); + return; + } + else + if( name == "col_pushed" ) + { + setColorPushedAsString( value ); + return; + } + else + if( name == "col_over" ) + { + setColorOverAsString( value ); + return; + } + else + if( name == "global_color_normal" ) + { + bool b; + if( fromString( value, b ) ) + _ModulateGlobalColorNormal = b; + return; + } + else + if( name == "global_color_pushed" ) + { + bool b; + if( fromString( value, b ) ) + _ModulateGlobalColorPushed = b; + return; + + } + else + if( name == "global_color_over" ) + { + bool b; + if( fromString( value, b ) ) + _ModulateGlobalColorOver = b; + return; + } + else + if( name == "onover" ) + { + _AHOnOver = CAHManager::getInstance()->getAH( value, std::string() ); + return; + } + else + if( name == "params_over" ) + { + _AHOverParams = value; + return; + } + else + if( name == "onclick_l" ) + { + _AHOnLeftClick = CAHManager::getInstance()->getAH( value, std::string() ); + return; + } + else + if( name == "params_l" ) + { + _AHLeftClickParams = value; + return; + } + else + if( name == "ondblclick_l" ) + { + _AHOnLeftDblClick = CAHManager::getInstance()->getAH( value, std::string() ); + return; + } + else + if( name == "params_dblclick_l" ) + { + _AHLeftDblClickParams = value; + return; + } + else + if( name == "onlongclick_l" ) + { + _AHOnLeftLongClick = CAHManager::getInstance()->getAH( value, std::string() ); + return; + } + else + if( name == "params_longclick_l" ) + { + _AHLeftLongClickParams = value; + return; + } + else + if( name == "onclick_r" ) + { + _AHOnRightClick = CAHManager::getInstance()->getAH( value, std::string() ); + return; + } + else + if( name == "params_r" ) + { + _AHRightClickParams = value; + return; + } + else + if( name == "onclock_tick" ) + { + _AHOnClockTick = CAHManager::getInstance()->getAH( value, std::string() ); + return; + } + else + if( name == "params_clock_tick" ) + { + _AHClockTickParams = value; + return; + } + else + if( name == "menu_l" ) + { + _ListMenuLeft = value; + return; + } + else + if( name == "menu_r" ) + { + _ListMenuRight = value; + return; + } + else + if( name == "menu_b" ) + { + _ListMenuLeft = _ListMenuRight = value; + return; + } + else + if( name == "frozen" ) + { + bool b; + if( fromString( value, b ) ) + _Frozen = b; + return; + } + else + if( name == "frozen_half_tone" ) + { + bool b; + if( fromString( value, b ) ) + _FrozenHalfTone = b; + return; + } + else + CCtrlBase::setProperty( name, value ); + } + // *************************************************************************** bool CCtrlBaseButton::parse (xmlNodePtr cur,CInterfaceGroup * parentGroup) @@ -222,26 +406,9 @@ namespace NLGUI // *** try to get the NEEDED specific props prop = xmlGetProp (cur, (xmlChar*)"button_type"); string type; - if (prop) type = (const char*) prop; - if (type.empty() || type == "toggle_button") + if (prop) { - _Type = ToggleButton; - } - else if (type == "push_button") - { - _Type = PushButton; - } - else if (type == "radio_button") - { - _Type = RadioButton; - - initRBRef(); - if (_Pushed) - *_RBRef = this; - } - else - { - nlinfo(("cannot parse button type for button " + getId()).c_str()); + type = (const char*) prop; } prop= (char*) xmlGetProp (cur, (xmlChar*)"pushed"); @@ -530,6 +697,37 @@ namespace NLGUI return ""; } + void CCtrlBaseButton::setTypeFromString( const std::string &type ) + { + if( type.empty() || type == "toggle_button" ) + { + _Type = ToggleButton; + return; + } + else + if( type == "push_button" ) + { + _Type = PushButton; + return; + } + else + if( type == "radio_button" ) + { + _Type = RadioButton; + + initRBRef(); + if( _Pushed ) + *_RBRef = this; + + return; + } + else + { + _Type = ToggleButton; + nlinfo( ( "cannot parse button type for button " + getId() ).c_str() ); + } + } + // *************************************************************************** void CCtrlBaseButton::initRBRef() {