diff -r 80ef3a206772 -r 48780e181b38 Symbian3/SDK/Source/GUID-6DF52DDC-B03C-5971-94C8-0E9BAAB949FD.dita --- a/Symbian3/SDK/Source/GUID-6DF52DDC-B03C-5971-94C8-0E9BAAB949FD.dita Fri Jul 16 17:23:46 2010 +0100 +++ b/Symbian3/SDK/Source/GUID-6DF52DDC-B03C-5971-94C8-0E9BAAB949FD.dita Tue Jul 20 12:00:49 2010 +0100 @@ -9,7 +9,7 @@ --> -Drawing Text

This topic provides examples that demonstrate how to draw a line of text and text in a colored box.

Text

The basic way to draw text is to call CGraphicsContext::DrawText() with a point specifying the bottom left position, as shown below:

Before calling, you must use the graphics context to:

  1. Set the font to use

  2. Set the pen color for the text

// In this example, we use one of the standard font styles +Drawing Text

This topic provides examples that demonstrate how to draw a line of text and text in a colored box.

Text

The basic way to draw text is to call CGraphicsContext::DrawText() with a point specifying the bottom left position, as shown below:

Before calling, you must use the graphics context to:

  1. Set the font to use

  2. Set the pen color for the text

// In this example, we use one of the standard font styles CFont* fontUsed = iEikonEnv->TitleFont(); gc.UseFont(fontUsed); @@ -17,7 +17,7 @@ TPoint pos(50,50); _LIT(KExampleText,"blacktext"); -gc.DrawText(KExampleText,pos);
Text in a box

To draw text in a box, you must specify:

  • a rectangle to draw the text in

  • an offset from the top of the rectangle to the text baseline: to center the text, add half the height of the rectangle to half the height of the font's ascent

  • the text alignment mode: in the example, left alignment is used

  • a margin: the left margin for left-aligned text, or the right margin for right-aligned text

The following figure show how these fit together:

In addition to the font and pen color, you can also set the brush for filling the box.

... +gc.DrawText(KExampleText,pos);
Text in a box

To draw text in a box, you must specify:

  • a rectangle to draw the text in

  • an offset from the top of the rectangle to the text baseline: to center the text, add half the height of the rectangle to half the height of the font's ascent

  • the text alignment mode: in the example, left alignment is used

  • a margin: the left margin for left-aligned text, or the right margin for right-aligned text

The following figure show how these fit together:

In addition to the font and pen color, you can also set the brush for filling the box.

... // Draw some text left justified in a box, // Offset so text is just inside top of box