menu-example_8cpp-example.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=9"/>
  6. <meta name="generator" content="Doxygen 1.8.17"/>
  7. <meta name="viewport" content="width=device-width, initial-scale=1"/>
  8. <title>Bugz Door Project: menu-example.cpp</title>
  9. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  10. <script type="text/javascript" src="jquery.js"></script>
  11. <script type="text/javascript" src="dynsections.js"></script>
  12. <link href="search/search.css" rel="stylesheet" type="text/css"/>
  13. <script type="text/javascript" src="search/searchdata.js"></script>
  14. <script type="text/javascript" src="search/search.js"></script>
  15. <link href="doxygen.css" rel="stylesheet" type="text/css" />
  16. </head>
  17. <body>
  18. <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
  19. <div id="titlearea">
  20. <table cellspacing="0" cellpadding="0">
  21. <tbody>
  22. <tr style="height: 56px;">
  23. <td id="projectalign" style="padding-left: 0.5em;">
  24. <div id="projectname">Bugz Door Project
  25. </div>
  26. </td>
  27. </tr>
  28. </tbody>
  29. </table>
  30. </div>
  31. <!-- end header part -->
  32. <!-- Generated by Doxygen 1.8.17 -->
  33. <script type="text/javascript">
  34. /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  35. var searchBox = new SearchBox("searchBox", "search",false,'Search');
  36. /* @license-end */
  37. </script>
  38. <script type="text/javascript" src="menudata.js"></script>
  39. <script type="text/javascript" src="menu.js"></script>
  40. <script type="text/javascript">
  41. /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  42. $(function() {
  43. initMenu('',true,false,'search.php','Search');
  44. $(document).ready(function() { init_search(); });
  45. });
  46. /* @license-end */</script>
  47. <div id="main-nav"></div>
  48. </div><!-- top -->
  49. <!-- window showing the filter options -->
  50. <div id="MSearchSelectWindow"
  51. onmouseover="return searchBox.OnSearchSelectShow()"
  52. onmouseout="return searchBox.OnSearchSelectHide()"
  53. onkeydown="return searchBox.OnSearchSelectKey(event)">
  54. </div>
  55. <!-- iframe showing the search results (closed by default) -->
  56. <div id="MSearchResultsWindow">
  57. <iframe src="javascript:void(0)" frameborder="0"
  58. name="MSearchResults" id="MSearchResults">
  59. </iframe>
  60. </div>
  61. <div class="header">
  62. <div class="headertitle">
  63. <div class="title">menu-example.cpp</div> </div>
  64. </div><!--header-->
  65. <div class="contents">
  66. <p>Example using menusThis example shows a menu, and demonstrates the new menu update ability.</p>
  67. <div class="fragment"><div class="line"><span class="preprocessor">#include &quot;door.h&quot;</span></div>
  68. <div class="line"> </div>
  69. <div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[]) {</div>
  70. <div class="line"> <a name="_a0"></a><a class="code" href="classdoor_1_1Door.html">door::Door</a> <a class="code" href="namespacedoor.html">door</a>(<span class="stringliteral">&quot;example&quot;</span>, argc, argv);</div>
  71. <div class="line"> </div>
  72. <div class="line"> <span class="comment">// reset colors, clear screen.</span></div>
  73. <div class="line"> <a class="code" href="namespacedoor.html">door</a> &lt;&lt; <a name="a1"></a><a class="code" href="namespacedoor.html#ae3a70989c43f6cb3522308af748b4481">door::reset</a> &lt;&lt; <a name="a2"></a><a class="code" href="namespacedoor.html#ac70193caf66e4b9aed1529593727a6eb">door::cls</a> &lt;&lt; <a name="a3"></a><a class="code" href="namespacedoor.html#a36352ded72aee66b10e1bda6d3d8efb8">door::nl</a>;</div>
  74. <div class="line"> </div>
  75. <div class="line"> <a name="_a4"></a><a class="code" href="classdoor_1_1Menu.html">door::Menu</a> menu(10, 5, 25);</div>
  76. <div class="line"> menu.<a name="a5"></a>setColor(<a name="_a6"></a><a class="code" href="classdoor_1_1ANSIColor.html">door::ANSIColor</a>(<a name="a7"></a><a class="code" href="namespacedoor.html#abafe0a9e79349883af3ab2a7fb544366a8a568e5f41b7e4da88fe5c4a00aad34e">door::COLOR::YELLOW</a>, <a name="a8"></a><a class="code" href="namespacedoor.html#abafe0a9e79349883af3ab2a7fb544366a1b3e1ee9bff86431dea6b181365ba65f">door::COLOR::BLUE</a>,</div>
  77. <div class="line"> <a name="a9"></a><a class="code" href="namespacedoor.html#add24f9a933f9a6e613de6d56854e5c52a2909dd0e0336f10b6da9735b859a3d19">door::ATTR::BOLD</a>)); <span class="comment">// set border</span></div>
  78. <div class="line"> menu.<a name="a10"></a>setTitle(std::make_unique&lt;door::Line&gt;(<span class="stringliteral">&quot;Menu Example&quot;</span>), 1);</div>
  79. <div class="line"> </div>
  80. <div class="line"> <span class="keywordtype">int</span> arrows = 15;</div>
  81. <div class="line"> <a class="code" href="namespacedoor.html#adb2697f83f8ce701366e05ed72c97d6e">door::updateFunction</a> arrowsUpdate = [&amp;arrows](void) -&gt; std::string {</div>
  82. <div class="line"> std::string text = <span class="stringliteral">&quot;Arrows (&quot;</span>;</div>
  83. <div class="line"> text += std::to_string(arrows);</div>
  84. <div class="line"> text += <span class="stringliteral">&quot; in stock)&quot;</span>;</div>
  85. <div class="line"> <span class="keywordflow">return</span> text;</div>
  86. <div class="line"> };</div>
  87. <div class="line"> menu.<a name="a11"></a>addSelection(<span class="charliteral">&#39;A&#39;</span>, <span class="stringliteral">&quot;Arrows (0 in stock)&quot;</span>, arrowsUpdate);</div>
  88. <div class="line"> menu.addSelection(<span class="charliteral">&#39;C&#39;</span>, <span class="stringliteral">&quot;Color selection&quot;</span>);</div>
  89. <div class="line"> menu.addSelection(<span class="charliteral">&#39;P&#39;</span>, <span class="stringliteral">&quot;Pants&quot;</span>);</div>
  90. <div class="line"> menu.addSelection(<span class="charliteral">&#39;Q&#39;</span>, <span class="stringliteral">&quot;Quit&quot;</span>);</div>
  91. <div class="line"> </div>
  92. <div class="line"> <span class="keywordtype">int</span> r = 0;</div>
  93. <div class="line"> </div>
  94. <div class="line"> <span class="keywordflow">while</span> (r &gt;= 0) {</div>
  95. <div class="line"> menu.<a name="a12"></a><a class="code" href="classdoor_1_1Panel.html#a57234d5f1d891ed8f9ea9c8c9be7aed4">update</a>();</div>
  96. <div class="line"> </div>
  97. <div class="line"> r = menu.<a name="a13"></a><a class="code" href="classdoor_1_1Menu.html#a06da9157cc5984510153a6b93bf2e71e">choose</a>(<a class="code" href="namespacedoor.html">door</a>);</div>
  98. <div class="line"> <span class="keywordflow">if</span> (r &gt; 0) {</div>
  99. <div class="line"> <span class="comment">// we did not timeout</span></div>
  100. <div class="line"> <span class="keywordtype">char</span> c = menu.<a name="a14"></a>which(r - 1);</div>
  101. <div class="line"> <span class="keywordflow">if</span> (c == <span class="charliteral">&#39;A&#39;</span>) {</div>
  102. <div class="line"> <span class="keywordflow">if</span> (arrows &gt; 0)</div>
  103. <div class="line"> --arrows;</div>
  104. <div class="line"> <span class="keywordflow">else</span> {</div>
  105. <div class="line"> <a class="code" href="namespacedoor.html">door</a> &lt;&lt; <a name="_a15"></a><a class="code" href="classdoor_1_1Goto.html">door::Goto</a>(1, 17) &lt;&lt; <a class="code" href="namespacedoor.html#ae3a70989c43f6cb3522308af748b4481">door::reset</a></div>
  106. <div class="line"> &lt;&lt; <span class="stringliteral">&quot;Sorry, we&#39;re out of stock.&quot;</span>;</div>
  107. <div class="line"> <span class="keywordflow">continue</span>;</div>
  108. <div class="line"> }</div>
  109. <div class="line"> }</div>
  110. <div class="line"> </div>
  111. <div class="line"> <a class="code" href="namespacedoor.html">door</a> &lt;&lt; <a class="code" href="classdoor_1_1Goto.html">door::Goto</a>(1, 17) &lt;&lt; <a class="code" href="namespacedoor.html#ae3a70989c43f6cb3522308af748b4481">door::reset</a> &lt;&lt; <span class="stringliteral">&quot;You chose &quot;</span> &lt;&lt; c &lt;&lt; <span class="stringliteral">&quot;!&quot;</span>;</div>
  112. <div class="line"> <span class="keywordflow">if</span> (c == <span class="charliteral">&#39;Q&#39;</span>)</div>
  113. <div class="line"> <span class="keywordflow">break</span>;</div>
  114. <div class="line"> }</div>
  115. <div class="line"> }</div>
  116. <div class="line"> </div>
  117. <div class="line"> <a class="code" href="namespacedoor.html">door</a> &lt;&lt; <a class="code" href="namespacedoor.html#a36352ded72aee66b10e1bda6d3d8efb8">door::nl</a> &lt;&lt; <span class="stringliteral">&quot;Returing to BBS... &quot;</span> &lt;&lt; <a class="code" href="namespacedoor.html#a36352ded72aee66b10e1bda6d3d8efb8">door::nl</a>;</div>
  118. <div class="line">}</div>
  119. </div><!-- fragment --> </div><!-- contents -->
  120. <div class="ttc" id="aclassdoor_1_1Goto_html"><div class="ttname"><a href="classdoor_1_1Goto.html">door::Goto</a></div><div class="ttdoc">ANSI Goto X, Y position.</div><div class="ttdef"><b>Definition:</b> door.h:425</div></div>
  121. <div class="ttc" id="aclassdoor_1_1Door_html"><div class="ttname"><a href="classdoor_1_1Door.html">door::Door</a></div><div class="ttdef"><b>Definition:</b> door.h:190</div></div>
  122. <div class="ttc" id="anamespacedoor_html_add24f9a933f9a6e613de6d56854e5c52a2909dd0e0336f10b6da9735b859a3d19"><div class="ttname"><a href="namespacedoor.html#add24f9a933f9a6e613de6d56854e5c52a2909dd0e0336f10b6da9735b859a3d19">door::ATTR::BOLD</a></div><div class="ttdeci">@ BOLD</div><div class="ttdoc">BOLD is the same as BRIGHT.</div></div>
  123. <div class="ttc" id="aclassdoor_1_1ANSIColor_html"><div class="ttname"><a href="classdoor_1_1ANSIColor.html">door::ANSIColor</a></div><div class="ttdoc">Foreground, Background and Attributes.</div><div class="ttdef"><b>Definition:</b> door.h:137</div></div>
  124. <div class="ttc" id="aclassdoor_1_1Menu_html"><div class="ttname"><a href="classdoor_1_1Menu.html">door::Menu</a></div><div class="ttdef"><b>Definition:</b> door.h:686</div></div>
  125. <div class="ttc" id="anamespacedoor_html_ac70193caf66e4b9aed1529593727a6eb"><div class="ttname"><a href="namespacedoor.html#ac70193caf66e4b9aed1529593727a6eb">door::cls</a></div><div class="ttdeci">Clrscr cls</div><div class="ttdef"><b>Definition:</b> door.cpp:1352</div></div>
  126. <div class="ttc" id="anamespacedoor_html_adb2697f83f8ce701366e05ed72c97d6e"><div class="ttname"><a href="namespacedoor.html#adb2697f83f8ce701366e05ed72c97d6e">door::updateFunction</a></div><div class="ttdeci">std::function&lt; std::string(void)&gt; updateFunction</div><div class="ttdef"><b>Definition:</b> door.h:374</div></div>
  127. <div class="ttc" id="anamespacedoor_html_a36352ded72aee66b10e1bda6d3d8efb8"><div class="ttname"><a href="namespacedoor.html#a36352ded72aee66b10e1bda6d3d8efb8">door::nl</a></div><div class="ttdeci">NewLine nl</div><div class="ttdef"><b>Definition:</b> door.cpp:1380</div></div>
  128. <div class="ttc" id="aclassdoor_1_1Panel_html_a57234d5f1d891ed8f9ea9c8c9be7aed4"><div class="ttname"><a href="classdoor_1_1Panel.html#a57234d5f1d891ed8f9ea9c8c9be7aed4">door::Panel::update</a></div><div class="ttdeci">bool update(Door &amp;d)</div><div class="ttdoc">Updates a panel.</div><div class="ttdef"><b>Definition:</b> panel.cpp:273</div></div>
  129. <div class="ttc" id="anamespacedoor_html_abafe0a9e79349883af3ab2a7fb544366a8a568e5f41b7e4da88fe5c4a00aad34e"><div class="ttname"><a href="namespacedoor.html#abafe0a9e79349883af3ab2a7fb544366a8a568e5f41b7e4da88fe5c4a00aad34e">door::COLOR::YELLOW</a></div><div class="ttdeci">@ YELLOW</div><div class="ttdoc">YELLOW (3)</div></div>
  130. <div class="ttc" id="anamespacedoor_html_ae3a70989c43f6cb3522308af748b4481"><div class="ttname"><a href="namespacedoor.html#ae3a70989c43f6cb3522308af748b4481">door::reset</a></div><div class="ttdeci">ANSIColor reset(ATTR::RESET)</div><div class="ttdoc">reset colors to normal</div><div class="ttdef"><b>Definition:</b> door.h:414</div></div>
  131. <div class="ttc" id="anamespacedoor_html"><div class="ttname"><a href="namespacedoor.html">door</a></div><div class="ttdoc">The BBS door project. This is an attempt at writing a C++ BBS door toolkit.</div><div class="ttdef"><b>Definition:</b> ansicolor.cpp:9</div></div>
  132. <div class="ttc" id="aclassdoor_1_1Menu_html_a06da9157cc5984510153a6b93bf2e71e"><div class="ttname"><a href="classdoor_1_1Menu.html#a06da9157cc5984510153a6b93bf2e71e">door::Menu::choose</a></div><div class="ttdeci">int choose(Door &amp;door)</div><div class="ttdef"><b>Definition:</b> panel.cpp:757</div></div>
  133. <div class="ttc" id="anamespacedoor_html_abafe0a9e79349883af3ab2a7fb544366a1b3e1ee9bff86431dea6b181365ba65f"><div class="ttname"><a href="namespacedoor.html#abafe0a9e79349883af3ab2a7fb544366a1b3e1ee9bff86431dea6b181365ba65f">door::COLOR::BLUE</a></div><div class="ttdeci">@ BLUE</div><div class="ttdoc">BLUE (4)</div></div>
  134. <!-- start footer part -->
  135. <hr class="footer"/><address class="footer"><small>
  136. Generated by &#160;<a href="http://www.doxygen.org/index.html">
  137. <img class="footer" src="doxygen.png" alt="doxygen"/>
  138. </a> 1.8.17
  139. </small></address>
  140. </body>
  141. </html>