From 37710898bca6482a0ba0eac28adccbcaac573ba8 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 3 Aug 2012 18:44:10 +0200 Subject: [PATCH] CHANGED: #1471 Implemented property setting for CCtrlBase. --HG-- branch : gsoc2012-gui-editor --- code/nel/include/nel/gui/ctrl_base.h | 7 +- code/nel/src/gui/ctrl_base.cpp | 101 ++++++++++++++++++++++++--- 2 files changed, 95 insertions(+), 13 deletions(-) diff --git a/code/nel/include/nel/gui/ctrl_base.h b/code/nel/include/nel/gui/ctrl_base.h index 4cbdd0add..f450a9042 100644 --- a/code/nel/include/nel/gui/ctrl_base.h +++ b/code/nel/include/nel/gui/ctrl_base.h @@ -57,12 +57,15 @@ namespace NLGUI virtual ~CCtrlBase(); static std::string tooltipParentToString( TToolTipParentType type ); + static TToolTipParentType stringToToolTipParent( const std::string &str ); + + std::string getProperty( const std::string &name ) const; + + void setProperty( const std::string &name, const std::string &value ); // special parse virtual bool parse(xmlNodePtr cur, CInterfaceGroup *parentGroup); - std::string getProperty( const std::string &name ) const; - /// Handle all events (implemented by derived classes) (return true to signal event handled) virtual bool handleEvent (const NLGUI::CEventDescriptor &event); diff --git a/code/nel/src/gui/ctrl_base.cpp b/code/nel/src/gui/ctrl_base.cpp index f3b96bef6..17e6a067a 100644 --- a/code/nel/src/gui/ctrl_base.cpp +++ b/code/nel/src/gui/ctrl_base.cpp @@ -80,6 +80,22 @@ namespace NLGUI return ""; } + CCtrlBase::TToolTipParentType CCtrlBase::stringToToolTipParent( const std::string &str ) + { + std::string s = toLower( str ); + + if( s == "mouse" ) + return TTMouse; + else + if( s == "win" ) + return TTWindow; + else + if( s == "special" ) + return TTSpecialWindow; + else + return TTCtrl; + } + // *************************************************************************** bool CCtrlBase::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) { @@ -129,14 +145,7 @@ namespace NLGUI _ToolTipParent= TTCtrl; if(prop) { - if(stricmp((const char*)prop, "win")==0) - _ToolTipParent= TTWindow; - else if(stricmp((const char*)prop, "mouse")==0) - _ToolTipParent= TTMouse; - else if(stricmp((const char*)prop, "special")==0) - _ToolTipParent= TTSpecialWindow; - else - _ToolTipParent= TTCtrl; + _ToolTipParent = stringToToolTipParent( std::string( prop ) ); } // Tooltip special parent @@ -216,12 +225,12 @@ namespace NLGUI if( name == "tooltip_posref_alt" ) { std::string s; - if( ( _ToolTipParentPosRef == Hotspot_TTAuto ) && ( _ToolTipPosRef == Hotspot_TTAuto ) ) + if( ( _ToolTipParentPosRefAlt == Hotspot_TTAuto ) && ( _ToolTipPosRefAlt == Hotspot_TTAuto ) ) return "auto"; else{ - s = CInterfaceElement::HotSpotToString( _ToolTipParentPosRef ); + s = CInterfaceElement::HotSpotToString( _ToolTipParentPosRefAlt ); s += " "; - s += CInterfaceElement::HotSpotToString( _ToolTipPosRef ); + s += CInterfaceElement::HotSpotToString( _ToolTipPosRefAlt ); return s; } } @@ -234,6 +243,76 @@ namespace NLGUI return CInterfaceElement::getProperty( name ); } + + void CCtrlBase::setProperty( const std::string &name, const std::string &value ) + { + if( name == "tooltip" ) + { + _ContextHelp = value; + return; + } + else + if( name == "tooltip_i18n" ) + { + _ContextHelp = value; + return; + } + else + if( name == "on_tooltip" ) + { + _OnContextHelp = value; + return; + } + else + if( name == "on_tooltip_params" ) + { + _OnContextHelpParams = value; + return; + } + else + if( name == "tooltip_parent" ) + { + _ToolTipParent = stringToToolTipParent( value ); + return; + } + else + if( name == "tooltip_special_parent" ) + { + _ToolTipSpecialParent = value; + return; + } + else + if( name == "tooltip_posref" ) + { + THotSpot parentHS; + THotSpot HS; + convertTooltipHotSpot( value.c_str(), parentHS, HS ); + _ToolTipParentPosRef = parentHS; + _ToolTipPosRef = HS; + return; + } + else + if( name == "tooltip_posref_alt" ) + { + THotSpot parentHS; + THotSpot HS; + convertTooltipHotSpot( value.c_str(), parentHS, HS ); + _ToolTipParentPosRefAlt = parentHS; + _ToolTipPosRefAlt = HS; + return; + } + else + if( name == "instant_help" ) + { + bool b; + if( fromString( value, b ) ) + _ToolTipInstant = b; + return; + } + else + CInterfaceElement::setProperty( name, value ); + } + // *************************************************************************** void CCtrlBase::convertTooltipHotSpot(const char *prop, THotSpot &parentHS, THotSpot &childHS) {