mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-12-16 01:48:56 +08:00
216 lines
15 KiB
HTML
216 lines
15 KiB
HTML
|
|
<!-- HTML header for doxygen 1.9.8-->
|
||
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
|
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
|
||
|
|
<head>
|
||
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||
|
|
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
||
|
|
<meta name="generator" content="Doxygen 1.12.0"/>
|
||
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||
|
|
<title>FTXUI: examples/component/radiobox_in_frame.cpp</title>
|
||
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
||
|
|
<script type="text/javascript" src="jquery.js"></script>
|
||
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
||
|
|
<script type="text/javascript" src="doxygen-awesome-fragment-copy-button.js"></script>
|
||
|
|
<script type="text/javascript" src="doxygen-awesome-paragraph-link.js"></script>
|
||
|
|
<script type="text/javascript" src="doxygen-awesome-interactive-toc.js"></script>
|
||
|
|
<script type="text/javascript" src="doxygen-awesome-tabs.js"></script>
|
||
|
|
<script type="text/javascript">
|
||
|
|
DoxygenAwesomeFragmentCopyButton.init()
|
||
|
|
DoxygenAwesomeParagraphLink.init()
|
||
|
|
DoxygenAwesomeInteractiveToc.init()
|
||
|
|
DoxygenAwesomeTabs.init()
|
||
|
|
</script>
|
||
|
|
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
||
|
|
<script type="text/javascript" src="navtreedata.js"></script>
|
||
|
|
<script type="text/javascript" src="navtree.js"></script>
|
||
|
|
<script type="text/javascript" src="resize.js"></script>
|
||
|
|
<script type="text/javascript" src="cookie.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="doxygen-awesome.css" rel="stylesheet" type="text/css"/>
|
||
|
|
<link href="stylesheet.css" rel="stylesheet" type="text/css"/>
|
||
|
|
</head>
|
||
|
|
<body>
|
||
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||
|
|
<div id="titlearea">
|
||
|
|
<table cellspacing="0" cellpadding="0">
|
||
|
|
<tbody>
|
||
|
|
<tr id="projectrow">
|
||
|
|
<td id="projectalign">
|
||
|
|
<div id="projectname">FTXUI<span id="projectnumber"> 6.1.9</span>
|
||
|
|
</div>
|
||
|
|
<div id="projectbrief">C++ functional terminal UI.</div>
|
||
|
|
</td>
|
||
|
|
</tr>
|
||
|
|
</tbody>
|
||
|
|
</table>
|
||
|
|
</div>
|
||
|
|
<!-- end header part -->
|
||
|
|
<!-- Generated by Doxygen 1.12.0 -->
|
||
|
|
<script type="text/javascript">
|
||
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||
|
|
var searchBox = new SearchBox("searchBox", "search/",'.html');
|
||
|
|
/* @license-end */
|
||
|
|
</script>
|
||
|
|
<script type="text/javascript">
|
||
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||
|
|
$(function() { codefold.init(0); });
|
||
|
|
/* @license-end */
|
||
|
|
</script>
|
||
|
|
<script type="text/javascript" src="menudata.js"></script>
|
||
|
|
<script type="text/javascript" src="menu.js"></script>
|
||
|
|
<script type="text/javascript">
|
||
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||
|
|
$(function() {
|
||
|
|
initMenu('',true,false,'search.php','Search',true);
|
||
|
|
$(function() { init_search(); });
|
||
|
|
});
|
||
|
|
/* @license-end */
|
||
|
|
</script>
|
||
|
|
<div id="main-nav"></div>
|
||
|
|
</div><!-- top -->
|
||
|
|
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
||
|
|
<div id="nav-tree">
|
||
|
|
<div id="nav-tree-contents">
|
||
|
|
<div id="nav-sync" class="sync"></div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<div id="splitbar" style="-moz-user-select:none;"
|
||
|
|
class="ui-resizable-handle">
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<script type="text/javascript">
|
||
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||
|
|
$(function(){initNavTree('examples_2component_2radiobox_in_frame_8cpp-example.html',''); initResizable(true); });
|
||
|
|
/* @license-end */
|
||
|
|
</script>
|
||
|
|
<div id="doc-content">
|
||
|
|
<!-- 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">
|
||
|
|
<div id="MSearchResults">
|
||
|
|
<div class="SRPage">
|
||
|
|
<div id="SRIndex">
|
||
|
|
<div id="SRResults"></div>
|
||
|
|
<div class="SRStatus" id="Loading">Loading...</div>
|
||
|
|
<div class="SRStatus" id="Searching">Searching...</div>
|
||
|
|
<div class="SRStatus" id="NoMatches">No Matches</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div class="header">
|
||
|
|
<div class="headertitle"><div class="title">examples/component/radiobox_in_frame.cpp</div></div>
|
||
|
|
</div><!--header-->
|
||
|
|
<div class="contents">
|
||
|
|
<h1><a class="anchor" id="autotoc_md198"></a>
|
||
|
|
renderer</h1>
|
||
|
|
<div class="fragment"><div class="line"><span class="comment">// Copyright 2020 Arthur Sonzogni. All rights reserved.</span></div>
|
||
|
|
<div class="line"><span class="comment">// Use of this source code is governed by the MIT license that can be found in</span></div>
|
||
|
|
<div class="line"><span class="comment">// the LICENSE file.</span></div>
|
||
|
|
<div class="line"><span class="preprocessor">#include <memory></span> <span class="comment">// for shared_ptr, allocator, __shared_ptr_access</span></div>
|
||
|
|
<div class="line"> </div>
|
||
|
|
<div class="line"><span class="preprocessor">#include "<a class="code" href="captured__mouse_8hpp.html">ftxui/component/captured_mouse.hpp</a>"</span> <span class="comment">// for ftxui</span></div>
|
||
|
|
<div class="line"><span class="preprocessor">#include "<a class="code" href="component_8hpp.html">ftxui/component/component.hpp</a>"</span> <span class="comment">// for Renderer, Button, Vertical</span></div>
|
||
|
|
<div class="line"><span class="preprocessor">#include "<a class="code" href="component__base_8hpp.html">ftxui/component/component_base.hpp</a>"</span> <span class="comment">// for ComponentBase</span></div>
|
||
|
|
<div class="line"><span class="preprocessor">#include "<a class="code" href="screen__interactive_8hpp.html">ftxui/component/screen_interactive.hpp</a>"</span> <span class="comment">// for ScreenInteractive</span></div>
|
||
|
|
<div class="line"><span class="preprocessor">#include "<a class="code" href="elements_8hpp.html">ftxui/dom/elements.hpp</a>"</span> <span class="comment">// for operator|, Element, text, bold, border, center, color</span></div>
|
||
|
|
<div class="line"><span class="preprocessor">#include "<a class="code" href="color_8hpp.html">ftxui/screen/color.hpp</a>"</span> <span class="comment">// for Color, Color::Red</span></div>
|
||
|
|
<div class="line"> </div>
|
||
|
|
<div class="line"><span class="keywordtype">int</span> <a id="a0" name="a0"></a><a class="code hl_function" href="examples_2component_2button_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a>() {</div>
|
||
|
|
<div class="line"> <span class="keyword">using namespace </span><a class="code hl_namespace" href="namespaceftxui.html">ftxui</a>;</div>
|
||
|
|
<div class="line"> <span class="keyword">auto</span> screen = ScreenInteractive::FitComponent();</div>
|
||
|
|
<div class="line"> </div>
|
||
|
|
<div class="line"> <span class="comment">// A Renderer() is a component using a lambda function as a parameter to</span></div>
|
||
|
|
<div class="line"> <span class="comment">// render itself.</span></div>
|
||
|
|
<div class="line"> </div>
|
||
|
|
<div class="line"> <span class="comment">// 1. Example of focusable renderer:</span></div>
|
||
|
|
<div class="line"> <span class="keyword">auto</span> renderer_focusable = Renderer([](<span class="keywordtype">bool</span> focused) {</div>
|
||
|
|
<div class="line"> <span class="keywordflow">if</span> (focused)</div>
|
||
|
|
<div class="line"> <span class="keywordflow">return</span> text(<span class="stringliteral">"FOCUSABLE RENDERER()"</span>) | center | bold | border;</div>
|
||
|
|
<div class="line"> <span class="keywordflow">else</span></div>
|
||
|
|
<div class="line"> <span class="keywordflow">return</span> text(<span class="stringliteral">" Focusable renderer() "</span>) | center | border;</div>
|
||
|
|
<div class="line"> });</div>
|
||
|
|
<div class="line"> </div>
|
||
|
|
<div class="line"> <span class="comment">// 2. Examples of a non focusable renderer.</span></div>
|
||
|
|
<div class="line"> <span class="keyword">auto</span> renderer_non_focusable = Renderer([&] {</div>
|
||
|
|
<div class="line"> <span class="keywordflow">return</span> text(<span class="stringliteral">"~~~~~ Non Focusable renderer() ~~~~~"</span>); <span class="comment">//</span></div>
|
||
|
|
<div class="line"> });</div>
|
||
|
|
<div class="line"> </div>
|
||
|
|
<div class="line"> <span class="comment">// 3. Renderer can wrap other components to redefine their Render() function.</span></div>
|
||
|
|
<div class="line"> <span class="keyword">auto</span> button = Button(<span class="stringliteral">"Wrapped quit button"</span>, screen.ExitLoopClosure());</div>
|
||
|
|
<div class="line"> <span class="keyword">auto</span> renderer_wrap = Renderer(button, [&] {</div>
|
||
|
|
<div class="line"> <span class="keywordflow">if</span> (button->Focused())</div>
|
||
|
|
<div class="line"> <span class="keywordflow">return</span> button->Render() | bold | color(Color::Red);</div>
|
||
|
|
<div class="line"> <span class="keywordflow">else</span></div>
|
||
|
|
<div class="line"> <span class="keywordflow">return</span> button->Render();</div>
|
||
|
|
<div class="line"> });</div>
|
||
|
|
<div class="line"> </div>
|
||
|
|
<div class="line"> <span class="comment">// Let's renderer everyone:</span></div>
|
||
|
|
<div class="line"> screen.Loop(Container::Vertical({</div>
|
||
|
|
<div class="line"> renderer_focusable,</div>
|
||
|
|
<div class="line"> renderer_non_focusable,</div>
|
||
|
|
<div class="line"> renderer_wrap,</div>
|
||
|
|
<div class="line"> }));</div>
|
||
|
|
<div class="line">}</div>
|
||
|
|
<div class="ttc" id="acaptured__mouse_8hpp_html"><div class="ttname"><a href="captured__mouse_8hpp.html">captured_mouse.hpp</a></div></div>
|
||
|
|
<div class="ttc" id="acolor_8hpp_html"><div class="ttname"><a href="color_8hpp.html">color.hpp</a></div></div>
|
||
|
|
<div class="ttc" id="acomponent_8hpp_html"><div class="ttname"><a href="component_8hpp.html">component.hpp</a></div></div>
|
||
|
|
<div class="ttc" id="acomponent__base_8hpp_html"><div class="ttname"><a href="component__base_8hpp.html">component_base.hpp</a></div></div>
|
||
|
|
<div class="ttc" id="aelements_8hpp_html"><div class="ttname"><a href="elements_8hpp.html">elements.hpp</a></div></div>
|
||
|
|
<div class="ttc" id="aexamples_2component_2button_8cpp_html_ae66f6b31b5ad750f1fe042a706a4e3d4"><div class="ttname"><a href="examples_2component_2button_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a></div><div class="ttdeci">int main()</div><div class="ttdef"><b>Definition</b> <a href="examples_2component_2button_8cpp_source.html#l00004">examples/component/button.cpp:4</a></div></div>
|
||
|
|
<div class="ttc" id="anamespaceftxui_html"><div class="ttname"><a href="namespaceftxui.html">ftxui</a></div><div class="ttdef"><b>Definition</b> <a href="animation_8hpp_source.html#l00010">animation.hpp:10</a></div></div>
|
||
|
|
<div class="ttc" id="ascreen__interactive_8hpp_html"><div class="ttname"><a href="screen__interactive_8hpp.html">screen_interactive.hpp</a></div></div>
|
||
|
|
</div><!-- fragment --><div class="fragment"><div class="line"><span class="comment">// Copyright 2020 Arthur Sonzogni. All rights reserved.</span></div>
|
||
|
|
<div class="line"><span class="comment">// Use of this source code is governed by the MIT license that can be found in</span></div>
|
||
|
|
<div class="line"><span class="comment">// the LICENSE file.</span></div>
|
||
|
|
<div class="line"><span class="preprocessor">#include <memory></span> <span class="comment">// for shared_ptr, __shared_ptr_access</span></div>
|
||
|
|
<div class="line"><span class="preprocessor">#include <string></span> <span class="comment">// for string, basic_string, operator+, to_string</span></div>
|
||
|
|
<div class="line"><span class="preprocessor">#include <vector></span> <span class="comment">// for vector</span></div>
|
||
|
|
<div class="line"> </div>
|
||
|
|
<div class="line"><span class="preprocessor">#include "<a class="code" href="captured__mouse_8hpp.html">ftxui/component/captured_mouse.hpp</a>"</span> <span class="comment">// for ftxui</span></div>
|
||
|
|
<div class="line"><span class="preprocessor">#include "<a class="code" href="component_8hpp.html">ftxui/component/component.hpp</a>"</span> <span class="comment">// for Radiobox, Renderer</span></div>
|
||
|
|
<div class="line"><span class="preprocessor">#include "<a class="code" href="component__base_8hpp.html">ftxui/component/component_base.hpp</a>"</span> <span class="comment">// for ComponentBase</span></div>
|
||
|
|
<div class="line"><span class="preprocessor">#include "<a class="code" href="screen__interactive_8hpp.html">ftxui/component/screen_interactive.hpp</a>"</span> <span class="comment">// for ScreenInteractive</span></div>
|
||
|
|
<div class="line"><span class="preprocessor">#include "<a class="code" href="elements_8hpp.html">ftxui/dom/elements.hpp</a>"</span> <span class="comment">// for operator|, Element, size, border, frame, HEIGHT, LESS_THAN</span></div>
|
||
|
|
<div class="line"> </div>
|
||
|
|
<div class="line"><span class="keyword">using namespace </span><a class="code hl_namespace" href="namespaceftxui.html">ftxui</a>;</div>
|
||
|
|
<div class="line"> </div>
|
||
|
|
<div class="line"><span class="keywordtype">int</span> <a class="code hl_function" href="examples_2component_2button_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a>() {</div>
|
||
|
|
<div class="line"> std::vector<std::string> entries;</div>
|
||
|
|
<div class="line"> <span class="keywordtype">int</span> selected = 0;</div>
|
||
|
|
<div class="line"> </div>
|
||
|
|
<div class="line"> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < 30; ++i)</div>
|
||
|
|
<div class="line"> entries.push_back(<span class="stringliteral">"RadioBox "</span> + std::to_string(i));</div>
|
||
|
|
<div class="line"> <span class="keyword">auto</span> radiobox = Radiobox(&entries, &selected);</div>
|
||
|
|
<div class="line"> <span class="keyword">auto</span> renderer = Renderer(radiobox, [&] {</div>
|
||
|
|
<div class="line"> <span class="keywordflow">return</span> radiobox->Render() | vscroll_indicator | frame |</div>
|
||
|
|
<div class="line"> size(HEIGHT, LESS_THAN, 10) | border;</div>
|
||
|
|
<div class="line"> });</div>
|
||
|
|
<div class="line"> </div>
|
||
|
|
<div class="line"> <span class="keyword">auto</span> screen = ScreenInteractive::FitComponent();</div>
|
||
|
|
<div class="line"> screen.Loop(renderer);</div>
|
||
|
|
<div class="line"> </div>
|
||
|
|
<div class="line"> <span class="keywordflow">return</span> 0;</div>
|
||
|
|
<div class="line">}</div>
|
||
|
|
</div><!-- fragment --> </div><!-- contents -->
|
||
|
|
</div><!-- doc-content -->
|
||
|
|
<!-- HTML footer for doxygen 1.9.8-->
|
||
|
|
<!-- start footer part -->
|
||
|
|
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
||
|
|
<ul>
|
||
|
|
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.12.0 </li>
|
||
|
|
</ul>
|
||
|
|
</div>
|
||
|
|
</body>
|
||
|
|
</html>
|