1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
|
<!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="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>wxWidgets: wxTextCompleterSimple Class Reference</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>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="extra_stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="page_container">
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0" style="width: 100%;">
<tbody>
<tr>
<td id="projectlogo">
<a href="http://www.wxwidgets.org/" target="_new">
<img alt="wxWidgets" src="logo.png"/>
</a>
</td>
<td style="padding-left: 0.5em; text-align: right;">
<span id="projectnumber">Version: 3.0.2</span>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Generated by Doxygen 1.8.2 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="modules.html"><span>Categories</span></a></li>
<li class="current"><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="annotated.html"><span>Class List</span></a></li>
<li><a href="classes.html"><span>Class Index</span></a></li>
<li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li>
<li><a href="functions.html"><span>Class Members</span></a></li>
</ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> |
<a href="classwx_text_completer_simple-members.html">List of all members</a> </div>
<div class="headertitle">
<div class="title">wxTextCompleterSimple Class Reference<span class="mlabels"><span class="mlabel">abstract</span></span></div> </div>
</div><!--header-->
<div class="contents">
<p><code>#include <wx/textcompleter.h></code></p>
<div id="dynsection-0" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
<img id="dynsection-0-trigger" src="closed.png" alt="+"/> Inheritance diagram for wxTextCompleterSimple:</div>
<div id="dynsection-0-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-0-content" class="dyncontent" style="display:none;">
<div class="center"><img src="classwx_text_completer_simple__inherit__graph.png" border="0" usemap="#wx_text_completer_simple_inherit__map" alt="Inheritance graph"/></div>
<map name="wx_text_completer_simple_inherit__map" id="wx_text_completer_simple_inherit__map">
<area shape="rect" id="node2" href="classwx_text_completer.html" title="Base class for custom text completer objects." alt="" coords="25,6,145,34"/></map>
<center><span class="legend">[<a href="graph_legend.html">legend</a>]</span></center></div>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>A simpler base class for custom completer objects. </p>
<p>This class may be simpler to use than the base <a class="el" href="classwx_text_completer.html" title="Base class for custom text completer objects.">wxTextCompleter</a> as it allows to implement only a single virtual method instead of two of them (at the price of storing all completions in a temporary array).</p>
<p>Here is a simple example of a custom completer that completes the names of some chess pieces. Of course, as the total list here has only four items it would have been much simpler to just specify the array containing all the completions in this example but the same approach could be used when the total number of completions is much higher provided the number of possibilities for each word is still relatively small: </p>
<div class="fragment"><div class="line"><span class="keyword">class </span>MyTextCompleter : <span class="keyword">public</span> <a class="code" href="classwx_text_completer_simple.html" title="A simpler base class for custom completer objects.">wxTextCompleterSimple</a></div>
<div class="line">{</div>
<div class="line"><span class="keyword">public</span>:</div>
<div class="line"> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classwx_text_completer_simple.html#abf3d103eda25bcb7a9d572523d0de736" title="Pure virtual method returning all possible completions for the given prefix.">GetCompletions</a>(<span class="keyword">const</span> <a class="code" href="classwx_string.html" title="String class for passing textual data to or receiving it from wxWidgets.">wxString</a>& prefix, <a class="code" href="classwx_array_string.html" title="wxArrayString is an efficient container for storing wxString objects.">wxArrayString</a>& res)</div>
<div class="line"> {</div>
<div class="line"> <span class="keyword">const</span> <a class="code" href="classwx_string.html" title="String class for passing textual data to or receiving it from wxWidgets.">wxString</a> firstWord = prefix.<a class="code" href="classwx_string.html#ac37f690daad1637493dc8ffc7c0efe70" title="Gets all characters before the first occurrence of ch.">BeforeFirst</a>(<span class="charliteral">' '</span>);</div>
<div class="line"> <span class="keywordflow">if</span> ( firstWord == <span class="stringliteral">"white"</span> )</div>
<div class="line"> {</div>
<div class="line"> res.push_back(<span class="stringliteral">"white pawn"</span>);</div>
<div class="line"> res.push_back(<span class="stringliteral">"white rook"</span>);</div>
<div class="line"> }</div>
<div class="line"> <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( firstWord == <span class="stringliteral">"black"</span> )</div>
<div class="line"> {</div>
<div class="line"> res.push_back(<span class="stringliteral">"black king"</span>);</div>
<div class="line"> res.push_back(<span class="stringliteral">"black queen"</span>);</div>
<div class="line"> }</div>
<div class="line"> <span class="keywordflow">else</span></div>
<div class="line"> {</div>
<div class="line"> res.push_back(<span class="stringliteral">"white"</span>);</div>
<div class="line"> res.push_back(<span class="stringliteral">"black"</span>);</div>
<div class="line"> }</div>
<div class="line"> }</div>
<div class="line">};</div>
<div class="line">...</div>
<div class="line">wxTextCtrl *text = ...;</div>
<div class="line">text->AutoComplete(<span class="keyword">new</span> MyTextCompleter);</div>
</div><!-- fragment --><h2></h2>
<div><span class="lib">Library:</span>  <span class="lib_text"><a class="el" href="page_libs.html#page_libs_wxcore">wxCore</a></span></div><dl class="section since"><dt>Since</dt><dd>2.9.2 </dd></dl>
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:abf3d103eda25bcb7a9d572523d0de736"><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_text_completer_simple.html#abf3d103eda25bcb7a9d572523d0de736">GetCompletions</a> (const <a class="el" href="classwx_string.html">wxString</a> &prefix, <a class="el" href="classwx_array_string.html">wxArrayString</a> &res)=0</td></tr>
<tr class="memdesc:abf3d103eda25bcb7a9d572523d0de736"><td class="mdescLeft"> </td><td class="mdescRight">Pure virtual method returning all possible completions for the given prefix. <a href="#abf3d103eda25bcb7a9d572523d0de736"></a><br/></td></tr>
<tr class="separator:abf3d103eda25bcb7a9d572523d0de736"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="inherit_header pub_methods_classwx_text_completer"><td colspan="2" onclick="javascript:toggleInherit('pub_methods_classwx_text_completer')"><img src="closed.png" alt="-"/> Public Member Functions inherited from <a class="el" href="classwx_text_completer.html">wxTextCompleter</a></td></tr>
<tr class="memitem:a041c2f6544f3071f45a944f7ebc743f5 inherit pub_methods_classwx_text_completer"><td class="memItemLeft" align="right" valign="top">virtual bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_text_completer.html#a041c2f6544f3071f45a944f7ebc743f5">Start</a> (const <a class="el" href="classwx_string.html">wxString</a> &prefix)=0</td></tr>
<tr class="memdesc:a041c2f6544f3071f45a944f7ebc743f5 inherit pub_methods_classwx_text_completer"><td class="mdescLeft"> </td><td class="mdescRight">Function called to start iteration over the completions for the given prefix. <a href="#a041c2f6544f3071f45a944f7ebc743f5"></a><br/></td></tr>
<tr class="separator:a041c2f6544f3071f45a944f7ebc743f5 inherit pub_methods_classwx_text_completer"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:afcfaf585fe34114a444411148c299619 inherit pub_methods_classwx_text_completer"><td class="memItemLeft" align="right" valign="top">virtual <a class="el" href="classwx_string.html">wxString</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_text_completer.html#afcfaf585fe34114a444411148c299619">GetNext</a> ()=0</td></tr>
<tr class="memdesc:afcfaf585fe34114a444411148c299619 inherit pub_methods_classwx_text_completer"><td class="mdescLeft"> </td><td class="mdescRight">Called to retrieve the next completion. <a href="#afcfaf585fe34114a444411148c299619"></a><br/></td></tr>
<tr class="separator:afcfaf585fe34114a444411148c299619 inherit pub_methods_classwx_text_completer"><td class="memSeparator" colspan="2"> </td></tr>
</table>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="abf3d103eda25bcb7a9d572523d0de736"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">virtual void wxTextCompleterSimple::GetCompletions </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="classwx_string.html">wxString</a> & </td>
<td class="paramname"><em>prefix</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="classwx_array_string.html">wxArrayString</a> & </td>
<td class="paramname"><em>res</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">pure virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Pure virtual method returning all possible completions for the given prefix. </p>
<p>The custom completer should examine the provided prefix and return all the possible completions for it in the output array <em>res</em>.</p>
<p>Please notice that the returned values should start with the prefix, otherwise they will be simply ignored, making adding them to the array in the first place useless.</p>
<p>Notice that this function may be called from thread other than main one (this is currently always the case under MSW) so the appropriate synchronization mechanism should be used to protect the shared data.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">prefix</td><td>The possibly empty prefix that the user had already entered. </td></tr>
<tr><td class="paramname">res</td><td>Initially empty array that should be filled with all possible completions (possibly none if there are no valid possibilities starting with the given prefix). </td></tr>
</table>
</dd>
</dl>
</div>
</div>
</div><!-- contents -->
<address class="footer">
<small>
Generated on Thu Nov 27 2014 13:47:00 for wxWidgets by <a href="http://www.doxygen.org/index.html" target="_new">Doxygen</a> 1.8.2
</small>
</address>
<script src="wxwidgets.js" type="text/javascript"></script>
</div><!-- #page_container -->
</body>
</html>
|