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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transistional//EN"><html><head><title>OpenLayer Offline Manual</title><style type="text/css" media="all">@import "../CrystalStyle.css";</style><body bgcolor="FFFFFF" ><div align="center" style="pagestyle"><table width="60%"><tr><td><div class="parentLinks"><a href="../index.html">OpenLayer</a> | <a href="../TextRenderer.html">TextRenderer</a> | <a href="../TextRenderer/Print.html">Print</a></div><br><div class="BigHeader">Print</div><br><div class=""><div class="Surrounded"><table><tr valign="top"><td align="right"><div class="FuncDef"><strong><font color="#777733">void</font> <a href="../TextRenderer/Print.html"><font color="#0000CC">Print</font></a>(</strong></div></td><td><div class="FuncDef"><strong><font color="#777733">const</font> std::string &text, <font color="#777733">int</font> x, <font color="#777733">int</font> baselineY ) <font color="#777733">const</font>;
<br></strong></div></td></tr></table>
<br>Prints the given (multi-lined) text to the screen at the given coordinates.
<br></div>
<br><div class="Surrounded"><table><tr valign="top"><td align="right"><div class="FuncDef"><strong><font color="#777733">void</font> <a href="../TextRenderer/Print.html"><font color="#0000CC">Print</font></a>(</strong></div></td><td><div class="FuncDef"><strong><font color="#777733">const</font> std::string &text, <font color="#777733">int</font> x, <font color="#777733">int</font> baselineY,
<br><font color="#777733">int</font> maxLineWidth, TextAlignment alignment = LEFT ) <font color="#777733">const</font>;
<br></strong></div></td></tr></table>
<br>Prints the text with automatic line wrapping and alignment. The maxLineWidth tells the maxium width of a text line in pixels. Lines wider than maxLineWidth will be cut to several lines. Possible text alignments are:
<br>
<br>* <i>LEFT</i> - Align the text lines to the left
<br>* <i>CENTER</i> - Center the text lines
<br>* <i>RIGHT</i> - Align the text lines to the right
<br>* <i>JUSTIFY</i> - Stretch the full text lines to fill the entire maxLineWidth
<br></div>
<br>Note that the y-coordinate is the y-coordinate of the baseline of the first text line, not the top position of the text (changed from the previous version)!
<br>
<br>All coordinates are in pixels. Note that you can print multi-lined text such that the end of a line is marked with an endline character (\n).
<br>
<br>Also notice that for performance reasons the function takes a reference to the printed text. This means that you have to construct a text variable first and then pass it to this function.
<br>
<br>OpenLayer contains a function ToString that converts a variable (number, for example) to a string so that it can be passed to the <a href="../TextRenderer/Print.html"><font color="#0000CC">Print</font></a> -function. See the examples of how to do this.</div><br><div class="MediumHeader">Examples</div><br><div class="Code"><a href="../TextRenderer.html"><font color="#0000CC">TextRenderer</font></a> myTextRenderer(...);
<br>
<br><font color="#999922">// Print the text Hello World! to the screen such that the //</font>
<br><font color="#999922">// top-left corner of the text is positioned at //</font>
<br><font color="#999922">// x = 200 and y-coodinate of the baseline = 110 //</font>
<br>String message = <font color="#CC0000">"Hello World!"</font>;
<br>myTextRenderer.<a href="../TextRenderer/Print.html"><font color="#0000CC">Print</font></a>( message, <font color="#994400">200</font>, <font color="#994400">110</font> );
<br>
<br><font color="#999922">// Print a multi-lined message at the same position in the screen //</font>
<br>String message = <font color="#CC0000">"First line\nSecond line\nThird line"</font>;
<br>myTextRenderer.<a href="../TextRenderer/Print.html"><font color="#0000CC">Print</font></a>( message, <font color="#994400">200</font>, <font color="#994400">110</font> );
<br>
<br><font color="#999922">// Print a number in the screen //</font>
<br><font color="#777733">int</font> number = <font color="#994400">500</font>;
<br>String message = ToString( number );
<br>myTextRenderer.<a href="../TextRenderer/Print.html"><font color="#0000CC">Print</font></a>( message, <font color="#994400">200</font>, <font color="#994400">110</font> );
<br>
<br><font color="#999922">// Print a long text in the screen with automatic line wrappings so that //</font>
<br><font color="#999922">// the maxium width of a text line is 300 pixels and justify the text //</font>
<br>String <font color="#777733">long</font>Text = <font color="#CC0000">"This is a very, very long text which will be automatically "</font>
<br> + <font color="#CC0000">"wrapped to several lines thanks to the overloaded version of the "</font>
<br> + <font color="#CC0000">"text rendering function!"</font>
<br>myTextRenderer.<a href="../TextRenderer/Print.html"><font color="#0000CC">Print</font></a>( <font color="#777733">long</font>Text , <font color="#994400">200</font>, <font color="#994400">110</font>, <font color="#994400">300</font>, JUSTIFY );
<br>
<br>
<br><font color="#999922">// Print a some text and two numbers in the screen //</font>
<br><font color="#777733">int</font> number1 = <font color="#994400">500</font>;
<br><font color="#777733">float</font> number2 = <font color="#994400">750.5</font>;
<br>
<br>String message = <font color="#CC0000">"The first number is "</font> + ToString( number1 ) +
<br> <font color="#CC0000">" and the second number is "</font> + ToString( number2 );
<br>
<br><font color="#999922">// message is: The first number is 500 and the second number is 750.5 //</font>
<br>myTextRenderer.<a href="../TextRenderer/Print.html"><font color="#0000CC">Print</font></a>( message, <font color="#994400">200</font>, <font color="#994400">110</font> );</div><div class=""><br><br><div class="MediumHeader">Other functions of the class <a href="../TextRenderer.html"><font color="#0000CC">TextRenderer</font></a></div><div class="Surrounded"><table size="100%" cellpadding="0" cellspacing="0"><tr><td halign="center" class="funclist"><a href="../TextRenderer/Load.html">Load</a></td><td width="65%" halign="center"><div class="smalltext">Load the font</div></td></tr><tr><td halign="center" class="funclist"><a href="../TextRenderer/Print.html">Print</a></td><td width="65%" halign="center"><div class="smalltext">Prints the given text to the screen</div></td></tr><tr><td halign="center" class="funclist"><a href="../TextRenderer/SetColor.html">SetColor</a></td><td width="65%" halign="center"><div class="smalltext">
Sets the color of the font</div></td></tr><tr><td halign="center" class="funclist"><a href="../TextRenderer/GetColor.html">GetColor</a></td><td width="65%" halign="center"><div class="smalltext">
Returns the text color of the font</div></td></tr><tr><td halign="center" class="funclist"><a href="../TextRenderer/SetItalics.html">SetItalics</a></td><td width="65%" halign="center"><div class="smalltext">
Sets the italics angle of the text</div></td></tr><tr><td halign="center" class="funclist"><a href="../TextRenderer/GetItalics.html">GetItalics</a></td><td width="65%" halign="center"><div class="smalltext">
Returns the italics angle of the text</div></td></tr><tr><td halign="center" class="funclist"><a href="../TextRenderer/Width.html">Width</a></td><td width="65%" halign="center"><div class="smalltext">
Returns the width of the given text</div></td></tr><tr><td halign="center" class="funclist"><a href="../TextRenderer/Height.html">Height</a></td><td width="65%" halign="center"><div class="smalltext">
Returns the height of the given text</div></td></tr><tr><td halign="center" class="funclist"><a href="../TextRenderer/FirstLineWidth.html">FirstLineWidth</a></td><td width="65%" halign="center"><div class="smalltext">
Returns the width of the first text line of the given text</div></td></tr><tr><td halign="center" class="funclist"><a href="../TextRenderer/FirstLineHeight.html">FirstLineHeight</a></td><td width="65%" halign="center"><div class="smalltext">
Returns the height of the first text line of the given text</div></td></tr><tr><td halign="center" class="funclist"><a href="../TextRenderer/IsValid.html">IsValid</a></td><td width="65%" halign="center"><div class="smalltext">
Checks if the TextRenderer was loaded correctly</div></td></tr><tr><td colspan="2"><br><div class="SmallHeader"><font color="#775500">Advanced functions</font></div><br></td></tr><tr><td halign="center" class="funclist"><a href="../TextRenderer/GetFace.html">GetFace</a></td><td width="65%" halign="center"></td></tr><tr><td halign="center" class="funclist"><a href="../TextRenderer/SendToGPU.html">SendToGPU</a></td><td width="65%" halign="center"></td></tr><tr><td halign="center" class="funclist"><a href="../TextRenderer/UnloadFromGPU.html">UnloadFromGPU</a></td><td width="65%" halign="center"></td></tr><tr><td halign="center" class="funclist"><a href="../TextRenderer/UseAutoDelete.html">UseAutoDelete</a></td><td width="65%" halign="center"></td></tr></table></div><br><div class=""><a href="../index.html">Back to the main page of the manual</a></div><br>Questions about Print? Click <a href="http://crystalstorm.ath.cx/index.php?lan=en&page=CreateFeedback&subject=Print">here.</a></div></td></tr></table></body></html>
|