TTextGraphic encapsulates a TTextDisplay; you can construct a TTextGraphic from a TTextDisplay, or directly from a text object. If you construct a TTextGraphic from a text object, you can also specify:
For example, this code shows how to create a simple text graphic and rotate it around its center, drawing it into the TGrafPort thePort
:
TStandardText theText( "Hello World" ); TFontPointSizeStyle size = TFontPointSizeStyle( 24.0 ); theText.AddStyles( size ) TTextGraphic theTextGraphic( theText, TGPoint( 100, 100 ) ); TGrafMatrix aMatrix; TGRect bounds = theTextGraphic.GetGeometricBounds(); aMatrix.RotateBy( 45, bounds.GetCenter() ); theTextGraphic.TransformBy( aMatrix ); theTextGraphic.Draw( thePort );
NOTE The MGraphic inheritance requires TTextGraphic to adopt a TGrafBundle. TTextGraphic does not define any default usage for the graf bundle, so the TTextGraphic::AdoptBundle function just deletes the bundle to avoid the unnecessary overhead of storing it.