The constructors for TSolidPen are shown below. The empty constructor creates a TSolidPen instance with all values set to NIL.
TSolidPen(); TSolidPen( const TSolidPen& ); TSolidPen( GCoordinate penWidth, EPenBalance balance );
balance: This enumerated parameter has the following values:
The code fragment creates the polygons with a wide black frames in Figure 103. The pen width is 10 worldcoordinate units. The polygon is created three times using a different pen balance each time. A centered pen balance is used first, followed by the inset pen balance, and the outset pen balance shown in Figure 103 from left to right.
To keep the code concise, the second and third polygons are not translated before being drawn so that they draw next to each other the way the do in the figure.
1 TColorPaint* blackFrame = new TColorPaint( TRGBColor( 0, 0, 0 ) ); 2 TGrafBundle* polyBundle = new TGrafBundle( blackFrame, TAttributeState::kFrame ); 3 4 TGPolygon aPolygonGeometry; 5 aPolygonGeometry.Append( TGPoint( 90, 55 ) ); 6 aPolygonGeometry.Append( TGPoint( 100, 125 ) ); 7 aPolygonGeometry.Append( TGPoint( 225, 75 ) ); 8 9 TPolygon* aPolygon = new TPolygon( aPolygonGeometry, polyBundle ); 10 11 TSolidPen* centerFramePen = new TSolidPen( 10, TPen::kCenterFrame ); 12 polyBundle->AdoptFramePen( centerFramePen ); 13 14 aPolygon->Draw( thePort ); 15 16 TSolidPen* insetFramePen = new TSolidPen( 10, TPen::kInsetFrame ); 17 polyBundle->AdoptFramePen( insetFramePen ); 18 19 aPolygon->Draw( thePort ); 20 21 TSolidPen* outsetFramePen = new TSolidPen( 10, TPen::kOutsetFrame ); 22 polyBundle->AdoptFramePen( outsetFramePen ); 23 24 aPolygon->Draw( thePort );
Lines 4 through 7: Create the polygon geometry.
Line 8: Create the polygon graphic from the geometry and the bundle.
Lines 11 and 12: Create a centered pen that is 10 world-coordinate units wide.
Line 14: Draw the polygon.
Lines 16 and 17: Create an inset pen that is 10 world-coordinate units wide.
Line 19: Draw the polygon.
Lines 21 and 22: Create an outset pen that is 10 world-coordinate units wide.
Line 24: Draw the polygon.