0% found this document useful (0 votes)
37 views

Solutions 131

This document discusses applying graphic attributes, such as color or gradients, to page items in layout. It provides three main solutions: 1) Using a selection suite to apply attributes to selected items, 2) Using utility methods to apply attributes to arbitrary items, specifying the attribute boss and command boss, 3) Creating appropriate commands directly, using the fill rendering attribute boss and command data classes to apply a color or gradient fill.

Uploaded by

Charana Studios
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Solutions 131

This document discusses applying graphic attributes, such as color or gradients, to page items in layout. It provides three main solutions: 1) Using a selection suite to apply attributes to selected items, 2) Using utility methods to apply attributes to arbitrary items, specifying the attribute boss and command boss, 3) Creating appropriate commands directly, using the fill rendering attribute boss and command data classes to apply a color or gradient fill.

Uploaded by

Charana Studios
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

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.

You might also like