ewol/ewol_tutorial_hello_world.html

243 lines
40 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: Hello world</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: Hello world </div> </div>
</div><!--header-->
<div class="contents">
<div class="toc"><h3>Table of Contents</h3>
<ul><li class="level1"><a href="#ewol_tutorial_hello_world_objectives">Objectif: </a></li>
<li class="level1"><a href="#ewol_tutorial_hello_world_debug">debug tools: </a></li>
<li class="level1"><a href="#ewol_tutorial_hello_world_sources">Application Sources: </a><ul><li class="level2"><a href="#ewol_tutorial_hello_world_sources_main">Application Main: </a></li>
<li class="level2"><a href="#ewol_tutorial_hello_world_sources_config">Some configuration are needed </a></li>
<li class="level2"><a href="#ewol_tutorial_hello_world_sources_windows">Main Windows: </a></li>
<li class="level2"><a href="#ewol_tutorial_hello_world_sources_configure_ewol">Configure Ewol to have display the windows </a></li>
</ul>
</li>
<li class="level1"><a href="#ewol_tutorial_hello_world_build">Build declaration: </a></li>
<li class="level1"><a href="#ewol_tutorial_hello_world_buildappl">Build your application </a></li>
</ul>
</div>
<div class="textblock"><h1><a class="anchor" id="ewol_tutorial_hello_world_objectives"></a>
Objectif: </h1>
<ul>
<li>Understand basis of ewol</li>
<li>Create a simple windows with a label "Hello Word"</li>
</ul>
<h1><a class="anchor" id="ewol_tutorial_hello_world_debug"></a>
debug tools: </h1>
<p>I will use for all test a basic template <a href="http://atria-soft.github.io/elog">elog</a> for debug logger that redirect logs in Android and IOs</p>
<p>File <code>appl/debug.hpp</code>:</p>
<div class="fragment"><div class="line"></div><div class="line"><span class="preprocessor">#pragma once</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="codeRef" doxygen="/home/heero/dev/perso/out/doc/release/elog.tag:http://atria-soft.github.io/elog/" href="http://atria-soft.github.io/elog/log__8hpp.html">elog/log.hpp</a>&gt;</span></div><div class="line"></div><div class="line"><span class="keyword">namespace </span>appl {</div><div class="line"> int32_t getLogId();</div><div class="line">};</div><div class="line"><span class="preprocessor">#define APPL_BASE(info,data) ELOG_BASE(appl::getLogId(),info,data)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#define APPL_CRITICAL(data) APPL_BASE(1, data)</span></div><div class="line"><span class="preprocessor">#define APPL_ERROR(data) APPL_BASE(2, data)</span></div><div class="line"><span class="preprocessor">#define APPL_WARNING(data) APPL_BASE(3, data)</span></div><div class="line"><span class="preprocessor">#ifdef DEBUG</span></div><div class="line"><span class="preprocessor"> #define APPL_INFO(data) APPL_BASE(4, data)</span></div><div class="line"><span class="preprocessor"> #define APPL_DEBUG(data) APPL_BASE(5, data)</span></div><div class="line"><span class="preprocessor"> #define APPL_VERBOSE(data) APPL_BASE(6, data)</span></div><div class="line"><span class="preprocessor"> #define APPL_TODO(data) APPL_BASE(4, &quot;TODO : &quot; &lt;&lt; data)</span></div><div class="line"><span class="preprocessor">#else</span></div><div class="line"><span class="preprocessor"> #define APPL_INFO(data) do { } while(false)</span></div><div class="line"><span class="preprocessor"> #define APPL_DEBUG(data) do { } while(false)</span></div><div class="line"><span class="preprocessor"> #define APPL_VERBOSE(data) do { } while(false)</span></div><div class="line"><span class="preprocessor"> #define APPL_TODO(data) do { } while(false)</span></div><div class="line"><span class="preprocessor">#endif</span></div><div class="line"></div><div class="line"><span class="preprocessor">#define APPL_ASSERT(cond,data) \</span></div><div class="line"><span class="preprocessor"> do { \</span></div><div class="line"><span class="preprocessor"> if (!(cond)) { \</span></div><div class="line"><span class="preprocessor"> APPL_CRITICAL(data); \</span></div><div class="line"><span class="preprocessor"> assert(!#cond); \</span></div><div class="line"><span class="preprocessor"> } \</span></div><div class="line"><span class="preprocessor"> } while (0)</span></div></div><!-- fragment --><p>File <code>appl/debug.cpp</code>:</p>
<div class="fragment"><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;appl/debug.hpp&gt;</span></div><div class="line"></div><div class="line">int32_t appl::getLogId() {</div><div class="line"> <span class="keyword">static</span> int32_t g_val = <a class="codeRef" doxygen="/home/heero/dev/perso/out/doc/release/elog.tag:http://atria-soft.github.io/elog/" href="http://atria-soft.github.io/elog/namespaceelog.html#a7e40b0be74fd80765658df83f72a4e3e">elog::registerInstance</a>(<span class="stringliteral">&quot;example&quot;</span>);</div><div class="line"> <span class="keywordflow">return</span> g_val;</div><div class="line">}</div></div><!-- fragment --><h1><a class="anchor" id="ewol_tutorial_hello_world_sources"></a>
Application Sources: </h1>
<h2><a class="anchor" id="ewol_tutorial_hello_world_sources_main"></a>
Application Main: </h2>
<p>A generic Ewol application is manage by creating an <a class="el" href="classewol_1_1context_1_1_application.html">ewol::context::Application</a> that is the basis of your application.</p>
<p>Due to the fact the ewol library is a multi-platform framework (base on <a href="http://atria-soft.github.io/gale">GALE</a>), you will have many contraint like:</p><ul>
<li>One application at the same time (note an exception for android wallpaper)</li>
<li>One Windows displayable at the time (main point of view of apple developpers)</li>
<li>Not a big CPU ...</li>
</ul>
<p>Then we will create the application:</p>
<p>First things: Some includes:</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &lt;<a class="codeRef" doxygen="/home/heero/dev/perso/out/doc/release/etk.tag:http://atria-soft.github.io/etk/" href="http://atria-soft.github.io/etk/types__8hpp.html">etk/types.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="ewol_8hpp.html">ewol/ewol.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;gale/context/commandLine.hpp&gt;</span></div></div><!-- fragment --><p> Declare the application:</p>
<div class="fragment"><div class="line"><span class="keyword">namespace </span>appl {</div><div class="line"> <span class="keyword">class </span>MainApplication : <span class="keyword">public</span> <a class="code" href="classewol_1_1context_1_1_application.html">ewol::context::Application</a> {</div><div class="line"> <span class="keyword">public</span>:</div><div class="line"> <span class="keywordtype">void</span> onCreate(<a class="code" href="classewol_1_1_context.html">ewol::Context</a>&amp; _context)<span class="keyword"> override </span>{</div><div class="line"> APPL_INFO(<span class="stringliteral">&quot;==&gt; CREATE ... &quot;</span> PROJECT_NAME <span class="stringliteral">&quot; (BEGIN)&quot;</span>);</div><div class="line"> localCreate(_context);</div><div class="line"> APPL_INFO(<span class="stringliteral">&quot;==&gt; CREATE ... &quot;</span> PROJECT_NAME <span class="stringliteral">&quot; (END)&quot;</span>);</div><div class="line"> }</div><div class="line"> <span class="keywordtype">void</span> onStart(<a class="code" href="classewol_1_1_context.html">ewol::Context</a>&amp; _context)<span class="keyword"> override </span>{</div><div class="line"> APPL_INFO(<span class="stringliteral">&quot;==&gt; START ... &quot;</span> PROJECT_NAME <span class="stringliteral">&quot; (BEGIN)&quot;</span>);</div><div class="line"> <span class="comment">// nothing to do ...</span></div><div class="line"> APPL_INFO(<span class="stringliteral">&quot;==&gt; START ... &quot;</span> PROJECT_NAME <span class="stringliteral">&quot; (END)&quot;</span>);</div><div class="line"> }</div><div class="line"> <span class="keywordtype">void</span> onResume(<a class="code" href="classewol_1_1_context.html">ewol::Context</a>&amp; _context)<span class="keyword"> override </span>{</div><div class="line"> APPL_INFO(<span class="stringliteral">&quot;==&gt; RESUME ... &quot;</span> PROJECT_NAME <span class="stringliteral">&quot; (BEGIN)&quot;</span>);</div><div class="line"> <span class="comment">// nothing to do ...</span></div><div class="line"> APPL_INFO(<span class="stringliteral">&quot;==&gt; RESUME ... &quot;</span> PROJECT_NAME <span class="stringliteral">&quot; (END)&quot;</span>);</div><div class="line"> }</div><div class="line"> <span class="keywordtype">void</span> onPause(<a class="code" href="classewol_1_1_context.html">ewol::Context</a>&amp; _context)<span class="keyword"> override </span>{</div><div class="line"> APPL_INFO(<span class="stringliteral">&quot;==&gt; PAUSE ... &quot;</span> PROJECT_NAME <span class="stringliteral">&quot; (BEGIN)&quot;</span>);</div><div class="line"> <span class="comment">// nothing to do ...</span></div><div class="line"> APPL_INFO(<span class="stringliteral">&quot;==&gt; PAUSE ... &quot;</span> PROJECT_NAME <span class="stringliteral">&quot; (END)&quot;</span>);</div><div class="line"> }</div><div class="line"> <span class="keywordtype">void</span> onStop(<a class="code" href="classewol_1_1_context.html">ewol::Context</a>&amp; _context)<span class="keyword"> override </span>{</div><div class="line"> APPL_INFO(<span class="stringliteral">&quot;==&gt; STOP ... &quot;</span> PROJECT_NAME <span class="stringliteral">&quot; (START)&quot;</span>);</div><div class="line"> <span class="comment">// nothing to do ...</span></div><div class="line"> APPL_INFO(<span class="stringliteral">&quot;==&gt; STOP ... &quot;</span> PROJECT_NAME <span class="stringliteral">&quot; (END)&quot;</span>);</div><div class="line"> }</div><div class="line"> <span class="keywordtype">void</span> onDestroy(<a class="code" href="classewol_1_1_context.html">ewol::Context</a>&amp; _context)<span class="keyword"> override </span>{</div><div class="line"> APPL_INFO(<span class="stringliteral">&quot;==&gt; DESTROY ... &quot;</span> PROJECT_NAME <span class="stringliteral">&quot; (START)&quot;</span>);</div><div class="line"> <span class="comment">// nothing to do ...</span></div><div class="line"> APPL_INFO(<span class="stringliteral">&quot;==&gt; DESTROY ... &quot;</span> PROJECT_NAME <span class="stringliteral">&quot; (END)&quot;</span>);</div><div class="line"> }</div></div><!-- fragment --><p>The input <a class="el" href="classewol_1_1_context.html">ewol::Context</a> is the main system context (for ewol).</p>
<p><b>Note:</b></p>
<div class="fragment"><div class="line">It is important to know that the system can create your application multiple times, the basic example of this is the Wallpaper on Android.</div><div class="line"></div><div class="line">What is done:</div><div class="line"> - When we select the wallpaper it create a new application (to show an example)</div><div class="line"> - When applying your choice, it create the real one an remove the previous one.</div></div><!-- fragment --><p>In all program we need to have a main()</p>
<p>To be portable on Android, the "main" in the java might call your main through the Android wrapper.</p>
<p>To simplify compabilities between platform it is recommanded to not add other things in the application main:</p>
<div class="fragment"><div class="line"></div><div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> _argc, <span class="keyword">const</span> <span class="keywordtype">char</span> *_argv[]) {</div><div class="line"> <span class="comment">// second possibility</span></div><div class="line"> <span class="keywordflow">return</span> <a class="code" href="ewol_8hpp.html#a6f0683bb3c85a81f0f61b85971e6bf8b">ewol::run</a>(<span class="keyword">new</span> appl::MainApplication(), _argc, _argv);</div><div class="line">}</div></div><!-- fragment --><h2><a class="anchor" id="ewol_tutorial_hello_world_sources_config"></a>
Some configuration are needed </h2>
<p>In your application you can use many configuration, it is really better to set all your configuration dynamic. With this basic condition will simplify the interface of the library if you would have many different application (never forget the compilator garbage collector is really very efficient).</p>
<p>All of this will be done one time: Then we will do it in:</p>
<div class="fragment"><div class="line"> <span class="keywordtype">void</span> onCreate(<a class="code" href="classewol_1_1_context.html">ewol::Context</a>&amp; _context)<span class="keyword"> override </span>{</div><div class="line"> APPL_INFO(<span class="stringliteral">&quot;==&gt; CREATE ... &quot;</span> PROJECT_NAME <span class="stringliteral">&quot; (BEGIN)&quot;</span>);</div><div class="line"> localCreate(_context);</div><div class="line"> APPL_INFO(<span class="stringliteral">&quot;==&gt; CREATE ... &quot;</span> PROJECT_NAME <span class="stringliteral">&quot; (END)&quot;</span>);</div><div class="line"> }</div></div><!-- fragment --> <h3>Parse arguments:</h3>
<p>All the argument is store in the ewol main application context: just get it...</p>
<div class="fragment"><div class="line"> <span class="comment">// parse all the argument of the application</span></div><div class="line"> <span class="keywordflow">for</span> (int32_t iii=0 ; iii&lt;_context.getCmd().size(); iii++) {</div><div class="line"> std::string tmpppp = _context.getCmd().get(iii);</div><div class="line"> <span class="keywordflow">if</span> ( tmpppp == <span class="stringliteral">&quot;-h&quot;</span></div><div class="line"> || tmpppp == <span class="stringliteral">&quot;--help&quot;</span>) {</div><div class="line"> APPL_INFO(<span class="stringliteral">&quot; -h/--help display this help&quot;</span> );</div><div class="line"> exit(0);</div><div class="line"> }</div><div class="line"> }</div></div><!-- fragment --> <h3>Set basic windosw size (for desktop):</h3>
<p>On descktop you can specify a start windows size:</p>
<div class="fragment"><div class="line"> <span class="comment">// TODO : Remove this: Move if in the windows properties</span></div><div class="line"> _context.setSize(<a class="codeRef" doxygen="/home/heero/dev/perso/out/doc/release/etk.tag:http://atria-soft.github.io/etk/" href="http://atria-soft.github.io/etk/classetk_1_1_vector2_d.html">vec2</a>(800, 600));</div></div><!-- fragment --><h3>Select fonts:</h3>
<p>This can be a problem when you design an application for some other operating system (OS), They do not have the same default fonts, than you can embended some of them or try to use the system fonts.</p>
<p>We select an order to search the font names and the system basic size.</p>
<div class="fragment"><div class="line"> <span class="comment">// eneble the search of the font in the system font path</span></div><div class="line"> _context.getFontDefault().setUseExternal(<span class="keyword">true</span>);</div><div class="line"> <span class="comment">// select font preference of der with a basic application size</span></div><div class="line"> _context.getFontDefault().set(<span class="stringliteral">&quot;FreeSerif;DejaVuSansMono&quot;</span>, 19);</div></div><!-- fragment --><h2><a class="anchor" id="ewol_tutorial_hello_world_sources_windows"></a>
Main Windows: </h2>
<p>Create the main Windows:</p>
<p>For this point we will create a class that herited form the basic <a class="el" href="classewol_1_1widget_1_1_windows.html" title="Windows basic interface. ">ewol::widget::Windows</a> class:</p>
<div class="fragment"><div class="line"></div><div class="line"><span class="preprocessor">#pragma once</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="_windows_8hpp.html">ewol/widget/Windows.hpp</a>&gt;</span></div><div class="line"></div><div class="line"><span class="keyword">namespace </span>appl {</div><div class="line"> <span class="keyword">class </span>Windows;</div><div class="line"> <span class="keyword">using</span> WindowsShared = <a class="codeRef" doxygen="/home/heero/dev/perso/out/doc/release/ememory.tag:http://atria-soft.github.io/ememory/" href="http://atria-soft.github.io/ememory/classememory_1_1_shared_ptr.html">ememory::SharedPtr&lt;appl::Windows&gt;</a>;</div><div class="line"> <span class="keyword">using</span> WindowsWeak = <a class="codeRef" doxygen="/home/heero/dev/perso/out/doc/release/ememory.tag:http://atria-soft.github.io/ememory/" href="http://atria-soft.github.io/ememory/classememory_1_1_weak_ptr.html">ememory::WeakPtr&lt;appl::Windows&gt;</a>;</div><div class="line"> <span class="keyword">class </span>Windows : <span class="keyword">public</span> <a class="code" href="classewol_1_1widget_1_1_windows.html">ewol::widget::Windows</a> {</div><div class="line"> <span class="keyword">protected</span>:</div><div class="line"> Windows();</div><div class="line"> <span class="keywordtype">void</span> <a class="codeRef" doxygen="/home/heero/dev/perso/out/doc/release/elog.tag:http://atria-soft.github.io/elog/" href="http://atria-soft.github.io/elog/namespaceelog.html#a1005ac82c94e09b499d29b70a98cd5cc">init</a>();</div><div class="line"> <span class="keyword">public</span>:</div><div class="line"> DECLARE_FACTORY(Windows);</div><div class="line"> };</div><div class="line">}</div><div class="line"></div></div><!-- fragment --><p>The C macro "DECLARE_FACTORY" create a simple factory function "create" that return the <a class="el" href="classewol_1_1_object.html" title="Basic message classes for ewol system this class mermit at every Object to communicate between them...">ewol::Object</a> well create.</p>
<p>For some internal reason, we create the object and we call the "init" function after creating the object. When well done we return the shared object created.</p>
<p>See <a class="el" href="ewol_tutorial_object_model.html">EWOL: Object model</a> to understand why this structure is so complex.</p>
<div class="fragment"><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="ewol_8hpp.html">ewol/ewol.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;appl/debug.hpp&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;appl/Windows.hpp&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="_label_8hpp.html">ewol/widget/Label.hpp</a>&gt;</span></div><div class="line"></div><div class="line">appl::Windows::Windows() {</div><div class="line"> addObjectType(<span class="stringliteral">&quot;appl::Windows&quot;</span>);</div><div class="line"> propertyTitle.setDirectCheck(std::string(<span class="stringliteral">&quot;sample &quot;</span>) + PROJECT_NAME);</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> appl::Windows::init() {</div><div class="line"> ewol::widget::Windows::init();</div><div class="line"> <a class="codeRef" doxygen="/home/heero/dev/perso/out/doc/release/ememory.tag:http://atria-soft.github.io/ememory/" href="http://atria-soft.github.io/ememory/classememory_1_1_shared_ptr.html">ewol::widget::LabelShared</a> tmpWidget = ewol::widget::Label::create();</div><div class="line"> <span class="keywordflow">if</span> (tmpWidget == <span class="keyword">nullptr</span>) {</div><div class="line"> APPL_ERROR(<span class="stringliteral">&quot;Can not allocate widget ==&gt; display might be in error&quot;</span>);</div><div class="line"> } <span class="keywordflow">else</span> {</div><div class="line"> tmpWidget-&gt;<a class="code" href="classewol_1_1widget_1_1_label.html#a9d6420ddec78c0d1abea850a79b4577a">propertyValue</a>.<a class="codeRef" doxygen="/home/heero/dev/perso/out/doc/release/eproperty.tag:http://atria-soft.github.io/eproperty/" href="http://atria-soft.github.io/eproperty/classeproperty_1_1_property_type.html#a29dd42486e15d92b9ea94d30e99854e1">set</a>(<span class="stringliteral">&quot;Hello &lt;font color=&#39;blue&#39;&gt;World&lt;/font&gt;&quot;</span>);</div><div class="line"> tmpWidget-&gt;<a class="code" href="classewol_1_1_widget.html#a3bc497e98895d8fcfcc130cd072853f0">propertyExpand</a>.set(<a class="codeRef" doxygen="/home/heero/dev/perso/out/doc/release/etk.tag:http://atria-soft.github.io/etk/" href="http://atria-soft.github.io/etk/classetk_1_1_vector2_d.html">bvec2</a>(<span class="keyword">true</span>,<span class="keyword">true</span>));</div><div class="line"> <span class="comment">// confidure the label as a windows sub-widget</span></div><div class="line"> setSubWidget(tmpWidget);</div><div class="line"> }</div><div class="line">}</div><div class="line"></div><div class="line"></div></div><!-- fragment --><p>The init function is virtual and you must call your parent object (or at least the ewol::Object::init)</p>
<div class="fragment"><div class="line"> ewol::widget::Windows::init();</div></div><!-- fragment --><p>The title is associated on the current windows then it is a simple property of <a class="el" href="classewol_1_1widget_1_1_windows.html" title="Windows basic interface. ">ewol::widget::Windows</a>.</p>
<p>We can change with calling the "setDirectCheck" function instead of "set" function when you are in the constructor (the callback can be unstable when we construct the object)</p>
<div class="fragment"><div class="line"> propertyTitle.setDirectCheck(std::string(<span class="stringliteral">&quot;sample &quot;</span>) + PROJECT_NAME);</div></div><!-- fragment --><p>The object <a class="el" href="classewol_1_1widget_1_1_windows.html" title="Windows basic interface. ">ewol::widget::Windows</a> is a simple container. But the reference between Object is <a class="elRef" doxygen="/home/heero/dev/perso/out/doc/release/ememory.tag:http://atria-soft.github.io/ememory/" href="http://atria-soft.github.io/ememory/classememory_1_1_shared_ptr.html">ememory::SharedPtr</a>, and this is not accessible in the constructor. This is the reason we use init function.</p>
<p>After we simple create a <a class="el" href="classewol_1_1widget_1_1_label.html">ewol::widget::Label</a> in the main windows init. We set label and basic properties:</p>
<div class="fragment"><div class="line"> <a class="codeRef" doxygen="/home/heero/dev/perso/out/doc/release/ememory.tag:http://atria-soft.github.io/ememory/" href="http://atria-soft.github.io/ememory/classememory_1_1_shared_ptr.html">ewol::widget::LabelShared</a> tmpWidget = ewol::widget::Label::create();</div><div class="line"> <span class="keywordflow">if</span> (tmpWidget == <span class="keyword">nullptr</span>) {</div><div class="line"> APPL_ERROR(<span class="stringliteral">&quot;Can not allocate widget ==&gt; display might be in error&quot;</span>);</div><div class="line"> } <span class="keywordflow">else</span> {</div><div class="line"> tmpWidget-&gt;<a class="code" href="classewol_1_1widget_1_1_label.html#a9d6420ddec78c0d1abea850a79b4577a">propertyValue</a>.<a class="codeRef" doxygen="/home/heero/dev/perso/out/doc/release/eproperty.tag:http://atria-soft.github.io/eproperty/" href="http://atria-soft.github.io/eproperty/classeproperty_1_1_property_type.html#a29dd42486e15d92b9ea94d30e99854e1">set</a>(<span class="stringliteral">&quot;Hello &lt;font color=&#39;blue&#39;&gt;World&lt;/font&gt;&quot;</span>);</div><div class="line"> tmpWidget-&gt;<a class="code" href="classewol_1_1_widget.html#a3bc497e98895d8fcfcc130cd072853f0">propertyExpand</a>.set(<a class="codeRef" doxygen="/home/heero/dev/perso/out/doc/release/etk.tag:http://atria-soft.github.io/etk/" href="http://atria-soft.github.io/etk/classetk_1_1_vector2_d.html">bvec2</a>(<span class="keyword">true</span>,<span class="keyword">true</span>));</div><div class="line"> <span class="comment">// confidure the label as a windows sub-widget</span></div><div class="line"> setSubWidget(tmpWidget);</div><div class="line"> }</div></div><!-- fragment --><p> When we call the function <code>ewol::Windows::setSubWidget</code>, it use the SharedFromThis() function that create an exception if we are in constructor (when setting the sub-widget parrent)</p>
<p>We can see in this example that the label have some other property like the font color.</p>
<p>The label can have decorated text based on the html generic writing but it is composed with really simple set of balise. I will take a really long time to create a real html parser.</p>
<p>The availlable property is:</p><ul>
<li><code>&lt;br/&gt;</code> : New line</li>
<li><code>&lt;font color="#FF0000\"&gt; ... &lt;/font&gt;</code> : change the font color.</li>
<li><code>&lt;center&gt; ... &lt;/center&gt;</code> : center the text.</li>
<li><code>&lt;left&gt; ... &lt;/left&gt;</code> : Set the text on the left.</li>
<li><code>&lt;right&gt; ... &lt;/right&gt;</code> : Set the text on the right.</li>
<li><code>&lt;justify&gt; ... &lt;/justify&gt;</code> : Set the text mode in justify.</li>
</ul>
<p><b>Note:</b></p>
<div class="fragment"><div class="line">The xml parser is a little strict on the case and end node (!! &lt;/br&gt; !!),</div><div class="line">but it support to:</div><div class="line"> - Not have a main node.</div><div class="line"> - replace &#39;&quot;&#39; with &#39;&#39;&#39; to simplify xml writing in C code.</div></div><!-- fragment --><h2><a class="anchor" id="ewol_tutorial_hello_world_sources_configure_ewol"></a>
Configure Ewol to have display the windows </h2>
<p>At this point we have created the basic windows. But the system does not know it. Then we create windows and set it in the main context main <code>appl::MainApplication::onCreate</code>:</p>
<div class="fragment"><div class="line"> <span class="comment">// Create the windows</span></div><div class="line"> <a class="codeRef" doxygen="/home/heero/dev/perso/out/doc/release/ememory.tag:http://atria-soft.github.io/ememory/" href="http://atria-soft.github.io/ememory/classememory_1_1_shared_ptr.html">ewol::widget::WindowsShared</a> basicWindows = appl::Windows::create();</div><div class="line"> <span class="comment">// configure the ewol context to use the new windows</span></div><div class="line"> _context.setWindows(basicWindows);</div></div><!-- fragment --><p> Here we call the create function that is created by the DECLARE_FACTORY macro</p>
<p><b>Note:</b></p>
<div class="fragment"><div class="line">You can use many windows and select the one you want to display, but I do not think it is the best design.</div></div><!-- fragment --><h1><a class="anchor" id="ewol_tutorial_hello_world_build"></a>
Build declaration: </h1>
<p>Ewol commonly use the <a href="http://HeeroYui.github.io/lutin">lutin</a> build system.</p>
<p>Then we need to add a "lutin_YourApplicationName.py", then for this example: <code>lutin_ewol-sample-HelloWord.py</code></p>
<div class="fragment"><div class="line"><span class="comment">#!/usr/bin/python</span></div><div class="line"><span class="keyword">import</span> lutin.debug <span class="keyword">as</span> debug</div><div class="line"><span class="keyword">import</span> lutin.tools <span class="keyword">as</span> tools</div><div class="line"></div><div class="line"><span class="keyword">def </span>get_type():</div><div class="line"> <span class="keywordflow">return</span> <span class="stringliteral">&quot;BINARY&quot;</span></div><div class="line"></div><div class="line"><span class="keyword">def </span>get_sub_type():</div><div class="line"> <span class="keywordflow">return</span> <span class="stringliteral">&quot;SAMPLE&quot;</span></div><div class="line"></div><div class="line"><span class="keyword">def </span>get_desc():</div><div class="line"> <span class="keywordflow">return</span> <span class="stringliteral">&quot;Tutorial 001 : Hello Word&quot;</span></div><div class="line"></div><div class="line"><span class="keyword">def </span>get_licence():</div><div class="line"> <span class="keywordflow">return</span> <span class="stringliteral">&quot;APACHE-2&quot;</span></div><div class="line"></div><div class="line"><span class="keyword">def </span>get_compagny_type():</div><div class="line"> <span class="keywordflow">return</span> <span class="stringliteral">&quot;com&quot;</span></div><div class="line"></div><div class="line"><span class="keyword">def </span>get_compagny_name():</div><div class="line"> <span class="keywordflow">return</span> <span class="stringliteral">&quot;atria-soft&quot;</span></div><div class="line"></div><div class="line"><span class="keyword">def </span>get_maintainer():</div><div class="line"> <span class="keywordflow">return</span> [<span class="stringliteral">&quot;Mr DUPIN Edouard &lt;yui.heero@gmail.com&gt;&quot;</span>]</div><div class="line"></div><div class="line"><span class="keyword">def </span>get_version():</div><div class="line"> <span class="keywordflow">return</span> [0,1]</div><div class="line"></div><div class="line"><span class="keyword">def </span>configure(target, my_module):</div><div class="line"> my_module.add_src_file([</div><div class="line"> <span class="stringliteral">&#39;appl/Main.cpp&#39;</span>,</div><div class="line"> <span class="stringliteral">&#39;appl/debug.cpp&#39;</span>,</div><div class="line"> <span class="stringliteral">&#39;appl/Windows.cpp&#39;</span>,</div><div class="line"> ])</div><div class="line"> my_module.add_depend([</div><div class="line"> <span class="stringliteral">&#39;ewol&#39;</span></div><div class="line"> ])</div><div class="line"> my_module.add_flag(<span class="stringliteral">&#39;c++&#39;</span>, [</div><div class="line"> <span class="stringliteral">&quot;-DPROJECT_NAME=\&quot;\\\&quot;&quot;</span>+my_module.get_name()+<span class="stringliteral">&quot;\\\&quot;\&quot;&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;-DAPPL_VERSION=\&quot;\\\&quot;&quot;</span> + tools.version_to_string(get_version()) + <span class="stringliteral">&quot;\\\&quot;\&quot;&quot;</span></div><div class="line"> ])</div><div class="line"> my_module.add_path(<span class="stringliteral">&quot;.&quot;</span>)</div><div class="line"> <span class="keywordflow">return</span> <span class="keyword">True</span></div><div class="line"></div></div><!-- fragment --><p>Show <a href="http://HeeroYui.github.io/lutin/lutin_module.html">lutin</a> doc for more information...</p>
<h1><a class="anchor" id="ewol_tutorial_hello_world_buildappl"></a>
Build your application </h1>
<p>Go to your workspace folder and launch:</p>
<div class="fragment"><div class="line">lutin -C -mdebug ewol-sample-HelloWord</div><div class="line"># or</div><div class="line">lutin -C -mdebug ewol-sample-HelloWord?build</div></div><!-- fragment --><p>You can now execute your application:</p>
<div class="fragment"><div class="line">lutin -C -mdebug ewol-sample-HelloWord?run</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>