CHAPTER 4: Graphics Graphic attributes 131
Solution
Check whether there is a selection suite (for example, IStrokeAttributeSuite) that you can use. If nothing is
selected, calling a selection suite changes defaults (the graphics state).
Alternatively, look at utility methods in IGraphicStateUtils, such as ProcessGfxStateApplyAttribute or
ProcessGfxStateAddMultAttributes, with the specific graphic attribute boss or attribute list passed in.
Otherwise, create appropriate commands. For rendering attributes, use kUpdateDefRenderDataCmdBoss
and kPrivateSetGSRenderDataCmdBoss; for other attributes, use kGfxStateChangeAttributeCmdBoss. You
also can use kAddMultAttributesCmdBoss to set any number of attributes. Fill in suitable command data
and process the command.
Related APIs
IGraphicStateUtils
IGraphicStyleAttributeBossList
IStrokeAttributeSuite
Applying gill color or a gradient to a page item
You can fill a layout page item with color.
Solution
Follow the procedure in “Applying graphic attributes to the active selection” or “Applying one graphic
attribute to page items”.
To fill page items that are selected, use the IGraphicAttributeSuite::ChangeFillRenderObject(ClassID
renderClassID, UID renderUID) method, where renderClass is kPMColorBoss or
kGradientRenderingObjectBoss, and renderUID is the UID of the color or gradient swatch.
Alternatively, to fill arbitrary page items, use utilities and commands as follows:
1. Create a kBoss_GfxStateApplyROAttributeCmd command.
2. The graphic attribute boss class kGraphicStyleFillRenderingAttrBoss represents the fill associated with
a graphic page item in the layout. This boss class aggregates the interface IPersistUIDRefData (with
interface identifier of IID_IPERSISTUIDDATA), which holds the UID of the fill color.
3. The command boss aggregates an IPMUnknownData interface. This needs to be populated with a
reference to an attribute boss object created in the previous step. Fill in other information of the
command data with IApplyRendObjAttrCmdData. You also can get the command filled with
command data by using the utility method IGraphicAttributeUtils::CreateFillRenderingCommand or
IGraphicStateUtils::CreateGfxApplyOverrideCommand, passing in rendering class ID, rendering UID,
and attribute boss class ID (in this case, kGraphicStyleFillRenderingAttrBoss).
4. Process the command.