ewol/ewol_tutorial_add_widget_custum_in_xml.html

182 lines
15 KiB
HTML

<!-- HTML header for doxygen 1.8.8-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- For Mobile Devices -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta name="generator" content="Doxygen 1.8.12"/>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<title>Ewol: Ewol Widget in OpenGl: EWOL: Add Widget in XML access</title>
<!--<link href="tabs.css" rel="stylesheet" type="text/css"/>-->
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="customdoxygen.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<script type="text/javascript" src="doxy-boot.js"></script>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand">Ewol: Ewol Widget in OpenGl 0.10.0</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="index.html">Main&nbsp;Page</a></li>
<li><a href="pages.html">Related&nbsp;Pages</a></li>
<li><a href="namespaces.html">Namespaces</a></li>
<li><a href="annotated.html">Classes</a></li>
<li><a href="files.html">Files</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
Link-libs<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="http://HeeroYui.github.io/lutin">lutin</a></li>
<li><a href="http://atria-soft.github.io/ewol">ewol</a></li>
<li><a href="http://atria-soft.github.io/echrono">echrono</a></li>
<li><a href="http://atria-soft.github.io/etk">etk</a></li>
<li><a href="http://atria-soft.github.io/ejson">ejson</a></li>
<li><a href="http://atria-soft.github.io/exml">exml</a></li>
<li><a href="http://atria-soft.github.io/esvg">esvg</a></li>
<li><a href="http://atria-soft.github.io/egami">egami</a></li>
<li><a href="http://atria-soft.github.io/gale">gale</a></li>
<li><a href="http://atria-soft.github.io/ege">ege</a></li>
<li><a href="http://atria-soft.github.io/elog">elog</a></li>
<li><a href="http://atria-soft.github.io/ememory">ememory</a></li>
<li><a href="http://atria-soft.github.io/enet">enet</a></li>
<li><a href="http://atria-soft.github.io/eproperty">eproperty</a></li>
<li><a href="http://atria-soft.github.io/esignal">esignal</a></li>
<li><a href="http://atria-soft.github.io/etranslate">etranslate</a></li>
<li><a href="http://atria-soft.github.io/zeus">zeus</a></li>
<li><a href="http://musicdsp.github.io/audio-ess">audio-ess</a></li>
<li><a href="http://musicdsp.github.io/audio">audio</a></li>
<li><a href="http://musicdsp.github.io/audio-drain">audio-drain</a></li>
<li><a href="http://musicdsp.github.io/audio-orchestra">audio-orchestra</a></li>
<li><a href="http://musicdsp.github.io/audio-river">audio-river</a></li>
</ul>
</li>
</ul>
<div id="search-box" class="input-group">
<div class="input-group-btn">
<button aria-expanded="false" type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span class="glyphicon glyphicon-search"></span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="#">All</a></li>
<li><a href="#">Classes</a></li>
<li><a href="#">Namespaces</a></li>
<li><a href="#">Files</a></li>
<li><a href="#">Functions</a></li>
<li><a href="#">Variables</a></li>
<li><a href="#">Typedefs</a></li>
<li><a href="#">Enumerations</a></li>
<li><a href="#">Enumerator</a></li>
<li><a href="#">Friends</a></li>
<li><a href="#">Macros</a></li>
<li><a href="#">Pages</a></li>
</ul>
</div>
<button id="search-close" type="button" class="close" aria-label="Close">
<span aria-hidden="true"></span>
</button>
<input id="search-field" class="form-control" accesskey="S" onkeydown="searchBox.OnSearchFieldChange(event);" placeholder="Search ..." type="text">
</div>
</div><!--/.nav-collapse -->
</div>
</nav>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div class="content" id="content">
<div class="container">
<div class="row">
<div class="col-sm-12 panel panel-default" style="padding-bottom: 15px;">
<div style="margin-bottom: 15px;margin-top: 60px;">
<!-- end header part -->
<!-- Generated by Doxygen 1.8.12 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">EWOL: Add Widget in XML access </div> </div>
</div><!--header-->
<div class="contents">
<div class="toc"><h3>Table of Contents</h3>
<ul><li class="level1"><a href="#ewol_tutorial_add_widget_custum_in_xml_objectif">Objectifs: </a></li>
<li class="level1"><a href="#ewol_tutorial_add_widget_custum_in_xml_declare">Declare object in XML </a></li>
<li class="level1"><a href="#ewol_tutorial_add_widget_custum_in_xml_dec2">Declare on XML and configuration </a></li>
<li class="level1"><a href="#ewol_tutorial_add_widget_custum_in_xml_parse">Special case SubParsing XML element </a></li>
</ul>
</div>
<div class="textblock"><h1><a class="anchor" id="ewol_tutorial_add_widget_custum_in_xml_objectif"></a>
Objectifs: </h1>
<ul>
<li>Create a C++ widget</li>
<li>use it in a XML</li>
</ul>
<h1><a class="anchor" id="ewol_tutorial_add_widget_custum_in_xml_declare"></a>
Declare object in XML </h1>
<p>Object can be declared in some XML, (like gui decription), then we need to declare the Object in the system recognition.</p>
<h2>Declare Object </h2>
<p>In your application "void onCreate(ewol::Context&amp; _context) override" add the function:</p>
<div class="fragment"><div class="line">YourWidgetClass::createManagerWidget(_context.getWidgetManager());</div></div><!-- fragment --><p>The simple question is: I does not define this function, where it is done ?</p>
<p>The createManagerWidget is instancuate when you use the macro:</p>
<div class="fragment"><div class="line">DECLARE_WIDGET_FACTORY(YourWidgetClass, <span class="stringliteral">&quot;YourWidgetClass&quot;</span>);</div></div><!-- fragment --><p>it create 2 function: "create(...)" and "createManagerWidget()"</p>
<h1><a class="anchor" id="ewol_tutorial_add_widget_custum_in_xml_dec2"></a>
Declare on XML and configuration </h1>
<p>in the xml instance simply request it like:</p>
<div class="fragment"><div class="line">&lt;<span class="keywordtype">YourWidgetClass</span> <span class="keyword">name</span>=<span class="stringliteral">&quot;jkjkj&quot;</span>&gt;</div><div class="line"> ...</div><div class="line">&lt;/<span class="keywordtype">YourWidgetClass</span>&gt;</div></div><!-- fragment --><p>The xml attribute are automaticaly parsed to configure properties of you object (this is the reason of naming it).</p>
<h1><a class="anchor" id="ewol_tutorial_add_widget_custum_in_xml_parse"></a>
Special case SubParsing XML element </h1>
<p>If you want to parse sub-node of the xml just override the function member:</p>
<div class="fragment"><div class="line"><span class="keywordtype">bool</span> loadXML(<span class="keyword">const</span> <a class="codeRef" doxygen="/home/heero/dev/perso/out/doc/release/exml.tag:http://atria-soft.github.io/exml/" href="http://atria-soft.github.io/exml/classexml_1_1_element.html">exml::Element</a>&amp; _node) <span class="keyword">override</span>;</div></div><!-- fragment --><p>Many example are availlable in container widget.</p>
<p>Simple example:</p>
<div class="fragment"><div class="line"><span class="keywordflow">if</span> (_node.exist() == <span class="keyword">false</span>) {</div><div class="line"> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line">}</div><div class="line"><span class="comment">// parse generic properties:</span></div><div class="line"><a class="code" href="classewol_1_1_widget.html#ae07ac7316857f71f873d586d3a84f08b">ewol::Widget::loadXML</a>(_node);</div><div class="line"><span class="comment">// parse all the elements:</span></div><div class="line"><span class="keywordflow">for</span> (<span class="keyword">const</span> <span class="keyword">auto</span> it : _node.nodes) {</div><div class="line"> <a class="codeRef" doxygen="/home/heero/dev/perso/out/doc/release/exml.tag:http://atria-soft.github.io/exml/" href="http://atria-soft.github.io/exml/classexml_1_1_element.html">exml::Element</a> pNode = it.<a class="codeRef" doxygen="/home/heero/dev/perso/out/doc/release/exml.tag:http://atria-soft.github.io/exml/" href="http://atria-soft.github.io/exml/classexml_1_1_node.html#a767481c377a99616b66b953a02f64dbe">toElement</a>();</div><div class="line"> <span class="keywordflow">if</span> (pNode.<a class="codeRef" doxygen="/home/heero/dev/perso/out/doc/release/exml.tag:http://atria-soft.github.io/exml/" href="http://atria-soft.github.io/exml/classexml_1_1_node.html#ae2be1ded472149113f3ea70710f57b39">exist</a>() == <span class="keyword">false</span>) {</div><div class="line"> <span class="comment">// trash here all that is not element</span></div><div class="line"> <span class="keywordflow">continue</span>;</div><div class="line"> }</div><div class="line"> <span class="comment">// Get the sub-node name:</span></div><div class="line"> std::string widgetName = pNode.<a class="codeRef" doxygen="/home/heero/dev/perso/out/doc/release/exml.tag:http://atria-soft.github.io/exml/" href="http://atria-soft.github.io/exml/classexml_1_1_node.html#a8b9a9d4befc43fce6cf11076b4d11aca">getValue</a>();</div><div class="line"> <span class="keywordflow">if</span> (getWidgetManager().exist(widgetName) == <span class="keyword">false</span>) {</div><div class="line"> APPL_ERROR(<span class="stringliteral">&quot;[&quot;</span> &lt;&lt; getId() &lt;&lt; <span class="stringliteral">&quot;] (l &quot;</span>&lt;&lt;pNode-&gt;<a class="codeRef" doxygen="/home/heero/dev/perso/out/doc/release/exml.tag:http://atria-soft.github.io/exml/" href="http://atria-soft.github.io/exml/classexml_1_1_node.html#a54d14b2b0d56d68d451b97b60e05c0cb">getPos</a>()&lt;&lt;<span class="stringliteral">&quot;) Unknown basic node=&#39;&quot;</span> &lt;&lt; widgetName &lt;&lt; <span class="stringliteral">&quot;&#39; not in : [&quot;</span> &lt;&lt; getWidgetManager().list() &lt;&lt; <span class="stringliteral">&quot;]&quot;</span> );</div><div class="line"> <span class="keywordflow">continue</span>;</div><div class="line"> }</div><div class="line"> ...</div><div class="line">}</div><div class="line"><span class="keywordflow">return</span> <span class="keyword">true</span>;</div></div><!-- fragment --> </div></div><!-- contents -->
<!-- HTML footer for doxygen 1.8.8-->
<!-- start footer part -->
</div>
</div>
</div>
</div>
</div>
<hr class="footer"/><address class="footer"><small>
Generated on Mon Oct 24 2016 15:35:52 for Ewol: Ewol Widget in OpenGl by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.12
</small></address>
</body>
</html>