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 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
|
<!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: wxTextWrapper 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="#pro-methods">Protected Member Functions</a> |
<a href="classwx_text_wrapper-members.html">List of all members</a> </div>
<div class="headertitle">
<div class="title">wxTextWrapper Class Reference<span class="mlabels"><span class="mlabel">abstract</span></span><div class="ingroups"><a class="el" href="group__group__class__gdi.html">Graphics Device Interface (GDI)</a></div></div> </div>
</div><!--header-->
<div class="contents">
<p><code>#include <wx/textwrapper.h></code></p>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Helps wrap lines of text to given width. </p>
<p>This is a generic purpose class which can be used to wrap lines of text to the specified width. It doesn't do anything by itself but simply calls its virtual <a class="el" href="classwx_text_wrapper.html#a0494d2803dd8471f3f96b3ef7febbb45" title="Called by Wrap() for each wrapped line of text.">OnOutputLine()</a> and <a class="el" href="classwx_text_wrapper.html#a71ef5470d0e0066c8b5d3372d8df5fd7" title="Called at the start of each subsequent line of text by Wrap().">OnNewLine()</a> methods for each wrapped line of text, you need to implement them in your derived class to actually do something useful.</p>
<p>Here is an example function using this class which inserts hard line breaks into a string of text at the positions where it would be wrapped:</p>
<div class="fragment"><div class="line"><a class="code" href="classwx_string.html" title="String class for passing textual data to or receiving it from wxWidgets.">wxString</a> WrapText(<a class="code" href="classwx_window.html" title="wxWindow is the base class for all windows and represents any visible object on screen.">wxWindow</a> *win, <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>& text, <span class="keywordtype">int</span> widthMax)</div>
<div class="line">{</div>
<div class="line"> <span class="keyword">class </span>HardBreakWrapper : <span class="keyword">public</span> <a class="code" href="classwx_text_wrapper.html" title="Helps wrap lines of text to given width.">wxTextWrapper</a></div>
<div class="line"> {</div>
<div class="line"> <span class="keyword">public</span>:</div>
<div class="line"> HardBreakWrapper(<a class="code" href="classwx_window.html" title="wxWindow is the base class for all windows and represents any visible object on screen.">wxWindow</a> *win, <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>& text, <span class="keywordtype">int</span> widthMax)</div>
<div class="line"> {</div>
<div class="line"> <a class="code" href="classwx_text_wrapper.html#afa7189141b03d3f3e41b77f32e501a94" title="Wrap the given text.">Wrap</a>(win, text, widthMax);</div>
<div class="line"> }</div>
<div class="line"></div>
<div class="line"> <a class="code" href="classwx_string.html" title="String class for passing textual data to or receiving it from wxWidgets.">wxString</a> <span class="keyword">const</span>& GetWrapped()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_wrapped; }</div>
<div class="line"></div>
<div class="line"> <span class="keyword">protected</span>:</div>
<div class="line"> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classwx_text_wrapper.html#a0494d2803dd8471f3f96b3ef7febbb45" title="Called by Wrap() for each wrapped line of text.">OnOutputLine</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>& line)</div>
<div class="line"> {</div>
<div class="line"> m_wrapped += line;</div>
<div class="line"> }</div>
<div class="line"></div>
<div class="line"> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classwx_text_wrapper.html#a71ef5470d0e0066c8b5d3372d8df5fd7" title="Called at the start of each subsequent line of text by Wrap().">OnNewLine</a>()</div>
<div class="line"> {</div>
<div class="line"> m_wrapped += <span class="charliteral">'\n'</span>;</div>
<div class="line"> }</div>
<div class="line"></div>
<div class="line"> <span class="keyword">private</span>:</div>
<div class="line"> <a class="code" href="classwx_string.html" title="String class for passing textual data to or receiving it from wxWidgets.">wxString</a> m_wrapped;</div>
<div class="line"> };</div>
<div class="line"></div>
<div class="line"> HardBreakWrapper wrapper(win, text, widthMax);</div>
<div class="line"> <span class="keywordflow">return</span> wrapper.GetWrapped();</div>
<div class="line">}</div>
</div><!-- fragment --><h2></h2>
<div><span class="lib">Library:</span>  <span class="lib_text">None; this class implementation is entirely header-based.</span></div><div><span class="category">Category:</span>  <span class="category_text"><a class="el" href="group__group__class__gdi.html">Graphics Device Interface (GDI)</a></span></div> </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:af2d0767c838907b326dc9ea362b60314"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_text_wrapper.html#af2d0767c838907b326dc9ea362b60314">wxTextWrapper</a> ()</td></tr>
<tr class="memdesc:af2d0767c838907b326dc9ea362b60314"><td class="mdescLeft"> </td><td class="mdescRight">Trivial default constructor. <a href="#af2d0767c838907b326dc9ea362b60314"></a><br/></td></tr>
<tr class="separator:af2d0767c838907b326dc9ea362b60314"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:afa7189141b03d3f3e41b77f32e501a94"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_text_wrapper.html#afa7189141b03d3f3e41b77f32e501a94">Wrap</a> (<a class="el" href="classwx_window.html">wxWindow</a> *win, const <a class="el" href="classwx_string.html">wxString</a> &text, int widthMax)</td></tr>
<tr class="memdesc:afa7189141b03d3f3e41b77f32e501a94"><td class="mdescLeft"> </td><td class="mdescRight">Wrap the given text. <a href="#afa7189141b03d3f3e41b77f32e501a94"></a><br/></td></tr>
<tr class="separator:afa7189141b03d3f3e41b77f32e501a94"><td class="memSeparator" colspan="2"> </td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr class="memitem:a0494d2803dd8471f3f96b3ef7febbb45"><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_text_wrapper.html#a0494d2803dd8471f3f96b3ef7febbb45">OnOutputLine</a> (const <a class="el" href="classwx_string.html">wxString</a> &line)=0</td></tr>
<tr class="memdesc:a0494d2803dd8471f3f96b3ef7febbb45"><td class="mdescLeft"> </td><td class="mdescRight">Called by <a class="el" href="classwx_text_wrapper.html#afa7189141b03d3f3e41b77f32e501a94" title="Wrap the given text.">Wrap()</a> for each wrapped line of text. <a href="#a0494d2803dd8471f3f96b3ef7febbb45"></a><br/></td></tr>
<tr class="separator:a0494d2803dd8471f3f96b3ef7febbb45"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a71ef5470d0e0066c8b5d3372d8df5fd7"><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_text_wrapper.html#a71ef5470d0e0066c8b5d3372d8df5fd7">OnNewLine</a> ()</td></tr>
<tr class="memdesc:a71ef5470d0e0066c8b5d3372d8df5fd7"><td class="mdescLeft"> </td><td class="mdescRight">Called at the start of each subsequent line of text by <a class="el" href="classwx_text_wrapper.html#afa7189141b03d3f3e41b77f32e501a94" title="Wrap the given text.">Wrap()</a>. <a href="#a71ef5470d0e0066c8b5d3372d8df5fd7"></a><br/></td></tr>
<tr class="separator:a71ef5470d0e0066c8b5d3372d8df5fd7"><td class="memSeparator" colspan="2"> </td></tr>
</table>
<h2 class="groupheader">Constructor & Destructor Documentation</h2>
<a class="anchor" id="af2d0767c838907b326dc9ea362b60314"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">wxTextWrapper::wxTextWrapper </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Trivial default constructor. </p>
</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="a71ef5470d0e0066c8b5d3372d8df5fd7"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">virtual void wxTextWrapper::OnNewLine </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span><span class="mlabel">virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Called at the start of each subsequent line of text by <a class="el" href="classwx_text_wrapper.html#afa7189141b03d3f3e41b77f32e501a94" title="Wrap the given text.">Wrap()</a>. </p>
<p>This method may not be called at all if the entire text passed to <a class="el" href="classwx_text_wrapper.html#afa7189141b03d3f3e41b77f32e501a94" title="Wrap the given text.">Wrap()</a> fits into the specified width. </p>
</div>
</div>
<a class="anchor" id="a0494d2803dd8471f3f96b3ef7febbb45"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">virtual void wxTextWrapper::OnOutputLine </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="classwx_string.html">wxString</a> & </td>
<td class="paramname"><em>line</em></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span><span class="mlabel">pure virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Called by <a class="el" href="classwx_text_wrapper.html#afa7189141b03d3f3e41b77f32e501a94" title="Wrap the given text.">Wrap()</a> for each wrapped line of text. </p>
<p>This method will always be called at least once by <a class="el" href="classwx_text_wrapper.html#afa7189141b03d3f3e41b77f32e501a94" title="Wrap the given text.">Wrap()</a>. Notice that <em>line</em> may be empty if the text passed to <a class="el" href="classwx_text_wrapper.html#afa7189141b03d3f3e41b77f32e501a94" title="Wrap the given text.">Wrap()</a> was empty itself. </p>
</div>
</div>
<a class="anchor" id="afa7189141b03d3f3e41b77f32e501a94"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void wxTextWrapper::Wrap </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classwx_window.html">wxWindow</a> * </td>
<td class="paramname"><em>win</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="classwx_string.html">wxString</a> & </td>
<td class="paramname"><em>text</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>widthMax</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Wrap the given text. </p>
<p>This method will call <a class="el" href="classwx_text_wrapper.html#a0494d2803dd8471f3f96b3ef7febbb45" title="Called by Wrap() for each wrapped line of text.">OnOutputLine()</a> for every line of wrapped text and <a class="el" href="classwx_text_wrapper.html#a71ef5470d0e0066c8b5d3372d8df5fd7" title="Called at the start of each subsequent line of text by Wrap().">OnNewLine()</a> before the beginning of every new line after the first one (so it might be never called at all if the width of entire <em>text</em> is less than <em>widthMax</em>).</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">win</td><td>A non-<span class="literal">NULL</span> window used for measuring the text extents. </td></tr>
<tr><td class="paramname">text</td><td>The text to wrap. </td></tr>
<tr><td class="paramname">widthMax</td><td>Maximal width of each line of text or <code>-1</code> to disable wrapping. </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>
|