CHANGED: #1471 Implemented property querying for CCtrlBase and CInterfaceGroup.
This commit is contained in:
parent
f245e69063
commit
307129e1bf
10 changed files with 374 additions and 15 deletions
|
@ -56,6 +56,8 @@ namespace NLGUI
|
|||
/// Destructor
|
||||
virtual ~CCtrlBase();
|
||||
|
||||
static std::string tooltipParentToString( TToolTipParentType type );
|
||||
|
||||
// special parse
|
||||
virtual bool parse(xmlNodePtr cur, CInterfaceGroup *parentGroup);
|
||||
|
||||
|
|
|
@ -341,6 +341,7 @@ namespace NLGUI
|
|||
// set sizeref as a string, like "wh", "wh5" ....
|
||||
void setSizeRef(const std::string &sizeref);
|
||||
std::string getSizeRefAsString() const;
|
||||
std::string getSizeRefAsString( const sint32 &sizeRef, const sint32 &sizeDivW, const sint32 &sizeDivH ) const;
|
||||
|
||||
// export some properties
|
||||
REFLECT_EXPORT_START(CInterfaceElement, CReflectable)
|
||||
|
|
|
@ -168,6 +168,7 @@ namespace NLGUI
|
|||
|
||||
/// LUA Class Association builder : associate a lua script to a group (called for each group after every document parsed)
|
||||
void addLuaClassAssociation(CInterfaceGroup *group, const std::string &luaScript);
|
||||
std::string getLuaClassAssociation( CInterfaceGroup *group ) const;
|
||||
|
||||
/**
|
||||
* Accessors
|
||||
|
|
|
@ -48,6 +48,7 @@ namespace NLGUI
|
|||
virtual std::string getParentPosAssociation( CInterfaceElement *element ) const = 0;
|
||||
virtual std::string getParentSizeAssociation( CInterfaceElement *element ) const = 0;
|
||||
virtual std::string getParentSizeMaxAssociation( CInterfaceElement *element ) const = 0;
|
||||
virtual std::string getLuaClassAssociation( CInterfaceGroup *group ) const = 0;
|
||||
virtual CInterfaceGroup* createGroupInstance( const std::string &templateName, const std::string &parentID, const std::pair< std::string, std::string > *templateParams, uint numParams, bool updateLinks = true ) = 0;
|
||||
virtual CInterfaceGroup* createGroupInstance( const std::string &templateName, const std::string &parentID, std::vector< std::pair< std::string, std::string > > &templateParams, bool updateLinks = true ) = 0;
|
||||
virtual bool parseGroupChildren( xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload ) = 0;
|
||||
|
|
|
@ -60,6 +60,26 @@ namespace NLGUI
|
|||
return false;
|
||||
}
|
||||
|
||||
std::string CCtrlBase::tooltipParentToString( TToolTipParentType type )
|
||||
{
|
||||
switch( type )
|
||||
{
|
||||
case TTMouse:
|
||||
return "mouse";
|
||||
break;
|
||||
|
||||
case TTWindow:
|
||||
return "win";
|
||||
break;
|
||||
|
||||
case TTSpecialWindow:
|
||||
return "special";
|
||||
break;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
bool CCtrlBase::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
|
||||
{
|
||||
|
@ -76,7 +96,7 @@ namespace NLGUI
|
|||
|
||||
_ContextHelp = ucstring(propPtr);
|
||||
|
||||
if (strlen(propPtr) > 2)
|
||||
if( !editorMode && ( strlen(propPtr) > 2 ) )
|
||||
{
|
||||
if ((propPtr[0] == 'u') && (propPtr[1] == 'i'))
|
||||
_ContextHelp = CI18N::get ((const char *) prop);
|
||||
|
@ -86,7 +106,10 @@ namespace NLGUI
|
|||
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_i18n" );
|
||||
if ((bool)prop && strlen((const char*)prop)>0)
|
||||
{
|
||||
if( !editorMode )
|
||||
_ContextHelp = CI18N::get ((const char *) prop);
|
||||
else
|
||||
_ContextHelp = (const char*)prop;
|
||||
}
|
||||
|
||||
// get dynamic toolTip ActionHandler
|
||||
|
@ -147,6 +170,16 @@ namespace NLGUI
|
|||
|
||||
std::string CCtrlBase::getProperty( const std::string &name ) const
|
||||
{
|
||||
if( name == "tooltip" )
|
||||
{
|
||||
return _ContextHelp.toString();
|
||||
}
|
||||
else
|
||||
if( name == "tooltip_i18n" )
|
||||
{
|
||||
return _ContextHelp.toString();
|
||||
}
|
||||
else
|
||||
if( name == "on_tooltip" )
|
||||
{
|
||||
return _OnContextHelp.toString();
|
||||
|
@ -156,7 +189,48 @@ namespace NLGUI
|
|||
{
|
||||
return _OnContextHelpParams.toString();
|
||||
}
|
||||
|
||||
else
|
||||
if( name == "tooltip_parent" )
|
||||
{
|
||||
return tooltipParentToString( _ToolTipParent );
|
||||
}
|
||||
else
|
||||
if( name == "tooltip_special_parent" )
|
||||
{
|
||||
return _ToolTipSpecialParent.toString();
|
||||
}
|
||||
else
|
||||
if( name == "tooltip_posref" )
|
||||
{
|
||||
std::string s;
|
||||
if( ( _ToolTipParentPosRef == Hotspot_TTAuto ) && ( _ToolTipPosRef == Hotspot_TTAuto ) )
|
||||
return "auto";
|
||||
else{
|
||||
s = CInterfaceElement::HotSpotToString( _ToolTipParentPosRef );
|
||||
s += " ";
|
||||
s += CInterfaceElement::HotSpotToString( _ToolTipPosRef );
|
||||
return s;
|
||||
}
|
||||
}
|
||||
else
|
||||
if( name == "tooltip_posref_alt" )
|
||||
{
|
||||
std::string s;
|
||||
if( ( _ToolTipParentPosRef == Hotspot_TTAuto ) && ( _ToolTipPosRef == Hotspot_TTAuto ) )
|
||||
return "auto";
|
||||
else{
|
||||
s = CInterfaceElement::HotSpotToString( _ToolTipParentPosRef );
|
||||
s += " ";
|
||||
s += CInterfaceElement::HotSpotToString( _ToolTipPosRef );
|
||||
return s;
|
||||
}
|
||||
}
|
||||
else
|
||||
if( name == "instant_help" )
|
||||
{
|
||||
return toString( _ToolTipInstant );
|
||||
}
|
||||
else
|
||||
return CInterfaceElement::getProperty( name );
|
||||
}
|
||||
|
||||
|
|
|
@ -261,7 +261,7 @@ namespace NLGUI
|
|||
else
|
||||
if( name == "sizeref" )
|
||||
{
|
||||
return getSizeRefAsString();
|
||||
return getSizeRefAsString( _SizeRef, _SizeDivW, _SizeDivH );
|
||||
}
|
||||
if( name == "posparent" )
|
||||
{
|
||||
|
@ -300,20 +300,25 @@ namespace NLGUI
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
std::string CInterfaceElement::getSizeRefAsString() const
|
||||
{
|
||||
return getSizeRefAsString( _SizeRef, _SizeDivW, _SizeDivH );
|
||||
}
|
||||
|
||||
std::string CInterfaceElement::getSizeRefAsString( const sint32 &sizeRef, const sint32 &sizeDivW, sint32 const &sizeDivH ) const
|
||||
{
|
||||
std::string s;
|
||||
if( ( _SizeRef & 1 ) != 0 )
|
||||
if( ( sizeRef & 1 ) != 0 )
|
||||
{
|
||||
s += "w";
|
||||
if( _SizeDivW < 10 )
|
||||
s += toString( _SizeDivW );
|
||||
if( sizeDivW < 10 )
|
||||
s += toString( sizeDivW );
|
||||
}
|
||||
|
||||
if( ( _SizeRef & 2 ) != 0 )
|
||||
{
|
||||
s += "h";
|
||||
if( _SizeDivH < 10 )
|
||||
s += toString( _SizeDivH );
|
||||
if( sizeDivH < 10 )
|
||||
s += toString( sizeDivH );
|
||||
}
|
||||
|
||||
return s;
|
||||
|
|
|
@ -355,6 +355,96 @@ namespace NLGUI
|
|||
|
||||
std::string CInterfaceGroup::getProperty( const std::string &name ) const
|
||||
{
|
||||
if( name == "overlappable" )
|
||||
{
|
||||
return NLMISC::toString( _Overlappable );
|
||||
}
|
||||
else
|
||||
if( name == "escapable" )
|
||||
{
|
||||
return NLMISC::toString( _Escapable );
|
||||
}
|
||||
else
|
||||
if( name == "child_resize_w" )
|
||||
{
|
||||
return NLMISC::toString( _ResizeFromChildW );
|
||||
}
|
||||
else
|
||||
if( name == "child_resize_h" )
|
||||
{
|
||||
return NLMISC::toString( _ResizeFromChildH );
|
||||
}
|
||||
else
|
||||
if( name == "child_resize_wmargin" )
|
||||
{
|
||||
return NLMISC::toString( _ResizeFromChildWMargin );
|
||||
}
|
||||
else
|
||||
if( name == "child_resize_hmargin" )
|
||||
{
|
||||
return NLMISC::toString( _ResizeFromChildHMargin );
|
||||
}
|
||||
else
|
||||
if( name == "on_active" )
|
||||
{
|
||||
return getOnActiveHandler();
|
||||
}
|
||||
else
|
||||
if( name == "on_active_params" )
|
||||
{
|
||||
return getOnActiveParams();
|
||||
}
|
||||
else
|
||||
if( name == "on_deactive" )
|
||||
{
|
||||
return getOnDeactiveHandler();
|
||||
}
|
||||
else
|
||||
if( name == "on_deactive_params" )
|
||||
{
|
||||
return getOnDeactiveParams();
|
||||
}
|
||||
else
|
||||
if( name == "max_w" )
|
||||
{
|
||||
return NLMISC::toString( _MaxW );
|
||||
}
|
||||
else
|
||||
if( name == "max_h" )
|
||||
{
|
||||
return NLMISC::toString( _MaxH );
|
||||
}
|
||||
else
|
||||
if( name == "max_sizeref" )
|
||||
{
|
||||
return getSizeRefAsString( _GroupSizeRef, _SizeDivW, _SizeDivH );
|
||||
}
|
||||
else
|
||||
if( name == "max_sizeparent" )
|
||||
{
|
||||
return CWidgetManager::getInstance()->getParser()->getParentSizeMaxAssociation( (CInterfaceElement*)this );
|
||||
}
|
||||
else
|
||||
if( name == "group_onclick_r" )
|
||||
{
|
||||
return getRightClickHandler();
|
||||
}
|
||||
else
|
||||
if( name == "group_params_r" )
|
||||
{
|
||||
return getRightClickHandlerParams();
|
||||
}
|
||||
else
|
||||
if( name == "group_onclick_l" )
|
||||
{
|
||||
return getLeftClickHandler();
|
||||
}
|
||||
else
|
||||
if( name == "group_params_l" )
|
||||
{
|
||||
return getLeftClickHandlerParams();
|
||||
}
|
||||
else
|
||||
if( name == "on_enter" )
|
||||
{
|
||||
return getAHOnEnter();
|
||||
|
@ -364,7 +454,32 @@ namespace NLGUI
|
|||
{
|
||||
return getAHOnEnterParams();
|
||||
}
|
||||
|
||||
else
|
||||
if( name == "win_priority" )
|
||||
{
|
||||
return NLMISC::toString( _Priority );
|
||||
}
|
||||
else
|
||||
if( name == "use_cursor" )
|
||||
{
|
||||
return NLMISC::toString( _UseCursor );
|
||||
}
|
||||
else
|
||||
if( name == "on_escape" )
|
||||
{
|
||||
return getAHOnEscape();
|
||||
}
|
||||
else
|
||||
if( name == "on_escape_params" )
|
||||
{
|
||||
return getAHOnEscapeParams();
|
||||
}
|
||||
else
|
||||
if( name == "lua_class" )
|
||||
{
|
||||
return CWidgetManager::getInstance()->getParser()->getLuaClassAssociation( (CInterfaceGroup*)this );
|
||||
}
|
||||
else
|
||||
return CCtrlBase::getProperty( name );
|
||||
}
|
||||
|
||||
|
|
|
@ -2017,6 +2017,16 @@ namespace NLGUI
|
|||
_LuaClassAssociation.insert (std::map<CInterfaceGroup*,std::string>::value_type(group, luaScript));
|
||||
}
|
||||
|
||||
std::string CInterfaceParser::getLuaClassAssociation( CInterfaceGroup *group ) const
|
||||
{
|
||||
std::map< CInterfaceGroup*, std::string >::const_iterator itr =
|
||||
_LuaClassAssociation.find( group );
|
||||
if( itr == _LuaClassAssociation.end() )
|
||||
return "";
|
||||
else
|
||||
return itr->second;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
const std::string &CInterfaceParser::getDefine(const std::string &id) const
|
||||
{
|
||||
|
|
|
@ -8,15 +8,50 @@
|
|||
<icon></icon>
|
||||
</header>
|
||||
<properties>
|
||||
<property>
|
||||
<name>tooltip</name>
|
||||
<type>string</type>
|
||||
<default></default>
|
||||
</property>
|
||||
<property>
|
||||
<name>tooltip_i18n</name>
|
||||
<type>string</type>
|
||||
<default></default>
|
||||
</property>
|
||||
<property>
|
||||
<name>on_tooltip</name>
|
||||
<type>string</type>
|
||||
<default>handler</default>
|
||||
<default></default>
|
||||
</property>
|
||||
<property>
|
||||
<name>on_tooltip_params</name>
|
||||
<type>string</type>
|
||||
<default>params</default>
|
||||
<default></default>
|
||||
</property>
|
||||
<property>
|
||||
<name>tooltip_parent</name>
|
||||
<type>string</type>
|
||||
<default></default>
|
||||
</property>
|
||||
<property>
|
||||
<name>tooltip_special_parent</name>
|
||||
<type>string</type>
|
||||
<default></default>
|
||||
</property>
|
||||
<property>
|
||||
<name>tooltip_posref</name>
|
||||
<type>string</type>
|
||||
<default>auto</default>
|
||||
</property>
|
||||
<property>
|
||||
<name>tooltip_posref_alt</name>
|
||||
<type>string</type>
|
||||
<default>auto</default>
|
||||
</property>
|
||||
<property>
|
||||
<name>instant_help</name>
|
||||
<type>bool</type>
|
||||
<default></default>
|
||||
</property>
|
||||
</properties>
|
||||
</widget>
|
||||
|
|
|
@ -8,6 +8,96 @@
|
|||
<icon></icon>
|
||||
</header>
|
||||
<properties>
|
||||
<property>
|
||||
<name>overlappable</name>
|
||||
<type>bool</type>
|
||||
<default>true</default>
|
||||
</property>
|
||||
<property>
|
||||
<name>escapable</name>
|
||||
<type>bool</type>
|
||||
<default>false</default>
|
||||
</property>
|
||||
<property>
|
||||
<name>child_resize_w</name>
|
||||
<type>bool</type>
|
||||
<default>false</default>
|
||||
</property>
|
||||
<property>
|
||||
<name>child_resize_h</name>
|
||||
<type>bool</type>
|
||||
<default>false</default>
|
||||
</property>
|
||||
<property>
|
||||
<name>child_resize_wmargin</name>
|
||||
<type>int</type>
|
||||
<default>0</default>
|
||||
</property>
|
||||
<property>
|
||||
<name>child_resize_hmargin</name>
|
||||
<type>int</type>
|
||||
<default>0</default>
|
||||
</property>
|
||||
<property>
|
||||
<name>on_active</name>
|
||||
<type>string</type>
|
||||
<default></default>
|
||||
</property>
|
||||
<property>
|
||||
<name>on_active_params</name>
|
||||
<type>string</type>
|
||||
<default></default>
|
||||
</property>
|
||||
<property>
|
||||
<name>on_deactive</name>
|
||||
<type>string</type>
|
||||
<default></default>
|
||||
</property>
|
||||
<property>
|
||||
<name>on_deactive_params</name>
|
||||
<type>string</type>
|
||||
<default></default>
|
||||
</property>
|
||||
<property>
|
||||
<name>max_w</name>
|
||||
<type>int</type>
|
||||
<default>16384</default>
|
||||
</property>
|
||||
<property>
|
||||
<name>max_h</name>
|
||||
<type>int</type>
|
||||
<default>16384</default>
|
||||
</property>
|
||||
<property>
|
||||
<name>max_sizeref</name>
|
||||
<type>string</type>
|
||||
<default></default>
|
||||
</property>
|
||||
<property>
|
||||
<name>max_sizeparent</name>
|
||||
<type>string</type>
|
||||
<default>parent</default>
|
||||
</property>
|
||||
<property>
|
||||
<name>group_onclick_r</name>
|
||||
<type>string</type>
|
||||
<default></default>
|
||||
</property>
|
||||
<property>
|
||||
<name>group_params_r</name>
|
||||
<type>string</type>
|
||||
<default></default>
|
||||
</property>
|
||||
<property>
|
||||
<name>group_onclick_l</name>
|
||||
<type>string</type>
|
||||
<default></default>
|
||||
</property>
|
||||
<property>
|
||||
<name>group_params_l</name>
|
||||
<type>string</type>
|
||||
<default></default>
|
||||
</property>
|
||||
<property>
|
||||
<name>on_enter</name>
|
||||
<type>string</type>
|
||||
|
@ -18,5 +108,30 @@
|
|||
<type>string</type>
|
||||
<default>params</default>
|
||||
</property>
|
||||
<property>
|
||||
<name>win_proprity</name>
|
||||
<type>int</type>
|
||||
<default>3</default>
|
||||
</property>
|
||||
<property>
|
||||
<name>use_cursor</name>
|
||||
<type>bool</type>
|
||||
<default>true</default>
|
||||
</property>
|
||||
<property>
|
||||
<name>on_escape</name>
|
||||
<type>string</type>
|
||||
<default></default>
|
||||
</property>
|
||||
<property>
|
||||
<name>on_escape_params</name>
|
||||
<type>string</type>
|
||||
<default></default>
|
||||
</property>
|
||||
<property>
|
||||
<name>lua_class</name>
|
||||
<type>string</type>
|
||||
<default></default>
|
||||
</property>
|
||||
</properties>
|
||||
</widget>
|
||||
|
|
Loading…
Reference in a new issue