Name

RichText — Static text with HTML-like formatting

Synopsis

RichText ( string text );
 

Parameters

string text

Options

plainText

don't interpret text as HTML

autoScrollDown

automatically scroll down for each text change

shrinkable

make the widget very small

Description

A RichText is a text area with two major differences to a Label: The amount of data it can contain is not restricted by the layout and a number of control sequences are allowed, which control the layout of the text.

Usage

 	`RichText( "This is a bold text" )

Examples

          // Example for a RichText widget
{
    UI::OpenDialog( `opt(`defaultsize),
		`VBox(
		      `RichText( "<h3>RichText example</h3>"
				 + "<p>This is a <i>RichText</i> widget.</p>"
				 + "<p>It's very much like <i>HTML</i>, but not quite as powerful.</p>"
				 + "<p><b>bold</b> and <i>italic</i> you can rely on.</p>"
				 + "<p>"
				 + "<font color=blue>colored	</font>"
				 + "<font color=red>	text 	</font>"
				 + "<font color=green>	might 	</font>"
				 + "<font color=magenta>	or 	</font>"
				 + "<font color=cyan>	might 	</font>"
				 + "<font color=blue>	not	</font>"
				 + "<font color=red>	be	</font>"
				 + "<font color=green>	available,</font>"
				 + "<font color=magenta>	depending	</font>"
				 + "<font color=cyan>	on		</font>"
				 + "<font color=blue>	the		</font>"
				 + "<font color=red>	UI.		</font>"
				 + "</p>"
				 + "<p>The product name is automatically replaced by the UI. "
				 + "Use the special macro <b>&amp;product;</b> for that."
				 + "</p><p>"
				 + "The current product name is <b>&product;</b>."
				 + "</p>"
				 ),
		      `PushButton(`opt(`default), "&OK")
		      )
	     );
  UI::UserInput();
  UI::CloseDialog();
}

        
          // Example for a RichText widget
{
    UI::OpenDialog( `opt(`defaultsize),
		`VBox(
		      `RichText(`opt(`plainText),
				"This is a RichText in   plainText   mode.\n"
				+"No HTML tags are supported here, but line breaks\n"
				+"are output literally - as are HTML tags like <b> or <i> or &product;."
				),
		      `PushButton(`opt(`default), "&OK")
		      )
		);
  UI::UserInput();
  UI::CloseDialog();
}

        
          // Example for a RichText widget
{
    UI::OpenDialog( `opt(`defaultsize),
		`VBox(
		      `RichText( "<h3>RichText example</h3>"
				 + "<p>This is a <i>RichText</i> widget. The ncurses UI wraps lines automatically - Qt breaks lines and uses a vertical scroll bar.</p>"
				 + "<p>It's very much like <i>HTML</i>, but not quite as powerful.</p>"
				 + "<p>Text in <b>pre</b> tags preserves newlines and spaces.</p>"
				 + "<pre>"
				 + "     host     ip adress       host     ip adress\n"
				 + "     sturm    10.10.0.159     sturm    10.10.0.159\n"
				 + "Lines are not wrapped; in text mode HTML tags are <b>not</b> removed if the pre tag is used.\n"
				 + "</pre>"
				 + "<p>After   <b>/pre</b>    the  text is <i>HTML</i> text like before.</p>"
				 + "<p>Much much more text .............. continous"
				 + " much much more text .... follows "
				 + " much much more text .................</p>"
				 + "<p>"
				 + "<pre>another    pre      t	t	</pre>"
				 + "and much more text hopefully now displayed correctly"
				 + "</p>"
                                 + "<pre>"
				 + "     host     ip adress       host     ip adress\n"
				 + "     sturm    10.10.0.159     sturm    10.10.0.159\n"
				 + "Lines are not wrapped; in text mode HTML tags are <b>not</b> removed if the pre tag is used.\n"
				 + "</pre>"
				 + "<p>and even much more text but now not wrapped at old place but with new layout of the pad widget which is underlying the richtext widget</p>"
				 + "<p><pre>And   another  short  pre</pre></p>"
				 ),
		      `PushButton(`opt(`default), "&OK")
		      )
	     );
  UI::UserInput();
  UI::CloseDialog();
}

        
          // Example for a RichText widget with hyperlinks
{
    UI::OpenDialog( `opt(`defaultsize),
		`VBox(
		      `RichText( "<h3>RichText example</h3>"
				 + "<p>RichText may contain <a href=\"hyper\">hyperlinks</a>,"
				 + "very much like HTML.</p>"
				 + "<p>Clicking on a <a href=\"link\">link</a> will make "
				 + "<a href=\"user_input\">UI::UserInput()</a> return "
				 + "with the <i>href</i> part of the hyperlink "
				 + "as a (string) return value.</p>"
				 + "<h3>Known (HTML-like) entities</h3>"
				 + "<ul>"
				 + "<li><b>&amp;product;</b> for the product name (<b>&product;</b>)"
				 + "<li><b>&amp;amp;</b> for <b>&amp;</b>"
				 + "<li><b>&amp;lt;</b> for <b>&lt;</b>"
				 + "<li><b>&amp;gt;</b> for <b>&gt;</b>"
				 + "</ul>"
				 ),
		      `HBox(
			    `Label( "You clicked: " ),
			    `Label(`id(`val), `opt(`outputField, `hstretch), "" )
			    ),
		      `PushButton(`id(`close), `opt(`default), "&Close")
		      )
		);


    any ret = nil;

    repeat
    {
	ret = UI::UserInput();

	if ( ret != nil )
	{
	    string val = sformat( "%1", ret );
	    UI::ChangeWidget(`id(`val), `Value, val );
	}
	
    } until ( ret == `close );
    
    UI::CloseDialog();
}