Drawing a Static Text String

Use IGraphicText to display styled text strings as static graphics. IGraphicText currently displays text as a single line, ignoring text following any new-line characters.

To draw a static text string:

  1. Create an IGraphicText instance, specifying the text to draw.
  2. Call the IGraphicText::setLocation function, passing in the point representing the position at which to begin drawing. This point is the baseline of the text.
  3. Call the IGraphicText::draw function, passing in the port to draw the text to.

For example, this code shows a simple drawContents function for a view that draws static styled text:

bool

IHelloWorldView::drawContents (IGrafPort& port) const

{

	IText string("Hello World!");

	string.addStyles(ITextTypeFaceStyle("Helvetica"));

	string.addStyles(ITextPointSizeStyle(18), 0, 5);

	

	IGraphicText hello(string, IGraphicText::kSingleLine);

	hello.setLocation(IGPoint2D(30, 30));

	hello.draw(port);

	return true;

}