mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-28 11:50:53 +00:00
CHANGED: #1471 CCtrlBase fields can now be serialized.
This commit is contained in:
parent
a3c1d0307d
commit
28811105be
5 changed files with 60 additions and 7 deletions
|
@ -63,6 +63,8 @@ namespace NLGUI
|
||||||
|
|
||||||
void setProperty( const std::string &name, const std::string &value );
|
void setProperty( const std::string &name, const std::string &value );
|
||||||
|
|
||||||
|
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||||
|
|
||||||
// special parse
|
// special parse
|
||||||
virtual bool parse(xmlNodePtr cur, CInterfaceGroup *parentGroup);
|
virtual bool parse(xmlNodePtr cur, CInterfaceGroup *parentGroup);
|
||||||
|
|
||||||
|
@ -171,6 +173,8 @@ namespace NLGUI
|
||||||
THotSpot _ToolTipPosRefAlt : 6;
|
THotSpot _ToolTipPosRefAlt : 6;
|
||||||
protected:
|
protected:
|
||||||
void convertTooltipHotSpot(const char *prop, THotSpot &parentHS, THotSpot &childHS);
|
void convertTooltipHotSpot(const char *prop, THotSpot &parentHS, THotSpot &childHS);
|
||||||
|
static std::string TooltipHotSpotToString( THotSpot parent, THotSpot child );
|
||||||
|
|
||||||
bool resizer;
|
bool resizer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,7 @@ namespace NLGUI
|
||||||
|
|
||||||
virtual void setProperty( const std::string &name, const std::string &value );
|
virtual void setProperty( const std::string &name, const std::string &value );
|
||||||
|
|
||||||
virtual bool serialize( xmlNodePtr parentNode, const char *type ) const;
|
virtual xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||||
|
|
||||||
/// Parse the element and initalize it
|
/// Parse the element and initalize it
|
||||||
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
|
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
|
||||||
|
|
|
@ -313,6 +313,33 @@ namespace NLGUI
|
||||||
CInterfaceElement::setProperty( name, value );
|
CInterfaceElement::setProperty( name, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
xmlNodePtr CCtrlBase::serialize( xmlNodePtr parentNode, const char *type ) const
|
||||||
|
{
|
||||||
|
xmlNodePtr node =
|
||||||
|
CInterfaceElement::serialize( parentNode, type );
|
||||||
|
|
||||||
|
if( node == NULL )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
xmlNewProp( node, BAD_CAST "tooltip", BAD_CAST _ContextHelp.toString().c_str() );
|
||||||
|
xmlNewProp( node, BAD_CAST "tooltip_i18n", BAD_CAST _ContextHelp.toString().c_str() );
|
||||||
|
xmlNewProp( node, BAD_CAST "on_tooltip", BAD_CAST _OnContextHelp.toString().c_str() );
|
||||||
|
xmlNewProp( node, BAD_CAST "on_tooltip_params", BAD_CAST _OnContextHelpParams.toString().c_str() );
|
||||||
|
xmlNewProp( node, BAD_CAST "tooltip_parent", BAD_CAST tooltipParentToString( _ToolTipParent ).c_str() );
|
||||||
|
xmlNewProp( node, BAD_CAST "tooltip_special_parent", BAD_CAST _ToolTipSpecialParent.toString().c_str() );
|
||||||
|
|
||||||
|
xmlNewProp( node, BAD_CAST "tooltip_posref",
|
||||||
|
BAD_CAST TooltipHotSpotToString( _ToolTipParentPosRef, _ToolTipPosRef ).c_str() );
|
||||||
|
|
||||||
|
xmlNewProp( node, BAD_CAST "tooltip_posref_alt",
|
||||||
|
BAD_CAST TooltipHotSpotToString( _ToolTipParentPosRefAlt, _ToolTipPosRefAlt ).c_str() );
|
||||||
|
|
||||||
|
xmlNewProp( node, BAD_CAST "instant_help", BAD_CAST toString( _ToolTipInstant ).c_str() );
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
void CCtrlBase::convertTooltipHotSpot(const char *prop, THotSpot &parentHS, THotSpot &childHS)
|
void CCtrlBase::convertTooltipHotSpot(const char *prop, THotSpot &parentHS, THotSpot &childHS)
|
||||||
{
|
{
|
||||||
|
@ -339,6 +366,24 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string CCtrlBase::TooltipHotSpotToString( THotSpot parent, THotSpot child )
|
||||||
|
{
|
||||||
|
std::string s;
|
||||||
|
|
||||||
|
if( ( parent == Hotspot_TTAuto ) && ( child == Hotspot_TTAuto ) )
|
||||||
|
{
|
||||||
|
s = "auto";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
s = CInterfaceElement::HotSpotToString( parent );
|
||||||
|
s += " ";
|
||||||
|
s += CInterfaceElement::HotSpotToString( child );
|
||||||
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
bool CCtrlBase::emptyContextHelp() const
|
bool CCtrlBase::emptyContextHelp() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -259,11 +259,11 @@ namespace NLGUI
|
||||||
nlwarning( "Tried to set invalid property '%s' for widget '%s'", name.c_str(), _Id.c_str() );
|
nlwarning( "Tried to set invalid property '%s' for widget '%s'", name.c_str(), _Id.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CInterfaceElement::serialize( xmlNodePtr parentNode, const char *type ) const
|
xmlNodePtr CInterfaceElement::serialize( xmlNodePtr parentNode, const char *type ) const
|
||||||
{
|
{
|
||||||
xmlNodePtr node = xmlNewNode( NULL, BAD_CAST type );
|
xmlNodePtr node = xmlNewNode( NULL, BAD_CAST type );
|
||||||
if( node == NULL )
|
if( node == NULL )
|
||||||
return false;
|
return NULL;
|
||||||
|
|
||||||
xmlAddChild( parentNode, node );
|
xmlAddChild( parentNode, node );
|
||||||
|
|
||||||
|
@ -284,7 +284,7 @@ namespace NLGUI
|
||||||
xmlNewProp( node, BAD_CAST "render_layer", BAD_CAST toString( _RenderLayer ).c_str() );
|
xmlNewProp( node, BAD_CAST "render_layer", BAD_CAST toString( _RenderLayer ).c_str() );
|
||||||
xmlNewProp( node, BAD_CAST "avoid_resize_parent", BAD_CAST toString( _AvoidResizeParent ).c_str() );
|
xmlNewProp( node, BAD_CAST "avoid_resize_parent", BAD_CAST toString( _AvoidResizeParent ).c_str() );
|
||||||
|
|
||||||
return true;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace GUIEditor
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !mg->serialize( root, "root" ) )
|
if( mg->serialize( root, "root" ) == NULL )
|
||||||
{
|
{
|
||||||
xmlFreeNode( root );
|
xmlFreeNode( root );
|
||||||
out.close();
|
out.close();
|
||||||
|
@ -66,8 +66,12 @@ namespace GUIEditor
|
||||||
xmlAttrPtr prop = node->properties;
|
xmlAttrPtr prop = node->properties;
|
||||||
while( prop != NULL )
|
while( prop != NULL )
|
||||||
{
|
{
|
||||||
std::string name = std::string( (const char*)prop->name );
|
std::string name =
|
||||||
std::string value = std::string( (const char*)xmlGetProp( node, BAD_CAST name.c_str() ) );
|
std::string( reinterpret_cast< const char* >( prop->name ) );
|
||||||
|
|
||||||
|
std::string value =
|
||||||
|
std::string( reinterpret_cast< const char* >( xmlGetProp( node, BAD_CAST name.c_str() ) ) );
|
||||||
|
|
||||||
out << " " << name << "=\"" << value << "\"" << std::endl;
|
out << " " << name << "=\"" << value << "\"" << std::endl;
|
||||||
|
|
||||||
prop = prop->next;
|
prop = prop->next;
|
||||||
|
|
Loading…
Reference in a new issue