### Attribute and Bundle Classes

### IAttributeState

IAttributeState is an abstract base class that defines drawing attributes for 2D graphics.

The figure shows the 2D attribute bundle classes derived from the abstract base class IAttributeState. IAttributeState has pure virtual data accessor functions to retrieve information about the attributes and drawing operation for the bundle. The drawing operation determines whether the bundle provides fills, frames, or fills and frames.

### IGrafBundle

IGrafBundle is a collection of attributes that contains imaging information for the graphic rendering device. IGrafBundle is derived from IAttributeState and can include:

- Fill and frame attributes
- Image attributes

#### Fill and Frame Attributes

The fill is a color that spreads over the interior of the geometry, and the frame is the color and line that outlines the border of the geometry. The draw operation tells the rendering device to fill the geometry, frame the geometry, or fill and frame the geometry, as shown in the figure:

The most frequently used attributes are fill paint, frame paint, pen, and draw operations. These attributes each have their own constructors. IPaint is the class used for specifying the fill paint and the frame paint. EDrawOperation is an enumerated type, defined in IAttributeState, used to specify frame only, fill only, or fill and frame operations for a given geometry. The following example specifies frame only:

> IGrafBundle(const IPaint& fPaint,
> IAttributeState::EDrawOperation attribute = kFrame);

If attribute equals kFrame, the paint is for framing; if attribute equals kFill, the paint is for filling; and if attribute equals kFillAndFrame, the paint is used for both fill and frame. The following example specifies different paint for filling and framing respectively:

> IGrafBundle(const IPaint& fillPaint,
> const IPaint& framePaint,
> IAttributeState::EDrawOperation attribute = kFillAndFrame);

The IBaseColor class specifies the color in IPaint. IBasic color can construct IPaint as a parameter. In the following example, constructors take IBaseColor as a parameter instead of referencing instances of IPaint:

> IGrafBundle(const IBaseColor& fillColor,
> const IBaseColor& frameColor,
> IAttributeState::EDrawOperation attribute = kFillAndFrame);

NOTE: The constructors in this example have the same semantics as the previous constructors except that IPaint is created by the constructor on the default heap.

Functions are available to add, remove, and change the standard fill, frame and draw attributes. The function for the drawing operations attribute is as follows:

> virtual IAttributeState::EDrawOperation drawingOperation() const;
> virtual void setDrawingOperation(IAttributeState::EDrawOperation);

The function for the fill paint attribute is as follows:

> virtual const IPaint* fillPaint() const;
> virtual void setFillPaint(const IPaint& paint);

The function for the frame paint attribute is as follows:

> virtual const IPaint* framePaint() const;
> virtual void setFramePaint(const IPaint& paint);

For convenience, in addition to the functions for fill and frame, the IPaint attribute provides the following data accessors of the IBaseColor fill and frame elements:

> virtual const IBaseColor* fillColor() const;
> virtual void setFillColor(const IBaseColor& color);
> virtual const IBaseColor* frameColor() const;
> virtual void setFrameColor(const IBaseColor& color);

The function for the fill paint transfer mode attribute is as follows:

> virtual const IColorTransferMode* fillTransferMode() const;
> virtual void setFillTransferMode(const IColorTransferMode&);

The function for the frame paint transfer mode attribute is as follows:

> virtual const IColorTransferMode* frameTransferMode() const;
> virtual void setFrameTransferMode(const IColorTransferMode&);

The function for the frame pen attribute is as follows:

> virtual const IPen* framePen() const;
> virtual void setFramePen(const IPen&);

The function for the frame end cap attribute is as follows:

> virtual const ICap* frameEndCap() const;
> virtual void setFrameEndCap(const ICap&);

The function for the frame joint attribute is as follows:

> virtual const IJoint* frameJoint() const;
> virtual void setFrameJoint(const IJoint&);

#### Image Attributes

IGrafBundle has the following functions to add, remove, and change the standard image attribute.

The function for the image transfer attribute is as follows:

> virtual const IImageTransferMode* imageTransferMode() const;
> virtual void setImageTransferMode(const IImageTransferMode&);

The function for the image sampling control attribute is as follows:

> virtual const IImageSamplingControl* imageSampling() const;
> virtual void setImageSampling(const IImageSamplingControl&);

The image transfer mode and the image sampling control apply for the geometry of both IGImage and the IGImage set in IPaint for image pattern fill.

### Special Purpose Attribute Bundles

While IGrafBundle provides more functionality than the special purpose attribute bundles by allowing you to specify transfer mode and image sampling settings for 2D image graphics, special purpose bundles are still provided. These classes are easy to construct and use. The supported special purpose attribute bundle classes are IFillBundle, IFrameBundle, and IFillAndFrameBundle.

#### IFillBundle

The color is applied to the fill only, and one constructor lets you pass a transfer mode that is applied to the fill color.

> IFillBundle (const IBaseColor& fillColor);
> IFillBundle (const IBaseColor& fillColor, const IColorTransferMode& transferMode);

#### IFrameBundle

These constructors have default pen width and pen balance values. The color is applied to the frame only and one constructor lets you pass a transfer mode that is applied to the frame color.

> IFrameBundle ( const IBaseColor& frameColor,
> GCoordinate penwidth = 1,
> IPen::EPenBalance balance = IPen::kCenteredFrame );

> IFrameBundle ( const IBaseColor& frameColor,
> const IColorTransferMode& transferMode,
> GCoordinate penWidth = 1,
> IPen::EPenBalance balance = IPen::kCenteredFrame );

#### IFillandFrameBundle

These constructors have default pen width and pen balance values. The colors are applid to the fill and frame, and one constructor lets you pass two transfer modes. One transfer mode is applied to the fill color and the other is applied to the frame color.

> IFillandFrameBundle ( const IBaseColor& fillColor,
> IBaseColor& frameColor,
> GCoordinate penwidth = 1,
> IPen::EPenBalance balance = IPen::kCenteredFrame );

> IFillandFrameBundle ( const IBaseColor& fillColor,
> const IColorTransferMode& fillTransferMode,
> IBaseColor& frameColor,
> const IColorTransferMode& frameTransferMode,
> GCoordinate penWidth = 1,
> IPen::EPenBalance balance = IPen::kCenteredFrame );