CHANGED: #1471 Implemented property querying for for CViewText.

This commit is contained in:
dfighter1985 2012-08-02 19:25:00 +02:00
parent 95b5f61d8c
commit 94fb0bbb8a
3 changed files with 246 additions and 1 deletions

View file

@ -54,6 +54,7 @@ namespace NLGUI
CViewText &operator=(const CViewText &vt);
std::string getProperty( const std::string &name ) const;
void parseTextOptions (xmlNodePtr cur);
bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
@ -199,7 +200,7 @@ namespace NLGUI
virtual void serial(NLMISC::IStream &f);
protected:
std::string _HardtextFormat;
/// Text to display.
ucstring _Text;
/// index of the computed String associated to this text control

View file

@ -176,6 +176,133 @@ namespace NLGUI
return *this;
}
std::string CViewText::getProperty( const std::string &name ) const
{
if( name == "color" )
{
return toString( _Color );
}
else
if( name == "global_color" )
{
return toString( _ModulateGlobalColor );
}
else
if( name == "fontsize" )
{
return toString(
_FontSize - CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont ).getValSInt32()
);
}
else
if( name == "shadow" )
{
return toString( _Shadow );
}
else
if( name == "shadow_color" )
{
return toString( _ShadowColor );
}
else
if( name == "multi_line" )
{
return toString( _MultiLine );
}
else
if( name == "justification" )
{
switch( _TextMode )
{
case ClipWord:
return "clip_word";
break;
case DontClipWord:
return "dont_clip_word";
break;
case Justified:
return "justified";
break;
}
return "";
}
else
if( name == "line_maxw" )
{
return toString( _LineMaxW );
}
else
if( name == "multi_line_space" )
{
return toString( _MultiLineSpace );
}
else
if( name == "multi_line_maxw_only" )
{
return toString( _MultiLineMaxWOnly );
}
else
if( name == "multi_max_line" )
{
return toString( _MultiMaxLine );
}
else
if( name == "underlined" )
{
return toString( _Underlined );
}
else
if( name == "case_mode" )
{
return toString( uint32( _CaseMode ) );
}
else
if( name == "over_extend_view_text" )
{
return toString( _OverExtendViewText );
}
else
if( name == "over_extend_parent_rect" )
{
return toString( _OverExtendViewTextUseParentRect );
}
else
if( name == "auto_clamp" )
{
return toString( _AutoClamp );
}
else
if( name == "clamp_right" )
{
return toString( _ClampRight );
}
else
if( name == "auto_clamp_offset" )
{
return toString( _AutoClampOffset );
}
else
if( name == "continuous_update" )
{
return toString( _ContinuousUpdate );
}
else
if( name == "hardtext" )
{
return _Text.toString();
}
else
if( name == "hardtext_format" )
{
return _HardtextFormat;
}
else
return CViewBase::getProperty( name );
}
// ***************************************************************************
void CViewText::parseTextOptions (xmlNodePtr cur)
{
@ -333,6 +460,8 @@ namespace NLGUI
if (prop)
{
const char *propPtr = prop;
_HardtextFormat = propPtr;
if (_MultiLine)
{
setTextFormatTaged(CI18N::get(propPtr));

View file

@ -0,0 +1,115 @@
<widget>
<header>
<name>ViewText</name>
<guiname>CViewText</guiname>
<ancestor>CtrlBase</ancestor>
<description></description>
<abstract>false</abstract>
<icon></icon>
</header>
<properties>
<property>
<name>color</name>
<type>string</type>
<default>255 255 255 255</default>
</property>
<property>
<name>global_color</name>
<type>bool</type>
<default>false</default>
</property>
<property>
<name>fontsize</name>
<type>int</type>
<default>12</default>
</property>
<property>
<name>shadow</name>
<type>bool</type>
<default>false</default>
</property>
<property>
<name>shadow_color</name>
<type>string</type>
<default>0 0 0 255</default>
</property>
<property>
<name>multi_line</name>
<type>bool</type>
<default>false</default>
</property>
<property>
<name>justification</name>
<type>string</type>
<default>dont_clip_word</default>
</property>
<property>
<name>line_maxw</name>
<type>int</type>
<default>0</default>
</property>
<property>
<name>multi_line_space</name>
<type>int</type>
<default>8</default>
</property>
<property>
<name>multi_line_maxw_only</name>
<type>bool</type>
<default>false</default>
</property>
<property>
<name>multi_max_line</name>
<type>int</type>
<default>0</default>
</property>
<property>
<name>underlined</name>
<type>bool</type>
<default>false</default>
</property>
<property>
<name>case_mode</name>
<type>int</type>
<default>0</default>
</property>
<property>
<name>over_extend_view_text</name>
<type>bool</type>
<default>false</default>
</property>
<property>
<name>over_extend_parent_rect</name>
<type>bool</type>
<default>false</default>
</property>
<property>
<name>clamp_right</name>
<type>bool</type>
<default>true</default>
</property>
<property>
<name>auto_clamp_offset</name>
<type>int</type>
<default>0</default>
</property>
<property>
<name>continuous_update</name>
<type>bool</type>
<default>false</default>
</property>
<property>
<name>hardtext</name>
<type>string</type>
<default></default>
</property>
<property>
<name>hardtext_format</name>
<type>string</type>
<default></default>
</property>
</properties>
</widget>