CHANGED: #1471 Implemented property querying for CGroupEditbox and CGroupCell.

This commit is contained in:
dfighter1985 2012-07-30 21:50:51 +02:00
parent c5d25276bf
commit 54cc17e769
7 changed files with 416 additions and 3 deletions

View file

@ -48,6 +48,8 @@ namespace NLGUI
/// Dtor /// Dtor
~CGroupEditBox(); ~CGroupEditBox();
std::string getProperty( const std::string &name ) const;
bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup); bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup);
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }

View file

@ -59,8 +59,6 @@ namespace NLGUI
static CGroupEditBoxBase *_CurrSelection; // the edit box for which the selection is currently active, or NULL if there's none static CGroupEditBoxBase *_CurrSelection; // the edit box for which the selection is currently active, or NULL if there's none
private:
}; };
} }

View file

@ -57,6 +57,8 @@ namespace NLGUI
virtual sint32 getMaxUsedW() const; virtual sint32 getMaxUsedW() const;
virtual sint32 getMinUsedW() const; virtual sint32 getMinUsedW() const;
std::string getProperty( const std::string &name ) const;
// to be called by CGroupTable // to be called by CGroupTable
bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup, uint columnIndex, uint rowIndex); bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup, uint columnIndex, uint rowIndex);

View file

@ -100,6 +100,161 @@ namespace NLGUI
} }
} }
std::string CGroupEditBox::getProperty( const stlpx_std::string &name ) const
{
if( name == "onchange" )
{
return _AHOnChange;
}
else
if( name == "onchange_params" )
{
return _ParamsOnChange;
}
else
if( name == "on_focus_lost" )
{
return _AHOnFocusLost;
}
else
if( name == "on_focus_lost_params" )
{
return _AHOnFocusLostParams;
}
else
if( name == "on_focus" )
{
return _AHOnFocus;
}
else
if( name == "on_focus_params" )
{
return _AHOnFocusParams;
}
else
if( name == "max_num_chars" )
{
return toString( _MaxNumChar );
}
else
if( name == "max_num_return" )
{
return toString( _MaxNumReturn );
}
else
if( name == "max_chars_size" )
{
return toString( _MaxCharsSize );
}
else
if( name == "enter_loose_focus" )
{
return toString( _LooseFocusOnEnter );
}
else
if( name == "enter_recover_focus" )
{
return toString( _RecoverFocusOnEnter );
}
else
if( name == "prompt" )
{
return _Prompt.toString();
}
else
if( name == "enter_type" )
{
switch( _EntryType )
{
case Integer:
return "integer";
break;
case PositiveInteger:
return "positive_integer";
break;
case Float:
return "float";
break;
case PositiveFloat:
return "positive_float";
break;
case Alpha:
return "alpha";
break;
case AlphaNum:
return "alpha_num";
break;
case AlphaNumSpace:
return "alpha_num_space";
break;
case Password:
return "password";
break;
case Filename:
return "filename";
break;
case PlayerName:
return "playername";
break;
}
return "text";
}
else
if( name == "menu_r" )
{
return _ListMenuRight;
}
else
if( name == "max_historic" )
{
return toString( _MaxHistoric );
}
else
if( name == "backup_father_container_pos" )
{
return toString( _BackupFatherContainerPos );
}
else
if( name == "want_return" )
{
return toString( _WantReturn );
}
else
if( name == "savable" )
{
return toString( _Savable );
}
else
if( name == "max_float_prec" )
{
return toString( _MaxFloatPrec );
}
else
if( name == "negative_filter" )
{
std::string s;
s.reserve( _NegativeFilter.size() );
std::vector< char >::const_iterator itr;
for( itr = _NegativeFilter.begin(); itr != _NegativeFilter.end(); ++itr )
s.push_back( *itr );
return s;
}
else
return CInterfaceGroup::getProperty( name );
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool CGroupEditBox::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) bool CGroupEditBox::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup)
{ {
@ -168,7 +323,8 @@ namespace NLGUI
else if (stricmp(prop, "password") == 0) _EntryType = Password; else if (stricmp(prop, "password") == 0) _EntryType = Password;
else if (stricmp(prop, "filename") == 0) _EntryType = Filename; else if (stricmp(prop, "filename") == 0) _EntryType = Filename;
else if (stricmp(prop, "playername") == 0) _EntryType = PlayerName; else if (stricmp(prop, "playername") == 0) _EntryType = PlayerName;
else nlwarning("<CGroupEditBox::parse> Unknown entry type %s", (const char *) prop); else
nlwarning("<CGroupEditBox::parse> Unknown entry type %s", (const char *) prop);
} }
prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_r" ); prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_r" );

View file

