CHANGED: #1471 Implemented property setting for CCtrlBase.

This commit is contained in:
dfighter1985 2012-08-03 18:44:10 +02:00
parent d562a50ceb
commit b8d5721b4a
2 changed files with 95 additions and 13 deletions

View file

@ -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);

View file

@ -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)
{