@ -71,6 +71,87 @@ namespace NLGUI
Group->setResizeFromChildH(true); Group->setResizeFromChildH(true);
} }
std::string CGroupCell::getProperty( const std::string &name ) const
{
if( name == "align" )
{
switch( Align )
{
case Right:
return "right";
break;
case Center:
return "center";
break;
}
return "left";
}
else
if( name == "valign" )
{
switch( VAlign )
{
case Middle:
return "middle";
break;
case Bottom:
return "bottom";
break;
}
return "top";
}
else
if( name == "left_margin" )
{
return toString( LeftMargin );
}
else
if( name == "nowrap" )
{
return toString( NoWrap );
}
else
if( name == "bgcolor" )
{
return toString( BgColor );
}
else
if( name == "width" )
{
if( WidthWanted != 0 )
return toString( WidthWanted );
else
return toString( TableRatio * 100.0f );
}
else
if( name == "height" )
{
return toString( Height );
}
else
if( name == "ignore_max_width" )
{
return toString( IgnoreMaxWidth );
}
else
if( name == "ignore_min_width" )
{
return toString( IgnoreMinWidth );
}
else
if( name == "add_child_w" )
{
return toString( AddChildW );
}
else
return CInterfaceGroup::getProperty( name );
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool CGroupCell::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup, uint columnIndex, uint rowIndex) bool CGroupCell::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup, uint columnIndex, uint rowIndex)
{ {

View file

@ -0,0 +1,62 @@
<widget>
<header>
<name>GroupCell</name>
<guiname>CGroupCell</guiname>
<ancestor>InterfaceGroup</ancestor>
<description></description>
<abstract>false</abstract>
<icon></icon>
</header>
<properties>
<property>
<name>align</name>
<type>string</type>
<default>left</default>
</property>
<property>
<name>valign</name>
<type>string</type>
<default>top</default>
</property>
<property>
<name>left_margin</name>
<type>int</type>
<default>0</default>
</property>
<property>
<name>nowrap</name>
<type>bool</type>
<default>false</default>
</property>
<property>
<name>bgcolor</name>
<type>string</type>
<default>0 0 0 0</default>
</property>
<property>
<name>width</name>
<type>string</type>
<default>0</default>
</property>
<property>
<name>height</name>
<type>int</type>
<default>0</default>
</property>
<property>
<name>ignore_max_width</name>
<type>bool</type>
<default>false</default>
</property>
<property>
<name>ignore_min_width</name>
<type>bool</type>
<default>false</default>
</property>
<property>
<name>add_child_w</name>
<type>bool</type>
<default>false</default>
</property>
</properties>
</widget>

View file

@ -0,0 +1,112 @@
<widget>
<header>
<name>GroupEditBox</name>
<guiname>CGroupEditBox</guiname>
<ancestor>InterfaceGroup</ancestor>
<description></description>
<abstract>false</abstract>
<icon></icon>
</header>
<properties>
<property>
<name>onchange</name>
<type>string</type>
<default></default>
</property>
<property>
<name>onchange_params</name>
<type>string</type>
<default></default>
</property>
<property>
<name>on_focus_lost</name>
<type>string</type>
<default></default>
</property>
<property>
<name>on_focus_lost_params</name>
<type>string</type>
<default></default>
</property>
<property>
<name>on_focus</name>
<type>string</type>
<default></default>
</property>
<property>
<name>on_focus_params</name>
<type>string</type>
<default></default>
</property>
<property>
<name>max_num_chars</name>
<type>int</type>
<default>2000000000</default>
</property>
<property>
<name>max_num_return</name>
<type>int</type>
<default>2000000000</default>
</property>
<property>
<name>max_chars_size</name>
<type>int</type>
<default>32768</default>
</property>
<property>
<name>enter_loose_focus</name>
<type>bool</type>
<default>true</default>
</property>
<property>
<name>enter_recover_focus</name>
<type>bool</type>
<default>true</default>
</property>
<property>
<name>prompt</name>
<type>string</type>
<default></default>
</property>
<property>
<name>enter_type</name>
<type>string</type>
<default>text</default>
</property>
<property>
<name>menu_r</name>
<type>string</type>
<default></default>
</property>
<property>
<name>max_historic</name>
<type>int</type>
<default>0</default>
</property>
<property>
<name>backup_father_container_pos</name>
<type>bool</type>
<default>false</default>
</property>
<property>
<name>want_return</name>
<type>bool</type>
<default>false</default>
</property>
<property>
<name>savable</name>
<type>bool</type>
<default>true</default>
</property>
<property>
<name>max_float_prec</name>
<type>int</type>
<default>20</default>
</property>
<property>
<name>negative_filter</name>
<type>string</type>
<default></default>
</property>
</properties>
</widget>